ReactOS 0.4.16-dev-125-g798ea90
static.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "commctrl.h"
#include "wine/debug.h"
#include "comctl32.h"
Include dependency graph for static.c:

Go to the source code of this file.

Macros

#define HFONT_GWL_OFFSET   0
 
#define HICON_GWL_OFFSET   (sizeof(HFONT))
 
#define STATIC_EXTRA_BYTES   (HICON_GWL_OFFSET + sizeof(HICON))
 

Typedefs

typedef void(* pfPaint) (HWND hwnd, HDC hdc, DWORD style)
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (static)
 
static void STATIC_PaintOwnerDrawfn (HWND hwnd, HDC hdc, DWORD style)
 
static void STATIC_PaintTextfn (HWND hwnd, HDC hdc, DWORD style)
 
static void STATIC_PaintRectfn (HWND hwnd, HDC hdc, DWORD style)
 
static void STATIC_PaintIconfn (HWND hwnd, HDC hdc, DWORD style)
 
static void STATIC_PaintBitmapfn (HWND hwnd, HDC hdc, DWORD style)
 
static void STATIC_PaintEnhMetafn (HWND hwnd, HDC hdc, DWORD style)
 
static void STATIC_PaintEtchedfn (HWND hwnd, HDC hdc, DWORD style)
 
static BOOL get_icon_size (HICON handle, SIZE *size)
 
static HICON STATIC_SetIcon (HWND hwnd, HICON hicon, DWORD style)
 
static HBITMAP STATIC_SetBitmap (HWND hwnd, HBITMAP hBitmap, DWORD style)
 
static HENHMETAFILE STATIC_SetEnhMetaFile (HWND hwnd, HENHMETAFILE hEnhMetaFile, DWORD style)
 
static HANDLE STATIC_GetImage (HWND hwnd, WPARAM wParam, DWORD style)
 
static HICON STATIC_LoadIconW (HINSTANCE hInstance, LPCWSTR name, DWORD style)
 
static VOID STATIC_TryPaintFcn (HWND hwnd, LONG full_style)
 
static HBRUSH STATIC_SendWmCtlColorStatic (HWND hwnd, HDC hdc)
 
static BOOL hasTextStyle (DWORD style)
 
static LRESULT CALLBACK STATIC_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static BOOL CALLBACK STATIC_DrawTextCallback (HDC hdc, LPARAM lp, WPARAM wp, int cx, int cy)
 
void STATIC_Register (void)
 

Variables

static const pfPaint staticPaintFunc [SS_TYPEMASK+1]
 

Macro Definition Documentation

◆ HFONT_GWL_OFFSET

#define HFONT_GWL_OFFSET   0

Definition at line 54 of file static.c.

◆ HICON_GWL_OFFSET

#define HICON_GWL_OFFSET   (sizeof(HFONT))

Definition at line 55 of file static.c.

◆ STATIC_EXTRA_BYTES

#define STATIC_EXTRA_BYTES   (HICON_GWL_OFFSET + sizeof(HICON))

Definition at line 56 of file static.c.

Typedef Documentation

◆ pfPaint

typedef void(* pfPaint) (HWND hwnd, HDC hdc, DWORD style)

Definition at line 58 of file static.c.

Function Documentation

◆ get_icon_size()

static BOOL get_icon_size ( HICON  handle,
SIZE size 
)
static

Definition at line 83 of file static.c.

84{
86 BITMAP bmp;
87 int ret;
88
89 if (!GetIconInfo(handle, &info))
90 return FALSE;
91
92#ifdef __REACTOS__
93 ret = GetObjectW(info.hbmMask, sizeof(bmp), &bmp);
94#else
95 ret = GetObjectW(info.hbmColor, sizeof(bmp), &bmp);
96#endif
97 if (ret)
98 {
99 size->cx = bmp.bmWidth;
100 size->cy = bmp.bmHeight;
101#ifdef __REACTOS__
102 /*
103 If this structure defines a black and white icon, this bitmask is formatted
104 so that the upper half is the icon AND bitmask and the lower half is
105 the icon XOR bitmask.
106 */
107 if (!info.hbmColor)
108 size->cy /= 2;
109#endif
110 }
111
112 DeleteObject(info.hbmMask);
113 DeleteObject(info.hbmColor);
114
115 return !!ret;
116}
#define FALSE
Definition: types.h:117
pKey DeleteObject()
GLsizeiptr size
Definition: glext.h:5919
BITMAP bmp
Definition: alphablend.c:62
Definition: bl.h:1331
int ret
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
BOOL WINAPI GetIconInfo(_In_ HICON, _Out_ PICONINFO)
Definition: cursoricon.c:2097

Referenced by IntDrawState(), STATIC_PaintIconfn(), and STATIC_SetIcon().

◆ hasTextStyle()

static BOOL hasTextStyle ( DWORD  style)
static

Definition at line 306 of file static.c.

307{
308 switch (style & SS_TYPEMASK)
309 {
310 case SS_SIMPLE:
311 case SS_LEFT:
313 case SS_CENTER:
314 case SS_RIGHT:
315 case SS_OWNERDRAW:
316 return TRUE;
317 }
318
319 return FALSE;
320}
Arabic default style
Definition: afstyles.h:94
#define TRUE
Definition: types.h:120
#define SS_RIGHT
Definition: pedump.c:694
#define SS_SIMPLE
Definition: pedump.c:702
#define SS_LEFTNOWORDWRAP
Definition: pedump.c:703
#define SS_CENTER
Definition: pedump.c:693
#define SS_LEFT
Definition: pedump.c:692
#define SS_OWNERDRAW
Definition: winuser.h:352
#define SS_TYPEMASK
Definition: winuser.h:362

