1 /*
2 * $Header: /cvsroot/lesstif/lesstif/test/common/XdbPrintResources.c,v 1.4 2002/05/01 16:01:26 amai Exp $
3 *
4 * Copyright (C) 1995 Free Software Foundation, Inc.
5 * Copyright (C) 1996-2002 LessTif Development Team
6 */
7
8 #include "LTTconfig.h"
9
10 #include <stdio.h>
11
12 #include <Xm/ScrolledWP.h>
13 #include <Xm/ListP.h>
14
15 #define LIB_LTTEST
16 #include "Test.h"
17
18 #ifndef List_ItemCount
19 #define List_ItemCount(w) \
20 (((XmListWidget)(w))->list.itemCount)
21
22 #define List_SelectedItemCount(w) \
23 (((XmListWidget)(w))->list.selectedItemCount)
24
25 #define List_VisibleItemCount(w) \
26 (((XmListWidget)(w))->list.visibleItemCount)
27
28 #define List_LastSetVizCount(w) \
29 (((XmListWidget)(w))->list.LastSetVizCount)
30
31
32 #define List_Items(w) \
33 (((XmListWidget)(w))->list.items)
34
35 #define List_SelectedItems(w) \
36 (((XmListWidget)(w))->list.selectedItems)
37
38 #define List_SelectedIndices(w) \
39 (((XmListWidget)(w))->list.selectedIndices)
40
41 #define List_MarginHeight(w) \
42 (((XmListWidget)(w))->list.margin_height)
43
44 #define List_MarginWidth(w) \
45 (((XmListWidget)(w))->list.margin_width)
46
47 #define List_SizePolicy(w) \
48 (((XmListWidget)(w))->list.SizePolicy)
49
50 #define List_ItemSpacing(w) \
51 (((XmListWidget)(w))->list.ItemSpacing)
52
53 #define List_Spacing(w) \
54 (((XmListWidget)(w))->list.spacing)
55
56 #define List_SBDisplayPolicy(w) \
57 (((XmListWidget)(w))->list.ScrollBarDisplayPolicy)
58
59 #define List_SelectionPolicy(w) \
60 (((XmListWidget)(w))->list.SelectionPolicy)
61
62 #define List_BaseX(w) \
63 (((XmListWidget)(w))->list.BaseX)
64
65 #define List_BaseY(w) \
66 (((XmListWidget)(w))->list.BaseY)
67
68 #endif
69
70
71 #ifndef SW_VSBMinimum
72 #define SW_VSBMinimum(w) \
73 (((XmScrolledWindowWidget)w)->swindow.vmin)
74
75 #define SW_VSBMaximum(w) \
76 (((XmScrolledWindowWidget)w)->swindow.vmax)
77
78 #define SW_VSBValue(w) \
79 (((XmScrolledWindowWidget)w)->swindow.vOrigin)
80
81 #define SW_VSBSliderSize(w) \
82 (((XmScrolledWindowWidget)w)->swindow.vExtent)
83
84 #define SW_HSBMinimum(w) \
85 (((XmScrolledWindowWidget)w)->swindow.hmin)
86
87 #define SW_HSBMaximum(w) \
88 (((XmScrolledWindowWidget)w)->swindow.hmax)
89
90 #define SW_HSBValue(w) \
91 (((XmScrolledWindowWidget)w)->swindow.hOrigin)
92
93
94 #define SW_HSBSliderSize(w) \
95 (((XmScrolledWindowWidget)w)->swindow.hExtent)
96
97 #define SW_HSBX(w) \
98 (((XmScrolledWindowWidget)w)->swindow.hsbX)
99
100 #define SW_HSBY(w) \
101 (((XmScrolledWindowWidget)w)->swindow.hsbY)
102
103 #define SW_HSBWidth(w) \
104 (((XmScrolledWindowWidget)w)->swindow.hsbWidth)
105
106 #define SW_HSBHeight(w) \
107 (((XmScrolledWindowWidget)w)->swindow.hsbHeight)
108
109 #define SW_VSBX(w) \
110 (((XmScrolledWindowWidget)w)->swindow.vsbX)
111
112 #define SW_VSBY(w) \
113 (((XmScrolledWindowWidget)w)->swindow.vsbY)
114
115 #define SW_VSBWidth(w) \
116 (((XmScrolledWindowWidget)w)->swindow.vsbWidth)
117
118 #define SW_VSBHeight(w) \
119 (((XmScrolledWindowWidget)w)->swindow.vsbHeight)
120
121 #define SW_GivenWidth(w) \
122 (((XmScrolledWindowWidget)w)->swindow.GivenWidth)
123
124 #define SW_GivenHeight(w) \
125 (((XmScrolledWindowWidget)w)->swindow.GivenHeight)
126
127 #define SW_CWX(w) \
128 (((XmScrolledWindowWidget)w)->swindow.XOffset)
129
130 #define SW_CWY(w) \
131 (((XmScrolledWindowWidget)w)->swindow.YOffset)
132
133 #define SW_CWWidth(w) \
134 (((XmScrolledWindowWidget)w)->swindow.AreaWidth)
135
136 #define SW_CWHeight(w) \
137 (((XmScrolledWindowWidget)w)->swindow.AreaHeight)
138
139 #define SW_MarginWidth(w) \
140 (((XmScrolledWindowWidget)w)->swindow.WidthPad)
141
142 #define SW_MarginHeight(w) \
143 (((XmScrolledWindowWidget)w)->swindow.HeightPad)
144
145 #define SW_Spacing(w) \
146 (((XmScrolledWindowWidget)w)->swindow.pad)
147
148 #define SW_HasHSB(w) \
149 (((XmScrolledWindowWidget)w)->swindow.hasHSB)
150
151 #define SW_HasVSB(w) \
152 (((XmScrolledWindowWidget)w)->swindow.hasVSB)
153
154 #define SW_InInit(w) \
155 (((XmScrolledWindowWidget)w)->swindow.InInit)
156
157 #define SW_FromResize(w) \
158 (((XmScrolledWindowWidget)w)->swindow.FromResize)
159
160 #define SW_VisualPolicy(w) \
161 (((XmScrolledWindowWidget)w)->swindow.VisualPolicy)
162
163 #define SW_ScrollPolicy(w) \
164 (((XmScrolledWindowWidget)w)->swindow.ScrollPolicy)
165
166 #define SW_ScrollBarPolicy(w) \
167 (((XmScrolledWindowWidget)w)->swindow.ScrollBarPolicy)
168
169 #define SW_Placement(w) \
170 (((XmScrolledWindowWidget)w)->swindow.Placement)
171
172 #define SW_HSB(w) \
173 (((XmScrolledWindowWidget)w)->swindow.hScrollBar)
174
175 #define SW_VSB(w) \
176 (((XmScrolledWindowWidget)w)->swindow.vScrollBar)
177
178 #endif
179
180
visualPolicy(int p)181 static const char *visualPolicy(int p)
182 {
183 switch(p)
184 {
185 case XmVARIABLE:
186 return "XmVARIABLE";
187 case XmCONSTANT:
188 return "XmCONSTANT";
189 default:
190 return "???";
191 }
192 }
193
194
scrollBarDisplayPolicy(int p)195 static const char *scrollBarDisplayPolicy(int p)
196 {
197 switch(p)
198 {
199 case XmAS_NEEDED:
200 return "XmAS_NEEDED";
201 case XmSTATIC:
202 return "XmSTATIC";
203 default:
204 return "???";
205 }
206 }
207
208
scrollingPolicy(int p)209 static const char *scrollingPolicy(int p)
210 {
211 switch(p)
212 {
213 case XmAUTOMATIC:
214 return "XmAUTOMATIC";
215 case XmAPPLICATION_DEFINED:
216 return "XmAPPLICATION_DEFINED";
217 default:
218 return "???";
219 }
220 }
221
222
scrollBarPlacement(int p)223 static const char *scrollBarPlacement(int p)
224 {
225 switch(p)
226 {
227 case XmTOP_LEFT:
228 return "XmTOP_LEFT";
229 case XmTOP_RIGHT:
230 return "XmTOP_RIGHT";
231 case XmBOTTOM_LEFT:
232 return "XmBOTTOM_LEFT";
233 case XmBOTTOM_RIGHT:
234 return "XmBOTTOM_RIGHT";
235 default:
236 return "???";
237 }
238 }
239
240
selectionPolicy(int p)241 static const char *selectionPolicy(int p)
242 {
243 switch(p)
244 {
245 case XmSINGLE_SELECT:
246 return "XmSINGLE_SELECT";
247 case XmMULTIPLE_SELECT:
248 return "XmMULTIPLE_SELECT";
249 case XmEXTENDED_SELECT:
250 return "XmEXTENDED_SELECT";
251 case XmBROWSE_SELECT:
252 return "XmBROWSE_SELECT";
253 default:
254 return "???";
255 }
256 }
257
258
listSizePolicy(int p)259 static const char *listSizePolicy(int p)
260 {
261 switch(p)
262 {
263 case XmCONSTANT:
264 return "XmCONSTANT";
265 case XmVARIABLE:
266 return "XmVARIABLE";
267 case XmRESIZE_IF_POSSIBLE:
268 return "XmRESIZE_IF_POSSIBLE";
269 default:
270 return "???";
271 }
272 }
273
274
_XdbPrintScrolledWindowResources(Widget w)275 static void _XdbPrintScrolledWindowResources(Widget w)
276 {
277 fprintf(stderr,"ScrolledWindow Resource(s):\n");
278 #if 0
279 fprintf(stderr,"GivenWidth=(%d)\n",(int) SW_GivenWidth(w));
280 fprintf(stderr,"GivenHeight=(%d)\n",(int) SW_GivenHeight(w));
281 #endif
282 fprintf(stderr,"AreaWidth=(%d)\n",(int) SW_CWWidth(w));
283 fprintf(stderr,"AreaHeight=(%d)\n",(int) SW_CWHeight(w));
284 fprintf(stderr,"WidthPad=(%d)\n",(int) SW_MarginWidth(w));
285 fprintf(stderr,"HeightPad=(%d)\n",(int) SW_MarginHeight(w));
286 fprintf(stderr,"XOffset=(%d)\n",(int) SW_CWX(w));
287 fprintf(stderr,"YOffset=(%d)\n",(int) SW_CWY(w));
288 fprintf(stderr,"pad=(%d)\n",(int) SW_Spacing(w));
289 #if 0
290 fprintf(stderr,"hasHSB=(%d)\n",(int) SW_HasHSB(w));
291 fprintf(stderr,"hasVSB=(%d)\n",(int) SW_HasVSB(w));
292 #endif
293 fprintf(stderr,"InInit=(%d)\n",(int) SW_InInit(w));
294 fprintf(stderr,"FromResize=(%d)\n",(int) SW_FromResize(w));
295 fprintf(stderr,"VisualPolicy=(%s)\n", visualPolicy(SW_VisualPolicy(w)));
296 fprintf(stderr,"ScrollPolicy=(%s)\n", scrollingPolicy(SW_ScrollPolicy(w)));
297 fprintf(stderr,"ScrollBarPolicy=(%s)\n", scrollBarDisplayPolicy(SW_ScrollBarPolicy(w)));
298 fprintf(stderr,"Placement=(%s)\n",scrollBarPlacement(SW_Placement(w)));
299 #if 0
300 fprintf(stderr,"vmin=(%d)\n",(int) SW_VSBMinimum(w));
301 fprintf(stderr,"vmax=(%d)\n",(int) SW_VSBMaximum(w));
302 fprintf(stderr,"vOrigin=(%d)\n",(int) SW_VSBValue(w));
303 fprintf(stderr,"vExtent=(%d)\n",(int) SW_VSBSliderSize(w));
304 fprintf(stderr,"hmin=(%d)\n",(int) SW_HSBMinimum(w));
305 fprintf(stderr,"hmax=(%d)\n",(int) SW_HSBMaximum(w));
306 fprintf(stderr,"hOrigin=(%d)\n",(int) SW_HSBValue(w));
307 fprintf(stderr,"hExtent=(%d)\n",(int) SW_HSBSliderSize(w));
308 fprintf(stderr,"hsbX=(%d)\n",(int) SW_HSBX(w));
309 fprintf(stderr,"hsbY=(%d)\n",(int) SW_HSBY(w));
310 fprintf(stderr,"hsbWidth=(%d)\n",(int) SW_HSBWidth(w));
311 fprintf(stderr,"hsbHeight=(%d)\n",(int) SW_HSBHeight(w));
312 fprintf(stderr,"vsbX=(%d)\n",(int) SW_VSBX(w));
313 fprintf(stderr,"vsbY=(%d)\n",(int) SW_VSBY(w));
314 fprintf(stderr,"vsbWidth=(%d)\n",(int) SW_VSBWidth(w));
315 fprintf(stderr,"vsbHeight=(%d)\n",(int) SW_VSBHeight(w));
316 #endif
317 }
318
319
_XdbPrintListResources(Widget w)320 static void _XdbPrintListResources(Widget w)
321 {
322 fprintf(stderr,"List Resource(s):\n");
323 fprintf(stderr,"spacing(%d):\n", List_Spacing(w));
324 fprintf(stderr,"ItemSpacing(%d):\n", List_ItemSpacing(w));
325 fprintf(stderr,"margin_width(%d):\n", List_MarginWidth(w));
326 fprintf(stderr,"margin_height(%d):\n", List_MarginHeight(w));
327 fprintf(stderr,"itemCount(%d):\n", List_ItemCount(w));
328 fprintf(stderr,"selectedItemCount(%d):\n", List_SelectedItemCount(w));
329 fprintf(stderr,"visibleItemCount(%d):\n", List_VisibleItemCount(w));
330 fprintf(stderr,"LastSetVizCount(%d):\n", List_LastSetVizCount(w));
331 fprintf(stderr,"SelectionPolicy(%s):\n",selectionPolicy(List_SelectionPolicy(w)));
332 fprintf(stderr,"ScrollBarDisplayPolicy(%s):\n",scrollBarDisplayPolicy(List_SBDisplayPolicy(w)));
333 fprintf(stderr,"SizePolicy(%s):\n",listSizePolicy(List_SizePolicy(w)));
334 }
335
336
XdbPrintResources(Widget w)337 void XdbPrintResources(Widget w)
338 {
339 if (XmIsScrolledWindow(w))
340 {
341 _XdbPrintScrolledWindowResources(w);
342 }
343 else if (XmIsList(w))
344 {
345 _XdbPrintListResources(w);
346 }
347 }
348