home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.windows.x
- Path: sparky!uunet!usc!rpi!uwm.edu!spool.mu.edu!yale.edu!jvnc.net!darwin.sura.net!udel!intercon!psinntp!sunic!dkuug!daimi!datpete
- From: datpete@daimi.aau.dk (Peter Andersen)
- Subject: RadioGroups in Aw ??
- Message-ID: <1992Nov17.095011.29951@daimi.aau.dk>
- Sender: datpete@daimi.aau.dk (Peter Andersen)
- Reply-To: datpete@mjolner.dk (Peter Andersen)
- Organization: DAIMI: Computer Science Department, Aarhus University, Denmark
- Date: Tue, 17 Nov 92 09:50:11 GMT
- Lines: 125
-
- I have tried using the Toggles of the Athena widgets (X11R4).
- I want to use them for a radio panel.
- I have created 5 Toggles t1, t2, t3, t4, and t5, that I connect
- in the following way:
-
- XtSetArg(arg, XtNradioGroup, t1);
- XtSetValues(t2, arg, 1);
- XtSetArg(arg, XtNradioGroup, t2);
- XtSetValues(t1, arg, 1);
- XtSetArg(arg, XtNradioGroup, t2);
- XtSetValues(t3, arg, 1);
- XtSetArg(arg, XtNradioGroup, t3);
- XtSetValues(t4, arg, 1);
- XtSetArg(arg, XtNradioGroup, t4);
- XtSetValues(t5, arg, 1);
-
- (The complete program in this version is added at the end).
-
- This works fine, the previously selected toggle deselects
- when another is clicked.
-
- My problem is that, if I change it to the somewhat more natural
-
- XtSetArg(arg, XtNradioGroup, t2);
- XtSetValues(t1, arg, 1);
- XtSetArg(arg, XtNradioGroup, t3);
- XtSetValues(t2, arg, 1);
- XtSetArg(arg, XtNradioGroup, t4);
- XtSetValues(t3, arg, 1);
- XtSetArg(arg, XtNradioGroup, t5);
- XtSetValues(t4, arg, 1);
- XtSetArg(arg, XtNradioGroup, t1);
- XtSetValues(t5, arg, 1);
-
- it does not work!
-
- I have various other combinations that work, and some that
- does not. I have tried to read the manual very carefully, but
- so far I have not figured out the pattern!
-
- Can anyone explain this to me in detail?
-
- The first (working) version:
-
-
- #include <stdio.h>
- #include <X11/Intrinsic.h>
- #include <X11/StringDefs.h> /* Get standard string definations. */
-
- #include <X11/Xaw/Toggle.h>
- #include <X11/Xaw/Box.h>
- #include <X11/Xaw/Cardinals.h>
-
- extern void exit();
-
- main(argc, argv)
- int argc;
- char **argv;
- {
- static XtCallbackProc Print();
- int i;
- Arg arg;
- XtAppContext app_con;
- Widget toplevel, box, t1, t2, t3, t4, t5;
-
- toplevel = XtAppInitialize(&app_con, "Xradiobutton",
- 0, 0, &argc, argv, 0, NULL, ZERO);
-
- box = XtCreateManagedWidget("box", boxWidgetClass, toplevel,
- NULL, ZERO);
-
- /*
- * Put a command widget in the box.
- */
-
- t1 = XtCreateManagedWidget("toggle1", toggleWidgetClass, box,
- NULL, ZERO);
- XtAddCallback(t1, XtNcallback, Print, NULL);
-
- t2 = XtCreateManagedWidget("toggle2", toggleWidgetClass, box,
- NULL, ZERO);
- XtAddCallback(t2, XtNcallback, Print, NULL);
-
- t3 = XtCreateManagedWidget("toggle3", toggleWidgetClass, box,
- NULL, ZERO);
- XtAddCallback(t3, XtNcallback, Print, NULL);
-
- t4 = XtCreateManagedWidget("toggle4", toggleWidgetClass, box,
- NULL, ZERO);
- XtAddCallback(t4, XtNcallback, Print, NULL);
-
- t5 = XtCreateManagedWidget("toggle5", toggleWidgetClass, box,
- NULL, ZERO);
- XtAddCallback(t5, XtNcallback, Print, NULL);
-
- /* specify radiogroup connection */
-
- XtSetArg(arg, XtNradioGroup, t1);
- XtSetValues(t2, arg, 1);
- XtSetArg(arg, XtNradioGroup, t2);
- XtSetValues(t1, arg, 1);
- XtSetArg(arg, XtNradioGroup, t2);
- XtSetValues(t3, arg, 1);
- XtSetArg(arg, XtNradioGroup, t3);
- XtSetValues(t4, arg, 1);
- XtSetArg(arg, XtNradioGroup, t4);
- XtSetValues(t5, arg, 1);
-
- XtRealizeWidget(toplevel);
- XtAppMainLoop(app_con);
- }
-
- static XtCallbackProc
- Print(w, call_data, client_data)
- Widget w;
- XtPointer call_data, client_data;
- {
- Boolean state;
- Arg arg;
- XtSetArg(arg, XtNstate, &state);
- XtGetValues(w, &arg, 1);
- fprintf(stdout, "%s %s\n", XtName(w), (state)? "on" : "off" );
- }
-
- Peter Andersen
-