XmNchildVerticalAlignment, XmALIGNMENT_WIDGET_TOP,
NULL);
#endif
frame = XtVaCreateManagedWidget ("frame4",
xmFrameWidgetClass, rowcol,
XmNshadowType, XmSHADOW_ETCHED_OUT,
NULL);
XtVaCreateManagedWidget ("XmSHADOW_ETCHED_OUT",
xmLabelGadgetClass, frame,
NULL);
#ifdef MOTIF_1_2
XtVaCreateManagedWidget ("XmALIGNMENT_WIDGET_BOTTOM",
xmLabelGadgetClass, frame,
XmNchildType, XmFRAME_TITLE_CHILD,
XmNchildVerticalAlignment, XmALIGNMENT_WIDGET_BOTTOM,
NULL);
#endif
XtManageChild (rowcol);
XtRealizeWidget (toplevel);
XtAppMainLoop (app);
}
The output of this example is shown in the figure.
Output of frame.c
The program creates four Frame widgets. Each Frame has two Label children, one for the work area and one for the
title. Each Frame uses a different value for the XmNshadowType and XmNchildVerticalPlacement
resources, where these values are indicated by the text of the Labels. Although we have used a Label as the work area
child of a Frame in this example, it is not a good idea to put a border around a Label. The shadow border implies
selectability, which can confuse the user.
9.7 The PanedWindow Widget
The PanedWindow widget lays out its children in a vertically−tiled format. The Motif Style Guide also provides for a
9 Manager Widgets 9.7 The PanedWindow Widget
236
horizontally−oriented paned window, but the Motif toolkit does not yet support it. The idea behind the PanedWindow
is that the user can adjust the individual panes to provide more or less space as needed on a per−child basis. For
example, if the user wants to see more text in a Text widget, he can use the control sashes (sometimes called grips) to
resize the area for the Text widget. When the user moves the sash, the widget above or below the one being resized is
resized smaller to compensate for the size change.
The width of the widget expands to that of its widest managed child and all of the other children are resized to match
that width. The height of the PanedWindow is set to the sum of the heights of all of its children, plus the spacing
between them and the size of the top and bottom margins. In Motif 1.1, widgets are placed in a PanedWindow in the
order that you create them, with the first child being placed at the top of the PanedWindow. With Motif 1.2, you can
set the XmNpositionIndex constraint resource to control the position of a child in a PanedWindow if you do not
want to use the default order.
An application that wants to use the PanedWindow must include the file <Xm/PanedW.h>. An instance of the widget
may be created as usual for manager widgets, as shown in the following code fragment:
Widget paned_w;
paned_w = XtVaCreateWidget ("name",
xmPanedWindowWidgetClass, parent,
resource−value−list,
NULL);
...
XtManageChild (paned_w);
The PanedWindow widget provides constraint resources that allow its children to indicate their preferred maximum
and minimum sizes. the source code shows three widgets that are set in a PanedWindow. XtSetLanguageProc()
is only available in X11R5; there is no corresponding function in X11R4.
/* paned_wind1.c −−there are two Label widgets that are positioned
* above and below a Text widget. The Labels' minimum and maximum
* sizes are set to 25 and 45 respectively, preventing those
* panes from growing beyond those bounds. The Text widget has its
* minimum size set to 35 preventing it from becoming so small that
* its text cannot be read.
*/
#include <Xm/Label.h>
#include <Xm/PanedW.h>
#include <Xm/Text.h>
main(argc, argv)
char *argv[];
{
Widget toplevel, pane;
XtAppContext app;
XtSetLanguageProc (NULL, NULL, NULL);
toplevel = XtVaAppInitialize (&app, "Demos", NULL, 0,
&argc, argv, NULL, NULL);
pane = XtVaCreateWidget ("pane",
xmPanedWindowWidgetClass, toplevel,
NULL);
XtVaCreateManagedWidget ("Hello", xmLabelWidgetClass, pane,
XmNpaneMinimum, 25,
9 Manager Widgets 9.7 The PanedWindow Widget
237
XmNpaneMaximum, 45,
NULL);
XtVaCreateManagedWidget ("text", xmTextWidgetClass, pane,
XmNrows, 5,
XmNcolumns, 80,
XmNpaneMinimum, 35,
XmNeditMode, XmMULTI_LINE_EDIT,
XmNvalue, "This is a test of the paned window widget.",
NULL);
XtVaCreateManagedWidget ("Goodbye", xmLabelWidgetClass, pane,
XmNpaneMinimum, 25,
XmNpaneMaximum, 45,
NULL);
XtManageChild (pane);
XtRealizeWidget (toplevel);
XtAppMainLoop (app);
}
The two Label widgets are positioned above and below a Text widget in a PanedWindow. The minimum and
maximum sizes of the Labels are set to 25 and 45 pixels respectively, using the resources XmNpaneMinimum and
XmNpaneMaximum. No matter how the PanedWindow or any of the other widgets are resized, the two Labels cannot
grow or shrink beyond these bounds. The Text widget, however, only has a minimum size restriction, so it may be
resized as large or as small as the user prefers, provided that it does not get smaller than the 35−pixel minimum. the
figure shows two configurations of this application.
9 Manager Widgets 9.7 The PanedWindow Widget
238
Get Volume 6A: Motif Programming Manual now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.