[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Table widgets
- Subject: Re: Table widgets
- From: philaldis(at)yahoo.com
- Date: Sat, 16 Oct 1999 09:13:40 GMT
- Newsgroups: comp.lang.idl-pvwave
- Organization: Deja.com - Before you buy.
- References: <firstname.lastname@example.org>
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:16864
In article <email@example.com>,
firstname.lastname@example.org (Nils Johnson) wrote:
> I have two questions about the WIDGET_TABLE command. I am trying to
> create a read-only table as part of a larger widget. It's not too
> hard to get something going, but...
> 1. There is a funny "gap" on the right and bottom sides of the table.
> What is the reason for this extra space, and is there any way to get
> rid of it?
> 2. I would like to set the column widths so that no text is cut off.
> Is there a relatively easy way to determine the number of pixels (or
> inches, or centimeters) a given string will take on the screen? Or
> is there some other slick way?
(Before I start this may be the second time this post appears because I
wasn't sure whether my news feed was working so I posted it again via
Anyway the problem and the answer to 2 is yes. Now I've found this to
be an extremely accurate method, and if I I
understand what you're trying yo do then tihs should work . As I read
you're trying to get the columns to automatically size by not just the
title (as IDL does automatically) but also by what's in the columns, so
Essentially you're going to use a dynamic resizing label widget to
calculate the width of the strings on the screen. So first we set this
base = Widget_Base(MAP=0)
label = Widget_Label(base, /DYNAMIC_RESIZE, VALUE='')
For a particular column, find out the strLen() of the longest column
or column title, i.e. on average the widest. Of course one of the other
column values might be slightly wider on screen if the max strLen() one
composed entirely of llllllllllll and a shorter one is all wwwwwww. But
practice it works out fine.
Now we set the label's value to this string we have found which is the
Widget_Control, label, SET_VALUE=longString
..and then we find out the width of this label:
width = (Widget_Info(label, /GEOMETRY)).scr_xsize
If you then add on about 20 pixels or so for safety (you can tell I'm
engineering at Uni). After you've repeated this for all columns you
array which can be used for
Widget_Control, tableID, SET_COLUMN_WIDTHS=[width1, width2......]
I hope this helps. It took me a little while to work this out when I
do it, but I think you'll find that it works quite effectively,
understood what you were wanting correctly. The IDL table widget is not
but can be caressed into doing vaguely what you want it to.
Sent via Deja.com http://www.deja.com/
Before you buy.