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