1#include <stdio.h>
2#include <stdlib.h>
3#include <X11/StringDefs.h>
4#include <Xaw/Box.h>
5#include <Xaw/Command.h>
6#include <Xaw/Toggle.h>
7
8static Widget toggle[3];
9static Widget    radio_group;
10
11static void
12quit_cb(Widget w, XtPointer client_data, XtPointer call_data)
13{
14        XtAppSetExitFlag(XtWidgetToApplicationContext(w));
15}
16
17static void
18getdata_cb(Widget w, XtPointer client_data, XtPointer call_data)
19{
20	char *radio_data=XawToggleGetCurrent(radio_group);
21	if (radio_data)
22		printf("radio_data=%s\n",radio_data);
23	else
24		printf("radio_data=%s\n","nodata");
25}
26
27static void
28unset_cb(Widget w, XtPointer client_data, XtPointer call_data)
29{
30	XawToggleUnsetCurrent(radio_group);
31}
32
33
34static void
35reset_cb(Widget w, XtPointer client_data, XtPointer call_data)
36{
37	XawToggleSetCurrent(radio_group,"3397");
38}
39
40
41int main(int argc, char **argv)
42{
43	Widget toplevel,box,command;
44	XtAppContext app_con;
45
46	toplevel = XtAppInitialize(&app_con, "demo", NULL, 0,
47                               &argc, argv, NULL,
48                               NULL, 0);
49
50    box = XtCreateManagedWidget("box", boxWidgetClass, toplevel, NULL, 0);
51
52    command = XtVaCreateManagedWidget("cmd",
53                                   commandWidgetClass,  box,
54				      XtNlabel, "EXIT",
55				      NULL);
56
57    toggle[0]=XtVaCreateManagedWidget("toggle",
58				   toggleWidgetClass,  box,
59//				   XtNradioData,radioname,
60				   XtNradioGroup,radio_group,
61   			           XtNlabel, "track",
62				   NULL);
63    radio_group=toggle[0];
64    toggle[1]=XtVaCreateManagedWidget("toggle",
65				   toggleWidgetClass,  box,
66//				   XtNradioData,radioname,
67   				   XtNradioGroup,radio_group,
68   			           XtNlabel, "trick",
69				    NULL);
70
71    toggle[2]=XtVaCreateManagedWidget("toggle",
72				   toggleWidgetClass,  box,
73				   XtNradioData,"3397",
74				   XtNradioGroup,radio_group,
75   			           XtNlabel, "tick",
76				    NULL);
77
78    XtAddCallback(command, XtNcallback, quit_cb, NULL);
79
80    command = XtVaCreateManagedWidget("getcurrent",
81                                   commandWidgetClass,  box,
82				      XtNlabel, "say ",
83				      NULL);
84      XtAddCallback(command, XtNcallback, getdata_cb, NULL);
85
86      command = XtVaCreateManagedWidget("unsetcurrent",
87                                   commandWidgetClass,  box,
88				      XtNlabel, "unset ",
89				      NULL);
90      XtAddCallback(command, XtNcallback, unset_cb, NULL);
91
92
93      command = XtVaCreateManagedWidget("setnew",
94                                   commandWidgetClass,  box,
95				      XtNlabel, "setnew",
96				      NULL);
97
98      XtAddCallback(command, XtNcallback, reset_cb, NULL);
99
100    XtRealizeWidget(toplevel);
101    XtAppMainLoop(app_con);
102    exit(0);
103}
104