1 #include <stdio.h>
2 #include <Xm/XmP.h>
3 #include <Xm/RowColumn.h>
4 #include <Xm/ToggleB.h>
5 
6 #define TEST_CBS 1
7 
8 void HiCB(Widget w,XtPointer client_data,XtPointer call_data);
9 
10 
11 int
main(int argc,char ** argv)12 main(int argc, char **argv)
13 {
14   XtAppContext theApp;
15   Widget toplevel;
16   Widget butt;
17   Pixmap Pix;
18   Display *theDisplay;
19   Window theRootWindow;
20   Pixel fg,bg;
21   Dimension mt, mb, ml, mr, mw, mh, st, ht;
22   XtWidgetGeometry geo;
23 
24   toplevel = XtVaAppInitialize(&theApp, "toggle1", NULL, 0,
25 			       &argc, argv, NULL, NULL);
26 
27   butt= XtVaCreateManagedWidget("Button1", xmToggleButtonWidgetClass, toplevel,
28 #if 0
29 				XmNindicatorOn, False,
30 #endif
31 				XmNshadowThickness, 5,
32 				XmNfillOnSelect, True,
33 				NULL);
34 
35   XtAddCallback(butt,XmNvalueChangedCallback,HiCB,NULL);
36 
37   XtRealizeWidget(toplevel);
38 
39   theDisplay = XtDisplay(toplevel);
40   theRootWindow = XDefaultRootWindow(theDisplay);
41 
42   fg = XBlackPixelOfScreen(DefaultScreenOfDisplay(theDisplay));
43   bg = XWhitePixelOfScreen(DefaultScreenOfDisplay(theDisplay));
44 
45   Pix = XmGetPixmap(DefaultScreenOfDisplay(theDisplay),
46                     "xlogo64",
47                     fg, bg);
48   if (Pix == XmUNSPECIFIED_PIXMAP)
49 	printf("PIX IS UNSPECIFIED\n");
50 
51   XtVaGetValues(butt,
52 		XmNmarginTop, &mt, XmNmarginBottom, &mb,
53 		XmNmarginLeft, &ml, XmNmarginRight, &mr,
54 		XmNmarginWidth, &mw, XmNmarginHeight, &mh,
55 		XmNshadowThickness, &st, XmNhighlightThickness, &ht,
56 		NULL);
57 printf("%d %d %d %d %d %d %d %d\n",
58 	mt, mb, ml, mr, mw, mh, st, ht);
59 
60   XtVaSetValues(butt,
61 #if 0
62 	        XmNlabelPixmap,Pix,
63 #endif
64                 XmNlabelType, XmPIXMAP,
65                 NULL);
66 
67   Pix = XmGetPixmap(DefaultScreenOfDisplay(theDisplay),
68                     "woman",
69                     fg, bg);
70 
71   XtVaGetValues(butt,
72 		XmNmarginTop, &mt, XmNmarginBottom, &mb,
73 		XmNmarginLeft, &ml, XmNmarginRight, &mr,
74 		XmNmarginWidth, &mw, XmNmarginHeight, &mh,
75 		XmNshadowThickness, &st, XmNhighlightThickness, &ht,
76 		NULL);
77 printf("%d %d %d %d %d %d %d %d\n",
78 	mt, mb, ml, mr, mw, mh, st, ht);
79 
80   XtVaSetValues(butt,
81 	        XmNselectPixmap, Pix,
82                 NULL);
83 
84   XtQueryGeometry(butt, NULL, &geo);
85 printf("toggle wants: %d %d has %d %d\n",
86 	geo.width, geo.height, XtWidth(butt), XtHeight(butt));
87 
88   XtVaGetValues(butt,
89 		XmNmarginTop, &mt, XmNmarginBottom, &mb,
90 		XmNmarginLeft, &ml, XmNmarginRight, &mr,
91 		XmNmarginWidth, &mw, XmNmarginHeight, &mh,
92 		XmNshadowThickness, &st, XmNhighlightThickness, &ht,
93 		NULL);
94 printf("%d %d %d %d %d %d %d %d\n",
95 	mt, mb, ml, mr, mw, mh, st, ht);
96 
97 /* Note: the following values are the result of
98  * querying the current geometry.
99  */
100 {
101 static XtWidgetGeometry Expected[] = {
102    CWWidth | CWHeight            ,  387,  402,   77,   45, 0,0,0, /* Button1 */
103 };
104 /* toplevel should be replaced with to correct applicationShell */
105 PrintDetails(toplevel, Expected);
106 }
107 LessTifTestMainLoop(toplevel);
108 
109   exit(0);
110 }
111 
HiCB(Widget w,XtPointer client_data,XtPointer call_data)112 void HiCB(Widget w,XtPointer client_data,XtPointer call_data)
113 {
114     XmToggleButtonCallbackStruct *cbs = (XmToggleButtonCallbackStruct *)call_data;
115 
116     printf("Toggle Me and I'm Yours: %d\n", cbs->set);
117 
118 #if TEST_CBS
119     cbs->set = False;
120 #endif
121 }
122