Initial revision
[wmaker-crm.git] / src / menu.h
blobb4943f04a07706a13e0990542b5bcea31a2e5b99
1 /*
2 * WindowMaker window manager
3 *
4 * Copyright (c) 1997, 1998 Alfredo K. Kojima
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19 * USA.
22 #ifndef WMMENU_H_
23 #define WMMENU_H_
25 #include "wcore.h"
27 #define MR_RESIZED 1
28 #define MR_TITLE_BACK 2
29 #define MR_TEXT_BACK 4
30 #define MR_TITLE_TEXT 8
32 #define MI_DIAMOND 0
33 #define MI_CHECK 1
34 #define MI_MINIWINDOW 2
35 #define MI_HIDDEN 3
36 #define MI_SHADED 4
38 typedef struct WMenuEntry {
39 int order;
40 char *text; /* entry text */
41 char *rtext; /* text to show in the right part */
42 void (*callback)(struct WMenu *menu, struct WMenuEntry *entry);
43 void (*free_cdata)(void *data); /* proc to be used to free clientdata */
44 void *clientdata; /* data to pass to callback */
45 int cascade; /* cascade menu index */
46 struct {
47 unsigned int enabled:1; /* entry is selectable */
48 unsigned int indicator:1; /* left indicator */
49 unsigned int indicator_on:1;
50 unsigned int indicator_type:3;
51 unsigned int editable:1;
52 } flags;
53 } WMenuEntry;
56 typedef struct WMenu {
57 struct WMenu *parent;
58 struct WMenu *brother;
60 time_t timestamp; /* for the root menu. Last time
61 * menu was reloaded */
63 /* decorations */
64 struct WFrameWindow *frame;
65 WCoreWindow *menu; /* the window menu */
66 Pixmap menu_texture_data;
67 int frame_x, frame_y; /* position of the frame in root*/
69 WMenuEntry **entries; /* array of entries. This is shared
70 * by the menu and it's "brother" */
71 short alloced_entries; /* number of entries allocated in
72 * entry array */
73 struct WMenu **cascades; /* array of cascades */
74 short cascade_no;
76 short entry_no; /* number of entries */
77 short selected_entry;
79 short entry_height; /* height of each entry */
81 WMHandlerID timer; /* timer for the autoscroll */
83 /* to be called when some entry is edited */
84 void (*on_edit)(struct WMenu *menu, struct WMenuEntry *entry);
85 /* to be called when destroyed */
86 void (*on_destroy)(struct WMenu *menu);
88 struct {
89 unsigned int titled:1;
90 unsigned int realized:1; /* whether the window was configured */
91 unsigned int app_menu:1; /* this is a application or root menu */
92 unsigned int mapped:1; /* if menu is already mapped on screen*/
93 unsigned int buttoned:1; /* if the close button is visible
94 * (menu was torn off) */
95 unsigned int open_to_left:1; /* direction to open submenus */
96 unsigned int lowered:1;
98 unsigned int brother:1; /* if this is a copy of the menu*/
99 unsigned int editing:1;
100 } flags;
101 } WMenu;
104 void wMenuRefresh(WMenu *menu, int flags);
105 void wMenuPaint(WMenu *menu);
106 void wMenuDestroy(WMenu *menu, int recurse);
107 void wMenuRealize(WMenu *menu);
108 WMenuEntry *wMenuInsertCascade(WMenu *menu, int index, char *text,
109 WMenu *cascade);
110 WMenuEntry *wMenuInsertCallback(WMenu *menu, int index, char *text,
111 void (*callback)(WMenu *menu, WMenuEntry *entry),
112 void *clientdata);
114 void wMenuEntrySetCascade(WMenu *menu, WMenuEntry *entry, WMenu *cascade);
116 #define wMenuAddCallback(menu, text, callback, data) \
117 wMenuInsertCallback(menu, -1, text, callback, data)
119 void wMenuRemoveItem(WMenu *menu, int index);
121 WMenu *wMenuCreate(WScreen *screen, char *title, int main_menu);
122 WMenu *wMenuCreateForApp(WScreen *screen, char *title, int main_menu);
123 void wMenuMap(WMenu *menu);
124 void wMenuMapAt(WMenu *menu, int x, int y, int keyboard);
125 #define wMenuMapCopyAt(menu, x, y) wMenuMapAt((menu)->brother, (x), (y), False)
126 void wMenuUnmap(WMenu *menu);
127 void wMenuSetEnabled(WMenu *menu, int index, int enable);
128 void wMenuMove(WMenu *menu, int x, int y, int submenus);
129 void wMenuEntryRemoveCascade(WMenu *menu, WMenuEntry *entry);
130 void wMenuScroll(WMenu *menu, XEvent *event);
131 WMenu *wMenuUnderPointer(WScreen *screen);
132 void wMenuSaveState(WScreen *scr);
133 void wMenuRestoreState(WScreen *scr);
136 #endif