1 /* simple test program */
2
3 #include <Xm/Xm.h>
4 #include <Xm/DropDown.h>
5 #include <Xm/XmAll.h>
6 #include <stdio.h>
7 #include <stdlib.h>
8
9 static int done = 0;
10
quitCB(Widget w,XtPointer client,XtPointer call)11 static void quitCB(Widget w, XtPointer client, XtPointer call)
12 {
13 done = 1;
14 }
15
16 /* note! using names of the widgets as equivalent to the labels */
17 static char * values[] = {
18 "Mercury", "Venus",
19 "Earth", "Mars",
20 "Jupiter", "Saturn",
21 "Uranus", "Neptune",
22 "Pluto",
23 };
24
createQuit(Widget quit_parent)25 static void createQuit(Widget quit_parent)
26 {
27 Widget button = XmCreatePushButton(quit_parent, "quit", NULL, 0);
28 XtManageChild(button);
29 XtAddCallback(button, XmNactivateCallback, quitCB, (XtPointer)NULL);
30 }
31
createScreen(Widget parent)32 static void createScreen(Widget parent)
33 {
34 Widget top = XmCreatePanedWindow(parent, "pane", NULL,0);
35
36 Widget tab = XmCreateTabStack(top,"tab",NULL,0);
37
38 XtManageChild(XmCreateScrolledText(tab,"explanation",NULL,0));
39
40 {
41 XmStringTable tmp0;
42 Arg args[10];
43 int n, i = XtNumber(values);
44 Widget combo;
45 Widget rc = XmCreateRowColumn(tab, "rc", NULL,0);
46 XtManageChild(rc);
47
48 tmp0 = (XmStringTable) XtMalloc(i * sizeof(XmString));
49 for(n = 0; n < i; n++)
50 tmp0[n] = XmStringCreateLocalized(values[n]);
51 n=0;
52 XtSetArg(args[n], XmNitems, tmp0); n++;
53 XtSetArg(args[n], XmNitemCount, i); n++;
54 combo = XmCreateDropDown(rc, "combo", args, n);
55
56 XtManageChild(combo);
57 }
58
59 createQuit(top);
60
61 XtManageChild(tab);
62 XtManageChild(top);
63 }
64
65 #define CLASS "Combo"
66
67 int
main(int argc,char * argv[])68 main (int argc,char *argv[])
69 {
70 XtAppContext app_context;
71 Widget app_shell;
72 Display *display;
73
74 XtSetLanguageProc(NULL, (XtLanguageProc) NULL, NULL);
75
76 app_shell = XtVaOpenApplication ( &app_context,
77 CLASS,
78 NULL,
79 0,
80 &argc,
81 argv,
82 NULL,
83 sessionShellWidgetClass,
84 NULL );
85
86 XtVaSetValues(app_shell,XmNallowShellResize, True, NULL);
87
88 /* create application */
89 createScreen(app_shell);
90
91 XtRealizeWidget(app_shell);
92
93 /* Process events, unwrapping correctly. */
94 while (!done)
95 {
96 XEvent event;
97 XtAppNextEvent(app_context, &event);
98 XtDispatchEvent(&event);
99 }
100
101 XtDestroyWidget(app_shell);
102 XtDestroyApplicationContext(app_context);
103 exit(0);
104 }
105
106