1 /*****************************************************************************/
2 /**       Copyright 1988 by Evans & Sutherland Computer Corporation,        **/
3 /**                          Salt Lake City, Utah                           **/
4 /**  Portions Copyright 1989 by the Massachusetts Institute of Technology   **/
5 /**                        Cambridge, Massachusetts                         **/
6 /**                                                                         **/
7 /**                           All Rights Reserved                           **/
8 /**                                                                         **/
9 /**    Permission to use, copy, modify, and distribute this software and    **/
10 /**    its documentation  for  any  purpose  and  without  fee is hereby    **/
11 /**    granted, provided that the above copyright notice appear  in  all    **/
12 /**    copies and that both  that  copyright  notice  and  this  permis-    **/
13 /**    sion  notice appear in supporting  documentation,  and  that  the    **/
14 /**    names of Evans & Sutherland and M.I.T. not be used in advertising    **/
15 /**    in publicity pertaining to distribution of the  software  without    **/
16 /**    specific, written prior permission.                                  **/
17 /**                                                                         **/
18 /**    EVANS & SUTHERLAND AND M.I.T. DISCLAIM ALL WARRANTIES WITH REGARD    **/
19 /**    TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES  OF  MERCHANT-    **/
20 /**    ABILITY  AND  FITNESS,  IN  NO  EVENT SHALL EVANS & SUTHERLAND OR    **/
21 /**    M.I.T. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL  DAM-    **/
22 /**    AGES OR  ANY DAMAGES WHATSOEVER  RESULTING FROM LOSS OF USE, DATA    **/
23 /**    OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER    **/
24 /**    TORTIOUS ACTION, ARISING OUT OF OR IN  CONNECTION  WITH  THE  USE    **/
25 /**    OR PERFORMANCE OF THIS SOFTWARE.                                     **/
26 /*****************************************************************************/
27 
28 
29 /***********************************************************************
30  *
31  * $XConsortium: menus.h,v 1.24 89/12/10 17:46:26 jim Exp $
32  *
33  * twm menus include file
34  *
35  * 17-Nov-87 Thomas E. LaStrange		File created
36  *
37  ***********************************************************************/
38 
39 #ifndef _MENUS_
40 #define _MENUS_
41 
42 #define TWM_ROOT	"bLoB_GoOp"	/* my private root menu */
43 #define TWM_WINDOWS	"TwmWindows"	/* for f.menu "TwmWindows" */
44 
45 #define MAX_FILE_SIZE 4096	/* max chars to read from file for cut */
46 
47 typedef struct MenuItem
48 {
49     struct MenuItem *next;	/* next menu item */
50     struct MenuItem *prev;	/* prev menu item */
51     struct MenuRoot *sub;	/* MenuRoot of a pull right menu */
52     struct MenuRoot *root;	/* back pointer to my MenuRoot */
53     char *item;			/* the character string displayed */
54     char *action;		/* action to be performed */
55     Pixel fore;			/* foreground color */
56     Pixel back;			/* background color */
57     Pixel hi_fore;		/* highlight foreground */
58     Pixel hi_back;		/* highlight background */
59     short item_num;		/* item number of this menu */
60     short x;			/* x coordinate for text */
61     short func;			/* twm built in function */
62     short state;		/* video state, 0 = normal, 1 = reversed */
63     short strlen;		/* strlen(item) */
64     short user_colors;		/* colors were specified */
65 } MenuItem;
66 
67 typedef struct MenuRoot
68 {
69     struct MenuItem *first;	/* first item in menu */
70     struct MenuItem *last;	/* last item in menu */
71     struct MenuRoot *prev;	/* previous root menu if pull right */
72     struct MenuRoot *next;	/* next in list of root menus */
73     char *name;			/* name of root */
74     char *file;			/* file where body is to be found */
75     Window w;			/* the window of the menu */
76     Window shadow;		/* the shadow window */
77     Pixel hi_fore;		/* highlight foreground */
78     Pixel hi_back;		/* highlight background */
79     time_t mtime;		/* when the file was last modified */
80     short mapped;		/* NEVER_MAPPED, UNMAPPED, or MAPPED */
81     short height;		/* height of the menu */
82     short width;		/* width of the menu */
83     short items;		/* number of items in the menu */
84     short def;			/* item index of default action */
85     short pull;			/* is there a pull right entry ? */
86     short entered;		/* EnterNotify following pop up */
87     short real_menu;		/* this is a real menu */
88 } MenuRoot;
89 
90 #define NEVER_MAPPED	0	/* constants for mapped field of MenuRoot */
91 #define UNMAPPED	1
92 #define MAPPED		2
93 
94 
95 typedef struct MouseButton
96 {
97     int func;			/* the function number */
98     int mask;			/* modifier mask */
99     MenuRoot *menu;		/* menu if func is F_MENU */
100     MenuItem *item;		/* action to perform if func != F_MENU */
101 } MouseButton;
102 
103 typedef struct FuncKey
104 {
105     struct FuncKey *next;	/* next in the list of function keys */
106     char *name;			/* key name */
107     KeySym keysym;		/* X keysym */
108     KeyCode keycode;		/* X keycode */
109     int cont;			/* context */
110     int mods;			/* modifiers */
111     int func;			/* function to perform */
112     char *win_name;		/* window name (if any) */
113     char *action;		/* action string (if any) */
114 } FuncKey;
115 
116 extern int RootFunction;
117 extern char *RootAction;
118 extern MenuRoot *ActiveMenu;
119 extern MenuItem *ActiveItem;
120 extern int MoveFunction;
121 extern int WindowMoved;
122 extern int ConstMove;
123 extern int ConstMoveDir;
124 extern int ConstMoveX;
125 extern int ConstMoveY;
126 extern int ConstMoveXL;
127 extern int ConstMoveXR;
128 extern int ConstMoveYT;
129 extern int ConstMoveYB;
130 
131 #define MAXMENUDEPTH	10	/* max number of nested menus */
132 extern int MenuDepth;
133 
134 #define MOVE_NONE	0	/* modes of constrained move */
135 #define MOVE_VERT	1
136 #define MOVE_HORIZ	2
137 
138 #define WARPSCREEN_NEXT "next"
139 #define WARPSCREEN_PREV "prev"
140 #define WARPSCREEN_BACK "back"
141 
142 #define COLORMAP_NEXT "next"
143 #define COLORMAP_PREV "prev"
144 #define COLORMAP_DEFAULT "default"
145 
146 extern void InitTitlebarButtons();
147 extern void InitMenus();
148 extern MenuRoot *NewMenuRoot();
149 extern MenuItem *AddToMenu();
150 extern Bool PopUpMenu();
151 extern MenuRoot *FindMenuRoot();
152 extern Bool AddFuncKey();
153 extern int ExecuteFunction();
154 extern int DeferExecution();
155 extern int Execute();
156 extern void FocusOnRoot();
157 
158 #endif /* _MENUS_ */
159