summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-04-12 14:44:45 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-04-12 14:44:45 +0000
commitea0ec0099a6400a80a4bae0f726e8a1e6522ee86 (patch)
tree0d17d389212e6b83883d09911db362c33e14c336 /plugins
parent2718fa3a1ddcbe82bf36ea1d4060b69de71eeae9 (diff)
- 'Leave chat' button bar's menu item isn't shown for non-chat windows;
- implementation of CustomButtonData became local for buttonsbar.cpp; - code cleaning; - version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@12776 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/TabSRMM/src/TSButton.cpp1
-rw-r--r--plugins/TabSRMM/src/buttonbar.h48
-rw-r--r--plugins/TabSRMM/src/buttonsbar.cpp1609
-rw-r--r--plugins/TabSRMM/src/generic_msghandlers.h3
-rw-r--r--plugins/TabSRMM/src/msgdialog.cpp237
-rw-r--r--plugins/TabSRMM/src/msgdlgutils.cpp5
-rw-r--r--plugins/TabSRMM/src/themes.cpp7
-rw-r--r--plugins/TabSRMM/src/themes.h1
-rw-r--r--plugins/TabSRMM/src/version.h2
9 files changed, 950 insertions, 963 deletions
diff --git a/plugins/TabSRMM/src/TSButton.cpp b/plugins/TabSRMM/src/TSButton.cpp
index fd81fd31a3..dc98af0044 100644
--- a/plugins/TabSRMM/src/TSButton.cpp
+++ b/plugins/TabSRMM/src/TSButton.cpp
@@ -519,5 +519,4 @@ void CustomizeButton(HWND hwndButton)
TSButtonCtrl *bct = (TSButtonCtrl*)GetWindowLongPtr(hwndButton, 0);
if (bct)
bct->hThemeToolbar = (M.isAero() || IsWinVerVistaPlus()) ? OpenThemeData(bct->hwnd, L"MENU") : OpenThemeData(bct->hwnd, L"TOOLBAR");
-
}
diff --git a/plugins/TabSRMM/src/buttonbar.h b/plugins/TabSRMM/src/buttonbar.h
index ada8201f1e..2c1e8ff78b 100644
--- a/plugins/TabSRMM/src/buttonbar.h
+++ b/plugins/TabSRMM/src/buttonbar.h
@@ -1,49 +1,10 @@
#ifndef _BUTTONSBAR_H
#define _BUTTONSBAR_H
-
+
#define MIN_CBUTTONID 4000
#define MAX_CBUTTONID 5000
-#define BBSF_IMBUTTON (1<<0)
-#define BBSF_CHATBUTTON (1<<1)
-#define BBSF_CANBEHIDDEN (1<<2)
-#define BBSF_NTBSWAPED (1<<3)
-#define BBSF_NTBDESTRUCT (1<<4)
-
-struct CustomButtonData : public MZeroedObject
-{
- ~CustomButtonData()
- {
- mir_free(pszModuleName);
- mir_free(ptszTooltip);
- }
-
- DWORD dwPosition; // default order pos of button, counted from window edge (left or right)
-
- DWORD dwButtonOrigID; // id of button used while button creation and to store button info in DB
- char *pszModuleName; // module name without spaces and underline symbols (e.g. "tabsrmm")
-
- DWORD dwButtonCID;
- DWORD dwArrowCID; // only use with BBBF_ISARROWBUTTON flag
-
- TCHAR *ptszTooltip; // button's tooltip
-
- int iButtonWidth; // must be 22 for regular button and 33 for button with arrow
- HANDLE hIcon; // Handle to icolib registred icon
-
- bool bIMButton, bChatButton;
- bool bCanBeHidden, bHidden, bAutoHidden, bSeparator, bDisabled, bPushButton;
- bool bLSided, bRSided;
- BYTE opFlags;
-};
-
-static INT_PTR CB_ModifyButton(WPARAM wParam, LPARAM lParam);
-static INT_PTR CB_RemoveButton(WPARAM wParam, LPARAM lParam);
-static INT_PTR CB_AddButton(WPARAM wParam, LPARAM lParam);
-static INT_PTR CB_GetButtonState(WPARAM wParam, LPARAM lParam);
-static INT_PTR CB_SetButtonState(WPARAM wParam, LPARAM lParam);
-static void CB_GetButtonSettings(MCONTACT hContact, CustomButtonData *cbd);
-
+struct CustomButtonData;
void CB_WriteButtonSettings(MCONTACT hContact, CustomButtonData *cbd);
void CB_DeInitCustomButtons();
@@ -51,9 +12,12 @@ void CB_InitCustomButtons();
void CB_InitDefaultButtons();
void CB_ReInitCustomButtons();
-/* MinGW doesn't like this struct declatations below */
void BB_UpdateIcons(HWND hdlg);
void BB_RefreshTheme(const TWindowData *dat);
+BOOL BB_SetButtonsPos(TWindowData *dat);
+void BB_RedrawButtons(TWindowData *dat);
+void BB_CustomButtonClick(TWindowData *dat, DWORD idFrom, HWND hwndFrom, BOOL code);
+
void CB_DestroyAllButtons(HWND hwndDlg);
void CB_DestroyButton(HWND hwndDlg, TWindowData *dat, DWORD dwButtonCID, DWORD dwFlags);
void CB_ChangeButton(HWND hwndDlg, TWindowData *dat, CustomButtonData* cbd);
diff --git a/plugins/TabSRMM/src/buttonsbar.cpp b/plugins/TabSRMM/src/buttonsbar.cpp
index 152e488718..7713ba0bdd 100644
--- a/plugins/TabSRMM/src/buttonsbar.cpp
+++ b/plugins/TabSRMM/src/buttonsbar.cpp
@@ -1,5 +1,40 @@
#include "commonheaders.h"
-
+
+#define BBSF_IMBUTTON (1<<0)
+#define BBSF_CHATBUTTON (1<<1)
+#define BBSF_CANBEHIDDEN (1<<2)
+#define BBSF_NTBSWAPED (1<<3)
+#define BBSF_NTBDESTRUCT (1<<4)
+
+struct CustomButtonData : public MZeroedObject
+{
+ ~CustomButtonData()
+ {
+ mir_free(m_pszModuleName);
+ mir_free(m_ptszTooltip);
+ }
+
+ void Accustom(HWND hwnd, TWindowData *dat);
+
+ DWORD m_dwPosition; // default order pos of button, counted from window edge (left or right)
+
+ DWORD m_dwButtonOrigID; // id of button used while button creation and to store button info in DB
+ char *m_pszModuleName; // module name without spaces and underline symbols (e.g. "tabsrmm")
+
+ DWORD m_dwButtonCID;
+ DWORD m_dwArrowCID; // only use with BBBF_ISARROWBUTTON flag
+
+ TCHAR *m_ptszTooltip; // button's tooltip
+
+ int m_iButtonWidth; // must be 22 for regular button and 33 for button with arrow
+ HANDLE m_hIcon; // Handle to icolib registred icon
+
+ bool m_bIMButton, m_bChatButton;
+ bool m_bCanBeHidden, m_bHidden, m_bAutoHidden, m_bSeparator, m_bDisabled, m_bPushButton;
+ bool m_bLSided, m_bRSided;
+ BYTE m_opFlags;
+};
+
static HANDLE hButtonsBarAddButton;
static HANDLE hButtonsBarRemoveButton;
static HANDLE hButtonsBarGetButtonState;
@@ -14,7 +49,7 @@ static LIST<CustomButtonData> RButtonsList(1, NumericKeySortT), LButtonsList(1,
DWORD LastCID = 4000;
DWORD dwSepCount = 0;
-static mir_cs ToolBarCS;
+static mir_cs csToolBar;
static void wipeList(LIST<CustomButtonData> &list)
{
@@ -26,121 +61,42 @@ static void wipeList(LIST<CustomButtonData> &list)
static int sstSortButtons(const void *p1, const void *p2)
{
- return (*(CustomButtonData**)p1)->dwPosition - (*(CustomButtonData**)p2)->dwPosition;
-}
-
-void CB_InitCustomButtons()
-{
- dwSepCount = M.GetDword("TabSRMM_Toolbar", "SeparatorsCount", 0);
-
- hButtonsBarAddButton = CreateServiceFunction(MS_BB_ADDBUTTON, CB_AddButton);
- hButtonsBarRemoveButton = CreateServiceFunction(MS_BB_REMOVEBUTTON, CB_RemoveButton);
- hButtonsBarModifyButton = CreateServiceFunction(MS_BB_MODIFYBUTTON, CB_ModifyButton);
- hButtonsBarGetButtonState = CreateServiceFunction(MS_BB_GETBUTTONSTATE, CB_GetButtonState);
- hButtonsBarSetButtonState = CreateServiceFunction(MS_BB_SETBUTTONSTATE, CB_SetButtonState);
-
- hHookToolBarLoadedEvt = CreateHookableEvent(ME_MSG_TOOLBARLOADED);
- hHookButtonPressedEvt = CreateHookableEvent(ME_MSG_BUTTONPRESSED);
-}
-
-void CB_DeInitCustomButtons()
-{
- wipeList(LButtonsList);
- wipeList(RButtonsList);
-
- DestroyHookableEvent(hHookToolBarLoadedEvt);
- DestroyHookableEvent(hHookButtonPressedEvt);
- DestroyServiceFunction(hButtonsBarAddButton);
- DestroyServiceFunction(hButtonsBarRemoveButton);
- DestroyServiceFunction(hButtonsBarModifyButton);
- DestroyServiceFunction(hButtonsBarGetButtonState);
- DestroyServiceFunction(hButtonsBarSetButtonState);
+ return (*(CustomButtonData**)p1)->m_dwPosition - (*(CustomButtonData**)p2)->m_dwPosition;
}
-void CB_DestroyAllButtons(HWND hwndDlg)
+static void CB_GetButtonSettings(MCONTACT hContact, CustomButtonData *cbd)
{
- HWND hwndBtn = NULL;
- for (int i = 0; i < LButtonsList.getCount(); i++) {
- CustomButtonData *cbd = LButtonsList[i];
- hwndBtn = GetDlgItem(hwndDlg, cbd->dwButtonCID);
- if (hwndBtn)
- DestroyWindow(hwndBtn);
- }
-
- for (int i = 0; i < RButtonsList.getCount(); i++) {
- CustomButtonData *cbd = RButtonsList[i];
- hwndBtn = GetDlgItem(hwndDlg, cbd->dwButtonCID);
- if (hwndBtn)
- DestroyWindow(hwndBtn);
- }
-}
-
-void CB_DestroyButton(HWND hwndDlg, TWindowData *dat, DWORD dwButtonCID, DWORD dwFlags)
-{
- HWND hwndBtn = GetDlgItem(hwndDlg, dwButtonCID);
- RECT rc = { 0 };
- if (hwndBtn) {
- GetClientRect(hwndBtn, &rc);
- if (dwFlags & BBBF_ISLSIDEBUTTON)
- dat->bbLSideWidth -= rc.right;
- else if (dwFlags & BBBF_ISRSIDEBUTTON)
- dat->bbRSideWidth -= rc.right;
-
- DestroyWindow(hwndBtn);
- BB_SetButtonsPos(dat);
- }
-}
-
-void CB_ChangeButton(HWND hwndDlg, TWindowData *dat, CustomButtonData *cbd)
-{
- HWND hwndBtn = GetDlgItem(hwndDlg, cbd->dwButtonCID);
- if (hwndBtn) {
- if (cbd->hIcon)
- SendMessage(hwndBtn, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Skin_GetIconByHandle(cbd->hIcon));
- if (cbd->ptszTooltip)
- SendMessage(hwndBtn, BUTTONADDTOOLTIP, (WPARAM)cbd->ptszTooltip, BATF_TCHAR);
- SendMessage(hwndBtn, BUTTONSETCONTAINER, (LPARAM)dat->pContainer, 0);
- SetWindowTextA(hwndBtn, cbd->pszModuleName);
- }
-}
-
-void CB_ReInitCustomButtons()
-{
- for (int i = 0; i < LButtonsList.getCount(); i++) {
- CustomButtonData *cbd = LButtonsList[i];
-
- if (cbd->opFlags & BBSF_NTBSWAPED || cbd->opFlags & BBSF_NTBDESTRUCT) {
- cbd->opFlags ^= BBSF_NTBSWAPED;
-
- if (!(cbd->opFlags & BBSF_NTBDESTRUCT))
- RButtonsList.insert(cbd);
+ DBVARIANT dbv = { 0 };
+ char SettingName[1024];
+ char* token = NULL;
- LButtonsList.remove(i);
- i--;
- }
- }
+ //modulename_buttonID, position_inIM_inCHAT_isLSide_isRSide_CanBeHidden
- for (int i = 0; i < RButtonsList.getCount(); i++) {
- CustomButtonData* cbd = RButtonsList[i];
- if (cbd->opFlags & BBSF_NTBSWAPED || cbd->opFlags & BBSF_NTBDESTRUCT) {
- cbd->opFlags ^= BBSF_NTBSWAPED;
+ mir_snprintf(SettingName, SIZEOF(SettingName), "%s_%d", cbd->m_pszModuleName, cbd->m_dwButtonOrigID);
- if (!(cbd->opFlags & BBSF_NTBDESTRUCT))
- LButtonsList.insert(cbd);
+ if (!db_get_s(hContact, "TabSRMM_Toolbar", SettingName, &dbv)) {
+ token = strtok(dbv.pszVal, "_");
+ cbd->m_dwPosition = (DWORD)atoi(token);
+ token = strtok(NULL, "_");
+ cbd->m_bIMButton = atoi(token) != 0;
+ token = strtok(NULL, "_");
+ cbd->m_bChatButton = atoi(token) != 0;
+ token = strtok(NULL, "_");
+ cbd->m_bLSided = atoi(token) != 0;
+ token = strtok(NULL, "_");
+ cbd->m_bRSided = atoi(token) != 0;
+ token = strtok(NULL, "_");
+ cbd->m_bCanBeHidden = atoi(token) != 0;
- RButtonsList.remove(i);
- i--;
- }
+ db_free(&dbv);
}
- M.BroadcastMessage(DM_BBNEEDUPDATE, 0, 0);
- M.BroadcastMessage(DM_LOADBUTTONBARICONS, 0, 0);
}
-void CB_HardReInit()
+static void CB_HardReInit()
{
M.BroadcastMessage(DM_CBDESTROY, 0, 0);
{
- mir_cslock lck(ToolBarCS);
+ mir_cslock lck(csToolBar);
wipeList(LButtonsList);
wipeList(RButtonsList);
}
@@ -158,54 +114,53 @@ static INT_PTR CB_AddButton(WPARAM, LPARAM lParam)
return 1;
CustomButtonData *cbd = new CustomButtonData();
-
if (!bbdi->iButtonWidth && (bbdi->bbbFlags & BBBF_ISARROWBUTTON))
- cbd->iButtonWidth = DPISCALEX_S(34);
+ cbd->m_iButtonWidth = DPISCALEX_S(34);
else if (!bbdi->iButtonWidth)
- cbd->iButtonWidth = DPISCALEX_S(22);
+ cbd->m_iButtonWidth = DPISCALEX_S(22);
else
- cbd->iButtonWidth = DPISCALEX_S(bbdi->iButtonWidth);
+ cbd->m_iButtonWidth = DPISCALEX_S(bbdi->iButtonWidth);
- cbd->pszModuleName = mir_strdup(bbdi->pszModuleName);
+ cbd->m_pszModuleName = mir_strdup(bbdi->pszModuleName);
if (bbdi->ptszTooltip) {
if (bbdi->bbbFlags & BBBF_ANSITOOLTIP)
- cbd->ptszTooltip = mir_a2u(bbdi->pszTooltip);
+ cbd->m_ptszTooltip = mir_a2u(bbdi->pszTooltip);
else
- cbd->ptszTooltip = mir_tstrdup(bbdi->ptszTooltip);
+ cbd->m_ptszTooltip = mir_tstrdup(bbdi->ptszTooltip);
}
- else cbd->ptszTooltip = NULL;
-
- cbd->dwButtonOrigID = bbdi->dwButtonID;
- cbd->hIcon = bbdi->hIcon;
- cbd->dwPosition = bbdi->dwDefPos;
- cbd->dwButtonCID = (bbdi->bbbFlags & BBBF_CREATEBYID) ? bbdi->dwButtonID : LastCID;
- //ugly workaround for smileys plugins
- cbd->dwArrowCID = (bbdi->bbbFlags & BBBF_ISARROWBUTTON) ? (cbd->dwButtonCID == IDOK ? IDC_SENDMENU : (cbd->dwButtonCID + 1)) : 0;
- cbd->bHidden = (bbdi->bbbFlags & BBBF_HIDDEN) != 0;
- cbd->bLSided = (bbdi->bbbFlags & BBBF_ISLSIDEBUTTON) != 0;
- cbd->bRSided = (bbdi->bbbFlags & BBBF_ISRSIDEBUTTON) != 0;
- cbd->bCanBeHidden = (bbdi->bbbFlags & BBBF_CANBEHIDDEN) != 0;
- cbd->bSeparator = (bbdi->bbbFlags & BBBF_ISDUMMYBUTTON) != 0;
- cbd->bChatButton = (bbdi->bbbFlags & BBBF_ISCHATBUTTON) != 0;
- cbd->bIMButton = (bbdi->bbbFlags & BBBF_ISIMBUTTON) != 0;
- cbd->bDisabled = (bbdi->bbbFlags & BBBF_DISABLED) != 0;
- cbd->bPushButton = (bbdi->bbbFlags & BBBF_ISPUSHBUTTON) != 0;
+ else cbd->m_ptszTooltip = NULL;
+
+ cbd->m_dwButtonOrigID = bbdi->dwButtonID;
+ cbd->m_hIcon = bbdi->hIcon;
+ cbd->m_dwPosition = bbdi->dwDefPos;
+ cbd->m_dwButtonCID = (bbdi->bbbFlags & BBBF_CREATEBYID) ? bbdi->dwButtonID : LastCID;
+ // ugly workaround for smileys plugins
+ cbd->m_dwArrowCID = (bbdi->bbbFlags & BBBF_ISARROWBUTTON) ? (cbd->m_dwButtonCID == IDOK ? IDC_SENDMENU : (cbd->m_dwButtonCID + 1)) : 0;
+ cbd->m_bHidden = (bbdi->bbbFlags & BBBF_HIDDEN) != 0;
+ cbd->m_bLSided = (bbdi->bbbFlags & BBBF_ISLSIDEBUTTON) != 0;
+ cbd->m_bRSided = (bbdi->bbbFlags & BBBF_ISRSIDEBUTTON) != 0;
+ cbd->m_bCanBeHidden = (bbdi->bbbFlags & BBBF_CANBEHIDDEN) != 0;
+ cbd->m_bSeparator = (bbdi->bbbFlags & BBBF_ISDUMMYBUTTON) != 0;
+ cbd->m_bChatButton = (bbdi->bbbFlags & BBBF_ISCHATBUTTON) != 0;
+ cbd->m_bIMButton = (bbdi->bbbFlags & BBBF_ISIMBUTTON) != 0;
+ cbd->m_bDisabled = (bbdi->bbbFlags & BBBF_DISABLED) != 0;
+ cbd->m_bPushButton = (bbdi->bbbFlags & BBBF_ISPUSHBUTTON) != 0;
CB_GetButtonSettings(NULL, cbd);
- if (cbd->bLSided)
+ if (cbd->m_bLSided)
LButtonsList.insert(cbd);
- else if (cbd->bRSided)
+ else if (cbd->m_bRSided)
RButtonsList.insert(cbd);
else {
delete cbd;
return 1;
}
- if (cbd->dwButtonCID != cbd->dwButtonOrigID)
+ if (cbd->m_dwButtonCID != cbd->m_dwButtonOrigID)
LastCID++;
- if (cbd->dwArrowCID == LastCID)
+ if (cbd->m_dwArrowCID == LastCID)
LastCID++;
M.BroadcastMessage(DM_BBNEEDUPDATE, 0, 0);
@@ -223,17 +178,17 @@ static INT_PTR CB_GetButtonState(WPARAM wParam, LPARAM lParam)
bbdi->bbbFlags = 0;
for (int i = 0; i < LButtonsList.getCount(); i++) {
CustomButtonData *cbd = LButtonsList[i];
- if (!strcmp(cbd->pszModuleName, bbdi->pszModuleName) && (cbd->dwButtonOrigID == bbdi->dwButtonID)) {
+ if (!strcmp(cbd->m_pszModuleName, bbdi->pszModuleName) && (cbd->m_dwButtonOrigID == bbdi->dwButtonID)) {
realbutton = true;
- tempCID = cbd->dwButtonCID;
+ tempCID = cbd->m_dwButtonCID;
}
}
if (!realbutton)
for (int i = 0; i < RButtonsList.getCount(); i++) {
CustomButtonData* cbd = RButtonsList[i];
- if (!strcmp(cbd->pszModuleName, bbdi->pszModuleName) && (cbd->dwButtonOrigID == bbdi->dwButtonID)) {
+ if (!strcmp(cbd->m_pszModuleName, bbdi->pszModuleName) && (cbd->m_dwButtonOrigID == bbdi->dwButtonID)) {
realbutton = true;
- tempCID = cbd->dwButtonCID;
+ tempCID = cbd->m_dwButtonCID;
}
}
@@ -259,17 +214,17 @@ static INT_PTR CB_SetButtonState(WPARAM wParam, LPARAM lParam)
BBButton *bbdi = (BBButton *)lParam;
for (int i = 0; i < LButtonsList.getCount(); i++) {
CustomButtonData *cbd = LButtonsList[i];
- if (!strcmp(cbd->pszModuleName, bbdi->pszModuleName) && (cbd->dwButtonOrigID == bbdi->dwButtonID)) {
+ if (!strcmp(cbd->m_pszModuleName, bbdi->pszModuleName) && (cbd->m_dwButtonOrigID == bbdi->dwButtonID)) {
realbutton = true;
- tempCID = cbd->dwButtonCID;
+ tempCID = cbd->m_dwButtonCID;
}
}
if (!realbutton)
for (int i = 0; i < RButtonsList.getCount(); i++) {
CustomButtonData* cbd = RButtonsList[i];
- if (!strcmp(cbd->pszModuleName, bbdi->pszModuleName) && (cbd->dwButtonOrigID == bbdi->dwButtonID)) {
+ if (!strcmp(cbd->m_pszModuleName, bbdi->pszModuleName) && (cbd->m_dwButtonOrigID == bbdi->dwButtonID)) {
realbutton = true;
- tempCID = cbd->dwButtonCID;
+ tempCID = cbd->m_dwButtonCID;
}
}
@@ -303,13 +258,13 @@ static INT_PTR CB_RemoveButton(WPARAM, LPARAM lParam)
DWORD tempCID = 0;
DWORD dwFlags = 0;
{
- mir_cslock lck(ToolBarCS);
+ mir_cslock lck(csToolBar);
for (int i = LButtonsList.getCount() - 1; i >= 0; i--) {
CustomButtonData *cbd = LButtonsList[i];
- if (!strcmp(cbd->pszModuleName, bbdi->pszModuleName) && cbd->dwButtonOrigID == bbdi->dwButtonID) {
- tempCID = cbd->dwButtonCID;
- dwFlags = cbd->bLSided ? BBBF_ISLSIDEBUTTON : BBBF_ISRSIDEBUTTON;
+ if (!strcmp(cbd->m_pszModuleName, bbdi->pszModuleName) && cbd->m_dwButtonOrigID == bbdi->dwButtonID) {
+ tempCID = cbd->m_dwButtonCID;
+ dwFlags = cbd->m_bLSided ? BBBF_ISLSIDEBUTTON : BBBF_ISRSIDEBUTTON;
LButtonsList.remove(i);
}
}
@@ -317,9 +272,9 @@ static INT_PTR CB_RemoveButton(WPARAM, LPARAM lParam)
if (!tempCID) {
for (int i = RButtonsList.getCount() - 1; i >= 0; i--) {
CustomButtonData *cbd = RButtonsList[i];
- if (!strcmp(cbd->pszModuleName, bbdi->pszModuleName) && cbd->dwButtonOrigID == bbdi->dwButtonID) {
- tempCID = cbd->dwButtonCID;
- dwFlags = cbd->bLSided ? BBBF_ISLSIDEBUTTON : BBBF_ISRSIDEBUTTON;
+ if (!strcmp(cbd->m_pszModuleName, bbdi->pszModuleName) && cbd->m_dwButtonOrigID == bbdi->dwButtonID) {
+ tempCID = cbd->m_dwButtonCID;
+ dwFlags = cbd->m_bLSided ? BBBF_ISLSIDEBUTTON : BBBF_ISRSIDEBUTTON;
RButtonsList.remove(i);
}
}
@@ -340,11 +295,11 @@ static INT_PTR CB_ModifyButton(WPARAM, LPARAM lParam)
bool bFound = false;
CustomButtonData *cbd = NULL;
{
- mir_cslock lck(ToolBarCS);
+ mir_cslock lck(csToolBar);
for (int i = 0; i < LButtonsList.getCount(); i++) {
cbd = LButtonsList[i];
- if (!strcmp(cbd->pszModuleName, bbdi->pszModuleName) && (cbd->dwButtonOrigID == bbdi->dwButtonID)) {
+ if (!strcmp(cbd->m_pszModuleName, bbdi->pszModuleName) && (cbd->m_dwButtonOrigID == bbdi->dwButtonID)) {
bFound = true;
break;
}
@@ -353,7 +308,7 @@ static INT_PTR CB_ModifyButton(WPARAM, LPARAM lParam)
if (!bFound) {
for (int i = 0; i < RButtonsList.getCount(); i++) {
cbd = RButtonsList[i];
- if (!strcmp(cbd->pszModuleName, bbdi->pszModuleName) && (cbd->dwButtonOrigID == bbdi->dwButtonID)) {
+ if (!strcmp(cbd->m_pszModuleName, bbdi->pszModuleName) && (cbd->m_dwButtonOrigID == bbdi->dwButtonID)) {
bFound = true;
break;
}
@@ -362,22 +317,22 @@ static INT_PTR CB_ModifyButton(WPARAM, LPARAM lParam)
if (bFound) {
if (bbdi->pszTooltip) {
- mir_free(cbd->ptszTooltip);
+ mir_free(cbd->m_ptszTooltip);
if (bbdi->bbbFlags & BBBF_ANSITOOLTIP)
- cbd->ptszTooltip = mir_a2u(bbdi->pszTooltip);
+ cbd->m_ptszTooltip = mir_a2u(bbdi->pszTooltip);
else
- cbd->ptszTooltip = mir_tstrdup(bbdi->ptszTooltip);
+ cbd->m_ptszTooltip = mir_tstrdup(bbdi->ptszTooltip);
}
if (bbdi->hIcon)
- cbd->hIcon = bbdi->hIcon;
+ cbd->m_hIcon = bbdi->hIcon;
if (bbdi->bbbFlags) {
- cbd->bHidden = (bbdi->bbbFlags & BBBF_HIDDEN) != 0;
- cbd->bLSided = (bbdi->bbbFlags & BBBF_ISLSIDEBUTTON) != 0;
- cbd->bRSided = (bbdi->bbbFlags & BBBF_ISRSIDEBUTTON) != 0;
- cbd->bCanBeHidden = (bbdi->bbbFlags & BBBF_CANBEHIDDEN) != 0;
- cbd->bChatButton = (bbdi->bbbFlags & BBBF_ISCHATBUTTON) != 0;
- cbd->bIMButton = (bbdi->bbbFlags & BBBF_ISIMBUTTON) != 0;
- cbd->bDisabled = (bbdi->bbbFlags & BBBF_DISABLED) != 0;
+ cbd->m_bHidden = (bbdi->bbbFlags & BBBF_HIDDEN) != 0;
+ cbd->m_bLSided = (bbdi->bbbFlags & BBBF_ISLSIDEBUTTON) != 0;
+ cbd->m_bRSided = (bbdi->bbbFlags & BBBF_ISRSIDEBUTTON) != 0;
+ cbd->m_bCanBeHidden = (bbdi->bbbFlags & BBBF_CANBEHIDDEN) != 0;
+ cbd->m_bChatButton = (bbdi->bbbFlags & BBBF_ISCHATBUTTON) != 0;
+ cbd->m_bIMButton = (bbdi->bbbFlags & BBBF_ISIMBUTTON) != 0;
+ cbd->m_bDisabled = (bbdi->bbbFlags & BBBF_DISABLED) != 0;
}
}
}
@@ -387,394 +342,7 @@ static INT_PTR CB_ModifyButton(WPARAM, LPARAM lParam)
return 0;
}
-void BB_UpdateIcons(HWND hdlg)
-{
- HWND hwndBtn = NULL;
-
- for (int i = 0; i < LButtonsList.getCount(); i++) {
- CustomButtonData *cbd = LButtonsList[i];
- if (cbd) {
- if (!cbd->bSeparator)
- hwndBtn = GetDlgItem(hdlg, cbd->dwButtonCID);
-
- if (hwndBtn && cbd->hIcon)
- SendMessage(hwndBtn, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Skin_GetIconByHandle(cbd->hIcon));
- }
- }
-
- hwndBtn = NULL;
- for (int i = 0; i < RButtonsList.getCount(); i++) {
- CustomButtonData *cbd = RButtonsList[i];
- if (cbd) {
- if (!cbd->bSeparator)
- hwndBtn = GetDlgItem(hdlg, cbd->dwButtonCID);
-
- if (hwndBtn && cbd->hIcon)
- SendMessage(hwndBtn, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Skin_GetIconByHandle(cbd->hIcon));
- }
- }
-}
-
-void TSAPI BB_InitDlgButtons(TWindowData *dat)
-{
- if (dat == 0)
- return;
- HWND hdlg = dat->hwnd;
- if (hdlg == 0)
- return;
- RECT rect;
- int lwidth = 0, rwidth = 0;
- RECT rcSplitter;
- POINT ptSplitter;
- int splitterY;
- BYTE gap = DPISCALEX_S(PluginConfig.m_iButtonsBarGap);
- BOOL isThemed = TRUE;
-
- if (CSkin::m_skinEnabled && !SkinItems[ID_EXTBKBUTTONSNPRESSED].IGNORED &&
- !SkinItems[ID_EXTBKBUTTONSPRESSED].IGNORED && !SkinItems[ID_EXTBKBUTTONSMOUSEOVER].IGNORED) {
- isThemed = FALSE;
- }
-
- GetWindowRect(GetDlgItem(hdlg, (dat->bType == SESSIONTYPE_IM) ? IDC_SPLITTER : IDC_SPLITTERY), &rcSplitter);
- ptSplitter.x = 0;
- ptSplitter.y = rcSplitter.top;
- ScreenToClient(hdlg, &ptSplitter);
-
- GetClientRect(hdlg, &rect);
- splitterY = ptSplitter.y - DPISCALEY_S(1);
-
- HWND hwndBtn = NULL;
-
- for (int i = 0; i < RButtonsList.getCount(); i++) {
- CustomButtonData *cbd = RButtonsList[i];
- if (((dat->bType == SESSIONTYPE_IM && cbd->bIMButton) || (dat->bType == SESSIONTYPE_CHAT && cbd->bChatButton))) {
- if (!cbd->bHidden)
- rwidth += cbd->iButtonWidth + gap;
- if (!cbd->bHidden && !cbd->bCanBeHidden)
- dat->iButtonBarReallyNeeds += cbd->iButtonWidth + gap;
- if (!cbd->bSeparator && !GetDlgItem(hdlg, cbd->dwButtonCID)) {
- hwndBtn = CreateWindowEx(0, _T("MButtonClass"), _T(""), WS_CHILD | WS_VISIBLE | WS_TABSTOP, rect.right - rwidth + gap, splitterY, cbd->iButtonWidth, DPISCALEY_S(22), hdlg, (HMENU)cbd->dwButtonCID, g_hInst, NULL);
- CustomizeButton(hwndBtn);
- }
- if (!cbd->bSeparator && hwndBtn) {
- SendMessage(hwndBtn, BUTTONSETASFLATBTN, TRUE, 0);
- SendMessage(hwndBtn, BUTTONSETASTHEMEDBTN, isThemed != 0, 0);
- if (cbd->hIcon)
- SendMessage(hwndBtn, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Skin_GetIconByHandle(cbd->hIcon));
- if (cbd->ptszTooltip)
- SendMessage(hwndBtn, BUTTONADDTOOLTIP, (WPARAM)TranslateTS(cbd->ptszTooltip), BATF_TCHAR);
- SendMessage(hwndBtn, BUTTONSETCONTAINER, (LPARAM)dat->pContainer, 0);
- SendMessage(hwndBtn, BUTTONSETASTOOLBARBUTTON, TRUE, 0);
-
- if (hwndBtn && cbd->dwArrowCID)
- SendMessage(hwndBtn, BUTTONSETARROW, cbd->dwArrowCID, 0);
- if (hwndBtn && cbd->bPushButton)
- SendMessage(hwndBtn, BUTTONSETASPUSHBTN, TRUE, 0);
- }
- }
- else if (GetDlgItem(hdlg, cbd->dwButtonCID))
- DestroyWindow(GetDlgItem(hdlg, cbd->dwButtonCID));
-
- if (cbd->bDisabled)
- EnableWindow(hwndBtn, 0);
- if (cbd->bHidden)
- ShowWindow(hwndBtn, SW_HIDE);
-
- }
-
- hwndBtn = NULL;
-
- for (int i = 0; i < LButtonsList.getCount(); i++) {
- CustomButtonData *cbd = LButtonsList[i];
- if (((dat->bType == SESSIONTYPE_IM && cbd->bIMButton) || (dat->bType == SESSIONTYPE_CHAT && cbd->bChatButton))) {
- if (!cbd->bSeparator && !GetDlgItem(hdlg, cbd->dwButtonCID)) {
- hwndBtn = CreateWindowEx(0, _T("MButtonClass"), _T(""), WS_CHILD | WS_VISIBLE | WS_TABSTOP, 2 + lwidth, splitterY,
- cbd->iButtonWidth, DPISCALEY_S(22), hdlg, (HMENU)cbd->dwButtonCID, g_hInst, NULL);
- CustomizeButton(hwndBtn);
- }
- if (!cbd->bHidden)
- lwidth += cbd->iButtonWidth + gap;
- if (!cbd->bHidden && !cbd->bCanBeHidden)
- dat->iButtonBarReallyNeeds += cbd->iButtonWidth + gap;
- if (!cbd->bSeparator && hwndBtn) {
- SendMessage(hwndBtn, BUTTONSETASFLATBTN, TRUE, 0);
- SendMessage(hwndBtn, BUTTONSETASTHEMEDBTN, isThemed != 0, 0);
- if (cbd->hIcon)
- SendMessage(hwndBtn, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Skin_GetIconByHandle(cbd->hIcon));
- if (cbd->ptszTooltip)
- SendMessage(hwndBtn, BUTTONADDTOOLTIP, (WPARAM)TranslateTS(cbd->ptszTooltip), BATF_TCHAR);
- SendMessage(hwndBtn, BUTTONSETCONTAINER, (LPARAM)dat->pContainer, 0);
- SendMessage(hwndBtn, BUTTONSETASTOOLBARBUTTON, TRUE, 0);
-
- if (hwndBtn && cbd->dwArrowCID)
- SendMessage(hwndBtn, BUTTONSETARROW, cbd->dwArrowCID, 0);
- if (hwndBtn && cbd->bPushButton)
- SendMessage(hwndBtn, BUTTONSETASPUSHBTN, TRUE, 0);
- }
- }
- else if (GetDlgItem(hdlg, cbd->dwButtonCID))
- DestroyWindow(GetDlgItem(hdlg, cbd->dwButtonCID));
-
- if (cbd->bDisabled)
- EnableWindow(hwndBtn, 0);
- if (cbd->bHidden)
- ShowWindow(hwndBtn, SW_HIDE);
- }
-
- dat->bbLSideWidth = lwidth;
- dat->bbRSideWidth = rwidth;
-}
-
-void TSAPI BB_RedrawButtons(TWindowData *dat)
-{
- for (int i = 0; i < LButtonsList.getCount(); i++) {
- CustomButtonData *cbd = LButtonsList[i];
- HWND hwnd = GetDlgItem(dat->hwnd, cbd->dwButtonCID);
- if (hwnd)
- InvalidateRect(hwnd, 0, TRUE);
- }
-
- for (int i = 0; i < RButtonsList.getCount(); i++) {
- CustomButtonData *cbd = RButtonsList[i];
- HWND hwnd = GetDlgItem(dat->hwnd, cbd->dwButtonCID);
- if (hwnd)
- InvalidateRect(hwnd, 0, TRUE);
- }
-
- HWND hwndToggleSideBar = GetDlgItem(dat->hwnd, dat->bType == SESSIONTYPE_IM ? IDC_TOGGLESIDEBAR : IDC_CHAT_TOGGLESIDEBAR);
- if (hwndToggleSideBar && IsWindow(hwndToggleSideBar))
- InvalidateRect(hwndToggleSideBar, 0, TRUE);
-}
-
-BOOL TSAPI BB_SetButtonsPos(TWindowData *dat)
-{
-
- if (!dat || !IsWindowVisible(dat->hwnd))
- return 0;
-
- HWND hwnd = dat->hwnd;
- RECT rect;
- int i;
- HWND hwndBtn = 0;
-
- BYTE gap = DPISCALEX_S(PluginConfig.m_iButtonsBarGap);
- bool showToolbar = !(dat->pContainer->dwFlags & CNT_HIDETOOLBAR);
- bool bBottomToolbar = (dat->pContainer->dwFlags & CNT_BOTTOMTOOLBAR) != 0;
-
- HWND hwndToggleSideBar = GetDlgItem(hwnd, dat->bType == SESSIONTYPE_IM ? IDC_TOGGLESIDEBAR : IDC_CHAT_TOGGLESIDEBAR);
- ShowWindow(hwndToggleSideBar, (showToolbar && dat->pContainer->SideBar->isActive()) ? SW_SHOW : SW_HIDE);
-
- HDWP hdwp = BeginDeferWindowPos(LButtonsList.getCount() + RButtonsList.getCount() + 1);
-
- mir_cslock lck(ToolBarCS);
-
- RECT rcSplitter;
- GetWindowRect(GetDlgItem(hwnd, (dat->bType == SESSIONTYPE_IM) ? IDC_SPLITTER : IDC_SPLITTERY), &rcSplitter);
-
- POINT ptSplitter = { 0, rcSplitter.top };
- ScreenToClient(hwnd, &ptSplitter);
-
- GetClientRect(hwnd, &rect);
-
- int splitterY = (!bBottomToolbar) ? ptSplitter.y - DPISCALEY_S(1) : rect.bottom;
- int tempL = dat->bbLSideWidth, tempR = dat->bbRSideWidth;
- int lwidth = 0, rwidth = 0;
- int iOff = DPISCALEY_S((PluginConfig.m_DPIscaleY > 1.0) ? (dat->bType == SESSIONTYPE_IM ? 22 : 23) : 22);
-
- int foravatar = 0;
- if ((rect.bottom - ptSplitter.y - (rcSplitter.bottom - rcSplitter.top) /*- DPISCALEY(2)*/ - (bBottomToolbar ? DPISCALEY_S(24) : 0) < dat->pic.cy - DPISCALEY_S(2)) && dat->bShowAvatar && !PluginConfig.m_bAlwaysFullToolbarWidth)
- foravatar = dat->pic.cx + gap;
-
- if ((dat->pContainer->dwFlags & CNT_SIDEBAR) && (dat->pContainer->SideBar->getFlags() & CSideBar::SIDEBARORIENTATION_LEFT)) {
- if (NULL != hwndToggleSideBar) /* Wine fix. */
- hdwp = DeferWindowPos(hdwp, hwndToggleSideBar, NULL, 4, 2 + splitterY - iOff, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
- lwidth += 10;
- tempL -= 10;
- }
-
- for (i = 0; i < LButtonsList.getCount(); i++) {
- CustomButtonData *cbd = LButtonsList[i];
- if (((dat->bType == SESSIONTYPE_IM) && cbd->bIMButton) || ((dat->bType == SESSIONTYPE_CHAT) && cbd->bChatButton)) {
- hwndBtn = GetDlgItem(hwnd, cbd->dwButtonCID);
-
- if (!showToolbar) {
- ShowWindow(hwndBtn, SW_HIDE);
- if (NULL != hwndBtn) /* Wine fix. */
- hdwp = DeferWindowPos(hdwp, hwndBtn, NULL, lwidth, splitterY - iOff, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
- if (IsWindowVisible(hwndBtn) || (cbd->bSeparator && !(cbd->bAutoHidden || cbd->bHidden)))
- lwidth += cbd->iButtonWidth + gap;
- if (!IsWindowEnabled(hwndBtn) && !IsWindowVisible(hwndBtn) && !cbd->bAutoHidden)
- cbd->bAutoHidden = 1;
- continue;
- }
- if (!cbd->bCanBeHidden && !cbd->bHidden && !(!IsWindowEnabled(hwndBtn) && !IsWindowVisible(hwndBtn) && !cbd->bAutoHidden)) {
- ShowWindow(hwndBtn, SW_SHOW);
- cbd->bAutoHidden = 0;
- }
-
- if (!cbd->bSeparator && !IsWindowVisible(hwndBtn) && !IsWindowEnabled(hwndBtn) && !cbd->bAutoHidden)
- tempL -= cbd->iButtonWidth + gap;
-
- if (cbd->bCanBeHidden && !cbd->bHidden && (cbd->bSeparator || !((!IsWindowEnabled(hwndBtn) && !IsWindowVisible(hwndBtn)) && !cbd->bAutoHidden))) {
- if (tempL + tempR > (rect.right - foravatar)) {
- ShowWindow(hwndBtn, SW_HIDE);
- cbd->bAutoHidden = 1;
- tempL -= cbd->iButtonWidth + gap;
- }
- else if (cbd->bAutoHidden) {
- ShowWindow(hwndBtn, SW_SHOW);
- cbd->bAutoHidden = 0;
- }
- }
- if (NULL != hwndBtn) /* Wine fix. */
- hdwp = DeferWindowPos(hdwp, hwndBtn, NULL, lwidth, splitterY - iOff, 0, 0, SWP_NOZORDER | SWP_NOSIZE);// SWP_NOCOPYBITS);
- if (IsWindowVisible(hwndBtn) || (cbd->bSeparator && !(cbd->bAutoHidden || cbd->bHidden)))
- lwidth += cbd->iButtonWidth + gap;
- }
- }
-
- if ((dat->pContainer->dwFlags & CNT_SIDEBAR) && (dat->pContainer->SideBar->getFlags() & CSideBar::SIDEBARORIENTATION_RIGHT)) {
- if (NULL != hwndToggleSideBar) /* Wine fix. */
- hdwp = DeferWindowPos(hdwp, hwndToggleSideBar, NULL, rect.right - foravatar - 10, 2 + splitterY - iOff, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
- rwidth += 12;
- tempR -= 12;
- }
-
- for (i = 0; i < RButtonsList.getCount(); i++) {
- CustomButtonData *cbd = RButtonsList[i];
- if (((dat->bType == SESSIONTYPE_IM) && cbd->bIMButton) || ((dat->bType == SESSIONTYPE_CHAT) && cbd->bChatButton)) {
- hwndBtn = GetDlgItem(hwnd, cbd->dwButtonCID);
-
- if (!showToolbar) {
- ShowWindow(hwndBtn, SW_HIDE);
- if (IsWindowVisible(hwndBtn) || (cbd->bSeparator && !(cbd->bAutoHidden || cbd->bHidden)))
- rwidth += cbd->iButtonWidth + gap;
- if (NULL != hwndBtn) /* Wine fix. */
- hdwp = DeferWindowPos(hdwp, hwndBtn, NULL, rect.right - foravatar - rwidth + gap, splitterY - iOff, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
- if (!IsWindowEnabled(hwndBtn) && !IsWindowVisible(hwndBtn) && !cbd->bAutoHidden)
- cbd->bAutoHidden = 1;
- continue;
- }
- if (!cbd->bCanBeHidden && !cbd->bHidden && !((!IsWindowEnabled(hwndBtn) && !IsWindowVisible(hwndBtn)) && !cbd->bAutoHidden)) {
- ShowWindow(hwndBtn, SW_SHOW);
- cbd->bAutoHidden = 0;
- }
-
- if (!cbd->bSeparator && !IsWindowVisible(hwndBtn) && !IsWindowEnabled(hwndBtn) && !cbd->bAutoHidden)
- tempR -= cbd->iButtonWidth + gap;
-
- if (cbd->bCanBeHidden && !cbd->bHidden && (cbd->bSeparator || !((!IsWindowEnabled(hwndBtn) && !IsWindowVisible(hwndBtn)) && !cbd->bAutoHidden))) {
- if (tempL + tempR > (rect.right - foravatar)) {
- ShowWindow(hwndBtn, SW_HIDE);
- cbd->bAutoHidden = 1;
- tempR -= cbd->iButtonWidth + gap;
- }
- else if (cbd->bAutoHidden) {
- ShowWindow(hwndBtn, SW_SHOW);
- cbd->bAutoHidden = 0;
- }
- }
-
- if (IsWindowVisible(hwndBtn) || (cbd->bSeparator && !(cbd->bAutoHidden || cbd->bHidden)))
- rwidth += cbd->iButtonWidth + gap;
- if (NULL != hwndBtn) /* Wine fix. */
- hdwp = DeferWindowPos(hdwp, hwndBtn, NULL, rect.right - foravatar - rwidth + gap, splitterY - iOff, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
- }
- }
- return EndDeferWindowPos(hdwp);
-}
-
-void TSAPI BB_CustomButtonClick(TWindowData *dat, DWORD idFrom, HWND hwndFrom, BOOL code)
-{
- RECT rc;
- int i;
- BOOL bFromArrow = 0;
- CustomButtonClickData cbcd = { 0 };
-
- GetWindowRect(hwndFrom, &rc);
- cbcd.pt.x = rc.left;
- cbcd.pt.y = rc.bottom;
-
- for (i = 0; i < LButtonsList.getCount(); i++) {
- CustomButtonData* cbd = LButtonsList[i];
- if (cbd->dwButtonCID == idFrom) {
- cbcd.pszModule = cbd->pszModuleName;
- cbcd.dwButtonId = cbd->dwButtonOrigID;
- }
- else if (cbd->dwArrowCID == idFrom) {
- bFromArrow = 1;
- cbcd.pszModule = cbd->pszModuleName;
- cbcd.dwButtonId = cbd->dwButtonOrigID;
- }
- }
-
- if (!cbcd.pszModule)
- for (i = 0; i < RButtonsList.getCount(); i++) {
- CustomButtonData* cbd = RButtonsList[i];
- if (cbd->dwButtonCID == idFrom) {
- cbcd.pszModule = cbd->pszModuleName;
- cbcd.dwButtonId = cbd->dwButtonOrigID;
- }
- else if (cbd->dwArrowCID == idFrom) {
- bFromArrow = 1;
- cbcd.pszModule = cbd->pszModuleName;
- cbcd.dwButtonId = cbd->dwButtonOrigID;
- }
- }
-
- cbcd.cbSize = sizeof(CustomButtonClickData);
- cbcd.hwndFrom = dat->hwnd;
- cbcd.hContact = dat->hContact;
- cbcd.flags = (code ? BBCF_RIGHTBUTTON : 0) | (GetKeyState(VK_SHIFT) & 0x8000 ? BBCF_SHIFTPRESSED : 0) | (GetKeyState(VK_CONTROL) & 0x8000 ? BBCF_CONTROLPRESSED : 0) | (bFromArrow ? BBCF_ARROWCLICKED : 0);
-
- NotifyEventHooks(hHookButtonPressedEvt, dat->hContact, (LPARAM)&cbcd);
-}
-
-
-void CB_GetButtonSettings(MCONTACT hContact, CustomButtonData *cbd)
-{
- DBVARIANT dbv = { 0 };
- char SettingName[1024];
- char* token = NULL;
-
- //modulename_buttonID, position_inIM_inCHAT_isLSide_isRSide_CanBeHidden
-
- mir_snprintf(SettingName, SIZEOF(SettingName), "%s_%d", cbd->pszModuleName, cbd->dwButtonOrigID);
-
- if (!db_get_s(hContact, "TabSRMM_Toolbar", SettingName, &dbv)) {
- token = strtok(dbv.pszVal, "_");
- cbd->dwPosition = (DWORD)atoi(token);
- token = strtok(NULL, "_");
- cbd->bIMButton = atoi(token) != 0;
- token = strtok(NULL, "_");
- cbd->bChatButton = atoi(token) != 0;
- token = strtok(NULL, "_");
- cbd->bLSided = atoi(token) != 0;
- token = strtok(NULL, "_");
- cbd->bRSided = atoi(token) != 0;
- token = strtok(NULL, "_");
- cbd->bCanBeHidden = atoi(token) != 0;
-
- db_free(&dbv);
- }
-}
-
-void CB_WriteButtonSettings(MCONTACT hContact, CustomButtonData *cbd)
-{
- char SettingName[1024];
- char SettingParameter[1024];
-
- //modulename_buttonID, position_inIM_inCHAT_isLSide_isRSide_CanBeHidden
-
- mir_snprintf(SettingName, SIZEOF(SettingName), "%s_%d", cbd->pszModuleName, cbd->dwButtonOrigID);
- mir_snprintf(SettingParameter, SIZEOF(SettingParameter), "%d_%u_%u_%u_%u_%u", cbd->dwPosition, cbd->bIMButton, cbd->bChatButton, cbd->bLSided, cbd->bRSided, cbd->bCanBeHidden);
- if (!(cbd->opFlags & BBSF_NTBDESTRUCT))
- db_set_s(hContact, "TabSRMM_Toolbar", SettingName, SettingParameter);
- else
- db_unset(hContact, "TabSRMM_Toolbar", SettingName);
-}
-
-void BB_RegisterSeparators()
+static void BB_RegisterSeparators()
{
BBButton bbd = { 0 };
DWORD i = 0;
@@ -788,193 +356,6 @@ void BB_RegisterSeparators()
}
}
-void BB_RefreshTheme(const TWindowData *dat)
-{
- for (int i = 0; i < RButtonsList.getCount(); i++) {
- CustomButtonData* cbd = RButtonsList[i];
- SendDlgItemMessage(dat->hwnd, cbd->dwButtonCID, WM_THEMECHANGED, 0, 0);
- }
- for (int i = 0; i < LButtonsList.getCount(); i++) {
- CustomButtonData* cbd = LButtonsList[i];
- SendDlgItemMessage(dat->hwnd, cbd->dwButtonCID, WM_THEMECHANGED, 0, 0);
- }
-}
-
-void CB_InitDefaultButtons()
-{
- BBButton bbd = { 0 };
- bbd.cbSize = sizeof(BBButton);
- bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISLSIDEBUTTON | BBBF_ISARROWBUTTON | BBBF_CREATEBYID;
- bbd.dwButtonID = IDC_PROTOCOL;
- bbd.dwDefPos = 10;
- bbd.hIcon = LoadSkinnedIconHandle(SKINICON_OTHER_CONNECTING);
- bbd.pszModuleName = "Tabsrmm";
- bbd.ptszTooltip = LPGENT("Protocol button");
- CB_AddButton(0, (LPARAM)&bbd);
-
- bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISLSIDEBUTTON | BBBF_ISARROWBUTTON | BBBF_CREATEBYID;
- bbd.dwButtonID = IDC_NAME;
- bbd.dwDefPos = 20;
- bbd.hIcon = PluginConfig.g_buttonBarIconHandles[20];
- bbd.ptszTooltip = LPGENT("Info button");
- CB_AddButton(0, (LPARAM)&bbd);
-
- if (PluginConfig.g_SmileyAddAvail) {
- bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON | BBBF_ISLSIDEBUTTON | BBBF_CREATEBYID;
- bbd.dwButtonID = IDC_SMILEYBTN;
- bbd.iButtonWidth = 0;
- bbd.dwDefPos = 30;
- bbd.hIcon = PluginConfig.g_buttonBarIconHandles[9];
- bbd.ptszTooltip = LPGENT("Insert emoticon");
- CB_AddButton(0, (LPARAM)&bbd);
- }
-
- bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON | BBBF_ISLSIDEBUTTON | BBBF_ISPUSHBUTTON | BBBF_CANBEHIDDEN | BBBF_CREATEBYID;
- bbd.dwButtonID = IDC_FONTBOLD;
- bbd.dwDefPos = 40;
- bbd.hIcon = PluginConfig.g_buttonBarIconHandles[10];
- bbd.ptszTooltip = LPGENT("Bold text");
- CB_AddButton(0, (LPARAM)&bbd);
-
- bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON | BBBF_ISLSIDEBUTTON | BBBF_ISPUSHBUTTON | BBBF_CANBEHIDDEN | BBBF_CREATEBYID;
- bbd.dwButtonID = IDC_FONTITALIC;
- bbd.dwDefPos = 50;
- bbd.hIcon = PluginConfig.g_buttonBarIconHandles[11];
- bbd.ptszTooltip = LPGENT("Italic text");
- CB_AddButton(0, (LPARAM)&bbd);
-
- bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON | BBBF_ISLSIDEBUTTON | BBBF_ISPUSHBUTTON | BBBF_CANBEHIDDEN | BBBF_CREATEBYID;
- bbd.dwButtonID = IDC_FONTUNDERLINE;
- bbd.dwDefPos = 60;
- bbd.hIcon = PluginConfig.g_buttonBarIconHandles[12];
- bbd.ptszTooltip = LPGENT("Underlined text");
- CB_AddButton(0, (LPARAM)&bbd);
-
- bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISLSIDEBUTTON | BBBF_ISPUSHBUTTON | BBBF_CANBEHIDDEN | BBBF_CREATEBYID;
- bbd.dwButtonID = IDC_FONTSTRIKEOUT;
- bbd.dwDefPos = 70;
- bbd.hIcon = PluginConfig.g_buttonBarIconHandles[15];
- bbd.ptszTooltip = LPGENT("Strike-through text");
- CB_AddButton(0, (LPARAM)&bbd);
-
- bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON | BBBF_ISLSIDEBUTTON | BBBF_CANBEHIDDEN | BBBF_CREATEBYID;
- bbd.dwButtonID = IDC_FONTFACE;
- bbd.dwDefPos = 80;
- bbd.hIcon = PluginConfig.g_buttonBarIconHandles[14];
- bbd.ptszTooltip = LPGENT("Select font color");
- CB_AddButton(0, (LPARAM)&bbd);
-
- bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON | BBBF_ISRSIDEBUTTON | BBBF_ISARROWBUTTON | BBBF_CREATEBYID;
- bbd.dwButtonID = IDOK;
- bbd.dwDefPos = 10;
- bbd.iButtonWidth = 51;
- bbd.hIcon = PluginConfig.g_buttonBarIconHandles[6];
- bbd.ptszTooltip = LPGENT("Send message\nClick dropdown arrow for sending options");
- CB_AddButton(0, (LPARAM)&bbd);
-
- bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON | BBBF_ISRSIDEBUTTON | BBBF_CREATEBYID;
- bbd.dwButtonID = IDC_SAVE;
- bbd.dwDefPos = 20;
- bbd.iButtonWidth = 0;
- bbd.hIcon = PluginConfig.g_buttonBarIconHandles[8];
- bbd.ptszTooltip = LPGENT("Close session");
- CB_AddButton(0, (LPARAM)&bbd);
-
- bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISRSIDEBUTTON | BBBF_CREATEBYID;
- bbd.dwButtonID = IDC_QUOTE;
- bbd.dwDefPos = 30;
- bbd.iButtonWidth = 0;
- bbd.hIcon = PluginConfig.g_buttonBarIconHandles[4];
- bbd.ptszTooltip = LPGENT("Quote last message OR selected text");
- CB_AddButton(0, (LPARAM)&bbd);
-
- bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISRSIDEBUTTON | BBBF_CREATEBYID;
- bbd.dwButtonID = IDC_TIME;
- bbd.dwDefPos = 40;
- bbd.iButtonWidth = 0;
- bbd.hIcon = PluginConfig.g_buttonBarIconHandles[2];
- bbd.ptszTooltip = LPGENT("Message log options");
- CB_AddButton(0, (LPARAM)&bbd);
-
- bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON | BBBF_ISRSIDEBUTTON | BBBF_CREATEBYID;
- bbd.dwButtonID = IDC_HISTORY;
- bbd.dwDefPos = 50;
- bbd.iButtonWidth = 0;
- bbd.hIcon = PluginConfig.g_buttonBarIconHandles[0];
- bbd.ptszTooltip = LPGENT("View user's history");
- CB_AddButton(0, (LPARAM)&bbd);
-
- bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISRSIDEBUTTON | BBBF_CREATEBYID;
- bbd.dwButtonID = IDC_PIC;
- bbd.dwDefPos = 60;
- bbd.iButtonWidth = 0;
- bbd.hIcon = PluginConfig.g_buttonBarIconHandles[7];
- bbd.ptszTooltip = LPGENT("Edit user notes");
- CB_AddButton(0, (LPARAM)&bbd);
-
- //chat buttons
-
- bbd.bbbFlags = BBBF_ISCHATBUTTON | BBBF_ISLSIDEBUTTON | BBBF_ISDUMMYBUTTON;
- bbd.dwButtonID = 1;
- bbd.pszModuleName = "tb_splitter";
- bbd.dwDefPos = 31;
- bbd.iButtonWidth = 22;
- bbd.hIcon = 0;
- bbd.pszTooltip = 0;
- CB_AddButton(0, (LPARAM)&bbd);
-
- bbd.bbbFlags = BBBF_ISCHATBUTTON | BBBF_ISLSIDEBUTTON | BBBF_ISDUMMYBUTTON;
- bbd.dwButtonID = 2;
- bbd.dwDefPos = 22;
- bbd.iButtonWidth = 22;
- bbd.hIcon = 0;
- bbd.pszTooltip = 0;
- CB_AddButton(0, (LPARAM)&bbd);
-
- bbd.bbbFlags = BBBF_ISCHATBUTTON | BBBF_ISLSIDEBUTTON | BBBF_ISDUMMYBUTTON;
- bbd.dwButtonID = 3;
- bbd.dwDefPos = 71;
- bbd.iButtonWidth = 22;
- bbd.hIcon = 0;
- bbd.pszTooltip = 0;
- CB_AddButton(0, (LPARAM)&bbd);
-
- bbd.bbbFlags = BBBF_ISCHATBUTTON | BBBF_ISLSIDEBUTTON | BBBF_ISPUSHBUTTON | BBBF_CREATEBYID;
- bbd.dwButtonID = IDC_BKGCOLOR;
- bbd.pszModuleName = "Tabsrmm";
- bbd.dwDefPos = 81;
- bbd.iButtonWidth = 22;
- bbd.hIcon = PluginConfig.g_buttonBarIconHandles[16];
- bbd.ptszTooltip = LPGENT("Change background color");
- CB_AddButton(0, (LPARAM)&bbd);
-
- bbd.bbbFlags = BBBF_ISCHATBUTTON | BBBF_ISRSIDEBUTTON | BBBF_CREATEBYID;
- bbd.dwButtonID = IDC_SHOWNICKLIST;
- bbd.dwDefPos = 22;
- bbd.iButtonWidth = 22;
- bbd.hIcon = PluginConfig.g_buttonBarIconHandles[19];
- bbd.ptszTooltip = LPGENT("Toggle nick list");
- CB_AddButton(0, (LPARAM)&bbd);
-
- bbd.bbbFlags = BBBF_ISCHATBUTTON | BBBF_ISRSIDEBUTTON | BBBF_CREATEBYID;
- bbd.dwButtonID = IDC_FILTER;
- bbd.dwDefPos = 24;
- bbd.iButtonWidth = 22;
- bbd.hIcon = PluginConfig.g_buttonBarIconHandles[18];
- bbd.ptszTooltip = LPGENT("Event filter - right click to setup, left click to activate/deactivate");
- CB_AddButton(0, (LPARAM)&bbd);
-
- bbd.bbbFlags = BBBF_ISCHATBUTTON | BBBF_ISRSIDEBUTTON | BBBF_CREATEBYID;
- bbd.dwButtonID = IDC_CHANMGR;
- bbd.dwDefPos = 33;
- bbd.iButtonWidth = 22;
- bbd.hIcon = PluginConfig.g_buttonBarIconHandles[17];
- bbd.ptszTooltip = LPGENT("Channel manager");
- CB_AddButton(0, (LPARAM)&bbd);
-
- BB_RegisterSeparators();
-}
-
#define MIDDLE_SEPARATOR _T(">-------M-------<")
static int SaveTree(HWND hToolBarTree)
@@ -990,7 +371,7 @@ static int SaveTree(HWND hToolBarTree)
tvi.pszText = strbuf;
tvi.cchTextMax = SIZEOF(strbuf);
{
- mir_cslock lck(ToolBarCS);
+ mir_cslock lck(csToolBar);
while (tvi.hItem != NULL) {
TreeView_GetItem(hToolBarTree, &tvi);
@@ -1003,47 +384,47 @@ static int SaveTree(HWND hToolBarTree)
}
CustomButtonData *cbd = (CustomButtonData*)tvi.lParam;
if (cbd) {
- if (cbd->opFlags) {
- cbd->bIMButton = (cbd->opFlags & BBSF_IMBUTTON) != 0;
- cbd->bChatButton = (cbd->opFlags & BBSF_CHATBUTTON) != 0;
- cbd->bCanBeHidden = (cbd->opFlags & BBSF_CANBEHIDDEN) != 0;
+ if (cbd->m_opFlags) {
+ cbd->m_bIMButton = (cbd->m_opFlags & BBSF_IMBUTTON) != 0;
+ cbd->m_bChatButton = (cbd->m_opFlags & BBSF_CHATBUTTON) != 0;
+ cbd->m_bCanBeHidden = (cbd->m_opFlags & BBSF_CANBEHIDDEN) != 0;
}
- if (RSide && cbd->bLSided) {
- cbd->bLSided = false;
- cbd->bRSided = true;
- cbd->opFlags |= BBSF_NTBSWAPED;
+ if (RSide && cbd->m_bLSided) {
+ cbd->m_bLSided = false;
+ cbd->m_bRSided = true;
+ cbd->m_opFlags |= BBSF_NTBSWAPED;
}
- else if (!RSide && cbd->bRSided) {
- cbd->bLSided = true;
- cbd->bRSided = false;
- cbd->opFlags |= BBSF_NTBSWAPED;
+ else if (!RSide && cbd->m_bRSided) {
+ cbd->m_bLSided = true;
+ cbd->m_bRSided = false;
+ cbd->m_opFlags |= BBSF_NTBSWAPED;
}
if (!TreeView_GetCheckState(hToolBarTree, tvi.hItem)) {
- cbd->bIMButton = false;
- cbd->bChatButton = false;
+ cbd->m_bIMButton = false;
+ cbd->m_bChatButton = false;
- if (cbd->bSeparator && !strcmp(cbd->pszModuleName, "Tabsrmm_sep"))
- cbd->opFlags = BBSF_NTBDESTRUCT;
+ if (cbd->m_bSeparator && !strcmp(cbd->m_pszModuleName, "Tabsrmm_sep"))
+ cbd->m_opFlags = BBSF_NTBDESTRUCT;
}
else {
- if (!cbd->bIMButton && !cbd->bChatButton)
- cbd->bIMButton = true;
- if (cbd->bSeparator && !strcmp(cbd->pszModuleName, "Tabsrmm_sep")) {
- cbd->bHidden = 0;
- cbd->opFlags &= ~BBSF_NTBDESTRUCT;
+ if (!cbd->m_bIMButton && !cbd->m_bChatButton)
+ cbd->m_bIMButton = true;
+ if (cbd->m_bSeparator && !strcmp(cbd->m_pszModuleName, "Tabsrmm_sep")) {
+ cbd->m_bHidden = 0;
+ cbd->m_opFlags &= ~BBSF_NTBDESTRUCT;
++loc_sepcout;
}
}
- cbd->dwPosition = (DWORD)count;
+ cbd->m_dwPosition = (DWORD)count;
CB_WriteButtonSettings(NULL, cbd);
- if (!(cbd->opFlags & BBSF_NTBDESTRUCT))
+ if (!(cbd->m_opFlags & BBSF_NTBDESTRUCT))
(RSide) ? (count -= 10) : (count += 10);
}
HTREEITEM hItem = TreeView_GetNextSibling(hToolBarTree, tvi.hItem);
- if (cbd->opFlags & BBSF_NTBDESTRUCT)
+ if (cbd->m_opFlags & BBSF_NTBDESTRUCT)
TreeView_DeleteItem(hToolBarTree, tvi.hItem);
tvi.hItem = hItem;
}
@@ -1078,25 +459,25 @@ static int BuildMenuObjectsTree(HWND hToolBarTree)
if ((RButtonsList.getCount() + LButtonsList.getCount()) == 0)
return FALSE;
- mir_cslock lck(ToolBarCS);
+ mir_cslock lck(csToolBar);
for (int i = 0; i < LButtonsList.getCount(); i++) {
CustomButtonData *cbd = LButtonsList[i];
tvis.item.lParam = (LPARAM)cbd;
- if (cbd->bSeparator) {
+ if (cbd->m_bSeparator) {
tvis.item.pszText = TranslateT("<Separator>");
tvis.item.iImage = tvis.item.iSelectedImage = 0;
}
else {
- tvis.item.pszText = TranslateTS(cbd->ptszTooltip);
- iImage = ImageList_AddIcon(himgl, Skin_GetIconByHandle(cbd->hIcon));
+ tvis.item.pszText = TranslateTS(cbd->m_ptszTooltip);
+ iImage = ImageList_AddIcon(himgl, Skin_GetIconByHandle(cbd->m_hIcon));
tvis.item.iImage = tvis.item.iSelectedImage = iImage;
}
- cbd->opFlags = 0;
+ cbd->m_opFlags = 0;
hti = TreeView_InsertItem(hToolBarTree, &tvis);
- TreeView_SetCheckState(hToolBarTree, hti, (cbd->bIMButton || cbd->bChatButton));
+ TreeView_SetCheckState(hToolBarTree, hti, (cbd->m_bIMButton || cbd->m_bChatButton));
}
tvis.item.lParam = 0;
@@ -1112,25 +493,24 @@ static int BuildMenuObjectsTree(HWND hToolBarTree)
CustomButtonData *cbd = RButtonsList[i];
tvis.item.lParam = (LPARAM)cbd;
- if (cbd->bSeparator) {
+ if (cbd->m_bSeparator) {
tvis.item.pszText = TranslateT("<Separator>");
tvis.item.iImage = tvis.item.iSelectedImage = -1;
}
else {
- tvis.item.pszText = TranslateTS(cbd->ptszTooltip);
- iImage = ImageList_AddIcon(himgl, Skin_GetIconByHandle(cbd->hIcon));
+ tvis.item.pszText = TranslateTS(cbd->m_ptszTooltip);
+ iImage = ImageList_AddIcon(himgl, Skin_GetIconByHandle(cbd->m_hIcon));
tvis.item.iImage = tvis.item.iSelectedImage = iImage;
}
tvis.item.state = 0;
- cbd->opFlags = 0;
+ cbd->m_opFlags = 0;
hti = TreeView_InsertItem(hToolBarTree, &tvis);
- TreeView_SetCheckState(hToolBarTree, hti, (cbd->bIMButton || cbd->bChatButton));
+ TreeView_SetCheckState(hToolBarTree, hti, (cbd->m_bIMButton || cbd->m_bChatButton));
}
return 1;
}
-
BOOL drag = FALSE, bOptionsInit = TRUE;
HANDLE hDragItem = NULL;
HWND hToolBarTree = NULL;
@@ -1151,7 +531,7 @@ INT_PTR CALLBACK DlgProcToolBar(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
SetWindowLongPtr(hToolBarTree, GWL_STYLE, style);
}
{
- mir_cslock lck(ToolBarCS);
+ mir_cslock lck(csToolBar);
BuildMenuObjectsTree(hToolBarTree);
}
@@ -1249,11 +629,11 @@ INT_PTR CALLBACK DlgProcToolBar(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
hti = TVI_FIRST;
CustomButtonData *cbd = new CustomButtonData();
- cbd->bSeparator = cbd->bHidden = cbd->bIMButton = cbd->bLSided = true;
- cbd->dwButtonOrigID = ++dwSepCount;
- cbd->pszModuleName = "Tabsrmm_sep";
- cbd->iButtonWidth = 22;
- cbd->opFlags = BBSF_NTBDESTRUCT;
+ cbd->m_bSeparator = cbd->m_bHidden = cbd->m_bIMButton = cbd->m_bLSided = true;
+ cbd->m_dwButtonOrigID = ++dwSepCount;
+ cbd->m_pszModuleName = "Tabsrmm_sep";
+ cbd->m_iButtonWidth = 22;
+ cbd->m_opFlags = BBSF_NTBDESTRUCT;
LButtonsList.insert(cbd);
TVINSERTSTRUCT tvis;
@@ -1266,7 +646,7 @@ INT_PTR CALLBACK DlgProcToolBar(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
tvis.item.lParam = (LPARAM)cbd;
hti = TreeView_InsertItem(hToolBarTree, &tvis);
- TreeView_SetCheckState(hToolBarTree, hti, (cbd->bIMButton || cbd->bChatButton));
+ TreeView_SetCheckState(hToolBarTree, hti, (cbd->m_bIMButton || cbd->m_bChatButton));
}
break;
@@ -1290,9 +670,9 @@ INT_PTR CALLBACK DlgProcToolBar(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
if (tvi.lParam) {
CustomButtonData *cbd = (CustomButtonData*)tvi.lParam;
if (cbd) {
- cbd->bIMButton = IsDlgButtonChecked(hwndDlg, IDC_IMCHECK) != 0;
- cbd->bChatButton = IsDlgButtonChecked(hwndDlg, IDC_CHATCHECK) != 0;
- cbd->bCanBeHidden = IsDlgButtonChecked(hwndDlg, IDC_CANBEHIDDEN) != 0;
+ cbd->m_bIMButton = IsDlgButtonChecked(hwndDlg, IDC_IMCHECK) != 0;
+ cbd->m_bChatButton = IsDlgButtonChecked(hwndDlg, IDC_CHATCHECK) != 0;
+ cbd->m_bCanBeHidden = IsDlgButtonChecked(hwndDlg, IDC_CANBEHIDDEN) != 0;
}
}
}
@@ -1342,13 +722,13 @@ INT_PTR CALLBACK DlgProcToolBar(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
CustomButtonData *cbd = (CustomButtonData*)tvi.lParam;
if (cbd) {
- cbd->opFlags = (IsDlgButtonChecked(hwndDlg, IDC_IMCHECK)) ? BBSF_IMBUTTON : 0;
- cbd->opFlags |= (IsDlgButtonChecked(hwndDlg, IDC_CHATCHECK)) ? BBSF_CHATBUTTON : 0;
- cbd->opFlags |= (IsDlgButtonChecked(hwndDlg, IDC_CANBEHIDDEN)) ? BBSF_CANBEHIDDEN : 0;
+ cbd->m_opFlags = (IsDlgButtonChecked(hwndDlg, IDC_IMCHECK)) ? BBSF_IMBUTTON : 0;
+ cbd->m_opFlags |= (IsDlgButtonChecked(hwndDlg, IDC_CHATCHECK)) ? BBSF_CHATBUTTON : 0;
+ cbd->m_opFlags |= (IsDlgButtonChecked(hwndDlg, IDC_CANBEHIDDEN)) ? BBSF_CANBEHIDDEN : 0;
- cbd->bIMButton = IsDlgButtonChecked(hwndDlg, IDC_IMCHECK) != 0;
- cbd->bChatButton = IsDlgButtonChecked(hwndDlg, IDC_CHATCHECK) != 0;
- cbd->bCanBeHidden = IsDlgButtonChecked(hwndDlg, IDC_CANBEHIDDEN) != 0;
+ cbd->m_bIMButton = IsDlgButtonChecked(hwndDlg, IDC_IMCHECK) != 0;
+ cbd->m_bChatButton = IsDlgButtonChecked(hwndDlg, IDC_CHATCHECK) != 0;
+ cbd->m_bCanBeHidden = IsDlgButtonChecked(hwndDlg, IDC_CANBEHIDDEN) != 0;
}
}
break;
@@ -1381,9 +761,9 @@ INT_PTR CALLBACK DlgProcToolBar(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
Utils::enableDlgControl(hwndDlg, IDC_IMCHECK, true);
Utils::enableDlgControl(hwndDlg, IDC_CHATCHECK, true);
Utils::enableDlgControl(hwndDlg, IDC_CANBEHIDDEN, true);
- CheckDlgButton(hwndDlg, IDC_IMCHECK, (cbd->bIMButton) ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_CHATCHECK, (cbd->bChatButton) ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_CANBEHIDDEN, (cbd->bCanBeHidden) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_IMCHECK, (cbd->m_bIMButton) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_CHATCHECK, (cbd->m_bChatButton) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_CANBEHIDDEN, (cbd->m_bCanBeHidden) ? BST_CHECKED : BST_UNCHECKED);
}
}
break;
@@ -1423,3 +803,648 @@ INT_PTR CALLBACK DlgProcToolBar(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
return FALSE;
}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+void CustomButtonData::Accustom(HWND hwndBtn, TWindowData *dat)
+{
+ SendMessage(hwndBtn, BUTTONSETASFLATBTN, TRUE, 0);
+ SendMessage(hwndBtn, BUTTONSETASTHEMEDBTN, CSkin::IsThemed(), 0);
+ if (m_hIcon)
+ SendMessage(hwndBtn, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Skin_GetIconByHandle(m_hIcon));
+ if (m_ptszTooltip)
+ SendMessage(hwndBtn, BUTTONADDTOOLTIP, (WPARAM)TranslateTS(m_ptszTooltip), BATF_TCHAR);
+ SendMessage(hwndBtn, BUTTONSETCONTAINER, (LPARAM)dat->pContainer, 0);
+ SendMessage(hwndBtn, BUTTONSETASTOOLBARBUTTON, TRUE, 0);
+
+ if (hwndBtn) {
+ if (m_dwArrowCID) SendMessage(hwndBtn, BUTTONSETARROW, m_dwArrowCID, 0);
+ if (m_bPushButton) SendMessage(hwndBtn, BUTTONSETASPUSHBTN, TRUE, 0);
+ }
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Global functions
+
+void CB_WriteButtonSettings(MCONTACT hContact, CustomButtonData *cbd)
+{
+ char SettingName[1024];
+ char SettingParameter[1024];
+
+ //modulename_buttonID, position_inIM_inCHAT_isLSide_isRSide_CanBeHidden
+
+ mir_snprintf(SettingName, SIZEOF(SettingName), "%s_%d", cbd->m_pszModuleName, cbd->m_dwButtonOrigID);
+ mir_snprintf(SettingParameter, SIZEOF(SettingParameter), "%d_%u_%u_%u_%u_%u", cbd->m_dwPosition, cbd->m_bIMButton, cbd->m_bChatButton, cbd->m_bLSided, cbd->m_bRSided, cbd->m_bCanBeHidden);
+ if (!(cbd->m_opFlags & BBSF_NTBDESTRUCT))
+ db_set_s(hContact, "TabSRMM_Toolbar", SettingName, SettingParameter);
+ else
+ db_unset(hContact, "TabSRMM_Toolbar", SettingName);
+}
+
+void CB_InitDefaultButtons()
+{
+ BBButton bbd = { 0 };
+ bbd.cbSize = sizeof(BBButton);
+ bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISLSIDEBUTTON | BBBF_ISARROWBUTTON | BBBF_CREATEBYID;
+ bbd.dwButtonID = IDC_PROTOCOL;
+ bbd.dwDefPos = 10;
+ bbd.hIcon = LoadSkinnedIconHandle(SKINICON_OTHER_CONNECTING);
+ bbd.pszModuleName = "Tabsrmm";
+ bbd.ptszTooltip = LPGENT("Protocol button");
+ CB_AddButton(0, (LPARAM)&bbd);
+
+ bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISLSIDEBUTTON | BBBF_ISARROWBUTTON | BBBF_CREATEBYID;
+ bbd.dwButtonID = IDC_NAME;
+ bbd.dwDefPos = 20;
+ bbd.hIcon = PluginConfig.g_buttonBarIconHandles[20];
+ bbd.ptszTooltip = LPGENT("Info button");
+ CB_AddButton(0, (LPARAM)&bbd);
+
+ if (PluginConfig.g_SmileyAddAvail) {
+ bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON | BBBF_ISLSIDEBUTTON | BBBF_CREATEBYID;
+ bbd.dwButtonID = IDC_SMILEYBTN;
+ bbd.iButtonWidth = 0;
+ bbd.dwDefPos = 30;
+ bbd.hIcon = PluginConfig.g_buttonBarIconHandles[9];
+ bbd.ptszTooltip = LPGENT("Insert emoticon");
+ CB_AddButton(0, (LPARAM)&bbd);
+ }
+
+ bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON | BBBF_ISLSIDEBUTTON | BBBF_ISPUSHBUTTON | BBBF_CANBEHIDDEN | BBBF_CREATEBYID;
+ bbd.dwButtonID = IDC_FONTBOLD;
+ bbd.dwDefPos = 40;
+ bbd.hIcon = PluginConfig.g_buttonBarIconHandles[10];
+ bbd.ptszTooltip = LPGENT("Bold text");
+ CB_AddButton(0, (LPARAM)&bbd);
+
+ bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON | BBBF_ISLSIDEBUTTON | BBBF_ISPUSHBUTTON | BBBF_CANBEHIDDEN | BBBF_CREATEBYID;
+ bbd.dwButtonID = IDC_FONTITALIC;
+ bbd.dwDefPos = 50;
+ bbd.hIcon = PluginConfig.g_buttonBarIconHandles[11];
+ bbd.ptszTooltip = LPGENT("Italic text");
+ CB_AddButton(0, (LPARAM)&bbd);
+
+ bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON | BBBF_ISLSIDEBUTTON | BBBF_ISPUSHBUTTON | BBBF_CANBEHIDDEN | BBBF_CREATEBYID;
+ bbd.dwButtonID = IDC_FONTUNDERLINE;
+ bbd.dwDefPos = 60;
+ bbd.hIcon = PluginConfig.g_buttonBarIconHandles[12];
+ bbd.ptszTooltip = LPGENT("Underlined text");
+ CB_AddButton(0, (LPARAM)&bbd);
+
+ bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISLSIDEBUTTON | BBBF_ISPUSHBUTTON | BBBF_CANBEHIDDEN | BBBF_CREATEBYID;
+ bbd.dwButtonID = IDC_FONTSTRIKEOUT;
+ bbd.dwDefPos = 70;
+ bbd.hIcon = PluginConfig.g_buttonBarIconHandles[15];
+ bbd.ptszTooltip = LPGENT("Strike-through text");
+ CB_AddButton(0, (LPARAM)&bbd);
+
+ bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON | BBBF_ISLSIDEBUTTON | BBBF_CANBEHIDDEN | BBBF_CREATEBYID;
+ bbd.dwButtonID = IDC_FONTFACE;
+ bbd.dwDefPos = 80;
+ bbd.hIcon = PluginConfig.g_buttonBarIconHandles[14];
+ bbd.ptszTooltip = LPGENT("Select font color");
+ CB_AddButton(0, (LPARAM)&bbd);
+
+ bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON | BBBF_ISRSIDEBUTTON | BBBF_ISARROWBUTTON | BBBF_CREATEBYID;
+ bbd.dwButtonID = IDOK;
+ bbd.dwDefPos = 10;
+ bbd.iButtonWidth = 51;
+ bbd.hIcon = PluginConfig.g_buttonBarIconHandles[6];
+ bbd.ptszTooltip = LPGENT("Send message\nClick dropdown arrow for sending options");
+ CB_AddButton(0, (LPARAM)&bbd);
+
+ bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON | BBBF_ISRSIDEBUTTON | BBBF_CREATEBYID;
+ bbd.dwButtonID = IDC_SAVE;
+ bbd.dwDefPos = 20;
+ bbd.iButtonWidth = 0;
+ bbd.hIcon = PluginConfig.g_buttonBarIconHandles[8];
+ bbd.ptszTooltip = LPGENT("Close session");
+ CB_AddButton(0, (LPARAM)&bbd);
+
+ bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISRSIDEBUTTON | BBBF_CREATEBYID;
+ bbd.dwButtonID = IDC_QUOTE;
+ bbd.dwDefPos = 30;
+ bbd.iButtonWidth = 0;
+ bbd.hIcon = PluginConfig.g_buttonBarIconHandles[4];
+ bbd.ptszTooltip = LPGENT("Quote last message OR selected text");
+ CB_AddButton(0, (LPARAM)&bbd);
+
+ bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISRSIDEBUTTON | BBBF_CREATEBYID;
+ bbd.dwButtonID = IDC_TIME;
+ bbd.dwDefPos = 40;
+ bbd.iButtonWidth = 0;
+ bbd.hIcon = PluginConfig.g_buttonBarIconHandles[2];
+ bbd.ptszTooltip = LPGENT("Message log options");
+ CB_AddButton(0, (LPARAM)&bbd);
+
+ bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON | BBBF_ISRSIDEBUTTON | BBBF_CREATEBYID;
+ bbd.dwButtonID = IDC_HISTORY;
+ bbd.dwDefPos = 50;
+ bbd.iButtonWidth = 0;
+ bbd.hIcon = PluginConfig.g_buttonBarIconHandles[0];
+ bbd.ptszTooltip = LPGENT("View user's history");
+ CB_AddButton(0, (LPARAM)&bbd);
+
+ bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISRSIDEBUTTON | BBBF_CREATEBYID;
+ bbd.dwButtonID = IDC_PIC;
+ bbd.dwDefPos = 60;
+ bbd.iButtonWidth = 0;
+ bbd.hIcon = PluginConfig.g_buttonBarIconHandles[7];
+ bbd.ptszTooltip = LPGENT("Edit user notes");
+ CB_AddButton(0, (LPARAM)&bbd);
+
+ //chat buttons
+
+ bbd.bbbFlags = BBBF_ISCHATBUTTON | BBBF_ISLSIDEBUTTON | BBBF_ISDUMMYBUTTON;
+ bbd.dwButtonID = 1;
+ bbd.pszModuleName = "tb_splitter";
+ bbd.dwDefPos = 31;
+ bbd.iButtonWidth = 22;
+ bbd.hIcon = 0;
+ bbd.pszTooltip = 0;
+ CB_AddButton(0, (LPARAM)&bbd);
+
+ bbd.bbbFlags = BBBF_ISCHATBUTTON | BBBF_ISLSIDEBUTTON | BBBF_ISDUMMYBUTTON;
+ bbd.dwButtonID = 2;
+ bbd.dwDefPos = 22;
+ bbd.iButtonWidth = 22;
+ bbd.hIcon = 0;
+ bbd.pszTooltip = 0;
+ CB_AddButton(0, (LPARAM)&bbd);
+
+ bbd.bbbFlags = BBBF_ISCHATBUTTON | BBBF_ISLSIDEBUTTON | BBBF_ISDUMMYBUTTON;
+ bbd.dwButtonID = 3;
+ bbd.dwDefPos = 71;
+ bbd.iButtonWidth = 22;
+ bbd.hIcon = 0;
+ bbd.pszTooltip = 0;
+ CB_AddButton(0, (LPARAM)&bbd);
+
+ bbd.bbbFlags = BBBF_ISCHATBUTTON | BBBF_ISLSIDEBUTTON | BBBF_ISPUSHBUTTON | BBBF_CREATEBYID;
+ bbd.dwButtonID = IDC_BKGCOLOR;
+ bbd.pszModuleName = "Tabsrmm";
+ bbd.dwDefPos = 81;
+ bbd.iButtonWidth = 22;
+ bbd.hIcon = PluginConfig.g_buttonBarIconHandles[16];
+ bbd.ptszTooltip = LPGENT("Change background color");
+ CB_AddButton(0, (LPARAM)&bbd);
+
+ bbd.bbbFlags = BBBF_ISCHATBUTTON | BBBF_ISRSIDEBUTTON | BBBF_CREATEBYID;
+ bbd.dwButtonID = IDC_SHOWNICKLIST;
+ bbd.dwDefPos = 22;
+ bbd.iButtonWidth = 22;
+ bbd.hIcon = PluginConfig.g_buttonBarIconHandles[19];
+ bbd.ptszTooltip = LPGENT("Toggle nick list");
+ CB_AddButton(0, (LPARAM)&bbd);
+
+ bbd.bbbFlags = BBBF_ISCHATBUTTON | BBBF_ISRSIDEBUTTON | BBBF_CREATEBYID;
+ bbd.dwButtonID = IDC_FILTER;
+ bbd.dwDefPos = 24;
+ bbd.iButtonWidth = 22;
+ bbd.hIcon = PluginConfig.g_buttonBarIconHandles[18];
+ bbd.ptszTooltip = LPGENT("Event filter - right click to setup, left click to activate/deactivate");
+ CB_AddButton(0, (LPARAM)&bbd);
+
+ bbd.bbbFlags = BBBF_ISCHATBUTTON | BBBF_ISRSIDEBUTTON | BBBF_CREATEBYID;
+ bbd.dwButtonID = IDC_CHANMGR;
+ bbd.dwDefPos = 33;
+ bbd.iButtonWidth = 22;
+ bbd.hIcon = PluginConfig.g_buttonBarIconHandles[17];
+ bbd.ptszTooltip = LPGENT("Channel manager");
+ CB_AddButton(0, (LPARAM)&bbd);
+
+ BB_RegisterSeparators();
+}
+
+void CB_ReInitCustomButtons()
+{
+ for (int i = 0; i < LButtonsList.getCount();) {
+ CustomButtonData *cbd = LButtonsList[i];
+
+ if (cbd->m_opFlags & (BBSF_NTBSWAPED | BBSF_NTBDESTRUCT)) {
+ cbd->m_opFlags ^= BBSF_NTBSWAPED;
+
+ if (!(cbd->m_opFlags & BBSF_NTBDESTRUCT))
+ RButtonsList.insert(cbd);
+
+ LButtonsList.remove(i);
+ }
+ else i++;
+ }
+
+ for (int i = 0; i < RButtonsList.getCount();) {
+ CustomButtonData* cbd = RButtonsList[i];
+ if (cbd->m_opFlags & (BBSF_NTBSWAPED | BBSF_NTBDESTRUCT)) {
+ cbd->m_opFlags ^= BBSF_NTBSWAPED;
+
+ if (!(cbd->m_opFlags & BBSF_NTBDESTRUCT))
+ LButtonsList.insert(cbd);
+
+ RButtonsList.remove(i);
+ }
+ else i++;
+ }
+ M.BroadcastMessage(DM_BBNEEDUPDATE, 0, 0);
+ M.BroadcastMessage(DM_LOADBUTTONBARICONS, 0, 0);
+}
+
+void BB_InitDlgButtons(TWindowData *dat)
+{
+ if (dat == 0)
+ return;
+ HWND hdlg = dat->hwnd;
+ if (hdlg == 0)
+ return;
+ RECT rect;
+ int lwidth = 0, rwidth = 0;
+ RECT rcSplitter;
+ POINT ptSplitter;
+ int splitterY;
+ BYTE gap = DPISCALEX_S(PluginConfig.m_iButtonsBarGap);
+
+ GetWindowRect(GetDlgItem(hdlg, (dat->bType == SESSIONTYPE_IM) ? IDC_SPLITTER : IDC_SPLITTERY), &rcSplitter);
+ ptSplitter.x = 0;
+ ptSplitter.y = rcSplitter.top;
+ ScreenToClient(hdlg, &ptSplitter);
+
+ GetClientRect(hdlg, &rect);
+ splitterY = ptSplitter.y - DPISCALEY_S(1);
+
+ HWND hwndBtn = NULL;
+
+ for (int i = 0; i < RButtonsList.getCount(); i++) {
+ CustomButtonData *cbd = RButtonsList[i];
+ if (((dat->bType == SESSIONTYPE_IM && cbd->m_bIMButton) || (dat->bType == SESSIONTYPE_CHAT && cbd->m_bChatButton))) {
+ if (!cbd->m_bHidden)
+ rwidth += cbd->m_iButtonWidth + gap;
+ if (!cbd->m_bHidden && !cbd->m_bCanBeHidden)
+ dat->iButtonBarReallyNeeds += cbd->m_iButtonWidth + gap;
+ if (!cbd->m_bSeparator && !GetDlgItem(hdlg, cbd->m_dwButtonCID)) {
+ hwndBtn = CreateWindowEx(0, _T("MButtonClass"), _T(""), WS_CHILD | WS_VISIBLE | WS_TABSTOP, rect.right - rwidth + gap, splitterY, cbd->m_iButtonWidth, DPISCALEY_S(22), hdlg, (HMENU)cbd->m_dwButtonCID, g_hInst, NULL);
+ CustomizeButton(hwndBtn);
+ }
+ if (!cbd->m_bSeparator && hwndBtn)
+ cbd->Accustom(hwndBtn, dat);
+ }
+ else if (GetDlgItem(hdlg, cbd->m_dwButtonCID))
+ DestroyWindow(GetDlgItem(hdlg, cbd->m_dwButtonCID));
+
+ if (cbd->m_bDisabled)
+ EnableWindow(hwndBtn, 0);
+ if (cbd->m_bHidden)
+ ShowWindow(hwndBtn, SW_HIDE);
+
+ }
+
+ hwndBtn = NULL;
+
+ for (int i = 0; i < LButtonsList.getCount(); i++) {
+ CustomButtonData *cbd = LButtonsList[i];
+ if (((dat->bType == SESSIONTYPE_IM && cbd->m_bIMButton) || (dat->bType == SESSIONTYPE_CHAT && cbd->m_bChatButton))) {
+ if (!cbd->m_bSeparator && !GetDlgItem(hdlg, cbd->m_dwButtonCID)) {
+ hwndBtn = CreateWindowEx(0, _T("MButtonClass"), _T(""), WS_CHILD | WS_VISIBLE | WS_TABSTOP, 2 + lwidth, splitterY,
+ cbd->m_iButtonWidth, DPISCALEY_S(22), hdlg, (HMENU)cbd->m_dwButtonCID, g_hInst, NULL);
+ CustomizeButton(hwndBtn);
+ }
+ if (!cbd->m_bHidden)
+ lwidth += cbd->m_iButtonWidth + gap;
+ if (!cbd->m_bHidden && !cbd->m_bCanBeHidden)
+ dat->iButtonBarReallyNeeds += cbd->m_iButtonWidth + gap;
+ if (!cbd->m_bSeparator && hwndBtn)
+ cbd->Accustom(hwndBtn, dat);
+ }
+ else if (GetDlgItem(hdlg, cbd->m_dwButtonCID))
+ DestroyWindow(GetDlgItem(hdlg, cbd->m_dwButtonCID));
+
+ if (cbd->m_bDisabled)
+ EnableWindow(hwndBtn, 0);
+ if (cbd->m_bHidden)
+ ShowWindow(hwndBtn, SW_HIDE);
+ }
+
+ dat->bbLSideWidth = lwidth;
+ dat->bbRSideWidth = rwidth;
+}
+
+void BB_RedrawButtons(TWindowData *dat)
+{
+ for (int i = 0; i < LButtonsList.getCount(); i++) {
+ CustomButtonData *cbd = LButtonsList[i];
+ HWND hwnd = GetDlgItem(dat->hwnd, cbd->m_dwButtonCID);
+ if (hwnd)
+ InvalidateRect(hwnd, 0, TRUE);
+ }
+
+ for (int i = 0; i < RButtonsList.getCount(); i++) {
+ CustomButtonData *cbd = RButtonsList[i];
+ HWND hwnd = GetDlgItem(dat->hwnd, cbd->m_dwButtonCID);
+ if (hwnd)
+ InvalidateRect(hwnd, 0, TRUE);
+ }
+
+ HWND hwndToggleSideBar = GetDlgItem(dat->hwnd, dat->bType == SESSIONTYPE_IM ? IDC_TOGGLESIDEBAR : IDC_CHAT_TOGGLESIDEBAR);
+ if (hwndToggleSideBar && IsWindow(hwndToggleSideBar))
+ InvalidateRect(hwndToggleSideBar, 0, TRUE);
+}
+
+void BB_UpdateIcons(HWND hdlg)
+{
+ HWND hwndBtn = NULL;
+
+ for (int i = 0; i < LButtonsList.getCount(); i++) {
+ CustomButtonData *cbd = LButtonsList[i];
+ if (cbd) {
+ if (!cbd->m_bSeparator)
+ hwndBtn = GetDlgItem(hdlg, cbd->m_dwButtonCID);
+
+ if (hwndBtn && cbd->m_hIcon)
+ SendMessage(hwndBtn, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Skin_GetIconByHandle(cbd->m_hIcon));
+ }
+ }
+
+ hwndBtn = NULL;
+ for (int i = 0; i < RButtonsList.getCount(); i++) {
+ CustomButtonData *cbd = RButtonsList[i];
+ if (cbd) {
+ if (!cbd->m_bSeparator)
+ hwndBtn = GetDlgItem(hdlg, cbd->m_dwButtonCID);
+
+ if (hwndBtn && cbd->m_hIcon)
+ SendMessage(hwndBtn, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Skin_GetIconByHandle(cbd->m_hIcon));
+ }
+ }
+}
+
+void BB_RefreshTheme(const TWindowData *dat)
+{
+ for (int i = 0; i < RButtonsList.getCount(); i++) {
+ CustomButtonData* cbd = RButtonsList[i];
+ SendDlgItemMessage(dat->hwnd, cbd->m_dwButtonCID, WM_THEMECHANGED, 0, 0);
+ }
+ for (int i = 0; i < LButtonsList.getCount(); i++) {
+ CustomButtonData* cbd = LButtonsList[i];
+ SendDlgItemMessage(dat->hwnd, cbd->m_dwButtonCID, WM_THEMECHANGED, 0, 0);
+ }
+}
+
+BOOL BB_SetButtonsPos(TWindowData *dat)
+{
+ if (!dat || !IsWindowVisible(dat->hwnd))
+ return 0;
+
+ HWND hwnd = dat->hwnd;
+ RECT rect;
+ int i;
+ HWND hwndBtn = 0;
+
+ BYTE gap = DPISCALEX_S(PluginConfig.m_iButtonsBarGap);
+ bool showToolbar = !(dat->pContainer->dwFlags & CNT_HIDETOOLBAR);
+ bool bBottomToolbar = (dat->pContainer->dwFlags & CNT_BOTTOMTOOLBAR) != 0;
+
+ HWND hwndToggleSideBar = GetDlgItem(hwnd, dat->bType == SESSIONTYPE_IM ? IDC_TOGGLESIDEBAR : IDC_CHAT_TOGGLESIDEBAR);
+ ShowWindow(hwndToggleSideBar, (showToolbar && dat->pContainer->SideBar->isActive()) ? SW_SHOW : SW_HIDE);
+
+ HDWP hdwp = BeginDeferWindowPos(LButtonsList.getCount() + RButtonsList.getCount() + 1);
+
+ mir_cslock lck(csToolBar);
+
+ RECT rcSplitter;
+ GetWindowRect(GetDlgItem(hwnd, (dat->bType == SESSIONTYPE_IM) ? IDC_SPLITTER : IDC_SPLITTERY), &rcSplitter);
+
+ POINT ptSplitter = { 0, rcSplitter.top };
+ ScreenToClient(hwnd, &ptSplitter);
+
+ GetClientRect(hwnd, &rect);
+
+ int splitterY = (!bBottomToolbar) ? ptSplitter.y - DPISCALEY_S(1) : rect.bottom;
+ int tempL = dat->bbLSideWidth, tempR = dat->bbRSideWidth;
+ int lwidth = 0, rwidth = 0;
+ int iOff = DPISCALEY_S((PluginConfig.m_DPIscaleY > 1.0) ? (dat->bType == SESSIONTYPE_IM ? 22 : 23) : 22);
+
+ int foravatar = 0;
+ if ((rect.bottom - ptSplitter.y - (rcSplitter.bottom - rcSplitter.top) /*- DPISCALEY(2)*/ - (bBottomToolbar ? DPISCALEY_S(24) : 0) < dat->pic.cy - DPISCALEY_S(2)) && dat->bShowAvatar && !PluginConfig.m_bAlwaysFullToolbarWidth)
+ foravatar = dat->pic.cx + gap;
+
+ if ((dat->pContainer->dwFlags & CNT_SIDEBAR) && (dat->pContainer->SideBar->getFlags() & CSideBar::SIDEBARORIENTATION_LEFT)) {
+ if (NULL != hwndToggleSideBar) /* Wine fix. */
+ hdwp = DeferWindowPos(hdwp, hwndToggleSideBar, NULL, 4, 2 + splitterY - iOff, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
+ lwidth += 10;
+ tempL -= 10;
+ }
+
+ for (i = 0; i < LButtonsList.getCount(); i++) {
+ CustomButtonData *cbd = LButtonsList[i];
+ if (((dat->bType == SESSIONTYPE_IM) && cbd->m_bIMButton) || ((dat->bType == SESSIONTYPE_CHAT) && cbd->m_bChatButton)) {
+ hwndBtn = GetDlgItem(hwnd, cbd->m_dwButtonCID);
+
+ if (!showToolbar) {
+ ShowWindow(hwndBtn, SW_HIDE);
+ if (NULL != hwndBtn) /* Wine fix. */
+ hdwp = DeferWindowPos(hdwp, hwndBtn, NULL, lwidth, splitterY - iOff, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
+ if (IsWindowVisible(hwndBtn) || (cbd->m_bSeparator && !(cbd->m_bAutoHidden || cbd->m_bHidden)))
+ lwidth += cbd->m_iButtonWidth + gap;
+ if (!IsWindowEnabled(hwndBtn) && !IsWindowVisible(hwndBtn) && !cbd->m_bAutoHidden)
+ cbd->m_bAutoHidden = 1;
+ continue;
+ }
+ if (!cbd->m_bCanBeHidden && !cbd->m_bHidden && !(!IsWindowEnabled(hwndBtn) && !IsWindowVisible(hwndBtn) && !cbd->m_bAutoHidden)) {
+ ShowWindow(hwndBtn, SW_SHOW);
+ cbd->m_bAutoHidden = 0;
+ }
+
+ if (!cbd->m_bSeparator && !IsWindowVisible(hwndBtn) && !IsWindowEnabled(hwndBtn) && !cbd->m_bAutoHidden)
+ tempL -= cbd->m_iButtonWidth + gap;
+
+ if (cbd->m_bCanBeHidden && !cbd->m_bHidden && (cbd->m_bSeparator || !((!IsWindowEnabled(hwndBtn) && !IsWindowVisible(hwndBtn)) && !cbd->m_bAutoHidden))) {
+ if (tempL + tempR > (rect.right - foravatar)) {
+ ShowWindow(hwndBtn, SW_HIDE);
+ cbd->m_bAutoHidden = 1;
+ tempL -= cbd->m_iButtonWidth + gap;
+ }
+ else if (cbd->m_bAutoHidden) {
+ ShowWindow(hwndBtn, SW_SHOW);
+ cbd->m_bAutoHidden = 0;
+ }
+ }
+ if (NULL != hwndBtn) /* Wine fix. */
+ hdwp = DeferWindowPos(hdwp, hwndBtn, NULL, lwidth, splitterY - iOff, 0, 0, SWP_NOZORDER | SWP_NOSIZE);// SWP_NOCOPYBITS);
+ if (IsWindowVisible(hwndBtn) || (cbd->m_bSeparator && !(cbd->m_bAutoHidden || cbd->m_bHidden)))
+ lwidth += cbd->m_iButtonWidth + gap;
+ }
+ }
+
+ if ((dat->pContainer->dwFlags & CNT_SIDEBAR) && (dat->pContainer->SideBar->getFlags() & CSideBar::SIDEBARORIENTATION_RIGHT)) {
+ if (NULL != hwndToggleSideBar) /* Wine fix. */
+ hdwp = DeferWindowPos(hdwp, hwndToggleSideBar, NULL, rect.right - foravatar - 10, 2 + splitterY - iOff, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
+ rwidth += 12;
+ tempR -= 12;
+ }
+
+ for (i = 0; i < RButtonsList.getCount(); i++) {
+ CustomButtonData *cbd = RButtonsList[i];
+ if (((dat->bType == SESSIONTYPE_IM) && cbd->m_bIMButton) || ((dat->bType == SESSIONTYPE_CHAT) && cbd->m_bChatButton)) {
+ hwndBtn = GetDlgItem(hwnd, cbd->m_dwButtonCID);
+
+ if (!showToolbar) {
+ ShowWindow(hwndBtn, SW_HIDE);
+ if (IsWindowVisible(hwndBtn) || (cbd->m_bSeparator && !(cbd->m_bAutoHidden || cbd->m_bHidden)))
+ rwidth += cbd->m_iButtonWidth + gap;
+ if (NULL != hwndBtn) /* Wine fix. */
+ hdwp = DeferWindowPos(hdwp, hwndBtn, NULL, rect.right - foravatar - rwidth + gap, splitterY - iOff, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
+ if (!IsWindowEnabled(hwndBtn) && !IsWindowVisible(hwndBtn) && !cbd->m_bAutoHidden)
+ cbd->m_bAutoHidden = 1;
+ continue;
+ }
+ if (!cbd->m_bCanBeHidden && !cbd->m_bHidden && !((!IsWindowEnabled(hwndBtn) && !IsWindowVisible(hwndBtn)) && !cbd->m_bAutoHidden)) {
+ ShowWindow(hwndBtn, SW_SHOW);
+ cbd->m_bAutoHidden = 0;
+ }
+
+ if (!cbd->m_bSeparator && !IsWindowVisible(hwndBtn) && !IsWindowEnabled(hwndBtn) && !cbd->m_bAutoHidden)
+ tempR -= cbd->m_iButtonWidth + gap;
+
+ if (cbd->m_bCanBeHidden && !cbd->m_bHidden && (cbd->m_bSeparator || !((!IsWindowEnabled(hwndBtn) && !IsWindowVisible(hwndBtn)) && !cbd->m_bAutoHidden))) {
+ if (tempL + tempR > (rect.right - foravatar)) {
+ ShowWindow(hwndBtn, SW_HIDE);
+ cbd->m_bAutoHidden = 1;
+ tempR -= cbd->m_iButtonWidth + gap;
+ }
+ else if (cbd->m_bAutoHidden) {
+ ShowWindow(hwndBtn, SW_SHOW);
+ cbd->m_bAutoHidden = 0;
+ }
+ }
+
+ if (IsWindowVisible(hwndBtn) || (cbd->m_bSeparator && !(cbd->m_bAutoHidden || cbd->m_bHidden)))
+ rwidth += cbd->m_iButtonWidth + gap;
+ if (NULL != hwndBtn) /* Wine fix. */
+ hdwp = DeferWindowPos(hdwp, hwndBtn, NULL, rect.right - foravatar - rwidth + gap, splitterY - iOff, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
+ }
+ }
+ return EndDeferWindowPos(hdwp);
+}
+
+void BB_CustomButtonClick(TWindowData *dat, DWORD idFrom, HWND hwndFrom, BOOL code)
+{
+ RECT rc;
+ int i;
+ BOOL bFromArrow = 0;
+ CustomButtonClickData cbcd = { 0 };
+
+ GetWindowRect(hwndFrom, &rc);
+ cbcd.pt.x = rc.left;
+ cbcd.pt.y = rc.bottom;
+
+ for (i = 0; i < LButtonsList.getCount(); i++) {
+ CustomButtonData* cbd = LButtonsList[i];
+ if (cbd->m_dwButtonCID == idFrom) {
+ cbcd.pszModule = cbd->m_pszModuleName;
+ cbcd.dwButtonId = cbd->m_dwButtonOrigID;
+ }
+ else if (cbd->m_dwArrowCID == idFrom) {
+ bFromArrow = 1;
+ cbcd.pszModule = cbd->m_pszModuleName;
+ cbcd.dwButtonId = cbd->m_dwButtonOrigID;
+ }
+ }
+
+ if (!cbcd.pszModule)
+ for (i = 0; i < RButtonsList.getCount(); i++) {
+ CustomButtonData* cbd = RButtonsList[i];
+ if (cbd->m_dwButtonCID == idFrom) {
+ cbcd.pszModule = cbd->m_pszModuleName;
+ cbcd.dwButtonId = cbd->m_dwButtonOrigID;
+ }
+ else if (cbd->m_dwArrowCID == idFrom) {
+ bFromArrow = 1;
+ cbcd.pszModule = cbd->m_pszModuleName;
+ cbcd.dwButtonId = cbd->m_dwButtonOrigID;
+ }
+ }
+
+ cbcd.cbSize = sizeof(CustomButtonClickData);
+ cbcd.hwndFrom = dat->hwnd;
+ cbcd.hContact = dat->hContact;
+ cbcd.flags = (code ? BBCF_RIGHTBUTTON : 0) | (GetKeyState(VK_SHIFT) & 0x8000 ? BBCF_SHIFTPRESSED : 0) | (GetKeyState(VK_CONTROL) & 0x8000 ? BBCF_CONTROLPRESSED : 0) | (bFromArrow ? BBCF_ARROWCLICKED : 0);
+
+ NotifyEventHooks(hHookButtonPressedEvt, dat->hContact, (LPARAM)&cbcd);
+}
+
+void CB_DestroyAllButtons(HWND hwndDlg)
+{
+ HWND hwndBtn = NULL;
+ for (int i = 0; i < LButtonsList.getCount(); i++) {
+ CustomButtonData *cbd = LButtonsList[i];
+ hwndBtn = GetDlgItem(hwndDlg, cbd->m_dwButtonCID);
+ if (hwndBtn)
+ DestroyWindow(hwndBtn);
+ }
+
+ for (int i = 0; i < RButtonsList.getCount(); i++) {
+ CustomButtonData *cbd = RButtonsList[i];
+ hwndBtn = GetDlgItem(hwndDlg, cbd->m_dwButtonCID);
+ if (hwndBtn)
+ DestroyWindow(hwndBtn);
+ }
+}
+
+void CB_DestroyButton(HWND hwndDlg, TWindowData *dat, DWORD dwButtonCID, DWORD dwFlags)
+{
+ HWND hwndBtn = GetDlgItem(hwndDlg, dwButtonCID);
+ RECT rc = { 0 };
+ if (hwndBtn) {
+ GetClientRect(hwndBtn, &rc);
+ if (dwFlags & BBBF_ISLSIDEBUTTON)
+ dat->bbLSideWidth -= rc.right;
+ else if (dwFlags & BBBF_ISRSIDEBUTTON)
+ dat->bbRSideWidth -= rc.right;
+
+ DestroyWindow(hwndBtn);
+ BB_SetButtonsPos(dat);
+ }
+}
+
+void CB_ChangeButton(HWND hwndDlg, TWindowData *dat, CustomButtonData *cbd)
+{
+ HWND hwndBtn = GetDlgItem(hwndDlg, cbd->m_dwButtonCID);
+ if (hwndBtn) {
+ if (cbd->m_hIcon)
+ SendMessage(hwndBtn, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Skin_GetIconByHandle(cbd->m_hIcon));
+ if (cbd->m_ptszTooltip)
+ SendMessage(hwndBtn, BUTTONADDTOOLTIP, (WPARAM)cbd->m_ptszTooltip, BATF_TCHAR);
+ SendMessage(hwndBtn, BUTTONSETCONTAINER, (LPARAM)dat->pContainer, 0);
+ SetWindowTextA(hwndBtn, cbd->m_pszModuleName);
+ }
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Module init procedure
+
+void CB_InitCustomButtons()
+{
+ dwSepCount = M.GetDword("TabSRMM_Toolbar", "SeparatorsCount", 0);
+
+ hButtonsBarAddButton = CreateServiceFunction(MS_BB_ADDBUTTON, CB_AddButton);
+ hButtonsBarRemoveButton = CreateServiceFunction(MS_BB_REMOVEBUTTON, CB_RemoveButton);
+ hButtonsBarModifyButton = CreateServiceFunction(MS_BB_MODIFYBUTTON, CB_ModifyButton);
+ hButtonsBarGetButtonState = CreateServiceFunction(MS_BB_GETBUTTONSTATE, CB_GetButtonState);
+ hButtonsBarSetButtonState = CreateServiceFunction(MS_BB_SETBUTTONSTATE, CB_SetButtonState);
+
+ hHookToolBarLoadedEvt = CreateHookableEvent(ME_MSG_TOOLBARLOADED);
+ hHookButtonPressedEvt = CreateHookableEvent(ME_MSG_BUTTONPRESSED);
+}
+
+void CB_DeInitCustomButtons()
+{
+ wipeList(LButtonsList);
+ wipeList(RButtonsList);
+
+ DestroyHookableEvent(hHookToolBarLoadedEvt);
+ DestroyHookableEvent(hHookButtonPressedEvt);
+ DestroyServiceFunction(hButtonsBarAddButton);
+ DestroyServiceFunction(hButtonsBarRemoveButton);
+ DestroyServiceFunction(hButtonsBarModifyButton);
+ DestroyServiceFunction(hButtonsBarGetButtonState);
+ DestroyServiceFunction(hButtonsBarSetButtonState);
+}
+
diff --git a/plugins/TabSRMM/src/generic_msghandlers.h b/plugins/TabSRMM/src/generic_msghandlers.h
index 40fc324e76..5b2812f9c1 100644
--- a/plugins/TabSRMM/src/generic_msghandlers.h
+++ b/plugins/TabSRMM/src/generic_msghandlers.h
@@ -44,9 +44,6 @@ void TSAPI DM_NotifyTyping(TWindowData *dat, int mode);
int TSAPI DM_SplitterGlobalEvent(TWindowData *dat, WPARAM wParam, LPARAM lParam);
void TSAPI BB_InitDlgButtons(TWindowData *dat);
-BOOL TSAPI BB_SetButtonsPos(TWindowData *dat);
-void TSAPI BB_RedrawButtons(TWindowData *dat);
-void TSAPI BB_CustomButtonClick(TWindowData *dat, DWORD idFrom, HWND hwndFrom, BOOL code);
void TSAPI DM_EventAdded(TWindowData *dat, WPARAM wParam, LPARAM lParam);
void TSAPI DM_InitRichEdit(TWindowData *dat);
LRESULT TSAPI DM_ContainerCmdHandler(TContainerData *pContainer, UINT cmd, WPARAM wParam, LPARAM lParam);
diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp
index e0648f09e3..46b54a9efc 100644
--- a/plugins/TabSRMM/src/msgdialog.cpp
+++ b/plugins/TabSRMM/src/msgdialog.cpp
@@ -1307,16 +1307,11 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
BB_InitDlgButtons(dat);
SendMessage(hwndDlg, DM_LOADBUTTONBARICONS, 0, 0);
- BOOL isThemed = TRUE;
- if (CSkin::m_skinEnabled && !SkinItems[ID_EXTBKBUTTONSNPRESSED].IGNORED &&
- !SkinItems[ID_EXTBKBUTTONSPRESSED].IGNORED && !SkinItems[ID_EXTBKBUTTONSMOUSEOVER].IGNORED)
- isThemed = FALSE;
-
SendDlgItemMessage(hwndDlg, IDC_ADD, BUTTONSETASFLATBTN, TRUE, 0);
SendDlgItemMessage(hwndDlg, IDC_CANCELADD, BUTTONSETASFLATBTN, TRUE, 0);
SendDlgItemMessage(hwndDlg, IDC_TOGGLESIDEBAR, BUTTONSETASFLATBTN, TRUE, 0);
- SendDlgItemMessage(hwndDlg, IDC_TOGGLESIDEBAR, BUTTONSETASTHEMEDBTN, isThemed, 0);
+ SendDlgItemMessage(hwndDlg, IDC_TOGGLESIDEBAR, BUTTONSETASTHEMEDBTN, CSkin::IsThemed(), 0);
SendDlgItemMessage(hwndDlg, IDC_TOGGLESIDEBAR, BUTTONSETCONTAINER, (LPARAM)m_pContainer, 0);
SendDlgItemMessage(hwndDlg, IDC_TOGGLESIDEBAR, BUTTONSETASTOOLBARBUTTON, TRUE, 0);
@@ -1570,12 +1565,10 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
case WM_PAINT:
// in skinned mode only, draw the background elements for the 2 richedit controls
// this allows border-less textboxes to appear "skinned" and blended with the background
- {
PAINTSTRUCT ps;
BeginPaint(hwndDlg, &ps);
EndPaint(hwndDlg, &ps);
- }
- return 0;
+ return 0;
case WM_SIZE:
if (!IsIconic(hwndDlg)) {
@@ -1754,32 +1747,32 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
CWarning::show(CWarning::WARN_NO_SENDLATER, MB_OK | MB_ICONINFORMATION, TranslateT("Configuration issue|The unattended send feature is disabled. The \\b1 send later\\b0 and \\b1 send to multiple contacts\\b0 features depend on it.\n\nYou must enable it under \\b1Options->Message sessions->Advanced tweaks\\b0. Changing this option requires a restart."));
return _dlgReturn(hwndDlg, 1);
case TABSRMM_HK_TOGGLERTL:
- {
- DWORD dwGlobal = M.GetDword("mwflags", MWF_LOG_DEFAULT);
- DWORD dwMask = M.GetDword(dat->hContact, "mwmask", 0);
- DWORD dwFlags = M.GetDword(dat->hContact, "mwflags", 0);
-
dat->dwFlags ^= MWF_LOG_RTL;
- if ((dwGlobal & MWF_LOG_RTL) != (dat->dwFlags & MWF_LOG_RTL)) {
- dwMask |= MWF_LOG_RTL;
- dwFlags |= (dat->dwFlags & MWF_LOG_RTL);
- }
- else {
- dwMask &= ~MWF_LOG_RTL;
- dwFlags &= ~MWF_LOG_RTL;
- }
- if (dwMask) {
- db_set_dw(dat->hContact, SRMSGMOD_T, "mwmask", dwMask);
- db_set_dw(dat->hContact, SRMSGMOD_T, "mwflags", dwFlags);
- }
- else {
- db_unset(dat->hContact, SRMSGMOD_T, "mwmask");
- db_unset(dat->hContact, SRMSGMOD_T, "mwflags");
+ {
+ DWORD dwGlobal = M.GetDword("mwflags", MWF_LOG_DEFAULT);
+ DWORD dwMask = M.GetDword(dat->hContact, "mwmask", 0);
+ DWORD dwFlags = M.GetDword(dat->hContact, "mwflags", 0);
+
+ if ((dwGlobal & MWF_LOG_RTL) != (dat->dwFlags & MWF_LOG_RTL)) {
+ dwMask |= MWF_LOG_RTL;
+ dwFlags |= (dat->dwFlags & MWF_LOG_RTL);
+ }
+ else {
+ dwMask &= ~MWF_LOG_RTL;
+ dwFlags &= ~MWF_LOG_RTL;
+ }
+ if (dwMask) {
+ db_set_dw(dat->hContact, SRMSGMOD_T, "mwmask", dwMask);
+ db_set_dw(dat->hContact, SRMSGMOD_T, "mwflags", dwFlags);
+ }
+ else {
+ db_unset(dat->hContact, SRMSGMOD_T, "mwmask");
+ db_unset(dat->hContact, SRMSGMOD_T, "mwflags");
+ }
+ SendMessage(hwndDlg, DM_OPTIONSAPPLIED, 0, 0);
+ SendMessage(hwndDlg, DM_DEFERREDREMAKELOG, (WPARAM)hwndDlg, 0);
}
- SendMessage(hwndDlg, DM_OPTIONSAPPLIED, 0, 0);
- SendMessage(hwndDlg, DM_DEFERREDREMAKELOG, (WPARAM)hwndDlg, 0);
- }
- return _dlgReturn(hwndDlg, 1);
+ return _dlgReturn(hwndDlg, 1);
case TABSRMM_HK_TOGGLEMULTISEND:
dat->sendMode ^= SMODE_MULTIPLE;
@@ -1990,16 +1983,16 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
}
switch (msg) {
case WM_LBUTTONDOWN:
- {
- HCURSOR hCur = GetCursor();
- m_pContainer->MenuBar->Cancel();
- if (hCur == LoadCursor(NULL, IDC_SIZENS) || hCur == LoadCursor(NULL, IDC_SIZEWE)
- || hCur == LoadCursor(NULL, IDC_SIZENESW) || hCur == LoadCursor(NULL, IDC_SIZENWSE)) {
- SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, TRUE);
- return TRUE;
+ {
+ HCURSOR hCur = GetCursor();
+ m_pContainer->MenuBar->Cancel();
+ if (hCur == LoadCursor(NULL, IDC_SIZENS) || hCur == LoadCursor(NULL, IDC_SIZEWE)
+ || hCur == LoadCursor(NULL, IDC_SIZENESW) || hCur == LoadCursor(NULL, IDC_SIZENWSE)) {
+ SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, TRUE);
+ return TRUE;
+ }
}
break;
- }
// auto-select-and-copy handling...
// if enabled, releasing the lmb with an active selection automatically copies the selection
@@ -2343,19 +2336,19 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
return 0;
case DM_SCROLLIEVIEW:
- {
- IEVIEWWINDOW iew = { sizeof(iew) };
- iew.iType = IEW_SCROLLBOTTOM;
- if (dat->hwndIEView) {
- iew.hwnd = dat->hwndIEView;
- CallService(MS_IEVIEW_WINDOW, 0, (LPARAM)&iew);
- }
- else if (dat->hwndHPP) {
- iew.hwnd = dat->hwndHPP;
- CallService(MS_HPP_EG_WINDOW, 0, (LPARAM)&iew);
+ {
+ IEVIEWWINDOW iew = { sizeof(iew) };
+ iew.iType = IEW_SCROLLBOTTOM;
+ if (dat->hwndIEView) {
+ iew.hwnd = dat->hwndIEView;
+ CallService(MS_IEVIEW_WINDOW, 0, (LPARAM)&iew);
+ }
+ else if (dat->hwndHPP) {
+ iew.hwnd = dat->hwndHPP;
+ CallService(MS_HPP_EG_WINDOW, 0, (LPARAM)&iew);
+ }
}
- }
- return 0;
+ return 0;
case HM_DBEVENTADDED:
// this is called whenever a new event has been added to the database.
@@ -2477,32 +2470,32 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
}
return 0;
- // return timestamp (in ticks) of last recent message which has not been read yet.
- // 0 if there is none
- // lParam = pointer to a dword receiving the value.
+ // return timestamp (in ticks) of last recent message which has not been read yet.
+ // 0 if there is none
+ // lParam = pointer to a dword receiving the value.
case DM_QUERYLASTUNREAD:
- {
- DWORD *pdw = (DWORD *)lParam;
- if (pdw)
- *pdw = dat->dwTickLastEvent;
- }
- return 0;
+ {
+ DWORD *pdw = (DWORD *)lParam;
+ if (pdw)
+ *pdw = dat->dwTickLastEvent;
+ }
+ return 0;
case DM_QUERYCONTAINER:
- {
- TContainerData **pc = (TContainerData **)lParam;
- if (pc)
- *pc = m_pContainer;
- }
- return 0;
+ {
+ TContainerData **pc = (TContainerData **)lParam;
+ if (pc)
+ *pc = m_pContainer;
+ }
+ return 0;
case DM_QUERYHCONTACT:
- {
- MCONTACT *phContact = (MCONTACT*)lParam;
- if (phContact)
- *phContact = dat->hContact;
- }
- return 0;
+ {
+ MCONTACT *phContact = (MCONTACT*)lParam;
+ if (phContact)
+ *phContact = dat->hContact;
+ }
+ return 0;
case DM_UPDATELASTMESSAGE:
DM_UpdateLastMessage(dat);
@@ -2572,48 +2565,48 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
break;
case WM_RBUTTONUP:
- {
- RECT rcPicture, rcPanelNick = { 0 };
- int menuID = 0;
+ {
+ RECT rcPicture, rcPanelNick = { 0 };
+ int menuID = 0;
- GetWindowRect(GetDlgItem(hwndDlg, IDC_CONTACTPIC), &rcPicture);
- rcPanelNick.left = rcPanelNick.right - 30;
- GetCursorPos(&pt);
+ GetWindowRect(GetDlgItem(hwndDlg, IDC_CONTACTPIC), &rcPicture);
+ rcPanelNick.left = rcPanelNick.right - 30;
+ GetCursorPos(&pt);
- if (dat->Panel->invokeConfigDialog(pt))
- break;
+ if (dat->Panel->invokeConfigDialog(pt))
+ break;
- if (PtInRect(&rcPicture, pt))
- menuID = MENU_PICMENU;
+ if (PtInRect(&rcPicture, pt))
+ menuID = MENU_PICMENU;
- if ((menuID == MENU_PICMENU && ((dat->ace ? dat->ace->hbmPic : PluginConfig.g_hbmUnknown) || dat->hOwnPic) && dat->bShowAvatar != 0)) {
- HMENU submenu = GetSubMenu(m_pContainer->hMenuContext, 1);
- GetCursorPos(&pt);
- MsgWindowUpdateMenu(dat, submenu, menuID);
- int iSelection = TrackPopupMenu(submenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL);
- MsgWindowMenuHandler(dat, iSelection, menuID);
- break;
- }
+ if ((menuID == MENU_PICMENU && ((dat->ace ? dat->ace->hbmPic : PluginConfig.g_hbmUnknown) || dat->hOwnPic) && dat->bShowAvatar != 0)) {
+ HMENU submenu = GetSubMenu(m_pContainer->hMenuContext, 1);
+ GetCursorPos(&pt);
+ MsgWindowUpdateMenu(dat, submenu, menuID);
+ int iSelection = TrackPopupMenu(submenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL);
+ MsgWindowMenuHandler(dat, iSelection, menuID);
+ break;
+ }
- HMENU subMenu = GetSubMenu(m_pContainer->hMenuContext, 0);
- MsgWindowUpdateMenu(dat, subMenu, MENU_TABCONTEXT);
+ HMENU subMenu = GetSubMenu(m_pContainer->hMenuContext, 0);
+ MsgWindowUpdateMenu(dat, subMenu, MENU_TABCONTEXT);
- int iSelection = TrackPopupMenu(subMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL);
- if (iSelection >= IDM_CONTAINERMENU) {
- char szIndex[10];
- char *szKey = "TAB_ContainersW";
+ int iSelection = TrackPopupMenu(subMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL);
+ if (iSelection >= IDM_CONTAINERMENU) {
+ char szIndex[10];
+ char *szKey = "TAB_ContainersW";
- mir_snprintf(szIndex, SIZEOF(szIndex), "%d", iSelection - IDM_CONTAINERMENU);
- if (iSelection - IDM_CONTAINERMENU >= 0) {
- ptrT val(db_get_tsa(NULL, szKey, szIndex));
- if (val)
- SendMessage(hwndDlg, DM_CONTAINERSELECTED, 0, (LPARAM)val);
+ mir_snprintf(szIndex, SIZEOF(szIndex), "%d", iSelection - IDM_CONTAINERMENU);
+ if (iSelection - IDM_CONTAINERMENU >= 0) {
+ ptrT val(db_get_tsa(NULL, szKey, szIndex));
+ if (val)
+ SendMessage(hwndDlg, DM_CONTAINERSELECTED, 0, (LPARAM)val);
+ }
+ break;
}
- break;
+ MsgWindowMenuHandler(dat, iSelection, MENU_TABCONTEXT);
}
- MsgWindowMenuHandler(dat, iSelection, MENU_TABCONTEXT);
- }
- break;
+ break;
case WM_MOUSEMOVE:
GetCursorPos(&pt);
@@ -2622,15 +2615,15 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
break;
case WM_MEASUREITEM:
- {
- LPMEASUREITEMSTRUCT lpmi = (LPMEASUREITEMSTRUCT)lParam;
- if (dat->Panel->isHovered()) {
- lpmi->itemHeight = 0;
- lpmi->itemWidth = 6;
- return TRUE;
+ {
+ LPMEASUREITEMSTRUCT lpmi = (LPMEASUREITEMSTRUCT)lParam;
+ if (dat->Panel->isHovered()) {
+ lpmi->itemHeight = 0;
+ lpmi->itemWidth = 6;
+ return TRUE;
+ }
}
- }
- return CallService(MS_CLIST_MENUMEASUREITEM, wParam, lParam);
+ return CallService(MS_CLIST_MENUMEASUREITEM, wParam, lParam);
case WM_NCHITTEST:
SendMessage(hwndContainer, WM_NCHITTEST, wParam, lParam);
@@ -2640,14 +2633,14 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
return MsgWindowDrawHandler(wParam, lParam, dat);
case WM_APPCOMMAND:
- {
- DWORD cmd = GET_APPCOMMAND_LPARAM(lParam);
- if (cmd == APPCOMMAND_BROWSER_BACKWARD || cmd == APPCOMMAND_BROWSER_FORWARD) {
- SendMessage(hwndContainer, DM_SELECTTAB, cmd == APPCOMMAND_BROWSER_BACKWARD ? DM_SELECT_PREV : DM_SELECT_NEXT, 0);
- return 1;
+ {
+ DWORD cmd = GET_APPCOMMAND_LPARAM(lParam);
+ if (cmd == APPCOMMAND_BROWSER_BACKWARD || cmd == APPCOMMAND_BROWSER_FORWARD) {
+ SendMessage(hwndContainer, DM_SELECTTAB, cmd == APPCOMMAND_BROWSER_BACKWARD ? DM_SELECT_PREV : DM_SELECT_NEXT, 0);
+ return 1;
+ }
}
- }
- break;
+ break;
case WM_COMMAND:
if (!dat)
diff --git a/plugins/TabSRMM/src/msgdlgutils.cpp b/plugins/TabSRMM/src/msgdlgutils.cpp
index 394bad89f2..60723882b5 100644
--- a/plugins/TabSRMM/src/msgdlgutils.cpp
+++ b/plugins/TabSRMM/src/msgdlgutils.cpp
@@ -254,7 +254,8 @@ int TSAPI MsgWindowUpdateMenu(TWindowData *dat, HMENU submenu, int menuID)
bool bInfoPanel = dat->Panel->isActive();
if (menuID == MENU_TABCONTEXT) {
- EnableMenuItem(submenu, ID_TABMENU_ATTACHTOCONTAINER, M.GetByte("useclistgroups", 0) || M.GetByte("singlewinmode", 0) ? MF_GRAYED : MF_ENABLED);
+ EnableMenuItem(submenu, ID_TABMENU_LEAVECHATROOM, (dat->bType == SESSIONTYPE_CHAT && ProtoServiceExists(dat->szProto, PS_LEAVECHAT)) ? MF_ENABLED : MF_DISABLED);
+ EnableMenuItem(submenu, ID_TABMENU_ATTACHTOCONTAINER, (M.GetByte("useclistgroups", 0) || M.GetByte("singlewinmode", 0)) ? MF_GRAYED : MF_ENABLED);
EnableMenuItem(submenu, ID_TABMENU_CLEARSAVEDTABPOSITION, (M.GetDword(dat->hContact, "tabindex", -1) != -1) ? MF_ENABLED : MF_GRAYED);
}
else if (menuID == MENU_PICMENU) {
@@ -332,7 +333,7 @@ int TSAPI MsgWindowMenuHandler(TWindowData *dat, int selection, int menuId)
case ID_TABMENU_LEAVECHATROOM:
if (dat && dat->bType == SESSIONTYPE_CHAT) {
SESSION_INFO *si = dat->si;
- if ((si != NULL) && (dat->hContact != NULL)) {
+ if (si != NULL && dat->hContact != NULL) {
char *szProto = GetContactProto(dat->hContact);
if (szProto)
CallProtoService(szProto, PS_LEAVECHAT, dat->hContact, 0);
diff --git a/plugins/TabSRMM/src/themes.cpp b/plugins/TabSRMM/src/themes.cpp
index 8829380568..d32fd28c82 100644
--- a/plugins/TabSRMM/src/themes.cpp
+++ b/plugins/TabSRMM/src/themes.cpp
@@ -2504,3 +2504,10 @@ void CSkin::FillBack(const HDC hdc, RECT* rc)
else
::FillRect(hdc, rc, GetSysColorBrush(COLOR_3DFACE));
}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+bool CSkin::IsThemed()
+{
+ return !(m_skinEnabled && !SkinItems[ID_EXTBKBUTTONSNPRESSED].IGNORED && !SkinItems[ID_EXTBKBUTTONSPRESSED].IGNORED && !SkinItems[ID_EXTBKBUTTONSMOUSEOVER].IGNORED);
+}
diff --git a/plugins/TabSRMM/src/themes.h b/plugins/TabSRMM/src/themes.h
index eadcd8239e..e115a1ccd8 100644
--- a/plugins/TabSRMM/src/themes.h
+++ b/plugins/TabSRMM/src/themes.h
@@ -302,6 +302,7 @@ public:
static bool __fastcall DrawItem(const HDC hdc, const RECT *rc, const CSkinItem *item);
static void TSAPI UpdateToolbarBG(TWindowData *dat);
static void TSAPI FillBack(const HDC hdc, RECT* rc);
+ static bool TSAPI IsThemed(void);
public:
static bool m_DisableScrollbars, m_bClipBorder;
diff --git a/plugins/TabSRMM/src/version.h b/plugins/TabSRMM/src/version.h
index dbc32d2397..639fb59ad0 100644
--- a/plugins/TabSRMM/src/version.h
+++ b/plugins/TabSRMM/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 3
#define __MINOR_VERSION 4
#define __RELEASE_NUM 0
-#define __BUILD_NUM 9
+#define __BUILD_NUM 10
#include <stdver.h>