annotate src/toolbar-gtk.c @ 582:0dcc097685c7

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