713
|
1 /* toolbar implementation -- Generic redisplay interface.
|
|
2 Copyright (C) 1995 Board of Trustees, University of Illinois.
|
|
3 Copyright (C) 1995 Sun Microsystems, Inc.
|
|
4 Copyright (C) 1995, 1996 Ben Wing.
|
|
5 Copyright (C) 1996 Chuck Thompson.
|
|
6
|
|
7 This file is part of XEmacs.
|
|
8
|
|
9 XEmacs is free software; you can redistribute it and/or modify it
|
|
10 under the terms of the GNU General Public License as published by the
|
|
11 Free Software Foundation; either version 2, or (at your option) any
|
|
12 later version.
|
|
13
|
|
14 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
17 for more details.
|
|
18
|
|
19 You should have received a copy of the GNU General Public License
|
|
20 along with XEmacs; see the file COPYING. If not, write to
|
|
21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
22 Boston, MA 02111-1307, USA. */
|
|
23
|
|
24 /* Synched up with: Not in FSF. */
|
|
25
|
|
26 #include <config.h>
|
|
27 #include "lisp.h"
|
|
28
|
|
29 #include "faces.h"
|
|
30 #include "frame.h"
|
|
31 #include "toolbar.h"
|
|
32 #include "window.h"
|
|
33
|
|
34 /* Only a very few things need to differ based on the toolkit used.
|
|
35 **
|
|
36 ** Some of the routines used assert(FRAME_yyy_P(f)) checks, this is
|
|
37 ** now abstracted into __INTERNAL_APPROPRIATENESS_CHECK(). When we
|
|
38 ** add new window systems that use this code, we should either add a
|
|
39 ** new case here, or just remove the checks completely.
|
|
40 **
|
|
41 ** At least for X & GTK redraw_frame_toolbars() might end up getting
|
|
42 ** called before we are completely initialized. To avoid this, we use
|
|
43 ** the __INTERNAL_MAPPED_P(f) macro, that should return 0 if we should
|
|
44 ** not draw the toolbars yet. When we add new window systems that use
|
|
45 ** this code, we should add a new case here, if they need it.
|
|
46 **
|
|
47 ** When clearing the toolbar, it is nice to flush the drawing queue.
|
|
48 ** Use __INTERNAL_FLUSH to do this. It is passed a device.
|
|
49 */
|
|
50 #if defined(HAVE_GTK)
|
|
51 #include "console-gtk.h"
|
|
52 #define __INTERNAL_MAPPED_P(f) GTK_WIDGET_REALIZED (FRAME_GTK_TEXT_WIDGET (f))
|
|
53 #define __INTERNAL_FLUSH(d) gdk_flush()
|
|
54 #define __INTERNAL_APPROPRIATENESS_CHECK(f) assert(FRAME_GTK_P (f))
|
|
55 #elif defined(HAVE_X_WINDOWS)
|
|
56 #include "console-x.h"
|
|
57 #define __INTERNAL_MAPPED_P(f) XtIsRealized (FRAME_X_SHELL_WIDGET (f))
|
|
58 #define __INTERNAL_APPROPRIATENESS_CHECK(f) assert(FRAME_X_P (f))
|
|
59 #define __INTERNAL_FLUSH(d) XFlush (DEVICE_X_DISPLAY (d))
|
|
60 #else
|
|
61 #define __INTERNAL_MAPPED_P(f) abort()
|
|
62 #define __INTERNAL_APPROPRIATENESS_CHECK(f) abort()
|
|
63 #define __INTERNAL_FLUSH(f) abort()
|
|
64 #endif
|
|
65
|
|
66 #include "toolbar-common.h"
|
|
67
|
744
|
68 extern Lisp_Object Vtoolbar_shadow_thickness;
|
|
69
|
713
|
70 static void __prepare_button_area (struct frame *f,
|
|
71 struct toolbar_button *tb)
|
|
72 {
|
|
73 int sx = tb->x;
|
|
74 int sy = tb->y;
|
|
75 int swidth = tb->width;
|
|
76 int sheight = tb->height;
|
|
77 int border_width = tb->border_width;
|
|
78 int x_adj, width_adj, y_adj, height_adj;
|
|
79 struct device *d = XDEVICE (f->device);
|
|
80 Lisp_Object window = FRAME_LAST_NONMINIBUF_WINDOW (f);
|
|
81 struct window *w = XWINDOW (window);
|
744
|
82 int shadow_thickness;
|
|
83 int def_shadow_thickness = XINT (Fspecifier_instance(Vtoolbar_shadow_thickness, window, Qnil, Qnil));
|
713
|
84 face_index toolbar_findex;
|
|
85
|
|
86 if (tb->vertical)
|
|
87 {
|
|
88 x_adj = border_width;
|
|
89 width_adj = - 2 * border_width;
|
|
90 y_adj = height_adj = 0;
|
|
91 }
|
|
92 else
|
|
93 {
|
|
94 x_adj = width_adj = 0;
|
|
95 y_adj = border_width;
|
|
96 height_adj = - 2 * border_width;
|
|
97 }
|
|
98
|
|
99 toolbar_findex = get_builtin_face_cache_index (w, Vtoolbar_face);
|
|
100
|
|
101 /* Blank toolbar buttons that should be 3d will have EQ(tb->up_glyph, Qt)
|
|
102 ** Blank toolbar buttons that should be flat will have NILP (tb->up_glyph)
|
|
103 **
|
|
104 ** Real toolbar buttons will check tb->enabled && tb->down
|
|
105 */
|
|
106 if (EQ (Qt, tb->up_glyph))
|
|
107 {
|
744
|
108 shadow_thickness = def_shadow_thickness;
|
713
|
109 }
|
|
110 else if (NILP (tb->up_glyph))
|
|
111 {
|
|
112 shadow_thickness = 0;
|
|
113 }
|
|
114 else
|
|
115 {
|
|
116 if (tb->enabled)
|
|
117 {
|
|
118 if (tb->down)
|
744
|
119 shadow_thickness = -def_shadow_thickness;
|
713
|
120 else
|
744
|
121 shadow_thickness = def_shadow_thickness;
|
713
|
122 }
|
|
123 else
|
|
124 {
|
|
125 shadow_thickness = 0;
|
|
126 }
|
|
127 }
|
|
128
|
|
129 /* Blank the entire area. */
|
|
130 redisplay_clear_region (window, toolbar_findex,
|
|
131 sx + x_adj, sy + y_adj,
|
|
132 swidth + width_adj,
|
|
133 sheight + height_adj);
|
|
134
|
|
135 /* Draw the outline. */
|
|
136 if (shadow_thickness)
|
|
137 {
|
|
138 MAYBE_DEVMETH (d, bevel_area,
|
|
139 (w, toolbar_findex, sx + x_adj,
|
|
140 sy + y_adj, swidth + width_adj,
|
|
141 sheight + height_adj, abs(shadow_thickness),
|
|
142 EDGE_ALL, (shadow_thickness < 0) ? EDGE_BEVEL_IN : EDGE_BEVEL_OUT));
|
|
143 }
|
|
144
|
|
145 /* Handle the borders... */
|
|
146 redisplay_clear_region (window, toolbar_findex,
|
|
147 sx, sy,
|
|
148 (tb->vertical ? border_width : swidth),
|
|
149 (tb->vertical ? sheight : border_width));
|
|
150 redisplay_clear_region (window, toolbar_findex,
|
|
151 (tb->vertical ? sx + swidth : sx),
|
|
152 (tb->vertical ? sy : sy + sheight),
|
|
153 (tb->vertical ? border_width : swidth),
|
|
154 (tb->vertical ? sheight : border_width));
|
|
155 }
|
|
156
|
|
157 #define common_draw_blank_toolbar_button(f,tb) __prepare_button_area (f,tb)
|
|
158
|
|
159 void
|
|
160 common_output_toolbar_button (struct frame *f, Lisp_Object button)
|
|
161 {
|
|
162 int shadow_thickness = 2;
|
|
163 int x_adj, y_adj, width_adj, height_adj;
|
|
164 struct device *d = XDEVICE (f->device);
|
|
165 Lisp_Object instance, frame, window, glyph;
|
|
166 struct toolbar_button *tb = XTOOLBAR_BUTTON (button);
|
|
167 struct Lisp_Image_Instance *p;
|
|
168 struct window *w;
|
|
169 int vertical = tb->vertical;
|
|
170 int border_width = tb->border_width;
|
|
171 face_index toolbar_findex;
|
|
172
|
|
173 if (vertical)
|
|
174 {
|
|
175 x_adj = border_width;
|
|
176 width_adj = - 2 * border_width;
|
|
177 y_adj = 0;
|
|
178 height_adj = 0;
|
|
179 }
|
|
180 else
|
|
181 {
|
|
182 x_adj = 0;
|
|
183 width_adj = 0;
|
|
184 y_adj = border_width;
|
|
185 height_adj = - 2 * border_width;
|
|
186 }
|
|
187
|
|
188 XSETFRAME (frame, f);
|
|
189 window = FRAME_LAST_NONMINIBUF_WINDOW (f);
|
|
190 w = XWINDOW (window);
|
|
191
|
|
192 glyph = get_toolbar_button_glyph (w, tb);
|
|
193
|
|
194 if (tb->enabled)
|
|
195 {
|
|
196 if (tb->down)
|
|
197 {
|
|
198 shadow_thickness = -2;
|
|
199 }
|
|
200 else
|
|
201 {
|
|
202 shadow_thickness = 2;
|
|
203 }
|
|
204 }
|
|
205 else
|
|
206 {
|
|
207 shadow_thickness = 0;
|
|
208 }
|
|
209
|
|
210 toolbar_findex = get_builtin_face_cache_index (w, Vtoolbar_face);
|
|
211
|
|
212 __prepare_button_area (f, tb);
|
|
213
|
|
214 /* #### It is currently possible for users to trash us by directly
|
|
215 changing the toolbar glyphs. Avoid crashing in that case. */
|
|
216 if (GLYPHP (glyph))
|
|
217 instance = glyph_image_instance (glyph, window, ERROR_ME_NOT, 1);
|
|
218 else
|
|
219 instance = Qnil;
|
|
220
|
|
221 if (IMAGE_INSTANCEP (instance))
|
|
222 {
|
|
223 int width = tb->width + width_adj - shadow_thickness * 2;
|
|
224 int height = tb->height + height_adj - shadow_thickness * 2;
|
|
225 int x_offset = x_adj + shadow_thickness;
|
|
226 int y_offset = y_adj + shadow_thickness;
|
|
227
|
|
228 p = XIMAGE_INSTANCE (instance);
|
|
229
|
|
230 if (IMAGE_INSTANCE_PIXMAP_TYPE_P (p))
|
|
231 {
|
|
232 struct display_box db;
|
|
233 struct display_glyph_area dga;
|
|
234
|
|
235 if (width > (int) IMAGE_INSTANCE_PIXMAP_WIDTH (p))
|
|
236 {
|
|
237 x_offset += ((int) (width - IMAGE_INSTANCE_PIXMAP_WIDTH (p))
|
|
238 / 2);
|
|
239 width = IMAGE_INSTANCE_PIXMAP_WIDTH (p);
|
|
240 }
|
|
241 if (height > (int) IMAGE_INSTANCE_PIXMAP_HEIGHT (p))
|
|
242 {
|
|
243 y_offset += ((int) (height - IMAGE_INSTANCE_PIXMAP_HEIGHT (p))
|
|
244 / 2);
|
|
245 height = IMAGE_INSTANCE_PIXMAP_HEIGHT (p);
|
|
246 }
|
|
247
|
|
248 /* Draw exactly in the area specified... */
|
|
249 db.xpos = tb->x + x_offset;
|
|
250 db.ypos = tb->y + y_offset;
|
|
251 db.width = width;
|
|
252 db.height = height;
|
|
253
|
|
254 /* Display the whole glyph */
|
|
255 dga.xoffset = 0;
|
|
256 dga.yoffset = 0;
|
|
257 dga.width = width;
|
|
258 dga.height = height;
|
|
259
|
|
260 redisplay_output_pixmap (w, instance,
|
|
261 &db, &dga,
|
|
262 toolbar_findex, 0, 0, 0, 0);
|
|
263 }
|
|
264 else if (IMAGE_INSTANCE_TYPE (p) == IMAGE_TEXT)
|
|
265 {
|
|
266 /* #### We need to make the face used configurable. */
|
|
267 struct face_cachel *cachel =
|
|
268 WINDOW_FACE_CACHEL (w, DEFAULT_INDEX);
|
|
269 struct display_line dl;
|
|
270 Lisp_Object string = IMAGE_INSTANCE_TEXT_STRING (p);
|
|
271 unsigned char charsets[NUM_LEADING_BYTES];
|
|
272 Emchar_dynarr *buf;
|
|
273 struct font_metric_info fm;
|
|
274
|
|
275 /* This could be true if we were called via the Expose event
|
|
276 handler. Mark the button as dirty and return
|
|
277 immediately. */
|
|
278 if (f->window_face_cache_reset)
|
|
279 {
|
|
280 tb->dirty = 1;
|
|
281 MARK_TOOLBAR_CHANGED;
|
|
282 return;
|
|
283 }
|
|
284 buf = Dynarr_new (Emchar);
|
|
285 convert_intbyte_string_into_emchar_dynarr
|
|
286 (XSTRING_DATA (string), XSTRING_LENGTH (string), buf);
|
|
287 find_charsets_in_emchar_string (charsets, Dynarr_atp (buf, 0),
|
|
288 Dynarr_length (buf));
|
|
289 ensure_face_cachel_complete (cachel, window, charsets);
|
|
290 face_cachel_charset_font_metric_info (cachel, charsets, &fm);
|
|
291
|
|
292 dl.ascent = fm.ascent;
|
|
293 dl.descent = fm.descent;
|
|
294 dl.ypos = tb->y + y_offset + fm.ascent;
|
|
295
|
|
296 if (fm.ascent + fm.descent <= height)
|
|
297 {
|
|
298 dl.ypos += (height - fm.ascent - fm.descent) / 2;
|
|
299 dl.clip = 0;
|
|
300 }
|
|
301 else
|
|
302 {
|
|
303 dl.clip = fm.ascent + fm.descent - height;
|
|
304 }
|
|
305
|
|
306 MAYBE_DEVMETH (d, output_string,
|
|
307 (w, &dl, buf, tb->x + x_offset, 0, 0, width,
|
|
308 toolbar_findex, 0, 0, 0, 0));
|
|
309 Dynarr_free (buf);
|
|
310 }
|
|
311
|
|
312 /* We silently ignore the image if it isn't a pixmap or text. */
|
|
313 }
|
|
314
|
|
315 tb->dirty = 0;
|
|
316 }
|
|
317
|
|
318 static int
|
|
319 common_get_button_size (struct frame *f, Lisp_Object window,
|
|
320 struct toolbar_button *tb, int vert, int pos)
|
|
321 {
|
|
322 int shadow_thickness = 2;
|
|
323 int size;
|
|
324
|
|
325 if (tb->blank)
|
|
326 {
|
|
327 if (!NILP (tb->down_glyph))
|
|
328 size = XINT (tb->down_glyph);
|
|
329 else
|
|
330 size = DEFAULT_TOOLBAR_BLANK_SIZE;
|
|
331 }
|
|
332 else
|
|
333 {
|
|
334 struct window *w = XWINDOW (window);
|
|
335 Lisp_Object glyph = get_toolbar_button_glyph (w, tb);
|
|
336
|
|
337 /* Unless, of course, the user has done something stupid like
|
|
338 change the glyph out from under us. Use a blank placeholder
|
|
339 in that case. */
|
|
340 if (NILP (glyph))
|
|
341 return XINT (f->toolbar_size[pos]);
|
|
342
|
|
343 if (vert)
|
|
344 size = glyph_height (glyph, window);
|
|
345 else
|
|
346 size = glyph_width (glyph, window);
|
|
347 }
|
|
348
|
|
349 if (!size)
|
|
350 {
|
|
351 /* If the glyph doesn't have a size we'll insert a blank
|
|
352 placeholder instead. */
|
|
353 return XINT (f->toolbar_size[pos]);
|
|
354 }
|
|
355
|
|
356 size += shadow_thickness * 2;
|
|
357
|
|
358 return (size);
|
|
359 }
|
|
360
|
|
361 #define COMMON_OUTPUT_BUTTONS_LOOP(left) \
|
|
362 do { \
|
|
363 while (!NILP (button)) \
|
|
364 { \
|
|
365 struct toolbar_button *tb = XTOOLBAR_BUTTON (button); \
|
|
366 int size, height, width; \
|
|
367 \
|
|
368 if (left && tb->pushright) \
|
|
369 break; \
|
|
370 \
|
|
371 size = common_get_button_size (f, window, tb, vert, pos); \
|
|
372 \
|
|
373 if (vert) \
|
|
374 { \
|
|
375 width = bar_width; \
|
|
376 if (y + size > max_pixpos) \
|
|
377 height = max_pixpos - y; \
|
|
378 else \
|
|
379 height = size; \
|
|
380 } \
|
|
381 else \
|
|
382 { \
|
|
383 if (x + size > max_pixpos) \
|
|
384 width = max_pixpos - x; \
|
|
385 else \
|
|
386 width = size; \
|
|
387 height = bar_height; \
|
|
388 } \
|
|
389 \
|
|
390 if (tb->x != x \
|
|
391 || tb->y != y \
|
|
392 || tb->width != width \
|
|
393 || tb->height != height \
|
|
394 || tb->dirty) \
|
|
395 { \
|
|
396 if (width && height) \
|
|
397 { \
|
|
398 tb->x = x; \
|
|
399 tb->y = y; \
|
|
400 tb->width = width; \
|
|
401 tb->height = height; \
|
|
402 tb->border_width = border_width; \
|
|
403 tb->vertical = vert; \
|
|
404 \
|
|
405 if (tb->blank || NILP (tb->up_glyph)) \
|
|
406 { \
|
|
407 common_draw_blank_toolbar_button (f, tb); \
|
|
408 } \
|
|
409 else \
|
|
410 common_output_toolbar_button (f, button); \
|
|
411 } \
|
|
412 } \
|
|
413 \
|
|
414 if (vert) \
|
|
415 y += height; \
|
|
416 else \
|
|
417 x += width; \
|
|
418 \
|
|
419 if ((vert && y == max_pixpos) || (!vert && x == max_pixpos)) \
|
|
420 button = Qnil; \
|
|
421 else \
|
|
422 button = tb->next; \
|
|
423 } \
|
|
424 } while (0)
|
|
425
|
|
426 #define SET_TOOLBAR_WAS_VISIBLE_FLAG(frame, pos, flag) \
|
|
427 do { \
|
|
428 switch (pos) \
|
|
429 { \
|
|
430 case TOP_TOOLBAR: \
|
|
431 (frame)->top_toolbar_was_visible = flag; \
|
|
432 break; \
|
|
433 case BOTTOM_TOOLBAR: \
|
|
434 (frame)->bottom_toolbar_was_visible = flag; \
|
|
435 break; \
|
|
436 case LEFT_TOOLBAR: \
|
|
437 (frame)->left_toolbar_was_visible = flag; \
|
|
438 break; \
|
|
439 case RIGHT_TOOLBAR: \
|
|
440 (frame)->right_toolbar_was_visible = flag; \
|
|
441 break; \
|
|
442 default: \
|
|
443 abort (); \
|
|
444 } \
|
|
445 } while (0)
|
|
446
|
|
447 static void
|
|
448 common_output_toolbar (struct frame *f, enum toolbar_pos pos)
|
|
449 {
|
|
450 int x, y, bar_width, bar_height, vert;
|
|
451 int max_pixpos, right_size, right_start, blank_size;
|
|
452 int border_width = FRAME_REAL_TOOLBAR_BORDER_WIDTH (f, pos);
|
|
453 Lisp_Object button, window;
|
|
454 face_index toolbar_findex;
|
|
455
|
|
456 get_toolbar_coords (f, pos, &x, &y, &bar_width, &bar_height, &vert, 1);
|
|
457 window = FRAME_LAST_NONMINIBUF_WINDOW (f);
|
|
458 toolbar_findex = get_builtin_face_cache_index (XWINDOW (window), Vtoolbar_face);
|
|
459
|
|
460 /* Do the border */
|
|
461 redisplay_clear_region (window, toolbar_findex,
|
|
462 x, y,
|
|
463 (vert ? bar_width : border_width),
|
|
464 (vert ? border_width : bar_height));
|
|
465 redisplay_clear_region (window, toolbar_findex,
|
|
466 (vert ? x : x + bar_width - border_width),
|
|
467 (vert ? y + bar_height - border_width : y),
|
|
468 (vert ? bar_width : border_width),
|
|
469 (vert ? border_width : bar_height));
|
|
470
|
|
471 if (vert)
|
|
472 {
|
|
473 max_pixpos = y + bar_height - border_width;
|
|
474 y += border_width;
|
|
475 }
|
|
476 else
|
|
477 {
|
|
478 max_pixpos = x + bar_width - border_width;
|
|
479 x += border_width;
|
|
480 }
|
|
481
|
|
482 button = FRAME_TOOLBAR_BUTTONS (f, pos);
|
|
483 right_size = 0;
|
|
484
|
|
485 /* First loop over all of the buttons to determine how much room we
|
|
486 need for left hand and right hand buttons. This loop will also
|
|
487 make sure that all instances are instantiated so when we actually
|
|
488 output them they will come up immediately. */
|
|
489 while (!NILP (button))
|
|
490 {
|
|
491 struct toolbar_button *tb = XTOOLBAR_BUTTON (button);
|
|
492 int size = common_get_button_size (f, window, tb, vert, pos);
|
|
493
|
|
494 if (tb->pushright)
|
|
495 right_size += size;
|
|
496
|
|
497 button = tb->next;
|
|
498 }
|
|
499
|
|
500 button = FRAME_TOOLBAR_BUTTONS (f, pos);
|
|
501
|
|
502 /* Loop over the left buttons, updating and outputting them. */
|
|
503 COMMON_OUTPUT_BUTTONS_LOOP (1);
|
|
504
|
|
505 /* Now determine where the right buttons start. */
|
|
506 right_start = max_pixpos - right_size;
|
|
507 if (right_start < (vert ? y : x))
|
|
508 right_start = (vert ? y : x);
|
|
509
|
|
510 /* Output the blank which goes from the end of the left buttons to
|
|
511 the start of the right. */
|
|
512 blank_size = right_start - (vert ? y : x);
|
|
513 if (blank_size)
|
|
514 {
|
|
515 int height, width;
|
|
516
|
|
517 if (vert)
|
|
518 {
|
|
519 width = bar_width;
|
|
520 height = blank_size;
|
|
521 }
|
|
522 else
|
|
523 {
|
|
524 width = blank_size;
|
|
525 height = bar_height;
|
|
526 }
|
|
527
|
|
528 /*
|
|
529 * Use a 3D pushright separator only if there isn't a toolbar
|
|
530 * border. A flat separator meshes with the border and looks
|
|
531 * better.
|
|
532 */
|
|
533 if (1)
|
|
534 {
|
|
535 struct toolbar_button tb;
|
|
536
|
|
537 tb.x = x;
|
|
538 tb.y = y;
|
|
539 tb.width = width;
|
|
540 tb.height = height;
|
|
541 tb.border_width = border_width;
|
|
542 tb.vertical = vert;
|
|
543 tb.enabled = 1;
|
|
544 tb.up_glyph = border_width ? Qt : Qnil;
|
|
545
|
|
546 __prepare_button_area (f, &tb);
|
|
547 }
|
|
548
|
|
549 if (vert)
|
|
550 y += height;
|
|
551 else
|
|
552 x += width;
|
|
553 }
|
|
554
|
|
555 /* Loop over the right buttons, updating and outputting them. */
|
|
556 COMMON_OUTPUT_BUTTONS_LOOP (0);
|
|
557
|
|
558 if (!vert)
|
|
559 {
|
|
560 Lisp_Object frame;
|
|
561
|
|
562 XSETFRAME (frame, f);
|
|
563 redisplay_clear_region (frame,
|
|
564 DEFAULT_INDEX, FRAME_PIXWIDTH (f) - 1, y, 1,
|
|
565 bar_height);
|
|
566 }
|
|
567
|
|
568 SET_TOOLBAR_WAS_VISIBLE_FLAG (f, pos, 1);
|
|
569 __INTERNAL_FLUSH (XDEVICE (f->device));
|
|
570 }
|
|
571
|
|
572 static void
|
|
573 common_clear_toolbar (struct frame *f, enum toolbar_pos pos, int thickness_change)
|
|
574 {
|
|
575 Lisp_Object frame;
|
|
576 int x, y, width, height, vert;
|
|
577
|
|
578 get_toolbar_coords (f, pos, &x, &y, &width, &height, &vert, 1);
|
|
579 XSETFRAME (frame, f);
|
|
580
|
|
581 /* The thickness_change parameter is used by the toolbar resize routines
|
|
582 to clear any excess toolbar if the size shrinks. */
|
|
583 if (thickness_change < 0)
|
|
584 {
|
|
585 if (pos == LEFT_TOOLBAR || pos == RIGHT_TOOLBAR)
|
|
586 {
|
|
587 x = x + width + thickness_change;
|
|
588 width = -thickness_change;
|
|
589 }
|
|
590 else
|
|
591 {
|
|
592 y = y + height + thickness_change;
|
|
593 height = -thickness_change;
|
|
594 }
|
|
595 }
|
|
596
|
|
597 SET_TOOLBAR_WAS_VISIBLE_FLAG (f, pos, 0);
|
|
598
|
|
599 redisplay_clear_region (frame, DEFAULT_INDEX, x, y, width, height);
|
|
600
|
|
601 __INTERNAL_FLUSH (XDEVICE (f->device));
|
|
602 }
|
|
603
|
|
604 void
|
|
605 common_output_frame_toolbars (struct frame *f)
|
|
606 {
|
|
607 __INTERNAL_APPROPRIATENESS_CHECK(f);
|
|
608
|
|
609 if (FRAME_REAL_TOP_TOOLBAR_VISIBLE (f))
|
|
610 common_output_toolbar (f, TOP_TOOLBAR);
|
|
611 else if (f->top_toolbar_was_visible)
|
|
612 common_clear_toolbar (f, TOP_TOOLBAR, 0);
|
|
613
|
|
614 if (FRAME_REAL_BOTTOM_TOOLBAR_VISIBLE (f))
|
|
615 common_output_toolbar (f, BOTTOM_TOOLBAR);
|
|
616 else if (f->bottom_toolbar_was_visible)
|
|
617 common_clear_toolbar (f, BOTTOM_TOOLBAR, 0);
|
|
618
|
|
619 if (FRAME_REAL_LEFT_TOOLBAR_VISIBLE (f))
|
|
620 common_output_toolbar (f, LEFT_TOOLBAR);
|
|
621 else if (f->left_toolbar_was_visible)
|
|
622 common_clear_toolbar (f, LEFT_TOOLBAR, 0);
|
|
623
|
|
624 if (FRAME_REAL_RIGHT_TOOLBAR_VISIBLE (f))
|
|
625 common_output_toolbar (f, RIGHT_TOOLBAR);
|
|
626 else if (f->right_toolbar_was_visible)
|
|
627 common_clear_toolbar (f, RIGHT_TOOLBAR, 0);
|
|
628 }
|
|
629
|
|
630 static void
|
|
631 common_redraw_exposed_toolbar (struct frame *f, enum toolbar_pos pos, int x, int y,
|
|
632 int width, int height)
|
|
633 {
|
|
634 int bar_x, bar_y, bar_width, bar_height, vert;
|
|
635 Lisp_Object button = FRAME_TOOLBAR_BUTTONS (f, pos);
|
|
636
|
|
637 get_toolbar_coords (f, pos, &bar_x, &bar_y, &bar_width, &bar_height,
|
|
638 &vert, 1);
|
|
639
|
|
640 if (((y + height) < bar_y) || (y > (bar_y + bar_height)))
|
|
641 return;
|
|
642 if (((x + width) < bar_x) || (x > (bar_x + bar_width)))
|
|
643 return;
|
|
644
|
|
645 while (!NILP (button))
|
|
646 {
|
|
647 struct toolbar_button *tb = XTOOLBAR_BUTTON (button);
|
|
648
|
|
649 if (vert)
|
|
650 {
|
|
651 if (((tb->y + tb->height) > y) && (tb->y < (y + height)))
|
|
652 tb->dirty = 1;
|
|
653
|
|
654 /* If this is true we have gone past the exposed region. */
|
|
655 if (tb->y > (y + height))
|
|
656 break;
|
|
657 }
|
|
658 else
|
|
659 {
|
|
660 if (((tb->x + tb->width) > x) && (tb->x < (x + width)))
|
|
661 tb->dirty = 1;
|
|
662
|
|
663 /* If this is true we have gone past the exposed region. */
|
|
664 if (tb->x > (x + width))
|
|
665 break;
|
|
666 }
|
|
667
|
|
668 button = tb->next;
|
|
669 }
|
|
670
|
|
671 /* Even if none of the buttons is in the area, the blank region at
|
|
672 the very least must be because the first thing we did is verify
|
|
673 that some portion of the toolbar is in the exposed region. */
|
|
674 common_output_toolbar (f, pos);
|
|
675 }
|
|
676
|
|
677 void
|
|
678 common_redraw_exposed_toolbars (struct frame *f, int x, int y, int width,
|
|
679 int height)
|
|
680 {
|
|
681 __INTERNAL_APPROPRIATENESS_CHECK(f);
|
|
682
|
|
683 if (FRAME_REAL_TOP_TOOLBAR_VISIBLE (f))
|
|
684 common_redraw_exposed_toolbar (f, TOP_TOOLBAR, x, y, width, height);
|
|
685
|
|
686 if (FRAME_REAL_BOTTOM_TOOLBAR_VISIBLE (f))
|
|
687 common_redraw_exposed_toolbar (f, BOTTOM_TOOLBAR, x, y, width, height);
|
|
688
|
|
689 if (FRAME_REAL_LEFT_TOOLBAR_VISIBLE (f))
|
|
690 common_redraw_exposed_toolbar (f, LEFT_TOOLBAR, x, y, width, height);
|
|
691
|
|
692 if (FRAME_REAL_RIGHT_TOOLBAR_VISIBLE (f))
|
|
693 common_redraw_exposed_toolbar (f, RIGHT_TOOLBAR, x, y, width, height);
|
|
694 }
|
|
695
|
|
696 void
|
|
697 common_redraw_frame_toolbars (struct frame *f)
|
|
698 {
|
|
699 /* There are certain startup paths that lead to update_EmacsFrame in
|
|
700 faces.c being called before a new frame is fully initialized. In
|
|
701 particular before we have actually mapped it. That routine can
|
|
702 call this one. So, we need to make sure that the frame is
|
|
703 actually ready before we try and draw all over it. */
|
|
704 if (__INTERNAL_MAPPED_P(f))
|
|
705 common_redraw_exposed_toolbars (f, 0, 0, FRAME_PIXWIDTH (f),
|
|
706 FRAME_PIXHEIGHT (f));
|
|
707 }
|