1 /* $Header: /cvsroot/lesstif/lesstif/test/Xm-2.0/combobox/test10.c,v 1.5 2002/05/01 15:47:31 amai Exp $ */
2 /* Purpose: test resizing of combobox inside a form */
3 
4 #include <stdio.h>
5 #include <stdlib.h>
6 
7 #include <Xm/Form.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,  386,   94, 0,0,0 }, /* combo */
26 {  CWWidth | CWHeight | CWX | CWY,    6,    6,  374,   50, 0,0,0 }, /* Text */
27 {  CWWidth | CWHeight | CWX | CWY,    6,   56,  374,   32, 0,0,0 }, /* ListSW */
28 {  CWWidth | CWHeight | CWX | CWY,  359,    0,   15,   32, 0,0,0 }, /* VertScrollBar */
29 {  CWWidth | CWHeight | CWX | CWY,    0,    0,  359,   32, 0,0,0 }, /* List */
30 };
31 
32 #if 0
33    PrintDetails2(w, NULL);
34 #else
35   if (result_index <= 0)
36   {
37      PrintDetails2(w, Expected);
38      fflush(stdout);
39      result_index ++;
40   }
41 #endif
42 }
43 
44 int
main(int argc,char ** argv)45 main(int argc, char **argv)
46 {
47   Widget toplevel, widget, bb, list;
48   XtAppContext app;
49   XmString item;
50   Arg args[10];
51   int n = 0;
52 
53   XtSetLanguageProc(NULL, NULL, NULL);
54 
55   toplevel = XtVaAppInitialize(&app, "ComBox", NULL, 0, &argc, argv, NULL, NULL);
56 
57   bb = XmCreateForm(toplevel, "bb", NULL, 0);
58   XtManageChild(bb);
59 
60   widget = XmCreateComboBox(bb, "combo", args, n);
61   XtVaSetValues(widget,
62   	XmNtopAttachment, XmATTACH_FORM,
63   	XmNbottomAttachment, XmATTACH_FORM,
64   	XmNleftAttachment, XmATTACH_FORM,
65   	XmNrightAttachment, XmATTACH_FORM,
66   	NULL);
67 
68   /* use list routine to add items */
69   list = CB_List(widget);
70 
71   item = XmStringCreateSimple("Item 1");
72   XmListAddItem(list,item,0);
73   item = XmStringCreateSimple("Item 2");
74   XmListAddItem(list,item,0);
75   item = XmStringCreateSimple("Item 3");
76   XmListAddItem(list,item,0);
77   item = XmStringCreateSimple("Item 4");
78   XmListAddItem(list,item,0);
79   item = XmStringCreateSimple("Item 5");
80   XmListAddItem(list,item,0);
81 
82   XmComboBoxUpdate(widget);
83 
84   XtManageChild(widget);
85 
86   XtRealizeWidget(toplevel);
87 
88 #if 0
89   XdbPrintResources(CB_ListShell(widget));
90   XdbPrintResources(widget);
91 #endif
92 
93   check_geometry(widget);
94 
95   LessTifTestMainLoop(toplevel);
96 
97   exit(0);
98 }
99 
100