summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Kümmerlin <jonas@kuemmerlin.eu>2022-07-07 21:44:00 +0200
committerJonas Kümmerlin <jonas@kuemmerlin.eu>2022-07-07 21:44:00 +0200
commit79f807f4b5a7528b236b27134a731158f1c08057 (patch)
treedf90f0ce6c562c9c1d9d3cc16a536c1a62ab9f43
parentfdeb11df8875ef6e56d03f06a8389528aac059c8 (diff)
improve disabled text drawingHEADmaster
now working pretty much exactly like the standard controls, even on Win3.1 and on Win95 with monochrome displays
-rw-r--r--alf/alfcompat.cpp74
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