annotate src/toolbar-msw.c @ 412:697ef44129c6 r21-2-14

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