[180] in The GTK GIMP ToolKit mailing list archive

home help back first fref pref prev next nref lref last post

[gtk-list] Re: Truncated labels

daemon@ATHENA.MIT.EDU (Owen Taylor)
Fri May 16 00:20:05 1997

To: gtk-list@redhat.com
From: Owen Taylor <owt1@cornell.edu>
In-Reply-To: "E. Young"'s message of Fri, 16 May 1997 02:51:41 +0100 (BST)
Date: 16 May 1997 00:21:02 -0400
Resent-From: gtk-list@redhat.com
Reply-To: gtk-list@redhat.com


"E. Young" <ey200@hermes.cam.ac.uk> writes:

> Is it possible to get some text displayed which is truncated to fit inside
> its allocation? 

gtk's behavior (no clipping) is a consequence of its attempts to
conserve X resources. Label widgets (among others) don't get their own
X window - they just draw their contents on their parent's window.
While it might be possible to have clipping occur by setting the clip
mask before drawing the text, this would probably cause a substantial
performance penalty.

Its possible that, in the long term, the best solution to such
problems might be just to change gtk to give labels X windows.
A short term workaround is to put the label widget inside another
widget that does get it's own window - one possible candidate would
be the viewport widget.

   viewport = gtk_viewport (NULL, NULL);
   gtk_widget_set_usize (viewport, 50, 25);
   gtk_viewport_set_shadow_type (GTK_VIEWPORT(viewport), GTK_SHADOW_NONE);
   gtk_widget_show(viewport);

   label = gtk_label ("a really long label that won't fit");
   gtk_container_add (GTK_CONTAINER(viewport), label);
   gtk_widget_show (label);

If you were doing this for a bunch of widgets, you might want to
copy gtkviewport.c and strip out the adjustment and shadow
functionality (perhaps you could call it GtkClipper).

Regards,
                                        Owen

(Shawn: feel free to use this for the FAQ if you like, though I'm sure
it could be improved upon)

--
To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null


home help back first fref pref prev next nref lref last post