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