diff options
39 files changed, 1058 insertions, 1097 deletions
diff --git a/bin10/lib/mir_app.lib b/bin10/lib/mir_app.lib Binary files differindex ff7f2dbd04..f31d787490 100644 --- a/bin10/lib/mir_app.lib +++ b/bin10/lib/mir_app.lib diff --git a/bin10/lib/mir_app64.lib b/bin10/lib/mir_app64.lib Binary files differindex 683da1da67..d653ce9d6e 100644 --- a/bin10/lib/mir_app64.lib +++ b/bin10/lib/mir_app64.lib diff --git a/bin12/lib/mir_app.lib b/bin12/lib/mir_app.lib Binary files differindex ff7f2dbd04..f31d787490 100644 --- a/bin12/lib/mir_app.lib +++ b/bin12/lib/mir_app.lib diff --git a/bin12/lib/mir_app64.lib b/bin12/lib/mir_app64.lib Binary files differindex 683da1da67..d653ce9d6e 100644 --- a/bin12/lib/mir_app64.lib +++ b/bin12/lib/mir_app64.lib diff --git a/bin14/lib/mir_app.lib b/bin14/lib/mir_app.lib Binary files differindex ff7f2dbd04..f31d787490 100644 --- a/bin14/lib/mir_app.lib +++ b/bin14/lib/mir_app.lib diff --git a/bin14/lib/mir_app64.lib b/bin14/lib/mir_app64.lib Binary files differindex 683da1da67..d653ce9d6e 100644 --- a/bin14/lib/mir_app64.lib +++ b/bin14/lib/mir_app64.lib diff --git a/include/m_chat_int.h b/include/m_chat_int.h index 9bc689994d..bf84cd85d2 100644 --- a/include/m_chat_int.h +++ b/include/m_chat_int.h @@ -26,6 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <m_string.h>
#include <m_chat.h>
+#include <m_utils.h>
#define OPTIONS_FONTCOUNT 20
#define STATUSICONCOUNT 6
@@ -387,6 +388,7 @@ struct CHAT_MANAGER FONTINFO aFonts[OPTIONS_FONTCOUNT];
SESSION_INFO *wndList;
char **pLogIconBmpBits;
+ MWindowList hWindowList;
// user-defined custom callbacks
void (*OnCreateModule)(MODULEINFO*);
diff --git a/include/m_message.h b/include/m_message.h index fe80b9c8e8..402c62f880 100644 --- a/include/m_message.h +++ b/include/m_message.h @@ -29,21 +29,21 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. extern int hLangpack;
-//brings up the send message dialog for a contact
-//wParam = (MCONTACT)hContact
-//lParam = (LPARAM)(char*)szText
-//returns 0 on success or nonzero on failure
-//returns immediately, just after the dialog is shown
-//szText is the text to put in the edit box of the window (but not send)
-//szText = NULL will not use any text
-//szText != NULL is only supported on v0.1.2.0+
+// brings up the send message dialog for a contact
+// wParam = (MCONTACT)hContact
+// lParam = (LPARAM)(char*)szText
+// returns 0 on success or nonzero on failure
+// returns immediately, just after the dialog is shown
+// szText is the text to put in the edit box of the window (but not send)
+// szText = NULL will not use any text
+// szText != NULL is only supported on v0.1.2.0+
#define MS_MSG_SENDMESSAGE "SRMsg/SendCommand"
#define MS_MSG_SENDMESSAGEW "SRMsg/SendCommandW"
#define ME_MSG_WINDOWEVENT "MessageAPI/WindowEvent"
-//wparam = 0
-//lparam = (WPARAM)(MessageWindowEventData*)hWindowEvent;
-//Event types
+// wparam = 0
+// lparam = (WPARAM)(MessageWindowEventData*)hWindowEvent;
+// Event types
#define MSG_WINDOW_EVT_OPENING 1 //window is about to be opened
#define MSG_WINDOW_EVT_OPEN 2 //window has been opened
#define MSG_WINDOW_EVT_CLOSING 3 //window is about to be closed
@@ -72,20 +72,20 @@ typedef struct { wchar_t tszText[100];
} StatusTextData;
-//wparam = (MCONTACT)hContact
-//lparam = (StatusTextData*) or NULL to clear statusbar
-//Sets a statusbar line text for the appropriate contact
+// wparam = (MCONTACT)hContact
+// lparam = (StatusTextData*) or NULL to clear statusbar
+// Sets a statusbar line text for the appropriate contact
#define MS_MSG_SETSTATUSTEXT "MessageAPI/SetStatusText"
-//wparam = 0
-//lparam = 0
-//Returns a dword with the current message api version
-//Current version is 0, 0, 0, 4
+// wparam = 0
+// lparam = 0
+// Returns a dword with the current message api version
+// Current version is 0, 0, 0, 4
#define MS_MSG_GETWINDOWAPI "MessageAPI/WindowAPI"
-//wparam = (char*)szBuf
-//lparam = (int)cbSize size of buffer
-//Sets the window class name in wParam (ex. "SRMM" for srmm.dll)
+// wparam = (char*)szBuf
+// lparam = (int)cbSize size of buffer
+// Sets the window class name in wParam (ex. "SRMM" for srmm.dll)
#define MS_MSG_GETWINDOWCLASS "MessageAPI/WindowClass"
typedef struct {
@@ -108,14 +108,14 @@ typedef struct { void *local; // used to store pointer to custom data
} MessageWindowData;
-//wparam = (MessageWindowInputData*)
-//lparam = (MessageWindowData*)
-//returns 0 on success and returns non-zero (1) on error or if no window data exists for that hcontact
+// wparam = (MessageWindowInputData*)
+// lparam = (MessageWindowData*)
+// returns 0 on success and returns non-zero (1) on error or if no window data exists for that hcontact
#define MS_MSG_GETWINDOWDATA "MessageAPI/GetWindowData"
-//wparam = 0 (unused)
-//lparam = (MessageWindowEvent*)
-//fired before SRMM writes an entered message into the database
+// wparam = 0 (unused)
+// lparam = (MessageWindowEvent*)
+// fired before SRMM writes an entered message into the database
#define ME_MSG_PRECREATEEVENT "MessageAPI/PreCreateEvent"
typedef struct {
@@ -176,24 +176,20 @@ typedef struct { #define MBCF_RIGHTBUTTON 0x01 // if this flag is specified, the click was a right button - otherwize it was a left click
// adds an icon
-
EXTERN_C MIR_APP_DLL(int) Srmm_AddIcon(StatusIconData *sid, int _hLang = hLangpack);
// removes an icon
-
EXTERN_C MIR_APP_DLL(void) Srmm_RemoveIcon(const char *szProto, DWORD iconId);
// if hContact is null, icon is modified for all contacts
// otherwise, only the flags field is valid
// if either hIcon, hIconDisabled or szTooltip is null, they will not be modified
-
EXTERN_C MIR_APP_DLL(int) Srmm_ModifyIcon(MCONTACT hContact, StatusIconData *sid);
// wParam = (HANDLE)hContact
// lParam = (int)zero-based index of a visible icon
// returns (StatusIconData*)icon description filled for the required contact
// don't free this memory.
-
EXTERN_C MIR_APP_DLL(StatusIconData*) Srmm_GetNthIcon(MCONTACT hContact, int index);
/////////////////////////////////////////////////////////////////////////////////////////
@@ -218,4 +214,129 @@ struct StatusIconClickData // catch to be notified about the icon list's change.
#define ME_MSG_ICONSCHANGED "MessageAPI/IconsChanged"
+/////////////////////////////////////////////////////////////////////////////////////////
+// srmm toolbar icons' support
+
+// button state flags
+#define BBSF_HIDDEN (1<<0)
+#define BBSF_DISABLED (1<<1)
+#define BBSF_PUSHED (1<<2)
+#define BBSF_RELEASED (1<<3)
+
+// button flags
+#define BBBF_DISABLED (1<<0)
+#define BBBF_HIDDEN (1<<1)
+#define BBBF_ISPUSHBUTTON (1<<2)
+#define BBBF_ISARROWBUTTON (1<<3)
+#define BBBF_ISCHATBUTTON (1<<4)
+#define BBBF_ISIMBUTTON (1<<5)
+#define BBBF_ISRSIDEBUTTON (1<<7)
+#define BBBF_CANBEHIDDEN (1<<8)
+#define BBBF_ISDUMMYBUTTON (1<<9)
+
+#define BBBF_CREATEBYID (1<<11) //only for tabsrmm internal use
+
+struct BBButton
+{
+ char *pszModuleName; // module name without spaces and underline symbols (e.g. "tabsrmm")
+ DWORD dwButtonID; // your button ID, will be combined with pszModuleName for storing settings, etc...
+
+ wchar_t *pwszTooltip;
+ DWORD dwDefPos; // default order pos of button, counted from window edge (left or right)
+ // use value >100, because internal buttons using 10,20,30... 80, etc
+ int iButtonWidth; // must be 0
+ DWORD bbbFlags; // combine of BBBF_ flags above
+ HANDLE hIcon; // Handle to icolib registered icon, it's better to register with pszSection = "TabSRMM/Toolbar"
+};
+
+// adds a new toolbar button
+// returns 0 on success and nonzero value otherwise
+EXTERN_C MIR_APP_DLL(int) Srmm_AddButton(const BBButton *bbdi, int = hLangpack);
+
+// modifies the existing toolbar button
+// returns 0 on success and nonzero value otherwise
+EXTERN_C MIR_APP_DLL(int) Srmm_ModifyButton(BBButton *bbdi);
+
+// removes a toolbar button identified by a structure
+// returns 0 on success and nonzero value otherwise
+EXTERN_C MIR_APP_DLL(int) Srmm_RemoveButton(BBButton *bbdi);
+
+// retrieves data from a toolbar button to a structure
+// returns 0 on success and nonzero value otherwise
+EXTERN_C MIR_APP_DLL(int) Srmm_GetButtonState(HWND hwndDlg, BBButton *bbdi);
+
+// applies a new data to a toolbar button
+// returns 0 on success and nonzero value otherwise
+EXTERN_C MIR_APP_DLL(int) Srmm_SetButtonState(MCONTACT hContact, BBButton *bbdi);
+
+// resets toolbar settings to these default values
+// returns 0 on success and nonzero value otherwise
+EXTERN_C MIR_APP_DLL(void) Srmm_ResetToolbar();
+
+// updates all toolbar icons in a message dialog
+EXTERN_C MIR_APP_DLL(void) Srmm_UpdateToolbarIcons(HWND hdlg);
+
+// draws all toolbar icons in a message dialog
+EXTERN_C MIR_APP_DLL(void) Srmm_RedrawToolbarIcons(HWND hwndDlg);
+
+// ToolBar loaded event
+// This event will be send after module loaded and after each toolbar reset
+// You should add your buttons on this event
+#define ME_MSG_TOOLBARLOADED "SRMM/ButtonsBar/ModuleLoaded"
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// toolbar button internal representation
+
+#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()
+ {}
+
+ 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
+ ptrA m_pszModuleName; // module name without spaces and underline symbols (e.g. "tabsrmm")
+
+ DWORD m_dwButtonCID;
+ DWORD m_dwArrowCID; // only use with BBBF_ISARROWBUTTON flag
+
+ ptrW m_pwszTooltip; // 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_bRSided;
+ BYTE m_opFlags;
+ int m_hLangpack;
+};
+
+// gets the required button or NULL, if i is out of boundaries
+EXTERN_C MIR_APP_DLL(CustomButtonData*) Srmm_GetNthButton(int i);
+
+// retrieves total number of toolbar buttons
+EXTERN_C MIR_APP_DLL(int) Srmm_GetButtonCount(void);
+
+// these messages are sent to the message windows if toolbar buttons are changed
+#define WM_CBD_FIRST (WM_USER+0x600)
+
+// wParam = 0 (ignored)
+// lParam = (CustomButtonData*)pointer to button or null if any button can be changed
+#define WM_CBD_UPDATED (WM_CBD_FIRST+1)
+
+// wParam = button id
+// lParam = (CustomButtonData*)pointer to button
+#define WM_CBD_REMOVED (WM_CBD_FIRST+2)
+
+// wParam = 0 (ignored)
+// lParam = 0 (ignored)
+#define WM_CBD_LOADICONS (WM_CBD_FIRST+3)
+
#endif // M_MESSAGE_H__
diff --git a/plugins/Dropbox/src/dropbox.cpp b/plugins/Dropbox/src/dropbox.cpp index de21e2613c..74dd9acee9 100644 --- a/plugins/Dropbox/src/dropbox.cpp +++ b/plugins/Dropbox/src/dropbox.cpp @@ -3,7 +3,6 @@ CDropbox::CDropbox() : transfers(1, HandleKeySortT)
{
HookEvent(ME_PROTO_ACK, OnProtoAck);
- HookEvent(ME_SYSTEM_PRESHUTDOWN, OnPreShutdown);
HookEventObj(ME_SYSTEM_MODULESLOADED, GlobalEvent<&CDropbox::OnModulesLoaded>, this);
hUploadedEventHook = CreateHookableEvent(ME_DROPBOX_UPLOADED);
diff --git a/plugins/Dropbox/src/dropbox.h b/plugins/Dropbox/src/dropbox.h index 5c1efa5d08..577bd190fc 100644 --- a/plugins/Dropbox/src/dropbox.h +++ b/plugins/Dropbox/src/dropbox.h @@ -41,7 +41,6 @@ private: // hooks
static int OnProtoAck(WPARAM wParam, LPARAM lParam);
- static int OnPreShutdown(WPARAM wParam, LPARAM lParam);
int OnModulesLoaded(WPARAM wParam, LPARAM lParam);
int OnContactDeleted(WPARAM wParam, LPARAM lParam);
int OnOptionsInitialized(WPARAM wParam, LPARAM lParam);
diff --git a/plugins/Dropbox/src/dropbox_events.cpp b/plugins/Dropbox/src/dropbox_events.cpp index 61a5b7203b..6e07cd1713 100644 --- a/plugins/Dropbox/src/dropbox_events.cpp +++ b/plugins/Dropbox/src/dropbox_events.cpp @@ -21,33 +21,16 @@ int CDropbox::OnModulesLoaded(WPARAM, LPARAM) WORD status = ProtoGetStatus(0, 0);
ProtoBroadcastAck(MODULE, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)ID_STATUS_OFFLINE, status);
- if (ServiceExists(MS_BB_ADDBUTTON)) {
- BBButton bbd = { sizeof(bbd) };
- bbd.pszModuleName = MODULE;
-
- bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON | BBBF_ISRSIDEBUTTON;
- bbd.pwszTooltip = TranslateT("Upload files to Dropbox");
- bbd.hIcon = GetIconHandleByName("upload");
- bbd.dwButtonID = BBB_ID_FILE_SEND;
- bbd.dwDefPos = 100 + bbd.dwButtonID;
- CallService(MS_BB_ADDBUTTON, 0, (LPARAM)&bbd);
-
- HookEventObj(ME_MSG_BUTTONPRESSED, GlobalEvent<&CDropbox::OnTabSrmmButtonPressed>, this);
- }
-
- return 0;
-}
-
-int CDropbox::OnPreShutdown(WPARAM, LPARAM)
-{
- if (ServiceExists(MS_BB_ADDBUTTON)) {
- BBButton bbd = { sizeof(bbd) };
- bbd.pszModuleName = MODULE;
-
- bbd.dwButtonID = BBB_ID_FILE_SEND;
- CallService(MS_BB_REMOVEBUTTON, 0, (LPARAM)&bbd);
- }
-
+ BBButton bbd = {};
+ bbd.pszModuleName = MODULE;
+ bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON | BBBF_ISRSIDEBUTTON;
+ bbd.pwszTooltip = TranslateT("Upload files to Dropbox");
+ bbd.hIcon = GetIconHandleByName("upload");
+ bbd.dwButtonID = BBB_ID_FILE_SEND;
+ bbd.dwDefPos = 100 + bbd.dwButtonID;
+ Srmm_AddButton(&bbd);
+
+ HookEventObj(ME_MSG_BUTTONPRESSED, GlobalEvent<&CDropbox::OnTabSrmmButtonPressed>, this);
return 0;
}
@@ -70,7 +53,7 @@ int CDropbox::OnSrmmWindowOpened(WPARAM, LPARAM lParam) WORD status = db_get_w(ev->hContact, proto, "Status", ID_STATUS_OFFLINE);
bool canSendOffline = (CallProtoService(proto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_IMSENDOFFLINE) > 0;
- BBButton bbd = { sizeof(bbd) };
+ BBButton bbd = {};
bbd.pszModuleName = MODULE;
bbd.dwButtonID = BBB_ID_FILE_SEND;
bbd.bbbFlags = BBSF_RELEASED;
@@ -79,7 +62,7 @@ int CDropbox::OnSrmmWindowOpened(WPARAM, LPARAM lParam) else if (!isProtoOnline || (status == ID_STATUS_OFFLINE && !canSendOffline))
bbd.bbbFlags = BBSF_DISABLED;
- CallService(MS_BB_SETBUTTONSTATE, ev->hContact, (LPARAM)&bbd);
+ Srmm_SetButtonState(ev->hContact, &bbd);
}
return 0;
@@ -132,7 +115,7 @@ int CDropbox::OnProtoAck(WPARAM, LPARAM lParam) msgw.cbSize = sizeof(msgw);
if (!CallService(MS_MSG_GETWINDOWDATA, (WPARAM)&msgwi, (LPARAM)&msgw) && msgw.uState & MSG_WINDOW_STATE_EXISTS) {
- BBButton bbd = { sizeof(bbd) };
+ BBButton bbd = {};
bbd.pszModuleName = MODULE;
bbd.dwButtonID = BBB_ID_FILE_SEND;
bbd.bbbFlags = BBSF_RELEASED;
@@ -140,7 +123,7 @@ int CDropbox::OnProtoAck(WPARAM, LPARAM lParam) if (status == ID_STATUS_OFFLINE && !canSendOffline)
bbd.bbbFlags = BBSF_DISABLED;
- CallService(MS_BB_SETBUTTONSTATE, hContact, (LPARAM)&bbd);
+ Srmm_SetButtonState(hContact, &bbd);
}
}
}
diff --git a/plugins/Dropbox/src/dropbox_options.cpp b/plugins/Dropbox/src/dropbox_options.cpp index 142a22b407..8403890397 100644 --- a/plugins/Dropbox/src/dropbox_options.cpp +++ b/plugins/Dropbox/src/dropbox_options.cpp @@ -133,12 +133,11 @@ void CDropboxOptionsInterception::OnApply() msgw.cbSize = sizeof(msgw);
if (!CallService(MS_MSG_GETWINDOWDATA, (WPARAM)&msgwi, (LPARAM)&msgw) && msgw.uState & MSG_WINDOW_STATE_EXISTS) {
- BBButton bbd = { sizeof(bbd) };
+ BBButton bbd = {};
bbd.pszModuleName = MODULE;
bbd.dwButtonID = BBB_ID_FILE_SEND;
bbd.bbbFlags = BBSF_HIDDEN | BBSF_DISABLED;
-
- CallService(MS_BB_SETBUTTONSTATE, hContact, (LPARAM)&bbd);
+ Srmm_SetButtonState(hContact, &bbd);
}
}
}
diff --git a/plugins/ExternalAPI/m_msg_buttonsbar.h b/plugins/ExternalAPI/m_msg_buttonsbar.h index b2eb25ef52..11413d853b 100644 --- a/plugins/ExternalAPI/m_msg_buttonsbar.h +++ b/plugins/ExternalAPI/m_msg_buttonsbar.h @@ -1,67 +1,9 @@ #ifndef M_MSG_BUTTONSBAR_H__
#define M_MSG_BUTTONSBAR_H__
-//////////////////////////////////////////////////////////////////////////
-// Services
-//
-//////////////////////////////////////////////////////////////////////////
-// Adding a button
-//
-// wParam = 0
-// lParam = (BBButton *) &description
-// Returns 0 on success, 1 otherwise
-#define MS_BB_ADDBUTTON "TabSRMM/ButtonsBar/AddButton"
-
-//////////////////////////////////////////////////////////////////////////
-// Remove button
-//
-// wParam = 0
-// lParam = (BBButton *) &description, only button ID and ModuleName used
-// Returns 0 on success, 1 otherwise
-#define MS_BB_REMOVEBUTTON "TabSRMM/ButtonsBar/RemoveButton"
-
-//////////////////////////////////////////////////////////////////////////
-// ModifyButton(global)
-//
-// wParam = 0
-// lParam = (BBButton *) &description
-// Returns 0 on success, 1 otherwise
-#define MS_BB_MODIFYBUTTON "TabSRMM/ButtonsBar/ModifyButton"
-
-
-#define BBSF_HIDDEN (1<<0)
-#define BBSF_DISABLED (1<<1)
-#define BBSF_PUSHED (1<<2)
-#define BBSF_RELEASED (1<<3)
-
-//////////////////////////////////////////////////////////////////////////
-// GetButtonState(local)
-//
-// wParam = hContact
-// lParam = (BBButton *) &description , only ModuleName and ID used
-// Returns BBButton struct with BBSF_ bbbFlags:
-// Returns 0 on success, 1 otherwise
-#define MS_BB_GETBUTTONSTATE "TabSRMM/ButtonsBar/GetButtonState"
-
-//////////////////////////////////////////////////////////////////////////
-// SetButtonState (local)
-//
-// wParam = hContact
-// lParam = (BBButton *) &description , ModuleName, ID,hIcon,Tooltip, and BBSF_ bbbFlags are used
-// Returns 0 on success, 1 otherwise
-#define MS_BB_SETBUTTONSTATE "TabSRMM/ButtonsBar/SetButtonState"
-
-
////////////////////////////////////////////////////////////////
//Events
//
-///////////////////////////////////////////////////
-// ToolBar loaded event
-// wParam = 0;
-// lParam = 0;
-// This event will be send after module loaded and after each toolbar reset
-// You should add your buttons on this event
-#define ME_MSG_TOOLBARLOADED "TabSRMM/ButtonsBar/ModuleLoaded"
///////////////////////////////////////////////////
// ButtonClicked event
@@ -71,7 +13,7 @@ #define ME_MSG_BUTTONPRESSED "TabSRMM/ButtonsBar/ButtonPressed"
-//event flags
+// event flags
#define BBCF_RIGHTBUTTON (1<<0)
#define BBCF_SHIFTPRESSED (1<<1)
#define BBCF_CONTROLPRESSED (1<<2)
@@ -87,34 +29,4 @@ typedef struct { DWORD flags; // BBCF_ flags
} CustomButtonClickData;
-
-//button flags
-#define BBBF_DISABLED (1<<0)
-#define BBBF_HIDDEN (1<<1)
-#define BBBF_ISPUSHBUTTON (1<<2)
-#define BBBF_ISARROWBUTTON (1<<3)
-#define BBBF_ISCHATBUTTON (1<<4)
-#define BBBF_ISIMBUTTON (1<<5)
-#define BBBF_ISRSIDEBUTTON (1<<7)
-#define BBBF_CANBEHIDDEN (1<<8)
-#define BBBF_ISDUMMYBUTTON (1<<9)
-
-#define BBBF_CREATEBYID (1<<11) //only for tabsrmm internal use
-
-typedef struct _tagBBButton
-{
- int cbSize; // size of structure
-
- DWORD dwButtonID; // your button ID, will be combined with pszModuleName for storing settings, etc...
-
- char *pszModuleName; // module name without spaces and underline symbols (e.g. "tabsrmm")
- wchar_t *pwszTooltip;
- DWORD dwDefPos; // default order pos of button, counted from window edge (left or right)
- // use value >100, because internal buttons using 10,20,30... 80, etc
- int iButtonWidth; // must be 0
- DWORD bbbFlags; // combine of BBBF_ flags above
- HANDLE hIcon; // Handle to icolib registered icon, it's better to register with pszSection = "TabSRMM/Toolbar"
-}
- BBButton;
-
#endif //M_MSG_BUTTONSBAR_H__
\ No newline at end of file diff --git a/plugins/MenuItemEx/src/main.cpp b/plugins/MenuItemEx/src/main.cpp index 79611ab50e..c8534b46bb 100644 --- a/plugins/MenuItemEx/src/main.cpp +++ b/plugins/MenuItemEx/src/main.cpp @@ -895,16 +895,12 @@ static int TabsrmmButtonPressed(WPARAM wParam, LPARAM lParam) static int TabsrmmButtonsInit(WPARAM, LPARAM)
{
BBButton bbd = { 0 };
-
- bbd.cbSize = sizeof(BBButton);
bbd.pszModuleName = MODULENAME;
- bbd.dwButtonID = 0;
bbd.dwDefPos = 1000;
bbd.pwszTooltip = LPGENW("Browse Received Files");
bbd.bbbFlags = BBBF_CANBEHIDDEN;
bbd.hIcon = IcoLib_GetIconHandle("miex_recfiles");
- CallService(MS_BB_ADDBUTTON, 0, (LPARAM)&bbd);
-
+ Srmm_AddButton(&bbd);
return 0;
}
@@ -913,11 +909,10 @@ static void TabsrmmButtonsModify(MCONTACT hContact) if (!DirectoryExists(hContact))
{
BBButton bbd = { 0 };
- bbd.cbSize = sizeof(BBButton);
bbd.dwButtonID = 0;
bbd.pszModuleName = MODULENAME;
bbd.bbbFlags = BBSF_DISABLED | BBSF_HIDDEN;
- CallService(MS_BB_SETBUTTONSTATE, hContact, (LPARAM)&bbd);
+ Srmm_SetButtonState(hContact, &bbd);
}
}
diff --git a/plugins/Nudge/src/main.cpp b/plugins/Nudge/src/main.cpp index c159a76aec..ca4e0f406c 100644 --- a/plugins/Nudge/src/main.cpp +++ b/plugins/Nudge/src/main.cpp @@ -248,15 +248,14 @@ static int TabsrmmButtonPressed(WPARAM wParam, LPARAM lParam) static int TabsrmmButtonInit(WPARAM, LPARAM)
{
- BBButton bbd = { sizeof(bbd) };
+ BBButton bbd = {};
bbd.pszModuleName = "Nudge";
bbd.pwszTooltip = LPGENW("Send Nudge");
bbd.dwDefPos = 300;
bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_CANBEHIDDEN;
bbd.hIcon = iconList[0].hIcolib;
bbd.dwButtonID = 6000;
- bbd.iButtonWidth = 0;
- CallService(MS_BB_ADDBUTTON, 0, (LPARAM)&bbd);
+ Srmm_AddButton(&bbd);
return 0;
}
@@ -265,11 +264,11 @@ void HideNudgeButton(MCONTACT hContact) {
char *szProto = GetContactProto(hContact);
if (!ProtoServiceExists(szProto, PS_SEND_NUDGE)) {
- BBButton bbd = { sizeof(bbd) };
- bbd.bbbFlags = BBSF_HIDDEN | BBSF_DISABLED;
+ BBButton bbd = {};
bbd.pszModuleName = "Nudge";
bbd.dwButtonID = 6000;
- CallService(MS_BB_SETBUTTONSTATE, hContact, (LPARAM)&bbd);
+ bbd.bbbFlags = BBSF_HIDDEN | BBSF_DISABLED;
+ Srmm_SetButtonState(hContact, &bbd);
}
}
diff --git a/plugins/TabSRMM/res/resource.rc b/plugins/TabSRMM/res/resource.rc index c50e604c1d..7343f29938 100644 --- a/plugins/TabSRMM/res/resource.rc +++ b/plugins/TabSRMM/res/resource.rc @@ -372,23 +372,6 @@ BEGIN PUSHBUTTON "Create new",IDC_CREATENEW,134,119,66,14
END
-IDD_OPT_TOOLBAR DIALOGEX 0, 0, 303, 229
-STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
-EXSTYLE WS_EX_CONTROLPARENT
-FONT 8, "MS Shell Dlg", 0, 0, 0x1
-BEGIN
- CONTROL "",IDC_TOOLBARTREE,"SysTreeView32",TVS_SHOWSELALWAYS | TVS_NOTOOLTIPS | TVS_CHECKBOXES | TVS_FULLROWSELECT | WS_HSCROLL | WS_TABSTOP,1,4,301,171,WS_EX_CLIENTEDGE
- PUSHBUTTON "Reset",IDC_BBRESET,250,211,53,15
- CONTROL "Show in IM chats",IDC_IMCHECK,"Button",BS_AUTOCHECKBOX | BS_VCENTER | BS_MULTILINE | WS_TABSTOP,4,181,127,12
- CONTROL "Show in chat rooms",IDC_CHATCHECK,"Button",BS_AUTOCHECKBOX | BS_VCENTER | BS_MULTILINE | WS_TABSTOP,4,196,127,12
- EDITTEXT IDC_EDIT1,252,183,32,12,ES_AUTOHSCROLL
- CONTROL "",IDC_SPIN1,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_GROUP,272,183,11,12
- RTEXT "Gap between buttons:",IDC_STATIC,136,183,104,12,SS_CENTERIMAGE
- CONTROL "Hide if there isn't enough space",IDC_CANBEHIDDEN,
- "Button",BS_AUTOCHECKBOX | BS_VCENTER | BS_MULTILINE | WS_TABSTOP,4,209,131,17
- PUSHBUTTON "Insert separator",IDC_SEPARATOR,137,211,103,15,BS_MULTILINE
-END
-
IDD_OPT_CONTAINERS DIALOGEX 0, 0, 303, 221
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
diff --git a/plugins/TabSRMM/src/buttonbar.h b/plugins/TabSRMM/src/buttonbar.h index fd4e4c90d2..52201ebb12 100644 --- a/plugins/TabSRMM/src/buttonbar.h +++ b/plugins/TabSRMM/src/buttonbar.h @@ -7,15 +7,10 @@ struct CustomButtonData;
struct TWindowData;
-void CB_WriteButtonSettings(MCONTACT hContact, CustomButtonData *cbd);
-
void CB_DeInitCustomButtons();
void CB_InitCustomButtons();
-void CB_InitDefaultButtons();
-void CB_ReInitCustomButtons();
void BB_InitDlgButtons(TWindowData *dat);
-void BB_UpdateIcons(HWND hdlg);
void BB_RefreshTheme(const TWindowData *dat);
BOOL BB_SetButtonsPos(TWindowData *dat);
void BB_RedrawButtons(TWindowData *dat);
diff --git a/plugins/TabSRMM/src/buttonsbar.cpp b/plugins/TabSRMM/src/buttonsbar.cpp index 969977083e..c44e2cba44 100644 --- a/plugins/TabSRMM/src/buttonsbar.cpp +++ b/plugins/TabSRMM/src/buttonsbar.cpp @@ -1,786 +1,27 @@ #include "stdafx.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() - {} - - 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 - ptrA m_pszModuleName; // module name without spaces and underline symbols (e.g. "tabsrmm") - - DWORD m_dwButtonCID; - DWORD m_dwArrowCID; // only use with BBBF_ISARROWBUTTON flag - - ptrW m_pwszTooltip; // 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_bRSided; - BYTE m_opFlags; -}; - HANDLE hHookButtonPressedEvt; -HANDLE hHookToolBarLoadedEvt; - -static int SortButtons(const CustomButtonData *p1, const CustomButtonData *p2) -{ - if (p1->m_bRSided != p2->m_bRSided) - return (p2->m_bRSided) ? -1 : 1; - return p1->m_dwPosition - p2->m_dwPosition; -} - -static LIST<CustomButtonData> arButtonsList(1, SortButtons); - -DWORD LastCID = 4000; -DWORD dwSepCount = 0; - -static mir_cs csToolBar; - -static void wipeList(LIST<CustomButtonData> &list) -{ - for (int i = list.getCount() - 1; i >= 0; i--) { - delete list[i]; - list.remove(i); - } -} - -static int sstSortButtons(const void *p1, const void *p2) -{ - CustomButtonData *pb1 = *(CustomButtonData**)p1, *pb2 = *(CustomButtonData**)p2; - if (pb1->m_bRSided != pb2->m_bRSided) - return (pb2->m_bRSided) ? -1 : 1; - return pb1->m_dwPosition - pb2->m_dwPosition; -} - -static 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, "%s_%d", cbd->m_pszModuleName, cbd->m_dwButtonOrigID); - - 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, "_"); - token = strtok(NULL, "_"); - cbd->m_bRSided = atoi(token) != 0; - token = strtok(NULL, "_"); - cbd->m_bCanBeHidden = atoi(token) != 0; - - db_free(&dbv); - } -} - -static void CB_HardReInit() -{ - M.BroadcastMessage(DM_CBDESTROY, 0, 0); - { - mir_cslock lck(csToolBar); - wipeList(arButtonsList); - } - LastCID = 4000; - dwSepCount = 0; - - CB_InitDefaultButtons(); - NotifyEventHooks(hHookToolBarLoadedEvt, 0, 0); -} - -static INT_PTR CB_AddButton(WPARAM, LPARAM lParam) -{ - BBButton *bbdi = (BBButton *)lParam; - if (!bbdi || bbdi->cbSize != sizeof(BBButton)) - return 1; - - CustomButtonData *cbd = new CustomButtonData(); - if (!bbdi->iButtonWidth && (bbdi->bbbFlags & BBBF_ISARROWBUTTON)) - cbd->m_iButtonWidth = DPISCALEX_S(34); - else if (!bbdi->iButtonWidth) - cbd->m_iButtonWidth = DPISCALEX_S(22); - else - cbd->m_iButtonWidth = DPISCALEX_S(bbdi->iButtonWidth); - - cbd->m_pszModuleName = mir_strdup(bbdi->pszModuleName); - cbd->m_pwszTooltip = mir_wstrdup(bbdi->pwszTooltip); - - 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_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; - - // download database settings - CB_GetButtonSettings(NULL, cbd); - - arButtonsList.insert(cbd); - - if (cbd->m_dwButtonCID != cbd->m_dwButtonOrigID) - LastCID++; - if (cbd->m_dwArrowCID == LastCID) - LastCID++; - - M.BroadcastMessage(DM_BBNEEDUPDATE, 0, 0); - return 0; -} - -static INT_PTR CB_GetButtonState(WPARAM wParam, LPARAM lParam) -{ - 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 < arButtonsList.getCount(); i++) { - CustomButtonData *cbd = arButtonsList[i]; - if (!mir_strcmp(cbd->m_pszModuleName, bbdi->pszModuleName) && (cbd->m_dwButtonOrigID == bbdi->dwButtonID)) { - realbutton = true; - tempCID = cbd->m_dwButtonCID; - } - } - if (!realbutton) - return 1; - - HWND hwndDlg = M.FindWindow(wParam); - 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; -} - -static INT_PTR CB_SetButtonState(WPARAM wParam, LPARAM lParam) -{ - if (wParam == 0 || lParam == 0) - return 1; - - bool realbutton = false; - DWORD tempCID = 0; - BBButton *bbdi = (BBButton *)lParam; - for (int i = 0; i < arButtonsList.getCount(); i++) { - CustomButtonData *cbd = arButtonsList[i]; - if (!mir_strcmp(cbd->m_pszModuleName, bbdi->pszModuleName) && (cbd->m_dwButtonOrigID == bbdi->dwButtonID)) { - realbutton = true; - tempCID = cbd->m_dwButtonCID; - } - } - if (!realbutton) - return 1; - - HWND hwndDlg = M.FindWindow(wParam); - if (!hwndDlg) - return 1; - - SetDlgItemTextA(hwndDlg, tempCID, bbdi->pszModuleName); - if (bbdi->hIcon) - SendDlgItemMessage(hwndDlg, tempCID, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIconByHandle(bbdi->hIcon)); - if (bbdi->pwszTooltip) - SendDlgItemMessage(hwndDlg, tempCID, BUTTONADDTOOLTIP, (WPARAM)bbdi->pwszTooltip, BATF_UNICODE); - if (bbdi->bbbFlags) { - Utils::showDlgControl(hwndDlg, tempCID, (bbdi->bbbFlags & BBSF_HIDDEN) ? SW_HIDE : SW_SHOW); - Utils::enableDlgControl(hwndDlg, tempCID, !(bbdi->bbbFlags & BBSF_DISABLED)); - CheckDlgButton(hwndDlg, tempCID, (bbdi->bbbFlags & BBSF_PUSHED) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, tempCID, (bbdi->bbbFlags & BBSF_RELEASED) ? BST_UNCHECKED : BST_CHECKED); - } - return 0; -} - -static INT_PTR CB_RemoveButton(WPARAM, LPARAM lParam) -{ - BBButton *bbdi = (BBButton*)lParam; - if (!bbdi) - return 1; - - CustomButtonData *pFound = NULL; - { - mir_cslock lck(csToolBar); - - for (int i = arButtonsList.getCount() - 1; i >= 0; i--) { - CustomButtonData *cbd = arButtonsList[i]; - if (!mir_strcmp(cbd->m_pszModuleName, bbdi->pszModuleName) && cbd->m_dwButtonOrigID == bbdi->dwButtonID) { - pFound = cbd; - arButtonsList.remove(i); - } - } - } - - if (pFound) { - M.BroadcastMessage(DM_CBDESTROY, pFound->m_dwButtonCID, pFound->m_bRSided ? BBBF_ISRSIDEBUTTON : ~BBBF_ISRSIDEBUTTON); - delete pFound; - } - return 0; -} - -static INT_PTR CB_ModifyButton(WPARAM, LPARAM lParam) -{ - BBButton *bbdi = (BBButton *)lParam; - if (!bbdi) - return 1; - - bool bFound = false; - CustomButtonData *cbd = NULL; - { - mir_cslock lck(csToolBar); - - for (int i = 0; i < arButtonsList.getCount(); i++) { - cbd = arButtonsList[i]; - if (!mir_strcmp(cbd->m_pszModuleName, bbdi->pszModuleName) && (cbd->m_dwButtonOrigID == bbdi->dwButtonID)) { - bFound = true; - break; - } - } - - if (bFound) { - if (bbdi->pwszTooltip) - cbd->m_pwszTooltip = mir_wstrdup(bbdi->pwszTooltip); - if (bbdi->hIcon) - cbd->m_hIcon = bbdi->hIcon; - if (bbdi->bbbFlags) { - cbd->m_bHidden = (bbdi->bbbFlags & BBBF_HIDDEN) != 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; - } - } - } - - if (bFound) - M.BroadcastMessage(DM_BBNEEDUPDATE, 0, (LPARAM)cbd); - return 0; -} - -static void BB_RegisterSeparators() -{ - BBButton bbd = { 0 }; - DWORD i = 0; - bbd.cbSize = sizeof(BBButton); - bbd.pszModuleName = "Tabsrmm_sep"; - for (; dwSepCount > i; i++) { - bbd.bbbFlags = BBBF_ISDUMMYBUTTON | BBBF_ISIMBUTTON; - bbd.dwButtonID = i + 1; - bbd.dwDefPos = 410 + i; - CB_AddButton(0, (LPARAM)&bbd); - } -} - -#define MIDDLE_SEPARATOR L">-------M-------<" - -static int SaveTree(HWND hToolBarTree) -{ - bool RSide = false; - int count = 10; - DWORD loc_sepcout = 0; - wchar_t strbuf[128]; - - TVITEM tvi; - tvi.mask = TVIF_TEXT | TVIF_PARAM | TVIF_HANDLE; - tvi.hItem = TreeView_GetRoot(hToolBarTree); - tvi.pszText = strbuf; - tvi.cchTextMax = _countof(strbuf); - { - mir_cslock lck(csToolBar); - - while (tvi.hItem != NULL) { - TreeView_GetItem(hToolBarTree, &tvi); - - if (mir_wstrcmp(tvi.pszText, MIDDLE_SEPARATOR) == 0) { - RSide = true; - count = TreeView_GetCount(hToolBarTree) * 10 - count; - tvi.hItem = TreeView_GetNextSibling(hToolBarTree, tvi.hItem); - continue; - } - CustomButtonData *cbd = (CustomButtonData*)tvi.lParam; - if (cbd) { - 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->m_bRSided) { - cbd->m_bRSided = true; - cbd->m_opFlags |= BBSF_NTBSWAPED; - } - else if (!RSide && cbd->m_bRSided) { - cbd->m_bRSided = false; - cbd->m_opFlags |= BBSF_NTBSWAPED; - } - if (!TreeView_GetCheckState(hToolBarTree, tvi.hItem)) { - cbd->m_bIMButton = false; - cbd->m_bChatButton = false; - - if (cbd->m_bSeparator && !mir_strcmp(cbd->m_pszModuleName, "Tabsrmm_sep")) - cbd->m_opFlags = BBSF_NTBDESTRUCT; - } - else { - if (!cbd->m_bIMButton && !cbd->m_bChatButton) - cbd->m_bIMButton = true; - if (cbd->m_bSeparator && !mir_strcmp(cbd->m_pszModuleName, "Tabsrmm_sep")) { - cbd->m_bHidden = 0; - cbd->m_opFlags &= ~BBSF_NTBDESTRUCT; - ++loc_sepcout; - } - } - - cbd->m_dwPosition = (DWORD)count; - CB_WriteButtonSettings(NULL, cbd); - - if (!(cbd->m_opFlags & BBSF_NTBDESTRUCT)) - (RSide) ? (count -= 10) : (count += 10); - } - - HTREEITEM hItem = TreeView_GetNextSibling(hToolBarTree, tvi.hItem); - if (cbd->m_opFlags & BBSF_NTBDESTRUCT) - TreeView_DeleteItem(hToolBarTree, tvi.hItem); - tvi.hItem = hItem; - } - - qsort(arButtonsList.getArray(), arButtonsList.getCount(), sizeof(void*), sstSortButtons); - } - db_set_dw(0, "TabSRMM_Toolbar", "SeparatorsCount", loc_sepcout); - dwSepCount = loc_sepcout; - return 1; -} - -HIMAGELIST himgl = NULL; - -static int BuildMenuObjectsTree(HWND hToolBarTree) -{ - HTREEITEM hti; - int iImage = 0; - - TVINSERTSTRUCT tvis; - tvis.hParent = NULL; - tvis.hInsertAfter = TVI_LAST; - tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_SELECTEDIMAGE | TVIF_IMAGE; - - TreeView_DeleteAllItems(hToolBarTree); - - himgl = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 2, 2); - ImageList_AddIcon(himgl, Skin_LoadIcon(SKINICON_OTHER_SMALLDOT)); - ImageList_Destroy(TreeView_GetImageList(hToolBarTree, TVSIL_NORMAL)); - TreeView_SetImageList(hToolBarTree, himgl, TVSIL_NORMAL); - - if (arButtonsList.getCount() == 0) - return FALSE; - - bool bPrevSide = false; - mir_cslock lck(csToolBar); - - for (int i = 0; i < arButtonsList.getCount(); i++) { - CustomButtonData *cbd = arButtonsList[i]; - - if (bPrevSide != cbd->m_bRSided) { - bPrevSide = true; - - TVINSERTSTRUCT tvis2 = {}; - tvis.hInsertAfter = TVI_LAST; - tvis2.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_SELECTEDIMAGE | TVIF_IMAGE | TVIF_STATE; - tvis2.item.pszText = MIDDLE_SEPARATOR; - tvis2.item.stateMask = TVIS_BOLD; - tvis2.item.state = TVIS_BOLD; - tvis2.item.iImage = tvis.item.iSelectedImage = -1; - tvis.hInsertAfter = hti = TreeView_InsertItem(hToolBarTree, &tvis2); - TreeView_SetCheckState(hToolBarTree, hti, 1); - } - - tvis.item.lParam = (LPARAM)cbd; - - if (cbd->m_bSeparator) { - tvis.item.pszText = TranslateT("<Separator>"); - tvis.item.iImage = tvis.item.iSelectedImage = 0; - } - else { - tvis.item.pszText = TranslateW(cbd->m_pwszTooltip); - iImage = ImageList_AddIcon(himgl, IcoLib_GetIconByHandle(cbd->m_hIcon)); - tvis.item.iImage = tvis.item.iSelectedImage = iImage; - } - cbd->m_opFlags = 0; - hti = TreeView_InsertItem(hToolBarTree, &tvis); - - TreeView_SetCheckState(hToolBarTree, hti, (cbd->m_bIMButton || cbd->m_bChatButton)); - } - - return 1; -} - -BOOL drag = FALSE, bOptionsInit = TRUE; -HANDLE hDragItem = NULL; -HWND hToolBarTree = NULL; - -INT_PTR CALLBACK DlgProcToolBar(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - HTREEITEM hItem; - - switch (uMsg) { - case WM_INITDIALOG: - hToolBarTree = GetDlgItem(hwndDlg, IDC_TOOLBARTREE); - { - LONG_PTR style = GetWindowLongPtr(hToolBarTree, GWL_STYLE); - style ^= TVS_CHECKBOXES; - SetWindowLongPtr(hToolBarTree, GWL_STYLE, style); - style |= TVS_CHECKBOXES; - style |= TVS_NOHSCROLL; - SetWindowLongPtr(hToolBarTree, GWL_STYLE, style); - } - { - mir_cslock lck(csToolBar); - BuildMenuObjectsTree(hToolBarTree); - } - - Utils::enableDlgControl(hwndDlg, IDC_IMCHECK, false); - Utils::enableDlgControl(hwndDlg, IDC_CHATCHECK, false); - Utils::enableDlgControl(hwndDlg, IDC_CANBEHIDDEN, false); - - SendDlgItemMessage(hwndDlg, IDC_SPIN1, UDM_SETRANGE, 0, MAKELONG(10, 0)); - SendDlgItemMessage(hwndDlg, IDC_SPIN1, UDM_SETPOS, 0, MAKELONG(PluginConfig.m_iButtonsBarGap, 0)); - TranslateDialogDefault(hwndDlg); - bOptionsInit = FALSE; - break; - - case WM_LBUTTONUP: - if (drag) { - TreeView_SetInsertMark(hToolBarTree, NULL, 0); - drag = 0; - ReleaseCapture(); - - TVHITTESTINFO hti; - hti.pt.x = (short)LOWORD(lParam); - hti.pt.y = (short)HIWORD(lParam); - ClientToScreen(hwndDlg, &hti.pt); - ScreenToClient(hToolBarTree, &hti.pt); - 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; - - 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)) { - TVINSERTSTRUCT tvis; - wchar_t strbuf[128]; - tvis.item.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_STATE; - tvis.item.stateMask = 0xFFFFFFFF; - tvis.item.pszText = strbuf; - tvis.item.cchTextMax = _countof(strbuf); - tvis.item.hItem = (HTREEITEM)hDragItem; - TreeView_GetItem(hToolBarTree, &tvis.item); - TreeView_DeleteItem(hToolBarTree, hDragItem); - tvis.hParent = NULL; - tvis.hInsertAfter = hti.hItem; - TreeView_SelectItem(hToolBarTree, TreeView_InsertItem(hToolBarTree, &tvis)); - SendMessage((GetParent(hwndDlg)), PSM_CHANGED, 0, 0); - } - } - break; - - case WM_MOUSEMOVE: - if (drag) { - TVHITTESTINFO hti; - hti.pt.x = (short)LOWORD(lParam); - hti.pt.y = (short)HIWORD(lParam); - ClientToScreen(hwndDlg, &hti.pt); - ScreenToClient(hToolBarTree, &hti.pt); - TreeView_HitTest(hToolBarTree, &hti); - 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)) - 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); - TreeView_SetInsertMark(hToolBarTree, NULL, 0); - } - } - break; - - case WM_COMMAND: - if (HIWORD(wParam) == BN_CLICKED && GetFocus() == (HWND)lParam && (HWND)lParam != hToolBarTree) - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - if ((HIWORD(wParam) == EN_CHANGE) && ((HWND)lParam == GetFocus())) - if (!bOptionsInit) - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - - switch (LOWORD(wParam)) { - case IDC_BBRESET: - db_delete_module(NULL, "TabSRMM_Toolbar"); - CB_HardReInit(); - BuildMenuObjectsTree(hToolBarTree); - break; - - case IDC_SEPARATOR: - hItem = TreeView_GetSelection(hToolBarTree); - if (!hItem) - hItem = TVI_FIRST; - - CustomButtonData *cbd = new CustomButtonData(); - cbd->m_bSeparator = cbd->m_bHidden = cbd->m_bIMButton = true; - cbd->m_dwButtonOrigID = ++dwSepCount; - cbd->m_pszModuleName = "Tabsrmm_sep"; - cbd->m_iButtonWidth = 22; - cbd->m_opFlags = BBSF_NTBDESTRUCT; - arButtonsList.insert(cbd); - - TVINSERTSTRUCT tvis; - tvis.hParent = NULL; - tvis.hInsertAfter = hItem; - 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; - hItem = TreeView_InsertItem(hToolBarTree, &tvis); - - TreeView_SetCheckState(hToolBarTree, hItem, (cbd->m_bIMButton || cbd->m_bChatButton)); - } - break; - - case WM_NOTIFY: - switch (((LPNMHDR)lParam)->idFrom) { - case 0: - switch (((LPNMHDR)lParam)->code) { - case PSN_RESET: - CB_ReInitCustomButtons(); - dwSepCount = M.GetDword("TabSRMM_Toolbar", "SeparatorsCount", 0); - return 1; - - case PSN_APPLY: - hItem = TreeView_GetSelection(hToolBarTree); - if (hItem) { - TVITEM tvi; - tvi.mask = TVIF_HANDLE | TVIF_PARAM; - tvi.hItem = hItem; - TreeView_GetItem(hToolBarTree, &tvi); - - if (tvi.lParam) { - CustomButtonData *cbd = (CustomButtonData*)tvi.lParam; - if (cbd) { - cbd->m_bIMButton = IsDlgButtonChecked(hwndDlg, IDC_IMCHECK) != 0; - cbd->m_bChatButton = IsDlgButtonChecked(hwndDlg, IDC_CHATCHECK) != 0; - cbd->m_bCanBeHidden = IsDlgButtonChecked(hwndDlg, IDC_CANBEHIDDEN) != 0; - } - } - } - - SaveTree(hToolBarTree); - CB_ReInitCustomButtons(); - PluginConfig.m_iButtonsBarGap = (BYTE)SendDlgItemMessage(hwndDlg, IDC_SPIN1, UDM_GETPOS, 0, 0); - - if (PluginConfig.m_iButtonsBarGap != M.GetByte("ButtonsBarGap", 1)) - M.BroadcastMessageAsync(WM_SIZE, 0, 0); - - db_set_b(0, SRMSGMOD_T, "ButtonsBarGap", PluginConfig.m_iButtonsBarGap); - - BuildMenuObjectsTree((HWND)hToolBarTree); - Utils::enableDlgControl(hwndDlg, IDC_IMCHECK, false); - Utils::enableDlgControl(hwndDlg, IDC_CHATCHECK, false); - Utils::enableDlgControl(hwndDlg, IDC_CANBEHIDDEN, false); - return 1; - } - break; - - case IDC_TOOLBARTREE: - switch (((LPNMHDR)lParam)->code) { - case TVN_BEGINDRAG: - SetCapture(hwndDlg); - drag = 1; - hDragItem = ((LPNMTREEVIEW)lParam)->itemNew.hItem; - TreeView_SelectItem(hToolBarTree, hDragItem); - break; - - case TVN_SELCHANGING: - hItem = TreeView_GetSelection(hToolBarTree); - if (hItem != NULL) { - wchar_t strbuf[128]; - - TVITEM tvi; - tvi.hItem = hItem; - tvi.pszText = strbuf; - tvi.cchTextMax = _countof(strbuf); - tvi.mask = TVIF_TEXT | TVIF_HANDLE | TVIF_PARAM; - TreeView_GetItem(hToolBarTree, &tvi); - - if (tvi.lParam == 0 || !TreeView_GetCheckState(hToolBarTree, tvi.hItem) || !mir_wstrcmp(tvi.pszText, MIDDLE_SEPARATOR)) - break; - - CustomButtonData *cbd = (CustomButtonData*)tvi.lParam; - if (cbd) { - 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->m_bIMButton = IsDlgButtonChecked(hwndDlg, IDC_IMCHECK) != 0; - cbd->m_bChatButton = IsDlgButtonChecked(hwndDlg, IDC_CHATCHECK) != 0; - cbd->m_bCanBeHidden = IsDlgButtonChecked(hwndDlg, IDC_CANBEHIDDEN) != 0; - } - } - break; - - case TVN_SELCHANGED: - hItem = TreeView_GetSelection(hToolBarTree); - if (hItem != NULL) { - wchar_t strbuf[128]; - - TVITEM tvi; - tvi.pszText = strbuf; - tvi.cchTextMax = _countof(strbuf); - tvi.mask = TVIF_TEXT | TVIF_HANDLE | TVIF_PARAM; - tvi.hItem = hItem; - TreeView_GetItem(hToolBarTree, &tvi); - - if (!TreeView_GetCheckState(hToolBarTree, tvi.hItem) || !mir_wstrcmp(tvi.pszText, MIDDLE_SEPARATOR)) { - Utils::enableDlgControl(hwndDlg, IDC_IMCHECK, false); - Utils::enableDlgControl(hwndDlg, IDC_CHATCHECK, false); - Utils::enableDlgControl(hwndDlg, IDC_CANBEHIDDEN, false); - break; - } - - if (tvi.lParam == 0) - break; - - CustomButtonData *cbd = (CustomButtonData*)tvi.lParam; - if (cbd) { - Utils::enableDlgControl(hwndDlg, IDC_IMCHECK, true); - Utils::enableDlgControl(hwndDlg, IDC_CHATCHECK, true); - Utils::enableDlgControl(hwndDlg, IDC_CANBEHIDDEN, true); - 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; - - case NM_CLICK: - TVHITTESTINFO hti = { 0 }; - GetCursorPos(&hti.pt); - ScreenToClient(hToolBarTree, &hti.pt); - if (TreeView_HitTest(hToolBarTree, &hti)) { - if (hti.flags&TVHT_ONITEMSTATEICON) { - SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0); - if (TreeView_GetCheckState(hToolBarTree, hti.hItem)) { - Utils::enableDlgControl(hwndDlg, IDC_IMCHECK, false); - Utils::enableDlgControl(hwndDlg, IDC_CHATCHECK, false); - Utils::enableDlgControl(hwndDlg, IDC_CANBEHIDDEN, false); - CheckDlgButton(hwndDlg, IDC_IMCHECK, BST_CHECKED); - } - else { - Utils::enableDlgControl(hwndDlg, IDC_IMCHECK, true); - Utils::enableDlgControl(hwndDlg, IDC_CHATCHECK, true); - Utils::enableDlgControl(hwndDlg, IDC_CANBEHIDDEN, true); - } - TreeView_SelectItem(hToolBarTree, hti.hItem); - } - } - } - } - break; - - case WM_DESTROY: - HIMAGELIST hIml = TreeView_GetImageList(GetDlgItem(hwndDlg, IDC_TOOLBARTREE), TVSIL_NORMAL); - ImageList_Destroy(hIml); - hIml = TreeView_GetImageList(GetDlgItem(hwndDlg, IDC_TOOLBARTREE), TVSIL_STATE); - ImageList_Destroy(hIml); - break; - } - - 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)IcoLib_GetIconByHandle(m_hIcon)); - if (m_pwszTooltip) - SendMessage(hwndBtn, BUTTONADDTOOLTIP, (WPARAM)TranslateW(m_pwszTooltip), BATF_UNICODE); - 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) +static int CB_InitDefaultButtons(WPARAM, LPARAM) { - char SettingName[1024]; - char SettingParameter[1024]; - - //modulename_buttonID, position_inIM_inCHAT_isLSide_isRSide_CanBeHidden - - mir_snprintf(SettingName, "%s_%d", cbd->m_pszModuleName, cbd->m_dwButtonOrigID); - mir_snprintf(SettingParameter, "%d_%u_%u_%u_%u_%u", cbd->m_dwPosition, cbd->m_bIMButton, cbd->m_bChatButton, 0, 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); + BBButton bbd = {}; bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISARROWBUTTON | BBBF_CREATEBYID; bbd.dwButtonID = IDC_PROTOCOL; bbd.dwDefPos = 10; bbd.hIcon = Skin_GetIconHandle(SKINICON_OTHER_CONNECTING); bbd.pszModuleName = "Tabsrmm"; bbd.pwszTooltip = LPGENW("Protocol button"); - CB_AddButton(0, (LPARAM)&bbd); + Srmm_AddButton(&bbd); bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISARROWBUTTON | BBBF_CREATEBYID; bbd.dwButtonID = IDC_NAME; bbd.dwDefPos = 20; bbd.hIcon = PluginConfig.g_buttonBarIconHandles[20]; bbd.pwszTooltip = LPGENW("Info button"); - CB_AddButton(0, (LPARAM)&bbd); + Srmm_AddButton(&bbd); if (PluginConfig.g_SmileyAddAvail) { bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON | BBBF_CREATEBYID; @@ -789,7 +30,7 @@ void CB_InitDefaultButtons() bbd.dwDefPos = 30; bbd.hIcon = PluginConfig.g_buttonBarIconHandles[9]; bbd.pwszTooltip = LPGENW("Insert emoticon"); - CB_AddButton(0, (LPARAM)&bbd); + Srmm_AddButton(&bbd); } bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON | BBBF_ISPUSHBUTTON | BBBF_CANBEHIDDEN | BBBF_CREATEBYID; @@ -797,28 +38,28 @@ void CB_InitDefaultButtons() bbd.dwDefPos = 40; bbd.hIcon = PluginConfig.g_buttonBarIconHandles[10]; bbd.pwszTooltip = LPGENW("Bold text"); - CB_AddButton(0, (LPARAM)&bbd); + Srmm_AddButton(&bbd); bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON | BBBF_ISPUSHBUTTON | BBBF_CANBEHIDDEN | BBBF_CREATEBYID; bbd.dwButtonID = IDC_FONTITALIC; bbd.dwDefPos = 50; bbd.hIcon = PluginConfig.g_buttonBarIconHandles[11]; bbd.pwszTooltip = LPGENW("Italic text"); - CB_AddButton(0, (LPARAM)&bbd); + Srmm_AddButton(&bbd); bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON | BBBF_ISPUSHBUTTON | BBBF_CANBEHIDDEN | BBBF_CREATEBYID; bbd.dwButtonID = IDC_FONTUNDERLINE; bbd.dwDefPos = 60; bbd.hIcon = PluginConfig.g_buttonBarIconHandles[12]; bbd.pwszTooltip = LPGENW("Underlined text"); - CB_AddButton(0, (LPARAM)&bbd); + Srmm_AddButton(&bbd); bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISPUSHBUTTON | BBBF_CANBEHIDDEN | BBBF_CREATEBYID; bbd.dwButtonID = IDC_FONTSTRIKEOUT; bbd.dwDefPos = 70; bbd.hIcon = PluginConfig.g_buttonBarIconHandles[15]; bbd.pwszTooltip = LPGENW("Strike-through text"); - CB_AddButton(0, (LPARAM)&bbd); + Srmm_AddButton(&bbd); bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON | BBBF_ISRSIDEBUTTON | BBBF_ISARROWBUTTON | BBBF_CREATEBYID; bbd.dwButtonID = IDOK; @@ -826,7 +67,7 @@ void CB_InitDefaultButtons() bbd.iButtonWidth = 51; bbd.hIcon = PluginConfig.g_buttonBarIconHandles[6]; bbd.pwszTooltip = LPGENW("Send message\nClick dropdown arrow for sending options"); - CB_AddButton(0, (LPARAM)&bbd); + Srmm_AddButton(&bbd); bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON | BBBF_ISRSIDEBUTTON | BBBF_CREATEBYID; bbd.dwButtonID = IDC_SAVE; @@ -834,7 +75,7 @@ void CB_InitDefaultButtons() bbd.iButtonWidth = 0; bbd.hIcon = PluginConfig.g_buttonBarIconHandles[8]; bbd.pwszTooltip = LPGENW("Close session"); - CB_AddButton(0, (LPARAM)&bbd); + Srmm_AddButton(&bbd); bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISRSIDEBUTTON | BBBF_CREATEBYID; bbd.dwButtonID = IDC_QUOTE; @@ -842,7 +83,7 @@ void CB_InitDefaultButtons() bbd.iButtonWidth = 0; bbd.hIcon = PluginConfig.g_buttonBarIconHandles[4]; bbd.pwszTooltip = LPGENW("Quote last message OR selected text"); - CB_AddButton(0, (LPARAM)&bbd); + Srmm_AddButton(&bbd); bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISRSIDEBUTTON | BBBF_CREATEBYID; bbd.dwButtonID = IDC_TIME; @@ -850,7 +91,7 @@ void CB_InitDefaultButtons() bbd.iButtonWidth = 0; bbd.hIcon = PluginConfig.g_buttonBarIconHandles[2]; bbd.pwszTooltip = LPGENW("Message log options"); - CB_AddButton(0, (LPARAM)&bbd); + Srmm_AddButton(&bbd); bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON | BBBF_ISRSIDEBUTTON | BBBF_CREATEBYID; bbd.dwButtonID = IDC_HISTORY; @@ -858,7 +99,7 @@ void CB_InitDefaultButtons() bbd.iButtonWidth = 0; bbd.hIcon = PluginConfig.g_buttonBarIconHandles[0]; bbd.pwszTooltip = LPGENW("View user's history"); - CB_AddButton(0, (LPARAM)&bbd); + Srmm_AddButton(&bbd); bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISRSIDEBUTTON | BBBF_CREATEBYID; bbd.dwButtonID = IDC_PIC; @@ -866,7 +107,7 @@ void CB_InitDefaultButtons() bbd.iButtonWidth = 0; bbd.hIcon = PluginConfig.g_buttonBarIconHandles[7]; bbd.pwszTooltip = LPGENW("Edit user notes"); - CB_AddButton(0, (LPARAM)&bbd); + Srmm_AddButton(&bbd); // chat buttons bbd.bbbFlags = BBBF_ISCHATBUTTON | BBBF_ISDUMMYBUTTON; @@ -876,17 +117,17 @@ void CB_InitDefaultButtons() bbd.iButtonWidth = 22; bbd.hIcon = 0; bbd.pwszTooltip = 0; - CB_AddButton(0, (LPARAM)&bbd); + Srmm_AddButton(&bbd); bbd.bbbFlags = BBBF_ISCHATBUTTON | BBBF_ISDUMMYBUTTON; bbd.dwButtonID = 2; bbd.dwDefPos = 22; - CB_AddButton(0, (LPARAM)&bbd); + Srmm_AddButton(&bbd); bbd.bbbFlags = BBBF_ISCHATBUTTON | BBBF_ISDUMMYBUTTON; bbd.dwButtonID = 3; bbd.dwDefPos = 71; - CB_AddButton(0, (LPARAM)&bbd); + Srmm_AddButton(&bbd); bbd.bbbFlags = BBBF_ISCHATBUTTON | BBBF_ISPUSHBUTTON | BBBF_CREATEBYID; bbd.dwButtonID = IDC_COLOR; @@ -894,7 +135,7 @@ void CB_InitDefaultButtons() bbd.dwDefPos = 80; bbd.hIcon = PluginConfig.g_buttonBarIconHandles[14]; bbd.pwszTooltip = LPGENW("Select font color"); - CB_AddButton(0, (LPARAM)&bbd); + Srmm_AddButton(&bbd); bbd.bbbFlags = BBBF_ISCHATBUTTON | BBBF_ISPUSHBUTTON | BBBF_CREATEBYID; bbd.dwButtonID = IDC_BKGCOLOR; @@ -902,7 +143,7 @@ void CB_InitDefaultButtons() bbd.iButtonWidth = 22; bbd.hIcon = PluginConfig.g_buttonBarIconHandles[16]; bbd.pwszTooltip = LPGENW("Change background color"); - CB_AddButton(0, (LPARAM)&bbd); + Srmm_AddButton(&bbd); bbd.bbbFlags = BBBF_ISCHATBUTTON | BBBF_ISRSIDEBUTTON | BBBF_CREATEBYID; bbd.dwButtonID = IDC_SHOWNICKLIST; @@ -910,7 +151,7 @@ void CB_InitDefaultButtons() bbd.iButtonWidth = 22; bbd.hIcon = PluginConfig.g_buttonBarIconHandles[19]; bbd.pwszTooltip = LPGENW("Toggle nick list"); - CB_AddButton(0, (LPARAM)&bbd); + Srmm_AddButton(&bbd); bbd.bbbFlags = BBBF_ISCHATBUTTON | BBBF_ISRSIDEBUTTON | BBBF_CREATEBYID; bbd.dwButtonID = IDC_FILTER; @@ -918,7 +159,7 @@ void CB_InitDefaultButtons() bbd.iButtonWidth = 22; bbd.hIcon = PluginConfig.g_buttonBarIconHandles[18]; bbd.pwszTooltip = LPGENW("Event filter - right click to setup, left click to activate/deactivate"); - CB_AddButton(0, (LPARAM)&bbd); + Srmm_AddButton(&bbd); bbd.bbbFlags = BBBF_ISCHATBUTTON | BBBF_ISRSIDEBUTTON | BBBF_CREATEBYID; bbd.dwButtonID = IDC_CHANMGR; @@ -926,27 +167,9 @@ void CB_InitDefaultButtons() bbd.iButtonWidth = 22; bbd.hIcon = PluginConfig.g_buttonBarIconHandles[17]; bbd.pwszTooltip = LPGENW("Channel manager"); - CB_AddButton(0, (LPARAM)&bbd); - - BB_RegisterSeparators(); -} - -void CB_ReInitCustomButtons() -{ - for (int i = arButtonsList.getCount()-1; i >= 0; i--) { - CustomButtonData *cbd = arButtonsList[i]; - - if (cbd->m_opFlags & (BBSF_NTBSWAPED | BBSF_NTBDESTRUCT)) { - cbd->m_opFlags ^= BBSF_NTBSWAPED; - - if (cbd->m_opFlags & BBSF_NTBDESTRUCT) - arButtonsList.remove(i); - } - } - qsort(arButtonsList.getArray(), arButtonsList.getCount(), sizeof(void*), sstSortButtons); - - M.BroadcastMessage(DM_BBNEEDUPDATE, 0, 0); - M.BroadcastMessage(DM_LOADBUTTONBARICONS, 0, 0); + Srmm_AddButton(&bbd); + + return 0; } void BB_InitDlgButtons(TWindowData *dat) @@ -960,7 +183,7 @@ void BB_InitDlgButtons(TWindowData *dat) RECT rcSplitter; POINT ptSplitter; int splitterY; - BYTE gap = DPISCALEX_S(PluginConfig.m_iButtonsBarGap); + BYTE gap = DPISCALEX_S(db_get_b(NULL, SRMSGMOD, "ButtonsBarGap", 1)); GetWindowRect(GetDlgItem(hdlg, (dat->bType == SESSIONTYPE_IM) ? IDC_SPLITTER : IDC_SPLITTERY), &rcSplitter); ptSplitter.x = 0; @@ -973,8 +196,8 @@ void BB_InitDlgButtons(TWindowData *dat) HWND hwndBtn = NULL; dat->bbLSideWidth = dat->bbRSideWidth = 0; - for (int i = 0; i < arButtonsList.getCount(); i++) { - CustomButtonData *cbd = arButtonsList[i]; + CustomButtonData *cbd; + for (int i = 0; cbd = Srmm_GetNthButton(i); i++) { if (((dat->bType == SESSIONTYPE_IM && cbd->m_bIMButton) || (dat->bType == SESSIONTYPE_CHAT && cbd->m_bChatButton))) { if (!cbd->m_bHidden) { if (cbd->m_bRSided) @@ -989,8 +212,23 @@ void BB_InitDlgButtons(TWindowData *dat) hwndBtn = CreateWindowEx(0, L"MButtonClass", L"", WS_CHILD | WS_VISIBLE | WS_TABSTOP, x, 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); + if (!cbd->m_bSeparator && hwndBtn) { + SendMessage(hwndBtn, BUTTONSETASFLATBTN, TRUE, 0); + SendMessage(hwndBtn, BUTTONSETASTHEMEDBTN, CSkin::IsThemed(), 0); + if (cbd->m_hIcon) + SendMessage(hwndBtn, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIconByHandle(cbd->m_hIcon)); + if (cbd->m_pwszTooltip) + SendMessage(hwndBtn, BUTTONADDTOOLTIP, (WPARAM)TranslateW(cbd->m_pwszTooltip), BATF_UNICODE); + SendMessage(hwndBtn, BUTTONSETCONTAINER, (LPARAM)dat->pContainer, 0); + SendMessage(hwndBtn, BUTTONSETASTOOLBARBUTTON, TRUE, 0); + + if (hwndBtn) { + if (cbd->m_dwArrowCID) + SendMessage(hwndBtn, BUTTONSETARROW, cbd->m_dwArrowCID, 0); + if (cbd->m_bPushButton) + SendMessage(hwndBtn, BUTTONSETASPUSHBTN, TRUE, 0); + } + } } else if (GetDlgItem(hdlg, cbd->m_dwButtonCID)) DestroyWindow(GetDlgItem(hdlg, cbd->m_dwButtonCID)); @@ -1005,36 +243,18 @@ void BB_InitDlgButtons(TWindowData *dat) void BB_RedrawButtons(TWindowData *dat) { - for (int i = 0; i < arButtonsList.getCount(); i++) { - CustomButtonData *cbd = arButtonsList[i]; - HWND hwnd = GetDlgItem(dat->hwnd, cbd->m_dwButtonCID); - if (hwnd) - InvalidateRect(hwnd, 0, TRUE); - } + Srmm_RedrawToolbarIcons(dat->hwnd); - HWND hwndToggleSideBar = GetDlgItem(dat->hwnd, dat->bType == SESSIONTYPE_IM ? IDC_TOGGLESIDEBAR : IDC_CHAT_TOGGLESIDEBAR); + HWND hwndToggleSideBar = GetDlgItem(dat->hwnd, IDC_TOGGLESIDEBAR); if (hwndToggleSideBar && IsWindow(hwndToggleSideBar)) InvalidateRect(hwndToggleSideBar, 0, TRUE); } -void BB_UpdateIcons(HWND hdlg) -{ - for (int i = 0; i < arButtonsList.getCount(); i++) { - CustomButtonData *cbd = arButtonsList[i]; - if (cbd) { - if (!cbd->m_bSeparator) { - HWND hwndBtn = GetDlgItem(hdlg, cbd->m_dwButtonCID); - if (hwndBtn && cbd->m_hIcon) - SendMessage(hwndBtn, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIconByHandle(cbd->m_hIcon)); - } - } - } -} - void BB_RefreshTheme(const TWindowData *dat) { - for (int i = 0; i < arButtonsList.getCount(); i++) - SendDlgItemMessage(dat->hwnd, arButtonsList[i]->m_dwButtonCID, WM_THEMECHANGED, 0, 0); + CustomButtonData *cbd; + for (int i = 0; cbd = Srmm_GetNthButton(i); i++) + SendDlgItemMessage(dat->hwnd, cbd->m_dwButtonCID, WM_THEMECHANGED, 0, 0); } BOOL BB_SetButtonsPos(TWindowData *dat) @@ -1044,19 +264,16 @@ BOOL BB_SetButtonsPos(TWindowData *dat) HWND hwnd = dat->hwnd; RECT rect; - int i; HWND hwndBtn = 0; - BYTE gap = DPISCALEX_S(PluginConfig.m_iButtonsBarGap); + BYTE gap = DPISCALEX_S(db_get_b(NULL, SRMSGMOD, "ButtonsBarGap", 1)); 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); + HWND hwndToggleSideBar = GetDlgItem(hwnd, IDC_TOGGLESIDEBAR); ShowWindow(hwndToggleSideBar, (showToolbar && dat->pContainer->SideBar->isActive()) ? SW_SHOW : SW_HIDE); - HDWP hdwp = BeginDeferWindowPos(arButtonsList.getCount() + 1); - - mir_cslock lck(csToolBar); + HDWP hdwp = BeginDeferWindowPos(Srmm_GetButtonCount() + 1); RECT rcSplitter; GetWindowRect(GetDlgItem(hwnd, (dat->bType == SESSIONTYPE_IM) ? IDC_SPLITTER : IDC_SPLITTERY), &rcSplitter); @@ -1082,8 +299,8 @@ BOOL BB_SetButtonsPos(TWindowData *dat) tempL -= 10; } - for (i = 0; i < arButtonsList.getCount(); i++) { - CustomButtonData *cbd = arButtonsList[i]; + CustomButtonData *cbd; + for (int i = 0; cbd = Srmm_GetNthButton(i); i++) { if (cbd->m_bRSided) // filter only left buttons continue; @@ -1133,8 +350,7 @@ BOOL BB_SetButtonsPos(TWindowData *dat) tempR -= 12; } - for (i = 0; i < arButtonsList.getCount(); i++) { - CustomButtonData *cbd = arButtonsList[i]; + for (int i = 0; cbd = Srmm_GetNthButton(i); i++) { if (!cbd->m_bRSided) // filter only right buttons continue; @@ -1192,8 +408,8 @@ void BB_CustomButtonClick(TWindowData *dat, DWORD idFrom, HWND hwndFrom, BOOL co cbcd.pt.x = rc.left; cbcd.pt.y = rc.bottom; - for (int i = 0; i < arButtonsList.getCount(); i++) { - CustomButtonData *cbd = arButtonsList[i]; + CustomButtonData *cbd; + for (int i = 0; cbd = Srmm_GetNthButton(i); i++) { if (cbd->m_dwButtonCID == idFrom) { cbcd.pszModule = cbd->m_pszModuleName; cbcd.dwButtonId = cbd->m_dwButtonOrigID; @@ -1214,8 +430,8 @@ void BB_CustomButtonClick(TWindowData *dat, DWORD idFrom, HWND hwndFrom, BOOL co void CB_DestroyAllButtons(HWND hwndDlg) { - for (int i = 0; i < arButtonsList.getCount(); i++) { - CustomButtonData *cbd = arButtonsList[i]; + CustomButtonData *cbd; + for (int i = 0; cbd = Srmm_GetNthButton(i); i++) { HWND hwndBtn = GetDlgItem(hwndDlg, cbd->m_dwButtonCID); if (hwndBtn) DestroyWindow(hwndBtn); @@ -1258,22 +474,12 @@ void CB_ChangeButton(HWND hwndDlg, TWindowData *dat, CustomButtonData *cbd) void CB_InitCustomButtons() { - dwSepCount = M.GetDword("TabSRMM_Toolbar", "SeparatorsCount", 0); - - CreateServiceFunction(MS_BB_ADDBUTTON, CB_AddButton); - CreateServiceFunction(MS_BB_REMOVEBUTTON, CB_RemoveButton); - CreateServiceFunction(MS_BB_MODIFYBUTTON, CB_ModifyButton); - CreateServiceFunction(MS_BB_GETBUTTONSTATE, CB_GetButtonState); - CreateServiceFunction(MS_BB_SETBUTTONSTATE, CB_SetButtonState); - - hHookToolBarLoadedEvt = CreateHookableEvent(ME_MSG_TOOLBARLOADED); hHookButtonPressedEvt = CreateHookableEvent(ME_MSG_BUTTONPRESSED); + + HookEvent(ME_MSG_TOOLBARLOADED, CB_InitDefaultButtons); } void CB_DeInitCustomButtons() { - wipeList(arButtonsList); - - DestroyHookableEvent(hHookToolBarLoadedEvt); DestroyHookableEvent(hHookButtonPressedEvt); } diff --git a/plugins/TabSRMM/src/chat/chat_resource.h b/plugins/TabSRMM/src/chat/chat_resource.h index 4ae21e844e..1674adf3e5 100644 --- a/plugins/TabSRMM/src/chat/chat_resource.h +++ b/plugins/TabSRMM/src/chat/chat_resource.h @@ -89,7 +89,6 @@ #define IDC_10 1209
#define IDC_11 1210
#define IDC_PANELSPLITTER 1216
-#define IDC_CHAT_TOGGLESIDEBAR 1277
#define IDC_P1 1300
#define IDC_P2 1301
#define IDC_P3 1302
diff --git a/plugins/TabSRMM/src/chat/window.cpp b/plugins/TabSRMM/src/chat/window.cpp index f67ccbdcc2..646a4398f1 100644 --- a/plugins/TabSRMM/src/chat/window.cpp +++ b/plugins/TabSRMM/src/chat/window.cpp @@ -1658,17 +1658,17 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar GetMYUIN(dat); GetMyNick(dat); - CustomizeButton(CreateWindowEx(0, L"MButtonClass", L"", WS_CHILD | WS_VISIBLE | WS_TABSTOP, 0, 0, 6, DPISCALEY_S(20), - hwndDlg, (HMENU)IDC_CHAT_TOGGLESIDEBAR, g_hInst, NULL)); - SendDlgItemMessage(hwndDlg, IDC_CHAT_TOGGLESIDEBAR, BUTTONSETASTHEMEDBTN, 1, 0); - SendDlgItemMessage(hwndDlg, IDC_CHAT_TOGGLESIDEBAR, BUTTONSETCONTAINER, (LPARAM)dat->pContainer, 0); - SendDlgItemMessage(hwndDlg, IDC_CHAT_TOGGLESIDEBAR, BUTTONSETASFLATBTN, FALSE, 0); - SendDlgItemMessage(hwndDlg, IDC_CHAT_TOGGLESIDEBAR, BUTTONSETASTOOLBARBUTTON, TRUE, 0); - SendDlgItemMessage(hwndDlg, IDC_CHAT_TOGGLESIDEBAR, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Expand or collapse the side bar"), BATF_UNICODE); + HWND hwndBtn = CreateWindowEx(0, L"MButtonClass", L"", WS_CHILD | WS_VISIBLE | WS_TABSTOP, 0, 0, 6, DPISCALEY_S(20), hwndDlg, (HMENU)IDC_TOGGLESIDEBAR, g_hInst, NULL); + CustomizeButton(hwndBtn); + SendMessage(hwndBtn, BUTTONSETASTHEMEDBTN, 1, 0); + SendMessage(hwndBtn, BUTTONSETCONTAINER, (LPARAM)dat->pContainer, 0); + SendMessage(hwndBtn, BUTTONSETASFLATBTN, FALSE, 0); + SendMessage(hwndBtn, BUTTONSETASTOOLBARBUTTON, TRUE, 0); + SendMessage(hwndBtn, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Expand or collapse the side bar"), BATF_UNICODE); DM_InitTip(dat); BB_InitDlgButtons(dat); - SendMessage(hwndDlg, DM_LOADBUTTONBARICONS, 0, 0); + SendMessage(hwndDlg, WM_CBD_LOADICONS, 0, 0); mir_subclassWindow(GetDlgItem(hwndDlg, IDC_SPLITTERX), SplitterSubclassProc); mir_subclassWindow(GetDlgItem(hwndDlg, IDC_SPLITTERY), SplitterSubclassProc); @@ -1706,8 +1706,8 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar PostMessage(hwndDlg, GC_REDRAWLOG, 0, 0); break; - case DM_LOADBUTTONBARICONS: - BB_UpdateIcons(hwndDlg); + case WM_CBD_LOADICONS: + Srmm_UpdateToolbarIcons(hwndDlg); return 0; case GC_SETWNDPROPS: @@ -2647,7 +2647,7 @@ LABEL_SHOWWINDOW: RedrawWindow(GetDlgItem(hwndDlg, IDC_LIST), NULL, NULL, RDW_INVALIDATE); break; - case IDC_CHAT_TOGGLESIDEBAR: + case IDC_TOGGLESIDEBAR: SendMessage(dat->pContainer->hwnd, WM_COMMAND, IDC_TOGGLESIDEBAR, 0); break; diff --git a/plugins/TabSRMM/src/globals.cpp b/plugins/TabSRMM/src/globals.cpp index 51fb9ecea7..fe655afa41 100644 --- a/plugins/TabSRMM/src/globals.cpp +++ b/plugins/TabSRMM/src/globals.cpp @@ -40,7 +40,6 @@ static TContainerSettings _cnt_default = { false, CNT_FLAGS_DEFAULT, CNT_FLAGSEX wchar_t* CGlobals::m_default_container_name = L"default";
extern HANDLE hHookButtonPressedEvt;
-extern HANDLE hHookToolBarLoadedEvt;
EXCEPTION_RECORD CGlobals::m_exRecord = { 0 };
CONTEXT CGlobals::m_exCtx = { 0 };
@@ -116,7 +115,6 @@ void CGlobals::reloadSystemModulesChanged() }
else db_set_b(0, SRMSGMOD_T, "ieview_installed", 0);
- m_iButtonsBarGap = M.GetByte("ButtonsBarGap", 1);
m_hwndClist = pcli->hwndContactList;
g_bPopupAvail = ServiceExists(MS_POPUP_ADDPOPUPT) != 0;
@@ -297,9 +295,7 @@ int CGlobals::ModulesLoaded(WPARAM, LPARAM) ::Chat_ModulesLoaded();
::BuildContainerMenu();
- ::CB_InitDefaultButtons();
::ModPlus_Init();
- ::NotifyEventHooks(hHookToolBarLoadedEvt, 0, 0);
if (M.GetByte("avatarmode", -1) == -1)
db_set_b(0, SRMSGMOD_T, "avatarmode", 2);
diff --git a/plugins/TabSRMM/src/globals.h b/plugins/TabSRMM/src/globals.h index 3cc0a9b484..bd34465557 100644 --- a/plugins/TabSRMM/src/globals.h +++ b/plugins/TabSRMM/src/globals.h @@ -113,7 +113,6 @@ public: double m_DPIscaleX;
double m_DPIscaleY;
HBITMAP m_hbmMsgArea;
- BYTE m_iButtonsBarGap;
BYTE m_WinVerMajor;
BYTE m_WinVerMinor;
bool m_bIsVista, m_bIsWin7;
diff --git a/plugins/TabSRMM/src/modplus.cpp b/plugins/TabSRMM/src/modplus.cpp index d58e9a3062..3885fbe072 100644 --- a/plugins/TabSRMM/src/modplus.cpp +++ b/plugins/TabSRMM/src/modplus.cpp @@ -49,18 +49,14 @@ static wchar_t* getMenuEntry(int i) static int RegisterCustomButton(WPARAM, LPARAM)
{
- if (!ServiceExists(MS_BB_ADDBUTTON))
- return 1;
-
- BBButton bbd = { 0 };
- bbd.cbSize = sizeof(BBButton);
+ BBButton bbd = {};
bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISPUSHBUTTON;
bbd.dwButtonID = 1;
bbd.dwDefPos = 200;
bbd.hIcon = PluginConfig.g_buttonBarIconHandles[3];
bbd.pszModuleName = "Tabmodplus";
bbd.pwszTooltip = LPGENW("Insert [img] tag / surround selected text with [img][/img]");
- return CallService(MS_BB_ADDBUTTON, 0, (LPARAM)&bbd);
+ return Srmm_AddButton(&bbd);
}
static int CustomButtonPressed(WPARAM wParam, LPARAM lParam)
@@ -69,10 +65,10 @@ static int CustomButtonPressed(WPARAM wParam, LPARAM lParam) if (mir_strcmp(cbcd->pszModule, "Tabmodplus") || cbcd->dwButtonId != 1)
return 0;
- BBButton bbd = { sizeof(bbd) };
+ BBButton bbd = {};
bbd.dwButtonID = 1;
bbd.pszModuleName = "Tabmodplus";
- CallService(MS_BB_GETBUTTONSTATE, wParam, (LPARAM)&bbd);
+ Srmm_SetButtonState(wParam, &bbd);
wchar_t *pszText = L"";
CHARRANGE cr;
@@ -133,21 +129,21 @@ static int CustomButtonPressed(WPARAM wParam, LPARAM lParam) bbd.pwszTooltip = 0;
bbd.hIcon = 0;
bbd.bbbFlags = BBSF_RELEASED;
- CallService(MS_BB_SETBUTTONSTATE, wParam, (LPARAM)&bbd);
+ Srmm_SetButtonState(wParam, &bbd);
break;
case 3:
pszFormatedText = L"[img]";
bbd.pwszTooltip = LPGENW("Insert [img] tag / surround selected text with [img][/img]");
- CallService(MS_BB_SETBUTTONSTATE, wParam, (LPARAM)&bbd);
+ Srmm_SetButtonState(wParam, &bbd);
break;
case 4:
pszFormatedText = L"[/img]";
bbd.pwszTooltip = LPGENW("Insert [img] tag / surround selected text with [img][/img]");
- CallService(MS_BB_SETBUTTONSTATE, wParam, (LPARAM)&bbd);
+ Srmm_SetButtonState(wParam, &bbd);
break;
}
diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp index c3f743914c..567673c5a5 100644 --- a/plugins/TabSRMM/src/msgdialog.cpp +++ b/plugins/TabSRMM/src/msgdialog.cpp @@ -1268,7 +1268,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l dat->minEditBoxSize.cy = rc.bottom - rc.top;
BB_InitDlgButtons(dat);
- SendMessage(hwndDlg, DM_LOADBUTTONBARICONS, 0, 0);
+ SendMessage(hwndDlg, WM_CBD_LOADICONS, 0, 0);
SendDlgItemMessage(hwndDlg, IDC_ADD, BUTTONSETASFLATBTN, TRUE, 0);
SendDlgItemMessage(hwndDlg, IDC_CANCELADD, BUTTONSETASFLATBTN, TRUE, 0);
@@ -2106,13 +2106,13 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l }
return 0;
- case DM_LOADBUTTONBARICONS:
+ case WM_CBD_LOADICONS:
for (int i = 0; i < _countof(buttonicons); i++) {
SendDlgItemMessage(hwndDlg, buttonicons[i].id, BM_SETIMAGE, IMAGE_ICON, (LPARAM)*buttonicons[i].pIcon);
SendDlgItemMessage(hwndDlg, buttonicons[i].id, BUTTONSETCONTAINER, (LPARAM)m_pContainer, 0);
}
- BB_UpdateIcons(hwndDlg);
+ Srmm_UpdateToolbarIcons(hwndDlg);
SendMessage(hwndDlg, DM_UPDATEWINICON, 0, 0);
return 0;
diff --git a/plugins/TabSRMM/src/msgoptions.cpp b/plugins/TabSRMM/src/msgoptions.cpp index 31245d3391..d63746a2dd 100644 --- a/plugins/TabSRMM/src/msgoptions.cpp +++ b/plugins/TabSRMM/src/msgoptions.cpp @@ -1281,11 +1281,6 @@ static int OptInitialise(WPARAM wParam, LPARAM lParam) odp.pfnDlgProc = DlgProcLogOptions;
Options_AddPage(wParam, &odp);
- odp.szTab.a = LPGEN("Toolbar");
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_TOOLBAR);
- odp.pfnDlgProc = DlgProcToolBar;
- Options_AddPage(wParam, &odp);
-
odp.szTab.a = LPGEN("Advanced tweaks");
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS_PLUS);
odp.pfnDlgProc = PlusOptionsProc;
diff --git a/plugins/TabSRMM/src/msgs.cpp b/plugins/TabSRMM/src/msgs.cpp index e88962717b..951034efc0 100644 --- a/plugins/TabSRMM/src/msgs.cpp +++ b/plugins/TabSRMM/src/msgs.cpp @@ -878,7 +878,7 @@ static int TSAPI LoadFromIconLib() PluginConfig.g_iconClock = IcoLib_GetIcon("tabSRMM_clock_symbol");
CacheMsgLogIcons();
- M.BroadcastMessage(DM_LOADBUTTONBARICONS, 0, 0);
+ M.BroadcastMessage(WM_CBD_LOADICONS, 0, 0);
return 0;
}
diff --git a/plugins/TabSRMM/src/msgs.h b/plugins/TabSRMM/src/msgs.h index 74c40c9e68..a765921139 100644 --- a/plugins/TabSRMM/src/msgs.h +++ b/plugins/TabSRMM/src/msgs.h @@ -542,7 +542,6 @@ struct TNewWindowData #define DM_PROTOACK (TM_USER+54)
#define DM_OWNNICKCHANGED (TM_USER+55)
#define DM_CONFIGURETOOLBAR (TM_USER+56)
-#define DM_LOADBUTTONBARICONS (TM_USER+57)
#define DM_ACTIVATETOOLTIP (TM_USER+58)
#define DM_UINTOCLIPBOARD (TM_USER+59)
#define DM_SENDMESSAGECOMMAND (TM_USER+61)
diff --git a/plugins/TabSRMM/src/resource.h b/plugins/TabSRMM/src/resource.h index 59b4511dfc..029ae6c4d9 100644 --- a/plugins/TabSRMM/src/resource.h +++ b/plugins/TabSRMM/src/resource.h @@ -53,7 +53,6 @@ #define IDD_SELECTCONTAINER 299
#define IDD_CONTAINEROPTIONS 300
#define IDD_OPT_CONTAINERS 301
-#define IDD_OPT_TOOLBAR 304
#define IDR_MENUBAR 308
#define IDD_CHOOSESTATUSMODES 310
#define IDD_SKINTABDIALOG 312
@@ -456,13 +455,8 @@ #define IDC_DESC 1404
#define IDC_LABEL_PRIVATETHEME 1405
#define IDC_MSGLOGDIDSPLAY 1407
-#define IDC_IMCHECK 1410
-#define IDC_CHATCHECK 1411
-#define IDC_CANBEHIDDEN 1412
-#define IDC_BBRESET 1413
#define IDC_BOTTOMTOOLBAR 1414
#define IDC_BUTTON1 1415
-#define IDC_SEPARATOR 1415
#define IDC_PLUS_REVERT 1415
#define IDC_SIZECOMPACT 1415
#define IDC_RESCANSKIN 1415
@@ -516,7 +510,6 @@ #define IDC_SKIN_WARN 1440
#define IDC_QMGR_LIST 1441
#define IDC_QMGR_FILTER 1442
-#define IDC_TOOLBARTREE 1444
#define IDC_QMGR_HELP 1444
#define IDC_QMGR_ERRORPOPUPS 1445
#define IDC_QMGR_ERRORPOPUPS2 1446
@@ -553,7 +546,6 @@ #define IDC_O_SOUNDSINACTIVE 1704
#define IDC_O_SOUNDSFOCUSED 1705
#define IDC_O_TITLEBARFORMAT 1706
-#define IDC_EDIT1 1720
#define IDC_O_CNTPRIVATE 1901
#define IDC_PLUS_CHECKTREE 2000
#define IDC_COPYRIGHT 2002
diff --git a/plugins/TabSRMM/src/sidebar.cpp b/plugins/TabSRMM/src/sidebar.cpp index ccaf889ee2..aa1b362298 100644 --- a/plugins/TabSRMM/src/sidebar.cpp +++ b/plugins/TabSRMM/src/sidebar.cpp @@ -552,7 +552,7 @@ void CSideBar::addSession(const TWindowData *dat, int position) else
m_buttonlist.insert(item, position);
- SendDlgItemMessage(dat->hwnd, dat->bType == SESSIONTYPE_IM ? IDC_TOGGLESIDEBAR : IDC_CHAT_TOGGLESIDEBAR, BM_SETIMAGE, IMAGE_ICON,
+ SendDlgItemMessage(dat->hwnd, IDC_TOGGLESIDEBAR, BM_SETIMAGE, IMAGE_ICON,
(LPARAM)(m_dwFlags & SIDEBARORIENTATION_LEFT ? PluginConfig.g_buttonBarIcons[ICON_DEFAULT_LEFT] : PluginConfig.g_buttonBarIcons[ICON_DEFAULT_RIGHT]));
Invalidate();
diff --git a/plugins/TabSRMM/src/stdafx.h b/plugins/TabSRMM/src/stdafx.h index 39383d1ed6..42140ab385 100644 --- a/plugins/TabSRMM/src/stdafx.h +++ b/plugins/TabSRMM/src/stdafx.h @@ -231,7 +231,6 @@ extern LOGFONTA logfonts[MSGDLGFONTCOUNT + 2]; extern COLORREF fontcolors[MSGDLGFONTCOUNT + 2];
extern HINSTANCE hinstance;
extern BOOL g_bIMGtagButton;
-extern HANDLE hHookToolBarLoadedEvt;
extern TLogIcon msgLogIcons[NR_LOGICONS * 3];
extern const wchar_t *pszIDCSAVE_save, *pszIDCSAVE_close;
extern char *TemplateNames[];
@@ -268,12 +267,10 @@ void TreeViewSetFromDB(HWND hwndTree, UINT id, DWORD dwFlags); void TreeViewToDB(HWND hwndTree, UINT id, char *DBPath, DWORD *dwFlags);
BOOL TreeViewHandleClick(HWND hwndDlg, HWND hwndTree, WPARAM wParam, LPARAM lParam);
-
INT_PTR CALLBACK DlgProcSetupStatusModes(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK DlgProcPopupOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK DlgProcTabConfig(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK DlgProcTemplateEditor(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
-INT_PTR CALLBACK DlgProcToolBar(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK PlusOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK DlgProcOptions1(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK DlgProcOptions2(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
diff --git a/src/mir_app/res/resource.rc b/src/mir_app/res/resource.rc index 35eba4afd8..e994096bb2 100644 --- a/src/mir_app/res/resource.rc +++ b/src/mir_app/res/resource.rc @@ -791,6 +791,22 @@ BEGIN CTEXT "",IDC_COLORTEXT,0,0,197,12,SS_CENTERIMAGE
END
+IDD_OPT_TOOLBAR DIALOGEX 0, 0, 303, 229
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
+EXSTYLE WS_EX_CONTROLPARENT
+FONT 8, "MS Shell Dlg", 0, 0, 0x1
+BEGIN
+ CONTROL "",IDC_TOOLBARTREE,"SysTreeView32",TVS_SHOWSELALWAYS | TVS_NOTOOLTIPS | TVS_NOHSCROLL | TVS_CHECKBOXES | TVS_FULLROWSELECT | WS_HSCROLL | WS_TABSTOP,1,4,301,171,WS_EX_CLIENTEDGE
+ PUSHBUTTON "Reset",IDC_BBRESET,250,211,53,15
+ CONTROL "Show in IM chats",IDC_IMCHECK,"Button",BS_AUTOCHECKBOX | BS_VCENTER | BS_MULTILINE | WS_TABSTOP,4,181,127,12
+ CONTROL "Show in chat rooms",IDC_CHATCHECK,"Button",BS_AUTOCHECKBOX | BS_VCENTER | BS_MULTILINE | WS_TABSTOP,4,196,127,12
+ CONTROL "",IDC_SPIN1,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_GROUP,272,183,11,12
+ RTEXT "Gap between buttons:",IDC_STATIC,136,183,104,12,SS_CENTERIMAGE
+ CONTROL "Hide if there isn't enough space",IDC_CANBEHIDDEN,
+ "Button",BS_AUTOCHECKBOX | BS_VCENTER | BS_MULTILINE | WS_TABSTOP,4,209,131,17
+ PUSHBUTTON "Insert separator",IDC_SEPARATOR,137,211,103,15,BS_MULTILINE
+END
+
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
diff --git a/src/mir_app/src/chat_svc.cpp b/src/mir_app/src/chat_svc.cpp index 3ce6a8417d..879fab56c9 100644 --- a/src/mir_app/src/chat_svc.cpp +++ b/src/mir_app/src/chat_svc.cpp @@ -741,6 +741,7 @@ int LoadChatModule(void) HookEvent(ME_SYSTEM_PRESHUTDOWN, PreShutdown);
HookEvent(ME_SKIN_ICONSCHANGED, IconsChanged);
+ chatApi.hWindowList = WindowList_Create();
chatApi.hSendEvent = CreateHookableEvent(ME_GC_EVENT);
chatApi.hBuildMenuEvent = CreateHookableEvent(ME_GC_BUILDMENU);
hHookEvent = CreateHookableEvent(ME_GC_HOOK_EVENT);
@@ -763,6 +764,8 @@ void UnloadChatModule(void) FreeMsgLogBitmaps();
OptionsUnInit();
+ WindowList_Destroy(chatApi.hWindowList);
+
DestroyHookableEvent(chatApi.hSendEvent);
DestroyHookableEvent(chatApi.hBuildMenuEvent);
DestroyHookableEvent(hHookEvent);
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index cb33d7d808..75a8b9629c 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -327,3 +327,13 @@ Options_AddPage @327 Options_Open @328
Options_OpenPage @329
Chat_HoverMouse @330
+Srmm_ModifyButton @331
+Srmm_AddButton @332
+Srmm_GetButtonState @333
+Srmm_RemoveButton @334
+Srmm_ResetToolbar @335
+Srmm_SetButtonState @336
+Srmm_UpdateToolbarIcons @337
+Srmm_RedrawToolbarIcons @338
+Srmm_GetNthButton @339
+Srmm_GetButtonCount @340
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 6bf981dead..5d571223a0 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -327,3 +327,13 @@ Options_AddPage @327 Options_Open @328
Options_OpenPage @329
Chat_HoverMouse @330
+Srmm_ModifyButton @331
+Srmm_AddButton @332
+Srmm_GetButtonState @333
+Srmm_RemoveButton @334
+Srmm_ResetToolbar @335
+Srmm_SetButtonState @336
+Srmm_UpdateToolbarIcons @337
+Srmm_RedrawToolbarIcons @338
+Srmm_GetNthButton @339
+Srmm_GetButtonCount @340
diff --git a/src/mir_app/src/miranda.h b/src/mir_app/src/miranda.h index a440c951ad..cf54e15b4a 100644 --- a/src/mir_app/src/miranda.h +++ b/src/mir_app/src/miranda.h @@ -78,6 +78,7 @@ void InitPathVar(void); /**** srmm.cpp *************************************************************************/
void KillModuleSrmmIcons(int hLangpack);
+void KillModuleToolbarIcons(int hLangpack);
/**** utf.cpp **************************************************************************/
diff --git a/src/mir_app/src/newplugins.cpp b/src/mir_app/src/newplugins.cpp index e282f4aa26..9fbb3e9b4a 100644 --- a/src/mir_app/src/newplugins.cpp +++ b/src/mir_app/src/newplugins.cpp @@ -358,6 +358,7 @@ int Plugin_UnloadDyn(pluginEntry *p) KillModuleSounds(_hLang);
KillModuleExtraIcons(_hLang);
KillModuleSrmmIcons(_hLang);
+ KillModuleToolbarIcons(_hLang);
}
NotifyFastHook(hevUnloadModule, (WPARAM)p->bpi.pluginInfo, (LPARAM)p->bpi.hInst);
diff --git a/src/mir_app/src/resource.h b/src/mir_app/src/resource.h index e126bcb0fb..eb56125575 100644 --- a/src/mir_app/src/resource.h +++ b/src/mir_app/src/resource.h @@ -12,6 +12,7 @@ #define IDI_SMS 103
#define IDI_ONLINE 104
#define IDI_OFFLINE 105
+#define IDD_OPT_TOOLBAR 106
#define IDD_OPT_FONTS 107
#define IDD_OPT_GENMENU 108
#define IDD_OPT_PROTOCOLORDER 109
@@ -220,6 +221,7 @@ #define IDC_URLS 1037
#define IDC_COLORTEXT 1038
#define IDC_REPLY 1039
+#define IDC_TOOLBARTREE 1040
#define IDC_URL 1041
#define IDC_FONTGROUP 1042
#define IDC_BTN_RESET 1045
@@ -230,6 +232,7 @@ #define IDC_NAMENICK 1049
#define IDC_NAMEFIRST 1050
#define IDC_NAMELAST 1051
+#define IDC_BBRESET 1052
#define IDC_NICK 1053
#define IDC_BTN_EXPORT 1054
#define IDC_FONTLIST 1056
@@ -278,6 +281,11 @@ #define IDC_TXT_PASSWORD 1097
#define IDC_TXT_COMBO 1098
#define IDC_TXT_RICHEDIT 1099
+#define IDC_IMCHECK 1100
+#define IDC_CHATCHECK 1101
+#define IDC_CANBEHIDDEN 1102
+#define IDC_SPIN1 1103
+#define IDC_SEPARATOR 1104
#define IDC_BUILDTIME 1108
#define IDC_CREDITSFILE 1109
#define IDC_NUMBER 1113
diff --git a/src/mir_app/src/srmm_statusicon.cpp b/src/mir_app/src/srmm_statusicon.cpp index eb2ded0671..a780effdcb 100644 --- a/src/mir_app/src/srmm_statusicon.cpp +++ b/src/mir_app/src/srmm_statusicon.cpp @@ -23,6 +23,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h"
+void LoadSrmmToolbarModule();
+void UnloadSrmmToolbarModule();
+
void SafeDestroyIcon(HICON hIcon)
{
if (hIcon != NULL)
@@ -202,6 +205,8 @@ void KillModuleSrmmIcons(int _hLang) int LoadSrmmModule()
{
+ LoadSrmmToolbarModule();
+
hHookIconsChanged = CreateHookableEvent(ME_MSG_ICONSCHANGED);
return 0;
}
@@ -211,4 +216,6 @@ void UnloadSrmmModule() arIcons.destroy();
NotifyEventHooks(hHookIconsChanged, NULL, NULL);
DestroyHookableEvent(hHookIconsChanged);
+
+ UnloadSrmmToolbarModule();
}
diff --git a/src/mir_app/src/srmm_toolbar.cpp b/src/mir_app/src/srmm_toolbar.cpp new file mode 100644 index 0000000000..ce6cf921cf --- /dev/null +++ b/src/mir_app/src/srmm_toolbar.cpp @@ -0,0 +1,739 @@ +/* + +Miranda NG: the free IM client for Microsoft* Windows* + +Copyright (ñ) 2012-16 Miranda NG project, +all portions of this codebase are copyrighted to the people +listed in contributors.txt. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "stdafx.h" + +#define MODULENAME "SRMsg" + +#define DPISCALEY_S(argY) ((int)((double)(argY) * g_DPIscaleY)) +#define DPISCALEX_S(argX) ((int)((double)(argX) * g_DPIscaleX)) + +static double g_DPIscaleX, g_DPIscaleY; + +static int SortButtons(const CustomButtonData *p1, const CustomButtonData *p2) +{ + if (p1->m_bRSided != p2->m_bRSided) + return (p2->m_bRSided) ? -1 : 1; + return p1->m_dwPosition - p2->m_dwPosition; +} + +static LIST<CustomButtonData> arButtonsList(1, SortButtons); + +DWORD LastCID = 4000; +DWORD dwSepCount = 0; + +static mir_cs csToolBar; +static HANDLE hHookToolBarLoadedEvt; + +static void wipeList(LIST<CustomButtonData> &list) +{ + for (int i = list.getCount() - 1; i >= 0; i--) { + delete list[i]; + list.remove(i); + } +} + +static int sstSortButtons(const void *p1, const void *p2) +{ + return SortButtons(*(CustomButtonData**)p1, *(CustomButtonData**)p2); +} + +static void CB_RegisterSeparators() +{ + BBButton bbd = { 0 }; + bbd.pszModuleName = "Tabsrmm_sep"; + for (DWORD i = 0; dwSepCount > i; i++) { + bbd.bbbFlags = BBBF_ISDUMMYBUTTON | BBBF_ISIMBUTTON; + bbd.dwButtonID = i + 1; + bbd.dwDefPos = 410 + i; + Srmm_AddButton(&bbd); + } +} + +static 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, "%s_%d", cbd->m_pszModuleName, cbd->m_dwButtonOrigID); + + 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, "_"); + token = strtok(NULL, "_"); + cbd->m_bRSided = atoi(token) != 0; + token = strtok(NULL, "_"); + cbd->m_bCanBeHidden = atoi(token) != 0; + + db_free(&dbv); + } +} + +MIR_APP_DLL(CustomButtonData*) Srmm_GetNthButton(int i) +{ + return arButtonsList[i]; +} + +MIR_APP_DLL(int) Srmm_GetButtonCount(void) +{ + return arButtonsList.getCount(); +} + +MIR_APP_DLL(int) Srmm_AddButton(const BBButton *bbdi, int _hLang) +{ + if (bbdi == NULL) + return 1; + + CustomButtonData *cbd = new CustomButtonData(); + if (!bbdi->iButtonWidth && (bbdi->bbbFlags & BBBF_ISARROWBUTTON)) + cbd->m_iButtonWidth = DPISCALEX_S(34); + else if (!bbdi->iButtonWidth) + cbd->m_iButtonWidth = DPISCALEX_S(22); + else + cbd->m_iButtonWidth = DPISCALEX_S(bbdi->iButtonWidth); + + cbd->m_pszModuleName = mir_strdup(bbdi->pszModuleName); + cbd->m_pwszTooltip = mir_wstrdup(bbdi->pwszTooltip); + + 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; + cbd->m_dwArrowCID = (bbdi->bbbFlags & BBBF_ISARROWBUTTON) ? cbd->m_dwButtonCID + 1 : 0; + cbd->m_bHidden = (bbdi->bbbFlags & BBBF_HIDDEN) != 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; + cbd->m_hLangpack = _hLang; + + // download database settings + CB_GetButtonSettings(NULL, cbd); + + arButtonsList.insert(cbd); + + if (cbd->m_dwButtonCID != cbd->m_dwButtonOrigID) + LastCID++; + if (cbd->m_dwArrowCID == LastCID) + LastCID++; + + WindowList_Broadcast(chatApi.hWindowList, WM_CBD_UPDATED, 0, 0); + return 0; +} + +MIR_APP_DLL(int) Srmm_GetButtonState(HWND hwndDlg, BBButton *bbdi) +{ + if (hwndDlg == NULL || bbdi == NULL) + return 1; + + DWORD tempCID = 0; + bool realbutton = false; + bbdi->bbbFlags = 0; + for (int i = 0; i < arButtonsList.getCount(); i++) { + CustomButtonData *cbd = arButtonsList[i]; + if (!mir_strcmp(cbd->m_pszModuleName, bbdi->pszModuleName) && (cbd->m_dwButtonOrigID == bbdi->dwButtonID)) { + realbutton = true; + tempCID = cbd->m_dwButtonCID; + } + } + if (!realbutton) + 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; +} + +MIR_APP_DLL(int) Srmm_SetButtonState(MCONTACT hContact, BBButton *bbdi) +{ + if (hContact == NULL || bbdi == NULL) + return 1; + + bool realbutton = false; + DWORD tempCID = 0; + for (int i = 0; i < arButtonsList.getCount(); i++) { + CustomButtonData *cbd = arButtonsList[i]; + if (!mir_strcmp(cbd->m_pszModuleName, bbdi->pszModuleName) && (cbd->m_dwButtonOrigID == bbdi->dwButtonID)) { + realbutton = true; + tempCID = cbd->m_dwButtonCID; + } + } + if (!realbutton) + return 1; + + HWND hwndDlg = WindowList_Find(NULL, hContact); + if (hwndDlg == NULL) + return 1; + + HWND hwndBtn = GetDlgItem(hwndDlg, tempCID); + if (hwndBtn == NULL) + return 1; + + SetWindowTextA(hwndBtn, bbdi->pszModuleName); + if (bbdi->hIcon) + SendMessage(hwndBtn, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIconByHandle(bbdi->hIcon)); + if (bbdi->pwszTooltip) + SendMessage(hwndBtn, BUTTONADDTOOLTIP, (WPARAM)bbdi->pwszTooltip, BATF_UNICODE); + if (bbdi->bbbFlags) { + ShowWindow(hwndBtn, (bbdi->bbbFlags & BBSF_HIDDEN) ? SW_HIDE : SW_SHOW); + EnableWindow(hwndBtn, !(bbdi->bbbFlags & BBSF_DISABLED)); + Button_SetCheck(hwndBtn, (bbdi->bbbFlags & BBSF_PUSHED) != 0); + Button_SetCheck(hwndBtn, (bbdi->bbbFlags & BBSF_RELEASED) != 0); + } + return 0; +} + +MIR_APP_DLL(int) Srmm_RemoveButton(BBButton *bbdi) +{ + if (!bbdi) + return 1; + + CustomButtonData *pFound = NULL; + { + mir_cslock lck(csToolBar); + + for (int i = arButtonsList.getCount() - 1; i >= 0; i--) { + CustomButtonData *cbd = arButtonsList[i]; + if (!mir_strcmp(cbd->m_pszModuleName, bbdi->pszModuleName) && cbd->m_dwButtonOrigID == bbdi->dwButtonID) { + pFound = cbd; + arButtonsList.remove(i); + } + } + } + + if (pFound) { + WindowList_Broadcast(chatApi.hWindowList, WM_CBD_REMOVED, pFound->m_dwButtonCID, (LPARAM)pFound); + delete pFound; + } + return 0; +} + +MIR_APP_DLL(int) Srmm_ModifyButton(BBButton *bbdi) +{ + if (!bbdi) + return 1; + + bool bFound = false; + CustomButtonData *cbd = NULL; + { + mir_cslock lck(csToolBar); + + for (int i = 0; i < arButtonsList.getCount(); i++) { + cbd = arButtonsList[i]; + if (!mir_strcmp(cbd->m_pszModuleName, bbdi->pszModuleName) && (cbd->m_dwButtonOrigID == bbdi->dwButtonID)) { + bFound = true; + break; + } + } + + if (bFound) { + if (bbdi->pwszTooltip) + cbd->m_pwszTooltip = mir_wstrdup(bbdi->pwszTooltip); + if (bbdi->hIcon) + cbd->m_hIcon = bbdi->hIcon; + if (bbdi->bbbFlags) { + cbd->m_bHidden = (bbdi->bbbFlags & BBBF_HIDDEN) != 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; + } + } + } + + if (bFound) + WindowList_Broadcast(chatApi.hWindowList, WM_CBD_UPDATED, 0, (LPARAM)cbd); + return 0; +} + +MIR_APP_DLL(void) Srmm_ResetToolbar() +{ + { mir_cslock lck(csToolBar); + wipeList(arButtonsList); + } + LastCID = 4000; + dwSepCount = 0; +} + +MIR_APP_DLL(void) Srmm_UpdateToolbarIcons(HWND hwndDlg) +{ + for (int i = 0; i < arButtonsList.getCount(); i++) { + CustomButtonData *cbd = arButtonsList[i]; + if (cbd) { + if (!cbd->m_bSeparator) { + HWND hwndBtn = GetDlgItem(hwndDlg, cbd->m_dwButtonCID); + if (hwndBtn && cbd->m_hIcon) + SendMessage(hwndBtn, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIconByHandle(cbd->m_hIcon)); + } + } + } +} + +MIR_APP_DLL(void) Srmm_RedrawToolbarIcons(HWND hwndDlg) +{ + for (int i = 0; i < arButtonsList.getCount(); i++) { + CustomButtonData *cbd = arButtonsList[i]; + HWND hwnd = GetDlgItem(hwndDlg, cbd->m_dwButtonCID); + if (hwnd) + InvalidateRect(hwnd, 0, TRUE); + } +} + +///////////////////////////////////////////////////////////////////////////////////////// + +static void CB_HardReInit() +{ + WindowList_Broadcast(chatApi.hWindowList, WM_CBD_REMOVED, 0, 0); + + Srmm_ResetToolbar(); + NotifyEventHooks(hHookToolBarLoadedEvt, 0, 0); +} + +static void CB_ReInitCustomButtons() +{ + for (int i = arButtonsList.getCount() - 1; i >= 0; i--) { + CustomButtonData *cbd = arButtonsList[i]; + + if (cbd->m_opFlags & (BBSF_NTBSWAPED | BBSF_NTBDESTRUCT)) { + cbd->m_opFlags ^= BBSF_NTBSWAPED; + + if (cbd->m_opFlags & BBSF_NTBDESTRUCT) + arButtonsList.remove(i); + } + } + qsort(arButtonsList.getArray(), arButtonsList.getCount(), sizeof(void*), sstSortButtons); + + WindowList_Broadcast(chatApi.hWindowList, WM_CBD_UPDATED, 0, 0); + WindowList_Broadcast(chatApi.hWindowList, WM_CBD_LOADICONS, 0, 0); +} + +static void CB_WriteButtonSettings(MCONTACT hContact, CustomButtonData *cbd) +{ + char SettingName[1024]; + char SettingParameter[1024]; + + //modulename_buttonID, position_inIM_inCHAT_isLSide_isRSide_CanBeHidden + + mir_snprintf(SettingName, "%s_%d", cbd->m_pszModuleName, cbd->m_dwButtonOrigID); + mir_snprintf(SettingParameter, "%d_%u_%u_%u_%u_%u", cbd->m_dwPosition, cbd->m_bIMButton, cbd->m_bChatButton, 0, 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); +} + +#define MIDDLE_SEPARATOR L">-------M-------<" + +class CSrmmToolbarOptions : public CDlgBase +{ + CCtrlTreeView m_toolBar; + CCtrlCheck m_btnIM, m_btnChat, m_btnHidden; + CCtrlButton m_btnReset, m_btnSeparator; + CCtrlSpin m_gap; + + HIMAGELIST m_hImgl; + + void SaveTree() + { + bool RSide = false; + int count = 10; + DWORD loc_sepcout = 0; + wchar_t strbuf[128]; + + TVITEMEX tvi; + tvi.mask = TVIF_TEXT | TVIF_PARAM | TVIF_HANDLE; + tvi.hItem = m_toolBar.GetRoot(); + tvi.pszText = strbuf; + tvi.cchTextMax = _countof(strbuf); + { + mir_cslock lck(csToolBar); + + while (tvi.hItem != NULL) { + m_toolBar.GetItem(&tvi); + + if (mir_wstrcmp(tvi.pszText, MIDDLE_SEPARATOR) == 0) { + RSide = true; + count = m_toolBar.GetCount() * 10 - count; + tvi.hItem = m_toolBar.GetNextSibling(tvi.hItem); + continue; + } + CustomButtonData *cbd = (CustomButtonData*)tvi.lParam; + if (cbd) { + 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->m_bRSided) { + cbd->m_bRSided = true; + cbd->m_opFlags |= BBSF_NTBSWAPED; + } + else if (!RSide && cbd->m_bRSided) { + cbd->m_bRSided = false; + cbd->m_opFlags |= BBSF_NTBSWAPED; + } + if (!m_toolBar.GetCheckState(tvi.hItem)) { + cbd->m_bIMButton = false; + cbd->m_bChatButton = false; + + if (cbd->m_bSeparator && !mir_strcmp(cbd->m_pszModuleName, "Tabsrmm_sep")) + cbd->m_opFlags = BBSF_NTBDESTRUCT; + } + else { + if (!cbd->m_bIMButton && !cbd->m_bChatButton) + cbd->m_bIMButton = true; + if (cbd->m_bSeparator && !mir_strcmp(cbd->m_pszModuleName, "Tabsrmm_sep")) { + cbd->m_bHidden = 0; + cbd->m_opFlags &= ~BBSF_NTBDESTRUCT; + ++loc_sepcout; + } + } + + cbd->m_dwPosition = (DWORD)count; + CB_WriteButtonSettings(NULL, cbd); + + if (!(cbd->m_opFlags & BBSF_NTBDESTRUCT)) + (RSide) ? (count -= 10) : (count += 10); + } + + HTREEITEM hItem = m_toolBar.GetNextSibling(tvi.hItem); + if (cbd->m_opFlags & BBSF_NTBDESTRUCT) + m_toolBar.DeleteItem(tvi.hItem); + tvi.hItem = hItem; + } + + qsort(arButtonsList.getArray(), arButtonsList.getCount(), sizeof(void*), sstSortButtons); + } + db_set_dw(0, "TabSRMM_Toolbar", "SeparatorsCount", loc_sepcout); + dwSepCount = loc_sepcout; + } + + void BuildMenuObjectsTree() + { + HTREEITEM hti; + int iImage = 0; + + TVINSERTSTRUCT tvis; + tvis.hParent = NULL; + tvis.hInsertAfter = TVI_LAST; + tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_SELECTEDIMAGE | TVIF_IMAGE; + + m_toolBar.DeleteAllItems(); + + m_hImgl = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 2, 2); + ImageList_AddIcon(m_hImgl, Skin_LoadIcon(SKINICON_OTHER_SMALLDOT)); + ImageList_Destroy(m_toolBar.GetImageList(TVSIL_NORMAL)); + m_toolBar.SetImageList(m_hImgl, TVSIL_NORMAL); + + if (arButtonsList.getCount() == 0) + return; + + bool bPrevSide = false; + mir_cslock lck(csToolBar); + + for (int i = 0; i < arButtonsList.getCount(); i++) { + CustomButtonData *cbd = arButtonsList[i]; + + if (bPrevSide != cbd->m_bRSided) { + bPrevSide = true; + + TVINSERTSTRUCT tvis2 = {}; + tvis.hInsertAfter = TVI_LAST; + tvis2.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_SELECTEDIMAGE | TVIF_IMAGE | TVIF_STATE; + tvis2.item.pszText = MIDDLE_SEPARATOR; + tvis2.item.stateMask = TVIS_BOLD; + tvis2.item.state = TVIS_BOLD; + tvis2.item.iImage = tvis.item.iSelectedImage = -1; + tvis.hInsertAfter = hti = m_toolBar.InsertItem(&tvis2); + m_toolBar.SetCheckState(hti, 1); + } + + tvis.item.lParam = (LPARAM)cbd; + + if (cbd->m_bSeparator) { + tvis.item.pszText = TranslateT("<Separator>"); + tvis.item.iImage = tvis.item.iSelectedImage = 0; + } + else { + tvis.item.pszText = TranslateW(cbd->m_pwszTooltip); + iImage = ImageList_AddIcon(m_hImgl, IcoLib_GetIconByHandle(cbd->m_hIcon)); + tvis.item.iImage = tvis.item.iSelectedImage = iImage; + } + cbd->m_opFlags = 0; + hti = m_toolBar.InsertItem(&tvis); + + m_toolBar.SetCheckState(hti, (cbd->m_bIMButton || cbd->m_bChatButton)); + } + } + +public: + CSrmmToolbarOptions() : + CDlgBase(g_hInst, IDD_OPT_TOOLBAR), + m_gap(this, IDC_SPIN1), + m_btnIM(this, IDC_IMCHECK), + m_btnChat(this, IDC_CHATCHECK), + m_toolBar(this, IDC_TOOLBARTREE), + m_btnReset(this, IDC_BBRESET), + m_btnHidden(this, IDC_CANBEHIDDEN), + m_btnSeparator(this, IDC_SEPARATOR), + m_hImgl(NULL) + { + m_toolBar.SetFlags(MTREE_DND); // enable drag-n-drop + + m_btnReset.OnClick = Callback(this, &CSrmmToolbarOptions::btnResetClicked); + m_btnSeparator.OnClick = Callback(this, &CSrmmToolbarOptions::btnSeparatorClicked); + } + + virtual void OnInitDialog() override + { + BuildMenuObjectsTree(); + + m_btnIM.Disable(); + m_btnChat.Disable(); + m_btnHidden.Disable(); + + m_gap.SetRange(10); + m_gap.SetPosition(db_get_b(NULL, MODULENAME, "ButtonsBarGap", 1)); + } + + virtual void OnDestroy() override + { + ImageList_Destroy(m_toolBar.GetImageList(TVSIL_NORMAL)); + ImageList_Destroy(m_toolBar.GetImageList(TVSIL_STATE)); + } + + virtual void OnApply() override + { + HTREEITEM hItem = m_toolBar.GetSelection(); + if (hItem) { + TVITEMEX tvi; + tvi.mask = TVIF_HANDLE | TVIF_PARAM; + tvi.hItem = hItem; + m_toolBar.GetItem(&tvi); + + if (tvi.lParam) { + CustomButtonData *cbd = (CustomButtonData*)tvi.lParam; + if (cbd) { + cbd->m_bIMButton = m_btnIM.Enabled() != 0; + cbd->m_bChatButton = m_btnChat.Enabled() != 0; + cbd->m_bCanBeHidden = m_btnHidden.Enabled() != 0; + } + } + } + + SaveTree(); + CB_ReInitCustomButtons(); + + BYTE newGap = (BYTE)SendDlgItemMessage(m_hwnd, IDC_SPIN1, UDM_GETPOS, 0, 0); + if (newGap != db_get_b(NULL, MODULENAME, "ButtonsBarGap", 1)) + WindowList_BroadcastAsync(chatApi.hWindowList, WM_SIZE, 0, 0); + + db_set_b(0, MODULENAME, "ButtonsBarGap", newGap); + + BuildMenuObjectsTree(); + + m_btnIM.Disable(); + m_btnChat.Disable(); + m_btnHidden.Disable(); + } + + virtual void OnReset() override + { + CB_ReInitCustomButtons(); + dwSepCount = db_get_dw(NULL, MODULENAME, "SeparatorsCount", 0); + } + + void btnResetClicked(void*) + { + db_delete_module(NULL, MODULENAME); + CB_HardReInit(); + BuildMenuObjectsTree(); + } + + void btnSeparatorClicked(void*) + { + HTREEITEM hItem = m_toolBar.GetSelection(); + if (!hItem) + hItem = TVI_FIRST; + + CustomButtonData *cbd = new CustomButtonData(); + cbd->m_bSeparator = cbd->m_bHidden = cbd->m_bIMButton = true; + cbd->m_dwButtonOrigID = ++dwSepCount; + cbd->m_pszModuleName = "Tabsrmm_sep"; + cbd->m_iButtonWidth = 22; + cbd->m_opFlags = BBSF_NTBDESTRUCT; + arButtonsList.insert(cbd); + + TVINSERTSTRUCT tvis; + tvis.hParent = NULL; + tvis.hInsertAfter = hItem; + 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; + hItem = m_toolBar.InsertItem(&tvis); + + m_toolBar.SetCheckState(hItem, (cbd->m_bIMButton || cbd->m_bChatButton)); + } + + void OnTreeSelChanging(void*) + { + HTREEITEM hItem = m_toolBar.GetSelection(); + if (hItem == NULL) + return; + + wchar_t strbuf[128]; + TVITEMEX tvi; + tvi.hItem = hItem; + tvi.pszText = strbuf; + tvi.cchTextMax = _countof(strbuf); + tvi.mask = TVIF_TEXT | TVIF_HANDLE | TVIF_PARAM; + m_toolBar.GetItem(&tvi); + + if (tvi.lParam == 0 || !m_toolBar.GetCheckState(tvi.hItem) || !mir_wstrcmp(tvi.pszText, MIDDLE_SEPARATOR)) + return; + + CustomButtonData *cbd = (CustomButtonData*)tvi.lParam; + cbd->m_bIMButton = m_btnIM.GetState() != 0; + cbd->m_bChatButton = m_btnChat.GetState() != 0; + cbd->m_bCanBeHidden = m_btnHidden.GetState() != 0; + cbd->m_opFlags = (cbd->m_bIMButton ? BBSF_IMBUTTON : 0) + (cbd->m_bChatButton ? BBSF_CHATBUTTON : 0) + (cbd->m_bCanBeHidden ? BBSF_CANBEHIDDEN : 0); + } + + void OnTreeSelChanged(void*) + { + HTREEITEM hItem = m_toolBar.GetSelection(); + if (hItem == NULL) + return; + + wchar_t strbuf[128]; + TVITEMEX tvi; + tvi.pszText = strbuf; + tvi.cchTextMax = _countof(strbuf); + tvi.mask = TVIF_TEXT | TVIF_HANDLE | TVIF_PARAM; + tvi.hItem = hItem; + m_toolBar.GetItem(&tvi); + + if (!m_toolBar.GetCheckState(tvi.hItem) || !mir_wstrcmp(tvi.pszText, MIDDLE_SEPARATOR)) { + m_btnIM.Disable(); + m_btnChat.Disable(); + m_btnHidden.Disable(); + return; + } + + if (tvi.lParam == 0) + return; + + CustomButtonData *cbd = (CustomButtonData*)tvi.lParam; + m_btnIM.Enable(); m_btnIM.SetState(cbd->m_bIMButton); + m_btnChat.Enable(); m_btnChat.SetState(cbd->m_bChatButton); + m_btnHidden.Enable(); m_btnHidden.SetState(cbd->m_bCanBeHidden); + } + + void OnTreeClicked(void*) + { + TVHITTESTINFO hti = { 0 }; + GetCursorPos(&hti.pt); + ScreenToClient(m_toolBar.GetHwnd(), &hti.pt); + if (m_toolBar.HitTest(&hti)) { + if (hti.flags & TVHT_ONITEMSTATEICON) { + NotifyChange(); + int iNewState = m_toolBar.GetCheckState(hti.hItem); + m_btnIM.Enable(iNewState); + m_btnChat.Enable(iNewState); + m_btnHidden.Enable(iNewState); + if (iNewState) + m_btnIM.SetState(true); + + m_toolBar.SelectItem(hti.hItem); + } + } + } +}; + +static int SrmmOptionsInit(WPARAM wParam, LPARAM) +{ + OPTIONSDIALOGPAGE odp = { 0 }; + odp.position = 910000000; + odp.hInstance = g_hInst; + odp.szGroup.a = LPGEN("Message sessions"); + odp.szTitle.a = LPGEN("Toolbar"); + odp.flags = ODPF_BOLDGROUPS; + odp.pDialog = new CSrmmToolbarOptions(); + Options_AddPage(wParam, &odp); + return 0; +} + +///////////////////////////////////////////////////////////////////////////////////////// + +void KillModuleToolbarIcons(int _hLang) +{ + for (int i = arButtonsList.getCount() - 1; i >= 0; i--) { + CustomButtonData *cbd = arButtonsList[i]; + if (cbd->m_hLangpack == _hLang) { + arButtonsList.remove(i); + delete cbd; + } + } +} + +static int SrmmModulesLoaded(WPARAM, LPARAM) +{ + NotifyEventHooks(hHookToolBarLoadedEvt, 0, 0); + return 0; +} + +void LoadSrmmToolbarModule() +{ + HookEvent(ME_OPT_INITIALISE, SrmmOptionsInit); + HookEvent(ME_SYSTEM_MODULESLOADED, SrmmModulesLoaded); + + hHookToolBarLoadedEvt = CreateHookableEvent(ME_MSG_TOOLBARLOADED); + + HDC hScrnDC = GetDC(0); + g_DPIscaleX = GetDeviceCaps(hScrnDC, LOGPIXELSX) / 96.0; + g_DPIscaleY = GetDeviceCaps(hScrnDC, LOGPIXELSY) / 96.0; + ReleaseDC(0, hScrnDC); + + dwSepCount = db_get_dw(NULL, "TabSRMM_Toolbar", "SeparatorsCount", 0); + CB_RegisterSeparators(); +} + +void UnloadSrmmToolbarModule() +{ + DestroyHookableEvent(hHookToolBarLoadedEvt); + wipeList(arButtonsList); +} |