Two widget questions [message #17714] |
Mon, 08 November 1999 00:00  |
pln
Messages: 10 Registered: September 1991
|
Junior Member |
|
|
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.
1. Is it possible to have exclusive button under a menu bar?
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.
I want to make a toggle between two mutually exclusive situations.
I have been faking it by making one of the buttons insensitive
and switching it when the other is pressed. This is not really
satisfactory because the currently active situation is represented
by the grayed-out button. I don't consider that intuitively obvious.
I don't want to have a single button whose "value" text changes,
because I want to make it clear that there are two choices.
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?
--
* Patrick L. Nolan
* W. W. Hansen Experimental Physics Laboratory (HEPL) *
* Stanford University *
|
|
|
Re: Two widget questions [message #17773 is a reply to message #17714] |
Wed, 10 November 1999 00:00  |
pln
Messages: 10 Registered: September 1991
|
Junior Member |
|
|
David Fanning (davidf@dfanning.com) wrote:
: Patrick L. Nolan (pln@egret1.stanford.edu) writes:
:
: > 1. Is it possible to have exclusive button under a menu bar?
:
: No, it is not possible.
:
: 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:
:
<example omitted>
This is a good idea. It's easy to implement and it gives a pretty good
visual impression of the current state.
: ************************************************************ ************
:
: > 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?
:
: 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
:
: 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.
:
I'm running this on Solaris. By experiment I find that the extraYpixels
is always low by 33 pixels. I suppose that must be the size of the menu
bar.
|
|
|