Update Serbian translation from master branch
[wmaker-crm.git] / src / menu.h
blob60ff95559b14ef26f54648744b3c469c88c20528
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_NONE 0
27 #define MI_DIAMOND 1
28 #define MI_CHECK 2
29 #define MI_MINIWINDOW 3
30 #define MI_HIDDEN 4
31 #define MI_SHADED 5
32 #define MI_SNAP_V 6
33 #define MI_SNAP_H 7
34 #define MI_SNAP_RH 8
35 #define MI_SNAP_LH 9
36 #define MI_SNAP_TH 10
37 #define MI_SNAP_BH 11
38 #define MI_SNAP_TL 12
39 #define MI_SNAP_TR 13
40 #define MI_SNAP_BL 14
41 #define MI_SNAP_BR 15
42 #define MI_SNAP_TILED 16
43 #define MI_CENTRAL 17
45 typedef struct WMenuEntry {
46 int order;
47 char *text; /* entry text */
48 char *rtext; /* text to show in the right part */
49 void (*callback)(struct WMenu *menu, struct WMenuEntry *entry);
50 void (*free_cdata)(void *data); /* proc to be used to free clientdata */
51 void *clientdata; /* data to pass to callback */
52 int cascade; /* cascade menu index */
53 #ifdef USER_MENU
54 WMPropList *instances; /* allowed instances */
55 #endif /* USER_MENU */
56 struct {
57 unsigned int enabled:1; /* entry is selectable */
58 unsigned int indicator:1; /* left indicator */
59 unsigned int indicator_on:1;
60 unsigned int indicator_type:5;
61 unsigned int editable:1;
62 } flags;
63 } WMenuEntry;
66 typedef struct WMenu {
67 struct WMenu *parent;
68 struct WMenu *brother;
70 time_t timestamp; /* for the root menu. Last time
71 * menu was reloaded */
73 /* decorations */
74 struct WFrameWindow *frame;
75 WCoreWindow *menu; /* the window menu */
76 Pixmap menu_texture_data;
77 int frame_x, frame_y; /* position of the frame in root*/
79 WMenuEntry **entries; /* array of entries. This is shared
80 * by the menu and its "brother" */
81 short alloced_entries; /* number of entries allocated in
82 * entry array */
83 struct WMenu **cascades; /* array of cascades */
84 short cascade_no;
86 short entry_no; /* number of entries */
87 short selected_entry;
89 short entry_height; /* height of each entry */
91 WMHandlerID timer; /* timer for the autoscroll */
93 void *jump_back; /* jump back data */
95 /* to be called when some entry is edited */
96 void (*on_edit)(struct WMenu *menu, struct WMenuEntry *entry);
97 /* to be called when destroyed */
98 void (*on_destroy)(struct WMenu *menu);
100 struct {
101 unsigned int titled:1;
102 unsigned int realized:1; /* whether the window was configured */
103 unsigned int app_menu:1; /* this is a application or root menu */
104 unsigned int mapped:1; /* if menu is already mapped on screen*/
105 unsigned int buttoned:1; /* if the close button is visible
106 * (menu was torn off) */
107 unsigned int open_to_left:1; /* direction to open submenus */
108 unsigned int lowered:1;
110 unsigned int brother:1; /* if this is a copy of the menu*/
111 unsigned int editing:1;
112 unsigned int jump_back_pending:1;
114 unsigned int inside_handler:1;
115 unsigned int shaded:1;
116 } flags;
117 } WMenu;
120 void wMenuPaint(WMenu *menu);
121 void wMenuDestroy(WMenu *menu, int recurse);
122 void wMenuRealize(WMenu *menu);
123 WMenuEntry *wMenuInsertCascade(WMenu *menu, int index, const char *text,
124 WMenu *cascade);
125 WMenuEntry *wMenuInsertCallback(WMenu *menu, int index, const char *text,
126 void (*callback)(WMenu *menu, WMenuEntry *entry),
127 void *clientdata);
129 void wMenuEntrySetCascade(WMenu *menu, WMenuEntry *entry, WMenu *cascade);
131 #define wMenuAddCallback(menu, text, callback, data) \
132 wMenuInsertCallback(menu, -1, text, callback, data)
134 void wMenuRemoveItem(WMenu *menu, int index);
136 WMenu *wMenuCreate(WScreen *screen, const char *title, int main_menu);
137 WMenu *wMenuCreateForApp(WScreen *screen, const char *title, int main_menu);
138 void wMenuMap(WMenu *menu);
139 void wMenuMapAt(WMenu *menu, int x, int y, int keyboard);
140 #define wMenuMapCopyAt(menu, x, y) wMenuMapAt((menu)->brother, (x), (y), False)
141 void wMenuUnmap(WMenu *menu);
142 void wMenuSetEnabled(WMenu *menu, int index, int enable);
143 void wMenuMove(WMenu *menu, int x, int y, int submenus);
144 void wMenuEntryRemoveCascade(WMenu *menu, WMenuEntry *entry);
145 void wMenuScroll(WMenu *menu);
146 WMenu *wMenuUnderPointer(WScreen *screen);
147 void wMenuSaveState(WScreen *scr);
148 void wMenuRestoreState(WScreen *scr);
151 #endif