|
|
| |
XmtNameToWidget(3) |
FreeBSD Library Functions Manual |
XmtNameToWidget(3) |
XmtNameToWidget() - find a descendant or ancestor widget by name.
#include <Xmt/Xmt.h>
Widget XmtNameToWidget(Widget ref,
String name)
INPUTS
- ref
- The ``reference'' widget, relative to which the named widget is looked
up.
- name
- The name of the widget to look up. This name may be a hierarchical name,
with individual component names separated by periods; it may also contain
resource file wildcards, and other special ``modifiers'', described
below.
RETURNS
The named widget, or NULL if no such widget was found.
XmtNameToWidget() is similar to XtNameToWidget(), but is much more
flexible than that Xt Intrinsics function. Like XtNameToWidget(),
XmtNameToWidget() takes a ``reference'' widget as its first argument,
and looks up the named widget (the name is the the second argument) relative
to that reference widget. Hierarchical widget names are specified as the are
in resource files; the `*' and `?' wildcards are supported, and widget class
names may be used in place of widget instance names.
Explicit Modifiers
XmtNameToWidget() also supports special ``modifiers'' at
the beginning of a widget name that change the reference widget and start
the search from an ancestor widget. Multiple modifiers can be used; they act
as unary operators, and are evaluated from right-to-left. The modifiers are
the following:
- ^
- This operator changes the reference widget to the parent of the current
reference widget.
- ~
- This operator changes the reference widget to the near est shell ancestor
of the reference widget.
- ^{name}
- This operator changes the reference widget to the near est ancestor widget
with the instance name name, or if no such ancestor is found, the
nearest ancestor with a class or superclass name name.
Implicit Modifiers
If there are modifiers at the beginning of the specified name,
those modifiers explicitly specify which widget is to be used as the
reference. If there are no explicit modifiers, then the reference widget may
be implicitly modified by one of the following rules.
Widget Naming
Once the reference widget has been determined by parsing either
the modifiers or by examining the first component of the widget name, the
search for a matching widget is started with the children of the reference
widget, using the remain ing components of the name. Widgets are named
exactly as they would be in a resource file:
- Each component name may be a widget instance name or a widget class
name.
- A `.' between two components is a ``tight binding'' and indicates that the
second component names a direct child of the first.
- A `*' between two components is a ``loose binding'' and indicates that the
second component names any descendant of the first, with zero or more
intervening ``generations'' of widgets.
- A `?' in place of a component name is a wildcard that matches any single
widget, but does not elide any number of generations as the `*' modifier
does.
The Search
The search is conducted breadth-first, which means that if several
children match the specified name (because of wildcards, for example) then
the one with the shortest name (i.e. the closest descendant of the reference
widget) will be returned. If there are multiple matches the same number of
generations removed from the reference widget, the one returned is
arbitrary.
Special Cases
There are also a few special cases in this search:
- If there is no name, or if the name consists only of modifiers, then the
reference widget, or the modified reference widget is returned. This means
that a widget name like ``^^'', is legal, and returns the grandparent of
the specified reference widget. This special case means that it is
possible to search up the tree for ancestor widgets (especially using the
^{} modifier syntax) rather than only searching down the tree for
descendants.
- The name ``self'' is a special case. The name ``self'' by itself, with no
modifiers, will always match the reference widget. This is often useful in
resource files with the String-to-Widget converter. Also, you can use
``self'' (again, only when there are no modifiers) as a way to force
XtNameToWidget() to start its search at the specified reference
widget. If you specify a name ``button1'', XtNameToWidget() will
find a sibling with that name in preference to a child with that name. To
disambiguate this case you can explicitly use ``self.button1'' when
searching for a child and ``^button1'' when looking for a sibling.
Chapter 9, Looking Up Widgets By Name,
XmtRegisterWidgetConverter(), XtNameToWidget().
Visit the GSP FreeBSD Man Page Interface. Output converted with ManDoc. |