Next: Forms Up: Combining Widgets Previous: How are we going to achieve this?

The RowColumn Widget

This the simplest widget in terms of how it manages the positioning of its child widgets.

Widgets are positioned as follows:

Let us now look at two programs that illustrate the above principles: rowcol1.c and rowcol2.c.

rowcol1.c lays 4 PushButtons vertically (default) whereas rowcol2.c sets the XmNorientation resource for a horizontal layout of the same 4 buttons.

The output of the programs looks like this.

Fig. 7 RowColumn program outputs

The rowcol1.c program is as follows:

#include <Xm/PushB.h>
#include <Xm/RowColumn.h>

main(argc, argv)
int argc;
char *argv[];
    Widget top_widget, rowcol;
    XtAppContext app;

    top_widget = XtVaAppInitialize(&app, "rowcol", NULL, 0, 
        &argc, argv, NULL, NULL);

    rowcol = XtVaCreateManagedWidget("rowcolumn",
        xmRowColumnWidgetClass, top_widget, NULL);

    (void) XtVaCreateManagedWidget("button 1",
        xmPushButtonWidgetClass, rowcol, NULL);

    (void) XtVaCreateManagedWidget("button 2",
        xmPushButtonWidgetClass, rowcol, NULL);

    (void) XtVaCreateManagedWidget("button 3",
        xmPushButtonWidgetClass, rowcol, NULL);
    (void) XtVaCreateManagedWidget("button 4",
        xmPushButtonWidgetClass, rowcol, NULL);

rowcol1.c does not achieve much. It provides no callback functions to perform any tasks. It simply creates a RowColumn widget, rowcol, and creates 4 child buttons with this. Note that rowcol is a child of app - the application shell widget.

Note: that we must include the <Xm/RowColumn.h> header file

rowcol2.c is identical to rowcol1.c except that the XmNorietation resource is set at the rowcol widget creation with:

XmNorientation, XmHORIZONTAL,
Tue May 24 16:52:56 BST 1994