Mercurial > hg > xemacs-beta
annotate src/toolbar-msw.c @ 5043:d0c14ea98592
various frame-geometry fixes
-------------------- ChangeLog entries follow: --------------------
src/ChangeLog addition:
2010-02-15 Ben Wing <ben@xemacs.org>
* EmacsFrame.c:
* EmacsFrame.c (EmacsFrameResize):
* console-msw-impl.h:
* console-msw-impl.h (struct mswindows_frame):
* console-msw-impl.h (FRAME_MSWINDOWS_TARGET_RECT):
* device-tty.c:
* device-tty.c (tty_asynch_device_change):
* event-msw.c:
* event-msw.c (mswindows_wnd_proc):
* faces.c (Fface_list):
* faces.h:
* frame-gtk.c:
* frame-gtk.c (gtk_set_initial_frame_size):
* frame-gtk.c (gtk_set_frame_size):
* frame-msw.c:
* frame-msw.c (mswindows_init_frame_1):
* frame-msw.c (mswindows_set_frame_size):
* frame-msw.c (mswindows_size_frame_internal):
* frame-msw.c (msprinter_init_frame_3):
* frame.c:
* frame.c (enum):
* frame.c (Fmake_frame):
* frame.c (adjust_frame_size):
* frame.c (store_minibuf_frame_prop):
* frame.c (Fframe_property):
* frame.c (Fframe_properties):
* frame.c (Fframe_displayable_pixel_height):
* frame.c (Fframe_displayable_pixel_width):
* frame.c (internal_set_frame_size):
* frame.c (Fset_frame_height):
* frame.c (Fset_frame_pixel_height):
* frame.c (Fset_frame_displayable_pixel_height):
* frame.c (Fset_frame_width):
* frame.c (Fset_frame_pixel_width):
* frame.c (Fset_frame_displayable_pixel_width):
* frame.c (Fset_frame_size):
* frame.c (Fset_frame_pixel_size):
* frame.c (Fset_frame_displayable_pixel_size):
* frame.c (frame_conversion_internal_1):
* frame.c (get_frame_displayable_pixel_size):
* frame.c (change_frame_size_1):
* frame.c (change_frame_size):
* frame.c (generate_title_string):
* frame.h:
* gtk-xemacs.c:
* gtk-xemacs.c (gtk_xemacs_size_request):
* gtk-xemacs.c (gtk_xemacs_size_allocate):
* gtk-xemacs.c (gtk_xemacs_paint):
* gutter.c:
* gutter.c (update_gutter_geometry):
* redisplay.c (end_hold_frame_size_changes):
* redisplay.c (redisplay_frame):
* toolbar.c:
* toolbar.c (update_frame_toolbars_geometry):
* window.c:
* window.c (frame_pixsize_valid_p):
* window.c (check_frame_size):
Various fixes to frame geometry to make it a bit easier to understand
and fix some bugs.
1. IMPORTANT: Some renamings. Will need to be applied carefully to
the carbon repository, in the following order:
-- pixel_to_char_size -> pixel_to_frame_unit_size
-- char_to_pixel_size -> frame_unit_to_pixel_size
-- pixel_to_real_char_size -> pixel_to_char_size
-- char_to_real_pixel_size -> char_to_pixel_size
-- Reverse second and third arguments of change_frame_size() and
change_frame_size_1() to try to make functions consistent in
putting width before height.
-- Eliminate old round_size_to_char, because it didn't really
do anything differently from round_size_to_real_char()
-- round_size_to_real_char -> round_size_to_char; any places that
called the old round_size_to_char should just call the new one.
2. IMPORTANT FOR CARBON: The set_frame_size() method is now passed
sizes in "frame units", like all other frame-sizing functions,
rather than some hacked-up combination of char-cell units and
total pixel size. This only affects window systems that use
"pixelated geometry", and I'm not sure if Carbon is one of them.
MS Windows is pixelated, X and GTK are not. For pixelated-geometry
systems, the size in set_frame_size() is in displayable pixels
rather than total pixels and needs to be converted appropriately;
take a look at the changes made to mswindows_set_frame_size()
method if necessary.
3. Add a big long comment in frame.c describing how frame geometry
works.
4. Remove MS Windows-specific character height and width fields,
duplicative and unused.
5. frame-displayable-pixel-* and set-frame-displayable-pixel-*
didn't use to work on MS Windows, but they do now.
6. In general, clean up the handling of "pixelated geometry" so
that fewer functions have to worry about this. This is really
an abomination that should be removed entirely but that will
have to happen later. Fix some buggy code in
frame_conversion_internal() that happened to "work" because it
was countered by oppositely buggy code in change_frame_size().
7. Clean up some frame-size code in toolbar.c and use functions
already provided in frame.c instead of rolling its own.
8. Fix check_frame_size() in window.c, which formerly didn't take
pixelated geometry into account.
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Mon, 15 Feb 2010 22:14:11 -0600 |
parents | 16112448d484 |
children | d372b17f63ce 8b2f75cecb89 |
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. | |
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: \ | |
2500 | 81 ABORT (); \ |
428 | 82 } \ |
83 } while (0) | |
84 | |
85 static int | |
771 | 86 allocate_toolbar_item_id (struct frame *f, struct toolbar_button *button, |
2286 | 87 enum toolbar_pos UNUSED (pos)) |
428 | 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, | |
2286 | 101 int UNUSED (thickness_change)) |
428 | 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 { | |
4976
16112448d484
Rename xfree(FOO, TYPE) -> xfree(FOO)
Ben Wing <ben@xemacs.org>
parents:
2500
diff
changeset
|
297 xfree (button_tbl); |
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 { | |
4976
16112448d484
Rename xfree(FOO, TYPE) -> xfree(FOO)
Ben Wing <ben@xemacs.org>
parents:
2500
diff
changeset
|
320 xfree (button_tbl); |
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 { | |
4976
16112448d484
Rename xfree(FOO, TYPE) -> xfree(FOO)
Ben Wing <ben@xemacs.org>
parents:
2500
diff
changeset
|
335 xfree (button_tbl); |
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 { |
4976
16112448d484
Rename xfree(FOO, TYPE) -> xfree(FOO)
Ben Wing <ben@xemacs.org>
parents:
2500
diff
changeset
|
397 xfree (button_tbl); |
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) |
4976
16112448d484
Rename xfree(FOO, TYPE) -> xfree(FOO)
Ben Wing <ben@xemacs.org>
parents:
2500
diff
changeset
|
471 xfree (button_tbl); |
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 | |
2286 | 516 mswindows_redraw_exposed_toolbars (struct frame *f, |
517 int UNUSED (x), int UNUSED (y), | |
518 int UNUSED (width), int UNUSED (height)) | |
428 | 519 { |
520 assert (FRAME_MSWINDOWS_P (f)); | |
521 | |
522 if (FRAME_REAL_TOP_TOOLBAR_VISIBLE (f)) | |
523 mswindows_move_toolbar (f, TOP_TOOLBAR); | |
524 | |
525 if (FRAME_REAL_BOTTOM_TOOLBAR_VISIBLE (f)) | |
526 mswindows_move_toolbar (f, BOTTOM_TOOLBAR); | |
527 | |
528 if (FRAME_REAL_LEFT_TOOLBAR_VISIBLE (f)) | |
529 mswindows_move_toolbar (f, LEFT_TOOLBAR); | |
530 | |
531 if (FRAME_REAL_RIGHT_TOOLBAR_VISIBLE (f)) | |
532 mswindows_move_toolbar (f, RIGHT_TOOLBAR); | |
533 } | |
534 | |
535 static void | |
536 mswindows_redraw_frame_toolbars (struct frame *f) | |
537 { | |
538 mswindows_redraw_exposed_toolbars (f, 0, 0, FRAME_PIXWIDTH (f), | |
539 FRAME_PIXHEIGHT (f)); | |
540 } | |
541 | |
542 static void | |
2286 | 543 mswindows_initialize_frame_toolbars (struct frame *UNUSED (f)) |
428 | 544 { |
545 | |
546 } | |
547 | |
548 static void | |
549 mswindows_output_frame_toolbars (struct frame *f) | |
550 { | |
551 assert (FRAME_MSWINDOWS_P (f)); | |
552 | |
553 if (FRAME_REAL_TOP_TOOLBAR_VISIBLE (f)) | |
554 mswindows_output_toolbar (f, TOP_TOOLBAR); | |
555 if (FRAME_REAL_BOTTOM_TOOLBAR_VISIBLE (f)) | |
556 mswindows_output_toolbar (f, BOTTOM_TOOLBAR); | |
557 if (FRAME_REAL_LEFT_TOOLBAR_VISIBLE (f)) | |
558 mswindows_output_toolbar (f, LEFT_TOOLBAR); | |
559 if (FRAME_REAL_RIGHT_TOOLBAR_VISIBLE (f)) | |
560 mswindows_output_toolbar (f, RIGHT_TOOLBAR); | |
905 | 561 } |
562 | |
563 static void | |
564 mswindows_clear_frame_toolbars (struct frame *f) | |
565 { | |
566 assert (FRAME_MSWINDOWS_P (f)); | |
567 | |
568 if (f->top_toolbar_was_visible | |
569 && !FRAME_REAL_TOP_TOOLBAR_VISIBLE (f)) | |
570 mswindows_clear_toolbar (f, TOP_TOOLBAR, 0); | |
571 if (f->bottom_toolbar_was_visible | |
572 && !FRAME_REAL_BOTTOM_TOOLBAR_VISIBLE (f)) | |
573 mswindows_clear_toolbar (f, BOTTOM_TOOLBAR, 0); | |
574 if (f->left_toolbar_was_visible | |
575 && !FRAME_REAL_LEFT_TOOLBAR_VISIBLE (f)) | |
576 mswindows_clear_toolbar (f, LEFT_TOOLBAR, 0); | |
577 if (f->right_toolbar_was_visible | |
578 && !FRAME_REAL_RIGHT_TOOLBAR_VISIBLE (f)) | |
428 | 579 mswindows_clear_toolbar (f, RIGHT_TOOLBAR, 0); |
580 } | |
581 | |
582 static void | |
583 mswindows_free_frame_toolbars (struct frame *f) | |
584 { | |
585 HWND twnd=NULL; | |
442 | 586 #define DELETE_TOOLBAR(pos) \ |
587 mswindows_clear_toolbar(f, pos, 0); \ | |
588 if ((twnd=GetDlgItem(FRAME_MSWINDOWS_HANDLE(f), \ | |
589 TOOLBAR_ID_BIAS + pos))) \ | |
428 | 590 DestroyWindow(twnd) |
591 | |
592 DELETE_TOOLBAR(TOP_TOOLBAR); | |
593 DELETE_TOOLBAR(BOTTOM_TOOLBAR); | |
594 DELETE_TOOLBAR(LEFT_TOOLBAR); | |
595 DELETE_TOOLBAR(RIGHT_TOOLBAR); | |
596 #undef DELETE_TOOLBAR | |
597 } | |
598 | |
599 Lisp_Object | |
771 | 600 mswindows_get_toolbar_button_text (struct frame *f, int command_id) |
428 | 601 { |
602 Lisp_Object button = Fgethash (make_int (command_id), | |
603 FRAME_MSWINDOWS_TOOLBAR_HASH_TABLE (f), Qnil); | |
604 | |
605 if (!NILP (button)) | |
606 { | |
607 struct toolbar_button *tb = XTOOLBAR_BUTTON (button); | |
608 return tb->help_string; | |
609 } | |
610 return Qnil; | |
611 } | |
612 | |
613 /* | |
614 * Return value is Qt if we have dispatched the command, | |
615 * or Qnil if id has not been mapped to a callback. | |
616 * Window procedure may try other targets to route the | |
617 * command if we return nil | |
618 */ | |
619 Lisp_Object | |
2286 | 620 mswindows_handle_toolbar_wm_command (struct frame *f, HWND UNUSED (ctrl), |
621 WORD id) | |
428 | 622 { |
623 /* Try to map the command id through the proper hash table */ | |
624 Lisp_Object button, data, fn, arg, frame; | |
625 | |
626 button = Fgethash (make_int (id), | |
627 FRAME_MSWINDOWS_TOOLBAR_HASH_TABLE (f), Qnil); | |
628 | |
629 if (NILP (button)) | |
630 return Qnil; | |
631 | |
632 data = XTOOLBAR_BUTTON (button)->callback; | |
633 | |
634 /* #### ? */ | |
635 if (UNBOUNDP (data)) | |
636 return Qnil; | |
637 | |
638 /* Ok, this is our one. Enqueue it. */ | |
639 get_gui_callback (data, &fn, &arg); | |
793 | 640 frame = wrap_frame (f); |
428 | 641 mswindows_enqueue_misc_user_event (frame, fn, arg); |
642 | |
643 return Qt; | |
644 } | |
645 | |
646 /************************************************************************/ | |
647 /* initialization */ | |
648 /************************************************************************/ | |
649 | |
650 void | |
651 console_type_create_toolbar_mswindows (void) | |
652 { | |
653 CONSOLE_HAS_METHOD (mswindows, output_frame_toolbars); | |
905 | 654 CONSOLE_HAS_METHOD (mswindows, clear_frame_toolbars); |
428 | 655 CONSOLE_HAS_METHOD (mswindows, initialize_frame_toolbars); |
656 CONSOLE_HAS_METHOD (mswindows, free_frame_toolbars); | |
657 CONSOLE_HAS_METHOD (mswindows, redraw_exposed_toolbars); | |
658 CONSOLE_HAS_METHOD (mswindows, redraw_frame_toolbars); | |
659 } | |
660 |