1 /* $Header: /cvsroot/lesstif/lesstif/test/Xm/panedw/test8.c,v 1.7 2002/05/01 15:39:21 amai Exp $ */
2
3 #include <stdlib.h>
4 #include <stdio.h>
5
6 #include <Xm/Xm.h>
7 #include <Xm/PanedWP.h>
8 #include <Xm/PushB.h>
9 #include <Xm/TextF.h>
10 #ifdef LESSTIF_REVISION
11 #include <XmI/XmI.h>
12 #endif
13
14 #include "../../common/Test.h"
15
16
17 Widget toplevel, field, pane, button, button2, button3;
18
19 #if XmVERSION < 2
main()20 int main()
21 {
22 printf("This test only works well with a Motif 2.x compatible library\n");
23 exit(0);
24 }
25 #else
26
27 #define PANEBOUND 1
28
activate_callback(Widget w,XtPointer client_data,XtPointer call_data)29 void activate_callback(Widget w, XtPointer client_data, XtPointer call_data)
30 {
31 XmTextFieldSetString(field, "Hello");
32 }
33
reorient(Widget w,XtPointer client,XtPointer call)34 void reorient(Widget w, XtPointer client, XtPointer call)
35 {
36 static int o = XmVERTICAL;
37
38 if (o == XmVERTICAL)
39 o = XmHORIZONTAL;
40 else
41 o = XmVERTICAL;
42
43 XtVaSetValues(pane, XmNorientation, o, NULL);
44 }
45
46 int
main(int argc,char ** argv)47 main(int argc, char **argv)
48 {
49 XtAppContext app;
50 int i;
51
52 XtSetLanguageProc(NULL, NULL, NULL);
53
54 toplevel = XtVaAppInitialize(&app, "Label", NULL, 0,
55 &argc, argv, NULL,
56 NULL);
57
58 pane = XtVaCreateManagedWidget("pane", xmPanedWindowWidgetClass,
59 toplevel, NULL);
60
61 #ifdef LESSTIF_REVISION
62 printf("sashinc: %d resizeAtRealize: %d\n",
63 PW_IncrementCount(pane), PW_ResizeAtRealize(pane));
64 #endif
65 field = XtVaCreateManagedWidget("field",xmPushButtonWidgetClass,
66 pane,
67 NULL);
68
69 #if 1
70 #ifdef LESSTIF_REVISION
71 printf("sashinc: %d resizeAtRealize: %d\n",
72 PW_IncrementCount(pane), PW_ResizeAtRealize(pane));
73 #endif
74 button = XtVaCreateManagedWidget("button", xmPushButtonWidgetClass,
75 pane,
76 #if PANEBOUND
77 XmNpaneMinimum, 20,
78 XmNpaneMaximum, 40,
79 #endif
80 NULL);
81
82 XtAddCallback(button, XmNactivateCallback, reorient, NULL);
83
84 #ifdef LESSTIF_REVISION
85 printf("sashinc: %d resizeAtRealize: %d\n",
86 PW_IncrementCount(pane), PW_ResizeAtRealize(pane));
87 #endif
88 button2 = XtVaCreateManagedWidget("button2", xmPushButtonWidgetClass,
89 pane,
90 #if PANEBOUND
91 XmNpaneMinimum, 20,
92 XmNpaneMaximum, 20,
93 #endif
94 NULL);
95
96 XtAddCallback(button2, XmNactivateCallback, activate_callback, NULL);
97
98 #if 1
99 #ifdef LESSTIF_REVISION
100 printf("sashinc: %d resizeAtRealize: %d\n",
101 PW_IncrementCount(pane), PW_ResizeAtRealize(pane));
102 #endif
103 button3 = XtVaCreateManagedWidget("button3", xmPushButtonWidgetClass,
104 pane,
105 #if PANEBOUND
106 XmNpaneMinimum, 20,
107 XmNpaneMaximum, 40,
108 #endif
109 NULL);
110 XtAddCallback(button3, XmNactivateCallback, activate_callback, NULL);
111 #endif
112
113 #endif
114
115 XtRealizeWidget(toplevel);
116
117 {
118 static XtWidgetGeometry Expected[] = {
119 NULL
120 };
121 PrintDetails(toplevel,Expected);
122 };
123
124 #if 0
125 printf("DUMP\n");
126 printf("sashinc: %d resizeAtRealize: %d\n",
127 PW_IncrementCount(pane), PW_ResizeAtRealize(pane));
128 for (i = 0; i < PW_NumManagedChildren(pane); i++) {
129 printf("child: %-8p %-10s ", PW_ManagedChildren(pane)[i],
130 XtName(PW_ManagedChildren(pane)[i]));
131 printf("sep: %-8p sash: %-8p index: %d position: %d\n",
132 PWC_Separator(PW_ManagedChildren(pane)[i]),
133 PWC_Sash(PW_ManagedChildren(pane)[i]),
134 PWC_PositionIndex(PW_ManagedChildren(pane)[i]),
135 PWC_Position(PW_ManagedChildren(pane)[i]));
136 }
137 printf("ALL CHILDREN\n");
138 for (i = 0; i < MGR_NumChildren(pane); i++) {
139 printf("child: %-8p %-10s ", MGR_Children(pane)[i],
140 XtName(MGR_Children(pane)[i]));
141 printf("sep: %-8p sash: %-8p index: %d position: %d\n",
142 PWC_Separator(MGR_Children(pane)[i]),
143 PWC_Sash(MGR_Children(pane)[i]),
144 PWC_PositionIndex(MGR_Children(pane)[i]),
145 PWC_Position(MGR_Children(pane)[i]));
146 }
147 printf("\n");
148
149 printf("UNMANAGE\n");
150 XtUnmanageChild(button);
151 XtUnmanageChild(button2);
152 printf("sashinc: %d resizeAtRealize: %d\n",
153 PW_IncrementCount(pane), PW_ResizeAtRealize(pane));
154 for (i = 0; i < PW_NumManagedChildren(pane); i++) {
155 printf("child: %-8p %-10s ", PW_ManagedChildren(pane)[i],
156 XtName(PW_ManagedChildren(pane)[i]));
157 printf("sep: %-8p sash: %-8p index: %d position: %d\n",
158 PWC_Separator(PW_ManagedChildren(pane)[i]),
159 PWC_Sash(PW_ManagedChildren(pane)[i]),
160 PWC_PositionIndex(PW_ManagedChildren(pane)[i]),
161 PWC_Position(PW_ManagedChildren(pane)[i]));
162 }
163 printf("ALL CHILDREN\n");
164 for (i = 0; i < MGR_NumChildren(pane); i++) {
165 printf("child: %-8p %-10s ", MGR_Children(pane)[i],
166 XtName(MGR_Children(pane)[i]));
167 printf("sep: %-8p sash: %-8p index: %d position: %d\n",
168 PWC_Separator(MGR_Children(pane)[i]),
169 PWC_Sash(MGR_Children(pane)[i]),
170 PWC_PositionIndex(MGR_Children(pane)[i]),
171 PWC_Position(MGR_Children(pane)[i]));
172 }
173 printf("\n");
174
175 printf("MANAGE\n");
176 XtManageChild(button2);
177 printf("sashinc: %d resizeAtRealize: %d\n",
178 PW_IncrementCount(pane), PW_ResizeAtRealize(pane));
179 for (i = 0; i < PW_NumManagedChildren(pane); i++) {
180 printf("child: %-8p %-10s ", PW_ManagedChildren(pane)[i],
181 XtName(PW_ManagedChildren(pane)[i]));
182 printf("sep: %-8p sash: %-8p index: %d position: %d\n",
183 PWC_Separator(PW_ManagedChildren(pane)[i]),
184 PWC_Sash(PW_ManagedChildren(pane)[i]),
185 PWC_PositionIndex(PW_ManagedChildren(pane)[i]),
186 PWC_Position(PW_ManagedChildren(pane)[i]));
187 }
188 printf("ALL CHILDREN\n");
189 for (i = 0; i < MGR_NumChildren(pane); i++) {
190 printf("child: %-8p %-10s ", MGR_Children(pane)[i],
191 XtName(MGR_Children(pane)[i]));
192 printf("sep: %-8p sash: %-8p index: %d position: %d\n",
193 PWC_Separator(MGR_Children(pane)[i]),
194 PWC_Sash(MGR_Children(pane)[i]),
195 PWC_PositionIndex(MGR_Children(pane)[i]),
196 PWC_Position(MGR_Children(pane)[i]));
197 }
198 printf("\n");
199 #endif /* #if 0 */
200
201 LessTifTestMainLoop(toplevel);
202
203 exit(0);
204 }
205
206 #endif
207