ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/UI.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/UI.pm (file contents):
Revision 1.50 by root, Sun Apr 9 22:27:24 2006 UTC vs.
Revision 1.56 by root, Mon Apr 10 22:16:34 2006 UTC

7use SDL::OpenGL; 7use SDL::OpenGL;
8use SDL::OpenGL::Constants; 8use SDL::OpenGL::Constants;
9 9
10use Crossfire::Client; 10use Crossfire::Client;
11 11
12our ($FOCUS, $HOVER, $GRAB); # various widgets
13
14our $TOPLEVEL;
15our $BUTTON_STATE;
16
12# class methods for events 17# class methods for events
13sub feed_sdl_key_down_event { $::FOCUS->key_down ($_[0]) if $::FOCUS } 18sub feed_sdl_key_down_event {
14sub feed_sdl_key_up_event { $::FOCUS->key_up ($_[0]) if $::FOCUS } 19 $FOCUS->key_down ($_[0]) if $FOCUS;
20}
21
22sub feed_sdl_key_up_event {
23 $FOCUS->key_up ($_[0]) if $FOCUS;
24}
25
15sub feed_sdl_button_down_event { } 26sub feed_sdl_button_down_event {
27 my ($ev) = @_;
28 my ($x, $y) = ($ev->motion_x, $ev->motion_y);
29
30 if (!$BUTTON_STATE) {
31 my $widget = $TOPLEVEL->find_widget ($x, $y);
32
33 $GRAB = $widget;
34 $GRAB->update if $GRAB;
35 }
36
37 $BUTTON_STATE |= 1 << ($ev->button - 1);
38
39 $GRAB->button_down ($ev) if $GRAB;
40}
41
16sub feed_sdl_button_up_event { } 42sub feed_sdl_button_up_event {
43 my ($ev) = @_;
44 my ($x, $y) = ($ev->motion_x, $ev->motion_y);
45
46 my $widget = $GRAB || $TOPLEVEL->find_widget ($x, $y);
47
48 $BUTTON_STATE &= ~(1 << ($ev->button - 1));
49
50 if (!$BUTTON_STATE) {
51 my $grab = $GRAB; undef $GRAB;
52 $grab->update if $grab;
53 $GRAB->update if $GRAB;
54 }
55}
56
57sub feed_sdl_motion_event {
58 my ($ev) = @_;
59 my ($x, $y) = ($ev->motion_x, $ev->motion_y);
60
61 my $widget = $GRAB || $TOPLEVEL->find_widget ($x, $y);
62
63 if ($widget != $HOVER) {
64 my $hover = $HOVER; $HOVER = $widget;
65
66 $hover->update if $hover;
67 $HOVER->update if $HOVER;
68 }
69
70 $HOVER->mouse_motion ($ev) if $HOVER;
71}
17 72
18sub new { 73sub new {
19 my $class = shift; 74 my $class = shift;
20 75
21 bless { @_ }, $class 76 bless { @_ }, $class
43 $self->{w} = $w; 98 $self->{w} = $w;
44 $self->{h} = $h; 99 $self->{h} = $h;
45} 100}
46 101
47sub focus_in { 102sub focus_in {
48 my ($widget) = @_; 103 my ($self) = @_;
49 $::FOCUS = $widget; 104
105 my $focus = $FOCUS; $FOCUS = $self;
106 $focus->update if $focus;
107 $FOCUS->update;
50} 108}
51 109
52sub focus_out { 110sub focus_out {
53 my ($widget) = @_; 111 my ($self) = @_;
54}
55 112
56sub key_down { 113 return unless $FOCUS == $self;
57 my ($widget, $sdlev) = @_;
58}
59 114
60sub key_up { 115 my $focus = $FOCUS; undef $FOCUS;
61 my ($widget, $sdlev) = @_; 116 $focus->update if $focus; #?
62} 117}
63 118
119sub mouse_motion { }
120sub button_up { }
64sub button_down { 121sub button_down { }
65 my ($widget, $sdlev) = @_; 122sub key_down { }
66} 123sub key_up { }
67 124
68sub button_up {
69 my ($widget, $sdlev) = @_;
70}
71
72sub w { $_[0]->{w} = $_[1] if $_[1]; $_[0]->{w} } 125sub w { $_[0]{w} = $_[1] if @_ > 1; $_[0]{w} }
73sub h { $_[0]->{h} = $_[1] if $_[1]; $_[0]->{h} } 126sub h { $_[0]{h} = $_[1] if @_ > 1; $_[0]{h} }
74sub x { $_[0]->{x} = $_[1] if $_[1]; $_[0]->{x} } 127sub x { $_[0]{x} = $_[1] if @_ > 1; $_[0]{x} }
75sub y { $_[0]->{y} = $_[1] if $_[1]; $_[0]->{y} } 128sub y { $_[0]{y} = $_[1] if @_ > 1; $_[0]{y} }
76sub z { $_[0]->{z} = $_[1] if $_[1]; $_[0]->{z} } 129sub z { $_[0]{z} = $_[1] if @_ > 1; $_[0]{z} }
77 130
78sub draw { 131sub draw {
79 my ($self) = @_; 132 my ($self) = @_;
80 133
81 glPushMatrix; 134 glPushMatrix;
82 glTranslate $self->{x}, $self->{y}, 0; 135 glTranslate $self->{x}, $self->{y}, 0;
83 $self->_draw; 136 $self->_draw;
84 if ($self == $::HOVER) { 137 if ($self == $HOVER) {
85 glColor 1, 1, 1, 0.4; 138 glColor 1, 1, 1, 0.4;
86 glEnable GL_BLEND; 139 glEnable GL_BLEND;
87 glBegin GL_QUADS; 140 glBegin GL_QUADS;
88 glVertex 0, 0; 141 glVertex 0 , 0;
89 glVertex $self->{w} - 1, 0; 142 glVertex $self->{w}, 0;
90 glVertex $self->{w} - 1, $self->{h} - 1; 143 glVertex $self->{w}, $self->{h};
91 glVertex 0, $self->{h} - 1; 144 glVertex 0 , $self->{h};
92 glEnd; 145 glEnd;
93 glDisable GL_BLEND; 146 glDisable GL_BLEND;
94 } 147 }
95 glPopMatrix; 148 glPopMatrix;
96} 149}
227 if $self->{children}[0] 280 if $self->{children}[0]
228} 281}
229 282
230############################################################################# 283#############################################################################
231 284
232package Crossfire::Client::Widget::Toplevel;
233
234our @ISA = Crossfire::Client::Widget::Container::;
235
236sub update {
237 my ($self) = @_;
238
239 ::refresh ();
240}
241
242sub add {
243 my ($self, $widget) = @_;
244
245 $self->SUPER::add ($widget);
246
247 $widget->size_allocate ($widget->size_request);
248}
249
250#############################################################################
251
252package Crossfire::Client::Widget::Window; 285package Crossfire::Client::Widget::Window;
253 286
254our @ISA = Crossfire::Client::Widget::Bin::; 287our @ISA = Crossfire::Client::Widget::Bin::;
255 288
256use SDL::OpenGL; 289use SDL::OpenGL;
299 or return; 332 or return;
300 333
301 glEnable GL_BLEND; 334 glEnable GL_BLEND;
302 glEnable GL_TEXTURE_2D; 335 glEnable GL_TEXTURE_2D;
303 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; 336 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
304 glBindTexture GL_TEXTURE_2D, $tex->{name};
305 337
306 glBegin GL_QUADS; 338 $tex->draw_quad (0, 0, $w, $h);
307 glTexCoord 0, 0; glVertex 0, 0;
308 glTexCoord 0, 1; glVertex 0, $h;
309 glTexCoord 1, 1; glVertex $w, $h;
310 glTexCoord 1, 0; glVertex $w, 0;
311 glEnd;
312 339
313 glDisable GL_BLEND; 340 glDisable GL_BLEND;
314 glDisable GL_TEXTURE_2D; 341 glDisable GL_TEXTURE_2D;
315} 342}
316 343
349 376
350 my ($w, $h) = $chld->size_request; 377 my ($w, $h) = $chld->size_request;
351 378
352 glBegin GL_QUADS; 379 glBegin GL_QUADS;
353 glColor 0, 0, 0; 380 glColor 0, 0, 0;
354 glTexCoord 0, 0; glVertex 0 , 0; 381 glVertex 0 , 0;
355 glTexCoord 0, 1; glVertex 0 , $h + 4; 382 glVertex 0 , $h + 4;
356 glTexCoord 1, 1; glVertex $w + 4 , $h + 4; 383 glVertex $w + 4 , $h + 4;
357 glTexCoord 1, 0; glVertex $w + 4 , 0; 384 glVertex $w + 4 , 0;
358 glEnd; 385 glEnd;
359 386
360 $chld->draw; 387 $chld->draw;
361} 388}
362 389
412 glEnable GL_TEXTURE_2D; 439 glEnable GL_TEXTURE_2D;
413 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; 440 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
414 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; 441 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
415 442
416 my $top = $tex[1]; 443 my $top = $tex[1];
417 glBindTexture GL_TEXTURE_2D, $top->{name}; 444 $top->draw_quad (0, 0, $w, $top->{height});
418
419 glBegin GL_QUADS;
420 glTexCoord 0, 0; glVertex 0 , 0;
421 glTexCoord 0, 1; glVertex 0 , $top->{height};
422 glTexCoord 1, 1; glVertex $w , $top->{height};
423 glTexCoord 1, 0; glVertex $w , 0;
424 glEnd;
425 445
426 my $left = $tex[3]; 446 my $left = $tex[3];
427 glBindTexture GL_TEXTURE_2D, $left->{name}; 447 $left->draw_quad (0, $top->{height}, $left->{width}, $ch);
428
429 glBegin GL_QUADS;
430 glTexCoord 0, 0; glVertex 0 , $top->{height};
431 glTexCoord 0, 1; glVertex 0 , $top->{height} + $ch;
432 glTexCoord 1, 1; glVertex $left->{width}, $top->{height} + $ch;
433 glTexCoord 1, 0; glVertex $left->{width}, $top->{height};
434 glEnd;
435 448
436 my $right = $tex[2]; 449 my $right = $tex[2];
437 glBindTexture GL_TEXTURE_2D, $right->{name}; 450 $right->draw_quad ($w - $right->{width}, $top->{height}, $right->{width}, $ch);
438
439 glBegin GL_QUADS;
440 glTexCoord 0, 0; glVertex $w - $right->{width}, $top->{height};
441 glTexCoord 0, 1; glVertex $w - $right->{width}, $top->{height} + $ch;
442 glTexCoord 1, 1; glVertex $w , $top->{height} + $ch;
443 glTexCoord 1, 0; glVertex $w , $top->{height};
444 glEnd;
445 451
446 my $bottom = $tex[4]; 452 my $bottom = $tex[4];
447 glBindTexture GL_TEXTURE_2D, $bottom->{name}; 453 $bottom->draw_quad (0, $h - $bottom->{height}, $w, $bottom->{height});
448
449 glBegin GL_QUADS;
450 glTexCoord 0, 0; glVertex 0 , $h - $bottom->{height};
451 glTexCoord 0, 1; glVertex 0 , $h;
452 glTexCoord 1, 1; glVertex $w , $h;
453 glTexCoord 1, 0; glVertex $w , $h - $bottom->{height};
454 glEnd;
455 454
456 my $bg = $tex[0]; 455 my $bg = $tex[0];
457 glBindTexture GL_TEXTURE_2D, $bg->{name}; 456 glBindTexture GL_TEXTURE_2D, $bg->{name};
458 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; 457 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
459 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT; 458 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT;
460 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT; 459 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT;
461 460
462 my $rep_x = $cw / $bg->{width}; 461 my $rep_x = $cw / $bg->{width};
463 my $rep_y = $ch / $bg->{height}; 462 my $rep_y = $ch / $bg->{height};
464 463
465 glBegin GL_QUADS; 464 $bg->draw_quad ($left->{width}, $top->{height}, $cw, $ch);
466 glTexCoord 0, 0; glVertex $left->{width}, $top->{height};
467 glTexCoord 0, $rep_y; glVertex $left->{width}, $top->{height} + $ch;
468 glTexCoord $rep_x, $rep_y; glVertex $left->{width} + $cw , $top->{height} + $ch;
469 glTexCoord $rep_x, 0; glVertex $left->{width} + $cw , $top->{height};
470 glEnd;
471 465
472 glDisable GL_BLEND; 466 glDisable GL_BLEND;
473 glDisable GL_TEXTURE_2D; 467 glDisable GL_TEXTURE_2D;
474 468
475 $self->child->draw; 469 $self->child->draw;
632use SDL::OpenGL; 626use SDL::OpenGL;
633 627
634sub new { 628sub new {
635 my ($class, $x, $y, $z, $height, $text) = @_; 629 my ($class, $x, $y, $z, $height, $text) = @_;
636 630
631 $height ||= $::FONTSIZE;
632
637 # TODO: color, and make height, xyz etc. optional 633 # TODO: color, and make height, xyz etc. optional
638 my $self = $class->SUPER::new (x => $x, y => $y, z => $z, height => $height); 634 my $self = $class->SUPER::new (x => $x, y => $y, z => $z, height => $height);
639 635
640 $self->set_text ($text); 636 $self->set_text ($text);
641 637
658} 654}
659 655
660sub size_request { 656sub size_request {
661 my ($self) = @_; 657 my ($self) = @_;
662 658
663 ( 659 if ($self->{texture}{width} > 1 && $self->{texture}{height} > 1) { #TODO: hack
660 (
664 $self->{texture}{width}, 661 $self->{texture}{width},
665 $self->{texture}{height}, 662 $self->{texture}{height},
663 )
664 } else {
665 my ($w, $h, $data) = Crossfire::Client::font_render "Yy", $self->{height};
666
667 ($w, $h)
666 ) 668 }
669
667} 670}
668 671
669sub _draw { 672sub _draw {
670 my ($self) = @_; 673 my ($self) = @_;
671 674
673 676
674 glEnable GL_BLEND; 677 glEnable GL_BLEND;
675 glEnable GL_TEXTURE_2D; 678 glEnable GL_TEXTURE_2D;
676 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; 679 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
677 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; 680 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE;
678 glBindTexture GL_TEXTURE_2D, $tex->{name};
679 681
680 glColor 1, 0, 0, 1; # TODO color 682 glColor 1, 0, 0, 1; # TODO color
681 683
682 glBegin GL_QUADS; 684 $tex->draw_quad (0, 0);
683 glTexCoord 0, 0; glVertex 0 , 0;
684 glTexCoord 0, 1; glVertex 0 , $tex->{height};
685 glTexCoord 1, 1; glVertex $tex->{width}, $tex->{height};
686 glTexCoord 1, 0; glVertex $tex->{width}, 0;
687 glEnd;
688 685
689 glDisable GL_BLEND; 686 glDisable GL_BLEND;
690 glDisable GL_TEXTURE_2D; 687 glDisable GL_TEXTURE_2D;
691} 688}
692 689
693############################################################################# 690#############################################################################
694 691
695package Crossfire::Client::Widget::TextEntry; 692package Crossfire::Client::Widget::Entry;
696 693
697our @ISA = Crossfire::Client::Widget::Label::; 694our @ISA = Crossfire::Client::Widget::Label::;
698 695
699use SDL; 696use SDL;
700use SDL::OpenGL; 697use SDL::OpenGL;
703 my ($self, $ev) = @_; 700 my ($self, $ev) = @_;
704 701
705 my $mod = $ev->key_mod; 702 my $mod = $ev->key_mod;
706 my $sym = $ev->key_sym; 703 my $sym = $ev->key_sym;
707 704
708 $ev->set_unicode (1);
709 my $uni = $ev->key_unicode; 705 my $uni = $ev->key_unicode;
710 706
711 my $text = $self->get_text; 707 my $text = $self->get_text;
712 708
713 if ($sym == SDLK_BACKSPACE) { 709 if ($sym == SDLK_BACKSPACE) {
714 substr $text, -1, 1, ''; 710 substr $text, -1, 1, '';
715
716 } elsif ($uni) { 711 } elsif ($uni) {
717 $text .= chr $uni; 712 $text .= chr $uni;
713 print "$uni <$text>\n";#d#
718 } 714 }
715
719 $self->set_text ($text); 716 $self->set_text ($text);
717}
718
719sub button_down {
720 my ($self, $ev) = @_;
721
722 $self->focus_in;
723}
724
725sub _draw {
726 my ($self) = @_;
727
728 if ($FOCUS == $self) {
729 glColor 1, 1, 1;
730 } else {
731 glColor 0.7, 0.7, 0.7;
732 }
733
734 glBegin GL_QUADS;
735 glVertex 0 , 0;
736 glVertex 0 , $self->{h} - 1;
737 glVertex $self->{w} - 1, $self->{h} - 1;
738 glVertex $self->{w} - 1, 0;
739 glEnd;
740
741 $self->SUPER::_draw;
720} 742}
721 743
722############################################################################# 744#############################################################################
723 745
724package Crossfire::Client::Widget::MapWidget; 746package Crossfire::Client::Widget::MapWidget;
739 761
740sub key_up { 762sub key_up {
741} 763}
742 764
743sub size_request { 765sub size_request {
744 766 (
745} 767 1 + int $::WIDTH / 32,
746 768 1 + int $::HEIGHT / 32,
747sub size_allocate { 769 )
748} 770}
749 771
750sub _draw { 772sub _draw {
751 my ($self) = @_; 773 my ($self) = @_;
752 774
785 my $cell = $map->[$x + $xofs][$y + $yofs] 807 my $cell = $map->[$x + $xofs][$y + $yofs]
786 or next; 808 or next;
787 809
788 my $darkness = $cell->[0] * (1 / 255); 810 my $darkness = $cell->[0] * (1 / 255);
789 if ($darkness < 0) { 811 if ($darkness < 0) {
790 $darkness = 0.15; 812 $darkness = $cell->[1] ? 0.1 : 0;
791 } 813 }
792 substr $lighting, $y * $sw4 + $x, 1, chr 255 - $darkness * 255; 814 substr $lighting, $y * $sw4 + $x, 1, chr 255 - $darkness * 255;
793 815
794 for my $num (grep $_, @$cell[1,2,3]) { 816 for my $num (grep $_, @$cell[1,2,3]) {
795 my $tex = $::CONN->{face}[$num]{texture} || next; 817 my $tex = $::CONN->{face}[$num]{texture} || next;
796 818
797 glBindTexture GL_TEXTURE_2D, $tex->{name};
798
799 my $w = $tex->{width}; 819 my $w = $tex->{width};
800 my $h = $tex->{height}; 820 my $h = $tex->{height};
801 821
802 my $px = ($x + 1) * 32 - $w; 822 my $px = ($x + 1) * 32 - $w;
803 my $py = ($y + 1) * 32 - $h; 823 my $py = ($y + 1) * 32 - $h;
804 824
805 glBegin GL_QUADS; 825 $tex->draw_quad ($px, $py, $w, $h);
806 glTexCoord 0, 0; glVertex $px , $py;
807 glTexCoord 0, 1; glVertex $px , $py + $h;
808 glTexCoord 1, 1; glVertex $px + $w, $py + $h;
809 glTexCoord 1, 0; glVertex $px + $w, $py;
810 glEnd;
811 } 826 }
812 } 827 }
813 } 828 }
814 829
815# if (1) { # higher quality darkness 830# if (1) { # higher quality darkness
824 839
825 $lighting = new Crossfire::Client::Texture 840 $lighting = new Crossfire::Client::Texture
826 width => $sw4, 841 width => $sw4,
827 height => $sh, 842 height => $sh,
828 data => $lighting, 843 data => $lighting,
829 internalformat => GL_ALPHA4, 844 internalformat => GL_ALPHA,
830 format => GL_ALPHA; 845 format => GL_ALPHA;
831 846
832 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; 847 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
833 glColor 0, 0, 0, 0.75; 848 glColor 0.45, 0.45, 0.45, 1;
834 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; 849 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE;
835 glBindTexture GL_TEXTURE_2D, $lighting->{name}; 850 glBindTexture GL_TEXTURE_2D, $lighting->{name};
836 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR; 851 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR;
837 glBegin GL_QUADS; 852
838 glTexCoord 0, 0; glVertex 0 , 0; 853 $lighting->draw_quad (0, 0, $sw4 * 32, $sh * 32);
839 glTexCoord 0, 1; glVertex 0 , $sh * 32;
840 glTexCoord 1, 1; glVertex $sw4 * 32, $sh * 32;
841 glTexCoord 1, 0; glVertex $sw4 * 32, 0;
842 glEnd;
843 854
844 glDisable GL_TEXTURE_2D; 855 glDisable GL_TEXTURE_2D;
845 glDisable GL_BLEND; 856 glDisable GL_BLEND;
846} 857}
847 858
906 917
907sub moveto { 918sub moveto {
908 my ($self, $x, $y) = @_; 919 my ($self, $x, $y) = @_;
909 920
910 $self->{moveto} = [$self->{x}, $self->{y}, $x, $y]; 921 $self->{moveto} = [$self->{x}, $self->{y}, $x, $y];
911 $self->{speed} = 0.2; 922 $self->{speed} = 0.001;
912 $self->{time} = 1; 923 $self->{time} = 1;
913 924
914 ::animation_start $self; 925 ::animation_start $self;
915} 926}
916 927
917sub animate { 928sub animate {
918 my ($self, $interval) = @_; 929 my ($self, $interval) = @_;
930
931 printf "%5.2f\n", 1 / $interval;#d#
919 932
920 $self->{time} -= $interval * $self->{speed}; 933 $self->{time} -= $interval * $self->{speed};
921 if ($self->{time} <= 0) { 934 if ($self->{time} <= 0) {
922 $self->{time} = 0; 935 $self->{time} = 0;
923 ::animation_stop $self; 936 ::animation_stop $self;
931 944
932sub _draw { 945sub _draw {
933 my ($self) = @_; 946 my ($self) = @_;
934 947
935 glPushMatrix; 948 glPushMatrix;
936 glRotate $self->{time} * 10000, 0, 1, 0; 949 glRotate $self->{time} * 1000, 0, 1, 0;
937 $self->{children}[0]->draw; 950 $self->{children}[0]->draw;
938 glPopMatrix; 951 glPopMatrix;
939} 952}
940 953
9411; 954#############################################################################
942 955
956package Crossfire::Client::Widget::Toplevel;
957
958our @ISA = Crossfire::Client::Widget::Container::;
959
960sub size_request {
961 ($::WIDTH, $::HEIGHT)
962}
963
964sub size_allocate {
965 my ($self, $w, $h) = @_;
966
967 $self->SUPER::size_allocate ($w, $h);
968
969 $_->size_allocate ($_->size_request)
970 for @{$self->{children}};
971}
972
973sub update {
974 my ($self) = @_;
975
976 $self->size_allocate ($self->size_request);
977 ::refresh ();
978}
979
980sub add {
981 my ($self, $widget) = @_;
982
983 $self->SUPER::add ($widget);
984
985 $widget->size_allocate ($widget->size_request);
986}
987
988sub draw {
989 my ($self) = @_;
990
991 $self->_draw;
992}
993
994#############################################################################
995
996package Crossfire::Client::Widget;
997
998$TOPLEVEL = new Crossfire::Client::Widget::Toplevel;
999
10001
1001

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines