*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
* NOTES
*
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_PaintEnhMetafn( HWND hwnd, HDC hdc, DWORD style );
static void STATIC_PaintEtchedfn( HWND hwnd, HDC hdc, DWORD style );
-static LRESULT WINAPI StaticWndProcA( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
-static LRESULT WINAPI StaticWndProcW( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
+//static LRESULT WINAPI StaticWndProcA( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
+//static LRESULT WINAPI StaticWndProcW( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
static COLORREF color_3dshadow, color_3ddkshadow, color_3dhighlight;
typedef void (*pfPaint)( HWND hwnd, HDC hdc, DWORD style );
-static pfPaint staticPaintFunc[SS_TYPEMASK+1] =
+static const pfPaint staticPaintFunc[SS_TYPEMASK+1] =
{
STATIC_PaintTextfn, /* SS_LEFT */
STATIC_PaintTextfn, /* SS_CENTER */
STATIC_PaintTextfn, /* SS_LEFTNOWORDWRAP */
STATIC_PaintOwnerDrawfn, /* SS_OWNERDRAW */
STATIC_PaintBitmapfn, /* SS_BITMAP */
- NULL, /* STATIC_PaintEnhMetafn, SS_ENHMETAFILE */
+ STATIC_PaintEnhMetafn, /* SS_ENHMETAFILE */
STATIC_PaintEtchedfn, /* SS_ETCHEDHORZ */
STATIC_PaintEtchedfn, /* SS_ETCHEDVERT */
STATIC_PaintEtchedfn, /* SS_ETCHEDFRAME */
/*********************************************************************
* static class descriptor
*/
+static const WCHAR staticW[] = {'S','t','a','t','i','c',0};
const struct builtin_class_descr STATIC_builtin_class =
{
- L"Static", /* name */
+ staticW, /* name */
CS_DBLCLKS | CS_PARENTDC, /* style */
StaticWndProcA, /* procA */
StaticWndProcW, /* procW */
0 /* brush */
};
+/* REACTOS ONLY */
static __inline void set_ui_state( HWND hwnd, LONG flags )
{
- SetWindowLongW( hwnd, UISTATE_GWL_OFFSET, flags );
+ SetWindowLongPtrW( hwnd, UISTATE_GWL_OFFSET, flags );
}
static __inline LONG get_ui_state( HWND hwnd )
return GetWindowLongPtrW( hwnd, UISTATE_GWL_OFFSET );
}
+/* Retrieve the UI state for the control */
+static BOOL STATIC_update_uistate(HWND hwnd, BOOL unicode)
+{
+ LONG flags, prevflags;
+
+ if (unicode)
+ flags = DefWindowProcW(hwnd, WM_QUERYUISTATE, 0, 0);
+ else
+ flags = DefWindowProcA(hwnd, WM_QUERYUISTATE, 0, 0);
+
+ prevflags = get_ui_state(hwnd);
+
+ if (prevflags != flags)
+ {
+ set_ui_state(hwnd, flags);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/* END REACTOS ONLY */
+
static void setup_clipping(HWND hwnd, HDC hdc, HRGN *orig)
{
RECT rc;
DeleteObject(hrgn);
}
-/* Retrieve the UI state for the control */
-static BOOL STATIC_update_uistate(HWND hwnd, BOOL unicode)
-{
- LONG flags, prevflags;
-
- if (unicode)
- flags = DefWindowProcW(hwnd, WM_QUERYUISTATE, 0, 0);
- else
- flags = DefWindowProcA(hwnd, WM_QUERYUISTATE, 0, 0);
-
- prevflags = get_ui_state(hwnd);
-
- if (prevflags != flags)
- {
- set_ui_state(hwnd, flags);
- return TRUE;
- }
-
- return FALSE;
-}
-
/***********************************************************************
* STATIC_SetIcon
*
SetWindowPos( hwnd, 0, 0, 0, bm.bmWidth, bm.bmHeight,
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER );
}
+
}
return hOldBitmap;
}
*
* Set the enhanced metafile for an SS_ENHMETAFILE control.
*/
-//static HENHMETAFILE STATIC_SetEnhMetaFile( HWND hwnd, HENHMETAFILE hEnhMetaFile, DWORD style )
-//{
-// if ((style & SS_TYPEMASK) != SS_ENHMETAFILE) return 0;
-// if (hEnhMetaFile && GetObjectType(hEnhMetaFile) != OBJ_ENHMETAFILE) {
-// WARN("hEnhMetaFile != 0, but it's not an enhanced metafile\n");
-// return 0;
-// }
-// return (HENHMETAFILE)SetWindowLongPtrW( hwnd, HICON_GWL_OFFSET, (LONG_PTR)hEnhMetaFile );
-//}
+static HENHMETAFILE STATIC_SetEnhMetaFile( HWND hwnd, HENHMETAFILE hEnhMetaFile, DWORD style )
+{
+ if ((style & SS_TYPEMASK) != SS_ENHMETAFILE) return 0;
+ if (hEnhMetaFile && GetObjectType(hEnhMetaFile) != OBJ_ENHMETAFILE) {
+ WARN("hEnhMetaFile != 0, but it's not an enhanced metafile\n");
+ return 0;
+ }
+ return (HENHMETAFILE)SetWindowLongPtrW( hwnd, HICON_GWL_OFFSET, (LONG_PTR)hEnhMetaFile );
+}
/***********************************************************************
* STATIC_GetImage
*
* Load the icon for an SS_ICON control.
*/
-static HICON STATIC_LoadIconA( HWND hwnd, LPCSTR name, DWORD style )
+static HICON STATIC_LoadIconA( HINSTANCE hInstance, LPCSTR name, DWORD style )
{
- HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtrW( hwnd, GWLP_HINSTANCE );
- if ((style & SS_REALSIZEIMAGE) != 0)
+ HICON hicon = 0;
+
+ if (hInstance && ((ULONG_PTR)hInstance >> 16))
{
- return LoadImageA(hInstance, name, IMAGE_ICON, 0, 0, LR_SHARED);
+ if ((style & SS_REALSIZEIMAGE) != 0)
+ hicon = LoadImageA(hInstance, name, IMAGE_ICON, 0, 0, LR_SHARED);
+ else
+ {
+ hicon = LoadIconA( hInstance, name );
+ if (!hicon) hicon = LoadCursorA( hInstance, name );
+ }
}
- else
- {
- HICON hicon = LoadIconA( hInstance, name );
- if (!hicon) hicon = LoadCursorA( hInstance, name );
- if (!hicon) hicon = LoadIconA( 0, name );
- /* Windows doesn't try to load a standard cursor,
- probably because most IDs for standard cursors conflict
- with the IDs for standard icons anyway */
+ if (!hicon) hicon = LoadIconA( 0, name );
+ /* Windows doesn't try to load a standard cursor,
+ probably because most IDs for standard cursors conflict
+ with the IDs for standard icons anyway */
return hicon;
- }
}
/***********************************************************************
*
* Load the icon for an SS_ICON control.
*/
-static HICON STATIC_LoadIconW( HWND hwnd, LPCWSTR name, DWORD style )
+static HICON STATIC_LoadIconW( HINSTANCE hInstance, LPCWSTR name, DWORD style )
{
- HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtrW( hwnd, GWLP_HINSTANCE );
- if ((style & SS_REALSIZEIMAGE) != 0)
- {
- return LoadImageW(hInstance, name, IMAGE_ICON, 0, 0, LR_SHARED);
- }
- else
+ HICON hicon = 0;
+
+ if (hInstance && ((ULONG_PTR)hInstance >> 16))
{
- HICON hicon = LoadIconW( hInstance, name );
- if (!hicon) hicon = LoadCursorW( hInstance, name );
- if (!hicon) hicon = LoadIconW( 0, name );
- /* Windows doesn't try to load a standard cursor,
- probably because most IDs for standard cursors conflict
- with the IDs for standard icons anyway */
- return hicon;
+ if ((style & SS_REALSIZEIMAGE) != 0)
+ hicon = LoadImageW(hInstance, name, IMAGE_ICON, 0, 0, LR_SHARED);
+ else
+ {
+ hicon = LoadIconW( hInstance, name );
+ if (!hicon) hicon = LoadCursorW( hInstance, name );
+ }
}
+ if (!hicon) hicon = LoadIconW( 0, name );
+ /* Windows doesn't try to load a standard cursor,
+ probably because most IDs for standard cursors conflict
+ with the IDs for standard icons anyway */
+ return hicon;
}
-/***********************************************************************
- * STATIC_LoadBitmapA
- *
- * Load the bitmap for an SS_BITMAP control.
- */
-static HBITMAP STATIC_LoadBitmapA( HWND hwnd, LPCSTR name )
-{
- HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtrW( hwnd, GWLP_HINSTANCE );
- /* Windows doesn't try to load OEM Bitmaps (hInstance == NULL) */
- return LoadBitmapA( hInstance, name );
-}
-
-/***********************************************************************
- * STATIC_LoadBitmapW
- *
- * Load the bitmap for an SS_BITMAP control.
- */
-static HBITMAP STATIC_LoadBitmapW( HWND hwnd, LPCWSTR name )
-{
- HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtrW( hwnd, GWLP_HINSTANCE );
- /* Windows doesn't try to load OEM Bitmaps (hInstance == NULL) */
- return LoadBitmapW( hInstance, name );
-}
/***********************************************************************
* STATIC_TryPaintFcn
HBRUSH hBrush;
HWND parent = GetParent(hwnd);
- if(!parent) parent = hwnd;
- hBrush = (HBRUSH) SendMessageW( GetParent(hwnd),
+ if (!parent) parent = hwnd;
+ hBrush = (HBRUSH) SendMessageW( parent,
WM_CTLCOLORSTATIC, (WPARAM)hdc, (LPARAM)hwnd );
if (!hBrush) /* did the app forget to call DefWindowProc ? */
{
/* FIXME: DefWindowProc should return different colors if a
manifest is present */
- hBrush = (HBRUSH)DefWindowProcW(GetParent(hwnd), WM_CTLCOLORSTATIC,
+ hBrush = (HBRUSH)DefWindowProcW( parent, WM_CTLCOLORSTATIC,
(WPARAM)hdc, (LPARAM)hwnd);
}
return hBrush;
/***********************************************************************
* StaticWndProc_common
*/
-static LRESULT StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam,
+LRESULT WINAPI StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam,
LPARAM lParam, BOOL unicode )
{
LRESULT lResult = 0;
- LONG full_style = GetWindowLongW( hwnd, GWL_STYLE );
+ LONG full_style = GetWindowLongPtrW( hwnd, GWL_STYLE );
LONG style = full_style & SS_TYPEMASK;
+#ifdef __REACTOS__
+ PWND pWnd;
+
+ pWnd = ValidateHwnd(hwnd);
+ if (pWnd)
+ {
+ if (!pWnd->fnid)
+ {
+ NtUserSetWindowFNID(hwnd, FNID_STATIC);
+ }
+ }
+#endif
switch (uMsg)
{
break;
case WM_NCDESTROY:
+#ifdef __REACTOS__
+ NtUserSetWindowFNID(hwnd, FNID_DESTROY);
+#endif
if (style == SS_ICON) {
/*
* FIXME
{
LPCSTR textA;
LPCWSTR textW;
+ HINSTANCE hInstance;
if (full_style & SS_SUNKEN)
- SetWindowLongW( hwnd, GWL_EXSTYLE,
- GetWindowLongW( hwnd, GWL_EXSTYLE ) | WS_EX_STATICEDGE );
+ SetWindowLongPtrW( hwnd, GWL_EXSTYLE,
+ GetWindowLongPtrW( hwnd, GWL_EXSTYLE ) | WS_EX_STATICEDGE );
if(unicode)
{
{
textA = ((LPCREATESTRUCTA)lParam)->lpszName;
textW = NULL;
+
}
+ hInstance = (HINSTANCE)GetWindowLongPtrW( hwnd, GWLP_HINSTANCE );
+
switch (style) {
case SS_ICON:
{
HICON hIcon;
- if(unicode)
- hIcon = STATIC_LoadIconW(hwnd, textW, full_style);
+ if(unicode )
+ hIcon = STATIC_LoadIconW(hInstance, textW, full_style);
else
- hIcon = STATIC_LoadIconA(hwnd, textA, full_style);
+ hIcon = STATIC_LoadIconA(hInstance, textA, full_style);
STATIC_SetIcon(hwnd, hIcon, full_style);
}
break;
case SS_BITMAP:
+ if ((ULONG_PTR)hInstance >> 16)
{
HBITMAP hBitmap;
if(unicode)
- hBitmap = STATIC_LoadBitmapW(hwnd, textW);
+ hBitmap = LoadBitmapW(hInstance, textW);
else
- hBitmap = STATIC_LoadBitmapA(hwnd, textA);
+ hBitmap = LoadBitmapA(hInstance, textA);
STATIC_SetBitmap(hwnd, hBitmap, full_style);
}
break;
if (hasTextStyle( full_style ))
{
SetWindowLongPtrW( hwnd, HFONT_GWL_OFFSET, wParam );
- if (LOWORD(lParam))
- RedrawWindow( hwnd, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_ALLCHILDREN );
+ if (LOWORD(lParam))
+ RedrawWindow( hwnd, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_ALLCHILDREN );
}
break;
case STM_GETIMAGE:
return (LRESULT)STATIC_GetImage( hwnd, wParam, full_style );
-#ifndef __REACTOS__
- case STM_GETICON16:
-#endif
+
case STM_GETICON:
return (LRESULT)STATIC_GetImage( hwnd, IMAGE_ICON, full_style );
case STM_SETIMAGE:
switch(wParam) {
case IMAGE_BITMAP:
+ if (style != SS_BITMAP) return 0;
lResult = (LRESULT)STATIC_SetBitmap( hwnd, (HBITMAP)lParam, full_style );
break;
-// case IMAGE_ENHMETAFILE:
-// lResult = (LRESULT)STATIC_SetEnhMetaFile( hwnd, (HENHMETAFILE)lParam, full_style );
-// break;
+ case IMAGE_ENHMETAFILE:
+ if (style != SS_ENHMETAFILE) return 0;
+ lResult = (LRESULT)STATIC_SetEnhMetaFile( hwnd, (HENHMETAFILE)lParam, full_style );
+ break;
case IMAGE_ICON:
case IMAGE_CURSOR:
+ if (style != SS_ICON) return 0;
lResult = (LRESULT)STATIC_SetIcon( hwnd, (HICON)lParam, full_style );
break;
default:
- FIXME("STM_SETIMAGE: Unhandled type %x\n", wParam);
+ FIXME("STM_SETIMAGE: Unhandled type %lx\n", wParam);
break;
}
STATIC_TryPaintFcn( hwnd, full_style );
break;
-#ifndef __REACTOS__
- case STM_SETICON16:
-#endif
case STM_SETICON:
lResult = (LRESULT)STATIC_SetIcon( hwnd, (HICON)wParam, full_style );
STATIC_TryPaintFcn( hwnd, full_style );
/***********************************************************************
* StaticWndProcA
*/
-static LRESULT WINAPI StaticWndProcA( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
+LRESULT WINAPI StaticWndProcA( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
if (!IsWindow( hWnd )) return 0;
return StaticWndProc_common(hWnd, uMsg, wParam, lParam, FALSE);
/***********************************************************************
* StaticWndProcW
*/
-static LRESULT WINAPI StaticWndProcW( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
+LRESULT WINAPI StaticWndProcW( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
if (!IsWindow( hWnd )) return 0;
return StaticWndProc_common(hWnd, uMsg, wParam, lParam, TRUE);
RECT rc;
HBRUSH hBrush;
HFONT hFont, hOldFont = NULL;
- DWORD wFormat;
+ WORD wFormat;
INT len, buf_size;
WCHAR *text;
return;
}
+ if (GetWindowLongW( hwnd, GWL_EXSTYLE ) & WS_EX_RIGHT)
+ wFormat = DT_RIGHT | (wFormat & ~(DT_LEFT | DT_CENTER));
+
if (style & SS_NOPREFIX)
wFormat |= DT_NOPREFIX;
else if (get_ui_state(hwnd) & UISF_HIDEACCEL)
}
if ((hFont = (HFONT)GetWindowLongPtrW( hwnd, HFONT_GWL_OFFSET )))
- hOldFont = (HFONT)SelectObject( hdc, hFont );
+ hOldFont = SelectObject( hdc, hFont );
/* SS_SIMPLE controls: WM_CTLCOLORSTATIC is sent, but the returned
brush is not used */
GetClientRect( hwnd, &rc);
/* FIXME: send WM_CTLCOLORSTATIC */
+#ifdef __REACTOS__
+ hBrush = STATIC_SendWmCtlColorStatic(hwnd, hdc); // Always sent....
+#endif
switch (style & SS_TYPEMASK)
{
case SS_BLACKRECT:
DeleteObject( hBrush );
}
-/* Modified for ReactOS */
static void STATIC_PaintIconfn( HWND hwnd, HDC hdc, DWORD style )
{
RECT rc, iconRect;
HBRUSH hbrush;
HICON hIcon;
- ICONINFO info;
+ SIZE size;
GetClientRect( hwnd, &rc );
hbrush = STATIC_SendWmCtlColorStatic(hwnd, hdc);
hIcon = (HICON)GetWindowLongPtrW( hwnd, HICON_GWL_OFFSET );
- if (!hIcon || (!GetIconInfo(hIcon, &info)))
+ if (!hIcon || !get_icon_size( hIcon, &size ))
{
FillRect(hdc, &rc, hbrush);
}
else
{
- BITMAP bm;
- if (!GetObjectW(info.hbmColor, sizeof(BITMAP), &bm)) return;
if (style & SS_CENTERIMAGE)
{
- iconRect.left = (rc.right - rc.left) / 2 - bm.bmWidth / 2;
- iconRect.top = (rc.bottom - rc.top) / 2 - bm.bmHeight / 2;
- iconRect.right = iconRect.left + bm.bmWidth;
- iconRect.bottom = iconRect.top + bm.bmHeight;
+ iconRect.left = (rc.right - rc.left) / 2 - size.cx / 2;
+ iconRect.top = (rc.bottom - rc.top) / 2 - size.cy / 2;
+ iconRect.right = iconRect.left + size.cx;
+ iconRect.bottom = iconRect.top + size.cy;
}
else
iconRect = rc;
if (brush.lbStyle == BS_SOLID)
SetBkColor(hdc, brush.lbColor);
}
- GetClientRect(hwnd, &rcClient);
+ GetClientRect(hwnd, &rcClient);
if (style & SS_CENTERIMAGE)
{
INT x, y;
SelectObject(hMemDC, oldbitmap);
DeleteDC(hMemDC);
}
- else
- {
- RECT rcClient;
- GetClientRect( hwnd, &rcClient );
- FillRect( hdc, &rcClient, hbrush );
- }
}
-//static void STATIC_PaintEnhMetafn(HWND hwnd, HDC hdc, DWORD style )
-//{
-// HENHMETAFILE hEnhMetaFile;
-// RECT rc;
-// HBRUSH hbrush;
-//
-// GetClientRect(hwnd, &rc);
-// hbrush = STATIC_SendWmCtlColorStatic(hwnd, hdc);
-// FillRect(hdc, &rc, hbrush);
-// if ((hEnhMetaFile = (HENHMETAFILE)GetWindowLongPtrW( hwnd, HICON_GWL_OFFSET )))
-// {
-// /* The control's current font is not selected into the
-// device context! */
-// if (GetObjectType(hEnhMetaFile) == OBJ_ENHMETAFILE)
-// PlayEnhMetaFile(hdc, hEnhMetaFile, &rc);
-// }
-//}
+static void STATIC_PaintEnhMetafn(HWND hwnd, HDC hdc, DWORD style )
+{
+ HENHMETAFILE hEnhMetaFile;
+ RECT rc;
+ HBRUSH hbrush;
+
+ GetClientRect(hwnd, &rc);
+ hbrush = STATIC_SendWmCtlColorStatic(hwnd, hdc);
+ FillRect(hdc, &rc, hbrush);
+ if ((hEnhMetaFile = (HENHMETAFILE)GetWindowLongPtrW( hwnd, HICON_GWL_OFFSET )))
+ {
+ /* The control's current font is not selected into the
+ device context! */
+ if (GetObjectType(hEnhMetaFile) == OBJ_ENHMETAFILE)
+ PlayEnhMetaFile(hdc, hEnhMetaFile, &rc);
+ }
+}
static void STATIC_PaintEtchedfn( HWND hwnd, HDC hdc, DWORD style )
break;
}
}
+