Thanks. The code compiles, but the painted box doesn't appear also. But the fault is somewhere else. I found gtk_paint_box doesn't work with MS-Windows theme only. With any other theme no problem exists (yes, I use gtk+ on win xp). It's weird because GtkButton also calls this function and there is no problem drawing it even with MS-Windows theme. I have no idea why it is so. Need to study gtk+ source more...
Sebastian 2009/12/20 Artur Galyamov <artur-...@yandex.ru>: > > #include <gtk/gtk.h> > > static GtkWidget *window = NULL; > > static gboolean > expose_event(GtkWidget *widget, GdkEventExpose *event) > { > static GtkStyle *style = NULL; > > int x = widget->allocation.x; > int y = widget->allocation.y; > int width = widget->allocation.width; > int height = widget->allocation.height; > > if (!style) > style = gtk_rc_get_style_by_paths(gtk_settings_get_default(), NULL, > "GtkButton", GTK_TYPE_BUTTON); > > style = gtk_style_attach(style, widget->window); > > gtk_paint_box(style, widget->window, > GTK_STATE_NORMAL, > GTK_SHADOW_OUT, &event->area, > widget, "button", > x, y, width, height); > > gtk_style_detach(style); > return FALSE; > } > > static GtkWidget * > create_widget(void) > { > GtkWidget *vbox = gtk_vbox_new(FALSE, 4); > GtkWidget *btn0 = gtk_vbox_new(FALSE, 0); > GtkWidget *btn1 = gtk_button_new(); > GtkWidget *btn2 = gtk_button_new(); > > GTK_WIDGET_SET_FLAGS(btn0, GTK_APP_PAINTABLE); > > g_signal_connect(btn0, "expose-event", > (GCallback) expose_event, NULL); > gtk_box_pack_start(GTK_BOX(vbox), btn0, 1, 1, 0); > gtk_box_pack_start(GTK_BOX(vbox), btn1, 1, 1, 0); > gtk_box_pack_start(GTK_BOX(vbox), btn2, 1, 1, 0); > > gtk_container_set_border_width(GTK_CONTAINER(vbox), 4); > gtk_widget_show_all(vbox); > return vbox; > } > > int > main(int argc, char *argv[]) > { > gtk_init(&argc, &argv); > window = gtk_window_new(GTK_WINDOW_TOPLEVEL); > gtk_window_set_default_size(GTK_WINDOW(window), 400, 300); > auto void on_destroy(void); > auto void on_destroy(void) { gtk_main_quit(); } > g_signal_connect(window, "destroy", (GCallback) on_destroy, NULL); > gtk_container_add(GTK_CONTAINER(window), create_widget()); > gtk_widget_show(window); > gtk_main(); > return 0; > } > > Attaches don't work here.. > > -- > Artur > _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list