widgets and drawing like Glade
| From: | thomas favennec | Date: | Thu, 24 May 2007 21:29:17 +0000 |
| Subject: | widgets and drawing like Glade | ||
| Groups: | php.gtk.general | ||
| Request: | Send a blank email to php-gtk-general+get-7847@lists.php.net to get a copy of this message | ||
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.