From b58fa04b8dc505c6d45100ccf772464a4b619df5 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 22 Sep 2016 09:08:46 +0000 Subject: UI utils: - added class CProgress; - added class CTimer; git-svn-id: http://svn.miranda-ng.org/main/trunk@17331 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- bin10/lib/mir_core.lib | Bin 306136 -> 311018 bytes bin10/lib/mir_core64.lib | Bin 306964 -> 311982 bytes bin12/lib/mir_core.lib | Bin 306136 -> 311018 bytes bin12/lib/mir_core64.lib | Bin 306964 -> 311982 bytes bin14/lib/mir_core.lib | Bin 306136 -> 311018 bytes bin14/lib/mir_core64.lib | Bin 306964 -> 311982 bytes include/m_gui.h | 46 +++++++++++++++++++++- src/mir_core/src/mir_core.def | 21 +++++++++- src/mir_core/src/mir_core64.def | 21 +++++++++- src/mir_core/src/ui_utils.cpp | 83 ++++++++++++++++++++++++++++++++++++++-- 10 files changed, 164 insertions(+), 7 deletions(-) diff --git a/bin10/lib/mir_core.lib b/bin10/lib/mir_core.lib index dfef9ea249..1f559beeb7 100644 Binary files a/bin10/lib/mir_core.lib and b/bin10/lib/mir_core.lib differ diff --git a/bin10/lib/mir_core64.lib b/bin10/lib/mir_core64.lib index faa30a740e..76cc57d8ce 100644 Binary files a/bin10/lib/mir_core64.lib and b/bin10/lib/mir_core64.lib differ diff --git a/bin12/lib/mir_core.lib b/bin12/lib/mir_core.lib index dfef9ea249..1f559beeb7 100644 Binary files a/bin12/lib/mir_core.lib and b/bin12/lib/mir_core.lib differ diff --git a/bin12/lib/mir_core64.lib b/bin12/lib/mir_core64.lib index faa30a740e..76cc57d8ce 100644 Binary files a/bin12/lib/mir_core64.lib and b/bin12/lib/mir_core64.lib differ diff --git a/bin14/lib/mir_core.lib b/bin14/lib/mir_core.lib index dfef9ea249..1f559beeb7 100644 Binary files a/bin14/lib/mir_core.lib and b/bin14/lib/mir_core.lib differ diff --git a/bin14/lib/mir_core64.lib b/bin14/lib/mir_core64.lib index faa30a740e..76cc57d8ce 100644 Binary files a/bin14/lib/mir_core64.lib and b/bin14/lib/mir_core64.lib differ diff --git a/include/m_gui.h b/include/m_gui.h index ffc80b1bfd..916e0a4038 100644 --- a/include/m_gui.h +++ b/include/m_gui.h @@ -371,6 +371,7 @@ public: class MIR_CORE_EXPORT CDlgBase { + friend class CTimer; friend class CCtrlBase; friend class CCtrlData; @@ -415,6 +416,8 @@ protected: virtual void OnClose() { } virtual void OnDestroy() { } + virtual void OnTimer(CTimer*) {} + // miranda-related stuff virtual int Resizer(UTILRESIZECONTROL *urc); virtual void OnApply() {} @@ -431,15 +434,42 @@ protected: void ThemeDialogBackground(BOOL tabbed); private: + LIST m_timers; LIST m_controls; void NotifyControls(void (CCtrlBase::*fn)()); CCtrlBase *FindControl(int idCtrl); + CTimer* FindTimer(int idEvent); + static INT_PTR CALLBACK GlobalDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); static int GlobalDlgResizer(HWND hwnd, LPARAM lParam, UTILRESIZECONTROL *urc); }; +///////////////////////////////////////////////////////////////////////////////////////// +// CTimer + +class MIR_CORE_EXPORT CTimer +{ + friend class CDlgBase; + +public: + CTimer(CDlgBase* wnd, int idEvent); + + __forceinline int GetEventId() const { return m_idEvent; } + + virtual BOOL OnTimer(); + + void Start(int elapse); + void Stop(); + + CCallback OnEvent; + +protected: + int m_idEvent; + CDlgBase* m_wnd; +}; + ///////////////////////////////////////////////////////////////////////////////////////// // CCtrlBase @@ -555,6 +585,20 @@ protected: const char* m_url; }; +///////////////////////////////////////////////////////////////////////////////////////// +// CProgress + +class MIR_CORE_EXPORT CProgress : public CCtrlBase +{ +public: + CProgress(CDlgBase *dlg, int ctrlId); + + void SetRange(WORD max, WORD min = 0); + void SetPosition(WORD value); + void SetStep(WORD value); + WORD Move(WORD delta = 0); +}; + ///////////////////////////////////////////////////////////////////////////////////////// // CCtrlClc @@ -711,7 +755,7 @@ class MIR_CORE_EXPORT CCtrlSpin : public CCtrlBase public: CCtrlSpin(CDlgBase *dlg, int ctrlId); - void SetRange(short min, short max); + void SetRange(WORD max, WORD min = 0); }; ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def index 435036b9b4..1c291ab133 100644 --- a/src/mir_core/src/mir_core.def +++ b/src/mir_core/src/mir_core.def @@ -1008,6 +1008,25 @@ db_delete_module @1161 ??4CCtrlSpin@@QAEAAV0@ABV0@@Z @1165 NONAME ??_7CCtrlSpin@@6B@ @1166 NONAME ?SetMaxLength@CCtrlEdit@@QAEXI@Z @1167 NONAME -?SetRange@CCtrlSpin@@QAEXFF@Z @1168 NONAME +?SetRange@CCtrlSpin@@QAEXGG@Z @1168 NONAME db_get_current @1169 CallFunctionSync @1170 +??0CProgress@@QAE@ABV0@@Z @1171 NONAME +??0CProgress@@QAE@PAVCDlgBase@@H@Z @1172 NONAME +??0CTimer@@QAE@ABV0@@Z @1173 NONAME +??0CTimer@@QAE@PAVCDlgBase@@H@Z @1174 NONAME +??1CProgress@@UAE@XZ @1175 NONAME +??4CProgress@@QAEAAV0@ABV0@@Z @1176 NONAME +??4CTimer@@QAEAAV0@ABV0@@Z @1177 NONAME +??_7CProgress@@6B@ @1178 NONAME +??_7CTimer@@6B@ @1179 NONAME +?FindTimer@CDlgBase@@AAEPAVCTimer@@H@Z @1180 NONAME +?GetEventId@CTimer@@QBEHXZ @1181 NONAME +?Move@CProgress@@QAEGG@Z @1182 NONAME +?OnTimer@CDlgBase@@MAEXPAVCTimer@@@Z @1183 NONAME +?OnTimer@CTimer@@UAEHXZ @1184 NONAME +?SetPosition@CProgress@@QAEXG@Z @1185 NONAME +?SetRange@CProgress@@QAEXGG@Z @1186 NONAME +?SetStep@CProgress@@QAEXG@Z @1187 NONAME +?Start@CTimer@@QAEXH@Z @1188 NONAME +?Stop@CTimer@@QAEXXZ @1189 NONAME diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def index f08ff49cdf..d2662a7730 100644 --- a/src/mir_core/src/mir_core64.def +++ b/src/mir_core/src/mir_core64.def @@ -1008,6 +1008,25 @@ db_delete_module @1161 ??4CCtrlSpin@@QEAAAEAV0@AEBV0@@Z @1165 NONAME ??_7CCtrlSpin@@6B@ @1166 NONAME ?SetMaxLength@CCtrlEdit@@QEAAXI@Z @1167 NONAME -?SetRange@CCtrlSpin@@QEAAXFF@Z @1168 NONAME +?SetRange@CCtrlSpin@@QEAAXGG@Z @1168 NONAME db_get_current @1169 CallFunctionSync @1170 +??0CProgress@@QEAA@AEBV0@@Z @1171 NONAME +??0CProgress@@QEAA@PEAVCDlgBase@@H@Z @1172 NONAME +??0CTimer@@QEAA@AEBV0@@Z @1173 NONAME +??0CTimer@@QEAA@PEAVCDlgBase@@H@Z @1174 NONAME +??1CProgress@@UEAA@XZ @1175 NONAME +??4CProgress@@QEAAAEAV0@AEBV0@@Z @1176 NONAME +??4CTimer@@QEAAAEAV0@AEBV0@@Z @1177 NONAME +??_7CProgress@@6B@ @1178 NONAME +??_7CTimer@@6B@ @1179 NONAME +?FindTimer@CDlgBase@@AEAAPEAVCTimer@@H@Z @1180 NONAME +?GetEventId@CTimer@@QEBAHXZ @1181 NONAME +?Move@CProgress@@QEAAGG@Z @1182 NONAME +?OnTimer@CDlgBase@@MEAAXPEAVCTimer@@@Z @1183 NONAME +?OnTimer@CTimer@@UEAAHXZ @1184 NONAME +?SetPosition@CProgress@@QEAAXG@Z @1185 NONAME +?SetRange@CProgress@@QEAAXGG@Z @1186 NONAME +?SetStep@CProgress@@QEAAXG@Z @1187 NONAME +?Start@CTimer@@QEAAXH@Z @1188 NONAME +?Stop@CTimer@@QEAAXXZ @1189 NONAME diff --git a/src/mir_core/src/ui_utils.cpp b/src/mir_core/src/ui_utils.cpp index 7c354bad0a..5e58783be2 100644 --- a/src/mir_core/src/ui_utils.cpp +++ b/src/mir_core/src/ui_utils.cpp @@ -40,12 +40,22 @@ static LIST arControls(10, CompareControls); #pragma comment(lib, "uxtheme") +///////////////////////////////////////////////////////////////////////////////////////// +// CDlgBase + static int CompareControlId(const CCtrlBase *c1, const CCtrlBase *c2) -{ return c1->GetCtrlId() - c2->GetCtrlId(); +{ + return c1->GetCtrlId() - c2->GetCtrlId(); +} + +static int CompareTimerId(const CTimer *t1, const CTimer *t2) +{ + return t1->GetEventId() - t2->GetEventId(); } CDlgBase::CDlgBase(HINSTANCE hInst, int idDialog) - : m_controls(1, CompareControlId) + : m_controls(1, CompareControlId), + m_timers(1, CompareTimerId) { m_hInst = hInst; m_idDialog = idDialog; @@ -198,6 +208,11 @@ INT_PTR CDlgBase::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) Utils_ResizeDialog(m_hwnd, m_hInst, MAKEINTRESOURCEA(m_idDialog), GlobalDlgResizer); return TRUE; + case WM_TIMER: + if (CTimer *timer = FindTimer(wParam)) + return timer->OnTimer(); + return FALSE; + case WM_CLOSE: m_lresult = FALSE; OnClose(); @@ -273,6 +288,12 @@ CCtrlBase* CDlgBase::FindControl(int idCtrl) return m_controls.find(&search); } +CTimer* CDlgBase::FindTimer(int idEvent) +{ + CTimer search(NULL, idEvent); + return m_timers.find(&search); +} + CDlgBase* CDlgBase::Find(HWND hwnd) { PVOID bullshit[2]; // vfptr + hwnd @@ -609,7 +630,7 @@ CCtrlSpin::CCtrlSpin(CDlgBase* dlg, int ctrlId) : CCtrlBase(dlg, ctrlId) {} -void CCtrlSpin::SetRange(short min, short max) +void CCtrlSpin::SetRange(WORD max, WORD min) { SendMsg(UDM_SETRANGE, 0, MAKELONG(min, max)); } @@ -711,6 +732,60 @@ BOOL CCtrlHyperlink::OnCommand(HWND, WORD, WORD) return FALSE; } +///////////////////////////////////////////////////////////////////////////////////////// +// CTimer + +CTimer::CTimer(CDlgBase *wnd, int idEvent) + : m_wnd(wnd), m_idEvent(idEvent) +{ +} + +BOOL CTimer::OnTimer() +{ + OnEvent(this); + return FALSE; +} + +void CTimer::Start(int elapse) +{ + SetTimer(m_wnd->GetHwnd(), m_idEvent, elapse, NULL); +} + +void CTimer::Stop() +{ + KillTimer(m_wnd->GetHwnd(), m_idEvent); +} + +///////////////////////////////////////////////////////////////////////////////////////// +// CProgress + +CProgress::CProgress(CDlgBase *wnd, int idCtrl) + : CCtrlBase(wnd, idCtrl) +{ +} + +void CProgress::SetRange(WORD max, WORD min) +{ + SendMsg(PBM_SETRANGE, 0, MAKELPARAM(min, max)); +} + +void CProgress::SetPosition(WORD value) +{ + SendMsg(PBM_SETPOS, value, 0); +} + +void CProgress::SetStep(WORD value) +{ + SendMsg(PBM_SETSTEP, value, 0); +} + +WORD CProgress::Move(WORD delta) +{ + return delta == 0 + ? SendMsg(PBM_STEPIT, 0, 0) + : SendMsg(PBM_DELTAPOS, delta, 0); +} + ///////////////////////////////////////////////////////////////////////////////////////// // CCtrlClc CCtrlClc::CCtrlClc(CDlgBase* dlg, int ctrlId) @@ -2539,4 +2614,4 @@ wchar_t* CDbLink::LoadText() void CDbLink::SaveText(wchar_t *value) { db_set_ws(NULL, m_szModule, m_szSetting, value); -} +} \ No newline at end of file -- cgit v1.2.3