Referenced by STATIC_WindowProc(), and StaticWndProc_common().

◆ STATIC_DrawTextCallback()

static BOOL CALLBACK STATIC_DrawTextCallback ( HDC  hdc,
LPARAM  lp,
WPARAM  wp,
int  cx,
int  cy 
)
static

Definition at line 531 of file static.c.

532{
533 RECT rc;
534
535 SetRect(&rc, 0, 0, cx, cy);
536 DrawTextW(hdc, (LPCWSTR)lp, -1, &rc, (UINT)wp);
537 return TRUE;
538}
HDC hdc
Definition: main.c:9
unsigned int UINT
Definition: ndis.h:50
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:16
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
_Out_opt_ int * cx
Definition: commctrl.h:585
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by STATIC_PaintTextfn().

◆ STATIC_GetImage()

static HANDLE STATIC_GetImage ( HWND  hwnd,
WPARAM  wParam,
DWORD  style 
)
static

Definition at line 214 of file static.c.

215{
216 switch (style & SS_TYPEMASK)
217 {
218 case SS_ICON:
219 if ((wParam != IMAGE_ICON) &&
220 (wParam != IMAGE_CURSOR)) return NULL;
221 break;
222 case SS_BITMAP:
223 if (wParam != IMAGE_BITMAP) return NULL;
224 break;
225 case SS_ENHMETAFILE:
226 if (wParam != IMAGE_ENHMETAFILE) return NULL;
227 break;
228 default:
229 return NULL;
230 }
232}
WPARAM wParam
Definition: combotst.c:138
#define NULL
Definition: types.h:112
#define HICON_GWL_OFFSET
Definition: static.c:55
#define SS_BITMAP
Definition: pedump.c:704
#define SS_ICON
Definition: pedump.c:695
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define IMAGE_BITMAP
Definition: winuser.h:211
#define GetWindowLongPtrW
Definition: winuser.h:4832
#define IMAGE_ICON
Definition: winuser.h:212
#define SS_ENHMETAFILE
Definition: winuser.h:341
#define IMAGE_ENHMETAFILE
Definition: winuser.h:214
#define IMAGE_CURSOR
Definition: winuser.h:213

Referenced by STATIC_WindowProc(), and StaticWndProc_common().

◆ STATIC_LoadIconW()

static HICON STATIC_LoadIconW ( HINSTANCE  hInstance,
LPCWSTR  name,
DWORD  style 
)
static

Definition at line 239 of file static.c.

240{
241 HICON hicon = 0;
242
243 if (hInstance && ((ULONG_PTR)hInstance >> 16))
244 {
245 if ((style & SS_REALSIZEIMAGE) != 0)
246 hicon = LoadImageW(hInstance, name, IMAGE_ICON, 0, 0, LR_SHARED);
247 else
248 {
249 hicon = LoadIconW( hInstance, name );
250 if (!hicon) hicon = LoadCursorW( hInstance, name );
251 }
252 }
253 if (!hicon) hicon = LoadIconW( 0, name );
254 /* Windows doesn't try to load a standard cursor,
255 probably because most IDs for standard cursors conflict
256 with the IDs for standard icons anyway */
257 return hicon;
258}
HINSTANCE hInstance
Definition: charmap.c:19
static HICON
Definition: imagelist.c:80
Definition: name.c:39
uint32_t ULONG_PTR
Definition: typedefs.h:65
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE hInst, _In_ LPCWSTR name, _In_ UINT type, _In_ int cx, _In_ int cy, _In_ UINT fuLoad)
Definition: cursoricon.c:2255
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2157
#define SS_REALSIZEIMAGE
Definition: winuser.h:354
#define LR_SHARED
Definition: winuser.h:1103
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE hInstance, _In_ LPCWSTR lpIconName)
Definition: cursoricon.c:2127

Referenced by STATIC_WindowProc(), and StaticWndProc_common().

◆ STATIC_PaintBitmapfn()

static void STATIC_PaintBitmapfn ( HWND  hwnd,
HDC  hdc,
DWORD  style 
)
static

Definition at line 722 of file static.c.

