Re: Right justifying text [message #18146] |
Fri, 03 December 1999 00:00 |
Phil Aldis
Messages: 11 Registered: February 1999
|
Junior Member |
|
|
David Fanning <davidf@dfanning.com> wrote in message
news:MPG.12b0b6aa4ed8c11b9899ae@news.frii.com...
> Robert S. Mallozzi (Robert.Mallozzi@msfc.nasa.gov) writes:
>
>> If you set the size of the text area explicitly, you
>> could do something like this:
>>
>> xsize = 40
>> ysize = 1
>> base = WIDGET_BASE (/COLUMN)
>> text = WIDGET_TEXT (base, XSIZE = xsize, YSIZE = ysize, VALUE = '')
>> WIDGET_CONTROL, /REALIZE, base
>>
>> num = 10.00
>> fmt = "(F" + STRTRIM (xsize, 2) + ".2)" ; F40.2
>>
>> str = STRING (num, FORMAT = fmt)
>> WIDGET_CONTROL, text, SET_VALUE = str
>>
>> You could make the number of digits after the decimal point a
>> parameter as well; here I just hardcoded it to 2.
>
> Humm. Maybe if you have a non-proportionally spaced
> font in the text widget, but I doubt otherwise. A
> table widget allows you to justify text. Maybe
> Phil Aldis will write us a nice CW_FIELD-like compound
> widget object that uses a Table Widget rather than a text
> widget. :-)
>
As I've almost finished term for my 6 week Christmas holiday (life's so
hard) then I would have been happy to give this a go. There is one major
problem which will stop it from working however. You can't create table
widgets that don't have scroll bars and so you can't create a single
standalone cell, which could look like a CW_Field. Try this code to see what
I mean:
base = Widget_Base()
table = Widget_Table(base, XSIZE=1, YSIZE=1, VALUE=[0], ROW_LABELS=[' '],
COLUMN_LABELS=[' '], SCROLL=0)
Widget_Control, base, /REALIZE
See what I mean - it just looks messy. Well it does on windows, at least,
I'm not sure about UNIX. So I', afraid this idea's a bit of a non starter (I
think).
Cheers,
Phil
Phil Aldis,
Gonville and Caius College,
Cambridge University,
Cambridge.
CB2 1TA.
Phone: 01223 520026
E-Mail : philaldis@yahoo.com
|
|
|
Re: Right justifying text [message #18155 is a reply to message #18146] |
Thu, 02 December 1999 00:00  |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Robert S. Mallozzi (Robert.Mallozzi@msfc.nasa.gov) writes:
> If you set the size of the text area explicitly, you
> could do something like this:
>
> xsize = 40
> ysize = 1
> base = WIDGET_BASE (/COLUMN)
> text = WIDGET_TEXT (base, XSIZE = xsize, YSIZE = ysize, VALUE = '')
> WIDGET_CONTROL, /REALIZE, base
>
> num = 10.00
> fmt = "(F" + STRTRIM (xsize, 2) + ".2)" ; F40.2
>
> str = STRING (num, FORMAT = fmt)
> WIDGET_CONTROL, text, SET_VALUE = str
>
> You could make the number of digits after the decimal point a
> parameter as well; here I just hardcoded it to 2.
Humm. Maybe if you have a non-proportionally spaced
font in the text widget, but I doubt otherwise. A
table widget allows you to justify text. Maybe
Phil Aldis will write us a nice CW_FIELD-like compound
widget object that uses a Table Widget rather than a text
widget. :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
Re: Right justifying text [message #18156 is a reply to message #18155] |
Thu, 02 December 1999 00:00  |
robert.mallozzi
Messages: 11 Registered: November 1999
|
Junior Member |
|
|
In article <3846E255.EA3BB3FB@va.aetc.com>,
Bernard Puc <bpuc@va.aetc.com> writes:
> Hello,
>
> Does anyone have a method of right-justifying text in a text widget?
> I'm trying to display a single floating point numeral in a widget_text
> field.
> Thanks for any ideas.
If you set the size of the text area explicitly, you
could do something like this:
xsize = 40
ysize = 1
base = WIDGET_BASE (/COLUMN)
text = WIDGET_TEXT (base, XSIZE = xsize, YSIZE = ysize, VALUE = '')
WIDGET_CONTROL, /REALIZE, base
num = 10.00
fmt = "(F" + STRTRIM (xsize, 2) + ".2)" ; F40.2
str = STRING (num, FORMAT = fmt)
WIDGET_CONTROL, text, SET_VALUE = str
You could make the number of digits after the decimal point a
parameter as well; here I just hardcoded it to 2.
Regards,
-bob
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~
Robert S. Mallozzi 256-544-0887
Mail Code SD 50
http://gammaray.msfc.nasa.gov/ Marshall Space Flight Center
http://cspar.uah.edu/~mallozzir/ Huntsville, AL 35812
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~
|
|
|