Shadows in Buttons



Hello,

i am interested in a very simple disabling mechanism of a shadow
(GtkShadowType) in a widget (here a GtkButton).

At my current state of information, this is not easily possible. A
shadow is (for me) a public object attribute, which should be easily
accesible via a corresponding function.

I tried this: 

gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);

Result: No background pixmap while in GTK_STATE_NORMAL. Is this a bug?

-

I tried this: 

button_style->klass->draw_shadow = no_shadow;

Where button_style is a GtkStyle * and no_shadow is a function with no
operation. 

You guess the result: All buttons in my application have no shadows.
Okay, because off GtkStyleClass *klass.

-

I tried this:

memcpy(button_style->klass, (GtkStyleClass *)&button_style_class,
sizeof(GtkStyleClass));
button_style->klass = (GtkStyleClass *)&button_style_class;

Where button_style is a GtkStyle * and button_style_class is a
GtkStyleClass. 

Result: Segfault because off the second line while entering gtk_main.
Okay. This is maybe a wild hack, there could be some magic data, i
forget to look after.

-

Conclusion: Solute it by myself.

Possibilities:

1. Don't use GtkButton. Use GtkEventBox & GtkFixed & GtkPixmap (in fact
it's a GtkWidget with a "PNG in it") and write own callbacks for
changing the background (i need a different background for every state).
2. Write my own widget.
3. Redirect the klass->draw_shadow GtkStyleClass * to my own function.
In this function check in a list of all my buttons if a shadow should be
drawn or not. If not, just return, else redirect back to the
default_class GtkStyleClass * from gtkstyle.c.

Comments:

1. 5 times bigger code.
2. I like standard widgets.
3. Current solution, little overhead maintaining the button list and
saving the pointers. There could be a problem in the future development
of Gtk for me, if the parameters should change for the
shadow_drawing_function.

-

Questions:

1. Is there a possibility to easily disable a shadow of a special
GtkButton, nor for all of them? If yes, tell me please. If no? Will be
there one?

2. Is there a possibility to attach my own GtkStyleClass to a GtkStyle?
If yes, tell me please. If no? Will be there one?

Any information is welcome. Thanks in advance.

Regards,

Szymon Polom.




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