/* Paint the label */
panel_paint_label(item);
/* Paint the value.
* In this wizzy example, we paint something into dp->block.
*/
display = (Display *) XV_DISPLAY_FROM_WINDOW(dp->panel);
for (ppw = (Panel_paint_window *)
xv_get(dp->panel, PANEL_FIRST_PAINT_WINDOW);
ppw;
ppw = ppw->next) {
pw = ppw->pw; /* pw = the actual window to paint in */
xid = (XID) xv_get(pw, XV_XID);
XFillRectangle(display, xid, dp->gc, dp->block.r_left,
dp->block.r_top, dp->block.r_width, dp->block.r_height);
}
}
25.11.9.10 The resize function
The resize function is called when the panel has been resized. Recalculate any extend-to-
edge dimensions. The function has the form:
static void
wizzy_resize (item)
Panel_item item;
25.11.9.11 The remove function
The remove function is called when the item has been made hidden via xv_set(item,
XV_SHOW, FALSE). An example function might be:
static void
wizzy_remove(item)
Panel_item item;
{
#ifdef WIZZY_CAN_ACCEPT_KBD_FOCUS
Wizzy_info *dp = WIZZY_PRIVATE(item);
Panel_status *panel_status;
/*
* Only reassign the keyboard focus to another item
* if the panel isn’t being destroyed.
*/
panel_status = (Panel_status *) xv_get(dp->panel, PANEL_STATUS);
if (!panel_status->destroying &&
xv_get(dp->panel, PANEL_CARET_ITEM) == item)
(void) panel_advance_caret(dp->panel);
#endif WIZZY_CAN_ACCEPT_KBD_FOCUS
}
XView Internals
XView Internals 629
25.11.9.12 The restore function
The restore function is called when the item has been made visible via xv_set(item,
XV_SHOW, TRUE). An example function might look like:
static void
wizzy_restore(item)
Panel_item item;
{
#ifdef WIZZY_CAN_ACCEPT_KBD_FOCUS
Wizzy_info *dp = WIZZY_PRIVATE(item);
/* If no item has the keyboard focus, then give this item the focus */
if (!xv_get(dp->panel, PANEL_CARET_ITEM))
xv_set(dp->panel, PANEL_CARET_ITEM, item, 0);
#endif WIZZY_CAN_ACCEPT_KBD_FOCUS
}
25.11.9.13 The layout function
The layout function is called when the item has been moved. Adjust the coordinates. An ex-
ample function might look like:
static void
wizzy_layout(item, deltas)
Panel_item item;
Rect *deltas;
{
Wizzy_info *dp = WIZZY_PRIVATE(item);
dp->block.r_left += deltas->r_left;
dp->block.r_top += deltas->r_top;
}
25.11.9.14 Accept keyboard focus function
The accept keyboard focus function is called when the keyboard focus has been set to this
item. Change the keyboard focus feedback to active, and update private data as necessary.
An example function might look like:
static void
wizzy_accept_kbd_focus(item)
Panel_item item;
{
Wizzy_info *dp = WIZZY_PRIVATE(item);
Frame frame;
int x;
int y;
dp->has_kbd_focus = TRUE;
frame = xv_get(dp->panel, WIN_FRAME);
if (xv_get(dp->panel, PANEL_LAYOUT) == PANEL_HORIZONTAL) {
630 XView Programming Manual
xv_set(frame, FRAME_FOCUS_DIRECTION, FRAME_FOCUS_UP, 0);
x = dp->block.r_left +
(dp->block.r_width - FRAME_FOCUS_UP_WIDTH)/2;
y = dp->block.r_top + dp->block.r_height - FRAME_FOCUS_UP_HEIGHT/2;
} else {
xv_set(frame, FRAME_FOCUS_DIRECTION, FRAME_FOCUS_RIGHT, 0);
x = dp->block.r_left - FRAME_FOCUS_RIGHT_WIDTH/2;
y = dp->block.r_top +
(dp->block.r_height - FRAME_FOCUS_RIGHT_HEIGHT)/2;
}
if (x < 0)
x = 0;
if (y < 0)
y = 0;
panel_show_focus_win(item, frame, x, y);
}
25.11.9.15 The yield keyboard focus function
The yield keyboard focus function is called when the keyboard focus has been removed from
this item. Change the keyboard focus back to inactive and update private data as necessary.
An example function might look like:
static void
wizzy_yield_kbd_focus(item)
Panel_item item;
{
Wizzy_info *dp = WIZZY_PRIVATE(item);
Xv_Window focus_win;
Frame frame;
dp->has_kbd_focus = FALSE;
frame = xv_get(dp->panel, WIN_FRAME);
focus_win = xv_get(frame, FRAME_FOCUS_WIN);
xv_set(focus_win, XV_SHOW, FALSE, 0);
}
25.11.10 Panel Item Extension Attributes
Table 25-1 lists the attributes for use with Panel Item extensions. This information is de-
scribed fully in the XView Reference Manual.
Table 25-1. Panel Item Extension Attributes
PANEL_ACCEPT_KEYSTROKE
PANEL_BUSY
PANEL_CURRENT_ITEM
PANEL_FIRST_PAINT_WINDOW
PANEL_FOCUS_PW
PANEL_GINFO
PANEL_ITEM_CREATED
XView Internals
XView Internals 631
Table 25-1. Panel Item Extension Attributes (continued)
PANEL_ITEM_DEAF
PANEL_ITEM_LABEL_RECT
PANEL_ITEM_VALUE_RECT
PANEL_ITEM_WANTS_ADJUST
PANEL_ITEM_WANTS_ISO
PANEL_ITEM_X_POSITION
PANEL_ITEM_Y_POSITION
PANEL_NO_REDISPLAY_ITEM
PANEL_OPS_VECTOR
PANEL_PRIMARY_FOCUS_ITEM
PANEL_STATUS
632 XView Programming Manual
This page intentionally left blank
to preserve original page counts.
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.