I have a compiling and working program, but I can't figure out how to place the buttons anywhere other than the top left.
Do I need to specify the location in rowcol (like I am now), or do I specify the position of each button when I assign them using XtCreateManagedWidget?
Note that I have callbacks declared, but I'm not including them as they are working.
#include <stdio.h>
#include <Xm/Xm.h>
#include <Xm/ToggleB.h>
#include <Xm/RowColumn.h>
int main(int argc, char **argv)
{
Widget shell, rowcol, toggle1, toggle2;
XtAppContext app;
//Set the window's size at 300x300
shell = XtVaAppInitialize(&app, "Radio", NULL, 0, &argc, argv, NULL,
XmNwidth, 300, XmNheight, 300, NULL);
//I want the buttons to start at 100x100
rowcol = XtVaCreateWidget("rowcol", xmRowColumnWidgetClass, shell,
XmNx, 100, XmNy, 100, NULL);
XtManageChild(rowcol);
//Add the buttons & callbacks
toggle1 = XtCreateManagedWidget("Switch1", xmToggleButtonWidgetClass, rowcol, NULL, 0);
XtAddCallback(toggle1, XmNvalueChangedCallback, toggle1_cbk, NULL);
toggle2 = XtCreateManagedWidget("Switch2", xmToggleButtonWidgetClass, rowcol, NULL, 0);
XtAddCallback(toggle2, XmNvalueChangedCallback, toggle2_cbk, NULL);
//Starts everything up
XtRealizeWidget(shell);
XtMainAppLoop(app);
return 0;
}
Put your widget in a BulletinBoard.
frame = XtVaCreateWidget("frame", xmBulletinBoardWidgetClass, shell,
XmNwidth, 300, XmNheight, 300, NULL);
rowcol = XtVaCreateWidget("rowcol", xmRowColumnWidgetClass, frame,
XmNx, 100, XmNy, 100, NULL);
XtManageChild(frame);
XtManageChild(rowcol);
The immediate child of the shell is special. Setting its X and Y doesn't position the child within the shell, but rather the shell itself. In addition, many widgets ignore X and Y positions of their children. But BulletinBoard does not.
From the Motif manual:
BulletinBoard is a general-purpose manager that allows children to be placed at arbitrary x, y positions.