diff options
Diffstat (limited to 'alf')
| -rw-r--r-- | alf/alfcompat.cpp | 74 |
1 files changed, 49 insertions, 25 deletions
diff --git a/alf/alfcompat.cpp b/alf/alfcompat.cpp index d764895..3efe210 100644 --- a/alf/alfcompat.cpp +++ b/alf/alfcompat.cpp @@ -579,6 +579,26 @@ ALF_Compat_DrawDisabledTextEmbossed(HDC hdc, DST_COMPLEX | DSS_DISABLED); } +struct ALF_Compat_DrawDisabledText_GrayTextClosure { + const TCHAR *text; + int cchText; + LONG width; + LONG height; + UINT format; +}; + +static BOOL CALLBACK +ALF_Compat_DrawDisabledText_GrayTextProc(HDC hdc, LPARAM lpdata, int cchData) +{ + (void)cchData; + + struct ALF_Compat_DrawDisabledText_GrayTextClosure *c = (struct ALF_Compat_DrawDisabledText_GrayTextClosure *)lpdata; + + RECT rc = { 0, 0, c->width, c->height }; + DrawText(hdc, c->text, c->cchText, &rc, c->format); + return TRUE; +} + static int ALF_Compat_DrawDisabledTextSolid(HDC hdc, LPCTSTR lpchText, @@ -586,24 +606,32 @@ ALF_Compat_DrawDisabledTextSolid(HDC hdc, LPRECT lprc, UINT format) { - COLORREF oldcolor = SetTextColor(hdc, GetSysColor(COLOR_GRAYTEXT)); - int r = DrawText(hdc, lpchText, cchText, lprc, format); - SetTextColor(hdc, oldcolor); - return r; -} - -// FIXME! This is how NT 3.x does it, need to figure out how to get the real 16bit look -static int -ALF_Compat_DrawDisabledText31(HDC hdc, - LPCTSTR lpchText, - int cchText, - LPRECT lprc, - UINT format) -{ - COLORREF oldcolor = SetTextColor(hdc, GetSysColor(COLOR_BTNSHADOW)); - int r = DrawText(hdc, lpchText, cchText, lprc, format); - SetTextColor(hdc, oldcolor); - return r; + DWORD graytext = GetSysColor(COLOR_GRAYTEXT); + if (graytext && graytext != GetSysColor(COLOR_BTNFACE)) { + // real gray color is available, use it for drawing + COLORREF oldcolor = SetTextColor(hdc, graytext); + int r = DrawText(hdc, lpchText, cchText, lprc, format); + SetTextColor(hdc, oldcolor); + return r; + } else { + // no real gray color (monochrome display or other weird color palette) + // need to go via GrayString + struct ALF_Compat_DrawDisabledText_GrayTextClosure c = { + lpchText, + cchText, + lprc->right - lprc->left, + lprc->bottom - lprc->top, + format + }; + + return GrayString(hdc, + GetSysColorBrush(COLOR_BTNTEXT), + ALF_Compat_DrawDisabledText_GrayTextProc, + (LPARAM)&c, + 42, + lprc->left, lprc->top, + lprc->right - lprc->left, lprc->bottom - lprc->top); + } } @@ -696,14 +724,10 @@ void ALF_LoadCompatFunctions(void) LOAD_FUNC(comctl32, LoadIconWithScaleDown); // initialize helper function for disabled text - if (ALF_Compat_Is40()) { - if (GetSystemMetrics(SM_SLOWMACHINE)) { - ALF_Compat_DrawDisabledText = ALF_Compat_DrawDisabledTextSolid; - } else { - ALF_Compat_DrawDisabledText = ALF_Compat_DrawDisabledTextEmbossed; - } + if (!ALF_Compat_Is40() || GetSystemMetrics(SM_SLOWMACHINE)) { + ALF_Compat_DrawDisabledText = ALF_Compat_DrawDisabledTextSolid; } else { - ALF_Compat_DrawDisabledText = ALF_Compat_DrawDisabledText31; + ALF_Compat_DrawDisabledText = ALF_Compat_DrawDisabledTextEmbossed; } // initialize double buffering wrapper |
