Re: how the change the shape and color of Gtk Button



On Jan 4, 2008 2:06 PM, Ajax John <ajaxjohn gmail com> wrote:
I want to change it's shape to some other shape, say round rectangle.
How to do that in Gtk?
2) I want to change the color of my Button to some color.

The easy way is to use a theme engine to change the way your buttons
are painted. It works something like this:

GTK widgets draw themselves with calls like gtk_paint_box() (to draw
the box shape of the button) and gtk_paint_focus() (to draw the
button's focus indicator). They look at the current style file to get
layout information, such as the interior margin etc.

gtk_paint_box() and friends are implemented by a theme engine. There's
rather a dull one built into GTK, but most desktops plug in an
alternative, such as clearlooks.

The theme engine reads more values from the current style (colour,
gradients, more layout, etc.) and then paints the screen using cairo
(usually these days) or GDK.

Cairo/GDK/whatever then make calls to the platform native drawing
toolkit (X11, GDI, etc).

So you should pick a theme engine that can paint rounded buttons, then
hack up a style file for your app that sets the colours and layout the
way you like.

(alternatively, don't do anything, and leave this sort of detailed
customisation of appearance to your users ... I guess this won't apply
to embedded applications)

John



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]