From 03758f8f918f392386a1dd7a1c7a795927f8c221 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 10 Mar 2013 11:51:00 +0000 Subject: - ME_TTB_INITBUTTONS event considered useless; - clist_modern & clist_nicer are trained to reload TTB buttons when TopToolBar plugin is loaded dynamically; - TTB processing code slightly reordered git-svn-id: http://svn.miranda-ng.org/main/trunk@3953 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- .../Clist_modern/src/hdr/modern_commonheaders.h | 10 ++++---- .../Clist_modern/src/hdr/modern_commonprototypes.h | 1 - plugins/Clist_modern/src/modern_tbbutton.cpp | 14 +++------- plugins/Clist_modern/src/modern_toolbar.cpp | 30 ++++++++++++++++------ plugins/Clist_modern/src/modern_viewmodebar.cpp | 3 --- plugins/Clist_nicer/src/CLCButton.cpp | 15 ++++++++--- plugins/ExternalAPI/m_toptoolbar.h | 7 ----- plugins/TopToolBar/src/InternalButtons.cpp | 3 +-- plugins/TopToolBar/src/common.h | 14 +++++----- plugins/TopToolBar/src/toolbar.cpp | 5 +--- plugins/TopToolBar/src/toolbarwnd.cpp | 5 ++-- plugins/TopToolBar/src/version.h | 2 +- 12 files changed, 56 insertions(+), 53 deletions(-) (limited to 'plugins') diff --git a/plugins/Clist_modern/src/hdr/modern_commonheaders.h b/plugins/Clist_modern/src/hdr/modern_commonheaders.h index a3338e4641..b8088cc8ff 100644 --- a/plugins/Clist_modern/src/hdr/modern_commonheaders.h +++ b/plugins/Clist_modern/src/hdr/modern_commonheaders.h @@ -174,13 +174,13 @@ DWORD exceptFunction(LPEXCEPTION_POINTERS EP); // lParam = 0 #define ME_BACKGROUNDCONFIG_CHANGED "ModernBkgrCfg/Changed" - - HBITMAP ske_CreateDIB32(int cx, int cy); -extern void InitDisplayNameCache(void); -extern void FreeDisplayNameCache(); -extern int CLUI_ShowWindowMod(HWND hwnd, int cmd); +void InitDisplayNameCache(void); +void FreeDisplayNameCache(); +int CLUI_ShowWindowMod(HWND hwnd, int cmd); + +void MakeButtonSkinned(HWND hWnd); #ifdef UNICODE #define GSMDF_TCHAR_MY GSMDF_TCHAR|CNF_UNICODE diff --git a/plugins/Clist_modern/src/hdr/modern_commonprototypes.h b/plugins/Clist_modern/src/hdr/modern_commonprototypes.h index 847aefa464..efbb035932 100644 --- a/plugins/Clist_modern/src/hdr/modern_commonprototypes.h +++ b/plugins/Clist_modern/src/hdr/modern_commonprototypes.h @@ -272,7 +272,6 @@ HRESULT PreLoadContactListModule(); HRESULT ClcLoadModule(); HRESULT ToolbarLoadModule(); HRESULT ToolbarButtonLoadModule(); -void CustomizeButton(HWND); // INTERFACES diff --git a/plugins/Clist_modern/src/modern_tbbutton.cpp b/plugins/Clist_modern/src/modern_tbbutton.cpp index 9a797411ec..d8f697ee3a 100644 --- a/plugins/Clist_modern/src/modern_tbbutton.cpp +++ b/plugins/Clist_modern/src/modern_tbbutton.cpp @@ -463,7 +463,9 @@ void MakeButtonSkinned(HWND hWnd) WindowList_Add(hButtonWindowList, hWnd, NULL); } -static void CustomizeButton(HANDLE ttbid, HWND hWnd, LPARAM lParam) +///////////////////////////////////////////////////////////////////////////////////////// + +void CustomizeButton(HANDLE ttbid, HWND hWnd, LPARAM lParam) { if (ttbid == TTB_WINDOW_HANDLE) { CustomizeToolbar(hWnd); @@ -473,19 +475,13 @@ static void CustomizeButton(HANDLE ttbid, HWND hWnd, LPARAM lParam) MakeButtonSkinned(hWnd); TBBUTTONDATA* p = (TBBUTTONDATA*)GetWindowLongPtr(hWnd, 0); - p->szButtonID, "Toolbar.MissingID"; + p->szButtonID = "Toolbar.MissingID"; p->ttbID = ttbid; SendMessage(hWnd, MBM_UPDATETRANSPARENTFLAG, 0, 2); } ///////////////////////////////////////////////////////////////////////////////////////// -int Buttons_ModuleLoaded(WPARAM wParam, LPARAM lParam) -{ - TopToolbar_SetCustomProc(CustomizeButton, 0); - return 0; -} - int Buttons_OnSkinModeSettingsChanged(WPARAM wParam, LPARAM lParam) { WindowList_BroadcastAsync(hButtonWindowList, MBM_UPDATETRANSPARENTFLAG, 0, 2); @@ -494,8 +490,6 @@ int Buttons_OnSkinModeSettingsChanged(WPARAM wParam, LPARAM lParam) HRESULT ToolbarButtonLoadModule() { - HookEvent(ME_SYSTEM_MODULESLOADED, Buttons_ModuleLoaded); - hButtonWindowList = (HANDLE) CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0); hIconChangedHook = HookEvent(ME_SKIN2_ICONSCHANGED,OnIconLibIconChanged); hBkgChangedHook = HookEvent(ME_BACKGROUNDCONFIG_CHANGED,Buttons_OnSkinModeSettingsChanged); diff --git a/plugins/Clist_modern/src/modern_toolbar.cpp b/plugins/Clist_modern/src/modern_toolbar.cpp index 486cfe8a78..6d654d889c 100644 --- a/plugins/Clist_modern/src/modern_toolbar.cpp +++ b/plugins/Clist_modern/src/modern_toolbar.cpp @@ -55,7 +55,7 @@ static void SetButtonPressed(int i, int state) CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)BTNS[i].hButton, state ? TTBST_PUSHED : TTBST_RELEASED); } -static int Modern_InitButtons(WPARAM, LPARAM) +void Modern_InitButtons() { for (int i=0; i < SIZEOF(BTNS); i++) { TTBButton tbb = { 0 }; @@ -91,7 +91,6 @@ static int Modern_InitButtons(WPARAM, LPARAM) SetButtonPressed(3, db_get_b(NULL, "CList", "HideOffline", SETTING_HIDEOFFLINE_DEFAULT)); SetButtonPressed(6, db_get_b(NULL, "CList", "UseGroups", SETTING_USEGROUPS_DEFAULT)); SetButtonPressed(7, db_get_b(NULL, "Skin", "UseSound", SETTING_ENABLESOUNDS_DEFAULT)); - return 1; } /////////////////////////////////////////////////////////////////////////////// @@ -304,15 +303,13 @@ void CustomizeToolbar(HWND hwnd) pMTBInfo->mtbXPTheme = xpt_AddThemeHandle(hwnd, L"TOOLBAR"); pMTBInfo->bHardUpdate = TRUE; + + Modern_InitButtons(); } #define TTB_OPTDIR "TopToolBar" -#if defined(WIN64) - static char szUrl[] = "http://miranda-ng.org/x64/Plugins/toptoolbar.zip"; -#else - static char szUrl[] = "http://miranda-ng.org/x32/Plugins/toptoolbar.zip"; -#endif +static char szUrl[] = "http://wiki.miranda-ng.org/index.php?title=Plugin:TopToolBar"; static TCHAR szWarning[] = LPGENT("To view a toolbar in Clist Modern you need the TopToolBar plugin. Click Yes to download it or Cancel to continue"); @@ -321,12 +318,27 @@ static void CopySettings(const char* to, const char* from, int defValue) db_set_b(NULL, TTB_OPTDIR, to, db_get_b(NULL,"ModernToolBar",from, defValue)); } +///////////////////////////////////////////////////////////////////////////////////////// + +void CustomizeButton(HANDLE ttbid, HWND hWnd, LPARAM lParam); + +static int Toolbar_ModuleReloaded(WPARAM wParam, LPARAM lParam) +{ + PLUGININFOEX *pInfo = (PLUGININFOEX*)wParam; + if ( !_stricmp(pInfo->shortName, "TopToolBar")) + TopToolbar_SetCustomProc(CustomizeButton, 0); + + return 0; +} + static int Toolbar_ModulesLoaded(WPARAM, LPARAM) { CallService(MS_BACKGROUNDCONFIG_REGISTER, (WPARAM)"ToolBar Background/ToolBar",0); + HookEvent(ME_DB_CONTACT_SETTINGCHANGED, ehhToolBarSettingsChanged); HookEvent(ME_BACKGROUNDCONFIG_CHANGED, ehhToolBarBackgroundSettingsChanged); - HookEvent(ME_TTB_INITBUTTONS, Modern_InitButtons); + + TopToolbar_SetCustomProc(CustomizeButton, 0); BYTE bOldSetting = 0; if ( !db_get_b(NULL, "Compatibility", "TTB_Upgrade", 0)) { @@ -356,6 +368,8 @@ static int Toolbar_ModulesLoaded(WPARAM, LPARAM) HRESULT ToolbarLoadModule() { ehhToolBarBackgroundSettingsChanged(0, 0); + + HookEvent(ME_SYSTEM_MODULELOAD, Toolbar_ModuleReloaded); HookEvent(ME_SYSTEM_MODULESLOADED, Toolbar_ModulesLoaded); return S_OK; } diff --git a/plugins/Clist_modern/src/modern_viewmodebar.cpp b/plugins/Clist_modern/src/modern_viewmodebar.cpp index 6f23c660bb..da5f2f3296 100644 --- a/plugins/Clist_modern/src/modern_viewmodebar.cpp +++ b/plugins/Clist_modern/src/modern_viewmodebar.cpp @@ -26,14 +26,11 @@ $Id: viewmodes.c 2998 2006-06-01 07:11:52Z nightwish2004 $ */ #include "hdr/modern_commonheaders.h" -#include "m_variables.h" #include "hdr/modern_cluiframes.h" #include "m_api/m_skinbutton.h" #define TIMERID_VIEWMODEEXPIRE 100 -void MakeButtonSkinned(HWND hWnd); - typedef int (__cdecl *pfnEnumCallback)(char *szName); static HWND clvmHwnd = 0; static int clvm_curItem = 0; diff --git a/plugins/Clist_nicer/src/CLCButton.cpp b/plugins/Clist_nicer/src/CLCButton.cpp index 9d4afe9b5b..b5c51182d6 100644 --- a/plugins/Clist_nicer/src/CLCButton.cpp +++ b/plugins/Clist_nicer/src/CLCButton.cpp @@ -64,7 +64,7 @@ static int getButtonIndex(HANDLE hButton) return -1; } -static int InitDefaultButtons(WPARAM, LPARAM) +static void InitDefaultButtons() { for (int i=0; i < SIZEOF(BTNS); i++ ) { TTBButton tbb = { 0 }; @@ -90,7 +90,6 @@ static int InitDefaultButtons(WPARAM, LPARAM) ClcSetButtonState(IDC_TBHIDEOFFLINE, db_get_b(NULL, "CList", "HideOffline", SETTING_HIDEOFFLINE_DEFAULT)); ClcSetButtonState(IDC_TBHIDEGROUPS, db_get_b(NULL, "CList", "UseGroups", SETTING_USEGROUPS_DEFAULT)); ClcSetButtonState(IDC_TBSOUND, db_get_b(NULL, "Skin", "UseSound", 1)); - return 1; } void ClcSetButtonState(int ctrlid, int status) @@ -520,6 +519,8 @@ static void CustomizeToolbar(HANDLE hButton, HWND hWnd, LPARAM) if (hButton == TTB_WINDOW_HANDLE) { TTBCtrlCustomize custData = { sizeof(TTBCtrl), ToolbarWndProc }; SendMessage(hWnd, TTB_SETCUSTOM, 0, (LPARAM)&custData); + + InitDefaultButtons(); return; } @@ -552,12 +553,20 @@ 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; } +static int Nicer_ReloadToolbar(WPARAM wParam, LPARAM) +{ + PLUGININFOEX *pInfo = (PLUGININFOEX*)wParam; + if ( !_stricmp(pInfo->shortName, "TopToolBar")) + TopToolbar_SetCustomProc(CustomizeToolbar, 0); + return 0; +} + void LoadButtonModule() { + HookEvent(ME_SYSTEM_MODULELOAD, Nicer_ReloadToolbar); HookEvent(ME_SYSTEM_MODULESLOADED, Nicer_CustomizeToolbar); } diff --git a/plugins/ExternalAPI/m_toptoolbar.h b/plugins/ExternalAPI/m_toptoolbar.h index 3c9d569d31..4b037a3168 100644 --- a/plugins/ExternalAPI/m_toptoolbar.h +++ b/plugins/ExternalAPI/m_toptoolbar.h @@ -50,13 +50,6 @@ Called when the toolbar services are available */ #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 === /* diff --git a/plugins/TopToolBar/src/InternalButtons.cpp b/plugins/TopToolBar/src/InternalButtons.cpp index 0662c540bf..eaf07853b6 100644 --- a/plugins/TopToolBar/src/InternalButtons.cpp +++ b/plugins/TopToolBar/src/InternalButtons.cpp @@ -79,7 +79,7 @@ INT_PTR TTBInternalSoundsOnOff(WPARAM wParam, LPARAM lParam) /////////////////////////////////////////////////////////////////////////////// -int InitInternalButtons(WPARAM, LPARAM) +void InitInternalButtons() { hwndContactTree = (HWND)CallService(MS_CLUI_GETHWNDTREE, 0, 0); @@ -119,5 +119,4 @@ int InitInternalButtons(WPARAM, LPARAM) db_get_b(NULL, "Skin", "UseSound", 1) ? TTBST_RELEASED : TTBST_PUSHED); HookEvent(ME_DB_CONTACT_SETTINGCHANGED, OnSettingChanging); - return 0; } diff --git a/plugins/TopToolBar/src/common.h b/plugins/TopToolBar/src/common.h index 0840111f2f..64e15fcad4 100644 --- a/plugins/TopToolBar/src/common.h +++ b/plugins/TopToolBar/src/common.h @@ -116,7 +116,7 @@ extern HBITMAP hBmpBackground, hBmpSeparator; extern CRITICAL_SECTION csButtonsHook; extern pfnCustomProc g_CustomProc; extern LPARAM g_CustomProcParam; -extern HANDLE hTTBModuleLoaded, hTTBInitButtons; +extern HANDLE hTTBModuleLoaded; void AddToOptions(TopButtonInt* b); void RemoveFromOptions(int id); @@ -138,14 +138,14 @@ TopButtonInt* idtopos(int id, int* pPos=NULL); INT_PTR TTBAddButton(WPARAM, LPARAM); INT_PTR TTBRemoveButton(WPARAM, LPARAM); -int InitInternalButtons(WPARAM, LPARAM); +void InitInternalButtons(void); -int LoadToolbarModule( void ); -int UnloadToolbarModule( void ); +int LoadToolbarModule(void); +int UnloadToolbarModule(void); -void SetAllBitmaps( void ); -int SaveAllLButs( void ); -int SaveAllButtonsOptions( void ); +void SetAllBitmaps(void); +int SaveAllLButs(void); +int SaveAllButtonsOptions(void); void InsertSeparator( int i ); void DeleteSeparator(int i); diff --git a/plugins/TopToolBar/src/toolbar.cpp b/plugins/TopToolBar/src/toolbar.cpp index 655117fc50..a0e5509ed8 100644 --- a/plugins/TopToolBar/src/toolbar.cpp +++ b/plugins/TopToolBar/src/toolbar.cpp @@ -13,7 +13,7 @@ HWND hwndContactList = 0; int nextButtonId = 200; -HANDLE hTTBModuleLoaded, hTTBInitButtons; +HANDLE hTTBModuleLoaded; static WNDPROC buttonWndProc; CRITICAL_SECTION csButtonsHook; @@ -677,8 +677,6 @@ int LoadToolbarModule() HookEvent(ME_OPT_INITIALISE, TTBOptInit); hTTBModuleLoaded = CreateHookableEvent(ME_TTB_MODULELOADED); - hTTBInitButtons = CreateHookableEvent(ME_TTB_INITBUTTONS); - SetHookDefaultForHookableEvent(hTTBInitButtons, InitInternalButtons); CreateServiceFunction("TopToolBar/AddButton", TTBAddButton); CreateServiceFunction(MS_TTB_REMOVEBUTTON, TTBRemoveButton); @@ -712,7 +710,6 @@ int LoadToolbarModule() int UnloadToolbarModule() { DestroyHookableEvent(hTTBModuleLoaded); - DestroyHookableEvent(hTTBInitButtons); DeleteObject(hBmpSeparator); DeleteCriticalSection(&csButtonsHook); diff --git a/plugins/TopToolBar/src/toolbarwnd.cpp b/plugins/TopToolBar/src/toolbarwnd.cpp index 99793040d4..9801ac5faa 100644 --- a/plugins/TopToolBar/src/toolbarwnd.cpp +++ b/plugins/TopToolBar/src/toolbarwnd.cpp @@ -279,6 +279,8 @@ INT_PTR OnEventFire(WPARAM wParam, LPARAM lParam) // if we're working in skinned clist, receive the standard buttons & customizations if (g_CustomProc && g_ctrl->hWnd) g_CustomProc(TTB_WINDOW_HANDLE, g_ctrl->hWnd, g_CustomProcParam); + else + InitInternalButtons(); // if there's no customized frames, create our own if (g_ctrl->hFrame == NULL) { @@ -292,8 +294,7 @@ INT_PTR OnEventFire(WPARAM wParam, LPARAM lParam) g_ctrl->hFrame = (HANDLE)CallService(MS_CLIST_FRAMES_ADDFRAME, (WPARAM)&Frame, 0); } - // receive all buttons - NotifyEventHooks(hTTBInitButtons, 0, 0); + // receive buttons NotifyEventHooks(hTTBModuleLoaded, 0, 0); return 0; diff --git a/plugins/TopToolBar/src/version.h b/plugins/TopToolBar/src/version.h index e9242d347d..f32fd595eb 100644 --- a/plugins/TopToolBar/src/version.h +++ b/plugins/TopToolBar/src/version.h @@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define __MAJOR_VERSION 0 #define __MINOR_VERSION 8 #define __RELEASE_NUM 0 -#define __BUILD_NUM 2 +#define __BUILD_NUM 3 // other stuff for Version resource #define __STRINGIFY_IMPL(x) #x -- cgit v1.2.3