From 3f343c22a352462660a71806303c1f8957a85702 Mon Sep 17 00:00:00 2001 From: aunsane Date: Sat, 24 Feb 2018 00:03:19 +0300 Subject: core: gui - new method IsChecked for CCtrlCheck - new methods GetUrl and SetUrl for CCtrlHypelink - new event OnClick for CCtrlHypelink - CCtrlSpin inherits from CCtrlData --- include/m_gui.h | 14 +++++++++++++- libs/win32/mir_core.lib | Bin 319114 -> 320826 bytes libs/win64/mir_core.lib | Bin 320084 -> 321844 bytes src/mir_core/src/CCtrlCheck.cpp | 11 +++++++++-- src/mir_core/src/CCtrlHyperlink.cpp | 23 ++++++++++++++++++++--- src/mir_core/src/CCtrlSpin.cpp | 17 +++++++++++++++-- src/mir_core/src/mir_core.def | 6 ++++++ src/mir_core/src/mir_core64.def | 6 ++++++ 8 files changed, 69 insertions(+), 8 deletions(-) diff --git a/include/m_gui.h b/include/m_gui.h index e4c7c40ed3..45b6130122 100644 --- a/include/m_gui.h +++ b/include/m_gui.h @@ -648,8 +648,15 @@ public: virtual BOOL OnCommand(HWND hwndCtrl, WORD idCtrl, WORD idCode) override; + CCallback OnClick; + + void SetUrl(const char *url); + const char *GetUrl(); + protected: const char* m_url; + + void Default_OnClick(CCtrlHyperlink*); }; ///////////////////////////////////////////////////////////////////////////////////////// @@ -793,6 +800,8 @@ public: int GetState(); void SetState(int state); + + bool IsChecked(); }; ///////////////////////////////////////////////////////////////////////////////////////// @@ -840,7 +849,7 @@ public: ///////////////////////////////////////////////////////////////////////////////////////// // CCtrlSpin -class MIR_CORE_EXPORT CCtrlSpin : public CCtrlBase +class MIR_CORE_EXPORT CCtrlSpin : public CCtrlData { typedef CCtrlData CSuper; @@ -849,6 +858,9 @@ class MIR_CORE_EXPORT CCtrlSpin : public CCtrlBase public: CCtrlSpin(CDlgBase *dlg, int ctrlId); + virtual void OnApply() override; + virtual void OnReset() override; + WORD GetPosition(); void SetPosition(WORD pos); void SetRange(WORD max, WORD min = 0); diff --git a/libs/win32/mir_core.lib b/libs/win32/mir_core.lib index 949cd6f9ac..d0f73992cf 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 45b9cea779..93e4bbceb0 100644 Binary files a/libs/win64/mir_core.lib and b/libs/win64/mir_core.lib differ diff --git a/src/mir_core/src/CCtrlCheck.cpp b/src/mir_core/src/CCtrlCheck.cpp index 13983b148c..01f4773a6d 100644 --- a/src/mir_core/src/CCtrlCheck.cpp +++ b/src/mir_core/src/CCtrlCheck.cpp @@ -50,9 +50,16 @@ void CCtrlCheck::OnReset() } int CCtrlCheck::GetState() -{ return SendMessage(m_hwnd, BM_GETCHECK, 0, 0); +{ + return SendMessage(m_hwnd, BM_GETCHECK, 0, 0); } void CCtrlCheck::SetState(int state) -{ SendMessage(m_hwnd, BM_SETCHECK, state, 0); +{ + SendMessage(m_hwnd, BM_SETCHECK, state, 0); +} + +bool CCtrlCheck::IsChecked() +{ + return GetState() == BST_CHECKED; } diff --git a/src/mir_core/src/CCtrlHyperlink.cpp b/src/mir_core/src/CCtrlHyperlink.cpp index 34266982de..fb0ab7f7ae 100644 --- a/src/mir_core/src/CCtrlHyperlink.cpp +++ b/src/mir_core/src/CCtrlHyperlink.cpp @@ -28,10 +28,27 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. CCtrlHyperlink::CCtrlHyperlink(CDlgBase* wnd, int idCtrl, const char* url) : CCtrlBase(wnd, idCtrl), m_url(url) -{} +{ + OnClick = Callback(this, &CCtrlHyperlink::Default_OnClick); +} -BOOL CCtrlHyperlink::OnCommand(HWND, WORD, WORD) +BOOL CCtrlHyperlink::OnCommand(HWND, WORD, WORD idCode) { - ShellExecuteA(m_hwnd, "open", m_url, "", "", SW_SHOW); + OnClick(this); return FALSE; } + +void CCtrlHyperlink::Default_OnClick(CCtrlHyperlink*) +{ + ShellExecuteA(m_hwnd, "open", m_url, "", "", SW_SHOW); +} + +void CCtrlHyperlink::SetUrl(const char *url) +{ + m_url = url; +} + +const char* CCtrlHyperlink::GetUrl() +{ + return m_url; +} diff --git a/src/mir_core/src/CCtrlSpin.cpp b/src/mir_core/src/CCtrlSpin.cpp index 56491c1411..f0af3c9609 100644 --- a/src/mir_core/src/CCtrlSpin.cpp +++ b/src/mir_core/src/CCtrlSpin.cpp @@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // CCtrlSpin class CCtrlSpin::CCtrlSpin(CDlgBase *dlg, int ctrlId) - : CCtrlBase(dlg, ctrlId) + : CCtrlData(dlg, ctrlId) {} BOOL CCtrlSpin::OnNotify(int, NMHDR *pnmh) @@ -35,10 +35,23 @@ BOOL CCtrlSpin::OnNotify(int, NMHDR *pnmh) NotifyChange(); return TRUE; } - return FALSE; } +void CCtrlSpin::OnApply() +{ + CSuper::OnApply(); + + if (m_dbLink != nullptr) + SaveInt(GetPosition()); +} + +void CCtrlSpin::OnReset() +{ + if (m_dbLink != nullptr) + SetPosition(LoadInt()); +} + WORD CCtrlSpin::GetPosition() { return SendMsg(UDM_GETPOS, 0, 0); diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def index d0fd2ed0c5..a0f547246a 100644 --- a/src/mir_core/src/mir_core.def +++ b/src/mir_core/src/mir_core.def @@ -1057,3 +1057,9 @@ IsTerminalDisconnected @1245 ?FindControl@CDlgBase@@QAEPAVCCtrlBase@@PAUHWND__@@@Z @1247 NONAME ?GlobalFieldEnum@CDlgBase@@CGHPAUHWND__@@J@Z @1248 NONAME ?OnDestroy@CCtrlTreeView@@MAEXXZ @1249 NONAME +?GetUrl@CCtrlHyperlink@@QAEPBDXZ @1250 NONAME +?IsChecked@CCtrlCheck@@QAE_NXZ @1251 NONAME +?OnApply@CCtrlSpin@@UAEXXZ @1252 NONAME +?OnReset@CCtrlSpin@@UAEXXZ @1253 NONAME +?SetUrl@CCtrlHyperlink@@QAEXPBD@Z @1254 NONAME +?Default_OnClick@CCtrlHyperlink@@IAEXPAV1@@Z @1255 NONAME diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def index 26daba4f81..57272df5e8 100644 --- a/src/mir_core/src/mir_core64.def +++ b/src/mir_core/src/mir_core64.def @@ -1057,3 +1057,9 @@ IsTerminalDisconnected @1245 ?FindControl@CDlgBase@@QEAAPEAVCCtrlBase@@PEAUHWND__@@@Z @1247 NONAME ?GlobalFieldEnum@CDlgBase@@CAHPEAUHWND__@@_J@Z @1248 NONAME ?OnDestroy@CCtrlTreeView@@MEAAXXZ @1249 NONAME +?Default_OnClick@CCtrlHyperlink@@IEAAXPEAV1@@Z @1250 NONAME +?GetUrl@CCtrlHyperlink@@QEAAPEBDXZ @1251 NONAME +?IsChecked@CCtrlCheck@@QEAA_NXZ @1252 NONAME +?OnApply@CCtrlSpin@@UEAAXXZ @1253 NONAME +?OnReset@CCtrlSpin@@UEAAXXZ @1254 NONAME +?SetUrl@CCtrlHyperlink@@QEAAXPEBD@Z @1255 NONAME -- cgit v1.2.3