1 | /* $Id: toolbar.c,v 1.8 1999-06-30 15:52:18 cbratschi Exp $ */
|
---|
2 | /*
|
---|
3 | * Toolbar control
|
---|
4 | *
|
---|
5 | * Copyright 1998,1999 Eric Kohl
|
---|
6 | * Copyright 1999 Achim Hasenmueller
|
---|
7 | * Copyright 1999 Christoph Bratschi
|
---|
8 | *
|
---|
9 | * TODO:
|
---|
10 | * - A little bug in TOOLBAR_DrawMasked()
|
---|
11 | * - Button wrapping (under construction).
|
---|
12 | * - Messages.
|
---|
13 | * - Notifications.
|
---|
14 | * - Fix TB_SETROWS.
|
---|
15 | * - Tooltip support (almost complete).
|
---|
16 | * - Unicode suppport.
|
---|
17 | * - Internal COMMCTL32 bitmaps.
|
---|
18 | * - Fix TOOLBAR_SetButtonInfo32A.
|
---|
19 | * - Customize dialog (under construction).
|
---|
20 | *
|
---|
21 | * Testing:
|
---|
22 | * - Run tests using Waite Group Windows95 API Bible Volume 2.
|
---|
23 | * The second cdrom contains executables addstr.exe, btncount.exe,
|
---|
24 | * btnstate.exe, butstrsz.exe, chkbtn.exe, chngbmp.exe, customiz.exe,
|
---|
25 | * enablebtn.exe, getbmp.exe, getbtn.exe, getflags.exe, hidebtn.exe,
|
---|
26 | * indetbtn.exe, insbtn.exe, pressbtn.exe, setbtnsz.exe, setcmdid.exe,
|
---|
27 | * setparnt.exe, setrows.exe, toolwnd.exe.
|
---|
28 | * - Microsofts controlspy examples.
|
---|
29 | */
|
---|
30 |
|
---|
31 | /* CB: Odin32/WINE bugs
|
---|
32 | - IMAGELIST_Draw draws a line too much at the bottom of the bitmap
|
---|
33 | */
|
---|
34 |
|
---|
35 | #include <string.h>
|
---|
36 |
|
---|
37 | #include "winbase.h"
|
---|
38 | #include "winuser.h"
|
---|
39 | #include "wingdi.h"
|
---|
40 | #include "commctrl.h"
|
---|
41 | #include "cache.h"
|
---|
42 | #include "comctl32.h"
|
---|
43 | #include "toolbar.h"
|
---|
44 |
|
---|
45 |
|
---|
46 | #define SEPARATOR_WIDTH 8
|
---|
47 | #define TOP_BORDER 2
|
---|
48 | #define BOTTOM_BORDER 2
|
---|
49 |
|
---|
50 | #define TOOLBAR_GetInfoPtr(wndPtr) ((TOOLBAR_INFO *)GetWindowLongA(hwnd,0))
|
---|
51 |
|
---|
52 |
|
---|
53 | static void
|
---|
54 | TOOLBAR_DrawFlatSeparator (LPRECT lpRect, HDC hdc)
|
---|
55 | {
|
---|
56 | INT x = (lpRect->left + lpRect->right) / 2 - 1;
|
---|
57 | INT yBottom = lpRect->bottom - 3;
|
---|
58 | INT yTop = lpRect->top + 1;
|
---|
59 |
|
---|
60 | SelectObject ( hdc, GetSysColorPen (COLOR_3DSHADOW));
|
---|
61 | MoveToEx (hdc, x, yBottom, NULL);
|
---|
62 | LineTo (hdc, x, yTop);
|
---|
63 | x++;
|
---|
64 | SelectObject ( hdc, GetSysColorPen (COLOR_3DHILIGHT));
|
---|
65 | MoveToEx (hdc, x, yBottom, NULL);
|
---|
66 | LineTo (hdc, x, yTop);
|
---|
67 | }
|
---|
68 |
|
---|
69 |
|
---|
70 | static void
|
---|
71 | TOOLBAR_DrawString (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
|
---|
72 | HDC hdc, INT nState)
|
---|
73 | {
|
---|
74 | RECT rcText = btnPtr->rect;
|
---|
75 | HFONT hOldFont;
|
---|
76 | INT nOldBkMode;
|
---|
77 | COLORREF clrOld;
|
---|
78 |
|
---|
79 | /* draw text */
|
---|
80 | if ((btnPtr->iString > -1) && (btnPtr->iString < infoPtr->nNumStrings)) {
|
---|
81 | InflateRect (&rcText, -3, -3);
|
---|
82 | rcText.top += infoPtr->nBitmapHeight;
|
---|
83 | if (nState & (TBSTATE_PRESSED | TBSTATE_CHECKED))
|
---|
84 | OffsetRect (&rcText, 1, 1);
|
---|
85 |
|
---|
86 | hOldFont = SelectObject (hdc, infoPtr->hFont);
|
---|
87 | nOldBkMode = SetBkMode (hdc, TRANSPARENT);
|
---|
88 | if (!(nState & TBSTATE_ENABLED)) {
|
---|
89 | clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DHILIGHT));
|
---|
90 | OffsetRect (&rcText, 1, 1);
|
---|
91 | DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1,
|
---|
92 | &rcText, infoPtr->dwDTFlags);
|
---|
93 | SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW));
|
---|
94 | OffsetRect (&rcText, -1, -1);
|
---|
95 | DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1,
|
---|
96 | &rcText, infoPtr->dwDTFlags);
|
---|
97 | }
|
---|
98 | else if (nState & TBSTATE_INDETERMINATE) {
|
---|
99 | clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW));
|
---|
100 | DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1,
|
---|
101 | &rcText, infoPtr->dwDTFlags);
|
---|
102 | }
|
---|
103 | else {
|
---|
104 | clrOld = SetTextColor (hdc, GetSysColor (COLOR_BTNTEXT));
|
---|
105 | DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1,
|
---|
106 | &rcText, infoPtr->dwDTFlags);
|
---|
107 | }
|
---|
108 |
|
---|
109 | SetTextColor (hdc, clrOld);
|
---|
110 | SelectObject (hdc, hOldFont);
|
---|
111 | if (nOldBkMode != TRANSPARENT)
|
---|
112 | SetBkMode (hdc, nOldBkMode);
|
---|
113 | }
|
---|
114 | }
|
---|
115 |
|
---|
116 |
|
---|
117 | static void
|
---|
118 | TOOLBAR_DrawPattern (HDC hdc, LPRECT lpRect)
|
---|
119 | {
|
---|
120 | HBRUSH hbr = SelectObject (hdc, CACHE_GetPattern55AABrush ());
|
---|
121 | INT cx = lpRect->right - lpRect->left;
|
---|
122 | INT cy = lpRect->bottom - lpRect->top;
|
---|
123 | PatBlt (hdc, lpRect->left, lpRect->top, cx, cy, 0x00FA0089);
|
---|
124 | SelectObject (hdc, hbr);
|
---|
125 | }
|
---|
126 |
|
---|
127 |
|
---|
128 | static void
|
---|
129 | TOOLBAR_DrawMasked (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
|
---|
130 | HDC hdc, INT x, INT y)
|
---|
131 | {
|
---|
132 | /* FIXME: this function is a hack since it uses image list
|
---|
133 | internals directly */
|
---|
134 |
|
---|
135 | HDC hdcImageList = CreateCompatibleDC (0);
|
---|
136 | HDC hdcMask = CreateCompatibleDC (0);
|
---|
137 | HIMAGELIST himl = infoPtr->himlStd;
|
---|
138 | HBITMAP hbmMask;
|
---|
139 |
|
---|
140 | /* create new bitmap */
|
---|
141 | hbmMask = CreateBitmap (himl->cx, himl->cy, 1, 1, NULL);
|
---|
142 | SelectObject (hdcMask, hbmMask);
|
---|
143 |
|
---|
144 | /* copy the mask bitmap */
|
---|
145 | SelectObject (hdcImageList, himl->hbmMask);
|
---|
146 | SetBkColor (hdcImageList, RGB(255, 255, 255));
|
---|
147 | SetTextColor (hdcImageList, RGB(0, 0, 0));
|
---|
148 | BitBlt (hdcMask, 0, 0, himl->cx, himl->cy,
|
---|
149 | hdcImageList, himl->cx * btnPtr->iBitmap, 0, SRCCOPY);
|
---|
150 |
|
---|
151 | #if 0
|
---|
152 | /* add white mask from image */
|
---|
153 | SelectObject (hdcImageList, himl->hbmImage);
|
---|
154 | SetBkColor (hdcImageList, RGB(0, 0, 0));
|
---|
155 | BitBlt (hdcMask, 0, 0, himl->cx, himl->cy,
|
---|
156 | hdcImageList, himl->cx * btnPtr->iBitmap, 0, MERGEPAINT);
|
---|
157 | #endif
|
---|
158 |
|
---|
159 | /* draw the new mask */
|
---|
160 | SelectObject (hdc, GetSysColorBrush (COLOR_3DHILIGHT));
|
---|
161 | BitBlt (hdc, x+1, y+1, himl->cx, himl->cy,
|
---|
162 | hdcMask, 0, 0, 0xB8074A);
|
---|
163 |
|
---|
164 | SelectObject (hdc, GetSysColorBrush (COLOR_3DSHADOW));
|
---|
165 | BitBlt (hdc, x, y, himl->cx, himl->cy,
|
---|
166 | hdcMask, 0, 0, 0xB8074A);
|
---|
167 |
|
---|
168 | DeleteObject (hbmMask);
|
---|
169 | DeleteDC (hdcMask);
|
---|
170 | DeleteDC (hdcImageList);
|
---|
171 | }
|
---|
172 |
|
---|
173 |
|
---|
174 | static void
|
---|
175 | TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc)
|
---|
176 | {
|
---|
177 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
178 | DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
|
---|
179 | RECT rc;
|
---|
180 |
|
---|
181 | if (btnPtr->fsState & TBSTATE_HIDDEN) return;
|
---|
182 |
|
---|
183 | rc = btnPtr->rect;
|
---|
184 | if (btnPtr->fsStyle & TBSTYLE_SEP)
|
---|
185 | {
|
---|
186 | if ((dwStyle & TBSTYLE_FLAT) && (btnPtr->idCommand == 0))
|
---|
187 | TOOLBAR_DrawFlatSeparator (&btnPtr->rect, hdc);
|
---|
188 | return;
|
---|
189 | }
|
---|
190 |
|
---|
191 | /* disabled */
|
---|
192 | if (!(btnPtr->fsState & TBSTATE_ENABLED))
|
---|
193 | {
|
---|
194 | DrawEdge (hdc, &rc, EDGE_RAISED,
|
---|
195 | BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
|
---|
196 |
|
---|
197 | if (dwStyle & TBSTYLE_FLAT)
|
---|
198 | {
|
---|
199 | /* if (infoPtr->himlDis) */
|
---|
200 | ImageList_Draw (infoPtr->himlDis, btnPtr->iBitmap, hdc,
|
---|
201 | rc.left+1, rc.top+1, ILD_NORMAL);
|
---|
202 | /* else */
|
---|
203 | /* TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left+1, rc.top+1); */
|
---|
204 | } else
|
---|
205 | TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left+1, rc.top+1);
|
---|
206 |
|
---|
207 | TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
|
---|
208 | return;
|
---|
209 | }
|
---|
210 |
|
---|
211 | /* pressed TBSTYLE_BUTTON */
|
---|
212 | if (btnPtr->fsState & TBSTATE_PRESSED)
|
---|
213 | {
|
---|
214 | DrawEdge (hdc, &rc, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST);
|
---|
215 | ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc,
|
---|
216 | rc.left+2, rc.top+2, ILD_NORMAL);
|
---|
217 | TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
|
---|
218 | return;
|
---|
219 | }
|
---|
220 |
|
---|
221 | /* checked TBSTYLE_CHECK*/
|
---|
222 | if ((btnPtr->fsStyle & TBSTYLE_CHECK) &&
|
---|
223 | (btnPtr->fsState & TBSTATE_CHECKED)) {
|
---|
224 | if (dwStyle & TBSTYLE_FLAT)
|
---|
225 | DrawEdge (hdc, &rc, BDR_SUNKENOUTER,
|
---|
226 | BF_RECT | BF_MIDDLE | BF_ADJUST);
|
---|
227 | else
|
---|
228 | DrawEdge (hdc, &rc, EDGE_SUNKEN,
|
---|
229 | BF_RECT | BF_MIDDLE | BF_ADJUST);
|
---|
230 |
|
---|
231 | TOOLBAR_DrawPattern (hdc, &rc);
|
---|
232 | if (dwStyle & TBSTYLE_FLAT)
|
---|
233 | {
|
---|
234 | if (infoPtr->himlDef != NULL)
|
---|
235 | ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
|
---|
236 | rc.left+2, rc.top+2, ILD_NORMAL);
|
---|
237 | else
|
---|
238 | ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc,
|
---|
239 | rc.left+2, rc.top+2, ILD_NORMAL);
|
---|
240 | } else
|
---|
241 | ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc,
|
---|
242 | rc.left+2, rc.top+2, ILD_NORMAL);
|
---|
243 | TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
|
---|
244 | return;
|
---|
245 | }
|
---|
246 |
|
---|
247 | /* indeterminate */
|
---|
248 | if (btnPtr->fsState & TBSTATE_INDETERMINATE)
|
---|
249 | {
|
---|
250 | DrawEdge (hdc, &rc, EDGE_RAISED,
|
---|
251 | BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
|
---|
252 |
|
---|
253 | TOOLBAR_DrawPattern (hdc, &rc);
|
---|
254 | TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left+1, rc.top+1);
|
---|
255 | TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
|
---|
256 | return;
|
---|
257 | }
|
---|
258 |
|
---|
259 | if (dwStyle & TBSTYLE_FLAT)
|
---|
260 | {
|
---|
261 | if(btnPtr->bHot)
|
---|
262 | DrawEdge (hdc, &rc, BDR_RAISEDINNER,
|
---|
263 | BF_RECT | BF_MIDDLE | BF_SOFT);
|
---|
264 |
|
---|
265 | if(infoPtr->himlDef != NULL)
|
---|
266 | ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
|
---|
267 | rc.left +2, rc.top +2, ILD_NORMAL);
|
---|
268 | else
|
---|
269 | ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc,
|
---|
270 | rc.left +2, rc.top +2, ILD_NORMAL);
|
---|
271 | } else
|
---|
272 | {
|
---|
273 | /* normal state */
|
---|
274 | DrawEdge (hdc, &rc, EDGE_RAISED,
|
---|
275 | BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
|
---|
276 |
|
---|
277 | ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc,
|
---|
278 | rc.left+1, rc.top+1, ILD_NORMAL);
|
---|
279 | }
|
---|
280 |
|
---|
281 | TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
|
---|
282 | }
|
---|
283 |
|
---|
284 |
|
---|
285 | static void
|
---|
286 | TOOLBAR_Refresh (HWND hwnd, HDC hdc)
|
---|
287 | {
|
---|
288 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
289 | TBUTTON_INFO *btnPtr;
|
---|
290 | INT i;
|
---|
291 |
|
---|
292 | /* draw buttons */
|
---|
293 | btnPtr = infoPtr->buttons;
|
---|
294 | for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++)
|
---|
295 | TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
|
---|
296 | }
|
---|
297 |
|
---|
298 |
|
---|
299 | static void
|
---|
300 | TOOLBAR_CalcStrings (HWND hwnd, LPSIZE lpSize)
|
---|
301 | {
|
---|
302 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
303 | TBUTTON_INFO *btnPtr;
|
---|
304 | INT i;
|
---|
305 | HDC hdc;
|
---|
306 | HFONT hOldFont;
|
---|
307 | SIZE sz;
|
---|
308 |
|
---|
309 | lpSize->cx = 0;
|
---|
310 | lpSize->cy = 0;
|
---|
311 | hdc = GetDC (0);
|
---|
312 | hOldFont = SelectObject (hdc, infoPtr->hFont);
|
---|
313 |
|
---|
314 | btnPtr = infoPtr->buttons;
|
---|
315 | for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
|
---|
316 | if (!(btnPtr->fsState & TBSTATE_HIDDEN) &&
|
---|
317 | (btnPtr->iString > -1) &&
|
---|
318 | (btnPtr->iString < infoPtr->nNumStrings)) {
|
---|
319 | LPWSTR lpText = infoPtr->strings[btnPtr->iString];
|
---|
320 | GetTextExtentPoint32W (hdc, lpText, lstrlenW (lpText), &sz);
|
---|
321 | if (sz.cx > lpSize->cx)
|
---|
322 | lpSize->cx = sz.cx;
|
---|
323 | if (sz.cy > lpSize->cy)
|
---|
324 | lpSize->cy = sz.cy;
|
---|
325 | }
|
---|
326 | }
|
---|
327 |
|
---|
328 | SelectObject (hdc, hOldFont);
|
---|
329 | ReleaseDC (0, hdc);
|
---|
330 |
|
---|
331 | // TRACE (toolbar, "string size %d x %d!\n", lpSize->cx, lpSize->cy);
|
---|
332 | }
|
---|
333 |
|
---|
334 | /***********************************************************************
|
---|
335 | * TOOLBAR_WrapToolbar
|
---|
336 | *
|
---|
337 | * This function walks through the buttons and seperators in the
|
---|
338 | * toolbar, and sets the TBSTATE_WRAP flag only on those items where
|
---|
339 | * wrapping should occur based on the width of the toolbar window.
|
---|
340 | * It does *not* calculate button placement itself. That task
|
---|
341 | * takes place in TOOLBAR_CalcToolbar. If the program wants to manage
|
---|
342 | * the toolbar wrapping on it's own, it can use the TBSTYLE_WRAPPABLE
|
---|
343 | * flag, and set the TBSTATE_WRAP flags manually on the appropriate items.
|
---|
344 | */
|
---|
345 |
|
---|
346 | static void
|
---|
347 | TOOLBAR_WrapToolbar( HWND hwnd )
|
---|
348 | {
|
---|
349 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
350 | TBUTTON_INFO *btnPtr;
|
---|
351 | DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
|
---|
352 | INT x, cx, i, j;
|
---|
353 | RECT rc;
|
---|
354 | BOOL bWrap, bButtonWrap;
|
---|
355 |
|
---|
356 | /* When the toolbar window style is not TBSTYLE_WRAPABLE, */
|
---|
357 | /* no layout is necessary. Applications may use this style */
|
---|
358 | /* to perform their own layout on the toolbar. */
|
---|
359 | if( !(dwStyle & TBSTYLE_WRAPABLE) )
|
---|
360 | return;
|
---|
361 |
|
---|
362 | btnPtr = infoPtr->buttons;
|
---|
363 | x = infoPtr->nIndent;
|
---|
364 |
|
---|
365 | GetClientRect( GetParent(hwnd), &rc );
|
---|
366 | infoPtr->nWidth = rc.right - rc.left;
|
---|
367 | bButtonWrap = FALSE;
|
---|
368 |
|
---|
369 | for (i = 0; i < infoPtr->nNumButtons; i++ )
|
---|
370 | {
|
---|
371 | bWrap = FALSE;
|
---|
372 | btnPtr[i].fsState &= ~TBSTATE_WRAP;
|
---|
373 |
|
---|
374 | if (btnPtr[i].fsState & TBSTATE_HIDDEN)
|
---|
375 | continue;
|
---|
376 |
|
---|
377 | /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
|
---|
378 | /* it is the actual width of the separator. This is used for */
|
---|
379 | /* custom controls in toolbars. */
|
---|
380 | if (btnPtr[i].fsStyle & TBSTYLE_SEP)
|
---|
381 | cx = (btnPtr[i].iBitmap > 0) ?
|
---|
382 | btnPtr[i].iBitmap : SEPARATOR_WIDTH;
|
---|
383 | else
|
---|
384 | cx = infoPtr->nButtonWidth;
|
---|
385 |
|
---|
386 | /* Two or more adjacent separators form a separator group. */
|
---|
387 | /* The first separator in a group should be wrapped to the */
|
---|
388 | /* next row if the previous wrapping is on a button. */
|
---|
389 | if( bButtonWrap &&
|
---|
390 | (btnPtr[i].fsStyle & TBSTYLE_SEP) &&
|
---|
391 | (i + 1 < infoPtr->nNumButtons ) &&
|
---|
392 | (btnPtr[i + 1].fsStyle & TBSTYLE_SEP) )
|
---|
393 | {
|
---|
394 | btnPtr[i].fsState |= TBSTATE_WRAP;
|
---|
395 | x = infoPtr->nIndent;
|
---|
396 | i++;
|
---|
397 | bButtonWrap = FALSE;
|
---|
398 | continue;
|
---|
399 | }
|
---|
400 |
|
---|
401 | /* The layout makes sure the bitmap is visible, but not the button. */
|
---|
402 | if ( x + cx - (infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2
|
---|
403 | > infoPtr->nWidth )
|
---|
404 | {
|
---|
405 | BOOL bFound = FALSE;
|
---|
406 |
|
---|
407 | /* If the current button is a separator and not hidden, */
|
---|
408 | /* go to the next until it reaches a non separator. */
|
---|
409 | /* Wrap the last separator if it is before a button. */
|
---|
410 | while( ( (btnPtr[i].fsStyle & TBSTYLE_SEP) ||
|
---|
411 | (btnPtr[i].fsState & TBSTATE_HIDDEN) ) &&
|
---|
412 | i < infoPtr->nNumButtons )
|
---|
413 | {
|
---|
414 | i++;
|
---|
415 | bFound = TRUE;
|
---|
416 | }
|
---|
417 |
|
---|
418 | if( bFound && i < infoPtr->nNumButtons )
|
---|
419 | {
|
---|
420 | i--;
|
---|
421 | btnPtr[i].fsState |= TBSTATE_WRAP;
|
---|
422 | x = infoPtr->nIndent;
|
---|
423 | bButtonWrap = FALSE;
|
---|
424 | continue;
|
---|
425 | }
|
---|
426 | else if ( i >= infoPtr->nNumButtons)
|
---|
427 | break;
|
---|
428 |
|
---|
429 | /* If the current button is not a separator, find the last */
|
---|
430 | /* separator and wrap it. */
|
---|
431 | for ( j = i - 1; j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
|
---|
432 | {
|
---|
433 | if ((btnPtr[j].fsStyle & TBSTYLE_SEP) &&
|
---|
434 | !(btnPtr[j].fsState & TBSTATE_HIDDEN))
|
---|
435 | {
|
---|
436 | bFound = TRUE;
|
---|
437 | i = j;
|
---|
438 | x = infoPtr->nIndent;
|
---|
439 | btnPtr[j].fsState |= TBSTATE_WRAP;
|
---|
440 | bButtonWrap = FALSE;
|
---|
441 | break;
|
---|
442 | }
|
---|
443 | }
|
---|
444 |
|
---|
445 | /* If no separator available for wrapping, wrap one of */
|
---|
446 | /* non-hidden previous button. */
|
---|
447 | if (!bFound)
|
---|
448 | {
|
---|
449 | for ( j = i - 1;
|
---|
450 | j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
|
---|
451 | {
|
---|
452 | if (btnPtr[j].fsState & TBSTATE_HIDDEN)
|
---|
453 | continue;
|
---|
454 |
|
---|
455 | bFound = TRUE;
|
---|
456 | i = j;
|
---|
457 | x = infoPtr->nIndent;
|
---|
458 | btnPtr[j].fsState |= TBSTATE_WRAP;
|
---|
459 | bButtonWrap = TRUE;
|
---|
460 | break;
|
---|
461 | }
|
---|
462 | }
|
---|
463 |
|
---|
464 | /* If all above failed, wrap the current button. */
|
---|
465 | if (!bFound)
|
---|
466 | {
|
---|
467 | btnPtr[i].fsState |= TBSTATE_WRAP;
|
---|
468 | bFound = TRUE;
|
---|
469 | x = infoPtr->nIndent;
|
---|
470 | if (btnPtr[i].fsState & TBSTYLE_SEP )
|
---|
471 | bButtonWrap = FALSE;
|
---|
472 | else
|
---|
473 | bButtonWrap = TRUE;
|
---|
474 | }
|
---|
475 | }
|
---|
476 | else
|
---|
477 | x += cx;
|
---|
478 | }
|
---|
479 | }
|
---|
480 |
|
---|
481 | /***********************************************************************
|
---|
482 | * TOOLBAR_CalcToolbar
|
---|
483 | *
|
---|
484 | * This function calculates button and separator placement. It first
|
---|
485 | * calculates the button sizes, gets the toolbar window width and then
|
---|
486 | * calls TOOLBAR_WrapToolbar to determine which buttons we need to wrap
|
---|
487 | * on. It assigns a new location to each item and sends this location to
|
---|
488 | * the tooltip window if appropriate. Finally, it updates the rcBound
|
---|
489 | * rect and calculates the new required toolbar window height.
|
---|
490 | */
|
---|
491 |
|
---|
492 | static void
|
---|
493 | TOOLBAR_CalcToolbar (HWND hwnd)
|
---|
494 | {
|
---|
495 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
|
---|
496 | TBUTTON_INFO *btnPtr;
|
---|
497 | INT i, nRows, nSepRows;
|
---|
498 | INT x, y, cx, cy;
|
---|
499 | SIZE sizeString;
|
---|
500 | RECT rc;
|
---|
501 | BOOL bWrap;
|
---|
502 |
|
---|
503 | TOOLBAR_CalcStrings (hwnd, &sizeString);
|
---|
504 |
|
---|
505 | if (sizeString.cy > 0)
|
---|
506 | infoPtr->nButtonHeight = sizeString.cy + infoPtr->nBitmapHeight + 6;
|
---|
507 | else if (infoPtr->nButtonHeight < infoPtr->nBitmapHeight + 6)
|
---|
508 | infoPtr->nButtonHeight = infoPtr->nBitmapHeight + 6;
|
---|
509 |
|
---|
510 | if (sizeString.cx > infoPtr->nBitmapWidth)
|
---|
511 | infoPtr->nButtonWidth = sizeString.cx + 6;
|
---|
512 | else if (infoPtr->nButtonWidth < infoPtr->nBitmapWidth + 6)
|
---|
513 | infoPtr->nButtonWidth = infoPtr->nBitmapWidth + 6;
|
---|
514 |
|
---|
515 | TOOLBAR_WrapToolbar( hwnd );
|
---|
516 |
|
---|
517 | x = infoPtr->nIndent;
|
---|
518 | y = TOP_BORDER;
|
---|
519 | cx = infoPtr->nButtonWidth;
|
---|
520 | cy = infoPtr->nButtonHeight;
|
---|
521 | nRows = nSepRows = 0;
|
---|
522 |
|
---|
523 | infoPtr->rcBound.top = y;
|
---|
524 | infoPtr->rcBound.left = x;
|
---|
525 | infoPtr->rcBound.bottom = y + cy;
|
---|
526 | infoPtr->rcBound.right = x;
|
---|
527 |
|
---|
528 | btnPtr = infoPtr->buttons;
|
---|
529 | GetClientRect( GetParent(hwnd), &rc );
|
---|
530 | infoPtr->nWidth = rc.right - rc.left;
|
---|
531 |
|
---|
532 | for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++ )
|
---|
533 | {
|
---|
534 | bWrap = FALSE;
|
---|
535 | if (btnPtr->fsState & TBSTATE_HIDDEN)
|
---|
536 | {
|
---|
537 | SetRectEmpty (&btnPtr->rect);
|
---|
538 | continue;
|
---|
539 | }
|
---|
540 |
|
---|
541 | /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
|
---|
542 | /* it is the actual width of the separator. This is used for */
|
---|
543 | /* custom controls in toolbars. */
|
---|
544 | if (btnPtr->fsStyle & TBSTYLE_SEP)
|
---|
545 | cx = (btnPtr->iBitmap > 0) ?
|
---|
546 | btnPtr->iBitmap : SEPARATOR_WIDTH;
|
---|
547 | else
|
---|
548 | cx = infoPtr->nButtonWidth;
|
---|
549 |
|
---|
550 | if (btnPtr->fsState & TBSTATE_WRAP )
|
---|
551 | bWrap = TRUE;
|
---|
552 |
|
---|
553 | SetRect (&btnPtr->rect, x, y, x + cx, y + cy);
|
---|
554 |
|
---|
555 | if (infoPtr->rcBound.left > x)
|
---|
556 | infoPtr->rcBound.left = x;
|
---|
557 | if (infoPtr->rcBound.right < x + cx)
|
---|
558 | infoPtr->rcBound.right = x + cx;
|
---|
559 | if (infoPtr->rcBound.bottom < y + cy)
|
---|
560 | infoPtr->rcBound.bottom = y + cy;
|
---|
561 |
|
---|
562 | /* Set the toolTip only for non-hidden, non-separator button */
|
---|
563 | if (infoPtr->hwndToolTip && !(btnPtr->fsStyle & TBSTYLE_SEP))
|
---|
564 | {
|
---|
565 | TTTOOLINFOA ti;
|
---|
566 |
|
---|
567 | ZeroMemory (&ti,sizeof(TTTOOLINFOA));
|
---|
568 | ti.cbSize = sizeof(TTTOOLINFOA);
|
---|
569 | ti.hwnd = hwnd;
|
---|
570 | ti.uId = btnPtr->idCommand;
|
---|
571 | ti.rect = btnPtr->rect;
|
---|
572 | SendMessageA(infoPtr->hwndToolTip,TTM_NEWTOOLRECTA,0,(LPARAM)&ti);
|
---|
573 | }
|
---|
574 |
|
---|
575 | /* btnPtr->nRow is zero based. The space between the rows is */
|
---|
576 | /* also considered as a row. */
|
---|
577 | btnPtr->nRow = nRows + nSepRows;
|
---|
578 | if( bWrap )
|
---|
579 | {
|
---|
580 | if ( !(btnPtr->fsStyle & TBSTYLE_SEP) )
|
---|
581 | y += cy;
|
---|
582 | else
|
---|
583 | {
|
---|
584 | /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
|
---|
585 | /* it is the actual width of the separator. This is used for */
|
---|
586 | /* custom controls in toolbars. */
|
---|
587 | y += cy + ( (btnPtr->iBitmap > 0 ) ?
|
---|
588 | btnPtr->iBitmap : SEPARATOR_WIDTH) * 2 /3;
|
---|
589 |
|
---|
590 | /* nSepRows is used to calculate the extra height follwoing */
|
---|
591 | /* the last row. */
|
---|
592 | nSepRows++;
|
---|
593 | }
|
---|
594 | x = infoPtr->nIndent;
|
---|
595 | nRows++;
|
---|
596 | }
|
---|
597 | else
|
---|
598 | x += cx;
|
---|
599 | }
|
---|
600 |
|
---|
601 | /* infoPtr->nRows is the number of rows on the toolbar */
|
---|
602 | infoPtr->nRows = nRows + nSepRows + 1;
|
---|
603 |
|
---|
604 | /* nSepRows * (infoPtr->nBitmapHeight + 1) is the space following */
|
---|
605 | /* the last row. */
|
---|
606 | infoPtr->nHeight = TOP_BORDER + (nRows + 1) * infoPtr->nButtonHeight +
|
---|
607 | nSepRows * SEPARATOR_WIDTH * 2 / 3 +
|
---|
608 | nSepRows * (infoPtr->nBitmapHeight + 1) +
|
---|
609 | BOTTOM_BORDER;
|
---|
610 | // TRACE (toolbar, "toolbar height %d\n", infoPtr->nHeight);
|
---|
611 | }
|
---|
612 |
|
---|
613 |
|
---|
614 | static INT
|
---|
615 | TOOLBAR_InternalHitTest (HWND hwnd, LPPOINT lpPt)
|
---|
616 | {
|
---|
617 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
618 | TBUTTON_INFO *btnPtr;
|
---|
619 | INT i;
|
---|
620 |
|
---|
621 | btnPtr = infoPtr->buttons;
|
---|
622 | for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
|
---|
623 | if (btnPtr->fsState & TBSTATE_HIDDEN)
|
---|
624 | continue;
|
---|
625 |
|
---|
626 | if (btnPtr->fsStyle & TBSTYLE_SEP) {
|
---|
627 | if (PtInRect (&btnPtr->rect, *lpPt)) {
|
---|
628 | // TRACE (toolbar, " ON SEPARATOR %d!\n", i);
|
---|
629 | return -i;
|
---|
630 | }
|
---|
631 | }
|
---|
632 | else {
|
---|
633 | if (PtInRect (&btnPtr->rect, *lpPt)) {
|
---|
634 | // TRACE (toolbar, " ON BUTTON %d!\n", i);
|
---|
635 | return i;
|
---|
636 | }
|
---|
637 | }
|
---|
638 | }
|
---|
639 |
|
---|
640 | // TRACE (toolbar, " NOWHERE!\n");
|
---|
641 | return -1;
|
---|
642 | }
|
---|
643 |
|
---|
644 |
|
---|
645 | static INT
|
---|
646 | TOOLBAR_GetButtonIndex (TOOLBAR_INFO *infoPtr, INT idCommand)
|
---|
647 | {
|
---|
648 | TBUTTON_INFO *btnPtr;
|
---|
649 | INT i;
|
---|
650 |
|
---|
651 | btnPtr = infoPtr->buttons;
|
---|
652 | for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
|
---|
653 | if (btnPtr->idCommand == idCommand) {
|
---|
654 | // TRACE (toolbar, "command=%d index=%d\n", idCommand, i);
|
---|
655 | return i;
|
---|
656 | }
|
---|
657 | }
|
---|
658 | // TRACE (toolbar, "no index found for command=%d\n", idCommand);
|
---|
659 | return -1;
|
---|
660 | }
|
---|
661 |
|
---|
662 |
|
---|
663 | static INT
|
---|
664 | TOOLBAR_GetCheckedGroupButtonIndex (TOOLBAR_INFO *infoPtr, INT nIndex)
|
---|
665 | {
|
---|
666 | TBUTTON_INFO *btnPtr;
|
---|
667 | INT nRunIndex;
|
---|
668 |
|
---|
669 | if ((nIndex < 0) || (nIndex > infoPtr->nNumButtons))
|
---|
670 | return -1;
|
---|
671 |
|
---|
672 | /* check index button */
|
---|
673 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
674 | if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
|
---|
675 | if (btnPtr->fsState & TBSTATE_CHECKED)
|
---|
676 | return nIndex;
|
---|
677 | }
|
---|
678 |
|
---|
679 | /* check previous buttons */
|
---|
680 | nRunIndex = nIndex - 1;
|
---|
681 | while (nRunIndex >= 0) {
|
---|
682 | btnPtr = &infoPtr->buttons[nRunIndex];
|
---|
683 | if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
|
---|
684 | if (btnPtr->fsState & TBSTATE_CHECKED)
|
---|
685 | return nRunIndex;
|
---|
686 | }
|
---|
687 | else
|
---|
688 | break;
|
---|
689 | nRunIndex--;
|
---|
690 | }
|
---|
691 |
|
---|
692 | /* check next buttons */
|
---|
693 | nRunIndex = nIndex + 1;
|
---|
694 | while (nRunIndex < infoPtr->nNumButtons) {
|
---|
695 | btnPtr = &infoPtr->buttons[nRunIndex];
|
---|
696 | if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
|
---|
697 | if (btnPtr->fsState & TBSTATE_CHECKED)
|
---|
698 | return nRunIndex;
|
---|
699 | }
|
---|
700 | else
|
---|
701 | break;
|
---|
702 | nRunIndex++;
|
---|
703 | }
|
---|
704 |
|
---|
705 | return -1;
|
---|
706 | }
|
---|
707 |
|
---|
708 |
|
---|
709 | static VOID
|
---|
710 | TOOLBAR_RelayEvent (HWND hwndTip, HWND hwndMsg, UINT uMsg,
|
---|
711 | WPARAM wParam, LPARAM lParam)
|
---|
712 | {
|
---|
713 | MSG msg;
|
---|
714 |
|
---|
715 | msg.hwnd = hwndMsg;
|
---|
716 | msg.message = uMsg;
|
---|
717 | msg.wParam = wParam;
|
---|
718 | msg.lParam = lParam;
|
---|
719 | msg.time = GetMessageTime();
|
---|
720 | msg.pt.x = LOWORD(GetMessagePos());
|
---|
721 | msg.pt.y = HIWORD(GetMessagePos());
|
---|
722 |
|
---|
723 | SendMessageA(hwndTip,TTM_RELAYEVENT,0,(LPARAM)&msg);
|
---|
724 | }
|
---|
725 |
|
---|
726 |
|
---|
727 | /***********************************************************************
|
---|
728 | * TOOLBAR_CustomizeDialogProc
|
---|
729 | * This function implements the toolbar customization dialog.
|
---|
730 | */
|
---|
731 | BOOL WINAPI
|
---|
732 | TOOLBAR_CustomizeDialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
---|
733 | {
|
---|
734 | TOOLBAR_INFO *infoPtr = (TOOLBAR_INFO *)GetWindowLongA (hwnd, DWL_USER);
|
---|
735 | static HDSA hDsa = NULL;
|
---|
736 |
|
---|
737 | switch (uMsg)
|
---|
738 | {
|
---|
739 | case WM_INITDIALOG:
|
---|
740 | infoPtr = (TOOLBAR_INFO *)lParam;
|
---|
741 | SetWindowLongA (hwnd, DWL_USER, (DWORD)infoPtr);
|
---|
742 |
|
---|
743 | hDsa = DSA_Create (sizeof(TBUTTON_INFO), 5);
|
---|
744 |
|
---|
745 | if (infoPtr)
|
---|
746 | {
|
---|
747 | TBUTTON_INFO *btnPtr;
|
---|
748 | INT i;
|
---|
749 |
|
---|
750 | /* insert 'virtual' separator button into 'available buttons' list */
|
---|
751 | SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)"");
|
---|
752 |
|
---|
753 | /* copy all buttons and append them to the right listbox */
|
---|
754 | btnPtr = infoPtr->buttons;
|
---|
755 | for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++)
|
---|
756 | {
|
---|
757 | DSA_InsertItem (hDsa, i, btnPtr);
|
---|
758 |
|
---|
759 | if (btnPtr->fsState & TBSTATE_HIDDEN)
|
---|
760 | {
|
---|
761 | SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)"");
|
---|
762 | }
|
---|
763 | else
|
---|
764 | {
|
---|
765 | SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)"");
|
---|
766 | }
|
---|
767 | }
|
---|
768 |
|
---|
769 | /* append 'virtual' sepatator button to the 'toolbar buttons' list */
|
---|
770 | /* TODO */
|
---|
771 | }
|
---|
772 | return TRUE;
|
---|
773 |
|
---|
774 | case WM_CLOSE:
|
---|
775 | EndDialog(hwnd, FALSE);
|
---|
776 | return TRUE;
|
---|
777 |
|
---|
778 | case WM_COMMAND:
|
---|
779 | switch (LOWORD(wParam))
|
---|
780 | {
|
---|
781 | case IDCANCEL:
|
---|
782 | EndDialog(hwnd, FALSE);
|
---|
783 | break;
|
---|
784 | }
|
---|
785 | return TRUE;
|
---|
786 |
|
---|
787 | case WM_DESTROY:
|
---|
788 | if (hDsa)
|
---|
789 | DSA_Destroy (hDsa);
|
---|
790 | return TRUE;
|
---|
791 |
|
---|
792 | case WM_DRAWITEM:
|
---|
793 | if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX)
|
---|
794 | {
|
---|
795 | LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
|
---|
796 | RECT rcButton;
|
---|
797 | RECT rcText;
|
---|
798 | HPEN hOldPen;
|
---|
799 | HBRUSH hOldBrush;
|
---|
800 | COLORREF oldText = 0;
|
---|
801 | COLORREF oldBk = 0;
|
---|
802 |
|
---|
803 | // FIXME(toolbar, "action: %x itemState: %x\n",
|
---|
804 | // lpdis->itemAction, lpdis->itemState);
|
---|
805 |
|
---|
806 | if (lpdis->itemState & ODS_FOCUS)
|
---|
807 | {
|
---|
808 | oldBk = SetBkColor (lpdis->hDC, GetSysColor(COLOR_HIGHLIGHT));
|
---|
809 | oldText = SetTextColor (lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
|
---|
810 | }
|
---|
811 |
|
---|
812 | hOldPen = SelectObject (lpdis->hDC, GetSysColorPen ((lpdis->itemState & ODS_SELECTED)?COLOR_HIGHLIGHT:COLOR_WINDOW));
|
---|
813 | hOldBrush = SelectObject (lpdis->hDC, GetSysColorBrush ((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW));
|
---|
814 |
|
---|
815 | /* fill background rectangle */
|
---|
816 | Rectangle (lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top,
|
---|
817 | lpdis->rcItem.right, lpdis->rcItem.bottom);
|
---|
818 |
|
---|
819 | /* calculate button and text rectangles */
|
---|
820 | CopyRect (&rcButton, &lpdis->rcItem);
|
---|
821 | InflateRect (&rcButton, -1, -1);
|
---|
822 | CopyRect (&rcText, &rcButton);
|
---|
823 | rcButton.right = rcButton.left + infoPtr->nBitmapWidth + 6;
|
---|
824 | rcText.left = rcButton.right + 2;
|
---|
825 |
|
---|
826 | /* draw focus rectangle */
|
---|
827 | if (lpdis->itemState & ODS_FOCUS)
|
---|
828 | DrawFocusRect (lpdis->hDC, &lpdis->rcItem);
|
---|
829 |
|
---|
830 | /* draw button */
|
---|
831 | DrawEdge (lpdis->hDC, &rcButton, EDGE_RAISED, BF_RECT|BF_MIDDLE|BF_SOFT);
|
---|
832 |
|
---|
833 | /* draw text */
|
---|
834 | if (wParam == IDC_AVAILBTN_LBOX && lpdis->itemID == 0)
|
---|
835 | DrawTextA (lpdis->hDC, "Separator", -1, &rcText,
|
---|
836 | DT_LEFT | DT_VCENTER | DT_SINGLELINE);
|
---|
837 |
|
---|
838 | if (lpdis->itemState & ODS_FOCUS)
|
---|
839 | {
|
---|
840 | SetBkColor (lpdis->hDC, oldBk);
|
---|
841 | SetTextColor (lpdis->hDC, oldText);
|
---|
842 | }
|
---|
843 |
|
---|
844 | SelectObject (lpdis->hDC, hOldBrush);
|
---|
845 | SelectObject (lpdis->hDC, hOldPen);
|
---|
846 |
|
---|
847 | return TRUE;
|
---|
848 | }
|
---|
849 | return FALSE;
|
---|
850 |
|
---|
851 | case WM_MEASUREITEM:
|
---|
852 | if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX)
|
---|
853 | {
|
---|
854 | MEASUREITEMSTRUCT *lpmis = (MEASUREITEMSTRUCT*)lParam;
|
---|
855 |
|
---|
856 | if (infoPtr)
|
---|
857 | lpmis->itemHeight = infoPtr->nBitmapHeight + 8;
|
---|
858 | else
|
---|
859 | lpmis->itemHeight = 16 + 8; /* default height */
|
---|
860 |
|
---|
861 | return TRUE;
|
---|
862 | }
|
---|
863 | return FALSE;
|
---|
864 |
|
---|
865 | default:
|
---|
866 | return FALSE;
|
---|
867 | }
|
---|
868 | }
|
---|
869 |
|
---|
870 |
|
---|
871 | /***********************************************************************
|
---|
872 | * TOOLBAR_AddBitmap: Add the bitmaps to the default image list.
|
---|
873 | *
|
---|
874 | */
|
---|
875 | static LRESULT
|
---|
876 | TOOLBAR_AddBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
877 | {
|
---|
878 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
879 | LPTBADDBITMAP lpAddBmp = (LPTBADDBITMAP)lParam;
|
---|
880 | INT nIndex = 0;
|
---|
881 |
|
---|
882 | if ((!lpAddBmp) || ((INT)wParam <= 0))
|
---|
883 | return -1;
|
---|
884 |
|
---|
885 | // TRACE (toolbar, "adding %d bitmaps!\n", wParam);
|
---|
886 |
|
---|
887 | if (!(infoPtr->himlStd)) {
|
---|
888 | /* create new standard image list */
|
---|
889 |
|
---|
890 | // TRACE (toolbar, "creating standard image list!\n");
|
---|
891 |
|
---|
892 |
|
---|
893 | /* Windows resize all the buttons to the size of a newly added STandard Image*/
|
---|
894 | /* TODO: The resizing should be done each time a standard image is added*/
|
---|
895 | if (lpAddBmp->hInst == HINST_COMMCTRL)
|
---|
896 | {
|
---|
897 |
|
---|
898 | if (lpAddBmp->nID & 1)
|
---|
899 | {
|
---|
900 | SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
|
---|
901 | MAKELPARAM((WORD)26, (WORD)26));
|
---|
902 | SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
|
---|
903 | MAKELPARAM((WORD)33, (WORD)33));
|
---|
904 | }
|
---|
905 | else
|
---|
906 | {
|
---|
907 | SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
|
---|
908 | MAKELPARAM((WORD)16, (WORD)16));
|
---|
909 |
|
---|
910 | SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
|
---|
911 | MAKELPARAM((WORD)22, (WORD)22));
|
---|
912 | }
|
---|
913 |
|
---|
914 | TOOLBAR_CalcToolbar (hwnd);
|
---|
915 | }
|
---|
916 |
|
---|
917 | infoPtr->himlStd =
|
---|
918 | ImageList_Create (infoPtr->nBitmapWidth, infoPtr->nBitmapHeight,
|
---|
919 | ILC_COLOR | ILC_MASK, (INT)wParam, 2);
|
---|
920 | }
|
---|
921 |
|
---|
922 | /* Add bitmaps to the standard image list */
|
---|
923 | if (lpAddBmp->hInst == (HINSTANCE)0) {
|
---|
924 | nIndex =
|
---|
925 | ImageList_AddMasked (infoPtr->himlStd, (HBITMAP)lpAddBmp->nID,
|
---|
926 | CLR_DEFAULT);
|
---|
927 | }
|
---|
928 | else if (lpAddBmp->hInst == HINST_COMMCTRL) {
|
---|
929 | /* add internal bitmaps */
|
---|
930 |
|
---|
931 | // FIXME (toolbar, "internal bitmaps not supported!\n");
|
---|
932 | /* TODO: Resize all the buttons when a new standard image is added */
|
---|
933 |
|
---|
934 | /* Hack to "add" some reserved images within the image list
|
---|
935 | to get the right image indices */
|
---|
936 | nIndex = ImageList_GetImageCount (infoPtr->himlStd);
|
---|
937 | ImageList_SetImageCount (infoPtr->himlStd, nIndex + (INT)wParam);
|
---|
938 |
|
---|
939 | }
|
---|
940 | else {
|
---|
941 | HBITMAP hBmp =
|
---|
942 | LoadBitmapA (lpAddBmp->hInst, (LPSTR)lpAddBmp->nID);
|
---|
943 | nIndex = ImageList_AddMasked (infoPtr->himlStd, hBmp, CLR_DEFAULT);
|
---|
944 |
|
---|
945 | DeleteObject (hBmp);
|
---|
946 | }
|
---|
947 |
|
---|
948 | infoPtr->nNumBitmaps += (INT)wParam;
|
---|
949 |
|
---|
950 | return nIndex;
|
---|
951 | }
|
---|
952 |
|
---|
953 |
|
---|
954 | static LRESULT
|
---|
955 | TOOLBAR_AddButtonsA (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
956 | {
|
---|
957 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
958 | LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
|
---|
959 | INT nOldButtons, nNewButtons, nAddButtons, nCount;
|
---|
960 |
|
---|
961 | // TRACE (toolbar, "adding %d buttons!\n", wParam);
|
---|
962 |
|
---|
963 | nAddButtons = (UINT)wParam;
|
---|
964 | nOldButtons = infoPtr->nNumButtons;
|
---|
965 | nNewButtons = nOldButtons + nAddButtons;
|
---|
966 |
|
---|
967 | if (infoPtr->nNumButtons == 0) {
|
---|
968 | infoPtr->buttons =
|
---|
969 | COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
|
---|
970 | }
|
---|
971 | else {
|
---|
972 | TBUTTON_INFO *oldButtons = infoPtr->buttons;
|
---|
973 | infoPtr->buttons =
|
---|
974 | COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
|
---|
975 | memcpy (&infoPtr->buttons[0], &oldButtons[0],
|
---|
976 | nOldButtons * sizeof(TBUTTON_INFO));
|
---|
977 | COMCTL32_Free (oldButtons);
|
---|
978 | }
|
---|
979 |
|
---|
980 | infoPtr->nNumButtons = nNewButtons;
|
---|
981 |
|
---|
982 | /* insert new button data */
|
---|
983 | for (nCount = 0; nCount < nAddButtons; nCount++)
|
---|
984 | {
|
---|
985 | TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount];
|
---|
986 | btnPtr->iBitmap = lpTbb[nCount].iBitmap;
|
---|
987 | btnPtr->idCommand = lpTbb[nCount].idCommand;
|
---|
988 | btnPtr->fsState = lpTbb[nCount].fsState;
|
---|
989 | btnPtr->fsStyle = lpTbb[nCount].fsStyle;
|
---|
990 | btnPtr->dwData = lpTbb[nCount].dwData;
|
---|
991 | btnPtr->iString = lpTbb[nCount].iString;
|
---|
992 | btnPtr->bHot = FALSE;
|
---|
993 |
|
---|
994 | if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP))
|
---|
995 | {
|
---|
996 | TTTOOLINFOA ti;
|
---|
997 |
|
---|
998 | ZeroMemory (&ti, sizeof(TTTOOLINFOA));
|
---|
999 | ti.cbSize = sizeof (TTTOOLINFOA);
|
---|
1000 | ti.hwnd = hwnd;
|
---|
1001 | ti.uId = btnPtr->idCommand;
|
---|
1002 | ti.hinst = 0;
|
---|
1003 | ti.lpszText = LPSTR_TEXTCALLBACKA;
|
---|
1004 |
|
---|
1005 | SendMessageA (infoPtr->hwndToolTip,TTM_ADDTOOLA,0,(LPARAM)&ti);
|
---|
1006 | }
|
---|
1007 | }
|
---|
1008 |
|
---|
1009 | TOOLBAR_CalcToolbar(hwnd);
|
---|
1010 |
|
---|
1011 | InvalidateRect(hwnd,NULL,FALSE);
|
---|
1012 |
|
---|
1013 | return TRUE;
|
---|
1014 | }
|
---|
1015 |
|
---|
1016 |
|
---|
1017 | /* << TOOLBAR_AddButtons32W >> */
|
---|
1018 |
|
---|
1019 |
|
---|
1020 | static LRESULT
|
---|
1021 | TOOLBAR_AddStringA (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1022 | {
|
---|
1023 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1024 | INT nIndex;
|
---|
1025 |
|
---|
1026 | if ((wParam) && (HIWORD(lParam) == 0)) {
|
---|
1027 | char szString[256];
|
---|
1028 | INT len;
|
---|
1029 | // TRACE (toolbar, "adding string from resource!\n");
|
---|
1030 |
|
---|
1031 | len = LoadStringA ((HINSTANCE)wParam, (UINT)lParam,
|
---|
1032 | szString, 256);
|
---|
1033 |
|
---|
1034 | // TRACE (toolbar, "len=%d \"%s\"\n", len, szString);
|
---|
1035 | nIndex = infoPtr->nNumStrings;
|
---|
1036 | if (infoPtr->nNumStrings == 0) {
|
---|
1037 | infoPtr->strings =
|
---|
1038 | COMCTL32_Alloc (sizeof(LPWSTR));
|
---|
1039 | }
|
---|
1040 | else {
|
---|
1041 | LPWSTR *oldStrings = infoPtr->strings;
|
---|
1042 | infoPtr->strings =
|
---|
1043 | COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
|
---|
1044 | memcpy (&infoPtr->strings[0], &oldStrings[0],
|
---|
1045 | sizeof(LPWSTR) * infoPtr->nNumStrings);
|
---|
1046 | COMCTL32_Free (oldStrings);
|
---|
1047 | }
|
---|
1048 |
|
---|
1049 | infoPtr->strings[infoPtr->nNumStrings] =
|
---|
1050 | COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
|
---|
1051 | lstrcpyAtoW (infoPtr->strings[infoPtr->nNumStrings], szString);
|
---|
1052 | infoPtr->nNumStrings++;
|
---|
1053 | }
|
---|
1054 | else {
|
---|
1055 | LPSTR p = (LPSTR)lParam;
|
---|
1056 | INT len;
|
---|
1057 |
|
---|
1058 | if (p == NULL)
|
---|
1059 | return -1;
|
---|
1060 | // TRACE (toolbar, "adding string(s) from array!\n");
|
---|
1061 | nIndex = infoPtr->nNumStrings;
|
---|
1062 | while (*p) {
|
---|
1063 | len = lstrlenA (p);
|
---|
1064 | // TRACE (toolbar, "len=%d \"%s\"\n", len, p);
|
---|
1065 |
|
---|
1066 | if (infoPtr->nNumStrings == 0) {
|
---|
1067 | infoPtr->strings =
|
---|
1068 | COMCTL32_Alloc (sizeof(LPWSTR));
|
---|
1069 | }
|
---|
1070 | else {
|
---|
1071 | LPWSTR *oldStrings = infoPtr->strings;
|
---|
1072 | infoPtr->strings =
|
---|
1073 | COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
|
---|
1074 | memcpy (&infoPtr->strings[0], &oldStrings[0],
|
---|
1075 | sizeof(LPWSTR) * infoPtr->nNumStrings);
|
---|
1076 | COMCTL32_Free (oldStrings);
|
---|
1077 | }
|
---|
1078 |
|
---|
1079 | infoPtr->strings[infoPtr->nNumStrings] =
|
---|
1080 | COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
|
---|
1081 | lstrcpyAtoW (infoPtr->strings[infoPtr->nNumStrings], p);
|
---|
1082 | infoPtr->nNumStrings++;
|
---|
1083 |
|
---|
1084 | p += (len+1);
|
---|
1085 | }
|
---|
1086 | }
|
---|
1087 |
|
---|
1088 | return nIndex;
|
---|
1089 | }
|
---|
1090 |
|
---|
1091 |
|
---|
1092 | static LRESULT
|
---|
1093 | TOOLBAR_AddStringW (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1094 | {
|
---|
1095 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1096 | INT nIndex;
|
---|
1097 |
|
---|
1098 | if ((wParam) && (HIWORD(lParam) == 0)) {
|
---|
1099 | WCHAR szString[256];
|
---|
1100 | INT len;
|
---|
1101 | // TRACE (toolbar, "adding string from resource!\n");
|
---|
1102 |
|
---|
1103 | len = LoadStringW ((HINSTANCE)wParam, (UINT)lParam,
|
---|
1104 | szString, 256);
|
---|
1105 |
|
---|
1106 | // TRACE (toolbar, "len=%d \"%s\"\n", len, debugstr_w(szString));
|
---|
1107 | nIndex = infoPtr->nNumStrings;
|
---|
1108 | if (infoPtr->nNumStrings == 0) {
|
---|
1109 | infoPtr->strings =
|
---|
1110 | COMCTL32_Alloc (sizeof(LPWSTR));
|
---|
1111 | }
|
---|
1112 | else {
|
---|
1113 | LPWSTR *oldStrings = infoPtr->strings;
|
---|
1114 | infoPtr->strings =
|
---|
1115 | COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
|
---|
1116 | memcpy (&infoPtr->strings[0], &oldStrings[0],
|
---|
1117 | sizeof(LPWSTR) * infoPtr->nNumStrings);
|
---|
1118 | COMCTL32_Free (oldStrings);
|
---|
1119 | }
|
---|
1120 |
|
---|
1121 | infoPtr->strings[infoPtr->nNumStrings] =
|
---|
1122 | COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
|
---|
1123 | lstrcpyW (infoPtr->strings[infoPtr->nNumStrings], szString);
|
---|
1124 | infoPtr->nNumStrings++;
|
---|
1125 | }
|
---|
1126 | else {
|
---|
1127 | LPWSTR p = (LPWSTR)lParam;
|
---|
1128 | INT len;
|
---|
1129 |
|
---|
1130 | if (p == NULL)
|
---|
1131 | return -1;
|
---|
1132 | // TRACE (toolbar, "adding string(s) from array!\n");
|
---|
1133 | nIndex = infoPtr->nNumStrings;
|
---|
1134 | while (*p) {
|
---|
1135 | len = lstrlenW (p);
|
---|
1136 | // TRACE (toolbar, "len=%d \"%s\"\n", len, debugstr_w(p));
|
---|
1137 |
|
---|
1138 | if (infoPtr->nNumStrings == 0) {
|
---|
1139 | infoPtr->strings =
|
---|
1140 | COMCTL32_Alloc (sizeof(LPWSTR));
|
---|
1141 | }
|
---|
1142 | else {
|
---|
1143 | LPWSTR *oldStrings = infoPtr->strings;
|
---|
1144 | infoPtr->strings =
|
---|
1145 | COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
|
---|
1146 | memcpy (&infoPtr->strings[0], &oldStrings[0],
|
---|
1147 | sizeof(LPWSTR) * infoPtr->nNumStrings);
|
---|
1148 | COMCTL32_Free (oldStrings);
|
---|
1149 | }
|
---|
1150 |
|
---|
1151 | infoPtr->strings[infoPtr->nNumStrings] =
|
---|
1152 | COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
|
---|
1153 | lstrcpyW (infoPtr->strings[infoPtr->nNumStrings], p);
|
---|
1154 | infoPtr->nNumStrings++;
|
---|
1155 |
|
---|
1156 | p += (len+1);
|
---|
1157 | }
|
---|
1158 | }
|
---|
1159 |
|
---|
1160 | return nIndex;
|
---|
1161 | }
|
---|
1162 |
|
---|
1163 |
|
---|
1164 | static LRESULT
|
---|
1165 | TOOLBAR_AutoSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1166 | {
|
---|
1167 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1168 | DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
|
---|
1169 | RECT parent_rect;
|
---|
1170 | HWND parent;
|
---|
1171 | /* INT32 x, y; */
|
---|
1172 | INT cx, cy;
|
---|
1173 | UINT uPosFlags = 0;
|
---|
1174 |
|
---|
1175 | // TRACE (toolbar, "resize forced!\n");
|
---|
1176 |
|
---|
1177 | parent = GetParent (hwnd);
|
---|
1178 | GetClientRect(parent, &parent_rect);
|
---|
1179 |
|
---|
1180 | if (dwStyle & CCS_NORESIZE) {
|
---|
1181 | uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
|
---|
1182 | cx = 0;
|
---|
1183 | cy = 0;
|
---|
1184 | }
|
---|
1185 | else {
|
---|
1186 | infoPtr->nWidth = parent_rect.right - parent_rect.left;
|
---|
1187 | TOOLBAR_CalcToolbar (hwnd);
|
---|
1188 | InvalidateRect( hwnd, NULL, TRUE );
|
---|
1189 | cy = infoPtr->nHeight;
|
---|
1190 | cx = infoPtr->nWidth;
|
---|
1191 | }
|
---|
1192 |
|
---|
1193 | if (dwStyle & CCS_NOPARENTALIGN)
|
---|
1194 | uPosFlags |= SWP_NOMOVE;
|
---|
1195 |
|
---|
1196 | if (!(dwStyle & CCS_NODIVIDER))
|
---|
1197 | cy += GetSystemMetrics(SM_CYEDGE);
|
---|
1198 |
|
---|
1199 | infoPtr->bAutoSize = TRUE;
|
---|
1200 | SetWindowPos (hwnd, HWND_TOP, parent_rect.left, parent_rect.top,
|
---|
1201 | cx, cy, uPosFlags);
|
---|
1202 |
|
---|
1203 | return 0;
|
---|
1204 | }
|
---|
1205 |
|
---|
1206 |
|
---|
1207 | static LRESULT
|
---|
1208 | TOOLBAR_ButtonCount (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1209 | {
|
---|
1210 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1211 |
|
---|
1212 | return infoPtr->nNumButtons;
|
---|
1213 | }
|
---|
1214 |
|
---|
1215 |
|
---|
1216 | static LRESULT
|
---|
1217 | TOOLBAR_ButtonStructSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1218 | {
|
---|
1219 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1220 |
|
---|
1221 | if (infoPtr == NULL) {
|
---|
1222 | // ERR (toolbar, "(0x%x, 0x%x, 0x%lx)\n", hwnd, wParam, lParam);
|
---|
1223 | // ERR (toolbar, "infoPtr == NULL!\n");
|
---|
1224 | return 0;
|
---|
1225 | }
|
---|
1226 |
|
---|
1227 | infoPtr->dwStructSize = (DWORD)wParam;
|
---|
1228 |
|
---|
1229 | return 0;
|
---|
1230 | }
|
---|
1231 |
|
---|
1232 |
|
---|
1233 | static LRESULT
|
---|
1234 | TOOLBAR_ChangeBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1235 | {
|
---|
1236 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1237 | TBUTTON_INFO *btnPtr;
|
---|
1238 | HDC hdc;
|
---|
1239 | INT nIndex;
|
---|
1240 |
|
---|
1241 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
1242 | if (nIndex == -1)
|
---|
1243 | return FALSE;
|
---|
1244 |
|
---|
1245 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
1246 | btnPtr->iBitmap = LOWORD(lParam);
|
---|
1247 |
|
---|
1248 | hdc = GetDC (hwnd);
|
---|
1249 | TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
|
---|
1250 | ReleaseDC (hwnd, hdc);
|
---|
1251 |
|
---|
1252 | return TRUE;
|
---|
1253 | }
|
---|
1254 |
|
---|
1255 |
|
---|
1256 | static LRESULT
|
---|
1257 | TOOLBAR_CheckButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1258 | {
|
---|
1259 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1260 | TBUTTON_INFO *btnPtr;
|
---|
1261 | HDC hdc;
|
---|
1262 | INT nIndex;
|
---|
1263 | INT nOldIndex = -1;
|
---|
1264 |
|
---|
1265 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
1266 | if (nIndex == -1)
|
---|
1267 | return FALSE;
|
---|
1268 |
|
---|
1269 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
1270 |
|
---|
1271 | if (!(btnPtr->fsStyle & TBSTYLE_CHECK))
|
---|
1272 | return FALSE;
|
---|
1273 |
|
---|
1274 | if (LOWORD(lParam) == FALSE)
|
---|
1275 | btnPtr->fsState &= ~TBSTATE_CHECKED;
|
---|
1276 | else {
|
---|
1277 | if (btnPtr->fsStyle & TBSTYLE_GROUP) {
|
---|
1278 | nOldIndex =
|
---|
1279 | TOOLBAR_GetCheckedGroupButtonIndex (infoPtr, nIndex);
|
---|
1280 | if (nOldIndex == nIndex)
|
---|
1281 | return 0;
|
---|
1282 | if (nOldIndex != -1)
|
---|
1283 | infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
|
---|
1284 | }
|
---|
1285 | btnPtr->fsState |= TBSTATE_CHECKED;
|
---|
1286 | }
|
---|
1287 |
|
---|
1288 | hdc = GetDC (hwnd);
|
---|
1289 | if (nOldIndex != -1)
|
---|
1290 | TOOLBAR_DrawButton (hwnd, &infoPtr->buttons[nOldIndex], hdc);
|
---|
1291 | TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
|
---|
1292 | ReleaseDC (hwnd, hdc);
|
---|
1293 |
|
---|
1294 | /* FIXME: Send a WM_NOTIFY?? */
|
---|
1295 |
|
---|
1296 | return TRUE;
|
---|
1297 | }
|
---|
1298 |
|
---|
1299 |
|
---|
1300 | static LRESULT
|
---|
1301 | TOOLBAR_CommandToIndex (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1302 | {
|
---|
1303 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1304 |
|
---|
1305 | return TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
1306 | }
|
---|
1307 |
|
---|
1308 |
|
---|
1309 | static LRESULT
|
---|
1310 | TOOLBAR_Customize (HWND hwnd)
|
---|
1311 | {
|
---|
1312 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1313 | LRESULT ret;
|
---|
1314 | LPCVOID template;
|
---|
1315 | HRSRC hRes;
|
---|
1316 | NMHDR nmhdr;
|
---|
1317 |
|
---|
1318 | /* send TBN_BEGINADJUST notification */
|
---|
1319 | nmhdr.hwndFrom = hwnd;
|
---|
1320 | nmhdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
|
---|
1321 | nmhdr.code = TBN_BEGINADJUST;
|
---|
1322 |
|
---|
1323 | SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
|
---|
1324 | (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
|
---|
1325 |
|
---|
1326 | if (!(hRes = FindResourceA (COMCTL32_hModule,
|
---|
1327 | MAKEINTRESOURCEA(IDD_TBCUSTOMIZE),
|
---|
1328 | RT_DIALOGA)))
|
---|
1329 | return FALSE;
|
---|
1330 |
|
---|
1331 | if(!(template = (LPVOID)LoadResource (COMCTL32_hModule, hRes)))
|
---|
1332 | return FALSE;
|
---|
1333 |
|
---|
1334 | ret = DialogBoxIndirectParamA (GetWindowLongA (hwnd, GWL_HINSTANCE),
|
---|
1335 | (LPDLGTEMPLATEA)template,
|
---|
1336 | hwnd,
|
---|
1337 | (DLGPROC)TOOLBAR_CustomizeDialogProc,
|
---|
1338 | (LPARAM)infoPtr);
|
---|
1339 |
|
---|
1340 | /* send TBN_ENDADJUST notification */
|
---|
1341 | nmhdr.code = TBN_ENDADJUST;
|
---|
1342 |
|
---|
1343 | SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
|
---|
1344 | (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
|
---|
1345 |
|
---|
1346 | return ret;
|
---|
1347 | }
|
---|
1348 |
|
---|
1349 |
|
---|
1350 | static LRESULT
|
---|
1351 | TOOLBAR_DeleteButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1352 | {
|
---|
1353 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1354 | INT nIndex = (INT)wParam;
|
---|
1355 |
|
---|
1356 | if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
|
---|
1357 | return FALSE;
|
---|
1358 |
|
---|
1359 | if ((infoPtr->hwndToolTip) &&
|
---|
1360 | !(infoPtr->buttons[nIndex].fsStyle & TBSTYLE_SEP)) {
|
---|
1361 | TTTOOLINFOA ti;
|
---|
1362 |
|
---|
1363 | ZeroMemory (&ti, sizeof(TTTOOLINFOA));
|
---|
1364 | ti.cbSize = sizeof (TTTOOLINFOA);
|
---|
1365 | ti.hwnd = hwnd;
|
---|
1366 | ti.uId = infoPtr->buttons[nIndex].idCommand;
|
---|
1367 |
|
---|
1368 | SendMessageA (infoPtr->hwndToolTip, TTM_DELTOOLA, 0, (LPARAM)&ti);
|
---|
1369 | }
|
---|
1370 |
|
---|
1371 | if (infoPtr->nNumButtons == 1) {
|
---|
1372 | // TRACE (toolbar, " simple delete!\n");
|
---|
1373 | COMCTL32_Free (infoPtr->buttons);
|
---|
1374 | infoPtr->buttons = NULL;
|
---|
1375 | infoPtr->nNumButtons = 0;
|
---|
1376 | }
|
---|
1377 | else {
|
---|
1378 | TBUTTON_INFO *oldButtons = infoPtr->buttons;
|
---|
1379 | // TRACE(toolbar, "complex delete! [nIndex=%d]\n", nIndex);
|
---|
1380 |
|
---|
1381 | infoPtr->nNumButtons--;
|
---|
1382 | infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
|
---|
1383 | if (nIndex > 0) {
|
---|
1384 | memcpy (&infoPtr->buttons[0], &oldButtons[0],
|
---|
1385 | nIndex * sizeof(TBUTTON_INFO));
|
---|
1386 | }
|
---|
1387 |
|
---|
1388 | if (nIndex < infoPtr->nNumButtons) {
|
---|
1389 | memcpy (&infoPtr->buttons[nIndex], &oldButtons[nIndex+1],
|
---|
1390 | (infoPtr->nNumButtons - nIndex) * sizeof(TBUTTON_INFO));
|
---|
1391 | }
|
---|
1392 |
|
---|
1393 | COMCTL32_Free (oldButtons);
|
---|
1394 | }
|
---|
1395 |
|
---|
1396 | TOOLBAR_CalcToolbar (hwnd);
|
---|
1397 |
|
---|
1398 | InvalidateRect (hwnd, NULL, TRUE);
|
---|
1399 |
|
---|
1400 | return TRUE;
|
---|
1401 | }
|
---|
1402 |
|
---|
1403 |
|
---|
1404 | static LRESULT
|
---|
1405 | TOOLBAR_EnableButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1406 | {
|
---|
1407 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1408 | TBUTTON_INFO *btnPtr;
|
---|
1409 | HDC hdc;
|
---|
1410 | INT nIndex;
|
---|
1411 |
|
---|
1412 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
1413 | if (nIndex == -1)
|
---|
1414 | return FALSE;
|
---|
1415 |
|
---|
1416 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
1417 | if (LOWORD(lParam) == FALSE)
|
---|
1418 | btnPtr->fsState &= ~(TBSTATE_ENABLED | TBSTATE_PRESSED);
|
---|
1419 | else
|
---|
1420 | btnPtr->fsState |= TBSTATE_ENABLED;
|
---|
1421 |
|
---|
1422 | hdc = GetDC (hwnd);
|
---|
1423 | TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
|
---|
1424 | ReleaseDC (hwnd, hdc);
|
---|
1425 |
|
---|
1426 | return TRUE;
|
---|
1427 | }
|
---|
1428 |
|
---|
1429 |
|
---|
1430 | /* << TOOLBAR_GetAnchorHighlight >> */
|
---|
1431 |
|
---|
1432 |
|
---|
1433 | static LRESULT
|
---|
1434 | TOOLBAR_GetBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1435 | {
|
---|
1436 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1437 | INT nIndex;
|
---|
1438 |
|
---|
1439 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
1440 | if (nIndex == -1)
|
---|
1441 | return -1;
|
---|
1442 |
|
---|
1443 | return infoPtr->buttons[nIndex].iBitmap;
|
---|
1444 | }
|
---|
1445 |
|
---|
1446 |
|
---|
1447 | static LRESULT
|
---|
1448 | TOOLBAR_GetBitmapFlags (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1449 | {
|
---|
1450 | return (GetDeviceCaps (0, LOGPIXELSX) >= 120) ? TBBF_LARGE : 0;
|
---|
1451 | }
|
---|
1452 |
|
---|
1453 |
|
---|
1454 | static LRESULT
|
---|
1455 | TOOLBAR_GetButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1456 | {
|
---|
1457 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1458 | LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
|
---|
1459 | INT nIndex = (INT)wParam;
|
---|
1460 | TBUTTON_INFO *btnPtr;
|
---|
1461 |
|
---|
1462 | if (infoPtr == NULL)
|
---|
1463 | return FALSE;
|
---|
1464 |
|
---|
1465 | if (lpTbb == NULL)
|
---|
1466 | return FALSE;
|
---|
1467 |
|
---|
1468 | if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
|
---|
1469 | return FALSE;
|
---|
1470 |
|
---|
1471 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
1472 | lpTbb->iBitmap = btnPtr->iBitmap;
|
---|
1473 | lpTbb->idCommand = btnPtr->idCommand;
|
---|
1474 | lpTbb->fsState = btnPtr->fsState;
|
---|
1475 | lpTbb->fsStyle = btnPtr->fsStyle;
|
---|
1476 | lpTbb->dwData = btnPtr->dwData;
|
---|
1477 | lpTbb->iString = btnPtr->iString;
|
---|
1478 |
|
---|
1479 | return TRUE;
|
---|
1480 | }
|
---|
1481 |
|
---|
1482 |
|
---|
1483 | static LRESULT
|
---|
1484 | TOOLBAR_GetButtonInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1485 | {
|
---|
1486 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1487 | LPTBBUTTONINFOA lpTbInfo = (LPTBBUTTONINFOA)lParam;
|
---|
1488 | TBUTTON_INFO *btnPtr;
|
---|
1489 | INT nIndex;
|
---|
1490 |
|
---|
1491 | if (infoPtr == NULL)
|
---|
1492 | return -1;
|
---|
1493 | if (lpTbInfo == NULL)
|
---|
1494 | return -1;
|
---|
1495 | if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOA))
|
---|
1496 | return -1;
|
---|
1497 |
|
---|
1498 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
1499 | if (nIndex == -1)
|
---|
1500 | return -1;
|
---|
1501 |
|
---|
1502 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
1503 |
|
---|
1504 | if (lpTbInfo->dwMask & TBIF_COMMAND)
|
---|
1505 | lpTbInfo->idCommand = btnPtr->idCommand;
|
---|
1506 | if (lpTbInfo->dwMask & TBIF_IMAGE)
|
---|
1507 | lpTbInfo->iImage = btnPtr->iBitmap;
|
---|
1508 | if (lpTbInfo->dwMask & TBIF_LPARAM)
|
---|
1509 | lpTbInfo->lParam = btnPtr->dwData;
|
---|
1510 | if (lpTbInfo->dwMask & TBIF_SIZE)
|
---|
1511 | lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left);
|
---|
1512 | if (lpTbInfo->dwMask & TBIF_STATE)
|
---|
1513 | lpTbInfo->fsState = btnPtr->fsState;
|
---|
1514 | if (lpTbInfo->dwMask & TBIF_STYLE)
|
---|
1515 | lpTbInfo->fsStyle = btnPtr->fsStyle;
|
---|
1516 | if (lpTbInfo->dwMask & TBIF_TEXT) {
|
---|
1517 | if ((btnPtr->iString >= 0) || (btnPtr->iString < infoPtr->nNumStrings))
|
---|
1518 | lstrcpynA (lpTbInfo->pszText,
|
---|
1519 | (LPSTR)infoPtr->strings[btnPtr->iString],
|
---|
1520 | lpTbInfo->cchText);
|
---|
1521 | }
|
---|
1522 |
|
---|
1523 | return nIndex;
|
---|
1524 | }
|
---|
1525 |
|
---|
1526 |
|
---|
1527 | /* << TOOLBAR_GetButtonInfo32W >> */
|
---|
1528 |
|
---|
1529 |
|
---|
1530 | static LRESULT
|
---|
1531 | TOOLBAR_GetButtonSize (HWND hwnd)
|
---|
1532 | {
|
---|
1533 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1534 |
|
---|
1535 | return MAKELONG((WORD)infoPtr->nButtonWidth,
|
---|
1536 | (WORD)infoPtr->nButtonHeight);
|
---|
1537 | }
|
---|
1538 |
|
---|
1539 |
|
---|
1540 | static LRESULT
|
---|
1541 | TOOLBAR_GetButtonTextA (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1542 | {
|
---|
1543 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1544 | INT nIndex, nStringIndex;
|
---|
1545 |
|
---|
1546 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
1547 | if (nIndex == -1)
|
---|
1548 | return -1;
|
---|
1549 |
|
---|
1550 | nStringIndex = infoPtr->buttons[nIndex].iString;
|
---|
1551 |
|
---|
1552 | // TRACE (toolbar, "index=%d stringIndex=%d\n", nIndex, nStringIndex);
|
---|
1553 |
|
---|
1554 | if ((nStringIndex < 0) || (nStringIndex >= infoPtr->nNumStrings))
|
---|
1555 | return -1;
|
---|
1556 |
|
---|
1557 | if (lParam == 0) return -1;
|
---|
1558 |
|
---|
1559 | lstrcpyA ((LPSTR)lParam, (LPSTR)infoPtr->strings[nStringIndex]);
|
---|
1560 |
|
---|
1561 | return lstrlenA ((LPSTR)infoPtr->strings[nStringIndex]);
|
---|
1562 | }
|
---|
1563 |
|
---|
1564 |
|
---|
1565 | /* << TOOLBAR_GetButtonText32W >> */
|
---|
1566 | /* << TOOLBAR_GetColorScheme >> */
|
---|
1567 |
|
---|
1568 |
|
---|
1569 | static LRESULT
|
---|
1570 | TOOLBAR_GetDisabledImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1571 | {
|
---|
1572 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1573 |
|
---|
1574 | if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT)
|
---|
1575 | return (LRESULT)infoPtr->himlDis;
|
---|
1576 | else
|
---|
1577 | return 0;
|
---|
1578 | }
|
---|
1579 |
|
---|
1580 |
|
---|
1581 | static LRESULT
|
---|
1582 | TOOLBAR_GetExtendedStyle (HWND hwnd)
|
---|
1583 | {
|
---|
1584 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1585 |
|
---|
1586 | return infoPtr->dwExStyle;
|
---|
1587 | }
|
---|
1588 |
|
---|
1589 |
|
---|
1590 | static LRESULT
|
---|
1591 | TOOLBAR_GetHotImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1592 | {
|
---|
1593 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1594 |
|
---|
1595 | if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT)
|
---|
1596 | return (LRESULT)infoPtr->himlHot;
|
---|
1597 | else
|
---|
1598 | return 0;
|
---|
1599 | }
|
---|
1600 |
|
---|
1601 |
|
---|
1602 | /* << TOOLBAR_GetHotItem >> */
|
---|
1603 |
|
---|
1604 |
|
---|
1605 | static LRESULT
|
---|
1606 | TOOLBAR_GetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1607 | {
|
---|
1608 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1609 |
|
---|
1610 | if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT)
|
---|
1611 | return (LRESULT)infoPtr->himlDef;
|
---|
1612 | else
|
---|
1613 | return 0;
|
---|
1614 | }
|
---|
1615 |
|
---|
1616 |
|
---|
1617 | /* << TOOLBAR_GetInsertMark >> */
|
---|
1618 | /* << TOOLBAR_GetInsertMarkColor >> */
|
---|
1619 |
|
---|
1620 |
|
---|
1621 | static LRESULT
|
---|
1622 | TOOLBAR_GetItemRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1623 | {
|
---|
1624 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1625 | TBUTTON_INFO *btnPtr;
|
---|
1626 | LPRECT lpRect;
|
---|
1627 | INT nIndex;
|
---|
1628 |
|
---|
1629 | if (infoPtr == NULL)
|
---|
1630 | return FALSE;
|
---|
1631 | nIndex = (INT)wParam;
|
---|
1632 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
1633 | if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
|
---|
1634 | return FALSE;
|
---|
1635 | lpRect = (LPRECT)lParam;
|
---|
1636 | if (lpRect == NULL)
|
---|
1637 | return FALSE;
|
---|
1638 | if (btnPtr->fsState & TBSTATE_HIDDEN)
|
---|
1639 | return FALSE;
|
---|
1640 |
|
---|
1641 | TOOLBAR_CalcToolbar( hwnd );
|
---|
1642 |
|
---|
1643 | lpRect->left = btnPtr->rect.left;
|
---|
1644 | lpRect->right = btnPtr->rect.right;
|
---|
1645 | lpRect->bottom = btnPtr->rect.bottom;
|
---|
1646 | lpRect->top = btnPtr->rect.top;
|
---|
1647 |
|
---|
1648 | return TRUE;
|
---|
1649 | }
|
---|
1650 |
|
---|
1651 |
|
---|
1652 | static LRESULT
|
---|
1653 | TOOLBAR_GetMaxSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1654 | {
|
---|
1655 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1656 | LPSIZE lpSize = (LPSIZE)lParam;
|
---|
1657 |
|
---|
1658 | if (lpSize == NULL)
|
---|
1659 | return FALSE;
|
---|
1660 |
|
---|
1661 | lpSize->cx = infoPtr->rcBound.right - infoPtr->rcBound.left;
|
---|
1662 | lpSize->cy = infoPtr->rcBound.bottom - infoPtr->rcBound.top;
|
---|
1663 |
|
---|
1664 | // TRACE (toolbar, "maximum size %d x %d\n",
|
---|
1665 | // infoPtr->rcBound.right - infoPtr->rcBound.left,
|
---|
1666 | // infoPtr->rcBound.bottom - infoPtr->rcBound.top);
|
---|
1667 |
|
---|
1668 | return TRUE;
|
---|
1669 | }
|
---|
1670 |
|
---|
1671 |
|
---|
1672 | /* << TOOLBAR_GetObject >> */
|
---|
1673 | /* << TOOLBAR_GetPadding >> */
|
---|
1674 |
|
---|
1675 |
|
---|
1676 | static LRESULT
|
---|
1677 | TOOLBAR_GetRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1678 | {
|
---|
1679 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1680 | TBUTTON_INFO *btnPtr;
|
---|
1681 | LPRECT lpRect;
|
---|
1682 | INT nIndex;
|
---|
1683 |
|
---|
1684 | if (infoPtr == NULL)
|
---|
1685 | return FALSE;
|
---|
1686 | nIndex = (INT)wParam;
|
---|
1687 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
1688 | if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
|
---|
1689 | return FALSE;
|
---|
1690 | lpRect = (LPRECT)lParam;
|
---|
1691 | if (lpRect == NULL)
|
---|
1692 | return FALSE;
|
---|
1693 |
|
---|
1694 | lpRect->left = btnPtr->rect.left;
|
---|
1695 | lpRect->right = btnPtr->rect.right;
|
---|
1696 | lpRect->bottom = btnPtr->rect.bottom;
|
---|
1697 | lpRect->top = btnPtr->rect.top;
|
---|
1698 |
|
---|
1699 | return TRUE;
|
---|
1700 | }
|
---|
1701 |
|
---|
1702 |
|
---|
1703 | static LRESULT
|
---|
1704 | TOOLBAR_GetRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1705 | {
|
---|
1706 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1707 |
|
---|
1708 | if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_WRAPABLE)
|
---|
1709 | return infoPtr->nRows;
|
---|
1710 | else
|
---|
1711 | return 1;
|
---|
1712 | }
|
---|
1713 |
|
---|
1714 |
|
---|
1715 | static LRESULT
|
---|
1716 | TOOLBAR_GetState (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1717 | {
|
---|
1718 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1719 | INT nIndex;
|
---|
1720 |
|
---|
1721 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
1722 | if (nIndex == -1)
|
---|
1723 | return -1;
|
---|
1724 |
|
---|
1725 | return infoPtr->buttons[nIndex].fsState;
|
---|
1726 | }
|
---|
1727 |
|
---|
1728 |
|
---|
1729 | static LRESULT
|
---|
1730 | TOOLBAR_GetStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1731 | {
|
---|
1732 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1733 | INT nIndex;
|
---|
1734 |
|
---|
1735 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
1736 | if (nIndex == -1)
|
---|
1737 | return -1;
|
---|
1738 |
|
---|
1739 | return infoPtr->buttons[nIndex].fsStyle;
|
---|
1740 | }
|
---|
1741 |
|
---|
1742 |
|
---|
1743 | static LRESULT
|
---|
1744 | TOOLBAR_GetTextRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1745 | {
|
---|
1746 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1747 |
|
---|
1748 | if (infoPtr == NULL)
|
---|
1749 | return 0;
|
---|
1750 |
|
---|
1751 | return infoPtr->nMaxTextRows;
|
---|
1752 | }
|
---|
1753 |
|
---|
1754 |
|
---|
1755 | static LRESULT
|
---|
1756 | TOOLBAR_GetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1757 | {
|
---|
1758 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1759 |
|
---|
1760 | if (infoPtr == NULL) return 0;
|
---|
1761 | return infoPtr->hwndToolTip;
|
---|
1762 | }
|
---|
1763 |
|
---|
1764 |
|
---|
1765 | static LRESULT
|
---|
1766 | TOOLBAR_GetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1767 | {
|
---|
1768 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1769 |
|
---|
1770 | // TRACE (toolbar, "%s hwnd=0x%x stub!\n",
|
---|
1771 | // infoPtr->bUnicode ? "TRUE" : "FALSE", hwnd);
|
---|
1772 |
|
---|
1773 | return infoPtr->bUnicode;
|
---|
1774 | }
|
---|
1775 |
|
---|
1776 |
|
---|
1777 | static LRESULT
|
---|
1778 | TOOLBAR_HideButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1779 | {
|
---|
1780 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1781 | TBUTTON_INFO *btnPtr;
|
---|
1782 | INT nIndex;
|
---|
1783 |
|
---|
1784 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
1785 | if (nIndex == -1)
|
---|
1786 | return FALSE;
|
---|
1787 |
|
---|
1788 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
1789 | if (LOWORD(lParam) == FALSE)
|
---|
1790 | btnPtr->fsState &= ~TBSTATE_HIDDEN;
|
---|
1791 | else
|
---|
1792 | btnPtr->fsState |= TBSTATE_HIDDEN;
|
---|
1793 |
|
---|
1794 | TOOLBAR_CalcToolbar (hwnd);
|
---|
1795 |
|
---|
1796 | InvalidateRect (hwnd, NULL, TRUE);
|
---|
1797 |
|
---|
1798 | return TRUE;
|
---|
1799 | }
|
---|
1800 |
|
---|
1801 |
|
---|
1802 | static LRESULT
|
---|
1803 | TOOLBAR_HitTest (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1804 | {
|
---|
1805 | return TOOLBAR_InternalHitTest (hwnd, (LPPOINT)lParam);
|
---|
1806 | }
|
---|
1807 |
|
---|
1808 |
|
---|
1809 | static LRESULT
|
---|
1810 | TOOLBAR_Indeterminate (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1811 | {
|
---|
1812 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1813 | TBUTTON_INFO *btnPtr;
|
---|
1814 | HDC hdc;
|
---|
1815 | INT nIndex;
|
---|
1816 |
|
---|
1817 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
1818 | if (nIndex == -1)
|
---|
1819 | return FALSE;
|
---|
1820 |
|
---|
1821 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
1822 | if (LOWORD(lParam) == FALSE)
|
---|
1823 | btnPtr->fsState &= ~TBSTATE_INDETERMINATE;
|
---|
1824 | else
|
---|
1825 | btnPtr->fsState |= TBSTATE_INDETERMINATE;
|
---|
1826 |
|
---|
1827 | hdc = GetDC (hwnd);
|
---|
1828 | TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
|
---|
1829 | ReleaseDC (hwnd, hdc);
|
---|
1830 |
|
---|
1831 | return TRUE;
|
---|
1832 | }
|
---|
1833 |
|
---|
1834 |
|
---|
1835 | static LRESULT
|
---|
1836 | TOOLBAR_InsertButtonA (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1837 | {
|
---|
1838 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1839 | LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
|
---|
1840 | INT nIndex = (INT)wParam;
|
---|
1841 | TBUTTON_INFO *oldButtons;
|
---|
1842 |
|
---|
1843 | if (lpTbb == NULL)
|
---|
1844 | return FALSE;
|
---|
1845 | if (nIndex < 0)
|
---|
1846 | return FALSE;
|
---|
1847 |
|
---|
1848 | // TRACE (toolbar, "inserting button index=%d\n", nIndex);
|
---|
1849 | if (nIndex > infoPtr->nNumButtons) {
|
---|
1850 | nIndex = infoPtr->nNumButtons;
|
---|
1851 | // TRACE (toolbar, "adjust index=%d\n", nIndex);
|
---|
1852 | }
|
---|
1853 |
|
---|
1854 | oldButtons = infoPtr->buttons;
|
---|
1855 | infoPtr->nNumButtons++;
|
---|
1856 | infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
|
---|
1857 | /* pre insert copy */
|
---|
1858 | if (nIndex > 0) {
|
---|
1859 | memcpy (&infoPtr->buttons[0], &oldButtons[0],
|
---|
1860 | nIndex * sizeof(TBUTTON_INFO));
|
---|
1861 | }
|
---|
1862 |
|
---|
1863 | /* insert new button */
|
---|
1864 | infoPtr->buttons[nIndex].iBitmap = lpTbb->iBitmap;
|
---|
1865 | infoPtr->buttons[nIndex].idCommand = lpTbb->idCommand;
|
---|
1866 | infoPtr->buttons[nIndex].fsState = lpTbb->fsState;
|
---|
1867 | infoPtr->buttons[nIndex].fsStyle = lpTbb->fsStyle;
|
---|
1868 | infoPtr->buttons[nIndex].dwData = lpTbb->dwData;
|
---|
1869 | infoPtr->buttons[nIndex].iString = lpTbb->iString;
|
---|
1870 |
|
---|
1871 | if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) {
|
---|
1872 | TTTOOLINFOA ti;
|
---|
1873 |
|
---|
1874 | ZeroMemory (&ti, sizeof(TTTOOLINFOA));
|
---|
1875 | ti.cbSize = sizeof (TTTOOLINFOA);
|
---|
1876 | ti.hwnd = hwnd;
|
---|
1877 | ti.uId = lpTbb->idCommand;
|
---|
1878 | ti.hinst = 0;
|
---|
1879 | ti.lpszText = LPSTR_TEXTCALLBACKA;
|
---|
1880 |
|
---|
1881 | SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
|
---|
1882 | 0, (LPARAM)&ti);
|
---|
1883 | }
|
---|
1884 |
|
---|
1885 | /* post insert copy */
|
---|
1886 | if (nIndex < infoPtr->nNumButtons - 1) {
|
---|
1887 | memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex],
|
---|
1888 | (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO));
|
---|
1889 | }
|
---|
1890 |
|
---|
1891 | COMCTL32_Free (oldButtons);
|
---|
1892 |
|
---|
1893 | TOOLBAR_CalcToolbar (hwnd);
|
---|
1894 |
|
---|
1895 | InvalidateRect (hwnd, NULL, FALSE);
|
---|
1896 |
|
---|
1897 | return TRUE;
|
---|
1898 | }
|
---|
1899 |
|
---|
1900 |
|
---|
1901 | /* << TOOLBAR_InsertButton32W >> */
|
---|
1902 | /* << TOOLBAR_InsertMarkHitTest >> */
|
---|
1903 |
|
---|
1904 |
|
---|
1905 | static LRESULT
|
---|
1906 | TOOLBAR_IsButtonChecked (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1907 | {
|
---|
1908 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1909 | INT nIndex;
|
---|
1910 |
|
---|
1911 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
1912 | if (nIndex == -1)
|
---|
1913 | return FALSE;
|
---|
1914 |
|
---|
1915 | return (infoPtr->buttons[nIndex].fsState & TBSTATE_CHECKED);
|
---|
1916 | }
|
---|
1917 |
|
---|
1918 |
|
---|
1919 | static LRESULT
|
---|
1920 | TOOLBAR_IsButtonEnabled (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1921 | {
|
---|
1922 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1923 | INT nIndex;
|
---|
1924 |
|
---|
1925 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
1926 | if (nIndex == -1)
|
---|
1927 | return FALSE;
|
---|
1928 |
|
---|
1929 | return (infoPtr->buttons[nIndex].fsState & TBSTATE_ENABLED);
|
---|
1930 | }
|
---|
1931 |
|
---|
1932 |
|
---|
1933 | static LRESULT
|
---|
1934 | TOOLBAR_IsButtonHidden (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1935 | {
|
---|
1936 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1937 | INT nIndex;
|
---|
1938 |
|
---|
1939 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
1940 | if (nIndex == -1)
|
---|
1941 | return FALSE;
|
---|
1942 |
|
---|
1943 | return (infoPtr->buttons[nIndex].fsState & TBSTATE_HIDDEN);
|
---|
1944 | }
|
---|
1945 |
|
---|
1946 |
|
---|
1947 | static LRESULT
|
---|
1948 | TOOLBAR_IsButtonHighlighted (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1949 | {
|
---|
1950 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1951 | INT nIndex;
|
---|
1952 |
|
---|
1953 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
1954 | if (nIndex == -1)
|
---|
1955 | return FALSE;
|
---|
1956 |
|
---|
1957 | return (infoPtr->buttons[nIndex].fsState & TBSTATE_MARKED);
|
---|
1958 | }
|
---|
1959 |
|
---|
1960 |
|
---|
1961 | static LRESULT
|
---|
1962 | TOOLBAR_IsButtonIndeterminate (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1963 | {
|
---|
1964 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1965 | INT nIndex;
|
---|
1966 |
|
---|
1967 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
1968 | if (nIndex == -1)
|
---|
1969 | return FALSE;
|
---|
1970 |
|
---|
1971 | return (infoPtr->buttons[nIndex].fsState & TBSTATE_INDETERMINATE);
|
---|
1972 | }
|
---|
1973 |
|
---|
1974 |
|
---|
1975 | static LRESULT
|
---|
1976 | TOOLBAR_IsButtonPressed (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1977 | {
|
---|
1978 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1979 | INT nIndex;
|
---|
1980 |
|
---|
1981 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
1982 | if (nIndex == -1)
|
---|
1983 | return FALSE;
|
---|
1984 |
|
---|
1985 | return (infoPtr->buttons[nIndex].fsState & TBSTATE_PRESSED);
|
---|
1986 | }
|
---|
1987 |
|
---|
1988 |
|
---|
1989 | /* << TOOLBAR_LoadImages >> */
|
---|
1990 | /* << TOOLBAR_MapAccelerator >> */
|
---|
1991 | /* << TOOLBAR_MarkButton >> */
|
---|
1992 | /* << TOOLBAR_MoveButton >> */
|
---|
1993 |
|
---|
1994 |
|
---|
1995 | static LRESULT
|
---|
1996 | TOOLBAR_PressButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1997 | {
|
---|
1998 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1999 | TBUTTON_INFO *btnPtr;
|
---|
2000 | HDC hdc;
|
---|
2001 | INT nIndex;
|
---|
2002 |
|
---|
2003 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
2004 | if (nIndex == -1)
|
---|
2005 | return FALSE;
|
---|
2006 |
|
---|
2007 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
2008 | if (LOWORD(lParam) == FALSE)
|
---|
2009 | btnPtr->fsState &= ~TBSTATE_PRESSED;
|
---|
2010 | else
|
---|
2011 | btnPtr->fsState |= TBSTATE_PRESSED;
|
---|
2012 |
|
---|
2013 | hdc = GetDC (hwnd);
|
---|
2014 | TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
|
---|
2015 | ReleaseDC (hwnd, hdc);
|
---|
2016 |
|
---|
2017 | return TRUE;
|
---|
2018 | }
|
---|
2019 |
|
---|
2020 |
|
---|
2021 | /* << TOOLBAR_ReplaceBitmap >> */
|
---|
2022 |
|
---|
2023 |
|
---|
2024 | static LRESULT
|
---|
2025 | TOOLBAR_SaveRestoreA (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2026 | {
|
---|
2027 | #if 0
|
---|
2028 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2029 | LPTBSAVEPARAMSA lpSave = (LPTBSAVEPARAMSA)lParam;
|
---|
2030 |
|
---|
2031 | if (lpSave == NULL) return 0;
|
---|
2032 |
|
---|
2033 | if ((BOOL)wParam) {
|
---|
2034 | /* save toolbar information */
|
---|
2035 | // FIXME (toolbar, "save to \"%s\" \"%s\"\n",
|
---|
2036 | // lpSave->pszSubKey, lpSave->pszValueName);
|
---|
2037 |
|
---|
2038 |
|
---|
2039 | }
|
---|
2040 | else {
|
---|
2041 | /* restore toolbar information */
|
---|
2042 |
|
---|
2043 | // FIXME (toolbar, "restore from \"%s\" \"%s\"\n",
|
---|
2044 | // lpSave->pszSubKey, lpSave->pszValueName);
|
---|
2045 |
|
---|
2046 |
|
---|
2047 | }
|
---|
2048 | #endif
|
---|
2049 |
|
---|
2050 | return 0;
|
---|
2051 | }
|
---|
2052 |
|
---|
2053 |
|
---|
2054 | /* << TOOLBAR_SaveRestore32W >> */
|
---|
2055 | /* << TOOLBAR_SetAnchorHighlight >> */
|
---|
2056 |
|
---|
2057 |
|
---|
2058 | static LRESULT
|
---|
2059 | TOOLBAR_SetBitmapSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2060 | {
|
---|
2061 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2062 |
|
---|
2063 | if ((LOWORD(lParam) <= 0) || (HIWORD(lParam) <= 0)) return FALSE;
|
---|
2064 |
|
---|
2065 | infoPtr->nBitmapWidth = (INT)LOWORD(lParam);
|
---|
2066 | infoPtr->nBitmapHeight = (INT)HIWORD(lParam);
|
---|
2067 |
|
---|
2068 | return TRUE;
|
---|
2069 | }
|
---|
2070 |
|
---|
2071 |
|
---|
2072 | static LRESULT
|
---|
2073 | TOOLBAR_SetButtonInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2074 | {
|
---|
2075 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2076 | LPTBBUTTONINFOA lptbbi = (LPTBBUTTONINFOA)lParam;
|
---|
2077 | TBUTTON_INFO *btnPtr;
|
---|
2078 | INT nIndex;
|
---|
2079 |
|
---|
2080 | if (lptbbi == NULL)
|
---|
2081 | return FALSE;
|
---|
2082 | if (lptbbi->cbSize < sizeof(TBBUTTONINFOA))
|
---|
2083 | return FALSE;
|
---|
2084 |
|
---|
2085 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
2086 | if (nIndex == -1)
|
---|
2087 | return FALSE;
|
---|
2088 |
|
---|
2089 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
2090 | if (lptbbi->dwMask & TBIF_COMMAND)
|
---|
2091 | btnPtr->idCommand = lptbbi->idCommand;
|
---|
2092 | if (lptbbi->dwMask & TBIF_IMAGE)
|
---|
2093 | btnPtr->iBitmap = lptbbi->iImage;
|
---|
2094 | if (lptbbi->dwMask & TBIF_LPARAM)
|
---|
2095 | btnPtr->dwData = lptbbi->lParam;
|
---|
2096 | /* if (lptbbi->dwMask & TBIF_SIZE) */
|
---|
2097 | /* btnPtr->cx = lptbbi->cx; */
|
---|
2098 | if (lptbbi->dwMask & TBIF_STATE)
|
---|
2099 | btnPtr->fsState = lptbbi->fsState;
|
---|
2100 | if (lptbbi->dwMask & TBIF_STYLE)
|
---|
2101 | btnPtr->fsStyle = lptbbi->fsStyle;
|
---|
2102 |
|
---|
2103 | if (lptbbi->dwMask & TBIF_TEXT) {
|
---|
2104 | if ((btnPtr->iString >= 0) ||
|
---|
2105 | (btnPtr->iString < infoPtr->nNumStrings)) {
|
---|
2106 | #if 0
|
---|
2107 | CHAR **lpString = &infoPtr->strings[btnPtr->iString];
|
---|
2108 | INT len = lstrlenA (lptbbi->pszText);
|
---|
2109 | *lpString = COMCTL32_ReAlloc (lpString, sizeof(char)*(len+1));
|
---|
2110 | #endif
|
---|
2111 |
|
---|
2112 | /* this is the ultimate sollution */
|
---|
2113 | /* Str_SetPtrA (&infoPtr->strings[btnPtr->iString], lptbbi->pszText); */
|
---|
2114 | }
|
---|
2115 | }
|
---|
2116 |
|
---|
2117 | return TRUE;
|
---|
2118 | }
|
---|
2119 |
|
---|
2120 |
|
---|
2121 | /* << TOOLBAR_SetButtonInfo32W >> */
|
---|
2122 |
|
---|
2123 |
|
---|
2124 | static LRESULT
|
---|
2125 | TOOLBAR_SetButtonSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2126 | {
|
---|
2127 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2128 |
|
---|
2129 | if ((LOWORD(lParam) <= 0) || (HIWORD(lParam) <= 0)) return FALSE;
|
---|
2130 |
|
---|
2131 | infoPtr->nButtonWidth = (INT)LOWORD(lParam);
|
---|
2132 | infoPtr->nButtonHeight = (INT)HIWORD(lParam);
|
---|
2133 |
|
---|
2134 | return TRUE;
|
---|
2135 | }
|
---|
2136 |
|
---|
2137 |
|
---|
2138 | static LRESULT
|
---|
2139 | TOOLBAR_SetButtonWidth (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2140 | {
|
---|
2141 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2142 |
|
---|
2143 | if (infoPtr == NULL)
|
---|
2144 | return FALSE;
|
---|
2145 |
|
---|
2146 | infoPtr->cxMin = (INT)LOWORD(lParam);
|
---|
2147 | infoPtr->cxMax = (INT)HIWORD(lParam);
|
---|
2148 |
|
---|
2149 | return TRUE;
|
---|
2150 | }
|
---|
2151 |
|
---|
2152 |
|
---|
2153 | static LRESULT
|
---|
2154 | TOOLBAR_SetCmdId (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2155 | {
|
---|
2156 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2157 | INT nIndex = (INT)wParam;
|
---|
2158 |
|
---|
2159 | if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
|
---|
2160 | return FALSE;
|
---|
2161 |
|
---|
2162 | infoPtr->buttons[nIndex].idCommand = (INT)lParam;
|
---|
2163 |
|
---|
2164 | if (infoPtr->hwndToolTip) {
|
---|
2165 |
|
---|
2166 | // FIXME (toolbar, "change tool tip!\n");
|
---|
2167 |
|
---|
2168 | }
|
---|
2169 |
|
---|
2170 | return TRUE;
|
---|
2171 | }
|
---|
2172 |
|
---|
2173 |
|
---|
2174 | /* << TOOLBAR_SetColorScheme >> */
|
---|
2175 |
|
---|
2176 |
|
---|
2177 | static LRESULT
|
---|
2178 | TOOLBAR_SetDisabledImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2179 | {
|
---|
2180 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2181 | HIMAGELIST himlTemp;
|
---|
2182 |
|
---|
2183 | if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT))
|
---|
2184 | return 0;
|
---|
2185 |
|
---|
2186 | himlTemp = infoPtr->himlDis;
|
---|
2187 | infoPtr->himlDis = (HIMAGELIST)lParam;
|
---|
2188 |
|
---|
2189 | /* FIXME: redraw ? */
|
---|
2190 |
|
---|
2191 | return (LRESULT)himlTemp;
|
---|
2192 | }
|
---|
2193 |
|
---|
2194 |
|
---|
2195 | static LRESULT
|
---|
2196 | TOOLBAR_SetDrawTextFlags (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2197 | {
|
---|
2198 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2199 | DWORD dwTemp;
|
---|
2200 |
|
---|
2201 | dwTemp = infoPtr->dwDTFlags;
|
---|
2202 | infoPtr->dwDTFlags =
|
---|
2203 | (infoPtr->dwDTFlags & (DWORD)wParam) | (DWORD)lParam;
|
---|
2204 |
|
---|
2205 | return (LRESULT)dwTemp;
|
---|
2206 | }
|
---|
2207 |
|
---|
2208 |
|
---|
2209 | static LRESULT
|
---|
2210 | TOOLBAR_SetExtendedStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2211 | {
|
---|
2212 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2213 | DWORD dwTemp;
|
---|
2214 |
|
---|
2215 | dwTemp = infoPtr->dwExStyle;
|
---|
2216 | infoPtr->dwExStyle = (DWORD)lParam;
|
---|
2217 |
|
---|
2218 | return (LRESULT)dwTemp;
|
---|
2219 | }
|
---|
2220 |
|
---|
2221 |
|
---|
2222 | static LRESULT
|
---|
2223 | TOOLBAR_SetHotImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2224 | {
|
---|
2225 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
|
---|
2226 | HIMAGELIST himlTemp;
|
---|
2227 |
|
---|
2228 | if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT))
|
---|
2229 | return 0;
|
---|
2230 |
|
---|
2231 | himlTemp = infoPtr->himlHot;
|
---|
2232 | infoPtr->himlHot = (HIMAGELIST)lParam;
|
---|
2233 |
|
---|
2234 | /* FIXME: redraw ? */
|
---|
2235 |
|
---|
2236 | return (LRESULT)himlTemp;
|
---|
2237 | }
|
---|
2238 |
|
---|
2239 |
|
---|
2240 | /* << TOOLBAR_SetHotItem >> */
|
---|
2241 |
|
---|
2242 |
|
---|
2243 | static LRESULT
|
---|
2244 | TOOLBAR_SetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2245 | {
|
---|
2246 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2247 | HIMAGELIST himlTemp;
|
---|
2248 |
|
---|
2249 | if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT))
|
---|
2250 | return 0;
|
---|
2251 |
|
---|
2252 | himlTemp = infoPtr->himlDef;
|
---|
2253 | infoPtr->himlDef = (HIMAGELIST)lParam;
|
---|
2254 |
|
---|
2255 | /* FIXME: redraw ? */
|
---|
2256 |
|
---|
2257 | return (LRESULT)himlTemp;
|
---|
2258 | }
|
---|
2259 |
|
---|
2260 |
|
---|
2261 | static LRESULT
|
---|
2262 | TOOLBAR_SetIndent (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2263 | {
|
---|
2264 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2265 |
|
---|
2266 | infoPtr->nIndent = (INT)wParam;
|
---|
2267 |
|
---|
2268 | TOOLBAR_CalcToolbar (hwnd);
|
---|
2269 |
|
---|
2270 | InvalidateRect(hwnd, NULL, FALSE);
|
---|
2271 |
|
---|
2272 | return TRUE;
|
---|
2273 | }
|
---|
2274 |
|
---|
2275 |
|
---|
2276 | /* << TOOLBAR_SetInsertMark >> */
|
---|
2277 |
|
---|
2278 |
|
---|
2279 | static LRESULT
|
---|
2280 | TOOLBAR_SetInsertMarkColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2281 | {
|
---|
2282 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2283 |
|
---|
2284 | infoPtr->clrInsertMark = (COLORREF)lParam;
|
---|
2285 |
|
---|
2286 | /* FIXME : redraw ??*/
|
---|
2287 |
|
---|
2288 | return 0;
|
---|
2289 | }
|
---|
2290 |
|
---|
2291 |
|
---|
2292 | static LRESULT
|
---|
2293 | TOOLBAR_SetMaxTextRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2294 | {
|
---|
2295 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2296 |
|
---|
2297 | if (infoPtr == NULL)
|
---|
2298 | return FALSE;
|
---|
2299 |
|
---|
2300 | infoPtr->nMaxTextRows = (INT)wParam;
|
---|
2301 |
|
---|
2302 | return TRUE;
|
---|
2303 | }
|
---|
2304 |
|
---|
2305 |
|
---|
2306 | /* << TOOLBAR_SetPadding >> */
|
---|
2307 |
|
---|
2308 |
|
---|
2309 | static LRESULT
|
---|
2310 | TOOLBAR_SetParent (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2311 | {
|
---|
2312 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2313 | HWND hwndOldNotify;
|
---|
2314 |
|
---|
2315 | if (infoPtr == NULL)
|
---|
2316 | return 0;
|
---|
2317 | hwndOldNotify = infoPtr->hwndNotify;
|
---|
2318 | infoPtr->hwndNotify = (HWND)wParam;
|
---|
2319 |
|
---|
2320 | return hwndOldNotify;
|
---|
2321 | }
|
---|
2322 |
|
---|
2323 |
|
---|
2324 | static LRESULT
|
---|
2325 | TOOLBAR_SetRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2326 | {
|
---|
2327 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2328 | LPRECT lprc = (LPRECT)lParam;
|
---|
2329 |
|
---|
2330 | if (LOWORD(wParam) > 1) {
|
---|
2331 |
|
---|
2332 | // FIXME (toolbar, "multiple rows not supported!\n");
|
---|
2333 |
|
---|
2334 | }
|
---|
2335 |
|
---|
2336 | /* recalculate toolbar */
|
---|
2337 | TOOLBAR_CalcToolbar (hwnd);
|
---|
2338 |
|
---|
2339 | /* return bounding rectangle */
|
---|
2340 | if (lprc) {
|
---|
2341 | lprc->left = infoPtr->rcBound.left;
|
---|
2342 | lprc->right = infoPtr->rcBound.right;
|
---|
2343 | lprc->top = infoPtr->rcBound.top;
|
---|
2344 | lprc->bottom = infoPtr->rcBound.bottom;
|
---|
2345 | }
|
---|
2346 |
|
---|
2347 | /* repaint toolbar */
|
---|
2348 | InvalidateRect(hwnd, NULL, FALSE);
|
---|
2349 |
|
---|
2350 | return 0;
|
---|
2351 | }
|
---|
2352 |
|
---|
2353 |
|
---|
2354 | static LRESULT
|
---|
2355 | TOOLBAR_SetState (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2356 | {
|
---|
2357 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2358 | TBUTTON_INFO *btnPtr;
|
---|
2359 | HDC hdc;
|
---|
2360 | INT nIndex;
|
---|
2361 |
|
---|
2362 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
2363 | if (nIndex == -1)
|
---|
2364 | return FALSE;
|
---|
2365 |
|
---|
2366 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
2367 | btnPtr->fsState = LOWORD(lParam);
|
---|
2368 |
|
---|
2369 | hdc = GetDC (hwnd);
|
---|
2370 | TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
|
---|
2371 | ReleaseDC (hwnd, hdc);
|
---|
2372 |
|
---|
2373 | return TRUE;
|
---|
2374 | }
|
---|
2375 |
|
---|
2376 |
|
---|
2377 | static LRESULT
|
---|
2378 | TOOLBAR_SetStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2379 | {
|
---|
2380 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2381 | TBUTTON_INFO *btnPtr;
|
---|
2382 | HDC hdc;
|
---|
2383 | INT nIndex;
|
---|
2384 |
|
---|
2385 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
2386 | if (nIndex == -1)
|
---|
2387 | return FALSE;
|
---|
2388 |
|
---|
2389 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
2390 | btnPtr->fsStyle = LOWORD(lParam);
|
---|
2391 |
|
---|
2392 | hdc = GetDC (hwnd);
|
---|
2393 | TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
|
---|
2394 | ReleaseDC (hwnd, hdc);
|
---|
2395 |
|
---|
2396 | if (infoPtr->hwndToolTip) {
|
---|
2397 |
|
---|
2398 | // FIXME (toolbar, "change tool tip!\n");
|
---|
2399 |
|
---|
2400 | }
|
---|
2401 |
|
---|
2402 | return TRUE;
|
---|
2403 | }
|
---|
2404 |
|
---|
2405 |
|
---|
2406 | static LRESULT
|
---|
2407 | TOOLBAR_SetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2408 | {
|
---|
2409 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2410 |
|
---|
2411 | if (infoPtr == NULL)
|
---|
2412 | return 0;
|
---|
2413 | infoPtr->hwndToolTip = (HWND)wParam;
|
---|
2414 | return 0;
|
---|
2415 | }
|
---|
2416 |
|
---|
2417 |
|
---|
2418 | static LRESULT
|
---|
2419 | TOOLBAR_SetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2420 | {
|
---|
2421 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2422 | BOOL bTemp;
|
---|
2423 |
|
---|
2424 | // TRACE (toolbar, "%s hwnd=0x%04x stub!\n",
|
---|
2425 | // ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd);
|
---|
2426 |
|
---|
2427 | bTemp = infoPtr->bUnicode;
|
---|
2428 | infoPtr->bUnicode = (BOOL)wParam;
|
---|
2429 |
|
---|
2430 | return bTemp;
|
---|
2431 | }
|
---|
2432 |
|
---|
2433 |
|
---|
2434 | static LRESULT
|
---|
2435 | TOOLBAR_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2436 | {
|
---|
2437 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2438 | DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
|
---|
2439 | LOGFONTA logFont;
|
---|
2440 |
|
---|
2441 | /* initialize info structure */
|
---|
2442 | infoPtr->nButtonHeight = 22;
|
---|
2443 | infoPtr->nButtonWidth = 23;
|
---|
2444 | infoPtr->nBitmapHeight = 15;
|
---|
2445 | infoPtr->nBitmapWidth = 16;
|
---|
2446 |
|
---|
2447 | infoPtr->nHeight = infoPtr->nButtonHeight + TOP_BORDER + BOTTOM_BORDER;
|
---|
2448 | infoPtr->nRows = 1;
|
---|
2449 | infoPtr->nMaxTextRows = 1;
|
---|
2450 | infoPtr->cxMin = -1;
|
---|
2451 | infoPtr->cxMax = -1;
|
---|
2452 |
|
---|
2453 | infoPtr->bCaptured = FALSE;
|
---|
2454 | infoPtr->bUnicode = IsWindowUnicode(hwnd);
|
---|
2455 | infoPtr->nButtonDown = -1;
|
---|
2456 | infoPtr->nOldHit = -1;
|
---|
2457 | infoPtr->nHotItem = -2; /* It has to be initially different from nOldHit */
|
---|
2458 | infoPtr->hwndNotify = GetParent (hwnd);
|
---|
2459 | infoPtr->bTransparent = (dwStyle & TBSTYLE_FLAT);
|
---|
2460 | infoPtr->dwDTFlags = DT_CENTER;
|
---|
2461 |
|
---|
2462 | SystemParametersInfoA (SPI_GETICONTITLELOGFONT, 0, &logFont, 0);
|
---|
2463 | infoPtr->hFont = CreateFontIndirectA (&logFont);
|
---|
2464 |
|
---|
2465 | if (dwStyle & TBSTYLE_TOOLTIPS)
|
---|
2466 | {
|
---|
2467 | /* Create tooltip control */
|
---|
2468 | infoPtr->hwndToolTip =
|
---|
2469 | CreateWindowExA (WS_EX_TOOLWINDOW,TOOLTIPS_CLASSA,NULL,WS_POPUP,
|
---|
2470 | CW_USEDEFAULT,CW_USEDEFAULT,
|
---|
2471 | CW_USEDEFAULT,CW_USEDEFAULT,
|
---|
2472 | hwnd,0,0,0);
|
---|
2473 |
|
---|
2474 | /* Send NM_TOOLTIPSCREATED notification */
|
---|
2475 | if (infoPtr->hwndToolTip)
|
---|
2476 | {
|
---|
2477 | NMTOOLTIPSCREATED nmttc;
|
---|
2478 |
|
---|
2479 | nmttc.hdr.hwndFrom = hwnd;
|
---|
2480 | nmttc.hdr.idFrom = GetWindowLongA(hwnd,GWL_ID);
|
---|
2481 | nmttc.hdr.code = NM_TOOLTIPSCREATED;
|
---|
2482 | nmttc.hwndToolTips = infoPtr->hwndToolTip;
|
---|
2483 |
|
---|
2484 | SendMessageA(infoPtr->hwndNotify,WM_NOTIFY,(WPARAM)nmttc.hdr.idFrom,(LPARAM)&nmttc);
|
---|
2485 | }
|
---|
2486 | }
|
---|
2487 |
|
---|
2488 | return 0;
|
---|
2489 | }
|
---|
2490 |
|
---|
2491 |
|
---|
2492 | static LRESULT
|
---|
2493 | TOOLBAR_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2494 | {
|
---|
2495 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2496 |
|
---|
2497 | /* delete tooltip control */
|
---|
2498 | if (infoPtr->hwndToolTip)
|
---|
2499 | DestroyWindow (infoPtr->hwndToolTip);
|
---|
2500 |
|
---|
2501 | /* delete button data */
|
---|
2502 | if (infoPtr->buttons)
|
---|
2503 | COMCTL32_Free (infoPtr->buttons);
|
---|
2504 |
|
---|
2505 | /* delete strings */
|
---|
2506 | if (infoPtr->strings) {
|
---|
2507 | INT i;
|
---|
2508 | for (i = 0; i < infoPtr->nNumStrings; i++)
|
---|
2509 | if (infoPtr->strings[i])
|
---|
2510 | COMCTL32_Free (infoPtr->strings[i]);
|
---|
2511 |
|
---|
2512 | COMCTL32_Free (infoPtr->strings);
|
---|
2513 | }
|
---|
2514 |
|
---|
2515 | /* destroy default image list */
|
---|
2516 | if (infoPtr->himlDef)
|
---|
2517 | ImageList_Destroy (infoPtr->himlDef);
|
---|
2518 |
|
---|
2519 | /* destroy disabled image list */
|
---|
2520 | if (infoPtr->himlDis)
|
---|
2521 | ImageList_Destroy (infoPtr->himlDis);
|
---|
2522 |
|
---|
2523 | /* destroy hot image list */
|
---|
2524 | if (infoPtr->himlHot)
|
---|
2525 | ImageList_Destroy (infoPtr->himlHot);
|
---|
2526 |
|
---|
2527 | /* delete default font */
|
---|
2528 | if (infoPtr->hFont)
|
---|
2529 | DeleteObject (infoPtr->hFont);
|
---|
2530 |
|
---|
2531 | /* free toolbar info data */
|
---|
2532 | COMCTL32_Free (infoPtr);
|
---|
2533 |
|
---|
2534 | return 0;
|
---|
2535 | }
|
---|
2536 |
|
---|
2537 |
|
---|
2538 | static LRESULT
|
---|
2539 | TOOLBAR_EraseBackground (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2540 | {
|
---|
2541 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2542 |
|
---|
2543 | if (infoPtr->bTransparent)
|
---|
2544 | return SendMessageA (GetParent (hwnd), WM_ERASEBKGND, wParam, lParam);
|
---|
2545 |
|
---|
2546 | return DefWindowProcA (hwnd, WM_ERASEBKGND, wParam, lParam);
|
---|
2547 | }
|
---|
2548 |
|
---|
2549 |
|
---|
2550 | static LRESULT
|
---|
2551 | TOOLBAR_LButtonDblClk (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2552 | {
|
---|
2553 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2554 | TBUTTON_INFO *btnPtr;
|
---|
2555 | POINT pt;
|
---|
2556 | INT nHit;
|
---|
2557 | HDC hdc;
|
---|
2558 |
|
---|
2559 | pt.x = (INT)LOWORD(lParam);
|
---|
2560 | pt.y = (INT)HIWORD(lParam);
|
---|
2561 | nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
|
---|
2562 |
|
---|
2563 | if (nHit >= 0) {
|
---|
2564 | btnPtr = &infoPtr->buttons[nHit];
|
---|
2565 | if (!(btnPtr->fsState & TBSTATE_ENABLED))
|
---|
2566 | return 0;
|
---|
2567 | SetCapture (hwnd);
|
---|
2568 | infoPtr->bCaptured = TRUE;
|
---|
2569 | infoPtr->nButtonDown = nHit;
|
---|
2570 |
|
---|
2571 | btnPtr->fsState |= TBSTATE_PRESSED;
|
---|
2572 |
|
---|
2573 | hdc = GetDC (hwnd);
|
---|
2574 | TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
|
---|
2575 | ReleaseDC (hwnd, hdc);
|
---|
2576 | }
|
---|
2577 | else if (GetWindowLongA (hwnd, GWL_STYLE) & CCS_ADJUSTABLE)
|
---|
2578 | TOOLBAR_Customize (hwnd);
|
---|
2579 |
|
---|
2580 | return 0;
|
---|
2581 | }
|
---|
2582 |
|
---|
2583 |
|
---|
2584 | static LRESULT
|
---|
2585 | TOOLBAR_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2586 | {
|
---|
2587 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2588 | TBUTTON_INFO *btnPtr;
|
---|
2589 | POINT pt;
|
---|
2590 | INT nHit;
|
---|
2591 | HDC hdc;
|
---|
2592 |
|
---|
2593 | if (infoPtr->hwndToolTip)
|
---|
2594 | TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
|
---|
2595 | WM_LBUTTONDOWN, wParam, lParam);
|
---|
2596 |
|
---|
2597 | pt.x = (INT)LOWORD(lParam);
|
---|
2598 | pt.y = (INT)HIWORD(lParam);
|
---|
2599 | nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
|
---|
2600 |
|
---|
2601 | if (nHit >= 0) {
|
---|
2602 | btnPtr = &infoPtr->buttons[nHit];
|
---|
2603 | if (!(btnPtr->fsState & TBSTATE_ENABLED))
|
---|
2604 | return 0;
|
---|
2605 |
|
---|
2606 | SetCapture (hwnd);
|
---|
2607 | infoPtr->bCaptured = TRUE;
|
---|
2608 | infoPtr->nButtonDown = nHit;
|
---|
2609 | infoPtr->nOldHit = nHit;
|
---|
2610 |
|
---|
2611 | btnPtr->fsState |= TBSTATE_PRESSED;
|
---|
2612 |
|
---|
2613 | hdc = GetDC (hwnd);
|
---|
2614 | TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
|
---|
2615 | ReleaseDC (hwnd, hdc);
|
---|
2616 | }
|
---|
2617 |
|
---|
2618 | return 0;
|
---|
2619 | }
|
---|
2620 |
|
---|
2621 |
|
---|
2622 | static LRESULT
|
---|
2623 | TOOLBAR_LButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2624 | {
|
---|
2625 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2626 | TBUTTON_INFO *btnPtr;
|
---|
2627 | POINT pt;
|
---|
2628 | INT nHit;
|
---|
2629 | INT nOldIndex = -1;
|
---|
2630 | HDC hdc;
|
---|
2631 | BOOL bSendMessage = TRUE;
|
---|
2632 |
|
---|
2633 | if (infoPtr->hwndToolTip)
|
---|
2634 | TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
|
---|
2635 | WM_LBUTTONUP, wParam, lParam);
|
---|
2636 |
|
---|
2637 | pt.x = (INT)LOWORD(lParam);
|
---|
2638 | pt.y = (INT)HIWORD(lParam);
|
---|
2639 | nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
|
---|
2640 |
|
---|
2641 | if ((infoPtr->bCaptured) && (infoPtr->nButtonDown >= 0)) {
|
---|
2642 | infoPtr->bCaptured = FALSE;
|
---|
2643 | ReleaseCapture ();
|
---|
2644 | btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
|
---|
2645 | btnPtr->fsState &= ~TBSTATE_PRESSED;
|
---|
2646 |
|
---|
2647 | if (nHit == infoPtr->nButtonDown) {
|
---|
2648 | if (btnPtr->fsStyle & TBSTYLE_CHECK) {
|
---|
2649 | if (btnPtr->fsStyle & TBSTYLE_GROUP) {
|
---|
2650 | nOldIndex = TOOLBAR_GetCheckedGroupButtonIndex (infoPtr,
|
---|
2651 | infoPtr->nButtonDown);
|
---|
2652 | if (nOldIndex == infoPtr->nButtonDown)
|
---|
2653 | bSendMessage = FALSE;
|
---|
2654 | if ((nOldIndex != infoPtr->nButtonDown) &&
|
---|
2655 | (nOldIndex != -1))
|
---|
2656 | infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
|
---|
2657 | btnPtr->fsState |= TBSTATE_CHECKED;
|
---|
2658 | }
|
---|
2659 | else {
|
---|
2660 | if (btnPtr->fsState & TBSTATE_CHECKED)
|
---|
2661 | btnPtr->fsState &= ~TBSTATE_CHECKED;
|
---|
2662 | else
|
---|
2663 | btnPtr->fsState |= TBSTATE_CHECKED;
|
---|
2664 | }
|
---|
2665 | }
|
---|
2666 | }
|
---|
2667 | else
|
---|
2668 | bSendMessage = FALSE;
|
---|
2669 |
|
---|
2670 | hdc = GetDC (hwnd);
|
---|
2671 | if (nOldIndex != -1)
|
---|
2672 | TOOLBAR_DrawButton (hwnd, &infoPtr->buttons[nOldIndex], hdc);
|
---|
2673 | TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
|
---|
2674 | ReleaseDC (hwnd, hdc);
|
---|
2675 |
|
---|
2676 | if (bSendMessage)
|
---|
2677 | SendMessageA (infoPtr->hwndNotify, WM_COMMAND,
|
---|
2678 | MAKEWPARAM(btnPtr->idCommand, 0), (LPARAM)hwnd);
|
---|
2679 |
|
---|
2680 | infoPtr->nButtonDown = -1;
|
---|
2681 | infoPtr->nOldHit = -1;
|
---|
2682 | }
|
---|
2683 |
|
---|
2684 | return 0;
|
---|
2685 | }
|
---|
2686 |
|
---|
2687 |
|
---|
2688 | static LRESULT
|
---|
2689 | TOOLBAR_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2690 | {
|
---|
2691 | TBUTTON_INFO *btnPtr, *oldBtnPtr;
|
---|
2692 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2693 | POINT pt;
|
---|
2694 | INT nHit;
|
---|
2695 | HDC hdc;
|
---|
2696 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
|
---|
2697 |
|
---|
2698 | if (infoPtr->hwndToolTip)
|
---|
2699 | TOOLBAR_RelayEvent (infoPtr->hwndToolTip,hwnd,
|
---|
2700 | WM_MOUSEMOVE,wParam,lParam);
|
---|
2701 |
|
---|
2702 | pt.x = (INT)LOWORD(lParam);
|
---|
2703 | pt.y = (INT)HIWORD(lParam);
|
---|
2704 |
|
---|
2705 | nHit = TOOLBAR_InternalHitTest(hwnd,&pt);
|
---|
2706 |
|
---|
2707 | if (infoPtr->nOldHit != nHit)
|
---|
2708 | {
|
---|
2709 | /* Remove the effect of an old hot button */
|
---|
2710 | if(infoPtr->nOldHit == infoPtr->nHotItem)
|
---|
2711 | {
|
---|
2712 | oldBtnPtr = &infoPtr->buttons[infoPtr->nOldHit];
|
---|
2713 | if (oldBtnPtr->bHot)
|
---|
2714 | {
|
---|
2715 | oldBtnPtr->bHot = FALSE;
|
---|
2716 |
|
---|
2717 | if (dwStyle & TBSTYLE_FLAT) InvalidateRect(hwnd,&oldBtnPtr->rect,TRUE);
|
---|
2718 | }
|
---|
2719 | }
|
---|
2720 |
|
---|
2721 | /* It's not a separator or in nowhere. It's a hot button. */
|
---|
2722 | if (nHit >= 0)
|
---|
2723 | {
|
---|
2724 | btnPtr = &infoPtr->buttons[nHit];
|
---|
2725 | if (!btnPtr->bHot)
|
---|
2726 | {
|
---|
2727 | btnPtr->bHot = TRUE;
|
---|
2728 |
|
---|
2729 | if (dwStyle & TBSTYLE_FLAT)
|
---|
2730 | {
|
---|
2731 | hdc = GetDC (hwnd);
|
---|
2732 | TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
|
---|
2733 | ReleaseDC (hwnd, hdc);
|
---|
2734 | }
|
---|
2735 |
|
---|
2736 | infoPtr->nHotItem = nHit;
|
---|
2737 | }
|
---|
2738 | }
|
---|
2739 |
|
---|
2740 | if (infoPtr->bCaptured)
|
---|
2741 | {
|
---|
2742 | btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
|
---|
2743 | if (infoPtr->nOldHit == infoPtr->nButtonDown)
|
---|
2744 | {
|
---|
2745 | btnPtr->fsState &= ~TBSTATE_PRESSED;
|
---|
2746 |
|
---|
2747 | hdc = GetDC (hwnd);
|
---|
2748 | TOOLBAR_DrawButton(hwnd,btnPtr,hdc);
|
---|
2749 | ReleaseDC(hwnd,hdc);
|
---|
2750 | } else if (nHit == infoPtr->nButtonDown)
|
---|
2751 | {
|
---|
2752 | btnPtr->fsState |= TBSTATE_PRESSED;
|
---|
2753 |
|
---|
2754 | hdc = GetDC(hwnd);
|
---|
2755 | TOOLBAR_DrawButton(hwnd,btnPtr,hdc);
|
---|
2756 | ReleaseDC(hwnd,hdc);
|
---|
2757 | }
|
---|
2758 | }
|
---|
2759 | infoPtr->nOldHit = nHit;
|
---|
2760 | }
|
---|
2761 | return 0;
|
---|
2762 | }
|
---|
2763 |
|
---|
2764 |
|
---|
2765 | static LRESULT
|
---|
2766 | TOOLBAR_NCActivate (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2767 | {
|
---|
2768 | /* if (wndPtr->dwStyle & CCS_NODIVIDER) */
|
---|
2769 | return DefWindowProcA (hwnd, WM_NCACTIVATE, wParam, lParam);
|
---|
2770 | /* else */
|
---|
2771 | /* return TOOLBAR_NCPaint (wndPtr, wParam, lParam); */
|
---|
2772 | }
|
---|
2773 |
|
---|
2774 |
|
---|
2775 | static LRESULT
|
---|
2776 | TOOLBAR_NCCalcSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2777 | {
|
---|
2778 | if (!(GetWindowLongA (hwnd, GWL_STYLE) & CCS_NODIVIDER))
|
---|
2779 | ((LPRECT)lParam)->top += GetSystemMetrics(SM_CYEDGE);
|
---|
2780 |
|
---|
2781 | return DefWindowProcA (hwnd, WM_NCCALCSIZE, wParam, lParam);
|
---|
2782 | }
|
---|
2783 |
|
---|
2784 |
|
---|
2785 | static LRESULT
|
---|
2786 | TOOLBAR_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2787 | {
|
---|
2788 | TOOLBAR_INFO *infoPtr;
|
---|
2789 |
|
---|
2790 | /* allocate memory for info structure */
|
---|
2791 | infoPtr = (TOOLBAR_INFO *)COMCTL32_Alloc (sizeof(TOOLBAR_INFO));
|
---|
2792 | SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
|
---|
2793 |
|
---|
2794 | /* paranoid!! */
|
---|
2795 | infoPtr->dwStructSize = sizeof(TBBUTTON);
|
---|
2796 |
|
---|
2797 | /* fix instance handle, if the toolbar was created by CreateToolbarEx() */
|
---|
2798 | if (!GetWindowLongA (hwnd, GWL_HINSTANCE)) {
|
---|
2799 | HINSTANCE hInst = (HINSTANCE)GetWindowLongA (GetParent (hwnd), GWL_HINSTANCE);
|
---|
2800 | SetWindowLongA (hwnd, GWL_HINSTANCE, (DWORD)hInst);
|
---|
2801 | }
|
---|
2802 |
|
---|
2803 | return DefWindowProcA (hwnd, WM_NCCREATE, wParam, lParam);
|
---|
2804 | }
|
---|
2805 |
|
---|
2806 |
|
---|
2807 | static LRESULT
|
---|
2808 | TOOLBAR_NCPaint (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2809 | {
|
---|
2810 | DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
|
---|
2811 | RECT rcWindow;
|
---|
2812 | HDC hdc;
|
---|
2813 |
|
---|
2814 | if (dwStyle & WS_MINIMIZE)
|
---|
2815 | return 0; /* Nothing to do */
|
---|
2816 |
|
---|
2817 | DefWindowProcA (hwnd, WM_NCPAINT, wParam, lParam);
|
---|
2818 |
|
---|
2819 | if (!(hdc = GetDCEx (hwnd, 0, DCX_USESTYLE | DCX_WINDOW)))
|
---|
2820 | return 0;
|
---|
2821 |
|
---|
2822 | if (!(dwStyle & CCS_NODIVIDER))
|
---|
2823 | {
|
---|
2824 | GetWindowRect (hwnd, &rcWindow);
|
---|
2825 | OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
|
---|
2826 | DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_TOP);
|
---|
2827 | }
|
---|
2828 |
|
---|
2829 | ReleaseDC( hwnd, hdc );
|
---|
2830 |
|
---|
2831 | return 0;
|
---|
2832 | }
|
---|
2833 |
|
---|
2834 |
|
---|
2835 | static LRESULT
|
---|
2836 | TOOLBAR_Notify (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2837 | {
|
---|
2838 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2839 | LPNMHDR lpnmh = (LPNMHDR)lParam;
|
---|
2840 |
|
---|
2841 | // TRACE (toolbar, "passing WM_NOTIFY!\n");
|
---|
2842 |
|
---|
2843 | if ((infoPtr->hwndToolTip) && (lpnmh->hwndFrom == infoPtr->hwndToolTip)) {
|
---|
2844 | SendMessageA (infoPtr->hwndNotify, WM_NOTIFY, wParam, lParam);
|
---|
2845 |
|
---|
2846 | #if 0
|
---|
2847 | if (lpnmh->code == TTN_GETDISPINFOA) {
|
---|
2848 | LPNMTTDISPINFOA lpdi = (LPNMTTDISPINFOA)lParam;
|
---|
2849 |
|
---|
2850 | // FIXME (toolbar, "retrieving ASCII string\n");
|
---|
2851 |
|
---|
2852 | }
|
---|
2853 | else if (lpnmh->code == TTN_GETDISPINFOW) {
|
---|
2854 | LPNMTTDISPINFOW lpdi = (LPNMTTDISPINFOW)lParam;
|
---|
2855 |
|
---|
2856 | // FIXME (toolbar, "retrieving UNICODE string\n");
|
---|
2857 |
|
---|
2858 | }
|
---|
2859 | #endif
|
---|
2860 | }
|
---|
2861 |
|
---|
2862 | return 0;
|
---|
2863 | }
|
---|
2864 |
|
---|
2865 |
|
---|
2866 | static LRESULT
|
---|
2867 | TOOLBAR_Paint (HWND hwnd, WPARAM wParam)
|
---|
2868 | {
|
---|
2869 | HDC hdc;
|
---|
2870 | PAINTSTRUCT ps;
|
---|
2871 |
|
---|
2872 | TOOLBAR_CalcToolbar(hwnd);
|
---|
2873 | hdc = wParam == 0 ? BeginPaint(hwnd,&ps) : (HDC)wParam;
|
---|
2874 | TOOLBAR_Refresh(hwnd,hdc);
|
---|
2875 | if (!wParam) EndPaint (hwnd, &ps);
|
---|
2876 | return 0;
|
---|
2877 | }
|
---|
2878 |
|
---|
2879 |
|
---|
2880 | static LRESULT
|
---|
2881 | TOOLBAR_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2882 | {
|
---|
2883 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2884 | DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
|
---|
2885 | RECT parent_rect;
|
---|
2886 | HWND parent;
|
---|
2887 | /* INT32 x, y; */
|
---|
2888 | INT cx, cy;
|
---|
2889 | INT flags;
|
---|
2890 | UINT uPosFlags = 0;
|
---|
2891 |
|
---|
2892 | /* Resize deadlock check */
|
---|
2893 | if (infoPtr->bAutoSize) {
|
---|
2894 | infoPtr->bAutoSize = FALSE;
|
---|
2895 | return 0;
|
---|
2896 | }
|
---|
2897 |
|
---|
2898 | flags = (INT) wParam;
|
---|
2899 |
|
---|
2900 | /* FIXME for flags =
|
---|
2901 | * SIZE_MAXIMIZED, SIZE_MAXSHOW, SIZE_MINIMIZED
|
---|
2902 | */
|
---|
2903 |
|
---|
2904 | // TRACE (toolbar, "sizing toolbar!\n");
|
---|
2905 |
|
---|
2906 | if (flags == SIZE_RESTORED) {
|
---|
2907 | /* width and height don't apply */
|
---|
2908 | parent = GetParent (hwnd);
|
---|
2909 | GetClientRect(parent, &parent_rect);
|
---|
2910 |
|
---|
2911 | if (dwStyle & CCS_NORESIZE) {
|
---|
2912 | uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
|
---|
2913 |
|
---|
2914 | /* FIXME */
|
---|
2915 | /* infoPtr->nWidth = parent_rect.right - parent_rect.left; */
|
---|
2916 | cy = infoPtr->nHeight;
|
---|
2917 | cx = infoPtr->nWidth;
|
---|
2918 | TOOLBAR_CalcToolbar (hwnd);
|
---|
2919 | infoPtr->nWidth = cx;
|
---|
2920 | infoPtr->nHeight = cy;
|
---|
2921 | }
|
---|
2922 | else {
|
---|
2923 | infoPtr->nWidth = parent_rect.right - parent_rect.left;
|
---|
2924 | TOOLBAR_CalcToolbar (hwnd);
|
---|
2925 | cy = infoPtr->nHeight;
|
---|
2926 | cx = infoPtr->nWidth;
|
---|
2927 | }
|
---|
2928 |
|
---|
2929 | if (dwStyle & CCS_NOPARENTALIGN) {
|
---|
2930 | uPosFlags |= SWP_NOMOVE;
|
---|
2931 | cy = infoPtr->nHeight;
|
---|
2932 | cx = infoPtr->nWidth;
|
---|
2933 | }
|
---|
2934 |
|
---|
2935 | if (!(dwStyle & CCS_NODIVIDER))
|
---|
2936 | cy += GetSystemMetrics(SM_CYEDGE);
|
---|
2937 |
|
---|
2938 | SetWindowPos (hwnd, 0, parent_rect.left, parent_rect.top,
|
---|
2939 | cx, cy, uPosFlags | SWP_NOZORDER);
|
---|
2940 | }
|
---|
2941 | return 0;
|
---|
2942 | }
|
---|
2943 |
|
---|
2944 |
|
---|
2945 | static LRESULT
|
---|
2946 | TOOLBAR_StyleChanged (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2947 | {
|
---|
2948 | TOOLBAR_AutoSize (hwnd, wParam, lParam);
|
---|
2949 |
|
---|
2950 | InvalidateRect(hwnd, NULL, FALSE);
|
---|
2951 |
|
---|
2952 | return 0;
|
---|
2953 | }
|
---|
2954 |
|
---|
2955 |
|
---|
2956 |
|
---|
2957 | LRESULT WINAPI
|
---|
2958 | ToolbarWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
---|
2959 | {
|
---|
2960 | switch (uMsg)
|
---|
2961 | {
|
---|
2962 | case TB_ADDBITMAP:
|
---|
2963 | return TOOLBAR_AddBitmap (hwnd, wParam, lParam);
|
---|
2964 |
|
---|
2965 | case TB_ADDBUTTONSA:
|
---|
2966 | return TOOLBAR_AddButtonsA (hwnd, wParam, lParam);
|
---|
2967 |
|
---|
2968 | /* case TB_ADDBUTTONSW: */
|
---|
2969 |
|
---|
2970 | case TB_ADDSTRINGA:
|
---|
2971 | return TOOLBAR_AddStringA (hwnd, wParam, lParam);
|
---|
2972 |
|
---|
2973 | case TB_ADDSTRINGW:
|
---|
2974 | return TOOLBAR_AddStringW (hwnd, wParam, lParam);
|
---|
2975 |
|
---|
2976 | case TB_AUTOSIZE:
|
---|
2977 | return TOOLBAR_AutoSize (hwnd, wParam, lParam);
|
---|
2978 |
|
---|
2979 | case TB_BUTTONCOUNT:
|
---|
2980 | return TOOLBAR_ButtonCount (hwnd, wParam, lParam);
|
---|
2981 |
|
---|
2982 | case TB_BUTTONSTRUCTSIZE:
|
---|
2983 | return TOOLBAR_ButtonStructSize (hwnd, wParam, lParam);
|
---|
2984 |
|
---|
2985 | case TB_CHANGEBITMAP:
|
---|
2986 | return TOOLBAR_ChangeBitmap (hwnd, wParam, lParam);
|
---|
2987 |
|
---|
2988 | case TB_CHECKBUTTON:
|
---|
2989 | return TOOLBAR_CheckButton (hwnd, wParam, lParam);
|
---|
2990 |
|
---|
2991 | case TB_COMMANDTOINDEX:
|
---|
2992 | return TOOLBAR_CommandToIndex (hwnd, wParam, lParam);
|
---|
2993 |
|
---|
2994 | case TB_CUSTOMIZE:
|
---|
2995 | return TOOLBAR_Customize (hwnd);
|
---|
2996 |
|
---|
2997 | case TB_DELETEBUTTON:
|
---|
2998 | return TOOLBAR_DeleteButton (hwnd, wParam, lParam);
|
---|
2999 |
|
---|
3000 | case TB_ENABLEBUTTON:
|
---|
3001 | return TOOLBAR_EnableButton (hwnd, wParam, lParam);
|
---|
3002 |
|
---|
3003 | /* case TB_GETANCHORHIGHLIGHT: */ /* 4.71 */
|
---|
3004 |
|
---|
3005 | case TB_GETBITMAP:
|
---|
3006 | return TOOLBAR_GetBitmap (hwnd, wParam, lParam);
|
---|
3007 |
|
---|
3008 | case TB_GETBITMAPFLAGS:
|
---|
3009 | return TOOLBAR_GetBitmapFlags (hwnd, wParam, lParam);
|
---|
3010 |
|
---|
3011 | case TB_GETBUTTON:
|
---|
3012 | return TOOLBAR_GetButton (hwnd, wParam, lParam);
|
---|
3013 |
|
---|
3014 | case TB_GETBUTTONINFOA:
|
---|
3015 | return TOOLBAR_GetButtonInfoA (hwnd, wParam, lParam);
|
---|
3016 |
|
---|
3017 | /* case TB_GETBUTTONINFOW: */ /* 4.71 */
|
---|
3018 |
|
---|
3019 | case TB_GETBUTTONSIZE:
|
---|
3020 | return TOOLBAR_GetButtonSize (hwnd);
|
---|
3021 |
|
---|
3022 | case TB_GETBUTTONTEXTA:
|
---|
3023 | return TOOLBAR_GetButtonTextA (hwnd, wParam, lParam);
|
---|
3024 |
|
---|
3025 | /* case TB_GETBUTTONTEXTW: */
|
---|
3026 | /* case TB_GETCOLORSCHEME: */ /* 4.71 */
|
---|
3027 |
|
---|
3028 | case TB_GETDISABLEDIMAGELIST:
|
---|
3029 | return TOOLBAR_GetDisabledImageList (hwnd, wParam, lParam);
|
---|
3030 |
|
---|
3031 | case TB_GETEXTENDEDSTYLE:
|
---|
3032 | return TOOLBAR_GetExtendedStyle (hwnd);
|
---|
3033 |
|
---|
3034 | case TB_GETHOTIMAGELIST:
|
---|
3035 | return TOOLBAR_GetHotImageList (hwnd, wParam, lParam);
|
---|
3036 |
|
---|
3037 | /* case TB_GETHOTITEM: */ /* 4.71 */
|
---|
3038 |
|
---|
3039 | case TB_GETIMAGELIST:
|
---|
3040 | return TOOLBAR_GetImageList (hwnd, wParam, lParam);
|
---|
3041 |
|
---|
3042 | /* case TB_GETINSERTMARK: */ /* 4.71 */
|
---|
3043 | /* case TB_GETINSERTMARKCOLOR: */ /* 4.71 */
|
---|
3044 |
|
---|
3045 | case TB_GETITEMRECT:
|
---|
3046 | return TOOLBAR_GetItemRect (hwnd, wParam, lParam);
|
---|
3047 |
|
---|
3048 | case TB_GETMAXSIZE:
|
---|
3049 | return TOOLBAR_GetMaxSize (hwnd, wParam, lParam);
|
---|
3050 |
|
---|
3051 | /* case TB_GETOBJECT: */ /* 4.71 */
|
---|
3052 | /* case TB_GETPADDING: */ /* 4.71 */
|
---|
3053 |
|
---|
3054 | case TB_GETRECT:
|
---|
3055 | return TOOLBAR_GetRect (hwnd, wParam, lParam);
|
---|
3056 |
|
---|
3057 | case TB_GETROWS:
|
---|
3058 | return TOOLBAR_GetRows (hwnd, wParam, lParam);
|
---|
3059 |
|
---|
3060 | case TB_GETSTATE:
|
---|
3061 | return TOOLBAR_GetState (hwnd, wParam, lParam);
|
---|
3062 |
|
---|
3063 | case TB_GETSTYLE:
|
---|
3064 | return TOOLBAR_GetStyle (hwnd, wParam, lParam);
|
---|
3065 |
|
---|
3066 | case TB_GETTEXTROWS:
|
---|
3067 | return TOOLBAR_GetTextRows (hwnd, wParam, lParam);
|
---|
3068 |
|
---|
3069 | case TB_GETTOOLTIPS:
|
---|
3070 | return TOOLBAR_GetToolTips (hwnd, wParam, lParam);
|
---|
3071 |
|
---|
3072 | case TB_GETUNICODEFORMAT:
|
---|
3073 | return TOOLBAR_GetUnicodeFormat (hwnd, wParam, lParam);
|
---|
3074 |
|
---|
3075 | case TB_HIDEBUTTON:
|
---|
3076 | return TOOLBAR_HideButton (hwnd, wParam, lParam);
|
---|
3077 |
|
---|
3078 | case TB_HITTEST:
|
---|
3079 | return TOOLBAR_HitTest (hwnd, wParam, lParam);
|
---|
3080 |
|
---|
3081 | case TB_INDETERMINATE:
|
---|
3082 | return TOOLBAR_Indeterminate (hwnd, wParam, lParam);
|
---|
3083 |
|
---|
3084 | case TB_INSERTBUTTONA:
|
---|
3085 | return TOOLBAR_InsertButtonA (hwnd, wParam, lParam);
|
---|
3086 |
|
---|
3087 | /* case TB_INSERTBUTTONW: */
|
---|
3088 | /* case TB_INSERTMARKHITTEST: */ /* 4.71 */
|
---|
3089 |
|
---|
3090 | case TB_ISBUTTONCHECKED:
|
---|
3091 | return TOOLBAR_IsButtonChecked (hwnd, wParam, lParam);
|
---|
3092 |
|
---|
3093 | case TB_ISBUTTONENABLED:
|
---|
3094 | return TOOLBAR_IsButtonEnabled (hwnd, wParam, lParam);
|
---|
3095 |
|
---|
3096 | case TB_ISBUTTONHIDDEN:
|
---|
3097 | return TOOLBAR_IsButtonHidden (hwnd, wParam, lParam);
|
---|
3098 |
|
---|
3099 | case TB_ISBUTTONHIGHLIGHTED:
|
---|
3100 | return TOOLBAR_IsButtonHighlighted (hwnd, wParam, lParam);
|
---|
3101 |
|
---|
3102 | case TB_ISBUTTONINDETERMINATE:
|
---|
3103 | return TOOLBAR_IsButtonIndeterminate (hwnd, wParam, lParam);
|
---|
3104 |
|
---|
3105 | case TB_ISBUTTONPRESSED:
|
---|
3106 | return TOOLBAR_IsButtonPressed (hwnd, wParam, lParam);
|
---|
3107 |
|
---|
3108 | /* case TB_LOADIMAGES: */ /* 4.70 */
|
---|
3109 | /* case TB_MAPACCELERATORA: */ /* 4.71 */
|
---|
3110 | /* case TB_MAPACCELERATORW: */ /* 4.71 */
|
---|
3111 | /* case TB_MARKBUTTON: */ /* 4.71 */
|
---|
3112 | /* case TB_MOVEBUTTON: */ /* 4.71 */
|
---|
3113 |
|
---|
3114 | case TB_PRESSBUTTON:
|
---|
3115 | return TOOLBAR_PressButton (hwnd, wParam, lParam);
|
---|
3116 |
|
---|
3117 | /* case TB_REPLACEBITMAP: */
|
---|
3118 |
|
---|
3119 | case TB_SAVERESTOREA:
|
---|
3120 | return TOOLBAR_SaveRestoreA (hwnd, wParam, lParam);
|
---|
3121 |
|
---|
3122 | /* case TB_SAVERESTOREW: */
|
---|
3123 | /* case TB_SETANCHORHIGHLIGHT: */ /* 4.71 */
|
---|
3124 |
|
---|
3125 | case TB_SETBITMAPSIZE:
|
---|
3126 | return TOOLBAR_SetBitmapSize (hwnd, wParam, lParam);
|
---|
3127 |
|
---|
3128 | case TB_SETBUTTONINFOA:
|
---|
3129 | return TOOLBAR_SetButtonInfoA (hwnd, wParam, lParam);
|
---|
3130 |
|
---|
3131 | /* case TB_SETBUTTONINFOW: */ /* 4.71 */
|
---|
3132 |
|
---|
3133 | case TB_SETBUTTONSIZE:
|
---|
3134 | return TOOLBAR_SetButtonSize (hwnd, wParam, lParam);
|
---|
3135 |
|
---|
3136 | case TB_SETBUTTONWIDTH:
|
---|
3137 | return TOOLBAR_SetButtonWidth (hwnd, wParam, lParam);
|
---|
3138 |
|
---|
3139 | case TB_SETCMDID:
|
---|
3140 | return TOOLBAR_SetCmdId (hwnd, wParam, lParam);
|
---|
3141 |
|
---|
3142 | /* case TB_SETCOLORSCHEME: */ /* 4.71 */
|
---|
3143 |
|
---|
3144 | case TB_SETDISABLEDIMAGELIST:
|
---|
3145 | return TOOLBAR_SetDisabledImageList (hwnd, wParam, lParam);
|
---|
3146 |
|
---|
3147 | case TB_SETDRAWTEXTFLAGS:
|
---|
3148 | return TOOLBAR_SetDrawTextFlags (hwnd, wParam, lParam);
|
---|
3149 |
|
---|
3150 | case TB_SETEXTENDEDSTYLE:
|
---|
3151 | return TOOLBAR_SetExtendedStyle (hwnd, wParam, lParam);
|
---|
3152 |
|
---|
3153 | case TB_SETHOTIMAGELIST:
|
---|
3154 | return TOOLBAR_SetHotImageList (hwnd, wParam, lParam);
|
---|
3155 |
|
---|
3156 | /* case TB_SETHOTITEM: */ /* 4.71 */
|
---|
3157 |
|
---|
3158 | case TB_SETIMAGELIST:
|
---|
3159 | return TOOLBAR_SetImageList (hwnd, wParam, lParam);
|
---|
3160 |
|
---|
3161 | case TB_SETINDENT:
|
---|
3162 | return TOOLBAR_SetIndent (hwnd, wParam, lParam);
|
---|
3163 |
|
---|
3164 | /* case TB_SETINSERTMARK: */ /* 4.71 */
|
---|
3165 |
|
---|
3166 | case TB_SETINSERTMARKCOLOR:
|
---|
3167 | return TOOLBAR_SetInsertMarkColor (hwnd, wParam, lParam);
|
---|
3168 |
|
---|
3169 | case TB_SETMAXTEXTROWS:
|
---|
3170 | return TOOLBAR_SetMaxTextRows (hwnd, wParam, lParam);
|
---|
3171 |
|
---|
3172 | /* case TB_SETPADDING: */ /* 4.71 */
|
---|
3173 |
|
---|
3174 | case TB_SETPARENT:
|
---|
3175 | return TOOLBAR_SetParent (hwnd, wParam, lParam);
|
---|
3176 |
|
---|
3177 | case TB_SETROWS:
|
---|
3178 | return TOOLBAR_SetRows (hwnd, wParam, lParam);
|
---|
3179 |
|
---|
3180 | case TB_SETSTATE:
|
---|
3181 | return TOOLBAR_SetState (hwnd, wParam, lParam);
|
---|
3182 |
|
---|
3183 | case TB_SETSTYLE:
|
---|
3184 | return TOOLBAR_SetStyle (hwnd, wParam, lParam);
|
---|
3185 |
|
---|
3186 | case TB_SETTOOLTIPS:
|
---|
3187 | return TOOLBAR_SetToolTips (hwnd, wParam, lParam);
|
---|
3188 |
|
---|
3189 | case TB_SETUNICODEFORMAT:
|
---|
3190 | return TOOLBAR_SetUnicodeFormat (hwnd, wParam, lParam);
|
---|
3191 |
|
---|
3192 |
|
---|
3193 | /* case WM_CHAR: */
|
---|
3194 |
|
---|
3195 | case WM_CREATE:
|
---|
3196 | return TOOLBAR_Create (hwnd, wParam, lParam);
|
---|
3197 |
|
---|
3198 | case WM_DESTROY:
|
---|
3199 | return TOOLBAR_Destroy (hwnd, wParam, lParam);
|
---|
3200 |
|
---|
3201 | case WM_ERASEBKGND:
|
---|
3202 | return TOOLBAR_EraseBackground (hwnd, wParam, lParam);
|
---|
3203 |
|
---|
3204 | /* case WM_GETFONT: */
|
---|
3205 | /* case WM_KEYDOWN: */
|
---|
3206 | /* case WM_KILLFOCUS: */
|
---|
3207 |
|
---|
3208 | case WM_LBUTTONDBLCLK:
|
---|
3209 | return TOOLBAR_LButtonDblClk (hwnd, wParam, lParam);
|
---|
3210 |
|
---|
3211 | case WM_LBUTTONDOWN:
|
---|
3212 | return TOOLBAR_LButtonDown (hwnd, wParam, lParam);
|
---|
3213 |
|
---|
3214 | case WM_LBUTTONUP:
|
---|
3215 | return TOOLBAR_LButtonUp (hwnd, wParam, lParam);
|
---|
3216 |
|
---|
3217 | case WM_MOUSEMOVE:
|
---|
3218 | return TOOLBAR_MouseMove (hwnd, wParam, lParam);
|
---|
3219 |
|
---|
3220 | case WM_NCACTIVATE:
|
---|
3221 | return TOOLBAR_NCActivate (hwnd, wParam, lParam);
|
---|
3222 |
|
---|
3223 | case WM_NCCALCSIZE:
|
---|
3224 | return TOOLBAR_NCCalcSize (hwnd, wParam, lParam);
|
---|
3225 |
|
---|
3226 | case WM_NCCREATE:
|
---|
3227 | return TOOLBAR_NCCreate (hwnd, wParam, lParam);
|
---|
3228 |
|
---|
3229 | case WM_NCPAINT:
|
---|
3230 | return TOOLBAR_NCPaint (hwnd, wParam, lParam);
|
---|
3231 |
|
---|
3232 | case WM_NOTIFY:
|
---|
3233 | return TOOLBAR_Notify (hwnd, wParam, lParam);
|
---|
3234 |
|
---|
3235 | /* case WM_NOTIFYFORMAT: */
|
---|
3236 |
|
---|
3237 | case WM_PAINT:
|
---|
3238 | return TOOLBAR_Paint (hwnd, wParam);
|
---|
3239 |
|
---|
3240 | case WM_SIZE:
|
---|
3241 | return TOOLBAR_Size (hwnd, wParam, lParam);
|
---|
3242 |
|
---|
3243 | case WM_STYLECHANGED:
|
---|
3244 | return TOOLBAR_StyleChanged (hwnd, wParam, lParam);
|
---|
3245 |
|
---|
3246 | /* case WM_SYSCOLORCHANGE: */
|
---|
3247 |
|
---|
3248 | /* case WM_WININICHANGE: */
|
---|
3249 |
|
---|
3250 | case WM_CHARTOITEM:
|
---|
3251 | case WM_COMMAND:
|
---|
3252 | case WM_DRAWITEM:
|
---|
3253 | case WM_MEASUREITEM:
|
---|
3254 | case WM_VKEYTOITEM:
|
---|
3255 | return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
|
---|
3256 |
|
---|
3257 | default:
|
---|
3258 | // if (uMsg >= WM_USER)
|
---|
3259 | // ERR (toolbar, "unknown msg %04x wp=%08x lp=%08lx\n",
|
---|
3260 | // uMsg, wParam, lParam);
|
---|
3261 | return DefWindowProcA (hwnd, uMsg, wParam, lParam);
|
---|
3262 | }
|
---|
3263 | return 0;
|
---|
3264 | }
|
---|
3265 |
|
---|
3266 |
|
---|
3267 | VOID
|
---|
3268 | TOOLBAR_Register (VOID)
|
---|
3269 | {
|
---|
3270 | WNDCLASSA wndClass;
|
---|
3271 |
|
---|
3272 | if (GlobalFindAtomA (TOOLBARCLASSNAMEA)) return;
|
---|
3273 |
|
---|
3274 | ZeroMemory (&wndClass, sizeof(WNDCLASSA));
|
---|
3275 | wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
|
---|
3276 | wndClass.lpfnWndProc = (WNDPROC)ToolbarWindowProc;
|
---|
3277 | wndClass.cbClsExtra = 0;
|
---|
3278 | wndClass.cbWndExtra = sizeof(TOOLBAR_INFO *);
|
---|
3279 | wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
|
---|
3280 | wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
|
---|
3281 | wndClass.lpszClassName = TOOLBARCLASSNAMEA;
|
---|
3282 |
|
---|
3283 | RegisterClassA (&wndClass);
|
---|
3284 | }
|
---|
3285 |
|
---|
3286 |
|
---|
3287 | VOID
|
---|
3288 | TOOLBAR_Unregister (VOID)
|
---|
3289 | {
|
---|
3290 | if (GlobalFindAtomA (TOOLBARCLASSNAMEA))
|
---|
3291 | UnregisterClassA (TOOLBARCLASSNAMEA, (HINSTANCE)NULL);
|
---|
3292 | }
|
---|
3293 |
|
---|