[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Secret to resizing text widgets

	I played around with this for a while and came up with a 
reasonably generic solution using the Widget_Info(wid*, /Geometry) 
function after the base has been realized.  
	This works with both text and draw widgets on both Windows 
NT and Solaris 5.7 with IDL 5.2.
	One problem is the menubar on Solaris: it is included in the 
widbase geometry but seems to be ignored when widbase is resized, 
leading to the window growing by the menu height extra vertically.

In article <38DBDE9A.46DAA20A@mailhost.va.aetc.com>,
Bernard Puc  <bpuc@va.aetc.com> wrote:
>	I give up.  Who can tell me the secret to modifying the size of a text
>widget with resize events on the base widget?  I want to have a simple
>widget to display some lines of text.  I want the user to be able to
>resize the window.  Why is this so difficult?  All the examples of
>resize that I have looked at deal with draw widgets only.  If I specify
>a base widget with column ordering, the xsize of the text widget
>automatically gets resized, but the y axis does not.  If I specify the
>xsize of the text widget, it is ignored.  Below is the code sample I
>have been stressing over.  If anyone can help, I'd be too grateful for
><=======Start of file testbox.pro==================>
>pro testbox_event, event
>widget_Control, event.top, Update = 0
>widget_control, event.top, get_uvalue = info
>widget_control, event.top, tlb_get_size = tlbsize
>;print,'1-Base size:',tlbsize

;>widget_control, info.widtext, scr_ysize = event.y
;>widget_control, info.widtext, scr_xsize = event.x
widget_control, info.widtext, scr_ysize = event.y-info.geo.y_offs
widget_control, info.widtext, scr_xsize = event.x-info.geo.x_offs

>;print,'( '+strtrim(event.x,2)+', '+strtrim(event.y,2)+')'
>;Reset the widbase widget size

;>widget_Control, event.top, xsize = tlbsize[0]-0, ysize = tlbsize[1]-0
widget_Control, event.top, xsize = tlbsize[0]+info.geo.x_xtra,$
			   ysize = tlbsize[1]+info.geo.y

>widget_control, event.top, /update
>widget_control, event.top, tlb_get_size = tlbsize
>;print,'2-Base size:',tlbsize
>wait, 0.01
>pro testbox
>widbase = widget_base(column = 0,$
>	TLB_Size_Events = 1)
>widbuttonclose = widget_button(widbase,$
>	value = 'Close',$
>	ysize = 30,$
>	xsize = 120)
>widtext = widget_text(widbase,$
>	scroll = 1,$
>	editable = 1,$
>	yoffset = 35,$
>	scr_xsize = 200,$	;Units are pixels
>	scr_ysize = 300)
tlbgeo = Widget_Info(widbase, /geometry)
txtgeo = Widget_Info(widtext, /geometry)
x_xtra = tlbgeo.scr_xsize - tlbgeo.xsize
y_xtra = tlbgeo.scr_ysize - tlbgeo.ysize
x_offs = tlbgeo.xsize - txtgeo.scr_xsize
y_offs = tlbgeo.ysize - txtgeo.scr_ysize

geo = { x_xtra:x_xtra,y_xtra:y_xtra,$
>info = {$
>	widbuttonclose:widbuttonclose,$
>	widtext:widtext }
>widget_control, widbase, /realize, Set_Uvalue = info
>xmanager, 'testbox', widbase, /no_block
>Bernard Puc                     AETC, INC.									  
>bpuc@va.aetc.com                1225 Jefferson Davis Highway #800
>(703) 413-0500                  Arlington, VA 22202

Mike Fitzgibbon			MRFitz@ns.arizona.edu
UofAz, LPL			phone:(520)626-4791
Systems Programmer, Sr.		fax:  (520)621-6783