Remove ANSI window proc and related funcs, fix color of SS_*RECT/SS_*FRAME

styles, fix SS_ETCHEDHORZ and SS_ETCHEDVERT styles, fix clipping

svn path=/trunk/; revision=5607
This commit is contained in:
Gé van Geldorp 2003-08-16 21:34:18 +00:00
parent 2ef7538593
commit 8d77a084ae

View file

@ -1,4 +1,4 @@
/* $Id: static.c,v 1.4 2003/08/15 15:55:02 weiden Exp $ /* $Id: static.c,v 1.5 2003/08/16 21:34:18 gvg Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS User32 * PROJECT: ReactOS User32
@ -21,7 +21,7 @@ static void STATIC_PaintEtchedfn( HWND hwnd, HDC hdc, DWORD style );
//static LRESULT CALLBACK StaticWndProcA( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ); //static LRESULT CALLBACK StaticWndProcA( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
static LRESULT CALLBACK StaticWndProcW( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ); static LRESULT CALLBACK StaticWndProcW( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
static COLORREF color_windowframe, color_background, color_window; static COLORREF color_black, color_gray, color_white;
/* offsets for GetWindowLong for static private information */ /* offsets for GetWindowLong for static private information */
#define HFONT_GWL_OFFSET 0 #define HFONT_GWL_OFFSET 0
@ -60,7 +60,7 @@ static pfPaint staticPaintFunc[SS_TYPEMASK+1] =
const struct builtin_class_descr STATIC_builtin_class = const struct builtin_class_descr STATIC_builtin_class =
{ {
L"Static", /* name */ L"Static", /* name */
CS_GLOBALCLASS | CS_DBLCLKS | CS_PARENTDC, /* style */ CS_GLOBALCLASS | CS_DBLCLKS, /* style */
(WNDPROC) StaticWndProcW, /* procW */ (WNDPROC) StaticWndProcW, /* procW */
STATIC_EXTRA_BYTES, /* extra */ STATIC_EXTRA_BYTES, /* extra */
(LPCWSTR) IDC_ARROW, /* cursor */ /* FIXME Wine uses IDC_ARROWA */ (LPCWSTR) IDC_ARROW, /* cursor */ /* FIXME Wine uses IDC_ARROWA */
@ -123,19 +123,6 @@ static HBITMAP STATIC_SetBitmap( HWND hwnd, HBITMAP hBitmap, DWORD style )
return hOldBitmap; return hOldBitmap;
} }
/***********************************************************************
* STATIC_LoadIconA
*
* Load the icon for an SS_ICON control.
*/
static HICON STATIC_LoadIconA( HWND hwnd, LPCSTR name )
{
HINSTANCE hInstance = (HINSTANCE)GetWindowLongA( hwnd, GWL_HINSTANCE );
HICON hicon = LoadIconA( hInstance, name );
if (!hicon) hicon = LoadIconA( 0, name );
return hicon;
}
/*********************************************************************** /***********************************************************************
* STATIC_LoadIconW * STATIC_LoadIconW
* *
@ -149,20 +136,6 @@ static HICON STATIC_LoadIconW( HWND hwnd, LPCWSTR name )
return hicon; return hicon;
} }
/***********************************************************************
* STATIC_LoadBitmapA
*
* Load the bitmap for an SS_BITMAP control.
*/
static HBITMAP STATIC_LoadBitmapA( HWND hwnd, LPCSTR name )
{
HINSTANCE hInstance = (HINSTANCE)GetWindowLongA( hwnd, GWL_HINSTANCE );
HBITMAP hbitmap = LoadBitmapA( hInstance, name );
if (!hbitmap) /* Try OEM icon (FIXME: is this right?) */
hbitmap = LoadBitmapA( 0, name );
return hbitmap;
}
/*********************************************************************** /***********************************************************************
* STATIC_LoadBitmapW * STATIC_LoadBitmapW
* *
@ -198,15 +171,15 @@ static VOID STATIC_TryPaintFcn(HWND hwnd, LONG full_style)
} }
/*********************************************************************** /***********************************************************************
* StaticWndProc_common * StaticWndProcW
*/ */
static LRESULT StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam, static LRESULT CALLBACK StaticWndProcW( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
LPARAM lParam, BOOL unicode )
{ {
LRESULT lResult = 0; LRESULT lResult = 0;
LONG full_style = GetWindowLongA( hwnd, GWL_STYLE ); LONG full_style = GetWindowLongA( hwnd, GWL_STYLE );
LONG style = full_style & SS_TYPEMASK; LONG style = full_style & SS_TYPEMASK;
if (!IsWindow( hwnd )) return 0;
switch (uMsg) switch (uMsg)
{ {
case WM_CREATE: case WM_CREATE:
@ -216,9 +189,9 @@ static LRESULT StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam,
return -1; return -1;
} }
/* initialise colours */ /* initialise colours */
color_windowframe = GetSysColor(COLOR_WINDOWFRAME); color_black = GetSysColor(COLOR_3DDKSHADOW);
color_background = GetSysColor(COLOR_BACKGROUND); color_gray = GetSysColor(COLOR_3DSHADOW);
color_window = GetSysColor(COLOR_WINDOW); color_white = GetSysColor(COLOR_3DHILIGHT);
break; break;
case WM_NCDESTROY: case WM_NCDESTROY:
@ -233,8 +206,7 @@ static LRESULT StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam,
*/ */
break; break;
} }
else return unicode ? DefWindowProcW(hwnd, uMsg, wParam, lParam) : else return DefWindowProcW(hwnd, uMsg, wParam, lParam);
DefWindowProcA(hwnd, uMsg, wParam, lParam);
case WM_PAINT: case WM_PAINT:
{ {
@ -251,9 +223,9 @@ static LRESULT StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam,
break; break;
case WM_SYSCOLORCHANGE: case WM_SYSCOLORCHANGE:
color_windowframe = GetSysColor(COLOR_WINDOWFRAME); color_black = GetSysColor(COLOR_3DDKSHADOW);
color_background = GetSysColor(COLOR_BACKGROUND); color_gray = GetSysColor(COLOR_3DSHADOW);
color_window = GetSysColor(COLOR_WINDOW); color_white = GetSysColor(COLOR_3DHILIGHT);
InvalidateRect(hwnd, NULL, TRUE); InvalidateRect(hwnd, NULL, TRUE);
break; break;
@ -262,20 +234,14 @@ static LRESULT StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam,
SetWindowLongA( hwnd, GWL_EXSTYLE, SetWindowLongA( hwnd, GWL_EXSTYLE,
GetWindowLongA( hwnd, GWL_EXSTYLE ) | WS_EX_STATICEDGE ); GetWindowLongA( hwnd, GWL_EXSTYLE ) | WS_EX_STATICEDGE );
if(unicode) lParam = (LPARAM)(((LPCREATESTRUCTW)lParam)->lpszName);
lParam = (LPARAM)(((LPCREATESTRUCTW)lParam)->lpszName);
else
lParam = (LPARAM)(((LPCREATESTRUCTA)lParam)->lpszName);
/* fall through */ /* fall through */
case WM_SETTEXT: case WM_SETTEXT:
switch (style) { switch (style) {
case SS_ICON: case SS_ICON:
{ {
HICON hIcon; HICON hIcon;
if(unicode) hIcon = STATIC_LoadIconW(hwnd, (LPCWSTR)lParam);
hIcon = STATIC_LoadIconW(hwnd, (LPCWSTR)lParam);
else
hIcon = STATIC_LoadIconA(hwnd, (LPCSTR)lParam);
/* FIXME : should we also return the previous hIcon here ??? */ /* FIXME : should we also return the previous hIcon here ??? */
STATIC_SetIcon(hwnd, hIcon, style); STATIC_SetIcon(hwnd, hIcon, style);
break; break;
@ -283,10 +249,7 @@ static LRESULT StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam,
case SS_BITMAP: case SS_BITMAP:
{ {
HBITMAP hBitmap; HBITMAP hBitmap;
if(unicode) hBitmap = STATIC_LoadBitmapW(hwnd, (LPCWSTR)lParam);
hBitmap = STATIC_LoadBitmapW(hwnd, (LPCWSTR)lParam);
else
hBitmap = STATIC_LoadBitmapA(hwnd, (LPCSTR)lParam);
STATIC_SetBitmap(hwnd, hBitmap, style); STATIC_SetBitmap(hwnd, hBitmap, style);
break; break;
} }
@ -298,10 +261,7 @@ static LRESULT StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam,
{ {
if (HIWORD(lParam)) if (HIWORD(lParam))
{ {
if(unicode) lResult = DefWindowProcW( hwnd, WM_SETTEXT, wParam, lParam );
lResult = DefWindowProcW( hwnd, WM_SETTEXT, wParam, lParam );
else
lResult = DefWindowProcA( hwnd, WM_SETTEXT, wParam, lParam );
} }
if (uMsg == WM_SETTEXT) if (uMsg == WM_SETTEXT)
STATIC_TryPaintFcn( hwnd, full_style ); STATIC_TryPaintFcn( hwnd, full_style );
@ -310,10 +270,7 @@ static LRESULT StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam,
default: default:
if (HIWORD(lParam)) if (HIWORD(lParam))
{ {
if(unicode) lResult = DefWindowProcW( hwnd, WM_SETTEXT, wParam, lParam );
lResult = DefWindowProcW( hwnd, WM_SETTEXT, wParam, lParam );
else
lResult = DefWindowProcA( hwnd, WM_SETTEXT, wParam, lParam );
} }
if(uMsg == WM_SETTEXT) if(uMsg == WM_SETTEXT)
InvalidateRect(hwnd, NULL, TRUE); InvalidateRect(hwnd, NULL, TRUE);
@ -364,32 +321,11 @@ static LRESULT StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam,
break; break;
default: default:
return unicode ? DefWindowProcW(hwnd, uMsg, wParam, lParam) : return DefWindowProcW(hwnd, uMsg, wParam, lParam);
DefWindowProcA(hwnd, uMsg, wParam, lParam);
} }
return lResult; return lResult;
} }
#if 0
/***********************************************************************
* StaticWndProcA
*/
static LRESULT CALLBACK StaticWndProcA( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
if (!IsWindow( hWnd )) return 0;
return StaticWndProc_common(hWnd, uMsg, wParam, lParam, FALSE);
}
#endif
/***********************************************************************
* StaticWndProcW
*/
static LRESULT CALLBACK StaticWndProcW( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
if (!IsWindow( hWnd )) return 0;
return StaticWndProc_common(hWnd, uMsg, wParam, lParam, TRUE);
}
static void STATIC_PaintOwnerDrawfn( HWND hwnd, HDC hdc, DWORD style ) static void STATIC_PaintOwnerDrawfn( HWND hwnd, HDC hdc, DWORD style )
{ {
DRAWITEMSTRUCT dis; DRAWITEMSTRUCT dis;
@ -479,27 +415,27 @@ static void STATIC_PaintRectfn( HWND hwnd, HDC hdc, DWORD style )
switch (style & SS_TYPEMASK) switch (style & SS_TYPEMASK)
{ {
case SS_BLACKRECT: case SS_BLACKRECT:
hBrush = CreateSolidBrush(color_windowframe); hBrush = CreateSolidBrush(color_black);
FillRect( hdc, &rc, hBrush ); FillRect( hdc, &rc, hBrush );
break; break;
case SS_GRAYRECT: case SS_GRAYRECT:
hBrush = CreateSolidBrush(color_background); hBrush = CreateSolidBrush(color_gray);
FillRect( hdc, &rc, hBrush ); FillRect( hdc, &rc, hBrush );
break; break;
case SS_WHITERECT: case SS_WHITERECT:
hBrush = CreateSolidBrush(color_window); hBrush = CreateSolidBrush(color_white);
FillRect( hdc, &rc, hBrush ); FillRect( hdc, &rc, hBrush );
break; break;
case SS_BLACKFRAME: case SS_BLACKFRAME:
hBrush = CreateSolidBrush(color_windowframe); hBrush = CreateSolidBrush(color_black);
FrameRect( hdc, &rc, hBrush ); FrameRect( hdc, &rc, hBrush );
break; break;
case SS_GRAYFRAME: case SS_GRAYFRAME:
hBrush = CreateSolidBrush(color_background); hBrush = CreateSolidBrush(color_gray);
FrameRect( hdc, &rc, hBrush ); FrameRect( hdc, &rc, hBrush );
break; break;
case SS_WHITEFRAME: case SS_WHITEFRAME:
hBrush = CreateSolidBrush(color_window); hBrush = CreateSolidBrush(color_white);
FrameRect( hdc, &rc, hBrush ); FrameRect( hdc, &rc, hBrush );
break; break;
default: default:
@ -561,10 +497,18 @@ static void STATIC_PaintEtchedfn( HWND hwnd, HDC hdc, DWORD style )
switch (style & SS_TYPEMASK) switch (style & SS_TYPEMASK)
{ {
case SS_ETCHEDHORZ: case SS_ETCHEDHORZ:
#if 0 /* This is what seems logical */
DrawEdge(hdc,&rc,EDGE_ETCHED,BF_TOP|BF_BOTTOM); DrawEdge(hdc,&rc,EDGE_ETCHED,BF_TOP|BF_BOTTOM);
#else /* But this is what NT, Win2k and WinXP actually do */
DrawEdge(hdc,&rc,EDGE_ETCHED,BF_TOP);
#endif
break; break;
case SS_ETCHEDVERT: case SS_ETCHEDVERT:
#if 0 /* This is what seems logical */
DrawEdge(hdc,&rc,EDGE_ETCHED,BF_LEFT|BF_RIGHT); DrawEdge(hdc,&rc,EDGE_ETCHED,BF_LEFT|BF_RIGHT);
#else /* But this is what NT, Win2k and WinXP actually do */
DrawEdge(hdc,&rc,EDGE_ETCHED,BF_LEFT);
#endif
break; break;
case SS_ETCHEDFRAME: case SS_ETCHEDFRAME:
DrawEdge (hdc, &rc, EDGE_ETCHED, BF_RECT); DrawEdge (hdc, &rc, EDGE_ETCHED, BF_RECT);