1 #include <Xm/XmP.h>
2 #include <Xm/Form.h>
3 #include <Xm/RowColumn.h>
4 #include <Xm/CascadeB.h>
5 #include <Xm/CascadeBG.h>
6 #include <Xm/PushB.h>
7 #include <Xm/PushBG.h>
8 #include <Xm/SeparatoG.h>
9 #include <Xm/MenuShell.h>
10 #include <Xm/MainWP.h>
11 #include <Xm/MessageB.h>
12 #include <Xm/Command.h>
13 #include <stdio.h>
14
15 void
dump_sw(char * where,Widget w)16 dump_sw(char *where, Widget w)
17 {
18 XmMainWindowWidget mw = (XmMainWindowWidget) w;
19
20 printf(where);
21 printf("Given W: %d H: %d\n", mw->swindow.GivenWidth,
22 mw->swindow.GivenHeight);
23 printf("Area W: %d H: %d\n", mw->swindow.AreaWidth,
24 mw->swindow.AreaHeight);
25 printf("MWArea W: %d H: %d\n", mw->mwindow.AreaWidth,
26 mw->mwindow.AreaHeight);
27 /*
28 printf("Pad W: %d H: %d\n", mw->swindow.WidthPad(w),
29 mw->swindow.HeightPad);
30 */
31 printf("Offset X: %d Y: %d\n", mw->swindow.XOffset, mw->swindow.YOffset);
32 printf("Spacing: %d\n", mw->swindow.pad);
33 printf("Has: %d %d\n", mw->swindow.hasHSB, mw->swindow.hasVSB);
34 printf("HSB: %d %d %d %d\n", mw->swindow.hsbX, mw->swindow.hsbY,
35 mw->swindow.hsbWidth, mw->swindow.hsbHeight);
36 printf("VSB: %d %d %d %d\n", mw->swindow.vsbX, mw->swindow.vsbY,
37 mw->swindow.vsbWidth, mw->swindow.vsbHeight);
38 /*
39 printf("HSB values: %d %d %d %d\n", mw->swindow.hmin, mw->hmax,
40 mw->swindow.hOrigin, mw->swindow.hExtent);
41 printf("VSB values: %d %d %d %d\n", mw->swindow.vmin, mw->vmax,
42 mw->swindow.vOrigin, mw->swindow.vExtent);
43 */
44 printf("Done.\n\n");
45 }
46
47 int
main(int argc,char ** argv)48 main(int argc, char **argv)
49 {
50 XtAppContext theApp;
51 Widget shell, toplevel, menubar, filepane;
52 Widget button, button1, button2, sep;
53 Widget saveAsPane, button3, button4, button5;
54 Widget button6, button7, editpane;
55 Widget mb, com;
56 Widget one, two, three;
57 XmString xmstr;
58
59 shell = XtVaAppInitialize(&theApp, "mainW", NULL, 0,
60 &argc, argv, NULL, NULL);
61
62 toplevel = XmCreateMainWindow(shell, "MainWindow", NULL, 0);
63 XtVaSetValues(toplevel, XmNshowSeparator, True, NULL);
64 XtManageChild(toplevel);
65 dump_sw("after init\n", toplevel);
66
67 menubar = XmCreateMenuBar(toplevel,
68 "menuBar",
69 NULL,0);
70 dump_sw("after add menu\n", toplevel);
71 XtManageChild(menubar);
72 dump_sw("after manage menu\n", toplevel);
73
74 filepane = XmCreatePulldownMenu(menubar,
75 "pane",
76 NULL,0);
77
78 xmstr = XmStringCreateSimple("File");
79
80 button = XtVaCreateManagedWidget("File",
81 xmCascadeButtonWidgetClass,
82 menubar,
83 XmNsubMenuId, filepane,
84 XmNlabelString, xmstr,
85 NULL);
86
87 editpane = XmCreatePulldownMenu(menubar,
88 "pane2",
89 NULL, 0);
90
91 button6 = XtVaCreateManagedWidget("Edit",
92 xmCascadeButtonGadgetClass,
93 menubar,
94 XmNsubMenuId, editpane,
95 NULL);
96
97 button7 = XtVaCreateManagedWidget("Cut",
98 xmPushButtonGadgetClass,
99 editpane,
100 NULL);
101
102 button1 = XtVaCreateManagedWidget("Open",
103 xmPushButtonGadgetClass,
104 filepane,
105 NULL);
106
107 sep = XtVaCreateManagedWidget("sep",
108 xmSeparatorGadgetClass,
109 filepane,
110 NULL);
111
112 button2 = XtVaCreateManagedWidget("Close",
113 xmPushButtonWidgetClass,
114 filepane,
115 NULL);
116
117 saveAsPane = XmCreatePulldownMenu(filepane,
118 "save_as",
119 NULL, 0);
120
121 button3 = XtVaCreateManagedWidget("Save As",
122 xmCascadeButtonWidgetClass,
123 filepane,
124 XmNsubMenuId, saveAsPane,
125 NULL);
126
127 button4 = XtVaCreateManagedWidget("MS Word",
128 xmPushButtonWidgetClass,
129 saveAsPane,
130 NULL);
131
132 button5 = XtVaCreateManagedWidget("LaTeX",
133 xmPushButtonWidgetClass,
134 saveAsPane,
135 NULL);
136
137 mb = XtVaCreateManagedWidget("mb", xmMessageBoxWidgetClass, toplevel, NULL);
138 dump_sw("after create message\n", toplevel);
139 XtVaSetValues(toplevel, XmNmessageWindow, mb, NULL);
140 dump_sw("after set message\n", toplevel);
141
142 com = XtVaCreateManagedWidget("com", xmCommandWidgetClass, toplevel, NULL);
143 dump_sw("after create command\n", toplevel);
144
145 one = XtVaCreateManagedWidget("form", xmFormWidgetClass, toplevel,
146 NULL);
147 dump_sw("after create form\n", toplevel);
148
149 two = XtVaCreateManagedWidget("two", xmPushButtonWidgetClass, one,
150 XmNtopAttachment, XmATTACH_FORM,
151 XmNbottomAttachment, XmATTACH_FORM,
152 XmNleftAttachment, XmATTACH_NONE,
153 XmNrightAttachment, XmATTACH_FORM,
154 NULL);
155 dump_sw("after create two\n", toplevel);
156
157 three = XtVaCreateManagedWidget("three", xmPushButtonWidgetClass, one,
158 XmNtopAttachment, XmATTACH_FORM,
159 XmNbottomAttachment, XmATTACH_FORM,
160 XmNleftAttachment, XmATTACH_FORM,
161 XmNrightAttachment, XmATTACH_WIDGET,
162 XmNrightWidget, two,
163 NULL);
164 dump_sw("after create three\n", toplevel);
165
166 XmMainWindowSetAreas(toplevel, menubar, com, NULL, NULL, one);
167 dump_sw("after set areas\n", toplevel);
168
169 XtRealizeWidget(shell);
170 dump_sw("after realize\n", toplevel);
171
172 /* toplevel should be replaced with to correct applicationShell */
173
174 {
175 static XtWidgetGeometry Expected[] = {
176 CWWidth | CWHeight , 508, 524, 212, 362, 0,0,0, /* MainWindow */
177 CWWidth | CWHeight | CWX | CWY, 0, 31, 212, 2, 0,0,0, /* Separator1 */
178 CWWidth | CWHeight | CWX | CWY, 0, 246, 212, 2, 0,0,0, /* Separator2 */
179 CWWidth | CWHeight | CWX | CWY, 0, 273, 212, 2, 0,0,0, /* Separator3 */
180 CWWidth | CWHeight | CWX | CWY, 0, 0, 212, 31, 0,0,0, /* menuBar */
181 CWWidth | CWHeight | CWX | CWY, 5, 5, 40, 21, 0,0,0, /* File */
182 CWWidth | CWHeight | CWX | CWY, 45, 5, 40, 21, 0,0,0, /* Edit */
183 CWWidth | CWHeight | CWX | CWY, 0, 275, 212, 87, 0,0,0, /* mb */
184 CWWidth | CWHeight | CWX | CWY, 0, 0, 4, 4, 0,0,0, /* Symbol */
185 CWWidth | CWHeight | CWX | CWY, 10, 10, 192, 4, 0,0,0, /* Message */
186 CWWidth | CWHeight | CWX | CWY, 0, 24, 212, 2, 0,0,0, /* Separator */
187 CWWidth | CWHeight | CWX | CWY, 10, 36, 64, 41, 0,0,0, /* OK */
188 CWWidth | CWHeight | CWX | CWY, 74, 36, 64, 41, 0,0,0, /* Cancel */
189 CWWidth | CWHeight | CWX | CWY, 138, 36, 64, 41, 0,0,0, /* Help */
190 CWWidth | CWHeight | CWX | CWY, 0, 33, 212, 213, 0,0,0, /* com */
191 CWWidth | CWHeight | CWX | CWY, 10, 10, 192, 135, 0,0,0, /* ItemsListSW */
192 CWWidth | CWHeight | CWX | CWY, 0, 0, 192, 135, 0,0,0, /* ItemsList */
193 CWWidth | CWHeight | CWX | CWY, 10, 155, 192, 17, 0,0,0, /* Selection */
194 CWWidth | CWHeight | CWX | CWY, 10, 172, 192, 31, 0,0,0, /* Text */
195 CWWidth | CWHeight | CWX | CWY, 0, 248, 212, 25, 0,0,0, /* form */
196 CWWidth | CWHeight | CWX | CWY, 182, 0, 30, 25, 0,0,0, /* two */
197 CWWidth | CWHeight | CWX | CWY, 0, 0, 182, 25, 0,0,0, /* three */
198 };
199 PrintDetails(shell,Expected);
200 };
201 LessTifTestMainLoop(shell);
202
203 exit(0);
204 }
205
206