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