1 /* 2 * twm menus include file 3 * 4 * 5 * Copyright 1988 by Evans & Sutherland Computer Corporation, 6 * Salt Lake City, Utah 7 * Portions Copyright 1989 by the Massachusetts Institute of Technology 8 * Cambridge, Massachusetts 9 * 10 * $XConsortium: menus.h,v 1.24 89/12/10 17:46:26 jim Exp $ 11 * 12 * 17-Nov-87 Thomas E. LaStrange File created 13 * 14 * Copyright 1992 Claude Lecommandeur. 15 */ 16 17 #ifndef _CTWM_MENUS_H 18 #define _CTWM_MENUS_H 19 20 #define TWM_ROOT "bLoB_GoOp" /* my private root menu */ 21 #define TWM_WINDOWS "TwmWindows" /* for f.menu "TwmWindows" */ 22 #define TWM_ICONS "TwmIcons" /* for f.menu "TwmIcons" */ 23 #define TWM_WORKSPACES "TwmWorkspaces" /* for f.menu "TwmWorkspaces" */ 24 #define TWM_ALLWINDOWS "TwmAllWindows" /* for f.menu "TwmAllWindows" */ 25 26 /* Added by dl 2004 */ 27 #define TWM_ALLICONS "TwmAllIcons" /* for f.menu "TwmAllIcons" */ 28 29 /*******************************************************************/ 30 /* Added by Dan Lilliehorn (dl@dl.nu) 2000-02-29 */ 31 #define TWM_KEYS "TwmKeys" /* for f.menu "TwmKeys" */ 32 #define TWM_VISIBLE "TwmVisible" /* for f.menu "TwmVisible" */ 33 34 35 /* 36 * MenuRoot.mapped - current/past state. 37 * 38 * XXX Perhaps the NEVER_MAPPED stuff should be pulled out and tracked 39 * some other way, and mapped just made into an bool. 40 */ 41 typedef enum { 42 MRM_NEVER, 43 MRM_UNMAPPED, 44 MRM_MAPPED, 45 } MRMapState; 46 47 48 struct MenuItem { 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 ColorPair normal; /* unhiglight colors */ 56 ColorPair highlight; /* highlight colors */ 57 short item_num; /* item number of this menu */ 58 short x; /* x coordinate for text */ 59 short func; /* twm built in function */ 60 bool state; /* in reversed video state (i.e., active) */ 61 short strlen; /* strlen(item) */ 62 bool user_colors; /* colors were specified */ 63 bool separated; /* separated from the next item */ 64 }; 65 66 struct MenuRoot { 67 struct MenuItem *first; /* first item in menu */ 68 struct MenuItem *last; /* last item in menu */ 69 struct MenuItem *lastactive; /* last active item in menu */ 70 struct MenuItem *defaultitem; /* default 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 Window w; /* the window of the menu */ 75 Window shadow; /* the shadow window */ 76 ColorPair highlight; /* highlight colors */ 77 MRMapState mapped; /* whether ever/currently mapped */ 78 short height; /* height of the menu */ 79 short width; /* width of the menu */ 80 short items; /* number of items in the menu */ 81 bool pull; /* is there a pull right entry ? */ 82 bool entered; /* EnterNotify following pop up */ 83 bool real_menu; /* this is a real menu */ 84 short x, y; /* position (for pinned menus) */ 85 bool pinned; /* is this a pinned menu*/ 86 struct MenuRoot *pmenu; /* the associated pinned menu */ 87 }; 88 89 90 struct MouseButton { 91 int func; /* the function number */ 92 int mask; /* modifier mask */ 93 MenuRoot *menu; /* menu if func is F_MENU */ 94 MenuItem *item; /* action to perform if func != F_MENU */ 95 }; 96 97 struct FuncButton { 98 struct FuncButton *next; /* next in the list of function buttons */ 99 int num; /* button number */ 100 int cont; /* context */ 101 int mods; /* modifiers */ 102 int func; /* the function number */ 103 MenuRoot *menu; /* menu if func is F_MENU */ 104 MenuItem *item; /* action to perform if func != F_MENU */ 105 }; 106 107 struct FuncKey { 108 struct FuncKey *next; /* next in the list of function keys */ 109 char *name; /* key name */ 110 KeySym keysym; /* X keysym */ 111 KeyCode keycode; /* X keycode */ 112 int cont; /* context */ 113 int mods; /* modifiers */ 114 int func; /* function to perform */ 115 char *win_name; /* window name (if any) */ 116 char *action; /* action string (if any) */ 117 MenuRoot *menu; /* menu if func is F_MENU */ 118 }; 119 120 extern MenuRoot *ActiveMenu; 121 extern MenuItem *ActiveItem; 122 123 extern bool menuFromFrameOrWindowOrTitlebar; 124 extern char *CurrentSelectedWorkspace; 125 extern bool AlternateContext; 126 extern int AlternateKeymap; 127 128 #define MAXMENUDEPTH 10 /* max number of nested menus */ 129 extern int MenuDepth; 130 131 #define WARPSCREEN_NEXT "next" 132 #define WARPSCREEN_PREV "prev" 133 #define WARPSCREEN_BACK "back" 134 135 #define COLORMAP_NEXT "next" 136 #define COLORMAP_PREV "prev" 137 #define COLORMAP_DEFAULT "default" 138 139 MenuRoot *NewMenuRoot(char *name); 140 MenuItem *AddToMenu(MenuRoot *menu, char *item, char *action, 141 MenuRoot *sub, int func, char *fore, char *back); 142 bool PopUpMenu(MenuRoot *menu, int x, int y, bool center); 143 void MakeWorkspacesMenu(void); 144 MenuRoot *FindMenuRoot(char *name); 145 bool AddFuncKey(char *name, int cont, int mods, int func, 146 MenuRoot *menu, char *win_name, char *action); 147 void AddFuncButton(int num, int cont, int mods, int func, 148 MenuRoot *menu, MenuItem *item); 149 void AddDefaultFuncButtons(void); 150 void PopDownMenu(void); 151 void HideMenu(MenuRoot *menu); 152 void PaintEntry(MenuRoot *mr, MenuItem *mi, bool exposure); 153 void PaintMenu(MenuRoot *mr, XEvent *e); 154 bool cur_fromMenu(void); 155 void UpdateMenu(void); 156 void MakeMenus(void); 157 void MakeMenu(MenuRoot *mr); 158 void MoveMenu(XEvent *eventp); 159 void WarpCursorToDefaultEntry(MenuRoot *menu); 160 161 #endif /* _CTWM_MENUS_H */ 162