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

Home » Public Forums » archive » widget_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: widget_text [message #12051 is a reply to message #2051] Fri, 12 June 1998 00:00 Go to previous messageGo to previous message
J.D. Smith is currently offline  J.D. Smith
Messages: 214
Registered: August 1996
Senior Member
David Fanning wrote:
>
> Lisa Bryan (lbryan@arete-az.com) writes:
>
>> I've been experimenting with WIDGET_TEXT hoping to make a text box
>> which will show the user messages from anywhere in my application.
>
> ...[nice solution snipped]...
>
>> Is there a better way to avoid this work around?
>
> I don't think that is a work-around. I think you found
> the only real solution.
>
>> P.S. Is there really no way I can get rid of the frame around a text
>> box under Windows!?!
>
> Not that I know of.
>
> Nice programming style, by the way. :-)
>
> Cheers,
>
> David

Come now David, there's always a way!

How about a convenience routine such as:

pro add_message, state_ptr, message
widget_control, (*state_ptr).text_box,set_value=message,/append

;; Find the last line in the text box
nt=widget_info((*state_ptr).text_box,/TEXT_NUMBER)
last_line=(widget_info((*state_ptr).text_box,TEXT_OFFSET_TO_ XY=nt-1))[1]

;; Only adjust the scrolling if we've scrolled off the bottom
if last_line lt (*state_ptr).box_ysize then return
widget_control, (*state_ptr).text_box, set_text_top_line = $
last_line-(*state_ptr).box_ysize+1
end

Note that this does *not* work with text widgets with /WRAP set (though see below),
and that another state variable, box_ysize (the ysize of the text widget), in lieu
of your top_line variable, is required (...well, not strictly, since you could do a
widget_info(/GEOMETRY,box) to find out the box's ysize -- but that's pretty
inefficient). It will still work even if some inconsiderate application or user
adds text without doing it nicely (i.e. incrementing your top_line variable).

Or, for an entirely magic way, at least on Linux, just set /WRAP on your text widget
when created. That gives you this behaviour automatically... i.e. you don't have to
go through the set_text_top_line business (in fact, that would fail), and the call:

widget_control, (*state_ptr).text_box, set_value = 'my text', /append

will do this all by itself. I'm not sure if this /WRAP solution works for all
platforms, but it certainly is the easiest way. Just tested and it does not work on
Windows v5.0.

Good Luck,

JD

--
J.D. Smith |*| WORK: (607) 255-5842
Cornell University Dept. of Astronomy |*| (607) 255-4083
206 Space Sciences Bldg. |*| FAX: (607) 255-5875
Ithaca, NY 14853 |*|
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: widget_text (correction)
Next Topic: resizing tlb with /align_right, /align_bottom

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

Current Time: Sun Oct 12 01:31:25 PDT 2025

Total time taken to generate the page: 0.39879 seconds