1 /*
2 * You should also run this with
3 * test1 -xrm "*tearOffModel: tear_off_enabled"
4 */
5 #include <stdio.h>
6 #include <Xm/Xm.h>
7 #include <Xm/RowColumn.h>
8 #include <Xm/PushB.h>
9 #include <Xm/PushBG.h>
10 #include <Xm/CascadeB.h>
11 #include <Xm/MenuShell.h>
12 #include <Xm/MessageB.h>
13
14 #include <Xm/Xm.h>
15 #include <Xm/XmP.h>
16
17 #if 0
18 #include <X11/Xmu/Editres.h>
19 #endif
20
21 char *fallback[] = {
22 "*tearOffModel: tear_off_enabled",
23 "*cascade.labelString: Menu",
24 "*cascade.mnemonic: M",
25 "*button1.labelString: Dialog From Button",
26 "*button1.mnemonic: 1",
27 "*button1.acceleratorText: Ctrl-1",
28 "*button1.accelerator: Ctrl<Key>1",
29 "*button2.labelString: Dialog From Pane",
30 "*button2.mnemonic: 2",
31 "*button2.acceleratorText: Ctrl-2",
32 "*button2.accelerator: Ctrl<Key>2",
33 "*button3.labelString: Dialog From MenuBar",
34 "*button3.mnemonic: 3",
35 "*button3.acceleratorText: Ctrl-3",
36 "*button3.accelerator: Ctrl<Key>3",
37 "*button4.labelString: Dialog From TopLevel",
38 "*button4.mnemonic: 4",
39 "*button4.acceleratorText: Ctrl-4",
40 "*button4.accelerator: Ctrl<Key>4",
41 "*okLabelString: This is OK",
42 "*cancelLabelString: Cancel me if you can",
43 NULL /* The end */
44 };
45
46 XtAppContext theApp;
47 Widget toplevel, rc, cascade, pane, w;
48
49
50 /*
51 * The Dialog that is a child of "w" will not work,
52 * the one from "toplevel" will.
53 */
Doit(Widget w,XtPointer client,XtPointer call)54 void Doit(Widget w, XtPointer client, XtPointer call)
55 {
56 Widget b = NULL;
57 int c = (int)client;
58
59 switch (c) {
60 case 1:
61 b = XmCreateQuestionDialog(w, "box-1", NULL, 0);
62 break;
63 case 2:
64 b = XmCreateQuestionDialog(pane, "box-2", NULL, 0);
65 break;
66 case 3:
67 b = XmCreateQuestionDialog(rc, "box-3", NULL, 0);
68 break;
69 case 4:
70 b = XmCreateQuestionDialog(toplevel, "box-4", NULL, 0);
71 break;
72 }
73 XtManageChild(b);
74 }
75
76 int
main(int argc,char ** argv)77 main(int argc, char **argv)
78 {
79 toplevel = XtVaAppInitialize(&theApp, "test1", NULL, 0, &argc, argv, fallback, NULL);
80
81 #if 0
82 XtAddEventHandler(toplevel, (EventMask)0, True, _XEditResCheckMessages, NULL);
83 #endif
84
85 rc = XmCreateMenuBar(toplevel, "menubar", NULL, 0);
86
87 pane = XmCreatePulldownMenu(rc, "pane", NULL, 0);
88
89 cascade = XtVaCreateManagedWidget("cascade", xmCascadeButtonWidgetClass, rc,
90 XmNsubMenuId, pane,
91 NULL);
92
93 w = XtVaCreateManagedWidget("button1", xmPushButtonWidgetClass, pane,
94 NULL);
95 XtAddCallback(w, XmNactivateCallback, Doit, (XtPointer)1);
96
97 w = XtVaCreateManagedWidget("button2", xmPushButtonWidgetClass, pane,
98 NULL);
99 XtAddCallback(w, XmNactivateCallback, Doit, (XtPointer)2);
100
101 w = XtVaCreateManagedWidget("button3", xmPushButtonWidgetClass, pane,
102 NULL);
103 XtAddCallback(w, XmNactivateCallback, Doit, (XtPointer)3);
104
105 w = XtVaCreateManagedWidget("button4", xmPushButtonWidgetClass, pane,
106 NULL);
107 XtAddCallback(w, XmNactivateCallback, Doit, (XtPointer)4);
108
109 XtManageChild(rc);
110 XtRealizeWidget(toplevel);
111
112 /* Note: the following values are the result of
113 * querying the current geometry.
114 */
115 {
116 static XtWidgetGeometry Expected[] = {
117 CWWidth | CWHeight , 0, 0, 50, 31, 0,0,0, /* menubar */
118 CWWidth | CWHeight | CWX | CWY, 5, 5, 40, 21, 0,0,0, /* cascade */
119 };
120 /* toplevel should be replaced with to correct applicationShell */
121 PrintDetails(toplevel, Expected);
122 }
123 LessTifTestMainLoop(toplevel);
124
125 exit(0);
126 }
127