summaryrefslogtreecommitdiff
path: root/plugins/TabSRMM/src/container.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-03-04 19:57:20 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-03-04 19:57:20 +0000
commit011c86b22aa67f25d751f731501eaaec9600f44c (patch)
treec48c84bc91dcd97975a4996d5cffee41ff873fea /plugins/TabSRMM/src/container.cpp
parenta9e2b96e8d4664fddea569f0c233bc0b028555f1 (diff)
fix for the smileys cleanup procedure
git-svn-id: http://svn.miranda-ng.org/main/trunk@3887 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/TabSRMM/src/container.cpp')
-rw-r--r--plugins/TabSRMM/src/container.cpp217
1 files changed, 109 insertions, 108 deletions
diff --git a/plugins/TabSRMM/src/container.cpp b/plugins/TabSRMM/src/container.cpp
index 9568e34161..f1a3aa3ade 100644
--- a/plugins/TabSRMM/src/container.cpp
+++ b/plugins/TabSRMM/src/container.cpp
@@ -66,66 +66,69 @@ static int ServiceParamsOK(ButtonItem *item, WPARAM *wParam, LPARAM *lParam, HAN
void TSAPI SetAeroMargins(TContainerData *pContainer)
{
- if (M->isAero() && pContainer && !CSkin::m_skinEnabled) {
- MARGINS m;
- TWindowData *dat = (TWindowData *)GetWindowLongPtr(pContainer->hwndActive, GWLP_USERDATA);
- RECT rcWnd;
- POINT pt;
- LONG sbar_left = 0, sbar_right = 0;
-
- if (dat) {
- if (dat->bType == SESSIONTYPE_IM) {
- if (dat->Panel->isActive())
- GetWindowRect(GetDlgItem(dat->hwnd, IDC_LOG), &rcWnd);
- else
- GetWindowRect(dat->hwnd, &rcWnd);
- }
- else {
- if (dat->Panel->isActive())
- GetWindowRect(GetDlgItem(dat->hwnd, IDC_CHAT_LOG), &rcWnd);
- else
- GetWindowRect(dat->hwnd, &rcWnd);
- }
-
- pt.x = rcWnd.left;
- pt.y = rcWnd.top;
- ScreenToClient(pContainer->hwnd, &pt);
- m.cyTopHeight = pt.y;
- pContainer->MenuBar->setAero(true);
+ if ( !M->isAero() || !pContainer || CSkin::m_skinEnabled) {
+ pContainer->MenuBar->setAero(false);
+ return;
+ }
- /*
- * bottom part
- */
+ TWindowData *dat = (TWindowData *)GetWindowLongPtr(pContainer->hwndActive, GWLP_USERDATA);
+ if (!dat)
+ return;
+ RECT rcWnd;
+ if (dat->bType == SESSIONTYPE_IM) {
+ if (dat->Panel->isActive())
+ GetWindowRect(GetDlgItem(dat->hwnd, IDC_LOG), &rcWnd);
+ else
GetWindowRect(dat->hwnd, &rcWnd);
- pt.x = rcWnd.left;
- if (!pContainer->SideBar->isActive())
- pt.y = rcWnd.bottom + ((pContainer->iChilds > 1 || !(pContainer->dwFlags & CNT_HIDETABS)) ? pContainer->tBorder : 0);
- else {
- pt.y = rcWnd.bottom;
- sbar_left = (pContainer->SideBar->getFlags() & CSideBar::SIDEBARORIENTATION_LEFT ? pContainer->SideBar->getWidth() : 0);
- sbar_right = (pContainer->SideBar->getFlags() & CSideBar::SIDEBARORIENTATION_RIGHT ? pContainer->SideBar->getWidth() : 0);
- }
- ScreenToClient(pContainer->hwnd, &pt);
- GetClientRect(pContainer->hwnd, &rcWnd);
- m.cyBottomHeight = (rcWnd.bottom - pt.y);
+ }
+ else {
+ if (dat->Panel->isActive())
+ GetWindowRect(GetDlgItem(dat->hwnd, IDC_CHAT_LOG), &rcWnd);
+ else
+ GetWindowRect(dat->hwnd, &rcWnd);
+ }
- if (m.cyBottomHeight < 0 || m.cyBottomHeight >= rcWnd.bottom)
- m.cyBottomHeight = 0;
+ POINT pt = { rcWnd.left, rcWnd.top };
+ ScreenToClient(pContainer->hwnd, &pt);
- m.cxLeftWidth = pContainer->tBorder_outer_left;
- m.cxRightWidth = pContainer->tBorder_outer_right;
- m.cxLeftWidth += sbar_left;
- m.cxRightWidth += sbar_right;
+ MARGINS m;
+ m.cyTopHeight = pt.y;
+ pContainer->MenuBar->setAero(true);
- if (memcmp(&m, &pContainer->mOld, sizeof(MARGINS)) != 0) {
- pContainer->mOld = m;
- CMimAPI::m_pfnDwmExtendFrameIntoClientArea(pContainer->hwnd, &m);
- }
- }
+ /*
+ * bottom part
+ */
+
+ GetWindowRect(dat->hwnd, &rcWnd);
+ pt.x = rcWnd.left;
+
+ LONG sbar_left, sbar_right;
+ if (!pContainer->SideBar->isActive()) {
+ pt.y = rcWnd.bottom + ((pContainer->iChilds > 1 || !(pContainer->dwFlags & CNT_HIDETABS)) ? pContainer->tBorder : 0);
+ sbar_left = 0, sbar_right = 0;
+ }
+ else {
+ pt.y = rcWnd.bottom;
+ sbar_left = (pContainer->SideBar->getFlags() & CSideBar::SIDEBARORIENTATION_LEFT ? pContainer->SideBar->getWidth() : 0);
+ sbar_right = (pContainer->SideBar->getFlags() & CSideBar::SIDEBARORIENTATION_RIGHT ? pContainer->SideBar->getWidth() : 0);
+ }
+ ScreenToClient(pContainer->hwnd, &pt);
+ GetClientRect(pContainer->hwnd, &rcWnd);
+ m.cyBottomHeight = (rcWnd.bottom - pt.y);
+
+ if (m.cyBottomHeight < 0 || m.cyBottomHeight >= rcWnd.bottom)
+ m.cyBottomHeight = 0;
+
+ m.cxLeftWidth = pContainer->tBorder_outer_left;
+ m.cxRightWidth = pContainer->tBorder_outer_right;
+ m.cxLeftWidth += sbar_left;
+ m.cxRightWidth += sbar_right;
+
+ if (memcmp(&m, &pContainer->mOld, sizeof(MARGINS)) != 0) {
+ pContainer->mOld = m;
+ CMimAPI::m_pfnDwmExtendFrameIntoClientArea(pContainer->hwnd, &m);
}
- else
- pContainer->MenuBar->setAero(false);
}
/*
@@ -137,76 +140,74 @@ void TSAPI SetAeroMargins(TContainerData *pContainer)
* pointer and for removing the struct from the linked list.
*/
-struct TContainerData* TSAPI CreateContainer(const TCHAR *name, int iTemp, HANDLE hContactFrom) {
- DBVARIANT dbv;
- char szCounter[10];
+struct TContainerData* TSAPI CreateContainer(const TCHAR *name, int iTemp, HANDLE hContactFrom)
+{
char *szKey = "TAB_ContainersW";
- int i, iFirstFree = -1, iFound = FALSE;
+ int iFirstFree = -1, iFound = FALSE;
- struct TContainerData *pContainer = (struct TContainerData *)malloc(sizeof(struct TContainerData));
- if (pContainer) {
- ZeroMemory((void*)pContainer, sizeof(struct TContainerData));
- _tcsncpy(pContainer->szName, name, CONTAINER_NAMELEN + 1);
- AppendToContainerList(pContainer);
+ struct TContainerData *pContainer = (struct TContainerData *)calloc(sizeof(struct TContainerData), 1);
+ if (!pContainer)
+ return NULL;
- if (M->GetByte("limittabs", 0) && !_tcscmp(name, _T("default")))
- iTemp |= CNT_CREATEFLAG_CLONED;
- /*
- * save container name to the db
- */
- i = 0;
- if (!M->GetByte("singlewinmode", 0)) {
- do {
- _snprintf(szCounter, 8, "%d", i);
- if (M->GetTString(NULL, szKey, szCounter, &dbv)) {
- if (iFirstFree != -1) {
- pContainer->iContainerIndex = iFirstFree;
- _snprintf(szCounter, 8, "%d", iFirstFree);
- }
- else {
- pContainer->iContainerIndex = i;
- }
- M->WriteTString(NULL, szKey, szCounter, name);
- BuildContainerMenu();
- break;
+ _tcsncpy(pContainer->szName, name, CONTAINER_NAMELEN + 1);
+ AppendToContainerList(pContainer);
+
+ if (M->GetByte("limittabs", 0) && !_tcscmp(name, _T("default")))
+ iTemp |= CNT_CREATEFLAG_CLONED;
+ /*
+ * save container name to the db
+ */
+ int i = 0;
+ if (!M->GetByte("singlewinmode", 0)) {
+ do {
+ char szCounter[10];
+ _snprintf(szCounter, 8, "%d", i);
+
+ DBVARIANT dbv;
+ if (M->GetTString(NULL, szKey, szCounter, &dbv)) {
+ if (iFirstFree != -1) {
+ pContainer->iContainerIndex = iFirstFree;
+ _snprintf(szCounter, 8, "%d", iFirstFree);
}
- else {
- if (dbv.type == DBVT_ASCIIZ || dbv.type == DBVT_WCHAR) {
- if (!_tcsncmp(dbv.ptszVal, name, CONTAINER_NAMELEN)) {
- pContainer->iContainerIndex = i;
- iFound = TRUE;
- }
- else if (!_tcsncmp(dbv.ptszVal, _T("**free**"), CONTAINER_NAMELEN))
- iFirstFree = i;
+ else pContainer->iContainerIndex = i;
+
+ M->WriteTString(NULL, szKey, szCounter, name);
+ BuildContainerMenu();
+ break;
+ }
+ else {
+ if (dbv.type == DBVT_ASCIIZ || dbv.type == DBVT_WCHAR) {
+ if (!_tcsncmp(dbv.ptszVal, name, CONTAINER_NAMELEN)) {
+ pContainer->iContainerIndex = i;
+ iFound = TRUE;
}
- DBFreeVariant(&dbv);
+ else if (!_tcsncmp(dbv.ptszVal, _T("**free**"), CONTAINER_NAMELEN))
+ iFirstFree = i;
}
+ DBFreeVariant(&dbv);
}
- while (++i && iFound == FALSE);
- }
- else {
- iTemp |= CNT_CREATEFLAG_CLONED;
- pContainer->iContainerIndex = 1;
}
+ while (++i && iFound == FALSE);
+ }
+ else {
+ iTemp |= CNT_CREATEFLAG_CLONED;
+ pContainer->iContainerIndex = 1;
+ }
- if (iTemp & CNT_CREATEFLAG_MINIMIZED)
- pContainer->dwFlags = CNT_CREATE_MINIMIZED;
- if (iTemp & CNT_CREATEFLAG_CLONED) {
- pContainer->dwFlags |= CNT_CREATE_CLONED;
- pContainer->hContactFrom = hContactFrom;
- }
- pContainer->hwnd = CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSGCONTAINER), NULL, DlgProcContainer, (LPARAM) pContainer);
- return pContainer;
+ if (iTemp & CNT_CREATEFLAG_MINIMIZED)
+ pContainer->dwFlags = CNT_CREATE_MINIMIZED;
+ if (iTemp & CNT_CREATEFLAG_CLONED) {
+ pContainer->dwFlags |= CNT_CREATE_CLONED;
+ pContainer->hContactFrom = hContactFrom;
}
- return NULL;
+ pContainer->hwnd = CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSGCONTAINER), NULL, DlgProcContainer, (LPARAM) pContainer);
+ return pContainer;
}
static LRESULT CALLBACK ContainerWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- BOOL bSkinned;
-
struct TContainerData *pContainer = (struct TContainerData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- bSkinned = CSkin::m_skinEnabled ? TRUE : FALSE;
+ BOOL bSkinned = CSkin::m_skinEnabled ? TRUE : FALSE;
switch (msg) {
case WM_NCPAINT: {