Author: mkupfer
Date: Wed Mar 11 00:39:22 2009
New Revision: 39940
URL:
http://svn.reactos.org/svn/reactos?rev=39940&view=rev
Log:
- due to minor differences (marletting related) combine drawing routines for check box and
radio button
- initial version for popup arrows, maybe someone know how to remove the bitmap and
memory-dc stuff properly
Modified:
trunk/reactos/dll/win32/user32/windows/draw.c
trunk/reactos/dll/win32/user32/windows/menu.c
Modified: trunk/reactos/dll/win32/user32/windows/draw.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/d…
==============================================================================
--- trunk/reactos/dll/win32/user32/windows/draw.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/windows/draw.c [iso-8859-1] Wed Mar 11 00:39:22 2009
@@ -690,18 +690,29 @@
return TRUE;
}
-static BOOL UITOOLS95_DFC_ButtonCheck(HDC dc, LPRECT r, UINT uFlags)
+static BOOL UITOOLS95_DFC_ButtonCheckRadio(HDC dc, LPRECT r, UINT uFlags, BOOL Radio)
{
RECT rc;
LOGFONT lf;
HFONT hFont, hOldFont;
int SmallDiam, i;
-
- LPCTSTR OutRight = TEXT("c"); // Outer right
- LPCTSTR OutLeft = TEXT("d"); // Outer left
- LPCTSTR InRight = TEXT("e"); // inner left
- LPCTSTR InLeft = TEXT("f"); // inner right
- LPCTSTR Center = TEXT("g"); // center
+ TCHAR OutRight, OutLeft, InRight, InLeft, Center;
+
+ if (Radio)
+ {
+ OutRight = 'j'; // Outer right
+ OutLeft = 'k'; // Outer left
+ InRight = 'l'; // inner left
+ InLeft = 'm'; // inner right
+ Center = 'n'; // center
+ } else
+ {
+ OutRight = 'c'; // Outer right
+ OutLeft = 'd'; // Outer left
+ InRight = 'e'; // inner left
+ InLeft = 'f'; // inner right
+ Center = 'g'; // center
+ }
SmallDiam = UITOOLS_MakeSquareRect(r, &rc);
@@ -714,82 +725,16 @@
hFont = CreateFontIndirect(&lf);
hOldFont = SelectObject(dc, hFont);
- SetBkMode(dc, TRANSPARENT);
-
- /* Center section, white for active, grey for inactive */
- i= !(uFlags & (DFCS_INACTIVE|DFCS_PUSHED)) ? COLOR_WINDOW : COLOR_BTNFACE;
- SetTextColor(dc, GetSysColor(i));
- TextOut(dc, rc.left, rc.top, Center, 1);
-
- if(uFlags & (DFCS_FLAT | DFCS_MONO))
- {
- SetTextColor(dc, GetSysColor(COLOR_WINDOWFRAME));
- TextOut(dc, rc.left, rc.top, OutRight, 1);
- TextOut(dc, rc.left, rc.top, OutLeft, 1);
- TextOut(dc, rc.left, rc.top, InRight, 1);
- TextOut(dc, rc.left, rc.top, InLeft, 1);
- }
- else
- {
- SetTextColor(dc, GetSysColor(COLOR_BTNSHADOW));
- TextOut(dc, rc.left, rc.top, OutRight, 1);
- SetTextColor(dc, GetSysColor(COLOR_BTNHIGHLIGHT));
- TextOut(dc, rc.left, rc.top, OutLeft, 1);
- SetTextColor(dc, GetSysColor(COLOR_3DDKSHADOW));
- TextOut(dc, rc.left, rc.top, InRight, 1);
- SetTextColor(dc, GetSysColor(COLOR_3DLIGHT));
- TextOut(dc, rc.left, rc.top, InLeft, 1);
- }
-
- if(uFlags & DFCS_CHECKED)
- {
- LPCTSTR Check = TEXT("b");
-
- SetTextColor(dc, GetSysColor(COLOR_WINDOWTEXT));
- TextOut(dc, rc.left, rc.top, Check, 1);
- }
-
- SetTextColor(dc, GetSysColor(COLOR_WINDOWTEXT));
- SelectObject(dc, hOldFont);
- DeleteObject(hFont);
-
- return TRUE;
-}
-
-static BOOL UITOOLS95_DFC_ButtonRadio(HDC dc, LPRECT r, UINT uFlags)
-{
- RECT rc;
- LOGFONT lf;
- HFONT hFont, hOldFont;
- int SmallDiam, i;
-
- LPCTSTR OutRight = TEXT("j"); // Outer right
- LPCTSTR OutLeft = TEXT("k"); // Outer left
- LPCTSTR InRight = TEXT("l"); // inner left
- LPCTSTR InLeft = TEXT("m"); // inner right
- LPCTSTR Center = TEXT("n"); // center
-
- SmallDiam = UITOOLS_MakeSquareRect(r, &rc);
-
- ZeroMemory(&lf, sizeof(LOGFONT));
- lf.lfHeight = SmallDiam;
- lf.lfWidth = 0;
- lf.lfWeight = FW_NORMAL;
- lf.lfCharSet = DEFAULT_CHARSET;
- lstrcpy(lf.lfFaceName, TEXT("Marlett"));
- hFont = CreateFontIndirect(&lf);
- hOldFont = SelectObject(dc, hFont);
-
- if((uFlags & 0xff) == DFCS_BUTTONRADIOMASK)
+ if(Radio && ((uFlags & 0xff) == DFCS_BUTTONRADIOMASK))
{
SetBkMode(dc, OPAQUE);
SetTextColor(dc, GetSysColor(COLOR_WINDOWFRAME));
- TextOut(dc, rc.left, rc.top, Center, 1);
+ TextOut(dc, rc.left, rc.top, &Center, 1);
SetBkMode(dc, TRANSPARENT);
SetTextColor(dc, GetSysColor(COLOR_WINDOWFRAME));
- TextOut(dc, rc.left, rc.top, OutRight, 1);
+ TextOut(dc, rc.left, rc.top, &OutRight, 1);
SetTextColor(dc, GetSysColor(COLOR_WINDOWFRAME));
- TextOut(dc, rc.left, rc.top, OutLeft, 1);
+ TextOut(dc, rc.left, rc.top, &OutLeft, 1);
}
else
{
@@ -798,35 +743,35 @@
/* Center section, white for active, grey for inactive */
i= !(uFlags & (DFCS_INACTIVE|DFCS_PUSHED)) ? COLOR_WINDOW : COLOR_BTNFACE;
SetTextColor(dc, GetSysColor(i));
- TextOut(dc, rc.left, rc.top, Center, 1);
+ TextOut(dc, rc.left, rc.top, &Center, 1);
if(uFlags & (DFCS_FLAT | DFCS_MONO))
{
SetTextColor(dc, GetSysColor(COLOR_WINDOWFRAME));
- TextOut(dc, rc.left, rc.top, OutRight, 1);
- TextOut(dc, rc.left, rc.top, OutLeft, 1);
- TextOut(dc, rc.left, rc.top, InRight, 1);
- TextOut(dc, rc.left, rc.top, InLeft, 1);
+ TextOut(dc, rc.left, rc.top, &OutRight, 1);
+ TextOut(dc, rc.left, rc.top, &OutLeft, 1);
+ TextOut(dc, rc.left, rc.top, &InRight, 1);
+ TextOut(dc, rc.left, rc.top, &InLeft, 1);
}
else
{
SetTextColor(dc, GetSysColor(COLOR_BTNSHADOW));
- TextOut(dc, rc.left, rc.top, OutRight, 1);
+ TextOut(dc, rc.left, rc.top, &OutRight, 1);
SetTextColor(dc, GetSysColor(COLOR_BTNHIGHLIGHT));
- TextOut(dc, rc.left, rc.top, OutLeft, 1);
+ TextOut(dc, rc.left, rc.top, &OutLeft, 1);
SetTextColor(dc, GetSysColor(COLOR_3DDKSHADOW));
- TextOut(dc, rc.left, rc.top, InRight, 1);
+ TextOut(dc, rc.left, rc.top, &InRight, 1);
SetTextColor(dc, GetSysColor(COLOR_3DLIGHT));
- TextOut(dc, rc.left, rc.top, InLeft, 1);
+ TextOut(dc, rc.left, rc.top, &InLeft, 1);
}
}
if(uFlags & DFCS_CHECKED)
{
- LPCTSTR Check = TEXT("i");
+ TCHAR Check = (Radio) ? 'i' : 'b';
SetTextColor(dc, GetSysColor(COLOR_WINDOWTEXT));
- TextOut(dc, rc.left, rc.top, Check, 1);
+ TextOut(dc, rc.left, rc.top, &Check, 1);
}
SetTextColor(dc, GetSysColor(COLOR_WINDOWTEXT));
@@ -846,12 +791,12 @@
case DFCS_BUTTONCHECK:
case DFCS_BUTTON3STATE:
- return UITOOLS95_DFC_ButtonCheck(hdc, rc, uState);
+ return UITOOLS95_DFC_ButtonCheckRadio(hdc, rc, uState, FALSE);
case DFCS_BUTTONRADIOIMAGE:
case DFCS_BUTTONRADIOMASK:
case DFCS_BUTTONRADIO:
- return UITOOLS95_DFC_ButtonRadio(hdc, rc, uState);
+ return UITOOLS95_DFC_ButtonCheckRadio(hdc, rc, uState, TRUE);
/*
default:
Modified: trunk/reactos/dll/win32/user32/windows/menu.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/m…
==============================================================================
--- trunk/reactos/dll/win32/user32/windows/menu.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/windows/menu.c [iso-8859-1] Wed Mar 11 00:39:22 2009
@@ -115,9 +115,6 @@
static HWND TopPopup;
/* Dimension of the menu bitmaps */
-static WORD ArrowBitmapWidth = 0, ArrowBitmapHeight = 0;
-
-static HBITMAP StdMnArrow = NULL;
static HBITMAP BmpSysMenu = NULL;
static SIZE MenuCharSize;
@@ -289,20 +286,6 @@
static void FASTCALL
MenuLoadBitmaps(VOID)
{
- /* Load menu bitmaps */
- if (NULL == StdMnArrow)
- {
- StdMnArrow = LoadBitmapW(0, MAKEINTRESOURCEW(OBM_MNARROW));
-
- if (NULL != StdMnArrow)
- {
- BITMAP bm;
- GetObjectW(StdMnArrow, sizeof(BITMAP), &bm);
- ArrowBitmapWidth = bm.bmWidth;
- ArrowBitmapHeight = bm.bmHeight;
- }
- }
-
/* Load system buttons bitmaps */
if (NULL == BmpSysMenu)
{
@@ -621,18 +604,24 @@
SendMessageW(WndOwner, WM_DRAWITEM, 0, (LPARAM) &dis);
/* Draw the popup-menu arrow */
if (0 != (Item->fType & MF_POPUP))
- {
- HDC DcMem = CreateCompatibleDC(Dc);
- HBITMAP OrigBitmap;
-
- OrigBitmap = SelectObject(DcMem, StdMnArrow);
- BitBlt(Dc, Rect.right - ArrowBitmapWidth - 1,
- ((Rect.top + Rect.bottom) - ArrowBitmapHeight) / 2,
- ArrowBitmapWidth, ArrowBitmapHeight,
- DcMem, 0, 0, SRCCOPY);
- SelectObject(DcMem, OrigBitmap);
- DeleteDC(DcMem);
- }
+ {
+ INT y = Rect.top + Rect.bottom;
+ UINT CheckBitmapWidth = GetSystemMetrics(SM_CXMENUCHECK);
+ UINT CheckBitmapHeight = GetSystemMetrics(SM_CYMENUCHECK);
+ RECT r;
+ HBITMAP bm = CreateBitmap(CheckBitmapWidth, CheckBitmapHeight, 1, 1, NULL);
+ HDC DcMem = CreateCompatibleDC(Dc);
+ SelectObject(DcMem, bm);
+ SetRect( &r, 0, 0, CheckBitmapWidth, CheckBitmapHeight);
+ DrawFrameControl(DcMem, &r, DFC_MENU, DFCS_MENUARROW);
+ BitBlt(Dc, Rect.right - CheckBitmapWidth, (y - r.bottom) / 2, r.right,
r.bottom, DcMem, 0, 0, SRCCOPY );
+ DeleteDC(DcMem);
+ DeleteObject(bm);
+ /*
+ SetRect(&r,Rect.right - CheckBitmapWidth, (y - CheckBitmapHeight) / 2,
Rect.right, Rect.bottom);
+ DrawFrameControl(Dc, &r, DFC_MENU, DFCS_MENUARROW);
+ */
+ }
return;
}
@@ -769,21 +758,24 @@
/* Draw the popup-menu arrow */
if (0 != (Item->fType & MF_POPUP))
{
- HDC DcMem = CreateCompatibleDC(Dc);
- HBITMAP OrigBitmap;
-
- OrigBitmap = SelectObject(DcMem, StdMnArrow);
- BitBlt(Dc, Rect.right - ArrowBitmapWidth - 1,
- (y - ArrowBitmapHeight) / 2,
- ArrowBitmapWidth, ArrowBitmapHeight,
- DcMem, 0, 0, SRCCOPY);
- SelectObject(DcMem, OrigBitmap);
- DeleteDC(DcMem);
+ RECT r;
+ HBITMAP bm = CreateBitmap(CheckBitmapWidth, CheckBitmapHeight, 1, 1, NULL);
+ HDC DcMem = CreateCompatibleDC(Dc);
+ SelectObject(DcMem, bm);
+ SetRect( &r, 0, 0, CheckBitmapWidth, CheckBitmapHeight);
+ DrawFrameControl(DcMem, &r, DFC_MENU, DFCS_MENUARROW);
+ BitBlt(Dc, Rect.right - CheckBitmapWidth, (y - r.bottom) / 2, r.right, r.bottom,
DcMem, 0, 0, SRCCOPY );
+ DeleteDC(DcMem);
+ DeleteObject(bm);
+ /*
+ SetRect(&r,Rect.right - CheckBitmapWidth, (y - CheckBitmapHeight) / 2,
Rect.right, Rect.bottom);
+ DrawFrameControl(Dc, &r, DFC_MENU, DFCS_MENUARROW);
+ */
}
Rect.left += 4;
if( !(MenuInfo->dwStyle & MNS_NOCHECK))
Rect.left += CheckBitmapWidth;
- Rect.right -= ArrowBitmapWidth;
+ Rect.right -= CheckBitmapWidth;
}
else if (Item->hbmpItem) /* Draw the bitmap */
{
@@ -1256,7 +1248,7 @@
{
ItemInfo->Rect.bottom += SEPARATOR_HEIGHT;
if( !MenuBar)
- ItemInfo->Rect.right += ArrowBitmapWidth + MenuCharSize.cx;
+ ItemInfo->Rect.right += CheckBitmapWidth + MenuCharSize.cx;
return;
}
@@ -1286,7 +1278,7 @@
ItemInfo->Rect.right += 2 * CheckBitmapWidth;
ItemInfo->Rect.right += 4 + MenuCharSize.cx;
ItemInfo->XTab = ItemInfo->Rect.right;
- ItemInfo->Rect.right += ArrowBitmapWidth;
+ ItemInfo->Rect.right += CheckBitmapWidth;
}
else /* hbmpItem & MenuBar */
{
@@ -1307,7 +1299,7 @@
ItemInfo->Rect.right += CheckBitmapWidth;
ItemInfo->Rect.right += 4 + MenuCharSize.cx;
ItemInfo->XTab = ItemInfo->Rect.right;
- ItemInfo->Rect.right += ArrowBitmapWidth;
+ ItemInfo->Rect.right += CheckBitmapWidth;
}
/* it must be a text item - unless it's the system menu */