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