summaryrefslogtreecommitdiff
path: root/plugins/TabSRMM/src/buttonsbar.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/TabSRMM/src/buttonsbar.cpp')
-rw-r--r--plugins/TabSRMM/src/buttonsbar.cpp812
1 files changed, 325 insertions, 487 deletions
diff --git a/plugins/TabSRMM/src/buttonsbar.cpp b/plugins/TabSRMM/src/buttonsbar.cpp
index 0d830624a8..3f3fc59133 100644
--- a/plugins/TabSRMM/src/buttonsbar.cpp
+++ b/plugins/TabSRMM/src/buttonsbar.cpp
@@ -9,138 +9,30 @@ static HANDLE hButtonsBarModifyButton;
HANDLE hHookButtonPressedEvt;
HANDLE hHookToolBarLoadedEvt;
-static SortedList * RButtonsList;
-static SortedList * LButtonsList;
+static LIST<CustomButtonData> RButtonsList(1, NumericKeySortT), LButtonsList(1, NumericKeySortT);
DWORD LastCID = 4000;
DWORD dwSepCount = 0;
-BOOL bNeedResort = FALSE;
-CRITICAL_SECTION ToolBarCS;
+static mir_cs ToolBarCS;
-typedef void (*ItemDestuctor)(void*);
-
-
-//////////////////////////////////////////////////////////////////////////////////
-//
-//some code parts from ClistModern toolbar by FYR
-//
-/////////////////////////////////////////////////////////////////////////////////
-static int sstSortButtons(const void *vmtbi1, const void *vmtbi2)
-{
- CustomButtonData *mtbi1 = (CustomButtonData *) * ((CustomButtonData **)vmtbi1);
- CustomButtonData *mtbi2 = (CustomButtonData *) * ((CustomButtonData **)vmtbi2);
- if (mtbi1 == NULL || mtbi2 == NULL) return (mtbi1 - mtbi2);
- return mtbi1->dwPosition - mtbi2->dwPosition;
-}
-
-
-static void li_ListDestruct(SortedList *pList, ItemDestuctor pItemDestructor)
-{
- if (!pList) return;
- for (int i=0; i < pList->realCount; i++)
- pItemDestructor(pList->items[i]);
- List_Destroy(pList);
- mir_free(pList);
-}
-
-static void li_RemoveDestruct(SortedList *pList, int index, ItemDestuctor pItemDestructor)
-{
- if (index >= 0 && index < pList->realCount) {
- pItemDestructor(pList->items[index]);
- List_Remove(pList, index);
- }
-}
-
-static void li_RemovePtrDestruct(SortedList *pList, void *ptr, ItemDestuctor pItemDestructor)
-{
- if (List_RemovePtr(pList, ptr))
- pItemDestructor(ptr);
-}
-
-static void li_SortList(SortedList *pList, FSortFunc pSortFunct)
-{
- FSortFunc pOldSort = pList->sortFunc;
- if (!pSortFunct) pSortFunct = pOldSort;
- pList->sortFunc = NULL;
- for (int i=0; i < pList->realCount - 1; i++)
- if (pOldSort(pList->items[i], pList->items[i+1]) < 0) {
- void * temp = pList->items[i];
- pList->items[i] = pList->items[i+1];
- pList->items[i+1] = temp;
- i--;
- if (i > 0) i--;
- }
- pList->sortFunc = pOldSort;
-}
-
-static void listdestructor(void *input)
-{
- CustomButtonData *cbdi = (CustomButtonData *)input;
- if (cbdi->pszModuleName) mir_free(cbdi->pszModuleName);
- if (cbdi->ptszTooltip) mir_free(cbdi->ptszTooltip);
- mir_free(cbdi);
-}
-
-//from "advanced auto away" plugin by P. Boon
-struct RemoveSettings {
- char *szPrefix;
- int count;
- char **szSettings;
-};
-
-static int DBRemoveEnumProc(const char *szSetting, LPARAM lParam)
+static void wipeList(LIST<CustomButtonData> &list)
{
- RemoveSettings *rs = (RemoveSettings *)lParam;
-
- if (!rs->szPrefix || !strncmp(szSetting, rs->szPrefix, strlen(rs->szPrefix))) {
- rs->szSettings = (char **)mir_realloc(rs->szSettings, (rs->count + 1) * sizeof(char *));
- rs->szSettings[rs->count] = _strdup(szSetting);
- rs->count += 1;
+ for (int i = list.getCount()-1; i >= 0; i--) {
+ delete list[i];
+ list.remove(i);
}
- return 0;
}
-static int Hlp_RemoveDatabaseSettings(MCONTACT hContact, char *szModule, char *szPrefix)
+static int sstSortButtons(const void *p1, const void *p2)
{
- RemoveSettings rs;
- int i, count;
-
- ZeroMemory(&rs, sizeof(RemoveSettings));
- rs.szPrefix = szPrefix;
-
- DBCONTACTENUMSETTINGS dbces = { 0 };
- dbces.pfnEnumProc = DBRemoveEnumProc;
- dbces.lParam = (LPARAM)&rs;
- dbces.szModule = szModule;
- if (CallService(MS_DB_CONTACT_ENUMSETTINGS, hContact, (LPARAM)&dbces) == -1)
- return -1;
-
- count = 0;
- if (rs.szSettings != NULL) {
- for (i=0; i < rs.count; i++) {
- if (rs.szSettings[i] != NULL) {
- if (!db_unset(hContact, szModule, rs.szSettings[i])) {
- count += 1;
- }
- mir_free(rs.szSettings[i]);
- }
- }
- mir_free(rs.szSettings);
- }
-
- return count;
+ return (*(CustomButtonData**)p1)->dwPosition - (*(CustomButtonData**)p2)->dwPosition;
}
void CB_InitCustomButtons()
{
- LButtonsList = List_Create(0, 1);
- RButtonsList = List_Create(0, 1);
- InitializeCriticalSection(&ToolBarCS);
dwSepCount = M.GetDword("TabSRMM_Toolbar", "SeparatorsCount", 0);
- //dwSepCount = db_get_dw(NULL, "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);
@@ -153,9 +45,6 @@ void CB_InitCustomButtons()
void CB_DeInitCustomButtons()
{
- DeleteCriticalSection(&ToolBarCS);
- li_ListDestruct(LButtonsList, listdestructor);
- li_ListDestruct(RButtonsList, listdestructor);
DestroyHookableEvent(hHookToolBarLoadedEvt);
DestroyHookableEvent(hHookButtonPressedEvt);
DestroyServiceFunction(hButtonsBarAddButton);
@@ -168,32 +57,30 @@ void CB_DeInitCustomButtons()
void CB_DestroyAllButtons(HWND hwndDlg, TWindowData *dat)
{
HWND hwndBtn = NULL;
- for (int i=0; i < LButtonsList->realCount; i++) {
- CustomButtonData* cbd = (CustomButtonData *)LButtonsList->items[i];
- {
- hwndBtn = GetDlgItem(hwndDlg, cbd->dwButtonCID);
- if (hwndBtn) DestroyWindow(hwndBtn);
- }
+ 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->realCount; i++) {
- CustomButtonData* cbd = (CustomButtonData *)RButtonsList->items[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};
+ RECT rc = { 0 };
if (hwndBtn) {
GetClientRect(hwndBtn, &rc);
- if (dwFlags&BBBF_ISLSIDEBUTTON)
+ if (dwFlags & BBBF_ISLSIDEBUTTON)
dat->bbLSideWidth -= rc.right;
- else if (dwFlags&BBBF_ISRSIDEBUTTON)
+ else if (dwFlags & BBBF_ISRSIDEBUTTON)
dat->bbRSideWidth -= rc.right;
DestroyWindow(hwndBtn);
@@ -210,35 +97,35 @@ void CB_ChangeButton(HWND hwndDlg, TWindowData *dat, CustomButtonData *cbd)
if (cbd->ptszTooltip)
SendMessage(hwndBtn, BUTTONADDTOOLTIP, (WPARAM)cbd->ptszTooltip, BATF_TCHAR);
SendMessage(hwndBtn, BUTTONSETCONTAINER, (LPARAM)dat->pContainer, 0);
- SetWindowTextA(hwndBtn,cbd->pszModuleName);
+ SetWindowTextA(hwndBtn, cbd->pszModuleName);
}
}
void CB_ReInitCustomButtons()
{
- for (int i=0; i < LButtonsList->realCount; i++) {
- CustomButtonData *cbd = (CustomButtonData *)LButtonsList->items[i];
- //GetButtonSettings(NULL,cbd);
- if (cbd->opFlags&BBSF_NTBSWAPED || cbd->opFlags&BBSF_NTBDESTRUCT) {
+ 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))
- List_InsertPtr(RButtonsList, cbd);
+ if (!(cbd->opFlags & BBSF_NTBDESTRUCT))
+ RButtonsList.insert(cbd);
- List_Remove(LButtonsList, i);
+ LButtonsList.remove(i);
i--;
}
}
- for (int i=0; i < RButtonsList->realCount; i++) {
- CustomButtonData* cbd = (CustomButtonData *)RButtonsList->items[i];
- if (cbd->opFlags&BBSF_NTBSWAPED || cbd->opFlags&BBSF_NTBDESTRUCT) {
+ 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;
- if (!(cbd->opFlags&BBSF_NTBDESTRUCT))
- List_InsertPtr(LButtonsList, cbd);
+ if (!(cbd->opFlags & BBSF_NTBDESTRUCT))
+ LButtonsList.insert(cbd);
- List_Remove(RButtonsList, i);
+ RButtonsList.remove(i);
i--;
}
}
@@ -249,12 +136,11 @@ void CB_ReInitCustomButtons()
void CB_HardReInit()
{
M.BroadcastMessage(DM_CBDESTROY, 0, 0);
- EnterCriticalSection(&ToolBarCS);
- li_ListDestruct(LButtonsList, listdestructor);
- li_ListDestruct(RButtonsList, listdestructor);
- LButtonsList = List_Create(0, 1);
- RButtonsList = List_Create(0, 1);
- LeaveCriticalSection(&ToolBarCS);
+ {
+ mir_cslock lck(ToolBarCS);
+ wipeList(LButtonsList);
+ wipeList(RButtonsList);
+ }
LastCID = 4000;
dwSepCount = 0;
@@ -268,10 +154,7 @@ static INT_PTR CB_AddButton(WPARAM, LPARAM lParam)
if (!bbdi || bbdi->cbSize != sizeof(BBButton))
return 1;
- bNeedResort = TRUE;
-
- CustomButtonData *cbd = (CustomButtonData *)mir_alloc(sizeof(CustomButtonData));
- memset(cbd, 0, sizeof(CustomButtonData));
+ CustomButtonData *cbd = new CustomButtonData();
if (!bbdi->iButtonWidth && (bbdi->bbbFlags & BBBF_ISARROWBUTTON))
cbd->iButtonWidth = DPISCALEX_S(34);
@@ -295,23 +178,23 @@ static INT_PTR CB_AddButton(WPARAM, LPARAM lParam)
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) ? 1 : 0;
- cbd->bLSided = (bbdi->bbbFlags & BBBF_ISLSIDEBUTTON) ? 1 : 0;
- cbd->bRSided = (bbdi->bbbFlags & BBBF_ISRSIDEBUTTON) ? 1 : 0;
- cbd->bCanBeHidden = (bbdi->bbbFlags & BBBF_CANBEHIDDEN) ? 1 : 0;
- cbd->bDummy = (bbdi->bbbFlags & BBBF_ISDUMMYBUTTON) ? 1 : 0;
- cbd->bChatButton = (bbdi->bbbFlags & BBBF_ISCHATBUTTON) ? 1 : 0;
- cbd->bIMButton = (bbdi->bbbFlags & BBBF_ISIMBUTTON) ? 1 : 0;
- cbd->bDisabled = (bbdi->bbbFlags & BBBF_DISABLED) ? 1 : 0;
- cbd->bPushButton = (bbdi->bbbFlags & BBBF_ISPUSHBUTTON) ? 1 : 0;
+ 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;
CB_GetButtonSettings(NULL, cbd);
if (cbd->bLSided)
- List_InsertPtr(LButtonsList, cbd);
+ LButtonsList.insert(cbd);
else if (cbd->bRSided)
- List_InsertPtr(RButtonsList, cbd);
+ RButtonsList.insert(cbd);
else return 1;
if (cbd->dwButtonCID != cbd->dwButtonOrigID)
@@ -325,23 +208,23 @@ static INT_PTR CB_AddButton(WPARAM, LPARAM lParam)
static INT_PTR CB_GetButtonState(WPARAM wParam, LPARAM lParam)
{
- if(wParam == 0 || lParam == 0)
+ if (wParam == 0 || lParam == 0)
return 1;
DWORD tempCID = 0;
bool realbutton = false;
BBButton *bbdi = (BBButton *)lParam;
bbdi->bbbFlags = 0;
- for (int i=0; i < LButtonsList->realCount; i++) {
- CustomButtonData *cbd = (CustomButtonData *)LButtonsList->items[i];
+ for (int i = 0; i < LButtonsList.getCount(); i++) {
+ CustomButtonData *cbd = LButtonsList[i];
if (!strcmp(cbd->pszModuleName, bbdi->pszModuleName) && (cbd->dwButtonOrigID == bbdi->dwButtonID)) {
realbutton = true;
tempCID = cbd->dwButtonCID;
}
}
if (!realbutton)
- for (int i=0; i < RButtonsList->realCount; i++) {
- CustomButtonData* cbd = (CustomButtonData *)RButtonsList->items[i];
+ for (int i = 0; i < RButtonsList.getCount(); i++) {
+ CustomButtonData* cbd = RButtonsList[i];
if (!strcmp(cbd->pszModuleName, bbdi->pszModuleName) && (cbd->dwButtonOrigID == bbdi->dwButtonID)) {
realbutton = true;
tempCID = cbd->dwButtonCID;
@@ -350,9 +233,11 @@ static INT_PTR CB_GetButtonState(WPARAM wParam, LPARAM lParam)
if (!realbutton)
return 1;
+
HWND hwndDlg = M.FindWindow(wParam);
- if(!hwndDlg)
+ if (!hwndDlg)
return 1;
+
HWND hwndBtn = GetDlgItem(hwndDlg, tempCID);
bbdi->bbbFlags = (IsDlgButtonChecked(hwndDlg, tempCID) ? BBSF_PUSHED : BBSF_RELEASED) | (IsWindowVisible(hwndBtn) ? 0 : BBSF_HIDDEN) | (IsWindowEnabled(hwndBtn) ? 0 : BBSF_DISABLED);
return 0;
@@ -360,22 +245,22 @@ static INT_PTR CB_GetButtonState(WPARAM wParam, LPARAM lParam)
static INT_PTR CB_SetButtonState(WPARAM wParam, LPARAM lParam)
{
- if(wParam == 0 || lParam == 0)
+ if (wParam == 0 || lParam == 0)
return 1;
bool realbutton = false;
DWORD tempCID = 0;
BBButton *bbdi = (BBButton *)lParam;
- for (int i=0; i < LButtonsList->realCount; i++) {
- CustomButtonData *cbd = (CustomButtonData *)LButtonsList->items[i];
+ for (int i = 0; i < LButtonsList.getCount(); i++) {
+ CustomButtonData *cbd = LButtonsList[i];
if (!strcmp(cbd->pszModuleName, bbdi->pszModuleName) && (cbd->dwButtonOrigID == bbdi->dwButtonID)) {
realbutton = true;
tempCID = cbd->dwButtonCID;
}
}
if (!realbutton)
- for (int i=0; i < RButtonsList->realCount; i++) {
- CustomButtonData* cbd = (CustomButtonData *)RButtonsList->items[i];
+ for (int i = 0; i < RButtonsList.getCount(); i++) {
+ CustomButtonData* cbd = RButtonsList[i];
if (!strcmp(cbd->pszModuleName, bbdi->pszModuleName) && (cbd->dwButtonOrigID == bbdi->dwButtonID)) {
realbutton = true;
tempCID = cbd->dwButtonCID;
@@ -386,7 +271,7 @@ static INT_PTR CB_SetButtonState(WPARAM wParam, LPARAM lParam)
return 1;
HWND hwndDlg = M.FindWindow(wParam);
- if(!hwndDlg)
+ if (!hwndDlg)
return 1;
SetDlgItemTextA(hwndDlg, tempCID, bbdi->pszModuleName);
@@ -411,35 +296,30 @@ static INT_PTR CB_RemoveButton(WPARAM, LPARAM lParam)
DWORD tempCID = 0;
DWORD dwFlags = 0;
+ {
+ mir_cslock lck(ToolBarCS);
- EnterCriticalSection(&ToolBarCS);
- for (int i=0; i < LButtonsList->realCount; i++) {
- CustomButtonData *cbd = (CustomButtonData *)LButtonsList->items[i];
- if (!strcmp(cbd->pszModuleName, bbdi->pszModuleName) && (cbd->dwButtonOrigID == bbdi->dwButtonID)) {
- tempCID = cbd->dwButtonCID;
- dwFlags = cbd->bLSided ? BBBF_ISLSIDEBUTTON : BBBF_ISRSIDEBUTTON;
- List_Remove(LButtonsList, i);
- i--;
- }
- }
- if (tempCID)
- qsort(LButtonsList->items, LButtonsList->realCount, sizeof(CustomButtonData *), sstSortButtons);
-
- if (!tempCID) {
- for (int i=0; i < RButtonsList->realCount; i++) {
- CustomButtonData *cbd = (CustomButtonData *)RButtonsList->items[i];
- if (!strcmp(cbd->pszModuleName, bbdi->pszModuleName) && (cbd->dwButtonOrigID == bbdi->dwButtonID)) {
+ 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;
- List_Remove(RButtonsList, i);
- i--;
+ LButtonsList.remove(i);
+ }
+ }
+
+ 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;
+ RButtonsList.remove(i);
+ }
}
}
- if (tempCID)
- qsort(RButtonsList->items, RButtonsList->realCount, sizeof(CustomButtonData *), sstSortButtons);
}
- LeaveCriticalSection(&ToolBarCS);
if (tempCID)
M.BroadcastMessage(DM_CBDESTROY, (WPARAM)tempCID, (LPARAM)dwFlags);
return 0;
@@ -448,52 +328,54 @@ static INT_PTR CB_RemoveButton(WPARAM, LPARAM lParam)
static INT_PTR CB_ModifyButton(WPARAM, LPARAM lParam)
{
BBButton *bbdi = (BBButton *)lParam;
- if(!bbdi)
+ if (!bbdi)
return 1;
bool bFound = 1;
CustomButtonData *cbd = NULL;
- EnterCriticalSection(&ToolBarCS);
- for (int i=0; i < LButtonsList->realCount; i++) {
- cbd = (CustomButtonData *)LButtonsList->items[i];
- if (!strcmp(cbd->pszModuleName, bbdi->pszModuleName) && (cbd->dwButtonOrigID == bbdi->dwButtonID)) {
- bFound = true;
- break;
- }
- }
+ {
+ mir_cslock lck(ToolBarCS);
- if (!bFound) {
- cbd = NULL;
- for (int i=0; i < RButtonsList->realCount; i++) {
- cbd = (CustomButtonData *)RButtonsList->items[i];
+ for (int i = 0; i < LButtonsList.getCount(); i++) {
+ cbd = LButtonsList[i];
if (!strcmp(cbd->pszModuleName, bbdi->pszModuleName) && (cbd->dwButtonOrigID == bbdi->dwButtonID)) {
bFound = true;
break;
}
}
- }
- if (bFound) {
- if (bbdi->pszTooltip) {
- if (cbd->ptszTooltip) mir_free(cbd->ptszTooltip);
- if (bbdi->bbbFlags&BBBF_ANSITOOLTIP)
- cbd->ptszTooltip = mir_a2u(bbdi->pszTooltip);
- else
- cbd->ptszTooltip = mir_tstrdup(bbdi->ptszTooltip);
+ if (!bFound) {
+ for (int i = 0; i < RButtonsList.getCount(); i++) {
+ cbd = RButtonsList[i];
+ if (!strcmp(cbd->pszModuleName, bbdi->pszModuleName) && (cbd->dwButtonOrigID == bbdi->dwButtonID)) {
+ bFound = true;
+ break;
+ }
+ }
}
- if (bbdi->hIcon)
- cbd->hIcon = bbdi->hIcon;
- if (bbdi->bbbFlags) {
- cbd->bHidden = (bbdi->bbbFlags & BBBF_HIDDEN) ? 1 : 0;
- cbd->bLSided = (bbdi->bbbFlags & BBBF_ISLSIDEBUTTON) ? 1 : 0;
- cbd->bRSided = (bbdi->bbbFlags & BBBF_ISRSIDEBUTTON) ? 1 : 0;
- cbd->bCanBeHidden = (bbdi->bbbFlags & BBBF_CANBEHIDDEN) ? 1 : 0;
- cbd->bChatButton = (bbdi->bbbFlags & BBBF_ISCHATBUTTON) ? 1 : 0;
- cbd->bIMButton = (bbdi->bbbFlags & BBBF_ISIMBUTTON) ? 1 : 0;
- cbd->bDisabled = (bbdi->bbbFlags & BBBF_DISABLED) ? 1 : 0;
+
+ if (bFound) {
+ if (bbdi->pszTooltip) {
+ mir_free(cbd->ptszTooltip);
+ if (bbdi->bbbFlags & BBBF_ANSITOOLTIP)
+ cbd->ptszTooltip = mir_a2u(bbdi->pszTooltip);
+ else
+ cbd->ptszTooltip = mir_tstrdup(bbdi->ptszTooltip);
+ }
+ if (bbdi->hIcon)
+ cbd->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;
+ }
}
}
- LeaveCriticalSection(&ToolBarCS);
+
if (bFound)
M.BroadcastMessage(DM_BBNEEDUPDATE, 0, (LPARAM)cbd);
return 0;
@@ -503,11 +385,10 @@ void BB_UpdateIcons(HWND hdlg, TWindowData *dat)
{
HWND hwndBtn = NULL;
- qsort(LButtonsList->items, LButtonsList->realCount, sizeof(CustomButtonData *), sstSortButtons);
- for (int i=0; i < LButtonsList->realCount; i++) {
- CustomButtonData *cbd = (CustomButtonData *)LButtonsList->items[i];
+ for (int i = 0; i < LButtonsList.getCount(); i++) {
+ CustomButtonData *cbd = LButtonsList[i];
if (cbd) {
- if (!cbd->bDummy)
+ if (!cbd->bSeparator)
hwndBtn = GetDlgItem(hdlg, cbd->dwButtonCID);
if (hwndBtn && cbd->hIcon)
@@ -516,11 +397,10 @@ void BB_UpdateIcons(HWND hdlg, TWindowData *dat)
}
hwndBtn = NULL;
- qsort(RButtonsList->items, RButtonsList->realCount, sizeof(CustomButtonData *), sstSortButtons);
- for (int i=0; i < RButtonsList->realCount; i++) {
- CustomButtonData *cbd = (CustomButtonData *)RButtonsList->items[i];
+ for (int i = 0; i < RButtonsList.getCount(); i++) {
+ CustomButtonData *cbd = RButtonsList[i];
if (cbd) {
- if (!cbd->bDummy)
+ if (!cbd->bSeparator)
hwndBtn = GetDlgItem(hdlg, cbd->dwButtonCID);
if (hwndBtn && cbd->hIcon)
@@ -534,20 +414,19 @@ void TSAPI BB_InitDlgButtons(TWindowData *dat)
RECT rect;
int i;
int lwidth = 0, rwidth = 0;
- HWND hwndBtn = NULL;
RECT rcSplitter;
POINT ptSplitter;
int splitterY;
BYTE gap = DPISCALEX_S(PluginConfig.g_iButtonsBarGap);
BOOL isThemed = TRUE;
int cx = 0, cy = 0;
- int lcount = LButtonsList->realCount;
- int rcount = RButtonsList->realCount;
+ int lcount = LButtonsList.getCount();
+ int rcount = RButtonsList.getCount();
HWND hdlg = dat->hwnd;
- if (dat == 0 || hdlg == 0) {return;}
+ if (dat == 0 || hdlg == 0) { return; }
if (CSkin::m_skinEnabled && !SkinItems[ID_EXTBKBUTTONSNPRESSED].IGNORED &&
- !SkinItems[ID_EXTBKBUTTONSPRESSED].IGNORED && !SkinItems[ID_EXTBKBUTTONSMOUSEOVER].IGNORED) {
+ !SkinItems[ID_EXTBKBUTTONSPRESSED].IGNORED && !SkinItems[ID_EXTBKBUTTONSMOUSEOVER].IGNORED) {
isThemed = FALSE;
}
@@ -559,21 +438,20 @@ void TSAPI BB_InitDlgButtons(TWindowData *dat)
GetClientRect(hdlg, &rect);
splitterY = ptSplitter.y - DPISCALEY_S(1);
- hwndBtn = NULL;
- qsort(RButtonsList->items, RButtonsList->realCount, sizeof(CustomButtonData *), sstSortButtons);
- for (i=0; i < RButtonsList->realCount; i++) {
- CustomButtonData* cbd = (CustomButtonData *)RButtonsList->items[i];
- if (((dat->bType == SESSIONTYPE_IM && cbd->bIMButton)
- || (dat->bType == SESSIONTYPE_CHAT && cbd->bChatButton))) {
+ HWND hwndBtn = NULL;
+
+ for (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->bDummy && !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);
+ 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->bDummy && hwndBtn) {
+ if (!cbd->bSeparator && hwndBtn) {
SendMessage(hwndBtn, BUTTONSETASFLATBTN, TRUE, 0);
SendMessage(hwndBtn, BUTTONSETASTHEMEDBTN, isThemed != 0, 0);
if (cbd->hIcon)
@@ -588,7 +466,8 @@ void TSAPI BB_InitDlgButtons(TWindowData *dat)
if (hwndBtn && cbd->bPushButton)
SendMessage(hwndBtn, BUTTONSETASPUSHBTN, TRUE, 0);
}
- } else if (GetDlgItem(hdlg, cbd->dwButtonCID))
+ }
+ else if (GetDlgItem(hdlg, cbd->dwButtonCID))
DestroyWindow(GetDlgItem(hdlg, cbd->dwButtonCID));
if (cbd->bDisabled)
@@ -599,21 +478,20 @@ void TSAPI BB_InitDlgButtons(TWindowData *dat)
}
hwndBtn = NULL;
- qsort(LButtonsList->items, LButtonsList->realCount, sizeof(CustomButtonData *), sstSortButtons);
- for (i=0; i < LButtonsList->realCount; i++) {
- CustomButtonData* cbd = (CustomButtonData *)LButtonsList->items[i];
- if (((dat->bType == SESSIONTYPE_IM && cbd->bIMButton)
- || (dat->bType == SESSIONTYPE_CHAT && cbd->bChatButton))) {
- if (!cbd->bDummy && !GetDlgItem(hdlg, cbd->dwButtonCID)) {
+
+ for (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);
+ 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->bDummy && hwndBtn) {
+ if (!cbd->bSeparator && hwndBtn) {
SendMessage(hwndBtn, BUTTONSETASFLATBTN, TRUE, 0);
SendMessage(hwndBtn, BUTTONSETASTHEMEDBTN, isThemed != 0, 0);
if (cbd->hIcon)
@@ -628,7 +506,8 @@ void TSAPI BB_InitDlgButtons(TWindowData *dat)
if (hwndBtn && cbd->bPushButton)
SendMessage(hwndBtn, BUTTONSETASPUSHBTN, TRUE, 0);
}
- } else if (GetDlgItem(hdlg, cbd->dwButtonCID))
+ }
+ else if (GetDlgItem(hdlg, cbd->dwButtonCID))
DestroyWindow(GetDlgItem(hdlg, cbd->dwButtonCID));
if (cbd->bDisabled)
@@ -643,26 +522,20 @@ void TSAPI BB_InitDlgButtons(TWindowData *dat)
void TSAPI BB_RedrawButtons(TWindowData *dat)
{
- int i;
- CustomButtonData* cbd;
- HWND hwnd;
-
- for (i=0; i < LButtonsList->realCount; i++) {
- cbd = reinterpret_cast<CustomButtonData *>(LButtonsList->items[i]);
- if (cbd) {
- hwnd = GetDlgItem(dat->hwnd, cbd->dwButtonCID);
- if (hwnd)
- InvalidateRect(hwnd, 0, TRUE);
- }
+ 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 (i=0; i < RButtonsList->realCount; i++) {
- cbd = reinterpret_cast<CustomButtonData *>(RButtonsList->items[i]);
- if (cbd) {
- 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);
@@ -677,17 +550,17 @@ BOOL TSAPI BB_SetButtonsPos(TWindowData *dat)
RECT rect;
int i;
HWND hwndBtn = 0;
-
+
BYTE gap = DPISCALEX_S(PluginConfig.g_iButtonsBarGap);
bool showToolbar = !(dat->pContainer->dwFlags & CNT_HIDETOOLBAR);
bool bBottomToolbar = (dat->pContainer->dwFlags & CNT_BOTTOMTOOLBAR) != 0;
- HDWP hdwp = BeginDeferWindowPos(LButtonsList->realCount + RButtonsList->realCount + 1);
+ HDWP hdwp = BeginDeferWindowPos(LButtonsList.getCount() + RButtonsList.getCount() + 1);
HWND hwndToggleSideBar = GetDlgItem(dat->hwnd, dat->bType == SESSIONTYPE_IM ? IDC_TOGGLESIDEBAR : IDC_CHAT_TOGGLESIDEBAR);
ShowWindow(hwndToggleSideBar, (showToolbar && dat->pContainer->SideBar->isActive()) ? SW_SHOW : SW_HIDE);
- EnterCriticalSection(&ToolBarCS);
+ mir_cslock lck(ToolBarCS);
RECT rcSplitter;
GetWindowRect(GetDlgItem(hwnd, (dat->bType == SESSIONTYPE_IM) ? IDC_SPLITTER : IDC_SPLITTERY), &rcSplitter);
@@ -706,24 +579,21 @@ BOOL TSAPI BB_SetButtonsPos(TWindowData *dat)
if ((rect.bottom - ptSplitter.y - (rcSplitter.bottom - rcSplitter.top) /*- DPISCALEY(2)*/ - (bBottomToolbar ? DPISCALEY_S(24) : 0) < dat->pic.cy - DPISCALEY_S(2)) && dat->showPic && !PluginConfig.m_AlwaysFullToolbarWidth)
foravatar = dat->pic.cx + gap;
- if (bNeedResort)
- qsort(LButtonsList->items, LButtonsList->realCount, sizeof(BBButton *), sstSortButtons);
-
if ((dat->pContainer->dwFlags & CNT_SIDEBAR) && (dat->pContainer->SideBar->getFlags() & CSideBar::SIDEBARORIENTATION_LEFT)) {
- DeferWindowPos(hdwp, hwndToggleSideBar , NULL, 4, 2 + splitterY - iOff, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
+ DeferWindowPos(hdwp, hwndToggleSideBar, NULL, 4, 2 + splitterY - iOff, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
lwidth += 10;
tempL -= 10;
}
- for (i=0; i < LButtonsList->realCount; i++) {
- CustomButtonData* cbd = (CustomButtonData *)LButtonsList->items[i];
+ 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);
- DeferWindowPos(hdwp, hwndBtn , NULL, lwidth, splitterY - iOff, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
- if (IsWindowVisible(hwndBtn) || (cbd->bDummy && !(cbd->bAutoHidden || cbd->bHidden)))
+ 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;
@@ -734,10 +604,10 @@ BOOL TSAPI BB_SetButtonsPos(TWindowData *dat)
cbd->bAutoHidden = 0;
}
- if (!cbd->bDummy && !IsWindowVisible(hwndBtn) && !IsWindowEnabled(hwndBtn) && !cbd->bAutoHidden)
+ if (!cbd->bSeparator && !IsWindowVisible(hwndBtn) && !IsWindowEnabled(hwndBtn) && !cbd->bAutoHidden)
tempL -= cbd->iButtonWidth + gap;
- if (cbd->bCanBeHidden && !cbd->bHidden && (cbd->bDummy || !((!IsWindowEnabled(hwndBtn) && !IsWindowVisible(hwndBtn)) && !cbd->bAutoHidden))) {
+ 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;
@@ -748,33 +618,28 @@ BOOL TSAPI BB_SetButtonsPos(TWindowData *dat)
cbd->bAutoHidden = 0;
}
}
- DeferWindowPos(hdwp, hwndBtn , NULL, lwidth, splitterY - iOff, 0, 0, SWP_NOZORDER | SWP_NOSIZE);// SWP_NOCOPYBITS);
- if (IsWindowVisible(hwndBtn) || (cbd->bDummy && !(cbd->bAutoHidden || cbd->bHidden)))
+ 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 (bNeedResort) {
- qsort(RButtonsList->items, RButtonsList->realCount, sizeof(CustomButtonData *), sstSortButtons);
- bNeedResort = FALSE;
- }
-
if ((dat->pContainer->dwFlags & CNT_SIDEBAR) && (dat->pContainer->SideBar->getFlags() & CSideBar::SIDEBARORIENTATION_RIGHT)) {
- DeferWindowPos(hdwp, hwndToggleSideBar , NULL, rect.right - foravatar - 10, 2 + splitterY - iOff, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
+ 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->realCount; i++) {
- CustomButtonData* cbd = (CustomButtonData *)RButtonsList->items[i];
+ 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->bDummy && !(cbd->bAutoHidden || cbd->bHidden)))
+ if (IsWindowVisible(hwndBtn) || (cbd->bSeparator && !(cbd->bAutoHidden || cbd->bHidden)))
rwidth += cbd->iButtonWidth + gap;
- DeferWindowPos(hdwp, hwndBtn , NULL, rect.right - foravatar - rwidth + gap, splitterY - iOff, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
+ 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;
@@ -784,10 +649,10 @@ BOOL TSAPI BB_SetButtonsPos(TWindowData *dat)
cbd->bAutoHidden = 0;
}
- if (!cbd->bDummy && !IsWindowVisible(hwndBtn) && !IsWindowEnabled(hwndBtn) && !cbd->bAutoHidden)
+ if (!cbd->bSeparator && !IsWindowVisible(hwndBtn) && !IsWindowEnabled(hwndBtn) && !cbd->bAutoHidden)
tempR -= cbd->iButtonWidth + gap;
- if (cbd->bCanBeHidden && !cbd->bHidden && (cbd->bDummy || !((!IsWindowEnabled(hwndBtn) && !IsWindowVisible(hwndBtn)) && !cbd->bAutoHidden))) {
+ 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;
@@ -799,14 +664,12 @@ BOOL TSAPI BB_SetButtonsPos(TWindowData *dat)
}
}
- if (IsWindowVisible(hwndBtn) || (cbd->bDummy && !(cbd->bAutoHidden || cbd->bHidden)))
+ if (IsWindowVisible(hwndBtn) || (cbd->bSeparator && !(cbd->bAutoHidden || cbd->bHidden)))
rwidth += cbd->iButtonWidth + gap;
- DeferWindowPos(hdwp, hwndBtn , NULL, rect.right - foravatar - rwidth + gap, splitterY - iOff, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
+ DeferWindowPos(hdwp, hwndBtn, NULL, rect.right - foravatar - rwidth + gap, splitterY - iOff, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
}
}
- LeaveCriticalSection(&ToolBarCS);
-
return EndDeferWindowPos(hdwp);
}
@@ -815,18 +678,19 @@ void TSAPI BB_CustomButtonClick(TWindowData *dat, DWORD idFrom, HWND hwndFrom, B
RECT rc;
int i;
BOOL bFromArrow = 0;
- CustomButtonClickData cbcd = {0};
+ CustomButtonClickData cbcd = { 0 };
GetWindowRect(hwndFrom, &rc);
cbcd.pt.x = rc.left;
cbcd.pt.y = rc.bottom;
- for (i=0; i < LButtonsList->realCount; i++) {
- CustomButtonData* cbd = (CustomButtonData *)LButtonsList->items[i];
+ 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) {
+ }
+ else if (cbd->dwArrowCID == idFrom) {
bFromArrow = 1;
cbcd.pszModule = cbd->pszModuleName;
cbcd.dwButtonId = cbd->dwButtonOrigID;
@@ -834,16 +698,17 @@ void TSAPI BB_CustomButtonClick(TWindowData *dat, DWORD idFrom, HWND hwndFrom, B
}
if (!cbcd.pszModule)
- for (i=0; i < RButtonsList->realCount; i++) {
- CustomButtonData* cbd = (CustomButtonData *)RButtonsList->items[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;
- }
+ 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);
@@ -857,8 +722,8 @@ void TSAPI BB_CustomButtonClick(TWindowData *dat, DWORD idFrom, HWND hwndFrom, B
void CB_GetButtonSettings(MCONTACT hContact, CustomButtonData *cbd)
{
- DBVARIANT dbv = {0};
- char SettingName[1024] = {'\0'};
+ DBVARIANT dbv = { 0 };
+ char SettingName[1024] = { '\0' };
char* token = NULL;
//modulename_buttonID, position_inIM_inCHAT_isLSide_isRSide_CanBeHidden
@@ -869,15 +734,15 @@ void CB_GetButtonSettings(MCONTACT hContact, CustomButtonData *cbd)
token = strtok(dbv.pszVal, "_");
cbd->dwPosition = (DWORD)atoi(token);
token = strtok(NULL, "_");
- cbd->bIMButton = (BOOL)atoi(token);
+ cbd->bIMButton = atoi(token) != 0;
token = strtok(NULL, "_");
- cbd->bChatButton = (BOOL)atoi(token);
+ cbd->bChatButton = atoi(token) != 0;
token = strtok(NULL, "_");
- cbd->bLSided = (BOOL)atoi(token);
+ cbd->bLSided = atoi(token) != 0;
token = strtok(NULL, "_");
- cbd->bRSided = (BOOL)atoi(token);
+ cbd->bRSided = atoi(token) != 0;
token = strtok(NULL, "_");
- cbd->bCanBeHidden = (BOOL)atoi(token);
+ cbd->bCanBeHidden = atoi(token) != 0;
db_free(&dbv);
}
@@ -885,14 +750,14 @@ void CB_GetButtonSettings(MCONTACT hContact, CustomButtonData *cbd)
void CB_WriteButtonSettings(MCONTACT hContact, CustomButtonData *cbd)
{
- char SettingName[1024] = {'\0'};
- char SettingParameter[1024] = {'\0'};
+ char SettingName[1024] = { '\0' };
+ char SettingParameter[1024] = { '\0' };
//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))
+ if (!(cbd->opFlags & BBSF_NTBDESTRUCT))
db_set_s(hContact, "TabSRMM_Toolbar", SettingName, SettingParameter);
else
db_unset(hContact, "TabSRMM_Toolbar", SettingName);
@@ -900,7 +765,7 @@ void CB_WriteButtonSettings(MCONTACT hContact, CustomButtonData *cbd)
void BB_RegisterSeparators()
{
- BBButton bbd = {0};
+ BBButton bbd = { 0 };
DWORD i = 0;
bbd.cbSize = sizeof(BBButton);
bbd.pszModuleName = "Tabsrmm_sep";
@@ -914,21 +779,19 @@ void BB_RegisterSeparators()
void BB_RefreshTheme(const TWindowData *dat)
{
- int i;
-
- for (i=0; i < RButtonsList->realCount; i++) {
- CustomButtonData* cbd = (CustomButtonData *)RButtonsList->items[i];
+ for (int i = 0; i < RButtonsList.getCount(); i++) {
+ CustomButtonData* cbd = RButtonsList[i];
SendMessage(GetDlgItem(dat->hwnd, cbd->dwButtonCID), WM_THEMECHANGED, 0, 0);
}
- for (i=0; i < LButtonsList->realCount; i++) {
- CustomButtonData* cbd = (CustomButtonData *)LButtonsList->items[i];
+ for (int i = 0; i < LButtonsList.getCount(); i++) {
+ CustomButtonData* cbd = LButtonsList[i];
SendMessage(GetDlgItem(dat->hwnd, cbd->dwButtonCID), WM_THEMECHANGED, 0, 0);
}
}
void CB_InitDefaultButtons()
{
- BBButton bbd = {0};
+ BBButton bbd = { 0 };
bbd.cbSize = sizeof(BBButton);
bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISLSIDEBUTTON | BBBF_ISARROWBUTTON | BBBF_CREATEBYID;
bbd.dwButtonID = IDC_PROTOCOL;
@@ -936,16 +799,13 @@ void CB_InitDefaultButtons()
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) {
@@ -963,7 +823,6 @@ void CB_InitDefaultButtons()
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;
@@ -971,7 +830,6 @@ void CB_InitDefaultButtons()
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;
@@ -979,7 +837,6 @@ void CB_InitDefaultButtons()
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;
@@ -987,7 +844,6 @@ void CB_InitDefaultButtons()
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;
@@ -995,17 +851,14 @@ void CB_InitDefaultButtons()
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;
@@ -1014,7 +867,6 @@ void CB_InitDefaultButtons()
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;
@@ -1023,7 +875,6 @@ void CB_InitDefaultButtons()
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;
@@ -1032,7 +883,6 @@ void CB_InitDefaultButtons()
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;
@@ -1041,7 +891,6 @@ void CB_InitDefaultButtons()
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;
@@ -1050,7 +899,6 @@ void CB_InitDefaultButtons()
bbd.iButtonWidth = 0;
bbd.hIcon = PluginConfig.g_buttonBarIconHandles[7];
bbd.ptszTooltip = LPGENT("Edit user notes");
-
CB_AddButton(0, (LPARAM)&bbd);
//chat buttons
@@ -1062,7 +910,6 @@ void CB_InitDefaultButtons()
bbd.iButtonWidth = 22;
bbd.hIcon = 0;
bbd.pszTooltip = 0;
-
CB_AddButton(0, (LPARAM)&bbd);
bbd.bbbFlags = BBBF_ISCHATBUTTON | BBBF_ISLSIDEBUTTON | BBBF_ISDUMMYBUTTON;
@@ -1071,17 +918,14 @@ void CB_InitDefaultButtons()
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;
@@ -1091,9 +935,7 @@ void CB_InitDefaultButtons()
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;
@@ -1101,7 +943,6 @@ void CB_InitDefaultButtons()
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;
@@ -1110,7 +951,6 @@ void CB_InitDefaultButtons()
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;
@@ -1119,10 +959,8 @@ void CB_InitDefaultButtons()
bbd.iButtonWidth = 22;
bbd.hIcon = PluginConfig.g_buttonBarIconHandles[17];
bbd.ptszTooltip = LPGENT("Channel manager");
-
CB_AddButton(0, (LPARAM)&bbd);
-
BB_RegisterSeparators();
}
@@ -1130,76 +968,80 @@ void CB_InitDefaultButtons()
static int SaveTree(HWND hToolBarTree)
{
- TVITEM tvi;
- HTREEITEM hItem = NULL;
- BOOL RSide = FALSE;
+ bool RSide = false;
int count = 10;
DWORD loc_sepcout = 0;
TCHAR strbuf[128];
- CustomButtonData* cbd = NULL;
+ TVITEM tvi;
tvi.mask = TVIF_TEXT | TVIF_PARAM | TVIF_HANDLE;
tvi.hItem = TreeView_GetRoot(hToolBarTree);
tvi.pszText = strbuf;
tvi.cchTextMax = sizeof(strbuf);
- EnterCriticalSection(&ToolBarCS);
- while (tvi.hItem != NULL) {
+ {
+ mir_cslock lck(ToolBarCS);
- TreeView_GetItem(hToolBarTree, &tvi);
+ while (tvi.hItem != NULL) {
+ TreeView_GetItem(hToolBarTree, &tvi);
- if (_tcscmp(tvi.pszText, MIDDLE_SEPARATOR) == 0) {
- RSide = TRUE;
- count = TreeView_GetCount(hToolBarTree) * 10 - count;
- tvi.hItem = TreeView_GetNextSibling(hToolBarTree, tvi.hItem);
- continue;
- }
- cbd = (CustomButtonData*)tvi.lParam;
- if (cbd) {
- if (cbd->opFlags) {
- cbd->bIMButton = (cbd->opFlags & BBSF_IMBUTTON) ? 1 : 0;
- cbd->bChatButton = (cbd->opFlags & BBSF_CHATBUTTON) ? 1 : 0;
- cbd->bCanBeHidden = (cbd->opFlags & BBSF_CANBEHIDDEN) ? 1 : 0;
- }
- if (RSide && cbd->bLSided) {
- cbd->bLSided = FALSE;
- cbd->bRSided = TRUE;
- cbd->opFlags |= BBSF_NTBSWAPED;
- } else if (!RSide && cbd->bRSided) {
- cbd->bLSided = TRUE;
- cbd->bRSided = FALSE;
- cbd->opFlags |= BBSF_NTBSWAPED;
+ if (_tcscmp(tvi.pszText, MIDDLE_SEPARATOR) == 0) {
+ RSide = true;
+ count = TreeView_GetCount(hToolBarTree) * 10 - count;
+ tvi.hItem = TreeView_GetNextSibling(hToolBarTree, tvi.hItem);
+ continue;
}
- if (!TreeView_GetCheckState(hToolBarTree, tvi.hItem)) {
- cbd->bIMButton = FALSE;
- cbd->bChatButton = FALSE;
-
- if (cbd->bDummy && !strcmp(cbd->pszModuleName, "Tabsrmm_sep"))
- cbd->opFlags = BBSF_NTBDESTRUCT;
- } else {
- if (!cbd->bIMButton && !cbd->bChatButton)
- cbd->bIMButton = TRUE;
- if (cbd->bDummy && !strcmp(cbd->pszModuleName, "Tabsrmm_sep")) {
- cbd->bHidden = 0;
- cbd->opFlags &= ~BBSF_NTBDESTRUCT;
- ++loc_sepcout;
+ 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 (RSide && cbd->bLSided) {
+ cbd->bLSided = false;
+ cbd->bRSided = true;
+ cbd->opFlags |= BBSF_NTBSWAPED;
+ }
+ else if (!RSide && cbd->bRSided) {
+ cbd->bLSided = true;
+ cbd->bRSided = false;
+ cbd->opFlags |= BBSF_NTBSWAPED;
+ }
+ if (!TreeView_GetCheckState(hToolBarTree, tvi.hItem)) {
+ cbd->bIMButton = false;
+ cbd->bChatButton = false;
+
+ if (cbd->bSeparator && !strcmp(cbd->pszModuleName, "Tabsrmm_sep"))
+ cbd->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;
+ ++loc_sepcout;
+ }
}
- }
- cbd->dwPosition = (DWORD)count;
- CB_WriteButtonSettings(NULL, cbd);
+ cbd->dwPosition = (DWORD)count;
+ CB_WriteButtonSettings(NULL, cbd);
- if (!(cbd->opFlags&BBSF_NTBDESTRUCT))
- (RSide) ? (count -= 10) : (count += 10);
+ if (!(cbd->opFlags & BBSF_NTBDESTRUCT))
+ (RSide) ? (count -= 10) : (count += 10);
+ }
+
+ HTREEITEM hItem = TreeView_GetNextSibling(hToolBarTree, tvi.hItem);
+ if (cbd->opFlags & BBSF_NTBDESTRUCT)
+ TreeView_DeleteItem(hToolBarTree, tvi.hItem);
+ tvi.hItem = hItem;
}
- hItem = TreeView_GetNextSibling(hToolBarTree, tvi.hItem);
- if (cbd->opFlags&BBSF_NTBDESTRUCT)
- TreeView_DeleteItem(hToolBarTree, tvi.hItem);
- tvi.hItem = hItem;
+
+ qsort(LButtonsList.getArray(), LButtonsList.getCount(), sizeof(void*), sstSortButtons);
+ qsort(RButtonsList.getArray(), RButtonsList.getCount(), sizeof(void*), sstSortButtons);
}
- LeaveCriticalSection(&ToolBarCS);
db_set_dw(0, "TabSRMM_Toolbar", "SeparatorsCount", loc_sepcout);
dwSepCount = loc_sepcout;
- bNeedResort = TRUE;
return 1;
}
@@ -1207,10 +1049,10 @@ HIMAGELIST himgl = NULL;
static int BuildMenuObjectsTree(HWND hToolBarTree)
{
- TVINSERTSTRUCT tvis;
HTREEITEM hti;
int iImage = 0;
- int i;
+
+ TVINSERTSTRUCT tvis;
tvis.hParent = NULL;
tvis.hInsertAfter = TVI_LAST;
tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_SELECTEDIMAGE | TVIF_IMAGE;
@@ -1219,63 +1061,61 @@ static int BuildMenuObjectsTree(HWND hToolBarTree)
himgl = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 2, 2);
ImageList_AddIcon(himgl, LoadSkinnedIcon(SKINICON_OTHER_SMALLDOT));
- ImageList_Destroy( TreeView_GetImageList(hToolBarTree, TVSIL_NORMAL));
+ ImageList_Destroy(TreeView_GetImageList(hToolBarTree, TVSIL_NORMAL));
TreeView_SetImageList(hToolBarTree, himgl, TVSIL_NORMAL);
- if ((RButtonsList->realCount + LButtonsList->realCount) == 0)
+ if ((RButtonsList.getCount() + LButtonsList.getCount()) == 0)
return FALSE;
- EnterCriticalSection(&ToolBarCS);
- qsort(LButtonsList->items, LButtonsList->realCount, sizeof(CustomButtonData *), sstSortButtons);
+ mir_cslock lck(ToolBarCS);
- for (i=0; i < LButtonsList->realCount; i++) {
- CustomButtonData * cbd = (CustomButtonData *)LButtonsList->items[i];
- tvis.item.lParam = (LPARAM)cbd;
+ for (int i = 0; i < LButtonsList.getCount(); i++) {
+ CustomButtonData *cbd = LButtonsList[i];
+ tvis.item.lParam = (LPARAM)cbd;
- if (cbd->bDummy) {
+ if (cbd->bSeparator) {
tvis.item.pszText = TranslateT("<Separator>");
- tvis.item.iImage = tvis.item.iSelectedImage = 0;
- } else {
+ tvis.item.iImage = tvis.item.iSelectedImage = 0;
+ }
+ else {
tvis.item.pszText = TranslateTS(cbd->ptszTooltip);
iImage = ImageList_AddIcon(himgl, Skin_GetIconByHandle(cbd->hIcon));
- tvis.item.iImage = tvis.item.iSelectedImage = iImage;
+ tvis.item.iImage = tvis.item.iSelectedImage = iImage;
}
cbd->opFlags = 0;
hti = TreeView_InsertItem(hToolBarTree, &tvis);
TreeView_SetCheckState(hToolBarTree, hti, (cbd->bIMButton || cbd->bChatButton));
}
- if (TRUE) {
- tvis.item.lParam = 0;
- tvis.item.mask |= TVIF_STATE;
- tvis.item.pszText = MIDDLE_SEPARATOR;
- tvis.item.stateMask = TVIS_BOLD;
- tvis.item.state = TVIS_BOLD;
- tvis.item.iImage = tvis.item.iSelectedImage = -1;
- hti = TreeView_InsertItem(hToolBarTree, &tvis);
- TreeView_SetCheckState(hToolBarTree, hti, 1);
- }
- qsort(RButtonsList->items, RButtonsList->realCount, sizeof(CustomButtonData *), sstSortButtons);
+ tvis.item.lParam = 0;
+ tvis.item.mask |= TVIF_STATE;
+ tvis.item.pszText = MIDDLE_SEPARATOR;
+ tvis.item.stateMask = TVIS_BOLD;
+ tvis.item.state = TVIS_BOLD;
+ tvis.item.iImage = tvis.item.iSelectedImage = -1;
+ hti = TreeView_InsertItem(hToolBarTree, &tvis);
+ TreeView_SetCheckState(hToolBarTree, hti, 1);
- for (i = RButtonsList->realCount; i > 0; i--) {
- CustomButtonData * cbd = (CustomButtonData *)RButtonsList->items[i-1];
- tvis.item.lParam = (LPARAM)cbd;
+ for (int i = RButtonsList.getCount()-1; i >= 0; i--) {
+ CustomButtonData *cbd = RButtonsList[i];
+ tvis.item.lParam = (LPARAM)cbd;
- if (cbd->bDummy) {
+ if (cbd->bSeparator) {
tvis.item.pszText = TranslateT("<Separator>");
- tvis.item.iImage = tvis.item.iSelectedImage = -1;
- } else {
+ tvis.item.iImage = tvis.item.iSelectedImage = -1;
+ }
+ else {
tvis.item.pszText = TranslateTS(cbd->ptszTooltip);
iImage = ImageList_AddIcon(himgl, Skin_GetIconByHandle(cbd->hIcon));
- tvis.item.iImage = tvis.item.iSelectedImage = iImage;
+ tvis.item.iImage = tvis.item.iSelectedImage = iImage;
}
tvis.item.state = 0;
cbd->opFlags = 0;
hti = TreeView_InsertItem(hToolBarTree, &tvis);
TreeView_SetCheckState(hToolBarTree, hti, (cbd->bIMButton || cbd->bChatButton));
}
- LeaveCriticalSection(&ToolBarCS);
+
return 1;
}
@@ -1299,11 +1139,10 @@ INT_PTR CALLBACK DlgProcToolBar(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
style |= TVS_NOHSCROLL;
SetWindowLongPtr(hToolBarTree, GWL_STYLE, style);
}
- EnterCriticalSection(&ToolBarCS);
-
- BuildMenuObjectsTree((HWND)hToolBarTree);
-
- LeaveCriticalSection(&ToolBarCS);
+ {
+ mir_cslock lck(ToolBarCS);
+ BuildMenuObjectsTree(hToolBarTree);
+ }
Utils::enableDlgControl(hwndDlg, IDC_IMCHECK, FALSE);
Utils::enableDlgControl(hwndDlg, IDC_CHATCHECK, FALSE);
@@ -1322,7 +1161,6 @@ INT_PTR CALLBACK DlgProcToolBar(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
ReleaseCapture();
TVHITTESTINFO hti;
- TVITEM tvi;
hti.pt.x = (short)LOWORD(lParam);
hti.pt.y = (short)HIWORD(lParam);
ClientToScreen(hwndDlg, &hti.pt);
@@ -1330,11 +1168,14 @@ INT_PTR CALLBACK DlgProcToolBar(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
hti.pt.y -= TreeView_GetItemHeight(hToolBarTree) / 2;
TreeView_HitTest(hToolBarTree, &hti);
if (hDragItem == hti.hItem) break;
- if (hti.flags&TVHT_ABOVE) hti.hItem = TVI_FIRST;
+ if (hti.flags & TVHT_ABOVE)
+ hti.hItem = TVI_FIRST;
+
+ TVITEM tvi;
tvi.mask = TVIF_HANDLE | TVIF_PARAM;
tvi.hItem = (HTREEITEM)hDragItem;
TreeView_GetItem(hToolBarTree, &tvi);
- if (hti.flags&(TVHT_ONITEM | TVHT_ONITEMRIGHT) || (hti.hItem == TVI_FIRST)) {
+ if (hti.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT) || (hti.hItem == TVI_FIRST)) {
TVINSERTSTRUCT tvis;
TCHAR strbuf[128];
tvis.item.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_STATE;
@@ -1360,17 +1201,18 @@ INT_PTR CALLBACK DlgProcToolBar(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
ClientToScreen(hwndDlg, &hti.pt);
ScreenToClient(hToolBarTree, &hti.pt);
TreeView_HitTest(hToolBarTree, &hti);
- if (hti.flags&(TVHT_ONITEM | TVHT_ONITEMRIGHT)) {
+ if (hti.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT)) {
HTREEITEM it = hti.hItem;
hti.pt.y -= TreeView_GetItemHeight(hToolBarTree) / 2;
TreeView_HitTest(hToolBarTree, &hti);
- if (!(hti.flags&TVHT_ABOVE))
+ if (!(hti.flags & TVHT_ABOVE))
TreeView_SetInsertMark(hToolBarTree, hti.hItem, 1);
else
TreeView_SetInsertMark(hToolBarTree, it, 0);
- } else {
- if (hti.flags&TVHT_ABOVE) SendMessage(hToolBarTree, WM_VSCROLL, MAKEWPARAM(SB_LINEUP, 0), 0);
- if (hti.flags&TVHT_BELOW) SendMessage(hToolBarTree, WM_VSCROLL, MAKEWPARAM(SB_LINEDOWN, 0), 0);
+ }
+ else {
+ if (hti.flags & TVHT_ABOVE) SendMessage(hToolBarTree, WM_VSCROLL, MAKEWPARAM(SB_LINEUP, 0), 0);
+ if (hti.flags & TVHT_BELOW) SendMessage(hToolBarTree, WM_VSCROLL, MAKEWPARAM(SB_LINEDOWN, 0), 0);
TreeView_SetInsertMark(hToolBarTree, NULL, 0);
}
}
@@ -1385,7 +1227,7 @@ INT_PTR CALLBACK DlgProcToolBar(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
switch (LOWORD(wParam)) {
case IDC_BBRESET:
- Hlp_RemoveDatabaseSettings(NULL, "TabSRMM_Toolbar", 0);
+ CallService(MS_DB_MODULE_DELETE, NULL, LPARAM("TabSRMM_Toolbar"));
CB_HardReInit();
BuildMenuObjectsTree(hToolBarTree);
break;
@@ -1395,18 +1237,13 @@ INT_PTR CALLBACK DlgProcToolBar(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
if (!hti)
hti = TVI_FIRST;
- CustomButtonData *cbd = (CustomButtonData *)mir_alloc(sizeof(CustomButtonData));
- ZeroMemory(cbd, sizeof(CustomButtonData));
-
- cbd->bDummy = 1;
- cbd->bHidden = 1;
- cbd->bIMButton = 1;
- cbd->bLSided = 1;
+ 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;
- List_InsertPtr(LButtonsList, cbd);
+ LButtonsList.insert(cbd);
TVINSERTSTRUCT tvis;
tvis.hParent = NULL;
@@ -1414,8 +1251,8 @@ INT_PTR CALLBACK DlgProcToolBar(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
tvis.item.pszText = TranslateT("<Separator>");
- tvis.item.iImage = tvis.item.iSelectedImage = -1;
- tvis.item.lParam = (LPARAM)cbd;
+ tvis.item.iImage = tvis.item.iSelectedImage = -1;
+ tvis.item.lParam = (LPARAM)cbd;
hti = TreeView_InsertItem(hToolBarTree, &tvis);
TreeView_SetCheckState(hToolBarTree, hti, (cbd->bIMButton || cbd->bChatButton));
@@ -1442,9 +1279,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);
- cbd->bChatButton = IsDlgButtonChecked(hwndDlg, IDC_CHATCHECK);
- cbd->bCanBeHidden = IsDlgButtonChecked(hwndDlg, IDC_CANBEHIDDEN);
+ cbd->bIMButton = IsDlgButtonChecked(hwndDlg, IDC_IMCHECK) != 0;
+ cbd->bChatButton = IsDlgButtonChecked(hwndDlg, IDC_CHATCHECK) != 0;
+ cbd->bCanBeHidden = IsDlgButtonChecked(hwndDlg, IDC_CANBEHIDDEN) != 0;
}
}
}
@@ -1541,7 +1378,7 @@ INT_PTR CALLBACK DlgProcToolBar(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
break;
case NM_CLICK:
- TVHITTESTINFO hti = {0};
+ TVHITTESTINFO hti = { 0 };
GetCursorPos(&hti.pt);
ScreenToClient(hToolBarTree, &hti.pt);
if (TreeView_HitTest(hToolBarTree, &hti)) {
@@ -1552,7 +1389,8 @@ INT_PTR CALLBACK DlgProcToolBar(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
Utils::enableDlgControl(hwndDlg, IDC_CHATCHECK, FALSE);
Utils::enableDlgControl(hwndDlg, IDC_CANBEHIDDEN, FALSE);
CheckDlgButton(hwndDlg, IDC_IMCHECK, 1);
- } else {
+ }
+ else {
Utils::enableDlgControl(hwndDlg, IDC_IMCHECK, TRUE);
Utils::enableDlgControl(hwndDlg, IDC_CHATCHECK, TRUE);
Utils::enableDlgControl(hwndDlg, IDC_CANBEHIDDEN, TRUE);