1 /* $Id: test7.c,v 1.7 2001/05/15 14:22:52 amai Exp $ */
2 
3 #include <stdlib.h>
4 
5 #include <Xm/Xm.h>
6 #include <Xm/PanedW.h>
7 #include <Xm/PushB.h>
8 #include <Xm/TextF.h>
9 #include <Xm/Form.h>
10 #include <Xm/DialogS.h>
11 
12 #include "../../common/Test.h"
13 
14 
15 static char *FallBack[] = {
16 		"*.geometrySlop: 0",
17 		NULL
18 };
19 
20 Widget toplevel, field, pane, button;
21 Widget dialog;
22 static XtWidgetGeometry Expected[] = {
23    CWWidth | CWHeight            ,  492,  361,  102,   25, 0,0,0, /* TopForm */
24    CWWidth | CWHeight | CWX | CWY,   10,    0,   36,   25, 0,0,0, /* Bad */
25    CWWidth | CWHeight | CWX | CWY,   56,    0,   36,   25, 0,0,0, /* Good */
26 
27    CWWidth | CWHeight            ,    8,   24,  366,   98, 0,0,0, /* FD */
28    CWWidth | CWHeight            ,    8,   24,  366,   98, 0,0,0, /* pane */
29    CWWidth | CWHeight | CWX | CWY,    3,    3,  360,   59, 0,0,0, /* DetailCheckBox */
30    CWWidth | CWHeight | CWX | CWY,    3,    3,  354,   25, 0,0,0, /* button_0 */
31    CWWidth | CWHeight | CWX | CWY,    3,   31,  354,   25, 0,0,0, /* button_1 */
32    CWWidth | CWHeight | CWX | CWY,    3,   70,  360,   25, 0,0,0, /* Form */
33    CWWidth | CWHeight | CWX | CWY,    0,    0,   72,   25, 0,0,0, /* bigbutton1 */
34    CWWidth | CWHeight | CWX | CWY,  288,    0,   72,   25, 0,0,0, /* bigbutton2 */
35    CWWidth | CWHeight | CWX | CWY,  346,   51,   10,   30, 0,0,0, /* sash */
36    CWWidth | CWHeight | CWX | CWY,    0,   65,  366,    2, 0,0,0, /* separator */
37    CWWidth | CWHeight            ,  360,  325,  366,   98, 0,0,0, /* FD */
38    CWWidth | CWHeight | CWX | CWY,    0,    0,  366,   98, 0,0,0, /* pane */
39    CWWidth | CWHeight | CWX | CWY,    3,    3,  360,   25, 0,0,0, /* Form */
40    CWWidth | CWHeight | CWX | CWY,    0,    0,   72,   25, 0,0,0, /* bigbutton1 */
41    CWWidth | CWHeight | CWX | CWY,  288,    0,   72,   25, 0,0,0, /* bigbutton2 */
42    CWWidth | CWHeight | CWX | CWY,    3,   36,  360,   59, 0,0,0, /* DetailCheckBox */
43    CWWidth | CWHeight | CWX | CWY,    3,    3,  354,   25, 0,0,0, /* button_0 */
44    CWWidth | CWHeight | CWX | CWY,    3,   31,  354,   25, 0,0,0, /* button_1 */
45    CWWidth | CWHeight | CWX | CWY,  346,   17,   10,   30, 0,0,0, /* sash */
46    CWWidth | CWHeight | CWX | CWY,    0,   31,  366,    2, 0,0,0, /* separator */
47 };
48 
activate_callback(Widget w,XtPointer client_data,XtPointer call_data)49 void activate_callback(Widget w, XtPointer client_data, XtPointer call_data)
50 {
51   XmTextFieldSetString(field, "Hello");
52 }
53 
makeform(Widget pane)54 void makeform(Widget pane)
55   {
56   Widget Form,b1,b2;
57 
58   	Form = XmCreateForm(pane, "Form", NULL, 0);
59   	b1 = XmCreatePushButton(Form,"bigbutton1",NULL,0);
60   	XtVaSetValues(b1,
61   		XmNtopAttachment, XmATTACH_FORM,
62   		XmNbottomAttachment, XmATTACH_FORM,
63   		XmNleftAttachment, XmATTACH_POSITION,
64   		XmNleftPosition, 0,
65   		XmNrightAttachment, XmATTACH_POSITION,
66   		XmNrightPosition, 20,
67   		NULL);
68   	XtManageChild(b1);
69   	b2 = XmCreatePushButton(Form,"bigbutton2",NULL,0);
70   	XtVaSetValues(b2,
71   		XmNtopAttachment, XmATTACH_FORM,
72   		XmNbottomAttachment, XmATTACH_FORM,
73   		XmNleftAttachment, XmATTACH_POSITION,
74   		XmNleftPosition, 80,
75   		XmNrightAttachment, XmATTACH_POSITION,
76   		XmNrightPosition, 100,
77   		NULL);
78   	XtManageChild(b2);
79   	XtManageChild(Form);
80   }
81 
makebox(Widget pane)82 void makebox(Widget pane)
83   {
84   Widget checkbox;
85 
86   checkbox = XmVaCreateSimpleCheckBox ( pane,"DetailCheckBox", NULL,
87                               XmVaCHECKBUTTON, NULL, NULL, NULL, NULL,
88                               XmVaCHECKBUTTON, NULL, NULL, NULL, NULL,
89                               NULL );
90   XtManageChild (checkbox);
91   }
92 
93 
callback(Widget W,int type)94 void callback(Widget W, int type)
95 {
96 Widget pane;
97 static int position = 0;
98 
99   switch (type)
100   {
101   case 1:
102 	  dialog = XmCreateDialogShell(toplevel,"FD",NULL,0);
103 	  break;
104   case 2:
105 	  dialog = XmCreateFormDialog(toplevel,"FD",NULL,0);
106 	  /*
107 	  dialog = XmCreateBulletinBoardDialog(toplevel,"FD",NULL,0);
108 	  */
109 	  break;
110   }
111 
112   pane = XtVaCreateWidget("pane", xmPanedWindowWidgetClass, dialog,
113 				 XmNsashHeight, 30,
114                                  NULL);
115 
116 
117   if (position / 2 * 2 == position)
118   {
119 	  makebox(pane);
120 	  makeform(pane);
121 	  position = 1;
122   }
123   else
124   {
125 	  makeform(pane);
126 	  makebox(pane);
127 	  position = 0;
128   }
129 
130   XtManageChild(pane);
131   XtManageChild(dialog);
132 }
133 
134 int
main(int argc,char ** argv)135 main(int argc, char **argv)
136 {
137   XtAppContext app;
138   Widget pb, pb1;
139   Widget Form;
140 
141   XtSetLanguageProc(NULL, NULL, NULL);
142 
143   toplevel = XtVaAppInitialize(&app,"Label",NULL,0,&argc,argv,FallBack,NULL);
144 
145   Form = XmCreateForm(toplevel,"TopForm",NULL,0);
146 
147   pb = XmCreatePushButton(Form,"Bad",NULL,0);
148   	XtVaSetValues(pb,
149   		XmNtopAttachment, XmATTACH_FORM,
150   		XmNbottomAttachment, XmATTACH_FORM,
151   		XmNleftAttachment, XmATTACH_POSITION,
152   		XmNleftPosition, 10,
153   		XmNrightAttachment, XmATTACH_POSITION,
154   		XmNrightPosition, 45,
155   		NULL);
156   XtAddCallback(pb,XmNactivateCallback,(XtCallbackProc)callback,(XtPointer)1);
157   XtManageChild(pb);
158   pb1 = pb;
159 
160   pb = XmCreatePushButton(Form,"Good",NULL,0);
161   	XtVaSetValues(pb,
162   		XmNtopAttachment, XmATTACH_FORM,
163   		XmNbottomAttachment, XmATTACH_FORM,
164   		XmNleftAttachment, XmATTACH_POSITION,
165   		XmNleftPosition, 55,
166   		XmNrightAttachment, XmATTACH_POSITION,
167   		XmNrightPosition, 90,
168   		NULL);
169   XtAddCallback(pb,XmNactivateCallback,(XtCallbackProc)callback,(XtPointer)2);
170   XtManageChild(pb);
171 
172   XtManageChild(Form);
173   XtRealizeWidget(toplevel);
174   LessTifTestWaitForIt(toplevel);
175 
176 {
177     PrintDetails(toplevel,Expected);
178 };
179   LessTifTestPushButton(pb1);
180 
181 {
182     PrintDetails(dialog,Expected);
183 };
184   LessTifTestPushButton(pb);
185 
186 {
187     PrintDetails(dialog,Expected);
188 };
189   LessTifTestMainLoop(toplevel);
190 
191   exit(0);
192 }
193 
194