summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-07-08 18:45:11 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-07-08 18:45:11 +0000
commit929cf4f6f089cc4db4eea16898402120fc812e30 (patch)
tree67218e5b14923f8021b4406249756bdf1cab232a
parent71defe6c2ba6284e775f2317311e29a77c02b81d (diff)
default buttons from Clist Nicer+ & Modern
git-svn-id: http://svn.miranda-ng.org/main/trunk@859 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--plugins/Clist_modern/modern_tbbutton.cpp2
-rw-r--r--plugins/Clist_modern/modern_toolbar.cpp114
-rw-r--r--plugins/Clist_nicer/INCLUDE/clc.h1
-rw-r--r--plugins/Clist_nicer/INCLUDE/commonheaders.h3
-rw-r--r--plugins/Clist_nicer/SRC/CLCButton.cpp96
-rw-r--r--plugins/Clist_nicer/SRC/clc.cpp4
-rw-r--r--plugins/Clist_nicer/SRC/clui.cpp118
-rw-r--r--plugins/Clist_nicer/SRC/extBackg.cpp14
-rw-r--r--plugins/Clist_nicer/SRC/init.cpp6
-rw-r--r--plugins/ExternalAPI/m_toptoolbar.h30
-rw-r--r--plugins/TopToolBar/InternalButtons.cpp177
-rw-r--r--plugins/TopToolBar/TopToolBar.vcxproj1
-rw-r--r--plugins/TopToolBar/TopToolBar.vcxproj.filters3
-rw-r--r--plugins/TopToolBar/common.h8
-rw-r--r--plugins/TopToolBar/main.cpp30
-rw-r--r--plugins/TopToolBar/toolbar.cpp30
16 files changed, 342 insertions, 295 deletions
diff --git a/plugins/Clist_modern/modern_tbbutton.cpp b/plugins/Clist_modern/modern_tbbutton.cpp
index c273719cc8..fc17b0921f 100644
--- a/plugins/Clist_modern/modern_tbbutton.cpp
+++ b/plugins/Clist_modern/modern_tbbutton.cpp
@@ -15,6 +15,7 @@
#define b2str(a) ((a) ? "True" : "False")
void CustomizeToolbar(HWND);
+int Modern_InitButtons(WPARAM, LPARAM);
struct TBBUTTONDATA : public MButtonCtrl
{
@@ -530,6 +531,7 @@ static void CustomizeButton(HANDLE ttbid, HWND hWnd, LPARAM lParam)
int Buttons_ModuleLoaded(WPARAM wParam, LPARAM lParam)
{
+ HookEvent(ME_TTB_INITBUTTONS, Modern_InitButtons);
TopToolbar_SetCustomProc(CustomizeButton, 0);
return 0;
}
diff --git a/plugins/Clist_modern/modern_toolbar.cpp b/plugins/Clist_modern/modern_toolbar.cpp
index 05ddd64100..75a1e2e915 100644
--- a/plugins/Clist_modern/modern_toolbar.cpp
+++ b/plugins/Clist_modern/modern_toolbar.cpp
@@ -29,6 +29,59 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <m_toptoolbar.h>
#include "hdr/modern_sync.h"
+struct
+{
+ char *pszButtonID, *pszButtonName, *pszServiceName;
+ char *pszTooltipUp, *pszTooltipDn;
+ int icoDefIdx, defResource, defResource2;
+ BOOL bVisByDefault;
+}
+static BTNS[] =
+{
+ { "MainMenu", "Main Menu", "CList/ShowMainMenu", "Main menu", NULL, 100 , IDI_RESETVIEW, IDI_RESETVIEW, TRUE },
+ { "StatusMenu", "Status Menu", "CList/ShowStatusMenu", "Status menu", NULL, 105 , IDI_RESETVIEW, IDI_RESETVIEW, TRUE },
+ { "AccoMgr", "Accounts", MS_PROTO_SHOWACCMGR, "Accounts...", NULL, 282 , IDI_ACCMGR, IDI_ACCMGR, TRUE },
+ { "ShowHideOffline","Show/Hide offline contacts", MS_CLIST_TOGGLEHIDEOFFLINE, "Hide offline contacts", "Show offline contacts", 110, IDI_RESETVIEW, IDI_RESETVIEW, TRUE },
+ { "DatabaseEditor","DBEditor++", "DBEditorpp/MenuCommand", "Database Editor", NULL, 130 , IDI_RESETVIEW, IDI_RESETVIEW, TRUE },
+ { "FindUser","Find User", "FindAdd/FindAddCommand", "Find User", NULL, 140 , IDI_RESETVIEW, IDI_RESETVIEW, TRUE },
+ { "Options","Options", "Options/OptionsCommand", "Options", NULL, 150 , IDI_RESETVIEW, IDI_RESETVIEW, TRUE },
+ { "UseGroups","Use/Disable groups", MS_CLIST_TOGGLEGROUPS, "Use groups", "Disable Groups", 160, IDI_RESETVIEW, IDI_RESETVIEW, FALSE },
+ { "EnableSounds","Enable/Disable sounds", MS_CLIST_TOGGLESOUNDS, "Enable sounds", "Disable Sounds", 170, IDI_RESETVIEW, IDI_RESETVIEW, FALSE },
+ { "Minimize","Minimize", "CList/ShowHide", "Minimize", NULL, 180 , IDI_RESETVIEW, IDI_RESETVIEW, FALSE }
+};
+
+int Modern_InitButtons(WPARAM, LPARAM)
+{
+ TTBButton tbb = { 0 };
+ tbb.cbSize = sizeof(tbb);
+
+ for (int i=0; i < SIZEOF(BTNS); i++ ) {
+ tbb.dwFlags = TTBBF_ICONBYHANDLE;
+ if (BTNS[i].pszButtonID) {
+ tbb.name = BTNS[i].pszButtonID;
+ tbb.pszService = BTNS[i].pszServiceName;
+ tbb.pszTooltipUp = BTNS[i].pszTooltipUp;
+ tbb.pszTooltipDn = BTNS[i].pszTooltipDn;
+
+ char buf[255];
+ mir_snprintf(buf,SIZEOF(buf),"%s%s%s", TTB_OPTDIR, BTNS[i].pszButtonID, "_dn");
+ tbb.hIconHandleUp = RegisterIcolibIconHandle( buf, "ToolBar", BTNS[i].pszButtonName , _T("icons\\toolbar_icons.dll"),-BTNS[i].icoDefIdx, g_hInst, BTNS[i].defResource );
+
+ if (BTNS[i].pszTooltipDn) {
+ mir_snprintf(buf,SIZEOF(buf),"%s%s%s", TTB_OPTDIR, BTNS[i].pszButtonID, "_up");
+ tbb.hIconHandleUp = RegisterIcolibIconHandle( buf, "ToolBar", BTNS[i].pszTooltipDn , _T("icons\\toolbar_icons.dll"),-(BTNS[i].icoDefIdx+1), g_hInst, BTNS[i].defResource2 );
+ }
+ }
+ else tbb.dwFlags |= TTBBF_ISSEPARATOR;
+
+ tbb.dwFlags |= (BTNS[i].bVisByDefault ? TTBBF_VISIBLE :0 );
+ TopToolbar_AddButton(&tbb);
+ }
+ return 1;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
#define TTB_OPTDIR "TopToolBar"
#if defined(WIN64)
@@ -44,66 +97,6 @@ static void CopySettings(const char* to, const char* from)
db_set_b(NULL, TTB_OPTDIR, to, db_get_b(NULL,"ModernToolBar",from, 0));
}
-static void sttRegisterToolBarButton(char * pszButtonID, char * pszButtonName, char * pszServiceName,
- char * pszTooltipUp, char * pszTooltipDn, int icoDefIdx, int defResource, int defResource2, BOOL bVisByDefault)
-{
- TTBButton tbb = { 0 };
- static int defPos = 0;
- defPos += 100;
- tbb.cbSize = sizeof(tbb);
- tbb.dwFlags = TTBBF_ICONBYHANDLE;
- if (pszButtonID) {
- tbb.name = pszButtonID;
- tbb.pszService = pszServiceName;
-
- char buf[255];
- mir_snprintf(buf,SIZEOF(buf),"%s%s%s", "TTB_", pszButtonID, "_dn");
- tbb.hIconHandleUp = RegisterIcolibIconHandle( buf, "ToolBar", pszButtonName , _T("icons\\toolbar_icons.dll"),-icoDefIdx, g_hInst, defResource );
-
- if (pszTooltipDn) {
- mir_snprintf(buf,SIZEOF(buf),"%s%s%s", "TTB_", pszButtonID, "_up");
- tbb.hIconHandleUp = RegisterIcolibIconHandle( buf, "ToolBar", pszTooltipDn , _T("icons\\toolbar_icons.dll"),-(icoDefIdx+1), g_hInst, defResource2 );
- }
- }
- else tbb.dwFlags |= TTBBF_ISSEPARATOR;
-
- tbb.dwFlags |= (bVisByDefault ? TTBBF_VISIBLE :0 );
- CallService(MS_TTB_ADDBUTTON,0, (LPARAM)&tbb);
-}
-
-static void ToolBar_DefaultButtonRegistration()
-{
- sttRegisterToolBarButton( "MainMenu", "Main Menu", "CList/ShowMainMenu",
- "Main menu", NULL, 100 , IDI_RESETVIEW, IDI_RESETVIEW, TRUE );
-
- sttRegisterToolBarButton( "StatusMenu", "Status Menu", "CList/ShowStatusMenu",
- "Status menu", NULL, 105 , IDI_RESETVIEW, IDI_RESETVIEW, TRUE );
-
- sttRegisterToolBarButton( "AccoMgr", "Accounts", MS_PROTO_SHOWACCMGR,
- "Accounts...", NULL, 282 , IDI_ACCMGR, IDI_ACCMGR, TRUE );
-
- sttRegisterToolBarButton( "ShowHideOffline","Show/Hide offline contacts", MS_CLIST_TOGGLEHIDEOFFLINE,
- "Hide offline contacts", "Show offline contacts", 110, IDI_RESETVIEW, IDI_RESETVIEW, TRUE );
-
- sttRegisterToolBarButton( "DatabaseEditor","DBEditor++", "DBEditorpp/MenuCommand",
- "Database Editor", NULL, 130 , IDI_RESETVIEW, IDI_RESETVIEW, TRUE );
-
- sttRegisterToolBarButton( "FindUser","Find User", "FindAdd/FindAddCommand",
- "Find User", NULL, 140 , IDI_RESETVIEW, IDI_RESETVIEW, TRUE );
-
- sttRegisterToolBarButton( "Options","Options", "Options/OptionsCommand",
- "Options", NULL, 150 , IDI_RESETVIEW, IDI_RESETVIEW, TRUE );
-
- sttRegisterToolBarButton( "UseGroups","Use/Disable groups", MS_CLIST_TOGGLEGROUPS,
- "Use groups", "Disable Groups", 160, IDI_RESETVIEW, IDI_RESETVIEW, FALSE );
-
- sttRegisterToolBarButton( "EnableSounds","Enable/Disable sounds", MS_CLIST_TOGGLESOUNDS,
- "Enable sounds", "Disable Sounds", 170, IDI_RESETVIEW, IDI_RESETVIEW, FALSE );
-
- sttRegisterToolBarButton( "Minimize","Minimize", "CList/ShowHide",
- "Minimize", NULL, 180 , IDI_RESETVIEW, IDI_RESETVIEW, FALSE );
-}
-
HRESULT ToolbarLoadModule()
{
if ( db_get_b(NULL, "CLUI", "ShowButtonBar", -1) != -1) {
@@ -121,6 +114,5 @@ HRESULT ToolbarLoadModule()
CallService(MS_UTILS_OPENURL, 0, (LPARAM)szUrl);
}
- ToolBar_DefaultButtonRegistration();
return S_OK;
}
diff --git a/plugins/Clist_nicer/INCLUDE/clc.h b/plugins/Clist_nicer/INCLUDE/clc.h
index 27cb5d9a62..7a78e52564 100644
--- a/plugins/Clist_nicer/INCLUDE/clc.h
+++ b/plugins/Clist_nicer/INCLUDE/clc.h
@@ -340,6 +340,7 @@ struct TCluiData {
DWORD dwFlags;
DWORD topOffset, bottomOffset;
int statusBarHeight;
+ int soundsOff;
BYTE tabSRMM_Avail;
BYTE bMetaAvail;
BYTE bAvatarServiceAvail;
diff --git a/plugins/Clist_nicer/INCLUDE/commonheaders.h b/plugins/Clist_nicer/INCLUDE/commonheaders.h
index 2b52d2734d..6a2e363544 100644
--- a/plugins/Clist_nicer/INCLUDE/commonheaders.h
+++ b/plugins/Clist_nicer/INCLUDE/commonheaders.h
@@ -192,6 +192,9 @@
// shared vars
extern HINSTANCE g_hInst;
+extern LONG g_cxsmIcon, g_cysmIcon;
+extern StatusItems_t *StatusItems;
+extern ImageItem *g_glyphItem;
/* most free()'s are invalid when the code is executed from a dll, so this changes
all the bad free()'s to good ones, however it's still incorrect code. The reasons for not
diff --git a/plugins/Clist_nicer/SRC/CLCButton.cpp b/plugins/Clist_nicer/SRC/CLCButton.cpp
index 134ca1ae71..3ab8587d0f 100644
--- a/plugins/Clist_nicer/SRC/CLCButton.cpp
+++ b/plugins/Clist_nicer/SRC/CLCButton.cpp
@@ -16,15 +16,60 @@ 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 <commonheaders.h>
+#include "commonheaders.h"
#include <m_button_int.h>
#include <m_toptoolbar.h>
-extern HINSTANCE g_hInst;
-extern LONG g_cxsmIcon, g_cysmIcon;
-extern StatusItems_t *StatusItems;
-extern ImageItem *g_glyphItem;
+struct
+{
+ int ctrlid;
+ char *pszButtonID, *pszButtonDn, *pszButtonName;
+ int isPush, isVis, isAction;
+ HANDLE hButton;
+}
+static BTNS[] =
+{
+ { IDC_TBTOPMENU, "CLN_topmenu", NULL, LPGEN("Show menu"), 1, 1, 1 },
+ { IDC_TBHIDEOFFLINE, "CLN_online", NULL, LPGEN("Show / hide offline contacts"), 0, 1, 0 },
+ { IDC_TBHIDEGROUPS, "CLN_groups", NULL, LPGEN("Toggle group mode"), 0, 1, 0 },
+ { IDC_TBFINDANDADD, "CLN_findadd", NULL, LPGEN("Find and add contacts"), 1, 1, 0 },
+ { IDC_TBACCOUNTS, "CLN_accounts", NULL, LPGEN("Accounts"), 1, 1, 0 },
+ { IDC_TBOPTIONS, "CLN_options", NULL, LPGEN("Open preferences"), 1, 1, 0 },
+ { IDC_TBSOUND, "CLN_sound", "CLN_soundsoff", LPGEN("Toggle sounds"), 0, 1, 0 },
+ { IDC_TBMINIMIZE, "CLN_minimize", NULL, LPGEN("Minimize contact list"), 1, 0, 0 },
+ { IDC_TBTOPSTATUS, "CLN_topstatus", NULL, LPGEN("Status menu"), 1, 0, 1 },
+ { IDC_TABSRMMSLIST, "CLN_slist", NULL, LPGEN("tabSRMM session list"), 1, 0, 1 },
+ { IDC_TABSRMMMENU, "CLN_menu", NULL, LPGEN("tabSRMM Menu"), 1, 0, 1 },
+
+ { IDC_TBSELECTVIEWMODE, "CLN_CLVM_select", NULL, LPGEN("Select view mode"), 1, 0, 1 },
+ { IDC_TBCONFIGUREVIEWMODE,"CLN_CLVM_options", NULL, LPGEN("Setup view modes"), 1, 0, 0 },
+ { IDC_TBCLEARVIEWMODE, "CLN_CLVM_reset", NULL, LPGEN("Clear view mode"), 1, 0, 0 }
+};
+
+static int InitDefaultButtons(WPARAM, LPARAM)
+{
+ TTBButton tbb = { 0 };
+ tbb.cbSize = sizeof(tbb);
+
+ for (int i=0; i < SIZEOF(BTNS); i++ ) {
+ tbb.dwFlags = TTBBF_ICONBYHANDLE;
+ if (BTNS[i].pszButtonID) {
+ tbb.pszTooltipUp = tbb.pszTooltipDn = tbb.name = BTNS[i].pszButtonName;
+ tbb.pszService = BTNS[i].pszButtonID;
+ tbb.hIconHandleUp = Skin_GetIconHandle(BTNS[i].pszButtonID);
+ if (BTNS[i].pszButtonDn)
+ tbb.hIconHandleUp = Skin_GetIconHandle(BTNS[i].pszButtonDn);
+ }
+ else tbb.dwFlags |= TTBBF_ISSEPARATOR;
+
+ tbb.dwFlags |= (BTNS[i].isVis ? TTBBF_VISIBLE :0 );
+ BTNS[i].hButton = TopToolbar_AddButton(&tbb);
+ }
+ return 1;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
struct MButtonExtension : public MButtonCtrl
{
@@ -32,7 +77,7 @@ struct MButtonExtension : public MButtonCtrl
TCHAR szText[128];
SIZE sLabel;
HIMAGELIST hIml;
- int iIcon;
+ int iIcon, iCtrlID;
BOOL bSendOnDown;
ButtonItem *buttonItem;
LONG lastGlyphMetrics[4];
@@ -292,7 +337,7 @@ static LRESULT CALLBACK TSButtonWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, L
case WM_SYSKEYUP:
if (bct->stateId != PBS_DISABLED && bct->cHot && bct->cHot == tolower((int) wParam)) {
if (!bct->bSendOnDown)
- SendMessage(GetParent(hwndDlg), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndDlg), BN_CLICKED), (LPARAM) hwndDlg);
+ SendMessage(pcli->hwndContactList, WM_COMMAND, MAKELONG(bct->iCtrlID, BN_CLICKED), (LPARAM) hwndDlg);
return 0;
}
break;
@@ -372,20 +417,21 @@ static LRESULT CALLBACK TSButtonWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, L
case WM_LBUTTONDOWN:
if (bct->stateId != PBS_DISABLED && bct->stateId != PBS_PRESSED) {
if (bct->bSendOnDown) {
- SendMessage(GetParent(hwndDlg), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndDlg), BN_CLICKED), (LPARAM) hwndDlg);
+ SendMessage(pcli->hwndContactList, WM_COMMAND, MAKELONG(bct->iCtrlID, BN_CLICKED), (LPARAM) hwndDlg);
bct->stateId = PBS_NORMAL;
InvalidateRect(bct->hwnd, NULL, TRUE);
+ return 1;
}
}
break;
case WM_LBUTTONUP:
if (!bct->bSendOnDown)
- SendMessage(GetParent(hwndDlg), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndDlg), BN_CLICKED), (LPARAM) hwndDlg);
+ SendMessage(pcli->hwndContactList, WM_COMMAND, MAKELONG(bct->iCtrlID, BN_CLICKED), (LPARAM) hwndDlg);
break;
case WM_NCHITTEST:
- switch( SendMessage(GetParent(hwndDlg), WM_NCHITTEST, wParam, lParam)) {
+ switch( SendMessage(pcli->hwndContactList, WM_NCHITTEST, wParam, lParam)) {
case HTLEFT: case HTRIGHT: case HTBOTTOM: case HTTOP:
case HTTOPLEFT: case HTTOPRIGHT: case HTBOTTOMLEFT: case HTBOTTOMRIGHT:
return HTTRANSPARENT;
@@ -394,7 +440,7 @@ static LRESULT CALLBACK TSButtonWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, L
return 0;
}
-static void CustomizeToolbar(HANDLE, HWND hWnd, LPARAM)
+static void SetButtonAsCustom(HWND hWnd)
{
MButtonCustomize Custom;
Custom.cbLen = sizeof(MButtonExtension);
@@ -403,10 +449,30 @@ static void CustomizeToolbar(HANDLE, HWND hWnd, LPARAM)
SendMessage(hWnd, BUTTONSETCUSTOM, 0, (LPARAM)&Custom);
}
-void CustomizeButton(HWND hWnd, bool bIsSkinned, bool bIsThemed, bool bIsFlat)
+static void CustomizeToolbar(HANDLE hButton, HWND hWnd, LPARAM)
{
- CustomizeToolbar(0, hWnd, 0);
+ // we don't customize the toolbar window, only buttons
+ if (hButton == TTB_WINDOW_HANDLE)
+ return;
+
+ SetButtonAsCustom(hWnd);
+ for (int i=0; i < SIZEOF(BTNS); i++) {
+ if (BTNS[i].hButton != hButton)
+ continue;
+
+ MButtonExtension *bct = (MButtonExtension*) GetWindowLongPtr(hWnd, 0);
+ bct->iCtrlID = BTNS[i].ctrlid;
+ if (BTNS[i].isAction)
+ bct->bSendOnDown = TRUE;
+ if (!BTNS[i].isPush)
+ bct->bIsPushBtn = TRUE;
+ break;
+ }
+}
+void CustomizeButton(HWND hWnd, bool bIsSkinned, bool bIsThemed, bool bIsFlat)
+{
+ SetButtonAsCustom(hWnd);
SendMessage(hWnd, BUTTONSETSKINNED, bIsSkinned, 0);
SendMessage(hWnd, BUTTONSETASTHEMEDBTN, bIsThemed, 0);
SendMessage(hWnd, BUTTONSETASFLATBTN, bIsFlat, 0);
@@ -414,12 +480,12 @@ void CustomizeButton(HWND hWnd, bool bIsSkinned, bool bIsThemed, bool bIsFlat)
static int Nicer_CustomizeToolbar(WPARAM, LPARAM)
{
+ HookEvent(ME_TTB_INITBUTTONS, InitDefaultButtons);
TopToolbar_SetCustomProc(CustomizeToolbar, 0);
return 0;
}
-int LoadButtonModule()
+void LoadButtonModule()
{
HookEvent(ME_SYSTEM_MODULESLOADED, Nicer_CustomizeToolbar);
- return 0;
}
diff --git a/plugins/Clist_nicer/SRC/clc.cpp b/plugins/Clist_nicer/SRC/clc.cpp
index 9a7d81a66b..7d6ce337f3 100644
--- a/plugins/Clist_nicer/SRC/clc.cpp
+++ b/plugins/Clist_nicer/SRC/clc.cpp
@@ -168,6 +168,10 @@ static int ClcSettingChanged(WPARAM wParam, LPARAM lParam)
if ((lstrlenA(cws->szSetting) > 6 && !strncmp(cws->szSetting, "Status", 6)) || strstr("Default,ForceSend,Nick", cws->szSetting))
pcli->pfnClcBroadcast(INTM_NAMEORDERCHANGED, wParam, lParam);
}
+ if (!__strcmp(cws->szSetting, "UseSound")) {
+ cfg::dat.soundsOff = cfg::getByte(cws->szModule, cws->szSetting, 0) ? 0 : 1;
+ CheckDlgButton(pcli->hwndContactList, IDC_TBSOUND, cfg::dat.soundsOff ? BST_UNCHECKED : BST_CHECKED);
+ }
}
if (cfg::dat.bMetaAvail && cfg::dat.bMetaEnabled && !__strcmp(cws->szModule, cfg::dat.szMetaName) && !__strcmp(cws->szSetting, "IsSubcontact"))
pcli->pfnClcBroadcast(INTM_HIDDENCHANGED, wParam, lParam);
diff --git a/plugins/Clist_nicer/SRC/clui.cpp b/plugins/Clist_nicer/SRC/clui.cpp
index 366e503c76..a000114e6c 100644
--- a/plugins/Clist_nicer/SRC/clui.cpp
+++ b/plugins/Clist_nicer/SRC/clui.cpp
@@ -106,32 +106,21 @@ static HBITMAP hbmLockedPoint = 0, hbmOldLockedPoint = 0;
HICON overlayicons[10];
-struct {
- HICON hIcon, hAltIcon;
- UINT idIcon, idAltIcon;
- char *szIcoLibIcon, *szIcoLibAltIcon;
- DWORD visibilityOrder;
- TCHAR *szTooltip;
-}
-static top_buttons[] =
-{
- { 0, 0, IDI_TBTOPMENU, 0, "CLN_topmenu", NULL, 1, LPGENT("Show menu") },
- { 0, 0, IDI_HIDEOFFLINE, 0, "CLN_online", NULL, 2, LPGENT("Show / hide offline contacts") },
- { 0, 0, IDI_HIDEGROUPS, 0, "CLN_groups", NULL, 4, LPGENT("Toggle group mode") },
- { 0, 0, IDI_FINDANDADD, 0, "CLN_findadd", NULL, 8, LPGENT("Find and add contacts") },
- { 0, 0, IDI_TBACCOUNTS, 0, "CLN_accounts", NULL, 8192, LPGENT("Accounts") },
- { 0, 0, IDI_TBOPTIONS, 0, "CLN_options", NULL, 16, LPGENT("Open preferences") },
- { 0, 0, IDI_SOUNDSON, IDI_SOUNDSOFF, "CLN_sound", "CLN_soundsoff", 32, LPGENT("Toggle sounds") },
- { 0, 0, IDI_MINIMIZE, 0, "CLN_minimize", NULL, 64, LPGENT("Minimize contact list") },
- { 0, 0, 0, 0, "CLN_topstatus", NULL, 128, LPGENT("Status menu") },
- { 0, 0, IDI_TABSRMMSESSIONLIST, 0, "CLN_slist", NULL, 256, LPGENT("tabSRMM session list") },
- { 0, 0, IDI_TABSRMMMENU, 0, "CLN_menu", NULL, 512, LPGENT("tabSRMM Menu") },
-
- { 0, 0, IDI_CLVM_SELECT, 0, "CLN_CLVM_select", NULL, 1024, LPGENT("Select view mode") },
- { 0, 0, IDI_CLVM_OPTIONS, 0, "CLN_CLVM_options", NULL, 2048, LPGENT("Setup view modes") },
- { 0, 0, IDI_DELETE, 0, "CLN_CLVM_reset", NULL, 4096, LPGENT("Clear view mode") },
-
- { 0, 0, IDI_MINIMIZE, 0, "", NULL, 0, LPGENT("Open main menu") }
+static struct IconDesc myIcons[] = {
+ { "CLN_online", LPGEN("Toggle show online/offline"), -IDI_HIDEOFFLINE },
+ { "CLN_groups", LPGEN("Toggle groups"), -IDI_HIDEGROUPS },
+ { "CLN_findadd", LPGEN("Find contacts"), -IDI_FINDANDADD },
+ { "CLN_options", LPGEN("Open preferences"), -IDI_TBOPTIONS },
+ { "CLN_sound", LPGEN("Toggle sounds"), -IDI_SOUNDSON },
+ { "CLN_minimize", LPGEN("Minimize contact list"), -IDI_MINIMIZE },
+ { "CLN_slist", LPGEN("Show tabSRMM session list"), -IDI_TABSRMMSESSIONLIST },
+ { "CLN_menu", LPGEN("Show tabSRMM menu"), -IDI_TABSRMMMENU },
+ { "CLN_soundsoff", LPGEN("Sounds are off"), -IDI_SOUNDSOFF },
+ { "CLN_CLVM_select", LPGEN("Select view mode"), -IDI_CLVM_SELECT },
+ { "CLN_CLVM_reset", LPGEN("Reset view mode"), -IDI_DELETE },
+ { "CLN_CLVM_options", LPGEN("Configure view modes"), -IDI_CLVM_OPTIONS },
+ { "CLN_topmenu", LPGEN("Show menu"), -IDI_TBTOPMENU },
+ { "CLN_accounts", LPGEN("Setup accounts"), -IDI_TBACCOUNTS }
};
HWND hTbMenu, hTbGlobalStatus;
@@ -335,32 +324,25 @@ static void CacheClientIcons()
static void InitIcoLib()
{
- SKINICONDESC sid = {0};
TCHAR szFilename[MAX_PATH];
- int i = 0, version = 0;
+ GetModuleFileName(g_hInst, szFilename, MAX_PATH);
+
+ SKINICONDESC sid = {0};
+ int i, version = 0;
char szBuffer[128];
int p_count = 0;
PROTOACCOUNT **accs = NULL;
- GetModuleFileName(g_hInst, szFilename, MAX_PATH);
-
sid.cbSize = sizeof(SKINICONDESC);
sid.flags = SIDF_PATH_TCHAR;
sid.pszSection = LPGEN("CList - Nicer/Default");
sid.ptszDefaultFile = szFilename;
-
- sid.pszName = "CLN_CLVM_select";
- sid.pszDescription = LPGEN("Select view mode");
- sid.iDefaultIndex = -IDI_CLVM_SELECT;
- Skin_AddIcon(&sid);
- sid.pszName = "CLN_CLVM_reset";
- sid.pszDescription = LPGEN("Reset view mode");
- sid.iDefaultIndex = -IDI_DELETE;
- Skin_AddIcon(&sid);
- sid.pszName = "CLN_CLVM_options";
- sid.pszDescription = LPGEN("Configure view modes");
- sid.iDefaultIndex = -IDI_CLVM_OPTIONS;
- Skin_AddIcon(&sid);
+ for (i=0; i < SIZEOF(myIcons); i++) {
+ sid.pszName = myIcons[i].szName;
+ sid.pszDescription = myIcons[i].szDesc;
+ sid.iDefaultIndex = myIcons[i].uId;
+ Skin_AddIcon(&sid);
+ }
sid.pszName = "CLN_visible";
sid.pszDescription = LPGEN("Contact on visible list");
@@ -588,7 +570,6 @@ void SetDBButtonStates(HANDLE hPassedContact)
}
}
-
void BlitWallpaper(HDC hdc, RECT *rc, RECT *rcPaint, struct ClcData *dat)
{
int x, y;
@@ -888,6 +869,18 @@ static void ShowCLUI(HWND hwnd)
SFL_SetState(cfg::dat.bUseFloater & CLUI_FLOATER_AUTOHIDE ? (old_cliststate == SETTING_STATE_NORMAL ? 0 : 1) : 1);
}
+static void GetButtonRect(HWND hwnd, RECT *rc)
+{
+ if (hwnd)
+ GetWindowRect(hwnd, rc);
+ else {
+ POINT pt;
+ GetCursorPos(&pt);
+ rc->bottom = rc->top = pt.y;
+ rc->left = rc->right = pt.x;
+ }
+}
+
#define M_CREATECLC (WM_USER+1)
LRESULT CALLBACK ContactListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
@@ -1572,22 +1565,35 @@ skipbg:
goto buttons_done;
}
switch (LOWORD(wParam)) {
- case IDC_TBMENU: {
+ case IDC_TBMENU:
+ case IDC_TBTOPMENU: {
RECT rc;
HMENU hMenu = (HMENU) CallService(MS_CLIST_MENUGETMAIN, 0, 0);
-
- GetWindowRect(GetDlgItem(hwnd, LOWORD(wParam)), &rc);
+ GetButtonRect(GetDlgItem(hwnd, LOWORD(wParam)), &rc);
TrackPopupMenu(hMenu, TPM_TOPALIGN | TPM_LEFTALIGN | TPM_RIGHTBUTTON, rc.left, LOWORD(wParam) == IDC_TBMENU ? rc.top : rc.bottom, 0, hwnd, NULL);
return 0;
}
+ case IDC_TBTOPSTATUS:
case IDC_TBGLOBALSTATUS: {
RECT rc;
HMENU hmenu = (HMENU)CallService(MS_CLIST_MENUGETSTATUS, 0, 0);
- GetWindowRect(GetDlgItem(hwnd, LOWORD(wParam)), &rc);
+ GetButtonRect(GetDlgItem(hwnd, LOWORD(wParam)), &rc);
TrackPopupMenu(hmenu, TPM_TOPALIGN | TPM_LEFTALIGN | TPM_RIGHTBUTTON, rc.left, rc.top, 0, hwnd, NULL);
return 0;
}
+ case IDC_TABSRMMSLIST:
+ case IDC_TABSRMMMENU:
+ if (ServiceExists("SRMsg_MOD/GetWindowFlags"))
+ CallService("SRMsg_MOD/Show_TrayMenu", 0, LOWORD(wParam) == IDC_TABSRMMSLIST ? 0 : 1);
+ return 0;
+
+ case IDC_TBSOUND:
+ cfg::dat.soundsOff = !cfg::dat.soundsOff;
+ cfg::writeByte("CLUI", "NoSounds", (BYTE)cfg::dat.soundsOff);
+ cfg::writeByte("Skin", "UseSound", (BYTE)(cfg::dat.soundsOff ? 0 : 1));
+ return 0;
+
case IDC_TBSELECTVIEWMODE:
SendMessage(g_hwndViewModeFrame, WM_COMMAND, IDC_SELECTMODE, lParam);
break;
@@ -1597,8 +1603,18 @@ skipbg:
case IDC_TBCONFIGUREVIEWMODE:
SendMessage(g_hwndViewModeFrame, WM_COMMAND, IDC_CONFIGUREMODES, lParam);
break;
+ case IDC_TBFINDANDADD:
+ CallService(MS_FINDADD_FINDADD, 0, 0);
+ return 0;
+ case IDC_TBACCOUNTS:
+ CallService(MS_PROTO_SHOWACCMGR, 0, 0);
+ break;
+ case IDC_TBOPTIONS:
+ CallService("Options/OptionsCommand", 0, 0);
+ return 0;
}
- } else if (CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), MPCF_MAINMENU), (LPARAM)(HANDLE) NULL))
+ }
+ else if (CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), MPCF_MAINMENU), (LPARAM)(HANDLE) NULL))
return 0;
buttons_done:
@@ -1610,6 +1626,7 @@ buttons_done:
DestroyWindow(hwnd);
break;
case ID_TRAY_HIDE:
+ case IDC_TBMINIMIZE:
pcli->pfnShowHide(0, 0);
break;
case POPUP_NEWGROUP:
@@ -1618,6 +1635,7 @@ buttons_done:
CallService(MS_CLIST_GROUPCREATE, 0, 0);
break;
case POPUP_HIDEOFFLINE:
+ case IDC_TBHIDEOFFLINE:
CallService(MS_CLIST_SETHIDEOFFLINE, (WPARAM)(-1), 0);
break;
case POPUP_HIDEOFFLINEROOT:
@@ -1629,10 +1647,12 @@ buttons_done:
SendMessage(pcli->hwndContactTree, CLM_SETHIDEEMPTYGROUPS, newVal, 0);
break;
}
+ case IDC_TBHIDEGROUPS:
case POPUP_DISABLEGROUPS: {
int newVal = !(GetWindowLongPtr(pcli->hwndContactTree, GWL_STYLE) & CLS_USEGROUPS);
cfg::writeByte("CList", "UseGroups", (BYTE) newVal);
SendMessage(pcli->hwndContactTree, CLM_SETUSEGROUPS, newVal, 0);
+ CheckDlgButton(hwnd, IDC_TBHIDEGROUPS, newVal ? BST_CHECKED : BST_UNCHECKED);
break;
}
case POPUP_HIDEMIRANDA:
diff --git a/plugins/Clist_nicer/SRC/extBackg.cpp b/plugins/Clist_nicer/SRC/extBackg.cpp
index 089c41e6e7..9cc8f0fd44 100644
--- a/plugins/Clist_nicer/SRC/extBackg.cpp
+++ b/plugins/Clist_nicer/SRC/extBackg.cpp
@@ -1172,19 +1172,7 @@ static void BTN_ReadItem(char *itemName, char *file)
tmpItem.uId = nextButtonID++;
}
}
- else if(_stricmp(szBuffer, "Custom")) {
- int i = 0;
- /*
- while(top_buttons[i].id) {
- if (!_stricmp(top_buttons[i].szIcoLibIcon, szBuffer)) {
- tmpItem.uId = top_buttons[i].id;
- tmpItem.dwFlags |= BUTTON_ISINTERNAL;
- break;
- }
- i++;
- }
- */
- }
+
GetPrivateProfileStringA(itemName, "PassContact", "None", szBuffer, 1000, file);
if(_stricmp(szBuffer, "None")) {
if(szBuffer[0] == 'w' || szBuffer[0] == 'W')
diff --git a/plugins/Clist_nicer/SRC/init.cpp b/plugins/Clist_nicer/SRC/init.cpp
index 16a33bfc66..3b2f372f95 100644
--- a/plugins/Clist_nicer/SRC/init.cpp
+++ b/plugins/Clist_nicer/SRC/init.cpp
@@ -55,7 +55,8 @@ struct ClcContact* CreateClcContact( void );
struct CListEvent* fnCreateEvent( void );
void ReloadThemedOptions();
void TrayIconUpdateBase(const char *szChangedProto);
-void RegisterCLUIFrameClasses();
+void RegisterCLUIFrameClasses();
+void LoadButtonModule();
void GetDefaultFontSetting(int i, LOGFONT *lf, COLORREF *colour);
int GetWindowVisibleState(HWND hWnd, int iStepX, int iStepY);
@@ -305,6 +306,7 @@ extern "C" int __declspec(dllexport) CListInitialise()
cfg::dat.dwFlags = cfg::getDword("CLUI", "Frameflags", CLUI_FRAME_STATUSICONS | CLUI_FRAME_SHOWBOTTOMBUTTONS |
CLUI_FRAME_BUTTONSFLAT | CLUI_FRAME_CLISTSUNKEN);
cfg::dat.dwFlags |= (cfg::getByte("CLUI", "ShowSBar", 1) ? CLUI_FRAME_SBARSHOW : 0);
+ cfg::dat.soundsOff = cfg::getByte("CLUI", "NoSounds", 0);
CallService(MS_DB_GETPROFILEPATH, MAX_PATH, (LPARAM)szProfilePath);
@@ -365,6 +367,7 @@ LBL_Error:
rc = LoadContactListModule();
if (rc == 0)
rc = LoadCLCModule();
+ LoadButtonModule();
HookEvent(ME_SYSTEM_MODULESLOADED, systemModulesLoaded);
return rc;
}
@@ -384,4 +387,3 @@ extern "C" int __declspec(dllexport) Unload(void)
UnLoadCLUIFramesModule();
return 0;
}
-
diff --git a/plugins/ExternalAPI/m_toptoolbar.h b/plugins/ExternalAPI/m_toptoolbar.h
index 6b5f6abd15..5ef3a20352 100644
--- a/plugins/ExternalAPI/m_toptoolbar.h
+++ b/plugins/ExternalAPI/m_toptoolbar.h
@@ -1,6 +1,8 @@
#ifndef M_TOPTOOLBAR_H
#define M_TOPTOOLBAR_H
+#define TTB_OPTDIR "TopToolBar"
+
//button flags
#define TTBBF_DISABLED 0x0001
#define TTBBF_VISIBLE 0x0002
@@ -32,14 +34,9 @@ typedef struct {
HICON hIconDn;
HANDLE hIconHandleDn;
};
- union {
- char *pszTooltipDn;
- TCHAR *ptszTooltipDn;
- };
- union {
- char *pszTooltipUp;
- TCHAR *ptszTooltipUp;
- };
+
+ char *pszTooltipUp;
+ char *pszTooltipDn;
}
TTBButton, * lpTTBButton;
@@ -52,18 +49,29 @@ Called when the toolbar services are available
!!!Warning you may work with TTB services only in this event or later.
*/
-#define ME_TTB_MODULELOADED "TopToolBar/ModuleLoaded"
+#define ME_TTB_MODULELOADED "TopToolBar/ModuleLoaded"
+/*
+toptoolbar/initbuttons event
+wParam = lParam = 0
+Called when the toolbar needs to add default buttons
+*/
+#define ME_TTB_INITBUTTONS "TopToolBar/InitButtons"
//=== SERVICES ===
/*
toptoolbar/addbutton service
wparam = (TTBButton*)lpTTBButton
-lparam = 0
+lparam = hLangpack
returns: hTTBButton - handle of added button on success, -1 on failure.
*/
-#define MS_TTB_ADDBUTTON "TopToolBar/AddButton"
+
+extern int hLangpack;
+
+__forceinline HANDLE TopToolbar_AddButton(TTBButton *pButton)
+{ return (HANDLE)CallService("TopToolBar/AddButton", (WPARAM)pButton, hLangpack);
+}
/*
toptoolbar/removebutton service
diff --git a/plugins/TopToolBar/InternalButtons.cpp b/plugins/TopToolBar/InternalButtons.cpp
index 4551d55c7d..ccd4c888c2 100644
--- a/plugins/TopToolBar/InternalButtons.cpp
+++ b/plugins/TopToolBar/InternalButtons.cpp
@@ -5,51 +5,48 @@
#define TTBI_SOUNDSONOFF "TTBInternal/SoundsOnOFF"
#define TTBI_MAINMENUBUTT "TTBInternal/MainMenuBUTT"
-int LoadInternalButtons( HWND );
-int UnLoadInternalButtons();
-
extern HINSTANCE hInst;
-static HANDLE hOnlineBut, hGroupBut, hSoundsBut, hOptionsBut, hMainMenuBut;
-static HANDLE hMinimizeBut;
-static HANDLE hFindUsers;
-
static HWND hwndContactTree;
+struct
+{
+ char *name, *pszService;
+ int iconidUp, iconidDn;
+ char *tooltipUp, *tooltipDn;
+ HANDLE hButton;
+}
+static stdButtons[] =
+{
+ { "Show only Online Users", MS_CLIST_SETHIDEOFFLINE, IDI_SHOWONLINEUP, IDI_SHOWONLINEDN, "Hide Offline Users", "Show All Users" },
+ { "Groups On/Off", TTBI_GROUPSHOWHIDE, IDI_GROUPSUP, IDI_GROUPSDN, "Hide Groups", "Show Groups" },
+ { "Sounds Enable/Disable", TTBI_SOUNDSONOFF, IDI_SOUNDUP, IDI_SOUNDDN, "Disable Sounds", "Enable Sounds" },
+
+ { "Show Options Page", "Options/OptionsCommand", IDI_OPTIONSUP, 0, "Show Options" },
+ { "Minimize Button", MS_CLIST_SHOWHIDE, IDI_MINIMIZEUP, 0, NULL },
+ { "Find/Add Contacts", MS_FINDADD_FINDADD, IDI_FINDADDUP, 0, NULL },
+ { "Show Main Menu", TTBI_MAINMENUBUTT, IDI_MIRANDAUP, 0, "Show Main Menu" }
+};
+
+///////////////////////////////////////////////////////////////////////////////
+
int OnSettingChanging(WPARAM wParam, LPARAM lParam)
{
- if (wParam != 0)
- return 0;
-
DBCONTACTWRITESETTING *dbcws = (DBCONTACTWRITESETTING *)lParam;
- if (dbcws == NULL)
+ if (wParam != 0 || dbcws == NULL)
return 0;
if ( !strcmp(dbcws->szModule, "CList")) {
- if ( !strcmp(dbcws->szSetting, "HideOffline")) {
- int val = dbcws->value.bVal;
-
- CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)hOnlineBut, (LPARAM)(val)?TTBST_PUSHED:TTBST_RELEASED);
-
- CallService(MS_TTB_SETBUTTONOPTIONS, MAKEWPARAM(TTBO_TIPNAME, hOnlineBut),
- (LPARAM)((!val)?Translate("Hide Offline Users"):Translate("Show All Users")));
+ if ( !strcmp(dbcws->szSetting, "HideOffline"))
+ CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)stdButtons[0].hButton, (dbcws->value.bVal) ? TTBST_PUSHED : TTBST_RELEASED);
- return 0;
- }
-
- if (!strcmp(dbcws->szSetting, "UseGroups")) {
- int val = dbcws->value.bVal;
- CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)hGroupBut, (LPARAM)((val)?TTBST_PUSHED:TTBST_RELEASED));
- return 0;
- }
+ else if (!strcmp(dbcws->szSetting, "UseGroups"))
+ CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)stdButtons[1].hButton, (dbcws->value.bVal) ? TTBST_PUSHED : TTBST_RELEASED);
}
- if (!strcmp(dbcws->szModule, "Skin")) {
- if (!strcmp(dbcws->szSetting, "UseSound")) {
- int val = dbcws->value.bVal;
- CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)hSoundsBut, (LPARAM)(val)?TTBST_RELEASED:TTBST_PUSHED);
- return 0;
- }
+ else if (!strcmp(dbcws->szModule, "Skin")) {
+ if (!strcmp(dbcws->szSetting, "UseSound"))
+ CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)stdButtons[2].hButton, (dbcws->value.bVal) ? TTBST_RELEASED : TTBST_PUSHED);
}
return 0;
@@ -62,7 +59,6 @@ INT_PTR TTBInternalMainMenuButt(WPARAM wParam, LPARAM lParam)
POINT pt;
GetCursorPos(&pt);
TrackPopupMenu(hMenu, TPM_TOPALIGN|TPM_LEFTALIGN|TPM_RIGHTBUTTON, pt.x, pt.y, 0, (HWND)CallService(MS_CLUI_GETHWND, 0, 0), NULL);
-
return 0;
}
@@ -78,98 +74,47 @@ INT_PTR TTBInternalSoundsOnOff(WPARAM wParam, LPARAM lParam)
{
int newVal = !(DBGetContactSettingByte(NULL, "Skin", "UseSound", 1));
DBWriteContactSettingByte(NULL, "Skin", "UseSound", (BYTE)newVal);
- CallService(MS_TTB_SETBUTTONOPTIONS, MAKEWPARAM(TTBO_TIPNAME, hSoundsBut),
- (LPARAM)((newVal)?Translate("Disable Sounds"):Translate("Enable Sounds")));
return 0;
}
-int UnLoadInternalButtons()
-{
- return 0;
-}
+///////////////////////////////////////////////////////////////////////////////
-int LoadInternalButtons(HWND hwnd)
+int InitInternalButtons(WPARAM, LPARAM)
{
- hwndContactTree = hwnd;
- CreateServiceFunction(TTBI_GROUPSHOWHIDE, TTBInternalGroupShowHide);
- CreateServiceFunction(TTBI_SOUNDSONOFF, TTBInternalSoundsOnOff);
-
- CreateServiceFunction(TTBI_MAINMENUBUTT, TTBInternalMainMenuButt);
+ hwndContactTree = (HWND)CallService(MS_CLUI_GETHWNDTREE, 0, 0);
- int ShowOnline = DBGetContactSettingByte(NULL, "CList", "HideOffline", 0);
- int ShowGroups = DBGetContactSettingByte(NULL, "CList", "UseGroups", 2);
- int SoundsEnabled = DBGetContactSettingByte(NULL, "Skin", "UseSound", 1);
+ CreateServiceFunction(TTBI_GROUPSHOWHIDE, TTBInternalGroupShowHide);
+ CreateServiceFunction(TTBI_SOUNDSONOFF, TTBInternalSoundsOnOff);
+ CreateServiceFunction(TTBI_MAINMENUBUTT, TTBInternalMainMenuButt);
TTBButton ttb = { 0 };
ttb.cbSize = sizeof(ttb);
- ttb.hIconUp = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_SHOWONLINEUP), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
- ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_SHOWONLINEDN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
- ttb.dwFlags = (ShowOnline?TTBBF_PUSHED:0)|TTBBF_VISIBLE|TTBBF_SHOWTOOLTIP|TTBBF_ASPUSHBUTTON|TTBBF_INTERNAL;
- ttb.pszService = MS_CLIST_SETHIDEOFFLINE;
- ttb.wParamUp = ttb.wParamDown = -1;
- ttb.name = "Show only Online Users";
- hOnlineBut = (HANDLE)TTBAddButton((WPARAM)&ttb, 0);
-
- ttb.wParamUp = ttb.wParamDown = 0;
-
- ttb.hIconUp = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_GROUPSUP), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
- ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_GROUPSDN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
- ttb.dwFlags = (ShowGroups?TTBBF_PUSHED:0)|TTBBF_VISIBLE|TTBBF_SHOWTOOLTIP|TTBBF_ASPUSHBUTTON|TTBBF_INTERNAL;
- ttb.pszService = TTBI_GROUPSHOWHIDE;
- ttb.name = "Groups On/Off";
- hGroupBut = (HANDLE)TTBAddButton((WPARAM)&ttb, 0);
-
- ttb.hIconUp = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_SOUNDUP), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
- ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_SOUNDDN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
- ttb.dwFlags = (SoundsEnabled?0:TTBBF_PUSHED)|TTBBF_VISIBLE|TTBBF_SHOWTOOLTIP|TTBBF_ASPUSHBUTTON|TTBBF_INTERNAL;
- ttb.pszService = TTBI_SOUNDSONOFF;
- ttb.name = "Sounds Enable/Disable";
- hSoundsBut = (HANDLE)TTBAddButton((WPARAM)&ttb, 0);
-
- ttb.hIconUp = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_OPTIONSUP), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
- ttb.hIconDn = 0;
- ttb.dwFlags = TTBBF_VISIBLE|TTBBF_SHOWTOOLTIP|TTBBF_INTERNAL;
- ttb.pszService = "Options/OptionsCommand";
- ttb.name = "Show Options Page";
- hOptionsBut = (HANDLE)TTBAddButton((WPARAM)&ttb, 0);
-
- ttb.hIconUp = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_MINIMIZEUP), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
- ttb.hIconDn = 0;
- ttb.dwFlags = TTBBF_VISIBLE|TTBBF_INTERNAL;
- ttb.pszService = MS_CLIST_SHOWHIDE;
- ttb.name = "Minimize Button";
- hMinimizeBut = (HANDLE)TTBAddButton((WPARAM)&ttb, 0);
-
- ttb.hIconUp = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_FINDADDUP), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
- ttb.hIconDn = 0;
- ttb.dwFlags = TTBBF_VISIBLE|TTBBF_INTERNAL;
- ttb.pszService = MS_FINDADD_FINDADD;
- ttb.name = "Find/Add Contacts";
- hFindUsers = (HANDLE)TTBAddButton((WPARAM)&ttb, 0);
-
- ttb.hIconUp = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_MIRANDAUP), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
- ttb.hIconDn = 0;
- ttb.dwFlags = TTBBF_VISIBLE|TTBBF_SHOWTOOLTIP|TTBBF_INTERNAL;
- ttb.pszService = TTBI_MAINMENUBUTT;
- ttb.name = "Show Main Menu";
- hMainMenuBut = (HANDLE)TTBAddButton((WPARAM)&ttb, 0);
-
- CallService(MS_TTB_SETBUTTONOPTIONS, MAKEWPARAM(TTBO_TIPNAME, hOnlineBut),
- (LPARAM)((ShowOnline) ? "Hide Offline Users" : "Show All Users" ));
-
- CallService(MS_TTB_SETBUTTONOPTIONS, MAKEWPARAM(TTBO_TIPNAME, hGroupBut),
- (LPARAM)((ShowGroups) ? "Hide Groups" : "Show Groups" ));
-
- CallService(MS_TTB_SETBUTTONOPTIONS, MAKEWPARAM(TTBO_TIPNAME, hSoundsBut),
- (LPARAM)((SoundsEnabled) ? "Disable Sounds" : "Enable Sounds" ));
-
- CallService(MS_TTB_SETBUTTONOPTIONS, MAKEWPARAM(TTBO_TIPNAME, hOptionsBut),
- (LPARAM)"Show Options");
-
- CallService(MS_TTB_SETBUTTONOPTIONS, MAKEWPARAM(TTBO_TIPNAME, hMainMenuBut),
- (LPARAM)"Show Main Menu");
-
- HookEvent(ME_DB_CONTACT_SETTINGCHANGED,OnSettingChanging);
+ for (int i=0; i < SIZEOF(stdButtons); i++) {
+ ttb.name = stdButtons[i].name;
+ ttb.dwFlags = TTBBF_VISIBLE | TTBBF_INTERNAL;
+ if ((ttb.pszTooltipDn = stdButtons[i].tooltipDn) != NULL)
+ ttb.dwFlags |= TTBBF_SHOWTOOLTIP;
+ ttb.pszTooltipUp = stdButtons[i].tooltipUp;
+ ttb.hIconUp = (HICON)LoadImage(hInst, MAKEINTRESOURCE(stdButtons[i].iconidUp), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
+ if (stdButtons[i].iconidDn) {
+ ttb.dwFlags |= TTBBF_ASPUSHBUTTON;
+ ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(stdButtons[i].iconidDn), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
+ }
+ else ttb.hIconDn = NULL;
+
+ stdButtons[i].hButton = (HANDLE)TTBAddButton((WPARAM)&ttb, 0);
+ }
+
+ CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)stdButtons[0].hButton,
+ db_get_b(NULL, "CList", "HideOffline", 0) ? TTBST_PUSHED : TTBST_RELEASED);
+
+ CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)stdButtons[1].hButton,
+ db_get_b(NULL, "CList", "UseGroups", 1) ? TTBST_PUSHED : TTBST_RELEASED);
+
+ CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)stdButtons[2].hButton,
+ db_get_b(NULL, "Skin", "UseSound", 1) ? TTBST_RELEASED : TTBST_PUSHED);
+
+ HookEvent(ME_DB_CONTACT_SETTINGCHANGED, OnSettingChanging);
return 0;
}
diff --git a/plugins/TopToolBar/TopToolBar.vcxproj b/plugins/TopToolBar/TopToolBar.vcxproj
index 74af8839cf..978fc4bfcc 100644
--- a/plugins/TopToolBar/TopToolBar.vcxproj
+++ b/plugins/TopToolBar/TopToolBar.vcxproj
@@ -237,6 +237,7 @@
</Bscmake>
</ItemDefinitionGroup>
<ItemGroup>
+ <ClInclude Include="..\ExternalAPI\m_toptoolbar.h" />
<ClInclude Include="BkgrCfg.h" />
<ClInclude Include="common.h" />
<ClInclude Include="resource.h" />
diff --git a/plugins/TopToolBar/TopToolBar.vcxproj.filters b/plugins/TopToolBar/TopToolBar.vcxproj.filters
index e6f6451e3c..fca64531d0 100644
--- a/plugins/TopToolBar/TopToolBar.vcxproj.filters
+++ b/plugins/TopToolBar/TopToolBar.vcxproj.filters
@@ -24,6 +24,9 @@
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="..\ExternalAPI\m_toptoolbar.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="icos\Find_Add Contacts_UP.ico">
diff --git a/plugins/TopToolBar/common.h b/plugins/TopToolBar/common.h
index 3ce3807d57..1e14548c0e 100644
--- a/plugins/TopToolBar/common.h
+++ b/plugins/TopToolBar/common.h
@@ -34,7 +34,6 @@
#include "m_icolib.h"
#include "BkgrCfg.h"
-#define TTB_OPTDIR "TopToolBar"
#define TTBDEFAULT_BKBMPUSE CLB_STRETCH
#define TTBDEFAULT_BKCOLOUR GetSysColor(COLOR_3DFACE)
#define TTBDEFAULT_USEBITMAP 0
@@ -79,6 +78,9 @@ struct TopButtonInt
WPARAM wParamUp;
LPARAM lParamDown;
WPARAM wParamDown;
+
+ int hLangpack;
+ char *szTooltipUp, *szTooltipDn;
};
///////////////////////////////////////////////////////////////////////////////
@@ -102,7 +104,6 @@ int ArrangeButtons();
extern LIST<TopButtonInt> Buttons;
extern bool StopArrange;
extern HWND hwndTopToolBar;
-extern HANDLE hHookTTBModuleLoaded;
extern HINSTANCE hInst;
extern HBITMAP hBmpBackground, hBmpSeparator;
extern int BUTTWIDTH, BUTTHEIGHT, BUTTGAP;
@@ -126,8 +127,7 @@ char *AS(char *str, const char *setting, char *addstr)
INT_PTR TTBAddButton(WPARAM, LPARAM);
INT_PTR TTBRemoveButton(WPARAM, LPARAM);
-int LoadInternalButtons( HWND );
-int UnLoadInternalButtons( void );
+int InitInternalButtons(WPARAM, LPARAM);
int LoadToolbarModule( void );
int UnloadToolbarModule( void );
diff --git a/plugins/TopToolBar/main.cpp b/plugins/TopToolBar/main.cpp
index 7eb6c653f2..601de36408 100644
--- a/plugins/TopToolBar/main.cpp
+++ b/plugins/TopToolBar/main.cpp
@@ -3,20 +3,8 @@
#include "version.h"
HINSTANCE hInst;
-
-HANDLE hHookTTBModuleLoaded;
int hLangpack;
-#define MIID_TTB {0xf593c752, 0x51d8, 0x4d46, {0xba, 0x27, 0x37, 0x57, 0x79, 0x53, 0xf5, 0x5c}}
-
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
-{
- hInst = hinstDLL;
- return TRUE;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
PLUGININFOEX pluginInfo =
{
sizeof(PLUGININFOEX),
@@ -27,8 +15,8 @@ PLUGININFOEX pluginInfo =
__PLUGIN_EMAIL,
__PLUGIN_RIGHTS,
__PLUGIN_AUTHORWEB,
- UNICODE_AWARE, //doesn't replace anything built-in
- MIID_TTB
+ UNICODE_AWARE,
+ {0xf593c752, 0x51d8, 0x4d46, {0xba, 0x27, 0x37, 0x57, 0x79, 0x53, 0xf5, 0x5c}}
};
extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion)
@@ -40,12 +28,9 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD miranda
extern "C" int __declspec(dllexport) Load(void)
{
-
mir_getLP(&pluginInfo);
LoadToolbarModule();
-
- hHookTTBModuleLoaded = CreateHookableEvent(ME_TTB_MODULELOADED);
return 0;
}
@@ -53,9 +38,14 @@ extern "C" int __declspec(dllexport) Load(void)
extern "C" int __declspec(dllexport) Unload(void)
{
- UnLoadInternalButtons();
UnloadToolbarModule();
-
- DestroyHookableEvent(hHookTTBModuleLoaded);
return 0;
}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
+ hInst = hinstDLL;
+ return TRUE;
+}
diff --git a/plugins/TopToolBar/toolbar.cpp b/plugins/TopToolBar/toolbar.cpp
index 44d2e537b5..6d41d19aff 100644
--- a/plugins/TopToolBar/toolbar.cpp
+++ b/plugins/TopToolBar/toolbar.cpp
@@ -1,6 +1,8 @@
#include "common.h"
+#define OLD_TBBUTTON_SIZE (offsetof(TTBButton, pszTooltipUp))
+
pfnCustomProc g_CustomProc = NULL;
LPARAM g_CustomProcParam = 0;
@@ -14,6 +16,8 @@ int BUTTGAP;
int nextButtonId = 200;
+static HANDLE hTTBModuleLoaded, hTTBInitButtons;
+
//------------ options -------------
COLORREF bkColour;
HBITMAP hBmpBackground, hBmpSeparator;
@@ -281,6 +285,11 @@ TopButtonInt* CreateButton(TTBButton* but)
sprintf(buf, "%s_dn", b->name);
b->hIconDn = LoadIconFromLibrary(buf, b->hIconDn, b->hIconHandleDn);
}
+
+ if (but->cbSize > OLD_TBBUTTON_SIZE) {
+ b->szTooltipUp = but->pszTooltipUp;
+ b->szTooltipDn = but->pszTooltipDn;
+ }
}
return b;
}
@@ -301,7 +310,10 @@ INT_PTR TTBAddButton(WPARAM wParam, LPARAM lParam)
mir_cslock lck(csButtonsHook);
TTBButton *but = (TTBButton*)wParam;
- if (but->cbSize != sizeof(TTBButton) || (!(but->dwFlags && TTBBF_ISLBUTTON) && nameexists(but->name)))
+ if (but->cbSize != sizeof(TTBButton) && but->cbSize != OLD_TBBUTTON_SIZE)
+ return -1;
+
+ if ( !(but->dwFlags && TTBBF_ISLBUTTON) && nameexists(but->name))
return -1;
b = CreateButton(but);
@@ -754,11 +766,15 @@ static INT_PTR OnEventFire(WPARAM wParam, LPARAM lParam)
{
CallService(MS_SYSTEM_REMOVEWAIT, wParam, 0);
StopArrange = FALSE;
- NotifyEventHooks(hHookTTBModuleLoaded, 0, 0);
+ NotifyEventHooks(hTTBInitButtons, 0, 0);
+ NotifyEventHooks(hTTBModuleLoaded, 0, 0);
if (g_CustomProc) {
mir_cslock lck(csButtonsHook);
+ if (hwndTopToolBar)
+ g_CustomProc(TTB_WINDOW_HANDLE, hwndTopToolBar, g_CustomProcParam);
+
for (int i=0; i < Buttons.getCount(); i++) {
TopButtonInt* p = Buttons[i];
g_CustomProc((HANDLE)p->id, p->hwnd, g_CustomProcParam);
@@ -800,7 +816,6 @@ int OnModulesLoad(WPARAM wParam, LPARAM lParam)
hwndContactList = (HWND)CallService(MS_CLUI_GETHWND, 0, 0);
hFrameTopWindow = addTopToolBarWindow(hwndContactList);
- LoadInternalButtons(( HWND )CallService(MS_CLUI_GETHWNDTREE, 0, 0));
LoadAllSeparators();
LoadAllLButs();
@@ -834,7 +849,11 @@ int LoadToolbarModule()
HookEvent(ME_SKIN2_ICONSCHANGED, OnIconChange);
HookEvent(ME_OPT_INITIALISE, TTBOptInit);
- CreateServiceFunction(MS_TTB_ADDBUTTON, TTBAddButton);
+ hTTBModuleLoaded = CreateHookableEvent(ME_TTB_MODULELOADED);
+ hTTBInitButtons = CreateHookableEvent(ME_TTB_INITBUTTONS);
+ SetHookDefaultForHookableEvent(hTTBInitButtons, InitInternalButtons);
+
+ CreateServiceFunction("TopToolBar/AddButton", TTBAddButton);
CreateServiceFunction(MS_TTB_REMOVEBUTTON, TTBRemoveButton);
CreateServiceFunction(MS_TTB_SETBUTTONSTATE, TTBSetState);
@@ -858,6 +877,9 @@ int LoadToolbarModule()
int UnloadToolbarModule()
{
+ DestroyHookableEvent(hTTBModuleLoaded);
+ DestroyHookableEvent(hTTBInitButtons);
+
DeleteObject(hBmpSeparator);
DeleteCriticalSection(&csButtonsHook);