diff options
author | George Hazan <ghazan@miranda.im> | 2018-03-13 13:59:18 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-03-13 13:59:18 +0300 |
commit | f9a6f40b7834edd693e8e5b8d64dbc7cd8921262 (patch) | |
tree | 7bc15bfe8681a98ce96695d37455c8b32829dbf3 | |
parent | d4e64ad19a3bc6d384c973715497fc6283750e3a (diff) |
fixes #1179 (Resurrect MagneticWindows plugin)
-rw-r--r-- | bin15/mir_full.sln | 119 | ||||
-rw-r--r-- | plugins/ExternalAPI/m_MagneticWindows.h | 86 | ||||
-rw-r--r-- | plugins/MagneticWindows/MagneticWindows.vcxproj | 28 | ||||
-rw-r--r-- | plugins/MagneticWindows/MagneticWindows.vcxproj.filters | 4 | ||||
-rw-r--r-- | plugins/MagneticWindows/res/Options.rc | 113 | ||||
-rw-r--r-- | plugins/MagneticWindows/res/Version.rc | 38 | ||||
-rw-r--r-- | plugins/MagneticWindows/src/MagneticWindows.cpp | 144 | ||||
-rw-r--r-- | plugins/MagneticWindows/src/MagneticWindowsCore.cpp | 354 | ||||
-rw-r--r-- | plugins/MagneticWindows/src/Options.cpp | 96 | ||||
-rw-r--r-- | plugins/MagneticWindows/src/Options.h | 16 | ||||
-rw-r--r-- | plugins/MagneticWindows/src/SnapToListService.cpp | 52 | ||||
-rw-r--r-- | plugins/MagneticWindows/src/SnapToListService.h | 2 | ||||
-rw-r--r-- | plugins/MagneticWindows/src/Version.h | 14 | ||||
-rw-r--r-- | plugins/MagneticWindows/src/resource.h | 25 | ||||
-rw-r--r-- | plugins/MagneticWindows/src/stdafx.cxx | 18 | ||||
-rw-r--r-- | plugins/MagneticWindows/src/stdafx.h | 34 | ||||
-rw-r--r-- | tools/build_scripts/bin15/z2_PackPluginUpdater_x32.txt | 1 | ||||
-rw-r--r-- | tools/build_scripts/bin15/z2_PackPluginUpdater_x64.txt | 1 |
18 files changed, 1145 insertions, 0 deletions
diff --git a/bin15/mir_full.sln b/bin15/mir_full.sln index 404b50c443..cf26ffc214 100644 --- a/bin15/mir_full.sln +++ b/bin15/mir_full.sln @@ -432,6 +432,24 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ICQCorp", "..\protocols\ICQ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeImage", "..\libs\freeimage\freeimage.vcxproj", "{5D14CFF3-0D17-4528-99EA-DE9DCA47CC2E}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MagneticWindows", "..\plugins\MagneticWindows\MagneticWindows.vcxproj", "{7DC23E4E-2448-4811-AABD-F5D069F6E74A}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Protocols", "Protocols", "{A035B524-0F2D-45D0-BCF2-3C20279C77E2}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{E7FB43FB-3563-4568-8846-A88FC37449BF}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Libs", "Libs", "{37EDFBEA-8446-4BF3-9F2E-655908CDFB62}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Lua", "Lua", "{329B4E94-C846-4C78-AFD5-8B6B839DCCE1}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Database", "Database", "{F13387B0-1C74-48EC-9AEC-65E3B9DE29E4}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Message edtors", "Message edtors", "{D8EA3AE1-64AA-42ED-9F13-83F6C7B5AA55}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Contact lists", "Contact lists", "{F9C41695-3353-4564-A154-58106829B19C}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Encryption", "Encryption", "{30218E20-9E62-4027-BB87-2627B17F6CA3}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -1998,10 +2016,111 @@ Global {5D14CFF3-0D17-4528-99EA-DE9DCA47CC2E}.Release|Win32.Build.0 = Release|Win32 {5D14CFF3-0D17-4528-99EA-DE9DCA47CC2E}.Release|x64.ActiveCfg = Release|x64 {5D14CFF3-0D17-4528-99EA-DE9DCA47CC2E}.Release|x64.Build.0 = Release|x64 + {7DC23E4E-2448-4811-AABD-F5D069F6E74A}.Debug|Win32.ActiveCfg = Debug|Win32 + {7DC23E4E-2448-4811-AABD-F5D069F6E74A}.Debug|Win32.Build.0 = Debug|Win32 + {7DC23E4E-2448-4811-AABD-F5D069F6E74A}.Debug|x64.ActiveCfg = Debug|x64 + {7DC23E4E-2448-4811-AABD-F5D069F6E74A}.Debug|x64.Build.0 = Debug|x64 + {7DC23E4E-2448-4811-AABD-F5D069F6E74A}.Release|Win32.ActiveCfg = Release|Win32 + {7DC23E4E-2448-4811-AABD-F5D069F6E74A}.Release|Win32.Build.0 = Release|Win32 + {7DC23E4E-2448-4811-AABD-F5D069F6E74A}.Release|x64.ActiveCfg = Release|x64 + {7DC23E4E-2448-4811-AABD-F5D069F6E74A}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {D9EFEA4B-B817-4DE1-BD62-68A5DB8F5F60} = {E7FB43FB-3563-4568-8846-A88FC37449BF} + {538E451F-E667-4D07-BCE6-976ECC7BB8D1} = {E7FB43FB-3563-4568-8846-A88FC37449BF} + {F6A9340E-B8D9-4C75-BE30-47DC66D0ABC7} = {37EDFBEA-8446-4BF3-9F2E-655908CDFB62} + {E2A369CD-EDA3-414F-8AD0-E732CD7EE68C} = {37EDFBEA-8446-4BF3-9F2E-655908CDFB62} + {9299B507-1AF9-4C93-9560-5F637D1E0C9E} = {F13387B0-1C74-48EC-9AEC-65E3B9DE29E4} + {20D781FB-4A20-4B75-B863-304A47182966} = {F13387B0-1C74-48EC-9AEC-65E3B9DE29E4} + {B8928210-546C-4AE3-956B-E2B724E6B8E5} = {D8EA3AE1-64AA-42ED-9F13-83F6C7B5AA55} + {99D26CA1-BFD4-4E77-9A1E-919E54CF33F7} = {D8EA3AE1-64AA-42ED-9F13-83F6C7B5AA55} + {6DA1396F-2A44-4D5C-8442-012F71006217} = {A035B524-0F2D-45D0-BCF2-3C20279C77E2} + {3A12F777-56A8-42EC-BD17-8F325524241E} = {A035B524-0F2D-45D0-BCF2-3C20279C77E2} + {01DDCB36-4DE2-405D-BC36-2C8BDEB86659} = {A035B524-0F2D-45D0-BCF2-3C20279C77E2} + {33276462-8313-4192-8306-13717ECCA60A} = {A035B524-0F2D-45D0-BCF2-3C20279C77E2} + {7B0F213E-C15E-4219-8AE5-49DD3D3D553D} = {A035B524-0F2D-45D0-BCF2-3C20279C77E2} + {3C42510C-A29E-4A53-899C-203BFA874E0B} = {F9C41695-3353-4564-A154-58106829B19C} + {987F026D-EB1F-4013-ADA8-2406ACCDA526} = {F9C41695-3353-4564-A154-58106829B19C} + {2AD2FF74-06E1-4BD8-984A-526F3C6315B3} = {F9C41695-3353-4564-A154-58106829B19C} + {751ED05D-AD3E-4EC6-A485-4ECDF1FE6068} = {F13387B0-1C74-48EC-9AEC-65E3B9DE29E4} + {9290A9CC-3FDA-4FD6-A8A2-04AD4BA1C856} = {F9C41695-3353-4564-A154-58106829B19C} + {9DE1F0B0-B9D1-4681-82E7-13CC3E047445} = {D8EA3AE1-64AA-42ED-9F13-83F6C7B5AA55} + {B988F96C-F87A-484C-AB15-D0674B22F291} = {D8EA3AE1-64AA-42ED-9F13-83F6C7B5AA55} + {DD76B998-ED0D-4BFD-9660-3ADC3A334872} = {D8EA3AE1-64AA-42ED-9F13-83F6C7B5AA55} + {27CA5499-B3F2-4FB6-8414-651819B0B96C} = {D8EA3AE1-64AA-42ED-9F13-83F6C7B5AA55} + {C09A0E86-E7C3-4229-B817-C86A0AE8ACE5} = {A035B524-0F2D-45D0-BCF2-3C20279C77E2} + {37C2B9A4-63EF-49E8-BF23-677B5EBD73E9} = {D8EA3AE1-64AA-42ED-9F13-83F6C7B5AA55} + {EE182018-5D3D-43F3-955F-7B5AB0BE2FCA} = {A035B524-0F2D-45D0-BCF2-3C20279C77E2} + {DADE9455-DC28-465A-9604-2CA28052B9FB} = {A035B524-0F2D-45D0-BCF2-3C20279C77E2} + {D5E2FEC1-B29A-476C-BD41-469FE282EE0F} = {A035B524-0F2D-45D0-BCF2-3C20279C77E2} + {12FFF2B0-0D0B-430B-A4C6-1577CA98F598} = {A035B524-0F2D-45D0-BCF2-3C20279C77E2} + {D9057E63-AAAA-4FE7-800A-20C02F4761F3} = {F9C41695-3353-4564-A154-58106829B19C} + {2C050CAF-D8AA-468A-B1A7-89F3BE99D3C8} = {37EDFBEA-8446-4BF3-9F2E-655908CDFB62} + {40FE7861-E54E-4DA9-BE4D-A5178014E477} = {37EDFBEA-8446-4BF3-9F2E-655908CDFB62} + {1423FC8F-AA52-4562-8275-4BF0838CA378} = {37EDFBEA-8446-4BF3-9F2E-655908CDFB62} + {53F841E8-284F-4545-9176-B131896E43F8} = {30218E20-9E62-4027-BB87-2627B17F6CA3} + {4AC1E062-0236-4E49-AA04-F732043D2DCF} = {30218E20-9E62-4027-BB87-2627B17F6CA3} + {290C5ED4-71A7-4040-AD26-4820CF7A9E60} = {30218E20-9E62-4027-BB87-2627B17F6CA3} + {1C856B14-54CD-4D07-B18B-5F7DB073AB51} = {E7FB43FB-3563-4568-8846-A88FC37449BF} + {A5B558C6-C767-11E1-A335-F6EB6188709B} = {E7FB43FB-3563-4568-8846-A88FC37449BF} + {6022990D-3FD5-46A9-8AB5-E444C51646F3} = {E7FB43FB-3563-4568-8846-A88FC37449BF} + {A8F23706-E590-4A87-96CC-5F8E5082503F} = {E7FB43FB-3563-4568-8846-A88FC37449BF} + {36C40BA6-E0B5-438A-919C-6A991933B313} = {E7FB43FB-3563-4568-8846-A88FC37449BF} + {DADAC956-3A54-440A-8B56-A07234DEE861} = {E7FB43FB-3563-4568-8846-A88FC37449BF} + {D22C1BBB-E06A-4A28-8F33-17D1EA3E8563} = {E7FB43FB-3563-4568-8846-A88FC37449BF} + {C14D6E0D-810E-4599-A6E0-17298AFA0501} = {E7FB43FB-3563-4568-8846-A88FC37449BF} + {E71C1722-A41D-4475-87F4-29961A3654BB} = {E7FB43FB-3563-4568-8846-A88FC37449BF} + {F47EAB99-C78F-4A92-87D5-B0E16FE5A133} = {E7FB43FB-3563-4568-8846-A88FC37449BF} + {8D0F60DE-DB07-49FD-8E1F-0DE558BE6DE3} = {E7FB43FB-3563-4568-8846-A88FC37449BF} + {2C9F6CB6-3E70-4E7A-945D-2A7C148B0DF3} = {E7FB43FB-3563-4568-8846-A88FC37449BF} + {73482497-9F57-4819-A9AB-5D841A9F072D} = {A035B524-0F2D-45D0-BCF2-3C20279C77E2} + {9C6040B8-1173-40FA-A3DB-DE044CCD8250} = {F13387B0-1C74-48EC-9AEC-65E3B9DE29E4} + {576EEEFD-E423-482B-879A-F0515D40B8E1} = {E7FB43FB-3563-4568-8846-A88FC37449BF} + {A2E9DA24-95E4-4414-94AF-488A382E276A} = {F13387B0-1C74-48EC-9AEC-65E3B9DE29E4} + {4CE78D43-FF23-4134-A5AC-B2CF0F8D9F3B} = {D8EA3AE1-64AA-42ED-9F13-83F6C7B5AA55} + {ABF05E2C-C335-4BD1-8C3E-4C63285362CF} = {D8EA3AE1-64AA-42ED-9F13-83F6C7B5AA55} + {C619A811-8023-4441-B3D7-785388A09DF0} = {A035B524-0F2D-45D0-BCF2-3C20279C77E2} + {6BFE3E13-BD5D-4C1C-BB29-A82FB51A16CE} = {A035B524-0F2D-45D0-BCF2-3C20279C77E2} + {155211F8-08E1-4864-A3B8-9F04F4270360} = {D8EA3AE1-64AA-42ED-9F13-83F6C7B5AA55} + {2E15C462-A150-4A37-ACD6-FBAECF1724F5} = {F9C41695-3353-4564-A154-58106829B19C} + {01F9E227-06F5-4BED-907F-402CA7DFAFE6} = {37EDFBEA-8446-4BF3-9F2E-655908CDFB62} + {0E046380-14CA-4C23-A807-8C678519A605} = {A035B524-0F2D-45D0-BCF2-3C20279C77E2} + {F462FDA1-BDCD-49B2-B996-D7DE71D07393} = {A035B524-0F2D-45D0-BCF2-3C20279C77E2} + {BF6E1942-7E42-4564-9DF5-FD0A00D71173} = {A035B524-0F2D-45D0-BCF2-3C20279C77E2} + {B5BCDC2F-81FC-4324-90C6-E5540A225EFF} = {D8EA3AE1-64AA-42ED-9F13-83F6C7B5AA55} + {12BCA020-EABF-429E-876A-A476BC9C10C0} = {37EDFBEA-8446-4BF3-9F2E-655908CDFB62} + {EDAAD28B-505B-4969-A8BB-97EAE818DEEA} = {A035B524-0F2D-45D0-BCF2-3C20279C77E2} + {6124E997-426E-4A0B-9617-D6D577D5E7D7} = {37EDFBEA-8446-4BF3-9F2E-655908CDFB62} + {7F5EA8BC-8F2B-478E-8F05-0ED4B691B776} = {D8EA3AE1-64AA-42ED-9F13-83F6C7B5AA55} + {8236EA1F-579A-4AFB-9DFE-5FA056AEDDBB} = {A035B524-0F2D-45D0-BCF2-3C20279C77E2} + {6C0C35E7-6522-403C-BB60-9805CDB9E52F} = {30218E20-9E62-4027-BB87-2627B17F6CA3} + {66A9BDEB-150F-45DC-B20F-9892C0B43834} = {A035B524-0F2D-45D0-BCF2-3C20279C77E2} + {B4327D10-ACDC-4C12-9555-749DD49A7BB0} = {A035B524-0F2D-45D0-BCF2-3C20279C77E2} + {27D41D81-991F-4DC6-8749-B0321C87E694} = {329B4E94-C846-4C78-AFD5-8B6B839DCCE1} + {BD291BF0-D804-4818-8311-DE871E6BCEAA} = {37EDFBEA-8446-4BF3-9F2E-655908CDFB62} + {620E0BE7-3763-4F35-9DBD-4770104E269C} = {37EDFBEA-8446-4BF3-9F2E-655908CDFB62} + {B80C2C8D-B987-48B6-AFE2-8DA2D17F2F6A} = {37EDFBEA-8446-4BF3-9F2E-655908CDFB62} + {817D2806-9EC5-4607-A404-F031C98A1872} = {37EDFBEA-8446-4BF3-9F2E-655908CDFB62} + {D5C9CA74-4E25-478A-B890-75EB13E6DB1C} = {329B4E94-C846-4C78-AFD5-8B6B839DCCE1} + {E604CD58-4579-4F69-9D6A-2605FD7CF716} = {329B4E94-C846-4C78-AFD5-8B6B839DCCE1} + {88928401-2CE8-4568-AAA7-226141870CBF} = {A035B524-0F2D-45D0-BCF2-3C20279C77E2} + {E876FE63-0701-4CDA-BED5-7C73A379C1D1} = {A035B524-0F2D-45D0-BCF2-3C20279C77E2} + {FBB46BDD-FD4C-4F95-98E8-6F0B6E8067A9} = {329B4E94-C846-4C78-AFD5-8B6B839DCCE1} + {277E433F-7D71-4247-8AAA-CC5FB1AA7A67} = {329B4E94-C846-4C78-AFD5-8B6B839DCCE1} + {CE6A5A24-EA88-4E67-BDF2-22517528E43F} = {F9C41695-3353-4564-A154-58106829B19C} + {0C02E395-E73F-47E3-8B95-B7924C0C7A6A} = {37EDFBEA-8446-4BF3-9F2E-655908CDFB62} + {A185B162-6CB6-4502-B03F-B56F7699A8D9} = {37EDFBEA-8446-4BF3-9F2E-655908CDFB62} + {E0EBB8A5-B577-414C-A5F9-9B4E2A0A66E9} = {37EDFBEA-8446-4BF3-9F2E-655908CDFB62} + {A21C50CD-28A6-481A-A12B-47189FE66641} = {37EDFBEA-8446-4BF3-9F2E-655908CDFB62} + {2115FEBC-1EC4-4F95-A058-A523ED5295A4} = {A035B524-0F2D-45D0-BCF2-3C20279C77E2} + {E0ACDEA0-0AC9-4431-8CA3-6B0CCACB2E18} = {F13387B0-1C74-48EC-9AEC-65E3B9DE29E4} + {AD0D0500-CE7D-417D-9C36-3620D56CA6D4} = {A035B524-0F2D-45D0-BCF2-3C20279C77E2} + {5D14CFF3-0D17-4528-99EA-DE9DCA47CC2E} = {37EDFBEA-8446-4BF3-9F2E-655908CDFB62} + {7DC23E4E-2448-4811-AABD-F5D069F6E74A} = {F9C41695-3353-4564-A154-58106829B19C} + EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {29A0C2A8-07A4-4A8B-8BED-8F7D024013D6} EndGlobalSection diff --git a/plugins/ExternalAPI/m_MagneticWindows.h b/plugins/ExternalAPI/m_MagneticWindows.h new file mode 100644 index 0000000000..73d182c90e --- /dev/null +++ b/plugins/ExternalAPI/m_MagneticWindows.h @@ -0,0 +1,86 @@ +#ifndef __M_MAGNETICWINDOWS_H__ +#define __M_MAGNETICWINDOWS_H__ + +//#include "../include/newpluginapi.h" + +// For other Plugins to start snapping for their windows +// wparam: hwnd of window +// lparam: 0 +// return: 0 on success, 1 on error +#define MS_MW_ADDWINDOW "Utils/MagneticWindows/Add" + +// For other Plugins to stop snapping for their windows +// wparam: hwnd of window +// lparam: 0 +// return: 0 on success, 1 on error +#define MS_MW_REMWINDOW "Utils/MagneticWindows/Rem" + +//decide where to align on the list: +#define MS_MW_STL_List_Left 0x00000001 //Snaps the window to the left border of the list +#define MS_MW_STL_List_Top 0x00000002 //Snaps the window to the top border of the list +#define MS_MW_STL_List_Right 0x00000004 //Snaps the window to the right border of the list +#define MS_MW_STL_List_Bottom 0x00000008 //Snaps the window to the bottom border of the list +//decide with what side (of the window you want to snap) to snap to the list +#define MS_MW_STL_Wnd_Left 0x00000010 //Snaps the window with the left border to the left/right side of the list +#define MS_MW_STL_Wnd_Top 0x00000020 //Snaps the window with the top border to the top/bottom side of the list +#define MS_MW_STL_Wnd_Right 0x00000040 //Snaps the window with the right border to the left/right side of the list +#define MS_MW_STL_Wnd_Bottom 0x00000080 //Snaps the window with the bottom border to the top/bottom side of the list + +#define MS_MW_STL_Wnd_FullWidth (MS_MW_STL_Wnd_Left | MS_MW_STL_Wnd_Right) + //Snaps to the top/bottom of the list and spans over the full width + +#define MS_MW_STL_Wnd_FullHeight (MS_MW_STL_Wnd_Top | MS_MW_STL_Wnd_Bottom) + //Snaps to the left/right of the list and spans over the full height + +// to place the window in the list combine f.e. MS_MW_STL_List_Left | MS_MW_STL_Wnd_Right | *vetical alignment* + +//For other Plugins to snap a window to the list for other Plugins +// wparam: hwnd of window +// lparam: combination of the above constants MS_MW_STL_* +// return: 0 on success, 1 on error +#define MS_MW_SNAPTOLIST "Utils/MagneticWindows/SnapToList" + +// Helper functions +#ifndef _MW_NO_HELPPER_FUNCTIONS + + +static inline int MagneticWindows_AddWindow(HWND hWnd) +{ + if (ServiceExists(MS_MW_ADDWINDOW)) + { + return CallService(MS_MW_ADDWINDOW, (WPARAM) hWnd, 0); + } + else + { + return -1; + } +} + +static inline int MagneticWindows_RemoveWindow(HWND hWnd) +{ + if (ServiceExists(MS_MW_REMWINDOW)) + { + return CallService(MS_MW_REMWINDOW, (WPARAM) hWnd, 0); + } + else + { + return -1; + } +} + +static inline int MagneticWindows_SnapWindowToList(HWND hWnd, int MS_MW_STL_Options) +{ + if (ServiceExists(MS_MW_SNAPTOLIST)) + { + return CallService(MS_MW_SNAPTOLIST, (WPARAM) hWnd, (LPARAM) MS_MW_STL_Options); + } + else + { + return -1; + } +} + +#endif + + +#endif // __M_MAGNETICWINDOWS_H__ diff --git a/plugins/MagneticWindows/MagneticWindows.vcxproj b/plugins/MagneticWindows/MagneticWindows.vcxproj new file mode 100644 index 0000000000..297c791d0f --- /dev/null +++ b/plugins/MagneticWindows/MagneticWindows.vcxproj @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|x64"> + <Configuration>Debug</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|x64"> + <Configuration>Release</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{7DC23E4E-2448-4811-AABD-F5D069F6E74A}</ProjectGuid> + <ProjectName>MagneticWindows</ProjectName> + </PropertyGroup> + <ImportGroup Label="PropertySheets"> + <Import Project="$(ProjectDir)..\..\build\vc.common\plugin.props" /> + </ImportGroup> +</Project> diff --git a/plugins/MagneticWindows/MagneticWindows.vcxproj.filters b/plugins/MagneticWindows/MagneticWindows.vcxproj.filters new file mode 100644 index 0000000000..fcae13a9d8 --- /dev/null +++ b/plugins/MagneticWindows/MagneticWindows.vcxproj.filters @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$(ProjectDir)..\..\build\vc.common\common.filters" /> +</Project>
\ No newline at end of file diff --git a/plugins/MagneticWindows/res/Options.rc b/plugins/MagneticWindows/res/Options.rc new file mode 100644 index 0000000000..27cb410d68 --- /dev/null +++ b/plugins/MagneticWindows/res/Options.rc @@ -0,0 +1,113 @@ +//Microsoft Developer Studio generated resource script. +// +#include "..\src\resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// Deutsch (Deutschland) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU) +#ifdef _WIN32 +LANGUAGE LANG_GERMAN, SUBLANG_GERMAN +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + +#endif // Deutsch (Deutschland) resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// Englisch (USA) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_OPT_MAGNETICWINDOWS DIALOGEX 0, 0, 275, 80 +STYLE DS_FIXEDSYS | WS_CHILD +FONT 8, "MS Shell Dlg" +BEGIN + GROUPBOX "Magnetic Windows",IDC_MAINFRAME,8,8,258,64,WS_GROUP + CONTROL "",IDC_SLIDER_SNAPWIDTH,"msctls_trackbar32",TBS_BOTH | + TBS_NOTICKS | WS_TABSTOP,108,24,96,12 + CONTROL "Snap windows",IDC_CHK_SNAP,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,18,24,84,12 + LTEXT "15 pix",IDC_TXT_SNAPWIDTH,216,24,42,12,SS_CENTERIMAGE + CONTROL "For Scriver users: automatically hold down the CTRL key while moving/sizing. (Make sure you use Scriver!)", + IDC_CHK_SCRIVERWORKAROUND,"Button",BS_AUTOCHECKBOX | + BS_MULTILINE | WS_TABSTOP,18,44,239,20,WS_EX_TRANSPARENT +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO DISCARDABLE +BEGIN + IDD_OPT_MAGNETICWINDOWS, DIALOG + BEGIN + RIGHTMARGIN, 273 + BOTTOMMARGIN, 79 + END +END +#endif // APSTUDIO_INVOKED + +#endif // Englisch (USA) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/plugins/MagneticWindows/res/Version.rc b/plugins/MagneticWindows/res/Version.rc new file mode 100644 index 0000000000..c1b35a28e6 --- /dev/null +++ b/plugins/MagneticWindows/res/Version.rc @@ -0,0 +1,38 @@ +// Microsoft Visual C++ generated resource script. +// +#ifdef APSTUDIO_INVOKED +#error this file is not editable by Microsoft Visual C++ +#endif //APSTUDIO_INVOKED + +#include "afxres.h" +#include "..\src\Version.h" + +VS_VERSION_INFO VERSIONINFO + FILEVERSION __FILEVERSION_STRING + PRODUCTVERSION __FILEVERSION_STRING + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x0L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "000004b0" + BEGIN + VALUE "FileDescription", __DESCRIPTION + VALUE "InternalName", __PLUGIN_NAME + VALUE "LegalCopyright", __COPYRIGHT + VALUE "OriginalFilename", __FILENAME + VALUE "ProductName", __PLUGIN_NAME + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0, 1200 + END +END diff --git a/plugins/MagneticWindows/src/MagneticWindows.cpp b/plugins/MagneticWindows/src/MagneticWindows.cpp new file mode 100644 index 0000000000..fa2ee26e89 --- /dev/null +++ b/plugins/MagneticWindows/src/MagneticWindows.cpp @@ -0,0 +1,144 @@ +#include "stdafx.h" + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// +// Magnetic Windows +// +// Autor: Michael Kunz +// EMail: Michael.Kunz@s2005.tu-chemnitz.de +// +// +// thanks to: pescuma +// +/////////////////////////////////////////////////////////////////////////////////////////////////// + + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Variables +/////////////////////////////////////////////////////////////////////////////////////////////////// + +PLUGININFOEX pluginInfo = { + sizeof(PLUGININFOEX), + __PLUGIN_NAME, + PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), + __DESCRIPTION, + __AUTHOR, + __AUTHOREMAIL, + __COPYRIGHT, + UNICODE_AWARE, + // {08C01613-24C8-486F-BDAE-2C3DDCAF9347} + {0x8c01613, 0x24c8, 0x486f, { 0xbd, 0xae, 0x2c, 0x3d, 0xdc, 0xaf, 0x93, 0x47 }} +}; + +HINSTANCE hInst; +int hLangpack; +CLIST_INTERFACE *pcli; + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Plugin Functions +/////////////////////////////////////////////////////////////////////////////////////////////////// + + +//For other Plugins to start snapping for other Windows +INT_PTR SnapPluginWindowStart(WPARAM wParam, LPARAM) +{ + if (!WindowOpen((HWND)wParam)) return 1; + return 0; +} + +//For other Plugins to stop snapping for other Windows +INT_PTR SnapPluginWindowStop(WPARAM wParam, LPARAM) +{ + if (!WindowClose((HWND)wParam)) return 1; + return 0; +} + +int PluginMessageWindowEvent(WPARAM, LPARAM lParam) +{ + MessageWindowEventData *Data = (MessageWindowEventData*) lParam; + + switch (Data->uType) { + case MSG_WINDOW_EVT_OPEN: + { + HWND hWnd = Data->hwndWindow; + HWND hWndParent = GetParent(hWnd); + while ((hWndParent != 0) && (hWndParent != GetDesktopWindow()) && (IsWindowVisible(hWndParent))) { + hWnd = hWndParent; + hWndParent = GetParent(hWnd); + } + + WindowOpen(hWnd); + } + break; + + case MSG_WINDOW_EVT_CLOSING: + WindowClose(Data->hwndWindow); + break; + } + + return 0; +} + + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Main Functions +/////////////////////////////////////////////////////////////////////////////////////////////////// + +int SnapPluginStart(WPARAM, LPARAM) +{ + LoadOptions(); + + HookEvent(ME_MSG_WINDOWEVENT, PluginMessageWindowEvent); + + WindowOpen(pcli->hwndContactList); + return 0; +} + +int SnapPluginShutDown(WPARAM, LPARAM) +{ + WindowCloseAll(); + return 0; +} + + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Exportet Functions +/////////////////////////////////////////////////////////////////////////////////////////////////// + +extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) +{ + return &pluginInfo; +} + +extern "C" int __declspec(dllexport) Load() +{ + mir_getLP(&pluginInfo); + pcli = Clist_GetInterface(); + + HookEvent(ME_SYSTEM_MODULESLOADED, SnapPluginStart); + HookEvent(ME_SYSTEM_PRESHUTDOWN, SnapPluginShutDown); + HookEvent(ME_OPT_INITIALISE, InitOptions); + + CreateServiceFunction(MS_MW_ADDWINDOW, SnapPluginWindowStart); + CreateServiceFunction(MS_MW_REMWINDOW, SnapPluginWindowStop); + CreateServiceFunction(MS_MW_SNAPTOLIST, SnapToList); + + WindowStart(); + return 0; +} + +extern "C" int __declspec(dllexport) Unload() +{ + return 0; +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// DLL MAIN +/////////////////////////////////////////////////////////////////////////////////////////////////// + + +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID) +{ + hInst = hinstDLL; + return TRUE; +} diff --git a/plugins/MagneticWindows/src/MagneticWindowsCore.cpp b/plugins/MagneticWindows/src/MagneticWindowsCore.cpp new file mode 100644 index 0000000000..6e0ee965cd --- /dev/null +++ b/plugins/MagneticWindows/src/MagneticWindowsCore.cpp @@ -0,0 +1,354 @@ +#include "stdafx.h" + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Variables +/////////////////////////////////////////////////////////////////////////////////////////////////// + +struct TWindowData +{ + HWND hWnd; + RECT Rect; +}; + +static LIST<TWindowData> arWindows(10, HandleKeySortT); + +TWorkingVariables Globals = +{ + 0, 0, false, false +}; + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Functions +/////////////////////////////////////////////////////////////////////////////////////////////////// + +int Abs(int a) +{ + return (a < 0) ? -a : a; +} + +void DockWindowRect(HWND hWnd, bool Sizing, RECT &GivenRect, int SizingEdge, int MouseX = 0, int MouseY = 0) +{ + POINT p; + int XPos, YPos; + int tmpXPos, tmpYPos; + int tmpMouseX, tmpMouseY; + + int diffX = Options.SnapWidth, diffY = Options.SnapWidth; + + RECT tmpRect = GivenRect; + RECT frmRect = GivenRect; + + bool FoundX = false, FoundY = false; + + if (!Sizing) { + GetCursorPos(&p); + if (Globals.SnappedX) { + tmpMouseX = p.x - tmpRect.left; + OffsetRect(&tmpRect, tmpMouseX - MouseX, 0); + OffsetRect(&GivenRect, tmpMouseX - MouseX, 0); + } + else MouseX = p.x - tmpRect.left; + + if (Globals.SnappedY) { + tmpMouseY = p.y - tmpRect.top; + OffsetRect(&tmpRect, 0, tmpMouseY - MouseY); + OffsetRect(&GivenRect, 0, tmpMouseY - MouseY); + } + else MouseY = p.y - tmpRect.top; + } + + int W = tmpRect.right - tmpRect.left; + int H = tmpRect.bottom - tmpRect.top; + + if (!Sizing) { + int i = 0; + for (auto &it : arWindows) { + if (it->hWnd == hWnd) + continue; + + if ((tmpRect.left >= (it->Rect.left - Options.SnapWidth)) && + (tmpRect.left <= (it->Rect.left + Options.SnapWidth)) && + ((tmpRect.top - Options.SnapWidth) < it->Rect.bottom) & + ((tmpRect.bottom + Options.SnapWidth) > it->Rect.top) && + (Abs(tmpRect.left - it->Rect.left) < diffX)) + { + GivenRect.left = it->Rect.left; + GivenRect.right = GivenRect.left + W; + + diffX = Abs(tmpRect.left - it->Rect.left); + + FoundX = true; + } + else if (i != 0 && + (tmpRect.left >= (it->Rect.right - Options.SnapWidth)) && + (tmpRect.left <= (it->Rect.right + Options.SnapWidth)) && + ((tmpRect.top - Options.SnapWidth) < it->Rect.bottom) && + ((tmpRect.bottom + Options.SnapWidth) > it->Rect.top) && + (Abs(tmpRect.left - it->Rect.right) < diffX)) + { + GivenRect.left = it->Rect.right; + GivenRect.right = GivenRect.left + W; + + diffX = Abs(tmpRect.left - it->Rect.right); + + FoundX = true; + } + else if (i != 0 && + (tmpRect.right >= (it->Rect.left - Options.SnapWidth)) && + (tmpRect.right <= (it->Rect.left + Options.SnapWidth)) && + ((tmpRect.top - Options.SnapWidth) < it->Rect.bottom) && + ((tmpRect.bottom + Options.SnapWidth) > it->Rect.top) && + (Abs(tmpRect.right - it->Rect.left) < diffX)) + { + GivenRect.right = it->Rect.left; + GivenRect.left = GivenRect.right - W; + + diffX = Abs(tmpRect.right - it->Rect.left); + + FoundX = true; + } + else if ((tmpRect.right >= (it->Rect.right - Options.SnapWidth)) && + (tmpRect.right <= (it->Rect.right + Options.SnapWidth)) && + ((tmpRect.top - Options.SnapWidth) < it->Rect.bottom) && + ((tmpRect.bottom + Options.SnapWidth) > it->Rect.top) && + (Abs(tmpRect.right - it->Rect.right) < diffX)) + { + GivenRect.right = it->Rect.right; + GivenRect.left = GivenRect.right - W; + + diffX = Abs(tmpRect.right - it->Rect.right); + + FoundX = true; + } + + if ((tmpRect.top >= (it->Rect.top - Options.SnapWidth)) && + (tmpRect.top <= (it->Rect.top + Options.SnapWidth)) && + ((tmpRect.left - Options.SnapWidth) < it->Rect.right) && + ((tmpRect.right + Options.SnapWidth) > it->Rect.left) && + (Abs(tmpRect.top - it->Rect.top) < diffY)) + { + GivenRect.top = it->Rect.top; + GivenRect.bottom = GivenRect.top + H; + + diffY = Abs(tmpRect.top - it->Rect.top); + + FoundY = true; + } + else if (i != 0 && + (tmpRect.top >= (it->Rect.bottom - Options.SnapWidth)) && + (tmpRect.top <= (it->Rect.bottom + Options.SnapWidth)) && + ((tmpRect.left - Options.SnapWidth) < it->Rect.right) && + ((tmpRect.right + Options.SnapWidth) > it->Rect.left) && + (Abs(tmpRect.top - it->Rect.bottom) < diffY)) + { + GivenRect.top = it->Rect.bottom; + GivenRect.bottom = GivenRect.top + H; + + diffY = Abs(tmpRect.top - it->Rect.bottom); + + FoundY = true; + } + else if (i != 0 && + (tmpRect.bottom >= (it->Rect.top - Options.SnapWidth)) && + (tmpRect.bottom <= (it->Rect.top + Options.SnapWidth)) && + ((tmpRect.left - Options.SnapWidth) < it->Rect.right) && + ((tmpRect.right + Options.SnapWidth) > it->Rect.left) && + (Abs(tmpRect.bottom - it->Rect.top) < diffY)) + { + GivenRect.bottom = it->Rect.top; + GivenRect.top = GivenRect.bottom - H; + + diffY = Abs(tmpRect.bottom - it->Rect.top); + + FoundY = true; + } + else if ((tmpRect.bottom >= (it->Rect.bottom - Options.SnapWidth)) && + (tmpRect.bottom <= (it->Rect.bottom + Options.SnapWidth)) && + ((tmpRect.left - Options.SnapWidth) < it->Rect.right) && + ((tmpRect.right + Options.SnapWidth) > it->Rect.left) && + (Abs(tmpRect.bottom - it->Rect.bottom) < diffY)) { + GivenRect.bottom = it->Rect.bottom; + GivenRect.top = GivenRect.bottom - H; + + diffY = Abs(tmpRect.bottom - it->Rect.bottom); + + FoundY = true; + } + i++; + } + + Globals.SnappedX = FoundX; + Globals.SnappedY = FoundY; + } + else { // Sizing + if (SizingEdge == WMSZ_LEFT || SizingEdge == WMSZ_TOPLEFT || SizingEdge == WMSZ_BOTTOMLEFT) + XPos = GivenRect.left; + else + XPos = GivenRect.right; + + if (SizingEdge == WMSZ_TOP || SizingEdge == WMSZ_TOPLEFT || SizingEdge == WMSZ_TOPRIGHT) + YPos = GivenRect.top; + else + YPos = GivenRect.bottom; + + tmpXPos = XPos; + tmpYPos = YPos; + + for (auto &it : arWindows) { + if (it->hWnd == hWnd) + continue; + + if ((tmpXPos >= (it->Rect.left - Options.SnapWidth)) && + (tmpXPos <= (it->Rect.left + Options.SnapWidth)) && + ((tmpRect.top - Options.SnapWidth) < it->Rect.bottom) && + ((tmpRect.bottom + Options.SnapWidth) > it->Rect.top) && + (Abs(tmpXPos - it->Rect.left) < diffX)) + { + XPos = it->Rect.left; + diffX = Abs(tmpXPos - it->Rect.left); + } + else if ((tmpXPos >= (it->Rect.right - Options.SnapWidth)) && + (tmpXPos <= (it->Rect.right + Options.SnapWidth)) && + ((tmpRect.top - Options.SnapWidth) < it->Rect.bottom) && + ((tmpRect.bottom + Options.SnapWidth) > it->Rect.top) && + (Abs(tmpXPos - it->Rect.right) < diffX)) + { + XPos = it->Rect.right; + diffX = Abs(tmpXPos - it->Rect.right); + } + + if ((tmpYPos >= (it->Rect.top - Options.SnapWidth)) && + (tmpYPos <= (it->Rect.top + Options.SnapWidth)) && + ((tmpRect.left - Options.SnapWidth) < it->Rect.right) && + ((tmpRect.right + Options.SnapWidth) > it->Rect.left) && + (Abs(tmpYPos - it->Rect.top) < diffY)) + { + YPos = it->Rect.top; + diffY = Abs(tmpYPos - it->Rect.top); + } + else if ((tmpYPos >= (it->Rect.bottom - Options.SnapWidth)) && + (tmpYPos <= (it->Rect.bottom + Options.SnapWidth)) && + ((tmpRect.left - Options.SnapWidth) < it->Rect.right) && + ((tmpRect.right + Options.SnapWidth) > it->Rect.left) && + (Abs(tmpYPos - it->Rect.bottom) < diffY)) + { + YPos = it->Rect.bottom; + diffY = Abs(tmpYPos - it->Rect.bottom); + } + } + + if (SizingEdge == WMSZ_LEFT || SizingEdge == WMSZ_TOPLEFT || SizingEdge == WMSZ_BOTTOMLEFT) + GivenRect.left = XPos; + else + GivenRect.right = XPos; + + if (SizingEdge == WMSZ_TOP || SizingEdge == WMSZ_TOPLEFT || SizingEdge == WMSZ_TOPRIGHT) + GivenRect.top = YPos; + else + GivenRect.bottom = YPos; + } +} + +void GetFrmRects(HWND ForWindow) +{ + SystemParametersInfo(SPI_GETWORKAREA, 0, &arWindows[0]->Rect, 0); + + for (int i = 1; i < arWindows.getCount(); i++) { + TWindowData *it = arWindows[i]; + if (it->hWnd != ForWindow && IsWindowVisible(it->hWnd)) + GetWindowRect(it->hWnd, &it->Rect); + } +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Subclass Window Proc +/////////////////////////////////////////////////////////////////////////////////////////////////// + +LRESULT CALLBACK WindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) +{ + RECT r; + POINT p; + + if (Options.DoSnap) { + switch (Msg) { + case WM_ENTERSIZEMOVE: + if (Options.ScriverWorkAround) + keybd_event(VK_CONTROL, 0, 0, 0); + + GetWindowRect(hWnd, &r); + GetCursorPos(&p); + Globals.MouseX = p.x - r.left; + Globals.MouseY = p.y - r.top; + GetFrmRects(hWnd); + break; + + case WM_EXITSIZEMOVE: + if (Options.ScriverWorkAround) + keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0); + break; + + case WM_SIZING: + case WM_MOVING: + r = *((PRECT)lParam); + if (Msg == WM_SIZING) + DockWindowRect(hWnd, true, r, wParam); + else + DockWindowRect(hWnd, false, r, wParam, Globals.MouseX, Globals.MouseY); + + (*(PRECT)lParam) = r; + + if (Msg == WM_SIZING) + return 1; + + break; + } + } + + return mir_callNextSubclass(hWnd, WindowProc, Msg, wParam, lParam); +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// exportet Functions +/////////////////////////////////////////////////////////////////////////////////////////////////// + +void WindowStart() +{ + TWindowData *p = (TWindowData*)mir_calloc(sizeof(TWindowData)); + arWindows.insert(p); +} + +bool WindowOpen(HWND hWnd) +{ + if (hWnd == 0) + return false; + + TWindowData *p = (TWindowData*)mir_alloc(sizeof(TWindowData)); + p->hWnd = hWnd; + GetWindowRect(hWnd, &p->Rect); + arWindows.insert(p); + + mir_subclassWindow(hWnd, WindowProc); + return true; +} + +bool WindowClose(HWND hWnd) +{ + if (hWnd == 0) + return false; + + mir_unsubclassWindow(hWnd, WindowProc); + int idx = arWindows.indexOf((TWindowData*)&hWnd); + if (idx != -1) { + TWindowData *p = arWindows[idx]; + arWindows.remove(idx); + mir_free(p); + } + return true; +} + +void WindowCloseAll() +{ + for (auto &it : arWindows) + mir_free(it); + arWindows.destroy(); +} diff --git a/plugins/MagneticWindows/src/Options.cpp b/plugins/MagneticWindows/src/Options.cpp new file mode 100644 index 0000000000..2c9de31cf1 --- /dev/null +++ b/plugins/MagneticWindows/src/Options.cpp @@ -0,0 +1,96 @@ +#include "stdafx.h" + +TOptions Options = { + true, + cDefaultSnapWidth, + false +}; + +INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + TCHAR str[64]; + + switch (msg) { + case WM_INITDIALOG: + TranslateDialogDefault(hwndDlg); + + CheckDlgButton(hwndDlg, IDC_CHK_SNAP, Options.DoSnap?BST_CHECKED:BST_UNCHECKED); + SendDlgItemMessage(hwndDlg, IDC_SLIDER_SNAPWIDTH, TBM_SETRANGE, FALSE, MAKELONG(1,32)); + SendDlgItemMessage(hwndDlg, IDC_SLIDER_SNAPWIDTH, TBM_SETPOS, TRUE, Options.SnapWidth); + + mir_snwprintf(str, TranslateT("%d pix"), Options.SnapWidth); + SetDlgItemText(hwndDlg, IDC_TXT_SNAPWIDTH, str); + + EnableWindow(GetDlgItem(hwndDlg, IDC_SLIDER_SNAPWIDTH), Options.DoSnap); + EnableWindow(GetDlgItem(hwndDlg, IDC_TXT_SNAPWIDTH), Options.DoSnap); + + CheckDlgButton(hwndDlg, IDC_CHK_SCRIVERWORKAROUND, Options.ScriverWorkAround?BST_CHECKED:BST_UNCHECKED); + break; + + case WM_HSCROLL: + mir_snwprintf(str, TranslateT("%d pix"), SendDlgItemMessage(hwndDlg, IDC_SLIDER_SNAPWIDTH, TBM_GETPOS, 0, 0)); + SetDlgItemText(hwndDlg, IDC_TXT_SNAPWIDTH, str); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + + case WM_COMMAND: + switch( LOWORD(wParam)) { + case IDC_CHK_SNAP: + if (HIWORD(wParam) == BN_CLICKED) { + EnableWindow(GetDlgItem(hwndDlg, IDC_SLIDER_SNAPWIDTH), IsDlgButtonChecked(hwndDlg, IDC_CHK_SNAP)); + EnableWindow(GetDlgItem(hwndDlg, IDC_TXT_SNAPWIDTH), IsDlgButtonChecked(hwndDlg, IDC_CHK_SNAP)); + + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + } + break; + + case IDC_CHK_SCRIVERWORKAROUND: + if (HIWORD(wParam) == BN_CLICKED) + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + } + break; + + case WM_NOTIFY: //Here we have pressed either the OK or the APPLY button. + switch(((LPNMHDR)lParam)->idFrom) { + case 0: + switch (((LPNMHDR)lParam)->code) { + case PSN_RESET: + LoadOptions(); + break; + + case PSN_APPLY: + Options.DoSnap = (IsDlgButtonChecked(hwndDlg, IDC_CHK_SNAP) == TRUE); + Options.SnapWidth = SendDlgItemMessage(hwndDlg, IDC_SLIDER_SNAPWIDTH, TBM_GETPOS, 0, 0); + Options.ScriverWorkAround = (IsDlgButtonChecked(hwndDlg, IDC_CHK_SCRIVERWORKAROUND) == TRUE); + + db_set_b(NULL, MODULE_NAME, "DoSnap", Options.DoSnap); + db_set_b(NULL, MODULE_NAME, "SnapWidth", Options.SnapWidth); + db_set_b(NULL, MODULE_NAME, "ScriverWorkAround", Options.ScriverWorkAround); + break; + } + } + break; + } + return 0; +} + +int InitOptions(WPARAM wParam, LPARAM) +{ + OPTIONSDIALOGPAGE Opt = { sizeof(Opt) }; + Opt.pfnDlgProc = OptionsDlgProc; + Opt.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_MAGNETICWINDOWS); + Opt.hInstance = hInst; + Opt.szGroup.a = LPGEN("Customize"); + Opt.szTitle.a = LPGEN("Magnetic Windows"); + Opt.flags = ODPF_BOLDGROUPS; + Options_AddPage(wParam, &Opt); + return 0; +} + +void LoadOptions() +{ + Options.DoSnap = db_get_b(NULL, MODULE_NAME, "DoSnap", 1) != 0; + Options.SnapWidth = db_get_b(NULL, MODULE_NAME, "SnapWidth", cDefaultSnapWidth); + Options.ScriverWorkAround = db_get_b(NULL, MODULE_NAME, "ScriverWorkAround", 0) != 0; +} diff --git a/plugins/MagneticWindows/src/Options.h b/plugins/MagneticWindows/src/Options.h new file mode 100644 index 0000000000..5a5b4bb318 --- /dev/null +++ b/plugins/MagneticWindows/src/Options.h @@ -0,0 +1,16 @@ + +#define cDefaultSnapWidth 12 + +typedef + struct TOptions { + bool DoSnap; + int SnapWidth; + bool ScriverWorkAround; +} TOptions; + +extern TOptions Options; + +INT_PTR CALLBACK OptionsDlgProc(HWND, UINT, WPARAM, LPARAM); + +int InitOptions(WPARAM, LPARAM); +void LoadOptions();
\ No newline at end of file diff --git a/plugins/MagneticWindows/src/SnapToListService.cpp b/plugins/MagneticWindows/src/SnapToListService.cpp new file mode 100644 index 0000000000..779e733827 --- /dev/null +++ b/plugins/MagneticWindows/src/SnapToListService.cpp @@ -0,0 +1,52 @@ +#include "stdafx.h" + +INT_PTR SnapToList(WPARAM wParam, LPARAM Align) +{ + HWND hWnd = (HWND)wParam; + HWND hWndList = pcli->hwndContactList; + + RECT WndRect, ListRect; + GetWindowRect(hWnd, &WndRect); + GetWindowRect(hWndList, &ListRect); + + RECT AlignRect = ListRect; + if ((!(MS_MW_STL_List_Left & Align)) && (MS_MW_STL_List_Right & Align)) + AlignRect.left = AlignRect.right; + else if ((MS_MW_STL_List_Left & Align) && (!(MS_MW_STL_List_Right & Align))) + AlignRect.right = AlignRect.left; + + if ((!(MS_MW_STL_List_Top & Align)) && (MS_MW_STL_List_Bottom & Align)) + AlignRect.top = AlignRect.bottom; + else if ((MS_MW_STL_List_Top & Align) && (!(MS_MW_STL_List_Bottom & Align))) + AlignRect.bottom = AlignRect.top; + + RECT ResultRect = WndRect; + if ((MS_MW_STL_Wnd_Left & Align) && (MS_MW_STL_Wnd_Right & Align)) { + ResultRect.left = AlignRect.left; + ResultRect.right = AlignRect.right; + } + else if ((!(MS_MW_STL_Wnd_Left & Align)) && (MS_MW_STL_Wnd_Right & Align)) { + ResultRect.left = AlignRect.right - (WndRect.right - WndRect.left); + ResultRect.right = AlignRect.right; + } + else if ((MS_MW_STL_Wnd_Left & Align) && (!(MS_MW_STL_Wnd_Right & Align))) { + ResultRect.left = AlignRect.left; + ResultRect.right = AlignRect.left + (WndRect.right - WndRect.left); + } + + if ((MS_MW_STL_Wnd_Top & Align) && (MS_MW_STL_Wnd_Bottom & Align)) { + ResultRect.top = AlignRect.top; + ResultRect.bottom = AlignRect.bottom; + } + else if ((!(MS_MW_STL_Wnd_Top & Align)) && (MS_MW_STL_Wnd_Bottom & Align)) { + ResultRect.top = AlignRect.bottom - (WndRect.bottom - WndRect.top); + ResultRect.bottom = AlignRect.bottom; + } + else if ((MS_MW_STL_Wnd_Top & Align) && (!(MS_MW_STL_Wnd_Bottom & Align))) { + ResultRect.top = AlignRect.top; + ResultRect.bottom = AlignRect.top + (WndRect.bottom - WndRect.top); + } + + MoveWindow(hWnd, ResultRect.left, ResultRect.top, ResultRect.right - ResultRect.left, ResultRect.bottom - ResultRect.top, true); + return 0; +} diff --git a/plugins/MagneticWindows/src/SnapToListService.h b/plugins/MagneticWindows/src/SnapToListService.h new file mode 100644 index 0000000000..187e1b4df9 --- /dev/null +++ b/plugins/MagneticWindows/src/SnapToListService.h @@ -0,0 +1,2 @@ + +INT_PTR SnapToList(WPARAM, LPARAM); diff --git a/plugins/MagneticWindows/src/Version.h b/plugins/MagneticWindows/src/Version.h new file mode 100644 index 0000000000..69c34409b7 --- /dev/null +++ b/plugins/MagneticWindows/src/Version.h @@ -0,0 +1,14 @@ +#define __MAJOR_VERSION 0 +#define __MINOR_VERSION 0 +#define __RELEASE_NUM 3 +#define __BUILD_NUM 2 + +#include <stdver.h> + +#define __PLUGIN_NAME "Magnetic Windows" +#define __FILENAME "MagneticWindows.dll" +#define __DESCRIPTION "Makes the main contactlist and the chat windows snapping to the desktop border and to each other." +#define __AUTHOR "Michael Kunz" +#define __AUTHOREMAIL "Michael.Kunz@s2005.TU-Cemnitz.de" +#define __AUTHORWEB "http://miranda-ng.org/p/MagneticWindows/" +#define __COPYRIGHT "© 2006 Michael Kunz" diff --git a/plugins/MagneticWindows/src/resource.h b/plugins/MagneticWindows/src/resource.h new file mode 100644 index 0000000000..6e45d3041a --- /dev/null +++ b/plugins/MagneticWindows/src/resource.h @@ -0,0 +1,25 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by Options.rc +// + +#define IDD_OPT_MAGNETICWINDOWS 101 + + +#define IDC_MAINFRAME 1001 +#define IDC_SLIDER_SNAPWIDTH 1002 +#define IDC_CHK_SNAP 1003 +#define IDC_TXT_SNAPWIDTH 1004 +#define IDC_CHK_SCRIVERWORKAROUND 1005 + + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 102 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1006 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/plugins/MagneticWindows/src/stdafx.cxx b/plugins/MagneticWindows/src/stdafx.cxx new file mode 100644 index 0000000000..54616ffc22 --- /dev/null +++ b/plugins/MagneticWindows/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 <http://www.gnu.org/licenses/>. +*/ + +#include "stdafx.h" diff --git a/plugins/MagneticWindows/src/stdafx.h b/plugins/MagneticWindows/src/stdafx.h new file mode 100644 index 0000000000..44a0b9dfee --- /dev/null +++ b/plugins/MagneticWindows/src/stdafx.h @@ -0,0 +1,34 @@ +#include <windows.h> +#include <commctrl.h> +#include <stdio.h> + +#include <newpluginapi.h> +#include <m_clist.h> +#include <m_message.h> +#include <m_system.h> +#include <m_options.h> +#include <m_database.h> +#include <m_langpack.h> +#include <m_MagneticWindows.h> + +#include "SnapToListService.h" +#include "Options.h" + +#include "resource.h" +#include "Version.h" + +typedef + struct { + int MouseX, MouseY; + bool SnappedX, SnappedY; + } TWorkingVariables; + + + +#define MODULE_NAME "MagneticWindows" +extern HINSTANCE hInst; + +void WindowStart(); +bool WindowOpen(HWND); +bool WindowClose(HWND); +void WindowCloseAll(); diff --git a/tools/build_scripts/bin15/z2_PackPluginUpdater_x32.txt b/tools/build_scripts/bin15/z2_PackPluginUpdater_x32.txt index 4ef0991ea4..bf90118bdb 100644 --- a/tools/build_scripts/bin15/z2_PackPluginUpdater_x32.txt +++ b/tools/build_scripts/bin15/z2_PackPluginUpdater_x32.txt @@ -73,6 +73,7 @@ Plugins\keyboardnotify.dll Plugins\linklist.dll Plugins\listeningto.dll Plugins\lotusnotify.dll +Plugins\MagneticWindows.dll Plugins\menuex.dll Plugins\messagestate.dll Plugins\minecraftdynmap.dll diff --git a/tools/build_scripts/bin15/z2_PackPluginUpdater_x64.txt b/tools/build_scripts/bin15/z2_PackPluginUpdater_x64.txt index 62a11addac..7737dea1b0 100644 --- a/tools/build_scripts/bin15/z2_PackPluginUpdater_x64.txt +++ b/tools/build_scripts/bin15/z2_PackPluginUpdater_x64.txt @@ -71,6 +71,7 @@ Plugins\jabber.dll Plugins\keyboardnotify.dll Plugins\linklist.dll Plugins\listeningto.dll +Plugins\MagneticWindows.dll Plugins\menuex.dll Plugins\messagestate.dll Plugins\minecraftdynmap.dll |