From 092d9b814c8c2e523fa2a73c69fa26cda1a5c17f Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 2 Jul 2015 19:41:38 +0000 Subject: unified project for clist_nicer git-svn-id: http://svn.miranda-ng.org/main/trunk@14474 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Clist_nicer/clist_nicer.vcxproj | 33 + plugins/Clist_nicer/clist_nicer.vcxproj.filters | 4 + plugins/Clist_nicer/clist_nicer_10.vcxproj | 250 -- plugins/Clist_nicer/clist_nicer_10.vcxproj.filters | 176 -- plugins/Clist_nicer/clist_nicer_12.vcxproj | 253 -- plugins/Clist_nicer/clist_nicer_12.vcxproj.filters | 176 -- plugins/Clist_nicer/res/resource.rc | 2 +- plugins/Clist_nicer/res/version.rc | 2 +- plugins/Clist_nicer/src/CLCButton.cpp | 2 +- plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp | 3069 -------------------- plugins/Clist_nicer/src/CLUIFrames/cluiframes.h | 127 - plugins/Clist_nicer/src/CLUIFrames/groupmenu.cpp | 288 -- plugins/Clist_nicer/src/Coolsb/coolsb_internal.h | 94 - plugins/Clist_nicer/src/Coolsb/coolsblib.cpp | 917 ------ plugins/Clist_nicer/src/Coolsb/coolsblib.h | 41 - plugins/Clist_nicer/src/Coolsb/coolscroll.cpp | 3060 ------------------- plugins/Clist_nicer/src/Coolsb/coolscroll.h | 232 -- plugins/Clist_nicer/src/Coolsb/userdefs.h | 79 - plugins/Clist_nicer/src/Docking.cpp | 2 +- plugins/Clist_nicer/src/Include/Version.h | 14 - plugins/Clist_nicer/src/Include/alphablend.h | 31 - plugins/Clist_nicer/src/Include/clc.h | 522 ---- plugins/Clist_nicer/src/Include/clist.h | 50 - plugins/Clist_nicer/src/Include/commonheaders.h | 88 - plugins/Clist_nicer/src/Include/config.h | 140 - plugins/Clist_nicer/src/Include/extBackg.h | 97 - plugins/Clist_nicer/src/Include/resource.h | 390 --- plugins/Clist_nicer/src/Include/rowheight_funcs.h | 74 - plugins/Clist_nicer/src/alphablend.cpp | 2 +- plugins/Clist_nicer/src/alphablend.h | 31 + plugins/Clist_nicer/src/clc.cpp | 10 +- plugins/Clist_nicer/src/clc.h | 522 ++++ plugins/Clist_nicer/src/clcidents.cpp | 2 +- plugins/Clist_nicer/src/clcitems.cpp | 2 +- plugins/Clist_nicer/src/clcmsgs.cpp | 2 +- plugins/Clist_nicer/src/clcopts.cpp | 4 +- plugins/Clist_nicer/src/clcpaint.cpp | 2 +- plugins/Clist_nicer/src/clcutils.cpp | 4 +- plugins/Clist_nicer/src/clist.h | 50 + plugins/Clist_nicer/src/clistevents.cpp | 4 +- plugins/Clist_nicer/src/clistmenus.cpp | 4 +- plugins/Clist_nicer/src/clistmod.cpp | 2 +- plugins/Clist_nicer/src/clistopts.cpp | 2 +- plugins/Clist_nicer/src/clistsettings.cpp | 2 +- plugins/Clist_nicer/src/clisttray.cpp | 2 +- plugins/Clist_nicer/src/clnplus.cpp | 2 +- plugins/Clist_nicer/src/clui.cpp | 6 +- plugins/Clist_nicer/src/cluiframes.cpp | 3069 ++++++++++++++++++++ plugins/Clist_nicer/src/cluiframes.h | 127 + plugins/Clist_nicer/src/cluiopts.cpp | 2 +- plugins/Clist_nicer/src/cluiservices.cpp | 4 +- plugins/Clist_nicer/src/config.cpp | 2 +- plugins/Clist_nicer/src/config.h | 140 + plugins/Clist_nicer/src/contact.cpp | 2 +- plugins/Clist_nicer/src/coolsb_internal.h | 94 + plugins/Clist_nicer/src/coolsblib.cpp | 917 ++++++ plugins/Clist_nicer/src/coolsblib.h | 41 + plugins/Clist_nicer/src/coolscroll.cpp | 3060 +++++++++++++++++++ plugins/Clist_nicer/src/coolscroll.h | 232 ++ plugins/Clist_nicer/src/extBackg.cpp | 4 +- plugins/Clist_nicer/src/extBackg.h | 97 + plugins/Clist_nicer/src/groupmenu.cpp | 288 ++ plugins/Clist_nicer/src/init.cpp | 6 +- plugins/Clist_nicer/src/resource.h | 390 +++ plugins/Clist_nicer/src/rowheight_funcs.cpp | 4 +- plugins/Clist_nicer/src/rowheight_funcs.h | 74 + plugins/Clist_nicer/src/statusbar.cpp | 4 +- plugins/Clist_nicer/src/stdafx.cpp | 18 - plugins/Clist_nicer/src/stdafx.cxx | 18 + plugins/Clist_nicer/src/stdafx.h | 87 + plugins/Clist_nicer/src/userdefs.h | 79 + plugins/Clist_nicer/src/version.h | 14 + plugins/Clist_nicer/src/viewmodes.cpp | 5 +- plugins/Clist_nicer/src/wallpaper.cpp | 2 +- 74 files changed, 9415 insertions(+), 10233 deletions(-) create mode 100644 plugins/Clist_nicer/clist_nicer.vcxproj create mode 100644 plugins/Clist_nicer/clist_nicer.vcxproj.filters delete mode 100644 plugins/Clist_nicer/clist_nicer_10.vcxproj delete mode 100644 plugins/Clist_nicer/clist_nicer_10.vcxproj.filters delete mode 100644 plugins/Clist_nicer/clist_nicer_12.vcxproj delete mode 100644 plugins/Clist_nicer/clist_nicer_12.vcxproj.filters delete mode 100644 plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp delete mode 100644 plugins/Clist_nicer/src/CLUIFrames/cluiframes.h delete mode 100644 plugins/Clist_nicer/src/CLUIFrames/groupmenu.cpp delete mode 100644 plugins/Clist_nicer/src/Coolsb/coolsb_internal.h delete mode 100644 plugins/Clist_nicer/src/Coolsb/coolsblib.cpp delete mode 100644 plugins/Clist_nicer/src/Coolsb/coolsblib.h delete mode 100644 plugins/Clist_nicer/src/Coolsb/coolscroll.cpp delete mode 100644 plugins/Clist_nicer/src/Coolsb/coolscroll.h delete mode 100644 plugins/Clist_nicer/src/Coolsb/userdefs.h delete mode 100644 plugins/Clist_nicer/src/Include/Version.h delete mode 100644 plugins/Clist_nicer/src/Include/alphablend.h delete mode 100644 plugins/Clist_nicer/src/Include/clc.h delete mode 100644 plugins/Clist_nicer/src/Include/clist.h delete mode 100644 plugins/Clist_nicer/src/Include/commonheaders.h delete mode 100644 plugins/Clist_nicer/src/Include/config.h delete mode 100644 plugins/Clist_nicer/src/Include/extBackg.h delete mode 100644 plugins/Clist_nicer/src/Include/resource.h delete mode 100644 plugins/Clist_nicer/src/Include/rowheight_funcs.h create mode 100644 plugins/Clist_nicer/src/alphablend.h create mode 100644 plugins/Clist_nicer/src/clc.h create mode 100644 plugins/Clist_nicer/src/clist.h create mode 100644 plugins/Clist_nicer/src/cluiframes.cpp create mode 100644 plugins/Clist_nicer/src/cluiframes.h create mode 100644 plugins/Clist_nicer/src/config.h create mode 100644 plugins/Clist_nicer/src/coolsb_internal.h create mode 100644 plugins/Clist_nicer/src/coolsblib.cpp create mode 100644 plugins/Clist_nicer/src/coolsblib.h create mode 100644 plugins/Clist_nicer/src/coolscroll.cpp create mode 100644 plugins/Clist_nicer/src/coolscroll.h create mode 100644 plugins/Clist_nicer/src/extBackg.h create mode 100644 plugins/Clist_nicer/src/groupmenu.cpp create mode 100644 plugins/Clist_nicer/src/resource.h create mode 100644 plugins/Clist_nicer/src/rowheight_funcs.h delete mode 100644 plugins/Clist_nicer/src/stdafx.cpp create mode 100644 plugins/Clist_nicer/src/stdafx.cxx create mode 100644 plugins/Clist_nicer/src/stdafx.h create mode 100644 plugins/Clist_nicer/src/userdefs.h create mode 100644 plugins/Clist_nicer/src/version.h diff --git a/plugins/Clist_nicer/clist_nicer.vcxproj b/plugins/Clist_nicer/clist_nicer.vcxproj new file mode 100644 index 0000000000..530b4c9922 --- /dev/null +++ b/plugins/Clist_nicer/clist_nicer.vcxproj @@ -0,0 +1,33 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + Clist_nicer + {3C42510C-A29E-4A53-899C-203BFA874E0B} + + + + + + + Sync + + + \ No newline at end of file diff --git a/plugins/Clist_nicer/clist_nicer.vcxproj.filters b/plugins/Clist_nicer/clist_nicer.vcxproj.filters new file mode 100644 index 0000000000..a8ab01c0e5 --- /dev/null +++ b/plugins/Clist_nicer/clist_nicer.vcxproj.filters @@ -0,0 +1,4 @@ + + + + diff --git a/plugins/Clist_nicer/clist_nicer_10.vcxproj b/plugins/Clist_nicer/clist_nicer_10.vcxproj deleted file mode 100644 index 1ec643fc74..0000000000 --- a/plugins/Clist_nicer/clist_nicer_10.vcxproj +++ /dev/null @@ -1,250 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - Clist_nicer - {3C42510C-A29E-4A53-899C-203BFA874E0B} - - - - DynamicLibrary - Unicode - true - - - DynamicLibrary - Unicode - - - DynamicLibrary - Unicode - true - - - DynamicLibrary - Unicode - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(SolutionDir)$(Configuration)\Plugins\ - $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)\Plugins\ - $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)64\Plugins\ - $(SolutionDir)$(Configuration)64\Plugins\ - $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ - true - - - - ..\..\include;src\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - commonheaders.h - EditAndContinue - MultiThreadedDebugDLL - Disabled - Use - Level3 - _DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - - - _DEBUG;%(PreprocessorDefinitions) - ..\..\include;..\..\include\msapi - - - comctl32.lib;shlwapi.lib;UxTheme.lib;%(AdditionalDependencies) - true - 0x6c540000 - false - $(IntDir)$(TargetName).lib - Windows - type=%27Win32%27 name=%27Microsoft.Windows.Common-Controls%27 version=%276.0.0.0%27 processorArchitecture=%27X86%27 publicKeyToken=%276595b64144ccf1df%27 language=%27*%27;%(AdditionalManifestDependencies) - $(ProfileDir)..\..\bin10\lib - - - - - Full - OnlyExplicitInline - Size - ..\..\include;src\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - false - true - Fast - commonheaders.h - Level3 - false - Use - - - NDEBUG;%(PreprocessorDefinitions) - ..\..\include;..\..\include\msapi - - - comctl32.lib;shlwapi.lib;UxTheme.lib;%(AdditionalDependencies) - type=%27Win32%27 name=%27Microsoft.Windows.Common-Controls%27 version=%276.0.0.0%27 processorArchitecture=%27X86%27 publicKeyToken=%276595b64144ccf1df%27 language=%27*%27;%(AdditionalManifestDependencies) - true - true - true - 0x6c540000 - false - $(IntDir)$(TargetName).lib - Windows - $(ProfileDir)..\..\bin10\lib - /PDBALTPATH:%_PDB% - - - - - ..\..\include;src\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - MultiThreadedDebugDLL - commonheaders.h - Disabled - Use - Level3 - _DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - - - ..\..\include;..\..\include\msapi - _DEBUG;%(PreprocessorDefinitions) - - - comctl32.lib;shlwapi.lib;UxTheme.lib;%(AdditionalDependencies) - true - Windows - 0x6c540000 - false - $(IntDir)$(TargetName).lib - type=%27Win32%27 name=%27Microsoft.Windows.Common-Controls%27 version=%276.0.0.0%27 processorArchitecture=%27*%27 publicKeyToken=%276595b64144ccf1df%27 language=%27*%27;%(AdditionalManifestDependencies) - $(ProfileDir)..\..\bin10\lib - - - - - ..\..\include;src\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - Full - Size - true - Use - commonheaders.h - NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - Fast - false - OnlyExplicitInline - Level3 - - - ..\..\include;..\..\include\msapi - NDEBUG;%(PreprocessorDefinitions) - - - comctl32.lib;shlwapi.lib;UxTheme.lib;%(AdditionalDependencies) - true - true - true - $(IntDir)$(TargetName).lib - Windows - 0x6c540000 - false - type=%27Win32%27 name=%27Microsoft.Windows.Common-Controls%27 version=%276.0.0.0%27 processorArchitecture=%27*%27 publicKeyToken=%276595b64144ccf1df%27 language=%27*%27;%(AdditionalManifestDependencies) - $(ProfileDir)..\..\bin10\lib - /PDBALTPATH:%_PDB% - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/plugins/Clist_nicer/clist_nicer_10.vcxproj.filters b/plugins/Clist_nicer/clist_nicer_10.vcxproj.filters deleted file mode 100644 index 6e654a40eb..0000000000 --- a/plugins/Clist_nicer/clist_nicer_10.vcxproj.filters +++ /dev/null @@ -1,176 +0,0 @@ - - - - - {5cea9501-67c7-486f-aaea-39bcdaf379dc} - cpp;c;cxx;rc;def;r;odl;idl;hpj;bat - - - {c05a0c33-3511-432e-b5ca-3a9657b2b2ab} - - - {6bdb6d4f-0852-479c-8ce1-811f89431e13} - - - {afb27711-5559-4318-b2e4-9eb76da90001} - h;hpp;hxx;hm;inl - - - {e5c38f32-abf7-49dc-8c7c-6cb39d9ad5ff} - ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files\COOLSB - - - Source Files\COOLSB - - - Source Files\CLUIFrames - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Source Files\CLUIFrames - - - Source Files\COOLSB - - - Source Files\COOLSB - - - Source Files\COOLSB - - - Source Files\COOLSB - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Resource Files - - - Resource Files - - - \ No newline at end of file diff --git a/plugins/Clist_nicer/clist_nicer_12.vcxproj b/plugins/Clist_nicer/clist_nicer_12.vcxproj deleted file mode 100644 index 67daf76ec4..0000000000 --- a/plugins/Clist_nicer/clist_nicer_12.vcxproj +++ /dev/null @@ -1,253 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - Clist_nicer - {3C42510C-A29E-4A53-899C-203BFA874E0B} - - - - DynamicLibrary - Unicode - true - v120_xp - - - DynamicLibrary - Unicode - v120_xp - - - DynamicLibrary - Unicode - true - v120_xp - - - DynamicLibrary - Unicode - v120_xp - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(SolutionDir)$(Configuration)\Plugins\ - $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)\Plugins\ - $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)64\Plugins\ - $(SolutionDir)$(Configuration)64\Plugins\ - $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ - true - - - - ..\..\include;src\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - commonheaders.h - EditAndContinue - MultiThreadedDebugDLL - Disabled - Use - Level4 - _DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - - - _DEBUG;%(PreprocessorDefinitions) - ..\..\include;..\..\include\msapi - - - comctl32.lib;shlwapi.lib;UxTheme.lib;%(AdditionalDependencies) - true - 0x6c540000 - false - $(IntDir)$(TargetName).lib - Windows - type=%27Win32%27 name=%27Microsoft.Windows.Common-Controls%27 version=%276.0.0.0%27 processorArchitecture=%27X86%27 publicKeyToken=%276595b64144ccf1df%27 language=%27*%27;%(AdditionalManifestDependencies) - $(ProfileDir)..\..\bin12\lib - false - - - - - Full - OnlyExplicitInline - Size - ..\..\include;src\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - false - true - Fast - commonheaders.h - Level4 - false - Use - - - NDEBUG;%(PreprocessorDefinitions) - ..\..\include;..\..\include\msapi - - - comctl32.lib;shlwapi.lib;UxTheme.lib;%(AdditionalDependencies) - type=%27Win32%27 name=%27Microsoft.Windows.Common-Controls%27 version=%276.0.0.0%27 processorArchitecture=%27X86%27 publicKeyToken=%276595b64144ccf1df%27 language=%27*%27;%(AdditionalManifestDependencies) - true - true - true - 0x6c540000 - false - $(IntDir)$(TargetName).lib - Windows - $(ProfileDir)..\..\bin12\lib - - - - - ..\..\include;src\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - MultiThreadedDebugDLL - commonheaders.h - Disabled - Use - Level4 - _DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - - - ..\..\include;..\..\include\msapi - _DEBUG;%(PreprocessorDefinitions) - - - comctl32.lib;shlwapi.lib;UxTheme.lib;%(AdditionalDependencies) - true - Windows - 0x6c540000 - false - $(IntDir)$(TargetName).lib - type=%27Win32%27 name=%27Microsoft.Windows.Common-Controls%27 version=%276.0.0.0%27 processorArchitecture=%27*%27 publicKeyToken=%276595b64144ccf1df%27 language=%27*%27;%(AdditionalManifestDependencies) - $(ProfileDir)..\..\bin12\lib - - - - - ..\..\include;src\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - Full - Size - true - Use - commonheaders.h - NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - Fast - false - OnlyExplicitInline - Level4 - - - ..\..\include;..\..\include\msapi - NDEBUG;%(PreprocessorDefinitions) - - - comctl32.lib;shlwapi.lib;UxTheme.lib;%(AdditionalDependencies) - true - true - true - $(IntDir)$(TargetName).lib - Windows - 0x6c540000 - false - type=%27Win32%27 name=%27Microsoft.Windows.Common-Controls%27 version=%276.0.0.0%27 processorArchitecture=%27*%27 publicKeyToken=%276595b64144ccf1df%27 language=%27*%27;%(AdditionalManifestDependencies) - $(ProfileDir)..\..\bin12\lib - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/plugins/Clist_nicer/clist_nicer_12.vcxproj.filters b/plugins/Clist_nicer/clist_nicer_12.vcxproj.filters deleted file mode 100644 index 6e654a40eb..0000000000 --- a/plugins/Clist_nicer/clist_nicer_12.vcxproj.filters +++ /dev/null @@ -1,176 +0,0 @@ - - - - - {5cea9501-67c7-486f-aaea-39bcdaf379dc} - cpp;c;cxx;rc;def;r;odl;idl;hpj;bat - - - {c05a0c33-3511-432e-b5ca-3a9657b2b2ab} - - - {6bdb6d4f-0852-479c-8ce1-811f89431e13} - - - {afb27711-5559-4318-b2e4-9eb76da90001} - h;hpp;hxx;hm;inl - - - {e5c38f32-abf7-49dc-8c7c-6cb39d9ad5ff} - ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files\COOLSB - - - Source Files\COOLSB - - - Source Files\CLUIFrames - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Source Files\CLUIFrames - - - Source Files\COOLSB - - - Source Files\COOLSB - - - Source Files\COOLSB - - - Source Files\COOLSB - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Resource Files - - - Resource Files - - - \ No newline at end of file diff --git a/plugins/Clist_nicer/res/resource.rc b/plugins/Clist_nicer/res/resource.rc index e2ec27705c..28fbc2cd53 100644 --- a/plugins/Clist_nicer/res/resource.rc +++ b/plugins/Clist_nicer/res/resource.rc @@ -1,6 +1,6 @@ // Microsoft Visual C++ generated resource script. // -#include "..\src\include\resource.h" +#include "..\src\resource.h" #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// diff --git a/plugins/Clist_nicer/res/version.rc b/plugins/Clist_nicer/res/version.rc index 126eb53280..5bfbab4754 100644 --- a/plugins/Clist_nicer/res/version.rc +++ b/plugins/Clist_nicer/res/version.rc @@ -5,7 +5,7 @@ #endif //APSTUDIO_INVOKED #include "afxres.h" -#include "..\src\include\version.h" +#include "..\src\version.h" VS_VERSION_INFO VERSIONINFO FILEVERSION __FILEVERSION_STRING diff --git a/plugins/Clist_nicer/src/CLCButton.cpp b/plugins/Clist_nicer/src/CLCButton.cpp index d5689f67f5..047ef84064 100644 --- a/plugins/Clist_nicer/src/CLCButton.cpp +++ b/plugins/Clist_nicer/src/CLCButton.cpp @@ -16,7 +16,7 @@ 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 "stdafx.h" #include #include diff --git a/plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp b/plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp deleted file mode 100644 index 84c4390de9..0000000000 --- a/plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp +++ /dev/null @@ -1,3069 +0,0 @@ -/* - -Miranda NG: the free IM client for Microsoft* Windows* - -Copyright (ñ) 2012-15 Miranda NG project (http://miranda-ng.org), -Copyright (c) 2000-03 Miranda ICQ/IM 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 -#include "cluiframes.h" -HFONT __fastcall ChangeToFont(HDC hdc, struct ClcData *dat, int id, int *fontHeight); - -extern HWND g_hwndViewModeFrame, g_hwndEventArea; -extern int mf_updatethread_running; - -extern HANDLE hThreadMFUpdate; - -void MF_UpdateThread(LPVOID); - -HANDLE hStatusBarShowToolTipEvent, hStatusBarHideToolTipEvent; -HANDLE g_hEventThread = 0; - -LOGFONT TitleBarLogFont = { 0 }; - -extern HINSTANCE g_hInst; - -//we use dynamic frame list, -//but who wants so huge number of frames ?? -#define MAX_FRAMES 40 - -#define UNCOLLAPSED_FRAME_SIZE 0 - -//legacy menu support -#define frame_menu_lock 1 -#define frame_menu_visible 2 -#define frame_menu_showtitlebar 3 -#define frame_menu_floating 4 -#define frame_menu_skinned 5 - -static int UpdateTBToolTip(int framepos); -INT_PTR CLUIFrameSetFloat(WPARAM wParam, LPARAM lParam); -int CLUIFrameResizeFloatingFrame(int framepos); -static int CLUIFramesReSort(); - -boolean FramesSysNotStarted = TRUE; -HPEN g_hPenCLUIFrames = 0; - -static SortData g_sd[MAX_FRAMES]; - -static HHOOK g_hFrameHook = 0; - -static int sortfunc(const void *a, const void *b) -{ - SortData *sd1, *sd2; - sd1 = (SortData *)a; - sd2 = (SortData *)b; - if (sd1->order > sd2->order) - return 1; - if (sd1->order < sd2->order) - return -1; - return 0; -} - -static FRAMEWND *Frames = NULL; - -FRAMEWND *wndFrameCLC = NULL, *wndFrameEventArea = NULL, *wndFrameViewMode = NULL; - -static int nFramescount = 0; -static int alclientFrame = -1;//for fast access to frame with alclient properties -static int NextFrameId = 100; - -static int TitleBarH = DEFAULT_TITLEBAR_HEIGHT; -static boolean resizing = FALSE; - -// menus -static FrameMenuHandles cont; - -// others -static int ContactListHeight; -static int LastStoreTick = 0; - -static int lbypos = -1; -static int oldframeheight = -1; -static int curdragbar = -1; -static mir_cs csFrameHook; - -static bool CLUIFramesFitInSize(void); -HWND hWndExplorerToolBar; -static int GapBetweenFrames = 1; - -static int RemoveItemFromList(int pos, FRAMEWND **lpFrames, int *FrameItemCount) -{ - memcpy(&((*lpFrames)[pos]), &((*lpFrames)[pos + 1]), sizeof(FRAMEWND) * (*FrameItemCount - pos - 1)); - (*FrameItemCount)--; - return 0; -} - -static int id2pos(int id) -{ - int i; - - if (FramesSysNotStarted) - return -1; - - for (i = 0; i < nFramescount; i++) { - if (Frames[i].id == id) - return i; - } - return -1; -} - -int __forceinline btoint(bool b) -{ - return (b ? 1 : 0); -} - -static FRAMEWND *FindFrameByWnd(HWND hwnd) -{ - if (hwnd == NULL) - return NULL; - - for (int i = 0; i < nFramescount; i++) - if ((Frames[i].floating) && (Frames[i].ContainerWnd == hwnd)) - return (&Frames[i]); - - return NULL; -} - -static void DockThumbs(FRAMEWND *pThumbLeft, FRAMEWND *pThumbRight, BOOL) -{ - if ((pThumbRight->dockOpt.hwndLeft == NULL) && (pThumbLeft->dockOpt.hwndRight == NULL)) { - pThumbRight->dockOpt.hwndLeft = pThumbLeft->ContainerWnd; - pThumbLeft->dockOpt.hwndRight = pThumbRight->ContainerWnd; - } -} - -static void UndockThumbs(FRAMEWND *pThumb1, FRAMEWND *pThumb2) -{ - if ((pThumb1 == NULL) || (pThumb2 == NULL)) - return; - - if (pThumb1->dockOpt.hwndRight == pThumb2->ContainerWnd) - pThumb1->dockOpt.hwndRight = NULL; - - if (pThumb1->dockOpt.hwndLeft == pThumb2->ContainerWnd) - pThumb1->dockOpt.hwndLeft = NULL; - - if (pThumb2->dockOpt.hwndRight == pThumb1->ContainerWnd) - pThumb2->dockOpt.hwndRight = NULL; - - if (pThumb2->dockOpt.hwndLeft == pThumb1->ContainerWnd) - pThumb2->dockOpt.hwndLeft = NULL; -} - -BOOLEAN bMoveTogether; - -static void PositionThumb(FRAMEWND *pThumb, short nX, short nY) -{ - FRAMEWND *pCurThumb = &Frames[0]; - FRAMEWND *pDockThumb = pThumb; - FRAMEWND fakeMainWindow; - FRAMEWND fakeTaskBarWindow; - RECT rc; - RECT rcThumb; - RECT rcOld; - SIZE sizeScreen; - int nOffs = 10; - POINT pt; - RECT rcLeft; - RECT rcTop; - RECT rcRight; - RECT rcBottom; - int frmidx = 0; - - if (pThumb == NULL) - return; - - sizeScreen.cx = GetSystemMetrics(SM_CXSCREEN); - sizeScreen.cy = GetSystemMetrics(SM_CYSCREEN); - - // Get thumb dimnsions - GetWindowRect(pThumb->ContainerWnd, &rcThumb); - int nWidth = rcThumb.right - rcThumb.left; - int nHeight = rcThumb.bottom - rcThumb.top; - - // Docking to the edges of the screen - int nNewX = nX < nOffs ? 0 : nX; - nNewX = nNewX >(sizeScreen.cx - nWidth - nOffs) ? (sizeScreen.cx - nWidth) : nNewX; - int nNewY = nY < nOffs ? 0 : nY; - nNewY = nNewY >(sizeScreen.cy - nHeight - nOffs) ? (sizeScreen.cy - nHeight) : nNewY; - - bool bLeading = pThumb->dockOpt.hwndRight != NULL; - - if (bMoveTogether) { - UndockThumbs(pThumb, FindFrameByWnd(pThumb->dockOpt.hwndLeft)); - GetWindowRect(pThumb->ContainerWnd, &rcOld); - } - - memset(&fakeMainWindow, 0, sizeof(fakeMainWindow)); - fakeMainWindow.ContainerWnd = pcli->hwndContactList; - fakeMainWindow.floating = TRUE; - - memset(&fakeTaskBarWindow, 0, sizeof(fakeTaskBarWindow)); - fakeTaskBarWindow.ContainerWnd = hWndExplorerToolBar; - fakeTaskBarWindow.floating = TRUE; - - while (pCurThumb != NULL) { - if (pCurThumb->floating) { - - if (pCurThumb != pThumb) { - GetWindowRect(pThumb->ContainerWnd, &rcThumb); - OffsetRect(&rcThumb, nX - rcThumb.left, nY - rcThumb.top); - - GetWindowRect(pCurThumb->ContainerWnd, &rc); - - rcLeft.left = rc.left - nOffs; - rcLeft.top = rc.top - nOffs; - rcLeft.right = rc.left + nOffs; - rcLeft.bottom = rc.bottom + nOffs; - - rcTop.left = rc.left - nOffs; - rcTop.top = rc.top - nOffs; - rcTop.right = rc.right + nOffs; - rcTop.bottom = rc.top + nOffs; - - rcRight.left = rc.right - nOffs; - rcRight.top = rc.top - nOffs; - rcRight.right = rc.right + nOffs; - rcRight.bottom = rc.bottom + nOffs; - - rcBottom.left = rc.left - nOffs; - rcBottom.top = rc.bottom - nOffs; - rcBottom.right = rc.right + nOffs; - rcBottom.bottom = rc.bottom + nOffs; - - bool bDockedLeft = false, bDockedRight = false, bDocked = false; - - // Upper-left - pt.x = rcThumb.left; - pt.y = rcThumb.top; - - if (PtInRect(&rcRight, pt)) { - nNewX = rc.right; - bDocked = true; - } - - if (PtInRect(&rcBottom, pt)) { - nNewY = rc.bottom; - if (PtInRect(&rcLeft, pt)) - nNewX = rc.left; - } - - if (PtInRect(&rcTop, pt)) { - nNewY = rc.top; - bDockedLeft = bDocked; - } - - // Upper-right - pt.x = rcThumb.right; - pt.y = rcThumb.top; - bDocked = false; - - if (!bLeading && PtInRect(&rcLeft, pt)) { - if (!bDockedLeft) { - nNewX = rc.left - nWidth; - bDocked = true; - } - else if (rc.right == rcThumb.left) - bDocked = true; - } - - - if (PtInRect(&rcBottom, pt)) { - nNewY = rc.bottom; - if (PtInRect(&rcRight, pt)) - nNewX = rc.right - nWidth; - } - - if (!bLeading && PtInRect(&rcTop, pt)) { - nNewY = rc.top; - bDockedRight = bDocked; - } - - if (bMoveTogether) { - if (bDockedRight) - DockThumbs(pThumb, pCurThumb, TRUE); - - if (bDockedLeft) - DockThumbs(pCurThumb, pThumb, FALSE); - } - - // Lower-left - pt.x = rcThumb.left; - pt.y = rcThumb.bottom; - - if (PtInRect(&rcRight, pt)) - nNewX = rc.right; - - if (PtInRect(&rcTop, pt)) { - nNewY = rc.top - nHeight; - - if (PtInRect(&rcLeft, pt)) - nNewX = rc.left; - } - - - // Lower-right - pt.x = rcThumb.right; - pt.y = rcThumb.bottom; - - if (!bLeading && PtInRect(&rcLeft, pt)) - nNewX = rc.left - nWidth; - - if (!bLeading && PtInRect(&rcTop, pt)) { - nNewY = rc.top - nHeight; - - if (PtInRect(&rcRight, pt)) - nNewX = rc.right - nWidth; - } - } - } - - frmidx++; - if (pCurThumb->ContainerWnd == fakeTaskBarWindow.ContainerWnd) - break; - - if (pCurThumb->ContainerWnd == fakeMainWindow.ContainerWnd) { - pCurThumb = &fakeTaskBarWindow; - continue; - } - if (frmidx == nFramescount) { - pCurThumb = &fakeMainWindow; - continue; - } - pCurThumb = &Frames[frmidx]; - } - - // Adjust coords once again - nNewX = nNewX < nOffs ? 0 : nNewX; - nNewX = nNewX > (sizeScreen.cx - nWidth - nOffs) ? (sizeScreen.cx - nWidth) : nNewX; - nNewY = nNewY < nOffs ? 0 : nNewY; - nNewY = nNewY > (sizeScreen.cy - nHeight - nOffs) ? (sizeScreen.cy - nHeight) : nNewY; - SetWindowPos(pThumb->ContainerWnd, 0, nNewX, nNewY, 0, 0, SWP_NOSIZE | SWP_NOZORDER); - - // OK, move all docked thumbs - if (bMoveTogether) { - pDockThumb = FindFrameByWnd(pDockThumb->dockOpt.hwndRight); - PositionThumb(pDockThumb, (short)(nNewX + nWidth), (short)nNewY); - } -} - -void GetBorderSize(HWND hwnd, RECT *rect) -{ - RECT wr, cr; - POINT pt1, pt2; - - GetWindowRect(hwnd, &wr); - GetClientRect(hwnd, &cr); - pt1.y = cr.top; - pt1.x = cr.left; - pt2.y = cr.bottom; - pt2.x = cr.right; - - ClientToScreen(hwnd, &pt1); - ClientToScreen(hwnd, &pt2); - - cr.top = pt1.y; - cr.left = pt1.x; - cr.bottom = pt2.y; - cr.right = pt2.x; - - rect->top = cr.top - wr.top; - rect->left = cr.left - wr.left; - rect->right = wr.right - cr.right; - rect->bottom = wr.bottom - cr.bottom; -} - -//append string -char __forceinline *AS(char *str, const char *setting, char *addstr) -{ - if (str != NULL) { - mir_strcpy(str, setting); - mir_strcat(str, addstr); - } - return str; -} - -int DBLoadFrameSettingsAtPos(int pos, int Frameid) -{ - char sadd[15]; - char buf[255]; - - _itoa(pos, sadd, 10); - - Frames[Frameid].collapsed = 0 != cfg::getByte(CLUIFrameModule, AS(buf, "Collapse", sadd), Frames[Frameid].collapsed); - - Frames[Frameid].Locked = 0 != cfg::getByte(CLUIFrameModule, AS(buf, "Locked", sadd), Frames[Frameid].Locked); - Frames[Frameid].visible = 0 != cfg::getByte(CLUIFrameModule, AS(buf, "Visible", sadd), Frames[Frameid].visible); - Frames[Frameid].TitleBar.ShowTitleBar = 0 != cfg::getByte(CLUIFrameModule, AS(buf, "TBVisile", sadd), Frames[Frameid].TitleBar.ShowTitleBar); - - Frames[Frameid].height = cfg::getWord(CLUIFrameModule, AS(buf, "Height", sadd), Frames[Frameid].height); - Frames[Frameid].HeightWhenCollapsed = cfg::getWord(CLUIFrameModule, AS(buf, "HeightCollapsed", sadd), 0); - Frames[Frameid].align = cfg::getWord(CLUIFrameModule, AS(buf, "Align", sadd), Frames[Frameid].align); - - Frames[Frameid].FloatingPos.x = DBGetContactSettingRangedWord(0, CLUIFrameModule, AS(buf, "FloatX", sadd), 100, 0, 1024); - Frames[Frameid].FloatingPos.y = DBGetContactSettingRangedWord(0, CLUIFrameModule, AS(buf, "FloatY", sadd), 100, 0, 1024); - Frames[Frameid].FloatingSize.x = DBGetContactSettingRangedWord(0, CLUIFrameModule, AS(buf, "FloatW", sadd), 100, 0, 1024); - Frames[Frameid].FloatingSize.y = DBGetContactSettingRangedWord(0, CLUIFrameModule, AS(buf, "FloatH", sadd), 100, 0, 1024); - - Frames[Frameid].floating = 0 != cfg::getByte(CLUIFrameModule, AS(buf, "Floating", sadd), 0); - Frames[Frameid].order = cfg::getWord(CLUIFrameModule, AS(buf, "Order", sadd), 0); - - Frames[Frameid].UseBorder = 0 != cfg::getByte(CLUIFrameModule, AS(buf, "UseBorder", sadd), Frames[Frameid].UseBorder); - Frames[Frameid].Skinned = 0 != cfg::getByte(CLUIFrameModule, AS(buf, "Skinned", sadd), Frames[Frameid].Skinned); - return 0; -} - -int DBStoreFrameSettingsAtPos(int pos, int Frameid) -{ - char sadd[16]; - char buf[255]; - - _itoa(pos, sadd, 10); - - cfg::writeTString(0, CLUIFrameModule, AS(buf, "Name", sadd), Frames[Frameid].name); - //boolean - cfg::writeByte(0, CLUIFrameModule, AS(buf, "Collapse", sadd), (BYTE)btoint(Frames[Frameid].collapsed)); - cfg::writeByte(0, CLUIFrameModule, AS(buf, "Locked", sadd), (BYTE)btoint(Frames[Frameid].Locked)); - cfg::writeByte(0, CLUIFrameModule, AS(buf, "Visible", sadd), (BYTE)btoint(Frames[Frameid].visible)); - cfg::writeByte(0, CLUIFrameModule, AS(buf, "TBVisile", sadd), (BYTE)btoint(Frames[Frameid].TitleBar.ShowTitleBar)); - - cfg::writeWord(CLUIFrameModule, AS(buf, "Height", sadd), (WORD)Frames[Frameid].height); - cfg::writeWord(CLUIFrameModule, AS(buf, "HeightCollapsed", sadd), (WORD)Frames[Frameid].HeightWhenCollapsed); - cfg::writeWord(CLUIFrameModule, AS(buf, "Align", sadd), (WORD)Frames[Frameid].align); - //FloatingPos - cfg::writeWord(CLUIFrameModule, AS(buf, "FloatX", sadd), (WORD)Frames[Frameid].FloatingPos.x); - cfg::writeWord(CLUIFrameModule, AS(buf, "FloatY", sadd), (WORD)Frames[Frameid].FloatingPos.y); - cfg::writeWord(CLUIFrameModule, AS(buf, "FloatW", sadd), (WORD)Frames[Frameid].FloatingSize.x); - cfg::writeWord(0, CLUIFrameModule, AS(buf, "FloatH", sadd), (WORD)Frames[Frameid].FloatingSize.y); - - cfg::writeByte(0, CLUIFrameModule, AS(buf, "Floating", sadd), (BYTE)btoint(Frames[Frameid].floating)); - cfg::writeByte(0, CLUIFrameModule, AS(buf, "UseBorder", sadd), (BYTE)btoint(Frames[Frameid].UseBorder)); - cfg::writeWord(0, CLUIFrameModule, AS(buf, "Order", sadd), (WORD)Frames[Frameid].order); - - cfg::writeByte(CLUIFrameModule, AS(buf, "Skinned", sadd), Frames[Frameid].Skinned); - return 0; -} - -int LocateStorePosition(int Frameid, int maxstored) -{ - if (Frames[Frameid].name == NULL) return -1; - - for (int i = 0; i < maxstored; i++) { - char settingname[255]; - mir_snprintf(settingname, _countof(settingname), "Name%d", i); - ptrT frmname(db_get_tsa(0, CLUIFrameModule, settingname)); - if (frmname == NULL) continue; - if (mir_tstrcmpi(frmname, Frames[Frameid].name) == 0) - return i; - } - return -1; -} - -int CLUIFramesLoadFrameSettings(int Frameid) -{ - int storpos, maxstored; - - if (FramesSysNotStarted) return -1; - - if (Frameid < 0 || Frameid >= nFramescount) - return -1; - - maxstored = cfg::getWord(CLUIFrameModule, "StoredFrames", -1); - if (maxstored == -1) - return 0; - - storpos = LocateStorePosition(Frameid, maxstored); - if (storpos == -1) - return 0; - - DBLoadFrameSettingsAtPos(storpos, Frameid); - return 0; -} - -int CLUIFramesStoreFrameSettings(int Frameid) -{ - int maxstored, storpos; - - if (FramesSysNotStarted) - return -1; - - if (Frameid < 0 || Frameid >= nFramescount) - return -1; - - maxstored = cfg::getWord(CLUIFrameModule, "StoredFrames", -1); - if (maxstored == -1) - maxstored = 0; - - storpos = LocateStorePosition(Frameid, maxstored); - if (storpos == -1) { - storpos = maxstored; - maxstored++; - } - - DBStoreFrameSettingsAtPos(storpos, Frameid); - cfg::writeWord(CLUIFrameModule, "StoredFrames", (WORD)maxstored); - return 0; -} - -int CLUIFramesStoreAllFrames() -{ - int i; - - if (FramesSysNotStarted) - return -1; - - if (cfg::shutDown) - return -1; - - mir_cslock lck(csFrameHook); - for (i = 0; i < nFramescount; i++) - CLUIFramesStoreFrameSettings(i); - return 0; -} - -// Get client frame -int CLUIFramesGetalClientFrame(void) -{ - int i; - if (FramesSysNotStarted) - return -1; - - if (alclientFrame != -1) { - /* this value could become invalid if RemoveItemFromList was called, - * so we double-check */ - if (alclientFrame < nFramescount) { - if (Frames[alclientFrame].align == alClient) { - return alclientFrame; - } - } - } - - for (i = 0; i < nFramescount; i++) - if (Frames[i].align == alClient) { - alclientFrame = i; - return i; - } - return -1; -} - -///////////////////////////////////////////////////////////////////////////////////////// - -static HGENMENU addFrameMenuItem(TMO_MenuItem *pmi, int frameid, bool bMain) -{ - HGENMENU res = (bMain) ? Menu_AddMainMenuItem(pmi) : Menu_AddContextFrameMenuItem(pmi); - if (pmi->pszService != NULL) - Menu_ConfigureItem(res, MCI_OPT_EXECPARAM, frameid); - return res; -} - -HMENU CLUIFramesCreateMenuForFrame(int frameid, HGENMENU root, int popuppos, bool bMain) -{ - if (FramesSysNotStarted) - return NULL; - - int framepos = id2pos(frameid); - FrameMenuHandles &fmh = (frameid == -1) ? cont : Frames[framepos].MenuHandles; - - CMenuItem mi; - mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_MIRANDA); - mi.root = root; - mi.position = popuppos++; - mi.name.a = LPGEN("&FrameTitle"); - mi.flags = CMIF_SYSTEM | CMIF_GRAYED; - fmh.MITitle = addFrameMenuItem(&mi, frameid, bMain); - - popuppos += 100000; - - mi.hIcolibItem = NULL; - mi.position = popuppos++; - mi.name.a = LPGEN("&Visible"); - mi.flags = CMIF_SYSTEM | CMIF_CHECKED; - mi.pszService = MS_CLIST_FRAMES_SHFRAME; - fmh.MIVisible = addFrameMenuItem(&mi, frameid, bMain); - - mi.position = popuppos++; - mi.name.a = LPGEN("&Show title bar"); - mi.pszService = MS_CLIST_FRAMES_SHFRAMETITLEBAR; - fmh.MITBVisible = addFrameMenuItem(&mi, frameid, bMain); - - popuppos += 100000; - - mi.position = popuppos++; - mi.name.a = LPGEN("&Locked"); - mi.pszService = MS_CLIST_FRAMES_ULFRAME; - fmh.MILock = addFrameMenuItem(&mi, frameid, bMain); - - mi.position = popuppos++; - mi.name.a = LPGEN("&Collapsed"); - mi.pszService = MS_CLIST_FRAMES_UCOLLFRAME; - fmh.MIColl = addFrameMenuItem(&mi, frameid, bMain); - - // floating - mi.position = popuppos++; - mi.name.a = LPGEN("&Floating mode"); - mi.flags = CMIF_SYSTEM; - mi.pszService = "Set_Floating"; - fmh.MIFloating = addFrameMenuItem(&mi, frameid, bMain); - - popuppos += 100000; - - mi.position = popuppos++; - mi.name.a = LPGEN("&Border"); - mi.flags = CMIF_SYSTEM | CMIF_CHECKED; - mi.pszService = MS_CLIST_FRAMES_SETUNBORDER; - fmh.MIBorder = addFrameMenuItem(&mi, frameid, bMain); - - popuppos += 100000; - - mi.position = popuppos++; - mi.name.a = LPGEN("&Skinned frame"); - mi.pszService = MS_CLIST_FRAMES_SETSKINNED; - fmh.MISkinned = addFrameMenuItem(&mi, frameid, bMain); - - popuppos += 100000; - - // alignment root - mi.root = root; - mi.position = popuppos++; - mi.name.a = LPGEN("&Align"); - mi.flags = CMIF_SYSTEM; - mi.pszService = NULL; - fmh.MIAlignRoot = addFrameMenuItem(&mi, frameid, bMain); - - // align top - mi.root = fmh.MIAlignRoot; - mi.position = popuppos++; - mi.name.a = LPGEN("&Top"); - mi.pszService = CLUIFRAMESSETALIGNALTOP; - fmh.MIAlignTop = addFrameMenuItem(&mi, frameid, bMain); - - // align client - mi.position = popuppos++; - mi.name.a = LPGEN("&Client"); - mi.pszService = CLUIFRAMESSETALIGNALCLIENT; - fmh.MIAlignClient = addFrameMenuItem(&mi, frameid, bMain); - - // align bottom - mi.position = popuppos++; - mi.name.a = LPGEN("&Bottom"); - mi.pszService = CLUIFRAMESSETALIGNALBOTTOM; - fmh.MIAlignBottom = addFrameMenuItem(&mi, frameid, bMain); - - // position root - mi.root = root; - mi.position = popuppos++; - mi.name.a = LPGEN("&Position"); - mi.pszService = NULL; - mi.root = addFrameMenuItem(&mi, frameid, bMain); - - mi.position = popuppos++; - mi.name.a = LPGEN("&Up"); - mi.pszService = CLUIFRAMESMOVEUP; - addFrameMenuItem(&mi, frameid, bMain); - - mi.position = popuppos++; - mi.name.a = LPGEN("&Down"); - mi.pszService = CLUIFRAMESMOVEDOWN; - addFrameMenuItem(&mi, frameid, bMain); - return 0; -} - -static int CLUIFramesModifyContextMenuForFrame(WPARAM wParam, LPARAM) -{ - if (FramesSysNotStarted) - return -1; - - mir_cslock lck(csFrameHook); - int pos = id2pos(wParam); - if (pos >= 0 && pos < nFramescount) { - FRAMEWND &p = Frames[pos]; - Menu_ModifyItem(cont.MITitle, p.TitleBar.tbname ? p.TitleBar.tbname : p.name); - Menu_SetChecked(cont.MIVisible, p.visible); - Menu_SetChecked(cont.MILock, p.Locked); - Menu_SetChecked(cont.MITBVisible, p.TitleBar.ShowTitleBar); - Menu_SetChecked(cont.MIFloating, p.floating); - Menu_SetChecked(cont.MIBorder, p.UseBorder); - Menu_SetChecked(cont.MISkinned, p.Skinned); - Menu_SetChecked(cont.MIAlignTop, (p.align & alTop) != 0); - Menu_SetChecked(cont.MIAlignClient, (p.align & alClient) != 0); - Menu_SetChecked(cont.MIAlignBottom, (p.align & alBottom) != 0); - - Menu_SetChecked(cont.MIColl, !p.collapsed); - Menu_EnableItem(cont.MIColl, p.visible && !p.Locked && pos != CLUIFramesGetalClientFrame()); - } - return 0; -} - -INT_PTR CLUIFramesModifyMainMenuItems(WPARAM frameId, LPARAM) -{ - if (FramesSysNotStarted) - return -1; - - mir_cslock lck(csFrameHook); - int pos = id2pos(frameId); - - if (pos >= 0 && pos < nFramescount) { - FRAMEWND &p = Frames[pos]; - Menu_ModifyItem(p.MenuHandles.MITitle, p.TitleBar.tbname ? p.TitleBar.tbname : p.name); - - Menu_SetChecked(p.MenuHandles.MIVisible, p.visible); - Menu_SetChecked(p.MenuHandles.MILock, p.Locked); - Menu_SetChecked(p.MenuHandles.MITBVisible, p.TitleBar.ShowTitleBar); - Menu_SetChecked(p.MenuHandles.MIFloating, p.floating); - Menu_SetChecked(p.MenuHandles.MIBorder, p.UseBorder); - Menu_SetChecked(p.MenuHandles.MISkinned, p.Skinned); - - Menu_EnableItem(p.MenuHandles.MIAlignTop, (p.align & alClient) == 0); - Menu_SetChecked(p.MenuHandles.MIAlignTop, (p.align & alTop) != 0); - - Menu_SetChecked(p.MenuHandles.MIAlignClient, (p.align & alClient) != 0); - - Menu_EnableItem(p.MenuHandles.MIAlignTop, (p.align & alClient) == 0); - Menu_SetChecked(p.MenuHandles.MIAlignTop, (p.align & alBottom) != 0); - - Menu_SetChecked(p.MenuHandles.MIColl, !p.collapsed); - Menu_EnableItem(p.MenuHandles.MIColl, p.visible && !p.Locked && pos != CLUIFramesGetalClientFrame()); - } - return 0; -} - -INT_PTR CLUIFramesGetFrameOptions(WPARAM wParam, LPARAM) -{ - if (FramesSysNotStarted) return -1; - - mir_cslock lck(csFrameHook); - int pos = id2pos(HIWORD(wParam)); - if (pos < 0 || pos >= nFramescount) - return -1; - - switch (LOWORD(wParam)) { - case FO_NAME: - return (INT_PTR)Frames[pos].name; - - case FO_TBNAME: - return (INT_PTR)Frames[pos].TitleBar.tbname; - - case FO_TBTIPNAME: - return (INT_PTR)Frames[pos].TitleBar.tooltip; - - case FO_TBSTYLE: - return GetWindowLongPtr(Frames[pos].TitleBar.hwnd, GWL_STYLE); - - case FO_TBEXSTYLE: - return GetWindowLongPtr(Frames[pos].TitleBar.hwnd, GWL_EXSTYLE); - - case FO_ICON: - return (INT_PTR)Frames[pos].TitleBar.hicon; - - case FO_HEIGHT: - return (INT_PTR)Frames[pos].height; - - case FO_ALIGN: - return (INT_PTR)Frames[pos].align; - - case FO_FLOATING: - return (INT_PTR)Frames[pos].floating; - - case FO_FLAGS: - INT_PTR dwFlags = 0; - if (Frames[pos].visible) dwFlags |= F_VISIBLE; - if (!Frames[pos].collapsed) dwFlags |= F_UNCOLLAPSED; - if (Frames[pos].Locked) dwFlags |= F_LOCKED; - if (Frames[pos].TitleBar.ShowTitleBar) dwFlags |= F_SHOWTB; - if (Frames[pos].TitleBar.ShowTitleBarTip) dwFlags |= F_SHOWTBTIP; - if (Frames[pos].Skinned) dwFlags |= F_SKINNED; - if (!(GetWindowLongPtr(Frames[pos].hWnd, GWL_STYLE)&WS_BORDER)) dwFlags |= F_NOBORDER; - return dwFlags; - } - - return -1; -} - -INT_PTR CLUIFramesSetFrameOptions(WPARAM wParam, LPARAM lParam) -{ - int retval; // value to be returned - - if (FramesSysNotStarted) - return -1; - - mir_cslockfull lck(csFrameHook); - int pos = id2pos(HIWORD(wParam)); - if (pos < 0 || pos >= nFramescount) - return -1; - - switch (LOWORD(wParam) & ~FO_UNICODETEXT) { - case FO_FLAGS: - { - int flag = lParam; - LONG_PTR style; - - Frames[pos].dwFlags = flag; - Frames[pos].visible = FALSE; - if (flag & F_VISIBLE) Frames[pos].visible = TRUE; - - Frames[pos].collapsed = TRUE; - if (flag & F_UNCOLLAPSED) Frames[pos].collapsed = FALSE; - - Frames[pos].Locked = FALSE; - if (flag & F_LOCKED) Frames[pos].Locked = TRUE; - - Frames[pos].UseBorder = TRUE; - if (flag & F_NOBORDER) Frames[pos].UseBorder = FALSE; - - Frames[pos].TitleBar.ShowTitleBar = FALSE; - if (flag & F_SHOWTB) Frames[pos].TitleBar.ShowTitleBar = TRUE; - - Frames[pos].TitleBar.ShowTitleBarTip = FALSE; - if (flag & F_SHOWTBTIP) Frames[pos].TitleBar.ShowTitleBarTip = TRUE; - - SendMessage(Frames[pos].TitleBar.hwndTip, TTM_ACTIVATE, (WPARAM)Frames[pos].TitleBar.ShowTitleBarTip, 0); - - style = GetWindowLongPtr(Frames[pos].hWnd, GWL_STYLE); - style |= WS_BORDER; - style |= CLS_SKINNEDFRAME; - - if (flag & F_NOBORDER) - style &= (~WS_BORDER); - - Frames[pos].Skinned = FALSE; - if (flag & F_SKINNED) - Frames[pos].Skinned = TRUE; - - if (!(flag & F_SKINNED)) - style &= ~CLS_SKINNEDFRAME; - - SetWindowLongPtr(Frames[pos].hWnd, GWL_STYLE, (LONG_PTR)style); - SetWindowLongPtr(Frames[pos].TitleBar.hwnd, GWL_STYLE, (LONG_PTR)style & ~(WS_VSCROLL | WS_HSCROLL)); - lck.unlock(); - - CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0); - SetWindowPos(Frames[pos].TitleBar.hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED); - } - return 0; - - case FO_NAME: - if (lParam == 0) - return -1; - - mir_free(Frames[pos].name); - Frames[pos].name = (wParam & FO_UNICODETEXT) ? mir_u2t((LPWSTR)lParam) : mir_a2t((LPSTR)lParam); - return 0; - - case FO_TBNAME: - if (lParam == 0) - return -1; - - mir_free(Frames[pos].TitleBar.tbname); - Frames[pos].TitleBar.tbname = (wParam & FO_UNICODETEXT) ? mir_u2t((LPWSTR)lParam) : mir_a2t((LPSTR)lParam); - lck.unlock(); - - if (Frames[pos].floating && (Frames[pos].TitleBar.tbname != NULL)) - SetWindowText(Frames[pos].ContainerWnd, Frames[pos].TitleBar.tbname); - return 0; - - case FO_TBTIPNAME: - if (lParam == 0) - return -1; - - mir_free(Frames[pos].TitleBar.tooltip); - Frames[pos].TitleBar.tooltip = (wParam & FO_UNICODETEXT) ? mir_u2t((LPWSTR)lParam) : mir_a2t((LPSTR)lParam); - UpdateTBToolTip(pos); - return 0; - - case FO_TBSTYLE: - SetWindowLongPtr(Frames[pos].TitleBar.hwnd, GWL_STYLE, lParam); - return 0; - - case FO_TBEXSTYLE: - SetWindowLongPtr(Frames[pos].TitleBar.hwnd, GWL_EXSTYLE, lParam); - return 0; - - case FO_ICON: - Frames[pos].TitleBar.hicon = (HICON)lParam; - return 0; - - case FO_HEIGHT: - if (lParam < 0) - return -1; - - if (Frames[pos].Skinned) { - int uID = (Frames[pos].TitleBar.ShowTitleBar ? ID_EXTBKOWNEDFRAMEBORDERTB - ID_STATUS_OFFLINE : ID_EXTBKOWNEDFRAMEBORDER - ID_STATUS_OFFLINE); - lParam += (arStatusItems[uID]->MARGIN_BOTTOM + arStatusItems[uID]->MARGIN_TOP); - } - if (Frames[pos].collapsed) { - int oldHeight = Frames[pos].height; - retval = Frames[pos].height; - Frames[pos].height = lParam; - if (!CLUIFramesFitInSize()) - Frames[pos].height = retval; - retval = Frames[pos].height; - - if (Frames[pos].height != oldHeight) { - CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0); - if (Frames[pos].Skinned) - RedrawWindow(Frames[pos].hWnd, 0, 0, RDW_FRAME | RDW_UPDATENOW | RDW_INVALIDATE); - } - } - else { - retval = Frames[pos].HeightWhenCollapsed; - Frames[pos].HeightWhenCollapsed = lParam; - if (!CLUIFramesFitInSize()) - Frames[pos].HeightWhenCollapsed = retval; - retval = Frames[pos].HeightWhenCollapsed; - } - return retval; - - case FO_FLOATING: - if (lParam < 0) - return -1; - else { - int id = Frames[pos].id; - Frames[pos].floating = !(lParam); - lck.unlock(); - - CLUIFrameSetFloat(id, 1);//lparam=1 use stored width and height - } - return wParam; - - case FO_ALIGN: - if (!(lParam&alTop || lParam&alBottom || lParam&alClient)) - return -1; - - if ((lParam&alClient) && (CLUIFramesGetalClientFrame() >= 0)) { //only one alClient frame possible - alclientFrame = -1;//recalc it - return -1; - } - Frames[pos].align = lParam; - return 0; - } - lck.unlock(); - - CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0); - return -1; -} - -static INT_PTR CLUIFramesShowAll(WPARAM, LPARAM) -{ - if (FramesSysNotStarted) - return -1; - - for (int i = 0; i < nFramescount; i++) - Frames[i].visible = TRUE; - - CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0); - return 0; -} - -INT_PTR CLUIFramesShowAllTitleBars(WPARAM, LPARAM) -{ - if (FramesSysNotStarted) - return -1; - - for (int i = 0; i < nFramescount; i++) { - Frames[i].TitleBar.ShowTitleBar = TRUE; - SetWindowPos(Frames[i].hWnd, 0, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED); - } - CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0); - RedrawWindow(pcli->hwndContactList, NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_UPDATENOW | RDW_ALLCHILDREN); - return 0; -} - -INT_PTR CLUIFramesHideAllTitleBars(WPARAM, LPARAM) -{ - if (FramesSysNotStarted) - return -1; - - for (int i = 0; i < nFramescount; i++) { - Frames[i].TitleBar.ShowTitleBar = FALSE; - SetWindowPos(Frames[i].hWnd, 0, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED); - } - CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0); - RedrawWindow(pcli->hwndContactList, NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_UPDATENOW | RDW_ALLCHILDREN); - return 0; -} - -INT_PTR CLUIFramesShowHideFrame(WPARAM frameId, LPARAM) -{ - if (FramesSysNotStarted) - return -1; - - int pos; - { - mir_cslock lck(csFrameHook); - pos = id2pos(frameId); - if (pos >= 0 && !mir_tstrcmp(Frames[pos].name, _T("My contacts"))) - Frames[pos].visible = 1; - else { - if (pos >= 0 && (int)pos < nFramescount) - Frames[pos].visible = !Frames[pos].visible; - if (Frames[pos].floating) - CLUIFrameResizeFloatingFrame(pos); - } - } - - if (!Frames[pos].floating) - CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0); - RedrawWindow(pcli->hwndContactList, NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_UPDATENOW | RDW_ALLCHILDREN); - return 0; -} - -INT_PTR CLUIFramesShowHideFrameTitleBar(WPARAM frameId, LPARAM) -{ - if (FramesSysNotStarted) - return -1; - - { - mir_cslock lck(csFrameHook); - int pos = id2pos(frameId); - if (pos >= 0 && (int)pos < nFramescount) { - Frames[pos].TitleBar.ShowTitleBar = !Frames[pos].TitleBar.ShowTitleBar; - SetWindowPos(Frames[pos].hWnd, 0, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED); - } - } - - CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0); - RedrawWindow(pcli->hwndContactList, NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_UPDATENOW | RDW_ALLCHILDREN); - return 0; -} - -// lparam=-1 up ,1 down -INT_PTR CLUIFramesMoveUpDown(WPARAM frameId, LPARAM lParam) -{ - int i, tmpval; - - if (FramesSysNotStarted) - return -1; - - mir_cslockfull lck(csFrameHook); - int pos = id2pos(frameId); - if (pos < 0 || pos >= nFramescount) - return 0; - - int curalign = Frames[pos].align; - int v = 0; - memset(g_sd, 0, sizeof(SortData) * MAX_FRAMES); - for (i = 0; i < nFramescount; i++) { - if (Frames[i].floating || (!Frames[i].visible) || (Frames[i].align != curalign)) - continue; - g_sd[v].order = Frames[i].order; - g_sd[v].realpos = i; - v++; - } - if (v == 0) - return 0; - - qsort(g_sd, v, sizeof(SortData), sortfunc); - for (i = 0; i < v; i++) { - if (g_sd[i].realpos == pos) { - if (lParam == -1) { - if (i < 1) break; - tmpval = Frames[g_sd[i - 1].realpos].order; - Frames[g_sd[i - 1].realpos].order = Frames[pos].order; - Frames[pos].order = tmpval; - break; - } - if (lParam == 1) { - if (i > v - 1) break; - tmpval = Frames[g_sd[i + 1].realpos].order; - Frames[g_sd[i + 1].realpos].order = Frames[pos].order; - Frames[pos].order = tmpval; - break; - } - } - } - lck.unlock(); - - CLUIFramesReSort(); - CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0); - PostMessage(pcli->hwndContactList, CLUIINTM_REDRAW, 0, 0); - return 0; -} - -static INT_PTR CLUIFramesMoveUp(WPARAM frameId, LPARAM) -{ - return CLUIFramesMoveUpDown(frameId, -1); -} - -static INT_PTR CLUIFramesMoveDown(WPARAM frameId, LPARAM) -{ - return CLUIFramesMoveUpDown(frameId, 1); -} - -//lparam=alignment -INT_PTR CLUIFramesSetAlign(WPARAM frameId, LPARAM lParam) -{ - if (FramesSysNotStarted) return -1; - - CLUIFramesSetFrameOptions(MAKEWPARAM(FO_ALIGN, frameId), lParam); - CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0); - RedrawWindow(pcli->hwndContactList, NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_UPDATENOW | RDW_ALLCHILDREN); - return 0; -} - -INT_PTR CLUIFramesSetAlignalTop(WPARAM wParam, LPARAM) -{ - if (FramesSysNotStarted) return -1; - - return CLUIFramesSetAlign(wParam, alTop); -} - -INT_PTR CLUIFramesSetAlignalBottom(WPARAM wParam, LPARAM) -{ - if (FramesSysNotStarted) return -1; - - return CLUIFramesSetAlign(wParam, alBottom); -} - -INT_PTR CLUIFramesSetAlignalClient(WPARAM wParam, LPARAM) -{ - if (FramesSysNotStarted) return -1; - - return CLUIFramesSetAlign(wParam, alClient); -} - -//wparam=frameid -INT_PTR CLUIFramesLockUnlockFrame(WPARAM wParam, LPARAM) -{ - if (FramesSysNotStarted) - return -1; - - mir_cslock lck(csFrameHook); - int pos = id2pos(wParam); - if (pos >= 0 && (int)pos < nFramescount) { - Frames[pos].Locked = !Frames[pos].Locked; - CLUIFramesStoreFrameSettings(pos); - } - return 0; -} - -//wparam=frameid -INT_PTR CLUIFramesSetUnSetBorder(WPARAM wParam, LPARAM) -{ - if (FramesSysNotStarted) - return -1; - - HWND hw; - int FrameId, oldflags; - { - mir_cslock lck(csFrameHook); - FrameId = id2pos(wParam); - if (FrameId == -1) - return -1; - - oldflags = CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_FLAGS, wParam), 0); - if (oldflags & F_NOBORDER) - oldflags &= (~F_NOBORDER); - else - oldflags |= F_NOBORDER; - - hw = Frames[FrameId].hWnd; - } - - CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS, MAKEWPARAM(FO_FLAGS, wParam), oldflags); - SetWindowPos(hw, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_DRAWFRAME | SWP_NOZORDER); - return 0; -} - -//wparam=frameid -INT_PTR CLUIFramesSetUnSetSkinned(WPARAM wParam, LPARAM) -{ - if (FramesSysNotStarted) - return -1; - - HWND hw; - int FrameId, oldflags; - { - mir_cslock lck(csFrameHook); - FrameId = id2pos(wParam); - if (FrameId == -1) - return -1; - - oldflags = CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_FLAGS, wParam), 0); - if (oldflags & F_SKINNED) - oldflags &= ~F_SKINNED; - else - oldflags |= F_SKINNED; - - hw = Frames[FrameId].hWnd; - } - - CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS, MAKEWPARAM(FO_FLAGS, wParam), oldflags); - SetWindowPos(hw, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_DRAWFRAME | SWP_NOZORDER); - return 0; -} - -//wparam=frameid -INT_PTR CLUIFramesCollapseUnCollapseFrame(WPARAM wParam, LPARAM) -{ - if (FramesSysNotStarted) - return -1; - - TitleBarH = cfg::dat.titleBarHeight; - - mir_cslockfull lck(csFrameHook); - int FrameId = id2pos(wParam); - if (FrameId < 0 || FrameId >= nFramescount) - return -1; - - int oldHeight; - - // do not collapse/uncollapse client/locked/invisible frames - if (Frames[FrameId].align == alClient && !(Frames[FrameId].Locked || (!Frames[FrameId].visible) || Frames[FrameId].floating)) { - RECT rc; - if (CallService(MS_CLIST_DOCKINGISDOCKED, 0, 0)) - return 0; - - if (cfg::getByte("CLUI", "AutoSize", 0)) - return 0; - - GetWindowRect(pcli->hwndContactList, &rc); - - if (Frames[FrameId].collapsed == TRUE) { - rc.bottom -= rc.top; - rc.bottom -= Frames[FrameId].height; - Frames[FrameId].HeightWhenCollapsed = Frames[FrameId].height; - Frames[FrameId].collapsed = FALSE; - } - else { - rc.bottom -= rc.top; - rc.bottom += Frames[FrameId].HeightWhenCollapsed; - Frames[FrameId].collapsed = TRUE; - } - - SetWindowPos(pcli->hwndContactList, NULL, 0, 0, rc.right - rc.left, rc.bottom, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOMOVE); - - CLUIFramesStoreAllFrames(); - lck.unlock(); - RedrawWindow(pcli->hwndContactList, NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_UPDATENOW | RDW_ALLCHILDREN); - return 0; - - } - if (Frames[FrameId].Locked || (!Frames[FrameId].visible)) - return 0; - - oldHeight = Frames[FrameId].height; - - // if collapsed, uncollapse - if (Frames[FrameId].collapsed == TRUE) { - Frames[FrameId].HeightWhenCollapsed = Frames[FrameId].height; - Frames[FrameId].height = UNCOLLAPSED_FRAME_SIZE; - Frames[FrameId].collapsed = FALSE; - } - // if uncollapsed, collapse - else { - Frames[FrameId].height = Frames[FrameId].HeightWhenCollapsed; - Frames[FrameId].collapsed = TRUE; - } - - if (!Frames[FrameId].floating) { - - if (!CLUIFramesFitInSize()) { - //cant collapse,we can resize only for height 2 * UNCOLLAPSED_FRAME_SIZE) { - oldHeight = Frames[alfrm].height - UNCOLLAPSED_FRAME_SIZE; - Frames[FrameId].collapsed = TRUE; - } - } - else { - int i, sumheight = 0; - - for (i = 0; i < nFramescount; i++) { - if ((Frames[i].align != alClient) && (!Frames[i].floating) && (Frames[i].visible) && (!Frames[i].needhide)) { - sumheight += (Frames[i].height) + (TitleBarH * btoint(Frames[i].TitleBar.ShowTitleBar)) + 2; - return FALSE; - } - if (sumheight > ContactListHeight - 0 - 2) - Frames[FrameId].height = (ContactListHeight - 0 - 2) - sumheight; - } - } - Frames[FrameId].height = oldHeight; - if (Frames[FrameId].collapsed == FALSE) { - if (Frames[FrameId].floating) - SetWindowPos(Frames[FrameId].ContainerWnd, HWND_TOP, 0, 0, Frames[FrameId].wndSize.right - Frames[FrameId].wndSize.left + 6, Frames[FrameId].height + DEFAULT_TITLEBAR_HEIGHT + 4, SWP_SHOWWINDOW | SWP_NOMOVE); - return -1; - } - } - } - lck.unlock(); - if (!Frames[FrameId].floating) - CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0); - else { - RECT contwnd; - GetWindowRect(Frames[FrameId].ContainerWnd, &contwnd); - contwnd.top = contwnd.bottom - contwnd.top;//height - contwnd.left = contwnd.right - contwnd.left;//width - - contwnd.top -= (oldHeight - Frames[FrameId].height);//newheight - SetWindowPos(Frames[FrameId].ContainerWnd, HWND_TOP, 0, 0, contwnd.left, contwnd.top, SWP_SHOWWINDOW | SWP_NOMOVE); - } - RedrawWindow(pcli->hwndContactList, NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_UPDATENOW | RDW_ALLCHILDREN); - CLUIFramesStoreAllFrames(); - return 0; -} - -static int CLUIFramesLoadMainMenu() -{ - if (FramesSysNotStarted) - return -1; - - if (cont.MainMenuItem != NULL) { - Menu_RemoveItem(cont.MainMenuItem); - cont.MainMenuItem = NULL; - } - - // create root menu - CMenuItem mi; - mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_FRAME); - mi.position = 3000090000; - mi.name.a = LPGEN("Frames"); - mi.pszService = 0; - cont.MainMenuItem = Menu_AddMainMenuItem(&mi); - - // create frames menu - mi.root = cont.MainMenuItem; - int separator = (int)3000200000; - for (int i = 0; i < nFramescount; i++) { - mi.hIcolibItem = Frames[i].TitleBar.hicon; - mi.flags = CMIF_TCHAR; - mi.position = separator; - mi.name.t = Frames[i].TitleBar.tbname ? Frames[i].TitleBar.tbname : Frames[i].name; - mi.pszService = 0; - Frames[i].MenuHandles.MainMenuItem = Menu_AddMainMenuItem(&mi); - CLUIFramesCreateMenuForFrame(Frames[i].id, Frames[i].MenuHandles.MainMenuItem, separator, true); - CLUIFramesModifyMainMenuItems(Frames[i].id, 0); - CallService(MS_CLIST_FRAMEMENUNOTIFY, (WPARAM)Frames[i].id, (LPARAM)Frames[i].MenuHandles.MainMenuItem); - separator++; - } - - separator += 100000; - - // create "show all frames" menu - mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_MIRANDA); - mi.flags = 0; - mi.position = separator++; - mi.name.a = LPGEN("Show all frames"); - mi.pszService = MS_CLIST_FRAMES_SHOWALLFRAMES; - Menu_AddMainMenuItem(&mi); - - // create "show all titlebars" menu - mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_HELP); - mi.position = separator++; - mi.name.a = LPGEN("Show all title bars"); - mi.pszService = MS_CLIST_FRAMES_SHOWALLFRAMESTB; - Menu_AddMainMenuItem(&mi); - - // create "hide all titlebars" menu - mi.position = separator++; - mi.name.a = LPGEN("Hide all title bars"); - mi.pszService = MS_CLIST_FRAMES_HIDEALLFRAMESTB; - Menu_AddMainMenuItem(&mi); - return 0; -} - -static HFONT CLUILoadTitleBarFont() -{ - char facename[] = "MS Shell Dlg"; - LOGFONT logfont; - memset(&logfont, 0, sizeof(logfont)); - memcpy(logfont.lfFaceName, facename, sizeof(facename)); - logfont.lfWeight = FW_NORMAL; - logfont.lfHeight = -10; - return CreateFontIndirect(&logfont); -} - -static int UpdateTBToolTip(int framepos) -{ - TOOLINFO ti; - - memset(&ti, 0, sizeof(ti)); - ti.cbSize = sizeof(ti); - ti.lpszText = Frames[framepos].TitleBar.tooltip; - ti.hinst = g_hInst; - ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS; - ti.uId = (UINT_PTR)Frames[framepos].TitleBar.hwnd; - - return SendMessage(Frames[framepos].TitleBar.hwndTip, TTM_UPDATETIPTEXT, 0, (LPARAM)&ti); -}; - -int FrameNCPaint(HWND hwnd, WNDPROC oldWndProc, WPARAM wParam, LPARAM lParam, BOOL hasTitleBar) -{ - HDC hdc; - RECT rcWindow, rc; - HWND hwndParent = GetParent(hwnd); - LRESULT result = 0; - - if (pcli == NULL) - return 0; - if (hwndParent != pcli->hwndContactList || !cfg::dat.bSkinnedScrollbar) - result = CallWindowProc(oldWndProc, hwnd, WM_NCPAINT, wParam, lParam); - if (!pcli->hwndContactList || hwndParent != pcli->hwndContactList) - return result; - - if (GetWindowLongPtr(hwnd, GWL_STYLE) & CLS_SKINNEDFRAME) { - StatusItems_t *item = (arStatusItems.getCount() != 0) ? (hasTitleBar ? arStatusItems[ID_EXTBKOWNEDFRAMEBORDERTB - ID_STATUS_OFFLINE] : arStatusItems[ID_EXTBKOWNEDFRAMEBORDER - ID_STATUS_OFFLINE]) : 0; - if (item == 0) - return 0; - - GetWindowRect(hwnd, &rcWindow); - rc.left = rc.top = 0; - rc.right = rcWindow.right - rcWindow.left; - rc.bottom = rcWindow.bottom - rcWindow.top; - - HDC hdc = GetWindowDC(hwnd); - if (hwnd == pcli->hwndContactTree) { - HDC realDC = CreateCompatibleDC(hdc); - HBITMAP hbmDraw = CreateCompatibleBitmap(hdc, rc.right, rc.bottom); - HBITMAP hbmOld = reinterpret_cast(SelectObject(realDC, hbmDraw)); - - ExcludeClipRect(realDC, item->MARGIN_LEFT, item->MARGIN_TOP, rc.right - item->MARGIN_RIGHT, rc.bottom - item->MARGIN_BOTTOM); - BitBlt(realDC, 0, 0, rc.right - rc.left, rc.bottom - rc.top, cfg::dat.hdcBg, rcWindow.left - cfg::dat.ptW.x, rcWindow.top - cfg::dat.ptW.y, SRCCOPY); - DrawAlpha(realDC, &rc, item->COLOR, item->ALPHA, item->COLOR2, item->COLOR2_TRANSPARENT, item->GRADIENT, item->CORNER, item->BORDERSTYLE, item->imageItem); - - ExcludeClipRect(hdc, item->MARGIN_LEFT, item->MARGIN_TOP, rc.right - item->MARGIN_RIGHT, rc.bottom - item->MARGIN_BOTTOM); - BitBlt(hdc, 0, 0, rc.right, rc.bottom, realDC, 0, 0, SRCCOPY); - SelectObject(realDC, hbmOld); - DeleteObject(hbmDraw); - DeleteDC(realDC); - } - else { - ExcludeClipRect(hdc, item->MARGIN_LEFT, item->MARGIN_TOP, rc.right - item->MARGIN_RIGHT, rc.bottom - item->MARGIN_BOTTOM); - BitBlt(hdc, 0, 0, rc.right - rc.left, rc.bottom - rc.top, cfg::dat.hdcBg, rcWindow.left - cfg::dat.ptW.x, rcWindow.top - cfg::dat.ptW.y, SRCCOPY); - DrawAlpha(hdc, &rc, item->COLOR, item->ALPHA, item->COLOR2, item->COLOR2_TRANSPARENT, item->GRADIENT, item->CORNER, item->BORDERSTYLE, item->imageItem); - } - ReleaseDC(hwnd, hdc); - return 0; - } - - if (GetWindowLongPtr(hwnd, GWL_STYLE) & WS_BORDER) { - hdc = GetWindowDC(hwnd); - HPEN hPenOld = reinterpret_cast(SelectObject(hdc, g_hPenCLUIFrames)); - GetWindowRect(hwnd, &rcWindow); - rc.left = rc.top = 0; - rc.right = rcWindow.right - rcWindow.left; - rc.bottom = rcWindow.bottom - rcWindow.top; - HBRUSH brold = reinterpret_cast(SelectObject(hdc, GetStockObject(HOLLOW_BRUSH))); - Rectangle(hdc, 0, 0, rcWindow.right - rcWindow.left, rcWindow.bottom - rcWindow.top); - SelectObject(hdc, hPenOld); - SelectObject(hdc, brold); - ReleaseDC(hwnd, hdc); - return 0; - } - - return result; -} - -int FrameNCCalcSize(HWND hwnd, WNDPROC oldWndProc, WPARAM wParam, LPARAM lParam, BOOL hasTitleBar) -{ - StatusItems_t *item = (arStatusItems.getCount() != 0) ? (hasTitleBar ? arStatusItems[ID_EXTBKOWNEDFRAMEBORDERTB - ID_STATUS_OFFLINE] : arStatusItems[ID_EXTBKOWNEDFRAMEBORDER - ID_STATUS_OFFLINE]) : 0; - LRESULT orig = oldWndProc ? CallWindowProc(oldWndProc, hwnd, WM_NCCALCSIZE, wParam, lParam) : 0; - NCCALCSIZE_PARAMS *nccp = (NCCALCSIZE_PARAMS *)lParam; - DWORD dwStyle = GetWindowLongPtr(hwnd, GWL_STYLE); - - if (item == 0 || pcli == NULL) - return orig; - - if (item->IGNORED || !(dwStyle & CLS_SKINNEDFRAME) || GetParent(hwnd) != pcli->hwndContactList) - return orig; - - nccp->rgrc[0].left += item->MARGIN_LEFT; - nccp->rgrc[0].right -= item->MARGIN_RIGHT; - nccp->rgrc[0].bottom -= item->MARGIN_BOTTOM; - nccp->rgrc[0].top += item->MARGIN_TOP; - return WVR_REDRAW; -} - -static LRESULT CALLBACK FramesSubClassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - int i; - - WNDPROC oldWndProc = 0; - BOOL hasTitleBar = FALSE; - - for (i = 0; i < nFramescount; i++) { - if (Frames[i].hWnd == hwnd) { - oldWndProc = Frames[i].wndProc; - hasTitleBar = Frames[i].TitleBar.ShowTitleBar; - } - } - switch (msg) { - case WM_NCPAINT: - return FrameNCPaint(hwnd, oldWndProc ? oldWndProc : DefWindowProc, wParam, lParam, hasTitleBar); - - case WM_NCCALCSIZE: - return FrameNCCalcSize(hwnd, oldWndProc, wParam, lParam, hasTitleBar); - - case WM_PRINTCLIENT: - return 0; - } - - if (oldWndProc) - return CallWindowProc(oldWndProc, hwnd, msg, wParam, lParam); - return DefWindowProc(hwnd, msg, wParam, lParam); -} - -/* - * re-sort all frames and correct frame ordering - */ - -static int CLUIFramesReSort() -{ - int v = 0, i; - int order = 1; - - mir_cslock lck(csFrameHook); - memset(g_sd, 0, sizeof(SortData) * MAX_FRAMES); - for (i = 0; i < nFramescount; i++) { - if (Frames[i].align != alTop) - continue; - g_sd[v].order = Frames[i].order; - g_sd[v].realpos = i; - v++; - } - if (v > 0) { - qsort(g_sd, v, sizeof(SortData), sortfunc); - for (i = 0; i < v; i++) - Frames[g_sd[i].realpos].order = order++; - } - - memset(g_sd, 0, sizeof(SortData) * MAX_FRAMES); - v = 0; - for (i = 0; i < nFramescount; i++) { - if (Frames[i].align != alBottom) - continue; - g_sd[v].order = Frames[i].order; - g_sd[v].realpos = i; - v++; - } - if (v > 0) { - qsort(g_sd, v, sizeof(SortData), sortfunc); - for (i = 0; i < v; i++) - Frames[g_sd[i].realpos].order = order++; - } - CLUIFramesStoreAllFrames(); - return 0; -} - -//wparam=(CLISTFrame*)clfrm -INT_PTR CLUIFramesAddFrame(WPARAM wParam, LPARAM) -{ - int style; - CLISTFrame *clfrm = (CLISTFrame *)wParam; - - if (pcli->hwndContactList == 0) return -1; - if (FramesSysNotStarted) return -1; - if (clfrm->cbSize != sizeof(CLISTFrame)) return -1; - - mir_cslockfull lck(csFrameHook); - if (nFramescount >= MAX_FRAMES) - return -1; - - if (Frames == NULL) { - Frames = (FRAMEWND*)malloc(sizeof(FRAMEWND) * (MAX_FRAMES + 2)); - memset(Frames, 0, (sizeof(FRAMEWND) * (MAX_FRAMES + 2))); - } - memset(&Frames[nFramescount], 0, sizeof(FRAMEWND)); - - Frames[nFramescount].id = NextFrameId++; - Frames[nFramescount].align = clfrm->align; - Frames[nFramescount].hWnd = clfrm->hWnd; - Frames[nFramescount].height = clfrm->height; - Frames[nFramescount].TitleBar.hicon = clfrm->hIcon; - //Frames[nFramescount].TitleBar.BackColour; - Frames[nFramescount].floating = FALSE; - - if (clfrm->Flags & F_NO_SUBCONTAINER) - Frames[nFramescount].OwnerWindow = (HWND)-2; - else - Frames[nFramescount].OwnerWindow = pcli->hwndContactList; - - SetClassLong(clfrm->hWnd, GCL_STYLE, GetClassLong(clfrm->hWnd, GCL_STYLE) & ~(CS_VREDRAW | CS_HREDRAW)); - SetWindowLongPtr(clfrm->hWnd, GWL_STYLE, GetWindowLongPtr(clfrm->hWnd, GWL_STYLE) | WS_CLIPCHILDREN); - - if (GetCurrentThreadId() == GetWindowThreadProcessId(clfrm->hWnd, NULL)) { - if (clfrm->hWnd != pcli->hwndContactTree && clfrm->hWnd != g_hwndViewModeFrame && clfrm->hWnd != g_hwndEventArea) { - Frames[nFramescount].wndProc = (WNDPROC)GetWindowLongPtr(clfrm->hWnd, GWLP_WNDPROC); - SetWindowLongPtr(clfrm->hWnd, GWLP_WNDPROC, (LONG_PTR)FramesSubClassProc); - } - } - - if (clfrm->hWnd == g_hwndEventArea) - wndFrameEventArea = &Frames[nFramescount]; - else if (clfrm->hWnd == pcli->hwndContactTree) - wndFrameCLC = &Frames[nFramescount]; - else if (clfrm->hWnd == g_hwndViewModeFrame) - wndFrameViewMode = &Frames[nFramescount]; - - Frames[nFramescount].dwFlags = clfrm->Flags; - - if (clfrm->name == NULL || ((clfrm->Flags&F_UNICODE) ? mir_wstrlen(clfrm->wname) : mir_strlen(clfrm->name)) == 0) { - TCHAR ptszClassName[256]; - GetClassName(Frames[nFramescount].hWnd, ptszClassName, _countof(ptszClassName)); - Frames[nFramescount].name = mir_tstrdup(ptszClassName); - } - else Frames[nFramescount].name = (clfrm->Flags & F_UNICODE) ? mir_u2t(clfrm->wname) : mir_a2t(clfrm->name); - - if (IsBadCodePtr((FARPROC)clfrm->TBname) || clfrm->TBname == NULL - || ((clfrm->Flags&F_UNICODE) ? mir_wstrlen(clfrm->TBwname) : mir_strlen(clfrm->TBname)) == 0) - Frames[nFramescount].TitleBar.tbname = mir_tstrdup(Frames[nFramescount].name); - else - Frames[nFramescount].TitleBar.tbname = (clfrm->Flags & F_UNICODE) ? mir_u2t(clfrm->TBwname) : mir_a2t(clfrm->TBname); - Frames[nFramescount].needhide = FALSE; - Frames[nFramescount].TitleBar.ShowTitleBar = (clfrm->Flags & F_SHOWTB ? TRUE : FALSE); - Frames[nFramescount].TitleBar.ShowTitleBarTip = (clfrm->Flags & F_SHOWTBTIP ? TRUE : FALSE); - - Frames[nFramescount].collapsed = clfrm->Flags & F_UNCOLLAPSED ? FALSE : TRUE; - Frames[nFramescount].Locked = clfrm->Flags & F_LOCKED ? TRUE : FALSE; - Frames[nFramescount].visible = clfrm->Flags & F_VISIBLE ? TRUE : FALSE; - - Frames[nFramescount].UseBorder = (clfrm->Flags & F_NOBORDER) ? FALSE : TRUE; - Frames[nFramescount].Skinned = (clfrm->Flags & F_SKINNED) ? TRUE : FALSE; - - // create frame - Frames[nFramescount].TitleBar.hwnd = - CreateWindow(CLUIFrameTitleBarClassName, Frames[nFramescount].name, - (cfg::getByte(CLUIFrameModule, "RemoveAllTitleBarBorders", 1) ? 0 : WS_BORDER) - | WS_CHILD | WS_CLIPCHILDREN | (Frames[nFramescount].TitleBar.ShowTitleBar ? WS_VISIBLE : 0) | - WS_CLIPCHILDREN, 0, 0, 0, 0, pcli->hwndContactList, NULL, g_hInst, NULL); - - SetWindowLongPtr(Frames[nFramescount].TitleBar.hwnd, GWLP_USERDATA, Frames[nFramescount].id); - - Frames[nFramescount].TitleBar.hwndTip = CreateWindowExA(0, TOOLTIPS_CLASSA, NULL, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, - CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - pcli->hwndContactList, NULL, g_hInst, NULL); - - SetWindowPos(Frames[nFramescount].TitleBar.hwndTip, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); - { - TOOLINFOA ti = { 0 }; - ti.cbSize = sizeof(ti); - ti.lpszText = ""; - ti.hinst = g_hInst; - ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS; - ti.uId = (UINT_PTR)Frames[nFramescount].TitleBar.hwnd; - SendMessageA(Frames[nFramescount].TitleBar.hwndTip, TTM_ADDTOOL, 0, (LPARAM)&ti); - } - - SendMessage(Frames[nFramescount].TitleBar.hwndTip, TTM_ACTIVATE, (WPARAM)Frames[nFramescount].TitleBar.ShowTitleBarTip, 0); - - Frames[nFramescount].oldstyles = GetWindowLongPtr(Frames[nFramescount].hWnd, GWL_STYLE); - Frames[nFramescount].TitleBar.oldstyles = GetWindowLongPtr(Frames[nFramescount].TitleBar.hwnd, GWL_STYLE); - - int retval = Frames[nFramescount].id; - Frames[nFramescount].order = nFramescount + 1; - nFramescount++; - - CLUIFramesLoadFrameSettings(id2pos(retval)); - style = GetWindowLongPtr(Frames[nFramescount - 1].hWnd, GWL_STYLE); - style &= ~(WS_BORDER); - style |= ((Frames[nFramescount - 1].UseBorder) ? WS_BORDER : 0); - - style |= Frames[nFramescount - 1].Skinned ? CLS_SKINNEDFRAME : 0; - - SetWindowLongPtr(Frames[nFramescount - 1].hWnd, GWL_STYLE, style); - SetWindowLongPtr(Frames[nFramescount - 1].TitleBar.hwnd, GWL_STYLE, style & ~(WS_VSCROLL | WS_HSCROLL)); - - if (Frames[nFramescount - 1].order == 0) - Frames[nFramescount - 1].order = nFramescount; - - lck.unlock(); - - alclientFrame = -1;//recalc it - CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0); - - if (Frames[nFramescount - 1].floating) { - Frames[nFramescount - 1].floating = FALSE; - CLUIFrameSetFloat(retval, 1);//lparam=1 use stored width and height - } - RedrawWindow(pcli->hwndContactList, NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_UPDATENOW | RDW_ALLCHILDREN); - return retval; -} - -static INT_PTR CLUIFramesRemoveFrame(WPARAM wParam, LPARAM) -{ - if (FramesSysNotStarted) - return -1; - - { - mir_cslock lck(csFrameHook); - int pos = id2pos(wParam); - if (pos < 0 || pos > nFramescount) - return -1; - - FRAMEWND* F = &Frames[pos]; - if (F->hWnd == g_hwndEventArea) - wndFrameEventArea = NULL; - else if (F->hWnd == pcli->hwndContactTree) - wndFrameCLC = NULL; - else if (F->hWnd == g_hwndViewModeFrame) - wndFrameViewMode = NULL; - - mir_free(F->name); - mir_free(F->TitleBar.tbname); - mir_free(F->TitleBar.tooltip); - - DestroyWindow(F->hWnd); - F->hWnd = (HWND)-1; - DestroyWindow(F->TitleBar.hwnd); - F->TitleBar.hwnd = (HWND)-1; - DestroyWindow(F->ContainerWnd); - F->ContainerWnd = (HWND)-1; - DestroyMenu(F->TitleBar.hmenu); - - RemoveItemFromList(pos, &Frames, &nFramescount); - } - - if (!cfg::shutDown) { - InvalidateRect(pcli->hwndContactList, NULL, TRUE); - CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0); - RedrawWindow(pcli->hwndContactList, NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_UPDATENOW | RDW_ALLCHILDREN); - } - return 0; -} - -INT_PTR CLUIFramesForceUpdateTB(const FRAMEWND *Frame) -{ - if (Frame->TitleBar.hwnd != 0) - RedrawWindow(Frame->TitleBar.hwnd, NULL, NULL, RDW_ALLCHILDREN | RDW_UPDATENOW | RDW_ERASE | RDW_INVALIDATE | RDW_FRAME); - return 0; -} - -INT_PTR CLUIFramesForceUpdateFrame(const FRAMEWND *Frame) -{ - if (Frame->hWnd != 0) - RedrawWindow(Frame->hWnd, NULL, NULL, RDW_UPDATENOW | RDW_FRAME | RDW_ERASE | RDW_INVALIDATE); - - if (Frame->floating) - if (Frame->ContainerWnd != 0) RedrawWindow(Frame->ContainerWnd, NULL, NULL, RDW_UPDATENOW | RDW_ALLCHILDREN | RDW_ERASE | RDW_INVALIDATE | RDW_FRAME); - return 0; -} - -int CLUIFrameMoveResize(const FRAMEWND *Frame) -{ - TitleBarH = cfg::dat.titleBarHeight; - // we need to show or hide the frame? - if (Frame->visible && (!Frame->needhide)) { - ShowWindow(Frame->hWnd, SW_SHOW); - ShowWindow(Frame->TitleBar.hwnd, Frame->TitleBar.ShowTitleBar == TRUE ? SW_SHOW : SW_HIDE); - } - else { - ShowWindow(Frame->hWnd, SW_HIDE); - ShowWindow(Frame->TitleBar.hwnd, SW_HIDE); - return 0; - } - - SetWindowPos(Frame->hWnd, NULL, Frame->wndSize.left + cfg::dat.bCLeft, Frame->wndSize.top + cfg::dat.topOffset, - (Frame->wndSize.right - Frame->wndSize.left), - (Frame->wndSize.bottom - Frame->wndSize.top), SWP_NOZORDER | SWP_NOREDRAW); - if (Frame->TitleBar.ShowTitleBar) { - SetWindowPos(Frame->TitleBar.hwnd, NULL, Frame->wndSize.left + cfg::dat.bCLeft, Frame->wndSize.top + cfg::dat.topOffset - TitleBarH, - (Frame->wndSize.right - Frame->wndSize.left), - TitleBarH + (Frame->UseBorder ? (!Frame->collapsed ? (Frame->align == alClient ? 0 : 2) : 1) : 0), SWP_NOZORDER); - } - return 0; -} - -bool CLUIFramesFitInSize(void) -{ - int i; - int sumheight = 0; - int tbh = 0; // title bar height - int clientfrm; - - TitleBarH = cfg::dat.titleBarHeight; - - clientfrm = CLUIFramesGetalClientFrame(); - if (clientfrm != -1) - tbh = TitleBarH * btoint(Frames[clientfrm].TitleBar.ShowTitleBar); - - for (i = 0; i < nFramescount; i++) { - if ((Frames[i].align != alClient) && (!Frames[i].floating) && (Frames[i].visible) && (!Frames[i].needhide)) { - sumheight += (Frames[i].height) + (TitleBarH * btoint(Frames[i].TitleBar.ShowTitleBar)) + 2/*+btoint(Frames[i].UseBorder)*2*/; - if (sumheight > ContactListHeight - tbh - 2) - return FALSE; - } - } - return TRUE; -} - -int CLUIFramesGetMinHeight() -{ - if (pcli->hwndContactList == NULL) - return 0; - - int i, tbh, clientfrm, sumheight = 0; - RECT border; - int allbord = 0; - { - mir_cslock lck(csFrameHook); - - TitleBarH = cfg::dat.titleBarHeight; - // search for alClient frame and get the titlebar's height - tbh = 0; - clientfrm = CLUIFramesGetalClientFrame(); - if (clientfrm != -1) - tbh = TitleBarH * btoint(Frames[clientfrm].TitleBar.ShowTitleBar); - - for (i = 0; i < nFramescount; i++) { - if ((Frames[i].align != alClient) && (Frames[i].visible) && (!Frames[i].needhide) && (!Frames[i].floating)) { - RECT wsize; - - GetWindowRect(Frames[i].hWnd, &wsize); - sumheight += (wsize.bottom - wsize.top) + (TitleBarH * btoint(Frames[i].TitleBar.ShowTitleBar)) + 3; - } - } - } - - GetBorderSize(pcli->hwndContactList, &border); - return(sumheight + border.top + border.bottom + allbord + tbh + 3); -} - -int SizeMoveNewSizes() -{ - for (int i = 0; i < nFramescount; i++) { - if (Frames[i].floating) - CLUIFrameResizeFloatingFrame(i); - else - CLUIFrameMoveResize(&Frames[i]); - } - return 0; -} - -/* - * changed Nightwish - * gap calculation was broken. Now, it doesn't calculate and store the gaps in Frames[] anymore. - * instead, it remembers the smallest wndSize.top value (which has to be the top frame) and then passes - * the gap to all following frame(s) to the actual resizing function which just adds the gap to - * wndSize.top and corrects the frame height accordingly. - - * Title bar gap has been removed (can be simulated by using a clist_nicer skin item for frame title bars - * and setting the bottom margin of the skin item - */ - -int CLUIFramesResize(const RECT newsize) -{ - int sumheight = 9999999, newheight; - int prevframe, prevframebottomline; - int tbh, curfrmtbh; - int drawitems; - int clientfrm, clientframe = -1; - int i, j; - int sepw; - int topOff = 0, botOff = 0, last_bottomtop; - - GapBetweenFrames = cfg::dat.gapBetweenFrames; - sepw = GapBetweenFrames; - - if (nFramescount < 1 || cfg::shutDown) - return 0; - - newheight = newsize.bottom - newsize.top; - TitleBarH = cfg::dat.titleBarHeight; - - // search for alClient frame and get the titlebar's height - tbh = 0; - clientfrm = CLUIFramesGetalClientFrame(); - if (clientfrm != -1) - tbh = (TitleBarH)* btoint(Frames[clientfrm].TitleBar.ShowTitleBar); - - for (i = 0; i < nFramescount; i++) { - if (!Frames[i].floating) { - Frames[i].needhide = FALSE; - Frames[i].wndSize.left = 0; - Frames[i].wndSize.right = newsize.right - newsize.left; - } - } - { - //sorting stuff - memset(g_sd, 0, sizeof(SortData) * MAX_FRAMES); - for (i = 0; i < nFramescount; i++) { - g_sd[i].order = Frames[i].order; - g_sd[i].realpos = i; - } - qsort(g_sd, nFramescount, sizeof(SortData), sortfunc); - - } - drawitems = nFramescount; - while (sumheight >(newheight - tbh) && drawitems > 0) { - sumheight = 0; - drawitems = 0; - for (i = 0; i < nFramescount; i++) { - if (((Frames[i].align != alClient)) && (!Frames[i].floating) && (Frames[i].visible) && (!Frames[i].needhide)) { - drawitems++; - curfrmtbh = (TitleBarH)* btoint(Frames[i].TitleBar.ShowTitleBar); - sumheight += (Frames[i].height) + curfrmtbh + (i > 0 ? sepw : 0) + (Frames[i].UseBorder ? 2 : 0); - if (sumheight > newheight - tbh) { - sumheight -= (Frames[i].height) + curfrmtbh + (i > 0 ? sepw : 0); - Frames[i].needhide = TRUE; - drawitems--; - break; - } - } - } - } - - prevframe = -1; - prevframebottomline = 0; - for (j = 0; j < nFramescount; j++) { - //move all alTop frames - i = g_sd[j].realpos; - if ((!Frames[i].needhide) && (!Frames[i].floating) && (Frames[i].visible) && (Frames[i].align == alTop)) { - curfrmtbh = (TitleBarH)* btoint(Frames[i].TitleBar.ShowTitleBar); - Frames[i].wndSize.top = prevframebottomline + (prevframebottomline > 0 ? sepw : 0) + (curfrmtbh); - Frames[i].wndSize.bottom = Frames[i].height + Frames[i].wndSize.top + (Frames[i].UseBorder ? 2 : 0); - Frames[i].prevvisframe = prevframe; - prevframe = i; - prevframebottomline = Frames[i].wndSize.bottom; - topOff = prevframebottomline; - } - } - - if (sumheight < newheight) { - for (j = 0; j < nFramescount; j++) { - //move alClient frame - i = g_sd[j].realpos; - if ((!Frames[i].needhide) && (!Frames[i].floating) && (Frames[i].visible) && (Frames[i].align == alClient)) { - int oldh; - Frames[i].wndSize.top = prevframebottomline + (prevframebottomline > 0 ? sepw : 0) + (tbh); - Frames[i].wndSize.bottom = Frames[i].wndSize.top + newheight - sumheight - tbh - ((prevframebottomline > 0) ? sepw : 0); - clientframe = i; - oldh = Frames[i].height; - Frames[i].height = Frames[i].wndSize.bottom - Frames[i].wndSize.top; - Frames[i].prevvisframe = prevframe; - prevframe = i; - prevframebottomline = Frames[i].wndSize.bottom; - if (prevframebottomline > newheight) { - //prevframebottomline-=Frames[i].height+(tbh+1); - //Frames[i].needhide=TRUE; - } - break; - } - } - } - - //newheight - prevframebottomline = last_bottomtop = newheight; - //prevframe=-1; - for (j = nFramescount - 1; j >= 0; j--) { - //move all alBottom frames - i = g_sd[j].realpos; - if ((Frames[i].visible) && (!Frames[i].floating) && (!Frames[i].needhide) && (Frames[i].align == alBottom)) { - curfrmtbh = (TitleBarH)* btoint(Frames[i].TitleBar.ShowTitleBar); - Frames[i].wndSize.bottom = prevframebottomline - ((prevframebottomline < newheight) ? sepw : 0); - Frames[i].wndSize.top = Frames[i].wndSize.bottom - Frames[i].height - (Frames[i].UseBorder ? 2 : 0); - Frames[i].prevvisframe = prevframe; - prevframe = i; - prevframebottomline = Frames[i].wndSize.top - curfrmtbh; - botOff = prevframebottomline; - last_bottomtop = Frames[i].wndSize.top - curfrmtbh; - } - } - - // correct client frame bottom gap if there is no other top frame. - if (clientframe != -1) { - Frames[clientframe].wndSize.bottom = last_bottomtop - (last_bottomtop < newheight ? sepw : 0); - Frames[clientframe].height = Frames[clientframe].wndSize.bottom - Frames[clientframe].wndSize.top; - } - return 0; -} - -INT_PTR CLUIFramesUpdateFrame(WPARAM wParam, LPARAM lParam) -{ - int pos; - if (FramesSysNotStarted) - return -1; - - if (wParam == -1) { - CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0); - return 0; - } - - if (lParam & FU_FMPOS) - CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 1); - - mir_cslock lck(csFrameHook); - pos = id2pos(wParam); - if (pos < 0 || pos >= nFramescount) - return -1; - - if (lParam & FU_TBREDRAW) - CLUIFramesForceUpdateTB(&Frames[pos]); - if (lParam & FU_FMREDRAW) - CLUIFramesForceUpdateFrame(&Frames[pos]); - return 0; -} - -int dock_prevent_moving = 0; - -int CLUIFramesApplyNewSizes(int mode) -{ - dock_prevent_moving = 0; - - for (int i = 0; i < nFramescount; i++) { - if ((mode == 1 && Frames[i].OwnerWindow != (HWND)-2 && Frames[i].OwnerWindow) || - (mode == 2 && Frames[i].OwnerWindow == (HWND)-2) || (mode == 3)) - if (Frames[i].floating) - CLUIFrameResizeFloatingFrame(i); - else - CLUIFrameMoveResize(&Frames[i]); - } - dock_prevent_moving = 1; - return 0; -} - -RECT old_window_rect = { 0 }, new_window_rect = { 0 }; - -int SizeFramesByWindowRect(RECT *r) -{ - RECT nRect; - DWORD noSize = 0; - - if (FramesSysNotStarted) - return -1; - - TitleBarH = cfg::dat.titleBarHeight; - - mir_cslock lck(csFrameHook); - GapBetweenFrames = cfg::dat.gapBetweenFrames; - - nRect = *r; - - nRect.bottom -= (cfg::dat.statusBarHeight + cfg::dat.bottomOffset); - nRect.right -= cfg::dat.bCRight; - nRect.left = cfg::dat.bCLeft; - nRect.top = cfg::dat.topOffset; - ContactListHeight = nRect.bottom - nRect.top; - - CLUIFramesResize(nRect); - { - int i; - for (i = 0; i < nFramescount; i++) { - int dx; - int dy; - dx = new_window_rect.left - old_window_rect.left; - dy = new_window_rect.top - old_window_rect.top; - if (!Frames[i].floating) { - if (Frames[i].OwnerWindow && Frames[i].OwnerWindow != (HWND)-2) { - /* - if (Frames[i].wndSize.right - Frames[i].wndSize.left == Frames[i].oldWndSize.right - Frames[i].oldWndSize.left && - Frames[i].wndSize.bottom - Frames[i].wndSize.top == Frames[i].oldWndSize.bottom - Frames[i].oldWndSize.top) - noSize = SWP_NOSIZE; - else { - noSize = 0; - CopyRect(&Frames[i].oldWndSize, &Frames[i].wndSize); - }*/ - SetWindowPos(Frames[i].hWnd, NULL, Frames[i].wndSize.left + cfg::dat.bCLeft, Frames[i].wndSize.top + cfg::dat.topOffset, - (Frames[i].wndSize.right - Frames[i].wndSize.left), - (Frames[i].wndSize.bottom - Frames[i].wndSize.top), SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW | SWP_NOCOPYBITS | noSize); - - if (Frames[i].TitleBar.ShowTitleBar) { - SetWindowPos(Frames[i].TitleBar.hwnd, NULL, Frames[i].wndSize.left + cfg::dat.bCLeft, Frames[i].wndSize.top + cfg::dat.topOffset - TitleBarH, - (Frames[i].wndSize.right - Frames[i].wndSize.left), - TitleBarH + (Frames[i].UseBorder ? (!Frames[i].collapsed ? (Frames[i].align == alClient ? 0 : 2) : 1) : 0), SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW | SWP_NOCOPYBITS); - } - } - else { - // set frame position - SetWindowPos(Frames[i].hWnd, NULL, Frames[i].wndSize.left + cfg::dat.bCLeft, Frames[i].wndSize.top + cfg::dat.topOffset, - (Frames[i].wndSize.right - Frames[i].wndSize.left), - (Frames[i].wndSize.bottom - Frames[i].wndSize.top), SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSENDCHANGING | SWP_NOCOPYBITS | SWP_NOREDRAW); - - // set titlebar position - if (Frames[i].TitleBar.ShowTitleBar) { - SetWindowPos(Frames[i].TitleBar.hwnd, NULL, Frames[i].wndSize.left + cfg::dat.bCLeft, Frames[i].wndSize.top + cfg::dat.topOffset - TitleBarH, - (Frames[i].wndSize.right - Frames[i].wndSize.left), - TitleBarH + (Frames[i].UseBorder ? (!Frames[i].collapsed ? (Frames[i].align == alClient ? 0 : 2) : 1) : 0), SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOCOPYBITS | SWP_NOREDRAW); - } - //UpdateWindow(Frames[i].hWnd); - if (Frames[i].TitleBar.ShowTitleBar) - UpdateWindow(Frames[i].TitleBar.hwnd); - } - } - } - - if (GetTickCount() - LastStoreTick > 1000) { - CLUIFramesStoreAllFrames(); - LastStoreTick = GetTickCount(); - } - } - return 0; -} - -int CLUIFramesOnClistResize(WPARAM wParam, LPARAM lParam) -{ - GapBetweenFrames = cfg::dat.gapBetweenFrames; - - if (FramesSysNotStarted || cfg::shutDown) - return -1; - - RECT nRect, rcStatus; - int tick; - { - mir_cslock lck(csFrameHook); - - GetClientRect(pcli->hwndContactList, &nRect); - if (lParam && lParam != 1) { - RECT oldRect; - POINT pt; - RECT * newRect = (RECT *)lParam; - int dl, dt, dr, db; - GetWindowRect((HWND)wParam, &oldRect); - pt.x = nRect.left; - pt.y = nRect.top; - ClientToScreen(pcli->hwndContactList, &pt); - dl = pt.x - oldRect.left; - dt = pt.y - oldRect.top; - dr = (oldRect.right - oldRect.left) - (nRect.right - nRect.left) - dl; - db = (oldRect.bottom - oldRect.top) - (nRect.bottom - nRect.top) - dt; - nRect.left = newRect->left + dl; - nRect.top = newRect->top + dt; - nRect.bottom = newRect->bottom - db; - nRect.right = newRect->right - dr; - } - - rcStatus.top = rcStatus.bottom = 0; - - nRect.bottom -= (cfg::dat.statusBarHeight + cfg::dat.bottomOffset); - nRect.right -= cfg::dat.bCRight; - nRect.left = cfg::dat.bCLeft; - nRect.top = cfg::dat.topOffset; - ContactListHeight = nRect.bottom - nRect.top; - - tick = GetTickCount(); - - CLUIFramesResize(nRect); - CLUIFramesApplyNewSizes(3); - } - - tick = GetTickCount() - tick; - - if (pcli->hwndContactList != 0) - InvalidateRect(pcli->hwndContactList, NULL, TRUE); - if (pcli->hwndContactList != 0) - UpdateWindow(pcli->hwndContactList); - - Sleep(0); - - if (GetTickCount() - LastStoreTick > 2000) { - CLUIFramesStoreAllFrames(); - LastStoreTick = GetTickCount(); - } - return 0; -} - -static HBITMAP hBmpBackground; -static int backgroundBmpUse; -static COLORREF bkColour; -static COLORREF SelBkColour; -boolean AlignCOLLIconToLeft; //will hide frame icon - -int OnFrameTitleBarBackgroundChange() -{ - AlignCOLLIconToLeft = cfg::getByte("FrameTitleBar", "AlignCOLLIconToLeft", 0); - bkColour = cfg::getDword("FrameTitleBar", "BkColour", CLCDEFAULT_BKCOLOUR); - - if (hBmpBackground) { - DeleteObject(hBmpBackground); - hBmpBackground = NULL; - } - if (cfg::getByte("FrameTitleBar", "UseBitmap", CLCDEFAULT_USEBITMAP)) { - ptrT tszBitmapName(db_get_tsa(NULL, "FrameTitleBar", "BkBitmap")); - if (tszBitmapName != NULL) - hBmpBackground = Bitmap_Load(tszBitmapName); - } - backgroundBmpUse = cfg::getWord("FrameTitleBar", "BkBmpUse", CLCDEFAULT_BKBMPUSE); - - CLUIFramesOnClistResize(0, 0); - return 0; -} - -static int DrawTitleBar(HDC dc, RECT rect, int Frameid) -{ - StatusItems_t *item = arStatusItems[ID_EXTBKFRAMETITLE - ID_STATUS_OFFLINE]; - - /* - * no need to redraw anything while shutting down - */ - if (cfg::shutDown) - return 0; - - TitleBarH = cfg::dat.titleBarHeight; - HDC hdcMem = CreateCompatibleDC(dc); - HBITMAP hBmpOsb = CreateCompatibleBitmap(dc, rect.right, rect.bottom); - HBITMAP hoBmp = reinterpret_cast(SelectObject(hdcMem, hBmpOsb)); - - SetBkMode(hdcMem, TRANSPARENT); - - HBRUSH hBack = GetSysColorBrush(COLOR_3DFACE); - HBRUSH hoBrush = reinterpret_cast(SelectObject(hdcMem, hBack)); - { - mir_cslock lck(csFrameHook); - int pos = id2pos(Frameid); - if (pos >= 0 && pos < nFramescount) { - HFONT oFont; - int fHeight, fontTop; - GetClientRect(Frames[pos].TitleBar.hwnd, &Frames[pos].TitleBar.wndSize); - - if (cfg::clcdat) { - oFont = ChangeToFont(hdcMem, cfg::clcdat, FONTID_FRAMETITLE, &fHeight); - } - else { - oFont = reinterpret_cast(SelectObject(hdcMem, GetStockObject(DEFAULT_GUI_FONT))); - fHeight = 10; - } - fontTop = (TitleBarH - fHeight) / 2; - - if (cfg::dat.bWallpaperMode && !Frames[pos].floating) - SkinDrawBg(Frames[pos].TitleBar.hwnd, hdcMem); - - if (!item->IGNORED) { - RECT rc = Frames[pos].TitleBar.wndSize; - rc.top += item->MARGIN_TOP; - rc.bottom -= item->MARGIN_BOTTOM; - rc.left += item->MARGIN_LEFT; - rc.right -= item->MARGIN_RIGHT; - DrawAlpha(hdcMem, &rc, item->COLOR, item->ALPHA, item->COLOR2, item->COLOR2_TRANSPARENT, - item->GRADIENT, item->CORNER, item->BORDERSTYLE, item->imageItem); - SetTextColor(hdcMem, item->TEXTCOLOR); - } - else if (cfg::clcdat) { - FillRect(hdcMem, &rect, hBack); - SetTextColor(hdcMem, cfg::clcdat->fontInfo[FONTID_FRAMETITLE].colour); - } - else { - FillRect(hdcMem, &rect, hBack); - SetTextColor(hdcMem, GetSysColor(COLOR_BTNTEXT)); - } - - if (!AlignCOLLIconToLeft) { - if (Frames[pos].TitleBar.hicon != NULL) { - DrawIconEx(hdcMem, 6 + cfg::dat.bClipBorder, ((TitleBarH >> 1) - 8), Frames[pos].TitleBar.hicon, 16, 16, 0, NULL, DI_NORMAL); - TextOut(hdcMem, 24 + cfg::dat.bClipBorder, fontTop, Frames[pos].TitleBar.tbname, (int)mir_tstrlen(Frames[pos].TitleBar.tbname)); - } - else TextOut(hdcMem, 6 + cfg::dat.bClipBorder, fontTop, Frames[pos].TitleBar.tbname, (int)mir_tstrlen(Frames[pos].TitleBar.tbname)); - } - else TextOut(hdcMem, 18 + cfg::dat.bClipBorder, fontTop, Frames[pos].TitleBar.tbname, (int)mir_tstrlen(Frames[pos].TitleBar.tbname)); - - if (!AlignCOLLIconToLeft) - DrawIconEx(hdcMem, Frames[pos].TitleBar.wndSize.right - 22, ((TitleBarH >> 1) - 8), Frames[pos].collapsed ? Skin_LoadIcon(SKINICON_OTHER_GROUPOPEN) : Skin_LoadIcon(SKINICON_OTHER_GROUPSHUT), 16, 16, 0, NULL, DI_NORMAL); - else - DrawIconEx(hdcMem, 0, ((TitleBarH >> 1) - 8), Frames[pos].collapsed ? Skin_LoadIcon(SKINICON_OTHER_GROUPOPEN) : Skin_LoadIcon(SKINICON_OTHER_GROUPSHUT), 16, 16, 0, NULL, DI_NORMAL); - SelectObject(hdcMem, oFont); - } - } - - BitBlt(dc, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, hdcMem, rect.left, rect.top, SRCCOPY); - SelectObject(hdcMem, hoBmp); - SelectObject(hdcMem, hoBrush); - DeleteDC(hdcMem); - DeleteObject(hBack); - DeleteObject(hBmpOsb); - return 0; -} - -#define MPCF_CONTEXTFRAMEMENU 3 -POINT ptOld; -short nLeft = 0; -short nTop = 0; - -LRESULT CALLBACK CLUIFrameTitleBarProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - RECT rect; - int Frameid, Framemod, direction; - int xpos, ypos, framepos; - - Frameid = GetWindowLongPtr(hwnd, GWLP_USERDATA); - memset(&rect, 0, sizeof(rect)); - - switch (msg) { - case WM_CREATE: - return FALSE; - - case WM_MEASUREITEM: - return Menu_MeasureItem((LPMEASUREITEMSTRUCT)lParam); - - case WM_DRAWITEM: - return Menu_DrawItem((LPDRAWITEMSTRUCT)lParam); - - case WM_ENABLE: - if (hwnd != 0) InvalidateRect(hwnd, NULL, FALSE); - return 0; - case WM_SIZE: - return 0; - - case WM_COMMAND: - if (CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), 0), Frameid)) - break; - - if (HIWORD(wParam) == 0) {//mouse events for self created menu - framepos = id2pos(Frameid); - if (framepos == -1) - break; - - switch (LOWORD(wParam)) { - case frame_menu_lock: - Frames[framepos].Locked = !Frames[framepos].Locked; - break; - case frame_menu_visible: - Frames[framepos].visible = !Frames[framepos].visible; - break; - case frame_menu_showtitlebar: - Frames[framepos].TitleBar.ShowTitleBar = !Frames[framepos].TitleBar.ShowTitleBar; - break; - case frame_menu_floating: - CLUIFrameSetFloat(Frameid, 0); - break; - } - CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0); - } - break; - - case WM_RBUTTONDOWN: - { - HMENU hmenu; - if (ServiceExists(MS_CLIST_MENUBUILDFRAMECONTEXT)) - hmenu = (HMENU)CallService(MS_CLIST_MENUBUILDFRAMECONTEXT, Frameid, 0); - else { - framepos = id2pos(Frameid); - - mir_cslock lck(csFrameHook); - if (framepos == -1) - break; - - hmenu = CreatePopupMenu(); - AppendMenu(hmenu, MF_STRING | MF_DISABLED | MF_GRAYED, 15, Frames[framepos].name); - AppendMenu(hmenu, MF_SEPARATOR, 16, _T("")); - - if (Frames[framepos].Locked) - AppendMenu(hmenu, MF_STRING | MF_CHECKED, frame_menu_lock, TranslateT("Lock frame")); - else - AppendMenu(hmenu, MF_STRING, frame_menu_lock, TranslateT("Lock frame")); - - if (Frames[framepos].visible) - AppendMenu(hmenu, MF_STRING | MF_CHECKED, frame_menu_visible, TranslateT("Visible")); - else - AppendMenu(hmenu, MF_STRING, frame_menu_visible, TranslateT("Visible")); - - if (Frames[framepos].TitleBar.ShowTitleBar) - AppendMenu(hmenu, MF_STRING | MF_CHECKED, frame_menu_showtitlebar, TranslateT("Show title bar")); - else - AppendMenu(hmenu, MF_STRING, frame_menu_showtitlebar, TranslateT("Show title bar")); - - if (Frames[framepos].Skinned) - AppendMenu(hmenu, MF_STRING | MF_CHECKED, frame_menu_skinned, TranslateT("Skinned frame")); - else - AppendMenu(hmenu, MF_STRING, frame_menu_skinned, TranslateT("Skinned frame")); - - if (Frames[framepos].floating) - AppendMenu(hmenu, MF_STRING | MF_CHECKED, frame_menu_floating, TranslateT("Floating")); - else - AppendMenu(hmenu, MF_STRING, frame_menu_floating, TranslateT("Floating")); - } - POINT pt; - GetCursorPos(&pt); - TrackPopupMenu(hmenu, TPM_LEFTALIGN, pt.x, pt.y, 0, hwnd, 0); - DestroyMenu(hmenu); - } - break; - - case WM_LBUTTONDBLCLK: - Framemod = -1; - lbypos = -1; - oldframeheight = -1; - ReleaseCapture(); - CallService(MS_CLIST_FRAMES_UCOLLFRAME, Frameid, 0); - lbypos = -1; - oldframeheight = -1; - ReleaseCapture(); - break; - - case WM_LBUTTONUP: - if (GetCapture() != hwnd) - break; - - curdragbar = -1; - lbypos = -1; - oldframeheight = -1; - ReleaseCapture(); - RedrawWindow(pcli->hwndContactList, NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_UPDATENOW | RDW_ALLCHILDREN); - break; - - case WM_LBUTTONDOWN: - framepos = id2pos(Frameid); - { - mir_cslock lck(csFrameHook); - if (framepos == -1) - break; - - if (Frames[framepos].floating) { - POINT pt; - GetCursorPos(&pt); - Frames[framepos].TitleBar.oldpos = pt; - } - - if ((!(wParam&MK_CONTROL)) && Frames[framepos].Locked && (!(Frames[framepos].floating))) { - if (cfg::getByte("CLUI", "ClientAreaDrag", 0)) { - POINT pt; - GetCursorPos(&pt); - return SendMessage(GetParent(hwnd), WM_SYSCOMMAND, SC_MOVE | HTCAPTION, MAKELPARAM(pt.x, pt.y)); - } - } - if (Frames[framepos].floating) { - RECT rc; - GetCursorPos(&ptOld); - GetWindowRect(hwnd, &rc); - nLeft = (short)rc.left; - nTop = (short)rc.top; - } - } - SetCapture(hwnd); - break; - - case WM_MOUSEMOVE: - { - mir_cslock lck(csFrameHook); - int pos = id2pos(Frameid); - if (pos != -1) { - int oldflags; - char TBcapt[255]; - mir_snprintf(TBcapt, _countof(TBcapt), "%s - h:%d, vis:%d, fl:%d, fl:(%d,%d,%d,%d),or: %d", - Frames[pos].name, Frames[pos].height, Frames[pos].visible, Frames[pos].floating, - Frames[pos].FloatingPos.x, Frames[pos].FloatingPos.y, - Frames[pos].FloatingSize.x, Frames[pos].FloatingSize.y, - Frames[pos].order); - - oldflags = CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_FLAGS, Frames[pos].id), 0); - if (!(oldflags & F_SHOWTBTIP)) - oldflags |= F_SHOWTBTIP; - } - } - if (wParam & MK_LBUTTON) { - RECT rcMiranda; - RECT rcwnd, rcOverlap; - POINT newpt, ofspt, curpt, newpos; - - mir_cslockfull lck(csFrameHook); - - int pos = id2pos(Frameid); - if (Frames[pos].floating) { - GetCursorPos(&curpt); - rcwnd.bottom = curpt.y + 5; - rcwnd.top = curpt.y; - rcwnd.left = curpt.x; - rcwnd.right = curpt.x + 5; - - GetWindowRect(pcli->hwndContactList, &rcMiranda); - if (IsWindowVisible(pcli->hwndContactList) && IntersectRect(&rcOverlap, &rcwnd, &rcMiranda)) { - int id = Frames[pos].id; - - lck.unlock(); - ofspt.x = 0; - ofspt.y = 0; - ClientToScreen(Frames[pos].TitleBar.hwnd, &ofspt); - ofspt.x = curpt.x - ofspt.x; - ofspt.y = curpt.y - ofspt.y; - - CLUIFrameSetFloat(id, 0); - newpt.x = 0; - newpt.y = 0; - ClientToScreen(Frames[pos].TitleBar.hwnd, &newpt); - SetCursorPos(newpt.x + ofspt.x, newpt.y + ofspt.y); - GetCursorPos(&curpt); - - lck.lock(); - Frames[pos].TitleBar.oldpos = curpt; - return 0; - } - } - else { - int id = Frames[pos].id; - - GetCursorPos(&curpt); - rcwnd.bottom = curpt.y + 5; - rcwnd.top = curpt.y; - rcwnd.left = curpt.x; - rcwnd.right = curpt.x + 5; - - GetWindowRect(pcli->hwndContactList, &rcMiranda); - - if (!IntersectRect(&rcOverlap, &rcwnd, &rcMiranda)) { - lck.unlock(); - GetCursorPos(&curpt); - GetWindowRect(Frames[pos].hWnd, &rcwnd); - rcwnd.left = rcwnd.right - rcwnd.left; - rcwnd.top = rcwnd.bottom - rcwnd.top; - newpos.x = curpt.x; - newpos.y = curpt.y; - if (curpt.x >= (rcMiranda.right - 1)) - newpos.x = curpt.x + 5; - if (curpt.x <= (rcMiranda.left + 1)) - newpos.x = curpt.x - (rcwnd.left) - 5; - if (curpt.y >= (rcMiranda.bottom - 1)) - newpos.y = curpt.y + 5; - if (curpt.y <= (rcMiranda.top + 1)) - newpos.y = curpt.y - (rcwnd.top) - 5; - - ofspt.x = 0; - ofspt.y = 0; - GetWindowRect(Frames[pos].TitleBar.hwnd, &rcwnd); - ofspt.x = curpt.x - ofspt.x; - ofspt.y = curpt.y - ofspt.y; - Frames[pos].FloatingPos.x = newpos.x; - Frames[pos].FloatingPos.y = newpos.y; - CLUIFrameSetFloat(id, 0); - - lck.lock(); - newpt.x = 0; - newpt.y = 0; - ClientToScreen(Frames[pos].TitleBar.hwnd, &newpt); - GetWindowRect(Frames[pos].hWnd, &rcwnd); - SetCursorPos(newpt.x + (rcwnd.right - rcwnd.left) / 2, newpt.y + (rcwnd.bottom - rcwnd.top) / 2); - GetCursorPos(&curpt); - Frames[pos].TitleBar.oldpos = curpt; - return 0; - } - } - } - if (wParam & MK_LBUTTON) { - int newh = -1, prevold; - - if (GetCapture() != hwnd) - break; - - POINT pt, pt2; - mir_cslockfull lck(csFrameHook); - int pos = id2pos(Frameid); - - if (Frames[pos].floating) { - RECT wndr; - GetCursorPos(&pt); - if ((Frames[pos].TitleBar.oldpos.x != pt.x) || (Frames[pos].TitleBar.oldpos.y != pt.y)) { - pt2 = pt; - ScreenToClient(hwnd, &pt2); - GetWindowRect(Frames[pos].ContainerWnd, &wndr); - - POINT ptNew = pt; - - nLeft += (short)ptNew.x - ptOld.x; - nTop += (short)ptNew.y - ptOld.y; - - if (!(wParam & MK_CONTROL)) - PositionThumb(&Frames[pos], nLeft, nTop); - else - SetWindowPos(Frames[pos].ContainerWnd, 0, nLeft, nTop, 0, 0, SWP_NOSIZE | SWP_NOZORDER); - - ptOld = ptNew; - - pt.x = nLeft; - pt.y = nTop; - Frames[pos].TitleBar.oldpos = pt; - } - return 0; - } - if (Frames[pos].prevvisframe != -1) { - GetCursorPos(&pt); - - if ((Frames[pos].TitleBar.oldpos.x == pt.x) && (Frames[pos].TitleBar.oldpos.y == pt.y)) - break; - - ypos = rect.top + pt.y; - xpos = rect.left + pt.x; - Framemod = -1; - - if (Frames[pos].align == alBottom) { - direction = -1; - Framemod = pos; - } - else { - direction = 1; - Framemod = Frames[pos].prevvisframe; - } - if (Frames[Framemod].Locked) - break; - if (curdragbar != -1 && curdragbar != pos) - break; - - if (lbypos == -1) { - curdragbar = pos; - lbypos = ypos; - oldframeheight = Frames[Framemod].height; - SetCapture(hwnd); - break; - } - newh = oldframeheight + direction * (ypos - lbypos); - if (newh > 0) { - prevold = Frames[Framemod].height; - Frames[Framemod].height = newh; - if (!CLUIFramesFitInSize()) { - Frames[Framemod].height = prevold; - return TRUE; - } - Frames[Framemod].height = newh; - if (newh > 3) Frames[Framemod].collapsed = TRUE; - - } - Frames[pos].TitleBar.oldpos = pt; - } - lck.unlock(); - - if (newh > 0) - CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0); - break; - } - curdragbar = -1; - lbypos = -1; - oldframeheight = -1; - ReleaseCapture(); - break; - - case WM_NCPAINT: - if (GetWindowLongPtr(hwnd, GWL_STYLE) & WS_BORDER) { - HDC hdc = GetWindowDC(hwnd); - HPEN hPenOld = reinterpret_cast(SelectObject(hdc, g_hPenCLUIFrames)); - RECT rcWindow, rc; - HBRUSH brold; - - CallWindowProc(DefWindowProc, hwnd, msg, wParam, lParam); - GetWindowRect(hwnd, &rcWindow); - rc.left = rc.top = 0; - rc.right = rcWindow.right - rcWindow.left; - rc.bottom = rcWindow.bottom - rcWindow.top; - brold = reinterpret_cast(SelectObject(hdc, GetStockObject(HOLLOW_BRUSH))); - Rectangle(hdc, 0, 0, rcWindow.right - rcWindow.left, rcWindow.bottom - rcWindow.top); - SelectObject(hdc, hPenOld); - SelectObject(hdc, brold); - ReleaseDC(hwnd, hdc); - return 0; - } - break; - - case WM_PRINT: - case WM_PRINTCLIENT: - GetClientRect(hwnd, &rect); - DrawTitleBar((HDC)wParam, rect, Frameid); - - case WM_PAINT: - { - PAINTSTRUCT paintStruct; - HDC paintDC = BeginPaint(hwnd, &paintStruct); - rect = paintStruct.rcPaint; - DrawTitleBar(paintDC, rect, Frameid); - EndPaint(hwnd, &paintStruct); - } - return 0; - - default: - return DefWindowProc(hwnd, msg, wParam, lParam); - } - return TRUE; -} - -int CLUIFrameResizeFloatingFrame(int framepos) -{ - if (!Frames[framepos].floating) - return 0; - if (Frames[framepos].ContainerWnd == 0) - return 0; - - RECT rect; - GetClientRect(Frames[framepos].ContainerWnd, &rect); - - int width = rect.right - rect.left; - int height = rect.bottom - rect.top; - int floatingHeight = cfg::dat.titleBarHeight; - - if (floatingHeight <= 0 || floatingHeight > 50) - floatingHeight = 18; - - Frames[framepos].visible ? ShowWindow(Frames[framepos].ContainerWnd, SW_SHOWNOACTIVATE) : ShowWindow(Frames[framepos].ContainerWnd, SW_HIDE); - - if (Frames[framepos].TitleBar.ShowTitleBar) { - ShowWindow(Frames[framepos].TitleBar.hwnd, SW_SHOWNOACTIVATE); - Frames[framepos].height = height - floatingHeight; - SetWindowPos(Frames[framepos].TitleBar.hwnd, HWND_TOP, 0, 0, width, floatingHeight, SWP_SHOWWINDOW | SWP_DRAWFRAME | SWP_NOACTIVATE); - InvalidateRect(Frames[framepos].TitleBar.hwnd, NULL, FALSE); - SetWindowPos(Frames[framepos].hWnd, HWND_TOP, 0, floatingHeight, width, height - floatingHeight, SWP_SHOWWINDOW | SWP_NOACTIVATE); - - } - else { - Frames[framepos].height = height; - ShowWindow(Frames[framepos].TitleBar.hwnd, SW_HIDE); - SetWindowPos(Frames[framepos].hWnd, HWND_TOP, 0, 0, width, height, SWP_SHOWWINDOW | SWP_NOACTIVATE); - } - - if (Frames[framepos].ContainerWnd != 0) - UpdateWindow(Frames[framepos].ContainerWnd); - GetWindowRect(Frames[framepos].hWnd, &Frames[framepos].wndSize); - - if (Frames[framepos].TitleBar.ShowTitleBar) - RedrawWindow(Frames[framepos].TitleBar.hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_UPDATENOW); - - RedrawWindow(Frames[framepos].hWnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_UPDATENOW); - return 0; -} - -static int CLUIFrameOnMainMenuBuild(WPARAM, LPARAM) -{ - CLUIFramesLoadMainMenu(); - return 0; -} - -LRESULT CALLBACK CLUIFrameContainerWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - int framepos; - RECT rect; - INT_PTR Frameid = GetWindowLongPtr(hwnd, GWLP_USERDATA); - - switch (msg) { - case WM_CREATE: - { - mir_cslockfull lck(csFrameHook); - framepos = id2pos(Frameid); - } - return 0; - - case WM_GETMINMAXINFO: - TitleBarH = cfg::dat.titleBarHeight; - { - mir_cslock lck(csFrameHook); - framepos = id2pos(Frameid); - if (framepos < 0 || framepos >= nFramescount) - break; - - if (!Frames[framepos].minmaxenabled) - break; - - if (Frames[framepos].ContainerWnd == 0) - break; - - if (Frames[framepos].Locked) { - RECT rct; - GetWindowRect(hwnd, &rct); - ((LPMINMAXINFO)lParam)->ptMinTrackSize.x = rct.right - rct.left; - ((LPMINMAXINFO)lParam)->ptMinTrackSize.y = rct.bottom - rct.top; - ((LPMINMAXINFO)lParam)->ptMaxTrackSize.x = rct.right - rct.left; - ((LPMINMAXINFO)lParam)->ptMaxTrackSize.y = rct.bottom - rct.top; - } - - MINMAXINFO minmax; - memset(&minmax, 0, sizeof(minmax)); - if (SendMessage(Frames[framepos].hWnd, WM_GETMINMAXINFO, 0, (LPARAM)&minmax) != 0) - return DefWindowProc(hwnd, msg, wParam, lParam); - - RECT border; - int tbh = TitleBarH * btoint(Frames[framepos].TitleBar.ShowTitleBar); - GetBorderSize(hwnd, &border); - if (minmax.ptMaxTrackSize.x != 0 && minmax.ptMaxTrackSize.y != 0) { - ((LPMINMAXINFO)lParam)->ptMinTrackSize.x = minmax.ptMinTrackSize.x; - ((LPMINMAXINFO)lParam)->ptMinTrackSize.y = minmax.ptMinTrackSize.y; - ((LPMINMAXINFO)lParam)->ptMaxTrackSize.x = minmax.ptMaxTrackSize.x + border.left + border.right; - ((LPMINMAXINFO)lParam)->ptMaxTrackSize.y = minmax.ptMaxTrackSize.y + tbh + border.top + border.bottom; - } - } - - case WM_MOVE: - { - mir_cslock lck(csFrameHook); - framepos = id2pos(Frameid); - if (framepos < 0 || framepos >= nFramescount) - break; - - if (Frames[framepos].ContainerWnd == 0) - return 0; - - GetWindowRect(Frames[framepos].ContainerWnd, &rect); - Frames[framepos].FloatingPos.x = rect.left; - Frames[framepos].FloatingPos.y = rect.top; - Frames[framepos].FloatingSize.x = rect.right - rect.left; - Frames[framepos].FloatingSize.y = rect.bottom - rect.top; - CLUIFramesStoreFrameSettings(framepos); - } - return 0; - - case WM_SIZE: - { - mir_cslock lck(csFrameHook); - framepos = id2pos(Frameid); - if (framepos < 0 || framepos >= nFramescount) - break; - - if (Frames[framepos].ContainerWnd == 0) - return 0; - - CLUIFrameResizeFloatingFrame(framepos); - - RECT rect; - GetWindowRect(Frames[framepos].ContainerWnd, &rect); - Frames[framepos].FloatingPos.x = rect.left; - Frames[framepos].FloatingPos.y = rect.top; - Frames[framepos].FloatingSize.x = rect.right - rect.left; - Frames[framepos].FloatingSize.y = rect.bottom - rect.top; - - CLUIFramesStoreFrameSettings(framepos); - } - return 0; - - case WM_CLOSE: - DestroyWindow(hwnd); - break; - - case WM_DESTROY: - return 0; - } - return DefWindowProc(hwnd, msg, wParam, lParam); -} - -static HWND CreateContainerWindow(HWND parent, int x, int y, int width, int height) -{ - return(CreateWindowA("FramesContainer", "aaaa", WS_POPUP | WS_THICKFRAME, x, y, width, height, parent, 0, g_hInst, 0)); -} - -INT_PTR CLUIFrameSetFloat(WPARAM wParam, LPARAM lParam) -{ - HWND hwndtmp, hwndtooltiptmp; - { - mir_cslock lck(csFrameHook); - wParam = id2pos(wParam); - if ((int)wParam >= 0 && (int)wParam < nFramescount) { - if (Frames[wParam].floating) { - SetParent(Frames[wParam].hWnd, pcli->hwndContactList); - SetParent(Frames[wParam].TitleBar.hwnd, pcli->hwndContactList); - Frames[wParam].floating = FALSE; - DestroyWindow(Frames[wParam].ContainerWnd); - Frames[wParam].ContainerWnd = 0; - } - else { - RECT recttb, rectw, border; - int temp; - int neww, newh; - - Frames[wParam].oldstyles = GetWindowLongPtr(Frames[wParam].hWnd, GWL_STYLE); - Frames[wParam].TitleBar.oldstyles = GetWindowLongPtr(Frames[wParam].TitleBar.hwnd, GWL_STYLE); - bool locked = Frames[wParam].Locked; - Frames[wParam].Locked = FALSE; - Frames[wParam].minmaxenabled = FALSE; - - GetWindowRect(Frames[wParam].hWnd, &rectw); - GetWindowRect(Frames[wParam].TitleBar.hwnd, &recttb); - if (!Frames[wParam].TitleBar.ShowTitleBar) - recttb.top = recttb.bottom = recttb.left = recttb.right = 0; - - Frames[wParam].ContainerWnd = CreateContainerWindow(pcli->hwndContactList, Frames[wParam].FloatingPos.x, Frames[wParam].FloatingPos.y, 10, 10); - - SetParent(Frames[wParam].hWnd, Frames[wParam].ContainerWnd); - SetParent(Frames[wParam].TitleBar.hwnd, Frames[wParam].ContainerWnd); - - GetBorderSize(Frames[wParam].ContainerWnd, &border); - - SetWindowLongPtr(Frames[wParam].ContainerWnd, GWLP_USERDATA, Frames[wParam].id); - if ((lParam == 1)) { - if ((Frames[wParam].FloatingPos.x != 0) && (Frames[wParam].FloatingPos.y != 0)) { - if (Frames[wParam].FloatingPos.x < 20) - Frames[wParam].FloatingPos.x = 40; - - if (Frames[wParam].FloatingPos.y < 20) - Frames[wParam].FloatingPos.y = 40; - - SetWindowPos(Frames[wParam].ContainerWnd, HWND_TOPMOST, Frames[wParam].FloatingPos.x, Frames[wParam].FloatingPos.y, Frames[wParam].FloatingSize.x, Frames[wParam].FloatingSize.y, SWP_HIDEWINDOW); - } - else SetWindowPos(Frames[wParam].ContainerWnd, HWND_TOPMOST, 120, 120, 140, 140, SWP_HIDEWINDOW); - } - else { - neww = rectw.right - rectw.left + border.left + border.right; - newh = (rectw.bottom - rectw.top) + (recttb.bottom - recttb.top) + border.top + border.bottom; - if (neww < 20) - neww = 40; - - if (newh < 20) - newh = 40; - - if (Frames[wParam].FloatingPos.x < 20) - Frames[wParam].FloatingPos.x = 40; - - if (Frames[wParam].FloatingPos.y < 20) - Frames[wParam].FloatingPos.y = 40; - - SetWindowPos(Frames[wParam].ContainerWnd, HWND_TOPMOST, Frames[wParam].FloatingPos.x, Frames[wParam].FloatingPos.y, neww, newh, SWP_HIDEWINDOW); - } - SetWindowText(Frames[wParam].ContainerWnd, Frames[wParam].TitleBar.tbname); - temp = GetWindowLongPtr(Frames[wParam].ContainerWnd, GWL_EXSTYLE); - temp |= WS_EX_TOOLWINDOW | WS_EX_TOPMOST; - SetWindowLongPtr(Frames[wParam].ContainerWnd, GWL_EXSTYLE, temp); - Frames[wParam].floating = TRUE; - Frames[wParam].Locked = locked; - } - } - - CLUIFramesStoreFrameSettings(wParam); - Frames[wParam].minmaxenabled = TRUE; - hwndtooltiptmp = Frames[wParam].TitleBar.hwndTip; - - hwndtmp = Frames[wParam].ContainerWnd; - } - - CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0); - SendMessage(hwndtmp, WM_SIZE, 0, 0); - SetWindowPos(hwndtooltiptmp, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); - return 0; -} - -TCHAR g_ptszEventName[100]; - -static int CLUIFrameOnModulesLoad(WPARAM, LPARAM) -{ - mir_sntprintf(g_ptszEventName, _countof(g_ptszEventName), _T("mf_update_evt_%d"), GetCurrentThreadId()); - g_hEventThread = CreateEvent(NULL, TRUE, FALSE, g_ptszEventName); - hThreadMFUpdate = mir_forkthread(MF_UpdateThread, NULL); - SetThreadPriority(hThreadMFUpdate, THREAD_PRIORITY_IDLE); - CLUIFramesLoadMainMenu(); - CLUIFramesCreateMenuForFrame(-1, NULL, 000010000, false); - return 0; -} - -static int CLUIFrameOnModulesUnload(WPARAM, LPARAM) -{ - mf_updatethread_running = FALSE; - - SetThreadPriority(hThreadMFUpdate, THREAD_PRIORITY_NORMAL); - SetEvent(g_hEventThread); - WaitForSingleObject(hThreadMFUpdate, 2000); - CloseHandle(g_hEventThread); - - Menu_RemoveItem(cont.MIVisible); - Menu_RemoveItem(cont.MITitle); - Menu_RemoveItem(cont.MITBVisible); - Menu_RemoveItem(cont.MILock); - Menu_RemoveItem(cont.MIColl); - Menu_RemoveItem(cont.MIFloating); - Menu_RemoveItem(cont.MIAlignRoot); - Menu_RemoveItem(cont.MIAlignTop); - Menu_RemoveItem(cont.MIAlignClient); - Menu_RemoveItem(cont.MIAlignBottom); - Menu_RemoveItem(cont.MIBorder); - return 0; -} - -/* - * wparam=hIcon - * return hImage on success,-1 on failure - */ - -void RegisterCLUIFrameClasses() -{ - WNDCLASS wndclass = {}; - wndclass.style = CS_DBLCLKS; - wndclass.lpfnWndProc = CLUIFrameTitleBarProc; - wndclass.hInstance = g_hInst; - wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); - wndclass.lpszClassName = CLUIFrameTitleBarClassName; - RegisterClass(&wndclass); - - WNDCLASS cntclass = {}; - cntclass.style = CS_DBLCLKS | CS_DROPSHADOW; - cntclass.lpfnWndProc = CLUIFrameContainerWndProc; - cntclass.hInstance = g_hInst; - cntclass.hCursor = LoadCursor(NULL, IDC_ARROW); - cntclass.lpszClassName = _T("FramesContainer"); - RegisterClass(&cntclass); -} - -int LoadCLUIFramesModule(void) -{ - GapBetweenFrames = cfg::dat.gapBetweenFrames; - - nFramescount = 0; - - HookEvent(ME_SYSTEM_MODULESLOADED, CLUIFrameOnModulesLoad); - HookEvent(ME_CLIST_PREBUILDFRAMEMENU, CLUIFramesModifyContextMenuForFrame); - HookEvent(ME_CLIST_PREBUILDMAINMENU, CLUIFrameOnMainMenuBuild); - HookEvent(ME_SYSTEM_PRESHUTDOWN, CLUIFrameOnModulesUnload); - - CreateServiceFunction(MS_CLIST_FRAMES_ADDFRAME, CLUIFramesAddFrame); - CreateServiceFunction(MS_CLIST_FRAMES_REMOVEFRAME, CLUIFramesRemoveFrame); - - CreateServiceFunction(MS_CLIST_FRAMES_SETFRAMEOPTIONS, CLUIFramesSetFrameOptions); - CreateServiceFunction(MS_CLIST_FRAMES_GETFRAMEOPTIONS, CLUIFramesGetFrameOptions); - CreateServiceFunction(MS_CLIST_FRAMES_UPDATEFRAME, CLUIFramesUpdateFrame); - - CreateServiceFunction(MS_CLIST_FRAMES_SHFRAMETITLEBAR, CLUIFramesShowHideFrameTitleBar); - CreateServiceFunction(MS_CLIST_FRAMES_SHOWALLFRAMESTB, CLUIFramesShowAllTitleBars); - CreateServiceFunction(MS_CLIST_FRAMES_HIDEALLFRAMESTB, CLUIFramesHideAllTitleBars); - CreateServiceFunction(MS_CLIST_FRAMES_SHFRAME, CLUIFramesShowHideFrame); - CreateServiceFunction(MS_CLIST_FRAMES_SHOWALLFRAMES, CLUIFramesShowAll); - - CreateServiceFunction(MS_CLIST_FRAMES_ULFRAME, CLUIFramesLockUnlockFrame); - CreateServiceFunction(MS_CLIST_FRAMES_UCOLLFRAME, CLUIFramesCollapseUnCollapseFrame); - CreateServiceFunction(MS_CLIST_FRAMES_SETUNBORDER, CLUIFramesSetUnSetBorder); - CreateServiceFunction(MS_CLIST_FRAMES_SETSKINNED, CLUIFramesSetUnSetSkinned); - - CreateServiceFunction(CLUIFRAMESSETALIGN, CLUIFramesSetAlign); - CreateServiceFunction(CLUIFRAMESMOVEDOWN, CLUIFramesMoveDown); - CreateServiceFunction(CLUIFRAMESMOVEUP, CLUIFramesMoveUp); - - CreateServiceFunction(CLUIFRAMESSETALIGNALTOP, CLUIFramesSetAlignalTop); - CreateServiceFunction(CLUIFRAMESSETALIGNALCLIENT, CLUIFramesSetAlignalClient); - CreateServiceFunction(CLUIFRAMESSETALIGNALBOTTOM, CLUIFramesSetAlignalBottom); - - CreateServiceFunction("Set_Floating", CLUIFrameSetFloat); - hWndExplorerToolBar = FindWindowExA(0, 0, "Shell_TrayWnd", NULL); - OnFrameTitleBarBackgroundChange(); - - FramesSysNotStarted = FALSE; - g_hPenCLUIFrames = CreatePen(PS_SOLID, 1, cfg::getDword("CLUI", "clr_frameborder", GetSysColor(COLOR_3DDKSHADOW))); - return 0; -} - -void LoadExtraIconModule() -{ - hStatusBarShowToolTipEvent = CreateHookableEvent(ME_CLIST_FRAMES_SB_SHOW_TOOLTIP); - hStatusBarHideToolTipEvent = CreateHookableEvent(ME_CLIST_FRAMES_SB_HIDE_TOOLTIP); -} - -int UnLoadCLUIFramesModule(void) -{ - CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0); - CLUIFramesStoreAllFrames(); - DeleteObject(g_hPenCLUIFrames); - - mir_cslock lck(csFrameHook); - FramesSysNotStarted = TRUE; - for (int i = 0; i < nFramescount; i++) { - DestroyWindow(Frames[i].hWnd); - Frames[i].hWnd = (HWND)-1; - DestroyWindow(Frames[i].TitleBar.hwnd); - Frames[i].TitleBar.hwnd = (HWND)-1; - DestroyWindow(Frames[i].ContainerWnd); - Frames[i].ContainerWnd = (HWND)-1; - DestroyMenu(Frames[i].TitleBar.hmenu); - - if (Frames[i].name != NULL) - mir_free(Frames[i].name); - if (Frames[i].TitleBar.tbname != NULL) - mir_free(Frames[i].TitleBar.tbname); - } - free(Frames); - Frames = NULL; - nFramescount = 0; - UnregisterClass(CLUIFrameTitleBarClassName, g_hInst); - return 0; -} diff --git a/plugins/Clist_nicer/src/CLUIFrames/cluiframes.h b/plugins/Clist_nicer/src/CLUIFrames/cluiframes.h deleted file mode 100644 index 4fef8cec0f..0000000000 --- a/plugins/Clist_nicer/src/CLUIFrames/cluiframes.h +++ /dev/null @@ -1,127 +0,0 @@ -/* -Miranda ICQ: the free icq client for MS Windows -Copyright (C) 2000-2 Richard Hughes, Roland Rabien & Tristan Van de Vreede - -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. -*/ - -#pragma once - -#ifndef _CLUIFRAMES_H_ -#define _CLUIFRAMES_H_ - -int LoadCLUIFramesModule(void); -int UnLoadCLUIFramesModule(void); -int CLUIFramesGetMinHeight(); -int CLUIFramesOnClistResize(WPARAM wParam, LPARAM lParam); -int SizeFramesByWindowRect(RECT *r); -int CLUIFramesResizeFrames(RECT *rc); - -typedef struct tagProtocolData { - char *RealName; - int protopos; - boolean show; -} ProtocolData; - -typedef struct -{ - int order; - int realpos; -}SortData; - - - - -//============ -#define CLUIFRAMESSETALIGN "CLUIFramesSetAlign" - -#define CLUIFRAMESSETALIGNALTOP "CLUIFramesSetAlignalTop" -#define CLUIFRAMESSETALIGNALCLIENT "CLUIFramesSetAlignalClient" -#define CLUIFRAMESSETALIGNALBOTTOM "CLUIFramesSetAlignalBottom" -#define CLUIFRAMESMOVEUP "CLUIFramesMoveUp" -#define CLUIFRAMESMOVEDOWN "CLUIFramesMoveDown" - -struct FrameMenuHandles -{ - HGENMENU MainMenuItem; - HGENMENU MIVisible, MITitle, MITBVisible, MILock, MIColl, MIFloating, MIAlignRoot; - HGENMENU MIAlignTop, MIAlignClient, MIAlignBottom; - HGENMENU MIBorder, MISkinned; -}; - -struct FrameTitleBar -{ - HWND hwnd; - HWND TitleBarbutt; - HWND hwndTip; - - LPTSTR tbname; - LPTSTR tooltip; - - HMENU hmenu; - HICON hicon; - - bool ShowTitleBar; - bool ShowTitleBarTip; - int oldstyles; - POINT oldpos; - RECT wndSize; -}; - -struct DockOpt -{ - HWND hwndLeft; - HWND hwndRight; -}; - -struct FRAMEWND -{ - int id; - HWND hWnd; - RECT wndSize; - LPTSTR name; - int align; - int height; - int dwFlags; - bool Locked; - bool visible; - bool needhide; - bool collapsed; - bool floating; - bool minmaxenabled; - bool UseBorder; - int prevvisframe; - int HeightWhenCollapsed; - FrameTitleBar TitleBar; - FrameMenuHandles MenuHandles; - int oldstyles; - HWND ContainerWnd; - POINT FloatingPos; - POINT FloatingSize; - int order; - DockOpt dockOpt; - HWND OwnerWindow; - bool Skinned; - RECT oldWndSize; - WNDPROC wndProc; -}; - -#define OFFSET_PROTOPOS 200 -#define OFFSET_VISIBLE 400 - -#define CLUIFrameTitleBarClassName _T("CLUIFrameTitleBar") -#define CLUIFrameModule "CLUIFrames" - -#endif diff --git a/plugins/Clist_nicer/src/CLUIFrames/groupmenu.cpp b/plugins/Clist_nicer/src/CLUIFrames/groupmenu.cpp deleted file mode 100644 index c68a3c16d1..0000000000 --- a/plugins/Clist_nicer/src/CLUIFrames/groupmenu.cpp +++ /dev/null @@ -1,288 +0,0 @@ -/* - -Miranda NG: the free IM client for Microsoft* Windows* - -Copyright (ñ) 2012-15 Miranda NG project (http://miranda-ng.org), -Copyright (c) 2000-08 Miranda ICQ/IM 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 - -///////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////// Group MENU ////////////////////////////// - -HGENMENU hGroupMainMenuItemProxy; -HGENMENU hHideShowMainMenuItem; -HGENMENU hGroupStatusMenuItemProxy; -HGENMENU hAppearanceMenuItemProxy; -HGENMENU hEventAreaMenuItemProxy; - -static HMENU hMenuOldContext; - -HGENMENU hHideOfflineUsersMenuItem; -HGENMENU hHideOfflineUsersOutHereMenuItem; -HGENMENU hHideEmptyGroupsMenuItem; -HGENMENU hDisableGroupsMenuItem; -HGENMENU hNewGroupMenuItem; -HGENMENU hNewSubGroupMenuItem; - -void InitSubGroupMenus(void); - -INT_PTR GroupMenu_OnAddService(WPARAM wParam, LPARAM lParam) -{ - MENUITEMINFO *mii = (MENUITEMINFO*)wParam; - if (mii == NULL) - return 0; - - if (hHideShowMainMenuItem == (HANDLE)lParam) { - mii->fMask |= MIIM_STATE; - mii->fState |= MFS_DEFAULT; - - } - if (hGroupMainMenuItemProxy == (HANDLE)lParam) { - mii->fMask |= MIIM_SUBMENU; - mii->hSubMenu = Menu_GetMainMenu(); - } - - if (hGroupStatusMenuItemProxy == (HANDLE)lParam) { - mii->fMask |= MIIM_SUBMENU; - mii->hSubMenu = Menu_GetStatusMenu(); - } - if (hAppearanceMenuItemProxy == (HANDLE)lParam) { - hMenuOldContext = GetSubMenu(LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_CONTEXT)), 3); - TranslateMenu(hMenuOldContext); - - CheckMenuItem(hMenuOldContext, POPUP_FRAME, MF_BYCOMMAND | (cfg::dat.dwFlags & CLUI_FRAME_CLISTSUNKEN ? MF_CHECKED : MF_UNCHECKED)); - CheckMenuItem(hMenuOldContext, POPUP_BUTTONS, MF_BYCOMMAND | (cfg::dat.dwFlags & CLUI_FRAME_SHOWBOTTOMBUTTONS ? MF_CHECKED : MF_UNCHECKED)); - CheckMenuItem(hMenuOldContext, POPUP_SHOWMETAICONS, MF_BYCOMMAND | (cfg::dat.dwFlags & CLUI_USEMETAICONS ? MF_CHECKED : MF_UNCHECKED)); - CheckMenuItem(hMenuOldContext, POPUP_SHOWSTATUSICONS, MF_BYCOMMAND | (cfg::dat.dwFlags & CLUI_FRAME_STATUSICONS ? MF_CHECKED : MF_UNCHECKED)); - - mii->fMask |= MIIM_SUBMENU; - mii->hSubMenu = hMenuOldContext; - } - return TRUE; -} - -INT_PTR HideGroupsHelper(WPARAM, LPARAM) -{ - int newVal = !(GetWindowLongPtr(pcli->hwndContactTree, GWL_STYLE) & CLS_HIDEEMPTYGROUPS); - cfg::writeByte("CList", "HideEmptyGroups", (BYTE)newVal); - SendMessage(pcli->hwndContactTree, CLM_SETHIDEEMPTYGROUPS, newVal, 0); - return 0; -} - -INT_PTR UseGroupsHelper(WPARAM, LPARAM) -{ - int newVal = !(GetWindowLongPtr(pcli->hwndContactTree, GWL_STYLE) & CLS_USEGROUPS); - cfg::writeByte("CList", "UseGroups", (BYTE)newVal); - SendMessage(pcli->hwndContactTree, CLM_SETUSEGROUPS, newVal,0); - return 0; -} - -INT_PTR HideOfflineRootHelper(WPARAM, LPARAM) -{ - SendMessage(pcli->hwndContactTree, CLM_SETHIDEOFFLINEROOT, !SendMessage(pcli->hwndContactTree, CLM_GETHIDEOFFLINEROOT, 0, 0), 0); - return 0; -} - -static int OnBuildGroupMenu(WPARAM, LPARAM) -{ - bool bEnabled = 0 != cfg::getByte("CList", "HideOffline", SETTING_HIDEOFFLINE_DEFAULT); - Menu_EnableItem(hHideOfflineUsersMenuItem, bEnabled); - - bEnabled = 0 != SendMessage(pcli->hwndContactTree, CLM_GETHIDEOFFLINEROOT, 0, 0); - Menu_EnableItem(hHideOfflineUsersOutHereMenuItem, bEnabled); - - bEnabled = 0 != (GetWindowLongPtr(pcli->hwndContactTree, GWL_STYLE) & CLS_HIDEEMPTYGROUPS); - Menu_EnableItem(hHideEmptyGroupsMenuItem, bEnabled); - - bEnabled = 0 != (GetWindowLongPtr(pcli->hwndContactTree, GWL_STYLE) & CLS_USEGROUPS); - Menu_EnableItem(hDisableGroupsMenuItem, bEnabled); - - Menu_EnableItem(hGroupMainMenuItemProxy, bEnabled); - Menu_EnableItem(hAppearanceMenuItemProxy, bEnabled); - return 0; -} - -IconItemT iconItem[] = { - { LPGENT("New group"), "new_group", IDI_ADDGROUP }, - { LPGENT("Contact list"), "clist", IDI_CLIST } -}; - -void InitIconLibMenuIcons(void) -{ - Icon_RegisterT(g_hInst, LPGENT("Contact list"), iconItem, _countof(iconItem)); -} - -void InitGroupMenus(void) -{ - CreateServiceFunction("CLISTMENUSGroup/GroupMenuOnAddService", GroupMenu_OnAddService); - CreateServiceFunction("CLISTMENUSGroup/HideGroupsHelper", HideGroupsHelper); - CreateServiceFunction("CLISTMENUSGroup/UseGroupsHelper", UseGroupsHelper); - CreateServiceFunction("CLISTMENUSGroup/HideOfflineRootHelper", HideOfflineRootHelper); - - HookEvent(ME_CLIST_PREBUILDGROUPMENU, OnBuildGroupMenu); - - InitSubGroupMenus(); - - // add exit command to menu - GroupMenuParam gmp; - - CMenuItem mi; - mi.position = 1900000; - mi.pszService = "CloseAction"; - mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_EXIT); - mi.name.a = LPGEN("E&xit"); - Menu_AddGroupMenuItem(&mi); - - mi.position = 500; - mi.pszService = MS_CLIST_SHOWHIDE; - mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_SHOWHIDE); - mi.name.a = LPGEN("&Hide/show"); - hHideShowMainMenuItem = Menu_AddGroupMenuItem(&mi); - - mi.position = 200000; - mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_FINDUSER); - mi.pszService = "FindAdd/FindAddCommand"; - mi.name.a = LPGEN("&Find/add contacts..."); - Menu_AddGroupMenuItem(&mi); - - mi.position = 300000; - mi.pszService = ""; - mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_MAINMENU); - mi.name.a = LPGEN("&Main menu"); - hGroupMainMenuItemProxy = Menu_AddGroupMenuItem(&mi); - - mi.position = 300100; - mi.pszService = ""; - mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_STATUS); - mi.name.a = LPGEN("&Status"); - hGroupStatusMenuItemProxy = Menu_AddGroupMenuItem(&mi); - - mi.position = 390100; - mi.hIcolibItem = iconItem[1].hIcolib; - mi.name.a = LPGEN("Appearance"); - hAppearanceMenuItemProxy = Menu_AddGroupMenuItem(&mi); - - mi.position = 400000; - mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_OPTIONS); - mi.pszService = "Options/OptionsCommand"; - mi.name.a = LPGEN("&Options..."); - Menu_AddGroupMenuItem(&mi); - - mi.position = 500000; - mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_MIRANDA); - mi.pszService = "CLN/About"; - mi.name.a = LPGEN("&About the contact list..."); - Menu_AddGroupMenuItem(&mi); - - mi.flags = 0; - mi.position = 100000; - mi.hIcolibItem = iconItem[0].hIcolib; - mi.pszService = "CLISTMENUSSubGroup/GroupMenuExecProxy"; - mi.name.a = LPGEN("&New group"); - hNewGroupMenuItem = Menu_AddGroupMenuItem(&mi, &gmp); - - mi.position = 100001; - mi.hIcolibItem = NULL; - mi.hIcolibItem = NULL; - mi.pszService = MS_CLIST_SETHIDEOFFLINE; - mi.name.a = LPGEN("&Hide offline users"); - gmp.wParam = -1; - hHideOfflineUsersMenuItem = Menu_AddGroupMenuItem(&mi, &gmp); - - mi.position = 100002; - mi.pszService = "CLISTMENUSGroup/HideOfflineRootHelper"; - mi.name.a = LPGEN("Hide &offline users out here"); - hHideOfflineUsersOutHereMenuItem = Menu_AddGroupMenuItem(&mi); - - mi.position = 100003; - mi.pszService = "CLISTMENUSGroup/HideGroupsHelper"; - mi.name.a = LPGEN("Hide &empty groups"); - hHideEmptyGroupsMenuItem = Menu_AddGroupMenuItem(&mi); - - mi.position = 100004; - mi.pszService = "CLISTMENUSGroup/UseGroupsHelper"; - mi.name.a = LPGEN("Disable &groups"); - hDisableGroupsMenuItem = Menu_AddGroupMenuItem(&mi); -} - -//////////////////////////////SubGroup MENU///////////////////////// -HANDLE hSubGroupMainMenuItemProxy; -HANDLE hSubGroupStatusMenuItemProxy; -HANDLE hPreBuildSubGroupMenuEvent; -HGENMENU hHideOfflineUsersHereMenuItem; - -static int OnBuildSubGroupMenu(WPARAM wParam, LPARAM) -{ - ClcGroup *group = (ClcGroup*)wParam; - if (group != 0) // contact->group - Menu_ModifyItem(hHideOfflineUsersHereMenuItem, NULL, INVALID_HANDLE_VALUE, group->hideOffline ? CMIF_CHECKED : 0); - return 0; -} - -// wparam menu handle to pass to clc.c -INT_PTR GroupMenuExecProxy(WPARAM wParam, LPARAM) -{ - SendMessage(pcli->hwndContactTree, WM_COMMAND, wParam, 0); - return 0; -} - -void InitSubGroupMenus(void) -{ - CreateServiceFunction("CLISTMENUSSubGroup/GroupMenuExecProxy", GroupMenuExecProxy); - - HookEvent(ME_CLIST_PREBUILDSUBGROUPMENU, OnBuildSubGroupMenu); - - // add exit command to menu - GroupMenuParam gmp = {}; - - CMenuItem mi; - mi.position = 1000; - mi.hIcolibItem = iconItem[0].hIcolib; - mi.pszService = "CLISTMENUSSubGroup/GroupMenuExecProxy"; - mi.name.a = LPGEN("&New subgroup"); - gmp.wParam = POPUP_NEWSUBGROUP; - hNewSubGroupMenuItem = Menu_AddSubGroupMenuItem(&mi, &gmp); - - mi.position = 1001; - mi.hIcolibItem = NULL; - mi.hIcolibItem = NULL; - mi.pszService = "CLISTMENUSSubGroup/GroupMenuExecProxy"; - mi.name.a = LPGEN("&Hide offline users in here"); - gmp.wParam = POPUP_GROUPHIDEOFFLINE; - hHideOfflineUsersHereMenuItem = (HGENMENU)Menu_AddSubGroupMenuItem(&mi, &gmp); - - memset(&mi, 0, sizeof(mi)); - mi.position = 900001; - mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_RENAME); - mi.pszService = "CLISTMENUSSubGroup/GroupMenuExecProxy"; - mi.name.a = LPGEN("&Rename group"); - gmp.wParam = POPUP_RENAMEGROUP; - Menu_AddSubGroupMenuItem(&mi, &gmp); - - mi.position = 900002; - mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_DELETE); - mi.pszService = "CLISTMENUSSubGroup/GroupMenuExecProxy"; - mi.name.a = LPGEN("&Delete group"); - gmp.wParam = POPUP_DELETEGROUP; - Menu_AddSubGroupMenuItem(&mi, &gmp); -} - -//////////////////////////////END SubGroup MENU///////////////////////// diff --git a/plugins/Clist_nicer/src/Coolsb/coolsb_internal.h b/plugins/Clist_nicer/src/Coolsb/coolsb_internal.h deleted file mode 100644 index 64249c355c..0000000000 --- a/plugins/Clist_nicer/src/Coolsb/coolsb_internal.h +++ /dev/null @@ -1,94 +0,0 @@ -#ifndef _COOLSB_INTERNAL_INCLUDED -#define _COOLSB_INTERNAL_INCLUDED - -#ifdef __cplusplus -extern "C"{ -#endif - -#include - -// -// SCROLLBAR datatype. There are two of these structures per window -// -typedef struct -{ - UINT fScrollFlags; //flags - BOOL fScrollVisible; //if this scrollbar visible? - SCROLLINFO scrollInfo; //positional data (range, position, page size etc) - - int nArrowLength; //perpendicular size (height of a horizontal, width of a vertical) - int nArrowWidth; //parallel size (width of horz, height of vert) - - //data for inserted buttons - SCROLLBUT sbButtons[MAX_COOLSB_BUTS]; - int nButtons; - int nButSizeBefore; //size to the left / above the bar - int nButSizeAfter; //size to the right / below the bar - - BOOL fButVisibleBefore; //if the buttons to the left are visible - BOOL fButVisibleAfter; //if the buttons to the right are visible - - int nBarType; //SB_HORZ / SB_VERT - - UINT fFlatScrollbar; //do we display flat scrollbars? - int nMinThumbSize; - -} SCROLLBAR; - -// -// Container structure for a cool scrollbar window. -// -typedef struct -{ - UINT bars; //which of the scrollbars do we handle? SB_VERT / SB_HORZ / SB_BOTH - - SCROLLBAR sbarHorz; //one scrollbar structure each for - SCROLLBAR sbarVert; //the horizontal and vertical scrollbars - - BOOL fThumbTracking; // are we currently thumb-tracking?? - BOOL fLeftScrollbar; // support the WS_EX_LEFTSCROLLBAR style - - HWND hwndToolTip; // tooltip support!!! - - //size of the window borders - int cxLeftEdge, cxRightEdge; - int cyTopEdge, cyBottomEdge; - - // To prevent calling original WindowProc in response - // to our own temporary style change (fixes TreeView problem) - BOOL bPreventStyleChange; - -} SCROLLWND; - - -// -// PRIVATE INTERNAL FUNCTIONS -// -SCROLLWND *GetScrollWndFromHwnd(HWND hwnd); -#define InvertCOLORREF(col) ((~col) & 0x00ffffff) - -#define COOLSB_TIMERID1 65533 //initial timer -#define COOLSB_TIMERID2 65534 //scroll message timer -#define COOLSB_TIMERID3 -14 //mouse hover timer -#define COOLSB_TIMERINTERVAL1 300 -#define COOLSB_TIMERINTERVAL2 55 -#define COOLSB_TIMERINTERVAL3 20 //mouse hover time - - -// -// direction: 0 - same axis as scrollbar (i.e. width of a horizontal bar) -// 1 - perpendicular dimesion (i.e. height of a horizontal bar) -// -#define SM_CXVERTSB 1 -#define SM_CYVERTSB 0 -#define SM_CXHORZSB 0 -#define SM_CYHORZSB 1 -#define SM_SCROLL_WIDTH 1 -#define SM_SCROLL_LENGTH 0 - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/plugins/Clist_nicer/src/Coolsb/coolsblib.cpp b/plugins/Clist_nicer/src/Coolsb/coolsblib.cpp deleted file mode 100644 index d2c0e15e54..0000000000 --- a/plugins/Clist_nicer/src/Coolsb/coolsblib.cpp +++ /dev/null @@ -1,917 +0,0 @@ -/* - - Cool Scrollbar Library Version 1.2 - - Module: coolsblib.c - Copyright (c) J Brown 2001 - - This code is freeware, however, you may not publish - this code elsewhere or charge any money for it. This code - is supplied as-is. I make no guarantees about the suitability - of this code - use at your own risk. - - It would be nice if you credited me, in the event - that you use this code in a product. - - VERSION HISTORY: - - V1.2: TreeView problem fixed by Diego Tartara - Small problem in thumbsize calculation also fixed (thanks Diego!) - - V1.1: Added support for Right-left windows - Changed calling convention of APIs to WINAPI (__stdcall) - Completely standalone (no need for c-runtime) - - V1.0: Apr 2001: Initial Version - -*/ - -#include -#include "coolscroll.h" -#include "userdefs.h" -#include "coolsb_internal.h" - -static TCHAR szPropStr[] = _T("CoolSBSubclassPtr"); - -LRESULT CALLBACK CoolSBWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); - -SCROLLWND* GetScrollWndFromHwnd(HWND hwnd) -{ - return (SCROLLWND *)GetProp(hwnd, szPropStr); -} - -SCROLLBAR* GetScrollBarFromHwnd(HWND hwnd, UINT nBar) -{ - SCROLLWND *sw = GetScrollWndFromHwnd(hwnd); - if (!sw) - return 0; - - if (nBar == SB_HORZ) - return &sw->sbarHorz; - if (nBar == SB_VERT) - return &sw->sbarVert; - return 0; -} - -BOOL WINAPI CoolSB_IsCoolScrollEnabled(HWND hwnd) -{ - if (GetScrollWndFromHwnd(hwnd)) - return TRUE; - return FALSE; -} - -BOOL GetScrollRect(SCROLLWND *sw, UINT nBar, HWND hwnd, RECT *rect); - -// -// Special support for USER32.DLL patching (using Detours library) -// The only place we call a real scrollbar API is in InitializeCoolSB, -// where we call EnableScrollbar. -// -// We HAVE to call the origial EnableScrollbar function, -// so we need to be able to set a pointer to this func when using -// using Detours (or any other LIB??) -// - -typedef BOOL(WINAPI *WPROC)(HWND, UINT, UINT); - -static WPROC pEnableScrollBar = 0; - -void WINAPI CoolSB_SetESBProc(WPROC proc) -{ - pEnableScrollBar = proc; -} - -static void RedrawNonClient(HWND hwnd, BOOL fFrameChanged) -{ - if (fFrameChanged == FALSE) { - /* - RECT rect; - HRGN hrgn1, hrgn2; - - SCROLLWND *sw = GetScrollWndFromHwnd(hwnd); - - GetScrollRect(sw, SB_HORZ, hwnd, &rect); - hrgn1 = CreateRectRgnIndirect(&rect); - - GetScrollRect(sw, SB_VERT, hwnd, &rect); - hrgn2 = CreateRectRgnIndirect(&rect); - - CombineRgn(hrgn1, hrgn2, hrgn1, RGN_OR); - - SendMessage(hwnd, WM_NCPAINT, (WPARAM)hrgn1, 0); - - DeleteObject(hrgn1); - DeleteObject(hrgn2);*/ - - SendMessage(hwnd, WM_NCPAINT, 1, 0); - } - else { - SetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE - | SWP_FRAMECHANGED | SWP_DRAWFRAME); - } -} - -// -// return the default minimum size of a scrollbar thumb -// -int WINAPI CoolSB_GetDefaultMinThumbSize(void) -{ - DWORD dwVersion = GetVersion(); - - // set the minimum thumb size for a scrollbar. This - // differs between NT4 and 2000, so need to check to see - // which platform we are running under - if (dwVersion < 0x80000000) // Windows NT/2000 - { - if (LOBYTE(LOWORD(dwVersion)) >= 5) - return MINTHUMBSIZE_2000; - return MINTHUMBSIZE_NT4; - } - - return MINTHUMBSIZE_NT4; -} - -static SCROLLINFO *GetScrollInfoFromHwnd(HWND hwnd, int fnBar) -{ - SCROLLBAR *sb = GetScrollBarFromHwnd(hwnd, fnBar); - - if (sb == 0) - return FALSE; - - if (fnBar == SB_HORZ) { - return &sb->scrollInfo; - } - else if (fnBar == SB_VERT) { - return &sb->scrollInfo; - } - else - return NULL; -} -// -// Initialize the cool scrollbars for a window by subclassing it -// and using the coolsb window procedure instead -// -BOOL WINAPI InitializeCoolSB(HWND hwnd) -{ - SCROLLWND *sw; - SCROLLINFO *si; - INITCOMMONCONTROLSEX ice; - TOOLINFO ti; - RECT rect; - DWORD dwCurStyle; - //BOOL fDisabled; - - if (pEnableScrollBar == 0) - pEnableScrollBar = EnableScrollBar; - - GetClientRect(hwnd, &rect); - - //if we have already initialized Cool Scrollbars for this window, - //then stop the user from doing it again - if (GetScrollWndFromHwnd(hwnd) != 0) { - return FALSE; - } - - //allocate a private scrollbar structure which we - //will use to keep track of the scrollbar data - sw = (SCROLLWND *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(SCROLLWND)); - - si = &sw->sbarHorz.scrollInfo; - si->cbSize = sizeof(SCROLLINFO); - si->fMask = SIF_ALL; - GetScrollInfo(hwnd, SB_HORZ, si); - - si = &sw->sbarVert.scrollInfo; - si->cbSize = sizeof(SCROLLINFO); - si->fMask = SIF_ALL; - GetScrollInfo(hwnd, SB_VERT, si); - - //check to see if the window has left-aligned scrollbars - if (GetWindowLongPtr(hwnd, GWL_EXSTYLE) & WS_EX_LEFTSCROLLBAR) - sw->fLeftScrollbar = TRUE; - else - sw->fLeftScrollbar = FALSE; - - dwCurStyle = GetWindowLongPtr(hwnd, GWL_STYLE); - - SetProp(hwnd, szPropStr, (HANDLE)sw); - - //try to enable the scrollbar arrows - if the return value is - //non-zero, then the scrollbars were previously disabled - //fDisabled = pEnableScrollBar(hwnd, SB_HORZ, ESB_ENABLE_BOTH); - - //scrollbars will automatically get enabled, even if - //they aren't to start with....sorry, but there isn't an - //easy alternative. - if (dwCurStyle & WS_HSCROLL) - sw->sbarHorz.fScrollFlags = CSBS_VISIBLE; - - if (dwCurStyle & WS_VSCROLL) - sw->sbarVert.fScrollFlags = CSBS_VISIBLE; - - //need to be able to distinguish between horizontal and vertical - //scrollbars in some instances - sw->sbarHorz.nBarType = SB_HORZ; - sw->sbarVert.nBarType = SB_VERT; - - sw->sbarHorz.fFlatScrollbar = CSBS_NORMAL; - sw->sbarVert.fFlatScrollbar = CSBS_NORMAL; - - //set the default arrow sizes for the scrollbars - sw->sbarHorz.nArrowLength = SYSTEM_METRIC; - sw->sbarHorz.nArrowWidth = SYSTEM_METRIC; - sw->sbarVert.nArrowLength = SYSTEM_METRIC; - sw->sbarVert.nArrowWidth = SYSTEM_METRIC; - - sw->bPreventStyleChange = FALSE; - - mir_subclassWindow(hwnd, CoolSBWndProc); - - CoolSB_SetMinThumbSize(hwnd, SB_BOTH, CoolSB_GetDefaultMinThumbSize()); - -#ifdef COOLSB_TOOLTIPS - ice.dwSize = sizeof(ice); - ice.dwICC = ICC_BAR_CLASSES; - InitCommonControlsEx(&ice); - - sw->hwndToolTip = CreateWindowEx(WS_EX_TOPMOST | WS_EX_TOOLWINDOW, TOOLTIPS_CLASS, _T(""), - WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, - CW_USEDEFAULT, CW_USEDEFAULT, - CW_USEDEFAULT, CW_USEDEFAULT, - hwnd, NULL, GetModuleHandle(0), - NULL); - - ti.cbSize = sizeof(TOOLINFO); - ti.uFlags = TTF_IDISHWND; - ti.hwnd = hwnd; - ti.uId = (UINT)hwnd; - ti.lpszText = LPSTR_TEXTCALLBACK; - ti.hinst = GetModuleHandle(0); - - SendMessage(sw->hwndToolTip, TTM_ADDTOOL, 0, (LPARAM)&ti); - -#else - - UNREFERENCED_PARAMETER(ice); - UNREFERENCED_PARAMETER(ti); - sw->hwndToolTip = 0; - -#endif - - //send the window a frame changed message to update the scrollbars - RedrawNonClient(hwnd, TRUE); - - return TRUE; -} - -BOOL WINAPI CoolSB_EnableScrollBar(HWND hwnd, int wSBflags, UINT wArrows) -{ - SCROLLBAR *sbar; - UINT oldstate; - BOOL bFailed = FALSE; - - if (!CoolSB_IsCoolScrollEnabled(hwnd)) - return EnableScrollBar(hwnd, wSBflags, wArrows); - - if ((wSBflags == SB_HORZ || wSBflags == SB_BOTH) && (sbar = GetScrollBarFromHwnd(hwnd, SB_HORZ))) { - oldstate = sbar->fScrollFlags; - - //clear any existing state, and OR in the disabled flags - sbar->fScrollFlags = (sbar->fScrollFlags & ~ESB_DISABLE_BOTH) | wArrows; - - if (oldstate == sbar->fScrollFlags) - bFailed = TRUE; - - } - - if ((wSBflags == SB_VERT || wSBflags == SB_BOTH) && (sbar = GetScrollBarFromHwnd(hwnd, SB_VERT))) { - oldstate = sbar->fScrollFlags; - - //clear any existing state, and OR in the disabled flags - sbar->fScrollFlags = (sbar->fScrollFlags & ~ESB_DISABLE_BOTH) | wArrows; - - if (oldstate == sbar->fScrollFlags) - bFailed = TRUE; - } - - return !bFailed; -} - -BOOL WINAPI CoolSB_GetScrollInfo(HWND hwnd, int fnBar, LPSCROLLINFO lpsi) -{ - BOOL copied = FALSE; - - if (!lpsi) - return FALSE; - - SCROLLINFO *mysi = GetScrollInfoFromHwnd(hwnd, fnBar); - if (!mysi) - return GetScrollInfo(hwnd, fnBar, lpsi); - - if (lpsi->fMask & SIF_PAGE) { - lpsi->nPage = mysi->nPage; - copied = TRUE; - } - - if (lpsi->fMask & SIF_POS) { - lpsi->nPos = mysi->nPos; - copied = TRUE; - } - - if (lpsi->fMask & SIF_TRACKPOS) { - lpsi->nTrackPos = mysi->nTrackPos; - copied = TRUE; - } - - if (lpsi->fMask & SIF_RANGE) { - lpsi->nMin = mysi->nMin; - lpsi->nMax = mysi->nMax; - copied = TRUE; - } - - return copied; -} - -int WINAPI CoolSB_GetScrollPos(HWND hwnd, int nBar) -{ - SCROLLINFO *mysi = GetScrollInfoFromHwnd(hwnd, nBar); - if (!mysi) - return GetScrollPos(hwnd, nBar); - - return mysi->nPos; -} - -BOOL WINAPI CoolSB_GetScrollRange(HWND hwnd, int nBar, LPINT lpMinPos, LPINT lpMaxPos) -{ - if (!lpMinPos || !lpMaxPos) - return FALSE; - - SCROLLINFO *mysi = GetScrollInfoFromHwnd(hwnd, nBar); - if (!mysi) - return GetScrollRange(hwnd, nBar, lpMinPos, lpMaxPos); - - *lpMinPos = mysi->nMin; - *lpMaxPos = mysi->nMax; - - return TRUE; -} - -int WINAPI CoolSB_SetScrollInfo(HWND hwnd, int fnBar, LPSCROLLINFO lpsi, BOOL fRedraw) -{ - BOOL fRecalcFrame = FALSE; - - if (!lpsi) - return FALSE; - - SCROLLINFO *mysi = GetScrollInfoFromHwnd(hwnd, fnBar); - if (!mysi) - return SetScrollInfo(hwnd, fnBar, lpsi, fRedraw); - - if (lpsi->fMask & SIF_RANGE) { - mysi->nMin = lpsi->nMin; - mysi->nMax = lpsi->nMax; - } - - //The nPage member must specify a value from 0 to nMax - nMin +1. - if (lpsi->fMask & SIF_PAGE) { - UINT t = (UINT)(mysi->nMax - mysi->nMin + 1); - mysi->nPage = min(lpsi->nPage, t); - } - - //The nPos member must specify a value between nMin and nMax - max(nPage - 1, 0). - if (lpsi->fMask & SIF_POS) { - mysi->nPos = max(lpsi->nPos, mysi->nMin); - mysi->nPos = min((UINT)mysi->nPos, mysi->nMax - max(mysi->nPage - 1, 0)); - } - - SCROLLBAR *sbar = GetScrollBarFromHwnd(hwnd, fnBar); - if (sbar == NULL) - return 0; - - if ((lpsi->fMask & SIF_DISABLENOSCROLL) || (sbar->fScrollFlags & CSBS_THUMBALWAYS)) { - if (!sbar->fScrollVisible) { - CoolSB_ShowScrollBar(hwnd, fnBar, TRUE); - fRecalcFrame = TRUE; - } - } - else { - if (mysi->nPage > (UINT)mysi->nMax - || mysi->nPage == (UINT)mysi->nMax && mysi->nMax == 0 - || mysi->nMax <= mysi->nMin) { - if (sbar->fScrollVisible) { - CoolSB_ShowScrollBar(hwnd, fnBar, FALSE); - fRecalcFrame = TRUE; - } - } - else { - if (!sbar->fScrollVisible) { - CoolSB_ShowScrollBar(hwnd, fnBar, TRUE); - fRecalcFrame = TRUE; - } - } - } - - if (fRedraw && !CoolSB_IsThumbTracking(hwnd)) - RedrawNonClient(hwnd, fRecalcFrame); - - return mysi->nPos; -} - - -int WINAPI CoolSB_SetScrollPos(HWND hwnd, int nBar, int nPos, BOOL fRedraw) -{ - int oldpos; - - SCROLLINFO *mysi = GetScrollInfoFromHwnd(hwnd, nBar); - if (!mysi) - return SetScrollPos(hwnd, nBar, nPos, fRedraw); - - //validate and set the scollbar position - oldpos = mysi->nPos; - mysi->nPos = max(nPos, mysi->nMin); - mysi->nPos = min((UINT)mysi->nPos, mysi->nMax - max(mysi->nPage - 1, 0)); - - if (fRedraw && !CoolSB_IsThumbTracking(hwnd)) - RedrawNonClient(hwnd, FALSE); - - return oldpos; -} - -int WINAPI CoolSB_SetScrollRange(HWND hwnd, int nBar, int nMinPos, int nMaxPos, BOOL fRedraw) -{ - SCROLLINFO *mysi = GetScrollInfoFromHwnd(hwnd, nBar); - if (!mysi) - return SetScrollRange(hwnd, nBar, nMinPos, nMaxPos, fRedraw); - - if (CoolSB_IsThumbTracking(hwnd)) - return mysi->nPos; - - //hide the scrollbar if nMin == nMax - //nMax-nMin must not be greater than MAXLONG - mysi->nMin = nMinPos; - mysi->nMax = nMaxPos; - - if (fRedraw) - RedrawNonClient(hwnd, FALSE); - - return TRUE; -} - -// -// Show or hide the specified scrollbars -// -BOOL WINAPI CoolSB_ShowScrollBar(HWND hwnd, int wBar, BOOL fShow) -{ - SCROLLBAR *sbar; - BOOL bFailed = FALSE; - DWORD dwStyle = GetWindowLongPtr(hwnd, GWL_STYLE); - - if (!CoolSB_IsCoolScrollEnabled(hwnd)) - return ShowScrollBar(hwnd, wBar, fShow); - - if ((wBar == SB_HORZ || wBar == SB_BOTH) && (sbar = GetScrollBarFromHwnd(hwnd, SB_HORZ))) { - sbar->fScrollFlags = sbar->fScrollFlags & ~CSBS_VISIBLE; - sbar->fScrollFlags |= fShow ? CSBS_VISIBLE : 0; - //bFailed = TRUE; - - if (fShow) SetWindowLongPtr(hwnd, GWL_STYLE, dwStyle | WS_HSCROLL); - else SetWindowLongPtr(hwnd, GWL_STYLE, dwStyle & ~WS_HSCROLL); - } - - if ((wBar == SB_VERT || wBar == SB_BOTH) && (sbar = GetScrollBarFromHwnd(hwnd, SB_VERT))) { - sbar->fScrollFlags = sbar->fScrollFlags & ~CSBS_VISIBLE; - sbar->fScrollFlags |= fShow ? CSBS_VISIBLE : 0; - //bFailed = TRUE; - - if (fShow) SetWindowLongPtr(hwnd, GWL_STYLE, dwStyle | WS_VSCROLL); - else SetWindowLongPtr(hwnd, GWL_STYLE, dwStyle & ~WS_VSCROLL); - } - - if (bFailed) { - return FALSE; - } - else { - //DWORD style = GetWindowLongPtr(hwnd, GWL_STYLE); - //style |= WS_VSCROLL; - - //if (s - //SetWindowLongPtr(hwnd, GWL_STYLE, style); - - SetWindowPos(hwnd, 0, 0, 0, 0, 0, - SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | - SWP_NOACTIVATE | SWP_FRAMECHANGED); - - return TRUE; - } -} - -// -// Remove cool scrollbars from the specified window. -// -HRESULT WINAPI UninitializeCoolSB(HWND hwnd) -{ - SCROLLWND *sw = GetScrollWndFromHwnd(hwnd); - if (!sw) - return E_FAIL; - - RemoveProp(hwnd, szPropStr); - //SetWindowLongPtr(hwnd, GWLP_USERDATA, 0); - - //finally, release the memory needed for the cool scrollbars - HeapFree(GetProcessHeap(), 0, sw); - - //Force WM_NCCALCSIZE and WM_NCPAINT so the original scrollbars can kick in - RedrawNonClient(hwnd, TRUE); - - return S_OK; -} - -#ifdef INCLUDE_BUTTONS - -// -// Cool scrollbar specific interface (BUTTON support) -// - -// -// Insert a button into the scrollbar area -// -// wSBflags - SB_HORZ / SB_VERT only -// uPos - position into which to insert. -// can be 0 to insert at the start, or -1 to insert -// at the end of previously inserted buttons -// - -BOOL WINAPI CoolSB_InsertButton(HWND hwnd, int wSBflags, UINT nPos, SCROLLBUT *psb) -{ - SCROLLBAR *sbar; - SCROLLBUT *sbut; - UINT i; - - if ( !psb) return FALSE; - - if ( !(sbar = GetScrollBarFromHwnd(hwnd, wSBflags))) - return FALSE; - - //check that we havn't reached the maximum allowed buttons yet - if (sbar->nButtons == MAX_COOLSB_BUTS) - return FALSE; - - //insert at end - if (nPos == -1) - { - sbut = &sbar->sbButtons[sbar->nButtons]; - } - //otherwise, need to make room - else if ((int)nPos < 0 || (int)nPos > (UINT)sbar->nButtons) - { - return FALSE; - } - else - { - //insert space for the button at the specified position - for (i = sbar->nButtons; i > nPos; i--) - { - sbar->sbButtons[i] = sbar->sbButtons[i-1]; - } - - sbut = &sbar->sbButtons[nPos]; - } - - //only set the button's properties if they are - //specified by the SCROLLBUT->fMask. - //Otherwise, use a default property value - - if (psb->fMask & SBBF_TYPE) - sbut->uButType = psb->uButType; - else - sbut->uButType = SBBT_PUSHBUTTON; - - if (psb->fMask & SBBF_STATE) - sbut->uState = psb->uState; - else - sbut->uState = 0; - - if (psb->fMask & SBBF_ID) - sbut->uCmdId = psb->uCmdId; - else - sbut->uCmdId = 0; - - if (psb->fMask & SBBF_SIZE) - sbut->nSize = psb->nSize; - else - sbut->nSize = -1; - - if (psb->fMask & SBBF_PLACEMENT) - sbut->uPlacement = psb->uPlacement; - else - sbut->uPlacement = SBBP_LEFT; - - if (psb->fMask & SBBF_BITMAP) - sbut->hBmp = psb->hBmp; - else - sbut->hBmp = 0; - - if (psb->fMask & SBBF_ENHMETAFILE) - sbut->hEmf = psb->hEmf; - else - sbut->hEmf = 0; - - if (psb->fMask & SBBF_CURSOR) - sbut->hCurs = psb->hCurs; - else - sbut->hCurs = 0; - - /* - We don't use the callback function anymore. The uButType - member must now specify SBBT_OWNERDRAW, and a WM_NOTIFY will - be sent when a button must be drawn - if ((psb->fMask & SBBF_OWNERDRAW) && ((psb->uButType & SBBT_MASK) == SBBT_OWNERDRAW)) - pDrawProc = psb->pDrawProc; - else - pDrawProc = 0;*/ - - sbar->nButtons++; - sbut->nSizeReserved = sbut->nSize; - - //MAKE SURE that any resizable buttons are only to the left / above - //a scrollbar. We don't support resize operations to the right of a scrollbar - if ((sbut->uButType & SBBM_RESIZABLE) && sbut->uPlacement == SBBP_RIGHT) - sbut->uButType &= ~SBBM_RESIZABLE; - - if (psb->fMask & SBBF_BUTMINMAX) - { - sbut->nMinSize = psb->nMinSize; - sbut->nMaxSize = psb->nMaxSize; - } - else - { - sbut->nMinSize = 0; - sbut->nMaxSize = -1; - } - - return TRUE; -} - -static SCROLLBUT *GetButtonFromId(SCROLLBAR *sbar, UINT uCmdId) -{ - int i; - for (i = 0; i < sbar->nButtons; i++) - { - if (sbar->sbButtons[i].uCmdId == uCmdId) - return &sbar->sbButtons[i]; - } - - return 0; -} - -// -// Modify the properties of the specified scrollbar button. -// wSBflags - SB_HORZ / SB_VERT only -// uItem - the command identifier specified when the button was created, -// or a non-negative position of the button, depending on if -// fByCmd is FALSE or TRUE, respectively -// -BOOL WINAPI CoolSB_ModifyButton (HWND hwnd, int wSBflags, UINT uItem, BOOL fByCmd, SCROLLBUT *psb) -{ - SCROLLBAR *sbar; - SCROLLBUT *sbut; - - if ( !psb) return FALSE; - - //find if this window is CoolScroll enabled - if ( !(sbar = GetScrollBarFromHwnd(hwnd, wSBflags))) - return FALSE; - - //find the button to modify, depending on if we - //are modifying by position or command id - if (fByCmd == FALSE) - { - //button from position - if ((int)uItem < 0 || (int)uItem >= (UINT)sbar->nButtons) - return FALSE; - else - sbut = &sbar->sbButtons[uItem]; - } - else if (fByCmd == TRUE) - { - //button from command identifier - if ( !(sbut = GetButtonFromId(sbar, uItem))) - return FALSE; - } - - if (psb->fMask & SBBF_TYPE) sbut->uButType = psb->uButType; - if (psb->fMask & SBBF_STATE) sbut->uState = psb->uState; - if (psb->fMask & SBBF_ID) sbut->uCmdId = psb->uCmdId; - if (psb->fMask & SBBF_SIZE) sbut->nSize = psb->nSize; - if (psb->fMask & SBBF_PLACEMENT) sbut->uPlacement = psb->uPlacement; - if (psb->fMask & SBBF_BITMAP) sbut->hBmp = psb->hBmp; - if (psb->fMask & SBBF_ENHMETAFILE) sbut->hEmf = psb->hEmf; - if (psb->fMask & SBBF_CURSOR) sbut->hCurs = psb->hCurs; - - if (psb->fMask & SBBF_BUTMINMAX) - { - sbut->nMinSize = psb->nMinSize; - sbut->nMaxSize = psb->nMaxSize; - } - - return TRUE; -} - -BOOL WINAPI CoolSB_RemoveButton(HWND hwnd, int wSBflags, UINT uItem, BOOL fByCmd) -{ - int i; - SCROLLBAR *sbar; - - //find if this window is CoolScroll enabled - if ( !(sbar = GetScrollBarFromHwnd(hwnd, wSBflags))) - return FALSE; - - //find the button to modify, depending on if we - //are modifying by position or command id - if (fByCmd == FALSE && ((int)uItem < 0 || (int)uItem >= (UINT)sbar->nButtons)) - { - return FALSE; - } - else if (fByCmd == TRUE) - { - //find the button with the specified command id - for (i = 0; i < sbar->nButtons; i++) - { - if (sbar->sbButtons[i].uCmdId == uItem) - { - //change the id to an index - uItem = i; - break; - } - } - - //if we failed to find the button... - if (i == sbar->nButtons) return FALSE; - } - - //remove the button! - for (i = uItem; i < sbar->nButtons - 1; i++) - { - sbar->sbButtons[i] = sbar->sbButtons[i+1]; - } - - sbar->nButtons--; - - RedrawNonClient(hwnd, TRUE); - - return TRUE; -} - -// -// fill in the supplied SCROLLBUT structure -// -BOOL WINAPI CoolSB_GetButton(HWND hwnd, int wSBflags, UINT uItem, BOOL fByCmd, SCROLLBUT *psb) -{ - SCROLLBAR *sbar; - SCROLLBUT *sbut; - - if ( !psb) return FALSE; - - //find if this window is CoolScroll enabled - if ( !(sbar = GetScrollBarFromHwnd(hwnd, wSBflags))) - return FALSE; - - //find the button to modify, depending on if we - //are modifying by position or command id - if (fByCmd == FALSE) - { - //button from position - if ((int)uItem < 0 || (int)uItem >= (UINT)sbar->nButtons) - return FALSE; - else - sbut = &sbar->sbButtons[uItem]; - } - else if (fByCmd == TRUE) - { - //button from command identifier - if ( !(sbut = GetButtonFromId(sbar, uItem))) - return FALSE; - } - - //copy them across - *psb = *sbut; - - return FALSE; -} - -#else - -BOOL WINAPI CoolSB_InsertButton(HWND, int, UINT, SCROLLBUT*) { return FALSE; } -BOOL WINAPI CoolSB_ModifyButton(HWND, int, UINT, BOOL, SCROLLBUT*) { return FALSE; } -BOOL WINAPI CoolSB_RemoveButton(HWND, int, UINT, BOOL) { return FALSE; } -BOOL WINAPI CoolSB_GetButton(HWND, int, UINT, BOOL, SCROLLBUT*) { return FALSE; } - -#endif //INCLUDE_BUTTONS - -// -// Set the size of the scrollbars -// -BOOL WINAPI CoolSB_SetSize(HWND hwnd, int wBar, int nLength, int nWidth) -{ - SCROLLBAR *sbar; - - if (nLength == 0 || nWidth == 0) - return FALSE; - - if (nLength < -8 || nWidth < -8) - return FALSE; - - if (nLength > 256 || nWidth > 256) - return FALSE; - - if (!GetScrollWndFromHwnd(hwnd)) - return FALSE; - - if ((wBar == SB_HORZ || wBar == SB_BOTH) && (sbar = GetScrollBarFromHwnd(hwnd, SB_HORZ))) { - sbar->nArrowLength = nLength; - sbar->nArrowWidth = nWidth; - } - - if ((wBar == SB_VERT || wBar == SB_BOTH) && (sbar = GetScrollBarFromHwnd(hwnd, SB_VERT))) { - sbar->nArrowLength = nLength; - sbar->nArrowWidth = nWidth; - } - - RedrawNonClient(hwnd, TRUE); - return TRUE; -} - -// -// Alter the display mode of the scrollbars -// wBar - SB_HORZ / SB_VERT / SB_BOTH -// nStyle - CSBF_NORMAL / CSBF_FLAT / CSBF_HOTTRACKED -// -BOOL WINAPI CoolSB_SetStyle(HWND hwnd, int wBar, UINT nStyle) -{ - SCROLLBAR *sbar; - - if (!GetScrollWndFromHwnd(hwnd)) - return FALSE; - - if ((wBar == SB_HORZ || wBar == SB_BOTH) && (sbar = GetScrollBarFromHwnd(hwnd, SB_HORZ))) - sbar->fFlatScrollbar = nStyle; - - if ((wBar == SB_VERT || wBar == SB_BOTH) && (sbar = GetScrollBarFromHwnd(hwnd, SB_VERT))) - sbar->fFlatScrollbar = nStyle; - - RedrawNonClient(hwnd, FALSE); - return TRUE; -} - -// -// Set if the thumb is always visible, even if there is no data to -// scroll. Setting this keeps the scrollbar enabled, but the thumb -// covers the whole area -// -BOOL WINAPI CoolSB_SetThumbAlways(HWND hwnd, int wBar, BOOL fThumbAlways) -{ - SCROLLBAR *sbar; - - if (!GetScrollWndFromHwnd(hwnd)) - return FALSE; - - if ((wBar == SB_HORZ || wBar == SB_BOTH) && (sbar = GetScrollBarFromHwnd(hwnd, SB_HORZ))) { - if (fThumbAlways) - sbar->fScrollFlags |= CSBS_THUMBALWAYS; - else - sbar->fScrollFlags &= ~CSBS_THUMBALWAYS; - } - - if ((wBar == SB_VERT || wBar == SB_BOTH) && (sbar = GetScrollBarFromHwnd(hwnd, SB_VERT))) { - if (fThumbAlways) - sbar->fScrollFlags |= CSBS_THUMBALWAYS; - else - sbar->fScrollFlags &= ~CSBS_THUMBALWAYS; - } - - RedrawNonClient(hwnd, FALSE); - - return TRUE; -} - -// -// Set the minimum size, in pixels, that the thumb box will shrink to. -// -BOOL WINAPI CoolSB_SetMinThumbSize(HWND hwnd, UINT wBar, UINT size) -{ - SCROLLBAR *sbar; - - if (!GetScrollWndFromHwnd(hwnd)) - return FALSE; - - if (size == -1) - size = CoolSB_GetDefaultMinThumbSize(); - - if ((wBar == SB_HORZ || wBar == SB_BOTH) && (sbar = GetScrollBarFromHwnd(hwnd, SB_HORZ))) - sbar->nMinThumbSize = size; - - if ((wBar == SB_VERT || wBar == SB_BOTH) && (sbar = GetScrollBarFromHwnd(hwnd, SB_VERT))) - sbar->nMinThumbSize = size; - - return TRUE; -} diff --git a/plugins/Clist_nicer/src/Coolsb/coolsblib.h b/plugins/Clist_nicer/src/Coolsb/coolsblib.h deleted file mode 100644 index d9b1c711f3..0000000000 --- a/plugins/Clist_nicer/src/Coolsb/coolsblib.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef _SUPERSCROLL_INCLUDED -#define _SUPERSCROLL_INCLUDED - -#ifdef __cplusplus -extern "C"{ -#endif - -#include - - -#ifdef __cplusplus -} -#endif - -#endif - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/plugins/Clist_nicer/src/Coolsb/coolscroll.cpp b/plugins/Clist_nicer/src/Coolsb/coolscroll.cpp deleted file mode 100644 index 80b0cd12c4..0000000000 --- a/plugins/Clist_nicer/src/Coolsb/coolscroll.cpp +++ /dev/null @@ -1,3060 +0,0 @@ -/* - Cool Scrollbar Library Version 1.2 - - Module: coolscroll.c - Copyright (c) J Brown 2001 - - This code is freeware, however, you may not publish - this code elsewhere or charge any money for it. This code - is supplied as-is. I make no guarantees about the suitability - of this code - use at your own risk. - - It would be nice if you credited me, in the event - that you use this code in a product. - - VERSION HISTORY: - - V1.2: TreeView problem fixed by Diego Tartara - Small problem in thumbsize calculation also fixed (thanks Diego!) - - V1.1: Added support for Right-left windows - Changed calling convention of APIs to WINAPI (__stdcall) - Completely standalone (no need for c-runtime) - Now supports ALL windows with appropriate USER32.DLL patching - (you provide!!) - - V1.0: Apr 2001: Initial Version - - IMPORTANT: - This whole library is based around code for a horizontal scrollbar. - All "vertical" scrollbar drawing / mouse interaction uses the - horizontal scrollbar functions, but uses a trick to convert the vertical - scrollbar coordinates into horizontal equivelants. When I started this project, - I quickly realised that the code for horz/vert bars was IDENTICAL, apart - from the fact that horizontal code uses left/right coords, and vertical code - uses top/bottom coords. On entry to a "vertical" drawing function, for example, - the coordinates are "rotated" before the horizontal function is called, and - then rotated back once the function has completed. When something needs to - be drawn, the coords are converted back again before drawing. - - This trick greatly reduces the amount of code required, and makes - maintanence much simpler. This way, only one function is needed to draw - a scrollbar, but this can be used for both horizontal and vertical bars - with careful thought. -*/ - -#include -#include "coolscroll.h" -#include "userdefs.h" -#include "coolsb_internal.h" - -//define some values if the new version of common controls -//is not available. -#ifndef NM_CUSTOMDRAW -#define NM_CUSTOMDRAW (NM_FIRST-12) -#define CDRF_DODEFAULT 0x0000 -#define CDRF_SKIPDEFAULT 0x0004 -#define CDDS_PREPAINT 0x0001 -#define CDDS_POSTPAINT 0x0002 -#endif - -// -// Special thumb-tracking variables -// -// -static UINT uCurrentScrollbar = COOLSB_NONE; //SB_HORZ / SB_VERT -static UINT uCurrentScrollPortion = HTSCROLL_NONE; -static UINT uCurrentButton = 0; - -static RECT rcThumbBounds; //area that the scroll thumb can travel in -static int nThumbSize; //(pixels) -static int nThumbPos; //(pixels) -static int nThumbMouseOffset; //(pixels) -static int nLastPos = -1; //(scrollbar units) -static int nThumbPos0; //(pixels) initial thumb position - -// -// Temporary state used to auto-generate timer messages -// -static UINT_PTR uMouseOverId = 0; -static UINT uMouseOverScrollbar = COOLSB_NONE; -static UINT uHitTestPortion = HTSCROLL_NONE; -static UINT uLastHitTestPortion = HTSCROLL_NONE; -static RECT MouseOverRect; - -static UINT uScrollTimerMsg = 0; -static UINT uScrollTimerPortion = HTSCROLL_NONE; -static UINT_PTR uScrollTimerId = 0; -static HWND hwndCurCoolSB = 0; - -extern int CustomDrawScrollBars(NMCSBCUSTOMDRAW *nmcsbcd); - -LRESULT CALLBACK CoolSBWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); - -// -// Provide this so there are NO dependencies on CRT -// -static void CoolSB_ZeroMemory(void *ptr, DWORD bytes) -{ - BYTE *bptr = (BYTE *)ptr; - - while(bytes--) *bptr++ = 0; -} - -BOOL WINAPI CoolSB_IsThumbTracking(HWND hwnd) -{ - SCROLLWND *sw; - - if ((sw = GetScrollWndFromHwnd(hwnd)) == NULL) - return FALSE; - else - return sw->fThumbTracking; -} - -// -// swap the rectangle's x coords with its y coords -// -static void __stdcall RotateRect(RECT *rect) -{ - int temp; - temp = rect->left; - rect->left = rect->top; - rect->top = temp; - - temp = rect->right; - rect->right = rect->bottom; - rect->bottom = temp; -} - -// -// swap the coords if the scrollbar is a SB_VERT -// -static void __stdcall RotateRect0(SCROLLBAR *sb, RECT *rect) -{ - if (sb->nBarType == SB_VERT) - RotateRect(rect); -} - -// -// Calculate if the SCROLLINFO members produce -// an enabled or disabled scrollbar -// -static BOOL IsScrollInfoActive(SCROLLINFO *si) -{ - if ((si->nPage > (UINT)si->nMax - || si->nMax <= si->nMin || si->nMax == 0)) - return FALSE; - else - return TRUE; -} - -// -// Return if the specified scrollbar is enabled or not -// -static BOOL IsScrollbarActive(SCROLLBAR *sb) -{ - SCROLLINFO *si = &sb->scrollInfo; - if (((sb->fScrollFlags & ESB_DISABLE_BOTH) == ESB_DISABLE_BOTH) || - !(sb->fScrollFlags & CSBS_THUMBALWAYS) && !IsScrollInfoActive(si)) - return FALSE; - else - return TRUE; -} - -// -// Draw a standard scrollbar arrow -// -static int DrawScrollArrow(SCROLLBAR *sbar, HDC hdc, RECT *rect, UINT arrow, BOOL fMouseDown, BOOL fMouseOver) -{ - UINT ret; - UINT flags = arrow; - - //HACKY bit so this routine can be called by vertical and horizontal code - if (sbar->nBarType == SB_VERT) - { - if (flags & DFCS_SCROLLLEFT) flags = flags & ~DFCS_SCROLLLEFT | DFCS_SCROLLUP; - if (flags & DFCS_SCROLLRIGHT) flags = flags & ~DFCS_SCROLLRIGHT | DFCS_SCROLLDOWN; - } - - if (fMouseDown) flags |= (DFCS_FLAT | DFCS_PUSHED); - -#ifdef FLAT_SCROLLBARS - if (sbar->fFlatScrollbar != CSBS_NORMAL) - { - HDC hdcmem1, hdcmem2; - HBITMAP hbm1, oldbm1; - HBITMAP hbm2, oldbm2; - RECT rc; - int width, height; - - rc = *rect; - width = rc.right-rc.left; - height = rc.bottom-rc.top; - SetRect(&rc, 0, 0, width, height); - - //MONOCHROME bitmap to convert the arrow to black/white mask - hdcmem1 = CreateCompatibleDC(hdc); - hbm1 = CreateBitmap(width, height, 1, 1, NULL); - UnrealizeObject(hbm1); - oldbm1 = reinterpret_cast(SelectObject(hdcmem1, hbm1)); - - - //NORMAL bitmap to draw the arrow into - hdcmem2 = CreateCompatibleDC(hdc); - hbm2 = CreateCompatibleBitmap(hdc, width, height); - UnrealizeObject(hbm2); - oldbm2 = reinterpret_cast(SelectObject(hdcmem2, hbm2)); - - - flags = flags & ~DFCS_PUSHED | DFCS_FLAT; //just in case - DrawFrameControl(hdcmem2, &rc, DFC_SCROLL, flags); - - -#ifndef HOT_TRACKING - if (fMouseDown) - { - //uncomment these to make the cool scrollbars - //look like the common controls flat scrollbars - //fMouseDown = FALSE; - //fMouseOver = TRUE; - } -#endif - //draw a flat monochrome version of a scrollbar arrow (dark) - if (fMouseDown) - { - SetBkColor(hdcmem2, GetSysColor(COLOR_BTNTEXT)); - BitBlt(hdcmem1, 0, 0, width, height, hdcmem2, 0, 0, SRCCOPY); - SetBkColor(hdc, 0x00ffffff); - SetTextColor(hdc, GetSysColor(COLOR_3DDKSHADOW)); - BitBlt(hdc, rect->left, rect->top, width, height, hdcmem1, 0, 0, SRCCOPY); - } - //draw a flat monochrome version of a scrollbar arrow (grey) - else if (fMouseOver) - { - SetBkColor(hdcmem2, GetSysColor(COLOR_BTNTEXT)); - FillRect(hdcmem1, &rc, reinterpret_cast(GetStockObject(WHITE_BRUSH))); - BitBlt(hdcmem1, 0, 0, width, height, hdcmem2, 0, 0, SRCINVERT); - - SetBkColor(hdc, GetSysColor(COLOR_3DSHADOW)); - SetTextColor(hdc, 0x00ffffff); - BitBlt(hdc, rect->left, rect->top, width, height, hdcmem1, 0, 0, SRCCOPY); - } - //draw the arrow normally - else - { - BitBlt(hdc, rect->left, rect->top, width, height, hdcmem2, 0, 0, SRCCOPY); - } - - SelectObject(hdcmem1, oldbm1); - SelectObject(hdcmem2, oldbm2); - DeleteObject(hbm1); - DeleteObject(hbm2); - DeleteDC(hdcmem1); - DeleteDC(hdcmem2); - - ret = 0; - } - else -#endif - ret = DrawFrameControl(hdc, rect, DFC_SCROLL, flags); - - return ret; -} - -// -// Return the size in pixels for the specified scrollbar metric, -// for the specified scrollbar -// -static int GetScrollMetric(SCROLLBAR *sbar, int metric) -{ - if (sbar->nBarType == SB_HORZ) - { - if (metric == SM_CXHORZSB) - { - if (sbar->nArrowLength < 0) - return -sbar->nArrowLength * GetSystemMetrics(SM_CXHSCROLL); - else - return sbar->nArrowLength; - } - else - { - if (sbar->nArrowWidth < 0) - return -sbar->nArrowWidth * GetSystemMetrics(SM_CYHSCROLL); - else - return sbar->nArrowWidth; - } - } - else if (sbar->nBarType == SB_VERT) - { - if (metric == SM_CYVERTSB) - { - if (sbar->nArrowLength < 0) - return -sbar->nArrowLength * GetSystemMetrics(SM_CYVSCROLL); - else - return sbar->nArrowLength; - } - else - { - if (sbar->nArrowWidth < 0) - return -sbar->nArrowWidth * GetSystemMetrics(SM_CXVSCROLL); - else - return sbar->nArrowWidth; - } - } - - return 0; -} - -// -// -// -static COLORREF GetSBForeColor(void) -{ - COLORREF c1 = GetSysColor(COLOR_3DHILIGHT); - COLORREF c2 = GetSysColor(COLOR_WINDOW); - - if (c1 != 0xffffff && c1 == c2) - { - return GetSysColor(COLOR_BTNFACE); - } - else - { - return GetSysColor(COLOR_3DHILIGHT); - } -} - -static COLORREF GetSBBackColor(void) -{ - return GetSysColor(COLOR_SCROLLBAR); -} - -// -// Paint a checkered rectangle, with each alternate -// pixel being assigned a different colour -// -static void DrawCheckedRect(HDC hdc, RECT *rect, COLORREF fg, COLORREF bg) -{ - static WORD wCheckPat[8] = - { - 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa, 0x5555 - }; - - HBITMAP hbmp; - HBRUSH hbr, hbrold; - COLORREF fgold, bgold; - - hbmp = CreateBitmap(8, 8, 1, 1, wCheckPat); - hbr = CreatePatternBrush(hbmp); - - UnrealizeObject(hbr); - SetBrushOrgEx(hdc, rect->left, rect->top, 0); - - hbrold = (HBRUSH)SelectObject(hdc, hbr); - - fgold = SetTextColor(hdc, fg); - bgold = SetBkColor(hdc, bg); - - PatBlt(hdc, rect->left, rect->top, - rect->right - rect->left, - rect->bottom - rect->top, - PATCOPY); - - SetBkColor(hdc, bgold); - SetTextColor(hdc, fgold); - - SelectObject(hdc, hbrold); - DeleteObject(hbr); - DeleteObject(hbmp); -} - -// -// Fill the specifed rectangle using a solid colour -// -static void PaintRect(HDC hdc, RECT *rect, COLORREF color) -{ - COLORREF oldcol = SetBkColor(hdc, color); - ExtTextOutA(hdc, 0, 0, ETO_OPAQUE, rect, "", 0, NULL); - SetBkColor(hdc, oldcol); -} - -// -// Draw a simple blank scrollbar push-button. Can be used -// to draw a push button, or the scrollbar thumb -// drawflag - could set to BF_FLAT to make flat scrollbars -// -void DrawBlankButton(HDC hdc, const RECT *rect, UINT drawflag) -{ - RECT rc = *rect; - -#ifndef FLAT_SCROLLBARS - drawflag &= ~BF_FLAT; -#endif - - DrawEdge(hdc, &rc, EDGE_RAISED, BF_RECT | drawflag | BF_ADJUST); - FillRect(hdc, &rc, GetSysColorBrush(COLOR_BTNFACE)); -} - -// -// Send a WM_VSCROLL or WM_HSCROLL message -// -static void SendScrollMessage(HWND hwnd, UINT scrMsg, UINT scrId, UINT pos) -{ - SendMessage(hwnd, scrMsg, MAKEWPARAM(scrId, pos), 0); -} - -// -// Calculate the screen coordinates of the area taken by -// the horizontal scrollbar. Take into account the size -// of the window borders -// -static BOOL GetHScrollRect(SCROLLWND *sw, HWND hwnd, RECT *rect) -{ - GetWindowRect(hwnd, rect); - - if (sw->fLeftScrollbar) - { - rect->left += sw->cxLeftEdge + (sw->sbarVert.fScrollVisible ? - GetScrollMetric(&sw->sbarVert, SM_CXVERTSB) : 0); - rect->right -= sw->cxRightEdge; - } - else - { - rect->left += sw->cxLeftEdge; //left window edge - - rect->right -= sw->cxRightEdge + //right window edge - (sw->sbarVert.fScrollVisible ? - GetScrollMetric(&sw->sbarVert, SM_CXVERTSB) : 0); - } - - rect->bottom -= sw->cyBottomEdge; //bottom window edge - - rect->top = rect->bottom - - (sw->sbarHorz.fScrollVisible ? - GetScrollMetric(&sw->sbarHorz, SM_CYHORZSB) : 0); - - return TRUE; -} - -// -// Calculate the screen coordinates of the area taken by the -// vertical scrollbar -// -static BOOL GetVScrollRect(SCROLLWND *sw, HWND hwnd, RECT *rect) -{ - GetWindowRect(hwnd, rect); - rect->top += sw->cyTopEdge; //top window edge - - rect->bottom -= sw->cyBottomEdge + - (sw->sbarHorz.fScrollVisible ? //bottom window edge - GetScrollMetric(&sw->sbarHorz, SM_CYHORZSB) : 0); - - if (sw->fLeftScrollbar) - { - rect->left += sw->cxLeftEdge; - rect->right = rect->left + (sw->sbarVert.fScrollVisible ? - GetScrollMetric(&sw->sbarVert, SM_CXVERTSB) : 0); - } - else - { - rect->right -= sw->cxRightEdge; - rect->left = rect->right - (sw->sbarVert.fScrollVisible ? - GetScrollMetric(&sw->sbarVert, SM_CXVERTSB) : 0); - } - - return TRUE; -} - -// Depending on what type of scrollbar nBar refers to, call the -// appropriate Get?ScrollRect function -// -BOOL GetScrollRect(SCROLLWND *sw, UINT nBar, HWND hwnd, RECT *rect) -{ - if (nBar == SB_HORZ) - return GetHScrollRect(sw, hwnd, rect); - else if (nBar == SB_VERT) - return GetVScrollRect(sw, hwnd, rect); - else - return FALSE; -} - -// -// This code is a prime candidate for splitting out into a separate -// file at some stage -// -#ifdef INCLUDE_BUTTONS - -// -// Calculate the size in pixels of the specified button -// -static int GetSingleButSize(SCROLLBAR *sbar, SCROLLBUT *sbut) -{ - //multiple of the system button size - //or a specific button size - if (sbut->nSize < 0) - { - if (sbar->nBarType == SB_HORZ) - return -sbut->nSize * GetSystemMetrics(SM_CXHSCROLL); - else - return -sbut->nSize * GetSystemMetrics(SM_CYVSCROLL); - } - else - return sbut->nSize; -} - -// -// Find the size in pixels of all the inserted buttons, -// either before or after the specified scrollbar -// -static int GetButtonSize(SCROLLBAR *sbar, HWND hwnd, UINT uBeforeAfter) -{ - int i; - int nPixels = 0; - - SCROLLBUT *sbut = sbar->sbButtons; - - for (i = 0; i < sbar->nButtons; i++) - { - //only consider those buttons on the same side as nTopBottom says - if (sbut[i].uPlacement == uBeforeAfter) - { - nPixels += GetSingleButSize(sbar, &sbut[i]); - } - } - - return nPixels; -} -#endif //INCLUDE_BUTTONS - -// -// Work out the scrollbar width/height for either type of scrollbar (SB_HORZ/SB_VERT) -// rect - coords of the scrollbar. -// store results into *thumbsize and *thumbpos -// -static int CalcThumbSize(SCROLLBAR *sbar, const RECT *rect, int *pthumbsize, int *pthumbpos) -{ - int scrollsize; //total size of the scrollbar including arrow buttons - int workingsize; //working area (where the thumb can slide) - int siMaxMin; - int butsize; - int startcoord; - int thumbpos = 0, thumbsize = 0; - - static int count=0; - - //work out the width (for a horizontal) or the height (for a vertical) - //of a standard scrollbar button - butsize = GetScrollMetric(sbar, SM_SCROLL_LENGTH); - - scrollsize = rect->right - rect->left; - startcoord = rect->left; - - SCROLLINFO *si = &sbar->scrollInfo; - siMaxMin = si->nMax - si->nMin + 1; - workingsize = scrollsize - butsize * 2; - - // - // Work out the scrollbar thumb SIZE - // - if (si->nPage == 0) - { - thumbsize = butsize; - } - else if (siMaxMin > 0) - { - thumbsize = MulDiv(si->nPage, workingsize, siMaxMin); - - if (thumbsize < sbar->nMinThumbSize) - thumbsize = sbar->nMinThumbSize; - } - - // - // Work out the scrollbar thumb position - // - if (siMaxMin > 0) - { - int pagesize = max(1, si->nPage); - thumbpos = MulDiv(si->nPos - si->nMin, workingsize-thumbsize, siMaxMin - pagesize); - - if (thumbpos < 0) - thumbpos = 0; - - if (thumbpos >= workingsize-thumbsize) - thumbpos = workingsize-thumbsize; - } - - thumbpos += startcoord + butsize; - - *pthumbpos = thumbpos; - *pthumbsize = thumbsize; - - return 1; -} - -// -// return a hit-test value for whatever part of the scrollbar x,y is located in -// rect, x, y: SCREEN coordinates -// the rectangle must not include space for any inserted buttons -// (i.e, JUST the scrollbar area) -// -static UINT GetHorzScrollPortion(SCROLLBAR *sbar, const RECT *rect, int x, int y) -{ - int thumbwidth, thumbpos; - int butwidth = GetScrollMetric(sbar, SM_SCROLL_LENGTH); - int scrollwidth = rect->right-rect->left; - int workingwidth = scrollwidth - butwidth*2; - - if (y < rect->top || y >= rect->bottom) - return HTSCROLL_NONE; - - CalcThumbSize(sbar, rect, &thumbwidth, &thumbpos); - - //if we have had to scale the buttons to fit in the rect, - //then adjust the button width accordingly - if (scrollwidth <= butwidth * 2) - { - butwidth = scrollwidth / 2; - } - - //check for left button click - if (x >= rect->left && x < rect->left + butwidth) - { - return HTSCROLL_LEFT; - } - //check for right button click - else if (x >= rect->right-butwidth && x < rect->right) - { - return HTSCROLL_RIGHT; - } - - //if the thumb is too big to fit (i.e. it isn't visible) - //then return a NULL scrollbar area - if (thumbwidth >= workingwidth) - return HTSCROLL_NONE; - - //check for point in the thumbbar - if (x >= thumbpos && x < thumbpos+thumbwidth) - { - return HTSCROLL_THUMB; - } - //check for left margin - else if (x >= rect->left+butwidth && x < thumbpos) - { - return HTSCROLL_PAGELEFT; - } - else if (x >= thumbpos+thumbwidth && x < rect->right-butwidth) - { - return HTSCROLL_PAGERIGHT; - } - - return HTSCROLL_NONE; -} - -// -// For vertical scrollbars, rotate all coordinates by -90 degrees -// so that we can use the horizontal version of this function -// -static UINT GetVertScrollPortion(SCROLLBAR *sb, RECT *rect, int x, int y) -{ - UINT r; - - RotateRect(rect); - r = GetHorzScrollPortion(sb, rect, y, x); - RotateRect(rect); - return r; -} - -// -// CUSTOM DRAW support -// -static LRESULT PostCustomPrePostPaint(HWND hwnd, HDC hdc, SCROLLBAR *sb, UINT dwStage) -{ -#ifdef CUSTOM_DRAW - NMCSBCUSTOMDRAW nmcd; - - CoolSB_ZeroMemory(&nmcd, sizeof nmcd); - nmcd.hdr.hwndFrom = hwnd; - nmcd.hdr.idFrom = GetWindowLongPtr(hwnd, GWLP_ID); - nmcd.hdr.code = NM_COOLSB_CUSTOMDRAW; - nmcd.nBar = sb->nBarType; - nmcd.dwDrawStage = dwStage; - nmcd.hdc = hdc; - - hwnd = GetParent(hwnd); - return CustomDrawScrollBars(&nmcd); -#else - return 0; -#endif -} - -static LRESULT PostCustomDrawNotify(HWND hwnd, HDC hdc, UINT nBar, RECT *prect, UINT nItem, BOOL fMouseDown, BOOL fMouseOver, BOOL fInactive) -{ -#ifdef CUSTOM_DRAW - NMCSBCUSTOMDRAW nmcd; - - //fill in the standard header - nmcd.hdr.hwndFrom = hwnd; - nmcd.hdr.idFrom = GetWindowLongPtr(hwnd, GWLP_ID); - nmcd.hdr.code = NM_COOLSB_CUSTOMDRAW; - - nmcd.dwDrawStage = CDDS_ITEMPREPAINT; - nmcd.nBar = nBar; - nmcd.rect = *prect; - nmcd.uItem = nItem; - nmcd.hdc = hdc; - - if (fMouseDown) - nmcd.uState = CDIS_SELECTED; - else if (fMouseOver) - nmcd.uState = CDIS_HOT; - else if (fInactive) - nmcd.uState = CDIS_DISABLED; - else - nmcd.uState = CDIS_DEFAULT; - - hwnd = GetParent(hwnd); - return CustomDrawScrollBars(&nmcd); -#else - return 0; -#endif -} - -// Depending on if we are supporting custom draw, either define -// a macro to the function name, or to nothing at all. If custom draw -// is turned off, then we can save ALOT of code space by binning all -// calls to the custom draw support. - -/* -#ifdef CUSTOM_DRAW -#define PostCustomDrawNotify PostCustomDrawNotify0 -#define PostCustomPrePostPaint PostCustomPrePostPaint0 -#else -#define PostCustomDrawNotify 1 ? (void)0 : PostCustomDrawNotify0 -#define PostCustomPrePostPaint 1 ? (void)0 : PostCustomPrePostPaint0 -#endif -*/ - -static LRESULT PostMouseNotify0(HWND hwnd, UINT nBar, RECT *prect, UINT nCmdId, POINT pt) -{ -#ifdef NOTIFY_MOUSE - NMCOOLBUTMSG nmcb; - - //fill in the standard header - nmcb.hdr.hwndFrom = hwnd; - nmcb.hdr.idFrom = GetWindowLongPtr(hwnd, GWLP_ID); - nmcb.hdr.code = NM_CLICK; - - nmcb.nBar = nBar; - nmcb.uCmdId = nCmdId; - nmcb.uState = 0; - nmcb.rect = *prect; - nmcb.pt = pt; - - hwnd = GetParent(hwnd); - return SendMessage(hwnd, WM_NOTIFY, nmcb.hdr.idFrom, (LPARAM)&nmcb); -#else - return 0; -#endif -} - -#ifdef NOTIFY_MOUSE -#define PostMouseNotify PostMouseNotify0 -#else -#define PostMouseNotify 1 ? (void)0 : PostMouseNotify0 -#endif - - - -// -// Draw a complete HORIZONTAL scrollbar in the given rectangle -// Don't draw any inserted buttons in this procedure -// -// uDrawFlags - hittest code, to say if to draw the -// specified portion in an active state or not. -// -// -static LRESULT NCDrawHScrollbar(SCROLLBAR *sb, HWND hwnd, HDC hdc, const RECT *rect, UINT uDrawFlags) -{ - SCROLLINFO *si; - RECT ctrl, thumb; - RECT sbm; - int butwidth = GetScrollMetric(sb, SM_SCROLL_LENGTH); - int scrollwidth = rect->right-rect->left; - int workingwidth = scrollwidth - butwidth*2; - int thumbwidth = 0, thumbpos = 0; - int siMaxMin; - - BOOL fCustomDraw = 0; - - BOOL fMouseDownL = 0, fMouseOverL = 0, fBarHot = 0; - BOOL fMouseDownR = 0, fMouseOverR = 0; - - COLORREF crCheck1 = GetSBForeColor(); - COLORREF crCheck2 = GetSBBackColor(); - COLORREF crInverse1 = InvertCOLORREF(crCheck1); - COLORREF crInverse2 = InvertCOLORREF(crCheck2); - - UINT uDEFlat = sb->fFlatScrollbar ? BF_FLAT : 0; - - //drawing flags to modify the appearance of the scrollbar buttons - UINT uLeftButFlags = DFCS_SCROLLLEFT; - UINT uRightButFlags = DFCS_SCROLLRIGHT; - - if (scrollwidth <= 0) - return 0; - - si = &sb->scrollInfo; - siMaxMin = si->nMax - si->nMin; - - if (hwnd != hwndCurCoolSB) - uDrawFlags = HTSCROLL_NONE; - // - // work out the thumb size and position - // - CalcThumbSize(sb, rect, &thumbwidth, &thumbpos); - - if (sb->fScrollFlags & ESB_DISABLE_LEFT) uLeftButFlags |= DFCS_INACTIVE; - if (sb->fScrollFlags & ESB_DISABLE_RIGHT) uRightButFlags |= DFCS_INACTIVE; - - //if we need to grey the arrows because there is no data to scroll - if ( !IsScrollInfoActive(si) && !(sb->fScrollFlags & CSBS_THUMBALWAYS)) - { - uLeftButFlags |= DFCS_INACTIVE; - uRightButFlags |= DFCS_INACTIVE; - } - - if (hwnd == hwndCurCoolSB) - { -#ifdef FLAT_SCROLLBARS - BOOL ldis = !(uLeftButFlags & DFCS_INACTIVE); - BOOL rdis = !(uRightButFlags & DFCS_INACTIVE); - - fBarHot = (sb->nBarType == (int)uMouseOverScrollbar && sb->fFlatScrollbar == CSBS_HOTTRACKED); - - fMouseOverL = uHitTestPortion == HTSCROLL_LEFT && fBarHot && ldis; - fMouseOverR = uHitTestPortion == HTSCROLL_RIGHT && fBarHot && rdis; -#endif - fMouseDownL = (uDrawFlags == HTSCROLL_LEFT); - fMouseDownR = (uDrawFlags == HTSCROLL_RIGHT); - } - - -//#ifdef CUSTOM_DRAW - fCustomDraw = ((PostCustomPrePostPaint(hwnd, hdc, sb, CDDS_PREPAINT)) == CDRF_SKIPDEFAULT); -//#endif - - // - // Draw the scrollbar now - // - if (scrollwidth > butwidth*2) - { - //LEFT ARROW - SetRect(&ctrl, rect->left, rect->top, rect->left + butwidth, rect->bottom); - - RotateRect0(sb, &ctrl); - - if (fCustomDraw) - PostCustomDrawNotify(hwnd, hdc, sb->nBarType, &ctrl, SB_LINELEFT, fMouseDownL, fMouseOverL, uLeftButFlags & DFCS_INACTIVE); - else - DrawScrollArrow(sb, hdc, &ctrl, uLeftButFlags, fMouseDownL, fMouseOverL); - - RotateRect0(sb, &ctrl); - - //MIDDLE PORTION - //if we can fit the thumbbar in, then draw it - if (thumbwidth > 0 && thumbwidth <= workingwidth - && IsScrollInfoActive(si) && ((sb->fScrollFlags & ESB_DISABLE_BOTH) != ESB_DISABLE_BOTH)) - { - //Draw the scrollbar margin above the thumb - SetRect(&sbm, rect->left + butwidth, rect->top, thumbpos, rect->bottom); - - RotateRect0(sb, &sbm); - - if (fCustomDraw) - { - PostCustomDrawNotify(hwnd, hdc, sb->nBarType, &sbm, SB_PAGELEFT, uDrawFlags == HTSCROLL_PAGELEFT, FALSE, FALSE); - } - else - { - if (uDrawFlags == HTSCROLL_PAGELEFT) - DrawCheckedRect(hdc, &sbm, crInverse1, crInverse2); - else - DrawCheckedRect(hdc, &sbm, crCheck1, crCheck2); - - } - - RotateRect0(sb, &sbm); - - //Draw the margin below the thumb - sbm.left = thumbpos+thumbwidth; - sbm.right = rect->right - butwidth; - - RotateRect0(sb, &sbm); - if (fCustomDraw) - { - PostCustomDrawNotify(hwnd, hdc, sb->nBarType, &sbm, SB_PAGERIGHT, uDrawFlags == HTSCROLL_PAGERIGHT, 0, 0); - } - else - { - if (uDrawFlags == HTSCROLL_PAGERIGHT) - DrawCheckedRect(hdc, &sbm, crInverse1, crInverse2); - else - DrawCheckedRect(hdc, &sbm, crCheck1, crCheck2); - - } - RotateRect0(sb, &sbm); - - //Draw the THUMB finally - SetRect(&thumb, thumbpos, rect->top, thumbpos+thumbwidth, rect->bottom); - - RotateRect0(sb, &thumb); - - if (fCustomDraw) - { - PostCustomDrawNotify(hwnd, hdc, sb->nBarType, &thumb, SB_THUMBTRACK, uDrawFlags==HTSCROLL_THUMB, uHitTestPortion == HTSCROLL_THUMB && fBarHot, FALSE); - } - else - { - -#ifdef FLAT_SCROLLBARS - if (hwnd == hwndCurCoolSB && sb->fFlatScrollbar && (uDrawFlags == HTSCROLL_THUMB || - (uHitTestPortion == HTSCROLL_THUMB && fBarHot))) - { - PaintRect(hdc, &thumb, GetSysColor(COLOR_3DSHADOW)); - } - else -#endif - { - DrawBlankButton(hdc, &thumb, uDEFlat); - } - } - RotateRect0(sb, &thumb); - - } - //otherwise, just leave that whole area blank - else - { - OffsetRect(&ctrl, butwidth, 0); - ctrl.right = rect->right - butwidth; - - //if we always show the thumb covering the whole scrollbar, - //then draw it that way - if ( !IsScrollInfoActive(si) && (sb->fScrollFlags & CSBS_THUMBALWAYS) - && ctrl.right - ctrl.left > sb->nMinThumbSize) - { - //leave a 1-pixel gap between the thumb + right button - ctrl.right --; - RotateRect0(sb, &ctrl); - - if (fCustomDraw) - PostCustomDrawNotify(hwnd, hdc, sb->nBarType, &ctrl, SB_THUMBTRACK, fMouseDownL, FALSE, FALSE); - else - { -#ifdef FLAT_SCROLLBARS - if (sb->fFlatScrollbar == CSBS_HOTTRACKED && uDrawFlags == HTSCROLL_THUMB) - PaintRect(hdc, &ctrl, GetSysColor(COLOR_3DSHADOW)); - else -#endif - DrawBlankButton(hdc, &ctrl, uDEFlat); - - } - RotateRect0(sb, &ctrl); - - //draw the single-line gap - ctrl.left = ctrl.right; - ctrl.right += 1; - - RotateRect0(sb, &ctrl); - - if (fCustomDraw) - PostCustomDrawNotify(hwnd, hdc, sb->nBarType, &ctrl, SB_PAGERIGHT, 0, 0, 0); - else - PaintRect(hdc, &ctrl, GetSysColor(COLOR_SCROLLBAR)); - - RotateRect0(sb, &ctrl); - } - //otherwise, paint a blank if the thumb doesn't fit in - else - { - RotateRect0(sb, &ctrl); - - if (fCustomDraw) - PostCustomDrawNotify(hwnd, hdc, sb->nBarType, &ctrl, SB_PAGERIGHT, 0, 0, 0); - else - DrawCheckedRect(hdc, &ctrl, crCheck1, crCheck2); - - RotateRect0(sb, &ctrl); - } - } - - //RIGHT ARROW - SetRect(&ctrl, rect->right - butwidth, rect->top, rect->right, rect->bottom); - - RotateRect0(sb, &ctrl); - - if (fCustomDraw) - PostCustomDrawNotify(hwnd, hdc, sb->nBarType, &ctrl, SB_LINERIGHT, fMouseDownR, fMouseOverR, uRightButFlags & DFCS_INACTIVE); - else - DrawScrollArrow(sb, hdc, &ctrl, uRightButFlags, fMouseDownR, fMouseOverR); - - RotateRect0(sb, &ctrl); - } - //not enough room for the scrollbar, so just draw the buttons (scaled in size to fit) - else - { - butwidth = scrollwidth / 2; - - //LEFT ARROW - SetRect(&ctrl, rect->left, rect->top, rect->left + butwidth, rect->bottom); - - RotateRect0(sb, &ctrl); - if (fCustomDraw) - PostCustomDrawNotify(hwnd, hdc, sb->nBarType, &ctrl, SB_LINELEFT, fMouseDownL, fMouseOverL, uLeftButFlags & DFCS_INACTIVE); - else - DrawScrollArrow(sb, hdc, &ctrl, uLeftButFlags, fMouseDownL, fMouseOverL); - RotateRect0(sb, &ctrl); - - //RIGHT ARROW - OffsetRect(&ctrl, scrollwidth - butwidth, 0); - - RotateRect0(sb, &ctrl); - if (fCustomDraw) - PostCustomDrawNotify(hwnd, hdc, sb->nBarType, &ctrl, SB_LINERIGHT, fMouseDownR, fMouseOverR, uRightButFlags & DFCS_INACTIVE); - else - DrawScrollArrow(sb, hdc, &ctrl, uRightButFlags, fMouseDownR, fMouseOverR); - RotateRect0(sb, &ctrl); - - //if there is a gap between the buttons, fill it with a solid color - //if (butwidth & 0x0001) - if (ctrl.left != rect->left + butwidth) - { - ctrl.left --; - ctrl.right -= butwidth; - RotateRect0(sb, &ctrl); - - if (fCustomDraw) - PostCustomDrawNotify(hwnd, hdc, sb->nBarType, &ctrl, SB_PAGERIGHT, 0, 0, 0); - else - DrawCheckedRect(hdc, &ctrl, crCheck1, crCheck2); - - RotateRect0(sb, &ctrl); - } - - } - -//#ifdef CUSTOM_DRAW - PostCustomPrePostPaint(hwnd, hdc, sb, CDDS_POSTPAINT); -//#endif - - return fCustomDraw; -} - -// -// Draw a vertical scrollbar using the horizontal draw routine, but -// with the coordinates adjusted accordingly -// -static LRESULT NCDrawVScrollbar(SCROLLBAR *sb, HWND hwnd, HDC hdc, const RECT *rect, UINT uDrawFlags) -{ - LRESULT ret; - RECT rc; - - rc = *rect; - RotateRect(&rc); - ret = NCDrawHScrollbar(sb, hwnd, hdc, &rc, uDrawFlags); - RotateRect(&rc); - - return ret; -} - -// -// Generic wrapper function for the scrollbar drawing -// -static LRESULT NCDrawScrollbar(SCROLLBAR *sb, HWND hwnd, HDC hdc, const RECT *rect, UINT uDrawFlags) -{ - if (sb->nBarType == SB_HORZ) - return NCDrawHScrollbar(sb, hwnd, hdc, rect, uDrawFlags); - else - return NCDrawVScrollbar(sb, hwnd, hdc, rect, uDrawFlags); -} - -#ifdef INCLUDE_BUTTONS - -// -// Draw the specified bitmap centered in the rectangle -// -static void DrawImage(HDC hdc, HBITMAP hBitmap, RECT *rc) -{ - BITMAP bm; - int cx; - int cy; - HDC memdc; - HBITMAP hOldBM; - RECT rcDest = *rc; - POINT p; - SIZE delta; - COLORREF colorOld; - - if (hBitmap == NULL) - return; - - // center bitmap in caller's rectangle - GetObject(hBitmap, sizeof bm, &bm); - - cx = bm.bmWidth; - cy = bm.bmHeight; - - delta.cx = (rc->right-rc->left - cx) / 2; - delta.cy = (rc->bottom-rc->top - cy) / 2; - - if (rc->right-rc->left > cx) - { - SetRect(&rcDest, rc->left+delta.cx, rc->top + delta.cy, 0, 0); - rcDest.right = rcDest.left + cx; - rcDest.bottom = rcDest.top + cy; - p.x = 0; - p.y = 0; - } - else - { - p.x = -delta.cx; - p.y = -delta.cy; - } - - // select checkmark into memory DC - memdc = CreateCompatibleDC(hdc); - hOldBM = (HBITMAP)SelectObject(memdc, hBitmap); - - // set BG color based on selected state - colorOld = SetBkColor(hdc, GetSysColor(COLOR_3DFACE)); - - BitBlt(hdc, rcDest.left, rcDest.top, rcDest.right-rcDest.left, rcDest.bottom-rcDest.top, memdc, p.x, p.y, SRCCOPY); - - // restore - SetBkColor(hdc, colorOld); - SelectObject(memdc, hOldBM); - DeleteDC(memdc); -} - -// -// Draw the specified metafile -// -static void DrawMetaFile(HDC hdc, HENHMETAFILE hemf, RECT *rect) -{ - RECT rc; - POINT pt; - - SetRect(&rc, 0, 0, rect->right-rect->left, rect->bottom-rect->top); - SetWindowOrgEx(hdc, -rect->left, -rect->top, &pt); - PlayEnhMetaFile(hdc, hemf, &rc); - SetWindowOrgEx(hdc, pt.x, pt.y, 0); -} - -// -// Draw a single scrollbar inserted button, in whatever style -// it has been defined to use. -// -static UINT DrawScrollButton(SCROLLBUT *sbut, HDC hdc, const RECT *pctrl, UINT flags) -{ - NMCSBCUSTOMDRAW nmcd; - HWND hwnd; - RECT rect = *pctrl; - UINT f; - - switch(sbut->uButType & SBBT_MASK) - { - case SBBT_OWNERDRAW: - - hwnd = WindowFromDC(hdc); - - //fill in the standard header - nmcd.hdr.hwndFrom = hwnd; - nmcd.hdr.idFrom = GetWindowLongPtr(hwnd, GWLP_ID); - nmcd.hdr.code = NM_COOLSB_CUSTOMDRAW; - - nmcd.dwDrawStage = CDDS_ITEMPREPAINT; - nmcd.nBar = SB_INSBUT; - nmcd.rect = *pctrl; - nmcd.uItem = sbut->uCmdId; - nmcd.hdc = hdc; - nmcd.uState = flags; - - IntersectClipRect(hdc, rect.left, rect.top, rect.right, rect.bottom); - SendMessage(GetParent(hwnd), WM_NOTIFY, nmcd.hdr.idFrom, (LPARAM)&nmcd); - SelectClipRgn(hdc, NULL); - - break; - - case SBBT_FIXED: - flags &= ~SBBS_PUSHED; - - case SBBT_TOGGLEBUTTON: - if (sbut->uState != SBBS_NORMAL) - flags |= SBBS_PUSHED; - - //intentionally fall through here... - - case SBBT_PUSHBUTTON: - - f = flags & SBBS_PUSHED ? DFCS_PUSHED | DFCS_FLAT : 0; - if (sbut->uButType & SBBM_LEFTARROW) - { - DrawFrameControl(hdc, &rect, DFC_SCROLL, DFCS_SCROLLLEFT | f); - } - else if (sbut->uButType & SBBM_RIGHTARROW) - { - DrawFrameControl(hdc, &rect, DFC_SCROLL, DFCS_SCROLLRIGHT | f); - } - else if (sbut->uButType & SBBM_UPARROW) - { - DrawFrameControl(hdc, &rect, DFC_SCROLL, DFCS_SCROLLUP | f); - } - else if (sbut->uButType & SBBM_DOWNARROW) - { - DrawFrameControl(hdc, &rect, DFC_SCROLL, DFCS_SCROLLDOWN | f); - } - else - { - // - if (flags & SBBS_PUSHED) - { - if (sbut->uButType & SBBM_RECESSED) - { - InflateRect(&rect, -1, -1); - DrawEdge(hdc, &rect, EDGE_SUNKEN, BF_RECT|BF_FLAT); - InflateRect(&rect, 1, 1); - - FrameRect(hdc, &rect, GetSysColorBrush(COLOR_3DDKSHADOW)); - InflateRect(&rect, -2, -2); - } - else - { - DrawEdge(hdc, &rect, EDGE_SUNKEN, BF_RECT | BF_FLAT | BF_ADJUST); - InflateRect(&rect, 1, 1); - } - } - else - { - // draw the button borders - if (sbut->uButType & SBBM_TYPE2) - { - DrawFrameControl(hdc, &rect, DFC_BUTTON, DFCS_BUTTONPUSH); - InflateRect(&rect, -2, -2); - } - - else if (sbut->uButType & SBBM_TYPE3) - { - DrawFrameControl(hdc, &rect, DFC_BUTTON, DFCS_BUTTONPUSH); - InflateRect(&rect, -1, -1); - } - else - { - DrawEdge(hdc, &rect, EDGE_RAISED, BF_RECT | BF_ADJUST); - rect.bottom++; - rect.right++; - } - - OffsetRect(&rect, -1, -1); - rect.top++; rect.left++; - } - - if (sbut->hBmp) - { - PaintRect(hdc, &rect, GetSysColor(COLOR_3DFACE)); - - if (flags & SBBS_PUSHED) - { - rect.top++; rect.left++; - } - - IntersectClipRect(hdc, rect.left, rect.top, rect.right,rect.bottom); - DrawImage(hdc, sbut->hBmp, &rect); - SelectClipRgn(hdc, 0); - } - else if (sbut->hEmf) - { - PaintRect(hdc, &rect, GetSysColor(COLOR_3DFACE)); - InflateRect(&rect, -1, -1); - - if (flags & SBBS_PUSHED) - { - rect.top++; rect.left++; - } - - IntersectClipRect(hdc, rect.left, rect.top, rect.right,rect.bottom); - DrawMetaFile(hdc, sbut->hEmf, &rect); - SelectClipRgn(hdc, 0); - } - else - { - PaintRect(hdc, &rect, GetSysColor(COLOR_3DFACE)); - } - } - - - break; - - case SBBT_BLANK: - PaintRect(hdc, &rect, GetSysColor(COLOR_3DFACE)); - break; - - case SBBT_FLAT: - DrawBlankButton(hdc, &rect, BF_FLAT); - break; - - case SBBT_DARK: - PaintRect(hdc, &rect, GetSysColor(COLOR_3DDKSHADOW)); - break; - } - - return 0; -} - -// -// Draw any buttons inserted into the horizontal scrollbar -// assume that the button widths have already been calculated -// Note: RECT *rect is the rectangle of the scrollbar -// leftright: 1 = left, 2 = right, 3 = both -// -static LRESULT DrawHorzButtons(SCROLLBAR *sbar, HDC hdc, const RECT *rect, int leftright) -{ - int i; - int xposl, xposr; - RECT ctrl; - SCROLLBUT *sbut = sbar->sbButtons; - - xposl = rect->left - sbar->nButSizeBefore; - xposr = rect->right; - - for (i = 0; i < sbar->nButtons; i++) - { - if ((leftright & SBBP_LEFT) && sbut[i].uPlacement == SBBP_LEFT) - { - int butwidth = GetSingleButSize(sbar, &sbut[i]); - SetRect(&ctrl, xposl, rect->top, xposl + butwidth, rect->bottom); - RotateRect0(sbar, &ctrl); - DrawScrollButton(&sbut[i], hdc, &ctrl, SBBS_NORMAL); - - xposl += butwidth; - } - - if ((leftright & SBBP_RIGHT) && sbut[i].uPlacement == SBBP_RIGHT) - { - int butwidth = GetSingleButSize(sbar, &sbut[i]); - SetRect(&ctrl, xposr, rect->top, xposr + butwidth, rect->bottom); - RotateRect0(sbar, &ctrl); - DrawScrollButton(&sbut[i], hdc, &ctrl, SBBS_NORMAL); - xposr += butwidth; - } - } - return 0; -} - -static LRESULT DrawVertButtons(SCROLLBAR *sbar, HDC hdc, const RECT *rect, int leftright) -{ - RECT rc = *rect; - RotateRect(&rc); - DrawHorzButtons(sbar, hdc, &rc, leftright); - return 0; -} -#endif // INCLUDE_BUTTONS - -// -// Define these two for proper processing of NCPAINT -// NOT needed if we don't bother to mask the scrollbars we draw -// to prevent the old window procedure from accidently drawing over them -// -HDC CoolSB_GetDC(HWND hwnd, WPARAM) -{ - // I just can't figure out GetDCEx, so I'll just use this: - return GetWindowDC(hwnd); -} - -static LRESULT NCPaint(SCROLLWND *sw, HWND hwnd, WPARAM wParam, LPARAM lParam) -{ - SCROLLBAR *sb; - HDC hdc; - RECT winrect, rect; - HRGN clip = 0; - BOOL fCustomDraw = FALSE; - LRESULT ret; - DWORD dwStyle; - - GetWindowRect(hwnd, &winrect); - - HRGN hrgn = (HRGN)wParam; - - //hdc = GetWindowDC(hwnd); - hdc = CoolSB_GetDC(hwnd, wParam); - - // - // Only draw the horizontal scrollbar if the window is tall enough - // - sb = &sw->sbarHorz; - if (sb->fScrollVisible) - { - //get the screen coordinates of the whole horizontal scrollbar area - GetHScrollRect(sw, hwnd, &rect); - - //make the coordinates relative to the window for drawing - OffsetRect(&rect, -winrect.left, -winrect.top); - - if (uCurrentScrollbar == SB_HORZ) - fCustomDraw |= NCDrawHScrollbar(sb, hwnd, hdc, &rect, uScrollTimerPortion); - else - fCustomDraw |= NCDrawHScrollbar(sb, hwnd, hdc, &rect, HTSCROLL_NONE); - } - - // - // Only draw the vertical scrollbar if the window is wide enough to accomodate it - // - sb = &sw->sbarVert; - if (sb->fScrollVisible) - { - //get the screen cooridinates of the whole horizontal scrollbar area - GetVScrollRect(sw, hwnd, &rect); - - //make the coordinates relative to the window for drawing - OffsetRect(&rect, -winrect.left, -winrect.top); - - if (uCurrentScrollbar == SB_VERT) - fCustomDraw |= NCDrawVScrollbar(sb, hwnd, hdc, &rect, uScrollTimerPortion); - else - fCustomDraw |= NCDrawVScrollbar(sb, hwnd, hdc, &rect, HTSCROLL_NONE); - } - - //Call the default window procedure for WM_NCPAINT, with the - //new window region. ** region must be in SCREEN coordinates ** - dwStyle = GetWindowLongPtr(hwnd, GWL_STYLE); - - // If the window has WS_(H-V)SCROLL bits set, we should reset them - // to avoid windows taking the scrollbars into account. - // We temporarily set a flag preventing the subsecuent - // WM_STYLECHANGING/WM_STYLECHANGED to be forwarded to - // the original window procedure - if ( dwStyle & (WS_VSCROLL|WS_HSCROLL)) - { - sw->bPreventStyleChange = TRUE; - SetWindowLongPtr(hwnd, GWL_STYLE, dwStyle & ~(WS_VSCROLL|WS_HSCROLL)); - } - - ret = mir_callNextSubclass(hwnd, CoolSBWndProc, WM_NCPAINT, (WPARAM)hrgn, lParam); - - if ( dwStyle & (WS_VSCROLL|WS_HSCROLL)) - { - SetWindowLongPtr(hwnd, GWL_STYLE, dwStyle); - sw->bPreventStyleChange = FALSE; - } - - // DRAW THE DEAD AREA - // only do this if the horizontal and vertical bars are visible - if (sw->sbarHorz.fScrollVisible && sw->sbarVert.fScrollVisible) - { - GetWindowRect(hwnd, &rect); - OffsetRect(&rect, -winrect.left, -winrect.top); - - rect.bottom -= sw->cyBottomEdge; - rect.top = rect.bottom - GetScrollMetric(&sw->sbarHorz, SM_CYHORZSB); - - if (sw->fLeftScrollbar) - { - rect.left += sw->cxLeftEdge; - rect.right = rect.left + GetScrollMetric(&sw->sbarVert, SM_CXVERTSB); - } - else - { - rect.right -= sw->cxRightEdge; - rect.left = rect.right - GetScrollMetric(&sw->sbarVert, SM_CXVERTSB); - } - - if (fCustomDraw) - PostCustomDrawNotify(hwnd, hdc, SB_BOTH, &rect, 32, 0, 0, 0); - else - { - //calculate the position of THIS window's dead area - //with the position of the PARENT window's client rectangle. - //if THIS window has been positioned such that its bottom-right - //corner sits in the parent's bottom-right corner, then we should - //show the sizing-grip. - //Otherwise, assume this window is not in the right place, and - //just draw a blank rectangle - RECT parent; - RECT rect2; - HWND hwndParent = GetParent(hwnd); - - GetClientRect(hwndParent, &parent); - MapWindowPoints(hwndParent, 0, (POINT *)&parent, 2); - - CopyRect(&rect2, &rect); - OffsetRect(&rect2, winrect.left, winrect.top); - - if ( !sw->fLeftScrollbar && parent.right == rect2.right+sw->cxRightEdge && parent.bottom == rect2.bottom+sw->cyBottomEdge - || sw->fLeftScrollbar && parent.left == rect2.left -sw->cxLeftEdge && parent.bottom == rect2.bottom+sw->cyBottomEdge) - DrawFrameControl(hdc, &rect, DFC_SCROLL, sw->fLeftScrollbar ? DFCS_SCROLLSIZEGRIPRIGHT : DFCS_SCROLLSIZEGRIP ); - else - PaintRect(hdc, &rect, GetSysColor(COLOR_3DFACE)); - } - } - - UNREFERENCED_PARAMETER(clip); - ReleaseDC(hwnd, hdc); - return ret; -} - -// -// Need to detect if we have clicked in the scrollbar region or not -// -static LRESULT NCHitTest(SCROLLWND *sw, HWND hwnd, WPARAM wParam, LPARAM lParam) -{ - RECT hrect; - RECT vrect; - POINT pt; - - pt.x = LOWORD(lParam); - pt.y = HIWORD(lParam); - - //work out exactly where the Horizontal and Vertical scrollbars are - GetHScrollRect(sw, hwnd, &hrect); - GetVScrollRect(sw, hwnd, &vrect); - - //Clicked in the horizontal scrollbar area - if (sw->sbarHorz.fScrollVisible && PtInRect(&hrect, pt)) - return HTHSCROLL; - - //Clicked in the vertical scrollbar area - if (sw->sbarVert.fScrollVisible && PtInRect(&vrect, pt)) - return HTVSCROLL; - - //clicked somewhere else - return mir_callNextSubclass(hwnd, CoolSBWndProc, WM_NCHITTEST, wParam, lParam); -} - -// -// Return a HT* value indicating what part of the scrollbar was clicked -// Rectangle is not adjusted -// -static UINT GetHorzPortion(SCROLLBAR *sb, RECT *rect, int x, int y) -{ - RECT rc = *rect; - - if (y < rc.top || y >= rc.bottom) return HTSCROLL_NONE; - -#ifdef INCLUDE_BUTTONS - - if (sb->fButVisibleBefore) - { - //clicked on the buttons to the left of the scrollbar - if (x >= rc.left && x < rc.left + sb->nButSizeBefore) - return HTSCROLL_INSERTED; - - //adjust the rectangle to exclude the left-side buttons, now that we - //know we havn't clicked on them - rc.left += sb->nButSizeBefore; - } - - if (sb->fButVisibleAfter) - { - //clicked on the buttons to the right of the scrollbar - if (x >= rc.right - sb->nButSizeAfter && x < rc.right) - return HTSCROLL_INSERTED; - - //adjust the rectangle to exclude the right-side buttons, now that we - //know we havn't clicked on them - rc.right -= sb->nButSizeAfter; - } - -#endif INCLUDE_BUTTONS - - //Now we have the rectangle for the scrollbar itself, so work out - //what part we clicked on. - return GetHorzScrollPortion(sb, &rc, x, y); -} - -// -// Just call the horizontal version, with adjusted coordinates -// -static UINT GetVertPortion(SCROLLBAR *sb, RECT *rect, int x, int y) -{ - UINT ret; - RotateRect(rect); - ret = GetHorzPortion(sb, rect, y, x); - RotateRect(rect); - return ret; -} - -// -// Wrapper function for GetHorzPortion and GetVertPortion -// -static UINT GetPortion(SCROLLBAR *sb, RECT *rect, int x, int y) -{ - if (sb->nBarType == SB_HORZ) - return GetHorzPortion(sb, rect, x, y); - else if (sb->nBarType == SB_VERT) - return GetVertPortion(sb, rect, x, y); - else - return HTSCROLL_NONE; -} - -// -// Input: rectangle of the total scrollbar area -// Output: adjusted to take the inserted buttons into account -// -static void GetRealHorzScrollRect(SCROLLBAR *sb, RECT *rect) -{ - if (sb->fButVisibleBefore) rect->left += sb->nButSizeBefore; - if (sb->fButVisibleAfter) rect->right -= sb->nButSizeAfter; -} - -// -// Input: rectangle of the total scrollbar area -// Output: adjusted to take the inserted buttons into account -// -static void GetRealVertScrollRect(SCROLLBAR *sb, RECT *rect) -{ - if (sb->fButVisibleBefore) rect->top += sb->nButSizeBefore; - if (sb->fButVisibleAfter) rect->bottom -= sb->nButSizeAfter; -} - -// -// Decide which type of scrollbar we have before calling -// the real function to do the job -// -static void GetRealScrollRect(SCROLLBAR *sb, RECT *rect) -{ - if (sb->nBarType == SB_HORZ) - { - GetRealHorzScrollRect(sb, rect); - } - else if (sb->nBarType == SB_VERT) - { - GetRealVertScrollRect(sb, rect); - } -} - -// -// All button code shoule be collected together -// -// -#ifdef INCLUDE_BUTTONS - -// -// Return the index of the button covering the specified point -// rect - rectangle of the whole scrollbar area -// pt - screen coords of the mouse -// fReturnRect - do/don't modify the rect to return the button's area -// -static UINT GetHorzButtonFromPt(SCROLLBAR *sb, RECT *rect, POINT pt, BOOL fReturnRect) -{ - int leftpos = rect->left, rightpos = rect->right; - int i; - int butwidth; - SCROLLBUT *sbut = sb->sbButtons; - - if ( !PtInRect(rect, pt)) - return -1; - - if (sb->fButVisibleAfter) - rightpos -= sb->nButSizeAfter; - - for (i = 0; i < sb->nButtons; i++) - { - if (sb->fButVisibleBefore && sbut[i].uPlacement == SBBP_LEFT) - { - butwidth = GetSingleButSize(sb, &sbut[i]); - - //if the current button is under the specified point - if (pt.x >= leftpos && pt.x < leftpos + butwidth) - { - //if the caller wants us to return the rectangle of the button - if (fReturnRect) - { - rect->left = leftpos; - rect->right = leftpos + butwidth; - } - - return i; - } - - leftpos += butwidth; - } - else if (sb->fButVisibleAfter && sbut[i].uPlacement == SBBP_RIGHT) - { - butwidth = GetSingleButSize(sb, &sbut[i]); - - //if the current button is under the specified point - if (pt.x >= rightpos && pt.x < rightpos + butwidth) - { - //if the caller wants us to return the rectangle of the button - if (fReturnRect) - { - rect->left = rightpos; - rect->right = rightpos + butwidth; - } - return i; - } - - rightpos += butwidth; - } - } - - return -1; -} - - -static UINT GetVertButtonFromPt(SCROLLBAR *sb, RECT *rect, POINT pt, BOOL fReturnRect) -{ - UINT ret; - int temp; - - //swap the X/Y coords - temp = pt.x; - pt.x = pt.y; - pt.y = temp; - - //swap the rectangle - RotateRect(rect); - - ret = GetHorzButtonFromPt(sb, rect, pt, fReturnRect); - - RotateRect(rect); - return ret; -} - -// -// -// -static UINT GetButtonFromPt(SCROLLBAR *sb, RECT *rect, POINT pt, BOOL fReturnRect) -{ - if (sb->nBarType == SB_HORZ) - { - return GetHorzButtonFromPt(sb, rect, pt, fReturnRect); - } - else - { - return GetVertButtonFromPt(sb, rect, pt, fReturnRect); - } -} - -// -// Find the coordinates (in RECT format) of the specified button index -// -static UINT GetHorzButtonRectFromId(SCROLLBAR *sb, RECT *rect, UINT index) -{ - UINT i; - SCROLLBUT *sbut = sb->sbButtons; - int leftpos = rect->left, rightpos = rect->right; - - if (sb->fButVisibleAfter) - rightpos -= sb->nButSizeAfter; - - //find the particular button in question - for (i = 0; i < index; i++) - { - if (sb->fButVisibleBefore && sbut[i].uPlacement == SBBP_LEFT) - { - leftpos += GetSingleButSize(sb, &sbut[i]); - } - else if (sb->fButVisibleAfter && sbut[i].uPlacement == SBBP_RIGHT) - { - rightpos += GetSingleButSize(sb, &sbut[i]); - } - } - - //now return the rectangle - if (sbut[i].uPlacement == SBBP_LEFT) - { - rect->left = leftpos; - rect->right = leftpos + GetSingleButSize(sb, &sbut[i]); - } - else - { - rect->left = rightpos; - rect->right = rightpos + GetSingleButSize(sb, &sbut[i]); - } - - return 0; -} - -static UINT GetVertButtonRectFromId(SCROLLBAR *sb, RECT *rect, UINT index) -{ - UINT ret; - RotateRect(rect); - ret = GetHorzButtonRectFromId(sb, rect, index); - RotateRect(rect); - return ret; -} - -static UINT GetButtonRectFromId(SCROLLBAR *sb, RECT *rect, UINT index) -{ - if (sb->nBarType == SB_HORZ) - { - return GetHorzButtonRectFromId(sb, rect, index); - } - else - { - return GetVertButtonRectFromId(sb, rect, index); - } -} -#endif //INCLUDE_BUTTONS - -// -// Left button click in the non-client area -// -static LRESULT NCLButtonDown(SCROLLWND *sw, HWND hwnd, WPARAM wParam, LPARAM lParam) -{ - RECT rect, winrect; - HDC hdc; - SCROLLBAR *sb; - POINT pt; - - pt.x = LOWORD(lParam); - pt.y = HIWORD(lParam); - - hwndCurCoolSB = hwnd; - - // - // HORIZONTAL SCROLLBAR PROCESSING - // - if (wParam == HTHSCROLL) - { - uScrollTimerMsg = WM_HSCROLL; - uCurrentScrollbar = SB_HORZ; - sb = &sw->sbarHorz; - - //get the total area of the normal Horz scrollbar area - GetHScrollRect(sw, hwnd, &rect); - uCurrentScrollPortion = GetHorzPortion(sb, &rect, LOWORD(lParam), HIWORD(lParam)); - } - // - // VERTICAL SCROLLBAR PROCESSING - // - else if (wParam == HTVSCROLL) - { - uScrollTimerMsg = WM_VSCROLL; - uCurrentScrollbar = SB_VERT; - sb = &sw->sbarVert; - - //get the total area of the normal Horz scrollbar area - GetVScrollRect(sw, hwnd, &rect); - uCurrentScrollPortion = GetVertPortion(sb, &rect, LOWORD(lParam), HIWORD(lParam)); - } - // - // NORMAL PROCESSING - // - else - { - uCurrentScrollPortion = HTSCROLL_NONE; - return mir_callNextSubclass(hwnd, CoolSBWndProc, WM_NCLBUTTONDOWN, wParam, lParam); - } - - // - // we can now share the same code for vertical - // and horizontal scrollbars - // - switch(uCurrentScrollPortion) - { - //inserted buttons to the left/right -#ifdef INCLUDE_BUTTONS - case HTSCROLL_INSERTED: - -#ifdef HOT_TRACKING - KillTimer(hwnd, uMouseOverId); - uMouseOverId = 0; - uMouseOverScrollbar = COOLSB_NONE; -#endif - - //find the index of the button that has been clicked - //adjust the rectangle to give the button's rectangle - uCurrentButton = GetButtonFromPt(sb, &rect, pt, TRUE); - - sbut = &sb->sbButtons[uCurrentButton]; - - //post a notification message - PostMouseNotify(hwnd, NM_CLICK, sb->nBarType, &rect, sbut->uCmdId, pt); - - GetWindowRect(hwnd, &winrect); - OffsetRect(&rect, -winrect.left, -winrect.top); - hdc = GetWindowDC(hwnd); - - DrawScrollButton(sbut, hdc, &rect, SBBS_PUSHED); - - ReleaseDC(hwnd, hdc); - - break; -#endif //INCLUDE_BUTTONS - - case HTSCROLL_THUMB: - - //if the scrollbar is disabled, then do no further processing - if ( !IsScrollbarActive(sb)) - return 0; - - GetRealScrollRect(sb, &rect); - RotateRect0(sb, &rect); - CalcThumbSize(sb, &rect, &nThumbSize, &nThumbPos); - RotateRect0(sb, &rect); - - //remember the bounding rectangle of the scrollbar work area - rcThumbBounds = rect; - - sw->fThumbTracking = TRUE; - sb->scrollInfo.nTrackPos = sb->scrollInfo.nPos; - - if (wParam == HTVSCROLL) - nThumbMouseOffset = pt.y - nThumbPos; - else - nThumbMouseOffset = pt.x - nThumbPos; - - nLastPos = -sb->scrollInfo.nPos; - nThumbPos0 = nThumbPos; - - //if (sb->fFlatScrollbar) - //{ - GetWindowRect(hwnd, &winrect); - OffsetRect(&rect, -winrect.left, -winrect.top); - hdc = GetWindowDC(hwnd); - NCDrawScrollbar(sb, hwnd, hdc, &rect, HTSCROLL_THUMB); - ReleaseDC(hwnd, hdc); - //} - - break; - - //Any part of the scrollbar - case HTSCROLL_LEFT: - if (sb->fScrollFlags & ESB_DISABLE_LEFT) return 0; - else goto target1; - - case HTSCROLL_RIGHT: - if (sb->fScrollFlags & ESB_DISABLE_RIGHT) return 0; - else goto target1; - - goto target1; - - case HTSCROLL_PAGELEFT: case HTSCROLL_PAGERIGHT: - - target1: - - //if the scrollbar is disabled, then do no further processing - if ( !IsScrollbarActive(sb)) - break; - - //ajust the horizontal rectangle to NOT include - //any inserted buttons - GetRealScrollRect(sb, &rect); - - SendScrollMessage(hwnd, uScrollTimerMsg, uCurrentScrollPortion, 0); - - // Check what area the mouse is now over : - // If the scroll thumb has moved under the mouse in response to - // a call to SetScrollPos etc, then we don't hilight the scrollbar margin - if (uCurrentScrollbar == SB_HORZ) - uScrollTimerPortion = GetHorzScrollPortion(sb, &rect, pt.x, pt.y); - else - uScrollTimerPortion = GetVertScrollPortion(sb, &rect, pt.x, pt.y); - - GetWindowRect(hwnd, &winrect); - OffsetRect(&rect, -winrect.left, -winrect.top); - hdc = GetWindowDC(hwnd); - -#ifndef HOT_TRACKING - //if we aren't hot-tracking, then don't highlight - //the scrollbar thumb unless we click on it - if (uScrollTimerPortion == HTSCROLL_THUMB) - uScrollTimerPortion = HTSCROLL_NONE; -#endif - NCDrawScrollbar(sb, hwnd, hdc, &rect, uScrollTimerPortion); - ReleaseDC(hwnd, hdc); - - //Post the scroll message!!!! - uScrollTimerPortion = uCurrentScrollPortion; - - //set a timer going on the first click. - //if this one expires, then we can start off a more regular timer - //to generate the auto-scroll behaviour - uScrollTimerId = SetTimer(hwnd, COOLSB_TIMERID1, COOLSB_TIMERINTERVAL1, 0); - break; - default: - return mir_callNextSubclass(hwnd, CoolSBWndProc, WM_NCLBUTTONDOWN, wParam, lParam); - //return 0; - } - - SetCapture(hwnd); - return 0; -} - -// -// Left button released -// -static LRESULT LButtonUp(SCROLLWND *sw, HWND hwnd, WPARAM wParam, LPARAM lParam) -{ - RECT rect; - //UINT thisportion; - HDC hdc; - POINT pt; - RECT winrect; - - //current scrollportion is the button that we clicked down on - if (uCurrentScrollPortion != HTSCROLL_NONE) - { - SCROLLBAR *sb = &sw->sbarHorz; - lParam = GetMessagePos(); - ReleaseCapture(); - - GetWindowRect(hwnd, &winrect); - pt.x = LOWORD(lParam); - pt.y = HIWORD(lParam); - - //emulate the mouse input on a scrollbar here... - if (uCurrentScrollbar == SB_HORZ) - { - //get the total area of the normal Horz scrollbar area - sb = &sw->sbarHorz; - GetHScrollRect(sw, hwnd, &rect); - } - else if (uCurrentScrollbar == SB_VERT) - { - //get the total area of the normal Horz scrollbar area - sb = &sw->sbarVert; - GetVScrollRect(sw, hwnd, &rect); - } - - //we need to do different things depending on if the - //user is activating the scrollbar itself, or one of - //the inserted buttons - switch(uCurrentScrollPortion) - { -#ifdef INCLUDE_BUTTONS - //inserted buttons are being clicked - case HTSCROLL_INSERTED: - - //get the rectangle of the ACTIVE button - buttonIdx = GetButtonFromPt(sb, &rect, pt, FALSE); - GetButtonRectFromId(sb, &rect, uCurrentButton); - - OffsetRect(&rect, -winrect.left, -winrect.top); - - //Send the notification BEFORE we redraw, so the - //bitmap can be changed smoothly by the user if they require - if (uCurrentButton == buttonIdx) - { - SCROLLBUT *sbut = &sb->sbButtons[buttonIdx]; - UINT cmdid = sbut->uCmdId; - - if ((sbut->uButType & SBBT_MASK) == SBBT_TOGGLEBUTTON) - sbut->uState ^= 1; - - //send a notify?? - //only post a message if the command id is valid - if (cmdid != -1 && cmdid > 0) - SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(cmdid, CSBN_CLICKED), 0); - - //user might have deleted this button, so redraw whole area - NCPaint(sw, hwnd, 1, 0); - } - else - { - //otherwise, just redraw the button in its new state - hdc = GetWindowDC(hwnd); - DrawScrollButton(&sb->sbButtons[uCurrentButton], hdc, &rect, SBBS_NORMAL); - ReleaseDC(hwnd, hdc); - } - - break; -#endif // INCLUDE_BUTTONS - - //The scrollbar is active - case HTSCROLL_LEFT: case HTSCROLL_RIGHT: - case HTSCROLL_PAGELEFT: case HTSCROLL_PAGERIGHT: - case HTSCROLL_NONE: - - KillTimer(hwnd, uScrollTimerId); - - case HTSCROLL_THUMB: - - //In case we were thumb tracking, make sure we stop NOW - if (sw->fThumbTracking == TRUE) - { - SendScrollMessage(hwnd, uScrollTimerMsg, SB_THUMBPOSITION, nLastPos); - sw->fThumbTracking = FALSE; - } - - //send the SB_ENDSCROLL message now that scrolling has finished - SendScrollMessage(hwnd, uScrollTimerMsg, SB_ENDSCROLL, 0); - - //adjust the total scroll area to become where the scrollbar - //really is (take into account the inserted buttons) - GetRealScrollRect(sb, &rect); - OffsetRect(&rect, -winrect.left, -winrect.top); - hdc = GetWindowDC(hwnd); - - //draw whichever scrollbar sb is - NCDrawScrollbar(sb, hwnd, hdc, &rect, HTSCROLL_NORMAL); - - ReleaseDC(hwnd, hdc); - break; - } - - //reset our state to default - uCurrentScrollPortion = HTSCROLL_NONE; - uScrollTimerPortion = HTSCROLL_NONE; - uScrollTimerId = 0; - - uScrollTimerMsg = 0; - uCurrentScrollbar = COOLSB_NONE; - - return 0; - } - else - { - /* - // Can't remember why I did this! - if (GetCapture() == hwnd) - { - ReleaseCapture(); - }*/ - } - - return mir_callNextSubclass(hwnd, CoolSBWndProc, WM_LBUTTONUP, wParam, lParam); -} - -// -// This function is called whenever the mouse is moved and -// we are dragging the scrollbar thumb about. -// -static LRESULT ThumbTrackHorz(SCROLLBAR *sbar, HWND hwnd, int x, int y) -{ - POINT pt; - RECT rc, winrect, rc2; - COLORREF crCheck1 = GetSBForeColor(); - COLORREF crCheck2 = GetSBBackColor(); - HDC hdc; - int thumbpos = nThumbPos; - int pos; - int siMaxMin = 0; - UINT flatflag = sbar->fFlatScrollbar ? BF_FLAT : 0; - BOOL fCustomDraw = FALSE; - - SCROLLINFO *si; - si = &sbar->scrollInfo; - - pt.x = x; - pt.y = y; - - //draw the thumb at whatever position - rc = rcThumbBounds; - - SetRect(&rc2, rc.left - THUMBTRACK_SNAPDIST*2, rc.top - THUMBTRACK_SNAPDIST, - rc.right + THUMBTRACK_SNAPDIST*2, rc.bottom + THUMBTRACK_SNAPDIST); - - rc.left += GetScrollMetric(sbar, SM_CXHORZSB); - rc.right -= GetScrollMetric(sbar, SM_CXHORZSB); - - //if the mouse is not in a suitable distance of the scrollbar, - //then "snap" the thumb back to its initial position -#ifdef SNAP_THUMB_BACK - if ( !PtInRect(&rc2, pt)) - { - thumbpos = nThumbPos0; - } - //otherwise, move the thumb to where the mouse is - else -#endif //SNAP_THUMB_BACK - { - //keep the thumb within the scrollbar limits - thumbpos = pt.x - nThumbMouseOffset; - if (thumbpos < rc.left) thumbpos = rc.left; - if (thumbpos > rc.right - nThumbSize) thumbpos = rc.right - nThumbSize; - } - - GetWindowRect(hwnd, &winrect); - - if (sbar->nBarType == SB_VERT) - RotateRect(&winrect); - - hdc = GetWindowDC(hwnd); - -//#ifdef CUSTOM_DRAW - fCustomDraw = PostCustomPrePostPaint(hwnd, hdc, sbar, CDDS_PREPAINT) == CDRF_SKIPDEFAULT; -//#endif - - OffsetRect(&rc, -winrect.left, -winrect.top); - thumbpos -= winrect.left; - - //draw the margin before the thumb - SetRect(&rc2, rc.left, rc.top, thumbpos, rc.bottom); - RotateRect0(sbar, &rc2); - - if (fCustomDraw) - PostCustomDrawNotify(hwnd, hdc, sbar->nBarType, &rc2, SB_PAGELEFT, 0, 0, 0); - else - DrawCheckedRect(hdc, &rc2, crCheck1, crCheck2); - - RotateRect0(sbar, &rc2); - - //draw the margin after the thumb - SetRect(&rc2, thumbpos+nThumbSize, rc.top, rc.right, rc.bottom); - - RotateRect0(sbar, &rc2); - - if (fCustomDraw) - PostCustomDrawNotify(hwnd, hdc, sbar->nBarType, &rc2, SB_PAGERIGHT, 0, 0, 0); - else - DrawCheckedRect(hdc, &rc2, crCheck1, crCheck2); - - RotateRect0(sbar, &rc2); - - //finally draw the thumb itelf. This is how it looks on win2000, anyway - SetRect(&rc2, thumbpos, rc.top, thumbpos+nThumbSize, rc.bottom); - - RotateRect0(sbar, &rc2); - - if (fCustomDraw) - PostCustomDrawNotify(hwnd, hdc, sbar->nBarType, &rc2, SB_THUMBTRACK, TRUE, TRUE, FALSE); - else - { - -#ifdef FLAT_SCROLLBARS - if (sbar->fFlatScrollbar) - PaintRect(hdc, &rc2, GetSysColor(COLOR_3DSHADOW)); - else -#endif - { - DrawBlankButton(hdc, &rc2, flatflag); - } - } - - RotateRect0(sbar, &rc2); - ReleaseDC(hwnd, hdc); - - //post a SB_TRACKPOS message!!! - siMaxMin = si->nMax - si->nMin; - - if (siMaxMin > 0) - pos = MulDiv(thumbpos-rc.left, siMaxMin-si->nPage + 1, rc.right-rc.left-nThumbSize); - else - pos = thumbpos - rc.left; - - if (pos != nLastPos) - { - si->nTrackPos = pos; - SendScrollMessage(hwnd, uScrollTimerMsg, SB_THUMBTRACK, pos); - } - - nLastPos = pos; - -//#ifdef CUSTOM_DRAW - PostCustomPrePostPaint(hwnd, hdc, sbar, CDDS_POSTPAINT); -//#endif - - return 0; -} - -// -// remember to rotate the thumb bounds rectangle!! -// -static LRESULT ThumbTrackVert(SCROLLBAR *sb, HWND hwnd, int x, int y) -{ - //sw->swapcoords = TRUE; - RotateRect(&rcThumbBounds); - ThumbTrackHorz(sb, hwnd, y, x); - RotateRect(&rcThumbBounds); - //sw->swapcoords = FALSE; - - return 0; -} - -// -// Called when we have set the capture from the NCLButtonDown(...) -// -static LRESULT MouseMove(SCROLLWND *sw, HWND hwnd, WPARAM wParam, LPARAM lParam) -{ - RECT rect; - UINT thisportion; - HDC hdc; - static UINT lastportion = 0; - static UINT lastbutton = 0; - POINT pt; - RECT winrect; - UINT buttonIdx = 0; - - if (sw->fThumbTracking == TRUE) - { - int x, y; - lParam = GetMessagePos(); - x = LOWORD(lParam); - y = HIWORD(lParam); - - if (uCurrentScrollbar == SB_HORZ) - return ThumbTrackHorz(&sw->sbarHorz, hwnd, x,y); - - else if (uCurrentScrollbar == SB_VERT) - return ThumbTrackVert(&sw->sbarVert, hwnd, x,y); - } - - if (uCurrentScrollPortion == HTSCROLL_NONE) - return mir_callNextSubclass(hwnd, CoolSBWndProc, WM_MOUSEMOVE, wParam, lParam); - - LPARAM nlParam; - SCROLLBAR *sb = &sw->sbarHorz; - - nlParam = GetMessagePos(); - - GetWindowRect(hwnd, &winrect); - - pt.x = LOWORD(nlParam); - pt.y = HIWORD(nlParam); - - //emulate the mouse input on a scrollbar here... - if (uCurrentScrollbar == SB_HORZ) - { - sb = &sw->sbarHorz; - } - else if (uCurrentScrollbar == SB_VERT) - { - sb = &sw->sbarVert; - } - - //get the total area of the normal scrollbar area - GetScrollRect(sw, sb->nBarType, hwnd, &rect); - - //see if we clicked in the inserted buttons / normal scrollbar - //thisportion = GetPortion(sb, hwnd, &rect, LOWORD(lParam), HIWORD(lParam)); - thisportion = GetPortion(sb, &rect, pt.x, pt.y); - - //we need to do different things depending on if the - //user is activating the scrollbar itself, or one of - //the inserted buttons - switch(uCurrentScrollPortion) { -#ifdef INCLUDE_BUTTONS - //inserted buttons are being clicked - case HTSCROLL_INSERTED: - - //find the index of the button that has been clicked - //Don't adjust the rectangle though - buttonIdx = GetButtonFromPt(sb, &rect, pt, FALSE); - - //Get the rectangle of the active button - GetButtonRectFromId(sb, &rect, uCurrentButton); - - //if the button to the LEFT of the current - //button is resizable, then resize it -#ifdef RESIZABLE_BUTTONS - if (uCurrentButton > 0) - { - sbut = &sb->sbButtons[uCurrentButton - 1]; - - //only resize if BOTH buttons are on same side of scrollbar - if (sbut->uPlacement == (sbut+1)->uPlacement && (sbut->uButType & SBBM_RESIZABLE)) - { - int oldsize = sbut->nSize; - int butsize1, butsize2; - RECT rect2; - int scrollsize; - - if (uCurrentScrollbar == SB_HORZ) - { - rect.left -= GetSingleButSize(sb, sbut); - sbut->nSize = pt.x - rect.left; - } - else - { - rect.top -= GetSingleButSize(sb, sbut); - sbut->nSize = pt.y - rect.top; - } - - //if (sbut->nSize < 0) sbut->nSize = 0; - if (sbut->nSize < (int)sbut->nMinSize) - sbut->nSize = sbut->nMinSize; - - if ((UINT)sbut->nSize > (UINT)sbut->nMaxSize) - sbut->nSize = sbut->nMaxSize; - - GetScrollRect(sw, uCurrentScrollbar, hwnd, &rect2); - - if (uCurrentScrollbar == SB_HORZ) - scrollsize = rect2.right-rect2.left; - else - scrollsize = rect2.bottom-rect2.top; - - butsize1 = GetButtonSize(sb, hwnd, SBBP_LEFT); - butsize2 = GetButtonSize(sb, hwnd, SBBP_RIGHT); - - //adjust the button size if it gets too big - if (butsize1 + butsize2 > scrollsize - MINSCROLLSIZE) - { - sbut->nSize -= (butsize1+butsize2) - (scrollsize - MINSCROLLSIZE); - } - - //remember what size the USER set the button to - sbut->nSizeReserved = sbut->nSize; - NCPaint(sw, hwnd, 1, 0); - return 0; - } - } -#endif //RESIZABLE_BUTTONS - - OffsetRect(&rect, -winrect.left, -winrect.top); - - hdc = GetWindowDC(hwnd); - - //if the button under the mouse is not the active button, - //then display the active button in its normal state - if (buttonIdx != uCurrentButton - //include this if toggle buttons always stay depressed - //if they are being activated - && (sb->sbButtons[uCurrentButton].uButType & SBBT_MASK) != SBBT_TOGGLEBUTTON) - { - if (lastbutton != buttonIdx) - DrawScrollButton(&sb->sbButtons[uCurrentButton], hdc, &rect, SBBS_NORMAL); - } - //otherwise, depress the active button if the mouse is over - //it (just like a normal scroll button works) - else - { - if (lastbutton != buttonIdx) - DrawScrollButton(&sb->sbButtons[uCurrentButton], hdc, &rect, SBBS_PUSHED); - } - - ReleaseDC(hwnd, hdc); - return mir_callNextSubclass(hwnd, CoolSBWndProc, WM_MOUSEMOVE, wParam, lParam); - //break; - -#endif //INCLUDE_BUTTONS - - //The scrollbar is active - case HTSCROLL_LEFT: case HTSCROLL_RIGHT:case HTSCROLL_THUMB: - case HTSCROLL_PAGELEFT: case HTSCROLL_PAGERIGHT: - case HTSCROLL_NONE: - //adjust the total scroll area to become where the scrollbar - //really is (take into account the inserted buttons) - GetRealScrollRect(sb, &rect); - - OffsetRect(&rect, -winrect.left, -winrect.top); - hdc = GetWindowDC(hwnd); - - if (thisportion != uCurrentScrollPortion) - { - uScrollTimerPortion = HTSCROLL_NONE; - - if (lastportion != thisportion) - NCDrawScrollbar(sb, hwnd, hdc, &rect, HTSCROLL_NORMAL); - } - //otherwise, draw the button in its depressed / clicked state - else - { - uScrollTimerPortion = uCurrentScrollPortion; - - if (lastportion != thisportion) - NCDrawScrollbar(sb, hwnd, hdc, &rect, thisportion); - } - - ReleaseDC(hwnd, hdc); - break; - } - - lastportion = thisportion; - lastbutton = buttonIdx; - return 0; -} - -#ifdef INCLUDE_BUTTONS -#ifdef RESIZABLE_BUTTONS -// -// Any resizable buttons must be shrunk to fit if the window is made too small -// -static void ResizeButtonsToFit(SCROLLWND *sw, SCROLLBAR *sbar, HWND hwnd) -{ - int butsize1, butsize2; - RECT rc; - int scrollsize; - int i; - SCROLLBUT *sbut; - - //make sure that the scrollbar can fit into space, by - //shrinking any resizable buttons - GetScrollRect(sw, sbar->nBarType, hwnd, &rc); - - if (sbar->nBarType == SB_HORZ) - scrollsize = rc.right-rc.left; - else - scrollsize = rc.bottom-rc.top; - - //restore any resizable buttons to their user-defined sizes, - //before shrinking them to fit. This means when we make the window - //bigger, the buttons will restore to their initial sizes - for (i = 0; i < sbar->nButtons; i++) - { - sbut = &sbar->sbButtons[i]; - if (sbut->uButType & SBBM_RESIZABLE) - { - sbut->nSize = sbut->nSizeReserved; - } - } - - butsize1 = GetButtonSize(sbar, hwnd, SBBP_LEFT); - butsize2 = GetButtonSize(sbar, hwnd, SBBP_RIGHT); - - if (butsize1 + butsize2 > scrollsize - MINSCROLLSIZE) - { - i = 0; - while(i < sbar->nButtons && - butsize1 + butsize2 > scrollsize - MINSCROLLSIZE) - { - sbut = &sbar->sbButtons[i++]; - if (sbut->uButType & SBBM_RESIZABLE) - { - int oldsize = sbut->nSize; - sbut->nSize -= (butsize1+butsize2) - (scrollsize-MINSCROLLSIZE); - - if (sbut->nSize < (int)sbut->nMinSize) - sbut->nSize = sbut->nMinSize; - - if ((UINT)sbut->nSize > (UINT)sbut->nMaxSize) - sbut->nSize = sbut->nMaxSize; - - - butsize1 -= (oldsize - sbut->nSize); - } - } - } - -} -#endif -#endif - -// -// We must allocate from in the non-client area for our scrollbars -// Call the default window procedure first, to get the borders (if any) -// allocated some space, then allocate the space for the scrollbars -// if they fit -// -static LRESULT NCCalcSize(SCROLLWND *sw, HWND hwnd, WPARAM wParam, LPARAM lParam) -{ - NCCALCSIZE_PARAMS *nccsp; - RECT *rect; - RECT oldrect; - SCROLLBAR *sb; - LRESULT ret; - DWORD dwStyle; - - //Regardless of the value of fCalcValidRects, the first rectangle - //in the array specified by the rgrc structure member of the - //NCCALCSIZE_PARAMS structure contains the coordinates of the window, - //so we can use the exact same code to modify this rectangle, when - //wParam is TRUE and when it is FALSE. - nccsp = (NCCALCSIZE_PARAMS *)lParam; - rect = &nccsp->rgrc[0]; - oldrect = *rect; - - dwStyle = GetWindowLongPtr(hwnd, GWL_STYLE); - - // TURN OFF SCROLL-STYLES. - if ( dwStyle & (WS_VSCROLL|WS_HSCROLL)) - { - sw->bPreventStyleChange = TRUE; - SetWindowLongPtr(hwnd, GWL_STYLE, dwStyle & ~(WS_VSCROLL|WS_HSCROLL)); - } - - //call the default procedure to get the borders allocated - ret = mir_callNextSubclass(hwnd, CoolSBWndProc, WM_NCCALCSIZE, wParam, lParam); - - // RESTORE PREVIOUS STYLES (if present at all) - if ( dwStyle & (WS_VSCROLL|WS_HSCROLL)) - { - SetWindowLongPtr(hwnd, GWL_STYLE, dwStyle); - sw->bPreventStyleChange = FALSE; - } - - // calculate what the size of each window border is, - sw->cxLeftEdge = rect->left - oldrect.left; - sw->cxRightEdge = oldrect.right - rect->right; - sw->cyTopEdge = rect->top - oldrect.top; - sw->cyBottomEdge = oldrect.bottom - rect->bottom; - - sb = &sw->sbarHorz; - - //if there is room, allocate some space for the horizontal scrollbar - //NOTE: Change the ">" to a ">=" to make the horz bar totally fill the - //window before disappearing - if ((sb->fScrollFlags & CSBS_VISIBLE) && -#ifdef COOLSB_FILLWINDOW - rect->bottom - rect->top >= GetScrollMetric(sb, SM_CYHORZSB)) -#else - rect->bottom - rect->top > GetScrollMetric(sb, SM_CYHORZSB)) -#endif - { - rect->bottom -= GetScrollMetric(sb, SM_CYHORZSB); - sb->fScrollVisible = TRUE; - } - else - sb->fScrollVisible = FALSE; - - sb = &sw->sbarVert; - - //if there is room, allocate some space for the vertical scrollbar - if ((sb->fScrollFlags & CSBS_VISIBLE) && - rect->right - rect->left >= GetScrollMetric(sb, SM_CXVERTSB)) - { - if (sw->fLeftScrollbar) - rect->left += GetScrollMetric(sb, SM_CXVERTSB); - else - rect->right -= GetScrollMetric(sb, SM_CXVERTSB); - - sb->fScrollVisible = TRUE; - } - else - sb->fScrollVisible = FALSE; - -#ifdef INCLUDE_BUTTONS -#ifdef RESIZABLE_BUTTONS - ResizeButtonsToFit(sw, &sw->sbarHorz, hwnd); - ResizeButtonsToFit(sw, &sw->sbarVert, hwnd); -#endif -#endif - - //don't return a value unless we actually modify the other rectangles - //in the NCCALCSIZE_PARAMS structure. In this case, we return 0 - //no matter what the value of fCalcValidRects is - return ret;//FALSE; -} - -// -// used for hot-tracking over the scroll buttons -// -static LRESULT NCMouseMove(SCROLLWND *sw, HWND hwnd, WPARAM wHitTest, LPARAM lParam) -{ - //install a timer for the mouse-over events, if the mouse moves - //over one of the scrollbars -#ifdef HOT_TRACKING - hwndCurCoolSB = hwnd; - if (wHitTest == HTHSCROLL) - { - if (uMouseOverScrollbar == SB_HORZ) - return mir_callNextSubclass(hwnd, CoolSBWndProc, WM_NCMOUSEMOVE, wHitTest, lParam); - - uLastHitTestPortion = HTSCROLL_NONE; - uHitTestPortion = HTSCROLL_NONE; - GetScrollRect(sw, SB_HORZ, hwnd, &MouseOverRect); - uMouseOverScrollbar = SB_HORZ; - uMouseOverId = SetTimer(hwnd, COOLSB_TIMERID3, COOLSB_TIMERINTERVAL3, 0); - - NCPaint(sw, hwnd, 1, 0); - } - else if (wHitTest == HTVSCROLL) - { - if (uMouseOverScrollbar == SB_VERT) - return mir_callNextSubclass(hwnd, CoolSBWndProc, WM_NCMOUSEMOVE, wHitTest, lParam); - - uLastHitTestPortion = HTSCROLL_NONE; - uHitTestPortion = HTSCROLL_NONE; - GetScrollRect(sw, SB_VERT, hwnd, &MouseOverRect); - uMouseOverScrollbar = SB_VERT; - uMouseOverId = SetTimer(hwnd, COOLSB_TIMERID3, COOLSB_TIMERINTERVAL3, 0); - - NCPaint(sw, hwnd, 1, 0); - } - -#endif //HOT_TRACKING - return mir_callNextSubclass(hwnd, CoolSBWndProc, WM_NCMOUSEMOVE, wHitTest, lParam); -} - -// -// Timer routine to generate scrollbar messages -// -static LRESULT CoolSB_Timer(SCROLLWND *swnd, HWND hwnd, WPARAM wTimerId, LPARAM lParam) -{ - //let all timer messages go past if we don't have a timer installed ourselves - if (uScrollTimerId == 0 && uMouseOverId == 0) - return mir_callNextSubclass(hwnd, CoolSBWndProc, WM_TIMER, wTimerId, lParam); - -#ifdef HOT_TRACKING - //mouse-over timer - if (wTimerId == COOLSB_TIMERID3) - { - POINT pt; - RECT rect, winrect; - HDC hdc; - SCROLLBAR *sbar; - - if (swnd->fThumbTracking) - return 0; - - //if the mouse moves outside the current scrollbar, - //then kill the timer.. - GetCursorPos(&pt); - - if ( !PtInRect(&MouseOverRect, pt)) - { - KillTimer(hwnd, uMouseOverId); - uMouseOverId = 0; - uMouseOverScrollbar = COOLSB_NONE; - uLastHitTestPortion = HTSCROLL_NONE; - - uHitTestPortion = HTSCROLL_NONE; - NCPaint(swnd, hwnd, 1, 0); - } - else - { - if (uMouseOverScrollbar == SB_HORZ) - { - sbar = &swnd->sbarHorz; - uHitTestPortion = GetHorzPortion(sbar, &MouseOverRect, pt.x, pt.y); - } - else - { - sbar = &swnd->sbarVert; - uHitTestPortion = GetVertPortion(sbar, &MouseOverRect, pt.x, pt.y); - } - - if (uLastHitTestPortion != uHitTestPortion) - { - rect = MouseOverRect; - GetRealScrollRect(sbar, &rect); - - GetWindowRect(hwnd, &winrect); - OffsetRect(&rect, -winrect.left, -winrect.top); - - hdc = GetWindowDC(hwnd); - NCDrawScrollbar(sbar, hwnd, hdc, &rect, HTSCROLL_NONE); - ReleaseDC(hwnd, hdc); - } - - uLastHitTestPortion = uHitTestPortion; - } - - return 0; - } -#endif // HOT_TRACKING - - //if the first timer goes off, then we can start a more - //regular timer interval to auto-generate scroll messages - //this gives a slight pause between first pressing the scroll arrow, and the - //actual scroll starting - if (wTimerId == COOLSB_TIMERID1) - { - KillTimer(hwnd, uScrollTimerId); - uScrollTimerId = SetTimer(hwnd, COOLSB_TIMERID2, COOLSB_TIMERINTERVAL2, 0); - return 0; - } - //send the scrollbar message repeatedly - else if (wTimerId == COOLSB_TIMERID2) - { - //need to process a spoof WM_MOUSEMOVE, so that - //we know where the mouse is each time the scroll timer goes off. - //This is so we can stop sending scroll messages if the thumb moves - //under the mouse. - POINT pt; - GetCursorPos(&pt); - ScreenToClient(hwnd, &pt); - - MouseMove(swnd, hwnd, MK_LBUTTON, MAKELPARAM(pt.x, pt.y)); - - if (uScrollTimerPortion != HTSCROLL_NONE) - SendScrollMessage(hwnd, uScrollTimerMsg, uScrollTimerPortion, 0); - - return 0; - } - - return mir_callNextSubclass(hwnd, CoolSBWndProc, WM_TIMER, wTimerId, lParam); -} - -// -// We must intercept any calls to SetWindowLongPtr, to check if -// left-scrollbars are taking effect or not -// -static LRESULT CoolSB_StyleChange(SCROLLWND *swnd, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - STYLESTRUCT *ss = (STYLESTRUCT *)lParam; - - if (wParam == GWL_EXSTYLE) - { - if (ss->styleNew & WS_EX_LEFTSCROLLBAR) - swnd->fLeftScrollbar = TRUE; - else - swnd->fLeftScrollbar = FALSE; - } - - return mir_callNextSubclass(hwnd, CoolSBWndProc, msg, wParam, lParam); -} - -static UINT curTool = -1; -static LRESULT CoolSB_Notify(SCROLLWND* /*swnd*/, HWND hwnd, WPARAM wParam, LPARAM lParam) -{ -#ifdef COOLSB_TOOLTIPS - - NMTTDISPINFO *nmdi = (NMTTDISPINFO *)lParam; - - if (nmdi->hdr.hwndFrom == swnd->hwndToolTip && - nmdi->hdr.code == TTN_GETDISPINFO) - { - //convert the tooltip notify from a "ISHWND" style - //request to an id-based request. - //We do this because our tooltip is a window-style - //tip, with no tools, and the GETDISPINFO request must - //indicate which button to retrieve the text for - //nmdi->hdr.idFrom = curTool; - nmdi->hdr.idFrom = curTool; - nmdi->hinst = GetModuleHandle(0); - nmdi->uFlags &= ~TTF_IDISHWND; - } -#endif //COOLSB_TOOLTIPS - - return mir_callNextSubclass(hwnd, CoolSBWndProc, WM_NOTIFY, wParam, lParam); -} - -static LRESULT SendToolTipMessage0(HWND hwndTT, UINT message, WPARAM wParam, LPARAM lParam) -{ - return SendMessage(hwndTT, message, wParam, lParam); -} - -#ifdef COOLSB_TOOLTIPS -#define SendToolTipMessage SendToolTipMessage0 -#else -#define SendToolTipMessage 1 ? (void)0 : SendToolTipMessage0 -#endif - - -// -// We must intercept any calls to SetWindowLongPtr, to make sure that -// the user does not set the WS_VSCROLL or WS_HSCROLL styles -// -static LRESULT CoolSB_SetCursor(SCROLLWND* /*swnd*/, HWND hwnd, WPARAM wParam, LPARAM lParam) -{ -#ifdef INCLUDE_BUTTONS - UINT lo = LOWORD(lParam); - UINT hi = HIWORD(lParam); - UINT xy; - RECT rect; - SCROLLBAR *sbar; - SCROLLBUT *sbut; - POINT pt; - UINT id; - static UINT lastid; - -#ifdef HIDE_CURSOR_AFTER_MOUSEUP - static UINT lastmsg; - if (lastmsg == WM_LBUTTONDOWN) - { - lastmsg = hi; - return mir_callNextSubclass(hwnd, CoolSBWndProc, WM_SETCURSOR, wParam, lParam); - } - else - lastmsg = hi; -#endif - - //if we are over either or our scrollbars - if (lo == HTHSCROLL || lo == HTVSCROLL) - { - xy = GetMessagePos(); - pt.x = LOWORD(xy); - pt.y = HIWORD(xy); - - if (lo == HTHSCROLL) - { - sbar = &swnd->sbarHorz; - GetScrollRect(swnd, SB_HORZ, hwnd, &rect); - id = GetHorzPortion(sbar, hwnd, &rect, pt.x, pt.y); - } - else - { - sbar = &swnd->sbarVert; - GetScrollRect(swnd, SB_VERT, hwnd, &rect); - id = GetVertPortion(sbar, hwnd, &rect, pt.x, pt.y); - } - - if (id != HTSCROLL_INSERTED) - { - if (swnd->hwndToolTip != 0) - { - SendToolTipMessage(swnd->hwndToolTip, TTM_ACTIVATE, FALSE, 0); - SendToolTipMessage(swnd->hwndToolTip, TTM_POP, 0, 0); - } - - return mir_callNextSubclass(hwnd, CoolSBWndProc, WM_SETCURSOR, wParam, lParam); - } - - if (swnd->hwndToolTip != 0) - { - SendToolTipMessage(swnd->hwndToolTip, TTM_ACTIVATE, TRUE, 0); - } - - //set the cursor if one has been specified - if ((id = GetButtonFromPt(sbar, &rect, pt, TRUE)) != -1) - { - sbut = &sbar->sbButtons[id]; - curTool = sbut->uCmdId; - - if (lastid != id && swnd->hwndToolTip != 0) - { - if (IsWindowVisible(swnd->hwndToolTip)) - SendToolTipMessage(swnd->hwndToolTip, TTM_UPDATE, TRUE, 0); - } - - lastid = id; - - if (sbut->hCurs != 0) - { - SetCursor(sbut->hCurs); - return 0; - } - } - else - { - curTool = -1; - lastid = -1; - } - } - else if (swnd->hwndToolTip != 0) - { - SendToolTipMessage(swnd->hwndToolTip, TTM_ACTIVATE, FALSE, 0); - SendToolTipMessage(swnd->hwndToolTip, TTM_POP, 0, 0); - } - -#endif //INCLUDE_BUTTONS - return mir_callNextSubclass(hwnd, CoolSBWndProc, WM_SETCURSOR, wParam, lParam); -} - - -// -// Send the specified message to the tooltip control -// -static void __stdcall RelayMouseEvent(HWND hwnd, HWND hwndToolTip, UINT event) -{ -#ifdef COOLSB_TOOLTIPS - MSG msg; - - CoolSB_ZeroMemory(&msg, sizeof(MSG)); - msg.hwnd = hwnd; - msg.message = event; - - SendMessage(hwndToolTip, TTM_RELAYEVENT, 0, (LONG)&msg); -#else - UNREFERENCED_PARAMETER(hwnd); - UNREFERENCED_PARAMETER(hwndToolTip); - UNREFERENCED_PARAMETER(event); -#endif -} - - -// -// CoolScrollbar subclass procedure. -// Handle all messages needed to mimick normal windows scrollbars -// -LRESULT CALLBACK CoolSBWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - SCROLLWND *swnd = GetScrollWndFromHwnd(hwnd); - static int count; - - switch(message) { - case WM_NCDESTROY: - //this should NEVER be called, because the user - //should have called Uninitialize() themselves. - - //However, if the user tries to call Uninitialize().. - //after this window is destroyed, this window's entry in the lookup - //table will not be there, and the call will fail - UninitializeCoolSB(hwnd); - - //we must call the original window procedure, otherwise it - //will never get the WM_NCDESTROY message, and it wouldn't - //be able to clean up etc. - return mir_callNextSubclass(hwnd, CoolSBWndProc, message, wParam, lParam); - - case WM_NCCALCSIZE: - return NCCalcSize(swnd, hwnd, wParam, lParam); - - case WM_NCPAINT: - return NCPaint(swnd, hwnd, wParam, lParam); - - case WM_NCHITTEST: - return NCHitTest(swnd, hwnd, wParam, lParam); - - case WM_NCRBUTTONDOWN: case WM_NCRBUTTONUP: - case WM_NCMBUTTONDOWN: case WM_NCMBUTTONUP: - RelayMouseEvent(hwnd, swnd->hwndToolTip, (WM_MOUSEMOVE-WM_NCMOUSEMOVE) + (message)); - if (wParam == HTHSCROLL || wParam == HTVSCROLL) - return 0; - else - break; - - case WM_NCLBUTTONDBLCLK: - //TRACE("WM_NCLBUTTONDBLCLK %d\n", count++); - if (wParam == HTHSCROLL || wParam == HTVSCROLL) - return NCLButtonDown(swnd, hwnd, wParam, lParam); - else - break; - - case WM_NCLBUTTONDOWN: - //TRACE("WM_NCLBUTTONDOWN%d\n", count++); - RelayMouseEvent(hwnd, swnd->hwndToolTip, WM_LBUTTONDOWN); - return NCLButtonDown(swnd, hwnd, wParam, lParam); - - - case WM_LBUTTONUP: - //TRACE("WM_LBUTTONUP %d\n", count++); - RelayMouseEvent(hwnd, swnd->hwndToolTip, WM_LBUTTONUP); - return LButtonUp(swnd, hwnd, wParam, lParam); - - case WM_NOTIFY: - return CoolSB_Notify(swnd, hwnd, wParam, lParam); - - //Mouse moves are received when we set the mouse capture, - //even when the mouse moves over the non-client area - case WM_MOUSEMOVE: - //TRACE("WM_MOUSEMOVE %d\n", count++); - return MouseMove(swnd, hwnd, wParam, lParam); - - case WM_TIMER: - return CoolSB_Timer(swnd, hwnd, wParam, lParam); - - //case WM_STYLECHANGING: - // return CoolSB_StyleChange(swnd, hwnd, WM_STYLECHANGING, wParam, lParam); - case WM_STYLECHANGED: - - if (swnd->bPreventStyleChange) - { - // the NCPAINT handler has told us to eat this message! - return 0; - } - else - { - if (message == WM_STYLECHANGED) - return CoolSB_StyleChange(swnd, hwnd, WM_STYLECHANGED, wParam, lParam); - else - break; - } - - case WM_NCMOUSEMOVE: - { - static LONG_PTR lastpos = -1; - - //TRACE("WM_NCMOUSEMOVE %d\n", count++); - - //The problem with NCMOUSEMOVE is that it is sent continuously - //even when the mouse is stationary (under win2000 / win98) - // - //Tooltips don't like being sent a continous stream of mouse-moves - //if the cursor isn't moving, because they will think that the mouse - //is moving position, and the internal timer will never expire - // - if (lastpos != lParam) - { - RelayMouseEvent(hwnd, swnd->hwndToolTip, WM_MOUSEMOVE); - lastpos = lParam; - } - } - - return NCMouseMove(swnd, hwnd, wParam, lParam); - - - case WM_SETCURSOR: - return CoolSB_SetCursor(swnd, hwnd, wParam, lParam); - - case WM_CAPTURECHANGED: - break; - - default: - break; - } - - return mir_callNextSubclass(hwnd, CoolSBWndProc, message, wParam, lParam); -} - diff --git a/plugins/Clist_nicer/src/Coolsb/coolscroll.h b/plugins/Clist_nicer/src/Coolsb/coolscroll.h deleted file mode 100644 index c5fe848a83..0000000000 --- a/plugins/Clist_nicer/src/Coolsb/coolscroll.h +++ /dev/null @@ -1,232 +0,0 @@ -#ifndef _COOLSBLIB_INCLUDED -#define _COOLSBLIB_INCLUDED - -#ifdef __cplusplus -extern "C"{ -#endif - -#include -#include - -// To complement the exisiting SB_HORZ, SB_VERT, SB_BOTH -// scrollbar identifiers -#define COOLSB_NONE (-1) -#define SB_INSBUT (-2) - -// -// Arrow size defines -// -#define SYSTEM_METRIC (-1) - - -// -// general scrollbar styles -// -// use the standard ESB_DISABLE_xxx flags to represent the -// enabled / disabled states. (defined in winuser.h) -// -#define CSBS_THUMBALWAYS 4 -#define CSBS_VISIBLE 8 - -//cool scrollbar styles for Flat scrollbars -#define CSBS_NORMAL 0 -#define CSBS_FLAT 1 -#define CSBS_HOTTRACKED 2 - -// -// Button mask flags for indicating which members of SCROLLBUT -// to use during a button insertion / modification -// -#define SBBF_TYPE 0x0001 -#define SBBF_ID 0x0002 -#define SBBF_PLACEMENT 0x0004 -#define SBBF_SIZE 0x0008 -#define SBBF_BITMAP 0x0010 -#define SBBF_ENHMETAFILE 0x0020 -//#define SBBF_OWNERDRAW 0x0040 //unused at present -#define SBBF_CURSOR 0x0080 -#define SBBF_BUTMINMAX 0x0100 -#define SBBF_STATE 0x0200 - -//button styles (states) -#define SBBS_NORMAL 0 -#define SBBS_PUSHED 1 -#define SBBS_CHECKED SBBS_PUSHED - -// -// scrollbar button types -// -#define SBBT_PUSHBUTTON 1 //standard push button -#define SBBT_TOGGLEBUTTON 2 //toggle button -#define SBBT_FIXED 3 //fixed button (non-clickable) -#define SBBT_FLAT 4 //blank area (flat, with border) -#define SBBT_BLANK 5 //blank area (flat, no border) -#define SBBT_DARK 6 //dark blank area (flat) -#define SBBT_OWNERDRAW 7 //user draws the button via a WM_NOTIFY - -#define SBBT_MASK 0x1f //mask off low 5 bits - -//button type modifiers -#define SBBM_RECESSED 0x0020 //recessed when clicked (like Word 97) -#define SBBM_LEFTARROW 0x0040 -#define SBBM_RIGHTARROW 0x0080 -#define SBBM_UPARROW 0x0100 -#define SBBM_DOWNARROW 0x0200 -#define SBBM_RESIZABLE 0x0400 -#define SBBM_TYPE2 0x0800 -#define SBBM_TYPE3 0x1000 -#define SBBM_TOOLTIPS 0x2000 //currently unused (define COOLSB_TOOLTIPS in userdefs.h) - -//button placement flags -#define SBBP_LEFT 1 -#define SBBP_RIGHT 2 -#define SBBP_TOP 1 //3 -#define SBBP_BOTTOM 2 //4 - - -// -// Button command notification codes -// for sending with a WM_COMMAND message -// -#define CSBN_BASE 0 -#define CSBN_CLICKED (1 + CSBN_BASE) -#define CSBN_HILIGHT (2 + CSBN_BASE) - -// -// Minimum size in pixels of a scrollbar thumb -// -#define MINTHUMBSIZE_NT4 8 -#define MINTHUMBSIZE_2000 6 - -//define some more hittest values for our cool-scrollbar -#define HTSCROLL_LEFT (SB_LINELEFT) -#define HTSCROLL_RIGHT (SB_LINERIGHT) -#define HTSCROLL_UP (SB_LINEUP) -#define HTSCROLL_DOWN (SB_LINEDOWN) -#define HTSCROLL_THUMB (SB_THUMBTRACK) -#define HTSCROLL_PAGEGUP (SB_PAGEUP) -#define HTSCROLL_PAGEGDOWN (SB_PAGEDOWN) -#define HTSCROLL_PAGELEFT (SB_PAGELEFT) -#define HTSCROLL_PAGERIGHT (SB_PAGERIGHT) - -#define HTSCROLL_NONE (-1) -#define HTSCROLL_NORMAL (-1) - -#define HTSCROLL_INSERTED (128) -#define HTSCROLL_PRE (32 | HTSCROLL_INSERTED) -#define HTSCROLL_POST (64 | HTSCROLL_INSERTED) - -/* - - Public interface to the Cool Scrollbar library - - -*/ - -BOOL WINAPI InitializeCoolSB(HWND hwnd); -HRESULT WINAPI UninitializeCoolSB (HWND hwnd); - -BOOL WINAPI CoolSB_SetMinThumbSize(HWND hwnd, UINT wBar, UINT size); -BOOL WINAPI CoolSB_IsThumbTracking(HWND hwnd); -BOOL WINAPI CoolSB_IsCoolScrollEnabled(HWND hwnd); - -// -BOOL WINAPI CoolSB_EnableScrollBar (HWND hwnd, int wSBflags, UINT wArrows); -BOOL WINAPI CoolSB_GetScrollInfo (HWND hwnd, int fnBar, LPSCROLLINFO lpsi); -int WINAPI CoolSB_GetScrollPos (HWND hwnd, int nBar); -BOOL WINAPI CoolSB_GetScrollRange (HWND hwnd, int nBar, LPINT lpMinPos, LPINT lpMaxPos); - -// -int WINAPI CoolSB_SetScrollInfo (HWND hwnd, int fnBar, LPSCROLLINFO lpsi, BOOL fRedraw); -int WINAPI CoolSB_SetScrollPos (HWND hwnd, int nBar, int nPos, BOOL fRedraw); -int WINAPI CoolSB_SetScrollRange (HWND hwnd, int nBar, int nMinPos, int nMaxPos, BOOL fRedraw); -BOOL WINAPI CoolSB_ShowScrollBar (HWND hwnd, int wBar, BOOL fShow); - -// -// Scrollbar dimension functions -// -BOOL WINAPI CoolSB_SetSize (HWND hwnd, int wBar, int nLength, int nWidth); - -// -// Set the visual nature of a scrollbar (flat, normal etc) -// -BOOL WINAPI CoolSB_SetStyle (HWND hwnd, int wBar, UINT nStyle); -BOOL WINAPI CoolSB_SetThumbAlways (HWND hwnd, int wBar, BOOL fThumbAlways); - -// -// Scrollbar button structure, for inserted buttons only -// -typedef struct -{ - UINT fMask; //which members are in use - UINT uPlacement; //is this button to the left/right (above/below) of the scrollbar?? - UINT uCmdId; //command identifier (WM_COMMAND value to send) - UINT uButType; // - UINT uState; //toggled etc - int nSize; //size in pixels. -1 for autosize - - HBITMAP hBmp; //handle to a bitmap to use as the button face - HENHMETAFILE hEmf; //handle to an enhanced metafile - - HCURSOR hCurs; //handle to a user-supplied mouse cursor to apply - //to this button - - int nSizeReserved; //internal variable used for resizing - int nMinSize; //min size - int nMaxSize; //max size - -} SCROLLBUT; - -BOOL WINAPI CoolSB_InsertButton(HWND hwnd, int wSBflags, UINT nPos, SCROLLBUT *psb); -BOOL WINAPI CoolSB_ModifyButton(HWND hwnd, int wSBflags, UINT uItem, BOOL fByCmd, SCROLLBUT *psb); -BOOL WINAPI CoolSB_RemoveButton(HWND hwnd, int wSBflags, UINT uItem, BOOL fByCmd); -BOOL WINAPI CoolSB_GetButton (HWND hwnd, int wSBflags, UINT uItem, BOOL fByCmd, SCROLLBUT *psb); - -void WINAPI CoolSB_SetESBProc(void *proc); - -typedef struct -{ - NMHDR hdr; - DWORD dwDrawStage; - HDC hdc; - RECT rect; - UINT uItem; - UINT uState; - UINT nBar; - -} NMCSBCUSTOMDRAW; - -typedef struct -{ - NMHDR hdr; - RECT rect; - POINT pt; - UINT uCmdId; - UINT uState; - int nBar; -} NMCOOLBUTMSG; - -/* -typedef struct -{ - NMHDR hdr; - DWORD dwDrawStage; - HDC hdc; - RECT rect; - UINT uCmdId; - UINT uState; - -} NMCOOLBUTTON_CUSTOMDRAW; -*/ - - -// -// Define the WM_NOTIFY code value for cool-scrollbar custom drawing -// -#define NM_COOLSB_CUSTOMDRAW (0-0xfffU) - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/plugins/Clist_nicer/src/Coolsb/userdefs.h b/plugins/Clist_nicer/src/Coolsb/userdefs.h deleted file mode 100644 index ea7ea1fe92..0000000000 --- a/plugins/Clist_nicer/src/Coolsb/userdefs.h +++ /dev/null @@ -1,79 +0,0 @@ -#ifndef _USERDEFINES_INCLUDED -#define _USERDEFINES_INCLUDED - -/* - - Define these values to alter the various - features of the coolscroll library. If you don't want - a certain feature, then you might be able to reduce the - size of your app by a few kb... - -*/ - -/* allow inserted buttons. Without this, all button code will - be excluded, resulting in a smaller build (about 4kb less). This - may not seem much, but it is a 25% reduction! */ -//#define INCLUDE_BUTTONS - -/* Allow user-resizable buttons. Makes no difference if INCLUDE_BUTTONS - is not defined for the project */ -#define RESIZABLE_BUTTONS - -/* Include tooltip support for inserted buttons. Without this, no - tooltip requests (TTN_GETDISPINFO's) will be sent to the window */ -//#define COOLSB_TOOLTIPS - -/* Define this to include the custom-draw support */ -#define CUSTOM_DRAW - -/* Define to enable WM_NOTIFY messages to be sent for mouse event */ -#define NOTIFY_MOUSE - -/* Define this value to make the horizontal scrollbar stay visible even - if the window is sized to small vertically. Normal scrollbars always leave - a 1-pixel line of "client" area before hiding the horizontal scrollbar. This - value allows the window to be sized so the client area totally disappears if - sized too small */ -//#define COOLSB_FILLWINDOW - -/* minimum size of scrollbar before inserted buttons are - hidden to make room when the window is sized too small */ -#define MIN_COOLSB_SIZE 24 - -/* min size of scrollbar when resizing a button, before the - resize is stopped because the scrollbar has gotten too small */ -#define MINSCROLLSIZE 50 - -/* define this to display the default mouse arrow whenever the - the mouse is released over a button which has a user-defined cursor. - not really very useful, just provides a different type of feedback */ -#undef HIDE_CURSOR_AFTER_MOUSEUP - -/* enable HOT_TRACKING to provide visual feedback when the mouse - moves over a scrollbar area (like Flat Scrollbars) */ -#define HOT_TRACKING - -/* enable FLAT_SCROLLBARS to include support for flat scrollbars - note that they must be enabled by the user first of all */ -#define FLAT_SCROLLBARS - -/* a normal scrollbar "snaps" its scroll-thumb back into position if - you move the mouse too far away from the window, whilst you are - dragging the thumb, that is. #undeffing this results in the thumb - never snapping back into position, no matter how far away you move - the mouse */ -#define SNAP_THUMB_BACK - -/* distance (in pixels) the mouse must move away from the thumb - during tracking to cause the thumb bar to snap back to its - starting place. Has no effect unless SNAP_THUMB_BACK is defined */ -#define THUMBTRACK_SNAPDIST 24 - -/* maximum number of inserted buttons per bar */ -#define MAX_COOLSB_BUTS 16 - -/* maximum number of coolsb windows per application. - Set to lower if you don't need many. */ -#define MAX_COOLSB 4 - -#endif /* _USERDEFINES_INCLUDED */ \ No newline at end of file diff --git a/plugins/Clist_nicer/src/Docking.cpp b/plugins/Clist_nicer/src/Docking.cpp index 2455efa43d..cb9848878e 100644 --- a/plugins/Clist_nicer/src/Docking.cpp +++ b/plugins/Clist_nicer/src/Docking.cpp @@ -22,7 +22,7 @@ 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 "stdafx.h" #define WM_DOCKCALLBACK (WM_USER+121) #define WM_CREATEDOCKED (WM_USER+122) diff --git a/plugins/Clist_nicer/src/Include/Version.h b/plugins/Clist_nicer/src/Include/Version.h deleted file mode 100644 index babd66c1bc..0000000000 --- a/plugins/Clist_nicer/src/Include/Version.h +++ /dev/null @@ -1,14 +0,0 @@ -#define __MAJOR_VERSION 0 -#define __MINOR_VERSION 9 -#define __RELEASE_NUM 2 -#define __BUILD_NUM 4 - -#include - -#define __PLUGIN_NAME "Clist nicer" -#define __FILENAME "Clist_nicer.dll" -#define __DESCRIPTION "Displays contacts, event notifications, protocol status." -#define __AUTHOR "Pixel, egoDust, cyreve, Nightwish" -#define __AUTHOREMAIL "" -#define __AUTHORWEB "http://miranda-ng.org/p/Clist_nicer/" -#define __COPYRIGHT "Copyright 2000-2010 Miranda-IM project" diff --git a/plugins/Clist_nicer/src/Include/alphablend.h b/plugins/Clist_nicer/src/Include/alphablend.h deleted file mode 100644 index d5ce2225b1..0000000000 --- a/plugins/Clist_nicer/src/Include/alphablend.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - -Miranda NG: the free IM client for Microsoft* Windows* - -Copyright (ñ) 2012-15 Miranda NG project (http://miranda-ng.org), -Copyright (c) 2000-03 Miranda ICQ/IM 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. -*/ - -void __inline gradientVertical(UCHAR *ubRedFinal, UCHAR *ubGreenFinal, UCHAR *ubBlueFinal, - ULONG ulBitmapHeight, UCHAR ubRed, UCHAR ubGreen, UCHAR ubBlue, UCHAR ubRed2, - UCHAR ubGreen2, UCHAR ubBlue2, DWORD FLG_GRADIENT, BOOL transparent, UINT32 y, UCHAR *ubAlpha); - -void __inline gradientHorizontal( UCHAR *ubRedFinal, UCHAR *ubGreenFinal, UCHAR *ubBlueFinal, - ULONG ulBitmapWidth, UCHAR ubRed, UCHAR ubGreen, UCHAR ubBlue, UCHAR ubRed2, - UCHAR ubGreen2, UCHAR ubBlue2, DWORD FLG_GRADIENT, BOOL transparent, UINT32 x, UCHAR *ubAlpha); \ No newline at end of file diff --git a/plugins/Clist_nicer/src/Include/clc.h b/plugins/Clist_nicer/src/Include/clc.h deleted file mode 100644 index a196275b15..0000000000 --- a/plugins/Clist_nicer/src/Include/clc.h +++ /dev/null @@ -1,522 +0,0 @@ -/* - -Miranda NG: the free IM client for Microsoft* Windows* - -Copyright (ñ) 2012-15 Miranda NG project (http://miranda-ng.org), -Copyright (c) 2000-03 Miranda ICQ/IM 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. -*/ - -#define INTM_XSTATUSCHANGED (WM_USER+26) -#define INTM_METACHANGEDEVENT (WM_USER+27) -#define INTM_CODEPAGECHANGED (WM_USER+28) -#define INTM_AVATARCHANGED (WM_USER+30) -#define INTM_STATUSMSGCHANGED (WM_USER+31) -#define INTM_SORTCLC (WM_USER+32) -#define INTM_STATUSCHANGED (WM_USER+33) -#define INTM_METACHANGED (WM_USER+34) -#define INTM_INVALIDATECONTACT (WM_USER+35) -#define INTM_FORCESORT (WM_USER+36) - -#define DEFAULT_TITLEBAR_HEIGHT 18 - -#define CLS_SKINNEDFRAME 0x0800 //this control will be the main contact list (v. 0.3.4.3+ 2004/11/02) - -#define TIMERID_RENAME 10 -#define TIMERID_DRAGAUTOSCROLL 11 -#define TIMERID_INFOTIP 13 -#define TIMERID_SORT 15 -#define TIMERID_REFRESH 18 -#define TIMERID_PAINT 19 - -#define CONTACTF_ONLINE 1 -//#define CONTACTF_INVISTO 2 -//#define CONTACTF_VISTO 4 -#define CONTACTF_NOTONLIST 8 -#define CONTACTF_CHECKED 16 -#define CONTACTF_IDLE 32 -#define CONTACTF_STICKY 64 -#define CONTACTF_PRIORITY 128 - -#define STATUSMSG_XSTATUSID 1 -#define STATUSMSG_XSTATUSNAME 2 -#define STATUSMSG_CLIST 4 -#define STATUSMSG_YIM 8 -#define STATUSMSG_GG 16 -#define STATUSMSG_XSTATUS 32 - -#define STATUSMSG_NOTFOUND 0 - -#define SMSG_MAXLEN 700 - -#define EXTRAIMAGECACHESIZE 1000 - -// extra cache contact flags - -#define ECF_RTLNICK 1 -#define ECF_RTLSTATUSMSG 2 -#define ECF_FORCEAVATAR 4 -#define ECF_HIDEAVATAR 8 -#define ECF_FORCEOVERLAY 16 -#define ECF_HIDEOVERLAY 32 -#define ECF_FORCELOCALTIME 64 -#define ECF_HIDELOCALTIME 128 -#define ECF_HASREALTIMEZONE 1024 - -// other contact flags (struct ClCContact; - -#define ECF_AVATAR 1 -#define ECF_SECONDLINE 2 - -#define DSPF_CENTERSTATUSICON 1 -#define DSPF_DIMIDLE 2 -#define DSPF_NOFFLINEAVATARS 4 -#define DSPF_SHOWLOCALTIME 8 -#define DSPF_LOCALTIMESELECTIVE 16 -#define DSPF_DONTSEPARATEOFFLINE 32 -#define DSPF_CENTERGROUPNAMES 64 - -/* Extra icons settings */ -typedef struct _OrderTreeData -{ - BYTE ID; - const TCHAR * Name; - BYTE Position; - BOOL Visible; - BOOL fReserved; -} *PORDERTREEDATA, ORDERTREEDATA; - -struct TExtraCache -{ - MCONTACT hContact; - HANDLE hTimeZone; - BYTE valid; - TCHAR *statusMsg; - BYTE bStatusMsgValid; - DWORD dwCFlags; - DWORD dwDFlags; // display flags for caching only - StatusItems_t *status_item, *proto_status_item; - DWORD dwLastMsgTime; - DWORD msgFrequency; - BOOL isChatRoom; -}; - -struct ClcContact : public ClcContactBase -{ - BOOL bIsMeta; - BYTE xStatus; - int xStatusIcon; - MCONTACT hSubContact; - char *metaProto; - DWORD codePage; - WORD wStatus; - int avatarLeft, extraIconRightBegin; - int isRtl; - DWORD cFlags; - BYTE bSecondLine; - - avatarCacheEntry *ace; - TExtraCache* pExtra; -}; - -#define DRAGSTAGE_NOTMOVED 0 -#define DRAGSTAGE_ACTIVE 1 -#define DRAGSTAGEM_STAGE 0x00FF -#define DRAGSTAGEF_MAYBERENAME 0x8000 -#define DRAGSTAGEF_OUTSIDE 0x4000 - -#define FONTID_CONTACTS 0 -#define FONTID_INVIS 1 -#define FONTID_OFFLINE 2 -#define FONTID_NOTONLIST 3 -#define FONTID_GROUPS 4 -#define FONTID_GROUPCOUNTS 5 -#define FONTID_DIVIDERS 6 -#define FONTID_OFFINVIS 7 -#define FONTID_STATUS 8 -#define FONTID_FRAMETITLE 9 -#define FONTID_EVENTAREA 10 -#define FONTID_TIMESTAMP 11 -#define FONTID_LAST FONTID_TIMESTAMP - -struct ClcData : public ClcDataBase -{ - int *row_heights; - int row_heights_size; - int row_heights_allocated; - - int row_border; - int min_row_heigh, group_row_height; - - int currentFontID; - int rightMargin; - BYTE SelectMode; - BYTE isMultiSelect; - HWND hwndParent; - DWORD lastSort; - BOOL bNeedPaint, bisEmbedded, bHideSubcontacts; - DWORD lastRepaint; - BOOL forceScroll; - int oldSelection; -}; - -//#define CLUI_FRAME_SHOWTOPBUTTONS 1 -#define CLUI_FRAME_SHOWBOTTOMBUTTONS 2 -#define CLUI_SHOWCLIENTICONS 4 -//#define CLUI_SHOWVISI 8 -#define CLUI_FRAME_CLISTSUNKEN 16 -#define CLUI_SHOWXSTATUS 32 -#define CLUI_FRAME_BUTTONSFLAT 64 -#define CLUI_FRAME_BUTTONSCLASSIC 128 -#define CLUI_USEMETAICONS 256 -#define CLUI_FRAME_AUTOHIDENOTIFY 512 -#define CLUI_FRAME_USEXSTATUSASSTATUS 1024 -#define CLUI_STICKYEVENTS 2048 -#define CLUI_FRAME_SBARSHOW 4096 -#define CLUI_STATUSASTEXT 8192 -#define CLUI_FULLROWSELECT 16384 -#define CLUI_FRAME_EVENTAREASUNKEN 32768 -//#define CLUI_FRAME_BUTTONBARSUNKEN 65536 -#define CLUI_FRAME_AVATARS 0x20000 -#define CLUI_FRAME_AVATARSLEFT 0x40000 -#define CLUI_FRAME_GDIPLUS 0x80000 -#define CLUI_FRAME_AVATARBORDER 0x100000 -#define CLUI_FRAME_STATUSICONS 0x200000 -#define CLUI_FRAME_AVATARSRIGHTWITHNICK 0x400000 -#define CLUI_FRAME_TRANSPARENTAVATAR 0x800000 -#define CLUI_FRAME_ROUNDAVATAR 0x1000000 -#define CLUI_FRAME_ALWAYSALIGNNICK 0x2000000 -#define CLUI_FRAME_AVATARSRIGHT 0x4000000 -#define CLUI_FRAME_SHOWSTATUSMSG 0x8000000 -#define CLUI_FRAME_OVERLAYICONS 0x10000000 -#define CLUI_FRAME_SELECTIVEICONS 0x20000000 -#define CLUI_FRAME_ROUNDEDFRAME 0x40000000 -#define CLUI_FRAME_NOGROUPICON 0x80000000 - -#define MULTIROW_NEVER 0 -#define MULTIROW_ALWAYS 1 -#define MULTIROW_IFSPACE 2 -#define MULTIROW_IFNEEDED 3 - -#define CLC_GROUPALIGN_LEFT 0 -#define CLC_GROUPALIGN_RIGHT 1 -#define CLC_GROUPALIGN_AUTO 2 - -struct TCluiData { - DWORD dwFlags; - DWORD topOffset, bottomOffset; - int statusBarHeight; - int soundsOff; - BYTE tabSRMM_Avail; - BYTE bAvatarServiceAvail; - HICON hIconConnecting; - DWORD winFlags; - DWORD winFlagsEx; - int notifyActive; - int hIconNotify; - HMENU hMenuNotify; - int iLastEventAdded; - int wNextMenuID; - MCONTACT hUpdateContact; - DWORD sortTimer; - BOOL forceResize; - BOOL neeedSnap; - COLORREF avatarBorder; - HBRUSH hBrushAvatarBorder, hBrushColorKey; - HBRUSH hBrushCLCBk; - DWORD avatarRadius; - int avatarSize; - BOOL bForceRefetchOnPaint; - BYTE dualRowMode; - BYTE avatarPadding; - BYTE cornerRadius; - BYTE isTransparent; - BYTE alpha, autoalpha; - BYTE fadeinout; - BYTE autosize; - BYTE gapBetweenFrames; - BYTE titleBarHeight; - BYTE bClipBorder, bRowSpacing; - HBITMAP bmpBackground, hbmBgOld, hbmBg; - HBITMAP hbmToolbar, hbmToolbarOld; - HDC hdcBg; - HDC hdcPic; - HDC hdcToolbar; - HBITMAP hbmPicOld; - BITMAP bminfoBg; - SIZE dcSize; - POINT ptW; - BOOL bWallpaperMode; - BOOL bNoOfflineAvatars; - BOOL bEventAreaEnabled; - BOOL bFullTransparent; - BOOL bDblClkAvatars; - BOOL bApplyIndentToBg; - BOOL bEqualSections; - DWORD bFilterEffective; - BOOL bCenterStatusIcons; - BOOL bSkinnedToolbar; - BOOL bSkinnedStatusBar; - BOOL bUsePerProto; - BOOL bOverridePerStatusColors; - BOOL bDontSeparateOffline; - TCHAR groupFilter[2048]; - char protoFilter[2048]; - char varFilter[2048]; - DWORD lastMsgFilter; - char current_viewmode[256], old_viewmode[256]; - BYTE boldHideOffline; - DWORD statusMaskFilter; - DWORD stickyMaskFilter; - DWORD filterFlags; - COLORREF colorkey; - BOOL bMetaEnabled; - BOOL bSecIMAvail; - BOOL bNoTrayTips; - BOOL bShowLocalTime; - BOOL bShowLocalTimeSelective; - BOOL bShowXStatusOnSbar; - BOOL bLayeredHack; - HPEN hPen3DBright, hPen3DDark; - BYTE bSkinnedButtonMode; - BYTE bFirstRun; - BYTE bUseDCMirroring; - BYTE bCLeft, bCRight, bCTop, bCBottom; - BYTE fullyInited; - BYTE bAutoExpandGroups; - SIZE szOldCTreeSize; - BYTE bWantFastGradients, bUseFastGradients; - BYTE sortOrder[3]; - BYTE bGroupAlign; - BYTE bSkinnedScrollbar; - DWORD langPackCP; - BOOL fOnDesktop; - int group_padding; - DWORD t_now; - BOOL realTimeSaving; - TCHAR tszProfilePath[MAX_PATH]; - FILETIME ft; - SYSTEMTIME st; -}; - -#define SORTBY_NAME 1 -#define SORTBY_PROTO 2 -#define SORTBY_STATUS 3 -#define SORTBY_LASTMSG 4 -#define SORTBY_FREQUENCY 5 -#define SORTBY_PRIOCONTACTS 6 - -struct IconDesc -{ - char *szName; - char *szDesc; - int uId; // icon ID -}; - -struct NotifyMenuItemExData -{ - MCONTACT hContact; - int iIcon; // icon index in the image list - HICON hIcon; // corresponding icon handle - MEVENT hDbEvent; -}; - -// #define NOTIFY_HEIGHT 24 - -struct CluiTopButton -{ - int ctrlid; - char *pszButtonID, *pszButtonDn, *pszButtonName; - int isPush, isVis, isAction; - HANDLE hButton; - HWND hwndButton; -}; - -struct TrayIconInfo -{ - union - { - HICON hIcon; - int iIcon; - }; -}; - -struct protoMenu -{ - char protoName[50]; - UINT menuID; - BOOL added; - HICON hIcon; -}; - -// clcidents.c -int FindItem(HWND hwnd, struct ClcData *dat, HANDLE hItem, ClcContact **contact, ClcGroup **subgroup, int *isVisible); -HANDLE ContactToItemHandle(ClcContact *contact, DWORD *nmFlags); - -// clcitems.c -void RebuildEntireList(HWND hwnd, struct ClcData *dat); -DWORD INTSORT_GetLastMsgTime(MCONTACT hContact); - -// clcmsgs.c -LRESULT ProcessExternalMessages(HWND hwnd, struct ClcData *dat, UINT msg, WPARAM wParam, LPARAM lParam); - -// clcutils.c -void SetGroupExpand(HWND hwnd, struct ClcData *dat, ClcGroup *group, int newState); -void DoSelectionDefaultAction(HWND hwnd, struct ClcData *dat); -int FindRowByText(HWND hwnd, struct ClcData *dat, const TCHAR *text, int prefixOk); -void BeginRenameSelection(HWND hwnd, struct ClcData *dat); -int HitTest(HWND hwnd, struct ClcData *dat, int testx, int testy, ClcContact **contact, ClcGroup **group, DWORD *flags); -void ScrollTo(HWND hwnd, struct ClcData *dat, int desty, int noSmooth); -void RecalcScrollBar(HWND hwnd, struct ClcData *dat); -size_t MY_pathToRelative(const TCHAR *pSrc, TCHAR *pOut); -size_t MY_pathToAbsolute(const TCHAR *pSrc, TCHAR *pOut); - -#define DROPTARGET_OUTSIDE 0 -#define DROPTARGET_ONSELF 1 -#define DROPTARGET_ONNOTHING 2 -#define DROPTARGET_ONGROUP 3 -#define DROPTARGET_ONCONTACT 4 -#define DROPTARGET_INSERTION 5 -int GetDropTargetInformation(HWND hwnd, struct ClcData *dat, POINT pt); -void LoadClcOptions(HWND hwnd, struct ClcData *dat, BOOL bFirst); -void RecalculateGroupCheckboxes(HWND hwnd, struct ClcData *dat); -void SetGroupChildCheckboxes(ClcGroup *group, int checked); -BYTE GetCachedStatusMsg(TExtraCache* p, char *szProto); -int __fastcall GetStatusOnlineness(int status); -void GetExtendedInfo(ClcContact *contact, struct ClcData *dat); -extern LRESULT CALLBACK NewStatusBarWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); -void HideShowNotifyFrame(); -DWORD GetCLUIWindowStyle(BYTE style); -void ApplyCLUIBorderStyle(); - -int FrameNCCalcSize(HWND hwnd, WNDPROC oldWndProc, WPARAM wParam, LPARAM lParam, BOOL hasTitleBar); -int FrameNCPaint(HWND hwnd, WNDPROC oldWndProc, WPARAM wParam, LPARAM lParam, BOOL hasTitleBar); - -void FreeProtocolData( void ); - -void GetClientID(ClcContact *contact, char *client); -int LoadCLCButtonModule(void); -void SetButtonStates(); -void ConfigureCLUIGeometry(int mode); -void IcoLibReloadIcons(); -int CompareContacts(const ClcContact* p1, const ClcContact* p2); -void PaintNotifyArea(HDC hDC, RECT *rc); -int AvatarChanged(WPARAM wParam, LPARAM lParam); -void ConfigureFrame(); -void ConfigureEventArea(); -void ClearIcons(int mode); -void SkinDrawBg(HWND hwnd, HDC hdc); -int GetBasicFontID(ClcContact * contact); -extern int __fastcall CLVM_GetContactHiddenStatus(MCONTACT hContact, char *szStatus, struct ClcData *dat); -void CreateViewModeFrame(); -int GetExtraCache(MCONTACT hContact, char *szProto); -void ReloadExtraInfo(MCONTACT hContact); -void LoadAvatarForContact(ClcContact *p); -void ApplyViewMode(const char *name); - -void ClcSetButtonState(int ctrlId, int status); -HWND ClcGetButtonWindow(int ctrlid); - -// clcpaint.c -void PaintClc(HWND hwnd, struct ClcData *dat, HDC hdc, RECT *rcPaint); -void __inline PaintItem(HDC hdcMem, ClcGroup *group, ClcContact *contact, int indent, int y, struct ClcData *dat, int index, HWND hwnd, DWORD style, RECT *clRect, BOOL *bFirstNGdrawn, int groupCountsFontTopShift, int rowHeight); -void Reload3dBevelColors(); -void ReloadThemedOptions(); -void SetButtonToSkinned(); -void RTL_DetectAndSet(ClcContact *contact, MCONTACT hContact); -void RTL_DetectGroupName(ClcContact *group); -void CLN_LoadAllIcons(BOOL mode); -void ReloadSkinItemsToCache(); - -// clcopts.c -int ClcOptInit(WPARAM wParam, LPARAM lParam); -void GetFontSetting(int i, LOGFONTA *lf, COLORREF *colour); -void CluiProtocolStatusChanged(int, const char*); - -void LoadSkinItemToCache(struct TExtraCache *cEntry); - -// Docking.c - -int Docking_IsDocked(WPARAM wParam, LPARAM lParam); - -// Buttons - -#define BUTTONSETIMLICON (WM_USER+20) -#define BUTTONSETSKINNED (WM_USER+21) -#define BUTTONSETBTNITEM (WM_USER+22) -#define BUTTONSETTTBUTTON (WM_USER+23) - -// Menus - -void IMG_DeleteItems(); -int CoolSB_SetupScrollBar(); - -#define NIIF_INTERN_UNICODE 0x00000100 - -#define SETTING_WINDOWSTYLE_DEFAULT 0 - -#define SETTING_TRAYICON_SINGLE 0 -#define SETTING_TRAYICON_CYCLE 1 -#define SETTING_TRAYICON_MULTI 2 - -#define SETTING_STATE_HIDDEN 0 -#define SETTING_STATE_MINIMIZED 1 -#define SETTING_STATE_NORMAL 2 - -#define SETTING_BRINGTOFRONT_DEFAULT 0 - -#define SETTING_WINDOWSTYLE_TOOLWINDOW 1 -#define SETTING_WINDOWSTYLE_THINBORDER 2 -#define SETTING_WINDOWSTYLE_NOBORDER 3 - -#define CLCHT_ONAVATAR 0x2000 -#define CLCHT_ONITEMSPACE 0x4000 - -#define CLM_SETEXTRAIMAGEINT (CLM_FIRST+101) -#define CLM_SETSTICKY (CLM_FIRST+100) -#define CLM_ISMULTISELECT (CLM_FIRST+102) -#define CLM_SETEXTRAIMAGEINTMETA (CLM_FIRST+104) -#define CLM_GETSTATUSMSG (CLM_FIRST+105) -#define CLM_SETHIDESUBCONTACTS (CLM_FIRST+106) -#define CLM_TOGGLEPRIORITYCONTACT (CLM_FIRST+107) -#define CLM_QUERYPRIORITYCONTACT (CLM_FIRST+108) - -#define IDC_RESETMODES 110 -#define IDC_SELECTMODE 108 -#define IDC_CONFIGUREMODES 109 - -#define NR_CLIENTS 40 - -typedef BOOL (WINAPI *PGF)(HDC, PTRIVERTEX, ULONG, PVOID, ULONG, ULONG); - -#define IDC_STBHIDEOFFLINE IDC_TBHIDEOFFLINE - 20 -#define IDC_STBHIDEGROUPS IDC_TBHIDEGROUPS - 20 -#define IDC_STBSOUND IDC_TBSOUND - 20 -#define IDC_STBFINDANDADD IDC_TBFINDANDADD - 20 -#define IDC_STBOPTIONS IDC_TBOPTIONS - 20 -#define IDC_STBMINIMIZE IDC_TBMINIMIZE - 20 -#define IDC_STABSRMMSLIST IDC_TABSRMMSLIST - 20 -#define IDC_STABSRMMMENU IDC_TABSRMMMENU - 20 -#define IDC_STBSELECTVIEWMODE IDC_TBSELECTVIEWMODE - 20 -#define IDC_STBCLEARVIEWMODE IDC_TBCLEARVIEWMODE - 20 -#define IDC_STBCONFIGUREVIEWMODE IDC_TBCONFIGUREVIEWMODE - 20 -#define IDC_STBTOPMENU IDC_TBTOPMENU - 20 -#define IDC_STBTOPSTATUS IDC_TBTOPSTATUS - 20 -#define IDC_STBFOLDER IDC_TBFOLDER - 20 -#define IDC_STBPOPUP IDC_TBPOPUP - 20 -#define IDC_STBACCOUNTS IDC_TBACCOUNTS - 20 diff --git a/plugins/Clist_nicer/src/Include/clist.h b/plugins/Clist_nicer/src/Include/clist.h deleted file mode 100644 index 6f9a0622ed..0000000000 --- a/plugins/Clist_nicer/src/Include/clist.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - -Miranda NG: the free IM client for Microsoft* Windows* - -Copyright (ñ) 2012-15 Miranda NG project (http://miranda-ng.org), -Copyright (c) 2000-03 Miranda ICQ/IM 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. -*/ - -void LoadContactTree(void); -int IconFromStatusMode(const char *szProto, int status, MCONTACT hContact, HICON *phIcon); -HTREEITEM GetTreeItemByHContact(MCONTACT hContact); -void SortContacts(void); - -#define CLUIINTM_REDRAW (WM_USER+100) -#define CLUIINTM_STATUSBARUPDATE (WM_USER+101) -#define CLUIINTM_REMOVEFROMTASKBAR (WM_USER+102) - -#define CLVM_FILTER_PROTOS 1 -#define CLVM_FILTER_GROUPS 2 -#define CLVM_FILTER_STATUS 4 -#define CLVM_FILTER_VARIABLES 8 -#define CLVM_STICKY_CONTACTS 16 -#define CLVM_FILTER_STICKYSTATUS 32 -#define CLVM_FILTER_LASTMSG 64 -#define CLVM_FILTER_LASTMSG_OLDERTHAN 128 -#define CLVM_FILTER_LASTMSG_NEWERTHAN 256 - -#define CLVM_PROTOGROUP_OP 1 -#define CLVM_GROUPSTATUS_OP 2 -#define CLVM_AUTOCLEAR 4 -#define CLVM_INCLUDED_UNGROUPED 8 -#define CLVM_USELASTMSG 16 - -#define CLVM_MODULE "CLVM_W" diff --git a/plugins/Clist_nicer/src/Include/commonheaders.h b/plugins/Clist_nicer/src/Include/commonheaders.h deleted file mode 100644 index a7cd57a950..0000000000 --- a/plugins/Clist_nicer/src/Include/commonheaders.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - -Miranda NG: the free IM client for Microsoft* Windows* - -Copyright (ñ) 2012-15 Miranda NG project (http://miranda-ng.org), -Copyright (c) 2000-03 Miranda ICQ/IM 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. -*/ - -#define _CRT_SECURE_NO_WARNINGS - -#undef FASTCALL - -#define TSAPI __stdcall -#define FASTCALL __fastcall - -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "resource.h" -#include "Version.h" -#include "extbackg.h" -#include "clc.h" -#include "config.h" -#include "clist.h" -#include "alphablend.h" -#include "rowheight_funcs.h" - -// shared vars -extern HINSTANCE g_hInst; -extern LONG g_cxsmIcon, g_cysmIcon; -extern LIST arStatusItems; -extern ImageItem *g_glyphItem; - -extern CLIST_INTERFACE coreCli; - -typedef int (__cdecl *pfnDrawAvatar)(HDC hdcOrig, HDC hdcMem, RECT *rc, ClcContact *contact, int y, struct ClcData *dat, int selected, WORD cstatus, int rowHeight); - -BOOL __forceinline GetItemByStatus(int status, StatusItems_t *retitem); - -void DrawAlpha(HDC hdcwnd, PRECT rc, DWORD basecolor, int alpha, DWORD basecolor2, BOOL transparent, BYTE FLG_GRADIENT, BYTE FLG_CORNER, DWORD BORDERSTYLE, ImageItem *item); - -void CustomizeButton(HWND hWnd, bool bIsSkinned, bool bIsThemed, bool bIsFlat = false, bool bIsTTButton = false); diff --git a/plugins/Clist_nicer/src/Include/config.h b/plugins/Clist_nicer/src/Include/config.h deleted file mode 100644 index c833107fe3..0000000000 --- a/plugins/Clist_nicer/src/Include/config.h +++ /dev/null @@ -1,140 +0,0 @@ -/* - -Miranda NG: the free IM client for Microsoft* Windows* - -Copyright (ñ) 2012-15 Miranda NG project (http://miranda-ng.org), -Copyright (c) 2000-03 Miranda ICQ/IM 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 - -#ifndef __CONFIG_H_ -#define __CONFIG_H_ - -#define DEFAULT_MODULE "Clist" - -#define IS_THEMED (API::sysState.isThemed) -#define IS_AERO (API::sysState.isAero) - -typedef HRESULT (WINAPI *pfnDwmExtendFrameIntoClientArea_t)(HWND hwnd, const MARGINS *margins); -typedef HRESULT (WINAPI *pfnDwmIsCompositionEnabled_t)(BOOL *); - -class CRTException : public std::runtime_error -{ -public: - CRTException(const char *szMsg, const TCHAR *szParam); - ~CRTException() {} - - void display() const; - -private: - TCHAR m_szParam[MAX_PATH]; -}; - -class cfg -{ -public: - static DWORD getDword(const MCONTACT hContact, const char *szModule, const char *szSetting, DWORD uDefault); - static DWORD getDword(const char *szModule, const char *szSetting, DWORD uDefault); - static DWORD getDword(const char *szSetting, DWORD uDefault); - - static WORD getWord(const MCONTACT hContact, const char *szModule, const char *szSetting, WORD uDefault); - static WORD getWord(const char *szModule, const char *szSetting, WORD uDefault); - static WORD getWord(const char *szSetting, WORD uDefault); - - static int getByte(const MCONTACT hContact, const char *szModule, const char *szSetting, int uDefault); - static int getByte(const char *szModule, const char *szSetting, int uDefault); - static int getByte(const char *szSetting, int uDefault); - - static INT_PTR getTString(const MCONTACT hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv); - static INT_PTR getString(const MCONTACT hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv); - - static INT_PTR writeDword(const MCONTACT hContact, const char *szModule, const char *szSetting, DWORD value); - static INT_PTR writeDword(const char *szModule, const char *szSetting, DWORD value); - - static INT_PTR writeWord(const MCONTACT hContact, const char *szModule, const char *szSetting, WORD value); - static INT_PTR writeWord(const char *szModule, const char *szSetting, WORD value); - - static INT_PTR writeByte(const MCONTACT hContact, const char *szModule, const char *szSetting, BYTE value); - static INT_PTR writeByte(const char *szModule, const char *szSetting, BYTE value); - - static INT_PTR writeTString(const MCONTACT hContact, const char *szModule, const char *szSetting, const TCHAR *st); - static INT_PTR writeString(const MCONTACT hContact, const char *szModule, const char *szSetting, const char *st); - - static TExtraCache* getCache(const MCONTACT hContact, const char *szProto); - -public: - static TCluiData dat; - static ClcData* clcdat; - - static LIST arCache; - - static bool shutDown; -}; - -struct TSysConfig { - bool isVistaPlus; - bool isSevenPlus; -}; - -struct TSysState { - bool isThemed; - bool isAero; - bool isDwmActive; -}; - -class API -{ -public: - static void onInit (); - static void updateState (); - - static void Ex_CopyEditToClipboard (HWND hWnd); - static INT_PTR CALLBACK Ex_DlgProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); - static void Ex_Handler (); - static int Ex_ShowDialog (EXCEPTION_POINTERS *ep, const char *szFile, int line, TCHAR* szReason, bool fAllowContinue); - - static pfnDwmExtendFrameIntoClientArea_t pfnDwmExtendFrameIntoClientArea; - static pfnDwmIsCompositionEnabled_t pfnDwmIsCompositionEnabled; - - static TSysConfig sysConfig; - static TSysState sysState; - - static EXCEPTION_RECORD exRecord; - static CONTEXT exCtx; - static LRESULT exLastResult; - static char exSzFile[MAX_PATH]; - static TCHAR exReason[256]; - static int exLine; - static bool exAllowContinue; - - static HMODULE hDwm; -}; - - -class Utils -{ -public: - static void TSAPI enableDlgControl(const HWND hwnd, UINT id, BOOL fEnable); - static void TSAPI showDlgControl(const HWND hwnd, UINT id, int showCmd); - static HMODULE loadSystemLibrary(const TCHAR* szFilename, bool useGetHandle = false); - -}; - -#endif /* __CONFIG_H_*/ diff --git a/plugins/Clist_nicer/src/Include/extBackg.h b/plugins/Clist_nicer/src/Include/extBackg.h deleted file mode 100644 index 9b98c283ee..0000000000 --- a/plugins/Clist_nicer/src/Include/extBackg.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - -Miranda NG: the free IM client for Microsoft* Windows* - -Copyright (ñ) 2012-15 Miranda NG project (http://miranda-ng.org), -Copyright (c) 2000-03 Miranda ICQ/IM 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. -*/ - -#define ID_EXTBKIDLE 40081 -#define ID_EXTBKEXPANDEDGROUP 40082 -#define ID_EXTBKCOLLAPSEDDGROUP 40083 -#define ID_EXTBKEMPTYGROUPS 40084 -#define ID_EXTBKFIRSTITEM 40085 -#define ID_EXTBKSINGLEITEM 40086 -#define ID_EXTBKLASTITEM 40087 - - -#define ID_EXTBKFIRSTITEM_NG 40088 -#define ID_EXTBKSINGLEITEM_NG 40089 -#define ID_EXTBKLASTITEM_NG 40090 - -#define ID_EXTBKEVEN_CNTCTPOS 40091 -#define ID_EXTBKODD_CNTCTPOS 40092 - -#define ID_EXTBKSELECTION 40093 -#define ID_EXTBKHOTTRACK 40094 -#define ID_EXTBKFRAMETITLE 40095 -#define ID_EXTBKEVTAREA 40096 -#define ID_EXTBKSTATUSBAR 40097 -#define ID_EXTBKBUTTONBAR 40098 -#define ID_EXTBKBUTTONSPRESSED 40099 -#define ID_EXTBKBUTTONSNPRESSED 40100 -#define ID_EXTBKBUTTONSMOUSEOVER 40101 -#define ID_EXTBKTBBUTTONSPRESSED 40102 -#define ID_EXTBKTBBUTTONSNPRESSED 40103 -#define ID_EXTBKTBBUTTONMOUSEOVER 40104 -#define ID_EXTBKSTATUSFLOATER 40105 -#define ID_EXTBKOWNEDFRAMEBORDER 40106 -#define ID_EXTBKOWNEDFRAMEBORDERTB 40107 -#define ID_EXTBKAVATARFRAME 40108 -#define ID_EXTBKAVATARFRAMEOFFLINE 40109 -#define ID_EXTBKSCROLLBACK 40110 -#define ID_EXTBKSCROLLBACKLOWER 40111 -#define ID_EXTBKSCROLLTHUMB 40112 -#define ID_EXTBKSCROLLTHUMBHOVER 40113 -#define ID_EXTBKSCROLLTHUMBPRESSED 40114 -#define ID_EXTBKSCROLLBUTTON 40115 -#define ID_EXTBKSCROLLBUTTONHOVER 40116 -#define ID_EXTBKSCROLLBUTTONPRESSED 40117 -#define ID_EXTBKSCROLLARROWUP 40118 -#define ID_EXTBKSCROLLARROWDOWN 40119 -#define ID_EXTBK_LAST_D 40119 - -#define ID_EXTBKSEPARATOR 40200 - -BOOL CheckItem(int item, HWND hwndDlg); -BOOL isValidItem(void); -void extbk_export(const TCHAR *file); -void extbk_import(const TCHAR *file, HWND hwndDlg); - -void LoadExtBkSettingsFromDB(); -void IMG_LoadItems(); -void __fastcall IMG_RenderImageItem(HDC hdc, ImageItem *item, RECT *rc); -void IMG_InitDecoder(); -void LoadPerContactSkins(const TCHAR *file); - -static void SaveCompleteStructToDB(); -StatusItems_t *GetProtocolStatusItem(const char *szProto); - -void OnListItemsChange(HWND hwndDlg); - -void UpdateStatusStructSettingsFromOptDlg(HWND hwndDlg, int index); - -void SaveNonStatusItemsSettings(HWND hwndDlg); - -void FillItemList(HWND hwndDlg); -void FillOptionDialogByCurrentSel(HWND hwndDlg); -void ReActiveCombo(HWND hwndDlg); -//BOOL __fastcall GetItemByStatus(int status, StatusItems_t *retitem); - -void FillOptionDialogByStatusItem(HWND hwndDlg, StatusItems_t *item); diff --git a/plugins/Clist_nicer/src/Include/resource.h b/plugins/Clist_nicer/src/Include/resource.h deleted file mode 100644 index abb763ae2e..0000000000 --- a/plugins/Clist_nicer/src/Include/resource.h +++ /dev/null @@ -1,390 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by ..\res\resource.rc -// -#define IDD_OPT_VIEWMODES 1 -#define IDD_OPT_SKIN 4 -#define IDD_QUICKIGNORE 5 -#define IDD_OPT 6 -#define IDD_EXCEPTION 20 -#define IDD_OPTIONSDIALOG 101 -#define IDD_CLNABOUT 102 -#define IDD_OPT_CLIST 126 -#define IDI_ADDGROUP 143 -#define IDI_CLIST 146 -#define IDI_OPTIONS 163 -#define IDI_DELETE 175 -#define IDI_CLVM_OPTIONS 176 -#define IDI_CLVM_SELECT 177 -#define IDR_CONTEXT 180 -#define IDC_DROP 183 -#define IDR_CLISTMENU 199 -#define IDI_BLANK 200 -#define IDI_ADDCONTACT 210 -#define IDC_HYPERLINKHAND 214 -#define IDC_DROPUSER 215 -#define IDD_OPT_CLUI 218 -#define IDD_OPT_ICONS 220 -#define IDD_OPT_CLC 228 -#define IDD_OPT_CLCBKG 230 -#define IDD_OPT_SBAR 234 -#define IDD_DELETECONTACT 254 -#define IDD_OPT_DSPADVANCED 301 -#define IDD_OPT_DSPITEMS 302 -#define IDD_OPT_DSPGROUPS 303 -#define IDC_ACTIVEPERC 1000 -#define IDC_OPTIONSTAB 1000 -#define IDC_ALWAYSSTATUS 1009 -#define IDC_APPLY 1011 -#define IDC_AUTOSIZE 1013 -#define IDC_AUTOSIZEUPWARD 1014 -#define IDC_AVATARSIZESPIN 1015 -#define IDC_SKINMODE 1020 -#define IDC_FULLTRANSPARENT 1020 -#define IDC_STATUSICONSCENTERED 1020 -#define IDC_NOTRAYINFOTIPS 1020 -#define IDC_SHOWXSTATUS 1020 -#define IDC_AUTOCLEAR 1020 -#define IDC_FLT_SIMPLELAYOUT 1020 -#define IDC_USESKIN 1020 -#define IDC_IGN_MSGEVENTS 1020 -#define IDC_AUTOCLEARVAL 1021 -#define IDC_MARKLOCKED 1021 -#define IDC_IGN_FILEEVENTS 1021 -#define IDC_AUTOCLEARSPIN 1022 -#define IDC_IGN_URLEVENTS 1022 -#define IDC_LASTMSG 1023 -#define IDC_IGN_AUTH 1023 -#define IDC_IGN_ADD 1024 -#define IDC_CONFIRMDELETE 1025 -#define IDC_IGN_ONLINE 1025 -#define IDC_IGN_ALWAYSONLINE 1026 -#define IDC_IGN_ALWAYSOFFLINE 1027 -#define IDC_IGN_PRIORITY 1028 -#define IDC_DISABLEGROUPS 1030 -#define IDC_DROPSHADOW 1035 -#define IDC_EQUALSELECTION 1040 -#define IDC_USEPERPROTO 1041 -#define IDC_OVERRIDEPERSTATUSCOLOR 1042 -#define IDC_EVENTAREASUNKEN 1043 -#define IDC_SETALLBUTTONSKINNED 1043 -#define IDC_EVENTSONTOP 1044 -#define IDC_FASTGRADIENT 1044 -#define IDC_DONTSEPARATE 1045 -#define IDC_FADEINOUT 1056 -#define IDC_FRAMEGAP 1064 -#define IDC_FRAMEGAPSPIN 1065 -#define IDC_CLIPBORDER 1066 -#define IDC_FULLROWSELECT 1067 -#define IDC_CLIPBORDERSPIN 1067 -#define IDC_LOCALTIME 1068 -#define IDC_CLEFT 1070 -#define IDC_CLEFTSPIN 1071 -#define IDC_GREYOUT 1072 -#define IDC_CTOP 1072 -#define IDC_ONTOP 1074 -#define IDC_SHOWMAINMENU 1075 -#define IDC_CLIENTDRAG 1076 -#define IDC_HIDEEMPTYGROUPS 1077 -#define IDC_CTOPSPIN 1077 -#define IDC_CBOTTOM 1078 -#define IDC_CBOTTOMSPIN 1079 -#define IDC_CRIGHT 1080 -#define IDC_HIDEOFFLINE 1081 -#define IDC_CRIGHTSPIN 1081 -#define IDC_HIDEOFFLINEOPTS 1082 -#define IDC_LEFTMARGINSPIN 1092 -#define IDC_NOGROUPICON 1102 -#define IDC_ONECLK 1105 -#define IDC_RIGHTMARGIN 1121 -#define IDC_ROWGAP 1122 -#define IDC_TRANSPARENT 1124 -#define IDC_ROWHEIGHT 1125 -#define IDC_TRANSINACTIVE 1126 -#define IDC_GROUPROWHEIGHT 1126 -#define IDC_TRANSACTIVE 1128 -#define IDC_PROFILELIST 1134 -#define IDC_CLASSLIST 1135 -#define IDC_SELBLEND 1140 -#define IDC_SHOWBOTTOMBUTTONS 1148 -#define IDC_STATIC11 1154 -#define IDC_STATIC12 1155 -#define IDC_STATIC21 1156 -#define IDC_STATIC13 1156 -#define IDC_STATIC22 1157 -#define IDC_STATIC14 1157 -#define IDC_STATIC15 1158 -#define IDC_SHOWGRIP 1169 -#define IDC_SKINBACKGROUND 1170 -#define IDC_FILLWALLPAPER 1171 -#define IDC_SHOWMETA 1172 -#define IDC_CENTERGROUPNAMES 1173 -#define IDC_APPLYINDENTBG 1174 -#define IDC_COPYRIGHT 1178 -#define IDC_VERSION 1179 -#define IDC_SHOWSTATUSICONS 1180 -#define IDC_BROWSE 1184 -#define IDC_INACTIVEPERC 1187 -#define IDC_SHOWSTATUSMSG 1188 -#define IDC_SHOWLOCALTIME 1189 -#define IDC_SHOWLOCALTIMEONLYWHENDIFFERENT 1191 -#define IDC_TITLETEXT 1196 -#define IDC_EXCEPTION_DETAILS 1200 -#define IDC_COPY_EXCEPTION 1201 -#define IDC_EX_REASON 1202 -#define IDC_TILEH 1208 -#define IDC_WHITERECT 1225 -#define IDC_AUTOHIDE 1235 -#define IDC_HIDETIME 1236 -#define IDC_ALWAYSHIDEONTASKBAR 1237 -#define IDC_IMPORT 1241 -#define IDC_MAXSIZEHEIGHT 1254 -#define IDC_MAXSIZESPIN 1255 -#define IDC_BKGCOLOUR 1269 -#define IDC_FILENAME 1271 -#define IDC_SCROLL 1277 -#define IDC_PROPORTIONAL 1278 -#define IDC_SMOOTHTIME 1283 -#define IDC_SMOOTHTIMESPIN 1284 -#define IDC_ROWHEIGHTSPIN 1286 -#define IDC_GROUPROWHEIGHTSPIN 1287 -#define IDC_GREYOUTOPTS 1288 -#define IDC_GROUPINDENT 1289 -#define IDC_GROUPINDENTSPIN 1290 -#define IDC_LEFTMARGIN 1291 -#define IDC_RIGHTMARGINSPIN 1294 -#define IDC_ROWGAPSPIN 1295 -#define IDC_STRETCHH 1298 -#define IDC_STRETCHV 1299 -#define IDC_TILEV 1301 -#define IDC_DONTCYCLE 1315 -#define IDC_PRIMARYSTATUS 1316 -#define IDC_CYCLE 1317 -#define IDC_CYCLETIME 1318 -#define IDC_CYCLETIMESPIN 1319 -#define IDC_HIDETIMESPIN 1320 -#define IDC_MULTITRAY 1321 -#define IDC_ALWAYSMULTI 1322 -#define IDC_SHOWICON 1323 -#define IDC_SORTTHEN 1323 -#define IDC_SHOWPROTO 1324 -#define IDC_SORTFINALLY 1324 -#define IDC_SHOWSTATUS 1325 -#define IDC_EQUALSECTIONS 1326 -#define IDC_SHOWSBAR 1329 -#define IDC_RIGHTMIRANDA 1330 -#define IDC_RIGHTSTATUS 1331 -#define IDC_STCLISTGROUP 1350 -#define IDC_DISABLEDRAGDROP 1351 -#define IDC_NOTEDITLABELS 1352 -#define IDC_SHOWSELALWAYS 1353 -#define IDC_TRACKSELECT 1354 -#define IDC_SHOWGROUPCOUNTS 1355 -#define IDC_HIDECOUNTSWHENEMPTY 1356 -#define IDC_DIVIDERONOFF 1357 -#define IDC_NOTNOTRANSLUCENTSEL 1358 -#define IDC_LINEWITHGROUPS 1359 -#define IDC_QUICKSEARCHVISONLY 1360 -#define IDC_SORTGROUPSALPHA 1361 -#define IDC_NOTNOSMOOTHSCROLLING 1362 -#define IDC_BITMAP 1363 -#define IDC_STWINDOWGROUP 1364 -#define IDC_STATIC01 1365 -#define IDC_SORTPRIMARY 1420 -#define IDC_HIDE 1534 -#define IDC_TOPLINE 1535 -#define IDC_BRINGTOFRONT 1579 -#define IDC_LOGO 1591 -#define IDC_BLINKTIME 1607 -#define IDC_BLINKSPIN 1608 -#define IDC_DISABLEBLINK 1609 -#define IDC_IDLE 1610 -#define IDC_SBPANELBEVEL 1611 -#define IDC_DBLCLKAVATARS 1611 -#define IDC_XSTATUSASSTATUS 1611 -#define IDC_NOSCROLLBAR 1613 -#define IDC_ADDVIEWMODE 1633 -#define IDC_SKINFILESELECT 1633 -#define IDC_IGN_ALL 1633 -#define IDC_EXPORT 1634 -#define IDC_DELETEVIEWMODE 1634 -#define IDC_IGN_NONE 1634 -#define IDC_RELOAD 1635 -#define IDC_IGN_ADDPERMANENTLY 1635 -#define IDC_DSP_LOADDEFAULT 1636 -#define IDC_ONDESKTOP 1657 -#define IDC_WINCOLOUR 1659 -#define IDC_ICONBLINK 1660 -#define IDC_APPLYLASTVIEWMODE 1661 -#define IDC_IGNORESELFORGROUPS 1722 -#define IDC_CLISTAVATARS 1729 -#define IDC_ALIGNMENT 1730 -#define IDC_AVATARSBORDER 1732 -#define IDC_AVATARBORDERCLR 1733 -#define IDC_AVATARSROUNDED 1734 -#define IDC_DUALROWMODE 1735 -#define IDC_CLISTALIGN 1737 -#define IDC_CLISTSUNKEN 1738 -#define IDC_EVENTAREAAUTOHIDE 1740 -#define IDC_RADIUS 1742 -#define IDC_RADIUSSPIN 1743 -#define IDC_ALWAYSALIGNNICK 1744 -#define IDC_SELECTIVEICONS 1746 -#define IDC_OVERLAYICONS 1747 -#define IDC_AVATARHEIGHT 1748 -#define IDC_NOAVATARSOFFLINE 1749 -#define IDC_CORNERRAD 1751 -#define IDC_CORNERSPIN 1752 -#define IDC_AVATARPADDING 1753 -#define IDC_GRPTOPPADDING 1753 -#define IDC_AVATARPADDINGSPIN 1754 -#define IDC_GRPPADDINGSPIN 1754 -#define IDC_LASTITEMPADDING 1755 -#define IDC_LASTITEMPADDINGSPIN 1756 -#define IDC_TBHIDEOFFLINE 1800 -#define IDC_TBHIDEGROUPS 1801 -#define IDC_TBSOUND 1802 -#define IDC_TBFINDANDADD 1803 -#define IDC_TBOPTIONS 1804 -#define IDC_TBMINIMIZE 1805 -#define IDC_TBMENU 1806 -#define IDC_TBGLOBALSTATUS 1807 -#define IDC_TABSRMMSLIST 1808 -#define IDC_TABSRMMMENU 1809 -#define IDC_TBSELECTVIEWMODE 1810 -#define IDC_ROUNDEDBORDER 1810 -#define IDC_TBCLEARVIEWMODE 1811 -#define IDC_TBCONFIGUREVIEWMODE 1812 -#define IDC_TBTOPMENU 1813 -#define IDC_TBTOPSTATUS 1814 -#define IDC_TBFOLDER 1815 -#define IDC_TBPOPUP 1816 -#define IDC_TBACCOUNTS 1817 -#define IDC_TBFIRSTUID 1820 -#define IDC_NOTIFYBUTTON 1900 -#define IDC_CLNICER 2002 -#define IDC_SUPPORT 2003 -#define IDI_OVL_OFFLINE 2050 -#define IDI_OVL_ONLINE 2051 -#define IDI_OVL_AWAY 2052 -#define IDI_OVL_DND 2053 -#define IDI_OVL_NA 2054 -#define IDI_OVL_OCCUPIED 2055 -#define IDI_OVL_INVISIBLE 2057 -#define IDI_OVL_ONTHEPHONE 2058 -#define IDI_OVL_OUTTOLUNCH 2059 -#define IDI_HIDEOFFLINE 2100 -#define IDI_HIDEGROUPS 2101 -#define IDI_SOUNDSON 2102 -#define IDI_FINDANDADD 2103 -#define IDI_TBOPTIONS 2104 -#define IDI_MINIMIZE 2105 -#define IDI_SOUNDSOFF 2106 -#define IDI_TABSRMMSESSIONLIST 2107 -#define IDI_TABSRMMMENU 2108 -#define IDI_PROTOCONNECTING 2111 -#define IDI_TBTOPMENU 2112 -#define IDI_TBACCOUNTS 2113 -#define IDC_FLT_DEFHOVERTIME 2200 -#define IDC_CLUIFRAMESBDR 25492 -#define IDC_FLT_PADLEFTSPIN 25494 -#define IDC_FLT_PADLEFT 25495 -#define IDC_GROUPALIGN 25499 -#define IDC_BORDERSTYLE 25501 -#define IDC_CURVIEWMODE2 25503 -#define ID_ICQ_EXIT 40001 -#define IDC_STATIC7 40002 -#define POPUP_HIDEEMPTYGROUPS 40003 -#define POPUP_NEWSUBGROUP 40004 -#define POPUP_HIDEOFFLINE 40005 -#define POPUP_GROUPHIDEOFFLINE 40006 -#define POPUP_HIDEOFFLINEROOT 40007 -#define POPUP_DISABLEGROUPS 40008 -#define IDC_VIEWMODES 40010 -#define IDC_PROTOCOLS 40011 -#define IDC_GROUPS 40012 -#define IDC_STATUSMODES 40013 -#define IDC_NEWVIEMODE 40014 -#define POPUP_HIDEMIRANDA 40017 -#define IDC_TAB 40017 -#define IDC_STATIC1 40018 -#define IDC_STATIC2 40019 -#define IDC_STATIC3 40020 -#define IDC_STATIC16 40021 -#define IDC_STATIC4 40022 -#define IDC_STATIC5 40023 -#define IDC_CLIST 40025 -#define IDC_STATIC8 40026 -#define IDC_STATIC9 40027 -#define POPUP_BUTTONS 40028 -#define IDC_CLEARALL 40028 -#define POPUP_FRAME 40029 -#define IDC_STATIC10 40029 -#define IDC_PROTOGROUPOP 40030 -#define POPUP_MOVEMARKEDHERE 40031 -#define IDC_GROUPSTATUSOP 40031 -#define IDC_LASTMESSAGEOP 40032 -#define ID_BUTTONS_ONLINE 40033 -#define IDC_SKINFILE 40034 -#define IDC_LASTMESSAGEUNIT 40034 -#define IDC_FLT_AVATARS 40036 -#define IDC_HIDECONTACT 40036 -#define IDC_FLT_DUALROWS 40037 -#define IDC_FLT_EXTRAICONS 40038 -#define ID_TRAY_HIDE 40038 -#define ID_TRAY_EXIT 40039 -#define IDC_FLT_SYNCED 40039 -#define POPUP_SHOWMETAICONS 40040 -#define IDC_FLT_AUTOHIDE 40040 -#define IDC_FLT_FILLSTD 40041 -#define IDC_FLT_PADRIGHT 40043 -#define IDC_LASTMSGVALUE 40043 -#define IDC_FLT_PADRIGHTSPIN 40044 -#define IDC_FLT_PADTOP 40045 -#define IDC_SKINFILENAME 40045 -#define IDC_FLT_PADTOPSPIN 40046 -#define IDC_SELECTSKINFILE 40046 -#define IDC_FLT_PADBOTTOM 40047 -#define IDC_RELOADSKIN 40047 -#define IDC_FLT_PADBOTTOMSPIN 40048 -#define IDC_UNLOAD 40048 -#define POPUP_NEWGROUP 40050 -#define IDC_SECONDLINEMODE 40050 -#define POPUP_SHOWSTATUSICONS 40051 -#define IDC_OVERLAYICON 40051 -#define IDC_SHOWLOCALTIME1 40052 -#define POPUP_RENAMEGROUP 40052 -#define POPUP_DELETEGROUP 40053 -#define IDC_DSP_ADD -25483 -#define IDC_DSP_DELETE 40054 -#define IDC_FLT_ENABLED 40054 -#define IDC_DSP_RENAME 40055 -#define IDC_FLT_OPACITY 40055 -#define IDC_DSP_APPLY 40056 -#define IDC_FLT_ACTIVEOPACITY 40056 -#define IDC_FLT_WIDTH 40058 -#define IDC_AVATARDISPMODE 40059 -#define IDC_FLT_WIDTHSPIN 40059 -#define IDC_FLT_SNAP 40060 -#define IDC_FLT_ACTIVEOPACITYVALUE 40061 -#define IDC_FLT_BORDER 40062 -#define IDC_FLT_ROUNDED 40063 -#define IDC_FLT_RADIUS 40065 -#define IDC_FLT_RADIUSSPIN 40066 -#define IDC_FLT_HOVERTIME 40067 -#define IDC_RESETXICONS 40067 -#define IDC_FLT_SHOWTOOLTIPS 40068 -#define IDC_FLT_HOVERTIMESPIN 40069 -#define IDC_FLT_OPACITYVALUE 40070 -#define IDC_FLT_BORDERCOLOUR 40072 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 10 -#define _APS_NEXT_COMMAND_VALUE 40061 -#define _APS_NEXT_CONTROL_VALUE 40066 -#define _APS_NEXT_SYMED_VALUE 40154 -#endif -#endif diff --git a/plugins/Clist_nicer/src/Include/rowheight_funcs.h b/plugins/Clist_nicer/src/Include/rowheight_funcs.h deleted file mode 100644 index 60a0998e1c..0000000000 --- a/plugins/Clist_nicer/src/Include/rowheight_funcs.h +++ /dev/null @@ -1,74 +0,0 @@ -#ifndef __ROWHEIGHT_FUNCS_H__ -# define __ROWHEIGHT_FUNCS_H__ - -#define ROW_SPACE_BEETWEEN_LINES 0 -#define ICON_HEIGHT 16 - -class RowHeight -{ -public: - static BOOL Alloc(ClcData *dat, int size); - static BOOL Init(ClcData *dat); - static void Free(ClcData *dat); - static void Clear(ClcData *dat); - - // Calc and store max row height - static int getMaxRowHeight(ClcData *dat, const HWND hwnd); - - // Calc and store row height - static int getRowHeight(ClcData *dat, ClcContact* contact, int item, DWORD style) - { - if (!Alloc(dat, item + 1)) - return -1; - - int height = dat->fontInfo[GetBasicFontID(contact)].fontHeight; - - if (!dat->bisEmbedded) { - if (contact->bSecondLine != MULTIROW_NEVER && contact->bSecondLine != MULTIROW_IFSPACE && contact->type == CLCIT_CONTACT) { - if ((contact->bSecondLine == MULTIROW_ALWAYS || ((cfg::dat.dwFlags & CLUI_FRAME_SHOWSTATUSMSG && contact->bSecondLine == MULTIROW_IFNEEDED) && (contact->xStatus > 0 || contact->pExtra->bStatusMsgValid > STATUSMSG_XSTATUSID)))) - height += (dat->fontInfo[FONTID_STATUS].fontHeight + cfg::dat.avatarPadding); - } - - // Avatar size - if (contact->cFlags & ECF_AVATAR && contact->type == CLCIT_CONTACT && contact->ace != NULL && !(contact->ace->dwFlags & AVS_HIDEONCLIST)) - height = max(height, cfg::dat.avatarSize + cfg::dat.avatarPadding); - } - - // Checkbox size - if ((style & CLS_CHECKBOXES && contact->type == CLCIT_CONTACT) || - (style & CLS_GROUPCHECKBOXES && contact->type == CLCIT_GROUP) || - (contact->type == CLCIT_INFO && contact->flags & CLCIIF_CHECKBOX)) { - height = max(height, dat->checkboxSize); - } - - //height += 2 * dat->row_border; - // Min size - height = max(height, contact->type == CLCIT_GROUP ? dat->group_row_height : dat->min_row_heigh); - height += cfg::dat.bRowSpacing; - - dat->row_heights[item] = height; - //contact->iRowHeight = item; - - return height; - } - - // Calc and store row height for all itens in the list - static void calcRowHeights (ClcData *dat, HWND hwnd); - - // Calc item top Y (using stored data) - static int getItemTopY (ClcData *dat, int item); - - // Calc item bottom Y (using stored data) - static int getItemBottomY (ClcData *dat, int item); - - // Calc total height of rows (using stored data) - static int getTotalHeight (ClcData *dat); - - // Return the line that pos_y is at or -1 (using stored data). Y start at 0 - static int hitTest (ClcData *dat, int pos_y); - - // Returns the height of the chosen row - static int getHeight (ClcData *dat, int item); -}; - -#endif // __ROWHEIGHT_FUNCS_H__ diff --git a/plugins/Clist_nicer/src/alphablend.cpp b/plugins/Clist_nicer/src/alphablend.cpp index 403f244fa5..0906dc512f 100644 --- a/plugins/Clist_nicer/src/alphablend.cpp +++ b/plugins/Clist_nicer/src/alphablend.cpp @@ -22,7 +22,7 @@ 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 "stdafx.h" extern int g_hottrack, g_hottrack_done; extern BOOL g_inCLCpaint; diff --git a/plugins/Clist_nicer/src/alphablend.h b/plugins/Clist_nicer/src/alphablend.h new file mode 100644 index 0000000000..d5ce2225b1 --- /dev/null +++ b/plugins/Clist_nicer/src/alphablend.h @@ -0,0 +1,31 @@ +/* + +Miranda NG: the free IM client for Microsoft* Windows* + +Copyright (ñ) 2012-15 Miranda NG project (http://miranda-ng.org), +Copyright (c) 2000-03 Miranda ICQ/IM 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. +*/ + +void __inline gradientVertical(UCHAR *ubRedFinal, UCHAR *ubGreenFinal, UCHAR *ubBlueFinal, + ULONG ulBitmapHeight, UCHAR ubRed, UCHAR ubGreen, UCHAR ubBlue, UCHAR ubRed2, + UCHAR ubGreen2, UCHAR ubBlue2, DWORD FLG_GRADIENT, BOOL transparent, UINT32 y, UCHAR *ubAlpha); + +void __inline gradientHorizontal( UCHAR *ubRedFinal, UCHAR *ubGreenFinal, UCHAR *ubBlueFinal, + ULONG ulBitmapWidth, UCHAR ubRed, UCHAR ubGreen, UCHAR ubBlue, UCHAR ubRed2, + UCHAR ubGreen2, UCHAR ubBlue2, DWORD FLG_GRADIENT, BOOL transparent, UINT32 x, UCHAR *ubAlpha); \ No newline at end of file diff --git a/plugins/Clist_nicer/src/clc.cpp b/plugins/Clist_nicer/src/clc.cpp index 6a5a3937ca..d2276d2f72 100644 --- a/plugins/Clist_nicer/src/clc.cpp +++ b/plugins/Clist_nicer/src/clc.cpp @@ -22,11 +22,11 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include -#include +#include "stdafx.h" +#include "resource.h" #include -#include "../cluiframes/cluiframes.h" -#include "../coolsb/coolscroll.h" +#include "cluiframes.h" +#include "coolscroll.h" void CSH_Destroy(); @@ -94,7 +94,7 @@ static int ClcEventAdded(WPARAM hContact, LPARAM lParam) static int ClcMetamodeChanged(WPARAM bMetaEnabled, LPARAM) { - if (bMetaEnabled != cfg::dat.bMetaEnabled) { + if (BOOL(bMetaEnabled) != cfg::dat.bMetaEnabled) { cfg::dat.bMetaEnabled = (BYTE)bMetaEnabled; pcli->pfnClcBroadcast(CLM_AUTOREBUILD, 0, 0); } diff --git a/plugins/Clist_nicer/src/clc.h b/plugins/Clist_nicer/src/clc.h new file mode 100644 index 0000000000..a196275b15 --- /dev/null +++ b/plugins/Clist_nicer/src/clc.h @@ -0,0 +1,522 @@ +/* + +Miranda NG: the free IM client for Microsoft* Windows* + +Copyright (ñ) 2012-15 Miranda NG project (http://miranda-ng.org), +Copyright (c) 2000-03 Miranda ICQ/IM 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. +*/ + +#define INTM_XSTATUSCHANGED (WM_USER+26) +#define INTM_METACHANGEDEVENT (WM_USER+27) +#define INTM_CODEPAGECHANGED (WM_USER+28) +#define INTM_AVATARCHANGED (WM_USER+30) +#define INTM_STATUSMSGCHANGED (WM_USER+31) +#define INTM_SORTCLC (WM_USER+32) +#define INTM_STATUSCHANGED (WM_USER+33) +#define INTM_METACHANGED (WM_USER+34) +#define INTM_INVALIDATECONTACT (WM_USER+35) +#define INTM_FORCESORT (WM_USER+36) + +#define DEFAULT_TITLEBAR_HEIGHT 18 + +#define CLS_SKINNEDFRAME 0x0800 //this control will be the main contact list (v. 0.3.4.3+ 2004/11/02) + +#define TIMERID_RENAME 10 +#define TIMERID_DRAGAUTOSCROLL 11 +#define TIMERID_INFOTIP 13 +#define TIMERID_SORT 15 +#define TIMERID_REFRESH 18 +#define TIMERID_PAINT 19 + +#define CONTACTF_ONLINE 1 +//#define CONTACTF_INVISTO 2 +//#define CONTACTF_VISTO 4 +#define CONTACTF_NOTONLIST 8 +#define CONTACTF_CHECKED 16 +#define CONTACTF_IDLE 32 +#define CONTACTF_STICKY 64 +#define CONTACTF_PRIORITY 128 + +#define STATUSMSG_XSTATUSID 1 +#define STATUSMSG_XSTATUSNAME 2 +#define STATUSMSG_CLIST 4 +#define STATUSMSG_YIM 8 +#define STATUSMSG_GG 16 +#define STATUSMSG_XSTATUS 32 + +#define STATUSMSG_NOTFOUND 0 + +#define SMSG_MAXLEN 700 + +#define EXTRAIMAGECACHESIZE 1000 + +// extra cache contact flags + +#define ECF_RTLNICK 1 +#define ECF_RTLSTATUSMSG 2 +#define ECF_FORCEAVATAR 4 +#define ECF_HIDEAVATAR 8 +#define ECF_FORCEOVERLAY 16 +#define ECF_HIDEOVERLAY 32 +#define ECF_FORCELOCALTIME 64 +#define ECF_HIDELOCALTIME 128 +#define ECF_HASREALTIMEZONE 1024 + +// other contact flags (struct ClCContact; + +#define ECF_AVATAR 1 +#define ECF_SECONDLINE 2 + +#define DSPF_CENTERSTATUSICON 1 +#define DSPF_DIMIDLE 2 +#define DSPF_NOFFLINEAVATARS 4 +#define DSPF_SHOWLOCALTIME 8 +#define DSPF_LOCALTIMESELECTIVE 16 +#define DSPF_DONTSEPARATEOFFLINE 32 +#define DSPF_CENTERGROUPNAMES 64 + +/* Extra icons settings */ +typedef struct _OrderTreeData +{ + BYTE ID; + const TCHAR * Name; + BYTE Position; + BOOL Visible; + BOOL fReserved; +} *PORDERTREEDATA, ORDERTREEDATA; + +struct TExtraCache +{ + MCONTACT hContact; + HANDLE hTimeZone; + BYTE valid; + TCHAR *statusMsg; + BYTE bStatusMsgValid; + DWORD dwCFlags; + DWORD dwDFlags; // display flags for caching only + StatusItems_t *status_item, *proto_status_item; + DWORD dwLastMsgTime; + DWORD msgFrequency; + BOOL isChatRoom; +}; + +struct ClcContact : public ClcContactBase +{ + BOOL bIsMeta; + BYTE xStatus; + int xStatusIcon; + MCONTACT hSubContact; + char *metaProto; + DWORD codePage; + WORD wStatus; + int avatarLeft, extraIconRightBegin; + int isRtl; + DWORD cFlags; + BYTE bSecondLine; + + avatarCacheEntry *ace; + TExtraCache* pExtra; +}; + +#define DRAGSTAGE_NOTMOVED 0 +#define DRAGSTAGE_ACTIVE 1 +#define DRAGSTAGEM_STAGE 0x00FF +#define DRAGSTAGEF_MAYBERENAME 0x8000 +#define DRAGSTAGEF_OUTSIDE 0x4000 + +#define FONTID_CONTACTS 0 +#define FONTID_INVIS 1 +#define FONTID_OFFLINE 2 +#define FONTID_NOTONLIST 3 +#define FONTID_GROUPS 4 +#define FONTID_GROUPCOUNTS 5 +#define FONTID_DIVIDERS 6 +#define FONTID_OFFINVIS 7 +#define FONTID_STATUS 8 +#define FONTID_FRAMETITLE 9 +#define FONTID_EVENTAREA 10 +#define FONTID_TIMESTAMP 11 +#define FONTID_LAST FONTID_TIMESTAMP + +struct ClcData : public ClcDataBase +{ + int *row_heights; + int row_heights_size; + int row_heights_allocated; + + int row_border; + int min_row_heigh, group_row_height; + + int currentFontID; + int rightMargin; + BYTE SelectMode; + BYTE isMultiSelect; + HWND hwndParent; + DWORD lastSort; + BOOL bNeedPaint, bisEmbedded, bHideSubcontacts; + DWORD lastRepaint; + BOOL forceScroll; + int oldSelection; +}; + +//#define CLUI_FRAME_SHOWTOPBUTTONS 1 +#define CLUI_FRAME_SHOWBOTTOMBUTTONS 2 +#define CLUI_SHOWCLIENTICONS 4 +//#define CLUI_SHOWVISI 8 +#define CLUI_FRAME_CLISTSUNKEN 16 +#define CLUI_SHOWXSTATUS 32 +#define CLUI_FRAME_BUTTONSFLAT 64 +#define CLUI_FRAME_BUTTONSCLASSIC 128 +#define CLUI_USEMETAICONS 256 +#define CLUI_FRAME_AUTOHIDENOTIFY 512 +#define CLUI_FRAME_USEXSTATUSASSTATUS 1024 +#define CLUI_STICKYEVENTS 2048 +#define CLUI_FRAME_SBARSHOW 4096 +#define CLUI_STATUSASTEXT 8192 +#define CLUI_FULLROWSELECT 16384 +#define CLUI_FRAME_EVENTAREASUNKEN 32768 +//#define CLUI_FRAME_BUTTONBARSUNKEN 65536 +#define CLUI_FRAME_AVATARS 0x20000 +#define CLUI_FRAME_AVATARSLEFT 0x40000 +#define CLUI_FRAME_GDIPLUS 0x80000 +#define CLUI_FRAME_AVATARBORDER 0x100000 +#define CLUI_FRAME_STATUSICONS 0x200000 +#define CLUI_FRAME_AVATARSRIGHTWITHNICK 0x400000 +#define CLUI_FRAME_TRANSPARENTAVATAR 0x800000 +#define CLUI_FRAME_ROUNDAVATAR 0x1000000 +#define CLUI_FRAME_ALWAYSALIGNNICK 0x2000000 +#define CLUI_FRAME_AVATARSRIGHT 0x4000000 +#define CLUI_FRAME_SHOWSTATUSMSG 0x8000000 +#define CLUI_FRAME_OVERLAYICONS 0x10000000 +#define CLUI_FRAME_SELECTIVEICONS 0x20000000 +#define CLUI_FRAME_ROUNDEDFRAME 0x40000000 +#define CLUI_FRAME_NOGROUPICON 0x80000000 + +#define MULTIROW_NEVER 0 +#define MULTIROW_ALWAYS 1 +#define MULTIROW_IFSPACE 2 +#define MULTIROW_IFNEEDED 3 + +#define CLC_GROUPALIGN_LEFT 0 +#define CLC_GROUPALIGN_RIGHT 1 +#define CLC_GROUPALIGN_AUTO 2 + +struct TCluiData { + DWORD dwFlags; + DWORD topOffset, bottomOffset; + int statusBarHeight; + int soundsOff; + BYTE tabSRMM_Avail; + BYTE bAvatarServiceAvail; + HICON hIconConnecting; + DWORD winFlags; + DWORD winFlagsEx; + int notifyActive; + int hIconNotify; + HMENU hMenuNotify; + int iLastEventAdded; + int wNextMenuID; + MCONTACT hUpdateContact; + DWORD sortTimer; + BOOL forceResize; + BOOL neeedSnap; + COLORREF avatarBorder; + HBRUSH hBrushAvatarBorder, hBrushColorKey; + HBRUSH hBrushCLCBk; + DWORD avatarRadius; + int avatarSize; + BOOL bForceRefetchOnPaint; + BYTE dualRowMode; + BYTE avatarPadding; + BYTE cornerRadius; + BYTE isTransparent; + BYTE alpha, autoalpha; + BYTE fadeinout; + BYTE autosize; + BYTE gapBetweenFrames; + BYTE titleBarHeight; + BYTE bClipBorder, bRowSpacing; + HBITMAP bmpBackground, hbmBgOld, hbmBg; + HBITMAP hbmToolbar, hbmToolbarOld; + HDC hdcBg; + HDC hdcPic; + HDC hdcToolbar; + HBITMAP hbmPicOld; + BITMAP bminfoBg; + SIZE dcSize; + POINT ptW; + BOOL bWallpaperMode; + BOOL bNoOfflineAvatars; + BOOL bEventAreaEnabled; + BOOL bFullTransparent; + BOOL bDblClkAvatars; + BOOL bApplyIndentToBg; + BOOL bEqualSections; + DWORD bFilterEffective; + BOOL bCenterStatusIcons; + BOOL bSkinnedToolbar; + BOOL bSkinnedStatusBar; + BOOL bUsePerProto; + BOOL bOverridePerStatusColors; + BOOL bDontSeparateOffline; + TCHAR groupFilter[2048]; + char protoFilter[2048]; + char varFilter[2048]; + DWORD lastMsgFilter; + char current_viewmode[256], old_viewmode[256]; + BYTE boldHideOffline; + DWORD statusMaskFilter; + DWORD stickyMaskFilter; + DWORD filterFlags; + COLORREF colorkey; + BOOL bMetaEnabled; + BOOL bSecIMAvail; + BOOL bNoTrayTips; + BOOL bShowLocalTime; + BOOL bShowLocalTimeSelective; + BOOL bShowXStatusOnSbar; + BOOL bLayeredHack; + HPEN hPen3DBright, hPen3DDark; + BYTE bSkinnedButtonMode; + BYTE bFirstRun; + BYTE bUseDCMirroring; + BYTE bCLeft, bCRight, bCTop, bCBottom; + BYTE fullyInited; + BYTE bAutoExpandGroups; + SIZE szOldCTreeSize; + BYTE bWantFastGradients, bUseFastGradients; + BYTE sortOrder[3]; + BYTE bGroupAlign; + BYTE bSkinnedScrollbar; + DWORD langPackCP; + BOOL fOnDesktop; + int group_padding; + DWORD t_now; + BOOL realTimeSaving; + TCHAR tszProfilePath[MAX_PATH]; + FILETIME ft; + SYSTEMTIME st; +}; + +#define SORTBY_NAME 1 +#define SORTBY_PROTO 2 +#define SORTBY_STATUS 3 +#define SORTBY_LASTMSG 4 +#define SORTBY_FREQUENCY 5 +#define SORTBY_PRIOCONTACTS 6 + +struct IconDesc +{ + char *szName; + char *szDesc; + int uId; // icon ID +}; + +struct NotifyMenuItemExData +{ + MCONTACT hContact; + int iIcon; // icon index in the image list + HICON hIcon; // corresponding icon handle + MEVENT hDbEvent; +}; + +// #define NOTIFY_HEIGHT 24 + +struct CluiTopButton +{ + int ctrlid; + char *pszButtonID, *pszButtonDn, *pszButtonName; + int isPush, isVis, isAction; + HANDLE hButton; + HWND hwndButton; +}; + +struct TrayIconInfo +{ + union + { + HICON hIcon; + int iIcon; + }; +}; + +struct protoMenu +{ + char protoName[50]; + UINT menuID; + BOOL added; + HICON hIcon; +}; + +// clcidents.c +int FindItem(HWND hwnd, struct ClcData *dat, HANDLE hItem, ClcContact **contact, ClcGroup **subgroup, int *isVisible); +HANDLE ContactToItemHandle(ClcContact *contact, DWORD *nmFlags); + +// clcitems.c +void RebuildEntireList(HWND hwnd, struct ClcData *dat); +DWORD INTSORT_GetLastMsgTime(MCONTACT hContact); + +// clcmsgs.c +LRESULT ProcessExternalMessages(HWND hwnd, struct ClcData *dat, UINT msg, WPARAM wParam, LPARAM lParam); + +// clcutils.c +void SetGroupExpand(HWND hwnd, struct ClcData *dat, ClcGroup *group, int newState); +void DoSelectionDefaultAction(HWND hwnd, struct ClcData *dat); +int FindRowByText(HWND hwnd, struct ClcData *dat, const TCHAR *text, int prefixOk); +void BeginRenameSelection(HWND hwnd, struct ClcData *dat); +int HitTest(HWND hwnd, struct ClcData *dat, int testx, int testy, ClcContact **contact, ClcGroup **group, DWORD *flags); +void ScrollTo(HWND hwnd, struct ClcData *dat, int desty, int noSmooth); +void RecalcScrollBar(HWND hwnd, struct ClcData *dat); +size_t MY_pathToRelative(const TCHAR *pSrc, TCHAR *pOut); +size_t MY_pathToAbsolute(const TCHAR *pSrc, TCHAR *pOut); + +#define DROPTARGET_OUTSIDE 0 +#define DROPTARGET_ONSELF 1 +#define DROPTARGET_ONNOTHING 2 +#define DROPTARGET_ONGROUP 3 +#define DROPTARGET_ONCONTACT 4 +#define DROPTARGET_INSERTION 5 +int GetDropTargetInformation(HWND hwnd, struct ClcData *dat, POINT pt); +void LoadClcOptions(HWND hwnd, struct ClcData *dat, BOOL bFirst); +void RecalculateGroupCheckboxes(HWND hwnd, struct ClcData *dat); +void SetGroupChildCheckboxes(ClcGroup *group, int checked); +BYTE GetCachedStatusMsg(TExtraCache* p, char *szProto); +int __fastcall GetStatusOnlineness(int status); +void GetExtendedInfo(ClcContact *contact, struct ClcData *dat); +extern LRESULT CALLBACK NewStatusBarWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); +void HideShowNotifyFrame(); +DWORD GetCLUIWindowStyle(BYTE style); +void ApplyCLUIBorderStyle(); + +int FrameNCCalcSize(HWND hwnd, WNDPROC oldWndProc, WPARAM wParam, LPARAM lParam, BOOL hasTitleBar); +int FrameNCPaint(HWND hwnd, WNDPROC oldWndProc, WPARAM wParam, LPARAM lParam, BOOL hasTitleBar); + +void FreeProtocolData( void ); + +void GetClientID(ClcContact *contact, char *client); +int LoadCLCButtonModule(void); +void SetButtonStates(); +void ConfigureCLUIGeometry(int mode); +void IcoLibReloadIcons(); +int CompareContacts(const ClcContact* p1, const ClcContact* p2); +void PaintNotifyArea(HDC hDC, RECT *rc); +int AvatarChanged(WPARAM wParam, LPARAM lParam); +void ConfigureFrame(); +void ConfigureEventArea(); +void ClearIcons(int mode); +void SkinDrawBg(HWND hwnd, HDC hdc); +int GetBasicFontID(ClcContact * contact); +extern int __fastcall CLVM_GetContactHiddenStatus(MCONTACT hContact, char *szStatus, struct ClcData *dat); +void CreateViewModeFrame(); +int GetExtraCache(MCONTACT hContact, char *szProto); +void ReloadExtraInfo(MCONTACT hContact); +void LoadAvatarForContact(ClcContact *p); +void ApplyViewMode(const char *name); + +void ClcSetButtonState(int ctrlId, int status); +HWND ClcGetButtonWindow(int ctrlid); + +// clcpaint.c +void PaintClc(HWND hwnd, struct ClcData *dat, HDC hdc, RECT *rcPaint); +void __inline PaintItem(HDC hdcMem, ClcGroup *group, ClcContact *contact, int indent, int y, struct ClcData *dat, int index, HWND hwnd, DWORD style, RECT *clRect, BOOL *bFirstNGdrawn, int groupCountsFontTopShift, int rowHeight); +void Reload3dBevelColors(); +void ReloadThemedOptions(); +void SetButtonToSkinned(); +void RTL_DetectAndSet(ClcContact *contact, MCONTACT hContact); +void RTL_DetectGroupName(ClcContact *group); +void CLN_LoadAllIcons(BOOL mode); +void ReloadSkinItemsToCache(); + +// clcopts.c +int ClcOptInit(WPARAM wParam, LPARAM lParam); +void GetFontSetting(int i, LOGFONTA *lf, COLORREF *colour); +void CluiProtocolStatusChanged(int, const char*); + +void LoadSkinItemToCache(struct TExtraCache *cEntry); + +// Docking.c + +int Docking_IsDocked(WPARAM wParam, LPARAM lParam); + +// Buttons + +#define BUTTONSETIMLICON (WM_USER+20) +#define BUTTONSETSKINNED (WM_USER+21) +#define BUTTONSETBTNITEM (WM_USER+22) +#define BUTTONSETTTBUTTON (WM_USER+23) + +// Menus + +void IMG_DeleteItems(); +int CoolSB_SetupScrollBar(); + +#define NIIF_INTERN_UNICODE 0x00000100 + +#define SETTING_WINDOWSTYLE_DEFAULT 0 + +#define SETTING_TRAYICON_SINGLE 0 +#define SETTING_TRAYICON_CYCLE 1 +#define SETTING_TRAYICON_MULTI 2 + +#define SETTING_STATE_HIDDEN 0 +#define SETTING_STATE_MINIMIZED 1 +#define SETTING_STATE_NORMAL 2 + +#define SETTING_BRINGTOFRONT_DEFAULT 0 + +#define SETTING_WINDOWSTYLE_TOOLWINDOW 1 +#define SETTING_WINDOWSTYLE_THINBORDER 2 +#define SETTING_WINDOWSTYLE_NOBORDER 3 + +#define CLCHT_ONAVATAR 0x2000 +#define CLCHT_ONITEMSPACE 0x4000 + +#define CLM_SETEXTRAIMAGEINT (CLM_FIRST+101) +#define CLM_SETSTICKY (CLM_FIRST+100) +#define CLM_ISMULTISELECT (CLM_FIRST+102) +#define CLM_SETEXTRAIMAGEINTMETA (CLM_FIRST+104) +#define CLM_GETSTATUSMSG (CLM_FIRST+105) +#define CLM_SETHIDESUBCONTACTS (CLM_FIRST+106) +#define CLM_TOGGLEPRIORITYCONTACT (CLM_FIRST+107) +#define CLM_QUERYPRIORITYCONTACT (CLM_FIRST+108) + +#define IDC_RESETMODES 110 +#define IDC_SELECTMODE 108 +#define IDC_CONFIGUREMODES 109 + +#define NR_CLIENTS 40 + +typedef BOOL (WINAPI *PGF)(HDC, PTRIVERTEX, ULONG, PVOID, ULONG, ULONG); + +#define IDC_STBHIDEOFFLINE IDC_TBHIDEOFFLINE - 20 +#define IDC_STBHIDEGROUPS IDC_TBHIDEGROUPS - 20 +#define IDC_STBSOUND IDC_TBSOUND - 20 +#define IDC_STBFINDANDADD IDC_TBFINDANDADD - 20 +#define IDC_STBOPTIONS IDC_TBOPTIONS - 20 +#define IDC_STBMINIMIZE IDC_TBMINIMIZE - 20 +#define IDC_STABSRMMSLIST IDC_TABSRMMSLIST - 20 +#define IDC_STABSRMMMENU IDC_TABSRMMMENU - 20 +#define IDC_STBSELECTVIEWMODE IDC_TBSELECTVIEWMODE - 20 +#define IDC_STBCLEARVIEWMODE IDC_TBCLEARVIEWMODE - 20 +#define IDC_STBCONFIGUREVIEWMODE IDC_TBCONFIGUREVIEWMODE - 20 +#define IDC_STBTOPMENU IDC_TBTOPMENU - 20 +#define IDC_STBTOPSTATUS IDC_TBTOPSTATUS - 20 +#define IDC_STBFOLDER IDC_TBFOLDER - 20 +#define IDC_STBPOPUP IDC_TBPOPUP - 20 +#define IDC_STBACCOUNTS IDC_TBACCOUNTS - 20 diff --git a/plugins/Clist_nicer/src/clcidents.cpp b/plugins/Clist_nicer/src/clcidents.cpp index bf2200cec5..d4f49e2cd3 100644 --- a/plugins/Clist_nicer/src/clcidents.cpp +++ b/plugins/Clist_nicer/src/clcidents.cpp @@ -22,7 +22,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include +#include "stdafx.h" /* the CLC uses 3 different ways to identify elements in its list, this file contains routines to convert between them. diff --git a/plugins/Clist_nicer/src/clcitems.cpp b/plugins/Clist_nicer/src/clcitems.cpp index c745bfac31..1efaba03ad 100644 --- a/plugins/Clist_nicer/src/clcitems.cpp +++ b/plugins/Clist_nicer/src/clcitems.cpp @@ -22,7 +22,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include +#include "stdafx.h" /* * load time zone information for the contact diff --git a/plugins/Clist_nicer/src/clcmsgs.cpp b/plugins/Clist_nicer/src/clcmsgs.cpp index c7e9df06f7..7f219c11db 100644 --- a/plugins/Clist_nicer/src/clcmsgs.cpp +++ b/plugins/Clist_nicer/src/clcmsgs.cpp @@ -22,7 +22,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include +#include "stdafx.h" //processing of all the CLM_ messages incoming diff --git a/plugins/Clist_nicer/src/clcopts.cpp b/plugins/Clist_nicer/src/clcopts.cpp index aa07621ba0..a2735846df 100644 --- a/plugins/Clist_nicer/src/clcopts.cpp +++ b/plugins/Clist_nicer/src/clcopts.cpp @@ -22,8 +22,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include -#include "../coolsb/coolscroll.h" +#include "stdafx.h" +#include "coolscroll.h" #include diff --git a/plugins/Clist_nicer/src/clcpaint.cpp b/plugins/Clist_nicer/src/clcpaint.cpp index 4dd4748b27..7a49a4aa0b 100644 --- a/plugins/Clist_nicer/src/clcpaint.cpp +++ b/plugins/Clist_nicer/src/clcpaint.cpp @@ -22,7 +22,7 @@ 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 "stdafx.h" extern struct avatarCache *g_avatarCache; extern int g_curAvatar; diff --git a/plugins/Clist_nicer/src/clcutils.cpp b/plugins/Clist_nicer/src/clcutils.cpp index 57a5023c87..da568c67a6 100644 --- a/plugins/Clist_nicer/src/clcutils.cpp +++ b/plugins/Clist_nicer/src/clcutils.cpp @@ -22,9 +22,9 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include +#include "stdafx.h" -#include "../coolsb/coolscroll.h" +#include "coolscroll.h" #ifndef SPI_GETDESKWALLPAPER #define SPI_GETDESKWALLPAPER 115 diff --git a/plugins/Clist_nicer/src/clist.h b/plugins/Clist_nicer/src/clist.h new file mode 100644 index 0000000000..6f9a0622ed --- /dev/null +++ b/plugins/Clist_nicer/src/clist.h @@ -0,0 +1,50 @@ +/* + +Miranda NG: the free IM client for Microsoft* Windows* + +Copyright (ñ) 2012-15 Miranda NG project (http://miranda-ng.org), +Copyright (c) 2000-03 Miranda ICQ/IM 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. +*/ + +void LoadContactTree(void); +int IconFromStatusMode(const char *szProto, int status, MCONTACT hContact, HICON *phIcon); +HTREEITEM GetTreeItemByHContact(MCONTACT hContact); +void SortContacts(void); + +#define CLUIINTM_REDRAW (WM_USER+100) +#define CLUIINTM_STATUSBARUPDATE (WM_USER+101) +#define CLUIINTM_REMOVEFROMTASKBAR (WM_USER+102) + +#define CLVM_FILTER_PROTOS 1 +#define CLVM_FILTER_GROUPS 2 +#define CLVM_FILTER_STATUS 4 +#define CLVM_FILTER_VARIABLES 8 +#define CLVM_STICKY_CONTACTS 16 +#define CLVM_FILTER_STICKYSTATUS 32 +#define CLVM_FILTER_LASTMSG 64 +#define CLVM_FILTER_LASTMSG_OLDERTHAN 128 +#define CLVM_FILTER_LASTMSG_NEWERTHAN 256 + +#define CLVM_PROTOGROUP_OP 1 +#define CLVM_GROUPSTATUS_OP 2 +#define CLVM_AUTOCLEAR 4 +#define CLVM_INCLUDED_UNGROUPED 8 +#define CLVM_USELASTMSG 16 + +#define CLVM_MODULE "CLVM_W" diff --git a/plugins/Clist_nicer/src/clistevents.cpp b/plugins/Clist_nicer/src/clistevents.cpp index 9d7e722d8b..b3b9c6cb37 100644 --- a/plugins/Clist_nicer/src/clistevents.cpp +++ b/plugins/Clist_nicer/src/clistevents.cpp @@ -22,8 +22,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include -#include "../cluiframes/cluiframes.h" +#include "stdafx.h" +#include "cluiframes.h" static HWND hwndEventFrame = 0; HFONT __fastcall ChangeToFont(HDC hdc, struct ClcData *dat, int id, int *fontHeight); diff --git a/plugins/Clist_nicer/src/clistmenus.cpp b/plugins/Clist_nicer/src/clistmenus.cpp index 8642b4978d..abaf6cda54 100644 --- a/plugins/Clist_nicer/src/clistmenus.cpp +++ b/plugins/Clist_nicer/src/clistmenus.cpp @@ -22,10 +22,10 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include +#include "stdafx.h" #include #include -#include "../CLUIFrames/cluiframes.h" +#include "cluiframes.h" #pragma hdrstop diff --git a/plugins/Clist_nicer/src/clistmod.cpp b/plugins/Clist_nicer/src/clistmod.cpp index bb19f80c8e..e590392b4d 100644 --- a/plugins/Clist_nicer/src/clistmod.cpp +++ b/plugins/Clist_nicer/src/clistmod.cpp @@ -22,7 +22,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include +#include "stdafx.h" extern int AddEvent(WPARAM wParam, LPARAM lParam); extern int RemoveEvent(WPARAM wParam, LPARAM lParam); diff --git a/plugins/Clist_nicer/src/clistopts.cpp b/plugins/Clist_nicer/src/clistopts.cpp index 291431b238..0059673aa8 100644 --- a/plugins/Clist_nicer/src/clistopts.cpp +++ b/plugins/Clist_nicer/src/clistopts.cpp @@ -22,7 +22,7 @@ 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 "stdafx.h" void LoadContactTree(void); void SortContacts(void); diff --git a/plugins/Clist_nicer/src/clistsettings.cpp b/plugins/Clist_nicer/src/clistsettings.cpp index 05e4cb7692..396b179b6a 100644 --- a/plugins/Clist_nicer/src/clistsettings.cpp +++ b/plugins/Clist_nicer/src/clistsettings.cpp @@ -22,7 +22,7 @@ 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 "stdafx.h" INT_PTR GetContactStatusMessage(WPARAM wParam, LPARAM lParam) { diff --git a/plugins/Clist_nicer/src/clisttray.cpp b/plugins/Clist_nicer/src/clisttray.cpp index f9c6ba956e..d60405fecc 100644 --- a/plugins/Clist_nicer/src/clisttray.cpp +++ b/plugins/Clist_nicer/src/clisttray.cpp @@ -22,7 +22,7 @@ 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 "stdafx.h" #define TRAYICON_ID_BASE 100 #define TIM_CALLBACK (WM_USER+1857) diff --git a/plugins/Clist_nicer/src/clnplus.cpp b/plugins/Clist_nicer/src/clnplus.cpp index eed275b1e3..a59b2ef982 100644 --- a/plugins/Clist_nicer/src/clnplus.cpp +++ b/plugins/Clist_nicer/src/clnplus.cpp @@ -2,7 +2,7 @@ * test for gdi+ */ -#include +#include "stdafx.h" #include #include "msapi/comptr.h" diff --git a/plugins/Clist_nicer/src/clui.cpp b/plugins/Clist_nicer/src/clui.cpp index bd4e65f1a5..80b01a7a48 100644 --- a/plugins/Clist_nicer/src/clui.cpp +++ b/plugins/Clist_nicer/src/clui.cpp @@ -22,10 +22,10 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include +#include "stdafx.h" #include -#include "../cluiframes/cluiframes.h" -#include "../coolsb/coolscroll.h" +#include "cluiframes.h" +#include "coolscroll.h" #define TM_AUTOALPHA 1 #define TIMERID_AUTOSIZE 100 diff --git a/plugins/Clist_nicer/src/cluiframes.cpp b/plugins/Clist_nicer/src/cluiframes.cpp new file mode 100644 index 0000000000..ace31e1037 --- /dev/null +++ b/plugins/Clist_nicer/src/cluiframes.cpp @@ -0,0 +1,3069 @@ +/* + +Miranda NG: the free IM client for Microsoft* Windows* + +Copyright (ñ) 2012-15 Miranda NG project (http://miranda-ng.org), +Copyright (c) 2000-03 Miranda ICQ/IM 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" +#include "cluiframes.h" +HFONT __fastcall ChangeToFont(HDC hdc, struct ClcData *dat, int id, int *fontHeight); + +extern HWND g_hwndViewModeFrame, g_hwndEventArea; +extern int mf_updatethread_running; + +extern HANDLE hThreadMFUpdate; + +void MF_UpdateThread(LPVOID); + +HANDLE hStatusBarShowToolTipEvent, hStatusBarHideToolTipEvent; +HANDLE g_hEventThread = 0; + +LOGFONT TitleBarLogFont = { 0 }; + +extern HINSTANCE g_hInst; + +//we use dynamic frame list, +//but who wants so huge number of frames ?? +#define MAX_FRAMES 40 + +#define UNCOLLAPSED_FRAME_SIZE 0 + +//legacy menu support +#define frame_menu_lock 1 +#define frame_menu_visible 2 +#define frame_menu_showtitlebar 3 +#define frame_menu_floating 4 +#define frame_menu_skinned 5 + +static int UpdateTBToolTip(int framepos); +INT_PTR CLUIFrameSetFloat(WPARAM wParam, LPARAM lParam); +int CLUIFrameResizeFloatingFrame(int framepos); +static int CLUIFramesReSort(); + +boolean FramesSysNotStarted = TRUE; +HPEN g_hPenCLUIFrames = 0; + +static SortData g_sd[MAX_FRAMES]; + +static HHOOK g_hFrameHook = 0; + +static int sortfunc(const void *a, const void *b) +{ + SortData *sd1, *sd2; + sd1 = (SortData *)a; + sd2 = (SortData *)b; + if (sd1->order > sd2->order) + return 1; + if (sd1->order < sd2->order) + return -1; + return 0; +} + +static FRAMEWND *Frames = NULL; + +FRAMEWND *wndFrameCLC = NULL, *wndFrameEventArea = NULL, *wndFrameViewMode = NULL; + +static int nFramescount = 0; +static int alclientFrame = -1;//for fast access to frame with alclient properties +static int NextFrameId = 100; + +static int TitleBarH = DEFAULT_TITLEBAR_HEIGHT; +static boolean resizing = FALSE; + +// menus +static FrameMenuHandles cont; + +// others +static int ContactListHeight; +static int LastStoreTick = 0; + +static int lbypos = -1; +static int oldframeheight = -1; +static int curdragbar = -1; +static mir_cs csFrameHook; + +static bool CLUIFramesFitInSize(void); +HWND hWndExplorerToolBar; +static int GapBetweenFrames = 1; + +static int RemoveItemFromList(int pos, FRAMEWND **lpFrames, int *FrameItemCount) +{ + memcpy(&((*lpFrames)[pos]), &((*lpFrames)[pos + 1]), sizeof(FRAMEWND) * (*FrameItemCount - pos - 1)); + (*FrameItemCount)--; + return 0; +} + +static int id2pos(int id) +{ + int i; + + if (FramesSysNotStarted) + return -1; + + for (i = 0; i < nFramescount; i++) { + if (Frames[i].id == id) + return i; + } + return -1; +} + +int __forceinline btoint(bool b) +{ + return (b ? 1 : 0); +} + +static FRAMEWND *FindFrameByWnd(HWND hwnd) +{ + if (hwnd == NULL) + return NULL; + + for (int i = 0; i < nFramescount; i++) + if ((Frames[i].floating) && (Frames[i].ContainerWnd == hwnd)) + return (&Frames[i]); + + return NULL; +} + +static void DockThumbs(FRAMEWND *pThumbLeft, FRAMEWND *pThumbRight, BOOL) +{ + if ((pThumbRight->dockOpt.hwndLeft == NULL) && (pThumbLeft->dockOpt.hwndRight == NULL)) { + pThumbRight->dockOpt.hwndLeft = pThumbLeft->ContainerWnd; + pThumbLeft->dockOpt.hwndRight = pThumbRight->ContainerWnd; + } +} + +static void UndockThumbs(FRAMEWND *pThumb1, FRAMEWND *pThumb2) +{ + if ((pThumb1 == NULL) || (pThumb2 == NULL)) + return; + + if (pThumb1->dockOpt.hwndRight == pThumb2->ContainerWnd) + pThumb1->dockOpt.hwndRight = NULL; + + if (pThumb1->dockOpt.hwndLeft == pThumb2->ContainerWnd) + pThumb1->dockOpt.hwndLeft = NULL; + + if (pThumb2->dockOpt.hwndRight == pThumb1->ContainerWnd) + pThumb2->dockOpt.hwndRight = NULL; + + if (pThumb2->dockOpt.hwndLeft == pThumb1->ContainerWnd) + pThumb2->dockOpt.hwndLeft = NULL; +} + +BOOLEAN bMoveTogether; + +static void PositionThumb(FRAMEWND *pThumb, short nX, short nY) +{ + FRAMEWND *pCurThumb = &Frames[0]; + FRAMEWND *pDockThumb = pThumb; + FRAMEWND fakeMainWindow; + FRAMEWND fakeTaskBarWindow; + RECT rc; + RECT rcThumb; + RECT rcOld; + SIZE sizeScreen; + int nOffs = 10; + POINT pt; + RECT rcLeft; + RECT rcTop; + RECT rcRight; + RECT rcBottom; + int frmidx = 0; + + if (pThumb == NULL) + return; + + sizeScreen.cx = GetSystemMetrics(SM_CXSCREEN); + sizeScreen.cy = GetSystemMetrics(SM_CYSCREEN); + + // Get thumb dimnsions + GetWindowRect(pThumb->ContainerWnd, &rcThumb); + int nWidth = rcThumb.right - rcThumb.left; + int nHeight = rcThumb.bottom - rcThumb.top; + + // Docking to the edges of the screen + int nNewX = nX < nOffs ? 0 : nX; + nNewX = nNewX >(sizeScreen.cx - nWidth - nOffs) ? (sizeScreen.cx - nWidth) : nNewX; + int nNewY = nY < nOffs ? 0 : nY; + nNewY = nNewY >(sizeScreen.cy - nHeight - nOffs) ? (sizeScreen.cy - nHeight) : nNewY; + + bool bLeading = pThumb->dockOpt.hwndRight != NULL; + + if (bMoveTogether) { + UndockThumbs(pThumb, FindFrameByWnd(pThumb->dockOpt.hwndLeft)); + GetWindowRect(pThumb->ContainerWnd, &rcOld); + } + + memset(&fakeMainWindow, 0, sizeof(fakeMainWindow)); + fakeMainWindow.ContainerWnd = pcli->hwndContactList; + fakeMainWindow.floating = TRUE; + + memset(&fakeTaskBarWindow, 0, sizeof(fakeTaskBarWindow)); + fakeTaskBarWindow.ContainerWnd = hWndExplorerToolBar; + fakeTaskBarWindow.floating = TRUE; + + while (pCurThumb != NULL) { + if (pCurThumb->floating) { + + if (pCurThumb != pThumb) { + GetWindowRect(pThumb->ContainerWnd, &rcThumb); + OffsetRect(&rcThumb, nX - rcThumb.left, nY - rcThumb.top); + + GetWindowRect(pCurThumb->ContainerWnd, &rc); + + rcLeft.left = rc.left - nOffs; + rcLeft.top = rc.top - nOffs; + rcLeft.right = rc.left + nOffs; + rcLeft.bottom = rc.bottom + nOffs; + + rcTop.left = rc.left - nOffs; + rcTop.top = rc.top - nOffs; + rcTop.right = rc.right + nOffs; + rcTop.bottom = rc.top + nOffs; + + rcRight.left = rc.right - nOffs; + rcRight.top = rc.top - nOffs; + rcRight.right = rc.right + nOffs; + rcRight.bottom = rc.bottom + nOffs; + + rcBottom.left = rc.left - nOffs; + rcBottom.top = rc.bottom - nOffs; + rcBottom.right = rc.right + nOffs; + rcBottom.bottom = rc.bottom + nOffs; + + bool bDockedLeft = false, bDockedRight = false, bDocked = false; + + // Upper-left + pt.x = rcThumb.left; + pt.y = rcThumb.top; + + if (PtInRect(&rcRight, pt)) { + nNewX = rc.right; + bDocked = true; + } + + if (PtInRect(&rcBottom, pt)) { + nNewY = rc.bottom; + if (PtInRect(&rcLeft, pt)) + nNewX = rc.left; + } + + if (PtInRect(&rcTop, pt)) { + nNewY = rc.top; + bDockedLeft = bDocked; + } + + // Upper-right + pt.x = rcThumb.right; + pt.y = rcThumb.top; + bDocked = false; + + if (!bLeading && PtInRect(&rcLeft, pt)) { + if (!bDockedLeft) { + nNewX = rc.left - nWidth; + bDocked = true; + } + else if (rc.right == rcThumb.left) + bDocked = true; + } + + + if (PtInRect(&rcBottom, pt)) { + nNewY = rc.bottom; + if (PtInRect(&rcRight, pt)) + nNewX = rc.right - nWidth; + } + + if (!bLeading && PtInRect(&rcTop, pt)) { + nNewY = rc.top; + bDockedRight = bDocked; + } + + if (bMoveTogether) { + if (bDockedRight) + DockThumbs(pThumb, pCurThumb, TRUE); + + if (bDockedLeft) + DockThumbs(pCurThumb, pThumb, FALSE); + } + + // Lower-left + pt.x = rcThumb.left; + pt.y = rcThumb.bottom; + + if (PtInRect(&rcRight, pt)) + nNewX = rc.right; + + if (PtInRect(&rcTop, pt)) { + nNewY = rc.top - nHeight; + + if (PtInRect(&rcLeft, pt)) + nNewX = rc.left; + } + + + // Lower-right + pt.x = rcThumb.right; + pt.y = rcThumb.bottom; + + if (!bLeading && PtInRect(&rcLeft, pt)) + nNewX = rc.left - nWidth; + + if (!bLeading && PtInRect(&rcTop, pt)) { + nNewY = rc.top - nHeight; + + if (PtInRect(&rcRight, pt)) + nNewX = rc.right - nWidth; + } + } + } + + frmidx++; + if (pCurThumb->ContainerWnd == fakeTaskBarWindow.ContainerWnd) + break; + + if (pCurThumb->ContainerWnd == fakeMainWindow.ContainerWnd) { + pCurThumb = &fakeTaskBarWindow; + continue; + } + if (frmidx == nFramescount) { + pCurThumb = &fakeMainWindow; + continue; + } + pCurThumb = &Frames[frmidx]; + } + + // Adjust coords once again + nNewX = nNewX < nOffs ? 0 : nNewX; + nNewX = nNewX > (sizeScreen.cx - nWidth - nOffs) ? (sizeScreen.cx - nWidth) : nNewX; + nNewY = nNewY < nOffs ? 0 : nNewY; + nNewY = nNewY > (sizeScreen.cy - nHeight - nOffs) ? (sizeScreen.cy - nHeight) : nNewY; + SetWindowPos(pThumb->ContainerWnd, 0, nNewX, nNewY, 0, 0, SWP_NOSIZE | SWP_NOZORDER); + + // OK, move all docked thumbs + if (bMoveTogether) { + pDockThumb = FindFrameByWnd(pDockThumb->dockOpt.hwndRight); + PositionThumb(pDockThumb, (short)(nNewX + nWidth), (short)nNewY); + } +} + +void GetBorderSize(HWND hwnd, RECT *rect) +{ + RECT wr, cr; + POINT pt1, pt2; + + GetWindowRect(hwnd, &wr); + GetClientRect(hwnd, &cr); + pt1.y = cr.top; + pt1.x = cr.left; + pt2.y = cr.bottom; + pt2.x = cr.right; + + ClientToScreen(hwnd, &pt1); + ClientToScreen(hwnd, &pt2); + + cr.top = pt1.y; + cr.left = pt1.x; + cr.bottom = pt2.y; + cr.right = pt2.x; + + rect->top = cr.top - wr.top; + rect->left = cr.left - wr.left; + rect->right = wr.right - cr.right; + rect->bottom = wr.bottom - cr.bottom; +} + +//append string +char __forceinline *AS(char *str, const char *setting, char *addstr) +{ + if (str != NULL) { + mir_strcpy(str, setting); + mir_strcat(str, addstr); + } + return str; +} + +int DBLoadFrameSettingsAtPos(int pos, int Frameid) +{ + char sadd[15]; + char buf[255]; + + _itoa(pos, sadd, 10); + + Frames[Frameid].collapsed = 0 != cfg::getByte(CLUIFrameModule, AS(buf, "Collapse", sadd), Frames[Frameid].collapsed); + + Frames[Frameid].Locked = 0 != cfg::getByte(CLUIFrameModule, AS(buf, "Locked", sadd), Frames[Frameid].Locked); + Frames[Frameid].visible = 0 != cfg::getByte(CLUIFrameModule, AS(buf, "Visible", sadd), Frames[Frameid].visible); + Frames[Frameid].TitleBar.ShowTitleBar = 0 != cfg::getByte(CLUIFrameModule, AS(buf, "TBVisile", sadd), Frames[Frameid].TitleBar.ShowTitleBar); + + Frames[Frameid].height = cfg::getWord(CLUIFrameModule, AS(buf, "Height", sadd), Frames[Frameid].height); + Frames[Frameid].HeightWhenCollapsed = cfg::getWord(CLUIFrameModule, AS(buf, "HeightCollapsed", sadd), 0); + Frames[Frameid].align = cfg::getWord(CLUIFrameModule, AS(buf, "Align", sadd), Frames[Frameid].align); + + Frames[Frameid].FloatingPos.x = DBGetContactSettingRangedWord(0, CLUIFrameModule, AS(buf, "FloatX", sadd), 100, 0, 1024); + Frames[Frameid].FloatingPos.y = DBGetContactSettingRangedWord(0, CLUIFrameModule, AS(buf, "FloatY", sadd), 100, 0, 1024); + Frames[Frameid].FloatingSize.x = DBGetContactSettingRangedWord(0, CLUIFrameModule, AS(buf, "FloatW", sadd), 100, 0, 1024); + Frames[Frameid].FloatingSize.y = DBGetContactSettingRangedWord(0, CLUIFrameModule, AS(buf, "FloatH", sadd), 100, 0, 1024); + + Frames[Frameid].floating = 0 != cfg::getByte(CLUIFrameModule, AS(buf, "Floating", sadd), 0); + Frames[Frameid].order = cfg::getWord(CLUIFrameModule, AS(buf, "Order", sadd), 0); + + Frames[Frameid].UseBorder = 0 != cfg::getByte(CLUIFrameModule, AS(buf, "UseBorder", sadd), Frames[Frameid].UseBorder); + Frames[Frameid].Skinned = 0 != cfg::getByte(CLUIFrameModule, AS(buf, "Skinned", sadd), Frames[Frameid].Skinned); + return 0; +} + +int DBStoreFrameSettingsAtPos(int pos, int Frameid) +{ + char sadd[16]; + char buf[255]; + + _itoa(pos, sadd, 10); + + cfg::writeTString(0, CLUIFrameModule, AS(buf, "Name", sadd), Frames[Frameid].name); + //boolean + cfg::writeByte(0, CLUIFrameModule, AS(buf, "Collapse", sadd), (BYTE)btoint(Frames[Frameid].collapsed)); + cfg::writeByte(0, CLUIFrameModule, AS(buf, "Locked", sadd), (BYTE)btoint(Frames[Frameid].Locked)); + cfg::writeByte(0, CLUIFrameModule, AS(buf, "Visible", sadd), (BYTE)btoint(Frames[Frameid].visible)); + cfg::writeByte(0, CLUIFrameModule, AS(buf, "TBVisile", sadd), (BYTE)btoint(Frames[Frameid].TitleBar.ShowTitleBar)); + + cfg::writeWord(CLUIFrameModule, AS(buf, "Height", sadd), (WORD)Frames[Frameid].height); + cfg::writeWord(CLUIFrameModule, AS(buf, "HeightCollapsed", sadd), (WORD)Frames[Frameid].HeightWhenCollapsed); + cfg::writeWord(CLUIFrameModule, AS(buf, "Align", sadd), (WORD)Frames[Frameid].align); + //FloatingPos + cfg::writeWord(CLUIFrameModule, AS(buf, "FloatX", sadd), (WORD)Frames[Frameid].FloatingPos.x); + cfg::writeWord(CLUIFrameModule, AS(buf, "FloatY", sadd), (WORD)Frames[Frameid].FloatingPos.y); + cfg::writeWord(CLUIFrameModule, AS(buf, "FloatW", sadd), (WORD)Frames[Frameid].FloatingSize.x); + cfg::writeWord(0, CLUIFrameModule, AS(buf, "FloatH", sadd), (WORD)Frames[Frameid].FloatingSize.y); + + cfg::writeByte(0, CLUIFrameModule, AS(buf, "Floating", sadd), (BYTE)btoint(Frames[Frameid].floating)); + cfg::writeByte(0, CLUIFrameModule, AS(buf, "UseBorder", sadd), (BYTE)btoint(Frames[Frameid].UseBorder)); + cfg::writeWord(0, CLUIFrameModule, AS(buf, "Order", sadd), (WORD)Frames[Frameid].order); + + cfg::writeByte(CLUIFrameModule, AS(buf, "Skinned", sadd), Frames[Frameid].Skinned); + return 0; +} + +int LocateStorePosition(int Frameid, int maxstored) +{ + if (Frames[Frameid].name == NULL) return -1; + + for (int i = 0; i < maxstored; i++) { + char settingname[255]; + mir_snprintf(settingname, _countof(settingname), "Name%d", i); + ptrT frmname(db_get_tsa(0, CLUIFrameModule, settingname)); + if (frmname == NULL) continue; + if (mir_tstrcmpi(frmname, Frames[Frameid].name) == 0) + return i; + } + return -1; +} + +int CLUIFramesLoadFrameSettings(int Frameid) +{ + int storpos, maxstored; + + if (FramesSysNotStarted) return -1; + + if (Frameid < 0 || Frameid >= nFramescount) + return -1; + + maxstored = cfg::getWord(CLUIFrameModule, "StoredFrames", -1); + if (maxstored == -1) + return 0; + + storpos = LocateStorePosition(Frameid, maxstored); + if (storpos == -1) + return 0; + + DBLoadFrameSettingsAtPos(storpos, Frameid); + return 0; +} + +int CLUIFramesStoreFrameSettings(int Frameid) +{ + int maxstored, storpos; + + if (FramesSysNotStarted) + return -1; + + if (Frameid < 0 || Frameid >= nFramescount) + return -1; + + maxstored = cfg::getWord(CLUIFrameModule, "StoredFrames", -1); + if (maxstored == -1) + maxstored = 0; + + storpos = LocateStorePosition(Frameid, maxstored); + if (storpos == -1) { + storpos = maxstored; + maxstored++; + } + + DBStoreFrameSettingsAtPos(storpos, Frameid); + cfg::writeWord(CLUIFrameModule, "StoredFrames", (WORD)maxstored); + return 0; +} + +int CLUIFramesStoreAllFrames() +{ + int i; + + if (FramesSysNotStarted) + return -1; + + if (cfg::shutDown) + return -1; + + mir_cslock lck(csFrameHook); + for (i = 0; i < nFramescount; i++) + CLUIFramesStoreFrameSettings(i); + return 0; +} + +// Get client frame +int CLUIFramesGetalClientFrame(void) +{ + int i; + if (FramesSysNotStarted) + return -1; + + if (alclientFrame != -1) { + /* this value could become invalid if RemoveItemFromList was called, + * so we double-check */ + if (alclientFrame < nFramescount) { + if (Frames[alclientFrame].align == alClient) { + return alclientFrame; + } + } + } + + for (i = 0; i < nFramescount; i++) + if (Frames[i].align == alClient) { + alclientFrame = i; + return i; + } + return -1; +} + +///////////////////////////////////////////////////////////////////////////////////////// + +static HGENMENU addFrameMenuItem(TMO_MenuItem *pmi, int frameid, bool bMain) +{ + HGENMENU res = (bMain) ? Menu_AddMainMenuItem(pmi) : Menu_AddContextFrameMenuItem(pmi); + if (pmi->pszService != NULL) + Menu_ConfigureItem(res, MCI_OPT_EXECPARAM, frameid); + return res; +} + +HMENU CLUIFramesCreateMenuForFrame(int frameid, HGENMENU root, int popuppos, bool bMain) +{ + if (FramesSysNotStarted) + return NULL; + + int framepos = id2pos(frameid); + FrameMenuHandles &fmh = (frameid == -1) ? cont : Frames[framepos].MenuHandles; + + CMenuItem mi; + mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_MIRANDA); + mi.root = root; + mi.position = popuppos++; + mi.name.a = LPGEN("&FrameTitle"); + mi.flags = CMIF_SYSTEM | CMIF_GRAYED; + fmh.MITitle = addFrameMenuItem(&mi, frameid, bMain); + + popuppos += 100000; + + mi.hIcolibItem = NULL; + mi.position = popuppos++; + mi.name.a = LPGEN("&Visible"); + mi.flags = CMIF_SYSTEM | CMIF_CHECKED; + mi.pszService = MS_CLIST_FRAMES_SHFRAME; + fmh.MIVisible = addFrameMenuItem(&mi, frameid, bMain); + + mi.position = popuppos++; + mi.name.a = LPGEN("&Show title bar"); + mi.pszService = MS_CLIST_FRAMES_SHFRAMETITLEBAR; + fmh.MITBVisible = addFrameMenuItem(&mi, frameid, bMain); + + popuppos += 100000; + + mi.position = popuppos++; + mi.name.a = LPGEN("&Locked"); + mi.pszService = MS_CLIST_FRAMES_ULFRAME; + fmh.MILock = addFrameMenuItem(&mi, frameid, bMain); + + mi.position = popuppos++; + mi.name.a = LPGEN("&Collapsed"); + mi.pszService = MS_CLIST_FRAMES_UCOLLFRAME; + fmh.MIColl = addFrameMenuItem(&mi, frameid, bMain); + + // floating + mi.position = popuppos++; + mi.name.a = LPGEN("&Floating mode"); + mi.flags = CMIF_SYSTEM; + mi.pszService = "Set_Floating"; + fmh.MIFloating = addFrameMenuItem(&mi, frameid, bMain); + + popuppos += 100000; + + mi.position = popuppos++; + mi.name.a = LPGEN("&Border"); + mi.flags = CMIF_SYSTEM | CMIF_CHECKED; + mi.pszService = MS_CLIST_FRAMES_SETUNBORDER; + fmh.MIBorder = addFrameMenuItem(&mi, frameid, bMain); + + popuppos += 100000; + + mi.position = popuppos++; + mi.name.a = LPGEN("&Skinned frame"); + mi.pszService = MS_CLIST_FRAMES_SETSKINNED; + fmh.MISkinned = addFrameMenuItem(&mi, frameid, bMain); + + popuppos += 100000; + + // alignment root + mi.root = root; + mi.position = popuppos++; + mi.name.a = LPGEN("&Align"); + mi.flags = CMIF_SYSTEM; + mi.pszService = NULL; + fmh.MIAlignRoot = addFrameMenuItem(&mi, frameid, bMain); + + // align top + mi.root = fmh.MIAlignRoot; + mi.position = popuppos++; + mi.name.a = LPGEN("&Top"); + mi.pszService = CLUIFRAMESSETALIGNALTOP; + fmh.MIAlignTop = addFrameMenuItem(&mi, frameid, bMain); + + // align client + mi.position = popuppos++; + mi.name.a = LPGEN("&Client"); + mi.pszService = CLUIFRAMESSETALIGNALCLIENT; + fmh.MIAlignClient = addFrameMenuItem(&mi, frameid, bMain); + + // align bottom + mi.position = popuppos++; + mi.name.a = LPGEN("&Bottom"); + mi.pszService = CLUIFRAMESSETALIGNALBOTTOM; + fmh.MIAlignBottom = addFrameMenuItem(&mi, frameid, bMain); + + // position root + mi.root = root; + mi.position = popuppos++; + mi.name.a = LPGEN("&Position"); + mi.pszService = NULL; + mi.root = addFrameMenuItem(&mi, frameid, bMain); + + mi.position = popuppos++; + mi.name.a = LPGEN("&Up"); + mi.pszService = CLUIFRAMESMOVEUP; + addFrameMenuItem(&mi, frameid, bMain); + + mi.position = popuppos++; + mi.name.a = LPGEN("&Down"); + mi.pszService = CLUIFRAMESMOVEDOWN; + addFrameMenuItem(&mi, frameid, bMain); + return 0; +} + +static int CLUIFramesModifyContextMenuForFrame(WPARAM wParam, LPARAM) +{ + if (FramesSysNotStarted) + return -1; + + mir_cslock lck(csFrameHook); + int pos = id2pos(wParam); + if (pos >= 0 && pos < nFramescount) { + FRAMEWND &p = Frames[pos]; + Menu_ModifyItem(cont.MITitle, p.TitleBar.tbname ? p.TitleBar.tbname : p.name); + Menu_SetChecked(cont.MIVisible, p.visible); + Menu_SetChecked(cont.MILock, p.Locked); + Menu_SetChecked(cont.MITBVisible, p.TitleBar.ShowTitleBar); + Menu_SetChecked(cont.MIFloating, p.floating); + Menu_SetChecked(cont.MIBorder, p.UseBorder); + Menu_SetChecked(cont.MISkinned, p.Skinned); + Menu_SetChecked(cont.MIAlignTop, (p.align & alTop) != 0); + Menu_SetChecked(cont.MIAlignClient, (p.align & alClient) != 0); + Menu_SetChecked(cont.MIAlignBottom, (p.align & alBottom) != 0); + + Menu_SetChecked(cont.MIColl, !p.collapsed); + Menu_EnableItem(cont.MIColl, p.visible && !p.Locked && pos != CLUIFramesGetalClientFrame()); + } + return 0; +} + +INT_PTR CLUIFramesModifyMainMenuItems(WPARAM frameId, LPARAM) +{ + if (FramesSysNotStarted) + return -1; + + mir_cslock lck(csFrameHook); + int pos = id2pos(frameId); + + if (pos >= 0 && pos < nFramescount) { + FRAMEWND &p = Frames[pos]; + Menu_ModifyItem(p.MenuHandles.MITitle, p.TitleBar.tbname ? p.TitleBar.tbname : p.name); + + Menu_SetChecked(p.MenuHandles.MIVisible, p.visible); + Menu_SetChecked(p.MenuHandles.MILock, p.Locked); + Menu_SetChecked(p.MenuHandles.MITBVisible, p.TitleBar.ShowTitleBar); + Menu_SetChecked(p.MenuHandles.MIFloating, p.floating); + Menu_SetChecked(p.MenuHandles.MIBorder, p.UseBorder); + Menu_SetChecked(p.MenuHandles.MISkinned, p.Skinned); + + Menu_EnableItem(p.MenuHandles.MIAlignTop, (p.align & alClient) == 0); + Menu_SetChecked(p.MenuHandles.MIAlignTop, (p.align & alTop) != 0); + + Menu_SetChecked(p.MenuHandles.MIAlignClient, (p.align & alClient) != 0); + + Menu_EnableItem(p.MenuHandles.MIAlignTop, (p.align & alClient) == 0); + Menu_SetChecked(p.MenuHandles.MIAlignTop, (p.align & alBottom) != 0); + + Menu_SetChecked(p.MenuHandles.MIColl, !p.collapsed); + Menu_EnableItem(p.MenuHandles.MIColl, p.visible && !p.Locked && pos != CLUIFramesGetalClientFrame()); + } + return 0; +} + +INT_PTR CLUIFramesGetFrameOptions(WPARAM wParam, LPARAM) +{ + if (FramesSysNotStarted) return -1; + + mir_cslock lck(csFrameHook); + int pos = id2pos(HIWORD(wParam)); + if (pos < 0 || pos >= nFramescount) + return -1; + + switch (LOWORD(wParam)) { + case FO_NAME: + return (INT_PTR)Frames[pos].name; + + case FO_TBNAME: + return (INT_PTR)Frames[pos].TitleBar.tbname; + + case FO_TBTIPNAME: + return (INT_PTR)Frames[pos].TitleBar.tooltip; + + case FO_TBSTYLE: + return GetWindowLongPtr(Frames[pos].TitleBar.hwnd, GWL_STYLE); + + case FO_TBEXSTYLE: + return GetWindowLongPtr(Frames[pos].TitleBar.hwnd, GWL_EXSTYLE); + + case FO_ICON: + return (INT_PTR)Frames[pos].TitleBar.hicon; + + case FO_HEIGHT: + return (INT_PTR)Frames[pos].height; + + case FO_ALIGN: + return (INT_PTR)Frames[pos].align; + + case FO_FLOATING: + return (INT_PTR)Frames[pos].floating; + + case FO_FLAGS: + INT_PTR dwFlags = 0; + if (Frames[pos].visible) dwFlags |= F_VISIBLE; + if (!Frames[pos].collapsed) dwFlags |= F_UNCOLLAPSED; + if (Frames[pos].Locked) dwFlags |= F_LOCKED; + if (Frames[pos].TitleBar.ShowTitleBar) dwFlags |= F_SHOWTB; + if (Frames[pos].TitleBar.ShowTitleBarTip) dwFlags |= F_SHOWTBTIP; + if (Frames[pos].Skinned) dwFlags |= F_SKINNED; + if (!(GetWindowLongPtr(Frames[pos].hWnd, GWL_STYLE)&WS_BORDER)) dwFlags |= F_NOBORDER; + return dwFlags; + } + + return -1; +} + +INT_PTR CLUIFramesSetFrameOptions(WPARAM wParam, LPARAM lParam) +{ + int retval; // value to be returned + + if (FramesSysNotStarted) + return -1; + + mir_cslockfull lck(csFrameHook); + int pos = id2pos(HIWORD(wParam)); + if (pos < 0 || pos >= nFramescount) + return -1; + + switch (LOWORD(wParam) & ~FO_UNICODETEXT) { + case FO_FLAGS: + { + int flag = lParam; + LONG_PTR style; + + Frames[pos].dwFlags = flag; + Frames[pos].visible = FALSE; + if (flag & F_VISIBLE) Frames[pos].visible = TRUE; + + Frames[pos].collapsed = TRUE; + if (flag & F_UNCOLLAPSED) Frames[pos].collapsed = FALSE; + + Frames[pos].Locked = FALSE; + if (flag & F_LOCKED) Frames[pos].Locked = TRUE; + + Frames[pos].UseBorder = TRUE; + if (flag & F_NOBORDER) Frames[pos].UseBorder = FALSE; + + Frames[pos].TitleBar.ShowTitleBar = FALSE; + if (flag & F_SHOWTB) Frames[pos].TitleBar.ShowTitleBar = TRUE; + + Frames[pos].TitleBar.ShowTitleBarTip = FALSE; + if (flag & F_SHOWTBTIP) Frames[pos].TitleBar.ShowTitleBarTip = TRUE; + + SendMessage(Frames[pos].TitleBar.hwndTip, TTM_ACTIVATE, (WPARAM)Frames[pos].TitleBar.ShowTitleBarTip, 0); + + style = GetWindowLongPtr(Frames[pos].hWnd, GWL_STYLE); + style |= WS_BORDER; + style |= CLS_SKINNEDFRAME; + + if (flag & F_NOBORDER) + style &= (~WS_BORDER); + + Frames[pos].Skinned = FALSE; + if (flag & F_SKINNED) + Frames[pos].Skinned = TRUE; + + if (!(flag & F_SKINNED)) + style &= ~CLS_SKINNEDFRAME; + + SetWindowLongPtr(Frames[pos].hWnd, GWL_STYLE, (LONG_PTR)style); + SetWindowLongPtr(Frames[pos].TitleBar.hwnd, GWL_STYLE, (LONG_PTR)style & ~(WS_VSCROLL | WS_HSCROLL)); + lck.unlock(); + + CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0); + SetWindowPos(Frames[pos].TitleBar.hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED); + } + return 0; + + case FO_NAME: + if (lParam == 0) + return -1; + + mir_free(Frames[pos].name); + Frames[pos].name = (wParam & FO_UNICODETEXT) ? mir_u2t((LPWSTR)lParam) : mir_a2t((LPSTR)lParam); + return 0; + + case FO_TBNAME: + if (lParam == 0) + return -1; + + mir_free(Frames[pos].TitleBar.tbname); + Frames[pos].TitleBar.tbname = (wParam & FO_UNICODETEXT) ? mir_u2t((LPWSTR)lParam) : mir_a2t((LPSTR)lParam); + lck.unlock(); + + if (Frames[pos].floating && (Frames[pos].TitleBar.tbname != NULL)) + SetWindowText(Frames[pos].ContainerWnd, Frames[pos].TitleBar.tbname); + return 0; + + case FO_TBTIPNAME: + if (lParam == 0) + return -1; + + mir_free(Frames[pos].TitleBar.tooltip); + Frames[pos].TitleBar.tooltip = (wParam & FO_UNICODETEXT) ? mir_u2t((LPWSTR)lParam) : mir_a2t((LPSTR)lParam); + UpdateTBToolTip(pos); + return 0; + + case FO_TBSTYLE: + SetWindowLongPtr(Frames[pos].TitleBar.hwnd, GWL_STYLE, lParam); + return 0; + + case FO_TBEXSTYLE: + SetWindowLongPtr(Frames[pos].TitleBar.hwnd, GWL_EXSTYLE, lParam); + return 0; + + case FO_ICON: + Frames[pos].TitleBar.hicon = (HICON)lParam; + return 0; + + case FO_HEIGHT: + if (lParam < 0) + return -1; + + if (Frames[pos].Skinned) { + int uID = (Frames[pos].TitleBar.ShowTitleBar ? ID_EXTBKOWNEDFRAMEBORDERTB - ID_STATUS_OFFLINE : ID_EXTBKOWNEDFRAMEBORDER - ID_STATUS_OFFLINE); + lParam += (arStatusItems[uID]->MARGIN_BOTTOM + arStatusItems[uID]->MARGIN_TOP); + } + if (Frames[pos].collapsed) { + int oldHeight = Frames[pos].height; + retval = Frames[pos].height; + Frames[pos].height = lParam; + if (!CLUIFramesFitInSize()) + Frames[pos].height = retval; + retval = Frames[pos].height; + + if (Frames[pos].height != oldHeight) { + CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0); + if (Frames[pos].Skinned) + RedrawWindow(Frames[pos].hWnd, 0, 0, RDW_FRAME | RDW_UPDATENOW | RDW_INVALIDATE); + } + } + else { + retval = Frames[pos].HeightWhenCollapsed; + Frames[pos].HeightWhenCollapsed = lParam; + if (!CLUIFramesFitInSize()) + Frames[pos].HeightWhenCollapsed = retval; + retval = Frames[pos].HeightWhenCollapsed; + } + return retval; + + case FO_FLOATING: + if (lParam < 0) + return -1; + else { + int id = Frames[pos].id; + Frames[pos].floating = !(lParam); + lck.unlock(); + + CLUIFrameSetFloat(id, 1);//lparam=1 use stored width and height + } + return wParam; + + case FO_ALIGN: + if (!(lParam&alTop || lParam&alBottom || lParam&alClient)) + return -1; + + if ((lParam&alClient) && (CLUIFramesGetalClientFrame() >= 0)) { //only one alClient frame possible + alclientFrame = -1;//recalc it + return -1; + } + Frames[pos].align = lParam; + return 0; + } + lck.unlock(); + + CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0); + return -1; +} + +static INT_PTR CLUIFramesShowAll(WPARAM, LPARAM) +{ + if (FramesSysNotStarted) + return -1; + + for (int i = 0; i < nFramescount; i++) + Frames[i].visible = TRUE; + + CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0); + return 0; +} + +INT_PTR CLUIFramesShowAllTitleBars(WPARAM, LPARAM) +{ + if (FramesSysNotStarted) + return -1; + + for (int i = 0; i < nFramescount; i++) { + Frames[i].TitleBar.ShowTitleBar = TRUE; + SetWindowPos(Frames[i].hWnd, 0, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED); + } + CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0); + RedrawWindow(pcli->hwndContactList, NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_UPDATENOW | RDW_ALLCHILDREN); + return 0; +} + +INT_PTR CLUIFramesHideAllTitleBars(WPARAM, LPARAM) +{ + if (FramesSysNotStarted) + return -1; + + for (int i = 0; i < nFramescount; i++) { + Frames[i].TitleBar.ShowTitleBar = FALSE; + SetWindowPos(Frames[i].hWnd, 0, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED); + } + CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0); + RedrawWindow(pcli->hwndContactList, NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_UPDATENOW | RDW_ALLCHILDREN); + return 0; +} + +INT_PTR CLUIFramesShowHideFrame(WPARAM frameId, LPARAM) +{ + if (FramesSysNotStarted) + return -1; + + int pos; + { + mir_cslock lck(csFrameHook); + pos = id2pos(frameId); + if (pos >= 0 && !mir_tstrcmp(Frames[pos].name, _T("My contacts"))) + Frames[pos].visible = 1; + else { + if (pos >= 0 && (int)pos < nFramescount) + Frames[pos].visible = !Frames[pos].visible; + if (Frames[pos].floating) + CLUIFrameResizeFloatingFrame(pos); + } + } + + if (!Frames[pos].floating) + CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0); + RedrawWindow(pcli->hwndContactList, NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_UPDATENOW | RDW_ALLCHILDREN); + return 0; +} + +INT_PTR CLUIFramesShowHideFrameTitleBar(WPARAM frameId, LPARAM) +{ + if (FramesSysNotStarted) + return -1; + + { + mir_cslock lck(csFrameHook); + int pos = id2pos(frameId); + if (pos >= 0 && (int)pos < nFramescount) { + Frames[pos].TitleBar.ShowTitleBar = !Frames[pos].TitleBar.ShowTitleBar; + SetWindowPos(Frames[pos].hWnd, 0, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED); + } + } + + CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0); + RedrawWindow(pcli->hwndContactList, NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_UPDATENOW | RDW_ALLCHILDREN); + return 0; +} + +// lparam=-1 up ,1 down +INT_PTR CLUIFramesMoveUpDown(WPARAM frameId, LPARAM lParam) +{ + int i, tmpval; + + if (FramesSysNotStarted) + return -1; + + mir_cslockfull lck(csFrameHook); + int pos = id2pos(frameId); + if (pos < 0 || pos >= nFramescount) + return 0; + + int curalign = Frames[pos].align; + int v = 0; + memset(g_sd, 0, sizeof(SortData) * MAX_FRAMES); + for (i = 0; i < nFramescount; i++) { + if (Frames[i].floating || (!Frames[i].visible) || (Frames[i].align != curalign)) + continue; + g_sd[v].order = Frames[i].order; + g_sd[v].realpos = i; + v++; + } + if (v == 0) + return 0; + + qsort(g_sd, v, sizeof(SortData), sortfunc); + for (i = 0; i < v; i++) { + if (g_sd[i].realpos == pos) { + if (lParam == -1) { + if (i < 1) break; + tmpval = Frames[g_sd[i - 1].realpos].order; + Frames[g_sd[i - 1].realpos].order = Frames[pos].order; + Frames[pos].order = tmpval; + break; + } + if (lParam == 1) { + if (i > v - 1) break; + tmpval = Frames[g_sd[i + 1].realpos].order; + Frames[g_sd[i + 1].realpos].order = Frames[pos].order; + Frames[pos].order = tmpval; + break; + } + } + } + lck.unlock(); + + CLUIFramesReSort(); + CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0); + PostMessage(pcli->hwndContactList, CLUIINTM_REDRAW, 0, 0); + return 0; +} + +static INT_PTR CLUIFramesMoveUp(WPARAM frameId, LPARAM) +{ + return CLUIFramesMoveUpDown(frameId, -1); +} + +static INT_PTR CLUIFramesMoveDown(WPARAM frameId, LPARAM) +{ + return CLUIFramesMoveUpDown(frameId, 1); +} + +//lparam=alignment +INT_PTR CLUIFramesSetAlign(WPARAM frameId, LPARAM lParam) +{ + if (FramesSysNotStarted) return -1; + + CLUIFramesSetFrameOptions(MAKEWPARAM(FO_ALIGN, frameId), lParam); + CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0); + RedrawWindow(pcli->hwndContactList, NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_UPDATENOW | RDW_ALLCHILDREN); + return 0; +} + +INT_PTR CLUIFramesSetAlignalTop(WPARAM wParam, LPARAM) +{ + if (FramesSysNotStarted) return -1; + + return CLUIFramesSetAlign(wParam, alTop); +} + +INT_PTR CLUIFramesSetAlignalBottom(WPARAM wParam, LPARAM) +{ + if (FramesSysNotStarted) return -1; + + return CLUIFramesSetAlign(wParam, alBottom); +} + +INT_PTR CLUIFramesSetAlignalClient(WPARAM wParam, LPARAM) +{ + if (FramesSysNotStarted) return -1; + + return CLUIFramesSetAlign(wParam, alClient); +} + +//wparam=frameid +INT_PTR CLUIFramesLockUnlockFrame(WPARAM wParam, LPARAM) +{ + if (FramesSysNotStarted) + return -1; + + mir_cslock lck(csFrameHook); + int pos = id2pos(wParam); + if (pos >= 0 && (int)pos < nFramescount) { + Frames[pos].Locked = !Frames[pos].Locked; + CLUIFramesStoreFrameSettings(pos); + } + return 0; +} + +//wparam=frameid +INT_PTR CLUIFramesSetUnSetBorder(WPARAM wParam, LPARAM) +{ + if (FramesSysNotStarted) + return -1; + + HWND hw; + int FrameId, oldflags; + { + mir_cslock lck(csFrameHook); + FrameId = id2pos(wParam); + if (FrameId == -1) + return -1; + + oldflags = CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_FLAGS, wParam), 0); + if (oldflags & F_NOBORDER) + oldflags &= (~F_NOBORDER); + else + oldflags |= F_NOBORDER; + + hw = Frames[FrameId].hWnd; + } + + CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS, MAKEWPARAM(FO_FLAGS, wParam), oldflags); + SetWindowPos(hw, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_DRAWFRAME | SWP_NOZORDER); + return 0; +} + +//wparam=frameid +INT_PTR CLUIFramesSetUnSetSkinned(WPARAM wParam, LPARAM) +{ + if (FramesSysNotStarted) + return -1; + + HWND hw; + int FrameId, oldflags; + { + mir_cslock lck(csFrameHook); + FrameId = id2pos(wParam); + if (FrameId == -1) + return -1; + + oldflags = CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_FLAGS, wParam), 0); + if (oldflags & F_SKINNED) + oldflags &= ~F_SKINNED; + else + oldflags |= F_SKINNED; + + hw = Frames[FrameId].hWnd; + } + + CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS, MAKEWPARAM(FO_FLAGS, wParam), oldflags); + SetWindowPos(hw, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_DRAWFRAME | SWP_NOZORDER); + return 0; +} + +//wparam=frameid +INT_PTR CLUIFramesCollapseUnCollapseFrame(WPARAM wParam, LPARAM) +{ + if (FramesSysNotStarted) + return -1; + + TitleBarH = cfg::dat.titleBarHeight; + + mir_cslockfull lck(csFrameHook); + int FrameId = id2pos(wParam); + if (FrameId < 0 || FrameId >= nFramescount) + return -1; + + int oldHeight; + + // do not collapse/uncollapse client/locked/invisible frames + if (Frames[FrameId].align == alClient && !(Frames[FrameId].Locked || (!Frames[FrameId].visible) || Frames[FrameId].floating)) { + RECT rc; + if (CallService(MS_CLIST_DOCKINGISDOCKED, 0, 0)) + return 0; + + if (cfg::getByte("CLUI", "AutoSize", 0)) + return 0; + + GetWindowRect(pcli->hwndContactList, &rc); + + if (Frames[FrameId].collapsed == TRUE) { + rc.bottom -= rc.top; + rc.bottom -= Frames[FrameId].height; + Frames[FrameId].HeightWhenCollapsed = Frames[FrameId].height; + Frames[FrameId].collapsed = FALSE; + } + else { + rc.bottom -= rc.top; + rc.bottom += Frames[FrameId].HeightWhenCollapsed; + Frames[FrameId].collapsed = TRUE; + } + + SetWindowPos(pcli->hwndContactList, NULL, 0, 0, rc.right - rc.left, rc.bottom, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOMOVE); + + CLUIFramesStoreAllFrames(); + lck.unlock(); + RedrawWindow(pcli->hwndContactList, NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_UPDATENOW | RDW_ALLCHILDREN); + return 0; + + } + if (Frames[FrameId].Locked || (!Frames[FrameId].visible)) + return 0; + + oldHeight = Frames[FrameId].height; + + // if collapsed, uncollapse + if (Frames[FrameId].collapsed == TRUE) { + Frames[FrameId].HeightWhenCollapsed = Frames[FrameId].height; + Frames[FrameId].height = UNCOLLAPSED_FRAME_SIZE; + Frames[FrameId].collapsed = FALSE; + } + // if uncollapsed, collapse + else { + Frames[FrameId].height = Frames[FrameId].HeightWhenCollapsed; + Frames[FrameId].collapsed = TRUE; + } + + if (!Frames[FrameId].floating) { + + if (!CLUIFramesFitInSize()) { + //cant collapse,we can resize only for height 2 * UNCOLLAPSED_FRAME_SIZE) { + oldHeight = Frames[alfrm].height - UNCOLLAPSED_FRAME_SIZE; + Frames[FrameId].collapsed = TRUE; + } + } + else { + int i, sumheight = 0; + + for (i = 0; i < nFramescount; i++) { + if ((Frames[i].align != alClient) && (!Frames[i].floating) && (Frames[i].visible) && (!Frames[i].needhide)) { + sumheight += (Frames[i].height) + (TitleBarH * btoint(Frames[i].TitleBar.ShowTitleBar)) + 2; + return FALSE; + } + if (sumheight > ContactListHeight - 0 - 2) + Frames[FrameId].height = (ContactListHeight - 0 - 2) - sumheight; + } + } + Frames[FrameId].height = oldHeight; + if (Frames[FrameId].collapsed == FALSE) { + if (Frames[FrameId].floating) + SetWindowPos(Frames[FrameId].ContainerWnd, HWND_TOP, 0, 0, Frames[FrameId].wndSize.right - Frames[FrameId].wndSize.left + 6, Frames[FrameId].height + DEFAULT_TITLEBAR_HEIGHT + 4, SWP_SHOWWINDOW | SWP_NOMOVE); + return -1; + } + } + } + lck.unlock(); + if (!Frames[FrameId].floating) + CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0); + else { + RECT contwnd; + GetWindowRect(Frames[FrameId].ContainerWnd, &contwnd); + contwnd.top = contwnd.bottom - contwnd.top;//height + contwnd.left = contwnd.right - contwnd.left;//width + + contwnd.top -= (oldHeight - Frames[FrameId].height);//newheight + SetWindowPos(Frames[FrameId].ContainerWnd, HWND_TOP, 0, 0, contwnd.left, contwnd.top, SWP_SHOWWINDOW | SWP_NOMOVE); + } + RedrawWindow(pcli->hwndContactList, NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_UPDATENOW | RDW_ALLCHILDREN); + CLUIFramesStoreAllFrames(); + return 0; +} + +static int CLUIFramesLoadMainMenu() +{ + if (FramesSysNotStarted) + return -1; + + if (cont.MainMenuItem != NULL) { + Menu_RemoveItem(cont.MainMenuItem); + cont.MainMenuItem = NULL; + } + + // create root menu + CMenuItem mi; + mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_FRAME); + mi.position = 3000090000; + mi.name.a = LPGEN("Frames"); + mi.pszService = 0; + cont.MainMenuItem = Menu_AddMainMenuItem(&mi); + + // create frames menu + mi.root = cont.MainMenuItem; + int separator = (int)3000200000; + for (int i = 0; i < nFramescount; i++) { + mi.hIcolibItem = Frames[i].TitleBar.hicon; + mi.flags = CMIF_TCHAR; + mi.position = separator; + mi.name.t = Frames[i].TitleBar.tbname ? Frames[i].TitleBar.tbname : Frames[i].name; + mi.pszService = 0; + Frames[i].MenuHandles.MainMenuItem = Menu_AddMainMenuItem(&mi); + CLUIFramesCreateMenuForFrame(Frames[i].id, Frames[i].MenuHandles.MainMenuItem, separator, true); + CLUIFramesModifyMainMenuItems(Frames[i].id, 0); + CallService(MS_CLIST_FRAMEMENUNOTIFY, (WPARAM)Frames[i].id, (LPARAM)Frames[i].MenuHandles.MainMenuItem); + separator++; + } + + separator += 100000; + + // create "show all frames" menu + mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_MIRANDA); + mi.flags = 0; + mi.position = separator++; + mi.name.a = LPGEN("Show all frames"); + mi.pszService = MS_CLIST_FRAMES_SHOWALLFRAMES; + Menu_AddMainMenuItem(&mi); + + // create "show all titlebars" menu + mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_HELP); + mi.position = separator++; + mi.name.a = LPGEN("Show all title bars"); + mi.pszService = MS_CLIST_FRAMES_SHOWALLFRAMESTB; + Menu_AddMainMenuItem(&mi); + + // create "hide all titlebars" menu + mi.position = separator++; + mi.name.a = LPGEN("Hide all title bars"); + mi.pszService = MS_CLIST_FRAMES_HIDEALLFRAMESTB; + Menu_AddMainMenuItem(&mi); + return 0; +} + +static HFONT CLUILoadTitleBarFont() +{ + char facename[] = "MS Shell Dlg"; + LOGFONT logfont; + memset(&logfont, 0, sizeof(logfont)); + memcpy(logfont.lfFaceName, facename, sizeof(facename)); + logfont.lfWeight = FW_NORMAL; + logfont.lfHeight = -10; + return CreateFontIndirect(&logfont); +} + +static int UpdateTBToolTip(int framepos) +{ + TOOLINFO ti; + + memset(&ti, 0, sizeof(ti)); + ti.cbSize = sizeof(ti); + ti.lpszText = Frames[framepos].TitleBar.tooltip; + ti.hinst = g_hInst; + ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS; + ti.uId = (UINT_PTR)Frames[framepos].TitleBar.hwnd; + + return SendMessage(Frames[framepos].TitleBar.hwndTip, TTM_UPDATETIPTEXT, 0, (LPARAM)&ti); +}; + +int FrameNCPaint(HWND hwnd, WNDPROC oldWndProc, WPARAM wParam, LPARAM lParam, BOOL hasTitleBar) +{ + HDC hdc; + RECT rcWindow, rc; + HWND hwndParent = GetParent(hwnd); + LRESULT result = 0; + + if (pcli == NULL) + return 0; + if (hwndParent != pcli->hwndContactList || !cfg::dat.bSkinnedScrollbar) + result = CallWindowProc(oldWndProc, hwnd, WM_NCPAINT, wParam, lParam); + if (!pcli->hwndContactList || hwndParent != pcli->hwndContactList) + return result; + + if (GetWindowLongPtr(hwnd, GWL_STYLE) & CLS_SKINNEDFRAME) { + StatusItems_t *item = (arStatusItems.getCount() != 0) ? (hasTitleBar ? arStatusItems[ID_EXTBKOWNEDFRAMEBORDERTB - ID_STATUS_OFFLINE] : arStatusItems[ID_EXTBKOWNEDFRAMEBORDER - ID_STATUS_OFFLINE]) : 0; + if (item == 0) + return 0; + + GetWindowRect(hwnd, &rcWindow); + rc.left = rc.top = 0; + rc.right = rcWindow.right - rcWindow.left; + rc.bottom = rcWindow.bottom - rcWindow.top; + + HDC hdc = GetWindowDC(hwnd); + if (hwnd == pcli->hwndContactTree) { + HDC realDC = CreateCompatibleDC(hdc); + HBITMAP hbmDraw = CreateCompatibleBitmap(hdc, rc.right, rc.bottom); + HBITMAP hbmOld = reinterpret_cast(SelectObject(realDC, hbmDraw)); + + ExcludeClipRect(realDC, item->MARGIN_LEFT, item->MARGIN_TOP, rc.right - item->MARGIN_RIGHT, rc.bottom - item->MARGIN_BOTTOM); + BitBlt(realDC, 0, 0, rc.right - rc.left, rc.bottom - rc.top, cfg::dat.hdcBg, rcWindow.left - cfg::dat.ptW.x, rcWindow.top - cfg::dat.ptW.y, SRCCOPY); + DrawAlpha(realDC, &rc, item->COLOR, item->ALPHA, item->COLOR2, item->COLOR2_TRANSPARENT, item->GRADIENT, item->CORNER, item->BORDERSTYLE, item->imageItem); + + ExcludeClipRect(hdc, item->MARGIN_LEFT, item->MARGIN_TOP, rc.right - item->MARGIN_RIGHT, rc.bottom - item->MARGIN_BOTTOM); + BitBlt(hdc, 0, 0, rc.right, rc.bottom, realDC, 0, 0, SRCCOPY); + SelectObject(realDC, hbmOld); + DeleteObject(hbmDraw); + DeleteDC(realDC); + } + else { + ExcludeClipRect(hdc, item->MARGIN_LEFT, item->MARGIN_TOP, rc.right - item->MARGIN_RIGHT, rc.bottom - item->MARGIN_BOTTOM); + BitBlt(hdc, 0, 0, rc.right - rc.left, rc.bottom - rc.top, cfg::dat.hdcBg, rcWindow.left - cfg::dat.ptW.x, rcWindow.top - cfg::dat.ptW.y, SRCCOPY); + DrawAlpha(hdc, &rc, item->COLOR, item->ALPHA, item->COLOR2, item->COLOR2_TRANSPARENT, item->GRADIENT, item->CORNER, item->BORDERSTYLE, item->imageItem); + } + ReleaseDC(hwnd, hdc); + return 0; + } + + if (GetWindowLongPtr(hwnd, GWL_STYLE) & WS_BORDER) { + hdc = GetWindowDC(hwnd); + HPEN hPenOld = reinterpret_cast(SelectObject(hdc, g_hPenCLUIFrames)); + GetWindowRect(hwnd, &rcWindow); + rc.left = rc.top = 0; + rc.right = rcWindow.right - rcWindow.left; + rc.bottom = rcWindow.bottom - rcWindow.top; + HBRUSH brold = reinterpret_cast(SelectObject(hdc, GetStockObject(HOLLOW_BRUSH))); + Rectangle(hdc, 0, 0, rcWindow.right - rcWindow.left, rcWindow.bottom - rcWindow.top); + SelectObject(hdc, hPenOld); + SelectObject(hdc, brold); + ReleaseDC(hwnd, hdc); + return 0; + } + + return result; +} + +int FrameNCCalcSize(HWND hwnd, WNDPROC oldWndProc, WPARAM wParam, LPARAM lParam, BOOL hasTitleBar) +{ + StatusItems_t *item = (arStatusItems.getCount() != 0) ? (hasTitleBar ? arStatusItems[ID_EXTBKOWNEDFRAMEBORDERTB - ID_STATUS_OFFLINE] : arStatusItems[ID_EXTBKOWNEDFRAMEBORDER - ID_STATUS_OFFLINE]) : 0; + LRESULT orig = oldWndProc ? CallWindowProc(oldWndProc, hwnd, WM_NCCALCSIZE, wParam, lParam) : 0; + NCCALCSIZE_PARAMS *nccp = (NCCALCSIZE_PARAMS *)lParam; + DWORD dwStyle = GetWindowLongPtr(hwnd, GWL_STYLE); + + if (item == 0 || pcli == NULL) + return orig; + + if (item->IGNORED || !(dwStyle & CLS_SKINNEDFRAME) || GetParent(hwnd) != pcli->hwndContactList) + return orig; + + nccp->rgrc[0].left += item->MARGIN_LEFT; + nccp->rgrc[0].right -= item->MARGIN_RIGHT; + nccp->rgrc[0].bottom -= item->MARGIN_BOTTOM; + nccp->rgrc[0].top += item->MARGIN_TOP; + return WVR_REDRAW; +} + +static LRESULT CALLBACK FramesSubClassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + int i; + + WNDPROC oldWndProc = 0; + BOOL hasTitleBar = FALSE; + + for (i = 0; i < nFramescount; i++) { + if (Frames[i].hWnd == hwnd) { + oldWndProc = Frames[i].wndProc; + hasTitleBar = Frames[i].TitleBar.ShowTitleBar; + } + } + switch (msg) { + case WM_NCPAINT: + return FrameNCPaint(hwnd, oldWndProc ? oldWndProc : DefWindowProc, wParam, lParam, hasTitleBar); + + case WM_NCCALCSIZE: + return FrameNCCalcSize(hwnd, oldWndProc, wParam, lParam, hasTitleBar); + + case WM_PRINTCLIENT: + return 0; + } + + if (oldWndProc) + return CallWindowProc(oldWndProc, hwnd, msg, wParam, lParam); + return DefWindowProc(hwnd, msg, wParam, lParam); +} + +/* + * re-sort all frames and correct frame ordering + */ + +static int CLUIFramesReSort() +{ + int v = 0, i; + int order = 1; + + mir_cslock lck(csFrameHook); + memset(g_sd, 0, sizeof(SortData) * MAX_FRAMES); + for (i = 0; i < nFramescount; i++) { + if (Frames[i].align != alTop) + continue; + g_sd[v].order = Frames[i].order; + g_sd[v].realpos = i; + v++; + } + if (v > 0) { + qsort(g_sd, v, sizeof(SortData), sortfunc); + for (i = 0; i < v; i++) + Frames[g_sd[i].realpos].order = order++; + } + + memset(g_sd, 0, sizeof(SortData) * MAX_FRAMES); + v = 0; + for (i = 0; i < nFramescount; i++) { + if (Frames[i].align != alBottom) + continue; + g_sd[v].order = Frames[i].order; + g_sd[v].realpos = i; + v++; + } + if (v > 0) { + qsort(g_sd, v, sizeof(SortData), sortfunc); + for (i = 0; i < v; i++) + Frames[g_sd[i].realpos].order = order++; + } + CLUIFramesStoreAllFrames(); + return 0; +} + +//wparam=(CLISTFrame*)clfrm +INT_PTR CLUIFramesAddFrame(WPARAM wParam, LPARAM) +{ + int style; + CLISTFrame *clfrm = (CLISTFrame *)wParam; + + if (pcli->hwndContactList == 0) return -1; + if (FramesSysNotStarted) return -1; + if (clfrm->cbSize != sizeof(CLISTFrame)) return -1; + + mir_cslockfull lck(csFrameHook); + if (nFramescount >= MAX_FRAMES) + return -1; + + if (Frames == NULL) { + Frames = (FRAMEWND*)malloc(sizeof(FRAMEWND) * (MAX_FRAMES + 2)); + memset(Frames, 0, (sizeof(FRAMEWND) * (MAX_FRAMES + 2))); + } + memset(&Frames[nFramescount], 0, sizeof(FRAMEWND)); + + Frames[nFramescount].id = NextFrameId++; + Frames[nFramescount].align = clfrm->align; + Frames[nFramescount].hWnd = clfrm->hWnd; + Frames[nFramescount].height = clfrm->height; + Frames[nFramescount].TitleBar.hicon = clfrm->hIcon; + //Frames[nFramescount].TitleBar.BackColour; + Frames[nFramescount].floating = FALSE; + + if (clfrm->Flags & F_NO_SUBCONTAINER) + Frames[nFramescount].OwnerWindow = (HWND)-2; + else + Frames[nFramescount].OwnerWindow = pcli->hwndContactList; + + SetClassLong(clfrm->hWnd, GCL_STYLE, GetClassLong(clfrm->hWnd, GCL_STYLE) & ~(CS_VREDRAW | CS_HREDRAW)); + SetWindowLongPtr(clfrm->hWnd, GWL_STYLE, GetWindowLongPtr(clfrm->hWnd, GWL_STYLE) | WS_CLIPCHILDREN); + + if (GetCurrentThreadId() == GetWindowThreadProcessId(clfrm->hWnd, NULL)) { + if (clfrm->hWnd != pcli->hwndContactTree && clfrm->hWnd != g_hwndViewModeFrame && clfrm->hWnd != g_hwndEventArea) { + Frames[nFramescount].wndProc = (WNDPROC)GetWindowLongPtr(clfrm->hWnd, GWLP_WNDPROC); + SetWindowLongPtr(clfrm->hWnd, GWLP_WNDPROC, (LONG_PTR)FramesSubClassProc); + } + } + + if (clfrm->hWnd == g_hwndEventArea) + wndFrameEventArea = &Frames[nFramescount]; + else if (clfrm->hWnd == pcli->hwndContactTree) + wndFrameCLC = &Frames[nFramescount]; + else if (clfrm->hWnd == g_hwndViewModeFrame) + wndFrameViewMode = &Frames[nFramescount]; + + Frames[nFramescount].dwFlags = clfrm->Flags; + + if (clfrm->name == NULL || ((clfrm->Flags&F_UNICODE) ? mir_wstrlen(clfrm->wname) : mir_strlen(clfrm->name)) == 0) { + TCHAR ptszClassName[256]; + GetClassName(Frames[nFramescount].hWnd, ptszClassName, _countof(ptszClassName)); + Frames[nFramescount].name = mir_tstrdup(ptszClassName); + } + else Frames[nFramescount].name = (clfrm->Flags & F_UNICODE) ? mir_u2t(clfrm->wname) : mir_a2t(clfrm->name); + + if (IsBadCodePtr((FARPROC)clfrm->TBname) || clfrm->TBname == NULL + || ((clfrm->Flags&F_UNICODE) ? mir_wstrlen(clfrm->TBwname) : mir_strlen(clfrm->TBname)) == 0) + Frames[nFramescount].TitleBar.tbname = mir_tstrdup(Frames[nFramescount].name); + else + Frames[nFramescount].TitleBar.tbname = (clfrm->Flags & F_UNICODE) ? mir_u2t(clfrm->TBwname) : mir_a2t(clfrm->TBname); + Frames[nFramescount].needhide = FALSE; + Frames[nFramescount].TitleBar.ShowTitleBar = (clfrm->Flags & F_SHOWTB ? TRUE : FALSE); + Frames[nFramescount].TitleBar.ShowTitleBarTip = (clfrm->Flags & F_SHOWTBTIP ? TRUE : FALSE); + + Frames[nFramescount].collapsed = clfrm->Flags & F_UNCOLLAPSED ? FALSE : TRUE; + Frames[nFramescount].Locked = clfrm->Flags & F_LOCKED ? TRUE : FALSE; + Frames[nFramescount].visible = clfrm->Flags & F_VISIBLE ? TRUE : FALSE; + + Frames[nFramescount].UseBorder = (clfrm->Flags & F_NOBORDER) ? FALSE : TRUE; + Frames[nFramescount].Skinned = (clfrm->Flags & F_SKINNED) ? TRUE : FALSE; + + // create frame + Frames[nFramescount].TitleBar.hwnd = + CreateWindow(CLUIFrameTitleBarClassName, Frames[nFramescount].name, + (cfg::getByte(CLUIFrameModule, "RemoveAllTitleBarBorders", 1) ? 0 : WS_BORDER) + | WS_CHILD | WS_CLIPCHILDREN | (Frames[nFramescount].TitleBar.ShowTitleBar ? WS_VISIBLE : 0) | + WS_CLIPCHILDREN, 0, 0, 0, 0, pcli->hwndContactList, NULL, g_hInst, NULL); + + SetWindowLongPtr(Frames[nFramescount].TitleBar.hwnd, GWLP_USERDATA, Frames[nFramescount].id); + + Frames[nFramescount].TitleBar.hwndTip = CreateWindowExA(0, TOOLTIPS_CLASSA, NULL, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, + CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, + pcli->hwndContactList, NULL, g_hInst, NULL); + + SetWindowPos(Frames[nFramescount].TitleBar.hwndTip, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); + { + TOOLINFOA ti = { 0 }; + ti.cbSize = sizeof(ti); + ti.lpszText = ""; + ti.hinst = g_hInst; + ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS; + ti.uId = (UINT_PTR)Frames[nFramescount].TitleBar.hwnd; + SendMessageA(Frames[nFramescount].TitleBar.hwndTip, TTM_ADDTOOL, 0, (LPARAM)&ti); + } + + SendMessage(Frames[nFramescount].TitleBar.hwndTip, TTM_ACTIVATE, (WPARAM)Frames[nFramescount].TitleBar.ShowTitleBarTip, 0); + + Frames[nFramescount].oldstyles = GetWindowLongPtr(Frames[nFramescount].hWnd, GWL_STYLE); + Frames[nFramescount].TitleBar.oldstyles = GetWindowLongPtr(Frames[nFramescount].TitleBar.hwnd, GWL_STYLE); + + int retval = Frames[nFramescount].id; + Frames[nFramescount].order = nFramescount + 1; + nFramescount++; + + CLUIFramesLoadFrameSettings(id2pos(retval)); + style = GetWindowLongPtr(Frames[nFramescount - 1].hWnd, GWL_STYLE); + style &= ~(WS_BORDER); + style |= ((Frames[nFramescount - 1].UseBorder) ? WS_BORDER : 0); + + style |= Frames[nFramescount - 1].Skinned ? CLS_SKINNEDFRAME : 0; + + SetWindowLongPtr(Frames[nFramescount - 1].hWnd, GWL_STYLE, style); + SetWindowLongPtr(Frames[nFramescount - 1].TitleBar.hwnd, GWL_STYLE, style & ~(WS_VSCROLL | WS_HSCROLL)); + + if (Frames[nFramescount - 1].order == 0) + Frames[nFramescount - 1].order = nFramescount; + + lck.unlock(); + + alclientFrame = -1;//recalc it + CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0); + + if (Frames[nFramescount - 1].floating) { + Frames[nFramescount - 1].floating = FALSE; + CLUIFrameSetFloat(retval, 1);//lparam=1 use stored width and height + } + RedrawWindow(pcli->hwndContactList, NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_UPDATENOW | RDW_ALLCHILDREN); + return retval; +} + +static INT_PTR CLUIFramesRemoveFrame(WPARAM wParam, LPARAM) +{ + if (FramesSysNotStarted) + return -1; + + { + mir_cslock lck(csFrameHook); + int pos = id2pos(wParam); + if (pos < 0 || pos > nFramescount) + return -1; + + FRAMEWND* F = &Frames[pos]; + if (F->hWnd == g_hwndEventArea) + wndFrameEventArea = NULL; + else if (F->hWnd == pcli->hwndContactTree) + wndFrameCLC = NULL; + else if (F->hWnd == g_hwndViewModeFrame) + wndFrameViewMode = NULL; + + mir_free(F->name); + mir_free(F->TitleBar.tbname); + mir_free(F->TitleBar.tooltip); + + DestroyWindow(F->hWnd); + F->hWnd = (HWND)-1; + DestroyWindow(F->TitleBar.hwnd); + F->TitleBar.hwnd = (HWND)-1; + DestroyWindow(F->ContainerWnd); + F->ContainerWnd = (HWND)-1; + DestroyMenu(F->TitleBar.hmenu); + + RemoveItemFromList(pos, &Frames, &nFramescount); + } + + if (!cfg::shutDown) { + InvalidateRect(pcli->hwndContactList, NULL, TRUE); + CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0); + RedrawWindow(pcli->hwndContactList, NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_UPDATENOW | RDW_ALLCHILDREN); + } + return 0; +} + +INT_PTR CLUIFramesForceUpdateTB(const FRAMEWND *Frame) +{ + if (Frame->TitleBar.hwnd != 0) + RedrawWindow(Frame->TitleBar.hwnd, NULL, NULL, RDW_ALLCHILDREN | RDW_UPDATENOW | RDW_ERASE | RDW_INVALIDATE | RDW_FRAME); + return 0; +} + +INT_PTR CLUIFramesForceUpdateFrame(const FRAMEWND *Frame) +{ + if (Frame->hWnd != 0) + RedrawWindow(Frame->hWnd, NULL, NULL, RDW_UPDATENOW | RDW_FRAME | RDW_ERASE | RDW_INVALIDATE); + + if (Frame->floating) + if (Frame->ContainerWnd != 0) RedrawWindow(Frame->ContainerWnd, NULL, NULL, RDW_UPDATENOW | RDW_ALLCHILDREN | RDW_ERASE | RDW_INVALIDATE | RDW_FRAME); + return 0; +} + +int CLUIFrameMoveResize(const FRAMEWND *Frame) +{ + TitleBarH = cfg::dat.titleBarHeight; + // we need to show or hide the frame? + if (Frame->visible && (!Frame->needhide)) { + ShowWindow(Frame->hWnd, SW_SHOW); + ShowWindow(Frame->TitleBar.hwnd, Frame->TitleBar.ShowTitleBar == TRUE ? SW_SHOW : SW_HIDE); + } + else { + ShowWindow(Frame->hWnd, SW_HIDE); + ShowWindow(Frame->TitleBar.hwnd, SW_HIDE); + return 0; + } + + SetWindowPos(Frame->hWnd, NULL, Frame->wndSize.left + cfg::dat.bCLeft, Frame->wndSize.top + cfg::dat.topOffset, + (Frame->wndSize.right - Frame->wndSize.left), + (Frame->wndSize.bottom - Frame->wndSize.top), SWP_NOZORDER | SWP_NOREDRAW); + if (Frame->TitleBar.ShowTitleBar) { + SetWindowPos(Frame->TitleBar.hwnd, NULL, Frame->wndSize.left + cfg::dat.bCLeft, Frame->wndSize.top + cfg::dat.topOffset - TitleBarH, + (Frame->wndSize.right - Frame->wndSize.left), + TitleBarH + (Frame->UseBorder ? (!Frame->collapsed ? (Frame->align == alClient ? 0 : 2) : 1) : 0), SWP_NOZORDER); + } + return 0; +} + +bool CLUIFramesFitInSize(void) +{ + int i; + int sumheight = 0; + int tbh = 0; // title bar height + int clientfrm; + + TitleBarH = cfg::dat.titleBarHeight; + + clientfrm = CLUIFramesGetalClientFrame(); + if (clientfrm != -1) + tbh = TitleBarH * btoint(Frames[clientfrm].TitleBar.ShowTitleBar); + + for (i = 0; i < nFramescount; i++) { + if ((Frames[i].align != alClient) && (!Frames[i].floating) && (Frames[i].visible) && (!Frames[i].needhide)) { + sumheight += (Frames[i].height) + (TitleBarH * btoint(Frames[i].TitleBar.ShowTitleBar)) + 2/*+btoint(Frames[i].UseBorder)*2*/; + if (sumheight > ContactListHeight - tbh - 2) + return FALSE; + } + } + return TRUE; +} + +int CLUIFramesGetMinHeight() +{ + if (pcli->hwndContactList == NULL) + return 0; + + int i, tbh, clientfrm, sumheight = 0; + RECT border; + int allbord = 0; + { + mir_cslock lck(csFrameHook); + + TitleBarH = cfg::dat.titleBarHeight; + // search for alClient frame and get the titlebar's height + tbh = 0; + clientfrm = CLUIFramesGetalClientFrame(); + if (clientfrm != -1) + tbh = TitleBarH * btoint(Frames[clientfrm].TitleBar.ShowTitleBar); + + for (i = 0; i < nFramescount; i++) { + if ((Frames[i].align != alClient) && (Frames[i].visible) && (!Frames[i].needhide) && (!Frames[i].floating)) { + RECT wsize; + + GetWindowRect(Frames[i].hWnd, &wsize); + sumheight += (wsize.bottom - wsize.top) + (TitleBarH * btoint(Frames[i].TitleBar.ShowTitleBar)) + 3; + } + } + } + + GetBorderSize(pcli->hwndContactList, &border); + return(sumheight + border.top + border.bottom + allbord + tbh + 3); +} + +int SizeMoveNewSizes() +{ + for (int i = 0; i < nFramescount; i++) { + if (Frames[i].floating) + CLUIFrameResizeFloatingFrame(i); + else + CLUIFrameMoveResize(&Frames[i]); + } + return 0; +} + +/* + * changed Nightwish + * gap calculation was broken. Now, it doesn't calculate and store the gaps in Frames[] anymore. + * instead, it remembers the smallest wndSize.top value (which has to be the top frame) and then passes + * the gap to all following frame(s) to the actual resizing function which just adds the gap to + * wndSize.top and corrects the frame height accordingly. + + * Title bar gap has been removed (can be simulated by using a clist_nicer skin item for frame title bars + * and setting the bottom margin of the skin item + */ + +int CLUIFramesResize(const RECT newsize) +{ + int sumheight = 9999999, newheight; + int prevframe, prevframebottomline; + int tbh, curfrmtbh; + int drawitems; + int clientfrm, clientframe = -1; + int i, j; + int sepw; + int topOff = 0, botOff = 0, last_bottomtop; + + GapBetweenFrames = cfg::dat.gapBetweenFrames; + sepw = GapBetweenFrames; + + if (nFramescount < 1 || cfg::shutDown) + return 0; + + newheight = newsize.bottom - newsize.top; + TitleBarH = cfg::dat.titleBarHeight; + + // search for alClient frame and get the titlebar's height + tbh = 0; + clientfrm = CLUIFramesGetalClientFrame(); + if (clientfrm != -1) + tbh = (TitleBarH)* btoint(Frames[clientfrm].TitleBar.ShowTitleBar); + + for (i = 0; i < nFramescount; i++) { + if (!Frames[i].floating) { + Frames[i].needhide = FALSE; + Frames[i].wndSize.left = 0; + Frames[i].wndSize.right = newsize.right - newsize.left; + } + } + { + //sorting stuff + memset(g_sd, 0, sizeof(SortData) * MAX_FRAMES); + for (i = 0; i < nFramescount; i++) { + g_sd[i].order = Frames[i].order; + g_sd[i].realpos = i; + } + qsort(g_sd, nFramescount, sizeof(SortData), sortfunc); + + } + drawitems = nFramescount; + while (sumheight >(newheight - tbh) && drawitems > 0) { + sumheight = 0; + drawitems = 0; + for (i = 0; i < nFramescount; i++) { + if (((Frames[i].align != alClient)) && (!Frames[i].floating) && (Frames[i].visible) && (!Frames[i].needhide)) { + drawitems++; + curfrmtbh = (TitleBarH)* btoint(Frames[i].TitleBar.ShowTitleBar); + sumheight += (Frames[i].height) + curfrmtbh + (i > 0 ? sepw : 0) + (Frames[i].UseBorder ? 2 : 0); + if (sumheight > newheight - tbh) { + sumheight -= (Frames[i].height) + curfrmtbh + (i > 0 ? sepw : 0); + Frames[i].needhide = TRUE; + drawitems--; + break; + } + } + } + } + + prevframe = -1; + prevframebottomline = 0; + for (j = 0; j < nFramescount; j++) { + //move all alTop frames + i = g_sd[j].realpos; + if ((!Frames[i].needhide) && (!Frames[i].floating) && (Frames[i].visible) && (Frames[i].align == alTop)) { + curfrmtbh = (TitleBarH)* btoint(Frames[i].TitleBar.ShowTitleBar); + Frames[i].wndSize.top = prevframebottomline + (prevframebottomline > 0 ? sepw : 0) + (curfrmtbh); + Frames[i].wndSize.bottom = Frames[i].height + Frames[i].wndSize.top + (Frames[i].UseBorder ? 2 : 0); + Frames[i].prevvisframe = prevframe; + prevframe = i; + prevframebottomline = Frames[i].wndSize.bottom; + topOff = prevframebottomline; + } + } + + if (sumheight < newheight) { + for (j = 0; j < nFramescount; j++) { + //move alClient frame + i = g_sd[j].realpos; + if ((!Frames[i].needhide) && (!Frames[i].floating) && (Frames[i].visible) && (Frames[i].align == alClient)) { + int oldh; + Frames[i].wndSize.top = prevframebottomline + (prevframebottomline > 0 ? sepw : 0) + (tbh); + Frames[i].wndSize.bottom = Frames[i].wndSize.top + newheight - sumheight - tbh - ((prevframebottomline > 0) ? sepw : 0); + clientframe = i; + oldh = Frames[i].height; + Frames[i].height = Frames[i].wndSize.bottom - Frames[i].wndSize.top; + Frames[i].prevvisframe = prevframe; + prevframe = i; + prevframebottomline = Frames[i].wndSize.bottom; + if (prevframebottomline > newheight) { + //prevframebottomline-=Frames[i].height+(tbh+1); + //Frames[i].needhide=TRUE; + } + break; + } + } + } + + //newheight + prevframebottomline = last_bottomtop = newheight; + //prevframe=-1; + for (j = nFramescount - 1; j >= 0; j--) { + //move all alBottom frames + i = g_sd[j].realpos; + if ((Frames[i].visible) && (!Frames[i].floating) && (!Frames[i].needhide) && (Frames[i].align == alBottom)) { + curfrmtbh = (TitleBarH)* btoint(Frames[i].TitleBar.ShowTitleBar); + Frames[i].wndSize.bottom = prevframebottomline - ((prevframebottomline < newheight) ? sepw : 0); + Frames[i].wndSize.top = Frames[i].wndSize.bottom - Frames[i].height - (Frames[i].UseBorder ? 2 : 0); + Frames[i].prevvisframe = prevframe; + prevframe = i; + prevframebottomline = Frames[i].wndSize.top - curfrmtbh; + botOff = prevframebottomline; + last_bottomtop = Frames[i].wndSize.top - curfrmtbh; + } + } + + // correct client frame bottom gap if there is no other top frame. + if (clientframe != -1) { + Frames[clientframe].wndSize.bottom = last_bottomtop - (last_bottomtop < newheight ? sepw : 0); + Frames[clientframe].height = Frames[clientframe].wndSize.bottom - Frames[clientframe].wndSize.top; + } + return 0; +} + +INT_PTR CLUIFramesUpdateFrame(WPARAM wParam, LPARAM lParam) +{ + int pos; + if (FramesSysNotStarted) + return -1; + + if (wParam == -1) { + CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0); + return 0; + } + + if (lParam & FU_FMPOS) + CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 1); + + mir_cslock lck(csFrameHook); + pos = id2pos(wParam); + if (pos < 0 || pos >= nFramescount) + return -1; + + if (lParam & FU_TBREDRAW) + CLUIFramesForceUpdateTB(&Frames[pos]); + if (lParam & FU_FMREDRAW) + CLUIFramesForceUpdateFrame(&Frames[pos]); + return 0; +} + +int dock_prevent_moving = 0; + +int CLUIFramesApplyNewSizes(int mode) +{ + dock_prevent_moving = 0; + + for (int i = 0; i < nFramescount; i++) { + if ((mode == 1 && Frames[i].OwnerWindow != (HWND)-2 && Frames[i].OwnerWindow) || + (mode == 2 && Frames[i].OwnerWindow == (HWND)-2) || (mode == 3)) + if (Frames[i].floating) + CLUIFrameResizeFloatingFrame(i); + else + CLUIFrameMoveResize(&Frames[i]); + } + dock_prevent_moving = 1; + return 0; +} + +RECT old_window_rect = { 0 }, new_window_rect = { 0 }; + +int SizeFramesByWindowRect(RECT *r) +{ + RECT nRect; + DWORD noSize = 0; + + if (FramesSysNotStarted) + return -1; + + TitleBarH = cfg::dat.titleBarHeight; + + mir_cslock lck(csFrameHook); + GapBetweenFrames = cfg::dat.gapBetweenFrames; + + nRect = *r; + + nRect.bottom -= (cfg::dat.statusBarHeight + cfg::dat.bottomOffset); + nRect.right -= cfg::dat.bCRight; + nRect.left = cfg::dat.bCLeft; + nRect.top = cfg::dat.topOffset; + ContactListHeight = nRect.bottom - nRect.top; + + CLUIFramesResize(nRect); + { + int i; + for (i = 0; i < nFramescount; i++) { + int dx; + int dy; + dx = new_window_rect.left - old_window_rect.left; + dy = new_window_rect.top - old_window_rect.top; + if (!Frames[i].floating) { + if (Frames[i].OwnerWindow && Frames[i].OwnerWindow != (HWND)-2) { + /* + if (Frames[i].wndSize.right - Frames[i].wndSize.left == Frames[i].oldWndSize.right - Frames[i].oldWndSize.left && + Frames[i].wndSize.bottom - Frames[i].wndSize.top == Frames[i].oldWndSize.bottom - Frames[i].oldWndSize.top) + noSize = SWP_NOSIZE; + else { + noSize = 0; + CopyRect(&Frames[i].oldWndSize, &Frames[i].wndSize); + }*/ + SetWindowPos(Frames[i].hWnd, NULL, Frames[i].wndSize.left + cfg::dat.bCLeft, Frames[i].wndSize.top + cfg::dat.topOffset, + (Frames[i].wndSize.right - Frames[i].wndSize.left), + (Frames[i].wndSize.bottom - Frames[i].wndSize.top), SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW | SWP_NOCOPYBITS | noSize); + + if (Frames[i].TitleBar.ShowTitleBar) { + SetWindowPos(Frames[i].TitleBar.hwnd, NULL, Frames[i].wndSize.left + cfg::dat.bCLeft, Frames[i].wndSize.top + cfg::dat.topOffset - TitleBarH, + (Frames[i].wndSize.right - Frames[i].wndSize.left), + TitleBarH + (Frames[i].UseBorder ? (!Frames[i].collapsed ? (Frames[i].align == alClient ? 0 : 2) : 1) : 0), SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW | SWP_NOCOPYBITS); + } + } + else { + // set frame position + SetWindowPos(Frames[i].hWnd, NULL, Frames[i].wndSize.left + cfg::dat.bCLeft, Frames[i].wndSize.top + cfg::dat.topOffset, + (Frames[i].wndSize.right - Frames[i].wndSize.left), + (Frames[i].wndSize.bottom - Frames[i].wndSize.top), SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSENDCHANGING | SWP_NOCOPYBITS | SWP_NOREDRAW); + + // set titlebar position + if (Frames[i].TitleBar.ShowTitleBar) { + SetWindowPos(Frames[i].TitleBar.hwnd, NULL, Frames[i].wndSize.left + cfg::dat.bCLeft, Frames[i].wndSize.top + cfg::dat.topOffset - TitleBarH, + (Frames[i].wndSize.right - Frames[i].wndSize.left), + TitleBarH + (Frames[i].UseBorder ? (!Frames[i].collapsed ? (Frames[i].align == alClient ? 0 : 2) : 1) : 0), SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOCOPYBITS | SWP_NOREDRAW); + } + //UpdateWindow(Frames[i].hWnd); + if (Frames[i].TitleBar.ShowTitleBar) + UpdateWindow(Frames[i].TitleBar.hwnd); + } + } + } + + if (GetTickCount() - LastStoreTick > 1000) { + CLUIFramesStoreAllFrames(); + LastStoreTick = GetTickCount(); + } + } + return 0; +} + +int CLUIFramesOnClistResize(WPARAM wParam, LPARAM lParam) +{ + GapBetweenFrames = cfg::dat.gapBetweenFrames; + + if (FramesSysNotStarted || cfg::shutDown) + return -1; + + RECT nRect, rcStatus; + int tick; + { + mir_cslock lck(csFrameHook); + + GetClientRect(pcli->hwndContactList, &nRect); + if (lParam && lParam != 1) { + RECT oldRect; + POINT pt; + RECT * newRect = (RECT *)lParam; + int dl, dt, dr, db; + GetWindowRect((HWND)wParam, &oldRect); + pt.x = nRect.left; + pt.y = nRect.top; + ClientToScreen(pcli->hwndContactList, &pt); + dl = pt.x - oldRect.left; + dt = pt.y - oldRect.top; + dr = (oldRect.right - oldRect.left) - (nRect.right - nRect.left) - dl; + db = (oldRect.bottom - oldRect.top) - (nRect.bottom - nRect.top) - dt; + nRect.left = newRect->left + dl; + nRect.top = newRect->top + dt; + nRect.bottom = newRect->bottom - db; + nRect.right = newRect->right - dr; + } + + rcStatus.top = rcStatus.bottom = 0; + + nRect.bottom -= (cfg::dat.statusBarHeight + cfg::dat.bottomOffset); + nRect.right -= cfg::dat.bCRight; + nRect.left = cfg::dat.bCLeft; + nRect.top = cfg::dat.topOffset; + ContactListHeight = nRect.bottom - nRect.top; + + tick = GetTickCount(); + + CLUIFramesResize(nRect); + CLUIFramesApplyNewSizes(3); + } + + tick = GetTickCount() - tick; + + if (pcli->hwndContactList != 0) + InvalidateRect(pcli->hwndContactList, NULL, TRUE); + if (pcli->hwndContactList != 0) + UpdateWindow(pcli->hwndContactList); + + Sleep(0); + + if (GetTickCount() - LastStoreTick > 2000) { + CLUIFramesStoreAllFrames(); + LastStoreTick = GetTickCount(); + } + return 0; +} + +static HBITMAP hBmpBackground; +static int backgroundBmpUse; +static COLORREF bkColour; +static COLORREF SelBkColour; +boolean AlignCOLLIconToLeft; //will hide frame icon + +int OnFrameTitleBarBackgroundChange() +{ + AlignCOLLIconToLeft = cfg::getByte("FrameTitleBar", "AlignCOLLIconToLeft", 0); + bkColour = cfg::getDword("FrameTitleBar", "BkColour", CLCDEFAULT_BKCOLOUR); + + if (hBmpBackground) { + DeleteObject(hBmpBackground); + hBmpBackground = NULL; + } + if (cfg::getByte("FrameTitleBar", "UseBitmap", CLCDEFAULT_USEBITMAP)) { + ptrT tszBitmapName(db_get_tsa(NULL, "FrameTitleBar", "BkBitmap")); + if (tszBitmapName != NULL) + hBmpBackground = Bitmap_Load(tszBitmapName); + } + backgroundBmpUse = cfg::getWord("FrameTitleBar", "BkBmpUse", CLCDEFAULT_BKBMPUSE); + + CLUIFramesOnClistResize(0, 0); + return 0; +} + +static int DrawTitleBar(HDC dc, RECT rect, int Frameid) +{ + StatusItems_t *item = arStatusItems[ID_EXTBKFRAMETITLE - ID_STATUS_OFFLINE]; + + /* + * no need to redraw anything while shutting down + */ + if (cfg::shutDown) + return 0; + + TitleBarH = cfg::dat.titleBarHeight; + HDC hdcMem = CreateCompatibleDC(dc); + HBITMAP hBmpOsb = CreateCompatibleBitmap(dc, rect.right, rect.bottom); + HBITMAP hoBmp = reinterpret_cast(SelectObject(hdcMem, hBmpOsb)); + + SetBkMode(hdcMem, TRANSPARENT); + + HBRUSH hBack = GetSysColorBrush(COLOR_3DFACE); + HBRUSH hoBrush = reinterpret_cast(SelectObject(hdcMem, hBack)); + { + mir_cslock lck(csFrameHook); + int pos = id2pos(Frameid); + if (pos >= 0 && pos < nFramescount) { + HFONT oFont; + int fHeight, fontTop; + GetClientRect(Frames[pos].TitleBar.hwnd, &Frames[pos].TitleBar.wndSize); + + if (cfg::clcdat) { + oFont = ChangeToFont(hdcMem, cfg::clcdat, FONTID_FRAMETITLE, &fHeight); + } + else { + oFont = reinterpret_cast(SelectObject(hdcMem, GetStockObject(DEFAULT_GUI_FONT))); + fHeight = 10; + } + fontTop = (TitleBarH - fHeight) / 2; + + if (cfg::dat.bWallpaperMode && !Frames[pos].floating) + SkinDrawBg(Frames[pos].TitleBar.hwnd, hdcMem); + + if (!item->IGNORED) { + RECT rc = Frames[pos].TitleBar.wndSize; + rc.top += item->MARGIN_TOP; + rc.bottom -= item->MARGIN_BOTTOM; + rc.left += item->MARGIN_LEFT; + rc.right -= item->MARGIN_RIGHT; + DrawAlpha(hdcMem, &rc, item->COLOR, item->ALPHA, item->COLOR2, item->COLOR2_TRANSPARENT, + item->GRADIENT, item->CORNER, item->BORDERSTYLE, item->imageItem); + SetTextColor(hdcMem, item->TEXTCOLOR); + } + else if (cfg::clcdat) { + FillRect(hdcMem, &rect, hBack); + SetTextColor(hdcMem, cfg::clcdat->fontInfo[FONTID_FRAMETITLE].colour); + } + else { + FillRect(hdcMem, &rect, hBack); + SetTextColor(hdcMem, GetSysColor(COLOR_BTNTEXT)); + } + + if (!AlignCOLLIconToLeft) { + if (Frames[pos].TitleBar.hicon != NULL) { + DrawIconEx(hdcMem, 6 + cfg::dat.bClipBorder, ((TitleBarH >> 1) - 8), Frames[pos].TitleBar.hicon, 16, 16, 0, NULL, DI_NORMAL); + TextOut(hdcMem, 24 + cfg::dat.bClipBorder, fontTop, Frames[pos].TitleBar.tbname, (int)mir_tstrlen(Frames[pos].TitleBar.tbname)); + } + else TextOut(hdcMem, 6 + cfg::dat.bClipBorder, fontTop, Frames[pos].TitleBar.tbname, (int)mir_tstrlen(Frames[pos].TitleBar.tbname)); + } + else TextOut(hdcMem, 18 + cfg::dat.bClipBorder, fontTop, Frames[pos].TitleBar.tbname, (int)mir_tstrlen(Frames[pos].TitleBar.tbname)); + + if (!AlignCOLLIconToLeft) + DrawIconEx(hdcMem, Frames[pos].TitleBar.wndSize.right - 22, ((TitleBarH >> 1) - 8), Frames[pos].collapsed ? Skin_LoadIcon(SKINICON_OTHER_GROUPOPEN) : Skin_LoadIcon(SKINICON_OTHER_GROUPSHUT), 16, 16, 0, NULL, DI_NORMAL); + else + DrawIconEx(hdcMem, 0, ((TitleBarH >> 1) - 8), Frames[pos].collapsed ? Skin_LoadIcon(SKINICON_OTHER_GROUPOPEN) : Skin_LoadIcon(SKINICON_OTHER_GROUPSHUT), 16, 16, 0, NULL, DI_NORMAL); + SelectObject(hdcMem, oFont); + } + } + + BitBlt(dc, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, hdcMem, rect.left, rect.top, SRCCOPY); + SelectObject(hdcMem, hoBmp); + SelectObject(hdcMem, hoBrush); + DeleteDC(hdcMem); + DeleteObject(hBack); + DeleteObject(hBmpOsb); + return 0; +} + +#define MPCF_CONTEXTFRAMEMENU 3 +POINT ptOld; +short nLeft = 0; +short nTop = 0; + +LRESULT CALLBACK CLUIFrameTitleBarProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + RECT rect; + int Frameid, Framemod, direction; + int xpos, ypos, framepos; + + Frameid = GetWindowLongPtr(hwnd, GWLP_USERDATA); + memset(&rect, 0, sizeof(rect)); + + switch (msg) { + case WM_CREATE: + return FALSE; + + case WM_MEASUREITEM: + return Menu_MeasureItem((LPMEASUREITEMSTRUCT)lParam); + + case WM_DRAWITEM: + return Menu_DrawItem((LPDRAWITEMSTRUCT)lParam); + + case WM_ENABLE: + if (hwnd != 0) InvalidateRect(hwnd, NULL, FALSE); + return 0; + case WM_SIZE: + return 0; + + case WM_COMMAND: + if (CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), 0), Frameid)) + break; + + if (HIWORD(wParam) == 0) {//mouse events for self created menu + framepos = id2pos(Frameid); + if (framepos == -1) + break; + + switch (LOWORD(wParam)) { + case frame_menu_lock: + Frames[framepos].Locked = !Frames[framepos].Locked; + break; + case frame_menu_visible: + Frames[framepos].visible = !Frames[framepos].visible; + break; + case frame_menu_showtitlebar: + Frames[framepos].TitleBar.ShowTitleBar = !Frames[framepos].TitleBar.ShowTitleBar; + break; + case frame_menu_floating: + CLUIFrameSetFloat(Frameid, 0); + break; + } + CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0); + } + break; + + case WM_RBUTTONDOWN: + { + HMENU hmenu; + if (ServiceExists(MS_CLIST_MENUBUILDFRAMECONTEXT)) + hmenu = (HMENU)CallService(MS_CLIST_MENUBUILDFRAMECONTEXT, Frameid, 0); + else { + framepos = id2pos(Frameid); + + mir_cslock lck(csFrameHook); + if (framepos == -1) + break; + + hmenu = CreatePopupMenu(); + AppendMenu(hmenu, MF_STRING | MF_DISABLED | MF_GRAYED, 15, Frames[framepos].name); + AppendMenu(hmenu, MF_SEPARATOR, 16, _T("")); + + if (Frames[framepos].Locked) + AppendMenu(hmenu, MF_STRING | MF_CHECKED, frame_menu_lock, TranslateT("Lock frame")); + else + AppendMenu(hmenu, MF_STRING, frame_menu_lock, TranslateT("Lock frame")); + + if (Frames[framepos].visible) + AppendMenu(hmenu, MF_STRING | MF_CHECKED, frame_menu_visible, TranslateT("Visible")); + else + AppendMenu(hmenu, MF_STRING, frame_menu_visible, TranslateT("Visible")); + + if (Frames[framepos].TitleBar.ShowTitleBar) + AppendMenu(hmenu, MF_STRING | MF_CHECKED, frame_menu_showtitlebar, TranslateT("Show title bar")); + else + AppendMenu(hmenu, MF_STRING, frame_menu_showtitlebar, TranslateT("Show title bar")); + + if (Frames[framepos].Skinned) + AppendMenu(hmenu, MF_STRING | MF_CHECKED, frame_menu_skinned, TranslateT("Skinned frame")); + else + AppendMenu(hmenu, MF_STRING, frame_menu_skinned, TranslateT("Skinned frame")); + + if (Frames[framepos].floating) + AppendMenu(hmenu, MF_STRING | MF_CHECKED, frame_menu_floating, TranslateT("Floating")); + else + AppendMenu(hmenu, MF_STRING, frame_menu_floating, TranslateT("Floating")); + } + POINT pt; + GetCursorPos(&pt); + TrackPopupMenu(hmenu, TPM_LEFTALIGN, pt.x, pt.y, 0, hwnd, 0); + DestroyMenu(hmenu); + } + break; + + case WM_LBUTTONDBLCLK: + Framemod = -1; + lbypos = -1; + oldframeheight = -1; + ReleaseCapture(); + CallService(MS_CLIST_FRAMES_UCOLLFRAME, Frameid, 0); + lbypos = -1; + oldframeheight = -1; + ReleaseCapture(); + break; + + case WM_LBUTTONUP: + if (GetCapture() != hwnd) + break; + + curdragbar = -1; + lbypos = -1; + oldframeheight = -1; + ReleaseCapture(); + RedrawWindow(pcli->hwndContactList, NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_UPDATENOW | RDW_ALLCHILDREN); + break; + + case WM_LBUTTONDOWN: + framepos = id2pos(Frameid); + { + mir_cslock lck(csFrameHook); + if (framepos == -1) + break; + + if (Frames[framepos].floating) { + POINT pt; + GetCursorPos(&pt); + Frames[framepos].TitleBar.oldpos = pt; + } + + if ((!(wParam&MK_CONTROL)) && Frames[framepos].Locked && (!(Frames[framepos].floating))) { + if (cfg::getByte("CLUI", "ClientAreaDrag", 0)) { + POINT pt; + GetCursorPos(&pt); + return SendMessage(GetParent(hwnd), WM_SYSCOMMAND, SC_MOVE | HTCAPTION, MAKELPARAM(pt.x, pt.y)); + } + } + if (Frames[framepos].floating) { + RECT rc; + GetCursorPos(&ptOld); + GetWindowRect(hwnd, &rc); + nLeft = (short)rc.left; + nTop = (short)rc.top; + } + } + SetCapture(hwnd); + break; + + case WM_MOUSEMOVE: + { + mir_cslock lck(csFrameHook); + int pos = id2pos(Frameid); + if (pos != -1) { + int oldflags; + char TBcapt[255]; + mir_snprintf(TBcapt, _countof(TBcapt), "%s - h:%d, vis:%d, fl:%d, fl:(%d,%d,%d,%d),or: %d", + Frames[pos].name, Frames[pos].height, Frames[pos].visible, Frames[pos].floating, + Frames[pos].FloatingPos.x, Frames[pos].FloatingPos.y, + Frames[pos].FloatingSize.x, Frames[pos].FloatingSize.y, + Frames[pos].order); + + oldflags = CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_FLAGS, Frames[pos].id), 0); + if (!(oldflags & F_SHOWTBTIP)) + oldflags |= F_SHOWTBTIP; + } + } + if (wParam & MK_LBUTTON) { + RECT rcMiranda; + RECT rcwnd, rcOverlap; + POINT newpt, ofspt, curpt, newpos; + + mir_cslockfull lck(csFrameHook); + + int pos = id2pos(Frameid); + if (Frames[pos].floating) { + GetCursorPos(&curpt); + rcwnd.bottom = curpt.y + 5; + rcwnd.top = curpt.y; + rcwnd.left = curpt.x; + rcwnd.right = curpt.x + 5; + + GetWindowRect(pcli->hwndContactList, &rcMiranda); + if (IsWindowVisible(pcli->hwndContactList) && IntersectRect(&rcOverlap, &rcwnd, &rcMiranda)) { + int id = Frames[pos].id; + + lck.unlock(); + ofspt.x = 0; + ofspt.y = 0; + ClientToScreen(Frames[pos].TitleBar.hwnd, &ofspt); + ofspt.x = curpt.x - ofspt.x; + ofspt.y = curpt.y - ofspt.y; + + CLUIFrameSetFloat(id, 0); + newpt.x = 0; + newpt.y = 0; + ClientToScreen(Frames[pos].TitleBar.hwnd, &newpt); + SetCursorPos(newpt.x + ofspt.x, newpt.y + ofspt.y); + GetCursorPos(&curpt); + + lck.lock(); + Frames[pos].TitleBar.oldpos = curpt; + return 0; + } + } + else { + int id = Frames[pos].id; + + GetCursorPos(&curpt); + rcwnd.bottom = curpt.y + 5; + rcwnd.top = curpt.y; + rcwnd.left = curpt.x; + rcwnd.right = curpt.x + 5; + + GetWindowRect(pcli->hwndContactList, &rcMiranda); + + if (!IntersectRect(&rcOverlap, &rcwnd, &rcMiranda)) { + lck.unlock(); + GetCursorPos(&curpt); + GetWindowRect(Frames[pos].hWnd, &rcwnd); + rcwnd.left = rcwnd.right - rcwnd.left; + rcwnd.top = rcwnd.bottom - rcwnd.top; + newpos.x = curpt.x; + newpos.y = curpt.y; + if (curpt.x >= (rcMiranda.right - 1)) + newpos.x = curpt.x + 5; + if (curpt.x <= (rcMiranda.left + 1)) + newpos.x = curpt.x - (rcwnd.left) - 5; + if (curpt.y >= (rcMiranda.bottom - 1)) + newpos.y = curpt.y + 5; + if (curpt.y <= (rcMiranda.top + 1)) + newpos.y = curpt.y - (rcwnd.top) - 5; + + ofspt.x = 0; + ofspt.y = 0; + GetWindowRect(Frames[pos].TitleBar.hwnd, &rcwnd); + ofspt.x = curpt.x - ofspt.x; + ofspt.y = curpt.y - ofspt.y; + Frames[pos].FloatingPos.x = newpos.x; + Frames[pos].FloatingPos.y = newpos.y; + CLUIFrameSetFloat(id, 0); + + lck.lock(); + newpt.x = 0; + newpt.y = 0; + ClientToScreen(Frames[pos].TitleBar.hwnd, &newpt); + GetWindowRect(Frames[pos].hWnd, &rcwnd); + SetCursorPos(newpt.x + (rcwnd.right - rcwnd.left) / 2, newpt.y + (rcwnd.bottom - rcwnd.top) / 2); + GetCursorPos(&curpt); + Frames[pos].TitleBar.oldpos = curpt; + return 0; + } + } + } + if (wParam & MK_LBUTTON) { + int newh = -1, prevold; + + if (GetCapture() != hwnd) + break; + + POINT pt, pt2; + mir_cslockfull lck(csFrameHook); + int pos = id2pos(Frameid); + + if (Frames[pos].floating) { + RECT wndr; + GetCursorPos(&pt); + if ((Frames[pos].TitleBar.oldpos.x != pt.x) || (Frames[pos].TitleBar.oldpos.y != pt.y)) { + pt2 = pt; + ScreenToClient(hwnd, &pt2); + GetWindowRect(Frames[pos].ContainerWnd, &wndr); + + POINT ptNew = pt; + + nLeft += (short)ptNew.x - ptOld.x; + nTop += (short)ptNew.y - ptOld.y; + + if (!(wParam & MK_CONTROL)) + PositionThumb(&Frames[pos], nLeft, nTop); + else + SetWindowPos(Frames[pos].ContainerWnd, 0, nLeft, nTop, 0, 0, SWP_NOSIZE | SWP_NOZORDER); + + ptOld = ptNew; + + pt.x = nLeft; + pt.y = nTop; + Frames[pos].TitleBar.oldpos = pt; + } + return 0; + } + if (Frames[pos].prevvisframe != -1) { + GetCursorPos(&pt); + + if ((Frames[pos].TitleBar.oldpos.x == pt.x) && (Frames[pos].TitleBar.oldpos.y == pt.y)) + break; + + ypos = rect.top + pt.y; + xpos = rect.left + pt.x; + Framemod = -1; + + if (Frames[pos].align == alBottom) { + direction = -1; + Framemod = pos; + } + else { + direction = 1; + Framemod = Frames[pos].prevvisframe; + } + if (Frames[Framemod].Locked) + break; + if (curdragbar != -1 && curdragbar != pos) + break; + + if (lbypos == -1) { + curdragbar = pos; + lbypos = ypos; + oldframeheight = Frames[Framemod].height; + SetCapture(hwnd); + break; + } + newh = oldframeheight + direction * (ypos - lbypos); + if (newh > 0) { + prevold = Frames[Framemod].height; + Frames[Framemod].height = newh; + if (!CLUIFramesFitInSize()) { + Frames[Framemod].height = prevold; + return TRUE; + } + Frames[Framemod].height = newh; + if (newh > 3) Frames[Framemod].collapsed = TRUE; + + } + Frames[pos].TitleBar.oldpos = pt; + } + lck.unlock(); + + if (newh > 0) + CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0); + break; + } + curdragbar = -1; + lbypos = -1; + oldframeheight = -1; + ReleaseCapture(); + break; + + case WM_NCPAINT: + if (GetWindowLongPtr(hwnd, GWL_STYLE) & WS_BORDER) { + HDC hdc = GetWindowDC(hwnd); + HPEN hPenOld = reinterpret_cast(SelectObject(hdc, g_hPenCLUIFrames)); + RECT rcWindow, rc; + HBRUSH brold; + + CallWindowProc(DefWindowProc, hwnd, msg, wParam, lParam); + GetWindowRect(hwnd, &rcWindow); + rc.left = rc.top = 0; + rc.right = rcWindow.right - rcWindow.left; + rc.bottom = rcWindow.bottom - rcWindow.top; + brold = reinterpret_cast(SelectObject(hdc, GetStockObject(HOLLOW_BRUSH))); + Rectangle(hdc, 0, 0, rcWindow.right - rcWindow.left, rcWindow.bottom - rcWindow.top); + SelectObject(hdc, hPenOld); + SelectObject(hdc, brold); + ReleaseDC(hwnd, hdc); + return 0; + } + break; + + case WM_PRINT: + case WM_PRINTCLIENT: + GetClientRect(hwnd, &rect); + DrawTitleBar((HDC)wParam, rect, Frameid); + + case WM_PAINT: + { + PAINTSTRUCT paintStruct; + HDC paintDC = BeginPaint(hwnd, &paintStruct); + rect = paintStruct.rcPaint; + DrawTitleBar(paintDC, rect, Frameid); + EndPaint(hwnd, &paintStruct); + } + return 0; + + default: + return DefWindowProc(hwnd, msg, wParam, lParam); + } + return TRUE; +} + +int CLUIFrameResizeFloatingFrame(int framepos) +{ + if (!Frames[framepos].floating) + return 0; + if (Frames[framepos].ContainerWnd == 0) + return 0; + + RECT rect; + GetClientRect(Frames[framepos].ContainerWnd, &rect); + + int width = rect.right - rect.left; + int height = rect.bottom - rect.top; + int floatingHeight = cfg::dat.titleBarHeight; + + if (floatingHeight <= 0 || floatingHeight > 50) + floatingHeight = 18; + + Frames[framepos].visible ? ShowWindow(Frames[framepos].ContainerWnd, SW_SHOWNOACTIVATE) : ShowWindow(Frames[framepos].ContainerWnd, SW_HIDE); + + if (Frames[framepos].TitleBar.ShowTitleBar) { + ShowWindow(Frames[framepos].TitleBar.hwnd, SW_SHOWNOACTIVATE); + Frames[framepos].height = height - floatingHeight; + SetWindowPos(Frames[framepos].TitleBar.hwnd, HWND_TOP, 0, 0, width, floatingHeight, SWP_SHOWWINDOW | SWP_DRAWFRAME | SWP_NOACTIVATE); + InvalidateRect(Frames[framepos].TitleBar.hwnd, NULL, FALSE); + SetWindowPos(Frames[framepos].hWnd, HWND_TOP, 0, floatingHeight, width, height - floatingHeight, SWP_SHOWWINDOW | SWP_NOACTIVATE); + + } + else { + Frames[framepos].height = height; + ShowWindow(Frames[framepos].TitleBar.hwnd, SW_HIDE); + SetWindowPos(Frames[framepos].hWnd, HWND_TOP, 0, 0, width, height, SWP_SHOWWINDOW | SWP_NOACTIVATE); + } + + if (Frames[framepos].ContainerWnd != 0) + UpdateWindow(Frames[framepos].ContainerWnd); + GetWindowRect(Frames[framepos].hWnd, &Frames[framepos].wndSize); + + if (Frames[framepos].TitleBar.ShowTitleBar) + RedrawWindow(Frames[framepos].TitleBar.hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_UPDATENOW); + + RedrawWindow(Frames[framepos].hWnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_UPDATENOW); + return 0; +} + +static int CLUIFrameOnMainMenuBuild(WPARAM, LPARAM) +{ + CLUIFramesLoadMainMenu(); + return 0; +} + +LRESULT CALLBACK CLUIFrameContainerWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + int framepos; + RECT rect; + INT_PTR Frameid = GetWindowLongPtr(hwnd, GWLP_USERDATA); + + switch (msg) { + case WM_CREATE: + { + mir_cslockfull lck(csFrameHook); + framepos = id2pos(Frameid); + } + return 0; + + case WM_GETMINMAXINFO: + TitleBarH = cfg::dat.titleBarHeight; + { + mir_cslock lck(csFrameHook); + framepos = id2pos(Frameid); + if (framepos < 0 || framepos >= nFramescount) + break; + + if (!Frames[framepos].minmaxenabled) + break; + + if (Frames[framepos].ContainerWnd == 0) + break; + + if (Frames[framepos].Locked) { + RECT rct; + GetWindowRect(hwnd, &rct); + ((LPMINMAXINFO)lParam)->ptMinTrackSize.x = rct.right - rct.left; + ((LPMINMAXINFO)lParam)->ptMinTrackSize.y = rct.bottom - rct.top; + ((LPMINMAXINFO)lParam)->ptMaxTrackSize.x = rct.right - rct.left; + ((LPMINMAXINFO)lParam)->ptMaxTrackSize.y = rct.bottom - rct.top; + } + + MINMAXINFO minmax; + memset(&minmax, 0, sizeof(minmax)); + if (SendMessage(Frames[framepos].hWnd, WM_GETMINMAXINFO, 0, (LPARAM)&minmax) != 0) + return DefWindowProc(hwnd, msg, wParam, lParam); + + RECT border; + int tbh = TitleBarH * btoint(Frames[framepos].TitleBar.ShowTitleBar); + GetBorderSize(hwnd, &border); + if (minmax.ptMaxTrackSize.x != 0 && minmax.ptMaxTrackSize.y != 0) { + ((LPMINMAXINFO)lParam)->ptMinTrackSize.x = minmax.ptMinTrackSize.x; + ((LPMINMAXINFO)lParam)->ptMinTrackSize.y = minmax.ptMinTrackSize.y; + ((LPMINMAXINFO)lParam)->ptMaxTrackSize.x = minmax.ptMaxTrackSize.x + border.left + border.right; + ((LPMINMAXINFO)lParam)->ptMaxTrackSize.y = minmax.ptMaxTrackSize.y + tbh + border.top + border.bottom; + } + } + + case WM_MOVE: + { + mir_cslock lck(csFrameHook); + framepos = id2pos(Frameid); + if (framepos < 0 || framepos >= nFramescount) + break; + + if (Frames[framepos].ContainerWnd == 0) + return 0; + + GetWindowRect(Frames[framepos].ContainerWnd, &rect); + Frames[framepos].FloatingPos.x = rect.left; + Frames[framepos].FloatingPos.y = rect.top; + Frames[framepos].FloatingSize.x = rect.right - rect.left; + Frames[framepos].FloatingSize.y = rect.bottom - rect.top; + CLUIFramesStoreFrameSettings(framepos); + } + return 0; + + case WM_SIZE: + { + mir_cslock lck(csFrameHook); + framepos = id2pos(Frameid); + if (framepos < 0 || framepos >= nFramescount) + break; + + if (Frames[framepos].ContainerWnd == 0) + return 0; + + CLUIFrameResizeFloatingFrame(framepos); + + RECT rect; + GetWindowRect(Frames[framepos].ContainerWnd, &rect); + Frames[framepos].FloatingPos.x = rect.left; + Frames[framepos].FloatingPos.y = rect.top; + Frames[framepos].FloatingSize.x = rect.right - rect.left; + Frames[framepos].FloatingSize.y = rect.bottom - rect.top; + + CLUIFramesStoreFrameSettings(framepos); + } + return 0; + + case WM_CLOSE: + DestroyWindow(hwnd); + break; + + case WM_DESTROY: + return 0; + } + return DefWindowProc(hwnd, msg, wParam, lParam); +} + +static HWND CreateContainerWindow(HWND parent, int x, int y, int width, int height) +{ + return(CreateWindowA("FramesContainer", "aaaa", WS_POPUP | WS_THICKFRAME, x, y, width, height, parent, 0, g_hInst, 0)); +} + +INT_PTR CLUIFrameSetFloat(WPARAM wParam, LPARAM lParam) +{ + HWND hwndtmp, hwndtooltiptmp; + { + mir_cslock lck(csFrameHook); + wParam = id2pos(wParam); + if ((int)wParam >= 0 && (int)wParam < nFramescount) { + if (Frames[wParam].floating) { + SetParent(Frames[wParam].hWnd, pcli->hwndContactList); + SetParent(Frames[wParam].TitleBar.hwnd, pcli->hwndContactList); + Frames[wParam].floating = FALSE; + DestroyWindow(Frames[wParam].ContainerWnd); + Frames[wParam].ContainerWnd = 0; + } + else { + RECT recttb, rectw, border; + int temp; + int neww, newh; + + Frames[wParam].oldstyles = GetWindowLongPtr(Frames[wParam].hWnd, GWL_STYLE); + Frames[wParam].TitleBar.oldstyles = GetWindowLongPtr(Frames[wParam].TitleBar.hwnd, GWL_STYLE); + bool locked = Frames[wParam].Locked; + Frames[wParam].Locked = FALSE; + Frames[wParam].minmaxenabled = FALSE; + + GetWindowRect(Frames[wParam].hWnd, &rectw); + GetWindowRect(Frames[wParam].TitleBar.hwnd, &recttb); + if (!Frames[wParam].TitleBar.ShowTitleBar) + recttb.top = recttb.bottom = recttb.left = recttb.right = 0; + + Frames[wParam].ContainerWnd = CreateContainerWindow(pcli->hwndContactList, Frames[wParam].FloatingPos.x, Frames[wParam].FloatingPos.y, 10, 10); + + SetParent(Frames[wParam].hWnd, Frames[wParam].ContainerWnd); + SetParent(Frames[wParam].TitleBar.hwnd, Frames[wParam].ContainerWnd); + + GetBorderSize(Frames[wParam].ContainerWnd, &border); + + SetWindowLongPtr(Frames[wParam].ContainerWnd, GWLP_USERDATA, Frames[wParam].id); + if ((lParam == 1)) { + if ((Frames[wParam].FloatingPos.x != 0) && (Frames[wParam].FloatingPos.y != 0)) { + if (Frames[wParam].FloatingPos.x < 20) + Frames[wParam].FloatingPos.x = 40; + + if (Frames[wParam].FloatingPos.y < 20) + Frames[wParam].FloatingPos.y = 40; + + SetWindowPos(Frames[wParam].ContainerWnd, HWND_TOPMOST, Frames[wParam].FloatingPos.x, Frames[wParam].FloatingPos.y, Frames[wParam].FloatingSize.x, Frames[wParam].FloatingSize.y, SWP_HIDEWINDOW); + } + else SetWindowPos(Frames[wParam].ContainerWnd, HWND_TOPMOST, 120, 120, 140, 140, SWP_HIDEWINDOW); + } + else { + neww = rectw.right - rectw.left + border.left + border.right; + newh = (rectw.bottom - rectw.top) + (recttb.bottom - recttb.top) + border.top + border.bottom; + if (neww < 20) + neww = 40; + + if (newh < 20) + newh = 40; + + if (Frames[wParam].FloatingPos.x < 20) + Frames[wParam].FloatingPos.x = 40; + + if (Frames[wParam].FloatingPos.y < 20) + Frames[wParam].FloatingPos.y = 40; + + SetWindowPos(Frames[wParam].ContainerWnd, HWND_TOPMOST, Frames[wParam].FloatingPos.x, Frames[wParam].FloatingPos.y, neww, newh, SWP_HIDEWINDOW); + } + SetWindowText(Frames[wParam].ContainerWnd, Frames[wParam].TitleBar.tbname); + temp = GetWindowLongPtr(Frames[wParam].ContainerWnd, GWL_EXSTYLE); + temp |= WS_EX_TOOLWINDOW | WS_EX_TOPMOST; + SetWindowLongPtr(Frames[wParam].ContainerWnd, GWL_EXSTYLE, temp); + Frames[wParam].floating = TRUE; + Frames[wParam].Locked = locked; + } + } + + CLUIFramesStoreFrameSettings(wParam); + Frames[wParam].minmaxenabled = TRUE; + hwndtooltiptmp = Frames[wParam].TitleBar.hwndTip; + + hwndtmp = Frames[wParam].ContainerWnd; + } + + CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0); + SendMessage(hwndtmp, WM_SIZE, 0, 0); + SetWindowPos(hwndtooltiptmp, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); + return 0; +} + +TCHAR g_ptszEventName[100]; + +static int CLUIFrameOnModulesLoad(WPARAM, LPARAM) +{ + mir_sntprintf(g_ptszEventName, _countof(g_ptszEventName), _T("mf_update_evt_%d"), GetCurrentThreadId()); + g_hEventThread = CreateEvent(NULL, TRUE, FALSE, g_ptszEventName); + hThreadMFUpdate = mir_forkthread(MF_UpdateThread, NULL); + SetThreadPriority(hThreadMFUpdate, THREAD_PRIORITY_IDLE); + CLUIFramesLoadMainMenu(); + CLUIFramesCreateMenuForFrame(-1, NULL, 000010000, false); + return 0; +} + +static int CLUIFrameOnModulesUnload(WPARAM, LPARAM) +{ + mf_updatethread_running = FALSE; + + SetThreadPriority(hThreadMFUpdate, THREAD_PRIORITY_NORMAL); + SetEvent(g_hEventThread); + WaitForSingleObject(hThreadMFUpdate, 2000); + CloseHandle(g_hEventThread); + + Menu_RemoveItem(cont.MIVisible); + Menu_RemoveItem(cont.MITitle); + Menu_RemoveItem(cont.MITBVisible); + Menu_RemoveItem(cont.MILock); + Menu_RemoveItem(cont.MIColl); + Menu_RemoveItem(cont.MIFloating); + Menu_RemoveItem(cont.MIAlignRoot); + Menu_RemoveItem(cont.MIAlignTop); + Menu_RemoveItem(cont.MIAlignClient); + Menu_RemoveItem(cont.MIAlignBottom); + Menu_RemoveItem(cont.MIBorder); + return 0; +} + +/* + * wparam=hIcon + * return hImage on success,-1 on failure + */ + +void RegisterCLUIFrameClasses() +{ + WNDCLASS wndclass = {}; + wndclass.style = CS_DBLCLKS; + wndclass.lpfnWndProc = CLUIFrameTitleBarProc; + wndclass.hInstance = g_hInst; + wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); + wndclass.lpszClassName = CLUIFrameTitleBarClassName; + RegisterClass(&wndclass); + + WNDCLASS cntclass = {}; + cntclass.style = CS_DBLCLKS | CS_DROPSHADOW; + cntclass.lpfnWndProc = CLUIFrameContainerWndProc; + cntclass.hInstance = g_hInst; + cntclass.hCursor = LoadCursor(NULL, IDC_ARROW); + cntclass.lpszClassName = _T("FramesContainer"); + RegisterClass(&cntclass); +} + +int LoadCLUIFramesModule(void) +{ + GapBetweenFrames = cfg::dat.gapBetweenFrames; + + nFramescount = 0; + + HookEvent(ME_SYSTEM_MODULESLOADED, CLUIFrameOnModulesLoad); + HookEvent(ME_CLIST_PREBUILDFRAMEMENU, CLUIFramesModifyContextMenuForFrame); + HookEvent(ME_CLIST_PREBUILDMAINMENU, CLUIFrameOnMainMenuBuild); + HookEvent(ME_SYSTEM_PRESHUTDOWN, CLUIFrameOnModulesUnload); + + CreateServiceFunction(MS_CLIST_FRAMES_ADDFRAME, CLUIFramesAddFrame); + CreateServiceFunction(MS_CLIST_FRAMES_REMOVEFRAME, CLUIFramesRemoveFrame); + + CreateServiceFunction(MS_CLIST_FRAMES_SETFRAMEOPTIONS, CLUIFramesSetFrameOptions); + CreateServiceFunction(MS_CLIST_FRAMES_GETFRAMEOPTIONS, CLUIFramesGetFrameOptions); + CreateServiceFunction(MS_CLIST_FRAMES_UPDATEFRAME, CLUIFramesUpdateFrame); + + CreateServiceFunction(MS_CLIST_FRAMES_SHFRAMETITLEBAR, CLUIFramesShowHideFrameTitleBar); + CreateServiceFunction(MS_CLIST_FRAMES_SHOWALLFRAMESTB, CLUIFramesShowAllTitleBars); + CreateServiceFunction(MS_CLIST_FRAMES_HIDEALLFRAMESTB, CLUIFramesHideAllTitleBars); + CreateServiceFunction(MS_CLIST_FRAMES_SHFRAME, CLUIFramesShowHideFrame); + CreateServiceFunction(MS_CLIST_FRAMES_SHOWALLFRAMES, CLUIFramesShowAll); + + CreateServiceFunction(MS_CLIST_FRAMES_ULFRAME, CLUIFramesLockUnlockFrame); + CreateServiceFunction(MS_CLIST_FRAMES_UCOLLFRAME, CLUIFramesCollapseUnCollapseFrame); + CreateServiceFunction(MS_CLIST_FRAMES_SETUNBORDER, CLUIFramesSetUnSetBorder); + CreateServiceFunction(MS_CLIST_FRAMES_SETSKINNED, CLUIFramesSetUnSetSkinned); + + CreateServiceFunction(CLUIFRAMESSETALIGN, CLUIFramesSetAlign); + CreateServiceFunction(CLUIFRAMESMOVEDOWN, CLUIFramesMoveDown); + CreateServiceFunction(CLUIFRAMESMOVEUP, CLUIFramesMoveUp); + + CreateServiceFunction(CLUIFRAMESSETALIGNALTOP, CLUIFramesSetAlignalTop); + CreateServiceFunction(CLUIFRAMESSETALIGNALCLIENT, CLUIFramesSetAlignalClient); + CreateServiceFunction(CLUIFRAMESSETALIGNALBOTTOM, CLUIFramesSetAlignalBottom); + + CreateServiceFunction("Set_Floating", CLUIFrameSetFloat); + hWndExplorerToolBar = FindWindowExA(0, 0, "Shell_TrayWnd", NULL); + OnFrameTitleBarBackgroundChange(); + + FramesSysNotStarted = FALSE; + g_hPenCLUIFrames = CreatePen(PS_SOLID, 1, cfg::getDword("CLUI", "clr_frameborder", GetSysColor(COLOR_3DDKSHADOW))); + return 0; +} + +void LoadExtraIconModule() +{ + hStatusBarShowToolTipEvent = CreateHookableEvent(ME_CLIST_FRAMES_SB_SHOW_TOOLTIP); + hStatusBarHideToolTipEvent = CreateHookableEvent(ME_CLIST_FRAMES_SB_HIDE_TOOLTIP); +} + +int UnLoadCLUIFramesModule(void) +{ + CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0); + CLUIFramesStoreAllFrames(); + DeleteObject(g_hPenCLUIFrames); + + mir_cslock lck(csFrameHook); + FramesSysNotStarted = TRUE; + for (int i = 0; i < nFramescount; i++) { + DestroyWindow(Frames[i].hWnd); + Frames[i].hWnd = (HWND)-1; + DestroyWindow(Frames[i].TitleBar.hwnd); + Frames[i].TitleBar.hwnd = (HWND)-1; + DestroyWindow(Frames[i].ContainerWnd); + Frames[i].ContainerWnd = (HWND)-1; + DestroyMenu(Frames[i].TitleBar.hmenu); + + if (Frames[i].name != NULL) + mir_free(Frames[i].name); + if (Frames[i].TitleBar.tbname != NULL) + mir_free(Frames[i].TitleBar.tbname); + } + free(Frames); + Frames = NULL; + nFramescount = 0; + UnregisterClass(CLUIFrameTitleBarClassName, g_hInst); + return 0; +} diff --git a/plugins/Clist_nicer/src/cluiframes.h b/plugins/Clist_nicer/src/cluiframes.h new file mode 100644 index 0000000000..4fef8cec0f --- /dev/null +++ b/plugins/Clist_nicer/src/cluiframes.h @@ -0,0 +1,127 @@ +/* +Miranda ICQ: the free icq client for MS Windows +Copyright (C) 2000-2 Richard Hughes, Roland Rabien & Tristan Van de Vreede + +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. +*/ + +#pragma once + +#ifndef _CLUIFRAMES_H_ +#define _CLUIFRAMES_H_ + +int LoadCLUIFramesModule(void); +int UnLoadCLUIFramesModule(void); +int CLUIFramesGetMinHeight(); +int CLUIFramesOnClistResize(WPARAM wParam, LPARAM lParam); +int SizeFramesByWindowRect(RECT *r); +int CLUIFramesResizeFrames(RECT *rc); + +typedef struct tagProtocolData { + char *RealName; + int protopos; + boolean show; +} ProtocolData; + +typedef struct +{ + int order; + int realpos; +}SortData; + + + + +//============ +#define CLUIFRAMESSETALIGN "CLUIFramesSetAlign" + +#define CLUIFRAMESSETALIGNALTOP "CLUIFramesSetAlignalTop" +#define CLUIFRAMESSETALIGNALCLIENT "CLUIFramesSetAlignalClient" +#define CLUIFRAMESSETALIGNALBOTTOM "CLUIFramesSetAlignalBottom" +#define CLUIFRAMESMOVEUP "CLUIFramesMoveUp" +#define CLUIFRAMESMOVEDOWN "CLUIFramesMoveDown" + +struct FrameMenuHandles +{ + HGENMENU MainMenuItem; + HGENMENU MIVisible, MITitle, MITBVisible, MILock, MIColl, MIFloating, MIAlignRoot; + HGENMENU MIAlignTop, MIAlignClient, MIAlignBottom; + HGENMENU MIBorder, MISkinned; +}; + +struct FrameTitleBar +{ + HWND hwnd; + HWND TitleBarbutt; + HWND hwndTip; + + LPTSTR tbname; + LPTSTR tooltip; + + HMENU hmenu; + HICON hicon; + + bool ShowTitleBar; + bool ShowTitleBarTip; + int oldstyles; + POINT oldpos; + RECT wndSize; +}; + +struct DockOpt +{ + HWND hwndLeft; + HWND hwndRight; +}; + +struct FRAMEWND +{ + int id; + HWND hWnd; + RECT wndSize; + LPTSTR name; + int align; + int height; + int dwFlags; + bool Locked; + bool visible; + bool needhide; + bool collapsed; + bool floating; + bool minmaxenabled; + bool UseBorder; + int prevvisframe; + int HeightWhenCollapsed; + FrameTitleBar TitleBar; + FrameMenuHandles MenuHandles; + int oldstyles; + HWND ContainerWnd; + POINT FloatingPos; + POINT FloatingSize; + int order; + DockOpt dockOpt; + HWND OwnerWindow; + bool Skinned; + RECT oldWndSize; + WNDPROC wndProc; +}; + +#define OFFSET_PROTOPOS 200 +#define OFFSET_VISIBLE 400 + +#define CLUIFrameTitleBarClassName _T("CLUIFrameTitleBar") +#define CLUIFrameModule "CLUIFrames" + +#endif diff --git a/plugins/Clist_nicer/src/cluiopts.cpp b/plugins/Clist_nicer/src/cluiopts.cpp index 3bdd48aeb9..bfba68fd9e 100644 --- a/plugins/Clist_nicer/src/cluiopts.cpp +++ b/plugins/Clist_nicer/src/cluiopts.cpp @@ -22,7 +22,7 @@ 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 "stdafx.h" extern HANDLE hExtraImageApplying; extern SIZE g_oldSize; diff --git a/plugins/Clist_nicer/src/cluiservices.cpp b/plugins/Clist_nicer/src/cluiservices.cpp index 351e4073c4..cda2e1b583 100644 --- a/plugins/Clist_nicer/src/cluiservices.cpp +++ b/plugins/Clist_nicer/src/cluiservices.cpp @@ -22,8 +22,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include -#include "../cluiframes/cluiframes.h" +#include "stdafx.h" +#include "cluiframes.h" extern HIMAGELIST hCListImages; extern ButtonItem *g_ButtonItems; diff --git a/plugins/Clist_nicer/src/config.cpp b/plugins/Clist_nicer/src/config.cpp index ba013a2202..48486e1456 100644 --- a/plugins/Clist_nicer/src/config.cpp +++ b/plugins/Clist_nicer/src/config.cpp @@ -22,7 +22,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include +#include "stdafx.h" TCluiData cfg::dat = { 0 }; ClcData* cfg::clcdat = 0; diff --git a/plugins/Clist_nicer/src/config.h b/plugins/Clist_nicer/src/config.h new file mode 100644 index 0000000000..c833107fe3 --- /dev/null +++ b/plugins/Clist_nicer/src/config.h @@ -0,0 +1,140 @@ +/* + +Miranda NG: the free IM client for Microsoft* Windows* + +Copyright (ñ) 2012-15 Miranda NG project (http://miranda-ng.org), +Copyright (c) 2000-03 Miranda ICQ/IM 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 + +#ifndef __CONFIG_H_ +#define __CONFIG_H_ + +#define DEFAULT_MODULE "Clist" + +#define IS_THEMED (API::sysState.isThemed) +#define IS_AERO (API::sysState.isAero) + +typedef HRESULT (WINAPI *pfnDwmExtendFrameIntoClientArea_t)(HWND hwnd, const MARGINS *margins); +typedef HRESULT (WINAPI *pfnDwmIsCompositionEnabled_t)(BOOL *); + +class CRTException : public std::runtime_error +{ +public: + CRTException(const char *szMsg, const TCHAR *szParam); + ~CRTException() {} + + void display() const; + +private: + TCHAR m_szParam[MAX_PATH]; +}; + +class cfg +{ +public: + static DWORD getDword(const MCONTACT hContact, const char *szModule, const char *szSetting, DWORD uDefault); + static DWORD getDword(const char *szModule, const char *szSetting, DWORD uDefault); + static DWORD getDword(const char *szSetting, DWORD uDefault); + + static WORD getWord(const MCONTACT hContact, const char *szModule, const char *szSetting, WORD uDefault); + static WORD getWord(const char *szModule, const char *szSetting, WORD uDefault); + static WORD getWord(const char *szSetting, WORD uDefault); + + static int getByte(const MCONTACT hContact, const char *szModule, const char *szSetting, int uDefault); + static int getByte(const char *szModule, const char *szSetting, int uDefault); + static int getByte(const char *szSetting, int uDefault); + + static INT_PTR getTString(const MCONTACT hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv); + static INT_PTR getString(const MCONTACT hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv); + + static INT_PTR writeDword(const MCONTACT hContact, const char *szModule, const char *szSetting, DWORD value); + static INT_PTR writeDword(const char *szModule, const char *szSetting, DWORD value); + + static INT_PTR writeWord(const MCONTACT hContact, const char *szModule, const char *szSetting, WORD value); + static INT_PTR writeWord(const char *szModule, const char *szSetting, WORD value); + + static INT_PTR writeByte(const MCONTACT hContact, const char *szModule, const char *szSetting, BYTE value); + static INT_PTR writeByte(const char *szModule, const char *szSetting, BYTE value); + + static INT_PTR writeTString(const MCONTACT hContact, const char *szModule, const char *szSetting, const TCHAR *st); + static INT_PTR writeString(const MCONTACT hContact, const char *szModule, const char *szSetting, const char *st); + + static TExtraCache* getCache(const MCONTACT hContact, const char *szProto); + +public: + static TCluiData dat; + static ClcData* clcdat; + + static LIST arCache; + + static bool shutDown; +}; + +struct TSysConfig { + bool isVistaPlus; + bool isSevenPlus; +}; + +struct TSysState { + bool isThemed; + bool isAero; + bool isDwmActive; +}; + +class API +{ +public: + static void onInit (); + static void updateState (); + + static void Ex_CopyEditToClipboard (HWND hWnd); + static INT_PTR CALLBACK Ex_DlgProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); + static void Ex_Handler (); + static int Ex_ShowDialog (EXCEPTION_POINTERS *ep, const char *szFile, int line, TCHAR* szReason, bool fAllowContinue); + + static pfnDwmExtendFrameIntoClientArea_t pfnDwmExtendFrameIntoClientArea; + static pfnDwmIsCompositionEnabled_t pfnDwmIsCompositionEnabled; + + static TSysConfig sysConfig; + static TSysState sysState; + + static EXCEPTION_RECORD exRecord; + static CONTEXT exCtx; + static LRESULT exLastResult; + static char exSzFile[MAX_PATH]; + static TCHAR exReason[256]; + static int exLine; + static bool exAllowContinue; + + static HMODULE hDwm; +}; + + +class Utils +{ +public: + static void TSAPI enableDlgControl(const HWND hwnd, UINT id, BOOL fEnable); + static void TSAPI showDlgControl(const HWND hwnd, UINT id, int showCmd); + static HMODULE loadSystemLibrary(const TCHAR* szFilename, bool useGetHandle = false); + +}; + +#endif /* __CONFIG_H_*/ diff --git a/plugins/Clist_nicer/src/contact.cpp b/plugins/Clist_nicer/src/contact.cpp index 7f1145226a..7e8617783a 100644 --- a/plugins/Clist_nicer/src/contact.cpp +++ b/plugins/Clist_nicer/src/contact.cpp @@ -22,7 +22,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include +#include "stdafx.h" struct { diff --git a/plugins/Clist_nicer/src/coolsb_internal.h b/plugins/Clist_nicer/src/coolsb_internal.h new file mode 100644 index 0000000000..64249c355c --- /dev/null +++ b/plugins/Clist_nicer/src/coolsb_internal.h @@ -0,0 +1,94 @@ +#ifndef _COOLSB_INTERNAL_INCLUDED +#define _COOLSB_INTERNAL_INCLUDED + +#ifdef __cplusplus +extern "C"{ +#endif + +#include + +// +// SCROLLBAR datatype. There are two of these structures per window +// +typedef struct +{ + UINT fScrollFlags; //flags + BOOL fScrollVisible; //if this scrollbar visible? + SCROLLINFO scrollInfo; //positional data (range, position, page size etc) + + int nArrowLength; //perpendicular size (height of a horizontal, width of a vertical) + int nArrowWidth; //parallel size (width of horz, height of vert) + + //data for inserted buttons + SCROLLBUT sbButtons[MAX_COOLSB_BUTS]; + int nButtons; + int nButSizeBefore; //size to the left / above the bar + int nButSizeAfter; //size to the right / below the bar + + BOOL fButVisibleBefore; //if the buttons to the left are visible + BOOL fButVisibleAfter; //if the buttons to the right are visible + + int nBarType; //SB_HORZ / SB_VERT + + UINT fFlatScrollbar; //do we display flat scrollbars? + int nMinThumbSize; + +} SCROLLBAR; + +// +// Container structure for a cool scrollbar window. +// +typedef struct +{ + UINT bars; //which of the scrollbars do we handle? SB_VERT / SB_HORZ / SB_BOTH + + SCROLLBAR sbarHorz; //one scrollbar structure each for + SCROLLBAR sbarVert; //the horizontal and vertical scrollbars + + BOOL fThumbTracking; // are we currently thumb-tracking?? + BOOL fLeftScrollbar; // support the WS_EX_LEFTSCROLLBAR style + + HWND hwndToolTip; // tooltip support!!! + + //size of the window borders + int cxLeftEdge, cxRightEdge; + int cyTopEdge, cyBottomEdge; + + // To prevent calling original WindowProc in response + // to our own temporary style change (fixes TreeView problem) + BOOL bPreventStyleChange; + +} SCROLLWND; + + +// +// PRIVATE INTERNAL FUNCTIONS +// +SCROLLWND *GetScrollWndFromHwnd(HWND hwnd); +#define InvertCOLORREF(col) ((~col) & 0x00ffffff) + +#define COOLSB_TIMERID1 65533 //initial timer +#define COOLSB_TIMERID2 65534 //scroll message timer +#define COOLSB_TIMERID3 -14 //mouse hover timer +#define COOLSB_TIMERINTERVAL1 300 +#define COOLSB_TIMERINTERVAL2 55 +#define COOLSB_TIMERINTERVAL3 20 //mouse hover time + + +// +// direction: 0 - same axis as scrollbar (i.e. width of a horizontal bar) +// 1 - perpendicular dimesion (i.e. height of a horizontal bar) +// +#define SM_CXVERTSB 1 +#define SM_CYVERTSB 0 +#define SM_CXHORZSB 0 +#define SM_CYHORZSB 1 +#define SM_SCROLL_WIDTH 1 +#define SM_SCROLL_LENGTH 0 + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/plugins/Clist_nicer/src/coolsblib.cpp b/plugins/Clist_nicer/src/coolsblib.cpp new file mode 100644 index 0000000000..bf4e14421d --- /dev/null +++ b/plugins/Clist_nicer/src/coolsblib.cpp @@ -0,0 +1,917 @@ +/* + + Cool Scrollbar Library Version 1.2 + + Module: coolsblib.c + Copyright (c) J Brown 2001 + + This code is freeware, however, you may not publish + this code elsewhere or charge any money for it. This code + is supplied as-is. I make no guarantees about the suitability + of this code - use at your own risk. + + It would be nice if you credited me, in the event + that you use this code in a product. + + VERSION HISTORY: + + V1.2: TreeView problem fixed by Diego Tartara + Small problem in thumbsize calculation also fixed (thanks Diego!) + + V1.1: Added support for Right-left windows + Changed calling convention of APIs to WINAPI (__stdcall) + Completely standalone (no need for c-runtime) + + V1.0: Apr 2001: Initial Version + +*/ + +#include "stdafx.h" +#include "coolscroll.h" +#include "userdefs.h" +#include "coolsb_internal.h" + +static TCHAR szPropStr[] = _T("CoolSBSubclassPtr"); + +LRESULT CALLBACK CoolSBWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); + +SCROLLWND* GetScrollWndFromHwnd(HWND hwnd) +{ + return (SCROLLWND *)GetProp(hwnd, szPropStr); +} + +SCROLLBAR* GetScrollBarFromHwnd(HWND hwnd, UINT nBar) +{ + SCROLLWND *sw = GetScrollWndFromHwnd(hwnd); + if (!sw) + return 0; + + if (nBar == SB_HORZ) + return &sw->sbarHorz; + if (nBar == SB_VERT) + return &sw->sbarVert; + return 0; +} + +BOOL WINAPI CoolSB_IsCoolScrollEnabled(HWND hwnd) +{ + if (GetScrollWndFromHwnd(hwnd)) + return TRUE; + return FALSE; +} + +BOOL GetScrollRect(SCROLLWND *sw, UINT nBar, HWND hwnd, RECT *rect); + +// +// Special support for USER32.DLL patching (using Detours library) +// The only place we call a real scrollbar API is in InitializeCoolSB, +// where we call EnableScrollbar. +// +// We HAVE to call the origial EnableScrollbar function, +// so we need to be able to set a pointer to this func when using +// using Detours (or any other LIB??) +// + +typedef BOOL(WINAPI *WPROC)(HWND, UINT, UINT); + +static WPROC pEnableScrollBar = 0; + +void WINAPI CoolSB_SetESBProc(WPROC proc) +{ + pEnableScrollBar = proc; +} + +static void RedrawNonClient(HWND hwnd, BOOL fFrameChanged) +{ + if (fFrameChanged == FALSE) { + /* + RECT rect; + HRGN hrgn1, hrgn2; + + SCROLLWND *sw = GetScrollWndFromHwnd(hwnd); + + GetScrollRect(sw, SB_HORZ, hwnd, &rect); + hrgn1 = CreateRectRgnIndirect(&rect); + + GetScrollRect(sw, SB_VERT, hwnd, &rect); + hrgn2 = CreateRectRgnIndirect(&rect); + + CombineRgn(hrgn1, hrgn2, hrgn1, RGN_OR); + + SendMessage(hwnd, WM_NCPAINT, (WPARAM)hrgn1, 0); + + DeleteObject(hrgn1); + DeleteObject(hrgn2);*/ + + SendMessage(hwnd, WM_NCPAINT, 1, 0); + } + else { + SetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE + | SWP_FRAMECHANGED | SWP_DRAWFRAME); + } +} + +// +// return the default minimum size of a scrollbar thumb +// +int WINAPI CoolSB_GetDefaultMinThumbSize(void) +{ + DWORD dwVersion = GetVersion(); + + // set the minimum thumb size for a scrollbar. This + // differs between NT4 and 2000, so need to check to see + // which platform we are running under + if (dwVersion < 0x80000000) // Windows NT/2000 + { + if (LOBYTE(LOWORD(dwVersion)) >= 5) + return MINTHUMBSIZE_2000; + return MINTHUMBSIZE_NT4; + } + + return MINTHUMBSIZE_NT4; +} + +static SCROLLINFO *GetScrollInfoFromHwnd(HWND hwnd, int fnBar) +{ + SCROLLBAR *sb = GetScrollBarFromHwnd(hwnd, fnBar); + + if (sb == 0) + return FALSE; + + if (fnBar == SB_HORZ) { + return &sb->scrollInfo; + } + else if (fnBar == SB_VERT) { + return &sb->scrollInfo; + } + else + return NULL; +} +// +// Initialize the cool scrollbars for a window by subclassing it +// and using the coolsb window procedure instead +// +BOOL WINAPI InitializeCoolSB(HWND hwnd) +{ + SCROLLWND *sw; + SCROLLINFO *si; + INITCOMMONCONTROLSEX ice; + TOOLINFO ti; + RECT rect; + DWORD dwCurStyle; + //BOOL fDisabled; + + if (pEnableScrollBar == 0) + pEnableScrollBar = EnableScrollBar; + + GetClientRect(hwnd, &rect); + + //if we have already initialized Cool Scrollbars for this window, + //then stop the user from doing it again + if (GetScrollWndFromHwnd(hwnd) != 0) { + return FALSE; + } + + //allocate a private scrollbar structure which we + //will use to keep track of the scrollbar data + sw = (SCROLLWND *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(SCROLLWND)); + + si = &sw->sbarHorz.scrollInfo; + si->cbSize = sizeof(SCROLLINFO); + si->fMask = SIF_ALL; + GetScrollInfo(hwnd, SB_HORZ, si); + + si = &sw->sbarVert.scrollInfo; + si->cbSize = sizeof(SCROLLINFO); + si->fMask = SIF_ALL; + GetScrollInfo(hwnd, SB_VERT, si); + + //check to see if the window has left-aligned scrollbars + if (GetWindowLongPtr(hwnd, GWL_EXSTYLE) & WS_EX_LEFTSCROLLBAR) + sw->fLeftScrollbar = TRUE; + else + sw->fLeftScrollbar = FALSE; + + dwCurStyle = GetWindowLongPtr(hwnd, GWL_STYLE); + + SetProp(hwnd, szPropStr, (HANDLE)sw); + + //try to enable the scrollbar arrows - if the return value is + //non-zero, then the scrollbars were previously disabled + //fDisabled = pEnableScrollBar(hwnd, SB_HORZ, ESB_ENABLE_BOTH); + + //scrollbars will automatically get enabled, even if + //they aren't to start with....sorry, but there isn't an + //easy alternative. + if (dwCurStyle & WS_HSCROLL) + sw->sbarHorz.fScrollFlags = CSBS_VISIBLE; + + if (dwCurStyle & WS_VSCROLL) + sw->sbarVert.fScrollFlags = CSBS_VISIBLE; + + //need to be able to distinguish between horizontal and vertical + //scrollbars in some instances + sw->sbarHorz.nBarType = SB_HORZ; + sw->sbarVert.nBarType = SB_VERT; + + sw->sbarHorz.fFlatScrollbar = CSBS_NORMAL; + sw->sbarVert.fFlatScrollbar = CSBS_NORMAL; + + //set the default arrow sizes for the scrollbars + sw->sbarHorz.nArrowLength = SYSTEM_METRIC; + sw->sbarHorz.nArrowWidth = SYSTEM_METRIC; + sw->sbarVert.nArrowLength = SYSTEM_METRIC; + sw->sbarVert.nArrowWidth = SYSTEM_METRIC; + + sw->bPreventStyleChange = FALSE; + + mir_subclassWindow(hwnd, CoolSBWndProc); + + CoolSB_SetMinThumbSize(hwnd, SB_BOTH, CoolSB_GetDefaultMinThumbSize()); + +#ifdef COOLSB_TOOLTIPS + ice.dwSize = sizeof(ice); + ice.dwICC = ICC_BAR_CLASSES; + InitCommonControlsEx(&ice); + + sw->hwndToolTip = CreateWindowEx(WS_EX_TOPMOST | WS_EX_TOOLWINDOW, TOOLTIPS_CLASS, _T(""), + WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, + CW_USEDEFAULT, CW_USEDEFAULT, + CW_USEDEFAULT, CW_USEDEFAULT, + hwnd, NULL, GetModuleHandle(0), + NULL); + + ti.cbSize = sizeof(TOOLINFO); + ti.uFlags = TTF_IDISHWND; + ti.hwnd = hwnd; + ti.uId = (UINT)hwnd; + ti.lpszText = LPSTR_TEXTCALLBACK; + ti.hinst = GetModuleHandle(0); + + SendMessage(sw->hwndToolTip, TTM_ADDTOOL, 0, (LPARAM)&ti); + +#else + + UNREFERENCED_PARAMETER(ice); + UNREFERENCED_PARAMETER(ti); + sw->hwndToolTip = 0; + +#endif + + //send the window a frame changed message to update the scrollbars + RedrawNonClient(hwnd, TRUE); + + return TRUE; +} + +BOOL WINAPI CoolSB_EnableScrollBar(HWND hwnd, int wSBflags, UINT wArrows) +{ + SCROLLBAR *sbar; + UINT oldstate; + BOOL bFailed = FALSE; + + if (!CoolSB_IsCoolScrollEnabled(hwnd)) + return EnableScrollBar(hwnd, wSBflags, wArrows); + + if ((wSBflags == SB_HORZ || wSBflags == SB_BOTH) && (sbar = GetScrollBarFromHwnd(hwnd, SB_HORZ))) { + oldstate = sbar->fScrollFlags; + + //clear any existing state, and OR in the disabled flags + sbar->fScrollFlags = (sbar->fScrollFlags & ~ESB_DISABLE_BOTH) | wArrows; + + if (oldstate == sbar->fScrollFlags) + bFailed = TRUE; + + } + + if ((wSBflags == SB_VERT || wSBflags == SB_BOTH) && (sbar = GetScrollBarFromHwnd(hwnd, SB_VERT))) { + oldstate = sbar->fScrollFlags; + + //clear any existing state, and OR in the disabled flags + sbar->fScrollFlags = (sbar->fScrollFlags & ~ESB_DISABLE_BOTH) | wArrows; + + if (oldstate == sbar->fScrollFlags) + bFailed = TRUE; + } + + return !bFailed; +} + +BOOL WINAPI CoolSB_GetScrollInfo(HWND hwnd, int fnBar, LPSCROLLINFO lpsi) +{ + BOOL copied = FALSE; + + if (!lpsi) + return FALSE; + + SCROLLINFO *mysi = GetScrollInfoFromHwnd(hwnd, fnBar); + if (!mysi) + return GetScrollInfo(hwnd, fnBar, lpsi); + + if (lpsi->fMask & SIF_PAGE) { + lpsi->nPage = mysi->nPage; + copied = TRUE; + } + + if (lpsi->fMask & SIF_POS) { + lpsi->nPos = mysi->nPos; + copied = TRUE; + } + + if (lpsi->fMask & SIF_TRACKPOS) { + lpsi->nTrackPos = mysi->nTrackPos; + copied = TRUE; + } + + if (lpsi->fMask & SIF_RANGE) { + lpsi->nMin = mysi->nMin; + lpsi->nMax = mysi->nMax; + copied = TRUE; + } + + return copied; +} + +int WINAPI CoolSB_GetScrollPos(HWND hwnd, int nBar) +{ + SCROLLINFO *mysi = GetScrollInfoFromHwnd(hwnd, nBar); + if (!mysi) + return GetScrollPos(hwnd, nBar); + + return mysi->nPos; +} + +BOOL WINAPI CoolSB_GetScrollRange(HWND hwnd, int nBar, LPINT lpMinPos, LPINT lpMaxPos) +{ + if (!lpMinPos || !lpMaxPos) + return FALSE; + + SCROLLINFO *mysi = GetScrollInfoFromHwnd(hwnd, nBar); + if (!mysi) + return GetScrollRange(hwnd, nBar, lpMinPos, lpMaxPos); + + *lpMinPos = mysi->nMin; + *lpMaxPos = mysi->nMax; + + return TRUE; +} + +int WINAPI CoolSB_SetScrollInfo(HWND hwnd, int fnBar, LPSCROLLINFO lpsi, BOOL fRedraw) +{ + BOOL fRecalcFrame = FALSE; + + if (!lpsi) + return FALSE; + + SCROLLINFO *mysi = GetScrollInfoFromHwnd(hwnd, fnBar); + if (!mysi) + return SetScrollInfo(hwnd, fnBar, lpsi, fRedraw); + + if (lpsi->fMask & SIF_RANGE) { + mysi->nMin = lpsi->nMin; + mysi->nMax = lpsi->nMax; + } + + //The nPage member must specify a value from 0 to nMax - nMin +1. + if (lpsi->fMask & SIF_PAGE) { + UINT t = (UINT)(mysi->nMax - mysi->nMin + 1); + mysi->nPage = min(lpsi->nPage, t); + } + + //The nPos member must specify a value between nMin and nMax - max(nPage - 1, 0). + if (lpsi->fMask & SIF_POS) { + mysi->nPos = max(lpsi->nPos, mysi->nMin); + mysi->nPos = min((UINT)mysi->nPos, mysi->nMax - max(mysi->nPage - 1, 0)); + } + + SCROLLBAR *sbar = GetScrollBarFromHwnd(hwnd, fnBar); + if (sbar == NULL) + return 0; + + if ((lpsi->fMask & SIF_DISABLENOSCROLL) || (sbar->fScrollFlags & CSBS_THUMBALWAYS)) { + if (!sbar->fScrollVisible) { + CoolSB_ShowScrollBar(hwnd, fnBar, TRUE); + fRecalcFrame = TRUE; + } + } + else { + if (mysi->nPage > (UINT)mysi->nMax + || mysi->nPage == (UINT)mysi->nMax && mysi->nMax == 0 + || mysi->nMax <= mysi->nMin) { + if (sbar->fScrollVisible) { + CoolSB_ShowScrollBar(hwnd, fnBar, FALSE); + fRecalcFrame = TRUE; + } + } + else { + if (!sbar->fScrollVisible) { + CoolSB_ShowScrollBar(hwnd, fnBar, TRUE); + fRecalcFrame = TRUE; + } + } + } + + if (fRedraw && !CoolSB_IsThumbTracking(hwnd)) + RedrawNonClient(hwnd, fRecalcFrame); + + return mysi->nPos; +} + + +int WINAPI CoolSB_SetScrollPos(HWND hwnd, int nBar, int nPos, BOOL fRedraw) +{ + int oldpos; + + SCROLLINFO *mysi = GetScrollInfoFromHwnd(hwnd, nBar); + if (!mysi) + return SetScrollPos(hwnd, nBar, nPos, fRedraw); + + //validate and set the scollbar position + oldpos = mysi->nPos; + mysi->nPos = max(nPos, mysi->nMin); + mysi->nPos = min((UINT)mysi->nPos, mysi->nMax - max(mysi->nPage - 1, 0)); + + if (fRedraw && !CoolSB_IsThumbTracking(hwnd)) + RedrawNonClient(hwnd, FALSE); + + return oldpos; +} + +int WINAPI CoolSB_SetScrollRange(HWND hwnd, int nBar, int nMinPos, int nMaxPos, BOOL fRedraw) +{ + SCROLLINFO *mysi = GetScrollInfoFromHwnd(hwnd, nBar); + if (!mysi) + return SetScrollRange(hwnd, nBar, nMinPos, nMaxPos, fRedraw); + + if (CoolSB_IsThumbTracking(hwnd)) + return mysi->nPos; + + //hide the scrollbar if nMin == nMax + //nMax-nMin must not be greater than MAXLONG + mysi->nMin = nMinPos; + mysi->nMax = nMaxPos; + + if (fRedraw) + RedrawNonClient(hwnd, FALSE); + + return TRUE; +} + +// +// Show or hide the specified scrollbars +// +BOOL WINAPI CoolSB_ShowScrollBar(HWND hwnd, int wBar, BOOL fShow) +{ + SCROLLBAR *sbar; + BOOL bFailed = FALSE; + DWORD dwStyle = GetWindowLongPtr(hwnd, GWL_STYLE); + + if (!CoolSB_IsCoolScrollEnabled(hwnd)) + return ShowScrollBar(hwnd, wBar, fShow); + + if ((wBar == SB_HORZ || wBar == SB_BOTH) && (sbar = GetScrollBarFromHwnd(hwnd, SB_HORZ))) { + sbar->fScrollFlags = sbar->fScrollFlags & ~CSBS_VISIBLE; + sbar->fScrollFlags |= fShow ? CSBS_VISIBLE : 0; + //bFailed = TRUE; + + if (fShow) SetWindowLongPtr(hwnd, GWL_STYLE, dwStyle | WS_HSCROLL); + else SetWindowLongPtr(hwnd, GWL_STYLE, dwStyle & ~WS_HSCROLL); + } + + if ((wBar == SB_VERT || wBar == SB_BOTH) && (sbar = GetScrollBarFromHwnd(hwnd, SB_VERT))) { + sbar->fScrollFlags = sbar->fScrollFlags & ~CSBS_VISIBLE; + sbar->fScrollFlags |= fShow ? CSBS_VISIBLE : 0; + //bFailed = TRUE; + + if (fShow) SetWindowLongPtr(hwnd, GWL_STYLE, dwStyle | WS_VSCROLL); + else SetWindowLongPtr(hwnd, GWL_STYLE, dwStyle & ~WS_VSCROLL); + } + + if (bFailed) { + return FALSE; + } + else { + //DWORD style = GetWindowLongPtr(hwnd, GWL_STYLE); + //style |= WS_VSCROLL; + + //if (s + //SetWindowLongPtr(hwnd, GWL_STYLE, style); + + SetWindowPos(hwnd, 0, 0, 0, 0, 0, + SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | + SWP_NOACTIVATE | SWP_FRAMECHANGED); + + return TRUE; + } +} + +// +// Remove cool scrollbars from the specified window. +// +HRESULT WINAPI UninitializeCoolSB(HWND hwnd) +{ + SCROLLWND *sw = GetScrollWndFromHwnd(hwnd); + if (!sw) + return E_FAIL; + + RemoveProp(hwnd, szPropStr); + //SetWindowLongPtr(hwnd, GWLP_USERDATA, 0); + + //finally, release the memory needed for the cool scrollbars + HeapFree(GetProcessHeap(), 0, sw); + + //Force WM_NCCALCSIZE and WM_NCPAINT so the original scrollbars can kick in + RedrawNonClient(hwnd, TRUE); + + return S_OK; +} + +#ifdef INCLUDE_BUTTONS + +// +// Cool scrollbar specific interface (BUTTON support) +// + +// +// Insert a button into the scrollbar area +// +// wSBflags - SB_HORZ / SB_VERT only +// uPos - position into which to insert. +// can be 0 to insert at the start, or -1 to insert +// at the end of previously inserted buttons +// + +BOOL WINAPI CoolSB_InsertButton(HWND hwnd, int wSBflags, UINT nPos, SCROLLBUT *psb) +{ + SCROLLBAR *sbar; + SCROLLBUT *sbut; + UINT i; + + if ( !psb) return FALSE; + + if ( !(sbar = GetScrollBarFromHwnd(hwnd, wSBflags))) + return FALSE; + + //check that we havn't reached the maximum allowed buttons yet + if (sbar->nButtons == MAX_COOLSB_BUTS) + return FALSE; + + //insert at end + if (nPos == -1) + { + sbut = &sbar->sbButtons[sbar->nButtons]; + } + //otherwise, need to make room + else if ((int)nPos < 0 || (int)nPos > (UINT)sbar->nButtons) + { + return FALSE; + } + else + { + //insert space for the button at the specified position + for (i = sbar->nButtons; i > nPos; i--) + { + sbar->sbButtons[i] = sbar->sbButtons[i-1]; + } + + sbut = &sbar->sbButtons[nPos]; + } + + //only set the button's properties if they are + //specified by the SCROLLBUT->fMask. + //Otherwise, use a default property value + + if (psb->fMask & SBBF_TYPE) + sbut->uButType = psb->uButType; + else + sbut->uButType = SBBT_PUSHBUTTON; + + if (psb->fMask & SBBF_STATE) + sbut->uState = psb->uState; + else + sbut->uState = 0; + + if (psb->fMask & SBBF_ID) + sbut->uCmdId = psb->uCmdId; + else + sbut->uCmdId = 0; + + if (psb->fMask & SBBF_SIZE) + sbut->nSize = psb->nSize; + else + sbut->nSize = -1; + + if (psb->fMask & SBBF_PLACEMENT) + sbut->uPlacement = psb->uPlacement; + else + sbut->uPlacement = SBBP_LEFT; + + if (psb->fMask & SBBF_BITMAP) + sbut->hBmp = psb->hBmp; + else + sbut->hBmp = 0; + + if (psb->fMask & SBBF_ENHMETAFILE) + sbut->hEmf = psb->hEmf; + else + sbut->hEmf = 0; + + if (psb->fMask & SBBF_CURSOR) + sbut->hCurs = psb->hCurs; + else + sbut->hCurs = 0; + + /* + We don't use the callback function anymore. The uButType + member must now specify SBBT_OWNERDRAW, and a WM_NOTIFY will + be sent when a button must be drawn + if ((psb->fMask & SBBF_OWNERDRAW) && ((psb->uButType & SBBT_MASK) == SBBT_OWNERDRAW)) + pDrawProc = psb->pDrawProc; + else + pDrawProc = 0;*/ + + sbar->nButtons++; + sbut->nSizeReserved = sbut->nSize; + + //MAKE SURE that any resizable buttons are only to the left / above + //a scrollbar. We don't support resize operations to the right of a scrollbar + if ((sbut->uButType & SBBM_RESIZABLE) && sbut->uPlacement == SBBP_RIGHT) + sbut->uButType &= ~SBBM_RESIZABLE; + + if (psb->fMask & SBBF_BUTMINMAX) + { + sbut->nMinSize = psb->nMinSize; + sbut->nMaxSize = psb->nMaxSize; + } + else + { + sbut->nMinSize = 0; + sbut->nMaxSize = -1; + } + + return TRUE; +} + +static SCROLLBUT *GetButtonFromId(SCROLLBAR *sbar, UINT uCmdId) +{ + int i; + for (i = 0; i < sbar->nButtons; i++) + { + if (sbar->sbButtons[i].uCmdId == uCmdId) + return &sbar->sbButtons[i]; + } + + return 0; +} + +// +// Modify the properties of the specified scrollbar button. +// wSBflags - SB_HORZ / SB_VERT only +// uItem - the command identifier specified when the button was created, +// or a non-negative position of the button, depending on if +// fByCmd is FALSE or TRUE, respectively +// +BOOL WINAPI CoolSB_ModifyButton (HWND hwnd, int wSBflags, UINT uItem, BOOL fByCmd, SCROLLBUT *psb) +{ + SCROLLBAR *sbar; + SCROLLBUT *sbut; + + if ( !psb) return FALSE; + + //find if this window is CoolScroll enabled + if ( !(sbar = GetScrollBarFromHwnd(hwnd, wSBflags))) + return FALSE; + + //find the button to modify, depending on if we + //are modifying by position or command id + if (fByCmd == FALSE) + { + //button from position + if ((int)uItem < 0 || (int)uItem >= (UINT)sbar->nButtons) + return FALSE; + else + sbut = &sbar->sbButtons[uItem]; + } + else if (fByCmd == TRUE) + { + //button from command identifier + if ( !(sbut = GetButtonFromId(sbar, uItem))) + return FALSE; + } + + if (psb->fMask & SBBF_TYPE) sbut->uButType = psb->uButType; + if (psb->fMask & SBBF_STATE) sbut->uState = psb->uState; + if (psb->fMask & SBBF_ID) sbut->uCmdId = psb->uCmdId; + if (psb->fMask & SBBF_SIZE) sbut->nSize = psb->nSize; + if (psb->fMask & SBBF_PLACEMENT) sbut->uPlacement = psb->uPlacement; + if (psb->fMask & SBBF_BITMAP) sbut->hBmp = psb->hBmp; + if (psb->fMask & SBBF_ENHMETAFILE) sbut->hEmf = psb->hEmf; + if (psb->fMask & SBBF_CURSOR) sbut->hCurs = psb->hCurs; + + if (psb->fMask & SBBF_BUTMINMAX) + { + sbut->nMinSize = psb->nMinSize; + sbut->nMaxSize = psb->nMaxSize; + } + + return TRUE; +} + +BOOL WINAPI CoolSB_RemoveButton(HWND hwnd, int wSBflags, UINT uItem, BOOL fByCmd) +{ + int i; + SCROLLBAR *sbar; + + //find if this window is CoolScroll enabled + if ( !(sbar = GetScrollBarFromHwnd(hwnd, wSBflags))) + return FALSE; + + //find the button to modify, depending on if we + //are modifying by position or command id + if (fByCmd == FALSE && ((int)uItem < 0 || (int)uItem >= (UINT)sbar->nButtons)) + { + return FALSE; + } + else if (fByCmd == TRUE) + { + //find the button with the specified command id + for (i = 0; i < sbar->nButtons; i++) + { + if (sbar->sbButtons[i].uCmdId == uItem) + { + //change the id to an index + uItem = i; + break; + } + } + + //if we failed to find the button... + if (i == sbar->nButtons) return FALSE; + } + + //remove the button! + for (i = uItem; i < sbar->nButtons - 1; i++) + { + sbar->sbButtons[i] = sbar->sbButtons[i+1]; + } + + sbar->nButtons--; + + RedrawNonClient(hwnd, TRUE); + + return TRUE; +} + +// +// fill in the supplied SCROLLBUT structure +// +BOOL WINAPI CoolSB_GetButton(HWND hwnd, int wSBflags, UINT uItem, BOOL fByCmd, SCROLLBUT *psb) +{ + SCROLLBAR *sbar; + SCROLLBUT *sbut; + + if ( !psb) return FALSE; + + //find if this window is CoolScroll enabled + if ( !(sbar = GetScrollBarFromHwnd(hwnd, wSBflags))) + return FALSE; + + //find the button to modify, depending on if we + //are modifying by position or command id + if (fByCmd == FALSE) + { + //button from position + if ((int)uItem < 0 || (int)uItem >= (UINT)sbar->nButtons) + return FALSE; + else + sbut = &sbar->sbButtons[uItem]; + } + else if (fByCmd == TRUE) + { + //button from command identifier + if ( !(sbut = GetButtonFromId(sbar, uItem))) + return FALSE; + } + + //copy them across + *psb = *sbut; + + return FALSE; +} + +#else + +BOOL WINAPI CoolSB_InsertButton(HWND, int, UINT, SCROLLBUT*) { return FALSE; } +BOOL WINAPI CoolSB_ModifyButton(HWND, int, UINT, BOOL, SCROLLBUT*) { return FALSE; } +BOOL WINAPI CoolSB_RemoveButton(HWND, int, UINT, BOOL) { return FALSE; } +BOOL WINAPI CoolSB_GetButton(HWND, int, UINT, BOOL, SCROLLBUT*) { return FALSE; } + +#endif //INCLUDE_BUTTONS + +// +// Set the size of the scrollbars +// +BOOL WINAPI CoolSB_SetSize(HWND hwnd, int wBar, int nLength, int nWidth) +{ + SCROLLBAR *sbar; + + if (nLength == 0 || nWidth == 0) + return FALSE; + + if (nLength < -8 || nWidth < -8) + return FALSE; + + if (nLength > 256 || nWidth > 256) + return FALSE; + + if (!GetScrollWndFromHwnd(hwnd)) + return FALSE; + + if ((wBar == SB_HORZ || wBar == SB_BOTH) && (sbar = GetScrollBarFromHwnd(hwnd, SB_HORZ))) { + sbar->nArrowLength = nLength; + sbar->nArrowWidth = nWidth; + } + + if ((wBar == SB_VERT || wBar == SB_BOTH) && (sbar = GetScrollBarFromHwnd(hwnd, SB_VERT))) { + sbar->nArrowLength = nLength; + sbar->nArrowWidth = nWidth; + } + + RedrawNonClient(hwnd, TRUE); + return TRUE; +} + +// +// Alter the display mode of the scrollbars +// wBar - SB_HORZ / SB_VERT / SB_BOTH +// nStyle - CSBF_NORMAL / CSBF_FLAT / CSBF_HOTTRACKED +// +BOOL WINAPI CoolSB_SetStyle(HWND hwnd, int wBar, UINT nStyle) +{ + SCROLLBAR *sbar; + + if (!GetScrollWndFromHwnd(hwnd)) + return FALSE; + + if ((wBar == SB_HORZ || wBar == SB_BOTH) && (sbar = GetScrollBarFromHwnd(hwnd, SB_HORZ))) + sbar->fFlatScrollbar = nStyle; + + if ((wBar == SB_VERT || wBar == SB_BOTH) && (sbar = GetScrollBarFromHwnd(hwnd, SB_VERT))) + sbar->fFlatScrollbar = nStyle; + + RedrawNonClient(hwnd, FALSE); + return TRUE; +} + +// +// Set if the thumb is always visible, even if there is no data to +// scroll. Setting this keeps the scrollbar enabled, but the thumb +// covers the whole area +// +BOOL WINAPI CoolSB_SetThumbAlways(HWND hwnd, int wBar, BOOL fThumbAlways) +{ + SCROLLBAR *sbar; + + if (!GetScrollWndFromHwnd(hwnd)) + return FALSE; + + if ((wBar == SB_HORZ || wBar == SB_BOTH) && (sbar = GetScrollBarFromHwnd(hwnd, SB_HORZ))) { + if (fThumbAlways) + sbar->fScrollFlags |= CSBS_THUMBALWAYS; + else + sbar->fScrollFlags &= ~CSBS_THUMBALWAYS; + } + + if ((wBar == SB_VERT || wBar == SB_BOTH) && (sbar = GetScrollBarFromHwnd(hwnd, SB_VERT))) { + if (fThumbAlways) + sbar->fScrollFlags |= CSBS_THUMBALWAYS; + else + sbar->fScrollFlags &= ~CSBS_THUMBALWAYS; + } + + RedrawNonClient(hwnd, FALSE); + + return TRUE; +} + +// +// Set the minimum size, in pixels, that the thumb box will shrink to. +// +BOOL WINAPI CoolSB_SetMinThumbSize(HWND hwnd, UINT wBar, UINT size) +{ + SCROLLBAR *sbar; + + if (!GetScrollWndFromHwnd(hwnd)) + return FALSE; + + if (size == -1) + size = CoolSB_GetDefaultMinThumbSize(); + + if ((wBar == SB_HORZ || wBar == SB_BOTH) && (sbar = GetScrollBarFromHwnd(hwnd, SB_HORZ))) + sbar->nMinThumbSize = size; + + if ((wBar == SB_VERT || wBar == SB_BOTH) && (sbar = GetScrollBarFromHwnd(hwnd, SB_VERT))) + sbar->nMinThumbSize = size; + + return TRUE; +} diff --git a/plugins/Clist_nicer/src/coolsblib.h b/plugins/Clist_nicer/src/coolsblib.h new file mode 100644 index 0000000000..d9b1c711f3 --- /dev/null +++ b/plugins/Clist_nicer/src/coolsblib.h @@ -0,0 +1,41 @@ +#ifndef _SUPERSCROLL_INCLUDED +#define _SUPERSCROLL_INCLUDED + +#ifdef __cplusplus +extern "C"{ +#endif + +#include + + +#ifdef __cplusplus +} +#endif + +#endif + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/Clist_nicer/src/coolscroll.cpp b/plugins/Clist_nicer/src/coolscroll.cpp new file mode 100644 index 0000000000..1e8f5b98ff --- /dev/null +++ b/plugins/Clist_nicer/src/coolscroll.cpp @@ -0,0 +1,3060 @@ +/* + Cool Scrollbar Library Version 1.2 + + Module: coolscroll.c + Copyright (c) J Brown 2001 + + This code is freeware, however, you may not publish + this code elsewhere or charge any money for it. This code + is supplied as-is. I make no guarantees about the suitability + of this code - use at your own risk. + + It would be nice if you credited me, in the event + that you use this code in a product. + + VERSION HISTORY: + + V1.2: TreeView problem fixed by Diego Tartara + Small problem in thumbsize calculation also fixed (thanks Diego!) + + V1.1: Added support for Right-left windows + Changed calling convention of APIs to WINAPI (__stdcall) + Completely standalone (no need for c-runtime) + Now supports ALL windows with appropriate USER32.DLL patching + (you provide!!) + + V1.0: Apr 2001: Initial Version + + IMPORTANT: + This whole library is based around code for a horizontal scrollbar. + All "vertical" scrollbar drawing / mouse interaction uses the + horizontal scrollbar functions, but uses a trick to convert the vertical + scrollbar coordinates into horizontal equivelants. When I started this project, + I quickly realised that the code for horz/vert bars was IDENTICAL, apart + from the fact that horizontal code uses left/right coords, and vertical code + uses top/bottom coords. On entry to a "vertical" drawing function, for example, + the coordinates are "rotated" before the horizontal function is called, and + then rotated back once the function has completed. When something needs to + be drawn, the coords are converted back again before drawing. + + This trick greatly reduces the amount of code required, and makes + maintanence much simpler. This way, only one function is needed to draw + a scrollbar, but this can be used for both horizontal and vertical bars + with careful thought. +*/ + +#include "stdafx.h" +#include "coolscroll.h" +#include "userdefs.h" +#include "coolsb_internal.h" + +//define some values if the new version of common controls +//is not available. +#ifndef NM_CUSTOMDRAW +#define NM_CUSTOMDRAW (NM_FIRST-12) +#define CDRF_DODEFAULT 0x0000 +#define CDRF_SKIPDEFAULT 0x0004 +#define CDDS_PREPAINT 0x0001 +#define CDDS_POSTPAINT 0x0002 +#endif + +// +// Special thumb-tracking variables +// +// +static UINT uCurrentScrollbar = COOLSB_NONE; //SB_HORZ / SB_VERT +static UINT uCurrentScrollPortion = HTSCROLL_NONE; +static UINT uCurrentButton = 0; + +static RECT rcThumbBounds; //area that the scroll thumb can travel in +static int nThumbSize; //(pixels) +static int nThumbPos; //(pixels) +static int nThumbMouseOffset; //(pixels) +static int nLastPos = -1; //(scrollbar units) +static int nThumbPos0; //(pixels) initial thumb position + +// +// Temporary state used to auto-generate timer messages +// +static UINT_PTR uMouseOverId = 0; +static UINT uMouseOverScrollbar = COOLSB_NONE; +static UINT uHitTestPortion = HTSCROLL_NONE; +static UINT uLastHitTestPortion = HTSCROLL_NONE; +static RECT MouseOverRect; + +static UINT uScrollTimerMsg = 0; +static UINT uScrollTimerPortion = HTSCROLL_NONE; +static UINT_PTR uScrollTimerId = 0; +static HWND hwndCurCoolSB = 0; + +extern int CustomDrawScrollBars(NMCSBCUSTOMDRAW *nmcsbcd); + +LRESULT CALLBACK CoolSBWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); + +// +// Provide this so there are NO dependencies on CRT +// +static void CoolSB_ZeroMemory(void *ptr, DWORD bytes) +{ + BYTE *bptr = (BYTE *)ptr; + + while(bytes--) *bptr++ = 0; +} + +BOOL WINAPI CoolSB_IsThumbTracking(HWND hwnd) +{ + SCROLLWND *sw; + + if ((sw = GetScrollWndFromHwnd(hwnd)) == NULL) + return FALSE; + else + return sw->fThumbTracking; +} + +// +// swap the rectangle's x coords with its y coords +// +static void __stdcall RotateRect(RECT *rect) +{ + int temp; + temp = rect->left; + rect->left = rect->top; + rect->top = temp; + + temp = rect->right; + rect->right = rect->bottom; + rect->bottom = temp; +} + +// +// swap the coords if the scrollbar is a SB_VERT +// +static void __stdcall RotateRect0(SCROLLBAR *sb, RECT *rect) +{ + if (sb->nBarType == SB_VERT) + RotateRect(rect); +} + +// +// Calculate if the SCROLLINFO members produce +// an enabled or disabled scrollbar +// +static BOOL IsScrollInfoActive(SCROLLINFO *si) +{ + if ((si->nPage > (UINT)si->nMax + || si->nMax <= si->nMin || si->nMax == 0)) + return FALSE; + else + return TRUE; +} + +// +// Return if the specified scrollbar is enabled or not +// +static BOOL IsScrollbarActive(SCROLLBAR *sb) +{ + SCROLLINFO *si = &sb->scrollInfo; + if (((sb->fScrollFlags & ESB_DISABLE_BOTH) == ESB_DISABLE_BOTH) || + !(sb->fScrollFlags & CSBS_THUMBALWAYS) && !IsScrollInfoActive(si)) + return FALSE; + else + return TRUE; +} + +// +// Draw a standard scrollbar arrow +// +static int DrawScrollArrow(SCROLLBAR *sbar, HDC hdc, RECT *rect, UINT arrow, BOOL fMouseDown, BOOL fMouseOver) +{ + UINT ret; + UINT flags = arrow; + + //HACKY bit so this routine can be called by vertical and horizontal code + if (sbar->nBarType == SB_VERT) + { + if (flags & DFCS_SCROLLLEFT) flags = flags & ~DFCS_SCROLLLEFT | DFCS_SCROLLUP; + if (flags & DFCS_SCROLLRIGHT) flags = flags & ~DFCS_SCROLLRIGHT | DFCS_SCROLLDOWN; + } + + if (fMouseDown) flags |= (DFCS_FLAT | DFCS_PUSHED); + +#ifdef FLAT_SCROLLBARS + if (sbar->fFlatScrollbar != CSBS_NORMAL) + { + HDC hdcmem1, hdcmem2; + HBITMAP hbm1, oldbm1; + HBITMAP hbm2, oldbm2; + RECT rc; + int width, height; + + rc = *rect; + width = rc.right-rc.left; + height = rc.bottom-rc.top; + SetRect(&rc, 0, 0, width, height); + + //MONOCHROME bitmap to convert the arrow to black/white mask + hdcmem1 = CreateCompatibleDC(hdc); + hbm1 = CreateBitmap(width, height, 1, 1, NULL); + UnrealizeObject(hbm1); + oldbm1 = reinterpret_cast(SelectObject(hdcmem1, hbm1)); + + + //NORMAL bitmap to draw the arrow into + hdcmem2 = CreateCompatibleDC(hdc); + hbm2 = CreateCompatibleBitmap(hdc, width, height); + UnrealizeObject(hbm2); + oldbm2 = reinterpret_cast(SelectObject(hdcmem2, hbm2)); + + + flags = flags & ~DFCS_PUSHED | DFCS_FLAT; //just in case + DrawFrameControl(hdcmem2, &rc, DFC_SCROLL, flags); + + +#ifndef HOT_TRACKING + if (fMouseDown) + { + //uncomment these to make the cool scrollbars + //look like the common controls flat scrollbars + //fMouseDown = FALSE; + //fMouseOver = TRUE; + } +#endif + //draw a flat monochrome version of a scrollbar arrow (dark) + if (fMouseDown) + { + SetBkColor(hdcmem2, GetSysColor(COLOR_BTNTEXT)); + BitBlt(hdcmem1, 0, 0, width, height, hdcmem2, 0, 0, SRCCOPY); + SetBkColor(hdc, 0x00ffffff); + SetTextColor(hdc, GetSysColor(COLOR_3DDKSHADOW)); + BitBlt(hdc, rect->left, rect->top, width, height, hdcmem1, 0, 0, SRCCOPY); + } + //draw a flat monochrome version of a scrollbar arrow (grey) + else if (fMouseOver) + { + SetBkColor(hdcmem2, GetSysColor(COLOR_BTNTEXT)); + FillRect(hdcmem1, &rc, reinterpret_cast(GetStockObject(WHITE_BRUSH))); + BitBlt(hdcmem1, 0, 0, width, height, hdcmem2, 0, 0, SRCINVERT); + + SetBkColor(hdc, GetSysColor(COLOR_3DSHADOW)); + SetTextColor(hdc, 0x00ffffff); + BitBlt(hdc, rect->left, rect->top, width, height, hdcmem1, 0, 0, SRCCOPY); + } + //draw the arrow normally + else + { + BitBlt(hdc, rect->left, rect->top, width, height, hdcmem2, 0, 0, SRCCOPY); + } + + SelectObject(hdcmem1, oldbm1); + SelectObject(hdcmem2, oldbm2); + DeleteObject(hbm1); + DeleteObject(hbm2); + DeleteDC(hdcmem1); + DeleteDC(hdcmem2); + + ret = 0; + } + else +#endif + ret = DrawFrameControl(hdc, rect, DFC_SCROLL, flags); + + return ret; +} + +// +// Return the size in pixels for the specified scrollbar metric, +// for the specified scrollbar +// +static int GetScrollMetric(SCROLLBAR *sbar, int metric) +{ + if (sbar->nBarType == SB_HORZ) + { + if (metric == SM_CXHORZSB) + { + if (sbar->nArrowLength < 0) + return -sbar->nArrowLength * GetSystemMetrics(SM_CXHSCROLL); + else + return sbar->nArrowLength; + } + else + { + if (sbar->nArrowWidth < 0) + return -sbar->nArrowWidth * GetSystemMetrics(SM_CYHSCROLL); + else + return sbar->nArrowWidth; + } + } + else if (sbar->nBarType == SB_VERT) + { + if (metric == SM_CYVERTSB) + { + if (sbar->nArrowLength < 0) + return -sbar->nArrowLength * GetSystemMetrics(SM_CYVSCROLL); + else + return sbar->nArrowLength; + } + else + { + if (sbar->nArrowWidth < 0) + return -sbar->nArrowWidth * GetSystemMetrics(SM_CXVSCROLL); + else + return sbar->nArrowWidth; + } + } + + return 0; +} + +// +// +// +static COLORREF GetSBForeColor(void) +{ + COLORREF c1 = GetSysColor(COLOR_3DHILIGHT); + COLORREF c2 = GetSysColor(COLOR_WINDOW); + + if (c1 != 0xffffff && c1 == c2) + { + return GetSysColor(COLOR_BTNFACE); + } + else + { + return GetSysColor(COLOR_3DHILIGHT); + } +} + +static COLORREF GetSBBackColor(void) +{ + return GetSysColor(COLOR_SCROLLBAR); +} + +// +// Paint a checkered rectangle, with each alternate +// pixel being assigned a different colour +// +static void DrawCheckedRect(HDC hdc, RECT *rect, COLORREF fg, COLORREF bg) +{ + static WORD wCheckPat[8] = + { + 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa, 0x5555 + }; + + HBITMAP hbmp; + HBRUSH hbr, hbrold; + COLORREF fgold, bgold; + + hbmp = CreateBitmap(8, 8, 1, 1, wCheckPat); + hbr = CreatePatternBrush(hbmp); + + UnrealizeObject(hbr); + SetBrushOrgEx(hdc, rect->left, rect->top, 0); + + hbrold = (HBRUSH)SelectObject(hdc, hbr); + + fgold = SetTextColor(hdc, fg); + bgold = SetBkColor(hdc, bg); + + PatBlt(hdc, rect->left, rect->top, + rect->right - rect->left, + rect->bottom - rect->top, + PATCOPY); + + SetBkColor(hdc, bgold); + SetTextColor(hdc, fgold); + + SelectObject(hdc, hbrold); + DeleteObject(hbr); + DeleteObject(hbmp); +} + +// +// Fill the specifed rectangle using a solid colour +// +static void PaintRect(HDC hdc, RECT *rect, COLORREF color) +{ + COLORREF oldcol = SetBkColor(hdc, color); + ExtTextOutA(hdc, 0, 0, ETO_OPAQUE, rect, "", 0, NULL); + SetBkColor(hdc, oldcol); +} + +// +// Draw a simple blank scrollbar push-button. Can be used +// to draw a push button, or the scrollbar thumb +// drawflag - could set to BF_FLAT to make flat scrollbars +// +void DrawBlankButton(HDC hdc, const RECT *rect, UINT drawflag) +{ + RECT rc = *rect; + +#ifndef FLAT_SCROLLBARS + drawflag &= ~BF_FLAT; +#endif + + DrawEdge(hdc, &rc, EDGE_RAISED, BF_RECT | drawflag | BF_ADJUST); + FillRect(hdc, &rc, GetSysColorBrush(COLOR_BTNFACE)); +} + +// +// Send a WM_VSCROLL or WM_HSCROLL message +// +static void SendScrollMessage(HWND hwnd, UINT scrMsg, UINT scrId, UINT pos) +{ + SendMessage(hwnd, scrMsg, MAKEWPARAM(scrId, pos), 0); +} + +// +// Calculate the screen coordinates of the area taken by +// the horizontal scrollbar. Take into account the size +// of the window borders +// +static BOOL GetHScrollRect(SCROLLWND *sw, HWND hwnd, RECT *rect) +{ + GetWindowRect(hwnd, rect); + + if (sw->fLeftScrollbar) + { + rect->left += sw->cxLeftEdge + (sw->sbarVert.fScrollVisible ? + GetScrollMetric(&sw->sbarVert, SM_CXVERTSB) : 0); + rect->right -= sw->cxRightEdge; + } + else + { + rect->left += sw->cxLeftEdge; //left window edge + + rect->right -= sw->cxRightEdge + //right window edge + (sw->sbarVert.fScrollVisible ? + GetScrollMetric(&sw->sbarVert, SM_CXVERTSB) : 0); + } + + rect->bottom -= sw->cyBottomEdge; //bottom window edge + + rect->top = rect->bottom - + (sw->sbarHorz.fScrollVisible ? + GetScrollMetric(&sw->sbarHorz, SM_CYHORZSB) : 0); + + return TRUE; +} + +// +// Calculate the screen coordinates of the area taken by the +// vertical scrollbar +// +static BOOL GetVScrollRect(SCROLLWND *sw, HWND hwnd, RECT *rect) +{ + GetWindowRect(hwnd, rect); + rect->top += sw->cyTopEdge; //top window edge + + rect->bottom -= sw->cyBottomEdge + + (sw->sbarHorz.fScrollVisible ? //bottom window edge + GetScrollMetric(&sw->sbarHorz, SM_CYHORZSB) : 0); + + if (sw->fLeftScrollbar) + { + rect->left += sw->cxLeftEdge; + rect->right = rect->left + (sw->sbarVert.fScrollVisible ? + GetScrollMetric(&sw->sbarVert, SM_CXVERTSB) : 0); + } + else + { + rect->right -= sw->cxRightEdge; + rect->left = rect->right - (sw->sbarVert.fScrollVisible ? + GetScrollMetric(&sw->sbarVert, SM_CXVERTSB) : 0); + } + + return TRUE; +} + +// Depending on what type of scrollbar nBar refers to, call the +// appropriate Get?ScrollRect function +// +BOOL GetScrollRect(SCROLLWND *sw, UINT nBar, HWND hwnd, RECT *rect) +{ + if (nBar == SB_HORZ) + return GetHScrollRect(sw, hwnd, rect); + else if (nBar == SB_VERT) + return GetVScrollRect(sw, hwnd, rect); + else + return FALSE; +} + +// +// This code is a prime candidate for splitting out into a separate +// file at some stage +// +#ifdef INCLUDE_BUTTONS + +// +// Calculate the size in pixels of the specified button +// +static int GetSingleButSize(SCROLLBAR *sbar, SCROLLBUT *sbut) +{ + //multiple of the system button size + //or a specific button size + if (sbut->nSize < 0) + { + if (sbar->nBarType == SB_HORZ) + return -sbut->nSize * GetSystemMetrics(SM_CXHSCROLL); + else + return -sbut->nSize * GetSystemMetrics(SM_CYVSCROLL); + } + else + return sbut->nSize; +} + +// +// Find the size in pixels of all the inserted buttons, +// either before or after the specified scrollbar +// +static int GetButtonSize(SCROLLBAR *sbar, HWND hwnd, UINT uBeforeAfter) +{ + int i; + int nPixels = 0; + + SCROLLBUT *sbut = sbar->sbButtons; + + for (i = 0; i < sbar->nButtons; i++) + { + //only consider those buttons on the same side as nTopBottom says + if (sbut[i].uPlacement == uBeforeAfter) + { + nPixels += GetSingleButSize(sbar, &sbut[i]); + } + } + + return nPixels; +} +#endif //INCLUDE_BUTTONS + +// +// Work out the scrollbar width/height for either type of scrollbar (SB_HORZ/SB_VERT) +// rect - coords of the scrollbar. +// store results into *thumbsize and *thumbpos +// +static int CalcThumbSize(SCROLLBAR *sbar, const RECT *rect, int *pthumbsize, int *pthumbpos) +{ + int scrollsize; //total size of the scrollbar including arrow buttons + int workingsize; //working area (where the thumb can slide) + int siMaxMin; + int butsize; + int startcoord; + int thumbpos = 0, thumbsize = 0; + + static int count=0; + + //work out the width (for a horizontal) or the height (for a vertical) + //of a standard scrollbar button + butsize = GetScrollMetric(sbar, SM_SCROLL_LENGTH); + + scrollsize = rect->right - rect->left; + startcoord = rect->left; + + SCROLLINFO *si = &sbar->scrollInfo; + siMaxMin = si->nMax - si->nMin + 1; + workingsize = scrollsize - butsize * 2; + + // + // Work out the scrollbar thumb SIZE + // + if (si->nPage == 0) + { + thumbsize = butsize; + } + else if (siMaxMin > 0) + { + thumbsize = MulDiv(si->nPage, workingsize, siMaxMin); + + if (thumbsize < sbar->nMinThumbSize) + thumbsize = sbar->nMinThumbSize; + } + + // + // Work out the scrollbar thumb position + // + if (siMaxMin > 0) + { + int pagesize = max(1, si->nPage); + thumbpos = MulDiv(si->nPos - si->nMin, workingsize-thumbsize, siMaxMin - pagesize); + + if (thumbpos < 0) + thumbpos = 0; + + if (thumbpos >= workingsize-thumbsize) + thumbpos = workingsize-thumbsize; + } + + thumbpos += startcoord + butsize; + + *pthumbpos = thumbpos; + *pthumbsize = thumbsize; + + return 1; +} + +// +// return a hit-test value for whatever part of the scrollbar x,y is located in +// rect, x, y: SCREEN coordinates +// the rectangle must not include space for any inserted buttons +// (i.e, JUST the scrollbar area) +// +static UINT GetHorzScrollPortion(SCROLLBAR *sbar, const RECT *rect, int x, int y) +{ + int thumbwidth, thumbpos; + int butwidth = GetScrollMetric(sbar, SM_SCROLL_LENGTH); + int scrollwidth = rect->right-rect->left; + int workingwidth = scrollwidth - butwidth*2; + + if (y < rect->top || y >= rect->bottom) + return HTSCROLL_NONE; + + CalcThumbSize(sbar, rect, &thumbwidth, &thumbpos); + + //if we have had to scale the buttons to fit in the rect, + //then adjust the button width accordingly + if (scrollwidth <= butwidth * 2) + { + butwidth = scrollwidth / 2; + } + + //check for left button click + if (x >= rect->left && x < rect->left + butwidth) + { + return HTSCROLL_LEFT; + } + //check for right button click + else if (x >= rect->right-butwidth && x < rect->right) + { + return HTSCROLL_RIGHT; + } + + //if the thumb is too big to fit (i.e. it isn't visible) + //then return a NULL scrollbar area + if (thumbwidth >= workingwidth) + return HTSCROLL_NONE; + + //check for point in the thumbbar + if (x >= thumbpos && x < thumbpos+thumbwidth) + { + return HTSCROLL_THUMB; + } + //check for left margin + else if (x >= rect->left+butwidth && x < thumbpos) + { + return HTSCROLL_PAGELEFT; + } + else if (x >= thumbpos+thumbwidth && x < rect->right-butwidth) + { + return HTSCROLL_PAGERIGHT; + } + + return HTSCROLL_NONE; +} + +// +// For vertical scrollbars, rotate all coordinates by -90 degrees +// so that we can use the horizontal version of this function +// +static UINT GetVertScrollPortion(SCROLLBAR *sb, RECT *rect, int x, int y) +{ + UINT r; + + RotateRect(rect); + r = GetHorzScrollPortion(sb, rect, y, x); + RotateRect(rect); + return r; +} + +// +// CUSTOM DRAW support +// +static LRESULT PostCustomPrePostPaint(HWND hwnd, HDC hdc, SCROLLBAR *sb, UINT dwStage) +{ +#ifdef CUSTOM_DRAW + NMCSBCUSTOMDRAW nmcd; + + CoolSB_ZeroMemory(&nmcd, sizeof nmcd); + nmcd.hdr.hwndFrom = hwnd; + nmcd.hdr.idFrom = GetWindowLongPtr(hwnd, GWLP_ID); + nmcd.hdr.code = NM_COOLSB_CUSTOMDRAW; + nmcd.nBar = sb->nBarType; + nmcd.dwDrawStage = dwStage; + nmcd.hdc = hdc; + + hwnd = GetParent(hwnd); + return CustomDrawScrollBars(&nmcd); +#else + return 0; +#endif +} + +static LRESULT PostCustomDrawNotify(HWND hwnd, HDC hdc, UINT nBar, RECT *prect, UINT nItem, BOOL fMouseDown, BOOL fMouseOver, BOOL fInactive) +{ +#ifdef CUSTOM_DRAW + NMCSBCUSTOMDRAW nmcd; + + //fill in the standard header + nmcd.hdr.hwndFrom = hwnd; + nmcd.hdr.idFrom = GetWindowLongPtr(hwnd, GWLP_ID); + nmcd.hdr.code = NM_COOLSB_CUSTOMDRAW; + + nmcd.dwDrawStage = CDDS_ITEMPREPAINT; + nmcd.nBar = nBar; + nmcd.rect = *prect; + nmcd.uItem = nItem; + nmcd.hdc = hdc; + + if (fMouseDown) + nmcd.uState = CDIS_SELECTED; + else if (fMouseOver) + nmcd.uState = CDIS_HOT; + else if (fInactive) + nmcd.uState = CDIS_DISABLED; + else + nmcd.uState = CDIS_DEFAULT; + + hwnd = GetParent(hwnd); + return CustomDrawScrollBars(&nmcd); +#else + return 0; +#endif +} + +// Depending on if we are supporting custom draw, either define +// a macro to the function name, or to nothing at all. If custom draw +// is turned off, then we can save ALOT of code space by binning all +// calls to the custom draw support. + +/* +#ifdef CUSTOM_DRAW +#define PostCustomDrawNotify PostCustomDrawNotify0 +#define PostCustomPrePostPaint PostCustomPrePostPaint0 +#else +#define PostCustomDrawNotify 1 ? (void)0 : PostCustomDrawNotify0 +#define PostCustomPrePostPaint 1 ? (void)0 : PostCustomPrePostPaint0 +#endif +*/ + +static LRESULT PostMouseNotify0(HWND hwnd, UINT nBar, RECT *prect, UINT nCmdId, POINT pt) +{ +#ifdef NOTIFY_MOUSE + NMCOOLBUTMSG nmcb; + + //fill in the standard header + nmcb.hdr.hwndFrom = hwnd; + nmcb.hdr.idFrom = GetWindowLongPtr(hwnd, GWLP_ID); + nmcb.hdr.code = NM_CLICK; + + nmcb.nBar = nBar; + nmcb.uCmdId = nCmdId; + nmcb.uState = 0; + nmcb.rect = *prect; + nmcb.pt = pt; + + hwnd = GetParent(hwnd); + return SendMessage(hwnd, WM_NOTIFY, nmcb.hdr.idFrom, (LPARAM)&nmcb); +#else + return 0; +#endif +} + +#ifdef NOTIFY_MOUSE +#define PostMouseNotify PostMouseNotify0 +#else +#define PostMouseNotify 1 ? (void)0 : PostMouseNotify0 +#endif + + + +// +// Draw a complete HORIZONTAL scrollbar in the given rectangle +// Don't draw any inserted buttons in this procedure +// +// uDrawFlags - hittest code, to say if to draw the +// specified portion in an active state or not. +// +// +static LRESULT NCDrawHScrollbar(SCROLLBAR *sb, HWND hwnd, HDC hdc, const RECT *rect, UINT uDrawFlags) +{ + SCROLLINFO *si; + RECT ctrl, thumb; + RECT sbm; + int butwidth = GetScrollMetric(sb, SM_SCROLL_LENGTH); + int scrollwidth = rect->right-rect->left; + int workingwidth = scrollwidth - butwidth*2; + int thumbwidth = 0, thumbpos = 0; + int siMaxMin; + + BOOL fCustomDraw = 0; + + BOOL fMouseDownL = 0, fMouseOverL = 0, fBarHot = 0; + BOOL fMouseDownR = 0, fMouseOverR = 0; + + COLORREF crCheck1 = GetSBForeColor(); + COLORREF crCheck2 = GetSBBackColor(); + COLORREF crInverse1 = InvertCOLORREF(crCheck1); + COLORREF crInverse2 = InvertCOLORREF(crCheck2); + + UINT uDEFlat = sb->fFlatScrollbar ? BF_FLAT : 0; + + //drawing flags to modify the appearance of the scrollbar buttons + UINT uLeftButFlags = DFCS_SCROLLLEFT; + UINT uRightButFlags = DFCS_SCROLLRIGHT; + + if (scrollwidth <= 0) + return 0; + + si = &sb->scrollInfo; + siMaxMin = si->nMax - si->nMin; + + if (hwnd != hwndCurCoolSB) + uDrawFlags = HTSCROLL_NONE; + // + // work out the thumb size and position + // + CalcThumbSize(sb, rect, &thumbwidth, &thumbpos); + + if (sb->fScrollFlags & ESB_DISABLE_LEFT) uLeftButFlags |= DFCS_INACTIVE; + if (sb->fScrollFlags & ESB_DISABLE_RIGHT) uRightButFlags |= DFCS_INACTIVE; + + //if we need to grey the arrows because there is no data to scroll + if ( !IsScrollInfoActive(si) && !(sb->fScrollFlags & CSBS_THUMBALWAYS)) + { + uLeftButFlags |= DFCS_INACTIVE; + uRightButFlags |= DFCS_INACTIVE; + } + + if (hwnd == hwndCurCoolSB) + { +#ifdef FLAT_SCROLLBARS + BOOL ldis = !(uLeftButFlags & DFCS_INACTIVE); + BOOL rdis = !(uRightButFlags & DFCS_INACTIVE); + + fBarHot = (sb->nBarType == (int)uMouseOverScrollbar && sb->fFlatScrollbar == CSBS_HOTTRACKED); + + fMouseOverL = uHitTestPortion == HTSCROLL_LEFT && fBarHot && ldis; + fMouseOverR = uHitTestPortion == HTSCROLL_RIGHT && fBarHot && rdis; +#endif + fMouseDownL = (uDrawFlags == HTSCROLL_LEFT); + fMouseDownR = (uDrawFlags == HTSCROLL_RIGHT); + } + + +//#ifdef CUSTOM_DRAW + fCustomDraw = ((PostCustomPrePostPaint(hwnd, hdc, sb, CDDS_PREPAINT)) == CDRF_SKIPDEFAULT); +//#endif + + // + // Draw the scrollbar now + // + if (scrollwidth > butwidth*2) + { + //LEFT ARROW + SetRect(&ctrl, rect->left, rect->top, rect->left + butwidth, rect->bottom); + + RotateRect0(sb, &ctrl); + + if (fCustomDraw) + PostCustomDrawNotify(hwnd, hdc, sb->nBarType, &ctrl, SB_LINELEFT, fMouseDownL, fMouseOverL, uLeftButFlags & DFCS_INACTIVE); + else + DrawScrollArrow(sb, hdc, &ctrl, uLeftButFlags, fMouseDownL, fMouseOverL); + + RotateRect0(sb, &ctrl); + + //MIDDLE PORTION + //if we can fit the thumbbar in, then draw it + if (thumbwidth > 0 && thumbwidth <= workingwidth + && IsScrollInfoActive(si) && ((sb->fScrollFlags & ESB_DISABLE_BOTH) != ESB_DISABLE_BOTH)) + { + //Draw the scrollbar margin above the thumb + SetRect(&sbm, rect->left + butwidth, rect->top, thumbpos, rect->bottom); + + RotateRect0(sb, &sbm); + + if (fCustomDraw) + { + PostCustomDrawNotify(hwnd, hdc, sb->nBarType, &sbm, SB_PAGELEFT, uDrawFlags == HTSCROLL_PAGELEFT, FALSE, FALSE); + } + else + { + if (uDrawFlags == HTSCROLL_PAGELEFT) + DrawCheckedRect(hdc, &sbm, crInverse1, crInverse2); + else + DrawCheckedRect(hdc, &sbm, crCheck1, crCheck2); + + } + + RotateRect0(sb, &sbm); + + //Draw the margin below the thumb + sbm.left = thumbpos+thumbwidth; + sbm.right = rect->right - butwidth; + + RotateRect0(sb, &sbm); + if (fCustomDraw) + { + PostCustomDrawNotify(hwnd, hdc, sb->nBarType, &sbm, SB_PAGERIGHT, uDrawFlags == HTSCROLL_PAGERIGHT, 0, 0); + } + else + { + if (uDrawFlags == HTSCROLL_PAGERIGHT) + DrawCheckedRect(hdc, &sbm, crInverse1, crInverse2); + else + DrawCheckedRect(hdc, &sbm, crCheck1, crCheck2); + + } + RotateRect0(sb, &sbm); + + //Draw the THUMB finally + SetRect(&thumb, thumbpos, rect->top, thumbpos+thumbwidth, rect->bottom); + + RotateRect0(sb, &thumb); + + if (fCustomDraw) + { + PostCustomDrawNotify(hwnd, hdc, sb->nBarType, &thumb, SB_THUMBTRACK, uDrawFlags==HTSCROLL_THUMB, uHitTestPortion == HTSCROLL_THUMB && fBarHot, FALSE); + } + else + { + +#ifdef FLAT_SCROLLBARS + if (hwnd == hwndCurCoolSB && sb->fFlatScrollbar && (uDrawFlags == HTSCROLL_THUMB || + (uHitTestPortion == HTSCROLL_THUMB && fBarHot))) + { + PaintRect(hdc, &thumb, GetSysColor(COLOR_3DSHADOW)); + } + else +#endif + { + DrawBlankButton(hdc, &thumb, uDEFlat); + } + } + RotateRect0(sb, &thumb); + + } + //otherwise, just leave that whole area blank + else + { + OffsetRect(&ctrl, butwidth, 0); + ctrl.right = rect->right - butwidth; + + //if we always show the thumb covering the whole scrollbar, + //then draw it that way + if ( !IsScrollInfoActive(si) && (sb->fScrollFlags & CSBS_THUMBALWAYS) + && ctrl.right - ctrl.left > sb->nMinThumbSize) + { + //leave a 1-pixel gap between the thumb + right button + ctrl.right --; + RotateRect0(sb, &ctrl); + + if (fCustomDraw) + PostCustomDrawNotify(hwnd, hdc, sb->nBarType, &ctrl, SB_THUMBTRACK, fMouseDownL, FALSE, FALSE); + else + { +#ifdef FLAT_SCROLLBARS + if (sb->fFlatScrollbar == CSBS_HOTTRACKED && uDrawFlags == HTSCROLL_THUMB) + PaintRect(hdc, &ctrl, GetSysColor(COLOR_3DSHADOW)); + else +#endif + DrawBlankButton(hdc, &ctrl, uDEFlat); + + } + RotateRect0(sb, &ctrl); + + //draw the single-line gap + ctrl.left = ctrl.right; + ctrl.right += 1; + + RotateRect0(sb, &ctrl); + + if (fCustomDraw) + PostCustomDrawNotify(hwnd, hdc, sb->nBarType, &ctrl, SB_PAGERIGHT, 0, 0, 0); + else + PaintRect(hdc, &ctrl, GetSysColor(COLOR_SCROLLBAR)); + + RotateRect0(sb, &ctrl); + } + //otherwise, paint a blank if the thumb doesn't fit in + else + { + RotateRect0(sb, &ctrl); + + if (fCustomDraw) + PostCustomDrawNotify(hwnd, hdc, sb->nBarType, &ctrl, SB_PAGERIGHT, 0, 0, 0); + else + DrawCheckedRect(hdc, &ctrl, crCheck1, crCheck2); + + RotateRect0(sb, &ctrl); + } + } + + //RIGHT ARROW + SetRect(&ctrl, rect->right - butwidth, rect->top, rect->right, rect->bottom); + + RotateRect0(sb, &ctrl); + + if (fCustomDraw) + PostCustomDrawNotify(hwnd, hdc, sb->nBarType, &ctrl, SB_LINERIGHT, fMouseDownR, fMouseOverR, uRightButFlags & DFCS_INACTIVE); + else + DrawScrollArrow(sb, hdc, &ctrl, uRightButFlags, fMouseDownR, fMouseOverR); + + RotateRect0(sb, &ctrl); + } + //not enough room for the scrollbar, so just draw the buttons (scaled in size to fit) + else + { + butwidth = scrollwidth / 2; + + //LEFT ARROW + SetRect(&ctrl, rect->left, rect->top, rect->left + butwidth, rect->bottom); + + RotateRect0(sb, &ctrl); + if (fCustomDraw) + PostCustomDrawNotify(hwnd, hdc, sb->nBarType, &ctrl, SB_LINELEFT, fMouseDownL, fMouseOverL, uLeftButFlags & DFCS_INACTIVE); + else + DrawScrollArrow(sb, hdc, &ctrl, uLeftButFlags, fMouseDownL, fMouseOverL); + RotateRect0(sb, &ctrl); + + //RIGHT ARROW + OffsetRect(&ctrl, scrollwidth - butwidth, 0); + + RotateRect0(sb, &ctrl); + if (fCustomDraw) + PostCustomDrawNotify(hwnd, hdc, sb->nBarType, &ctrl, SB_LINERIGHT, fMouseDownR, fMouseOverR, uRightButFlags & DFCS_INACTIVE); + else + DrawScrollArrow(sb, hdc, &ctrl, uRightButFlags, fMouseDownR, fMouseOverR); + RotateRect0(sb, &ctrl); + + //if there is a gap between the buttons, fill it with a solid color + //if (butwidth & 0x0001) + if (ctrl.left != rect->left + butwidth) + { + ctrl.left --; + ctrl.right -= butwidth; + RotateRect0(sb, &ctrl); + + if (fCustomDraw) + PostCustomDrawNotify(hwnd, hdc, sb->nBarType, &ctrl, SB_PAGERIGHT, 0, 0, 0); + else + DrawCheckedRect(hdc, &ctrl, crCheck1, crCheck2); + + RotateRect0(sb, &ctrl); + } + + } + +//#ifdef CUSTOM_DRAW + PostCustomPrePostPaint(hwnd, hdc, sb, CDDS_POSTPAINT); +//#endif + + return fCustomDraw; +} + +// +// Draw a vertical scrollbar using the horizontal draw routine, but +// with the coordinates adjusted accordingly +// +static LRESULT NCDrawVScrollbar(SCROLLBAR *sb, HWND hwnd, HDC hdc, const RECT *rect, UINT uDrawFlags) +{ + LRESULT ret; + RECT rc; + + rc = *rect; + RotateRect(&rc); + ret = NCDrawHScrollbar(sb, hwnd, hdc, &rc, uDrawFlags); + RotateRect(&rc); + + return ret; +} + +// +// Generic wrapper function for the scrollbar drawing +// +static LRESULT NCDrawScrollbar(SCROLLBAR *sb, HWND hwnd, HDC hdc, const RECT *rect, UINT uDrawFlags) +{ + if (sb->nBarType == SB_HORZ) + return NCDrawHScrollbar(sb, hwnd, hdc, rect, uDrawFlags); + else + return NCDrawVScrollbar(sb, hwnd, hdc, rect, uDrawFlags); +} + +#ifdef INCLUDE_BUTTONS + +// +// Draw the specified bitmap centered in the rectangle +// +static void DrawImage(HDC hdc, HBITMAP hBitmap, RECT *rc) +{ + BITMAP bm; + int cx; + int cy; + HDC memdc; + HBITMAP hOldBM; + RECT rcDest = *rc; + POINT p; + SIZE delta; + COLORREF colorOld; + + if (hBitmap == NULL) + return; + + // center bitmap in caller's rectangle + GetObject(hBitmap, sizeof bm, &bm); + + cx = bm.bmWidth; + cy = bm.bmHeight; + + delta.cx = (rc->right-rc->left - cx) / 2; + delta.cy = (rc->bottom-rc->top - cy) / 2; + + if (rc->right-rc->left > cx) + { + SetRect(&rcDest, rc->left+delta.cx, rc->top + delta.cy, 0, 0); + rcDest.right = rcDest.left + cx; + rcDest.bottom = rcDest.top + cy; + p.x = 0; + p.y = 0; + } + else + { + p.x = -delta.cx; + p.y = -delta.cy; + } + + // select checkmark into memory DC + memdc = CreateCompatibleDC(hdc); + hOldBM = (HBITMAP)SelectObject(memdc, hBitmap); + + // set BG color based on selected state + colorOld = SetBkColor(hdc, GetSysColor(COLOR_3DFACE)); + + BitBlt(hdc, rcDest.left, rcDest.top, rcDest.right-rcDest.left, rcDest.bottom-rcDest.top, memdc, p.x, p.y, SRCCOPY); + + // restore + SetBkColor(hdc, colorOld); + SelectObject(memdc, hOldBM); + DeleteDC(memdc); +} + +// +// Draw the specified metafile +// +static void DrawMetaFile(HDC hdc, HENHMETAFILE hemf, RECT *rect) +{ + RECT rc; + POINT pt; + + SetRect(&rc, 0, 0, rect->right-rect->left, rect->bottom-rect->top); + SetWindowOrgEx(hdc, -rect->left, -rect->top, &pt); + PlayEnhMetaFile(hdc, hemf, &rc); + SetWindowOrgEx(hdc, pt.x, pt.y, 0); +} + +// +// Draw a single scrollbar inserted button, in whatever style +// it has been defined to use. +// +static UINT DrawScrollButton(SCROLLBUT *sbut, HDC hdc, const RECT *pctrl, UINT flags) +{ + NMCSBCUSTOMDRAW nmcd; + HWND hwnd; + RECT rect = *pctrl; + UINT f; + + switch(sbut->uButType & SBBT_MASK) + { + case SBBT_OWNERDRAW: + + hwnd = WindowFromDC(hdc); + + //fill in the standard header + nmcd.hdr.hwndFrom = hwnd; + nmcd.hdr.idFrom = GetWindowLongPtr(hwnd, GWLP_ID); + nmcd.hdr.code = NM_COOLSB_CUSTOMDRAW; + + nmcd.dwDrawStage = CDDS_ITEMPREPAINT; + nmcd.nBar = SB_INSBUT; + nmcd.rect = *pctrl; + nmcd.uItem = sbut->uCmdId; + nmcd.hdc = hdc; + nmcd.uState = flags; + + IntersectClipRect(hdc, rect.left, rect.top, rect.right, rect.bottom); + SendMessage(GetParent(hwnd), WM_NOTIFY, nmcd.hdr.idFrom, (LPARAM)&nmcd); + SelectClipRgn(hdc, NULL); + + break; + + case SBBT_FIXED: + flags &= ~SBBS_PUSHED; + + case SBBT_TOGGLEBUTTON: + if (sbut->uState != SBBS_NORMAL) + flags |= SBBS_PUSHED; + + //intentionally fall through here... + + case SBBT_PUSHBUTTON: + + f = flags & SBBS_PUSHED ? DFCS_PUSHED | DFCS_FLAT : 0; + if (sbut->uButType & SBBM_LEFTARROW) + { + DrawFrameControl(hdc, &rect, DFC_SCROLL, DFCS_SCROLLLEFT | f); + } + else if (sbut->uButType & SBBM_RIGHTARROW) + { + DrawFrameControl(hdc, &rect, DFC_SCROLL, DFCS_SCROLLRIGHT | f); + } + else if (sbut->uButType & SBBM_UPARROW) + { + DrawFrameControl(hdc, &rect, DFC_SCROLL, DFCS_SCROLLUP | f); + } + else if (sbut->uButType & SBBM_DOWNARROW) + { + DrawFrameControl(hdc, &rect, DFC_SCROLL, DFCS_SCROLLDOWN | f); + } + else + { + // + if (flags & SBBS_PUSHED) + { + if (sbut->uButType & SBBM_RECESSED) + { + InflateRect(&rect, -1, -1); + DrawEdge(hdc, &rect, EDGE_SUNKEN, BF_RECT|BF_FLAT); + InflateRect(&rect, 1, 1); + + FrameRect(hdc, &rect, GetSysColorBrush(COLOR_3DDKSHADOW)); + InflateRect(&rect, -2, -2); + } + else + { + DrawEdge(hdc, &rect, EDGE_SUNKEN, BF_RECT | BF_FLAT | BF_ADJUST); + InflateRect(&rect, 1, 1); + } + } + else + { + // draw the button borders + if (sbut->uButType & SBBM_TYPE2) + { + DrawFrameControl(hdc, &rect, DFC_BUTTON, DFCS_BUTTONPUSH); + InflateRect(&rect, -2, -2); + } + + else if (sbut->uButType & SBBM_TYPE3) + { + DrawFrameControl(hdc, &rect, DFC_BUTTON, DFCS_BUTTONPUSH); + InflateRect(&rect, -1, -1); + } + else + { + DrawEdge(hdc, &rect, EDGE_RAISED, BF_RECT | BF_ADJUST); + rect.bottom++; + rect.right++; + } + + OffsetRect(&rect, -1, -1); + rect.top++; rect.left++; + } + + if (sbut->hBmp) + { + PaintRect(hdc, &rect, GetSysColor(COLOR_3DFACE)); + + if (flags & SBBS_PUSHED) + { + rect.top++; rect.left++; + } + + IntersectClipRect(hdc, rect.left, rect.top, rect.right,rect.bottom); + DrawImage(hdc, sbut->hBmp, &rect); + SelectClipRgn(hdc, 0); + } + else if (sbut->hEmf) + { + PaintRect(hdc, &rect, GetSysColor(COLOR_3DFACE)); + InflateRect(&rect, -1, -1); + + if (flags & SBBS_PUSHED) + { + rect.top++; rect.left++; + } + + IntersectClipRect(hdc, rect.left, rect.top, rect.right,rect.bottom); + DrawMetaFile(hdc, sbut->hEmf, &rect); + SelectClipRgn(hdc, 0); + } + else + { + PaintRect(hdc, &rect, GetSysColor(COLOR_3DFACE)); + } + } + + + break; + + case SBBT_BLANK: + PaintRect(hdc, &rect, GetSysColor(COLOR_3DFACE)); + break; + + case SBBT_FLAT: + DrawBlankButton(hdc, &rect, BF_FLAT); + break; + + case SBBT_DARK: + PaintRect(hdc, &rect, GetSysColor(COLOR_3DDKSHADOW)); + break; + } + + return 0; +} + +// +// Draw any buttons inserted into the horizontal scrollbar +// assume that the button widths have already been calculated +// Note: RECT *rect is the rectangle of the scrollbar +// leftright: 1 = left, 2 = right, 3 = both +// +static LRESULT DrawHorzButtons(SCROLLBAR *sbar, HDC hdc, const RECT *rect, int leftright) +{ + int i; + int xposl, xposr; + RECT ctrl; + SCROLLBUT *sbut = sbar->sbButtons; + + xposl = rect->left - sbar->nButSizeBefore; + xposr = rect->right; + + for (i = 0; i < sbar->nButtons; i++) + { + if ((leftright & SBBP_LEFT) && sbut[i].uPlacement == SBBP_LEFT) + { + int butwidth = GetSingleButSize(sbar, &sbut[i]); + SetRect(&ctrl, xposl, rect->top, xposl + butwidth, rect->bottom); + RotateRect0(sbar, &ctrl); + DrawScrollButton(&sbut[i], hdc, &ctrl, SBBS_NORMAL); + + xposl += butwidth; + } + + if ((leftright & SBBP_RIGHT) && sbut[i].uPlacement == SBBP_RIGHT) + { + int butwidth = GetSingleButSize(sbar, &sbut[i]); + SetRect(&ctrl, xposr, rect->top, xposr + butwidth, rect->bottom); + RotateRect0(sbar, &ctrl); + DrawScrollButton(&sbut[i], hdc, &ctrl, SBBS_NORMAL); + xposr += butwidth; + } + } + return 0; +} + +static LRESULT DrawVertButtons(SCROLLBAR *sbar, HDC hdc, const RECT *rect, int leftright) +{ + RECT rc = *rect; + RotateRect(&rc); + DrawHorzButtons(sbar, hdc, &rc, leftright); + return 0; +} +#endif // INCLUDE_BUTTONS + +// +// Define these two for proper processing of NCPAINT +// NOT needed if we don't bother to mask the scrollbars we draw +// to prevent the old window procedure from accidently drawing over them +// +HDC CoolSB_GetDC(HWND hwnd, WPARAM) +{ + // I just can't figure out GetDCEx, so I'll just use this: + return GetWindowDC(hwnd); +} + +static LRESULT NCPaint(SCROLLWND *sw, HWND hwnd, WPARAM wParam, LPARAM lParam) +{ + SCROLLBAR *sb; + HDC hdc; + RECT winrect, rect; + HRGN clip = 0; + BOOL fCustomDraw = FALSE; + LRESULT ret; + DWORD dwStyle; + + GetWindowRect(hwnd, &winrect); + + HRGN hrgn = (HRGN)wParam; + + //hdc = GetWindowDC(hwnd); + hdc = CoolSB_GetDC(hwnd, wParam); + + // + // Only draw the horizontal scrollbar if the window is tall enough + // + sb = &sw->sbarHorz; + if (sb->fScrollVisible) + { + //get the screen coordinates of the whole horizontal scrollbar area + GetHScrollRect(sw, hwnd, &rect); + + //make the coordinates relative to the window for drawing + OffsetRect(&rect, -winrect.left, -winrect.top); + + if (uCurrentScrollbar == SB_HORZ) + fCustomDraw |= NCDrawHScrollbar(sb, hwnd, hdc, &rect, uScrollTimerPortion); + else + fCustomDraw |= NCDrawHScrollbar(sb, hwnd, hdc, &rect, HTSCROLL_NONE); + } + + // + // Only draw the vertical scrollbar if the window is wide enough to accomodate it + // + sb = &sw->sbarVert; + if (sb->fScrollVisible) + { + //get the screen cooridinates of the whole horizontal scrollbar area + GetVScrollRect(sw, hwnd, &rect); + + //make the coordinates relative to the window for drawing + OffsetRect(&rect, -winrect.left, -winrect.top); + + if (uCurrentScrollbar == SB_VERT) + fCustomDraw |= NCDrawVScrollbar(sb, hwnd, hdc, &rect, uScrollTimerPortion); + else + fCustomDraw |= NCDrawVScrollbar(sb, hwnd, hdc, &rect, HTSCROLL_NONE); + } + + //Call the default window procedure for WM_NCPAINT, with the + //new window region. ** region must be in SCREEN coordinates ** + dwStyle = GetWindowLongPtr(hwnd, GWL_STYLE); + + // If the window has WS_(H-V)SCROLL bits set, we should reset them + // to avoid windows taking the scrollbars into account. + // We temporarily set a flag preventing the subsecuent + // WM_STYLECHANGING/WM_STYLECHANGED to be forwarded to + // the original window procedure + if ( dwStyle & (WS_VSCROLL|WS_HSCROLL)) + { + sw->bPreventStyleChange = TRUE; + SetWindowLongPtr(hwnd, GWL_STYLE, dwStyle & ~(WS_VSCROLL|WS_HSCROLL)); + } + + ret = mir_callNextSubclass(hwnd, CoolSBWndProc, WM_NCPAINT, (WPARAM)hrgn, lParam); + + if ( dwStyle & (WS_VSCROLL|WS_HSCROLL)) + { + SetWindowLongPtr(hwnd, GWL_STYLE, dwStyle); + sw->bPreventStyleChange = FALSE; + } + + // DRAW THE DEAD AREA + // only do this if the horizontal and vertical bars are visible + if (sw->sbarHorz.fScrollVisible && sw->sbarVert.fScrollVisible) + { + GetWindowRect(hwnd, &rect); + OffsetRect(&rect, -winrect.left, -winrect.top); + + rect.bottom -= sw->cyBottomEdge; + rect.top = rect.bottom - GetScrollMetric(&sw->sbarHorz, SM_CYHORZSB); + + if (sw->fLeftScrollbar) + { + rect.left += sw->cxLeftEdge; + rect.right = rect.left + GetScrollMetric(&sw->sbarVert, SM_CXVERTSB); + } + else + { + rect.right -= sw->cxRightEdge; + rect.left = rect.right - GetScrollMetric(&sw->sbarVert, SM_CXVERTSB); + } + + if (fCustomDraw) + PostCustomDrawNotify(hwnd, hdc, SB_BOTH, &rect, 32, 0, 0, 0); + else + { + //calculate the position of THIS window's dead area + //with the position of the PARENT window's client rectangle. + //if THIS window has been positioned such that its bottom-right + //corner sits in the parent's bottom-right corner, then we should + //show the sizing-grip. + //Otherwise, assume this window is not in the right place, and + //just draw a blank rectangle + RECT parent; + RECT rect2; + HWND hwndParent = GetParent(hwnd); + + GetClientRect(hwndParent, &parent); + MapWindowPoints(hwndParent, 0, (POINT *)&parent, 2); + + CopyRect(&rect2, &rect); + OffsetRect(&rect2, winrect.left, winrect.top); + + if ( !sw->fLeftScrollbar && parent.right == rect2.right+sw->cxRightEdge && parent.bottom == rect2.bottom+sw->cyBottomEdge + || sw->fLeftScrollbar && parent.left == rect2.left -sw->cxLeftEdge && parent.bottom == rect2.bottom+sw->cyBottomEdge) + DrawFrameControl(hdc, &rect, DFC_SCROLL, sw->fLeftScrollbar ? DFCS_SCROLLSIZEGRIPRIGHT : DFCS_SCROLLSIZEGRIP ); + else + PaintRect(hdc, &rect, GetSysColor(COLOR_3DFACE)); + } + } + + UNREFERENCED_PARAMETER(clip); + ReleaseDC(hwnd, hdc); + return ret; +} + +// +// Need to detect if we have clicked in the scrollbar region or not +// +static LRESULT NCHitTest(SCROLLWND *sw, HWND hwnd, WPARAM wParam, LPARAM lParam) +{ + RECT hrect; + RECT vrect; + POINT pt; + + pt.x = LOWORD(lParam); + pt.y = HIWORD(lParam); + + //work out exactly where the Horizontal and Vertical scrollbars are + GetHScrollRect(sw, hwnd, &hrect); + GetVScrollRect(sw, hwnd, &vrect); + + //Clicked in the horizontal scrollbar area + if (sw->sbarHorz.fScrollVisible && PtInRect(&hrect, pt)) + return HTHSCROLL; + + //Clicked in the vertical scrollbar area + if (sw->sbarVert.fScrollVisible && PtInRect(&vrect, pt)) + return HTVSCROLL; + + //clicked somewhere else + return mir_callNextSubclass(hwnd, CoolSBWndProc, WM_NCHITTEST, wParam, lParam); +} + +// +// Return a HT* value indicating what part of the scrollbar was clicked +// Rectangle is not adjusted +// +static UINT GetHorzPortion(SCROLLBAR *sb, RECT *rect, int x, int y) +{ + RECT rc = *rect; + + if (y < rc.top || y >= rc.bottom) return HTSCROLL_NONE; + +#ifdef INCLUDE_BUTTONS + + if (sb->fButVisibleBefore) + { + //clicked on the buttons to the left of the scrollbar + if (x >= rc.left && x < rc.left + sb->nButSizeBefore) + return HTSCROLL_INSERTED; + + //adjust the rectangle to exclude the left-side buttons, now that we + //know we havn't clicked on them + rc.left += sb->nButSizeBefore; + } + + if (sb->fButVisibleAfter) + { + //clicked on the buttons to the right of the scrollbar + if (x >= rc.right - sb->nButSizeAfter && x < rc.right) + return HTSCROLL_INSERTED; + + //adjust the rectangle to exclude the right-side buttons, now that we + //know we havn't clicked on them + rc.right -= sb->nButSizeAfter; + } + +#endif INCLUDE_BUTTONS + + //Now we have the rectangle for the scrollbar itself, so work out + //what part we clicked on. + return GetHorzScrollPortion(sb, &rc, x, y); +} + +// +// Just call the horizontal version, with adjusted coordinates +// +static UINT GetVertPortion(SCROLLBAR *sb, RECT *rect, int x, int y) +{ + UINT ret; + RotateRect(rect); + ret = GetHorzPortion(sb, rect, y, x); + RotateRect(rect); + return ret; +} + +// +// Wrapper function for GetHorzPortion and GetVertPortion +// +static UINT GetPortion(SCROLLBAR *sb, RECT *rect, int x, int y) +{ + if (sb->nBarType == SB_HORZ) + return GetHorzPortion(sb, rect, x, y); + else if (sb->nBarType == SB_VERT) + return GetVertPortion(sb, rect, x, y); + else + return HTSCROLL_NONE; +} + +// +// Input: rectangle of the total scrollbar area +// Output: adjusted to take the inserted buttons into account +// +static void GetRealHorzScrollRect(SCROLLBAR *sb, RECT *rect) +{ + if (sb->fButVisibleBefore) rect->left += sb->nButSizeBefore; + if (sb->fButVisibleAfter) rect->right -= sb->nButSizeAfter; +} + +// +// Input: rectangle of the total scrollbar area +// Output: adjusted to take the inserted buttons into account +// +static void GetRealVertScrollRect(SCROLLBAR *sb, RECT *rect) +{ + if (sb->fButVisibleBefore) rect->top += sb->nButSizeBefore; + if (sb->fButVisibleAfter) rect->bottom -= sb->nButSizeAfter; +} + +// +// Decide which type of scrollbar we have before calling +// the real function to do the job +// +static void GetRealScrollRect(SCROLLBAR *sb, RECT *rect) +{ + if (sb->nBarType == SB_HORZ) + { + GetRealHorzScrollRect(sb, rect); + } + else if (sb->nBarType == SB_VERT) + { + GetRealVertScrollRect(sb, rect); + } +} + +// +// All button code shoule be collected together +// +// +#ifdef INCLUDE_BUTTONS + +// +// Return the index of the button covering the specified point +// rect - rectangle of the whole scrollbar area +// pt - screen coords of the mouse +// fReturnRect - do/don't modify the rect to return the button's area +// +static UINT GetHorzButtonFromPt(SCROLLBAR *sb, RECT *rect, POINT pt, BOOL fReturnRect) +{ + int leftpos = rect->left, rightpos = rect->right; + int i; + int butwidth; + SCROLLBUT *sbut = sb->sbButtons; + + if ( !PtInRect(rect, pt)) + return -1; + + if (sb->fButVisibleAfter) + rightpos -= sb->nButSizeAfter; + + for (i = 0; i < sb->nButtons; i++) + { + if (sb->fButVisibleBefore && sbut[i].uPlacement == SBBP_LEFT) + { + butwidth = GetSingleButSize(sb, &sbut[i]); + + //if the current button is under the specified point + if (pt.x >= leftpos && pt.x < leftpos + butwidth) + { + //if the caller wants us to return the rectangle of the button + if (fReturnRect) + { + rect->left = leftpos; + rect->right = leftpos + butwidth; + } + + return i; + } + + leftpos += butwidth; + } + else if (sb->fButVisibleAfter && sbut[i].uPlacement == SBBP_RIGHT) + { + butwidth = GetSingleButSize(sb, &sbut[i]); + + //if the current button is under the specified point + if (pt.x >= rightpos && pt.x < rightpos + butwidth) + { + //if the caller wants us to return the rectangle of the button + if (fReturnRect) + { + rect->left = rightpos; + rect->right = rightpos + butwidth; + } + return i; + } + + rightpos += butwidth; + } + } + + return -1; +} + + +static UINT GetVertButtonFromPt(SCROLLBAR *sb, RECT *rect, POINT pt, BOOL fReturnRect) +{ + UINT ret; + int temp; + + //swap the X/Y coords + temp = pt.x; + pt.x = pt.y; + pt.y = temp; + + //swap the rectangle + RotateRect(rect); + + ret = GetHorzButtonFromPt(sb, rect, pt, fReturnRect); + + RotateRect(rect); + return ret; +} + +// +// +// +static UINT GetButtonFromPt(SCROLLBAR *sb, RECT *rect, POINT pt, BOOL fReturnRect) +{ + if (sb->nBarType == SB_HORZ) + { + return GetHorzButtonFromPt(sb, rect, pt, fReturnRect); + } + else + { + return GetVertButtonFromPt(sb, rect, pt, fReturnRect); + } +} + +// +// Find the coordinates (in RECT format) of the specified button index +// +static UINT GetHorzButtonRectFromId(SCROLLBAR *sb, RECT *rect, UINT index) +{ + UINT i; + SCROLLBUT *sbut = sb->sbButtons; + int leftpos = rect->left, rightpos = rect->right; + + if (sb->fButVisibleAfter) + rightpos -= sb->nButSizeAfter; + + //find the particular button in question + for (i = 0; i < index; i++) + { + if (sb->fButVisibleBefore && sbut[i].uPlacement == SBBP_LEFT) + { + leftpos += GetSingleButSize(sb, &sbut[i]); + } + else if (sb->fButVisibleAfter && sbut[i].uPlacement == SBBP_RIGHT) + { + rightpos += GetSingleButSize(sb, &sbut[i]); + } + } + + //now return the rectangle + if (sbut[i].uPlacement == SBBP_LEFT) + { + rect->left = leftpos; + rect->right = leftpos + GetSingleButSize(sb, &sbut[i]); + } + else + { + rect->left = rightpos; + rect->right = rightpos + GetSingleButSize(sb, &sbut[i]); + } + + return 0; +} + +static UINT GetVertButtonRectFromId(SCROLLBAR *sb, RECT *rect, UINT index) +{ + UINT ret; + RotateRect(rect); + ret = GetHorzButtonRectFromId(sb, rect, index); + RotateRect(rect); + return ret; +} + +static UINT GetButtonRectFromId(SCROLLBAR *sb, RECT *rect, UINT index) +{ + if (sb->nBarType == SB_HORZ) + { + return GetHorzButtonRectFromId(sb, rect, index); + } + else + { + return GetVertButtonRectFromId(sb, rect, index); + } +} +#endif //INCLUDE_BUTTONS + +// +// Left button click in the non-client area +// +static LRESULT NCLButtonDown(SCROLLWND *sw, HWND hwnd, WPARAM wParam, LPARAM lParam) +{ + RECT rect, winrect; + HDC hdc; + SCROLLBAR *sb; + POINT pt; + + pt.x = LOWORD(lParam); + pt.y = HIWORD(lParam); + + hwndCurCoolSB = hwnd; + + // + // HORIZONTAL SCROLLBAR PROCESSING + // + if (wParam == HTHSCROLL) + { + uScrollTimerMsg = WM_HSCROLL; + uCurrentScrollbar = SB_HORZ; + sb = &sw->sbarHorz; + + //get the total area of the normal Horz scrollbar area + GetHScrollRect(sw, hwnd, &rect); + uCurrentScrollPortion = GetHorzPortion(sb, &rect, LOWORD(lParam), HIWORD(lParam)); + } + // + // VERTICAL SCROLLBAR PROCESSING + // + else if (wParam == HTVSCROLL) + { + uScrollTimerMsg = WM_VSCROLL; + uCurrentScrollbar = SB_VERT; + sb = &sw->sbarVert; + + //get the total area of the normal Horz scrollbar area + GetVScrollRect(sw, hwnd, &rect); + uCurrentScrollPortion = GetVertPortion(sb, &rect, LOWORD(lParam), HIWORD(lParam)); + } + // + // NORMAL PROCESSING + // + else + { + uCurrentScrollPortion = HTSCROLL_NONE; + return mir_callNextSubclass(hwnd, CoolSBWndProc, WM_NCLBUTTONDOWN, wParam, lParam); + } + + // + // we can now share the same code for vertical + // and horizontal scrollbars + // + switch(uCurrentScrollPortion) + { + //inserted buttons to the left/right +#ifdef INCLUDE_BUTTONS + case HTSCROLL_INSERTED: + +#ifdef HOT_TRACKING + KillTimer(hwnd, uMouseOverId); + uMouseOverId = 0; + uMouseOverScrollbar = COOLSB_NONE; +#endif + + //find the index of the button that has been clicked + //adjust the rectangle to give the button's rectangle + uCurrentButton = GetButtonFromPt(sb, &rect, pt, TRUE); + + sbut = &sb->sbButtons[uCurrentButton]; + + //post a notification message + PostMouseNotify(hwnd, NM_CLICK, sb->nBarType, &rect, sbut->uCmdId, pt); + + GetWindowRect(hwnd, &winrect); + OffsetRect(&rect, -winrect.left, -winrect.top); + hdc = GetWindowDC(hwnd); + + DrawScrollButton(sbut, hdc, &rect, SBBS_PUSHED); + + ReleaseDC(hwnd, hdc); + + break; +#endif //INCLUDE_BUTTONS + + case HTSCROLL_THUMB: + + //if the scrollbar is disabled, then do no further processing + if ( !IsScrollbarActive(sb)) + return 0; + + GetRealScrollRect(sb, &rect); + RotateRect0(sb, &rect); + CalcThumbSize(sb, &rect, &nThumbSize, &nThumbPos); + RotateRect0(sb, &rect); + + //remember the bounding rectangle of the scrollbar work area + rcThumbBounds = rect; + + sw->fThumbTracking = TRUE; + sb->scrollInfo.nTrackPos = sb->scrollInfo.nPos; + + if (wParam == HTVSCROLL) + nThumbMouseOffset = pt.y - nThumbPos; + else + nThumbMouseOffset = pt.x - nThumbPos; + + nLastPos = -sb->scrollInfo.nPos; + nThumbPos0 = nThumbPos; + + //if (sb->fFlatScrollbar) + //{ + GetWindowRect(hwnd, &winrect); + OffsetRect(&rect, -winrect.left, -winrect.top); + hdc = GetWindowDC(hwnd); + NCDrawScrollbar(sb, hwnd, hdc, &rect, HTSCROLL_THUMB); + ReleaseDC(hwnd, hdc); + //} + + break; + + //Any part of the scrollbar + case HTSCROLL_LEFT: + if (sb->fScrollFlags & ESB_DISABLE_LEFT) return 0; + else goto target1; + + case HTSCROLL_RIGHT: + if (sb->fScrollFlags & ESB_DISABLE_RIGHT) return 0; + else goto target1; + + goto target1; + + case HTSCROLL_PAGELEFT: case HTSCROLL_PAGERIGHT: + + target1: + + //if the scrollbar is disabled, then do no further processing + if ( !IsScrollbarActive(sb)) + break; + + //ajust the horizontal rectangle to NOT include + //any inserted buttons + GetRealScrollRect(sb, &rect); + + SendScrollMessage(hwnd, uScrollTimerMsg, uCurrentScrollPortion, 0); + + // Check what area the mouse is now over : + // If the scroll thumb has moved under the mouse in response to + // a call to SetScrollPos etc, then we don't hilight the scrollbar margin + if (uCurrentScrollbar == SB_HORZ) + uScrollTimerPortion = GetHorzScrollPortion(sb, &rect, pt.x, pt.y); + else + uScrollTimerPortion = GetVertScrollPortion(sb, &rect, pt.x, pt.y); + + GetWindowRect(hwnd, &winrect); + OffsetRect(&rect, -winrect.left, -winrect.top); + hdc = GetWindowDC(hwnd); + +#ifndef HOT_TRACKING + //if we aren't hot-tracking, then don't highlight + //the scrollbar thumb unless we click on it + if (uScrollTimerPortion == HTSCROLL_THUMB) + uScrollTimerPortion = HTSCROLL_NONE; +#endif + NCDrawScrollbar(sb, hwnd, hdc, &rect, uScrollTimerPortion); + ReleaseDC(hwnd, hdc); + + //Post the scroll message!!!! + uScrollTimerPortion = uCurrentScrollPortion; + + //set a timer going on the first click. + //if this one expires, then we can start off a more regular timer + //to generate the auto-scroll behaviour + uScrollTimerId = SetTimer(hwnd, COOLSB_TIMERID1, COOLSB_TIMERINTERVAL1, 0); + break; + default: + return mir_callNextSubclass(hwnd, CoolSBWndProc, WM_NCLBUTTONDOWN, wParam, lParam); + //return 0; + } + + SetCapture(hwnd); + return 0; +} + +// +// Left button released +// +static LRESULT LButtonUp(SCROLLWND *sw, HWND hwnd, WPARAM wParam, LPARAM lParam) +{ + RECT rect; + //UINT thisportion; + HDC hdc; + POINT pt; + RECT winrect; + + //current scrollportion is the button that we clicked down on + if (uCurrentScrollPortion != HTSCROLL_NONE) + { + SCROLLBAR *sb = &sw->sbarHorz; + lParam = GetMessagePos(); + ReleaseCapture(); + + GetWindowRect(hwnd, &winrect); + pt.x = LOWORD(lParam); + pt.y = HIWORD(lParam); + + //emulate the mouse input on a scrollbar here... + if (uCurrentScrollbar == SB_HORZ) + { + //get the total area of the normal Horz scrollbar area + sb = &sw->sbarHorz; + GetHScrollRect(sw, hwnd, &rect); + } + else if (uCurrentScrollbar == SB_VERT) + { + //get the total area of the normal Horz scrollbar area + sb = &sw->sbarVert; + GetVScrollRect(sw, hwnd, &rect); + } + + //we need to do different things depending on if the + //user is activating the scrollbar itself, or one of + //the inserted buttons + switch(uCurrentScrollPortion) + { +#ifdef INCLUDE_BUTTONS + //inserted buttons are being clicked + case HTSCROLL_INSERTED: + + //get the rectangle of the ACTIVE button + buttonIdx = GetButtonFromPt(sb, &rect, pt, FALSE); + GetButtonRectFromId(sb, &rect, uCurrentButton); + + OffsetRect(&rect, -winrect.left, -winrect.top); + + //Send the notification BEFORE we redraw, so the + //bitmap can be changed smoothly by the user if they require + if (uCurrentButton == buttonIdx) + { + SCROLLBUT *sbut = &sb->sbButtons[buttonIdx]; + UINT cmdid = sbut->uCmdId; + + if ((sbut->uButType & SBBT_MASK) == SBBT_TOGGLEBUTTON) + sbut->uState ^= 1; + + //send a notify?? + //only post a message if the command id is valid + if (cmdid != -1 && cmdid > 0) + SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(cmdid, CSBN_CLICKED), 0); + + //user might have deleted this button, so redraw whole area + NCPaint(sw, hwnd, 1, 0); + } + else + { + //otherwise, just redraw the button in its new state + hdc = GetWindowDC(hwnd); + DrawScrollButton(&sb->sbButtons[uCurrentButton], hdc, &rect, SBBS_NORMAL); + ReleaseDC(hwnd, hdc); + } + + break; +#endif // INCLUDE_BUTTONS + + //The scrollbar is active + case HTSCROLL_LEFT: case HTSCROLL_RIGHT: + case HTSCROLL_PAGELEFT: case HTSCROLL_PAGERIGHT: + case HTSCROLL_NONE: + + KillTimer(hwnd, uScrollTimerId); + + case HTSCROLL_THUMB: + + //In case we were thumb tracking, make sure we stop NOW + if (sw->fThumbTracking == TRUE) + { + SendScrollMessage(hwnd, uScrollTimerMsg, SB_THUMBPOSITION, nLastPos); + sw->fThumbTracking = FALSE; + } + + //send the SB_ENDSCROLL message now that scrolling has finished + SendScrollMessage(hwnd, uScrollTimerMsg, SB_ENDSCROLL, 0); + + //adjust the total scroll area to become where the scrollbar + //really is (take into account the inserted buttons) + GetRealScrollRect(sb, &rect); + OffsetRect(&rect, -winrect.left, -winrect.top); + hdc = GetWindowDC(hwnd); + + //draw whichever scrollbar sb is + NCDrawScrollbar(sb, hwnd, hdc, &rect, HTSCROLL_NORMAL); + + ReleaseDC(hwnd, hdc); + break; + } + + //reset our state to default + uCurrentScrollPortion = HTSCROLL_NONE; + uScrollTimerPortion = HTSCROLL_NONE; + uScrollTimerId = 0; + + uScrollTimerMsg = 0; + uCurrentScrollbar = COOLSB_NONE; + + return 0; + } + else + { + /* + // Can't remember why I did this! + if (GetCapture() == hwnd) + { + ReleaseCapture(); + }*/ + } + + return mir_callNextSubclass(hwnd, CoolSBWndProc, WM_LBUTTONUP, wParam, lParam); +} + +// +// This function is called whenever the mouse is moved and +// we are dragging the scrollbar thumb about. +// +static LRESULT ThumbTrackHorz(SCROLLBAR *sbar, HWND hwnd, int x, int y) +{ + POINT pt; + RECT rc, winrect, rc2; + COLORREF crCheck1 = GetSBForeColor(); + COLORREF crCheck2 = GetSBBackColor(); + HDC hdc; + int thumbpos = nThumbPos; + int pos; + int siMaxMin = 0; + UINT flatflag = sbar->fFlatScrollbar ? BF_FLAT : 0; + BOOL fCustomDraw = FALSE; + + SCROLLINFO *si; + si = &sbar->scrollInfo; + + pt.x = x; + pt.y = y; + + //draw the thumb at whatever position + rc = rcThumbBounds; + + SetRect(&rc2, rc.left - THUMBTRACK_SNAPDIST*2, rc.top - THUMBTRACK_SNAPDIST, + rc.right + THUMBTRACK_SNAPDIST*2, rc.bottom + THUMBTRACK_SNAPDIST); + + rc.left += GetScrollMetric(sbar, SM_CXHORZSB); + rc.right -= GetScrollMetric(sbar, SM_CXHORZSB); + + //if the mouse is not in a suitable distance of the scrollbar, + //then "snap" the thumb back to its initial position +#ifdef SNAP_THUMB_BACK + if ( !PtInRect(&rc2, pt)) + { + thumbpos = nThumbPos0; + } + //otherwise, move the thumb to where the mouse is + else +#endif //SNAP_THUMB_BACK + { + //keep the thumb within the scrollbar limits + thumbpos = pt.x - nThumbMouseOffset; + if (thumbpos < rc.left) thumbpos = rc.left; + if (thumbpos > rc.right - nThumbSize) thumbpos = rc.right - nThumbSize; + } + + GetWindowRect(hwnd, &winrect); + + if (sbar->nBarType == SB_VERT) + RotateRect(&winrect); + + hdc = GetWindowDC(hwnd); + +//#ifdef CUSTOM_DRAW + fCustomDraw = PostCustomPrePostPaint(hwnd, hdc, sbar, CDDS_PREPAINT) == CDRF_SKIPDEFAULT; +//#endif + + OffsetRect(&rc, -winrect.left, -winrect.top); + thumbpos -= winrect.left; + + //draw the margin before the thumb + SetRect(&rc2, rc.left, rc.top, thumbpos, rc.bottom); + RotateRect0(sbar, &rc2); + + if (fCustomDraw) + PostCustomDrawNotify(hwnd, hdc, sbar->nBarType, &rc2, SB_PAGELEFT, 0, 0, 0); + else + DrawCheckedRect(hdc, &rc2, crCheck1, crCheck2); + + RotateRect0(sbar, &rc2); + + //draw the margin after the thumb + SetRect(&rc2, thumbpos+nThumbSize, rc.top, rc.right, rc.bottom); + + RotateRect0(sbar, &rc2); + + if (fCustomDraw) + PostCustomDrawNotify(hwnd, hdc, sbar->nBarType, &rc2, SB_PAGERIGHT, 0, 0, 0); + else + DrawCheckedRect(hdc, &rc2, crCheck1, crCheck2); + + RotateRect0(sbar, &rc2); + + //finally draw the thumb itelf. This is how it looks on win2000, anyway + SetRect(&rc2, thumbpos, rc.top, thumbpos+nThumbSize, rc.bottom); + + RotateRect0(sbar, &rc2); + + if (fCustomDraw) + PostCustomDrawNotify(hwnd, hdc, sbar->nBarType, &rc2, SB_THUMBTRACK, TRUE, TRUE, FALSE); + else + { + +#ifdef FLAT_SCROLLBARS + if (sbar->fFlatScrollbar) + PaintRect(hdc, &rc2, GetSysColor(COLOR_3DSHADOW)); + else +#endif + { + DrawBlankButton(hdc, &rc2, flatflag); + } + } + + RotateRect0(sbar, &rc2); + ReleaseDC(hwnd, hdc); + + //post a SB_TRACKPOS message!!! + siMaxMin = si->nMax - si->nMin; + + if (siMaxMin > 0) + pos = MulDiv(thumbpos-rc.left, siMaxMin-si->nPage + 1, rc.right-rc.left-nThumbSize); + else + pos = thumbpos - rc.left; + + if (pos != nLastPos) + { + si->nTrackPos = pos; + SendScrollMessage(hwnd, uScrollTimerMsg, SB_THUMBTRACK, pos); + } + + nLastPos = pos; + +//#ifdef CUSTOM_DRAW + PostCustomPrePostPaint(hwnd, hdc, sbar, CDDS_POSTPAINT); +//#endif + + return 0; +} + +// +// remember to rotate the thumb bounds rectangle!! +// +static LRESULT ThumbTrackVert(SCROLLBAR *sb, HWND hwnd, int x, int y) +{ + //sw->swapcoords = TRUE; + RotateRect(&rcThumbBounds); + ThumbTrackHorz(sb, hwnd, y, x); + RotateRect(&rcThumbBounds); + //sw->swapcoords = FALSE; + + return 0; +} + +// +// Called when we have set the capture from the NCLButtonDown(...) +// +static LRESULT MouseMove(SCROLLWND *sw, HWND hwnd, WPARAM wParam, LPARAM lParam) +{ + RECT rect; + UINT thisportion; + HDC hdc; + static UINT lastportion = 0; + static UINT lastbutton = 0; + POINT pt; + RECT winrect; + UINT buttonIdx = 0; + + if (sw->fThumbTracking == TRUE) + { + int x, y; + lParam = GetMessagePos(); + x = LOWORD(lParam); + y = HIWORD(lParam); + + if (uCurrentScrollbar == SB_HORZ) + return ThumbTrackHorz(&sw->sbarHorz, hwnd, x,y); + + else if (uCurrentScrollbar == SB_VERT) + return ThumbTrackVert(&sw->sbarVert, hwnd, x,y); + } + + if (uCurrentScrollPortion == HTSCROLL_NONE) + return mir_callNextSubclass(hwnd, CoolSBWndProc, WM_MOUSEMOVE, wParam, lParam); + + LPARAM nlParam; + SCROLLBAR *sb = &sw->sbarHorz; + + nlParam = GetMessagePos(); + + GetWindowRect(hwnd, &winrect); + + pt.x = LOWORD(nlParam); + pt.y = HIWORD(nlParam); + + //emulate the mouse input on a scrollbar here... + if (uCurrentScrollbar == SB_HORZ) + { + sb = &sw->sbarHorz; + } + else if (uCurrentScrollbar == SB_VERT) + { + sb = &sw->sbarVert; + } + + //get the total area of the normal scrollbar area + GetScrollRect(sw, sb->nBarType, hwnd, &rect); + + //see if we clicked in the inserted buttons / normal scrollbar + //thisportion = GetPortion(sb, hwnd, &rect, LOWORD(lParam), HIWORD(lParam)); + thisportion = GetPortion(sb, &rect, pt.x, pt.y); + + //we need to do different things depending on if the + //user is activating the scrollbar itself, or one of + //the inserted buttons + switch(uCurrentScrollPortion) { +#ifdef INCLUDE_BUTTONS + //inserted buttons are being clicked + case HTSCROLL_INSERTED: + + //find the index of the button that has been clicked + //Don't adjust the rectangle though + buttonIdx = GetButtonFromPt(sb, &rect, pt, FALSE); + + //Get the rectangle of the active button + GetButtonRectFromId(sb, &rect, uCurrentButton); + + //if the button to the LEFT of the current + //button is resizable, then resize it +#ifdef RESIZABLE_BUTTONS + if (uCurrentButton > 0) + { + sbut = &sb->sbButtons[uCurrentButton - 1]; + + //only resize if BOTH buttons are on same side of scrollbar + if (sbut->uPlacement == (sbut+1)->uPlacement && (sbut->uButType & SBBM_RESIZABLE)) + { + int oldsize = sbut->nSize; + int butsize1, butsize2; + RECT rect2; + int scrollsize; + + if (uCurrentScrollbar == SB_HORZ) + { + rect.left -= GetSingleButSize(sb, sbut); + sbut->nSize = pt.x - rect.left; + } + else + { + rect.top -= GetSingleButSize(sb, sbut); + sbut->nSize = pt.y - rect.top; + } + + //if (sbut->nSize < 0) sbut->nSize = 0; + if (sbut->nSize < (int)sbut->nMinSize) + sbut->nSize = sbut->nMinSize; + + if ((UINT)sbut->nSize > (UINT)sbut->nMaxSize) + sbut->nSize = sbut->nMaxSize; + + GetScrollRect(sw, uCurrentScrollbar, hwnd, &rect2); + + if (uCurrentScrollbar == SB_HORZ) + scrollsize = rect2.right-rect2.left; + else + scrollsize = rect2.bottom-rect2.top; + + butsize1 = GetButtonSize(sb, hwnd, SBBP_LEFT); + butsize2 = GetButtonSize(sb, hwnd, SBBP_RIGHT); + + //adjust the button size if it gets too big + if (butsize1 + butsize2 > scrollsize - MINSCROLLSIZE) + { + sbut->nSize -= (butsize1+butsize2) - (scrollsize - MINSCROLLSIZE); + } + + //remember what size the USER set the button to + sbut->nSizeReserved = sbut->nSize; + NCPaint(sw, hwnd, 1, 0); + return 0; + } + } +#endif //RESIZABLE_BUTTONS + + OffsetRect(&rect, -winrect.left, -winrect.top); + + hdc = GetWindowDC(hwnd); + + //if the button under the mouse is not the active button, + //then display the active button in its normal state + if (buttonIdx != uCurrentButton + //include this if toggle buttons always stay depressed + //if they are being activated + && (sb->sbButtons[uCurrentButton].uButType & SBBT_MASK) != SBBT_TOGGLEBUTTON) + { + if (lastbutton != buttonIdx) + DrawScrollButton(&sb->sbButtons[uCurrentButton], hdc, &rect, SBBS_NORMAL); + } + //otherwise, depress the active button if the mouse is over + //it (just like a normal scroll button works) + else + { + if (lastbutton != buttonIdx) + DrawScrollButton(&sb->sbButtons[uCurrentButton], hdc, &rect, SBBS_PUSHED); + } + + ReleaseDC(hwnd, hdc); + return mir_callNextSubclass(hwnd, CoolSBWndProc, WM_MOUSEMOVE, wParam, lParam); + //break; + +#endif //INCLUDE_BUTTONS + + //The scrollbar is active + case HTSCROLL_LEFT: case HTSCROLL_RIGHT:case HTSCROLL_THUMB: + case HTSCROLL_PAGELEFT: case HTSCROLL_PAGERIGHT: + case HTSCROLL_NONE: + //adjust the total scroll area to become where the scrollbar + //really is (take into account the inserted buttons) + GetRealScrollRect(sb, &rect); + + OffsetRect(&rect, -winrect.left, -winrect.top); + hdc = GetWindowDC(hwnd); + + if (thisportion != uCurrentScrollPortion) + { + uScrollTimerPortion = HTSCROLL_NONE; + + if (lastportion != thisportion) + NCDrawScrollbar(sb, hwnd, hdc, &rect, HTSCROLL_NORMAL); + } + //otherwise, draw the button in its depressed / clicked state + else + { + uScrollTimerPortion = uCurrentScrollPortion; + + if (lastportion != thisportion) + NCDrawScrollbar(sb, hwnd, hdc, &rect, thisportion); + } + + ReleaseDC(hwnd, hdc); + break; + } + + lastportion = thisportion; + lastbutton = buttonIdx; + return 0; +} + +#ifdef INCLUDE_BUTTONS +#ifdef RESIZABLE_BUTTONS +// +// Any resizable buttons must be shrunk to fit if the window is made too small +// +static void ResizeButtonsToFit(SCROLLWND *sw, SCROLLBAR *sbar, HWND hwnd) +{ + int butsize1, butsize2; + RECT rc; + int scrollsize; + int i; + SCROLLBUT *sbut; + + //make sure that the scrollbar can fit into space, by + //shrinking any resizable buttons + GetScrollRect(sw, sbar->nBarType, hwnd, &rc); + + if (sbar->nBarType == SB_HORZ) + scrollsize = rc.right-rc.left; + else + scrollsize = rc.bottom-rc.top; + + //restore any resizable buttons to their user-defined sizes, + //before shrinking them to fit. This means when we make the window + //bigger, the buttons will restore to their initial sizes + for (i = 0; i < sbar->nButtons; i++) + { + sbut = &sbar->sbButtons[i]; + if (sbut->uButType & SBBM_RESIZABLE) + { + sbut->nSize = sbut->nSizeReserved; + } + } + + butsize1 = GetButtonSize(sbar, hwnd, SBBP_LEFT); + butsize2 = GetButtonSize(sbar, hwnd, SBBP_RIGHT); + + if (butsize1 + butsize2 > scrollsize - MINSCROLLSIZE) + { + i = 0; + while(i < sbar->nButtons && + butsize1 + butsize2 > scrollsize - MINSCROLLSIZE) + { + sbut = &sbar->sbButtons[i++]; + if (sbut->uButType & SBBM_RESIZABLE) + { + int oldsize = sbut->nSize; + sbut->nSize -= (butsize1+butsize2) - (scrollsize-MINSCROLLSIZE); + + if (sbut->nSize < (int)sbut->nMinSize) + sbut->nSize = sbut->nMinSize; + + if ((UINT)sbut->nSize > (UINT)sbut->nMaxSize) + sbut->nSize = sbut->nMaxSize; + + + butsize1 -= (oldsize - sbut->nSize); + } + } + } + +} +#endif +#endif + +// +// We must allocate from in the non-client area for our scrollbars +// Call the default window procedure first, to get the borders (if any) +// allocated some space, then allocate the space for the scrollbars +// if they fit +// +static LRESULT NCCalcSize(SCROLLWND *sw, HWND hwnd, WPARAM wParam, LPARAM lParam) +{ + NCCALCSIZE_PARAMS *nccsp; + RECT *rect; + RECT oldrect; + SCROLLBAR *sb; + LRESULT ret; + DWORD dwStyle; + + //Regardless of the value of fCalcValidRects, the first rectangle + //in the array specified by the rgrc structure member of the + //NCCALCSIZE_PARAMS structure contains the coordinates of the window, + //so we can use the exact same code to modify this rectangle, when + //wParam is TRUE and when it is FALSE. + nccsp = (NCCALCSIZE_PARAMS *)lParam; + rect = &nccsp->rgrc[0]; + oldrect = *rect; + + dwStyle = GetWindowLongPtr(hwnd, GWL_STYLE); + + // TURN OFF SCROLL-STYLES. + if ( dwStyle & (WS_VSCROLL|WS_HSCROLL)) + { + sw->bPreventStyleChange = TRUE; + SetWindowLongPtr(hwnd, GWL_STYLE, dwStyle & ~(WS_VSCROLL|WS_HSCROLL)); + } + + //call the default procedure to get the borders allocated + ret = mir_callNextSubclass(hwnd, CoolSBWndProc, WM_NCCALCSIZE, wParam, lParam); + + // RESTORE PREVIOUS STYLES (if present at all) + if ( dwStyle & (WS_VSCROLL|WS_HSCROLL)) + { + SetWindowLongPtr(hwnd, GWL_STYLE, dwStyle); + sw->bPreventStyleChange = FALSE; + } + + // calculate what the size of each window border is, + sw->cxLeftEdge = rect->left - oldrect.left; + sw->cxRightEdge = oldrect.right - rect->right; + sw->cyTopEdge = rect->top - oldrect.top; + sw->cyBottomEdge = oldrect.bottom - rect->bottom; + + sb = &sw->sbarHorz; + + //if there is room, allocate some space for the horizontal scrollbar + //NOTE: Change the ">" to a ">=" to make the horz bar totally fill the + //window before disappearing + if ((sb->fScrollFlags & CSBS_VISIBLE) && +#ifdef COOLSB_FILLWINDOW + rect->bottom - rect->top >= GetScrollMetric(sb, SM_CYHORZSB)) +#else + rect->bottom - rect->top > GetScrollMetric(sb, SM_CYHORZSB)) +#endif + { + rect->bottom -= GetScrollMetric(sb, SM_CYHORZSB); + sb->fScrollVisible = TRUE; + } + else + sb->fScrollVisible = FALSE; + + sb = &sw->sbarVert; + + //if there is room, allocate some space for the vertical scrollbar + if ((sb->fScrollFlags & CSBS_VISIBLE) && + rect->right - rect->left >= GetScrollMetric(sb, SM_CXVERTSB)) + { + if (sw->fLeftScrollbar) + rect->left += GetScrollMetric(sb, SM_CXVERTSB); + else + rect->right -= GetScrollMetric(sb, SM_CXVERTSB); + + sb->fScrollVisible = TRUE; + } + else + sb->fScrollVisible = FALSE; + +#ifdef INCLUDE_BUTTONS +#ifdef RESIZABLE_BUTTONS + ResizeButtonsToFit(sw, &sw->sbarHorz, hwnd); + ResizeButtonsToFit(sw, &sw->sbarVert, hwnd); +#endif +#endif + + //don't return a value unless we actually modify the other rectangles + //in the NCCALCSIZE_PARAMS structure. In this case, we return 0 + //no matter what the value of fCalcValidRects is + return ret;//FALSE; +} + +// +// used for hot-tracking over the scroll buttons +// +static LRESULT NCMouseMove(SCROLLWND *sw, HWND hwnd, WPARAM wHitTest, LPARAM lParam) +{ + //install a timer for the mouse-over events, if the mouse moves + //over one of the scrollbars +#ifdef HOT_TRACKING + hwndCurCoolSB = hwnd; + if (wHitTest == HTHSCROLL) + { + if (uMouseOverScrollbar == SB_HORZ) + return mir_callNextSubclass(hwnd, CoolSBWndProc, WM_NCMOUSEMOVE, wHitTest, lParam); + + uLastHitTestPortion = HTSCROLL_NONE; + uHitTestPortion = HTSCROLL_NONE; + GetScrollRect(sw, SB_HORZ, hwnd, &MouseOverRect); + uMouseOverScrollbar = SB_HORZ; + uMouseOverId = SetTimer(hwnd, COOLSB_TIMERID3, COOLSB_TIMERINTERVAL3, 0); + + NCPaint(sw, hwnd, 1, 0); + } + else if (wHitTest == HTVSCROLL) + { + if (uMouseOverScrollbar == SB_VERT) + return mir_callNextSubclass(hwnd, CoolSBWndProc, WM_NCMOUSEMOVE, wHitTest, lParam); + + uLastHitTestPortion = HTSCROLL_NONE; + uHitTestPortion = HTSCROLL_NONE; + GetScrollRect(sw, SB_VERT, hwnd, &MouseOverRect); + uMouseOverScrollbar = SB_VERT; + uMouseOverId = SetTimer(hwnd, COOLSB_TIMERID3, COOLSB_TIMERINTERVAL3, 0); + + NCPaint(sw, hwnd, 1, 0); + } + +#endif //HOT_TRACKING + return mir_callNextSubclass(hwnd, CoolSBWndProc, WM_NCMOUSEMOVE, wHitTest, lParam); +} + +// +// Timer routine to generate scrollbar messages +// +static LRESULT CoolSB_Timer(SCROLLWND *swnd, HWND hwnd, WPARAM wTimerId, LPARAM lParam) +{ + //let all timer messages go past if we don't have a timer installed ourselves + if (uScrollTimerId == 0 && uMouseOverId == 0) + return mir_callNextSubclass(hwnd, CoolSBWndProc, WM_TIMER, wTimerId, lParam); + +#ifdef HOT_TRACKING + //mouse-over timer + if (wTimerId == COOLSB_TIMERID3) + { + POINT pt; + RECT rect, winrect; + HDC hdc; + SCROLLBAR *sbar; + + if (swnd->fThumbTracking) + return 0; + + //if the mouse moves outside the current scrollbar, + //then kill the timer.. + GetCursorPos(&pt); + + if ( !PtInRect(&MouseOverRect, pt)) + { + KillTimer(hwnd, uMouseOverId); + uMouseOverId = 0; + uMouseOverScrollbar = COOLSB_NONE; + uLastHitTestPortion = HTSCROLL_NONE; + + uHitTestPortion = HTSCROLL_NONE; + NCPaint(swnd, hwnd, 1, 0); + } + else + { + if (uMouseOverScrollbar == SB_HORZ) + { + sbar = &swnd->sbarHorz; + uHitTestPortion = GetHorzPortion(sbar, &MouseOverRect, pt.x, pt.y); + } + else + { + sbar = &swnd->sbarVert; + uHitTestPortion = GetVertPortion(sbar, &MouseOverRect, pt.x, pt.y); + } + + if (uLastHitTestPortion != uHitTestPortion) + { + rect = MouseOverRect; + GetRealScrollRect(sbar, &rect); + + GetWindowRect(hwnd, &winrect); + OffsetRect(&rect, -winrect.left, -winrect.top); + + hdc = GetWindowDC(hwnd); + NCDrawScrollbar(sbar, hwnd, hdc, &rect, HTSCROLL_NONE); + ReleaseDC(hwnd, hdc); + } + + uLastHitTestPortion = uHitTestPortion; + } + + return 0; + } +#endif // HOT_TRACKING + + //if the first timer goes off, then we can start a more + //regular timer interval to auto-generate scroll messages + //this gives a slight pause between first pressing the scroll arrow, and the + //actual scroll starting + if (wTimerId == COOLSB_TIMERID1) + { + KillTimer(hwnd, uScrollTimerId); + uScrollTimerId = SetTimer(hwnd, COOLSB_TIMERID2, COOLSB_TIMERINTERVAL2, 0); + return 0; + } + //send the scrollbar message repeatedly + else if (wTimerId == COOLSB_TIMERID2) + { + //need to process a spoof WM_MOUSEMOVE, so that + //we know where the mouse is each time the scroll timer goes off. + //This is so we can stop sending scroll messages if the thumb moves + //under the mouse. + POINT pt; + GetCursorPos(&pt); + ScreenToClient(hwnd, &pt); + + MouseMove(swnd, hwnd, MK_LBUTTON, MAKELPARAM(pt.x, pt.y)); + + if (uScrollTimerPortion != HTSCROLL_NONE) + SendScrollMessage(hwnd, uScrollTimerMsg, uScrollTimerPortion, 0); + + return 0; + } + + return mir_callNextSubclass(hwnd, CoolSBWndProc, WM_TIMER, wTimerId, lParam); +} + +// +// We must intercept any calls to SetWindowLongPtr, to check if +// left-scrollbars are taking effect or not +// +static LRESULT CoolSB_StyleChange(SCROLLWND *swnd, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + STYLESTRUCT *ss = (STYLESTRUCT *)lParam; + + if (wParam == GWL_EXSTYLE) + { + if (ss->styleNew & WS_EX_LEFTSCROLLBAR) + swnd->fLeftScrollbar = TRUE; + else + swnd->fLeftScrollbar = FALSE; + } + + return mir_callNextSubclass(hwnd, CoolSBWndProc, msg, wParam, lParam); +} + +static UINT curTool = -1; +static LRESULT CoolSB_Notify(SCROLLWND* /*swnd*/, HWND hwnd, WPARAM wParam, LPARAM lParam) +{ +#ifdef COOLSB_TOOLTIPS + + NMTTDISPINFO *nmdi = (NMTTDISPINFO *)lParam; + + if (nmdi->hdr.hwndFrom == swnd->hwndToolTip && + nmdi->hdr.code == TTN_GETDISPINFO) + { + //convert the tooltip notify from a "ISHWND" style + //request to an id-based request. + //We do this because our tooltip is a window-style + //tip, with no tools, and the GETDISPINFO request must + //indicate which button to retrieve the text for + //nmdi->hdr.idFrom = curTool; + nmdi->hdr.idFrom = curTool; + nmdi->hinst = GetModuleHandle(0); + nmdi->uFlags &= ~TTF_IDISHWND; + } +#endif //COOLSB_TOOLTIPS + + return mir_callNextSubclass(hwnd, CoolSBWndProc, WM_NOTIFY, wParam, lParam); +} + +static LRESULT SendToolTipMessage0(HWND hwndTT, UINT message, WPARAM wParam, LPARAM lParam) +{ + return SendMessage(hwndTT, message, wParam, lParam); +} + +#ifdef COOLSB_TOOLTIPS +#define SendToolTipMessage SendToolTipMessage0 +#else +#define SendToolTipMessage 1 ? (void)0 : SendToolTipMessage0 +#endif + + +// +// We must intercept any calls to SetWindowLongPtr, to make sure that +// the user does not set the WS_VSCROLL or WS_HSCROLL styles +// +static LRESULT CoolSB_SetCursor(SCROLLWND* /*swnd*/, HWND hwnd, WPARAM wParam, LPARAM lParam) +{ +#ifdef INCLUDE_BUTTONS + UINT lo = LOWORD(lParam); + UINT hi = HIWORD(lParam); + UINT xy; + RECT rect; + SCROLLBAR *sbar; + SCROLLBUT *sbut; + POINT pt; + UINT id; + static UINT lastid; + +#ifdef HIDE_CURSOR_AFTER_MOUSEUP + static UINT lastmsg; + if (lastmsg == WM_LBUTTONDOWN) + { + lastmsg = hi; + return mir_callNextSubclass(hwnd, CoolSBWndProc, WM_SETCURSOR, wParam, lParam); + } + else + lastmsg = hi; +#endif + + //if we are over either or our scrollbars + if (lo == HTHSCROLL || lo == HTVSCROLL) + { + xy = GetMessagePos(); + pt.x = LOWORD(xy); + pt.y = HIWORD(xy); + + if (lo == HTHSCROLL) + { + sbar = &swnd->sbarHorz; + GetScrollRect(swnd, SB_HORZ, hwnd, &rect); + id = GetHorzPortion(sbar, hwnd, &rect, pt.x, pt.y); + } + else + { + sbar = &swnd->sbarVert; + GetScrollRect(swnd, SB_VERT, hwnd, &rect); + id = GetVertPortion(sbar, hwnd, &rect, pt.x, pt.y); + } + + if (id != HTSCROLL_INSERTED) + { + if (swnd->hwndToolTip != 0) + { + SendToolTipMessage(swnd->hwndToolTip, TTM_ACTIVATE, FALSE, 0); + SendToolTipMessage(swnd->hwndToolTip, TTM_POP, 0, 0); + } + + return mir_callNextSubclass(hwnd, CoolSBWndProc, WM_SETCURSOR, wParam, lParam); + } + + if (swnd->hwndToolTip != 0) + { + SendToolTipMessage(swnd->hwndToolTip, TTM_ACTIVATE, TRUE, 0); + } + + //set the cursor if one has been specified + if ((id = GetButtonFromPt(sbar, &rect, pt, TRUE)) != -1) + { + sbut = &sbar->sbButtons[id]; + curTool = sbut->uCmdId; + + if (lastid != id && swnd->hwndToolTip != 0) + { + if (IsWindowVisible(swnd->hwndToolTip)) + SendToolTipMessage(swnd->hwndToolTip, TTM_UPDATE, TRUE, 0); + } + + lastid = id; + + if (sbut->hCurs != 0) + { + SetCursor(sbut->hCurs); + return 0; + } + } + else + { + curTool = -1; + lastid = -1; + } + } + else if (swnd->hwndToolTip != 0) + { + SendToolTipMessage(swnd->hwndToolTip, TTM_ACTIVATE, FALSE, 0); + SendToolTipMessage(swnd->hwndToolTip, TTM_POP, 0, 0); + } + +#endif //INCLUDE_BUTTONS + return mir_callNextSubclass(hwnd, CoolSBWndProc, WM_SETCURSOR, wParam, lParam); +} + + +// +// Send the specified message to the tooltip control +// +static void __stdcall RelayMouseEvent(HWND hwnd, HWND hwndToolTip, UINT event) +{ +#ifdef COOLSB_TOOLTIPS + MSG msg; + + CoolSB_ZeroMemory(&msg, sizeof(MSG)); + msg.hwnd = hwnd; + msg.message = event; + + SendMessage(hwndToolTip, TTM_RELAYEVENT, 0, (LONG)&msg); +#else + UNREFERENCED_PARAMETER(hwnd); + UNREFERENCED_PARAMETER(hwndToolTip); + UNREFERENCED_PARAMETER(event); +#endif +} + + +// +// CoolScrollbar subclass procedure. +// Handle all messages needed to mimick normal windows scrollbars +// +LRESULT CALLBACK CoolSBWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + SCROLLWND *swnd = GetScrollWndFromHwnd(hwnd); + static int count; + + switch(message) { + case WM_NCDESTROY: + //this should NEVER be called, because the user + //should have called Uninitialize() themselves. + + //However, if the user tries to call Uninitialize().. + //after this window is destroyed, this window's entry in the lookup + //table will not be there, and the call will fail + UninitializeCoolSB(hwnd); + + //we must call the original window procedure, otherwise it + //will never get the WM_NCDESTROY message, and it wouldn't + //be able to clean up etc. + return mir_callNextSubclass(hwnd, CoolSBWndProc, message, wParam, lParam); + + case WM_NCCALCSIZE: + return NCCalcSize(swnd, hwnd, wParam, lParam); + + case WM_NCPAINT: + return NCPaint(swnd, hwnd, wParam, lParam); + + case WM_NCHITTEST: + return NCHitTest(swnd, hwnd, wParam, lParam); + + case WM_NCRBUTTONDOWN: case WM_NCRBUTTONUP: + case WM_NCMBUTTONDOWN: case WM_NCMBUTTONUP: + RelayMouseEvent(hwnd, swnd->hwndToolTip, (WM_MOUSEMOVE-WM_NCMOUSEMOVE) + (message)); + if (wParam == HTHSCROLL || wParam == HTVSCROLL) + return 0; + else + break; + + case WM_NCLBUTTONDBLCLK: + //TRACE("WM_NCLBUTTONDBLCLK %d\n", count++); + if (wParam == HTHSCROLL || wParam == HTVSCROLL) + return NCLButtonDown(swnd, hwnd, wParam, lParam); + else + break; + + case WM_NCLBUTTONDOWN: + //TRACE("WM_NCLBUTTONDOWN%d\n", count++); + RelayMouseEvent(hwnd, swnd->hwndToolTip, WM_LBUTTONDOWN); + return NCLButtonDown(swnd, hwnd, wParam, lParam); + + + case WM_LBUTTONUP: + //TRACE("WM_LBUTTONUP %d\n", count++); + RelayMouseEvent(hwnd, swnd->hwndToolTip, WM_LBUTTONUP); + return LButtonUp(swnd, hwnd, wParam, lParam); + + case WM_NOTIFY: + return CoolSB_Notify(swnd, hwnd, wParam, lParam); + + //Mouse moves are received when we set the mouse capture, + //even when the mouse moves over the non-client area + case WM_MOUSEMOVE: + //TRACE("WM_MOUSEMOVE %d\n", count++); + return MouseMove(swnd, hwnd, wParam, lParam); + + case WM_TIMER: + return CoolSB_Timer(swnd, hwnd, wParam, lParam); + + //case WM_STYLECHANGING: + // return CoolSB_StyleChange(swnd, hwnd, WM_STYLECHANGING, wParam, lParam); + case WM_STYLECHANGED: + + if (swnd->bPreventStyleChange) + { + // the NCPAINT handler has told us to eat this message! + return 0; + } + else + { + if (message == WM_STYLECHANGED) + return CoolSB_StyleChange(swnd, hwnd, WM_STYLECHANGED, wParam, lParam); + else + break; + } + + case WM_NCMOUSEMOVE: + { + static LONG_PTR lastpos = -1; + + //TRACE("WM_NCMOUSEMOVE %d\n", count++); + + //The problem with NCMOUSEMOVE is that it is sent continuously + //even when the mouse is stationary (under win2000 / win98) + // + //Tooltips don't like being sent a continous stream of mouse-moves + //if the cursor isn't moving, because they will think that the mouse + //is moving position, and the internal timer will never expire + // + if (lastpos != lParam) + { + RelayMouseEvent(hwnd, swnd->hwndToolTip, WM_MOUSEMOVE); + lastpos = lParam; + } + } + + return NCMouseMove(swnd, hwnd, wParam, lParam); + + + case WM_SETCURSOR: + return CoolSB_SetCursor(swnd, hwnd, wParam, lParam); + + case WM_CAPTURECHANGED: + break; + + default: + break; + } + + return mir_callNextSubclass(hwnd, CoolSBWndProc, message, wParam, lParam); +} + diff --git a/plugins/Clist_nicer/src/coolscroll.h b/plugins/Clist_nicer/src/coolscroll.h new file mode 100644 index 0000000000..c5fe848a83 --- /dev/null +++ b/plugins/Clist_nicer/src/coolscroll.h @@ -0,0 +1,232 @@ +#ifndef _COOLSBLIB_INCLUDED +#define _COOLSBLIB_INCLUDED + +#ifdef __cplusplus +extern "C"{ +#endif + +#include +#include + +// To complement the exisiting SB_HORZ, SB_VERT, SB_BOTH +// scrollbar identifiers +#define COOLSB_NONE (-1) +#define SB_INSBUT (-2) + +// +// Arrow size defines +// +#define SYSTEM_METRIC (-1) + + +// +// general scrollbar styles +// +// use the standard ESB_DISABLE_xxx flags to represent the +// enabled / disabled states. (defined in winuser.h) +// +#define CSBS_THUMBALWAYS 4 +#define CSBS_VISIBLE 8 + +//cool scrollbar styles for Flat scrollbars +#define CSBS_NORMAL 0 +#define CSBS_FLAT 1 +#define CSBS_HOTTRACKED 2 + +// +// Button mask flags for indicating which members of SCROLLBUT +// to use during a button insertion / modification +// +#define SBBF_TYPE 0x0001 +#define SBBF_ID 0x0002 +#define SBBF_PLACEMENT 0x0004 +#define SBBF_SIZE 0x0008 +#define SBBF_BITMAP 0x0010 +#define SBBF_ENHMETAFILE 0x0020 +//#define SBBF_OWNERDRAW 0x0040 //unused at present +#define SBBF_CURSOR 0x0080 +#define SBBF_BUTMINMAX 0x0100 +#define SBBF_STATE 0x0200 + +//button styles (states) +#define SBBS_NORMAL 0 +#define SBBS_PUSHED 1 +#define SBBS_CHECKED SBBS_PUSHED + +// +// scrollbar button types +// +#define SBBT_PUSHBUTTON 1 //standard push button +#define SBBT_TOGGLEBUTTON 2 //toggle button +#define SBBT_FIXED 3 //fixed button (non-clickable) +#define SBBT_FLAT 4 //blank area (flat, with border) +#define SBBT_BLANK 5 //blank area (flat, no border) +#define SBBT_DARK 6 //dark blank area (flat) +#define SBBT_OWNERDRAW 7 //user draws the button via a WM_NOTIFY + +#define SBBT_MASK 0x1f //mask off low 5 bits + +//button type modifiers +#define SBBM_RECESSED 0x0020 //recessed when clicked (like Word 97) +#define SBBM_LEFTARROW 0x0040 +#define SBBM_RIGHTARROW 0x0080 +#define SBBM_UPARROW 0x0100 +#define SBBM_DOWNARROW 0x0200 +#define SBBM_RESIZABLE 0x0400 +#define SBBM_TYPE2 0x0800 +#define SBBM_TYPE3 0x1000 +#define SBBM_TOOLTIPS 0x2000 //currently unused (define COOLSB_TOOLTIPS in userdefs.h) + +//button placement flags +#define SBBP_LEFT 1 +#define SBBP_RIGHT 2 +#define SBBP_TOP 1 //3 +#define SBBP_BOTTOM 2 //4 + + +// +// Button command notification codes +// for sending with a WM_COMMAND message +// +#define CSBN_BASE 0 +#define CSBN_CLICKED (1 + CSBN_BASE) +#define CSBN_HILIGHT (2 + CSBN_BASE) + +// +// Minimum size in pixels of a scrollbar thumb +// +#define MINTHUMBSIZE_NT4 8 +#define MINTHUMBSIZE_2000 6 + +//define some more hittest values for our cool-scrollbar +#define HTSCROLL_LEFT (SB_LINELEFT) +#define HTSCROLL_RIGHT (SB_LINERIGHT) +#define HTSCROLL_UP (SB_LINEUP) +#define HTSCROLL_DOWN (SB_LINEDOWN) +#define HTSCROLL_THUMB (SB_THUMBTRACK) +#define HTSCROLL_PAGEGUP (SB_PAGEUP) +#define HTSCROLL_PAGEGDOWN (SB_PAGEDOWN) +#define HTSCROLL_PAGELEFT (SB_PAGELEFT) +#define HTSCROLL_PAGERIGHT (SB_PAGERIGHT) + +#define HTSCROLL_NONE (-1) +#define HTSCROLL_NORMAL (-1) + +#define HTSCROLL_INSERTED (128) +#define HTSCROLL_PRE (32 | HTSCROLL_INSERTED) +#define HTSCROLL_POST (64 | HTSCROLL_INSERTED) + +/* + + Public interface to the Cool Scrollbar library + + +*/ + +BOOL WINAPI InitializeCoolSB(HWND hwnd); +HRESULT WINAPI UninitializeCoolSB (HWND hwnd); + +BOOL WINAPI CoolSB_SetMinThumbSize(HWND hwnd, UINT wBar, UINT size); +BOOL WINAPI CoolSB_IsThumbTracking(HWND hwnd); +BOOL WINAPI CoolSB_IsCoolScrollEnabled(HWND hwnd); + +// +BOOL WINAPI CoolSB_EnableScrollBar (HWND hwnd, int wSBflags, UINT wArrows); +BOOL WINAPI CoolSB_GetScrollInfo (HWND hwnd, int fnBar, LPSCROLLINFO lpsi); +int WINAPI CoolSB_GetScrollPos (HWND hwnd, int nBar); +BOOL WINAPI CoolSB_GetScrollRange (HWND hwnd, int nBar, LPINT lpMinPos, LPINT lpMaxPos); + +// +int WINAPI CoolSB_SetScrollInfo (HWND hwnd, int fnBar, LPSCROLLINFO lpsi, BOOL fRedraw); +int WINAPI CoolSB_SetScrollPos (HWND hwnd, int nBar, int nPos, BOOL fRedraw); +int WINAPI CoolSB_SetScrollRange (HWND hwnd, int nBar, int nMinPos, int nMaxPos, BOOL fRedraw); +BOOL WINAPI CoolSB_ShowScrollBar (HWND hwnd, int wBar, BOOL fShow); + +// +// Scrollbar dimension functions +// +BOOL WINAPI CoolSB_SetSize (HWND hwnd, int wBar, int nLength, int nWidth); + +// +// Set the visual nature of a scrollbar (flat, normal etc) +// +BOOL WINAPI CoolSB_SetStyle (HWND hwnd, int wBar, UINT nStyle); +BOOL WINAPI CoolSB_SetThumbAlways (HWND hwnd, int wBar, BOOL fThumbAlways); + +// +// Scrollbar button structure, for inserted buttons only +// +typedef struct +{ + UINT fMask; //which members are in use + UINT uPlacement; //is this button to the left/right (above/below) of the scrollbar?? + UINT uCmdId; //command identifier (WM_COMMAND value to send) + UINT uButType; // + UINT uState; //toggled etc + int nSize; //size in pixels. -1 for autosize + + HBITMAP hBmp; //handle to a bitmap to use as the button face + HENHMETAFILE hEmf; //handle to an enhanced metafile + + HCURSOR hCurs; //handle to a user-supplied mouse cursor to apply + //to this button + + int nSizeReserved; //internal variable used for resizing + int nMinSize; //min size + int nMaxSize; //max size + +} SCROLLBUT; + +BOOL WINAPI CoolSB_InsertButton(HWND hwnd, int wSBflags, UINT nPos, SCROLLBUT *psb); +BOOL WINAPI CoolSB_ModifyButton(HWND hwnd, int wSBflags, UINT uItem, BOOL fByCmd, SCROLLBUT *psb); +BOOL WINAPI CoolSB_RemoveButton(HWND hwnd, int wSBflags, UINT uItem, BOOL fByCmd); +BOOL WINAPI CoolSB_GetButton (HWND hwnd, int wSBflags, UINT uItem, BOOL fByCmd, SCROLLBUT *psb); + +void WINAPI CoolSB_SetESBProc(void *proc); + +typedef struct +{ + NMHDR hdr; + DWORD dwDrawStage; + HDC hdc; + RECT rect; + UINT uItem; + UINT uState; + UINT nBar; + +} NMCSBCUSTOMDRAW; + +typedef struct +{ + NMHDR hdr; + RECT rect; + POINT pt; + UINT uCmdId; + UINT uState; + int nBar; +} NMCOOLBUTMSG; + +/* +typedef struct +{ + NMHDR hdr; + DWORD dwDrawStage; + HDC hdc; + RECT rect; + UINT uCmdId; + UINT uState; + +} NMCOOLBUTTON_CUSTOMDRAW; +*/ + + +// +// Define the WM_NOTIFY code value for cool-scrollbar custom drawing +// +#define NM_COOLSB_CUSTOMDRAW (0-0xfffU) + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/plugins/Clist_nicer/src/extBackg.cpp b/plugins/Clist_nicer/src/extBackg.cpp index 937a550431..aad2b8689c 100644 --- a/plugins/Clist_nicer/src/extBackg.cpp +++ b/plugins/Clist_nicer/src/extBackg.cpp @@ -22,8 +22,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include -#include "../coolsb/coolscroll.h" +#include "stdafx.h" +#include "coolscroll.h" extern int g_hottrack; diff --git a/plugins/Clist_nicer/src/extBackg.h b/plugins/Clist_nicer/src/extBackg.h new file mode 100644 index 0000000000..9b98c283ee --- /dev/null +++ b/plugins/Clist_nicer/src/extBackg.h @@ -0,0 +1,97 @@ +/* + +Miranda NG: the free IM client for Microsoft* Windows* + +Copyright (ñ) 2012-15 Miranda NG project (http://miranda-ng.org), +Copyright (c) 2000-03 Miranda ICQ/IM 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. +*/ + +#define ID_EXTBKIDLE 40081 +#define ID_EXTBKEXPANDEDGROUP 40082 +#define ID_EXTBKCOLLAPSEDDGROUP 40083 +#define ID_EXTBKEMPTYGROUPS 40084 +#define ID_EXTBKFIRSTITEM 40085 +#define ID_EXTBKSINGLEITEM 40086 +#define ID_EXTBKLASTITEM 40087 + + +#define ID_EXTBKFIRSTITEM_NG 40088 +#define ID_EXTBKSINGLEITEM_NG 40089 +#define ID_EXTBKLASTITEM_NG 40090 + +#define ID_EXTBKEVEN_CNTCTPOS 40091 +#define ID_EXTBKODD_CNTCTPOS 40092 + +#define ID_EXTBKSELECTION 40093 +#define ID_EXTBKHOTTRACK 40094 +#define ID_EXTBKFRAMETITLE 40095 +#define ID_EXTBKEVTAREA 40096 +#define ID_EXTBKSTATUSBAR 40097 +#define ID_EXTBKBUTTONBAR 40098 +#define ID_EXTBKBUTTONSPRESSED 40099 +#define ID_EXTBKBUTTONSNPRESSED 40100 +#define ID_EXTBKBUTTONSMOUSEOVER 40101 +#define ID_EXTBKTBBUTTONSPRESSED 40102 +#define ID_EXTBKTBBUTTONSNPRESSED 40103 +#define ID_EXTBKTBBUTTONMOUSEOVER 40104 +#define ID_EXTBKSTATUSFLOATER 40105 +#define ID_EXTBKOWNEDFRAMEBORDER 40106 +#define ID_EXTBKOWNEDFRAMEBORDERTB 40107 +#define ID_EXTBKAVATARFRAME 40108 +#define ID_EXTBKAVATARFRAMEOFFLINE 40109 +#define ID_EXTBKSCROLLBACK 40110 +#define ID_EXTBKSCROLLBACKLOWER 40111 +#define ID_EXTBKSCROLLTHUMB 40112 +#define ID_EXTBKSCROLLTHUMBHOVER 40113 +#define ID_EXTBKSCROLLTHUMBPRESSED 40114 +#define ID_EXTBKSCROLLBUTTON 40115 +#define ID_EXTBKSCROLLBUTTONHOVER 40116 +#define ID_EXTBKSCROLLBUTTONPRESSED 40117 +#define ID_EXTBKSCROLLARROWUP 40118 +#define ID_EXTBKSCROLLARROWDOWN 40119 +#define ID_EXTBK_LAST_D 40119 + +#define ID_EXTBKSEPARATOR 40200 + +BOOL CheckItem(int item, HWND hwndDlg); +BOOL isValidItem(void); +void extbk_export(const TCHAR *file); +void extbk_import(const TCHAR *file, HWND hwndDlg); + +void LoadExtBkSettingsFromDB(); +void IMG_LoadItems(); +void __fastcall IMG_RenderImageItem(HDC hdc, ImageItem *item, RECT *rc); +void IMG_InitDecoder(); +void LoadPerContactSkins(const TCHAR *file); + +static void SaveCompleteStructToDB(); +StatusItems_t *GetProtocolStatusItem(const char *szProto); + +void OnListItemsChange(HWND hwndDlg); + +void UpdateStatusStructSettingsFromOptDlg(HWND hwndDlg, int index); + +void SaveNonStatusItemsSettings(HWND hwndDlg); + +void FillItemList(HWND hwndDlg); +void FillOptionDialogByCurrentSel(HWND hwndDlg); +void ReActiveCombo(HWND hwndDlg); +//BOOL __fastcall GetItemByStatus(int status, StatusItems_t *retitem); + +void FillOptionDialogByStatusItem(HWND hwndDlg, StatusItems_t *item); diff --git a/plugins/Clist_nicer/src/groupmenu.cpp b/plugins/Clist_nicer/src/groupmenu.cpp new file mode 100644 index 0000000000..a3be204ae6 --- /dev/null +++ b/plugins/Clist_nicer/src/groupmenu.cpp @@ -0,0 +1,288 @@ +/* + +Miranda NG: the free IM client for Microsoft* Windows* + +Copyright (ñ) 2012-15 Miranda NG project (http://miranda-ng.org), +Copyright (c) 2000-08 Miranda ICQ/IM 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" + +///////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////// Group MENU ////////////////////////////// + +HGENMENU hGroupMainMenuItemProxy; +HGENMENU hHideShowMainMenuItem; +HGENMENU hGroupStatusMenuItemProxy; +HGENMENU hAppearanceMenuItemProxy; +HGENMENU hEventAreaMenuItemProxy; + +static HMENU hMenuOldContext; + +HGENMENU hHideOfflineUsersMenuItem; +HGENMENU hHideOfflineUsersOutHereMenuItem; +HGENMENU hHideEmptyGroupsMenuItem; +HGENMENU hDisableGroupsMenuItem; +HGENMENU hNewGroupMenuItem; +HGENMENU hNewSubGroupMenuItem; + +void InitSubGroupMenus(void); + +INT_PTR GroupMenu_OnAddService(WPARAM wParam, LPARAM lParam) +{ + MENUITEMINFO *mii = (MENUITEMINFO*)wParam; + if (mii == NULL) + return 0; + + if (hHideShowMainMenuItem == (HANDLE)lParam) { + mii->fMask |= MIIM_STATE; + mii->fState |= MFS_DEFAULT; + + } + if (hGroupMainMenuItemProxy == (HANDLE)lParam) { + mii->fMask |= MIIM_SUBMENU; + mii->hSubMenu = Menu_GetMainMenu(); + } + + if (hGroupStatusMenuItemProxy == (HANDLE)lParam) { + mii->fMask |= MIIM_SUBMENU; + mii->hSubMenu = Menu_GetStatusMenu(); + } + if (hAppearanceMenuItemProxy == (HANDLE)lParam) { + hMenuOldContext = GetSubMenu(LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_CONTEXT)), 3); + TranslateMenu(hMenuOldContext); + + CheckMenuItem(hMenuOldContext, POPUP_FRAME, MF_BYCOMMAND | (cfg::dat.dwFlags & CLUI_FRAME_CLISTSUNKEN ? MF_CHECKED : MF_UNCHECKED)); + CheckMenuItem(hMenuOldContext, POPUP_BUTTONS, MF_BYCOMMAND | (cfg::dat.dwFlags & CLUI_FRAME_SHOWBOTTOMBUTTONS ? MF_CHECKED : MF_UNCHECKED)); + CheckMenuItem(hMenuOldContext, POPUP_SHOWMETAICONS, MF_BYCOMMAND | (cfg::dat.dwFlags & CLUI_USEMETAICONS ? MF_CHECKED : MF_UNCHECKED)); + CheckMenuItem(hMenuOldContext, POPUP_SHOWSTATUSICONS, MF_BYCOMMAND | (cfg::dat.dwFlags & CLUI_FRAME_STATUSICONS ? MF_CHECKED : MF_UNCHECKED)); + + mii->fMask |= MIIM_SUBMENU; + mii->hSubMenu = hMenuOldContext; + } + return TRUE; +} + +INT_PTR HideGroupsHelper(WPARAM, LPARAM) +{ + int newVal = !(GetWindowLongPtr(pcli->hwndContactTree, GWL_STYLE) & CLS_HIDEEMPTYGROUPS); + cfg::writeByte("CList", "HideEmptyGroups", (BYTE)newVal); + SendMessage(pcli->hwndContactTree, CLM_SETHIDEEMPTYGROUPS, newVal, 0); + return 0; +} + +INT_PTR UseGroupsHelper(WPARAM, LPARAM) +{ + int newVal = !(GetWindowLongPtr(pcli->hwndContactTree, GWL_STYLE) & CLS_USEGROUPS); + cfg::writeByte("CList", "UseGroups", (BYTE)newVal); + SendMessage(pcli->hwndContactTree, CLM_SETUSEGROUPS, newVal,0); + return 0; +} + +INT_PTR HideOfflineRootHelper(WPARAM, LPARAM) +{ + SendMessage(pcli->hwndContactTree, CLM_SETHIDEOFFLINEROOT, !SendMessage(pcli->hwndContactTree, CLM_GETHIDEOFFLINEROOT, 0, 0), 0); + return 0; +} + +static int OnBuildGroupMenu(WPARAM, LPARAM) +{ + bool bEnabled = 0 != cfg::getByte("CList", "HideOffline", SETTING_HIDEOFFLINE_DEFAULT); + Menu_EnableItem(hHideOfflineUsersMenuItem, bEnabled); + + bEnabled = 0 != SendMessage(pcli->hwndContactTree, CLM_GETHIDEOFFLINEROOT, 0, 0); + Menu_EnableItem(hHideOfflineUsersOutHereMenuItem, bEnabled); + + bEnabled = 0 != (GetWindowLongPtr(pcli->hwndContactTree, GWL_STYLE) & CLS_HIDEEMPTYGROUPS); + Menu_EnableItem(hHideEmptyGroupsMenuItem, bEnabled); + + bEnabled = 0 != (GetWindowLongPtr(pcli->hwndContactTree, GWL_STYLE) & CLS_USEGROUPS); + Menu_EnableItem(hDisableGroupsMenuItem, bEnabled); + + Menu_EnableItem(hGroupMainMenuItemProxy, bEnabled); + Menu_EnableItem(hAppearanceMenuItemProxy, bEnabled); + return 0; +} + +IconItemT iconItem[] = { + { LPGENT("New group"), "new_group", IDI_ADDGROUP }, + { LPGENT("Contact list"), "clist", IDI_CLIST } +}; + +void InitIconLibMenuIcons(void) +{ + Icon_RegisterT(g_hInst, LPGENT("Contact list"), iconItem, _countof(iconItem)); +} + +void InitGroupMenus(void) +{ + CreateServiceFunction("CLISTMENUSGroup/GroupMenuOnAddService", GroupMenu_OnAddService); + CreateServiceFunction("CLISTMENUSGroup/HideGroupsHelper", HideGroupsHelper); + CreateServiceFunction("CLISTMENUSGroup/UseGroupsHelper", UseGroupsHelper); + CreateServiceFunction("CLISTMENUSGroup/HideOfflineRootHelper", HideOfflineRootHelper); + + HookEvent(ME_CLIST_PREBUILDGROUPMENU, OnBuildGroupMenu); + + InitSubGroupMenus(); + + // add exit command to menu + GroupMenuParam gmp; + + CMenuItem mi; + mi.position = 1900000; + mi.pszService = "CloseAction"; + mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_EXIT); + mi.name.a = LPGEN("E&xit"); + Menu_AddGroupMenuItem(&mi); + + mi.position = 500; + mi.pszService = MS_CLIST_SHOWHIDE; + mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_SHOWHIDE); + mi.name.a = LPGEN("&Hide/show"); + hHideShowMainMenuItem = Menu_AddGroupMenuItem(&mi); + + mi.position = 200000; + mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_FINDUSER); + mi.pszService = "FindAdd/FindAddCommand"; + mi.name.a = LPGEN("&Find/add contacts..."); + Menu_AddGroupMenuItem(&mi); + + mi.position = 300000; + mi.pszService = ""; + mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_MAINMENU); + mi.name.a = LPGEN("&Main menu"); + hGroupMainMenuItemProxy = Menu_AddGroupMenuItem(&mi); + + mi.position = 300100; + mi.pszService = ""; + mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_STATUS); + mi.name.a = LPGEN("&Status"); + hGroupStatusMenuItemProxy = Menu_AddGroupMenuItem(&mi); + + mi.position = 390100; + mi.hIcolibItem = iconItem[1].hIcolib; + mi.name.a = LPGEN("Appearance"); + hAppearanceMenuItemProxy = Menu_AddGroupMenuItem(&mi); + + mi.position = 400000; + mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_OPTIONS); + mi.pszService = "Options/OptionsCommand"; + mi.name.a = LPGEN("&Options..."); + Menu_AddGroupMenuItem(&mi); + + mi.position = 500000; + mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_MIRANDA); + mi.pszService = "CLN/About"; + mi.name.a = LPGEN("&About the contact list..."); + Menu_AddGroupMenuItem(&mi); + + mi.flags = 0; + mi.position = 100000; + mi.hIcolibItem = iconItem[0].hIcolib; + mi.pszService = "CLISTMENUSSubGroup/GroupMenuExecProxy"; + mi.name.a = LPGEN("&New group"); + hNewGroupMenuItem = Menu_AddGroupMenuItem(&mi, &gmp); + + mi.position = 100001; + mi.hIcolibItem = NULL; + mi.hIcolibItem = NULL; + mi.pszService = MS_CLIST_SETHIDEOFFLINE; + mi.name.a = LPGEN("&Hide offline users"); + gmp.wParam = -1; + hHideOfflineUsersMenuItem = Menu_AddGroupMenuItem(&mi, &gmp); + + mi.position = 100002; + mi.pszService = "CLISTMENUSGroup/HideOfflineRootHelper"; + mi.name.a = LPGEN("Hide &offline users out here"); + hHideOfflineUsersOutHereMenuItem = Menu_AddGroupMenuItem(&mi); + + mi.position = 100003; + mi.pszService = "CLISTMENUSGroup/HideGroupsHelper"; + mi.name.a = LPGEN("Hide &empty groups"); + hHideEmptyGroupsMenuItem = Menu_AddGroupMenuItem(&mi); + + mi.position = 100004; + mi.pszService = "CLISTMENUSGroup/UseGroupsHelper"; + mi.name.a = LPGEN("Disable &groups"); + hDisableGroupsMenuItem = Menu_AddGroupMenuItem(&mi); +} + +//////////////////////////////SubGroup MENU///////////////////////// +HANDLE hSubGroupMainMenuItemProxy; +HANDLE hSubGroupStatusMenuItemProxy; +HANDLE hPreBuildSubGroupMenuEvent; +HGENMENU hHideOfflineUsersHereMenuItem; + +static int OnBuildSubGroupMenu(WPARAM wParam, LPARAM) +{ + ClcGroup *group = (ClcGroup*)wParam; + if (group != 0) // contact->group + Menu_ModifyItem(hHideOfflineUsersHereMenuItem, NULL, INVALID_HANDLE_VALUE, group->hideOffline ? CMIF_CHECKED : 0); + return 0; +} + +// wparam menu handle to pass to clc.c +INT_PTR GroupMenuExecProxy(WPARAM wParam, LPARAM) +{ + SendMessage(pcli->hwndContactTree, WM_COMMAND, wParam, 0); + return 0; +} + +void InitSubGroupMenus(void) +{ + CreateServiceFunction("CLISTMENUSSubGroup/GroupMenuExecProxy", GroupMenuExecProxy); + + HookEvent(ME_CLIST_PREBUILDSUBGROUPMENU, OnBuildSubGroupMenu); + + // add exit command to menu + GroupMenuParam gmp = {}; + + CMenuItem mi; + mi.position = 1000; + mi.hIcolibItem = iconItem[0].hIcolib; + mi.pszService = "CLISTMENUSSubGroup/GroupMenuExecProxy"; + mi.name.a = LPGEN("&New subgroup"); + gmp.wParam = POPUP_NEWSUBGROUP; + hNewSubGroupMenuItem = Menu_AddSubGroupMenuItem(&mi, &gmp); + + mi.position = 1001; + mi.hIcolibItem = NULL; + mi.hIcolibItem = NULL; + mi.pszService = "CLISTMENUSSubGroup/GroupMenuExecProxy"; + mi.name.a = LPGEN("&Hide offline users in here"); + gmp.wParam = POPUP_GROUPHIDEOFFLINE; + hHideOfflineUsersHereMenuItem = (HGENMENU)Menu_AddSubGroupMenuItem(&mi, &gmp); + + memset(&mi, 0, sizeof(mi)); + mi.position = 900001; + mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_RENAME); + mi.pszService = "CLISTMENUSSubGroup/GroupMenuExecProxy"; + mi.name.a = LPGEN("&Rename group"); + gmp.wParam = POPUP_RENAMEGROUP; + Menu_AddSubGroupMenuItem(&mi, &gmp); + + mi.position = 900002; + mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_DELETE); + mi.pszService = "CLISTMENUSSubGroup/GroupMenuExecProxy"; + mi.name.a = LPGEN("&Delete group"); + gmp.wParam = POPUP_DELETEGROUP; + Menu_AddSubGroupMenuItem(&mi, &gmp); +} + +//////////////////////////////END SubGroup MENU///////////////////////// diff --git a/plugins/Clist_nicer/src/init.cpp b/plugins/Clist_nicer/src/init.cpp index b785b163e3..462ada6ea0 100644 --- a/plugins/Clist_nicer/src/init.cpp +++ b/plugins/Clist_nicer/src/init.cpp @@ -22,8 +22,10 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include -#include "../cluiframes/cluiframes.h" +#include "stdafx.h" +#include "cluiframes.h" + +#pragma comment(lib, "shlwapi.lib") HINSTANCE g_hInst = 0; CLIST_INTERFACE *pcli, coreCli; diff --git a/plugins/Clist_nicer/src/resource.h b/plugins/Clist_nicer/src/resource.h new file mode 100644 index 0000000000..abb763ae2e --- /dev/null +++ b/plugins/Clist_nicer/src/resource.h @@ -0,0 +1,390 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by ..\res\resource.rc +// +#define IDD_OPT_VIEWMODES 1 +#define IDD_OPT_SKIN 4 +#define IDD_QUICKIGNORE 5 +#define IDD_OPT 6 +#define IDD_EXCEPTION 20 +#define IDD_OPTIONSDIALOG 101 +#define IDD_CLNABOUT 102 +#define IDD_OPT_CLIST 126 +#define IDI_ADDGROUP 143 +#define IDI_CLIST 146 +#define IDI_OPTIONS 163 +#define IDI_DELETE 175 +#define IDI_CLVM_OPTIONS 176 +#define IDI_CLVM_SELECT 177 +#define IDR_CONTEXT 180 +#define IDC_DROP 183 +#define IDR_CLISTMENU 199 +#define IDI_BLANK 200 +#define IDI_ADDCONTACT 210 +#define IDC_HYPERLINKHAND 214 +#define IDC_DROPUSER 215 +#define IDD_OPT_CLUI 218 +#define IDD_OPT_ICONS 220 +#define IDD_OPT_CLC 228 +#define IDD_OPT_CLCBKG 230 +#define IDD_OPT_SBAR 234 +#define IDD_DELETECONTACT 254 +#define IDD_OPT_DSPADVANCED 301 +#define IDD_OPT_DSPITEMS 302 +#define IDD_OPT_DSPGROUPS 303 +#define IDC_ACTIVEPERC 1000 +#define IDC_OPTIONSTAB 1000 +#define IDC_ALWAYSSTATUS 1009 +#define IDC_APPLY 1011 +#define IDC_AUTOSIZE 1013 +#define IDC_AUTOSIZEUPWARD 1014 +#define IDC_AVATARSIZESPIN 1015 +#define IDC_SKINMODE 1020 +#define IDC_FULLTRANSPARENT 1020 +#define IDC_STATUSICONSCENTERED 1020 +#define IDC_NOTRAYINFOTIPS 1020 +#define IDC_SHOWXSTATUS 1020 +#define IDC_AUTOCLEAR 1020 +#define IDC_FLT_SIMPLELAYOUT 1020 +#define IDC_USESKIN 1020 +#define IDC_IGN_MSGEVENTS 1020 +#define IDC_AUTOCLEARVAL 1021 +#define IDC_MARKLOCKED 1021 +#define IDC_IGN_FILEEVENTS 1021 +#define IDC_AUTOCLEARSPIN 1022 +#define IDC_IGN_URLEVENTS 1022 +#define IDC_LASTMSG 1023 +#define IDC_IGN_AUTH 1023 +#define IDC_IGN_ADD 1024 +#define IDC_CONFIRMDELETE 1025 +#define IDC_IGN_ONLINE 1025 +#define IDC_IGN_ALWAYSONLINE 1026 +#define IDC_IGN_ALWAYSOFFLINE 1027 +#define IDC_IGN_PRIORITY 1028 +#define IDC_DISABLEGROUPS 1030 +#define IDC_DROPSHADOW 1035 +#define IDC_EQUALSELECTION 1040 +#define IDC_USEPERPROTO 1041 +#define IDC_OVERRIDEPERSTATUSCOLOR 1042 +#define IDC_EVENTAREASUNKEN 1043 +#define IDC_SETALLBUTTONSKINNED 1043 +#define IDC_EVENTSONTOP 1044 +#define IDC_FASTGRADIENT 1044 +#define IDC_DONTSEPARATE 1045 +#define IDC_FADEINOUT 1056 +#define IDC_FRAMEGAP 1064 +#define IDC_FRAMEGAPSPIN 1065 +#define IDC_CLIPBORDER 1066 +#define IDC_FULLROWSELECT 1067 +#define IDC_CLIPBORDERSPIN 1067 +#define IDC_LOCALTIME 1068 +#define IDC_CLEFT 1070 +#define IDC_CLEFTSPIN 1071 +#define IDC_GREYOUT 1072 +#define IDC_CTOP 1072 +#define IDC_ONTOP 1074 +#define IDC_SHOWMAINMENU 1075 +#define IDC_CLIENTDRAG 1076 +#define IDC_HIDEEMPTYGROUPS 1077 +#define IDC_CTOPSPIN 1077 +#define IDC_CBOTTOM 1078 +#define IDC_CBOTTOMSPIN 1079 +#define IDC_CRIGHT 1080 +#define IDC_HIDEOFFLINE 1081 +#define IDC_CRIGHTSPIN 1081 +#define IDC_HIDEOFFLINEOPTS 1082 +#define IDC_LEFTMARGINSPIN 1092 +#define IDC_NOGROUPICON 1102 +#define IDC_ONECLK 1105 +#define IDC_RIGHTMARGIN 1121 +#define IDC_ROWGAP 1122 +#define IDC_TRANSPARENT 1124 +#define IDC_ROWHEIGHT 1125 +#define IDC_TRANSINACTIVE 1126 +#define IDC_GROUPROWHEIGHT 1126 +#define IDC_TRANSACTIVE 1128 +#define IDC_PROFILELIST 1134 +#define IDC_CLASSLIST 1135 +#define IDC_SELBLEND 1140 +#define IDC_SHOWBOTTOMBUTTONS 1148 +#define IDC_STATIC11 1154 +#define IDC_STATIC12 1155 +#define IDC_STATIC21 1156 +#define IDC_STATIC13 1156 +#define IDC_STATIC22 1157 +#define IDC_STATIC14 1157 +#define IDC_STATIC15 1158 +#define IDC_SHOWGRIP 1169 +#define IDC_SKINBACKGROUND 1170 +#define IDC_FILLWALLPAPER 1171 +#define IDC_SHOWMETA 1172 +#define IDC_CENTERGROUPNAMES 1173 +#define IDC_APPLYINDENTBG 1174 +#define IDC_COPYRIGHT 1178 +#define IDC_VERSION 1179 +#define IDC_SHOWSTATUSICONS 1180 +#define IDC_BROWSE 1184 +#define IDC_INACTIVEPERC 1187 +#define IDC_SHOWSTATUSMSG 1188 +#define IDC_SHOWLOCALTIME 1189 +#define IDC_SHOWLOCALTIMEONLYWHENDIFFERENT 1191 +#define IDC_TITLETEXT 1196 +#define IDC_EXCEPTION_DETAILS 1200 +#define IDC_COPY_EXCEPTION 1201 +#define IDC_EX_REASON 1202 +#define IDC_TILEH 1208 +#define IDC_WHITERECT 1225 +#define IDC_AUTOHIDE 1235 +#define IDC_HIDETIME 1236 +#define IDC_ALWAYSHIDEONTASKBAR 1237 +#define IDC_IMPORT 1241 +#define IDC_MAXSIZEHEIGHT 1254 +#define IDC_MAXSIZESPIN 1255 +#define IDC_BKGCOLOUR 1269 +#define IDC_FILENAME 1271 +#define IDC_SCROLL 1277 +#define IDC_PROPORTIONAL 1278 +#define IDC_SMOOTHTIME 1283 +#define IDC_SMOOTHTIMESPIN 1284 +#define IDC_ROWHEIGHTSPIN 1286 +#define IDC_GROUPROWHEIGHTSPIN 1287 +#define IDC_GREYOUTOPTS 1288 +#define IDC_GROUPINDENT 1289 +#define IDC_GROUPINDENTSPIN 1290 +#define IDC_LEFTMARGIN 1291 +#define IDC_RIGHTMARGINSPIN 1294 +#define IDC_ROWGAPSPIN 1295 +#define IDC_STRETCHH 1298 +#define IDC_STRETCHV 1299 +#define IDC_TILEV 1301 +#define IDC_DONTCYCLE 1315 +#define IDC_PRIMARYSTATUS 1316 +#define IDC_CYCLE 1317 +#define IDC_CYCLETIME 1318 +#define IDC_CYCLETIMESPIN 1319 +#define IDC_HIDETIMESPIN 1320 +#define IDC_MULTITRAY 1321 +#define IDC_ALWAYSMULTI 1322 +#define IDC_SHOWICON 1323 +#define IDC_SORTTHEN 1323 +#define IDC_SHOWPROTO 1324 +#define IDC_SORTFINALLY 1324 +#define IDC_SHOWSTATUS 1325 +#define IDC_EQUALSECTIONS 1326 +#define IDC_SHOWSBAR 1329 +#define IDC_RIGHTMIRANDA 1330 +#define IDC_RIGHTSTATUS 1331 +#define IDC_STCLISTGROUP 1350 +#define IDC_DISABLEDRAGDROP 1351 +#define IDC_NOTEDITLABELS 1352 +#define IDC_SHOWSELALWAYS 1353 +#define IDC_TRACKSELECT 1354 +#define IDC_SHOWGROUPCOUNTS 1355 +#define IDC_HIDECOUNTSWHENEMPTY 1356 +#define IDC_DIVIDERONOFF 1357 +#define IDC_NOTNOTRANSLUCENTSEL 1358 +#define IDC_LINEWITHGROUPS 1359 +#define IDC_QUICKSEARCHVISONLY 1360 +#define IDC_SORTGROUPSALPHA 1361 +#define IDC_NOTNOSMOOTHSCROLLING 1362 +#define IDC_BITMAP 1363 +#define IDC_STWINDOWGROUP 1364 +#define IDC_STATIC01 1365 +#define IDC_SORTPRIMARY 1420 +#define IDC_HIDE 1534 +#define IDC_TOPLINE 1535 +#define IDC_BRINGTOFRONT 1579 +#define IDC_LOGO 1591 +#define IDC_BLINKTIME 1607 +#define IDC_BLINKSPIN 1608 +#define IDC_DISABLEBLINK 1609 +#define IDC_IDLE 1610 +#define IDC_SBPANELBEVEL 1611 +#define IDC_DBLCLKAVATARS 1611 +#define IDC_XSTATUSASSTATUS 1611 +#define IDC_NOSCROLLBAR 1613 +#define IDC_ADDVIEWMODE 1633 +#define IDC_SKINFILESELECT 1633 +#define IDC_IGN_ALL 1633 +#define IDC_EXPORT 1634 +#define IDC_DELETEVIEWMODE 1634 +#define IDC_IGN_NONE 1634 +#define IDC_RELOAD 1635 +#define IDC_IGN_ADDPERMANENTLY 1635 +#define IDC_DSP_LOADDEFAULT 1636 +#define IDC_ONDESKTOP 1657 +#define IDC_WINCOLOUR 1659 +#define IDC_ICONBLINK 1660 +#define IDC_APPLYLASTVIEWMODE 1661 +#define IDC_IGNORESELFORGROUPS 1722 +#define IDC_CLISTAVATARS 1729 +#define IDC_ALIGNMENT 1730 +#define IDC_AVATARSBORDER 1732 +#define IDC_AVATARBORDERCLR 1733 +#define IDC_AVATARSROUNDED 1734 +#define IDC_DUALROWMODE 1735 +#define IDC_CLISTALIGN 1737 +#define IDC_CLISTSUNKEN 1738 +#define IDC_EVENTAREAAUTOHIDE 1740 +#define IDC_RADIUS 1742 +#define IDC_RADIUSSPIN 1743 +#define IDC_ALWAYSALIGNNICK 1744 +#define IDC_SELECTIVEICONS 1746 +#define IDC_OVERLAYICONS 1747 +#define IDC_AVATARHEIGHT 1748 +#define IDC_NOAVATARSOFFLINE 1749 +#define IDC_CORNERRAD 1751 +#define IDC_CORNERSPIN 1752 +#define IDC_AVATARPADDING 1753 +#define IDC_GRPTOPPADDING 1753 +#define IDC_AVATARPADDINGSPIN 1754 +#define IDC_GRPPADDINGSPIN 1754 +#define IDC_LASTITEMPADDING 1755 +#define IDC_LASTITEMPADDINGSPIN 1756 +#define IDC_TBHIDEOFFLINE 1800 +#define IDC_TBHIDEGROUPS 1801 +#define IDC_TBSOUND 1802 +#define IDC_TBFINDANDADD 1803 +#define IDC_TBOPTIONS 1804 +#define IDC_TBMINIMIZE 1805 +#define IDC_TBMENU 1806 +#define IDC_TBGLOBALSTATUS 1807 +#define IDC_TABSRMMSLIST 1808 +#define IDC_TABSRMMMENU 1809 +#define IDC_TBSELECTVIEWMODE 1810 +#define IDC_ROUNDEDBORDER 1810 +#define IDC_TBCLEARVIEWMODE 1811 +#define IDC_TBCONFIGUREVIEWMODE 1812 +#define IDC_TBTOPMENU 1813 +#define IDC_TBTOPSTATUS 1814 +#define IDC_TBFOLDER 1815 +#define IDC_TBPOPUP 1816 +#define IDC_TBACCOUNTS 1817 +#define IDC_TBFIRSTUID 1820 +#define IDC_NOTIFYBUTTON 1900 +#define IDC_CLNICER 2002 +#define IDC_SUPPORT 2003 +#define IDI_OVL_OFFLINE 2050 +#define IDI_OVL_ONLINE 2051 +#define IDI_OVL_AWAY 2052 +#define IDI_OVL_DND 2053 +#define IDI_OVL_NA 2054 +#define IDI_OVL_OCCUPIED 2055 +#define IDI_OVL_INVISIBLE 2057 +#define IDI_OVL_ONTHEPHONE 2058 +#define IDI_OVL_OUTTOLUNCH 2059 +#define IDI_HIDEOFFLINE 2100 +#define IDI_HIDEGROUPS 2101 +#define IDI_SOUNDSON 2102 +#define IDI_FINDANDADD 2103 +#define IDI_TBOPTIONS 2104 +#define IDI_MINIMIZE 2105 +#define IDI_SOUNDSOFF 2106 +#define IDI_TABSRMMSESSIONLIST 2107 +#define IDI_TABSRMMMENU 2108 +#define IDI_PROTOCONNECTING 2111 +#define IDI_TBTOPMENU 2112 +#define IDI_TBACCOUNTS 2113 +#define IDC_FLT_DEFHOVERTIME 2200 +#define IDC_CLUIFRAMESBDR 25492 +#define IDC_FLT_PADLEFTSPIN 25494 +#define IDC_FLT_PADLEFT 25495 +#define IDC_GROUPALIGN 25499 +#define IDC_BORDERSTYLE 25501 +#define IDC_CURVIEWMODE2 25503 +#define ID_ICQ_EXIT 40001 +#define IDC_STATIC7 40002 +#define POPUP_HIDEEMPTYGROUPS 40003 +#define POPUP_NEWSUBGROUP 40004 +#define POPUP_HIDEOFFLINE 40005 +#define POPUP_GROUPHIDEOFFLINE 40006 +#define POPUP_HIDEOFFLINEROOT 40007 +#define POPUP_DISABLEGROUPS 40008 +#define IDC_VIEWMODES 40010 +#define IDC_PROTOCOLS 40011 +#define IDC_GROUPS 40012 +#define IDC_STATUSMODES 40013 +#define IDC_NEWVIEMODE 40014 +#define POPUP_HIDEMIRANDA 40017 +#define IDC_TAB 40017 +#define IDC_STATIC1 40018 +#define IDC_STATIC2 40019 +#define IDC_STATIC3 40020 +#define IDC_STATIC16 40021 +#define IDC_STATIC4 40022 +#define IDC_STATIC5 40023 +#define IDC_CLIST 40025 +#define IDC_STATIC8 40026 +#define IDC_STATIC9 40027 +#define POPUP_BUTTONS 40028 +#define IDC_CLEARALL 40028 +#define POPUP_FRAME 40029 +#define IDC_STATIC10 40029 +#define IDC_PROTOGROUPOP 40030 +#define POPUP_MOVEMARKEDHERE 40031 +#define IDC_GROUPSTATUSOP 40031 +#define IDC_LASTMESSAGEOP 40032 +#define ID_BUTTONS_ONLINE 40033 +#define IDC_SKINFILE 40034 +#define IDC_LASTMESSAGEUNIT 40034 +#define IDC_FLT_AVATARS 40036 +#define IDC_HIDECONTACT 40036 +#define IDC_FLT_DUALROWS 40037 +#define IDC_FLT_EXTRAICONS 40038 +#define ID_TRAY_HIDE 40038 +#define ID_TRAY_EXIT 40039 +#define IDC_FLT_SYNCED 40039 +#define POPUP_SHOWMETAICONS 40040 +#define IDC_FLT_AUTOHIDE 40040 +#define IDC_FLT_FILLSTD 40041 +#define IDC_FLT_PADRIGHT 40043 +#define IDC_LASTMSGVALUE 40043 +#define IDC_FLT_PADRIGHTSPIN 40044 +#define IDC_FLT_PADTOP 40045 +#define IDC_SKINFILENAME 40045 +#define IDC_FLT_PADTOPSPIN 40046 +#define IDC_SELECTSKINFILE 40046 +#define IDC_FLT_PADBOTTOM 40047 +#define IDC_RELOADSKIN 40047 +#define IDC_FLT_PADBOTTOMSPIN 40048 +#define IDC_UNLOAD 40048 +#define POPUP_NEWGROUP 40050 +#define IDC_SECONDLINEMODE 40050 +#define POPUP_SHOWSTATUSICONS 40051 +#define IDC_OVERLAYICON 40051 +#define IDC_SHOWLOCALTIME1 40052 +#define POPUP_RENAMEGROUP 40052 +#define POPUP_DELETEGROUP 40053 +#define IDC_DSP_ADD -25483 +#define IDC_DSP_DELETE 40054 +#define IDC_FLT_ENABLED 40054 +#define IDC_DSP_RENAME 40055 +#define IDC_FLT_OPACITY 40055 +#define IDC_DSP_APPLY 40056 +#define IDC_FLT_ACTIVEOPACITY 40056 +#define IDC_FLT_WIDTH 40058 +#define IDC_AVATARDISPMODE 40059 +#define IDC_FLT_WIDTHSPIN 40059 +#define IDC_FLT_SNAP 40060 +#define IDC_FLT_ACTIVEOPACITYVALUE 40061 +#define IDC_FLT_BORDER 40062 +#define IDC_FLT_ROUNDED 40063 +#define IDC_FLT_RADIUS 40065 +#define IDC_FLT_RADIUSSPIN 40066 +#define IDC_FLT_HOVERTIME 40067 +#define IDC_RESETXICONS 40067 +#define IDC_FLT_SHOWTOOLTIPS 40068 +#define IDC_FLT_HOVERTIMESPIN 40069 +#define IDC_FLT_OPACITYVALUE 40070 +#define IDC_FLT_BORDERCOLOUR 40072 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 10 +#define _APS_NEXT_COMMAND_VALUE 40061 +#define _APS_NEXT_CONTROL_VALUE 40066 +#define _APS_NEXT_SYMED_VALUE 40154 +#endif +#endif diff --git a/plugins/Clist_nicer/src/rowheight_funcs.cpp b/plugins/Clist_nicer/src/rowheight_funcs.cpp index a7eb1b83cb..6b0803275c 100644 --- a/plugins/Clist_nicer/src/rowheight_funcs.cpp +++ b/plugins/Clist_nicer/src/rowheight_funcs.cpp @@ -22,8 +22,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include -#include +#include "stdafx.h" +#include "rowheight_funcs.h" BOOL RowHeight::Init(ClcData *dat) { diff --git a/plugins/Clist_nicer/src/rowheight_funcs.h b/plugins/Clist_nicer/src/rowheight_funcs.h new file mode 100644 index 0000000000..60a0998e1c --- /dev/null +++ b/plugins/Clist_nicer/src/rowheight_funcs.h @@ -0,0 +1,74 @@ +#ifndef __ROWHEIGHT_FUNCS_H__ +# define __ROWHEIGHT_FUNCS_H__ + +#define ROW_SPACE_BEETWEEN_LINES 0 +#define ICON_HEIGHT 16 + +class RowHeight +{ +public: + static BOOL Alloc(ClcData *dat, int size); + static BOOL Init(ClcData *dat); + static void Free(ClcData *dat); + static void Clear(ClcData *dat); + + // Calc and store max row height + static int getMaxRowHeight(ClcData *dat, const HWND hwnd); + + // Calc and store row height + static int getRowHeight(ClcData *dat, ClcContact* contact, int item, DWORD style) + { + if (!Alloc(dat, item + 1)) + return -1; + + int height = dat->fontInfo[GetBasicFontID(contact)].fontHeight; + + if (!dat->bisEmbedded) { + if (contact->bSecondLine != MULTIROW_NEVER && contact->bSecondLine != MULTIROW_IFSPACE && contact->type == CLCIT_CONTACT) { + if ((contact->bSecondLine == MULTIROW_ALWAYS || ((cfg::dat.dwFlags & CLUI_FRAME_SHOWSTATUSMSG && contact->bSecondLine == MULTIROW_IFNEEDED) && (contact->xStatus > 0 || contact->pExtra->bStatusMsgValid > STATUSMSG_XSTATUSID)))) + height += (dat->fontInfo[FONTID_STATUS].fontHeight + cfg::dat.avatarPadding); + } + + // Avatar size + if (contact->cFlags & ECF_AVATAR && contact->type == CLCIT_CONTACT && contact->ace != NULL && !(contact->ace->dwFlags & AVS_HIDEONCLIST)) + height = max(height, cfg::dat.avatarSize + cfg::dat.avatarPadding); + } + + // Checkbox size + if ((style & CLS_CHECKBOXES && contact->type == CLCIT_CONTACT) || + (style & CLS_GROUPCHECKBOXES && contact->type == CLCIT_GROUP) || + (contact->type == CLCIT_INFO && contact->flags & CLCIIF_CHECKBOX)) { + height = max(height, dat->checkboxSize); + } + + //height += 2 * dat->row_border; + // Min size + height = max(height, contact->type == CLCIT_GROUP ? dat->group_row_height : dat->min_row_heigh); + height += cfg::dat.bRowSpacing; + + dat->row_heights[item] = height; + //contact->iRowHeight = item; + + return height; + } + + // Calc and store row height for all itens in the list + static void calcRowHeights (ClcData *dat, HWND hwnd); + + // Calc item top Y (using stored data) + static int getItemTopY (ClcData *dat, int item); + + // Calc item bottom Y (using stored data) + static int getItemBottomY (ClcData *dat, int item); + + // Calc total height of rows (using stored data) + static int getTotalHeight (ClcData *dat); + + // Return the line that pos_y is at or -1 (using stored data). Y start at 0 + static int hitTest (ClcData *dat, int pos_y); + + // Returns the height of the chosen row + static int getHeight (ClcData *dat, int item); +}; + +#endif // __ROWHEIGHT_FUNCS_H__ diff --git a/plugins/Clist_nicer/src/statusbar.cpp b/plugins/Clist_nicer/src/statusbar.cpp index 774e193a8d..2aec05b640 100644 --- a/plugins/Clist_nicer/src/statusbar.cpp +++ b/plugins/Clist_nicer/src/statusbar.cpp @@ -22,8 +22,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include -#include "../CLUIFrames/cluiframes.h" +#include "stdafx.h" +#include "cluiframes.h" static POINT ptMouse = { 0 }; static RECT rcMouse = { 0 }; diff --git a/plugins/Clist_nicer/src/stdafx.cpp b/plugins/Clist_nicer/src/stdafx.cpp deleted file mode 100644 index 048b14e9d2..0000000000 --- a/plugins/Clist_nicer/src/stdafx.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/* -Copyright (C) 2012-15 Miranda NG project (http://miranda-ng.org) - -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 version 2 -of the License. - -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, see . -*/ - -#include "commonheaders.h" \ No newline at end of file diff --git a/plugins/Clist_nicer/src/stdafx.cxx b/plugins/Clist_nicer/src/stdafx.cxx new file mode 100644 index 0000000000..0c766ea07f --- /dev/null +++ b/plugins/Clist_nicer/src/stdafx.cxx @@ -0,0 +1,18 @@ +/* +Copyright (C) 2012-15 Miranda NG project (http://miranda-ng.org) + +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 version 2 +of the License. + +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, see . +*/ + +#include "stdafx.h" diff --git a/plugins/Clist_nicer/src/stdafx.h b/plugins/Clist_nicer/src/stdafx.h new file mode 100644 index 0000000000..4dfc5ffa40 --- /dev/null +++ b/plugins/Clist_nicer/src/stdafx.h @@ -0,0 +1,87 @@ +/* + +Miranda NG: the free IM client for Microsoft* Windows* + +Copyright (ñ) 2012-15 Miranda NG project (http://miranda-ng.org), +Copyright (c) 2000-03 Miranda ICQ/IM 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. +*/ + +#undef FASTCALL + +#define TSAPI __stdcall +#define FASTCALL __fastcall + +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "resource.h" +#include "Version.h" +#include "extbackg.h" +#include "clc.h" +#include "config.h" +#include "clist.h" +#include "alphablend.h" +#include "rowheight_funcs.h" + +// shared vars +extern HINSTANCE g_hInst; +extern LONG g_cxsmIcon, g_cysmIcon; +extern LIST arStatusItems; +extern ImageItem *g_glyphItem; + +extern CLIST_INTERFACE coreCli; + +typedef int (__cdecl *pfnDrawAvatar)(HDC hdcOrig, HDC hdcMem, RECT *rc, ClcContact *contact, int y, struct ClcData *dat, int selected, WORD cstatus, int rowHeight); + +BOOL __forceinline GetItemByStatus(int status, StatusItems_t *retitem); + +void DrawAlpha(HDC hdcwnd, PRECT rc, DWORD basecolor, int alpha, DWORD basecolor2, BOOL transparent, BYTE FLG_GRADIENT, BYTE FLG_CORNER, DWORD BORDERSTYLE, ImageItem *item); + +void CustomizeButton(HWND hWnd, bool bIsSkinned, bool bIsThemed, bool bIsFlat = false, bool bIsTTButton = false); diff --git a/plugins/Clist_nicer/src/userdefs.h b/plugins/Clist_nicer/src/userdefs.h new file mode 100644 index 0000000000..ea7ea1fe92 --- /dev/null +++ b/plugins/Clist_nicer/src/userdefs.h @@ -0,0 +1,79 @@ +#ifndef _USERDEFINES_INCLUDED +#define _USERDEFINES_INCLUDED + +/* + + Define these values to alter the various + features of the coolscroll library. If you don't want + a certain feature, then you might be able to reduce the + size of your app by a few kb... + +*/ + +/* allow inserted buttons. Without this, all button code will + be excluded, resulting in a smaller build (about 4kb less). This + may not seem much, but it is a 25% reduction! */ +//#define INCLUDE_BUTTONS + +/* Allow user-resizable buttons. Makes no difference if INCLUDE_BUTTONS + is not defined for the project */ +#define RESIZABLE_BUTTONS + +/* Include tooltip support for inserted buttons. Without this, no + tooltip requests (TTN_GETDISPINFO's) will be sent to the window */ +//#define COOLSB_TOOLTIPS + +/* Define this to include the custom-draw support */ +#define CUSTOM_DRAW + +/* Define to enable WM_NOTIFY messages to be sent for mouse event */ +#define NOTIFY_MOUSE + +/* Define this value to make the horizontal scrollbar stay visible even + if the window is sized to small vertically. Normal scrollbars always leave + a 1-pixel line of "client" area before hiding the horizontal scrollbar. This + value allows the window to be sized so the client area totally disappears if + sized too small */ +//#define COOLSB_FILLWINDOW + +/* minimum size of scrollbar before inserted buttons are + hidden to make room when the window is sized too small */ +#define MIN_COOLSB_SIZE 24 + +/* min size of scrollbar when resizing a button, before the + resize is stopped because the scrollbar has gotten too small */ +#define MINSCROLLSIZE 50 + +/* define this to display the default mouse arrow whenever the + the mouse is released over a button which has a user-defined cursor. + not really very useful, just provides a different type of feedback */ +#undef HIDE_CURSOR_AFTER_MOUSEUP + +/* enable HOT_TRACKING to provide visual feedback when the mouse + moves over a scrollbar area (like Flat Scrollbars) */ +#define HOT_TRACKING + +/* enable FLAT_SCROLLBARS to include support for flat scrollbars + note that they must be enabled by the user first of all */ +#define FLAT_SCROLLBARS + +/* a normal scrollbar "snaps" its scroll-thumb back into position if + you move the mouse too far away from the window, whilst you are + dragging the thumb, that is. #undeffing this results in the thumb + never snapping back into position, no matter how far away you move + the mouse */ +#define SNAP_THUMB_BACK + +/* distance (in pixels) the mouse must move away from the thumb + during tracking to cause the thumb bar to snap back to its + starting place. Has no effect unless SNAP_THUMB_BACK is defined */ +#define THUMBTRACK_SNAPDIST 24 + +/* maximum number of inserted buttons per bar */ +#define MAX_COOLSB_BUTS 16 + +/* maximum number of coolsb windows per application. + Set to lower if you don't need many. */ +#define MAX_COOLSB 4 + +#endif /* _USERDEFINES_INCLUDED */ \ No newline at end of file diff --git a/plugins/Clist_nicer/src/version.h b/plugins/Clist_nicer/src/version.h new file mode 100644 index 0000000000..babd66c1bc --- /dev/null +++ b/plugins/Clist_nicer/src/version.h @@ -0,0 +1,14 @@ +#define __MAJOR_VERSION 0 +#define __MINOR_VERSION 9 +#define __RELEASE_NUM 2 +#define __BUILD_NUM 4 + +#include + +#define __PLUGIN_NAME "Clist nicer" +#define __FILENAME "Clist_nicer.dll" +#define __DESCRIPTION "Displays contacts, event notifications, protocol status." +#define __AUTHOR "Pixel, egoDust, cyreve, Nightwish" +#define __AUTHOREMAIL "" +#define __AUTHORWEB "http://miranda-ng.org/p/Clist_nicer/" +#define __COPYRIGHT "Copyright 2000-2010 Miranda-IM project" diff --git a/plugins/Clist_nicer/src/viewmodes.cpp b/plugins/Clist_nicer/src/viewmodes.cpp index c19d607890..5e8ed3b24a 100644 --- a/plugins/Clist_nicer/src/viewmodes.cpp +++ b/plugins/Clist_nicer/src/viewmodes.cpp @@ -22,9 +22,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include -#include -#include "../cluiframes/cluiframes.h" +#include "stdafx.h" +#include "cluiframes.h" #define TIMERID_VIEWMODEEXPIRE 100 diff --git a/plugins/Clist_nicer/src/wallpaper.cpp b/plugins/Clist_nicer/src/wallpaper.cpp index c235094fda..75e1831bfe 100644 --- a/plugins/Clist_nicer/src/wallpaper.cpp +++ b/plugins/Clist_nicer/src/wallpaper.cpp @@ -22,7 +22,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include +#include "stdafx.h" typedef enum { WPS_TILED=0, -- cgit v1.2.3