Re: [gtk-list] clist scrolling
- From: Brad Pepers <brad linuxcanada com>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] clist scrolling
- Date: Mon, 23 Aug 1999 18:21:33 -0600
John Estess wrote:
>
> I'm fairly new to GTK, so if this is a stupid question, have mercy.
>
> I put a clist into a gtk_scroll_window_add_with_viewport - that part
> works. When I scroll the scroll window, the labels for the clist move
> with the rest of the clist. How can I stop that from happening? It
> looks tacky and unprofessional. Do I have to create labels on top of
> the clist and have signals update the column size when the labels are
> resized? (yech)
The code I use does a gtk_container_add instead of the scrolled window
routines and that works for me!
Here is a small code section:
scrolled = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
gtk_box_pack_start(GTK_BOX(main_box), scrolled, TRUE, TRUE, 0);
clist = gtk_ctree_new_with_titles(2, 0, titles);
gtk_clist_set_selection_mode(GTK_CLIST(clist),
GTK_SELECTION_BROWSE);
gtk_clist_set_shadow_type(GTK_CLIST(clist), GTK_SHADOW_ETCHED_IN);
gtk_clist_set_column_justification(GTK_CLIST(clist), 1,
GTK_JUSTIFY_RIGHT);
gtk_container_add(GTK_CONTAINER(scrolled), clist);
My main problem is that the scrolled list window doesn't start with a
good size so I added this code to set the size:
/* Set column widths */
style = gtk_widget_get_style(window);
width = gdk_char_width(style->font, 'X');
height = style->font->ascent + style->font->descent;
gtk_clist_set_column_width(GTK_CLIST(clist), 0, width * 30);
gtk_clist_set_column_width(GTK_CLIST(clist), 1, width * 10);
/* Size window to fit (TODO: fix fudge factor) */
gtk_widget_set_usize(scrolled, width * 40 + 44, 10 * height);
I would like to know of a better way to do this. It needs the fudge
factor
of 44 for the scrollbar in the scrolled window. Ideally I would like to
just tell the clist that its default size is 10 rows high and the width
of
the columns are 30 and 10 and then its tells the scrolled window what
size
it wants. Anyone have a better way to do this?
Looking at the code right now, getting the style from the main window is
likely bogus too. I should be getting it from the clist right?
Otherwise
if the user changes the font used in only the clist, my code will fail
to
size properly.
--
Brad Pepers
Linux Canada Inc. Home of Linux products in Canada!
http://www.linuxcanada.com Proud supporter of Cyclades, Red
brad@linuxcanada.com Hat, and Caldera.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]