Cairo drowing works fine. I saw in gtkstyle.c that gtk_paint_box just sets background and draws shadow. Now, if I paint shadow directly instead of box (with gtk_paint_shadow) it works! Strange. I need to read more about these engines/themes and try gtk_rc_* func as you suggested.
> I can post complete example code tomorrow, if you need it. Yes, please. Thanks >> Sebastian >> 2009/12/19 Artur Galyamov : >> > Hi, Sebastian! >> > >> > 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) >> > // key phrase: >> > style = gtk_rc_get_style_by_paths(gtk_settings_get_default(), NULL, >> > "GtkButton", GTK_TYPE_BUTTON); >> > >> > 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; >> > } >> > >> > Style engine may or may not heavily depend on widget's class or even >> > properties, so don't expect exact emulation for all classes on all >> > engines. I think it is why things are not documented. >> > >> > See $SRC/gtk/gtkbutton.c on how to paint button's focus, default, etc >> > exactly as GtkButton does. >> > >> > -- >> > Artur >> > >> > 19.12.09, 14:09, "Sebastian Pająk" : >> > >> >> Hi >> >> I'm trying to create a shape for my custom widget using GtkStyle >> >> (gtk_paint func. family). For a start I want a shape like a button has >> >> (shadow + relief). This is my code for expose event: >> >> static int >> >> clv_expose(GtkWidget *widget, GdkEventExpose *event) // clv is a >> >> subclass of GtkConainer >> >> { >> >> int x = widget->allocation.x; >> >> int y = widget->allocation.y; >> >> int width = widget->allocation.width; >> >> int height = widget->allocation.height; >> >> gtk_paint_box(widget->style, widget->window, >> >> GTK_STATE_NORMAL, >> >> GTK_SHADOW_IN, &event->area, >> >> widget, "button", >> >> x+4, y+4, width-8, height-8); >> >> std::printf("EXPOSE"); >> >> return FALSE; >> >> } >> >> clv_expose is connected and is called. Unfortunately it doesn't work. >> >> Only empty, flat window is showing, no shadow like in a button. Do you >> >> know what can be wrong? Is GtkConainer good for sublassing in this >> >> situation? >> >> I cannot find any info on gtk/gdk drawing using google (only cairo). >> >> Gtk API reference is very poor abou it. Some hints, simple exmples or >> >> howtos will be helpful for a GTK+ beginner like me :). >> >> Thanks in advance >> >> Sebastian >> >> _______________________________________________ >> >> gtk-app-devel-list mailing list >> >> gtk-app-devel-list@gnome.org >> >> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list >> > > > -- > Artur > _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list