summaryrefslogtreecommitdiff
path: root/plugins/!NotAdopted/HistoryStats/optionsctrlimpl_check.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/!NotAdopted/HistoryStats/optionsctrlimpl_check.cpp')
-rw-r--r--plugins/!NotAdopted/HistoryStats/optionsctrlimpl_check.cpp59
1 files changed, 59 insertions, 0 deletions
diff --git a/plugins/!NotAdopted/HistoryStats/optionsctrlimpl_check.cpp b/plugins/!NotAdopted/HistoryStats/optionsctrlimpl_check.cpp
new file mode 100644
index 0000000000..d6c2b99c56
--- /dev/null
+++ b/plugins/!NotAdopted/HistoryStats/optionsctrlimpl_check.cpp
@@ -0,0 +1,59 @@
+#include "_globals.h"
+#include "optionsctrlimpl.h"
+
+/*
+ * OptionsCtrlImpl::Check
+ */
+
+int OptionsCtrlImpl::Check::getStateImage()
+{
+ return m_bEnabled ? (m_bChecked ? siCheckC : siCheckU) : (m_bChecked ? siCheckCG : siCheckUG);
+}
+
+bool OptionsCtrlImpl::Check::getChildEnable()
+{
+ return
+ !m_bDisableChildsOnUncheck && m_bDisableChilds && m_bEnabled ||
+ m_bDisableChildsOnUncheck && m_bChecked && (!m_bDisableChilds || m_bEnabled);
+}
+
+void OptionsCtrlImpl::Check::updateItem()
+{
+ m_pCtrl->setStateImage(m_hItem, m_bEnabled ? (m_bChecked ? siCheckC : siCheckU) : (m_bChecked ? siCheckCG : siCheckUG));
+
+ if (m_bDisableChilds || m_bDisableChildsOnUncheck)
+ {
+ enableChilds(getChildEnable());
+ }
+}
+
+OptionsCtrlImpl::Check::Check(OptionsCtrlImpl* pCtrl, Item* pParent, const mu_text* szLabel, DWORD dwFlags, DWORD dwData)
+ : Item(pCtrl, itCheck, szLabel, dwFlags, dwData)
+{
+ m_bChecked = bool_(dwFlags & OCF_CHECKED);
+ m_bDisableChildsOnUncheck = bool_(dwFlags & OCF_DISABLECHILDSONUNCHECK);
+
+ pCtrl->insertItem(pParent, this, szLabel, dwFlags, getStateImage());
+
+ if (pParent)
+ {
+ pParent->childAdded(this);
+ }
+}
+
+void OptionsCtrlImpl::Check::onToggle()
+{
+ if (m_bEnabled)
+ {
+ setChecked(!m_bChecked);
+ m_pCtrl->setModified(this);
+ }
+}
+
+void OptionsCtrlImpl::Check::childAdded(Item* pChild)
+{
+ if (m_bDisableChilds || m_bDisableChildsOnUncheck)
+ {
+ pChild->setEnabled(getChildEnable());
+ }
+}