I'm attaching a GtkStyle to my widget's window inside "realize"
callback (like I saw it in gtkbutton.c). So I think there is no need
to do it inside "expose" callback.

Essentially all I want now is to draw "something" I can see like
relief/shadow/line, because now I can see no effect of my
gtk_paint_box call. I thought GTK_SHADOW_OUT or IN flag creates this
3D effect... Am I wrong?

btw. Does GtkStyle uses Cairo for painting? Maybe I will use Cairo if
it's more low-level layer of gtk+.

Sebastian

2009/12/19 Artur Galyamov <artur-...@yandex.ru>:
> 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" <spcon...@gmail.com>:
>
>> 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
>
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to