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

Home » Public Forums » archive » Re: Widget_List resizing problem
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
Re: Widget_List resizing problem [message #7260] Mon, 28 October 1996 00:00
sterner is currently offline  sterner
Messages: 106
Registered: February 1991
Senior Member
davidf@fortnet.org (David Fanning) writes:

. . .
> With respect to list widgets, one thing you might try is to make all
> the string elements in the list the same length. Then there will be no
> need to resize as you scroll through the list. (At least if you are using
> a fixed-spaced font, as you claim.)

Here is a code fragment to pad all the lines of a string array
to match the longest line. It's not as general as David's
function but it might have its place:

padded = string(byte(string_array)>32B)

Ray Sterner sterner@tesla.jhuapl.edu
The Johns Hopkins University North latitude 39.16 degrees.
Applied Physics Laboratory West longitude 76.90 degrees.
Laurel, MD 20723-6099
WWW Home page: http://fermi.jhuapl.edu/s1r/people/res/res.html
Re: Widget_List resizing problem [message #7265 is a reply to message #7260] Sat, 26 October 1996 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Brian Jackel <brian.jackel@uwo.ca> writes:

> I'm running IDL 4.0.1 under Windows95, and List Widgets are driving me
> crazy. Specifically, they tend to resize themselves (horizontally) after
> every two or three events (clicks or cursor up/down).

I am not sure about this, because I haven't been around Windows 95 enough
to know for sure, but it appears to me that Windows 95 does a lot of
automatic resizing of widgets. Most of the time, this is what I want, but
I can understand how it might be annoying too.

With respect to list widgets, one thing you might try is to make all
the string elements in the list the same length. Then there will be no
need to resize as you scroll through the list. (At least if you are using
a fixed-spaced font, as you claim.)

Here is a little function of mine that takes a string (or string array)
and pads it with blank characters so that it is always a specified
length. It might be just what you are looking for.

Good luck!

David

***********************************************************

FUNCTION PADSTRING, thisString, length

; This function takes the input string and pads it with blanks
; to make a string of a specified length. The variable
; "thisString" can be a scalar string or an array of strings.
; If "thisString" is longer than the specified length, the
; string is truncated.

ON_ERROR, 1

; Must have one parameter.

IF N_PARAMS() LT 1 THEN $
MESSAGE, 'Must pass at least one parameter to this function.'

; Is first parameter a string?

s = SIZE(thisString)
IF s(s(0) + 1) NE 7 THEN $
MESSAGE, 'First parameter must be a string variable.'

; Define default string length if necessary.

IF N_PARAMS() LT 2 THEN length = 20

; Create a return value (can be an array).

paddedString = thisString

; Do the string padding.

FOR j=0, N_ELEMENTS(thisString)-1 DO BEGIN

; Check to be sure thisString is not too long.

IF N_ELEMENTS(thisString(j)) GT length THEN $
thisString(j) = STRMID(thisString(j), 0, length)

padding = STRING(REPLICATE(32B, length))
STRPUT, padding, thisString(j), 0
paddedString(j) = padding

ENDFOR

RETURN, paddedString
END

*******************************************************

--
David Fanning, Ph.D.
Phone: 970-221-0438
Fax: 970-221-4728
E-Mail: davidf@fortnet.org
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: ANNOUNCE: perlDL v1.00 - the 'perl Data Language'
Next Topic: ACR-NEMA reader?

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

Current Time: Wed Oct 08 20:03:29 PDT 2025

Total time taken to generate the page: 0.00420 seconds