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