comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Predicting string lengths in widgets
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Predicting string lengths in widgets [message #55142] Mon, 06 August 2007 04:41 Go to next message
mattf is currently offline  mattf
Messages: 13
Registered: January 2007
Junior Member
Hi all...

I have a table widget and I'd like to set the column widths -before-
the table is realized so that the user doesn't have to fiddle with
adjustable widths. Unfortunately, I don't know the lengths of the
strings that I'm going to put into the table before running the
program, and the strings may be rather long. And, for a cross-platform
application, I don't know what the font will be, or, for that matter,
the size of the display.

At the moment, I'm just hacking at the problem by using a pixmap
window and the width parameter in xyouts to get an idea of the string
length in pixels, e.g., if the string is 'test_str' I do

str_max_sz
window, /free, /pixmap, xsize = str_max_sz, ysize = str_max_sz
xyouts, test_str, width = w
wdelete
str_pix_len = ceil(w*str_max_sz)

and then use a fudge factor to get good-looking column widths from
str_pix_len. But there must be a way of doing it, you know,
correctly... no?
Re: Predicting string lengths in widgets [message #55234 is a reply to message #55142] Mon, 06 August 2007 10:08 Go to previous message
mattf is currently offline  mattf
Messages: 13
Registered: January 2007
Junior Member
On Aug 6, 12:40 pm, "mgal...@gmail.com" <mgal...@gmail.com> wrote:
> On Aug 6, 5:41 am, mattf <mfe...@earthlink.net> wrote:
>
>
>
>> Hi all...
>
>> I have a table widget and I'd like to set the column widths -before-
>> the table is realized so that the user doesn't have to fiddle with
>> adjustable widths. Unfortunately, I don't know the lengths of the
>> strings that I'm going to put into the table before running the
>> program, and the strings may be rather long. And, for a cross-platform
>> application, I don't know what the font will be, or, for that matter,
>> the size of the display.
>
>> At the moment, I'm just hacking at the problem by using a pixmap
>> window and the width parameter in xyouts to get an idea of the string
>> length in pixels, e.g., if the string is 'test_str' I do
>
>> str_max_sz
>> window, /free, /pixmap, xsize = str_max_sz, ysize = str_max_sz
>> xyouts, test_str, width = w
>> wdelete
>> str_pix_len = ceil(w*str_max_sz)
>
>> and then use a fudge factor to get good-looking column widths from
>> str_pix_len. But there must be a way of doing it, you know,
>> correctly... no?
>
> Check out the STRING_SIZE keyword to WIDGET_INFO. (IDL 6.2+ required.)
>
> Mike
> --www.michaelgalloy.com

Thanks. I saw that, actually, but the documentation is mercilessly
brief. Does the widget have to be realized? Do all the widgets on a
given base inherit the same default string-to-pixels scaling? I
suppose I could try applying WIDGET_INFO with that keyword to some
realized widget in the widget application, and then kinda assume that
a string in my table would work the same way... Still kind of a hack,
but seems closer to the right answer. Hmm...
Re: Predicting string lengths in widgets [message #55235 is a reply to message #55142] Mon, 06 August 2007 09:40 Go to previous message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On Aug 6, 5:41 am, mattf <mfe...@earthlink.net> wrote:
> Hi all...
>
> I have a table widget and I'd like to set the column widths -before-
> the table is realized so that the user doesn't have to fiddle with
> adjustable widths. Unfortunately, I don't know the lengths of the
> strings that I'm going to put into the table before running the
> program, and the strings may be rather long. And, for a cross-platform
> application, I don't know what the font will be, or, for that matter,
> the size of the display.
>
> At the moment, I'm just hacking at the problem by using a pixmap
> window and the width parameter in xyouts to get an idea of the string
> length in pixels, e.g., if the string is 'test_str' I do
>
> str_max_sz
> window, /free, /pixmap, xsize = str_max_sz, ysize = str_max_sz
> xyouts, test_str, width = w
> wdelete
> str_pix_len = ceil(w*str_max_sz)
>
> and then use a fudge factor to get good-looking column widths from
> str_pix_len. But there must be a way of doing it, you know,
> correctly... no?

Check out the STRING_SIZE keyword to WIDGET_INFO. (IDL 6.2+ required.)

Mike
--
www.michaelgalloy.com
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Predicting string lengths in widgets
Next Topic: Re: Question regarding HDF file

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:39:58 PDT 2025

Total time taken to generate the page: 0.00628 seconds