From 83f34aa4f856201ac4fab3509707e012c1f984f8 Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Sun, 31 May 2015 16:39:46 -0700 Subject: Issue #24293: Adds mapping from explicit colours to system colours to correctly handle user themes. --- Tools/msi/bundle/Default.thm | 14 +++--- .../bootstrap/PythonBootstrapperApplication.cpp | 57 ++++++++++++++++++++-- 2 files changed, 59 insertions(+), 12 deletions(-) diff --git a/Tools/msi/bundle/Default.thm b/Tools/msi/bundle/Default.thm index aac71ab..d5e1969 100644 --- a/Tools/msi/bundle/Default.thm +++ b/Tools/msi/bundle/Default.thm @@ -1,12 +1,12 @@ - #(loc.Caption) - Segoe UI - Segoe UI - Segoe UI - Segoe UI - Segoe UI - Segoe UI + #(loc.Caption) + Segoe UI + Segoe UI + Segoe UI + Segoe UI + Segoe UI + Segoe UI #(loc.HelpHeader) diff --git a/Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp b/Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp index 7f5af74..0c40be5 100644 --- a/Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp +++ b/Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp @@ -1475,6 +1475,8 @@ private: POINT ptCursor = { }; HMONITOR hMonitor = nullptr; MONITORINFO mi = { }; + COLORREF fg, bg; + HBRUSH bgBrush; // If the theme did not provide an icon, try using the icon from the bundle engine. if (!hIcon) { @@ -1484,12 +1486,23 @@ private: } } + fg = RGB(0, 0, 0); + bg = RGB(255, 255, 255); + bgBrush = (HBRUSH)(COLOR_WINDOW+1); + if (_theme->dwFontId < _theme->cFonts) { + THEME_FONT *font = &_theme->rgFonts[_theme->dwFontId]; + fg = font->crForeground; + bg = font->crBackground; + bgBrush = font->hBackground; + RemapColor(&fg, &bg, &bgBrush); + } + // Register the window class and create the window. wc.lpfnWndProc = PythonBootstrapperApplication::WndProc; wc.hInstance = _hModule; wc.hIcon = hIcon; wc.hCursor = ::LoadCursorW(nullptr, (LPCWSTR)IDC_ARROW); - wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); + wc.hbrBackground = bgBrush; wc.lpszMenuName = nullptr; wc.lpszClassName = PYBA_WINDOW_CLASS; if (!::RegisterClassW(&wc)) { @@ -1704,12 +1717,12 @@ private: } break; + case WM_CTLCOLORSTATIC: case WM_CTLCOLORBTN: if (pBA) { - HWND button = (HWND)lParam; - DWORD style = GetWindowLong(button, GWL_STYLE) & BS_TYPEMASK; - if (style == BS_COMMANDLINK || style == BS_DEFCOMMANDLINK) { - return (LRESULT)pBA->_theme->rgFonts[pBA->_theme->dwFontId].hBackground; + HBRUSH brush = nullptr; + if (pBA->SetControlColor((HWND)lParam, (HDC)wParam, &brush)) { + return (LRESULT)brush; } } break; @@ -1782,6 +1795,40 @@ private: return SUCCEEDED(hr); } + void RemapColor(COLORREF *fg, COLORREF *bg, HBRUSH *bgBrush) { + if (*fg == RGB(0, 0, 0)) { + *fg = GetSysColor(COLOR_WINDOWTEXT); + } else if (*fg == RGB(128, 128, 128)) { + *fg = GetSysColor(COLOR_GRAYTEXT); + } + if (*bgBrush && *bg == RGB(255, 255, 255)) { + *bg = GetSysColor(COLOR_WINDOW); + *bgBrush = GetSysColorBrush(COLOR_WINDOW); + } + } + + BOOL SetControlColor(HWND hWnd, HDC hDC, HBRUSH *brush) { + for (int i = 0; i < _theme->cControls; ++i) { + if (_theme->rgControls[i].hWnd != hWnd) { + continue; + } + + DWORD fontId = _theme->rgControls[i].dwFontId; + if (fontId > _theme->cFonts) { + fontId = 0; + } + THEME_FONT *fnt = &_theme->rgFonts[fontId]; + + COLORREF fg = fnt->crForeground, bg = fnt->crBackground; + *brush = fnt->hBackground; + RemapColor(&fg, &bg, brush); + SetTextColor(hDC, fg); + SetBkColor(hDC, bg); + + return TRUE; + } + return FALSE; + } // // OnShowFailure - display the failure page. -- cgit v0.12 From 773490099f243d91c0280b64462f1f9df4783392 Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Sun, 31 May 2015 16:39:46 -0700 Subject: Issue #24317: Makes Customize page default to installing per-user, and switching to All Users enable CompileAll. --- Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp | 6 ++++++ Tools/msi/bundle/bundle.wxs | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp b/Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp index 0c40be5..62b9614 100644 --- a/Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp +++ b/Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp @@ -89,6 +89,7 @@ enum CONTROL_ID { ID_TARGETDIR_EDITBOX, ID_CUSTOM_ASSOCIATE_FILES_CHECKBOX, ID_CUSTOM_INSTALL_ALL_USERS_CHECKBOX, + ID_CUSTOM_COMPILE_ALL_CHECKBOX, ID_CUSTOM_BROWSE_BUTTON, ID_CUSTOM_BROWSE_BUTTON_LABEL, ID_CUSTOM_INSTALL_BUTTON, @@ -149,6 +150,7 @@ static THEME_ASSIGN_CONTROL_ID CONTROL_ID_NAMES[] = { { ID_TARGETDIR_EDITBOX, L"TargetDir" }, { ID_CUSTOM_ASSOCIATE_FILES_CHECKBOX, L"AssociateFiles" }, { ID_CUSTOM_INSTALL_ALL_USERS_CHECKBOX, L"InstallAllUsers" }, + { ID_CUSTOM_COMPILE_ALL_CHECKBOX, L"CompileAll" }, { ID_CUSTOM_BROWSE_BUTTON, L"CustomBrowseButton" }, { ID_CUSTOM_BROWSE_BUTTON_LABEL, L"CustomBrowseButtonLabel" }, { ID_CUSTOM_INSTALL_BUTTON, L"CustomInstallButton" }, @@ -372,6 +374,10 @@ class PythonBootstrapperApplication : public CBalBaseBootstrapperApplication { checked = ThemeIsControlChecked(_theme, ID_CUSTOM_INSTALL_ALL_USERS_CHECKBOX); ThemeControlElevates(_theme, ID_CUSTOM_INSTALL_BUTTON, checked && (FAILED(hr) || !elevated)); ThemeControlEnable(_theme, ID_CUSTOM_BROWSE_BUTTON_LABEL, !checked); + if (checked) { + _engine->SetVariableNumeric(L"CompileAll", 1); + ThemeSendControlMessage(_theme, ID_CUSTOM_COMPILE_ALL_CHECKBOX, BM_SETCHECK, BST_CHECKED, 0); + } ThemeGetTextControl(_theme, ID_TARGETDIR_EDITBOX, &targetDir); if (targetDir) { // Check the current value against the default to see diff --git a/Tools/msi/bundle/bundle.wxs b/Tools/msi/bundle/bundle.wxs index c8a7f5c..76e87ab 100644 --- a/Tools/msi/bundle/bundle.wxs +++ b/Tools/msi/bundle/bundle.wxs @@ -23,7 +23,7 @@ - + @@ -60,7 +60,7 @@ - + -- cgit v0.12