--- deliantra/server/ext/widget.ext 2007/09/01 07:22:20 1.19 +++ deliantra/server/ext/widget.ext 2007/12/27 18:35:48 1.20 @@ -5,6 +5,7 @@ # ws_n ws # widgetset new # ws_d ws # widgetset destroy # ws_c ws id class @args # widgetset create +# ws_ct ws templateface \%cfg # widgetset create from template # w_c id rid name @args # widget method call # w_s id @attr # widget member set # w_g id rid @attr # widget member get @@ -40,10 +41,22 @@ my $ws = $ns->{csc} = $ns->new_widgetset; - $ws->{tab} = $ws->new (Label => text => "dumb tst", c_tab => ["hull"]); + my ($tl, $entry) = $ws->template (undef, + toplevel => {}, + entry => { + text => "xyz", + on_changed => sub { + warn "changed<@_>\n";#d# + }, + }, + ); + + $tl->show; + + $ns->{xxxw} = [$tl, $entry];#d# - $ws->find ("setup_notebook")->add ($ws->{tab}); - $ws->find ("setup_dialog")->toggle_visibility; +# $ws->find ("setup_notebook")->add ($ws->{tab}); +# $ws->find ("setup_dialog")->toggle_visibility; } sub csc_start { @@ -106,7 +119,7 @@ return unless $ns->{can_widget}; #csc_start $ns; - #demo_start $ns; + demo_start $ns; }, ); @@ -208,6 +221,41 @@ $proxy } +sub template { + my ($self, $template, @args) = @_; + + my %cfg; + my @res; + + while (@args) { + my ($name, $args) = splice @args, 0, 2, (); + + my $proxy = $self->alloc; + + Scalar::Util::weaken ($self->{_w}{$proxy->{id}} = $proxy); + Scalar::Util::weaken ($proxy->{ws} = $self); + + for my $ev (grep /^on_/, keys %$args) { + $args->{$ev} = $proxy->{"_$ev"} = $proxy->cb ($args->{$ev}); + } + + $cfg{$name} = { + %$args, + id => $proxy->{id}, + }; + + push @res, $proxy; + } + + $self->msg (ws_ct => + $self->{id}, + $template, + \%cfg, + ); + + @res +} + sub find { my ($self, @names) = @_;