From 01313480057e4272d545732fc3a21150869edf54 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 1 Mar 2021 21:28:01 +0300 Subject: CCtrlSlider - new GUI component --- include/m_gui.h | 22 +++++++++++ libs/win32/mir_core.lib | Bin 472972 -> 475208 bytes libs/win64/mir_core.lib | Bin 478026 -> 480308 bytes src/mir_core/mir_core.vcxproj | 1 + src/mir_core/mir_core.vcxproj.filters | 3 ++ src/mir_core/src/CCtrlSlider.cpp | 70 ++++++++++++++++++++++++++++++++++ src/mir_core/src/CDlgBase.cpp | 5 +++ src/mir_core/src/mir_core.def | 8 ++++ src/mir_core/src/mir_core64.def | 8 ++++ 9 files changed, 117 insertions(+) create mode 100644 src/mir_core/src/CCtrlSlider.cpp diff --git a/include/m_gui.h b/include/m_gui.h index 972821ab32..a3e211b7b4 100644 --- a/include/m_gui.h +++ b/include/m_gui.h @@ -838,6 +838,28 @@ public: void SetReadOnly(bool bReadOnly); }; +///////////////////////////////////////////////////////////////////////////////////////// +// CCtrlSlider + +class MIR_CORE_EXPORT CCtrlSlider : public CCtrlData +{ + typedef CCtrlData CSuper; + + int m_wMin, m_wMax; + +protected: + BOOL OnCommand(HWND hwndCtrl, WORD idCtrl, WORD idCode) override; + +public: + CCtrlSlider(CDlgBase *dlg, int ctrlId, int max = 100, int min = 0); + + bool OnApply() override; + void OnReset() override; + + int GetPosition(); + void SetPosition(int pos); +}; + ///////////////////////////////////////////////////////////////////////////////////////// // CCtrlSpin diff --git a/libs/win32/mir_core.lib b/libs/win32/mir_core.lib index c2b71219b8..2b146a38c2 100644 Binary files a/libs/win32/mir_core.lib and b/libs/win32/mir_core.lib differ diff --git a/libs/win64/mir_core.lib b/libs/win64/mir_core.lib index d3d1f7f49c..99b560204b 100644 Binary files a/libs/win64/mir_core.lib and b/libs/win64/mir_core.lib differ diff --git a/src/mir_core/mir_core.vcxproj b/src/mir_core/mir_core.vcxproj index d95f7b9197..23e75824de 100644 --- a/src/mir_core/mir_core.vcxproj +++ b/src/mir_core/mir_core.vcxproj @@ -58,6 +58,7 @@ + diff --git a/src/mir_core/mir_core.vcxproj.filters b/src/mir_core/mir_core.vcxproj.filters index 17987d4682..2eba1c3237 100644 --- a/src/mir_core/mir_core.vcxproj.filters +++ b/src/mir_core/mir_core.vcxproj.filters @@ -173,6 +173,9 @@ Source Files + + Source Files + diff --git a/src/mir_core/src/CCtrlSlider.cpp b/src/mir_core/src/CCtrlSlider.cpp new file mode 100644 index 0000000000..c418051693 --- /dev/null +++ b/src/mir_core/src/CCtrlSlider.cpp @@ -0,0 +1,70 @@ +/* + +Object UI extensions +Copyright (c) 2008 Victor Pavlychko, George Hazan +Copyright (C) 2012-21 Miranda NG team + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +#include "stdafx.h" + +///////////////////////////////////////////////////////////////////////////////////////// +// CCtrlSlider class + +CCtrlSlider::CCtrlSlider(CDlgBase *dlg, int ctrlId, int wMax, int wMin) : + CCtrlData(dlg, ctrlId), + m_wMin(wMin), + m_wMax(wMax) +{ + m_bNotifiable = true; +} + +BOOL CCtrlSlider::OnCommand(HWND, WORD, WORD idCode) +{ + if (idCode == WM_HSCROLL) { + NotifyChange(); + return TRUE; + } + return FALSE; +} + +bool CCtrlSlider::OnApply() +{ + CSuper::OnApply(); + + if (m_dbLink != nullptr) + SaveInt(GetPosition()); + return true; +} + +void CCtrlSlider::OnReset() +{ + SendMsg(TBM_SETRANGE, 0, MAKELPARAM(m_wMax, m_wMin)); + + if (m_dbLink != nullptr) + SetPosition(LoadInt()); +} + +int CCtrlSlider::GetPosition() +{ + return SendMsg(TBM_GETPOS, 0, 0); +} + +void CCtrlSlider::SetPosition(int wPos) +{ + SendMsg(TBM_SETPOS, TRUE, wPos); +} diff --git a/src/mir_core/src/CDlgBase.cpp b/src/mir_core/src/CDlgBase.cpp index 95449c56a0..d2cbbc23a1 100644 --- a/src/mir_core/src/CDlgBase.cpp +++ b/src/mir_core/src/CDlgBase.cpp @@ -339,6 +339,11 @@ INT_PTR CDlgBase::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) } return FALSE; + case WM_HSCROLL: + if (auto *pCtrl = FindControl(HWND(lParam))) + pCtrl->OnCommand(HWND(lParam), pCtrl->m_idCtrl, WM_HSCROLL); + break; + case PSM_CHANGED: if (m_bInitialized) OnChange(); diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def index e0aca3aaff..2a9322ac5e 100644 --- a/src/mir_core/src/mir_core.def +++ b/src/mir_core/src/mir_core.def @@ -1489,3 +1489,11 @@ TimeZone_GetSystemTime @1692 ?OnCommand@CCtrlColor@@UAEHPAUHWND__@@GG@Z @1712 NONAME ?OnReset@CCtrlColor@@UAEXXZ @1713 NONAME ?SetColor@CCtrlColor@@QAEXK@Z @1714 NONAME +??0CCtrlSlider@@QAE@PAVCDlgBase@@HHH@Z @1715 NONAME +??1CCtrlSlider@@UAE@XZ @1716 NONAME +??_7CCtrlSlider@@6B@ @1717 NONAME +?GetPosition@CCtrlSlider@@QAEHXZ @1718 NONAME +?OnApply@CCtrlSlider@@UAE_NXZ @1719 NONAME +?OnCommand@CCtrlSlider@@MAEHPAUHWND__@@GG@Z @1720 NONAME +?OnReset@CCtrlSlider@@UAEXXZ @1721 NONAME +?SetPosition@CCtrlSlider@@QAEXH@Z @1722 NONAME diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def index d0b84bfdd6..4d694019fb 100644 --- a/src/mir_core/src/mir_core64.def +++ b/src/mir_core/src/mir_core64.def @@ -1489,3 +1489,11 @@ TimeZone_GetSystemTime @1692 ?OnCommand@CCtrlColor@@UEAAHPEAUHWND__@@GG@Z @1712 NONAME ?OnReset@CCtrlColor@@UEAAXXZ @1713 NONAME ?SetColor@CCtrlColor@@QEAAXK@Z @1714 NONAME +??0CCtrlSlider@@QEAA@PEAVCDlgBase@@HHH@Z @1715 NONAME +??1CCtrlSlider@@UEAA@XZ @1716 NONAME +??_7CCtrlSlider@@6B@ @1717 NONAME +?GetPosition@CCtrlSlider@@QEAAHXZ @1718 NONAME +?OnApply@CCtrlSlider@@UEAA_NXZ @1719 NONAME +?OnCommand@CCtrlSlider@@MEAAHPEAUHWND__@@GG@Z @1720 NONAME +?OnReset@CCtrlSlider@@UEAAXXZ @1721 NONAME +?SetPosition@CCtrlSlider@@QEAAXH@Z @1722 NONAME -- cgit v1.2.3