723{
724 HDC hMemDC;
725 HBITMAP hBitmap, oldbitmap;
726 HBRUSH hbrush;
727
729
732 && (hMemDC = CreateCompatibleDC( hdc )))
733 {
734 BITMAP bm;
735 RECT rcClient;
736 LOGBRUSH brush;
737
738 GetObjectW(hBitmap, sizeof(bm), &bm);
739 oldbitmap = SelectObject(hMemDC, hBitmap);
740
741 /* Set the background color for monochrome bitmaps
742 to the color of the background brush */
743 if (GetObjectW( hbrush, sizeof(brush), &brush ))
744 {
745 if (brush.lbStyle == BS_SOLID)
746 SetBkColor(hdc, brush.lbColor);
747 }
748 GetClientRect(hwnd, &rcClient);
749 if (style & SS_CENTERIMAGE)
750 {
751 FillRect( hdc, &rcClient, hbrush );
752 rcClient.left = (rcClient.right - rcClient.left)/2 - bm.bmWidth/2;
753 rcClient.top = (rcClient.bottom - rcClient.top)/2 - bm.bmHeight/2;
754 rcClient.right = rcClient.left + bm.bmWidth;
755 rcClient.bottom = rcClient.top + bm.bmHeight;
756 }
757 StretchBlt(hdc, rcClient.left, rcClient.top, rcClient.right - rcClient.left,
758 rcClient.bottom - rcClient.top, hMemDC,
759 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
760 SelectObject(hMemDC, oldbitmap);
761 DeleteDC(hMemDC);
762 }
763}
static HBRUSH hbrush
static POBJECT_TYPE GetObjectType(IN PCWSTR TypeName)
Definition: ObTypes.c:15
static HBITMAP hBitmap
Definition: timezone.c:26
static HBRUSH STATIC_SendWmCtlColorStatic(HWND hwnd, HDC hdc)
Definition: static.c:285
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:88
#define OBJ_BITMAP
Definition: objidl.idl:1415
UINT lbStyle
Definition: wingdi.h:1747
COLORREF lbColor
Definition: wingdi.h:1748
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
COLORREF WINAPI SetBkColor(_In_ HDC, _In_ COLORREF)
Definition: dc.c:999
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
BOOL WINAPI StretchBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_opt_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
#define SRCCOPY
Definition: wingdi.h:333
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
BOOL WINAPI DeleteDC(_In_ HDC)
#define BS_SOLID
Definition: wingdi.h:1086
#define SS_CENTERIMAGE
Definition: winuser.h:339
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)

◆ STATIC_PaintEnhMetafn()

static void STATIC_PaintEnhMetafn ( HWND  hwnd,
HDC  hdc,
DWORD  style 
)
static

Definition at line 765 of file static.c.

766{
767 HENHMETAFILE hEnhMetaFile;
768 RECT rc;
769 HBRUSH hbrush;
770
771 GetClientRect(hwnd, &rc);
773 FillRect(hdc, &rc, hbrush);
774 if ((hEnhMetaFile = (HENHMETAFILE)GetWindowLongPtrW( hwnd, HICON_GWL_OFFSET )))
775 {
776 /* The control's current font is not selected into the
777 device context! */
778 if (GetObjectType(hEnhMetaFile) == OBJ_ENHMETAFILE)
779 PlayEnhMetaFile(hdc, hEnhMetaFile, &rc);
780 }
781}
#define OBJ_ENHMETAFILE
Definition: objidl.idl:1421
BOOL WINAPI PlayEnhMetaFile(_In_ HDC, _In_ HENHMETAFILE, _In_ LPCRECT)

◆ STATIC_PaintEtchedfn()

static void STATIC_PaintEtchedfn ( HWND  hwnd,
HDC  hdc,
DWORD  style 
)
static

Definition at line 783 of file static.c.

784{
785 RECT rc;
786
787 /* FIXME: sometimes (not always) sends WM_CTLCOLORSTATIC */
788 GetClientRect( hwnd, &rc );
789 switch (style & SS_TYPEMASK)
790 {
791 case SS_ETCHEDHORZ:
793 break;
794 case SS_ETCHEDVERT:
796 break;
797 case SS_ETCHEDFRAME:
799 break;
800 }
801}
#define BF_LEFT
Definition: winuser.h:454
#define SS_ETCHEDFRAME
Definition: winuser.h:342
#define EDGE_ETCHED
Definition: winuser.h:452
#define SS_ETCHEDHORZ
Definition: winuser.h:343
#define BF_BOTTOM
Definition: winuser.h:457
#define SS_ETCHEDVERT
Definition: winuser.h:344
BOOL WINAPI DrawEdge(_In_ HDC, _Inout_ LPRECT, _In_ UINT, _In_ UINT)
#define BF_TOP
Definition: winuser.h:455
#define BF_RIGHT
Definition: winuser.h:456
#define BF_RECT
Definition: winuser.h:462

◆ STATIC_PaintIconfn()

static void STATIC_PaintIconfn ( HWND  hwnd,
HDC  hdc,
DWORD  style 
)
static

Definition at line 691 of file static.c.

692{
693 RECT rc, iconRect;
694 HBRUSH hbrush;
695 HICON hIcon;
696 SIZE size;
697
698 GetClientRect( hwnd, &rc );
701 if (!hIcon || !get_icon_size( hIcon, &size ))
702 {
703 FillRect(hdc, &rc, hbrush);
704 }
705 else
706 {
707 if (style & SS_CENTERIMAGE)
708 {
709 iconRect.left = (rc.right - rc.left) / 2 - size.cx / 2;
710 iconRect.top = (rc.bottom - rc.top) / 2 - size.cy / 2;
711 iconRect.right = iconRect.left + size.cx;
712 iconRect.bottom = iconRect.top + size.cy;
713 }
714 else
715 iconRect = rc;
716 FillRect( hdc, &rc, hbrush );
717 DrawIconEx( hdc, iconRect.left, iconRect.top, hIcon, iconRect.right - iconRect.left,
718 iconRect.bottom - iconRect.top, 0, NULL, DI_NORMAL );
719 }
720}
static BOOL get_icon_size(HICON handle, SIZE *size)
Definition: static.c:83
HICON hIcon
Definition: msconfig.c:44
#define DI_NORMAL
Definition: wingdi.h:72
BOOL WINAPI DrawIconEx(_In_ HDC, _In_ int, _In_ int, _In_ HICON, _In_ int, _In_ int, _In_ UINT, _In_opt_ HBRUSH, _In_ UINT)
Definition: cursoricon.c:2080

◆ STATIC_PaintOwnerDrawfn()

