Example 12-6. The notice.c program (continued)
xv_set(panel, PANEL_LAYOUT, PANEL_HORIZONTAL, NULL);
(void) xv_create(panel, PANEL_BUTTON,
PANEL_LABEL_STRING, "Commit...",
PANEL_NOTIFY_PROC, my_notify_proc,
XV_KEY_DATA, MSG_ITEM, msg_item,
/*
* attach a prompt specific for this button used by
* notices
*/
XV_KEY_DATA, NOTICE_PROMPT, "Update all changes?",
/*
* Note there is no callback func here, but one could be
* written
*/
NULL);
window_fit(panel);
window_fit(frame);
xv_main_loop(frame);
}
/*
* my_notify_proc()
* The "key data" associated with the panel item is extracted via
* xv_get(). The resulting choice is displayed in the panel
* message item.
*/
Xv_opaque
my_notify_proc(item, event)
Panel_item item;
Event *event;
{
int result;
int (*func)();
char *prompt;
Panel_item msg_item;
Panel panel;
static Xv_notice notice = NULL;
func = (int(*)())xv_get(item, XV_KEY_DATA, CALLBACK_FUNC);
prompt = (char *)xv_get(item, XV_KEY_DATA, NOTICE_PROMPT);
msg_item = (Panel_item)xv_get(item, XV_KEY_DATA, MSG_ITEM);
panel = (Panel)xv_get(item, PANEL_PARENT_PANEL);
/*
* Create the notice and get a response.
*/
if (!notice) {
notice = xv_create(panel, NOTICE,
NOTICE_LOCK_SCREEN, TRUE,
NOTICE_STATUS, &result,
XV_SHOW, TRUE,
NOTICE_MESSAGE_STRINGS,
prompt,
"Press YES to confirm",
"Press NO to cancel",
NULL,
322 XView Programming Manual
Example 12-6. The notice.c program (continued)
NOTICE_BUTTON_YES, "YES",
NOTICE_BUTTON_NO, "NO",
NULL);
}
else {
/*
* If the notice has been created, just set its
* message strings and show it.
*/
xv_set(notice,
XV_SHOW, TRUE,
NOTICE_MESSAGE_STRINGS,
prompt,
"Press YES to confirm",
"Press NO to cancel",
NULL,
NULL);
}
switch(result) {
case NOTICE_YES:
xv_set(msg_item, PANEL_LABEL_STRING, "Confirmed", NULL);
if (func)
(*func)();
break;
case NOTICE_NO:
xv_set(msg_item, PANEL_LABEL_STRING, "Cancelled", NULL);
break;
case NOTICE_FAILED:
xv_set(msg_item, PANEL_LABEL_STRING, "unable to pop-up",
NULL);
break;
default:
xv_set(msg_item, PANEL_LABEL_STRING, "unknown choice",
NULL);
}
}
12.5 Notice Package Summary
Table 12-3 lists the attributes for the NOTICE package. These attributes are described fully in
the XView Reference Manual.
Notices
Notices 323
Table 12-3. Notice Attributes
NOTICE_BLOCK_THREAD NOTICE_LOCK_SCREEN
NOTICE_BUSY_FRAMES NOTICE_MESSAGE_STRING
NOTICE_BUTTON NOTICE_MESSAGE_STRINGS
NOTICE_BUTTON_NO NOTICE_MESSAGE_STRINGS_ARRAY_PTR
NOTICE_BUTTON_YES NOTICE_NO_BEEPING
NOTICE_EVENT_PROC NOTICE_STATUS
NOTICE_FOCUS_XY NOTICE_TRIGGER
NOTICE_FONT NOTICE_TRIGGER_EVENT
XV_KEY_DATA XV_SHOW
324 XView Programming Manual
This page intentionally left blank
to preserve original page counts.
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.