- 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

svn path=/trunk/; revision=39940
This commit is contained in:
Matthias Kupfer 2009-03-10 21:39:22 +00:00
parent 83c3b848b3
commit 9c5d76e1bf
2 changed files with 69 additions and 132 deletions

View file

@ -690,18 +690,29 @@ static BOOL UITOOLS95_DFC_ButtonPush(HDC dc, LPRECT r, UINT uFlags)
return TRUE; 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; RECT rc;
LOGFONT lf; LOGFONT lf;
HFONT hFont, hOldFont; HFONT hFont, hOldFont;
int SmallDiam, i; int SmallDiam, i;
TCHAR OutRight, OutLeft, InRight, InLeft, Center;
LPCTSTR OutRight = TEXT("c"); // Outer right if (Radio)
LPCTSTR OutLeft = TEXT("d"); // Outer left {
LPCTSTR InRight = TEXT("e"); // inner left OutRight = 'j'; // Outer right
LPCTSTR InLeft = TEXT("f"); // inner right OutLeft = 'k'; // Outer left
LPCTSTR Center = TEXT("g"); // center 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); SmallDiam = UITOOLS_MakeSquareRect(r, &rc);
@ -714,82 +725,16 @@ static BOOL UITOOLS95_DFC_ButtonCheck(HDC dc, LPRECT r, UINT uFlags)
hFont = CreateFontIndirect(&lf); hFont = CreateFontIndirect(&lf);
hOldFont = SelectObject(dc, hFont); hOldFont = SelectObject(dc, hFont);
SetBkMode(dc, TRANSPARENT); if(Radio && ((uFlags & 0xff) == DFCS_BUTTONRADIOMASK))
/* 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)
{ {
SetBkMode(dc, OPAQUE); SetBkMode(dc, OPAQUE);
SetTextColor(dc, GetSysColor(COLOR_WINDOWFRAME)); SetTextColor(dc, GetSysColor(COLOR_WINDOWFRAME));
TextOut(dc, rc.left, rc.top, Center, 1); TextOut(dc, rc.left, rc.top, &Center, 1);
SetBkMode(dc, TRANSPARENT); SetBkMode(dc, TRANSPARENT);
SetTextColor(dc, GetSysColor(COLOR_WINDOWFRAME)); 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)); SetTextColor(dc, GetSysColor(COLOR_WINDOWFRAME));
TextOut(dc, rc.left, rc.top, OutLeft, 1); TextOut(dc, rc.left, rc.top, &OutLeft, 1);
} }
else else
{ {
@ -798,35 +743,35 @@ static BOOL UITOOLS95_DFC_ButtonRadio(HDC dc, LPRECT r, UINT uFlags)
/* Center section, white for active, grey for inactive */ /* Center section, white for active, grey for inactive */
i= !(uFlags & (DFCS_INACTIVE|DFCS_PUSHED)) ? COLOR_WINDOW : COLOR_BTNFACE; i= !(uFlags & (DFCS_INACTIVE|DFCS_PUSHED)) ? COLOR_WINDOW : COLOR_BTNFACE;
SetTextColor(dc, GetSysColor(i)); 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)) if(uFlags & (DFCS_FLAT | DFCS_MONO))
{ {
SetTextColor(dc, GetSysColor(COLOR_WINDOWFRAME)); SetTextColor(dc, GetSysColor(COLOR_WINDOWFRAME));
TextOut(dc, rc.left, rc.top, OutRight, 1); TextOut(dc, rc.left, rc.top, &OutRight, 1);
TextOut(dc, rc.left, rc.top, OutLeft, 1); TextOut(dc, rc.left, rc.top, &OutLeft, 1);
TextOut(dc, rc.left, rc.top, InRight, 1); TextOut(dc, rc.left, rc.top, &InRight, 1);
TextOut(dc, rc.left, rc.top, InLeft, 1); TextOut(dc, rc.left, rc.top, &InLeft, 1);
} }
else else
{ {
SetTextColor(dc, GetSysColor(COLOR_BTNSHADOW)); 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)); 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)); 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)); 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) if(uFlags & DFCS_CHECKED)
{ {
LPCTSTR Check = TEXT("i"); TCHAR Check = (Radio) ? 'i' : 'b';
SetTextColor(dc, GetSysColor(COLOR_WINDOWTEXT)); 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)); SetTextColor(dc, GetSysColor(COLOR_WINDOWTEXT));
@ -846,12 +791,12 @@ static BOOL UITOOLS95_DrawFrameButton(HDC hdc, LPRECT rc, UINT uState)
case DFCS_BUTTONCHECK: case DFCS_BUTTONCHECK:
case DFCS_BUTTON3STATE: case DFCS_BUTTON3STATE:
return UITOOLS95_DFC_ButtonCheck(hdc, rc, uState); return UITOOLS95_DFC_ButtonCheckRadio(hdc, rc, uState, FALSE);
case DFCS_BUTTONRADIOIMAGE: case DFCS_BUTTONRADIOIMAGE:
case DFCS_BUTTONRADIOMASK: case DFCS_BUTTONRADIOMASK:
case DFCS_BUTTONRADIO: case DFCS_BUTTONRADIO:
return UITOOLS95_DFC_ButtonRadio(hdc, rc, uState); return UITOOLS95_DFC_ButtonCheckRadio(hdc, rc, uState, TRUE);
/* /*
default: default:

View file

@ -115,9 +115,6 @@ static BOOL fEndMenu = FALSE;
static HWND TopPopup; static HWND TopPopup;
/* Dimension of the menu bitmaps */ /* Dimension of the menu bitmaps */
static WORD ArrowBitmapWidth = 0, ArrowBitmapHeight = 0;
static HBITMAP StdMnArrow = NULL;
static HBITMAP BmpSysMenu = NULL; static HBITMAP BmpSysMenu = NULL;
static SIZE MenuCharSize; static SIZE MenuCharSize;
@ -289,20 +286,6 @@ MenuCleanupAllRosMenuItemInfo(PROSMENUITEMINFO ItemInfo)
static void FASTCALL static void FASTCALL
MenuLoadBitmaps(VOID) 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 */ /* Load system buttons bitmaps */
if (NULL == BmpSysMenu) if (NULL == BmpSysMenu)
{ {
@ -622,16 +605,22 @@ MenuDrawMenuItem(HWND hWnd, PROSMENUINFO MenuInfo, HWND WndOwner, HDC Dc,
/* Draw the popup-menu arrow */ /* Draw the popup-menu arrow */
if (0 != (Item->fType & MF_POPUP)) if (0 != (Item->fType & MF_POPUP))
{ {
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); HDC DcMem = CreateCompatibleDC(Dc);
HBITMAP OrigBitmap; SelectObject(DcMem, bm);
SetRect( &r, 0, 0, CheckBitmapWidth, CheckBitmapHeight);
OrigBitmap = SelectObject(DcMem, StdMnArrow); DrawFrameControl(DcMem, &r, DFC_MENU, DFCS_MENUARROW);
BitBlt(Dc, Rect.right - ArrowBitmapWidth - 1, BitBlt(Dc, Rect.right - CheckBitmapWidth, (y - r.bottom) / 2, r.right, r.bottom, DcMem, 0, 0, SRCCOPY );
((Rect.top + Rect.bottom) - ArrowBitmapHeight) / 2,
ArrowBitmapWidth, ArrowBitmapHeight,
DcMem, 0, 0, SRCCOPY);
SelectObject(DcMem, OrigBitmap);
DeleteDC(DcMem); DeleteDC(DcMem);
DeleteObject(bm);
/*
SetRect(&r,Rect.right - CheckBitmapWidth, (y - CheckBitmapHeight) / 2, Rect.right, Rect.bottom);
DrawFrameControl(Dc, &r, DFC_MENU, DFCS_MENUARROW);
*/
} }
return; return;
} }
@ -769,21 +758,24 @@ MenuDrawMenuItem(HWND hWnd, PROSMENUINFO MenuInfo, HWND WndOwner, HDC Dc,
/* Draw the popup-menu arrow */ /* Draw the popup-menu arrow */
if (0 != (Item->fType & MF_POPUP)) if (0 != (Item->fType & MF_POPUP))
{ {
RECT r;
HBITMAP bm = CreateBitmap(CheckBitmapWidth, CheckBitmapHeight, 1, 1, NULL);
HDC DcMem = CreateCompatibleDC(Dc); HDC DcMem = CreateCompatibleDC(Dc);
HBITMAP OrigBitmap; SelectObject(DcMem, bm);
SetRect( &r, 0, 0, CheckBitmapWidth, CheckBitmapHeight);
OrigBitmap = SelectObject(DcMem, StdMnArrow); DrawFrameControl(DcMem, &r, DFC_MENU, DFCS_MENUARROW);
BitBlt(Dc, Rect.right - ArrowBitmapWidth - 1, BitBlt(Dc, Rect.right - CheckBitmapWidth, (y - r.bottom) / 2, r.right, r.bottom, DcMem, 0, 0, SRCCOPY );
(y - ArrowBitmapHeight) / 2,
ArrowBitmapWidth, ArrowBitmapHeight,
DcMem, 0, 0, SRCCOPY);
SelectObject(DcMem, OrigBitmap);
DeleteDC(DcMem); 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; Rect.left += 4;
if( !(MenuInfo->dwStyle & MNS_NOCHECK)) if( !(MenuInfo->dwStyle & MNS_NOCHECK))
Rect.left += CheckBitmapWidth; Rect.left += CheckBitmapWidth;
Rect.right -= ArrowBitmapWidth; Rect.right -= CheckBitmapWidth;
} }
else if (Item->hbmpItem) /* Draw the bitmap */ else if (Item->hbmpItem) /* Draw the bitmap */
{ {
@ -1256,7 +1248,7 @@ MenuCalcItemSize(HDC Dc, PROSMENUITEMINFO ItemInfo, PROSMENUINFO MenuInfo, HWND
{ {
ItemInfo->Rect.bottom += SEPARATOR_HEIGHT; ItemInfo->Rect.bottom += SEPARATOR_HEIGHT;
if( !MenuBar) if( !MenuBar)
ItemInfo->Rect.right += ArrowBitmapWidth + MenuCharSize.cx; ItemInfo->Rect.right += CheckBitmapWidth + MenuCharSize.cx;
return; return;
} }
@ -1286,7 +1278,7 @@ MenuCalcItemSize(HDC Dc, PROSMENUITEMINFO ItemInfo, PROSMENUINFO MenuInfo, HWND
ItemInfo->Rect.right += 2 * CheckBitmapWidth; ItemInfo->Rect.right += 2 * CheckBitmapWidth;
ItemInfo->Rect.right += 4 + MenuCharSize.cx; ItemInfo->Rect.right += 4 + MenuCharSize.cx;
ItemInfo->XTab = ItemInfo->Rect.right; ItemInfo->XTab = ItemInfo->Rect.right;
ItemInfo->Rect.right += ArrowBitmapWidth; ItemInfo->Rect.right += CheckBitmapWidth;
} }
else /* hbmpItem & MenuBar */ else /* hbmpItem & MenuBar */
{ {
@ -1307,7 +1299,7 @@ MenuCalcItemSize(HDC Dc, PROSMENUITEMINFO ItemInfo, PROSMENUINFO MenuInfo, HWND
ItemInfo->Rect.right += CheckBitmapWidth; ItemInfo->Rect.right += CheckBitmapWidth;
ItemInfo->Rect.right += 4 + MenuCharSize.cx; ItemInfo->Rect.right += 4 + MenuCharSize.cx;
ItemInfo->XTab = ItemInfo->Rect.right; 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 */ /* it must be a text item - unless it's the system menu */