[dasher: 12/217] CModuleControl for T_LONGSPIN bounds checking; no slider
- From: Patrick Welche <pwelche src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dasher: 12/217] CModuleControl for T_LONGSPIN bounds checking; no slider
- Date: Sat, 27 Feb 2016 12:01:20 +0000 (UTC)
commit 1b19c30418ff1ff299c4b8c9ba1a1e9c510061ca
Author: ipomoena <amajorek google com>
Date: Fri Jul 17 14:59:16 2015 -0700
CModuleControl for T_LONGSPIN bounds checking; no slider
Src/Win32/ModuleControlLong.cpp | 39 +++++++++++++++++++++++++++------------
Src/Win32/ModuleControlLong.h | 5 +++--
Src/Win32/ModuleSettings.cpp | 4 ++--
3 files changed, 32 insertions(+), 16 deletions(-)
---
diff --git a/Src/Win32/ModuleControlLong.cpp b/Src/Win32/ModuleControlLong.cpp
index a7dccfd..f4c617d 100644
--- a/Src/Win32/ModuleControlLong.cpp
+++ b/Src/Win32/ModuleControlLong.cpp
@@ -11,7 +11,7 @@ LRESULT CModuleControlLong::OnEditChange(WORD wNotifyCode, WORD wID, HWND hWndCt
}
LRESULT CModuleControlLong::OnEditLeft(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) {
- UpdateValue(GetSliderValue());
+ UpdateValue(GetValue());
return 0;
}
@@ -24,30 +24,35 @@ void CModuleControlLong::Initialise(CAppSettings *pAppSets) {
}
void CModuleControlLong::Apply(CAppSettings *pAppSets) {
- pAppSets->SetLongParameter(m_iId, GetSliderValue());
+ pAppSets->SetLongParameter(m_iId, GetValue());
}
void CModuleControlLong::CreateChild(HWND hParent) {
CWindowImpl<CModuleControlLong>::Create(hParent);
+ if (m_bShowSlider) {
+ m_hSlider.Create(TRACKBAR_CLASS, *this, 0, 0, TBS_HORZ | WS_CHILD | WS_VISIBLE | WS_TABSTOP);
+ m_hSlider.SendMessage(TBM_SETPAGESIZE, 0, m_iStep);
+ m_hSlider.SendMessage(TBM_SETRANGEMIN, true, m_iMin);
+ m_hSlider.SendMessage(TBM_SETRANGEMAX, true, m_iMax);
+ }
- m_hSlider.Create(TRACKBAR_CLASS, *this, 0, 0, TBS_HORZ | WS_CHILD | WS_VISIBLE | WS_TABSTOP);
- m_hSlider.SendMessage(TBM_SETPAGESIZE, 0, m_iStep);
- m_hSlider.SendMessage(TBM_SETRANGEMIN, true, m_iMin);
- m_hSlider.SendMessage(TBM_SETRANGEMAX, true, m_iMax);
-
- m_hEdit.Create(TEXT("EDIT"), *this, 0, 0,
+ m_hEdit.Create(TEXT("EDIT"), *this, 0, 0,
WS_CHILD | WS_VISIBLE | WS_TABSTOP, WS_EX_CLIENTEDGE, 1);
}
void CModuleControlLong::LayoutChild(RECT &sRect) {
MoveWindow(&sRect);
- m_hEdit.MoveWindow(0, 0, 32, sRect.bottom - sRect.top);
- m_hSlider.MoveWindow(32, 0, sRect.right - sRect.left - 32, sRect.bottom - sRect.top);
+ if (m_bShowSlider) {
+ m_hEdit.MoveWindow(0, 0, 32, sRect.bottom - sRect.top);
+ m_hSlider.MoveWindow(32, 0, sRect.right - sRect.left - 32, sRect.bottom - sRect.top);
+ }
+ else {
+ m_hEdit.MoveWindow(0, 0, sRect.right - sRect.left, sRect.bottom - sRect.top);
+ }
}
void CModuleControlLong::UpdateValue(long lValue) {
- if (GetSliderValue() != lValue)
- {
+ if (m_hSlider && GetSliderValue() != lValue) {
m_hSlider.SendMessage(TBM_SETPOS, true, lValue);
}
if (GetEditValue() != lValue)
@@ -68,3 +73,13 @@ long CModuleControlLong::GetEditValue() {
long CModuleControlLong::GetSliderValue() {
return m_hSlider.SendMessage(TBM_GETPOS);
}
+
+long CModuleControlLong::GetValue() {
+ if (m_hSlider)
+ return GetSliderValue();
+
+ long lValue = GetEditValue();
+ if (lValue < m_iMin) lValue = m_iMin;
+ if (lValue > m_iMax) lValue = m_iMax;
+ return lValue;
+}
diff --git a/Src/Win32/ModuleControlLong.h b/Src/Win32/ModuleControlLong.h
index a60205d..cf7b806 100644
--- a/Src/Win32/ModuleControlLong.h
+++ b/Src/Win32/ModuleControlLong.h
@@ -5,7 +5,7 @@
class CModuleControlLong : public CModuleControl, public CWindowImpl<CModuleControlLong>{
public:
- CModuleControlLong(SModuleSettings *pSetting) : CModuleControl(pSetting) {};
+ CModuleControlLong(SModuleSettings *pSetting, bool bShowSlider) : CModuleControl(pSetting),
m_bShowSlider(bShowSlider) {};
DECLARE_WND_SUPERCLASS(NULL, L"STATIC")
BEGIN_MSG_MAP(CModuleControlLong)
@@ -27,9 +27,10 @@ private:
void UpdateValue(long lValue);
long GetEditValue();
long GetSliderValue();
+ long GetValue();
CWindow m_hEdit;
CWindow m_hSlider;
-
+ bool m_bShowSlider;
};
#endif
\ No newline at end of file
diff --git a/Src/Win32/ModuleSettings.cpp b/Src/Win32/ModuleSettings.cpp
index b806864..d434ad7 100644
--- a/Src/Win32/ModuleSettings.cpp
+++ b/Src/Win32/ModuleSettings.cpp
@@ -15,10 +15,10 @@ CModuleSettings::CModuleSettings(const std::string &strModuleName, SModuleSettin
m_pControls[i] = new CModuleControlBool(pSettings + i);
break;
case T_LONG:
- m_pControls[i] = new CModuleControlLong(pSettings + i);
+ m_pControls[i] = new CModuleControlLong(pSettings + i, true);
break;
case T_LONGSPIN:
- m_pControls[i] = new CModuleControlLong(pSettings + i);
+ m_pControls[i] = new CModuleControlLong(pSettings + i, false);
break;
case T_STRING:
m_pControls[i] = new CModuleControlString(pSettings + i);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]