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

Re: Two widget questions

pln@egret1.stanford.edu (Patrick L. Nolan) writes:
> 2.  My base window contains a menu bar, a scrolling list, and a draw
> widget.  I want to handle resize events properly.  At first I resized
> the draw widget to event.x and event.y.  This doesn't work properly
> because of the space occupied by the menu bar and list.  The user
> moves the window corner to the desired place, and then the thing
> grows a bit.  By experimenting I found approximately how much padding
> is required to make it come out right, but this is a very fragile
> solution.
> So far I haven't found a reliable solution.  I have been trying to
> use widget_info(/geometry) and widget_control,/tlb_get_size to
> find the actual sizes of the draw and base widgets before and after
> the resize.  Unfortunately the results don't seem to be reliable, or 
> I just don't understand how to interpret them.  Indeed, the manual 
> says that widget_info(/geometry) returns an incorrect value if there 
> is a menu bar.
> Is there some general way to deal with this?  Have I just missed
> the proper section in the book?

I never found a textbook way to solve this problem.  The resizing bug
is truly a nuisance.  Here is my best solution:

1. Create an encapsulating top level base with xpad=0 ypad=0 and then
   put your practical top level base within that.  Example:

   tlb0 = widget_base(column=1, tlb_size_events=1, xpad=0, ypad=0)
   tlb  = widget_base(tlb0, column=1)
   ... fill up the tlb base ...

   This doesn't work if you insist on a top-level menu.  You can
   create an IDL menu under tlb if you need to.

   However, this seems to take care of the growing widget problem.
   The rest of the steps are optional if you decide to add a menu

2. Create a menu if you need it under tlb.

3. Realize the widget and get the size of the menu.

4. If needed, enlarge the window to fully encompass the menu.

5. When resize events come, resize the widget taking into account the
   menu size.


Craig B. Markwardt, Ph.D.         EMAIL:    craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response