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