276
|
1 /* toolbar implementation -- mswindows interface.
|
|
2 Copyright (C) 1998 Free Software Foundation.
|
|
3
|
|
4 This file is part of XEmacs.
|
|
5
|
|
6 XEmacs is free software; you can redistribute it and/or modify it
|
|
7 under the terms of the GNU General Public License as published by the
|
|
8 Free Software Foundation; either version 2, or (at your option) any
|
|
9 later version.
|
|
10
|
|
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 for more details.
|
|
15
|
|
16 You should have received a copy of the GNU General Public License
|
|
17 along with XEmacs; see the file COPYING. If not, write to
|
|
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
19 Boston, MA 02111-1307, USA. */
|
|
20
|
|
21 /* This implementation by Andy Piper <andyp@parallax.co.uk>, with bits
|
|
22 borrowed from toolbar-x.c */
|
|
23
|
|
24 /* Synched up with: Not in FSF. */
|
|
25
|
|
26 #include <config.h>
|
|
27 #include "lisp.h"
|
|
28
|
|
29 #include "faces.h"
|
|
30 #include "frame.h"
|
|
31 #include "toolbar.h"
|
|
32 #include "window.h"
|
|
33 #include "gui.h"
|
278
|
34 #include "elhash.h"
|
276
|
35 #include "console-msw.h"
|
|
36 #include "glyphs-msw.h"
|
|
37 #include "objects-msw.h"
|
|
38
|
|
39 /* Why did Kirill choose this range ? */
|
|
40 #define TOOLBAR_ITEM_ID_MIN 0x4000
|
|
41 #define TOOLBAR_ITEM_ID_MAX 0x7FFF
|
|
42 #define TOOLBAR_ITEM_ID_BITS(x) (((x) & 0x3FFF) | 0x4000)
|
278
|
43 #define TOOLBAR_ID_BIAS 16
|
|
44 #define TOOLBAR_HANDLE(f,p) \
|
|
45 GetDlgItem(FRAME_MSWINDOWS_HANDLE(f), TOOLBAR_ID_BIAS + p)
|
276
|
46 #ifndef TB_SETIMAGELIST
|
|
47 #define TB_SETIMAGELIST (WM_USER + 48)
|
|
48 #define TB_GETIMAGELIST (WM_USER + 49)
|
278
|
49 #define TB_SETPADDING (WM_USER + 87)
|
276
|
50 #endif
|
|
51
|
|
52 #define SET_TOOLBAR_WAS_VISIBLE_FLAG(frame, pos, flag) \
|
|
53 do { \
|
|
54 switch (pos) \
|
|
55 { \
|
|
56 case TOP_TOOLBAR: \
|
|
57 (frame)->top_toolbar_was_visible = flag; \
|
|
58 break; \
|
|
59 case BOTTOM_TOOLBAR: \
|
|
60 (frame)->bottom_toolbar_was_visible = flag; \
|
|
61 break; \
|
|
62 case LEFT_TOOLBAR: \
|
|
63 (frame)->left_toolbar_was_visible = flag; \
|
|
64 break; \
|
|
65 case RIGHT_TOOLBAR: \
|
|
66 (frame)->right_toolbar_was_visible = flag; \
|
|
67 break; \
|
|
68 default: \
|
|
69 abort (); \
|
|
70 } \
|
|
71 } while (0)
|
|
72
|
|
73 static int
|
278
|
74 allocate_toolbar_item_id (struct frame* f, struct toolbar_button* button,
|
|
75 enum toolbar_pos pos)
|
276
|
76 {
|
|
77 /* hmm what do we generate an id based on */
|
|
78 int id = TOOLBAR_ITEM_ID_BITS (internal_hash (button->callback, 0));
|
|
79 while (!NILP (Fgethash (make_int (id),
|
|
80 FRAME_MSWINDOWS_TOOLBAR_HASHTABLE (f), Qnil)))
|
|
81 {
|
|
82 id = TOOLBAR_ITEM_ID_BITS (id + 1);
|
|
83 }
|
|
84 return id;
|
|
85 }
|
|
86
|
|
87 static void
|
|
88 mswindows_clear_toolbar (struct frame *f, enum toolbar_pos pos,
|
|
89 int thickness_change)
|
|
90 {
|
|
91 HIMAGELIST ilist=NULL;
|
278
|
92 int i;
|
|
93 HWND toolbarwnd = TOOLBAR_HANDLE(f, pos);
|
|
94 if (toolbarwnd)
|
276
|
95 {
|
278
|
96 TBBUTTON info;
|
276
|
97
|
278
|
98 /* delete the buttons and remove the command from the hashtable*/
|
|
99 i = SendMessage (toolbarwnd, TB_BUTTONCOUNT, 0, 0);
|
|
100 for (i--; i >= 0; i--)
|
|
101 {
|
|
102 SendMessage (toolbarwnd, TB_GETBUTTON, (WPARAM)i,
|
|
103 (LPARAM)&info);
|
|
104 Fremhash(make_int(info.idCommand),
|
|
105 FRAME_MSWINDOWS_TOOLBAR_HASHTABLE(f));
|
|
106 SendMessage (toolbarwnd, TB_DELETEBUTTON, (WPARAM)i, 0);
|
|
107 }
|
|
108
|
276
|
109 /* finally get rid of the image list assuming it clears up its
|
|
110 bitmaps */
|
278
|
111 SendMessage (toolbarwnd, TB_GETIMAGELIST, 0, (LONG) &ilist);
|
276
|
112 if (ilist)
|
|
113 {
|
|
114 ImageList_Destroy(ilist);
|
|
115 }
|
278
|
116 SendMessage (toolbarwnd, TB_SETIMAGELIST, 0, (LPARAM)NULL);
|
|
117
|
|
118 ShowWindow(toolbarwnd, SW_HIDE);
|
276
|
119 }
|
278
|
120
|
|
121 FRAME_MSWINDOWS_TOOLBAR_CHECKSUM(f,pos)=0;
|
|
122 SET_TOOLBAR_WAS_VISIBLE_FLAG (f, pos, 0);
|
276
|
123 }
|
|
124
|
|
125 static void
|
|
126 mswindows_output_toolbar (struct frame *f, enum toolbar_pos pos)
|
|
127 {
|
|
128 int x, y, bar_width, bar_height, vert;
|
|
129 int width=-1, height=-1, bmwidth=-1, bmheight=-1;
|
|
130 int border_width = FRAME_REAL_TOOLBAR_BORDER_WIDTH (f, pos);
|
|
131 Lisp_Object button, window, glyph, instance;
|
|
132 int nbuttons=0;
|
278
|
133 int shadow_thickness = 2; /* get this from somewhere else? */
|
|
134 int window_frame_width = 3;
|
|
135 unsigned int checksum=0;
|
276
|
136 struct window *w;
|
|
137 TBBUTTON* button_tbl, *tbbutton;
|
|
138 HIMAGELIST ilist=NULL;
|
278
|
139 HWND toolbarwnd=NULL;
|
276
|
140
|
|
141 get_toolbar_coords (f, pos, &x, &y, &bar_width, &bar_height, &vert, 0);
|
278
|
142
|
|
143 if (x==1)
|
|
144 x=0;
|
|
145
|
276
|
146 window = FRAME_LAST_NONMINIBUF_WINDOW (f);
|
|
147 w = XWINDOW (window);
|
|
148
|
278
|
149 toolbarwnd = TOOLBAR_HANDLE(f,pos);
|
|
150
|
276
|
151 /* set button sizes based on bar size */
|
|
152 if (vert)
|
|
153 {
|
278
|
154 width = height = bar_width;
|
|
155 bmwidth = bmheight = width - (border_width + shadow_thickness) * 2;
|
276
|
156 }
|
|
157 else
|
|
158 {
|
278
|
159 height = width = bar_height - window_frame_width * 2;
|
|
160 bmwidth = bmheight = width - (border_width + shadow_thickness) * 2;
|
276
|
161 }
|
|
162
|
|
163 button = FRAME_TOOLBAR_DATA (f, pos)->toolbar_buttons;
|
|
164
|
|
165 /* First loop over all of the buttons to determine how many there
|
|
166 are. This loop will also make sure that all instances are
|
|
167 instantiated so when we actually output them they will come up
|
|
168 immediately. */
|
|
169 while (!NILP (button))
|
|
170 {
|
|
171 struct toolbar_button *tb = XTOOLBAR_BUTTON (button);
|
278
|
172 checksum = HASH3 (checksum,
|
|
173 internal_hash (get_toolbar_button_glyph(w, tb), 0),
|
|
174 internal_hash (tb->callback, 0));
|
276
|
175 button = tb->next;
|
|
176 nbuttons++;
|
|
177 }
|
|
178
|
278
|
179 /* only rebuild if something has changed */
|
|
180 if (!toolbarwnd || FRAME_MSWINDOWS_TOOLBAR_CHECKSUM(f,pos)!=checksum)
|
276
|
181 {
|
278
|
182 /* remove the old one */
|
|
183 mswindows_clear_toolbar (f, pos, 0);
|
276
|
184
|
278
|
185 FRAME_MSWINDOWS_TOOLBAR_CHECKSUM(f,pos)=checksum;
|
276
|
186
|
278
|
187 /* build up the data required by win32 fns. */
|
|
188 button_tbl = xnew_array_and_zero (TBBUTTON, nbuttons);
|
|
189 button = FRAME_TOOLBAR_DATA (f, pos)->toolbar_buttons;
|
|
190 tbbutton = button_tbl;
|
276
|
191
|
278
|
192 while (!NILP (button))
|
|
193 {
|
|
194 struct toolbar_button *tb = XTOOLBAR_BUTTON (button);
|
|
195
|
|
196 tbbutton->idCommand = allocate_toolbar_item_id (f, tb, pos);
|
|
197 tbbutton->fsState=tb->enabled ? TBSTATE_ENABLED
|
|
198 : TBSTATE_INDETERMINATE;
|
|
199 tbbutton->fsStyle=tb->blank ? TBSTYLE_SEP : TBSTYLE_BUTTON;
|
|
200 tbbutton->dwData=0;
|
|
201 tbbutton->iString=0;
|
|
202
|
|
203 /* note that I am not doing the button size here. This is
|
|
204 because it is slightly out of my control and the main
|
|
205 place they are used is in redisplay for getting events
|
|
206 over toolbar buttons. Since the right way to do help echo
|
|
207 is with tooltips I'm not going to bother with the extra
|
|
208 work involved. */
|
|
209
|
|
210 /* mess with the button image */
|
|
211 glyph = get_toolbar_button_glyph (w, tb);
|
|
212
|
|
213 if (GLYPHP (glyph))
|
|
214 instance = glyph_image_instance (glyph, window, ERROR_ME_NOT, 1);
|
|
215 else
|
|
216 instance = Qnil;
|
|
217
|
|
218 if (IMAGE_INSTANCEP (instance))
|
276
|
219 {
|
278
|
220 struct Lisp_Image_Instance* p = XIMAGE_INSTANCE (instance);
|
276
|
221
|
278
|
222 if (IMAGE_INSTANCE_PIXMAP_TYPE_P (p))
|
276
|
223 {
|
278
|
224 /* we are going to honour the toolbar settings and
|
|
225 resize the bitmaps accordingly */
|
|
226
|
|
227 if (IMAGE_INSTANCE_PIXMAP_WIDTH (p) > bmwidth
|
|
228 ||
|
|
229 IMAGE_INSTANCE_PIXMAP_HEIGHT (p) > bmheight)
|
|
230 {
|
|
231 if (!mswindows_resize_dibitmap_instance
|
|
232 (p, f, bmwidth, bmheight))
|
|
233 {
|
|
234 xfree (button_tbl);
|
|
235 if (ilist) ImageList_Destroy (ilist);
|
|
236 signal_simple_error ("couldn't resize pixmap",
|
|
237 instance);
|
|
238 }
|
|
239 }
|
|
240 else
|
|
241 {
|
|
242 bmwidth = IMAGE_INSTANCE_PIXMAP_WIDTH (p);
|
|
243 bmheight = IMAGE_INSTANCE_PIXMAP_HEIGHT (p);
|
|
244 }
|
276
|
245
|
278
|
246 /* need to build an image list for the bitmaps */
|
|
247 if (!ilist)
|
|
248 {
|
|
249 if (!(ilist = ImageList_Create
|
|
250 ( IMAGE_INSTANCE_PIXMAP_WIDTH (p),
|
|
251 IMAGE_INSTANCE_PIXMAP_HEIGHT (p),
|
|
252 ILC_COLOR24,
|
|
253 nbuttons,
|
|
254 nbuttons * 2 )))
|
|
255 {
|
|
256 xfree (button_tbl);
|
|
257 signal_simple_error ("couldn't create image list",
|
|
258 instance);
|
|
259 }
|
|
260 }
|
|
261
|
|
262 /* add a bitmap to the list */
|
|
263 if ((tbbutton->iBitmap =
|
|
264 ImageList_Add (ilist,
|
|
265 IMAGE_INSTANCE_MSWINDOWS_BITMAP (p),
|
|
266 IMAGE_INSTANCE_MSWINDOWS_MASK (p))) < 0)
|
276
|
267 {
|
|
268 xfree (button_tbl);
|
278
|
269 if (ilist) ImageList_Destroy (ilist);
|
|
270 signal_simple_error ("image list creation failed",
|
276
|
271 instance);
|
|
272 }
|
|
273 }
|
|
274 }
|
278
|
275
|
|
276 Fputhash (make_int (tbbutton->idCommand),
|
|
277 button, FRAME_MSWINDOWS_TOOLBAR_HASHTABLE (f));
|
|
278
|
|
279 tbbutton++;
|
|
280 button = tb->next;
|
|
281 }
|
|
282
|
|
283 button = FRAME_TOOLBAR_DATA (f, pos)->toolbar_buttons;
|
|
284
|
|
285 /* create the toolbar window? */
|
|
286 if (!toolbarwnd
|
|
287 &&
|
|
288 (toolbarwnd =
|
|
289 CreateWindowEx ( WS_EX_WINDOWEDGE,
|
|
290 TOOLBARCLASSNAME,
|
|
291 NULL,
|
|
292 WS_CHILD | WS_VISIBLE | WS_DLGFRAME | TBSTYLE_TOOLTIPS
|
|
293 | CCS_NORESIZE | CCS_NOPARENTALIGN | CCS_NODIVIDER,
|
|
294 x, y, bar_width, bar_height,
|
|
295 FRAME_MSWINDOWS_HANDLE (f),
|
|
296 (HMENU)(TOOLBAR_ID_BIAS + pos),
|
|
297 NULL,
|
|
298 NULL))==NULL)
|
|
299 {
|
|
300 xfree (button_tbl);
|
|
301 ImageList_Destroy (ilist);
|
|
302 error ("couldn't create toolbar");
|
|
303 }
|
|
304 #if 0
|
|
305 SendMessage (toolbarwnd, TB_SETPADDING,
|
|
306 0, MAKELPARAM(border_width, border_width));
|
|
307 #endif
|
|
308 /* finally populate with images */
|
|
309 if (SendMessage (toolbarwnd, TB_BUTTONSTRUCTSIZE,
|
|
310 (WPARAM)sizeof(TBBUTTON), (LPARAM)0) == -1)
|
|
311 {
|
|
312 mswindows_clear_toolbar (f, pos, 0);
|
|
313 error ("couldn't set button structure size");
|
|
314 }
|
|
315
|
|
316 /* set the size of buttons */
|
|
317 SendMessage (toolbarwnd, TB_SETBUTTONSIZE, 0,
|
|
318 (LPARAM)MAKELONG (width, height));
|
|
319
|
|
320 /* set the size of bitmaps */
|
|
321 SendMessage (toolbarwnd, TB_SETBITMAPSIZE, 0,
|
|
322 (LPARAM)MAKELONG (bmwidth, bmheight));
|
|
323
|
|
324 /* finally populate with images */
|
|
325 if (!SendMessage (toolbarwnd, TB_ADDBUTTONS,
|
|
326 (WPARAM)nbuttons, (LPARAM)button_tbl))
|
|
327 {
|
|
328 mswindows_clear_toolbar (f, pos, 0);
|
|
329 error ("couldn't add button list to toolbar");
|
|
330 }
|
|
331
|
|
332 /* vertical toolbars need more rows */
|
|
333 if (vert)
|
|
334 {
|
|
335 SendMessage (toolbarwnd, TB_SETROWS,
|
|
336 MAKEWPARAM(nbuttons, FALSE), 0);
|
|
337 }
|
|
338
|
|
339 else
|
|
340 {
|
|
341 SendMessage (toolbarwnd, TB_SETROWS, MAKEWPARAM(1, FALSE), 0);
|
276
|
342 }
|
|
343
|
278
|
344 /* finally populate with images */
|
|
345 if (SendMessage (toolbarwnd, TB_SETIMAGELIST, 0,
|
|
346 (LPARAM)ilist) == -1)
|
|
347 {
|
|
348 mswindows_clear_toolbar (f, pos, 0);
|
|
349 error ("couldn't add image list to toolbar");
|
|
350 }
|
276
|
351
|
278
|
352 /* now display the window */
|
|
353 ShowWindow (toolbarwnd, SW_SHOW);
|
276
|
354
|
278
|
355 if (button_tbl) xfree (button_tbl);
|
|
356
|
|
357 SET_TOOLBAR_WAS_VISIBLE_FLAG (f, pos, 1);
|
|
358 }
|
|
359 }
|
|
360
|
|
361 static void
|
|
362 mswindows_move_toolbar (struct frame *f, enum toolbar_pos pos)
|
|
363 {
|
|
364 int bar_x, bar_y, bar_width, bar_height, vert;
|
|
365 HWND toolbarwnd = TOOLBAR_HANDLE(f,pos);
|
|
366
|
|
367 if (toolbarwnd)
|
276
|
368 {
|
278
|
369 get_toolbar_coords (f, pos, &bar_x, &bar_y, &bar_width, &bar_height,
|
|
370 &vert, 1);
|
276
|
371
|
278
|
372 /* #### This terrible mangling with coordinates perhaps
|
|
373 arises from different treatment of toolbar positions
|
|
374 by Windows and by XEmacs. */
|
|
375 switch (pos)
|
|
376 {
|
|
377 case TOP_TOOLBAR:
|
|
378 bar_x -= 2; bar_y--;
|
|
379 bar_width += 2; bar_height++;
|
|
380 break;
|
|
381 case LEFT_TOOLBAR:
|
|
382 bar_x -= 2; bar_y--;
|
|
383 bar_width++; bar_height++;
|
|
384 break;
|
|
385 case BOTTOM_TOOLBAR:
|
|
386 bar_x--;
|
|
387 bar_width++;
|
|
388 break;
|
|
389 case RIGHT_TOOLBAR:
|
|
390 bar_y--;
|
|
391 break;
|
|
392 }
|
|
393 SetWindowPos (toolbarwnd, NULL, bar_x, bar_y,
|
|
394 bar_width + 1, bar_height + 1, SWP_NOZORDER);
|
276
|
395 }
|
278
|
396 }
|
276
|
397
|
278
|
398 static void
|
|
399 mswindows_redraw_exposed_toolbars (struct frame *f, int x, int y, int width,
|
|
400 int height)
|
|
401 {
|
|
402 assert (FRAME_MSWINDOWS_P (f));
|
|
403
|
|
404 if (FRAME_REAL_TOP_TOOLBAR_VISIBLE (f))
|
|
405 mswindows_move_toolbar (f, TOP_TOOLBAR);
|
276
|
406
|
278
|
407 if (FRAME_REAL_BOTTOM_TOOLBAR_VISIBLE (f))
|
|
408 mswindows_move_toolbar (f, BOTTOM_TOOLBAR);
|
276
|
409
|
278
|
410 if (FRAME_REAL_LEFT_TOOLBAR_VISIBLE (f))
|
|
411 mswindows_move_toolbar (f, LEFT_TOOLBAR);
|
|
412
|
|
413 if (FRAME_REAL_RIGHT_TOOLBAR_VISIBLE (f))
|
|
414 mswindows_move_toolbar (f, RIGHT_TOOLBAR);
|
276
|
415 }
|
|
416
|
|
417 static void
|
|
418 mswindows_initialize_frame_toolbars (struct frame *f)
|
|
419 {
|
|
420
|
|
421 }
|
|
422
|
|
423 static void
|
|
424 mswindows_output_frame_toolbars (struct frame *f)
|
|
425 {
|
|
426 assert (FRAME_MSWINDOWS_P (f));
|
|
427
|
|
428 if (FRAME_REAL_TOP_TOOLBAR_VISIBLE (f))
|
|
429 mswindows_output_toolbar (f, TOP_TOOLBAR);
|
|
430 else if (f->top_toolbar_was_visible)
|
|
431 mswindows_clear_toolbar (f, TOP_TOOLBAR, 0);
|
|
432
|
|
433 if (FRAME_REAL_BOTTOM_TOOLBAR_VISIBLE (f))
|
|
434 mswindows_output_toolbar (f, BOTTOM_TOOLBAR);
|
|
435 else if (f->bottom_toolbar_was_visible)
|
|
436 mswindows_clear_toolbar (f, BOTTOM_TOOLBAR, 0);
|
|
437
|
|
438 if (FRAME_REAL_LEFT_TOOLBAR_VISIBLE (f))
|
|
439 mswindows_output_toolbar (f, LEFT_TOOLBAR);
|
|
440 else if (f->left_toolbar_was_visible)
|
|
441 mswindows_clear_toolbar (f, LEFT_TOOLBAR, 0);
|
|
442
|
|
443 if (FRAME_REAL_RIGHT_TOOLBAR_VISIBLE (f))
|
|
444 mswindows_output_toolbar (f, RIGHT_TOOLBAR);
|
|
445 else if (f->right_toolbar_was_visible)
|
|
446 mswindows_clear_toolbar (f, RIGHT_TOOLBAR, 0);
|
|
447 }
|
|
448
|
|
449 static void
|
|
450 mswindows_free_frame_toolbars (struct frame *f)
|
|
451 {
|
278
|
452 HWND twnd=NULL;
|
|
453 #define DELETE_TOOLBAR(pos) \
|
|
454 mswindows_clear_toolbar(f, 0, pos); \
|
|
455 if ((twnd=GetDlgItem(FRAME_MSWINDOWS_HANDLE(f), TOOLBAR_ID_BIAS + pos))) \
|
|
456 DestroyWindow(twnd)
|
|
457
|
|
458 DELETE_TOOLBAR(TOP_TOOLBAR);
|
|
459 DELETE_TOOLBAR(BOTTOM_TOOLBAR);
|
|
460 DELETE_TOOLBAR(LEFT_TOOLBAR);
|
|
461 DELETE_TOOLBAR(RIGHT_TOOLBAR);
|
|
462 #undef DELETE_TOOLBAR
|
|
463 }
|
|
464
|
|
465 /* map toolbar hwnd to pos*/
|
|
466 int mswindows_find_toolbar_pos(struct frame* f, HWND ctrl)
|
|
467 {
|
|
468 #if 1
|
|
469 int id = GetDlgCtrlID(ctrl);
|
|
470 return id ? id - TOOLBAR_ID_BIAS : -1;
|
|
471 #else
|
|
472 if (GetDlgItem(FRAME_MSWINDOWS_HANDLE(f), TOOLBAR_ID_BIAS) == ctrl)
|
|
473 return 0;
|
|
474 else if (GetDlgItem(FRAME_MSWINDOWS_HANDLE(f), TOOLBAR_ID_BIAS +1) == ctrl)
|
|
475 return 1;
|
|
476 else if (GetDlgItem(FRAME_MSWINDOWS_HANDLE(f), TOOLBAR_ID_BIAS +2) == ctrl)
|
|
477 return 2;
|
|
478 else if (GetDlgItem(FRAME_MSWINDOWS_HANDLE(f), TOOLBAR_ID_BIAS +3) == ctrl)
|
|
479 return 3;
|
|
480 else
|
|
481 assert(0);
|
|
482 #endif
|
|
483 }
|
|
484
|
|
485 Lisp_Object
|
|
486 mswindows_get_toolbar_button_text ( struct frame* f, int command_id )
|
|
487 {
|
|
488 Lisp_Object button = Fgethash (make_int (command_id),
|
|
489 FRAME_MSWINDOWS_TOOLBAR_HASHTABLE (f), Qnil);
|
|
490
|
|
491 if (!NILP (button))
|
|
492 {
|
|
493 struct toolbar_button *tb = XTOOLBAR_BUTTON (button);
|
|
494 return tb->help_string;
|
|
495 }
|
|
496 return Qnil;
|
276
|
497 }
|
|
498
|
|
499 /*
|
|
500 * Return value is Qt if we have dispatched the command,
|
|
501 * or Qnil if id has not been mapped to a callback.
|
|
502 * Window procedure may try other targets to route the
|
|
503 * command if we return nil
|
|
504 */
|
|
505 Lisp_Object
|
278
|
506 mswindows_handle_toolbar_wm_command (struct frame* f, HWND ctrl, WORD id)
|
276
|
507 {
|
|
508 /* Try to map the command id through the proper hash table */
|
278
|
509 Lisp_Object button, command, funcsym, frame;
|
276
|
510 struct gcpro gcpro1;
|
278
|
511
|
|
512 button = Fgethash (make_int (id),
|
|
513 FRAME_MSWINDOWS_TOOLBAR_HASHTABLE (f), Qnil);
|
276
|
514
|
278
|
515 if (NILP (button))
|
|
516 return Qnil;
|
276
|
517
|
278
|
518 command = XTOOLBAR_BUTTON(button)->callback;
|
|
519
|
|
520 if (UNBOUNDP(command))
|
|
521 return Qnil;
|
|
522
|
276
|
523 /* Need to gcpro because the hashtable may get destroyed
|
|
524 by menu_cleanup(), and will not gcpro the command
|
|
525 any more */
|
|
526 GCPRO1 (command);
|
|
527
|
|
528 /* Ok, this is our one. Enqueue it. */
|
|
529 if (SYMBOLP (command))
|
|
530 funcsym = Qcall_interactively;
|
|
531 else if (CONSP (command))
|
|
532 funcsym = Qeval;
|
|
533 else
|
|
534 signal_simple_error ("Callback must be either evallable form or a symbol",
|
|
535 command);
|
|
536
|
|
537 XSETFRAME (frame, f);
|
|
538 enqueue_misc_user_event (frame, funcsym, command);
|
|
539
|
|
540 /* Needs good bump also, for WM_COMMAND may have been dispatched from
|
|
541 mswindows_need_event, which will block again despite new command
|
|
542 event has arrived */
|
|
543 mswindows_bump_queue ();
|
|
544
|
|
545 UNGCPRO; /* command */
|
|
546 return Qt;
|
|
547 }
|
|
548
|
|
549
|
|
550 /************************************************************************/
|
|
551 /* initialization */
|
|
552 /************************************************************************/
|
|
553
|
|
554 void
|
|
555 console_type_create_toolbar_mswindows (void)
|
|
556 {
|
|
557 CONSOLE_HAS_METHOD (mswindows, output_frame_toolbars);
|
|
558 CONSOLE_HAS_METHOD (mswindows, initialize_frame_toolbars);
|
|
559 CONSOLE_HAS_METHOD (mswindows, free_frame_toolbars);
|
278
|
560 CONSOLE_HAS_METHOD (mswindows, redraw_exposed_toolbars);
|
276
|
561 }
|
|
562
|