1 /*****************************************************************************/ 2 /* 3 4 Copyright 1989,1998 The Open Group 5 6 Permission to use, copy, modify, distribute, and sell this software and its 7 documentation for any purpose is hereby granted without fee, provided that 8 the above copyright notice appear in all copies and that both that 9 copyright notice and this permission notice appear in supporting 10 documentation. 11 12 The above copyright notice and this permission notice shall be included in 13 all copies or substantial portions of the Software. 14 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 22 Except as contained in this notice, the name of The Open Group shall not be 23 used in advertising or otherwise to promote the sale, use or other dealings 24 in this Software without prior written authorization from The Open Group. 25 26 */ 27 /** Copyright 1988 by Evans & Sutherland Computer Corporation, **/ 28 /** Salt Lake City, Utah **/ 29 /** Cambridge, Massachusetts **/ 30 /** **/ 31 /** All Rights Reserved **/ 32 /** **/ 33 /** Permission to use, copy, modify, and distribute this software and **/ 34 /** its documentation for any purpose and without fee is hereby **/ 35 /** granted, provided that the above copyright notice appear in all **/ 36 /** copies and that both that copyright notice and this permis- **/ 37 /** sion notice appear in supporting documentation, and that the **/ 38 /** name of Evans & Sutherland not be used in advertising **/ 39 /** in publicity pertaining to distribution of the software without **/ 40 /** specific, written prior permission. **/ 41 /** **/ 42 /** EVANS & SUTHERLAND DISCLAIMs ALL WARRANTIES WITH REGARD **/ 43 /** TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT- **/ 44 /** ABILITY AND FITNESS, IN NO EVENT SHALL EVANS & SUTHERLAND **/ 45 /** BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAM- **/ 46 /** AGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA **/ 47 /** OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER **/ 48 /** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE **/ 49 /** OR PERFORMANCE OF THIS SOFTWARE. **/ 50 /*****************************************************************************/ 51 52 /*********************************************************************** 53 * 54 * twm menus include file 55 * 56 * 17-Nov-87 Thomas E. LaStrange File created 57 * 58 ***********************************************************************/ 59 60 #ifndef _MENUS_ 61 #define _MENUS_ 62 63 #define TWM_ROOT "bLoB_GoOp" /* my private root menu */ 64 #define TWM_WINDOWS "TwmWindows" /* for f.menu "TwmWindows" */ 65 66 #define MAX_FILE_SIZE 4096 /* max chars to read from file for cut */ 67 68 typedef struct MenuItem { 69 struct MenuItem *next; /* next menu item */ 70 struct MenuItem *prev; /* prev menu item */ 71 struct MenuRoot *sub; /* MenuRoot of a pull right menu */ 72 struct MenuRoot *root; /* back pointer to my MenuRoot */ 73 const char *item; /* the character string displayed */ 74 const char *action; /* action to be performed */ 75 Pixel fore; /* foreground color */ 76 Pixel back; /* background color */ 77 Pixel hi_fore; /* highlight foreground */ 78 Pixel hi_back; /* highlight background */ 79 short item_num; /* item number of this menu */ 80 short x; /* x coordinate for text */ 81 short func; /* twm built in function */ 82 short state; /* video state, 0 = normal, 1 = reversed */ 83 short strlen; /* strlen(item) */ 84 short user_colors; /* colors were specified */ 85 } MenuItem; 86 87 typedef struct MenuRoot { 88 struct MenuItem *first; /* first item in menu */ 89 struct MenuItem *last; /* last item in menu */ 90 struct MenuRoot *prev; /* previous root menu if pull right */ 91 struct MenuRoot *next; /* next in list of root menus */ 92 const char *name; /* name of root */ 93 Window w; /* the window of the menu */ 94 Window shadow; /* the shadow window */ 95 Pixel hi_fore; /* highlight foreground */ 96 Pixel hi_back; /* highlight background */ 97 short mapped; /* NEVER_MAPPED, UNMAPPED, or MAPPED */ 98 short height; /* height of the menu */ 99 short width; /* width of the menu */ 100 short items; /* number of items in the menu */ 101 short pull; /* is there a pull right entry ? */ 102 short entered; /* EnterNotify following pop up */ 103 short real_menu; /* this is a real menu */ 104 } MenuRoot; 105 106 #define NEVER_MAPPED 0 /* constants for mapped field of MenuRoot */ 107 #define UNMAPPED 1 108 #define MAPPED 2 109 110 typedef struct MouseButton { 111 int func; /* the function number */ 112 int mask; /* modifier mask */ 113 MenuRoot *menu; /* menu if func is F_MENU */ 114 MenuItem *item; /* action to perform if func != F_MENU */ 115 } MouseButton; 116 117 typedef struct FuncKey { 118 struct FuncKey *next; /* next in the list of function keys */ 119 char *name; /* key name */ 120 KeySym keysym; /* X keysym */ 121 KeyCode keycode; /* X keycode */ 122 int cont; /* context */ 123 int mods; /* modifiers */ 124 int func; /* function to perform */ 125 char *win_name; /* window name (if any) */ 126 char *action; /* action string (if any) */ 127 } FuncKey; 128 129 extern int RootFunction; 130 extern MenuRoot *ActiveMenu; 131 extern MenuItem *ActiveItem; 132 extern int MoveFunction; 133 extern int WindowMoved; 134 extern int ConstMove; 135 extern int ConstMoveDir; 136 extern int ConstMoveX; 137 extern int ConstMoveY; 138 extern int ConstMoveXL; 139 extern int ConstMoveXR; 140 extern int ConstMoveYT; 141 extern int ConstMoveYB; 142 extern int menuFromFrameOrWindowOrTitlebar; 143 extern int ResizeOrigX; 144 extern int ResizeOrigY; 145 146 #define MAXMENUDEPTH 10 /* max number of nested menus */ 147 extern int MenuDepth; 148 149 #define MOVE_NONE 0 /* modes of constrained move */ 150 #define MOVE_VERT 1 151 #define MOVE_HORIZ 2 152 153 #define WARPSCREEN_NEXT "next" 154 #define WARPSCREEN_PREV "prev" 155 #define WARPSCREEN_BACK "back" 156 157 #define COLORMAP_NEXT "next" 158 #define COLORMAP_PREV "prev" 159 #define COLORMAP_DEFAULT "default" 160 161 extern void InitMenus(void); 162 extern Bool AddFuncKey(char *name, int cont, int mods, int func, char *win_name, 163 char *action); 164 extern int CreateTitleButton(const char *name, int func, const char *action, 165 MenuRoot *menuroot, Bool rightside, Bool append); 166 extern void InitTitlebarButtons(void); 167 extern void PaintEntry(MenuRoot *mr, MenuItem *mi, int exposure); 168 extern void PaintMenu(MenuRoot *mr, XEvent *e); 169 extern void UpdateMenu(void); 170 extern MenuRoot *NewMenuRoot(const char *name); 171 extern MenuItem *AddToMenu(MenuRoot *menu, const char *item, const char *action, 172 MenuRoot *sub, int func, const char *fore, 173 const char *back); 174 extern void MakeMenus(void); 175 extern Bool PopUpMenu(MenuRoot *menu, int x, int y, Bool center); 176 extern void PopDownMenu(void); 177 extern MenuRoot *FindMenuRoot(const char *name); 178 extern int ExecuteFunction(int func, const char *action, Window w, 179 TwmWindow *tmp_win, XEvent *eventp, int context, 180 int pulldown); 181 extern void ReGrab(void); 182 extern void FocusOnRoot(void); 183 extern void DeIconify(TwmWindow *tmp_win); 184 extern void Iconify(TwmWindow *tmp_win, int def_x, int def_y); 185 extern void SetMapStateProp(TwmWindow *tmp_win, int state); 186 extern void WarpToScreen(int n, int inc); 187 extern void SetBorder(TwmWindow *tmp, Bool onoroff); 188 extern void SendDeleteWindowMessage(TwmWindow *tmp, Time timestamp); 189 extern void SendSaveYourselfMessage(TwmWindow *tmp, Time timestamp); 190 extern void SendTakeFocusMessage(TwmWindow *tmp, Time timestamp); 191 192 #endif /* _MENUS_ */ 193