… | |
… | |
3 | # sends the following ext message types |
3 | # sends the following ext message types |
4 | # ws_a id name... # associate well-known widget with given id |
4 | # ws_a id name... # associate well-known widget with given id |
5 | # ws_n ws # widgetset new |
5 | # ws_n ws # widgetset new |
6 | # ws_d ws # widgetset destroy |
6 | # ws_d ws # widgetset destroy |
7 | # ws_c ws id class @args # widgetset create |
7 | # ws_c ws id class @args # widgetset create |
|
|
8 | # ws_ct ws templateface \%cfg # widgetset create from template |
8 | # w_c id rid name @args # widget method call |
9 | # w_c id rid name @args # widget method call |
9 | # w_s id @attr # widget member set |
10 | # w_s id @attr # widget member set |
10 | # w_g id rid @attr # widget member get |
11 | # w_g id rid @attr # widget member get |
11 | # |
12 | # |
12 | # and expects the following exti message types |
13 | # and expects the following exti message types |
… | |
… | |
38 | sub demo_start { |
39 | sub demo_start { |
39 | my ($ns) = @_; |
40 | my ($ns) = @_; |
40 | |
41 | |
41 | my $ws = $ns->{csc} = $ns->new_widgetset; |
42 | my $ws = $ns->{csc} = $ns->new_widgetset; |
42 | |
43 | |
43 | $ws->{tab} = $ws->new (Label => text => "dumb tst", c_tab => ["hull"]); |
44 | my ($tl, $entry) = $ws->template (undef, |
|
|
45 | toplevel => {}, |
|
|
46 | entry => { |
|
|
47 | text => "xyz", |
|
|
48 | on_changed => sub { |
|
|
49 | warn "changed<@_>\n";#d# |
|
|
50 | }, |
|
|
51 | }, |
|
|
52 | ); |
|
|
53 | |
|
|
54 | $tl->show; |
|
|
55 | |
|
|
56 | $ns->{xxxw} = [$tl, $entry];#d# |
44 | |
57 | |
45 | $ws->find ("setup_notebook")->add ($ws->{tab}); |
58 | # $ws->find ("setup_notebook")->add ($ws->{tab}); |
46 | $ws->find ("setup_dialog")->toggle_visibility; |
59 | # $ws->find ("setup_dialog")->toggle_visibility; |
47 | } |
60 | } |
48 | |
61 | |
49 | sub csc_start { |
62 | sub csc_start { |
50 | my ($ns) = @_; |
63 | my ($ns) = @_; |
51 | |
64 | |
… | |
… | |
104 | |
117 | |
105 | my $ns = $pl->ns; |
118 | my $ns = $pl->ns; |
106 | |
119 | |
107 | return unless $ns->{can_widget}; |
120 | return unless $ns->{can_widget}; |
108 | #csc_start $ns; |
121 | #csc_start $ns; |
109 | #demo_start $ns; |
122 | demo_start $ns; |
110 | }, |
123 | }, |
111 | ); |
124 | ); |
112 | |
125 | |
113 | cf::register_exticmd w_e => sub { |
126 | cf::register_exticmd w_e => sub { |
114 | my ($ns, $id, @args) = @_; |
127 | my ($ns, $id, @args) = @_; |
… | |
… | |
206 | ); |
219 | ); |
207 | |
220 | |
208 | $proxy |
221 | $proxy |
209 | } |
222 | } |
210 | |
223 | |
|
|
224 | sub template { |
|
|
225 | my ($self, $template, @args) = @_; |
|
|
226 | |
|
|
227 | my %cfg; |
|
|
228 | my @res; |
|
|
229 | |
|
|
230 | while (@args) { |
|
|
231 | my ($name, $args) = splice @args, 0, 2, (); |
|
|
232 | |
|
|
233 | my $proxy = $self->alloc; |
|
|
234 | |
|
|
235 | Scalar::Util::weaken ($self->{_w}{$proxy->{id}} = $proxy); |
|
|
236 | Scalar::Util::weaken ($proxy->{ws} = $self); |
|
|
237 | |
|
|
238 | for my $ev (grep /^on_/, keys %$args) { |
|
|
239 | $args->{$ev} = $proxy->{"_$ev"} = $proxy->cb ($args->{$ev}); |
|
|
240 | } |
|
|
241 | |
|
|
242 | $cfg{$name} = { |
|
|
243 | %$args, |
|
|
244 | id => $proxy->{id}, |
|
|
245 | }; |
|
|
246 | |
|
|
247 | push @res, $proxy; |
|
|
248 | } |
|
|
249 | |
|
|
250 | $self->msg (ws_ct => |
|
|
251 | $self->{id}, |
|
|
252 | $template, |
|
|
253 | \%cfg, |
|
|
254 | ); |
|
|
255 | |
|
|
256 | @res |
|
|
257 | } |
|
|
258 | |
211 | sub find { |
259 | sub find { |
212 | my ($self, @names) = @_; |
260 | my ($self, @names) = @_; |
213 | |
261 | |
214 | my @res; |
262 | my @res; |
215 | my @alloc; |
263 | my @alloc; |