Commit 1de825f7 authored by Michael Kaufmann's avatar Michael Kaufmann Committed by Alexandre Julliard

static control: SS_CENTERIMAGE fixes.

- Stretch bitmaps and icons to the whole control size if SS_CENTERIMAGE is absent - Draw the background of centered bitmaps and icons with the background brush (like Windows XP for applications with a manifest)
parent 2fed6479
...@@ -25,14 +25,21 @@ ...@@ -25,14 +25,21 @@
* Unless otherwise noted, we believe this code to be complete, as per * Unless otherwise noted, we believe this code to be complete, as per
* the specification mentioned above. * the specification mentioned above.
* If you discover missing features, or bugs, please note them below. * If you discover missing features, or bugs, please note them below.
*
* TODO:
* *
* Styles * Notes:
* - SS_RIGHTJUST * - Windows XP introduced new behavior: The background of centered
* icons and bitmaps is painted differently. This is only done if
* a manifest is present.
* Because it has not yet been decided how to implement the two
* different modes in Wine, only the Windows XP mode is implemented.
* - Controls with SS_SIMPLE but without SS_NOPREFIX:
* The text should not be changed. Windows doesn't clear the
* client rectangle, so the new text must be larger than the old one.
* - The SS_RIGHTJUST style is currently not implemented by Windows
* (or it does something different than documented).
* *
* Messages * TODO:
* - STM_SETIMAGE: IMAGE_CURSOR * - Animated cursors
*/ */
#include <stdarg.h> #include <stdarg.h>
...@@ -531,13 +538,11 @@ static LRESULT StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam, ...@@ -531,13 +538,11 @@ static LRESULT StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam,
case IMAGE_BITMAP: case IMAGE_BITMAP:
lResult = (LRESULT)STATIC_SetBitmap( hwnd, (HBITMAP)lParam, full_style ); lResult = (LRESULT)STATIC_SetBitmap( hwnd, (HBITMAP)lParam, full_style );
break; break;
case IMAGE_CURSOR:
FIXME("STM_SETIMAGE: Unhandled type IMAGE_CURSOR\n");
break;
case IMAGE_ENHMETAFILE: case IMAGE_ENHMETAFILE:
lResult = (LRESULT)STATIC_SetEnhMetaFile( hwnd, (HENHMETAFILE)lParam, full_style ); lResult = (LRESULT)STATIC_SetEnhMetaFile( hwnd, (HENHMETAFILE)lParam, full_style );
break; break;
case IMAGE_ICON: case IMAGE_ICON:
case IMAGE_CURSOR:
lResult = (LRESULT)STATIC_SetIcon( hwnd, (HICON)lParam, full_style ); lResult = (LRESULT)STATIC_SetIcon( hwnd, (HICON)lParam, full_style );
break; break;
default: default:
...@@ -733,65 +738,90 @@ static void STATIC_PaintRectfn( HWND hwnd, HDC hdc, DWORD style ) ...@@ -733,65 +738,90 @@ static void STATIC_PaintRectfn( HWND hwnd, HDC hdc, DWORD style )
static void STATIC_PaintIconfn( HWND hwnd, HDC hdc, DWORD style ) static void STATIC_PaintIconfn( HWND hwnd, HDC hdc, DWORD style )
{ {
RECT rc; RECT rc, iconRect;
HBRUSH hbrush; HBRUSH hbrush;
HICON hIcon; HICON hIcon;
INT x, y; CURSORICONINFO * info;
GetClientRect( hwnd, &rc ); GetClientRect( hwnd, &rc );
hbrush = (HBRUSH)SendMessageW( GetParent(hwnd), WM_CTLCOLORSTATIC, hbrush = STATIC_SendWmCtlColorStatic(hwnd, hdc);
(WPARAM)hdc, (LPARAM)hwnd );
FillRect( hdc, &rc, hbrush );
hIcon = (HICON)GetWindowLongPtrW( hwnd, HICON_GWL_OFFSET ); hIcon = (HICON)GetWindowLongPtrW( hwnd, HICON_GWL_OFFSET );
if (style & SS_CENTERIMAGE) info = hIcon ? (CURSORICONINFO *)GlobalLock16(HICON_16(hIcon)) : NULL;
if (!hIcon || !info)
{ {
CURSORICONINFO *info = hIcon ? (CURSORICONINFO *)GlobalLock16(HICON_16(hIcon)) : NULL; FillRect(hdc, &rc, hbrush);
x = (rc.right - rc.left)/2 - (info ? info->nWidth/2 : 0);
y = (rc.bottom - rc.top)/2 - (info ? info->nHeight/2 : 0);
} }
else else
{ {
x = rc.left; if (style & SS_CENTERIMAGE)
y = rc.top; {
iconRect.left = (rc.right - rc.left) / 2 - info->nWidth / 2;
iconRect.top = (rc.bottom - rc.top) / 2 - info->nHeight / 2;
iconRect.right = iconRect.left + info->nWidth;
iconRect.bottom = iconRect.top + info->nHeight;
FillRect( hdc, &rc, hbrush );
}
else
{
FillRect( hdc, &rc, hbrush );
DrawIconEx( hdc, rc.left, rc.top, hIcon, rc.right - rc.left,
rc.bottom - rc.top, 0, NULL, DI_NORMAL );
}
} }
if (hIcon) if (info) GlobalUnlock16(HICON_16(hIcon));
DrawIcon( hdc, x, y, hIcon );
} }
static void STATIC_PaintBitmapfn(HWND hwnd, HDC hdc, DWORD style ) static void STATIC_PaintBitmapfn(HWND hwnd, HDC hdc, DWORD style )
{ {
HDC hMemDC; HDC hMemDC;
HBITMAP hBitmap, oldbitmap; HBITMAP hBitmap, oldbitmap;
HBRUSH hbrush;
/* message is still sent, even if the returned brush is not used */ /* message is still sent, even if the returned brush is not used */
SendMessageW( GetParent(hwnd), WM_CTLCOLORSTATIC, hbrush = STATIC_SendWmCtlColorStatic(hwnd, hdc);
(WPARAM)hdc, (LPARAM)hwnd );
if ((hBitmap = (HBITMAP)GetWindowLongPtrW( hwnd, HICON_GWL_OFFSET ))) if ((hBitmap = (HBITMAP)GetWindowLongPtrW( hwnd, HICON_GWL_OFFSET ))
&& (GetObjectType(hBitmap) == OBJ_BITMAP)
&& (hMemDC = CreateCompatibleDC( hdc )))
{ {
INT x, y;
BITMAP bm; BITMAP bm;
RECT rcClient;
LOGBRUSH brush;
GetObjectW(hBitmap, sizeof(bm), &bm);
oldbitmap = SelectObject(hMemDC, hBitmap);
if(GetObjectType(hBitmap) != OBJ_BITMAP) return; /* Set the background color for monochrome bitmaps
if (!(hMemDC = CreateCompatibleDC( hdc ))) return; to the color of the background brush */
GetObjectW(hBitmap, sizeof(bm), &bm); if (GetObjectW( hbrush, sizeof(brush), &brush ))
oldbitmap = SelectObject(hMemDC, hBitmap); {
if (brush.lbStyle == BS_SOLID)
SetBkColor(hdc, brush.lbColor);
}
GetClientRect(hwnd, &rcClient);
if (style & SS_CENTERIMAGE) if (style & SS_CENTERIMAGE)
{ {
RECT rcClient; INT x, y;
GetClientRect(hwnd, &rcClient);
x = (rcClient.right - rcClient.left)/2 - bm.bmWidth/2; x = (rcClient.right - rcClient.left)/2 - bm.bmWidth/2;
y = (rcClient.bottom - rcClient.top)/2 - bm.bmHeight/2; y = (rcClient.bottom - rcClient.top)/2 - bm.bmHeight/2;
FillRect( hdc, &rcClient, hbrush );
BitBlt(hdc, x, y, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0,
SRCCOPY);
} }
else else
{ {
x = 0; StretchBlt(hdc, 0, 0, rcClient.right - rcClient.left,
y = 0; rcClient.bottom - rcClient.top, hMemDC,
0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
} }
BitBlt(hdc, x, y, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SelectObject(hMemDC, oldbitmap);
SRCCOPY); DeleteDC(hMemDC);
SelectObject(hMemDC, oldbitmap); }
DeleteDC(hMemDC); else
{
RECT rcClient;
GetClientRect( hwnd, &rcClient );
FillRect( hdc, &rcClient, hbrush );
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment