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 | infoPtr->nNumStrings++;
|
---|
1045 | }
|
---|
1046 | else {
|
---|
1047 | LPSTR p = (LPSTR)lParam;
|
---|
1048 | INT len;
|
---|
1049 |
|
---|
1050 | if (p == NULL)
|
---|
1051 | return -1;
|
---|
1052 | // TRACE (toolbar, "adding string(s) from array!\n");
|
---|
1053 | nIndex = infoPtr->nNumStrings;
|
---|
1054 | while (*p) {
|
---|
1055 | len = lstrlenA (p);
|
---|
1056 | // TRACE (toolbar, "len=%d \"%s\"\n", len, p);
|
---|
1057 |
|
---|
1058 | if (infoPtr->nNumStrings == 0) {
|
---|
1059 | infoPtr->strings =
|
---|
1060 | COMCTL32_Alloc (sizeof(LPWSTR));
|
---|
1061 | }
|
---|
1062 | else {
|
---|
1063 | LPWSTR *oldStrings = infoPtr->strings;
|
---|
1064 | infoPtr->strings =
|
---|
1065 | COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
|
---|
1066 | memcpy (&infoPtr->strings[0], &oldStrings[0],
|
---|
1067 | sizeof(LPWSTR) * infoPtr->nNumStrings);
|
---|
1068 | COMCTL32_Free (oldStrings);
|
---|
1069 | }
|
---|
1070 |
|
---|
1071 | infoPtr->strings[infoPtr->nNumStrings] =
|
---|
1072 | COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
|
---|
1073 | lstrcpyAtoW (infoPtr->strings[infoPtr->nNumStrings], p);
|
---|
1074 | infoPtr->nNumStrings++;
|
---|
1075 |
|
---|
1076 | p += (len+1);
|
---|
1077 | }
|
---|
1078 | }
|
---|
1079 |
|
---|
1080 | return nIndex;
|
---|
1081 | }
|
---|
1082 |
|
---|
1083 |
|
---|
1084 | static LRESULT
|
---|
1085 | TOOLBAR_AddStringW (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1086 | {
|
---|
1087 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1088 | INT nIndex;
|
---|
1089 |
|
---|
1090 | if ((wParam) && (HIWORD(lParam) == 0)) {
|
---|
1091 | WCHAR szString[256];
|
---|
1092 | INT len;
|
---|
1093 | // TRACE (toolbar, "adding string from resource!\n");
|
---|
1094 |
|
---|
1095 | len = LoadStringW ((HINSTANCE)wParam, (UINT)lParam,
|
---|
1096 | szString, 256);
|
---|
1097 |
|
---|
1098 | // TRACE (toolbar, "len=%d \"%s\"\n", len, debugstr_w(szString));
|
---|
1099 | nIndex = infoPtr->nNumStrings;
|
---|
1100 | if (infoPtr->nNumStrings == 0) {
|
---|
1101 | infoPtr->strings =
|
---|
1102 | COMCTL32_Alloc (sizeof(LPWSTR));
|
---|
1103 | }
|
---|
1104 | else {
|
---|
1105 | LPWSTR *oldStrings = infoPtr->strings;
|
---|
1106 | infoPtr->strings =
|
---|
1107 | COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
|
---|
1108 | memcpy (&infoPtr->strings[0], &oldStrings[0],
|
---|
1109 | sizeof(LPWSTR) * infoPtr->nNumStrings);
|
---|
1110 | COMCTL32_Free (oldStrings);
|
---|
1111 | }
|
---|
1112 |
|
---|
1113 | infoPtr->strings[infoPtr->nNumStrings] =
|
---|
1114 | COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
|
---|
1115 | lstrcpyW (infoPtr->strings[infoPtr->nNumStrings], szString);
|
---|
1116 | infoPtr->nNumStrings++;
|
---|
1117 | }
|
---|
1118 | else {
|
---|
1119 | LPWSTR p = (LPWSTR)lParam;
|
---|
1120 | INT len;
|
---|
1121 |
|
---|
1122 | if (p == NULL)
|
---|
1123 | return -1;
|
---|
1124 | // TRACE (toolbar, "adding string(s) from array!\n");
|
---|
1125 | nIndex = infoPtr->nNumStrings;
|
---|
1126 | while (*p) {
|
---|
1127 | len = lstrlenW (p);
|
---|
1128 | // TRACE (toolbar, "len=%d \"%s\"\n", len, debugstr_w(p));
|
---|
1129 |
|
---|
1130 | if (infoPtr->nNumStrings == 0) {
|
---|
1131 | infoPtr->strings =
|
---|
1132 | COMCTL32_Alloc (sizeof(LPWSTR));
|
---|
1133 | }
|
---|
1134 | else {
|
---|
1135 | LPWSTR *oldStrings = infoPtr->strings;
|
---|
1136 | infoPtr->strings =
|
---|
1137 | COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
|
---|
1138 | memcpy (&infoPtr->strings[0], &oldStrings[0],
|
---|
1139 | sizeof(LPWSTR) * infoPtr->nNumStrings);
|
---|
1140 | COMCTL32_Free (oldStrings);
|
---|
1141 | }
|
---|
1142 |
|
---|
1143 | infoPtr->strings[infoPtr->nNumStrings] =
|
---|
1144 | COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
|
---|
1145 | lstrcpyW (infoPtr->strings[infoPtr->nNumStrings], p);
|
---|
1146 | infoPtr->nNumStrings++;
|
---|
1147 |
|
---|
1148 | p += (len+1);
|
---|
1149 | }
|
---|
1150 | }
|
---|
1151 |
|
---|
1152 | return nIndex;
|
---|
1153 | }
|
---|
1154 |
|
---|
1155 |
|
---|
1156 | static LRESULT
|
---|
1157 | TOOLBAR_AutoSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1158 | {
|
---|
1159 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1160 | DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
|
---|
1161 | RECT parent_rect;
|
---|
1162 | HWND parent;
|
---|
1163 | /* INT32 x, y; */
|
---|
1164 | INT cx, cy;
|
---|
1165 | UINT uPosFlags = 0;
|
---|
1166 |
|
---|
1167 | // TRACE (toolbar, "resize forced!\n");
|
---|
1168 |
|
---|
1169 | parent = GetParent (hwnd);
|
---|
1170 | GetClientRect(parent, &parent_rect);
|
---|
1171 |
|
---|
1172 | if (dwStyle & CCS_NORESIZE) {
|
---|
1173 | uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
|
---|
1174 | cx = 0;
|
---|
1175 | cy = 0;
|
---|
1176 | }
|
---|
1177 | else {
|
---|
1178 | infoPtr->nWidth = parent_rect.right - parent_rect.left;
|
---|
1179 | TOOLBAR_CalcToolbar (hwnd);
|
---|
1180 | InvalidateRect( hwnd, NULL, TRUE );
|
---|
1181 | cy = infoPtr->nHeight;
|
---|
1182 | cx = infoPtr->nWidth;
|
---|
1183 | }
|
---|
1184 |
|
---|
1185 | if (dwStyle & CCS_NOPARENTALIGN)
|
---|
1186 | uPosFlags |= SWP_NOMOVE;
|
---|
1187 |
|
---|
1188 | if (!(dwStyle & CCS_NODIVIDER))
|
---|
1189 | cy += GetSystemMetrics(SM_CYEDGE);
|
---|
1190 |
|
---|
1191 | infoPtr->bAutoSize = TRUE;
|
---|
1192 | SetWindowPos (hwnd, HWND_TOP, parent_rect.left, parent_rect.top,
|
---|
1193 | cx, cy, uPosFlags);
|
---|
1194 |
|
---|
1195 | return 0;
|
---|
1196 | }
|
---|
1197 |
|
---|
1198 |
|
---|
1199 | static LRESULT
|
---|
1200 | TOOLBAR_ButtonCount (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1201 | {
|
---|
1202 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1203 |
|
---|
1204 | return infoPtr->nNumButtons;
|
---|
1205 | }
|
---|
1206 |
|
---|
1207 |
|
---|
1208 | static LRESULT
|
---|
1209 | TOOLBAR_ButtonStructSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1210 | {
|
---|
1211 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1212 |
|
---|
1213 | if (infoPtr == NULL) {
|
---|
1214 | // ERR (toolbar, "(0x%x, 0x%x, 0x%lx)\n", hwnd, wParam, lParam);
|
---|
1215 | // ERR (toolbar, "infoPtr == NULL!\n");
|
---|
1216 | return 0;
|
---|
1217 | }
|
---|
1218 |
|
---|
1219 | infoPtr->dwStructSize = (DWORD)wParam;
|
---|
1220 |
|
---|
1221 | return 0;
|
---|
1222 | }
|
---|
1223 |
|
---|
1224 |
|
---|
1225 | static LRESULT
|
---|
1226 | TOOLBAR_ChangeBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1227 | {
|
---|
1228 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1229 | TBUTTON_INFO *btnPtr;
|
---|
1230 | HDC hdc;
|
---|
1231 | INT nIndex;
|
---|
1232 |
|
---|
1233 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
1234 | if (nIndex == -1)
|
---|
1235 | return FALSE;
|
---|
1236 |
|
---|
1237 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
1238 | btnPtr->iBitmap = LOWORD(lParam);
|
---|
1239 |
|
---|
1240 | hdc = GetDC (hwnd);
|
---|
1241 | TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
|
---|
1242 | ReleaseDC (hwnd, hdc);
|
---|
1243 |
|
---|
1244 | return TRUE;
|
---|
1245 | }
|
---|
1246 |
|
---|
1247 |
|
---|
1248 | static LRESULT
|
---|
1249 | TOOLBAR_CheckButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1250 | {
|
---|
1251 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1252 | TBUTTON_INFO *btnPtr;
|
---|
1253 | HDC hdc;
|
---|
1254 | INT nIndex;
|
---|
1255 | INT nOldIndex = -1;
|
---|
1256 |
|
---|
1257 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
1258 | if (nIndex == -1)
|
---|
1259 | return FALSE;
|
---|
1260 |
|
---|
1261 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
1262 |
|
---|
1263 | if (!(btnPtr->fsStyle & TBSTYLE_CHECK))
|
---|
1264 | return FALSE;
|
---|
1265 |
|
---|
1266 | if (LOWORD(lParam) == FALSE)
|
---|
1267 | btnPtr->fsState &= ~TBSTATE_CHECKED;
|
---|
1268 | else {
|
---|
1269 | if (btnPtr->fsStyle & TBSTYLE_GROUP) {
|
---|
1270 | nOldIndex =
|
---|
1271 | TOOLBAR_GetCheckedGroupButtonIndex (infoPtr, nIndex);
|
---|
1272 | if (nOldIndex == nIndex)
|
---|
1273 | return 0;
|
---|
1274 | if (nOldIndex != -1)
|
---|
1275 | infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
|
---|
1276 | }
|
---|
1277 | btnPtr->fsState |= TBSTATE_CHECKED;
|
---|
1278 | }
|
---|
1279 |
|
---|
1280 | hdc = GetDC (hwnd);
|
---|
1281 | if (nOldIndex != -1)
|
---|
1282 | TOOLBAR_DrawButton (hwnd, &infoPtr->buttons[nOldIndex], hdc);
|
---|
1283 | TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
|
---|
1284 | ReleaseDC (hwnd, hdc);
|
---|
1285 |
|
---|
1286 | /* FIXME: Send a WM_NOTIFY?? */
|
---|
1287 |
|
---|
1288 | return TRUE;
|
---|
1289 | }
|
---|
1290 |
|
---|
1291 |
|
---|
1292 | static LRESULT
|
---|
1293 | TOOLBAR_CommandToIndex (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1294 | {
|
---|
1295 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1296 |
|
---|
1297 | return TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
1298 | }
|
---|
1299 |
|
---|
1300 |
|
---|
1301 | static LRESULT
|
---|
1302 | TOOLBAR_Customize (HWND hwnd)
|
---|
1303 | {
|
---|
1304 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1305 | LRESULT ret;
|
---|
1306 | LPCVOID template;
|
---|
1307 | HRSRC hRes;
|
---|
1308 | NMHDR nmhdr;
|
---|
1309 |
|
---|
1310 | /* send TBN_BEGINADJUST notification */
|
---|
1311 | nmhdr.hwndFrom = hwnd;
|
---|
1312 | nmhdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
|
---|
1313 | nmhdr.code = TBN_BEGINADJUST;
|
---|
1314 |
|
---|
1315 | SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
|
---|
1316 | (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
|
---|
1317 |
|
---|
1318 | if (!(hRes = FindResourceA (COMCTL32_hModule,
|
---|
1319 | MAKEINTRESOURCEA(IDD_TBCUSTOMIZE),
|
---|
1320 | RT_DIALOGA)))
|
---|
1321 | return FALSE;
|
---|
1322 |
|
---|
1323 | if(!(template = (LPVOID)LoadResource (COMCTL32_hModule, hRes)))
|
---|
1324 | return FALSE;
|
---|
1325 |
|
---|
1326 | ret = DialogBoxIndirectParamA (GetWindowLongA (hwnd, GWL_HINSTANCE),
|
---|
1327 | (LPDLGTEMPLATEA)template,
|
---|
1328 | hwnd,
|
---|
1329 | (DLGPROC)TOOLBAR_CustomizeDialogProc,
|
---|
1330 | (LPARAM)infoPtr);
|
---|
1331 |
|
---|
1332 | /* send TBN_ENDADJUST notification */
|
---|
1333 | nmhdr.code = TBN_ENDADJUST;
|
---|
1334 |
|
---|
1335 | SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
|
---|
1336 | (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
|
---|
1337 |
|
---|
1338 | return ret;
|
---|
1339 | }
|
---|
1340 |
|
---|
1341 |
|
---|
1342 | static LRESULT
|
---|
1343 | TOOLBAR_DeleteButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1344 | {
|
---|
1345 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1346 | INT nIndex = (INT)wParam;
|
---|
1347 |
|
---|
1348 | if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
|
---|
1349 | return FALSE;
|
---|
1350 |
|
---|
1351 | if ((infoPtr->hwndToolTip) &&
|
---|
1352 | !(infoPtr->buttons[nIndex].fsStyle & TBSTYLE_SEP)) {
|
---|
1353 | TTTOOLINFOA ti;
|
---|
1354 |
|
---|
1355 | ZeroMemory (&ti, sizeof(TTTOOLINFOA));
|
---|
1356 | ti.cbSize = sizeof (TTTOOLINFOA);
|
---|
1357 | ti.hwnd = hwnd;
|
---|
1358 | ti.uId = infoPtr->buttons[nIndex].idCommand;
|
---|
1359 |
|
---|
1360 | SendMessageA (infoPtr->hwndToolTip, TTM_DELTOOLA, 0, (LPARAM)&ti);
|
---|
1361 | }
|
---|
1362 |
|
---|
1363 | if (infoPtr->nNumButtons == 1) {
|
---|
1364 | // TRACE (toolbar, " simple delete!\n");
|
---|
1365 | COMCTL32_Free (infoPtr->buttons);
|
---|
1366 | infoPtr->buttons = NULL;
|
---|
1367 | infoPtr->nNumButtons = 0;
|
---|
1368 | }
|
---|
1369 | else {
|
---|
1370 | TBUTTON_INFO *oldButtons = infoPtr->buttons;
|
---|
1371 | // TRACE(toolbar, "complex delete! [nIndex=%d]\n", nIndex);
|
---|
1372 |
|
---|
1373 | infoPtr->nNumButtons--;
|
---|
1374 | infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
|
---|
1375 | if (nIndex > 0) {
|
---|
1376 | memcpy (&infoPtr->buttons[0], &oldButtons[0],
|
---|
1377 | nIndex * sizeof(TBUTTON_INFO));
|
---|
1378 | }
|
---|
1379 |
|
---|
1380 | if (nIndex < infoPtr->nNumButtons) {
|
---|
1381 | memcpy (&infoPtr->buttons[nIndex], &oldButtons[nIndex+1],
|
---|
1382 | (infoPtr->nNumButtons - nIndex) * sizeof(TBUTTON_INFO));
|
---|
1383 | }
|
---|
1384 |
|
---|
1385 | COMCTL32_Free (oldButtons);
|
---|
1386 | }
|
---|
1387 |
|
---|
1388 | TOOLBAR_CalcToolbar (hwnd);
|
---|
1389 |
|
---|
1390 | InvalidateRect (hwnd, NULL, TRUE);
|
---|
1391 |
|
---|
1392 | return TRUE;
|
---|
1393 | }
|
---|
1394 |
|
---|
1395 |
|
---|
1396 | static LRESULT
|
---|
1397 | TOOLBAR_EnableButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1398 | {
|
---|
1399 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1400 | TBUTTON_INFO *btnPtr;
|
---|
1401 | HDC hdc;
|
---|
1402 | INT nIndex;
|
---|
1403 |
|
---|
1404 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
1405 | if (nIndex == -1)
|
---|
1406 | return FALSE;
|
---|
1407 |
|
---|
1408 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
1409 | if (LOWORD(lParam) == FALSE)
|
---|
1410 | btnPtr->fsState &= ~(TBSTATE_ENABLED | TBSTATE_PRESSED);
|
---|
1411 | else
|
---|
1412 | btnPtr->fsState |= TBSTATE_ENABLED;
|
---|
1413 |
|
---|
1414 | hdc = GetDC (hwnd);
|
---|
1415 | TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
|
---|
1416 | ReleaseDC (hwnd, hdc);
|
---|
1417 |
|
---|
1418 | return TRUE;
|
---|
1419 | }
|
---|
1420 |
|
---|
1421 |
|
---|
1422 | /* << TOOLBAR_GetAnchorHighlight >> */
|
---|
1423 |
|
---|
1424 |
|
---|
1425 | static LRESULT
|
---|
1426 | TOOLBAR_GetBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1427 | {
|
---|
1428 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1429 | INT nIndex;
|
---|
1430 |
|
---|
1431 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
1432 | if (nIndex == -1)
|
---|
1433 | return -1;
|
---|
1434 |
|
---|
1435 | return infoPtr->buttons[nIndex].iBitmap;
|
---|
1436 | }
|
---|
1437 |
|
---|
1438 |
|
---|
1439 | static LRESULT
|
---|
1440 | TOOLBAR_GetBitmapFlags (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1441 | {
|
---|
1442 | return (GetDeviceCaps (0, LOGPIXELSX) >= 120) ? TBBF_LARGE : 0;
|
---|
1443 | }
|
---|
1444 |
|
---|
1445 |
|
---|
1446 | static LRESULT
|
---|
1447 | TOOLBAR_GetButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1448 | {
|
---|
1449 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1450 | LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
|
---|
1451 | INT nIndex = (INT)wParam;
|
---|
1452 | TBUTTON_INFO *btnPtr;
|
---|
1453 |
|
---|
1454 | if (infoPtr == NULL)
|
---|
1455 | return FALSE;
|
---|
1456 |
|
---|
1457 | if (lpTbb == NULL)
|
---|
1458 | return FALSE;
|
---|
1459 |
|
---|
1460 | if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
|
---|
1461 | return FALSE;
|
---|
1462 |
|
---|
1463 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
1464 | lpTbb->iBitmap = btnPtr->iBitmap;
|
---|
1465 | lpTbb->idCommand = btnPtr->idCommand;
|
---|
1466 | lpTbb->fsState = btnPtr->fsState;
|
---|
1467 | lpTbb->fsStyle = btnPtr->fsStyle;
|
---|
1468 | lpTbb->dwData = btnPtr->dwData;
|
---|
1469 | lpTbb->iString = btnPtr->iString;
|
---|
1470 |
|
---|
1471 | return TRUE;
|
---|
1472 | }
|
---|
1473 |
|
---|
1474 |
|
---|
1475 | static LRESULT
|
---|
1476 | TOOLBAR_GetButtonInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1477 | {
|
---|
1478 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1479 | LPTBBUTTONINFOA lpTbInfo = (LPTBBUTTONINFOA)lParam;
|
---|
1480 | TBUTTON_INFO *btnPtr;
|
---|
1481 | INT nIndex;
|
---|
1482 |
|
---|
1483 | if (infoPtr == NULL)
|
---|
1484 | return -1;
|
---|
1485 | if (lpTbInfo == NULL)
|
---|
1486 | return -1;
|
---|
1487 | if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOA))
|
---|
1488 | return -1;
|
---|
1489 |
|
---|
1490 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
1491 | if (nIndex == -1)
|
---|
1492 | return -1;
|
---|
1493 |
|
---|
1494 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
1495 |
|
---|
1496 | if (lpTbInfo->dwMask & TBIF_COMMAND)
|
---|
1497 | lpTbInfo->idCommand = btnPtr->idCommand;
|
---|
1498 | if (lpTbInfo->dwMask & TBIF_IMAGE)
|
---|
1499 | lpTbInfo->iImage = btnPtr->iBitmap;
|
---|
1500 | if (lpTbInfo->dwMask & TBIF_LPARAM)
|
---|
1501 | lpTbInfo->lParam = btnPtr->dwData;
|
---|
1502 | if (lpTbInfo->dwMask & TBIF_SIZE)
|
---|
1503 | lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left);
|
---|
1504 | if (lpTbInfo->dwMask & TBIF_STATE)
|
---|
1505 | lpTbInfo->fsState = btnPtr->fsState;
|
---|
1506 | if (lpTbInfo->dwMask & TBIF_STYLE)
|
---|
1507 | lpTbInfo->fsStyle = btnPtr->fsStyle;
|
---|
1508 | if (lpTbInfo->dwMask & TBIF_TEXT) {
|
---|
1509 | if ((btnPtr->iString >= 0) || (btnPtr->iString < infoPtr->nNumStrings))
|
---|
1510 | lstrcpynA (lpTbInfo->pszText,
|
---|
1511 | (LPSTR)infoPtr->strings[btnPtr->iString],
|
---|
1512 | lpTbInfo->cchText);
|
---|
1513 | }
|
---|
1514 |
|
---|
1515 | return nIndex;
|
---|
1516 | }
|
---|
1517 |
|
---|
1518 |
|
---|
1519 | /* << TOOLBAR_GetButtonInfo32W >> */
|
---|
1520 |
|
---|
1521 |
|
---|
1522 | static LRESULT
|
---|
1523 | TOOLBAR_GetButtonSize (HWND hwnd)
|
---|
1524 | {
|
---|
1525 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1526 |
|
---|
1527 | return MAKELONG((WORD)infoPtr->nButtonWidth,
|
---|
1528 | (WORD)infoPtr->nButtonHeight);
|
---|
1529 | }
|
---|
1530 |
|
---|
1531 |
|
---|
1532 | static LRESULT
|
---|
1533 | TOOLBAR_GetButtonTextA (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1534 | {
|
---|
1535 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1536 | INT nIndex, nStringIndex;
|
---|
1537 |
|
---|
1538 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
1539 | if (nIndex == -1)
|
---|
1540 | return -1;
|
---|
1541 |
|
---|
1542 | nStringIndex = infoPtr->buttons[nIndex].iString;
|
---|
1543 |
|
---|
1544 | // TRACE (toolbar, "index=%d stringIndex=%d\n", nIndex, nStringIndex);
|
---|
1545 |
|
---|
1546 | if ((nStringIndex < 0) || (nStringIndex >= infoPtr->nNumStrings))
|
---|
1547 | return -1;
|
---|
1548 |
|
---|
1549 | if (lParam == 0) return -1;
|
---|
1550 |
|
---|
1551 | lstrcpyA ((LPSTR)lParam, (LPSTR)infoPtr->strings[nStringIndex]);
|
---|
1552 |
|
---|
1553 | return lstrlenA ((LPSTR)infoPtr->strings[nStringIndex]);
|
---|
1554 | }
|
---|
1555 |
|
---|
1556 |
|
---|
1557 | /* << TOOLBAR_GetButtonText32W >> */
|
---|
1558 | /* << TOOLBAR_GetColorScheme >> */
|
---|
1559 |
|
---|
1560 |
|
---|
1561 | static LRESULT
|
---|
1562 | TOOLBAR_GetDisabledImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1563 | {
|
---|
1564 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1565 |
|
---|
1566 | if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT)
|
---|
1567 | return (LRESULT)infoPtr->himlDis;
|
---|
1568 | else
|
---|
1569 | return 0;
|
---|
1570 | }
|
---|
1571 |
|
---|
1572 |
|
---|
1573 | static LRESULT
|
---|
1574 | TOOLBAR_GetExtendedStyle (HWND hwnd)
|
---|
1575 | {
|
---|
1576 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1577 |
|
---|
1578 | return infoPtr->dwExStyle;
|
---|
1579 | }
|
---|
1580 |
|
---|
1581 |
|
---|
1582 | static LRESULT
|
---|
1583 | TOOLBAR_GetHotImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1584 | {
|
---|
1585 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1586 |
|
---|
1587 | if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT)
|
---|
1588 | return (LRESULT)infoPtr->himlHot;
|
---|
1589 | else
|
---|
1590 | return 0;
|
---|
1591 | }
|
---|
1592 |
|
---|
1593 |
|
---|
1594 | /* << TOOLBAR_GetHotItem >> */
|
---|
1595 |
|
---|
1596 |
|
---|
1597 | static LRESULT
|
---|
1598 | TOOLBAR_GetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1599 | {
|
---|
1600 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1601 |
|
---|
1602 | if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT)
|
---|
1603 | return (LRESULT)infoPtr->himlDef;
|
---|
1604 | else
|
---|
1605 | return 0;
|
---|
1606 | }
|
---|
1607 |
|
---|
1608 |
|
---|
1609 | /* << TOOLBAR_GetInsertMark >> */
|
---|
1610 | /* << TOOLBAR_GetInsertMarkColor >> */
|
---|
1611 |
|
---|
1612 |
|
---|
1613 | static LRESULT
|
---|
1614 | TOOLBAR_GetItemRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1615 | {
|
---|
1616 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1617 | TBUTTON_INFO *btnPtr;
|
---|
1618 | LPRECT lpRect;
|
---|
1619 | INT nIndex;
|
---|
1620 |
|
---|
1621 | if (infoPtr == NULL)
|
---|
1622 | return FALSE;
|
---|
1623 | nIndex = (INT)wParam;
|
---|
1624 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
1625 | if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
|
---|
1626 | return FALSE;
|
---|
1627 | lpRect = (LPRECT)lParam;
|
---|
1628 | if (lpRect == NULL)
|
---|
1629 | return FALSE;
|
---|
1630 | if (btnPtr->fsState & TBSTATE_HIDDEN)
|
---|
1631 | return FALSE;
|
---|
1632 |
|
---|
1633 | TOOLBAR_CalcToolbar( hwnd );
|
---|
1634 |
|
---|
1635 | lpRect->left = btnPtr->rect.left;
|
---|
1636 | lpRect->right = btnPtr->rect.right;
|
---|
1637 | lpRect->bottom = btnPtr->rect.bottom;
|
---|
1638 | lpRect->top = btnPtr->rect.top;
|
---|
1639 |
|
---|
1640 | return TRUE;
|
---|
1641 | }
|
---|
1642 |
|
---|
1643 |
|
---|
1644 | static LRESULT
|
---|
1645 | TOOLBAR_GetMaxSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1646 | {
|
---|
1647 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1648 | LPSIZE lpSize = (LPSIZE)lParam;
|
---|
1649 |
|
---|
1650 | if (lpSize == NULL)
|
---|
1651 | return FALSE;
|
---|
1652 |
|
---|
1653 | lpSize->cx = infoPtr->rcBound.right - infoPtr->rcBound.left;
|
---|
1654 | lpSize->cy = infoPtr->rcBound.bottom - infoPtr->rcBound.top;
|
---|
1655 |
|
---|
1656 | // TRACE (toolbar, "maximum size %d x %d\n",
|
---|
1657 | // infoPtr->rcBound.right - infoPtr->rcBound.left,
|
---|
1658 | // infoPtr->rcBound.bottom - infoPtr->rcBound.top);
|
---|
1659 |
|
---|
1660 | return TRUE;
|
---|
1661 | }
|
---|
1662 |
|
---|
1663 |
|
---|
1664 | /* << TOOLBAR_GetObject >> */
|
---|
1665 | /* << TOOLBAR_GetPadding >> */
|
---|
1666 |
|
---|
1667 |
|
---|
1668 | static LRESULT
|
---|
1669 | TOOLBAR_GetRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1670 | {
|
---|
1671 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1672 | TBUTTON_INFO *btnPtr;
|
---|
1673 | LPRECT lpRect;
|
---|
1674 | INT nIndex;
|
---|
1675 |
|
---|
1676 | if (infoPtr == NULL)
|
---|
1677 | return FALSE;
|
---|
1678 | nIndex = (INT)wParam;
|
---|
1679 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
1680 | if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
|
---|
1681 | return FALSE;
|
---|
1682 | lpRect = (LPRECT)lParam;
|
---|
1683 | if (lpRect == NULL)
|
---|
1684 | return FALSE;
|
---|
1685 |
|
---|
1686 | lpRect->left = btnPtr->rect.left;
|
---|
1687 | lpRect->right = btnPtr->rect.right;
|
---|
1688 | lpRect->bottom = btnPtr->rect.bottom;
|
---|
1689 | lpRect->top = btnPtr->rect.top;
|
---|
1690 |
|
---|
1691 | return TRUE;
|
---|
1692 | }
|
---|
1693 |
|
---|
1694 |
|
---|
1695 | static LRESULT
|
---|
1696 | TOOLBAR_GetRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1697 | {
|
---|
1698 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1699 |
|
---|
1700 | if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_WRAPABLE)
|
---|
1701 | return infoPtr->nRows;
|
---|
1702 | else
|
---|
1703 | return 1;
|
---|
1704 | }
|
---|
1705 |
|
---|
1706 |
|
---|
1707 | static LRESULT
|
---|
1708 | TOOLBAR_GetState (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1709 | {
|
---|
1710 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1711 | INT nIndex;
|
---|
1712 |
|
---|
1713 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
1714 | if (nIndex == -1)
|
---|
1715 | return -1;
|
---|
1716 |
|
---|
1717 | return infoPtr->buttons[nIndex].fsState;
|
---|
1718 | }
|
---|
1719 |
|
---|
1720 |
|
---|
1721 | static LRESULT
|
---|
1722 | TOOLBAR_GetStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1723 | {
|
---|
1724 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1725 | INT nIndex;
|
---|
1726 |
|
---|
1727 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
1728 | if (nIndex == -1)
|
---|
1729 | return -1;
|
---|
1730 |
|
---|
1731 | return infoPtr->buttons[nIndex].fsStyle;
|
---|
1732 | }
|
---|
1733 |
|
---|
1734 |
|
---|
1735 | static LRESULT
|
---|
1736 | TOOLBAR_GetTextRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1737 | {
|
---|
1738 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1739 |
|
---|
1740 | if (infoPtr == NULL)
|
---|
1741 | return 0;
|
---|
1742 |
|
---|
1743 | return infoPtr->nMaxTextRows;
|
---|
1744 | }
|
---|
1745 |
|
---|
1746 |
|
---|
1747 | static LRESULT
|
---|
1748 | TOOLBAR_GetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1749 | {
|
---|
1750 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1751 |
|
---|
1752 | if (infoPtr == NULL)
|
---|
1753 | return 0;
|
---|
1754 | return infoPtr->hwndToolTip;
|
---|
1755 | }
|
---|
1756 |
|
---|
1757 |
|
---|
1758 | static LRESULT
|
---|
1759 | TOOLBAR_GetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1760 | {
|
---|
1761 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1762 |
|
---|
1763 | // TRACE (toolbar, "%s hwnd=0x%x stub!\n",
|
---|
1764 | // infoPtr->bUnicode ? "TRUE" : "FALSE", hwnd);
|
---|
1765 |
|
---|
1766 | return infoPtr->bUnicode;
|
---|
1767 | }
|
---|
1768 |
|
---|
1769 |
|
---|
1770 | static LRESULT
|
---|
1771 | TOOLBAR_HideButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1772 | {
|
---|
1773 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1774 | TBUTTON_INFO *btnPtr;
|
---|
1775 | INT nIndex;
|
---|
1776 |
|
---|
1777 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
1778 | if (nIndex == -1)
|
---|
1779 | return FALSE;
|
---|
1780 |
|
---|
1781 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
1782 | if (LOWORD(lParam) == FALSE)
|
---|
1783 | btnPtr->fsState &= ~TBSTATE_HIDDEN;
|
---|
1784 | else
|
---|
1785 | btnPtr->fsState |= TBSTATE_HIDDEN;
|
---|
1786 |
|
---|
1787 | TOOLBAR_CalcToolbar (hwnd);
|
---|
1788 |
|
---|
1789 | InvalidateRect (hwnd, NULL, TRUE);
|
---|
1790 |
|
---|
1791 | return TRUE;
|
---|
1792 | }
|
---|
1793 |
|
---|
1794 |
|
---|
1795 | static LRESULT
|
---|
1796 | TOOLBAR_HitTest (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1797 | {
|
---|
1798 | return TOOLBAR_InternalHitTest (hwnd, (LPPOINT)lParam);
|
---|
1799 | }
|
---|
1800 |
|
---|
1801 |
|
---|
1802 | static LRESULT
|
---|
1803 | TOOLBAR_Indeterminate (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1804 | {
|
---|
1805 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1806 | TBUTTON_INFO *btnPtr;
|
---|
1807 | HDC hdc;
|
---|
1808 | INT nIndex;
|
---|
1809 |
|
---|
1810 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
1811 | if (nIndex == -1)
|
---|
1812 | return FALSE;
|
---|
1813 |
|
---|
1814 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
1815 | if (LOWORD(lParam) == FALSE)
|
---|
1816 | btnPtr->fsState &= ~TBSTATE_INDETERMINATE;
|
---|
1817 | else
|
---|
1818 | btnPtr->fsState |= TBSTATE_INDETERMINATE;
|
---|
1819 |
|
---|
1820 | hdc = GetDC (hwnd);
|
---|
1821 | TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
|
---|
1822 | ReleaseDC (hwnd, hdc);
|
---|
1823 |
|
---|
1824 | return TRUE;
|
---|
1825 | }
|
---|
1826 |
|
---|
1827 |
|
---|
1828 | static LRESULT
|
---|
1829 | TOOLBAR_InsertButtonA (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1830 | {
|
---|
1831 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1832 | LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
|
---|
1833 | INT nIndex = (INT)wParam;
|
---|
1834 | TBUTTON_INFO *oldButtons;
|
---|
1835 |
|
---|
1836 | if (lpTbb == NULL)
|
---|
1837 | return FALSE;
|
---|
1838 | if (nIndex < 0)
|
---|
1839 | return FALSE;
|
---|
1840 |
|
---|
1841 | // TRACE (toolbar, "inserting button index=%d\n", nIndex);
|
---|
1842 | if (nIndex > infoPtr->nNumButtons) {
|
---|
1843 | nIndex = infoPtr->nNumButtons;
|
---|
1844 | // TRACE (toolbar, "adjust index=%d\n", nIndex);
|
---|
1845 | }
|
---|
1846 |
|
---|
1847 | oldButtons = infoPtr->buttons;
|
---|
1848 | infoPtr->nNumButtons++;
|
---|
1849 | infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
|
---|
1850 | /* pre insert copy */
|
---|
1851 | if (nIndex > 0) {
|
---|
1852 | memcpy (&infoPtr->buttons[0], &oldButtons[0],
|
---|
1853 | nIndex * sizeof(TBUTTON_INFO));
|
---|
1854 | }
|
---|
1855 |
|
---|
1856 | /* insert new button */
|
---|
1857 | infoPtr->buttons[nIndex].iBitmap = lpTbb->iBitmap;
|
---|
1858 | infoPtr->buttons[nIndex].idCommand = lpTbb->idCommand;
|
---|
1859 | infoPtr->buttons[nIndex].fsState = lpTbb->fsState;
|
---|
1860 | infoPtr->buttons[nIndex].fsStyle = lpTbb->fsStyle;
|
---|
1861 | infoPtr->buttons[nIndex].dwData = lpTbb->dwData;
|
---|
1862 | infoPtr->buttons[nIndex].iString = lpTbb->iString;
|
---|
1863 |
|
---|
1864 | if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) {
|
---|
1865 | TTTOOLINFOA ti;
|
---|
1866 |
|
---|
1867 | ZeroMemory (&ti, sizeof(TTTOOLINFOA));
|
---|
1868 | ti.cbSize = sizeof (TTTOOLINFOA);
|
---|
1869 | ti.hwnd = hwnd;
|
---|
1870 | ti.uId = lpTbb->idCommand;
|
---|
1871 | ti.hinst = 0;
|
---|
1872 | ti.lpszText = LPSTR_TEXTCALLBACKA;
|
---|
1873 |
|
---|
1874 | SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
|
---|
1875 | 0, (LPARAM)&ti);
|
---|
1876 | }
|
---|
1877 |
|
---|
1878 | /* post insert copy */
|
---|
1879 | if (nIndex < infoPtr->nNumButtons - 1) {
|
---|
1880 | memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex],
|
---|
1881 | (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO));
|
---|
1882 | }
|
---|
1883 |
|
---|
1884 | COMCTL32_Free (oldButtons);
|
---|
1885 |
|
---|
1886 | TOOLBAR_CalcToolbar (hwnd);
|
---|
1887 |
|
---|
1888 | InvalidateRect (hwnd, NULL, FALSE);
|
---|
1889 |
|
---|
1890 | return TRUE;
|
---|
1891 | }
|
---|
1892 |
|
---|
1893 |
|
---|
1894 | /* << TOOLBAR_InsertButton32W >> */
|
---|
1895 | /* << TOOLBAR_InsertMarkHitTest >> */
|
---|
1896 |
|
---|
1897 |
|
---|
1898 | static LRESULT
|
---|
1899 | TOOLBAR_IsButtonChecked (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1900 | {
|
---|
1901 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1902 | INT nIndex;
|
---|
1903 |
|
---|
1904 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
1905 | if (nIndex == -1)
|
---|
1906 | return FALSE;
|
---|
1907 |
|
---|
1908 | return (infoPtr->buttons[nIndex].fsState & TBSTATE_CHECKED);
|
---|
1909 | }
|
---|
1910 |
|
---|
1911 |
|
---|
1912 | static LRESULT
|
---|
1913 | TOOLBAR_IsButtonEnabled (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1914 | {
|
---|
1915 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1916 | INT nIndex;
|
---|
1917 |
|
---|
1918 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
1919 | if (nIndex == -1)
|
---|
1920 | return FALSE;
|
---|
1921 |
|
---|
1922 | return (infoPtr->buttons[nIndex].fsState & TBSTATE_ENABLED);
|
---|
1923 | }
|
---|
1924 |
|
---|
1925 |
|
---|
1926 | static LRESULT
|
---|
1927 | TOOLBAR_IsButtonHidden (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1928 | {
|
---|
1929 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1930 | INT nIndex;
|
---|
1931 |
|
---|
1932 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
1933 | if (nIndex == -1)
|
---|
1934 | return FALSE;
|
---|
1935 |
|
---|
1936 | return (infoPtr->buttons[nIndex].fsState & TBSTATE_HIDDEN);
|
---|
1937 | }
|
---|
1938 |
|
---|
1939 |
|
---|
1940 | static LRESULT
|
---|
1941 | TOOLBAR_IsButtonHighlighted (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1942 | {
|
---|
1943 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1944 | INT nIndex;
|
---|
1945 |
|
---|
1946 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
1947 | if (nIndex == -1)
|
---|
1948 | return FALSE;
|
---|
1949 |
|
---|
1950 | return (infoPtr->buttons[nIndex].fsState & TBSTATE_MARKED);
|
---|
1951 | }
|
---|
1952 |
|
---|
1953 |
|
---|
1954 | static LRESULT
|
---|
1955 | TOOLBAR_IsButtonIndeterminate (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1956 | {
|
---|
1957 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1958 | INT nIndex;
|
---|
1959 |
|
---|
1960 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
1961 | if (nIndex == -1)
|
---|
1962 | return FALSE;
|
---|
1963 |
|
---|
1964 | return (infoPtr->buttons[nIndex].fsState & TBSTATE_INDETERMINATE);
|
---|
1965 | }
|
---|
1966 |
|
---|
1967 |
|
---|
1968 | static LRESULT
|
---|
1969 | TOOLBAR_IsButtonPressed (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1970 | {
|
---|
1971 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1972 | INT nIndex;
|
---|
1973 |
|
---|
1974 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
1975 | if (nIndex == -1)
|
---|
1976 | return FALSE;
|
---|
1977 |
|
---|
1978 | return (infoPtr->buttons[nIndex].fsState & TBSTATE_PRESSED);
|
---|
1979 | }
|
---|
1980 |
|
---|
1981 |
|
---|
1982 | /* << TOOLBAR_LoadImages >> */
|
---|
1983 | /* << TOOLBAR_MapAccelerator >> */
|
---|
1984 | /* << TOOLBAR_MarkButton >> */
|
---|
1985 | /* << TOOLBAR_MoveButton >> */
|
---|
1986 |
|
---|
1987 |
|
---|
1988 | static LRESULT
|
---|
1989 | TOOLBAR_PressButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1990 | {
|
---|
1991 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1992 | TBUTTON_INFO *btnPtr;
|
---|
1993 | HDC hdc;
|
---|
1994 | INT nIndex;
|
---|
1995 |
|
---|
1996 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
1997 | if (nIndex == -1)
|
---|
1998 | return FALSE;
|
---|
1999 |
|
---|
2000 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
2001 | if (LOWORD(lParam) == FALSE)
|
---|
2002 | btnPtr->fsState &= ~TBSTATE_PRESSED;
|
---|
2003 | else
|
---|
2004 | btnPtr->fsState |= TBSTATE_PRESSED;
|
---|
2005 |
|
---|
2006 | hdc = GetDC (hwnd);
|
---|
2007 | TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
|
---|
2008 | ReleaseDC (hwnd, hdc);
|
---|
2009 |
|
---|
2010 | return TRUE;
|
---|
2011 | }
|
---|
2012 |
|
---|
2013 |
|
---|
2014 | /* << TOOLBAR_ReplaceBitmap >> */
|
---|
2015 |
|
---|
2016 |
|
---|
2017 | static LRESULT
|
---|
2018 | TOOLBAR_SaveRestoreA (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2019 | {
|
---|
2020 | #if 0
|
---|
2021 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2022 | LPTBSAVEPARAMSA lpSave = (LPTBSAVEPARAMSA)lParam;
|
---|
2023 |
|
---|
2024 | if (lpSave == NULL) return 0;
|
---|
2025 |
|
---|
2026 | if ((BOOL)wParam) {
|
---|
2027 | /* save toolbar information */
|
---|
2028 | // FIXME (toolbar, "save to \"%s\" \"%s\"\n",
|
---|
2029 | // lpSave->pszSubKey, lpSave->pszValueName);
|
---|
2030 |
|
---|
2031 |
|
---|
2032 | }
|
---|
2033 | else {
|
---|
2034 | /* restore toolbar information */
|
---|
2035 |
|
---|
2036 | // FIXME (toolbar, "restore from \"%s\" \"%s\"\n",
|
---|
2037 | // lpSave->pszSubKey, lpSave->pszValueName);
|
---|
2038 |
|
---|
2039 |
|
---|
2040 | }
|
---|
2041 | #endif
|
---|
2042 |
|
---|
2043 | return 0;
|
---|
2044 | }
|
---|
2045 |
|
---|
2046 |
|
---|
2047 | /* << TOOLBAR_SaveRestore32W >> */
|
---|
2048 | /* << TOOLBAR_SetAnchorHighlight >> */
|
---|
2049 |
|
---|
2050 |
|
---|
2051 | static LRESULT
|
---|
2052 | TOOLBAR_SetBitmapSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2053 | {
|
---|
2054 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2055 |
|
---|
2056 | if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0))
|
---|
2057 | return FALSE;
|
---|
2058 |
|
---|
2059 | infoPtr->nBitmapWidth = (INT)LOWORD(lParam);
|
---|
2060 | infoPtr->nBitmapHeight = (INT)HIWORD(lParam);
|
---|
2061 |
|
---|
2062 | return TRUE;
|
---|
2063 | }
|
---|
2064 |
|
---|
2065 |
|
---|
2066 | static LRESULT
|
---|
2067 | TOOLBAR_SetButtonInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2068 | {
|
---|
2069 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2070 | LPTBBUTTONINFOA lptbbi = (LPTBBUTTONINFOA)lParam;
|
---|
2071 | TBUTTON_INFO *btnPtr;
|
---|
2072 | INT nIndex;
|
---|
2073 |
|
---|
2074 | if (lptbbi == NULL)
|
---|
2075 | return FALSE;
|
---|
2076 | if (lptbbi->cbSize < sizeof(TBBUTTONINFOA))
|
---|
2077 | return FALSE;
|
---|
2078 |
|
---|
2079 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
2080 | if (nIndex == -1)
|
---|
2081 | return FALSE;
|
---|
2082 |
|
---|
2083 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
2084 | if (lptbbi->dwMask & TBIF_COMMAND)
|
---|
2085 | btnPtr->idCommand = lptbbi->idCommand;
|
---|
2086 | if (lptbbi->dwMask & TBIF_IMAGE)
|
---|
2087 | btnPtr->iBitmap = lptbbi->iImage;
|
---|
2088 | if (lptbbi->dwMask & TBIF_LPARAM)
|
---|
2089 | btnPtr->dwData = lptbbi->lParam;
|
---|
2090 | /* if (lptbbi->dwMask & TBIF_SIZE) */
|
---|
2091 | /* btnPtr->cx = lptbbi->cx; */
|
---|
2092 | if (lptbbi->dwMask & TBIF_STATE)
|
---|
2093 | btnPtr->fsState = lptbbi->fsState;
|
---|
2094 | if (lptbbi->dwMask & TBIF_STYLE)
|
---|
2095 | btnPtr->fsStyle = lptbbi->fsStyle;
|
---|
2096 |
|
---|
2097 | if (lptbbi->dwMask & TBIF_TEXT) {
|
---|
2098 | if ((btnPtr->iString >= 0) ||
|
---|
2099 | (btnPtr->iString < infoPtr->nNumStrings)) {
|
---|
2100 | #if 0
|
---|
2101 | CHAR **lpString = &infoPtr->strings[btnPtr->iString];
|
---|
2102 | INT len = lstrlenA (lptbbi->pszText);
|
---|
2103 | *lpString = COMCTL32_ReAlloc (lpString, sizeof(char)*(len+1));
|
---|
2104 | #endif
|
---|
2105 |
|
---|
2106 | /* this is the ultimate sollution */
|
---|
2107 | /* Str_SetPtrA (&infoPtr->strings[btnPtr->iString], lptbbi->pszText); */
|
---|
2108 | }
|
---|
2109 | }
|
---|
2110 |
|
---|
2111 | return TRUE;
|
---|
2112 | }
|
---|
2113 |
|
---|
2114 |
|
---|
2115 | /* << TOOLBAR_SetButtonInfo32W >> */
|
---|
2116 |
|
---|
2117 |
|
---|
2118 | static LRESULT
|
---|
2119 | TOOLBAR_SetButtonSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2120 | {
|
---|
2121 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2122 |
|
---|
2123 | if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0))
|
---|
2124 | return FALSE;
|
---|
2125 |
|
---|
2126 | infoPtr->nButtonWidth = (INT)LOWORD(lParam);
|
---|
2127 | infoPtr->nButtonHeight = (INT)HIWORD(lParam);
|
---|
2128 |
|
---|
2129 | return TRUE;
|
---|
2130 | }
|
---|
2131 |
|
---|
2132 |
|
---|
2133 | static LRESULT
|
---|
2134 | TOOLBAR_SetButtonWidth (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2135 | {
|
---|
2136 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2137 |
|
---|
2138 | if (infoPtr == NULL)
|
---|
2139 | return FALSE;
|
---|
2140 |
|
---|
2141 | infoPtr->cxMin = (INT)LOWORD(lParam);
|
---|
2142 | infoPtr->cxMax = (INT)HIWORD(lParam);
|
---|
2143 |
|
---|
2144 | return TRUE;
|
---|
2145 | }
|
---|
2146 |
|
---|
2147 |
|
---|
2148 | static LRESULT
|
---|
2149 | TOOLBAR_SetCmdId (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2150 | {
|
---|
2151 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2152 | INT nIndex = (INT)wParam;
|
---|
2153 |
|
---|
2154 | if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
|
---|
2155 | return FALSE;
|
---|
2156 |
|
---|
2157 | infoPtr->buttons[nIndex].idCommand = (INT)lParam;
|
---|
2158 |
|
---|
2159 | if (infoPtr->hwndToolTip) {
|
---|
2160 |
|
---|
2161 | // FIXME (toolbar, "change tool tip!\n");
|
---|
2162 |
|
---|
2163 | }
|
---|
2164 |
|
---|
2165 | return TRUE;
|
---|
2166 | }
|
---|
2167 |
|
---|
2168 |
|
---|
2169 | /* << TOOLBAR_SetColorScheme >> */
|
---|
2170 |
|
---|
2171 |
|
---|
2172 | static LRESULT
|
---|
2173 | TOOLBAR_SetDisabledImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2174 | {
|
---|
2175 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2176 | HIMAGELIST himlTemp;
|
---|
2177 |
|
---|
2178 | if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT))
|
---|
2179 | return 0;
|
---|
2180 |
|
---|
2181 | himlTemp = infoPtr->himlDis;
|
---|
2182 | infoPtr->himlDis = (HIMAGELIST)lParam;
|
---|
2183 |
|
---|
2184 | /* FIXME: redraw ? */
|
---|
2185 |
|
---|
2186 | return (LRESULT)himlTemp;
|
---|
2187 | }
|
---|
2188 |
|
---|
2189 |
|
---|
2190 | static LRESULT
|
---|
2191 | TOOLBAR_SetDrawTextFlags (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2192 | {
|
---|
2193 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2194 | DWORD dwTemp;
|
---|
2195 |
|
---|
2196 | dwTemp = infoPtr->dwDTFlags;
|
---|
2197 | infoPtr->dwDTFlags =
|
---|
2198 | (infoPtr->dwDTFlags & (DWORD)wParam) | (DWORD)lParam;
|
---|
2199 |
|
---|
2200 | return (LRESULT)dwTemp;
|
---|
2201 | }
|
---|
2202 |
|
---|
2203 |
|
---|
2204 | static LRESULT
|
---|
2205 | TOOLBAR_SetExtendedStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2206 | {
|
---|
2207 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2208 | DWORD dwTemp;
|
---|
2209 |
|
---|
2210 | dwTemp = infoPtr->dwExStyle;
|
---|
2211 | infoPtr->dwExStyle = (DWORD)lParam;
|
---|
2212 |
|
---|
2213 | return (LRESULT)dwTemp;
|
---|
2214 | }
|
---|
2215 |
|
---|
2216 |
|
---|
2217 | static LRESULT
|
---|
2218 | TOOLBAR_SetHotImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2219 | {
|
---|
2220 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
|
---|
2221 | HIMAGELIST himlTemp;
|
---|
2222 |
|
---|
2223 | if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT))
|
---|
2224 | return 0;
|
---|
2225 |
|
---|
2226 | himlTemp = infoPtr->himlHot;
|
---|
2227 | infoPtr->himlHot = (HIMAGELIST)lParam;
|
---|
2228 |
|
---|
2229 | /* FIXME: redraw ? */
|
---|
2230 |
|
---|
2231 | return (LRESULT)himlTemp;
|
---|
2232 | }
|
---|
2233 |
|
---|
2234 |
|
---|
2235 | /* << TOOLBAR_SetHotItem >> */
|
---|
2236 |
|
---|
2237 |
|
---|
2238 | static LRESULT
|
---|
2239 | TOOLBAR_SetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2240 | {
|
---|
2241 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2242 | HIMAGELIST himlTemp;
|
---|
2243 |
|
---|
2244 | if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT))
|
---|
2245 | return 0;
|
---|
2246 |
|
---|
2247 | himlTemp = infoPtr->himlDef;
|
---|
2248 | infoPtr->himlDef = (HIMAGELIST)lParam;
|
---|
2249 |
|
---|
2250 | /* FIXME: redraw ? */
|
---|
2251 |
|
---|
2252 | return (LRESULT)himlTemp;
|
---|
2253 | }
|
---|
2254 |
|
---|
2255 |
|
---|
2256 | static LRESULT
|
---|
2257 | TOOLBAR_SetIndent (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2258 | {
|
---|
2259 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2260 |
|
---|
2261 | infoPtr->nIndent = (INT)wParam;
|
---|
2262 |
|
---|
2263 | TOOLBAR_CalcToolbar (hwnd);
|
---|
2264 |
|
---|
2265 | InvalidateRect(hwnd, NULL, FALSE);
|
---|
2266 |
|
---|
2267 | return TRUE;
|
---|
2268 | }
|
---|
2269 |
|
---|
2270 |
|
---|
2271 | /* << TOOLBAR_SetInsertMark >> */
|
---|
2272 |
|
---|
2273 |
|
---|
2274 | static LRESULT
|
---|
2275 | TOOLBAR_SetInsertMarkColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2276 | {
|
---|
2277 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2278 |
|
---|
2279 | infoPtr->clrInsertMark = (COLORREF)lParam;
|
---|
2280 |
|
---|
2281 | /* FIXME : redraw ??*/
|
---|
2282 |
|
---|
2283 | return 0;
|
---|
2284 | }
|
---|
2285 |
|
---|
2286 |
|
---|
2287 | static LRESULT
|
---|
2288 | TOOLBAR_SetMaxTextRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2289 | {
|
---|
2290 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2291 |
|
---|
2292 | if (infoPtr == NULL)
|
---|
2293 | return FALSE;
|
---|
2294 |
|
---|
2295 | infoPtr->nMaxTextRows = (INT)wParam;
|
---|
2296 |
|
---|
2297 | return TRUE;
|
---|
2298 | }
|
---|
2299 |
|
---|
2300 |
|
---|
2301 | /* << TOOLBAR_SetPadding >> */
|
---|
2302 |
|
---|
2303 |
|
---|
2304 | static LRESULT
|
---|
2305 | TOOLBAR_SetParent (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2306 | {
|
---|
2307 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2308 | HWND hwndOldNotify;
|
---|
2309 |
|
---|
2310 | if (infoPtr == NULL)
|
---|
2311 | return 0;
|
---|
2312 | hwndOldNotify = infoPtr->hwndNotify;
|
---|
2313 | infoPtr->hwndNotify = (HWND)wParam;
|
---|
2314 |
|
---|
2315 | return hwndOldNotify;
|
---|
2316 | }
|
---|
2317 |
|
---|
2318 |
|
---|
2319 | static LRESULT
|
---|
2320 | TOOLBAR_SetRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2321 | {
|
---|
2322 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2323 | LPRECT lprc = (LPRECT)lParam;
|
---|
2324 |
|
---|
2325 | if (LOWORD(wParam) > 1) {
|
---|
2326 |
|
---|
2327 | // FIXME (toolbar, "multiple rows not supported!\n");
|
---|
2328 |
|
---|
2329 | }
|
---|
2330 |
|
---|
2331 | /* recalculate toolbar */
|
---|
2332 | TOOLBAR_CalcToolbar (hwnd);
|
---|
2333 |
|
---|
2334 | /* return bounding rectangle */
|
---|
2335 | if (lprc) {
|
---|
2336 | lprc->left = infoPtr->rcBound.left;
|
---|
2337 | lprc->right = infoPtr->rcBound.right;
|
---|
2338 | lprc->top = infoPtr->rcBound.top;
|
---|
2339 | lprc->bottom = infoPtr->rcBound.bottom;
|
---|
2340 | }
|
---|
2341 |
|
---|
2342 | /* repaint toolbar */
|
---|
2343 | InvalidateRect(hwnd, NULL, FALSE);
|
---|
2344 |
|
---|
2345 | return 0;
|
---|
2346 | }
|
---|
2347 |
|
---|
2348 |
|
---|
2349 | static LRESULT
|
---|
2350 | TOOLBAR_SetState (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2351 | {
|
---|
2352 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2353 | TBUTTON_INFO *btnPtr;
|
---|
2354 | HDC hdc;
|
---|
2355 | INT nIndex;
|
---|
2356 |
|
---|
2357 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
2358 | if (nIndex == -1)
|
---|
2359 | return FALSE;
|
---|
2360 |
|
---|
2361 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
2362 | btnPtr->fsState = LOWORD(lParam);
|
---|
2363 |
|
---|
2364 | hdc = GetDC (hwnd);
|
---|
2365 | TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
|
---|
2366 | ReleaseDC (hwnd, hdc);
|
---|
2367 |
|
---|
2368 | return TRUE;
|
---|
2369 | }
|
---|
2370 |
|
---|
2371 |
|
---|
2372 | static LRESULT
|
---|
2373 | TOOLBAR_SetStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2374 | {
|
---|
2375 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2376 | TBUTTON_INFO *btnPtr;
|
---|
2377 | HDC hdc;
|
---|
2378 | INT nIndex;
|
---|
2379 |
|
---|
2380 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
2381 | if (nIndex == -1)
|
---|
2382 | return FALSE;
|
---|
2383 |
|
---|
2384 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
2385 | btnPtr->fsStyle = LOWORD(lParam);
|
---|
2386 |
|
---|
2387 | hdc = GetDC (hwnd);
|
---|
2388 | TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
|
---|
2389 | ReleaseDC (hwnd, hdc);
|
---|
2390 |
|
---|
2391 | if (infoPtr->hwndToolTip) {
|
---|
2392 |
|
---|
2393 | // FIXME (toolbar, "change tool tip!\n");
|
---|
2394 |
|
---|
2395 | }
|
---|
2396 |
|
---|
2397 | return TRUE;
|
---|
2398 | }
|
---|
2399 |
|
---|
2400 |
|
---|
2401 | static LRESULT
|
---|
2402 | TOOLBAR_SetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2403 | {
|
---|
2404 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2405 |
|
---|
2406 | if (infoPtr == NULL)
|
---|
2407 | return 0;
|
---|
2408 | infoPtr->hwndToolTip = (HWND)wParam;
|
---|
2409 | return 0;
|
---|
2410 | }
|
---|
2411 |
|
---|
2412 |
|
---|
2413 | static LRESULT
|
---|
2414 | TOOLBAR_SetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2415 | {
|
---|
2416 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2417 | BOOL bTemp;
|
---|
2418 |
|
---|
2419 | // TRACE (toolbar, "%s hwnd=0x%04x stub!\n",
|
---|
2420 | // ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd);
|
---|
2421 |
|
---|
2422 | bTemp = infoPtr->bUnicode;
|
---|
2423 | infoPtr->bUnicode = (BOOL)wParam;
|
---|
2424 |
|
---|
2425 | return bTemp;
|
---|
2426 | }
|
---|
2427 |
|
---|
2428 |
|
---|
2429 | static LRESULT
|
---|
2430 | TOOLBAR_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2431 | {
|
---|
2432 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2433 | DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
|
---|
2434 | LOGFONTA logFont;
|
---|
2435 |
|
---|
2436 | /* initialize info structure */
|
---|
2437 | infoPtr->nButtonHeight = 22;
|
---|
2438 | infoPtr->nButtonWidth = 23;
|
---|
2439 | infoPtr->nBitmapHeight = 15;
|
---|
2440 | infoPtr->nBitmapWidth = 16;
|
---|
2441 |
|
---|
2442 | infoPtr->nHeight = infoPtr->nButtonHeight + TOP_BORDER + BOTTOM_BORDER;
|
---|
2443 | infoPtr->nRows = 1;
|
---|
2444 | infoPtr->nMaxTextRows = 1;
|
---|
2445 | infoPtr->cxMin = -1;
|
---|
2446 | infoPtr->cxMax = -1;
|
---|
2447 |
|
---|
2448 | infoPtr->bCaptured = FALSE;
|
---|
2449 | infoPtr->bUnicode = IsWindowUnicode (hwnd);
|
---|
2450 | infoPtr->nButtonDown = -1;
|
---|
2451 | infoPtr->nOldHit = -1;
|
---|
2452 | infoPtr->nHotItem = -2; /* It has to be initially different from nOldHit */
|
---|
2453 | infoPtr->hwndNotify = GetParent (hwnd);
|
---|
2454 | infoPtr->bTransparent = (dwStyle & TBSTYLE_FLAT);
|
---|
2455 | infoPtr->dwDTFlags = DT_CENTER;
|
---|
2456 |
|
---|
2457 | SystemParametersInfoA (SPI_GETICONTITLELOGFONT, 0, &logFont, 0);
|
---|
2458 | infoPtr->hFont = CreateFontIndirectA (&logFont);
|
---|
2459 |
|
---|
2460 | if (dwStyle & TBSTYLE_TOOLTIPS) {
|
---|
2461 | /* Create tooltip control */
|
---|
2462 | infoPtr->hwndToolTip =
|
---|
2463 | CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
|
---|
2464 | CW_USEDEFAULT, CW_USEDEFAULT,
|
---|
2465 | CW_USEDEFAULT, CW_USEDEFAULT,
|
---|
2466 | hwnd, 0, 0, 0);
|
---|
2467 |
|
---|
2468 | /* Send NM_TOOLTIPSCREATED notification */
|
---|
2469 | if (infoPtr->hwndToolTip) {
|
---|
2470 | NMTOOLTIPSCREATED nmttc;
|
---|
2471 |
|
---|
2472 | nmttc.hdr.hwndFrom = hwnd;
|
---|
2473 | nmttc.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
|
---|
2474 | nmttc.hdr.code = NM_TOOLTIPSCREATED;
|
---|
2475 | nmttc.hwndToolTips = infoPtr->hwndToolTip;
|
---|
2476 |
|
---|
2477 | SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
|
---|
2478 | (WPARAM)nmttc.hdr.idFrom, (LPARAM)&nmttc);
|
---|
2479 | }
|
---|
2480 | }
|
---|
2481 |
|
---|
2482 | return 0;
|
---|
2483 | }
|
---|
2484 |
|
---|
2485 |
|
---|
2486 | static LRESULT
|
---|
2487 | TOOLBAR_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2488 | {
|
---|
2489 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2490 |
|
---|
2491 | /* delete tooltip control */
|
---|
2492 | if (infoPtr->hwndToolTip)
|
---|
2493 | DestroyWindow (infoPtr->hwndToolTip);
|
---|
2494 |
|
---|
2495 | /* delete button data */
|
---|
2496 | if (infoPtr->buttons)
|
---|
2497 | COMCTL32_Free (infoPtr->buttons);
|
---|
2498 |
|
---|
2499 | /* delete strings */
|
---|
2500 | if (infoPtr->strings) {
|
---|
2501 | INT i;
|
---|
2502 | for (i = 0; i < infoPtr->nNumStrings; i++)
|
---|
2503 | if (infoPtr->strings[i])
|
---|
2504 | COMCTL32_Free (infoPtr->strings[i]);
|
---|
2505 |
|
---|
2506 | COMCTL32_Free (infoPtr->strings);
|
---|
2507 | }
|
---|
2508 |
|
---|
2509 | /* destroy default image list */
|
---|
2510 | if (infoPtr->himlDef)
|
---|
2511 | ImageList_Destroy (infoPtr->himlDef);
|
---|
2512 |
|
---|
2513 | /* destroy disabled image list */
|
---|
2514 | if (infoPtr->himlDis)
|
---|
2515 | ImageList_Destroy (infoPtr->himlDis);
|
---|
2516 |
|
---|
2517 | /* destroy hot image list */
|
---|
2518 | if (infoPtr->himlHot)
|
---|
2519 | ImageList_Destroy (infoPtr->himlHot);
|
---|
2520 |
|
---|
2521 | /* delete default font */
|
---|
2522 | if (infoPtr->hFont)
|
---|
2523 | DeleteObject (infoPtr->hFont);
|
---|
2524 |
|
---|
2525 | /* free toolbar info data */
|
---|
2526 | COMCTL32_Free (infoPtr);
|
---|
2527 |
|
---|
2528 | return 0;
|
---|
2529 | }
|
---|
2530 |
|
---|
2531 |
|
---|
2532 | static LRESULT
|
---|
2533 | TOOLBAR_EraseBackground (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2534 | {
|
---|
2535 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2536 |
|
---|
2537 | if (infoPtr->bTransparent)
|
---|
2538 | return SendMessageA (GetParent (hwnd), WM_ERASEBKGND, wParam, lParam);
|
---|
2539 |
|
---|
2540 | return DefWindowProcA (hwnd, WM_ERASEBKGND, wParam, lParam);
|
---|
2541 | }
|
---|
2542 |
|
---|
2543 |
|
---|
2544 | static LRESULT
|
---|
2545 | TOOLBAR_LButtonDblClk (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2546 | {
|
---|
2547 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2548 | TBUTTON_INFO *btnPtr;
|
---|
2549 | POINT pt;
|
---|
2550 | INT nHit;
|
---|
2551 | HDC hdc;
|
---|
2552 |
|
---|
2553 | pt.x = (INT)LOWORD(lParam);
|
---|
2554 | pt.y = (INT)HIWORD(lParam);
|
---|
2555 | nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
|
---|
2556 |
|
---|
2557 | if (nHit >= 0) {
|
---|
2558 | btnPtr = &infoPtr->buttons[nHit];
|
---|
2559 | if (!(btnPtr->fsState & TBSTATE_ENABLED))
|
---|
2560 | return 0;
|
---|
2561 | SetCapture (hwnd);
|
---|
2562 | infoPtr->bCaptured = TRUE;
|
---|
2563 | infoPtr->nButtonDown = nHit;
|
---|
2564 |
|
---|
2565 | btnPtr->fsState |= TBSTATE_PRESSED;
|
---|
2566 |
|
---|
2567 | hdc = GetDC (hwnd);
|
---|
2568 | TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
|
---|
2569 | ReleaseDC (hwnd, hdc);
|
---|
2570 | }
|
---|
2571 | else if (GetWindowLongA (hwnd, GWL_STYLE) & CCS_ADJUSTABLE)
|
---|
2572 | TOOLBAR_Customize (hwnd);
|
---|
2573 |
|
---|
2574 | return 0;
|
---|
2575 | }
|
---|
2576 |
|
---|
2577 |
|
---|
2578 | static LRESULT
|
---|
2579 | TOOLBAR_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2580 | {
|
---|
2581 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2582 | TBUTTON_INFO *btnPtr;
|
---|
2583 | POINT pt;
|
---|
2584 | INT nHit;
|
---|
2585 | HDC hdc;
|
---|
2586 |
|
---|
2587 | if (infoPtr->hwndToolTip)
|
---|
2588 | TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
|
---|
2589 | WM_LBUTTONDOWN, wParam, lParam);
|
---|
2590 |
|
---|
2591 | pt.x = (INT)LOWORD(lParam);
|
---|
2592 | pt.y = (INT)HIWORD(lParam);
|
---|
2593 | nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
|
---|
2594 |
|
---|
2595 | if (nHit >= 0) {
|
---|
2596 | btnPtr = &infoPtr->buttons[nHit];
|
---|
2597 | if (!(btnPtr->fsState & TBSTATE_ENABLED))
|
---|
2598 | return 0;
|
---|
2599 |
|
---|
2600 | SetCapture (hwnd);
|
---|
2601 | infoPtr->bCaptured = TRUE;
|
---|
2602 | infoPtr->nButtonDown = nHit;
|
---|
2603 | infoPtr->nOldHit = nHit;
|
---|
2604 |
|
---|
2605 | btnPtr->fsState |= TBSTATE_PRESSED;
|
---|
2606 |
|
---|
2607 | hdc = GetDC (hwnd);
|
---|
2608 | TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
|
---|
2609 | ReleaseDC (hwnd, hdc);
|
---|
2610 | }
|
---|
2611 |
|
---|
2612 | return 0;
|
---|
2613 | }
|
---|
2614 |
|
---|
2615 |
|
---|
2616 | static LRESULT
|
---|
2617 | TOOLBAR_LButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2618 | {
|
---|
2619 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2620 | TBUTTON_INFO *btnPtr;
|
---|
2621 | POINT pt;
|
---|
2622 | INT nHit;
|
---|
2623 | INT nOldIndex = -1;
|
---|
2624 | HDC hdc;
|
---|
2625 | BOOL bSendMessage = TRUE;
|
---|
2626 |
|
---|
2627 | if (infoPtr->hwndToolTip)
|
---|
2628 | TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
|
---|
2629 | WM_LBUTTONUP, wParam, lParam);
|
---|
2630 |
|
---|
2631 | pt.x = (INT)LOWORD(lParam);
|
---|
2632 | pt.y = (INT)HIWORD(lParam);
|
---|
2633 | nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
|
---|
2634 |
|
---|
2635 | if ((infoPtr->bCaptured) && (infoPtr->nButtonDown >= 0)) {
|
---|
2636 | infoPtr->bCaptured = FALSE;
|
---|
2637 | ReleaseCapture ();
|
---|
2638 | btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
|
---|
2639 | btnPtr->fsState &= ~TBSTATE_PRESSED;
|
---|
2640 |
|
---|
2641 | if (nHit == infoPtr->nButtonDown) {
|
---|
2642 | if (btnPtr->fsStyle & TBSTYLE_CHECK) {
|
---|
2643 | if (btnPtr->fsStyle & TBSTYLE_GROUP) {
|
---|
2644 | nOldIndex = TOOLBAR_GetCheckedGroupButtonIndex (infoPtr,
|
---|
2645 | infoPtr->nButtonDown);
|
---|
2646 | if (nOldIndex == infoPtr->nButtonDown)
|
---|
2647 | bSendMessage = FALSE;
|
---|
2648 | if ((nOldIndex != infoPtr->nButtonDown) &&
|
---|
2649 | (nOldIndex != -1))
|
---|
2650 | infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
|
---|
2651 | btnPtr->fsState |= TBSTATE_CHECKED;
|
---|
2652 | }
|
---|
2653 | else {
|
---|
2654 | if (btnPtr->fsState & TBSTATE_CHECKED)
|
---|
2655 | btnPtr->fsState &= ~TBSTATE_CHECKED;
|
---|
2656 | else
|
---|
2657 | btnPtr->fsState |= TBSTATE_CHECKED;
|
---|
2658 | }
|
---|
2659 | }
|
---|
2660 | }
|
---|
2661 | else
|
---|
2662 | bSendMessage = FALSE;
|
---|
2663 |
|
---|
2664 | hdc = GetDC (hwnd);
|
---|
2665 | if (nOldIndex != -1)
|
---|
2666 | TOOLBAR_DrawButton (hwnd, &infoPtr->buttons[nOldIndex], hdc);
|
---|
2667 | TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
|
---|
2668 | ReleaseDC (hwnd, hdc);
|
---|
2669 |
|
---|
2670 | if (bSendMessage)
|
---|
2671 | SendMessageA (infoPtr->hwndNotify, WM_COMMAND,
|
---|
2672 | MAKEWPARAM(btnPtr->idCommand, 0), (LPARAM)hwnd);
|
---|
2673 |
|
---|
2674 | infoPtr->nButtonDown = -1;
|
---|
2675 | infoPtr->nOldHit = -1;
|
---|
2676 | }
|
---|
2677 |
|
---|
2678 | return 0;
|
---|
2679 | }
|
---|
2680 |
|
---|
2681 |
|
---|
2682 | static LRESULT
|
---|
2683 | TOOLBAR_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2684 | {
|
---|
2685 | TBUTTON_INFO *btnPtr, *oldBtnPtr;
|
---|
2686 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2687 | POINT pt;
|
---|
2688 | INT nHit;
|
---|
2689 | HDC hdc;
|
---|
2690 |
|
---|
2691 | if (infoPtr->hwndToolTip)
|
---|
2692 | TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
|
---|
2693 | WM_MOUSEMOVE, wParam, lParam);
|
---|
2694 |
|
---|
2695 | pt.x = (INT)LOWORD(lParam);
|
---|
2696 | pt.y = (INT)HIWORD(lParam);
|
---|
2697 |
|
---|
2698 | nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
|
---|
2699 |
|
---|
2700 | if (infoPtr->nOldHit != nHit)
|
---|
2701 | {
|
---|
2702 | /* Remove the effect of an old hot button */
|
---|
2703 | if(infoPtr->nOldHit == infoPtr->nHotItem)
|
---|
2704 | {
|
---|
2705 | oldBtnPtr = &infoPtr->buttons[infoPtr->nOldHit];
|
---|
2706 | oldBtnPtr->bHot = FALSE;
|
---|
2707 |
|
---|
2708 | InvalidateRect (hwnd, &oldBtnPtr->rect, TRUE);
|
---|
2709 | }
|
---|
2710 |
|
---|
2711 | /* It's not a separator or in nowhere. It's a hot button. */
|
---|
2712 | if (nHit >= 0)
|
---|
2713 | {
|
---|
2714 | btnPtr = &infoPtr->buttons[nHit];
|
---|
2715 | btnPtr->bHot = TRUE;
|
---|
2716 |
|
---|
2717 | hdc = GetDC (hwnd);
|
---|
2718 | TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
|
---|
2719 | ReleaseDC (hwnd, hdc);
|
---|
2720 |
|
---|
2721 | infoPtr->nHotItem = nHit;
|
---|
2722 | }
|
---|
2723 |
|
---|
2724 | if (infoPtr->bCaptured) {
|
---|
2725 | btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
|
---|
2726 | if (infoPtr->nOldHit == infoPtr->nButtonDown) {
|
---|
2727 | btnPtr->fsState &= ~TBSTATE_PRESSED;
|
---|
2728 | hdc = GetDC (hwnd);
|
---|
2729 | TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
|
---|
2730 | ReleaseDC (hwnd, hdc);
|
---|
2731 | }
|
---|
2732 | else if (nHit == infoPtr->nButtonDown) {
|
---|
2733 | btnPtr->fsState |= TBSTATE_PRESSED;
|
---|
2734 | hdc = GetDC (hwnd);
|
---|
2735 | TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
|
---|
2736 | ReleaseDC (hwnd, hdc);
|
---|
2737 | }
|
---|
2738 | }
|
---|
2739 | infoPtr->nOldHit = nHit;
|
---|
2740 | }
|
---|
2741 | return 0;
|
---|
2742 | }
|
---|
2743 |
|
---|
2744 |
|
---|
2745 | static LRESULT
|
---|
2746 | TOOLBAR_NCActivate (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2747 | {
|
---|
2748 | /* if (wndPtr->dwStyle & CCS_NODIVIDER) */
|
---|
2749 | return DefWindowProcA (hwnd, WM_NCACTIVATE, wParam, lParam);
|
---|
2750 | /* else */
|
---|
2751 | /* return TOOLBAR_NCPaint (wndPtr, wParam, lParam); */
|
---|
2752 | }
|
---|
2753 |
|
---|
2754 |
|
---|
2755 | static LRESULT
|
---|
2756 | TOOLBAR_NCCalcSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2757 | {
|
---|
2758 | if (!(GetWindowLongA (hwnd, GWL_STYLE) & CCS_NODIVIDER))
|
---|
2759 | ((LPRECT)lParam)->top += GetSystemMetrics(SM_CYEDGE);
|
---|
2760 |
|
---|
2761 | return DefWindowProcA (hwnd, WM_NCCALCSIZE, wParam, lParam);
|
---|
2762 | }
|
---|
2763 |
|
---|
2764 |
|
---|
2765 | static LRESULT
|
---|
2766 | TOOLBAR_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2767 | {
|
---|
2768 | TOOLBAR_INFO *infoPtr;
|
---|
2769 |
|
---|
2770 | /* allocate memory for info structure */
|
---|
2771 | infoPtr = (TOOLBAR_INFO *)COMCTL32_Alloc (sizeof(TOOLBAR_INFO));
|
---|
2772 | SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
|
---|
2773 |
|
---|
2774 | /* paranoid!! */
|
---|
2775 | infoPtr->dwStructSize = sizeof(TBBUTTON);
|
---|
2776 |
|
---|
2777 | /* fix instance handle, if the toolbar was created by CreateToolbarEx() */
|
---|
2778 | if (!GetWindowLongA (hwnd, GWL_HINSTANCE)) {
|
---|
2779 | HINSTANCE hInst = (HINSTANCE)GetWindowLongA (GetParent (hwnd), GWL_HINSTANCE);
|
---|
2780 | SetWindowLongA (hwnd, GWL_HINSTANCE, (DWORD)hInst);
|
---|
2781 | }
|
---|
2782 |
|
---|
2783 | return DefWindowProcA (hwnd, WM_NCCREATE, wParam, lParam);
|
---|
2784 | }
|
---|
2785 |
|
---|
2786 |
|
---|
2787 | static LRESULT
|
---|
2788 | TOOLBAR_NCPaint (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2789 | {
|
---|
2790 | DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
|
---|
2791 | RECT rcWindow;
|
---|
2792 | HDC hdc;
|
---|
2793 |
|
---|
2794 | if (dwStyle & WS_MINIMIZE)
|
---|
2795 | return 0; /* Nothing to do */
|
---|
2796 |
|
---|
2797 | DefWindowProcA (hwnd, WM_NCPAINT, wParam, lParam);
|
---|
2798 |
|
---|
2799 | if (!(hdc = GetDCEx (hwnd, 0, DCX_USESTYLE | DCX_WINDOW)))
|
---|
2800 | return 0;
|
---|
2801 |
|
---|
2802 | if (!(dwStyle & CCS_NODIVIDER))
|
---|
2803 | {
|
---|
2804 | GetWindowRect (hwnd, &rcWindow);
|
---|
2805 | OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
|
---|
2806 | DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_TOP);
|
---|
2807 | }
|
---|
2808 |
|
---|
2809 | ReleaseDC( hwnd, hdc );
|
---|
2810 |
|
---|
2811 | return 0;
|
---|
2812 | }
|
---|
2813 |
|
---|
2814 |
|
---|
2815 | static LRESULT
|
---|
2816 | TOOLBAR_Notify (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2817 | {
|
---|
2818 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2819 | LPNMHDR lpnmh = (LPNMHDR)lParam;
|
---|
2820 |
|
---|
2821 | // TRACE (toolbar, "passing WM_NOTIFY!\n");
|
---|
2822 |
|
---|
2823 | if ((infoPtr->hwndToolTip) && (lpnmh->hwndFrom == infoPtr->hwndToolTip)) {
|
---|
2824 | SendMessageA (infoPtr->hwndNotify, WM_NOTIFY, wParam, lParam);
|
---|
2825 |
|
---|
2826 | #if 0
|
---|
2827 | if (lpnmh->code == TTN_GETDISPINFOA) {
|
---|
2828 | LPNMTTDISPINFOA lpdi = (LPNMTTDISPINFOA)lParam;
|
---|
2829 |
|
---|
2830 | // FIXME (toolbar, "retrieving ASCII string\n");
|
---|
2831 |
|
---|
2832 | }
|
---|
2833 | else if (lpnmh->code == TTN_GETDISPINFOW) {
|
---|
2834 | LPNMTTDISPINFOW lpdi = (LPNMTTDISPINFOW)lParam;
|
---|
2835 |
|
---|
2836 | // FIXME (toolbar, "retrieving UNICODE string\n");
|
---|
2837 |
|
---|
2838 | }
|
---|
2839 | #endif
|
---|
2840 | }
|
---|
2841 |
|
---|
2842 | return 0;
|
---|
2843 | }
|
---|
2844 |
|
---|
2845 |
|
---|
2846 | static LRESULT
|
---|
2847 | TOOLBAR_Paint (HWND hwnd, WPARAM wParam)
|
---|
2848 | {
|
---|
2849 | HDC hdc;
|
---|
2850 | PAINTSTRUCT ps;
|
---|
2851 |
|
---|
2852 | TOOLBAR_CalcToolbar( hwnd );
|
---|
2853 | hdc = wParam==0 ? BeginPaint (hwnd, &ps) : (HDC)wParam;
|
---|
2854 | TOOLBAR_Refresh (hwnd, hdc);
|
---|
2855 | if (!wParam)
|
---|
2856 | EndPaint (hwnd, &ps);
|
---|
2857 | return 0;
|
---|
2858 | }
|
---|
2859 |
|
---|
2860 |
|
---|
2861 | static LRESULT
|
---|
2862 | TOOLBAR_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2863 | {
|
---|
2864 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2865 | DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
|
---|
2866 | RECT parent_rect;
|
---|
2867 | HWND parent;
|
---|
2868 | /* INT32 x, y; */
|
---|
2869 | INT cx, cy;
|
---|
2870 | INT flags;
|
---|
2871 | UINT uPosFlags = 0;
|
---|
2872 |
|
---|
2873 | /* Resize deadlock check */
|
---|
2874 | if (infoPtr->bAutoSize) {
|
---|
2875 | infoPtr->bAutoSize = FALSE;
|
---|
2876 | return 0;
|
---|
2877 | }
|
---|
2878 |
|
---|
2879 | flags = (INT) wParam;
|
---|
2880 |
|
---|
2881 | /* FIXME for flags =
|
---|
2882 | * SIZE_MAXIMIZED, SIZE_MAXSHOW, SIZE_MINIMIZED
|
---|
2883 | */
|
---|
2884 |
|
---|
2885 | // TRACE (toolbar, "sizing toolbar!\n");
|
---|
2886 |
|
---|
2887 | if (flags == SIZE_RESTORED) {
|
---|
2888 | /* width and height don't apply */
|
---|
2889 | parent = GetParent (hwnd);
|
---|
2890 | GetClientRect(parent, &parent_rect);
|
---|
2891 |
|
---|
2892 | if (dwStyle & CCS_NORESIZE) {
|
---|
2893 | uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
|
---|
2894 |
|
---|
2895 | /* FIXME */
|
---|
2896 | /* infoPtr->nWidth = parent_rect.right - parent_rect.left; */
|
---|
2897 | cy = infoPtr->nHeight;
|
---|
2898 | cx = infoPtr->nWidth;
|
---|
2899 | TOOLBAR_CalcToolbar (hwnd);
|
---|
2900 | infoPtr->nWidth = cx;
|
---|
2901 | infoPtr->nHeight = cy;
|
---|
2902 | }
|
---|
2903 | else {
|
---|
2904 | infoPtr->nWidth = parent_rect.right - parent_rect.left;
|
---|
2905 | TOOLBAR_CalcToolbar (hwnd);
|
---|
2906 | cy = infoPtr->nHeight;
|
---|
2907 | cx = infoPtr->nWidth;
|
---|
2908 | }
|
---|
2909 |
|
---|
2910 | if (dwStyle & CCS_NOPARENTALIGN) {
|
---|
2911 | uPosFlags |= SWP_NOMOVE;
|
---|
2912 | cy = infoPtr->nHeight;
|
---|
2913 | cx = infoPtr->nWidth;
|
---|
2914 | }
|
---|
2915 |
|
---|
2916 | if (!(dwStyle & CCS_NODIVIDER))
|
---|
2917 | cy += GetSystemMetrics(SM_CYEDGE);
|
---|
2918 |
|
---|
2919 | SetWindowPos (hwnd, 0, parent_rect.left, parent_rect.top,
|
---|
2920 | cx, cy, uPosFlags | SWP_NOZORDER);
|
---|
2921 | }
|
---|
2922 | return 0;
|
---|
2923 | }
|
---|
2924 |
|
---|
2925 |
|
---|
2926 | static LRESULT
|
---|
2927 | TOOLBAR_StyleChanged (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2928 | {
|
---|
2929 | TOOLBAR_AutoSize (hwnd, wParam, lParam);
|
---|
2930 |
|
---|
2931 | InvalidateRect(hwnd, NULL, FALSE);
|
---|
2932 |
|
---|
2933 | return 0;
|
---|
2934 | }
|
---|
2935 |
|
---|
2936 |
|
---|
2937 |
|
---|
2938 | LRESULT WINAPI
|
---|
2939 | ToolbarWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
---|
2940 | {
|
---|
2941 | switch (uMsg)
|
---|
2942 | {
|
---|
2943 | case TB_ADDBITMAP:
|
---|
2944 | return TOOLBAR_AddBitmap (hwnd, wParam, lParam);
|
---|
2945 |
|
---|
2946 | case TB_ADDBUTTONSA:
|
---|
2947 | return TOOLBAR_AddButtonsA (hwnd, wParam, lParam);
|
---|
2948 |
|
---|
2949 | /* case TB_ADDBUTTONSW: */
|
---|
2950 |
|
---|
2951 | case TB_ADDSTRINGA:
|
---|
2952 | return TOOLBAR_AddStringA (hwnd, wParam, lParam);
|
---|
2953 |
|
---|
2954 | case TB_ADDSTRINGW:
|
---|
2955 | return TOOLBAR_AddStringW (hwnd, wParam, lParam);
|
---|
2956 |
|
---|
2957 | case TB_AUTOSIZE:
|
---|
2958 | return TOOLBAR_AutoSize (hwnd, wParam, lParam);
|
---|
2959 |
|
---|
2960 | case TB_BUTTONCOUNT:
|
---|
2961 | return TOOLBAR_ButtonCount (hwnd, wParam, lParam);
|
---|
2962 |
|
---|
2963 | case TB_BUTTONSTRUCTSIZE:
|
---|
2964 | return TOOLBAR_ButtonStructSize (hwnd, wParam, lParam);
|
---|
2965 |
|
---|
2966 | case TB_CHANGEBITMAP:
|
---|
2967 | return TOOLBAR_ChangeBitmap (hwnd, wParam, lParam);
|
---|
2968 |
|
---|
2969 | case TB_CHECKBUTTON:
|
---|
2970 | return TOOLBAR_CheckButton (hwnd, wParam, lParam);
|
---|
2971 |
|
---|
2972 | case TB_COMMANDTOINDEX:
|
---|
2973 | return TOOLBAR_CommandToIndex (hwnd, wParam, lParam);
|
---|
2974 |
|
---|
2975 | case TB_CUSTOMIZE:
|
---|
2976 | return TOOLBAR_Customize (hwnd);
|
---|
2977 |
|
---|
2978 | case TB_DELETEBUTTON:
|
---|
2979 | return TOOLBAR_DeleteButton (hwnd, wParam, lParam);
|
---|
2980 |
|
---|
2981 | case TB_ENABLEBUTTON:
|
---|
2982 | return TOOLBAR_EnableButton (hwnd, wParam, lParam);
|
---|
2983 |
|
---|
2984 | /* case TB_GETANCHORHIGHLIGHT: */ /* 4.71 */
|
---|
2985 |
|
---|
2986 | case TB_GETBITMAP:
|
---|
2987 | return TOOLBAR_GetBitmap (hwnd, wParam, lParam);
|
---|
2988 |
|
---|
2989 | case TB_GETBITMAPFLAGS:
|
---|
2990 | return TOOLBAR_GetBitmapFlags (hwnd, wParam, lParam);
|
---|
2991 |
|
---|
2992 | case TB_GETBUTTON:
|
---|
2993 | return TOOLBAR_GetButton (hwnd, wParam, lParam);
|
---|
2994 |
|
---|
2995 | case TB_GETBUTTONINFOA:
|
---|
2996 | return TOOLBAR_GetButtonInfoA (hwnd, wParam, lParam);
|
---|
2997 |
|
---|
2998 | /* case TB_GETBUTTONINFOW: */ /* 4.71 */
|
---|
2999 |
|
---|
3000 | case TB_GETBUTTONSIZE:
|
---|
3001 | return TOOLBAR_GetButtonSize (hwnd);
|
---|
3002 |
|
---|
3003 | case TB_GETBUTTONTEXTA:
|
---|
3004 | return TOOLBAR_GetButtonTextA (hwnd, wParam, lParam);
|
---|
3005 |
|
---|
3006 | /* case TB_GETBUTTONTEXTW: */
|
---|
3007 | /* case TB_GETCOLORSCHEME: */ /* 4.71 */
|
---|
3008 |
|
---|
3009 | case TB_GETDISABLEDIMAGELIST:
|
---|
3010 | return TOOLBAR_GetDisabledImageList (hwnd, wParam, lParam);
|
---|
3011 |
|
---|
3012 | case TB_GETEXTENDEDSTYLE:
|
---|
3013 | return TOOLBAR_GetExtendedStyle (hwnd);
|
---|
3014 |
|
---|
3015 | case TB_GETHOTIMAGELIST:
|
---|
3016 | return TOOLBAR_GetHotImageList (hwnd, wParam, lParam);
|
---|
3017 |
|
---|
3018 | /* case TB_GETHOTITEM: */ /* 4.71 */
|
---|
3019 |
|
---|
3020 | case TB_GETIMAGELIST:
|
---|
3021 | return TOOLBAR_GetImageList (hwnd, wParam, lParam);
|
---|
3022 |
|
---|
3023 | /* case TB_GETINSERTMARK: */ /* 4.71 */
|
---|
3024 | /* case TB_GETINSERTMARKCOLOR: */ /* 4.71 */
|
---|
3025 |
|
---|
3026 | case TB_GETITEMRECT:
|
---|
3027 | return TOOLBAR_GetItemRect (hwnd, wParam, lParam);
|
---|
3028 |
|
---|
3029 | case TB_GETMAXSIZE:
|
---|
3030 | return TOOLBAR_GetMaxSize (hwnd, wParam, lParam);
|
---|
3031 |
|
---|
3032 | /* case TB_GETOBJECT: */ /* 4.71 */
|
---|
3033 | /* case TB_GETPADDING: */ /* 4.71 */
|
---|
3034 |
|
---|
3035 | case TB_GETRECT:
|
---|
3036 | return TOOLBAR_GetRect (hwnd, wParam, lParam);
|
---|
3037 |
|
---|
3038 | case TB_GETROWS:
|
---|
3039 | return TOOLBAR_GetRows (hwnd, wParam, lParam);
|
---|
3040 |
|
---|
3041 | case TB_GETSTATE:
|
---|
3042 | return TOOLBAR_GetState (hwnd, wParam, lParam);
|
---|
3043 |
|
---|
3044 | case TB_GETSTYLE:
|
---|
3045 | return TOOLBAR_GetStyle (hwnd, wParam, lParam);
|
---|
3046 |
|
---|
3047 | case TB_GETTEXTROWS:
|
---|
3048 | return TOOLBAR_GetTextRows (hwnd, wParam, lParam);
|
---|
3049 |
|
---|
3050 | case TB_GETTOOLTIPS:
|
---|
3051 | return TOOLBAR_GetToolTips (hwnd, wParam, lParam);
|
---|
3052 |
|
---|
3053 | case TB_GETUNICODEFORMAT:
|
---|
3054 | return TOOLBAR_GetUnicodeFormat (hwnd, wParam, lParam);
|
---|
3055 |
|
---|
3056 | case TB_HIDEBUTTON:
|
---|
3057 | return TOOLBAR_HideButton (hwnd, wParam, lParam);
|
---|
3058 |
|
---|
3059 | case TB_HITTEST:
|
---|
3060 | return TOOLBAR_HitTest (hwnd, wParam, lParam);
|
---|
3061 |
|
---|
3062 | case TB_INDETERMINATE:
|
---|
3063 | return TOOLBAR_Indeterminate (hwnd, wParam, lParam);
|
---|
3064 |
|
---|
3065 | case TB_INSERTBUTTONA:
|
---|
3066 | return TOOLBAR_InsertButtonA (hwnd, wParam, lParam);
|
---|
3067 |
|
---|
3068 | /* case TB_INSERTBUTTONW: */
|
---|
3069 | /* case TB_INSERTMARKHITTEST: */ /* 4.71 */
|
---|
3070 |
|
---|
3071 | case TB_ISBUTTONCHECKED:
|
---|
3072 | return TOOLBAR_IsButtonChecked (hwnd, wParam, lParam);
|
---|
3073 |
|
---|
3074 | case TB_ISBUTTONENABLED:
|
---|
3075 | return TOOLBAR_IsButtonEnabled (hwnd, wParam, lParam);
|
---|
3076 |
|
---|
3077 | case TB_ISBUTTONHIDDEN:
|
---|
3078 | return TOOLBAR_IsButtonHidden (hwnd, wParam, lParam);
|
---|
3079 |
|
---|
3080 | case TB_ISBUTTONHIGHLIGHTED:
|
---|
3081 | return TOOLBAR_IsButtonHighlighted (hwnd, wParam, lParam);
|
---|
3082 |
|
---|
3083 | case TB_ISBUTTONINDETERMINATE:
|
---|
3084 | return TOOLBAR_IsButtonIndeterminate (hwnd, wParam, lParam);
|
---|
3085 |
|
---|
3086 | case TB_ISBUTTONPRESSED:
|
---|
3087 | return TOOLBAR_IsButtonPressed (hwnd, wParam, lParam);
|
---|
3088 |
|
---|
3089 | /* case TB_LOADIMAGES: */ /* 4.70 */
|
---|
3090 | /* case TB_MAPACCELERATORA: */ /* 4.71 */
|
---|
3091 | /* case TB_MAPACCELERATORW: */ /* 4.71 */
|
---|
3092 | /* case TB_MARKBUTTON: */ /* 4.71 */
|
---|
3093 | /* case TB_MOVEBUTTON: */ /* 4.71 */
|
---|
3094 |
|
---|
3095 | case TB_PRESSBUTTON:
|
---|
3096 | return TOOLBAR_PressButton (hwnd, wParam, lParam);
|
---|
3097 |
|
---|
3098 | /* case TB_REPLACEBITMAP: */
|
---|
3099 |
|
---|
3100 | case TB_SAVERESTOREA:
|
---|
3101 | return TOOLBAR_SaveRestoreA (hwnd, wParam, lParam);
|
---|
3102 |
|
---|
3103 | /* case TB_SAVERESTOREW: */
|
---|
3104 | /* case TB_SETANCHORHIGHLIGHT: */ /* 4.71 */
|
---|
3105 |
|
---|
3106 | case TB_SETBITMAPSIZE:
|
---|
3107 | return TOOLBAR_SetBitmapSize (hwnd, wParam, lParam);
|
---|
3108 |
|
---|
3109 | case TB_SETBUTTONINFOA:
|
---|
3110 | return TOOLBAR_SetButtonInfoA (hwnd, wParam, lParam);
|
---|
3111 |
|
---|
3112 | /* case TB_SETBUTTONINFOW: */ /* 4.71 */
|
---|
3113 |
|
---|
3114 | case TB_SETBUTTONSIZE:
|
---|
3115 | return TOOLBAR_SetButtonSize (hwnd, wParam, lParam);
|
---|
3116 |
|
---|
3117 | case TB_SETBUTTONWIDTH:
|
---|
3118 | return TOOLBAR_SetButtonWidth (hwnd, wParam, lParam);
|
---|
3119 |
|
---|
3120 | case TB_SETCMDID:
|
---|
3121 | return TOOLBAR_SetCmdId (hwnd, wParam, lParam);
|
---|
3122 |
|
---|
3123 | /* case TB_SETCOLORSCHEME: */ /* 4.71 */
|
---|
3124 |
|
---|
3125 | case TB_SETDISABLEDIMAGELIST:
|
---|
3126 | return TOOLBAR_SetDisabledImageList (hwnd, wParam, lParam);
|
---|
3127 |
|
---|
3128 | case TB_SETDRAWTEXTFLAGS:
|
---|
3129 | return TOOLBAR_SetDrawTextFlags (hwnd, wParam, lParam);
|
---|
3130 |
|
---|
3131 | case TB_SETEXTENDEDSTYLE:
|
---|
3132 | return TOOLBAR_SetExtendedStyle (hwnd, wParam, lParam);
|
---|
3133 |
|
---|
3134 | case TB_SETHOTIMAGELIST:
|
---|
3135 | return TOOLBAR_SetHotImageList (hwnd, wParam, lParam);
|
---|
3136 |
|
---|
3137 | /* case TB_SETHOTITEM: */ /* 4.71 */
|
---|
3138 |
|
---|
3139 | case TB_SETIMAGELIST:
|
---|
3140 | return TOOLBAR_SetImageList (hwnd, wParam, lParam);
|
---|
3141 |
|
---|
3142 | case TB_SETINDENT:
|
---|
3143 | return TOOLBAR_SetIndent (hwnd, wParam, lParam);
|
---|
3144 |
|
---|
3145 | /* case TB_SETINSERTMARK: */ /* 4.71 */
|
---|
3146 |
|
---|
3147 | case TB_SETINSERTMARKCOLOR:
|
---|
3148 | return TOOLBAR_SetInsertMarkColor (hwnd, wParam, lParam);
|
---|
3149 |
|
---|
3150 | case TB_SETMAXTEXTROWS:
|
---|
3151 | return TOOLBAR_SetMaxTextRows (hwnd, wParam, lParam);
|
---|
3152 |
|
---|
3153 | /* case TB_SETPADDING: */ /* 4.71 */
|
---|
3154 |
|
---|
3155 | case TB_SETPARENT:
|
---|
3156 | return TOOLBAR_SetParent (hwnd, wParam, lParam);
|
---|
3157 |
|
---|
3158 | case TB_SETROWS:
|
---|
3159 | return TOOLBAR_SetRows (hwnd, wParam, lParam);
|
---|
3160 |
|
---|
3161 | case TB_SETSTATE:
|
---|
3162 | return TOOLBAR_SetState (hwnd, wParam, lParam);
|
---|
3163 |
|
---|
3164 | case TB_SETSTYLE:
|
---|
3165 | return TOOLBAR_SetStyle (hwnd, wParam, lParam);
|
---|
3166 |
|
---|
3167 | case TB_SETTOOLTIPS:
|
---|
3168 | return TOOLBAR_SetToolTips (hwnd, wParam, lParam);
|
---|
3169 |
|
---|
3170 | case TB_SETUNICODEFORMAT:
|
---|
3171 | return TOOLBAR_SetUnicodeFormat (hwnd, wParam, lParam);
|
---|
3172 |
|
---|
3173 |
|
---|
3174 | /* case WM_CHAR: */
|
---|
3175 |
|
---|
3176 | case WM_CREATE:
|
---|
3177 | return TOOLBAR_Create (hwnd, wParam, lParam);
|
---|
3178 |
|
---|
3179 | case WM_DESTROY:
|
---|
3180 | return TOOLBAR_Destroy (hwnd, wParam, lParam);
|
---|
3181 |
|
---|
3182 | case WM_ERASEBKGND:
|
---|
3183 | return TOOLBAR_EraseBackground (hwnd, wParam, lParam);
|
---|
3184 |
|
---|
3185 | /* case WM_GETFONT: */
|
---|
3186 | /* case WM_KEYDOWN: */
|
---|
3187 | /* case WM_KILLFOCUS: */
|
---|
3188 |
|
---|
3189 | case WM_LBUTTONDBLCLK:
|
---|
3190 | return TOOLBAR_LButtonDblClk (hwnd, wParam, lParam);
|
---|
3191 |
|
---|
3192 | case WM_LBUTTONDOWN:
|
---|
3193 | return TOOLBAR_LButtonDown (hwnd, wParam, lParam);
|
---|
3194 |
|
---|
3195 | case WM_LBUTTONUP:
|
---|
3196 | return TOOLBAR_LButtonUp (hwnd, wParam, lParam);
|
---|
3197 |
|
---|
3198 | case WM_MOUSEMOVE:
|
---|
3199 | return TOOLBAR_MouseMove (hwnd, wParam, lParam);
|
---|
3200 |
|
---|
3201 | case WM_NCACTIVATE:
|
---|
3202 | return TOOLBAR_NCActivate (hwnd, wParam, lParam);
|
---|
3203 |
|
---|
3204 | case WM_NCCALCSIZE:
|
---|
3205 | return TOOLBAR_NCCalcSize (hwnd, wParam, lParam);
|
---|
3206 |
|
---|
3207 | case WM_NCCREATE:
|
---|
3208 | return TOOLBAR_NCCreate (hwnd, wParam, lParam);
|
---|
3209 |
|
---|
3210 | case WM_NCPAINT:
|
---|
3211 | return TOOLBAR_NCPaint (hwnd, wParam, lParam);
|
---|
3212 |
|
---|
3213 | case WM_NOTIFY:
|
---|
3214 | return TOOLBAR_Notify (hwnd, wParam, lParam);
|
---|
3215 |
|
---|
3216 | /* case WM_NOTIFYFORMAT: */
|
---|
3217 |
|
---|
3218 | case WM_PAINT:
|
---|
3219 | return TOOLBAR_Paint (hwnd, wParam);
|
---|
3220 |
|
---|
3221 | case WM_SIZE:
|
---|
3222 | return TOOLBAR_Size (hwnd, wParam, lParam);
|
---|
3223 |
|
---|
3224 | case WM_STYLECHANGED:
|
---|
3225 | return TOOLBAR_StyleChanged (hwnd, wParam, lParam);
|
---|
3226 |
|
---|
3227 | /* case WM_SYSCOLORCHANGE: */
|
---|
3228 |
|
---|
3229 | /* case WM_WININICHANGE: */
|
---|
3230 |
|
---|
3231 | case WM_CHARTOITEM:
|
---|
3232 | case WM_COMMAND:
|
---|
3233 | case WM_DRAWITEM:
|
---|
3234 | case WM_MEASUREITEM:
|
---|
3235 | case WM_VKEYTOITEM:
|
---|
3236 | return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
|
---|
3237 |
|
---|
3238 | default:
|
---|
3239 | if (uMsg >= WM_USER)
|
---|
3240 | // ERR (toolbar, "unknown msg %04x wp=%08x lp=%08lx\n",
|
---|
3241 | // uMsg, wParam, lParam);
|
---|
3242 | return DefWindowProcA (hwnd, uMsg, wParam, lParam);
|
---|
3243 | }
|
---|
3244 | return 0;
|
---|
3245 | }
|
---|
3246 |
|
---|
3247 |
|
---|
3248 | VOID
|
---|
3249 | TOOLBAR_Register (VOID)
|
---|
3250 | {
|
---|
3251 | WNDCLASSA wndClass;
|
---|
3252 |
|
---|
3253 | if (GlobalFindAtomA (TOOLBARCLASSNAMEA)) return;
|
---|
3254 |
|
---|
3255 | ZeroMemory (&wndClass, sizeof(WNDCLASSA));
|
---|
3256 | wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
|
---|
3257 | wndClass.lpfnWndProc = (WNDPROC)ToolbarWindowProc;
|
---|
3258 | wndClass.cbClsExtra = 0;
|
---|
3259 | wndClass.cbWndExtra = sizeof(TOOLBAR_INFO *);
|
---|
3260 | wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
|
---|
3261 | wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
|
---|
3262 | wndClass.lpszClassName = TOOLBARCLASSNAMEA;
|
---|
3263 |
|
---|
3264 | RegisterClassA (&wndClass);
|
---|
3265 | }
|
---|
3266 |
|
---|
3267 |
|
---|
3268 | VOID
|
---|
3269 | TOOLBAR_Unregister (VOID)
|
---|
3270 | {
|
---|
3271 | if (GlobalFindAtomA (TOOLBARCLASSNAMEA))
|
---|
3272 | UnregisterClassA (TOOLBARCLASSNAMEA, (HINSTANCE)NULL);
|
---|
3273 | }
|
---|
3274 |
|
---|