1 /* $Header: /cvsroot/lesstif/lesstif/test/Xm-2.0/combobox/test11.c,v 1.5 2002/05/01 15:47:31 amai Exp $ */
2 /* Purpose: Test the XmNlayoutDirection resource (CG only) */
3
4 #include <stdio.h>
5 #include <stdlib.h>
6
7 #include <Xm/RowColumn.h>
8 #include <Xm/ComboBoxP.h>
9 #include <Xm/List.h>
10
11 #include "../../common/Test.h"
12
13 #if !defined(CB_List)
14 #define CB_List(w) \
15 (((XmComboBoxWidget)(w))->combo_box.list)
16 #endif
17
18 void
check_geometry(Widget w)19 check_geometry(Widget w)
20 {
21 static int result_index = 0;
22
23 static XtWidgetGeometry Expected[] = {
24 /* result test 0 */
25 { CWWidth | CWHeight , 0, 0, 418, 58, 0,0,0 }, /* combo */
26 { CWWidth | CWHeight | CWX | CWY, 6, 6, 370, 46, 0,0,0 }, /* Text */
27 { CWWidth | CWHeight | CWX | CWY, 0, 0, 414, 42, 0,0,0 }, /* GrabShell */
28 { CWWidth | CWHeight | CWX | CWY, 0, 0, 410, 38, 0,0,0 }, /* ListSW */
29 { CWWidth | CWHeight | CWX | CWY, 395, 0, 15, 38, 0,0,0 }, /* VertScrollBar */
30 { CWWidth | CWHeight | CWX | CWY, 0, 0, 395, 38, 0,0,0 }, /* List */
31 };
32
33 #if 1
34 PrintDetails2(w, NULL);
35 #else
36 if (result_index <= 0)
37 {
38 PrintDetails2(w, Expected);
39 fflush(stdout);
40 result_index ++;
41 }
42 #endif
43 }
44
print_direction(Widget w)45 void print_direction(Widget w)
46 {
47 XmDirection dir;
48
49 XtVaGetValues(w, XmNlayoutDirection, &dir, NULL);
50
51 switch(dir)
52 {
53 case XmDEFAULT_DIRECTION:
54 printf("XmDEFAULT_DIRECTION\n");
55 break;
56 case XmRIGHT_TO_LEFT_TOP_TO_BOTTOM:
57 printf("XmRIGHT_TO_LEFT_TOP_TO_BOTTOM\n");
58 break;
59 case XmLEFT_TO_RIGHT_TOP_TO_BOTTOM:
60 printf("XmLEFT_TO_RIGHT_TOP_TO_BOTTOM\n");
61 break;
62 case XmRIGHT_TO_LEFT_BOTTOM_TO_TOP:
63 printf("XmRIGHT_TO_LEFT_BOTTOM_TO_TOP\n");
64 break;
65 case XmLEFT_TO_RIGHT_BOTTOM_TO_TOP:
66 printf("XmLEFT_TO_RIGHT_BOTTOM_TO_TOP\n");
67 break;
68 case XmTOP_TO_BOTTOM_RIGHT_TO_LEFT:
69 printf("XmTOP_TO_BOTTOM_RIGHT_TO_LEFT\n");
70 break;
71 case XmTOP_TO_BOTTOM_LEFT_TO_RIGHT:
72 printf("XmTOP_TO_BOTTOM_LEFT_TO_RIGHT\n");
73 break;
74 case XmBOTTOM_TO_TOP_RIGHT_TO_LEFT:
75 printf("XmBOTTOM_TO_TOP_RIGHT_TO_LEFT\n");
76 break;
77 case XmBOTTOM_TO_TOP_LEFT_TO_RIGHT:
78 printf("XmBOTTOM_TO_TOP_LEFT_TO_RIGHT\n");
79 break;
80 case XmTOP_TO_BOTTOM:
81 printf("XmTOP_TO_BOTTOM\n");
82 break;
83 case XmBOTTOM_TO_TOP:
84 printf("XmBOTTOM_TO_TOP\n");
85 break;
86 case XmRIGHT_TO_LEFT:
87 printf("XmRIGHT_TO_LEFT\n");
88 break;
89 case XmLEFT_TO_RIGHT:
90 printf("XmLEFT_TO_RIGHT\n");
91 break;
92 default:
93 printf("Unknown received value %d\n",dir);
94 }
95 }
96
direction_test(Widget parent,XmDirection dir)97 void direction_test(Widget parent, XmDirection dir)
98 {
99 Widget widget, list;
100 XmString item;
101 Arg args[10];
102 int n;
103 static char *foo = "Hello World";
104
105 n = 0;
106 XtSetArg(args[n], XmNlayoutDirection, dir); n++;
107 XtSetArg(args[n], XmNuserData, foo); n++;
108 widget = XmCreateDropDownList(parent, "combo", args, n);
109
110 /* use list routine to add items */
111 list = CB_List(widget);
112
113 item = XmStringCreateSimple("Item 1");
114 XmListAddItem(list,item,0);
115 item = XmStringCreateSimple("Item 2");
116 XmListAddItem(list,item,0);
117 item = XmStringCreateSimple("Item 3");
118 XmListAddItem(list,item,0);
119 item = XmStringCreateSimple("Item 4");
120 XmListAddItem(list,item,0);
121 item = XmStringCreateSimple("Item 5");
122 XmListAddItem(list,item,0);
123
124 XmComboBoxUpdate(widget);
125
126 XtManageChild(widget);
127
128 print_direction(widget);
129 }
130
131 int
main(int argc,char ** argv)132 main(int argc, char **argv)
133 {
134 Widget toplevel, bb;
135 XtAppContext app;
136 Arg args[10];
137 int n;
138
139 XtSetLanguageProc(NULL, NULL, NULL);
140
141 toplevel = XtVaAppInitialize(&app, "ComBox", NULL, 0, &argc, argv, NULL, NULL);
142
143 n = 0;
144 XtSetArg(args[n], XmNnumColumns, 2); n++;
145 XtSetArg(args[n], XmNpacking, XmPACK_COLUMN); n++;
146 bb = XmCreateRowColumn(toplevel, "bb", args, n);
147 XtManageChild(bb);
148
149 direction_test(bb,(XmDirection) XmDEFAULT_DIRECTION);
150 direction_test(bb,(XmDirection) XmRIGHT_TO_LEFT_TOP_TO_BOTTOM);
151 direction_test(bb,(XmDirection) XmLEFT_TO_RIGHT_TOP_TO_BOTTOM);
152 direction_test(bb,(XmDirection) XmRIGHT_TO_LEFT_BOTTOM_TO_TOP);
153 direction_test(bb,(XmDirection) XmLEFT_TO_RIGHT_BOTTOM_TO_TOP);
154 direction_test(bb,(XmDirection) XmTOP_TO_BOTTOM_RIGHT_TO_LEFT);
155 direction_test(bb,(XmDirection) XmTOP_TO_BOTTOM_LEFT_TO_RIGHT);
156 direction_test(bb,(XmDirection) XmBOTTOM_TO_TOP_RIGHT_TO_LEFT);
157 direction_test(bb,(XmDirection) XmBOTTOM_TO_TOP_LEFT_TO_RIGHT);
158 direction_test(bb,(XmDirection) XmTOP_TO_BOTTOM);
159 direction_test(bb,(XmDirection) XmBOTTOM_TO_TOP);
160 direction_test(bb,(XmDirection) XmRIGHT_TO_LEFT);
161 direction_test(bb,(XmDirection) XmLEFT_TO_RIGHT);
162
163 XtRealizeWidget(toplevel);
164
165 #if 0
166 XdbPrintResources(CB_ListShell(widget));
167 XdbPrintResources(widget);
168 check_geometry(bb);
169 #endif
170
171 LessTifTestMainLoop(toplevel);
172
173 exit(0);
174 }
175
176