开发者

How Do I Give a GtkEventBox a Transparent Background?

On a GTK dialog, I have a GtkLabel wrapped in a GtkEventBox so that it can receive click events (navigates to a web page for more info). Functionally it works great.

However, when I add the label to the event box, the label's background is no longer transparent -- the label now has the default window background color. This doesn't work for me since the window I'm drawing has a background bitmap and the lack of transparency makes it look goofy.

What do I need to do to keep the GtkLabel's background transparent when it's added to a GtkEventBox?

GdkColor color;
gdk_color_parse("blue", &color);
GtkStyle* linkstyle = gtk_style_new();
linkstyle->fg[GTK_STATE_NORMAL] = color;
GtkWidget* learnmorebox = gtk_event_box_new();
GtkWidget* learnmore = gtk_label_new("More Info");
gtk_widget_set_style(GTK_WIDGET(learnmore), GTK_STYLE(linkstyle));
gtk_container_add(GTK_CONTAINER(learnmorebox), learnmore);
gtk_widget_set_events(learnmorebox, GDK_BUTTON_PRESS开发者_StackOverflow_MASK);
g_signal_connect(G_OBJECT(learnmorebox), "button_press_event", G_CALLBACK(learn_more), NULL);

I suspect there's something I can set in the GtkStyle but haven't found anything useful yet.


GtkEventBox works by creating a new X window to receive the events. By default it uses an input/output window. Call gtk_event_box_set_visible_window to make the window invisible (and input only.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