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