From b1a77fa391bb99898c544bab8e2d9add58e15960 Mon Sep 17 00:00:00 2001 From: Julian Storer Date: Wed, 29 Jun 2011 16:24:37 +0100 Subject: [PATCH] Tidied up some DynamicLibrary stuff and fixed a drop-shadow problem on mac. --- Builds/Linux/Makefile | 10 +- Builds/MacOSX/Juce.xcodeproj/project.pbxproj | 12 +- Builds/VisualStudio2005/Juce.vcproj | 4 +- Builds/VisualStudio2008/Juce.vcproj | 4 +- Builds/VisualStudio2008_DLL/Juce.vcproj | 4 +- Builds/VisualStudio2010/Juce.vcxproj | 4 +- Builds/VisualStudio2010/Juce.vcxproj.filters | 6 +- Builds/iOS/Juce.xcodeproj/project.pbxproj | 12 +- Juce.jucer | 8 +- juce_amalgamated.cpp | 389 +++++++++--------- juce_amalgamated.h | 7 +- src/core/juce_StandardHeader.h | 2 +- .../windows/juce_ResizableWindow.cpp | 1 + .../components/windows/juce_TopLevelWindow.h | 3 + src/native/common/juce_posix_SharedCode.h | 30 +- src/native/linux/juce_linux_Threads.cpp | 18 - src/native/mac/juce_mac_Threads.mm | 19 - src/native/windows/juce_win32_ComSmartPtr.h | 125 ++++++ .../windows/juce_win32_DynamicLibraryLoader.h | 80 ---- src/native/windows/juce_win32_Misc.cpp | 54 --- src/native/windows/juce_win32_NativeCode.cpp | 1 - .../windows/juce_win32_NativeIncludes.h | 107 +---- src/native/windows/juce_win32_Network.cpp | 69 ++-- src/native/windows/juce_win32_Threads.cpp | 7 +- src/native/windows/juce_win32_WASAPI.cpp | 6 +- src/native/windows/juce_win32_Windowing.cpp | 58 +++ src/threads/juce_DynamicLibrary.h | 2 +- 27 files changed, 499 insertions(+), 543 deletions(-) create mode 100644 src/native/windows/juce_win32_ComSmartPtr.h delete mode 100644 src/native/windows/juce_win32_DynamicLibraryLoader.h diff --git a/Builds/Linux/Makefile b/Builds/Linux/Makefile index 22d50d2396..b8df7a1949 100644 --- a/Builds/Linux/Makefile +++ b/Builds/Linux/Makefile @@ -329,8 +329,8 @@ OBJECTS := \ $(OBJDIR)/juce_win32_NativeCode_c247c7f6.o \ $(OBJDIR)/juce_win32_Network_6c84a66.o \ $(OBJDIR)/juce_win32_OpenGLComponent_d0d99a46.o \ - $(OBJDIR)/juce_win32_Registry_86da784f.o \ $(OBJDIR)/juce_win32_QuickTimeMovieComponent_be08e5f.o \ + $(OBJDIR)/juce_win32_Registry_86da784f.o \ $(OBJDIR)/juce_win32_SystemStats_6446cd68.o \ $(OBJDIR)/juce_win32_Threads_ee986e61.o \ $(OBJDIR)/juce_win32_WASAPI_c7c6c3c3.o \ @@ -1838,14 +1838,14 @@ $(OBJDIR)/juce_win32_OpenGLComponent_d0d99a46.o: ../../src/native/windows/juce_w @echo "Compiling juce_win32_OpenGLComponent.cpp" @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" -$(OBJDIR)/juce_win32_Registry_86da784f.o: ../../src/native/windows/juce_win32_Registry.cpp +$(OBJDIR)/juce_win32_QuickTimeMovieComponent_be08e5f.o: ../../src/native/windows/juce_win32_QuickTimeMovieComponent.cpp -@mkdir -p $(OBJDIR) - @echo "Compiling juce_win32_Registry.cpp" + @echo "Compiling juce_win32_QuickTimeMovieComponent.cpp" @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" -$(OBJDIR)/juce_win32_QuickTimeMovieComponent_be08e5f.o: ../../src/native/windows/juce_win32_QuickTimeMovieComponent.cpp +$(OBJDIR)/juce_win32_Registry_86da784f.o: ../../src/native/windows/juce_win32_Registry.cpp -@mkdir -p $(OBJDIR) - @echo "Compiling juce_win32_QuickTimeMovieComponent.cpp" + @echo "Compiling juce_win32_Registry.cpp" @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" $(OBJDIR)/juce_win32_SystemStats_6446cd68.o: ../../src/native/windows/juce_win32_SystemStats.cpp diff --git a/Builds/MacOSX/Juce.xcodeproj/project.pbxproj b/Builds/MacOSX/Juce.xcodeproj/project.pbxproj index 6dfb84ea51..298a7f0ee0 100644 --- a/Builds/MacOSX/Juce.xcodeproj/project.pbxproj +++ b/Builds/MacOSX/Juce.xcodeproj/project.pbxproj @@ -324,8 +324,8 @@ A46B0025A68136ED993E0D85 = { isa = PBXBuildFile; fileRef = 50159A5B7A552A6C1EB557F3; }; B99678E919BF547A3A3F5D6E = { isa = PBXBuildFile; fileRef = CDA5FCC51F6C1E84D7DC3274; }; 5B714CDD0082419BFED7D2D4 = { isa = PBXBuildFile; fileRef = B14735381ADB00741166E330; }; - 5B33FFE120A47EF42CBC05E4 = { isa = PBXBuildFile; fileRef = 0EB41C0AB478EE02D8C851F9; }; 2DD498313DA488A5063C4C1B = { isa = PBXBuildFile; fileRef = 09AE0882D58BE1715219556A; }; + 5B33FFE120A47EF42CBC05E4 = { isa = PBXBuildFile; fileRef = 0EB41C0AB478EE02D8C851F9; }; 552D45FB250C62F86CD02A57 = { isa = PBXBuildFile; fileRef = FBE07C5CC622A5D36BDAB9E1; }; 0E8E9829E95E32163F45482D = { isa = PBXBuildFile; fileRef = B07C853EB60D8D8691BC1B4B; }; 6801797B247CB3A6890C0AB0 = { isa = PBXBuildFile; fileRef = 5D32C8856093B33438AEB758; }; @@ -1019,10 +1019,10 @@ F3B50EE3939E9F16D13C3C7C = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_win32_AudioCDReader.cpp"; path = "../../src/native/windows/juce_win32_AudioCDReader.cpp"; sourceTree = "SOURCE_ROOT"; }; 9C4D1018ECC0BA07346453EF = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_win32_AutoLinkLibraries.h"; path = "../../src/native/windows/juce_win32_AutoLinkLibraries.h"; sourceTree = "SOURCE_ROOT"; }; 3A37CD82212075940421CE4F = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_win32_CameraDevice.cpp"; path = "../../src/native/windows/juce_win32_CameraDevice.cpp"; sourceTree = "SOURCE_ROOT"; }; + B296F736C0CD6AC15BE6424B = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_win32_ComSmartPtr.h"; path = "../../src/native/windows/juce_win32_ComSmartPtr.h"; sourceTree = "SOURCE_ROOT"; }; 7F3EF672D07ECE3E13AAF267 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_win32_Direct2DGraphicsContext.cpp"; path = "../../src/native/windows/juce_win32_Direct2DGraphicsContext.cpp"; sourceTree = "SOURCE_ROOT"; }; 249959E338D7750E56A9F2F8 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_win32_DirectShowComponent.cpp"; path = "../../src/native/windows/juce_win32_DirectShowComponent.cpp"; sourceTree = "SOURCE_ROOT"; }; 58B70C726D186B4E770300BC = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_win32_DirectSound.cpp"; path = "../../src/native/windows/juce_win32_DirectSound.cpp"; sourceTree = "SOURCE_ROOT"; }; - BA66E265749F75DBA86EC3F1 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_win32_DynamicLibraryLoader.h"; path = "../../src/native/windows/juce_win32_DynamicLibraryLoader.h"; sourceTree = "SOURCE_ROOT"; }; DCD09B6EF4A4A109DE01F152 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_win32_FileChooser.cpp"; path = "../../src/native/windows/juce_win32_FileChooser.cpp"; sourceTree = "SOURCE_ROOT"; }; 7527A5E8F4F39581159D3E5B = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_win32_Files.cpp"; path = "../../src/native/windows/juce_win32_Files.cpp"; sourceTree = "SOURCE_ROOT"; }; 1DBF9DAAD0690CB2CA4E9960 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_win32_Fonts.cpp"; path = "../../src/native/windows/juce_win32_Fonts.cpp"; sourceTree = "SOURCE_ROOT"; }; @@ -1033,8 +1033,8 @@ E7625D7A06CBC11F40A56A70 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_win32_NativeIncludes.h"; path = "../../src/native/windows/juce_win32_NativeIncludes.h"; sourceTree = "SOURCE_ROOT"; }; CDA5FCC51F6C1E84D7DC3274 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_win32_Network.cpp"; path = "../../src/native/windows/juce_win32_Network.cpp"; sourceTree = "SOURCE_ROOT"; }; B14735381ADB00741166E330 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_win32_OpenGLComponent.cpp"; path = "../../src/native/windows/juce_win32_OpenGLComponent.cpp"; sourceTree = "SOURCE_ROOT"; }; - 0EB41C0AB478EE02D8C851F9 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_win32_Registry.cpp"; path = "../../src/native/windows/juce_win32_Registry.cpp"; sourceTree = "SOURCE_ROOT"; }; 09AE0882D58BE1715219556A = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_win32_QuickTimeMovieComponent.cpp"; path = "../../src/native/windows/juce_win32_QuickTimeMovieComponent.cpp"; sourceTree = "SOURCE_ROOT"; }; + 0EB41C0AB478EE02D8C851F9 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_win32_Registry.cpp"; path = "../../src/native/windows/juce_win32_Registry.cpp"; sourceTree = "SOURCE_ROOT"; }; FBE07C5CC622A5D36BDAB9E1 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_win32_SystemStats.cpp"; path = "../../src/native/windows/juce_win32_SystemStats.cpp"; sourceTree = "SOURCE_ROOT"; }; B07C853EB60D8D8691BC1B4B = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_win32_Threads.cpp"; path = "../../src/native/windows/juce_win32_Threads.cpp"; sourceTree = "SOURCE_ROOT"; }; 5D32C8856093B33438AEB758 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_win32_WASAPI.cpp"; path = "../../src/native/windows/juce_win32_WASAPI.cpp"; sourceTree = "SOURCE_ROOT"; }; @@ -1862,10 +1862,10 @@ F3B50EE3939E9F16D13C3C7C, 9C4D1018ECC0BA07346453EF, 3A37CD82212075940421CE4F, + B296F736C0CD6AC15BE6424B, 7F3EF672D07ECE3E13AAF267, 249959E338D7750E56A9F2F8, 58B70C726D186B4E770300BC, - BA66E265749F75DBA86EC3F1, DCD09B6EF4A4A109DE01F152, 7527A5E8F4F39581159D3E5B, 1DBF9DAAD0690CB2CA4E9960, @@ -1876,8 +1876,8 @@ E7625D7A06CBC11F40A56A70, CDA5FCC51F6C1E84D7DC3274, B14735381ADB00741166E330, - 0EB41C0AB478EE02D8C851F9, 09AE0882D58BE1715219556A, + 0EB41C0AB478EE02D8C851F9, FBE07C5CC622A5D36BDAB9E1, B07C853EB60D8D8691BC1B4B, 5D32C8856093B33438AEB758, @@ -2387,8 +2387,8 @@ A46B0025A68136ED993E0D85, B99678E919BF547A3A3F5D6E, 5B714CDD0082419BFED7D2D4, - 5B33FFE120A47EF42CBC05E4, 2DD498313DA488A5063C4C1B, + 5B33FFE120A47EF42CBC05E4, 552D45FB250C62F86CD02A57, 0E8E9829E95E32163F45482D, 6801797B247CB3A6890C0AB0, diff --git a/Builds/VisualStudio2005/Juce.vcproj b/Builds/VisualStudio2005/Juce.vcproj index 15f9de1fc6..fcd41e82c8 100644 --- a/Builds/VisualStudio2005/Juce.vcproj +++ b/Builds/VisualStudio2005/Juce.vcproj @@ -922,10 +922,10 @@ + - @@ -936,8 +936,8 @@ - + diff --git a/Builds/VisualStudio2008/Juce.vcproj b/Builds/VisualStudio2008/Juce.vcproj index 52520bea60..7ab0421ba0 100644 --- a/Builds/VisualStudio2008/Juce.vcproj +++ b/Builds/VisualStudio2008/Juce.vcproj @@ -922,10 +922,10 @@ + - @@ -936,8 +936,8 @@ - + diff --git a/Builds/VisualStudio2008_DLL/Juce.vcproj b/Builds/VisualStudio2008_DLL/Juce.vcproj index e80c2c5ee1..f3347f92a7 100644 --- a/Builds/VisualStudio2008_DLL/Juce.vcproj +++ b/Builds/VisualStudio2008_DLL/Juce.vcproj @@ -924,10 +924,10 @@ + - @@ -938,8 +938,8 @@ - + diff --git a/Builds/VisualStudio2010/Juce.vcxproj b/Builds/VisualStudio2010/Juce.vcxproj index a721d61858..3d3ced0910 100644 --- a/Builds/VisualStudio2010/Juce.vcxproj +++ b/Builds/VisualStudio2010/Juce.vcxproj @@ -412,8 +412,8 @@ - + @@ -792,7 +792,7 @@ - + diff --git a/Builds/VisualStudio2010/Juce.vcxproj.filters b/Builds/VisualStudio2010/Juce.vcxproj.filters index 83e575d122..5e4de1d9f6 100644 --- a/Builds/VisualStudio2010/Juce.vcxproj.filters +++ b/Builds/VisualStudio2010/Juce.vcxproj.filters @@ -1171,10 +1171,10 @@ Juce\Source\native\windows - + Juce\Source\native\windows - + Juce\Source\native\windows @@ -2307,7 +2307,7 @@ Juce\Source\native\windows - + Juce\Source\native\windows diff --git a/Builds/iOS/Juce.xcodeproj/project.pbxproj b/Builds/iOS/Juce.xcodeproj/project.pbxproj index a1fd8a38bd..363f5f6d0e 100644 --- a/Builds/iOS/Juce.xcodeproj/project.pbxproj +++ b/Builds/iOS/Juce.xcodeproj/project.pbxproj @@ -324,8 +324,8 @@ A46B0025A68136ED993E0D85 = { isa = PBXBuildFile; fileRef = 50159A5B7A552A6C1EB557F3; }; B99678E919BF547A3A3F5D6E = { isa = PBXBuildFile; fileRef = CDA5FCC51F6C1E84D7DC3274; }; 5B714CDD0082419BFED7D2D4 = { isa = PBXBuildFile; fileRef = B14735381ADB00741166E330; }; - 5B33FFE120A47EF42CBC05E4 = { isa = PBXBuildFile; fileRef = 0EB41C0AB478EE02D8C851F9; }; 2DD498313DA488A5063C4C1B = { isa = PBXBuildFile; fileRef = 09AE0882D58BE1715219556A; }; + 5B33FFE120A47EF42CBC05E4 = { isa = PBXBuildFile; fileRef = 0EB41C0AB478EE02D8C851F9; }; 552D45FB250C62F86CD02A57 = { isa = PBXBuildFile; fileRef = FBE07C5CC622A5D36BDAB9E1; }; 0E8E9829E95E32163F45482D = { isa = PBXBuildFile; fileRef = B07C853EB60D8D8691BC1B4B; }; 6801797B247CB3A6890C0AB0 = { isa = PBXBuildFile; fileRef = 5D32C8856093B33438AEB758; }; @@ -1019,10 +1019,10 @@ F3B50EE3939E9F16D13C3C7C = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_win32_AudioCDReader.cpp"; path = "../../src/native/windows/juce_win32_AudioCDReader.cpp"; sourceTree = "SOURCE_ROOT"; }; 9C4D1018ECC0BA07346453EF = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_win32_AutoLinkLibraries.h"; path = "../../src/native/windows/juce_win32_AutoLinkLibraries.h"; sourceTree = "SOURCE_ROOT"; }; 3A37CD82212075940421CE4F = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_win32_CameraDevice.cpp"; path = "../../src/native/windows/juce_win32_CameraDevice.cpp"; sourceTree = "SOURCE_ROOT"; }; + B296F736C0CD6AC15BE6424B = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_win32_ComSmartPtr.h"; path = "../../src/native/windows/juce_win32_ComSmartPtr.h"; sourceTree = "SOURCE_ROOT"; }; 7F3EF672D07ECE3E13AAF267 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_win32_Direct2DGraphicsContext.cpp"; path = "../../src/native/windows/juce_win32_Direct2DGraphicsContext.cpp"; sourceTree = "SOURCE_ROOT"; }; 249959E338D7750E56A9F2F8 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_win32_DirectShowComponent.cpp"; path = "../../src/native/windows/juce_win32_DirectShowComponent.cpp"; sourceTree = "SOURCE_ROOT"; }; 58B70C726D186B4E770300BC = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_win32_DirectSound.cpp"; path = "../../src/native/windows/juce_win32_DirectSound.cpp"; sourceTree = "SOURCE_ROOT"; }; - BA66E265749F75DBA86EC3F1 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_win32_DynamicLibraryLoader.h"; path = "../../src/native/windows/juce_win32_DynamicLibraryLoader.h"; sourceTree = "SOURCE_ROOT"; }; DCD09B6EF4A4A109DE01F152 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_win32_FileChooser.cpp"; path = "../../src/native/windows/juce_win32_FileChooser.cpp"; sourceTree = "SOURCE_ROOT"; }; 7527A5E8F4F39581159D3E5B = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_win32_Files.cpp"; path = "../../src/native/windows/juce_win32_Files.cpp"; sourceTree = "SOURCE_ROOT"; }; 1DBF9DAAD0690CB2CA4E9960 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_win32_Fonts.cpp"; path = "../../src/native/windows/juce_win32_Fonts.cpp"; sourceTree = "SOURCE_ROOT"; }; @@ -1033,8 +1033,8 @@ E7625D7A06CBC11F40A56A70 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_win32_NativeIncludes.h"; path = "../../src/native/windows/juce_win32_NativeIncludes.h"; sourceTree = "SOURCE_ROOT"; }; CDA5FCC51F6C1E84D7DC3274 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_win32_Network.cpp"; path = "../../src/native/windows/juce_win32_Network.cpp"; sourceTree = "SOURCE_ROOT"; }; B14735381ADB00741166E330 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_win32_OpenGLComponent.cpp"; path = "../../src/native/windows/juce_win32_OpenGLComponent.cpp"; sourceTree = "SOURCE_ROOT"; }; - 0EB41C0AB478EE02D8C851F9 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_win32_Registry.cpp"; path = "../../src/native/windows/juce_win32_Registry.cpp"; sourceTree = "SOURCE_ROOT"; }; 09AE0882D58BE1715219556A = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_win32_QuickTimeMovieComponent.cpp"; path = "../../src/native/windows/juce_win32_QuickTimeMovieComponent.cpp"; sourceTree = "SOURCE_ROOT"; }; + 0EB41C0AB478EE02D8C851F9 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_win32_Registry.cpp"; path = "../../src/native/windows/juce_win32_Registry.cpp"; sourceTree = "SOURCE_ROOT"; }; FBE07C5CC622A5D36BDAB9E1 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_win32_SystemStats.cpp"; path = "../../src/native/windows/juce_win32_SystemStats.cpp"; sourceTree = "SOURCE_ROOT"; }; B07C853EB60D8D8691BC1B4B = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_win32_Threads.cpp"; path = "../../src/native/windows/juce_win32_Threads.cpp"; sourceTree = "SOURCE_ROOT"; }; 5D32C8856093B33438AEB758 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_win32_WASAPI.cpp"; path = "../../src/native/windows/juce_win32_WASAPI.cpp"; sourceTree = "SOURCE_ROOT"; }; @@ -1862,10 +1862,10 @@ F3B50EE3939E9F16D13C3C7C, 9C4D1018ECC0BA07346453EF, 3A37CD82212075940421CE4F, + B296F736C0CD6AC15BE6424B, 7F3EF672D07ECE3E13AAF267, 249959E338D7750E56A9F2F8, 58B70C726D186B4E770300BC, - BA66E265749F75DBA86EC3F1, DCD09B6EF4A4A109DE01F152, 7527A5E8F4F39581159D3E5B, 1DBF9DAAD0690CB2CA4E9960, @@ -1876,8 +1876,8 @@ E7625D7A06CBC11F40A56A70, CDA5FCC51F6C1E84D7DC3274, B14735381ADB00741166E330, - 0EB41C0AB478EE02D8C851F9, 09AE0882D58BE1715219556A, + 0EB41C0AB478EE02D8C851F9, FBE07C5CC622A5D36BDAB9E1, B07C853EB60D8D8691BC1B4B, 5D32C8856093B33438AEB758, @@ -2391,8 +2391,8 @@ A46B0025A68136ED993E0D85, B99678E919BF547A3A3F5D6E, 5B714CDD0082419BFED7D2D4, - 5B33FFE120A47EF42CBC05E4, 2DD498313DA488A5063C4C1B, + 5B33FFE120A47EF42CBC05E4, 552D45FB250C62F86CD02A57, 0E8E9829E95E32163F45482D, 6801797B247CB3A6890C0AB0, diff --git a/Juce.jucer b/Juce.jucer index 1bad2e75df..f876827119 100644 --- a/Juce.jucer +++ b/Juce.jucer @@ -1422,14 +1422,14 @@ resource="0" file="src/native/windows/juce_win32_AutoLinkLibraries.h"/> + - - + class ComSmartPtr @@ -770,6 +774,23 @@ protected: int refCount; }; +#endif // __JUCE_WIN32_COMSMARTPTR_JUCEHEADER__ + +/*** End of inlined file: juce_win32_ComSmartPtr.h ***/ + +/* Used with DynamicLibrary to simplify importing functions + + functionName: function to import + localFunctionName: name you want to use to actually call it (must be different) + returnType: the return type + object: the DynamicLibrary to use + params: list of params (bracketed) +*/ +#define JUCE_DLL_FUNCTION(functionName, localFunctionName, returnType, object, params) \ + typedef returnType (WINAPI *type##localFunctionName) params; \ + type##localFunctionName localFunctionName \ + = (type##localFunctionName)object.getFunction (#functionName); + #endif // __JUCE_WIN32_NATIVEINCLUDES_JUCEHEADER__ /*** End of inlined file: juce_win32_NativeIncludes.h ***/ @@ -80508,6 +80529,7 @@ int ResizableWindow::getDesktopWindowStyleFlags() const void ResizableWindow::addToDesktop() { Component::addToDesktop (ResizableWindow::getDesktopWindowStyleFlags()); + setDropShadowEnabled (isDropShadowEnabled()); // force an update to clear away any fake shadows if necessary. } void ResizableWindow::clearContentComponent() @@ -244590,63 +244612,6 @@ BEGIN_JUCE_NAMESPACE // Now include the actual code files.. -/*** Start of inlined file: juce_win32_DynamicLibraryLoader.h ***/ -#ifndef __JUCE_WIN32_DYNAMICLIBRARYLOADER_JUCEHEADER__ -#define __JUCE_WIN32_DYNAMICLIBRARYLOADER_JUCEHEADER__ - -#ifndef DOXYGEN - -// use with DynamicLibraryLoader to simplify importing functions -// -// functionName: function to import -// localFunctionName: name you want to use to actually call it (must be different) -// returnType: the return type -// object: the DynamicLibraryLoader to use -// params: list of params (bracketed) -// -#define DynamicLibraryImport(functionName, localFunctionName, returnType, object, params) \ - typedef returnType (WINAPI *type##localFunctionName) params; \ - type##localFunctionName localFunctionName \ - = (type##localFunctionName)object.findProcAddress (#functionName); - -// loads and unloads a DLL automatically -class JUCE_API DynamicLibraryLoader -{ -public: - DynamicLibraryLoader (const String& name = String::empty) - : libHandle (0) - { - load (name); - } - - ~DynamicLibraryLoader() - { - load (String::empty); - } - - bool load (const String& name) - { - FreeLibrary ((HMODULE) libHandle); - libHandle = name.isNotEmpty() ? LoadLibrary (name.toWideCharPointer()) : 0; - return libHandle != 0; - } - - void* findProcAddress (const String& functionName) - { - return (void*) GetProcAddress ((HMODULE) libHandle, functionName.toUTF8()); // (void* cast is required for mingw) - } - -private: - void* libHandle; -}; - -#endif -#endif // __JUCE_WIN32_DYNAMICLIBRARYLOADER_JUCEHEADER__ - -/*** End of inlined file: juce_win32_DynamicLibraryLoader.h ***/ - - - /*** Start of inlined file: juce_win32_SystemStats.cpp ***/ // (This file gets included by juce_win32_NativeCode.cpp, rather than being // compiled on its own). @@ -244992,6 +244957,7 @@ String SystemStats::getComputerName() /*** End of inlined file: juce_win32_SystemStats.cpp ***/ + /*** Start of inlined file: juce_win32_Threads.cpp ***/ // (This file gets included by juce_win32_NativeCode.cpp, rather than being // compiled on its own). @@ -245275,6 +245241,8 @@ void Process::terminate() bool DynamicLibrary::open (const String& name) { + close(); + JUCE_TRY { handle = LoadLibrary (name.toWideCharPointer()); @@ -245284,12 +245252,15 @@ bool DynamicLibrary::open (const String& name) return handle != nullptr; } -void DynamicLibrary::close() noexcept +void DynamicLibrary::close() { JUCE_TRY { if (handle != nullptr) + { FreeLibrary ((HMODULE) handle); + handle = nullptr; + } } JUCE_CATCH_ALL } @@ -246632,8 +246603,8 @@ namespace MACAddressHelpers { void getViaGetAdaptersInfo (Array& result) { - DynamicLibraryLoader dll ("iphlpapi.dll"); - DynamicLibraryImport (GetAdaptersInfo, getAdaptersInfo, DWORD, dll, (PIP_ADAPTER_INFO, PULONG)) + DynamicLibrary dll ("iphlpapi.dll"); + JUCE_DLL_FUNCTION (GetAdaptersInfo, getAdaptersInfo, DWORD, dll, (PIP_ADAPTER_INFO, PULONG)) if (getAdaptersInfo != 0) { @@ -246660,8 +246631,8 @@ namespace MACAddressHelpers void getViaNetBios (Array& result) { - DynamicLibraryLoader dll ("netapi32.dll"); - DynamicLibraryImport (Netbios, NetbiosCall, UCHAR, dll, (PNCB)) + DynamicLibrary dll ("netapi32.dll"); + JUCE_DLL_FUNCTION (Netbios, NetbiosCall, UCHAR, dll, (PNCB)) if (NetbiosCall != 0) { @@ -246717,45 +246688,40 @@ bool Process::openEmailWithAttachments (const String& targetEmailAddress, const String& bodyText, const StringArray& filesToAttach) { - HMODULE h = LoadLibraryA ("MAPI32.dll"); - typedef ULONG (WINAPI *MAPISendMailType) (LHANDLE, ULONG, lpMapiMessage, ::FLAGS, ULONG); - MAPISendMailType mapiSendMail = (MAPISendMailType) GetProcAddress (h, "MAPISendMail"); - bool ok = false; + DynamicLibrary mapiLib ("MAPI32.dll"); + MAPISendMailType mapiSendMail = (MAPISendMailType) mapiLib.getFunction ("MAPISendMail"); - if (mapiSendMail != 0) - { - MapiMessage message = { 0 }; - message.lpszSubject = (LPSTR) emailSubject.toUTF8().getAddress(); - message.lpszNoteText = (LPSTR) bodyText.toUTF8().getAddress(); + if (mapiSendMail == nullptr) + return false; - MapiRecipDesc recip = { 0 }; - recip.ulRecipClass = MAPI_TO; - String targetEmailAddress_ (targetEmailAddress); - if (targetEmailAddress_.isEmpty()) - targetEmailAddress_ = " "; // (Windows Mail can't deal with a blank address) - recip.lpszName = (LPSTR) targetEmailAddress_.toUTF8().getAddress(); - message.nRecipCount = 1; - message.lpRecips = &recip; + MapiMessage message = { 0 }; + message.lpszSubject = (LPSTR) emailSubject.toUTF8().getAddress(); + message.lpszNoteText = (LPSTR) bodyText.toUTF8().getAddress(); - HeapBlock files; - files.calloc (filesToAttach.size()); + MapiRecipDesc recip = { 0 }; + recip.ulRecipClass = MAPI_TO; + String targetEmailAddress_ (targetEmailAddress); + if (targetEmailAddress_.isEmpty()) + targetEmailAddress_ = " "; // (Windows Mail can't deal with a blank address) + recip.lpszName = (LPSTR) targetEmailAddress_.toUTF8().getAddress(); + message.nRecipCount = 1; + message.lpRecips = &recip; - message.nFileCount = filesToAttach.size(); - message.lpFiles = files; + HeapBlock files; + files.calloc (filesToAttach.size()); - for (int i = 0; i < filesToAttach.size(); ++i) - { - files[i].nPosition = (ULONG) -1; - files[i].lpszPathName = (LPSTR) filesToAttach[i].toUTF8().getAddress(); - } + message.nFileCount = filesToAttach.size(); + message.lpFiles = files; - ok = (mapiSendMail (0, 0, &message, MAPI_DIALOG | MAPI_LOGON_UI, 0) == SUCCESS_SUCCESS); + for (int i = 0; i < filesToAttach.size(); ++i) + { + files[i].nPosition = (ULONG) -1; + files[i].lpszPathName = (LPSTR) filesToAttach[i].toUTF8().getAddress(); } - FreeLibrary (h); - return ok; + return mapiSendMail (0, 0, &message, MAPI_DIALOG | MAPI_LOGON_UI, 0) == SUCCESS_SUCCESS; } #endif @@ -251368,6 +251334,63 @@ void LookAndFeel::playAlertSound() MessageBeep (MB_OK); } +void SystemClipboard::copyTextToClipboard (const String& text) +{ + if (OpenClipboard (0) != 0) + { + if (EmptyClipboard() != 0) + { + const int bytesNeeded = CharPointer_UTF16::getBytesRequiredFor (text.getCharPointer()) + 4; + + if (bytesNeeded > 0) + { + HGLOBAL bufH = GlobalAlloc (GMEM_MOVEABLE | GMEM_DDESHARE | GMEM_ZEROINIT, bytesNeeded + sizeof (WCHAR)); + + if (bufH != 0) + { + WCHAR* const data = static_cast (GlobalLock (bufH)); + + if (data != nullptr) + { + text.copyToUTF16 (data, bytesNeeded); + GlobalUnlock (bufH); + + SetClipboardData (CF_UNICODETEXT, bufH); + } + } + } + } + + CloseClipboard(); + } +} + +String SystemClipboard::getTextFromClipboard() +{ + String result; + + if (OpenClipboard (0) != 0) + { + HANDLE bufH = GetClipboardData (CF_UNICODETEXT); + + if (bufH != 0) + { + const WCHAR* const data = (const WCHAR*) GlobalLock (bufH); + + if (data != nullptr) + { + result = String (data, (int) (GlobalSize (bufH) / sizeof (WCHAR))); + + GlobalUnlock (bufH); + } + } + + CloseClipboard(); + } + + return result; +} + void Desktop::setKioskComponent (Component* kioskModeComponent, bool enableOrDisable, bool /*allowMenusAndBars*/) { if (enableOrDisable) @@ -252068,59 +252091,6 @@ void FileChooser::showPlatformDialog (Array& results, const String& title_ // compiled on its own). #if JUCE_INCLUDED_FILE -void SystemClipboard::copyTextToClipboard (const String& text) -{ - if (OpenClipboard (0) != 0) - { - if (EmptyClipboard() != 0) - { - const int bytesNeeded = CharPointer_UTF16::getBytesRequiredFor (text.getCharPointer()) + 4; - - if (bytesNeeded > 0) - { - HGLOBAL bufH = GlobalAlloc (GMEM_MOVEABLE | GMEM_DDESHARE | GMEM_ZEROINIT, bytesNeeded + sizeof (WCHAR)); - - if (bufH != 0) - { - WCHAR* const data = static_cast (GlobalLock (bufH)); - text.copyToUTF16 (data, bytesNeeded); - GlobalUnlock (bufH); - - SetClipboardData (CF_UNICODETEXT, bufH); - } - } - } - - CloseClipboard(); - } -} - -String SystemClipboard::getTextFromClipboard() -{ - String result; - - if (OpenClipboard (0) != 0) - { - HANDLE bufH = GetClipboardData (CF_UNICODETEXT); - - if (bufH != 0) - { - const WCHAR* const data = (const WCHAR*) GlobalLock (bufH); - - if (data != nullptr) - { - result = String (data, (int) (GlobalSize (bufH) / sizeof (WCHAR))); - - GlobalUnlock (bufH); - } - } - - CloseClipboard(); - } - - return result; -} - bool juce_IsRunningInWine() { HMODULE ntdll = GetModuleHandle (_T("ntdll.dll")); @@ -260712,9 +260682,9 @@ public: void setMMThreadPriority() { - DynamicLibraryLoader dll ("avrt.dll"); - DynamicLibraryImport (AvSetMmThreadCharacteristicsW, avSetMmThreadCharacteristics, HANDLE, dll, (LPCWSTR, LPDWORD)) - DynamicLibraryImport (AvSetMmThreadPriority, avSetMmThreadPriority, HANDLE, dll, (HANDLE, AVRT_PRIORITY)) + DynamicLibrary dll ("avrt.dll"); + JUCE_DLL_FUNCTION (AvSetMmThreadCharacteristicsW, avSetMmThreadCharacteristics, HANDLE, dll, (LPCWSTR, LPDWORD)) + JUCE_DLL_FUNCTION (AvSetMmThreadPriority, avSetMmThreadPriority, HANDLE, dll, (HANDLE, AVRT_PRIORITY)) if (avSetMmThreadCharacteristics != 0 && avSetMmThreadPriority != 0) { @@ -262806,12 +262776,12 @@ void Thread::yield() versions, and a lot of distros seem to ship with obsolete versions) */ #if defined (CPU_ISSET) && ! defined (SUPPORT_AFFINITIES) - #define SUPPORT_AFFINITIES 1 + #define SUPPORT_AFFINITIES 1 #endif void Thread::setCurrentThreadAffinityMask (const uint32 affinityMask) { -#if SUPPORT_AFFINITIES + #if SUPPORT_AFFINITIES cpu_set_t affinity; CPU_ZERO (&affinity); @@ -262829,13 +262799,34 @@ void Thread::setCurrentThreadAffinityMask (const uint32 affinityMask) sched_setaffinity (getpid(), sizeof (cpu_set_t), &affinity); sched_yield(); -#else + #else /* affinities aren't supported because either the appropriate header files weren't found, or the SUPPORT_AFFINITIES macro was turned off */ jassertfalse; (void) affinityMask; -#endif + #endif +} + +bool DynamicLibrary::open (const String& name) +{ + close(); + handle = dlopen (name.toUTF8(), RTLD_LOCAL | RTLD_NOW); + return handle != 0; +} + +void DynamicLibrary::close() +{ + if (handle != nullptr) + { + dlclose (handle); + handle = nullptr; + } +} + +void* DynamicLibrary::getFunction (const String& functionName) noexcept +{ + return handle != nullptr ? dlsym (handle, functionName.toUTF8()) : nullptr; } /*** End of inlined file: juce_posix_SharedCode.h ***/ @@ -264021,24 +264012,6 @@ void Process::lowerPrivilege() } } -bool DynamicLibrary::open (const String& name) -{ - close(); - handle = dlopen (name.toUTF8(), RTLD_LOCAL | RTLD_NOW); - return handle != 0; -} - -void DynamicLibrary::close() noexcept -{ - if (handle != nullptr) - dlclose (handle); -} - -void* DynamicLibrary::getFunction (const String& functionName) noexcept -{ - return handle != nullptr ? dlsym (handle, functionName.toUTF8()) : nullptr; -} - #endif /*** End of inlined file: juce_linux_Threads.cpp ***/ @@ -271994,24 +271967,6 @@ void Process::setPriority (ProcessPriority) // xxx } -bool DynamicLibrary::open (const String& name) -{ - close(); - handle = dlopen (name.toUTF8(), RTLD_LOCAL | RTLD_NOW); - return handle != 0; -} - -void DynamicLibrary::close() noexcept -{ - if (handle != nullptr) - dlclose (handle); -} - -void* DynamicLibrary::getFunction (const String& functionName) noexcept -{ - return handle != nullptr ? dlsym (handle, functionName.toUTF8()) : nullptr; -} - #endif /*** End of inlined file: juce_mac_Threads.mm ***/ @@ -272843,12 +272798,12 @@ void Thread::yield() versions, and a lot of distros seem to ship with obsolete versions) */ #if defined (CPU_ISSET) && ! defined (SUPPORT_AFFINITIES) - #define SUPPORT_AFFINITIES 1 + #define SUPPORT_AFFINITIES 1 #endif void Thread::setCurrentThreadAffinityMask (const uint32 affinityMask) { -#if SUPPORT_AFFINITIES + #if SUPPORT_AFFINITIES cpu_set_t affinity; CPU_ZERO (&affinity); @@ -272866,13 +272821,34 @@ void Thread::setCurrentThreadAffinityMask (const uint32 affinityMask) sched_setaffinity (getpid(), sizeof (cpu_set_t), &affinity); sched_yield(); -#else + #else /* affinities aren't supported because either the appropriate header files weren't found, or the SUPPORT_AFFINITIES macro was turned off */ jassertfalse; (void) affinityMask; -#endif + #endif +} + +bool DynamicLibrary::open (const String& name) +{ + close(); + handle = dlopen (name.toUTF8(), RTLD_LOCAL | RTLD_NOW); + return handle != 0; +} + +void DynamicLibrary::close() +{ + if (handle != nullptr) + { + dlclose (handle); + handle = nullptr; + } +} + +void* DynamicLibrary::getFunction (const String& functionName) noexcept +{ + return handle != nullptr ? dlsym (handle, functionName.toUTF8()) : nullptr; } /*** End of inlined file: juce_posix_SharedCode.h ***/ @@ -289783,12 +289759,12 @@ void Thread::yield() versions, and a lot of distros seem to ship with obsolete versions) */ #if defined (CPU_ISSET) && ! defined (SUPPORT_AFFINITIES) - #define SUPPORT_AFFINITIES 1 + #define SUPPORT_AFFINITIES 1 #endif void Thread::setCurrentThreadAffinityMask (const uint32 affinityMask) { -#if SUPPORT_AFFINITIES + #if SUPPORT_AFFINITIES cpu_set_t affinity; CPU_ZERO (&affinity); @@ -289806,13 +289782,34 @@ void Thread::setCurrentThreadAffinityMask (const uint32 affinityMask) sched_setaffinity (getpid(), sizeof (cpu_set_t), &affinity); sched_yield(); -#else + #else /* affinities aren't supported because either the appropriate header files weren't found, or the SUPPORT_AFFINITIES macro was turned off */ jassertfalse; (void) affinityMask; -#endif + #endif +} + +bool DynamicLibrary::open (const String& name) +{ + close(); + handle = dlopen (name.toUTF8(), RTLD_LOCAL | RTLD_NOW); + return handle != 0; +} + +void DynamicLibrary::close() +{ + if (handle != nullptr) + { + dlclose (handle); + handle = nullptr; + } +} + +void* DynamicLibrary::getFunction (const String& functionName) noexcept +{ + return handle != nullptr ? dlsym (handle, functionName.toUTF8()) : nullptr; } /*** End of inlined file: juce_posix_SharedCode.h ***/ diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 50a7a737c8..8c0bd759bb 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -73,7 +73,7 @@ namespace JuceDummyNamespace {} */ #define JUCE_MAJOR_VERSION 1 #define JUCE_MINOR_VERSION 54 -#define JUCE_BUILDNUMBER 7 +#define JUCE_BUILDNUMBER 8 /** Current Juce version number. @@ -22203,7 +22203,7 @@ public: bool open (const String& name); /** Releases the currently-open DLL, or has no effect if none was open. */ - void close() noexcept; + void close(); /** Tries to find a named function in the currently-open DLL, and returns a pointer to it. If no library is open, or if the function isn't found, this will return a null pointer. @@ -56753,6 +56753,9 @@ public: /** Turns the drop-shadow on and off. */ void setDropShadowEnabled (bool useShadow); + /** True if drop-shadowing is enabled. */ + bool isDropShadowEnabled() const noexcept { return useDropShadow; } + /** Sets whether an OS-native title bar will be used, or a Juce one. @see isUsingNativeTitleBar diff --git a/src/core/juce_StandardHeader.h b/src/core/juce_StandardHeader.h index 2537ee4af5..b7440774c8 100644 --- a/src/core/juce_StandardHeader.h +++ b/src/core/juce_StandardHeader.h @@ -33,7 +33,7 @@ */ #define JUCE_MAJOR_VERSION 1 #define JUCE_MINOR_VERSION 54 -#define JUCE_BUILDNUMBER 7 +#define JUCE_BUILDNUMBER 8 /** Current Juce version number. diff --git a/src/gui/components/windows/juce_ResizableWindow.cpp b/src/gui/components/windows/juce_ResizableWindow.cpp index 4335fef10f..0e20b946bb 100644 --- a/src/gui/components/windows/juce_ResizableWindow.cpp +++ b/src/gui/components/windows/juce_ResizableWindow.cpp @@ -106,6 +106,7 @@ int ResizableWindow::getDesktopWindowStyleFlags() const void ResizableWindow::addToDesktop() { Component::addToDesktop (ResizableWindow::getDesktopWindowStyleFlags()); + setDropShadowEnabled (isDropShadowEnabled()); // force an update to clear away any fake shadows if necessary. } //============================================================================== diff --git a/src/gui/components/windows/juce_TopLevelWindow.h b/src/gui/components/windows/juce_TopLevelWindow.h index 978e257abb..85fc1e77c4 100644 --- a/src/gui/components/windows/juce_TopLevelWindow.h +++ b/src/gui/components/windows/juce_TopLevelWindow.h @@ -97,6 +97,9 @@ public: /** Turns the drop-shadow on and off. */ void setDropShadowEnabled (bool useShadow); + /** True if drop-shadowing is enabled. */ + bool isDropShadowEnabled() const noexcept { return useDropShadow; } + /** Sets whether an OS-native title bar will be used, or a Juce one. @see isUsingNativeTitleBar diff --git a/src/native/common/juce_posix_SharedCode.h b/src/native/common/juce_posix_SharedCode.h index 3dfcc52f03..91e18ecd3f 100644 --- a/src/native/common/juce_posix_SharedCode.h +++ b/src/native/common/juce_posix_SharedCode.h @@ -868,12 +868,12 @@ void Thread::yield() versions, and a lot of distros seem to ship with obsolete versions) */ #if defined (CPU_ISSET) && ! defined (SUPPORT_AFFINITIES) - #define SUPPORT_AFFINITIES 1 + #define SUPPORT_AFFINITIES 1 #endif void Thread::setCurrentThreadAffinityMask (const uint32 affinityMask) { -#if SUPPORT_AFFINITIES + #if SUPPORT_AFFINITIES cpu_set_t affinity; CPU_ZERO (&affinity); @@ -891,11 +891,33 @@ void Thread::setCurrentThreadAffinityMask (const uint32 affinityMask) sched_setaffinity (getpid(), sizeof (cpu_set_t), &affinity); sched_yield(); -#else + #else /* affinities aren't supported because either the appropriate header files weren't found, or the SUPPORT_AFFINITIES macro was turned off */ jassertfalse; (void) affinityMask; -#endif + #endif +} + +//============================================================================== +bool DynamicLibrary::open (const String& name) +{ + close(); + handle = dlopen (name.toUTF8(), RTLD_LOCAL | RTLD_NOW); + return handle != 0; +} + +void DynamicLibrary::close() +{ + if (handle != nullptr) + { + dlclose (handle); + handle = nullptr; + } +} + +void* DynamicLibrary::getFunction (const String& functionName) noexcept +{ + return handle != nullptr ? dlsym (handle, functionName.toUTF8()) : nullptr; } diff --git a/src/native/linux/juce_linux_Threads.cpp b/src/native/linux/juce_linux_Threads.cpp index d7b1dc9cd7..202de742eb 100644 --- a/src/native/linux/juce_linux_Threads.cpp +++ b/src/native/linux/juce_linux_Threads.cpp @@ -111,22 +111,4 @@ void Process::lowerPrivilege() } } -bool DynamicLibrary::open (const String& name) -{ - close(); - handle = dlopen (name.toUTF8(), RTLD_LOCAL | RTLD_NOW); - return handle != 0; -} - -void DynamicLibrary::close() noexcept -{ - if (handle != nullptr) - dlclose (handle); -} - -void* DynamicLibrary::getFunction (const String& functionName) noexcept -{ - return handle != nullptr ? dlsym (handle, functionName.toUTF8()) : nullptr; -} - #endif diff --git a/src/native/mac/juce_mac_Threads.mm b/src/native/mac/juce_mac_Threads.mm index c477741b6d..5c27c266c5 100644 --- a/src/native/mac/juce_mac_Threads.mm +++ b/src/native/mac/juce_mac_Threads.mm @@ -63,23 +63,4 @@ void Process::setPriority (ProcessPriority) // xxx } -bool DynamicLibrary::open (const String& name) -{ - close(); - handle = dlopen (name.toUTF8(), RTLD_LOCAL | RTLD_NOW); - return handle != 0; -} - -void DynamicLibrary::close() noexcept -{ - if (handle != nullptr) - dlclose (handle); -} - -void* DynamicLibrary::getFunction (const String& functionName) noexcept -{ - return handle != nullptr ? dlsym (handle, functionName.toUTF8()) : nullptr; -} - - #endif diff --git a/src/native/windows/juce_win32_ComSmartPtr.h b/src/native/windows/juce_win32_ComSmartPtr.h new file mode 100644 index 0000000000..e60578618c --- /dev/null +++ b/src/native/windows/juce_win32_ComSmartPtr.h @@ -0,0 +1,125 @@ +/* + ============================================================================== + + This file is part of the JUCE library - "Jules' Utility Class Extensions" + Copyright 2004-11 by Raw Material Software Ltd. + + ------------------------------------------------------------------------------ + + JUCE can be redistributed and/or modified under the terms of the GNU General + Public License (Version 2), as published by the Free Software Foundation. + A copy of the license is included in the JUCE distribution, or can be found + online at www.gnu.org/licenses. + + JUCE 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. + + ------------------------------------------------------------------------------ + + To release a closed-source product which uses JUCE, commercial licenses are + available: visit www.rawmaterialsoftware.com/juce for more information. + + ============================================================================== +*/ + +#ifndef __JUCE_WIN32_COMSMARTPTR_JUCEHEADER__ +#define __JUCE_WIN32_COMSMARTPTR_JUCEHEADER__ + + +//============================================================================== +/** A simple COM smart pointer. +*/ +template +class ComSmartPtr +{ +public: + ComSmartPtr() throw() : p (0) {} + ComSmartPtr (ComClass* const p_) : p (p_) { if (p_ != 0) p_->AddRef(); } + ComSmartPtr (const ComSmartPtr& p_) : p (p_.p) { if (p != 0) p->AddRef(); } + ~ComSmartPtr() { release(); } + + operator ComClass*() const throw() { return p; } + ComClass& operator*() const throw() { return *p; } + ComClass* operator->() const throw() { return p; } + + ComSmartPtr& operator= (ComClass* const newP) + { + if (newP != 0) newP->AddRef(); + release(); + p = newP; + return *this; + } + + ComSmartPtr& operator= (const ComSmartPtr& newP) { return operator= (newP.p); } + + // Releases and nullifies this pointer and returns its address + ComClass** resetAndGetPointerAddress() + { + release(); + p = 0; + return &p; + } + + HRESULT CoCreateInstance (REFCLSID classUUID, DWORD dwClsContext = CLSCTX_INPROC_SERVER) + { + #ifndef __MINGW32__ + return ::CoCreateInstance (classUUID, 0, dwClsContext, __uuidof (ComClass), (void**) resetAndGetPointerAddress()); + #else + return E_NOTIMPL; + #endif + } + + template + HRESULT QueryInterface (REFCLSID classUUID, ComSmartPtr& destObject) const + { + if (p == 0) + return E_POINTER; + + return p->QueryInterface (classUUID, (void**) destObject.resetAndGetPointerAddress()); + } + + template + HRESULT QueryInterface (ComSmartPtr& destObject) const + { + return this->QueryInterface (__uuidof (OtherComClass), destObject); + } + +private: + ComClass* p; + + void release() { if (p != 0) p->Release(); } + + ComClass** operator&() throw(); // private to avoid it being used accidentally +}; + +//============================================================================== +/** Handy base class for writing COM objects, providing ref-counting and a basic QueryInterface method. +*/ +template +class ComBaseClassHelper : public ComClass +{ +public: + ComBaseClassHelper() : refCount (1) {} + virtual ~ComBaseClassHelper() {} + + HRESULT __stdcall QueryInterface (REFIID refId, void** result) + { + #ifndef __MINGW32__ + if (refId == __uuidof (ComClass)) { AddRef(); *result = dynamic_cast (this); return S_OK; } + #endif + + if (refId == IID_IUnknown) { AddRef(); *result = dynamic_cast (this); return S_OK; } + + *result = 0; + return E_NOINTERFACE; + } + + ULONG __stdcall AddRef() { return ++refCount; } + ULONG __stdcall Release() { const int r = --refCount; if (r == 0) delete this; return r; } + +protected: + int refCount; +}; + +#endif // __JUCE_WIN32_COMSMARTPTR_JUCEHEADER__ diff --git a/src/native/windows/juce_win32_DynamicLibraryLoader.h b/src/native/windows/juce_win32_DynamicLibraryLoader.h deleted file mode 100644 index e3ef1a7eea..0000000000 --- a/src/native/windows/juce_win32_DynamicLibraryLoader.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - ============================================================================== - - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. - - ------------------------------------------------------------------------------ - - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. - - JUCE 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. - - ------------------------------------------------------------------------------ - - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. - - ============================================================================== -*/ - -#ifndef __JUCE_WIN32_DYNAMICLIBRARYLOADER_JUCEHEADER__ -#define __JUCE_WIN32_DYNAMICLIBRARYLOADER_JUCEHEADER__ - -#ifndef DOXYGEN - -//============================================================================== -// use with DynamicLibraryLoader to simplify importing functions -// -// functionName: function to import -// localFunctionName: name you want to use to actually call it (must be different) -// returnType: the return type -// object: the DynamicLibraryLoader to use -// params: list of params (bracketed) -// -#define DynamicLibraryImport(functionName, localFunctionName, returnType, object, params) \ - typedef returnType (WINAPI *type##localFunctionName) params; \ - type##localFunctionName localFunctionName \ - = (type##localFunctionName)object.findProcAddress (#functionName); - - -//============================================================================== -// loads and unloads a DLL automatically -class JUCE_API DynamicLibraryLoader -{ -public: - DynamicLibraryLoader (const String& name = String::empty) - : libHandle (0) - { - load (name); - } - - ~DynamicLibraryLoader() - { - load (String::empty); - } - - bool load (const String& name) - { - FreeLibrary ((HMODULE) libHandle); - libHandle = name.isNotEmpty() ? LoadLibrary (name.toWideCharPointer()) : 0; - return libHandle != 0; - } - - void* findProcAddress (const String& functionName) - { - return (void*) GetProcAddress ((HMODULE) libHandle, functionName.toUTF8()); // (void* cast is required for mingw) - } - -private: - void* libHandle; -}; - - -#endif -#endif // __JUCE_WIN32_DYNAMICLIBRARYLOADER_JUCEHEADER__ diff --git a/src/native/windows/juce_win32_Misc.cpp b/src/native/windows/juce_win32_Misc.cpp index b9524a2ade..2911ec2c57 100644 --- a/src/native/windows/juce_win32_Misc.cpp +++ b/src/native/windows/juce_win32_Misc.cpp @@ -28,60 +28,6 @@ #if JUCE_INCLUDED_FILE -//============================================================================== -void SystemClipboard::copyTextToClipboard (const String& text) -{ - if (OpenClipboard (0) != 0) - { - if (EmptyClipboard() != 0) - { - const int bytesNeeded = CharPointer_UTF16::getBytesRequiredFor (text.getCharPointer()) + 4; - - if (bytesNeeded > 0) - { - HGLOBAL bufH = GlobalAlloc (GMEM_MOVEABLE | GMEM_DDESHARE | GMEM_ZEROINIT, bytesNeeded + sizeof (WCHAR)); - - if (bufH != 0) - { - WCHAR* const data = static_cast (GlobalLock (bufH)); - text.copyToUTF16 (data, bytesNeeded); - GlobalUnlock (bufH); - - SetClipboardData (CF_UNICODETEXT, bufH); - } - } - } - - CloseClipboard(); - } -} - -String SystemClipboard::getTextFromClipboard() -{ - String result; - - if (OpenClipboard (0) != 0) - { - HANDLE bufH = GetClipboardData (CF_UNICODETEXT); - - if (bufH != 0) - { - const WCHAR* const data = (const WCHAR*) GlobalLock (bufH); - - if (data != nullptr) - { - result = String (data, (int) (GlobalSize (bufH) / sizeof (WCHAR))); - - GlobalUnlock (bufH); - } - } - - CloseClipboard(); - } - - return result; -} - //============================================================================== bool juce_IsRunningInWine() { diff --git a/src/native/windows/juce_win32_NativeCode.cpp b/src/native/windows/juce_win32_NativeCode.cpp index c5671be179..7463e06890 100644 --- a/src/native/windows/juce_win32_NativeCode.cpp +++ b/src/native/windows/juce_win32_NativeCode.cpp @@ -100,7 +100,6 @@ BEGIN_JUCE_NAMESPACE #define JUCE_INCLUDED_FILE 1 // Now include the actual code files.. -#include "juce_win32_DynamicLibraryLoader.h" #include "juce_win32_SystemStats.cpp" #include "juce_win32_Threads.cpp" #include "juce_win32_Files.cpp" diff --git a/src/native/windows/juce_win32_NativeIncludes.h b/src/native/windows/juce_win32_NativeIncludes.h index 0493f04c31..0a9cec6797 100644 --- a/src/native/windows/juce_win32_NativeIncludes.h +++ b/src/native/windows/juce_win32_NativeIncludes.h @@ -23,7 +23,6 @@ ============================================================================== */ -//============================================================================== #ifndef __JUCE_WIN32_NATIVEINCLUDES_JUCEHEADER__ #define __JUCE_WIN32_NATIVEINCLUDES_JUCEHEADER__ @@ -201,100 +200,20 @@ #define WM_APPCOMMAND 0x0319 #endif -//============================================================================== -/** A simple COM smart pointer. - Avoids having to include ATL just to get one of these. -*/ -template -class ComSmartPtr -{ -public: - ComSmartPtr() throw() : p (0) {} - ComSmartPtr (ComClass* const p_) : p (p_) { if (p_ != 0) p_->AddRef(); } - ComSmartPtr (const ComSmartPtr& p_) : p (p_.p) { if (p != 0) p->AddRef(); } - ~ComSmartPtr() { release(); } - - operator ComClass*() const throw() { return p; } - ComClass& operator*() const throw() { return *p; } - ComClass* operator->() const throw() { return p; } - - ComSmartPtr& operator= (ComClass* const newP) - { - if (newP != 0) newP->AddRef(); - release(); - p = newP; - return *this; - } - - ComSmartPtr& operator= (const ComSmartPtr& newP) { return operator= (newP.p); } - - // Releases and nullifies this pointer and returns its address - ComClass** resetAndGetPointerAddress() - { - release(); - p = 0; - return &p; - } - - HRESULT CoCreateInstance (REFCLSID classUUID, DWORD dwClsContext = CLSCTX_INPROC_SERVER) - { - #ifndef __MINGW32__ - return ::CoCreateInstance (classUUID, 0, dwClsContext, __uuidof (ComClass), (void**) resetAndGetPointerAddress()); - #else - return E_NOTIMPL; - #endif - } - - template - HRESULT QueryInterface (REFCLSID classUUID, ComSmartPtr& destObject) const - { - if (p == 0) - return E_POINTER; - - return p->QueryInterface (classUUID, (void**) destObject.resetAndGetPointerAddress()); - } - - template - HRESULT QueryInterface (ComSmartPtr& destObject) const - { - return this->QueryInterface (__uuidof (OtherComClass), destObject); - } - -private: - ComClass* p; - - void release() { if (p != 0) p->Release(); } - - ComClass** operator&() throw(); // private to avoid it being used accidentally -}; +#include "juce_win32_ComSmartPtr.h" -//============================================================================== -/** Handy base class for writing COM objects, providing ref-counting and a basic QueryInterface method. +/* Used with DynamicLibrary to simplify importing functions + + functionName: function to import + localFunctionName: name you want to use to actually call it (must be different) + returnType: the return type + object: the DynamicLibrary to use + params: list of params (bracketed) */ -template -class ComBaseClassHelper : public ComClass -{ -public: - ComBaseClassHelper() : refCount (1) {} - virtual ~ComBaseClassHelper() {} - - HRESULT __stdcall QueryInterface (REFIID refId, void** result) - { - #ifndef __MINGW32__ - if (refId == __uuidof (ComClass)) { AddRef(); *result = dynamic_cast (this); return S_OK; } - #endif - - if (refId == IID_IUnknown) { AddRef(); *result = dynamic_cast (this); return S_OK; } - - *result = 0; - return E_NOINTERFACE; - } - - ULONG __stdcall AddRef() { return ++refCount; } - ULONG __stdcall Release() { const int r = --refCount; if (r == 0) delete this; return r; } - -protected: - int refCount; -}; +#define JUCE_DLL_FUNCTION(functionName, localFunctionName, returnType, object, params) \ + typedef returnType (WINAPI *type##localFunctionName) params; \ + type##localFunctionName localFunctionName \ + = (type##localFunctionName)object.getFunction (#functionName); + #endif // __JUCE_WIN32_NATIVEINCLUDES_JUCEHEADER__ diff --git a/src/native/windows/juce_win32_Network.cpp b/src/native/windows/juce_win32_Network.cpp index aad304291f..dc48cb0523 100644 --- a/src/native/windows/juce_win32_Network.cpp +++ b/src/native/windows/juce_win32_Network.cpp @@ -361,8 +361,8 @@ namespace MACAddressHelpers { void getViaGetAdaptersInfo (Array& result) { - DynamicLibraryLoader dll ("iphlpapi.dll"); - DynamicLibraryImport (GetAdaptersInfo, getAdaptersInfo, DWORD, dll, (PIP_ADAPTER_INFO, PULONG)) + DynamicLibrary dll ("iphlpapi.dll"); + JUCE_DLL_FUNCTION (GetAdaptersInfo, getAdaptersInfo, DWORD, dll, (PIP_ADAPTER_INFO, PULONG)) if (getAdaptersInfo != 0) { @@ -389,8 +389,8 @@ namespace MACAddressHelpers void getViaNetBios (Array& result) { - DynamicLibraryLoader dll ("netapi32.dll"); - DynamicLibraryImport (Netbios, NetbiosCall, UCHAR, dll, (PNCB)) + DynamicLibrary dll ("netapi32.dll"); + JUCE_DLL_FUNCTION (Netbios, NetbiosCall, UCHAR, dll, (PNCB)) if (NetbiosCall != 0) { @@ -447,45 +447,40 @@ bool Process::openEmailWithAttachments (const String& targetEmailAddress, const String& bodyText, const StringArray& filesToAttach) { - HMODULE h = LoadLibraryA ("MAPI32.dll"); - typedef ULONG (WINAPI *MAPISendMailType) (LHANDLE, ULONG, lpMapiMessage, ::FLAGS, ULONG); - MAPISendMailType mapiSendMail = (MAPISendMailType) GetProcAddress (h, "MAPISendMail"); - bool ok = false; + DynamicLibrary mapiLib ("MAPI32.dll"); + MAPISendMailType mapiSendMail = (MAPISendMailType) mapiLib.getFunction ("MAPISendMail"); - if (mapiSendMail != 0) - { - MapiMessage message = { 0 }; - message.lpszSubject = (LPSTR) emailSubject.toUTF8().getAddress(); - message.lpszNoteText = (LPSTR) bodyText.toUTF8().getAddress(); - - MapiRecipDesc recip = { 0 }; - recip.ulRecipClass = MAPI_TO; - String targetEmailAddress_ (targetEmailAddress); - if (targetEmailAddress_.isEmpty()) - targetEmailAddress_ = " "; // (Windows Mail can't deal with a blank address) - recip.lpszName = (LPSTR) targetEmailAddress_.toUTF8().getAddress(); - message.nRecipCount = 1; - message.lpRecips = &recip; - - HeapBlock files; - files.calloc (filesToAttach.size()); - - message.nFileCount = filesToAttach.size(); - message.lpFiles = files; - - for (int i = 0; i < filesToAttach.size(); ++i) - { - files[i].nPosition = (ULONG) -1; - files[i].lpszPathName = (LPSTR) filesToAttach[i].toUTF8().getAddress(); - } + if (mapiSendMail == nullptr) + return false; + + MapiMessage message = { 0 }; + message.lpszSubject = (LPSTR) emailSubject.toUTF8().getAddress(); + message.lpszNoteText = (LPSTR) bodyText.toUTF8().getAddress(); - ok = (mapiSendMail (0, 0, &message, MAPI_DIALOG | MAPI_LOGON_UI, 0) == SUCCESS_SUCCESS); + MapiRecipDesc recip = { 0 }; + recip.ulRecipClass = MAPI_TO; + String targetEmailAddress_ (targetEmailAddress); + if (targetEmailAddress_.isEmpty()) + targetEmailAddress_ = " "; // (Windows Mail can't deal with a blank address) + recip.lpszName = (LPSTR) targetEmailAddress_.toUTF8().getAddress(); + message.nRecipCount = 1; + message.lpRecips = &recip; + + HeapBlock files; + files.calloc (filesToAttach.size()); + + message.nFileCount = filesToAttach.size(); + message.lpFiles = files; + + for (int i = 0; i < filesToAttach.size(); ++i) + { + files[i].nPosition = (ULONG) -1; + files[i].lpszPathName = (LPSTR) filesToAttach[i].toUTF8().getAddress(); } - FreeLibrary (h); - return ok; + return mapiSendMail (0, 0, &message, MAPI_DIALOG | MAPI_LOGON_UI, 0) == SUCCESS_SUCCESS; } diff --git a/src/native/windows/juce_win32_Threads.cpp b/src/native/windows/juce_win32_Threads.cpp index 5af9e69f5e..89cd60214c 100644 --- a/src/native/windows/juce_win32_Threads.cpp +++ b/src/native/windows/juce_win32_Threads.cpp @@ -314,6 +314,8 @@ void Process::terminate() //============================================================================== bool DynamicLibrary::open (const String& name) { + close(); + JUCE_TRY { handle = LoadLibrary (name.toWideCharPointer()); @@ -323,12 +325,15 @@ bool DynamicLibrary::open (const String& name) return handle != nullptr; } -void DynamicLibrary::close() noexcept +void DynamicLibrary::close() { JUCE_TRY { if (handle != nullptr) + { FreeLibrary ((HMODULE) handle); + handle = nullptr; + } } JUCE_CATCH_ALL } diff --git a/src/native/windows/juce_win32_WASAPI.cpp b/src/native/windows/juce_win32_WASAPI.cpp index 68c65d164f..e68ae6ee2f 100644 --- a/src/native/windows/juce_win32_WASAPI.cpp +++ b/src/native/windows/juce_win32_WASAPI.cpp @@ -822,9 +822,9 @@ public: void setMMThreadPriority() { - DynamicLibraryLoader dll ("avrt.dll"); - DynamicLibraryImport (AvSetMmThreadCharacteristicsW, avSetMmThreadCharacteristics, HANDLE, dll, (LPCWSTR, LPDWORD)) - DynamicLibraryImport (AvSetMmThreadPriority, avSetMmThreadPriority, HANDLE, dll, (HANDLE, AVRT_PRIORITY)) + DynamicLibrary dll ("avrt.dll"); + JUCE_DLL_FUNCTION (AvSetMmThreadCharacteristicsW, avSetMmThreadCharacteristics, HANDLE, dll, (LPCWSTR, LPDWORD)) + JUCE_DLL_FUNCTION (AvSetMmThreadPriority, avSetMmThreadPriority, HANDLE, dll, (HANDLE, AVRT_PRIORITY)) if (avSetMmThreadCharacteristics != 0 && avSetMmThreadPriority != 0) { diff --git a/src/native/windows/juce_win32_Windowing.cpp b/src/native/windows/juce_win32_Windowing.cpp index b65224cb14..3af31912f3 100644 --- a/src/native/windows/juce_win32_Windowing.cpp +++ b/src/native/windows/juce_win32_Windowing.cpp @@ -2889,6 +2889,64 @@ void LookAndFeel::playAlertSound() MessageBeep (MB_OK); } +//============================================================================== +void SystemClipboard::copyTextToClipboard (const String& text) +{ + if (OpenClipboard (0) != 0) + { + if (EmptyClipboard() != 0) + { + const int bytesNeeded = CharPointer_UTF16::getBytesRequiredFor (text.getCharPointer()) + 4; + + if (bytesNeeded > 0) + { + HGLOBAL bufH = GlobalAlloc (GMEM_MOVEABLE | GMEM_DDESHARE | GMEM_ZEROINIT, bytesNeeded + sizeof (WCHAR)); + + if (bufH != 0) + { + WCHAR* const data = static_cast (GlobalLock (bufH)); + + if (data != nullptr) + { + text.copyToUTF16 (data, bytesNeeded); + GlobalUnlock (bufH); + + SetClipboardData (CF_UNICODETEXT, bufH); + } + } + } + } + + CloseClipboard(); + } +} + +String SystemClipboard::getTextFromClipboard() +{ + String result; + + if (OpenClipboard (0) != 0) + { + HANDLE bufH = GetClipboardData (CF_UNICODETEXT); + + if (bufH != 0) + { + const WCHAR* const data = (const WCHAR*) GlobalLock (bufH); + + if (data != nullptr) + { + result = String (data, (int) (GlobalSize (bufH) / sizeof (WCHAR))); + + GlobalUnlock (bufH); + } + } + + CloseClipboard(); + } + + return result; +} + //============================================================================== void Desktop::setKioskComponent (Component* kioskModeComponent, bool enableOrDisable, bool /*allowMenusAndBars*/) { diff --git a/src/threads/juce_DynamicLibrary.h b/src/threads/juce_DynamicLibrary.h index 8f5eb99864..3c4627284c 100644 --- a/src/threads/juce_DynamicLibrary.h +++ b/src/threads/juce_DynamicLibrary.h @@ -60,7 +60,7 @@ public: bool open (const String& name); /** Releases the currently-open DLL, or has no effect if none was open. */ - void close() noexcept; + void close(); /** Tries to find a named function in the currently-open DLL, and returns a pointer to it. If no library is open, or if the function isn't found, this will return a null pointer.