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

Home » Public Forums » archive » Re: CENTERING TEXT
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: CENTERING TEXT [message #13047 is a reply to message #13045] Fri, 02 October 1998 00:00 Go to previous messageGo to previous message
David Foster is currently offline  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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: call_external with PASCAL calling convention
Next Topic: Would you consider this a bug?

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

Current Time: Sat Nov 29 15:46:23 PST 2025

Total time taken to generate the page: 1.35454 seconds