/usr/share/doc/xviewg/examples/notice/trigger_notice.c is in xview-examples 3.2p1.4-28.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | /*
* trigger_notice.c -- Demonstrate the use of triggers in notices.
*/
#include <xview/xview.h>
#include <xview/panel.h>
#include <xview/notice.h>
main(argc,argv)
int argc;
char *argv[];
{
Frame frame;
Panel panel;
Xv_opaque my_notify_proc();
extern void exit();
/*
* Initialize XView, create a frame, a panel and one panel button.
*/
xv_init(XV_INIT_ARGS, argc, argv, NULL);
frame = (Frame)xv_create(XV_NULL, FRAME, NULL);
panel = (Panel)xv_create(frame, PANEL, NULL);
(void) xv_create(panel, PANEL_BUTTON,
PANEL_LABEL_STRING, "Quit",
PANEL_NOTIFY_PROC, exit,
NULL);
(void) xv_create(panel, PANEL_BUTTON,
PANEL_LABEL_STRING, "Move",
PANEL_NOTIFY_PROC, my_notify_proc,
NULL);
/* make sure everything looks good */
window_fit(panel);
window_fit(frame);
/* start window event processing */
xv_main_loop(frame);
}
/*
* my_notify_proc() -- called when the user selects the "Move"
* panel button. Put up a notice_prompt to get new coordinates
* to move the main window.
*/
Xv_opaque
my_notify_proc(item, event)
Panel_item item;
Event *event;
{
int result, x, y;
Panel panel = (Panel)xv_get(item, PANEL_PARENT_PANEL);
Frame frame = (Frame)xv_get(panel, XV_OWNER);
x = event_x(event), y = event_y(event);
printf("original click relative to panel: %d, %d\n", x, y);
result = notice_prompt(panel, event,
NOTICE_FOCUS_XY, x, y,
NOTICE_MESSAGE_STRINGS,
"You may move the window to a new location specified by",
"clicking the Left Mouse Button somewhere on the screen",
"or cancel this operation by selecting \"cancel\".",
NULL,
NOTICE_BUTTON_YES, "cancel",
NOTICE_TRIGGER, MS_LEFT,
NOTICE_NO_BEEPING, TRUE,
NULL);
if (result == NOTICE_TRIGGERED) {
x = event_x(event) + (int)xv_get(frame, XV_X);
y = event_y(event) + (int)xv_get(frame, XV_Y);
printf("screen x,y: %d, %d\n", x, y);
xv_set(frame, XV_X, x, XV_Y, y, NULL);
}
}
|