Re: CENTERING TEXT [message #13042] |
Sun, 04 October 1998 00:00 |
lbrown1698
Messages: 1 Registered: October 1998
|
Junior Member |
|
|
I haven't been paying attention to the whole thread but how bout this (from the
online help):
ALIGNMENT
This keyword applies to widgets created with the WIDGET_TABLE function.
Set this keyword equal to a scalar or 2-D array specifying the alignment of the
text within each cell. An alignment of 0 (the default) aligns the left edge of
the text with the left edge of the cell. An alignment of 2 right-justifies the
text, while 1 results in text centered within the cell. If ALIGNMENT is set
equal to a scalar, all table cells are aligned as specified. If ALIGNMENT is
set equal to a 2-D array, the alignment of each table cell is governed by the
corresponding element of the array. If the USE_TABLE_SELECT keyword is set,
then the alignment is changed only for the selected cells.
LBrown1698@aol.com
|
|
|
Re: CENTERING TEXT [message #13043 is a reply to message #13042] |
Sat, 03 October 1998 00:00  |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Phillip David (pdavid@earthling.net) writes:
> If you really want to do this, the answer is simple. Just don't use a
> proportionally spaced font.
I hate to keep harping on this, but sometimes the simple
answers are the hardest to implement. :-)
I would send a book (of your choice and my modest means)
to anyone who can reliably center text in a text widget
using *any* kind of text. :-)
Cheers,
David
----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
E-Mail: davidf@dfanning.com
Phone: 970-221-0438, Toll-Free Book Orders: 1-888-461-0155
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|
Re: CENTERING TEXT [message #13045 is a reply to message #13043] |
Fri, 02 October 1998 00:00  |
Phillip & Suzanne
Messages: 31 Registered: June 1998
|
Member |
|
|
If you really want to do this, the answer is simple. Just don't use a
proportionally spaced font. You can set a font to Courier fairly easily at
least in IDL 5.1. Mainly, I had to get into this thread as I noticed that it
was the 'David' thread, and I wanted to add a David at the other end of the name...
Phillip David
David Fanning wrote:
> In any case, I think centering text in a text widget is
> probably impossible with proportionally spaced fonts.
|
|
|
Re: CENTERING TEXT [message #13046 is a reply to message #13045] |
Fri, 02 October 1998 00:00  |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
David Foster (foster@bial1.ucsd.edu) writes:
> David Sheerin wrote:
>>
>> Hi
>>
>> Can anyone tell me how to center text in a text widget?
>> Thanks for any help received.
>>
>> David
>
> David -
>
> I'm procrastinating, so here's a little procedure to do this...
Alas, this didn't work for me, given that my default font
is a proportionally spaced font. In fact, the text got cut
off. Apparently the character that is used to count "spaces"
is much smaller than the actual characters in my string.
In any case, I think centering text in a text widget is
probably impossible with proportionally spaced fonts.
Cheers,
David
----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
E-Mail: davidf@dfanning.com
Phone: 970-221-0438, Toll-Free Book Orders: 1-888-461-0155
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|
Re: CENTERING TEXT [message #13047 is a reply to message #13045] |
Fri, 02 October 1998 00:00  |
David Foster
Messages: 341 Registered: January 1996
|
Senior Member |
|
|
David Sheerin wrote:
>
> Hi
>
> Can anyone tell me how to center text in a text widget?
> Thanks for any help received.
>
> David
David -
I'm procrastinating, so here's a little procedure to do this...
;=========================================================== =
; CENTER_TEXT.PRO 10-02-98 DSFoster
;
; Procedure to center a message within a text widget.
PRO center_text, text_wid, message
if (widget_info(text_wid, /valid_id) eq 0) then begin
message, 'Invalid widget identifier: ' + strmid(text_wid,2), /info
endif else if (widget_info(text_wid, /name) ne 'TEXT') then begin
message, 'Widget ID not a text widget: ' + strmid(text_wid,2), /info
endif else if (n_params() lt 2) then begin
message, 'Missing required parameters', /info
endif else begin
geom = widget_info(text_wid, /geometry)
xsize = round(geom.xsize) ; Size of text widget in chars
ok = execute( "str = string(' ', format='(a" + $
strtrim(xsize,2) + ")')" )
start = 0 > round((xsize - strlen(message))/2)
strput, str, message, start
widget_control, text_wid, set_value=str
endelse
return
END
;=========================================================== =
Dave
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
David S. Foster Univ. of California, San Diego
Programmer/Analyst Brain Image Analysis Laboratory
foster@bial1.ucsd.edu Department of Psychiatry
(619) 622-5892 8950 Via La Jolla Drive, Suite 2240
La Jolla, CA 92037
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
|
|
|
Re: CENTERING TEXT [message #13058 is a reply to message #13045] |
Fri, 02 October 1998 00:00  |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
David Sheerin (dsheerin@dera.gov.uk) writes:
> Can anyone tell me how to center text in a text widget?
> Thanks for any help received.
Can't be done as far as I know. When I need centered text
I put the text in a Label Widget and use the Align_Center
keyword. :-)
Cheers,
David
----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
E-Mail: davidf@dfanning.com
Phone: 970-221-0438, Toll-Free Book Orders: 1-888-461-0155
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|