source: trunk/src/comctl32/status.c

Last change on this file was 10535, checked in by sandervl, 22 years ago

Wine merge + status & rebar fixes

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