1 #include <stdio.h>
2 #include <Xm/Xm.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 int
main(int argc,char ** argv)11 main(int argc, char **argv)
12 {
13   XtAppContext theApp;
14   Widget toplevel, rc;
15   Widget butt1,butt2;
16 
17   toplevel = XtVaAppInitialize(&theApp, "toggle1", NULL, 0,
18 			       &argc, argv, NULL, NULL);
19 
20   rc= XtVaCreateManagedWidget("A Simple Toggle Button",
21 			      xmRowColumnWidgetClass,
22 			      toplevel,
23 			      XmNentryAlignment, XmALIGNMENT_CENTER,
24 			      XmNorientation, XmHORIZONTAL,
25 			      XmNpacking, XmPACK_TIGHT,
26 			      XmNradioBehavior, True,
27 			      XmNnumColumns, 1,
28 			      NULL);
29 
30   butt1= XtVaCreateManagedWidget("Button1", xmToggleButtonWidgetClass, rc,
31 #if XmVERSION > 1
32 		XmNtoggleMode, XmTOGGLE_INDETERMINATE,
33 #endif
34 				NULL);
35 
36   butt2= XtVaCreateManagedWidget("Button2", xmToggleButtonWidgetClass, rc,
37 				NULL);
38 
39   XtAddCallback(butt1,XmNvalueChangedCallback,HiCB,NULL);
40   XtAddCallback(butt2,XmNvalueChangedCallback,HiCB,NULL);
41 
42   XtRealizeWidget(toplevel);
43 
44 /* Note: the following values are the result of
45  * querying the current geometry.
46  */
47 {
48 static XtWidgetGeometry Expected[] = {
49    CWWidth | CWHeight            ,    0,    0,  143,   31, 0,0,0, /* A Simple Toggle Button */
50    CWWidth | CWHeight | CWX | CWY,    3,    3,   67,   25, 0,0,0, /* Button1 */
51    CWWidth | CWHeight | CWX | CWY,   73,    3,   67,   25, 0,0,0, /* Button2 */
52 };
53 /* toplevel should be replaced with to correct applicationShell */
54 PrintDetails(toplevel, Expected);
55 }
56 LessTifTestMainLoop(toplevel);
57 
58   exit(0);
59 }
60 
HiCB(Widget w,XtPointer client_data,XtPointer call_data)61 void HiCB(Widget w,XtPointer client_data,XtPointer call_data)
62 {
63     XmToggleButtonCallbackStruct *cbs = (XmToggleButtonCallbackStruct *)call_data;
64 
65     printf("Toggle Me and I'm Yours: %d\n", cbs->set);
66 
67 #if TEST_CBS
68     cbs->set = False;
69 #endif
70 }
71