From 31be76a65fb3cae1f5f1bea82243b39716a4e5c7 Mon Sep 17 00:00:00 2001 From: Edwig Date: Sat, 16 Jul 2022 20:37:14 +0200 Subject: [PATCH] Version 1.0.13 New StyleFramework --- Documentation/Releasenotes.txt | 6 + Installer/kwatta.nsi | 8 +- Kwatta/KwattaAppDlg.cpp | 4 +- Kwatta/MutateNamesDlg.cpp | 6 +- Kwatta/SplashDlg.cpp | 1 - Kwatta/StarterDlg.cpp | 4 +- Kwatta/SystemDlg.cpp | 6 +- ResultViewer/resource.h | Bin 6446 -> 6536 bytes StepEditor/resource.h | Bin 20578 -> 20668 bytes StyleFramework/Grid/GridCellCombo.cpp | 5 +- StyleFramework/Grid/GridCtrl.cpp | 4 +- StyleFramework/SkinScrollWnd.cpp | 12 +- StyleFramework/StyleButton.cpp | 28 +- StyleFramework/StyleCalendar.cpp | 6 +- StyleFramework/StyleCheckBox.cpp | 49 +- StyleFramework/StyleColors.cpp | 58 +- StyleFramework/StyleColors.h | 80 ++- StyleFramework/StyleComboBox.cpp | 24 +- StyleFramework/StyleDialog.cpp | 61 +- StyleFramework/StyleDialog.h | 2 + StyleFramework/StyleDialogCA.cpp | 2 + StyleFramework/StyleEdit.cpp | 134 +++-- StyleFramework/StyleEdit.h | 9 +- StyleFramework/StyleFrameWnd.cpp | 10 +- StyleFramework/StyleFrameWndEx.cpp | 23 +- StyleFramework/StyleFrameWork.h | 1 + StyleFramework/StyleFramework.rc | 2 + StyleFramework/StyleFramework.vcxproj | 87 ++- StyleFramework/StyleFramework.vcxproj.filters | 9 + StyleFramework/StyleGridCtrl.cpp | 33 +- StyleFramework/StyleGridCtrl.h | 1 + StyleFramework/StyleGroupBox.cpp | 133 +++++ StyleFramework/StyleGroupBox.h | 37 ++ StyleFramework/StyleHyperlink.cpp | 22 +- StyleFramework/StyleHyperlink.h | 2 +- StyleFramework/StyleListBox.cpp | 536 +++++++++++++++++- StyleFramework/StyleListBox.h | 39 +- StyleFramework/StyleListCtrl.cpp | 37 +- StyleFramework/StyleListCtrl.h | 3 +- StyleFramework/StyleMDIFrameWnd.cpp | 36 +- StyleFramework/StyleMacros.h | 2 +- StyleFramework/StyleMessageBox.cpp | 12 +- StyleFramework/StyleMessageBox.h | 2 +- StyleFramework/StyleProgressCtrl.cpp | 8 +- StyleFramework/StyleProgressCtrl.h | 2 +- StyleFramework/StyleSpinButtonCtrl.cpp | 8 +- StyleFramework/StyleTabCtrl.cpp | 14 +- StyleFramework/StyleToast.cpp | 4 +- StyleFramework/StyleTreeCtrl.cpp | 22 +- StyleFramework/StyleTreeCtrl.h | 1 + StyleFramework/res/ScrollBar7.bmp | Bin 0 -> 13782 bytes StyleFramework/resource.h | Bin 4884 -> 4960 bytes StyleFramework/stdafx.h | Bin 3018 -> 3318 bytes SuiteLibrary/AboutDlg.cpp | 4 +- SuiteLibrary/SuiteLibrary.h | 6 +- TestEditor/MutateDlg.cpp | 4 +- TestEditor/resource.h | Bin 9200 -> 9290 bytes TestRunner/resource.h | Bin 3886 -> 3976 bytes ValidateEditor/resource.h | Bin 12056 -> 12146 bytes 59 files changed, 1344 insertions(+), 265 deletions(-) create mode 100644 StyleFramework/StyleGroupBox.cpp create mode 100644 StyleFramework/StyleGroupBox.h create mode 100644 StyleFramework/res/ScrollBar7.bmp diff --git a/Documentation/Releasenotes.txt b/Documentation/Releasenotes.txt index 16d63c8..3041fc9 100644 --- a/Documentation/Releasenotes.txt +++ b/Documentation/Releasenotes.txt @@ -1,6 +1,12 @@ KWATTA RELEASNOTES ================== +Version 1.0.13 Release date: 16-07-2022 +--------------------------------------- +1) Upgraded to new version of the StyleFramework, fixing many bugs + e.g. No erasure in non-mutable fields with DEL/DELETE keys +2) Support for OData 4.00 batches and Concept-ID of batches + Version 1.0.10 Release date: 03-05-2022 --------------------------------------- 1) Added the SQL test type. Add your SQL tests!! diff --git a/Installer/kwatta.nsi b/Installer/kwatta.nsi index a4d93fa..f00603c 100644 --- a/Installer/kwatta.nsi +++ b/Installer/kwatta.nsi @@ -6,12 +6,12 @@ ; Copyright (c) 2021 ir. W.E. Huisman ; All rights reserved ; -; Last change: 3-05-2022 -; Versionnumber: 1.0.11 +; Last change: 16-07-2022 +; Versionnumber: 1.0.13 ;------------------------------------------------------- !define PRODUCT_NAME "Kwatta" - !define PRODUCT_VERSION "1.0.11" - !define PRODUCT_BUILDNUMBER "132" + !define PRODUCT_VERSION "1.0.13" + !define PRODUCT_BUILDNUMBER "138" !define PRODUCT_PUBLISHER "EDO" !define PRODUCT_WEB_SITE "https://github.com/edwig/kwatta" !define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\${PRODUCT_NAME}" diff --git a/Kwatta/KwattaAppDlg.cpp b/Kwatta/KwattaAppDlg.cpp index 0d570f6..b417adc 100644 --- a/Kwatta/KwattaAppDlg.cpp +++ b/Kwatta/KwattaAppDlg.cpp @@ -43,6 +43,8 @@ static char THIS_FILE[] = __FILE__; #define new DEBUG_NEW #endif +using namespace ThemeColor; + IMPLEMENT_DYNAMIC(KwattaAppDlg, StyleDialog) KwattaAppDlg::KwattaAppDlg(CWnd* p_parent,CString p_suiteFilename) @@ -108,7 +110,7 @@ KwattaAppDlg::DoDataExchange(CDataExchange* pDX) } m_editTestsuite.SetMutable(m_testsuite.IsEmpty()); - m_editTestsuite.SetBkColor(m_testsuite.IsEmpty() ? ClrEditBkgnd : ThemeColor::_Color2); + m_editTestsuite.SetBkColor(m_testsuite.IsEmpty() ? ClrEditBkgnd : ThemeColor::GetColor(Colors::AccentColor2)); } BEGIN_MESSAGE_MAP(KwattaAppDlg, StyleDialog) diff --git a/Kwatta/MutateNamesDlg.cpp b/Kwatta/MutateNamesDlg.cpp index 945294a..67b01a2 100644 --- a/Kwatta/MutateNamesDlg.cpp +++ b/Kwatta/MutateNamesDlg.cpp @@ -25,6 +25,8 @@ #include "ExtraExtensions.h" #include +using namespace ThemeColor; + // MutateNamesDlg dialog IMPLEMENT_DYNAMIC(MutateNamesDlg, StyleDialog) @@ -72,9 +74,9 @@ MutateNamesDlg::OnInitDialog() SetWindowText("Change directory or filename"); m_editOrigDirectory.SetMutable(false); - m_editOrigDirectory.SetBkColor(ThemeColor::_Color2); + m_editOrigDirectory.SetBkColor(ThemeColor::GetColor(Colors::AccentColor2)); m_editOrigFilename .SetMutable(false); - m_editOrigFilename .SetBkColor(ThemeColor::_Color2); + m_editOrigFilename .SetBkColor(ThemeColor::GetColor(Colors::AccentColor2)); m_newDirectory = m_origDirectory; m_newFilename = m_origFilename; diff --git a/Kwatta/SplashDlg.cpp b/Kwatta/SplashDlg.cpp index 37cfd21..03c66fc 100644 --- a/Kwatta/SplashDlg.cpp +++ b/Kwatta/SplashDlg.cpp @@ -70,7 +70,6 @@ SplashDlg::OnInitDialog() m_editTitle.SetMutable(false); m_editTitle.SetFontName("Verdana",420); m_editTitle.SetFontStyle(true); - m_editTitle.SetMutable(false); UpdateData(FALSE); diff --git a/Kwatta/StarterDlg.cpp b/Kwatta/StarterDlg.cpp index 7b4bc75..38295ce 100644 --- a/Kwatta/StarterDlg.cpp +++ b/Kwatta/StarterDlg.cpp @@ -28,6 +28,8 @@ #include #include +using namespace ThemeColor; + // StarterDlg dialog IMPLEMENT_DYNAMIC(StarterDlg, StyleDialog) @@ -89,7 +91,7 @@ void StarterDlg::InitTitle() { m_title = "Kwatta Test Suite " KWATTA_YEAR; - m_editTitle.SetBkColor(ThemeColor::_Color1); + m_editTitle.SetBkColor(ThemeColor::GetColor(Colors::AccentColor1)); m_editTitle.SetTextColor(RGB(255, 255, 255)); m_editTitle.SetFontSize(240); m_editTitle.SetFontStyle(true); diff --git a/Kwatta/SystemDlg.cpp b/Kwatta/SystemDlg.cpp index 041b7f3..fbc262c 100644 --- a/Kwatta/SystemDlg.cpp +++ b/Kwatta/SystemDlg.cpp @@ -23,6 +23,8 @@ #include #include "resource.h" +using namespace ThemeColor; + // SystemDlg dialog IMPLEMENT_DYNAMIC(SystemDlg, StyleDialog) @@ -84,7 +86,7 @@ SystemDlg::InitButtons() m_buttonCancel .SetStyle("can"); m_editPassword.SetMutable(false); - m_editPassword.SetBkColor(ThemeColor::_Color2); + m_editPassword.SetBkColor(ThemeColor::GetColor(Colors::AccentColor2)); m_comboLoglevel.AddString("No logging"); // HLL_NOLOG 0 // No logging is ever done m_comboLoglevel.AddString("Error logging only"); // HLL_ERRORS 1 // Only errors are logged @@ -95,7 +97,7 @@ SystemDlg::InitButtons() m_help.SetTipText("Use to set the KWATTA_PASSWORD variable with the 'setx /m' command!"); m_help.SetURL("https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/setx"); - m_help.SetColours(ThemeColor::_Color1,RGB(0,0,255)); + m_help.SetColours(ThemeColor::GetColor(Colors::AccentColor1),RGB(0,0,255)); } void diff --git a/ResultViewer/resource.h b/ResultViewer/resource.h index 872f7c71ffb279fafd6e12a59bff538e3f9e68bb..c2c277259109186e315d44ed3031588c36c3c9d7 100644 GIT binary patch delta 49 zcmV-10M7reGKe#<2)T0tFhApa=}J HQV84-ntTt$ delta 31 ncmeA$UT3sn68j`(mdPL3Z6;r0mzwOx;V@Z;Lu&H^ju!#|xljuq diff --git a/StepEditor/resource.h b/StepEditor/resource.h index bdd9115d5146df737a376dfc013c8f52bd14046f..9f22b01c50e30b071c17df323d4a52ead653ef69 100644 GIT binary patch delta 54 zcmaE~fN{@4#tnV!lN;E?7|kbtWYe5{j$LZ90uRgNH|$}PH!y=}8%DFq2iasNFW}(V J?8hPE0RSyW62t%i delta 42 zcmV+_0M-Azp#kEc0kDn-lOPNPlk5jPlgSelectObject(&pen); // draw vertical lines (drawn at ends of cells) diff --git a/StyleFramework/SkinScrollWnd.cpp b/StyleFramework/SkinScrollWnd.cpp index 80ea7c1..26ea20c 100644 --- a/StyleFramework/SkinScrollWnd.cpp +++ b/StyleFramework/SkinScrollWnd.cpp @@ -33,6 +33,8 @@ static char THIS_FILE[] = __FILE__; #endif +using namespace ThemeColor; + #define TIMER_UPDATE 100 // Update the scrollbars after this amount of milliseconds #define SF_LIMITERMOVE (WM_USER+100) // User message to move the scrollbars, limiter and control @@ -175,7 +177,7 @@ HookWndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) rcVert.top = border; rcVert.bottom = nBottom - border + 1 - bias; rcHorz.left = border; - rcHorz.right = nRight - border; + rcHorz.right = nRight - border + 1; rcHorz.top = nBottom + bias; rcHorz.bottom = nBottom + nWid + bias; } @@ -642,14 +644,14 @@ SkinScrollWnd::OnNcPaint() readonly = (control->GetStyle() & ES_READONLY) > 0 || !control->IsWindowEnabled(); if(readonly) { - color = ClrFrameBkGnd; + color = ThemeColor::GetColor(Colors::ColorWindowFrame); //ClrFrameBkGnd; } } StyleEdit* edit = reinterpret_cast(control); if(edit && edit->GetIsComboBox()) { - color = readonly ? m_borderColor : Assistant0; + color = readonly ? m_borderColor : ThemeColor::GetColor(Colors::ColorCtrlBackground); // Assistant0 } if(dc) @@ -822,7 +824,7 @@ SkinScrollWnd::DrawFrame() return; } - COLORREF color = ThemeColor::_Color2; + COLORREF color = ThemeColor::GetColor(Colors::AccentColor2); if (m_wndLimit.m_hWnd) { CWnd* control = m_wndLimit.GetWindow(GW_CHILD); @@ -843,7 +845,7 @@ SkinScrollWnd::DrawFrame() } if(control == GetFocus()) { - color = ThemeColor::_Color1; + color = ThemeColor::GetColor(Colors::AccentColor1); } } DrawFrame(color); diff --git a/StyleFramework/StyleButton.cpp b/StyleFramework/StyleButton.cpp index b88184e..a6c0d46 100644 --- a/StyleFramework/StyleButton.cpp +++ b/StyleFramework/StyleButton.cpp @@ -31,6 +31,8 @@ static char THIS_FILE[] = __FILE__; #endif +using namespace ThemeColor; + ////////////////////////////////////////////////////////////////////////// // // SERVICE FUNCTIONS FOR STYLE BUTTON @@ -474,8 +476,8 @@ StyleButton::Draw(CDC* pDC } else { - filling = ClrControlNormal; - textcolor = ClrControlTextNormal; + filling = ThemeColor::GetColor(Colors::ColorWindowFrame); // ClrControlNormal; + textcolor = ThemeColor::GetColor(Colors::AccentColor3); // ClrControlTextNormal; outline = ClrControlFrameNormal; } } @@ -491,15 +493,15 @@ StyleButton::Draw(CDC* pDC { if (over || (style & BS_DEFPUSHBUTTON)) { - filling = ClrControlDefault; + filling = ThemeColor::GetColor(Colors::AccentColor1); // ClrControlDefault; textcolor = ClrControlTextHover; outline = ClrControlFrameHover; } else { - filling = ClrControlNormal; - textcolor = ClrControlTextNormal; - outline = ThemeColor::_Color1; + filling = ThemeColor::GetColor(Colors::ColorCtrlBackground); // ClrControlNormal; + textcolor = ThemeColor::GetColor(Colors::AccentColor1); //ClrControlTextNormal; + outline = ThemeColor::GetColor(Colors::AccentColor1); } } } @@ -518,9 +520,9 @@ StyleButton::Draw(CDC* pDC else { - filling = ClrControlNormal; - textcolor = ClrControlTextNormal; - outline = ClrControlFrameNormal; + filling = ThemeColor::GetColor(Colors::ColorButtonBackground); // ClrControlNormal = UsersBackground + textcolor = ThemeColor::GetColor(Colors::ColorButtonText); // ClrControlTextNormal + outline = ThemeColor::GetColor(Colors::AccentColor1); // ClrControlFrameNormal } } else @@ -532,7 +534,7 @@ StyleButton::Draw(CDC* pDC if (p_mandatory) { - outline = ClrEditFrameVerplicht; + outline = ThemeColor::NoWhite(ThemeColor::GetColor(Colors::AccentColor1)); //ClrEditFrameVerplicht; } if (pInError) { @@ -559,7 +561,9 @@ StyleButton::Draw(CDC* pDC { if (p_themeColor) { - CWSExpander(pDC, rect).DrawIcon(hicon, ClrFrameBkGnd,ComboBoxActive); + CWSExpander(pDC, rect).DrawIcon(hicon + ,ThemeColor::GetColor(Colors::ColorWindowFrame) + ,ThemeColor::GetColor(Colors::ColorComboActive)); // Alternative without scaling // bmpRect.DeflateRect(1, 1); // br.DeleteObject(); @@ -583,7 +587,7 @@ StyleButton::Draw(CDC* pDC } else { - CWSExpander(pDC, rect).DrawIcon(hicon, ClrFrameBkGnd, textcolor); + CWSExpander(pDC, rect).DrawIcon(hicon,ThemeColor::GetColor(Colors::ColorWindowFrame),textcolor); // Alternative without scaling // br.DeleteObject(); // br.CreateSolidBrush(textcolor); diff --git a/StyleFramework/StyleCalendar.cpp b/StyleFramework/StyleCalendar.cpp index df2973c..1dec195 100644 --- a/StyleFramework/StyleCalendar.cpp +++ b/StyleFramework/StyleCalendar.cpp @@ -27,6 +27,8 @@ static char THIS_FILE[] = __FILE__; #endif +using namespace ThemeColor; + StyleCalendar::StyleCalendar(CWnd* p_parent,CString p_select,int top,int left) :StyleDialog(IDD_CALENDAR,p_parent) ,m_select(p_select) @@ -62,8 +64,8 @@ StyleCalendar::OnInitDialog() { m_control.SetFont(m_font); } - m_control.SetColor(MCSC_MONTHBK,ThemeColor::_Color1); - m_control.SetColor(MCSC_TEXT, ThemeColor::_Color1); + m_control.SetColor(MCSC_MONTHBK,ThemeColor::GetColor(Colors::AccentColor1)); + m_control.SetColor(MCSC_TEXT, ThemeColor::GetColor(Colors::AccentColor1)); // Find the size and position of the window CRect rect; diff --git a/StyleFramework/StyleCheckBox.cpp b/StyleFramework/StyleCheckBox.cpp index 2c9da3c..1ef0dc2 100644 --- a/StyleFramework/StyleCheckBox.cpp +++ b/StyleFramework/StyleCheckBox.cpp @@ -27,6 +27,8 @@ static char THIS_FILE[] = __FILE__; #endif +using namespace ThemeColor; + BEGIN_MESSAGE_MAP(StyleCheckbox, CButton) ON_WM_PAINT() ON_WM_KEYDOWN() @@ -84,35 +86,35 @@ StyleCheckbox::Draw(CWnd* p_wnd if ((p_style & WS_DISABLED) != 0) { - filling = ClrControlDisabledBack; - textcolor = ClrControlDisabledFore; - outline = ThemeColor::_Color2; + filling = ThemeColor::GetColor(Colors::ColorCtrlBackground); // ClrControlDisabledBack; + textcolor = ThemeColor::GetColor(Colors::ColorEditText); // ClrControlDisabledFore; + outline = ThemeColor::GetColor(Colors::AccentColor2); } else { if ((p_state & BST_PUSHED) != 0) { - filling = ClrCheckboxPressed; - textcolor = ClrCheckboxTextPressed; - outline = ThemeColor::_Color1; + filling = ThemeColor::GetColor(Colors::ColorCtrlBackground); // ClrCheckboxPressed; + textcolor = ThemeColor::GetColor(Colors::ColorEditText); // ClrCheckboxTextPressed; + outline = ThemeColor::GetColor(Colors::AccentColor1); } else if ((p_state & BST_FOCUS) != 0) { - filling = ClrCheckboxFocus; - textcolor = ClrCheckboxTextFocus; - outline = ThemeColor::_Color1; + filling = ThemeColor::GetColor(Colors::ColorCtrlBackground); // ClrCheckboxFocus; + textcolor = ThemeColor::NoWhite(ThemeColor::GetColor(Colors::AccentColor1)); // ClrCheckboxTextFocus; + outline = ThemeColor::GetColor(Colors::AccentColor1); } else if (p_hover) { - filling = ClrCheckboxHover; - textcolor = ClrCheckboxTextHover; - outline = ThemeColor::_Color1; + filling = ThemeColor::GetColor(Colors::ColorCtrlBackground); //ClrCheckboxHover; + textcolor = ThemeColor::NoWhite(ThemeColor::GetColor(Colors::AccentColor1)); // ClrCheckboxTextHover; + outline = ThemeColor::GetColor(Colors::AccentColor1); } else { - filling = ClrCheckboxNormal; - textcolor = ClrCheckboxTextNormal; - outline = ThemeColor::_Color2; + filling = ThemeColor::GetColor(Colors::ColorCtrlBackground); // ClrCheckboxNormal; + textcolor = ThemeColor::GetColor(Colors::ColorEditText); // ClrCheckboxTextNormal; + outline = ThemeColor::GetColor(Colors::AccentColor1); } } @@ -143,7 +145,7 @@ StyleCheckbox::Draw(CWnd* p_wnd CSize MySize(p_rect.Height() * FACTOR, p_rect.Height() * FACTOR); bitmap.CreateCompatibleBitmap(p_dc, MySize.cx, MySize.cy); dc.SelectObject(bitmap); - dc.FillSolidRect(0, 0, MySize.cx, MySize.cy, ClrFrameBkGnd); + dc.FillSolidRect(0,0,MySize.cx,MySize.cy,ThemeColor::GetColor(Colors::ColorWindowFrame)); // ClrFrameBkGnd); // Draw the edge CPen pen; @@ -163,11 +165,11 @@ StyleCheckbox::Draw(CWnd* p_wnd r.DeflateRect(3 * FACTOR, 3 * FACTOR); pen.DeleteObject(); - pen.CreatePen(PS_SOLID, 1, textcolor); + pen.CreatePen(PS_SOLID, 1, outline); dc.SelectObject(pen); br.DeleteObject(); - br.CreateSolidBrush(textcolor); + br.CreateSolidBrush(outline); dc.SelectObject(br); dc.Ellipse(r); @@ -201,7 +203,7 @@ StyleCheckbox::Draw(CWnd* p_wnd } CPen pen; - pen.CreatePen(PS_SOLID,2,textcolor); + pen.CreatePen(PS_SOLID,2,outline); p_dc->SelectObject(pen); if ((p_state & BST_CHECKED) != 0) @@ -213,7 +215,7 @@ StyleCheckbox::Draw(CWnd* p_wnd else if ((p_state & BST_INDETERMINATE) != 0) { mark.DeflateRect(3, 3); - p_dc->FillSolidRect(mark, textcolor); + p_dc->FillSolidRect(mark, outline); } } @@ -227,8 +229,9 @@ StyleCheckbox::Draw(CWnd* p_wnd CPen pen; pen.CreatePen(PS_SOLID,1,textcolor); p_dc->SelectObject(pen); - p_dc->SetBkColor(ClrCheckBoxDefaultBkGrnd); + p_dc->SetBkColor(ThemeColor::GetColor(Colors::ColorWindowFrame)); // ClrCheckBoxDefaultBkGrnd p_dc->SelectObject(STYLEFONTS.DialogTextFont); + p_dc->SetTextColor(textcolor); p_rect.left += WS(28); p_dc->DrawText(text,&p_rect,DT_VCENTER | DT_SINGLELINE); } @@ -248,7 +251,7 @@ StyleCheckbox::OnPaint() GetClientRect(rect); // Remove underlying MFC implementation - dc.FillSolidRect(rect,ClrCheckBoxDefaultBkGrnd); + dc.FillSolidRect(rect, ThemeColor::GetColor(Colors::ColorWindowFrame)); // ClrCheckBoxDefaultBkGrnd DWORD style = GetStyle(); UINT state = GetState(); @@ -277,7 +280,7 @@ StyleCheckbox::OnEraseBkgnd(CDC* pDC) { CRect rcChild; GetClientRect(rcChild); - pDC->FillSolidRect(0, 0, rcChild.Width(), rcChild.Height(),ClrCheckBoxDefaultBkGrnd); + pDC->FillSolidRect(0, 0, rcChild.Width(), rcChild.Height(),ThemeColor::GetColor(Colors::ColorWindowFrame));// ClrCheckBoxDefaultBkGrnd); } return TRUE; diff --git a/StyleFramework/StyleColors.cpp b/StyleFramework/StyleColors.cpp index fe43fa2..7c81287 100644 --- a/StyleFramework/StyleColors.cpp +++ b/StyleFramework/StyleColors.cpp @@ -33,12 +33,32 @@ using namespace ThemeColor; UINT ThemeColor::g_msg_changed = 0; // Put default theme to Loyalty -COLORREF ThemeColor::_Color1 = Skyblue1; -COLORREF ThemeColor::_Color2 = Skyblue2; -COLORREF ThemeColor::_Color3 = Skyblue3; -COLORREF ThemeColor::_Color4 = SkyblueHeader; Themes ThemeColor::_theme = ThemeColor::Themes::ThemeSkyblue; +const int ThemeColor::theme_colors[NO_OF_COLORS][NO_OF_THEMES] = +{ + /* LIME SKYBLUE PURPLE MODERATE-GRAY PURE-GRAY BLACK-WHITE, DARK-THEME */ + { Lime1, Skyblue1, Purple1, ModerateGray1, PureGray1, BlackWhite1, Dark1 } // AccentColor1 + ,{ Lime2, Skyblue2, Purple2, ModerateGray2, PureGray2, BlackWhite2, Dark2 } // AccentColor2 + ,{ Lime3, Skyblue3, Purple3, ModerateGray3, PureGray3, BlackWhite3, Dark3 } // AccentColor3 + ,{ LimeHeader, SkyblueHeader, PurpleHeader, ModerateGrayHeader,PureGrayHeader, BlackWhiteHeader,DarkHeader } // AccentColor4 + ,{ UsersBackground,UsersBackground,UsersBackground,UsersBackground, UsersBackground,UsersBackground, DarkBackground } // ColorWindowFrame + ,{ Assistant0, Assistant0, Assistant0, Assistant0, Assistant0, Assistant0, DarkCtrlBackground } // ColorCtrlBackground + ,{ ClrEditText, ClrEditText, ClrEditText, ClrEditText, ClrEditText, ClrEditText, ClrEditDark } // ColorEditText + ,{ ClrEditText, ClrEditText, ClrEditText, ClrEditText, ClrEditText, ClrEditText, ClrEditDarkHover } // ColorEditHover + ,{ ClrEditText, ClrEditText, ClrEditText, ClrEditText, ClrEditText, ClrEditText, ClrEditDark } // ColorLabelText + ,{ ComboBoxActive, ComboBoxActive, ComboBoxActive, ComboBoxActive, ComboBoxActive, ComboBoxActive, ComboBoxDActive } // ColorComboActive + ,{ ComboBoxDropped,ComboBoxDropped,ComboBoxDropped,ComboBoxDropped, ComboBoxDropped,ComboBoxDropped, ComboBoxDDropped } // ColorComboDropped + ,{ GroupBoxLine, GroupBoxLine, GroupBoxLine, GroupBoxLine, GroupBoxLine, GroupBoxLine, GroupBoxLine, } // ColorGroupLine + ,{ UsersBackground,UsersBackground,UsersBackground,UsersBackground, UsersBackground,UsersBackground, DarkCtrlBackground } // ColorButtonBackground + ,{ Lime3, Skyblue3, Purple3, ModerateGray3, PureGray3, BlackWhite3, DarkButtonText } // ColorButtonText +}; + +int ThemeColor::GetColor(Colors p_color) +{ + return ThemeColor::theme_colors[(int)p_color][(int)ThemeColor::_theme]; +} + const char* ThemeColor::theme_names[NO_OF_THEMES] = { "Lime" @@ -47,32 +67,14 @@ const char* ThemeColor::theme_names[NO_OF_THEMES] = ,"Moderate gray" ,"Pure gray" ,"Black and White" + ,"Dark theme" }; void ThemeColor::SetTheme(Themes pTheme) { - switch (pTheme) - { - case Themes::ThemeLime: ThemeColor::SetColors(Lime1, Lime2, Lime3, LimeHeader); break; - case Themes::ThemeSkyblue: ThemeColor::SetColors(Skyblue1, Skyblue2, Skyblue3, SkyblueHeader); break; - case Themes::ThemePurple: ThemeColor::SetColors(Purple1, Purple2, Purple3, PurpleHeader); break; - case Themes::ThemeModerateGray: ThemeColor::SetColors(ModerateGray1,ModerateGray2,ModerateGray3,ModerateGrayHeader);break; - case Themes::ThemePureGray: ThemeColor::SetColors(PureGray1, PureGray2, PureGray3, PureGrayHeader); break; - case Themes::ThemeBlackWhite: ThemeColor::SetColors(BlackWhite1, BlackWhite2, BlackWhite3, BlackWhiteHeader); break; - default: return; - } _theme = pTheme; } - -void ThemeColor::SetColors(COLORREF pColor1, COLORREF pColor2, COLORREF pColor3, COLORREF pColor4) -{ - _Color1 = pColor1; - _Color2 = pColor2; - _Color3 = pColor3; - _Color4 = pColor4; -} - Themes ThemeColor::GetTheme() { return _theme; @@ -96,3 +98,13 @@ ThemeColor::GetScrollbarBitmap() } return g_scrollbars[(int)ThemeColor::_theme]; } + +COLORREF +ThemeColor::HalfTone(COLORREF color,double p_factor /*=0.5*/) +{ + int red = color >> 16; + int green = (color & 0xFF00) >> 8; + int blue = (color & 0x00FF); + + return RGB(red * p_factor,green * p_factor,blue * p_factor); +} diff --git a/StyleFramework/StyleColors.h b/StyleFramework/StyleColors.h index 6484eb6..9db94b7 100644 --- a/StyleFramework/StyleColors.h +++ b/StyleFramework/StyleColors.h @@ -51,6 +51,12 @@ #define BlackWhite3 RGB(0x00, 0x00, 0x00) #define BlackWhiteHeader RGB(0x44, 0x58, 0x73) +#define Dark1 RGB(0xBE, 0xBE, 0xBE) +#define Dark2 RGB(0x99, 0x99, 0x99) +#define Dark3 RGB(0x4D, 0x4D, 0x4D) +#define DarkHeader RGB(0x1F, 0x1F, 0x1F) +#define DarkButtonText RGB(0xDD, 0xDD, 0xDD) + #define Assistant0 RGB(0xFF, 0xFF, 0xFF) #define Assistant1 RGB(0xFA, 0xFB, 0xFC) #define Assistant2 RGB(0xF5, 0xF8, 0xFB) @@ -94,9 +100,16 @@ #define ComboBoxActive RGB(0xE5, 0xE8, 0xFF) #define ComboBoxDropped RGB(0xC5, 0xC8, 0xDF) #define SpinButtonActive RGB(0xC5, 0xC8, 0xDF) +#define ComboBoxDActive RGB(0x72, 0x74, 0x7F) +#define ComboBoxDDropped RGB(0x62, 0x64, 0x6F) + + #define VkTextInActive RGB(0xa0, 0xa3, 0xa2) #define UsersBackground RGB(0xED, 0xF3, 0xF6) // RGB(0xFF, 0xFF, 0xFF) // +#define DarkBackground RGB(0x1F, 0x1F, 0x1F) +#define DarkCtrlBackground RGB(0x2F, 0x2F, 0x2F) +#define GroupBoxLine RGB(0xDC, 0xDC, 0xDC) namespace ThemeColor { @@ -107,24 +120,44 @@ namespace ThemeColor ThemePurple, // Theme in color Purple ThemeModerateGray, // Theme in color ModerateGray ThemePureGray, // Theme in color PureGray - ThemeBlackWhite // Theme in color BlackWhite + ThemeBlackWhite, // Theme in color BlackWhite + ThemeDark, // Theme in color DarkContrast + ThemeMax + }; + + enum class Colors + { + AccentColor1 + ,AccentColor2 + ,AccentColor3 + ,AccentColor4 + ,ColorWindowFrame + ,ColorCtrlBackground + ,ColorEditText + ,ColorEditHover + ,ColorLabelText + ,ColorComboActive + ,ColorComboDropped + ,ColorGroupLine + ,ColorButtonBackground + ,ColorButtonText + ,ColorMax }; // Message that styles have changed extern UINT g_msg_changed; - const unsigned NO_OF_THEMES = 6; - extern const char* theme_names[]; - extern COLORREF _Color1; - extern COLORREF _Color2; - extern COLORREF _Color3; - extern COLORREF _Color4; + constexpr unsigned NO_OF_THEMES = (int)Themes::ThemeMax; + constexpr unsigned NO_OF_COLORS = (int)Colors::ColorMax; + extern const char* theme_names [NO_OF_THEMES]; + extern const int theme_colors[NO_OF_COLORS][NO_OF_THEMES]; extern Themes _theme; extern Themes GetTheme(); extern void SetTheme(Themes pTheme); - extern void SetColors(COLORREF pColor1, COLORREF pColor2, COLORREF pColor3, COLORREF pColor4); + extern int GetColor(Colors p_color); static COLORREF NoWhite(COLORREF color) { return color == Assistant0 ? Assistant7 : color; } extern HBITMAP GetScrollbarBitmap(); + extern COLORREF HalfTone(COLORREF color,double p_factor = 0.5); } // Where we store the styles in the registry of MS-Windows @@ -133,10 +166,10 @@ namespace ThemeColor // Window #define ClrwindowTransparent RGB(0xFF, 0x00, 0xFF) -#define ClrWindowHeader ThemeColor::_Color1 +#define ClrWindowHeader ThemeColor::GetColor(Colors::AccentColor1) #define ClrWindowHeaderText ClrWindowHeader == Assistant0 ? Assistant10 : Assistant0 -#define ClrWindowHeaderIcon ThemeColor::_Color2 -#define ClrWindowHeaderIconActive ThemeColor::_Color3 +#define ClrWindowHeaderIcon ThemeColor::GetColor(Colors::AccentColor2) +#define ClrWindowHeaderIconActive ThemeColor::GetColor(Colors::AccentColor3) #define ClrWindowFrame RGB(0x96, 0x96, 0x96) // 20% graying #define ClrWindowFrameError Accent3 // Red for errors #define ClrWindowFrameTextError Assistant0 @@ -157,7 +190,7 @@ namespace ThemeColor // Frame #define ClrFrameFrame Assistant7 -#define ClrFrameText ThemeColor::_Color4 +#define ClrFrameText ThemeColor::GetColor(Colors::AccentColor4) // Label #define ClrLabelTextNormal Assistant10 @@ -175,7 +208,10 @@ namespace ThemeColor #define ClrEditFrameNormal Assistant6 #define ClrEditFrameError Accent3 #define ClrEditFrameHover Assistant8 -#define ClrEditFrameVerplicht ThemeColor::NoWhite(ThemeColor::_Color1) +#define ClrEditFrameVerplicht ThemeColor::NoWhite(ThemeColor::GetColor(Colors::AccentColor1)) +#define ClrEditDark RGB(0xFF,0xFF,0xFF) +#define ClrEditDarkHover RGB(0x00,0x00,0xFF) + // Buttoncontrol #define ClrControlFrameNormal Assistant7 @@ -186,11 +222,11 @@ namespace ThemeColor #define ClrControlHover Assistant5 #define ClrControlPressed Assistant6 #define ClrControlDisabled Assistant2 -#define ClrControlTextNormal ThemeColor::_Color3 +#define ClrControlTextNormal ThemeColor::GetColor(Colors::AccentColor3) #define ClrControlTextHover Assistant9 #define ClrControlTextPressed Assistant9 #define ClrControlTextDisabled Assistant7 -#define ClrControlDefault ThemeColor::_Color1 +#define ClrControlDefault ThemeColor::GetColor(Colors::AccentColor1) // Checkbox #define ClrCheckBoxDefaultBkGrnd UsersBackground @@ -202,9 +238,9 @@ namespace ThemeColor #define ClrCheckboxHover ClrCheckboxNormal #define ClrCheckboxFocus ClrCheckboxNormal #define ClrCheckboxPressed ClrCheckboxNormal -#define ClrCheckboxTextNormal ThemeColor::NoWhite(ThemeColor::_Color1) -#define ClrCheckboxTextHover ThemeColor::NoWhite(ThemeColor::_Color1) -#define ClrCheckboxTextFocus ThemeColor::NoWhite(ThemeColor::_Color1) +#define ClrCheckboxTextNormal ThemeColor::NoWhite(ThemeColor::GetColor(Colors::AccentColor1)) +#define ClrCheckboxTextHover ThemeColor::NoWhite(ThemeColor::GetColor(Colors::AccentColor1)) +#define ClrCheckboxTextFocus ThemeColor::NoWhite(ThemeColor::GetColor(Colors::AccentColor1)) #define ClrCheckboxTextPressed Assistant1 // Edit @@ -212,9 +248,9 @@ namespace ThemeColor #define ClrControlDisabledBack ClrEditDisabledBack // Scrollbar -#define ClrScrollbarNormal ThemeColor::NoWhite(ThemeColor::_Color2) -#define ClrScrollbarHover ThemeColor::NoWhite(ThemeColor::_Color1) -#define ClrScrollbarPressed ThemeColor::_Color3 +#define ClrScrollbarNormal ThemeColor::NoWhite(ThemeColor::GetColor(Colors::AccentColor2)) +#define ClrScrollbarHover ThemeColor::NoWhite(ThemeColor::GetColor(Colors::AccentColor1)) +#define ClrScrollbarPressed ThemeColor::GetColor(Colors::AccentColor3) // TabControl #define ClrTabFrame Assistant5 @@ -222,7 +258,7 @@ namespace ThemeColor #define ClrTabTextActive TabTextActive #define ClrTabBkGndHover Assistant4 #define ClrTabTextHover Assistant9 -#define ClrTabBkGndSelected ThemeColor::NoWhite(ThemeColor::_Color1) +#define ClrTabBkGndSelected ThemeColor::NoWhite(ThemeColor::GetColor(Colors::AccentColor1)) #define ClrTabTextSelected TabTextSelected #define ClrTabBkGndInactive ClrControlDisabledBack #define ClrTabTextInactive TabTextInactive diff --git a/StyleFramework/StyleComboBox.cpp b/StyleFramework/StyleComboBox.cpp index 8c68b2c..69f36bb 100644 --- a/StyleFramework/StyleComboBox.cpp +++ b/StyleFramework/StyleComboBox.cpp @@ -28,6 +28,8 @@ static char THIS_FILE[] = __FILE__; #endif +using namespace ThemeColor; + IMPLEMENT_DYNAMIC(StyleComboBox,CComboBox) StyleComboBox::StyleComboBox() @@ -195,7 +197,7 @@ StyleComboBox::CreateListControl() { CRect rect(0,0,0,0); DWORD cbstyle = GetStyle(); - DWORD style = LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_POPUP | LBS_NOTIFY; + DWORD style = LBS_OWNERDRAWFIXED | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_POPUP | LBS_NOTIFY; DWORD styleEx = WS_EX_TOOLWINDOW | WS_EX_TOPMOST; if(cbstyle & CBS_OWNERDRAWVARIABLE) @@ -1607,14 +1609,14 @@ StyleComboBox::OnPaint() this->GetClientRect(&rcItem); // Find the arrow color - COLORREF color = ThemeColor::_Color1; + COLORREF color = ThemeColor::GetColor(Colors::AccentColor1); if(m_arrowColor) { color = m_arrowColor; } else if(!this->IsWindowEnabled()) { - color = ThemeColor::_Color2; + color = ThemeColor::GetColor(Colors::AccentColor2); } // Create pen @@ -1625,14 +1627,14 @@ StyleComboBox::OnPaint() // Paint the button int size = rcItem.Height(); CRect but(rcItem.right-size,rcItem.top,rcItem.right,rcItem.bottom); - DWORD background = ClrEditBkgnd; + DWORD background = ThemeColor::GetColor(Colors::ColorCtrlBackground); // ClrEditBkgnd; if(m_buttonDown) { - background = ComboBoxDropped; + background = ThemeColor::GetColor(Colors::ColorComboDropped); // ComboBoxDropped; } else if(m_itemControl->GetHoverOver()) { - background = ComboBoxActive; + background = ThemeColor::GetColor(Colors::ColorComboActive); // ComboBoxActive; } dc->FillSolidRect(but, background); but.CenterPoint(); @@ -2298,9 +2300,17 @@ SCBListBox::OnMouseMove(UINT nFlags,CPoint point) if(PtInRect(rcItem,point)) { + // Current item + CRect rcCurrent; + int current = GetCurSel(); + GetItemRect(current, &rcCurrent); + // Change selection SetCurSel(index); - GetSkin()->DrawFrame(); + // Paint optimizations: + // Only redraw the changed items! + InvalidateRect(rcCurrent); + InvalidateRect(rcItem); } } } diff --git a/StyleFramework/StyleDialog.cpp b/StyleFramework/StyleDialog.cpp index e1d478f..509c9a7 100644 --- a/StyleFramework/StyleDialog.cpp +++ b/StyleFramework/StyleDialog.cpp @@ -62,15 +62,14 @@ StyleDialog::StyleDialog(UINT p_IDTemplate { LoadStyleTheme(); } - // Needed for coloring backgrounds of the controls - m_defaultBrush.CreateSolidBrush(UsersBackground); + m_defaultBrush.DeleteObject(); + m_defaultBrush.CreateSolidBrush(ThemeColor::GetColor(Colors::ColorWindowFrame)); } BEGIN_MESSAGE_MAP(StyleDialog,CDialog) ON_WM_CREATE() ON_WM_ERASEBKGND() ON_WM_CTLCOLOR() - ON_MESSAGE(WM_CTLCOLORSTATIC,OnCtlColorStatic) ON_WM_NCMOUSEMOVE() ON_WM_NCLBUTTONDOWN() ON_WM_NCRBUTTONUP() @@ -87,6 +86,8 @@ BEGIN_MESSAGE_MAP(StyleDialog,CDialog) ON_WM_SETTINGCHANGE() ON_REGISTERED_MESSAGE(g_msg_changed,OnStyleChanged) ON_NOTIFY_EX(TTN_NEEDTEXT,0,OnToolTipNotify) + ON_MESSAGE(WM_CTLCOLORSTATIC, OnCtlColorStatic) + ON_MESSAGE(WM_CTLCOLORLISTBOX, OnCtlColorListBox) END_MESSAGE_MAP() BOOL @@ -136,7 +137,7 @@ StyleDialog::InitStatusBar() } else { - AfxMessageBox("Error: Cannot create statusbar"); + AfxMessageBox("Error: Cannot create a dialog statusbar"); } } @@ -506,9 +507,14 @@ StyleDialog::LoadStyleTheme() ThemeColor::Themes theme = (ThemeColor::Themes)th; ThemeColor::SetTheme(theme); + // Needed for coloring backgrounds of the controls + m_defaultBrush.DeleteObject(); + m_defaultBrush.CreateSolidBrush(ThemeColor::GetColor(Colors::ColorWindowFrame)); + // Now repaint ourselves and all of our children if(GetSafeHwnd()) { + Invalidate(); ReDrawFrame(); ReDrawDialog(); RedrawWindow(NULL,NULL,RDW_INVALIDATE|RDW_FRAME|RDW_ALLCHILDREN); @@ -578,12 +584,18 @@ StyleDialog::OnStyleBlackWhite() SetTheme(ThemeColor::Themes::ThemeBlackWhite); } +void +StyleDialog::OnStyleDark() +{ + SetTheme(ThemeColor::Themes::ThemeDark); +} + BOOL StyleDialog::OnEraseBkgnd(CDC* pDC) { CRect client; GetClientRect(client); - pDC->FillSolidRect(client,UsersBackground); + pDC->FillSolidRect(client,ThemeColor::GetColor(Colors::ColorWindowFrame)); return TRUE; } @@ -591,8 +603,17 @@ LPARAM StyleDialog::OnCtlColorStatic(WPARAM wParam,LPARAM /*lParam*/) { HDC hdc = (HDC)wParam; - SetTextColor(hdc,InputTextActive); - SetBkColor(hdc,UsersBackground); + SetTextColor(hdc,ThemeColor::GetColor(Colors::ColorEditText)); + SetBkColor (hdc,ThemeColor::GetColor(Colors::ColorWindowFrame)); + return (LPARAM)(HBRUSH)m_defaultBrush; +} + +LPARAM +StyleDialog::OnCtlColorListBox(WPARAM wParam, LPARAM lParam) +{ + HDC hdc = (HDC)wParam; + SetTextColor(hdc, ThemeColor::GetColor(Colors::ColorEditText)); + SetBkColor (hdc, ThemeColor::GetColor(Colors::ColorCtrlBackground)); return (LPARAM)(HBRUSH)m_defaultBrush; } @@ -900,6 +921,10 @@ StyleDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { switch (nCtlColor) { + case CTLCOLOR_LISTBOX:// Fall through + case CTLCOLOR_EDIT: pDC->SetTextColor(ThemeColor::GetColor(Colors::ColorEditText)); + pDC->SetBkColor (ThemeColor::GetColor(Colors::ColorCtrlBackground)); + break; case CTLCOLOR_STATIC: if(dynamic_cast(pWnd)) { return (dynamic_cast(pWnd))->CtlColor(pDC,nCtlColor); @@ -907,23 +932,23 @@ StyleDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) if (m_error) { pDC->SetTextColor(ClrWindowMessageTextError); - pDC->SetBkColor (ClrWindowMessageError); + pDC->SetBkColor(ThemeColor::GetColor(Colors::ColorWindowFrame)); // ClrWindowMessageError); } else { - pDC->SetTextColor(ClrLabelTextNormal); - pDC->SetBkColor (ClrFrameBkGnd); + pDC->SetTextColor(ThemeColor::GetColor(Colors::ColorLabelText)); + pDC->SetBkColor (ThemeColor::GetColor(Colors::ColorWindowFrame)); } break; case CTLCOLOR_BTN: if (m_error) { pDC->SetTextColor(ClrWindowMessageTextError); - pDC->SetBkColor (ClrWindowMessageError); + pDC->SetBkColor(ThemeColor::GetColor(Colors::ColorWindowFrame)); // ClrWindowMessageError); } else { - pDC->SetTextColor(ClrLabelTextNormal); - pDC->SetBkColor (ClrFrameBkGnd); + pDC->SetTextColor(ThemeColor::GetColor(Colors::ColorLabelText)); //ClrLabelTextNormal); + pDC->SetBkColor (ThemeColor::GetColor(Colors::ColorWindowFrame)); // ClrFrameBkGnd); } break; } @@ -1080,7 +1105,7 @@ StyleDialog::OnNcPaint() // caption bar CRect caption(m_captionRect); - dc.FillSolidRect(caption, m_error ? ClrWindowFrameError : ClrWindowHeader); + dc.FillSolidRect(caption, m_error ? ClrWindowFrameError : ThemeColor::GetColor(Colors::AccentColor1)); // title dc.SetTextColor(m_error ? ClrWindowFrameTextError : ClrWindowHeaderText); @@ -1125,12 +1150,14 @@ StyleDialog::OnNcPaint() dc.SelectObject(orgpen); CRect r; + int back = ThemeColor::GetColor(Colors::ColorWindowFrame); + r.SetRect(window.left + 1, window.top + WINDOWCAPTIONHEIGHT, window.left + SIZEMARGIN, window.bottom - WINDOWSHADOWBORDER-1); - dc.FillSolidRect(r, ClrFrameBkGnd); + dc.FillSolidRect(r, back); r.SetRect(window.left + SIZEMARGIN, window.bottom - WINDOWSHADOWBORDER- SIZEMARGIN, window.right - WINDOWSHADOWBORDER- 1, window.bottom - WINDOWSHADOWBORDER - 1); - dc.FillSolidRect(r, ClrFrameBkGnd); + dc.FillSolidRect(r, back); r.SetRect(window.right - WINDOWSHADOWBORDER-SIZEMARGIN, window.top + WINDOWCAPTIONHEIGHT, window.right - WINDOWSHADOWBORDER- 1, window.bottom - WINDOWSHADOWBORDER-SIZEMARGIN); - dc.FillSolidRect(r, ClrFrameBkGnd); + dc.FillSolidRect(r, back); } else { diff --git a/StyleFramework/StyleDialog.h b/StyleFramework/StyleDialog.h index 957707f..08da255 100644 --- a/StyleFramework/StyleDialog.h +++ b/StyleFramework/StyleDialog.h @@ -89,6 +89,7 @@ class StyleDialog : public CDialog afx_msg BOOL OnEraseBkgnd(CDC* pDC); afx_msg HBRUSH OnCtlColor(CDC* pDC,CWnd* pWnd,UINT nCtlColor); afx_msg LPARAM OnCtlColorStatic(WPARAM wParam,LPARAM lParam); + afx_msg LPARAM OnCtlColorListBox(WPARAM wParam,LPARAM lParam); afx_msg void OnNcMouseMove(UINT nFlags, CPoint point); afx_msg void OnNcLButtonDown(UINT nFlags, CPoint point); afx_msg void OnNcRButtonUp(UINT nFlags, CPoint point); @@ -115,6 +116,7 @@ class StyleDialog : public CDialog afx_msg void OnStyleModerateGray(); afx_msg void OnStylePureGray(); afx_msg void OnStyleBlackWhite(); + afx_msg void OnStyleDark(); bool m_error { false }; // Dialog is in an error state? bool m_down { false }; // mouse pressed in m_closeRect diff --git a/StyleFramework/StyleDialogCA.cpp b/StyleFramework/StyleDialogCA.cpp index 4016368..d1aa0ac 100644 --- a/StyleFramework/StyleDialogCA.cpp +++ b/StyleFramework/StyleDialogCA.cpp @@ -32,6 +32,8 @@ static char THIS_FILE[] = __FILE__; #endif +using namespace ThemeColor; + IMPLEMENT_DYNAMIC(StyleDialogCA,CDialogEx); StyleDialogCA::StyleDialogCA(UINT nIDTemplate,CWnd* p_parent, bool caption /*=true*/) diff --git a/StyleFramework/StyleEdit.cpp b/StyleFramework/StyleEdit.cpp index e721b42..280a703 100644 --- a/StyleFramework/StyleEdit.cpp +++ b/StyleFramework/StyleEdit.cpp @@ -34,6 +34,8 @@ static char THIS_FILE[] = __FILE__; #endif +using namespace ThemeColor; + // Standard MS-Windows ComboBox focus dots bool g_StyleFxComboBoxDots = true; @@ -94,6 +96,13 @@ StyleEdit::PreSubclassWindow() } } +void +StyleEdit::ResetEditColors() +{ + m_colorBackground = FRAME_DEFAULT_COLOR; + m_colorText = FRAME_DEFAULT_COLOR; +} + void StyleEdit::InitSkin(bool p_force /*=false*/) { @@ -102,12 +111,7 @@ StyleEdit::InitSkin(bool p_force /*=false*/) { return; } - - // Set read-only color - if(!m_combo && GetStyle() & ES_READONLY) - { - SetBkColor(ClrFrameBkGnd); - } + ResetEditColors(); DWORD style = GetStyle(); DWORD exsty = GetExStyle(); @@ -131,6 +135,7 @@ StyleEdit::InitSkin(bool p_force /*=false*/) if(p_force || (style & ES_MULTILINE)) { SkinWndScroll(this,border?m_borderSize:0); + GetSkin()->SetScrollbarBias(0); } m_initCorrectly = true; } @@ -266,7 +271,7 @@ StyleEdit::SetBkColor(COLORREF p_colorBackground) void StyleEdit::SetBackgroundColorEmpty(COLORREF p_colorEmptyBackground) { - if(m_colorBackgroundEmpty != p_colorEmptyBackground) + if(p_colorEmptyBackground != FRAME_DEFAULT_COLOR) { m_colorBackgroundEmpty = p_colorEmptyBackground; CreateBackgroundEmptyBrush(p_colorEmptyBackground); @@ -490,21 +495,9 @@ BOOL StyleEdit::EnableWindow(BOOL p_enable) { BOOL result = CWnd::EnableWindow(p_enable); - bool enable = p_enable && !(GetStyle() & ES_READONLY); - COLORREF back = m_colorBackground; - - if(m_colorBackground == FRAME_DEFAULT_COLOR || - m_colorBackground == ClrEditDisabledBack || - m_colorBackground == RGB(255,255,255)) - { - back = enable ? RGB(255,255,255) : ClrEditDisabledBack; - } - - SetBkColor(back); SkinScrollWnd* skin = GetSkin(); if(skin) { - skin->SetBorderColor(back); skin->OnNcPaint(); } if(m_buddy) @@ -563,7 +556,7 @@ StyleEdit::OnChar(UINT p_char,UINT p_repetitions,UINT p_flags) } // DEFAULT ACTION WITH THIS CHAR - if(m_mutable || p_char < VK_SPACE) + if(m_mutable) { CEdit::OnChar(p_char,p_repetitions,p_flags); } @@ -584,6 +577,25 @@ StyleEdit::OnChar(UINT p_char,UINT p_repetitions,UINT p_flags) Invalidate(); } +BOOL +StyleEdit::PreTranslateMessage(MSG* pMsg) +{ + // Make sure that the keystrokes continue to the appropriate handlers + if(pMsg->message == WM_KEYDOWN || pMsg->message == WM_KEYUP) + { + if(!m_mutable) + { + // Stop removing text from non-mutable fields + if(pMsg->wParam == VK_BACK || pMsg->wParam == VK_DELETE) + { + return TRUE; + } + } + } + // Standard pre-translate + return CEdit::PreTranslateMessage(pMsg); +} + void StyleEdit::SetPassword(bool p_password /* = true */) { @@ -631,7 +643,8 @@ StyleEdit::DrawFrame() GetClientRect(&rcItem); // Getting the color - DWORD color = readonly ? UsersBackground: Assistant0; + DWORD color = readonly ? ThemeColor::GetColor(Colors::ColorWindowFrame) + : ThemeColor::GetColor(Colors::ColorCtrlBackground); if(m_combo) { if(m_colorBackground != FRAME_DEFAULT_COLOR) @@ -640,17 +653,17 @@ StyleEdit::DrawFrame() } else { - color = Assistant0; + color = ThemeColor::GetColor(Colors::ColorCtrlBackground); // Assistant0; if(readonly) { - color = UsersBackground; + color = ThemeColor::GetColor(Colors::ColorWindowFrame); // UsersBackground; if (m_combo->GetDroppedState()) { - color = ComboBoxDropped; + color = ThemeColor::GetColor(Colors::ColorComboDropped); // ComboBoxDropped; } else if (m_over) { - color = ComboBoxActive; + color = ThemeColor::GetColor(Colors::ColorComboActive); // ComboBoxActive; } } } @@ -659,7 +672,7 @@ StyleEdit::DrawFrame() { back = color; penstyle = PS_DOT; // Dotted line - color = ThemeColor::_Color1; // In the style color + color = ThemeColor::GetColor(Colors::AccentColor1); // In the style color } } else @@ -680,7 +693,7 @@ StyleEdit::DrawFrame() void StyleEdit::GetDrawFrameColor(COLORREF& p_color,int& p_bordersize,bool& p_readonly) { - p_color = m_colorBorder ? m_colorBorder : ThemeColor::_Color2; + p_color = m_colorBorder ? m_colorBorder : ThemeColor::GetColor(Colors::AccentColor2); p_bordersize = 1; p_readonly = !IsWindowEnabled() || (GetStyle() & ES_READONLY); @@ -691,11 +704,11 @@ StyleEdit::GetDrawFrameColor(COLORREF& p_color,int& p_bordersize,bool& p_readonl } else if ((!m_combo && p_readonly) || (m_combo && !m_combo->IsWindowEnabled())) { - p_color = ThemeColor::_Color2; + p_color = ThemeColor::GetColor(Colors::AccentColor2); } else if (m_over || m_focus) { - p_color = m_colorBorderFocus ? m_colorBorderFocus : ThemeColor::_Color1; + p_color = m_colorBorderFocus ? m_colorBorderFocus : ThemeColor::GetColor(Colors::AccentColor1); } } @@ -708,21 +721,22 @@ StyleEdit::DrawEditFrame() GetDrawFrameColor(color,bordersize,readonly); SkinScrollWnd* skin = (SkinScrollWnd*)GetWindowLongPtr(m_hWnd,GWLP_USERDATA); - DWORD skinborder = readonly ? ClrFrameBkGnd : RGB(0xFF,0xFF,0xFF); + DWORD skinborder = readonly ? ThemeColor::GetColor(Colors::ColorWindowFrame) + : ThemeColor::GetColor(Colors::ColorCtrlBackground); if(m_combo && readonly) { if(m_combo->GetDroppedState()) { - skinborder = ComboBoxDropped; + skinborder = ThemeColor::GetColor(Colors::ColorComboDropped); // ComboBoxDropped; } else if(m_over) { - skinborder = ComboBoxActive; + skinborder = ThemeColor::GetColor(Colors::ColorComboActive); //ComboBoxActive; } else { - skinborder = ClrFrameBkGnd; + skinborder = ThemeColor::GetColor(Colors::ColorWindowFrame); // ClrFrameBkGnd; } } else @@ -852,7 +866,7 @@ StyleEdit::DrawPasswordEye() int endy = starty; // Getting the color for the eye - COLORREF color = (m_colorPasswordEye == FRAME_DEFAULT_COLOR) ? ThemeColor::_Color1 : m_colorPasswordEye; + COLORREF color = (m_colorPasswordEye == FRAME_DEFAULT_COLOR) ? ThemeColor::GetColor(Colors::AccentColor1) : m_colorPasswordEye; // Take a colored pen CPen pen; @@ -899,7 +913,7 @@ StyleEdit::DrawErrorExclamation() CString text("!"); LOGBRUSH logbrush; - COLORREF background = Assistant0; + COLORREF background = ThemeColor::GetColor(Colors::ColorCtrlBackground); //Assistant0; if(m_bkBrush.m_hObject) { m_bkBrush.GetLogBrush(&logbrush); @@ -1091,6 +1105,7 @@ StyleEdit::OnDoubleClick(WPARAM wParam, LPARAM lParam) // Do we have the calendar style? if(m_calendar == false) { + TrySelectWord(); return 0; } // May we edit the field? @@ -1153,24 +1168,24 @@ StyleEdit::CtlColor(CDC* pDC, UINT nCtlColor) } // Find background color - DWORD background = ClrEditBkgnd; + DWORD background = ThemeColor::GetColor(Colors::ColorCtrlBackground); // ClrEditBkgnd; if(readonly) { - background = ClrFrameBkGnd; + background = ThemeColor::GetColor(Colors::ColorWindowFrame); //ClrFrameBkGnd; } if(m_combo && readonly) { if(m_combo->GetDroppedState()) { - background = ComboBoxDropped; + background = ThemeColor::GetColor(Colors::ColorComboDropped); // ComboBoxDropped; } else if(m_over) { - background = ComboBoxActive; + background = ThemeColor::GetColor(Colors::ColorComboActive); //ComboBoxActive; } else { - background = UsersBackground; + background = ThemeColor::GetColor(Colors::ColorWindowFrame); //UsersBackground; } } else @@ -1182,7 +1197,7 @@ StyleEdit::CtlColor(CDC* pDC, UINT nCtlColor) } // Find foreground text color - DWORD foreground = ClrEditText; + DWORD foreground = ThemeColor::GetColor(Colors::ColorEditText); //ClrEditText; if(m_colorText != FRAME_DEFAULT_COLOR) { foreground = m_colorText; @@ -1191,9 +1206,14 @@ StyleEdit::CtlColor(CDC* pDC, UINT nCtlColor) // Change attributes of the DC here if(m_empty && !readonly) { + DWORD colorBackgroundEmpty = ThemeColor::GetColor(Colors::ColorCtrlBackground); + if(m_colorBackgroundEmpty != FRAME_DEFAULT_COLOR) + { + colorBackgroundEmpty = m_colorBackgroundEmpty; + } pDC->SetTextColor(m_colorTextEmpty); - pDC->SetBkColor(m_colorBackgroundEmpty); - CreateBackgroundEmptyBrush(m_colorBackgroundEmpty); + pDC->SetBkColor(colorBackgroundEmpty); + CreateBackgroundEmptyBrush(colorBackgroundEmpty); return m_bkEmptyBrush; } pDC->SetTextColor(foreground); @@ -1439,6 +1459,34 @@ StyleEdit::OnWindowPosChanged(WINDOWPOS* pos) } } +// Try to select a word after double clicking in the text +void +StyleEdit::TrySelectWord() +{ + int startPos = -1; + int endPos = -1; + GetSel(startPos,endPos); + + if(startPos >= 0 && endPos >= 0 && startPos == endPos) + { + CString text; + GetWindowText(text); + if(isspace(text[startPos])) + { + return; + } + while(startPos >= 0 && isalnum(text[startPos])) + { + --startPos; + } + while(endPos < text.GetLength() && isalnum(text[endPos])) + { + ++endPos; + } + SetSel(++startPos,endPos); + } +} + ////////////////////////////////////////////////////////////////////////// // // SUPPORT FOR DynamicDataEXchange in Dialogs diff --git a/StyleFramework/StyleEdit.h b/StyleFramework/StyleEdit.h index 1379acc..bf7ab0d 100644 --- a/StyleFramework/StyleEdit.h +++ b/StyleFramework/StyleEdit.h @@ -129,6 +129,9 @@ class StyleEdit : public CEdit void GetDrawFrameColor(COLORREF& p_color,int& p_bordersize,bool& p_readonly); protected: + // Stop editing in non-mutable controls + virtual BOOL PreTranslateMessage(MSG* pMsg) override; + afx_msg void OnMove(int x, int y); afx_msg void OnSize(UINT nType, int cx, int cy); afx_msg void OnShowWindow(BOOL bShow, UINT nStatus); @@ -156,6 +159,7 @@ class StyleEdit : public CEdit BOOL m_focus { FALSE }; private: + void ResetEditColors(); void ResetFont(); void CreateBackgroundBrush(DWORD p_color); void CreateBackgroundEmptyBrush(DWORD p_color); @@ -163,6 +167,7 @@ class StyleEdit : public CEdit void DrawErrorExclamation(); void StyleNcPaint(DWORD p_color,DWORD p_inner); void DrawBox(CRect& rect,DWORD p_color,int p_penstyle = PS_SOLID,DWORD p_background = NO_BACKGROUND_COLOR); + void TrySelectWord(); CString m_tooltip; // Tooltip on the contents CString m_emptyText; // Background text in case the field is empty: hint what to fill in @@ -192,8 +197,8 @@ class StyleEdit : public CEdit // Colors COLORREF m_colorText { FRAME_DEFAULT_COLOR }; COLORREF m_colorBackground { FRAME_DEFAULT_COLOR }; - COLORREF m_colorTextEmpty { RGB(0x8F,0x8F,0x8F) }; // Light gray - COLORREF m_colorBackgroundEmpty { RGB(0xFF,0xFF,0xFF) }; + COLORREF m_colorTextEmpty { RGB(0xAF,0xAF,0xAF) }; // Light gray + COLORREF m_colorBackgroundEmpty { FRAME_DEFAULT_COLOR }; COLORREF m_colorPasswordEye { FRAME_DEFAULT_COLOR }; CBrush m_bkBrush; CBrush m_bkEmptyBrush; diff --git a/StyleFramework/StyleFrameWnd.cpp b/StyleFramework/StyleFrameWnd.cpp index d6596e9..05c578e 100644 --- a/StyleFramework/StyleFrameWnd.cpp +++ b/StyleFramework/StyleFrameWnd.cpp @@ -33,6 +33,8 @@ static char THIS_FILE[] = __FILE__; #endif +using namespace ThemeColor; + IMPLEMENT_DYNAMIC(StyleFrameWnd,CFrameWndEx) StyleFrameWnd::StyleFrameWnd() @@ -490,7 +492,7 @@ void StyleFrameWnd::OnSize(UINT nType, int cx, int cy) } else { - border = MARGE; + border = MARGIN; } m_closeRect.SetRect(m_windowRectLocal.right - border - WINCAPTIONHEIGHT, m_windowRectLocal.top, m_windowRectLocal.right - border, m_windowRectLocal.top + WINCAPTIONHEIGHT); @@ -514,7 +516,7 @@ void StyleFrameWnd::OnSize(UINT nType, int cx, int cy) void StyleFrameWnd::OnNcCalcSize(BOOL calcValidRects,NCCALCSIZE_PARAMS* p_params) { - int marge = MARGE; + int marge = MARGIN; p_params->rgrc[0].top += WINCAPTIONHEIGHT; if(GetStyle() & WS_MAXIMIZE) @@ -562,8 +564,8 @@ StyleFrameWnd::OnNcPaint() if ((GetStyle() & WS_MAXIMIZE) == 0) { CRect r; - COLORREF bkgnd = ThemeColor::_Color1; // ClrWindowFrame; - int width = MARGE; + COLORREF bkgnd = ThemeColor::GetColor(Colors::AccentColor1); // ClrWindowFrame; + int width = MARGIN; r.SetRect(m_windowRectLocal.left, m_windowRectLocal.top, m_windowRectLocal.right, m_windowRectLocal.top + width); dc.FillSolidRect(r, bkgnd); diff --git a/StyleFramework/StyleFrameWndEx.cpp b/StyleFramework/StyleFrameWndEx.cpp index 73ee7c5..821732a 100644 --- a/StyleFramework/StyleFrameWndEx.cpp +++ b/StyleFramework/StyleFrameWndEx.cpp @@ -523,7 +523,7 @@ void StyleFrameWndEx::OnSize(UINT nType, int cx, int cy) } else { - border = MARGE; + border = MARGIN; } m_closeRect.SetRect(m_windowRectLocal.right - border - CAPTIONHEIGHT, m_windowRectLocal.top, m_windowRectLocal.right - border, m_windowRectLocal.top + CAPTIONHEIGHT); @@ -602,7 +602,6 @@ StyleFrameWndEx::MenuFromPoint(CPoint p_point) CFrameWndEx* frame = (CFrameWndEx*)AfxGetMainWnd(); popup->RecalcLayout(); CMFCPopupMenu::ActivatePopupMenu(frame,popup); - // frame->OnShowPopupMenu(popup); return; } } @@ -611,12 +610,12 @@ StyleFrameWndEx::MenuFromPoint(CPoint p_point) void StyleFrameWndEx::OnNcCalcSize(BOOL calcValidRects,NCCALCSIZE_PARAMS* p_params) { - int marge = MARGE; + int baseMargin = MARGIN; p_params->rgrc[0].top += CAPTIONHEIGHT; if(GetStyle() & WS_MAXIMIZE) { - // Bij een volledig scherm gebruikt het OS deze marge buiten beeld!! + // In full-screen mode, the MS-Windows OS uses this extra margin CSize marge = afxGlobalUtils.GetSystemBorders(GetStyle()); p_params->rgrc[0].left += marge.cx; @@ -626,12 +625,12 @@ StyleFrameWndEx::OnNcCalcSize(BOOL calcValidRects,NCCALCSIZE_PARAMS* p_params) } else { - // Marge is nodig voor twee zaken: - // 1) Om de linker/rechter/onder muis-uitrek actie te activeren - // 2) Om ruimte te maken voor het kader rondom het venster - p_params->rgrc[0].left += marge; - p_params->rgrc[0].right -= marge; - p_params->rgrc[0].bottom -= marge; + // The baseMargin is needed for two things: + // 1) To activate the left/right/bottom mouse pulling action + // 2) To provide space for a painted border around the window + p_params->rgrc[0].left += baseMargin; + p_params->rgrc[0].right -= baseMargin; + p_params->rgrc[0].bottom -= baseMargin; } // Use same rectangle for displacement (so hide it) p_params->rgrc[2] = p_params->rgrc[0]; @@ -657,8 +656,8 @@ StyleFrameWndEx::OnNcPaint() if((GetStyle() & WS_MAXIMIZE) == 0) { CRect r; - COLORREF bkgnd = ThemeColor::_Color1; // ClrWindowFrame; - int width = MARGE; + COLORREF bkgnd = ThemeColor::GetColor(Colors::AccentColor1); // ClrWindowFrame; + int width = MARGIN; r.SetRect(m_windowRectLocal.left, m_windowRectLocal.top, m_windowRectLocal.right, m_windowRectLocal.top + width); dc.FillSolidRect(r, bkgnd); diff --git a/StyleFramework/StyleFrameWork.h b/StyleFramework/StyleFrameWork.h index 2f62dda..300b413 100644 --- a/StyleFramework/StyleFrameWork.h +++ b/StyleFramework/StyleFrameWork.h @@ -45,6 +45,7 @@ #include "StyleComboBox.h" // CComboBox -> StyleComboBox #include "StyleEdit.h" // CEdit -> StyleEdit #include "StyleGridCtrl.h" // CGridCtrl -> StyleGridCtrl +#include "StyleGroupBox.h" // CButton -> StyleGroupBox #include "StyleHyperlink.h" // CLinkCtrl -> StyleHyperlink #include "StyleListBox.h" // CListBox -> StyleListBox #include "StyleListCtrl.h" // CListCtrl -> StyleListCtrl diff --git a/StyleFramework/StyleFramework.rc b/StyleFramework/StyleFramework.rc index 0358b44..8a6dbf7 100644 --- a/StyleFramework/StyleFramework.rc +++ b/StyleFramework/StyleFramework.rc @@ -63,6 +63,8 @@ IDB_SCROLLBAR5 BITMAP "res\\ScrollBar5.bmp" IDB_SCROLLBAR6 BITMAP "res\\ScrollBar6.bmp" +IDB_SCROLLBAR7 BITMAP "res\\ScrollBar7.bmp" + ///////////////////////////////////////////////////////////////////////////// // diff --git a/StyleFramework/StyleFramework.vcxproj b/StyleFramework/StyleFramework.vcxproj index a2f83d1..d8a7cdf 100644 --- a/StyleFramework/StyleFramework.vcxproj +++ b/StyleFramework/StyleFramework.vcxproj @@ -1,6 +1,14 @@ + + Debug + Win32 + + + Release + Win32 + Debug x64 @@ -18,6 +26,21 @@ StyleFramework + + StaticLibrary + true + v143 + MultiByte + Static + + + StaticLibrary + false + v143 + true + MultiByte + Static + StaticLibrary true @@ -38,6 +61,12 @@ + + + + + + @@ -45,6 +74,14 @@ + + $(ProjectName)_x86R + $(SolutionDir)Lib\ + + + $(ProjectName)_x86D + $(SolutionDir)Lib\ + $(ProjectName)_x64D $(SolutionDir)Lib\ @@ -53,21 +90,59 @@ $(ProjectName)_x64R $(SolutionDir)Lib\ + + + Level3 + Disabled + false + Default + Use + $(SolutionDir)StyleFramework\Grid + true + stdcpp17 + Async + stdc17 + + + MachineX86 + $(OutDir)$(TargetName)$(TargetExt) + + Level3 Disabled - true + false Use $(SolutionDir)StyleFramework\Grid MultiThreadedDebug WSCALE;_MBCS;%(PreprocessorDefinitions) - stdcpplatest - stdc17 + stdcpp17 true + stdc17 + + + $(OutDir)$(TargetName)$(TargetExt) + + + + + Level3 + MaxSpeed + true + true + true false + Use + $(SolutionDir)StyleFramework\Grid + true + + true + true + + MachineX86 $(OutDir)$(TargetName)$(TargetExt) @@ -85,7 +160,6 @@ stdcpplatest EnableFastChecks MultiThreaded - stdc17 true @@ -122,6 +196,7 @@ + @@ -173,11 +248,14 @@ + + Create + Create Create Create @@ -223,6 +301,7 @@ + diff --git a/StyleFramework/StyleFramework.vcxproj.filters b/StyleFramework/StyleFramework.vcxproj.filters index ee10d3c..1317a2d 100644 --- a/StyleFramework/StyleFramework.vcxproj.filters +++ b/StyleFramework/StyleFramework.vcxproj.filters @@ -180,6 +180,9 @@ Header Files + + Header Files + @@ -320,6 +323,9 @@ Source Files + + Source Files + @@ -374,6 +380,9 @@ Resource Files + + Resource Files + diff --git a/StyleFramework/StyleGridCtrl.cpp b/StyleFramework/StyleGridCtrl.cpp index e7fc661..d022da1 100644 --- a/StyleFramework/StyleGridCtrl.cpp +++ b/StyleFramework/StyleGridCtrl.cpp @@ -27,6 +27,8 @@ static char THIS_FILE[] = __FILE__; #endif +using namespace ThemeColor; + ///////////////////////////////////////////////////////////////////////////// // StyleGridCtrl @@ -101,7 +103,7 @@ StyleGridCtrl::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) void StyleGridCtrl::DrawFrame() { - COLORREF color = ThemeColor::_Color1; + COLORREF color = ThemeColor::GetColor(Colors::AccentColor1); SkinScrollWnd* skin = (SkinScrollWnd*)GetWindowLongPtr(m_hWnd,GWLP_USERDATA); if(skin) { @@ -109,12 +111,41 @@ StyleGridCtrl::DrawFrame() } } +void +StyleGridCtrl::CheckColors() +{ + HWND hwnd = GetSafeHwnd(); + int textColor = ThemeColor::GetColor(Colors::ColorEditText); + int backColor = ThemeColor::GetColor(Colors::ColorCtrlBackground); + if(GetTextColor() != textColor) + { + SetTextColor(textColor); + } + if(GetTextBkColor() != backColor) + { + SetTextBkColor(backColor); + } + if(GetGridBkColor() != backColor) + { + SetGridBkColor(backColor); + } + if(GetFixedTextColor() != textColor) + { + SetFixedTextColor(textColor); + } + if(GetFixedBkColor() != backColor) + { + SetFixedBkColor(ThemeColor::HalfTone(backColor,0.9)); + } +} + void StyleGridCtrl::OnPaint() { if(!m_inPaint) { m_inPaint = true; + CheckColors(); CGridCtrl::OnPaint(); DrawFrame(); m_inPaint = false; diff --git a/StyleFramework/StyleGridCtrl.h b/StyleFramework/StyleGridCtrl.h index 2c6290c..54fdb99 100644 --- a/StyleFramework/StyleGridCtrl.h +++ b/StyleFramework/StyleGridCtrl.h @@ -34,6 +34,7 @@ class StyleGridCtrl : public CGridCtrl protected: bool m_inPaint { false }; void DrawFrame(); + void CheckColors(); virtual LRESULT WindowProc(UINT message,WPARAM wParam,LPARAM lParam) override; diff --git a/StyleFramework/StyleGroupBox.cpp b/StyleFramework/StyleGroupBox.cpp new file mode 100644 index 0000000..fcccb60 --- /dev/null +++ b/StyleFramework/StyleGroupBox.cpp @@ -0,0 +1,133 @@ +//////////////////////////////////////////////////////////////////////// +// +// File: StyleGroupBox.cpp +// Function: Styling variant of the CButton with BTN_GROUPBOX style +// +// _____ _ _ _ ______ _ +// / ____| | | (_) | ____| | | +// | (___ | |_ _ _| |_ _ __ __ _| |__ _ __ __ _ _ __ ___ _____ _____ _ __| | __ +// \___ \| __| | | | | | '_ \ / _` | __| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ / +// ____) | |_| |_| | | | | | | (_| | | | | | (_| | | | | | | __/\ V V / (_) | | | < +// |_____/ \__|\__, |_|_|_| |_|\__, |_| |_| \__,_|_| |_| |_|\___| \_/\_/ \___/|_| |_|\_\ +// __/ | __/ | +// |___/ |___/ +// +// +// Author: ir. W.E. Huisman +// For license: See the file "LICENSE.txt" in the root folder +// +#include "stdafx.h" +#include "StyleGroupBox.h" +#include "StyleFonts.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +using namespace ThemeColor; + +IMPLEMENT_DYNAMIC(StyleGroupBox,CWnd); + +StyleGroupBox::StyleGroupBox() +{ +} + +StyleGroupBox::~StyleGroupBox() +{ +} + +BEGIN_MESSAGE_MAP(StyleGroupBox,CWnd) + ON_WM_PAINT() +END_MESSAGE_MAP() + +static HRGN SetControlClipping(HDC hdc, const RECT* rect) +{ + RECT rc = *rect; + HRGN hrgn = CreateRectRgn(0, 0, 0, 0); + + if(GetClipRgn(hdc,hrgn) != 1) + { + DeleteObject(hrgn); + hrgn = 0; + } + DPtoLP(hdc,(POINT*)&rc,2); + if(GetLayout(hdc) & LAYOUT_RTL) /* compensate for the shifting done by IntersectClipRect */ + { + rc.left++; + rc.right++; + } + IntersectClipRect(hdc, rc.left, rc.top, rc.right, rc.bottom); + return hrgn; +} + +void +StyleGroupBox::OnPaint() +{ + PAINTSTRUCT ps; + + CDC* dc = BeginPaint(&ps); + Internal_Paint(dc); + EndPaint(&ps); +} + +void +StyleGroupBox::Internal_Paint(CDC* p_dc) +{ + // Text of the label + CString text; + GetWindowText(text); + HFONT oldfont = (HFONT)p_dc->SelectObject(&STYLEFONTS.DialogTextFont); + + /* GroupBox acts like static control, so it sends CTLCOLORSTATIC */ + CWnd* parent = GetParent(); + + HBRUSH hbr = (HBRUSH)parent->SendMessage(WM_CTLCOLORSTATIC,(WPARAM)p_dc->GetSafeHdc(),(LPARAM)GetSafeHwnd()); + if (!hbr) + { + /* did the app forget to call DefWindowProc ? */ + hbr = (HBRUSH)DefWindowProcW(parent->GetSafeHwnd(),WM_CTLCOLORSTATIC,(WPARAM)p_dc->GetSafeHdc(),(LPARAM)GetSafeHwnd()); + } + // Getting the rectangles + CRect labelrect; + GetClientRect(&labelrect); + CRect rcFrame(labelrect); + + HRGN hrgn = SetControlClipping(p_dc->GetSafeHdc(),&labelrect); + + TEXTMETRIC tm; + p_dc->GetTextMetrics(&tm); + rcFrame.top += (tm.tmHeight / 2) + 2; + CPen pen(PS_SOLID,1,ThemeColor::GetColor(Colors::ColorGroupLine)); + HPEN oldpen = (HPEN) p_dc->SelectObject(pen); + p_dc->MoveTo(rcFrame.left, rcFrame.top); + p_dc->LineTo(rcFrame.right-1,rcFrame.top); + p_dc->LineTo(rcFrame.right-1,rcFrame.bottom-1); + p_dc->LineTo(rcFrame.left, rcFrame.bottom-1); + p_dc->LineTo(rcFrame.left, rcFrame.top); + p_dc->SelectObject(oldpen); + + InflateRect(&labelrect, -7,1); + labelrect.top += 3; + labelrect.bottom = labelrect.top + 2 + tm.tmHeight; + CRect textrect(labelrect); + { + /* There is 1-pixel margin at the left, right, and bottom */ + labelrect.left -= 2; + labelrect.bottom++; + CPoint extent = p_dc->GetTextExtent(text); + labelrect.right = labelrect.left + extent.x + 5; + + FillRect(p_dc->GetSafeHdc(),&labelrect,hbr); + + UINT flags = IsWindowEnabled() ? DSS_NORMAL : DSS_DISABLED; + p_dc->DrawText(text,&textrect,flags); + } + if(hrgn) + { + SelectClipRgn(p_dc->GetSafeHdc(), hrgn); + DeleteObject(hrgn); + } + p_dc->SelectObject(oldfont); +} diff --git a/StyleFramework/StyleGroupBox.h b/StyleFramework/StyleGroupBox.h new file mode 100644 index 0000000..32257da --- /dev/null +++ b/StyleFramework/StyleGroupBox.h @@ -0,0 +1,37 @@ +//////////////////////////////////////////////////////////////////////// +// +// File: StyleGroupBox.h +// Function: Styling frame for a groupbox control +// +// _____ _ _ _ ______ _ +// / ____| | | (_) | ____| | | +// | (___ | |_ _ _| |_ _ __ __ _| |__ _ __ __ _ _ __ ___ _____ _____ _ __| | __ +// \___ \| __| | | | | | '_ \ / _` | __| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ / +// ____) | |_| |_| | | | | | | (_| | | | | | (_| | | | | | | __/\ V V / (_) | | | < +// |_____/ \__|\__, |_|_|_| |_|\__, |_| |_| \__,_|_| |_| |_|\___| \_/\_/ \___/|_| |_|\_\ +// __/ | __/ | +// |___/ |___/ +// +// +// Author: ir. W.E. Huisman +// For license: See the file "LICENSE.txt" in the root folder +// +#pragma once +#include "StyleColors.h" + +class StyleGroupBox : public CWnd +{ + DECLARE_DYNAMIC(StyleGroupBox); + +public: + StyleGroupBox(); + virtual ~StyleGroupBox(); + +private: + void Internal_Paint(CDC* p_dc); + + DECLARE_MESSAGE_MAP() + + afx_msg void OnPaint(); + +}; \ No newline at end of file diff --git a/StyleFramework/StyleHyperlink.cpp b/StyleFramework/StyleHyperlink.cpp index fb8b403..24b3c56 100644 --- a/StyleFramework/StyleHyperlink.cpp +++ b/StyleFramework/StyleHyperlink.cpp @@ -124,18 +124,23 @@ void StyleHyperLink::PreSubclassWindow() SetDefaultCursor(); // Try and load up a "hand" cursor SetUnderline(); + // Create the tooltip + CRect rect; + GetClientRect(rect); + m_ToolTip.Create(this); + m_ToolTip.AddTool(this, m_strURL, rect, TOOLTIP_ID); CStatic::PreSubclassWindow(); } void -StyleHyperLink::SetTipText(LPCTSTR tipText) +StyleHyperLink::SetTipText(LPCTSTR p_tipText) { if(::IsWindow(GetSafeHwnd()) && ::IsWindow(m_ToolTip.GetSafeHwnd())) { // Update the tooltip PositionWindow(); - m_ToolTip.UpdateTipText(tipText,this,TOOLTIP_ID); + m_ToolTip.UpdateTipText(p_tipText,this,TOOLTIP_ID); } else { @@ -143,7 +148,7 @@ StyleHyperLink::SetTipText(LPCTSTR tipText) CRect rect; GetClientRect(rect); m_ToolTip.Create(this); - m_ToolTip.AddTool(this,tipText,rect,TOOLTIP_ID); + m_ToolTip.AddTool(this,p_tipText,rect,TOOLTIP_ID); } } @@ -253,6 +258,12 @@ BOOL StyleHyperLink::OnEraseBkgnd(CDC* pDC) void StyleHyperLink::SetURL(CString strURL) { m_strURL = strURL; + + if (::IsWindow(GetSafeHwnd())) + { + PositionWindow(); + m_ToolTip.UpdateTipText(strURL, this, TOOLTIP_ID); + } } CString StyleHyperLink::GetURL() const @@ -260,9 +271,8 @@ CString StyleHyperLink::GetURL() const return m_strURL; } -void StyleHyperLink::SetColours(COLORREF crLinkColour - ,COLORREF crVisitedColour - ,COLORREF crHoverColour /* = -1 */) +void StyleHyperLink::SetColours(COLORREF crLinkColour, COLORREF crVisitedColour, + COLORREF crHoverColour /* = -1 */) { m_crLinkColour = crLinkColour; m_crVisitedColour = crVisitedColour; diff --git a/StyleFramework/StyleHyperlink.h b/StyleFramework/StyleHyperlink.h index cb81733..38e94eb 100644 --- a/StyleFramework/StyleHyperlink.h +++ b/StyleFramework/StyleHyperlink.h @@ -26,7 +26,7 @@ class StyleHyperLink : public CStatic // Attributes public: - void SetTipText(LPCTSTR tipText); + void SetTipText(LPCTSTR p_tipText); void SetURL(CString strURL); CString GetURL() const; void SetColours(COLORREF crLinkColour diff --git a/StyleFramework/StyleListBox.cpp b/StyleFramework/StyleListBox.cpp index 2a8b180..23d96c1 100644 --- a/StyleFramework/StyleListBox.cpp +++ b/StyleFramework/StyleListBox.cpp @@ -23,6 +23,7 @@ #include "StyleColors.h" #include "LinePrinter.h" #include "StyleTexts.h" +#include "StyleMessageBox.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -30,6 +31,8 @@ static char THIS_FILE[] = __FILE__; #endif +using namespace ThemeColor; + ///////////////////////////////////////////////////////////////////////////// // StyleListBox @@ -49,11 +52,19 @@ StyleListBox::~StyleListBox() BEGIN_MESSAGE_MAP(StyleListBox,CListBox) ON_WM_PAINT() ON_WM_SHOWWINDOW() + ON_WM_DESTROY() + ON_WM_ERASEBKGND() + ON_WM_HSCROLL() END_MESSAGE_MAP() void StyleListBox::PreSubclassWindow() { + // Check for unsupported styles in StyleFramework + int style = GetStyle(); + ASSERT((style & LBS_OWNERDRAWVARIABLE) == 0); + ASSERT((style & LBS_MULTICOLUMN) == 0); + if(m_directInit) { InitSkin(); @@ -98,23 +109,43 @@ StyleListBox::DrawFrame() SkinScrollWnd* skin = GetSkin(); if(skin) { - COLORREF color = (this == GetFocus()) ? ThemeColor::_Color1 : ThemeColor::_Color2; + COLORREF color = (this == GetFocus()) ? ThemeColor::GetColor(Colors::AccentColor1) : ThemeColor::GetColor(Colors::AccentColor2); skin->DrawFrame(color); } } +BOOL +StyleListBox::OnEraseBkgnd(CDC* pDC) +{ + CRect client; + GetClientRect(client); + pDC->FillSolidRect(client,ThemeColor::GetColor(Colors::ColorCtrlBackground)); + return TRUE; +} + void StyleListBox::OnPaint() { if(!m_inPaint) { m_inPaint = true; - CListBox::OnPaint(); + PAINTSTRUCT ps; + CDC* cdc = BeginPaint(&ps); + OnEraseBkgnd(cdc); + Internal_Paint(cdc); + EndPaint(&ps); DrawFrame(); m_inPaint = false; } } +void +StyleListBox::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) +{ + CListBox::OnHScroll(nSBCode,nPos,pScrollBar); + Invalidate(); +} + // Propagate the ShowWindow command void StyleListBox::OnShowWindow(BOOL bShow, UINT nStatus) @@ -140,43 +171,226 @@ StyleListBox::OnShowWindow(BOOL bShow, UINT nStatus) int StyleListBox::AddString(LPCTSTR p_string) { - int result = CListBox::AddString(p_string); - if(result < 0) + return AppendString(p_string); +} + +int +StyleListBox::InsertString(int p_index,LPCTSTR p_string,COLORREF p_foreground,COLORREF p_background) +{ + bool owner = (GetStyle() & LBS_OWNERDRAWFIXED) > 0; + int result = CListBox::InsertString(p_index,owner ? "" : p_string); + if (result != LB_ERR) { - return result; + if (GetStyle() & LBS_OWNERDRAWFIXED) + { + ListBoxColorLine* line = new ListBoxColorLine(); + line->m_foreground = p_foreground; + line->m_background = p_background; + line->m_text = p_string; + + SetItemPointer(result,line); } UpdateWidth(p_string); AdjustScroll(); + } return result; } int -StyleListBox::InsertString(int p_index,LPCTSTR p_string) +StyleListBox::AppendString(LPCSTR p_string,COLORREF p_foreground,COLORREF p_background) { - int result = CListBox::InsertString(p_index,p_string); - if(result < 0) + bool owner = (GetStyle() & LBS_OWNERDRAWFIXED) > 0; + int result = CListBox::AddString(owner ? "" : p_string); + if (result != LB_ERR) +{ + if(GetStyle() & LBS_OWNERDRAWFIXED) { - return result; + ListBoxColorLine* line = new ListBoxColorLine(); + line->m_foreground = p_foreground; + line->m_background = p_background; + line->m_text = p_string; + + SetItemPointer(result,line); } UpdateWidth(p_string); AdjustScroll(); +} return result; } -void StyleListBox::ResetContent() +void +StyleListBox::SetItemPointer(int p_index,void* p_data) { + ListBoxColorLine* listBox = reinterpret_cast(GetItemDataPtr(p_index)); + if(listBox && (listBox != (ListBoxColorLine*)LB_ERR) &&listBox->m_magic == LIST_MAGIC) + { + delete listBox; + } + SetItemDataPtr(p_index,p_data); +} + +void +StyleListBox::MeasureItem(LPMEASUREITEMSTRUCT p_measureItemStruct) +{ + // TODO: Add your code to determine the size of specified item + ASSERT(p_measureItemStruct->CtlType == ODT_LISTBOX); + + ListBoxColorLine* listBox = reinterpret_cast(GetItemDataPtr(p_measureItemStruct->itemID)); + if(listBox && (listBox != (ListBoxColorLine*)LB_ERR) && listBox->m_magic == LIST_MAGIC) + { + CString strText = listBox->m_text; + if (strText.GetLength()) + { + CRect rect; + GetItemRect(p_measureItemStruct->itemID, &rect); + + CDC* pDC = GetDC(); + p_measureItemStruct->itemHeight = pDC->DrawText(strText, -1, rect, DT_WORDBREAK | DT_CALCRECT); + ReleaseDC(pDC); + } + } +} + +void +StyleListBox::DrawItem(LPDRAWITEMSTRUCT p_drawItemStruct) +{ + // TODO: Add your code to draw the specified item + ASSERT(p_drawItemStruct->CtlType == ODT_LISTBOX); + + // Getting a DC + CDC dc; + dc.Attach(p_drawItemStruct->hDC); + + // Save these value to restore them when done drawing. + COLORREF crOldTextColor = dc.GetTextColor(); + COLORREF crOldBkColor = dc.GetBkColor(); + + COLORREF foreground(FRAME_DEFAULT_COLOR); + COLORREF background(FRAME_DEFAULT_COLOR); + // Getting our foreground/background colors + ListBoxColorLine* listBox = reinterpret_cast(GetItemDataPtr(p_drawItemStruct->itemID)); + if(!listBox || (listBox == (ListBoxColorLine*)LB_ERR) || listBox->m_magic != LIST_MAGIC) + { + return; + } + foreground = listBox->m_foreground; + background = listBox->m_background; + if(foreground == FRAME_DEFAULT_COLOR) + { + foreground = ThemeColor::GetColor(Colors::ColorEditText); + } + if(background == FRAME_DEFAULT_COLOR) + { + background = ThemeColor::GetColor(Colors::ColorCtrlBackground); + } + + // If this item is selected, set the background color + // and the text color to appropriate values. Also, erase + // rect by filling it with the background color. + if((p_drawItemStruct->itemAction | ODA_SELECT) && + (p_drawItemStruct->itemState & ODS_SELECTED)) + { + int accent = ThemeColor::GetColor(Colors::AccentColor1); + dc.SetTextColor(background); + dc.SetBkColor (accent); + dc.FillSolidRect(&p_drawItemStruct->rcItem,accent); + } + else + { + dc.SetTextColor(foreground); + dc.SetBkColor (background); + dc.FillSolidRect(&p_drawItemStruct->rcItem,background); + } + if((p_drawItemStruct->itemAction | ODA_FOCUS) && + (p_drawItemStruct->itemState & ODS_FOCUS)) + { + dc.DrawFocusRect(&p_drawItemStruct->rcItem); + } + + // Draw the text. + p_drawItemStruct->rcItem.left += 5; + p_drawItemStruct->rcItem.top += 1; + p_drawItemStruct->rcItem.bottom -= 1; + + dc.DrawText(listBox->m_text.GetString(),listBox->m_text.GetLength(),&p_drawItemStruct->rcItem,DT_NOCLIP | DT_NOPREFIX | DT_VCENTER); + + // Reset the background color and the text color back to their + // original values. + dc.SetTextColor(crOldTextColor); + dc.SetBkColor (crOldBkColor); + + dc.Detach(); +} + +int +StyleListBox::CompareItem(LPCOMPAREITEMSTRUCT p_compare) +{ + if(p_compare->itemID1 >= 0 && p_compare->itemID1 < (UINT)GetCount() && + p_compare->itemID2 >= 0 && p_compare->itemID2 < (UINT)GetCount()) + { + ListBoxColorLine* listBox1 = reinterpret_cast(GetItemDataPtr(p_compare->itemID1)); + ListBoxColorLine* listBox2 = reinterpret_cast(GetItemDataPtr(p_compare->itemID2)); + if(listBox1->m_magic == LIST_MAGIC && listBox2->m_magic == LIST_MAGIC) + { + return listBox1->m_text.Compare(listBox2->m_text); + } + } + return 0; +} + +void +StyleListBox::DeleteItem(LPDELETEITEMSTRUCT p_deleteItemStruct) +{ + ASSERT(p_deleteItemStruct->CtlType == ODT_LISTBOX); + ListBoxColorLine* line = reinterpret_cast(p_deleteItemStruct->itemData); + if(line && line->m_magic == LIST_MAGIC) + { + delete line; + } + CListBox::DeleteItem(p_deleteItemStruct); +} + +void +StyleListBox::ResetContent() +{ + if(GetStyle() & LBS_OWNERDRAWFIXED) + { + RemoveLineInfo(); + } + // Empty the control CListBox::ResetContent(); CListBox::SetHorizontalExtent(0); AdjustScroll(); m_width = 0; } +void +StyleListBox::OnDestroy() +{ + if(GetStyle() & LBS_OWNERDRAWFIXED) + { + RemoveLineInfo(); + } + CListBox::OnDestroy(); +} + // Deleting a string implies recalculating the width // of all other strings in the control to shrink the // maximum extend of the horizontal scrollbar int StyleListBox::DeleteString(int p_number) { + if(GetStyle() & LBS_OWNERDRAWFIXED) + { + // Remove color info + ListBoxColorLine* line = reinterpret_cast(GetItemDataPtr(p_number)); + if(line) + { + delete line; + } + } + + // Do the delete int result = CListBox::DeleteString(p_number); if(result < 0) { @@ -192,7 +406,7 @@ StyleListBox::DeleteString(int p_number) { /* scan strings */ CString s; - CListBox::GetText(i,s); + GetText(i,s); CSize sz = dc.GetTextExtent(s); sz.cx += 3 * ::GetSystemMetrics(SM_CXBORDER); if(sz.cx > m_width) @@ -250,7 +464,7 @@ StyleListBox::Copy() result += "\r\n"; } CString text; - CListBox::GetText(lines[index],text); + GetText(lines[index],text); RemoveLineNumber(text); result += text; } @@ -380,7 +594,7 @@ StyleListBox::Print(CString p_documentName for(int index = 0; index < GetCount(); ++index) { CString line; - CListBox::GetText(index, line); + GetText(index, line); print.Print(line); print.NextLine(); } @@ -433,7 +647,7 @@ StyleListBox::PrintSelection(CString p_documentName for(int index = 0; index < count; ++index) { CString line; - CListBox::GetText(lines[index],line); + GetText(lines[index],line); print.Print(line); print.NextLine(); } @@ -445,6 +659,73 @@ StyleListBox::PrintSelection(CString p_documentName return result; } +int +StyleListBox::GetText(int p_index,LPTSTR p_buffer) const +{ + ASSERT(::IsWindow(m_hWnd)); + int length = 0; + if(p_index >= 0 && p_index < GetCount()) + { + if(GetStyle() & LBS_OWNERDRAWFIXED) + { + ListBoxColorLine* listBox = reinterpret_cast(GetItemDataPtr(p_index)); + if(listBox && listBox->m_magic == LIST_MAGIC) + { + length = listBox->m_text.GetLength() + 1; + strcpy_s(p_buffer, length, listBox->m_text.GetString()); + } + } + else + { + return CListBox::GetText(p_index,p_buffer); + } + } + return length; +} + +void +StyleListBox::GetText(int p_index,CString& p_string) const +{ + ASSERT(::IsWindow(m_hWnd)); + if (p_index >= 0 && p_index < GetCount()) + { + if(GetStyle() & LBS_OWNERDRAWFIXED) + { + ListBoxColorLine* listBox = reinterpret_cast(GetItemDataPtr(p_index)); + if(listBox && listBox->m_magic == LIST_MAGIC) + { + p_string = listBox->m_text; + } + } + else + { + CListBox::GetText(p_index,p_string); + } + } +} + +int +StyleListBox::GetTextLen(int p_index) const +{ + ASSERT(::IsWindow(m_hWnd)); + if(p_index >= 0 && p_index < GetCount()) + { + if(GetStyle() & LBS_OWNERDRAWFIXED) + { + ListBoxColorLine* listBox = reinterpret_cast(GetItemDataPtr(p_index)); + if(listBox && listBox->m_magic == LIST_MAGIC) + { + return listBox->m_text.GetLength(); + } + } + else + { + return CListBox::GetTextLen(p_index); + } + } + return 0; +} + ////////////////////////////////////////////////////////////////////////// // // PRIVATE @@ -512,3 +793,230 @@ StyleListBox::RemoveLineNumber(CString& p_text) p_text = p_text.Mid(pos + 2); } } + +void +StyleListBox::RemoveLineInfo() +{ + // Remove our text and color content + int nCount = GetCount(); + for(int index = 0;index < nCount;index++) + { + ListBoxColorLine* line = reinterpret_cast(GetItemDataPtr(index)); + if(line && line->m_magic == LIST_MAGIC) + { + delete line; + } + } +} + +////////////////////////////////////////////////////////////////////////// +// +// OWNERDRAW PAINTING CODE +// +////////////////////////////////////////////////////////////////////////// + +static const char* DebugRect(const RECT* rect) +{ + static char buffer[51]; + sprintf_s(buffer,50,"top=%d,left=%d,right=%d,bottom=%d",rect->top,rect->left,rect->right,rect->bottom); + return buffer; +} + +void +StyleListBox::Internal_Paint(CDC* p_cdc) +{ + int item_height = GetItemHeight(0); + int items = GetCount(); + int style = GetStyle(); + CRect clientrect; + RECT focusRect = { -1,-1,-1,-1 }; + + // Special case! Do not paint + if(style & LBS_NOREDRAW) + { + return; + } + + // Getting the client rectangle + GetClientRect(&clientrect); + SCROLLINFO info; + info.cbSize = sizeof(SCROLLINFO); + GetScrollInfo(SB_HORZ,&info); + if(info.nPos > 0) + { + int shift = info.nPos + ::GetSystemMetrics(SM_CXHSCROLL); + SetWindowOrgEx(p_cdc->GetSafeHdc(),shift,0,nullptr); + clientrect.right += shift; + } + CRect itemrect(clientrect); + + // Should get the brush from the parent normally + // hbrush = (HBRUSH)SendMessageW(GetParent()->GetSafeHwnd(),WM_CTLCOLORLISTBOX,(WPARAM)p_cdc->GetSafeHdc(),(LPARAM)GetSafeHwnd()); + CBrush brush; + brush.CreateSolidBrush(ThemeColor::GetColor(Colors::ColorCtrlBackground)); + HBRUSH oldBrush = (HBRUSH) p_cdc->SelectObject(brush); + + if(!IsWindowEnabled()) + { + p_cdc->SetTextColor(GetSysColor(COLOR_GRAYTEXT)); + } + + // Paint all the items, regarding the selection + // Focus state will be painted after + + int top_item = GetTopIndex(); + int focus_item = GetCaretIndex(); + + HFONT oldFont = (HFONT) p_cdc->SelectObject(&STYLEFONTS.DialogTextFont); + + for(int index = top_item; index < items; index++) + { + itemrect.bottom = itemrect.top + item_height; + + /* keep the focus rect, to paint the focus item after */ + if (index == focus_item) + { + focusRect = itemrect; + } + Internal_PaintItem(p_cdc,&itemrect,index,ODA_DRAWENTIRE,TRUE); + itemrect.top = itemrect.bottom; + + if(itemrect.top >= clientrect.Height()) + { + break; + } + } + + /* Paint the focus item now */ + if(focusRect.top != focusRect.bottom && focus_item >= 0) + { + Internal_PaintItem(p_cdc,&focusRect, focus_item, ODA_FOCUS, FALSE); + } + + /* Clear the remainder of the client area */ + p_cdc->SelectObject(brush); + if (itemrect.top < clientrect.Height()) + { + itemrect.bottom = clientrect.bottom; + p_cdc->ExtTextOut(0, 0, ETO_OPAQUE | ETO_CLIPPED,&itemrect, NULL, 0, NULL); + } + if(itemrect.right < clientrect.Width()) + { + itemrect.left = itemrect.right; + itemrect.right = clientrect.right; + itemrect.top = 0; + itemrect.bottom = clientrect.bottom; + p_cdc->ExtTextOut(0, 0, ETO_OPAQUE | ETO_CLIPPED,&itemrect, NULL, 0, NULL); + } + + // Reset old values in DC + if (oldFont) p_cdc->SelectObject(oldFont); + if (oldBrush) p_cdc->SelectObject(oldBrush); +} + +void +StyleListBox::Internal_PaintItem(CDC* p_cdc,const RECT* rect,INT index,UINT action,BOOL ignoreFocus) +{ + const char* item_str = NULL; + int nb_items = GetCount(); + int style = GetStyle(); + + ListBoxColorLine* line = reinterpret_cast(GetItemDataPtr(index)); + if(line && (line != (ListBoxColorLine*) LB_ERR) && line->m_magic == LIST_MAGIC) + { + item_str = line->m_text.GetString(); + } + else + { + TRACE("called with an out of bounds index %d (Total: %d) in owner draw, Not good.\n",index,GetCount()); + return; + } + BOOL selected = GetSel(index); + BOOL focused = GetCaretIndex() == index; + + if(GetStyle() & (LBS_OWNERDRAWFIXED | LBS_OWNERDRAWVARIABLE)) + { + DRAWITEMSTRUCT dis; + RECT r; + + if (index >= nb_items) + { + if(action == ODA_FOCUS) + { + p_cdc->DrawFocusRect(rect); + } + else + { + TRACE("called with an out of bounds index %d(%d) in owner draw, Not good.\n", index, nb_items); + } + return; + } + + GetClientRect(&r); + + dis.CtlType = ODT_LISTBOX; + dis.CtlID = (UINT)GetWindowLongPtrW(GetSafeHwnd(), GWLP_ID); + dis.hwndItem = GetSafeHwnd(); + dis.itemAction = action; + dis.hDC = p_cdc->GetSafeHdc(); + dis.itemID = index; + dis.itemState = 0; + if (selected) dis.itemState |= ODS_SELECTED; + if (focused) dis.itemState |= ODS_FOCUS; + if (!IsWindowEnabled()) dis.itemState |= ODS_DISABLED; + dis.itemData = (ULONG_PTR) GetItemDataPtr(index); + dis.rcItem = *rect; + TRACE("[%p]: drawitem %d (%s) action=%02x state=%02x rect=%s\n",GetSafeHwnd(),index,item_str, action, dis.itemState, DebugRect(rect)); + + // This is the reason we are here! + // Standard MS-Windows sends this to the parent of the control so CMenu can have a go at it + // But the standard desktop does NOT reflect the MEASUREITEM/DRAWITEM messages + // So we send it directly to ourselves!!!!!! + // + // SendMessage(GetParent()->GetSafeHwnd(),WM_DRAWITEM,(WPARAM)dis.CtlID,(LPARAM)&dis); + SendMessage(WM_DRAWITEM,(WPARAM)dis.CtlID,(LPARAM)&dis); + } + else + { + COLORREF oldText = 0, oldBk = 0; + + if (action == ODA_FOCUS) + { + p_cdc->DrawFocusRect(rect); + return; + } + if (selected) + { + oldBk = p_cdc->SetBkColor (GetSysColor(COLOR_HIGHLIGHT)); + oldText = p_cdc->SetTextColor(GetSysColor(COLOR_HIGHLIGHTTEXT)); + } + + TRACE("[%p]: painting %d (%s) action=%02x rect=%s\n",GetSafeHwnd(),index,item_str,action,DebugRect(rect)); + if(!item_str) + { + p_cdc->ExtTextOut(rect->left + 1, rect->top, ETO_OPAQUE | ETO_CLIPPED, rect, NULL, 0, NULL); + } + else if(style & LBS_USETABSTOPS) + { + int nb_tabs = 0; + int* tabs = nullptr; + + /* Output empty string to paint background in the full width. */ + p_cdc->ExtTextOut (rect->left + 1, rect->top,ETO_OPAQUE | ETO_CLIPPED, rect, NULL, 0, NULL); + p_cdc->TabbedTextOut(rect->left + 1, rect->top, item_str, lstrlen(item_str),nb_tabs,tabs,0); + } + else + { + p_cdc->ExtTextOut(rect->left + 1, rect->top, ETO_OPAQUE | ETO_CLIPPED, rect, item_str, (UINT)strlen(item_str), NULL); + } + if(selected) + { + p_cdc->SetBkColor(oldBk); + p_cdc->SetTextColor(oldText); + } + if(focused) + { + p_cdc->DrawFocusRect(rect); + } + } +} diff --git a/StyleFramework/StyleListBox.h b/StyleFramework/StyleListBox.h index e527c4e..e8c511f 100644 --- a/StyleFramework/StyleListBox.h +++ b/StyleFramework/StyleListBox.h @@ -20,6 +20,26 @@ #pragma once #include "SkinScrollWnd.h" +#define LIST_MAGIC 0xDEBAC1 + +///////////////////////////////////////////////////////////////////////////// +// CMulitLineListBox window +class ListBoxColorLine +{ +public: + int m_magic; + CString m_text; + COLORREF m_foreground; + COLORREF m_background; + + ListBoxColorLine() + { + m_magic = LIST_MAGIC; + m_foreground = FRAME_DEFAULT_COLOR; + m_background = FRAME_DEFAULT_COLOR; + } +}; + class StyleListBox : public CListBox { DECLARE_DYNAMIC(StyleListBox) @@ -38,10 +58,14 @@ class StyleListBox : public CListBox // Overrides of CListBox functions int AddString(LPCTSTR p_string) ; - int InsertString(int p_index,LPCTSTR p_string); + int InsertString(int p_index,LPCTSTR p_string,COLORREF p_foreground = FRAME_DEFAULT_COLOR,COLORREF p_background = FRAME_DEFAULT_COLOR); + int AppendString(LPCSTR p_text,COLORREF p_foreground = FRAME_DEFAULT_COLOR,COLORREF p_background = FRAME_DEFAULT_COLOR); void ResetContent(); int DeleteString(int p_number); void MoveWindow(int x,int y,int nWidth,int nHeight,BOOL bRepaint = TRUE); + int GetText(int nIndex,LPTSTR lpszBuffer) const; + void GetText(int nIndex,CString& rString) const; + int GetTextLen(int nIndex) const; // Edit functions void SelectAll(BOOL p_select = TRUE); @@ -55,13 +79,26 @@ class StyleListBox : public CListBox protected: virtual void PreSubclassWindow() override; + virtual void MeasureItem(LPMEASUREITEMSTRUCT p_measureItemStruct) override; + virtual void DrawItem (LPDRAWITEMSTRUCT p_drawItemStruct) override; + virtual int CompareItem(LPCOMPAREITEMSTRUCT p_compareItemStruct) override; + virtual void DeleteItem (LPDELETEITEMSTRUCT p_deleteItemStruct) override; void UpdateWidth(LPCTSTR p_string); void AdjustScroll(); void RemoveLineNumber(CString& p_text); + void RemoveLineInfo(); + void SetItemPointer(int p_index,void* p_data); + + // Owner painting inside OnPaint + void Internal_Paint(CDC* p_cdc); + void Internal_PaintItem(CDC* p_cdc,const RECT* rect,INT index,UINT action,BOOL ignoreFocus); afx_msg void OnPaint(); afx_msg void OnShowWindow(BOOL bShow, UINT nStatus); + afx_msg void OnDestroy(); + afx_msg BOOL OnEraseBkgnd(CDC* pDC); + afx_msg void OnHScroll(UINT nSBCode,UINT nPos,CScrollBar* pScrollBar); SkinScrollWnd* m_skin; int m_width { 0 }; diff --git a/StyleFramework/StyleListCtrl.cpp b/StyleFramework/StyleListCtrl.cpp index 72d7882..31eaa49 100644 --- a/StyleFramework/StyleListCtrl.cpp +++ b/StyleFramework/StyleListCtrl.cpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////////////////// // // File: StyleListCtrl.cpp -// Function: Styling frame for CListCtrl object +// Function: Styling frame for CMFCListCtrl object // // _____ _ _ _ ______ _ // / ____| | | (_) | ____| | | @@ -27,6 +27,8 @@ static char THIS_FILE[] = __FILE__; #endif +using namespace ThemeColor; + ///////////////////////////////////////////////////////////////////////////// // StyleListCtrl @@ -40,7 +42,7 @@ StyleListCtrl::~StyleListCtrl() CWnd::OnNcDestroy(); } -BEGIN_MESSAGE_MAP(StyleListCtrl,CListCtrl) +BEGIN_MESSAGE_MAP(StyleListCtrl,CMFCListCtrl) ON_WM_CREATE() ON_WM_PAINT() ON_WM_SIZE() @@ -137,13 +139,13 @@ StyleListCtrl::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) return 1; } } - return CListCtrl::WindowProc(message, wParam, lParam); + return CMFCListCtrl::WindowProc(message, wParam, lParam); } void StyleListCtrl::DrawFrame() { - COLORREF color = (this == GetFocus()) ? ThemeColor::_Color1 : ThemeColor::_Color2; + COLORREF color = (this == GetFocus()) ? ThemeColor::GetColor(Colors::AccentColor1) : ThemeColor::GetColor(Colors::AccentColor2); SkinScrollWnd* skin = (SkinScrollWnd*)GetWindowLongPtr(m_hWnd,GWLP_USERDATA); if(skin) { @@ -151,13 +153,34 @@ StyleListCtrl::DrawFrame() } } +void +StyleListCtrl::CheckColors() +{ + int background = ThemeColor::GetColor(Colors::ColorCtrlBackground); + int textcolor = ThemeColor::GetColor(Colors::ColorEditText); + + if(GetBkColor() != background) + { + SetBkColor(background); + } + if(GetTextBkColor() != background) + { + SetTextBkColor(background); + } + if(GetTextColor() != textcolor) + { + SetTextColor(textcolor); + } +} + void StyleListCtrl::OnPaint() { if(!m_inPaint) { m_inPaint = true; - CListCtrl::OnPaint(); + CheckColors(); + CMFCListCtrl::OnPaint(); DrawFrame(); m_inPaint = false; } @@ -166,7 +189,7 @@ StyleListCtrl::OnPaint() void StyleListCtrl::OnSize(UINT nType,int cx,int cy) { - CListCtrl::OnSize(nType,cx,cy); + CMFCListCtrl::OnSize(nType,cx,cy); DrawFrame(); } @@ -182,7 +205,7 @@ StyleListCtrl::OnShowWindow(BOOL bShow, UINT nStatus) } else { - CListCtrl::OnShowWindow(bShow, nStatus); + CMFCListCtrl::OnShowWindow(bShow, nStatus); } } diff --git a/StyleFramework/StyleListCtrl.h b/StyleFramework/StyleListCtrl.h index 409734e..80c7d81 100644 --- a/StyleFramework/StyleListCtrl.h +++ b/StyleFramework/StyleListCtrl.h @@ -19,7 +19,7 @@ #pragma once #include "SkinScrollWnd.h" -class StyleListCtrl : public CListCtrl +class StyleListCtrl : public CMFCListCtrl { // Construction public: @@ -38,6 +38,7 @@ class StyleListCtrl : public CListCtrl virtual LRESULT WindowProc(UINT message,WPARAM wParam,LPARAM lParam) override; virtual void PreSubclassWindow() override; + void CheckColors(); afx_msg void OnPaint(); afx_msg void OnSize(UINT nType,int cx,int cy); diff --git a/StyleFramework/StyleMDIFrameWnd.cpp b/StyleFramework/StyleMDIFrameWnd.cpp index 4e577fd..324cf3e 100644 --- a/StyleFramework/StyleMDIFrameWnd.cpp +++ b/StyleFramework/StyleMDIFrameWnd.cpp @@ -34,6 +34,8 @@ static char THIS_FILE[] = __FILE__; #endif +using namespace ThemeColor; + IMPLEMENT_DYNAMIC(StyleMDIFrameWnd,CMDIFrameWndEx) StyleMDIFrameWnd::StyleMDIFrameWnd() @@ -485,7 +487,7 @@ void StyleMDIFrameWnd::OnSize(UINT nType, int cx, int cy) int border = 0; if ((GetStyle() & WS_MAXIMIZE) != 0) { - // Bij een volledig scherm gebruikt het OS deze marge buiten beeld!! + // On a full screen the MS-Windows OS uses this margin outside our view CSize marge = afxGlobalUtils.GetSystemBorders(GetStyle()); m_windowRectLocal.left += marge.cx; @@ -495,7 +497,7 @@ void StyleMDIFrameWnd::OnSize(UINT nType, int cx, int cy) } else { - border = MARGE; + border = MARGIN; } m_closeRect.SetRect(m_windowRectLocal.right - border - WINCAPTIONHEIGHT, m_windowRectLocal.top, m_windowRectLocal.right - border, m_windowRectLocal.top + WINCAPTIONHEIGHT); @@ -519,27 +521,27 @@ void StyleMDIFrameWnd::OnSize(UINT nType, int cx, int cy) void StyleMDIFrameWnd::OnNcCalcSize(BOOL calcValidRects,NCCALCSIZE_PARAMS* p_params) { - int marge = MARGE; + int baseMargin = MARGIN; p_params->rgrc[0].top += WINCAPTIONHEIGHT; if(GetStyle() & WS_MAXIMIZE) { - // Bij een volledig scherm gebruikt het OS deze marge buiten beeld!! - CSize marge = afxGlobalUtils.GetSystemBorders(GetStyle()); + // In full-screen mode, the MS-Windows OS uses this extra margin + CSize margin = afxGlobalUtils.GetSystemBorders(GetStyle()); - p_params->rgrc[0].left += marge.cx; - p_params->rgrc[0].top += marge.cy; - p_params->rgrc[0].right -= marge.cx; - p_params->rgrc[0].bottom -= marge.cy; + p_params->rgrc[0].left += margin.cx; + p_params->rgrc[0].top += margin.cy; + p_params->rgrc[0].right -= margin.cx; + p_params->rgrc[0].bottom -= margin.cy; } else { - // Marge is nodig voor twee zaken: - // 1) Om de linker/rechter/onder muis-uitrek actie te activeren - // 2) Om ruimte te maken voor het kader rondom het venster - p_params->rgrc[0].left += marge; - p_params->rgrc[0].right -= marge; - p_params->rgrc[0].bottom -= marge; + // The baseMargin is needed for two things: + // 1) To activate the left/right/bottom mouse pulling action + // 2) To provide space for a painted border around the window + p_params->rgrc[0].left += baseMargin; + p_params->rgrc[0].right -= baseMargin; + p_params->rgrc[0].bottom -= baseMargin; } // Use same rectangle for displacement (so hide it) p_params->rgrc[2] = p_params->rgrc[0]; @@ -565,8 +567,8 @@ StyleMDIFrameWnd::OnNcPaint() if((GetStyle() & WS_MAXIMIZE) == 0) { CRect r; - COLORREF bkgnd = ThemeColor::_Color1; // ClrWindowFrame; - int width = MARGE; + COLORREF bkgnd = ThemeColor::GetColor(Colors::AccentColor1); // ClrWindowFrame; + int width = MARGIN; r.SetRect(m_windowRectLocal.left, m_windowRectLocal.top, m_windowRectLocal.right, m_windowRectLocal.top + width); dc.FillSolidRect(r, bkgnd); diff --git a/StyleFramework/StyleMacros.h b/StyleFramework/StyleMacros.h index 00bea43..279c1bc 100644 --- a/StyleFramework/StyleMacros.h +++ b/StyleFramework/StyleMacros.h @@ -25,7 +25,7 @@ #define WS(val) MulDiv(val, CWindowDC(0).GetDeviceCaps(LOGPIXELSY), 96) #endif -#define MARGE MulDiv( 1, StyleFonts::logpixelsy(), 96) +#define MARGIN MulDiv( 1, StyleFonts::logpixelsy(), 96) #define PANELHEADERHEIGHT MulDiv( 0, StyleFonts::logpixelsy(), 96) #define CAPTIONHEIGHT MulDiv( 46, StyleFonts::logpixelsy(), 96) #define WINCAPTIONHEIGHT MulDiv( 30, StyleFonts::logpixelsy(), 96) diff --git a/StyleFramework/StyleMessageBox.cpp b/StyleFramework/StyleMessageBox.cpp index 6aa5358..9c80efd 100644 --- a/StyleFramework/StyleMessageBox.cpp +++ b/StyleFramework/StyleMessageBox.cpp @@ -255,7 +255,7 @@ MessageDialog::MessageDialog(CWnd* p_parent { labels = GetStyleText(TXT_RETRY_CANCEL); // "retry$ok cancel$can"; } - SpliLabelTextAndStyles(labels); + SplitLabelTextAndStyles(labels); } MessageDialog::MessageDialog(CWnd* p_parent @@ -312,9 +312,13 @@ MessageDialog::MessageDialog(CWnd* p_parent // (MB_ICONHAND | MB_ICONQUESTION | MB_ICONEXCLAMATION | MB_ICONASTERISK) if(style == MB_ICONASTERISK) m_image = IDI_ASTERISK; if(style == MB_ICONEXCLAMATION) m_image = IDI_EXCLAMATION; - if(style == MB_ICONHAND) m_image = IDI_HAND; if(style == MB_ICONQUESTION) m_image = IDI_QUESTION; if(style == MB_USERICON) m_image = IDI_SHIELD; + if(style == MB_ICONHAND) + { + m_error = true; + m_image = IDI_HAND; + } if(m_image) { m_icon = LoadIcon(nullptr, m_image); @@ -341,7 +345,7 @@ MessageDialog::MessageDialog(CWnd* p_parent m_foreground = true; } - SpliLabelTextAndStyles(labels); + SplitLabelTextAndStyles(labels); } // Destructor @@ -521,7 +525,7 @@ MessageDialog::GotoControl(int p_direction) // "buttontext$ab" -> label = "buttontext" style = "ab" // void -MessageDialog::SpliLabelTextAndStyles(CString& p_labels) +MessageDialog::SplitLabelTextAndStyles(CString& p_labels) { // Reset everything for (int i = 0; i < MAX_LABELS; ++i) diff --git a/StyleFramework/StyleMessageBox.h b/StyleFramework/StyleMessageBox.h index a59da69..a04867e 100644 --- a/StyleFramework/StyleMessageBox.h +++ b/StyleFramework/StyleMessageBox.h @@ -105,7 +105,7 @@ class MessageDialog : public StyleDialogCA // Reset the buttons void ResetButtons(); // Split labels strings and styles - void SpliLabelTextAndStyles(CString& p_labels); + void SplitLabelTextAndStyles(CString& p_labels); // Suppress this message, always ID_OK void SuppressFromNowOn(); // Flash our application and message box diff --git a/StyleFramework/StyleProgressCtrl.cpp b/StyleFramework/StyleProgressCtrl.cpp index efc46fa..88213f7 100644 --- a/StyleFramework/StyleProgressCtrl.cpp +++ b/StyleFramework/StyleProgressCtrl.cpp @@ -19,6 +19,8 @@ #include "stdafx.h" #include "StyleProgressCtrl.h" +using namespace ThemeColor; + IMPLEMENT_DYNAMIC(StyleProgressCtrl,CWnd); BEGIN_MESSAGE_MAP(StyleProgressCtrl,CWnd) @@ -158,7 +160,7 @@ StyleProgressCtrl::GetBkColor() const { if(m_background == NO_COLOR) { - return ClrFrameBkGnd; + return ThemeColor::GetColor(Colors::ColorCtrlBackground);// ClrFrameBkGnd; } // Explicitly set user color return m_background; @@ -174,11 +176,11 @@ StyleProgressCtrl::GetBarColor() const } if(m_state == PBST_PAUSED) { - return ThemeColor::_Color3; // Lighter theme color + return ThemeColor::GetColor(Colors::AccentColor3); // Lighter theme color } if(m_barcolor == NO_COLOR) { - return ThemeColor::_Color1; // Our theme + return ThemeColor::GetColor(Colors::AccentColor1); // Our theme } return m_barcolor; // Explicitly set user color } diff --git a/StyleFramework/StyleProgressCtrl.h b/StyleFramework/StyleProgressCtrl.h index 4702e98..b28dadf 100644 --- a/StyleFramework/StyleProgressCtrl.h +++ b/StyleFramework/StyleProgressCtrl.h @@ -124,6 +124,6 @@ class StyleProgressCtrl : public CWnd int m_position { 0 }; // Current position between lower and upper int m_state { PBST_NORMAL }; // State we are in COLORREF m_background = (DWORD) NO_COLOR; // If no color, use ClrFrameBkGnd - COLORREF m_barcolor = (DWORD) NO_COLOR; // If no color, use ThemeColor::_Color1 + COLORREF m_barcolor = (DWORD) NO_COLOR; // If no color, use ThemeColor::GetColor(Colors::AccentColor1) }; diff --git a/StyleFramework/StyleSpinButtonCtrl.cpp b/StyleFramework/StyleSpinButtonCtrl.cpp index e0007a2..d74cc5f 100644 --- a/StyleFramework/StyleSpinButtonCtrl.cpp +++ b/StyleFramework/StyleSpinButtonCtrl.cpp @@ -22,6 +22,8 @@ #include "StyleEdit.h" #include "StyleTexts.h" +using namespace ThemeColor; + IMPLEMENT_DYNAMIC(StyleSpinButtonCtrl,CSpinButtonCtrl); BEGIN_MESSAGE_MAP(StyleSpinButtonCtrl,CSpinButtonCtrl) @@ -103,7 +105,7 @@ StyleSpinButtonCtrl::DrawTopButton(CDC* dc,CRect& rect, int p_offset /*= 0*/) int middle = rect.Width() / 2; int half = height / 2; - CBrush brush(m_buttonUP ? SpinButtonActive : Assistant0); + CBrush brush(m_buttonUP ? SpinButtonActive : ThemeColor::GetColor(Colors::ColorCtrlBackground)); // Assistant0); HGDIOBJ oldbrush = dc->SelectObject(brush); CRect back(rect.left + 2, rect.top + 3, rect.Width() - 3, height); dc->FillRect(&back,&brush); @@ -135,7 +137,7 @@ StyleSpinButtonCtrl::DrawBotButton(CDC* dc,CRect& rect, int p_offset /*= 0*/) int middle = rect.Width() / 2; int half = height / 2; - CBrush brush(m_buttonDN ? SpinButtonActive : Assistant0); + CBrush brush(m_buttonDN ? SpinButtonActive : ThemeColor::GetColor(Colors::ColorCtrlBackground)); HGDIOBJ oldbrush = dc->SelectObject(brush); CRect back(rect.left + 2, rect.top + height + 1, rect.Width() - 3, rect.bottom - 3); dc->FillRect(&back, &brush); @@ -169,7 +171,7 @@ StyleSpinButtonCtrl::OnPaint() GetClientRect(&rect); CDC* dc = GetDC(); - COLORREF color = IsWindowEnabled() ? ThemeColor::_Color1 : ThemeColor::_Color2; + COLORREF color = IsWindowEnabled() ? ThemeColor::GetColor(Colors::AccentColor1) : ThemeColor::GetColor(Colors::AccentColor2); if(m_error) { color = ClrEditFrameError; diff --git a/StyleFramework/StyleTabCtrl.cpp b/StyleFramework/StyleTabCtrl.cpp index 7d8be56..2165ec9 100644 --- a/StyleFramework/StyleTabCtrl.cpp +++ b/StyleFramework/StyleTabCtrl.cpp @@ -27,6 +27,8 @@ static char THIS_FILE[] = __FILE__; #endif +using namespace ThemeColor; + IMPLEMENT_DYNAMIC(StyleTabCtrl,CTabCtrl) StyleTabCtrl::StyleTabCtrl() @@ -84,8 +86,8 @@ LPARAM StyleTabCtrl::OnCtlColorStatic(WPARAM wParam,LPARAM /*lParam*/) { HDC hdc = (HDC)wParam; - SetTextColor(hdc,InputTextActive); - SetBkColor(hdc,UsersBackground); + SetTextColor(hdc,ThemeColor::GetColor(Colors::ColorEditText)); // InputTextActive + SetBkColor (hdc,ThemeColor::GetColor(Colors::ColorWindowFrame)); // UsersBackground return (LPARAM)(HBRUSH)m_brush; } @@ -94,7 +96,7 @@ StyleTabCtrl::OnEraseBkgnd(CDC* pDC) { CRect rect; GetClientRect(&rect); - pDC->FillSolidRect(&rect,UsersBackground); + pDC->FillSolidRect(&rect,ThemeColor::GetColor(Colors::ColorWindowFrame)); // UsersBackground return TRUE; } @@ -269,7 +271,6 @@ StyleTabCtrl::OnPaint() { COLORREF clrbkgnd; COLORREF clrtext; - // bool close = false; if (!active) { @@ -280,7 +281,6 @@ StyleTabCtrl::OnPaint() { clrbkgnd = ClrTabBkGndSelected; clrtext = ClrTabTextSelected; - // close = it->m_closable; } else if (ind == m_hover) { @@ -340,8 +340,8 @@ StyleTabCtrl::OnPaint() points[3].y += tabHeaderNotch; points[1].y = points[0].y - tabHeaderNotch + 1; points[2].y = points[3].y - tabHeaderNotch + 1; - CBrush blank(ClrTabBkGndActive); - CPen nopen(PS_SOLID,1,ClrTabBkGndActive); + CBrush blank(ThemeColor::GetColor(Colors::ColorWindowFrame)); // ClrTabBkGndActive + CPen nopen(PS_SOLID,1,ThemeColor::GetColor(Colors::ColorWindowFrame)); // ClrTabBkGndActive dc->SelectObject(blank); dc->SelectObject(nopen); dc->Polygon(points, 4); diff --git a/StyleFramework/StyleToast.cpp b/StyleFramework/StyleToast.cpp index c926b06..617ba99 100644 --- a/StyleFramework/StyleToast.cpp +++ b/StyleFramework/StyleToast.cpp @@ -22,6 +22,8 @@ #include "StyleUtilities.h" #include "StyleFonts.h" +using namespace ThemeColor; + StyleToast::StyleToast(int p_style ,int p_position ,CString p_text1 @@ -67,7 +69,7 @@ StyleToast::OnInitDialog() m_foreground = RGB( 0, 0, 0); switch(m_style) { - case STYLE_TOAST_MESSAGE: m_background = ThemeColor::_Color1; + case STYLE_TOAST_MESSAGE: m_background = ThemeColor::GetColor(Colors::AccentColor1); m_foreground = RGB( 0, 0, 0); break; case STYLE_TOAST_WARNING: m_background = RGB(236,183, 0); diff --git a/StyleFramework/StyleTreeCtrl.cpp b/StyleFramework/StyleTreeCtrl.cpp index a389fdf..203fed6 100644 --- a/StyleFramework/StyleTreeCtrl.cpp +++ b/StyleFramework/StyleTreeCtrl.cpp @@ -28,6 +28,8 @@ static char THIS_FILE[] = __FILE__; #endif +using namespace ThemeColor; + StyleTreeCtrl::StyleTreeCtrl() { } @@ -88,7 +90,8 @@ StyleTreeCtrl::SetDirectInit(bool p_init) void StyleTreeCtrl::DrawFrame() { - COLORREF color = (this == GetFocus()) ? ThemeColor::_Color1 : ThemeColor::_Color2; + COLORREF color = (this == GetFocus()) ? ThemeColor::GetColor(Colors::AccentColor1) + : ThemeColor::GetColor(Colors::AccentColor2); SkinScrollWnd* skin = (SkinScrollWnd*)GetWindowLongPtr(m_hWnd, GWLP_USERDATA); if (skin) { @@ -96,12 +99,29 @@ StyleTreeCtrl::DrawFrame() } } +void +StyleTreeCtrl::CheckColors() +{ + HWND hwnd = GetSafeHwnd(); + int textColor = ThemeColor::GetColor(Colors::ColorEditText); + int backColor = ThemeColor::GetColor(Colors::ColorCtrlBackground); + if(TreeView_GetTextColor(hwnd) != textColor) + { + TreeView_SetTextColor(hwnd,textColor); + } + if(TreeView_GetBkColor(hwnd) != backColor) + { + TreeView_SetBkColor(hwnd,backColor); + } +} + void StyleTreeCtrl::OnPaint() { if (!m_inPaint) { m_inPaint = true; + CheckColors(); CTreeCtrl::OnPaint(); DrawFrame(); m_inPaint = false; diff --git a/StyleFramework/StyleTreeCtrl.h b/StyleFramework/StyleTreeCtrl.h index cd6ece8..0812396 100644 --- a/StyleFramework/StyleTreeCtrl.h +++ b/StyleFramework/StyleTreeCtrl.h @@ -41,6 +41,7 @@ class StyleTreeCtrl : public CTreeCtrl virtual LRESULT WindowProc(UINT message,WPARAM wParam,LPARAM lParam) override; virtual void PreSubclassWindow() override; + void CheckColors(); afx_msg void OnPaint(); afx_msg void OnSize(UINT nType, int cx, int cy); diff --git a/StyleFramework/res/ScrollBar7.bmp b/StyleFramework/res/ScrollBar7.bmp new file mode 100644 index 0000000000000000000000000000000000000000..de3cadfb6e266c7a2f7824a928213e3155c966f9 GIT binary patch literal 13782 zcmeHJ!HpX+5ZiQ-4w6@XNdfs^IVr}!RFX1M&k-ksJ06L=k>JH*0WV-uWxvL*}md^+y379kLLdN^E=jhSME?LA+*_eF6*l=UV=qHL{hR%+I;JcBQk z^QSm7ZOYc}-{0X@V+y@uhgJ<#BSoCfN^bTIF2FW5hXMxR}#7wm(_g z-3y2$s(7Tf}qu7I&Bn6djDL znJa-|&8Z@#oELCJe7$^ePsE{a>#3Nds+IE^e#v~-u6oMUE8k;dKO|rL?x^S3+nnK! zo5mld)V}h4!e^2)jqN4##RXI5YJtFO+iyhjWT}&lmG)v2mnws3F@ILwym9 zZfeA6B4ujjT*ToVBYwyi7F=xXsA)y7OoG_<;vy1FP^&2;OO$Gra~+2>BhLB41+?)R z9xLgGng%B2R2yy8pwUFi)XI4ZhkuKBkgqW+9;+xbixfrY1p#M$p`2%NY(d0x`4)GW z3ltrUteGo;Va=%`rJNUV*j_JR+!NXq-Yu^*D}n|_YH z%^B|ao#B6D*q_>0zEAi}Ql_!JWWMh{tlNKQ|J{tv}&LlDdKcidLtm^3*}tF`-t~^F`pJ2 zM=FOJvVAes7s2SJMvNv>rdG~HJVpGFFD$s&*iqApUYP{3?ZrhTnxIxwMwTemD(5;L zBhLB4#hkve{mIhqUO*%%r&^kzP=iJjDN`%wDVz}x@-;@qV-;m)k)r6lAmFSol=Cd! zBA&~)xWina=wM{cTnP+oP8BKTynrL(>*b4kA`W$1PsJQnt(@2JOXjylF1Cb3|tKQ4EmEB8RI8jlGyCSO=jYj T*__37fPJzNlh|elAq7SNz?&lw diff --git a/StyleFramework/stdafx.h b/StyleFramework/stdafx.h index 1eba137b32e6bd4f1a22c04b837b5b194be44243..157177d4ba732c76d09c0a40f8754e3d1c2e62d9 100644 GIT binary patch delta 359 zcmX>l{!Ma&3v)d$0~don5GpW~FqASBG2}561KIfuX+WsJ;LG5~;LM;77RzABWJm$x zJce|r3I(8eK0_`;Dv+NHX5|9OJRmO-NTxtll>p^IV#PqwG$1>Np%Tc;1e%h^kgo%@ zG8L?}94HO49%cc^*kZ7zbTA9((8-?6p_AV+Uz?o7D54tA;0SbF1VcQ7AA>)T^k?v4 za0SxA4517GKge|lLJ{KCr@A%nY@8TZn6u@waHspq$U@!&X~N7 RMPhOhTLXyR9K^na6##2v6fXb( diff --git a/SuiteLibrary/AboutDlg.cpp b/SuiteLibrary/AboutDlg.cpp index a5a273f..02a3d43 100644 --- a/SuiteLibrary/AboutDlg.cpp +++ b/SuiteLibrary/AboutDlg.cpp @@ -29,6 +29,8 @@ static char THIS_FILE[] = __FILE__; #define new DEBUG_NEW #endif +using namespace ThemeColor; + // AboutDlg dialog IMPLEMENT_DYNAMIC(AboutDlg, StyleDialog) @@ -95,7 +97,7 @@ AboutDlg::OnInitDialog() m_text += version; // Perform the streaming - m_editText.SetBorderColor(ThemeColor::_Color1); + m_editText.SetBorderColor(ThemeColor::GetColor(Colors::AccentColor1)); m_editText.SetTextMode(TM_RICHTEXT); UpdateData(FALSE); diff --git a/SuiteLibrary/SuiteLibrary.h b/SuiteLibrary/SuiteLibrary.h index fdf688f..bb0efe3 100644 --- a/SuiteLibrary/SuiteLibrary.h +++ b/SuiteLibrary/SuiteLibrary.h @@ -22,11 +22,11 @@ #define KWATTA_VERSION_MAJOR 1 #define KWATTA_VERSION_MINOR 0 -#define KWATTA_VERSION_SP 12 -#define KWATTA_VERSION_BUILD 134 +#define KWATTA_VERSION_SP 13 +#define KWATTA_VERSION_BUILD 138 #define KWATTA "Kwatta" -#define KWATTA_VERSION "1.0.12" +#define KWATTA_VERSION "1.0.13" #define KWATTA_YEAR "2022" // Used for environment variables diff --git a/TestEditor/MutateDlg.cpp b/TestEditor/MutateDlg.cpp index 1cc2e5f..c5dc06c 100644 --- a/TestEditor/MutateDlg.cpp +++ b/TestEditor/MutateDlg.cpp @@ -25,6 +25,8 @@ #include #include +using namespace ThemeColor; + // MutateDlg dialog IMPLEMENT_DYNAMIC(MutateDlg, StyleDialog) @@ -65,7 +67,7 @@ MutateDlg::OnInitDialog() SetWindowText("Change filename for: " + m_object); m_editOrgFilename.SetMutable(false); - m_editOrgFilename.SetBkColor(ThemeColor::_Color2); + m_editOrgFilename.SetBkColor(ThemeColor::GetColor(Colors::AccentColor2)); m_editNewFilename.SetFocus(); return FALSE; } diff --git a/TestEditor/resource.h b/TestEditor/resource.h index 8b986f6b1f19ba35f584c94b1984ad5d0d04f008..66f1e411e93c06614b310e4bfb62ab015469e211 100644 GIT binary patch delta 50 zcmV-20L}mKN6JXBjt7%~1{MJ~lko;AlgKlPCxplkg4(lkNvPlcE|LlTZl^ IvrY)28|sP?@Bjb+ delta 40 ycmV+@0N4M@NbpCnjt7(Q4g{0z2RxI`2O5*G0|b*s2t1Q02pW@62@JES2%;NRSq{Vi diff --git a/TestRunner/resource.h b/TestRunner/resource.h index da28879938d21b71b8ef0b68fa7bdef08c4e596b..008fde01158aaf6ddd5279b72460aeb1ef1462df 100644 GIT binary patch delta 52 zcmV-40L%Zb9*7^Xjt7%~1{MJ~lko;AlgKlPCxplduB>lk5jP0XCDt1|5^2 K2ne%I2;c_Wx)Fu| delta 40 ycmV+@0N4MBAFdv-jt7%o3I>zz2Rf6^2O5*G0|b*s2t1Q02pW@62@JES2;c@H{0)Nu diff --git a/ValidateEditor/resource.h b/ValidateEditor/resource.h index 1de25176c03e19767add946aca2acc7a748af017..498eaee75960a49355ba27fd9d01c1ce1cd4a1df 100644 GIT binary patch delta 50 zcmV-20L}lHUh-bBmIsqA1{MJ~lK}xIlhg+slfViDlbQ!SlQ0Mxlkf*XlVTDYll}+{ IvsMVgCcUH)E&u=k delta 36 ucmV+<0NelaUYK66mIssY2SAh72O5(g1q73D1O$`#2U3&%2n@5Z2*M^DYz~V6