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