annotate src/toolbar-common.c @ 2762:e20ee26d2313

[xemacs-hg @ 2005-05-08 11:37:41 by malcolmp] sysdep.c: Use autoconf 2.59's HAVE_DECL_SYS_SIGLIST instead of SYS_SIGLIST_DECLARED.
author malcolmp
date Sun, 08 May 2005 11:37:42 +0000
parents 3d8143fc88e1
children ad2f4ae9895b
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),
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
147 EDGE_ALL, (shadow_thickness < 0) ? EDGE_BEVEL_IN : EDGE_BEVEL_OUT));
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
148 }
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 /* Handle the borders... */
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
151 redisplay_clear_region (window, toolbar_findex,
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
152 sx, sy,
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
153 (tb->vertical ? border_width : swidth),
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
154 (tb->vertical ? sheight : border_width));
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
155 redisplay_clear_region (window, toolbar_findex,
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
156 (tb->vertical ? sx + swidth : sx),
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
157 (tb->vertical ? sy : sy + sheight),
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
158 (tb->vertical ? border_width : swidth),
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
159 (tb->vertical ? sheight : border_width));
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
160 }
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 #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
163
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
164 void
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
165 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
166 {
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
167 int shadow_thickness = 2;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
168 int x_adj, y_adj, width_adj, height_adj;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
169 struct device *d = XDEVICE (f->device);
2212
51a17f29fab3 [xemacs-hg @ 2004-08-12 14:51:34 by james]
james
parents: 905
diff changeset
170 Lisp_Object instance, window, glyph;
713
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
171 struct toolbar_button *tb = XTOOLBAR_BUTTON (button);
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
172 struct Lisp_Image_Instance *p;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
173 struct window *w;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
174 int vertical = tb->vertical;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
175 int border_width = tb->border_width;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
176 face_index toolbar_findex;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
177
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
178 if (vertical)
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
179 {
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
180 x_adj = border_width;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
181 width_adj = - 2 * border_width;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
182 y_adj = 0;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
183 height_adj = 0;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
184 }
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
185 else
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
186 {
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
187 x_adj = 0;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
188 width_adj = 0;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
189 y_adj = border_width;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
190 height_adj = - 2 * border_width;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
191 }
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 window = FRAME_LAST_NONMINIBUF_WINDOW (f);
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
194 w = XWINDOW (window);
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
195
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
196 glyph = get_toolbar_button_glyph (w, tb);
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
197
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
198 if (tb->enabled)
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
199 {
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
200 if (tb->down)
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
201 {
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
202 shadow_thickness = -2;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
203 }
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
204 else
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
205 {
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
206 shadow_thickness = 2;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
207 }
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 else
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
210 {
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
211 shadow_thickness = 0;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
212 }
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 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
215
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
216 __prepare_button_area (f, tb);
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
217
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
218 /* #### 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
219 changing the toolbar glyphs. Avoid crashing in that case. */
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
220 if (GLYPHP (glyph))
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
221 instance = glyph_image_instance (glyph, window, ERROR_ME_DEBUG_WARN, 1);
713
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
222 else
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
223 instance = Qnil;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
224
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
225 if (IMAGE_INSTANCEP (instance))
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
226 {
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
227 int width = tb->width + width_adj - shadow_thickness * 2;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
228 int height = tb->height + height_adj - shadow_thickness * 2;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
229 int x_offset = x_adj + shadow_thickness;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
230 int y_offset = y_adj + shadow_thickness;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
231
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
232 p = XIMAGE_INSTANCE (instance);
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
233
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
234 if (IMAGE_INSTANCE_PIXMAP_TYPE_P (p))
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
235 {
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
236 struct display_box db;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
237 struct display_glyph_area dga;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
238
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
239 if (width > (int) IMAGE_INSTANCE_PIXMAP_WIDTH (p))
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
240 {
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
241 x_offset += ((int) (width - IMAGE_INSTANCE_PIXMAP_WIDTH (p))
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
242 / 2);
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
243 width = IMAGE_INSTANCE_PIXMAP_WIDTH (p);
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
244 }
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
245 if (height > (int) IMAGE_INSTANCE_PIXMAP_HEIGHT (p))
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 y_offset += ((int) (height - IMAGE_INSTANCE_PIXMAP_HEIGHT (p))
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
248 / 2);
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
249 height = IMAGE_INSTANCE_PIXMAP_HEIGHT (p);
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
250 }
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
251
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
252 /* Draw exactly in the area specified... */
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
253 db.xpos = tb->x + x_offset;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
254 db.ypos = tb->y + y_offset;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
255 db.width = width;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
256 db.height = height;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
257
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
258 /* Display the whole glyph */
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
259 dga.xoffset = 0;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
260 dga.yoffset = 0;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
261 dga.width = width;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
262 dga.height = height;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
263
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
264 redisplay_output_pixmap (w, instance,
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
265 &db, &dga,
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
266 toolbar_findex, 0, 0, 0, 0);
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
267 }
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
268 else if (IMAGE_INSTANCE_TYPE (p) == IMAGE_TEXT)
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
269 {
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
270 /* #### We need to make the face used configurable. */
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
271 struct face_cachel *cachel =
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
272 WINDOW_FACE_CACHEL (w, DEFAULT_INDEX);
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
273 struct display_line dl;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
274 Lisp_Object string = IMAGE_INSTANCE_TEXT_STRING (p);
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
275 unsigned char charsets[NUM_LEADING_BYTES];
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 800
diff changeset
276 Ichar_dynarr *buf;
713
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
277 struct font_metric_info fm;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
278
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
279 /* 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
280 handler. Mark the button as dirty and return
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
281 immediately. */
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
282 if (f->window_face_cache_reset)
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
283 {
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
284 tb->dirty = 1;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
285 MARK_TOOLBAR_CHANGED;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
286 return;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
287 }
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 800
diff changeset
288 buf = Dynarr_new (Ichar);
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 800
diff changeset
289 convert_ibyte_string_into_ichar_dynarr
713
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
290 (XSTRING_DATA (string), XSTRING_LENGTH (string), buf);
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 800
diff changeset
291 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
292 Dynarr_length (buf));
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
293 ensure_face_cachel_complete (cachel, window, charsets);
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
294 face_cachel_charset_font_metric_info (cachel, charsets, &fm);
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
295
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
296 dl.ascent = fm.ascent;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
297 dl.descent = fm.descent;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
298 dl.ypos = tb->y + y_offset + fm.ascent;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
299
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
300 if (fm.ascent + fm.descent <= height)
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
301 {
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
302 dl.ypos += (height - fm.ascent - fm.descent) / 2;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
303 dl.clip = 0;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
304 }
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
305 else
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
306 {
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
307 dl.clip = fm.ascent + fm.descent - height;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
308 }
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 MAYBE_DEVMETH (d, output_string,
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
311 (w, &dl, buf, tb->x + x_offset, 0, 0, width,
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
312 toolbar_findex, 0, 0, 0, 0));
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
313 Dynarr_free (buf);
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
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
316 /* 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
317 }
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
318
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
319 tb->dirty = 0;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
320 }
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
321
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
322 static int
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
323 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
324 struct toolbar_button *tb, int vert, int pos)
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 int shadow_thickness = 2;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
327 int size;
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 if (tb->blank)
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
330 {
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
331 if (!NILP (tb->down_glyph))
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
332 size = XINT (tb->down_glyph);
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
333 else
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
334 size = DEFAULT_TOOLBAR_BLANK_SIZE;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
335 }
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
336 else
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
337 {
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
338 struct window *w = XWINDOW (window);
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
339 Lisp_Object glyph = get_toolbar_button_glyph (w, tb);
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
340
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
341 /* 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
342 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
343 in that case. */
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
344 if (NILP (glyph))
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
345 return XINT (f->toolbar_size[pos]);
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
346
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
347 if (vert)
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
348 size = glyph_height (glyph, window);
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
349 else
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
350 size = glyph_width (glyph, window);
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
351 }
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
352
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
353 if (!size)
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 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
356 placeholder instead. */
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
357 return XINT (f->toolbar_size[pos]);
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
358 }
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 size += shadow_thickness * 2;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
361
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
362 return (size);
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
363 }
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
364
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
365 #define COMMON_OUTPUT_BUTTONS_LOOP(left) \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
366 do { \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
367 while (!NILP (button)) \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
368 { \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
369 struct toolbar_button *tb = XTOOLBAR_BUTTON (button); \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
370 int size, height, width; \
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 if (left && tb->pushright) \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
373 break; \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
374 \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
375 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
376 \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
377 if (vert) \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
378 { \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
379 width = bar_width; \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
380 if (y + size > max_pixpos) \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
381 height = max_pixpos - y; \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
382 else \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
383 height = size; \
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 else \
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 if (x + size > max_pixpos) \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
388 width = max_pixpos - x; \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
389 else \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
390 width = size; \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
391 height = bar_height; \
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 \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
394 if (tb->x != x \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
395 || tb->y != y \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
396 || tb->width != width \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
397 || tb->height != height \
905
c15f25529e61 [xemacs-hg @ 2002-07-06 21:05:42 by andyp]
andyp
parents: 872
diff changeset
398 || tb->dirty \
c15f25529e61 [xemacs-hg @ 2002-07-06 21:05:42 by andyp]
andyp
parents: 872
diff changeset
399 || f->clear) /* This is clearly necessary. */ \
713
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 if (width && height) \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
402 { \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
403 tb->x = x; \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
404 tb->y = y; \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
405 tb->width = width; \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
406 tb->height = height; \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
407 tb->border_width = border_width; \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
408 tb->vertical = vert; \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
409 \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
410 if (tb->blank || NILP (tb->up_glyph)) \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
411 { \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
412 common_draw_blank_toolbar_button (f, tb); \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
413 } \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
414 else \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
415 common_output_toolbar_button (f, button); \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
416 } \
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 \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
419 if (vert) \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
420 y += height; \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
421 else \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
422 x += width; \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
423 \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
424 if ((vert && y == max_pixpos) || (!vert && x == max_pixpos)) \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
425 button = Qnil; \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
426 else \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
427 button = tb->next; \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
428 } \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
429 } while (0)
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
430
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
431 #define SET_TOOLBAR_WAS_VISIBLE_FLAG(frame, pos, flag) \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
432 do { \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
433 switch (pos) \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
434 { \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
435 case TOP_TOOLBAR: \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
436 (frame)->top_toolbar_was_visible = flag; \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
437 break; \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
438 case BOTTOM_TOOLBAR: \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
439 (frame)->bottom_toolbar_was_visible = flag; \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
440 break; \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
441 case LEFT_TOOLBAR: \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
442 (frame)->left_toolbar_was_visible = flag; \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
443 break; \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
444 case RIGHT_TOOLBAR: \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
445 (frame)->right_toolbar_was_visible = flag; \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
446 break; \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
447 default: \
2500
3d8143fc88e1 [xemacs-hg @ 2005-01-24 23:33:30 by ben]
ben
parents: 2212
diff changeset
448 ABORT (); \
713
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
449 } \
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
450 } while (0)
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
451
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
452 static void
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
453 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
454 {
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
455 int x, y, bar_width, bar_height, vert;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
456 int max_pixpos, right_size, right_start, blank_size;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
457 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
458 Lisp_Object button, window;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
459 face_index toolbar_findex;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
460
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
461 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
462 window = FRAME_LAST_NONMINIBUF_WINDOW (f);
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
463 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
464
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
465 /* Do the border */
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
466 redisplay_clear_region (window, toolbar_findex,
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
467 x, y,
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
468 (vert ? bar_width : border_width),
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
469 (vert ? border_width : bar_height));
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
470 redisplay_clear_region (window, toolbar_findex,
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
471 (vert ? x : x + bar_width - border_width),
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
472 (vert ? y + bar_height - border_width : y),
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
473 (vert ? bar_width : border_width),
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
474 (vert ? border_width : bar_height));
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
475
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
476 if (vert)
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
477 {
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
478 max_pixpos = y + bar_height - border_width;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
479 y += border_width;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
480 }
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
481 else
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
482 {
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
483 max_pixpos = x + bar_width - border_width;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
484 x += border_width;
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
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
487 button = FRAME_TOOLBAR_BUTTONS (f, pos);
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
488 right_size = 0;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
489
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
490 /* 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
491 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
492 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
493 output them they will come up immediately. */
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
494 while (!NILP (button))
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
495 {
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
496 struct toolbar_button *tb = XTOOLBAR_BUTTON (button);
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
497 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
498
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
499 if (tb->pushright)
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
500 right_size += size;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
501
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
502 button = tb->next;
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
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
505 button = FRAME_TOOLBAR_BUTTONS (f, 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 /* Loop over the left buttons, updating and outputting them. */
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
508 COMMON_OUTPUT_BUTTONS_LOOP (1);
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 /* Now determine where the right buttons start. */
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
511 right_start = max_pixpos - right_size;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
512 if (right_start < (vert ? y : x))
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
513 right_start = (vert ? y : x);
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 /* 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
516 the start of the right. */
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
517 blank_size = right_start - (vert ? y : x);
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
518 if (blank_size)
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
519 {
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
520 int height, width;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
521
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
522 if (vert)
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
523 {
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
524 width = bar_width;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
525 height = blank_size;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
526 }
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
527 else
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
528 {
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
529 width = blank_size;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
530 height = bar_height;
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
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
533 /*
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
534 * 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
535 * 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
536 * better.
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
537 */
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
538 if (1)
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 struct toolbar_button tb;
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 tb.x = x;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
543 tb.y = y;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
544 tb.width = width;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
545 tb.height = height;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
546 tb.border_width = border_width;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
547 tb.vertical = vert;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
548 tb.enabled = 1;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
549 tb.up_glyph = border_width ? Qt : Qnil;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
550
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
551 __prepare_button_area (f, &tb);
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
552 }
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
553
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
554 if (vert)
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
555 y += height;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
556 else
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
557 x += width;
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
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
560 /* Loop over the right buttons, updating and outputting them. */
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
561 COMMON_OUTPUT_BUTTONS_LOOP (0);
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
562
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
563 if (!vert)
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
564 {
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
565 Lisp_Object frame = wrap_frame (f);
713
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 redisplay_clear_region (frame,
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
568 DEFAULT_INDEX, FRAME_PIXWIDTH (f) - 1, y, 1,
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
569 bar_height);
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
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
572 SET_TOOLBAR_WAS_VISIBLE_FLAG (f, pos, 1);
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
573 __INTERNAL_FLUSH (XDEVICE (f->device));
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
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
576 static void
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
577 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
578 {
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
579 Lisp_Object frame;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
580 int x, y, width, height, vert;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
581
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
582 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
583 frame = wrap_frame (f);
713
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
584
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
585 /* 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
586 to clear any excess toolbar if the size shrinks. */
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
587 if (thickness_change < 0)
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
588 {
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
589 if (pos == LEFT_TOOLBAR || pos == RIGHT_TOOLBAR)
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
590 {
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
591 x = x + width + thickness_change;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
592 width = -thickness_change;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
593 }
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
594 else
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
595 {
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
596 y = y + height + thickness_change;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
597 height = -thickness_change;
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 }
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
600
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
601 SET_TOOLBAR_WAS_VISIBLE_FLAG (f, pos, 0);
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
602
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
603 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
604
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
605 __INTERNAL_FLUSH (XDEVICE (f->device));
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 void
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
609 common_output_frame_toolbars (struct frame *f)
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 __INTERNAL_APPROPRIATENESS_CHECK(f);
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 if (FRAME_REAL_TOP_TOOLBAR_VISIBLE (f))
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
614 common_output_toolbar (f, TOP_TOOLBAR);
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 if (FRAME_REAL_BOTTOM_TOOLBAR_VISIBLE (f))
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
617 common_output_toolbar (f, BOTTOM_TOOLBAR);
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 if (FRAME_REAL_LEFT_TOOLBAR_VISIBLE (f))
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
620 common_output_toolbar (f, LEFT_TOOLBAR);
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
621
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
622 if (FRAME_REAL_RIGHT_TOOLBAR_VISIBLE (f))
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
623 common_output_toolbar (f, RIGHT_TOOLBAR);
905
c15f25529e61 [xemacs-hg @ 2002-07-06 21:05:42 by andyp]
andyp
parents: 872
diff changeset
624 }
c15f25529e61 [xemacs-hg @ 2002-07-06 21:05:42 by andyp]
andyp
parents: 872
diff changeset
625
c15f25529e61 [xemacs-hg @ 2002-07-06 21:05:42 by andyp]
andyp
parents: 872
diff changeset
626 void
c15f25529e61 [xemacs-hg @ 2002-07-06 21:05:42 by andyp]
andyp
parents: 872
diff changeset
627 common_clear_frame_toolbars (struct frame *f)
c15f25529e61 [xemacs-hg @ 2002-07-06 21:05:42 by andyp]
andyp
parents: 872
diff changeset
628 {
c15f25529e61 [xemacs-hg @ 2002-07-06 21:05:42 by andyp]
andyp
parents: 872
diff changeset
629 __INTERNAL_APPROPRIATENESS_CHECK(f);
c15f25529e61 [xemacs-hg @ 2002-07-06 21:05:42 by andyp]
andyp
parents: 872
diff changeset
630
c15f25529e61 [xemacs-hg @ 2002-07-06 21:05:42 by andyp]
andyp
parents: 872
diff changeset
631 if (f->top_toolbar_was_visible
c15f25529e61 [xemacs-hg @ 2002-07-06 21:05:42 by andyp]
andyp
parents: 872
diff changeset
632 && !FRAME_REAL_TOP_TOOLBAR_VISIBLE (f))
c15f25529e61 [xemacs-hg @ 2002-07-06 21:05:42 by andyp]
andyp
parents: 872
diff changeset
633 common_clear_toolbar (f, TOP_TOOLBAR, 0);
c15f25529e61 [xemacs-hg @ 2002-07-06 21:05:42 by andyp]
andyp
parents: 872
diff changeset
634 if (f->bottom_toolbar_was_visible
c15f25529e61 [xemacs-hg @ 2002-07-06 21:05:42 by andyp]
andyp
parents: 872
diff changeset
635 && !FRAME_REAL_BOTTOM_TOOLBAR_VISIBLE (f))
c15f25529e61 [xemacs-hg @ 2002-07-06 21:05:42 by andyp]
andyp
parents: 872
diff changeset
636 common_clear_toolbar (f, BOTTOM_TOOLBAR, 0);
c15f25529e61 [xemacs-hg @ 2002-07-06 21:05:42 by andyp]
andyp
parents: 872
diff changeset
637 if (f->left_toolbar_was_visible
c15f25529e61 [xemacs-hg @ 2002-07-06 21:05:42 by andyp]
andyp
parents: 872
diff changeset
638 && !FRAME_REAL_LEFT_TOOLBAR_VISIBLE (f))
c15f25529e61 [xemacs-hg @ 2002-07-06 21:05:42 by andyp]
andyp
parents: 872
diff changeset
639 common_clear_toolbar (f, LEFT_TOOLBAR, 0);
c15f25529e61 [xemacs-hg @ 2002-07-06 21:05:42 by andyp]
andyp
parents: 872
diff changeset
640 if (f->right_toolbar_was_visible
c15f25529e61 [xemacs-hg @ 2002-07-06 21:05:42 by andyp]
andyp
parents: 872
diff changeset
641 && !FRAME_REAL_RIGHT_TOOLBAR_VISIBLE (f))
713
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
642 common_clear_toolbar (f, RIGHT_TOOLBAR, 0);
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
643 }
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
644
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
645 static void
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
646 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
647 int width, int height)
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
648 {
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
649 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
650 Lisp_Object button = FRAME_TOOLBAR_BUTTONS (f, pos);
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 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
653 &vert, 1);
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
654
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
655 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
656 return;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
657 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
658 return;
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 while (!NILP (button))
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
661 {
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
662 struct toolbar_button *tb = XTOOLBAR_BUTTON (button);
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
663
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
664 if (vert)
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
665 {
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
666 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
667 tb->dirty = 1;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
668
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
669 /* 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
670 if (tb->y > (y + height))
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
671 break;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
672 }
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
673 else
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
674 {
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
675 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
676 tb->dirty = 1;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
677
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
678 /* 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
679 if (tb->x > (x + width))
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
680 break;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
681 }
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 button = tb->next;
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
684 }
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 /* 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
687 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
688 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
689 common_output_toolbar (f, pos);
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
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
692 void
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
693 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
694 int height)
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
695 {
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
696 __INTERNAL_APPROPRIATENESS_CHECK(f);
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
697
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
698 if (FRAME_REAL_TOP_TOOLBAR_VISIBLE (f))
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
699 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
700
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
701 if (FRAME_REAL_BOTTOM_TOOLBAR_VISIBLE (f))
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
702 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
703
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
704 if (FRAME_REAL_LEFT_TOOLBAR_VISIBLE (f))
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
705 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
706
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
707 if (FRAME_REAL_RIGHT_TOOLBAR_VISIBLE (f))
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
708 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
709 }
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
710
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
711 void
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
712 common_redraw_frame_toolbars (struct frame *f)
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
713 {
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
714 /* 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
715 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
716 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
717 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
718 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
719 if (__INTERNAL_MAPPED_P(f))
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
720 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
721 FRAME_PIXHEIGHT (f));
c2c346111c9a [xemacs-hg @ 2001-12-23 01:11:00 by wmperry]
wmperry
parents:
diff changeset
722 }