From 1e31b33f83e84436a42531969ec411c7b63e5c48 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Mon, 10 Jul 2023 22:56:32 +0300 Subject: [PATCH] Replaced rich text controls, they are not dark mode compatible. --- od-win32/darkmode.cpp | 1 - od-win32/resources/winuae.rc | 22 ++-- od-win32/win32gui.cpp | 242 +++++++++++++++++------------------ 3 files changed, 132 insertions(+), 133 deletions(-) diff --git a/od-win32/darkmode.cpp b/od-win32/darkmode.cpp index 1688f803..637536c5 100644 --- a/od-win32/darkmode.cpp +++ b/od-win32/darkmode.cpp @@ -683,7 +683,6 @@ void SubclassTreeViewControl(HWND hListView) } } - void SubClassStatusBar(HWND hwnd) { if (g_darkModeSupported && g_darkModeEnabled) { diff --git a/od-win32/resources/winuae.rc b/od-win32/resources/winuae.rc index 9a4dbc0b..1312fe6f 100644 --- a/od-win32/resources/winuae.rc +++ b/od-win32/resources/winuae.rc @@ -586,7 +586,7 @@ CAPTION "UAE Authors and Contributors..." FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN DEFPUSHBUTTON "Ok",ID_OK,238,324,53,14 - CONTROL "",IDC_CONTRIBUTORS,"RICHEDIT",TCS_HOTTRACK | TCS_VERTICAL | TCS_RAGGEDRIGHT | TCS_OWNERDRAWFIXED | TCS_MULTISELECT | WS_BORDER | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP,4,5,521,311 + CONTROL "",IDC_CONTRIBUTORS,"SysListView32",LVS_REPORT | LVS_ALIGNLEFT | LVS_NOSCROLL | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,10,7,510,312 END IDD_ERRORLOG DIALOGEX 0, 0, 530, 345 @@ -596,23 +596,23 @@ FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN DEFPUSHBUTTON "OK",IDOK,176,322,65,15 PUSHBUTTON "Clear log",IDC_ERRORLOGCLEAR,288,322,65,15 - CONTROL "",IDC_ERRORLOGMESSAGE,"RICHEDIT",TCS_HOTTRACK | TCS_VERTICAL | TCS_RAGGEDRIGHT | TCS_OWNERDRAWFIXED | TCS_MULTISELECT | WS_BORDER | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP,4,5,521,309 + CONTROL "",IDC_ERRORLOGMESSAGE,"SysListView32",LVS_REPORT | LVS_ALIGNLEFT | LVS_NOSCROLL | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,7,10,515,306 END IDD_ABOUT DIALOGEX 0, 0, 396, 316 STYLE DS_LOCALEDIT | DS_SETFONT | DS_3DLOOK | DS_CONTROL | WS_CHILD FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN - CONTROL "",IDC_RICHEDIT1,"RICHEDIT",TCS_SCROLLOPPOSITE | TCS_RAGGEDRIGHT | TCS_MULTISELECT | WS_DISABLED,85,36,210,35 - CONTROL "",IDC_RICHEDIT2,"RICHEDIT",TCS_SCROLLOPPOSITE | TCS_RAGGEDRIGHT | TCS_MULTISELECT | WS_DISABLED,21,84,343,28 + CTEXT "WinUAE",IDC_RICHEDIT1,85,36,210,35 + CTEXT "",IDC_RICHEDIT2,21,84,343,28 PUSHBUTTON "Contributors",IDC_CONTRIBUTORS,152,126,80,15 - CONTROL "",IDC_CLOANTOHOME,"RICHEDIT",TCS_SCROLLOPPOSITE | TCS_RAGGEDRIGHT | TCS_MULTISELECT | WS_DISABLED,22,194,112,24 - CONTROL "",IDC_AMIGAHOME,"RICHEDIT",TCS_SCROLLOPPOSITE | TCS_RAGGEDRIGHT | TCS_MULTISELECT | WS_DISABLED,136,194,112,24 - CONTROL "",IDC_WINUAEHOME,"RICHEDIT",TCS_SCROLLOPPOSITE | TCS_RAGGEDRIGHT | TCS_MULTISELECT | WS_DISABLED,251,194,112,24 - CONTROL "",IDC_ABIME,"RICHEDIT",TCS_SCROLLOPPOSITE | TCS_RAGGEDRIGHT | TCS_MULTISELECT | WS_DISABLED,22,222,112,24 - CONTROL "",IDC_CAPS,"RICHEDIT",TCS_SCROLLOPPOSITE | TCS_RAGGEDRIGHT | TCS_MULTISELECT | WS_DISABLED,136,222,112,24 - CONTROL "",IDC_AMIGASYS,"RICHEDIT",TCS_SCROLLOPPOSITE | TCS_RAGGEDRIGHT | TCS_MULTISELECT | WS_DISABLED,136,255,112,24 - CONTROL "",IDC_AMIKIT,"RICHEDIT",TCS_SCROLLOPPOSITE | TCS_RAGGEDRIGHT | TCS_MULTISELECT | WS_DISABLED,251,222,112,24 + CTEXT "",IDC_CLOANTOHOME,22,194,112,24 + CTEXT "",IDC_AMIGAHOME,136,194,112,24 + CTEXT "",IDC_WINUAEHOME,251,194,112,24 + CTEXT "",IDC_ABIME,22,222,112,24 + CTEXT "",IDC_CAPS,136,222,112,24 + CTEXT "",IDC_AMIGASYS,136,255,112,24 + CTEXT "",IDC_AMIKIT,251,222,112,24 END IDD_MISC1 DIALOGEX 0, 0, 396, 316 diff --git a/od-win32/win32gui.cpp b/od-win32/win32gui.cpp index ba1aafa6..7788d35f 100644 --- a/od-win32/win32gui.cpp +++ b/od-win32/win32gui.cpp @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include @@ -2627,9 +2626,9 @@ void gui_infotextbox(HWND hDlg, const TCHAR *text) TranslateMessage (&msg); DispatchMessage (&msg); } + if (stringboxdialogactive == -1) + break; } - if (stringboxdialogactive == -1) - break; } if (font) { DeleteObject(font); @@ -2723,9 +2722,9 @@ static void infofloppy (HWND hDlg, int n) TranslateMessage (&msg); DispatchMessage (&msg); } + if (stringboxdialogactive == -1) + break; } - if (stringboxdialogactive == -1) - break; } DeleteObject (font); } @@ -6505,7 +6504,6 @@ static INT_PTR CALLBACK LoadSaveDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPA static INT_PTR CALLBACK ErrorLogProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - CHARFORMAT CharFormat; TCHAR *err; if (dialog_inhibit) @@ -6531,17 +6529,47 @@ static INT_PTR CALLBACK ErrorLogProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM } break; case WM_INITDIALOG: - err = get_error_log (); - if (err == NULL) - return FALSE; - CharFormat.cbSize = sizeof (CharFormat); - SetDlgItemText (hDlg, IDC_ERRORLOGMESSAGE, err); - xSendDlgItemMessage (hDlg, IDC_ERRORLOGMESSAGE, EM_GETCHARFORMAT, 0, (LPARAM) & CharFormat); - CharFormat.dwMask |= CFM_SIZE | CFM_FACE; - CharFormat.yHeight = -getscaledfontsize(8 * 20); /* height in twips, where a twip is 1/20th of a point - for a pt.size of 18 */ - _tcscpy (CharFormat.szFaceName, _T("Segoe UI")); - xSendDlgItemMessage (hDlg, IDC_ERRORLOGMESSAGE, EM_SETCHARFORMAT, SCF_ALL, (LPARAM) & CharFormat); - return TRUE; + { + err = get_error_log (); + if (err == NULL) + return FALSE; + HWND list = GetDlgItem(hDlg, IDC_ERRORLOGMESSAGE); + SubclassListViewControl(list); + + LV_COLUMN lvcolumn; + RECT r; + GetClientRect(list, &r); + lvcolumn.mask = LVCF_WIDTH; + lvcolumn.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM; + lvcolumn.iSubItem = 0; + lvcolumn.fmt = LVCFMT_LEFT; + lvcolumn.pszText = _T(""); + lvcolumn.cx = r.right - r.left; + ListView_InsertColumn(list, 0, &lvcolumn); + + TCHAR *s = err; + int cnt = 0; + while (*s) { + TCHAR *se = _tcschr(s, '\n'); + if (se) { + *se = 0; + } + LV_ITEM lvstruct; + lvstruct.mask = LVIF_TEXT | LVIF_PARAM; + lvstruct.pszText = s; + lvstruct.lParam = 0; + lvstruct.iItem = cnt; + lvstruct.iSubItem = 0; + ListView_InsertItem(list, &lvstruct); + if (!se) { + break; + } + cnt++; + s = se + 1; + } + xfree(err); + return TRUE; + } } return FALSE; } @@ -6552,8 +6580,6 @@ static TCHAR szContributors[MAX_CONTRIBUTORS_LENGTH * 2]; static INT_PTR CALLBACK ContributorsProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - CHARFORMAT CharFormat; - if (dialog_inhibit) return 0; @@ -6579,20 +6605,47 @@ static INT_PTR CALLBACK ContributorsProc (HWND hDlg, UINT msg, WPARAM wParam, LP } break; case WM_INITDIALOG: - CharFormat.cbSize = sizeof (CharFormat); - - WIN32GUI_LoadUIString(IDS_CONTRIBUTORS1, szContributors1, MAX_CONTRIBUTORS_LENGTH); - WIN32GUI_LoadUIString(IDS_CONTRIBUTORS2, szContributors2, MAX_CONTRIBUTORS_LENGTH); - _stprintf (szContributors, _T("%s%s"), szContributors1, szContributors2); - - SetDlgItemText (hDlg, IDC_CONTRIBUTORS, szContributors ); - xSendDlgItemMessage (hDlg, IDC_CONTRIBUTORS, EM_GETCHARFORMAT, 0, (LPARAM) & CharFormat); - CharFormat.dwMask |= CFM_SIZE | CFM_FACE; - CharFormat.yHeight = getscaledfontsize(8 * 20); /* height in twips, where a twip is 1/20th of a point - for a pt.size of 18 */ - - _tcscpy (CharFormat.szFaceName, _T("Segoe UI")); - xSendDlgItemMessage (hDlg, IDC_CONTRIBUTORS, EM_SETCHARFORMAT, SCF_ALL, (LPARAM) & CharFormat); - return TRUE; + { + HWND list = GetDlgItem(hDlg, IDC_CONTRIBUTORS); + SubclassListViewControl(list); + + WIN32GUI_LoadUIString(IDS_CONTRIBUTORS1, szContributors1, MAX_CONTRIBUTORS_LENGTH); + WIN32GUI_LoadUIString(IDS_CONTRIBUTORS2, szContributors2, MAX_CONTRIBUTORS_LENGTH); + _stprintf (szContributors, _T("%s%s"), szContributors1, szContributors2); + + LV_COLUMN lvcolumn; + RECT r; + GetClientRect(list, &r); + lvcolumn.mask = LVCF_WIDTH; + lvcolumn.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM; + lvcolumn.iSubItem = 0; + lvcolumn.fmt = LVCFMT_LEFT; + lvcolumn.pszText = _T(""); + lvcolumn.cx = r.right - r.left; + ListView_InsertColumn(list, 0, &lvcolumn); + + TCHAR *s = szContributors; + int cnt = 0; + while (*s) { + TCHAR *se = _tcschr(s, '\n'); + if (se) { + *se = 0; + } + LV_ITEM lvstruct; + lvstruct.mask = LVIF_TEXT | LVIF_PARAM; + lvstruct.pszText = s; + lvstruct.lParam = 0; + lvstruct.iItem = cnt; + lvstruct.iSubItem = 0; + ListView_InsertItem(list, &lvstruct); + if (!se) { + break; + } + cnt++; + s = se + 1; + } + return TRUE; + } } return FALSE; } @@ -6626,34 +6679,13 @@ static urlinfo urls[] = { -1, FALSE, NULL, NULL } }; -static void SetupRichText(HWND hDlg, urlinfo *url) -{ - CHARFORMAT CharFormat; - CharFormat.cbSize = sizeof (CharFormat); - - SetDlgItemText (hDlg, url->id, url->display); - xSendDlgItemMessage (hDlg, url->id, EM_GETCHARFORMAT, 0, (LPARAM)&CharFormat); - CharFormat.dwMask |= CFM_UNDERLINE | CFM_SIZE | CFM_FACE | CFM_COLOR; - CharFormat.dwEffects = url->state ? CFE_UNDERLINE : 0; - CharFormat.yHeight = getscaledfontsize(10 * 20); /* height in twips, where a twip is 1/20th of a point - for a pt.size of 18 */ - - CharFormat.crTextColor = GetSysColor (COLOR_ACTIVECAPTION); - _tcscpy (CharFormat.szFaceName, _T("Segoe UI")); - xSendDlgItemMessage (hDlg, url->id, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&CharFormat); - xSendDlgItemMessage (hDlg, url->id, EM_SETBKGNDCOLOR, 0, GetSysColor (COLOR_3DFACE)); -} - static void url_handler (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - static int last_rectangle = -1; - int i; - BOOL found = FALSE; - HCURSOR m_hCursor = NULL; POINT point; point.x = LOWORD (lParam); point.y = HIWORD (lParam); - for (i = 0; urls[i].id >= 0; i++) + for (int i = 0; urls[i].id >= 0; i++) { RECT rect; GetWindowRect (GetDlgItem(hDlg, urls[i].id), &rect); @@ -6666,41 +6698,8 @@ static void url_handler (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) ShellExecute (NULL, NULL, urls[i].url , NULL, NULL, SW_SHOWNORMAL); SetCursor(LoadCursor(NULL, IDC_ARROW)); } - else - { - if(i != last_rectangle) - { - // try and load the system hand (Win2000+) - m_hCursor = LoadCursor (NULL, IDC_HAND); - if (!m_hCursor) - { - // retry with our fallback hand - m_hCursor = LoadCursor (hInst, MAKEINTRESOURCE (IDC_MYHAND) ); - } - SetCursor (m_hCursor); - urls[i].state = TRUE; - SetupRichText (hDlg, &urls[i]); - - if(last_rectangle != -1) - { - urls[last_rectangle].state = FALSE; - SetupRichText (hDlg, &urls[last_rectangle]); - } - } - } - last_rectangle = i; - found = TRUE; - break; } } - - if(!found && last_rectangle >= 0) - { - SetCursor (LoadCursor (NULL, IDC_ARROW)); - urls[last_rectangle].state = FALSE; - SetupRichText (hDlg, &urls[last_rectangle]); - last_rectangle = -1; - } } static void setac (HWND hDlg, int id) @@ -8049,36 +8048,13 @@ static INT_PTR CALLBACK QuickstartDlgProc (HWND hDlg, UINT msg, WPARAM wParam, L static void init_aboutdlg (HWND hDlg) { - CHARFORMAT CharFormat; - int i; - - CharFormat.cbSize = sizeof (CharFormat); - SetDlgItemText (hDlg, IDC_RICHEDIT1, _T("WinUAE")); - xSendDlgItemMessage (hDlg, IDC_RICHEDIT1, EM_GETCHARFORMAT, 0, (LPARAM) & CharFormat); - CharFormat.dwMask |= CFM_BOLD | CFM_SIZE | CFM_FACE; - CharFormat.dwEffects = CFE_BOLD; - CharFormat.yHeight = -getscaledfontsize(30 * 20); /* height in twips, where a twip is 1/20th of a point */ - - _tcscpy (CharFormat.szFaceName, _T("Segoe UI")); - xSendDlgItemMessage (hDlg, IDC_RICHEDIT1, EM_SETCHARFORMAT, SCF_ALL, (LPARAM) & CharFormat); - xSendDlgItemMessage (hDlg, IDC_RICHEDIT1, EM_SETBKGNDCOLOR, 0, GetSysColor (COLOR_3DFACE)); - - SetDlgItemText (hDlg, IDC_RICHEDIT2, VersionStr ); - xSendDlgItemMessage (hDlg, IDC_RICHEDIT2, EM_GETCHARFORMAT, 0, (LPARAM) & CharFormat); - CharFormat.dwMask |= CFM_SIZE | CFM_FACE; - CharFormat.dwEffects = CFE_BOLD; - CharFormat.yHeight = -getscaledfontsize(16 * 20); - _tcscpy (CharFormat.szFaceName, _T("Segoe UI")); - xSendDlgItemMessage (hDlg, IDC_RICHEDIT2, EM_SETCHARFORMAT, SCF_ALL, (LPARAM) & CharFormat); - xSendDlgItemMessage (hDlg, IDC_RICHEDIT2, EM_SETBKGNDCOLOR, 0, GetSysColor (COLOR_3DFACE)); - - for(i = 0; urls[i].id >= 0; i++) - SetupRichText (hDlg, &urls[i]); } static INT_PTR CALLBACK AboutDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { + static HFONT font1, font2; + if (dialog_inhibit) return 0; @@ -8091,11 +8067,35 @@ static INT_PTR CALLBACK AboutDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM switch( msg ) { case WM_INITDIALOG: - pages[ABOUT_ID] = hDlg; - currentpage = ABOUT_ID; - init_aboutdlg (hDlg); - break; - + { + pages[ABOUT_ID] = hDlg; + currentpage = ABOUT_ID; + + if (!font1) { + font1 = CreateFont(-getscaledfontsize(60), 0, 0, 0, 0, + 0, FALSE, FALSE, DEFAULT_CHARSET, 0, 0, + PROOF_QUALITY, FF_DONTCARE, _T("Segoe UI")); + } + if (!font2) { + font2 = CreateFont(-getscaledfontsize(32), 0, 0, 0, 0, + 0, FALSE, FALSE, DEFAULT_CHARSET, 0, 0, + PROOF_QUALITY, FF_DONTCARE, _T("Segoe UI")); + } + + HWND hwnd = GetDlgItem(hDlg, IDC_RICHEDIT1); + SendMessage(hwnd, WM_SETFONT, (WPARAM)font1, 0); + SetWindowText(hwnd, _T("WinUAE")); + hwnd = GetDlgItem(hDlg, IDC_RICHEDIT2); + SendMessage(hwnd, WM_SETFONT, (WPARAM)font1, 0); + SetWindowText(hwnd, VersionStr); + + for (int i = 0; urls[i].id >= 0; i++) { + hwnd = GetDlgItem(hDlg, urls[i].id); + SendMessage(hwnd, WM_SETFONT, (WPARAM)font2, 0); + SetWindowText(hwnd, urls[i].display); + } break; + return TRUE; + } case WM_COMMAND: if (wParam == IDC_CONTRIBUTORS) DisplayContributors (hDlg); @@ -8105,7 +8105,7 @@ static INT_PTR CALLBACK AboutDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM break; case WM_LBUTTONDOWN: case WM_MOUSEMOVE: - url_handler (hDlg, msg, wParam, lParam); + url_handler(hDlg, msg, wParam, lParam); break; } @@ -23036,9 +23036,9 @@ int CustomCreateDialogBox(int templ, HWND hDlg, DLGPROC proc) TranslateMessage(&msg); DispatchMessage(&msg); } + if (customdialogactive == -1) + break; } - if (customdialogactive == -1) - break; } return 1; } -- 2.47.3