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