1 | /* $Id: toolbar.c,v 1.13 1999-08-15 19:12:50 cbratschi Exp $ */
|
---|
2 | /*
|
---|
3 | * Toolbar control
|
---|
4 | *
|
---|
5 | * Copyright 1998,1999 Eric Kohl
|
---|
6 | * Copyright 1999 Achim Hasenmueller
|
---|
7 | * Copyright 1999 Christoph Bratschi
|
---|
8 | *
|
---|
9 | * TODO:
|
---|
10 | * - A little bug in TOOLBAR_DrawMasked()
|
---|
11 | * - Button wrapping (under construction).
|
---|
12 | * - Messages.
|
---|
13 | * - Notifications.
|
---|
14 | * - Fix TB_SETROWS.
|
---|
15 | * - Tooltip support (almost complete).
|
---|
16 | * - Fix TOOLBAR_SetButtonInfo32A.
|
---|
17 | * - Drag & drop of buttons
|
---|
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 | /* CB: Odin32/WINE bugs
|
---|
30 | - IMAGELIST_Draw draws a line too at the bottom of the bitmap (toolbar.exe)
|
---|
31 | imagelist uses default size values instead of real bitmap values
|
---|
32 | - LoadBitmapA -> use NativeLoadBitmap, is OS/2 bitmap resource
|
---|
33 | */
|
---|
34 |
|
---|
35 | #include <string.h>
|
---|
36 |
|
---|
37 | #include "winbase.h"
|
---|
38 | #include "commctrl.h"
|
---|
39 | #include "cache.h"
|
---|
40 | #include "comctl32.h"
|
---|
41 | #include "toolbar.h"
|
---|
42 |
|
---|
43 | #define SEPARATOR_WIDTH 8
|
---|
44 | #define TOP_BORDER 2
|
---|
45 | #define BOTTOM_BORDER 2
|
---|
46 |
|
---|
47 | #define TOOLBAR_GetInfoPtr(hwnd) ((TOOLBAR_INFO *)GetWindowLongA(hwnd,0))
|
---|
48 |
|
---|
49 |
|
---|
50 | static void
|
---|
51 | TOOLBAR_DrawFlatSeparator (LPRECT lpRect, HDC hdc)
|
---|
52 | {
|
---|
53 | INT x = (lpRect->left + lpRect->right) / 2 - 1;
|
---|
54 | INT yBottom = lpRect->bottom - 3;
|
---|
55 | INT yTop = lpRect->top + 1;
|
---|
56 |
|
---|
57 | SelectObject ( hdc, GetSysColorPen (COLOR_3DSHADOW));
|
---|
58 | MoveToEx (hdc, x, yBottom, NULL);
|
---|
59 | LineTo (hdc, x, yTop);
|
---|
60 | x++;
|
---|
61 | SelectObject ( hdc, GetSysColorPen (COLOR_3DHILIGHT));
|
---|
62 | MoveToEx (hdc, x, yBottom, NULL);
|
---|
63 | LineTo (hdc, x, yTop);
|
---|
64 | }
|
---|
65 |
|
---|
66 |
|
---|
67 | static void
|
---|
68 | TOOLBAR_DrawString (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
|
---|
69 | HDC hdc, INT nState)
|
---|
70 | {
|
---|
71 | RECT rcText = btnPtr->rect;
|
---|
72 | HFONT hOldFont;
|
---|
73 | INT nOldBkMode;
|
---|
74 | COLORREF clrOld;
|
---|
75 |
|
---|
76 | /* draw text */
|
---|
77 | if ((btnPtr->iString > -1) && (btnPtr->iString < infoPtr->nNumStrings)) {
|
---|
78 | InflateRect (&rcText, -3, -3);
|
---|
79 | rcText.top += infoPtr->nBitmapHeight;
|
---|
80 | if (nState & (TBSTATE_PRESSED | TBSTATE_CHECKED))
|
---|
81 | OffsetRect (&rcText, 1, 1);
|
---|
82 |
|
---|
83 | hOldFont = SelectObject (hdc, infoPtr->hFont);
|
---|
84 | nOldBkMode = SetBkMode (hdc, TRANSPARENT);
|
---|
85 | if (!(nState & TBSTATE_ENABLED)) {
|
---|
86 | clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DHILIGHT));
|
---|
87 | OffsetRect (&rcText, 1, 1);
|
---|
88 | DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1,
|
---|
89 | &rcText, infoPtr->dwDTFlags);
|
---|
90 | SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW));
|
---|
91 | OffsetRect (&rcText, -1, -1);
|
---|
92 | DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1,
|
---|
93 | &rcText, infoPtr->dwDTFlags);
|
---|
94 | }
|
---|
95 | else if (nState & TBSTATE_INDETERMINATE) {
|
---|
96 | clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW));
|
---|
97 | DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1,
|
---|
98 | &rcText, infoPtr->dwDTFlags);
|
---|
99 | }
|
---|
100 | else {
|
---|
101 | clrOld = SetTextColor (hdc, GetSysColor (COLOR_BTNTEXT));
|
---|
102 | DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1,
|
---|
103 | &rcText, infoPtr->dwDTFlags);
|
---|
104 | }
|
---|
105 |
|
---|
106 | SetTextColor (hdc, clrOld);
|
---|
107 | SelectObject (hdc, hOldFont);
|
---|
108 | if (nOldBkMode != TRANSPARENT)
|
---|
109 | SetBkMode (hdc, nOldBkMode);
|
---|
110 | }
|
---|
111 | }
|
---|
112 |
|
---|
113 |
|
---|
114 | static void
|
---|
115 | TOOLBAR_DrawPattern (HDC hdc, LPRECT lpRect)
|
---|
116 | {
|
---|
117 | HBRUSH hbr = SelectObject (hdc, CACHE_GetPattern55AABrush ());
|
---|
118 | INT cx = lpRect->right - lpRect->left;
|
---|
119 | INT cy = lpRect->bottom - lpRect->top;
|
---|
120 | PatBlt (hdc, lpRect->left, lpRect->top, cx, cy, 0x00FA0089);
|
---|
121 | SelectObject (hdc, hbr);
|
---|
122 | }
|
---|
123 |
|
---|
124 |
|
---|
125 | static void
|
---|
126 | TOOLBAR_DrawMasked (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
|
---|
127 | HDC hdc, INT x, INT y)
|
---|
128 | {
|
---|
129 | /* FIXME: this function is a hack since it uses image list
|
---|
130 | internals directly */
|
---|
131 |
|
---|
132 | HIMAGELIST himl = infoPtr->himlDef;
|
---|
133 | HBITMAP hbmMask;
|
---|
134 | HDC hdcImageList;
|
---|
135 | HDC hdcMask;
|
---|
136 |
|
---|
137 | if (!himl)
|
---|
138 | return;
|
---|
139 |
|
---|
140 | /* create new dc's */
|
---|
141 | hdcImageList = CreateCompatibleDC (0);
|
---|
142 | hdcMask = CreateCompatibleDC (0);
|
---|
143 |
|
---|
144 | /* create new bitmap */
|
---|
145 | hbmMask = CreateBitmap (himl->cx, himl->cy, 1, 1, NULL);
|
---|
146 | SelectObject (hdcMask, hbmMask);
|
---|
147 |
|
---|
148 | /* copy the mask bitmap */
|
---|
149 | SelectObject (hdcImageList, himl->hbmMask);
|
---|
150 | SetBkColor (hdcImageList, RGB(255, 255, 255));
|
---|
151 | SetTextColor (hdcImageList, RGB(0, 0, 0));
|
---|
152 | BitBlt (hdcMask, 0, 0, himl->cx, himl->cy,
|
---|
153 | hdcImageList, himl->cx * btnPtr->iBitmap, 0, SRCCOPY);
|
---|
154 |
|
---|
155 | #if 0
|
---|
156 | /* add white mask from image */
|
---|
157 | SelectObject (hdcImageList, himl->hbmImage);
|
---|
158 | SetBkColor (hdcImageList, RGB(0, 0, 0));
|
---|
159 | BitBlt (hdcMask, 0, 0, himl->cx, himl->cy,
|
---|
160 | hdcImageList, himl->cx * btnPtr->iBitmap, 0, MERGEPAINT);
|
---|
161 | #endif
|
---|
162 |
|
---|
163 | /* draw the new mask */
|
---|
164 | SelectObject (hdc, GetSysColorBrush (COLOR_3DHILIGHT));
|
---|
165 | BitBlt (hdc, x+1, y+1, himl->cx, himl->cy,
|
---|
166 | hdcMask, 0, 0, 0xB8074A);
|
---|
167 |
|
---|
168 | SelectObject (hdc, GetSysColorBrush (COLOR_3DSHADOW));
|
---|
169 | BitBlt (hdc, x, y, himl->cx, himl->cy,
|
---|
170 | hdcMask, 0, 0, 0xB8074A);
|
---|
171 |
|
---|
172 | DeleteObject (hbmMask);
|
---|
173 | DeleteDC (hdcMask);
|
---|
174 | DeleteDC (hdcImageList);
|
---|
175 | }
|
---|
176 |
|
---|
177 |
|
---|
178 | static void
|
---|
179 | TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc)
|
---|
180 | {
|
---|
181 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
182 | DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
|
---|
183 | RECT rc;
|
---|
184 |
|
---|
185 | if (btnPtr->fsState & TBSTATE_HIDDEN) return;
|
---|
186 |
|
---|
187 | rc = btnPtr->rect;
|
---|
188 |
|
---|
189 | /* separator */
|
---|
190 | if (btnPtr->fsStyle & TBSTYLE_SEP)
|
---|
191 | {
|
---|
192 | if ((dwStyle & TBSTYLE_FLAT) && (btnPtr->iBitmap == 0))
|
---|
193 | TOOLBAR_DrawFlatSeparator (&rc, hdc);
|
---|
194 | return;
|
---|
195 | }
|
---|
196 |
|
---|
197 | /* disabled */
|
---|
198 | if (!(btnPtr->fsState & TBSTATE_ENABLED))
|
---|
199 | {
|
---|
200 | if (!(dwStyle & TBSTYLE_FLAT))
|
---|
201 | DrawEdge (hdc, &rc, EDGE_RAISED,
|
---|
202 | BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
|
---|
203 |
|
---|
204 | if (infoPtr->himlDis)
|
---|
205 | ImageList_Draw (infoPtr->himlDis, btnPtr->iBitmap, hdc,
|
---|
206 | rc.left+1, rc.top+1, ILD_NORMAL);
|
---|
207 | else
|
---|
208 | TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left+1, rc.top+1);
|
---|
209 |
|
---|
210 | TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
|
---|
211 | return;
|
---|
212 | }
|
---|
213 |
|
---|
214 | /* pressed TBSTYLE_BUTTON */
|
---|
215 | if (btnPtr->fsState & TBSTATE_PRESSED)
|
---|
216 | {
|
---|
217 | DrawEdge (hdc, &rc, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST);
|
---|
218 | ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
|
---|
219 | rc.left+2, rc.top+2, ILD_NORMAL);
|
---|
220 | TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
|
---|
221 | return;
|
---|
222 | }
|
---|
223 |
|
---|
224 | /* checked TBSTYLE_CHECK*/
|
---|
225 | if ((btnPtr->fsStyle & TBSTYLE_CHECK) &&
|
---|
226 | (btnPtr->fsState & TBSTATE_CHECKED)) {
|
---|
227 | if (dwStyle & TBSTYLE_FLAT)
|
---|
228 | DrawEdge (hdc, &rc, BDR_SUNKENOUTER,
|
---|
229 | BF_RECT | BF_MIDDLE | BF_ADJUST);
|
---|
230 | else
|
---|
231 | DrawEdge (hdc, &rc, EDGE_SUNKEN,
|
---|
232 | BF_RECT | BF_MIDDLE | BF_ADJUST);
|
---|
233 |
|
---|
234 | TOOLBAR_DrawPattern (hdc, &rc);
|
---|
235 |
|
---|
236 | ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
|
---|
237 | rc.left+2, rc.top+2, ILD_NORMAL);
|
---|
238 |
|
---|
239 | TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
|
---|
240 | return;
|
---|
241 | }
|
---|
242 |
|
---|
243 | /* indeterminate */
|
---|
244 | if (btnPtr->fsState & TBSTATE_INDETERMINATE)
|
---|
245 | {
|
---|
246 | DrawEdge (hdc, &rc, EDGE_RAISED,
|
---|
247 | BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
|
---|
248 |
|
---|
249 | TOOLBAR_DrawPattern (hdc, &rc);
|
---|
250 | TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left+1, rc.top+1);
|
---|
251 | TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
|
---|
252 | return;
|
---|
253 | }
|
---|
254 |
|
---|
255 | /* normal state */
|
---|
256 | if (dwStyle & TBSTYLE_FLAT)
|
---|
257 | {
|
---|
258 | if(btnPtr->bHot)
|
---|
259 | DrawEdge (hdc, &rc, BDR_RAISEDINNER,
|
---|
260 | BF_RECT | BF_MIDDLE | BF_SOFT);
|
---|
261 |
|
---|
262 | if(btnPtr->bHot && infoPtr->himlHot)
|
---|
263 | ImageList_Draw (infoPtr->himlHot, btnPtr->iBitmap, hdc,
|
---|
264 | rc.left +2, rc.top +2, ILD_NORMAL);
|
---|
265 | else
|
---|
266 | ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
|
---|
267 | rc.left +2, rc.top +2, ILD_NORMAL);
|
---|
268 | } else
|
---|
269 | {
|
---|
270 | DrawEdge (hdc, &rc, EDGE_RAISED,
|
---|
271 | BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
|
---|
272 |
|
---|
273 | ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
|
---|
274 | rc.left+1, rc.top+1, ILD_NORMAL);
|
---|
275 | }
|
---|
276 |
|
---|
277 | TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
|
---|
278 | }
|
---|
279 |
|
---|
280 |
|
---|
281 | static void
|
---|
282 | TOOLBAR_Refresh (HWND hwnd, HDC hdc)
|
---|
283 | {
|
---|
284 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
285 | TBUTTON_INFO *btnPtr;
|
---|
286 | INT i;
|
---|
287 |
|
---|
288 | /* draw buttons */
|
---|
289 | btnPtr = infoPtr->buttons;
|
---|
290 | for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++)
|
---|
291 | TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
|
---|
292 | }
|
---|
293 |
|
---|
294 |
|
---|
295 | static void
|
---|
296 | TOOLBAR_CalcStrings (HWND hwnd, LPSIZE lpSize)
|
---|
297 | {
|
---|
298 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
299 | TBUTTON_INFO *btnPtr;
|
---|
300 | INT i;
|
---|
301 | HDC hdc;
|
---|
302 | HFONT hOldFont;
|
---|
303 | SIZE sz;
|
---|
304 |
|
---|
305 | lpSize->cx = 0;
|
---|
306 | lpSize->cy = 0;
|
---|
307 | hdc = GetDC (0);
|
---|
308 | hOldFont = SelectObject (hdc, infoPtr->hFont);
|
---|
309 |
|
---|
310 | btnPtr = infoPtr->buttons;
|
---|
311 | for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
|
---|
312 | if (!(btnPtr->fsState & TBSTATE_HIDDEN) &&
|
---|
313 | (btnPtr->iString > -1) &&
|
---|
314 | (btnPtr->iString < infoPtr->nNumStrings)) {
|
---|
315 | LPWSTR lpText = infoPtr->strings[btnPtr->iString];
|
---|
316 | GetTextExtentPoint32W (hdc, lpText, lstrlenW (lpText), &sz);
|
---|
317 | if (sz.cx > lpSize->cx)
|
---|
318 | lpSize->cx = sz.cx;
|
---|
319 | if (sz.cy > lpSize->cy)
|
---|
320 | lpSize->cy = sz.cy;
|
---|
321 | }
|
---|
322 | }
|
---|
323 |
|
---|
324 | SelectObject (hdc, hOldFont);
|
---|
325 | ReleaseDC (0, hdc);
|
---|
326 |
|
---|
327 | // TRACE (toolbar, "string size %d x %d!\n", lpSize->cx, lpSize->cy);
|
---|
328 | }
|
---|
329 |
|
---|
330 | /***********************************************************************
|
---|
331 | * TOOLBAR_WrapToolbar
|
---|
332 | *
|
---|
333 | * This function walks through the buttons and seperators in the
|
---|
334 | * toolbar, and sets the TBSTATE_WRAP flag only on those items where
|
---|
335 | * wrapping should occur based on the width of the toolbar window.
|
---|
336 | * It does *not* calculate button placement itself. That task
|
---|
337 | * takes place in TOOLBAR_CalcToolbar. If the program wants to manage
|
---|
338 | * the toolbar wrapping on it's own, it can use the TBSTYLE_WRAPPABLE
|
---|
339 | * flag, and set the TBSTATE_WRAP flags manually on the appropriate items.
|
---|
340 | */
|
---|
341 |
|
---|
342 | static void
|
---|
343 | TOOLBAR_WrapToolbar( HWND hwnd )
|
---|
344 | {
|
---|
345 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
346 | TBUTTON_INFO *btnPtr;
|
---|
347 | DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
|
---|
348 | INT x, cx, i, j;
|
---|
349 | RECT rc;
|
---|
350 | BOOL bWrap, bButtonWrap;
|
---|
351 |
|
---|
352 | /* When the toolbar window style is not TBSTYLE_WRAPABLE, */
|
---|
353 | /* no layout is necessary. Applications may use this style */
|
---|
354 | /* to perform their own layout on the toolbar. */
|
---|
355 | if( !(dwStyle & TBSTYLE_WRAPABLE) )
|
---|
356 | return;
|
---|
357 |
|
---|
358 | btnPtr = infoPtr->buttons;
|
---|
359 | x = infoPtr->nIndent;
|
---|
360 |
|
---|
361 | GetClientRect( GetParent(hwnd), &rc );
|
---|
362 | infoPtr->nWidth = rc.right - rc.left;
|
---|
363 | bButtonWrap = FALSE;
|
---|
364 |
|
---|
365 | for (i = 0; i < infoPtr->nNumButtons; i++ )
|
---|
366 | {
|
---|
367 | bWrap = FALSE;
|
---|
368 | btnPtr[i].fsState &= ~TBSTATE_WRAP;
|
---|
369 |
|
---|
370 | if (btnPtr[i].fsState & TBSTATE_HIDDEN)
|
---|
371 | continue;
|
---|
372 |
|
---|
373 | /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
|
---|
374 | /* it is the actual width of the separator. This is used for */
|
---|
375 | /* custom controls in toolbars. */
|
---|
376 | if (btnPtr[i].fsStyle & TBSTYLE_SEP)
|
---|
377 | cx = (btnPtr[i].iBitmap > 0) ?
|
---|
378 | btnPtr[i].iBitmap : SEPARATOR_WIDTH;
|
---|
379 | else
|
---|
380 | cx = infoPtr->nButtonWidth;
|
---|
381 |
|
---|
382 | /* Two or more adjacent separators form a separator group. */
|
---|
383 | /* The first separator in a group should be wrapped to the */
|
---|
384 | /* next row if the previous wrapping is on a button. */
|
---|
385 | if( bButtonWrap &&
|
---|
386 | (btnPtr[i].fsStyle & TBSTYLE_SEP) &&
|
---|
387 | (i + 1 < infoPtr->nNumButtons ) &&
|
---|
388 | (btnPtr[i + 1].fsStyle & TBSTYLE_SEP) )
|
---|
389 | {
|
---|
390 | btnPtr[i].fsState |= TBSTATE_WRAP;
|
---|
391 | x = infoPtr->nIndent;
|
---|
392 | i++;
|
---|
393 | bButtonWrap = FALSE;
|
---|
394 | continue;
|
---|
395 | }
|
---|
396 |
|
---|
397 | /* The layout makes sure the bitmap is visible, but not the button. */
|
---|
398 | if ( x + cx - (infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2
|
---|
399 | > infoPtr->nWidth )
|
---|
400 | {
|
---|
401 | BOOL bFound = FALSE;
|
---|
402 |
|
---|
403 | /* If the current button is a separator and not hidden, */
|
---|
404 | /* go to the next until it reaches a non separator. */
|
---|
405 | /* Wrap the last separator if it is before a button. */
|
---|
406 | while( ( (btnPtr[i].fsStyle & TBSTYLE_SEP) ||
|
---|
407 | (btnPtr[i].fsState & TBSTATE_HIDDEN) ) &&
|
---|
408 | i < infoPtr->nNumButtons )
|
---|
409 | {
|
---|
410 | i++;
|
---|
411 | bFound = TRUE;
|
---|
412 | }
|
---|
413 |
|
---|
414 | if( bFound && i < infoPtr->nNumButtons )
|
---|
415 | {
|
---|
416 | i--;
|
---|
417 | btnPtr[i].fsState |= TBSTATE_WRAP;
|
---|
418 | x = infoPtr->nIndent;
|
---|
419 | bButtonWrap = FALSE;
|
---|
420 | continue;
|
---|
421 | }
|
---|
422 | else if ( i >= infoPtr->nNumButtons)
|
---|
423 | break;
|
---|
424 |
|
---|
425 | /* If the current button is not a separator, find the last */
|
---|
426 | /* separator and wrap it. */
|
---|
427 | for ( j = i - 1; j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
|
---|
428 | {
|
---|
429 | if ((btnPtr[j].fsStyle & TBSTYLE_SEP) &&
|
---|
430 | !(btnPtr[j].fsState & TBSTATE_HIDDEN))
|
---|
431 | {
|
---|
432 | bFound = TRUE;
|
---|
433 | i = j;
|
---|
434 | x = infoPtr->nIndent;
|
---|
435 | btnPtr[j].fsState |= TBSTATE_WRAP;
|
---|
436 | bButtonWrap = FALSE;
|
---|
437 | break;
|
---|
438 | }
|
---|
439 | }
|
---|
440 |
|
---|
441 | /* If no separator available for wrapping, wrap one of */
|
---|
442 | /* non-hidden previous button. */
|
---|
443 | if (!bFound)
|
---|
444 | {
|
---|
445 | for ( j = i - 1;
|
---|
446 | j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
|
---|
447 | {
|
---|
448 | if (btnPtr[j].fsState & TBSTATE_HIDDEN)
|
---|
449 | continue;
|
---|
450 |
|
---|
451 | bFound = TRUE;
|
---|
452 | i = j;
|
---|
453 | x = infoPtr->nIndent;
|
---|
454 | btnPtr[j].fsState |= TBSTATE_WRAP;
|
---|
455 | bButtonWrap = TRUE;
|
---|
456 | break;
|
---|
457 | }
|
---|
458 | }
|
---|
459 |
|
---|
460 | /* If all above failed, wrap the current button. */
|
---|
461 | if (!bFound)
|
---|
462 | {
|
---|
463 | btnPtr[i].fsState |= TBSTATE_WRAP;
|
---|
464 | bFound = TRUE;
|
---|
465 | x = infoPtr->nIndent;
|
---|
466 | if (btnPtr[i].fsState & TBSTYLE_SEP )
|
---|
467 | bButtonWrap = FALSE;
|
---|
468 | else
|
---|
469 | bButtonWrap = TRUE;
|
---|
470 | }
|
---|
471 | }
|
---|
472 | else
|
---|
473 | x += cx;
|
---|
474 | }
|
---|
475 | }
|
---|
476 |
|
---|
477 | /***********************************************************************
|
---|
478 | * TOOLBAR_CalcToolbar
|
---|
479 | *
|
---|
480 | * This function calculates button and separator placement. It first
|
---|
481 | * calculates the button sizes, gets the toolbar window width and then
|
---|
482 | * calls TOOLBAR_WrapToolbar to determine which buttons we need to wrap
|
---|
483 | * on. It assigns a new location to each item and sends this location to
|
---|
484 | * the tooltip window if appropriate. Finally, it updates the rcBound
|
---|
485 | * rect and calculates the new required toolbar window height.
|
---|
486 | */
|
---|
487 |
|
---|
488 | static void
|
---|
489 | TOOLBAR_CalcToolbar (HWND hwnd)
|
---|
490 | {
|
---|
491 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
|
---|
492 | TBUTTON_INFO *btnPtr;
|
---|
493 | INT i, nRows, nSepRows;
|
---|
494 | INT x, y, cx, cy;
|
---|
495 | SIZE sizeString;
|
---|
496 | RECT rc;
|
---|
497 | BOOL bWrap;
|
---|
498 |
|
---|
499 | TOOLBAR_CalcStrings (hwnd, &sizeString);
|
---|
500 |
|
---|
501 | if (sizeString.cy > 0)
|
---|
502 | infoPtr->nButtonHeight = sizeString.cy + infoPtr->nBitmapHeight + 6;
|
---|
503 | else if (infoPtr->nButtonHeight < infoPtr->nBitmapHeight + 6)
|
---|
504 | infoPtr->nButtonHeight = infoPtr->nBitmapHeight + 6;
|
---|
505 |
|
---|
506 | if (sizeString.cx > infoPtr->nBitmapWidth)
|
---|
507 | infoPtr->nButtonWidth = sizeString.cx + 6;
|
---|
508 | else if (infoPtr->nButtonWidth < infoPtr->nBitmapWidth + 6)
|
---|
509 | infoPtr->nButtonWidth = infoPtr->nBitmapWidth + 6;
|
---|
510 |
|
---|
511 | TOOLBAR_WrapToolbar( hwnd );
|
---|
512 |
|
---|
513 | x = infoPtr->nIndent;
|
---|
514 | y = TOP_BORDER;
|
---|
515 | cx = infoPtr->nButtonWidth;
|
---|
516 | cy = infoPtr->nButtonHeight;
|
---|
517 | nRows = nSepRows = 0;
|
---|
518 |
|
---|
519 | infoPtr->rcBound.top = y;
|
---|
520 | infoPtr->rcBound.left = x;
|
---|
521 | infoPtr->rcBound.bottom = y + cy;
|
---|
522 | infoPtr->rcBound.right = x;
|
---|
523 |
|
---|
524 | btnPtr = infoPtr->buttons;
|
---|
525 | GetClientRect( GetParent(hwnd), &rc );
|
---|
526 | infoPtr->nWidth = rc.right - rc.left;
|
---|
527 |
|
---|
528 | for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++ )
|
---|
529 | {
|
---|
530 | bWrap = FALSE;
|
---|
531 | if (btnPtr->fsState & TBSTATE_HIDDEN)
|
---|
532 | {
|
---|
533 | SetRectEmpty (&btnPtr->rect);
|
---|
534 | continue;
|
---|
535 | }
|
---|
536 |
|
---|
537 | /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
|
---|
538 | /* it is the actual width of the separator. This is used for */
|
---|
539 | /* custom controls in toolbars. */
|
---|
540 | if (btnPtr->fsStyle & TBSTYLE_SEP)
|
---|
541 | cx = (btnPtr->iBitmap > 0) ?
|
---|
542 | btnPtr->iBitmap : SEPARATOR_WIDTH;
|
---|
543 | else
|
---|
544 | cx = infoPtr->nButtonWidth;
|
---|
545 |
|
---|
546 | if (btnPtr->fsState & TBSTATE_WRAP )
|
---|
547 | bWrap = TRUE;
|
---|
548 |
|
---|
549 | SetRect (&btnPtr->rect, x, y, x + cx, y + cy);
|
---|
550 |
|
---|
551 | if (infoPtr->rcBound.left > x)
|
---|
552 | infoPtr->rcBound.left = x;
|
---|
553 | if (infoPtr->rcBound.right < x + cx)
|
---|
554 | infoPtr->rcBound.right = x + cx;
|
---|
555 | if (infoPtr->rcBound.bottom < y + cy)
|
---|
556 | infoPtr->rcBound.bottom = y + cy;
|
---|
557 |
|
---|
558 | /* Set the toolTip only for non-hidden, non-separator button */
|
---|
559 | if (infoPtr->hwndToolTip && !(btnPtr->fsStyle & TBSTYLE_SEP))
|
---|
560 | {
|
---|
561 | TTTOOLINFOA ti;
|
---|
562 |
|
---|
563 | ZeroMemory (&ti,sizeof(TTTOOLINFOA));
|
---|
564 | ti.cbSize = sizeof(TTTOOLINFOA);
|
---|
565 | ti.hwnd = hwnd;
|
---|
566 | ti.uId = btnPtr->idCommand;
|
---|
567 | ti.rect = btnPtr->rect;
|
---|
568 | SendMessageA(infoPtr->hwndToolTip,TTM_NEWTOOLRECTA,0,(LPARAM)&ti);
|
---|
569 | }
|
---|
570 |
|
---|
571 | /* btnPtr->nRow is zero based. The space between the rows is */
|
---|
572 | /* also considered as a row. */
|
---|
573 | btnPtr->nRow = nRows + nSepRows;
|
---|
574 | if( bWrap )
|
---|
575 | {
|
---|
576 | if ( !(btnPtr->fsStyle & TBSTYLE_SEP) )
|
---|
577 | y += cy;
|
---|
578 | else
|
---|
579 | {
|
---|
580 | /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
|
---|
581 | /* it is the actual width of the separator. This is used for */
|
---|
582 | /* custom controls in toolbars. */
|
---|
583 | y += cy + ( (btnPtr->iBitmap > 0 ) ?
|
---|
584 | btnPtr->iBitmap : SEPARATOR_WIDTH) * 2 /3;
|
---|
585 |
|
---|
586 | /* nSepRows is used to calculate the extra height follwoing */
|
---|
587 | /* the last row. */
|
---|
588 | nSepRows++;
|
---|
589 | }
|
---|
590 | x = infoPtr->nIndent;
|
---|
591 | nRows++;
|
---|
592 | }
|
---|
593 | else
|
---|
594 | x += cx;
|
---|
595 | }
|
---|
596 |
|
---|
597 | /* infoPtr->nRows is the number of rows on the toolbar */
|
---|
598 | infoPtr->nRows = nRows + nSepRows + 1;
|
---|
599 |
|
---|
600 | /* nSepRows * (infoPtr->nBitmapHeight + 1) is the space following */
|
---|
601 | /* the last row. */
|
---|
602 | infoPtr->nHeight = TOP_BORDER + (nRows + 1) * infoPtr->nButtonHeight +
|
---|
603 | nSepRows * SEPARATOR_WIDTH * 2 / 3 +
|
---|
604 | nSepRows * (infoPtr->nBitmapHeight + 1) +
|
---|
605 | BOTTOM_BORDER;
|
---|
606 | // TRACE (toolbar, "toolbar height %d\n", infoPtr->nHeight);
|
---|
607 | }
|
---|
608 |
|
---|
609 |
|
---|
610 | static INT
|
---|
611 | TOOLBAR_InternalHitTest (HWND hwnd, LPPOINT lpPt)
|
---|
612 | {
|
---|
613 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
614 | TBUTTON_INFO *btnPtr;
|
---|
615 | INT i;
|
---|
616 |
|
---|
617 | btnPtr = infoPtr->buttons;
|
---|
618 | for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
|
---|
619 | if (btnPtr->fsState & TBSTATE_HIDDEN)
|
---|
620 | continue;
|
---|
621 |
|
---|
622 | if (btnPtr->fsStyle & TBSTYLE_SEP) {
|
---|
623 | if (PtInRect (&btnPtr->rect, *lpPt)) {
|
---|
624 | // TRACE (toolbar, " ON SEPARATOR %d!\n", i);
|
---|
625 | return -i;
|
---|
626 | }
|
---|
627 | }
|
---|
628 | else {
|
---|
629 | if (PtInRect (&btnPtr->rect, *lpPt)) {
|
---|
630 | // TRACE (toolbar, " ON BUTTON %d!\n", i);
|
---|
631 | return i;
|
---|
632 | }
|
---|
633 | }
|
---|
634 | }
|
---|
635 |
|
---|
636 | // TRACE (toolbar, " NOWHERE!\n");
|
---|
637 | return -1;
|
---|
638 | }
|
---|
639 |
|
---|
640 |
|
---|
641 | static INT
|
---|
642 | TOOLBAR_GetButtonIndex (TOOLBAR_INFO *infoPtr, INT idCommand)
|
---|
643 | {
|
---|
644 | TBUTTON_INFO *btnPtr;
|
---|
645 | INT i;
|
---|
646 |
|
---|
647 | btnPtr = infoPtr->buttons;
|
---|
648 | for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
|
---|
649 | if (btnPtr->idCommand == idCommand) {
|
---|
650 | // TRACE (toolbar, "command=%d index=%d\n", idCommand, i);
|
---|
651 | return i;
|
---|
652 | }
|
---|
653 | }
|
---|
654 | // TRACE (toolbar, "no index found for command=%d\n", idCommand);
|
---|
655 | return -1;
|
---|
656 | }
|
---|
657 |
|
---|
658 |
|
---|
659 | static INT
|
---|
660 | TOOLBAR_GetCheckedGroupButtonIndex (TOOLBAR_INFO *infoPtr, INT nIndex)
|
---|
661 | {
|
---|
662 | TBUTTON_INFO *btnPtr;
|
---|
663 | INT nRunIndex;
|
---|
664 |
|
---|
665 | if ((nIndex < 0) || (nIndex > infoPtr->nNumButtons))
|
---|
666 | return -1;
|
---|
667 |
|
---|
668 | /* check index button */
|
---|
669 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
670 | if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
|
---|
671 | if (btnPtr->fsState & TBSTATE_CHECKED)
|
---|
672 | return nIndex;
|
---|
673 | }
|
---|
674 |
|
---|
675 | /* check previous buttons */
|
---|
676 | nRunIndex = nIndex - 1;
|
---|
677 | while (nRunIndex >= 0) {
|
---|
678 | btnPtr = &infoPtr->buttons[nRunIndex];
|
---|
679 | if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
|
---|
680 | if (btnPtr->fsState & TBSTATE_CHECKED)
|
---|
681 | return nRunIndex;
|
---|
682 | }
|
---|
683 | else
|
---|
684 | break;
|
---|
685 | nRunIndex--;
|
---|
686 | }
|
---|
687 |
|
---|
688 | /* check next buttons */
|
---|
689 | nRunIndex = nIndex + 1;
|
---|
690 | while (nRunIndex < infoPtr->nNumButtons) {
|
---|
691 | btnPtr = &infoPtr->buttons[nRunIndex];
|
---|
692 | if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
|
---|
693 | if (btnPtr->fsState & TBSTATE_CHECKED)
|
---|
694 | return nRunIndex;
|
---|
695 | }
|
---|
696 | else
|
---|
697 | break;
|
---|
698 | nRunIndex++;
|
---|
699 | }
|
---|
700 |
|
---|
701 | return -1;
|
---|
702 | }
|
---|
703 |
|
---|
704 |
|
---|
705 | static VOID
|
---|
706 | TOOLBAR_RelayEvent (HWND hwndTip, HWND hwndMsg, UINT uMsg,
|
---|
707 | WPARAM wParam, LPARAM lParam)
|
---|
708 | {
|
---|
709 | MSG msg;
|
---|
710 |
|
---|
711 | msg.hwnd = hwndMsg;
|
---|
712 | msg.message = uMsg;
|
---|
713 | msg.wParam = wParam;
|
---|
714 | msg.lParam = lParam;
|
---|
715 | msg.time = GetMessageTime();
|
---|
716 | msg.pt.x = LOWORD(GetMessagePos());
|
---|
717 | msg.pt.y = HIWORD(GetMessagePos());
|
---|
718 |
|
---|
719 | SendMessageA(hwndTip,TTM_RELAYEVENT,0,(LPARAM)&msg);
|
---|
720 | }
|
---|
721 |
|
---|
722 | static void TBCUSTOMIZE_GetToolNameA(TOOLBAR_INFO* infoPtr,TBUTTON_INFO* btnPtr,INT pos)
|
---|
723 | {
|
---|
724 | if (btnPtr->iString > -1 && btnPtr->iString < infoPtr->nNumStrings)
|
---|
725 | {
|
---|
726 | if (!btnPtr->pszName) btnPtr->pszName = COMCTL32_Alloc(MAXTOOLNAME*sizeof(WCHAR));
|
---|
727 | lstrcpynW(btnPtr->pszName,infoPtr->strings[btnPtr->iString],MAXTOOLNAME*sizeof(WCHAR));
|
---|
728 |
|
---|
729 | return;
|
---|
730 | }
|
---|
731 |
|
---|
732 | if (btnPtr->fsStyle & TBSTYLE_SEP)
|
---|
733 | {
|
---|
734 | if (!btnPtr->pszName) btnPtr->pszName = COMCTL32_Alloc(MAXTOOLNAME*sizeof(WCHAR));
|
---|
735 | lstrcpyAtoW(btnPtr->pszName,"Separator");
|
---|
736 | } else
|
---|
737 | {
|
---|
738 | TBNOTIFYA tbNotify;
|
---|
739 |
|
---|
740 | tbNotify.hdr.hwndFrom = infoPtr->hwndToolbar;
|
---|
741 | tbNotify.hdr.idFrom = GetWindowLongA(infoPtr->hwndToolbar,GWL_ID);
|
---|
742 | tbNotify.hdr.code = TBN_GETBUTTONINFOA;
|
---|
743 | tbNotify.iItem = pos;
|
---|
744 | tbNotify.tbButton = (TBBUTTON*)btnPtr;
|
---|
745 | tbNotify.cchText = MAXTOOLNAME;
|
---|
746 | tbNotify.pszText = COMCTL32_Alloc(MAXTOOLNAME);
|
---|
747 | tbNotify.pszText[0] = 0;
|
---|
748 |
|
---|
749 | if (!SendMessageA(infoPtr->hwndNotify,WM_NOTIFY,(WPARAM)tbNotify.hdr.idFrom,(LPARAM)&tbNotify))
|
---|
750 | { //CB: failed, try other methods
|
---|
751 | if (infoPtr->hwndToolTip)
|
---|
752 | { //try to get tool tip text
|
---|
753 | TTTOOLINFOA ti;
|
---|
754 |
|
---|
755 | ZeroMemory (&ti,sizeof(ti));
|
---|
756 | ti.cbSize = sizeof(ti);
|
---|
757 | ti.hwnd = infoPtr->hwndToolbar;
|
---|
758 | ti.uId = btnPtr->idCommand;
|
---|
759 | ti.hinst = 0;
|
---|
760 | ti.lpszText = COMCTL32_Alloc(INFOTIPSIZE);
|
---|
761 | ti.lpszText[0] = 0;
|
---|
762 |
|
---|
763 | SendMessageA(infoPtr->hwndToolTip,TTM_GETTEXTA,0,(LPARAM)&ti);
|
---|
764 | if (ti.lpszText[0] != 0) lstrcpynA(tbNotify.pszText,ti.lpszText,MAXTOOLNAME);
|
---|
765 | else strcpy(tbNotify.pszText,"Button");
|
---|
766 |
|
---|
767 | COMCTL32_Free(ti.lpszText);
|
---|
768 |
|
---|
769 | } else strcpy(tbNotify.pszText,"Button");
|
---|
770 | }
|
---|
771 |
|
---|
772 | if (!btnPtr->pszName) btnPtr->pszName = COMCTL32_Alloc(MAXTOOLNAME*sizeof(WCHAR));
|
---|
773 | lstrcpyAtoW(btnPtr->pszName,tbNotify.pszText);
|
---|
774 | COMCTL32_Free(tbNotify.pszText);
|
---|
775 | }
|
---|
776 | }
|
---|
777 |
|
---|
778 | static void TBCUSTOMIZE_GetToolNameW(TOOLBAR_INFO* infoPtr,TBUTTON_INFO* btnPtr,INT pos)
|
---|
779 | {
|
---|
780 | if (btnPtr->iString > -1 && btnPtr->iString < infoPtr->nNumStrings)
|
---|
781 | {
|
---|
782 | if (!btnPtr->pszName) btnPtr->pszName = COMCTL32_Alloc(MAXTOOLNAME*sizeof(WCHAR));
|
---|
783 | lstrcpynW(btnPtr->pszName,infoPtr->strings[btnPtr->iString],MAXTOOLNAME*sizeof(WCHAR));
|
---|
784 |
|
---|
785 | return;
|
---|
786 | }
|
---|
787 |
|
---|
788 | if (btnPtr->fsStyle & TBSTYLE_SEP)
|
---|
789 | {
|
---|
790 | if (!btnPtr->pszName) btnPtr->pszName = COMCTL32_Alloc(MAXTOOLNAME*sizeof(WCHAR));
|
---|
791 | lstrcpyAtoW(btnPtr->pszName,"Separator");
|
---|
792 | } else
|
---|
793 | {
|
---|
794 | TBNOTIFYW tbNotify;
|
---|
795 |
|
---|
796 | if (!btnPtr->pszName) btnPtr->pszName = COMCTL32_Alloc(MAXTOOLNAME*sizeof(WCHAR));
|
---|
797 | btnPtr->pszName[0] = 0;
|
---|
798 |
|
---|
799 | tbNotify.hdr.hwndFrom = infoPtr->hwndToolbar;
|
---|
800 | tbNotify.hdr.idFrom = GetWindowLongA(infoPtr->hwndToolbar,GWL_ID);
|
---|
801 | tbNotify.hdr.code = TBN_GETBUTTONINFOW;
|
---|
802 | tbNotify.iItem = pos;
|
---|
803 | tbNotify.tbButton = (TBBUTTON*)btnPtr;
|
---|
804 | tbNotify.cchText = MAXTOOLNAME;
|
---|
805 | tbNotify.pszText = btnPtr->pszName;
|
---|
806 |
|
---|
807 | if (!SendMessageW(infoPtr->hwndNotify,WM_NOTIFY,(WPARAM)tbNotify.hdr.idFrom,(LPARAM)&tbNotify))
|
---|
808 | { //CB: failed, try other methods
|
---|
809 | if (infoPtr->hwndToolTip)
|
---|
810 | { //try to get tool tip text
|
---|
811 | TTTOOLINFOW ti;
|
---|
812 |
|
---|
813 | ZeroMemory (&ti,sizeof(ti));
|
---|
814 | ti.cbSize = sizeof(ti);
|
---|
815 | ti.hwnd = infoPtr->hwndToolbar;
|
---|
816 | ti.uId = btnPtr->idCommand;
|
---|
817 | ti.hinst = 0;
|
---|
818 | ti.lpszText = COMCTL32_Alloc(INFOTIPSIZE*sizeof(WCHAR));
|
---|
819 | ti.lpszText[0] = 0;
|
---|
820 |
|
---|
821 | SendMessageA(infoPtr->hwndToolTip,TTM_GETTEXTW,0,(LPARAM)&ti);
|
---|
822 | if (ti.lpszText[0] != 0) lstrcpynW(btnPtr->pszName,ti.lpszText,MAXTOOLNAME);
|
---|
823 | else lstrcpyAtoW(btnPtr->pszName,"Button");
|
---|
824 |
|
---|
825 | COMCTL32_Free(ti.lpszText);
|
---|
826 |
|
---|
827 | } else lstrcpyAtoW(btnPtr->pszName,"Button");
|
---|
828 | }
|
---|
829 | }
|
---|
830 | }
|
---|
831 |
|
---|
832 | static VOID TBCUSTOMIZE_AvailSelChange(HWND hwnd);
|
---|
833 | static VOID TBCUSTOMIZE_VisSelChange(HWND hwnd);
|
---|
834 |
|
---|
835 | static BOOL TBCUSTOMIZE_FillData(HWND hwnd,TOOLBAR_INFO* infoPtr)
|
---|
836 | {
|
---|
837 | TBUTTON_INFO* btnPtr;
|
---|
838 | INT i;
|
---|
839 | INT leftCount = 0;
|
---|
840 | INT rightCount = 0;
|
---|
841 | INT nItem;
|
---|
842 |
|
---|
843 | SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_RESETCONTENT,0,0);
|
---|
844 | SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_RESETCONTENT,0,0);
|
---|
845 |
|
---|
846 | /* insert 'virtual' separator button into 'available buttons' list */
|
---|
847 | nItem = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_ADDSTRING,0,(LPARAM)"Separator");
|
---|
848 | SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_SETITEMDATA,nItem,0);
|
---|
849 |
|
---|
850 | /* copy all buttons and append them to the listboxes */
|
---|
851 | btnPtr = infoPtr->buttons;
|
---|
852 | for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++)
|
---|
853 | {
|
---|
854 | if (IsWindowUnicode(infoPtr->hwndNotify))
|
---|
855 | {
|
---|
856 | TBNOTIFYW tbNotify;
|
---|
857 |
|
---|
858 | tbNotify.hdr.hwndFrom = infoPtr->hwndToolbar;
|
---|
859 | tbNotify.hdr.idFrom = GetWindowLongA(infoPtr->hwndToolbar,GWL_ID);
|
---|
860 | tbNotify.iItem = i;
|
---|
861 | tbNotify.tbButton = (TBBUTTON*)btnPtr;
|
---|
862 | tbNotify.cchText = 0;
|
---|
863 | tbNotify.pszText = NULL;
|
---|
864 |
|
---|
865 | // send TBN_QUERYINSERT notification
|
---|
866 |
|
---|
867 | tbNotify.hdr.code = TBN_QUERYINSERT;
|
---|
868 |
|
---|
869 | if (!SendMessageW(infoPtr->hwndNotify,WM_NOTIFY,(WPARAM)tbNotify.hdr.idFrom,(LPARAM)&tbNotify)) continue;
|
---|
870 |
|
---|
871 | // send TBN_QUERYDELETE notification
|
---|
872 |
|
---|
873 | tbNotify.hdr.code = TBN_QUERYDELETE;
|
---|
874 |
|
---|
875 | btnPtr->bDelete = (BOOL)SendMessageW(infoPtr->hwndNotify,WM_NOTIFY,(WPARAM)tbNotify.hdr.idFrom,(LPARAM)&tbNotify);
|
---|
876 |
|
---|
877 | //get tool name
|
---|
878 |
|
---|
879 | TBCUSTOMIZE_GetToolNameW(infoPtr,btnPtr,i);
|
---|
880 |
|
---|
881 | } else
|
---|
882 | {
|
---|
883 | TBNOTIFYA tbNotify;
|
---|
884 |
|
---|
885 | tbNotify.hdr.hwndFrom = infoPtr->hwndToolbar;
|
---|
886 | tbNotify.hdr.idFrom = GetWindowLongA(infoPtr->hwndToolbar,GWL_ID);
|
---|
887 | tbNotify.iItem = i;
|
---|
888 | tbNotify.tbButton = (TBBUTTON*)btnPtr;
|
---|
889 | tbNotify.cchText = 0;
|
---|
890 | tbNotify.pszText = NULL;
|
---|
891 |
|
---|
892 | // send TBN_QUERYINSERT notification
|
---|
893 |
|
---|
894 | tbNotify.hdr.code = TBN_QUERYINSERT;
|
---|
895 |
|
---|
896 | if (!SendMessageA(infoPtr->hwndNotify,WM_NOTIFY,(WPARAM)tbNotify.hdr.idFrom,(LPARAM)&tbNotify)) continue;
|
---|
897 |
|
---|
898 | // send TBN_QUERYDELETE notification
|
---|
899 |
|
---|
900 | tbNotify.hdr.code = TBN_QUERYDELETE;
|
---|
901 |
|
---|
902 | btnPtr->bDelete = (BOOL)SendMessageA(infoPtr->hwndNotify,WM_NOTIFY,(WPARAM)tbNotify.hdr.idFrom,(LPARAM)&tbNotify);
|
---|
903 |
|
---|
904 | //get tool name
|
---|
905 |
|
---|
906 | TBCUSTOMIZE_GetToolNameA(infoPtr,btnPtr,i);
|
---|
907 | }
|
---|
908 |
|
---|
909 | if (btnPtr->fsState & TBSTATE_HIDDEN)
|
---|
910 | {
|
---|
911 | nItem = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_ADDSTRING,0,(LPARAM)"");
|
---|
912 | SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_SETITEMDATA,nItem,btnPtr->nCustomID);
|
---|
913 | leftCount++;
|
---|
914 | } else
|
---|
915 | {
|
---|
916 | nItem = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_ADDSTRING,0,(LPARAM)"");
|
---|
917 | SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETITEMDATA,nItem,btnPtr->nCustomID);
|
---|
918 | rightCount++;
|
---|
919 | }
|
---|
920 | }
|
---|
921 |
|
---|
922 | if (leftCount == 0 && rightCount == 0) return FALSE;
|
---|
923 |
|
---|
924 | SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_SETCURSEL,0,0);
|
---|
925 | SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETCURSEL,(rightCount > 0) ? 0:(WPARAM)-1,0);
|
---|
926 |
|
---|
927 | TBCUSTOMIZE_AvailSelChange(hwnd);
|
---|
928 | TBCUSTOMIZE_VisSelChange(hwnd);
|
---|
929 |
|
---|
930 | return TRUE;
|
---|
931 | }
|
---|
932 |
|
---|
933 | static BOOL TBCUSTOMIZE_InitDialog(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
934 | {
|
---|
935 | TOOLBAR_INFO* infoPtr;
|
---|
936 |
|
---|
937 | infoPtr = (TOOLBAR_INFO*)lParam;
|
---|
938 | SetWindowLongA(hwnd,DWL_USER,(DWORD)infoPtr);
|
---|
939 |
|
---|
940 | if (infoPtr)
|
---|
941 | {
|
---|
942 | INT x;
|
---|
943 |
|
---|
944 | //custom ID: 1-nNumButtons, 0 == new separator
|
---|
945 | for (x = 0;x < infoPtr->nNumButtons;x++)
|
---|
946 | {
|
---|
947 | infoPtr->buttons[x].nCustomID = x+1;
|
---|
948 | infoPtr->buttons[x].pszName = NULL;
|
---|
949 | }
|
---|
950 | infoPtr->nMaxCustomID = infoPtr->nNumButtons;
|
---|
951 |
|
---|
952 | //save tools
|
---|
953 | infoPtr->nNumOldButtons = infoPtr->nNumButtons;
|
---|
954 | infoPtr->oldButtons = COMCTL32_Alloc(infoPtr->nNumOldButtons*sizeof(TBUTTON_INFO));
|
---|
955 | memcpy(&infoPtr->oldButtons[0],&infoPtr->buttons[0],infoPtr->nNumOldButtons*sizeof(TBUTTON_INFO));
|
---|
956 |
|
---|
957 | if (!TBCUSTOMIZE_FillData(hwnd,infoPtr)) EndDialog(hwnd,FALSE);
|
---|
958 | }
|
---|
959 |
|
---|
960 | return TRUE;
|
---|
961 | }
|
---|
962 |
|
---|
963 | static BOOL TBCUSTOMIZE_Close(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
964 | {
|
---|
965 | EndDialog(hwnd,FALSE);
|
---|
966 |
|
---|
967 | return TRUE;
|
---|
968 | }
|
---|
969 |
|
---|
970 | static VOID TBCUSTOMIZE_Reset(HWND hwnd)
|
---|
971 | {
|
---|
972 | TOOLBAR_INFO* infoPtr = (TOOLBAR_INFO*)GetWindowLongA(hwnd,DWL_USER);
|
---|
973 | NMHDR nmhdr;
|
---|
974 | INT x;
|
---|
975 |
|
---|
976 | //Send TBN_RESET
|
---|
977 | nmhdr.hwndFrom = infoPtr->hwndToolbar;
|
---|
978 | nmhdr.idFrom = GetWindowLongA(infoPtr->hwndToolbar,GWL_ID);
|
---|
979 | nmhdr.code = TBN_RESET;
|
---|
980 |
|
---|
981 | SendMessageA(infoPtr->hwndNotify,WM_NOTIFY,(WPARAM)nmhdr.idFrom,(LPARAM)&nmhdr);
|
---|
982 |
|
---|
983 | for (x = 0;x < infoPtr->nNumOldButtons;x++) COMCTL32_Free(infoPtr->oldButtons[x].pszName);
|
---|
984 |
|
---|
985 | //restore data
|
---|
986 | if (infoPtr->nNumButtons != infoPtr->nNumOldButtons)
|
---|
987 | {
|
---|
988 | COMCTL32_Free(infoPtr->buttons);
|
---|
989 | infoPtr->nNumButtons = infoPtr->nNumOldButtons;
|
---|
990 | infoPtr->buttons = COMCTL32_Alloc(infoPtr->nNumButtons*sizeof(TBUTTON_INFO));
|
---|
991 | }
|
---|
992 | memcpy(&infoPtr->buttons[0],&infoPtr->oldButtons[0],infoPtr->nNumButtons*sizeof(TBUTTON_INFO));
|
---|
993 |
|
---|
994 | if (!TBCUSTOMIZE_FillData(hwnd,infoPtr)) EndDialog(hwnd,FALSE);
|
---|
995 |
|
---|
996 | TOOLBAR_CalcToolbar(infoPtr->hwndToolbar);
|
---|
997 | InvalidateRect(infoPtr->hwndToolbar,NULL,TRUE);
|
---|
998 | }
|
---|
999 |
|
---|
1000 | static TBUTTON_INFO* TBCUSTOMIZE_GetBtnPtr(TOOLBAR_INFO* infoPtr,INT customID)
|
---|
1001 | {
|
---|
1002 | INT x;
|
---|
1003 | TBUTTON_INFO* btnPtr = infoPtr->buttons;
|
---|
1004 |
|
---|
1005 | if (customID == 0) return NULL;
|
---|
1006 |
|
---|
1007 | for (x = 0;x < infoPtr->nNumButtons;btnPtr++)
|
---|
1008 | if (btnPtr->nCustomID == customID) return btnPtr;
|
---|
1009 |
|
---|
1010 | return NULL;
|
---|
1011 | }
|
---|
1012 |
|
---|
1013 | static VOID TBCUSTOMIZE_AddTool(HWND hwnd)
|
---|
1014 | {
|
---|
1015 | TOOLBAR_INFO* infoPtr = (TOOLBAR_INFO*)GetWindowLongA(hwnd,DWL_USER);
|
---|
1016 | LRESULT pos,count;
|
---|
1017 | INT customID;
|
---|
1018 | TBUTTON_INFO* btnPtr;
|
---|
1019 | LRESULT rightSel,rightCount,rightPos;
|
---|
1020 |
|
---|
1021 | pos = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_GETCURSEL,0,0);
|
---|
1022 | if (pos == (LRESULT)-1) return;
|
---|
1023 |
|
---|
1024 | count = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_GETCOUNT,0,0);
|
---|
1025 |
|
---|
1026 | customID = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_GETITEMDATA,pos,0);
|
---|
1027 | if (customID == 0) btnPtr = NULL; else
|
---|
1028 | {
|
---|
1029 | btnPtr = TBCUSTOMIZE_GetBtnPtr(infoPtr,customID);
|
---|
1030 | if (btnPtr == NULL) return;
|
---|
1031 |
|
---|
1032 | SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_DELETESTRING,pos,0);
|
---|
1033 | }
|
---|
1034 |
|
---|
1035 | rightSel = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETCURSEL,0,0);
|
---|
1036 | rightCount = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETCOUNT,0,0);
|
---|
1037 |
|
---|
1038 | if (rightSel != (LRESULT)-1)
|
---|
1039 | rightPos = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_INSERTSTRING,rightSel,(LPARAM)"");
|
---|
1040 | else
|
---|
1041 | rightPos = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_ADDSTRING,0,(LPARAM)"");
|
---|
1042 | if (!btnPtr)
|
---|
1043 | { //new separator
|
---|
1044 | TBUTTON_INFO* newButtons;
|
---|
1045 |
|
---|
1046 | newButtons = COMCTL32_Alloc((infoPtr->nNumButtons+1)*sizeof(TBUTTON_INFO));
|
---|
1047 | memcpy(&newButtons[0],&infoPtr->buttons[0],infoPtr->nNumButtons*sizeof(TBUTTON_INFO));
|
---|
1048 | COMCTL32_Free(infoPtr->buttons);
|
---|
1049 |
|
---|
1050 | infoPtr->buttons = newButtons;
|
---|
1051 | infoPtr->nNumButtons++;
|
---|
1052 |
|
---|
1053 | btnPtr = &infoPtr->buttons[infoPtr->nNumButtons-1];
|
---|
1054 | ZeroMemory(btnPtr,sizeof(TBUTTON_INFO));
|
---|
1055 | btnPtr->fsStyle = TBSTYLE_SEP;
|
---|
1056 | btnPtr->bDelete = TRUE;
|
---|
1057 |
|
---|
1058 | customID = ++infoPtr->nMaxCustomID;
|
---|
1059 | btnPtr->nCustomID = customID;
|
---|
1060 | SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETITEMDATA,rightPos,customID);
|
---|
1061 | } else
|
---|
1062 | {
|
---|
1063 | SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETITEMDATA,rightPos,customID);
|
---|
1064 | btnPtr->fsState &= ~TBSTATE_HIDDEN;
|
---|
1065 | }
|
---|
1066 | SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETCURSEL,rightPos,0);
|
---|
1067 | TBCUSTOMIZE_VisSelChange(hwnd);
|
---|
1068 |
|
---|
1069 | if (rightCount > 0)
|
---|
1070 | { //change order
|
---|
1071 | TBUTTON_INFO* btnPtr2;
|
---|
1072 | INT customID2,pos1,pos2;
|
---|
1073 |
|
---|
1074 | pos1 = 0;
|
---|
1075 | while (infoPtr->buttons[pos1].nCustomID != customID) pos1++;
|
---|
1076 | if (rightPos < rightCount)
|
---|
1077 | { //insert before
|
---|
1078 | customID2 = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETITEMDATA,rightPos+1,0);
|
---|
1079 | pos2 = 0;
|
---|
1080 | while (infoPtr->buttons[pos2].nCustomID != customID2) pos2++;
|
---|
1081 | } else
|
---|
1082 | { //insert behind
|
---|
1083 | INT x;
|
---|
1084 |
|
---|
1085 | customID2 = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETITEMDATA,rightPos-1,0);
|
---|
1086 | pos2 = 0;
|
---|
1087 | while (infoPtr->buttons[pos2].nCustomID != customID2) pos2++;
|
---|
1088 | //exchange to use first alogrithm
|
---|
1089 | x = pos1;
|
---|
1090 | pos1 = pos2;
|
---|
1091 | pos2 = x;
|
---|
1092 | }
|
---|
1093 |
|
---|
1094 | if (pos1+1 != pos2)
|
---|
1095 | {
|
---|
1096 | TBUTTON_INFO temp;
|
---|
1097 | INT x;
|
---|
1098 |
|
---|
1099 | memcpy(&temp,&infoPtr->buttons[pos1],sizeof(TBUTTON_INFO));
|
---|
1100 | if (pos1 < pos2)
|
---|
1101 | {
|
---|
1102 | for (x = pos1;x < pos2;x++)
|
---|
1103 | memcpy(&infoPtr->buttons[x],&infoPtr->buttons[x+1],sizeof(TBUTTON_INFO));
|
---|
1104 | memcpy(&infoPtr->buttons[pos2-1],&temp,sizeof(TBUTTON_INFO));
|
---|
1105 | } else
|
---|
1106 | {
|
---|
1107 | for (x = pos1-1;x >= pos2;x--)
|
---|
1108 | memcpy(&infoPtr->buttons[x+1],&infoPtr->buttons[x],sizeof(TBUTTON_INFO));
|
---|
1109 | memcpy(&infoPtr->buttons[pos2],&temp,sizeof(TBUTTON_INFO));
|
---|
1110 | }
|
---|
1111 | }
|
---|
1112 | }
|
---|
1113 |
|
---|
1114 | if (pos == count-1 && pos > 0) pos--;
|
---|
1115 | SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_SETCURSEL,pos,0);
|
---|
1116 | TBCUSTOMIZE_AvailSelChange(hwnd);
|
---|
1117 |
|
---|
1118 | TOOLBAR_CalcToolbar(infoPtr->hwndToolbar);
|
---|
1119 | InvalidateRect(infoPtr->hwndToolbar,NULL,TRUE);
|
---|
1120 | }
|
---|
1121 |
|
---|
1122 | static VOID TBCUSTOMIZE_RemoveTool(HWND hwnd)
|
---|
1123 | {
|
---|
1124 | TOOLBAR_INFO* infoPtr = (TOOLBAR_INFO*)GetWindowLongA(hwnd,DWL_USER);
|
---|
1125 | LRESULT pos,count;
|
---|
1126 | INT customID;
|
---|
1127 | TBUTTON_INFO* btnPtr;
|
---|
1128 |
|
---|
1129 | pos = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETCURSEL,0,0);
|
---|
1130 | if (pos == (LRESULT)-1) return;
|
---|
1131 |
|
---|
1132 | count = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETCOUNT,0,0);
|
---|
1133 |
|
---|
1134 | customID = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETITEMDATA,pos,0);
|
---|
1135 | if (customID == 0) return; //no allowed
|
---|
1136 |
|
---|
1137 | btnPtr = TBCUSTOMIZE_GetBtnPtr(infoPtr,customID);
|
---|
1138 | if (btnPtr == NULL || !btnPtr->bDelete) return;
|
---|
1139 |
|
---|
1140 | SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_DELETESTRING,pos,0);
|
---|
1141 |
|
---|
1142 | if (btnPtr->fsStyle & TBSTYLE_SEP)
|
---|
1143 | { //remove separator
|
---|
1144 | TBUTTON_INFO* newButtons;
|
---|
1145 | INT nIndex,x;
|
---|
1146 |
|
---|
1147 | //find pos
|
---|
1148 | for (x = 0;x < infoPtr->nNumButtons;x++) if (&infoPtr->buttons[x] == btnPtr)
|
---|
1149 | {
|
---|
1150 | nIndex = x;
|
---|
1151 | break;
|
---|
1152 | }
|
---|
1153 |
|
---|
1154 | infoPtr->nNumButtons--;
|
---|
1155 | newButtons = COMCTL32_Alloc(infoPtr->nNumButtons*sizeof(TBUTTON_INFO));
|
---|
1156 |
|
---|
1157 | if (nIndex > 0)
|
---|
1158 | memcpy(&newButtons[0],&infoPtr->buttons[0],nIndex*sizeof(TBUTTON_INFO));
|
---|
1159 |
|
---|
1160 | if (nIndex < infoPtr->nNumButtons)
|
---|
1161 | memcpy (&newButtons[nIndex],&infoPtr->buttons[nIndex+1],(infoPtr->nNumButtons-nIndex)*sizeof(TBUTTON_INFO));
|
---|
1162 |
|
---|
1163 | COMCTL32_Free(infoPtr->buttons);
|
---|
1164 | infoPtr->buttons = newButtons;
|
---|
1165 | } else
|
---|
1166 | {
|
---|
1167 | LRESULT leftSel,leftCount,leftPos;
|
---|
1168 |
|
---|
1169 | leftSel = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_GETCURSEL,0,0);
|
---|
1170 | leftCount = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_GETCOUNT,0,0);
|
---|
1171 |
|
---|
1172 | if (leftSel == 0)
|
---|
1173 | if (leftCount > 1) leftSel++; else leftSel = -1;
|
---|
1174 |
|
---|
1175 | if (leftSel != (LRESULT)-1)
|
---|
1176 | leftPos = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_INSERTSTRING,leftSel,(LPARAM)"");
|
---|
1177 | else
|
---|
1178 | leftPos = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_ADDSTRING,0,(LPARAM)"");
|
---|
1179 | SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_SETITEMDATA,leftPos,customID);
|
---|
1180 |
|
---|
1181 | SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_SETCURSEL,leftPos,0);
|
---|
1182 | TBCUSTOMIZE_AvailSelChange(hwnd);
|
---|
1183 |
|
---|
1184 | btnPtr->fsState |= TBSTATE_HIDDEN;
|
---|
1185 |
|
---|
1186 | if (leftCount > 1)
|
---|
1187 | { //change order
|
---|
1188 | TBUTTON_INFO* btnPtr2;
|
---|
1189 | INT customID2,pos1,pos2;
|
---|
1190 |
|
---|
1191 | pos1 = 0;
|
---|
1192 | while (infoPtr->buttons[pos1].nCustomID != customID) pos1++;
|
---|
1193 | if (leftPos < leftCount)
|
---|
1194 | { //insert before
|
---|
1195 | customID2 = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_GETITEMDATA,leftPos+1,0);
|
---|
1196 | pos2 = 0;
|
---|
1197 | while (infoPtr->buttons[pos2].nCustomID != customID2) pos2++;
|
---|
1198 | } else
|
---|
1199 | { //insert behind
|
---|
1200 | INT x;
|
---|
1201 |
|
---|
1202 | customID2 = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_GETITEMDATA,leftPos-1,0);
|
---|
1203 | pos2 = 0;
|
---|
1204 | while (infoPtr->buttons[pos2].nCustomID != customID2) pos2++;
|
---|
1205 | //exchange to use first alogrithm
|
---|
1206 | x = pos1;
|
---|
1207 | pos1 = pos2;
|
---|
1208 | pos2 = x;
|
---|
1209 | }
|
---|
1210 |
|
---|
1211 | if (pos1+1 != pos2)
|
---|
1212 | {
|
---|
1213 | TBUTTON_INFO temp;
|
---|
1214 | INT x;
|
---|
1215 |
|
---|
1216 | memcpy(&temp,&infoPtr->buttons[pos1],sizeof(TBUTTON_INFO));
|
---|
1217 | if (pos1 < pos2)
|
---|
1218 | {
|
---|
1219 | for (x = pos1;x < pos2;x++)
|
---|
1220 | memcpy(&infoPtr->buttons[x],&infoPtr->buttons[x+1],sizeof(TBUTTON_INFO));
|
---|
1221 | memcpy(&infoPtr->buttons[pos2-1],&temp,sizeof(TBUTTON_INFO));
|
---|
1222 | } else
|
---|
1223 | {
|
---|
1224 | for (x = pos1-1;x >= pos2;x--)
|
---|
1225 | memcpy(&infoPtr->buttons[x+1],&infoPtr->buttons[x],sizeof(TBUTTON_INFO));
|
---|
1226 | memcpy(&infoPtr->buttons[pos2],&temp,sizeof(TBUTTON_INFO));
|
---|
1227 | }
|
---|
1228 | }
|
---|
1229 | }
|
---|
1230 | }
|
---|
1231 |
|
---|
1232 | if (pos == count-1) pos--;
|
---|
1233 | SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETCURSEL,pos,0);
|
---|
1234 | TBCUSTOMIZE_VisSelChange(hwnd);
|
---|
1235 |
|
---|
1236 | TOOLBAR_CalcToolbar(infoPtr->hwndToolbar);
|
---|
1237 | InvalidateRect(infoPtr->hwndToolbar,NULL,TRUE);
|
---|
1238 | }
|
---|
1239 |
|
---|
1240 | static VOID TBCUSTOMIZE_Help(HWND hwnd)
|
---|
1241 | {
|
---|
1242 | TOOLBAR_INFO* infoPtr = (TOOLBAR_INFO*)GetWindowLongA(hwnd,DWL_USER);
|
---|
1243 | NMHDR nmhdr;
|
---|
1244 |
|
---|
1245 | //Send TBN_CUSTHELP
|
---|
1246 | nmhdr.hwndFrom = infoPtr->hwndToolbar;
|
---|
1247 | nmhdr.idFrom = GetWindowLongA(infoPtr->hwndToolbar,GWL_ID);
|
---|
1248 | nmhdr.code = TBN_CUSTHELP;
|
---|
1249 |
|
---|
1250 | SendMessageA(infoPtr->hwndNotify,WM_NOTIFY,(WPARAM)nmhdr.idFrom,(LPARAM)&nmhdr);
|
---|
1251 | }
|
---|
1252 |
|
---|
1253 | static VOID TBCUSTOMIZE_MoveToolUp(HWND hwnd)
|
---|
1254 | {
|
---|
1255 | TOOLBAR_INFO* infoPtr = (TOOLBAR_INFO*)GetWindowLongA(hwnd,DWL_USER);
|
---|
1256 | LRESULT pos;
|
---|
1257 | TBUTTON_INFO button;
|
---|
1258 | INT customID;
|
---|
1259 | TBUTTON_INFO* btnPtr1,* btnPtr2;
|
---|
1260 |
|
---|
1261 | pos = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETCURSEL,0,0);
|
---|
1262 | if (pos == (LRESULT)-1 || pos == 0) return;
|
---|
1263 |
|
---|
1264 | //update listbox
|
---|
1265 |
|
---|
1266 | customID = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETITEMDATA,pos,0);
|
---|
1267 | btnPtr1 = TBCUSTOMIZE_GetBtnPtr(infoPtr,customID);
|
---|
1268 | if (btnPtr1 == NULL) return;
|
---|
1269 |
|
---|
1270 | customID = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETITEMDATA,pos-1,0);
|
---|
1271 | btnPtr2 = TBCUSTOMIZE_GetBtnPtr(infoPtr,customID);
|
---|
1272 | if (btnPtr2 == NULL) return;
|
---|
1273 |
|
---|
1274 | SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETITEMDATA,pos,btnPtr2->nCustomID);
|
---|
1275 | SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETITEMDATA,pos-1,btnPtr1->nCustomID);
|
---|
1276 |
|
---|
1277 | SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETCURSEL,pos-1,0);
|
---|
1278 | TBCUSTOMIZE_VisSelChange(hwnd);
|
---|
1279 |
|
---|
1280 | //update buttons
|
---|
1281 | memcpy(&button,btnPtr1,sizeof(TBUTTON_INFO));
|
---|
1282 | memcpy(btnPtr1,btnPtr2,sizeof(TBUTTON_INFO));
|
---|
1283 | memcpy(btnPtr2,&button,sizeof(TBUTTON_INFO));
|
---|
1284 |
|
---|
1285 | TOOLBAR_CalcToolbar(infoPtr->hwndToolbar);
|
---|
1286 | InvalidateRect(infoPtr->hwndToolbar,NULL,TRUE);
|
---|
1287 | }
|
---|
1288 |
|
---|
1289 | static VOID TBCUSTOMIZE_MoveToolDown(HWND hwnd)
|
---|
1290 | {
|
---|
1291 | TOOLBAR_INFO* infoPtr = (TOOLBAR_INFO*)GetWindowLongA(hwnd,DWL_USER);
|
---|
1292 | LRESULT pos,count;
|
---|
1293 | TBUTTON_INFO button;
|
---|
1294 | INT customID;
|
---|
1295 | TBUTTON_INFO* btnPtr1,* btnPtr2;
|
---|
1296 |
|
---|
1297 | pos = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETCURSEL,0,0);
|
---|
1298 | if (pos == (LRESULT)-1) return;
|
---|
1299 |
|
---|
1300 | count = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETCOUNT,0,0);
|
---|
1301 | if (pos == count-1) return;
|
---|
1302 |
|
---|
1303 | //update listbox
|
---|
1304 |
|
---|
1305 | customID = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETITEMDATA,pos,0);
|
---|
1306 | btnPtr1 = TBCUSTOMIZE_GetBtnPtr(infoPtr,customID);
|
---|
1307 | if (btnPtr1 == NULL) return;
|
---|
1308 |
|
---|
1309 | customID = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETITEMDATA,pos+1,0);
|
---|
1310 | btnPtr2 = TBCUSTOMIZE_GetBtnPtr(infoPtr,customID);
|
---|
1311 | if (btnPtr2 == NULL) return;
|
---|
1312 |
|
---|
1313 | SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETITEMDATA,pos,btnPtr2->nCustomID);
|
---|
1314 | SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETITEMDATA,pos+1,btnPtr1->nCustomID);
|
---|
1315 |
|
---|
1316 | SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETCURSEL,pos+1,0);
|
---|
1317 | TBCUSTOMIZE_VisSelChange(hwnd);
|
---|
1318 |
|
---|
1319 | //update buttons
|
---|
1320 | memcpy(&button,btnPtr1,sizeof(TBUTTON_INFO));
|
---|
1321 | memcpy(btnPtr1,btnPtr2,sizeof(TBUTTON_INFO));
|
---|
1322 | memcpy(btnPtr2,&button,sizeof(TBUTTON_INFO));
|
---|
1323 |
|
---|
1324 | TOOLBAR_CalcToolbar(infoPtr->hwndToolbar);
|
---|
1325 | InvalidateRect(infoPtr->hwndToolbar,NULL,TRUE);
|
---|
1326 | }
|
---|
1327 |
|
---|
1328 | static VOID TBCUSTOMIZE_AvailSelChange(HWND hwnd)
|
---|
1329 | {
|
---|
1330 | LRESULT pos;
|
---|
1331 | HWND hwndBtn;
|
---|
1332 |
|
---|
1333 | pos = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_GETCURSEL,0,0);
|
---|
1334 |
|
---|
1335 | hwndBtn = GetDlgItem(hwnd,IDOK);
|
---|
1336 | EnableWindow(hwndBtn,(pos == (LRESULT)-1) ? FALSE:TRUE);
|
---|
1337 | }
|
---|
1338 |
|
---|
1339 | static VOID TBCUSTOMIZE_VisSelChange(HWND hwnd)
|
---|
1340 | {
|
---|
1341 | TOOLBAR_INFO* infoPtr = (TOOLBAR_INFO*)GetWindowLongA(hwnd,DWL_USER);
|
---|
1342 | LRESULT pos;
|
---|
1343 |
|
---|
1344 | pos = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETCURSEL,0,0);
|
---|
1345 |
|
---|
1346 | if (pos == (LRESULT)-1)
|
---|
1347 | {
|
---|
1348 | EnableWindow(GetDlgItem(hwnd,IDC_REMOVE_BTN),FALSE);
|
---|
1349 | EnableWindow(GetDlgItem(hwnd,IDC_MOVEUP_BTN),FALSE);
|
---|
1350 | EnableWindow(GetDlgItem(hwnd,IDC_MOVEDN_BTN),FALSE);
|
---|
1351 | } else
|
---|
1352 | {
|
---|
1353 | INT customID;
|
---|
1354 | TBUTTON_INFO* btnPtr;
|
---|
1355 | LRESULT count;
|
---|
1356 |
|
---|
1357 | customID = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETITEMDATA,pos,0);
|
---|
1358 | btnPtr = TBCUSTOMIZE_GetBtnPtr(infoPtr,customID);
|
---|
1359 | count = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETCOUNT,0,0);
|
---|
1360 |
|
---|
1361 | if (btnPtr)
|
---|
1362 | EnableWindow(GetDlgItem(hwnd,IDC_REMOVE_BTN),btnPtr->bDelete);
|
---|
1363 | else
|
---|
1364 | EnableWindow(GetDlgItem(hwnd,IDC_REMOVE_BTN),TRUE);
|
---|
1365 | EnableWindow(GetDlgItem(hwnd,IDC_MOVEUP_BTN),!(pos == 0));
|
---|
1366 | EnableWindow(GetDlgItem(hwnd,IDC_MOVEDN_BTN),!(pos == count-1));
|
---|
1367 | }
|
---|
1368 | }
|
---|
1369 |
|
---|
1370 | static BOOL TBCUSTOMIZE_Command(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
1371 | {
|
---|
1372 | switch(LOWORD(wParam))
|
---|
1373 | {
|
---|
1374 | case IDCANCEL:
|
---|
1375 | EndDialog(hwnd,FALSE);
|
---|
1376 | break;
|
---|
1377 | case IDC_RESET_BTN:
|
---|
1378 | TBCUSTOMIZE_Reset(hwnd);
|
---|
1379 | break;
|
---|
1380 | case IDOK: //== add tool
|
---|
1381 | TBCUSTOMIZE_AddTool(hwnd);
|
---|
1382 | break;
|
---|
1383 | case IDC_REMOVE_BTN:
|
---|
1384 | TBCUSTOMIZE_RemoveTool(hwnd);
|
---|
1385 | break;
|
---|
1386 | case IDC_HELP_BTN:
|
---|
1387 | TBCUSTOMIZE_Help(hwnd);
|
---|
1388 | break;
|
---|
1389 | case IDC_MOVEUP_BTN:
|
---|
1390 | TBCUSTOMIZE_MoveToolUp(hwnd);
|
---|
1391 | break;
|
---|
1392 | case IDC_MOVEDN_BTN:
|
---|
1393 | TBCUSTOMIZE_MoveToolDown(hwnd);
|
---|
1394 | break;
|
---|
1395 | case IDC_AVAILBTN_LBOX:
|
---|
1396 | switch(HIWORD(wParam))
|
---|
1397 | {
|
---|
1398 | case LBN_SELCHANGE:
|
---|
1399 | TBCUSTOMIZE_AvailSelChange(hwnd);
|
---|
1400 | break;
|
---|
1401 | case LBN_DBLCLK:
|
---|
1402 | TBCUSTOMIZE_AddTool(hwnd);
|
---|
1403 | break;
|
---|
1404 | }
|
---|
1405 | break;
|
---|
1406 | case IDC_TOOLBARBTN_LBOX:
|
---|
1407 | switch(HIWORD(wParam))
|
---|
1408 | {
|
---|
1409 | case LBN_SELCHANGE:
|
---|
1410 | TBCUSTOMIZE_VisSelChange(hwnd);
|
---|
1411 | break;
|
---|
1412 | case LBN_DBLCLK:
|
---|
1413 | TBCUSTOMIZE_RemoveTool(hwnd);
|
---|
1414 | break;
|
---|
1415 | }
|
---|
1416 | break;
|
---|
1417 | }
|
---|
1418 |
|
---|
1419 | return TRUE;
|
---|
1420 | }
|
---|
1421 |
|
---|
1422 | static BOOL TBCUSTOMIZE_Destroy(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
1423 | {
|
---|
1424 | TOOLBAR_INFO* infoPtr = (TOOLBAR_INFO*)GetWindowLongA(hwnd,DWL_USER);
|
---|
1425 | INT x;
|
---|
1426 |
|
---|
1427 | for (x = 0;x < infoPtr->nNumOldButtons;x++)
|
---|
1428 | COMCTL32_Free(infoPtr->oldButtons[x].pszName);
|
---|
1429 | COMCTL32_Free(infoPtr->oldButtons);
|
---|
1430 | infoPtr->oldButtons = NULL;
|
---|
1431 | infoPtr->nNumOldButtons = 0;
|
---|
1432 |
|
---|
1433 | return TRUE;
|
---|
1434 | }
|
---|
1435 |
|
---|
1436 | static BOOL TBCUSTOMIZE_DrawItem(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
1437 | {
|
---|
1438 | if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX)
|
---|
1439 | {
|
---|
1440 | TOOLBAR_INFO* infoPtr = (TOOLBAR_INFO*)GetWindowLongA(hwnd,DWL_USER);
|
---|
1441 | LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
|
---|
1442 | RECT rcButton;
|
---|
1443 | RECT rcText;
|
---|
1444 | HPEN hOldPen;
|
---|
1445 | HBRUSH hOldBrush;
|
---|
1446 | COLORREF oldText = 0;
|
---|
1447 | COLORREF oldBk = 0;
|
---|
1448 | INT customID;
|
---|
1449 | TBUTTON_INFO* btnPtr;
|
---|
1450 | DWORD dwStyle = GetWindowLongA(infoPtr->hwndToolbar,GWL_STYLE);
|
---|
1451 |
|
---|
1452 | customID = SendDlgItemMessageA(hwnd,wParam,LB_GETITEMDATA,lpdis->itemID,0);
|
---|
1453 | btnPtr = TBCUSTOMIZE_GetBtnPtr(infoPtr,customID);
|
---|
1454 |
|
---|
1455 | if (btnPtr != NULL && !btnPtr->bDelete)
|
---|
1456 | {
|
---|
1457 | if (lpdis->itemState & ODS_FOCUS) oldBk = SetBkColor(lpdis->hDC,GetSysColor(COLOR_HIGHLIGHT));
|
---|
1458 | oldText = SetTextColor(lpdis->hDC,GetSysColor(COLOR_GRAYTEXT));
|
---|
1459 | } else if (lpdis->itemState & ODS_FOCUS)
|
---|
1460 | {
|
---|
1461 | oldBk = SetBkColor (lpdis->hDC, GetSysColor(COLOR_HIGHLIGHT));
|
---|
1462 | oldText = SetTextColor (lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
|
---|
1463 | }
|
---|
1464 |
|
---|
1465 |
|
---|
1466 | hOldPen = SelectObject (lpdis->hDC, GetSysColorPen ((lpdis->itemState & ODS_SELECTED)?COLOR_HIGHLIGHT:COLOR_WINDOW));
|
---|
1467 | hOldBrush = SelectObject (lpdis->hDC, GetSysColorBrush ((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW));
|
---|
1468 |
|
---|
1469 | /* fill background rectangle */
|
---|
1470 | Rectangle (lpdis->hDC,lpdis->rcItem.left,lpdis->rcItem.top,lpdis->rcItem.right,lpdis->rcItem.bottom);
|
---|
1471 |
|
---|
1472 | /* calculate button and text rectangles */
|
---|
1473 | CopyRect (&rcButton, &lpdis->rcItem);
|
---|
1474 | InflateRect (&rcButton, -1, -1);
|
---|
1475 | CopyRect (&rcText, &rcButton);
|
---|
1476 | rcButton.right = rcButton.left + infoPtr->nBitmapWidth + 6;
|
---|
1477 | rcText.left = rcButton.right + 2;
|
---|
1478 |
|
---|
1479 | /* draw focus rectangle */
|
---|
1480 | if (lpdis->itemState & ODS_FOCUS) DrawFocusRect (lpdis->hDC, &lpdis->rcItem);
|
---|
1481 |
|
---|
1482 | //draw tool
|
---|
1483 | if (btnPtr && !(btnPtr->fsStyle & TBSTYLE_SEP))
|
---|
1484 | {
|
---|
1485 | //draw button
|
---|
1486 | if (dwStyle & TBSTYLE_FLAT)
|
---|
1487 | {
|
---|
1488 | ImageList_Draw(infoPtr->himlDef,btnPtr->iBitmap,lpdis->hDC,rcButton.left+2,rcButton.top+2,ILD_NORMAL);
|
---|
1489 | } else
|
---|
1490 | {
|
---|
1491 | DrawEdge (lpdis->hDC,&rcButton,EDGE_RAISED,BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
|
---|
1492 |
|
---|
1493 | ImageList_Draw(infoPtr->himlDef,btnPtr->iBitmap,lpdis->hDC,rcButton.left+1,rcButton.top+1,ILD_NORMAL);
|
---|
1494 | }
|
---|
1495 |
|
---|
1496 | } else
|
---|
1497 | { //draw separator
|
---|
1498 | if (!(dwStyle & TBSTYLE_FLAT))
|
---|
1499 | DrawEdge (lpdis->hDC,&rcButton,EDGE_RAISED,BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
|
---|
1500 |
|
---|
1501 | TOOLBAR_DrawFlatSeparator(&rcButton,lpdis->hDC);
|
---|
1502 | }
|
---|
1503 |
|
---|
1504 | /* draw text */
|
---|
1505 | if (btnPtr == NULL)
|
---|
1506 | { //new separator
|
---|
1507 | DrawTextA(lpdis->hDC,"Separator",-1,&rcText,DT_LEFT | DT_VCENTER | DT_SINGLELINE);
|
---|
1508 | } else if (btnPtr->pszName != NULL)
|
---|
1509 | {
|
---|
1510 | DrawTextW(lpdis->hDC,btnPtr->pszName,-1,&rcText,DT_LEFT | DT_VCENTER | DT_SINGLELINE);
|
---|
1511 | }
|
---|
1512 |
|
---|
1513 | if (lpdis->itemState & ODS_FOCUS)
|
---|
1514 | {
|
---|
1515 | SetBkColor (lpdis->hDC, oldBk);
|
---|
1516 | SetTextColor (lpdis->hDC, oldText);
|
---|
1517 | }
|
---|
1518 |
|
---|
1519 | SelectObject (lpdis->hDC, hOldBrush);
|
---|
1520 | SelectObject (lpdis->hDC, hOldPen);
|
---|
1521 |
|
---|
1522 | return TRUE;
|
---|
1523 | }
|
---|
1524 |
|
---|
1525 | return FALSE;
|
---|
1526 | }
|
---|
1527 |
|
---|
1528 | static BOOL TBCUSTOMIZE_MeasureItem(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
1529 | {
|
---|
1530 | if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX)
|
---|
1531 | {
|
---|
1532 | TOOLBAR_INFO* infoPtr = (TOOLBAR_INFO*)GetWindowLongA(hwnd,DWL_USER);
|
---|
1533 | MEASUREITEMSTRUCT *lpmis = (MEASUREITEMSTRUCT*)lParam;
|
---|
1534 |
|
---|
1535 | if (infoPtr)
|
---|
1536 | {
|
---|
1537 | DWORD dwStyle = GetWindowLongA(infoPtr->hwndToolbar,GWL_STYLE);
|
---|
1538 |
|
---|
1539 | if (dwStyle & TBSTYLE_FLAT)
|
---|
1540 | lpmis->itemHeight = infoPtr->nBitmapHeight+4;
|
---|
1541 | else
|
---|
1542 | lpmis->itemHeight = infoPtr->nBitmapHeight+8;
|
---|
1543 | } else lpmis->itemHeight = 16+8;
|
---|
1544 |
|
---|
1545 | return TRUE;
|
---|
1546 | }
|
---|
1547 |
|
---|
1548 | return FALSE;
|
---|
1549 | }
|
---|
1550 |
|
---|
1551 | /***********************************************************************
|
---|
1552 | * TOOLBAR_CustomizeDialogProc
|
---|
1553 | * This function implements the toolbar customization dialog.
|
---|
1554 | */
|
---|
1555 | static BOOL WINAPI
|
---|
1556 | TOOLBAR_CustomizeDialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
---|
1557 | {
|
---|
1558 | TOOLBAR_INFO *infoPtr;
|
---|
1559 |
|
---|
1560 | switch (uMsg)
|
---|
1561 | {
|
---|
1562 | case WM_INITDIALOG:
|
---|
1563 | return TBCUSTOMIZE_InitDialog(hwnd,wParam,lParam);
|
---|
1564 |
|
---|
1565 | case WM_CLOSE:
|
---|
1566 | return TBCUSTOMIZE_Close(hwnd,wParam,lParam);
|
---|
1567 |
|
---|
1568 | case WM_COMMAND:
|
---|
1569 | return TBCUSTOMIZE_Command(hwnd,wParam,lParam);
|
---|
1570 |
|
---|
1571 | case WM_DESTROY:
|
---|
1572 | return TBCUSTOMIZE_Destroy(hwnd,wParam,lParam);
|
---|
1573 |
|
---|
1574 | case WM_DRAWITEM:
|
---|
1575 | return TBCUSTOMIZE_DrawItem(hwnd,wParam,lParam);
|
---|
1576 |
|
---|
1577 | case WM_MEASUREITEM:
|
---|
1578 | return TBCUSTOMIZE_MeasureItem(hwnd,wParam,lParam);
|
---|
1579 |
|
---|
1580 | default:
|
---|
1581 | return FALSE;
|
---|
1582 | }
|
---|
1583 | }
|
---|
1584 |
|
---|
1585 |
|
---|
1586 | /***********************************************************************
|
---|
1587 | * TOOLBAR_AddBitmap: Add the bitmaps to the default image list.
|
---|
1588 | *
|
---|
1589 | */
|
---|
1590 | static LRESULT
|
---|
1591 | TOOLBAR_AddBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1592 | {
|
---|
1593 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1594 | LPTBADDBITMAP lpAddBmp = (LPTBADDBITMAP)lParam;
|
---|
1595 | INT nIndex = 0,nButtons;
|
---|
1596 | HBITMAP hbmLoad;
|
---|
1597 |
|
---|
1598 | if (!lpAddBmp)
|
---|
1599 | return -1;
|
---|
1600 |
|
---|
1601 | if (lpAddBmp->hInst == HINST_COMMCTRL)
|
---|
1602 | {
|
---|
1603 | if ((lpAddBmp->nID & ~1) == IDB_STD_SMALL_COLOR)
|
---|
1604 | nButtons = 15;
|
---|
1605 | else if ((lpAddBmp->nID & ~1) == IDB_VIEW_SMALL_COLOR)
|
---|
1606 | nButtons = 13;
|
---|
1607 | else if ((lpAddBmp->nID & ~1) == IDB_HIST_SMALL_COLOR)
|
---|
1608 | nButtons = 5;
|
---|
1609 | else
|
---|
1610 | return -1;
|
---|
1611 |
|
---|
1612 | // TRACE ("adding %d internal bitmaps!\n", nButtons);
|
---|
1613 |
|
---|
1614 | /* Windows resize all the buttons to the size of a newly added standard Image*/
|
---|
1615 | if (lpAddBmp->nID & 1)
|
---|
1616 | {
|
---|
1617 | /* large icons */
|
---|
1618 | SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
|
---|
1619 | MAKELPARAM((WORD)26, (WORD)26));
|
---|
1620 | SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
|
---|
1621 | MAKELPARAM((WORD)33, (WORD)33));
|
---|
1622 | }
|
---|
1623 | else
|
---|
1624 | {
|
---|
1625 | /* small icons */
|
---|
1626 | SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
|
---|
1627 | MAKELPARAM((WORD)16, (WORD)16));
|
---|
1628 | SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
|
---|
1629 | MAKELPARAM((WORD)22, (WORD)22));
|
---|
1630 | }
|
---|
1631 |
|
---|
1632 | TOOLBAR_CalcToolbar (hwnd);
|
---|
1633 | }
|
---|
1634 | else
|
---|
1635 | {
|
---|
1636 | nButtons = (INT)wParam;
|
---|
1637 | if (nButtons <= 0)
|
---|
1638 | return -1;
|
---|
1639 |
|
---|
1640 | // TRACE ("adding %d bitmaps!\n", nButtons);
|
---|
1641 | }
|
---|
1642 |
|
---|
1643 | if (!(infoPtr->himlDef)) {
|
---|
1644 | /* create new default image list */
|
---|
1645 | // TRACE ("creating default image list!\n");
|
---|
1646 |
|
---|
1647 | infoPtr->himlDef =
|
---|
1648 | ImageList_Create (infoPtr->nBitmapWidth, infoPtr->nBitmapHeight,
|
---|
1649 | ILC_COLOR | ILC_MASK, nButtons, 2);
|
---|
1650 | infoPtr->himlInt = infoPtr->himlDef;
|
---|
1651 | }
|
---|
1652 |
|
---|
1653 | /* Add bitmaps to the default image list */
|
---|
1654 | if (lpAddBmp->hInst == (HINSTANCE)0)
|
---|
1655 | {
|
---|
1656 | nIndex =
|
---|
1657 | ImageList_AddMasked (infoPtr->himlDef, (HBITMAP)lpAddBmp->nID,
|
---|
1658 | CLR_DEFAULT);
|
---|
1659 | }
|
---|
1660 | else if (lpAddBmp->hInst == HINST_COMMCTRL)
|
---|
1661 | {
|
---|
1662 | /* Add system bitmaps */
|
---|
1663 | switch (lpAddBmp->nID)
|
---|
1664 | {
|
---|
1665 | case IDB_STD_SMALL_COLOR:
|
---|
1666 | hbmLoad = LoadBitmapA (COMCTL32_hModule,
|
---|
1667 | MAKEINTRESOURCEA(IDB_STD_SMALL));
|
---|
1668 | nIndex = ImageList_AddMasked (infoPtr->himlDef,
|
---|
1669 | hbmLoad, CLR_DEFAULT);
|
---|
1670 | DeleteObject (hbmLoad);
|
---|
1671 | break;
|
---|
1672 |
|
---|
1673 | case IDB_STD_LARGE_COLOR:
|
---|
1674 | hbmLoad = LoadBitmapA (COMCTL32_hModule,
|
---|
1675 | MAKEINTRESOURCEA(IDB_STD_LARGE));
|
---|
1676 | nIndex = ImageList_AddMasked (infoPtr->himlDef,
|
---|
1677 | hbmLoad, CLR_DEFAULT);
|
---|
1678 | DeleteObject (hbmLoad);
|
---|
1679 | break;
|
---|
1680 |
|
---|
1681 | case IDB_VIEW_SMALL_COLOR:
|
---|
1682 | hbmLoad = LoadBitmapA (COMCTL32_hModule,
|
---|
1683 | MAKEINTRESOURCEA(IDB_VIEW_SMALL));
|
---|
1684 | nIndex = ImageList_AddMasked (infoPtr->himlDef,
|
---|
1685 | hbmLoad, CLR_DEFAULT);
|
---|
1686 | DeleteObject (hbmLoad);
|
---|
1687 | break;
|
---|
1688 |
|
---|
1689 | case IDB_VIEW_LARGE_COLOR:
|
---|
1690 | hbmLoad = LoadBitmapA (COMCTL32_hModule,
|
---|
1691 | MAKEINTRESOURCEA(IDB_VIEW_LARGE));
|
---|
1692 | nIndex = ImageList_AddMasked (infoPtr->himlDef,
|
---|
1693 | hbmLoad, CLR_DEFAULT);
|
---|
1694 | DeleteObject (hbmLoad);
|
---|
1695 | break;
|
---|
1696 |
|
---|
1697 | case IDB_HIST_SMALL_COLOR:
|
---|
1698 | hbmLoad = LoadBitmapA (COMCTL32_hModule,
|
---|
1699 | MAKEINTRESOURCEA(IDB_HIST_SMALL));
|
---|
1700 | nIndex = ImageList_AddMasked (infoPtr->himlDef,
|
---|
1701 | hbmLoad, CLR_DEFAULT);
|
---|
1702 | DeleteObject (hbmLoad);
|
---|
1703 | break;
|
---|
1704 |
|
---|
1705 | case IDB_HIST_LARGE_COLOR:
|
---|
1706 | hbmLoad = LoadBitmapA (COMCTL32_hModule,
|
---|
1707 | MAKEINTRESOURCEA(IDB_HIST_LARGE));
|
---|
1708 | nIndex = ImageList_AddMasked (infoPtr->himlDef,
|
---|
1709 | hbmLoad, CLR_DEFAULT);
|
---|
1710 | DeleteObject (hbmLoad);
|
---|
1711 | break;
|
---|
1712 |
|
---|
1713 | default:
|
---|
1714 | nIndex = ImageList_GetImageCount (infoPtr->himlDef);
|
---|
1715 | //ERR ("invalid imagelist!\n");
|
---|
1716 | break;
|
---|
1717 | }
|
---|
1718 | }
|
---|
1719 | else
|
---|
1720 | {
|
---|
1721 | hbmLoad = LoadBitmapA (lpAddBmp->hInst, (LPSTR)lpAddBmp->nID);
|
---|
1722 | nIndex = ImageList_AddMasked (infoPtr->himlDef, hbmLoad, CLR_DEFAULT);
|
---|
1723 | DeleteObject (hbmLoad);
|
---|
1724 | }
|
---|
1725 |
|
---|
1726 | infoPtr->nNumBitmaps += nButtons;
|
---|
1727 |
|
---|
1728 | return nIndex;
|
---|
1729 | }
|
---|
1730 |
|
---|
1731 |
|
---|
1732 | static LRESULT
|
---|
1733 | TOOLBAR_AddButtonsA (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1734 | {
|
---|
1735 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1736 | LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
|
---|
1737 | INT nOldButtons, nNewButtons, nAddButtons, nCount;
|
---|
1738 |
|
---|
1739 | // TRACE (toolbar, "adding %d buttons!\n", wParam);
|
---|
1740 |
|
---|
1741 | nAddButtons = (UINT)wParam;
|
---|
1742 | nOldButtons = infoPtr->nNumButtons;
|
---|
1743 | nNewButtons = nOldButtons+nAddButtons;
|
---|
1744 |
|
---|
1745 | if (infoPtr->nNumButtons == 0)
|
---|
1746 | {
|
---|
1747 | infoPtr->buttons = COMCTL32_Alloc(sizeof(TBUTTON_INFO)*nNewButtons);
|
---|
1748 | } else
|
---|
1749 | {
|
---|
1750 | TBUTTON_INFO* oldButtons = infoPtr->buttons;
|
---|
1751 |
|
---|
1752 | infoPtr->buttons = COMCTL32_Alloc(sizeof(TBUTTON_INFO)*nNewButtons);
|
---|
1753 | memcpy(&infoPtr->buttons[0], &oldButtons[0],nOldButtons * sizeof(TBUTTON_INFO));
|
---|
1754 | COMCTL32_Free(oldButtons);
|
---|
1755 | }
|
---|
1756 |
|
---|
1757 | infoPtr->nNumButtons = nNewButtons;
|
---|
1758 |
|
---|
1759 | /* insert new button data */
|
---|
1760 | for (nCount = 0; nCount < nAddButtons; nCount++)
|
---|
1761 | {
|
---|
1762 | TBUTTON_INFO* btnPtr = &infoPtr->buttons[nOldButtons+nCount];
|
---|
1763 |
|
---|
1764 | btnPtr->iBitmap = lpTbb[nCount].iBitmap;
|
---|
1765 | btnPtr->idCommand = lpTbb[nCount].idCommand;
|
---|
1766 | btnPtr->fsState = lpTbb[nCount].fsState;
|
---|
1767 | btnPtr->fsStyle = lpTbb[nCount].fsStyle;
|
---|
1768 | btnPtr->dwData = lpTbb[nCount].dwData;
|
---|
1769 | btnPtr->iString = lpTbb[nCount].iString;
|
---|
1770 | btnPtr->bHot = FALSE;
|
---|
1771 | btnPtr->bDelete = FALSE; //only used in customize
|
---|
1772 | btnPtr->pszName = NULL;
|
---|
1773 |
|
---|
1774 | if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP))
|
---|
1775 | {
|
---|
1776 | TTTOOLINFOA ti;
|
---|
1777 |
|
---|
1778 | ZeroMemory (&ti, sizeof(TTTOOLINFOA));
|
---|
1779 | ti.cbSize = sizeof (TTTOOLINFOA);
|
---|
1780 | ti.hwnd = hwnd;
|
---|
1781 | ti.uId = btnPtr->idCommand;
|
---|
1782 | ti.hinst = 0;
|
---|
1783 | ti.lpszText = LPSTR_TEXTCALLBACKA;
|
---|
1784 |
|
---|
1785 | SendMessageA (infoPtr->hwndToolTip,TTM_ADDTOOLA,0,(LPARAM)&ti);
|
---|
1786 | }
|
---|
1787 | }
|
---|
1788 |
|
---|
1789 | TOOLBAR_CalcToolbar(hwnd);
|
---|
1790 |
|
---|
1791 | InvalidateRect(hwnd,NULL,FALSE);
|
---|
1792 |
|
---|
1793 | return TRUE;
|
---|
1794 | }
|
---|
1795 |
|
---|
1796 |
|
---|
1797 | static LRESULT TOOLBAR_AddButtonsW(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
1798 | {
|
---|
1799 | //CB: just call AddButtonsA, no Unicode used?!?
|
---|
1800 |
|
---|
1801 | return TOOLBAR_AddButtonsA(hwnd,wParam,lParam);
|
---|
1802 | }
|
---|
1803 |
|
---|
1804 | /* << TOOLBAR_AddButtons32W >> */
|
---|
1805 |
|
---|
1806 |
|
---|
1807 | static LRESULT
|
---|
1808 | TOOLBAR_AddStringA (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1809 | {
|
---|
1810 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1811 | INT nIndex;
|
---|
1812 |
|
---|
1813 | if ((wParam) && (HIWORD(lParam) == 0)) {
|
---|
1814 | char szString[256];
|
---|
1815 | INT len;
|
---|
1816 | // TRACE (toolbar, "adding string from resource!\n");
|
---|
1817 |
|
---|
1818 | len = LoadStringA ((HINSTANCE)wParam, (UINT)lParam,
|
---|
1819 | szString, 256);
|
---|
1820 |
|
---|
1821 | // TRACE (toolbar, "len=%d \"%s\"\n", len, szString);
|
---|
1822 | nIndex = infoPtr->nNumStrings;
|
---|
1823 | if (infoPtr->nNumStrings == 0) {
|
---|
1824 | infoPtr->strings =
|
---|
1825 | COMCTL32_Alloc (sizeof(LPWSTR));
|
---|
1826 | }
|
---|
1827 | else {
|
---|
1828 | LPWSTR *oldStrings = infoPtr->strings;
|
---|
1829 | infoPtr->strings =
|
---|
1830 | COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
|
---|
1831 | memcpy (&infoPtr->strings[0], &oldStrings[0],
|
---|
1832 | sizeof(LPWSTR) * infoPtr->nNumStrings);
|
---|
1833 | COMCTL32_Free (oldStrings);
|
---|
1834 | }
|
---|
1835 |
|
---|
1836 | infoPtr->strings[infoPtr->nNumStrings] =
|
---|
1837 | COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
|
---|
1838 | lstrcpyAtoW (infoPtr->strings[infoPtr->nNumStrings], szString);
|
---|
1839 | infoPtr->nNumStrings++;
|
---|
1840 | }
|
---|
1841 | else {
|
---|
1842 | LPSTR p = (LPSTR)lParam;
|
---|
1843 | INT len;
|
---|
1844 |
|
---|
1845 | if (p == NULL)
|
---|
1846 | return -1;
|
---|
1847 | // TRACE (toolbar, "adding string(s) from array!\n");
|
---|
1848 | nIndex = infoPtr->nNumStrings;
|
---|
1849 | while (*p) {
|
---|
1850 | len = lstrlenA (p);
|
---|
1851 | // TRACE (toolbar, "len=%d \"%s\"\n", len, p);
|
---|
1852 |
|
---|
1853 | if (infoPtr->nNumStrings == 0) {
|
---|
1854 | infoPtr->strings =
|
---|
1855 | COMCTL32_Alloc (sizeof(LPWSTR));
|
---|
1856 | }
|
---|
1857 | else {
|
---|
1858 | LPWSTR *oldStrings = infoPtr->strings;
|
---|
1859 | infoPtr->strings =
|
---|
1860 | COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
|
---|
1861 | memcpy (&infoPtr->strings[0], &oldStrings[0],
|
---|
1862 | sizeof(LPWSTR) * infoPtr->nNumStrings);
|
---|
1863 | COMCTL32_Free (oldStrings);
|
---|
1864 | }
|
---|
1865 |
|
---|
1866 | infoPtr->strings[infoPtr->nNumStrings] =
|
---|
1867 | COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
|
---|
1868 | lstrcpyAtoW (infoPtr->strings[infoPtr->nNumStrings], p);
|
---|
1869 | infoPtr->nNumStrings++;
|
---|
1870 |
|
---|
1871 | p += (len+1);
|
---|
1872 | }
|
---|
1873 | }
|
---|
1874 |
|
---|
1875 | return nIndex;
|
---|
1876 | }
|
---|
1877 |
|
---|
1878 |
|
---|
1879 | static LRESULT
|
---|
1880 | TOOLBAR_AddStringW (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1881 | {
|
---|
1882 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1883 | INT nIndex;
|
---|
1884 |
|
---|
1885 | if ((wParam) && (HIWORD(lParam) == 0)) {
|
---|
1886 | WCHAR szString[256];
|
---|
1887 | INT len;
|
---|
1888 | // TRACE (toolbar, "adding string from resource!\n");
|
---|
1889 |
|
---|
1890 | len = LoadStringW ((HINSTANCE)wParam, (UINT)lParam,
|
---|
1891 | szString, 256);
|
---|
1892 |
|
---|
1893 | // TRACE (toolbar, "len=%d \"%s\"\n", len, debugstr_w(szString));
|
---|
1894 | nIndex = infoPtr->nNumStrings;
|
---|
1895 | if (infoPtr->nNumStrings == 0) {
|
---|
1896 | infoPtr->strings =
|
---|
1897 | COMCTL32_Alloc (sizeof(LPWSTR));
|
---|
1898 | }
|
---|
1899 | else {
|
---|
1900 | LPWSTR *oldStrings = infoPtr->strings;
|
---|
1901 | infoPtr->strings =
|
---|
1902 | COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
|
---|
1903 | memcpy (&infoPtr->strings[0], &oldStrings[0],
|
---|
1904 | sizeof(LPWSTR) * infoPtr->nNumStrings);
|
---|
1905 | COMCTL32_Free (oldStrings);
|
---|
1906 | }
|
---|
1907 |
|
---|
1908 | infoPtr->strings[infoPtr->nNumStrings] =
|
---|
1909 | COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
|
---|
1910 | lstrcpyW (infoPtr->strings[infoPtr->nNumStrings], szString);
|
---|
1911 | infoPtr->nNumStrings++;
|
---|
1912 | }
|
---|
1913 | else {
|
---|
1914 | LPWSTR p = (LPWSTR)lParam;
|
---|
1915 | INT len;
|
---|
1916 |
|
---|
1917 | if (p == NULL)
|
---|
1918 | return -1;
|
---|
1919 | // TRACE (toolbar, "adding string(s) from array!\n");
|
---|
1920 | nIndex = infoPtr->nNumStrings;
|
---|
1921 | while (*p) {
|
---|
1922 | len = lstrlenW (p);
|
---|
1923 | // TRACE (toolbar, "len=%d \"%s\"\n", len, debugstr_w(p));
|
---|
1924 |
|
---|
1925 | if (infoPtr->nNumStrings == 0) {
|
---|
1926 | infoPtr->strings =
|
---|
1927 | COMCTL32_Alloc (sizeof(LPWSTR));
|
---|
1928 | }
|
---|
1929 | else {
|
---|
1930 | LPWSTR *oldStrings = infoPtr->strings;
|
---|
1931 | infoPtr->strings =
|
---|
1932 | COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
|
---|
1933 | memcpy (&infoPtr->strings[0], &oldStrings[0],
|
---|
1934 | sizeof(LPWSTR) * infoPtr->nNumStrings);
|
---|
1935 | COMCTL32_Free (oldStrings);
|
---|
1936 | }
|
---|
1937 |
|
---|
1938 | infoPtr->strings[infoPtr->nNumStrings] =
|
---|
1939 | COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
|
---|
1940 | lstrcpyW (infoPtr->strings[infoPtr->nNumStrings], p);
|
---|
1941 | infoPtr->nNumStrings++;
|
---|
1942 |
|
---|
1943 | p += (len+1);
|
---|
1944 | }
|
---|
1945 | }
|
---|
1946 |
|
---|
1947 | return nIndex;
|
---|
1948 | }
|
---|
1949 |
|
---|
1950 |
|
---|
1951 | static LRESULT
|
---|
1952 | TOOLBAR_AutoSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1953 | {
|
---|
1954 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1955 | DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
|
---|
1956 | RECT parent_rect;
|
---|
1957 | HWND parent;
|
---|
1958 | /* INT32 x, y; */
|
---|
1959 | INT cx, cy;
|
---|
1960 | UINT uPosFlags = 0;
|
---|
1961 |
|
---|
1962 | // TRACE (toolbar, "resize forced!\n");
|
---|
1963 |
|
---|
1964 | parent = GetParent (hwnd);
|
---|
1965 | GetClientRect(parent, &parent_rect);
|
---|
1966 |
|
---|
1967 | if (dwStyle & CCS_NORESIZE) {
|
---|
1968 | uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
|
---|
1969 | cx = 0;
|
---|
1970 | cy = 0;
|
---|
1971 | }
|
---|
1972 | else {
|
---|
1973 | infoPtr->nWidth = parent_rect.right - parent_rect.left;
|
---|
1974 | TOOLBAR_CalcToolbar (hwnd);
|
---|
1975 | InvalidateRect( hwnd, NULL, TRUE );
|
---|
1976 | cy = infoPtr->nHeight;
|
---|
1977 | cx = infoPtr->nWidth;
|
---|
1978 | }
|
---|
1979 |
|
---|
1980 | if (dwStyle & CCS_NOPARENTALIGN)
|
---|
1981 | uPosFlags |= SWP_NOMOVE;
|
---|
1982 |
|
---|
1983 | if (!(dwStyle & CCS_NODIVIDER))
|
---|
1984 | cy += GetSystemMetrics(SM_CYEDGE);
|
---|
1985 |
|
---|
1986 | infoPtr->bAutoSize = TRUE;
|
---|
1987 | SetWindowPos (hwnd, HWND_TOP, parent_rect.left, parent_rect.top,
|
---|
1988 | cx, cy, uPosFlags);
|
---|
1989 |
|
---|
1990 | return 0;
|
---|
1991 | }
|
---|
1992 |
|
---|
1993 |
|
---|
1994 | static LRESULT
|
---|
1995 | TOOLBAR_ButtonCount (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1996 | {
|
---|
1997 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1998 |
|
---|
1999 | return infoPtr->nNumButtons;
|
---|
2000 | }
|
---|
2001 |
|
---|
2002 |
|
---|
2003 | static LRESULT
|
---|
2004 | TOOLBAR_ButtonStructSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2005 | {
|
---|
2006 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2007 |
|
---|
2008 | if (infoPtr == NULL) {
|
---|
2009 | // ERR (toolbar, "(0x%x, 0x%x, 0x%lx)\n", hwnd, wParam, lParam);
|
---|
2010 | // ERR (toolbar, "infoPtr == NULL!\n");
|
---|
2011 | return 0;
|
---|
2012 | }
|
---|
2013 |
|
---|
2014 | infoPtr->dwStructSize = (DWORD)wParam;
|
---|
2015 |
|
---|
2016 | return 0;
|
---|
2017 | }
|
---|
2018 |
|
---|
2019 |
|
---|
2020 | static LRESULT
|
---|
2021 | TOOLBAR_ChangeBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2022 | {
|
---|
2023 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2024 | TBUTTON_INFO *btnPtr;
|
---|
2025 | HDC hdc;
|
---|
2026 | INT nIndex;
|
---|
2027 |
|
---|
2028 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
2029 | if (nIndex == -1)
|
---|
2030 | return FALSE;
|
---|
2031 |
|
---|
2032 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
2033 | btnPtr->iBitmap = LOWORD(lParam);
|
---|
2034 |
|
---|
2035 | hdc = GetDC (hwnd);
|
---|
2036 | TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
|
---|
2037 | ReleaseDC (hwnd, hdc);
|
---|
2038 |
|
---|
2039 | return TRUE;
|
---|
2040 | }
|
---|
2041 |
|
---|
2042 |
|
---|
2043 | static LRESULT
|
---|
2044 | TOOLBAR_CheckButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2045 | {
|
---|
2046 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2047 | TBUTTON_INFO *btnPtr;
|
---|
2048 | HDC hdc;
|
---|
2049 | INT nIndex;
|
---|
2050 | INT nOldIndex = -1;
|
---|
2051 |
|
---|
2052 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
2053 | if (nIndex == -1)
|
---|
2054 | return FALSE;
|
---|
2055 |
|
---|
2056 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
2057 |
|
---|
2058 | if (!(btnPtr->fsStyle & TBSTYLE_CHECK))
|
---|
2059 | return FALSE;
|
---|
2060 |
|
---|
2061 | if (LOWORD(lParam) == FALSE)
|
---|
2062 | btnPtr->fsState &= ~TBSTATE_CHECKED;
|
---|
2063 | else {
|
---|
2064 | if (btnPtr->fsStyle & TBSTYLE_GROUP) {
|
---|
2065 | nOldIndex =
|
---|
2066 | TOOLBAR_GetCheckedGroupButtonIndex (infoPtr, nIndex);
|
---|
2067 | if (nOldIndex == nIndex)
|
---|
2068 | return 0;
|
---|
2069 | if (nOldIndex != -1)
|
---|
2070 | infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
|
---|
2071 | }
|
---|
2072 | btnPtr->fsState |= TBSTATE_CHECKED;
|
---|
2073 | }
|
---|
2074 |
|
---|
2075 | hdc = GetDC (hwnd);
|
---|
2076 | if (nOldIndex != -1)
|
---|
2077 | TOOLBAR_DrawButton (hwnd, &infoPtr->buttons[nOldIndex], hdc);
|
---|
2078 | TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
|
---|
2079 | ReleaseDC (hwnd, hdc);
|
---|
2080 |
|
---|
2081 | /* FIXME: Send a WM_NOTIFY?? */
|
---|
2082 |
|
---|
2083 | return TRUE;
|
---|
2084 | }
|
---|
2085 |
|
---|
2086 |
|
---|
2087 | static LRESULT
|
---|
2088 | TOOLBAR_CommandToIndex (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2089 | {
|
---|
2090 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2091 |
|
---|
2092 | return TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
2093 | }
|
---|
2094 |
|
---|
2095 | static LRESULT
|
---|
2096 | TOOLBAR_Customize (HWND hwnd)
|
---|
2097 | {
|
---|
2098 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2099 | LRESULT ret;
|
---|
2100 | LPCVOID template;
|
---|
2101 | HRSRC hRes;
|
---|
2102 | NMHDR nmhdr;
|
---|
2103 |
|
---|
2104 | if (infoPtr->nNumButtons == 0) return 0;
|
---|
2105 |
|
---|
2106 | /* send TBN_BEGINADJUST notification */
|
---|
2107 | nmhdr.hwndFrom = hwnd;
|
---|
2108 | nmhdr.idFrom = GetWindowLongA(hwnd,GWL_ID);
|
---|
2109 | nmhdr.code = TBN_BEGINADJUST;
|
---|
2110 |
|
---|
2111 | SendMessageA (infoPtr->hwndNotify,WM_NOTIFY,(WPARAM)nmhdr.idFrom,(LPARAM)&nmhdr);
|
---|
2112 |
|
---|
2113 | //load OS/2 dialog
|
---|
2114 |
|
---|
2115 | ret = NativeDlgBoxIP(COMCTL32_hModule,
|
---|
2116 | GetWindowLongA(hwnd,GWL_HINSTANCE),
|
---|
2117 | MAKEINTRESOURCEA(IDD_TBCUSTOMIZE),
|
---|
2118 | hwnd,
|
---|
2119 | (DLGPROC)TOOLBAR_CustomizeDialogProc,
|
---|
2120 | (LPARAM)infoPtr);
|
---|
2121 |
|
---|
2122 | if (ret == (INT)-1) ret = 0;
|
---|
2123 |
|
---|
2124 | /* //original WINE code
|
---|
2125 | if (!(hRes = FindResourceA (COMCTL32_hModule,
|
---|
2126 | MAKEINTRESOURCEA(IDD_TBCUSTOMIZE),
|
---|
2127 | RT_DIALOGA)))
|
---|
2128 | return FALSE;
|
---|
2129 |
|
---|
2130 | if(!(template = (LPVOID)LoadResource (COMCTL32_hModule, hRes)))
|
---|
2131 | return FALSE;
|
---|
2132 |
|
---|
2133 | ret = DialogBoxIndirectParamA (GetWindowLongA (hwnd, GWL_HINSTANCE),
|
---|
2134 | (LPDLGTEMPLATEA)template,
|
---|
2135 | hwnd,
|
---|
2136 | (DLGPROC)TOOLBAR_CustomizeDialogProc,
|
---|
2137 | (LPARAM)infoPtr);
|
---|
2138 | */
|
---|
2139 |
|
---|
2140 | /* send TBN_ENDADJUST notification */
|
---|
2141 | nmhdr.code = TBN_ENDADJUST;
|
---|
2142 |
|
---|
2143 | SendMessageA(infoPtr->hwndNotify,WM_NOTIFY,(WPARAM)nmhdr.idFrom,(LPARAM)&nmhdr);
|
---|
2144 |
|
---|
2145 | return ret;
|
---|
2146 | }
|
---|
2147 |
|
---|
2148 |
|
---|
2149 | static LRESULT
|
---|
2150 | TOOLBAR_DeleteButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2151 | {
|
---|
2152 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2153 | INT nIndex = (INT)wParam;
|
---|
2154 |
|
---|
2155 | if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
|
---|
2156 | return FALSE;
|
---|
2157 |
|
---|
2158 | if ((infoPtr->hwndToolTip) &&
|
---|
2159 | !(infoPtr->buttons[nIndex].fsStyle & TBSTYLE_SEP)) {
|
---|
2160 | TTTOOLINFOA ti;
|
---|
2161 |
|
---|
2162 | ZeroMemory (&ti, sizeof(TTTOOLINFOA));
|
---|
2163 | ti.cbSize = sizeof (TTTOOLINFOA);
|
---|
2164 | ti.hwnd = hwnd;
|
---|
2165 | ti.uId = infoPtr->buttons[nIndex].idCommand;
|
---|
2166 |
|
---|
2167 | SendMessageA (infoPtr->hwndToolTip, TTM_DELTOOLA, 0, (LPARAM)&ti);
|
---|
2168 | }
|
---|
2169 |
|
---|
2170 | COMCTL32_Free(infoPtr->buttons[nIndex].pszName);
|
---|
2171 |
|
---|
2172 | if (infoPtr->nNumButtons == 1)
|
---|
2173 | {
|
---|
2174 | // TRACE (toolbar, " simple delete!\n");
|
---|
2175 | COMCTL32_Free (infoPtr->buttons);
|
---|
2176 | infoPtr->buttons = NULL;
|
---|
2177 | infoPtr->nNumButtons = 0;
|
---|
2178 | } else
|
---|
2179 | {
|
---|
2180 | TBUTTON_INFO *oldButtons = infoPtr->buttons;
|
---|
2181 | // TRACE(toolbar, "complex delete! [nIndex=%d]\n", nIndex);
|
---|
2182 |
|
---|
2183 | infoPtr->nNumButtons--;
|
---|
2184 | infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
|
---|
2185 | if (nIndex > 0) {
|
---|
2186 | memcpy (&infoPtr->buttons[0], &oldButtons[0],
|
---|
2187 | nIndex * sizeof(TBUTTON_INFO));
|
---|
2188 | }
|
---|
2189 |
|
---|
2190 | if (nIndex < infoPtr->nNumButtons) {
|
---|
2191 | memcpy (&infoPtr->buttons[nIndex], &oldButtons[nIndex+1],
|
---|
2192 | (infoPtr->nNumButtons - nIndex) * sizeof(TBUTTON_INFO));
|
---|
2193 | }
|
---|
2194 |
|
---|
2195 | COMCTL32_Free (oldButtons);
|
---|
2196 | }
|
---|
2197 |
|
---|
2198 | TOOLBAR_CalcToolbar (hwnd);
|
---|
2199 |
|
---|
2200 | InvalidateRect (hwnd, NULL, TRUE);
|
---|
2201 |
|
---|
2202 | return TRUE;
|
---|
2203 | }
|
---|
2204 |
|
---|
2205 |
|
---|
2206 | static LRESULT
|
---|
2207 | TOOLBAR_EnableButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2208 | {
|
---|
2209 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2210 | TBUTTON_INFO *btnPtr;
|
---|
2211 | HDC hdc;
|
---|
2212 | INT nIndex;
|
---|
2213 |
|
---|
2214 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
2215 | if (nIndex == -1)
|
---|
2216 | return FALSE;
|
---|
2217 |
|
---|
2218 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
2219 | if (LOWORD(lParam) == FALSE)
|
---|
2220 | btnPtr->fsState &= ~(TBSTATE_ENABLED | TBSTATE_PRESSED);
|
---|
2221 | else
|
---|
2222 | btnPtr->fsState |= TBSTATE_ENABLED;
|
---|
2223 |
|
---|
2224 | hdc = GetDC (hwnd);
|
---|
2225 | TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
|
---|
2226 | ReleaseDC (hwnd, hdc);
|
---|
2227 |
|
---|
2228 | return TRUE;
|
---|
2229 | }
|
---|
2230 |
|
---|
2231 |
|
---|
2232 | /* << TOOLBAR_GetAnchorHighlight >> */
|
---|
2233 |
|
---|
2234 |
|
---|
2235 | static LRESULT
|
---|
2236 | TOOLBAR_GetBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2237 | {
|
---|
2238 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2239 | INT nIndex;
|
---|
2240 |
|
---|
2241 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
2242 | if (nIndex == -1)
|
---|
2243 | return -1;
|
---|
2244 |
|
---|
2245 | return infoPtr->buttons[nIndex].iBitmap;
|
---|
2246 | }
|
---|
2247 |
|
---|
2248 |
|
---|
2249 | static LRESULT
|
---|
2250 | TOOLBAR_GetBitmapFlags (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2251 | {
|
---|
2252 | return (GetDeviceCaps (0, LOGPIXELSX) >= 120) ? TBBF_LARGE : 0;
|
---|
2253 | }
|
---|
2254 |
|
---|
2255 |
|
---|
2256 | static LRESULT
|
---|
2257 | TOOLBAR_GetButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2258 | {
|
---|
2259 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2260 | LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
|
---|
2261 | INT nIndex = (INT)wParam;
|
---|
2262 | TBUTTON_INFO *btnPtr;
|
---|
2263 |
|
---|
2264 | if (infoPtr == NULL)
|
---|
2265 | return FALSE;
|
---|
2266 |
|
---|
2267 | if (lpTbb == NULL)
|
---|
2268 | return FALSE;
|
---|
2269 |
|
---|
2270 | if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
|
---|
2271 | return FALSE;
|
---|
2272 |
|
---|
2273 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
2274 | lpTbb->iBitmap = btnPtr->iBitmap;
|
---|
2275 | lpTbb->idCommand = btnPtr->idCommand;
|
---|
2276 | lpTbb->fsState = btnPtr->fsState;
|
---|
2277 | lpTbb->fsStyle = btnPtr->fsStyle;
|
---|
2278 | lpTbb->dwData = btnPtr->dwData;
|
---|
2279 | lpTbb->iString = btnPtr->iString;
|
---|
2280 |
|
---|
2281 | return TRUE;
|
---|
2282 | }
|
---|
2283 |
|
---|
2284 |
|
---|
2285 | static LRESULT
|
---|
2286 | TOOLBAR_GetButtonInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2287 | {
|
---|
2288 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2289 | LPTBBUTTONINFOA lpTbInfo = (LPTBBUTTONINFOA)lParam;
|
---|
2290 | TBUTTON_INFO *btnPtr;
|
---|
2291 | INT nIndex;
|
---|
2292 |
|
---|
2293 | if (infoPtr == NULL)
|
---|
2294 | return -1;
|
---|
2295 | if (lpTbInfo == NULL)
|
---|
2296 | return -1;
|
---|
2297 | if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOA))
|
---|
2298 | return -1;
|
---|
2299 |
|
---|
2300 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
2301 | if (nIndex == -1)
|
---|
2302 | return -1;
|
---|
2303 |
|
---|
2304 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
2305 |
|
---|
2306 | if (lpTbInfo->dwMask & TBIF_COMMAND)
|
---|
2307 | lpTbInfo->idCommand = btnPtr->idCommand;
|
---|
2308 | if (lpTbInfo->dwMask & TBIF_IMAGE)
|
---|
2309 | lpTbInfo->iImage = btnPtr->iBitmap;
|
---|
2310 | if (lpTbInfo->dwMask & TBIF_LPARAM)
|
---|
2311 | lpTbInfo->lParam = btnPtr->dwData;
|
---|
2312 | if (lpTbInfo->dwMask & TBIF_SIZE)
|
---|
2313 | lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left);
|
---|
2314 | if (lpTbInfo->dwMask & TBIF_STATE)
|
---|
2315 | lpTbInfo->fsState = btnPtr->fsState;
|
---|
2316 | if (lpTbInfo->dwMask & TBIF_STYLE)
|
---|
2317 | lpTbInfo->fsStyle = btnPtr->fsStyle;
|
---|
2318 | if (lpTbInfo->dwMask & TBIF_TEXT) {
|
---|
2319 | if ((btnPtr->iString >= 0) || (btnPtr->iString < infoPtr->nNumStrings))
|
---|
2320 | lstrcpynWtoA (lpTbInfo->pszText,
|
---|
2321 | infoPtr->strings[btnPtr->iString],
|
---|
2322 | lpTbInfo->cchText);
|
---|
2323 | }
|
---|
2324 |
|
---|
2325 | return nIndex;
|
---|
2326 | }
|
---|
2327 |
|
---|
2328 | static LRESULT TOOLBAR_GetButtonInfoW(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
2329 | {
|
---|
2330 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2331 | LPTBBUTTONINFOW lpTbInfo = (LPTBBUTTONINFOW)lParam;
|
---|
2332 | TBUTTON_INFO *btnPtr;
|
---|
2333 | INT nIndex;
|
---|
2334 |
|
---|
2335 | if (infoPtr == NULL)
|
---|
2336 | return -1;
|
---|
2337 | if (lpTbInfo == NULL)
|
---|
2338 | return -1;
|
---|
2339 | if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOW))
|
---|
2340 | return -1;
|
---|
2341 |
|
---|
2342 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
2343 | if (nIndex == -1)
|
---|
2344 | return -1;
|
---|
2345 |
|
---|
2346 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
2347 |
|
---|
2348 | if (lpTbInfo->dwMask & TBIF_COMMAND)
|
---|
2349 | lpTbInfo->idCommand = btnPtr->idCommand;
|
---|
2350 | if (lpTbInfo->dwMask & TBIF_IMAGE)
|
---|
2351 | lpTbInfo->iImage = btnPtr->iBitmap;
|
---|
2352 | if (lpTbInfo->dwMask & TBIF_LPARAM)
|
---|
2353 | lpTbInfo->lParam = btnPtr->dwData;
|
---|
2354 | if (lpTbInfo->dwMask & TBIF_SIZE)
|
---|
2355 | lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left);
|
---|
2356 | if (lpTbInfo->dwMask & TBIF_STATE)
|
---|
2357 | lpTbInfo->fsState = btnPtr->fsState;
|
---|
2358 | if (lpTbInfo->dwMask & TBIF_STYLE)
|
---|
2359 | lpTbInfo->fsStyle = btnPtr->fsStyle;
|
---|
2360 | if (lpTbInfo->dwMask & TBIF_TEXT) {
|
---|
2361 | if ((btnPtr->iString >= 0) || (btnPtr->iString < infoPtr->nNumStrings))
|
---|
2362 | lstrcpynW (lpTbInfo->pszText,
|
---|
2363 | infoPtr->strings[btnPtr->iString],
|
---|
2364 | lpTbInfo->cchText);
|
---|
2365 | }
|
---|
2366 |
|
---|
2367 | return nIndex;
|
---|
2368 | }
|
---|
2369 |
|
---|
2370 | /* << TOOLBAR_GetButtonInfo32W >> */
|
---|
2371 |
|
---|
2372 |
|
---|
2373 | static LRESULT
|
---|
2374 | TOOLBAR_GetButtonSize (HWND hwnd)
|
---|
2375 | {
|
---|
2376 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2377 |
|
---|
2378 | return MAKELONG((WORD)infoPtr->nButtonWidth,
|
---|
2379 | (WORD)infoPtr->nButtonHeight);
|
---|
2380 | }
|
---|
2381 |
|
---|
2382 |
|
---|
2383 | static LRESULT
|
---|
2384 | TOOLBAR_GetButtonTextA (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2385 | {
|
---|
2386 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2387 | INT nIndex, nStringIndex;
|
---|
2388 |
|
---|
2389 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
2390 | if (nIndex == -1)
|
---|
2391 | return -1;
|
---|
2392 |
|
---|
2393 | nStringIndex = infoPtr->buttons[nIndex].iString;
|
---|
2394 |
|
---|
2395 | // TRACE (toolbar, "index=%d stringIndex=%d\n", nIndex, nStringIndex);
|
---|
2396 |
|
---|
2397 | if ((nStringIndex < 0) || (nStringIndex >= infoPtr->nNumStrings))
|
---|
2398 | return -1;
|
---|
2399 |
|
---|
2400 | if (lParam == 0) return -1;
|
---|
2401 |
|
---|
2402 | lstrcpyWtoA ((LPSTR)lParam, infoPtr->strings[nStringIndex]);
|
---|
2403 |
|
---|
2404 | return lstrlenW (infoPtr->strings[nStringIndex]);
|
---|
2405 | }
|
---|
2406 |
|
---|
2407 | static LRESULT TOOLBAR_GetButtonTextW (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2408 | {
|
---|
2409 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2410 | INT nIndex, nStringIndex;
|
---|
2411 |
|
---|
2412 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
2413 | if (nIndex == -1)
|
---|
2414 | return -1;
|
---|
2415 |
|
---|
2416 | nStringIndex = infoPtr->buttons[nIndex].iString;
|
---|
2417 |
|
---|
2418 | // TRACE (toolbar, "index=%d stringIndex=%d\n", nIndex, nStringIndex);
|
---|
2419 |
|
---|
2420 | if ((nStringIndex < 0) || (nStringIndex >= infoPtr->nNumStrings))
|
---|
2421 | return -1;
|
---|
2422 |
|
---|
2423 | if (lParam == 0) return -1;
|
---|
2424 |
|
---|
2425 | lstrcpyW ((LPWSTR)lParam, infoPtr->strings[nStringIndex]);
|
---|
2426 |
|
---|
2427 | return lstrlenW (infoPtr->strings[nStringIndex]);
|
---|
2428 | }
|
---|
2429 |
|
---|
2430 | /* << TOOLBAR_GetButtonText32W >> */
|
---|
2431 | /* << TOOLBAR_GetColorScheme >> */
|
---|
2432 |
|
---|
2433 |
|
---|
2434 | static LRESULT
|
---|
2435 | TOOLBAR_GetDisabledImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2436 | {
|
---|
2437 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2438 |
|
---|
2439 | return (LRESULT)infoPtr->himlDis;
|
---|
2440 | }
|
---|
2441 |
|
---|
2442 |
|
---|
2443 | static LRESULT
|
---|
2444 | TOOLBAR_GetExtendedStyle (HWND hwnd)
|
---|
2445 | {
|
---|
2446 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2447 |
|
---|
2448 | return infoPtr->dwExStyle;
|
---|
2449 | }
|
---|
2450 |
|
---|
2451 |
|
---|
2452 | static LRESULT
|
---|
2453 | TOOLBAR_GetHotImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2454 | {
|
---|
2455 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2456 |
|
---|
2457 | return (LRESULT)infoPtr->himlHot;
|
---|
2458 | }
|
---|
2459 |
|
---|
2460 |
|
---|
2461 | /* << TOOLBAR_GetHotItem >> */
|
---|
2462 |
|
---|
2463 |
|
---|
2464 | static LRESULT
|
---|
2465 | TOOLBAR_GetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2466 | {
|
---|
2467 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2468 |
|
---|
2469 | return (LRESULT)infoPtr->himlDef;
|
---|
2470 | }
|
---|
2471 |
|
---|
2472 |
|
---|
2473 | /* << TOOLBAR_GetInsertMark >> */
|
---|
2474 | /* << TOOLBAR_GetInsertMarkColor >> */
|
---|
2475 |
|
---|
2476 |
|
---|
2477 | static LRESULT
|
---|
2478 | TOOLBAR_GetItemRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2479 | {
|
---|
2480 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2481 | TBUTTON_INFO *btnPtr;
|
---|
2482 | LPRECT lpRect;
|
---|
2483 | INT nIndex;
|
---|
2484 |
|
---|
2485 | if (infoPtr == NULL)
|
---|
2486 | return FALSE;
|
---|
2487 | nIndex = (INT)wParam;
|
---|
2488 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
2489 | if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
|
---|
2490 | return FALSE;
|
---|
2491 | lpRect = (LPRECT)lParam;
|
---|
2492 | if (lpRect == NULL)
|
---|
2493 | return FALSE;
|
---|
2494 | if (btnPtr->fsState & TBSTATE_HIDDEN)
|
---|
2495 | return FALSE;
|
---|
2496 |
|
---|
2497 | TOOLBAR_CalcToolbar( hwnd );
|
---|
2498 |
|
---|
2499 | lpRect->left = btnPtr->rect.left;
|
---|
2500 | lpRect->right = btnPtr->rect.right;
|
---|
2501 | lpRect->bottom = btnPtr->rect.bottom;
|
---|
2502 | lpRect->top = btnPtr->rect.top;
|
---|
2503 |
|
---|
2504 | return TRUE;
|
---|
2505 | }
|
---|
2506 |
|
---|
2507 |
|
---|
2508 | static LRESULT
|
---|
2509 | TOOLBAR_GetMaxSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2510 | {
|
---|
2511 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2512 | LPSIZE lpSize = (LPSIZE)lParam;
|
---|
2513 |
|
---|
2514 | if (lpSize == NULL)
|
---|
2515 | return FALSE;
|
---|
2516 |
|
---|
2517 | lpSize->cx = infoPtr->rcBound.right - infoPtr->rcBound.left;
|
---|
2518 | lpSize->cy = infoPtr->rcBound.bottom - infoPtr->rcBound.top;
|
---|
2519 |
|
---|
2520 | // TRACE (toolbar, "maximum size %d x %d\n",
|
---|
2521 | // infoPtr->rcBound.right - infoPtr->rcBound.left,
|
---|
2522 | // infoPtr->rcBound.bottom - infoPtr->rcBound.top);
|
---|
2523 |
|
---|
2524 | return TRUE;
|
---|
2525 | }
|
---|
2526 |
|
---|
2527 |
|
---|
2528 | /* << TOOLBAR_GetObject >> */
|
---|
2529 | /* << TOOLBAR_GetPadding >> */
|
---|
2530 |
|
---|
2531 |
|
---|
2532 | static LRESULT
|
---|
2533 | TOOLBAR_GetRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2534 | {
|
---|
2535 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2536 | TBUTTON_INFO *btnPtr;
|
---|
2537 | LPRECT lpRect;
|
---|
2538 | INT nIndex;
|
---|
2539 |
|
---|
2540 | if (infoPtr == NULL)
|
---|
2541 | return FALSE;
|
---|
2542 | nIndex = (INT)wParam;
|
---|
2543 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
2544 | if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
|
---|
2545 | return FALSE;
|
---|
2546 | lpRect = (LPRECT)lParam;
|
---|
2547 | if (lpRect == NULL)
|
---|
2548 | return FALSE;
|
---|
2549 |
|
---|
2550 | lpRect->left = btnPtr->rect.left;
|
---|
2551 | lpRect->right = btnPtr->rect.right;
|
---|
2552 | lpRect->bottom = btnPtr->rect.bottom;
|
---|
2553 | lpRect->top = btnPtr->rect.top;
|
---|
2554 |
|
---|
2555 | return TRUE;
|
---|
2556 | }
|
---|
2557 |
|
---|
2558 |
|
---|
2559 | static LRESULT
|
---|
2560 | TOOLBAR_GetRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2561 | {
|
---|
2562 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2563 |
|
---|
2564 | if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_WRAPABLE)
|
---|
2565 | return infoPtr->nRows;
|
---|
2566 | else
|
---|
2567 | return 1;
|
---|
2568 | }
|
---|
2569 |
|
---|
2570 |
|
---|
2571 | static LRESULT
|
---|
2572 | TOOLBAR_GetState (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2573 | {
|
---|
2574 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2575 | INT nIndex;
|
---|
2576 |
|
---|
2577 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
2578 | if (nIndex == -1)
|
---|
2579 | return -1;
|
---|
2580 |
|
---|
2581 | return infoPtr->buttons[nIndex].fsState;
|
---|
2582 | }
|
---|
2583 |
|
---|
2584 |
|
---|
2585 | static LRESULT
|
---|
2586 | TOOLBAR_GetStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2587 | {
|
---|
2588 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2589 | INT nIndex;
|
---|
2590 |
|
---|
2591 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
2592 | if (nIndex == -1)
|
---|
2593 | return -1;
|
---|
2594 |
|
---|
2595 | return infoPtr->buttons[nIndex].fsStyle;
|
---|
2596 | }
|
---|
2597 |
|
---|
2598 |
|
---|
2599 | static LRESULT
|
---|
2600 | TOOLBAR_GetTextRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2601 | {
|
---|
2602 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2603 |
|
---|
2604 | if (infoPtr == NULL)
|
---|
2605 | return 0;
|
---|
2606 |
|
---|
2607 | return infoPtr->nMaxTextRows;
|
---|
2608 | }
|
---|
2609 |
|
---|
2610 |
|
---|
2611 | static LRESULT
|
---|
2612 | TOOLBAR_GetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2613 | {
|
---|
2614 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2615 |
|
---|
2616 | if (infoPtr == NULL) return 0;
|
---|
2617 | return infoPtr->hwndToolTip;
|
---|
2618 | }
|
---|
2619 |
|
---|
2620 |
|
---|
2621 | static LRESULT
|
---|
2622 | TOOLBAR_GetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2623 | {
|
---|
2624 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2625 |
|
---|
2626 | // TRACE (toolbar, "%s hwnd=0x%x stub!\n",
|
---|
2627 | // infoPtr->bUnicode ? "TRUE" : "FALSE", hwnd);
|
---|
2628 |
|
---|
2629 | return infoPtr->bUnicode;
|
---|
2630 | }
|
---|
2631 |
|
---|
2632 |
|
---|
2633 | static LRESULT
|
---|
2634 | TOOLBAR_HideButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2635 | {
|
---|
2636 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2637 | TBUTTON_INFO *btnPtr;
|
---|
2638 | INT nIndex;
|
---|
2639 |
|
---|
2640 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
2641 | if (nIndex == -1)
|
---|
2642 | return FALSE;
|
---|
2643 |
|
---|
2644 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
2645 | if (LOWORD(lParam) == FALSE)
|
---|
2646 | btnPtr->fsState &= ~TBSTATE_HIDDEN;
|
---|
2647 | else
|
---|
2648 | btnPtr->fsState |= TBSTATE_HIDDEN;
|
---|
2649 |
|
---|
2650 | TOOLBAR_CalcToolbar (hwnd);
|
---|
2651 |
|
---|
2652 | InvalidateRect (hwnd, NULL, TRUE);
|
---|
2653 |
|
---|
2654 | return TRUE;
|
---|
2655 | }
|
---|
2656 |
|
---|
2657 |
|
---|
2658 | static LRESULT
|
---|
2659 | TOOLBAR_HitTest (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2660 | {
|
---|
2661 | return TOOLBAR_InternalHitTest (hwnd, (LPPOINT)lParam);
|
---|
2662 | }
|
---|
2663 |
|
---|
2664 |
|
---|
2665 | static LRESULT
|
---|
2666 | TOOLBAR_Indeterminate (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2667 | {
|
---|
2668 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2669 | TBUTTON_INFO *btnPtr;
|
---|
2670 | HDC hdc;
|
---|
2671 | INT nIndex;
|
---|
2672 |
|
---|
2673 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
2674 | if (nIndex == -1)
|
---|
2675 | return FALSE;
|
---|
2676 |
|
---|
2677 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
2678 | if (LOWORD(lParam) == FALSE)
|
---|
2679 | btnPtr->fsState &= ~TBSTATE_INDETERMINATE;
|
---|
2680 | else
|
---|
2681 | btnPtr->fsState |= TBSTATE_INDETERMINATE;
|
---|
2682 |
|
---|
2683 | hdc = GetDC (hwnd);
|
---|
2684 | TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
|
---|
2685 | ReleaseDC (hwnd, hdc);
|
---|
2686 |
|
---|
2687 | return TRUE;
|
---|
2688 | }
|
---|
2689 |
|
---|
2690 |
|
---|
2691 | static LRESULT
|
---|
2692 | TOOLBAR_InsertButtonA (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2693 | {
|
---|
2694 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2695 | LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
|
---|
2696 | INT nIndex = (INT)wParam;
|
---|
2697 | TBUTTON_INFO *oldButtons;
|
---|
2698 |
|
---|
2699 | if (lpTbb == NULL)
|
---|
2700 | return FALSE;
|
---|
2701 | if (nIndex < 0)
|
---|
2702 | return FALSE;
|
---|
2703 |
|
---|
2704 | // TRACE (toolbar, "inserting button index=%d\n", nIndex);
|
---|
2705 | if (nIndex > infoPtr->nNumButtons) {
|
---|
2706 | nIndex = infoPtr->nNumButtons;
|
---|
2707 | // TRACE (toolbar, "adjust index=%d\n", nIndex);
|
---|
2708 | }
|
---|
2709 |
|
---|
2710 | oldButtons = infoPtr->buttons;
|
---|
2711 | infoPtr->nNumButtons++;
|
---|
2712 | infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
|
---|
2713 | /* pre insert copy */
|
---|
2714 | if (nIndex > 0) {
|
---|
2715 | memcpy (&infoPtr->buttons[0], &oldButtons[0],
|
---|
2716 | nIndex * sizeof(TBUTTON_INFO));
|
---|
2717 | }
|
---|
2718 |
|
---|
2719 | /* insert new button */
|
---|
2720 | infoPtr->buttons[nIndex].iBitmap = lpTbb->iBitmap;
|
---|
2721 | infoPtr->buttons[nIndex].idCommand = lpTbb->idCommand;
|
---|
2722 | infoPtr->buttons[nIndex].fsState = lpTbb->fsState;
|
---|
2723 | infoPtr->buttons[nIndex].fsStyle = lpTbb->fsStyle;
|
---|
2724 | infoPtr->buttons[nIndex].dwData = lpTbb->dwData;
|
---|
2725 | infoPtr->buttons[nIndex].iString = lpTbb->iString;
|
---|
2726 |
|
---|
2727 | if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) {
|
---|
2728 | TTTOOLINFOA ti;
|
---|
2729 |
|
---|
2730 | ZeroMemory (&ti, sizeof(TTTOOLINFOA));
|
---|
2731 | ti.cbSize = sizeof (TTTOOLINFOA);
|
---|
2732 | ti.hwnd = hwnd;
|
---|
2733 | ti.uId = lpTbb->idCommand;
|
---|
2734 | ti.hinst = 0;
|
---|
2735 | ti.lpszText = LPSTR_TEXTCALLBACKA;
|
---|
2736 |
|
---|
2737 | SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
|
---|
2738 | 0, (LPARAM)&ti);
|
---|
2739 | }
|
---|
2740 |
|
---|
2741 | /* post insert copy */
|
---|
2742 | if (nIndex < infoPtr->nNumButtons - 1) {
|
---|
2743 | memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex],
|
---|
2744 | (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO));
|
---|
2745 | }
|
---|
2746 |
|
---|
2747 | COMCTL32_Free (oldButtons);
|
---|
2748 |
|
---|
2749 | TOOLBAR_CalcToolbar (hwnd);
|
---|
2750 |
|
---|
2751 | InvalidateRect (hwnd, NULL, FALSE);
|
---|
2752 |
|
---|
2753 | return TRUE;
|
---|
2754 | }
|
---|
2755 |
|
---|
2756 | static LRESULT TOOLBAR_InsertButtonW (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2757 | {
|
---|
2758 | //CB: just call InsertButtonA, no Unicode used?!?
|
---|
2759 |
|
---|
2760 | return TOOLBAR_InsertButtonA(hwnd,wParam,lParam);
|
---|
2761 | }
|
---|
2762 |
|
---|
2763 | /* << TOOLBAR_InsertButton32W >> */
|
---|
2764 | /* << TOOLBAR_InsertMarkHitTest >> */
|
---|
2765 |
|
---|
2766 |
|
---|
2767 | static LRESULT
|
---|
2768 | TOOLBAR_IsButtonChecked (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2769 | {
|
---|
2770 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2771 | INT nIndex;
|
---|
2772 |
|
---|
2773 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
2774 | if (nIndex == -1)
|
---|
2775 | return FALSE;
|
---|
2776 |
|
---|
2777 | return (infoPtr->buttons[nIndex].fsState & TBSTATE_CHECKED);
|
---|
2778 | }
|
---|
2779 |
|
---|
2780 |
|
---|
2781 | static LRESULT
|
---|
2782 | TOOLBAR_IsButtonEnabled (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2783 | {
|
---|
2784 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2785 | INT nIndex;
|
---|
2786 |
|
---|
2787 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
2788 | if (nIndex == -1)
|
---|
2789 | return FALSE;
|
---|
2790 |
|
---|
2791 | return (infoPtr->buttons[nIndex].fsState & TBSTATE_ENABLED);
|
---|
2792 | }
|
---|
2793 |
|
---|
2794 |
|
---|
2795 | static LRESULT
|
---|
2796 | TOOLBAR_IsButtonHidden (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2797 | {
|
---|
2798 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2799 | INT nIndex;
|
---|
2800 |
|
---|
2801 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
2802 | if (nIndex == -1)
|
---|
2803 | return FALSE;
|
---|
2804 |
|
---|
2805 | return (infoPtr->buttons[nIndex].fsState & TBSTATE_HIDDEN);
|
---|
2806 | }
|
---|
2807 |
|
---|
2808 |
|
---|
2809 | static LRESULT
|
---|
2810 | TOOLBAR_IsButtonHighlighted (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2811 | {
|
---|
2812 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2813 | INT nIndex;
|
---|
2814 |
|
---|
2815 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
2816 | if (nIndex == -1)
|
---|
2817 | return FALSE;
|
---|
2818 |
|
---|
2819 | return (infoPtr->buttons[nIndex].fsState & TBSTATE_MARKED);
|
---|
2820 | }
|
---|
2821 |
|
---|
2822 |
|
---|
2823 | static LRESULT
|
---|
2824 | TOOLBAR_IsButtonIndeterminate (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2825 | {
|
---|
2826 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2827 | INT nIndex;
|
---|
2828 |
|
---|
2829 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
2830 | if (nIndex == -1)
|
---|
2831 | return FALSE;
|
---|
2832 |
|
---|
2833 | return (infoPtr->buttons[nIndex].fsState & TBSTATE_INDETERMINATE);
|
---|
2834 | }
|
---|
2835 |
|
---|
2836 |
|
---|
2837 | static LRESULT
|
---|
2838 | TOOLBAR_IsButtonPressed (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2839 | {
|
---|
2840 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2841 | INT nIndex;
|
---|
2842 |
|
---|
2843 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
2844 | if (nIndex == -1)
|
---|
2845 | return FALSE;
|
---|
2846 |
|
---|
2847 | return (infoPtr->buttons[nIndex].fsState & TBSTATE_PRESSED);
|
---|
2848 | }
|
---|
2849 |
|
---|
2850 |
|
---|
2851 | /* << TOOLBAR_LoadImages >> */
|
---|
2852 | /* << TOOLBAR_MapAccelerator >> */
|
---|
2853 | /* << TOOLBAR_MarkButton >> */
|
---|
2854 | /* << TOOLBAR_MoveButton >> */
|
---|
2855 |
|
---|
2856 |
|
---|
2857 | static LRESULT
|
---|
2858 | TOOLBAR_PressButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2859 | {
|
---|
2860 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2861 | TBUTTON_INFO *btnPtr;
|
---|
2862 | HDC hdc;
|
---|
2863 | INT nIndex;
|
---|
2864 |
|
---|
2865 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
2866 | if (nIndex == -1)
|
---|
2867 | return FALSE;
|
---|
2868 |
|
---|
2869 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
2870 | if (LOWORD(lParam) == FALSE)
|
---|
2871 | btnPtr->fsState &= ~TBSTATE_PRESSED;
|
---|
2872 | else
|
---|
2873 | btnPtr->fsState |= TBSTATE_PRESSED;
|
---|
2874 |
|
---|
2875 | hdc = GetDC (hwnd);
|
---|
2876 | TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
|
---|
2877 | ReleaseDC (hwnd, hdc);
|
---|
2878 |
|
---|
2879 | return TRUE;
|
---|
2880 | }
|
---|
2881 |
|
---|
2882 |
|
---|
2883 | /* << TOOLBAR_ReplaceBitmap >> */
|
---|
2884 |
|
---|
2885 |
|
---|
2886 | static LRESULT
|
---|
2887 | TOOLBAR_SaveRestoreA (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2888 | {
|
---|
2889 | #if 0
|
---|
2890 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2891 | LPTBSAVEPARAMSA lpSave = (LPTBSAVEPARAMSA)lParam;
|
---|
2892 |
|
---|
2893 | if (lpSave == NULL) return 0;
|
---|
2894 |
|
---|
2895 | if ((BOOL)wParam) {
|
---|
2896 | /* save toolbar information */
|
---|
2897 | // FIXME (toolbar, "save to \"%s\" \"%s\"\n",
|
---|
2898 | // lpSave->pszSubKey, lpSave->pszValueName);
|
---|
2899 |
|
---|
2900 |
|
---|
2901 | }
|
---|
2902 | else {
|
---|
2903 | /* restore toolbar information */
|
---|
2904 |
|
---|
2905 | // FIXME (toolbar, "restore from \"%s\" \"%s\"\n",
|
---|
2906 | // lpSave->pszSubKey, lpSave->pszValueName);
|
---|
2907 |
|
---|
2908 |
|
---|
2909 | }
|
---|
2910 | #endif
|
---|
2911 |
|
---|
2912 | return 0;
|
---|
2913 | }
|
---|
2914 |
|
---|
2915 | static LRESULT TOOLBAR_SaveRestoreW(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
2916 | {
|
---|
2917 | #if 0
|
---|
2918 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2919 | LPTBSAVEPARAMSW lpSave = (LPTBSAVEPARAMSW)lParam;
|
---|
2920 |
|
---|
2921 | if (lpSave == NULL) return 0;
|
---|
2922 |
|
---|
2923 | if ((BOOL)wParam) {
|
---|
2924 | /* save toolbar information */
|
---|
2925 | // FIXME (toolbar, "save to \"%s\" \"%s\"\n",
|
---|
2926 | // lpSave->pszSubKey, lpSave->pszValueName);
|
---|
2927 |
|
---|
2928 |
|
---|
2929 | }
|
---|
2930 | else {
|
---|
2931 | /* restore toolbar information */
|
---|
2932 |
|
---|
2933 | // FIXME (toolbar, "restore from \"%s\" \"%s\"\n",
|
---|
2934 | // lpSave->pszSubKey, lpSave->pszValueName);
|
---|
2935 |
|
---|
2936 |
|
---|
2937 | }
|
---|
2938 | #endif
|
---|
2939 |
|
---|
2940 | return 0;
|
---|
2941 | }
|
---|
2942 |
|
---|
2943 | /* << TOOLBAR_SaveRestore32W >> */
|
---|
2944 | /* << TOOLBAR_SetAnchorHighlight >> */
|
---|
2945 |
|
---|
2946 |
|
---|
2947 | static LRESULT
|
---|
2948 | TOOLBAR_SetBitmapSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2949 | {
|
---|
2950 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2951 |
|
---|
2952 | if (((INT)LOWORD(lParam) <= 0) || ((INT)HIWORD(lParam) <= 0)) return FALSE;
|
---|
2953 |
|
---|
2954 | infoPtr->nBitmapWidth = (INT)LOWORD(lParam);
|
---|
2955 | infoPtr->nBitmapHeight = (INT)HIWORD(lParam);
|
---|
2956 |
|
---|
2957 | return TRUE;
|
---|
2958 | }
|
---|
2959 |
|
---|
2960 |
|
---|
2961 | static LRESULT
|
---|
2962 | TOOLBAR_SetButtonInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2963 | {
|
---|
2964 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2965 | LPTBBUTTONINFOA lptbbi = (LPTBBUTTONINFOA)lParam;
|
---|
2966 | TBUTTON_INFO *btnPtr;
|
---|
2967 | INT nIndex;
|
---|
2968 |
|
---|
2969 | if (lptbbi == NULL)
|
---|
2970 | return FALSE;
|
---|
2971 | if (lptbbi->cbSize < sizeof(TBBUTTONINFOA))
|
---|
2972 | return FALSE;
|
---|
2973 |
|
---|
2974 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
2975 | if (nIndex == -1)
|
---|
2976 | return FALSE;
|
---|
2977 |
|
---|
2978 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
2979 | if (lptbbi->dwMask & TBIF_COMMAND)
|
---|
2980 | btnPtr->idCommand = lptbbi->idCommand;
|
---|
2981 | if (lptbbi->dwMask & TBIF_IMAGE)
|
---|
2982 | btnPtr->iBitmap = lptbbi->iImage;
|
---|
2983 | if (lptbbi->dwMask & TBIF_LPARAM)
|
---|
2984 | btnPtr->dwData = lptbbi->lParam;
|
---|
2985 | /* if (lptbbi->dwMask & TBIF_SIZE) */
|
---|
2986 | /* btnPtr->cx = lptbbi->cx; */
|
---|
2987 | if (lptbbi->dwMask & TBIF_STATE)
|
---|
2988 | btnPtr->fsState = lptbbi->fsState;
|
---|
2989 | if (lptbbi->dwMask & TBIF_STYLE)
|
---|
2990 | btnPtr->fsStyle = lptbbi->fsStyle;
|
---|
2991 |
|
---|
2992 | if (lptbbi->dwMask & TBIF_TEXT) {
|
---|
2993 | if ((btnPtr->iString >= 0) ||
|
---|
2994 | (btnPtr->iString < infoPtr->nNumStrings)) {
|
---|
2995 | #if 0
|
---|
2996 | CHAR **lpString = &infoPtr->strings[btnPtr->iString]; //wrong, it's Unicode!!!
|
---|
2997 | INT len = lstrlenA (lptbbi->pszText);
|
---|
2998 | *lpString = COMCTL32_ReAlloc (lpString, sizeof(char)*(len+1));
|
---|
2999 | #endif
|
---|
3000 |
|
---|
3001 | /* this is the ultimate sollution */
|
---|
3002 | /* Str_SetPtrA (&infoPtr->strings[btnPtr->iString], lptbbi->pszText); */
|
---|
3003 | }
|
---|
3004 | }
|
---|
3005 |
|
---|
3006 | return TRUE;
|
---|
3007 | }
|
---|
3008 |
|
---|
3009 | static LRESULT TOOLBAR_SetButtonInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3010 | {
|
---|
3011 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3012 | LPTBBUTTONINFOW lptbbi = (LPTBBUTTONINFOW)lParam;
|
---|
3013 | TBUTTON_INFO *btnPtr;
|
---|
3014 | INT nIndex;
|
---|
3015 |
|
---|
3016 | if (lptbbi == NULL)
|
---|
3017 | return FALSE;
|
---|
3018 | if (lptbbi->cbSize < sizeof(TBBUTTONINFOW))
|
---|
3019 | return FALSE;
|
---|
3020 |
|
---|
3021 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
3022 | if (nIndex == -1)
|
---|
3023 | return FALSE;
|
---|
3024 |
|
---|
3025 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
3026 | if (lptbbi->dwMask & TBIF_COMMAND)
|
---|
3027 | btnPtr->idCommand = lptbbi->idCommand;
|
---|
3028 | if (lptbbi->dwMask & TBIF_IMAGE)
|
---|
3029 | btnPtr->iBitmap = lptbbi->iImage;
|
---|
3030 | if (lptbbi->dwMask & TBIF_LPARAM)
|
---|
3031 | btnPtr->dwData = lptbbi->lParam;
|
---|
3032 | /* if (lptbbi->dwMask & TBIF_SIZE) */
|
---|
3033 | /* btnPtr->cx = lptbbi->cx; */
|
---|
3034 | if (lptbbi->dwMask & TBIF_STATE)
|
---|
3035 | btnPtr->fsState = lptbbi->fsState;
|
---|
3036 | if (lptbbi->dwMask & TBIF_STYLE)
|
---|
3037 | btnPtr->fsStyle = lptbbi->fsStyle;
|
---|
3038 |
|
---|
3039 | if (lptbbi->dwMask & TBIF_TEXT) {
|
---|
3040 | if ((btnPtr->iString >= 0) ||
|
---|
3041 | (btnPtr->iString < infoPtr->nNumStrings)) {
|
---|
3042 | #if 0
|
---|
3043 | WCHAR **lpString = &infoPtr->strings[btnPtr->iString];
|
---|
3044 | INT len = lstrlenW (lptbbi->pszText);
|
---|
3045 | *lpString = COMCTL32_ReAlloc (lpString, sizeof(wchar)*(len+1));
|
---|
3046 | #endif
|
---|
3047 |
|
---|
3048 | /* this is the ultimate sollution */
|
---|
3049 | /* Str_SetPtrW (&infoPtr->strings[btnPtr->iString], lptbbi->pszText); */
|
---|
3050 | }
|
---|
3051 | }
|
---|
3052 |
|
---|
3053 | return TRUE;
|
---|
3054 | }
|
---|
3055 |
|
---|
3056 | /* << TOOLBAR_SetButtonInfo32W >> */
|
---|
3057 |
|
---|
3058 |
|
---|
3059 | static LRESULT
|
---|
3060 | TOOLBAR_SetButtonSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3061 | {
|
---|
3062 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3063 |
|
---|
3064 | if (((INT)LOWORD(lParam) <= 0) || ((INT)HIWORD(lParam) <= 0)) return FALSE;
|
---|
3065 |
|
---|
3066 | infoPtr->nButtonWidth = (INT)LOWORD(lParam);
|
---|
3067 | infoPtr->nButtonHeight = (INT)HIWORD(lParam);
|
---|
3068 |
|
---|
3069 | return TRUE;
|
---|
3070 | }
|
---|
3071 |
|
---|
3072 |
|
---|
3073 | static LRESULT
|
---|
3074 | TOOLBAR_SetButtonWidth (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3075 | {
|
---|
3076 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3077 |
|
---|
3078 | if (infoPtr == NULL)
|
---|
3079 | return FALSE;
|
---|
3080 |
|
---|
3081 | infoPtr->cxMin = (INT)LOWORD(lParam);
|
---|
3082 | infoPtr->cxMax = (INT)HIWORD(lParam);
|
---|
3083 |
|
---|
3084 | return TRUE;
|
---|
3085 | }
|
---|
3086 |
|
---|
3087 |
|
---|
3088 | static LRESULT
|
---|
3089 | TOOLBAR_SetCmdId (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3090 | {
|
---|
3091 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3092 | INT nIndex = (INT)wParam;
|
---|
3093 |
|
---|
3094 | if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
|
---|
3095 | return FALSE;
|
---|
3096 |
|
---|
3097 | infoPtr->buttons[nIndex].idCommand = (INT)lParam;
|
---|
3098 |
|
---|
3099 | if (infoPtr->hwndToolTip) {
|
---|
3100 |
|
---|
3101 | // FIXME (toolbar, "change tool tip!\n");
|
---|
3102 |
|
---|
3103 | }
|
---|
3104 |
|
---|
3105 | return TRUE;
|
---|
3106 | }
|
---|
3107 |
|
---|
3108 |
|
---|
3109 | /* << TOOLBAR_SetColorScheme >> */
|
---|
3110 |
|
---|
3111 |
|
---|
3112 | static LRESULT
|
---|
3113 | TOOLBAR_SetDisabledImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3114 | {
|
---|
3115 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3116 | HIMAGELIST himlTemp;
|
---|
3117 |
|
---|
3118 | himlTemp = infoPtr->himlDis;
|
---|
3119 | infoPtr->himlDis = (HIMAGELIST)lParam;
|
---|
3120 |
|
---|
3121 | /* FIXME: redraw ? */
|
---|
3122 |
|
---|
3123 | return (LRESULT)himlTemp;
|
---|
3124 | }
|
---|
3125 |
|
---|
3126 |
|
---|
3127 | static LRESULT
|
---|
3128 | TOOLBAR_SetDrawTextFlags (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3129 | {
|
---|
3130 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3131 | DWORD dwTemp;
|
---|
3132 |
|
---|
3133 | dwTemp = infoPtr->dwDTFlags;
|
---|
3134 | infoPtr->dwDTFlags =
|
---|
3135 | (infoPtr->dwDTFlags & (DWORD)wParam) | (DWORD)lParam;
|
---|
3136 |
|
---|
3137 | return (LRESULT)dwTemp;
|
---|
3138 | }
|
---|
3139 |
|
---|
3140 |
|
---|
3141 | static LRESULT
|
---|
3142 | TOOLBAR_SetExtendedStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3143 | {
|
---|
3144 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3145 | DWORD dwTemp;
|
---|
3146 |
|
---|
3147 | dwTemp = infoPtr->dwExStyle;
|
---|
3148 | infoPtr->dwExStyle = (DWORD)lParam;
|
---|
3149 |
|
---|
3150 | return (LRESULT)dwTemp;
|
---|
3151 | }
|
---|
3152 |
|
---|
3153 |
|
---|
3154 | static LRESULT
|
---|
3155 | TOOLBAR_SetHotImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3156 | {
|
---|
3157 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
|
---|
3158 | HIMAGELIST himlTemp;
|
---|
3159 |
|
---|
3160 | himlTemp = infoPtr->himlHot;
|
---|
3161 | infoPtr->himlHot = (HIMAGELIST)lParam;
|
---|
3162 |
|
---|
3163 | /* FIXME: redraw ? */
|
---|
3164 |
|
---|
3165 | return (LRESULT)himlTemp;
|
---|
3166 | }
|
---|
3167 |
|
---|
3168 |
|
---|
3169 | /* << TOOLBAR_SetHotItem >> */
|
---|
3170 |
|
---|
3171 |
|
---|
3172 | static LRESULT
|
---|
3173 | TOOLBAR_SetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3174 | {
|
---|
3175 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3176 | HIMAGELIST himlTemp;
|
---|
3177 |
|
---|
3178 | himlTemp = infoPtr->himlDef;
|
---|
3179 | infoPtr->himlDef = (HIMAGELIST)lParam;
|
---|
3180 |
|
---|
3181 | /* FIXME: redraw ? */
|
---|
3182 |
|
---|
3183 | return (LRESULT)himlTemp;
|
---|
3184 | }
|
---|
3185 |
|
---|
3186 |
|
---|
3187 | static LRESULT
|
---|
3188 | TOOLBAR_SetIndent (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3189 | {
|
---|
3190 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3191 |
|
---|
3192 | infoPtr->nIndent = (INT)wParam;
|
---|
3193 |
|
---|
3194 | TOOLBAR_CalcToolbar (hwnd);
|
---|
3195 |
|
---|
3196 | InvalidateRect(hwnd, NULL, FALSE);
|
---|
3197 |
|
---|
3198 | return TRUE;
|
---|
3199 | }
|
---|
3200 |
|
---|
3201 |
|
---|
3202 | /* << TOOLBAR_SetInsertMark >> */
|
---|
3203 |
|
---|
3204 |
|
---|
3205 | static LRESULT
|
---|
3206 | TOOLBAR_SetInsertMarkColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3207 | {
|
---|
3208 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3209 |
|
---|
3210 | infoPtr->clrInsertMark = (COLORREF)lParam;
|
---|
3211 |
|
---|
3212 | /* FIXME : redraw ??*/
|
---|
3213 |
|
---|
3214 | return 0;
|
---|
3215 | }
|
---|
3216 |
|
---|
3217 |
|
---|
3218 | static LRESULT
|
---|
3219 | TOOLBAR_SetMaxTextRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3220 | {
|
---|
3221 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3222 |
|
---|
3223 | if (infoPtr == NULL)
|
---|
3224 | return FALSE;
|
---|
3225 |
|
---|
3226 | infoPtr->nMaxTextRows = (INT)wParam;
|
---|
3227 |
|
---|
3228 | return TRUE;
|
---|
3229 | }
|
---|
3230 |
|
---|
3231 |
|
---|
3232 | /* << TOOLBAR_SetPadding >> */
|
---|
3233 |
|
---|
3234 |
|
---|
3235 | static LRESULT
|
---|
3236 | TOOLBAR_SetParent (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3237 | {
|
---|
3238 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3239 | HWND hwndOldNotify;
|
---|
3240 |
|
---|
3241 | if (infoPtr == NULL)
|
---|
3242 | return 0;
|
---|
3243 | hwndOldNotify = infoPtr->hwndNotify;
|
---|
3244 | infoPtr->hwndNotify = (HWND)wParam;
|
---|
3245 |
|
---|
3246 | return hwndOldNotify;
|
---|
3247 | }
|
---|
3248 |
|
---|
3249 |
|
---|
3250 | static LRESULT
|
---|
3251 | TOOLBAR_SetRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3252 | {
|
---|
3253 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3254 | LPRECT lprc = (LPRECT)lParam;
|
---|
3255 |
|
---|
3256 | if (LOWORD(wParam) > 1) {
|
---|
3257 |
|
---|
3258 | // FIXME (toolbar, "multiple rows not supported!\n");
|
---|
3259 |
|
---|
3260 | }
|
---|
3261 |
|
---|
3262 | /* recalculate toolbar */
|
---|
3263 | TOOLBAR_CalcToolbar (hwnd);
|
---|
3264 |
|
---|
3265 | /* return bounding rectangle */
|
---|
3266 | if (lprc) {
|
---|
3267 | lprc->left = infoPtr->rcBound.left;
|
---|
3268 | lprc->right = infoPtr->rcBound.right;
|
---|
3269 | lprc->top = infoPtr->rcBound.top;
|
---|
3270 | lprc->bottom = infoPtr->rcBound.bottom;
|
---|
3271 | }
|
---|
3272 |
|
---|
3273 | /* repaint toolbar */
|
---|
3274 | InvalidateRect(hwnd, NULL, FALSE);
|
---|
3275 |
|
---|
3276 | return 0;
|
---|
3277 | }
|
---|
3278 |
|
---|
3279 |
|
---|
3280 | static LRESULT
|
---|
3281 | TOOLBAR_SetState (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3282 | {
|
---|
3283 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3284 | TBUTTON_INFO *btnPtr;
|
---|
3285 | HDC hdc;
|
---|
3286 | INT nIndex;
|
---|
3287 |
|
---|
3288 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
3289 | if (nIndex == -1)
|
---|
3290 | return FALSE;
|
---|
3291 |
|
---|
3292 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
3293 | btnPtr->fsState = LOWORD(lParam);
|
---|
3294 |
|
---|
3295 | hdc = GetDC (hwnd);
|
---|
3296 | TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
|
---|
3297 | ReleaseDC (hwnd, hdc);
|
---|
3298 |
|
---|
3299 | return TRUE;
|
---|
3300 | }
|
---|
3301 |
|
---|
3302 |
|
---|
3303 | static LRESULT
|
---|
3304 | TOOLBAR_SetStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3305 | {
|
---|
3306 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3307 | TBUTTON_INFO *btnPtr;
|
---|
3308 | HDC hdc;
|
---|
3309 | INT nIndex;
|
---|
3310 |
|
---|
3311 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
3312 | if (nIndex == -1)
|
---|
3313 | return FALSE;
|
---|
3314 |
|
---|
3315 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
3316 | btnPtr->fsStyle = LOWORD(lParam);
|
---|
3317 |
|
---|
3318 | hdc = GetDC (hwnd);
|
---|
3319 | TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
|
---|
3320 | ReleaseDC (hwnd, hdc);
|
---|
3321 |
|
---|
3322 | if (infoPtr->hwndToolTip) {
|
---|
3323 |
|
---|
3324 | // FIXME (toolbar, "change tool tip!\n");
|
---|
3325 |
|
---|
3326 | }
|
---|
3327 |
|
---|
3328 | return TRUE;
|
---|
3329 | }
|
---|
3330 |
|
---|
3331 |
|
---|
3332 | static LRESULT
|
---|
3333 | TOOLBAR_SetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3334 | {
|
---|
3335 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3336 |
|
---|
3337 | if (infoPtr == NULL)
|
---|
3338 | return 0;
|
---|
3339 | infoPtr->hwndToolTip = (HWND)wParam;
|
---|
3340 | return 0;
|
---|
3341 | }
|
---|
3342 |
|
---|
3343 |
|
---|
3344 | static LRESULT
|
---|
3345 | TOOLBAR_SetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3346 | {
|
---|
3347 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3348 | BOOL bTemp;
|
---|
3349 |
|
---|
3350 | // TRACE (toolbar, "%s hwnd=0x%04x stub!\n",
|
---|
3351 | // ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd);
|
---|
3352 |
|
---|
3353 | bTemp = infoPtr->bUnicode;
|
---|
3354 | infoPtr->bUnicode = (BOOL)wParam;
|
---|
3355 |
|
---|
3356 | return bTemp;
|
---|
3357 | }
|
---|
3358 |
|
---|
3359 |
|
---|
3360 | static LRESULT
|
---|
3361 | TOOLBAR_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3362 | {
|
---|
3363 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3364 | DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
|
---|
3365 | LOGFONTA logFont;
|
---|
3366 |
|
---|
3367 | /* initialize info structure */
|
---|
3368 | infoPtr->nButtonHeight = 22;
|
---|
3369 | infoPtr->nButtonWidth = 23;
|
---|
3370 | infoPtr->nBitmapHeight = 15;
|
---|
3371 | infoPtr->nBitmapWidth = 16;
|
---|
3372 |
|
---|
3373 | infoPtr->nHeight = infoPtr->nButtonHeight + TOP_BORDER + BOTTOM_BORDER;
|
---|
3374 | infoPtr->nRows = 1;
|
---|
3375 | infoPtr->nMaxTextRows = 1;
|
---|
3376 | infoPtr->cxMin = -1;
|
---|
3377 | infoPtr->cxMax = -1;
|
---|
3378 |
|
---|
3379 | infoPtr->bCaptured = FALSE;
|
---|
3380 | infoPtr->bUnicode = IsWindowUnicode(hwnd);
|
---|
3381 | infoPtr->nButtonDown = -1;
|
---|
3382 | infoPtr->nOldHit = -1;
|
---|
3383 | infoPtr->nHotItem = -2; /* It has to be initially different from nOldHit */
|
---|
3384 | infoPtr->hwndNotify = GetParent (hwnd);
|
---|
3385 | infoPtr->bTransparent = (dwStyle & TBSTYLE_FLAT);
|
---|
3386 | infoPtr->dwDTFlags = DT_CENTER;
|
---|
3387 |
|
---|
3388 | infoPtr->hwndToolbar = hwnd;
|
---|
3389 | infoPtr->oldButtons = NULL;
|
---|
3390 | infoPtr->nNumOldButtons = 0;
|
---|
3391 |
|
---|
3392 | SystemParametersInfoA (SPI_GETICONTITLELOGFONT, 0, &logFont, 0);
|
---|
3393 | infoPtr->hFont = CreateFontIndirectA (&logFont);
|
---|
3394 |
|
---|
3395 | if (dwStyle & TBSTYLE_TOOLTIPS)
|
---|
3396 | {
|
---|
3397 | /* Create tooltip control */
|
---|
3398 | infoPtr->hwndToolTip =
|
---|
3399 | CreateWindowExA (WS_EX_TOOLWINDOW,TOOLTIPS_CLASSA,NULL,WS_POPUP,
|
---|
3400 | CW_USEDEFAULT,CW_USEDEFAULT,
|
---|
3401 | CW_USEDEFAULT,CW_USEDEFAULT,
|
---|
3402 | hwnd,0,0,0);
|
---|
3403 |
|
---|
3404 | /* Send NM_TOOLTIPSCREATED notification */
|
---|
3405 | if (infoPtr->hwndToolTip)
|
---|
3406 | {
|
---|
3407 | NMTOOLTIPSCREATED nmttc;
|
---|
3408 |
|
---|
3409 | nmttc.hdr.hwndFrom = hwnd;
|
---|
3410 | nmttc.hdr.idFrom = GetWindowLongA(hwnd,GWL_ID);
|
---|
3411 | nmttc.hdr.code = NM_TOOLTIPSCREATED;
|
---|
3412 | nmttc.hwndToolTips = infoPtr->hwndToolTip;
|
---|
3413 |
|
---|
3414 | SendMessageA(infoPtr->hwndNotify,WM_NOTIFY,(WPARAM)nmttc.hdr.idFrom,(LPARAM)&nmttc);
|
---|
3415 | }
|
---|
3416 | }
|
---|
3417 |
|
---|
3418 | return 0;
|
---|
3419 | }
|
---|
3420 |
|
---|
3421 |
|
---|
3422 | static LRESULT
|
---|
3423 | TOOLBAR_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3424 | {
|
---|
3425 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3426 |
|
---|
3427 | /* delete tooltip control */
|
---|
3428 | if (infoPtr->hwndToolTip)
|
---|
3429 | DestroyWindow (infoPtr->hwndToolTip);
|
---|
3430 |
|
---|
3431 | /* delete button data */
|
---|
3432 | if (infoPtr->buttons)
|
---|
3433 | {
|
---|
3434 | INT x;
|
---|
3435 |
|
---|
3436 | for (x = 0;x < infoPtr->nNumButtons;x++) COMCTL32_Free(infoPtr->buttons[x].pszName);
|
---|
3437 | COMCTL32_Free(infoPtr->buttons);
|
---|
3438 | }
|
---|
3439 |
|
---|
3440 | /* delete strings */
|
---|
3441 | if (infoPtr->strings) {
|
---|
3442 | INT i;
|
---|
3443 | for (i = 0; i < infoPtr->nNumStrings; i++)
|
---|
3444 | if (infoPtr->strings[i])
|
---|
3445 | COMCTL32_Free (infoPtr->strings[i]);
|
---|
3446 |
|
---|
3447 | COMCTL32_Free (infoPtr->strings);
|
---|
3448 | }
|
---|
3449 |
|
---|
3450 | /* destroy internal image list */
|
---|
3451 | if (infoPtr->himlInt)
|
---|
3452 | ImageList_Destroy (infoPtr->himlInt);
|
---|
3453 |
|
---|
3454 | /* delete default font */
|
---|
3455 | if (infoPtr->hFont)
|
---|
3456 | DeleteObject (infoPtr->hFont);
|
---|
3457 |
|
---|
3458 | /* free toolbar info data */
|
---|
3459 | COMCTL32_Free (infoPtr);
|
---|
3460 |
|
---|
3461 | return 0;
|
---|
3462 | }
|
---|
3463 |
|
---|
3464 |
|
---|
3465 | static LRESULT
|
---|
3466 | TOOLBAR_EraseBackground (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3467 | {
|
---|
3468 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3469 |
|
---|
3470 | if (infoPtr->bTransparent)
|
---|
3471 | return SendMessageA (GetParent (hwnd), WM_ERASEBKGND, wParam, lParam);
|
---|
3472 |
|
---|
3473 | return DefWindowProcA (hwnd, WM_ERASEBKGND, wParam, lParam);
|
---|
3474 | }
|
---|
3475 |
|
---|
3476 |
|
---|
3477 | static LRESULT
|
---|
3478 | TOOLBAR_LButtonDblClk (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3479 | {
|
---|
3480 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3481 | TBUTTON_INFO *btnPtr;
|
---|
3482 | POINT pt;
|
---|
3483 | INT nHit;
|
---|
3484 | HDC hdc;
|
---|
3485 |
|
---|
3486 | pt.x = (INT)LOWORD(lParam);
|
---|
3487 | pt.y = (INT)HIWORD(lParam);
|
---|
3488 | nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
|
---|
3489 |
|
---|
3490 | if (nHit >= 0) {
|
---|
3491 | btnPtr = &infoPtr->buttons[nHit];
|
---|
3492 | if (!(btnPtr->fsState & TBSTATE_ENABLED))
|
---|
3493 | return 0;
|
---|
3494 | SetCapture (hwnd);
|
---|
3495 | infoPtr->bCaptured = TRUE;
|
---|
3496 | infoPtr->nButtonDown = nHit;
|
---|
3497 |
|
---|
3498 | btnPtr->fsState |= TBSTATE_PRESSED;
|
---|
3499 |
|
---|
3500 | hdc = GetDC (hwnd);
|
---|
3501 | TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
|
---|
3502 | ReleaseDC (hwnd, hdc);
|
---|
3503 | }
|
---|
3504 | else if (GetWindowLongA (hwnd, GWL_STYLE) & CCS_ADJUSTABLE)
|
---|
3505 | TOOLBAR_Customize (hwnd);
|
---|
3506 |
|
---|
3507 | return 0;
|
---|
3508 | }
|
---|
3509 |
|
---|
3510 |
|
---|
3511 | static LRESULT
|
---|
3512 | TOOLBAR_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3513 | {
|
---|
3514 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3515 | TBUTTON_INFO *btnPtr;
|
---|
3516 | POINT pt;
|
---|
3517 | INT nHit;
|
---|
3518 | HDC hdc;
|
---|
3519 |
|
---|
3520 | if (infoPtr->hwndToolTip)
|
---|
3521 | TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
|
---|
3522 | WM_LBUTTONDOWN, wParam, lParam);
|
---|
3523 |
|
---|
3524 | pt.x = (INT)LOWORD(lParam);
|
---|
3525 | pt.y = (INT)HIWORD(lParam);
|
---|
3526 | nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
|
---|
3527 |
|
---|
3528 | if (nHit >= 0) {
|
---|
3529 | btnPtr = &infoPtr->buttons[nHit];
|
---|
3530 | if (!(btnPtr->fsState & TBSTATE_ENABLED))
|
---|
3531 | return 0;
|
---|
3532 |
|
---|
3533 | SetCapture (hwnd);
|
---|
3534 | infoPtr->bCaptured = TRUE;
|
---|
3535 | infoPtr->nButtonDown = nHit;
|
---|
3536 | infoPtr->nOldHit = nHit;
|
---|
3537 |
|
---|
3538 | btnPtr->fsState |= TBSTATE_PRESSED;
|
---|
3539 |
|
---|
3540 | hdc = GetDC (hwnd);
|
---|
3541 | TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
|
---|
3542 | ReleaseDC (hwnd, hdc);
|
---|
3543 | }
|
---|
3544 |
|
---|
3545 | return 0;
|
---|
3546 | }
|
---|
3547 |
|
---|
3548 |
|
---|
3549 | static LRESULT
|
---|
3550 | TOOLBAR_LButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3551 | {
|
---|
3552 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3553 | TBUTTON_INFO *btnPtr;
|
---|
3554 | POINT pt;
|
---|
3555 | INT nHit;
|
---|
3556 | INT nOldIndex = -1;
|
---|
3557 | HDC hdc;
|
---|
3558 | BOOL bSendMessage = TRUE;
|
---|
3559 |
|
---|
3560 | if (infoPtr->hwndToolTip)
|
---|
3561 | TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
|
---|
3562 | WM_LBUTTONUP, wParam, lParam);
|
---|
3563 |
|
---|
3564 | pt.x = (INT)LOWORD(lParam);
|
---|
3565 | pt.y = (INT)HIWORD(lParam);
|
---|
3566 | nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
|
---|
3567 |
|
---|
3568 | if ((infoPtr->bCaptured) && (infoPtr->nButtonDown >= 0)) {
|
---|
3569 | infoPtr->bCaptured = FALSE;
|
---|
3570 | ReleaseCapture ();
|
---|
3571 | btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
|
---|
3572 | btnPtr->fsState &= ~TBSTATE_PRESSED;
|
---|
3573 |
|
---|
3574 | if (nHit == infoPtr->nButtonDown) {
|
---|
3575 | if (btnPtr->fsStyle & TBSTYLE_CHECK) {
|
---|
3576 | if (btnPtr->fsStyle & TBSTYLE_GROUP) {
|
---|
3577 | nOldIndex = TOOLBAR_GetCheckedGroupButtonIndex (infoPtr,
|
---|
3578 | infoPtr->nButtonDown);
|
---|
3579 | if (nOldIndex == infoPtr->nButtonDown)
|
---|
3580 | bSendMessage = FALSE;
|
---|
3581 | if ((nOldIndex != infoPtr->nButtonDown) &&
|
---|
3582 | (nOldIndex != -1))
|
---|
3583 | infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
|
---|
3584 | btnPtr->fsState |= TBSTATE_CHECKED;
|
---|
3585 | }
|
---|
3586 | else {
|
---|
3587 | if (btnPtr->fsState & TBSTATE_CHECKED)
|
---|
3588 | btnPtr->fsState &= ~TBSTATE_CHECKED;
|
---|
3589 | else
|
---|
3590 | btnPtr->fsState |= TBSTATE_CHECKED;
|
---|
3591 | }
|
---|
3592 | }
|
---|
3593 | }
|
---|
3594 | else
|
---|
3595 | bSendMessage = FALSE;
|
---|
3596 |
|
---|
3597 | hdc = GetDC (hwnd);
|
---|
3598 | if (nOldIndex != -1)
|
---|
3599 | TOOLBAR_DrawButton (hwnd, &infoPtr->buttons[nOldIndex], hdc);
|
---|
3600 | TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
|
---|
3601 | ReleaseDC (hwnd, hdc);
|
---|
3602 |
|
---|
3603 | if (bSendMessage)
|
---|
3604 | SendMessageA (infoPtr->hwndNotify, WM_COMMAND,
|
---|
3605 | MAKEWPARAM(btnPtr->idCommand, 0), (LPARAM)hwnd);
|
---|
3606 |
|
---|
3607 | infoPtr->nButtonDown = -1;
|
---|
3608 | infoPtr->nOldHit = -1;
|
---|
3609 | }
|
---|
3610 |
|
---|
3611 | return 0;
|
---|
3612 | }
|
---|
3613 |
|
---|
3614 |
|
---|
3615 | static LRESULT
|
---|
3616 | TOOLBAR_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3617 | {
|
---|
3618 | TBUTTON_INFO *btnPtr, *oldBtnPtr;
|
---|
3619 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3620 | POINT pt;
|
---|
3621 | INT nHit;
|
---|
3622 | HDC hdc;
|
---|
3623 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
|
---|
3624 |
|
---|
3625 | if (infoPtr->hwndToolTip)
|
---|
3626 | TOOLBAR_RelayEvent (infoPtr->hwndToolTip,hwnd,
|
---|
3627 | WM_MOUSEMOVE,wParam,lParam);
|
---|
3628 |
|
---|
3629 | pt.x = (INT)LOWORD(lParam);
|
---|
3630 | pt.y = (INT)HIWORD(lParam);
|
---|
3631 |
|
---|
3632 | nHit = TOOLBAR_InternalHitTest(hwnd,&pt);
|
---|
3633 |
|
---|
3634 | if (infoPtr->nOldHit != nHit)
|
---|
3635 | {
|
---|
3636 | /* Remove the effect of an old hot button */
|
---|
3637 | if(infoPtr->nOldHit == infoPtr->nHotItem)
|
---|
3638 | {
|
---|
3639 | oldBtnPtr = &infoPtr->buttons[infoPtr->nOldHit];
|
---|
3640 | if (oldBtnPtr->bHot) //CB: dynamic buttons
|
---|
3641 | {
|
---|
3642 | oldBtnPtr->bHot = FALSE;
|
---|
3643 |
|
---|
3644 | if (dwStyle & TBSTYLE_FLAT) InvalidateRect(hwnd,&oldBtnPtr->rect,TRUE);
|
---|
3645 | }
|
---|
3646 | }
|
---|
3647 |
|
---|
3648 | /* It's not a separator or in nowhere. It's a hot button. */
|
---|
3649 | if (nHit >= 0)
|
---|
3650 | {
|
---|
3651 | btnPtr = &infoPtr->buttons[nHit];
|
---|
3652 | if (!btnPtr->bHot)
|
---|
3653 | {
|
---|
3654 | btnPtr->bHot = TRUE;
|
---|
3655 |
|
---|
3656 | if (dwStyle & TBSTYLE_FLAT)
|
---|
3657 | {
|
---|
3658 | hdc = GetDC (hwnd);
|
---|
3659 | TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
|
---|
3660 | ReleaseDC (hwnd, hdc);
|
---|
3661 | }
|
---|
3662 |
|
---|
3663 | infoPtr->nHotItem = nHit;
|
---|
3664 | }
|
---|
3665 | }
|
---|
3666 |
|
---|
3667 | if (infoPtr->bCaptured)
|
---|
3668 | {
|
---|
3669 | btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
|
---|
3670 | if (infoPtr->nOldHit == infoPtr->nButtonDown)
|
---|
3671 | {
|
---|
3672 | btnPtr->fsState &= ~TBSTATE_PRESSED;
|
---|
3673 |
|
---|
3674 | hdc = GetDC (hwnd);
|
---|
3675 | TOOLBAR_DrawButton(hwnd,btnPtr,hdc);
|
---|
3676 | ReleaseDC(hwnd,hdc);
|
---|
3677 | } else if (nHit == infoPtr->nButtonDown)
|
---|
3678 | {
|
---|
3679 | btnPtr->fsState |= TBSTATE_PRESSED;
|
---|
3680 |
|
---|
3681 | hdc = GetDC(hwnd);
|
---|
3682 | TOOLBAR_DrawButton(hwnd,btnPtr,hdc);
|
---|
3683 | ReleaseDC(hwnd,hdc);
|
---|
3684 | }
|
---|
3685 | }
|
---|
3686 | infoPtr->nOldHit = nHit;
|
---|
3687 | }
|
---|
3688 | return 0;
|
---|
3689 | }
|
---|
3690 |
|
---|
3691 |
|
---|
3692 | static LRESULT
|
---|
3693 | TOOLBAR_NCActivate (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3694 | {
|
---|
3695 | /* if (wndPtr->dwStyle & CCS_NODIVIDER) */
|
---|
3696 | return DefWindowProcA (hwnd, WM_NCACTIVATE, wParam, lParam);
|
---|
3697 | /* else */
|
---|
3698 | /* return TOOLBAR_NCPaint (wndPtr, wParam, lParam); */
|
---|
3699 | }
|
---|
3700 |
|
---|
3701 |
|
---|
3702 | static LRESULT
|
---|
3703 | TOOLBAR_NCCalcSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3704 | {
|
---|
3705 | if (!(GetWindowLongA (hwnd, GWL_STYLE) & CCS_NODIVIDER))
|
---|
3706 | ((LPRECT)lParam)->top += GetSystemMetrics(SM_CYEDGE);
|
---|
3707 |
|
---|
3708 | return DefWindowProcA (hwnd, WM_NCCALCSIZE, wParam, lParam);
|
---|
3709 | }
|
---|
3710 |
|
---|
3711 |
|
---|
3712 | static LRESULT
|
---|
3713 | TOOLBAR_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3714 | {
|
---|
3715 | TOOLBAR_INFO *infoPtr;
|
---|
3716 |
|
---|
3717 | /* allocate memory for info structure */
|
---|
3718 | infoPtr = (TOOLBAR_INFO *)COMCTL32_Alloc (sizeof(TOOLBAR_INFO));
|
---|
3719 | SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
|
---|
3720 |
|
---|
3721 | /* paranoid!! */
|
---|
3722 | infoPtr->dwStructSize = sizeof(TBBUTTON);
|
---|
3723 |
|
---|
3724 | /* fix instance handle, if the toolbar was created by CreateToolbarEx() */
|
---|
3725 | if (!GetWindowLongA (hwnd, GWL_HINSTANCE)) {
|
---|
3726 | HINSTANCE hInst = (HINSTANCE)GetWindowLongA (GetParent (hwnd), GWL_HINSTANCE);
|
---|
3727 | SetWindowLongA (hwnd, GWL_HINSTANCE, (DWORD)hInst);
|
---|
3728 | }
|
---|
3729 |
|
---|
3730 | return DefWindowProcA (hwnd, WM_NCCREATE, wParam, lParam);
|
---|
3731 | }
|
---|
3732 |
|
---|
3733 |
|
---|
3734 | static LRESULT
|
---|
3735 | TOOLBAR_NCPaint (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3736 | {
|
---|
3737 | DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
|
---|
3738 | RECT rcWindow;
|
---|
3739 | HDC hdc;
|
---|
3740 |
|
---|
3741 | if (dwStyle & WS_MINIMIZE)
|
---|
3742 | return 0; /* Nothing to do */
|
---|
3743 |
|
---|
3744 | DefWindowProcA (hwnd, WM_NCPAINT, wParam, lParam);
|
---|
3745 |
|
---|
3746 | if (!(hdc = GetDCEx (hwnd, 0, DCX_USESTYLE | DCX_WINDOW)))
|
---|
3747 | return 0;
|
---|
3748 |
|
---|
3749 | if (!(dwStyle & CCS_NODIVIDER))
|
---|
3750 | {
|
---|
3751 | GetWindowRect (hwnd, &rcWindow);
|
---|
3752 | OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
|
---|
3753 | DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_TOP);
|
---|
3754 | }
|
---|
3755 |
|
---|
3756 | ReleaseDC( hwnd, hdc );
|
---|
3757 |
|
---|
3758 | return 0;
|
---|
3759 | }
|
---|
3760 |
|
---|
3761 |
|
---|
3762 | static LRESULT
|
---|
3763 | TOOLBAR_Notify (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3764 | {
|
---|
3765 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3766 | LPNMHDR lpnmh = (LPNMHDR)lParam;
|
---|
3767 |
|
---|
3768 | // TRACE (toolbar, "passing WM_NOTIFY!\n");
|
---|
3769 |
|
---|
3770 | if ((infoPtr->hwndToolTip) && (lpnmh->hwndFrom == infoPtr->hwndToolTip)) {
|
---|
3771 | SendMessageA (infoPtr->hwndNotify, WM_NOTIFY, wParam, lParam);
|
---|
3772 |
|
---|
3773 | #if 0
|
---|
3774 | if (lpnmh->code == TTN_GETDISPINFOA) {
|
---|
3775 | LPNMTTDISPINFOA lpdi = (LPNMTTDISPINFOA)lParam;
|
---|
3776 |
|
---|
3777 | // FIXME (toolbar, "retrieving ASCII string\n");
|
---|
3778 |
|
---|
3779 | }
|
---|
3780 | else if (lpnmh->code == TTN_GETDISPINFOW) {
|
---|
3781 | LPNMTTDISPINFOW lpdi = (LPNMTTDISPINFOW)lParam;
|
---|
3782 |
|
---|
3783 | // FIXME (toolbar, "retrieving UNICODE string\n");
|
---|
3784 |
|
---|
3785 | }
|
---|
3786 | #endif
|
---|
3787 | }
|
---|
3788 |
|
---|
3789 | return 0;
|
---|
3790 | }
|
---|
3791 |
|
---|
3792 |
|
---|
3793 | static LRESULT
|
---|
3794 | TOOLBAR_Paint (HWND hwnd, WPARAM wParam)
|
---|
3795 | {
|
---|
3796 | HDC hdc;
|
---|
3797 | PAINTSTRUCT ps;
|
---|
3798 |
|
---|
3799 | TOOLBAR_CalcToolbar(hwnd);
|
---|
3800 | hdc = wParam == 0 ? BeginPaint(hwnd,&ps) : (HDC)wParam;
|
---|
3801 | TOOLBAR_Refresh(hwnd,hdc);
|
---|
3802 | if (!wParam) EndPaint (hwnd, &ps);
|
---|
3803 | return 0;
|
---|
3804 | }
|
---|
3805 |
|
---|
3806 |
|
---|
3807 | static LRESULT
|
---|
3808 | TOOLBAR_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3809 | {
|
---|
3810 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3811 | DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
|
---|
3812 | RECT parent_rect;
|
---|
3813 | HWND parent;
|
---|
3814 | /* INT32 x, y; */
|
---|
3815 | INT cx, cy;
|
---|
3816 | INT flags;
|
---|
3817 | UINT uPosFlags = 0;
|
---|
3818 |
|
---|
3819 | /* Resize deadlock check */
|
---|
3820 | if (infoPtr->bAutoSize) {
|
---|
3821 | infoPtr->bAutoSize = FALSE;
|
---|
3822 | return 0;
|
---|
3823 | }
|
---|
3824 |
|
---|
3825 | flags = (INT) wParam;
|
---|
3826 |
|
---|
3827 | /* FIXME for flags =
|
---|
3828 | * SIZE_MAXIMIZED, SIZE_MAXSHOW, SIZE_MINIMIZED
|
---|
3829 | */
|
---|
3830 |
|
---|
3831 | // TRACE (toolbar, "sizing toolbar!\n");
|
---|
3832 |
|
---|
3833 | if (flags == SIZE_RESTORED) {
|
---|
3834 | /* width and height don't apply */
|
---|
3835 | parent = GetParent (hwnd);
|
---|
3836 | GetClientRect(parent, &parent_rect);
|
---|
3837 |
|
---|
3838 | if (dwStyle & CCS_NORESIZE) {
|
---|
3839 | uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
|
---|
3840 |
|
---|
3841 | /* FIXME */
|
---|
3842 | /* infoPtr->nWidth = parent_rect.right - parent_rect.left; */
|
---|
3843 | cy = infoPtr->nHeight;
|
---|
3844 | cx = infoPtr->nWidth;
|
---|
3845 | TOOLBAR_CalcToolbar (hwnd);
|
---|
3846 | infoPtr->nWidth = cx;
|
---|
3847 | infoPtr->nHeight = cy;
|
---|
3848 | }
|
---|
3849 | else {
|
---|
3850 | infoPtr->nWidth = parent_rect.right - parent_rect.left;
|
---|
3851 | TOOLBAR_CalcToolbar (hwnd);
|
---|
3852 | cy = infoPtr->nHeight;
|
---|
3853 | cx = infoPtr->nWidth;
|
---|
3854 | }
|
---|
3855 |
|
---|
3856 | if (dwStyle & CCS_NOPARENTALIGN) {
|
---|
3857 | uPosFlags |= SWP_NOMOVE;
|
---|
3858 | cy = infoPtr->nHeight;
|
---|
3859 | cx = infoPtr->nWidth;
|
---|
3860 | }
|
---|
3861 |
|
---|
3862 | if (!(dwStyle & CCS_NODIVIDER))
|
---|
3863 | cy += GetSystemMetrics(SM_CYEDGE);
|
---|
3864 |
|
---|
3865 | SetWindowPos (hwnd, 0, parent_rect.left, parent_rect.top,
|
---|
3866 | cx, cy, uPosFlags | SWP_NOZORDER);
|
---|
3867 | }
|
---|
3868 | return 0;
|
---|
3869 | }
|
---|
3870 |
|
---|
3871 |
|
---|
3872 | static LRESULT
|
---|
3873 | TOOLBAR_StyleChanged (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3874 | {
|
---|
3875 | TOOLBAR_AutoSize (hwnd, wParam, lParam);
|
---|
3876 |
|
---|
3877 | InvalidateRect(hwnd, NULL, FALSE);
|
---|
3878 |
|
---|
3879 | return 0;
|
---|
3880 | }
|
---|
3881 |
|
---|
3882 |
|
---|
3883 |
|
---|
3884 | static LRESULT WINAPI
|
---|
3885 | ToolbarWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
---|
3886 | {
|
---|
3887 | switch (uMsg)
|
---|
3888 | {
|
---|
3889 | case TB_ADDBITMAP:
|
---|
3890 | return TOOLBAR_AddBitmap (hwnd, wParam, lParam);
|
---|
3891 |
|
---|
3892 | case TB_ADDBUTTONSA:
|
---|
3893 | return TOOLBAR_AddButtonsA (hwnd, wParam, lParam);
|
---|
3894 |
|
---|
3895 | case TB_ADDBUTTONSW:
|
---|
3896 | return TOOLBAR_AddButtonsW(hwnd,wParam,lParam);
|
---|
3897 |
|
---|
3898 | case TB_ADDSTRINGA:
|
---|
3899 | return TOOLBAR_AddStringA (hwnd, wParam, lParam);
|
---|
3900 |
|
---|
3901 | case TB_ADDSTRINGW:
|
---|
3902 | return TOOLBAR_AddStringW (hwnd, wParam, lParam);
|
---|
3903 |
|
---|
3904 | case TB_AUTOSIZE:
|
---|
3905 | return TOOLBAR_AutoSize (hwnd, wParam, lParam);
|
---|
3906 |
|
---|
3907 | case TB_BUTTONCOUNT:
|
---|
3908 | return TOOLBAR_ButtonCount (hwnd, wParam, lParam);
|
---|
3909 |
|
---|
3910 | case TB_BUTTONSTRUCTSIZE:
|
---|
3911 | return TOOLBAR_ButtonStructSize (hwnd, wParam, lParam);
|
---|
3912 |
|
---|
3913 | case TB_CHANGEBITMAP:
|
---|
3914 | return TOOLBAR_ChangeBitmap (hwnd, wParam, lParam);
|
---|
3915 |
|
---|
3916 | case TB_CHECKBUTTON:
|
---|
3917 | return TOOLBAR_CheckButton (hwnd, wParam, lParam);
|
---|
3918 |
|
---|
3919 | case TB_COMMANDTOINDEX:
|
---|
3920 | return TOOLBAR_CommandToIndex (hwnd, wParam, lParam);
|
---|
3921 |
|
---|
3922 | case TB_CUSTOMIZE:
|
---|
3923 | return TOOLBAR_Customize (hwnd);
|
---|
3924 |
|
---|
3925 | case TB_DELETEBUTTON:
|
---|
3926 | return TOOLBAR_DeleteButton (hwnd, wParam, lParam);
|
---|
3927 |
|
---|
3928 | case TB_ENABLEBUTTON:
|
---|
3929 | return TOOLBAR_EnableButton (hwnd, wParam, lParam);
|
---|
3930 |
|
---|
3931 | /* case TB_GETANCHORHIGHLIGHT: */ /* 4.71 */
|
---|
3932 |
|
---|
3933 | case TB_GETBITMAP:
|
---|
3934 | return TOOLBAR_GetBitmap (hwnd, wParam, lParam);
|
---|
3935 |
|
---|
3936 | case TB_GETBITMAPFLAGS:
|
---|
3937 | return TOOLBAR_GetBitmapFlags (hwnd, wParam, lParam);
|
---|
3938 |
|
---|
3939 | case TB_GETBUTTON:
|
---|
3940 | return TOOLBAR_GetButton (hwnd, wParam, lParam);
|
---|
3941 |
|
---|
3942 | case TB_GETBUTTONINFOA:
|
---|
3943 | return TOOLBAR_GetButtonInfoA (hwnd, wParam, lParam);
|
---|
3944 |
|
---|
3945 | case TB_GETBUTTONINFOW: /* 4.71 */
|
---|
3946 | return TOOLBAR_GetButtonInfoW(hwnd,wParam,lParam);
|
---|
3947 |
|
---|
3948 | case TB_GETBUTTONSIZE:
|
---|
3949 | return TOOLBAR_GetButtonSize (hwnd);
|
---|
3950 |
|
---|
3951 | case TB_GETBUTTONTEXTA:
|
---|
3952 | return TOOLBAR_GetButtonTextA (hwnd, wParam, lParam);
|
---|
3953 |
|
---|
3954 | case TB_GETBUTTONTEXTW:
|
---|
3955 | return TOOLBAR_GetButtonTextW(hwnd,wParam,lParam);
|
---|
3956 |
|
---|
3957 | /* case TB_GETCOLORSCHEME: */ /* 4.71 */
|
---|
3958 |
|
---|
3959 | case TB_GETDISABLEDIMAGELIST:
|
---|
3960 | return TOOLBAR_GetDisabledImageList (hwnd, wParam, lParam);
|
---|
3961 |
|
---|
3962 | case TB_GETEXTENDEDSTYLE:
|
---|
3963 | return TOOLBAR_GetExtendedStyle (hwnd);
|
---|
3964 |
|
---|
3965 | case TB_GETHOTIMAGELIST:
|
---|
3966 | return TOOLBAR_GetHotImageList (hwnd, wParam, lParam);
|
---|
3967 |
|
---|
3968 | /* case TB_GETHOTITEM: */ /* 4.71 */
|
---|
3969 |
|
---|
3970 | case TB_GETIMAGELIST:
|
---|
3971 | return TOOLBAR_GetImageList (hwnd, wParam, lParam);
|
---|
3972 |
|
---|
3973 | /* case TB_GETINSERTMARK: */ /* 4.71 */
|
---|
3974 | /* case TB_GETINSERTMARKCOLOR: */ /* 4.71 */
|
---|
3975 |
|
---|
3976 | case TB_GETITEMRECT:
|
---|
3977 | return TOOLBAR_GetItemRect (hwnd, wParam, lParam);
|
---|
3978 |
|
---|
3979 | case TB_GETMAXSIZE:
|
---|
3980 | return TOOLBAR_GetMaxSize (hwnd, wParam, lParam);
|
---|
3981 |
|
---|
3982 | /* case TB_GETOBJECT: */ /* 4.71 */
|
---|
3983 | /* case TB_GETPADDING: */ /* 4.71 */
|
---|
3984 |
|
---|
3985 | case TB_GETRECT:
|
---|
3986 | return TOOLBAR_GetRect (hwnd, wParam, lParam);
|
---|
3987 |
|
---|
3988 | case TB_GETROWS:
|
---|
3989 | return TOOLBAR_GetRows (hwnd, wParam, lParam);
|
---|
3990 |
|
---|
3991 | case TB_GETSTATE:
|
---|
3992 | return TOOLBAR_GetState (hwnd, wParam, lParam);
|
---|
3993 |
|
---|
3994 | case TB_GETSTYLE:
|
---|
3995 | return TOOLBAR_GetStyle (hwnd, wParam, lParam);
|
---|
3996 |
|
---|
3997 | case TB_GETTEXTROWS:
|
---|
3998 | return TOOLBAR_GetTextRows (hwnd, wParam, lParam);
|
---|
3999 |
|
---|
4000 | case TB_GETTOOLTIPS:
|
---|
4001 | return TOOLBAR_GetToolTips (hwnd, wParam, lParam);
|
---|
4002 |
|
---|
4003 | case TB_GETUNICODEFORMAT:
|
---|
4004 | return TOOLBAR_GetUnicodeFormat (hwnd, wParam, lParam);
|
---|
4005 |
|
---|
4006 | case TB_HIDEBUTTON:
|
---|
4007 | return TOOLBAR_HideButton (hwnd, wParam, lParam);
|
---|
4008 |
|
---|
4009 | case TB_HITTEST:
|
---|
4010 | return TOOLBAR_HitTest (hwnd, wParam, lParam);
|
---|
4011 |
|
---|
4012 | case TB_INDETERMINATE:
|
---|
4013 | return TOOLBAR_Indeterminate (hwnd, wParam, lParam);
|
---|
4014 |
|
---|
4015 | case TB_INSERTBUTTONA:
|
---|
4016 | return TOOLBAR_InsertButtonA (hwnd, wParam, lParam);
|
---|
4017 |
|
---|
4018 | case TB_INSERTBUTTONW:
|
---|
4019 | return TOOLBAR_InsertButtonW(hwnd,wParam,lParam);
|
---|
4020 |
|
---|
4021 | /* case TB_INSERTMARKHITTEST: */ /* 4.71 */
|
---|
4022 |
|
---|
4023 | case TB_ISBUTTONCHECKED:
|
---|
4024 | return TOOLBAR_IsButtonChecked (hwnd, wParam, lParam);
|
---|
4025 |
|
---|
4026 | case TB_ISBUTTONENABLED:
|
---|
4027 | return TOOLBAR_IsButtonEnabled (hwnd, wParam, lParam);
|
---|
4028 |
|
---|
4029 | case TB_ISBUTTONHIDDEN:
|
---|
4030 | return TOOLBAR_IsButtonHidden (hwnd, wParam, lParam);
|
---|
4031 |
|
---|
4032 | case TB_ISBUTTONHIGHLIGHTED:
|
---|
4033 | return TOOLBAR_IsButtonHighlighted (hwnd, wParam, lParam);
|
---|
4034 |
|
---|
4035 | case TB_ISBUTTONINDETERMINATE:
|
---|
4036 | return TOOLBAR_IsButtonIndeterminate (hwnd, wParam, lParam);
|
---|
4037 |
|
---|
4038 | case TB_ISBUTTONPRESSED:
|
---|
4039 | return TOOLBAR_IsButtonPressed (hwnd, wParam, lParam);
|
---|
4040 |
|
---|
4041 | /* case TB_LOADIMAGES: */ /* 4.70 */
|
---|
4042 | /* case TB_MAPACCELERATORA: */ /* 4.71 */
|
---|
4043 | /* case TB_MAPACCELERATORW: */ /* 4.71 */
|
---|
4044 | /* case TB_MARKBUTTON: */ /* 4.71 */
|
---|
4045 | /* case TB_MOVEBUTTON: */ /* 4.71 */
|
---|
4046 |
|
---|
4047 | case TB_PRESSBUTTON:
|
---|
4048 | return TOOLBAR_PressButton (hwnd, wParam, lParam);
|
---|
4049 |
|
---|
4050 | /* case TB_REPLACEBITMAP: */
|
---|
4051 |
|
---|
4052 | case TB_SAVERESTOREA:
|
---|
4053 | return TOOLBAR_SaveRestoreA (hwnd, wParam, lParam);
|
---|
4054 |
|
---|
4055 | case TB_SAVERESTOREW:
|
---|
4056 | return TOOLBAR_SaveRestoreW(hwnd,wParam,lParam);
|
---|
4057 |
|
---|
4058 | /* case TB_SETANCHORHIGHLIGHT: */ /* 4.71 */
|
---|
4059 |
|
---|
4060 | case TB_SETBITMAPSIZE:
|
---|
4061 | return TOOLBAR_SetBitmapSize (hwnd, wParam, lParam);
|
---|
4062 |
|
---|
4063 | case TB_SETBUTTONINFOA:
|
---|
4064 | return TOOLBAR_SetButtonInfoA (hwnd, wParam, lParam);
|
---|
4065 |
|
---|
4066 | case TB_SETBUTTONINFOW: /* 4.71 */
|
---|
4067 | return TOOLBAR_SetButtonInfoW(hwnd,wParam,lParam);
|
---|
4068 |
|
---|
4069 | case TB_SETBUTTONSIZE:
|
---|
4070 | return TOOLBAR_SetButtonSize (hwnd, wParam, lParam);
|
---|
4071 |
|
---|
4072 | case TB_SETBUTTONWIDTH:
|
---|
4073 | return TOOLBAR_SetButtonWidth (hwnd, wParam, lParam);
|
---|
4074 |
|
---|
4075 | case TB_SETCMDID:
|
---|
4076 | return TOOLBAR_SetCmdId (hwnd, wParam, lParam);
|
---|
4077 |
|
---|
4078 | /* case TB_SETCOLORSCHEME: */ /* 4.71 */
|
---|
4079 |
|
---|
4080 | case TB_SETDISABLEDIMAGELIST:
|
---|
4081 | return TOOLBAR_SetDisabledImageList (hwnd, wParam, lParam);
|
---|
4082 |
|
---|
4083 | case TB_SETDRAWTEXTFLAGS:
|
---|
4084 | return TOOLBAR_SetDrawTextFlags (hwnd, wParam, lParam);
|
---|
4085 |
|
---|
4086 | case TB_SETEXTENDEDSTYLE:
|
---|
4087 | return TOOLBAR_SetExtendedStyle (hwnd, wParam, lParam);
|
---|
4088 |
|
---|
4089 | case TB_SETHOTIMAGELIST:
|
---|
4090 | return TOOLBAR_SetHotImageList (hwnd, wParam, lParam);
|
---|
4091 |
|
---|
4092 | /* case TB_SETHOTITEM: */ /* 4.71 */
|
---|
4093 |
|
---|
4094 | case TB_SETIMAGELIST:
|
---|
4095 | return TOOLBAR_SetImageList (hwnd, wParam, lParam);
|
---|
4096 |
|
---|
4097 | case TB_SETINDENT:
|
---|
4098 | return TOOLBAR_SetIndent (hwnd, wParam, lParam);
|
---|
4099 |
|
---|
4100 | /* case TB_SETINSERTMARK: */ /* 4.71 */
|
---|
4101 |
|
---|
4102 | case TB_SETINSERTMARKCOLOR:
|
---|
4103 | return TOOLBAR_SetInsertMarkColor (hwnd, wParam, lParam);
|
---|
4104 |
|
---|
4105 | case TB_SETMAXTEXTROWS:
|
---|
4106 | return TOOLBAR_SetMaxTextRows (hwnd, wParam, lParam);
|
---|
4107 |
|
---|
4108 | /* case TB_SETPADDING: */ /* 4.71 */
|
---|
4109 |
|
---|
4110 | case TB_SETPARENT:
|
---|
4111 | return TOOLBAR_SetParent (hwnd, wParam, lParam);
|
---|
4112 |
|
---|
4113 | case TB_SETROWS:
|
---|
4114 | return TOOLBAR_SetRows (hwnd, wParam, lParam);
|
---|
4115 |
|
---|
4116 | case TB_SETSTATE:
|
---|
4117 | return TOOLBAR_SetState (hwnd, wParam, lParam);
|
---|
4118 |
|
---|
4119 | case TB_SETSTYLE:
|
---|
4120 | return TOOLBAR_SetStyle (hwnd, wParam, lParam);
|
---|
4121 |
|
---|
4122 | case TB_SETTOOLTIPS:
|
---|
4123 | return TOOLBAR_SetToolTips (hwnd, wParam, lParam);
|
---|
4124 |
|
---|
4125 | case TB_SETUNICODEFORMAT:
|
---|
4126 | return TOOLBAR_SetUnicodeFormat (hwnd, wParam, lParam);
|
---|
4127 |
|
---|
4128 |
|
---|
4129 | /* case WM_CHAR: */
|
---|
4130 |
|
---|
4131 | case WM_CREATE:
|
---|
4132 | return TOOLBAR_Create (hwnd, wParam, lParam);
|
---|
4133 |
|
---|
4134 | case WM_DESTROY:
|
---|
4135 | return TOOLBAR_Destroy (hwnd, wParam, lParam);
|
---|
4136 |
|
---|
4137 | case WM_ERASEBKGND:
|
---|
4138 | return TOOLBAR_EraseBackground (hwnd, wParam, lParam);
|
---|
4139 |
|
---|
4140 | /* case WM_GETFONT: */
|
---|
4141 | /* case WM_KEYDOWN: */
|
---|
4142 | /* case WM_KILLFOCUS: */
|
---|
4143 |
|
---|
4144 | case WM_LBUTTONDBLCLK:
|
---|
4145 | return TOOLBAR_LButtonDblClk (hwnd, wParam, lParam);
|
---|
4146 |
|
---|
4147 | case WM_LBUTTONDOWN:
|
---|
4148 | return TOOLBAR_LButtonDown (hwnd, wParam, lParam);
|
---|
4149 |
|
---|
4150 | case WM_LBUTTONUP:
|
---|
4151 | return TOOLBAR_LButtonUp (hwnd, wParam, lParam);
|
---|
4152 |
|
---|
4153 | case WM_MOUSEMOVE:
|
---|
4154 | return TOOLBAR_MouseMove (hwnd, wParam, lParam);
|
---|
4155 |
|
---|
4156 | case WM_NCACTIVATE:
|
---|
4157 | return TOOLBAR_NCActivate (hwnd, wParam, lParam);
|
---|
4158 |
|
---|
4159 | case WM_NCCALCSIZE:
|
---|
4160 | return TOOLBAR_NCCalcSize (hwnd, wParam, lParam);
|
---|
4161 |
|
---|
4162 | case WM_NCCREATE:
|
---|
4163 | return TOOLBAR_NCCreate (hwnd, wParam, lParam);
|
---|
4164 |
|
---|
4165 | case WM_NCPAINT:
|
---|
4166 | return TOOLBAR_NCPaint (hwnd, wParam, lParam);
|
---|
4167 |
|
---|
4168 | case WM_NOTIFY:
|
---|
4169 | return TOOLBAR_Notify (hwnd, wParam, lParam);
|
---|
4170 |
|
---|
4171 | /* case WM_NOTIFYFORMAT: */
|
---|
4172 |
|
---|
4173 | case WM_PAINT:
|
---|
4174 | return TOOLBAR_Paint (hwnd, wParam);
|
---|
4175 |
|
---|
4176 | case WM_SIZE:
|
---|
4177 | return TOOLBAR_Size (hwnd, wParam, lParam);
|
---|
4178 |
|
---|
4179 | case WM_STYLECHANGED:
|
---|
4180 | return TOOLBAR_StyleChanged (hwnd, wParam, lParam);
|
---|
4181 |
|
---|
4182 | /* case WM_SYSCOLORCHANGE: */
|
---|
4183 |
|
---|
4184 | /* case WM_WININICHANGE: */
|
---|
4185 |
|
---|
4186 | case WM_CHARTOITEM:
|
---|
4187 | case WM_COMMAND:
|
---|
4188 | case WM_DRAWITEM:
|
---|
4189 | case WM_MEASUREITEM:
|
---|
4190 | case WM_VKEYTOITEM:
|
---|
4191 | return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
|
---|
4192 |
|
---|
4193 | default:
|
---|
4194 | // if (uMsg >= WM_USER)
|
---|
4195 | // ERR (toolbar, "unknown msg %04x wp=%08x lp=%08lx\n",
|
---|
4196 | // uMsg, wParam, lParam);
|
---|
4197 | return DefWindowProcA (hwnd, uMsg, wParam, lParam);
|
---|
4198 | }
|
---|
4199 | return 0;
|
---|
4200 | }
|
---|
4201 |
|
---|
4202 |
|
---|
4203 | VOID
|
---|
4204 | TOOLBAR_Register (VOID)
|
---|
4205 | {
|
---|
4206 | WNDCLASSA wndClass;
|
---|
4207 |
|
---|
4208 | if (GlobalFindAtomA (TOOLBARCLASSNAMEA)) return;
|
---|
4209 |
|
---|
4210 | ZeroMemory (&wndClass, sizeof(WNDCLASSA));
|
---|
4211 | wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
|
---|
4212 | wndClass.lpfnWndProc = (WNDPROC)ToolbarWindowProc;
|
---|
4213 | wndClass.cbClsExtra = 0;
|
---|
4214 | wndClass.cbWndExtra = sizeof(TOOLBAR_INFO *);
|
---|
4215 | wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
|
---|
4216 | wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
|
---|
4217 | wndClass.lpszClassName = TOOLBARCLASSNAMEA;
|
---|
4218 |
|
---|
4219 | RegisterClassA (&wndClass);
|
---|
4220 | }
|
---|
4221 |
|
---|
4222 |
|
---|
4223 | VOID
|
---|
4224 | TOOLBAR_Unregister (VOID)
|
---|
4225 | {
|
---|
4226 | if (GlobalFindAtomA (TOOLBARCLASSNAMEA))
|
---|
4227 | UnregisterClassA (TOOLBARCLASSNAMEA, (HINSTANCE)NULL);
|
---|
4228 | }
|
---|
4229 |
|
---|