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