[Top] [Prev] [Next] [Index]
Page 21 out of 84 total pages , Page 4 out of 6 pages in this chapter

Update Functions

The update function is called by Builder Xcessory to display a value in a resource type editor. The value can be passed as either a string (the most common case) or as a value of the actual type. The string value used by Builder Xcessory is the same value that the fetch function returns.


Note: For Builder Xcessory to use a new resource type correctly, there must be a resource converter to convert a string representation of the resource to the actual expected type. Most widgets provide this type of converter for new types to allow the resource to be set from an application defaults file. See your Xt documentation for more information about resource converters.


EditorUpdateFunc Function Prototype

The update function has the following function prototype:

void EditorUpdateFunc(char *val_str, XtPointer val_ptr,
  Widget wgt, XtPointer data,
  XtPointer bx_internal)

val_str String representation of the value of the resource that should be displayed in the resource type editor. This is the most common way Builder Xcessory passes a value to be displayed. Always try to use this value first when determining what to display. This value can be NULL.

val_ptr Pointer to the value to display in the resource type. You must cast this pointer to the correct type. This method of passing a value to display is used rarely by Builder Xcessory. In most cases, this value is NULL.

wgt Widget that is above the top-level container of your resource type editor. For an extended editor, wgt is the shell widget containing the editor. For a simple editor, wgt is the parent widget of your top-level container.

data Pointer value that you supplied in the creation function. If you did not specify a value, data is NULL.

bx_internal Used by Builder Xcessory. Do not modify this value.

Example

As an example of the resource type editor update function, we'll examine the functions for the XmNjustify resource of the XmDumbLabel widget:

void JustifySingleUpdate(String strval, XtPointer typeval,
    Widget editor, XtPointer data,
    XtPointer unused)
{
JustifyWidgets *wids = (JustifyWidgets*) data;
int value = (int)typeval;
if ( strval )
{
if ( !strcmp("left", strval) )
{
value = XmALIGNMENT_LEFT;
}
else if ( !strcmp("center", strval) )
{
value = XmALIGNMENT_CENTER;
}
else if ( !strcmp("right", strval) )
{
value = XmALIGNMENT_RIGHT;
}
{
switch(value)
{
case XmALIGNMENT_LEFT:
XmToggleButtonGadgetSetState(wids->sngl_left,
   True, False);
XmToggleButtonGadgetSetState(wids->sngl_cntr,
   False, False);
XmToggleButtonGadgetSetState(wids->sngl_right,
   False, False);
break;
case XmALIGNMENT_CENTER:

... Set Toggle Button Values ...

break;
case XmALIGNMENT_RIGHT:
... Set Toggle Button Values ...
break;
}
}


[Top] [Prev] [Next] [Index]
Page 21 out of 84 total pages , Page 4 out of 6 pages in this chapter

info@ics.com
Copyright © 1998, Integrated Computer Solutions, Inc. All rights reserved.