/usr/share/doc/xviewg/examples/menus/simple_menu.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 75 76 77 78 79 80 81 82 83 84 85 86 | /*
* simple_menu.c -
* Demonstrate the use of an XView menu in a canvas subwindow.
* A Menu is brought up with the MENU mouse button. The choices
* in the menu toggle the display of the scrollbar next to the canvas.
*/
#include <xview/xview.h>
#include <xview/canvas.h>
#include <xview/scrollbar.h>
#define SCROLLBAR_KEY 100
#define MENU_KEY 200
main(argc,argv)
int argc;
char *argv[];
{
Frame frame;
Canvas canvas;
Scrollbar scrollbar;
Menu menu;
void menu_notify_proc(), pw_event_proc();
xv_init(XV_INIT_ARGC_PTR_ARGV, &argc, argv, NULL);
/*
* Create a frame, canvas and menu.
* A canvas receives input in its canvas_paint_window().
*/
frame = (Frame)xv_create(NULL, FRAME,
FRAME_LABEL, argv[0],
NULL);
canvas = (Canvas)xv_create(frame, CANVAS,
XV_WIDTH, 300,
XV_HEIGHT, 200,
NULL);
scrollbar = (Scrollbar)xv_create(canvas, SCROLLBAR,
SCROLLBAR_DIRECTION, SCROLLBAR_VERTICAL,
NULL);
menu = (Menu)xv_create(NULL, MENU,
MENU_TITLE_ITEM, "Scrollbar",
MENU_STRINGS, "On", "Off", NULL,
MENU_NOTIFY_PROC, menu_notify_proc,
XV_KEY_DATA, SCROLLBAR_KEY, scrollbar,
NULL);
xv_set(canvas_paint_window(canvas),
WIN_EVENT_PROC, pw_event_proc,
XV_KEY_DATA, MENU_KEY, menu,
NULL);
window_fit(frame);
window_main_loop(frame);
}
/*
* menu_notify_proc - toggle the display of the scrollbar
* based on which menu item was chosen.
*/
void
menu_notify_proc(menu, menu_item)
Menu menu;
Menu_item menu_item;
{
char *menu_choice = (char *)xv_get(menu_item, MENU_STRING);
int show_it = !strcmp(menu_choice, "On");
xv_set(xv_get(menu, XV_KEY_DATA, SCROLLBAR_KEY),
XV_SHOW, show_it,
NULL);
}
/*
* Call menu_show() to display menu.
*/
void
pw_event_proc(canvas_pw, event)
Xv_Window canvas_pw;
Event *event;
{
if (event_action(event) == ACTION_MENU && event_is_down(event)) {
Menu menu = (Menu)xv_get(canvas_pw, XV_KEY_DATA, MENU_KEY);
menu_show(menu, canvas_pw, event, NULL);
}
}
|