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

Home » Public Forums » archive » CENTERING TEXT
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
CENTERING TEXT [message #13059] Fri, 02 October 1998 00:00 Go to next message
dsheerin is currently offline  dsheerin
Messages: 8
Registered: June 1998
Junior Member
Hi

Can anyone tell me how to center text in a text widget?
Thanks for any help received.

David
Re: CENTERING TEXT [message #13122 is a reply to message #13059] Wed, 07 October 1998 00:00 Go to previous message
David Foster is currently offline  David Foster
Messages: 341
Registered: January 1996
Senior Member
David Fanning wrote:
>
> 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. :-)

Maybe I'm missing something, but I seem to be able to center
non-proportional-font text just fine with CENTER_TEXT.PRO .
I've included it here (again). Prove me wrong. Make my day...

Dave

;=========================================================== =====
; 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


--

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: what am I doing wrong?
Next Topic: Re: Widgets and classes

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

Current Time: Fri Oct 10 10:30:21 PDT 2025

Total time taken to generate the page: 0.40404 seconds