Added option to 'configure' to control debug information for compilation
[wmaker-crm.git] / src / menu.h
blob3922bcb6fb8db220cd2571d22a31c69787146d2c
1 /*
2 * Window Maker window manager
4 * Copyright (c) 1997-2003 Alfredo K. Kojima
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 along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #ifndef WMMENU_H_
22 #define WMMENU_H_
24 #include "wcore.h"
26 #define MI_DIAMOND 0
27 #define MI_CHECK 1
28 #define MI_MINIWINDOW 2
29 #define MI_HIDDEN 3
30 #define MI_SHADED 4
32 typedef struct WMenuEntry {
33 int order;
34 char *text; /* entry text */
35 char *rtext; /* text to show in the right part */
36 void (*callback)(struct WMenu *menu, struct WMenuEntry *entry);
37 void (*free_cdata)(void *data); /* proc to be used to free clientdata */
38 void *clientdata; /* data to pass to callback */
39 int cascade; /* cascade menu index */
40 #ifdef USER_MENU
41 WMPropList *instances; /* allowed instances */
42 #endif /* USER_MENU */
43 struct {
44 unsigned int enabled:1; /* entry is selectable */
45 unsigned int indicator:1; /* left indicator */
46 unsigned int indicator_on:1;
47 unsigned int indicator_type:3;
48 unsigned int editable:1;
49 } flags;
50 } WMenuEntry;
53 typedef struct WMenu {
54 struct WMenu *parent;
55 struct WMenu *brother;
57 time_t timestamp; /* for the root menu. Last time
58 * menu was reloaded */
60 /* decorations */
61 struct WFrameWindow *frame;
62 WCoreWindow *menu; /* the window menu */
63 Pixmap menu_texture_data;
64 int frame_x, frame_y; /* position of the frame in root*/
66 WMenuEntry **entries; /* array of entries. This is shared
67 * by the menu and it's "brother" */
68 short alloced_entries; /* number of entries allocated in
69 * entry array */
70 struct WMenu **cascades; /* array of cascades */
71 short cascade_no;
73 short entry_no; /* number of entries */
74 short selected_entry;
76 short entry_height; /* height of each entry */
78 WMHandlerID timer; /* timer for the autoscroll */
80 void *jump_back; /* jump back data */
82 /* to be called when some entry is edited */
83 void (*on_edit)(struct WMenu *menu, struct WMenuEntry *entry);
84 /* to be called when destroyed */
85 void (*on_destroy)(struct WMenu *menu);
87 struct {
88 unsigned int titled:1;
89 unsigned int realized:1; /* whether the window was configured */
90 unsigned int app_menu:1; /* this is a application or root menu */
91 unsigned int mapped:1; /* if menu is already mapped on screen*/
92 unsigned int buttoned:1; /* if the close button is visible
93 * (menu was torn off) */
94 unsigned int open_to_left:1; /* direction to open submenus */
95 unsigned int lowered:1;
97 unsigned int brother:1; /* if this is a copy of the menu*/
98 unsigned int editing:1;
99 unsigned int jump_back_pending:1;
101 unsigned int inside_handler:1;
102 } flags;
103 } WMenu;
106 void wMenuPaint(WMenu *menu);
107 void wMenuDestroy(WMenu *menu, int recurse);
108 void wMenuRealize(WMenu *menu);
109 WMenuEntry *wMenuInsertCascade(WMenu *menu, int index, char *text,
110 WMenu *cascade);
111 WMenuEntry *wMenuInsertCallback(WMenu *menu, int index, char *text,
112 void (*callback)(WMenu *menu, WMenuEntry *entry),
113 void *clientdata);
115 void wMenuEntrySetCascade(WMenu *menu, WMenuEntry *entry, WMenu *cascade);
117 #define wMenuAddCallback(menu, text, callback, data) \
118 wMenuInsertCallback(menu, -1, text, callback, data)
120 void wMenuRemoveItem(WMenu *menu, int index);
122 WMenu *wMenuCreate(WScreen *screen, char *title, int main_menu);
123 WMenu *wMenuCreateForApp(WScreen *screen, char *title, int main_menu);
124 void wMenuMap(WMenu *menu);
125 void wMenuMapAt(WMenu *menu, int x, int y, int keyboard);
126 #define wMenuMapCopyAt(menu, x, y) wMenuMapAt((menu)->brother, (x), (y), False)
127 void wMenuUnmap(WMenu *menu);
128 void wMenuSetEnabled(WMenu *menu, int index, int enable);
129 void wMenuMove(WMenu *menu, int x, int y, int submenus);
130 void wMenuEntryRemoveCascade(WMenu *menu, WMenuEntry *entry);
131 void wMenuScroll(WMenu *menu, XEvent *event);
132 WMenu *wMenuUnderPointer(WScreen *screen);
133 void wMenuSaveState(WScreen *scr);
134 void wMenuRestoreState(WScreen *scr);
137 #endif