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