DAVISM@kcgl1.eng.ohio-state.edu (Michael T. Davis) (05/14/91)
I am using DECwindows under VAX/VMS V5.4-2 (i.e. DECwindows 2.0). I
am trying to initialize an option menu such that it has a "default" value as
demonstrated/displayed in all the examples. I am using DwtNmenuHistory to set
the value to a widget (gadget) id which is a child of the pull-down menu, whose
parent is the option menu (catch that ;-). All I'm getting is a tiny rectangle
where the default value should be displayed. Only when I hold MB1 in that rec-
tangle, do I see anything from the pull-down menu. I am using a combination of
low-level and high-level routines to intialize the hierarchy, but no UIL.
Here's some sample code:
...
void my_proc(), my_other_proc();
char * list [];
int i, count;
Arg arglist [5];
DwtCallback callback [2];
DwtCompString compound_string;
Widget main_window, pd, * gadgets, om;
...
pd = DwtMenuPulldownCreate ( main_window, "pull down", arglist, 0 );
gadgets = ( Widget * ) calloc ( count + 2, sizeof ( Widget ) );
callback [0]. proc = my_proc;
callback [1]. proc = 0;
for ( i = 0; i < count; i++ )
{
callback [0]. tag = i + 1;
compound_string = DwtLatin1String ( list [ i ] );
XtSetArg ( arglist [0], DwtNlabel, compound_string );
XtSetArg ( arglist [1], DwtNactivateCallback, callback );
gadgets [ i ] =
DwtPushButtonGadgetCreate ( pd, NULL, arglist, 2 );
XtFree ( compound_string );
}
gadgets [ count ] =
DwtSeparatorGadgetCreate ( pd, NULL, arglist, 0 );
callback [0]. proc = my_other_proc;
callback [0]. tag = callback [1]. proc = 0;
compound_string = DwtLatin1String ( "whatever" );
XtSetArg ( arglist [0], DwtNlabel, compound_string );
XtSetArg ( arglist [1], DwtNactivateCallback, callback );
gadgets [ count + 1 ] =
DwtPushButtonGadgetCreate ( pd, NULL, arglist, 2 );
XtFree ( compound_string );
compound_string = DwtLatin1String ( "something else" );
XtSetArg ( arglist [0], DwtNx, 4 );
XtSetArg ( arglist [1], DwtNy, 88 );
XtSetArg ( arglist [2], DwtNlabel, compound_string );
XtSetArg ( arglist [3], DwtNsubMenuId, pd );
XtSetArg ( arglist [4], DwtNmenuHistory, gadgets [0] );
om = DwtOptionMenuCreate ( main_window, "option menu", arglist, 5 );
XtFree ( compound_string );
XtManageChildren ( gadgets, count + 2 );
XtManageChild ( om );
...
I would appreciate any pointers.
Thanks,
Mike
Internet: davism@kcgl1.eng.ohio-state.edu |
-or- DAVISM+@osu.edu | These Thoughts, They Be Mine
BITNET: DAVISM+@OHSTMAIL.BITNET |
baxter@xmws.uucp (06/01/91)
In article <1991May13.230003.24187@zardoz.eng.ohio-state.edu>, DAVISM@kcgl1.eng.ohio-state.edu (Michael T. Davis) writes: > I am using DECwindows under VAX/VMS V5.4-2 (i.e. DECwindows 2.0). I > am trying to initialize an option menu such that it has a "default" value as > demonstrated/displayed in all the examples. I am using DwtNmenuHistory to set > the value to a widget (gadget) id which is a child of the pull-down menu, whose > parent is the option menu (catch that ;-). All I'm getting is a tiny rectangle > where the default value should be displayed. Only when I hold MB1 in that rec- > tangle, do I see anything from the pull-down menu. I am using a combination of > low-level and high-level routines to intialize the hierarchy, but no UIL. > {code deleted} I don't know if you got a response to this in comp.os.vms, by the time I read this your message was purged out of my comp.os.vms news area... windows.x has lower volume and I keep it around longer... ANY WAY... I know what your problem is... I had it... The is a bug in the option menu widget... the widget sizes the popup at the time it is realized based the the CHILDREN IT HAS AT THAT TIME... Adding children latter will not cause the widget to resize the popup... and since there were not children at the time it was realized... it was tiny... Setting the DwtNmenuHistory resource SHOULD cause the widget to revaluate the size requirements of the popup on its then current children BUT IT DOESN'T. It works in UIL because it knows at the time it is realized what the sizes of its children need to be... IN fact... in UIL the whole HIERARCHY is predefined... (which ofcouse in the problem with UIL) The work-around is to make sure you have added the children to the OPtion menu's popup BEFORE realizing the OptionMenu. If you cann't to this then you will have to either resize the popup yourself with the XtSetValues function at the time you do... (which is painfull) since you have to know the how big to make it. It MAY be possible retrigger geometry negotiation the right Xt function... or you could (perish the thought...) Unrealize and the realize it again... but that will look ugly... Best bet if you can, is to add the children before realizing the OptionMenu. Lincoln Baxter baxter@xmws.uucp OR ...uunet!cbmvax!xmws!baxter