summaryrefslogtreecommitdiff
path: root/src/mir_core
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2016-12-15 23:29:39 +0300
committerGeorge Hazan <ghazan@miranda.im>2016-12-15 23:29:39 +0300
commit63dd9362a3f8f071669de8f03c06d74a7a617eb8 (patch)
tree78727f52ba4ee6f2720fb89d65fd73a84cc3e97f /src/mir_core
parent47a8f51fb9830ac470c40dfce3ce27c09fd82d7b (diff)
new methods of CCtrlPages
Diffstat (limited to 'src/mir_core')
-rw-r--r--src/mir_core/src/mir_core.def4
-rw-r--r--src/mir_core/src/mir_core64.def4
-rw-r--r--src/mir_core/src/ui_utils.cpp78
3 files changed, 65 insertions, 21 deletions
diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def
index 2020ff8fec..dfd29efba7 100644
--- a/src/mir_core/src/mir_core.def
+++ b/src/mir_core/src/mir_core.def
@@ -1040,3 +1040,7 @@ CallFunctionSync @1170
?GetPosition@CCtrlSpin@@QAEGXZ @1197 NONAME
?OnNotify@CCtrlSpin@@EAEHHPAUtagNMHDR@@@Z @1198 NONAME
?GetCount@CCtrlPages@@QAEHXZ @1199 NONAME
+?GetActivePage@CCtrlPages@@QBEPAVCDlgBase@@XZ @1200 NONAME
+?InsertPage@CCtrlPages@@AAEXPAUTPageInfo@1@@Z @1201 NONAME
+?GetDlgIndex@CCtrlPages@@QAEHPAVCDlgBase@@@Z @1202 NONAME
+?GetNthPage@CCtrlPages@@QAEPAVCDlgBase@@H@Z @1203 NONAME
diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def
index c5be964fd0..893c96c3a4 100644
--- a/src/mir_core/src/mir_core64.def
+++ b/src/mir_core/src/mir_core64.def
@@ -1040,3 +1040,7 @@ CallFunctionSync @1170
?GetPosition@CCtrlSpin@@QEAAGXZ @1197 NONAME
?OnNotify@CCtrlSpin@@EEAAHHPEAUtagNMHDR@@@Z @1198 NONAME
?GetCount@CCtrlPages@@QEAAHXZ @1199 NONAME
+?GetActivePage@CCtrlPages@@QEBAPEAVCDlgBase@@XZ @1200 NONAME
+?InsertPage@CCtrlPages@@AEAAXPEAUTPageInfo@1@@Z @1201 NONAME
+?GetDlgIndex@CCtrlPages@@QEAAHPEAVCDlgBase@@@Z @1202 NONAME
+?GetNthPage@CCtrlPages@@QEAAPEAVCDlgBase@@H@Z @1203 NONAME
diff --git a/src/mir_core/src/ui_utils.cpp b/src/mir_core/src/ui_utils.cpp
index ef6291a8cf..ef39a81670 100644
--- a/src/mir_core/src/ui_utils.cpp
+++ b/src/mir_core/src/ui_utils.cpp
@@ -226,7 +226,7 @@ INT_PTR CDlgBase::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
break;
case WM_SIZE:
- if (m_forceResizable || (GetWindowLongPtr(m_hwnd, GWL_STYLE) & WS_SIZEBOX))
+ if (m_forceResizable || (GetWindowLongPtr(m_hwnd, GWL_STYLE) & WS_THICKFRAME))
Utils_ResizeDialog(m_hwnd, m_hInst, MAKEINTRESOURCEA(m_idDialog), GlobalDlgResizer);
return TRUE;
@@ -2231,24 +2231,8 @@ void CCtrlPages::OnInit()
CSuper::OnInit();
Subclass();
- for (int i = 0; i < m_pages.getCount(); i++) {
- TPageInfo *p = m_pages[i];
- TCITEM tci = { 0 };
- tci.mask = TCIF_PARAM | TCIF_TEXT;
- tci.lParam = (LPARAM)p;
- tci.pszText = TranslateW(p->m_ptszHeader);
- if (p->m_hIcon) {
- if (!m_hIml) {
- m_hIml = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 0, 1);
- TabCtrl_SetImageList(m_hwnd, m_hIml);
- }
-
- tci.mask |= TCIF_IMAGE;
- tci.iImage = ImageList_AddIcon(m_hIml, p->m_hIcon);
- }
-
- p->m_pageId = TabCtrl_InsertItem(m_hwnd, TabCtrl_GetItemCount(m_hwnd), &tci);
- }
+ for (int i = 0; i < m_pages.getCount(); i++)
+ InsertPage(m_pages[i]);
::SetWindowLongPtr(m_hwnd, GWL_EXSTYLE, ::GetWindowLongPtr(m_hwnd, GWL_EXSTYLE) | WS_EX_CONTROLPARENT);
@@ -2309,6 +2293,15 @@ void CCtrlPages::AddPage(wchar_t *ptszName, HICON hIcon, CDlgBase *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) {
+ m_pActivePage = info->m_pDlg;
+ ShowPage(m_pActivePage);
+ }
+ }
}
void CCtrlPages::ActivatePage(int iPage)
@@ -2331,6 +2324,12 @@ int CCtrlPages::GetCount()
return m_pages.getCount();
}
+CDlgBase* CCtrlPages::GetNthPage(int iPage)
+{
+ TPageInfo *info = m_pages[iPage];
+ return (info == NULL) ? NULL : info->m_pDlg;
+}
+
CCtrlPages::TPageInfo* CCtrlPages::GetCurrPage()
{
TCITEM tci = { 0 };
@@ -2341,6 +2340,43 @@ CCtrlPages::TPageInfo* CCtrlPages::GetCurrPage()
return (TPageInfo*)tci.lParam;
}
+int CCtrlPages::GetDlgIndex(CDlgBase *pDlg)
+{
+ int tabCount = TabCtrl_GetItemCount(m_hwnd);
+ for (int i = 0; i < tabCount; i++) {
+ TCITEM tci;
+ tci.mask = TCIF_PARAM | TCIF_IMAGE;
+ TabCtrl_GetItem(m_hwnd, i, &tci);
+ TPageInfo *pPage = (TPageInfo *)tci.lParam;
+ if (pPage == NULL)
+ continue;
+
+ if (pPage->m_pDlg == pDlg)
+ return i;
+ }
+
+ return -1;
+}
+
+void CCtrlPages::InsertPage(TPageInfo *pPage)
+{
+ TCITEM tci = { 0 };
+ tci.mask = TCIF_PARAM | TCIF_TEXT;
+ tci.lParam = (LPARAM)pPage;
+ tci.pszText = TranslateW(pPage->m_ptszHeader);
+ if (pPage->m_hIcon) {
+ if (!m_hIml) {
+ m_hIml = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 0, 1);
+ TabCtrl_SetImageList(m_hwnd, m_hIml);
+ }
+
+ tci.mask |= TCIF_IMAGE;
+ tci.iImage = ImageList_AddIcon(m_hIml, pPage->m_hIcon);
+ }
+
+ pPage->m_pageId = TabCtrl_InsertItem(m_hwnd, TabCtrl_GetItemCount(m_hwnd), &tci);
+}
+
void CCtrlPages::ShowPage(CDlgBase *pDlg)
{
if (pDlg->GetHwnd() == NULL) {
@@ -2350,7 +2386,7 @@ void CCtrlPages::ShowPage(CDlgBase *pDlg)
RECT rc;
GetClientRect(m_hwnd, &rc);
TabCtrl_AdjustRect(m_hwnd, FALSE, &rc);
- SetWindowPos(pDlg->GetHwnd(), HWND_TOP, rc.left, rc.top, 0, 0, SWP_NOSIZE);
+ SetWindowPos(pDlg->GetHwnd(), HWND_TOP, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, SWP_NOACTIVATE);
EnableThemeDialogTexture(pDlg->GetHwnd(), ETDT_ENABLETAB);
@@ -2690,4 +2726,4 @@ wchar_t* CDbLink::LoadText()
void CDbLink::SaveText(wchar_t *value)
{
db_set_ws(NULL, m_szModule, m_szSetting, value);
-} \ No newline at end of file
+}