[Search for users]
[Overall Top Noters]
[List of all Conferences]
[Download this site]
Title: | DECWINDOWS 26-JAN-89 to 29-NOV-90 |
Notice: | See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit |
Moderator: | STAR::VATNE |
|
Created: | Mon Oct 30 1989 |
Last Modified: | Mon Dec 31 1990 |
Last Successful Update: | Fri Jun 06 1997 |
Number of topics: | 3726 |
Total number of notes: | 19516 |
2571.0. "PULLDOWNMENUECREATE IN SUBMENUE PROBLEM" by OSLLAV::EIVINDR () Wed Apr 04 1990 14:45
Hello!
This note is added from decwindow_programming note nr 742 because no responce
there.
I have a program from a customer. The problem is that when an item from a
pull-right (submenu) is selected, the menu is not unmanaged. Instead the error
X Toolkit Warning: XtRemoveGrab asked to remove a widget not on the grab list
is displayed. I haven't found any examples on how to do this correctly. What
is wrong with the code?
Olav
#include <stdio.h>
#ifdef VMS
#include <decw$include:DwtAppl.h> /* DECwindows Toolkit */
#else
#include <X11:DwtAppl.h> /* DECwindows Toolkit */
#endif
static void activate_proc();
static DwtCallback callback_arg[2];
static char *itoa( int );
/******** Main program ************/
int main(argc, argv)
unsigned int argc;
char **argv;
{
DwtCallback CallbackArg[3];
Widget toplevel,MainApplication,PullDownEntry[11],MenuBar,EntryWidget,
Push[11],MenuWidget,SubMenu[11];
int i,j;
Arg Arglist[6] ;
toplevel = XtInitialize("Hi","helloworldclass",NULL,0,&argc, argv);
XtSetArg (Arglist[0], XtNallowShellResize, TRUE) ;
XtSetValues (toplevel, Arglist, 1) ;
MainApplication = DwtMainWindowCreate(toplevel,"main",NULL,0);
XtSetArg (Arglist[0], DwtNx,100);
XtSetArg (Arglist[1], DwtNy,200);
XtSetArg (Arglist[2], DwtNwidth, 500);
XtSetArg (Arglist[3], DwtNheight, 200);
XtSetArg (Arglist[4], DwtNacceptFocus, TRUE);
XtSetValues (MainApplication, Arglist, 5) ;
MenuBar = DwtMenuBarCreate(MainApplication,"menubar",NULL,0);
XtSetArg (Arglist[0], DwtNorientation, DwtOrientationHorizontal);
XtSetArg (Arglist[1], DwtNspacing, 15);
XtSetValues (MenuBar, Arglist, 2) ;
XtManageChild(MenuBar);
EntryWidget = DwtPullDownMenuEntryCreate(MenuBar,"entry",NULL,0);
XtSetArg( Arglist[0],DwtNlabel,DwtLatin1String("Entry"));
XtSetValues( EntryWidget,Arglist,1);
MenuWidget = DwtMenuPulldownCreate(EntryWidget,"menu",NULL,0);
XtSetArg(Arglist[0],DwtNsubMenuId,MenuWidget);
XtSetValues( EntryWidget,Arglist,1);
XtManageChild(EntryWidget);
for (i = 0;i<10;i++) {
PullDownEntry[i] = DwtPullDownMenuEntryCreate(MenuWidget,"pull",NULL,0);
SubMenu[i] = DwtMenuPulldownCreate(PullDownEntry[i],"entries",NULL,0);
XtSetArg(Arglist[0],DwtNsubMenuId,SubMenu[i]);
XtSetValues( PullDownEntry[i],Arglist,1);
XtSetArg( Arglist[0],DwtNlabel,DwtLatin1String(itoa(i)));
XtSetValues( SubMenu[i],Arglist,1);
for (j = 0; j < 10 ; j++) {
Push[j] = DwtPushButtonCreate(SubMenu[i],"text",NULL,0);
CallbackArg[0].proc = activate_proc;
CallbackArg[0].tag = &i;
CallbackArg[1].proc = NULL;
XtSetArg( Arglist[0],DwtNlabel,DwtLatin1String(itoa(j)));
XtSetArg( Arglist[1],DwtNactivateCallback, CallbackArg);
XtSetValues( Push[j], Arglist, 2);
XtManageChild(Push[j]);
}
XtManageChild(PullDownEntry[i]);
}
XtManageChild(MainApplication);
XtRealizeWidget(toplevel);
XtMainLoop();
/* UNREACHABLE */
return (0);
}
void activate_proc(w, Tag, Reason)
Widget w;
int *Tag;
unsigned long *Reason;
{
printf("I ACTIVATE_PROC\n");
}
static char *itoa(n)
int n;
{
int d=1,i,j,k=0;
char *s;
if (n<0) {
k=1;
n=abs(n);
}
for ( i=1; ;i++ ) {
if ( n/d < 10.0)
break;
d *= 10;
}
if (k) i++;
s = malloc(i+1);
if (k)
s[0]='-';
s[i] = '\0';
for (j=k;j<i;j++) {
s[j] = '0'+ (n-(n % d))/d;
n = n - (n - (n % d));
d /= 10;
}
return s;
}
T.R | Title | User | Personal Name | Date | Lines |
---|
2571.1 | RE: PULLDOWNMENU CREATE IN SUBMENU PROBLEM | RTL::JUNE | | Thu Apr 05 1990 11:13 | 9 |
|
Your widget hierarchy is messed up in the test program. Although it
seems logical at first that a pulldown menu would be the child of the
pulldown menu entry that activates it, in actuality the two should have
the same parent. So, in your example EntryWidget and MenuWidget should
both be children of MenuBar, and PulldownEntry[n] and SubMenu[n] should both
be children of MenuWidget. That should fix the problem.
Rich
|
2571.2 | | OSLLAV::EIVINDR | | Fri Apr 06 1990 04:59 | 5 |
| HELLO!
We have modified the program and now it works.
Thank you very much.
|