Re: [gtk-list] EventBox problem
- From: Owen Taylor <owt1 cornell edu>
- To: Stefan Jeske <jeske braunschweig netsurf de>
- Cc: gtk-list redhat com
- Subject: Re: [gtk-list] EventBox problem
- Date: 29 Oct 1997 22:59:07 -0500
Stefan Jeske <jeske@braunschweig.netsurf.de> writes:
> I'd like to create a multi-column listbox with each list item containing
> several left- or right-justified labels (all of them in a big hbox).
> I need clipping, so I guess that EventBoxes have to be used. (?)
>
> But if I put each label into an EventBox, the whole list looks quite ugly
> because the background of all EventBoxes (or labels ?) is painted grey...
When there isn't an eventbox, the background is white, because the
widgets (which don't have an X window) simply share the background
of the parent. When there is an eventbox, you have to get trickier.
The window background color needs to be set at two points - when
the window is initially realized (you can't do it when you create
the widget, because the X window doesn't exist yet), and when
the state of the list item changes.
The following seems to work for me:
----
void
event_box_state_changed (GtkWidget *w)
{
if (w->state == GTK_STATE_NORMAL)
gdk_window_set_background (w->window, &w->style->white);
else
gdk_window_set_background (w->window, &w->style->bg[w->state]);
if (GTK_WIDGET_DRAWABLE(w))
gdk_window_clear_area (w->window, 0, 0,
w->allocation.width, w->allocation.height);
}
event_box = gtk_event_box_new ();
gtk_signal_connect(GTK_OBJECT(event_box), "state_changed",
GTK_SIGNAL_FUNC (event_box_state_changed), NULL);
gtk_signal_connect(GTK_OBJECT(event_box), "realize",
GTK_SIGNAL_FUNC (event_box_state_changed), NULL);
... show the listbox, fill in contents ...
----
As for speed, there isn't much you can do for now (beyond drawing the
text strings "by hand" - which isn't too bad _if_ you don't need
selection). Ryan Willhoit is working on a Grid widget, which should be
useful for this sort of thing.
Regards,
Owen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]