1
/* This software is subject to the terms of the Common Public License
2
You must accept the terms of this license to use this software.
4
Copyright (C) 2002, International Business Machines Corporation
5
and others. All Rights Reserved.
7
Further information about Common Public License Version 0.5 is obtained
8
from url http://oss.software.ibm.com/developer/opensource/license-cpl.html */
10
#include <X11/Intrinsic.h>
11
#include <X11/Xaw/SimpleMenu.h>
12
#include <X11/Xaw/SmeBSB.h>
13
#include <X11/StringDefs.h>
17
extern Pixmap menu_item_bitmap;
20
static void font_callback(Widget w, XtPointer p, XtPointer p2);
21
static void toggle_scrollbar(Widget w, XtPointer p, XtPointer p2);
22
static void toggle_scrollbar_left(Widget w, XtPointer p, XtPointer p2);
23
static void toggle_visual_bell(Widget w, XtPointer p, XtPointer p2);
24
static void toggle_reverse_video(Widget w, XtPointer p, XtPointer p2);
33
struct MenuEntry font_menu_entry[] ={
34
{"default", font_callback,NULL},
35
{"fontSet1", font_callback,NULL},
36
{"fontSet2", font_callback,NULL},
37
{"fontSet3", font_callback,NULL},
38
{"fontSet4", font_callback,NULL},
39
{"fontSet5", font_callback,NULL},
40
{"fontSet6", font_callback,NULL},
43
struct MenuEntry option_menu_entry[] ={
44
{"enableScrollbar", toggle_scrollbar,NULL},
45
{"enableScrollbarLeft", toggle_scrollbar_left,NULL},
46
{"enableVisualBell",toggle_visual_bell,NULL},
47
{"enableReverseVideo",toggle_reverse_video,NULL},
50
#define SetBitmap(w,bool) \
53
bool?menu_item_bitmap:(XtArgVal)0, \
58
static void font_callback(Widget w, XtPointer p, XtPointer p2)
62
struct MenuEntry *entries = font_menu_entry;
64
ItermSelectFont(iterm,num);
66
for(i=0;entries[i].name != NULL;i++)
68
SetBitmap(entries[i].entry_widget,i==num);
72
static void toggle_scrollbar(Widget w, XtPointer p, XtPointer p2)
74
ItermSetScrollbar(iterm,!ItermIsScrollbarOn(iterm));
75
SetBitmap(w,ItermIsScrollbarOn(iterm));
78
static void toggle_scrollbar_left(Widget w, XtPointer p, XtPointer p2)
80
ItermSetScrollbarLeft(iterm,!ItermIsScrollbarLeft(iterm));
81
SetBitmap(w,ItermIsScrollbarLeft(iterm));
84
static void toggle_visual_bell(Widget w, XtPointer p, XtPointer p2)
86
ItermSetVisualBell(iterm,!ItermIsVisualBell(iterm));
87
SetBitmap(w,ItermIsVisualBell(iterm));
90
static void toggle_reverse_video(Widget w, XtPointer p, XtPointer p2)
92
ItermSetReverseVideo(iterm,!ItermIsReverseVideo(iterm));
93
SetBitmap(w,ItermIsReverseVideo(iterm));
96
static Widget create_popup_menu(Widget parent,
98
struct MenuEntry *entries)
101
XtCallbackRec cb[2] = { { NULL, 0 }, { NULL, NULL }};
102
Arg arg[] = {{ XtNcallback, (XtArgVal) cb},};
104
popup = XtVaCreatePopupShell(widget_name,simpleMenuWidgetClass,parent,
106
for(i=0;entries[i].name != NULL;i++)
108
cb[0].callback = entries[i].proc;
109
cb[0].closure =(XtPointer)i;
110
entries[i].entry_widget = XtCreateManagedWidget(entries[i].name,
118
Widget init_font_menu(Widget parent)
120
Widget menu = create_popup_menu(parent,"fontMenu",font_menu_entry);
121
XtVaSetValues(font_menu_entry[0].entry_widget,
122
XtNleftBitmap,menu_item_bitmap,
127
Widget init_option_menu(Widget parent)
129
Widget menu = create_popup_menu(parent,"optionMenu",option_menu_entry);
130
XtVaSetValues(option_menu_entry[0].entry_widget,
132
ItermIsScrollbarOn(iterm)?menu_item_bitmap:(XtArgVal)0,
134
XtVaSetValues(option_menu_entry[1].entry_widget,
136
ItermIsScrollbarLeft(iterm)?menu_item_bitmap:(XtArgVal)0,
138
XtVaSetValues(option_menu_entry[2].entry_widget,
140
ItermIsVisualBell(iterm)?menu_item_bitmap:(XtArgVal)0,
142
XtVaSetValues(option_menu_entry[3].entry_widget,
144
ItermIsReverseVideo(iterm)?menu_item_bitmap:(XtArgVal)0,
150
static void videoChanged(Widget w, XtPointer p1, XtPointer p2)
152
SetBitmap((Widget)p1,p2);
155
void set_callbacks(Widget iterm)
157
XtAddCallback(iterm,XtNvideoChanged,videoChanged,
158
option_menu_entry[3].entry_widget);