Name
set_values — Core method for processing resource changes.
Synopsis
typedef Boolean (∗XtSetValuesFunc)(Widget, Widget, Widget, ArgList, Cardinal ∗);
Widget current;
Widget request;
Widget new;
ArgList args;
Cardinal ∗num-args;
Arguments
currentSpecifies a copy of the widget as it was before the XtSetValues call.
requestSpecifies a copy of the widget with all values changed as asked for by the XtSetValues call before any class set_values procedures have been called.
newSpecifies the widget with the new values that are actually allowed.
argsSpecifies the argument list passed to XtSetValues.
num_argsSpecifies the count of arguments in the argument list.
Description
The Core set_values method is responsible for checking the validity of resource settings made with XtSetValues, and updating any nonresource instance structure fields (such as GCs) that depend on resource values.
Like the initialize method, set_values is concerned primarily with the fields defined by its own class, but it may have to resolve conflicts with its superclass, especially over width and height.
The current, request, and new arguments are widget instance records of the appropriate widget class. new reflects values that have been modified by superclass set_values methods. request reflects changes made only by the XtSetValues call itself. current was the widget instance at the time of the call, reflecting no changes. A widget can refer to request, to resolve conflicts between current and new. Any changes that the widget needs to make should be made to new.
Before calling the set_values method, the Intrinsics modify the resources of the request widget according to the contents of the ArgList; if the widget names all of its resources in the class resource list, the contents of args never need examining.
An XtSetValuesFunc returns a Boolean indicating True if the widget should be redisplayed and returns False otherwise. set_values methods should not do any work in response to anticipated changes in geometry because XtSetValues will eventually perform a geometry request. The request might be denied. If the widget actually changes size in response to an XtSetValues, its resize method is called. Widgets should make geometry-related changes there.
An XtSetValuesFunc cannot assume that the widget is realized, since it is permissible for an application to call XtSetValues before a widget is realized.
As of R4, the Core set_values method can contain the code that previously appeared in the set_values_hook method. This is the case because Core set_values is now passed the argument list passed to XtSetValues.
Examples
The following is the set_values method of the BitmapEdit widget class:
/∗ ARGSUSED ∗/
static Boolean
SetValues(current, request, new, args, num_args)
Widget current, request, new;
ArgList args;
Cardinal ∗num_args;
{
BitmapEditWidget curcw = (BitmapEditWidget) current;
BitmapEditWidget newcw = (BitmapEditWidget) new;
Boolean do_redisplay = False;
if (curcw->bitmapEdit.foreground != newcw->bitmapEdit.foreground) {
XtReleaseGC(curcw, curcw->bitmapEdit.copy_gc);
GetCopyGC(newcw);
do_redisplay = True;
}
if ((curcw->bitmapEdit.cur_x != newcw->bitmapEdit.cur_x) ||
(curcw->bitmapEdit.cur_y != newcw->bitmapEdit.cur_y))
do_redisplay = True;
if (curcw->bitmapEdit.cell_size_in_pixels !=
newcw->bitmapEdit.cell_size_in_pixels) {
ChangeCellSize(curcw, newcw->bitmapEdit.cell_size_in_pixels);
do_redisplay = True;
}
if (curcw->bitmapEdit.pixmap_width_in_cells !=
newcw->bitmapEdit.pixmap_width_in_cells) {
newcw->bitmapEdit.pixmap_width_in_cells =
curcw->bitmapEdit.pixmap_width_in_cells;
XtWarning("BitmapEdit: pixmap_width_in_cells cannot be \
set by XtSetValues.\n");
}
if (curcw->bitmapEdit.pixmap_height_in_cells !=
newcw->bitmapEdit.pixmap_height_in_cells) {
newcw->bitmapEdit.pixmap_height_in_cells =
curcw->bitmapEdit.pixmap_height_in_cells;
XtWarning("BitmapEdit: pixmap_height_in_cells cannot be \
set by XtSetValues.\n");
}
return do_redisplay;
}