From dcfb8826d85930581d179164afb1522c88074b2d Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 17 Jan 2018 23:14:12 +0300 Subject: no need to copy that stuff each time --- src/mir_app/src/menu_options.cpp | 8 +------- src/mir_app/src/proto_order.cpp | 14 ++------------ src/mir_core/src/CCtrlTreeView.cpp | 23 +++++++++++++++++++++++ 3 files changed, 26 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/mir_app/src/menu_options.cpp b/src/mir_app/src/menu_options.cpp index 750fe1fd8a..93e4422902 100644 --- a/src/mir_app/src/menu_options.cpp +++ b/src/mir_app/src/menu_options.cpp @@ -293,7 +293,7 @@ public: m_menuObjects.OnSelChange = Callback(this, &CGenMenuOptionsPage::onMenuObjectChanged); - m_menuItems.SetFlags(MTREE_CHECKBOX | MTREE_DND /*| MTREE_MULTISELECT*/); + m_menuItems.SetFlags(MTREE_CHECKBOX | MTREE_DND); m_menuItems.OnSelChanged = Callback(this, &CGenMenuOptionsPage::onMenuItemChanged); m_menuItems.OnBeginDrag = Callback(this, &CGenMenuOptionsPage::onMenuItemBeginDrag); @@ -307,11 +307,6 @@ public: { iInitMenuValue = db_get_b(0, "CList", "MoveProtoMenus", TRUE); - HIMAGELIST himlCheckBoxes = ImageList_Create(g_iIconSX, g_iIconSY, ILC_COLOR32 | ILC_MASK, 2, 2); - ImageList_AddIcon_IconLibLoaded(himlCheckBoxes, SKINICON_OTHER_NOTICK); - ImageList_AddIcon_IconLibLoaded(himlCheckBoxes, SKINICON_OTHER_TICK); - m_menuItems.SetImageList(himlCheckBoxes, TVSIL_NORMAL); - if (iInitMenuValue) m_radio2.SetState(true); else @@ -348,7 +343,6 @@ public: virtual void OnDestroy() { - ImageList_Destroy(m_menuItems.GetImageList(TVSIL_NORMAL)); FreeTreeData(); } diff --git a/src/mir_app/src/proto_order.cpp b/src/mir_app/src/proto_order.cpp index b72b6ff049..c1b971b185 100644 --- a/src/mir_app/src/proto_order.cpp +++ b/src/mir_app/src/proto_order.cpp @@ -153,17 +153,12 @@ public: m_order.OnDeleteItem = Callback(this, &CProtocolOrderOpts::onOrder_DeleteItem); } - virtual void OnInitDialog() + virtual void OnInitDialog() override { - HIMAGELIST himlCheckBoxes = ImageList_Create(g_iIconSX, g_iIconSY, ILC_COLOR32 | ILC_MASK, 2, 2); - ImageList_AddIcon_IconLibLoaded(himlCheckBoxes, SKINICON_OTHER_NOTICK); - ImageList_AddIcon_IconLibLoaded(himlCheckBoxes, SKINICON_OTHER_TICK); - m_order.SetImageList(himlCheckBoxes, TVSIL_NORMAL); - FillTree(); } - virtual void OnApply() + virtual void OnApply() override { int idx = 0; @@ -195,11 +190,6 @@ public: Clist_Broadcast(INTM_INVALIDATE, 0, 0); } - virtual void OnDestroy() - { - ImageList_Destroy(m_order.GetImageList(TVSIL_NORMAL)); - } - void onReset_Click(CCtrlButton*) { for (int i = 0; i < accounts.getCount(); i++) diff --git a/src/mir_core/src/CCtrlTreeView.cpp b/src/mir_core/src/CCtrlTreeView.cpp index 0a8ba4e8b2..52c7df846b 100644 --- a/src/mir_core/src/CCtrlTreeView.cpp +++ b/src/mir_core/src/CCtrlTreeView.cpp @@ -22,6 +22,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h" +int ImageList_AddIcon_IconLibLoaded(HIMAGELIST hIml, int iconId) +{ + HICON hIcon = Skin_LoadIcon(iconId); + int res = ImageList_AddIcon(hIml, hIcon); + IcoLib_ReleaseIcon(hIcon); + return res; +} + ///////////////////////////////////////////////////////////////////////////////////////// // CCtrlTreeView @@ -51,6 +59,21 @@ void CCtrlTreeView::OnInit() if (m_bDndEnabled) Subclass(); + + if (m_bCheckBox) { + HIMAGELIST himlCheckBoxes = ::ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 2, 2); + ::ImageList_AddIcon_IconLibLoaded(himlCheckBoxes, SKINICON_OTHER_NOTICK); + ::ImageList_AddIcon_IconLibLoaded(himlCheckBoxes, SKINICON_OTHER_TICK); + SetImageList(himlCheckBoxes, TVSIL_NORMAL); + } +} + +void CCtrlTreeView::OnDestroy() +{ + if (m_bCheckBox) + ::ImageList_Destroy(GetImageList(TVSIL_NORMAL)); + + CSuper::OnDestroy(); } HTREEITEM CCtrlTreeView::MoveItemAbove(HTREEITEM hItem, HTREEITEM hInsertAfter, HTREEITEM hParent) -- cgit v1.2.3