Repost
> 1.) Why is this call for "Check Toggles" XtVaCreateManagedWidget the
> size of the dialog?
>
> 2.) How can I draw frame around the text ( ie the radio buttons
> created from TestNames)?
>
>
> 3.) Is there an application that can generate this type of code for
> me?
>
> Thanks in advance
>
>
> Michael
>
>
> /* program below*/
>
> #include
> #include
> #include
> #include
>
> #include
>
> unsigned long toggles_set; /* has the bits of which toggles are set */
>
> char *TestNames[] = {
> "Some tests With the name One in it",
> "Some tests With the name Two in it",
> "Some tests With the name Three in it",
> "Some tests With the name Four in it ",
> "Some tests With the name Five in it",
> "Some tests With the name Six in it",
> "Some tests With the name Seven in it",
> "Some tests With the name Eight in it",
> "Some tests With the name Nine in it",
> "Some tests With the name Ten in it",
> };
>
> /* A RowColumn is used to manage a ToggleBox (also a RowColumn) and
> * a PushButton with a separator gadget in between.
> */
> main(argc, argv)
> int argc;
> char *argv[];
> {
> Widget toplevel, rowcol, toggle_box, w;
> XtAppContext app;
> void toggled(), check_bits();
> int i;
>
> XtSetLanguageProc (NULL, NULL, NULL);
>
> toplevel = XtVaAppInitialize (
> &app,
> "The Name of my app",
> NULL,
> 0,
> &argc,
> argv,
> NULL,
> NULL);
>
> // Set the Title to something I want it to be
> XtVaSetValues(toplevel, XmNtitle, "Michael", NULL);
>
> rowcol = XtVaCreateManagedWidget ("rowcolumn",
> xmRowColumnWidgetClass, toplevel,
> NULL);
>
> toggle_box = XtVaCreateWidget ("System STE",
> xmRowColumnWidgetClass, rowcol,
> XmNpacking, XmPACK_COLUMN,
> XmNnumColumns, 3,
> NULL);
>
> // Why doesn't this come above the
> XtVaCreateManagedWidget ("sep",
> xmSeparatorGadgetClass, rowcol, NULL);
>
> /* simply loop thru the strings creating a widget for each one */
> for (i = 0; i < XtNumber (TestNames); i++) {
> w = XtVaCreateManagedWidget (TestNames[i],
> xmToggleButtonGadgetClass, toggle_box, NULL);
> XtAddCallback (w, XmNvalueChangedCallback, toggled, i);
> }
>
> XtVaCreateManagedWidget ("sep",
> xmSeparatorGadgetClass, rowcol, NULL);
>
> w = XtVaCreateManagedWidget ("Check Toggles",
> xmPushButtonGadgetClass, rowcol, NULL);
> XtAddCallback (w, XmNactivateCallback, check_bits, NULL);
>
> XtManageChild (rowcol);
> XtManageChild (toggle_box);
>
> XtRealizeWidget (toplevel);
> XtAppMainLoop (app);
>
> }
>
> /* callback for all ToggleButtons. */
> void
> toggled(widget, client_data, call_data)
> Widget widget;
> XtPointer client_data;
> XtPointer call_data;
> {
> int bit = (int) client_data;
> XmToggleButtonCallbackStruct *toggle_data =
> (XmToggleButtonCallbackStruct *) call_data;
>
> if (toggle_data->set) /* if the toggle button is set, flip its bit
> */
> toggles_set |= (1 << bit);
> else /* if the toggle is "off", turn off the bit. */
> toggles_set &= ~(1 << bit);
> }
>
> void
> check_bits(widget, client_data, call_data)
> Widget widget;
> XtPointer client_data;
> XtPointer call_data;
> {
> int i;
>
> printf ("Toggles set:");
> for (i = 0; i < XtNumber (TestNames); i++)
> if (toggles_set & (1< > printf (" %s\n", TestNames[i]);
> putchar ('\n');