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