Mercurial > hg > xemacs-beta
annotate src/toolbar-msw.c @ 5934:e2fae7783046 cygwin
lots of use of EMACS_INT, a few others, to eliminate all pointer truncation warnings
author | Henry Thompson <ht@markup.co.uk> |
---|---|
date | Sat, 12 Dec 2015 19:08:46 +0000 |
parents | 68639fb08af8 |
children |
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)); |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
68 while (!NILP (Fgethash (make_fixnum (id), |
428 | 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); | |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
93 Fremhash (make_fixnum (info.idCommand), |
1130 | 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 */ | |
5921
68639fb08af8
no obvious 64 vs. 32 pblms in compilation, but still crashing in event-msw
Henry Thompson <ht@markup.co.uk>
parents:
5581
diff
changeset
|
100 qxeSendMessage (toolbarwnd, TB_GETIMAGELIST, 0, (intptr_t) &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; | |
5934
e2fae7783046
lots of use of EMACS_INT, a few others, to eliminate all pointer truncation warnings
Henry Thompson <ht@markup.co.uk>
parents:
5921
diff
changeset
|
128 uintptr_t checksum=0; |
428 | 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 | |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
324 Fputhash (make_fixnum (tbbutton->idCommand), |
428 | 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), | |
5921
68639fb08af8
no obvious 64 vs. 32 pblms in compilation, but still crashing in event-msw
Henry Thompson <ht@markup.co.uk>
parents:
5581
diff
changeset
|
370 /* odd param: pointer _or_ integer id . . . */ |
68639fb08af8
no obvious 64 vs. 32 pblms in compilation, but still crashing in event-msw
Henry Thompson <ht@markup.co.uk>
parents:
5581
diff
changeset
|
371 (HMENU)(intptr_t)(TOOLBAR_ID_BIAS + pos), |
771 | 372 NULL, |
373 NULL))==NULL) | |
428 | 374 { |
4976
16112448d484
Rename xfree(FOO, TYPE) -> xfree(FOO)
Ben Wing <ben@xemacs.org>
parents:
2500
diff
changeset
|
375 xfree (button_tbl); |
428 | 376 ImageList_Destroy (ilist); |
563 | 377 gui_error ("couldn't create toolbar", Qunbound); |
428 | 378 } |
379 | |
380 /* finally populate with images */ | |
771 | 381 if (qxeSendMessage (toolbarwnd, TB_BUTTONSTRUCTSIZE, |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
4976
diff
changeset
|
382 (WPARAM)sizeof (TBBUTTON), (LPARAM)0) == -1) |
428 | 383 { |
384 mswindows_clear_toolbar (f, pos, 0); | |
563 | 385 gui_error ("couldn't set button structure size", Qunbound); |
428 | 386 } |
387 | |
388 if (vert) | |
389 height = min (bmheight + padding, height); | |
390 else | |
391 width = min (bmwidth + padding, width); | |
392 | |
393 /* pad the buttons */ | |
771 | 394 qxeSendMessage (toolbarwnd, TB_SETPADDING, |
395 0, MAKELPARAM (width - bmwidth, height - bmheight)); | |
428 | 396 |
397 /* set the size of buttons */ | |
771 | 398 qxeSendMessage (toolbarwnd, TB_SETBUTTONSIZE, 0, |
399 (LPARAM) MAKELONG (width, height)); | |
428 | 400 |
401 /* set the size of bitmaps */ | |
771 | 402 qxeSendMessage (toolbarwnd, TB_SETBITMAPSIZE, 0, |
403 (LPARAM) MAKELONG (bmwidth, bmheight)); | |
428 | 404 |
405 /* tell it we've done it */ | |
771 | 406 qxeSendMessage (toolbarwnd, TB_AUTOSIZE, 0, 0); |
428 | 407 |
408 /* finally populate with images */ | |
771 | 409 if (!qxeSendMessage (toolbarwnd, TB_ADDBUTTONS, |
410 (WPARAM) nbuttons, (LPARAM) button_tbl)) | |
428 | 411 { |
412 mswindows_clear_toolbar (f, pos, 0); | |
563 | 413 gui_error ("couldn't add button list to toolbar", Qunbound); |
428 | 414 } |
415 | |
416 /* vertical toolbars need more rows */ | |
417 if (vert) | |
418 { | |
419 RECT tmp; | |
771 | 420 qxeSendMessage (toolbarwnd, TB_SETROWS, |
421 MAKEWPARAM (nbuttons, FALSE), (LPARAM) &tmp); | |
428 | 422 } |
423 | |
424 else | |
425 { | |
426 RECT tmp; | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
4976
diff
changeset
|
427 qxeSendMessage (toolbarwnd, TB_SETROWS, MAKEWPARAM (1, FALSE), |
771 | 428 (LPARAM)&tmp); |
428 | 429 } |
430 | |
431 /* finally populate with images */ | |
771 | 432 if (qxeSendMessage (toolbarwnd, TB_SETIMAGELIST, 0, |
433 (LPARAM)ilist) < 0 | |
428 | 434 || |
771 | 435 qxeSendMessage (toolbarwnd, TB_SETDISABLEDIMAGELIST, 0, |
436 (LPARAM)ilist) < 0) | |
428 | 437 { |
438 mswindows_clear_toolbar (f, pos, 0); | |
563 | 439 gui_error ("couldn't add image list to toolbar", Qunbound); |
428 | 440 } |
441 | |
442 /* now display the window */ | |
443 ShowWindow (toolbarwnd, SW_SHOW); | |
444 /* no idea why this is necessary but initial display will not | |
445 happen otherwise. */ | |
446 mswindows_move_toolbar (f, pos); | |
447 | |
1726 | 448 if (button_tbl) |
4976
16112448d484
Rename xfree(FOO, TYPE) -> xfree(FOO)
Ben Wing <ben@xemacs.org>
parents:
2500
diff
changeset
|
449 xfree (button_tbl); |
428 | 450 |
451 SET_TOOLBAR_WAS_VISIBLE_FLAG (f, pos, 1); | |
452 } | |
453 } | |
454 | |
455 static void | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
4976
diff
changeset
|
456 mswindows_move_toolbar (struct frame *f, enum edge_pos pos) |
428 | 457 { |
458 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
|
459 HWND toolbarwnd = TOOLBAR_HANDLE (f,pos); |
428 | 460 |
461 if (toolbarwnd) | |
462 { | |
463 get_toolbar_coords (f, pos, &bar_x, &bar_y, &bar_width, &bar_height, | |
464 &vert, 1); | |
465 | |
466 /* #### This terrible mangling with coordinates perhaps | |
467 arises from different treatment of toolbar positions | |
468 by Windows and by XEmacs. */ | |
469 switch (pos) | |
470 { | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
4976
diff
changeset
|
471 case TOP_EDGE: |
428 | 472 bar_x--; bar_y-=2; |
473 bar_width+=3; bar_height+=3; | |
474 break; | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
4976
diff
changeset
|
475 case LEFT_EDGE: |
428 | 476 bar_x--; bar_y-=2; |
477 bar_height++; bar_width++; | |
478 break; | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
4976
diff
changeset
|
479 case BOTTOM_EDGE: |
428 | 480 bar_y-=2; |
481 bar_width+=4; bar_height+=4; | |
482 break; | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
4976
diff
changeset
|
483 case RIGHT_EDGE: |
428 | 484 bar_y-=2; bar_x++; |
485 bar_width++; bar_height++; | |
486 break; | |
487 } | |
488 SetWindowPos (toolbarwnd, NULL, bar_x, bar_y, | |
489 bar_width, bar_height, SWP_NOZORDER); | |
490 } | |
491 } | |
492 | |
493 static void | |
2286 | 494 mswindows_redraw_exposed_toolbars (struct frame *f, |
495 int UNUSED (x), int UNUSED (y), | |
496 int UNUSED (width), int UNUSED (height)) | |
428 | 497 { |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
4976
diff
changeset
|
498 enum edge_pos pos; |
428 | 499 assert (FRAME_MSWINDOWS_P (f)); |
500 | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
4976
diff
changeset
|
501 EDGE_POS_LOOP (pos) |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
4976
diff
changeset
|
502 { |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
4976
diff
changeset
|
503 if (FRAME_REAL_TOOLBAR_VISIBLE (f, pos)) |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
4976
diff
changeset
|
504 mswindows_move_toolbar (f, pos); |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
4976
diff
changeset
|
505 } |
428 | 506 } |
507 | |
508 static void | |
509 mswindows_redraw_frame_toolbars (struct frame *f) | |
510 { | |
511 mswindows_redraw_exposed_toolbars (f, 0, 0, FRAME_PIXWIDTH (f), | |
512 FRAME_PIXHEIGHT (f)); | |
513 } | |
514 | |
515 static void | |
2286 | 516 mswindows_initialize_frame_toolbars (struct frame *UNUSED (f)) |
428 | 517 { |
518 } | |
519 | |
520 static void | |
521 mswindows_output_frame_toolbars (struct frame *f) | |
522 { | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
4976
diff
changeset
|
523 enum edge_pos pos; |
428 | 524 assert (FRAME_MSWINDOWS_P (f)); |
525 | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
4976
diff
changeset
|
526 EDGE_POS_LOOP (pos) |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
4976
diff
changeset
|
527 { |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
4976
diff
changeset
|
528 if (FRAME_REAL_TOOLBAR_VISIBLE (f, pos)) |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
4976
diff
changeset
|
529 mswindows_output_toolbar (f, pos); |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
4976
diff
changeset
|
530 } |
905 | 531 } |
532 | |
533 static void | |
534 mswindows_clear_frame_toolbars (struct frame *f) | |
535 { | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
4976
diff
changeset
|
536 enum edge_pos pos; |
905 | 537 assert (FRAME_MSWINDOWS_P (f)); |
538 | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
4976
diff
changeset
|
539 EDGE_POS_LOOP (pos) |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
4976
diff
changeset
|
540 { |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
4976
diff
changeset
|
541 if (f->toolbar_was_visible[pos] |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
4976
diff
changeset
|
542 && !FRAME_REAL_TOOLBAR_VISIBLE (f, pos)) |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
4976
diff
changeset
|
543 mswindows_clear_toolbar (f, pos, 0); |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
4976
diff
changeset
|
544 } |
428 | 545 } |
546 | |
547 static void | |
548 mswindows_free_frame_toolbars (struct frame *f) | |
549 { | |
550 HWND twnd=NULL; | |
442 | 551 #define DELETE_TOOLBAR(pos) \ |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
4976
diff
changeset
|
552 mswindows_clear_toolbar (f, pos, 0); \ |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
4976
diff
changeset
|
553 if ((twnd=GetDlgItem (FRAME_MSWINDOWS_HANDLE (f), \ |
442 | 554 TOOLBAR_ID_BIAS + pos))) \ |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
4976
diff
changeset
|
555 DestroyWindow (twnd) |
428 | 556 |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
4976
diff
changeset
|
557 DELETE_TOOLBAR (TOP_EDGE); |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
4976
diff
changeset
|
558 DELETE_TOOLBAR (BOTTOM_EDGE); |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
4976
diff
changeset
|
559 DELETE_TOOLBAR (LEFT_EDGE); |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
4976
diff
changeset
|
560 DELETE_TOOLBAR (RIGHT_EDGE); |
428 | 561 #undef DELETE_TOOLBAR |
562 } | |
563 | |
564 Lisp_Object | |
771 | 565 mswindows_get_toolbar_button_text (struct frame *f, int command_id) |
428 | 566 { |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
567 Lisp_Object button = Fgethash (make_fixnum (command_id), |
428 | 568 FRAME_MSWINDOWS_TOOLBAR_HASH_TABLE (f), Qnil); |
569 | |
570 if (!NILP (button)) | |
571 { | |
572 struct toolbar_button *tb = XTOOLBAR_BUTTON (button); | |
573 return tb->help_string; | |
574 } | |
575 return Qnil; | |
576 } | |
577 | |
578 /* | |
579 * Return value is Qt if we have dispatched the command, | |
580 * or Qnil if id has not been mapped to a callback. | |
581 * Window procedure may try other targets to route the | |
582 * command if we return nil | |
583 */ | |
584 Lisp_Object | |
2286 | 585 mswindows_handle_toolbar_wm_command (struct frame *f, HWND UNUSED (ctrl), |
586 WORD id) | |
428 | 587 { |
588 /* Try to map the command id through the proper hash table */ | |
589 Lisp_Object button, data, fn, arg, frame; | |
590 | |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
591 button = Fgethash (make_fixnum (id), |
428 | 592 FRAME_MSWINDOWS_TOOLBAR_HASH_TABLE (f), Qnil); |
593 | |
594 if (NILP (button)) | |
595 return Qnil; | |
596 | |
597 data = XTOOLBAR_BUTTON (button)->callback; | |
598 | |
599 /* #### ? */ | |
600 if (UNBOUNDP (data)) | |
601 return Qnil; | |
602 | |
603 /* Ok, this is our one. Enqueue it. */ | |
604 get_gui_callback (data, &fn, &arg); | |
793 | 605 frame = wrap_frame (f); |
428 | 606 mswindows_enqueue_misc_user_event (frame, fn, arg); |
607 | |
608 return Qt; | |
609 } | |
610 | |
611 /************************************************************************/ | |
612 /* initialization */ | |
613 /************************************************************************/ | |
614 | |
615 void | |
616 console_type_create_toolbar_mswindows (void) | |
617 { | |
618 CONSOLE_HAS_METHOD (mswindows, output_frame_toolbars); | |
905 | 619 CONSOLE_HAS_METHOD (mswindows, clear_frame_toolbars); |
428 | 620 CONSOLE_HAS_METHOD (mswindows, initialize_frame_toolbars); |
621 CONSOLE_HAS_METHOD (mswindows, free_frame_toolbars); | |
622 CONSOLE_HAS_METHOD (mswindows, redraw_exposed_toolbars); | |
623 CONSOLE_HAS_METHOD (mswindows, redraw_frame_toolbars); | |
624 } | |
625 |