1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 #ifndef _XMenu_h_
35 #define _XMenu_h_
36
37 #include <stdlib.h>
38 #include <X11/Xutil.h>
39 #include "X10.h"
40
41 #define FAILURE -1
42 #define SUCCESS 1
43 #define POST_ERROR -1
44 #define NO_SELECTION -1
45
46 #define XM_FAILURE -1
47 #define XM_SUCCESS 1
48 #define XM_NO_SELECT 2
49 #define XM_IA_SELECT 3
50
51 #define XME_CODE_COUNT 17
52
53 #define XME_NO_ERROR 0
54 #define XME_NOT_INIT 1
55 #define XME_ARG_BOUNDS 2
56 #define XME_P_NOT_FOUND 3
57 #define XME_S_NOT_FOUND 4
58 #define XME_STYLE_PARAM 5
59 #define XME_GRAB_MOUSE 6
60 #define XME_INTERP_LOC 7
61 #define XME_CALLOC 8
62 #define XME_CREATE_ASSOC 9
63 #define XME_STORE_BITMAP 10
64 #define XME_MAKE_TILES 11
65 #define XME_MAKE_PIXMAP 12
66 #define XME_CREATE_CURSOR 13
67 #define XME_OPEN_FONT 14
68 #define XME_CREATE_WINDOW 15
69 #define XME_CREATE_TRANSP 16
70
71
72
73
74 extern int _XMErrorCode;
75 extern char const *const _XMErrorList[];
76
77
78
79
80
81
82
83
84
85
86
87
88
89 typedef enum _xmwintype {PANE, SELECTION, PL_HEADER, SL_HEADER, SEPARATOR} XMWType;
90
91 typedef struct _xmwindow {
92 struct _xmwindow *next;
93 struct _xmwindow *prev;
94 XMWType type;
95 Window window;
96 int window_x;
97 int window_y;
98 int window_w;
99 int window_h;
100 int active;
101 int activated;
102 int pad_l1;
103 char *pad_l2;
104 int pad_l3;
105 int pad_l4;
106 int pad_l5;
107 int pad_l6;
108 int pad_l7;
109 int pad_l8;
110 struct _xmwindow *pad_l9;
111 char *pad_l10;
112 struct _xmwindow *pad_l11;
113 } XMWindow;
114
115 typedef struct _xmpane {
116 struct _xmpane *next;
117 struct _xmpane *prev;
118 XMWType type;
119 Window window;
120 int window_x;
121 int window_y;
122 int window_w;
123 int window_h;
124 int active;
125 int activated;
126 int serial;
127 char const *label;
128 int label_width;
129 int label_length;
130 int label_x;
131 int label_uy;
132 int label_ly;
133 int s_count;
134 struct _xmselect *s_list;
135 char *pad_l10;
136 struct _xmwindow *pad_l11;
137 } XMPane;
138
139 typedef struct _xmselect {
140 struct _xmselect *next;
141 struct _xmselect *prev;
142 XMWType type;
143 Window window;
144 Window parent;
145 int window_x;
146 int window_y;
147 int window_w;
148 int window_h;
149 int active;
150 int activated;
151 int serial;
152 char *label;
153 int label_width;
154 int label_length;
155 int label_x;
156 int label_y;
157 int pad_l7;
158 int pad_l8;
159 struct _xmwindow *pad_l9;
160 char *data;
161 struct _xmpane *parent_p;
162 char const *help_string;
163 } XMSelect;
164
165
166
167
168
169
170
171
172 typedef enum _xmstyle {
173 LEFT,
174 RIGHT,
175 CENTER
176 } XMStyle;
177
178
179
180
181
182
183
184
185 typedef enum _xmmode {
186 BOX,
187 INVERT
188 } XMMode;
189
190
191
192
193
194
195
196 typedef struct _xmenu {
197
198 XMStyle menu_style;
199 XMMode menu_mode;
200 int freeze;
201 int aeq;
202 int recompute;
203 Window parent;
204 int width;
205 int height;
206 int x_pos;
207 int y_pos;
208 Cursor mouse_cursor;
209 XAssocTable *assoc_tab;
210 XMPane *p_list;
211
212 XMStyle p_style;
213 int p_events;
214 XFontStruct *p_fnt_info;
215 GC pane_GC;
216 int p_fnt_pad;
217 double p_spread;
218 int p_bdr_width;
219 int flag_height;
220 int p_width;
221 int p_height;
222 int p_x_off;
223 int p_y_off;
224 int p_count;
225
226 XMStyle s_style;
227 int s_events;
228 XFontStruct *s_fnt_info;
229 int s_fnt_pad;
230 double s_spread;
231 int s_bdr_width;
232 int s_width;
233 int s_height;
234 int s_x_off;
235 int s_y_off;
236 int s_count;
237 GC normal_select_GC;
238 GC inverse_select_GC;
239 GC inact_GC;
240
241
242 unsigned long p_bdr_color;
243 unsigned long s_bdr_color;
244 unsigned long p_frg_color;
245 unsigned long s_frg_color;
246 unsigned long bkgnd_color;
247
248 Pixmap p_bdr_pixmap;
249 Pixmap s_bdr_pixmap;
250 Pixmap p_frg_pixmap;
251 Pixmap s_frg_pixmap;
252 Pixmap bkgnd_pixmap;
253 Pixmap inact_pixmap;
254 } XMenu;
255
256 typedef void (*Wait_func)(void*);
257
258
259
260
261 typedef void (*Translate_func)(XEvent *);
262
263
264
265
266 XMenu *XMenuCreate(Display *display, Window parent, char const *def_env);
267 int XMenuAddPane(Display *display, XMenu *menu, char const *label, int active);
268 int XMenuAddSelection(Display *display, XMenu *menu, int p_num, char *data, char *label, int active, char const *help);
269 int XMenuInsertPane(XMenu *menu, int p_num, char *label, int active);
270 int XMenuInsertSelection(XMenu *menu, int p_num, int s_num, char *data, char *label, int active);
271 int XMenuFindPane(XMenu *menu, char *label);
272 int XMenuFindSelection(XMenu *menu, int p_num, char *label);
273 int XMenuChangePane(XMenu *menu, int p_num, char *label);
274 int XMenuChangeSelection(Display *display, XMenu *menu, int p_num, int s_num, char *data, int data_sw, char *label, int label_sw);
275 int XMenuSetPane(XMenu *menu, int p_num, int active);
276 int XMenuSetSelection(XMenu *menu, int p_num, int s_num, int active);
277 int XMenuRecompute(Display *display, XMenu *menu);
278 void XMenuEventHandler(int (*handler) (XEvent *));
279 int XMenuLocate(Display *display, XMenu *menu, int p_num, int s_num, int x_pos, int y_pos, int *ul_x, int *ul_y, int *width, int *height);
280 void XMenuSetFreeze(XMenu *menu, int freeze);
281 void XMenuActivateSetWaitFunction(Wait_func func, void *data);
282 void XMenuActivateSetTranslateFunction(Translate_func func);
283 int XMenuActivate(Display *display, XMenu *menu, int *p_num, int *s_num, int x_pos, int y_pos, unsigned int event_mask, char **data, void (*help_callback) (char const *, int, int));
284 char *XMenuPost(Display *display, XMenu *menu, int *p_num, int *s_num, int x_pos, int y_pos, int event_mask);
285 int XMenuDeletePane(Display *display, XMenu *menu, int p_num);
286 int XMenuDeleteSelection(Display *display, XMenu *menu, int p_num, int s_num);
287 void XMenuDestroy(Display *display, XMenu *menu);
288 char const *XMenuError(void);
289 void XMenuSetAEQ(XMenu *menu, int aeq);
290
291 #endif
292