connect('size-allocate', array($this, 'size_allocate')); # $this->connect('size-request', array($this, 'size_request')); $this->tempo_parent = new GtkFixed(); } public function move_top($w){ $pos = $w->allocation; $w->reparent($this->tempo_parent); $w->reparent($this); $this->move($w, $pos->x, $pos->y); } } class TextBox extends GtkEventBox{ public function __construct($label, $fg='#111', $bg='#EEE', $font='Sans Bold 20'){ parent::__construct(); $this->modify_bg(Gtk::STATE_NORMAL, GdkColor::parse($bg)); $this->label = new GtkLabel($label); $this->label->modify_font(new PangoFontDescription($font)); $this->label->modify_fg(Gtk::STATE_NORMAL, GdkColor::parse($fg)); $this->add($this->label); } } $window = new GtkWindow(); $window->connect_simple('destroy', array('Gtk','main_quit')); $window->set_size_request( 300, 200 ); # set window size $window->set_position(Gtk::WIN_POS_CENTER); # place window to screen center $window->set_title("Composite widget extention test"); $box = new CompositeBox(); $box2 = new CompositeBox(); $window->add($box); $box->put($w1 = new TextBox("some \ntext\n....", '#A00', '#EEE'), 50, 50); $box->put($w2 = new TextBox("an other\ntext box\n....", '#0A0', '#AAA'), 150, 70); Gtk::timeout_add(2000, 'timeout'); //display it $window->show_all(); Gtk::main(); function timeout(){ global $w1, $w2, $box; echo "timeout\n"; $box->move_top($w1); } ?>