| 1 | /*
|
|---|
| 2 | * Interface code to StatusWindow widget/control
|
|---|
| 3 | *
|
|---|
| 4 | * Copyright 1996 Bruce Milner
|
|---|
| 5 | * Copyright 1998, 1999 Eric Kohl
|
|---|
| 6 | */
|
|---|
| 7 | /*
|
|---|
| 8 | * FIXME/TODO
|
|---|
| 9 | * 1) Don't hard code bar to bottom of window, allow CCS_TOP also.
|
|---|
| 10 | * 2) Tooltip support (almost done).
|
|---|
| 11 | * 3) where else should we use infoPtr->hwndParent instead of GetParent() ?
|
|---|
| 12 | * 4) send WM_QUERYFORMAT
|
|---|
| 13 | */
|
|---|
| 14 |
|
|---|
| 15 | #include <string.h>
|
|---|
| 16 | #include "winbase.h"
|
|---|
| 17 | #include "wine/unicode.h"
|
|---|
| 18 | #include "commctrl.h"
|
|---|
| 19 | #include "debugtools.h"
|
|---|
| 20 | #ifdef __WIN32OS2__
|
|---|
| 21 | #include "ccbase.h"
|
|---|
| 22 | #endif
|
|---|
| 23 |
|
|---|
| 24 | DEFAULT_DEBUG_CHANNEL(statusbar);
|
|---|
| 25 |
|
|---|
| 26 | typedef struct
|
|---|
| 27 | {
|
|---|
| 28 | INT x;
|
|---|
| 29 | INT style;
|
|---|
| 30 | RECT bound;
|
|---|
| 31 | LPWSTR text;
|
|---|
| 32 | HICON hIcon;
|
|---|
| 33 | } STATUSWINDOWPART;
|
|---|
| 34 |
|
|---|
| 35 | typedef struct
|
|---|
| 36 | {
|
|---|
| 37 | #ifdef __WIN32OS2__
|
|---|
| 38 | COMCTL32_HEADER header;
|
|---|
| 39 | #endif
|
|---|
| 40 | HWND hwndParent;
|
|---|
| 41 | WORD numParts;
|
|---|
| 42 | WORD textHeight;
|
|---|
| 43 | UINT height;
|
|---|
| 44 | BOOL simple;
|
|---|
| 45 | HWND hwndToolTip;
|
|---|
| 46 | HFONT hFont;
|
|---|
| 47 | HFONT hDefaultFont;
|
|---|
| 48 | COLORREF clrBk; /* background color */
|
|---|
| 49 | BOOL bUnicode; /* unicode flag */
|
|---|
| 50 | STATUSWINDOWPART part0; /* simple window */
|
|---|
| 51 | STATUSWINDOWPART *parts;
|
|---|
| 52 | } STATUSWINDOWINFO;
|
|---|
| 53 |
|
|---|
| 54 | /*
|
|---|
| 55 | * Run tests using Waite Group Windows95 API Bible Vol. 1&2
|
|---|
| 56 | * The second cdrom contains executables drawstat.exe, gettext.exe,
|
|---|
| 57 | * simple.exe, getparts.exe, setparts.exe, statwnd.exe
|
|---|
| 58 | */
|
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 | #define _MAX(a,b) (((a)>(b))?(a):(b))
|
|---|
| 62 | #define _MIN(a,b) (((a)>(b))?(b):(a))
|
|---|
| 63 |
|
|---|
| 64 | #define HORZ_BORDER 0
|
|---|
| 65 | #define VERT_BORDER 2
|
|---|
| 66 | #define HORZ_GAP 2
|
|---|
| 67 |
|
|---|
| 68 | #define STATUSBAR_GetInfoPtr(hwnd) ((STATUSWINDOWINFO *)GetWindowLongA (hwnd, 0))
|
|---|
| 69 |
|
|---|
| 70 | /* prototype */
|
|---|
| 71 | static void
|
|---|
| 72 | STATUSBAR_SetPartBounds (STATUSWINDOWINFO *infoPtr, HWND hwnd);
|
|---|
| 73 |
|
|---|
| 74 | static void
|
|---|
| 75 | STATUSBAR_DrawSizeGrip (HDC hdc, LPRECT lpRect)
|
|---|
| 76 | {
|
|---|
| 77 | HPEN hOldPen;
|
|---|
| 78 | POINT pt;
|
|---|
| 79 | INT i;
|
|---|
| 80 |
|
|---|
| 81 | TRACE("draw size grip %d,%d - %d,%d\n", lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
|
|---|
| 82 | pt.x = lpRect->right - 1;
|
|---|
| 83 | pt.y = lpRect->bottom - 1;
|
|---|
| 84 |
|
|---|
| 85 | hOldPen = SelectObject (hdc, GetSysColorPen (COLOR_3DFACE));
|
|---|
| 86 | MoveToEx (hdc, pt.x - 12, pt.y, NULL);
|
|---|
| 87 | LineTo (hdc, pt.x, pt.y);
|
|---|
| 88 | LineTo (hdc, pt.x, pt.y - 12);
|
|---|
| 89 |
|
|---|
| 90 | pt.x--;
|
|---|
| 91 | pt.y--;
|
|---|
| 92 |
|
|---|
| 93 | SelectObject (hdc, GetSysColorPen (COLOR_3DSHADOW));
|
|---|
| 94 | for (i = 1; i < 11; i += 4) {
|
|---|
| 95 | MoveToEx (hdc, pt.x - i, pt.y, NULL);
|
|---|
| 96 | LineTo (hdc, pt.x, pt.y - i);
|
|---|
| 97 |
|
|---|
| 98 | MoveToEx (hdc, pt.x - i-1, pt.y, NULL);
|
|---|
| 99 | LineTo (hdc, pt.x, pt.y - i-1);
|
|---|
| 100 | }
|
|---|
| 101 |
|
|---|
| 102 | SelectObject (hdc, GetSysColorPen (COLOR_3DHIGHLIGHT));
|
|---|
| 103 | for (i = 3; i < 13; i += 4) {
|
|---|
| 104 | MoveToEx (hdc, pt.x - i, pt.y, NULL);
|
|---|
| 105 | LineTo (hdc, pt.x, pt.y - i);
|
|---|
| 106 | }
|
|---|
| 107 |
|
|---|
| 108 | SelectObject (hdc, hOldPen);
|
|---|
| 109 | }
|
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 | static void
|
|---|
| 113 | STATUSBAR_DrawPart (HDC hdc, STATUSWINDOWPART *part)
|
|---|
| 114 | {
|
|---|
| 115 | RECT r = part->bound;
|
|---|
| 116 | UINT border = BDR_SUNKENOUTER;
|
|---|
| 117 |
|
|---|
| 118 | TRACE("part bound %d,%d - %d,%d\n", r.left, r.top, r.right, r.bottom);
|
|---|
| 119 | if (part->style & SBT_POPOUT)
|
|---|
| 120 | border = BDR_RAISEDOUTER;
|
|---|
| 121 | else if (part->style & SBT_NOBORDERS)
|
|---|
| 122 | border = 0;
|
|---|
| 123 |
|
|---|
| 124 | DrawEdge(hdc, &r, border, BF_RECT|BF_ADJUST);
|
|---|
| 125 |
|
|---|
| 126 | /* draw the icon */
|
|---|
| 127 | if (part->hIcon) {
|
|---|
| 128 | INT cy = r.bottom - r.top;
|
|---|
| 129 |
|
|---|
| 130 | r.left += 2;
|
|---|
| 131 | DrawIconEx (hdc, r.left, r.top, part->hIcon, cy, cy, 0, 0, DI_NORMAL);
|
|---|
| 132 | r.left += cy;
|
|---|
| 133 | }
|
|---|
| 134 |
|
|---|
| 135 | /* now draw text */
|
|---|
| 136 | if (part->text) {
|
|---|
| 137 | int oldbkmode = SetBkMode(hdc, TRANSPARENT);
|
|---|
| 138 | LPWSTR p = (LPWSTR)part->text;
|
|---|
| 139 | UINT align = DT_LEFT;
|
|---|
| 140 | if (*p == L'\t') {
|
|---|
| 141 | p++;
|
|---|
| 142 | align = DT_CENTER;
|
|---|
| 143 |
|
|---|
| 144 | if (*p == L'\t') {
|
|---|
| 145 | p++;
|
|---|
| 146 | align = DT_RIGHT;
|
|---|
| 147 | }
|
|---|
| 148 | }
|
|---|
| 149 | r.left += 3;
|
|---|
| 150 | TRACE("%s at %d,%d - %d,%d\n", debugstr_w(p), r.left, r.top, r.right, r.bottom);
|
|---|
| 151 | DrawTextW (hdc, p, -1, &r, align|DT_VCENTER|DT_SINGLELINE);
|
|---|
| 152 | if (oldbkmode != TRANSPARENT)
|
|---|
| 153 | SetBkMode(hdc, oldbkmode);
|
|---|
| 154 | }
|
|---|
| 155 | }
|
|---|
| 156 |
|
|---|
| 157 |
|
|---|
| 158 | static VOID
|
|---|
| 159 | STATUSBAR_RefreshPart (STATUSWINDOWINFO *infoPtr, HWND hwnd, STATUSWINDOWPART *part, HDC hdc, int itemID)
|
|---|
| 160 | {
|
|---|
| 161 | HBRUSH hbrBk;
|
|---|
| 162 | HFONT hOldFont;
|
|---|
| 163 |
|
|---|
| 164 | TRACE("item %d\n", itemID);
|
|---|
| 165 | if (!IsWindowVisible (hwnd))
|
|---|
| 166 | return;
|
|---|
| 167 |
|
|---|
| 168 | if (part->bound.right < part->bound.left) return;
|
|---|
| 169 |
|
|---|
| 170 | if (infoPtr->clrBk != CLR_DEFAULT)
|
|---|
| 171 | hbrBk = CreateSolidBrush (infoPtr->clrBk);
|
|---|
| 172 | else
|
|---|
| 173 | hbrBk = GetSysColorBrush (COLOR_3DFACE);
|
|---|
| 174 | FillRect(hdc, &part->bound, hbrBk);
|
|---|
| 175 |
|
|---|
| 176 | hOldFont = SelectObject (hdc, infoPtr->hFont ? infoPtr->hFont : infoPtr->hDefaultFont);
|
|---|
| 177 |
|
|---|
| 178 | if (part->style & SBT_OWNERDRAW) {
|
|---|
| 179 | DRAWITEMSTRUCT dis;
|
|---|
| 180 |
|
|---|
| 181 | dis.CtlID = GetWindowLongA (hwnd, GWL_ID);
|
|---|
| 182 | dis.itemID = itemID;
|
|---|
| 183 | dis.hwndItem = hwnd;
|
|---|
| 184 | dis.hDC = hdc;
|
|---|
| 185 | dis.rcItem = part->bound;
|
|---|
| 186 | dis.itemData = (INT)part->text;
|
|---|
| 187 | SendMessageA (GetParent (hwnd), WM_DRAWITEM,
|
|---|
| 188 | (WPARAM)dis.CtlID, (LPARAM)&dis);
|
|---|
| 189 | } else
|
|---|
| 190 | STATUSBAR_DrawPart (hdc, part);
|
|---|
| 191 |
|
|---|
| 192 | SelectObject (hdc, hOldFont);
|
|---|
| 193 |
|
|---|
| 194 | if (infoPtr->clrBk != CLR_DEFAULT)
|
|---|
| 195 | DeleteObject (hbrBk);
|
|---|
| 196 |
|
|---|
| 197 | if (GetWindowLongA (hwnd, GWL_STYLE) & SBARS_SIZEGRIP) {
|
|---|
| 198 | RECT rect;
|
|---|
| 199 |
|
|---|
| 200 | GetClientRect (hwnd, &rect);
|
|---|
| 201 | STATUSBAR_DrawSizeGrip (hdc, &rect);
|
|---|
| 202 | }
|
|---|
| 203 | }
|
|---|
| 204 |
|
|---|
| 205 |
|
|---|
| 206 | static BOOL
|
|---|
| 207 | STATUSBAR_Refresh (STATUSWINDOWINFO *infoPtr, HWND hwnd, HDC hdc)
|
|---|
| 208 | {
|
|---|
| 209 | int i;
|
|---|
| 210 | RECT rect;
|
|---|
| 211 | HBRUSH hbrBk;
|
|---|
| 212 | HFONT hOldFont;
|
|---|
| 213 |
|
|---|
| 214 | TRACE("\n");
|
|---|
| 215 | if (!IsWindowVisible(hwnd))
|
|---|
| 216 | return (TRUE);
|
|---|
| 217 |
|
|---|
| 218 | STATUSBAR_SetPartBounds(infoPtr, hwnd);
|
|---|
| 219 |
|
|---|
| 220 | GetClientRect (hwnd, &rect);
|
|---|
| 221 |
|
|---|
| 222 | if (infoPtr->clrBk != CLR_DEFAULT)
|
|---|
| 223 | hbrBk = CreateSolidBrush (infoPtr->clrBk);
|
|---|
| 224 | else
|
|---|
| 225 | hbrBk = GetSysColorBrush (COLOR_3DFACE);
|
|---|
| 226 | FillRect(hdc, &rect, hbrBk);
|
|---|
| 227 |
|
|---|
| 228 | hOldFont = SelectObject (hdc, infoPtr->hFont ? infoPtr->hFont : infoPtr->hDefaultFont);
|
|---|
| 229 |
|
|---|
| 230 | if (infoPtr->simple) {
|
|---|
| 231 | STATUSBAR_RefreshPart (infoPtr, hwnd, &infoPtr->part0, hdc, 0);
|
|---|
| 232 | } else {
|
|---|
| 233 | for (i = 0; i < infoPtr->numParts; i++) {
|
|---|
| 234 | if (infoPtr->parts[i].style & SBT_OWNERDRAW) {
|
|---|
| 235 | DRAWITEMSTRUCT dis;
|
|---|
| 236 |
|
|---|
| 237 | dis.CtlID = GetWindowLongA (hwnd, GWL_ID);
|
|---|
| 238 | dis.itemID = i;
|
|---|
| 239 | dis.hwndItem = hwnd;
|
|---|
| 240 | dis.hDC = hdc;
|
|---|
| 241 | dis.rcItem = infoPtr->parts[i].bound;
|
|---|
| 242 | dis.itemData = (INT)infoPtr->parts[i].text;
|
|---|
| 243 | SendMessageA (GetParent (hwnd), WM_DRAWITEM,
|
|---|
| 244 | (WPARAM)dis.CtlID, (LPARAM)&dis);
|
|---|
| 245 | } else
|
|---|
| 246 | STATUSBAR_RefreshPart (infoPtr, hwnd, &infoPtr->parts[i], hdc, i);
|
|---|
| 247 | }
|
|---|
| 248 | }
|
|---|
| 249 |
|
|---|
| 250 | SelectObject (hdc, hOldFont);
|
|---|
| 251 |
|
|---|
| 252 | if (infoPtr->clrBk != CLR_DEFAULT)
|
|---|
| 253 | DeleteObject (hbrBk);
|
|---|
| 254 |
|
|---|
| 255 | if (GetWindowLongA(hwnd, GWL_STYLE) & SBARS_SIZEGRIP)
|
|---|
| 256 | STATUSBAR_DrawSizeGrip (hdc, &rect);
|
|---|
| 257 |
|
|---|
| 258 | return TRUE;
|
|---|
| 259 | }
|
|---|
| 260 |
|
|---|
| 261 |
|
|---|
| 262 | static void
|
|---|
| 263 | STATUSBAR_SetPartBounds (STATUSWINDOWINFO *infoPtr, HWND hwnd)
|
|---|
| 264 | {
|
|---|
| 265 | STATUSWINDOWPART *part;
|
|---|
| 266 | RECT rect, *r;
|
|---|
| 267 | int i;
|
|---|
| 268 |
|
|---|
| 269 | /* get our window size */
|
|---|
| 270 | GetClientRect (hwnd, &rect);
|
|---|
| 271 | TRACE("client wnd size is %d,%d - %d,%d\n", rect.left, rect.top, rect.right, rect.bottom);
|
|---|
| 272 |
|
|---|
| 273 | rect.top += VERT_BORDER;
|
|---|
| 274 |
|
|---|
| 275 | /* set bounds for simple rectangle */
|
|---|
| 276 | infoPtr->part0.bound = rect;
|
|---|
| 277 |
|
|---|
| 278 | /* set bounds for non-simple rectangles */
|
|---|
| 279 | for (i = 0; i < infoPtr->numParts; i++) {
|
|---|
| 280 | part = &infoPtr->parts[i];
|
|---|
| 281 | r = &infoPtr->parts[i].bound;
|
|---|
| 282 | r->top = rect.top;
|
|---|
| 283 | r->bottom = rect.bottom;
|
|---|
| 284 | if (i == 0)
|
|---|
| 285 | r->left = 0;
|
|---|
| 286 | else
|
|---|
| 287 | r->left = infoPtr->parts[i-1].bound.right + HORZ_GAP;
|
|---|
| 288 | if (part->x == -1)
|
|---|
| 289 | r->right = rect.right;
|
|---|
| 290 | else
|
|---|
| 291 | r->right = part->x;
|
|---|
| 292 |
|
|---|
| 293 | if (infoPtr->hwndToolTip) {
|
|---|
| 294 | TTTOOLINFOA ti;
|
|---|
| 295 |
|
|---|
| 296 | ti.cbSize = sizeof(TTTOOLINFOA);
|
|---|
| 297 | ti.hwnd = hwnd;
|
|---|
| 298 | ti.uId = i;
|
|---|
| 299 | ti.rect = *r;
|
|---|
| 300 | SendMessageA (infoPtr->hwndToolTip, TTM_NEWTOOLRECTA,
|
|---|
| 301 | 0, (LPARAM)&ti);
|
|---|
| 302 | }
|
|---|
| 303 | }
|
|---|
| 304 | }
|
|---|
| 305 |
|
|---|
| 306 |
|
|---|
| 307 | static VOID
|
|---|
| 308 | STATUSBAR_RelayEvent (HWND hwndTip, HWND hwndMsg, UINT uMsg,
|
|---|
| 309 | WPARAM wParam, LPARAM lParam)
|
|---|
| 310 | {
|
|---|
| 311 | MSG msg;
|
|---|
| 312 |
|
|---|
| 313 | msg.hwnd = hwndMsg;
|
|---|
| 314 | msg.message = uMsg;
|
|---|
| 315 | msg.wParam = wParam;
|
|---|
| 316 | msg.lParam = lParam;
|
|---|
| 317 | msg.time = GetMessageTime ();
|
|---|
| 318 | msg.pt.x = LOWORD(GetMessagePos ());
|
|---|
| 319 | msg.pt.y = HIWORD(GetMessagePos ());
|
|---|
| 320 |
|
|---|
| 321 | SendMessageA (hwndTip, TTM_RELAYEVENT, 0, (LPARAM)&msg);
|
|---|
| 322 | }
|
|---|
| 323 |
|
|---|
| 324 |
|
|---|
| 325 | inline static LRESULT
|
|---|
| 326 | STATUSBAR_GetBorders (LPARAM lParam)
|
|---|
| 327 | {
|
|---|
| 328 | LPINT out = (LPINT) lParam;
|
|---|
| 329 |
|
|---|
| 330 | TRACE("\n");
|
|---|
| 331 | out[0] = HORZ_BORDER; /* horizontal border width */
|
|---|
| 332 | out[1] = VERT_BORDER; /* vertical border width */
|
|---|
| 333 | out[2] = HORZ_GAP; /* width of border between rectangles */
|
|---|
| 334 |
|
|---|
| 335 | return TRUE;
|
|---|
| 336 | }
|
|---|
| 337 |
|
|---|
| 338 |
|
|---|
| 339 | static LRESULT
|
|---|
| 340 | STATUSBAR_GetIcon (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam)
|
|---|
| 341 | {
|
|---|
| 342 | INT nPart;
|
|---|
| 343 |
|
|---|
| 344 | nPart = (INT)wParam & 0x00ff;
|
|---|
| 345 | TRACE("%d\n", nPart);
|
|---|
| 346 | if ((nPart < -1) || (nPart >= infoPtr->numParts))
|
|---|
| 347 | return 0;
|
|---|
| 348 |
|
|---|
| 349 | if (nPart == -1)
|
|---|
| 350 | return (infoPtr->part0.hIcon);
|
|---|
| 351 | else
|
|---|
| 352 | return (infoPtr->parts[nPart].hIcon);
|
|---|
| 353 | }
|
|---|
| 354 |
|
|---|
| 355 |
|
|---|
| 356 | static LRESULT
|
|---|
| 357 | STATUSBAR_GetParts (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 358 | {
|
|---|
| 359 | LPINT parts;
|
|---|
| 360 | INT num_parts;
|
|---|
| 361 | INT i;
|
|---|
| 362 |
|
|---|
| 363 | num_parts = (INT) wParam;
|
|---|
| 364 | TRACE("(%d)\n", num_parts);
|
|---|
| 365 | parts = (LPINT) lParam;
|
|---|
| 366 | if (parts) {
|
|---|
| 367 | for (i = 0; i < num_parts; i++) {
|
|---|
| 368 | parts[i] = infoPtr->parts[i].x;
|
|---|
| 369 | }
|
|---|
| 370 | }
|
|---|
| 371 | return (infoPtr->numParts);
|
|---|
| 372 | }
|
|---|
| 373 |
|
|---|
| 374 |
|
|---|
| 375 | static LRESULT
|
|---|
| 376 | STATUSBAR_GetRect (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 377 | {
|
|---|
| 378 | int nPart;
|
|---|
| 379 | LPRECT rect;
|
|---|
| 380 |
|
|---|
| 381 | nPart = ((INT) wParam) & 0x00ff;
|
|---|
| 382 | TRACE("part %d\n", nPart);
|
|---|
| 383 | rect = (LPRECT) lParam;
|
|---|
| 384 | if (infoPtr->simple)
|
|---|
| 385 | *rect = infoPtr->part0.bound;
|
|---|
| 386 | else
|
|---|
| 387 | *rect = infoPtr->parts[nPart].bound;
|
|---|
| 388 | return TRUE;
|
|---|
| 389 | }
|
|---|
| 390 |
|
|---|
| 391 |
|
|---|
| 392 | static LRESULT
|
|---|
| 393 | STATUSBAR_GetTextA (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 394 | {
|
|---|
| 395 | STATUSWINDOWPART *part;
|
|---|
| 396 | INT nPart;
|
|---|
| 397 | LRESULT result;
|
|---|
| 398 |
|
|---|
| 399 | nPart = ((INT) wParam) & 0x00ff;
|
|---|
| 400 | TRACE("part %d\n", nPart);
|
|---|
| 401 | if (infoPtr->simple)
|
|---|
| 402 | part = &infoPtr->part0;
|
|---|
| 403 | else
|
|---|
| 404 | #ifdef __WIN32OS2__
|
|---|
| 405 | {
|
|---|
| 406 | if (nPart >= infoPtr->numParts)
|
|---|
| 407 | return FALSE;
|
|---|
| 408 | part = &infoPtr->parts[nPart];
|
|---|
| 409 | }
|
|---|
| 410 | #else
|
|---|
| 411 | part = &infoPtr->parts[nPart];
|
|---|
| 412 | #endif
|
|---|
| 413 |
|
|---|
| 414 | if (part->style & SBT_OWNERDRAW)
|
|---|
| 415 | result = (LRESULT)part->text;
|
|---|
| 416 | else {
|
|---|
| 417 | DWORD len = part->text ? WideCharToMultiByte( CP_ACP, 0, part->text, -1,
|
|---|
| 418 | NULL, 0, NULL, NULL ) - 1 : 0;
|
|---|
| 419 | result = MAKELONG( len, part->style );
|
|---|
| 420 | if (lParam && len)
|
|---|
| 421 | WideCharToMultiByte( CP_ACP, 0, part->text, -1, (LPSTR)lParam, len+1, NULL, NULL );
|
|---|
| 422 | }
|
|---|
| 423 | return result;
|
|---|
| 424 | }
|
|---|
| 425 |
|
|---|
| 426 |
|
|---|
| 427 | static LRESULT
|
|---|
| 428 | STATUSBAR_GetTextW (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 429 | {
|
|---|
| 430 | STATUSWINDOWPART *part;
|
|---|
| 431 | INT nPart;
|
|---|
| 432 | LRESULT result;
|
|---|
| 433 |
|
|---|
| 434 | nPart = ((INT)wParam) & 0x00ff;
|
|---|
| 435 | TRACE("part %d\n", nPart);
|
|---|
| 436 | if (infoPtr->simple)
|
|---|
| 437 | part = &infoPtr->part0;
|
|---|
| 438 | else
|
|---|
| 439 | #ifdef __WIN32OS2__
|
|---|
| 440 | {
|
|---|
| 441 | if (nPart >= infoPtr->numParts)
|
|---|
| 442 | return FALSE;
|
|---|
| 443 | part = &infoPtr->parts[nPart];
|
|---|
| 444 | }
|
|---|
| 445 | #else
|
|---|
| 446 | part = &infoPtr->parts[nPart];
|
|---|
| 447 | #endif
|
|---|
| 448 |
|
|---|
| 449 | if (part->style & SBT_OWNERDRAW)
|
|---|
| 450 | result = (LRESULT)part->text;
|
|---|
| 451 | else {
|
|---|
| 452 | result = part->text ? strlenW (part->text) : 0;
|
|---|
| 453 | result |= (part->style << 16);
|
|---|
| 454 | if (part->text && lParam)
|
|---|
| 455 | strcpyW ((LPWSTR)lParam, part->text);
|
|---|
| 456 | }
|
|---|
| 457 | return result;
|
|---|
| 458 | }
|
|---|
| 459 |
|
|---|
| 460 |
|
|---|
| 461 | static LRESULT
|
|---|
| 462 | STATUSBAR_GetTextLength (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam)
|
|---|
| 463 | {
|
|---|
| 464 | STATUSWINDOWPART *part;
|
|---|
| 465 | INT nPart;
|
|---|
| 466 | DWORD result;
|
|---|
| 467 |
|
|---|
| 468 | nPart = ((INT) wParam) & 0x00ff;
|
|---|
| 469 |
|
|---|
| 470 | TRACE("part %d\n", nPart);
|
|---|
| 471 |
|
|---|
| 472 | if (infoPtr->simple)
|
|---|
| 473 | part = &infoPtr->part0;
|
|---|
| 474 | else
|
|---|
| 475 | #ifdef __WIN32OS2__
|
|---|
| 476 | {
|
|---|
| 477 | if (nPart >= infoPtr->numParts)
|
|---|
| 478 | return FALSE;
|
|---|
| 479 | if (infoPtr->simple)
|
|---|
| 480 | part = &infoPtr->part0;
|
|---|
| 481 | else
|
|---|
| 482 | part = &infoPtr->parts[nPart];
|
|---|
| 483 | }
|
|---|
| 484 | #else
|
|---|
| 485 | if (infoPtr->simple)
|
|---|
| 486 | part = &infoPtr->part0;
|
|---|
| 487 | else
|
|---|
| 488 | part = &infoPtr->parts[nPart];
|
|---|
| 489 | #endif
|
|---|
| 490 |
|
|---|
| 491 | if (part->text)
|
|---|
| 492 | result = strlenW(part->text);
|
|---|
| 493 | else
|
|---|
| 494 | result = 0;
|
|---|
| 495 |
|
|---|
| 496 | result |= (part->style << 16);
|
|---|
| 497 | return result;
|
|---|
| 498 | }
|
|---|
| 499 |
|
|---|
| 500 |
|
|---|
| 501 | static LRESULT
|
|---|
| 502 | STATUSBAR_GetTipTextA (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 503 | {
|
|---|
| 504 | LPSTR tip = (LPSTR)lParam;
|
|---|
| 505 |
|
|---|
| 506 | if (tip) {
|
|---|
| 507 | CHAR buf[INFOTIPSIZE];
|
|---|
| 508 | buf[0]='\0';
|
|---|
| 509 |
|
|---|
| 510 | if (infoPtr->hwndToolTip) {
|
|---|
| 511 | TTTOOLINFOA ti;
|
|---|
| 512 | ti.cbSize = sizeof(TTTOOLINFOA);
|
|---|
| 513 | ti.hwnd = hwnd;
|
|---|
| 514 | ti.uId = LOWORD(wParam);
|
|---|
| 515 | ti.lpszText = buf;
|
|---|
| 516 | SendMessageA(infoPtr->hwndToolTip, TTM_GETTEXTA, 0, (LPARAM)&ti);
|
|---|
| 517 | }
|
|---|
| 518 | lstrcpynA(tip, buf, HIWORD(wParam));
|
|---|
| 519 | }
|
|---|
| 520 | return 0;
|
|---|
| 521 | }
|
|---|
| 522 |
|
|---|
| 523 |
|
|---|
| 524 | static LRESULT
|
|---|
| 525 | STATUSBAR_GetTipTextW (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 526 | {
|
|---|
| 527 | LPWSTR tip = (LPWSTR)lParam;
|
|---|
| 528 |
|
|---|
| 529 | TRACE("\n");
|
|---|
| 530 | if (tip) {
|
|---|
| 531 | WCHAR buf[INFOTIPSIZE];
|
|---|
| 532 | buf[0]=0;
|
|---|
| 533 |
|
|---|
| 534 | if (infoPtr->hwndToolTip) {
|
|---|
| 535 | TTTOOLINFOW ti;
|
|---|
| 536 | ti.cbSize = sizeof(TTTOOLINFOW);
|
|---|
| 537 | ti.hwnd = hwnd;
|
|---|
| 538 | ti.uId = LOWORD(wParam);
|
|---|
| 539 | ti.lpszText = buf;
|
|---|
| 540 | SendMessageW(infoPtr->hwndToolTip, TTM_GETTEXTW, 0, (LPARAM)&ti);
|
|---|
| 541 | }
|
|---|
| 542 | lstrcpynW(tip, buf, HIWORD(wParam));
|
|---|
| 543 | }
|
|---|
| 544 |
|
|---|
| 545 | return 0;
|
|---|
| 546 | }
|
|---|
| 547 |
|
|---|
| 548 |
|
|---|
| 549 | inline static LRESULT
|
|---|
| 550 | STATUSBAR_GetUnicodeFormat (STATUSWINDOWINFO *infoPtr, HWND hwnd)
|
|---|
| 551 | {
|
|---|
| 552 | return infoPtr->bUnicode;
|
|---|
| 553 | }
|
|---|
| 554 |
|
|---|
| 555 |
|
|---|
| 556 | inline static LRESULT
|
|---|
| 557 | STATUSBAR_IsSimple (STATUSWINDOWINFO *infoPtr, HWND hwnd)
|
|---|
| 558 | {
|
|---|
| 559 | return infoPtr->simple;
|
|---|
| 560 | }
|
|---|
| 561 |
|
|---|
| 562 |
|
|---|
| 563 | static LRESULT
|
|---|
| 564 | STATUSBAR_SetBkColor (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 565 | {
|
|---|
| 566 | COLORREF oldBkColor;
|
|---|
| 567 |
|
|---|
| 568 | oldBkColor = infoPtr->clrBk;
|
|---|
| 569 | infoPtr->clrBk = (COLORREF)lParam;
|
|---|
| 570 | InvalidateRect(hwnd, NULL, FALSE);
|
|---|
| 571 |
|
|---|
| 572 | TRACE("CREF: %08lx -> %08lx\n", oldBkColor, infoPtr->clrBk);
|
|---|
| 573 | return oldBkColor;
|
|---|
| 574 | }
|
|---|
| 575 |
|
|---|
| 576 |
|
|---|
| 577 | static LRESULT
|
|---|
| 578 | STATUSBAR_SetIcon (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 579 | {
|
|---|
| 580 | INT nPart = (INT)wParam & 0x00ff;
|
|---|
| 581 |
|
|---|
| 582 | if ((nPart < -1) || (nPart >= infoPtr->numParts))
|
|---|
| 583 | return FALSE;
|
|---|
| 584 |
|
|---|
| 585 | TRACE("setting part %d, icon %lx\n",nPart,lParam);
|
|---|
| 586 |
|
|---|
| 587 | if (nPart == -1) {
|
|---|
| 588 | if (infoPtr->part0.hIcon == (HICON)lParam) /* same as - no redraw */
|
|---|
| 589 | return TRUE;
|
|---|
| 590 | infoPtr->part0.hIcon = (HICON)lParam;
|
|---|
| 591 | if (infoPtr->simple)
|
|---|
| 592 | InvalidateRect(hwnd, &infoPtr->part0.bound, FALSE);
|
|---|
| 593 | } else {
|
|---|
| 594 | if (infoPtr->parts[nPart].hIcon == (HICON)lParam) /* same as - no redraw */
|
|---|
| 595 | return TRUE;
|
|---|
| 596 |
|
|---|
| 597 | infoPtr->parts[nPart].hIcon = (HICON)lParam;
|
|---|
| 598 | if (!(infoPtr->simple))
|
|---|
| 599 | InvalidateRect(hwnd, &infoPtr->parts[nPart].bound, FALSE);
|
|---|
| 600 | }
|
|---|
| 601 | return TRUE;
|
|---|
| 602 | }
|
|---|
| 603 |
|
|---|
| 604 |
|
|---|
| 605 | static LRESULT
|
|---|
| 606 | STATUSBAR_SetMinHeight (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 607 | {
|
|---|
| 608 |
|
|---|
| 609 | TRACE("\n");
|
|---|
| 610 | if (IsWindowVisible (hwnd)) {
|
|---|
| 611 | HWND parent = GetParent (hwnd);
|
|---|
| 612 | INT width, x, y;
|
|---|
| 613 | RECT parent_rect;
|
|---|
| 614 |
|
|---|
| 615 | GetClientRect (parent, &parent_rect);
|
|---|
| 616 | infoPtr->height = (INT)wParam + VERT_BORDER;
|
|---|
| 617 | width = parent_rect.right - parent_rect.left;
|
|---|
| 618 | x = parent_rect.left;
|
|---|
| 619 | y = parent_rect.bottom - infoPtr->height;
|
|---|
| 620 | MoveWindow (hwnd, parent_rect.left,
|
|---|
| 621 | parent_rect.bottom - infoPtr->height,
|
|---|
| 622 | width, infoPtr->height, TRUE);
|
|---|
| 623 | STATUSBAR_SetPartBounds (infoPtr, hwnd);
|
|---|
| 624 | }
|
|---|
| 625 |
|
|---|
| 626 | return TRUE;
|
|---|
| 627 | }
|
|---|
| 628 |
|
|---|
| 629 |
|
|---|
| 630 | static LRESULT
|
|---|
| 631 | STATUSBAR_SetParts (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 632 | {
|
|---|
| 633 | STATUSWINDOWPART *tmp;
|
|---|
| 634 | LPINT parts;
|
|---|
| 635 | int i;
|
|---|
| 636 | int oldNumParts;
|
|---|
| 637 |
|
|---|
| 638 | TRACE("(%d,%p)\n",wParam,(LPVOID)lParam);
|
|---|
| 639 |
|
|---|
| 640 | /* FIXME: should return FALSE sometimes (maybe when wParam == 0 ?) */
|
|---|
| 641 | if (infoPtr->simple)
|
|---|
| 642 | infoPtr->simple = FALSE;
|
|---|
| 643 |
|
|---|
| 644 | oldNumParts = infoPtr->numParts;
|
|---|
| 645 | infoPtr->numParts = (INT) wParam;
|
|---|
| 646 | parts = (LPINT) lParam;
|
|---|
| 647 | if (oldNumParts > infoPtr->numParts) {
|
|---|
| 648 | for (i = infoPtr->numParts ; i < oldNumParts; i++) {
|
|---|
| 649 | if (infoPtr->parts[i].text && !(infoPtr->parts[i].style & SBT_OWNERDRAW))
|
|---|
| 650 | COMCTL32_Free (infoPtr->parts[i].text);
|
|---|
| 651 | }
|
|---|
| 652 | }
|
|---|
| 653 | if (oldNumParts < infoPtr->numParts) {
|
|---|
| 654 | tmp = COMCTL32_Alloc (sizeof(STATUSWINDOWPART) * infoPtr->numParts);
|
|---|
| 655 | for (i = 0; i < oldNumParts; i++) {
|
|---|
| 656 | tmp[i] = infoPtr->parts[i];
|
|---|
| 657 | }
|
|---|
| 658 | if (infoPtr->parts)
|
|---|
| 659 | COMCTL32_Free (infoPtr->parts);
|
|---|
| 660 | infoPtr->parts = tmp;
|
|---|
| 661 | }
|
|---|
| 662 | if (oldNumParts == infoPtr->numParts) {
|
|---|
| 663 | for (i=0;i<oldNumParts;i++)
|
|---|
| 664 | if (infoPtr->parts[i].x != parts[i])
|
|---|
| 665 | break;
|
|---|
| 666 | if (i==oldNumParts) /* Unchanged? no need to redraw! */
|
|---|
| 667 | return TRUE;
|
|---|
| 668 | }
|
|---|
| 669 |
|
|---|
| 670 | for (i = 0; i < infoPtr->numParts; i++)
|
|---|
| 671 | infoPtr->parts[i].x = parts[i];
|
|---|
| 672 |
|
|---|
| 673 | if (infoPtr->hwndToolTip) {
|
|---|
| 674 | INT nTipCount =
|
|---|
| 675 | SendMessageA (infoPtr->hwndToolTip, TTM_GETTOOLCOUNT, 0, 0);
|
|---|
| 676 |
|
|---|
| 677 | if (nTipCount < infoPtr->numParts) {
|
|---|
| 678 | /* add tools */
|
|---|
| 679 | TTTOOLINFOA ti;
|
|---|
| 680 | INT i;
|
|---|
| 681 |
|
|---|
| 682 | ZeroMemory (&ti, sizeof(TTTOOLINFOA));
|
|---|
| 683 | ti.cbSize = sizeof(TTTOOLINFOA);
|
|---|
| 684 | ti.hwnd = hwnd;
|
|---|
| 685 | for (i = nTipCount; i < infoPtr->numParts; i++) {
|
|---|
| 686 | TRACE("add tool %d\n", i);
|
|---|
| 687 | ti.uId = i;
|
|---|
| 688 | SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
|
|---|
| 689 | 0, (LPARAM)&ti);
|
|---|
| 690 | }
|
|---|
| 691 | }
|
|---|
| 692 | else if (nTipCount > infoPtr->numParts) {
|
|---|
| 693 | /* delete tools */
|
|---|
| 694 | INT i;
|
|---|
| 695 |
|
|---|
| 696 | for (i = nTipCount - 1; i >= infoPtr->numParts; i--) {
|
|---|
| 697 | FIXME("delete tool %d\n", i);
|
|---|
| 698 | }
|
|---|
| 699 | }
|
|---|
| 700 | }
|
|---|
| 701 | STATUSBAR_SetPartBounds (infoPtr, hwnd);
|
|---|
| 702 | InvalidateRect(hwnd, NULL, FALSE);
|
|---|
| 703 | return TRUE;
|
|---|
| 704 | }
|
|---|
| 705 |
|
|---|
| 706 |
|
|---|
| 707 | static LRESULT
|
|---|
| 708 | STATUSBAR_SetTextA (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 709 | {
|
|---|
| 710 | STATUSWINDOWPART *part=NULL;
|
|---|
| 711 | int nPart;
|
|---|
| 712 | int style;
|
|---|
| 713 | LPSTR text;
|
|---|
| 714 | BOOL changed = FALSE;
|
|---|
| 715 |
|
|---|
| 716 | text = (LPSTR) lParam;
|
|---|
| 717 | nPart = ((INT) wParam) & 0x00ff;
|
|---|
| 718 | style = ((INT) wParam) & 0xff00;
|
|---|
| 719 |
|
|---|
| 720 | #ifdef __WIN32OS2__
|
|---|
| 721 | if (style & SBT_OWNERDRAW) {
|
|---|
| 722 | TRACE("part %d, text %x\n",nPart,text);
|
|---|
| 723 | }
|
|---|
| 724 | else TRACE("part %d, text %s\n",nPart,debugstr_a(text));
|
|---|
| 725 | #else
|
|---|
| 726 | TRACE("part %d, text %s\n",nPart,debugstr_a(text));
|
|---|
| 727 | #endif
|
|---|
| 728 |
|
|---|
| 729 | if (nPart==255)
|
|---|
| 730 | part = &infoPtr->part0;
|
|---|
| 731 | else if (!infoPtr->simple && infoPtr->parts!=NULL)
|
|---|
| 732 | #ifdef __WIN32OS2__
|
|---|
| 733 | {
|
|---|
| 734 | if (nPart >= infoPtr->numParts)
|
|---|
| 735 | return FALSE;
|
|---|
| 736 | part = &infoPtr->parts[nPart];
|
|---|
| 737 | }
|
|---|
| 738 | #else
|
|---|
| 739 | part = &infoPtr->parts[nPart];
|
|---|
| 740 | #endif
|
|---|
| 741 | if (!part) return FALSE;
|
|---|
| 742 |
|
|---|
| 743 | if (part->style != style)
|
|---|
| 744 | changed = TRUE;
|
|---|
| 745 |
|
|---|
| 746 | part->style = style;
|
|---|
| 747 | if (style & SBT_OWNERDRAW) {
|
|---|
| 748 | if (part->text == (LPWSTR)text)
|
|---|
| 749 | return TRUE;
|
|---|
| 750 | part->text = (LPWSTR)text;
|
|---|
| 751 | } else {
|
|---|
| 752 | LPWSTR ntext;
|
|---|
| 753 |
|
|---|
| 754 | /* check if text is unchanged -> no need to redraw */
|
|---|
| 755 | if (text) {
|
|---|
| 756 | DWORD len = MultiByteToWideChar( CP_ACP, 0, text, -1, NULL, 0 );
|
|---|
| 757 | LPWSTR tmptext = COMCTL32_Alloc(len*sizeof(WCHAR));
|
|---|
| 758 | MultiByteToWideChar( CP_ACP, 0, text, -1, tmptext, len );
|
|---|
| 759 |
|
|---|
| 760 | if (!changed && part->text && !lstrcmpW(tmptext,part->text)) {
|
|---|
| 761 | COMCTL32_Free(tmptext);
|
|---|
| 762 | return TRUE;
|
|---|
| 763 | }
|
|---|
| 764 | ntext = tmptext;
|
|---|
| 765 | } else {
|
|---|
| 766 | if (!changed && !part->text)
|
|---|
| 767 | return TRUE;
|
|---|
| 768 | ntext = 0;
|
|---|
| 769 | }
|
|---|
| 770 |
|
|---|
| 771 | if (part->text)
|
|---|
| 772 | COMCTL32_Free (part->text);
|
|---|
| 773 | part->text = ntext;
|
|---|
| 774 | }
|
|---|
| 775 | InvalidateRect(hwnd, &part->bound, FALSE);
|
|---|
| 776 |
|
|---|
| 777 | return TRUE;
|
|---|
| 778 | }
|
|---|
| 779 |
|
|---|
| 780 |
|
|---|
| 781 | static LRESULT
|
|---|
| 782 | STATUSBAR_SetTextW (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 783 | {
|
|---|
| 784 | STATUSWINDOWPART *part;
|
|---|
| 785 | INT nPart, style, len;
|
|---|
| 786 | LPWSTR text;
|
|---|
| 787 | BOOL bRedraw = FALSE;
|
|---|
| 788 |
|
|---|
| 789 | text = (LPWSTR) lParam;
|
|---|
| 790 | nPart = ((INT) wParam) & 0x00ff;
|
|---|
| 791 | style = ((INT) wParam) & 0xff00;
|
|---|
| 792 |
|
|---|
| 793 | TRACE("part %d -> '%s' with style %04x\n", nPart, debugstr_w(text), style);
|
|---|
| 794 | if ((infoPtr->simple) || (infoPtr->parts==NULL) || (nPart==255))
|
|---|
| 795 | part = &infoPtr->part0;
|
|---|
| 796 | else
|
|---|
| 797 | #ifdef __WIN32OS2__
|
|---|
| 798 | {
|
|---|
| 799 | if (nPart >= infoPtr->numParts)
|
|---|
| 800 | return FALSE;
|
|---|
| 801 | part = &infoPtr->parts[nPart];
|
|---|
| 802 | }
|
|---|
| 803 | #else
|
|---|
| 804 | part = &infoPtr->parts[nPart];
|
|---|
| 805 | #endif
|
|---|
| 806 | if (!part) return FALSE;
|
|---|
| 807 |
|
|---|
| 808 | if(part->style != style)
|
|---|
| 809 | bRedraw = TRUE;
|
|---|
| 810 |
|
|---|
| 811 | part->style = style;
|
|---|
| 812 |
|
|---|
| 813 | /* FIXME: not sure how/if we can check for change in string with ownerdraw(remove this if we can't)... */
|
|---|
| 814 | if (style & SBT_OWNERDRAW)
|
|---|
| 815 | {
|
|---|
| 816 | part->text = text;
|
|---|
| 817 | bRedraw = TRUE;
|
|---|
| 818 | } else if(!text)
|
|---|
| 819 | {
|
|---|
| 820 | if(part->text)
|
|---|
| 821 | {
|
|---|
| 822 | COMCTL32_Free(part->text);
|
|---|
| 823 | bRedraw = TRUE;
|
|---|
| 824 | }
|
|---|
| 825 | part->text = 0;
|
|---|
| 826 | } else if(!part->text || strcmpW(part->text, text)) /* see if the new string differs from the existing string */
|
|---|
| 827 | {
|
|---|
| 828 | if(part->text) COMCTL32_Free(part->text);
|
|---|
| 829 |
|
|---|
| 830 | len = strlenW(text);
|
|---|
| 831 | part->text = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
|
|---|
| 832 | strcpyW(part->text, text);
|
|---|
| 833 | bRedraw = TRUE;
|
|---|
| 834 | }
|
|---|
| 835 |
|
|---|
| 836 | if(bRedraw)
|
|---|
| 837 | InvalidateRect(hwnd, &part->bound, FALSE);
|
|---|
| 838 |
|
|---|
| 839 | return TRUE;
|
|---|
| 840 | }
|
|---|
| 841 |
|
|---|
| 842 |
|
|---|
| 843 | static LRESULT
|
|---|
| 844 | STATUSBAR_SetTipTextA (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 845 | {
|
|---|
| 846 | TRACE("part %d: \"%s\"\n", (INT)wParam, (LPSTR)lParam);
|
|---|
| 847 | if (infoPtr->hwndToolTip) {
|
|---|
| 848 | TTTOOLINFOA ti;
|
|---|
| 849 | ti.cbSize = sizeof(TTTOOLINFOA);
|
|---|
| 850 | ti.hwnd = hwnd;
|
|---|
| 851 | ti.uId = (INT)wParam;
|
|---|
| 852 | ti.hinst = 0;
|
|---|
| 853 | ti.lpszText = (LPSTR)lParam;
|
|---|
| 854 | SendMessageA (infoPtr->hwndToolTip, TTM_UPDATETIPTEXTA,
|
|---|
| 855 | 0, (LPARAM)&ti);
|
|---|
| 856 | }
|
|---|
| 857 |
|
|---|
| 858 | return 0;
|
|---|
| 859 | }
|
|---|
| 860 |
|
|---|
| 861 |
|
|---|
| 862 | static LRESULT
|
|---|
| 863 | STATUSBAR_SetTipTextW (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 864 | {
|
|---|
| 865 | TRACE("part %d: \"%s\"\n", (INT)wParam, (LPSTR)lParam);
|
|---|
| 866 | if (infoPtr->hwndToolTip) {
|
|---|
| 867 | TTTOOLINFOW ti;
|
|---|
| 868 | ti.cbSize = sizeof(TTTOOLINFOW);
|
|---|
| 869 | ti.hwnd = hwnd;
|
|---|
| 870 | ti.uId = (INT)wParam;
|
|---|
| 871 | ti.hinst = 0;
|
|---|
| 872 | ti.lpszText = (LPWSTR)lParam;
|
|---|
| 873 | SendMessageW (infoPtr->hwndToolTip, TTM_UPDATETIPTEXTW,
|
|---|
| 874 | 0, (LPARAM)&ti);
|
|---|
| 875 | }
|
|---|
| 876 |
|
|---|
| 877 | return 0;
|
|---|
| 878 | }
|
|---|
| 879 |
|
|---|
| 880 |
|
|---|
| 881 | inline static LRESULT
|
|---|
| 882 | STATUSBAR_SetUnicodeFormat (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam)
|
|---|
| 883 | {
|
|---|
| 884 | BOOL bOld = infoPtr->bUnicode;
|
|---|
| 885 |
|
|---|
| 886 | TRACE("(0x%x)\n", (BOOL)wParam);
|
|---|
| 887 | infoPtr->bUnicode = (BOOL)wParam;
|
|---|
| 888 |
|
|---|
| 889 | return bOld;
|
|---|
| 890 | }
|
|---|
| 891 |
|
|---|
| 892 |
|
|---|
| 893 | static LRESULT
|
|---|
| 894 | STATUSBAR_Simple (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 895 | {
|
|---|
| 896 | NMHDR nmhdr;
|
|---|
| 897 |
|
|---|
| 898 | TRACE("(is simple: %d)\n", wParam);
|
|---|
| 899 | if (infoPtr->simple == wParam) /* no need to change */
|
|---|
| 900 | return TRUE;
|
|---|
| 901 |
|
|---|
| 902 | infoPtr->simple = (BOOL)wParam;
|
|---|
| 903 |
|
|---|
| 904 | /* send notification */
|
|---|
| 905 | nmhdr.hwndFrom = hwnd;
|
|---|
| 906 | nmhdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
|
|---|
| 907 | nmhdr.code = SBN_SIMPLEMODECHANGE;
|
|---|
| 908 | SendMessageA (GetParent (hwnd), WM_NOTIFY, 0, (LPARAM)&nmhdr);
|
|---|
| 909 | InvalidateRect(hwnd, NULL, FALSE);
|
|---|
| 910 | return TRUE;
|
|---|
| 911 | }
|
|---|
| 912 |
|
|---|
| 913 |
|
|---|
| 914 | static LRESULT
|
|---|
| 915 | STATUSBAR_WMCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 916 | {
|
|---|
| 917 | LPCREATESTRUCTA lpCreate = (LPCREATESTRUCTA)lParam;
|
|---|
| 918 | NONCLIENTMETRICSA nclm;
|
|---|
| 919 | DWORD dwStyle;
|
|---|
| 920 | RECT rect;
|
|---|
| 921 | int width, len;
|
|---|
| 922 | HDC hdc;
|
|---|
| 923 | STATUSWINDOWINFO *infoPtr;
|
|---|
| 924 |
|
|---|
| 925 | TRACE("\n");
|
|---|
| 926 | #ifdef __WIN32OS2__
|
|---|
| 927 | infoPtr = (STATUSWINDOWINFO*)initControl(hwnd,sizeof(STATUSWINDOWINFO));
|
|---|
| 928 | #else
|
|---|
| 929 | infoPtr = (STATUSWINDOWINFO*)COMCTL32_Alloc (sizeof(STATUSWINDOWINFO));
|
|---|
| 930 | #endif
|
|---|
| 931 | SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
|
|---|
| 932 |
|
|---|
| 933 | infoPtr->hwndParent = lpCreate->hwndParent;
|
|---|
| 934 | infoPtr->numParts = 1;
|
|---|
| 935 | infoPtr->parts = 0;
|
|---|
| 936 | infoPtr->simple = FALSE;
|
|---|
| 937 | infoPtr->clrBk = CLR_DEFAULT;
|
|---|
| 938 | infoPtr->hFont = 0;
|
|---|
| 939 |
|
|---|
| 940 | /* TODO: send unicode parent notification query (WM_QUERYFORMAT) here */
|
|---|
| 941 |
|
|---|
| 942 | GetClientRect (hwnd, &rect);
|
|---|
| 943 | InvalidateRect (hwnd, &rect, 0);
|
|---|
| 944 | UpdateWindow(hwnd);
|
|---|
| 945 |
|
|---|
| 946 | nclm.cbSize = sizeof(NONCLIENTMETRICSA);
|
|---|
| 947 | SystemParametersInfoA (SPI_GETNONCLIENTMETRICS, nclm.cbSize, &nclm, 0);
|
|---|
| 948 | infoPtr->hDefaultFont = CreateFontIndirectA (&nclm.lfStatusFont);
|
|---|
| 949 |
|
|---|
| 950 | /* initialize simple case */
|
|---|
| 951 | infoPtr->part0.bound = rect;
|
|---|
| 952 | infoPtr->part0.text = 0;
|
|---|
| 953 | infoPtr->part0.x = 0;
|
|---|
| 954 | infoPtr->part0.style = 0;
|
|---|
| 955 | infoPtr->part0.hIcon = 0;
|
|---|
| 956 |
|
|---|
| 957 | /* initialize first part */
|
|---|
| 958 | infoPtr->parts = COMCTL32_Alloc (sizeof(STATUSWINDOWPART));
|
|---|
| 959 | infoPtr->parts[0].bound = rect;
|
|---|
| 960 | infoPtr->parts[0].text = 0;
|
|---|
| 961 | infoPtr->parts[0].x = -1;
|
|---|
| 962 | infoPtr->parts[0].style = 0;
|
|---|
| 963 | infoPtr->parts[0].hIcon = 0;
|
|---|
| 964 |
|
|---|
| 965 | if (IsWindowUnicode (hwnd)) {
|
|---|
| 966 | infoPtr->bUnicode = TRUE;
|
|---|
| 967 | if (lpCreate->lpszName &&
|
|---|
| 968 | (len = strlenW ((LPCWSTR)lpCreate->lpszName))) {
|
|---|
| 969 | infoPtr->parts[0].text = COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
|
|---|
| 970 | strcpyW (infoPtr->parts[0].text, (LPCWSTR)lpCreate->lpszName);
|
|---|
| 971 | }
|
|---|
| 972 | }
|
|---|
| 973 | else {
|
|---|
| 974 | if (lpCreate->lpszName &&
|
|---|
| 975 | (len = strlen((LPCSTR)lpCreate->lpszName))) {
|
|---|
| 976 | DWORD lenW = MultiByteToWideChar( CP_ACP, 0, (LPCSTR)lpCreate->lpszName, -1, NULL, 0 );
|
|---|
| 977 | infoPtr->parts[0].text = COMCTL32_Alloc (lenW*sizeof(WCHAR));
|
|---|
| 978 | MultiByteToWideChar( CP_ACP, 0, (LPCSTR)lpCreate->lpszName, -1,
|
|---|
| 979 | infoPtr->parts[0].text, lenW );
|
|---|
| 980 | }
|
|---|
| 981 | }
|
|---|
| 982 |
|
|---|
| 983 | dwStyle = GetWindowLongA(hwnd, GWL_STYLE);
|
|---|
| 984 |
|
|---|
| 985 | #ifndef __WIN32OS2__
|
|---|
| 986 | /* statusbars on managed windows should not have SIZEGRIP style */
|
|---|
| 987 | if ((dwStyle & SBARS_SIZEGRIP) && lpCreate->hwndParent)
|
|---|
| 988 | if (GetWindowLongA(lpCreate->hwndParent, GWL_EXSTYLE) & WS_EX_MANAGED)
|
|---|
| 989 | SetWindowLongA (hwnd, GWL_STYLE, dwStyle & ~SBARS_SIZEGRIP);
|
|---|
| 990 | #endif
|
|---|
| 991 | if ((hdc = GetDC (0))) {
|
|---|
| 992 | TEXTMETRICA tm;
|
|---|
| 993 | HFONT hOldFont;
|
|---|
| 994 |
|
|---|
| 995 | hOldFont = SelectObject (hdc,infoPtr->hDefaultFont);
|
|---|
| 996 | GetTextMetricsA(hdc, &tm);
|
|---|
| 997 | infoPtr->textHeight = tm.tmHeight;
|
|---|
| 998 | SelectObject (hdc, hOldFont);
|
|---|
| 999 | ReleaseDC(0, hdc);
|
|---|
| 1000 | }
|
|---|
| 1001 |
|
|---|
| 1002 | if (dwStyle & SBT_TOOLTIPS) {
|
|---|
| 1003 | infoPtr->hwndToolTip =
|
|---|
| 1004 | CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
|
|---|
| 1005 | CW_USEDEFAULT, CW_USEDEFAULT,
|
|---|
| 1006 | CW_USEDEFAULT, CW_USEDEFAULT,
|
|---|
| 1007 | hwnd, 0,
|
|---|
| 1008 | GetWindowLongA (hwnd, GWL_HINSTANCE), NULL);
|
|---|
| 1009 |
|
|---|
| 1010 | if (infoPtr->hwndToolTip) {
|
|---|
| 1011 | NMTOOLTIPSCREATED nmttc;
|
|---|
| 1012 |
|
|---|
| 1013 | nmttc.hdr.hwndFrom = hwnd;
|
|---|
| 1014 | nmttc.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
|
|---|
| 1015 | nmttc.hdr.code = NM_TOOLTIPSCREATED;
|
|---|
| 1016 | nmttc.hwndToolTips = infoPtr->hwndToolTip;
|
|---|
| 1017 |
|
|---|
| 1018 | SendMessageA (lpCreate->hwndParent, WM_NOTIFY,
|
|---|
| 1019 | (WPARAM)nmttc.hdr.idFrom, (LPARAM)&nmttc);
|
|---|
| 1020 | }
|
|---|
| 1021 | }
|
|---|
| 1022 |
|
|---|
| 1023 | if (!dwStyle & CCS_NORESIZE) /* don't resize wnd if it doesn't want it ! */
|
|---|
| 1024 | {
|
|---|
| 1025 | GetClientRect (GetParent (hwnd), &rect);
|
|---|
| 1026 | width = rect.right - rect.left;
|
|---|
| 1027 | infoPtr->height = infoPtr->textHeight + 4 + VERT_BORDER;
|
|---|
| 1028 | SetWindowPos(hwnd, 0, lpCreate->x, lpCreate->y - 1,
|
|---|
| 1029 | width, infoPtr->height, SWP_NOZORDER);
|
|---|
| 1030 | STATUSBAR_SetPartBounds (infoPtr, hwnd);
|
|---|
| 1031 | }
|
|---|
| 1032 |
|
|---|
| 1033 | return 0;
|
|---|
| 1034 | }
|
|---|
| 1035 |
|
|---|
| 1036 |
|
|---|
| 1037 | static LRESULT
|
|---|
| 1038 | STATUSBAR_WMDestroy (STATUSWINDOWINFO *infoPtr, HWND hwnd)
|
|---|
| 1039 | {
|
|---|
| 1040 | int i;
|
|---|
| 1041 |
|
|---|
| 1042 | TRACE("\n");
|
|---|
| 1043 | for (i = 0; i < infoPtr->numParts; i++) {
|
|---|
| 1044 | if (infoPtr->parts[i].text && !(infoPtr->parts[i].style & SBT_OWNERDRAW))
|
|---|
| 1045 | COMCTL32_Free (infoPtr->parts[i].text);
|
|---|
| 1046 | }
|
|---|
| 1047 | if (infoPtr->part0.text && !(infoPtr->part0.style & SBT_OWNERDRAW))
|
|---|
| 1048 | COMCTL32_Free (infoPtr->part0.text);
|
|---|
| 1049 | COMCTL32_Free (infoPtr->parts);
|
|---|
| 1050 |
|
|---|
| 1051 | /* delete default font */
|
|---|
| 1052 | if (infoPtr->hDefaultFont)
|
|---|
| 1053 | DeleteObject (infoPtr->hDefaultFont);
|
|---|
| 1054 |
|
|---|
| 1055 | /* delete tool tip control */
|
|---|
| 1056 | if (infoPtr->hwndToolTip)
|
|---|
| 1057 | DestroyWindow (infoPtr->hwndToolTip);
|
|---|
| 1058 |
|
|---|
| 1059 | COMCTL32_Free (infoPtr);
|
|---|
| 1060 | SetWindowLongA(hwnd, 0, 0);
|
|---|
| 1061 | return 0;
|
|---|
| 1062 | }
|
|---|
| 1063 |
|
|---|
| 1064 |
|
|---|
| 1065 | static inline LRESULT
|
|---|
| 1066 | STATUSBAR_WMGetFont (STATUSWINDOWINFO *infoPtr, HWND hwnd)
|
|---|
| 1067 | {
|
|---|
| 1068 | TRACE("\n");
|
|---|
| 1069 | return infoPtr->hFont? infoPtr->hFont : infoPtr->hDefaultFont;
|
|---|
| 1070 | }
|
|---|
| 1071 |
|
|---|
| 1072 |
|
|---|
| 1073 | /* in contrast to SB_GETTEXT*, WM_GETTEXT handles the text
|
|---|
| 1074 | * of the first part only (usual behaviour) */
|
|---|
| 1075 | static LRESULT
|
|---|
| 1076 | STATUSBAR_WMGetText (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 1077 | {
|
|---|
| 1078 | INT len;
|
|---|
| 1079 |
|
|---|
| 1080 | TRACE("\n");
|
|---|
| 1081 | if (!(infoPtr->parts[0].text))
|
|---|
| 1082 | return 0;
|
|---|
| 1083 | if (infoPtr->bUnicode)
|
|---|
| 1084 | len = strlenW (infoPtr->parts[0].text);
|
|---|
| 1085 | else
|
|---|
| 1086 | len = WideCharToMultiByte( CP_ACP, 0, infoPtr->parts[0].text, -1, NULL, 0, NULL, NULL )-1;
|
|---|
| 1087 |
|
|---|
| 1088 | if (wParam > len) {
|
|---|
| 1089 | if (infoPtr->bUnicode)
|
|---|
| 1090 | strcpyW ((LPWSTR)lParam, infoPtr->parts[0].text);
|
|---|
| 1091 | else
|
|---|
| 1092 | WideCharToMultiByte( CP_ACP, 0, infoPtr->parts[0].text, -1,
|
|---|
| 1093 | (LPSTR)lParam, len+1, NULL, NULL );
|
|---|
| 1094 | return len;
|
|---|
| 1095 | }
|
|---|
| 1096 |
|
|---|
| 1097 | return -1;
|
|---|
| 1098 | }
|
|---|
| 1099 |
|
|---|
| 1100 |
|
|---|
| 1101 | inline static LRESULT
|
|---|
| 1102 | STATUSBAR_WMMouseMove (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 1103 | {
|
|---|
| 1104 | if (infoPtr->hwndToolTip)
|
|---|
| 1105 | STATUSBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
|
|---|
| 1106 | WM_MOUSEMOVE, wParam, lParam);
|
|---|
| 1107 | return 0;
|
|---|
| 1108 | }
|
|---|
| 1109 |
|
|---|
| 1110 |
|
|---|
| 1111 | static LRESULT
|
|---|
| 1112 | STATUSBAR_WMNCHitTest (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 1113 | {
|
|---|
| 1114 | if (GetWindowLongA (hwnd, GWL_STYLE) & SBARS_SIZEGRIP) {
|
|---|
| 1115 | RECT rect;
|
|---|
| 1116 | POINT pt;
|
|---|
| 1117 |
|
|---|
| 1118 | GetClientRect (hwnd, &rect);
|
|---|
| 1119 |
|
|---|
| 1120 | pt.x = (INT)LOWORD(lParam);
|
|---|
| 1121 | pt.y = (INT)HIWORD(lParam);
|
|---|
| 1122 | ScreenToClient (hwnd, &pt);
|
|---|
| 1123 |
|
|---|
| 1124 | rect.left = rect.right - 13;
|
|---|
| 1125 | rect.top += 2;
|
|---|
| 1126 |
|
|---|
| 1127 | if (PtInRect (&rect, pt))
|
|---|
| 1128 | return HTBOTTOMRIGHT;
|
|---|
| 1129 | }
|
|---|
| 1130 |
|
|---|
| 1131 | /* FIXME: instead check result in StatusWindowProc and call if needed ? */
|
|---|
| 1132 | return DefWindowProcA (hwnd, WM_NCHITTEST, wParam, lParam);
|
|---|
| 1133 | }
|
|---|
| 1134 |
|
|---|
| 1135 |
|
|---|
| 1136 | static inline LRESULT
|
|---|
| 1137 | STATUSBAR_WMNCLButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 1138 | {
|
|---|
| 1139 | TRACE("\n");
|
|---|
| 1140 | PostMessageA (GetParent (hwnd), WM_NCLBUTTONDOWN, wParam, lParam);
|
|---|
| 1141 | return 0;
|
|---|
| 1142 | }
|
|---|
| 1143 |
|
|---|
| 1144 |
|
|---|
| 1145 | static inline LRESULT
|
|---|
| 1146 | STATUSBAR_WMNCLButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 1147 | {
|
|---|
| 1148 | TRACE("\n");
|
|---|
| 1149 | PostMessageA (GetParent (hwnd), WM_NCLBUTTONUP, wParam, lParam);
|
|---|
| 1150 | return 0;
|
|---|
| 1151 | }
|
|---|
| 1152 |
|
|---|
| 1153 |
|
|---|
| 1154 | static LRESULT
|
|---|
| 1155 | STATUSBAR_WMPaint (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam)
|
|---|
| 1156 | {
|
|---|
| 1157 | HDC hdc;
|
|---|
| 1158 | PAINTSTRUCT ps;
|
|---|
| 1159 |
|
|---|
| 1160 | TRACE("\n");
|
|---|
| 1161 | hdc = wParam==0 ? BeginPaint (hwnd, &ps) : (HDC)wParam;
|
|---|
| 1162 | STATUSBAR_Refresh (infoPtr, hwnd, hdc);
|
|---|
| 1163 | if (!wParam)
|
|---|
| 1164 | EndPaint (hwnd, &ps);
|
|---|
| 1165 |
|
|---|
| 1166 | return 0;
|
|---|
| 1167 | }
|
|---|
| 1168 |
|
|---|
| 1169 |
|
|---|
| 1170 | static LRESULT
|
|---|
| 1171 | STATUSBAR_WMSetFont (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 1172 | {
|
|---|
| 1173 | infoPtr->hFont = (HFONT)wParam;
|
|---|
| 1174 | TRACE("%04x\n", infoPtr->hFont);
|
|---|
| 1175 | #ifdef __WIN32OS2__
|
|---|
| 1176 | if (LOWORD(lParam) == TRUE)
|
|---|
| 1177 | {
|
|---|
| 1178 | HDC hdc = GetDC (hwnd);
|
|---|
| 1179 | TEXTMETRICA tm;
|
|---|
| 1180 | HFONT hOldFont;
|
|---|
| 1181 |
|
|---|
| 1182 | hOldFont = SelectObject(hdc,infoPtr->hFont);
|
|---|
| 1183 | GetTextMetricsA(hdc,&tm);
|
|---|
| 1184 | infoPtr->textHeight = tm.tmHeight+tm.tmExternalLeading;
|
|---|
| 1185 | SelectObject(hdc,hOldFont);
|
|---|
| 1186 |
|
|---|
| 1187 | //CB: todo: move window
|
|---|
| 1188 |
|
|---|
| 1189 | STATUSBAR_Refresh (infoPtr, hwnd, hdc);
|
|---|
| 1190 | ReleaseDC (hwnd, hdc);
|
|---|
| 1191 | }
|
|---|
| 1192 | #else
|
|---|
| 1193 | if (LOWORD(lParam) == TRUE)
|
|---|
| 1194 | InvalidateRect(hwnd, NULL, FALSE);
|
|---|
| 1195 | #endif
|
|---|
| 1196 |
|
|---|
| 1197 | return 0;
|
|---|
| 1198 | }
|
|---|
| 1199 |
|
|---|
| 1200 |
|
|---|
| 1201 | static LRESULT
|
|---|
| 1202 | STATUSBAR_WMSetText (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 1203 | {
|
|---|
| 1204 | STATUSWINDOWPART *part;
|
|---|
| 1205 | int len;
|
|---|
| 1206 |
|
|---|
| 1207 | TRACE("\n");
|
|---|
| 1208 | if (infoPtr->numParts == 0)
|
|---|
| 1209 | return FALSE;
|
|---|
| 1210 |
|
|---|
| 1211 | part = &infoPtr->parts[0];
|
|---|
| 1212 | /* duplicate string */
|
|---|
| 1213 | if (part->text)
|
|---|
| 1214 | COMCTL32_Free (part->text);
|
|---|
| 1215 | part->text = 0;
|
|---|
| 1216 | if (infoPtr->bUnicode) {
|
|---|
| 1217 | if (lParam && (len = strlenW((LPCWSTR)lParam))) {
|
|---|
| 1218 | part->text = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
|
|---|
| 1219 | strcpyW (part->text, (LPCWSTR)lParam);
|
|---|
| 1220 | }
|
|---|
| 1221 | }
|
|---|
| 1222 | else {
|
|---|
| 1223 | if (lParam && (len = lstrlenA((LPCSTR)lParam))) {
|
|---|
| 1224 | DWORD lenW = MultiByteToWideChar( CP_ACP, 0, (LPCSTR)lParam, -1, NULL, 0 );
|
|---|
| 1225 | part->text = COMCTL32_Alloc (lenW*sizeof(WCHAR));
|
|---|
| 1226 | MultiByteToWideChar( CP_ACP, 0, (LPCSTR)lParam, -1, part->text, lenW );
|
|---|
| 1227 | }
|
|---|
| 1228 | }
|
|---|
| 1229 |
|
|---|
| 1230 | InvalidateRect(hwnd, &part->bound, FALSE);
|
|---|
| 1231 |
|
|---|
| 1232 | return TRUE;
|
|---|
| 1233 | }
|
|---|
| 1234 |
|
|---|
| 1235 |
|
|---|
| 1236 | static LRESULT
|
|---|
| 1237 | STATUSBAR_WMSize (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 1238 | {
|
|---|
| 1239 | INT width, x, y, flags;
|
|---|
| 1240 | RECT parent_rect;
|
|---|
| 1241 | DWORD dwStyle;
|
|---|
| 1242 |
|
|---|
| 1243 | /* Need to resize width to match parent */
|
|---|
| 1244 | flags = (INT) wParam;
|
|---|
| 1245 |
|
|---|
| 1246 | TRACE("flags %04x\n", flags);
|
|---|
| 1247 | /* FIXME for flags =
|
|---|
| 1248 | * SIZE_MAXIMIZED, SIZE_MAXSHOW, SIZE_MINIMIZED, SIZE_RESTORED
|
|---|
| 1249 | */
|
|---|
| 1250 |
|
|---|
| 1251 | dwStyle = GetWindowLongA(hwnd, GWL_STYLE);
|
|---|
| 1252 | if (!dwStyle & CCS_NORESIZE) /* don't resize wnd if it doesn't want it ! */
|
|---|
| 1253 | {
|
|---|
| 1254 | if (flags == SIZE_RESTORED) {
|
|---|
| 1255 | /* width and height don't apply */
|
|---|
| 1256 | GetClientRect (infoPtr->hwndParent, &parent_rect);
|
|---|
| 1257 | width = parent_rect.right - parent_rect.left;
|
|---|
| 1258 | x = parent_rect.left;
|
|---|
| 1259 | y = parent_rect.bottom - infoPtr->height;
|
|---|
| 1260 | MoveWindow (hwnd, parent_rect.left,
|
|---|
| 1261 | parent_rect.bottom - infoPtr->height,
|
|---|
| 1262 | width, infoPtr->height, TRUE);
|
|---|
| 1263 | STATUSBAR_SetPartBounds (infoPtr, hwnd);
|
|---|
| 1264 | }
|
|---|
| 1265 | return 0; /* FIXME: ok to return here ? */
|
|---|
| 1266 | }
|
|---|
| 1267 |
|
|---|
| 1268 | /* FIXME: instead check result in StatusWindowProc and call if needed ? */
|
|---|
| 1269 | return DefWindowProcA (hwnd, WM_SIZE, wParam, lParam);
|
|---|
| 1270 | }
|
|---|
| 1271 |
|
|---|
| 1272 |
|
|---|
| 1273 | static LRESULT
|
|---|
| 1274 | STATUSBAR_SendNotify (HWND hwnd, UINT code)
|
|---|
| 1275 | {
|
|---|
| 1276 | NMHDR nmhdr;
|
|---|
| 1277 |
|
|---|
| 1278 | TRACE("code %04x\n", code);
|
|---|
| 1279 | nmhdr.hwndFrom = hwnd;
|
|---|
| 1280 | nmhdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
|
|---|
| 1281 | nmhdr.code = code;
|
|---|
| 1282 | SendMessageA (GetParent (hwnd), WM_NOTIFY, 0, (LPARAM)&nmhdr);
|
|---|
| 1283 | return 0;
|
|---|
| 1284 | }
|
|---|
| 1285 |
|
|---|
| 1286 |
|
|---|
| 1287 |
|
|---|
| 1288 | static LRESULT WINAPI
|
|---|
| 1289 | StatusWindowProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|---|
| 1290 | {
|
|---|
| 1291 | STATUSWINDOWINFO *infoPtr = STATUSBAR_GetInfoPtr(hwnd);
|
|---|
| 1292 |
|
|---|
| 1293 | TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n", hwnd, msg, wParam, lParam);
|
|---|
| 1294 | if (!(infoPtr) && (msg != WM_CREATE))
|
|---|
| 1295 | return DefWindowProcA (hwnd, msg, wParam, lParam);
|
|---|
| 1296 |
|
|---|
| 1297 | switch (msg) {
|
|---|
| 1298 | case SB_GETBORDERS:
|
|---|
| 1299 | return STATUSBAR_GetBorders (lParam);
|
|---|
| 1300 |
|
|---|
| 1301 | case SB_GETICON:
|
|---|
| 1302 | return STATUSBAR_GetIcon (infoPtr, hwnd, wParam);
|
|---|
| 1303 |
|
|---|
| 1304 | case SB_GETPARTS:
|
|---|
| 1305 | return STATUSBAR_GetParts (infoPtr, hwnd, wParam, lParam);
|
|---|
| 1306 |
|
|---|
| 1307 | case SB_GETRECT:
|
|---|
| 1308 | return STATUSBAR_GetRect (infoPtr, hwnd, wParam, lParam);
|
|---|
| 1309 |
|
|---|
| 1310 | case SB_GETTEXTA:
|
|---|
| 1311 | return STATUSBAR_GetTextA (infoPtr, hwnd, wParam, lParam);
|
|---|
| 1312 |
|
|---|
| 1313 | case SB_GETTEXTW:
|
|---|
| 1314 | return STATUSBAR_GetTextW (infoPtr, hwnd, wParam, lParam);
|
|---|
| 1315 |
|
|---|
| 1316 | case SB_GETTEXTLENGTHA:
|
|---|
| 1317 | case SB_GETTEXTLENGTHW:
|
|---|
| 1318 | return STATUSBAR_GetTextLength (infoPtr, hwnd, wParam);
|
|---|
| 1319 |
|
|---|
| 1320 | case SB_GETTIPTEXTA:
|
|---|
| 1321 | return STATUSBAR_GetTipTextA (infoPtr, hwnd, wParam, lParam);
|
|---|
| 1322 |
|
|---|
| 1323 | case SB_GETTIPTEXTW:
|
|---|
| 1324 | return STATUSBAR_GetTipTextW (infoPtr, hwnd, wParam, lParam);
|
|---|
| 1325 |
|
|---|
| 1326 | case SB_GETUNICODEFORMAT:
|
|---|
| 1327 | return STATUSBAR_GetUnicodeFormat (infoPtr, hwnd);
|
|---|
| 1328 |
|
|---|
| 1329 | case SB_ISSIMPLE:
|
|---|
| 1330 | return STATUSBAR_IsSimple (infoPtr, hwnd);
|
|---|
| 1331 |
|
|---|
| 1332 | case SB_SETBKCOLOR:
|
|---|
| 1333 | return STATUSBAR_SetBkColor (infoPtr, hwnd, wParam, lParam);
|
|---|
| 1334 |
|
|---|
| 1335 | case SB_SETICON:
|
|---|
| 1336 | return STATUSBAR_SetIcon (infoPtr, hwnd, wParam, lParam);
|
|---|
| 1337 |
|
|---|
| 1338 | case SB_SETMINHEIGHT:
|
|---|
| 1339 | return STATUSBAR_SetMinHeight (infoPtr, hwnd, wParam, lParam);
|
|---|
| 1340 |
|
|---|
| 1341 | case SB_SETPARTS:
|
|---|
| 1342 | return STATUSBAR_SetParts (infoPtr, hwnd, wParam, lParam);
|
|---|
| 1343 |
|
|---|
| 1344 | case SB_SETTEXTA:
|
|---|
| 1345 | return STATUSBAR_SetTextA (infoPtr, hwnd, wParam, lParam);
|
|---|
| 1346 |
|
|---|
| 1347 | case SB_SETTEXTW:
|
|---|
| 1348 | return STATUSBAR_SetTextW (infoPtr, hwnd, wParam, lParam);
|
|---|
| 1349 |
|
|---|
| 1350 | case SB_SETTIPTEXTA:
|
|---|
| 1351 | return STATUSBAR_SetTipTextA (infoPtr, hwnd, wParam, lParam);
|
|---|
| 1352 |
|
|---|
| 1353 | case SB_SETTIPTEXTW:
|
|---|
| 1354 | return STATUSBAR_SetTipTextW (infoPtr, hwnd, wParam, lParam);
|
|---|
| 1355 |
|
|---|
| 1356 | case SB_SETUNICODEFORMAT:
|
|---|
| 1357 | return STATUSBAR_SetUnicodeFormat (infoPtr, hwnd, wParam);
|
|---|
| 1358 |
|
|---|
| 1359 | case SB_SIMPLE:
|
|---|
| 1360 | return STATUSBAR_Simple (infoPtr, hwnd, wParam, lParam);
|
|---|
| 1361 |
|
|---|
| 1362 |
|
|---|
| 1363 | case WM_CREATE:
|
|---|
| 1364 | return STATUSBAR_WMCreate (hwnd, wParam, lParam);
|
|---|
| 1365 |
|
|---|
| 1366 | case WM_DESTROY:
|
|---|
| 1367 | return STATUSBAR_WMDestroy (infoPtr, hwnd);
|
|---|
| 1368 |
|
|---|
| 1369 | case WM_GETFONT:
|
|---|
| 1370 | return STATUSBAR_WMGetFont (infoPtr, hwnd);
|
|---|
| 1371 |
|
|---|
| 1372 | case WM_GETTEXT:
|
|---|
| 1373 | return STATUSBAR_WMGetText (infoPtr, hwnd, wParam, lParam);
|
|---|
| 1374 |
|
|---|
| 1375 | case WM_GETTEXTLENGTH:
|
|---|
| 1376 | return STATUSBAR_GetTextLength (infoPtr, hwnd, 0);
|
|---|
| 1377 |
|
|---|
| 1378 | case WM_LBUTTONDBLCLK:
|
|---|
| 1379 | return STATUSBAR_SendNotify (hwnd, NM_DBLCLK);
|
|---|
| 1380 |
|
|---|
| 1381 | case WM_LBUTTONUP:
|
|---|
| 1382 | return STATUSBAR_SendNotify (hwnd, NM_CLICK);
|
|---|
| 1383 |
|
|---|
| 1384 | case WM_MOUSEMOVE:
|
|---|
| 1385 | return STATUSBAR_WMMouseMove (infoPtr, hwnd, wParam, lParam);
|
|---|
| 1386 |
|
|---|
| 1387 | case WM_NCHITTEST:
|
|---|
| 1388 | return STATUSBAR_WMNCHitTest (hwnd, wParam, lParam);
|
|---|
| 1389 |
|
|---|
| 1390 | case WM_NCLBUTTONDOWN:
|
|---|
| 1391 | return STATUSBAR_WMNCLButtonDown (hwnd, wParam, lParam);
|
|---|
| 1392 |
|
|---|
| 1393 | case WM_NCLBUTTONUP:
|
|---|
| 1394 | return STATUSBAR_WMNCLButtonUp (hwnd, wParam, lParam);
|
|---|
| 1395 |
|
|---|
| 1396 | case WM_PAINT:
|
|---|
| 1397 | return STATUSBAR_WMPaint (infoPtr, hwnd, wParam);
|
|---|
| 1398 |
|
|---|
| 1399 | case WM_RBUTTONDBLCLK:
|
|---|
| 1400 | return STATUSBAR_SendNotify (hwnd, NM_RDBLCLK);
|
|---|
| 1401 |
|
|---|
| 1402 | case WM_RBUTTONUP:
|
|---|
| 1403 | return STATUSBAR_SendNotify (hwnd, NM_RCLICK);
|
|---|
| 1404 |
|
|---|
| 1405 | case WM_SETFONT:
|
|---|
| 1406 | return STATUSBAR_WMSetFont (infoPtr, hwnd, wParam, lParam);
|
|---|
| 1407 |
|
|---|
| 1408 | case WM_SETTEXT:
|
|---|
| 1409 | return STATUSBAR_WMSetText (infoPtr, hwnd, wParam, lParam);
|
|---|
| 1410 |
|
|---|
| 1411 | case WM_SIZE:
|
|---|
| 1412 | return STATUSBAR_WMSize (infoPtr, hwnd, wParam, lParam);
|
|---|
| 1413 |
|
|---|
| 1414 | default:
|
|---|
| 1415 | if (msg >= WM_USER)
|
|---|
| 1416 | ERR("unknown msg %04x wp=%04x lp=%08lx\n",
|
|---|
| 1417 | msg, wParam, lParam);
|
|---|
| 1418 | #ifdef __WIN32OS2__
|
|---|
| 1419 | return defComCtl32ProcA (hwnd, msg, wParam, lParam);
|
|---|
| 1420 | #else
|
|---|
| 1421 | return DefWindowProcA (hwnd, msg, wParam, lParam);
|
|---|
| 1422 | #endif
|
|---|
| 1423 | }
|
|---|
| 1424 | return 0;
|
|---|
| 1425 | }
|
|---|
| 1426 |
|
|---|
| 1427 |
|
|---|
| 1428 | /***********************************************************************
|
|---|
| 1429 | * STATUS_Register [Internal]
|
|---|
| 1430 | *
|
|---|
| 1431 | * Registers the status window class.
|
|---|
| 1432 | */
|
|---|
| 1433 |
|
|---|
| 1434 | VOID
|
|---|
| 1435 | STATUS_Register (void)
|
|---|
| 1436 | {
|
|---|
| 1437 | WNDCLASSA wndClass;
|
|---|
| 1438 |
|
|---|
| 1439 | ZeroMemory (&wndClass, sizeof(WNDCLASSA));
|
|---|
| 1440 | wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS | CS_VREDRAW;
|
|---|
| 1441 | wndClass.lpfnWndProc = (WNDPROC)StatusWindowProc;
|
|---|
| 1442 | wndClass.cbClsExtra = 0;
|
|---|
| 1443 | wndClass.cbWndExtra = sizeof(STATUSWINDOWINFO *);
|
|---|
| 1444 | wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
|
|---|
| 1445 | wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
|
|---|
| 1446 | wndClass.lpszClassName = STATUSCLASSNAMEA;
|
|---|
| 1447 |
|
|---|
| 1448 | RegisterClassA (&wndClass);
|
|---|
| 1449 | }
|
|---|
| 1450 |
|
|---|
| 1451 |
|
|---|
| 1452 | /***********************************************************************
|
|---|
| 1453 | * STATUS_Unregister [Internal]
|
|---|
| 1454 | *
|
|---|
| 1455 | * Unregisters the status window class.
|
|---|
| 1456 | */
|
|---|
| 1457 |
|
|---|
| 1458 | VOID
|
|---|
| 1459 | STATUS_Unregister (void)
|
|---|
| 1460 | {
|
|---|
| 1461 | UnregisterClassA (STATUSCLASSNAMEA, (HINSTANCE)NULL);
|
|---|
| 1462 | }
|
|---|
| 1463 |
|
|---|