2 * Interface code to StatusWindow widget/control
4 * Copyright 1996 Bruce Milner
5 * Copyright 1998, 1999 Eric Kohl
13 DEFAULT_DEBUG_CHANNEL(statusbar)
16 * Run tests using Waite Group Windows95 API Bible Vol. 1&2
17 * The second cdrom contains executables drawstat.exe,gettext.exe,
18 * simple.exe, getparts.exe, setparts.exe, statwnd.exe
23 * 1) Don't hard code bar to bottom of window, allow CCS_TOP also.
24 * 2) Tooltip support (almost done).
27 #define _MAX(a,b) (((a)>(b))?(a):(b))
28 #define _MIN(a,b) (((a)>(b))?(b):(a))
34 #define STATUSBAR_GetInfoPtr(hwnd) ((STATUSWINDOWINFO *)GetWindowLongA (hwnd, 0))
38 STATUSBAR_DrawSizeGrip (HDC hdc, LPRECT lpRect)
44 pt.x = lpRect->right - 1;
45 pt.y = lpRect->bottom - 1;
47 hOldPen = SelectObject (hdc, GetSysColorPen (COLOR_3DFACE));
48 MoveToEx (hdc, pt.x - 12, pt.y, NULL);
49 LineTo (hdc, pt.x, pt.y);
50 LineTo (hdc, pt.x, pt.y - 12);
55 SelectObject (hdc, GetSysColorPen (COLOR_3DSHADOW));
56 for (i = 1; i < 11; i += 4) {
57 MoveToEx (hdc, pt.x - i, pt.y, NULL);
58 LineTo (hdc, pt.x, pt.y - i);
60 MoveToEx (hdc, pt.x - i-1, pt.y, NULL);
61 LineTo (hdc, pt.x, pt.y - i-1);
64 SelectObject (hdc, GetSysColorPen (COLOR_3DHIGHLIGHT));
65 for (i = 3; i < 13; i += 4) {
66 MoveToEx (hdc, pt.x - i, pt.y, NULL);
67 LineTo (hdc, pt.x, pt.y - i);
70 SelectObject (hdc, hOldPen);
75 STATUSBAR_DrawPart (HDC hdc, STATUSWINDOWPART *part)
78 UINT border = BDR_SUNKENOUTER;
80 if (part->style==SBT_POPOUT)
81 border = BDR_RAISEDOUTER;
82 else if (part->style==SBT_NOBORDERS)
85 DrawEdge(hdc, &r, border, BF_RECT|BF_ADJUST);
89 INT cy = r.bottom - r.top;
92 DrawIconEx (hdc, r.left, r.top, part->hIcon, cy, cy, 0, 0, DI_NORMAL);
98 int oldbkmode = SetBkMode(hdc, TRANSPARENT);
99 LPWSTR p = (LPWSTR)part->text;
100 UINT align = DT_LEFT;
111 DrawTextW (hdc, p, lstrlenW (p), &r, align|DT_VCENTER|DT_SINGLELINE);
112 if (oldbkmode != TRANSPARENT)
113 SetBkMode(hdc, oldbkmode);
119 STATUSBAR_RefreshPart (HWND hwnd, STATUSWINDOWPART *part, HDC hdc)
121 STATUSWINDOWINFO *self = STATUSBAR_GetInfoPtr (hwnd);
125 if (!IsWindowVisible (hwnd))
128 if (self->clrBk != CLR_DEFAULT)
129 hbrBk = CreateSolidBrush (self->clrBk);
131 hbrBk = GetSysColorBrush (COLOR_3DFACE);
132 FillRect(hdc, &part->bound, hbrBk);
134 hOldFont = SelectObject (hdc, self->hFont ? self->hFont : self->hDefaultFont);
136 if (part->style == SBT_OWNERDRAW) {
139 dis.CtlID = GetWindowLongA (hwnd, GWL_ID);
143 dis.rcItem = part->bound;
144 dis.itemData = (INT)part->text;
145 SendMessageA (GetParent (hwnd), WM_DRAWITEM,
146 (WPARAM)dis.CtlID, (LPARAM)&dis);
149 STATUSBAR_DrawPart (hdc, part);
151 SelectObject (hdc, hOldFont);
153 if (self->clrBk != CLR_DEFAULT)
154 DeleteObject (hbrBk);
156 if (GetWindowLongA (hwnd, GWL_STYLE) & SBARS_SIZEGRIP) {
159 GetClientRect (hwnd, &rect);
160 STATUSBAR_DrawSizeGrip (hdc, &rect);
166 STATUSBAR_Refresh (HWND hwnd, HDC hdc)
168 STATUSWINDOWINFO *infoPtr = STATUSBAR_GetInfoPtr (hwnd);
174 if (!IsWindowVisible(hwnd))
177 GetClientRect (hwnd, &rect);
179 if (infoPtr->clrBk != CLR_DEFAULT)
180 hbrBk = CreateSolidBrush (infoPtr->clrBk);
182 hbrBk = GetSysColorBrush (COLOR_3DFACE);
183 FillRect(hdc, &rect, hbrBk);
185 hOldFont = SelectObject (hdc, infoPtr->hFont ? infoPtr->hFont : infoPtr->hDefaultFont);
187 if (infoPtr->simple) {
188 STATUSBAR_DrawPart (hdc, &infoPtr->part0);
191 for (i = 0; i < infoPtr->numParts; i++) {
192 if (infoPtr->parts[i].style == SBT_OWNERDRAW) {
195 dis.CtlID = GetWindowLongA (hwnd, GWL_ID);
199 dis.rcItem = infoPtr->parts[i].bound;
200 dis.itemData = (INT)infoPtr->parts[i].text;
201 SendMessageA (GetParent (hwnd), WM_DRAWITEM,
202 (WPARAM)dis.CtlID, (LPARAM)&dis);
205 STATUSBAR_DrawPart (hdc, &infoPtr->parts[i]);
209 SelectObject (hdc, hOldFont);
211 if (infoPtr->clrBk != CLR_DEFAULT)
212 DeleteObject (hbrBk);
214 if (GetWindowLongA(hwnd, GWL_STYLE) & SBARS_SIZEGRIP)
215 STATUSBAR_DrawSizeGrip (hdc, &rect);
222 STATUSBAR_SetPartBounds (HWND hwnd)
224 STATUSWINDOWINFO *self = STATUSBAR_GetInfoPtr (hwnd);
225 STATUSWINDOWPART *part;
229 /* get our window size */
230 GetClientRect (hwnd, &rect);
232 rect.top += VERT_BORDER;
234 /* set bounds for simple rectangle */
235 self->part0.bound = rect;
237 /* set bounds for non-simple rectangles */
238 for (i = 0; i < self->numParts; i++) {
239 part = &self->parts[i];
240 r = &self->parts[i].bound;
242 r->bottom = rect.bottom;
246 r->left = self->parts[i-1].bound.right + HORZ_GAP;
248 r->right = rect.right;
252 if (self->hwndToolTip) {
255 ti.cbSize = sizeof(TTTOOLINFOA);
259 SendMessageA (self->hwndToolTip, TTM_NEWTOOLRECTA,
267 STATUSBAR_RelayEvent (HWND hwndTip, HWND hwndMsg, UINT uMsg,
268 WPARAM wParam, LPARAM lParam)
276 msg.time = GetMessageTime ();
277 msg.pt.x = LOWORD(GetMessagePos ());
278 msg.pt.y = HIWORD(GetMessagePos ());
280 SendMessageA (hwndTip, TTM_RELAYEVENT, 0, (LPARAM)&msg);
284 __inline__ static LRESULT
285 STATUSBAR_GetBorders (LPARAM lParam)
287 LPINT out = (LPINT) lParam;
289 out[0] = HORZ_BORDER; /* horizontal border width */
290 out[1] = VERT_BORDER; /* vertical border width */
291 out[2] = HORZ_GAP; /* width of border between rectangles */
298 STATUSBAR_GetIcon (HWND hwnd, WPARAM wParam)
300 STATUSWINDOWINFO *self = STATUSBAR_GetInfoPtr (hwnd);
303 nPart = (INT)wParam & 0x00ff;
304 if ((nPart < -1) || (nPart >= self->numParts))
308 return (self->part0.hIcon);
310 return (self->parts[nPart].hIcon);
315 STATUSBAR_GetParts (HWND hwnd, WPARAM wParam, LPARAM lParam)
317 STATUSWINDOWINFO *infoPtr = STATUSBAR_GetInfoPtr (hwnd);
322 num_parts = (INT) wParam;
323 parts = (LPINT) lParam;
325 return (infoPtr->numParts);
326 for (i = 0; i < num_parts; i++) {
327 parts[i] = infoPtr->parts[i].x;
330 return (infoPtr->numParts);
335 STATUSBAR_GetRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
337 STATUSWINDOWINFO *infoPtr = STATUSBAR_GetInfoPtr (hwnd);
341 part_num = ((INT) wParam) & 0x00ff;
342 rect = (LPRECT) lParam;
344 *rect = infoPtr->part0.bound;
346 *rect = infoPtr->parts[part_num].bound;
352 STATUSBAR_GetTextA (HWND hwnd, WPARAM wParam, LPARAM lParam)
354 STATUSWINDOWINFO *self = STATUSBAR_GetInfoPtr (hwnd);
355 STATUSWINDOWPART *part;
359 nPart = ((INT) wParam) & 0x00ff;
363 part = &self->parts[nPart];
365 if (part->style == SBT_OWNERDRAW)
366 result = (LRESULT)part->text;
368 result = part->text ? lstrlenW (part->text) : 0;
369 result |= (part->style << 16);
370 if (lParam && LOWORD(result))
371 lstrcpyWtoA ((LPSTR)lParam, part->text);
378 STATUSBAR_GetTextW (HWND hwnd, WPARAM wParam, LPARAM lParam)
380 STATUSWINDOWINFO *infoPtr = STATUSBAR_GetInfoPtr (hwnd);
381 STATUSWINDOWPART *part;
385 nPart = ((INT)wParam) & 0x00ff;
387 part = &infoPtr->part0;
389 part = &infoPtr->parts[nPart];
391 if (part->style == SBT_OWNERDRAW)
392 result = (LRESULT)part->text;
394 result = part->text ? lstrlenW (part->text) : 0;
395 result |= (part->style << 16);
397 lstrcpyW ((LPWSTR)lParam, part->text);
404 STATUSBAR_GetTextLength (HWND hwnd, WPARAM wParam)
406 STATUSWINDOWINFO *infoPtr = STATUSBAR_GetInfoPtr (hwnd);
407 STATUSWINDOWPART *part;
411 part_num = ((INT) wParam) & 0x00ff;
414 part = &infoPtr->part0;
416 part = &infoPtr->parts[part_num];
419 result = lstrlenW(part->text);
423 result |= (part->style << 16);
429 STATUSBAR_GetTipTextA (HWND hwnd, WPARAM wParam, LPARAM lParam)
431 STATUSWINDOWINFO *infoPtr = STATUSBAR_GetInfoPtr (hwnd);
433 if (infoPtr->hwndToolTip) {
435 ti.cbSize = sizeof(TTTOOLINFOA);
437 ti.uId = LOWORD(wParam);
438 SendMessageA (infoPtr->hwndToolTip, TTM_GETTEXTA, 0, (LPARAM)&ti);
441 lstrcpynA ((LPSTR)lParam, ti.lpszText, HIWORD(wParam));
449 STATUSBAR_GetTipTextW (HWND hwnd, WPARAM wParam, LPARAM lParam)
451 STATUSWINDOWINFO *infoPtr = STATUSBAR_GetInfoPtr (hwnd);
453 if (infoPtr->hwndToolTip) {
455 ti.cbSize = sizeof(TTTOOLINFOW);
457 ti.uId = LOWORD(wParam);
458 SendMessageW (infoPtr->hwndToolTip, TTM_GETTEXTW, 0, (LPARAM)&ti);
461 lstrcpynW ((LPWSTR)lParam, ti.lpszText, HIWORD(wParam));
468 __inline__ static LRESULT
469 STATUSBAR_GetUnicodeFormat (HWND hwnd)
471 STATUSWINDOWINFO *infoPtr = STATUSBAR_GetInfoPtr (hwnd);
472 return infoPtr->bUnicode;
476 __inline__ static LRESULT
477 STATUSBAR_IsSimple (HWND hwnd)
479 STATUSWINDOWINFO *infoPtr = STATUSBAR_GetInfoPtr (hwnd);
480 return infoPtr->simple;
485 STATUSBAR_SetBkColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
487 STATUSWINDOWINFO *self = STATUSBAR_GetInfoPtr (hwnd);
491 oldBkColor = self->clrBk;
492 self->clrBk = (COLORREF)lParam;
494 STATUSBAR_Refresh (hwnd, hdc);
495 ReleaseDC (hwnd, hdc);
502 STATUSBAR_SetIcon (HWND hwnd, WPARAM wParam, LPARAM lParam)
504 STATUSWINDOWINFO *self = STATUSBAR_GetInfoPtr (hwnd);
505 INT nPart = (INT)wParam & 0x00ff;
508 if ((nPart < -1) || (nPart >= self->numParts))
513 self->part0.hIcon = (HICON)lParam;
515 STATUSBAR_RefreshPart (hwnd, &self->part0, hdc);
518 self->parts[nPart].hIcon = (HICON)lParam;
520 STATUSBAR_RefreshPart (hwnd, &self->parts[nPart], hdc);
522 ReleaseDC (hwnd, hdc);
529 STATUSBAR_SetMinHeight (HWND hwnd, WPARAM wParam, LPARAM lParam)
531 STATUSWINDOWINFO *self = STATUSBAR_GetInfoPtr (hwnd);
533 if (IsWindowVisible (hwnd)) {
534 HWND parent = GetParent (hwnd);
538 GetClientRect (parent, &parent_rect);
539 self->height = (INT)wParam + VERT_BORDER;
540 width = parent_rect.right - parent_rect.left;
541 x = parent_rect.left;
542 y = parent_rect.bottom - self->height;
543 MoveWindow (hwnd, parent_rect.left,
544 parent_rect.bottom - self->height,
545 width, self->height, TRUE);
546 STATUSBAR_SetPartBounds (hwnd);
554 STATUSBAR_SetParts (HWND hwnd, WPARAM wParam, LPARAM lParam)
556 STATUSWINDOWINFO *self = STATUSBAR_GetInfoPtr (hwnd);
557 STATUSWINDOWPART *tmp;
564 self->simple = FALSE;
566 oldNumParts = self->numParts;
567 self->numParts = (INT) wParam;
568 parts = (LPINT) lParam;
569 if (oldNumParts > self->numParts) {
570 for (i = self->numParts ; i < oldNumParts; i++) {
571 if (self->parts[i].text && (self->parts[i].style != SBT_OWNERDRAW))
572 COMCTL32_Free (self->parts[i].text);
575 else if (oldNumParts < self->numParts) {
576 tmp = COMCTL32_Alloc (sizeof(STATUSWINDOWPART) * self->numParts);
577 for (i = 0; i < oldNumParts; i++) {
578 tmp[i] = self->parts[i];
581 COMCTL32_Free (self->parts);
585 for (i = 0; i < self->numParts; i++) {
586 self->parts[i].x = parts[i];
589 if (self->hwndToolTip) {
591 SendMessageA (self->hwndToolTip, TTM_GETTOOLCOUNT, 0, 0);
593 if (nTipCount < self->numParts) {
598 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
599 ti.cbSize = sizeof(TTTOOLINFOA);
601 for (i = nTipCount; i < self->numParts; i++) {
602 TRACE (statusbar, "add tool %d\n", i);
604 SendMessageA (self->hwndToolTip, TTM_ADDTOOLA,
608 else if (nTipCount > self->numParts) {
612 for (i = nTipCount - 1; i >= self->numParts; i--) {
614 FIXME (statusbar, "delete tool %d\n", i);
620 STATUSBAR_SetPartBounds (hwnd);
623 STATUSBAR_Refresh (hwnd, hdc);
624 ReleaseDC (hwnd, hdc);
631 STATUSBAR_SetTextA (HWND hwnd, WPARAM wParam, LPARAM lParam)
633 STATUSWINDOWINFO *self = STATUSBAR_GetInfoPtr (hwnd);
634 STATUSWINDOWPART *part;
641 text = (LPSTR) lParam;
642 part_num = ((INT) wParam) & 0x00ff;
643 style = ((INT) wParam) & 0xff00;
645 if ((self->simple) || (self->parts==NULL) || (part_num==255))
648 part = &self->parts[part_num];
649 if (!part) return FALSE;
651 if (style == SBT_OWNERDRAW) {
652 part->text = (LPWSTR)text;
655 /* duplicate string */
657 COMCTL32_Free (part->text);
659 if (text && (len = lstrlenA(text))) {
660 part->text = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
661 lstrcpyAtoW (part->text, text);
666 STATUSBAR_RefreshPart (hwnd, part, hdc);
667 ReleaseDC (hwnd, hdc);
674 STATUSBAR_SetTextW (HWND hwnd, WPARAM wParam, LPARAM lParam)
676 STATUSWINDOWINFO *self = STATUSBAR_GetInfoPtr (hwnd);
677 STATUSWINDOWPART *part;
678 INT part_num, style, len;
682 text = (LPWSTR) lParam;
683 part_num = ((INT) wParam) & 0x00ff;
684 style = ((INT) wParam) & 0xff00;
686 if ((self->simple) || (self->parts==NULL) || (part_num==255))
689 part = &self->parts[part_num];
690 if (!part) return FALSE;
692 if (style == SBT_OWNERDRAW) {
696 /* duplicate string */
698 COMCTL32_Free (part->text);
700 if (text && (len = lstrlenW(text))) {
701 part->text = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
702 lstrcpyW(part->text, text);
707 STATUSBAR_RefreshPart (hwnd, part, hdc);
708 ReleaseDC (hwnd, hdc);
715 STATUSBAR_SetTipTextA (HWND hwnd, WPARAM wParam, LPARAM lParam)
717 STATUSWINDOWINFO *infoPtr = STATUSBAR_GetInfoPtr (hwnd);
719 TRACE (statusbar, "part %d: \"%s\"\n", (INT)wParam, (LPSTR)lParam);
720 if (infoPtr->hwndToolTip) {
722 ti.cbSize = sizeof(TTTOOLINFOA);
724 ti.uId = (INT)wParam;
726 ti.lpszText = (LPSTR)lParam;
727 SendMessageA (infoPtr->hwndToolTip, TTM_UPDATETIPTEXTA,
736 STATUSBAR_SetTipTextW (HWND hwnd, WPARAM wParam, LPARAM lParam)
738 STATUSWINDOWINFO *infoPtr = STATUSBAR_GetInfoPtr (hwnd);
740 TRACE (statusbar, "part %d: \"%s\"\n", (INT)wParam, (LPSTR)lParam);
741 if (infoPtr->hwndToolTip) {
743 ti.cbSize = sizeof(TTTOOLINFOW);
745 ti.uId = (INT)wParam;
747 ti.lpszText = (LPWSTR)lParam;
748 SendMessageW (infoPtr->hwndToolTip, TTM_UPDATETIPTEXTW,
756 __inline__ static LRESULT
757 STATUSBAR_SetUnicodeFormat (HWND hwnd, WPARAM wParam)
759 STATUSWINDOWINFO *infoPtr = STATUSBAR_GetInfoPtr (hwnd);
760 BOOL bTemp = infoPtr->bUnicode;
762 TRACE (statusbar, "(0x%x)\n", (BOOL)wParam);
763 infoPtr->bUnicode = (BOOL)wParam;
770 STATUSBAR_Simple (HWND hwnd, WPARAM wParam, LPARAM lParam)
772 STATUSWINDOWINFO *infoPtr = STATUSBAR_GetInfoPtr (hwnd);
776 infoPtr->simple = (BOOL)wParam;
778 /* send notification */
779 nmhdr.hwndFrom = hwnd;
780 nmhdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
781 nmhdr.code = SBN_SIMPLEMODECHANGE;
782 SendMessageA (GetParent (hwnd), WM_NOTIFY, 0, (LPARAM)&nmhdr);
785 STATUSBAR_Refresh (hwnd, hdc);
786 ReleaseDC (hwnd, hdc);
793 STATUSBAR_WMCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
795 LPCREATESTRUCTA lpCreate = (LPCREATESTRUCTA)lParam;
796 NONCLIENTMETRICSA nclm;
800 STATUSWINDOWINFO *self;
802 self = (STATUSWINDOWINFO*)COMCTL32_Alloc (sizeof(STATUSWINDOWINFO));
803 SetWindowLongA (hwnd, 0, (DWORD)self);
807 self->simple = FALSE;
808 self->clrBk = CLR_DEFAULT;
810 GetClientRect (hwnd, &rect);
812 nclm.cbSize = sizeof(NONCLIENTMETRICSA);
813 SystemParametersInfoA (SPI_GETNONCLIENTMETRICS, 0, &nclm, 0);
814 self->hDefaultFont = CreateFontIndirectA (&nclm.lfStatusFont);
816 /* initialize simple case */
817 self->part0.bound = rect;
818 self->part0.text = 0;
820 self->part0.style = 0;
821 self->part0.hIcon = 0;
823 /* initialize first part */
824 self->parts = COMCTL32_Alloc (sizeof(STATUSWINDOWPART));
825 self->parts[0].bound = rect;
826 self->parts[0].text = 0;
827 self->parts[0].x = -1;
828 self->parts[0].style = 0;
829 self->parts[0].hIcon = 0;
831 if (IsWindowUnicode (hwnd)) {
832 self->bUnicode = TRUE;
833 if ((len = lstrlenW ((LPCWSTR)lpCreate->lpszName))) {
834 self->parts[0].text = COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
835 lstrcpyW (self->parts[0].text, (LPCWSTR)lpCreate->lpszName);
839 if ((len = lstrlenA ((LPCSTR)lpCreate->lpszName))) {
840 self->parts[0].text = COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
841 lstrcpyAtoW (self->parts[0].text, (LPCSTR)lpCreate->lpszName);
845 if ((hdc = GetDC (0))) {
849 hOldFont = SelectObject (hdc,self->hDefaultFont);
850 GetTextMetricsA(hdc, &tm);
851 self->textHeight = tm.tmHeight;
852 SelectObject (hdc, hOldFont);
856 if (GetWindowLongA (hwnd, GWL_STYLE) & SBT_TOOLTIPS) {
858 CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
859 CW_USEDEFAULT, CW_USEDEFAULT,
860 CW_USEDEFAULT, CW_USEDEFAULT,
862 GetWindowLongA (hwnd, GWL_HINSTANCE), NULL);
864 if (self->hwndToolTip) {
865 NMTOOLTIPSCREATED nmttc;
867 nmttc.hdr.hwndFrom = hwnd;
868 nmttc.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
869 nmttc.hdr.code = NM_TOOLTIPSCREATED;
870 nmttc.hwndToolTips = self->hwndToolTip;
872 SendMessageA (GetParent (hwnd), WM_NOTIFY,
873 (WPARAM)nmttc.hdr.idFrom, (LPARAM)&nmttc);
877 GetClientRect (GetParent (hwnd), &rect);
878 width = rect.right - rect.left;
879 self->height = self->textHeight + 4 + VERT_BORDER;
880 MoveWindow (hwnd, lpCreate->x, lpCreate->y-1,
881 width, self->height, FALSE);
882 STATUSBAR_SetPartBounds (hwnd);
889 STATUSBAR_WMDestroy (HWND hwnd)
891 STATUSWINDOWINFO *self = STATUSBAR_GetInfoPtr (hwnd);
894 for (i = 0; i < self->numParts; i++) {
895 if (self->parts[i].text && (self->parts[i].style != SBT_OWNERDRAW))
896 COMCTL32_Free (self->parts[i].text);
898 if (self->part0.text && (self->part0.style != SBT_OWNERDRAW))
899 COMCTL32_Free (self->part0.text);
900 COMCTL32_Free (self->parts);
902 /* delete default font */
903 if (self->hDefaultFont)
904 DeleteObject (self->hDefaultFont);
906 /* delete tool tip control */
907 if (self->hwndToolTip)
908 DestroyWindow (self->hwndToolTip);
910 COMCTL32_Free (self);
916 static __inline__ LRESULT
917 STATUSBAR_WMGetFont (HWND hwnd)
919 STATUSWINDOWINFO *infoPtr = STATUSBAR_GetInfoPtr (hwnd);
920 return infoPtr->hFont;
925 STATUSBAR_WMGetText (HWND hwnd, WPARAM wParam, LPARAM lParam)
927 STATUSWINDOWINFO *infoPtr = STATUSBAR_GetInfoPtr (hwnd);
930 if (!(infoPtr->parts[0].text))
932 len = lstrlenW (infoPtr->parts[0].text);
934 if (infoPtr->bUnicode)
935 lstrcpyW ((LPWSTR)lParam, infoPtr->parts[0].text);
937 lstrcpyWtoA ((LPSTR)lParam, infoPtr->parts[0].text);
945 __inline__ static LRESULT
946 STATUSBAR_WMMouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam)
948 STATUSWINDOWINFO *infoPtr = STATUSBAR_GetInfoPtr (hwnd);
950 if (infoPtr->hwndToolTip)
951 STATUSBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
952 WM_MOUSEMOVE, wParam, lParam);
958 STATUSBAR_WMNCHitTest (HWND hwnd, WPARAM wParam, LPARAM lParam)
960 if (GetWindowLongA (hwnd, GWL_STYLE) & SBARS_SIZEGRIP) {
964 GetClientRect (hwnd, &rect);
966 pt.x = (INT)LOWORD(lParam);
967 pt.y = (INT)HIWORD(lParam);
968 ScreenToClient (hwnd, &pt);
970 rect.left = rect.right - 13;
973 if (PtInRect (&rect, pt))
974 return HTBOTTOMRIGHT;
977 return DefWindowProcA (hwnd, WM_NCHITTEST, wParam, lParam);
981 static __inline__ LRESULT
982 STATUSBAR_WMNCLButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
984 PostMessageA (GetParent (hwnd), WM_NCLBUTTONDOWN, wParam, lParam);
989 static __inline__ LRESULT
990 STATUSBAR_WMNCLButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam)
992 PostMessageA (GetParent (hwnd), WM_NCLBUTTONUP, wParam, lParam);
998 STATUSBAR_WMPaint (HWND hwnd, WPARAM wParam)
1003 hdc = wParam==0 ? BeginPaint (hwnd, &ps) : (HDC)wParam;
1004 STATUSBAR_Refresh (hwnd, hdc);
1006 EndPaint (hwnd, &ps);
1013 STATUSBAR_WMSetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
1015 STATUSWINDOWINFO *infoPtr = STATUSBAR_GetInfoPtr (hwnd);
1017 infoPtr->hFont = (HFONT)wParam;
1018 if (LOWORD(lParam) == TRUE) {
1019 HDC hdc = GetDC (hwnd);
1020 STATUSBAR_Refresh (hwnd, hdc);
1021 ReleaseDC (hwnd, hdc);
1029 STATUSBAR_WMSetText (HWND hwnd, WPARAM wParam, LPARAM lParam)
1031 STATUSWINDOWINFO *infoPtr = STATUSBAR_GetInfoPtr (hwnd);
1032 STATUSWINDOWPART *part;
1036 if (infoPtr->numParts == 0)
1039 part = &infoPtr->parts[0];
1040 /* duplicate string */
1042 COMCTL32_Free (part->text);
1044 if (infoPtr->bUnicode) {
1045 if (lParam && (len = lstrlenW((LPCWSTR)lParam))) {
1046 part->text = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
1047 lstrcpyW (part->text, (LPCWSTR)lParam);
1051 if (lParam && (len = lstrlenA((LPCSTR)lParam))) {
1052 part->text = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
1053 lstrcpyAtoW (part->text, (LPCSTR)lParam);
1058 STATUSBAR_RefreshPart (hwnd, part, hdc);
1059 ReleaseDC (hwnd, hdc);
1066 STATUSBAR_WMSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
1068 STATUSWINDOWINFO *infoPtr = STATUSBAR_GetInfoPtr (hwnd);
1069 INT width, x, y, flags;
1073 /* Need to resize width to match parent */
1074 flags = (INT) wParam;
1076 /* FIXME for flags =
1077 * SIZE_MAXIMIZED, SIZE_MAXSHOW, SIZE_MINIMIZED, SIZE_RESTORED
1080 if (flags == SIZE_RESTORED) {
1081 /* width and height don't apply */
1082 parent = GetParent (hwnd);
1083 GetClientRect (parent, &parent_rect);
1084 width = parent_rect.right - parent_rect.left;
1085 x = parent_rect.left;
1086 y = parent_rect.bottom - infoPtr->height;
1087 MoveWindow (hwnd, parent_rect.left,
1088 parent_rect.bottom - infoPtr->height,
1089 width, infoPtr->height, TRUE);
1090 STATUSBAR_SetPartBounds (hwnd);
1097 STATUSBAR_SendNotify (HWND hwnd, UINT code)
1101 nmhdr.hwndFrom = hwnd;
1102 nmhdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
1104 SendMessageA (GetParent (hwnd), WM_NOTIFY, 0, (LPARAM)&nmhdr);
1111 StatusWindowProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
1115 return STATUSBAR_GetBorders (lParam);
1118 return STATUSBAR_GetIcon (hwnd, wParam);
1121 return STATUSBAR_GetParts (hwnd, wParam, lParam);
1124 return STATUSBAR_GetRect (hwnd, wParam, lParam);
1127 return STATUSBAR_GetTextA (hwnd, wParam, lParam);
1130 return STATUSBAR_GetTextW (hwnd, wParam, lParam);
1132 case SB_GETTEXTLENGTHA:
1133 case SB_GETTEXTLENGTHW:
1134 return STATUSBAR_GetTextLength (hwnd, wParam);
1136 case SB_GETTIPTEXTA:
1137 return STATUSBAR_GetTipTextA (hwnd, wParam, lParam);
1139 case SB_GETTIPTEXTW:
1140 return STATUSBAR_GetTipTextW (hwnd, wParam, lParam);
1142 case SB_GETUNICODEFORMAT:
1143 return STATUSBAR_GetUnicodeFormat (hwnd);
1146 return STATUSBAR_IsSimple (hwnd);
1149 return STATUSBAR_SetBkColor (hwnd, wParam, lParam);
1152 return STATUSBAR_SetIcon (hwnd, wParam, lParam);
1154 case SB_SETMINHEIGHT:
1155 return STATUSBAR_SetMinHeight (hwnd, wParam, lParam);
1158 return STATUSBAR_SetParts (hwnd, wParam, lParam);
1161 return STATUSBAR_SetTextA (hwnd, wParam, lParam);
1164 return STATUSBAR_SetTextW (hwnd, wParam, lParam);
1166 case SB_SETTIPTEXTA:
1167 return STATUSBAR_SetTipTextA (hwnd, wParam, lParam);
1169 case SB_SETTIPTEXTW:
1170 return STATUSBAR_SetTipTextW (hwnd, wParam, lParam);
1172 case SB_SETUNICODEFORMAT:
1173 return STATUSBAR_SetUnicodeFormat (hwnd, wParam);
1176 return STATUSBAR_Simple (hwnd, wParam, lParam);
1180 return STATUSBAR_WMCreate (hwnd, wParam, lParam);
1183 return STATUSBAR_WMDestroy (hwnd);
1186 return STATUSBAR_WMGetFont (hwnd);
1189 return STATUSBAR_WMGetText (hwnd, wParam, lParam);
1191 case WM_GETTEXTLENGTH:
1192 return STATUSBAR_GetTextLength (hwnd, 0);
1194 case WM_LBUTTONDBLCLK:
1195 return STATUSBAR_SendNotify (hwnd, NM_DBLCLK);
1198 return STATUSBAR_SendNotify (hwnd, NM_CLICK);
1201 return STATUSBAR_WMMouseMove (hwnd, wParam, lParam);
1204 return STATUSBAR_WMNCHitTest (hwnd, wParam, lParam);
1206 case WM_NCLBUTTONDOWN:
1207 return STATUSBAR_WMNCLButtonDown (hwnd, wParam, lParam);
1209 case WM_NCLBUTTONUP:
1210 return STATUSBAR_WMNCLButtonUp (hwnd, wParam, lParam);
1213 return STATUSBAR_WMPaint (hwnd, wParam);
1215 case WM_RBUTTONDBLCLK:
1216 return STATUSBAR_SendNotify (hwnd, NM_RDBLCLK);
1219 return STATUSBAR_SendNotify (hwnd, NM_RCLICK);
1222 return STATUSBAR_WMSetFont (hwnd, wParam, lParam);
1225 return STATUSBAR_WMSetText (hwnd, wParam, lParam);
1228 return STATUSBAR_WMSize (hwnd, wParam, lParam);
1232 ERR (statusbar, "unknown msg %04x wp=%04x lp=%08lx\n",
1233 msg, wParam, lParam);
1234 return DefWindowProcA (hwnd, msg, wParam, lParam);
1240 /***********************************************************************
1241 * STATUS_Register [Internal]
1243 * Registers the status window class.
1247 STATUS_Register (VOID)
1251 if (GlobalFindAtomA (STATUSCLASSNAMEA)) return;
1253 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
1254 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS | CS_VREDRAW;
1255 wndClass.lpfnWndProc = (WNDPROC)StatusWindowProc;
1256 wndClass.cbClsExtra = 0;
1257 wndClass.cbWndExtra = sizeof(STATUSWINDOWINFO *);
1258 wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
1259 wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
1260 wndClass.lpszClassName = STATUSCLASSNAMEA;
1262 RegisterClassA (&wndClass);
1266 /***********************************************************************
1267 * STATUS_Unregister [Internal]
1269 * Unregisters the status window class.
1273 STATUS_Unregister (VOID)
1275 if (GlobalFindAtomA (STATUSCLASSNAMEA))
1276 UnregisterClassA (STATUSCLASSNAMEA, (HINSTANCE)NULL);