25.11.6 The Wizzy Set Method
The code for the set method is as follows:
Pkg_private Xv_opaque
wizzy_set_avlist(item, avlist)
Panel_item item; /* this object */
Attr_avlist avlist; /* attribute list */
{
Wizzy_private *dp = WIZZY_PRIVATE(item);
Xv_opaque result;
Rect value_rect;
Attr_attribute *attrs;
/* Parse panel item generic attributes before parsing Wizzy
* specific attributes and prevent panel_redisplay_item() from
* being called in item_set_avlist()
*/
if (*avlist != XV_END_CREATE) {
xv_set( dp->panel, PANEL_NO_REDISPLAY_ITEM, TRUE, NULL);
result = xv_super_avlist( item, &xv_wizzy_panel_pkg, avlist);
xv_set( dp->panel, PANEL_NO_REDISPLAY_ITEM, FALSE, NULL);
if (result != XV_OK)
return (result);
}
for ( attrs = avlist; *avlist; attrs = attr_next(attrs)) {
switch ( (int)attrs[0 ] ) {
case WIZZY_OFFSET:
dp->offset = attrs[1];
break;
case WIZZY_FLAG:
dp->flag = attrs[1];
break;
case XV_END_CREATE:
value_rect = *(Rect *)xv_get(item, PANEL_ITEM_VALUE_RECT);
rect_construct(&dp->block,
value_rect.r_left + dp->offset,
value_rect.r_top,
BLOCK_WIDTH, BLOCK_HEIGHT);
value_rect = rect_bounding(&value_rect, &dp->block);
/* Note: setting the value rect will cause the item
* item rect to be recalculated as the enclosing rect
* containing both the label and value rects.
*/
xv_set( item, PANEL_ITEM_VALUE_RECT, &value_rect,
624 XView Programming Manual
NULL);
break;
default:
break;
}
}
return XV_OK; /* return XV_ERROR if something went very wrong */
}
The purpose of the set method is to set any of the attributes defined in the public header file
by storing the corresponding value in the private data structure. In the case of the Wizzy
package, WIZZY_OFFSET and WIZZY_FLAG are the only attributes and they correspond to
offset and flag, respectively.
However, before parsing attributes specific to the Wizzy object, it is necessary to parse any
attributes generic to Panel. This is done by a call to xv_super_avlist(). It is also nec-
essary to prevent the parent panel from redisplaying while these attributes are being set. This
is taken care of by setting the attribute PANEL_NO_REDISPLAY_ITEM to TRUE for the parent
panel and then resetting it to FALSE.
After all attributes are handled, the value rectangle value_rect is constructed and the
item rectangle is recalculated since it encloses both the label and value rectangles.
25.11.7 The Wizzy Get Method
The get routine for the Wizzy package provides the ability to return values for
WIZZY_OFFSET and WIZZY_FLAG.
Pkg_private Xv_opaque
wizzy_get_attr(item, status, which_attr, avlist)
Panel_item item;
int *status;
Attr_attribute which_attr;
va_list avlist;
{
Wizzy_private *dp = WIZZY_PRIVATE(item);
switch ( (int)which_attr ) {
case WIZZY_OFFSET:
return (Xv_opaque)dp->offset;
break;
case WIZZY_FLAG:
return (Xv_opaque)dp->flag;
break;
default:
XView Internals
XView Internals 625
*status = xv_check_bad_attr(WIZZY, attr);
return (Xv_opaque)XV_OK;
}
}
25.11.8 The Wizzy Destroy Method
When an instance of the Wizzy class is destroyed, the destroy procedure is called. The first
parameter to the destroy function is a handle to the panel item being destroyed. The second
parameter is the destroy status (see Chapter 20, The Notifier, for more information on des-
troy_status). The task of the destroy function for the Wizzy package is to remove the
item from the list of items attached to the panel object and free it. Once the object has been
freed, all references to the object become invalid.
Pkg_private int
wizzy_destroy(item, status)
Panel_item item;
Destroy_status status;
{
Wizzy_private *dp = WIZZY_PRIVATE(item);
if ( (status==DESTROY_CHECKING) || (status==DESTROY_YOURSELF) )
return XV_OK;
#ifdef WIZZY_CAN_ACCEPT_KBD_FOCUS
wizzy_remove(item);
#endif WIZZY_CAN_ACCEPT_KBD_FOCUS
free(dp);
return XV_OK;
}
25.11.9 Panel Item Handler Procedures
25.11.9.1 The handle event function
The handle event function allows the application writer to specify a notify procedure for the
panel item.
626 XView Programming Manual
25.11.9.2 The begin preview function
The begin preview function is called when SELECT-down has been detected. Highlight the
item to show active feedback but don’t actually take any action yet. Private data may be ac-
cessed as necessary. The function has the form:
static void
wizzy_begin_preview (item, event)
Panel_item item;
Event *event;
25.11.9.3 The update preview function
The update preview function is called when the pointer has been dragged within the item af-
ter begin preview was detected. Adjust highlighting to reflect the new position of the pointer
and update the appropriate private data. The function has the form:
static void
wizzy_update_preview (item, event)
Panel_item item;
Event *event;
25.11.9.4 The cancel preview function
The cancel preview function is called when the pointer has been dragged out of the item after
begin preview was detected. Remove the active feedback (i.e., de-highlight) and clean up any
private data. The function has the form:
static void
wizzy_cancel_preview (item, event)
Panel_item item;
Event *event;
25.11.9.5 The accept preview function
The accept preview function is called when the SELECT button has been released over the
item. Remove the active feedback (i.e., de-highlight), paint the busy feedback, perform the
action associated with the item, and then remove the busy feedback. Also update any private
data as necessary. The function has the form:
static void
wizzy_accept_preview (item, event)
Panel_item item;
Event *event;
XView Internals
XView Internals 627
25.11.9.6 The accept menu function
The accept menu function is called when the MENU button has been pressed over the item.
Show the menu item attached to the item, if any. The function has the form:
static void
wizzy_accept_menu (item, event)
Panel_item item;
Event *event;
25.11.9.7 The accept key function
The accept key function is called when a keyboard event has been detected. Process the key
and update the data and/or display as necessary. The function has the form:
static void
wizzy_accept_key (item, event)
Panel_item item;
Event *event;
25.11.9.8 The clear function
The clear function is called whenever the item’s rectangle needs to be cleared. Clear the
item rectangle and update any private data as needed. An example of this function would be:
static void
wizzy_clear (item, event)
Panel_item item;
Event *event;
{
panel_default_clear_item(item);
}
25.11.9.9 The paint function
The paint function is called when the panel needs to be repainted. Do everything necessary
to paint the entire item but do not go outside of the rectangle describing the boundaries of the
item. An example of this function would be:
static void
wizzy_paint(item)
Panel_item item;
Display *display;
Wizzy_info *dp = WIZZY_PRIVATE(item);
Panel_paint_window *ppw; /* ptr to Panel_paint_window structure */
Xv_Window pw; /* paint window */
XID xid;
628 XView Programming Manual

Get Volume 7A: XView 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.