diff options
author | George Hazan <ghazan@miranda.im> | 2022-02-10 22:33:57 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2022-02-10 22:33:57 +0300 |
commit | 68827c97e131401e97ff772167acf9ab80fe8ef4 (patch) | |
tree | 70ba7134a15620e6e606ba5df6dad2b9a1922574 | |
parent | d40f9d4394e74404024fd8d5a393dce697384935 (diff) |
two extensions for CCtrlTreeOpts for memory variables
-rw-r--r-- | include/m_gui.h | 22 | ||||
-rw-r--r-- | libs/win32/mir_core.lib | bin | 480300 -> 480964 bytes | |||
-rw-r--r-- | libs/win64/mir_core.lib | bin | 485470 -> 486162 bytes | |||
-rw-r--r-- | src/mir_core/src/Windows/CCtrlTreeOpts.cpp | 53 | ||||
-rw-r--r-- | src/mir_core/src/mir_core.def | 1 | ||||
-rw-r--r-- | src/mir_core/src/mir_core64.def | 1 |
6 files changed, 69 insertions, 8 deletions
diff --git a/include/m_gui.h b/include/m_gui.h index a320652f0e..364a255fe2 100644 --- a/include/m_gui.h +++ b/include/m_gui.h @@ -1352,6 +1352,8 @@ public: ~CCtrlTreeOpts(); void AddOption(const wchar_t *pwszSection, const wchar_t *pwszName, CMOption<bool> &option); + void AddOption(const wchar_t *pwszSection, const wchar_t *pwszName, bool &option); + void AddOption(const wchar_t *pwszSection, const wchar_t *pwszName, uint32_t &option, uint32_t mask); BOOL OnNotify(int idCtrl, NMHDR *pnmh) override; void OnDestroy() override; @@ -1363,16 +1365,26 @@ protected: { const wchar_t *m_pwszSection, *m_pwszName; - CMOption<bool> *m_option; + union + { + CMOption<bool> *m_option; + bool *m_pBool; + struct + { + uint32_t *m_pDword; + uint32_t m_mask; + }; + }; HTREEITEM m_hItem = nullptr; + enum OptionItemType { CMOPTION = 1, BOOL = 2, MASK = 3 }; + OptionItemType m_type; - COptionsItem(const wchar_t *pwszSection, const wchar_t *pwszName, CMOption<bool> &option) : + COptionsItem(const wchar_t *pwszSection, const wchar_t *pwszName, OptionItemType type) : m_pwszSection(pwszSection), m_pwszName(pwszName), - m_option(&option) - { - } + m_type(type) + {} }; OBJLIST<COptionsItem> m_options; diff --git a/libs/win32/mir_core.lib b/libs/win32/mir_core.lib Binary files differindex f53831db9c..534bd481b9 100644 --- a/libs/win32/mir_core.lib +++ b/libs/win32/mir_core.lib diff --git a/libs/win64/mir_core.lib b/libs/win64/mir_core.lib Binary files differindex b61080cd83..838e86ef7a 100644 --- a/libs/win64/mir_core.lib +++ b/libs/win64/mir_core.lib diff --git a/src/mir_core/src/Windows/CCtrlTreeOpts.cpp b/src/mir_core/src/Windows/CCtrlTreeOpts.cpp index f5fe27a854..13a6b79bd3 100644 --- a/src/mir_core/src/Windows/CCtrlTreeOpts.cpp +++ b/src/mir_core/src/Windows/CCtrlTreeOpts.cpp @@ -36,7 +36,24 @@ CCtrlTreeOpts::~CCtrlTreeOpts() void CCtrlTreeOpts::AddOption(const wchar_t *pwszSection, const wchar_t *pwszName, CMOption<bool> &option) { - m_options.insert(new COptionsItem(pwszSection, pwszName, option), m_options.getCount()); + auto *p = new COptionsItem(pwszSection, pwszName, COptionsItem::CMOPTION); + p->m_option = &option; + m_options.insert(p, m_options.getCount()); +} + +void CCtrlTreeOpts::AddOption(const wchar_t *pwszSection, const wchar_t *pwszName, bool &option) +{ + auto *p = new COptionsItem(pwszSection, pwszName, COptionsItem::BOOL); + p->m_pBool = &option; + m_options.insert(p, m_options.getCount()); +} + +void CCtrlTreeOpts::AddOption(const wchar_t *pwszSection, const wchar_t *pwszName, uint32_t &option, uint32_t mask) +{ + auto *p = new COptionsItem(pwszSection, pwszName, COptionsItem::MASK); + p->m_pDword = &option; + p->m_mask = mask; + m_options.insert(p, m_options.getCount()); } BOOL CCtrlTreeOpts::OnNotify(int idCtrl, NMHDR *pnmh) @@ -104,6 +121,21 @@ void CCtrlTreeOpts::OnInit() hSection = InsertItem(&tvis); } + bool bValue; + switch (it->m_type) { + case COptionsItem::CMOPTION: + bValue = *it->m_option; + break; + case COptionsItem::BOOL: + bValue = *it->m_pBool; + break; + case COptionsItem::MASK: + bValue = (*it->m_pDword & it->m_mask) != 0; + break; + default: + continue; + } + TVINSERTSTRUCT tvis = {}; tvis.hParent = hSection; tvis.hInsertAfter = TVI_LAST; @@ -111,7 +143,7 @@ void CCtrlTreeOpts::OnInit() tvis.item.pszText = (LPWSTR)it->m_pwszName; tvis.item.state = tvis.item.stateMask = TVIS_EXPANDED; tvis.item.lParam = m_options.indexOf(&it); - tvis.item.iImage = tvis.item.iSelectedImage = (*it->m_option) ? IMG_CHECK : IMG_NOCHECK; + tvis.item.iImage = tvis.item.iSelectedImage = (bValue) ? IMG_CHECK : IMG_NOCHECK; it->m_hItem = InsertItem(&tvis); } @@ -134,7 +166,22 @@ bool CCtrlTreeOpts::OnApply() for (auto &it : m_options) { TVITEMEX tvi; GetItem(it->m_hItem, &tvi); - *it->m_option = (tvi.iImage == IMG_CHECK) ? 1 : 0; + + bool bValue = (tvi.iImage == IMG_CHECK); + switch (it->m_type) { + case COptionsItem::CMOPTION: + *it->m_option = bValue; + break; + case COptionsItem::BOOL: + *it->m_pBool = bValue; + break; + case COptionsItem::MASK: + if (bValue) + *it->m_pDword |= it->m_mask; + else + *it->m_pDword &= ~it->m_mask; + break; + } } return true; } diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def index 70f0dcd951..bcfad9a713 100644 --- a/src/mir_core/src/mir_core.def +++ b/src/mir_core/src/mir_core.def @@ -1513,3 +1513,4 @@ TimeZone_GetSystemTime @1692 ?QueryAttribute@XMLElement@tinyxml2@@QBE?AW4XMLError@2@PBDPAPBD@Z @1735 NONAME
db_copy_module @1736
?db_is_module_empty@@YG_NIPBD@Z @1737 NONAME
+?AddOption@CCtrlTreeOpts@@QAEXPB_W0AA_N@Z @1738 NONAME
diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def index 0fd20a620b..030e27b5c1 100644 --- a/src/mir_core/src/mir_core64.def +++ b/src/mir_core/src/mir_core64.def @@ -1513,3 +1513,4 @@ TimeZone_GetSystemTime @1692 ?QueryAttribute@XMLElement@tinyxml2@@QEBA?AW4XMLError@2@PEBDPEAPEBD@Z @1735 NONAME
db_copy_module @1736
?db_is_module_empty@@YA_NIPEBD@Z @1737 NONAME
+?AddOption@CCtrlTreeOpts@@QEAAXPEB_W0AEA_N@Z @1738 NONAME
|