annotate src/toolbar-msw.c @ 442:abe6d1db359e r21-2-36

Import from CVS: tag r21-2-36
author cvs
date Mon, 13 Aug 2007 11:35:02 +0200
parents 8de8e3f6228a
children 183866b06e0b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* toolbar implementation -- mswindows interface.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1995 Board of Trustees, University of Illinois.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 Copyright (C) 1995 Sun Microsystems, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4 Copyright (C) 1995, 1996 Ben Wing.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5 Copyright (C) 1996 Chuck Thompson.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 Copyright (C) 1998 Andy Piper.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 under the terms of the GNU General Public License as published by the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 Free Software Foundation; either version 2, or (at your option) any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 XEmacs is distributed in the hope that it will be useful, but WITHOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 along with XEmacs; see the file COPYING. If not, write to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 Boston, MA 02111-1307, USA. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 /* This implementation by Andy Piper <andyp@parallax.co.uk>, with bits
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 borrowed from toolbar-x.c */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 /* Synched up with: Not in FSF. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 #include "lisp.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 #include "faces.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 #include "frame.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 #include "toolbar.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 #include "window.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 #include "gui.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 #include "elhash.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 #include "console-msw.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 #include "glyphs-msw.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 #include "objects-msw.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 #define TOOLBAR_ITEM_ID_MIN 0x4000
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 #define TOOLBAR_ITEM_ID_MAX 0x7FFF
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 #define TOOLBAR_ITEM_ID_BITS(x) (((x) & 0x3FFF) | 0x4000)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 #define TOOLBAR_ID_BIAS 16
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 #define TOOLBAR_HANDLE(f,p) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 GetDlgItem(FRAME_MSWINDOWS_HANDLE(f), TOOLBAR_ID_BIAS + p)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
49
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 #define MSWINDOWS_BUTTON_SHADOW_THICKNESS 2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 #define MSWINDOWS_BLANK_SIZE 5
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 #define MSWINDOWS_MINIMUM_TOOLBAR_SIZE 8
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 mswindows_move_toolbar (struct frame *f, enum toolbar_pos pos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 #define SET_TOOLBAR_WAS_VISIBLE_FLAG(frame, pos, flag) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 do { \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 switch (pos) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 { \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 case TOP_TOOLBAR: \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 (frame)->top_toolbar_was_visible = flag; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 break; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 case BOTTOM_TOOLBAR: \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 (frame)->bottom_toolbar_was_visible = flag; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 break; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 case LEFT_TOOLBAR: \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 (frame)->left_toolbar_was_visible = flag; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 break; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 case RIGHT_TOOLBAR: \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 (frame)->right_toolbar_was_visible = flag; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 break; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 default: \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 abort (); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 } \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 } while (0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 allocate_toolbar_item_id (struct frame* f, struct toolbar_button* button,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 enum toolbar_pos pos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 /* hmm what do we generate an id based on */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 int id = TOOLBAR_ITEM_ID_BITS (internal_hash (button->callback, 0));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 while (!NILP (Fgethash (make_int (id),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 FRAME_MSWINDOWS_TOOLBAR_HASH_TABLE (f), Qnil)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 id = TOOLBAR_ITEM_ID_BITS (id + 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 return id;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 mswindows_clear_toolbar (struct frame *f, enum toolbar_pos pos,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 int thickness_change)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 HIMAGELIST ilist=NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 HWND toolbarwnd = TOOLBAR_HANDLE(f, pos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 if (toolbarwnd)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 TBBUTTON info;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 /* Delete the buttons and remove the command from the hash table*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 i = SendMessage (toolbarwnd, TB_BUTTONCOUNT, 0, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 for (i--; i >= 0; i--)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 SendMessage (toolbarwnd, TB_GETBUTTON, (WPARAM)i,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 (LPARAM)&info);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 Fremhash(make_int(info.idCommand),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 FRAME_MSWINDOWS_TOOLBAR_HASH_TABLE(f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 SendMessage (toolbarwnd, TB_DELETEBUTTON, (WPARAM)i, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 /* finally get rid of the image list assuming it clears up its
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 bitmaps */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 SendMessage (toolbarwnd, TB_GETIMAGELIST, 0, (LONG) &ilist);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 if (ilist)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 ImageList_Destroy(ilist);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 SendMessage (toolbarwnd, TB_SETIMAGELIST, 0, (LPARAM)NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 ShowWindow(toolbarwnd, SW_HIDE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
126 FRAME_MSWINDOWS_TOOLBAR_CHECKSUM (f, pos) = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 SET_TOOLBAR_WAS_VISIBLE_FLAG (f, pos, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 mswindows_output_toolbar (struct frame *f, enum toolbar_pos pos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 int x, y, bar_width, bar_height, vert;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 int width=-1, height=-1, bmwidth=0, bmheight=0, maxbmwidth, maxbmheight;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 int style_3d=0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 int border_width = FRAME_REAL_TOOLBAR_BORDER_WIDTH (f, pos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 Lisp_Object button, glyph, instance;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 Lisp_Object window = FRAME_LAST_NONMINIBUF_WINDOW (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 int nbuttons=0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 int shadow_thickness = 2; /* get this from somewhere else? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 int window_frame_width = 3;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 int padding = (border_width + shadow_thickness) * 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 unsigned int checksum=0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 struct window *w = XWINDOW (window);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 TBBUTTON* button_tbl, *tbbutton;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 HIMAGELIST ilist=NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 HWND toolbarwnd=NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 get_toolbar_coords (f, pos, &x, &y, &bar_width, &bar_height, &vert, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 /* ediff bogusly sets the height to 2 for some obscure X-specific
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 reason. This ensures that we only try and output a toolbar for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 sensible sizes */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 if (bar_width < MSWINDOWS_MINIMUM_TOOLBAR_SIZE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 bar_height < MSWINDOWS_MINIMUM_TOOLBAR_SIZE)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 if (x==1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 x=0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 toolbarwnd = TOOLBAR_HANDLE (f,pos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 /* set button sizes based on bar size */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 if (vert)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 if (style_3d)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 width = height = bar_width
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 - (window_frame_width + shadow_thickness) * 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 width = height = bar_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 maxbmwidth = maxbmheight = width - padding;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 if (style_3d)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 height = width = bar_height
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 - (window_frame_width + shadow_thickness) * 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 width = height = bar_height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 maxbmwidth = maxbmheight = width - padding;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 button = FRAME_TOOLBAR_BUTTONS (f, pos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 /* First loop over all of the buttons to determine how many there
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 are. This loop will also make sure that all instances are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 instantiated so when we actually output them they will come up
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 immediately. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 while (!NILP (button))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 struct toolbar_button *tb = XTOOLBAR_BUTTON (button);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 checksum = HASH5 (checksum,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 internal_hash (get_toolbar_button_glyph(w, tb), 0),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 internal_hash (tb->callback, 0),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 width,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 LISP_HASH (w->toolbar_buttons_captioned_p));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 button = tb->next;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 nbuttons++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 /* only rebuild if something has changed */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 if (!toolbarwnd || FRAME_MSWINDOWS_TOOLBAR_CHECKSUM(f,pos)!=checksum)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 /* remove the old one */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 mswindows_clear_toolbar (f, pos, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
218 FRAME_MSWINDOWS_TOOLBAR_CHECKSUM (f, pos)=checksum;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 /* build up the data required by win32 fns. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 button_tbl = xnew_array_and_zero (TBBUTTON, nbuttons);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 button = FRAME_TOOLBAR_BUTTONS (f, pos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 tbbutton = button_tbl;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 while (!NILP (button))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 struct toolbar_button *tb = XTOOLBAR_BUTTON (button);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 HBITMAP bitmap=NULL, mask=NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 bitmap=mask=NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 if (tb->blank)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 tbbutton->fsStyle = TBSTYLE_SEP;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 tbbutton->idCommand = allocate_toolbar_item_id (f, tb, pos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 /* currently we output the toolbar again with disabled
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 buttons it might be good to use the ms disabled code
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 instead but that means another image list, so we'll stick
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 with the emacs model. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 tbbutton->fsState = tb->enabled ? TBSTATE_ENABLED :
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 TBSTATE_INDETERMINATE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 tbbutton->fsStyle = TBSTYLE_BUTTON;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 tbbutton->dwData=0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 tbbutton->iString=0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 /* mess with the button image */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 glyph = get_toolbar_button_glyph (w, tb);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 if (GLYPHP (glyph))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 instance = glyph_image_instance (glyph, window,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 ERROR_ME_NOT, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 instance = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 if (IMAGE_INSTANCEP (instance))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
257 Lisp_Image_Instance* p = XIMAGE_INSTANCE (instance);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 if (IMAGE_INSTANCE_PIXMAP_TYPE_P (p))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 /* we are going to honor the toolbar settings
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 and resize the bitmaps accordingly if they are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 too big. If they are too small we leave them
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 and pad the difference - unless a different size
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 crops up in the middle, at which point we *have*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 to resize since the ImageList won't cope.*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 if ((bmwidth
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 IMAGE_INSTANCE_PIXMAP_WIDTH (p) != bmwidth)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 (bmheight
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 IMAGE_INSTANCE_PIXMAP_HEIGHT (p) != bmheight)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 IMAGE_INSTANCE_PIXMAP_WIDTH (p) > maxbmwidth
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 IMAGE_INSTANCE_PIXMAP_HEIGHT (p) > maxbmheight)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 if (!bmheight)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 bmheight = min (maxbmheight,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 IMAGE_INSTANCE_PIXMAP_HEIGHT (p));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 if (!bmwidth)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 bmwidth = min (maxbmwidth,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 IMAGE_INSTANCE_PIXMAP_WIDTH (p));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 if (! (bitmap = mswindows_create_resized_bitmap
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 (p, f, bmwidth, bmheight)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 xfree (button_tbl);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 if (ilist) ImageList_Destroy (ilist);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 signal_simple_error ("Couldn't resize pixmap",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 /* we don't care if the mask fails */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 mask = mswindows_create_resized_mask
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 (p, f, bmwidth, bmheight);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 if (!bmwidth)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 bmwidth = IMAGE_INSTANCE_PIXMAP_WIDTH (p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 if (!bmheight)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 bmheight = IMAGE_INSTANCE_PIXMAP_HEIGHT (p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 /* need to build an image list for the bitmaps */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 if (!ilist && !(ilist = ImageList_Create
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 ( bmwidth, bmheight,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 (IMAGE_INSTANCE_MSWINDOWS_MASK (p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 ? ILC_MASK : 0) | ILC_COLOR24,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 nbuttons, nbuttons * 2 )))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 xfree (button_tbl);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 signal_simple_error ("Couldn't create image list",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316 instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 /* make the mask actually do something */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 ImageList_SetBkColor (ilist, CLR_NONE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 /* add a bitmap to the list */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 if ((tbbutton->iBitmap =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 ImageList_Add
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 (ilist,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 bitmap ? bitmap
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 : IMAGE_INSTANCE_MSWINDOWS_BITMAP (p),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 mask ? mask
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 : IMAGE_INSTANCE_MSWINDOWS_MASK (p))) < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 xfree (button_tbl);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 if (ilist) ImageList_Destroy (ilist);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 signal_simple_error
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 ("couldn't add image to image list", instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 /* we're done with these now */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 DeleteObject (bitmap);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 DeleteObject (mask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 Fputhash (make_int (tbbutton->idCommand),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 button, FRAME_MSWINDOWS_TOOLBAR_HASH_TABLE (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 /* now fix up the button size */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 tb->x = x;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 tb->y = y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 tb->vertical = vert;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 tb->border_width = border_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 tb->width = width + MSWINDOWS_BUTTON_SHADOW_THICKNESS * 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 tb->height = height + MSWINDOWS_BUTTON_SHADOW_THICKNESS * 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 if (tb->blank)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 if (vert)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 tb->height = MSWINDOWS_BLANK_SIZE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 tb->width = MSWINDOWS_BLANK_SIZE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 if (vert)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 y += tb->height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 x += tb->width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 /* move on to the next button */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 tbbutton++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 button = tb->next;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 button = FRAME_TOOLBAR_BUTTONS (f, pos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 /* create the toolbar window? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 if (!toolbarwnd
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 (toolbarwnd =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 CreateWindowEx ( WS_EX_WINDOWEDGE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 TOOLBARCLASSNAME,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 NULL,
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
379 WS_CHILD
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 | (style_3d ? WS_DLGFRAME : 0)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
381 | TBSTYLE_TOOLTIPS
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
382 | CCS_NORESIZE
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
383 | CCS_NOPARENTALIGN | CCS_NODIVIDER
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
384 | CCS_ADJUSTABLE,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385 x, y, bar_width, bar_height,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 FRAME_MSWINDOWS_HANDLE (f),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 (HMENU)(TOOLBAR_ID_BIAS + pos),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 NULL))==NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 xfree (button_tbl);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 ImageList_Destroy (ilist);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 error ("couldn't create toolbar");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 /* finally populate with images */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 if (SendMessage (toolbarwnd, TB_BUTTONSTRUCTSIZE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 (WPARAM)sizeof(TBBUTTON), (LPARAM)0) == -1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 mswindows_clear_toolbar (f, pos, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 error ("couldn't set button structure size");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 if (vert)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 height = min (bmheight + padding, height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 width = min (bmwidth + padding, width);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 /* pad the buttons */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 SendMessage (toolbarwnd, TB_SETPADDING,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 0, MAKELPARAM(width - bmwidth, height - bmheight));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 /* set the size of buttons */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 SendMessage (toolbarwnd, TB_SETBUTTONSIZE, 0,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 (LPARAM)MAKELONG (width, height));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 /* set the size of bitmaps */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 SendMessage (toolbarwnd, TB_SETBITMAPSIZE, 0,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 (LPARAM)MAKELONG (bmwidth, bmheight));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 /* tell it we've done it */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 SendMessage (toolbarwnd, TB_AUTOSIZE, 0, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 /* finally populate with images */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425 if (!SendMessage (toolbarwnd, TB_ADDBUTTONS,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 (WPARAM)nbuttons, (LPARAM)button_tbl))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 mswindows_clear_toolbar (f, pos, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 error ("couldn't add button list to toolbar");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 /* vertical toolbars need more rows */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 if (vert)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 RECT tmp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 SendMessage (toolbarwnd, TB_SETROWS,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 MAKEWPARAM(nbuttons, FALSE), (LPARAM)&tmp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 RECT tmp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 SendMessage (toolbarwnd, TB_SETROWS, MAKEWPARAM(1, FALSE),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 (LPARAM)&tmp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 /* finally populate with images */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 if (SendMessage (toolbarwnd, TB_SETIMAGELIST, 0,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449 (LPARAM)ilist) < 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 SendMessage (toolbarwnd, TB_SETDISABLEDIMAGELIST, 0,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 (LPARAM)ilist) < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 mswindows_clear_toolbar (f, pos, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 error ("couldn't add image list to toolbar");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 /* now display the window */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 ShowWindow (toolbarwnd, SW_SHOW);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460 /* no idea why this is necessary but initial display will not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 happen otherwise. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462 mswindows_move_toolbar (f, pos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 if (button_tbl) xfree (button_tbl);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 SET_TOOLBAR_WAS_VISIBLE_FLAG (f, pos, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 mswindows_move_toolbar (struct frame *f, enum toolbar_pos pos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 int bar_x, bar_y, bar_width, bar_height, vert;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 HWND toolbarwnd = TOOLBAR_HANDLE(f,pos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 if (toolbarwnd)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478 get_toolbar_coords (f, pos, &bar_x, &bar_y, &bar_width, &bar_height,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479 &vert, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481 /* #### This terrible mangling with coordinates perhaps
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 arises from different treatment of toolbar positions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483 by Windows and by XEmacs. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 switch (pos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 case TOP_TOOLBAR:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 bar_x--; bar_y-=2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 bar_width+=3; bar_height+=3;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 case LEFT_TOOLBAR:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 bar_x--; bar_y-=2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 bar_height++; bar_width++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494 case BOTTOM_TOOLBAR:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 bar_y-=2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 bar_width+=4; bar_height+=4;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 case RIGHT_TOOLBAR:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 bar_y-=2; bar_x++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 bar_width++; bar_height++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 SetWindowPos (toolbarwnd, NULL, bar_x, bar_y,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 bar_width, bar_height, SWP_NOZORDER);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 mswindows_redraw_exposed_toolbars (struct frame *f, int x, int y, int width,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 int height)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 assert (FRAME_MSWINDOWS_P (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 if (FRAME_REAL_TOP_TOOLBAR_VISIBLE (f))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 mswindows_move_toolbar (f, TOP_TOOLBAR);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517 if (FRAME_REAL_BOTTOM_TOOLBAR_VISIBLE (f))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 mswindows_move_toolbar (f, BOTTOM_TOOLBAR);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520 if (FRAME_REAL_LEFT_TOOLBAR_VISIBLE (f))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521 mswindows_move_toolbar (f, LEFT_TOOLBAR);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 if (FRAME_REAL_RIGHT_TOOLBAR_VISIBLE (f))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 mswindows_move_toolbar (f, RIGHT_TOOLBAR);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 mswindows_redraw_frame_toolbars (struct frame *f)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530 mswindows_redraw_exposed_toolbars (f, 0, 0, FRAME_PIXWIDTH (f),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 FRAME_PIXHEIGHT (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 mswindows_initialize_frame_toolbars (struct frame *f)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541 mswindows_output_frame_toolbars (struct frame *f)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 assert (FRAME_MSWINDOWS_P (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 if (FRAME_REAL_TOP_TOOLBAR_VISIBLE (f))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546 mswindows_output_toolbar (f, TOP_TOOLBAR);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 else if (f->top_toolbar_was_visible)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 mswindows_clear_toolbar (f, TOP_TOOLBAR, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 if (FRAME_REAL_BOTTOM_TOOLBAR_VISIBLE (f))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 mswindows_output_toolbar (f, BOTTOM_TOOLBAR);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 else if (f->bottom_toolbar_was_visible)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 mswindows_clear_toolbar (f, BOTTOM_TOOLBAR, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 if (FRAME_REAL_LEFT_TOOLBAR_VISIBLE (f))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 mswindows_output_toolbar (f, LEFT_TOOLBAR);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 else if (f->left_toolbar_was_visible)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 mswindows_clear_toolbar (f, LEFT_TOOLBAR, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 if (FRAME_REAL_RIGHT_TOOLBAR_VISIBLE (f))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561 mswindows_output_toolbar (f, RIGHT_TOOLBAR);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562 else if (f->right_toolbar_was_visible)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 mswindows_clear_toolbar (f, RIGHT_TOOLBAR, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567 mswindows_free_frame_toolbars (struct frame *f)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569 HWND twnd=NULL;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
570 #define DELETE_TOOLBAR(pos) \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
571 mswindows_clear_toolbar(f, pos, 0); \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
572 if ((twnd=GetDlgItem(FRAME_MSWINDOWS_HANDLE(f), \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
573 TOOLBAR_ID_BIAS + pos))) \
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574 DestroyWindow(twnd)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576 DELETE_TOOLBAR(TOP_TOOLBAR);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577 DELETE_TOOLBAR(BOTTOM_TOOLBAR);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578 DELETE_TOOLBAR(LEFT_TOOLBAR);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579 DELETE_TOOLBAR(RIGHT_TOOLBAR);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580 #undef DELETE_TOOLBAR
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583 /* map toolbar hwnd to pos*/
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
584 static int mswindows_find_toolbar_pos(struct frame* f, HWND ctrl)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586 int id = GetDlgCtrlID(ctrl);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587 return id ? id - TOOLBAR_ID_BIAS : -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 mswindows_get_toolbar_button_text ( struct frame* f, int command_id )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 Lisp_Object button = Fgethash (make_int (command_id),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 FRAME_MSWINDOWS_TOOLBAR_HASH_TABLE (f), Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596 if (!NILP (button))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 struct toolbar_button *tb = XTOOLBAR_BUTTON (button);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 return tb->help_string;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605 * Return value is Qt if we have dispatched the command,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606 * or Qnil if id has not been mapped to a callback.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607 * Window procedure may try other targets to route the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608 * command if we return nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610 Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611 mswindows_handle_toolbar_wm_command (struct frame* f, HWND ctrl, WORD id)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
613 /* Try to map the command id through the proper hash table */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
614 Lisp_Object button, data, fn, arg, frame;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
616 button = Fgethash (make_int (id),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
617 FRAME_MSWINDOWS_TOOLBAR_HASH_TABLE (f), Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
618
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
619 if (NILP (button))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622 data = XTOOLBAR_BUTTON (button)->callback;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
623
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
624 /* #### ? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
625 if (UNBOUNDP (data))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
626 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
628 /* Ok, this is our one. Enqueue it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
629 get_gui_callback (data, &fn, &arg);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
630 XSETFRAME (frame, f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
631 mswindows_enqueue_misc_user_event (frame, fn, arg);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
632
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
633 return Qt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637 /* initialization */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
638 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 console_type_create_toolbar_mswindows (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643 CONSOLE_HAS_METHOD (mswindows, output_frame_toolbars);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644 CONSOLE_HAS_METHOD (mswindows, initialize_frame_toolbars);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 CONSOLE_HAS_METHOD (mswindows, free_frame_toolbars);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646 CONSOLE_HAS_METHOD (mswindows, redraw_exposed_toolbars);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647 CONSOLE_HAS_METHOD (mswindows, redraw_frame_toolbars);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649