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