static void STATIC_PaintOwnerDrawfn ( HWND  hwnd,
HDC  hdc,
DWORD  style 
)
static

Definition at line 508 of file static.c.

509{
510 DRAWITEMSTRUCT dis;
511 HFONT font, oldFont = NULL;
513
514 dis.CtlType = ODT_STATIC;
515 dis.CtlID = id;
516 dis.itemID = 0;
519 dis.hwndItem = hwnd;
520 dis.hDC = hdc;
521 dis.itemData = 0;
522 GetClientRect( hwnd, &dis.rcItem );
523
525 if (font) oldFont = SelectObject( hdc, font );
528 if (font) SelectObject( hdc, oldFont );
529}
#define HFONT_GWL_OFFSET
Definition: static.c:54
GLuint id
Definition: glext.h:5910
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
Definition: mk_font.cpp:20
ULONG_PTR itemData
Definition: winuser.h:3096
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
#define ODS_DISABLED
Definition: winuser.h:2550
#define WM_CTLCOLORSTATIC
Definition: winuser.h:1775
#define ODA_DRAWENTIRE
Definition: winuser.h:2545
#define WM_DRAWITEM
Definition: winuser.h:1648
BOOL WINAPI IsWindowEnabled(_In_ HWND)
HWND WINAPI GetParent(_In_ HWND)
#define GWLP_ID
Definition: winuser.h:863
#define ODT_STATIC
Definition: winuser.h:2544
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

◆ STATIC_PaintRectfn()

static void STATIC_PaintRectfn ( HWND  hwnd,
HDC  hdc,
DWORD  style 
)
static

Definition at line 650 of file static.c.

651{
652 RECT rc;
653 HBRUSH hBrush;
654
655 GetClientRect( hwnd, &rc);
656
657 /* FIXME: send WM_CTLCOLORSTATIC */
658 switch (style & SS_TYPEMASK)
659 {
660 case SS_BLACKRECT:
662 FillRect( hdc, &rc, hBrush );
663 break;
664 case SS_GRAYRECT:
666 FillRect( hdc, &rc, hBrush );
667 break;
668 case SS_WHITERECT:
670 FillRect( hdc, &rc, hBrush );
671 break;
672 case SS_BLACKFRAME:
674 FrameRect( hdc, &rc, hBrush );
675 break;
676 case SS_GRAYFRAME:
678 FrameRect( hdc, &rc, hBrush );
679 break;
680 case SS_WHITEFRAME:
682 FrameRect( hdc, &rc, hBrush );
683 break;
684 default:
685 return;
686 }
687 DeleteObject( hBrush );
688}
COMCTL32_SysColor comctl32_color
Definition: commctrl.c:82
#define SS_WHITERECT
Definition: pedump.c:698
#define SS_WHITEFRAME
Definition: pedump.c:701
#define SS_BLACKRECT
Definition: pedump.c:696
#define SS_GRAYFRAME
Definition: pedump.c:700
#define SS_GRAYRECT
Definition: pedump.c:697
#define SS_BLACKFRAME
Definition: pedump.c:699
COLORREF clr3dShadow
Definition: comctl32.h:179
COLORREF clr3dDkShadow
Definition: comctl32.h:180
COLORREF clr3dHilight
Definition: comctl32.h:178
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
int WINAPI FrameRect(_In_ HDC, _In_ LPCRECT, _In_ HBRUSH)

◆ STATIC_PaintTextfn()

static void STATIC_PaintTextfn ( HWND  hwnd,
HDC  hdc,
DWORD  style 
)
static

Definition at line 540 of file static.c.

