annotate src/toolbar-x.c @ 552:a3adcf42bcec

[xemacs-hg @ 2001-05-21 06:19:40 by mta] Don't assert out if the printer isn't reachable on the net.
author mta
date Mon, 21 May 2001 06:19:41 +0000
parents abe6d1db359e
children fdefd0186b75
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* toolbar implementation -- X interface.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1995 Board of Trustees, University of Illinois.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 Copyright (C) 1995 Sun Microsystems, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4 Copyright (C) 1995, 1996 Ben Wing.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5 Copyright (C) 1996 Chuck Thompson.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 under the terms of the GNU General Public License as published by the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 Free Software Foundation; either version 2, or (at your option) any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 XEmacs is distributed in the hope that it will be useful, but WITHOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 along with XEmacs; see the file COPYING. If not, write to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 Boston, MA 02111-1307, USA. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 /* Synched up with: Not in FSF. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
26 /* This file Mule-ized (more like Mule-verified) by Ben Wing, 7-8-00. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
27
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 #include "lisp.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 #include "console-x.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 #include "glyphs-x.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 #include "objects-x.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 #include "EmacsFrame.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 #include "EmacsFrameP.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 #include "faces.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 #include "frame.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 #include "toolbar.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 #include "window.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 x_draw_blank_toolbar_button (struct frame *f, int x, int y, int width,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 int height, int threed, int border_width,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 int vertical)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 struct device *d = XDEVICE (f->device);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 EmacsFrame ef = (EmacsFrame) FRAME_X_TEXT_WIDGET (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 int shadow_thickness = ef->emacs_frame.toolbar_shadow_thickness;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 int sx = x, sy = y, swidth = width, sheight = height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 Display *dpy = DEVICE_X_DISPLAY (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 Window x_win = XtWindow (FRAME_X_TEXT_WIDGET (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 GC top_shadow_gc, bottom_shadow_gc, background_gc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 background_gc = FRAME_X_TOOLBAR_BLANK_BACKGROUND_GC (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 if (threed)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 top_shadow_gc = FRAME_X_TOOLBAR_TOP_SHADOW_GC (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 bottom_shadow_gc = FRAME_X_TOOLBAR_BOTTOM_SHADOW_GC (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 top_shadow_gc = background_gc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 bottom_shadow_gc = background_gc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 if (vertical)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 sx += border_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 swidth -= 2 * border_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 sy += border_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 sheight -= 2 * border_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 /* Draw the outline. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 x_output_shadows (f, sx, sy, swidth, sheight, top_shadow_gc,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 bottom_shadow_gc, background_gc, shadow_thickness,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 EDGE_ALL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 /* Blank the middle. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 XFillRectangle (dpy, x_win, background_gc, sx + shadow_thickness,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 sy + shadow_thickness, swidth - shadow_thickness * 2,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 sheight - shadow_thickness * 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 /* Do the border */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 XFillRectangle (dpy, x_win, background_gc, x, y,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 (vertical ? border_width : width),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 (vertical ? height : border_width));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 XFillRectangle (dpy, x_win, background_gc,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 (vertical ? sx + swidth : x),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 (vertical ? y : sy + sheight),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 (vertical ? border_width : width),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 (vertical ? height : border_width));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 x_output_toolbar_button (struct frame *f, Lisp_Object button)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 struct device *d = XDEVICE (f->device);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 EmacsFrame ef = (EmacsFrame) FRAME_X_TEXT_WIDGET (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 int shadow_thickness = ef->emacs_frame.toolbar_shadow_thickness;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 int x_adj, y_adj, width_adj, height_adj;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 Display *dpy = DEVICE_X_DISPLAY (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 Window x_win = XtWindow (FRAME_X_TEXT_WIDGET (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 GC top_shadow_gc, bottom_shadow_gc, background_gc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 Lisp_Object instance, frame, window, glyph;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 struct toolbar_button *tb = XTOOLBAR_BUTTON (button);
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
114 Lisp_Image_Instance *p;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 struct window *w;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 int vertical = tb->vertical;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 int border_width = tb->border_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 if (vertical)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 x_adj = border_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 width_adj = - 2 * border_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 y_adj = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 height_adj = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 x_adj = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 width_adj = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 y_adj = border_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 height_adj = - 2 * border_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 XSETFRAME (frame, f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 window = FRAME_LAST_NONMINIBUF_WINDOW (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 w = XWINDOW (window);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 glyph = get_toolbar_button_glyph (w, tb);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 if (tb->enabled)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 if (tb->down)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 top_shadow_gc = FRAME_X_TOOLBAR_BOTTOM_SHADOW_GC (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 bottom_shadow_gc = FRAME_X_TOOLBAR_TOP_SHADOW_GC (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 top_shadow_gc = FRAME_X_TOOLBAR_TOP_SHADOW_GC (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 bottom_shadow_gc = FRAME_X_TOOLBAR_BOTTOM_SHADOW_GC (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 top_shadow_gc = FRAME_X_TOOLBAR_BLANK_BACKGROUND_GC (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 bottom_shadow_gc = FRAME_X_TOOLBAR_BLANK_BACKGROUND_GC (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 background_gc = FRAME_X_TOOLBAR_BLANK_BACKGROUND_GC (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 /* Draw the outline. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 x_output_shadows (f, tb->x + x_adj, tb->y + y_adj,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 tb->width + width_adj, tb->height + height_adj,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 top_shadow_gc,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 bottom_shadow_gc, background_gc, shadow_thickness,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 EDGE_ALL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 /* Clear the pixmap area. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 XFillRectangle (dpy, x_win, background_gc, tb->x + x_adj + shadow_thickness,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 tb->y + y_adj + shadow_thickness,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 tb->width + width_adj - shadow_thickness * 2,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 tb->height + height_adj - shadow_thickness * 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 /* Do the border. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 XFillRectangle (dpy, x_win, background_gc, tb->x, tb->y,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 (vertical ? border_width : tb->width),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 (vertical ? tb->height : border_width));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 XFillRectangle (dpy, x_win, background_gc,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 (vertical ? tb->x + tb->width - border_width : tb->x),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 (vertical ? tb->y : tb->y + tb->height - border_width),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 (vertical ? border_width : tb->width),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 (vertical ? tb->height : border_width));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 background_gc = FRAME_X_TOOLBAR_PIXMAP_BACKGROUND_GC (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 /* #### It is currently possible for users to trash us by directly
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 changing the toolbar glyphs. Avoid crashing in that case. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 if (GLYPHP (glyph))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 instance = glyph_image_instance (glyph, window, ERROR_ME_NOT, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 instance = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 if (IMAGE_INSTANCEP (instance))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 int width = tb->width + width_adj - shadow_thickness * 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 int height = tb->height + height_adj - shadow_thickness * 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 int x_offset = x_adj + shadow_thickness;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 int y_offset = y_adj + shadow_thickness;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 p = XIMAGE_INSTANCE (instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 if (IMAGE_INSTANCE_PIXMAP_TYPE_P (p))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 if (width > (int) IMAGE_INSTANCE_PIXMAP_WIDTH (p))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 x_offset += ((int) (width - IMAGE_INSTANCE_PIXMAP_WIDTH (p))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 / 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 width = IMAGE_INSTANCE_PIXMAP_WIDTH (p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 if (height > (int) IMAGE_INSTANCE_PIXMAP_HEIGHT (p))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 y_offset += ((int) (height - IMAGE_INSTANCE_PIXMAP_HEIGHT (p))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 / 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 height = IMAGE_INSTANCE_PIXMAP_HEIGHT (p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 x_output_x_pixmap (f, XIMAGE_INSTANCE (instance), tb->x + x_offset,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 tb->y + y_offset, 0, 0, width, height,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 0, 0, background_gc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 else if (IMAGE_INSTANCE_TYPE (p) == IMAGE_TEXT)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 /* #### We need to make the face used configurable. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 struct face_cachel *cachel =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 WINDOW_FACE_CACHEL (w, DEFAULT_INDEX);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 struct display_line dl;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 Lisp_Object string = IMAGE_INSTANCE_TEXT_STRING (p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 unsigned char charsets[NUM_LEADING_BYTES];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 Emchar_dynarr *buf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 struct font_metric_info fm;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 /* This could be true if we were called via the Expose event
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 handler. Mark the button as dirty and return
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 immediately. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 if (f->window_face_cache_reset)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 tb->dirty = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 MARK_TOOLBAR_CHANGED;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 buf = Dynarr_new (Emchar);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 convert_bufbyte_string_into_emchar_dynarr
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 (XSTRING_DATA (string), XSTRING_LENGTH (string), buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 find_charsets_in_emchar_string (charsets, Dynarr_atp (buf, 0),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 Dynarr_length (buf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 ensure_face_cachel_complete (cachel, window, charsets);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 face_cachel_charset_font_metric_info (cachel, charsets, &fm);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 dl.ascent = fm.ascent;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 dl.descent = fm.descent;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 dl.ypos = tb->y + y_offset + fm.ascent;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 if (fm.ascent + fm.descent <= height)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 dl.ypos += (height - fm.ascent - fm.descent) / 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 dl.clip = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 dl.clip = fm.ascent + fm.descent - height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 x_output_string (w, &dl, buf, tb->x + x_offset, 0, 0, width,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 DEFAULT_INDEX, 0, 0, 0, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 Dynarr_free (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 /* We silently ignore the image if it isn't a pixmap or text. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 tb->dirty = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 x_get_button_size (struct frame *f, Lisp_Object window,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 struct toolbar_button *tb, int vert, int pos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 EmacsFrame ef = (EmacsFrame) FRAME_X_TEXT_WIDGET (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 int shadow_thickness = ef->emacs_frame.toolbar_shadow_thickness;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 int size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 if (tb->blank)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 if (!NILP (tb->down_glyph))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 size = XINT (tb->down_glyph);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 size = DEFAULT_TOOLBAR_BLANK_SIZE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 struct window *w = XWINDOW (window);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 Lisp_Object glyph = get_toolbar_button_glyph (w, tb);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 /* Unless, of course, the user has done something stupid like
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 change the glyph out from under us. Use a blank placeholder
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 in that case. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 if (NILP (glyph))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 return XINT (f->toolbar_size[pos]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 if (vert)
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
301 size = glyph_height (glyph, window);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 else
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
303 size = glyph_width (glyph, window);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 if (!size)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 /* If the glyph doesn't have a size we'll insert a blank
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 placeholder instead. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 return XINT (f->toolbar_size[pos]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 size += shadow_thickness * 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 return (size);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 #define X_OUTPUT_BUTTONS_LOOP(left) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 do { \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 while (!NILP (button)) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 { \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 struct toolbar_button *tb = XTOOLBAR_BUTTON (button); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 int size, height, width; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 if (left && tb->pushright) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 break; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 size = x_get_button_size (f, window, tb, vert, pos); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 if (vert) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 { \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 width = bar_width; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 if (y + size > max_pixpos) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 height = max_pixpos - y; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 else \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 height = size; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 } \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 else \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 { \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 if (x + size > max_pixpos) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 width = max_pixpos - x; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 else \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 width = size; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344 height = bar_height; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 } \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 if (tb->x != x \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 || tb->y != y \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 || tb->width != width \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 || tb->height != height \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 || tb->dirty) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 { \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 if (width && height) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 { \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 tb->x = x; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 tb->y = y; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 tb->width = width; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 tb->height = height; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 tb->border_width = border_width; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 tb->vertical = vert; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 if (tb->blank || NILP (tb->up_glyph)) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 { \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 int threed = (EQ (Qt, tb->up_glyph) ? 1 : 0); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 x_draw_blank_toolbar_button (f, x, y, width, \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 height, threed, \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 border_width, vert); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 } \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 else \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 x_output_toolbar_button (f, button); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 } \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 } \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 if (vert) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 y += height; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 else \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 x += width; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 if ((vert && y == max_pixpos) || (!vert && x == max_pixpos)) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 button = Qnil; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 else \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 button = tb->next; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 } \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384 } while (0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 #define SET_TOOLBAR_WAS_VISIBLE_FLAG(frame, pos, flag) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 do { \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 switch (pos) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 { \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390 case TOP_TOOLBAR: \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 (frame)->top_toolbar_was_visible = flag; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 break; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 case BOTTOM_TOOLBAR: \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394 (frame)->bottom_toolbar_was_visible = flag; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 break; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 case LEFT_TOOLBAR: \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 (frame)->left_toolbar_was_visible = flag; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 break; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 case RIGHT_TOOLBAR: \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 (frame)->right_toolbar_was_visible = flag; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 break; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 default: \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 abort (); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 } \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 } while (0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 x_output_toolbar (struct frame *f, enum toolbar_pos pos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 struct device *d = XDEVICE (f->device);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 int x, y, bar_width, bar_height, vert;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 int max_pixpos, right_size, right_start, blank_size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 int border_width = FRAME_REAL_TOOLBAR_BORDER_WIDTH (f, pos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 Lisp_Object button, window;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 Display *dpy = DEVICE_X_DISPLAY (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 Window x_win = XtWindow (FRAME_X_TEXT_WIDGET (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 GC background_gc = FRAME_X_TOOLBAR_BLANK_BACKGROUND_GC (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 get_toolbar_coords (f, pos, &x, &y, &bar_width, &bar_height, &vert, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 window = FRAME_LAST_NONMINIBUF_WINDOW (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 /* Do the border */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 XFillRectangle (dpy, x_win, background_gc, x, y,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 (vert ? bar_width : border_width),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425 (vert ? border_width : bar_height));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 XFillRectangle (dpy, x_win, background_gc,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 (vert ? x : x + bar_width - border_width),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 (vert ? y + bar_height - border_width : y),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 (vert ? bar_width : border_width),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 (vert ? border_width : bar_height));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 if (vert)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 max_pixpos = y + bar_height - border_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 y += border_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 max_pixpos = x + bar_width - border_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 x += border_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 button = FRAME_TOOLBAR_BUTTONS (f, pos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 right_size = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 /* First loop over all of the buttons to determine how much room we
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 need for left hand and right hand buttons. This loop will also
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 make sure that all instances are instantiated so when we actually
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449 output them they will come up immediately. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 while (!NILP (button))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 struct toolbar_button *tb = XTOOLBAR_BUTTON (button);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 int size = x_get_button_size (f, window, tb, vert, pos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 if (tb->pushright)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 right_size += size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 button = tb->next;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 button = FRAME_TOOLBAR_BUTTONS (f, pos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 /* Loop over the left buttons, updating and outputting them. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 X_OUTPUT_BUTTONS_LOOP (1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 /* Now determine where the right buttons start. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 right_start = max_pixpos - right_size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 if (right_start < (vert ? y : x))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 right_start = (vert ? y : x);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 /* Output the blank which goes from the end of the left buttons to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 the start of the right. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 blank_size = right_start - (vert ? y : x);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 if (blank_size)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 int height, width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478 if (vert)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480 width = bar_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481 height = blank_size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 width = blank_size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 height = bar_height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 * Use a 3D pushright separator only if there isn't a toolbar
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 * border. A flat separator meshes with the border and looks
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 * better.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494 x_draw_blank_toolbar_button (f, x, y, width, height, !border_width,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 border_width, vert);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 if (vert)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 y += height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 x += width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 /* Loop over the right buttons, updating and outputting them. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 X_OUTPUT_BUTTONS_LOOP (0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 if (!vert)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 Lisp_Object frame;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 XSETFRAME (frame, f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511 redisplay_clear_region (frame,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 DEFAULT_INDEX, FRAME_PIXWIDTH (f) - 1, y, 1,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513 bar_height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 SET_TOOLBAR_WAS_VISIBLE_FLAG (f, pos, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 XFlush (DEVICE_X_DISPLAY (d));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 x_clear_toolbar (struct frame *f, enum toolbar_pos pos, int thickness_change)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 Lisp_Object frame;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525 struct device *d = XDEVICE (f->device);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 int x, y, width, height, vert;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 get_toolbar_coords (f, pos, &x, &y, &width, &height, &vert, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 XSETFRAME (frame, f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 /* The thickness_change parameter is used by the toolbar resize routines
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532 to clear any excess toolbar if the size shrinks. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 if (thickness_change < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 if (pos == LEFT_TOOLBAR || pos == RIGHT_TOOLBAR)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 x = x + width + thickness_change;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 width = -thickness_change;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 y = y + height + thickness_change;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 height = -thickness_change;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 SET_TOOLBAR_WAS_VISIBLE_FLAG (f, pos, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549 redisplay_clear_region (frame, DEFAULT_INDEX, x, y, width, height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 XFlush (DEVICE_X_DISPLAY (d));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 x_output_frame_toolbars (struct frame *f)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 assert (FRAME_X_P (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 if (FRAME_REAL_TOP_TOOLBAR_VISIBLE (f))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559 x_output_toolbar (f, TOP_TOOLBAR);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 else if (f->top_toolbar_was_visible)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561 x_clear_toolbar (f, TOP_TOOLBAR, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 if (FRAME_REAL_BOTTOM_TOOLBAR_VISIBLE (f))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564 x_output_toolbar (f, BOTTOM_TOOLBAR);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 else if (f->bottom_toolbar_was_visible)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566 x_clear_toolbar (f, BOTTOM_TOOLBAR, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 if (FRAME_REAL_LEFT_TOOLBAR_VISIBLE (f))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569 x_output_toolbar (f, LEFT_TOOLBAR);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 else if (f->left_toolbar_was_visible)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571 x_clear_toolbar (f, LEFT_TOOLBAR, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
573 if (FRAME_REAL_RIGHT_TOOLBAR_VISIBLE (f))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574 x_output_toolbar (f, RIGHT_TOOLBAR);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575 else if (f->right_toolbar_was_visible)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576 x_clear_toolbar (f, RIGHT_TOOLBAR, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580 x_redraw_exposed_toolbar (struct frame *f, enum toolbar_pos pos, int x, int y,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 int width, int height)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583 int bar_x, bar_y, bar_width, bar_height, vert;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 Lisp_Object button = FRAME_TOOLBAR_BUTTONS (f, pos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586 get_toolbar_coords (f, pos, &bar_x, &bar_y, &bar_width, &bar_height,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587 &vert, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589 if (((y + height) < bar_y) || (y > (bar_y + bar_height)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 if (((x + width) < bar_x) || (x > (bar_x + bar_width)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 while (!NILP (button))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596 struct toolbar_button *tb = XTOOLBAR_BUTTON (button);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 if (vert)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 if (((tb->y + tb->height) > y) && (tb->y < (y + height)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 tb->dirty = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603 /* If this is true we have gone past the exposed region. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604 if (tb->y > (y + height))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609 if (((tb->x + tb->width) > x) && (tb->x < (x + width)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610 tb->dirty = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612 /* If this is true we have gone past the exposed region. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
613 if (tb->x > (x + width))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
614 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
616
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
617 button = tb->next;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
618 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
619
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620 /* Even if none of the buttons is in the area, the blank region at
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621 the very least must be because the first thing we did is verify
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622 that some portion of the toolbar is in the exposed region. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
623 x_output_toolbar (f, pos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
624 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
625
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
626 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627 x_redraw_exposed_toolbars (struct frame *f, int x, int y, int width,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
628 int height)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
629 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
630 assert (FRAME_X_P (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
631
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
632 if (FRAME_REAL_TOP_TOOLBAR_VISIBLE (f))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
633 x_redraw_exposed_toolbar (f, TOP_TOOLBAR, x, y, width, height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635 if (FRAME_REAL_BOTTOM_TOOLBAR_VISIBLE (f))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 x_redraw_exposed_toolbar (f, BOTTOM_TOOLBAR, x, y, width, height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
638 if (FRAME_REAL_LEFT_TOOLBAR_VISIBLE (f))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639 x_redraw_exposed_toolbar (f, LEFT_TOOLBAR, x, y, width, height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 if (FRAME_REAL_RIGHT_TOOLBAR_VISIBLE (f))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642 x_redraw_exposed_toolbar (f, RIGHT_TOOLBAR, x, y, width, height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646 x_redraw_frame_toolbars (struct frame *f)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648 /* There are certain startup paths that lead to update_EmacsFrame in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649 faces.c being called before a new frame is fully initialized. In
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650 particular before we have actually mapped it. That routine can
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651 call this one. So, we need to make sure that the frame is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652 actually ready before we try and draw all over it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654 if (XtIsRealized (FRAME_X_SHELL_WIDGET (f)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655 x_redraw_exposed_toolbars (f, 0, 0, FRAME_PIXWIDTH (f),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656 FRAME_PIXHEIGHT (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661 x_initialize_frame_toolbar_gcs (struct frame *f)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663 EmacsFrame ef = (EmacsFrame) FRAME_X_TEXT_WIDGET (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664 EmacsFramePart *efp = &(ef->emacs_frame);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665 XGCValues gcv;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
666 unsigned long flags = (GCForeground | GCBackground | GCGraphicsExposures);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
668 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
669 * If backgroundToolBarColor is specified, use it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
670 * Otherwise use the background resource.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
671 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
672 if (efp->background_toolbar_pixel == (Pixel) (-1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
673 efp->background_toolbar_pixel = efp->background_pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
674
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
675 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
676 * ####
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
677 * If foregroundToolBarColor is specified, use it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678 * Otherwise use the foreground resource.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
679 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
680 * The foreground pixel is currently unused, but will likely be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
681 * used when toolbar captions are generated by the toolbar code
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
682 * instead being incorporated into the icon image.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
683 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
684 if (efp->foreground_toolbar_pixel == (Pixel) (-1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
685 efp->foreground_toolbar_pixel = efp->foreground_pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
686
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
687 gcv.foreground = efp->background_toolbar_pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
688 gcv.background = ef->core.background_pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
689 gcv.graphics_exposures = False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
690 FRAME_X_TOOLBAR_BLANK_BACKGROUND_GC (f) =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691 XtGetGC ((Widget) ef, flags, &gcv);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
692
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
693 if (efp->top_toolbar_shadow_pixel == efp->bottom_toolbar_shadow_pixel)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
694 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
695 efp->top_toolbar_shadow_pixel = efp->background_toolbar_pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
696 efp->bottom_toolbar_shadow_pixel = efp->background_toolbar_pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
697 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
698
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
699 x_generate_shadow_pixels (f, &efp->top_toolbar_shadow_pixel,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
700 &efp->bottom_toolbar_shadow_pixel,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
701 efp->background_toolbar_pixel,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
702 ef->core.background_pixel);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
703
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
704 gcv.foreground = efp->top_toolbar_shadow_pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
705 gcv.background = ef->core.background_pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
706 gcv.graphics_exposures = False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
707 flags = GCForeground | GCBackground | GCGraphicsExposures;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
708 if (efp->top_toolbar_shadow_pixmap)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
709 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
710 gcv.fill_style = FillOpaqueStippled;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711 gcv.stipple = efp->top_toolbar_shadow_pixmap;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712 flags |= GCStipple | GCFillStyle;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
713 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
714 FRAME_X_TOOLBAR_TOP_SHADOW_GC (f) = XtGetGC ((Widget) ef, flags, &gcv);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
715
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
716 gcv.foreground = efp->bottom_toolbar_shadow_pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
717 gcv.background = ef->core.background_pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
718 gcv.graphics_exposures = False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
719 flags = GCForeground | GCBackground | GCGraphicsExposures;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
720 if (efp->bottom_toolbar_shadow_pixmap)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
721 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
722 gcv.fill_style = FillOpaqueStippled;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
723 gcv.stipple = efp->bottom_toolbar_shadow_pixmap;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
724 flags |= GCStipple | GCFillStyle;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
725 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726 FRAME_X_TOOLBAR_BOTTOM_SHADOW_GC (f) = XtGetGC ((Widget) ef, flags, &gcv);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
728 #ifdef HAVE_XPM
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
729 FRAME_X_TOOLBAR_PIXMAP_BACKGROUND_GC (f) =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
730 FRAME_X_TOOLBAR_BLANK_BACKGROUND_GC (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
731 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
732 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
733 struct device *d = XDEVICE (f->device);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
734 Display *dpy = DEVICE_X_DISPLAY (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
735
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
736 gcv.background = WhitePixelOfScreen (DefaultScreenOfDisplay (dpy));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
737 gcv.foreground = BlackPixelOfScreen (DefaultScreenOfDisplay (dpy));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
738 gcv.graphics_exposures = False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
739 flags = GCForeground | GCBackground | GCGraphicsExposures;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
740 FRAME_X_TOOLBAR_PIXMAP_BACKGROUND_GC (f) =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
741 XtGetGC ((Widget) ef, flags, &gcv);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
742 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
743 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
744 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
745
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
746 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
747 x_release_frame_toolbar_gcs (struct frame *f)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
748 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
749 Widget ew = (Widget) FRAME_X_TEXT_WIDGET (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
750 XtReleaseGC (ew, FRAME_X_TOOLBAR_BLANK_BACKGROUND_GC (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
751 /* If compiled with XPM support, this is a pointer to the same GC as
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
752 FRAME_X_BLANK_BACKGROUND_GC so we need to make sure we don't
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
753 release it twice. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
754 #ifndef HAVE_XPM
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
755 XtReleaseGC (ew, FRAME_X_TOOLBAR_PIXMAP_BACKGROUND_GC (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
756 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
757 XtReleaseGC (ew, FRAME_X_TOOLBAR_TOP_SHADOW_GC (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
758 XtReleaseGC (ew, FRAME_X_TOOLBAR_BOTTOM_SHADOW_GC (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
759
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
760 /* Seg fault if we try and use these again. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
761 FRAME_X_TOOLBAR_BLANK_BACKGROUND_GC (f) = (GC) - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
762 FRAME_X_TOOLBAR_PIXMAP_BACKGROUND_GC (f) = (GC) - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
763 FRAME_X_TOOLBAR_TOP_SHADOW_GC (f) = (GC) - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
764 FRAME_X_TOOLBAR_BOTTOM_SHADOW_GC (f) = (GC) - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
765 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
766
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
767 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
768 x_initialize_frame_toolbars (struct frame *f)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
769 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
770 EmacsFrame ef = (EmacsFrame) FRAME_X_TEXT_WIDGET (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
771
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
772 if (ef->emacs_frame.toolbar_shadow_thickness < MINIMUM_SHADOW_THICKNESS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
773 Xt_SET_VALUE (FRAME_X_TEXT_WIDGET (f),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
774 XtNtoolBarShadowThickness, MINIMUM_SHADOW_THICKNESS);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
775
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
776 x_initialize_frame_toolbar_gcs (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
777 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
778
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
779 /* This only calls one function but we go ahead and create this in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
780 case we ever do decide that we need to do more work. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
781 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
782 x_free_frame_toolbars (struct frame *f)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
783 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
784 x_release_frame_toolbar_gcs (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
785 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
786
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
787
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
788 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
789 /* initialization */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
790 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
791
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
792 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
793 console_type_create_toolbar_x (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
794 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
795 CONSOLE_HAS_METHOD (x, output_frame_toolbars);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
796 CONSOLE_HAS_METHOD (x, initialize_frame_toolbars);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
797 CONSOLE_HAS_METHOD (x, free_frame_toolbars);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
798 CONSOLE_HAS_METHOD (x, output_toolbar_button);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
799 CONSOLE_HAS_METHOD (x, redraw_exposed_toolbars);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
800 CONSOLE_HAS_METHOD (x, redraw_frame_toolbars);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
801 }