Mercurial > hg > xemacs-beta
annotate src/toolbar-msw.c @ 5176:8b2f75cecb89
rename objects* (.c, .h and .el files) to fontcolor*
-------------------- ChangeLog entries follow: --------------------
etc/ChangeLog addition:
2010-02-22 Ben Wing <ben@xemacs.org>
* dbxrc.in:
Rename objects.c -> fontcolor.c.
lisp/ChangeLog addition:
2010-02-22 Ben Wing <ben@xemacs.org>
* dumped-lisp.el (preloaded-file-list):
* font.el (font-tty-find-closest-color):
* fontcolor.el:
* fontcolor.el (ws-object-property-1): Removed.
* fontcolor.el (fontcolor-property-1): New.
* fontcolor.el (font-name):
* fontcolor.el (font-ascent):
* fontcolor.el (font-descent):
* fontcolor.el (font-width):
* fontcolor.el (font-height):
* fontcolor.el (font-proportional-p):
* fontcolor.el (font-properties):
* fontcolor.el (font-truename):
* fontcolor.el (color-name):
* fontcolor.el (color-rgb-components):
* x-faces.el:
Rename objects.el -> fontcolor.el.
lwlib/ChangeLog addition:
2010-02-22 Ben Wing <ben@xemacs.org>
* lwlib-colors.h:
objects*.h -> fontcolor*.h.
man/ChangeLog addition:
2010-02-22 Ben Wing <ben@xemacs.org>
* internals/internals.texi (A Summary of the Various XEmacs Modules):
* internals/internals.texi (Modules for other Display-Related Lisp Objects):
objects*.[ch] -> fontcolor*.[ch].
nt/ChangeLog addition:
2010-02-22 Ben Wing <ben@xemacs.org>
* xemacs.dsp:
* xemacs.mak:
* xemacs.mak (OPT_OBJS):
objects*.[ch] -> fontcolor*.[ch].
src/ChangeLog addition:
2010-02-22 Ben Wing <ben@xemacs.org>
* EmacsFrame.c:
* Makefile.in.in (x_objs):
* Makefile.in.in (mswindows_objs):
* Makefile.in.in (tty_objs):
* Makefile.in.in (gtk_objs):
* Makefile.in.in (objs):
* console-tty.h:
* console-x-impl.h:
* console-x-impl.h (struct x_device):
* console-x.h:
* console-xlike-inc.h:
* depend:
* device-gtk.c:
* device-msw.c:
* device-x.c:
* device-x.c (x_init_device):
* device-x.c (x_finish_init_device):
* device.c:
* devslots.h (MARKED_SLOT):
* emacs.c (main_1):
* event-Xt.c:
* event-gtk.c:
* event-msw.c:
* faces.c:
* font-mgr.c:
* fontcolor-gtk-impl.h:
* fontcolor-gtk.c:
* fontcolor-gtk.c (syms_of_fontcolor_gtk):
* fontcolor-gtk.c (console_type_create_fontcolor_gtk):
* fontcolor-gtk.c (vars_of_fontcolor_gtk):
* fontcolor-gtk.h:
* fontcolor-impl.h:
* fontcolor-msw-impl.h:
* fontcolor-msw.c:
* fontcolor-msw.c (syms_of_fontcolor_mswindows):
* fontcolor-msw.c (console_type_create_fontcolor_mswindows):
* fontcolor-msw.c (reinit_vars_of_fontcolor_mswindows):
* fontcolor-msw.c (vars_of_fontcolor_mswindows):
* fontcolor-msw.h:
* fontcolor-msw.h (mswindows_color_to_string):
* fontcolor-tty-impl.h:
* fontcolor-tty.c:
* fontcolor-tty.c (syms_of_fontcolor_tty):
* fontcolor-tty.c (console_type_create_fontcolor_tty):
* fontcolor-tty.c (vars_of_fontcolor_tty):
* fontcolor-tty.h:
* fontcolor-x-impl.h:
* fontcolor-x.c:
* fontcolor-x.c (syms_of_fontcolor_x):
* fontcolor-x.c (console_type_create_fontcolor_x):
* fontcolor-x.c (vars_of_fontcolor_x):
* fontcolor-x.c (Xatoms_of_fontcolor_x):
* fontcolor-x.h:
* fontcolor.c:
* fontcolor.c (syms_of_fontcolor):
* fontcolor.c (specifier_type_create_fontcolor):
* fontcolor.c (reinit_specifier_type_create_fontcolor):
* fontcolor.c (reinit_vars_of_fontcolor):
* fontcolor.c (vars_of_fontcolor):
* fontcolor.h:
* fontcolor.h (set_face_boolean_attached_to):
* frame-gtk.c:
* frame-x.c:
* glyphs-eimage.c:
* glyphs-gtk.c:
* glyphs-msw.c:
* glyphs-widget.c:
* glyphs-x.c:
* glyphs.c:
* gtk-glue.c:
* gtk-glue.c (xemacs_type_register):
* gtk-xemacs.c:
* inline.c:
* intl-win32.c:
* lisp.h:
* lrecord.h:
* mule-charset.c:
* native-gtk-toolbar.c:
* redisplay-msw.c:
* redisplay-tty.c:
* redisplay.c:
* select-x.c:
* select.c:
* symsinit.h:
* toolbar-msw.c:
* toolbar-msw.c (TOOLBAR_ITEM_ID_BITS):
* toolbar-x.c:
* ui-gtk.c:
* window.c:
Rename objects*.[ch] -> fontcolor*.[ch]. Fix up all references to
the old files (e.g. in #include statements, Makefiles,
functions like syms_of_objects_x(), etc.).
tests/ChangeLog addition:
2010-02-22 Ben Wing <ben@xemacs.org>
* reproduce-crashes.el (8):
objects*.[ch] -> fontcolor*.[ch].
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Mon, 22 Feb 2010 06:49:30 -0600 |
parents | 16112448d484 |
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. | |
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" |
5176
8b2f75cecb89
rename objects* (.c, .h and .el files) to fontcolor*
Ben Wing <ben@xemacs.org>
parents:
4976
diff
changeset
|
48 /* #include "fontcolor-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 |