Dialog Widget
Application Header file <X11/Xaw/Dialog.h>
Class Header file <X11/Xaw/DialogP.h>
Class dialogWidgetClass
Class Name Dialog
Superclass Form
The Dialog widget implements a commonly used interaction semantic to
prompt for auxiliary input from a user. For example, you can use a
Dialog widget when an application requires a small piece of information,
such as a filename, from the user. A Dialog widget, which is simply a
special case of the Form widget, provides a convenient way to create a
preconfigured form.
The typical Dialog widget contains three areas. The first line
contains a description of the function of the Dialog widget, for
example, the string Filename:. The second line contains an area
into which the user types input. The third line can contain buttons
that let the user confirm or cancel the Dialog input. Any of these
areas may be omitted by the application.
Resources
When creating a Dialog widget instance, the following resources are
retrieved from the argument list or the resource database:
Name
Class
Type
Notes
Default Value
accelerators
Accelerators
AcceleratorTable
NULL
ancestorSensitive
AncestorSensitive
Boolean
D
True
background
Background
Pixel
XtDefaultBackground
backgroundPixmap
Pixmap
Pixmap
XtUnspecifiedPixmap
borderColor
BorderColor
Pixel
XtDefaultForeground
borderPixmap
Pixmap
Pixmap
XtUnspecifiedPixmap
borderWidth
BorderWidth
Dimension
1
children
ReadOnly
WidgetList
R
NULL
colormap
Colormap
Colormap
Parent's Colormap
defaultDistance
Thickness
int
4
depth
Depth
int
C
Parent's Depth
destroyCallback
Callback
XtCallbackList
NULL
height
Height
Dimension
A
Enough space to contain all children
icon
Icon
Bitmap
None
label
Label
String
"label"
mappedWhenManaged
MappedWhenManaged
Boolean
True
numChildren
ReadOnly
Cardinal
R
0
screen
Screen
Screen
R
Parent's Screen
sensitive
Sensitive
Boolean
True
translations
Translations
TranslationTable
NULL
value
Value
String
no value widget
width
Width
Dimension
A
Enough space to contain all children
x
Position
Position
0
y
Position
Position
0
_
icon
A pixmap image to be displayed immediately to the left of the
Dialog widget's label.
label
A string to be displayed at the top of the Dialog widget.
value
An initial value for the string field that the user will enter text
into. By default, no text entry field is available to the user.
Specifying an initial value for value activates the text entry
field. If string input is desired, but no initial value is to be
specified then set this resource to "" (empty string).
Constraint Resources
Each child of the Dialog widget may request special layout resources
be applied to it. These constraint resources allow the Dialog
widget's children to specify individual layout requirements.
Name
Class
Type
Notes
Default Value
bottom
Edge
XawEdgeType
XawRubber
fromHoriz
Widget
Widget
NULL (left edge of Dialog)
fromVert
Widget
Widget
NULL (top edge of Dialog)
horizDistance
Thickness
int
defaultDistance resource
left
Edge
XawEdgeType
XawRubber
resizable
Boolean
Boolean
FALSE
right
Edge
XawEdgeType
XawRubber
top
Edge
XawEdgeType
XawRubber
vertDistance
Thickness
int
defaultDistance resource
bottom
left
right
top What to do with this edge of the child when
the parent is resized. This resource may be
any edgeType. See Layout Semantics for
details.
fromHoriz
fromVert Which widget this child should be placed
underneath (or to the right of). If a value
of NULL is specified then this widget will be
positioned relative to the edge of the par-
ent.
horizDistance
vertDistance The amount of space, in pixels, between this
child and its left or upper neighbor.
resizable If this resource is False then the parent
widget will ignore all geometry request made
by this child. The parent may still resize
this child itself, however.
Layout Semantics
The Dialog widget uses two different sets of layout seman-
tics. One is used when initially laying out the children.
The other is used when the Dialog is resized.
The first layout method uses the fromVert mand fromHoriz
resources to place the children of the Dialog. A single
pass is made through the Dialog widget's children in the
order that they were created. Each child is then placed in
the Dialog widget below or to the right of the widget speci-
fied by the fromVert mand fromHoriz mresources. The distance
the new child is placed from its left or upper neighbor is
determined by the horizDistance mand vertDistance mresources.
This implies some things about how the order of creation
affects the possible placement of the children. The Form
widget registers a string to widget converter which does not
postpone conversion and does not cache conversion results.
The second layout method is used when the Dialog is resized.
It does not matter what causes this resize, and it is possi-
ble for a resize to happen before the widget becomes visible
(due to constraints imposed by the parent of the Dialog).
This layout method uses the bottom ,
top , left , and
right
resources. These resources are used to determine what will
happen to each edge of the child when the Dialog is resized.
If a value of XawChain
<something>
is specified, the the edge
of the child will remain a fixed distance from the chain
edge of the Dialog. For example if XawChainLeft
mis specified for the right mresource of a child
then the right edge
of that child will remain a fixed distance from the left
edge of the Dialog widget. If a value of XawRubber mis spec-
ified, that edge will grow by the same percentage that the
Dialog grew. For instance if the Dialog grows by 50% the
left edge of the child (if specified as XawRubber mwill be
50% farther from the left edge of the Dialog). One must be
very careful when specifying these resources, for when they
are specified incorrectly children may overlap or completely
occlude other children when the Dialog widget is resized.
Edge Type
Resource Name
Description
XawChainBottom
ChainBottom
Edge remains a fixed distance from bottom of Dialog
XawChainLeft
ChainLeft
Edge remains a fixed distance from left of Dialog
XawChainRight
ChainRight
Edge remains a fixed distance from right of Dialog
XawChainTop
ChainTop
Edge remains a fixed distance from top of Dialog
XawRubber
Rubber
Edges will move a proportional distance
Example
If you wish to force the Dialog to never resize one or more of its children
then set left and right to XawChainLeft and
top and bottom to XawChainTop. This will cause
the child to remain a fixed distance from the top and left
edges of the Dialog, and to never resize.
Special Considerations
The Dialog widget automatically sets the top and bottom
resources for all Children that are subclasses of the Command widget,
as well as the widget children that are used to contain the label,
value, and icon. This policy allows the buttons at the
bottom of the Dialog to interact correctly with the predefined children,
and makes it possible for a client to simply create and manage a new
Command button without having to specify its constraints.
The Dialog will also set fromLeft to the last button in the
Dialog for each new button added to the Dialog widget.
The automatically added constraints cannot be overridden, as they are
policy decisions of the Dialog widget. If a more flexible Dialog is
desired, the application is free to use the Form widget to create its
own Dialog policy.
Automatically Created Children.
The Dialog uses Label widgets to contain the label and icon.
These widgets are named label and icon respectively. The
Dialog value is contained in an AsciiText widget whose name is
value. Using XtNameToWidget the application can change
those resources associated with each of these widgets that are not
available through the Dialog widget itself.
Convenience Routines
To return the character string in the text field, use
String XawDialogGetValueString
Widget w
w
Specifies the Dialog widget.
This function returns a copy of the value string of the Dialog
widget. This string is allocated by the AsciiText widget and will
remain valid and unchanged until another call to
XawDialogGetValueString or an XtGetValues call on the
value widget, when the string will be automatically freed, and
a new string is returned. This string may be freed earlier by calling
the function XawAsciiSourceFreeString.
To add a new button to the Dialog widget use
XawDialogAddButton.
void XawDialogAddButton
Widget w
String name
XtCallbackProc func
XtPointer client_data
w
Specifies the Dialog widget.
name
Specifies the name of the new Command button to be added to the Dialog.
func
Specifies a callback function to be called when this button is activated. If
NULL is specified then no callback is added.
client_data
Specifies the client_data to be passed to the func.
This function is merely a shorthand for the code sequence:
{
Widget button = XtCreateManagedWidget(name, commandWidgetClass, w, NULL, ZERO);
XtAddCallback(button, XtNcallback, func, client_data);
}