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