4 * Copyright David W. Metcalfe, 1993
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 * This code was audited for completeness against the documented features
23 * of Comctl32.dll version 6.0 on Oct. 4, 2004, by Dimitrie O. Paun.
25 * Unless otherwise noted, we believe this code to be complete, as per
26 * the specification mentioned above.
27 * If you discover missing features, or bugs, please note them below.
30 * - Windows XP introduced new behavior: The background of centered
31 * icons and bitmaps is painted differently. This is only done if
32 * a manifest is present.
33 * Because it has not yet been decided how to implement the two
34 * different modes in Wine, only the Windows XP mode is implemented.
35 * - Controls with SS_SIMPLE but without SS_NOPREFIX:
36 * The text should not be changed. Windows doesn't clear the
37 * client rectangle, so the new text must be larger than the old one.
38 * - The SS_RIGHTJUST style is currently not implemented by Windows
39 * (or it does something different than documented).
51 #include "user_private.h"
52 #include "wine/debug.h"
54 WINE_DEFAULT_DEBUG_CHANNEL(static);
56 static void STATIC_PaintOwnerDrawfn( HWND hwnd
, HDC hdc
, DWORD style
);
57 static void STATIC_PaintTextfn( HWND hwnd
, HDC hdc
, DWORD style
);
58 static void STATIC_PaintRectfn( HWND hwnd
, HDC hdc
, DWORD style
);
59 static void STATIC_PaintIconfn( HWND hwnd
, HDC hdc
, DWORD style
);
60 static void STATIC_PaintBitmapfn( HWND hwnd
, HDC hdc
, DWORD style
);
61 static void STATIC_PaintEnhMetafn( HWND hwnd
, HDC hdc
, DWORD style
);
62 static void STATIC_PaintEtchedfn( HWND hwnd
, HDC hdc
, DWORD style
);
64 static COLORREF color_3dshadow
, color_3ddkshadow
, color_3dhighlight
;
66 /* offsets for GetWindowLong for static private information */
67 #define HFONT_GWL_OFFSET 0
68 #define HICON_GWL_OFFSET (sizeof(HFONT))
69 #define STATIC_EXTRA_BYTES (HICON_GWL_OFFSET + sizeof(HICON))
71 typedef void (*pfPaint
)( HWND hwnd
, HDC hdc
, DWORD style
);
73 static const pfPaint staticPaintFunc
[SS_TYPEMASK
+1] =
75 STATIC_PaintTextfn
, /* SS_LEFT */
76 STATIC_PaintTextfn
, /* SS_CENTER */
77 STATIC_PaintTextfn
, /* SS_RIGHT */
78 STATIC_PaintIconfn
, /* SS_ICON */
79 STATIC_PaintRectfn
, /* SS_BLACKRECT */
80 STATIC_PaintRectfn
, /* SS_GRAYRECT */
81 STATIC_PaintRectfn
, /* SS_WHITERECT */
82 STATIC_PaintRectfn
, /* SS_BLACKFRAME */
83 STATIC_PaintRectfn
, /* SS_GRAYFRAME */
84 STATIC_PaintRectfn
, /* SS_WHITEFRAME */
85 NULL
, /* SS_USERITEM */
86 STATIC_PaintTextfn
, /* SS_SIMPLE */
87 STATIC_PaintTextfn
, /* SS_LEFTNOWORDWRAP */
88 STATIC_PaintOwnerDrawfn
, /* SS_OWNERDRAW */
89 STATIC_PaintBitmapfn
, /* SS_BITMAP */
90 STATIC_PaintEnhMetafn
, /* SS_ENHMETAFILE */
91 STATIC_PaintEtchedfn
, /* SS_ETCHEDHORZ */
92 STATIC_PaintEtchedfn
, /* SS_ETCHEDVERT */
93 STATIC_PaintEtchedfn
, /* SS_ETCHEDFRAME */
97 /*********************************************************************
98 * static class descriptor
100 static const WCHAR staticW
[] = {'S','t','a','t','i','c',0};
101 const struct builtin_class_descr STATIC_builtin_class
=
104 CS_DBLCLKS
| CS_PARENTDC
, /* style */
105 WINPROC_STATIC
, /* proc */
106 STATIC_EXTRA_BYTES
, /* extra */
107 IDC_ARROW
, /* cursor */
111 static void setup_clipping(HWND hwnd
, HDC hdc
, HRGN
*orig
)
116 /* Native control has always a clipping region set (this may be because
117 * builtin controls uses CS_PARENTDC) and an application depends on it
119 hrgn
= CreateRectRgn(0, 0, 1, 1);
120 if (GetClipRgn(hdc
, hrgn
) != 1)
127 GetClientRect(hwnd
, &rc
);
128 DPtoLP(hdc
, (POINT
*)&rc
, 2);
129 IntersectClipRect(hdc
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
132 static void restore_clipping(HDC hdc
, HRGN hrgn
)
134 SelectClipRgn(hdc
, hrgn
);
139 /***********************************************************************
142 * Set the icon for an SS_ICON control.
144 static HICON
STATIC_SetIcon( HWND hwnd
, HICON hicon
, DWORD style
)
149 if ((style
& SS_TYPEMASK
) != SS_ICON
) return 0;
150 if (hicon
&& !get_icon_size( hicon
, &size
))
152 WARN("hicon != 0, but invalid\n");
155 prevIcon
= (HICON
)SetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
, (LONG_PTR
)hicon
);
156 if (hicon
&& !(style
& SS_CENTERIMAGE
) && !(style
& SS_REALSIZECONTROL
))
158 /* Windows currently doesn't implement SS_RIGHTJUST */
160 if ((style & SS_RIGHTJUST) != 0)
163 GetWindowRect(hwnd, &wr);
164 SetWindowPos( hwnd, 0, wr.right - info->nWidth, wr.bottom - info->nHeight,
165 info->nWidth, info->nHeight, SWP_NOACTIVATE | SWP_NOZORDER );
169 SetWindowPos( hwnd
, 0, 0, 0, size
.cx
, size
.cy
, SWP_NOACTIVATE
| SWP_NOMOVE
| SWP_NOZORDER
);
175 /***********************************************************************
178 * Set the bitmap for an SS_BITMAP control.
180 static HBITMAP
STATIC_SetBitmap( HWND hwnd
, HBITMAP hBitmap
, DWORD style
)
184 if ((style
& SS_TYPEMASK
) != SS_BITMAP
) return 0;
185 if (hBitmap
&& GetObjectType(hBitmap
) != OBJ_BITMAP
) {
186 WARN("hBitmap != 0, but it's not a bitmap\n");
189 hOldBitmap
= (HBITMAP
)SetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
, (LONG_PTR
)hBitmap
);
190 if (hBitmap
&& !(style
& SS_CENTERIMAGE
) && !(style
& SS_REALSIZECONTROL
))
193 GetObjectW(hBitmap
, sizeof(bm
), &bm
);
194 /* Windows currently doesn't implement SS_RIGHTJUST */
196 if ((style & SS_RIGHTJUST) != 0)
199 GetWindowRect(hwnd, &wr);
200 SetWindowPos( hwnd, 0, wr.right - bm.bmWidth, wr.bottom - bm.bmHeight,
201 bm.bmWidth, bm.bmHeight, SWP_NOACTIVATE | SWP_NOZORDER );
205 SetWindowPos( hwnd
, 0, 0, 0, bm
.bmWidth
, bm
.bmHeight
,
206 SWP_NOACTIVATE
| SWP_NOMOVE
| SWP_NOZORDER
);
213 /***********************************************************************
214 * STATIC_SetEnhMetaFile
216 * Set the enhanced metafile for an SS_ENHMETAFILE control.
218 static HENHMETAFILE
STATIC_SetEnhMetaFile( HWND hwnd
, HENHMETAFILE hEnhMetaFile
, DWORD style
)
220 if ((style
& SS_TYPEMASK
) != SS_ENHMETAFILE
) return 0;
221 if (hEnhMetaFile
&& GetObjectType(hEnhMetaFile
) != OBJ_ENHMETAFILE
) {
222 WARN("hEnhMetaFile != 0, but it's not an enhanced metafile\n");
225 return (HENHMETAFILE
)SetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
, (LONG_PTR
)hEnhMetaFile
);
228 /***********************************************************************
231 * Gets the bitmap for an SS_BITMAP control, the icon/cursor for an
232 * SS_ICON control or the enhanced metafile for an SS_ENHMETAFILE control.
234 static HANDLE
STATIC_GetImage( HWND hwnd
, WPARAM wParam
, DWORD style
)
236 switch(style
& SS_TYPEMASK
)
239 if ((wParam
!= IMAGE_ICON
) &&
240 (wParam
!= IMAGE_CURSOR
)) return NULL
;
243 if (wParam
!= IMAGE_BITMAP
) return NULL
;
246 if (wParam
!= IMAGE_ENHMETAFILE
) return NULL
;
251 return (HANDLE
)GetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
);
254 /***********************************************************************
257 * Load the icon for an SS_ICON control.
259 static HICON
STATIC_LoadIconA( HWND hwnd
, LPCSTR name
, DWORD style
)
261 HINSTANCE hInstance
= (HINSTANCE
)GetWindowLongPtrW( hwnd
, GWLP_HINSTANCE
);
262 if ((style
& SS_REALSIZEIMAGE
) != 0)
264 return LoadImageA(hInstance
, name
, IMAGE_ICON
, 0, 0, LR_SHARED
);
268 HICON hicon
= LoadIconA( hInstance
, name
);
269 if (!hicon
) hicon
= LoadCursorA( hInstance
, name
);
270 if (!hicon
) hicon
= LoadIconA( 0, name
);
271 /* Windows doesn't try to load a standard cursor,
272 probably because most IDs for standard cursors conflict
273 with the IDs for standard icons anyway */
278 /***********************************************************************
281 * Load the icon for an SS_ICON control.
283 static HICON
STATIC_LoadIconW( HWND hwnd
, LPCWSTR name
, DWORD style
)
285 HINSTANCE hInstance
= (HINSTANCE
)GetWindowLongPtrW( hwnd
, GWLP_HINSTANCE
);
286 if ((style
& SS_REALSIZEIMAGE
) != 0)
288 return LoadImageW(hInstance
, name
, IMAGE_ICON
, 0, 0, LR_SHARED
);
292 HICON hicon
= LoadIconW( hInstance
, name
);
293 if (!hicon
) hicon
= LoadCursorW( hInstance
, name
);
294 if (!hicon
) hicon
= LoadIconW( 0, name
);
295 /* Windows doesn't try to load a standard cursor,
296 probably because most IDs for standard cursors conflict
297 with the IDs for standard icons anyway */
302 /***********************************************************************
305 * Load the bitmap for an SS_BITMAP control.
307 static HBITMAP
STATIC_LoadBitmapA( HWND hwnd
, LPCSTR name
)
309 HINSTANCE hInstance
= (HINSTANCE
)GetWindowLongPtrW( hwnd
, GWLP_HINSTANCE
);
310 /* Windows doesn't try to load OEM Bitmaps (hInstance == NULL) */
311 return LoadBitmapA( hInstance
, name
);
314 /***********************************************************************
317 * Load the bitmap for an SS_BITMAP control.
319 static HBITMAP
STATIC_LoadBitmapW( HWND hwnd
, LPCWSTR name
)
321 HINSTANCE hInstance
= (HINSTANCE
)GetWindowLongPtrW( hwnd
, GWLP_HINSTANCE
);
322 /* Windows doesn't try to load OEM Bitmaps (hInstance == NULL) */
323 return LoadBitmapW( hInstance
, name
);
326 /***********************************************************************
329 * Try to immediately paint the control.
331 static VOID
STATIC_TryPaintFcn(HWND hwnd
, LONG full_style
)
333 LONG style
= full_style
& SS_TYPEMASK
;
336 GetClientRect( hwnd
, &rc
);
337 if (!IsRectEmpty(&rc
) && IsWindowVisible(hwnd
) && staticPaintFunc
[style
])
343 setup_clipping(hwnd
, hdc
, &hOrigClipping
);
344 (staticPaintFunc
[style
])( hwnd
, hdc
, full_style
);
345 restore_clipping(hdc
, hOrigClipping
);
346 ReleaseDC( hwnd
, hdc
);
350 static HBRUSH
STATIC_SendWmCtlColorStatic(HWND hwnd
, HDC hdc
)
353 HWND parent
= GetParent(hwnd
);
355 if (!parent
) parent
= hwnd
;
356 hBrush
= (HBRUSH
) SendMessageW( parent
,
357 WM_CTLCOLORSTATIC
, (WPARAM
)hdc
, (LPARAM
)hwnd
);
358 if (!hBrush
) /* did the app forget to call DefWindowProc ? */
360 /* FIXME: DefWindowProc should return different colors if a
361 manifest is present */
362 hBrush
= (HBRUSH
)DefWindowProcW( parent
, WM_CTLCOLORSTATIC
,
363 (WPARAM
)hdc
, (LPARAM
)hwnd
);
368 static VOID
STATIC_InitColours(void)
370 color_3ddkshadow
= GetSysColor(COLOR_3DDKSHADOW
);
371 color_3dshadow
= GetSysColor(COLOR_3DSHADOW
);
372 color_3dhighlight
= GetSysColor(COLOR_3DHIGHLIGHT
);
375 /***********************************************************************
378 * Tests if the control displays text.
380 static BOOL
hasTextStyle( DWORD style
)
382 switch(style
& SS_TYPEMASK
)
386 case SS_LEFTNOWORDWRAP
:
396 /***********************************************************************
397 * StaticWndProc_common
399 LRESULT
StaticWndProc_common( HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL unicode
)
402 LONG full_style
= GetWindowLongW( hwnd
, GWL_STYLE
);
403 LONG style
= full_style
& SS_TYPEMASK
;
405 if (!IsWindow( hwnd
)) return 0;
410 if (style
< 0L || style
> SS_TYPEMASK
)
412 ERR("Unknown style 0x%02x\n", style
);
415 STATIC_InitColours();
419 if (style
== SS_ICON
) {
422 * DestroyIcon32( STATIC_SetIcon( wndPtr, 0 ) );
424 * We don't want to do this yet because DestroyIcon32 is broken. If the icon
425 * had already been loaded by the application the last thing we want to do is
426 * GlobalFree16 the handle.
430 else return unicode
? DefWindowProcW(hwnd
, uMsg
, wParam
, lParam
) :
431 DefWindowProcA(hwnd
, uMsg
, wParam
, lParam
);
434 /* do all painting in WM_PAINT like Windows does */
441 HDC hdc
= wParam
? (HDC
)wParam
: BeginPaint(hwnd
, &ps
);
442 if (staticPaintFunc
[style
])
445 setup_clipping(hwnd
, hdc
, &hOrigClipping
);
446 (staticPaintFunc
[style
])( hwnd
, hdc
, full_style
);
447 restore_clipping(hdc
, hOrigClipping
);
449 if (!wParam
) EndPaint(hwnd
, &ps
);
454 STATIC_TryPaintFcn( hwnd
, full_style
);
455 if (full_style
& SS_NOTIFY
) {
457 SendMessageW( GetParent(hwnd
), WM_COMMAND
,
458 MAKEWPARAM( GetWindowLongPtrW(hwnd
,GWLP_ID
), STN_ENABLE
), (LPARAM
)hwnd
);
461 SendMessageW( GetParent(hwnd
), WM_COMMAND
,
462 MAKEWPARAM( GetWindowLongPtrW(hwnd
,GWLP_ID
), STN_DISABLE
), (LPARAM
)hwnd
);
467 case WM_SYSCOLORCHANGE
:
468 STATIC_InitColours();
469 STATIC_TryPaintFcn( hwnd
, full_style
);
477 if (full_style
& SS_SUNKEN
)
478 SetWindowLongW( hwnd
, GWL_EXSTYLE
,
479 GetWindowLongW( hwnd
, GWL_EXSTYLE
) | WS_EX_STATICEDGE
);
484 textW
= ((LPCREATESTRUCTW
)lParam
)->lpszName
;
488 textA
= ((LPCREATESTRUCTA
)lParam
)->lpszName
;
497 hIcon
= STATIC_LoadIconW(hwnd
, textW
, full_style
);
499 hIcon
= STATIC_LoadIconA(hwnd
, textA
, full_style
);
500 STATIC_SetIcon(hwnd
, hIcon
, full_style
);
507 hBitmap
= STATIC_LoadBitmapW(hwnd
, textW
);
509 hBitmap
= STATIC_LoadBitmapA(hwnd
, textA
);
510 STATIC_SetBitmap(hwnd
, hBitmap
, full_style
);
514 /* SS_ENHMETAFILE: Despite what MSDN says, Windows does not load
515 the enhanced metafile that was specified as the window text. */
517 return unicode
? DefWindowProcW(hwnd
, uMsg
, wParam
, lParam
) :
518 DefWindowProcA(hwnd
, uMsg
, wParam
, lParam
);
521 if (hasTextStyle( full_style
))
526 lResult
= DefWindowProcW( hwnd
, uMsg
, wParam
, lParam
);
528 lResult
= DefWindowProcA( hwnd
, uMsg
, wParam
, lParam
);
529 STATIC_TryPaintFcn( hwnd
, full_style
);
535 if (hasTextStyle( full_style
))
537 SetWindowLongPtrW( hwnd
, HFONT_GWL_OFFSET
, wParam
);
539 RedrawWindow( hwnd
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_UPDATENOW
| RDW_ALLCHILDREN
);
544 return GetWindowLongPtrW( hwnd
, HFONT_GWL_OFFSET
);
547 if (full_style
& SS_NOTIFY
)
550 return HTTRANSPARENT
;
556 case WM_NCLBUTTONDOWN
:
557 if (full_style
& SS_NOTIFY
)
558 SendMessageW( GetParent(hwnd
), WM_COMMAND
,
559 MAKEWPARAM( GetWindowLongPtrW(hwnd
,GWLP_ID
), STN_CLICKED
), (LPARAM
)hwnd
);
562 case WM_LBUTTONDBLCLK
:
563 case WM_NCLBUTTONDBLCLK
:
564 if (full_style
& SS_NOTIFY
)
565 SendMessageW( GetParent(hwnd
), WM_COMMAND
,
566 MAKEWPARAM( GetWindowLongPtrW(hwnd
,GWLP_ID
), STN_DBLCLK
), (LPARAM
)hwnd
);
570 return (LRESULT
)STATIC_GetImage( hwnd
, wParam
, full_style
);
573 return (LRESULT
)STATIC_GetImage( hwnd
, IMAGE_ICON
, full_style
);
578 lResult
= (LRESULT
)STATIC_SetBitmap( hwnd
, (HBITMAP
)lParam
, full_style
);
580 case IMAGE_ENHMETAFILE
:
581 lResult
= (LRESULT
)STATIC_SetEnhMetaFile( hwnd
, (HENHMETAFILE
)lParam
, full_style
);
585 lResult
= (LRESULT
)STATIC_SetIcon( hwnd
, (HICON
)lParam
, full_style
);
588 FIXME("STM_SETIMAGE: Unhandled type %lx\n", wParam
);
591 STATIC_TryPaintFcn( hwnd
, full_style
);
595 lResult
= (LRESULT
)STATIC_SetIcon( hwnd
, (HICON
)wParam
, full_style
);
596 STATIC_TryPaintFcn( hwnd
, full_style
);
600 return unicode
? DefWindowProcW(hwnd
, uMsg
, wParam
, lParam
) :
601 DefWindowProcA(hwnd
, uMsg
, wParam
, lParam
);
606 static void STATIC_PaintOwnerDrawfn( HWND hwnd
, HDC hdc
, DWORD style
)
609 HFONT font
, oldFont
= NULL
;
610 UINT id
= (UINT
)GetWindowLongPtrW( hwnd
, GWLP_ID
);
612 dis
.CtlType
= ODT_STATIC
;
615 dis
.itemAction
= ODA_DRAWENTIRE
;
616 dis
.itemState
= IsWindowEnabled(hwnd
) ? 0 : ODS_DISABLED
;
620 GetClientRect( hwnd
, &dis
.rcItem
);
622 font
= (HFONT
)GetWindowLongPtrW( hwnd
, HFONT_GWL_OFFSET
);
623 if (font
) oldFont
= SelectObject( hdc
, font
);
624 SendMessageW( GetParent(hwnd
), WM_CTLCOLORSTATIC
, (WPARAM
)hdc
, (LPARAM
)hwnd
);
625 SendMessageW( GetParent(hwnd
), WM_DRAWITEM
, id
, (LPARAM
)&dis
);
626 if (font
) SelectObject( hdc
, oldFont
);
629 static void STATIC_PaintTextfn( HWND hwnd
, HDC hdc
, DWORD style
)
633 HFONT hFont
, hOldFont
= NULL
;
638 GetClientRect( hwnd
, &rc
);
640 switch (style
& SS_TYPEMASK
)
643 wFormat
= DT_LEFT
| DT_EXPANDTABS
| DT_WORDBREAK
;
647 wFormat
= DT_CENTER
| DT_EXPANDTABS
| DT_WORDBREAK
;
651 wFormat
= DT_RIGHT
| DT_EXPANDTABS
| DT_WORDBREAK
;
655 wFormat
= DT_LEFT
| DT_SINGLELINE
;
658 case SS_LEFTNOWORDWRAP
:
659 wFormat
= DT_LEFT
| DT_EXPANDTABS
;
666 if (GetWindowLongW( hwnd
, GWL_EXSTYLE
) & WS_EX_RIGHT
)
667 wFormat
= DT_RIGHT
| (wFormat
& ~(DT_LEFT
| DT_CENTER
));
669 if (style
& SS_NOPREFIX
)
670 wFormat
|= DT_NOPREFIX
;
672 if ((style
& SS_TYPEMASK
) != SS_SIMPLE
)
674 if (style
& SS_CENTERIMAGE
)
675 wFormat
|= DT_SINGLELINE
| DT_VCENTER
;
676 if (style
& SS_EDITCONTROL
)
677 wFormat
|= DT_EDITCONTROL
;
678 if (style
& SS_ENDELLIPSIS
)
679 wFormat
|= DT_SINGLELINE
| DT_END_ELLIPSIS
;
680 if (style
& SS_PATHELLIPSIS
)
681 wFormat
|= DT_SINGLELINE
| DT_PATH_ELLIPSIS
;
682 if (style
& SS_WORDELLIPSIS
)
683 wFormat
|= DT_SINGLELINE
| DT_WORD_ELLIPSIS
;
686 if ((hFont
= (HFONT
)GetWindowLongPtrW( hwnd
, HFONT_GWL_OFFSET
)))
687 hOldFont
= SelectObject( hdc
, hFont
);
689 /* SS_SIMPLE controls: WM_CTLCOLORSTATIC is sent, but the returned
691 hBrush
= STATIC_SendWmCtlColorStatic(hwnd
, hdc
);
693 if ((style
& SS_TYPEMASK
) != SS_SIMPLE
)
695 FillRect( hdc
, &rc
, hBrush
);
696 if (!IsWindowEnabled(hwnd
)) SetTextColor(hdc
, GetSysColor(COLOR_GRAYTEXT
));
700 if (!(text
= HeapAlloc( GetProcessHeap(), 0, buf_size
* sizeof(WCHAR
) )))
703 while ((len
= InternalGetWindowText( hwnd
, text
, buf_size
)) == buf_size
- 1)
706 if (!(text
= HeapReAlloc( GetProcessHeap(), 0, text
, buf_size
* sizeof(WCHAR
) )))
710 if (!len
) goto no_TextOut
;
712 if (((style
& SS_TYPEMASK
) == SS_SIMPLE
) && (style
& SS_NOPREFIX
))
714 /* Windows uses the faster ExtTextOut() to draw the text and
715 to paint the whole client rectangle with the text background
716 color. Reference: "Static Controls" by Kyle Marsh, 1992 */
717 ExtTextOutW( hdc
, rc
.left
, rc
.top
, ETO_CLIPPED
| ETO_OPAQUE
,
718 &rc
, text
, len
, NULL
);
722 DrawTextW( hdc
, text
, -1, &rc
, wFormat
);
726 HeapFree( GetProcessHeap(), 0, text
);
729 SelectObject( hdc
, hOldFont
);
732 static void STATIC_PaintRectfn( HWND hwnd
, HDC hdc
, DWORD style
)
737 GetClientRect( hwnd
, &rc
);
739 /* FIXME: send WM_CTLCOLORSTATIC */
740 switch (style
& SS_TYPEMASK
)
743 hBrush
= CreateSolidBrush(color_3ddkshadow
);
744 FillRect( hdc
, &rc
, hBrush
);
747 hBrush
= CreateSolidBrush(color_3dshadow
);
748 FillRect( hdc
, &rc
, hBrush
);
751 hBrush
= CreateSolidBrush(color_3dhighlight
);
752 FillRect( hdc
, &rc
, hBrush
);
755 hBrush
= CreateSolidBrush(color_3ddkshadow
);
756 FrameRect( hdc
, &rc
, hBrush
);
759 hBrush
= CreateSolidBrush(color_3dshadow
);
760 FrameRect( hdc
, &rc
, hBrush
);
763 hBrush
= CreateSolidBrush(color_3dhighlight
);
764 FrameRect( hdc
, &rc
, hBrush
);
769 DeleteObject( hBrush
);
773 static void STATIC_PaintIconfn( HWND hwnd
, HDC hdc
, DWORD style
)
780 GetClientRect( hwnd
, &rc
);
781 hbrush
= STATIC_SendWmCtlColorStatic(hwnd
, hdc
);
782 hIcon
= (HICON
)GetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
);
783 if (!hIcon
|| !get_icon_size( hIcon
, &size
))
785 FillRect(hdc
, &rc
, hbrush
);
789 if (style
& SS_CENTERIMAGE
)
791 iconRect
.left
= (rc
.right
- rc
.left
) / 2 - size
.cx
/ 2;
792 iconRect
.top
= (rc
.bottom
- rc
.top
) / 2 - size
.cy
/ 2;
793 iconRect
.right
= iconRect
.left
+ size
.cx
;
794 iconRect
.bottom
= iconRect
.top
+ size
.cy
;
798 FillRect( hdc
, &rc
, hbrush
);
799 DrawIconEx( hdc
, iconRect
.left
, iconRect
.top
, hIcon
, iconRect
.right
- iconRect
.left
,
800 iconRect
.bottom
- iconRect
.top
, 0, NULL
, DI_NORMAL
);
804 static void STATIC_PaintBitmapfn(HWND hwnd
, HDC hdc
, DWORD style
)
807 HBITMAP hBitmap
, oldbitmap
;
810 /* message is still sent, even if the returned brush is not used */
811 hbrush
= STATIC_SendWmCtlColorStatic(hwnd
, hdc
);
813 if ((hBitmap
= (HBITMAP
)GetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
))
814 && (GetObjectType(hBitmap
) == OBJ_BITMAP
)
815 && (hMemDC
= CreateCompatibleDC( hdc
)))
821 GetObjectW(hBitmap
, sizeof(bm
), &bm
);
822 oldbitmap
= SelectObject(hMemDC
, hBitmap
);
824 /* Set the background color for monochrome bitmaps
825 to the color of the background brush */
826 if (GetObjectW( hbrush
, sizeof(brush
), &brush
))
828 if (brush
.lbStyle
== BS_SOLID
)
829 SetBkColor(hdc
, brush
.lbColor
);
831 GetClientRect(hwnd
, &rcClient
);
832 if (style
& SS_CENTERIMAGE
)
835 x
= (rcClient
.right
- rcClient
.left
)/2 - bm
.bmWidth
/2;
836 y
= (rcClient
.bottom
- rcClient
.top
)/2 - bm
.bmHeight
/2;
837 FillRect( hdc
, &rcClient
, hbrush
);
838 BitBlt(hdc
, x
, y
, bm
.bmWidth
, bm
.bmHeight
, hMemDC
, 0, 0,
843 StretchBlt(hdc
, 0, 0, rcClient
.right
- rcClient
.left
,
844 rcClient
.bottom
- rcClient
.top
, hMemDC
,
845 0, 0, bm
.bmWidth
, bm
.bmHeight
, SRCCOPY
);
847 SelectObject(hMemDC
, oldbitmap
);
853 static void STATIC_PaintEnhMetafn(HWND hwnd
, HDC hdc
, DWORD style
)
855 HENHMETAFILE hEnhMetaFile
;
859 GetClientRect(hwnd
, &rc
);
860 hbrush
= STATIC_SendWmCtlColorStatic(hwnd
, hdc
);
861 FillRect(hdc
, &rc
, hbrush
);
862 if ((hEnhMetaFile
= (HENHMETAFILE
)GetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
)))
864 /* The control's current font is not selected into the
866 if (GetObjectType(hEnhMetaFile
) == OBJ_ENHMETAFILE
)
867 PlayEnhMetaFile(hdc
, hEnhMetaFile
, &rc
);
872 static void STATIC_PaintEtchedfn( HWND hwnd
, HDC hdc
, DWORD style
)
876 /* FIXME: sometimes (not always) sends WM_CTLCOLORSTATIC */
877 GetClientRect( hwnd
, &rc
);
878 switch (style
& SS_TYPEMASK
)
881 DrawEdge(hdc
,&rc
,EDGE_ETCHED
,BF_TOP
|BF_BOTTOM
);
884 DrawEdge(hdc
,&rc
,EDGE_ETCHED
,BF_LEFT
|BF_RIGHT
);
887 DrawEdge (hdc
, &rc
, EDGE_ETCHED
, BF_RECT
);