| 1 | /*
|
|---|
| 2 | * Toolbar control
|
|---|
| 3 | *
|
|---|
| 4 | * Copyright 1998,1999 Eric Kohl
|
|---|
| 5 | * Copyright 2000 Eric Kohl for CodeWeavers
|
|---|
| 6 | *
|
|---|
| 7 | * Differences between MSDN and actual native control operation:
|
|---|
| 8 | * 1. MSDN says: "TBSTYLE_LIST: Creates a flat toolbar with button text
|
|---|
| 9 | * to the right of the bitmap. Otherwise, this style is
|
|---|
| 10 | * identical to TBSTYLE_FLAT."
|
|---|
| 11 | * As implemented by both v4.71 and v5.80 of the native COMCTL32.DLL
|
|---|
| 12 | * you can create a TBSTYLE_LIST without TBSTYLE_FLAT and the result
|
|---|
| 13 | * is non-flat non-transparent buttons. Therefore TBSTYLE_LIST does
|
|---|
| 14 | * *not* imply TBSTYLE_FLAT as documented. (GA 8/2001)
|
|---|
| 15 | *
|
|---|
| 16 | *
|
|---|
| 17 | * TODO:
|
|---|
| 18 | * - A little bug in TOOLBAR_DrawMasked()
|
|---|
| 19 | * - Button wrapping (under construction).
|
|---|
| 20 | * - Messages.
|
|---|
| 21 | * - Notifications (under construction).
|
|---|
| 22 | * - Fix TB_SETROWS.
|
|---|
| 23 | * - Tooltip support (almost complete).
|
|---|
| 24 | * - Unicode suppport (under construction).
|
|---|
| 25 | * - Fix TOOLBAR_SetButtonInfo32A/W.
|
|---|
| 26 | * - TBSTYLE_AUTOSIZE for toolbar and buttons.
|
|---|
| 27 | * - I_IMAGECALLBACK support.
|
|---|
| 28 | * - iString of -1 is undocumented
|
|---|
| 29 | * - Customization dialog:
|
|---|
| 30 | * - Add flat look.
|
|---|
| 31 | * - Minor buglet in 'available buttons' list:
|
|---|
| 32 | * Buttons are not listed in M$-like order. M$ seems to use a single
|
|---|
| 33 | * internal list to store the button information of both listboxes.
|
|---|
| 34 | * - Drag list support.
|
|---|
| 35 | * - Help and Reset button support.
|
|---|
| 36 | *
|
|---|
| 37 | * Testing:
|
|---|
| 38 | * - Run tests using Waite Group Windows95 API Bible Volume 2.
|
|---|
| 39 | * The second cdrom contains executables addstr.exe, btncount.exe,
|
|---|
| 40 | * btnstate.exe, butstrsz.exe, chkbtn.exe, chngbmp.exe, customiz.exe,
|
|---|
| 41 | * enablebtn.exe, getbmp.exe, getbtn.exe, getflags.exe, hidebtn.exe,
|
|---|
| 42 | * indetbtn.exe, insbtn.exe, pressbtn.exe, setbtnsz.exe, setcmdid.exe,
|
|---|
| 43 | * setparnt.exe, setrows.exe, toolwnd.exe.
|
|---|
| 44 | * - Microsofts controlspy examples.
|
|---|
| 45 | * - Charles Petzold's 'Programming Windows': gadgets.exe
|
|---|
| 46 | */
|
|---|
| 47 |
|
|---|
| 48 | #include <string.h>
|
|---|
| 49 |
|
|---|
| 50 | #include "winbase.h"
|
|---|
| 51 | #include "windef.h"
|
|---|
| 52 | #include "wingdi.h"
|
|---|
| 53 | #include "winuser.h"
|
|---|
| 54 | #include "wine/unicode.h"
|
|---|
| 55 | #include "commctrl.h"
|
|---|
| 56 | #include "imagelist.h"
|
|---|
| 57 | #include "comctl32.h"
|
|---|
| 58 | #include "debugtools.h"
|
|---|
| 59 |
|
|---|
| 60 | DEFAULT_DEBUG_CHANNEL(toolbar);
|
|---|
| 61 |
|
|---|
| 62 | typedef struct
|
|---|
| 63 | {
|
|---|
| 64 | INT iBitmap;
|
|---|
| 65 | INT idCommand;
|
|---|
| 66 | BYTE fsState;
|
|---|
| 67 | BYTE fsStyle;
|
|---|
| 68 | DWORD dwData;
|
|---|
| 69 | INT iString;
|
|---|
| 70 |
|
|---|
| 71 | BOOL bHot;
|
|---|
| 72 | INT nRow;
|
|---|
| 73 | RECT rect;
|
|---|
| 74 | } TBUTTON_INFO;
|
|---|
| 75 |
|
|---|
| 76 | typedef struct
|
|---|
| 77 | {
|
|---|
| 78 | DWORD dwStructSize; /* size of TBBUTTON struct */
|
|---|
| 79 | INT nHeight; /* height of the toolbar */
|
|---|
| 80 | INT nWidth; /* width of the toolbar */
|
|---|
| 81 | INT nButtonHeight;
|
|---|
| 82 | INT nButtonWidth;
|
|---|
| 83 | INT nBitmapHeight;
|
|---|
| 84 | INT nBitmapWidth;
|
|---|
| 85 | INT nIndent;
|
|---|
| 86 | INT nRows; /* number of button rows */
|
|---|
| 87 | INT nMaxTextRows; /* maximum number of text rows */
|
|---|
| 88 | INT cxMin; /* minimum button width */
|
|---|
| 89 | INT cxMax; /* maximum button width */
|
|---|
| 90 | INT nNumButtons; /* number of buttons */
|
|---|
| 91 | INT nNumBitmaps; /* number of bitmaps */
|
|---|
| 92 | INT nNumStrings; /* number of strings */
|
|---|
| 93 | BOOL bUnicode; /* ASCII (FALSE) or Unicode (TRUE)? */
|
|---|
| 94 | BOOL bCaptured; /* mouse captured? */
|
|---|
| 95 | INT nButtonDown;
|
|---|
| 96 | INT nOldHit;
|
|---|
| 97 | INT nHotItem; /* index of the "hot" item */
|
|---|
| 98 | HFONT hDefaultFont;
|
|---|
| 99 | HFONT hFont; /* text font */
|
|---|
| 100 | HIMAGELIST himlInt; /* image list created internally */
|
|---|
| 101 | HIMAGELIST himlDef; /* default image list */
|
|---|
| 102 | HIMAGELIST himlHot; /* hot image list */
|
|---|
| 103 | HIMAGELIST himlDis; /* disabled image list */
|
|---|
| 104 | HWND hwndToolTip; /* handle to tool tip control */
|
|---|
| 105 | HWND hwndNotify; /* handle to the window that gets notifications */
|
|---|
| 106 | HWND hwndSelf; /* my own handle */
|
|---|
| 107 | BOOL bTransparent; /* background transparency flag */
|
|---|
| 108 | BOOL bBtnTranspnt; /* button transparency flag */
|
|---|
| 109 | BOOL bAutoSize; /* auto size deadlock indicator */
|
|---|
| 110 | BOOL bAnchor; /* anchor highlight enabled */
|
|---|
| 111 | BOOL bNtfUnicode; /* TRUE if NOTIFYs use {W} */
|
|---|
| 112 | BOOL bDoRedraw; /* Redraw status */
|
|---|
| 113 | DWORD dwExStyle; /* extended toolbar style */
|
|---|
| 114 | DWORD dwDTFlags; /* DrawText flags */
|
|---|
| 115 |
|
|---|
| 116 | COLORREF clrInsertMark; /* insert mark color */
|
|---|
| 117 | RECT rcBound; /* bounding rectangle */
|
|---|
| 118 | INT iVersion;
|
|---|
| 119 |
|
|---|
| 120 | TBUTTON_INFO *buttons; /* pointer to button array */
|
|---|
| 121 | LPWSTR *strings; /* pointer to string array */
|
|---|
| 122 | } TOOLBAR_INFO, *PTOOLBAR_INFO;
|
|---|
| 123 |
|
|---|
| 124 |
|
|---|
| 125 | /* used by customization dialog */
|
|---|
| 126 | typedef struct
|
|---|
| 127 | {
|
|---|
| 128 | PTOOLBAR_INFO tbInfo;
|
|---|
| 129 | HWND tbHwnd;
|
|---|
| 130 | } CUSTDLG_INFO, *PCUSTDLG_INFO;
|
|---|
| 131 |
|
|---|
| 132 | typedef struct
|
|---|
| 133 | {
|
|---|
| 134 | TBBUTTON btn;
|
|---|
| 135 | BOOL bVirtual;
|
|---|
| 136 | BOOL bRemovable;
|
|---|
| 137 | CHAR text[64];
|
|---|
| 138 | } CUSTOMBUTTON, *PCUSTOMBUTTON;
|
|---|
| 139 |
|
|---|
| 140 |
|
|---|
| 141 | #define SEPARATOR_WIDTH 8
|
|---|
| 142 | #define TOP_BORDER 2
|
|---|
| 143 | #define BOTTOM_BORDER 2
|
|---|
| 144 | #define DDARROW_WIDTH 11
|
|---|
| 145 |
|
|---|
| 146 | #define TOOLBAR_GetInfoPtr(hwnd) ((TOOLBAR_INFO *)GetWindowLongA(hwnd,0))
|
|---|
| 147 | #define TOOLBAR_HasText(x, y) (TOOLBAR_GetText(x, y) ? TRUE : FALSE)
|
|---|
| 148 | #define TOOLBAR_HasDropDownArrows(exStyle) ((exStyle & TBSTYLE_EX_DRAWDDARROWS) ? TRUE : FALSE)
|
|---|
| 149 |
|
|---|
| 150 |
|
|---|
| 151 | static LPWSTR
|
|---|
| 152 | TOOLBAR_GetText(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr)
|
|---|
| 153 | {
|
|---|
| 154 | LPWSTR lpText = NULL;
|
|---|
| 155 |
|
|---|
| 156 | /* FIXME: iString == -1 is undocumented */
|
|---|
| 157 | if ((HIWORD(btnPtr->iString) != 0) && (btnPtr->iString != -1))
|
|---|
| 158 | lpText = (LPWSTR)btnPtr->iString;
|
|---|
| 159 | else if ((btnPtr->iString >= 0) && (btnPtr->iString < infoPtr->nNumStrings))
|
|---|
| 160 | lpText = infoPtr->strings[btnPtr->iString];
|
|---|
| 161 |
|
|---|
| 162 | return lpText;
|
|---|
| 163 | }
|
|---|
| 164 |
|
|---|
| 165 | static void
|
|---|
| 166 | TOOLBAR_DumpButton(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *bP, INT btn_num, BOOL internal)
|
|---|
| 167 | {
|
|---|
| 168 | if (TRACE_ON(toolbar)){
|
|---|
| 169 | TRACE("button %d id %d, bitmap=%d, state=%02x, style=%02x, data=%08lx, stringid=0x%08x\n",
|
|---|
| 170 | btn_num, bP->idCommand,
|
|---|
| 171 | bP->iBitmap, bP->fsState, bP->fsStyle, bP->dwData, bP->iString);
|
|---|
| 172 | TRACE("string %s\n", debugstr_w(TOOLBAR_GetText(infoPtr,bP)));
|
|---|
| 173 | if (internal)
|
|---|
| 174 | TRACE("button %d id %d, hot=%s, row=%d, rect=(%d,%d)-(%d,%d)\n",
|
|---|
| 175 | btn_num, bP->idCommand,
|
|---|
| 176 | (bP->bHot) ? "TRUE":"FALSE", bP->nRow,
|
|---|
| 177 | bP->rect.left, bP->rect.top,
|
|---|
| 178 | bP->rect.right, bP->rect.bottom);
|
|---|
| 179 | }
|
|---|
| 180 | }
|
|---|
| 181 |
|
|---|
| 182 |
|
|---|
| 183 | static void
|
|---|
| 184 | TOOLBAR_DumpToolbar(TOOLBAR_INFO *iP, INT line)
|
|---|
| 185 | {
|
|---|
| 186 | if (TRACE_ON(toolbar)) {
|
|---|
| 187 | INT i;
|
|---|
| 188 | DWORD dwStyle;
|
|---|
| 189 |
|
|---|
| 190 | dwStyle = GetWindowLongA (iP->hwndSelf, GWL_STYLE);
|
|---|
| 191 | TRACE("toolbar %08x at line %d, exStyle=%08lx, buttons=%d, bitmaps=%d, strings=%d, style=%08lx\n",
|
|---|
| 192 | iP->hwndSelf, line,
|
|---|
| 193 | iP->dwExStyle, iP->nNumButtons, iP->nNumBitmaps,
|
|---|
| 194 | iP->nNumStrings, dwStyle);
|
|---|
| 195 | TRACE("toolbar %08x at line %d, himlInt=%p, himlDef=%p, himlHot=%p, himlDis=%p, redrawable=%s\n",
|
|---|
| 196 | iP->hwndSelf, line,
|
|---|
| 197 | iP->himlInt, iP->himlDef, iP->himlHot, iP->himlDis,
|
|---|
| 198 | (iP->bDoRedraw) ? "TRUE" : "FALSE");
|
|---|
| 199 | for(i=0; i<iP->nNumButtons; i++) {
|
|---|
| 200 | TOOLBAR_DumpButton(iP, &iP->buttons[i], i, TRUE);
|
|---|
| 201 | }
|
|---|
| 202 | }
|
|---|
| 203 | }
|
|---|
| 204 |
|
|---|
| 205 |
|
|---|
| 206 | /***********************************************************************
|
|---|
| 207 | * TOOLBAR_CheckStyle
|
|---|
| 208 | *
|
|---|
| 209 | * This function validates that the styles set are implemented and
|
|---|
| 210 | * issues FIXME's warning of possible problems. In a perfect world this
|
|---|
| 211 | * function should be null.
|
|---|
| 212 | */
|
|---|
| 213 | static void
|
|---|
| 214 | TOOLBAR_CheckStyle (HWND hwnd, DWORD dwStyle)
|
|---|
| 215 | {
|
|---|
| 216 | if (dwStyle & TBSTYLE_ALTDRAG)
|
|---|
| 217 | FIXME("[%04x] TBSTYLE_ALTDRAG not implemented\n", hwnd);
|
|---|
| 218 | if (dwStyle & TBSTYLE_REGISTERDROP)
|
|---|
| 219 | FIXME("[%04x] TBSTYLE_REGISTERDROP not implemented\n", hwnd);
|
|---|
| 220 | }
|
|---|
| 221 |
|
|---|
| 222 |
|
|---|
| 223 | static INT
|
|---|
| 224 | TOOLBAR_SendNotify (NMHDR *nmhdr, TOOLBAR_INFO *infoPtr, UINT code)
|
|---|
| 225 | {
|
|---|
| 226 | if(!IsWindow(infoPtr->hwndSelf))
|
|---|
| 227 | return 0; /* we have just been destroyed */
|
|---|
| 228 |
|
|---|
| 229 | nmhdr->idFrom = GetDlgCtrlID (infoPtr->hwndSelf);
|
|---|
| 230 | nmhdr->hwndFrom = infoPtr->hwndSelf;
|
|---|
| 231 | nmhdr->code = code;
|
|---|
| 232 |
|
|---|
| 233 | TRACE("to window %04x, code=%08x, %s\n", infoPtr->hwndNotify, code,
|
|---|
| 234 | (infoPtr->bNtfUnicode) ? "via Unicode" : "via ANSI");
|
|---|
| 235 |
|
|---|
| 236 | if (infoPtr->bNtfUnicode)
|
|---|
| 237 | return SendMessageW (infoPtr->hwndNotify, WM_NOTIFY,
|
|---|
| 238 | (WPARAM) nmhdr->idFrom, (LPARAM)nmhdr);
|
|---|
| 239 | else
|
|---|
| 240 | return SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
|
|---|
| 241 | (WPARAM) nmhdr->idFrom, (LPARAM)nmhdr);
|
|---|
| 242 | }
|
|---|
| 243 |
|
|---|
| 244 | /***********************************************************************
|
|---|
| 245 | * TOOLBAR_GetBitmapIndex
|
|---|
| 246 | *
|
|---|
| 247 | * This function returns the bitmap index associated with a button.
|
|---|
| 248 | * If the button specifies I_IMAGECALLBACK, then the TBN_GETDISPINFO
|
|---|
| 249 | * is issued to retrieve the index.
|
|---|
| 250 | */
|
|---|
| 251 | static INT
|
|---|
| 252 | TOOLBAR_GetBitmapIndex(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr)
|
|---|
| 253 | {
|
|---|
| 254 | INT ret = btnPtr->iBitmap;
|
|---|
| 255 |
|
|---|
| 256 | if (ret == I_IMAGECALLBACK) {
|
|---|
| 257 | /* issue TBN_GETDISPINFO */
|
|---|
| 258 | NMTBDISPINFOA nmgd;
|
|---|
| 259 |
|
|---|
| 260 | nmgd.idCommand = btnPtr->idCommand;
|
|---|
| 261 | nmgd.lParam = btnPtr->dwData;
|
|---|
| 262 | nmgd.dwMask = TBNF_IMAGE;
|
|---|
| 263 | TOOLBAR_SendNotify ((NMHDR *) &nmgd, infoPtr,
|
|---|
| 264 | (infoPtr->bNtfUnicode) ? TBN_GETDISPINFOW :
|
|---|
| 265 | TBN_GETDISPINFOA);
|
|---|
| 266 | if (nmgd.dwMask & TBNF_DI_SETITEM) {
|
|---|
| 267 | btnPtr->iBitmap = nmgd.iImage;
|
|---|
| 268 | }
|
|---|
| 269 | ret = nmgd.iImage;
|
|---|
| 270 | TRACE("TBN_GETDISPINFOA returned bitmap id %d, mask=%08lx, nNumBitmaps=%d\n",
|
|---|
| 271 | ret, nmgd.dwMask, infoPtr->nNumBitmaps);
|
|---|
| 272 | }
|
|---|
| 273 | return ret;
|
|---|
| 274 | }
|
|---|
| 275 |
|
|---|
| 276 |
|
|---|
| 277 | static BOOL
|
|---|
| 278 | TOOLBAR_IsValidBitmapIndex(TOOLBAR_INFO *infoPtr, INT index)
|
|---|
| 279 | {
|
|---|
| 280 | if (((index>=0) && (index <= infoPtr->nNumBitmaps)) ||
|
|---|
| 281 | (index == I_IMAGECALLBACK))
|
|---|
| 282 | return TRUE;
|
|---|
| 283 | else
|
|---|
| 284 | return FALSE;
|
|---|
| 285 | }
|
|---|
| 286 |
|
|---|
| 287 |
|
|---|
| 288 | /***********************************************************************
|
|---|
| 289 | * TOOLBAR_DrawImageList
|
|---|
| 290 | *
|
|---|
| 291 | * This function validates the bitmap index (including I_IMAGECALLBACK
|
|---|
| 292 | * functionality). It then draws the image via the ImageList_Draw
|
|---|
| 293 | * function. It returns TRUE if the image was drawn, FALSE otherwise.
|
|---|
| 294 | */
|
|---|
| 295 | static BOOL
|
|---|
| 296 | TOOLBAR_DrawImageList (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, HIMAGELIST himl,
|
|---|
| 297 | HDC hdc, UINT left, UINT top, UINT draw_flags)
|
|---|
| 298 | {
|
|---|
| 299 | INT index;
|
|---|
| 300 |
|
|---|
| 301 | if (!himl) return FALSE;
|
|---|
| 302 |
|
|---|
| 303 | if (!TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) {
|
|---|
| 304 | ERR("index %d is not valid, max %d\n",
|
|---|
| 305 | btnPtr->iBitmap, infoPtr->nNumBitmaps);
|
|---|
| 306 | return FALSE;
|
|---|
| 307 | }
|
|---|
| 308 |
|
|---|
| 309 | if ((index = TOOLBAR_GetBitmapIndex(infoPtr, btnPtr)) < 0) {
|
|---|
| 310 | if (index == -1) return FALSE;
|
|---|
| 311 | ERR("TBN_GETDISPINFO returned invalid index %d\n",
|
|---|
| 312 | index);
|
|---|
| 313 | return FALSE;
|
|---|
| 314 | }
|
|---|
| 315 | TRACE("drawing index=%d, himl=%p, left=%d, top=%d, flags=%08x\n",
|
|---|
| 316 | index, himl, left, top, draw_flags);
|
|---|
| 317 |
|
|---|
| 318 | ImageList_Draw (himl, index, hdc, left, top, draw_flags);
|
|---|
| 319 | return TRUE;
|
|---|
| 320 | }
|
|---|
| 321 |
|
|---|
| 322 |
|
|---|
| 323 | /***********************************************************************
|
|---|
| 324 | * TOOLBAR_TestImageExist
|
|---|
| 325 | *
|
|---|
| 326 | * This function is similar to TOOLBAR_DrawImageList, except it does not
|
|---|
| 327 | * draw the image. The I_IMAGECALLBACK functionality is implemented.
|
|---|
| 328 | */
|
|---|
| 329 | static BOOL
|
|---|
| 330 | TOOLBAR_TestImageExist (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, HIMAGELIST himl)
|
|---|
| 331 | {
|
|---|
| 332 | INT index;
|
|---|
| 333 |
|
|---|
| 334 | if (!himl) return FALSE;
|
|---|
| 335 |
|
|---|
| 336 | if (!TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) {
|
|---|
| 337 | ERR("index %d is not valid, max %d\n",
|
|---|
| 338 | btnPtr->iBitmap, infoPtr->nNumBitmaps);
|
|---|
| 339 | return FALSE;
|
|---|
| 340 | }
|
|---|
| 341 |
|
|---|
| 342 | if ((index = TOOLBAR_GetBitmapIndex(infoPtr, btnPtr)) < 0) {
|
|---|
| 343 | if (index == -1) return FALSE;
|
|---|
| 344 | ERR("TBN_GETDISPINFO returned invalid index %d\n",
|
|---|
| 345 | index);
|
|---|
| 346 | return FALSE;
|
|---|
| 347 | }
|
|---|
| 348 | return TRUE;
|
|---|
| 349 | }
|
|---|
| 350 |
|
|---|
| 351 |
|
|---|
| 352 | static void
|
|---|
| 353 | TOOLBAR_DrawFlatSeparator (LPRECT lpRect, HDC hdc)
|
|---|
| 354 | {
|
|---|
| 355 | INT x = (lpRect->left + lpRect->right) / 2 - 1;
|
|---|
| 356 | INT yBottom = lpRect->bottom - 3;
|
|---|
| 357 | INT yTop = lpRect->top + 1;
|
|---|
| 358 |
|
|---|
| 359 | SelectObject ( hdc, GetSysColorPen (COLOR_3DSHADOW));
|
|---|
| 360 | MoveToEx (hdc, x, yBottom, NULL);
|
|---|
| 361 | LineTo (hdc, x, yTop);
|
|---|
| 362 | x++;
|
|---|
| 363 | SelectObject ( hdc, GetSysColorPen (COLOR_3DHILIGHT));
|
|---|
| 364 | MoveToEx (hdc, x, yBottom, NULL);
|
|---|
| 365 | LineTo (hdc, x, yTop);
|
|---|
| 366 | }
|
|---|
| 367 |
|
|---|
| 368 |
|
|---|
| 369 | /***********************************************************************
|
|---|
| 370 | * TOOLBAR_DrawDDFlatSeparator
|
|---|
| 371 | *
|
|---|
| 372 | * This function draws the separator that was flaged as TBSTYLE_DROPDOWN.
|
|---|
| 373 | * In this case, the separator is a pixel high line of COLOR_BTNSHADOW,
|
|---|
| 374 | * followed by a pixel high line of COLOR_BTNHIGHLIGHT. These separators
|
|---|
| 375 | * are horizontal as opposed to the vertical separators for not dropdown
|
|---|
| 376 | * type.
|
|---|
| 377 | *
|
|---|
| 378 | * FIXME: It is possible that the height of each line is really SM_CYBORDER.
|
|---|
| 379 | */
|
|---|
| 380 | static void
|
|---|
| 381 | TOOLBAR_DrawDDFlatSeparator (LPRECT lpRect, HDC hdc, TBUTTON_INFO *btnPtr)
|
|---|
| 382 | {
|
|---|
| 383 | RECT myrect;
|
|---|
| 384 | COLORREF oldcolor, newcolor;
|
|---|
| 385 |
|
|---|
| 386 | myrect.left = lpRect->left;
|
|---|
| 387 | myrect.right = lpRect->right;
|
|---|
| 388 | myrect.top = lpRect->top + (lpRect->bottom - lpRect->top - 2)/2;
|
|---|
| 389 | myrect.bottom = myrect.top + 1;
|
|---|
| 390 |
|
|---|
| 391 | InflateRect (&myrect, -2, 0);
|
|---|
| 392 |
|
|---|
| 393 | TRACE("rect=(%d,%d)-(%d,%d)\n",
|
|---|
| 394 | myrect.left, myrect.top, myrect.right, myrect.bottom);
|
|---|
| 395 |
|
|---|
| 396 | newcolor = GetSysColor (COLOR_BTNSHADOW);
|
|---|
| 397 | oldcolor = SetBkColor (hdc, newcolor);
|
|---|
| 398 | ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &myrect, 0, 0, 0);
|
|---|
| 399 |
|
|---|
| 400 | myrect.top = myrect.bottom;
|
|---|
| 401 | myrect.bottom = myrect.top + 1;
|
|---|
| 402 |
|
|---|
| 403 | newcolor = GetSysColor (COLOR_BTNHIGHLIGHT);
|
|---|
| 404 | SetBkColor (hdc, newcolor);
|
|---|
| 405 | ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &myrect, 0, 0, 0);
|
|---|
| 406 |
|
|---|
| 407 | SetBkColor (hdc, oldcolor);
|
|---|
| 408 | }
|
|---|
| 409 |
|
|---|
| 410 |
|
|---|
| 411 | static void
|
|---|
| 412 | TOOLBAR_DrawArrow (HDC hdc, INT left, INT top, INT colorRef)
|
|---|
| 413 | {
|
|---|
| 414 | INT x, y;
|
|---|
| 415 | SelectObject ( hdc, GetSysColorPen (colorRef));
|
|---|
| 416 | x = left + 2;
|
|---|
| 417 | y = top + 8;
|
|---|
| 418 | MoveToEx (hdc, x, y, NULL);
|
|---|
| 419 | LineTo (hdc, x+5, y++); x++;
|
|---|
| 420 | MoveToEx (hdc, x, y, NULL);
|
|---|
| 421 | LineTo (hdc, x+3, y++); x++;
|
|---|
| 422 | MoveToEx (hdc, x, y, NULL);
|
|---|
| 423 | LineTo (hdc, x+1, y++);
|
|---|
| 424 | }
|
|---|
| 425 |
|
|---|
| 426 | /*
|
|---|
| 427 | * Draw the text string for this button.
|
|---|
| 428 | * note: infoPtr->himlDis *SHOULD* be non-zero when infoPtr->himlDef
|
|---|
| 429 | * is non-zero, so we can simply check himlDef to see if we have
|
|---|
| 430 | * an image list
|
|---|
| 431 | */
|
|---|
| 432 | static void
|
|---|
| 433 | TOOLBAR_DrawString (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
|
|---|
| 434 | HDC hdc, INT nState, DWORD dwStyle)
|
|---|
| 435 | {
|
|---|
| 436 | RECT rcText = btnPtr->rect;
|
|---|
| 437 | HFONT hOldFont;
|
|---|
| 438 | COLORREF clrOld;
|
|---|
| 439 | LPWSTR lpText = NULL;
|
|---|
| 440 | HIMAGELIST himl = infoPtr->himlDef;
|
|---|
| 441 |
|
|---|
| 442 | TRACE ("iString: %x\n", btnPtr->iString);
|
|---|
| 443 |
|
|---|
| 444 | /* get a pointer to the text */
|
|---|
| 445 | lpText = TOOLBAR_GetText(infoPtr, btnPtr);
|
|---|
| 446 |
|
|---|
| 447 | TRACE ("Stringtext: %s\n", debugstr_w(lpText));
|
|---|
| 448 |
|
|---|
| 449 | /* draw text */
|
|---|
| 450 | if (lpText) {
|
|---|
| 451 |
|
|---|
| 452 | InflateRect (&rcText, -3, -3);
|
|---|
| 453 |
|
|---|
| 454 | if (himl && TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) {
|
|---|
| 455 | /* The following test looked like this before
|
|---|
| 456 | * I changed it. IE4 "Links" toolbar would not
|
|---|
| 457 | * draw correctly with the original code. - GA 8/01
|
|---|
| 458 | * ((dwStyle & TBSTYLE_LIST) &&
|
|---|
| 459 | * ((btnPtr->fsStyle & TBSTYLE_AUTOSIZE) == 0) &&
|
|---|
| 460 | * (btnPtr->iBitmap != I_IMAGENONE))
|
|---|
| 461 | */
|
|---|
| 462 | if (dwStyle & TBSTYLE_LIST) {
|
|---|
| 463 | /* LIST style w/ ICON offset is by matching native. */
|
|---|
| 464 | /* Matches IE4 "Links" bar. - GA 8/01 */
|
|---|
| 465 | rcText.left += (infoPtr->nBitmapWidth + 2);
|
|---|
| 466 | }
|
|---|
| 467 | else {
|
|---|
| 468 | rcText.top += infoPtr->nBitmapHeight + 1;
|
|---|
| 469 | }
|
|---|
| 470 | }
|
|---|
| 471 | else {
|
|---|
| 472 | if (dwStyle & TBSTYLE_LIST) {
|
|---|
| 473 | /* LIST style w/o ICON offset is by matching native. */
|
|---|
| 474 | /* Matches IE4 "menu" bar. - GA 8/01 */
|
|---|
| 475 | rcText.left += 4;
|
|---|
| 476 | }
|
|---|
| 477 | }
|
|---|
| 478 |
|
|---|
| 479 | if (nState & (TBSTATE_PRESSED | TBSTATE_CHECKED))
|
|---|
| 480 | OffsetRect (&rcText, 1, 1);
|
|---|
| 481 |
|
|---|
| 482 | TRACE("string rect=(%d,%d)-(%d,%d)\n",
|
|---|
| 483 | rcText.left, rcText.top, rcText.right, rcText.bottom);
|
|---|
| 484 |
|
|---|
| 485 | hOldFont = SelectObject (hdc, infoPtr->hFont);
|
|---|
| 486 | if (!(nState & TBSTATE_ENABLED)) {
|
|---|
| 487 | clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DHILIGHT));
|
|---|
| 488 | OffsetRect (&rcText, 1, 1);
|
|---|
| 489 | DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags);
|
|---|
| 490 | SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW));
|
|---|
| 491 | OffsetRect (&rcText, -1, -1);
|
|---|
| 492 | DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags);
|
|---|
| 493 | }
|
|---|
| 494 | else if (nState & TBSTATE_INDETERMINATE) {
|
|---|
| 495 | clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW));
|
|---|
| 496 | DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags);
|
|---|
| 497 | }
|
|---|
| 498 | else {
|
|---|
| 499 | clrOld = SetTextColor (hdc, GetSysColor (COLOR_BTNTEXT));
|
|---|
| 500 | DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags);
|
|---|
| 501 | }
|
|---|
| 502 |
|
|---|
| 503 | SetTextColor (hdc, clrOld);
|
|---|
| 504 | SelectObject (hdc, hOldFont);
|
|---|
| 505 | }
|
|---|
| 506 | }
|
|---|
| 507 |
|
|---|
| 508 |
|
|---|
| 509 | static void
|
|---|
| 510 | TOOLBAR_DrawPattern (HDC hdc, LPRECT lpRect)
|
|---|
| 511 | {
|
|---|
| 512 | HBRUSH hbr = SelectObject (hdc, COMCTL32_hPattern55AABrush);
|
|---|
| 513 | INT cx = lpRect->right - lpRect->left;
|
|---|
| 514 | INT cy = lpRect->bottom - lpRect->top;
|
|---|
| 515 | PatBlt (hdc, lpRect->left, lpRect->top, cx, cy, 0x00FA0089);
|
|---|
| 516 | SelectObject (hdc, hbr);
|
|---|
| 517 | }
|
|---|
| 518 |
|
|---|
| 519 |
|
|---|
| 520 | static void
|
|---|
| 521 | TOOLBAR_DrawMasked (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
|
|---|
| 522 | HDC hdc, INT x, INT y)
|
|---|
| 523 | {
|
|---|
| 524 | /* FIXME: this function is a hack since it uses image list
|
|---|
| 525 | internals directly */
|
|---|
| 526 |
|
|---|
| 527 | HIMAGELIST himl = infoPtr->himlDef;
|
|---|
| 528 | HBITMAP hbmMask;
|
|---|
| 529 | HDC hdcImageList;
|
|---|
| 530 | HDC hdcMask;
|
|---|
| 531 |
|
|---|
| 532 | if (!himl)
|
|---|
| 533 | return;
|
|---|
| 534 |
|
|---|
| 535 | /* create new dc's */
|
|---|
| 536 | hdcImageList = CreateCompatibleDC (0);
|
|---|
| 537 | hdcMask = CreateCompatibleDC (0);
|
|---|
| 538 |
|
|---|
| 539 | /* create new bitmap */
|
|---|
| 540 | hbmMask = CreateBitmap (himl->cx, himl->cy, 1, 1, NULL);
|
|---|
| 541 | SelectObject (hdcMask, hbmMask);
|
|---|
| 542 |
|
|---|
| 543 | /* copy the mask bitmap */
|
|---|
| 544 | SelectObject (hdcImageList, himl->hbmMask);
|
|---|
| 545 | SetBkColor (hdcImageList, RGB(255, 255, 255));
|
|---|
| 546 | SetTextColor (hdcImageList, RGB(0, 0, 0));
|
|---|
| 547 | BitBlt (hdcMask, 0, 0, himl->cx, himl->cy,
|
|---|
| 548 | hdcImageList, himl->cx * btnPtr->iBitmap, 0, SRCCOPY);
|
|---|
| 549 |
|
|---|
| 550 | /* draw the new mask */
|
|---|
| 551 | SelectObject (hdc, GetSysColorBrush (COLOR_3DHILIGHT));
|
|---|
| 552 | BitBlt (hdc, x+1, y+1, himl->cx, himl->cy,
|
|---|
| 553 | hdcMask, 0, 0, 0xB8074A);
|
|---|
| 554 |
|
|---|
| 555 | SelectObject (hdc, GetSysColorBrush (COLOR_3DSHADOW));
|
|---|
| 556 | BitBlt (hdc, x, y, himl->cx, himl->cy,
|
|---|
| 557 | hdcMask, 0, 0, 0xB8074A);
|
|---|
| 558 |
|
|---|
| 559 | DeleteObject (hbmMask);
|
|---|
| 560 | DeleteDC (hdcMask);
|
|---|
| 561 | DeleteDC (hdcImageList);
|
|---|
| 562 | }
|
|---|
| 563 |
|
|---|
| 564 |
|
|---|
| 565 | static void
|
|---|
| 566 | TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc)
|
|---|
| 567 | {
|
|---|
| 568 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 569 | DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
|
|---|
| 570 | BOOL hasDropDownArrow = TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle) &&
|
|---|
| 571 | (btnPtr->fsStyle & TBSTYLE_DROPDOWN);
|
|---|
| 572 | RECT rc, rcArrow, rcBitmap;
|
|---|
| 573 |
|
|---|
| 574 | if (btnPtr->fsState & TBSTATE_HIDDEN)
|
|---|
| 575 | return;
|
|---|
| 576 |
|
|---|
| 577 | rc = btnPtr->rect;
|
|---|
| 578 | CopyRect (&rcArrow, &rc);
|
|---|
| 579 | CopyRect(&rcBitmap, &rc);
|
|---|
| 580 |
|
|---|
| 581 | if (!infoPtr->bBtnTranspnt)
|
|---|
| 582 | FillRect( hdc, &rc, GetSysColorBrush(COLOR_BTNFACE));
|
|---|
| 583 |
|
|---|
| 584 | if (hasDropDownArrow)
|
|---|
| 585 | {
|
|---|
| 586 | if (dwStyle & TBSTYLE_FLAT)
|
|---|
| 587 | rc.right = max(rc.left, rc.right - DDARROW_WIDTH);
|
|---|
| 588 | else
|
|---|
| 589 | rc.right = max(rc.left, rc.right - DDARROW_WIDTH - 2);
|
|---|
| 590 | rcArrow.left = rc.right;
|
|---|
| 591 | }
|
|---|
| 592 |
|
|---|
| 593 | /* Center the bitmap horizontally and vertically */
|
|---|
| 594 | if (dwStyle & TBSTYLE_LIST)
|
|---|
| 595 | rcBitmap.left += 3;
|
|---|
| 596 | else
|
|---|
| 597 | rcBitmap.left+=(infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2;
|
|---|
| 598 |
|
|---|
| 599 | if(TOOLBAR_HasText(infoPtr, btnPtr))
|
|---|
| 600 | rcBitmap.top+=2; /* this looks to be the correct value from vmware comparison - cmm */
|
|---|
| 601 | else
|
|---|
| 602 | rcBitmap.top+=(infoPtr->nButtonHeight - infoPtr->nBitmapHeight) / 2;
|
|---|
| 603 |
|
|---|
| 604 | TRACE("iBitmap: %d, start=(%d,%d) w=%d, h=%d\n",
|
|---|
| 605 | btnPtr->iBitmap, rcBitmap.left, rcBitmap.top,
|
|---|
| 606 | infoPtr->nBitmapWidth, infoPtr->nBitmapHeight);
|
|---|
| 607 |
|
|---|
| 608 | /* separator */
|
|---|
| 609 | if (btnPtr->fsStyle & TBSTYLE_SEP) {
|
|---|
| 610 | /* with the FLAT style, iBitmap is the width and has already */
|
|---|
| 611 | /* been taken into consideration in calculating the width */
|
|---|
| 612 | /* so now we need to draw the vertical separator */
|
|---|
| 613 | /* empirical tests show that iBitmap can/will be non-zero */
|
|---|
| 614 | /* when drawing the vertical bar... */
|
|---|
| 615 | if ((dwStyle & TBSTYLE_FLAT) /* && (btnPtr->iBitmap == 0) */) {
|
|---|
| 616 | if (btnPtr->fsStyle & TBSTYLE_DROPDOWN)
|
|---|
| 617 | TOOLBAR_DrawDDFlatSeparator (&rc, hdc, btnPtr);
|
|---|
| 618 | else
|
|---|
| 619 | TOOLBAR_DrawFlatSeparator (&rc, hdc);
|
|---|
| 620 | }
|
|---|
| 621 | return;
|
|---|
| 622 | }
|
|---|
| 623 |
|
|---|
| 624 | /* disabled */
|
|---|
| 625 | if (!(btnPtr->fsState & TBSTATE_ENABLED)) {
|
|---|
| 626 | if (!(dwStyle & TBSTYLE_FLAT))
|
|---|
| 627 | {
|
|---|
| 628 | DrawEdge (hdc, &rc, EDGE_RAISED,
|
|---|
| 629 | BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
|
|---|
| 630 | if (hasDropDownArrow)
|
|---|
| 631 | DrawEdge (hdc, &rcArrow, EDGE_RAISED,
|
|---|
| 632 | BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
|
|---|
| 633 | }
|
|---|
| 634 |
|
|---|
| 635 | if (hasDropDownArrow)
|
|---|
| 636 | {
|
|---|
| 637 | TOOLBAR_DrawArrow(hdc, rcArrow.left+1, rcArrow.top+1, COLOR_3DHIGHLIGHT);
|
|---|
| 638 | TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_3DSHADOW);
|
|---|
| 639 | }
|
|---|
| 640 |
|
|---|
| 641 | if (!TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDis,
|
|---|
| 642 | hdc, rcBitmap.left, rcBitmap.top,
|
|---|
| 643 | ILD_NORMAL))
|
|---|
| 644 | TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rcBitmap.left, rcBitmap.top);
|
|---|
| 645 |
|
|---|
| 646 | TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
|
|---|
| 647 | return;
|
|---|
| 648 | }
|
|---|
| 649 |
|
|---|
| 650 | /* pressed TBSTYLE_BUTTON */
|
|---|
| 651 | if (btnPtr->fsState & TBSTATE_PRESSED) {
|
|---|
| 652 | if (dwStyle & TBSTYLE_FLAT)
|
|---|
| 653 | {
|
|---|
| 654 | DrawEdge (hdc, &rc, BDR_SUNKENOUTER, BF_RECT | BF_ADJUST);
|
|---|
| 655 | if (hasDropDownArrow)
|
|---|
| 656 | DrawEdge (hdc, &rcArrow, BDR_SUNKENOUTER, BF_RECT | BF_ADJUST);
|
|---|
| 657 | }
|
|---|
| 658 | else
|
|---|
| 659 | {
|
|---|
| 660 | DrawEdge (hdc, &rc, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST);
|
|---|
| 661 | if (hasDropDownArrow)
|
|---|
| 662 | DrawEdge (hdc, &rcArrow, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST);
|
|---|
| 663 | }
|
|---|
| 664 |
|
|---|
| 665 | if (hasDropDownArrow)
|
|---|
| 666 | TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_WINDOWFRAME);
|
|---|
| 667 |
|
|---|
| 668 | TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDef,
|
|---|
| 669 | hdc, rcBitmap.left+1, rcBitmap.top+1,
|
|---|
| 670 | ILD_NORMAL);
|
|---|
| 671 |
|
|---|
| 672 | TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
|
|---|
| 673 | return;
|
|---|
| 674 | }
|
|---|
| 675 |
|
|---|
| 676 | /* checked TBSTYLE_CHECK */
|
|---|
| 677 | if ((btnPtr->fsStyle & TBSTYLE_CHECK) &&
|
|---|
| 678 | (btnPtr->fsState & TBSTATE_CHECKED)) {
|
|---|
| 679 | if (dwStyle & TBSTYLE_FLAT)
|
|---|
| 680 | DrawEdge (hdc, &rc, BDR_SUNKENOUTER,
|
|---|
| 681 | BF_RECT | BF_ADJUST);
|
|---|
| 682 | else
|
|---|
| 683 | DrawEdge (hdc, &rc, EDGE_SUNKEN,
|
|---|
| 684 | BF_RECT | BF_MIDDLE | BF_ADJUST);
|
|---|
| 685 |
|
|---|
| 686 | TOOLBAR_DrawPattern (hdc, &rc);
|
|---|
| 687 |
|
|---|
| 688 | TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDef,
|
|---|
| 689 | hdc, rcBitmap.left+1, rcBitmap.top+1,
|
|---|
| 690 | ILD_NORMAL);
|
|---|
| 691 |
|
|---|
| 692 | TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
|
|---|
| 693 | return;
|
|---|
| 694 | }
|
|---|
| 695 |
|
|---|
| 696 | /* indeterminate */
|
|---|
| 697 | if (btnPtr->fsState & TBSTATE_INDETERMINATE) {
|
|---|
| 698 | DrawEdge (hdc, &rc, EDGE_RAISED,
|
|---|
| 699 | BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
|
|---|
| 700 |
|
|---|
| 701 | TOOLBAR_DrawPattern (hdc, &rc);
|
|---|
| 702 | TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rcBitmap.left, rcBitmap.top);
|
|---|
| 703 | TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
|
|---|
| 704 | return;
|
|---|
| 705 | }
|
|---|
| 706 |
|
|---|
| 707 | /* normal state */
|
|---|
| 708 | if (dwStyle & TBSTYLE_FLAT)
|
|---|
| 709 | {
|
|---|
| 710 | if (btnPtr->bHot)
|
|---|
| 711 | {
|
|---|
| 712 | DrawEdge (hdc, &rc, BDR_RAISEDINNER, BF_RECT);
|
|---|
| 713 | if (hasDropDownArrow)
|
|---|
| 714 | DrawEdge (hdc, &rcArrow, BDR_RAISEDINNER, BF_RECT);
|
|---|
| 715 | }
|
|---|
| 716 | #if 1
|
|---|
| 717 | else /* The following code needs to be removed after
|
|---|
| 718 | * "hot item" support has been implemented for the
|
|---|
| 719 | * case where it is being de-selected.
|
|---|
| 720 | */
|
|---|
| 721 | {
|
|---|
| 722 | FrameRect(hdc, &rc, GetSysColorBrush(COLOR_BTNFACE));
|
|---|
| 723 | if (hasDropDownArrow)
|
|---|
| 724 | FrameRect(hdc, &rcArrow, GetSysColorBrush(COLOR_BTNFACE));
|
|---|
| 725 | }
|
|---|
| 726 | #endif
|
|---|
| 727 |
|
|---|
| 728 | if (hasDropDownArrow)
|
|---|
| 729 | TOOLBAR_DrawArrow(hdc, rcArrow.left+1, rcArrow.top, COLOR_WINDOWFRAME);
|
|---|
| 730 |
|
|---|
| 731 | if (btnPtr->bHot) {
|
|---|
| 732 | /* if hot, attempt to draw with himlHot, if fails, use himlDef */
|
|---|
| 733 | if (!TOOLBAR_DrawImageList (infoPtr, btnPtr,
|
|---|
| 734 | infoPtr->himlHot,
|
|---|
| 735 | hdc, rcBitmap.left,
|
|---|
| 736 | rcBitmap.top, ILD_NORMAL))
|
|---|
| 737 | TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDef,
|
|---|
| 738 | hdc, rcBitmap.left, rcBitmap.top,
|
|---|
| 739 | ILD_NORMAL);
|
|---|
| 740 | }
|
|---|
| 741 | else
|
|---|
| 742 | TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDef,
|
|---|
| 743 | hdc, rcBitmap.left, rcBitmap.top,
|
|---|
| 744 | ILD_NORMAL);
|
|---|
| 745 | }
|
|---|
| 746 | else
|
|---|
| 747 | {
|
|---|
| 748 | DrawEdge (hdc, &rc, EDGE_RAISED,
|
|---|
| 749 | BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
|
|---|
| 750 |
|
|---|
| 751 | if (hasDropDownArrow)
|
|---|
| 752 | {
|
|---|
| 753 | DrawEdge (hdc, &rcArrow, EDGE_RAISED,
|
|---|
| 754 | BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
|
|---|
| 755 | TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_WINDOWFRAME);
|
|---|
| 756 | }
|
|---|
| 757 |
|
|---|
| 758 | TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDef,
|
|---|
| 759 | hdc, rcBitmap.left, rcBitmap.top,
|
|---|
| 760 | ILD_NORMAL);
|
|---|
| 761 | }
|
|---|
| 762 |
|
|---|
| 763 | TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
|
|---|
| 764 | }
|
|---|
| 765 |
|
|---|
| 766 |
|
|---|
| 767 | static void
|
|---|
| 768 | TOOLBAR_Refresh (HWND hwnd, HDC hdc, PAINTSTRUCT* ps)
|
|---|
| 769 | {
|
|---|
| 770 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 771 | TBUTTON_INFO *btnPtr;
|
|---|
| 772 | INT i, oldBKmode = 0;
|
|---|
| 773 | RECT rcTemp;
|
|---|
| 774 |
|
|---|
| 775 | /* if imagelist belongs to the app, it can be changed
|
|---|
| 776 | by the app after setting it */
|
|---|
| 777 | if (infoPtr->himlDef != infoPtr->himlInt)
|
|---|
| 778 | infoPtr->nNumBitmaps = ImageList_GetImageCount(infoPtr->himlDef);
|
|---|
| 779 |
|
|---|
| 780 | TOOLBAR_DumpToolbar (infoPtr, __LINE__);
|
|---|
| 781 |
|
|---|
| 782 | if (infoPtr->bBtnTranspnt)
|
|---|
| 783 | oldBKmode = SetBkMode (hdc, TRANSPARENT);
|
|---|
| 784 |
|
|---|
| 785 | /* redraw necessary buttons */
|
|---|
| 786 | btnPtr = infoPtr->buttons;
|
|---|
| 787 | for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++)
|
|---|
| 788 | {
|
|---|
| 789 | if(IntersectRect(&rcTemp, &(ps->rcPaint), &(btnPtr->rect)))
|
|---|
| 790 | TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
|
|---|
| 791 | }
|
|---|
| 792 |
|
|---|
| 793 | if (infoPtr->bBtnTranspnt && (oldBKmode != TRANSPARENT))
|
|---|
| 794 | SetBkMode (hdc, oldBKmode);
|
|---|
| 795 | }
|
|---|
| 796 |
|
|---|
| 797 | /***********************************************************************
|
|---|
| 798 | * TOOLBAR_MeasureString
|
|---|
| 799 | *
|
|---|
| 800 | * This function gets the width and height of a string in pixels. This
|
|---|
| 801 | * is done first by using GetTextExtentPoint to get the basic width
|
|---|
| 802 | * and height. The DrawText is called with DT_CALCRECT to get the exact
|
|---|
| 803 | * width. The reason is because the text may have more than one "&" (or
|
|---|
| 804 | * prefix characters as M$ likes to call them). The prefix character
|
|---|
| 805 | * indicates where the underline goes, except for the string "&&" which
|
|---|
| 806 | * is reduced to a single "&". GetTextExtentPoint does not process these
|
|---|
| 807 | * only DrawText does. Note that the TBSTYLE_NOPREFIX is handled here.
|
|---|
| 808 | */
|
|---|
| 809 | static void
|
|---|
| 810 | TOOLBAR_MeasureString(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
|
|---|
| 811 | HDC hdc, LPSIZE lpSize)
|
|---|
| 812 | {
|
|---|
| 813 | RECT myrect;
|
|---|
| 814 |
|
|---|
| 815 | lpSize->cx = 0;
|
|---|
| 816 | lpSize->cy = 0;
|
|---|
| 817 |
|
|---|
| 818 | if (!(btnPtr->fsState & TBSTATE_HIDDEN) )
|
|---|
| 819 | {
|
|---|
| 820 | LPWSTR lpText = TOOLBAR_GetText(infoPtr, btnPtr);
|
|---|
| 821 |
|
|---|
| 822 | /* first get size of all the text */
|
|---|
| 823 | GetTextExtentPoint32W (hdc, lpText, strlenW (lpText), lpSize);
|
|---|
| 824 |
|
|---|
| 825 | /* feed above size into the rectangle for DrawText */
|
|---|
| 826 | myrect.left = myrect.top = 0;
|
|---|
| 827 | myrect.right = lpSize->cx;
|
|---|
| 828 | myrect.bottom = lpSize->cy;
|
|---|
| 829 |
|
|---|
| 830 | /* Use DrawText to get true size as drawn (less pesky "&") */
|
|---|
| 831 | DrawTextW (hdc, lpText, -1, &myrect, DT_VCENTER | DT_SINGLELINE |
|
|---|
| 832 | DT_CALCRECT | ((btnPtr->fsStyle & TBSTYLE_NOPREFIX) ?
|
|---|
| 833 | DT_NOPREFIX : 0));
|
|---|
| 834 |
|
|---|
| 835 | /* feed back to caller */
|
|---|
| 836 | lpSize->cx = myrect.right;
|
|---|
| 837 | lpSize->cy = myrect.bottom;
|
|---|
| 838 | }
|
|---|
| 839 |
|
|---|
| 840 | TRACE("string size %ld x %ld!\n", lpSize->cx, lpSize->cy);
|
|---|
| 841 | }
|
|---|
| 842 |
|
|---|
| 843 | /***********************************************************************
|
|---|
| 844 | * TOOLBAR_CalcStrings
|
|---|
| 845 | *
|
|---|
| 846 | * This function walks through each string and measures it and returns
|
|---|
| 847 | * the largest height and width to caller.
|
|---|
| 848 | */
|
|---|
| 849 | static void
|
|---|
| 850 | TOOLBAR_CalcStrings (HWND hwnd, LPSIZE lpSize)
|
|---|
| 851 | {
|
|---|
| 852 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 853 | TBUTTON_INFO *btnPtr;
|
|---|
| 854 | INT i;
|
|---|
| 855 | SIZE sz;
|
|---|
| 856 | HDC hdc;
|
|---|
| 857 | HFONT hOldFont;
|
|---|
| 858 |
|
|---|
| 859 | lpSize->cx = 0;
|
|---|
| 860 | lpSize->cy = 0;
|
|---|
| 861 |
|
|---|
| 862 | hdc = GetDC (hwnd);
|
|---|
| 863 | hOldFont = SelectObject (hdc, infoPtr->hFont);
|
|---|
| 864 |
|
|---|
| 865 | btnPtr = infoPtr->buttons;
|
|---|
| 866 | for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
|
|---|
| 867 | if(TOOLBAR_HasText(infoPtr, btnPtr))
|
|---|
| 868 | {
|
|---|
| 869 | TOOLBAR_MeasureString(infoPtr, btnPtr, hdc, &sz);
|
|---|
| 870 | if (sz.cx > lpSize->cx)
|
|---|
| 871 | lpSize->cx = sz.cx;
|
|---|
| 872 | if (sz.cy > lpSize->cy)
|
|---|
| 873 | lpSize->cy = sz.cy;
|
|---|
| 874 | }
|
|---|
| 875 | }
|
|---|
| 876 |
|
|---|
| 877 | SelectObject (hdc, hOldFont);
|
|---|
| 878 | ReleaseDC (hwnd, hdc);
|
|---|
| 879 |
|
|---|
| 880 | TRACE("max string size %ld x %ld!\n", lpSize->cx, lpSize->cy);
|
|---|
| 881 | }
|
|---|
| 882 |
|
|---|
| 883 | /***********************************************************************
|
|---|
| 884 | * TOOLBAR_WrapToolbar
|
|---|
| 885 | *
|
|---|
| 886 | * This function walks through the buttons and seperators in the
|
|---|
| 887 | * toolbar, and sets the TBSTATE_WRAP flag only on those items where
|
|---|
| 888 | * wrapping should occur based on the width of the toolbar window.
|
|---|
| 889 | * It does *not* calculate button placement itself. That task
|
|---|
| 890 | * takes place in TOOLBAR_CalcToolbar. If the program wants to manage
|
|---|
| 891 | * the toolbar wrapping on its own, it can use the TBSTYLE_WRAPABLE
|
|---|
| 892 | * flag, and set the TBSTATE_WRAP flags manually on the appropriate items.
|
|---|
| 893 | */
|
|---|
| 894 |
|
|---|
| 895 | static void
|
|---|
| 896 | TOOLBAR_WrapToolbar( HWND hwnd, DWORD dwStyle )
|
|---|
| 897 | {
|
|---|
| 898 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 899 | TBUTTON_INFO *btnPtr;
|
|---|
| 900 | INT x, cx, i, j;
|
|---|
| 901 | RECT rc;
|
|---|
| 902 | BOOL bWrap, bButtonWrap;
|
|---|
| 903 |
|
|---|
| 904 | /* When the toolbar window style is not TBSTYLE_WRAPABLE, */
|
|---|
| 905 | /* no layout is necessary. Applications may use this style */
|
|---|
| 906 | /* to perform their own layout on the toolbar. */
|
|---|
| 907 | if( !(dwStyle & TBSTYLE_WRAPABLE) )
|
|---|
| 908 | return;
|
|---|
| 909 |
|
|---|
| 910 | btnPtr = infoPtr->buttons;
|
|---|
| 911 | x = infoPtr->nIndent;
|
|---|
| 912 |
|
|---|
| 913 | /* this can get the parents width, to know how far we can extend
|
|---|
| 914 | * this toolbar. We cannot use its height, as there may be multiple
|
|---|
| 915 | * toolbars in a rebar control
|
|---|
| 916 | */
|
|---|
| 917 | GetClientRect( GetParent(hwnd), &rc );
|
|---|
| 918 | infoPtr->nWidth = rc.right - rc.left;
|
|---|
| 919 | bButtonWrap = FALSE;
|
|---|
| 920 |
|
|---|
| 921 | TRACE("start ButtonWidth=%d, BitmapWidth=%d, nWidth=%d, nIndent=%d\n",
|
|---|
| 922 | infoPtr->nButtonWidth, infoPtr->nBitmapWidth, infoPtr->nWidth,
|
|---|
| 923 | infoPtr->nIndent);
|
|---|
| 924 |
|
|---|
| 925 | for (i = 0; i < infoPtr->nNumButtons; i++ )
|
|---|
| 926 | {
|
|---|
| 927 | bWrap = FALSE;
|
|---|
| 928 | btnPtr[i].fsState &= ~TBSTATE_WRAP;
|
|---|
| 929 |
|
|---|
| 930 | if (btnPtr[i].fsState & TBSTATE_HIDDEN)
|
|---|
| 931 | continue;
|
|---|
| 932 |
|
|---|
| 933 | /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
|
|---|
| 934 | /* it is the actual width of the separator. This is used for */
|
|---|
| 935 | /* custom controls in toolbars. */
|
|---|
| 936 | /* */
|
|---|
| 937 | /* TBSTYLE_DROPDOWN separators are treated as buttons for */
|
|---|
| 938 | /* width. - GA 8/01 */
|
|---|
| 939 | if ((btnPtr[i].fsStyle & TBSTYLE_SEP) &&
|
|---|
| 940 | !(btnPtr[i].fsStyle & TBSTYLE_DROPDOWN))
|
|---|
| 941 | cx = (btnPtr[i].iBitmap > 0) ?
|
|---|
| 942 | btnPtr[i].iBitmap : SEPARATOR_WIDTH;
|
|---|
| 943 | else
|
|---|
| 944 | cx = infoPtr->nButtonWidth;
|
|---|
| 945 |
|
|---|
| 946 | /* Two or more adjacent separators form a separator group. */
|
|---|
| 947 | /* The first separator in a group should be wrapped to the */
|
|---|
| 948 | /* next row if the previous wrapping is on a button. */
|
|---|
| 949 | if( bButtonWrap &&
|
|---|
| 950 | (btnPtr[i].fsStyle & TBSTYLE_SEP) &&
|
|---|
| 951 | (i + 1 < infoPtr->nNumButtons ) &&
|
|---|
| 952 | (btnPtr[i + 1].fsStyle & TBSTYLE_SEP) )
|
|---|
| 953 | {
|
|---|
| 954 | TRACE("wrap point 1 btn %d style %02x\n", i, btnPtr[i].fsStyle);
|
|---|
| 955 | btnPtr[i].fsState |= TBSTATE_WRAP;
|
|---|
| 956 | x = infoPtr->nIndent;
|
|---|
| 957 | i++;
|
|---|
| 958 | bButtonWrap = FALSE;
|
|---|
| 959 | continue;
|
|---|
| 960 | }
|
|---|
| 961 |
|
|---|
| 962 | /* The layout makes sure the bitmap is visible, but not the button. */
|
|---|
| 963 | /* Test added to also wrap after a button that starts a row but */
|
|---|
| 964 | /* is bigger than the area. - GA 8/01 */
|
|---|
| 965 | if (( x + cx - (infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2
|
|---|
| 966 | > infoPtr->nWidth ) ||
|
|---|
| 967 | ((x == infoPtr->nIndent) && (cx > infoPtr->nWidth)))
|
|---|
| 968 | {
|
|---|
| 969 | BOOL bFound = FALSE;
|
|---|
| 970 |
|
|---|
| 971 | /* If the current button is a separator and not hidden, */
|
|---|
| 972 | /* go to the next until it reaches a non separator. */
|
|---|
| 973 | /* Wrap the last separator if it is before a button. */
|
|---|
| 974 | while( ( (btnPtr[i].fsStyle & TBSTYLE_SEP) ||
|
|---|
| 975 | (btnPtr[i].fsState & TBSTATE_HIDDEN) ) &&
|
|---|
| 976 | i < infoPtr->nNumButtons )
|
|---|
| 977 | {
|
|---|
| 978 | i++;
|
|---|
| 979 | bFound = TRUE;
|
|---|
| 980 | }
|
|---|
| 981 |
|
|---|
| 982 | if( bFound && i < infoPtr->nNumButtons )
|
|---|
| 983 | {
|
|---|
| 984 | i--;
|
|---|
| 985 | TRACE("wrap point 2 btn %d style %02x, x=%d, cx=%d\n",
|
|---|
| 986 | i, btnPtr[i].fsStyle, x, cx);
|
|---|
| 987 | btnPtr[i].fsState |= TBSTATE_WRAP;
|
|---|
| 988 | x = infoPtr->nIndent;
|
|---|
| 989 | bButtonWrap = FALSE;
|
|---|
| 990 | continue;
|
|---|
| 991 | }
|
|---|
| 992 | else if ( i >= infoPtr->nNumButtons)
|
|---|
| 993 | break;
|
|---|
| 994 |
|
|---|
| 995 | /* If the current button is not a separator, find the last */
|
|---|
| 996 | /* separator and wrap it. */
|
|---|
| 997 | for ( j = i - 1; j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
|
|---|
| 998 | {
|
|---|
| 999 | if ((btnPtr[j].fsStyle & TBSTYLE_SEP) &&
|
|---|
| 1000 | !(btnPtr[j].fsState & TBSTATE_HIDDEN))
|
|---|
| 1001 | {
|
|---|
| 1002 | bFound = TRUE;
|
|---|
| 1003 | i = j;
|
|---|
| 1004 | TRACE("wrap point 3 btn %d style %02x, x=%d, cx=%d\n",
|
|---|
| 1005 | i, btnPtr[i].fsStyle, x, cx);
|
|---|
| 1006 | x = infoPtr->nIndent;
|
|---|
| 1007 | btnPtr[j].fsState |= TBSTATE_WRAP;
|
|---|
| 1008 | bButtonWrap = FALSE;
|
|---|
| 1009 | break;
|
|---|
| 1010 | }
|
|---|
| 1011 | }
|
|---|
| 1012 |
|
|---|
| 1013 | /* If no separator available for wrapping, wrap one of */
|
|---|
| 1014 | /* non-hidden previous button. */
|
|---|
| 1015 | if (!bFound)
|
|---|
| 1016 | {
|
|---|
| 1017 | for ( j = i - 1;
|
|---|
| 1018 | j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
|
|---|
| 1019 | {
|
|---|
| 1020 | if (btnPtr[j].fsState & TBSTATE_HIDDEN)
|
|---|
| 1021 | continue;
|
|---|
| 1022 |
|
|---|
| 1023 | bFound = TRUE;
|
|---|
| 1024 | i = j;
|
|---|
| 1025 | TRACE("wrap point 4 btn %d style %02x, x=%d, cx=%d\n",
|
|---|
| 1026 | i, btnPtr[i].fsStyle, x, cx);
|
|---|
| 1027 | x = infoPtr->nIndent;
|
|---|
| 1028 | btnPtr[j].fsState |= TBSTATE_WRAP;
|
|---|
| 1029 | bButtonWrap = TRUE;
|
|---|
| 1030 | break;
|
|---|
| 1031 | }
|
|---|
| 1032 | }
|
|---|
| 1033 |
|
|---|
| 1034 | /* If all above failed, wrap the current button. */
|
|---|
| 1035 | if (!bFound)
|
|---|
| 1036 | {
|
|---|
| 1037 | TRACE("wrap point 5 btn %d style %02x, x=%d, cx=%d\n",
|
|---|
| 1038 | i, btnPtr[i].fsStyle, x, cx);
|
|---|
| 1039 | btnPtr[i].fsState |= TBSTATE_WRAP;
|
|---|
| 1040 | bFound = TRUE;
|
|---|
| 1041 | x = infoPtr->nIndent;
|
|---|
| 1042 | if (btnPtr[i].fsStyle & TBSTYLE_SEP )
|
|---|
| 1043 | bButtonWrap = FALSE;
|
|---|
| 1044 | else
|
|---|
| 1045 | bButtonWrap = TRUE;
|
|---|
| 1046 | }
|
|---|
| 1047 | }
|
|---|
| 1048 | else {
|
|---|
| 1049 | TRACE("wrap point 6 btn %d style %02x, x=%d, cx=%d\n",
|
|---|
| 1050 | i, btnPtr[i].fsStyle, x, cx);
|
|---|
| 1051 | x += cx;
|
|---|
| 1052 | }
|
|---|
| 1053 | }
|
|---|
| 1054 | }
|
|---|
| 1055 |
|
|---|
| 1056 |
|
|---|
| 1057 | /***********************************************************************
|
|---|
| 1058 | * TOOLBAR_CalcToolbar
|
|---|
| 1059 | *
|
|---|
| 1060 | * This function calculates button and separator placement. It first
|
|---|
| 1061 | * calculates the button sizes, gets the toolbar window width and then
|
|---|
| 1062 | * calls TOOLBAR_WrapToolbar to determine which buttons we need to wrap
|
|---|
| 1063 | * on. It assigns a new location to each item and sends this location to
|
|---|
| 1064 | * the tooltip window if appropriate. Finally, it updates the rcBound
|
|---|
| 1065 | * rect and calculates the new required toolbar window height.
|
|---|
| 1066 | */
|
|---|
| 1067 |
|
|---|
| 1068 | static void
|
|---|
| 1069 | TOOLBAR_CalcToolbar (HWND hwnd)
|
|---|
| 1070 | {
|
|---|
| 1071 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
|
|---|
| 1072 | DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
|
|---|
| 1073 | TBUTTON_INFO *btnPtr;
|
|---|
| 1074 | INT i, nRows, nSepRows;
|
|---|
| 1075 | INT x, y, cx, cy;
|
|---|
| 1076 | SIZE sizeString;
|
|---|
| 1077 | BOOL bWrap;
|
|---|
| 1078 | BOOL usesBitmaps = FALSE;
|
|---|
| 1079 | BOOL hasDropDownArrows = TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle);
|
|---|
| 1080 |
|
|---|
| 1081 | TOOLBAR_CalcStrings (hwnd, &sizeString);
|
|---|
| 1082 |
|
|---|
| 1083 | if (dwStyle & TBSTYLE_LIST)
|
|---|
| 1084 | {
|
|---|
| 1085 | for (i = 0; i < infoPtr->nNumButtons && !usesBitmaps; i++)
|
|---|
| 1086 | {
|
|---|
| 1087 | if (infoPtr->buttons[i].iBitmap >= 0)
|
|---|
| 1088 | usesBitmaps = TRUE;
|
|---|
| 1089 | }
|
|---|
| 1090 | infoPtr->nButtonHeight = max((usesBitmaps) ? infoPtr->nBitmapHeight :
|
|---|
| 1091 | 0, sizeString.cy) + 6;
|
|---|
| 1092 | infoPtr->nButtonWidth = ((usesBitmaps) ? infoPtr->nBitmapWidth :
|
|---|
| 1093 | 0) + sizeString.cx + 6;
|
|---|
| 1094 | TRACE("LIST style, But w=%d h=%d, useBitmaps=%d, Bit w=%d h=%d\n",
|
|---|
| 1095 | infoPtr->nButtonWidth, infoPtr->nButtonHeight, usesBitmaps,
|
|---|
| 1096 | infoPtr->nBitmapWidth, infoPtr->nBitmapHeight);
|
|---|
| 1097 | TOOLBAR_DumpToolbar (infoPtr, __LINE__);
|
|---|
| 1098 | }
|
|---|
| 1099 | else {
|
|---|
| 1100 | for (i = 0; i < infoPtr->nNumButtons && !usesBitmaps; i++)
|
|---|
| 1101 | {
|
|---|
| 1102 | if (TOOLBAR_IsValidBitmapIndex(infoPtr,infoPtr->buttons[i].iBitmap))
|
|---|
| 1103 | usesBitmaps = TRUE;
|
|---|
| 1104 | }
|
|---|
| 1105 |
|
|---|
| 1106 | if (sizeString.cy > 0)
|
|---|
| 1107 | {
|
|---|
| 1108 | if (usesBitmaps)
|
|---|
| 1109 | infoPtr->nButtonHeight = sizeString.cy +
|
|---|
| 1110 | 2 + /* this is the space to separate text from bitmap */
|
|---|
| 1111 | infoPtr->nBitmapHeight + 6;
|
|---|
| 1112 | else
|
|---|
| 1113 | infoPtr->nButtonHeight = sizeString.cy + 6;
|
|---|
| 1114 | }
|
|---|
| 1115 | else if (infoPtr->nButtonHeight < infoPtr->nBitmapHeight + 6)
|
|---|
| 1116 | infoPtr->nButtonHeight = infoPtr->nBitmapHeight + 6;
|
|---|
| 1117 |
|
|---|
| 1118 | if (sizeString.cx > infoPtr->nBitmapWidth)
|
|---|
| 1119 | infoPtr->nButtonWidth = sizeString.cx + 6;
|
|---|
| 1120 | else if (infoPtr->nButtonWidth < infoPtr->nBitmapWidth + 6)
|
|---|
| 1121 | infoPtr->nButtonWidth = infoPtr->nBitmapWidth + 6;
|
|---|
| 1122 | }
|
|---|
| 1123 |
|
|---|
| 1124 | if ( infoPtr->cxMin >= 0 && infoPtr->nButtonWidth < infoPtr->cxMin )
|
|---|
| 1125 | infoPtr->nButtonWidth = infoPtr->cxMin;
|
|---|
| 1126 | if ( infoPtr->cxMax > 0 && infoPtr->nButtonWidth > infoPtr->cxMax )
|
|---|
| 1127 | infoPtr->nButtonWidth = infoPtr->cxMax;
|
|---|
| 1128 |
|
|---|
| 1129 | TOOLBAR_WrapToolbar( hwnd, dwStyle );
|
|---|
| 1130 |
|
|---|
| 1131 | x = infoPtr->nIndent;
|
|---|
| 1132 | y = 0;
|
|---|
| 1133 |
|
|---|
| 1134 | /*
|
|---|
| 1135 | * We will set the height below, and we set the width on entry
|
|---|
| 1136 | * so we do not reset them here..
|
|---|
| 1137 | */
|
|---|
| 1138 | #if 0
|
|---|
| 1139 | GetClientRect( hwnd, &rc );
|
|---|
| 1140 | /* get initial values for toolbar */
|
|---|
| 1141 | infoPtr->nWidth = rc.right - rc.left;
|
|---|
| 1142 | infoPtr->nHeight = rc.bottom - rc.top;
|
|---|
| 1143 | #endif
|
|---|
| 1144 |
|
|---|
| 1145 | /* from above, minimum is a button, and possible text */
|
|---|
| 1146 | cx = infoPtr->nButtonWidth;
|
|---|
| 1147 |
|
|---|
| 1148 | /* cannot use just ButtonHeight, we may have no buttons! */
|
|---|
| 1149 | if (infoPtr->nNumButtons > 0)
|
|---|
| 1150 | infoPtr->nHeight = infoPtr->nButtonHeight;
|
|---|
| 1151 |
|
|---|
| 1152 | cy = infoPtr->nHeight;
|
|---|
| 1153 |
|
|---|
| 1154 | nRows = nSepRows = 0;
|
|---|
| 1155 |
|
|---|
| 1156 | infoPtr->rcBound.top = y;
|
|---|
| 1157 | infoPtr->rcBound.left = x;
|
|---|
| 1158 | infoPtr->rcBound.bottom = y + cy;
|
|---|
| 1159 | infoPtr->rcBound.right = x;
|
|---|
| 1160 |
|
|---|
| 1161 | btnPtr = infoPtr->buttons;
|
|---|
| 1162 |
|
|---|
| 1163 | /* do not base height/width on parent, if the parent is a */
|
|---|
| 1164 | /* rebar control it could have multiple rows of toolbars */
|
|---|
| 1165 | /* GetClientRect( GetParent(hwnd), &rc ); */
|
|---|
| 1166 | /* cx = rc.right - rc.left; */
|
|---|
| 1167 | /* cy = rc.bottom - rc.top; */
|
|---|
| 1168 |
|
|---|
| 1169 | TRACE("cy=%d\n", cy);
|
|---|
| 1170 |
|
|---|
| 1171 | for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++ )
|
|---|
| 1172 | {
|
|---|
| 1173 | bWrap = FALSE;
|
|---|
| 1174 | if (btnPtr->fsState & TBSTATE_HIDDEN)
|
|---|
| 1175 | {
|
|---|
| 1176 | SetRectEmpty (&btnPtr->rect);
|
|---|
| 1177 | continue;
|
|---|
| 1178 | }
|
|---|
| 1179 |
|
|---|
| 1180 | cy = infoPtr->nHeight;
|
|---|
| 1181 |
|
|---|
| 1182 | /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
|
|---|
| 1183 | /* it is the actual width of the separator. This is used for */
|
|---|
| 1184 | /* custom controls in toolbars. */
|
|---|
| 1185 | if (btnPtr->fsStyle & TBSTYLE_SEP) {
|
|---|
| 1186 | if (btnPtr->fsStyle & TBSTYLE_DROPDOWN) {
|
|---|
| 1187 | cy = (btnPtr->iBitmap > 0) ?
|
|---|
| 1188 | btnPtr->iBitmap : SEPARATOR_WIDTH;
|
|---|
| 1189 | cx = infoPtr->nButtonWidth;
|
|---|
| 1190 | }
|
|---|
| 1191 | else
|
|---|
| 1192 | cx = (btnPtr->iBitmap > 0) ?
|
|---|
| 1193 | btnPtr->iBitmap : SEPARATOR_WIDTH;
|
|---|
| 1194 | }
|
|---|
| 1195 | else
|
|---|
| 1196 | {
|
|---|
| 1197 | if (btnPtr->fsStyle & TBSTYLE_AUTOSIZE)
|
|---|
| 1198 | {
|
|---|
| 1199 | SIZE sz;
|
|---|
| 1200 | HDC hdc;
|
|---|
| 1201 | HFONT hOldFont;
|
|---|
| 1202 |
|
|---|
| 1203 | hdc = GetDC (hwnd);
|
|---|
| 1204 | hOldFont = SelectObject (hdc, infoPtr->hFont);
|
|---|
| 1205 |
|
|---|
| 1206 | TOOLBAR_MeasureString(infoPtr, btnPtr, hdc, &sz);
|
|---|
| 1207 |
|
|---|
| 1208 | SelectObject (hdc, hOldFont);
|
|---|
| 1209 | ReleaseDC (hwnd, hdc);
|
|---|
| 1210 |
|
|---|
| 1211 | /* Fudge amount measured against IE4 "menu" and "Links" */
|
|---|
| 1212 | /* toolbars with native control (v4.71). - GA 8/01 */
|
|---|
| 1213 | cx = sz.cx + 6 + 5 + 5;
|
|---|
| 1214 | if ((dwStyle & TBSTYLE_LIST) &&
|
|---|
| 1215 | (TOOLBAR_TestImageExist (infoPtr, btnPtr, infoPtr->himlDef)))
|
|---|
| 1216 | cx += infoPtr->nBitmapWidth;
|
|---|
| 1217 | }
|
|---|
| 1218 | else
|
|---|
| 1219 | cx = infoPtr->nButtonWidth;
|
|---|
| 1220 |
|
|---|
| 1221 | if (hasDropDownArrows && (btnPtr->fsStyle & TBSTYLE_DROPDOWN))
|
|---|
| 1222 | cx += DDARROW_WIDTH;
|
|---|
| 1223 | }
|
|---|
| 1224 | if (btnPtr->fsState & TBSTATE_WRAP )
|
|---|
| 1225 | bWrap = TRUE;
|
|---|
| 1226 |
|
|---|
| 1227 | SetRect (&btnPtr->rect, x, y, x + cx, y + cy);
|
|---|
| 1228 |
|
|---|
| 1229 | if (infoPtr->rcBound.left > x)
|
|---|
| 1230 | infoPtr->rcBound.left = x;
|
|---|
| 1231 | if (infoPtr->rcBound.right < x + cx)
|
|---|
| 1232 | infoPtr->rcBound.right = x + cx;
|
|---|
| 1233 | if (infoPtr->rcBound.bottom < y + cy)
|
|---|
| 1234 | infoPtr->rcBound.bottom = y + cy;
|
|---|
| 1235 |
|
|---|
| 1236 | /* Set the toolTip only for non-hidden, non-separator button */
|
|---|
| 1237 | if (infoPtr->hwndToolTip && !(btnPtr->fsStyle & TBSTYLE_SEP ))
|
|---|
| 1238 | {
|
|---|
| 1239 | TTTOOLINFOA ti;
|
|---|
| 1240 |
|
|---|
| 1241 | ZeroMemory (&ti, sizeof(TTTOOLINFOA));
|
|---|
| 1242 | ti.cbSize = sizeof(TTTOOLINFOA);
|
|---|
| 1243 | ti.hwnd = hwnd;
|
|---|
| 1244 | ti.uId = btnPtr->idCommand;
|
|---|
| 1245 | ti.rect = btnPtr->rect;
|
|---|
| 1246 | SendMessageA (infoPtr->hwndToolTip, TTM_NEWTOOLRECTA,
|
|---|
| 1247 | 0, (LPARAM)&ti);
|
|---|
| 1248 | }
|
|---|
| 1249 |
|
|---|
| 1250 | /* btnPtr->nRow is zero based. The space between the rows is */
|
|---|
| 1251 | /* also considered as a row. */
|
|---|
| 1252 | btnPtr->nRow = nRows + nSepRows;
|
|---|
| 1253 |
|
|---|
| 1254 | TRACE("button %d style=%x, bWrap=%d, nRows=%d, nSepRows=%d, btnrow=%d\n",
|
|---|
| 1255 | i, btnPtr->fsStyle, bWrap, nRows, nSepRows, btnPtr->nRow);
|
|---|
| 1256 |
|
|---|
| 1257 | if( bWrap )
|
|---|
| 1258 | {
|
|---|
| 1259 | if ( !(btnPtr->fsStyle & TBSTYLE_SEP) )
|
|---|
| 1260 | y += cy;
|
|---|
| 1261 | else
|
|---|
| 1262 | {
|
|---|
| 1263 | /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
|
|---|
| 1264 | /* it is the actual width of the separator. This is used for */
|
|---|
| 1265 | /* custom controls in toolbars. */
|
|---|
| 1266 | if ( !(btnPtr->fsStyle & TBSTYLE_DROPDOWN))
|
|---|
| 1267 | y += cy + ( (btnPtr->iBitmap > 0 ) ?
|
|---|
| 1268 | btnPtr->iBitmap : SEPARATOR_WIDTH) * 2 /3;
|
|---|
| 1269 | else
|
|---|
| 1270 | y += cy;
|
|---|
| 1271 |
|
|---|
| 1272 | /* nSepRows is used to calculate the extra height follwoing */
|
|---|
| 1273 | /* the last row. */
|
|---|
| 1274 | nSepRows++;
|
|---|
| 1275 | }
|
|---|
| 1276 | x = infoPtr->nIndent;
|
|---|
| 1277 | nRows++;
|
|---|
| 1278 | }
|
|---|
| 1279 | else
|
|---|
| 1280 | x += cx;
|
|---|
| 1281 | }
|
|---|
| 1282 |
|
|---|
| 1283 | /* infoPtr->nRows is the number of rows on the toolbar */
|
|---|
| 1284 | infoPtr->nRows = nRows + nSepRows + 1;
|
|---|
| 1285 |
|
|---|
| 1286 | /* nSepRows * (infoPtr->nBitmapHeight + 1) is the space following */
|
|---|
| 1287 | /* the last row. */
|
|---|
| 1288 | infoPtr->nHeight = TOP_BORDER + (nRows + 1) * infoPtr->nButtonHeight +
|
|---|
| 1289 | nSepRows * (SEPARATOR_WIDTH * 2 / 3) +
|
|---|
| 1290 | nSepRows * (infoPtr->nBitmapHeight + 1) +
|
|---|
| 1291 | BOTTOM_BORDER;
|
|---|
| 1292 | TRACE("toolbar height %d, button width %d\n", infoPtr->nHeight, infoPtr->nButtonWidth);
|
|---|
| 1293 | }
|
|---|
| 1294 |
|
|---|
| 1295 |
|
|---|
| 1296 | static INT
|
|---|
| 1297 | TOOLBAR_InternalHitTest (HWND hwnd, LPPOINT lpPt)
|
|---|
| 1298 | {
|
|---|
| 1299 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 1300 | TBUTTON_INFO *btnPtr;
|
|---|
| 1301 | INT i;
|
|---|
| 1302 |
|
|---|
| 1303 | btnPtr = infoPtr->buttons;
|
|---|
| 1304 | for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
|
|---|
| 1305 | if (btnPtr->fsState & TBSTATE_HIDDEN)
|
|---|
| 1306 | continue;
|
|---|
| 1307 |
|
|---|
| 1308 | if (btnPtr->fsStyle & TBSTYLE_SEP) {
|
|---|
| 1309 | if (PtInRect (&btnPtr->rect, *lpPt)) {
|
|---|
| 1310 | TRACE(" ON SEPARATOR %d!\n", i);
|
|---|
| 1311 | return -i;
|
|---|
| 1312 | }
|
|---|
| 1313 | }
|
|---|
| 1314 | else {
|
|---|
| 1315 | if (PtInRect (&btnPtr->rect, *lpPt)) {
|
|---|
| 1316 | TRACE(" ON BUTTON %d!\n", i);
|
|---|
| 1317 | return i;
|
|---|
| 1318 | }
|
|---|
| 1319 | }
|
|---|
| 1320 | }
|
|---|
| 1321 |
|
|---|
| 1322 | TRACE(" NOWHERE!\n");
|
|---|
| 1323 | return -1;
|
|---|
| 1324 | }
|
|---|
| 1325 |
|
|---|
| 1326 |
|
|---|
| 1327 | static INT
|
|---|
| 1328 | TOOLBAR_GetButtonIndex (TOOLBAR_INFO *infoPtr, INT idCommand, BOOL CommandIsIndex)
|
|---|
| 1329 | {
|
|---|
| 1330 | TBUTTON_INFO *btnPtr;
|
|---|
| 1331 | INT i;
|
|---|
| 1332 |
|
|---|
| 1333 | if (CommandIsIndex) {
|
|---|
| 1334 | TRACE("command is really index command=%d\n", idCommand);
|
|---|
| 1335 | return idCommand;
|
|---|
| 1336 | }
|
|---|
| 1337 | btnPtr = infoPtr->buttons;
|
|---|
| 1338 | for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
|
|---|
| 1339 | if (btnPtr->idCommand == idCommand) {
|
|---|
| 1340 | TRACE("command=%d index=%d\n", idCommand, i);
|
|---|
| 1341 | return i;
|
|---|
| 1342 | }
|
|---|
| 1343 | }
|
|---|
| 1344 | TRACE("no index found for command=%d\n", idCommand);
|
|---|
| 1345 | return -1;
|
|---|
| 1346 | }
|
|---|
| 1347 |
|
|---|
| 1348 |
|
|---|
| 1349 | static INT
|
|---|
| 1350 | TOOLBAR_GetCheckedGroupButtonIndex (TOOLBAR_INFO *infoPtr, INT nIndex)
|
|---|
| 1351 | {
|
|---|
| 1352 | TBUTTON_INFO *btnPtr;
|
|---|
| 1353 | INT nRunIndex;
|
|---|
| 1354 |
|
|---|
| 1355 | if ((nIndex < 0) || (nIndex > infoPtr->nNumButtons))
|
|---|
| 1356 | return -1;
|
|---|
| 1357 |
|
|---|
| 1358 | /* check index button */
|
|---|
| 1359 | btnPtr = &infoPtr->buttons[nIndex];
|
|---|
| 1360 | if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
|
|---|
| 1361 | if (btnPtr->fsState & TBSTATE_CHECKED)
|
|---|
| 1362 | return nIndex;
|
|---|
| 1363 | }
|
|---|
| 1364 |
|
|---|
| 1365 | /* check previous buttons */
|
|---|
| 1366 | nRunIndex = nIndex - 1;
|
|---|
| 1367 | while (nRunIndex >= 0) {
|
|---|
| 1368 | btnPtr = &infoPtr->buttons[nRunIndex];
|
|---|
| 1369 | if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
|
|---|
| 1370 | if (btnPtr->fsState & TBSTATE_CHECKED)
|
|---|
| 1371 | return nRunIndex;
|
|---|
| 1372 | }
|
|---|
| 1373 | else
|
|---|
| 1374 | break;
|
|---|
| 1375 | nRunIndex--;
|
|---|
| 1376 | }
|
|---|
| 1377 |
|
|---|
| 1378 | /* check next buttons */
|
|---|
| 1379 | nRunIndex = nIndex + 1;
|
|---|
| 1380 | while (nRunIndex < infoPtr->nNumButtons) {
|
|---|
| 1381 | btnPtr = &infoPtr->buttons[nRunIndex];
|
|---|
| 1382 | if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
|
|---|
| 1383 | if (btnPtr->fsState & TBSTATE_CHECKED)
|
|---|
| 1384 | return nRunIndex;
|
|---|
| 1385 | }
|
|---|
| 1386 | else
|
|---|
| 1387 | break;
|
|---|
| 1388 | nRunIndex++;
|
|---|
| 1389 | }
|
|---|
| 1390 |
|
|---|
| 1391 | return -1;
|
|---|
| 1392 | }
|
|---|
| 1393 |
|
|---|
| 1394 |
|
|---|
| 1395 | static VOID
|
|---|
| 1396 | TOOLBAR_RelayEvent (HWND hwndTip, HWND hwndMsg, UINT uMsg,
|
|---|
| 1397 | WPARAM wParam, LPARAM lParam)
|
|---|
| 1398 | {
|
|---|
| 1399 | MSG msg;
|
|---|
| 1400 |
|
|---|
| 1401 | msg.hwnd = hwndMsg;
|
|---|
| 1402 | msg.message = uMsg;
|
|---|
| 1403 | msg.wParam = wParam;
|
|---|
| 1404 | msg.lParam = lParam;
|
|---|
| 1405 | msg.time = GetMessageTime ();
|
|---|
| 1406 | msg.pt.x = LOWORD(GetMessagePos ());
|
|---|
| 1407 | msg.pt.y = HIWORD(GetMessagePos ());
|
|---|
| 1408 |
|
|---|
| 1409 | SendMessageA (hwndTip, TTM_RELAYEVENT, 0, (LPARAM)&msg);
|
|---|
| 1410 | }
|
|---|
| 1411 |
|
|---|
| 1412 |
|
|---|
| 1413 | /***********************************************************************
|
|---|
| 1414 | * TOOLBAR_CustomizeDialogProc
|
|---|
| 1415 | * This function implements the toolbar customization dialog.
|
|---|
| 1416 | */
|
|---|
| 1417 | static BOOL WINAPI
|
|---|
| 1418 | TOOLBAR_CustomizeDialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|---|
| 1419 | {
|
|---|
| 1420 | PCUSTDLG_INFO custInfo = (PCUSTDLG_INFO)GetWindowLongA (hwnd, DWL_USER);
|
|---|
| 1421 | PCUSTOMBUTTON btnInfo;
|
|---|
| 1422 | NMTOOLBARA nmtb;
|
|---|
| 1423 | TOOLBAR_INFO *infoPtr = custInfo ? custInfo->tbInfo : NULL;
|
|---|
| 1424 |
|
|---|
| 1425 | switch (uMsg)
|
|---|
| 1426 | {
|
|---|
| 1427 | case WM_INITDIALOG:
|
|---|
| 1428 | custInfo = (PCUSTDLG_INFO)lParam;
|
|---|
| 1429 | SetWindowLongA (hwnd, DWL_USER, (DWORD)custInfo);
|
|---|
| 1430 |
|
|---|
| 1431 | if (custInfo)
|
|---|
| 1432 | {
|
|---|
| 1433 | char Buffer[256];
|
|---|
| 1434 | int i = 0;
|
|---|
| 1435 | int index;
|
|---|
| 1436 |
|
|---|
| 1437 | infoPtr = custInfo->tbInfo;
|
|---|
| 1438 |
|
|---|
| 1439 | /* send TBN_QUERYINSERT notification */
|
|---|
| 1440 | nmtb.iItem = custInfo->tbInfo->nNumButtons;
|
|---|
| 1441 |
|
|---|
| 1442 | if (!TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr, TBN_QUERYINSERT))
|
|---|
| 1443 | return FALSE;
|
|---|
| 1444 |
|
|---|
| 1445 | /* add items to 'toolbar buttons' list and check if removable */
|
|---|
| 1446 | for (i = 0; i < custInfo->tbInfo->nNumButtons; i++)
|
|---|
| 1447 | {
|
|---|
| 1448 | btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
|
|---|
| 1449 | memset (&btnInfo->btn, 0, sizeof(TBBUTTON));
|
|---|
| 1450 | btnInfo->btn.fsStyle = TBSTYLE_SEP;
|
|---|
| 1451 | btnInfo->bVirtual = FALSE;
|
|---|
| 1452 | LoadStringA (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64);
|
|---|
| 1453 |
|
|---|
| 1454 | /* send TBN_QUERYDELETE notification */
|
|---|
| 1455 | nmtb.iItem = i;
|
|---|
| 1456 | btnInfo->bRemovable = TOOLBAR_SendNotify ((NMHDR *) &nmtb,
|
|---|
| 1457 | infoPtr,
|
|---|
| 1458 | TBN_QUERYDELETE);
|
|---|
| 1459 |
|
|---|
| 1460 | index = (int)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_ADDSTRING, 0, 0);
|
|---|
| 1461 | SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
|
|---|
| 1462 | }
|
|---|
| 1463 |
|
|---|
| 1464 | /* insert separator button into 'available buttons' list */
|
|---|
| 1465 | btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
|
|---|
| 1466 | memset (&btnInfo->btn, 0, sizeof(TBBUTTON));
|
|---|
| 1467 | btnInfo->btn.fsStyle = TBSTYLE_SEP;
|
|---|
| 1468 | btnInfo->bVirtual = FALSE;
|
|---|
| 1469 | btnInfo->bRemovable = TRUE;
|
|---|
| 1470 | LoadStringA (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64);
|
|---|
| 1471 | index = (int)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)btnInfo);
|
|---|
| 1472 | SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
|
|---|
| 1473 |
|
|---|
| 1474 | /* insert all buttons into dsa */
|
|---|
| 1475 | for (i = 0;; i++)
|
|---|
| 1476 | {
|
|---|
| 1477 | /* send TBN_GETBUTTONINFO notification */
|
|---|
| 1478 | nmtb.iItem = i;
|
|---|
| 1479 | nmtb.pszText = Buffer;
|
|---|
| 1480 | nmtb.cchText = 256;
|
|---|
| 1481 |
|
|---|
| 1482 | if (!TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr, TBN_GETBUTTONINFOA))
|
|---|
| 1483 | break;
|
|---|
| 1484 |
|
|---|
| 1485 | TRACE("style: %x\n", nmtb.tbButton.fsStyle);
|
|---|
| 1486 |
|
|---|
| 1487 | /* insert button into the apropriate list */
|
|---|
| 1488 | index = TOOLBAR_GetButtonIndex (custInfo->tbInfo, nmtb.tbButton.idCommand, FALSE);
|
|---|
| 1489 | if (index == -1)
|
|---|
| 1490 | {
|
|---|
| 1491 | btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
|
|---|
| 1492 | memcpy (&btnInfo->btn, &nmtb.tbButton, sizeof(TBBUTTON));
|
|---|
| 1493 | btnInfo->bVirtual = FALSE;
|
|---|
| 1494 | btnInfo->bRemovable = TRUE;
|
|---|
| 1495 | if (!(nmtb.tbButton.fsStyle & TBSTYLE_SEP))
|
|---|
| 1496 | strcpy (btnInfo->text, nmtb.pszText);
|
|---|
| 1497 |
|
|---|
| 1498 | index = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, 0);
|
|---|
| 1499 | SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
|
|---|
| 1500 | }
|
|---|
| 1501 | else
|
|---|
| 1502 | {
|
|---|
| 1503 | btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
|
|---|
| 1504 | memcpy (&btnInfo->btn, &nmtb.tbButton, sizeof(TBBUTTON));
|
|---|
| 1505 | if (!(nmtb.tbButton.fsStyle & TBSTYLE_SEP))
|
|---|
| 1506 | strcpy (btnInfo->text, nmtb.pszText);
|
|---|
| 1507 |
|
|---|
| 1508 | SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
|
|---|
| 1509 | }
|
|---|
| 1510 | }
|
|---|
| 1511 |
|
|---|
| 1512 | /* select first item in the 'available' list */
|
|---|
| 1513 | SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, 0, 0);
|
|---|
| 1514 |
|
|---|
| 1515 | /* append 'virtual' separator button to the 'toolbar buttons' list */
|
|---|
| 1516 | btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
|
|---|
| 1517 | memset (&btnInfo->btn, 0, sizeof(TBBUTTON));
|
|---|
| 1518 | btnInfo->btn.fsStyle = TBSTYLE_SEP;
|
|---|
| 1519 | btnInfo->bVirtual = TRUE;
|
|---|
| 1520 | btnInfo->bRemovable = FALSE;
|
|---|
| 1521 | LoadStringA (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64);
|
|---|
| 1522 | index = (int)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)btnInfo);
|
|---|
| 1523 | SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
|
|---|
| 1524 |
|
|---|
| 1525 | /* select last item in the 'toolbar' list */
|
|---|
| 1526 | SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index, 0);
|
|---|
| 1527 | SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETTOPINDEX, index, 0);
|
|---|
| 1528 |
|
|---|
| 1529 | /* set focus and disable buttons */
|
|---|
| 1530 | PostMessageA (hwnd, WM_USER, 0, 0);
|
|---|
| 1531 | }
|
|---|
| 1532 | return TRUE;
|
|---|
| 1533 |
|
|---|
| 1534 | case WM_USER:
|
|---|
| 1535 | EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
|
|---|
| 1536 | EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
|
|---|
| 1537 | EnableWindow (GetDlgItem (hwnd,IDC_REMOVE_BTN), FALSE);
|
|---|
| 1538 | SetFocus (GetDlgItem (hwnd, IDC_TOOLBARBTN_LBOX));
|
|---|
| 1539 | return TRUE;
|
|---|
| 1540 |
|
|---|
| 1541 | case WM_CLOSE:
|
|---|
| 1542 | EndDialog(hwnd, FALSE);
|
|---|
| 1543 | return TRUE;
|
|---|
| 1544 |
|
|---|
| 1545 | case WM_COMMAND:
|
|---|
| 1546 | switch (LOWORD(wParam))
|
|---|
| 1547 | {
|
|---|
| 1548 | case IDC_TOOLBARBTN_LBOX:
|
|---|
| 1549 | if (HIWORD(wParam) == LBN_SELCHANGE)
|
|---|
| 1550 | {
|
|---|
| 1551 | PCUSTOMBUTTON btnInfo;
|
|---|
| 1552 | NMTOOLBARA nmtb;
|
|---|
| 1553 | int count;
|
|---|
| 1554 | int index;
|
|---|
| 1555 |
|
|---|
| 1556 | count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
|
|---|
| 1557 | index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
|
|---|
| 1558 |
|
|---|
| 1559 | /* send TBN_QUERYINSERT notification */
|
|---|
| 1560 | nmtb.iItem = index;
|
|---|
| 1561 | TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
|
|---|
| 1562 | TBN_QUERYINSERT);
|
|---|
| 1563 |
|
|---|
| 1564 | /* get list box item */
|
|---|
| 1565 | btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
|
|---|
| 1566 |
|
|---|
| 1567 | if (index == (count - 1))
|
|---|
| 1568 | {
|
|---|
| 1569 | /* last item (virtual separator) */
|
|---|
| 1570 | EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
|
|---|
| 1571 | EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
|
|---|
| 1572 | }
|
|---|
| 1573 | else if (index == (count - 2))
|
|---|
| 1574 | {
|
|---|
| 1575 | /* second last item (last non-virtual item) */
|
|---|
| 1576 | EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE);
|
|---|
| 1577 | EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
|
|---|
| 1578 | }
|
|---|
| 1579 | else if (index == 0)
|
|---|
| 1580 | {
|
|---|
| 1581 | /* first item */
|
|---|
| 1582 | EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
|
|---|
| 1583 | EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE);
|
|---|
| 1584 | }
|
|---|
| 1585 | else
|
|---|
| 1586 | {
|
|---|
| 1587 | EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE);
|
|---|
| 1588 | EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE);
|
|---|
| 1589 | }
|
|---|
| 1590 |
|
|---|
| 1591 | EnableWindow (GetDlgItem (hwnd,IDC_REMOVE_BTN), btnInfo->bRemovable);
|
|---|
| 1592 | }
|
|---|
| 1593 | break;
|
|---|
| 1594 |
|
|---|
| 1595 | case IDC_MOVEUP_BTN:
|
|---|
| 1596 | {
|
|---|
| 1597 | PCUSTOMBUTTON btnInfo;
|
|---|
| 1598 | int index;
|
|---|
| 1599 | int count;
|
|---|
| 1600 |
|
|---|
| 1601 | count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
|
|---|
| 1602 | index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
|
|---|
| 1603 | TRACE("Move up: index %d\n", index);
|
|---|
| 1604 |
|
|---|
| 1605 | /* send TBN_QUERYINSERT notification */
|
|---|
| 1606 | nmtb.iItem = index;
|
|---|
| 1607 |
|
|---|
| 1608 | if (TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
|
|---|
| 1609 | TBN_QUERYINSERT))
|
|---|
| 1610 | {
|
|---|
| 1611 | btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
|
|---|
| 1612 |
|
|---|
| 1613 | SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0);
|
|---|
| 1614 | SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index-1, 0);
|
|---|
| 1615 | SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index-1, (LPARAM)btnInfo);
|
|---|
| 1616 | SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index-1 , 0);
|
|---|
| 1617 |
|
|---|
| 1618 | if (index <= 1)
|
|---|
| 1619 | EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
|
|---|
| 1620 | else if (index >= (count - 3))
|
|---|
| 1621 | EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE);
|
|---|
| 1622 |
|
|---|
| 1623 | SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0);
|
|---|
| 1624 | SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index-1, (LPARAM)&(btnInfo->btn));
|
|---|
| 1625 | }
|
|---|
| 1626 | }
|
|---|
| 1627 | break;
|
|---|
| 1628 |
|
|---|
| 1629 | case IDC_MOVEDN_BTN: /* move down */
|
|---|
| 1630 | {
|
|---|
| 1631 | PCUSTOMBUTTON btnInfo;
|
|---|
| 1632 | int index;
|
|---|
| 1633 | int count;
|
|---|
| 1634 |
|
|---|
| 1635 | count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
|
|---|
| 1636 | index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
|
|---|
| 1637 | TRACE("Move up: index %d\n", index);
|
|---|
| 1638 |
|
|---|
| 1639 | /* send TBN_QUERYINSERT notification */
|
|---|
| 1640 | nmtb.iItem = index;
|
|---|
| 1641 | if (TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
|
|---|
| 1642 | TBN_QUERYINSERT))
|
|---|
| 1643 | {
|
|---|
| 1644 | btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
|
|---|
| 1645 |
|
|---|
| 1646 | /* move button down */
|
|---|
| 1647 | SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0);
|
|---|
| 1648 | SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index+1, 0);
|
|---|
| 1649 | SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index+1, (LPARAM)btnInfo);
|
|---|
| 1650 | SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index+1 , 0);
|
|---|
| 1651 |
|
|---|
| 1652 | if (index == 0)
|
|---|
| 1653 | EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE);
|
|---|
| 1654 | else if (index >= (count - 3))
|
|---|
| 1655 | EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
|
|---|
| 1656 |
|
|---|
| 1657 | SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0);
|
|---|
| 1658 | SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index+1, (LPARAM)&(btnInfo->btn));
|
|---|
| 1659 | }
|
|---|
| 1660 | }
|
|---|
| 1661 | break;
|
|---|
| 1662 |
|
|---|
| 1663 | case IDC_REMOVE_BTN: /* remove button */
|
|---|
| 1664 | {
|
|---|
| 1665 | PCUSTOMBUTTON btnInfo;
|
|---|
| 1666 | int index;
|
|---|
| 1667 |
|
|---|
| 1668 | index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
|
|---|
| 1669 | TRACE("Remove: index %d\n", index);
|
|---|
| 1670 |
|
|---|
| 1671 | /* send TBN_QUERYDELETE notification */
|
|---|
| 1672 | nmtb.iItem = index;
|
|---|
| 1673 | if (TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
|
|---|
| 1674 | TBN_QUERYDELETE))
|
|---|
| 1675 | {
|
|---|
| 1676 | btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
|
|---|
| 1677 | SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0);
|
|---|
| 1678 | SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index , 0);
|
|---|
| 1679 |
|
|---|
| 1680 | SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0);
|
|---|
| 1681 |
|
|---|
| 1682 | /* insert into 'available button' list */
|
|---|
| 1683 | if (!(btnInfo->btn.fsStyle & TBSTYLE_SEP))
|
|---|
| 1684 | {
|
|---|
| 1685 | index = (int)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, 0);
|
|---|
| 1686 | SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
|
|---|
| 1687 | }
|
|---|
| 1688 | else
|
|---|
| 1689 | COMCTL32_Free (btnInfo);
|
|---|
| 1690 | }
|
|---|
| 1691 | }
|
|---|
| 1692 | break;
|
|---|
| 1693 |
|
|---|
| 1694 | case IDOK: /* Add button */
|
|---|
| 1695 | {
|
|---|
| 1696 | int index;
|
|---|
| 1697 | int count;
|
|---|
| 1698 |
|
|---|
| 1699 | count = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCOUNT, 0, 0);
|
|---|
| 1700 | index = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCURSEL, 0, 0);
|
|---|
| 1701 | TRACE("Add: index %d\n", index);
|
|---|
| 1702 |
|
|---|
| 1703 | /* send TBN_QUERYINSERT notification */
|
|---|
| 1704 | nmtb.iItem = index;
|
|---|
| 1705 | if (TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
|
|---|
| 1706 | TBN_QUERYINSERT))
|
|---|
| 1707 | {
|
|---|
| 1708 | btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETITEMDATA, index, 0);
|
|---|
| 1709 |
|
|---|
| 1710 | if (index != 0)
|
|---|
| 1711 | {
|
|---|
| 1712 | /* remove from 'available buttons' list */
|
|---|
| 1713 | SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_DELETESTRING, index, 0);
|
|---|
| 1714 | if (index == count-1)
|
|---|
| 1715 | SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, index-1 , 0);
|
|---|
| 1716 | else
|
|---|
| 1717 | SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, index , 0);
|
|---|
| 1718 | }
|
|---|
| 1719 | else
|
|---|
| 1720 | {
|
|---|
| 1721 | PCUSTOMBUTTON btnNew;
|
|---|
| 1722 |
|
|---|
| 1723 | /* duplicate 'separator' button */
|
|---|
| 1724 | btnNew = (PCUSTOMBUTTON)COMCTL32_Alloc (sizeof(CUSTOMBUTTON));
|
|---|
| 1725 | memcpy (btnNew, btnInfo, sizeof(CUSTOMBUTTON));
|
|---|
| 1726 | btnInfo = btnNew;
|
|---|
| 1727 | }
|
|---|
| 1728 |
|
|---|
| 1729 | /* insert into 'toolbar button' list */
|
|---|
| 1730 | index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
|
|---|
| 1731 | SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index, 0);
|
|---|
| 1732 | SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
|
|---|
| 1733 |
|
|---|
| 1734 | SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index, (LPARAM)&(btnInfo->btn));
|
|---|
| 1735 | }
|
|---|
| 1736 | }
|
|---|
| 1737 | break;
|
|---|
| 1738 |
|
|---|
| 1739 | case IDCANCEL:
|
|---|
| 1740 | EndDialog(hwnd, FALSE);
|
|---|
| 1741 | break;
|
|---|
| 1742 | }
|
|---|
| 1743 | return TRUE;
|
|---|
| 1744 |
|
|---|
| 1745 | case WM_DESTROY:
|
|---|
| 1746 | {
|
|---|
| 1747 | int count;
|
|---|
| 1748 | int i;
|
|---|
| 1749 |
|
|---|
| 1750 | /* delete items from 'toolbar buttons' listbox*/
|
|---|
| 1751 | count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
|
|---|
| 1752 | for (i = 0; i < count; i++)
|
|---|
| 1753 | {
|
|---|
| 1754 | btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, i, 0);
|
|---|
| 1755 | COMCTL32_Free(btnInfo);
|
|---|
| 1756 | SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, 0, 0);
|
|---|
| 1757 | }
|
|---|
| 1758 | SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_RESETCONTENT, 0, 0);
|
|---|
| 1759 |
|
|---|
| 1760 |
|
|---|
| 1761 | /* delete items from 'available buttons' listbox*/
|
|---|
| 1762 | count = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCOUNT, 0, 0);
|
|---|
| 1763 | for (i = 0; i < count; i++)
|
|---|
| 1764 | {
|
|---|
| 1765 | btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETITEMDATA, i, 0);
|
|---|
| 1766 | COMCTL32_Free(btnInfo);
|
|---|
| 1767 | SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, i, 0);
|
|---|
| 1768 | }
|
|---|
| 1769 | SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_RESETCONTENT, 0, 0);
|
|---|
| 1770 | }
|
|---|
| 1771 | return TRUE;
|
|---|
| 1772 |
|
|---|
| 1773 | case WM_DRAWITEM:
|
|---|
| 1774 | if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX)
|
|---|
| 1775 | {
|
|---|
| 1776 | LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
|
|---|
| 1777 | RECT rcButton;
|
|---|
| 1778 | RECT rcText;
|
|---|
| 1779 | HPEN hOldPen;
|
|---|
| 1780 | HBRUSH hOldBrush;
|
|---|
| 1781 | COLORREF oldText = 0;
|
|---|
| 1782 | COLORREF oldBk = 0;
|
|---|
| 1783 |
|
|---|
| 1784 | /* get item data */
|
|---|
| 1785 | btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, wParam, LB_GETITEMDATA, (WPARAM)lpdis->itemID, 0);
|
|---|
| 1786 | if (btnInfo == NULL)
|
|---|
| 1787 | {
|
|---|
| 1788 | FIXME("btnInfo invalid!\n");
|
|---|
| 1789 | return TRUE;
|
|---|
| 1790 | }
|
|---|
| 1791 |
|
|---|
| 1792 | /* set colors and select objects */
|
|---|
| 1793 | oldBk = SetBkColor (lpdis->hDC, GetSysColor((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW));
|
|---|
| 1794 | if (btnInfo->bVirtual)
|
|---|
| 1795 | oldText = SetTextColor (lpdis->hDC, GetSysColor(COLOR_GRAYTEXT));
|
|---|
| 1796 | else
|
|---|
| 1797 | oldText = SetTextColor (lpdis->hDC, GetSysColor((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHTTEXT:COLOR_WINDOWTEXT));
|
|---|
| 1798 | hOldPen = SelectObject (lpdis->hDC, GetSysColorPen ((lpdis->itemState & ODS_SELECTED)?COLOR_HIGHLIGHT:COLOR_WINDOW));
|
|---|
| 1799 | hOldBrush = SelectObject (lpdis->hDC, GetSysColorBrush ((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW));
|
|---|
| 1800 |
|
|---|
| 1801 | /* fill background rectangle */
|
|---|
| 1802 | Rectangle (lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top,
|
|---|
| 1803 | lpdis->rcItem.right, lpdis->rcItem.bottom);
|
|---|
| 1804 |
|
|---|
| 1805 | /* calculate button and text rectangles */
|
|---|
| 1806 | CopyRect (&rcButton, &lpdis->rcItem);
|
|---|
| 1807 | InflateRect (&rcButton, -1, -1);
|
|---|
| 1808 | CopyRect (&rcText, &rcButton);
|
|---|
| 1809 | rcButton.right = rcButton.left + custInfo->tbInfo->nBitmapWidth + 6;
|
|---|
| 1810 | rcText.left = rcButton.right + 2;
|
|---|
| 1811 |
|
|---|
| 1812 | /* draw focus rectangle */
|
|---|
| 1813 | if (lpdis->itemState & ODS_FOCUS)
|
|---|
| 1814 | DrawFocusRect (lpdis->hDC, &lpdis->rcItem);
|
|---|
| 1815 |
|
|---|
| 1816 | /* draw button */
|
|---|
| 1817 | DrawEdge (lpdis->hDC, &rcButton, EDGE_RAISED, BF_RECT|BF_MIDDLE|BF_SOFT);
|
|---|
| 1818 |
|
|---|
| 1819 | /* draw image and text */
|
|---|
| 1820 | if ((btnInfo->btn.fsStyle & TBSTYLE_SEP) == 0)
|
|---|
| 1821 | ImageList_Draw (custInfo->tbInfo->himlDef, btnInfo->btn.iBitmap, lpdis->hDC,
|
|---|
| 1822 | rcButton.left+3, rcButton.top+3, ILD_NORMAL);
|
|---|
| 1823 | DrawTextA (lpdis->hDC, btnInfo->text, -1, &rcText,
|
|---|
| 1824 | DT_LEFT | DT_VCENTER | DT_SINGLELINE);
|
|---|
| 1825 |
|
|---|
| 1826 | /* delete objects and reset colors */
|
|---|
| 1827 | SelectObject (lpdis->hDC, hOldBrush);
|
|---|
| 1828 | SelectObject (lpdis->hDC, hOldPen);
|
|---|
| 1829 | SetBkColor (lpdis->hDC, oldBk);
|
|---|
| 1830 | SetTextColor (lpdis->hDC, oldText);
|
|---|
| 1831 |
|
|---|
| 1832 | return TRUE;
|
|---|
| 1833 | }
|
|---|
| 1834 | return FALSE;
|
|---|
| 1835 |
|
|---|
| 1836 | case WM_MEASUREITEM:
|
|---|
| 1837 | if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX)
|
|---|
| 1838 | {
|
|---|
| 1839 | MEASUREITEMSTRUCT *lpmis = (MEASUREITEMSTRUCT*)lParam;
|
|---|
| 1840 |
|
|---|
| 1841 | if (custInfo && custInfo->tbInfo)
|
|---|
| 1842 | lpmis->itemHeight = custInfo->tbInfo->nBitmapHeight + 8;
|
|---|
| 1843 | else
|
|---|
| 1844 | lpmis->itemHeight = 15 + 8; /* default height */
|
|---|
| 1845 |
|
|---|
| 1846 | return TRUE;
|
|---|
| 1847 | }
|
|---|
| 1848 | return FALSE;
|
|---|
| 1849 |
|
|---|
| 1850 | default:
|
|---|
| 1851 | return FALSE;
|
|---|
| 1852 | }
|
|---|
| 1853 | }
|
|---|
| 1854 |
|
|---|
| 1855 |
|
|---|
| 1856 | /***********************************************************************
|
|---|
| 1857 | * TOOLBAR_AddBitmap: Add the bitmaps to the default image list.
|
|---|
| 1858 | *
|
|---|
| 1859 | */
|
|---|
| 1860 | static LRESULT
|
|---|
| 1861 | TOOLBAR_AddBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 1862 | {
|
|---|
| 1863 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 1864 | LPTBADDBITMAP lpAddBmp = (LPTBADDBITMAP)lParam;
|
|---|
| 1865 | INT nIndex = 0, nButtons, nCount;
|
|---|
| 1866 | HBITMAP hbmLoad;
|
|---|
| 1867 |
|
|---|
| 1868 | TRACE("hwnd=%x wParam=%x lParam=%lx\n", hwnd, wParam, lParam);
|
|---|
| 1869 | if (!lpAddBmp)
|
|---|
| 1870 | return -1;
|
|---|
| 1871 |
|
|---|
| 1872 | if (lpAddBmp->hInst == HINST_COMMCTRL)
|
|---|
| 1873 | {
|
|---|
| 1874 | if ((lpAddBmp->nID & ~1) == IDB_STD_SMALL_COLOR)
|
|---|
| 1875 | nButtons = 15;
|
|---|
| 1876 | else if ((lpAddBmp->nID & ~1) == IDB_VIEW_SMALL_COLOR)
|
|---|
| 1877 | nButtons = 13;
|
|---|
| 1878 | else if ((lpAddBmp->nID & ~1) == IDB_HIST_SMALL_COLOR)
|
|---|
| 1879 | nButtons = 5;
|
|---|
| 1880 | else
|
|---|
| 1881 | return -1;
|
|---|
| 1882 |
|
|---|
| 1883 | TRACE ("adding %d internal bitmaps!\n", nButtons);
|
|---|
| 1884 |
|
|---|
| 1885 | /* Windows resize all the buttons to the size of a newly added standard image */
|
|---|
| 1886 | if (lpAddBmp->nID & 1)
|
|---|
| 1887 | {
|
|---|
| 1888 | /* large icons */
|
|---|
| 1889 | /* FIXME: on windows the size of the images is 25x24 but the size of the bitmap
|
|---|
| 1890 | * in rsrc is only 24x24. Fix the bitmap (how?) and then fix this
|
|---|
| 1891 | */
|
|---|
| 1892 | SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
|
|---|
| 1893 | MAKELPARAM((WORD)24, (WORD)24));
|
|---|
| 1894 | SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
|
|---|
| 1895 | MAKELPARAM((WORD)31, (WORD)30));
|
|---|
| 1896 | }
|
|---|
| 1897 | else
|
|---|
| 1898 | {
|
|---|
| 1899 | /* small icons */
|
|---|
| 1900 | SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
|
|---|
| 1901 | MAKELPARAM((WORD)16, (WORD)16));
|
|---|
| 1902 | SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
|
|---|
| 1903 | MAKELPARAM((WORD)22, (WORD)22));
|
|---|
| 1904 | }
|
|---|
| 1905 |
|
|---|
| 1906 | TOOLBAR_CalcToolbar (hwnd);
|
|---|
| 1907 | }
|
|---|
| 1908 | else
|
|---|
| 1909 | {
|
|---|
| 1910 | nButtons = (INT)wParam;
|
|---|
| 1911 | if (nButtons <= 0)
|
|---|
| 1912 | return -1;
|
|---|
| 1913 |
|
|---|
| 1914 | TRACE ("adding %d bitmaps!\n", nButtons);
|
|---|
| 1915 | }
|
|---|
| 1916 |
|
|---|
| 1917 | if (!(infoPtr->himlDef)) {
|
|---|
| 1918 | /* create new default image list */
|
|---|
| 1919 | TRACE ("creating default image list!\n");
|
|---|
| 1920 |
|
|---|
| 1921 | infoPtr->himlDef =
|
|---|
| 1922 | ImageList_Create (infoPtr->nBitmapWidth, infoPtr->nBitmapHeight,
|
|---|
| 1923 | ILC_COLOR | ILC_MASK, nButtons, 2);
|
|---|
| 1924 | infoPtr->himlInt = infoPtr->himlDef;
|
|---|
| 1925 | }
|
|---|
| 1926 |
|
|---|
| 1927 | nCount = ImageList_GetImageCount(infoPtr->himlDef);
|
|---|
| 1928 |
|
|---|
| 1929 | /* Add bitmaps to the default image list */
|
|---|
| 1930 | if (lpAddBmp->hInst == (HINSTANCE)0)
|
|---|
| 1931 | {
|
|---|
| 1932 | nIndex =
|
|---|
| 1933 | ImageList_AddMasked (infoPtr->himlDef, (HBITMAP)lpAddBmp->nID,
|
|---|
| 1934 | CLR_DEFAULT);
|
|---|
| 1935 | }
|
|---|
| 1936 | else if (lpAddBmp->hInst == HINST_COMMCTRL)
|
|---|
| 1937 | {
|
|---|
| 1938 | /* Add system bitmaps */
|
|---|
| 1939 | switch (lpAddBmp->nID)
|
|---|
| 1940 | {
|
|---|
| 1941 | case IDB_STD_SMALL_COLOR:
|
|---|
| 1942 | hbmLoad = LoadBitmapA (COMCTL32_hModule,
|
|---|
| 1943 | MAKEINTRESOURCEA(IDB_STD_SMALL));
|
|---|
| 1944 | nIndex = ImageList_AddMasked (infoPtr->himlDef,
|
|---|
| 1945 | hbmLoad, CLR_DEFAULT);
|
|---|
| 1946 | DeleteObject (hbmLoad);
|
|---|
| 1947 | break;
|
|---|
| 1948 |
|
|---|
| 1949 | case IDB_STD_LARGE_COLOR:
|
|---|
| 1950 | hbmLoad = LoadBitmapA (COMCTL32_hModule,
|
|---|
| 1951 | MAKEINTRESOURCEA(IDB_STD_LARGE));
|
|---|
| 1952 | nIndex = ImageList_AddMasked (infoPtr->himlDef,
|
|---|
| 1953 | hbmLoad, CLR_DEFAULT);
|
|---|
| 1954 | DeleteObject (hbmLoad);
|
|---|
| 1955 | break;
|
|---|
| 1956 |
|
|---|
| 1957 | case IDB_VIEW_SMALL_COLOR:
|
|---|
| 1958 | hbmLoad = LoadBitmapA (COMCTL32_hModule,
|
|---|
| 1959 | MAKEINTRESOURCEA(IDB_VIEW_SMALL));
|
|---|
| 1960 | nIndex = ImageList_AddMasked (infoPtr->himlDef,
|
|---|
| 1961 | hbmLoad, CLR_DEFAULT);
|
|---|
| 1962 | DeleteObject (hbmLoad);
|
|---|
| 1963 | break;
|
|---|
| 1964 |
|
|---|
| 1965 | case IDB_VIEW_LARGE_COLOR:
|
|---|
| 1966 | hbmLoad = LoadBitmapA (COMCTL32_hModule,
|
|---|
| 1967 | MAKEINTRESOURCEA(IDB_VIEW_LARGE));
|
|---|
| 1968 | nIndex = ImageList_AddMasked (infoPtr->himlDef,
|
|---|
| 1969 | hbmLoad, CLR_DEFAULT);
|
|---|
| 1970 | DeleteObject (hbmLoad);
|
|---|
| 1971 | break;
|
|---|
| 1972 |
|
|---|
| 1973 | case IDB_HIST_SMALL_COLOR:
|
|---|
| 1974 | hbmLoad = LoadBitmapA (COMCTL32_hModule,
|
|---|
| 1975 | MAKEINTRESOURCEA(IDB_HIST_SMALL));
|
|---|
| 1976 | nIndex = ImageList_AddMasked (infoPtr->himlDef,
|
|---|
| 1977 | hbmLoad, CLR_DEFAULT);
|
|---|
| 1978 | DeleteObject (hbmLoad);
|
|---|
| 1979 | break;
|
|---|
| 1980 |
|
|---|
| 1981 | case IDB_HIST_LARGE_COLOR:
|
|---|
| 1982 | hbmLoad = LoadBitmapA (COMCTL32_hModule,
|
|---|
| 1983 | MAKEINTRESOURCEA(IDB_HIST_LARGE));
|
|---|
| 1984 | nIndex = ImageList_AddMasked (infoPtr->himlDef,
|
|---|
| 1985 | hbmLoad, CLR_DEFAULT);
|
|---|
| 1986 | DeleteObject (hbmLoad);
|
|---|
| 1987 | break;
|
|---|
| 1988 |
|
|---|
| 1989 | default:
|
|---|
| 1990 | nIndex = ImageList_GetImageCount (infoPtr->himlDef);
|
|---|
| 1991 | ERR ("invalid imagelist!\n");
|
|---|
| 1992 | break;
|
|---|
| 1993 | }
|
|---|
| 1994 | }
|
|---|
| 1995 | else
|
|---|
| 1996 | {
|
|---|
| 1997 | hbmLoad = LoadBitmapA (lpAddBmp->hInst, (LPSTR)lpAddBmp->nID);
|
|---|
| 1998 | nIndex = ImageList_AddMasked (infoPtr->himlDef, hbmLoad, CLR_DEFAULT);
|
|---|
| 1999 | DeleteObject (hbmLoad);
|
|---|
| 2000 | }
|
|---|
| 2001 |
|
|---|
| 2002 | if (nIndex != -1)
|
|---|
| 2003 | {
|
|---|
| 2004 | INT imagecount = ImageList_GetImageCount(infoPtr->himlDef);
|
|---|
| 2005 |
|
|---|
| 2006 | if (infoPtr->nNumBitmaps + nButtons != imagecount)
|
|---|
| 2007 | {
|
|---|
| 2008 | WARN("Desired images do not match received images : Previous image number %i Previous images in list %i added %i expecting total %i, Images in list %i\n",
|
|---|
| 2009 | infoPtr->nNumBitmaps, nCount, imagecount - nCount,
|
|---|
| 2010 | infoPtr->nNumBitmaps+nButtons,imagecount);
|
|---|
| 2011 |
|
|---|
| 2012 | infoPtr->nNumBitmaps = imagecount;
|
|---|
| 2013 | }
|
|---|
| 2014 | else
|
|---|
| 2015 | infoPtr->nNumBitmaps += nButtons;
|
|---|
| 2016 | }
|
|---|
| 2017 |
|
|---|
| 2018 | InvalidateRect(hwnd, NULL, FALSE);
|
|---|
| 2019 |
|
|---|
| 2020 | return nIndex;
|
|---|
| 2021 | }
|
|---|
| 2022 |
|
|---|
| 2023 |
|
|---|
| 2024 | static LRESULT
|
|---|
| 2025 | TOOLBAR_AddButtonsA (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 2026 | {
|
|---|
| 2027 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 2028 | LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
|
|---|
| 2029 | INT nOldButtons, nNewButtons, nAddButtons, nCount;
|
|---|
| 2030 |
|
|---|
| 2031 | TRACE("adding %d buttons!\n", wParam);
|
|---|
| 2032 |
|
|---|
| 2033 | nAddButtons = (UINT)wParam;
|
|---|
| 2034 | nOldButtons = infoPtr->nNumButtons;
|
|---|
| 2035 | nNewButtons = nOldButtons + nAddButtons;
|
|---|
| 2036 |
|
|---|
| 2037 | if (infoPtr->nNumButtons == 0) {
|
|---|
| 2038 | infoPtr->buttons =
|
|---|
| 2039 | COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
|
|---|
| 2040 | }
|
|---|
| 2041 | else {
|
|---|
| 2042 | TBUTTON_INFO *oldButtons = infoPtr->buttons;
|
|---|
| 2043 | infoPtr->buttons =
|
|---|
| 2044 | COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
|
|---|
| 2045 | memcpy (&infoPtr->buttons[0], &oldButtons[0],
|
|---|
| 2046 | nOldButtons * sizeof(TBUTTON_INFO));
|
|---|
| 2047 | COMCTL32_Free (oldButtons);
|
|---|
| 2048 | }
|
|---|
| 2049 |
|
|---|
| 2050 | infoPtr->nNumButtons = nNewButtons;
|
|---|
| 2051 |
|
|---|
| 2052 | /* insert new button data */
|
|---|
| 2053 | for (nCount = 0; nCount < nAddButtons; nCount++) {
|
|---|
| 2054 | TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount];
|
|---|
| 2055 | btnPtr->iBitmap = lpTbb[nCount].iBitmap;
|
|---|
| 2056 | btnPtr->idCommand = lpTbb[nCount].idCommand;
|
|---|
| 2057 | btnPtr->fsState = lpTbb[nCount].fsState;
|
|---|
| 2058 | btnPtr->fsStyle = lpTbb[nCount].fsStyle;
|
|---|
| 2059 | btnPtr->dwData = lpTbb[nCount].dwData;
|
|---|
| 2060 | btnPtr->iString = lpTbb[nCount].iString;
|
|---|
| 2061 | btnPtr->bHot = FALSE;
|
|---|
| 2062 |
|
|---|
| 2063 | if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) {
|
|---|
| 2064 | TTTOOLINFOA ti;
|
|---|
| 2065 |
|
|---|
| 2066 | ZeroMemory (&ti, sizeof(TTTOOLINFOA));
|
|---|
| 2067 | ti.cbSize = sizeof (TTTOOLINFOA);
|
|---|
| 2068 | ti.hwnd = hwnd;
|
|---|
| 2069 | ti.uId = btnPtr->idCommand;
|
|---|
| 2070 | ti.hinst = 0;
|
|---|
| 2071 | ti.lpszText = LPSTR_TEXTCALLBACKA;
|
|---|
| 2072 |
|
|---|
| 2073 | SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
|
|---|
| 2074 | 0, (LPARAM)&ti);
|
|---|
| 2075 | }
|
|---|
| 2076 | }
|
|---|
| 2077 |
|
|---|
| 2078 | TOOLBAR_CalcToolbar (hwnd);
|
|---|
| 2079 |
|
|---|
| 2080 | TOOLBAR_DumpToolbar (infoPtr, __LINE__);
|
|---|
| 2081 |
|
|---|
| 2082 | InvalidateRect(hwnd, NULL, FALSE);
|
|---|
| 2083 |
|
|---|
| 2084 | return TRUE;
|
|---|
| 2085 | }
|
|---|
| 2086 |
|
|---|
| 2087 |
|
|---|
| 2088 | static LRESULT
|
|---|
| 2089 | TOOLBAR_AddButtonsW (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 2090 | {
|
|---|
| 2091 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 2092 | LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
|
|---|
| 2093 | INT nOldButtons, nNewButtons, nAddButtons, nCount;
|
|---|
| 2094 |
|
|---|
| 2095 | TRACE("adding %d buttons!\n", wParam);
|
|---|
| 2096 |
|
|---|
| 2097 | nAddButtons = (UINT)wParam;
|
|---|
| 2098 | nOldButtons = infoPtr->nNumButtons;
|
|---|
| 2099 | nNewButtons = nOldButtons + nAddButtons;
|
|---|
| 2100 |
|
|---|
| 2101 | if (infoPtr->nNumButtons == 0) {
|
|---|
| 2102 | infoPtr->buttons =
|
|---|
| 2103 | COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
|
|---|
| 2104 | }
|
|---|
| 2105 | else {
|
|---|
| 2106 | TBUTTON_INFO *oldButtons = infoPtr->buttons;
|
|---|
| 2107 | infoPtr->buttons =
|
|---|
| 2108 | COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
|
|---|
| 2109 | memcpy (&infoPtr->buttons[0], &oldButtons[0],
|
|---|
| 2110 | nOldButtons * sizeof(TBUTTON_INFO));
|
|---|
| 2111 | COMCTL32_Free (oldButtons);
|
|---|
| 2112 | }
|
|---|
| 2113 |
|
|---|
| 2114 | infoPtr->nNumButtons = nNewButtons;
|
|---|
| 2115 |
|
|---|
| 2116 | /* insert new button data */
|
|---|
| 2117 | for (nCount = 0; nCount < nAddButtons; nCount++) {
|
|---|
| 2118 | TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount];
|
|---|
| 2119 | btnPtr->iBitmap = lpTbb[nCount].iBitmap;
|
|---|
| 2120 | btnPtr->idCommand = lpTbb[nCount].idCommand;
|
|---|
| 2121 | btnPtr->fsState = lpTbb[nCount].fsState;
|
|---|
| 2122 | btnPtr->fsStyle = lpTbb[nCount].fsStyle;
|
|---|
| 2123 | btnPtr->dwData = lpTbb[nCount].dwData;
|
|---|
| 2124 | btnPtr->iString = lpTbb[nCount].iString;
|
|---|
| 2125 | btnPtr->bHot = FALSE;
|
|---|
| 2126 |
|
|---|
| 2127 | if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) {
|
|---|
| 2128 | TTTOOLINFOW ti;
|
|---|
| 2129 |
|
|---|
| 2130 | ZeroMemory (&ti, sizeof(TTTOOLINFOW));
|
|---|
| 2131 | ti.cbSize = sizeof (TTTOOLINFOW);
|
|---|
| 2132 | ti.hwnd = hwnd;
|
|---|
| 2133 | ti.uId = btnPtr->idCommand;
|
|---|
| 2134 | ti.hinst = 0;
|
|---|
| 2135 | ti.lpszText = LPSTR_TEXTCALLBACKW;
|
|---|
| 2136 |
|
|---|
| 2137 | SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW,
|
|---|
| 2138 | 0, (LPARAM)&ti);
|
|---|
| 2139 | }
|
|---|
| 2140 | }
|
|---|
| 2141 |
|
|---|
| 2142 | TOOLBAR_CalcToolbar (hwnd);
|
|---|
| 2143 |
|
|---|
| 2144 | TOOLBAR_DumpToolbar (infoPtr, __LINE__);
|
|---|
| 2145 |
|
|---|
| 2146 | InvalidateRect(hwnd, NULL, FALSE);
|
|---|
| 2147 |
|
|---|
| 2148 | return TRUE;
|
|---|
| 2149 | }
|
|---|
| 2150 |
|
|---|
| 2151 |
|
|---|
| 2152 | static LRESULT
|
|---|
| 2153 | TOOLBAR_AddStringA (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 2154 | {
|
|---|
| 2155 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 2156 | INT nIndex;
|
|---|
| 2157 |
|
|---|
| 2158 | if ((wParam) && (HIWORD(lParam) == 0)) {
|
|---|
| 2159 | char szString[256];
|
|---|
| 2160 | INT len;
|
|---|
| 2161 | TRACE("adding string from resource!\n");
|
|---|
| 2162 |
|
|---|
| 2163 | len = LoadStringA ((HINSTANCE)wParam, (UINT)lParam,
|
|---|
| 2164 | szString, 256);
|
|---|
| 2165 |
|
|---|
| 2166 | TRACE("len=%d \"%s\"\n", len, szString);
|
|---|
| 2167 | nIndex = infoPtr->nNumStrings;
|
|---|
| 2168 | if (infoPtr->nNumStrings == 0) {
|
|---|
| 2169 | infoPtr->strings =
|
|---|
| 2170 | COMCTL32_Alloc (sizeof(LPWSTR));
|
|---|
| 2171 | }
|
|---|
| 2172 | else {
|
|---|
| 2173 | LPWSTR *oldStrings = infoPtr->strings;
|
|---|
| 2174 | infoPtr->strings =
|
|---|
| 2175 | COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
|
|---|
| 2176 | memcpy (&infoPtr->strings[0], &oldStrings[0],
|
|---|
| 2177 | sizeof(LPWSTR) * infoPtr->nNumStrings);
|
|---|
| 2178 | COMCTL32_Free (oldStrings);
|
|---|
| 2179 | }
|
|---|
| 2180 |
|
|---|
| 2181 | /*COMCTL32_Alloc zeros out the allocated memory*/
|
|---|
| 2182 | Str_SetPtrAtoW (&infoPtr->strings[infoPtr->nNumStrings], szString );
|
|---|
| 2183 | infoPtr->nNumStrings++;
|
|---|
| 2184 | }
|
|---|
| 2185 | else {
|
|---|
| 2186 | LPSTR p = (LPSTR)lParam;
|
|---|
| 2187 | INT len;
|
|---|
| 2188 |
|
|---|
| 2189 | if (p == NULL)
|
|---|
| 2190 | return -1;
|
|---|
| 2191 | TRACE("adding string(s) from array!\n");
|
|---|
| 2192 |
|
|---|
| 2193 | nIndex = infoPtr->nNumStrings;
|
|---|
| 2194 | while (*p) {
|
|---|
| 2195 | len = strlen (p);
|
|---|
| 2196 | TRACE("len=%d \"%s\"\n", len, p);
|
|---|
| 2197 |
|
|---|
| 2198 | if (infoPtr->nNumStrings == 0) {
|
|---|
| 2199 | infoPtr->strings =
|
|---|
| 2200 | COMCTL32_Alloc (sizeof(LPWSTR));
|
|---|
| 2201 | }
|
|---|
| 2202 | else {
|
|---|
| 2203 | LPWSTR *oldStrings = infoPtr->strings;
|
|---|
| 2204 | infoPtr->strings =
|
|---|
| 2205 | COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
|
|---|
| 2206 | memcpy (&infoPtr->strings[0], &oldStrings[0],
|
|---|
| 2207 | sizeof(LPWSTR) * infoPtr->nNumStrings);
|
|---|
| 2208 | COMCTL32_Free (oldStrings);
|
|---|
| 2209 | }
|
|---|
| 2210 |
|
|---|
| 2211 | Str_SetPtrAtoW (&infoPtr->strings[infoPtr->nNumStrings], p );
|
|---|
| 2212 | infoPtr->nNumStrings++;
|
|---|
| 2213 |
|
|---|
| 2214 | p += (len+1);
|
|---|
| 2215 | }
|
|---|
| 2216 | }
|
|---|
| 2217 |
|
|---|
| 2218 | return nIndex;
|
|---|
| 2219 | }
|
|---|
| 2220 |
|
|---|
| 2221 |
|
|---|
| 2222 | static LRESULT
|
|---|
| 2223 | TOOLBAR_AddStringW (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 2224 | {
|
|---|
| 2225 | #define MAX_RESOURCE_STRING_LENGTH 512
|
|---|
| 2226 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 2227 | INT nIndex;
|
|---|
| 2228 |
|
|---|
| 2229 | if ((wParam) && (HIWORD(lParam) == 0)) {
|
|---|
| 2230 | WCHAR szString[MAX_RESOURCE_STRING_LENGTH];
|
|---|
| 2231 | INT len;
|
|---|
| 2232 | TRACE("adding string from resource!\n");
|
|---|
| 2233 |
|
|---|
| 2234 | len = LoadStringW ((HINSTANCE)wParam, (UINT)lParam,
|
|---|
| 2235 | szString, MAX_RESOURCE_STRING_LENGTH);
|
|---|
| 2236 |
|
|---|
| 2237 | TRACE("len=%d %s\n", len, debugstr_w(szString));
|
|---|
| 2238 | TRACE("First char: 0x%x\n", *szString);
|
|---|
| 2239 | if (szString[0] == L'|')
|
|---|
| 2240 | {
|
|---|
| 2241 | PWSTR p = szString + 1;
|
|---|
| 2242 |
|
|---|
| 2243 | nIndex = infoPtr->nNumStrings;
|
|---|
| 2244 | while (*p != L'|') {
|
|---|
| 2245 |
|
|---|
| 2246 | if (infoPtr->nNumStrings == 0) {
|
|---|
| 2247 | infoPtr->strings =
|
|---|
| 2248 | COMCTL32_Alloc (sizeof(LPWSTR));
|
|---|
| 2249 | }
|
|---|
| 2250 | else {
|
|---|
| 2251 | LPWSTR *oldStrings = infoPtr->strings;
|
|---|
| 2252 | infoPtr->strings =
|
|---|
| 2253 | COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
|
|---|
| 2254 | memcpy (&infoPtr->strings[0], &oldStrings[0],
|
|---|
| 2255 | sizeof(LPWSTR) * infoPtr->nNumStrings);
|
|---|
| 2256 | COMCTL32_Free (oldStrings);
|
|---|
| 2257 | }
|
|---|
| 2258 |
|
|---|
| 2259 | len = COMCTL32_StrChrW (p, L'|') - p;
|
|---|
| 2260 | TRACE("len=%d %s\n", len, debugstr_w(p));
|
|---|
| 2261 | infoPtr->strings[infoPtr->nNumStrings] =
|
|---|
| 2262 | COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
|
|---|
| 2263 | lstrcpynW (infoPtr->strings[infoPtr->nNumStrings], p, len+1);
|
|---|
| 2264 | infoPtr->nNumStrings++;
|
|---|
| 2265 |
|
|---|
| 2266 | p += (len+1);
|
|---|
| 2267 | }
|
|---|
| 2268 | }
|
|---|
| 2269 | else
|
|---|
| 2270 | {
|
|---|
| 2271 | nIndex = infoPtr->nNumStrings;
|
|---|
| 2272 | if (infoPtr->nNumStrings == 0) {
|
|---|
| 2273 | infoPtr->strings =
|
|---|
| 2274 | COMCTL32_Alloc (sizeof(LPWSTR));
|
|---|
| 2275 | }
|
|---|
| 2276 | else {
|
|---|
| 2277 | LPWSTR *oldStrings = infoPtr->strings;
|
|---|
| 2278 | infoPtr->strings =
|
|---|
| 2279 | COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
|
|---|
| 2280 | memcpy (&infoPtr->strings[0], &oldStrings[0],
|
|---|
| 2281 | sizeof(LPWSTR) * infoPtr->nNumStrings);
|
|---|
| 2282 | COMCTL32_Free (oldStrings);
|
|---|
| 2283 | }
|
|---|
| 2284 |
|
|---|
| 2285 | Str_SetPtrW (&infoPtr->strings[infoPtr->nNumStrings], szString);
|
|---|
| 2286 | infoPtr->nNumStrings++;
|
|---|
| 2287 | }
|
|---|
| 2288 | }
|
|---|
| 2289 | else {
|
|---|
| 2290 | LPWSTR p = (LPWSTR)lParam;
|
|---|
| 2291 | INT len;
|
|---|
| 2292 |
|
|---|
| 2293 | if (p == NULL)
|
|---|
| 2294 | return -1;
|
|---|
| 2295 | TRACE("adding string(s) from array!\n");
|
|---|
| 2296 | nIndex = infoPtr->nNumStrings;
|
|---|
| 2297 | while (*p) {
|
|---|
| 2298 | len = strlenW (p);
|
|---|
| 2299 |
|
|---|
| 2300 | TRACE("len=%d %s\n", len, debugstr_w(p));
|
|---|
| 2301 | if (infoPtr->nNumStrings == 0) {
|
|---|
| 2302 | infoPtr->strings =
|
|---|
| 2303 | COMCTL32_Alloc (sizeof(LPWSTR));
|
|---|
| 2304 | }
|
|---|
| 2305 | else {
|
|---|
| 2306 | LPWSTR *oldStrings = infoPtr->strings;
|
|---|
| 2307 | infoPtr->strings =
|
|---|
| 2308 | COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
|
|---|
| 2309 | memcpy (&infoPtr->strings[0], &oldStrings[0],
|
|---|
| 2310 | sizeof(LPWSTR) * infoPtr->nNumStrings);
|
|---|
| 2311 | COMCTL32_Free (oldStrings);
|
|---|
| 2312 | }
|
|---|
| 2313 |
|
|---|
| 2314 | Str_SetPtrW (&infoPtr->strings[infoPtr->nNumStrings], p);
|
|---|
| 2315 | infoPtr->nNumStrings++;
|
|---|
| 2316 |
|
|---|
| 2317 | p += (len+1);
|
|---|
| 2318 | }
|
|---|
| 2319 | }
|
|---|
| 2320 |
|
|---|
| 2321 | return nIndex;
|
|---|
| 2322 | }
|
|---|
| 2323 |
|
|---|
| 2324 |
|
|---|
| 2325 | static LRESULT
|
|---|
| 2326 | TOOLBAR_AutoSize (HWND hwnd)
|
|---|
| 2327 | {
|
|---|
| 2328 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 2329 | DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
|
|---|
| 2330 | RECT parent_rect;
|
|---|
| 2331 | RECT window_rect;
|
|---|
| 2332 | HWND parent;
|
|---|
| 2333 | INT x, y;
|
|---|
| 2334 | INT cx, cy;
|
|---|
| 2335 | UINT uPosFlags = SWP_NOZORDER;
|
|---|
| 2336 |
|
|---|
| 2337 | TRACE("resize forced, style=%lx!\n", dwStyle);
|
|---|
| 2338 |
|
|---|
| 2339 | parent = GetParent (hwnd);
|
|---|
| 2340 | GetClientRect(parent, &parent_rect);
|
|---|
| 2341 |
|
|---|
| 2342 | x = parent_rect.left;
|
|---|
| 2343 | y = parent_rect.top;
|
|---|
| 2344 |
|
|---|
| 2345 | /* FIXME: we should be able to early out if nothing */
|
|---|
| 2346 | /* has changed with nWidth != parent_rect width */
|
|---|
| 2347 |
|
|---|
| 2348 | if (dwStyle & CCS_NORESIZE) {
|
|---|
| 2349 | uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
|
|---|
| 2350 | cx = 0;
|
|---|
| 2351 | cy = 0;
|
|---|
| 2352 | TOOLBAR_CalcToolbar (hwnd);
|
|---|
| 2353 | }
|
|---|
| 2354 | else {
|
|---|
| 2355 | infoPtr->nWidth = parent_rect.right - parent_rect.left;
|
|---|
| 2356 | TOOLBAR_CalcToolbar (hwnd);
|
|---|
| 2357 | InvalidateRect( hwnd, NULL, TRUE );
|
|---|
| 2358 | cy = infoPtr->nHeight;
|
|---|
| 2359 | cx = infoPtr->nWidth;
|
|---|
| 2360 |
|
|---|
| 2361 | if (dwStyle & CCS_NOMOVEY) {
|
|---|
| 2362 | GetWindowRect(hwnd, &window_rect);
|
|---|
| 2363 | ScreenToClient(parent, (LPPOINT)&window_rect.left);
|
|---|
| 2364 | y = window_rect.top;
|
|---|
| 2365 | }
|
|---|
| 2366 | }
|
|---|
| 2367 |
|
|---|
| 2368 | if (dwStyle & CCS_NOPARENTALIGN)
|
|---|
| 2369 | uPosFlags |= SWP_NOMOVE;
|
|---|
| 2370 |
|
|---|
| 2371 | if (!(dwStyle & CCS_NODIVIDER))
|
|---|
| 2372 | cy += GetSystemMetrics(SM_CYEDGE);
|
|---|
| 2373 |
|
|---|
| 2374 | if (dwStyle & WS_BORDER)
|
|---|
| 2375 | {
|
|---|
| 2376 | x = y = 1;
|
|---|
| 2377 | cy += GetSystemMetrics(SM_CYEDGE);
|
|---|
| 2378 | cx += GetSystemMetrics(SM_CYEDGE);
|
|---|
| 2379 | }
|
|---|
| 2380 |
|
|---|
| 2381 | infoPtr->bAutoSize = TRUE;
|
|---|
| 2382 | SetWindowPos (hwnd, HWND_TOP, parent_rect.left - x, parent_rect.top - y,
|
|---|
| 2383 | cx, cy, uPosFlags);
|
|---|
| 2384 | /* The following line makes sure that the infoPtr->bAutoSize is turned off after
|
|---|
| 2385 | * the setwindowpos calls */
|
|---|
| 2386 | infoPtr->bAutoSize = FALSE;
|
|---|
| 2387 |
|
|---|
| 2388 | return 0;
|
|---|
| 2389 | }
|
|---|
| 2390 |
|
|---|
| 2391 |
|
|---|
| 2392 | static LRESULT
|
|---|
| 2393 | TOOLBAR_ButtonCount (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 2394 | {
|
|---|
| 2395 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 2396 |
|
|---|
| 2397 | return infoPtr->nNumButtons;
|
|---|
| 2398 | }
|
|---|
| 2399 |
|
|---|
| 2400 |
|
|---|
| 2401 | static LRESULT
|
|---|
| 2402 | TOOLBAR_ButtonStructSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 2403 | {
|
|---|
| 2404 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 2405 |
|
|---|
| 2406 | if (infoPtr == NULL) {
|
|---|
| 2407 | ERR("(0x%x, 0x%x, 0x%lx)\n", hwnd, wParam, lParam);
|
|---|
| 2408 | ERR("infoPtr == NULL!\n");
|
|---|
| 2409 | return 0;
|
|---|
| 2410 | }
|
|---|
| 2411 |
|
|---|
| 2412 | infoPtr->dwStructSize = (DWORD)wParam;
|
|---|
| 2413 |
|
|---|
| 2414 | return 0;
|
|---|
| 2415 | }
|
|---|
| 2416 |
|
|---|
| 2417 |
|
|---|
| 2418 | static LRESULT
|
|---|
| 2419 | TOOLBAR_ChangeBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 2420 | {
|
|---|
| 2421 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 2422 | TBUTTON_INFO *btnPtr;
|
|---|
| 2423 | INT nIndex;
|
|---|
| 2424 |
|
|---|
| 2425 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
|
|---|
| 2426 | if (nIndex == -1)
|
|---|
| 2427 | return FALSE;
|
|---|
| 2428 |
|
|---|
| 2429 | btnPtr = &infoPtr->buttons[nIndex];
|
|---|
| 2430 | btnPtr->iBitmap = LOWORD(lParam);
|
|---|
| 2431 |
|
|---|
| 2432 | /* we HAVE to erase the background, the new bitmap could be */
|
|---|
| 2433 | /* transparent */
|
|---|
| 2434 | InvalidateRect(hwnd, &btnPtr->rect, TRUE);
|
|---|
| 2435 |
|
|---|
| 2436 | return TRUE;
|
|---|
| 2437 | }
|
|---|
| 2438 |
|
|---|
| 2439 |
|
|---|
| 2440 | static LRESULT
|
|---|
| 2441 | TOOLBAR_CheckButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 2442 | {
|
|---|
| 2443 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 2444 | TBUTTON_INFO *btnPtr;
|
|---|
| 2445 | INT nIndex;
|
|---|
| 2446 | INT nOldIndex = -1;
|
|---|
| 2447 | BOOL bChecked = FALSE;
|
|---|
| 2448 |
|
|---|
| 2449 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
|
|---|
| 2450 | if (nIndex == -1)
|
|---|
| 2451 | return FALSE;
|
|---|
| 2452 |
|
|---|
| 2453 | btnPtr = &infoPtr->buttons[nIndex];
|
|---|
| 2454 |
|
|---|
| 2455 | if (!(btnPtr->fsStyle & TBSTYLE_CHECK))
|
|---|
| 2456 | return FALSE;
|
|---|
| 2457 |
|
|---|
| 2458 | bChecked = (btnPtr->fsState & TBSTATE_CHECKED) ? TRUE : FALSE;
|
|---|
| 2459 |
|
|---|
| 2460 | if (LOWORD(lParam) == FALSE)
|
|---|
| 2461 | btnPtr->fsState &= ~TBSTATE_CHECKED;
|
|---|
| 2462 | else {
|
|---|
| 2463 | if (btnPtr->fsStyle & TBSTYLE_GROUP) {
|
|---|
| 2464 | nOldIndex =
|
|---|
| 2465 | TOOLBAR_GetCheckedGroupButtonIndex (infoPtr, nIndex);
|
|---|
| 2466 | if (nOldIndex == nIndex)
|
|---|
| 2467 | return 0;
|
|---|
| 2468 | if (nOldIndex != -1)
|
|---|
| 2469 | infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
|
|---|
| 2470 | }
|
|---|
| 2471 | btnPtr->fsState |= TBSTATE_CHECKED;
|
|---|
| 2472 | }
|
|---|
| 2473 |
|
|---|
| 2474 | if( bChecked != LOWORD(lParam) )
|
|---|
| 2475 | {
|
|---|
| 2476 | if (nOldIndex != -1)
|
|---|
| 2477 | {
|
|---|
| 2478 | InvalidateRect(hwnd, &infoPtr->buttons[nOldIndex].rect,
|
|---|
| 2479 | TOOLBAR_HasText(infoPtr, &infoPtr->buttons[nOldIndex]));
|
|---|
| 2480 | }
|
|---|
| 2481 | InvalidateRect(hwnd, &btnPtr->rect, TRUE);
|
|---|
| 2482 | }
|
|---|
| 2483 |
|
|---|
| 2484 | /* FIXME: Send a WM_NOTIFY?? */
|
|---|
| 2485 |
|
|---|
| 2486 | return TRUE;
|
|---|
| 2487 | }
|
|---|
| 2488 |
|
|---|
| 2489 |
|
|---|
| 2490 | static LRESULT
|
|---|
| 2491 | TOOLBAR_CommandToIndex (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 2492 | {
|
|---|
| 2493 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 2494 |
|
|---|
| 2495 | return TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
|
|---|
| 2496 | }
|
|---|
| 2497 |
|
|---|
| 2498 |
|
|---|
| 2499 | static LRESULT
|
|---|
| 2500 | TOOLBAR_Customize (HWND hwnd)
|
|---|
| 2501 | {
|
|---|
| 2502 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 2503 | CUSTDLG_INFO custInfo;
|
|---|
| 2504 | LRESULT ret;
|
|---|
| 2505 | LPCVOID template;
|
|---|
| 2506 | HRSRC hRes;
|
|---|
| 2507 | NMHDR nmhdr;
|
|---|
| 2508 |
|
|---|
| 2509 | custInfo.tbInfo = infoPtr;
|
|---|
| 2510 | custInfo.tbHwnd = hwnd;
|
|---|
| 2511 |
|
|---|
| 2512 | /* send TBN_BEGINADJUST notification */
|
|---|
| 2513 | TOOLBAR_SendNotify ((NMHDR *) &nmhdr, infoPtr,
|
|---|
| 2514 | TBN_BEGINADJUST);
|
|---|
| 2515 |
|
|---|
| 2516 | if (!(hRes = FindResourceA (COMCTL32_hModule,
|
|---|
| 2517 | MAKEINTRESOURCEA(IDD_TBCUSTOMIZE),
|
|---|
| 2518 | RT_DIALOGA)))
|
|---|
| 2519 | return FALSE;
|
|---|
| 2520 |
|
|---|
| 2521 | if(!(template = (LPVOID)LoadResource (COMCTL32_hModule, hRes)))
|
|---|
| 2522 | return FALSE;
|
|---|
| 2523 |
|
|---|
| 2524 | ret = DialogBoxIndirectParamA (GetWindowLongA (hwnd, GWL_HINSTANCE),
|
|---|
| 2525 | (LPDLGTEMPLATEA)template,
|
|---|
| 2526 | hwnd,
|
|---|
| 2527 | (DLGPROC)TOOLBAR_CustomizeDialogProc,
|
|---|
| 2528 | (LPARAM)&custInfo);
|
|---|
| 2529 |
|
|---|
| 2530 | /* send TBN_ENDADJUST notification */
|
|---|
| 2531 | TOOLBAR_SendNotify ((NMHDR *) &nmhdr, infoPtr,
|
|---|
| 2532 | TBN_ENDADJUST);
|
|---|
| 2533 |
|
|---|
| 2534 | return ret;
|
|---|
| 2535 | }
|
|---|
| 2536 |
|
|---|
| 2537 |
|
|---|
| 2538 | static LRESULT
|
|---|
| 2539 | TOOLBAR_DeleteButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 2540 | {
|
|---|
| 2541 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 2542 | INT nIndex = (INT)wParam;
|
|---|
| 2543 |
|
|---|
| 2544 | if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
|
|---|
| 2545 | return FALSE;
|
|---|
| 2546 |
|
|---|
| 2547 | if ((infoPtr->hwndToolTip) &&
|
|---|
| 2548 | !(infoPtr->buttons[nIndex].fsStyle & TBSTYLE_SEP)) {
|
|---|
| 2549 | TTTOOLINFOA ti;
|
|---|
| 2550 |
|
|---|
| 2551 | ZeroMemory (&ti, sizeof(TTTOOLINFOA));
|
|---|
| 2552 | ti.cbSize = sizeof (TTTOOLINFOA);
|
|---|
| 2553 | ti.hwnd = hwnd;
|
|---|
| 2554 | ti.uId = infoPtr->buttons[nIndex].idCommand;
|
|---|
| 2555 |
|
|---|
| 2556 | SendMessageA (infoPtr->hwndToolTip, TTM_DELTOOLA, 0, (LPARAM)&ti);
|
|---|
| 2557 | }
|
|---|
| 2558 |
|
|---|
| 2559 | if (infoPtr->nNumButtons == 1) {
|
|---|
| 2560 | TRACE(" simple delete!\n");
|
|---|
| 2561 | COMCTL32_Free (infoPtr->buttons);
|
|---|
| 2562 | infoPtr->buttons = NULL;
|
|---|
| 2563 | infoPtr->nNumButtons = 0;
|
|---|
| 2564 | }
|
|---|
| 2565 | else {
|
|---|
| 2566 | TBUTTON_INFO *oldButtons = infoPtr->buttons;
|
|---|
| 2567 | TRACE("complex delete! [nIndex=%d]\n", nIndex);
|
|---|
| 2568 |
|
|---|
| 2569 | infoPtr->nNumButtons--;
|
|---|
| 2570 | infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
|
|---|
| 2571 | if (nIndex > 0) {
|
|---|
| 2572 | memcpy (&infoPtr->buttons[0], &oldButtons[0],
|
|---|
| 2573 | nIndex * sizeof(TBUTTON_INFO));
|
|---|
| 2574 | }
|
|---|
| 2575 |
|
|---|
| 2576 | if (nIndex < infoPtr->nNumButtons) {
|
|---|
| 2577 | memcpy (&infoPtr->buttons[nIndex], &oldButtons[nIndex+1],
|
|---|
| 2578 | (infoPtr->nNumButtons - nIndex) * sizeof(TBUTTON_INFO));
|
|---|
| 2579 | }
|
|---|
| 2580 |
|
|---|
| 2581 | COMCTL32_Free (oldButtons);
|
|---|
| 2582 | }
|
|---|
| 2583 |
|
|---|
| 2584 | TOOLBAR_CalcToolbar (hwnd);
|
|---|
| 2585 |
|
|---|
| 2586 | InvalidateRect (hwnd, NULL, TRUE);
|
|---|
| 2587 |
|
|---|
| 2588 | return TRUE;
|
|---|
| 2589 | }
|
|---|
| 2590 |
|
|---|
| 2591 |
|
|---|
| 2592 | static LRESULT
|
|---|
| 2593 | TOOLBAR_EnableButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 2594 | {
|
|---|
| 2595 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 2596 | TBUTTON_INFO *btnPtr;
|
|---|
| 2597 | INT nIndex;
|
|---|
| 2598 | DWORD bState;
|
|---|
| 2599 |
|
|---|
| 2600 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
|
|---|
| 2601 | if (nIndex == -1)
|
|---|
| 2602 | return FALSE;
|
|---|
| 2603 |
|
|---|
| 2604 | btnPtr = &infoPtr->buttons[nIndex];
|
|---|
| 2605 |
|
|---|
| 2606 | bState = btnPtr->fsState & TBSTATE_ENABLED;
|
|---|
| 2607 |
|
|---|
| 2608 | /* update the toolbar button state */
|
|---|
| 2609 | if(LOWORD(lParam) == FALSE) {
|
|---|
| 2610 | btnPtr->fsState &= ~(TBSTATE_ENABLED | TBSTATE_PRESSED);
|
|---|
| 2611 | } else {
|
|---|
| 2612 | btnPtr->fsState |= TBSTATE_ENABLED;
|
|---|
| 2613 | }
|
|---|
| 2614 |
|
|---|
| 2615 | /* redraw the button only if the state of the button changed */
|
|---|
| 2616 | if(bState != (btnPtr->fsState & TBSTATE_ENABLED))
|
|---|
| 2617 | {
|
|---|
| 2618 | InvalidateRect(hwnd, &btnPtr->rect,
|
|---|
| 2619 | TOOLBAR_HasText(infoPtr, btnPtr));
|
|---|
| 2620 | }
|
|---|
| 2621 |
|
|---|
| 2622 | return TRUE;
|
|---|
| 2623 | }
|
|---|
| 2624 |
|
|---|
| 2625 |
|
|---|
| 2626 | static inline LRESULT
|
|---|
| 2627 | TOOLBAR_GetAnchorHighlight (HWND hwnd)
|
|---|
| 2628 | {
|
|---|
| 2629 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 2630 |
|
|---|
| 2631 | return infoPtr->bAnchor;
|
|---|
| 2632 | }
|
|---|
| 2633 |
|
|---|
| 2634 |
|
|---|
| 2635 | static LRESULT
|
|---|
| 2636 | TOOLBAR_GetBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 2637 | {
|
|---|
| 2638 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 2639 | INT nIndex;
|
|---|
| 2640 |
|
|---|
| 2641 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
|
|---|
| 2642 | if (nIndex == -1)
|
|---|
| 2643 | return -1;
|
|---|
| 2644 |
|
|---|
| 2645 | return infoPtr->buttons[nIndex].iBitmap;
|
|---|
| 2646 | }
|
|---|
| 2647 |
|
|---|
| 2648 |
|
|---|
| 2649 | static inline LRESULT
|
|---|
| 2650 | TOOLBAR_GetBitmapFlags (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 2651 | {
|
|---|
| 2652 | return (GetDeviceCaps (0, LOGPIXELSX) >= 120) ? TBBF_LARGE : 0;
|
|---|
| 2653 | }
|
|---|
| 2654 |
|
|---|
| 2655 |
|
|---|
| 2656 | static LRESULT
|
|---|
| 2657 | TOOLBAR_GetButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 2658 | {
|
|---|
| 2659 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 2660 | LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
|
|---|
| 2661 | INT nIndex = (INT)wParam;
|
|---|
| 2662 | TBUTTON_INFO *btnPtr;
|
|---|
| 2663 |
|
|---|
| 2664 | if (infoPtr == NULL)
|
|---|
| 2665 | return FALSE;
|
|---|
| 2666 |
|
|---|
| 2667 | if (lpTbb == NULL)
|
|---|
| 2668 | return FALSE;
|
|---|
| 2669 |
|
|---|
| 2670 | if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
|
|---|
| 2671 | return FALSE;
|
|---|
| 2672 |
|
|---|
| 2673 | btnPtr = &infoPtr->buttons[nIndex];
|
|---|
| 2674 | lpTbb->iBitmap = btnPtr->iBitmap;
|
|---|
| 2675 | lpTbb->idCommand = btnPtr->idCommand;
|
|---|
| 2676 | lpTbb->fsState = btnPtr->fsState;
|
|---|
| 2677 | lpTbb->fsStyle = btnPtr->fsStyle;
|
|---|
| 2678 | lpTbb->dwData = btnPtr->dwData;
|
|---|
| 2679 | lpTbb->iString = btnPtr->iString;
|
|---|
| 2680 |
|
|---|
| 2681 | return TRUE;
|
|---|
| 2682 | }
|
|---|
| 2683 |
|
|---|
| 2684 |
|
|---|
| 2685 | static LRESULT
|
|---|
| 2686 | TOOLBAR_GetButtonInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 2687 | {
|
|---|
| 2688 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 2689 | LPTBBUTTONINFOA lpTbInfo = (LPTBBUTTONINFOA)lParam;
|
|---|
| 2690 | TBUTTON_INFO *btnPtr;
|
|---|
| 2691 | INT nIndex;
|
|---|
| 2692 |
|
|---|
| 2693 | if (infoPtr == NULL)
|
|---|
| 2694 | return -1;
|
|---|
| 2695 | if (lpTbInfo == NULL)
|
|---|
| 2696 | return -1;
|
|---|
| 2697 | if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOA))
|
|---|
| 2698 | return -1;
|
|---|
| 2699 |
|
|---|
| 2700 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam,
|
|---|
| 2701 | lpTbInfo->dwMask & 0x80000000);
|
|---|
| 2702 | if (nIndex == -1)
|
|---|
| 2703 | return -1;
|
|---|
| 2704 |
|
|---|
| 2705 | if (!(btnPtr = &infoPtr->buttons[nIndex])) return -1;
|
|---|
| 2706 |
|
|---|
| 2707 | if (lpTbInfo->dwMask & TBIF_COMMAND)
|
|---|
| 2708 | lpTbInfo->idCommand = btnPtr->idCommand;
|
|---|
| 2709 | if (lpTbInfo->dwMask & TBIF_IMAGE)
|
|---|
| 2710 | lpTbInfo->iImage = btnPtr->iBitmap;
|
|---|
| 2711 | if (lpTbInfo->dwMask & TBIF_LPARAM)
|
|---|
| 2712 | lpTbInfo->lParam = btnPtr->dwData;
|
|---|
| 2713 | if (lpTbInfo->dwMask & TBIF_SIZE)
|
|---|
| 2714 | lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left);
|
|---|
| 2715 | if (lpTbInfo->dwMask & TBIF_STATE)
|
|---|
| 2716 | lpTbInfo->fsState = btnPtr->fsState;
|
|---|
| 2717 | if (lpTbInfo->dwMask & TBIF_STYLE)
|
|---|
| 2718 | lpTbInfo->fsStyle = btnPtr->fsStyle;
|
|---|
| 2719 | if (lpTbInfo->dwMask & TBIF_TEXT) {
|
|---|
| 2720 | LPWSTR lpText = TOOLBAR_GetText(infoPtr,btnPtr);
|
|---|
| 2721 | Str_GetPtrWtoA (lpText, lpTbInfo->pszText,lpTbInfo->cchText);
|
|---|
| 2722 | }
|
|---|
| 2723 | return nIndex;
|
|---|
| 2724 | }
|
|---|
| 2725 |
|
|---|
| 2726 |
|
|---|
| 2727 | static LRESULT
|
|---|
| 2728 | TOOLBAR_GetButtonInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 2729 | {
|
|---|
| 2730 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 2731 | LPTBBUTTONINFOW lpTbInfo = (LPTBBUTTONINFOW)lParam;
|
|---|
| 2732 | TBUTTON_INFO *btnPtr;
|
|---|
| 2733 | INT nIndex;
|
|---|
| 2734 |
|
|---|
| 2735 | if (infoPtr == NULL)
|
|---|
| 2736 | return -1;
|
|---|
| 2737 | if (lpTbInfo == NULL)
|
|---|
| 2738 | return -1;
|
|---|
| 2739 | if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOW))
|
|---|
| 2740 | return -1;
|
|---|
| 2741 |
|
|---|
| 2742 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam,
|
|---|
| 2743 | lpTbInfo->dwMask & 0x80000000);
|
|---|
| 2744 | if (nIndex == -1)
|
|---|
| 2745 | return -1;
|
|---|
| 2746 |
|
|---|
| 2747 | btnPtr = &infoPtr->buttons[nIndex];
|
|---|
| 2748 |
|
|---|
| 2749 | if (lpTbInfo->dwMask & TBIF_COMMAND)
|
|---|
| 2750 | lpTbInfo->idCommand = btnPtr->idCommand;
|
|---|
| 2751 | if (lpTbInfo->dwMask & TBIF_IMAGE)
|
|---|
| 2752 | lpTbInfo->iImage = btnPtr->iBitmap;
|
|---|
| 2753 | if (lpTbInfo->dwMask & TBIF_LPARAM)
|
|---|
| 2754 | lpTbInfo->lParam = btnPtr->dwData;
|
|---|
| 2755 | if (lpTbInfo->dwMask & TBIF_SIZE)
|
|---|
| 2756 | lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left);
|
|---|
| 2757 | if (lpTbInfo->dwMask & TBIF_STATE)
|
|---|
| 2758 | lpTbInfo->fsState = btnPtr->fsState;
|
|---|
| 2759 | if (lpTbInfo->dwMask & TBIF_STYLE)
|
|---|
| 2760 | lpTbInfo->fsStyle = btnPtr->fsStyle;
|
|---|
| 2761 | if (lpTbInfo->dwMask & TBIF_TEXT) {
|
|---|
| 2762 | LPWSTR lpText = TOOLBAR_GetText(infoPtr,btnPtr);
|
|---|
| 2763 | Str_GetPtrW (lpText,lpTbInfo->pszText,lpTbInfo->cchText);
|
|---|
| 2764 | }
|
|---|
| 2765 |
|
|---|
| 2766 | return nIndex;
|
|---|
| 2767 | }
|
|---|
| 2768 |
|
|---|
| 2769 |
|
|---|
| 2770 | static LRESULT
|
|---|
| 2771 | TOOLBAR_GetButtonSize (HWND hwnd)
|
|---|
| 2772 | {
|
|---|
| 2773 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 2774 |
|
|---|
| 2775 | if (infoPtr->nNumButtons > 0)
|
|---|
| 2776 | return MAKELONG((WORD)infoPtr->nButtonWidth,
|
|---|
| 2777 | (WORD)infoPtr->nButtonHeight);
|
|---|
| 2778 | else
|
|---|
| 2779 | return MAKELONG(8,7);
|
|---|
| 2780 | }
|
|---|
| 2781 |
|
|---|
| 2782 |
|
|---|
| 2783 | static LRESULT
|
|---|
| 2784 | TOOLBAR_GetButtonTextA (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 2785 | {
|
|---|
| 2786 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 2787 | INT nIndex;
|
|---|
| 2788 | LPWSTR lpText;
|
|---|
| 2789 |
|
|---|
| 2790 | if (lParam == 0)
|
|---|
| 2791 | return -1;
|
|---|
| 2792 |
|
|---|
| 2793 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
|
|---|
| 2794 | if (nIndex == -1)
|
|---|
| 2795 | return -1;
|
|---|
| 2796 |
|
|---|
| 2797 | lpText = TOOLBAR_GetText(infoPtr,&infoPtr->buttons[nIndex]);
|
|---|
| 2798 |
|
|---|
| 2799 | return WideCharToMultiByte( CP_ACP, 0, lpText, -1,
|
|---|
| 2800 | (LPSTR)lParam, 0x7fffffff, NULL, NULL ) - 1;
|
|---|
| 2801 | }
|
|---|
| 2802 |
|
|---|
| 2803 |
|
|---|
| 2804 | static LRESULT
|
|---|
| 2805 | TOOLBAR_GetButtonTextW (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 2806 | {
|
|---|
| 2807 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 2808 | INT nIndex;
|
|---|
| 2809 | LPWSTR lpText;
|
|---|
| 2810 |
|
|---|
| 2811 | if (lParam == 0)
|
|---|
| 2812 | return -1;
|
|---|
| 2813 |
|
|---|
| 2814 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
|
|---|
| 2815 | if (nIndex == -1)
|
|---|
| 2816 | return -1;
|
|---|
| 2817 |
|
|---|
| 2818 | lpText = TOOLBAR_GetText(infoPtr,&infoPtr->buttons[nIndex]);
|
|---|
| 2819 |
|
|---|
| 2820 | strcpyW ((LPWSTR)lParam, lpText);
|
|---|
| 2821 |
|
|---|
| 2822 | return strlenW (lpText);
|
|---|
| 2823 | }
|
|---|
| 2824 |
|
|---|
| 2825 |
|
|---|
| 2826 | /* << TOOLBAR_GetColorScheme >> */
|
|---|
| 2827 |
|
|---|
| 2828 |
|
|---|
| 2829 | static LRESULT
|
|---|
| 2830 | TOOLBAR_GetDisabledImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 2831 | {
|
|---|
| 2832 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 2833 |
|
|---|
| 2834 | return (LRESULT)infoPtr->himlDis;
|
|---|
| 2835 | }
|
|---|
| 2836 |
|
|---|
| 2837 |
|
|---|
| 2838 | inline static LRESULT
|
|---|
| 2839 | TOOLBAR_GetExtendedStyle (HWND hwnd)
|
|---|
| 2840 | {
|
|---|
| 2841 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 2842 |
|
|---|
| 2843 | return infoPtr->dwExStyle;
|
|---|
| 2844 | }
|
|---|
| 2845 |
|
|---|
| 2846 |
|
|---|
| 2847 | static LRESULT
|
|---|
| 2848 | TOOLBAR_GetHotImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 2849 | {
|
|---|
| 2850 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 2851 |
|
|---|
| 2852 | return (LRESULT)infoPtr->himlHot;
|
|---|
| 2853 | }
|
|---|
| 2854 |
|
|---|
| 2855 |
|
|---|
| 2856 | static LRESULT
|
|---|
| 2857 | TOOLBAR_GetHotItem (HWND hwnd)
|
|---|
| 2858 | {
|
|---|
| 2859 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 2860 |
|
|---|
| 2861 | if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT))
|
|---|
| 2862 | return -1;
|
|---|
| 2863 |
|
|---|
| 2864 | if (infoPtr->nHotItem < 0)
|
|---|
| 2865 | return -1;
|
|---|
| 2866 |
|
|---|
| 2867 | return (LRESULT)infoPtr->nHotItem;
|
|---|
| 2868 | }
|
|---|
| 2869 |
|
|---|
| 2870 |
|
|---|
| 2871 | static LRESULT
|
|---|
| 2872 | TOOLBAR_GetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 2873 | {
|
|---|
| 2874 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 2875 |
|
|---|
| 2876 | return (LRESULT)infoPtr->himlDef;
|
|---|
| 2877 | }
|
|---|
| 2878 |
|
|---|
| 2879 |
|
|---|
| 2880 | /* << TOOLBAR_GetInsertMark >> */
|
|---|
| 2881 | /* << TOOLBAR_GetInsertMarkColor >> */
|
|---|
| 2882 |
|
|---|
| 2883 |
|
|---|
| 2884 | static LRESULT
|
|---|
| 2885 | TOOLBAR_GetItemRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 2886 | {
|
|---|
| 2887 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 2888 | TBUTTON_INFO *btnPtr;
|
|---|
| 2889 | LPRECT lpRect;
|
|---|
| 2890 | INT nIndex;
|
|---|
| 2891 |
|
|---|
| 2892 | if (infoPtr == NULL)
|
|---|
| 2893 | return FALSE;
|
|---|
| 2894 | nIndex = (INT)wParam;
|
|---|
| 2895 | btnPtr = &infoPtr->buttons[nIndex];
|
|---|
| 2896 | if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
|
|---|
| 2897 | return FALSE;
|
|---|
| 2898 | lpRect = (LPRECT)lParam;
|
|---|
| 2899 | if (lpRect == NULL)
|
|---|
| 2900 | return FALSE;
|
|---|
| 2901 | if (btnPtr->fsState & TBSTATE_HIDDEN)
|
|---|
| 2902 | return FALSE;
|
|---|
| 2903 |
|
|---|
| 2904 | lpRect->left = btnPtr->rect.left;
|
|---|
| 2905 | lpRect->right = btnPtr->rect.right;
|
|---|
| 2906 | lpRect->bottom = btnPtr->rect.bottom;
|
|---|
| 2907 | lpRect->top = btnPtr->rect.top;
|
|---|
| 2908 |
|
|---|
| 2909 | return TRUE;
|
|---|
| 2910 | }
|
|---|
| 2911 |
|
|---|
| 2912 |
|
|---|
| 2913 | static LRESULT
|
|---|
| 2914 | TOOLBAR_GetMaxSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 2915 | {
|
|---|
| 2916 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 2917 | LPSIZE lpSize = (LPSIZE)lParam;
|
|---|
| 2918 |
|
|---|
| 2919 | if (lpSize == NULL)
|
|---|
| 2920 | return FALSE;
|
|---|
| 2921 |
|
|---|
| 2922 | lpSize->cx = infoPtr->rcBound.right - infoPtr->rcBound.left;
|
|---|
| 2923 | lpSize->cy = infoPtr->rcBound.bottom - infoPtr->rcBound.top;
|
|---|
| 2924 |
|
|---|
| 2925 | TRACE("maximum size %d x %d\n",
|
|---|
| 2926 | infoPtr->rcBound.right - infoPtr->rcBound.left,
|
|---|
| 2927 | infoPtr->rcBound.bottom - infoPtr->rcBound.top);
|
|---|
| 2928 |
|
|---|
| 2929 | return TRUE;
|
|---|
| 2930 | }
|
|---|
| 2931 |
|
|---|
| 2932 |
|
|---|
| 2933 | /* << TOOLBAR_GetObject >> */
|
|---|
| 2934 | /* << TOOLBAR_GetPadding >> */
|
|---|
| 2935 |
|
|---|
| 2936 |
|
|---|
| 2937 | static LRESULT
|
|---|
| 2938 | TOOLBAR_GetRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 2939 | {
|
|---|
| 2940 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 2941 | TBUTTON_INFO *btnPtr;
|
|---|
| 2942 | LPRECT lpRect;
|
|---|
| 2943 | INT nIndex;
|
|---|
| 2944 |
|
|---|
| 2945 | if (infoPtr == NULL)
|
|---|
| 2946 | return FALSE;
|
|---|
| 2947 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
|
|---|
| 2948 | btnPtr = &infoPtr->buttons[nIndex];
|
|---|
| 2949 | if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
|
|---|
| 2950 | return FALSE;
|
|---|
| 2951 | lpRect = (LPRECT)lParam;
|
|---|
| 2952 | if (lpRect == NULL)
|
|---|
| 2953 | return FALSE;
|
|---|
| 2954 |
|
|---|
| 2955 | lpRect->left = btnPtr->rect.left;
|
|---|
| 2956 | lpRect->right = btnPtr->rect.right;
|
|---|
| 2957 | lpRect->bottom = btnPtr->rect.bottom;
|
|---|
| 2958 | lpRect->top = btnPtr->rect.top;
|
|---|
| 2959 |
|
|---|
| 2960 | return TRUE;
|
|---|
| 2961 | }
|
|---|
| 2962 |
|
|---|
| 2963 |
|
|---|
| 2964 | static LRESULT
|
|---|
| 2965 | TOOLBAR_GetRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 2966 | {
|
|---|
| 2967 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 2968 |
|
|---|
| 2969 | if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_WRAPABLE)
|
|---|
| 2970 | return infoPtr->nRows;
|
|---|
| 2971 | else
|
|---|
| 2972 | return 1;
|
|---|
| 2973 | }
|
|---|
| 2974 |
|
|---|
| 2975 |
|
|---|
| 2976 | static LRESULT
|
|---|
| 2977 | TOOLBAR_GetState (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 2978 | {
|
|---|
| 2979 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 2980 | INT nIndex;
|
|---|
| 2981 |
|
|---|
| 2982 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
|
|---|
| 2983 | if (nIndex == -1)
|
|---|
| 2984 | return -1;
|
|---|
| 2985 |
|
|---|
| 2986 | return infoPtr->buttons[nIndex].fsState;
|
|---|
| 2987 | }
|
|---|
| 2988 |
|
|---|
| 2989 |
|
|---|
| 2990 | static LRESULT
|
|---|
| 2991 | TOOLBAR_GetStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 2992 | {
|
|---|
| 2993 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 2994 | INT nIndex;
|
|---|
| 2995 |
|
|---|
| 2996 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
|
|---|
| 2997 | if (nIndex == -1)
|
|---|
| 2998 | return -1;
|
|---|
| 2999 |
|
|---|
| 3000 | return infoPtr->buttons[nIndex].fsStyle;
|
|---|
| 3001 | }
|
|---|
| 3002 |
|
|---|
| 3003 |
|
|---|
| 3004 | static LRESULT
|
|---|
| 3005 | TOOLBAR_GetTextRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 3006 | {
|
|---|
| 3007 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 3008 |
|
|---|
| 3009 | if (infoPtr == NULL)
|
|---|
| 3010 | return 0;
|
|---|
| 3011 |
|
|---|
| 3012 | return infoPtr->nMaxTextRows;
|
|---|
| 3013 | }
|
|---|
| 3014 |
|
|---|
| 3015 |
|
|---|
| 3016 | static LRESULT
|
|---|
| 3017 | TOOLBAR_GetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 3018 | {
|
|---|
| 3019 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 3020 |
|
|---|
| 3021 | if (infoPtr == NULL)
|
|---|
| 3022 | return 0;
|
|---|
| 3023 | return infoPtr->hwndToolTip;
|
|---|
| 3024 | }
|
|---|
| 3025 |
|
|---|
| 3026 |
|
|---|
| 3027 | static LRESULT
|
|---|
| 3028 | TOOLBAR_GetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 3029 | {
|
|---|
| 3030 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 3031 |
|
|---|
| 3032 | TRACE("%s hwnd=0x%x stub!\n",
|
|---|
| 3033 | infoPtr->bUnicode ? "TRUE" : "FALSE", hwnd);
|
|---|
| 3034 |
|
|---|
| 3035 | return infoPtr->bUnicode;
|
|---|
| 3036 | }
|
|---|
| 3037 |
|
|---|
| 3038 |
|
|---|
| 3039 | inline static LRESULT
|
|---|
| 3040 | TOOLBAR_GetVersion (HWND hwnd)
|
|---|
| 3041 | {
|
|---|
| 3042 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 3043 | return infoPtr->iVersion;
|
|---|
| 3044 | }
|
|---|
| 3045 |
|
|---|
| 3046 |
|
|---|
| 3047 | static LRESULT
|
|---|
| 3048 | TOOLBAR_HideButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 3049 | {
|
|---|
| 3050 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 3051 | TBUTTON_INFO *btnPtr;
|
|---|
| 3052 | INT nIndex;
|
|---|
| 3053 |
|
|---|
| 3054 | TRACE("\n");
|
|---|
| 3055 |
|
|---|
| 3056 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
|
|---|
| 3057 | if (nIndex == -1)
|
|---|
| 3058 | return FALSE;
|
|---|
| 3059 |
|
|---|
| 3060 | btnPtr = &infoPtr->buttons[nIndex];
|
|---|
| 3061 | if (LOWORD(lParam) == FALSE)
|
|---|
| 3062 | btnPtr->fsState &= ~TBSTATE_HIDDEN;
|
|---|
| 3063 | else
|
|---|
| 3064 | btnPtr->fsState |= TBSTATE_HIDDEN;
|
|---|
| 3065 |
|
|---|
| 3066 | TOOLBAR_CalcToolbar (hwnd);
|
|---|
| 3067 |
|
|---|
| 3068 | InvalidateRect (hwnd, NULL, TRUE);
|
|---|
| 3069 |
|
|---|
| 3070 | return TRUE;
|
|---|
| 3071 | }
|
|---|
| 3072 |
|
|---|
| 3073 |
|
|---|
| 3074 | inline static LRESULT
|
|---|
| 3075 | TOOLBAR_HitTest (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 3076 | {
|
|---|
| 3077 | return TOOLBAR_InternalHitTest (hwnd, (LPPOINT)lParam);
|
|---|
| 3078 | }
|
|---|
| 3079 |
|
|---|
| 3080 |
|
|---|
| 3081 | static LRESULT
|
|---|
| 3082 | TOOLBAR_Indeterminate (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 3083 | {
|
|---|
| 3084 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 3085 | TBUTTON_INFO *btnPtr;
|
|---|
| 3086 | INT nIndex;
|
|---|
| 3087 |
|
|---|
| 3088 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
|
|---|
| 3089 | if (nIndex == -1)
|
|---|
| 3090 | return FALSE;
|
|---|
| 3091 |
|
|---|
| 3092 | btnPtr = &infoPtr->buttons[nIndex];
|
|---|
| 3093 | if (LOWORD(lParam) == FALSE)
|
|---|
| 3094 | btnPtr->fsState &= ~TBSTATE_INDETERMINATE;
|
|---|
| 3095 | else
|
|---|
| 3096 | btnPtr->fsState |= TBSTATE_INDETERMINATE;
|
|---|
| 3097 |
|
|---|
| 3098 | InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr, btnPtr));
|
|---|
| 3099 |
|
|---|
| 3100 | return TRUE;
|
|---|
| 3101 | }
|
|---|
| 3102 |
|
|---|
| 3103 |
|
|---|
| 3104 | static LRESULT
|
|---|
| 3105 | TOOLBAR_InsertButtonA (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 3106 | {
|
|---|
| 3107 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 3108 | LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
|
|---|
| 3109 | INT nIndex = (INT)wParam;
|
|---|
| 3110 | TBUTTON_INFO *oldButtons;
|
|---|
| 3111 |
|
|---|
| 3112 | if (lpTbb == NULL)
|
|---|
| 3113 | return FALSE;
|
|---|
| 3114 |
|
|---|
| 3115 | TOOLBAR_DumpButton(infoPtr, (TBUTTON_INFO *)lpTbb, nIndex, FALSE);
|
|---|
| 3116 |
|
|---|
| 3117 | if (nIndex == -1) {
|
|---|
| 3118 | /* EPP: this seems to be an undocumented call (from my IE4)
|
|---|
| 3119 | * I assume in that case that:
|
|---|
| 3120 | * - lpTbb->iString is a string pointer (not a string index in strings[] table
|
|---|
| 3121 | * - index of insertion is at the end of existing buttons
|
|---|
| 3122 | * I only see this happen with nIndex == -1, but it could have a special
|
|---|
| 3123 | * meaning (like -nIndex (or ~nIndex) to get the real position of insertion).
|
|---|
| 3124 | */
|
|---|
| 3125 | nIndex = infoPtr->nNumButtons;
|
|---|
| 3126 |
|
|---|
| 3127 | } else if (nIndex < 0)
|
|---|
| 3128 | return FALSE;
|
|---|
| 3129 |
|
|---|
| 3130 | /* If the string passed is not an index, assume address of string
|
|---|
| 3131 | and do our own AddString */
|
|---|
| 3132 | if ((HIWORD(lpTbb->iString) != 0) && (lpTbb->iString != -1)) {
|
|---|
| 3133 | LPSTR ptr;
|
|---|
| 3134 | INT len;
|
|---|
| 3135 |
|
|---|
| 3136 | TRACE("string %s passed instead of index, adding string\n",
|
|---|
| 3137 | debugstr_a((LPSTR)lpTbb->iString));
|
|---|
| 3138 | len = strlen((LPSTR)lpTbb->iString) + 2;
|
|---|
| 3139 | ptr = COMCTL32_Alloc(len);
|
|---|
| 3140 | strcpy(ptr, (LPSTR)lpTbb->iString);
|
|---|
| 3141 | ptr[len - 1] = 0; /* ended by two '\0' */
|
|---|
| 3142 | lpTbb->iString = TOOLBAR_AddStringA(hwnd, 0, (LPARAM)ptr);
|
|---|
| 3143 | COMCTL32_Free(ptr);
|
|---|
| 3144 | }
|
|---|
| 3145 |
|
|---|
| 3146 | TRACE("inserting button index=%d\n", nIndex);
|
|---|
| 3147 | if (nIndex > infoPtr->nNumButtons) {
|
|---|
| 3148 | nIndex = infoPtr->nNumButtons;
|
|---|
| 3149 | TRACE("adjust index=%d\n", nIndex);
|
|---|
| 3150 | }
|
|---|
| 3151 |
|
|---|
| 3152 | oldButtons = infoPtr->buttons;
|
|---|
| 3153 | infoPtr->nNumButtons++;
|
|---|
| 3154 | infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
|
|---|
| 3155 | /* pre insert copy */
|
|---|
| 3156 | if (nIndex > 0) {
|
|---|
| 3157 | memcpy (&infoPtr->buttons[0], &oldButtons[0],
|
|---|
| 3158 | nIndex * sizeof(TBUTTON_INFO));
|
|---|
| 3159 | }
|
|---|
| 3160 |
|
|---|
| 3161 | /* insert new button */
|
|---|
| 3162 | infoPtr->buttons[nIndex].iBitmap = lpTbb->iBitmap;
|
|---|
| 3163 | infoPtr->buttons[nIndex].idCommand = lpTbb->idCommand;
|
|---|
| 3164 | infoPtr->buttons[nIndex].fsState = lpTbb->fsState;
|
|---|
| 3165 | infoPtr->buttons[nIndex].fsStyle = lpTbb->fsStyle;
|
|---|
| 3166 | infoPtr->buttons[nIndex].dwData = lpTbb->dwData;
|
|---|
| 3167 | /* if passed string and not index, then add string */
|
|---|
| 3168 | if(HIWORD(lpTbb->iString) && lpTbb->iString!=-1) {
|
|---|
| 3169 | Str_SetPtrAtoW ((LPWSTR *)&infoPtr->buttons[nIndex].iString, (LPCSTR )lpTbb->iString);
|
|---|
| 3170 | }
|
|---|
| 3171 | else
|
|---|
| 3172 | infoPtr->buttons[nIndex].iString = lpTbb->iString;
|
|---|
| 3173 |
|
|---|
| 3174 | if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) {
|
|---|
| 3175 | TTTOOLINFOA ti;
|
|---|
| 3176 |
|
|---|
| 3177 | ZeroMemory (&ti, sizeof(TTTOOLINFOA));
|
|---|
| 3178 | ti.cbSize = sizeof (TTTOOLINFOA);
|
|---|
| 3179 | ti.hwnd = hwnd;
|
|---|
| 3180 | ti.uId = lpTbb->idCommand;
|
|---|
| 3181 | ti.hinst = 0;
|
|---|
| 3182 | ti.lpszText = LPSTR_TEXTCALLBACKA;
|
|---|
| 3183 |
|
|---|
| 3184 | SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
|
|---|
| 3185 | 0, (LPARAM)&ti);
|
|---|
| 3186 | }
|
|---|
| 3187 |
|
|---|
| 3188 | /* post insert copy */
|
|---|
| 3189 | if (nIndex < infoPtr->nNumButtons - 1) {
|
|---|
| 3190 | memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex],
|
|---|
| 3191 | (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO));
|
|---|
| 3192 | }
|
|---|
| 3193 |
|
|---|
| 3194 | COMCTL32_Free (oldButtons);
|
|---|
| 3195 |
|
|---|
| 3196 | TOOLBAR_CalcToolbar (hwnd);
|
|---|
| 3197 |
|
|---|
| 3198 | InvalidateRect (hwnd, NULL, TRUE);
|
|---|
| 3199 |
|
|---|
| 3200 | return TRUE;
|
|---|
| 3201 | }
|
|---|
| 3202 |
|
|---|
| 3203 |
|
|---|
| 3204 | static LRESULT
|
|---|
| 3205 | TOOLBAR_InsertButtonW (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 3206 | {
|
|---|
| 3207 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 3208 | LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
|
|---|
| 3209 | INT nIndex = (INT)wParam;
|
|---|
| 3210 | TBUTTON_INFO *oldButtons;
|
|---|
| 3211 |
|
|---|
| 3212 | if (lpTbb == NULL)
|
|---|
| 3213 | return FALSE;
|
|---|
| 3214 |
|
|---|
| 3215 | TOOLBAR_DumpButton(infoPtr, (TBUTTON_INFO *)lpTbb, nIndex, FALSE);
|
|---|
| 3216 |
|
|---|
| 3217 | if (nIndex < 0)
|
|---|
| 3218 | return FALSE;
|
|---|
| 3219 |
|
|---|
| 3220 | TRACE("inserting button index=%d\n", nIndex);
|
|---|
| 3221 | if (nIndex > infoPtr->nNumButtons) {
|
|---|
| 3222 | nIndex = infoPtr->nNumButtons;
|
|---|
| 3223 | TRACE("adjust index=%d\n", nIndex);
|
|---|
| 3224 | }
|
|---|
| 3225 |
|
|---|
| 3226 | oldButtons = infoPtr->buttons;
|
|---|
| 3227 | infoPtr->nNumButtons++;
|
|---|
| 3228 | infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
|
|---|
| 3229 | /* pre insert copy */
|
|---|
| 3230 | if (nIndex > 0) {
|
|---|
| 3231 | memcpy (&infoPtr->buttons[0], &oldButtons[0],
|
|---|
| 3232 | nIndex * sizeof(TBUTTON_INFO));
|
|---|
| 3233 | }
|
|---|
| 3234 |
|
|---|
| 3235 |
|
|---|
| 3236 | /* If the string passed is not an index, assume address of string
|
|---|
| 3237 | and do our own AddString */
|
|---|
| 3238 | if ((HIWORD(lpTbb->iString) != 0) && (lpTbb->iString != -1)) {
|
|---|
| 3239 | LPWSTR ptr;
|
|---|
| 3240 | INT len;
|
|---|
| 3241 |
|
|---|
| 3242 | TRACE("string %s passed instead of index, adding string\n",
|
|---|
| 3243 | debugstr_w((LPWSTR)lpTbb->iString));
|
|---|
| 3244 | len = strlenW((LPWSTR)lpTbb->iString) + 2;
|
|---|
| 3245 | ptr = COMCTL32_Alloc(len*sizeof(WCHAR));
|
|---|
| 3246 | strcpyW(ptr, (LPWSTR)lpTbb->iString);
|
|---|
| 3247 | ptr[len - 1] = 0; /* ended by two '\0' */
|
|---|
| 3248 | lpTbb->iString = TOOLBAR_AddStringW(hwnd, 0, (LPARAM)ptr);
|
|---|
| 3249 | COMCTL32_Free(ptr);
|
|---|
| 3250 | }
|
|---|
| 3251 |
|
|---|
| 3252 | /* insert new button */
|
|---|
| 3253 | infoPtr->buttons[nIndex].iBitmap = lpTbb->iBitmap;
|
|---|
| 3254 | infoPtr->buttons[nIndex].idCommand = lpTbb->idCommand;
|
|---|
| 3255 | infoPtr->buttons[nIndex].fsState = lpTbb->fsState;
|
|---|
| 3256 | infoPtr->buttons[nIndex].fsStyle = lpTbb->fsStyle;
|
|---|
| 3257 | infoPtr->buttons[nIndex].dwData = lpTbb->dwData;
|
|---|
| 3258 | /* if passed string and not index, then add string */
|
|---|
| 3259 | if(HIWORD(lpTbb->iString) && lpTbb->iString!=-1) {
|
|---|
| 3260 | Str_SetPtrW ((LPWSTR *)&infoPtr->buttons[nIndex].iString, (LPWSTR)lpTbb->iString);
|
|---|
| 3261 | }
|
|---|
| 3262 | else
|
|---|
| 3263 | infoPtr->buttons[nIndex].iString = lpTbb->iString;
|
|---|
| 3264 |
|
|---|
| 3265 | if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) {
|
|---|
| 3266 | TTTOOLINFOW ti;
|
|---|
| 3267 |
|
|---|
| 3268 | ZeroMemory (&ti, sizeof(TTTOOLINFOW));
|
|---|
| 3269 | ti.cbSize = sizeof (TTTOOLINFOW);
|
|---|
| 3270 | ti.hwnd = hwnd;
|
|---|
| 3271 | ti.uId = lpTbb->idCommand;
|
|---|
| 3272 | ti.hinst = 0;
|
|---|
| 3273 | ti.lpszText = LPSTR_TEXTCALLBACKW;
|
|---|
| 3274 |
|
|---|
| 3275 | SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW,
|
|---|
| 3276 | 0, (LPARAM)&ti);
|
|---|
| 3277 | }
|
|---|
| 3278 |
|
|---|
| 3279 | /* post insert copy */
|
|---|
| 3280 | if (nIndex < infoPtr->nNumButtons - 1) {
|
|---|
| 3281 | memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex],
|
|---|
| 3282 | (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO));
|
|---|
| 3283 | }
|
|---|
| 3284 |
|
|---|
| 3285 | COMCTL32_Free (oldButtons);
|
|---|
| 3286 |
|
|---|
| 3287 | InvalidateRect (hwnd, NULL, TRUE);
|
|---|
| 3288 |
|
|---|
| 3289 | return TRUE;
|
|---|
| 3290 | }
|
|---|
| 3291 |
|
|---|
| 3292 |
|
|---|
| 3293 | /* << TOOLBAR_InsertMarkHitTest >> */
|
|---|
| 3294 |
|
|---|
| 3295 |
|
|---|
| 3296 | static LRESULT
|
|---|
| 3297 | TOOLBAR_IsButtonChecked (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 3298 | {
|
|---|
| 3299 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 3300 | INT nIndex;
|
|---|
| 3301 |
|
|---|
| 3302 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
|
|---|
| 3303 | if (nIndex == -1)
|
|---|
| 3304 | return FALSE;
|
|---|
| 3305 |
|
|---|
| 3306 | return (infoPtr->buttons[nIndex].fsState & TBSTATE_CHECKED);
|
|---|
| 3307 | }
|
|---|
| 3308 |
|
|---|
| 3309 |
|
|---|
| 3310 | static LRESULT
|
|---|
| 3311 | TOOLBAR_IsButtonEnabled (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 3312 | {
|
|---|
| 3313 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 3314 | INT nIndex;
|
|---|
| 3315 |
|
|---|
| 3316 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
|
|---|
| 3317 | if (nIndex == -1)
|
|---|
| 3318 | return FALSE;
|
|---|
| 3319 |
|
|---|
| 3320 | return (infoPtr->buttons[nIndex].fsState & TBSTATE_ENABLED);
|
|---|
| 3321 | }
|
|---|
| 3322 |
|
|---|
| 3323 |
|
|---|
| 3324 | static LRESULT
|
|---|
| 3325 | TOOLBAR_IsButtonHidden (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 3326 | {
|
|---|
| 3327 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 3328 | INT nIndex;
|
|---|
| 3329 |
|
|---|
| 3330 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
|
|---|
| 3331 | if (nIndex == -1)
|
|---|
| 3332 | return TRUE;
|
|---|
| 3333 |
|
|---|
| 3334 | return (infoPtr->buttons[nIndex].fsState & TBSTATE_HIDDEN);
|
|---|
| 3335 | }
|
|---|
| 3336 |
|
|---|
| 3337 |
|
|---|
| 3338 | static LRESULT
|
|---|
| 3339 | TOOLBAR_IsButtonHighlighted (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 3340 | {
|
|---|
| 3341 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 3342 | INT nIndex;
|
|---|
| 3343 |
|
|---|
| 3344 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
|
|---|
| 3345 | if (nIndex == -1)
|
|---|
| 3346 | return FALSE;
|
|---|
| 3347 |
|
|---|
| 3348 | return (infoPtr->buttons[nIndex].fsState & TBSTATE_MARKED);
|
|---|
| 3349 | }
|
|---|
| 3350 |
|
|---|
| 3351 |
|
|---|
| 3352 | static LRESULT
|
|---|
| 3353 | TOOLBAR_IsButtonIndeterminate (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 3354 | {
|
|---|
| 3355 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 3356 | INT nIndex;
|
|---|
| 3357 |
|
|---|
| 3358 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
|
|---|
| 3359 | if (nIndex == -1)
|
|---|
| 3360 | return FALSE;
|
|---|
| 3361 |
|
|---|
| 3362 | return (infoPtr->buttons[nIndex].fsState & TBSTATE_INDETERMINATE);
|
|---|
| 3363 | }
|
|---|
| 3364 |
|
|---|
| 3365 |
|
|---|
| 3366 | static LRESULT
|
|---|
| 3367 | TOOLBAR_IsButtonPressed (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 3368 | {
|
|---|
| 3369 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 3370 | INT nIndex;
|
|---|
| 3371 |
|
|---|
| 3372 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
|
|---|
| 3373 | if (nIndex == -1)
|
|---|
| 3374 | return FALSE;
|
|---|
| 3375 |
|
|---|
| 3376 | return (infoPtr->buttons[nIndex].fsState & TBSTATE_PRESSED);
|
|---|
| 3377 | }
|
|---|
| 3378 |
|
|---|
| 3379 |
|
|---|
| 3380 | /* << TOOLBAR_LoadImages >> */
|
|---|
| 3381 | /* << TOOLBAR_MapAccelerator >> */
|
|---|
| 3382 | /* << TOOLBAR_MarkButton >> */
|
|---|
| 3383 | /* << TOOLBAR_MoveButton >> */
|
|---|
| 3384 |
|
|---|
| 3385 |
|
|---|
| 3386 | static LRESULT
|
|---|
| 3387 | TOOLBAR_PressButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 3388 | {
|
|---|
| 3389 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 3390 | TBUTTON_INFO *btnPtr;
|
|---|
| 3391 | INT nIndex;
|
|---|
| 3392 |
|
|---|
| 3393 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
|
|---|
| 3394 | if (nIndex == -1)
|
|---|
| 3395 | return FALSE;
|
|---|
| 3396 |
|
|---|
| 3397 | btnPtr = &infoPtr->buttons[nIndex];
|
|---|
| 3398 | if (LOWORD(lParam) == FALSE)
|
|---|
| 3399 | btnPtr->fsState &= ~TBSTATE_PRESSED;
|
|---|
| 3400 | else
|
|---|
| 3401 | btnPtr->fsState |= TBSTATE_PRESSED;
|
|---|
| 3402 |
|
|---|
| 3403 | InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr, btnPtr));
|
|---|
| 3404 |
|
|---|
| 3405 | return TRUE;
|
|---|
| 3406 | }
|
|---|
| 3407 |
|
|---|
| 3408 |
|
|---|
| 3409 | /* << TOOLBAR_ReplaceBitmap >> */
|
|---|
| 3410 |
|
|---|
| 3411 |
|
|---|
| 3412 | static LRESULT
|
|---|
| 3413 | TOOLBAR_SaveRestoreA (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 3414 | {
|
|---|
| 3415 | #if 0
|
|---|
| 3416 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 3417 | LPTBSAVEPARAMSA lpSave = (LPTBSAVEPARAMSA)lParam;
|
|---|
| 3418 |
|
|---|
| 3419 | if (lpSave == NULL) return 0;
|
|---|
| 3420 |
|
|---|
| 3421 | if ((BOOL)wParam) {
|
|---|
| 3422 | /* save toolbar information */
|
|---|
| 3423 | FIXME("save to \"%s\" \"%s\"\n",
|
|---|
| 3424 | lpSave->pszSubKey, lpSave->pszValueName);
|
|---|
| 3425 |
|
|---|
| 3426 |
|
|---|
| 3427 | }
|
|---|
| 3428 | else {
|
|---|
| 3429 | /* restore toolbar information */
|
|---|
| 3430 |
|
|---|
| 3431 | FIXME("restore from \"%s\" \"%s\"\n",
|
|---|
| 3432 | lpSave->pszSubKey, lpSave->pszValueName);
|
|---|
| 3433 |
|
|---|
| 3434 |
|
|---|
| 3435 | }
|
|---|
| 3436 | #endif
|
|---|
| 3437 |
|
|---|
| 3438 | return 0;
|
|---|
| 3439 | }
|
|---|
| 3440 |
|
|---|
| 3441 |
|
|---|
| 3442 | static LRESULT
|
|---|
| 3443 | TOOLBAR_SaveRestoreW (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 3444 | {
|
|---|
| 3445 | #if 0
|
|---|
| 3446 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 3447 | LPTBSAVEPARAMSW lpSave = (LPTBSAVEPARAMSW)lParam;
|
|---|
| 3448 |
|
|---|
| 3449 | if (lpSave == NULL)
|
|---|
| 3450 | return 0;
|
|---|
| 3451 |
|
|---|
| 3452 | if ((BOOL)wParam) {
|
|---|
| 3453 | /* save toolbar information */
|
|---|
| 3454 | FIXME("save to \"%s\" \"%s\"\n",
|
|---|
| 3455 | lpSave->pszSubKey, lpSave->pszValueName);
|
|---|
| 3456 |
|
|---|
| 3457 |
|
|---|
| 3458 | }
|
|---|
| 3459 | else {
|
|---|
| 3460 | /* restore toolbar information */
|
|---|
| 3461 |
|
|---|
| 3462 | FIXME("restore from \"%s\" \"%s\"\n",
|
|---|
| 3463 | lpSave->pszSubKey, lpSave->pszValueName);
|
|---|
| 3464 |
|
|---|
| 3465 |
|
|---|
| 3466 | }
|
|---|
| 3467 | #endif
|
|---|
| 3468 |
|
|---|
| 3469 | return 0;
|
|---|
| 3470 | }
|
|---|
| 3471 |
|
|---|
| 3472 |
|
|---|
| 3473 | static LRESULT
|
|---|
| 3474 | TOOLBAR_SetAnchorHighlight (HWND hwnd, WPARAM wParam)
|
|---|
| 3475 | {
|
|---|
| 3476 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 3477 | BOOL bOldAnchor = infoPtr->bAnchor;
|
|---|
| 3478 |
|
|---|
| 3479 | infoPtr->bAnchor = (BOOL)wParam;
|
|---|
| 3480 |
|
|---|
| 3481 | return (LRESULT)bOldAnchor;
|
|---|
| 3482 | }
|
|---|
| 3483 |
|
|---|
| 3484 |
|
|---|
| 3485 | static LRESULT
|
|---|
| 3486 | TOOLBAR_SetBitmapSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 3487 | {
|
|---|
| 3488 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 3489 |
|
|---|
| 3490 | if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0))
|
|---|
| 3491 | return FALSE;
|
|---|
| 3492 |
|
|---|
| 3493 | if (infoPtr->nNumButtons > 0)
|
|---|
| 3494 | WARN("%d buttons, undoc increase to bitmap size : %d-%d -> %d-%d\n",
|
|---|
| 3495 | infoPtr->nNumButtons,
|
|---|
| 3496 | infoPtr->nBitmapWidth, infoPtr->nBitmapHeight,
|
|---|
| 3497 | LOWORD(lParam), HIWORD(lParam));
|
|---|
| 3498 |
|
|---|
| 3499 | infoPtr->nBitmapWidth = (INT)LOWORD(lParam);
|
|---|
| 3500 | infoPtr->nBitmapHeight = (INT)HIWORD(lParam);
|
|---|
| 3501 |
|
|---|
| 3502 | /* uses image list internals directly */
|
|---|
| 3503 | if (infoPtr->himlDef) {
|
|---|
| 3504 | infoPtr->himlDef->cx = infoPtr->nBitmapWidth;
|
|---|
| 3505 | infoPtr->himlDef->cy = infoPtr->nBitmapHeight;
|
|---|
| 3506 | }
|
|---|
| 3507 |
|
|---|
| 3508 | return TRUE;
|
|---|
| 3509 | }
|
|---|
| 3510 |
|
|---|
| 3511 |
|
|---|
| 3512 | static LRESULT
|
|---|
| 3513 | TOOLBAR_SetButtonInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 3514 | {
|
|---|
| 3515 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 3516 | LPTBBUTTONINFOA lptbbi = (LPTBBUTTONINFOA)lParam;
|
|---|
| 3517 | TBUTTON_INFO *btnPtr;
|
|---|
| 3518 | INT nIndex;
|
|---|
| 3519 |
|
|---|
| 3520 | if (lptbbi == NULL)
|
|---|
| 3521 | return FALSE;
|
|---|
| 3522 | if (lptbbi->cbSize < sizeof(TBBUTTONINFOA))
|
|---|
| 3523 | return FALSE;
|
|---|
| 3524 |
|
|---|
| 3525 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam,
|
|---|
| 3526 | lptbbi->dwMask & 0x80000000);
|
|---|
| 3527 | if (nIndex == -1)
|
|---|
| 3528 | return FALSE;
|
|---|
| 3529 |
|
|---|
| 3530 | btnPtr = &infoPtr->buttons[nIndex];
|
|---|
| 3531 | if (lptbbi->dwMask & TBIF_COMMAND)
|
|---|
| 3532 | btnPtr->idCommand = lptbbi->idCommand;
|
|---|
| 3533 | if (lptbbi->dwMask & TBIF_IMAGE)
|
|---|
| 3534 | btnPtr->iBitmap = lptbbi->iImage;
|
|---|
| 3535 | if (lptbbi->dwMask & TBIF_LPARAM)
|
|---|
| 3536 | btnPtr->dwData = lptbbi->lParam;
|
|---|
| 3537 | /* if (lptbbi->dwMask & TBIF_SIZE) */
|
|---|
| 3538 | /* btnPtr->cx = lptbbi->cx; */
|
|---|
| 3539 | if (lptbbi->dwMask & TBIF_STATE)
|
|---|
| 3540 | btnPtr->fsState = lptbbi->fsState;
|
|---|
| 3541 | if (lptbbi->dwMask & TBIF_STYLE)
|
|---|
| 3542 | btnPtr->fsStyle = lptbbi->fsStyle;
|
|---|
| 3543 |
|
|---|
| 3544 | if ((lptbbi->dwMask & TBIF_TEXT) && ((INT)lptbbi->pszText != -1)) {
|
|---|
| 3545 | if ((HIWORD(btnPtr->iString) == 0) || (btnPtr->iString == -1))
|
|---|
| 3546 | /* iString is index, zero it to make Str_SetPtr succeed */
|
|---|
| 3547 | btnPtr->iString=0;
|
|---|
| 3548 |
|
|---|
| 3549 | Str_SetPtrAtoW ((LPWSTR *)&btnPtr->iString, lptbbi->pszText);
|
|---|
| 3550 | }
|
|---|
| 3551 | return TRUE;
|
|---|
| 3552 | }
|
|---|
| 3553 |
|
|---|
| 3554 |
|
|---|
| 3555 | static LRESULT
|
|---|
| 3556 | TOOLBAR_SetButtonInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 3557 | {
|
|---|
| 3558 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 3559 | LPTBBUTTONINFOW lptbbi = (LPTBBUTTONINFOW)lParam;
|
|---|
| 3560 | TBUTTON_INFO *btnPtr;
|
|---|
| 3561 | INT nIndex;
|
|---|
| 3562 |
|
|---|
| 3563 | if (lptbbi == NULL)
|
|---|
| 3564 | return FALSE;
|
|---|
| 3565 | if (lptbbi->cbSize < sizeof(TBBUTTONINFOW))
|
|---|
| 3566 | return FALSE;
|
|---|
| 3567 |
|
|---|
| 3568 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam,
|
|---|
| 3569 | lptbbi->dwMask & 0x80000000);
|
|---|
| 3570 | if (nIndex == -1)
|
|---|
| 3571 | return FALSE;
|
|---|
| 3572 |
|
|---|
| 3573 | btnPtr = &infoPtr->buttons[nIndex];
|
|---|
| 3574 | if (lptbbi->dwMask & TBIF_COMMAND)
|
|---|
| 3575 | btnPtr->idCommand = lptbbi->idCommand;
|
|---|
| 3576 | if (lptbbi->dwMask & TBIF_IMAGE)
|
|---|
| 3577 | btnPtr->iBitmap = lptbbi->iImage;
|
|---|
| 3578 | if (lptbbi->dwMask & TBIF_LPARAM)
|
|---|
| 3579 | btnPtr->dwData = lptbbi->lParam;
|
|---|
| 3580 | /* if (lptbbi->dwMask & TBIF_SIZE) */
|
|---|
| 3581 | /* btnPtr->cx = lptbbi->cx; */
|
|---|
| 3582 | if (lptbbi->dwMask & TBIF_STATE)
|
|---|
| 3583 | btnPtr->fsState = lptbbi->fsState;
|
|---|
| 3584 | if (lptbbi->dwMask & TBIF_STYLE)
|
|---|
| 3585 | btnPtr->fsStyle = lptbbi->fsStyle;
|
|---|
| 3586 |
|
|---|
| 3587 | if ((lptbbi->dwMask & TBIF_TEXT) && ((INT)lptbbi->pszText != -1)) {
|
|---|
| 3588 | if ((HIWORD(btnPtr->iString) == 0) || (btnPtr->iString == -1))
|
|---|
| 3589 | /* iString is index, zero it to make Str_SetPtr succeed */
|
|---|
| 3590 | btnPtr->iString=0;
|
|---|
| 3591 | Str_SetPtrW ((LPWSTR *)&btnPtr->iString, lptbbi->pszText);
|
|---|
| 3592 | }
|
|---|
| 3593 | return TRUE;
|
|---|
| 3594 | }
|
|---|
| 3595 |
|
|---|
| 3596 |
|
|---|
| 3597 | static LRESULT
|
|---|
| 3598 | TOOLBAR_SetButtonSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 3599 | {
|
|---|
| 3600 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 3601 |
|
|---|
| 3602 | if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0))
|
|---|
| 3603 | {
|
|---|
| 3604 | ERR("invalid parameter\n");
|
|---|
| 3605 | return FALSE;
|
|---|
| 3606 | }
|
|---|
| 3607 |
|
|---|
| 3608 | /* The documentation claims you can only change the button size before
|
|---|
| 3609 | * any button has been added. But this is wrong.
|
|---|
| 3610 | * WINZIP32.EXE (ver 8) calls this on one of its buttons after adding
|
|---|
| 3611 | * it to the toolbar, and it checks that the return value is nonzero - mjm
|
|---|
| 3612 | * Further testing shows that we must actually perform the change too.
|
|---|
| 3613 | */
|
|---|
| 3614 | infoPtr->nButtonWidth = (INT)LOWORD(lParam);
|
|---|
| 3615 | infoPtr->nButtonHeight = (INT)HIWORD(lParam);
|
|---|
| 3616 | return TRUE;
|
|---|
| 3617 | }
|
|---|
| 3618 |
|
|---|
| 3619 |
|
|---|
| 3620 | static LRESULT
|
|---|
| 3621 | TOOLBAR_SetButtonWidth (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 3622 | {
|
|---|
| 3623 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 3624 |
|
|---|
| 3625 | if (infoPtr == NULL) {
|
|---|
| 3626 | TRACE("Toolbar not initialized yet?????\n");
|
|---|
| 3627 | return FALSE;
|
|---|
| 3628 | }
|
|---|
| 3629 |
|
|---|
| 3630 | /* if setting to current values, ignore */
|
|---|
| 3631 | if ((infoPtr->cxMin == (INT)LOWORD(lParam)) &&
|
|---|
| 3632 | (infoPtr->cxMax == (INT)HIWORD(lParam))) {
|
|---|
| 3633 | TRACE("matches current width, min=%d, max=%d, no recalc\n",
|
|---|
| 3634 | infoPtr->cxMin, infoPtr->cxMax);
|
|---|
| 3635 | return TRUE;
|
|---|
| 3636 | }
|
|---|
| 3637 |
|
|---|
| 3638 | /* save new values */
|
|---|
| 3639 | infoPtr->cxMin = (INT)LOWORD(lParam);
|
|---|
| 3640 | infoPtr->cxMax = (INT)HIWORD(lParam);
|
|---|
| 3641 |
|
|---|
| 3642 | /* if both values are 0 then we are done */
|
|---|
| 3643 | if (lParam == 0) {
|
|---|
| 3644 | TRACE("setting both min and max to 0, norecalc\n");
|
|---|
| 3645 | return TRUE;
|
|---|
| 3646 | }
|
|---|
| 3647 |
|
|---|
| 3648 | /* otherwise we need to recalc the toolbar and in some cases
|
|---|
| 3649 | recalc the bounding rectangle (does DrawText w/ DT_CALCRECT
|
|---|
| 3650 | which doesn't actually draw - GA). */
|
|---|
| 3651 | TRACE("number of buttons %d, cx=%d, cy=%d, recalcing\n",
|
|---|
| 3652 | infoPtr->nNumButtons, infoPtr->cxMin, infoPtr->cxMax);
|
|---|
| 3653 |
|
|---|
| 3654 | TOOLBAR_CalcToolbar (hwnd);
|
|---|
| 3655 |
|
|---|
| 3656 | InvalidateRect (hwnd, NULL, TRUE);
|
|---|
| 3657 |
|
|---|
| 3658 | return TRUE;
|
|---|
| 3659 | }
|
|---|
| 3660 |
|
|---|
| 3661 |
|
|---|
| 3662 | static LRESULT
|
|---|
| 3663 | TOOLBAR_SetCmdId (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 3664 | {
|
|---|
| 3665 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 3666 | INT nIndex = (INT)wParam;
|
|---|
| 3667 |
|
|---|
| 3668 | if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
|
|---|
| 3669 | return FALSE;
|
|---|
| 3670 |
|
|---|
| 3671 | infoPtr->buttons[nIndex].idCommand = (INT)lParam;
|
|---|
| 3672 |
|
|---|
| 3673 | if (infoPtr->hwndToolTip) {
|
|---|
| 3674 |
|
|---|
| 3675 | FIXME("change tool tip!\n");
|
|---|
| 3676 |
|
|---|
| 3677 | }
|
|---|
| 3678 |
|
|---|
| 3679 | return TRUE;
|
|---|
| 3680 | }
|
|---|
| 3681 |
|
|---|
| 3682 |
|
|---|
| 3683 | /* << TOOLBAR_SetColorScheme >> */
|
|---|
| 3684 |
|
|---|
| 3685 |
|
|---|
| 3686 | static LRESULT
|
|---|
| 3687 | TOOLBAR_SetDisabledImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 3688 | {
|
|---|
| 3689 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 3690 | HIMAGELIST himlTemp;
|
|---|
| 3691 |
|
|---|
| 3692 |
|
|---|
| 3693 | if (wParam != 0) {
|
|---|
| 3694 | FIXME("no support for multiple image lists\n");
|
|---|
| 3695 | return 0;
|
|---|
| 3696 | }
|
|---|
| 3697 |
|
|---|
| 3698 | himlTemp = infoPtr->himlDis;
|
|---|
| 3699 | infoPtr->himlDis = (HIMAGELIST)lParam;
|
|---|
| 3700 |
|
|---|
| 3701 | /* FIXME: redraw ? */
|
|---|
| 3702 |
|
|---|
| 3703 | return (LRESULT)himlTemp;
|
|---|
| 3704 | }
|
|---|
| 3705 |
|
|---|
| 3706 |
|
|---|
| 3707 | static LRESULT
|
|---|
| 3708 | TOOLBAR_SetDrawTextFlags (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 3709 | {
|
|---|
| 3710 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 3711 | DWORD dwTemp;
|
|---|
| 3712 |
|
|---|
| 3713 | dwTemp = infoPtr->dwDTFlags;
|
|---|
| 3714 | infoPtr->dwDTFlags =
|
|---|
| 3715 | (infoPtr->dwDTFlags & (DWORD)wParam) | (DWORD)lParam;
|
|---|
| 3716 |
|
|---|
| 3717 | return (LRESULT)dwTemp;
|
|---|
| 3718 | }
|
|---|
| 3719 |
|
|---|
| 3720 |
|
|---|
| 3721 | static LRESULT
|
|---|
| 3722 | TOOLBAR_SetExtendedStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 3723 | {
|
|---|
| 3724 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 3725 | DWORD dwTemp;
|
|---|
| 3726 |
|
|---|
| 3727 | dwTemp = infoPtr->dwExStyle;
|
|---|
| 3728 | infoPtr->dwExStyle = (DWORD)lParam;
|
|---|
| 3729 |
|
|---|
| 3730 | return (LRESULT)dwTemp;
|
|---|
| 3731 | }
|
|---|
| 3732 |
|
|---|
| 3733 |
|
|---|
| 3734 | static LRESULT
|
|---|
| 3735 | TOOLBAR_SetHotImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 3736 | {
|
|---|
| 3737 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
|
|---|
| 3738 | HIMAGELIST himlTemp;
|
|---|
| 3739 |
|
|---|
| 3740 | if (wParam != 0) {
|
|---|
| 3741 | FIXME("no support for multiple image lists\n");
|
|---|
| 3742 | return 0;
|
|---|
| 3743 | }
|
|---|
| 3744 |
|
|---|
| 3745 | himlTemp = infoPtr->himlHot;
|
|---|
| 3746 | infoPtr->himlHot = (HIMAGELIST)lParam;
|
|---|
| 3747 |
|
|---|
| 3748 | /* FIXME: redraw ? */
|
|---|
| 3749 |
|
|---|
| 3750 | return (LRESULT)himlTemp;
|
|---|
| 3751 | }
|
|---|
| 3752 |
|
|---|
| 3753 |
|
|---|
| 3754 | static LRESULT
|
|---|
| 3755 | TOOLBAR_SetHotItem (HWND hwnd, WPARAM wParam)
|
|---|
| 3756 | {
|
|---|
| 3757 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
|
|---|
| 3758 | INT nOldHotItem = infoPtr->nHotItem;
|
|---|
| 3759 | TBUTTON_INFO *btnPtr;
|
|---|
| 3760 |
|
|---|
| 3761 | if ((INT) wParam < 0 || (INT)wParam > infoPtr->nNumButtons)
|
|---|
| 3762 | wParam = -2;
|
|---|
| 3763 |
|
|---|
| 3764 | if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT)
|
|---|
| 3765 | {
|
|---|
| 3766 |
|
|---|
| 3767 | infoPtr->nHotItem = (INT)wParam;
|
|---|
| 3768 | if ((INT)wParam >=0)
|
|---|
| 3769 | {
|
|---|
| 3770 | btnPtr = &infoPtr->buttons[(INT)wParam];
|
|---|
| 3771 | btnPtr->bHot = TRUE;
|
|---|
| 3772 | InvalidateRect (hwnd, &btnPtr->rect,
|
|---|
| 3773 | TOOLBAR_HasText(infoPtr, btnPtr));
|
|---|
| 3774 | }
|
|---|
| 3775 | if (nOldHotItem>=0)
|
|---|
| 3776 | {
|
|---|
| 3777 | btnPtr = &infoPtr->buttons[nOldHotItem];
|
|---|
| 3778 | btnPtr->bHot = FALSE;
|
|---|
| 3779 | InvalidateRect (hwnd, &btnPtr->rect,
|
|---|
| 3780 | TOOLBAR_HasText(infoPtr, btnPtr));
|
|---|
| 3781 | }
|
|---|
| 3782 | }
|
|---|
| 3783 |
|
|---|
| 3784 | if (nOldHotItem < 0)
|
|---|
| 3785 | return -1;
|
|---|
| 3786 |
|
|---|
| 3787 | return (LRESULT)nOldHotItem;
|
|---|
| 3788 | }
|
|---|
| 3789 |
|
|---|
| 3790 |
|
|---|
| 3791 | static LRESULT
|
|---|
| 3792 | TOOLBAR_SetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 3793 | {
|
|---|
| 3794 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 3795 | HIMAGELIST himlTemp;
|
|---|
| 3796 |
|
|---|
| 3797 | if (wParam != 0) {
|
|---|
| 3798 | FIXME("no support for multiple image lists\n");
|
|---|
| 3799 | return 0;
|
|---|
| 3800 | }
|
|---|
| 3801 |
|
|---|
| 3802 | himlTemp = infoPtr->himlDef;
|
|---|
| 3803 | infoPtr->himlDef = (HIMAGELIST)lParam;
|
|---|
| 3804 |
|
|---|
| 3805 | infoPtr->nNumBitmaps = ImageList_GetImageCount(infoPtr->himlDef);
|
|---|
| 3806 |
|
|---|
| 3807 | ImageList_GetIconSize(infoPtr->himlDef, &infoPtr->nBitmapWidth,
|
|---|
| 3808 | &infoPtr->nBitmapHeight);
|
|---|
| 3809 | TRACE("hwnd %08x, new himl=%08x, count=%d, bitmap w=%d, h=%d\n",
|
|---|
| 3810 | hwnd, (INT)infoPtr->himlDef, infoPtr->nNumBitmaps,
|
|---|
| 3811 | infoPtr->nBitmapWidth, infoPtr->nBitmapHeight);
|
|---|
| 3812 |
|
|---|
| 3813 | /* FIXME: redraw ? */
|
|---|
| 3814 | InvalidateRect(hwnd, NULL, TRUE);
|
|---|
| 3815 |
|
|---|
| 3816 | return (LRESULT)himlTemp;
|
|---|
| 3817 | }
|
|---|
| 3818 |
|
|---|
| 3819 |
|
|---|
| 3820 | static LRESULT
|
|---|
| 3821 | TOOLBAR_SetIndent (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 3822 | {
|
|---|
| 3823 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 3824 |
|
|---|
| 3825 | infoPtr->nIndent = (INT)wParam;
|
|---|
| 3826 |
|
|---|
| 3827 | TRACE("\n");
|
|---|
| 3828 |
|
|---|
| 3829 | /* process only on indent changing */
|
|---|
| 3830 | if(infoPtr->nIndent != (INT)wParam)
|
|---|
| 3831 | {
|
|---|
| 3832 | infoPtr->nIndent = (INT)wParam;
|
|---|
| 3833 | TOOLBAR_CalcToolbar (hwnd);
|
|---|
| 3834 | InvalidateRect(hwnd, NULL, FALSE);
|
|---|
| 3835 | }
|
|---|
| 3836 |
|
|---|
| 3837 | return TRUE;
|
|---|
| 3838 | }
|
|---|
| 3839 |
|
|---|
| 3840 |
|
|---|
| 3841 | /* << TOOLBAR_SetInsertMark >> */
|
|---|
| 3842 |
|
|---|
| 3843 |
|
|---|
| 3844 | static LRESULT
|
|---|
| 3845 | TOOLBAR_SetInsertMarkColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 3846 | {
|
|---|
| 3847 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 3848 |
|
|---|
| 3849 | infoPtr->clrInsertMark = (COLORREF)lParam;
|
|---|
| 3850 |
|
|---|
| 3851 | /* FIXME : redraw ??*/
|
|---|
| 3852 |
|
|---|
| 3853 | return 0;
|
|---|
| 3854 | }
|
|---|
| 3855 |
|
|---|
| 3856 |
|
|---|
| 3857 | static LRESULT
|
|---|
| 3858 | TOOLBAR_SetMaxTextRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 3859 | {
|
|---|
| 3860 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 3861 |
|
|---|
| 3862 | if (infoPtr == NULL)
|
|---|
| 3863 | return FALSE;
|
|---|
| 3864 |
|
|---|
| 3865 | infoPtr->nMaxTextRows = (INT)wParam;
|
|---|
| 3866 |
|
|---|
| 3867 | return TRUE;
|
|---|
| 3868 | }
|
|---|
| 3869 |
|
|---|
| 3870 |
|
|---|
| 3871 | /* << TOOLBAR_SetPadding >> */
|
|---|
| 3872 |
|
|---|
| 3873 |
|
|---|
| 3874 | static LRESULT
|
|---|
| 3875 | TOOLBAR_SetParent (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 3876 | {
|
|---|
| 3877 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 3878 | HWND hwndOldNotify;
|
|---|
| 3879 |
|
|---|
| 3880 | TRACE("\n");
|
|---|
| 3881 |
|
|---|
| 3882 | if (infoPtr == NULL)
|
|---|
| 3883 | return 0;
|
|---|
| 3884 | hwndOldNotify = infoPtr->hwndNotify;
|
|---|
| 3885 | infoPtr->hwndNotify = (HWND)wParam;
|
|---|
| 3886 |
|
|---|
| 3887 | return hwndOldNotify;
|
|---|
| 3888 | }
|
|---|
| 3889 |
|
|---|
| 3890 |
|
|---|
| 3891 | static LRESULT
|
|---|
| 3892 | TOOLBAR_SetRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 3893 | {
|
|---|
| 3894 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 3895 | LPRECT lprc = (LPRECT)lParam;
|
|---|
| 3896 |
|
|---|
| 3897 | TRACE("\n");
|
|---|
| 3898 |
|
|---|
| 3899 | if (LOWORD(wParam) > 1) {
|
|---|
| 3900 | FIXME("multiple rows not supported!\n");
|
|---|
| 3901 | }
|
|---|
| 3902 |
|
|---|
| 3903 | if(infoPtr->nRows != LOWORD(wParam))
|
|---|
| 3904 | {
|
|---|
| 3905 | infoPtr->nRows = LOWORD(wParam);
|
|---|
| 3906 |
|
|---|
| 3907 | /* recalculate toolbar */
|
|---|
| 3908 | TOOLBAR_CalcToolbar (hwnd);
|
|---|
| 3909 |
|
|---|
| 3910 | /* repaint toolbar */
|
|---|
| 3911 | InvalidateRect(hwnd, NULL, FALSE);
|
|---|
| 3912 | }
|
|---|
| 3913 |
|
|---|
| 3914 | /* return bounding rectangle */
|
|---|
| 3915 | if (lprc) {
|
|---|
| 3916 | lprc->left = infoPtr->rcBound.left;
|
|---|
| 3917 | lprc->right = infoPtr->rcBound.right;
|
|---|
| 3918 | lprc->top = infoPtr->rcBound.top;
|
|---|
| 3919 | lprc->bottom = infoPtr->rcBound.bottom;
|
|---|
| 3920 | }
|
|---|
| 3921 |
|
|---|
| 3922 | return 0;
|
|---|
| 3923 | }
|
|---|
| 3924 |
|
|---|
| 3925 |
|
|---|
| 3926 | static LRESULT
|
|---|
| 3927 | TOOLBAR_SetState (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 3928 | {
|
|---|
| 3929 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 3930 | TBUTTON_INFO *btnPtr;
|
|---|
| 3931 | INT nIndex;
|
|---|
| 3932 |
|
|---|
| 3933 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
|
|---|
| 3934 | if (nIndex == -1)
|
|---|
| 3935 | return FALSE;
|
|---|
| 3936 |
|
|---|
| 3937 | btnPtr = &infoPtr->buttons[nIndex];
|
|---|
| 3938 |
|
|---|
| 3939 | /* if hidden state has changed the invalidate entire window and recalc */
|
|---|
| 3940 | if ((btnPtr->fsState & TBSTATE_HIDDEN) != (LOWORD(lParam) & TBSTATE_HIDDEN)) {
|
|---|
| 3941 | btnPtr->fsState = LOWORD(lParam);
|
|---|
| 3942 | TOOLBAR_CalcToolbar (hwnd);
|
|---|
| 3943 | InvalidateRect(hwnd, 0, TOOLBAR_HasText(infoPtr, btnPtr));
|
|---|
| 3944 | return TRUE;
|
|---|
| 3945 | }
|
|---|
| 3946 |
|
|---|
| 3947 | /* process state changing if current state doesn't match new state */
|
|---|
| 3948 | if(btnPtr->fsState != LOWORD(lParam))
|
|---|
| 3949 | {
|
|---|
| 3950 | btnPtr->fsState = LOWORD(lParam);
|
|---|
| 3951 | InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr,
|
|---|
| 3952 | btnPtr));
|
|---|
| 3953 | }
|
|---|
| 3954 |
|
|---|
| 3955 | return TRUE;
|
|---|
| 3956 | }
|
|---|
| 3957 |
|
|---|
| 3958 |
|
|---|
| 3959 | static LRESULT
|
|---|
| 3960 | TOOLBAR_SetStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 3961 | {
|
|---|
| 3962 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 3963 | TBUTTON_INFO *btnPtr;
|
|---|
| 3964 | INT nIndex;
|
|---|
| 3965 |
|
|---|
| 3966 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
|
|---|
| 3967 | if (nIndex == -1)
|
|---|
| 3968 | return FALSE;
|
|---|
| 3969 |
|
|---|
| 3970 | btnPtr = &infoPtr->buttons[nIndex];
|
|---|
| 3971 |
|
|---|
| 3972 | /* process style change if current style doesn't match new style */
|
|---|
| 3973 | if(btnPtr->fsStyle != LOWORD(lParam))
|
|---|
| 3974 | {
|
|---|
| 3975 | btnPtr->fsStyle = LOWORD(lParam);
|
|---|
| 3976 | InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr,
|
|---|
| 3977 | btnPtr));
|
|---|
| 3978 |
|
|---|
| 3979 | if (infoPtr->hwndToolTip) {
|
|---|
| 3980 | FIXME("change tool tip!\n");
|
|---|
| 3981 | }
|
|---|
| 3982 | }
|
|---|
| 3983 |
|
|---|
| 3984 | return TRUE;
|
|---|
| 3985 | }
|
|---|
| 3986 |
|
|---|
| 3987 |
|
|---|
| 3988 | inline static LRESULT
|
|---|
| 3989 | TOOLBAR_SetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 3990 | {
|
|---|
| 3991 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 3992 |
|
|---|
| 3993 | if (infoPtr == NULL)
|
|---|
| 3994 | return 0;
|
|---|
| 3995 | infoPtr->hwndToolTip = (HWND)wParam;
|
|---|
| 3996 | return 0;
|
|---|
| 3997 | }
|
|---|
| 3998 |
|
|---|
| 3999 |
|
|---|
| 4000 | static LRESULT
|
|---|
| 4001 | TOOLBAR_SetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 4002 | {
|
|---|
| 4003 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 4004 | BOOL bTemp;
|
|---|
| 4005 |
|
|---|
| 4006 | TRACE("%s hwnd=0x%04x stub!\n",
|
|---|
| 4007 | ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd);
|
|---|
| 4008 |
|
|---|
| 4009 | bTemp = infoPtr->bUnicode;
|
|---|
| 4010 | infoPtr->bUnicode = (BOOL)wParam;
|
|---|
| 4011 |
|
|---|
| 4012 | return bTemp;
|
|---|
| 4013 | }
|
|---|
| 4014 |
|
|---|
| 4015 |
|
|---|
| 4016 | static LRESULT
|
|---|
| 4017 | TOOLBAR_SetVersion (HWND hwnd, INT iVersion)
|
|---|
| 4018 | {
|
|---|
| 4019 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 4020 | INT iOldVersion = infoPtr->iVersion;
|
|---|
| 4021 |
|
|---|
| 4022 | infoPtr->iVersion = iVersion;
|
|---|
| 4023 |
|
|---|
| 4024 | return iOldVersion;
|
|---|
| 4025 | }
|
|---|
| 4026 |
|
|---|
| 4027 |
|
|---|
| 4028 | static LRESULT
|
|---|
| 4029 | TOOLBAR_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 4030 | {
|
|---|
| 4031 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 4032 | DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
|
|---|
| 4033 | LOGFONTA logFont;
|
|---|
| 4034 |
|
|---|
| 4035 | /* initialize info structure */
|
|---|
| 4036 | infoPtr->nButtonHeight = 22;
|
|---|
| 4037 | infoPtr->nButtonWidth = 24;
|
|---|
| 4038 | infoPtr->nBitmapHeight = 15;
|
|---|
| 4039 | infoPtr->nBitmapWidth = 16;
|
|---|
| 4040 |
|
|---|
| 4041 | infoPtr->nHeight = infoPtr->nButtonHeight + TOP_BORDER + BOTTOM_BORDER;
|
|---|
| 4042 | infoPtr->nRows = 1;
|
|---|
| 4043 | infoPtr->nMaxTextRows = 1;
|
|---|
| 4044 | infoPtr->cxMin = -1;
|
|---|
| 4045 | infoPtr->cxMax = -1;
|
|---|
| 4046 | infoPtr->nNumBitmaps = 0;
|
|---|
| 4047 | infoPtr->nNumStrings = 0;
|
|---|
| 4048 |
|
|---|
| 4049 | infoPtr->bCaptured = FALSE;
|
|---|
| 4050 | infoPtr->bUnicode = IsWindowUnicode (hwnd);
|
|---|
| 4051 | infoPtr->nButtonDown = -1;
|
|---|
| 4052 | infoPtr->nOldHit = -1;
|
|---|
| 4053 | infoPtr->nHotItem = -2; /* It has to be initially different from nOldHit */
|
|---|
| 4054 | infoPtr->hwndNotify = GetParent (hwnd);
|
|---|
| 4055 | infoPtr->bTransparent = (dwStyle & TBSTYLE_TRANSPARENT);
|
|---|
| 4056 | infoPtr->bBtnTranspnt = (dwStyle & (TBSTYLE_FLAT | TBSTYLE_LIST));
|
|---|
| 4057 | infoPtr->dwDTFlags = (dwStyle & TBSTYLE_LIST) ? DT_LEFT | DT_VCENTER | DT_SINGLELINE : DT_CENTER;
|
|---|
| 4058 | infoPtr->bAnchor = FALSE; /* no anchor highlighting */
|
|---|
| 4059 | infoPtr->iVersion = 0;
|
|---|
| 4060 | infoPtr->bNtfUnicode = FALSE;
|
|---|
| 4061 | infoPtr->hwndSelf = hwnd;
|
|---|
| 4062 | infoPtr->bDoRedraw = TRUE;
|
|---|
| 4063 |
|
|---|
| 4064 | SystemParametersInfoA (SPI_GETICONTITLELOGFONT, 0, &logFont, 0);
|
|---|
| 4065 | infoPtr->hFont = infoPtr->hDefaultFont = CreateFontIndirectA (&logFont);
|
|---|
| 4066 |
|
|---|
| 4067 | if (dwStyle & TBSTYLE_TOOLTIPS) {
|
|---|
| 4068 | /* Create tooltip control */
|
|---|
| 4069 | infoPtr->hwndToolTip =
|
|---|
| 4070 | CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
|
|---|
| 4071 | CW_USEDEFAULT, CW_USEDEFAULT,
|
|---|
| 4072 | CW_USEDEFAULT, CW_USEDEFAULT,
|
|---|
| 4073 | hwnd, 0, 0, 0);
|
|---|
| 4074 |
|
|---|
| 4075 | /* Send NM_TOOLTIPSCREATED notification */
|
|---|
| 4076 | if (infoPtr->hwndToolTip) {
|
|---|
| 4077 | NMTOOLTIPSCREATED nmttc;
|
|---|
| 4078 |
|
|---|
| 4079 | nmttc.hwndToolTips = infoPtr->hwndToolTip;
|
|---|
| 4080 |
|
|---|
| 4081 | TOOLBAR_SendNotify ((NMHDR *) &nmttc, infoPtr,
|
|---|
| 4082 | NM_TOOLTIPSCREATED);
|
|---|
| 4083 | }
|
|---|
| 4084 | }
|
|---|
| 4085 |
|
|---|
| 4086 | TOOLBAR_CheckStyle (hwnd, dwStyle);
|
|---|
| 4087 |
|
|---|
| 4088 | TOOLBAR_CalcToolbar(hwnd);
|
|---|
| 4089 |
|
|---|
| 4090 | return 0;
|
|---|
| 4091 | }
|
|---|
| 4092 |
|
|---|
| 4093 |
|
|---|
| 4094 | static LRESULT
|
|---|
| 4095 | TOOLBAR_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 4096 | {
|
|---|
| 4097 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 4098 |
|
|---|
| 4099 | /* delete tooltip control */
|
|---|
| 4100 | if (infoPtr->hwndToolTip)
|
|---|
| 4101 | DestroyWindow (infoPtr->hwndToolTip);
|
|---|
| 4102 |
|
|---|
| 4103 | /* delete button data */
|
|---|
| 4104 | if (infoPtr->buttons)
|
|---|
| 4105 | COMCTL32_Free (infoPtr->buttons);
|
|---|
| 4106 |
|
|---|
| 4107 | /* delete strings */
|
|---|
| 4108 | if (infoPtr->strings) {
|
|---|
| 4109 | INT i;
|
|---|
| 4110 | for (i = 0; i < infoPtr->nNumStrings; i++)
|
|---|
| 4111 | if (infoPtr->strings[i])
|
|---|
| 4112 | COMCTL32_Free (infoPtr->strings[i]);
|
|---|
| 4113 |
|
|---|
| 4114 | COMCTL32_Free (infoPtr->strings);
|
|---|
| 4115 | }
|
|---|
| 4116 |
|
|---|
| 4117 | /* destroy internal image list */
|
|---|
| 4118 | if (infoPtr->himlInt)
|
|---|
| 4119 | ImageList_Destroy (infoPtr->himlInt);
|
|---|
| 4120 |
|
|---|
| 4121 | /* delete default font */
|
|---|
| 4122 | if (infoPtr->hFont)
|
|---|
| 4123 | DeleteObject (infoPtr->hDefaultFont);
|
|---|
| 4124 |
|
|---|
| 4125 | /* free toolbar info data */
|
|---|
| 4126 | COMCTL32_Free (infoPtr);
|
|---|
| 4127 | SetWindowLongA (hwnd, 0, 0);
|
|---|
| 4128 |
|
|---|
| 4129 | return 0;
|
|---|
| 4130 | }
|
|---|
| 4131 |
|
|---|
| 4132 |
|
|---|
| 4133 | static LRESULT
|
|---|
| 4134 | TOOLBAR_EraseBackground (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 4135 | {
|
|---|
| 4136 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 4137 | DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
|
|---|
| 4138 | NMTBCUSTOMDRAW tbcd;
|
|---|
| 4139 | INT ret = FALSE, ntfret;
|
|---|
| 4140 |
|
|---|
| 4141 | if (dwStyle & TBSTYLE_CUSTOMERASE) {
|
|---|
| 4142 | ZeroMemory (&tbcd, sizeof(NMTBCUSTOMDRAW));
|
|---|
| 4143 | tbcd.nmcd.dwDrawStage = CDDS_PREERASE;
|
|---|
| 4144 | tbcd.nmcd.hdc = (HDC)wParam;
|
|---|
| 4145 | ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
|
|---|
| 4146 | /* FIXME: in general the return flags *can* be or'ed together */
|
|---|
| 4147 | switch (ntfret)
|
|---|
| 4148 | {
|
|---|
| 4149 | case CDRF_DODEFAULT:
|
|---|
| 4150 | break;
|
|---|
| 4151 | case CDRF_SKIPDEFAULT:
|
|---|
| 4152 | return TRUE;
|
|---|
| 4153 | default:
|
|---|
| 4154 | FIXME("[%04x] response %d not handled to NM_CUSTOMDRAW (CDDS_PREERASE)\n",
|
|---|
| 4155 | hwnd, ntfret);
|
|---|
| 4156 | }
|
|---|
| 4157 | }
|
|---|
| 4158 |
|
|---|
| 4159 | /* If the toolbar is "transparent" then pass the WM_ERASEBKGND up
|
|---|
| 4160 | * to my parent for processing.
|
|---|
| 4161 | */
|
|---|
| 4162 | if (infoPtr->bTransparent) {
|
|---|
| 4163 | POINT pt, ptorig;
|
|---|
| 4164 | HDC hdc = (HDC)wParam;
|
|---|
| 4165 | HWND parent;
|
|---|
| 4166 |
|
|---|
| 4167 | pt.x = 0;
|
|---|
| 4168 | pt.y = 0;
|
|---|
| 4169 | parent = GetParent(hwnd);
|
|---|
| 4170 | MapWindowPoints(hwnd, parent, &pt, 1);
|
|---|
| 4171 | OffsetWindowOrgEx (hdc, pt.x, pt.y, &ptorig);
|
|---|
| 4172 | ret = SendMessageA (parent, WM_ERASEBKGND, wParam, lParam);
|
|---|
| 4173 | SetWindowOrgEx (hdc, ptorig.x, ptorig.y, 0);
|
|---|
| 4174 | }
|
|---|
| 4175 | if (!ret)
|
|---|
| 4176 | ret = DefWindowProcA (hwnd, WM_ERASEBKGND, wParam, lParam);
|
|---|
| 4177 |
|
|---|
| 4178 | if (dwStyle & TBSTYLE_CUSTOMERASE) {
|
|---|
| 4179 | ZeroMemory (&tbcd, sizeof(NMTBCUSTOMDRAW));
|
|---|
| 4180 | tbcd.nmcd.dwDrawStage = CDDS_POSTERASE;
|
|---|
| 4181 | tbcd.nmcd.hdc = (HDC)wParam;
|
|---|
| 4182 | ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
|
|---|
| 4183 | switch (ntfret)
|
|---|
| 4184 | {
|
|---|
| 4185 | case CDRF_DODEFAULT:
|
|---|
| 4186 | break;
|
|---|
| 4187 | case CDRF_SKIPDEFAULT:
|
|---|
| 4188 | return TRUE;
|
|---|
| 4189 | default:
|
|---|
| 4190 | FIXME("[%04x] response %d not handled to NM_CUSTOMDRAW (CDDS_PREERASE)\n",
|
|---|
| 4191 | hwnd, ntfret);
|
|---|
| 4192 | }
|
|---|
| 4193 | }
|
|---|
| 4194 | return ret;
|
|---|
| 4195 | }
|
|---|
| 4196 |
|
|---|
| 4197 |
|
|---|
| 4198 | static LRESULT
|
|---|
| 4199 | TOOLBAR_GetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 4200 | {
|
|---|
| 4201 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 4202 |
|
|---|
| 4203 | return infoPtr->hFont;
|
|---|
| 4204 | }
|
|---|
| 4205 |
|
|---|
| 4206 |
|
|---|
| 4207 | static LRESULT
|
|---|
| 4208 | TOOLBAR_LButtonDblClk (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 4209 | {
|
|---|
| 4210 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 4211 | TBUTTON_INFO *btnPtr;
|
|---|
| 4212 | POINT pt;
|
|---|
| 4213 | INT nHit;
|
|---|
| 4214 |
|
|---|
| 4215 | pt.x = (INT)LOWORD(lParam);
|
|---|
| 4216 | pt.y = (INT)HIWORD(lParam);
|
|---|
| 4217 | nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
|
|---|
| 4218 |
|
|---|
| 4219 | if (nHit >= 0) {
|
|---|
| 4220 | btnPtr = &infoPtr->buttons[nHit];
|
|---|
| 4221 | if (!(btnPtr->fsState & TBSTATE_ENABLED))
|
|---|
| 4222 | return 0;
|
|---|
| 4223 | SetCapture (hwnd);
|
|---|
| 4224 | infoPtr->bCaptured = TRUE;
|
|---|
| 4225 | infoPtr->nButtonDown = nHit;
|
|---|
| 4226 |
|
|---|
| 4227 | btnPtr->fsState |= TBSTATE_PRESSED;
|
|---|
| 4228 |
|
|---|
| 4229 | InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr,
|
|---|
| 4230 | btnPtr));
|
|---|
| 4231 | }
|
|---|
| 4232 | else if (GetWindowLongA (hwnd, GWL_STYLE) & CCS_ADJUSTABLE)
|
|---|
| 4233 | TOOLBAR_Customize (hwnd);
|
|---|
| 4234 |
|
|---|
| 4235 | return 0;
|
|---|
| 4236 | }
|
|---|
| 4237 |
|
|---|
| 4238 |
|
|---|
| 4239 | static LRESULT
|
|---|
| 4240 | TOOLBAR_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 4241 | {
|
|---|
| 4242 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 4243 | TBUTTON_INFO *btnPtr;
|
|---|
| 4244 | POINT pt;
|
|---|
| 4245 | INT nHit;
|
|---|
| 4246 | NMTOOLBARA nmtb;
|
|---|
| 4247 |
|
|---|
| 4248 | if (infoPtr->hwndToolTip)
|
|---|
| 4249 | TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
|
|---|
| 4250 | WM_LBUTTONDOWN, wParam, lParam);
|
|---|
| 4251 |
|
|---|
| 4252 | pt.x = (INT)LOWORD(lParam);
|
|---|
| 4253 | pt.y = (INT)HIWORD(lParam);
|
|---|
| 4254 | nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
|
|---|
| 4255 |
|
|---|
| 4256 | if (nHit >= 0) {
|
|---|
| 4257 | RECT arrowRect;
|
|---|
| 4258 | btnPtr = &infoPtr->buttons[nHit];
|
|---|
| 4259 | if (!(btnPtr->fsState & TBSTATE_ENABLED))
|
|---|
| 4260 | return 0;
|
|---|
| 4261 |
|
|---|
| 4262 | infoPtr->nOldHit = nHit;
|
|---|
| 4263 |
|
|---|
| 4264 | CopyRect(&arrowRect, &btnPtr->rect);
|
|---|
| 4265 | arrowRect.left = max(btnPtr->rect.left, btnPtr->rect.right - DDARROW_WIDTH);
|
|---|
| 4266 |
|
|---|
| 4267 | /* for EX_DRAWDDARROWS style, click must be in the drop-down arrow rect */
|
|---|
| 4268 | if ((btnPtr->fsStyle & TBSTYLE_DROPDOWN) &&
|
|---|
| 4269 | ((TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle) && PtInRect(&arrowRect, pt)) ||
|
|---|
| 4270 | (!TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle))))
|
|---|
| 4271 | {
|
|---|
| 4272 | LRESULT res;
|
|---|
| 4273 | /*
|
|---|
| 4274 | * this time we must force a Redraw, so the btn is
|
|---|
| 4275 | * painted down before CaptureChanged repaints it up
|
|---|
| 4276 | */
|
|---|
| 4277 | RedrawWindow(hwnd,&btnPtr->rect,0,
|
|---|
| 4278 | RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW);
|
|---|
| 4279 |
|
|---|
| 4280 | nmtb.iItem = btnPtr->idCommand;
|
|---|
| 4281 | memset(&nmtb.tbButton, 0, sizeof(TBBUTTON));
|
|---|
| 4282 | nmtb.cchText = 0;
|
|---|
| 4283 | nmtb.pszText = 0;
|
|---|
| 4284 | memset(&nmtb.rcButton, 0, sizeof(RECT));
|
|---|
| 4285 | res = TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
|
|---|
| 4286 | TBN_DROPDOWN);
|
|---|
| 4287 | if (res != TBDDRET_TREATPRESSED)
|
|---|
| 4288 | /* ??? guess (GA) */
|
|---|
| 4289 | return 0;
|
|---|
| 4290 | /* otherwise drop through and process as pushed */
|
|---|
| 4291 | }
|
|---|
| 4292 | /* SetCapture (hwnd); */
|
|---|
| 4293 | infoPtr->bCaptured = TRUE;
|
|---|
| 4294 | infoPtr->nButtonDown = nHit;
|
|---|
| 4295 |
|
|---|
| 4296 | btnPtr->fsState |= TBSTATE_PRESSED;
|
|---|
| 4297 | btnPtr->bHot = FALSE;
|
|---|
| 4298 |
|
|---|
| 4299 | InvalidateRect(hwnd, &btnPtr->rect,
|
|---|
| 4300 | TOOLBAR_HasText(infoPtr, btnPtr));
|
|---|
| 4301 | UpdateWindow(hwnd);
|
|---|
| 4302 | SetCapture (hwnd);
|
|---|
| 4303 |
|
|---|
| 4304 | /* native issues the TBN_BEGINDRAG here */
|
|---|
| 4305 | nmtb.iItem = btnPtr->idCommand;
|
|---|
| 4306 | nmtb.tbButton.iBitmap = btnPtr->iBitmap;
|
|---|
| 4307 | nmtb.tbButton.idCommand = btnPtr->idCommand;
|
|---|
| 4308 | nmtb.tbButton.fsState = btnPtr->fsState;
|
|---|
| 4309 | nmtb.tbButton.fsStyle = btnPtr->fsStyle;
|
|---|
| 4310 | nmtb.tbButton.dwData = btnPtr->dwData;
|
|---|
| 4311 | nmtb.tbButton.iString = btnPtr->iString;
|
|---|
| 4312 | nmtb.cchText = 0; /* !!! not correct */
|
|---|
| 4313 | nmtb.pszText = 0; /* !!! not correct */
|
|---|
| 4314 | TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
|
|---|
| 4315 | TBN_BEGINDRAG);
|
|---|
| 4316 | }
|
|---|
| 4317 |
|
|---|
| 4318 | return 0;
|
|---|
| 4319 | }
|
|---|
| 4320 |
|
|---|
| 4321 | static LRESULT
|
|---|
| 4322 | TOOLBAR_LButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 4323 | {
|
|---|
| 4324 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 4325 | TBUTTON_INFO *btnPtr;
|
|---|
| 4326 | POINT pt;
|
|---|
| 4327 | INT nHit;
|
|---|
| 4328 | INT nOldIndex = -1;
|
|---|
| 4329 | BOOL bSendMessage = TRUE;
|
|---|
| 4330 | NMHDR hdr;
|
|---|
| 4331 | NMMOUSE nmmouse;
|
|---|
| 4332 | NMTOOLBARA nmtb;
|
|---|
| 4333 |
|
|---|
| 4334 | if (infoPtr->hwndToolTip)
|
|---|
| 4335 | TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
|
|---|
| 4336 | WM_LBUTTONUP, wParam, lParam);
|
|---|
| 4337 |
|
|---|
| 4338 | pt.x = (INT)LOWORD(lParam);
|
|---|
| 4339 | pt.y = (INT)HIWORD(lParam);
|
|---|
| 4340 | nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
|
|---|
| 4341 |
|
|---|
| 4342 | /* restore hot effect to hot button disabled by TOOLBAR_LButtonDown() */
|
|---|
| 4343 | /* if the cursor is still inside of the toolbar */
|
|---|
| 4344 | if((infoPtr->nHotItem >= 0) && (nHit != -1))
|
|---|
| 4345 | infoPtr->buttons[infoPtr->nHotItem].bHot = TRUE;
|
|---|
| 4346 |
|
|---|
| 4347 | if ((infoPtr->bCaptured) && (infoPtr->nButtonDown >= 0)) {
|
|---|
| 4348 | btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
|
|---|
| 4349 | btnPtr->fsState &= ~TBSTATE_PRESSED;
|
|---|
| 4350 |
|
|---|
| 4351 | if (nHit == infoPtr->nButtonDown) {
|
|---|
| 4352 | if (btnPtr->fsStyle & TBSTYLE_CHECK) {
|
|---|
| 4353 | if (btnPtr->fsStyle & TBSTYLE_GROUP) {
|
|---|
| 4354 | nOldIndex = TOOLBAR_GetCheckedGroupButtonIndex (infoPtr,
|
|---|
| 4355 | infoPtr->nButtonDown);
|
|---|
| 4356 | if (nOldIndex == infoPtr->nButtonDown)
|
|---|
| 4357 | bSendMessage = FALSE;
|
|---|
| 4358 | if ((nOldIndex != infoPtr->nButtonDown) &&
|
|---|
| 4359 | (nOldIndex != -1))
|
|---|
| 4360 | infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
|
|---|
| 4361 | btnPtr->fsState |= TBSTATE_CHECKED;
|
|---|
| 4362 | }
|
|---|
| 4363 | else {
|
|---|
| 4364 | if (btnPtr->fsState & TBSTATE_CHECKED)
|
|---|
| 4365 | btnPtr->fsState &= ~TBSTATE_CHECKED;
|
|---|
| 4366 | else
|
|---|
| 4367 | btnPtr->fsState |= TBSTATE_CHECKED;
|
|---|
| 4368 | }
|
|---|
| 4369 | }
|
|---|
| 4370 | }
|
|---|
| 4371 | else
|
|---|
| 4372 | bSendMessage = FALSE;
|
|---|
| 4373 |
|
|---|
| 4374 | if (nOldIndex != -1)
|
|---|
| 4375 | {
|
|---|
| 4376 | InvalidateRect(hwnd, &infoPtr->buttons[nOldIndex].rect,
|
|---|
| 4377 | TOOLBAR_HasText(infoPtr, &infoPtr->buttons[nOldIndex]));
|
|---|
| 4378 | }
|
|---|
| 4379 |
|
|---|
| 4380 | /*
|
|---|
| 4381 | * now we can ReleaseCapture, which triggers CAPTURECHANGED msg,
|
|---|
| 4382 | * that resets bCaptured and btn TBSTATE_PRESSED flags,
|
|---|
| 4383 | * and obliterates nButtonDown and nOldHit (see TOOLBAR_CaptureChanged)
|
|---|
| 4384 | */
|
|---|
| 4385 | ReleaseCapture ();
|
|---|
| 4386 |
|
|---|
| 4387 | /* Issue NM_RELEASEDCAPTURE to parent to let him know it is released */
|
|---|
| 4388 | TOOLBAR_SendNotify ((NMHDR *) &hdr, infoPtr,
|
|---|
| 4389 | NM_RELEASEDCAPTURE);
|
|---|
| 4390 |
|
|---|
| 4391 | /* native issues TBN_ENDDRAG here, if _LBUTTONDOWN issued the
|
|---|
| 4392 | * TBN_BEGINDRAG
|
|---|
| 4393 | */
|
|---|
| 4394 | nmtb.iItem = btnPtr->idCommand;
|
|---|
| 4395 | nmtb.tbButton.iBitmap = btnPtr->iBitmap;
|
|---|
| 4396 | nmtb.tbButton.idCommand = btnPtr->idCommand;
|
|---|
| 4397 | nmtb.tbButton.fsState = btnPtr->fsState;
|
|---|
| 4398 | nmtb.tbButton.fsStyle = btnPtr->fsStyle;
|
|---|
| 4399 | nmtb.tbButton.dwData = btnPtr->dwData;
|
|---|
| 4400 | nmtb.tbButton.iString = btnPtr->iString;
|
|---|
| 4401 | nmtb.cchText = 0; /* !!! not correct */
|
|---|
| 4402 | nmtb.pszText = 0; /* !!! not correct */
|
|---|
| 4403 | TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
|
|---|
| 4404 | TBN_ENDDRAG);
|
|---|
| 4405 |
|
|---|
| 4406 | if (bSendMessage)
|
|---|
| 4407 | SendMessageA (infoPtr->hwndNotify, WM_COMMAND,
|
|---|
| 4408 | MAKEWPARAM(btnPtr->idCommand, 0), (LPARAM)hwnd);
|
|---|
| 4409 |
|
|---|
| 4410 | /* !!! Undocumented - toolbar at 4.71 level and above sends
|
|---|
| 4411 | * either NMRCLICK or NM_CLICK with the NMMOUSE structure.
|
|---|
| 4412 | * Only NM_RCLICK is documented.
|
|---|
| 4413 | */
|
|---|
| 4414 | nmmouse.dwItemSpec = btnPtr->idCommand;
|
|---|
| 4415 | nmmouse.dwItemData = btnPtr->dwData;
|
|---|
| 4416 | TOOLBAR_SendNotify ((NMHDR *) &nmmouse, infoPtr,
|
|---|
| 4417 | NM_CLICK);
|
|---|
| 4418 | }
|
|---|
| 4419 |
|
|---|
| 4420 | return 0;
|
|---|
| 4421 | }
|
|---|
| 4422 |
|
|---|
| 4423 | static LRESULT
|
|---|
| 4424 | TOOLBAR_CaptureChanged(HWND hwnd)
|
|---|
| 4425 | {
|
|---|
| 4426 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 4427 | TBUTTON_INFO *btnPtr;
|
|---|
| 4428 |
|
|---|
| 4429 | infoPtr->bCaptured = FALSE;
|
|---|
| 4430 |
|
|---|
| 4431 | if (infoPtr->nButtonDown >= 0)
|
|---|
| 4432 | {
|
|---|
| 4433 | btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
|
|---|
| 4434 | btnPtr->fsState &= ~TBSTATE_PRESSED;
|
|---|
| 4435 |
|
|---|
| 4436 | infoPtr->nButtonDown = -1;
|
|---|
| 4437 | infoPtr->nOldHit = -1;
|
|---|
| 4438 |
|
|---|
| 4439 | InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr,
|
|---|
| 4440 | btnPtr));
|
|---|
| 4441 | }
|
|---|
| 4442 | return 0;
|
|---|
| 4443 | }
|
|---|
| 4444 |
|
|---|
| 4445 | static LRESULT
|
|---|
| 4446 | TOOLBAR_MouseLeave (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 4447 | {
|
|---|
| 4448 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 4449 | TBUTTON_INFO *hotBtnPtr, *btnPtr;
|
|---|
| 4450 | RECT rc1;
|
|---|
| 4451 |
|
|---|
| 4452 | if (infoPtr->nOldHit < 0)
|
|---|
| 4453 | return TRUE;
|
|---|
| 4454 |
|
|---|
| 4455 | hotBtnPtr = &infoPtr->buttons[infoPtr->nOldHit];
|
|---|
| 4456 |
|
|---|
| 4457 | /* Redraw the button if the last button we were over is the hot button and it
|
|---|
| 4458 | is enabled */
|
|---|
| 4459 | if((infoPtr->nOldHit == infoPtr->nHotItem) && (hotBtnPtr->fsState & TBSTATE_ENABLED))
|
|---|
| 4460 | {
|
|---|
| 4461 | hotBtnPtr->bHot = FALSE;
|
|---|
| 4462 | rc1 = hotBtnPtr->rect;
|
|---|
| 4463 | InflateRect (&rc1, 1, 1);
|
|---|
| 4464 | InvalidateRect (hwnd, &rc1, TOOLBAR_HasText(infoPtr,
|
|---|
| 4465 | hotBtnPtr));
|
|---|
| 4466 | }
|
|---|
| 4467 |
|
|---|
| 4468 | /* If the last button we were over is depressed then make it not */
|
|---|
| 4469 | /* depressed and redraw it */
|
|---|
| 4470 | if(infoPtr->nOldHit == infoPtr->nButtonDown)
|
|---|
| 4471 | {
|
|---|
| 4472 | btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
|
|---|
| 4473 |
|
|---|
| 4474 | btnPtr->fsState &= ~TBSTATE_PRESSED;
|
|---|
| 4475 |
|
|---|
| 4476 | rc1 = hotBtnPtr->rect;
|
|---|
| 4477 | InflateRect (&rc1, 1, 1);
|
|---|
| 4478 | InvalidateRect (hwnd, &rc1, TRUE);
|
|---|
| 4479 | }
|
|---|
| 4480 |
|
|---|
| 4481 | infoPtr->nOldHit = -1; /* reset the old hit index as we've left the toolbar */
|
|---|
| 4482 | infoPtr->nHotItem = -2; /* It has to be initially different from nOldHit */
|
|---|
| 4483 |
|
|---|
| 4484 | return TRUE;
|
|---|
| 4485 | }
|
|---|
| 4486 |
|
|---|
| 4487 | static LRESULT
|
|---|
| 4488 | TOOLBAR_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 4489 | {
|
|---|
| 4490 | TBUTTON_INFO *btnPtr, *oldBtnPtr;
|
|---|
| 4491 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 4492 | POINT pt;
|
|---|
| 4493 | INT nHit;
|
|---|
| 4494 | TRACKMOUSEEVENT trackinfo;
|
|---|
| 4495 |
|
|---|
| 4496 | /* fill in the TRACKMOUSEEVENT struct */
|
|---|
| 4497 | trackinfo.cbSize = sizeof(TRACKMOUSEEVENT);
|
|---|
| 4498 | trackinfo.dwFlags = TME_QUERY;
|
|---|
| 4499 | trackinfo.hwndTrack = hwnd;
|
|---|
| 4500 | trackinfo.dwHoverTime = HOVER_DEFAULT;
|
|---|
| 4501 |
|
|---|
| 4502 | /* call _TrackMouseEvent to see if we are currently tracking for this hwnd */
|
|---|
| 4503 | _TrackMouseEvent(&trackinfo);
|
|---|
| 4504 |
|
|---|
| 4505 | /* Make sure tracking is enabled so we receive a WM_MOUSELEAVE message */
|
|---|
| 4506 | if(!(trackinfo.dwFlags & TME_LEAVE)) {
|
|---|
| 4507 | trackinfo.dwFlags = TME_LEAVE; /* notify upon leaving */
|
|---|
| 4508 |
|
|---|
| 4509 | /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */
|
|---|
| 4510 | /* and can properly deactivate the hot toolbar button */
|
|---|
| 4511 | _TrackMouseEvent(&trackinfo);
|
|---|
| 4512 | }
|
|---|
| 4513 |
|
|---|
| 4514 | if (infoPtr->hwndToolTip)
|
|---|
| 4515 | TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
|
|---|
| 4516 | WM_MOUSEMOVE, wParam, lParam);
|
|---|
| 4517 |
|
|---|
| 4518 | pt.x = (INT)LOWORD(lParam);
|
|---|
| 4519 | pt.y = (INT)HIWORD(lParam);
|
|---|
| 4520 |
|
|---|
| 4521 | nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
|
|---|
| 4522 |
|
|---|
| 4523 | if (infoPtr->nOldHit != nHit)
|
|---|
| 4524 | {
|
|---|
| 4525 | /* Remove the effect of an old hot button if the button was enabled and was
|
|---|
| 4526 | drawn with the hot button effect */
|
|---|
| 4527 | if(infoPtr->nOldHit >= 0 && infoPtr->nOldHit == infoPtr->nHotItem &&
|
|---|
| 4528 | (infoPtr->buttons[infoPtr->nOldHit].fsState & TBSTATE_ENABLED))
|
|---|
| 4529 | {
|
|---|
| 4530 | oldBtnPtr = &infoPtr->buttons[infoPtr->nOldHit];
|
|---|
| 4531 | oldBtnPtr->bHot = FALSE;
|
|---|
| 4532 |
|
|---|
| 4533 | InvalidateRect (hwnd, &oldBtnPtr->rect,
|
|---|
| 4534 | TOOLBAR_HasText(infoPtr, oldBtnPtr));
|
|---|
| 4535 | }
|
|---|
| 4536 |
|
|---|
| 4537 | /* It's not a separator or in nowhere. It's a hot button. */
|
|---|
| 4538 | if (nHit >= 0)
|
|---|
| 4539 | {
|
|---|
| 4540 | btnPtr = &infoPtr->buttons[nHit];
|
|---|
| 4541 |
|
|---|
| 4542 | infoPtr->nHotItem = nHit;
|
|---|
| 4543 |
|
|---|
| 4544 | /* only enabled buttons show hot effect */
|
|---|
| 4545 | if(infoPtr->buttons[nHit].fsState & TBSTATE_ENABLED)
|
|---|
| 4546 | {
|
|---|
| 4547 | btnPtr->bHot = TRUE;
|
|---|
| 4548 | InvalidateRect(hwnd, &btnPtr->rect,
|
|---|
| 4549 | TOOLBAR_HasText(infoPtr, btnPtr));
|
|---|
| 4550 | }
|
|---|
| 4551 |
|
|---|
| 4552 | }
|
|---|
| 4553 |
|
|---|
| 4554 | if (infoPtr->bCaptured) {
|
|---|
| 4555 | btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
|
|---|
| 4556 | if (infoPtr->nOldHit == infoPtr->nButtonDown) {
|
|---|
| 4557 | btnPtr->fsState &= ~TBSTATE_PRESSED;
|
|---|
| 4558 | InvalidateRect(hwnd, &btnPtr->rect, TRUE);
|
|---|
| 4559 | }
|
|---|
| 4560 | else if (nHit == infoPtr->nButtonDown) {
|
|---|
| 4561 | btnPtr->fsState |= TBSTATE_PRESSED;
|
|---|
| 4562 | InvalidateRect(hwnd, &btnPtr->rect, TRUE);
|
|---|
| 4563 | }
|
|---|
| 4564 | }
|
|---|
| 4565 | infoPtr->nOldHit = nHit;
|
|---|
| 4566 | }
|
|---|
| 4567 | return 0;
|
|---|
| 4568 | }
|
|---|
| 4569 |
|
|---|
| 4570 |
|
|---|
| 4571 | inline static LRESULT
|
|---|
| 4572 | TOOLBAR_NCActivate (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 4573 | {
|
|---|
| 4574 | /* if (wndPtr->dwStyle & CCS_NODIVIDER) */
|
|---|
| 4575 | return DefWindowProcA (hwnd, WM_NCACTIVATE, wParam, lParam);
|
|---|
| 4576 | /* else */
|
|---|
| 4577 | /* return TOOLBAR_NCPaint (wndPtr, wParam, lParam); */
|
|---|
| 4578 | }
|
|---|
| 4579 |
|
|---|
| 4580 |
|
|---|
| 4581 | inline static LRESULT
|
|---|
| 4582 | TOOLBAR_NCCalcSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 4583 | {
|
|---|
| 4584 | if (!(GetWindowLongA (hwnd, GWL_STYLE) & CCS_NODIVIDER))
|
|---|
| 4585 | ((LPRECT)lParam)->top += GetSystemMetrics(SM_CYEDGE);
|
|---|
| 4586 |
|
|---|
| 4587 | return DefWindowProcA (hwnd, WM_NCCALCSIZE, wParam, lParam);
|
|---|
| 4588 | }
|
|---|
| 4589 |
|
|---|
| 4590 |
|
|---|
| 4591 | static LRESULT
|
|---|
| 4592 | TOOLBAR_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 4593 | {
|
|---|
| 4594 | TOOLBAR_INFO *infoPtr;
|
|---|
| 4595 | LPCREATESTRUCTA cs = (LPCREATESTRUCTA)lParam;
|
|---|
| 4596 | DWORD styleadd = 0;
|
|---|
| 4597 |
|
|---|
| 4598 | /* allocate memory for info structure */
|
|---|
| 4599 | infoPtr = (TOOLBAR_INFO *)COMCTL32_Alloc (sizeof(TOOLBAR_INFO));
|
|---|
| 4600 | SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
|
|---|
| 4601 |
|
|---|
| 4602 | /* paranoid!! */
|
|---|
| 4603 | infoPtr->dwStructSize = sizeof(TBBUTTON);
|
|---|
| 4604 |
|
|---|
| 4605 | /* fix instance handle, if the toolbar was created by CreateToolbarEx() */
|
|---|
| 4606 | if (!GetWindowLongA (hwnd, GWL_HINSTANCE)) {
|
|---|
| 4607 | HINSTANCE hInst = (HINSTANCE)GetWindowLongA (GetParent (hwnd), GWL_HINSTANCE);
|
|---|
| 4608 | SetWindowLongA (hwnd, GWL_HINSTANCE, (DWORD)hInst);
|
|---|
| 4609 | }
|
|---|
| 4610 |
|
|---|
| 4611 | /* native control does:
|
|---|
| 4612 | * Get a lot of colors and brushes
|
|---|
| 4613 | * WM_NOTIFYFORMAT
|
|---|
| 4614 | * SystemParametersInfoA(0x1f, 0x3c, adr1, 0)
|
|---|
| 4615 | * CreateFontIndirectA(adr1)
|
|---|
| 4616 | * CreateBitmap(0x27, 0x24, 1, 1, 0)
|
|---|
| 4617 | * hdc = GetDC(toolbar)
|
|---|
| 4618 | * GetSystemMetrics(0x48)
|
|---|
| 4619 | * fnt2=CreateFontA(0xe, 0, 0, 0, 0x190, 0, 0, 0, 0, 2,
|
|---|
| 4620 | * 0, 0, 0, 0, "MARLETT")
|
|---|
| 4621 | * oldfnt = SelectObject(hdc, fnt2)
|
|---|
| 4622 | * GetCharWidthA(hdc, 0x36, 0x36, adr2)
|
|---|
| 4623 | * GetTextMetricsA(hdc, adr3)
|
|---|
| 4624 | * SelectObject(hdc, oldfnt)
|
|---|
| 4625 | * DeleteObject(fnt2)
|
|---|
| 4626 | * ReleaseDC(hdc)
|
|---|
| 4627 | * InvalidateRect(toolbar, 0, 1)
|
|---|
| 4628 | * SetWindowLongA(toolbar, 0, addr)
|
|---|
| 4629 | * SetWindowLongA(toolbar, -16, xxx) **sometimes**
|
|---|
| 4630 | * WM_STYLECHANGING
|
|---|
| 4631 | * CallWinEx old new
|
|---|
| 4632 | * ie 1 0x56000a4c 0x46000a4c 0x56008a4d
|
|---|
| 4633 | * ie 2 0x4600094c 0x4600094c 0x4600894d
|
|---|
| 4634 | * ie 3 0x56000b4c 0x46000b4c 0x56008b4d
|
|---|
| 4635 | * rebar 0x50008844 0x40008844 0x50008845
|
|---|
| 4636 | * pager 0x50000844 0x40000844 0x50008845
|
|---|
| 4637 | * IC35mgr 0x5400084e **nochange**
|
|---|
| 4638 | * on entry to _NCCREATE 0x5400084e
|
|---|
| 4639 | * rowlist 0x5400004e **nochange**
|
|---|
| 4640 | * on entry to _NCCREATE 0x5400004e
|
|---|
| 4641 | *
|
|---|
| 4642 | */
|
|---|
| 4643 |
|
|---|
| 4644 | /* I think the code below is a bug, but it is the way that the native
|
|---|
| 4645 | * controls seem to work. The effect is that if the user of TBSTYLE_FLAT
|
|---|
| 4646 | * forgets to specify TBSTYLE_TRANSPARENT but does specify either
|
|---|
| 4647 | * CCS_TOP or CCS_BOTTOM (_NOMOVEY and _TOP), then the control
|
|---|
| 4648 | * does *not* set TBSTYLE_TRANSPARENT even though it should!!!!
|
|---|
| 4649 | * Some how, the only cases of this seem to be MFC programs.
|
|---|
| 4650 | *
|
|---|
| 4651 | * Note also that the addition of _TRANSPARENT occurs *only* here. It
|
|---|
| 4652 | * does not occur in the WM_STYLECHANGING routine.
|
|---|
| 4653 | * (Guy Albertelli 9/2001)
|
|---|
| 4654 | *
|
|---|
| 4655 | */
|
|---|
| 4656 | if ((cs->style & TBSTYLE_FLAT) && !(cs->style & TBSTYLE_TRANSPARENT))
|
|---|
| 4657 | styleadd |= TBSTYLE_TRANSPARENT;
|
|---|
| 4658 | if (!(cs->style & (CCS_TOP | CCS_NOMOVEY))) {
|
|---|
| 4659 | styleadd |= CCS_TOP; /* default to top */
|
|---|
| 4660 | SetWindowLongA (hwnd, GWL_STYLE, cs->style | styleadd);
|
|---|
| 4661 | }
|
|---|
| 4662 |
|
|---|
| 4663 | return DefWindowProcA (hwnd, WM_NCCREATE, wParam, lParam);
|
|---|
| 4664 | }
|
|---|
| 4665 |
|
|---|
| 4666 |
|
|---|
| 4667 | static LRESULT
|
|---|
| 4668 | TOOLBAR_NCPaint (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 4669 | {
|
|---|
| 4670 | DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
|
|---|
| 4671 | RECT rcWindow;
|
|---|
| 4672 | HDC hdc;
|
|---|
| 4673 |
|
|---|
| 4674 | if (dwStyle & WS_MINIMIZE)
|
|---|
| 4675 | return 0; /* Nothing to do */
|
|---|
| 4676 |
|
|---|
| 4677 | DefWindowProcA (hwnd, WM_NCPAINT, wParam, lParam);
|
|---|
| 4678 |
|
|---|
| 4679 | if (!(hdc = GetDCEx (hwnd, 0, DCX_USESTYLE | DCX_WINDOW)))
|
|---|
| 4680 | return 0;
|
|---|
| 4681 |
|
|---|
| 4682 | if (!(dwStyle & CCS_NODIVIDER))
|
|---|
| 4683 | {
|
|---|
| 4684 | GetWindowRect (hwnd, &rcWindow);
|
|---|
| 4685 | OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
|
|---|
| 4686 | if( dwStyle & WS_BORDER )
|
|---|
| 4687 | OffsetRect (&rcWindow, 1, 1);
|
|---|
| 4688 | DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_TOP);
|
|---|
| 4689 | }
|
|---|
| 4690 |
|
|---|
| 4691 | ReleaseDC( hwnd, hdc );
|
|---|
| 4692 |
|
|---|
| 4693 | return 0;
|
|---|
| 4694 | }
|
|---|
| 4695 |
|
|---|
| 4696 |
|
|---|
| 4697 | inline static LRESULT
|
|---|
| 4698 | TOOLBAR_Notify (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 4699 | {
|
|---|
| 4700 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 4701 | LPNMHDR lpnmh = (LPNMHDR)lParam;
|
|---|
| 4702 |
|
|---|
| 4703 | if (lpnmh->code == PGN_CALCSIZE) {
|
|---|
| 4704 | LPNMPGCALCSIZE lppgc = (LPNMPGCALCSIZE)lParam;
|
|---|
| 4705 |
|
|---|
| 4706 | if (lppgc->dwFlag == PGF_CALCWIDTH) {
|
|---|
| 4707 | lppgc->iWidth = infoPtr->nWidth;
|
|---|
| 4708 | TRACE("processed PGN_CALCSIZE, returning horz size = %d\n",
|
|---|
| 4709 | infoPtr->nWidth);
|
|---|
| 4710 | }
|
|---|
| 4711 | else {
|
|---|
| 4712 | lppgc->iHeight = infoPtr->nHeight;
|
|---|
| 4713 | TRACE("processed PGN_CALCSIZE, returning vert size = %d\n",
|
|---|
| 4714 | infoPtr->nHeight);
|
|---|
| 4715 | }
|
|---|
| 4716 | return 0;
|
|---|
| 4717 | }
|
|---|
| 4718 |
|
|---|
| 4719 |
|
|---|
| 4720 | TRACE("passing WM_NOTIFY!\n");
|
|---|
| 4721 |
|
|---|
| 4722 | if ((infoPtr->hwndToolTip) && (lpnmh->hwndFrom == infoPtr->hwndToolTip)) {
|
|---|
| 4723 | SendMessageA (infoPtr->hwndNotify, WM_NOTIFY, wParam, lParam);
|
|---|
| 4724 |
|
|---|
| 4725 | #if 0
|
|---|
| 4726 | if (lpnmh->code == TTN_GETDISPINFOA) {
|
|---|
| 4727 | LPNMTTDISPINFOA lpdi = (LPNMTTDISPINFOA)lParam;
|
|---|
| 4728 |
|
|---|
| 4729 | FIXME("retrieving ASCII string\n");
|
|---|
| 4730 |
|
|---|
| 4731 | }
|
|---|
| 4732 | else if (lpnmh->code == TTN_GETDISPINFOW) {
|
|---|
| 4733 | LPNMTTDISPINFOW lpdi = (LPNMTTDISPINFOW)lParam;
|
|---|
| 4734 |
|
|---|
| 4735 | FIXME("retrieving UNICODE string\n");
|
|---|
| 4736 |
|
|---|
| 4737 | }
|
|---|
| 4738 | #endif
|
|---|
| 4739 | }
|
|---|
| 4740 |
|
|---|
| 4741 | return 0;
|
|---|
| 4742 | }
|
|---|
| 4743 |
|
|---|
| 4744 |
|
|---|
| 4745 | static LRESULT
|
|---|
| 4746 | TOOLBAR_Paint (HWND hwnd, WPARAM wParam)
|
|---|
| 4747 | {
|
|---|
| 4748 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
|
|---|
| 4749 | HDC hdc;
|
|---|
| 4750 | PAINTSTRUCT ps;
|
|---|
| 4751 |
|
|---|
| 4752 | /* fill ps.rcPaint with a default rect */
|
|---|
| 4753 | memcpy(&(ps.rcPaint), &(infoPtr->rcBound), sizeof(infoPtr->rcBound));
|
|---|
| 4754 |
|
|---|
| 4755 | hdc = wParam==0 ? BeginPaint(hwnd, &ps) : (HDC)wParam;
|
|---|
| 4756 |
|
|---|
| 4757 | TRACE("psrect=(%d,%d)-(%d,%d)\n",
|
|---|
| 4758 | ps.rcPaint.left, ps.rcPaint.top,
|
|---|
| 4759 | ps.rcPaint.right, ps.rcPaint.bottom);
|
|---|
| 4760 |
|
|---|
| 4761 | TOOLBAR_Refresh (hwnd, hdc, &ps);
|
|---|
| 4762 | if (!wParam) EndPaint (hwnd, &ps);
|
|---|
| 4763 |
|
|---|
| 4764 | return 0;
|
|---|
| 4765 | }
|
|---|
| 4766 |
|
|---|
| 4767 |
|
|---|
| 4768 | static LRESULT
|
|---|
| 4769 | TOOLBAR_SetRedraw (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 4770 | /*****************************************************
|
|---|
| 4771 | *
|
|---|
| 4772 | * Function;
|
|---|
| 4773 | * Handles the WM_SETREDRAW message.
|
|---|
| 4774 | *
|
|---|
| 4775 | * Documentation:
|
|---|
| 4776 | * According to testing V4.71 of COMCTL32 returns the
|
|---|
| 4777 | * *previous* status of the redraw flag (either 0 or 1)
|
|---|
| 4778 | * instead of the MSDN documented value of 0 if handled.
|
|---|
| 4779 | * (For laughs see the "consistancy" with same function
|
|---|
| 4780 | * in rebar.)
|
|---|
| 4781 | *
|
|---|
| 4782 | *****************************************************/
|
|---|
| 4783 | {
|
|---|
| 4784 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 4785 | BOOL oldredraw = infoPtr->bDoRedraw;
|
|---|
| 4786 |
|
|---|
| 4787 | TRACE("set to %s\n",
|
|---|
| 4788 | (wParam) ? "TRUE" : "FALSE");
|
|---|
| 4789 | infoPtr->bDoRedraw = (BOOL) wParam;
|
|---|
| 4790 | if (wParam) {
|
|---|
| 4791 | InvalidateRect (infoPtr->hwndSelf, 0, TRUE);
|
|---|
| 4792 | }
|
|---|
| 4793 | return (oldredraw) ? 1 : 0;
|
|---|
| 4794 | }
|
|---|
| 4795 |
|
|---|
| 4796 |
|
|---|
| 4797 | static LRESULT
|
|---|
| 4798 | TOOLBAR_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 4799 | {
|
|---|
| 4800 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 4801 | DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
|
|---|
| 4802 | RECT parent_rect;
|
|---|
| 4803 | RECT window_rect;
|
|---|
| 4804 | HWND parent;
|
|---|
| 4805 | INT x, y;
|
|---|
| 4806 | INT cx, cy;
|
|---|
| 4807 | INT flags;
|
|---|
| 4808 | UINT uPosFlags = 0;
|
|---|
| 4809 |
|
|---|
| 4810 | /* Resize deadlock check */
|
|---|
| 4811 | if (infoPtr->bAutoSize) {
|
|---|
| 4812 | infoPtr->bAutoSize = FALSE;
|
|---|
| 4813 | return 0;
|
|---|
| 4814 | }
|
|---|
| 4815 |
|
|---|
| 4816 | /* FIXME: optimize to only update size if the new size doesn't */
|
|---|
| 4817 | /* match the current size */
|
|---|
| 4818 |
|
|---|
| 4819 | flags = (INT) wParam;
|
|---|
| 4820 |
|
|---|
| 4821 | /* FIXME for flags =
|
|---|
| 4822 | * SIZE_MAXIMIZED, SIZE_MAXSHOW, SIZE_MINIMIZED
|
|---|
| 4823 | */
|
|---|
| 4824 |
|
|---|
| 4825 | TRACE("sizing toolbar!\n");
|
|---|
| 4826 |
|
|---|
| 4827 | if (flags == SIZE_RESTORED) {
|
|---|
| 4828 | /* width and height don't apply */
|
|---|
| 4829 | parent = GetParent (hwnd);
|
|---|
| 4830 | GetClientRect(parent, &parent_rect);
|
|---|
| 4831 | x = parent_rect.left;
|
|---|
| 4832 | y = parent_rect.top;
|
|---|
| 4833 |
|
|---|
| 4834 | if (dwStyle & CCS_NORESIZE) {
|
|---|
| 4835 | uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
|
|---|
| 4836 |
|
|---|
| 4837 | /*
|
|---|
| 4838 | * this sets the working width of the toolbar, and
|
|---|
| 4839 | * Calc Toolbar will not adjust it, only the height
|
|---|
| 4840 | */
|
|---|
| 4841 | infoPtr->nWidth = parent_rect.right - parent_rect.left;
|
|---|
| 4842 | cy = infoPtr->nHeight;
|
|---|
| 4843 | cx = infoPtr->nWidth;
|
|---|
| 4844 | TOOLBAR_CalcToolbar (hwnd);
|
|---|
| 4845 | infoPtr->nWidth = cx;
|
|---|
| 4846 | infoPtr->nHeight = cy;
|
|---|
| 4847 | }
|
|---|
| 4848 | else {
|
|---|
| 4849 | infoPtr->nWidth = parent_rect.right - parent_rect.left;
|
|---|
| 4850 | TOOLBAR_CalcToolbar (hwnd);
|
|---|
| 4851 | cy = infoPtr->nHeight;
|
|---|
| 4852 | cx = infoPtr->nWidth;
|
|---|
| 4853 |
|
|---|
| 4854 | if (dwStyle & CCS_NOMOVEY) {
|
|---|
| 4855 | GetWindowRect(hwnd, &window_rect);
|
|---|
| 4856 | ScreenToClient(parent, (LPPOINT)&window_rect.left);
|
|---|
| 4857 | y = window_rect.top;
|
|---|
| 4858 | }
|
|---|
| 4859 | }
|
|---|
| 4860 |
|
|---|
| 4861 | if (dwStyle & CCS_NOPARENTALIGN) {
|
|---|
| 4862 | uPosFlags |= SWP_NOMOVE;
|
|---|
| 4863 | cy = infoPtr->nHeight;
|
|---|
| 4864 | cx = infoPtr->nWidth;
|
|---|
| 4865 | }
|
|---|
| 4866 |
|
|---|
| 4867 | if (!(dwStyle & CCS_NODIVIDER))
|
|---|
| 4868 | cy += GetSystemMetrics(SM_CYEDGE);
|
|---|
| 4869 |
|
|---|
| 4870 | if (dwStyle & WS_BORDER)
|
|---|
| 4871 | {
|
|---|
| 4872 | x = y = 1;
|
|---|
| 4873 | cy += GetSystemMetrics(SM_CYEDGE);
|
|---|
| 4874 | cx += GetSystemMetrics(SM_CYEDGE);
|
|---|
| 4875 | }
|
|---|
| 4876 |
|
|---|
| 4877 | SetWindowPos (hwnd, 0, parent_rect.left - x, parent_rect.top - y,
|
|---|
| 4878 | cx, cy, uPosFlags | SWP_NOZORDER);
|
|---|
| 4879 | }
|
|---|
| 4880 | return 0;
|
|---|
| 4881 | }
|
|---|
| 4882 |
|
|---|
| 4883 |
|
|---|
| 4884 | static LRESULT
|
|---|
| 4885 | TOOLBAR_StyleChanged (HWND hwnd, INT nType, LPSTYLESTRUCT lpStyle)
|
|---|
| 4886 | {
|
|---|
| 4887 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 4888 |
|
|---|
| 4889 | if (nType == GWL_STYLE) {
|
|---|
| 4890 | if (lpStyle->styleNew & TBSTYLE_LIST) {
|
|---|
| 4891 | infoPtr->dwDTFlags = DT_LEFT | DT_VCENTER | DT_SINGLELINE;
|
|---|
| 4892 | }
|
|---|
| 4893 | else {
|
|---|
| 4894 | infoPtr->dwDTFlags = DT_CENTER;
|
|---|
| 4895 | }
|
|---|
| 4896 | infoPtr->bTransparent = (lpStyle->styleNew & TBSTYLE_TRANSPARENT);
|
|---|
| 4897 | infoPtr->bBtnTranspnt = (lpStyle->styleNew &
|
|---|
| 4898 | (TBSTYLE_FLAT | TBSTYLE_LIST));
|
|---|
| 4899 | TOOLBAR_CheckStyle (hwnd, lpStyle->styleNew);
|
|---|
| 4900 | }
|
|---|
| 4901 |
|
|---|
| 4902 | TOOLBAR_AutoSize (hwnd);
|
|---|
| 4903 |
|
|---|
| 4904 | InvalidateRect(hwnd, NULL, FALSE);
|
|---|
| 4905 |
|
|---|
| 4906 | return 0;
|
|---|
| 4907 | }
|
|---|
| 4908 |
|
|---|
| 4909 |
|
|---|
| 4910 |
|
|---|
| 4911 | static LRESULT WINAPI
|
|---|
| 4912 | ToolbarWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|---|
| 4913 | {
|
|---|
| 4914 | TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n",
|
|---|
| 4915 | hwnd, uMsg, /* SPY_GetMsgName(uMsg), */ wParam, lParam);
|
|---|
| 4916 |
|
|---|
| 4917 | if (!TOOLBAR_GetInfoPtr(hwnd) && (uMsg != WM_NCCREATE))
|
|---|
| 4918 | return DefWindowProcA( hwnd, uMsg, wParam, lParam );
|
|---|
| 4919 |
|
|---|
| 4920 | switch (uMsg)
|
|---|
| 4921 | {
|
|---|
| 4922 | case TB_ADDBITMAP:
|
|---|
| 4923 | return TOOLBAR_AddBitmap (hwnd, wParam, lParam);
|
|---|
| 4924 |
|
|---|
| 4925 | case TB_ADDBUTTONSA:
|
|---|
| 4926 | return TOOLBAR_AddButtonsA (hwnd, wParam, lParam);
|
|---|
| 4927 |
|
|---|
| 4928 | case TB_ADDBUTTONSW:
|
|---|
| 4929 | return TOOLBAR_AddButtonsW (hwnd, wParam, lParam);
|
|---|
| 4930 |
|
|---|
| 4931 | case TB_ADDSTRINGA:
|
|---|
| 4932 | return TOOLBAR_AddStringA (hwnd, wParam, lParam);
|
|---|
| 4933 |
|
|---|
| 4934 | case TB_ADDSTRINGW:
|
|---|
| 4935 | return TOOLBAR_AddStringW (hwnd, wParam, lParam);
|
|---|
| 4936 |
|
|---|
| 4937 | case TB_AUTOSIZE:
|
|---|
| 4938 | return TOOLBAR_AutoSize (hwnd);
|
|---|
| 4939 |
|
|---|
| 4940 | case TB_BUTTONCOUNT:
|
|---|
| 4941 | return TOOLBAR_ButtonCount (hwnd, wParam, lParam);
|
|---|
| 4942 |
|
|---|
| 4943 | case TB_BUTTONSTRUCTSIZE:
|
|---|
| 4944 | return TOOLBAR_ButtonStructSize (hwnd, wParam, lParam);
|
|---|
| 4945 |
|
|---|
| 4946 | case TB_CHANGEBITMAP:
|
|---|
| 4947 | return TOOLBAR_ChangeBitmap (hwnd, wParam, lParam);
|
|---|
| 4948 |
|
|---|
| 4949 | case TB_CHECKBUTTON:
|
|---|
| 4950 | return TOOLBAR_CheckButton (hwnd, wParam, lParam);
|
|---|
| 4951 |
|
|---|
| 4952 | case TB_COMMANDTOINDEX:
|
|---|
| 4953 | return TOOLBAR_CommandToIndex (hwnd, wParam, lParam);
|
|---|
| 4954 |
|
|---|
| 4955 | case TB_CUSTOMIZE:
|
|---|
| 4956 | return TOOLBAR_Customize (hwnd);
|
|---|
| 4957 |
|
|---|
| 4958 | case TB_DELETEBUTTON:
|
|---|
| 4959 | return TOOLBAR_DeleteButton (hwnd, wParam, lParam);
|
|---|
| 4960 |
|
|---|
| 4961 | case TB_ENABLEBUTTON:
|
|---|
| 4962 | return TOOLBAR_EnableButton (hwnd, wParam, lParam);
|
|---|
| 4963 |
|
|---|
| 4964 | case TB_GETANCHORHIGHLIGHT:
|
|---|
| 4965 | return TOOLBAR_GetAnchorHighlight (hwnd);
|
|---|
| 4966 |
|
|---|
| 4967 | case TB_GETBITMAP:
|
|---|
| 4968 | return TOOLBAR_GetBitmap (hwnd, wParam, lParam);
|
|---|
| 4969 |
|
|---|
| 4970 | case TB_GETBITMAPFLAGS:
|
|---|
| 4971 | return TOOLBAR_GetBitmapFlags (hwnd, wParam, lParam);
|
|---|
| 4972 |
|
|---|
| 4973 | case TB_GETBUTTON:
|
|---|
| 4974 | return TOOLBAR_GetButton (hwnd, wParam, lParam);
|
|---|
| 4975 |
|
|---|
| 4976 | case TB_GETBUTTONINFOA:
|
|---|
| 4977 | return TOOLBAR_GetButtonInfoA (hwnd, wParam, lParam);
|
|---|
| 4978 |
|
|---|
| 4979 | case TB_GETBUTTONINFOW:
|
|---|
| 4980 | return TOOLBAR_GetButtonInfoW (hwnd, wParam, lParam);
|
|---|
| 4981 |
|
|---|
| 4982 | case TB_GETBUTTONSIZE:
|
|---|
| 4983 | return TOOLBAR_GetButtonSize (hwnd);
|
|---|
| 4984 |
|
|---|
| 4985 | case TB_GETBUTTONTEXTA:
|
|---|
| 4986 | return TOOLBAR_GetButtonTextA (hwnd, wParam, lParam);
|
|---|
| 4987 |
|
|---|
| 4988 | case TB_GETBUTTONTEXTW:
|
|---|
| 4989 | return TOOLBAR_GetButtonTextW (hwnd, wParam, lParam);
|
|---|
| 4990 |
|
|---|
| 4991 | /* case TB_GETCOLORSCHEME: */ /* 4.71 */
|
|---|
| 4992 |
|
|---|
| 4993 | case TB_GETDISABLEDIMAGELIST:
|
|---|
| 4994 | return TOOLBAR_GetDisabledImageList (hwnd, wParam, lParam);
|
|---|
| 4995 |
|
|---|
| 4996 | case TB_GETEXTENDEDSTYLE:
|
|---|
| 4997 | return TOOLBAR_GetExtendedStyle (hwnd);
|
|---|
| 4998 |
|
|---|
| 4999 | case TB_GETHOTIMAGELIST:
|
|---|
| 5000 | return TOOLBAR_GetHotImageList (hwnd, wParam, lParam);
|
|---|
| 5001 |
|
|---|
| 5002 | case TB_GETHOTITEM:
|
|---|
| 5003 | return TOOLBAR_GetHotItem (hwnd);
|
|---|
| 5004 |
|
|---|
| 5005 | case TB_GETIMAGELIST:
|
|---|
| 5006 | return TOOLBAR_GetImageList (hwnd, wParam, lParam);
|
|---|
| 5007 |
|
|---|
| 5008 | /* case TB_GETINSERTMARK: */ /* 4.71 */
|
|---|
| 5009 | /* case TB_GETINSERTMARKCOLOR: */ /* 4.71 */
|
|---|
| 5010 |
|
|---|
| 5011 | case TB_GETITEMRECT:
|
|---|
| 5012 | return TOOLBAR_GetItemRect (hwnd, wParam, lParam);
|
|---|
| 5013 |
|
|---|
| 5014 | case TB_GETMAXSIZE:
|
|---|
| 5015 | return TOOLBAR_GetMaxSize (hwnd, wParam, lParam);
|
|---|
| 5016 |
|
|---|
| 5017 | /* case TB_GETOBJECT: */ /* 4.71 */
|
|---|
| 5018 | /* case TB_GETPADDING: */ /* 4.71 */
|
|---|
| 5019 |
|
|---|
| 5020 | case TB_GETRECT:
|
|---|
| 5021 | return TOOLBAR_GetRect (hwnd, wParam, lParam);
|
|---|
| 5022 |
|
|---|
| 5023 | case TB_GETROWS:
|
|---|
| 5024 | return TOOLBAR_GetRows (hwnd, wParam, lParam);
|
|---|
| 5025 |
|
|---|
| 5026 | case TB_GETSTATE:
|
|---|
| 5027 | return TOOLBAR_GetState (hwnd, wParam, lParam);
|
|---|
| 5028 |
|
|---|
| 5029 | case TB_GETSTYLE:
|
|---|
| 5030 | return TOOLBAR_GetStyle (hwnd, wParam, lParam);
|
|---|
| 5031 |
|
|---|
| 5032 | case TB_GETTEXTROWS:
|
|---|
| 5033 | return TOOLBAR_GetTextRows (hwnd, wParam, lParam);
|
|---|
| 5034 |
|
|---|
| 5035 | case TB_GETTOOLTIPS:
|
|---|
| 5036 | return TOOLBAR_GetToolTips (hwnd, wParam, lParam);
|
|---|
| 5037 |
|
|---|
| 5038 | case TB_GETUNICODEFORMAT:
|
|---|
| 5039 | return TOOLBAR_GetUnicodeFormat (hwnd, wParam, lParam);
|
|---|
| 5040 |
|
|---|
| 5041 | case CCM_GETVERSION:
|
|---|
| 5042 | return TOOLBAR_GetVersion (hwnd);
|
|---|
| 5043 |
|
|---|
| 5044 | case TB_HIDEBUTTON:
|
|---|
| 5045 | return TOOLBAR_HideButton (hwnd, wParam, lParam);
|
|---|
| 5046 |
|
|---|
| 5047 | case TB_HITTEST:
|
|---|
| 5048 | return TOOLBAR_HitTest (hwnd, wParam, lParam);
|
|---|
| 5049 |
|
|---|
| 5050 | case TB_INDETERMINATE:
|
|---|
| 5051 | return TOOLBAR_Indeterminate (hwnd, wParam, lParam);
|
|---|
| 5052 |
|
|---|
| 5053 | case TB_INSERTBUTTONA:
|
|---|
| 5054 | return TOOLBAR_InsertButtonA (hwnd, wParam, lParam);
|
|---|
| 5055 |
|
|---|
| 5056 | case TB_INSERTBUTTONW:
|
|---|
| 5057 | return TOOLBAR_InsertButtonW (hwnd, wParam, lParam);
|
|---|
| 5058 |
|
|---|
| 5059 | /* case TB_INSERTMARKHITTEST: */ /* 4.71 */
|
|---|
| 5060 |
|
|---|
| 5061 | case TB_ISBUTTONCHECKED:
|
|---|
| 5062 | return TOOLBAR_IsButtonChecked (hwnd, wParam, lParam);
|
|---|
| 5063 |
|
|---|
| 5064 | case TB_ISBUTTONENABLED:
|
|---|
| 5065 | return TOOLBAR_IsButtonEnabled (hwnd, wParam, lParam);
|
|---|
| 5066 |
|
|---|
| 5067 | case TB_ISBUTTONHIDDEN:
|
|---|
| 5068 | return TOOLBAR_IsButtonHidden (hwnd, wParam, lParam);
|
|---|
| 5069 |
|
|---|
| 5070 | case TB_ISBUTTONHIGHLIGHTED:
|
|---|
| 5071 | return TOOLBAR_IsButtonHighlighted (hwnd, wParam, lParam);
|
|---|
| 5072 |
|
|---|
| 5073 | case TB_ISBUTTONINDETERMINATE:
|
|---|
| 5074 | return TOOLBAR_IsButtonIndeterminate (hwnd, wParam, lParam);
|
|---|
| 5075 |
|
|---|
| 5076 | case TB_ISBUTTONPRESSED:
|
|---|
| 5077 | return TOOLBAR_IsButtonPressed (hwnd, wParam, lParam);
|
|---|
| 5078 |
|
|---|
| 5079 | case TB_LOADIMAGES: /* 4.70 */
|
|---|
| 5080 | FIXME("missing standard imagelists\n");
|
|---|
| 5081 | return 0;
|
|---|
| 5082 |
|
|---|
| 5083 | /* case TB_MAPACCELERATORA: */ /* 4.71 */
|
|---|
| 5084 | /* case TB_MAPACCELERATORW: */ /* 4.71 */
|
|---|
| 5085 | /* case TB_MARKBUTTON: */ /* 4.71 */
|
|---|
| 5086 | /* case TB_MOVEBUTTON: */ /* 4.71 */
|
|---|
| 5087 |
|
|---|
| 5088 | case TB_PRESSBUTTON:
|
|---|
| 5089 | return TOOLBAR_PressButton (hwnd, wParam, lParam);
|
|---|
| 5090 |
|
|---|
| 5091 | /* case TB_REPLACEBITMAP: */
|
|---|
| 5092 |
|
|---|
| 5093 | case TB_SAVERESTOREA:
|
|---|
| 5094 | return TOOLBAR_SaveRestoreA (hwnd, wParam, lParam);
|
|---|
| 5095 |
|
|---|
| 5096 | case TB_SAVERESTOREW:
|
|---|
| 5097 | return TOOLBAR_SaveRestoreW (hwnd, wParam, lParam);
|
|---|
| 5098 |
|
|---|
| 5099 | case TB_SETANCHORHIGHLIGHT:
|
|---|
| 5100 | return TOOLBAR_SetAnchorHighlight (hwnd, wParam);
|
|---|
| 5101 |
|
|---|
| 5102 | case TB_SETBITMAPSIZE:
|
|---|
| 5103 | return TOOLBAR_SetBitmapSize (hwnd, wParam, lParam);
|
|---|
| 5104 |
|
|---|
| 5105 | case TB_SETBUTTONINFOA:
|
|---|
| 5106 | return TOOLBAR_SetButtonInfoA (hwnd, wParam, lParam);
|
|---|
| 5107 |
|
|---|
| 5108 | case TB_SETBUTTONINFOW:
|
|---|
| 5109 | return TOOLBAR_SetButtonInfoW (hwnd, wParam, lParam);
|
|---|
| 5110 |
|
|---|
| 5111 | case TB_SETBUTTONSIZE:
|
|---|
| 5112 | return TOOLBAR_SetButtonSize (hwnd, wParam, lParam);
|
|---|
| 5113 |
|
|---|
| 5114 | case TB_SETBUTTONWIDTH:
|
|---|
| 5115 | return TOOLBAR_SetButtonWidth (hwnd, wParam, lParam);
|
|---|
| 5116 |
|
|---|
| 5117 | case TB_SETCMDID:
|
|---|
| 5118 | return TOOLBAR_SetCmdId (hwnd, wParam, lParam);
|
|---|
| 5119 |
|
|---|
| 5120 | /* case TB_SETCOLORSCHEME: */ /* 4.71 */
|
|---|
| 5121 |
|
|---|
| 5122 | case TB_SETDISABLEDIMAGELIST:
|
|---|
| 5123 | return TOOLBAR_SetDisabledImageList (hwnd, wParam, lParam);
|
|---|
| 5124 |
|
|---|
| 5125 | case TB_SETDRAWTEXTFLAGS:
|
|---|
| 5126 | return TOOLBAR_SetDrawTextFlags (hwnd, wParam, lParam);
|
|---|
| 5127 |
|
|---|
| 5128 | case TB_SETEXTENDEDSTYLE:
|
|---|
| 5129 | return TOOLBAR_SetExtendedStyle (hwnd, wParam, lParam);
|
|---|
| 5130 |
|
|---|
| 5131 | case TB_SETHOTIMAGELIST:
|
|---|
| 5132 | return TOOLBAR_SetHotImageList (hwnd, wParam, lParam);
|
|---|
| 5133 |
|
|---|
| 5134 | case TB_SETHOTITEM:
|
|---|
| 5135 | return TOOLBAR_SetHotItem (hwnd, wParam);
|
|---|
| 5136 |
|
|---|
| 5137 | case TB_SETIMAGELIST:
|
|---|
| 5138 | return TOOLBAR_SetImageList (hwnd, wParam, lParam);
|
|---|
| 5139 |
|
|---|
| 5140 | case TB_SETINDENT:
|
|---|
| 5141 | return TOOLBAR_SetIndent (hwnd, wParam, lParam);
|
|---|
| 5142 |
|
|---|
| 5143 | /* case TB_SETINSERTMARK: */ /* 4.71 */
|
|---|
| 5144 |
|
|---|
| 5145 | case TB_SETINSERTMARKCOLOR:
|
|---|
| 5146 | return TOOLBAR_SetInsertMarkColor (hwnd, wParam, lParam);
|
|---|
| 5147 |
|
|---|
| 5148 | case TB_SETMAXTEXTROWS:
|
|---|
| 5149 | return TOOLBAR_SetMaxTextRows (hwnd, wParam, lParam);
|
|---|
| 5150 |
|
|---|
| 5151 | /* case TB_SETPADDING: */ /* 4.71 */
|
|---|
| 5152 |
|
|---|
| 5153 | case TB_SETPARENT:
|
|---|
| 5154 | return TOOLBAR_SetParent (hwnd, wParam, lParam);
|
|---|
| 5155 |
|
|---|
| 5156 | case TB_SETROWS:
|
|---|
| 5157 | return TOOLBAR_SetRows (hwnd, wParam, lParam);
|
|---|
| 5158 |
|
|---|
| 5159 | case TB_SETSTATE:
|
|---|
| 5160 | return TOOLBAR_SetState (hwnd, wParam, lParam);
|
|---|
| 5161 |
|
|---|
| 5162 | case TB_SETSTYLE:
|
|---|
| 5163 | return TOOLBAR_SetStyle (hwnd, wParam, lParam);
|
|---|
| 5164 |
|
|---|
| 5165 | case TB_SETTOOLTIPS:
|
|---|
| 5166 | return TOOLBAR_SetToolTips (hwnd, wParam, lParam);
|
|---|
| 5167 |
|
|---|
| 5168 | case TB_SETUNICODEFORMAT:
|
|---|
| 5169 | return TOOLBAR_SetUnicodeFormat (hwnd, wParam, lParam);
|
|---|
| 5170 |
|
|---|
| 5171 | case CCM_SETVERSION:
|
|---|
| 5172 | return TOOLBAR_SetVersion (hwnd, (INT)wParam);
|
|---|
| 5173 |
|
|---|
| 5174 |
|
|---|
| 5175 | /* case WM_CHAR: */
|
|---|
| 5176 |
|
|---|
| 5177 | case WM_CREATE:
|
|---|
| 5178 | return TOOLBAR_Create (hwnd, wParam, lParam);
|
|---|
| 5179 |
|
|---|
| 5180 | case WM_DESTROY:
|
|---|
| 5181 | return TOOLBAR_Destroy (hwnd, wParam, lParam);
|
|---|
| 5182 |
|
|---|
| 5183 | case WM_ERASEBKGND:
|
|---|
| 5184 | return TOOLBAR_EraseBackground (hwnd, wParam, lParam);
|
|---|
| 5185 |
|
|---|
| 5186 | case WM_GETFONT:
|
|---|
| 5187 | return TOOLBAR_GetFont (hwnd, wParam, lParam);
|
|---|
| 5188 |
|
|---|
| 5189 | /* case WM_KEYDOWN: */
|
|---|
| 5190 | /* case WM_KILLFOCUS: */
|
|---|
| 5191 |
|
|---|
| 5192 | case WM_LBUTTONDBLCLK:
|
|---|
| 5193 | return TOOLBAR_LButtonDblClk (hwnd, wParam, lParam);
|
|---|
| 5194 |
|
|---|
| 5195 | case WM_LBUTTONDOWN:
|
|---|
| 5196 | return TOOLBAR_LButtonDown (hwnd, wParam, lParam);
|
|---|
| 5197 |
|
|---|
| 5198 | case WM_LBUTTONUP:
|
|---|
| 5199 | return TOOLBAR_LButtonUp (hwnd, wParam, lParam);
|
|---|
| 5200 |
|
|---|
| 5201 | case WM_MOUSEMOVE:
|
|---|
| 5202 | return TOOLBAR_MouseMove (hwnd, wParam, lParam);
|
|---|
| 5203 |
|
|---|
| 5204 | case WM_MOUSELEAVE:
|
|---|
| 5205 | return TOOLBAR_MouseLeave (hwnd, wParam, lParam);
|
|---|
| 5206 |
|
|---|
| 5207 | case WM_CAPTURECHANGED:
|
|---|
| 5208 | return TOOLBAR_CaptureChanged(hwnd);
|
|---|
| 5209 |
|
|---|
| 5210 | case WM_NCACTIVATE:
|
|---|
| 5211 | return TOOLBAR_NCActivate (hwnd, wParam, lParam);
|
|---|
| 5212 |
|
|---|
| 5213 | case WM_NCCALCSIZE:
|
|---|
| 5214 | return TOOLBAR_NCCalcSize (hwnd, wParam, lParam);
|
|---|
| 5215 |
|
|---|
| 5216 | case WM_NCCREATE:
|
|---|
| 5217 | return TOOLBAR_NCCreate (hwnd, wParam, lParam);
|
|---|
| 5218 |
|
|---|
| 5219 | case WM_NCPAINT:
|
|---|
| 5220 | return TOOLBAR_NCPaint (hwnd, wParam, lParam);
|
|---|
| 5221 |
|
|---|
| 5222 | case WM_NOTIFY:
|
|---|
| 5223 | return TOOLBAR_Notify (hwnd, wParam, lParam);
|
|---|
| 5224 |
|
|---|
| 5225 | /* case WM_NOTIFYFORMAT: */
|
|---|
| 5226 |
|
|---|
| 5227 | case WM_PAINT:
|
|---|
| 5228 | return TOOLBAR_Paint (hwnd, wParam);
|
|---|
| 5229 |
|
|---|
| 5230 | case WM_SETREDRAW:
|
|---|
| 5231 | return TOOLBAR_SetRedraw (hwnd, wParam, lParam);
|
|---|
| 5232 |
|
|---|
| 5233 | case WM_SIZE:
|
|---|
| 5234 | return TOOLBAR_Size (hwnd, wParam, lParam);
|
|---|
| 5235 |
|
|---|
| 5236 | case WM_STYLECHANGED:
|
|---|
| 5237 | return TOOLBAR_StyleChanged (hwnd, (INT)wParam, (LPSTYLESTRUCT)lParam);
|
|---|
| 5238 |
|
|---|
| 5239 | /* case WM_SYSCOLORCHANGE: */
|
|---|
| 5240 |
|
|---|
| 5241 | /* case WM_WININICHANGE: */
|
|---|
| 5242 |
|
|---|
| 5243 | case WM_CHARTOITEM:
|
|---|
| 5244 | case WM_COMMAND:
|
|---|
| 5245 | case WM_DRAWITEM:
|
|---|
| 5246 | case WM_MEASUREITEM:
|
|---|
| 5247 | case WM_VKEYTOITEM:
|
|---|
| 5248 | {
|
|---|
| 5249 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
|---|
| 5250 | if(infoPtr != NULL)
|
|---|
| 5251 | return SendMessageA (infoPtr->hwndNotify, uMsg, wParam, lParam);
|
|---|
| 5252 | else
|
|---|
| 5253 | return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
|
|---|
| 5254 | }
|
|---|
| 5255 |
|
|---|
| 5256 | default:
|
|---|
| 5257 | if (uMsg >= WM_USER)
|
|---|
| 5258 | ERR("unknown msg %04x wp=%08x lp=%08lx\n",
|
|---|
| 5259 | uMsg, wParam, lParam);
|
|---|
| 5260 | return DefWindowProcA (hwnd, uMsg, wParam, lParam);
|
|---|
| 5261 | }
|
|---|
| 5262 | return 0;
|
|---|
| 5263 | }
|
|---|
| 5264 |
|
|---|
| 5265 |
|
|---|
| 5266 | VOID
|
|---|
| 5267 | TOOLBAR_Register (void)
|
|---|
| 5268 | {
|
|---|
| 5269 | WNDCLASSA wndClass;
|
|---|
| 5270 |
|
|---|
| 5271 | ZeroMemory (&wndClass, sizeof(WNDCLASSA));
|
|---|
| 5272 | wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
|
|---|
| 5273 | wndClass.lpfnWndProc = (WNDPROC)ToolbarWindowProc;
|
|---|
| 5274 | wndClass.cbClsExtra = 0;
|
|---|
| 5275 | wndClass.cbWndExtra = sizeof(TOOLBAR_INFO *);
|
|---|
| 5276 | wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
|
|---|
| 5277 | wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
|
|---|
| 5278 | wndClass.lpszClassName = TOOLBARCLASSNAMEA;
|
|---|
| 5279 |
|
|---|
| 5280 | RegisterClassA (&wndClass);
|
|---|
| 5281 | }
|
|---|
| 5282 |
|
|---|
| 5283 |
|
|---|
| 5284 | VOID
|
|---|
| 5285 | TOOLBAR_Unregister (void)
|
|---|
| 5286 | {
|
|---|
| 5287 | UnregisterClassA (TOOLBARCLASSNAMEA, (HINSTANCE)NULL);
|
|---|
| 5288 | }
|
|---|