summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2016-12-16 16:14:03 +0300
committerGeorge Hazan <ghazan@miranda.im>2016-12-16 16:14:03 +0300
commit4a3fcb3dbc6b928415d7b5500b4d32b795b86602 (patch)
tree429efe48437f364f32e181324f599d47239a2d9d
parentf63ee92aad4b9b9e0dc4f57360137bfb8252badc (diff)
CCtrlPages::m_pages is not used anymore, all page data are bound to tabs only
-rw-r--r--bin10/lib/mir_core.libbin315516 -> 316154 bytes
-rw-r--r--bin10/lib/mir_core64.libbin316600 -> 317252 bytes
-rw-r--r--bin12/lib/mir_core.libbin315516 -> 316154 bytes
-rw-r--r--bin12/lib/mir_core64.libbin316600 -> 317252 bytes
-rw-r--r--bin14/lib/mir_core.libbin315516 -> 316154 bytes
-rw-r--r--bin14/lib/mir_core64.libbin316600 -> 317252 bytes
-rw-r--r--include/m_gui.h11
-rw-r--r--src/mir_core/src/mir_core.def2
-rw-r--r--src/mir_core/src/mir_core64.def2
-rw-r--r--src/mir_core/src/ui_utils.cpp71
10 files changed, 65 insertions, 21 deletions
diff --git a/bin10/lib/mir_core.lib b/bin10/lib/mir_core.lib
index 046a7a9ab0..1d8ec18973 100644
--- a/bin10/lib/mir_core.lib
+++ b/bin10/lib/mir_core.lib
Binary files differ
diff --git a/bin10/lib/mir_core64.lib b/bin10/lib/mir_core64.lib
index c8c8b4145b..59b32d7dd1 100644
--- a/bin10/lib/mir_core64.lib
+++ b/bin10/lib/mir_core64.lib
Binary files differ
diff --git a/bin12/lib/mir_core.lib b/bin12/lib/mir_core.lib
index 046a7a9ab0..1d8ec18973 100644
--- a/bin12/lib/mir_core.lib
+++ b/bin12/lib/mir_core.lib
Binary files differ
diff --git a/bin12/lib/mir_core64.lib b/bin12/lib/mir_core64.lib
index c8c8b4145b..59b32d7dd1 100644
--- a/bin12/lib/mir_core64.lib
+++ b/bin12/lib/mir_core64.lib
Binary files differ
diff --git a/bin14/lib/mir_core.lib b/bin14/lib/mir_core.lib
index 046a7a9ab0..1d8ec18973 100644
--- a/bin14/lib/mir_core.lib
+++ b/bin14/lib/mir_core.lib
Binary files differ
diff --git a/bin14/lib/mir_core64.lib b/bin14/lib/mir_core64.lib
index c8c8b4145b..59b32d7dd1 100644
--- a/bin14/lib/mir_core64.lib
+++ b/bin14/lib/mir_core64.lib
Binary files differ
diff --git a/include/m_gui.h b/include/m_gui.h
index 6450ec7164..f38764d05c 100644
--- a/include/m_gui.h
+++ b/include/m_gui.h
@@ -1200,9 +1200,9 @@ public:
void ActivatePage(int iPage);
int GetCount(void);
int GetDlgIndex(CDlgBase*);
-
CDlgBase* GetNthPage(int iPage);
-
+ void RemovePage(int iPage);
+
__forceinline CDlgBase* GetActivePage() const
{ return m_pActivePage;
}
@@ -1224,6 +1224,12 @@ private:
struct TPageInfo : public MZeroedObject
{
+ ~TPageInfo()
+ {
+ if (m_hIcon)
+ DestroyIcon(m_hIcon);
+ }
+
int m_pageId;
ptrW m_ptszHeader;
HICON m_hIcon;
@@ -1235,6 +1241,7 @@ private:
void ShowPage(CDlgBase *pDlg);
TPageInfo* GetCurrPage();
+ TPageInfo* GetItemPage(int iPage);
LIST<TPageInfo> m_pages;
};
diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def
index dfd29efba7..bb24cd6108 100644
--- a/src/mir_core/src/mir_core.def
+++ b/src/mir_core/src/mir_core.def
@@ -1044,3 +1044,5 @@ CallFunctionSync @1170
?InsertPage@CCtrlPages@@AAEXPAUTPageInfo@1@@Z @1201 NONAME
?GetDlgIndex@CCtrlPages@@QAEHPAVCDlgBase@@@Z @1202 NONAME
?GetNthPage@CCtrlPages@@QAEPAVCDlgBase@@H@Z @1203 NONAME
+?GetItemPage@CCtrlPages@@AAEPAUTPageInfo@1@H@Z @1204 NONAME
+?RemovePage@CCtrlPages@@QAEXH@Z @1205 NONAME
diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def
index 893c96c3a4..e8a9e2d9cb 100644
--- a/src/mir_core/src/mir_core64.def
+++ b/src/mir_core/src/mir_core64.def
@@ -1044,3 +1044,5 @@ CallFunctionSync @1170
?InsertPage@CCtrlPages@@AEAAXPEAUTPageInfo@1@@Z @1201 NONAME
?GetDlgIndex@CCtrlPages@@QEAAHPEAVCDlgBase@@@Z @1202 NONAME
?GetNthPage@CCtrlPages@@QEAAPEAVCDlgBase@@H@Z @1203 NONAME
+?GetItemPage@CCtrlPages@@AEAAPEAUTPageInfo@1@H@Z @1204 NONAME
+?RemovePage@CCtrlPages@@QEAAXH@Z @1205 NONAME
diff --git a/src/mir_core/src/ui_utils.cpp b/src/mir_core/src/ui_utils.cpp
index ef39a81670..1ca3ee069a 100644
--- a/src/mir_core/src/ui_utils.cpp
+++ b/src/mir_core/src/ui_utils.cpp
@@ -2233,6 +2233,7 @@ void CCtrlPages::OnInit()
for (int i = 0; i < m_pages.getCount(); i++)
InsertPage(m_pages[i]);
+ m_pages.destroy();
::SetWindowLongPtr(m_hwnd, GWL_EXSTYLE, ::GetWindowLongPtr(m_hwnd, GWL_EXSTYLE) | WS_EX_CONTROLPARENT);
@@ -2252,16 +2253,19 @@ void CCtrlPages::OnInit()
LRESULT CCtrlPages::CustomWndProc(UINT msg, WPARAM wParam, LPARAM lParam)
{
+ int tabCount;
+
switch (msg) {
case WM_SIZE:
RECT rc;
GetClientRect(m_hwnd, &rc);
TabCtrl_AdjustRect(m_hwnd, FALSE, &rc);
- for (int i = 0; i < m_pages.getCount(); i++) {
- TPageInfo *p = m_pages[i];
- if (p->m_pDlg->GetHwnd() != NULL)
- SetWindowPos(m_pActivePage->GetHwnd(), HWND_TOP, rc.left, rc.top, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW);
+ tabCount = GetCount();
+ for (int i = 0; i < tabCount; i++) {
+ TPageInfo *p = GetItemPage(i);
+ if (p && p->m_pDlg->GetHwnd() != NULL)
+ SetWindowPos(p->m_pDlg->GetHwnd(), HWND_TOP, rc.left, rc.top, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW);
}
break;
@@ -2271,14 +2275,19 @@ LRESULT CCtrlPages::CustomWndProc(UINT msg, WPARAM wParam, LPARAM lParam)
return TRUE;
case PSM_FORCECHANGED:
+ tabCount = GetCount();
+
PSHNOTIFY pshn;
pshn.hdr.code = PSN_INFOCHANGED;
pshn.hdr.idFrom = 0;
pshn.lParam = 0;
- for (int i = 0; i < m_pages.getCount(); i++) {
- pshn.hdr.hwndFrom = m_pages[i]->m_pDlg->GetHwnd();
- if (pshn.hdr.hwndFrom != NULL)
- SendMessage(pshn.hdr.hwndFrom, WM_NOTIFY, 0, (LPARAM)&pshn);
+ for (int i = 0; i < tabCount; i++) {
+ TPageInfo *p = GetItemPage(i);
+ if (p) {
+ pshn.hdr.hwndFrom = p->m_pDlg->GetHwnd();
+ if (pshn.hdr.hwndFrom != NULL)
+ SendMessage(pshn.hdr.hwndFrom, WM_NOTIFY, 0, (LPARAM)&pshn);
+ }
}
break;
}
@@ -2292,21 +2301,21 @@ void CCtrlPages::AddPage(wchar_t *ptszName, HICON hIcon, CDlgBase *pDlg)
info->m_pDlg = pDlg;
info->m_hIcon = hIcon;
info->m_ptszHeader = mir_wstrdup(ptszName);
- m_pages.insert(info);
if (m_hwnd != NULL) {
InsertPage(info);
- if (m_pages.getCount() == 1) {
+ if (GetCount() == 1) {
m_pActivePage = info->m_pDlg;
ShowPage(m_pActivePage);
}
}
+ else m_pages.insert(info);
}
void CCtrlPages::ActivatePage(int iPage)
{
- TPageInfo *info = m_pages[iPage];
+ TPageInfo *info = GetItemPage(iPage);
if (info == NULL)
return;
@@ -2321,12 +2330,12 @@ void CCtrlPages::ActivatePage(int iPage)
int CCtrlPages::GetCount()
{
- return m_pages.getCount();
+ return TabCtrl_GetItemCount(m_hwnd);
}
CDlgBase* CCtrlPages::GetNthPage(int iPage)
{
- TPageInfo *info = m_pages[iPage];
+ TPageInfo *info = GetItemPage(iPage);
return (info == NULL) ? NULL : info->m_pDlg;
}
@@ -2340,6 +2349,16 @@ CCtrlPages::TPageInfo* CCtrlPages::GetCurrPage()
return (TPageInfo*)tci.lParam;
}
+CCtrlPages::TPageInfo* CCtrlPages::GetItemPage(int iPage)
+{
+ TCITEM tci = { 0 };
+ tci.mask = TCIF_PARAM;
+ if (!TabCtrl_GetItem(m_hwnd, iPage, &tci))
+ return NULL;
+
+ return (TPageInfo*)tci.lParam;
+}
+
int CCtrlPages::GetDlgIndex(CDlgBase *pDlg)
{
int tabCount = TabCtrl_GetItemCount(m_hwnd);
@@ -2358,6 +2377,7 @@ int CCtrlPages::GetDlgIndex(CDlgBase *pDlg)
return -1;
}
+
void CCtrlPages::InsertPage(TPageInfo *pPage)
{
TCITEM tci = { 0 };
@@ -2377,6 +2397,16 @@ void CCtrlPages::InsertPage(TPageInfo *pPage)
pPage->m_pageId = TabCtrl_InsertItem(m_hwnd, TabCtrl_GetItemCount(m_hwnd), &tci);
}
+void CCtrlPages::RemovePage(int iPage)
+{
+ TPageInfo *p = GetItemPage(iPage);
+ if (p == NULL)
+ return;
+
+ TabCtrl_DeleteItem(m_hwnd, iPage);
+ delete p;
+}
+
void CCtrlPages::ShowPage(CDlgBase *pDlg)
{
if (pDlg->GetHwnd() == NULL) {
@@ -2443,8 +2473,9 @@ void CCtrlPages::OnReset()
pshn.hdr.idFrom = 0;
pshn.lParam = 0;
- for (int i = 0; i < m_pages.getCount(); i++) {
- TPageInfo *p = m_pages[i];
+ int tabCount = GetCount();
+ for (int i = 0; i < tabCount; i++) {
+ TPageInfo *p = GetItemPage(i);
if (p->m_pDlg->GetHwnd() == NULL || !p->m_bChanged)
continue;
@@ -2469,8 +2500,9 @@ void CCtrlPages::OnApply()
}
pshn.hdr.code = PSN_APPLY;
- for (int i = 0; i < m_pages.getCount(); i++) {
- TPageInfo *p = m_pages[i];
+ int tabCount = GetCount();
+ for (int i = 0; i < tabCount; i++) {
+ TPageInfo *p = GetItemPage(i);
if (p->m_pDlg->GetHwnd() == NULL || !p->m_bChanged)
continue;
@@ -2492,8 +2524,9 @@ void CCtrlPages::OnApply()
void CCtrlPages::OnDestroy()
{
- for (int i = 0; i < m_pages.getCount(); i++) {
- TPageInfo *p = m_pages[i];
+ int tabCount = GetCount();
+ for (int i = 0; i < tabCount; i++) {
+ TPageInfo *p = GetItemPage(i);
if (p->m_pDlg->GetHwnd())
p->m_pDlg->Close();
delete p;