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

Re: Two widget questions

Patrick L. Nolan (pln@egret1.stanford.edu) writes:

> I'm back with more questions about my first widget program.
> My first question about flashing colors was solved nicely.  Now
> I'm getting into more advanced details.

Oh, boy, this is great. :-)

> 1.  Is it possible to have exclusive button under a menu bar?

No, it is not possible.

> I tried putting a widget_base,/exclusive or a cw_bgroup as 
> children of a menu bar button.  In both cases it told me that
> the parent was the wrong type.

Exactly. About the best you can do is have some
visual way of indicating the menu item is selected.
For example, you can put an asterisk in front of 
selected items. Here is a small example of how to
do something like this:

PRO Example_Button_Events, event
Widget_Control, event.id, Get_Value=buttonValue, Get_UValue=buttonUValue
Widget_Control, event.id, Set_Value=buttonUValue, Set_UValue=buttonValue


tlb = Widget_Base(Column=1, Title='Make a Choice...')
selectID = Widget_Button(tlb, Value='Animal Selections...', /Menu, $
   Event_Pro='Example_Button_Events', Scr_XSize=200)
choice1 = Widget_Button(selectID, Value='Choose Dogs', /Menu)
button = Widget_Button(choice1, Value='Retriever', UValue='* Retriever')
button = Widget_Button(choice1, Value='Boxer', UValue='* Boxer')
button = Widget_Button(choice1, Value='Great Dane', UValue='* Great Dane')

choice2 = Widget_Button(selectID, Value='Choose Cows', /Menu)
button = Widget_Button(choice2, Value='Holstein', UValue='* Holstein')
button = Widget_Button(choice2, Value='Angus', UValue='* Angus')
button = Widget_Button(choice2, Value='Jersey', UValue='* Jersey')

Widget_Control, tlb, /Realize
XManager, 'example', tlb, /No_Block

> 2.  My base window contains a menu bar, a scrolling list, and a draw
> widget.  I want to handle resize events properly.  
> Is there some general way to deal with this?  Have I just missed
> the proper section in the book?

Uh, I'm sure it's in my book...somewhere. At least it *should*
be. :-(

Here is what I would do. Just before I realize the TLB
I would find out what size it is:

   tlb_geom = Widget_Info(tlb, /Geometry)

I would use the screen X and Y sizes here. What I want to know
is how much space in my top-level base is NOT composed of the
draw widget. 

   draw_geom = Widget_Info(drawID, /Geometry)
   extraXpixels = tlb_geom.scr_xsize - draw_geom.scr_xsize
   extraYpixels = tlb_geom.scr_ysize - draw_geom.scr_ysize

Now, I would save these numbers in my info structure so that
when I do the resize I can do something like this:

   Widget_Control, info.drawID, Draw_XSize=event.x - info.extraXpixels $
      Draw_YSize=event.y - info.extraYpixels

This leaves enough space for the other widgets that are still in the
top-level base and doesn't change their position or size.

Sadly, you sometimes still need a "fudge" factor on various platforms,
since the reporting of sizes is not totally consistent from one platform
to another. Test it on all the computers you expect to run on. Something
like this usually works OK.



David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155