annotate src/toolbar-x.c @ 108:360340f9fd5f r20-1b6

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