annotate src/toolbar-common.c @ 4594:2986723ac32d

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