Re: widgets and drawing like Glade
| From: | Jake Cobb | Date: | Thu, 24 May 2007 21:52:56 +0000 |
| Subject: | Re: widgets and drawing like Glade | ||
| References: | 1 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-7848@lists.php.net to get a copy of this message | ||
Hello,
This is sort of the inverse of your event box post. There are default
handlers for many events, expose-event being one of them. By default,
the GtkWindow would redraw itself and its children, but when doExpose()
returns true, the chain ends and the children are not redrawn. Remove
the return line from doExpose() and you'll see both buttons, one with a
rectangle around it.
-Jake Cobb
thomas favennec wrote:
Hi, I would like create a rectangle around gtkButton like Glade do it. I tried draw_rectangle method with expose event in the main window but widgets added in the window are now ... hidden ! <?php function doExpose($widget, $event) { global $button2; $gc = new GdkGC($widget->window); $gc->set_rgb_fg_color(new GdkColor(0,0,0)); $gc->set_rgb_fg_color(new GdkColor(0,0,0)); $widget->window->draw_rectangle($gc, false, $button2->allocation->x-1, $button2->allocation->y-1, $button2->allocation->width+1, $button2->allocation->height+1); return true; } $win = new GtkWindow(); $win->connect_simple('destroy', array('Gtk', 'main_quit')); $win->connect('expose-event', 'doExpose'); // this box and chids are hidden :-( $box = new gtkHbox(); $win->add($box); $box->set_border_width(2); $button = new gtkButton('test'); $box->pack_start($button,0); $button2 = new gtkButton('test'); $box->pack_start($button2,0); $win->show_all(); Gtk::main(); ?> Do you know what is wrong ? Thanks, Thomas.