PRO RESIZE_EVENT, EVENT ;- Get info structure widget_control, event.top, get_uvalue=info ;- Resize the draw widget using one of two methods case info.fix of ;- First method: widget grows vertically 0 : widget_control, info.drawid, xsize=event.x, ysize=event.y ;- Second method: resizes widget correctly 1 : begin ;- Get current tlb size widget_control, event.top, tlb_get_size=result tlb_xsize = result[0] tlb_ysize = result[1] ;- Compute difference between current and old tlb size xdiff = tlb_xsize - info.tlb_xsize ydiff = tlb_ysize - info.tlb_ysize ;- Set new tlb size info.tlb_xsize = tlb_xsize info.tlb_ysize = tlb_ysize ;- Set new draw widget size info.draw_xsize = info.draw_xsize + xdiff info.draw_ysize = info.draw_ysize + ydiff ;- Resize the draw widget widget_control, info.drawid, $ draw_xsize=info.draw_xsize, draw_ysize=info.draw_ysize end endcase ;- Display a plot plot, indgen(10) END ;---------------------------------------------------------------- PRO RESIZE, FIX=FIX ;- Check keywords if not keyword_set( fix ) then fix = 0 ;- Set initial size of draw widget draw_xsize = 400 draw_ysize = 400 ;- Create base widget with menubar and draw widget tlb = widget_base( title='Resize Example', $ tlb_size_events=1, mbar=menubase ) drawid = widget_draw( tlb, xsize=draw_xsize, ysize=draw_ysize ) widget_control, tlb, /realize ;- Display a plot plot, indgen(10) ;- Get size of top level base widget_control, tlb, tlb_get_size=result tlb_xsize = result[0] tlb_ysize = result[1] ;- Create and store info structure info = { fix : fix, $ drawid : drawid, $ draw_xsize : draw_xsize, $ draw_ysize : draw_ysize, $ tlb_xsize : tlb_xsize, $ tlb_ysize : tlb_ysize } widget_control, tlb, set_uvalue = info ;- Manage widget events xmanager, 'resize', tlb END