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