tk@essex.ac.UK (tk) (09/07/90)
%% This is an example programme given in XView Programming Manual (Vol. 7)
%% by Dan Heller. It worked fine using the old XView which comes alongwith
%% X11R4 tapes. Now I have installed XView-2.0 (on SUN-4/110 with SOS-4.1)
%% and the programme still compiles fine.
%%
%% The problem is that the menu is not displayed any more and reports this
%% error when I click the right button on the canvas:
XView warning: menu_show: menu not owned by this server (Command Menu package)
%% Please e-mail to ghosr@essex.ac.uk if you are aware of any solution to
%% this problem or even have experienced this problem.
---x---x---x---x---x---x---x---x---x---x---x---x---x---x---x---x---x---x---
#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);
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(canvas, 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);
}
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);
}
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);
}
}