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