428
|
1 /* toolbar implementation -- mswindows interface.
|
|
2 Copyright (C) 1995 Board of Trustees, University of Illinois.
|
|
3 Copyright (C) 1995 Sun Microsystems, Inc.
|
793
|
4 Copyright (C) 1995, 1996, 2002 Ben Wing.
|
428
|
5 Copyright (C) 1996 Chuck Thompson.
|
|
6 Copyright (C) 1998 Andy Piper.
|
|
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
|
771
|
30 /* This file essentially Mule-ized (except perhaps some Unicode splitting).
|
|
31 5-2000. (??? Needs a once-over.) */
|
|
32
|
|
33 #define NEED_MSWINDOWS_COMMCTRL
|
|
34
|
428
|
35 #include <config.h>
|
|
36 #include "lisp.h"
|
|
37
|
|
38 #include "faces.h"
|
|
39 #include "frame.h"
|
|
40 #include "toolbar.h"
|
|
41 #include "window.h"
|
|
42 #include "gui.h"
|
|
43 #include "elhash.h"
|
|
44 #include "console-msw.h"
|
|
45 #include "glyphs-msw.h"
|
|
46 #include "objects-msw.h"
|
|
47
|
|
48 #define TOOLBAR_ITEM_ID_MIN 0x4000
|
|
49 #define TOOLBAR_ITEM_ID_MAX 0x7FFF
|
|
50 #define TOOLBAR_ITEM_ID_BITS(x) (((x) & 0x3FFF) | 0x4000)
|
|
51 #define TOOLBAR_ID_BIAS 16
|
|
52 #define TOOLBAR_HANDLE(f,p) \
|
|
53 GetDlgItem(FRAME_MSWINDOWS_HANDLE(f), TOOLBAR_ID_BIAS + p)
|
442
|
54
|
428
|
55 #define MSWINDOWS_BUTTON_SHADOW_THICKNESS 2
|
|
56 #define MSWINDOWS_BLANK_SIZE 5
|
|
57 #define MSWINDOWS_MINIMUM_TOOLBAR_SIZE 8
|
|
58
|
|
59 static void
|
|
60 mswindows_move_toolbar (struct frame *f, enum toolbar_pos pos);
|
|
61
|
|
62 #define SET_TOOLBAR_WAS_VISIBLE_FLAG(frame, pos, flag) \
|
|
63 do { \
|
|
64 switch (pos) \
|
|
65 { \
|
|
66 case TOP_TOOLBAR: \
|
|
67 (frame)->top_toolbar_was_visible = flag; \
|
|
68 break; \
|
|
69 case BOTTOM_TOOLBAR: \
|
|
70 (frame)->bottom_toolbar_was_visible = flag; \
|
|
71 break; \
|
|
72 case LEFT_TOOLBAR: \
|
|
73 (frame)->left_toolbar_was_visible = flag; \
|
|
74 break; \
|
|
75 case RIGHT_TOOLBAR: \
|
|
76 (frame)->right_toolbar_was_visible = flag; \
|
|
77 break; \
|
|
78 default: \
|
|
79 abort (); \
|
|
80 } \
|
|
81 } while (0)
|
|
82
|
|
83 static int
|
771
|
84 allocate_toolbar_item_id (struct frame *f, struct toolbar_button *button,
|
428
|
85 enum toolbar_pos pos)
|
|
86 {
|
|
87 /* hmm what do we generate an id based on */
|
|
88 int id = TOOLBAR_ITEM_ID_BITS (internal_hash (button->callback, 0));
|
|
89 while (!NILP (Fgethash (make_int (id),
|
|
90 FRAME_MSWINDOWS_TOOLBAR_HASH_TABLE (f), Qnil)))
|
|
91 {
|
|
92 id = TOOLBAR_ITEM_ID_BITS (id + 1);
|
|
93 }
|
|
94 return id;
|
|
95 }
|
|
96
|
|
97 static void
|
|
98 mswindows_clear_toolbar (struct frame *f, enum toolbar_pos pos,
|
|
99 int thickness_change)
|
|
100 {
|
|
101 HIMAGELIST ilist=NULL;
|
|
102 int i;
|
|
103 HWND toolbarwnd = TOOLBAR_HANDLE(f, pos);
|
|
104 if (toolbarwnd)
|
|
105 {
|
|
106 TBBUTTON info;
|
|
107
|
771
|
108 /* Delete the buttons and remove the command from the hash table */
|
|
109 i = qxeSendMessage (toolbarwnd, TB_BUTTONCOUNT, 0, 0);
|
428
|
110 for (i--; i >= 0; i--)
|
|
111 {
|
771
|
112 qxeSendMessage (toolbarwnd, TB_GETBUTTON, (WPARAM)i,
|
428
|
113 (LPARAM)&info);
|
|
114 Fremhash(make_int(info.idCommand),
|
|
115 FRAME_MSWINDOWS_TOOLBAR_HASH_TABLE(f));
|
771
|
116 qxeSendMessage (toolbarwnd, TB_DELETEBUTTON, (WPARAM)i, 0);
|
428
|
117 }
|
|
118
|
|
119 /* finally get rid of the image list assuming it clears up its
|
|
120 bitmaps */
|
771
|
121 qxeSendMessage (toolbarwnd, TB_GETIMAGELIST, 0, (LONG) &ilist);
|
428
|
122 if (ilist)
|
|
123 {
|
|
124 ImageList_Destroy(ilist);
|
|
125 }
|
771
|
126 qxeSendMessage (toolbarwnd, TB_SETIMAGELIST, 0, (LPARAM)NULL);
|
428
|
127
|
|
128 ShowWindow(toolbarwnd, SW_HIDE);
|
|
129 }
|
|
130
|
442
|
131 FRAME_MSWINDOWS_TOOLBAR_CHECKSUM (f, pos) = 0;
|
428
|
132 SET_TOOLBAR_WAS_VISIBLE_FLAG (f, pos, 0);
|
|
133 }
|
|
134
|
|
135 static void
|
|
136 mswindows_output_toolbar (struct frame *f, enum toolbar_pos pos)
|
|
137 {
|
|
138 int x, y, bar_width, bar_height, vert;
|
|
139 int width=-1, height=-1, bmwidth=0, bmheight=0, maxbmwidth, maxbmheight;
|
|
140 int style_3d=0;
|
|
141 int border_width = FRAME_REAL_TOOLBAR_BORDER_WIDTH (f, pos);
|
|
142 Lisp_Object button, glyph, instance;
|
|
143 Lisp_Object window = FRAME_LAST_NONMINIBUF_WINDOW (f);
|
|
144
|
|
145 int nbuttons=0;
|
|
146 int shadow_thickness = 2; /* get this from somewhere else? */
|
|
147 int window_frame_width = 3;
|
|
148 int padding = (border_width + shadow_thickness) * 2;
|
|
149 unsigned int checksum=0;
|
|
150 struct window *w = XWINDOW (window);
|
771
|
151 TBBUTTON *button_tbl, *tbbutton;
|
428
|
152 HIMAGELIST ilist=NULL;
|
|
153 HWND toolbarwnd=NULL;
|
|
154
|
|
155 get_toolbar_coords (f, pos, &x, &y, &bar_width, &bar_height, &vert, 0);
|
|
156
|
|
157 /* ediff bogusly sets the height to 2 for some obscure X-specific
|
|
158 reason. This ensures that we only try and output a toolbar for
|
|
159 sensible sizes */
|
|
160 if (bar_width < MSWINDOWS_MINIMUM_TOOLBAR_SIZE
|
|
161 ||
|
|
162 bar_height < MSWINDOWS_MINIMUM_TOOLBAR_SIZE)
|
|
163 {
|
|
164 return;
|
|
165 }
|
|
166
|
|
167 if (x==1)
|
|
168 x=0;
|
|
169
|
|
170 toolbarwnd = TOOLBAR_HANDLE (f,pos);
|
|
171
|
|
172 /* set button sizes based on bar size */
|
|
173 if (vert)
|
|
174 {
|
|
175 if (style_3d)
|
|
176 {
|
|
177 width = height = bar_width
|
|
178 - (window_frame_width + shadow_thickness) * 2;
|
|
179 }
|
|
180 else
|
|
181 width = height = bar_width;
|
|
182
|
|
183 maxbmwidth = maxbmheight = width - padding;
|
|
184 }
|
|
185 else
|
|
186 {
|
|
187 if (style_3d)
|
|
188 {
|
|
189 height = width = bar_height
|
|
190 - (window_frame_width + shadow_thickness) * 2;
|
|
191 }
|
|
192 else
|
|
193 width = height = bar_height;
|
|
194
|
|
195 maxbmwidth = maxbmheight = width - padding;
|
|
196 }
|
|
197
|
|
198 button = FRAME_TOOLBAR_BUTTONS (f, pos);
|
|
199
|
|
200 /* First loop over all of the buttons to determine how many there
|
|
201 are. This loop will also make sure that all instances are
|
|
202 instantiated so when we actually output them they will come up
|
|
203 immediately. */
|
|
204 while (!NILP (button))
|
|
205 {
|
|
206
|
|
207 struct toolbar_button *tb = XTOOLBAR_BUTTON (button);
|
|
208 checksum = HASH5 (checksum,
|
|
209 internal_hash (get_toolbar_button_glyph(w, tb), 0),
|
|
210 internal_hash (tb->callback, 0),
|
|
211 width,
|
|
212 LISP_HASH (w->toolbar_buttons_captioned_p));
|
|
213 button = tb->next;
|
|
214 nbuttons++;
|
|
215 }
|
|
216
|
|
217 /* only rebuild if something has changed */
|
|
218 if (!toolbarwnd || FRAME_MSWINDOWS_TOOLBAR_CHECKSUM(f,pos)!=checksum)
|
|
219 {
|
|
220 /* remove the old one */
|
|
221 mswindows_clear_toolbar (f, pos, 0);
|
|
222
|
442
|
223 FRAME_MSWINDOWS_TOOLBAR_CHECKSUM (f, pos)=checksum;
|
428
|
224
|
|
225 /* build up the data required by win32 fns. */
|
|
226 button_tbl = xnew_array_and_zero (TBBUTTON, nbuttons);
|
|
227 button = FRAME_TOOLBAR_BUTTONS (f, pos);
|
|
228 tbbutton = button_tbl;
|
|
229
|
|
230 while (!NILP (button))
|
|
231 {
|
|
232 struct toolbar_button *tb = XTOOLBAR_BUTTON (button);
|
|
233 HBITMAP bitmap=NULL, mask=NULL;
|
|
234 bitmap=mask=NULL;
|
|
235
|
|
236 if (tb->blank)
|
|
237 tbbutton->fsStyle = TBSTYLE_SEP;
|
|
238 else
|
|
239 {
|
|
240 tbbutton->idCommand = allocate_toolbar_item_id (f, tb, pos);
|
|
241 /* currently we output the toolbar again with disabled
|
|
242 buttons it might be good to use the ms disabled code
|
|
243 instead but that means another image list, so we'll stick
|
|
244 with the emacs model. */
|
|
245 tbbutton->fsState = tb->enabled ? TBSTATE_ENABLED :
|
|
246 TBSTATE_INDETERMINATE;
|
|
247 tbbutton->fsStyle = TBSTYLE_BUTTON;
|
|
248 tbbutton->dwData=0;
|
|
249 tbbutton->iString=0;
|
|
250
|
|
251 /* mess with the button image */
|
|
252 glyph = get_toolbar_button_glyph (w, tb);
|
|
253
|
|
254 if (GLYPHP (glyph))
|
|
255 instance = glyph_image_instance (glyph, window,
|
793
|
256 ERROR_ME_DEBUG_WARN, 1);
|
428
|
257 else
|
|
258 instance = Qnil;
|
|
259
|
|
260 if (IMAGE_INSTANCEP (instance))
|
|
261 {
|
771
|
262 Lisp_Image_Instance *p = XIMAGE_INSTANCE (instance);
|
428
|
263
|
|
264 if (IMAGE_INSTANCE_PIXMAP_TYPE_P (p))
|
|
265 {
|
|
266 /* we are going to honor the toolbar settings
|
|
267 and resize the bitmaps accordingly if they are
|
|
268 too big. If they are too small we leave them
|
|
269 and pad the difference - unless a different size
|
|
270 crops up in the middle, at which point we *have*
|
771
|
271 to resize since the ImageList won't cope. */
|
428
|
272
|
|
273 if ((bmwidth
|
|
274 &&
|
|
275 IMAGE_INSTANCE_PIXMAP_WIDTH (p) != bmwidth)
|
|
276 ||
|
|
277 (bmheight
|
|
278 &&
|
|
279 IMAGE_INSTANCE_PIXMAP_HEIGHT (p) != bmheight)
|
|
280 ||
|
|
281 IMAGE_INSTANCE_PIXMAP_WIDTH (p) > maxbmwidth
|
|
282 ||
|
|
283 IMAGE_INSTANCE_PIXMAP_HEIGHT (p) > maxbmheight)
|
|
284 {
|
|
285 if (!bmheight)
|
|
286 bmheight = min (maxbmheight,
|
|
287 IMAGE_INSTANCE_PIXMAP_HEIGHT (p));
|
|
288 if (!bmwidth)
|
|
289 bmwidth = min (maxbmwidth,
|
|
290 IMAGE_INSTANCE_PIXMAP_WIDTH (p));
|
|
291
|
|
292 if (! (bitmap = mswindows_create_resized_bitmap
|
|
293 (p, f, bmwidth, bmheight)))
|
|
294 {
|
|
295 xfree (button_tbl);
|
|
296 if (ilist) ImageList_Destroy (ilist);
|
563
|
297 gui_error ("Couldn't resize pixmap", instance);
|
428
|
298 }
|
|
299 /* we don't care if the mask fails */
|
|
300 mask = mswindows_create_resized_mask
|
|
301 (p, f, bmwidth, bmheight);
|
|
302 }
|
|
303 else
|
|
304 {
|
|
305 if (!bmwidth)
|
|
306 bmwidth = IMAGE_INSTANCE_PIXMAP_WIDTH (p);
|
|
307 if (!bmheight)
|
|
308 bmheight = IMAGE_INSTANCE_PIXMAP_HEIGHT (p);
|
|
309 }
|
|
310
|
|
311 /* need to build an image list for the bitmaps */
|
|
312 if (!ilist && !(ilist = ImageList_Create
|
|
313 ( bmwidth, bmheight,
|
|
314 (IMAGE_INSTANCE_MSWINDOWS_MASK (p)
|
|
315 ? ILC_MASK : 0) | ILC_COLOR24,
|
|
316 nbuttons, nbuttons * 2 )))
|
|
317 {
|
|
318 xfree (button_tbl);
|
563
|
319 gui_error ("Couldn't create image list", instance);
|
428
|
320 }
|
|
321
|
|
322 /* make the mask actually do something */
|
|
323 ImageList_SetBkColor (ilist, CLR_NONE);
|
|
324 /* add a bitmap to the list */
|
|
325 if ((tbbutton->iBitmap =
|
|
326 ImageList_Add
|
|
327 (ilist,
|
|
328 bitmap ? bitmap
|
|
329 : IMAGE_INSTANCE_MSWINDOWS_BITMAP (p),
|
|
330 mask ? mask
|
|
331 : IMAGE_INSTANCE_MSWINDOWS_MASK (p))) < 0)
|
|
332 {
|
|
333 xfree (button_tbl);
|
771
|
334 if (ilist)
|
|
335 ImageList_Destroy (ilist);
|
563
|
336 gui_error
|
428
|
337 ("couldn't add image to image list", instance);
|
|
338 }
|
|
339 /* we're done with these now */
|
|
340 DeleteObject (bitmap);
|
|
341 DeleteObject (mask);
|
|
342 }
|
|
343 }
|
|
344
|
|
345 Fputhash (make_int (tbbutton->idCommand),
|
|
346 button, FRAME_MSWINDOWS_TOOLBAR_HASH_TABLE (f));
|
|
347 }
|
|
348
|
|
349 /* now fix up the button size */
|
|
350 tb->x = x;
|
|
351 tb->y = y;
|
|
352 tb->vertical = vert;
|
|
353 tb->border_width = border_width;
|
|
354 tb->width = width + MSWINDOWS_BUTTON_SHADOW_THICKNESS * 2;
|
|
355 tb->height = height + MSWINDOWS_BUTTON_SHADOW_THICKNESS * 2;
|
|
356
|
|
357 if (tb->blank)
|
|
358 {
|
|
359 if (vert)
|
|
360 tb->height = MSWINDOWS_BLANK_SIZE;
|
|
361 else
|
|
362 tb->width = MSWINDOWS_BLANK_SIZE;
|
|
363 }
|
|
364
|
|
365 if (vert)
|
|
366 y += tb->height;
|
|
367 else
|
|
368 x += tb->width;
|
|
369 /* move on to the next button */
|
|
370 tbbutton++;
|
|
371 button = tb->next;
|
|
372 }
|
|
373
|
|
374 button = FRAME_TOOLBAR_BUTTONS (f, pos);
|
|
375
|
|
376 /* create the toolbar window? */
|
|
377 if (!toolbarwnd
|
|
378 &&
|
|
379 (toolbarwnd =
|
771
|
380 qxeCreateWindowEx (WS_EX_WINDOWEDGE,
|
|
381 XETEXT (TOOLBARCLASSNAME),
|
|
382 NULL,
|
|
383 WS_CHILD
|
|
384 | (style_3d ? WS_DLGFRAME : 0)
|
|
385 | TBSTYLE_TOOLTIPS
|
|
386 | CCS_NORESIZE
|
|
387 | CCS_NOPARENTALIGN | CCS_NODIVIDER
|
|
388 | CCS_ADJUSTABLE,
|
|
389 x, y, bar_width, bar_height,
|
|
390 FRAME_MSWINDOWS_HANDLE (f),
|
|
391 (HMENU)(TOOLBAR_ID_BIAS + pos),
|
|
392 NULL,
|
|
393 NULL))==NULL)
|
428
|
394 {
|
|
395 xfree (button_tbl);
|
|
396 ImageList_Destroy (ilist);
|
563
|
397 gui_error ("couldn't create toolbar", Qunbound);
|
428
|
398 }
|
|
399
|
|
400 /* finally populate with images */
|
771
|
401 if (qxeSendMessage (toolbarwnd, TB_BUTTONSTRUCTSIZE,
|
|
402 (WPARAM)sizeof(TBBUTTON), (LPARAM)0) == -1)
|
428
|
403 {
|
|
404 mswindows_clear_toolbar (f, pos, 0);
|
563
|
405 gui_error ("couldn't set button structure size", Qunbound);
|
428
|
406 }
|
|
407
|
|
408 if (vert)
|
|
409 height = min (bmheight + padding, height);
|
|
410 else
|
|
411 width = min (bmwidth + padding, width);
|
|
412
|
|
413 /* pad the buttons */
|
771
|
414 qxeSendMessage (toolbarwnd, TB_SETPADDING,
|
|
415 0, MAKELPARAM (width - bmwidth, height - bmheight));
|
428
|
416
|
|
417 /* set the size of buttons */
|
771
|
418 qxeSendMessage (toolbarwnd, TB_SETBUTTONSIZE, 0,
|
|
419 (LPARAM) MAKELONG (width, height));
|
428
|
420
|
|
421 /* set the size of bitmaps */
|
771
|
422 qxeSendMessage (toolbarwnd, TB_SETBITMAPSIZE, 0,
|
|
423 (LPARAM) MAKELONG (bmwidth, bmheight));
|
428
|
424
|
|
425 /* tell it we've done it */
|
771
|
426 qxeSendMessage (toolbarwnd, TB_AUTOSIZE, 0, 0);
|
428
|
427
|
|
428 /* finally populate with images */
|
771
|
429 if (!qxeSendMessage (toolbarwnd, TB_ADDBUTTONS,
|
|
430 (WPARAM) nbuttons, (LPARAM) button_tbl))
|
428
|
431 {
|
|
432 mswindows_clear_toolbar (f, pos, 0);
|
563
|
433 gui_error ("couldn't add button list to toolbar", Qunbound);
|
428
|
434 }
|
|
435
|
|
436 /* vertical toolbars need more rows */
|
|
437 if (vert)
|
|
438 {
|
|
439 RECT tmp;
|
771
|
440 qxeSendMessage (toolbarwnd, TB_SETROWS,
|
|
441 MAKEWPARAM (nbuttons, FALSE), (LPARAM) &tmp);
|
428
|
442 }
|
|
443
|
|
444 else
|
|
445 {
|
|
446 RECT tmp;
|
771
|
447 qxeSendMessage (toolbarwnd, TB_SETROWS, MAKEWPARAM(1, FALSE),
|
|
448 (LPARAM)&tmp);
|
428
|
449 }
|
|
450
|
|
451 /* finally populate with images */
|
771
|
452 if (qxeSendMessage (toolbarwnd, TB_SETIMAGELIST, 0,
|
|
453 (LPARAM)ilist) < 0
|
428
|
454 ||
|
771
|
455 qxeSendMessage (toolbarwnd, TB_SETDISABLEDIMAGELIST, 0,
|
|
456 (LPARAM)ilist) < 0)
|
428
|
457 {
|
|
458 mswindows_clear_toolbar (f, pos, 0);
|
563
|
459 gui_error ("couldn't add image list to toolbar", Qunbound);
|
428
|
460 }
|
|
461
|
|
462 /* now display the window */
|
|
463 ShowWindow (toolbarwnd, SW_SHOW);
|
|
464 /* no idea why this is necessary but initial display will not
|
|
465 happen otherwise. */
|
|
466 mswindows_move_toolbar (f, pos);
|
|
467
|
|
468 if (button_tbl) xfree (button_tbl);
|
|
469
|
|
470 SET_TOOLBAR_WAS_VISIBLE_FLAG (f, pos, 1);
|
|
471 }
|
|
472 }
|
|
473
|
|
474 static void
|
|
475 mswindows_move_toolbar (struct frame *f, enum toolbar_pos pos)
|
|
476 {
|
|
477 int bar_x, bar_y, bar_width, bar_height, vert;
|
|
478 HWND toolbarwnd = TOOLBAR_HANDLE(f,pos);
|
|
479
|
|
480 if (toolbarwnd)
|
|
481 {
|
|
482 get_toolbar_coords (f, pos, &bar_x, &bar_y, &bar_width, &bar_height,
|
|
483 &vert, 1);
|
|
484
|
|
485 /* #### This terrible mangling with coordinates perhaps
|
|
486 arises from different treatment of toolbar positions
|
|
487 by Windows and by XEmacs. */
|
|
488 switch (pos)
|
|
489 {
|
|
490 case TOP_TOOLBAR:
|
|
491 bar_x--; bar_y-=2;
|
|
492 bar_width+=3; bar_height+=3;
|
|
493 break;
|
|
494 case LEFT_TOOLBAR:
|
|
495 bar_x--; bar_y-=2;
|
|
496 bar_height++; bar_width++;
|
|
497 break;
|
|
498 case BOTTOM_TOOLBAR:
|
|
499 bar_y-=2;
|
|
500 bar_width+=4; bar_height+=4;
|
|
501 break;
|
|
502 case RIGHT_TOOLBAR:
|
|
503 bar_y-=2; bar_x++;
|
|
504 bar_width++; bar_height++;
|
|
505 break;
|
|
506 }
|
|
507 SetWindowPos (toolbarwnd, NULL, bar_x, bar_y,
|
|
508 bar_width, bar_height, SWP_NOZORDER);
|
|
509 }
|
|
510 }
|
|
511
|
|
512 static void
|
|
513 mswindows_redraw_exposed_toolbars (struct frame *f, int x, int y, int width,
|
|
514 int height)
|
|
515 {
|
|
516 assert (FRAME_MSWINDOWS_P (f));
|
|
517
|
|
518 if (FRAME_REAL_TOP_TOOLBAR_VISIBLE (f))
|
|
519 mswindows_move_toolbar (f, TOP_TOOLBAR);
|
|
520
|
|
521 if (FRAME_REAL_BOTTOM_TOOLBAR_VISIBLE (f))
|
|
522 mswindows_move_toolbar (f, BOTTOM_TOOLBAR);
|
|
523
|
|
524 if (FRAME_REAL_LEFT_TOOLBAR_VISIBLE (f))
|
|
525 mswindows_move_toolbar (f, LEFT_TOOLBAR);
|
|
526
|
|
527 if (FRAME_REAL_RIGHT_TOOLBAR_VISIBLE (f))
|
|
528 mswindows_move_toolbar (f, RIGHT_TOOLBAR);
|
|
529 }
|
|
530
|
|
531 static void
|
|
532 mswindows_redraw_frame_toolbars (struct frame *f)
|
|
533 {
|
|
534 mswindows_redraw_exposed_toolbars (f, 0, 0, FRAME_PIXWIDTH (f),
|
|
535 FRAME_PIXHEIGHT (f));
|
|
536 }
|
|
537
|
|
538 static void
|
|
539 mswindows_initialize_frame_toolbars (struct frame *f)
|
|
540 {
|
|
541
|
|
542 }
|
|
543
|
|
544 static void
|
|
545 mswindows_output_frame_toolbars (struct frame *f)
|
|
546 {
|
|
547 assert (FRAME_MSWINDOWS_P (f));
|
|
548
|
|
549 if (FRAME_REAL_TOP_TOOLBAR_VISIBLE (f))
|
|
550 mswindows_output_toolbar (f, TOP_TOOLBAR);
|
|
551 else if (f->top_toolbar_was_visible)
|
|
552 mswindows_clear_toolbar (f, TOP_TOOLBAR, 0);
|
|
553
|
|
554 if (FRAME_REAL_BOTTOM_TOOLBAR_VISIBLE (f))
|
|
555 mswindows_output_toolbar (f, BOTTOM_TOOLBAR);
|
|
556 else if (f->bottom_toolbar_was_visible)
|
|
557 mswindows_clear_toolbar (f, BOTTOM_TOOLBAR, 0);
|
|
558
|
|
559 if (FRAME_REAL_LEFT_TOOLBAR_VISIBLE (f))
|
|
560 mswindows_output_toolbar (f, LEFT_TOOLBAR);
|
|
561 else if (f->left_toolbar_was_visible)
|
|
562 mswindows_clear_toolbar (f, LEFT_TOOLBAR, 0);
|
|
563
|
|
564 if (FRAME_REAL_RIGHT_TOOLBAR_VISIBLE (f))
|
|
565 mswindows_output_toolbar (f, RIGHT_TOOLBAR);
|
|
566 else if (f->right_toolbar_was_visible)
|
|
567 mswindows_clear_toolbar (f, RIGHT_TOOLBAR, 0);
|
|
568 }
|
|
569
|
|
570 static void
|
|
571 mswindows_free_frame_toolbars (struct frame *f)
|
|
572 {
|
|
573 HWND twnd=NULL;
|
442
|
574 #define DELETE_TOOLBAR(pos) \
|
|
575 mswindows_clear_toolbar(f, pos, 0); \
|
|
576 if ((twnd=GetDlgItem(FRAME_MSWINDOWS_HANDLE(f), \
|
|
577 TOOLBAR_ID_BIAS + pos))) \
|
428
|
578 DestroyWindow(twnd)
|
|
579
|
|
580 DELETE_TOOLBAR(TOP_TOOLBAR);
|
|
581 DELETE_TOOLBAR(BOTTOM_TOOLBAR);
|
|
582 DELETE_TOOLBAR(LEFT_TOOLBAR);
|
|
583 DELETE_TOOLBAR(RIGHT_TOOLBAR);
|
|
584 #undef DELETE_TOOLBAR
|
|
585 }
|
|
586
|
771
|
587 /* map toolbar hwnd to pos */
|
|
588 static int
|
|
589 mswindows_find_toolbar_pos (struct frame *f, HWND ctrl)
|
428
|
590 {
|
771
|
591 int id = GetDlgCtrlID (ctrl);
|
428
|
592 return id ? id - TOOLBAR_ID_BIAS : -1;
|
|
593 }
|
|
594
|
|
595 Lisp_Object
|
771
|
596 mswindows_get_toolbar_button_text (struct frame *f, int command_id)
|
428
|
597 {
|
|
598 Lisp_Object button = Fgethash (make_int (command_id),
|
|
599 FRAME_MSWINDOWS_TOOLBAR_HASH_TABLE (f), Qnil);
|
|
600
|
|
601 if (!NILP (button))
|
|
602 {
|
|
603 struct toolbar_button *tb = XTOOLBAR_BUTTON (button);
|
|
604 return tb->help_string;
|
|
605 }
|
|
606 return Qnil;
|
|
607 }
|
|
608
|
|
609 /*
|
|
610 * Return value is Qt if we have dispatched the command,
|
|
611 * or Qnil if id has not been mapped to a callback.
|
|
612 * Window procedure may try other targets to route the
|
|
613 * command if we return nil
|
|
614 */
|
|
615 Lisp_Object
|
771
|
616 mswindows_handle_toolbar_wm_command (struct frame *f, HWND ctrl, WORD id)
|
428
|
617 {
|
|
618 /* Try to map the command id through the proper hash table */
|
|
619 Lisp_Object button, data, fn, arg, frame;
|
|
620
|
|
621 button = Fgethash (make_int (id),
|
|
622 FRAME_MSWINDOWS_TOOLBAR_HASH_TABLE (f), Qnil);
|
|
623
|
|
624 if (NILP (button))
|
|
625 return Qnil;
|
|
626
|
|
627 data = XTOOLBAR_BUTTON (button)->callback;
|
|
628
|
|
629 /* #### ? */
|
|
630 if (UNBOUNDP (data))
|
|
631 return Qnil;
|
|
632
|
|
633 /* Ok, this is our one. Enqueue it. */
|
|
634 get_gui_callback (data, &fn, &arg);
|
793
|
635 frame = wrap_frame (f);
|
428
|
636 mswindows_enqueue_misc_user_event (frame, fn, arg);
|
|
637
|
|
638 return Qt;
|
|
639 }
|
|
640
|
|
641 /************************************************************************/
|
|
642 /* initialization */
|
|
643 /************************************************************************/
|
|
644
|
|
645 void
|
|
646 console_type_create_toolbar_mswindows (void)
|
|
647 {
|
|
648 CONSOLE_HAS_METHOD (mswindows, output_frame_toolbars);
|
|
649 CONSOLE_HAS_METHOD (mswindows, initialize_frame_toolbars);
|
|
650 CONSOLE_HAS_METHOD (mswindows, free_frame_toolbars);
|
|
651 CONSOLE_HAS_METHOD (mswindows, redraw_exposed_toolbars);
|
|
652 CONSOLE_HAS_METHOD (mswindows, redraw_frame_toolbars);
|
|
653 }
|
|
654
|