menus.h revision c2535118
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 *
55 * twm menus include file
56 *
57 * 17-Nov-87 Thomas E. LaStrange		File created
58 *
59 ***********************************************************************/
60
61#ifndef _MENUS_
62#define _MENUS_
63
64#define TWM_ROOT	"bLoB_GoOp"	/* my private root menu */
65#define TWM_WINDOWS	"TwmWindows"	/* for f.menu "TwmWindows" */
66
67#define MAX_FILE_SIZE 4096	/* max chars to read from file for cut */
68
69typedef struct MenuItem
70{
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{
91    struct MenuItem *first;	/* first item in menu */
92    struct MenuItem *last;	/* last item in menu */
93    struct MenuRoot *prev;	/* previous root menu if pull right */
94    struct MenuRoot *next;	/* next in list of root menus */
95    const char *name;		/* name of root */
96    Window w;			/* the window of the menu */
97    Window shadow;		/* the shadow window */
98    Pixel hi_fore;		/* highlight foreground */
99    Pixel hi_back;		/* highlight background */
100    short mapped;		/* NEVER_MAPPED, UNMAPPED, or MAPPED */
101    short height;		/* height of the menu */
102    short width;		/* width of the menu */
103    short items;		/* number of items in the menu */
104    short pull;			/* is there a pull right entry ? */
105    short entered;		/* EnterNotify following pop up */
106    short real_menu;		/* this is a real menu */
107} MenuRoot;
108
109#define NEVER_MAPPED	0	/* constants for mapped field of MenuRoot */
110#define UNMAPPED	1
111#define MAPPED		2
112
113
114typedef struct MouseButton
115{
116    int func;			/* the function number */
117    int mask;			/* modifier mask */
118    MenuRoot *menu;		/* menu if func is F_MENU */
119    MenuItem *item;		/* action to perform if func != F_MENU */
120} MouseButton;
121
122typedef struct FuncKey
123{
124    struct FuncKey *next;	/* next in the list of function keys */
125    char *name;			/* key name */
126    KeySym keysym;		/* X keysym */
127    KeyCode keycode;		/* X keycode */
128    int cont;			/* context */
129    int mods;			/* modifiers */
130    int func;			/* function to perform */
131    char *win_name;		/* window name (if any) */
132    char *action;		/* action string (if any) */
133} FuncKey;
134
135extern int RootFunction;
136extern MenuRoot *ActiveMenu;
137extern MenuItem *ActiveItem;
138extern int MoveFunction;
139extern int WindowMoved;
140extern int ConstMove;
141extern int ConstMoveDir;
142extern int ConstMoveX;
143extern int ConstMoveY;
144extern int ConstMoveXL;
145extern int ConstMoveXR;
146extern int ConstMoveYT;
147extern int ConstMoveYB;
148extern int menuFromFrameOrWindowOrTitlebar;
149extern int ResizeOrigX;
150extern int ResizeOrigY;
151
152#define MAXMENUDEPTH	10	/* max number of nested menus */
153extern int MenuDepth;
154
155#define MOVE_NONE	0	/* modes of constrained move */
156#define MOVE_VERT	1
157#define MOVE_HORIZ	2
158
159#define WARPSCREEN_NEXT "next"
160#define WARPSCREEN_PREV "prev"
161#define WARPSCREEN_BACK "back"
162
163#define COLORMAP_NEXT "next"
164#define COLORMAP_PREV "prev"
165#define COLORMAP_DEFAULT "default"
166
167extern void InitMenus ( void );
168extern Bool AddFuncKey ( char *name, int cont, int mods, int func, char *win_name, char *action );
169extern int CreateTitleButton ( const char *name, int func, const char *action, MenuRoot *menuroot, Bool rightside, Bool append );
170extern void InitTitlebarButtons ( void );
171extern void PaintEntry ( MenuRoot *mr, MenuItem *mi, int exposure );
172extern void PaintMenu ( MenuRoot *mr, XEvent *e );
173extern void UpdateMenu ( void );
174extern MenuRoot * NewMenuRoot ( const char *name );
175extern MenuItem * AddToMenu ( MenuRoot *menu, const char *item, const char *action, MenuRoot *sub, int func, const char *fore, const char *back );
176extern void MakeMenus ( void );
177extern Bool PopUpMenu ( MenuRoot *menu, int x, int y, Bool center );
178extern void PopDownMenu ( void );
179extern MenuRoot * FindMenuRoot ( const char *name );
180extern int ExecuteFunction ( int func, const char *action, Window w, TwmWindow *tmp_win, XEvent *eventp, int context, int pulldown );
181extern void ReGrab ( void );
182extern void FocusOnRoot ( void );
183extern void DeIconify ( TwmWindow *tmp_win );
184extern void Iconify ( TwmWindow *tmp_win, int def_x, int def_y );
185extern void SetMapStateProp ( TwmWindow *tmp_win, int state );
186extern void WarpToScreen ( int n, int inc );
187extern void SetBorder ( TwmWindow *tmp, Bool onoroff );
188extern void SendDeleteWindowMessage ( TwmWindow *tmp, Time timestamp );
189extern void SendSaveYourselfMessage ( TwmWindow *tmp, Time timestamp );
190extern void SendTakeFocusMessage ( TwmWindow *tmp, Time timestamp );
191
192#endif /* _MENUS_ */
193