541{
542 RECT rc;
543 HBRUSH hBrush;
544 HFONT hFont, hOldFont = NULL;
545 UINT format;
546 INT len, buf_size;
547 WCHAR *text;
548
549 GetClientRect( hwnd, &rc);
550
551 switch (style & SS_TYPEMASK)
552 {
553 case SS_LEFT:
555 break;
556
557 case SS_CENTER:
559 break;
560
561 case SS_RIGHT:
563 break;
564
565 case SS_SIMPLE:
567 break;
568
571 break;
572
573 default:
574 return;
575 }
576
579
580 if (style & SS_NOPREFIX)
582
583 if ((style & SS_TYPEMASK) != SS_SIMPLE)
584 {
585 if (style & SS_CENTERIMAGE)
587 if (style & SS_EDITCONTROL)
589 if (style & SS_ENDELLIPSIS)
595 }
596
598 hOldFont = SelectObject( hdc, hFont );
599
600 /* SS_SIMPLE controls: WM_CTLCOLORSTATIC is sent, but the returned
601 brush is not used */
603
604 if ((style & SS_TYPEMASK) != SS_SIMPLE)
605 {
606 FillRect( hdc, &rc, hBrush );
608 }
609
610 buf_size = 256;
611 if (!(text = HeapAlloc( GetProcessHeap(), 0, buf_size * sizeof(WCHAR) )))
612 goto no_TextOut;
613
614 while ((len = InternalGetWindowText( hwnd, text, buf_size )) == buf_size - 1)
615 {
616 buf_size *= 2;
617 if (!(text = HeapReAlloc( GetProcessHeap(), 0, text, buf_size * sizeof(WCHAR) )))
618 goto no_TextOut;
619 }
620
621 if (!len) goto no_TextOut;
622
623 if (((style & SS_TYPEMASK) == SS_SIMPLE) && (style & SS_NOPREFIX))
624 {
625 /* Windows uses the faster ExtTextOut() to draw the text and
626 to paint the whole client rectangle with the text background
627 color. Reference: "Static Controls" by Kyle Marsh, 1992 */
629 &rc, text, len, NULL );
630 }
631 else
632 {
634 if (style & WS_DISABLED)
638 rc.left, rc.top,
639 rc.right - rc.left, rc.bottom - rc.top,
640 flags);
641 }
642
643no_TextOut:
645
646 if (hFont)
647 SelectObject( hdc, hOldFont );
648}
HFONT hFont
Definition: main.c:53
static BOOL CALLBACK STATIC_DrawTextCallback(HDC hdc, LPARAM lp, WPARAM wp, int cx, int cy)
Definition: static.c:531
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapReAlloc
Definition: compat.h:734
#define HeapFree(x, y, z)
Definition: compat.h:735
const WCHAR * text
Definition: package.c:1794
GLbitfield flags
Definition: glext.h:7161
GLenum GLsizei len
Definition: glext.h:6722
#define WS_DISABLED
Definition: pedump.c:621
#define SS_ENDELLIPSIS
Definition: statst2.c:8
Definition: format.c:58
int32_t INT
Definition: typedefs.h:58
#define ETO_CLIPPED
Definition: wingdi.h:648
BOOL WINAPI ExtTextOutW(_In_ HDC hdc, _In_ int x, _In_ int y, _In_ UINT options, _In_opt_ const RECT *lprect, _In_reads_opt_(c) LPCWSTR lpString, _In_ UINT c, _In_reads_opt_(c) const INT *lpDx)
#define ETO_OPAQUE
Definition: wingdi.h:647
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:918
DWORD WINAPI GetSysColor(_In_ int)
#define DT_NOPREFIX
Definition: winuser.h:537
#define COLOR_GRAYTEXT
Definition: winuser.h:935
#define SS_PATHELLIPSIS
Definition: winuser.h:364
#define DT_CENTER
Definition: winuser.h:527
#define DT_END_ELLIPSIS
Definition: winuser.h:529
#define DSS_DISABLED
Definition: winuser.h:519
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
#define DT_SINGLELINE
Definition: winuser.h:540
#define SS_EDITCONTROL
Definition: winuser.h:340
#define SS_NOPREFIX
Definition: winuser.h:350
#define SS_WORDELLIPSIS
Definition: winuser.h:365
#define DT_LEFT
Definition: winuser.h:534
#define DST_COMPLEX
Definition: winuser.h:512
#define DT_WORDBREAK
Definition: winuser.h:544
#define DT_VCENTER
Definition: winuser.h:543
#define DT_WORD_ELLIPSIS
Definition: winuser.h:531
#define DT_RIGHT
Definition: winuser.h:538
#define DT_EXPANDTABS
Definition: winuser.h:532
INT WINAPI InternalGetWindowText(_In_ HWND hWnd, _Out_writes_to_(cchMaxCount, return+1) LPWSTR pString, _In_ int cchMaxCount)
#define DT_EDITCONTROL
Definition: winuser.h:528
BOOL WINAPI DrawStateW(_In_ HDC, _In_opt_ HBRUSH, _In_opt_ DRAWSTATEPROC, _In_ LPARAM, _In_ WPARAM, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define DT_PATH_ELLIPSIS
Definition: winuser.h:530
#define WS_EX_RIGHT
Definition: winuser.h:400
#define GWL_EXSTYLE
Definition: winuser.h:854
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ STATIC_Register()

void STATIC_Register ( void  )

Definition at line 803 of file static.c.

804{
805 WNDCLASSW wndClass;
806
807 memset(&wndClass, 0, sizeof(wndClass));
810 wndClass.cbClsExtra = 0;
812 wndClass.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW);
813 wndClass.hbrBackground = NULL;
814 wndClass.lpszClassName = WC_STATICW;
815 RegisterClassW(&wndClass);
816}
static LRESULT CALLBACK STATIC_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: static.c:322
#define STATIC_EXTRA_BYTES
Definition: static.c:56
#define WC_STATICW
Definition: commctrl.h:4685
#define memset(x, y, z)
Definition: compat.h:39
LPCWSTR lpszClassName
Definition: winuser.h:3188
HBRUSH hbrBackground
Definition: winuser.h:3186
int cbClsExtra
Definition: winuser.h:3181
UINT style
Definition: winuser.h:3179
WNDPROC lpfnWndProc
Definition: winuser.h:3180
int cbWndExtra
Definition: winuser.h:3182
HCURSOR hCursor
Definition: winuser.h:3185
ATOM WINAPI RegisterClassW(_In_ CONST WNDCLASSW *)
#define IDC_ARROW
Definition: winuser.h:687
#define CS_DBLCLKS
Definition: winuser.h:651
#define CS_GLOBALCLASS
Definition: winuser.h:652
#define CS_PARENTDC
Definition: winuser.h:656
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by DllMain().

◆ STATIC_SendWmCtlColorStatic()

static HBRUSH STATIC_SendWmCtlColorStatic ( HWND  hwnd,
HDC  hdc 
)
static

Definition at line 285 of file static.c.

286{
287 HBRUSH hBrush;
289
290 if (!parent) parent = hwnd;
291 hBrush = (HBRUSH) SendMessageW( parent, WM_CTLCOLORSTATIC, (WPARAM)hdc, (LPARAM)hwnd );
292 if (!hBrush) /* did the app forget to call DefWindowProc ? */
293 {
294 /* FIXME: DefWindowProc should return different colors if a
295 manifest is present */
297 }
298 return hBrush;
299}
r parent
Definition: btrfs.c:3010
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by STATIC_PaintBitmapfn(), STATIC_PaintEnhMetafn(), STATIC_PaintIconfn(), STATIC_PaintOwnerDrawfn(), STATIC_PaintRectfn(), and STATIC_PaintTextfn().

