*** empty log message ***
[wmaker-crm.git] / src / menu.h
blob415ea78a6819bd44c98851299149b07da7ee09d5
1 /*
2 * Window Maker 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 MI_DIAMOND 0
28 #define MI_CHECK 1
29 #define MI_MINIWINDOW 2
30 #define MI_HIDDEN 3
31 #define MI_SHADED 4
33 typedef struct WMenuEntry {
34 int order;
35 char *text; /* entry text */
36 char *rtext; /* text to show in the right part */
37 void (*callback)(struct WMenu *menu, struct WMenuEntry *entry);
38 void (*free_cdata)(void *data); /* proc to be used to free clientdata */
39 void *clientdata; /* data to pass to callback */
40 int cascade; /* cascade menu index */
41 #ifdef USER_MENU
42 proplist_t instances; /* allowed instances */
43 #endif /* USER_MENU */
44 struct {
45 unsigned int enabled:1; /* entry is selectable */
46 unsigned int indicator:1; /* left indicator */
47 unsigned int indicator_on:1;
48 unsigned int indicator_type:3;
49 unsigned int editable:1;
50 } flags;
51 } WMenuEntry;
54 typedef struct WMenu {
55 struct WMenu *parent;
56 struct WMenu *brother;
58 time_t timestamp; /* for the root menu. Last time
59 * menu was reloaded */
61 /* decorations */
62 struct WFrameWindow *frame;
63 WCoreWindow *menu; /* the window menu */
64 Pixmap menu_texture_data;
65 int frame_x, frame_y; /* position of the frame in root*/
67 WMenuEntry **entries; /* array of entries. This is shared
68 * by the menu and it's "brother" */
69 short alloced_entries; /* number of entries allocated in
70 * entry array */
71 struct WMenu **cascades; /* array of cascades */
72 short cascade_no;
74 short entry_no; /* number of entries */
75 short selected_entry;
77 short entry_height; /* height of each entry */
79 WMHandlerID timer; /* timer for the autoscroll */
81 /* to be called when some entry is edited */
82 void (*on_edit)(struct WMenu *menu, struct WMenuEntry *entry);
83 /* to be called when destroyed */
84 void (*on_destroy)(struct WMenu *menu);
86 struct {
87 unsigned int titled:1;
88 unsigned int realized:1; /* whether the window was configured */
89 unsigned int app_menu:1; /* this is a application or root menu */
90 unsigned int mapped:1; /* if menu is already mapped on screen*/
91 unsigned int buttoned:1; /* if the close button is visible
92 * (menu was torn off) */
93 unsigned int open_to_left:1; /* direction to open submenus */
94 unsigned int lowered:1;
96 unsigned int brother:1; /* if this is a copy of the menu*/
97 unsigned int editing:1;
98 unsigned int jump_back_pending:1;
99 } flags;
100 } WMenu;
103 void wMenuPaint(WMenu *menu);
104 void wMenuDestroy(WMenu *menu, int recurse);
105 void wMenuRealize(WMenu *menu);
106 WMenuEntry *wMenuInsertCascade(WMenu *menu, int index, char *text,
107 WMenu *cascade);
108 WMenuEntry *wMenuInsertCallback(WMenu *menu, int index, char *text,
109 void (*callback)(WMenu *menu, WMenuEntry *entry),
110 void *clientdata);
112 void wMenuEntrySetCascade(WMenu *menu, WMenuEntry *entry, WMenu *cascade);
114 #define wMenuAddCallback(menu, text, callback, data) \
115 wMenuInsertCallback(menu, -1, text, callback, data)
117 void wMenuRemoveItem(WMenu *menu, int index);
119 WMenu *wMenuCreate(WScreen *screen, char *title, int main_menu);
120 WMenu *wMenuCreateForApp(WScreen *screen, char *title, int main_menu);
121 void wMenuMap(WMenu *menu);
122 void wMenuMapAt(WMenu *menu, int x, int y, int keyboard);
123 #define wMenuMapCopyAt(menu, x, y) wMenuMapAt((menu)->brother, (x), (y), False)
124 void wMenuUnmap(WMenu *menu);
125 void wMenuSetEnabled(WMenu *menu, int index, int enable);
126 void wMenuMove(WMenu *menu, int x, int y, int submenus);
127 void wMenuEntryRemoveCascade(WMenu *menu, WMenuEntry *entry);
128 void wMenuScroll(WMenu *menu, XEvent *event);
129 WMenu *wMenuUnderPointer(WScreen *screen);
130 void wMenuSaveState(WScreen *scr);
131 void wMenuRestoreState(WScreen *scr);
134 #endif