◆ STATIC_SetBitmap()

static HBITMAP STATIC_SetBitmap ( HWND  hwnd,
HBITMAP  hBitmap,
DWORD  style 
)
static

Definition at line 159 of file static.c.

160{
161 HBITMAP hOldBitmap;
162
163 if ((style & SS_TYPEMASK) != SS_BITMAP) return 0;
165 {
166 WARN("hBitmap != 0, but it's not a bitmap\n");
167 return 0;
168 }
171 {
172 BITMAP bm;
173 GetObjectW(hBitmap, sizeof(bm), &bm);
174 /* Windows currently doesn't implement SS_RIGHTJUST */
175 /*
176 if ((style & SS_RIGHTJUST) != 0)
177 {
178 RECT wr;
179 GetWindowRect(hwnd, &wr);
180 SetWindowPos( hwnd, 0, wr.right - bm.bmWidth, wr.bottom - bm.bmHeight,
181 bm.bmWidth, bm.bmHeight, SWP_NOACTIVATE | SWP_NOZORDER );
182 }
183 else */
184 {
185 SetWindowPos( hwnd, 0, 0, 0, bm.bmWidth, bm.bmHeight,
187 }
188 }
189 return hOldBitmap;
190}
#define WARN(fmt,...)
Definition: precomp.h:61
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define SWP_NOACTIVATE
Definition: winuser.h:1245
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define SWP_NOMOVE
Definition: winuser.h:1247
#define SS_REALSIZECONTROL
Definition: winuser.h:353
#define SWP_NOZORDER
Definition: winuser.h:1250
#define SetWindowLongPtrW
Definition: winuser.h:5358

Referenced by STATIC_WindowProc(), and StaticWndProc_common().

◆ STATIC_SetEnhMetaFile()

static HENHMETAFILE STATIC_SetEnhMetaFile ( HWND  hwnd,
HENHMETAFILE  hEnhMetaFile,
DWORD  style 
)
static

Definition at line 197 of file static.c.

198{
199 if ((style & SS_TYPEMASK) != SS_ENHMETAFILE) return 0;
200 if (hEnhMetaFile && GetObjectType(hEnhMetaFile) != OBJ_ENHMETAFILE)
201 {
202 WARN("hEnhMetaFile != 0, but it's not an enhanced metafile\n");
203 return 0;
204 }
205 return (HENHMETAFILE)SetWindowLongPtrW( hwnd, HICON_GWL_OFFSET, (LONG_PTR)hEnhMetaFile );
206}

Referenced by STATIC_WindowProc(), and StaticWndProc_common().

◆ STATIC_SetIcon()

static HICON STATIC_SetIcon ( HWND  hwnd,
HICON  hicon,
DWORD  style 
)
static

Definition at line 123 of file static.c.

124{
125 HICON prevIcon;
126 SIZE size;
127
128 if ((style & SS_TYPEMASK) != SS_ICON) return 0;
129 if (hicon && !get_icon_size( hicon, &size ))
130 {
131 WARN("hicon != 0, but invalid\n");
132 return 0;
133 }
134 prevIcon = (HICON)SetWindowLongPtrW( hwnd, HICON_GWL_OFFSET, (LONG_PTR)hicon );
135 if (hicon && !(style & SS_CENTERIMAGE) && !(style & SS_REALSIZECONTROL))
136 {
137 /* Windows currently doesn't implement SS_RIGHTJUST */
138 /*
139 if ((style & SS_RIGHTJUST) != 0)
140 {
141 RECT wr;
142 GetWindowRect(hwnd, &wr);
143 SetWindowPos( hwnd, 0, wr.right - info->nWidth, wr.bottom - info->nHeight,
144 info->nWidth, info->nHeight, SWP_NOACTIVATE | SWP_NOZORDER );
145 }
146 else */
147 {
149 }
150 }
151 return prevIcon;
152}

Referenced by STATIC_WindowProc(), and StaticWndProc_common().

◆ STATIC_TryPaintFcn()

static VOID STATIC_TryPaintFcn ( HWND  hwnd,
LONG  full_style 
)
static

Definition at line 265 of file static.c.

266{
267 LONG style = full_style & SS_TYPEMASK;
268 RECT rc;
269
270 GetClientRect( hwnd, &rc );
272 {
273 HDC hdc;
274 HRGN hrgn;
275
276 hdc = GetDC( hwnd );
277 hrgn = set_control_clipping( hdc, &rc );
278 (staticPaintFunc[style])( hwnd, hdc, full_style );
280 if (hrgn) DeleteObject( hrgn );
281 ReleaseDC( hwnd, hdc );
282 }
283}
static HRGN hrgn
HRGN set_control_clipping(HDC hdc, const RECT *rect)
Definition: button.c:242
static const pfPaint staticPaintFunc[SS_TYPEMASK+1]
Definition: static.c:60
long LONG
Definition: pedump.c:60
int WINAPI SelectClipRgn(_In_ HDC, _In_opt_ HRGN)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
BOOL WINAPI IsRectEmpty(_In_ LPCRECT)
HDC WINAPI GetDC(_In_opt_ HWND)
BOOL WINAPI IsWindowVisible(_In_ HWND)

Referenced by STATIC_WindowProc(), and StaticWndProc_common().

◆ STATIC_WindowProc()

static LRESULT CALLBACK STATIC_WindowProc ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 322 of file static.c.

323{
324 LRESULT lResult = 0;
325 LONG full_style = GetWindowLongW( hwnd, GWL_STYLE );
326 LONG style = full_style & SS_TYPEMASK;
327
328 if (!IsWindow( hwnd )) return 0;
329
330 switch (uMsg)
331 {
332 case WM_CREATE:
333 if (style < 0L || style > SS_TYPEMASK)
334 {
335 ERR("Unknown style 0x%02x\n", style );
336 return -1;
337 }
338 break;
339
340 case WM_NCDESTROY:
341 if (style == SS_ICON)
342 {
343/*
344 * FIXME
345 * DestroyIcon32( STATIC_SetIcon( wndPtr, 0 ) );
346 *
347 * We don't want to do this yet because DestroyIcon32 is broken. If the icon
348 * had already been loaded by the application the last thing we want to do is
349 * GlobalFree16 the handle.
350 */
351 break;
352 }
353 else
354 return DefWindowProcW(hwnd, uMsg, wParam, lParam);
355
356 case WM_ERASEBKGND:
357 /* do all painting in WM_PAINT like Windows does */
358 return 1;
359
360 case WM_PRINTCLIENT:
361 case WM_PAINT:
362 {
363 PAINTSTRUCT ps;
364 RECT rect;
365 HDC hdc = wParam ? (HDC)wParam : BeginPaint(hwnd, &ps);
368 {
369 HRGN hrgn = set_control_clipping( hdc, &rect );
370 (staticPaintFunc[style])( hwnd, hdc, full_style );
372 if (hrgn) DeleteObject( hrgn );
373 }
374 if (!wParam) EndPaint(hwnd, &ps);
375 }
376 break;
377
378 case WM_ENABLE:
379 STATIC_TryPaintFcn( hwnd, full_style );
380 if (full_style & SS_NOTIFY)
381 {
382 if (wParam)
385 else
388 }
389 break;
390
393 STATIC_TryPaintFcn( hwnd, full_style );
394 break;
395
396 case WM_NCCREATE:
397 {
399
400 if (full_style & SS_SUNKEN)
403
404 switch (style)
405 {
406 case SS_ICON:
407 {
408 HICON hIcon;
409
410 hIcon = STATIC_LoadIconW(cs->hInstance, cs->lpszName, full_style);
411 STATIC_SetIcon(hwnd, hIcon, full_style);
412 }
413 break;
414 case SS_BITMAP:
415 if ((ULONG_PTR)cs->hInstance >> 16)
416 {
418 hBitmap = LoadBitmapW(cs->hInstance, cs->lpszName);
419 STATIC_SetBitmap(hwnd, hBitmap, full_style);
420 }
421 break;
422 }
423 /* SS_ENHMETAFILE: Despite what MSDN says, Windows does not load
424 the enhanced metafile that was specified as the window text. */
425 }
426 return DefWindowProcW(hwnd, uMsg, wParam, lParam);
427
428 case WM_SETTEXT:
429 if (hasTextStyle( full_style ))
430 {
431 lResult = DefWindowProcW( hwnd, uMsg, wParam, lParam );
432 STATIC_TryPaintFcn( hwnd, full_style );
433 }
434 break;
435
436 case WM_SETFONT:
437 if (hasTextStyle( full_style ))
438 {
440 if (LOWORD(lParam))
442 }
443 break;
444
445 case WM_GETFONT:
447
448 case WM_NCHITTEST:
449 if (full_style & SS_NOTIFY)
450 return HTCLIENT;
451 else
452 return HTTRANSPARENT;
453
454 case WM_GETDLGCODE:
455 return DLGC_STATIC;
456
457 case WM_LBUTTONDOWN:
458 case WM_NCLBUTTONDOWN:
459 if (full_style & SS_NOTIFY)
462 return 0;
463
464 case WM_LBUTTONDBLCLK:
466 if (full_style & SS_NOTIFY)
469 return 0;
470
471 case STM_GETIMAGE:
472 return (LRESULT)STATIC_GetImage( hwnd, wParam, full_style );
473
474 case STM_GETICON:
475 return (LRESULT)STATIC_GetImage( hwnd, IMAGE_ICON, full_style );
476
477 case STM_SETIMAGE:
478 switch (wParam)
479 {
480 case IMAGE_BITMAP:
481 lResult = (LRESULT)STATIC_SetBitmap( hwnd, (HBITMAP)lParam, full_style );
482 break;
484 lResult = (LRESULT)STATIC_SetEnhMetaFile( hwnd, (HENHMETAFILE)lParam, full_style );
485 break;
486 case IMAGE_ICON:
487 case IMAGE_CURSOR:
488 lResult = (LRESULT)STATIC_SetIcon( hwnd, (HICON)lParam, full_style );
489 break;
490 default:
491 FIXME("STM_SETIMAGE: Unhandled type %lx\n", wParam);
492 break;
493 }
494 STATIC_TryPaintFcn( hwnd, full_style );
495 break;
496
497 case STM_SETICON:
498 lResult = (LRESULT)STATIC_SetIcon( hwnd, (HICON)wParam, full_style );
499 STATIC_TryPaintFcn( hwnd, full_style );
500 break;
501
502 default:
503 return DefWindowProcW(hwnd, uMsg, wParam, lParam);
504 }
505 return lResult;
506}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define ERR(fmt,...)
Definition: precomp.h:57
LPARAM lParam
Definition: combotst.c:139
VOID COMCTL32_RefreshSysColors(void) DECLSPEC_HIDDEN
Definition: commctrl.c:1593
static HBITMAP STATIC_SetBitmap(HWND hwnd, HBITMAP hBitmap, DWORD style)
Definition: static.c:159
static HICON STATIC_LoadIconW(HINSTANCE hInstance, LPCWSTR name, DWORD style)
Definition: static.c:239
static HICON STATIC_SetIcon(HWND hwnd, HICON hicon, DWORD style)
Definition: static.c:123
static BOOL hasTextStyle(DWORD style)
Definition: static.c:306
static HANDLE STATIC_GetImage(HWND hwnd, WPARAM wParam, DWORD style)
Definition: static.c:214
static VOID STATIC_TryPaintFcn(HWND hwnd, LONG full_style)
Definition: static.c:265
static HENHMETAFILE STATIC_SetEnhMetaFile(HWND hwnd, HENHMETAFILE hEnhMetaFile, DWORD style)
Definition: static.c:197
#define cs
Definition: i386-dis.c:442
#define LRESULT
Definition: ole.h:14
#define LOWORD(l)
Definition: pedump.c:82
#define WM_PRINTCLIENT
Definition: richedit.h:70
& rect
Definition: startmenu.cpp:1413
LONG_PTR LRESULT
Definition: windef.h:209
#define WM_PAINT
Definition: winuser.h:1623
#define WM_ERASEBKGND
Definition: winuser.h:1628
#define MAKEWPARAM(l, h)
Definition: winuser.h:4012
#define WS_EX_STATICEDGE
Definition: winuser.h:403
BOOL WINAPI IsWindow(_In_opt_ HWND)
BOOL WINAPI RedrawWindow(_In_opt_ HWND, _In_opt_ LPCRECT, _In_opt_ HRGN, _In_ UINT)
#define WM_ENABLE
Definition: winuser.h:1618
#define STM_SETICON
Definition: winuser.h:2095
#define WM_CREATE
Definition: winuser.h:1611
LONG WINAPI SetWindowLongW(_In_ HWND, _In_ int, _In_ LONG)
#define WM_LBUTTONDBLCLK
Definition: winuser.h:1781
#define WM_COMMAND
Definition: winuser.h:1743
#define SS_NOTIFY
Definition: winuser.h:351
#define WM_NCHITTEST
Definition: winuser.h:1689
#define RDW_UPDATENOW
Definition: winuser.h:1223
#define RDW_ERASE
Definition: winuser.h:1214
#define WM_LBUTTONDOWN
Definition: winuser.h:1779
#define WM_SYSCOLORCHANGE
Definition: winuser.h:1629
#define WM_GETFONT
Definition: winuser.h:1654
#define STM_SETIMAGE
Definition: winuser.h:2096
#define WM_NCLBUTTONDBLCLK
Definition: winuser.h:1697
#define WM_NCCREATE
Definition: winuser.h:1686
#define STM_GETICON
Definition: winuser.h:2093
#define STN_DISABLE
Definition: winuser.h:2099
#define WM_SETTEXT
Definition: winuser.h:1620
#define RDW_ALLCHILDREN
Definition: winuser.h:1224
#define WM_SETFONT
Definition: winuser.h:1653
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
#define HTCLIENT
Definition: winuser.h:2478
#define DLGC_STATIC
Definition: winuser.h:2622
#define WM_NCDESTROY
Definition: winuser.h:1687
#define HTTRANSPARENT
Definition: winuser.h:2476
HBITMAP WINAPI LoadBitmapW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2215
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
#define GWL_STYLE
Definition: winuser.h:855
#define STN_DBLCLK
Definition: winuser.h:2098
#define STM_GETIMAGE
Definition: winuser.h:2094
#define SS_SUNKEN
Definition: winuser.h:358
#define STN_ENABLE
Definition: winuser.h:2100
#define WM_NCLBUTTONDOWN
Definition: winuser.h:1695
#define STN_CLICKED
Definition: winuser.h:2097
#define RDW_INVALIDATE
Definition: winuser.h:1217
#define WM_GETDLGCODE
Definition: winuser.h:1692

Referenced by STATIC_Register().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( static  )

Variable Documentation

◆ staticPaintFunc

const pfPaint staticPaintFunc[SS_TYPEMASK+1]
static
Initial value:
=
{
NULL,
}
static void STATIC_PaintEnhMetafn(HWND hwnd, HDC hdc, DWORD style)
Definition: static.c:765
static void STATIC_PaintOwnerDrawfn(HWND hwnd, HDC hdc, DWORD style)
Definition: static.c:508
static void STATIC_PaintTextfn(HWND hwnd, HDC hdc, DWORD style)
Definition: static.c:540
static void STATIC_PaintRectfn(HWND hwnd, HDC hdc, DWORD style)
Definition: static.c:650
static void STATIC_PaintBitmapfn(HWND hwnd, HDC hdc, DWORD style)
Definition: static.c:722
static void STATIC_PaintIconfn(HWND hwnd, HDC hdc, DWORD style)
Definition: static.c:691
static void STATIC_PaintEtchedfn(HWND hwnd, HDC hdc, DWORD style)
Definition: static.c:783

Definition at line 60 of file static.c.

Referenced by STATIC_TryPaintFcn(), STATIC_WindowProc(), and StaticWndProc_common().