diff --git a/Builds/Linux/Makefile b/Builds/Linux/Makefile index 3ccc60f94c..22d50d2396 100644 --- a/Builds/Linux/Makefile +++ b/Builds/Linux/Makefile @@ -329,7 +329,7 @@ OBJECTS := \ $(OBJDIR)/juce_win32_NativeCode_c247c7f6.o \ $(OBJDIR)/juce_win32_Network_6c84a66.o \ $(OBJDIR)/juce_win32_OpenGLComponent_d0d99a46.o \ - $(OBJDIR)/juce_win32_PlatformUtils_73e7e1f6.o \ + $(OBJDIR)/juce_win32_Registry_86da784f.o \ $(OBJDIR)/juce_win32_QuickTimeMovieComponent_be08e5f.o \ $(OBJDIR)/juce_win32_SystemStats_6446cd68.o \ $(OBJDIR)/juce_win32_Threads_ee986e61.o \ @@ -1838,9 +1838,9 @@ $(OBJDIR)/juce_win32_OpenGLComponent_d0d99a46.o: ../../src/native/windows/juce_w @echo "Compiling juce_win32_OpenGLComponent.cpp" @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" -$(OBJDIR)/juce_win32_PlatformUtils_73e7e1f6.o: ../../src/native/windows/juce_win32_PlatformUtils.cpp +$(OBJDIR)/juce_win32_Registry_86da784f.o: ../../src/native/windows/juce_win32_Registry.cpp -@mkdir -p $(OBJDIR) - @echo "Compiling juce_win32_PlatformUtils.cpp" + @echo "Compiling juce_win32_Registry.cpp" @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" $(OBJDIR)/juce_win32_QuickTimeMovieComponent_be08e5f.o: ../../src/native/windows/juce_win32_QuickTimeMovieComponent.cpp diff --git a/Builds/MacOSX/Juce.xcodeproj/project.pbxproj b/Builds/MacOSX/Juce.xcodeproj/project.pbxproj index cb0a0a8489..6dfb84ea51 100644 --- a/Builds/MacOSX/Juce.xcodeproj/project.pbxproj +++ b/Builds/MacOSX/Juce.xcodeproj/project.pbxproj @@ -324,7 +324,7 @@ A46B0025A68136ED993E0D85 = { isa = PBXBuildFile; fileRef = 50159A5B7A552A6C1EB557F3; }; B99678E919BF547A3A3F5D6E = { isa = PBXBuildFile; fileRef = CDA5FCC51F6C1E84D7DC3274; }; 5B714CDD0082419BFED7D2D4 = { isa = PBXBuildFile; fileRef = B14735381ADB00741166E330; }; - FB5D5D89E17FF079170E3867 = { isa = PBXBuildFile; fileRef = 83F4C7477C76503C8D028288; }; + 5B33FFE120A47EF42CBC05E4 = { isa = PBXBuildFile; fileRef = 0EB41C0AB478EE02D8C851F9; }; 2DD498313DA488A5063C4C1B = { isa = PBXBuildFile; fileRef = 09AE0882D58BE1715219556A; }; 552D45FB250C62F86CD02A57 = { isa = PBXBuildFile; fileRef = FBE07C5CC622A5D36BDAB9E1; }; 0E8E9829E95E32163F45482D = { isa = PBXBuildFile; fileRef = B07C853EB60D8D8691BC1B4B; }; @@ -543,7 +543,6 @@ DF6CAC67C0F2D379BDA03062 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_PerformanceCounter.cpp"; path = "../../src/core/juce_PerformanceCounter.cpp"; sourceTree = "SOURCE_ROOT"; }; 1159C6BB0D33EE8E1A96B083 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_PerformanceCounter.h"; path = "../../src/core/juce_PerformanceCounter.h"; sourceTree = "SOURCE_ROOT"; }; 8292AE37F99FCC1E5BF63A28 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_PlatformDefs.h"; path = "../../src/core/juce_PlatformDefs.h"; sourceTree = "SOURCE_ROOT"; }; - 8D499CED6DCF525ACD6E39B2 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_PlatformUtilities.h"; path = "../../src/core/juce_PlatformUtilities.h"; sourceTree = "SOURCE_ROOT"; }; CFAECB6551F48A1695DEC243 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_RelativeTime.cpp"; path = "../../src/core/juce_RelativeTime.cpp"; sourceTree = "SOURCE_ROOT"; }; B4137E4612C1D161894D0D27 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_RelativeTime.h"; path = "../../src/core/juce_RelativeTime.h"; sourceTree = "SOURCE_ROOT"; }; 0AD73B8EA0D60D9927B36624 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_Result.cpp"; path = "../../src/core/juce_Result.cpp"; sourceTree = "SOURCE_ROOT"; }; @@ -568,6 +567,7 @@ 31D985CB8646B78460E9D5A7 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_ActionBroadcaster.cpp"; path = "../../src/events/juce_ActionBroadcaster.cpp"; sourceTree = "SOURCE_ROOT"; }; 09F7685D1EFF472ECB1F5EF1 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_ActionBroadcaster.h"; path = "../../src/events/juce_ActionBroadcaster.h"; sourceTree = "SOURCE_ROOT"; }; 4EF8BD4BF46C4BCB39F96609 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_ActionListener.h"; path = "../../src/events/juce_ActionListener.h"; sourceTree = "SOURCE_ROOT"; }; + 5EB7BD94A754E88D076D777A = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_AppleRemote.h"; path = "../../src/events/juce_AppleRemote.h"; sourceTree = "SOURCE_ROOT"; }; 1617348BBF5D103619D76911 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_AsyncUpdater.cpp"; path = "../../src/events/juce_AsyncUpdater.cpp"; sourceTree = "SOURCE_ROOT"; }; 44DB44953945417F76199479 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_AsyncUpdater.h"; path = "../../src/events/juce_AsyncUpdater.h"; sourceTree = "SOURCE_ROOT"; }; D04B6E43A037F985434B2F5A = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_CallbackMessage.h"; path = "../../src/events/juce_CallbackMessage.h"; sourceTree = "SOURCE_ROOT"; }; @@ -797,6 +797,7 @@ A34C0E63D41CFF5E55FD1D9E = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_PreferencesPanel.cpp"; path = "../../src/gui/components/special/juce_PreferencesPanel.cpp"; sourceTree = "SOURCE_ROOT"; }; 6BE989C709D2D1D017548447 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_PreferencesPanel.h"; path = "../../src/gui/components/special/juce_PreferencesPanel.h"; sourceTree = "SOURCE_ROOT"; }; 529CB909220344AD55944372 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_QuickTimeMovieComponent.h"; path = "../../src/gui/components/special/juce_QuickTimeMovieComponent.h"; sourceTree = "SOURCE_ROOT"; }; + A9DB12F944D9DC336AD0A78B = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_ScopedXLock.h"; path = "../../src/gui/components/special/juce_ScopedXLock.h"; sourceTree = "SOURCE_ROOT"; }; CC04F253CB70B20B774801A9 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_SystemTrayIconComponent.cpp"; path = "../../src/gui/components/special/juce_SystemTrayIconComponent.cpp"; sourceTree = "SOURCE_ROOT"; }; D9847FECA6801E9A61007D50 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_SystemTrayIconComponent.h"; path = "../../src/gui/components/special/juce_SystemTrayIconComponent.h"; sourceTree = "SOURCE_ROOT"; }; 740D1808DB934123F05A1598 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_WebBrowserComponent.h"; path = "../../src/gui/components/special/juce_WebBrowserComponent.h"; sourceTree = "SOURCE_ROOT"; }; @@ -1011,6 +1012,8 @@ FE6E3F911679B0D7547577A3 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = "juce_mac_SystemStats.mm"; path = "../../src/native/mac/juce_mac_SystemStats.mm"; sourceTree = "SOURCE_ROOT"; }; 8BCE60CBC91DBAAB089958A1 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = "juce_mac_Threads.mm"; path = "../../src/native/mac/juce_mac_Threads.mm"; sourceTree = "SOURCE_ROOT"; }; 3F11593DC3A168A52FCC2DD9 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = "juce_mac_WebBrowserComponent.mm"; path = "../../src/native/mac/juce_mac_WebBrowserComponent.mm"; sourceTree = "SOURCE_ROOT"; }; + AB0F3F5A622CBB251F64945A = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_osx_MessageQueue.h"; path = "../../src/native/mac/juce_osx_MessageQueue.h"; sourceTree = "SOURCE_ROOT"; }; + AD495FA1991295C722B46843 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_osx_ObjCHelpers.h"; path = "../../src/native/mac/juce_osx_ObjCHelpers.h"; sourceTree = "SOURCE_ROOT"; }; 42059626955C547DA6AD3196 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_win32_ActiveXComponent.cpp"; path = "../../src/native/windows/juce_win32_ActiveXComponent.cpp"; sourceTree = "SOURCE_ROOT"; }; 8F383A785B4876198C5B0194 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_win32_ASIO.cpp"; path = "../../src/native/windows/juce_win32_ASIO.cpp"; sourceTree = "SOURCE_ROOT"; }; F3B50EE3939E9F16D13C3C7C = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_win32_AudioCDReader.cpp"; path = "../../src/native/windows/juce_win32_AudioCDReader.cpp"; sourceTree = "SOURCE_ROOT"; }; @@ -1030,7 +1033,7 @@ 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"; }; - 83F4C7477C76503C8D028288 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_win32_PlatformUtils.cpp"; path = "../../src/native/windows/juce_win32_PlatformUtils.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"; }; 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"; }; @@ -1080,6 +1083,7 @@ 95F21C2733BD5932372E4157 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_XmlElement.cpp"; path = "../../src/text/juce_XmlElement.cpp"; sourceTree = "SOURCE_ROOT"; }; 4EF8C44FF03700F6140950F3 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_XmlElement.h"; path = "../../src/text/juce_XmlElement.h"; sourceTree = "SOURCE_ROOT"; }; 40282E23D43D86D122CA5C54 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_CriticalSection.h"; path = "../../src/threads/juce_CriticalSection.h"; sourceTree = "SOURCE_ROOT"; }; + EC240B4379FB70C8A8AC2855 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_DynamicLibrary.h"; path = "../../src/threads/juce_DynamicLibrary.h"; sourceTree = "SOURCE_ROOT"; }; 5508D42FCF7A1C8A8CD78BF0 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_InterProcessLock.h"; path = "../../src/threads/juce_InterProcessLock.h"; sourceTree = "SOURCE_ROOT"; }; 90E4999A78655A238AF42BC0 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_Process.h"; path = "../../src/threads/juce_Process.h"; sourceTree = "SOURCE_ROOT"; }; 8E78623B2D21CFE68DEC0483 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_ReadWriteLock.cpp"; path = "../../src/threads/juce_ReadWriteLock.cpp"; sourceTree = "SOURCE_ROOT"; }; @@ -1110,6 +1114,7 @@ 3C9E6597968358B57374502C = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_UndoManager.h"; path = "../../src/utilities/juce_UndoManager.h"; sourceTree = "SOURCE_ROOT"; }; ADE5F12AA5AD969E2C7002B3 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_UnitTest.cpp"; path = "../../src/utilities/juce_UnitTest.cpp"; sourceTree = "SOURCE_ROOT"; }; 75700D13513346310CEAC30D = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_UnitTest.h"; path = "../../src/utilities/juce_UnitTest.h"; sourceTree = "SOURCE_ROOT"; }; + AAC585C4648559DD713F28FE = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_WindowsRegistry.h"; path = "../../src/utilities/juce_WindowsRegistry.h"; sourceTree = "SOURCE_ROOT"; }; 2FD5C998952BE08F8ED3F262 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce.h; path = ../../juce.h; sourceTree = "SOURCE_ROOT"; }; 01778F26212AECCBF2452804 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_Config.h"; path = "../../juce_Config.h"; sourceTree = "SOURCE_ROOT"; }; D443FD24B52106986FC8A531 = { isa = PBXGroup; children = ( @@ -1319,7 +1324,6 @@ DF6CAC67C0F2D379BDA03062, 1159C6BB0D33EE8E1A96B083, 8292AE37F99FCC1E5BF63A28, - 8D499CED6DCF525ACD6E39B2, CFAECB6551F48A1695DEC243, B4137E4612C1D161894D0D27, 0AD73B8EA0D60D9927B36624, @@ -1346,6 +1350,7 @@ 31D985CB8646B78460E9D5A7, 09F7685D1EFF472ECB1F5EF1, 4EF8BD4BF46C4BCB39F96609, + 5EB7BD94A754E88D076D777A, 1617348BBF5D103619D76911, 44DB44953945417F76199479, D04B6E43A037F985434B2F5A, @@ -1579,6 +1584,7 @@ A34C0E63D41CFF5E55FD1D9E, 6BE989C709D2D1D017548447, 529CB909220344AD55944372, + A9DB12F944D9DC336AD0A78B, CC04F253CB70B20B774801A9, D9847FECA6801E9A61007D50, 740D1808DB934123F05A1598 ); name = special; sourceTree = ""; }; @@ -1847,7 +1853,9 @@ E6A7BFB0FCD17A9B133CDFA4, FE6E3F911679B0D7547577A3, 8BCE60CBC91DBAAB089958A1, - 3F11593DC3A168A52FCC2DD9 ); name = mac; sourceTree = ""; }; + 3F11593DC3A168A52FCC2DD9, + AB0F3F5A622CBB251F64945A, + AD495FA1991295C722B46843 ); name = mac; sourceTree = ""; }; 64DE2D4534D79E74C40A0DEE = { isa = PBXGroup; children = ( 42059626955C547DA6AD3196, 8F383A785B4876198C5B0194, @@ -1868,7 +1876,7 @@ E7625D7A06CBC11F40A56A70, CDA5FCC51F6C1E84D7DC3274, B14735381ADB00741166E330, - 83F4C7477C76503C8D028288, + 0EB41C0AB478EE02D8C851F9, 09AE0882D58BE1715219556A, FBE07C5CC622A5D36BDAB9E1, B07C853EB60D8D8691BC1B4B, @@ -1927,6 +1935,7 @@ 4EF8C44FF03700F6140950F3 ); name = text; sourceTree = ""; }; 723AC5B999F1EC8F4A101AAF = { isa = PBXGroup; children = ( 40282E23D43D86D122CA5C54, + EC240B4379FB70C8A8AC2855, 5508D42FCF7A1C8A8CD78BF0, 90E4999A78655A238AF42BC0, 8E78623B2D21CFE68DEC0483, @@ -1957,7 +1966,8 @@ A59A5DCFCCAAEA79D03C2B27, 3C9E6597968358B57374502C, ADE5F12AA5AD969E2C7002B3, - 75700D13513346310CEAC30D ); name = utilities; sourceTree = ""; }; + 75700D13513346310CEAC30D, + AAC585C4648559DD713F28FE ); name = utilities; sourceTree = ""; }; 9AA3D660772E3D4C64EC7859 = { isa = PBXGroup; children = ( D443FD24B52106986FC8A531, F2B0E44A08E127FD31184241, @@ -2377,7 +2387,7 @@ A46B0025A68136ED993E0D85, B99678E919BF547A3A3F5D6E, 5B714CDD0082419BFED7D2D4, - FB5D5D89E17FF079170E3867, + 5B33FFE120A47EF42CBC05E4, 2DD498313DA488A5063C4C1B, 552D45FB250C62F86CD02A57, 0E8E9829E95E32163F45482D, diff --git a/Builds/VisualStudio2005/Juce.vcproj b/Builds/VisualStudio2005/Juce.vcproj index a37a9211f1..15f9de1fc6 100644 --- a/Builds/VisualStudio2005/Juce.vcproj +++ b/Builds/VisualStudio2005/Juce.vcproj @@ -373,7 +373,6 @@ - @@ -402,6 +401,7 @@ + @@ -657,6 +657,7 @@ + @@ -912,6 +913,8 @@ + + @@ -933,7 +936,7 @@ - + @@ -990,6 +993,7 @@ + @@ -1022,6 +1026,7 @@ + diff --git a/Builds/VisualStudio2008/Juce.vcproj b/Builds/VisualStudio2008/Juce.vcproj index f789ed2030..52520bea60 100644 --- a/Builds/VisualStudio2008/Juce.vcproj +++ b/Builds/VisualStudio2008/Juce.vcproj @@ -373,7 +373,6 @@ - @@ -402,6 +401,7 @@ + @@ -657,6 +657,7 @@ + @@ -912,6 +913,8 @@ + + @@ -933,7 +936,7 @@ - + @@ -990,6 +993,7 @@ + @@ -1022,6 +1026,7 @@ + diff --git a/Builds/VisualStudio2008_DLL/Juce.vcproj b/Builds/VisualStudio2008_DLL/Juce.vcproj index 071c104db2..e80c2c5ee1 100644 --- a/Builds/VisualStudio2008_DLL/Juce.vcproj +++ b/Builds/VisualStudio2008_DLL/Juce.vcproj @@ -375,7 +375,6 @@ - @@ -404,6 +403,7 @@ + @@ -659,6 +659,7 @@ + @@ -914,6 +915,8 @@ + + @@ -935,7 +938,7 @@ - + @@ -992,6 +995,7 @@ + @@ -1024,6 +1028,7 @@ + diff --git a/Builds/VisualStudio2010/Juce.vcxproj b/Builds/VisualStudio2010/Juce.vcxproj index 68d92ebf05..a721d61858 100644 --- a/Builds/VisualStudio2010/Juce.vcxproj +++ b/Builds/VisualStudio2010/Juce.vcxproj @@ -412,7 +412,7 @@ - + @@ -553,7 +553,6 @@ - @@ -568,6 +567,7 @@ + @@ -691,6 +691,7 @@ + @@ -788,6 +789,8 @@ + + @@ -808,6 +811,7 @@ + @@ -828,6 +832,7 @@ + diff --git a/Builds/VisualStudio2010/Juce.vcxproj.filters b/Builds/VisualStudio2010/Juce.vcxproj.filters index a46857739c..83e575d122 100644 --- a/Builds/VisualStudio2010/Juce.vcxproj.filters +++ b/Builds/VisualStudio2010/Juce.vcxproj.filters @@ -1171,7 +1171,7 @@ Juce\Source\native\windows - + Juce\Source\native\windows @@ -1590,9 +1590,6 @@ Juce\Source\core - - Juce\Source\core - Juce\Source\core @@ -1635,6 +1632,9 @@ Juce\Source\events + + Juce\Source\events + Juce\Source\events @@ -2004,6 +2004,9 @@ Juce\Source\gui\components\special + + Juce\Source\gui\components\special + Juce\Source\gui\components\special @@ -2295,6 +2298,12 @@ Juce\Source\native\mac + + Juce\Source\native\mac + + + Juce\Source\native\mac + Juce\Source\native\windows @@ -2355,6 +2364,9 @@ Juce\Source\threads + + Juce\Source\threads + Juce\Source\threads @@ -2415,6 +2427,9 @@ Juce\Source\utilities + + Juce\Source\utilities + Juce\Source diff --git a/Builds/iOS/Juce.xcodeproj/project.pbxproj b/Builds/iOS/Juce.xcodeproj/project.pbxproj index e28b356fdb..a1fd8a38bd 100644 --- a/Builds/iOS/Juce.xcodeproj/project.pbxproj +++ b/Builds/iOS/Juce.xcodeproj/project.pbxproj @@ -324,7 +324,7 @@ A46B0025A68136ED993E0D85 = { isa = PBXBuildFile; fileRef = 50159A5B7A552A6C1EB557F3; }; B99678E919BF547A3A3F5D6E = { isa = PBXBuildFile; fileRef = CDA5FCC51F6C1E84D7DC3274; }; 5B714CDD0082419BFED7D2D4 = { isa = PBXBuildFile; fileRef = B14735381ADB00741166E330; }; - FB5D5D89E17FF079170E3867 = { isa = PBXBuildFile; fileRef = 83F4C7477C76503C8D028288; }; + 5B33FFE120A47EF42CBC05E4 = { isa = PBXBuildFile; fileRef = 0EB41C0AB478EE02D8C851F9; }; 2DD498313DA488A5063C4C1B = { isa = PBXBuildFile; fileRef = 09AE0882D58BE1715219556A; }; 552D45FB250C62F86CD02A57 = { isa = PBXBuildFile; fileRef = FBE07C5CC622A5D36BDAB9E1; }; 0E8E9829E95E32163F45482D = { isa = PBXBuildFile; fileRef = B07C853EB60D8D8691BC1B4B; }; @@ -543,7 +543,6 @@ DF6CAC67C0F2D379BDA03062 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_PerformanceCounter.cpp"; path = "../../src/core/juce_PerformanceCounter.cpp"; sourceTree = "SOURCE_ROOT"; }; 1159C6BB0D33EE8E1A96B083 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_PerformanceCounter.h"; path = "../../src/core/juce_PerformanceCounter.h"; sourceTree = "SOURCE_ROOT"; }; 8292AE37F99FCC1E5BF63A28 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_PlatformDefs.h"; path = "../../src/core/juce_PlatformDefs.h"; sourceTree = "SOURCE_ROOT"; }; - 8D499CED6DCF525ACD6E39B2 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_PlatformUtilities.h"; path = "../../src/core/juce_PlatformUtilities.h"; sourceTree = "SOURCE_ROOT"; }; CFAECB6551F48A1695DEC243 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_RelativeTime.cpp"; path = "../../src/core/juce_RelativeTime.cpp"; sourceTree = "SOURCE_ROOT"; }; B4137E4612C1D161894D0D27 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_RelativeTime.h"; path = "../../src/core/juce_RelativeTime.h"; sourceTree = "SOURCE_ROOT"; }; 0AD73B8EA0D60D9927B36624 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_Result.cpp"; path = "../../src/core/juce_Result.cpp"; sourceTree = "SOURCE_ROOT"; }; @@ -568,6 +567,7 @@ 31D985CB8646B78460E9D5A7 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_ActionBroadcaster.cpp"; path = "../../src/events/juce_ActionBroadcaster.cpp"; sourceTree = "SOURCE_ROOT"; }; 09F7685D1EFF472ECB1F5EF1 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_ActionBroadcaster.h"; path = "../../src/events/juce_ActionBroadcaster.h"; sourceTree = "SOURCE_ROOT"; }; 4EF8BD4BF46C4BCB39F96609 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_ActionListener.h"; path = "../../src/events/juce_ActionListener.h"; sourceTree = "SOURCE_ROOT"; }; + 5EB7BD94A754E88D076D777A = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_AppleRemote.h"; path = "../../src/events/juce_AppleRemote.h"; sourceTree = "SOURCE_ROOT"; }; 1617348BBF5D103619D76911 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_AsyncUpdater.cpp"; path = "../../src/events/juce_AsyncUpdater.cpp"; sourceTree = "SOURCE_ROOT"; }; 44DB44953945417F76199479 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_AsyncUpdater.h"; path = "../../src/events/juce_AsyncUpdater.h"; sourceTree = "SOURCE_ROOT"; }; D04B6E43A037F985434B2F5A = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_CallbackMessage.h"; path = "../../src/events/juce_CallbackMessage.h"; sourceTree = "SOURCE_ROOT"; }; @@ -797,6 +797,7 @@ A34C0E63D41CFF5E55FD1D9E = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_PreferencesPanel.cpp"; path = "../../src/gui/components/special/juce_PreferencesPanel.cpp"; sourceTree = "SOURCE_ROOT"; }; 6BE989C709D2D1D017548447 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_PreferencesPanel.h"; path = "../../src/gui/components/special/juce_PreferencesPanel.h"; sourceTree = "SOURCE_ROOT"; }; 529CB909220344AD55944372 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_QuickTimeMovieComponent.h"; path = "../../src/gui/components/special/juce_QuickTimeMovieComponent.h"; sourceTree = "SOURCE_ROOT"; }; + A9DB12F944D9DC336AD0A78B = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_ScopedXLock.h"; path = "../../src/gui/components/special/juce_ScopedXLock.h"; sourceTree = "SOURCE_ROOT"; }; CC04F253CB70B20B774801A9 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_SystemTrayIconComponent.cpp"; path = "../../src/gui/components/special/juce_SystemTrayIconComponent.cpp"; sourceTree = "SOURCE_ROOT"; }; D9847FECA6801E9A61007D50 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_SystemTrayIconComponent.h"; path = "../../src/gui/components/special/juce_SystemTrayIconComponent.h"; sourceTree = "SOURCE_ROOT"; }; 740D1808DB934123F05A1598 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_WebBrowserComponent.h"; path = "../../src/gui/components/special/juce_WebBrowserComponent.h"; sourceTree = "SOURCE_ROOT"; }; @@ -1011,6 +1012,8 @@ FE6E3F911679B0D7547577A3 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = "juce_mac_SystemStats.mm"; path = "../../src/native/mac/juce_mac_SystemStats.mm"; sourceTree = "SOURCE_ROOT"; }; 8BCE60CBC91DBAAB089958A1 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = "juce_mac_Threads.mm"; path = "../../src/native/mac/juce_mac_Threads.mm"; sourceTree = "SOURCE_ROOT"; }; 3F11593DC3A168A52FCC2DD9 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = "juce_mac_WebBrowserComponent.mm"; path = "../../src/native/mac/juce_mac_WebBrowserComponent.mm"; sourceTree = "SOURCE_ROOT"; }; + AB0F3F5A622CBB251F64945A = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_osx_MessageQueue.h"; path = "../../src/native/mac/juce_osx_MessageQueue.h"; sourceTree = "SOURCE_ROOT"; }; + AD495FA1991295C722B46843 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_osx_ObjCHelpers.h"; path = "../../src/native/mac/juce_osx_ObjCHelpers.h"; sourceTree = "SOURCE_ROOT"; }; 42059626955C547DA6AD3196 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_win32_ActiveXComponent.cpp"; path = "../../src/native/windows/juce_win32_ActiveXComponent.cpp"; sourceTree = "SOURCE_ROOT"; }; 8F383A785B4876198C5B0194 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_win32_ASIO.cpp"; path = "../../src/native/windows/juce_win32_ASIO.cpp"; sourceTree = "SOURCE_ROOT"; }; F3B50EE3939E9F16D13C3C7C = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_win32_AudioCDReader.cpp"; path = "../../src/native/windows/juce_win32_AudioCDReader.cpp"; sourceTree = "SOURCE_ROOT"; }; @@ -1030,7 +1033,7 @@ 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"; }; - 83F4C7477C76503C8D028288 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_win32_PlatformUtils.cpp"; path = "../../src/native/windows/juce_win32_PlatformUtils.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"; }; 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"; }; @@ -1080,6 +1083,7 @@ 95F21C2733BD5932372E4157 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_XmlElement.cpp"; path = "../../src/text/juce_XmlElement.cpp"; sourceTree = "SOURCE_ROOT"; }; 4EF8C44FF03700F6140950F3 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_XmlElement.h"; path = "../../src/text/juce_XmlElement.h"; sourceTree = "SOURCE_ROOT"; }; 40282E23D43D86D122CA5C54 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_CriticalSection.h"; path = "../../src/threads/juce_CriticalSection.h"; sourceTree = "SOURCE_ROOT"; }; + EC240B4379FB70C8A8AC2855 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_DynamicLibrary.h"; path = "../../src/threads/juce_DynamicLibrary.h"; sourceTree = "SOURCE_ROOT"; }; 5508D42FCF7A1C8A8CD78BF0 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_InterProcessLock.h"; path = "../../src/threads/juce_InterProcessLock.h"; sourceTree = "SOURCE_ROOT"; }; 90E4999A78655A238AF42BC0 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_Process.h"; path = "../../src/threads/juce_Process.h"; sourceTree = "SOURCE_ROOT"; }; 8E78623B2D21CFE68DEC0483 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_ReadWriteLock.cpp"; path = "../../src/threads/juce_ReadWriteLock.cpp"; sourceTree = "SOURCE_ROOT"; }; @@ -1110,6 +1114,7 @@ 3C9E6597968358B57374502C = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_UndoManager.h"; path = "../../src/utilities/juce_UndoManager.h"; sourceTree = "SOURCE_ROOT"; }; ADE5F12AA5AD969E2C7002B3 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_UnitTest.cpp"; path = "../../src/utilities/juce_UnitTest.cpp"; sourceTree = "SOURCE_ROOT"; }; 75700D13513346310CEAC30D = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_UnitTest.h"; path = "../../src/utilities/juce_UnitTest.h"; sourceTree = "SOURCE_ROOT"; }; + AAC585C4648559DD713F28FE = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_WindowsRegistry.h"; path = "../../src/utilities/juce_WindowsRegistry.h"; sourceTree = "SOURCE_ROOT"; }; 2FD5C998952BE08F8ED3F262 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce.h; path = ../../juce.h; sourceTree = "SOURCE_ROOT"; }; 01778F26212AECCBF2452804 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_Config.h"; path = "../../juce_Config.h"; sourceTree = "SOURCE_ROOT"; }; D443FD24B52106986FC8A531 = { isa = PBXGroup; children = ( @@ -1319,7 +1324,6 @@ DF6CAC67C0F2D379BDA03062, 1159C6BB0D33EE8E1A96B083, 8292AE37F99FCC1E5BF63A28, - 8D499CED6DCF525ACD6E39B2, CFAECB6551F48A1695DEC243, B4137E4612C1D161894D0D27, 0AD73B8EA0D60D9927B36624, @@ -1346,6 +1350,7 @@ 31D985CB8646B78460E9D5A7, 09F7685D1EFF472ECB1F5EF1, 4EF8BD4BF46C4BCB39F96609, + 5EB7BD94A754E88D076D777A, 1617348BBF5D103619D76911, 44DB44953945417F76199479, D04B6E43A037F985434B2F5A, @@ -1579,6 +1584,7 @@ A34C0E63D41CFF5E55FD1D9E, 6BE989C709D2D1D017548447, 529CB909220344AD55944372, + A9DB12F944D9DC336AD0A78B, CC04F253CB70B20B774801A9, D9847FECA6801E9A61007D50, 740D1808DB934123F05A1598 ); name = special; sourceTree = ""; }; @@ -1847,7 +1853,9 @@ E6A7BFB0FCD17A9B133CDFA4, FE6E3F911679B0D7547577A3, 8BCE60CBC91DBAAB089958A1, - 3F11593DC3A168A52FCC2DD9 ); name = mac; sourceTree = ""; }; + 3F11593DC3A168A52FCC2DD9, + AB0F3F5A622CBB251F64945A, + AD495FA1991295C722B46843 ); name = mac; sourceTree = ""; }; 64DE2D4534D79E74C40A0DEE = { isa = PBXGroup; children = ( 42059626955C547DA6AD3196, 8F383A785B4876198C5B0194, @@ -1868,7 +1876,7 @@ E7625D7A06CBC11F40A56A70, CDA5FCC51F6C1E84D7DC3274, B14735381ADB00741166E330, - 83F4C7477C76503C8D028288, + 0EB41C0AB478EE02D8C851F9, 09AE0882D58BE1715219556A, FBE07C5CC622A5D36BDAB9E1, B07C853EB60D8D8691BC1B4B, @@ -1927,6 +1935,7 @@ 4EF8C44FF03700F6140950F3 ); name = text; sourceTree = ""; }; 723AC5B999F1EC8F4A101AAF = { isa = PBXGroup; children = ( 40282E23D43D86D122CA5C54, + EC240B4379FB70C8A8AC2855, 5508D42FCF7A1C8A8CD78BF0, 90E4999A78655A238AF42BC0, 8E78623B2D21CFE68DEC0483, @@ -1957,7 +1966,8 @@ A59A5DCFCCAAEA79D03C2B27, 3C9E6597968358B57374502C, ADE5F12AA5AD969E2C7002B3, - 75700D13513346310CEAC30D ); name = utilities; sourceTree = ""; }; + 75700D13513346310CEAC30D, + AAC585C4648559DD713F28FE ); name = utilities; sourceTree = ""; }; 9AA3D660772E3D4C64EC7859 = { isa = PBXGroup; children = ( D443FD24B52106986FC8A531, F2B0E44A08E127FD31184241, @@ -2381,7 +2391,7 @@ A46B0025A68136ED993E0D85, B99678E919BF547A3A3F5D6E, 5B714CDD0082419BFED7D2D4, - FB5D5D89E17FF079170E3867, + 5B33FFE120A47EF42CBC05E4, 2DD498313DA488A5063C4C1B, 552D45FB250C62F86CD02A57, 0E8E9829E95E32163F45482D, diff --git a/Juce.jucer b/Juce.jucer index ad3bcfb40c..1bad2e75df 100644 --- a/Juce.jucer +++ b/Juce.jucer @@ -418,8 +418,6 @@ file="src/core/juce_PerformanceCounter.h"/> - + + + + - + + + presetNumber == index) { - s = PlatformUtilities::cfStringToJuceString (p->presetName); + s = String::fromCFString (p->presetName); break; } } @@ -34117,6 +34117,11 @@ END_JUCE_NAMESPACE #else #include #include + + static bool makeFSRefFromPath (FSRef* destFSRef, const String& path) + { + return FSPathMakeRef (reinterpret_cast (path.toUTF8().getAddress()), destFSRef, 0) == noErr; + } #endif #if ! (JUCE_MAC && JUCE_64BIT) @@ -34621,11 +34626,9 @@ public: ModuleHandle (const File& file_) : file (file_), - moduleMain (0), - #if JUCE_WINDOWS || JUCE_LINUX - hModule (0) - #elif JUCE_MAC - fragId (0), resHandle (0), bundleRef (0), resFileId (0) + moduleMain (0) + #if JUCE_MAC + , fragId (0), resHandle (0), bundleRef (0), resFileId (0) #endif { getActiveModules().add (this); @@ -34634,7 +34637,7 @@ public: fullParentDirectoryPathName = file_.getParentDirectory().getFullPathName(); #elif JUCE_MAC FSRef ref; - PlatformUtilities::makeFSRefFromPath (&ref, file_.getParentDirectory().getFullPathName()); + makeFSRefFromPath (&ref, file_.getParentDirectory().getFullPathName()); FSGetCatalogInfo (&ref, kFSCatInfoNone, 0, 0, &parentDirFSSpec, 0); #endif } @@ -34646,7 +34649,7 @@ public: } #if JUCE_WINDOWS || JUCE_LINUX - void* hModule; + DynamicLibrary module; String fullParentDirectoryPathName; bool open() @@ -34663,21 +34666,21 @@ public: pluginName = file.getFileNameWithoutExtension(); - hModule = PlatformUtilities::loadDynamicLibrary (file.getFullPathName()); + module.open (file.getFullPathName()); - moduleMain = (MainCall) PlatformUtilities::getProcedureEntryPoint (hModule, "VSTPluginMain"); + moduleMain = (MainCall) module.getFunction ("VSTPluginMain"); - if (moduleMain == 0) - moduleMain = (MainCall) PlatformUtilities::getProcedureEntryPoint (hModule, "main"); + if (moduleMain == nullptr) + moduleMain = (MainCall) module.getFunction ("main"); - return moduleMain != 0; + return moduleMain != nullptr; } void close() { _fpreset(); // (doesn't do any harm) - PlatformUtilities::freeDynamicLibrary (hModule); + module.close(); } void closeEffect (AEffect* eff) @@ -37011,7 +37014,7 @@ bool VSTPluginFormat::fileMightContainThisPluginType (const String& fileOrIdenti #if JUCE_PPC FSRef fileRef; - if (PlatformUtilities::makeFSRefFromPath (&fileRef, f.getFullPathName())) + if (makeFSRefFromPath (&fileRef, f.getFullPathName())) { const short resFileId = FSOpenResFile (&fileRef, fsRdPerm); @@ -51485,7 +51488,9 @@ void Slider::lookAndFeelChanged() valueBox->setWantsKeyboardFocus (false); valueBox->setText (previousTextBoxContent, false); - valueBox->setEditable (editableText && isEnabled()); + if (valueBox->isEditable() != editableText) // (avoid overriding the single/double click flags unless we have to) + valueBox->setEditable (editableText && isEnabled()); + valueBox->addListener (this); if (style == LinearBar) @@ -69830,11 +69835,6 @@ const Drawable* LookAndFeel::getDefaultDocumentFileImage() return documentImage; } -void LookAndFeel::playAlertSound() -{ - PlatformUtilities::beep(); -} - void LookAndFeel::drawLevelMeter (Graphics& g, int width, int height, float level) { g.setColour (Colours::white.withAlpha (0.7f)); @@ -245273,32 +245273,31 @@ void Process::terminate() ExitProcess (0); } -void* PlatformUtilities::loadDynamicLibrary (const String& name) +bool DynamicLibrary::open (const String& name) { - void* result = nullptr; - JUCE_TRY { - result = LoadLibrary (name.toWideCharPointer()); + handle = LoadLibrary (name.toWideCharPointer()); } JUCE_CATCH_ALL - return result; + return handle != nullptr; } -void PlatformUtilities::freeDynamicLibrary (void* h) +void DynamicLibrary::close() noexcept { JUCE_TRY { - if (h != nullptr) - FreeLibrary ((HMODULE) h); + if (handle != nullptr) + FreeLibrary ((HMODULE) handle); } JUCE_CATCH_ALL } -void* PlatformUtilities::getProcedureEntryPoint (void* h, const String& name) +void* DynamicLibrary::getFunction (const String& functionName) noexcept { - return (h != nullptr) ? (void*) GetProcAddress ((HMODULE) h, name.toUTF8()) : nullptr; // (void* cast is required for mingw) + return handle != nullptr ? (void*) GetProcAddress ((HMODULE) handle, functionName.toUTF8()) // (void* cast is required for mingw) + : nullptr; } class InterProcessLock::Pimpl @@ -245882,7 +245881,7 @@ File JUCE_CALLTYPE File::getSpecialLocation (const SpecialLocationType type) case currentExecutableFile: case currentApplicationFile: { - HINSTANCE moduleHandle = (HINSTANCE) PlatformUtilities::getCurrentModuleInstanceHandle(); + HINSTANCE moduleHandle = (HINSTANCE) Process::getCurrentModuleInstanceHandle(); WCHAR dest [MAX_PATH + 256]; dest[0] = 0; @@ -246046,7 +246045,7 @@ bool DirectoryIterator::NativeIterator::next (String& filenameFound, return pimpl->next (filenameFound, isDir, isHidden, fileSize, modTime, creationTime, isReadOnly); } -bool PlatformUtilities::openDocument (const String& fileName, const String& parameters) +bool Process::openDocument (const String& fileName, const String& parameters) { HINSTANCE hInstance = 0; @@ -246713,10 +246712,10 @@ void MACAddress::findAllAddresses (Array& result) MACAddressHelpers::getViaNetBios (result); } -bool PlatformUtilities::launchEmailWithAttachments (const String& targetEmailAddress, - const String& emailSubject, - const String& bodyText, - const StringArray& filesToAttach) +bool Process::openEmailWithAttachments (const String& targetEmailAddress, + const String& emailSubject, + const String& bodyText, + const StringArray& filesToAttach) { HMODULE h = LoadLibraryA ("MAPI32.dll"); @@ -246764,7 +246763,7 @@ bool PlatformUtilities::launchEmailWithAttachments (const String& targetEmailAdd /*** End of inlined file: juce_win32_Network.cpp ***/ -/*** Start of inlined file: juce_win32_PlatformUtils.cpp ***/ +/*** Start of inlined file: juce_win32_Registry.cpp ***/ // (This file gets included by juce_win32_NativeCode.cpp, rather than being // compiled on its own). #if JUCE_INCLUDED_FILE @@ -246807,8 +246806,7 @@ namespace } } -String PlatformUtilities::getRegistryValue (const String& regValuePath, - const String& defaultValue) +String WindowsRegistry::getValue (const String& regValuePath, const String& defaultValue) { String valueName, result (defaultValue); HKEY k = findKeyForPath (regValuePath, false, valueName); @@ -246833,8 +246831,7 @@ String PlatformUtilities::getRegistryValue (const String& regValuePath, return result; } -void PlatformUtilities::setRegistryValue (const String& regValuePath, - const String& value) +void WindowsRegistry::setValue (const String& regValuePath, const String& value) { String valueName; HKEY k = findKeyForPath (regValuePath, true, valueName); @@ -246849,7 +246846,7 @@ void PlatformUtilities::setRegistryValue (const String& regValuePath, } } -bool PlatformUtilities::registryValueExists (const String& regValuePath) +bool WindowsRegistry::valueExists (const String& regValuePath) { bool exists = false; String valueName; @@ -246870,7 +246867,7 @@ bool PlatformUtilities::registryValueExists (const String& regValuePath) return exists; } -void PlatformUtilities::deleteRegistryValue (const String& regValuePath) +void WindowsRegistry::deleteValue (const String& regValuePath) { String valueName; HKEY k = findKeyForPath (regValuePath, true, valueName); @@ -246882,7 +246879,7 @@ void PlatformUtilities::deleteRegistryValue (const String& regValuePath) } } -void PlatformUtilities::deleteRegistryKey (const String& regKeyPath) +void WindowsRegistry::deleteKey (const String& regKeyPath) { String valueName; HKEY k = findKeyForPath (regKeyPath, true, valueName); @@ -246894,67 +246891,27 @@ void PlatformUtilities::deleteRegistryKey (const String& regKeyPath) } } -void PlatformUtilities::registerFileAssociation (const String& fileExtension, - const String& symbolicDescription, - const String& fullDescription, - const File& targetExecutable, - int iconResourceNumber) +void WindowsRegistry::registerFileAssociation (const String& fileExtension, + const String& symbolicDescription, + const String& fullDescription, + const File& targetExecutable, + int iconResourceNumber) { - setRegistryValue ("HKEY_CLASSES_ROOT\\" + fileExtension + "\\", symbolicDescription); + setValue ("HKEY_CLASSES_ROOT\\" + fileExtension + "\\", symbolicDescription); const String key ("HKEY_CLASSES_ROOT\\" + symbolicDescription); if (iconResourceNumber != 0) - setRegistryValue (key + "\\DefaultIcon\\", - targetExecutable.getFullPathName() + "," + String (-iconResourceNumber)); - - setRegistryValue (key + "\\", fullDescription); - setRegistryValue (key + "\\shell\\open\\command\\", targetExecutable.getFullPathName() + " %1"); -} - -bool juce_IsRunningInWine() -{ - HMODULE ntdll = GetModuleHandle (_T("ntdll.dll")); - return ntdll != 0 && GetProcAddress (ntdll, "wine_get_version") != 0; -} - -String JUCE_CALLTYPE PlatformUtilities::getCurrentCommandLineParams() -{ - return String (CharacterFunctions::findEndOfToken (CharPointer_UTF16 (GetCommandLineW()), - CharPointer_UTF16 (L" "), - CharPointer_UTF16 (L"\""))).trimStart(); -} - -static void* currentModuleHandle = nullptr; - -void* PlatformUtilities::getCurrentModuleInstanceHandle() noexcept -{ - if (currentModuleHandle == nullptr) - currentModuleHandle = GetModuleHandle (0); - - return currentModuleHandle; -} + setValue (key + "\\DefaultIcon\\", + targetExecutable.getFullPathName() + "," + String (-iconResourceNumber)); -void PlatformUtilities::setCurrentModuleInstanceHandle (void* const newHandle) noexcept -{ - currentModuleHandle = newHandle; -} - -void PlatformUtilities::fpuReset() -{ - #if JUCE_MSVC - _clearfp(); - #endif -} - -void PlatformUtilities::beep() -{ - MessageBeep (MB_OK); + setValue (key + "\\", fullDescription); + setValue (key + "\\shell\\open\\command\\", targetExecutable.getFullPathName() + " %1"); } #endif -/*** End of inlined file: juce_win32_PlatformUtils.cpp ***/ +/*** End of inlined file: juce_win32_Registry.cpp ***/ #if ! JUCE_ONLY_BUILD_CORE_LIBRARY @@ -246971,7 +246928,7 @@ public: String className ("JUCE_"); className << String::toHexString (Time::getHighResolutionTicks()); - HMODULE moduleHandle = (HMODULE) PlatformUtilities::getCurrentModuleInstanceHandle(); + HMODULE moduleHandle = (HMODULE) Process::getCurrentModuleInstanceHandle(); WNDCLASSEX wc = { 0 }; wc.cbSize = sizeof (wc); @@ -249579,7 +249536,7 @@ private: String windowClassName ("JUCE_"); windowClassName << (int) (Time::currentTimeMillis() & 0x7fffffff); - HINSTANCE moduleHandle = (HINSTANCE) PlatformUtilities::getCurrentModuleInstanceHandle(); + HINSTANCE moduleHandle = (HINSTANCE) Process::getCurrentModuleInstanceHandle(); TCHAR moduleFile [1024] = { 0 }; GetModuleFileName (moduleHandle, moduleFile, 1024); @@ -249603,7 +249560,7 @@ private: ~WindowClassHolder() { if (ComponentPeer::getNumPeers() == 0) - UnregisterClass (getWindowClassName(), (HINSTANCE) PlatformUtilities::getCurrentModuleInstanceHandle()); + UnregisterClass (getWindowClassName(), (HINSTANCE) Process::getCurrentModuleInstanceHandle()); clearSingletonInstance(); } @@ -249674,7 +249631,7 @@ private: hwnd = CreateWindowEx (exstyle, WindowClassHolder::getInstance()->getWindowClassName(), L"", type, 0, 0, 0, 0, parentToAddTo, 0, - (HINSTANCE) PlatformUtilities::getCurrentModuleInstanceHandle(), 0); + (HINSTANCE) Process::getCurrentModuleInstanceHandle(), 0); #if JUCE_DIRECT2D setCurrentRenderingEngine (1); @@ -251406,6 +251363,11 @@ bool Desktop::isScreenSaverEnabled() noexcept } */ +void LookAndFeel::playAlertSound() +{ + MessageBeep (MB_OK); +} + void Desktop::setKioskComponent (Component* kioskModeComponent, bool enableOrDisable, bool /*allowMenusAndBars*/) { if (enableOrDisable) @@ -251457,7 +251419,7 @@ Image juce_createIconForFile (const File& file) Image image; WORD iconNum = 0; - HICON icon = ExtractAssociatedIcon ((HINSTANCE) PlatformUtilities::getCurrentModuleInstanceHandle(), + HICON icon = ExtractAssociatedIcon ((HINSTANCE) Process::getCurrentModuleInstanceHandle(), const_cast (file.getFullPathName().toWideCharPointer()), &iconNum); if (icon != 0) @@ -252159,6 +252121,34 @@ String SystemClipboard::getTextFromClipboard() return result; } +bool juce_IsRunningInWine() +{ + HMODULE ntdll = GetModuleHandle (_T("ntdll.dll")); + return ntdll != 0 && GetProcAddress (ntdll, "wine_get_version") != 0; +} + +String JUCE_CALLTYPE Process::getCurrentCommandLineParams() +{ + return String (CharacterFunctions::findEndOfToken (CharPointer_UTF16 (GetCommandLineW()), + CharPointer_UTF16 (L" "), + CharPointer_UTF16 (L"\""))).trimStart(); +} + +static void* currentModuleHandle = nullptr; + +void* Process::getCurrentModuleInstanceHandle() noexcept +{ + if (currentModuleHandle == nullptr) + currentModuleHandle = GetModuleHandle (0); + + return currentModuleHandle; +} + +void Process::setCurrentModuleInstanceHandle (void* const newHandle) noexcept +{ + currentModuleHandle = newHandle; +} + #endif /*** End of inlined file: juce_win32_Misc.cpp ***/ @@ -253482,7 +253472,7 @@ private: String windowClassName ("JUCE_DIRECTSHOW_"); windowClassName << (int) (Time::currentTimeMillis() & 0x7fffffff); - HINSTANCE moduleHandle = (HINSTANCE) PlatformUtilities::getCurrentModuleInstanceHandle(); + HINSTANCE moduleHandle = (HINSTANCE) Process::getCurrentModuleInstanceHandle(); TCHAR moduleFile [1024] = { 0 }; GetModuleFileName (moduleHandle, moduleFile, 1024); @@ -253501,7 +253491,7 @@ private: ~NativeWindowClass() { if (atom != 0) - UnregisterClass (getWindowClassName(), (HINSTANCE) PlatformUtilities::getCurrentModuleInstanceHandle()); + UnregisterClass (getWindowClassName(), (HINSTANCE) Process::getCurrentModuleInstanceHandle()); clearSingletonInstance(); } @@ -253553,7 +253543,7 @@ private: hwnd = CreateWindowEx (exstyle, wc->getWindowClassName(), L"", type, 0, 0, 0, 0, parentToAddTo, 0, - (HINSTANCE) PlatformUtilities::getCurrentModuleInstanceHandle(), 0); + (HINSTANCE) Process::getCurrentModuleInstanceHandle(), 0); if (hwnd != 0) { @@ -263124,7 +263114,7 @@ bool DirectoryIterator::NativeIterator::next (String& filenameFound, return pimpl->next (filenameFound, isDir, isHidden, fileSize, modTime, creationTime, isReadOnly); } -bool PlatformUtilities::openDocument (const String& fileName, const String& parameters) +bool Process::openDocument (const String& fileName, const String& parameters) { String cmdString (fileName.replace (" ", "\\ ",false)); cmdString << " " << parameters; @@ -263398,10 +263388,10 @@ void MACAddress::findAllAddresses (Array& result) } } -bool PlatformUtilities::launchEmailWithAttachments (const String& targetEmailAddress, - const String& emailSubject, - const String& bodyText, - const StringArray& filesToAttach) +bool Process::openEmailWithAttachments (const String& targetEmailAddress, + const String& emailSubject, + const String& bodyText, + const StringArray& filesToAttach) { jassertfalse; // xxx todo @@ -263903,10 +263893,6 @@ SystemStats::CPUFlags::CPUFlags() numCpus = LinuxStatsHelpers::getCpuInfo ("processor").getIntValue() + 1; } -void PlatformUtilities::fpuReset() -{ -} - uint32 juce_millisecondsSinceStartup() noexcept { timespec t; @@ -264035,27 +264021,26 @@ void Process::lowerPrivilege() } } -#if ! JUCE_ONLY_BUILD_CORE_LIBRARY - -void* PlatformUtilities::loadDynamicLibrary (const String& name) +bool DynamicLibrary::open (const String& name) { - return dlopen (name.toUTF8(), RTLD_LOCAL | RTLD_NOW); + close(); + handle = dlopen (name.toUTF8(), RTLD_LOCAL | RTLD_NOW); + return handle != 0; } -void PlatformUtilities::freeDynamicLibrary (void* handle) +void DynamicLibrary::close() noexcept { - dlclose(handle); + if (handle != nullptr) + dlclose (handle); } -void* PlatformUtilities::getProcedureEntryPoint (void* libraryHandle, const String& procedureName) +void* DynamicLibrary::getFunction (const String& functionName) noexcept { - return dlsym (libraryHandle, procedureName.toUTF8()); + return handle != nullptr ? dlsym (handle, functionName.toUTF8()) : nullptr; } #endif -#endif - /*** End of inlined file: juce_linux_Threads.cpp ***/ #if ! JUCE_ONLY_BUILD_CORE_LIBRARY @@ -268546,7 +268531,7 @@ void SystemTrayIconComponent::setIconTooltip (const String& tooltip) // xxx not yet implemented! } -void PlatformUtilities::beep() +void LookAndFeel::playAlertSound() { std::cout << "\a" << std::flush; } @@ -270880,8 +270865,27 @@ BEGIN_JUCE_NAMESPACE #undef Point #if ! JUCE_ONLY_BUILD_CORE_LIBRARY + +/*** Start of inlined file: juce_osx_ObjCHelpers.h ***/ +#ifndef __JUCE_OSX_OBJCHELPERS_JUCEHEADER__ +#define __JUCE_OSX_OBJCHELPERS_JUCEHEADER__ + +/* This file contains a few helper functions that are used internally but which + need to be kept away from the public headers because they use obj-C symbols. +*/ namespace { + + String nsStringToJuce (NSString* s) + { + return CharPointer_UTF8 ([s UTF8String]); + } + + NSString* juceStringToNS (const String& s) + { + return [NSString stringWithUTF8String: s.toUTF8()]; + } + template const Rectangle convertToRectInt (const RectType& r) { @@ -270901,6 +270905,17 @@ namespace } } +#endif // __JUCE_OSX_OBJCHELPERS_JUCEHEADER__ + +/*** End of inlined file: juce_osx_ObjCHelpers.h ***/ + + + +/*** Start of inlined file: juce_osx_MessageQueue.h ***/ +#ifndef __JUCE_OSX_MESSAGEQUEUE_JUCEHEADER__ +#define __JUCE_OSX_MESSAGEQUEUE_JUCEHEADER__ + +/* An internal message pump class used in OSX and iOS. */ class MessageQueue { public: @@ -270966,6 +270981,11 @@ private: static_cast (info)->runLoopCallback(); } }; + +#endif // __JUCE_OSX_MESSAGEQUEUE_JUCEHEADER__ + +/*** End of inlined file: juce_osx_MessageQueue.h ***/ + #endif #define JUCE_INCLUDED_FILE 1 @@ -271005,20 +271025,7 @@ private: // compiled on its own). #if JUCE_INCLUDED_FILE -namespace -{ - String nsStringToJuce (NSString* s) - { - return CharPointer_UTF8 ([s UTF8String]); - } - - NSString* juceStringToNS (const String& s) - { - return [NSString stringWithUTF8String: s.toUTF8()]; - } -} - -String PlatformUtilities::cfStringToJuceString (CFStringRef cfString) +String String::fromCFString (CFStringRef cfString) { if (cfString == 0) return String::empty; @@ -271031,19 +271038,18 @@ String PlatformUtilities::cfStringToJuceString (CFStringRef cfString) return String (CharPointer_UTF16 ((const CharPointer_UTF16::CharType*) u.getData())); } -CFStringRef PlatformUtilities::juceStringToCFString (const String& s) +CFStringRef String::toCFString() const { - CharPointer_UTF16 utf16 (s.toUTF16()); - + CharPointer_UTF16 utf16 (toUTF16()); return CFStringCreateWithCharacters (kCFAllocatorDefault, (const UniChar*) utf16.getAddress(), utf16.length()); } -String PlatformUtilities::convertToPrecomposedUnicode (const String& s) +String String::convertToPrecomposedUnicode() const { -#if JUCE_IOS + #if JUCE_IOS JUCE_AUTORELEASEPOOL - return nsStringToJuce ([juceStringToNS (s) precomposedStringWithCanonicalMapping]); -#else + return nsStringToJuce ([juceStringToNS (*this) precomposedStringWithCanonicalMapping]); + #else UnicodeMapping map; map.unicodeEncoding = CreateTextEncoding (kTextEncodingUnicodeDefault, @@ -271061,7 +271067,7 @@ String PlatformUtilities::convertToPrecomposedUnicode (const String& s) if (CreateUnicodeToTextInfo (&map, &conversionInfo) == noErr) { - const int bytesNeeded = CharPointer_UTF16::getBytesRequiredFor (s.getCharPointer()); + const int bytesNeeded = CharPointer_UTF16::getBytesRequiredFor (getCharPointer()); HeapBlock tempOut; tempOut.calloc (bytesNeeded + 4); @@ -271070,7 +271076,7 @@ String PlatformUtilities::convertToPrecomposedUnicode (const String& s) ByteCount outputBufferSize = 0; if (ConvertFromUnicodeToText (conversionInfo, - bytesNeeded, (ConstUniCharArrayPtr) s.toUTF16().getAddress(), + bytesNeeded, (ConstUniCharArrayPtr) toUTF16().getAddress(), kUnicodeDefaultDirectionMask, 0, 0, 0, 0, bytesNeeded, &bytesRead, @@ -271083,39 +271089,9 @@ String PlatformUtilities::convertToPrecomposedUnicode (const String& s) } return result; -#endif -} - -#if ! JUCE_ONLY_BUILD_CORE_LIBRARY - -void SystemClipboard::copyTextToClipboard (const String& text) -{ - #if JUCE_IOS - [[UIPasteboard generalPasteboard] setValue: juceStringToNS (text) - forPasteboardType: @"public.text"]; - #else - [[NSPasteboard generalPasteboard] declareTypes: [NSArray arrayWithObject: NSStringPboardType] - owner: nil]; - - [[NSPasteboard generalPasteboard] setString: juceStringToNS (text) - forType: NSStringPboardType]; #endif } -String SystemClipboard::getTextFromClipboard() -{ - #if JUCE_IOS - NSString* text = [[UIPasteboard generalPasteboard] valueForPasteboardType: @"public.text"]; - #else - NSString* text = [[NSPasteboard generalPasteboard] stringForType: NSStringPboardType]; - #endif - - return text == nil ? String::empty - : nsStringToJuce (text); -} - -#endif - #endif /*** End of inlined file: juce_mac_Strings.mm ***/ @@ -271207,7 +271183,7 @@ String SystemStats::getOperatingSystemName() } #if ! JUCE_IOS -int PlatformUtilities::getOSXMinorVersionNumber() +int SystemStats::getOSXMinorVersionNumber() { SInt32 versionMinor = 0; OSErr err = Gestalt (gestaltSystemVersionMinor, &versionMinor); @@ -271224,7 +271200,7 @@ bool SystemStats::isOperatingSystem64Bit() #elif JUCE_64BIT return true; #else - return PlatformUtilities::getOSXMinorVersionNumber() >= 6; + return getOSXMinorVersionNumber() >= 6; #endif } @@ -271333,10 +271309,6 @@ int SystemStats::getPageSize() return (int) NSPageSize(); } -void PlatformUtilities::fpuReset() -{ -} - #endif /*** End of inlined file: juce_mac_SystemStats.mm ***/ @@ -271373,10 +271345,10 @@ void MACAddress::findAllAddresses (Array& result) } } -bool PlatformUtilities::launchEmailWithAttachments (const String& targetEmailAddress, - const String& emailSubject, - const String& bodyText, - const StringArray& filesToAttach) +bool Process::openEmailWithAttachments (const String& targetEmailAddress, + const String& emailSubject, + const String& bodyText, + const StringArray& filesToAttach) { #if JUCE_IOS //xxx probably need to use MFMailComposeViewController @@ -272022,6 +271994,24 @@ 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 ***/ @@ -273107,7 +273097,7 @@ File File::getSpecialLocation (const SpecialLocationType type) } if (resultPath.isNotEmpty()) - return File (PlatformUtilities::convertToPrecomposedUnicode (resultPath)); + return File (resultPath.convertToPrecomposedUnicode()); return File::nonexistent; } @@ -273245,7 +273235,7 @@ bool DirectoryIterator::NativeIterator::next (String& filenameFound, return pimpl->next (filenameFound, isDir, isHidden, fileSize, modTime, creationTime, isReadOnly); } -bool PlatformUtilities::openDocument (const String& fileName, const String& parameters) +bool Process::openDocument (const String& fileName, const String& parameters) { #if JUCE_IOS return [[UIApplication sharedApplication] openURL: [NSURL fileURLWithPath: juceStringToNS (fileName)]]; @@ -273259,8 +273249,9 @@ bool PlatformUtilities::openDocument (const String& fileName, const String& para } bool ok = false; + const File file (fileName); - if (PlatformUtilities::isBundle (fileName)) + if (file.isBundle()) { NSMutableArray* urls = [NSMutableArray array]; @@ -273275,7 +273266,7 @@ bool PlatformUtilities::openDocument (const String& fileName, const String& para additionalEventParamDescriptor: nil launchIdentifiers: nil]; } - else if (File (fileName).exists()) + else if (file.exists()) { ok = FileHelpers::launchExecutable ("\"" + fileName + "\" " + parameters); } @@ -273294,47 +273285,44 @@ void File::revealToUser() const #endif } -#if ! JUCE_IOS -bool PlatformUtilities::makeFSRefFromPath (FSRef* destFSRef, const String& path) -{ - return FSPathMakeRef (reinterpret_cast (path.toUTF8().getAddress()), destFSRef, 0) == noErr; -} - -String PlatformUtilities::makePathFromFSRef (FSRef* file) -{ - char path [2048] = { 0 }; - - if (FSRefMakePath (file, (UInt8*) path, sizeof (path) - 1) == noErr) - return PlatformUtilities::convertToPrecomposedUnicode (CharPointer_UTF8 (path)); - - return String::empty; -} -#endif - -OSType PlatformUtilities::getTypeOfFile (const String& filename) +OSType File::getMacOSType() const { JUCE_AUTORELEASEPOOL #if JUCE_IOS || (defined (MAC_OS_X_VERSION_10_5) && MAC_OS_X_VERSION_MIN_ALLOWED >= MAC_OS_X_VERSION_10_5) - NSDictionary* fileDict = [[NSFileManager defaultManager] attributesOfItemAtPath: juceStringToNS (filename) error: nil]; + NSDictionary* fileDict = [[NSFileManager defaultManager] attributesOfItemAtPath: juceStringToNS (getFullPathName()) error: nil]; #else // (the cast here avoids a deprecation warning) - NSDictionary* fileDict = [((id) [NSFileManager defaultManager]) fileAttributesAtPath: juceStringToNS (filename) traverseLink: NO]; + NSDictionary* fileDict = [((id) [NSFileManager defaultManager]) fileAttributesAtPath: juceStringToNS (getFullPathName()) traverseLink: NO]; #endif return [fileDict fileHFSTypeCode]; } -bool PlatformUtilities::isBundle (const String& filename) +bool File::isBundle() const { #if JUCE_IOS return false; // xxx can't find a sensible way to do this without trying to open the bundle.. #else JUCE_AUTORELEASEPOOL - return [[NSWorkspace sharedWorkspace] isFilePackageAtPath: juceStringToNS (filename)]; + return [[NSWorkspace sharedWorkspace] isFilePackageAtPath: juceStringToNS (getFullPathName())]; #endif } +#if ! JUCE_IOS +void File::addToDock() const +{ + // check that it's not already there... + if (! juce_getOutputFromCommand ("defaults read com.apple.dock persistent-apps").containsIgnoreCase (getFullPathName())) + { + juce_runSystemCommand ("defaults write com.apple.dock persistent-apps -array-add \"tile-datafile-data_CFURLString" + + getFullPathName() + "_CFURLStringType0\""); + + juce_runSystemCommand ("osascript -e \"tell application \\\"Dock\\\" to quit\""); + } +} +#endif + #endif /*** End of inlined file: juce_mac_Files.mm ***/ @@ -273391,16 +273379,12 @@ ScopedAutoReleasePool::~ScopedAutoReleasePool() [((NSAutoreleasePool*) pool) release]; } -void PlatformUtilities::beep() +void LookAndFeel::playAlertSound() { //xxx //AudioServicesPlaySystemSound (); } -void PlatformUtilities::addItemToDock (const File& file) -{ -} - #if ! JUCE_ONLY_BUILD_CORE_LIBRARY class iOSMessageBox; @@ -273582,24 +273566,11 @@ ScopedAutoReleasePool::~ScopedAutoReleasePool() [((NSAutoreleasePool*) pool) release]; } -void PlatformUtilities::beep() +void LookAndFeel::playAlertSound() { NSBeep(); } -void PlatformUtilities::addItemToDock (const File& file) -{ - // check that it's not already there... - if (! juce_getOutputFromCommand ("defaults read com.apple.dock persistent-apps") - .containsIgnoreCase (file.getFullPathName())) - { - juce_runSystemCommand ("defaults write com.apple.dock persistent-apps -array-add \"tile-datafile-data_CFURLString" - + file.getFullPathName() + "_CFURLStringType0\""); - - juce_runSystemCommand ("osascript -e \"tell application \\\"Dock\\\" to quit\""); - } -} - #if ! JUCE_ONLY_BUILD_CORE_LIBRARY class OSXMessageBox : public AsyncUpdater @@ -273958,7 +273929,7 @@ public: unitsToHeightScaleFactor (0.0f) { JUCE_AUTORELEASEPOOL - CFStringRef cfName = PlatformUtilities::juceStringToCFString (font.getTypefaceName()); + CFStringRef cfName = font.getTypefaceName().toCFString(); ctFontRef = CTFontCreateWithName (cfName, 1024, nullptr); CFRelease (cfName); @@ -274044,7 +274015,7 @@ public: if (ctFontRef != nullptr && text.isNotEmpty()) { - CFStringRef cfText = PlatformUtilities::juceStringToCFString (text); + CFStringRef cfText = text.toCFString(); CFAttributedStringRef attribString = CFAttributedStringCreate (kCFAllocatorDefault, cfText, attributedStringAtts); CFRelease (cfText); @@ -274079,7 +274050,7 @@ public: { float x = 0; - CFStringRef cfText = PlatformUtilities::juceStringToCFString (text); + CFStringRef cfText = text.toCFString(); CFAttributedStringRef attribString = CFAttributedStringCreate (kCFAllocatorDefault, cfText, attributedStringAtts); CFRelease (cfText); @@ -276509,6 +276480,20 @@ Image juce_createIconForFile (const File& file) return Image::null; } +void SystemClipboard::copyTextToClipboard (const String& text) +{ + [[UIPasteboard generalPasteboard] setValue: juceStringToNS (text) + forPasteboardType: @"public.text"]; +} + +String SystemClipboard::getTextFromClipboard() +{ + NSString* text = [[UIPasteboard generalPasteboard] valueForPasteboardType: @"public.text"]; + + return text == nil ? String::empty + : nsStringToJuce (text); +} + void Desktop::createMouseInputSources() { for (int i = 0; i < 10; ++i) @@ -278461,7 +278446,7 @@ namespace CoreMidiHelpers if (str != 0) { - result = PlatformUtilities::cfStringToJuceString (str); + result = String::fromCFString (str); CFRelease (str); str = 0; } @@ -278479,7 +278464,7 @@ namespace CoreMidiHelpers if (str != 0) { - result += PlatformUtilities::cfStringToJuceString (str); + result += String::fromCFString (str); CFRelease (str); str = 0; } @@ -278495,7 +278480,7 @@ namespace CoreMidiHelpers if (str != 0) { - const String s (PlatformUtilities::cfStringToJuceString (str)); + const String s (String::fromCFString (str)); CFRelease (str); // if an external device has only one entity, throw away @@ -278557,7 +278542,7 @@ namespace CoreMidiHelpers if (str != 0) { - s = PlatformUtilities::cfStringToJuceString (str); + s = String::fromCFString (str); CFRelease (str); } } @@ -278594,7 +278579,7 @@ namespace CoreMidiHelpers if (JUCEApplication::getInstance() != nullptr) name = JUCEApplication::getInstance()->getApplicationName(); - CFStringRef appName = PlatformUtilities::juceStringToCFString (name); + CFStringRef appName = name.toCFString(); CHECK_ERROR (MIDIClientCreate (appName, 0, 0, &globalMidiClient)); CFRelease (appName); } @@ -278755,7 +278740,7 @@ MidiOutput* MidiOutput::createNewDevice (const String& deviceName) MIDIClientRef client = CoreMidiHelpers::getGlobalMidiClient(); MIDIEndpointRef endPoint; - CFStringRef name = PlatformUtilities::juceStringToCFString (deviceName); + CFStringRef name = deviceName.toCFString(); if (client != 0 && CHECK_ERROR (MIDISourceCreate (client, name, &endPoint))) { @@ -278909,7 +278894,8 @@ MidiInput* MidiInput::createNewDevice (const String& deviceName, MidiInputCallba mpc->active = false; MIDIEndpointRef endPoint; - CFStringRef name = PlatformUtilities::juceStringToCFString(deviceName); + CFStringRef name = deviceName.toCFString(); + if (CHECK_ERROR (MIDIDestinationCreate (client, name, midiInputProc, mpc, &endPoint))) { mpc->portAndEndpoint = new MidiPortAndEndpoint (0, endPoint); @@ -278997,7 +278983,7 @@ public: unitsToHeightScaleFactor (0.0f) { JUCE_AUTORELEASEPOOL - CFStringRef cfName = PlatformUtilities::juceStringToCFString (font.getTypefaceName()); + CFStringRef cfName = font.getTypefaceName().toCFString(); ctFontRef = CTFontCreateWithName (cfName, 1024, nullptr); CFRelease (cfName); @@ -279083,7 +279069,7 @@ public: if (ctFontRef != nullptr && text.isNotEmpty()) { - CFStringRef cfText = PlatformUtilities::juceStringToCFString (text); + CFStringRef cfText = text.toCFString(); CFAttributedStringRef attribString = CFAttributedStringCreate (kCFAllocatorDefault, cfText, attributedStringAtts); CFRelease (cfText); @@ -279118,7 +279104,7 @@ public: { float x = 0; - CFStringRef cfText = PlatformUtilities::juceStringToCFString (text); + CFStringRef cfText = text.toCFString(); CFAttributedStringRef attribString = CFAttributedStringCreate (kCFAllocatorDefault, cfText, attributedStringAtts); CFRelease (cfText); @@ -282277,6 +282263,23 @@ Image juce_createIconForFile (const File& file) return Image (result); } +void SystemClipboard::copyTextToClipboard (const String& text) +{ + [[NSPasteboard generalPasteboard] declareTypes: [NSArray arrayWithObject: NSStringPboardType] + owner: nil]; + + [[NSPasteboard generalPasteboard] setString: juceStringToNS (text) + forType: NSStringPboardType]; +} + +String SystemClipboard::getTextFromClipboard() +{ + NSString* text = [[NSPasteboard generalPasteboard] stringForType: NSStringPboardType]; + + return text == nil ? String::empty + : nsStringToJuce (text); +} + const int KeyPress::spaceKey = ' '; const int KeyPress::returnKey = 0x0d; const int KeyPress::escapeKey = 0x1b; @@ -287289,7 +287292,7 @@ namespace CoreMidiHelpers if (str != 0) { - result = PlatformUtilities::cfStringToJuceString (str); + result = String::fromCFString (str); CFRelease (str); str = 0; } @@ -287307,7 +287310,7 @@ namespace CoreMidiHelpers if (str != 0) { - result += PlatformUtilities::cfStringToJuceString (str); + result += String::fromCFString (str); CFRelease (str); str = 0; } @@ -287323,7 +287326,7 @@ namespace CoreMidiHelpers if (str != 0) { - const String s (PlatformUtilities::cfStringToJuceString (str)); + const String s (String::fromCFString (str)); CFRelease (str); // if an external device has only one entity, throw away @@ -287385,7 +287388,7 @@ namespace CoreMidiHelpers if (str != 0) { - s = PlatformUtilities::cfStringToJuceString (str); + s = String::fromCFString (str); CFRelease (str); } } @@ -287422,7 +287425,7 @@ namespace CoreMidiHelpers if (JUCEApplication::getInstance() != nullptr) name = JUCEApplication::getInstance()->getApplicationName(); - CFStringRef appName = PlatformUtilities::juceStringToCFString (name); + CFStringRef appName = name.toCFString(); CHECK_ERROR (MIDIClientCreate (appName, 0, 0, &globalMidiClient)); CFRelease (appName); } @@ -287583,7 +287586,7 @@ MidiOutput* MidiOutput::createNewDevice (const String& deviceName) MIDIClientRef client = CoreMidiHelpers::getGlobalMidiClient(); MIDIEndpointRef endPoint; - CFStringRef name = PlatformUtilities::juceStringToCFString (deviceName); + CFStringRef name = deviceName.toCFString(); if (client != 0 && CHECK_ERROR (MIDISourceCreate (client, name, &endPoint))) { @@ -287737,7 +287740,8 @@ MidiInput* MidiInput::createNewDevice (const String& deviceName, MidiInputCallba mpc->active = false; MIDIEndpointRef endPoint; - CFStringRef name = PlatformUtilities::juceStringToCFString(deviceName); + CFStringRef name = deviceName.toCFString(); + if (CHECK_ERROR (MIDIDestinationCreate (client, name, midiInputProc, mpc, &endPoint))) { mpc->portAndEndpoint = new MidiPortAndEndpoint (0, endPoint); @@ -288785,7 +288789,7 @@ JUCE_JNI_CALLBACK (JuceAppActivity, quitApp, void, (JNIEnv* env, jobject activit android.shutdown(); } -void PlatformUtilities::beep() +void LookAndFeel::playAlertSound() { } @@ -288916,8 +288920,6 @@ SystemStats::CPUFlags::CPUFlags() numCpus = jmax (1, sysconf (_SC_NPROCESSORS_ONLN)); } -void PlatformUtilities::fpuReset() {} - uint32 juce_millisecondsSinceStartup() noexcept { timespec t; @@ -290015,7 +290017,7 @@ bool DirectoryIterator::NativeIterator::next (String& filenameFound, return pimpl->next (filenameFound, isDir, isHidden, fileSize, modTime, creationTime, isReadOnly); } -bool PlatformUtilities::openDocument (const String& fileName, const String& parameters) +bool Process::openDocument (const String& fileName, const String& parameters) { } @@ -290296,13 +290298,12 @@ void MACAddress::findAllAddresses (Array& result) // TODO } -bool PlatformUtilities::launchEmailWithAttachments (const String& targetEmailAddress, - const String& emailSubject, - const String& bodyText, - const StringArray& filesToAttach) +bool Process::openEmailWithAttachments (const String& targetEmailAddress, + const String& emailSubject, + const String& bodyText, + const StringArray& filesToAttach) { // TODO - return false; } diff --git a/juce_amalgamated.h b/juce_amalgamated.h index b7740838f6..50a7a737c8 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 6 +#define JUCE_BUILDNUMBER 7 /** Current Juce version number. @@ -5337,6 +5337,22 @@ public: JUCE_DECLARE_NON_COPYABLE (Concatenator); }; + #if JUCE_MAC || JUCE_IOS || DOXYGEN + + /** MAC ONLY - Creates a String from an OSX CFString. */ + static String fromCFString (CFStringRef cfString); + + /** MAC ONLY - Converts this string to a CFString. + Remember that you must use CFRelease() to free the returned string when you're + finished with it. + */ + CFStringRef toCFString() const; + + /** MAC ONLY - Returns a copy of this string in which any decomposed unicode characters have + been converted to their precomposed equivalents. */ + String convertToPrecomposedUnicode() const; + #endif + private: CharPointerType text; @@ -5654,6 +5670,28 @@ private: #undef TYPE_BOOL // (stupidly-named CoreServices definition which interferes with other libraries). +#if JUCE_MAC || JUCE_IOS || DOXYGEN + + /** A handy C++ wrapper that creates and deletes an NSAutoreleasePool object using RAII. */ + class JUCE_API ScopedAutoReleasePool + { + public: + ScopedAutoReleasePool(); + ~ScopedAutoReleasePool(); + + private: + void* pool; + + JUCE_DECLARE_NON_COPYABLE (ScopedAutoReleasePool); + }; + + /** A macro that can be used to easily declare a local ScopedAutoReleasePool object for RAII-based obj-C autoreleasing. */ + #define JUCE_AUTORELEASEPOOL const JUCE_NAMESPACE::ScopedAutoReleasePool JUCE_JOIN_MACRO (autoReleasePool_, __LINE__); + +#else + #define JUCE_AUTORELEASEPOOL +#endif + END_JUCE_NAMESPACE #endif // __JUCE_STANDARDHEADER_JUCEHEADER__ @@ -13056,6 +13094,20 @@ public: /** Adds a separator character to the end of a path if it doesn't already have one. */ static String addTrailingSeparator (const String& path); + #if JUCE_MAC || JUCE_IOS || DOXYGEN + + /** OSX ONLY - Finds the OSType of a file from the its resources. */ + OSType getMacOSType() const; + + /** OSX ONLY - Returns true if this file is actually a bundle. */ + bool isBundle() const; + #endif + + #if JUCE_MAC || DOXYGEN + /** OSX ONLY - Adds this file to the OSX dock */ + void addToDock() const; + #endif + private: String fullPath; @@ -17538,7 +17590,7 @@ private: Juce calls, to make sure things are initialised correctly. Note that if you're creating a Juce DLL for Windows, you may also need to call the - PlatformUtilities::setCurrentModuleInstanceHandle() method. + Process::setCurrentModuleInstanceHandle() method. @see shutdownJuce_GUI() */ @@ -17606,7 +17658,7 @@ public: int main (int, char* argv[]) \ { \ JUCE_NAMESPACE::JUCEApplication::createInstance = &juce_CreateApplication; \ - return JUCE_NAMESPACE::JUCEApplication::main (JUCE_NAMESPACE::PlatformUtilities::getCurrentCommandLineParams()); \ + return JUCE_NAMESPACE::JUCEApplication::main (JUCE_NAMESPACE::Process::getCurrentCommandLineParams()); \ } #elif ! defined (_AFXDLL) #ifdef _WINDOWS_ @@ -17615,7 +17667,7 @@ public: int WINAPI WinMain (HINSTANCE, HINSTANCE, LPSTR, int) \ { \ JUCE_NAMESPACE::JUCEApplication::createInstance = &juce_CreateApplication; \ - return JUCE_NAMESPACE::JUCEApplication::main (JUCE_NAMESPACE::PlatformUtilities::getCurrentCommandLineParams()); \ + return JUCE_NAMESPACE::JUCEApplication::main (JUCE_NAMESPACE::Process::getCurrentCommandLineParams()); \ } #else #define START_JUCE_APPLICATION(AppClass) \ @@ -17623,7 +17675,7 @@ public: int __stdcall WinMain (int, int, const char*, int) \ { \ JUCE_NAMESPACE::JUCEApplication::createInstance = &juce_CreateApplication; \ - return JUCE_NAMESPACE::JUCEApplication::main (JUCE_NAMESPACE::PlatformUtilities::getCurrentCommandLineParams()); \ + return JUCE_NAMESPACE::JUCEApplication::main (JUCE_NAMESPACE::Process::getCurrentCommandLineParams()); \ } #endif #endif @@ -17724,311 +17776,6 @@ private: #endif #ifndef __JUCE_PLATFORMDEFS_JUCEHEADER__ -#endif -#ifndef __JUCE_PLATFORMUTILITIES_JUCEHEADER__ - -/*** Start of inlined file: juce_PlatformUtilities.h ***/ -#ifndef __JUCE_PLATFORMUTILITIES_JUCEHEADER__ -#define __JUCE_PLATFORMUTILITIES_JUCEHEADER__ - -/** - A collection of miscellaneous platform-specific utilities. - -*/ -class JUCE_API PlatformUtilities -{ -public: - - /** Plays the operating system's default alert 'beep' sound. */ - static void beep(); - - /** Tries to launch the system's default reader for a given file or URL. */ - static bool openDocument (const String& documentURL, const String& parameters); - - /** Tries to launch the system's default email app to let the user create an email. - */ - static bool launchEmailWithAttachments (const String& targetEmailAddress, - const String& emailSubject, - const String& bodyText, - const StringArray& filesToAttach); - -#if JUCE_MAC || JUCE_IOS || DOXYGEN - - /** MAC ONLY - Turns a Core CF String into a juce one. */ - static String cfStringToJuceString (CFStringRef cfString); - - /** MAC ONLY - Turns a juce string into a Core CF one. */ - static CFStringRef juceStringToCFString (const String& s); - - /** MAC ONLY - Turns a file path into an FSRef, returning true if it succeeds. */ - static bool makeFSRefFromPath (FSRef* destFSRef, const String& path); - - /** MAC ONLY - Turns an FSRef into a juce string path. */ - static String makePathFromFSRef (FSRef* file); - - /** MAC ONLY - Converts any decomposed unicode characters in a string into - their precomposed equivalents. - */ - static String convertToPrecomposedUnicode (const String& s); - - /** MAC ONLY - Gets the type of a file from the file's resources. */ - static OSType getTypeOfFile (const String& filename); - - /** MAC ONLY - Returns true if this file is actually a bundle. */ - static bool isBundle (const String& filename); - - /** MAC ONLY - Adds an item to the dock */ - static void addItemToDock (const File& file); - - /** MAC ONLY - Returns the current OS version number. - E.g. if it's running on 10.4, this will be 4, 10.5 will return 5, etc. - */ - static int getOSXMinorVersionNumber(); -#endif - -#if JUCE_WINDOWS || DOXYGEN - - // Some registry helper functions: - - /** WIN32 ONLY - Returns a string from the registry. - - The path is a string for the entire path of a value in the registry, - e.g. "HKEY_CURRENT_USER\Software\foo\bar" - */ - static String getRegistryValue (const String& regValuePath, - const String& defaultValue = String::empty); - - /** WIN32 ONLY - Sets a registry value as a string. - - This will take care of creating any groups needed to get to the given - registry value. - */ - static void setRegistryValue (const String& regValuePath, - const String& value); - - /** WIN32 ONLY - Returns true if the given value exists in the registry. */ - static bool registryValueExists (const String& regValuePath); - - /** WIN32 ONLY - Deletes a registry value. */ - static void deleteRegistryValue (const String& regValuePath); - - /** WIN32 ONLY - Deletes a registry key (which is registry-talk for 'folder'). */ - static void deleteRegistryKey (const String& regKeyPath); - - /** WIN32 ONLY - Creates a file association in the registry. - - This lets you set the exe that should be launched by a given file extension. - @param fileExtension the file extension to associate, including the - initial dot, e.g. ".txt" - @param symbolicDescription a space-free short token to identify the file type - @param fullDescription a human-readable description of the file type - @param targetExecutable the executable that should be launched - @param iconResourceNumber the icon that gets displayed for the file type will be - found by looking up this resource number in the - executable. Pass 0 here to not use an icon - */ - static void registerFileAssociation (const String& fileExtension, - const String& symbolicDescription, - const String& fullDescription, - const File& targetExecutable, - int iconResourceNumber); - - /** WIN32 ONLY - This returns the HINSTANCE of the current module. - - In a normal Juce application this will be set to the module handle - of the application executable. - - If you're writing a DLL using Juce and plan to use any Juce messaging or - windows, you'll need to make sure you use the setCurrentModuleInstanceHandle() - to set the correct module handle in your DllMain() function, because - the win32 system relies on the correct instance handle when opening windows. - */ - static void* JUCE_CALLTYPE getCurrentModuleInstanceHandle() noexcept; - - /** WIN32 ONLY - Sets a new module handle to be used by the library. - - @see getCurrentModuleInstanceHandle() - */ - static void JUCE_CALLTYPE setCurrentModuleInstanceHandle (void* newHandle) noexcept; - - /** WIN32 ONLY - Gets the command-line params as a string. - - This is needed to avoid unicode problems with the argc type params. - */ - static String JUCE_CALLTYPE getCurrentCommandLineParams(); -#endif - - /** Clears the floating point unit's flags. - - Only has an effect under win32, currently. - */ - static void fpuReset(); - -#if JUCE_LINUX || JUCE_WINDOWS - - /** Loads a dynamically-linked library into the process's address space. - - @param pathOrFilename the platform-dependent name and search path - @returns a handle which can be used by getProcedureEntryPoint(), or - zero if it fails. - @see freeDynamicLibrary, getProcedureEntryPoint - */ - static void* loadDynamicLibrary (const String& pathOrFilename); - - /** Frees a dynamically-linked library. - - @param libraryHandle a handle created by loadDynamicLibrary - @see loadDynamicLibrary, getProcedureEntryPoint - */ - static void freeDynamicLibrary (void* libraryHandle); - - /** Finds a procedure call in a dynamically-linked library. - - @param libraryHandle a library handle returned by loadDynamicLibrary - @param procedureName the name of the procedure call to try to load - @returns a pointer to the function if found, or 0 if it fails - @see loadDynamicLibrary - */ - static void* getProcedureEntryPoint (void* libraryHandle, - const String& procedureName); -#endif - -private: - PlatformUtilities(); - - JUCE_DECLARE_NON_COPYABLE (PlatformUtilities); -}; - -#if JUCE_MAC || JUCE_IOS || DOXYGEN - - /** A handy C++ wrapper that creates and deletes an NSAutoreleasePool object using RAII. */ - class JUCE_API ScopedAutoReleasePool - { - public: - ScopedAutoReleasePool(); - ~ScopedAutoReleasePool(); - - private: - void* pool; - - JUCE_DECLARE_NON_COPYABLE (ScopedAutoReleasePool); - }; - - /** A macro that can be used to easily declare a local ScopedAutoReleasePool object for RAII-based obj-C autoreleasing. */ - #define JUCE_AUTORELEASEPOOL const JUCE_NAMESPACE::ScopedAutoReleasePool JUCE_JOIN_MACRO (autoReleasePool_, __LINE__); - -#else - #define JUCE_AUTORELEASEPOOL -#endif - -#if JUCE_LINUX - -/** A handy class that uses XLockDisplay and XUnlockDisplay to lock the X server - using an RAII approach. -*/ -class ScopedXLock -{ -public: - /** Creating a ScopedXLock object locks the X display. - This uses XLockDisplay() to grab the display that Juce is using. - */ - ScopedXLock(); - - /** Deleting a ScopedXLock object unlocks the X display. - This calls XUnlockDisplay() to release the lock. - */ - ~ScopedXLock(); -}; - -#endif - -#if JUCE_MAC - -/** - A wrapper class for picking up events from an Apple IR remote control device. - - To use it, just create a subclass of this class, implementing the buttonPressed() - callback, then call start() and stop() to start or stop receiving events. -*/ -class JUCE_API AppleRemoteDevice -{ -public: - - AppleRemoteDevice(); - virtual ~AppleRemoteDevice(); - - /** The set of buttons that may be pressed. - @see buttonPressed - */ - enum ButtonType - { - menuButton = 0, /**< The menu button (if it's held for a short time). */ - playButton, /**< The play button. */ - plusButton, /**< The plus or volume-up button. */ - minusButton, /**< The minus or volume-down button. */ - rightButton, /**< The right button (if it's held for a short time). */ - leftButton, /**< The left button (if it's held for a short time). */ - rightButton_Long, /**< The right button (if it's held for a long time). */ - leftButton_Long, /**< The menu button (if it's held for a long time). */ - menuButton_Long, /**< The menu button (if it's held for a long time). */ - playButtonSleepMode, - switched - }; - - /** Override this method to receive the callback about a button press. - - The callback will happen on the application's message thread. - - Some buttons trigger matching up and down events, in which the isDown parameter - will be true and then false. Others only send a single event when the - button is pressed. - */ - virtual void buttonPressed (ButtonType buttonId, bool isDown) = 0; - - /** Starts the device running and responding to events. - - Returns true if it managed to open the device. - - @param inExclusiveMode if true, the remote will be grabbed exclusively for this app, - and will not be available to any other part of the system. If - false, it will be shared with other apps. - @see stop - */ - bool start (bool inExclusiveMode); - - /** Stops the device running. - @see start - */ - void stop(); - - /** Returns true if the device has been started successfully. - */ - bool isActive() const; - - /** Returns the ID number of the remote, if it has sent one. - */ - int getRemoteId() const { return remoteId; } - - /** @internal */ - void handleCallbackInternal(); - -private: - void* device; - void* queue; - int remoteId; - - bool open (bool openInExclusiveMode); - - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AppleRemoteDevice); -}; - -#endif - -#endif // __JUCE_PLATFORMUTILITIES_JUCEHEADER__ - -/*** End of inlined file: juce_PlatformUtilities.h ***/ - - #endif #ifndef __JUCE_RELATIVETIME_JUCEHEADER__ @@ -18361,6 +18108,13 @@ public: */ static bool isOperatingSystem64Bit(); + #if JUCE_MAC || DOXYGEN + /** OSX ONLY - Returns the current OS version number. + E.g. if it's running on 10.4, this will be 4, 10.5 will return 5, etc. + */ + static int getOSXMinorVersionNumber(); + #endif + /** Returns the current user's name, if available. @see getFullUserName() */ @@ -22408,6 +22162,70 @@ private: #endif #ifndef __JUCE_CRITICALSECTION_JUCEHEADER__ +#endif +#ifndef __JUCE_DYNAMICLIBRARY_JUCEHEADER__ + +/*** Start of inlined file: juce_DynamicLibrary.h ***/ +#ifndef __JUCE_DYNAMICLIBRARY_JUCEHEADER__ +#define __JUCE_DYNAMICLIBRARY_JUCEHEADER__ + +/** + Handles the opening and closing of DLLs. + + This class can be used to open a DLL and get some function pointers from it. + Since the DLL is freed when this object is deleted, it's handy for managing + library lifetimes using RAII. +*/ +class DynamicLibrary +{ +public: + /** Creates an unopened DynamicLibrary object. + Call open() to actually open one. + */ + DynamicLibrary() noexcept : handle (nullptr) {} + + /** + */ + DynamicLibrary (const String& name) : handle (nullptr) { open (name); } + + /** Destructor. + If a library is currently open, it will be closed when this object is destroyed. + */ + ~DynamicLibrary() { close(); } + + /** Opens a DLL. + The name and the method by which it gets found is of course platform-specific, and + may or may not include a path, depending on the OS. + If a library is already open when this method is called, it will first close the library + before attempting to load the new one. + @returns true if the library was successfully found and opened. + */ + bool open (const String& name); + + /** Releases the currently-open DLL, or has no effect if none was open. */ + void close() noexcept; + + /** 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. + */ + void* getFunction (const String& functionName) noexcept; + + /** Returns the platform-specific native library handle. + You'll need to cast this to whatever is appropriate for the OS that's in use. + */ + void* getNativeHandle() const noexcept { return handle; } + +private: + void* handle; + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DynamicLibrary); +}; + +#endif // __JUCE_DYNAMICLIBRARY_JUCEHEADER__ + +/*** End of inlined file: juce_DynamicLibrary.h ***/ + + #endif #ifndef __JUCE_INTERPROCESSLOCK_JUCEHEADER__ @@ -22581,9 +22399,49 @@ public: */ static bool JUCE_CALLTYPE isRunningUnderDebugger(); + /** Tries to launch the OS's default reader application for a given file or URL. */ + static bool openDocument (const String& documentURL, const String& parameters); + + /** Tries to launch the OS's default email application to let the user create a message. */ + static bool openEmailWithAttachments (const String& targetEmailAddress, + const String& emailSubject, + const String& bodyText, + const StringArray& filesToAttach); + + #if JUCE_WINDOWS || DOXYGEN + + /** WINDOWS ONLY - This returns the HINSTANCE of the current module. + + The return type is a void* to avoid being dependent on windows.h - just cast + it to a HINSTANCE to use it. + + In a normal JUCE application, this will be automatically set to the module + handle of the executable. + + If you've built a DLL and plan to use any JUCE messaging or windowing classes, + you'll need to make sure you call the setCurrentModuleInstanceHandle() + to provide the correct module handle in your DllMain() function, because + the system relies on the correct instance handle when opening windows. + */ + static void* JUCE_CALLTYPE getCurrentModuleInstanceHandle() noexcept; + + /** WINDOWS ONLY - Sets a new module handle to be used by the library. + + The parameter type is a void* to avoid being dependent on windows.h, but it actually + expects a HINSTANCE value. + + @see getCurrentModuleInstanceHandle() + */ + static void JUCE_CALLTYPE setCurrentModuleInstanceHandle (void* newHandle) noexcept; + + /** WINDOWS ONLY - Gets the command-line params as a string. + This is needed to avoid unicode problems with the argc type params. + */ + static String JUCE_CALLTYPE getCurrentCommandLineParams(); + #endif + private: Process(); - JUCE_DECLARE_NON_COPYABLE (Process); }; @@ -47971,6 +47829,98 @@ private: #endif #ifndef __JUCE_ACTIONLISTENER_JUCEHEADER__ +#endif +#ifndef __JUCE_APPLEREMOTE_JUCEHEADER__ + +/*** Start of inlined file: juce_AppleRemote.h ***/ +#ifndef __JUCE_APPLEREMOTE_JUCEHEADER__ +#define __JUCE_APPLEREMOTE_JUCEHEADER__ + +#if JUCE_MAC || DOXYGEN +/** + Receives events from an Apple IR remote control device (Only available in OSX!). + + To use it, just create a subclass of this class, implementing the buttonPressed() + callback, then call start() and stop() to start or stop receiving events. +*/ +class JUCE_API AppleRemoteDevice +{ +public: + + AppleRemoteDevice(); + virtual ~AppleRemoteDevice(); + + /** The set of buttons that may be pressed. + @see buttonPressed + */ + enum ButtonType + { + menuButton = 0, /**< The menu button (if it's held for a short time). */ + playButton, /**< The play button. */ + plusButton, /**< The plus or volume-up button. */ + minusButton, /**< The minus or volume-down button. */ + rightButton, /**< The right button (if it's held for a short time). */ + leftButton, /**< The left button (if it's held for a short time). */ + rightButton_Long, /**< The right button (if it's held for a long time). */ + leftButton_Long, /**< The menu button (if it's held for a long time). */ + menuButton_Long, /**< The menu button (if it's held for a long time). */ + playButtonSleepMode, + switched + }; + + /** Override this method to receive the callback about a button press. + + The callback will happen on the application's message thread. + + Some buttons trigger matching up and down events, in which the isDown parameter + will be true and then false. Others only send a single event when the + button is pressed. + */ + virtual void buttonPressed (ButtonType buttonId, bool isDown) = 0; + + /** Starts the device running and responding to events. + + Returns true if it managed to open the device. + + @param inExclusiveMode if true, the remote will be grabbed exclusively for this app, + and will not be available to any other part of the system. If + false, it will be shared with other apps. + @see stop + */ + bool start (bool inExclusiveMode); + + /** Stops the device running. + @see start + */ + void stop(); + + /** Returns true if the device has been started successfully. + */ + bool isActive() const; + + /** Returns the ID number of the remote, if it has sent one. + */ + int getRemoteId() const { return remoteId; } + + /** @internal */ + void handleCallbackInternal(); + +private: + void* device; + void* queue; + int remoteId; + + bool open (bool openInExclusiveMode); + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AppleRemoteDevice); +}; + +#endif +#endif // __JUCE_APPLEREMOTE_JUCEHEADER__ + +/*** End of inlined file: juce_AppleRemote.h ***/ + + #endif #ifndef __JUCE_ASYNCUPDATER_JUCEHEADER__ @@ -62029,7 +61979,7 @@ public: virtual void drawKeymapChangeButton (Graphics& g, int width, int height, Button& button, const String& keyDescription); - /** + /** Plays the system's default 'beep' noise, to alert the user about something very important. */ virtual void playAlertSound(); @@ -65660,6 +65610,38 @@ private: /*** End of inlined file: juce_QuickTimeMovieComponent.h ***/ +#endif +#ifndef __JUCE_SCOPEDXLOCK_JUCEHEADER__ + +/*** Start of inlined file: juce_ScopedXLock.h ***/ +#ifndef __JUCE_SCOPEDXLOCK_JUCEHEADER__ +#define __JUCE_SCOPEDXLOCK_JUCEHEADER__ + +#if JUCE_LINUX || DOXYGEN + +/** A handy class that uses XLockDisplay and XUnlockDisplay to lock the X server + using RAII (Only available in Linux!). +*/ +class ScopedXLock +{ +public: + /** Creating a ScopedXLock object locks the X display. + This uses XLockDisplay() to grab the display that Juce is using. + */ + ScopedXLock(); + + /** Deleting a ScopedXLock object unlocks the X display. + This calls XUnlockDisplay() to release the lock. + */ + ~ScopedXLock(); +}; + +#endif +#endif // __JUCE_SCOPEDXLOCK_JUCEHEADER__ + +/*** End of inlined file: juce_ScopedXLock.h ***/ + + #endif #ifndef __JUCE_SYSTEMTRAYICONCOMPONENT_JUCEHEADER__ @@ -69670,6 +69652,76 @@ private: /*** End of inlined file: juce_UnitTest.h ***/ +#endif +#ifndef __JUCE_WINDOWSREGISTRY_JUCEHEADER__ + +/*** Start of inlined file: juce_WindowsRegistry.h ***/ +#ifndef __JUCE_WINDOWSREGISTRY_JUCEHEADER__ +#define __JUCE_WINDOWSREGISTRY_JUCEHEADER__ + +#if JUCE_WINDOWS || DOXYGEN + +/** + Contains some static helper functions for manipulating the MS Windows registry + (Only available on Windows, of course!) +*/ +class WindowsRegistry +{ + + /** Returns a string from the registry. + + The path is a string for the entire path of a value in the registry, + e.g. "HKEY_CURRENT_USER\Software\foo\bar" + */ + static String getValue (const String& regValuePath, + const String& defaultValue = String::empty); + + /** Sets a registry value as a string. + + This will take care of creating any groups needed to get to the given + registry value. + */ + static void setValue (const String& regValuePath, + const String& value); + + /** Returns true if the given value exists in the registry. */ + static bool valueExists (const String& regValuePath); + + /** Deletes a registry value. */ + static void deleteValue (const String& regValuePath); + + /** Deletes a registry key (which is registry-talk for 'folder'). */ + static void deleteKey (const String& regKeyPath); + + /** Creates a file association in the registry. + + This lets you set the executable that should be launched by a given file extension. + @param fileExtension the file extension to associate, including the + initial dot, e.g. ".txt" + @param symbolicDescription a space-free short token to identify the file type + @param fullDescription a human-readable description of the file type + @param targetExecutable the executable that should be launched + @param iconResourceNumber the icon that gets displayed for the file type will be + found by looking up this resource number in the + executable. Pass 0 here to not use an icon + */ + static void registerFileAssociation (const String& fileExtension, + const String& symbolicDescription, + const String& fullDescription, + const File& targetExecutable, + int iconResourceNumber); + +private: + WindowsRegistry(); + JUCE_DECLARE_NON_COPYABLE (WindowsRegistry); +}; + +#endif +#endif // __JUCE_WINDOWSREGISTRY_JUCEHEADER__ + +/*** End of inlined file: juce_WindowsRegistry.h ***/ + + #endif #endif diff --git a/src/application/juce_Application.cpp b/src/application/juce_Application.cpp index 1b704041f0..832ed432f9 100644 --- a/src/application/juce_Application.cpp +++ b/src/application/juce_Application.cpp @@ -31,7 +31,6 @@ BEGIN_JUCE_NAMESPACE #include "../events/juce_MessageManager.h" #include "../core/juce_Initialisation.h" #include "../threads/juce_Process.h" -#include "../core/juce_PlatformUtilities.h" #include "../text/juce_LocalisedStrings.h" #if JUCE_MAC diff --git a/src/audio/audio_file_formats/juce_AiffAudioFormat.cpp b/src/audio/audio_file_formats/juce_AiffAudioFormat.cpp index b8ccdbecb4..38042c0ddf 100644 --- a/src/audio/audio_file_formats/juce_AiffAudioFormat.cpp +++ b/src/audio/audio_file_formats/juce_AiffAudioFormat.cpp @@ -30,7 +30,6 @@ BEGIN_JUCE_NAMESPACE #include "juce_AiffAudioFormat.h" #include "../../io/streams/juce_BufferedInputStream.h" #include "../../io/streams/juce_MemoryOutputStream.h" -#include "../../core/juce_PlatformUtilities.h" #include "../../text/juce_LocalisedStrings.h" @@ -700,7 +699,7 @@ bool AiffAudioFormat::canHandleFile (const File& f) if (AudioFormat::canHandleFile (f)) return true; - const OSType type = PlatformUtilities::getTypeOfFile (f.getFullPathName()); + const OSType type = f.getMacOSType(); return type == 'AIFF' || type == 'AIFC' || type == 'aiff' || type == 'aifc'; } diff --git a/src/audio/audio_file_formats/juce_QuickTimeAudioFormat.cpp b/src/audio/audio_file_formats/juce_QuickTimeAudioFormat.cpp index 8131b5cb0e..1473af2690 100644 --- a/src/audio/audio_file_formats/juce_QuickTimeAudioFormat.cpp +++ b/src/audio/audio_file_formats/juce_QuickTimeAudioFormat.cpp @@ -66,7 +66,6 @@ BEGIN_JUCE_NAMESPACE #include "../../threads/juce_Thread.h" #include "../../io/network/juce_URL.h" #include "../../memory/juce_ScopedPointer.h" -#include "../../core/juce_PlatformUtilities.h" bool juce_OpenQuickTimeMovieFromStream (InputStream* input, Movie& movie, Handle& dataHandle); diff --git a/src/audio/plugin_client/AU/juce_AU_Wrapper.mm b/src/audio/plugin_client/AU/juce_AU_Wrapper.mm index 37f00bb224..9680f7012e 100644 --- a/src/audio/plugin_client/AU/juce_AU_Wrapper.mm +++ b/src/audio/plugin_client/AU/juce_AU_Wrapper.mm @@ -208,7 +208,7 @@ public: { #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5 // (On 10.4, there's a random obj-c dispatching crash when trying to load a cocoa UI) - if (PlatformUtilities::getOSXMinorVersionNumber() > 4) + if (SystemStats::getOSXMinorVersionNumber() > 4) #endif { outDataSize = sizeof (AudioUnitCocoaViewInfo); @@ -246,10 +246,10 @@ public: } else if (inID == kAudioUnitProperty_CocoaUI) { - #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5 + #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5 // (On 10.4, there's a random obj-c dispatching crash when trying to load a cocoa UI) - if (PlatformUtilities::getOSXMinorVersionNumber() > 4) - #endif + if (SystemStats::getOSXMinorVersionNumber() > 4) + #endif { JUCE_AUTORELEASEPOOL @@ -390,9 +390,7 @@ public: if (juceFilter->isMetaParameter (index)) outParameterInfo.flags |= kAudioUnitParameterFlag_IsGlobalMeta; - AUBase::FillInParameterName (outParameterInfo, - PlatformUtilities::juceStringToCFString (name), - false); + AUBase::FillInParameterName (outParameterInfo, name.toCFString(), false); outParameterInfo.minValue = 0.0f; outParameterInfo.maxValue = 1.0f; @@ -869,7 +867,7 @@ protected: for (int i = 0; i < numPrograms; ++i) { presets[i].presetNumber = i; - presets[i].presetName = PlatformUtilities::juceStringToCFString (juceFilter->getProgramName (i)); + presets[i].presetName = juceFilter->getProgramName(i).toCFString(); CFArrayAppendValue (presetsArray, presets + i); } @@ -890,7 +888,7 @@ protected: AUPreset chosenPreset; chosenPreset.presetNumber = chosenPresetNumber; - chosenPreset.presetName = PlatformUtilities::juceStringToCFString (juceFilter->getProgramName (chosenPresetNumber)); + chosenPreset.presetName = juceFilter->getProgramName (chosenPresetNumber).toCFString(); juceFilter->setCurrentProgram (chosenPresetNumber); SetAFactoryPresetAsCurrent (chosenPreset); diff --git a/src/audio/plugin_client/RTAS/juce_RTAS_Wrapper.cpp b/src/audio/plugin_client/RTAS/juce_RTAS_Wrapper.cpp index b222ab2a2b..48d8657a94 100644 --- a/src/audio/plugin_client/RTAS/juce_RTAS_Wrapper.cpp +++ b/src/audio/plugin_client/RTAS/juce_RTAS_Wrapper.cpp @@ -941,7 +941,7 @@ private: static CEffectProcess* createNewProcess() { #if JUCE_WINDOWS - PlatformUtilities::setCurrentModuleInstanceHandle (gThisModule); + Process::setCurrentModuleInstanceHandle (gThisModule); #endif initialiseJuce_GUI(); diff --git a/src/audio/plugin_client/VST/juce_VST_Wrapper.cpp b/src/audio/plugin_client/VST/juce_VST_Wrapper.cpp index c6f9cee362..0c0c76bfac 100644 --- a/src/audio/plugin_client/VST/juce_VST_Wrapper.cpp +++ b/src/audio/plugin_client/VST/juce_VST_Wrapper.cpp @@ -229,7 +229,7 @@ namespace { if (mouseHookUsers++ == 0) mouseWheelHook = SetWindowsHookEx (WH_MOUSE, mouseWheelHookCallback, - (HINSTANCE) PlatformUtilities::getCurrentModuleInstanceHandle(), + (HINSTANCE) Process::getCurrentModuleInstanceHandle(), GetCurrentThreadId()); } @@ -1519,7 +1519,7 @@ namespace #endif { if (dwReason == DLL_PROCESS_ATTACH) - PlatformUtilities::setCurrentModuleInstanceHandle (instance); + Process::setCurrentModuleInstanceHandle (instance); return TRUE; } diff --git a/src/audio/plugin_host/formats/juce_AudioUnitPluginFormat.mm b/src/audio/plugin_host/formats/juce_AudioUnitPluginFormat.mm index a556cc7690..41ec92e853 100644 --- a/src/audio/plugin_host/formats/juce_AudioUnitPluginFormat.mm +++ b/src/audio/plugin_host/formats/juce_AudioUnitPluginFormat.mm @@ -45,7 +45,6 @@ BEGIN_JUCE_NAMESPACE #include "../juce_PluginDescription.h" #include "../../../threads/juce_CriticalSection.h" #include "../../../events/juce_Timer.h" -#include "../../../core/juce_PlatformUtilities.h" #include "../../../gui/components/layout/juce_ComponentMovementWatcher.h" #include "../../../gui/components/windows/juce_ComponentPeer.h" #include "../../../gui/components/special/juce_NSViewComponent.h" @@ -480,7 +479,7 @@ bool AudioUnitPluginInstance::getComponentDescFromFile (const String& fileOrIden CFTypeRef name = CFBundleGetValueForInfoDictionaryKey (bundleRef, CFSTR("CFBundleName")); if (name != 0 && CFGetTypeID (name) == CFStringGetTypeID()) - pluginName = PlatformUtilities::cfStringToJuceString ((CFStringRef) name); + pluginName = String::fromCFString ((CFStringRef) name); if (pluginName.isEmpty()) pluginName = file.getFileNameWithoutExtension(); @@ -488,12 +487,12 @@ bool AudioUnitPluginInstance::getComponentDescFromFile (const String& fileOrIden CFTypeRef versionString = CFBundleGetValueForInfoDictionaryKey (bundleRef, CFSTR("CFBundleVersion")); if (versionString != 0 && CFGetTypeID (versionString) == CFStringGetTypeID()) - version = PlatformUtilities::cfStringToJuceString ((CFStringRef) versionString); + version = String::fromCFString ((CFStringRef) versionString); CFTypeRef manuString = CFBundleGetValueForInfoDictionaryKey (bundleRef, CFSTR("CFBundleGetInfoString")); if (manuString != 0 && CFGetTypeID (manuString) == CFStringGetTypeID()) - manufacturer = PlatformUtilities::cfStringToJuceString ((CFStringRef) manuString); + manufacturer = String::fromCFString ((CFStringRef) manuString); short resFileId = CFBundleOpenBundleResourceMap (bundleRef); UseResFile (resFileId); @@ -1237,7 +1236,7 @@ const String AudioUnitPluginInstance::getParameterName (int index) parameterIds [index], &info, &sz) == noErr) { if ((info.flags & kAudioUnitParameterFlag_HasCFNameString) != 0) - name = PlatformUtilities::cfStringToJuceString (info.cfNameString); + name = String::fromCFString (info.cfNameString); else name = String (info.name, sizeof (info.name)); } @@ -1328,7 +1327,7 @@ const String AudioUnitPluginInstance::getProgramName (int index) if (p != nullptr && p->presetNumber == index) { - s = PlatformUtilities::cfStringToJuceString (p->presetName); + s = String::fromCFString (p->presetName); break; } } diff --git a/src/audio/plugin_host/formats/juce_VSTPluginFormat.cpp b/src/audio/plugin_host/formats/juce_VSTPluginFormat.cpp index 9a3d026aa0..123de311a3 100644 --- a/src/audio/plugin_host/formats/juce_VSTPluginFormat.cpp +++ b/src/audio/plugin_host/formats/juce_VSTPluginFormat.cpp @@ -52,6 +52,11 @@ #else #include #include + + static bool makeFSRefFromPath (FSRef* destFSRef, const String& path) + { + return FSPathMakeRef (reinterpret_cast (path.toUTF8().getAddress()), destFSRef, 0) == noErr; + } #endif //============================================================================== @@ -64,6 +69,7 @@ BEGIN_JUCE_NAMESPACE #include "juce_VSTPluginFormat.h" #include "../../../threads/juce_Process.h" #include "../../../threads/juce_CriticalSection.h" +#include "../../../threads/juce_DynamicLibrary.h" #include "../../../maths/juce_Random.h" #include "../../../io/files/juce_DirectoryIterator.h" #include "../../../events/juce_Timer.h" @@ -72,7 +78,6 @@ BEGIN_JUCE_NAMESPACE #include "../../../gui/components/layout/juce_ComponentMovementWatcher.h" #include "../../../gui/components/windows/juce_ComponentPeer.h" #include "../../../application/juce_Application.h" -#include "../../../core/juce_PlatformUtilities.h" #if JUCE_MAC && JUCE_SUPPORT_CARBON #include "../../../native/mac/juce_mac_CarbonViewWrapperComponent.h" @@ -423,11 +428,9 @@ public: //============================================================================== ModuleHandle (const File& file_) : file (file_), - moduleMain (0), - #if JUCE_WINDOWS || JUCE_LINUX - hModule (0) - #elif JUCE_MAC - fragId (0), resHandle (0), bundleRef (0), resFileId (0) + moduleMain (0) + #if JUCE_MAC + , fragId (0), resHandle (0), bundleRef (0), resFileId (0) #endif { getActiveModules().add (this); @@ -436,7 +439,7 @@ public: fullParentDirectoryPathName = file_.getParentDirectory().getFullPathName(); #elif JUCE_MAC FSRef ref; - PlatformUtilities::makeFSRefFromPath (&ref, file_.getParentDirectory().getFullPathName()); + makeFSRefFromPath (&ref, file_.getParentDirectory().getFullPathName()); FSGetCatalogInfo (&ref, kFSCatInfoNone, 0, 0, &parentDirFSSpec, 0); #endif } @@ -449,7 +452,7 @@ public: //============================================================================== #if JUCE_WINDOWS || JUCE_LINUX - void* hModule; + DynamicLibrary module; String fullParentDirectoryPathName; bool open() @@ -466,21 +469,21 @@ public: pluginName = file.getFileNameWithoutExtension(); - hModule = PlatformUtilities::loadDynamicLibrary (file.getFullPathName()); + module.open (file.getFullPathName()); - moduleMain = (MainCall) PlatformUtilities::getProcedureEntryPoint (hModule, "VSTPluginMain"); + moduleMain = (MainCall) module.getFunction ("VSTPluginMain"); - if (moduleMain == 0) - moduleMain = (MainCall) PlatformUtilities::getProcedureEntryPoint (hModule, "main"); + if (moduleMain == nullptr) + moduleMain = (MainCall) module.getFunction ("main"); - return moduleMain != 0; + return moduleMain != nullptr; } void close() { _fpreset(); // (doesn't do any harm) - PlatformUtilities::freeDynamicLibrary (hModule); + module.close(); } void closeEffect (AEffect* eff) @@ -2854,7 +2857,7 @@ bool VSTPluginFormat::fileMightContainThisPluginType (const String& fileOrIdenti #if JUCE_PPC FSRef fileRef; - if (PlatformUtilities::makeFSRefFromPath (&fileRef, f.getFullPathName())) + if (makeFSRefFromPath (&fileRef, f.getFullPathName())) { const short resFileId = FSOpenResFile (&fileRef, fsRdPerm); diff --git a/src/core/juce_Initialisation.cpp b/src/core/juce_Initialisation.cpp index 8696ba6604..c899e4f12e 100644 --- a/src/core/juce_Initialisation.cpp +++ b/src/core/juce_Initialisation.cpp @@ -27,7 +27,6 @@ BEGIN_JUCE_NAMESPACE -#include "juce_PlatformUtilities.h" #include "../utilities/juce_DeletedAtShutdown.h" #if ! JUCE_ONLY_BUILD_CORE_LIBRARY diff --git a/src/core/juce_Initialisation.h b/src/core/juce_Initialisation.h index ac8826222d..909fbe19b4 100644 --- a/src/core/juce_Initialisation.h +++ b/src/core/juce_Initialisation.h @@ -35,7 +35,7 @@ Juce calls, to make sure things are initialised correctly. Note that if you're creating a Juce DLL for Windows, you may also need to call the - PlatformUtilities::setCurrentModuleInstanceHandle() method. + Process::setCurrentModuleInstanceHandle() method. @see shutdownJuce_GUI() */ @@ -107,7 +107,7 @@ public: int main (int, char* argv[]) \ { \ JUCE_NAMESPACE::JUCEApplication::createInstance = &juce_CreateApplication; \ - return JUCE_NAMESPACE::JUCEApplication::main (JUCE_NAMESPACE::PlatformUtilities::getCurrentCommandLineParams()); \ + return JUCE_NAMESPACE::JUCEApplication::main (JUCE_NAMESPACE::Process::getCurrentCommandLineParams()); \ } #elif ! defined (_AFXDLL) #ifdef _WINDOWS_ @@ -116,7 +116,7 @@ public: int WINAPI WinMain (HINSTANCE, HINSTANCE, LPSTR, int) \ { \ JUCE_NAMESPACE::JUCEApplication::createInstance = &juce_CreateApplication; \ - return JUCE_NAMESPACE::JUCEApplication::main (JUCE_NAMESPACE::PlatformUtilities::getCurrentCommandLineParams()); \ + return JUCE_NAMESPACE::JUCEApplication::main (JUCE_NAMESPACE::Process::getCurrentCommandLineParams()); \ } #else #define START_JUCE_APPLICATION(AppClass) \ @@ -124,7 +124,7 @@ public: int __stdcall WinMain (int, int, const char*, int) \ { \ JUCE_NAMESPACE::JUCEApplication::createInstance = &juce_CreateApplication; \ - return JUCE_NAMESPACE::JUCEApplication::main (JUCE_NAMESPACE::PlatformUtilities::getCurrentCommandLineParams()); \ + return JUCE_NAMESPACE::JUCEApplication::main (JUCE_NAMESPACE::Process::getCurrentCommandLineParams()); \ } #endif #endif diff --git a/src/core/juce_PlatformUtilities.h b/src/core/juce_PlatformUtilities.h deleted file mode 100644 index ad074e57d6..0000000000 --- a/src/core/juce_PlatformUtilities.h +++ /dev/null @@ -1,340 +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_PLATFORMUTILITIES_JUCEHEADER__ -#define __JUCE_PLATFORMUTILITIES_JUCEHEADER__ - -#include "../text/juce_StringArray.h" -#include "../io/files/juce_File.h" - - -//============================================================================== -/** - A collection of miscellaneous platform-specific utilities. - -*/ -class JUCE_API PlatformUtilities -{ -public: - //============================================================================== - /** Plays the operating system's default alert 'beep' sound. */ - static void beep(); - - /** Tries to launch the system's default reader for a given file or URL. */ - static bool openDocument (const String& documentURL, const String& parameters); - - /** Tries to launch the system's default email app to let the user create an email. - */ - static bool launchEmailWithAttachments (const String& targetEmailAddress, - const String& emailSubject, - const String& bodyText, - const StringArray& filesToAttach); - -#if JUCE_MAC || JUCE_IOS || DOXYGEN - //============================================================================== - /** MAC ONLY - Turns a Core CF String into a juce one. */ - static String cfStringToJuceString (CFStringRef cfString); - - /** MAC ONLY - Turns a juce string into a Core CF one. */ - static CFStringRef juceStringToCFString (const String& s); - - /** MAC ONLY - Turns a file path into an FSRef, returning true if it succeeds. */ - static bool makeFSRefFromPath (FSRef* destFSRef, const String& path); - - /** MAC ONLY - Turns an FSRef into a juce string path. */ - static String makePathFromFSRef (FSRef* file); - - /** MAC ONLY - Converts any decomposed unicode characters in a string into - their precomposed equivalents. - */ - static String convertToPrecomposedUnicode (const String& s); - - /** MAC ONLY - Gets the type of a file from the file's resources. */ - static OSType getTypeOfFile (const String& filename); - - /** MAC ONLY - Returns true if this file is actually a bundle. */ - static bool isBundle (const String& filename); - - /** MAC ONLY - Adds an item to the dock */ - static void addItemToDock (const File& file); - - /** MAC ONLY - Returns the current OS version number. - E.g. if it's running on 10.4, this will be 4, 10.5 will return 5, etc. - */ - static int getOSXMinorVersionNumber(); -#endif - - -#if JUCE_WINDOWS || DOXYGEN - //============================================================================== - // Some registry helper functions: - - /** WIN32 ONLY - Returns a string from the registry. - - The path is a string for the entire path of a value in the registry, - e.g. "HKEY_CURRENT_USER\Software\foo\bar" - */ - static String getRegistryValue (const String& regValuePath, - const String& defaultValue = String::empty); - - /** WIN32 ONLY - Sets a registry value as a string. - - This will take care of creating any groups needed to get to the given - registry value. - */ - static void setRegistryValue (const String& regValuePath, - const String& value); - - /** WIN32 ONLY - Returns true if the given value exists in the registry. */ - static bool registryValueExists (const String& regValuePath); - - /** WIN32 ONLY - Deletes a registry value. */ - static void deleteRegistryValue (const String& regValuePath); - - /** WIN32 ONLY - Deletes a registry key (which is registry-talk for 'folder'). */ - static void deleteRegistryKey (const String& regKeyPath); - - /** WIN32 ONLY - Creates a file association in the registry. - - This lets you set the exe that should be launched by a given file extension. - @param fileExtension the file extension to associate, including the - initial dot, e.g. ".txt" - @param symbolicDescription a space-free short token to identify the file type - @param fullDescription a human-readable description of the file type - @param targetExecutable the executable that should be launched - @param iconResourceNumber the icon that gets displayed for the file type will be - found by looking up this resource number in the - executable. Pass 0 here to not use an icon - */ - static void registerFileAssociation (const String& fileExtension, - const String& symbolicDescription, - const String& fullDescription, - const File& targetExecutable, - int iconResourceNumber); - - /** WIN32 ONLY - This returns the HINSTANCE of the current module. - - In a normal Juce application this will be set to the module handle - of the application executable. - - If you're writing a DLL using Juce and plan to use any Juce messaging or - windows, you'll need to make sure you use the setCurrentModuleInstanceHandle() - to set the correct module handle in your DllMain() function, because - the win32 system relies on the correct instance handle when opening windows. - */ - static void* JUCE_CALLTYPE getCurrentModuleInstanceHandle() noexcept; - - /** WIN32 ONLY - Sets a new module handle to be used by the library. - - @see getCurrentModuleInstanceHandle() - */ - static void JUCE_CALLTYPE setCurrentModuleInstanceHandle (void* newHandle) noexcept; - - /** WIN32 ONLY - Gets the command-line params as a string. - - This is needed to avoid unicode problems with the argc type params. - */ - static String JUCE_CALLTYPE getCurrentCommandLineParams(); -#endif - - /** Clears the floating point unit's flags. - - Only has an effect under win32, currently. - */ - static void fpuReset(); - - -#if JUCE_LINUX || JUCE_WINDOWS - //============================================================================== - /** Loads a dynamically-linked library into the process's address space. - - @param pathOrFilename the platform-dependent name and search path - @returns a handle which can be used by getProcedureEntryPoint(), or - zero if it fails. - @see freeDynamicLibrary, getProcedureEntryPoint - */ - static void* loadDynamicLibrary (const String& pathOrFilename); - - /** Frees a dynamically-linked library. - - @param libraryHandle a handle created by loadDynamicLibrary - @see loadDynamicLibrary, getProcedureEntryPoint - */ - static void freeDynamicLibrary (void* libraryHandle); - - /** Finds a procedure call in a dynamically-linked library. - - @param libraryHandle a library handle returned by loadDynamicLibrary - @param procedureName the name of the procedure call to try to load - @returns a pointer to the function if found, or 0 if it fails - @see loadDynamicLibrary - */ - static void* getProcedureEntryPoint (void* libraryHandle, - const String& procedureName); -#endif - -private: - PlatformUtilities(); - - JUCE_DECLARE_NON_COPYABLE (PlatformUtilities); -}; - - -//============================================================================== -#if JUCE_MAC || JUCE_IOS || DOXYGEN - - /** A handy C++ wrapper that creates and deletes an NSAutoreleasePool object using RAII. */ - class JUCE_API ScopedAutoReleasePool - { - public: - ScopedAutoReleasePool(); - ~ScopedAutoReleasePool(); - - private: - void* pool; - - JUCE_DECLARE_NON_COPYABLE (ScopedAutoReleasePool); - }; - - /** A macro that can be used to easily declare a local ScopedAutoReleasePool object for RAII-based obj-C autoreleasing. */ - #define JUCE_AUTORELEASEPOOL const JUCE_NAMESPACE::ScopedAutoReleasePool JUCE_JOIN_MACRO (autoReleasePool_, __LINE__); - -#else - #define JUCE_AUTORELEASEPOOL -#endif - - -//============================================================================== -#if JUCE_LINUX - -/** A handy class that uses XLockDisplay and XUnlockDisplay to lock the X server - using an RAII approach. -*/ -class ScopedXLock -{ -public: - /** Creating a ScopedXLock object locks the X display. - This uses XLockDisplay() to grab the display that Juce is using. - */ - ScopedXLock(); - - /** Deleting a ScopedXLock object unlocks the X display. - This calls XUnlockDisplay() to release the lock. - */ - ~ScopedXLock(); -}; - -#endif - - -//============================================================================== -#if JUCE_MAC - -/** - A wrapper class for picking up events from an Apple IR remote control device. - - To use it, just create a subclass of this class, implementing the buttonPressed() - callback, then call start() and stop() to start or stop receiving events. -*/ -class JUCE_API AppleRemoteDevice -{ -public: - //============================================================================== - AppleRemoteDevice(); - virtual ~AppleRemoteDevice(); - - //============================================================================== - /** The set of buttons that may be pressed. - @see buttonPressed - */ - enum ButtonType - { - menuButton = 0, /**< The menu button (if it's held for a short time). */ - playButton, /**< The play button. */ - plusButton, /**< The plus or volume-up button. */ - minusButton, /**< The minus or volume-down button. */ - rightButton, /**< The right button (if it's held for a short time). */ - leftButton, /**< The left button (if it's held for a short time). */ - rightButton_Long, /**< The right button (if it's held for a long time). */ - leftButton_Long, /**< The menu button (if it's held for a long time). */ - menuButton_Long, /**< The menu button (if it's held for a long time). */ - playButtonSleepMode, - switched - }; - - //============================================================================== - /** Override this method to receive the callback about a button press. - - The callback will happen on the application's message thread. - - Some buttons trigger matching up and down events, in which the isDown parameter - will be true and then false. Others only send a single event when the - button is pressed. - */ - virtual void buttonPressed (ButtonType buttonId, bool isDown) = 0; - - //============================================================================== - /** Starts the device running and responding to events. - - Returns true if it managed to open the device. - - @param inExclusiveMode if true, the remote will be grabbed exclusively for this app, - and will not be available to any other part of the system. If - false, it will be shared with other apps. - @see stop - */ - bool start (bool inExclusiveMode); - - /** Stops the device running. - @see start - */ - void stop(); - - /** Returns true if the device has been started successfully. - */ - bool isActive() const; - - /** Returns the ID number of the remote, if it has sent one. - */ - int getRemoteId() const { return remoteId; } - - //============================================================================== - /** @internal */ - void handleCallbackInternal(); - -private: - void* device; - void* queue; - int remoteId; - - bool open (bool openInExclusiveMode); - - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AppleRemoteDevice); -}; - -#endif - - -#endif // __JUCE_PLATFORMUTILITIES_JUCEHEADER__ diff --git a/src/core/juce_StandardHeader.h b/src/core/juce_StandardHeader.h index 304dea12cd..2537ee4af5 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 6 +#define JUCE_BUILDNUMBER 7 /** Current Juce version number. @@ -187,6 +187,29 @@ extern JUCE_API bool JUCE_CALLTYPE juce_isRunningUnderDebugger(); #undef TYPE_BOOL // (stupidly-named CoreServices definition which interferes with other libraries). +//============================================================================== +#if JUCE_MAC || JUCE_IOS || DOXYGEN + + /** A handy C++ wrapper that creates and deletes an NSAutoreleasePool object using RAII. */ + class JUCE_API ScopedAutoReleasePool + { + public: + ScopedAutoReleasePool(); + ~ScopedAutoReleasePool(); + + private: + void* pool; + + JUCE_DECLARE_NON_COPYABLE (ScopedAutoReleasePool); + }; + + /** A macro that can be used to easily declare a local ScopedAutoReleasePool object for RAII-based obj-C autoreleasing. */ + #define JUCE_AUTORELEASEPOOL const JUCE_NAMESPACE::ScopedAutoReleasePool JUCE_JOIN_MACRO (autoReleasePool_, __LINE__); + +#else + #define JUCE_AUTORELEASEPOOL +#endif + END_JUCE_NAMESPACE diff --git a/src/core/juce_SystemStats.cpp b/src/core/juce_SystemStats.cpp index 0ee22356a5..d98c0dd3d9 100644 --- a/src/core/juce_SystemStats.cpp +++ b/src/core/juce_SystemStats.cpp @@ -30,7 +30,6 @@ BEGIN_JUCE_NAMESPACE #include "../text/juce_String.h" #include "juce_SystemStats.h" #include "juce_Time.h" -#include "juce_PlatformUtilities.h" //============================================================================== diff --git a/src/core/juce_SystemStats.h b/src/core/juce_SystemStats.h index 7fc4b3e1d8..5ca17771a7 100644 --- a/src/core/juce_SystemStats.h +++ b/src/core/juce_SystemStats.h @@ -87,6 +87,13 @@ public: */ static bool isOperatingSystem64Bit(); + #if JUCE_MAC || DOXYGEN + /** OSX ONLY - Returns the current OS version number. + E.g. if it's running on 10.4, this will be 4, 10.5 will return 5, etc. + */ + static int getOSXMinorVersionNumber(); + #endif + //============================================================================== /** Returns the current user's name, if available. @see getFullUserName() diff --git a/src/events/juce_AppleRemote.h b/src/events/juce_AppleRemote.h new file mode 100644 index 0000000000..8db5de7e51 --- /dev/null +++ b/src/events/juce_AppleRemote.h @@ -0,0 +1,115 @@ +/* + ============================================================================== + + 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_APPLEREMOTE_JUCEHEADER__ +#define __JUCE_APPLEREMOTE_JUCEHEADER__ + + +//============================================================================== +#if JUCE_MAC || DOXYGEN +/** + Receives events from an Apple IR remote control device (Only available in OSX!). + + To use it, just create a subclass of this class, implementing the buttonPressed() + callback, then call start() and stop() to start or stop receiving events. +*/ +class JUCE_API AppleRemoteDevice +{ +public: + //============================================================================== + AppleRemoteDevice(); + virtual ~AppleRemoteDevice(); + + //============================================================================== + /** The set of buttons that may be pressed. + @see buttonPressed + */ + enum ButtonType + { + menuButton = 0, /**< The menu button (if it's held for a short time). */ + playButton, /**< The play button. */ + plusButton, /**< The plus or volume-up button. */ + minusButton, /**< The minus or volume-down button. */ + rightButton, /**< The right button (if it's held for a short time). */ + leftButton, /**< The left button (if it's held for a short time). */ + rightButton_Long, /**< The right button (if it's held for a long time). */ + leftButton_Long, /**< The menu button (if it's held for a long time). */ + menuButton_Long, /**< The menu button (if it's held for a long time). */ + playButtonSleepMode, + switched + }; + + //============================================================================== + /** Override this method to receive the callback about a button press. + + The callback will happen on the application's message thread. + + Some buttons trigger matching up and down events, in which the isDown parameter + will be true and then false. Others only send a single event when the + button is pressed. + */ + virtual void buttonPressed (ButtonType buttonId, bool isDown) = 0; + + //============================================================================== + /** Starts the device running and responding to events. + + Returns true if it managed to open the device. + + @param inExclusiveMode if true, the remote will be grabbed exclusively for this app, + and will not be available to any other part of the system. If + false, it will be shared with other apps. + @see stop + */ + bool start (bool inExclusiveMode); + + /** Stops the device running. + @see start + */ + void stop(); + + /** Returns true if the device has been started successfully. + */ + bool isActive() const; + + /** Returns the ID number of the remote, if it has sent one. + */ + int getRemoteId() const { return remoteId; } + + //============================================================================== + /** @internal */ + void handleCallbackInternal(); + +private: + void* device; + void* queue; + int remoteId; + + bool open (bool openInExclusiveMode); + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AppleRemoteDevice); +}; + +#endif +#endif // __JUCE_APPLEREMOTE_JUCEHEADER__ diff --git a/src/gui/components/controls/juce_Slider.cpp b/src/gui/components/controls/juce_Slider.cpp index 6f22991d8d..103137857b 100644 --- a/src/gui/components/controls/juce_Slider.cpp +++ b/src/gui/components/controls/juce_Slider.cpp @@ -341,7 +341,9 @@ void Slider::lookAndFeelChanged() valueBox->setWantsKeyboardFocus (false); valueBox->setText (previousTextBoxContent, false); - valueBox->setEditable (editableText && isEnabled()); + if (valueBox->isEditable() != editableText) // (avoid overriding the single/double click flags unless we have to) + valueBox->setEditable (editableText && isEnabled()); + valueBox->addListener (this); if (style == LinearBar) diff --git a/src/gui/components/juce_Component.cpp b/src/gui/components/juce_Component.cpp index 04abe541dd..e0f5a37f26 100644 --- a/src/gui/components/juce_Component.cpp +++ b/src/gui/components/juce_Component.cpp @@ -39,7 +39,6 @@ BEGIN_JUCE_NAMESPACE #include "../../events/juce_MessageManager.h" #include "../../events/juce_Timer.h" #include "../../core/juce_Time.h" -#include "../../core/juce_PlatformUtilities.h" #include "mouse/juce_MouseInputSource.h" #include "positioning/juce_RelativeRectangle.h" diff --git a/src/gui/components/keyboard/juce_KeyPressMappingSet.cpp b/src/gui/components/keyboard/juce_KeyPressMappingSet.cpp index 656f8647d4..8b08eead9c 100644 --- a/src/gui/components/keyboard/juce_KeyPressMappingSet.cpp +++ b/src/gui/components/keyboard/juce_KeyPressMappingSet.cpp @@ -29,7 +29,6 @@ BEGIN_JUCE_NAMESPACE #include "juce_KeyPressMappingSet.h" #include "../../../core/juce_Time.h" -#include "../../../core/juce_PlatformUtilities.h" #include "../lookandfeel/juce_LookAndFeel.h" diff --git a/src/gui/components/lookandfeel/juce_LookAndFeel.cpp b/src/gui/components/lookandfeel/juce_LookAndFeel.cpp index 60cd22937e..05236d871c 100644 --- a/src/gui/components/lookandfeel/juce_LookAndFeel.cpp +++ b/src/gui/components/lookandfeel/juce_LookAndFeel.cpp @@ -69,7 +69,6 @@ BEGIN_JUCE_NAMESPACE #include "../../../text/juce_LocalisedStrings.h" #include "../special/juce_MidiKeyboardComponent.h" #include "../special/juce_ColourSelector.h" -#include "../../../core/juce_PlatformUtilities.h" #include "../../../text/juce_XmlDocument.h" #include "../../../io/streams/juce_GZIPDecompressorInputStream.h" #include "../../../io/streams/juce_MemoryInputStream.h" @@ -2822,13 +2821,6 @@ const Drawable* LookAndFeel::getDefaultDocumentFileImage() return documentImage; } - -//============================================================================== -void LookAndFeel::playAlertSound() -{ - PlatformUtilities::beep(); -} - //============================================================================== void LookAndFeel::drawLevelMeter (Graphics& g, int width, int height, float level) { diff --git a/src/gui/components/lookandfeel/juce_LookAndFeel.h b/src/gui/components/lookandfeel/juce_LookAndFeel.h index e9771915b2..433b99be04 100644 --- a/src/gui/components/lookandfeel/juce_LookAndFeel.h +++ b/src/gui/components/lookandfeel/juce_LookAndFeel.h @@ -616,7 +616,7 @@ public: virtual void drawKeymapChangeButton (Graphics& g, int width, int height, Button& button, const String& keyDescription); //============================================================================== - /** + /** Plays the system's default 'beep' noise, to alert the user about something very important. */ virtual void playAlertSound(); diff --git a/src/gui/components/special/juce_ScopedXLock.h b/src/gui/components/special/juce_ScopedXLock.h new file mode 100644 index 0000000000..6df27e31c6 --- /dev/null +++ b/src/gui/components/special/juce_ScopedXLock.h @@ -0,0 +1,51 @@ +/* + ============================================================================== + + 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_SCOPEDXLOCK_JUCEHEADER__ +#define __JUCE_SCOPEDXLOCK_JUCEHEADER__ + + +//============================================================================== +#if JUCE_LINUX || DOXYGEN + +/** A handy class that uses XLockDisplay and XUnlockDisplay to lock the X server + using RAII (Only available in Linux!). +*/ +class ScopedXLock +{ +public: + /** Creating a ScopedXLock object locks the X display. + This uses XLockDisplay() to grab the display that Juce is using. + */ + ScopedXLock(); + + /** Deleting a ScopedXLock object unlocks the X display. + This calls XUnlockDisplay() to release the lock. + */ + ~ScopedXLock(); +}; + +#endif +#endif // __JUCE_SCOPEDXLOCK_JUCEHEADER__ diff --git a/src/io/files/juce_File.cpp b/src/io/files/juce_File.cpp index 7a72da6fa9..9b7fc88950 100644 --- a/src/io/files/juce_File.cpp +++ b/src/io/files/juce_File.cpp @@ -38,8 +38,8 @@ BEGIN_JUCE_NAMESPACE #include "juce_TemporaryFile.h" #include "../../core/juce_SystemStats.h" #include "../../maths/juce_Random.h" -#include "../../core/juce_PlatformUtilities.h" #include "../../memory/juce_ScopedPointer.h" +#include "../../threads/juce_Process.h" //============================================================================== @@ -669,7 +669,7 @@ File File::withFileExtension (const String& newExtension) const //============================================================================== bool File::startAsProcess (const String& parameters) const { - return exists() && PlatformUtilities::openDocument (fullPath, parameters); + return exists() && Process::openDocument (fullPath, parameters); } //============================================================================== diff --git a/src/io/files/juce_File.h b/src/io/files/juce_File.h index 57ebc8547d..ee64b85779 100644 --- a/src/io/files/juce_File.h +++ b/src/io/files/juce_File.h @@ -920,6 +920,20 @@ public: /** Adds a separator character to the end of a path if it doesn't already have one. */ static String addTrailingSeparator (const String& path); + #if JUCE_MAC || JUCE_IOS || DOXYGEN + //============================================================================== + /** OSX ONLY - Finds the OSType of a file from the its resources. */ + OSType getMacOSType() const; + + /** OSX ONLY - Returns true if this file is actually a bundle. */ + bool isBundle() const; + #endif + + #if JUCE_MAC || DOXYGEN + /** OSX ONLY - Adds this file to the OSX dock */ + void addToDock() const; + #endif + private: //============================================================================== String fullPath; diff --git a/src/io/network/juce_URL.cpp b/src/io/network/juce_URL.cpp index 15849a1303..4e10269e74 100644 --- a/src/io/network/juce_URL.cpp +++ b/src/io/network/juce_URL.cpp @@ -30,9 +30,9 @@ BEGIN_JUCE_NAMESPACE #include "juce_URL.h" #include "../streams/juce_InputStream.h" #include "../../maths/juce_Random.h" -#include "../../core/juce_PlatformUtilities.h" #include "../../text/juce_XmlDocument.h" #include "../../io/streams/juce_MemoryOutputStream.h" +#include "../../threads/juce_Process.h" //============================================================================== @@ -450,7 +450,7 @@ bool URL::launchInDefaultBrowser() const if (u.containsChar ('@') && ! u.containsChar (':')) u = "mailto:" + u; - return PlatformUtilities::openDocument (u, String::empty); + return Process::openDocument (u, String::empty); } diff --git a/src/juce_app_includes.h b/src/juce_app_includes.h index 5407cf8759..a7adb9bfb6 100644 --- a/src/juce_app_includes.h +++ b/src/juce_app_includes.h @@ -239,6 +239,9 @@ #ifndef __JUCE_ACTIONLISTENER_JUCEHEADER__ #include "events/juce_ActionListener.h" #endif +#ifndef __JUCE_APPLEREMOTE_JUCEHEADER__ + #include "events/juce_AppleRemote.h" +#endif #ifndef __JUCE_ASYNCUPDATER_JUCEHEADER__ #include "events/juce_AsyncUpdater.h" #endif @@ -608,6 +611,9 @@ #ifndef __JUCE_QUICKTIMEMOVIECOMPONENT_JUCEHEADER__ #include "gui/components/special/juce_QuickTimeMovieComponent.h" #endif +#ifndef __JUCE_SCOPEDXLOCK_JUCEHEADER__ + #include "gui/components/special/juce_ScopedXLock.h" +#endif #ifndef __JUCE_SYSTEMTRAYICONCOMPONENT_JUCEHEADER__ #include "gui/components/special/juce_SystemTrayIconComponent.h" #endif @@ -797,5 +803,8 @@ #ifndef __JUCE_UNITTEST_JUCEHEADER__ #include "utilities/juce_UnitTest.h" #endif +#ifndef __JUCE_WINDOWSREGISTRY_JUCEHEADER__ + #include "utilities/juce_WindowsRegistry.h" +#endif #endif diff --git a/src/juce_core_includes.h b/src/juce_core_includes.h index 5f525933ab..2599b13c27 100644 --- a/src/juce_core_includes.h +++ b/src/juce_core_includes.h @@ -92,9 +92,6 @@ #ifndef __JUCE_PLATFORMDEFS_JUCEHEADER__ #include "core/juce_PlatformDefs.h" #endif -#ifndef __JUCE_PLATFORMUTILITIES_JUCEHEADER__ - #include "core/juce_PlatformUtilities.h" -#endif #ifndef __JUCE_RELATIVETIME_JUCEHEADER__ #include "core/juce_RelativeTime.h" #endif @@ -290,6 +287,9 @@ #ifndef __JUCE_CRITICALSECTION_JUCEHEADER__ #include "threads/juce_CriticalSection.h" #endif +#ifndef __JUCE_DYNAMICLIBRARY_JUCEHEADER__ + #include "threads/juce_DynamicLibrary.h" +#endif #ifndef __JUCE_INTERPROCESSLOCK_JUCEHEADER__ #include "threads/juce_InterProcessLock.h" #endif diff --git a/src/native/android/juce_android_Files.cpp b/src/native/android/juce_android_Files.cpp index 0b53b079a9..cf018532a0 100644 --- a/src/native/android/juce_android_Files.cpp +++ b/src/native/android/juce_android_Files.cpp @@ -232,7 +232,7 @@ bool DirectoryIterator::NativeIterator::next (String& filenameFound, //============================================================================== -bool PlatformUtilities::openDocument (const String& fileName, const String& parameters) +bool Process::openDocument (const String& fileName, const String& parameters) { } diff --git a/src/native/android/juce_android_Misc.cpp b/src/native/android/juce_android_Misc.cpp index b6195f4b3b..41268c00ce 100644 --- a/src/native/android/juce_android_Misc.cpp +++ b/src/native/android/juce_android_Misc.cpp @@ -55,7 +55,7 @@ JUCE_JNI_CALLBACK (JuceAppActivity, quitApp, void, (JNIEnv* env, jobject activit } //============================================================================== -void PlatformUtilities::beep() +void LookAndFeel::playAlertSound() { } diff --git a/src/native/android/juce_android_NativeCode.cpp b/src/native/android/juce_android_NativeCode.cpp index 74ca8fb1c9..3cda7f92f8 100644 --- a/src/native/android/juce_android_NativeCode.cpp +++ b/src/native/android/juce_android_NativeCode.cpp @@ -56,7 +56,6 @@ BEGIN_JUCE_NAMESPACE #include "../../io/files/juce_MemoryMappedFile.h" #include "../../io/network/juce_URL.h" #include "../../io/network/juce_MACAddress.h" -#include "../../core/juce_PlatformUtilities.h" #include "../../text/juce_LocalisedStrings.h" #include "../../utilities/juce_DeletedAtShutdown.h" #include "../../application/juce_Application.h" diff --git a/src/native/android/juce_android_Network.cpp b/src/native/android/juce_android_Network.cpp index 5f1c3e144c..5f5aaadb8a 100644 --- a/src/native/android/juce_android_Network.cpp +++ b/src/native/android/juce_android_Network.cpp @@ -35,13 +35,12 @@ void MACAddress::findAllAddresses (Array& result) } -bool PlatformUtilities::launchEmailWithAttachments (const String& targetEmailAddress, - const String& emailSubject, - const String& bodyText, - const StringArray& filesToAttach) +bool Process::openEmailWithAttachments (const String& targetEmailAddress, + const String& emailSubject, + const String& bodyText, + const StringArray& filesToAttach) { // TODO - return false; } diff --git a/src/native/android/juce_android_SystemStats.cpp b/src/native/android/juce_android_SystemStats.cpp index 07a2a6a94e..08bc778a37 100644 --- a/src/native/android/juce_android_SystemStats.cpp +++ b/src/native/android/juce_android_SystemStats.cpp @@ -126,8 +126,6 @@ SystemStats::CPUFlags::CPUFlags() numCpus = jmax (1, sysconf (_SC_NPROCESSORS_ONLN)); } -void PlatformUtilities::fpuReset() {} - //============================================================================== uint32 juce_millisecondsSinceStartup() noexcept { diff --git a/src/native/linux/juce_linux_Files.cpp b/src/native/linux/juce_linux_Files.cpp index 69f81ab4e1..233960a43a 100644 --- a/src/native/linux/juce_linux_Files.cpp +++ b/src/native/linux/juce_linux_Files.cpp @@ -304,7 +304,7 @@ bool DirectoryIterator::NativeIterator::next (String& filenameFound, //============================================================================== -bool PlatformUtilities::openDocument (const String& fileName, const String& parameters) +bool Process::openDocument (const String& fileName, const String& parameters) { String cmdString (fileName.replace (" ", "\\ ",false)); cmdString << " " << parameters; diff --git a/src/native/linux/juce_linux_NativeCode.cpp b/src/native/linux/juce_linux_NativeCode.cpp index f6928fa560..cb6503b70b 100644 --- a/src/native/linux/juce_linux_NativeCode.cpp +++ b/src/native/linux/juce_linux_NativeCode.cpp @@ -47,7 +47,6 @@ BEGIN_JUCE_NAMESPACE #include "../../core/juce_Time.h" #include "../../maths/juce_Random.h" #include "../../core/juce_Singleton.h" -#include "../../core/juce_PlatformUtilities.h" #include "../../memory/juce_MemoryBlock.h" #include "../../containers/juce_ReferenceCountedArray.h" #include "../../utilities/juce_DeletedAtShutdown.h" @@ -59,6 +58,7 @@ BEGIN_JUCE_NAMESPACE #include "../../threads/juce_InterProcessLock.h" #include "../../threads/juce_WaitableEvent.h" #include "../../threads/juce_Process.h" +#include "../../threads/juce_DynamicLibrary.h" #include "../../io/files/juce_File.h" #include "../../io/files/juce_NamedPipe.h" #include "../../io/files/juce_FileInputStream.h" @@ -83,6 +83,7 @@ BEGIN_JUCE_NAMESPACE #include "../../gui/graphics/geometry/juce_RectangleList.h" #include "../../gui/graphics/imaging/juce_ImageFileFormat.h" #include "../../gui/graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.h" +#include "../../gui/components/lookandfeel/juce_LookAndFeel.h" #include "../../gui/components/juce_Desktop.h" #include "../../gui/components/mouse/juce_MouseInputSource.h" #include "../../gui/components/mouse/juce_DragAndDropContainer.h" @@ -94,6 +95,7 @@ BEGIN_JUCE_NAMESPACE #include "../../gui/components/special/juce_WebBrowserComponent.h" #include "../../gui/components/special/juce_OpenGLComponent.h" #include "../../gui/components/special/juce_SystemTrayIconComponent.h" +#include "../../gui/components/special/juce_ScopedXLock.h" #include "../../containers/juce_ScopedValueSetter.h" //============================================================================== diff --git a/src/native/linux/juce_linux_Network.cpp b/src/native/linux/juce_linux_Network.cpp index e735891267..738c115ad7 100644 --- a/src/native/linux/juce_linux_Network.cpp +++ b/src/native/linux/juce_linux_Network.cpp @@ -58,10 +58,10 @@ void MACAddress::findAllAddresses (Array& result) } -bool PlatformUtilities::launchEmailWithAttachments (const String& targetEmailAddress, - const String& emailSubject, - const String& bodyText, - const StringArray& filesToAttach) +bool Process::openEmailWithAttachments (const String& targetEmailAddress, + const String& emailSubject, + const String& bodyText, + const StringArray& filesToAttach) { jassertfalse; // xxx todo diff --git a/src/native/linux/juce_linux_SystemStats.cpp b/src/native/linux/juce_linux_SystemStats.cpp index 4693999123..2abce828f8 100644 --- a/src/native/linux/juce_linux_SystemStats.cpp +++ b/src/native/linux/juce_linux_SystemStats.cpp @@ -137,10 +137,6 @@ SystemStats::CPUFlags::CPUFlags() numCpus = LinuxStatsHelpers::getCpuInfo ("processor").getIntValue() + 1; } -void PlatformUtilities::fpuReset() -{ -} - //============================================================================== uint32 juce_millisecondsSinceStartup() noexcept { diff --git a/src/native/linux/juce_linux_Threads.cpp b/src/native/linux/juce_linux_Threads.cpp index a0961b2a40..d7b1dc9cd7 100644 --- a/src/native/linux/juce_linux_Threads.cpp +++ b/src/native/linux/juce_linux_Threads.cpp @@ -111,23 +111,22 @@ void Process::lowerPrivilege() } } -#if ! JUCE_ONLY_BUILD_CORE_LIBRARY - -void* PlatformUtilities::loadDynamicLibrary (const String& name) +bool DynamicLibrary::open (const String& name) { - return dlopen (name.toUTF8(), RTLD_LOCAL | RTLD_NOW); + close(); + handle = dlopen (name.toUTF8(), RTLD_LOCAL | RTLD_NOW); + return handle != 0; } -void PlatformUtilities::freeDynamicLibrary (void* handle) +void DynamicLibrary::close() noexcept { - dlclose(handle); + if (handle != nullptr) + dlclose (handle); } -void* PlatformUtilities::getProcedureEntryPoint (void* libraryHandle, const String& procedureName) +void* DynamicLibrary::getFunction (const String& functionName) noexcept { - return dlsym (libraryHandle, procedureName.toUTF8()); + return handle != nullptr ? dlsym (handle, functionName.toUTF8()) : nullptr; } #endif - -#endif diff --git a/src/native/linux/juce_linux_Windowing.cpp b/src/native/linux/juce_linux_Windowing.cpp index a22a917002..a7fde24099 100644 --- a/src/native/linux/juce_linux_Windowing.cpp +++ b/src/native/linux/juce_linux_Windowing.cpp @@ -3334,7 +3334,7 @@ void SystemTrayIconComponent::setIconTooltip (const String& tooltip) //============================================================================== -void PlatformUtilities::beep() +void LookAndFeel::playAlertSound() { std::cout << "\a" << std::flush; } diff --git a/src/native/mac/juce_ios_MiscUtilities.mm b/src/native/mac/juce_ios_MiscUtilities.mm index 74bf012930..799ec0d1b4 100644 --- a/src/native/mac/juce_ios_MiscUtilities.mm +++ b/src/native/mac/juce_ios_MiscUtilities.mm @@ -76,18 +76,12 @@ ScopedAutoReleasePool::~ScopedAutoReleasePool() } //============================================================================== -void PlatformUtilities::beep() +void LookAndFeel::playAlertSound() { //xxx //AudioServicesPlaySystemSound (); } -//============================================================================== -void PlatformUtilities::addItemToDock (const File& file) -{ -} - - //============================================================================== #if ! JUCE_ONLY_BUILD_CORE_LIBRARY diff --git a/src/native/mac/juce_ios_UIViewComponentPeer.mm b/src/native/mac/juce_ios_UIViewComponentPeer.mm index b1c0fa8044..2416f38e04 100644 --- a/src/native/mac/juce_ios_UIViewComponentPeer.mm +++ b/src/native/mac/juce_ios_UIViewComponentPeer.mm @@ -1010,6 +1010,21 @@ Image juce_createIconForFile (const File& file) return Image::null; } +//============================================================================== +void SystemClipboard::copyTextToClipboard (const String& text) +{ + [[UIPasteboard generalPasteboard] setValue: juceStringToNS (text) + forPasteboardType: @"public.text"]; +} + +String SystemClipboard::getTextFromClipboard() +{ + NSString* text = [[UIPasteboard generalPasteboard] valueForPasteboardType: @"public.text"]; + + return text == nil ? String::empty + : nsStringToJuce (text); +} + //============================================================================== void Desktop::createMouseInputSources() { diff --git a/src/native/mac/juce_mac_CoreMidi.cpp b/src/native/mac/juce_mac_CoreMidi.cpp index 6f539c8cba..8855ce90d1 100644 --- a/src/native/mac/juce_mac_CoreMidi.cpp +++ b/src/native/mac/juce_mac_CoreMidi.cpp @@ -55,7 +55,7 @@ namespace CoreMidiHelpers if (str != 0) { - result = PlatformUtilities::cfStringToJuceString (str); + result = String::fromCFString (str); CFRelease (str); str = 0; } @@ -73,7 +73,7 @@ namespace CoreMidiHelpers if (str != 0) { - result += PlatformUtilities::cfStringToJuceString (str); + result += String::fromCFString (str); CFRelease (str); str = 0; } @@ -89,7 +89,7 @@ namespace CoreMidiHelpers if (str != 0) { - const String s (PlatformUtilities::cfStringToJuceString (str)); + const String s (String::fromCFString (str)); CFRelease (str); // if an external device has only one entity, throw away @@ -151,7 +151,7 @@ namespace CoreMidiHelpers if (str != 0) { - s = PlatformUtilities::cfStringToJuceString (str); + s = String::fromCFString (str); CFRelease (str); } } @@ -188,7 +188,7 @@ namespace CoreMidiHelpers if (JUCEApplication::getInstance() != nullptr) name = JUCEApplication::getInstance()->getApplicationName(); - CFStringRef appName = PlatformUtilities::juceStringToCFString (name); + CFStringRef appName = name.toCFString(); CHECK_ERROR (MIDIClientCreate (appName, 0, 0, &globalMidiClient)); CFRelease (appName); } @@ -352,7 +352,7 @@ MidiOutput* MidiOutput::createNewDevice (const String& deviceName) MIDIClientRef client = CoreMidiHelpers::getGlobalMidiClient(); MIDIEndpointRef endPoint; - CFStringRef name = PlatformUtilities::juceStringToCFString (deviceName); + CFStringRef name = deviceName.toCFString(); if (client != 0 && CHECK_ERROR (MIDISourceCreate (client, name, &endPoint))) { @@ -507,7 +507,8 @@ MidiInput* MidiInput::createNewDevice (const String& deviceName, MidiInputCallba mpc->active = false; MIDIEndpointRef endPoint; - CFStringRef name = PlatformUtilities::juceStringToCFString(deviceName); + CFStringRef name = deviceName.toCFString(); + if (CHECK_ERROR (MIDIDestinationCreate (client, name, midiInputProc, mpc, &endPoint))) { mpc->portAndEndpoint = new MidiPortAndEndpoint (0, endPoint); diff --git a/src/native/mac/juce_mac_Files.mm b/src/native/mac/juce_mac_Files.mm index afdbe90d74..30066b12df 100644 --- a/src/native/mac/juce_mac_Files.mm +++ b/src/native/mac/juce_mac_Files.mm @@ -245,7 +245,7 @@ File File::getSpecialLocation (const SpecialLocationType type) } if (resultPath.isNotEmpty()) - return File (PlatformUtilities::convertToPrecomposedUnicode (resultPath)); + return File (resultPath.convertToPrecomposedUnicode()); return File::nonexistent; } @@ -389,7 +389,7 @@ bool DirectoryIterator::NativeIterator::next (String& filenameFound, //============================================================================== -bool PlatformUtilities::openDocument (const String& fileName, const String& parameters) +bool Process::openDocument (const String& fileName, const String& parameters) { #if JUCE_IOS return [[UIApplication sharedApplication] openURL: [NSURL fileURLWithPath: juceStringToNS (fileName)]]; @@ -403,8 +403,9 @@ bool PlatformUtilities::openDocument (const String& fileName, const String& para } bool ok = false; + const File file (fileName); - if (PlatformUtilities::isBundle (fileName)) + if (file.isBundle()) { NSMutableArray* urls = [NSMutableArray array]; @@ -419,7 +420,7 @@ bool PlatformUtilities::openDocument (const String& fileName, const String& para additionalEventParamDescriptor: nil launchIdentifiers: nil]; } - else if (File (fileName).exists()) + else if (file.exists()) { ok = FileHelpers::launchExecutable ("\"" + fileName + "\" " + parameters); } @@ -439,46 +440,42 @@ void File::revealToUser() const } //============================================================================== -#if ! JUCE_IOS -bool PlatformUtilities::makeFSRefFromPath (FSRef* destFSRef, const String& path) -{ - return FSPathMakeRef (reinterpret_cast (path.toUTF8().getAddress()), destFSRef, 0) == noErr; -} - -String PlatformUtilities::makePathFromFSRef (FSRef* file) -{ - char path [2048] = { 0 }; - - if (FSRefMakePath (file, (UInt8*) path, sizeof (path) - 1) == noErr) - return PlatformUtilities::convertToPrecomposedUnicode (CharPointer_UTF8 (path)); - - return String::empty; -} -#endif - -//============================================================================== -OSType PlatformUtilities::getTypeOfFile (const String& filename) +OSType File::getMacOSType() const { JUCE_AUTORELEASEPOOL #if JUCE_IOS || (defined (MAC_OS_X_VERSION_10_5) && MAC_OS_X_VERSION_MIN_ALLOWED >= MAC_OS_X_VERSION_10_5) - NSDictionary* fileDict = [[NSFileManager defaultManager] attributesOfItemAtPath: juceStringToNS (filename) error: nil]; + NSDictionary* fileDict = [[NSFileManager defaultManager] attributesOfItemAtPath: juceStringToNS (getFullPathName()) error: nil]; #else // (the cast here avoids a deprecation warning) - NSDictionary* fileDict = [((id) [NSFileManager defaultManager]) fileAttributesAtPath: juceStringToNS (filename) traverseLink: NO]; + NSDictionary* fileDict = [((id) [NSFileManager defaultManager]) fileAttributesAtPath: juceStringToNS (getFullPathName()) traverseLink: NO]; #endif return [fileDict fileHFSTypeCode]; } -bool PlatformUtilities::isBundle (const String& filename) +bool File::isBundle() const { #if JUCE_IOS return false; // xxx can't find a sensible way to do this without trying to open the bundle.. #else JUCE_AUTORELEASEPOOL - return [[NSWorkspace sharedWorkspace] isFilePackageAtPath: juceStringToNS (filename)]; + return [[NSWorkspace sharedWorkspace] isFilePackageAtPath: juceStringToNS (getFullPathName())]; #endif } +#if ! JUCE_IOS +void File::addToDock() const +{ + // check that it's not already there... + if (! juce_getOutputFromCommand ("defaults read com.apple.dock persistent-apps").containsIgnoreCase (getFullPathName())) + { + juce_runSystemCommand ("defaults write com.apple.dock persistent-apps -array-add \"tile-datafile-data_CFURLString" + + getFullPathName() + "_CFURLStringType0\""); + + juce_runSystemCommand ("osascript -e \"tell application \\\"Dock\\\" to quit\""); + } +} +#endif + #endif diff --git a/src/native/mac/juce_mac_Fonts.mm b/src/native/mac/juce_mac_Fonts.mm index 1adc5ae67f..93cf38bc8b 100644 --- a/src/native/mac/juce_mac_Fonts.mm +++ b/src/native/mac/juce_mac_Fonts.mm @@ -51,7 +51,7 @@ public: unitsToHeightScaleFactor (0.0f) { JUCE_AUTORELEASEPOOL - CFStringRef cfName = PlatformUtilities::juceStringToCFString (font.getTypefaceName()); + CFStringRef cfName = font.getTypefaceName().toCFString(); ctFontRef = CTFontCreateWithName (cfName, 1024, nullptr); CFRelease (cfName); @@ -137,7 +137,7 @@ public: if (ctFontRef != nullptr && text.isNotEmpty()) { - CFStringRef cfText = PlatformUtilities::juceStringToCFString (text); + CFStringRef cfText = text.toCFString(); CFAttributedStringRef attribString = CFAttributedStringCreate (kCFAllocatorDefault, cfText, attributedStringAtts); CFRelease (cfText); @@ -172,7 +172,7 @@ public: { float x = 0; - CFStringRef cfText = PlatformUtilities::juceStringToCFString (text); + CFStringRef cfText = text.toCFString(); CFAttributedStringRef attribString = CFAttributedStringCreate (kCFAllocatorDefault, cfText, attributedStringAtts); CFRelease (cfText); diff --git a/src/native/mac/juce_mac_MiscUtilities.mm b/src/native/mac/juce_mac_MiscUtilities.mm index 27ce426bc8..4625fa55c1 100644 --- a/src/native/mac/juce_mac_MiscUtilities.mm +++ b/src/native/mac/juce_mac_MiscUtilities.mm @@ -40,26 +40,11 @@ ScopedAutoReleasePool::~ScopedAutoReleasePool() } //============================================================================== -void PlatformUtilities::beep() +void LookAndFeel::playAlertSound() { NSBeep(); } -//============================================================================== -void PlatformUtilities::addItemToDock (const File& file) -{ - // check that it's not already there... - if (! juce_getOutputFromCommand ("defaults read com.apple.dock persistent-apps") - .containsIgnoreCase (file.getFullPathName())) - { - juce_runSystemCommand ("defaults write com.apple.dock persistent-apps -array-add \"tile-datafile-data_CFURLString" - + file.getFullPathName() + "_CFURLStringType0\""); - - juce_runSystemCommand ("osascript -e \"tell application \\\"Dock\\\" to quit\""); - } -} - - //============================================================================== #if ! JUCE_ONLY_BUILD_CORE_LIBRARY diff --git a/src/native/mac/juce_mac_NSViewComponentPeer.mm b/src/native/mac/juce_mac_NSViewComponentPeer.mm index bd5dd7f4cb..7af1fbb2e7 100644 --- a/src/native/mac/juce_mac_NSViewComponentPeer.mm +++ b/src/native/mac/juce_mac_NSViewComponentPeer.mm @@ -1741,6 +1741,24 @@ Image juce_createIconForFile (const File& file) return Image (result); } +//============================================================================== +void SystemClipboard::copyTextToClipboard (const String& text) +{ + [[NSPasteboard generalPasteboard] declareTypes: [NSArray arrayWithObject: NSStringPboardType] + owner: nil]; + + [[NSPasteboard generalPasteboard] setString: juceStringToNS (text) + forType: NSStringPboardType]; +} + +String SystemClipboard::getTextFromClipboard() +{ + NSString* text = [[NSPasteboard generalPasteboard] stringForType: NSStringPboardType]; + + return text == nil ? String::empty + : nsStringToJuce (text); +} + //============================================================================== const int KeyPress::spaceKey = ' '; const int KeyPress::returnKey = 0x0d; diff --git a/src/native/mac/juce_mac_NativeCode.mm b/src/native/mac/juce_mac_NativeCode.mm index 7c766288b7..dc512f19b5 100644 --- a/src/native/mac/juce_mac_NativeCode.mm +++ b/src/native/mac/juce_mac_NativeCode.mm @@ -49,6 +49,7 @@ BEGIN_JUCE_NAMESPACE #include "../../threads/juce_Process.h" #include "../../threads/juce_Thread.h" #include "../../threads/juce_InterProcessLock.h" +#include "../../threads/juce_DynamicLibrary.h" #include "../../io/files/juce_FileInputStream.h" #include "../../io/files/juce_FileOutputStream.h" #include "../../io/files/juce_NamedPipe.h" @@ -58,7 +59,6 @@ BEGIN_JUCE_NAMESPACE #include "../../io/network/juce_MACAddress.h" #include "../../io/streams/juce_MemoryInputStream.h" #include "../../io/streams/juce_BufferedInputStream.h" -#include "../../core/juce_PlatformUtilities.h" #include "../../core/juce_Initialisation.h" #include "../../text/juce_LocalisedStrings.h" #include "../../text/juce_XmlDocument.h" @@ -86,6 +86,7 @@ BEGIN_JUCE_NAMESPACE #include "../../gui/components/layout/juce_ComponentMovementWatcher.h" #include "../../gui/components/special/juce_WebBrowserComponent.h" #include "../../gui/components/filebrowser/juce_FileChooser.h" +#include "../../gui/components/lookandfeel/juce_LookAndFeel.h" #include "../../audio/audio_file_formats/juce_AudioCDBurner.h" #include "../../audio/audio_file_formats/juce_AudioCDReader.h" #include "../../audio/audio_file_formats/juce_AiffAudioFormat.h" @@ -95,97 +96,13 @@ BEGIN_JUCE_NAMESPACE #include "../../audio/midi/juce_MidiOutput.h" #include "../../audio/midi/juce_MidiInput.h" #include "../../containers/juce_ScopedValueSetter.h" +#include "../../events/juce_AppleRemote.h" #include "../common/juce_MidiDataConcatenator.h" #undef Point #if ! JUCE_ONLY_BUILD_CORE_LIBRARY -namespace -{ - template - const Rectangle convertToRectInt (const RectType& r) - { - return Rectangle ((int) r.origin.x, (int) r.origin.y, (int) r.size.width, (int) r.size.height); - } - - template - const Rectangle convertToRectFloat (const RectType& r) - { - return Rectangle (r.origin.x, r.origin.y, r.size.width, r.size.height); - } - - template - CGRect convertToCGRect (const RectType& r) - { - return CGRectMake ((CGFloat) r.getX(), (CGFloat) r.getY(), (CGFloat) r.getWidth(), (CGFloat) r.getHeight()); - } -} - -//============================================================================== -class MessageQueue -{ -public: - MessageQueue() - { - #if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_4 && ! JUCE_IOS - runLoop = CFRunLoopGetMain(); - #else - runLoop = CFRunLoopGetCurrent(); - #endif - - CFRunLoopSourceContext sourceContext = { 0 }; - sourceContext.info = this; - sourceContext.perform = runLoopSourceCallback; - runLoopSource = CFRunLoopSourceCreate (kCFAllocatorDefault, 1, &sourceContext); - CFRunLoopAddSource (runLoop, runLoopSource, kCFRunLoopCommonModes); - } - - ~MessageQueue() - { - CFRunLoopRemoveSource (runLoop, runLoopSource, kCFRunLoopCommonModes); - CFRunLoopSourceInvalidate (runLoopSource); - CFRelease (runLoopSource); - } - - void post (Message* const message) - { - messages.add (message); - CFRunLoopSourceSignal (runLoopSource); - CFRunLoopWakeUp (runLoop); - } - -private: - ReferenceCountedArray messages; - CriticalSection lock; - CFRunLoopRef runLoop; - CFRunLoopSourceRef runLoopSource; - - bool deliverNextMessage() - { - const Message::Ptr nextMessage (messages.removeAndReturn (0)); - - if (nextMessage == nullptr) - return false; - - JUCE_AUTORELEASEPOOL - MessageManager::getInstance()->deliverMessage (nextMessage); - return true; - } - - void runLoopCallback() - { - for (int i = 4; --i >= 0;) - if (! deliverNextMessage()) - return; - - CFRunLoopSourceSignal (runLoopSource); - CFRunLoopWakeUp (runLoop); - } - - static void runLoopSourceCallback (void* info) - { - static_cast (info)->runLoopCallback(); - } -}; + #include "juce_osx_ObjCHelpers.h" + #include "juce_osx_MessageQueue.h" #endif //============================================================================== diff --git a/src/native/mac/juce_mac_Network.mm b/src/native/mac/juce_mac_Network.mm index 7667d4591e..88b8b4283f 100644 --- a/src/native/mac/juce_mac_Network.mm +++ b/src/native/mac/juce_mac_Network.mm @@ -55,10 +55,10 @@ void MACAddress::findAllAddresses (Array& result) } //============================================================================== -bool PlatformUtilities::launchEmailWithAttachments (const String& targetEmailAddress, - const String& emailSubject, - const String& bodyText, - const StringArray& filesToAttach) +bool Process::openEmailWithAttachments (const String& targetEmailAddress, + const String& emailSubject, + const String& bodyText, + const StringArray& filesToAttach) { #if JUCE_IOS //xxx probably need to use MFMailComposeViewController diff --git a/src/native/mac/juce_mac_Strings.mm b/src/native/mac/juce_mac_Strings.mm index 0c9daedf08..882efaf948 100644 --- a/src/native/mac/juce_mac_Strings.mm +++ b/src/native/mac/juce_mac_Strings.mm @@ -28,20 +28,7 @@ #if JUCE_INCLUDED_FILE //============================================================================== -namespace -{ - String nsStringToJuce (NSString* s) - { - return CharPointer_UTF8 ([s UTF8String]); - } - - NSString* juceStringToNS (const String& s) - { - return [NSString stringWithUTF8String: s.toUTF8()]; - } -} - -String PlatformUtilities::cfStringToJuceString (CFStringRef cfString) +String String::fromCFString (CFStringRef cfString) { if (cfString == 0) return String::empty; @@ -54,19 +41,18 @@ String PlatformUtilities::cfStringToJuceString (CFStringRef cfString) return String (CharPointer_UTF16 ((const CharPointer_UTF16::CharType*) u.getData())); } -CFStringRef PlatformUtilities::juceStringToCFString (const String& s) +CFStringRef String::toCFString() const { - CharPointer_UTF16 utf16 (s.toUTF16()); - + CharPointer_UTF16 utf16 (toUTF16()); return CFStringCreateWithCharacters (kCFAllocatorDefault, (const UniChar*) utf16.getAddress(), utf16.length()); } -String PlatformUtilities::convertToPrecomposedUnicode (const String& s) +String String::convertToPrecomposedUnicode() const { -#if JUCE_IOS + #if JUCE_IOS JUCE_AUTORELEASEPOOL - return nsStringToJuce ([juceStringToNS (s) precomposedStringWithCanonicalMapping]); -#else + return nsStringToJuce ([juceStringToNS (*this) precomposedStringWithCanonicalMapping]); + #else UnicodeMapping map; map.unicodeEncoding = CreateTextEncoding (kTextEncodingUnicodeDefault, @@ -84,7 +70,7 @@ String PlatformUtilities::convertToPrecomposedUnicode (const String& s) if (CreateUnicodeToTextInfo (&map, &conversionInfo) == noErr) { - const int bytesNeeded = CharPointer_UTF16::getBytesRequiredFor (s.getCharPointer()); + const int bytesNeeded = CharPointer_UTF16::getBytesRequiredFor (getCharPointer()); HeapBlock tempOut; tempOut.calloc (bytesNeeded + 4); @@ -93,7 +79,7 @@ String PlatformUtilities::convertToPrecomposedUnicode (const String& s) ByteCount outputBufferSize = 0; if (ConvertFromUnicodeToText (conversionInfo, - bytesNeeded, (ConstUniCharArrayPtr) s.toUTF16().getAddress(), + bytesNeeded, (ConstUniCharArrayPtr) toUTF16().getAddress(), kUnicodeDefaultDirectionMask, 0, 0, 0, 0, bytesNeeded, &bytesRead, @@ -106,38 +92,7 @@ String PlatformUtilities::convertToPrecomposedUnicode (const String& s) } return result; -#endif -} - -//============================================================================== -#if ! JUCE_ONLY_BUILD_CORE_LIBRARY - -void SystemClipboard::copyTextToClipboard (const String& text) -{ - #if JUCE_IOS - [[UIPasteboard generalPasteboard] setValue: juceStringToNS (text) - forPasteboardType: @"public.text"]; - #else - [[NSPasteboard generalPasteboard] declareTypes: [NSArray arrayWithObject: NSStringPboardType] - owner: nil]; - - [[NSPasteboard generalPasteboard] setString: juceStringToNS (text) - forType: NSStringPboardType]; - #endif -} - -String SystemClipboard::getTextFromClipboard() -{ - #if JUCE_IOS - NSString* text = [[UIPasteboard generalPasteboard] valueForPasteboardType: @"public.text"]; - #else - NSString* text = [[NSPasteboard generalPasteboard] stringForType: NSStringPboardType]; #endif - - return text == nil ? String::empty - : nsStringToJuce (text); } #endif - -#endif diff --git a/src/native/mac/juce_mac_SystemStats.mm b/src/native/mac/juce_mac_SystemStats.mm index e33227a793..76f2cc598d 100644 --- a/src/native/mac/juce_mac_SystemStats.mm +++ b/src/native/mac/juce_mac_SystemStats.mm @@ -110,7 +110,7 @@ String SystemStats::getOperatingSystemName() } #if ! JUCE_IOS -int PlatformUtilities::getOSXMinorVersionNumber() +int SystemStats::getOSXMinorVersionNumber() { SInt32 versionMinor = 0; OSErr err = Gestalt (gestaltSystemVersionMinor, &versionMinor); @@ -127,7 +127,7 @@ bool SystemStats::isOperatingSystem64Bit() #elif JUCE_64BIT return true; #else - return PlatformUtilities::getOSXMinorVersionNumber() >= 6; + return getOSXMinorVersionNumber() >= 6; #endif } @@ -239,9 +239,4 @@ int SystemStats::getPageSize() return (int) NSPageSize(); } -void PlatformUtilities::fpuReset() -{ -} - - #endif diff --git a/src/native/mac/juce_mac_Threads.mm b/src/native/mac/juce_mac_Threads.mm index 5c27c266c5..c477741b6d 100644 --- a/src/native/mac/juce_mac_Threads.mm +++ b/src/native/mac/juce_mac_Threads.mm @@ -63,4 +63,23 @@ 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/mac/juce_osx_MessageQueue.h b/src/native/mac/juce_osx_MessageQueue.h new file mode 100644 index 0000000000..fdc8b9642e --- /dev/null +++ b/src/native/mac/juce_osx_MessageQueue.h @@ -0,0 +1,97 @@ +/* + ============================================================================== + + 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_OSX_MESSAGEQUEUE_JUCEHEADER__ +#define __JUCE_OSX_MESSAGEQUEUE_JUCEHEADER__ + +//============================================================================== +/* An internal message pump class used in OSX and iOS. */ +class MessageQueue +{ +public: + MessageQueue() + { + #if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_4 && ! JUCE_IOS + runLoop = CFRunLoopGetMain(); + #else + runLoop = CFRunLoopGetCurrent(); + #endif + + CFRunLoopSourceContext sourceContext = { 0 }; + sourceContext.info = this; + sourceContext.perform = runLoopSourceCallback; + runLoopSource = CFRunLoopSourceCreate (kCFAllocatorDefault, 1, &sourceContext); + CFRunLoopAddSource (runLoop, runLoopSource, kCFRunLoopCommonModes); + } + + ~MessageQueue() + { + CFRunLoopRemoveSource (runLoop, runLoopSource, kCFRunLoopCommonModes); + CFRunLoopSourceInvalidate (runLoopSource); + CFRelease (runLoopSource); + } + + void post (Message* const message) + { + messages.add (message); + CFRunLoopSourceSignal (runLoopSource); + CFRunLoopWakeUp (runLoop); + } + +private: + ReferenceCountedArray messages; + CriticalSection lock; + CFRunLoopRef runLoop; + CFRunLoopSourceRef runLoopSource; + + bool deliverNextMessage() + { + const Message::Ptr nextMessage (messages.removeAndReturn (0)); + + if (nextMessage == nullptr) + return false; + + JUCE_AUTORELEASEPOOL + MessageManager::getInstance()->deliverMessage (nextMessage); + return true; + } + + void runLoopCallback() + { + for (int i = 4; --i >= 0;) + if (! deliverNextMessage()) + return; + + CFRunLoopSourceSignal (runLoopSource); + CFRunLoopWakeUp (runLoop); + } + + static void runLoopSourceCallback (void* info) + { + static_cast (info)->runLoopCallback(); + } +}; + +#endif // __JUCE_OSX_MESSAGEQUEUE_JUCEHEADER__ diff --git a/src/native/mac/juce_osx_ObjCHelpers.h b/src/native/mac/juce_osx_ObjCHelpers.h new file mode 100644 index 0000000000..dbd0894868 --- /dev/null +++ b/src/native/mac/juce_osx_ObjCHelpers.h @@ -0,0 +1,67 @@ +/* + ============================================================================== + + 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_OSX_OBJCHELPERS_JUCEHEADER__ +#define __JUCE_OSX_OBJCHELPERS_JUCEHEADER__ + + +/* This file contains a few helper functions that are used internally but which + need to be kept away from the public headers because they use obj-C symbols. +*/ +namespace +{ + //============================================================================== + String nsStringToJuce (NSString* s) + { + return CharPointer_UTF8 ([s UTF8String]); + } + + NSString* juceStringToNS (const String& s) + { + return [NSString stringWithUTF8String: s.toUTF8()]; + } + + //============================================================================== + template + const Rectangle convertToRectInt (const RectType& r) + { + return Rectangle ((int) r.origin.x, (int) r.origin.y, (int) r.size.width, (int) r.size.height); + } + + template + const Rectangle convertToRectFloat (const RectType& r) + { + return Rectangle (r.origin.x, r.origin.y, r.size.width, r.size.height); + } + + template + CGRect convertToCGRect (const RectType& r) + { + return CGRectMake ((CGFloat) r.getX(), (CGFloat) r.getY(), (CGFloat) r.getWidth(), (CGFloat) r.getHeight()); + } +} + + +#endif // __JUCE_OSX_OBJCHELPERS_JUCEHEADER__ diff --git a/src/native/windows/juce_win32_DirectShowComponent.cpp b/src/native/windows/juce_win32_DirectShowComponent.cpp index 21e8e2d8c6..cfc1dab47a 100644 --- a/src/native/windows/juce_win32_DirectShowComponent.cpp +++ b/src/native/windows/juce_win32_DirectShowComponent.cpp @@ -510,7 +510,7 @@ private: String windowClassName ("JUCE_DIRECTSHOW_"); windowClassName << (int) (Time::currentTimeMillis() & 0x7fffffff); - HINSTANCE moduleHandle = (HINSTANCE) PlatformUtilities::getCurrentModuleInstanceHandle(); + HINSTANCE moduleHandle = (HINSTANCE) Process::getCurrentModuleInstanceHandle(); TCHAR moduleFile [1024] = { 0 }; GetModuleFileName (moduleHandle, moduleFile, 1024); @@ -529,7 +529,7 @@ private: ~NativeWindowClass() { if (atom != 0) - UnregisterClass (getWindowClassName(), (HINSTANCE) PlatformUtilities::getCurrentModuleInstanceHandle()); + UnregisterClass (getWindowClassName(), (HINSTANCE) Process::getCurrentModuleInstanceHandle()); clearSingletonInstance(); } @@ -582,7 +582,7 @@ private: hwnd = CreateWindowEx (exstyle, wc->getWindowClassName(), L"", type, 0, 0, 0, 0, parentToAddTo, 0, - (HINSTANCE) PlatformUtilities::getCurrentModuleInstanceHandle(), 0); + (HINSTANCE) Process::getCurrentModuleInstanceHandle(), 0); if (hwnd != 0) { diff --git a/src/native/windows/juce_win32_Files.cpp b/src/native/windows/juce_win32_Files.cpp index bbc414adc8..2bd1199ed1 100644 --- a/src/native/windows/juce_win32_Files.cpp +++ b/src/native/windows/juce_win32_Files.cpp @@ -518,7 +518,7 @@ File JUCE_CALLTYPE File::getSpecialLocation (const SpecialLocationType type) case currentExecutableFile: case currentApplicationFile: { - HINSTANCE moduleHandle = (HINSTANCE) PlatformUtilities::getCurrentModuleInstanceHandle(); + HINSTANCE moduleHandle = (HINSTANCE) Process::getCurrentModuleInstanceHandle(); WCHAR dest [MAX_PATH + 256]; dest[0] = 0; @@ -689,7 +689,7 @@ bool DirectoryIterator::NativeIterator::next (String& filenameFound, //============================================================================== -bool PlatformUtilities::openDocument (const String& fileName, const String& parameters) +bool Process::openDocument (const String& fileName, const String& parameters) { HINSTANCE hInstance = 0; diff --git a/src/native/windows/juce_win32_Messaging.cpp b/src/native/windows/juce_win32_Messaging.cpp index e933252902..30644414cc 100644 --- a/src/native/windows/juce_win32_Messaging.cpp +++ b/src/native/windows/juce_win32_Messaging.cpp @@ -37,7 +37,7 @@ public: String className ("JUCE_"); className << String::toHexString (Time::getHighResolutionTicks()); - HMODULE moduleHandle = (HMODULE) PlatformUtilities::getCurrentModuleInstanceHandle(); + HMODULE moduleHandle = (HMODULE) Process::getCurrentModuleInstanceHandle(); WNDCLASSEX wc = { 0 }; wc.cbSize = sizeof (wc); diff --git a/src/native/windows/juce_win32_Misc.cpp b/src/native/windows/juce_win32_Misc.cpp index 0358337832..b9524a2ade 100644 --- a/src/native/windows/juce_win32_Misc.cpp +++ b/src/native/windows/juce_win32_Misc.cpp @@ -82,5 +82,35 @@ String SystemClipboard::getTextFromClipboard() return result; } +//============================================================================== +bool juce_IsRunningInWine() +{ + HMODULE ntdll = GetModuleHandle (_T("ntdll.dll")); + return ntdll != 0 && GetProcAddress (ntdll, "wine_get_version") != 0; +} + +//============================================================================== +String JUCE_CALLTYPE Process::getCurrentCommandLineParams() +{ + return String (CharacterFunctions::findEndOfToken (CharPointer_UTF16 (GetCommandLineW()), + CharPointer_UTF16 (L" "), + CharPointer_UTF16 (L"\""))).trimStart(); +} + +//============================================================================== +static void* currentModuleHandle = nullptr; + +void* Process::getCurrentModuleInstanceHandle() noexcept +{ + if (currentModuleHandle == nullptr) + currentModuleHandle = GetModuleHandle (0); + + return currentModuleHandle; +} + +void Process::setCurrentModuleInstanceHandle (void* const newHandle) noexcept +{ + currentModuleHandle = newHandle; +} #endif diff --git a/src/native/windows/juce_win32_NativeCode.cpp b/src/native/windows/juce_win32_NativeCode.cpp index e6c4627c75..c5671be179 100644 --- a/src/native/windows/juce_win32_NativeCode.cpp +++ b/src/native/windows/juce_win32_NativeCode.cpp @@ -49,6 +49,7 @@ BEGIN_JUCE_NAMESPACE #include "../../threads/juce_Process.h" #include "../../threads/juce_Thread.h" #include "../../threads/juce_InterProcessLock.h" +#include "../../threads/juce_DynamicLibrary.h" #include "../../io/files/juce_FileInputStream.h" #include "../../io/files/juce_FileOutputStream.h" #include "../../io/streams/juce_MemoryOutputStream.h" @@ -57,7 +58,6 @@ BEGIN_JUCE_NAMESPACE #include "../../io/files/juce_MemoryMappedFile.h" #include "../../io/network/juce_URL.h" #include "../../io/network/juce_MACAddress.h" -#include "../../core/juce_PlatformUtilities.h" #include "../../text/juce_LocalisedStrings.h" #include "../../utilities/juce_DeletedAtShutdown.h" #include "../../application/juce_Application.h" @@ -93,6 +93,7 @@ BEGIN_JUCE_NAMESPACE #include "../../audio/midi/juce_MidiOutput.h" #include "../../audio/midi/juce_MidiInput.h" #include "../../containers/juce_ScopedValueSetter.h" +#include "../../utilities/juce_WindowsRegistry.h" #include "../common/juce_MidiDataConcatenator.h" //============================================================================== @@ -104,7 +105,7 @@ BEGIN_JUCE_NAMESPACE #include "juce_win32_Threads.cpp" #include "juce_win32_Files.cpp" #include "juce_win32_Network.cpp" -#include "juce_win32_PlatformUtils.cpp" +#include "juce_win32_Registry.cpp" #if ! JUCE_ONLY_BUILD_CORE_LIBRARY #include "juce_win32_Messaging.cpp" diff --git a/src/native/windows/juce_win32_Network.cpp b/src/native/windows/juce_win32_Network.cpp index 566b126e81..aad304291f 100644 --- a/src/native/windows/juce_win32_Network.cpp +++ b/src/native/windows/juce_win32_Network.cpp @@ -442,10 +442,10 @@ void MACAddress::findAllAddresses (Array& result) } //============================================================================== -bool PlatformUtilities::launchEmailWithAttachments (const String& targetEmailAddress, - const String& emailSubject, - const String& bodyText, - const StringArray& filesToAttach) +bool Process::openEmailWithAttachments (const String& targetEmailAddress, + const String& emailSubject, + const String& bodyText, + const StringArray& filesToAttach) { HMODULE h = LoadLibraryA ("MAPI32.dll"); diff --git a/src/native/windows/juce_win32_PlatformUtils.cpp b/src/native/windows/juce_win32_Registry.cpp similarity index 61% rename from src/native/windows/juce_win32_PlatformUtils.cpp rename to src/native/windows/juce_win32_Registry.cpp index ce02b53465..8863cd205d 100644 --- a/src/native/windows/juce_win32_PlatformUtils.cpp +++ b/src/native/windows/juce_win32_Registry.cpp @@ -67,8 +67,7 @@ namespace } } -String PlatformUtilities::getRegistryValue (const String& regValuePath, - const String& defaultValue) +String WindowsRegistry::getValue (const String& regValuePath, const String& defaultValue) { String valueName, result (defaultValue); HKEY k = findKeyForPath (regValuePath, false, valueName); @@ -93,8 +92,7 @@ String PlatformUtilities::getRegistryValue (const String& regValuePath, return result; } -void PlatformUtilities::setRegistryValue (const String& regValuePath, - const String& value) +void WindowsRegistry::setValue (const String& regValuePath, const String& value) { String valueName; HKEY k = findKeyForPath (regValuePath, true, valueName); @@ -109,7 +107,7 @@ void PlatformUtilities::setRegistryValue (const String& regValuePath, } } -bool PlatformUtilities::registryValueExists (const String& regValuePath) +bool WindowsRegistry::valueExists (const String& regValuePath) { bool exists = false; String valueName; @@ -130,7 +128,7 @@ bool PlatformUtilities::registryValueExists (const String& regValuePath) return exists; } -void PlatformUtilities::deleteRegistryValue (const String& regValuePath) +void WindowsRegistry::deleteValue (const String& regValuePath) { String valueName; HKEY k = findKeyForPath (regValuePath, true, valueName); @@ -142,7 +140,7 @@ void PlatformUtilities::deleteRegistryValue (const String& regValuePath) } } -void PlatformUtilities::deleteRegistryKey (const String& regKeyPath) +void WindowsRegistry::deleteKey (const String& regKeyPath) { String valueName; HKEY k = findKeyForPath (regKeyPath, true, valueName); @@ -154,68 +152,22 @@ void PlatformUtilities::deleteRegistryKey (const String& regKeyPath) } } -void PlatformUtilities::registerFileAssociation (const String& fileExtension, - const String& symbolicDescription, - const String& fullDescription, - const File& targetExecutable, - int iconResourceNumber) +void WindowsRegistry::registerFileAssociation (const String& fileExtension, + const String& symbolicDescription, + const String& fullDescription, + const File& targetExecutable, + int iconResourceNumber) { - setRegistryValue ("HKEY_CLASSES_ROOT\\" + fileExtension + "\\", symbolicDescription); + setValue ("HKEY_CLASSES_ROOT\\" + fileExtension + "\\", symbolicDescription); const String key ("HKEY_CLASSES_ROOT\\" + symbolicDescription); if (iconResourceNumber != 0) - setRegistryValue (key + "\\DefaultIcon\\", - targetExecutable.getFullPathName() + "," + String (-iconResourceNumber)); + setValue (key + "\\DefaultIcon\\", + targetExecutable.getFullPathName() + "," + String (-iconResourceNumber)); - setRegistryValue (key + "\\", fullDescription); - setRegistryValue (key + "\\shell\\open\\command\\", targetExecutable.getFullPathName() + " %1"); + setValue (key + "\\", fullDescription); + setValue (key + "\\shell\\open\\command\\", targetExecutable.getFullPathName() + " %1"); } - -//============================================================================== -bool juce_IsRunningInWine() -{ - HMODULE ntdll = GetModuleHandle (_T("ntdll.dll")); - return ntdll != 0 && GetProcAddress (ntdll, "wine_get_version") != 0; -} - -//============================================================================== -String JUCE_CALLTYPE PlatformUtilities::getCurrentCommandLineParams() -{ - return String (CharacterFunctions::findEndOfToken (CharPointer_UTF16 (GetCommandLineW()), - CharPointer_UTF16 (L" "), - CharPointer_UTF16 (L"\""))).trimStart(); -} - -//============================================================================== -static void* currentModuleHandle = nullptr; - -void* PlatformUtilities::getCurrentModuleInstanceHandle() noexcept -{ - if (currentModuleHandle == nullptr) - currentModuleHandle = GetModuleHandle (0); - - return currentModuleHandle; -} - -void PlatformUtilities::setCurrentModuleInstanceHandle (void* const newHandle) noexcept -{ - currentModuleHandle = newHandle; -} - -void PlatformUtilities::fpuReset() -{ - #if JUCE_MSVC - _clearfp(); - #endif -} - -//============================================================================== -void PlatformUtilities::beep() -{ - MessageBeep (MB_OK); -} - - #endif diff --git a/src/native/windows/juce_win32_Threads.cpp b/src/native/windows/juce_win32_Threads.cpp index 8f141458a1..5af9e69f5e 100644 --- a/src/native/windows/juce_win32_Threads.cpp +++ b/src/native/windows/juce_win32_Threads.cpp @@ -312,32 +312,31 @@ void Process::terminate() } //============================================================================== -void* PlatformUtilities::loadDynamicLibrary (const String& name) +bool DynamicLibrary::open (const String& name) { - void* result = nullptr; - JUCE_TRY { - result = LoadLibrary (name.toWideCharPointer()); + handle = LoadLibrary (name.toWideCharPointer()); } JUCE_CATCH_ALL - return result; + return handle != nullptr; } -void PlatformUtilities::freeDynamicLibrary (void* h) +void DynamicLibrary::close() noexcept { JUCE_TRY { - if (h != nullptr) - FreeLibrary ((HMODULE) h); + if (handle != nullptr) + FreeLibrary ((HMODULE) handle); } JUCE_CATCH_ALL } -void* PlatformUtilities::getProcedureEntryPoint (void* h, const String& name) +void* DynamicLibrary::getFunction (const String& functionName) noexcept { - return (h != nullptr) ? (void*) GetProcAddress ((HMODULE) h, name.toUTF8()) : nullptr; // (void* cast is required for mingw) + return handle != nullptr ? (void*) GetProcAddress ((HMODULE) handle, functionName.toUTF8()) // (void* cast is required for mingw) + : nullptr; } diff --git a/src/native/windows/juce_win32_Windowing.cpp b/src/native/windows/juce_win32_Windowing.cpp index 33a23a2f09..b65224cb14 100644 --- a/src/native/windows/juce_win32_Windowing.cpp +++ b/src/native/windows/juce_win32_Windowing.cpp @@ -1030,7 +1030,7 @@ private: String windowClassName ("JUCE_"); windowClassName << (int) (Time::currentTimeMillis() & 0x7fffffff); - HINSTANCE moduleHandle = (HINSTANCE) PlatformUtilities::getCurrentModuleInstanceHandle(); + HINSTANCE moduleHandle = (HINSTANCE) Process::getCurrentModuleInstanceHandle(); TCHAR moduleFile [1024] = { 0 }; GetModuleFileName (moduleHandle, moduleFile, 1024); @@ -1054,7 +1054,7 @@ private: ~WindowClassHolder() { if (ComponentPeer::getNumPeers() == 0) - UnregisterClass (getWindowClassName(), (HINSTANCE) PlatformUtilities::getCurrentModuleInstanceHandle()); + UnregisterClass (getWindowClassName(), (HINSTANCE) Process::getCurrentModuleInstanceHandle()); clearSingletonInstance(); } @@ -1126,7 +1126,7 @@ private: hwnd = CreateWindowEx (exstyle, WindowClassHolder::getInstance()->getWindowClassName(), L"", type, 0, 0, 0, 0, parentToAddTo, 0, - (HINSTANCE) PlatformUtilities::getCurrentModuleInstanceHandle(), 0); + (HINSTANCE) Process::getCurrentModuleInstanceHandle(), 0); #if JUCE_DIRECT2D setCurrentRenderingEngine (1); @@ -2883,6 +2883,12 @@ bool Desktop::isScreenSaverEnabled() noexcept } */ +//============================================================================== +void LookAndFeel::playAlertSound() +{ + MessageBeep (MB_OK); +} + //============================================================================== void Desktop::setKioskComponent (Component* kioskModeComponent, bool enableOrDisable, bool /*allowMenusAndBars*/) { @@ -2937,7 +2943,7 @@ Image juce_createIconForFile (const File& file) Image image; WORD iconNum = 0; - HICON icon = ExtractAssociatedIcon ((HINSTANCE) PlatformUtilities::getCurrentModuleInstanceHandle(), + HICON icon = ExtractAssociatedIcon ((HINSTANCE) Process::getCurrentModuleInstanceHandle(), const_cast (file.getFullPathName().toWideCharPointer()), &iconNum); if (icon != 0) diff --git a/src/text/juce_String.h b/src/text/juce_String.h index d68bb1367a..dabce117e3 100644 --- a/src/text/juce_String.h +++ b/src/text/juce_String.h @@ -1188,6 +1188,22 @@ public: JUCE_DECLARE_NON_COPYABLE (Concatenator); }; + #if JUCE_MAC || JUCE_IOS || DOXYGEN + //============================================================================== + /** MAC ONLY - Creates a String from an OSX CFString. */ + static String fromCFString (CFStringRef cfString); + + /** MAC ONLY - Converts this string to a CFString. + Remember that you must use CFRelease() to free the returned string when you're + finished with it. + */ + CFStringRef toCFString() const; + + /** MAC ONLY - Returns a copy of this string in which any decomposed unicode characters have + been converted to their precomposed equivalents. */ + String convertToPrecomposedUnicode() const; + #endif + private: //============================================================================== CharPointerType text; diff --git a/src/threads/juce_DynamicLibrary.h b/src/threads/juce_DynamicLibrary.h new file mode 100644 index 0000000000..8f5eb99864 --- /dev/null +++ b/src/threads/juce_DynamicLibrary.h @@ -0,0 +1,82 @@ +/* + ============================================================================== + + 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_DYNAMICLIBRARY_JUCEHEADER__ +#define __JUCE_DYNAMICLIBRARY_JUCEHEADER__ + +/** + Handles the opening and closing of DLLs. + + This class can be used to open a DLL and get some function pointers from it. + Since the DLL is freed when this object is deleted, it's handy for managing + library lifetimes using RAII. +*/ +class DynamicLibrary +{ +public: + /** Creates an unopened DynamicLibrary object. + Call open() to actually open one. + */ + DynamicLibrary() noexcept : handle (nullptr) {} + + /** + */ + DynamicLibrary (const String& name) : handle (nullptr) { open (name); } + + /** Destructor. + If a library is currently open, it will be closed when this object is destroyed. + */ + ~DynamicLibrary() { close(); } + + /** Opens a DLL. + The name and the method by which it gets found is of course platform-specific, and + may or may not include a path, depending on the OS. + If a library is already open when this method is called, it will first close the library + before attempting to load the new one. + @returns true if the library was successfully found and opened. + */ + bool open (const String& name); + + /** Releases the currently-open DLL, or has no effect if none was open. */ + void close() noexcept; + + /** 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. + */ + void* getFunction (const String& functionName) noexcept; + + /** Returns the platform-specific native library handle. + You'll need to cast this to whatever is appropriate for the OS that's in use. + */ + void* getNativeHandle() const noexcept { return handle; } + +private: + void* handle; + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DynamicLibrary); +}; + + +#endif // __JUCE_DYNAMICLIBRARY_JUCEHEADER__ diff --git a/src/threads/juce_Process.h b/src/threads/juce_Process.h index 3aeedea7cb..522d2a667c 100644 --- a/src/threads/juce_Process.h +++ b/src/threads/juce_Process.h @@ -93,9 +93,50 @@ public: static bool JUCE_CALLTYPE isRunningUnderDebugger(); + //============================================================================== + /** Tries to launch the OS's default reader application for a given file or URL. */ + static bool openDocument (const String& documentURL, const String& parameters); + + /** Tries to launch the OS's default email application to let the user create a message. */ + static bool openEmailWithAttachments (const String& targetEmailAddress, + const String& emailSubject, + const String& bodyText, + const StringArray& filesToAttach); + + #if JUCE_WINDOWS || DOXYGEN + //============================================================================== + /** WINDOWS ONLY - This returns the HINSTANCE of the current module. + + The return type is a void* to avoid being dependent on windows.h - just cast + it to a HINSTANCE to use it. + + In a normal JUCE application, this will be automatically set to the module + handle of the executable. + + If you've built a DLL and plan to use any JUCE messaging or windowing classes, + you'll need to make sure you call the setCurrentModuleInstanceHandle() + to provide the correct module handle in your DllMain() function, because + the system relies on the correct instance handle when opening windows. + */ + static void* JUCE_CALLTYPE getCurrentModuleInstanceHandle() noexcept; + + /** WINDOWS ONLY - Sets a new module handle to be used by the library. + + The parameter type is a void* to avoid being dependent on windows.h, but it actually + expects a HINSTANCE value. + + @see getCurrentModuleInstanceHandle() + */ + static void JUCE_CALLTYPE setCurrentModuleInstanceHandle (void* newHandle) noexcept; + + /** WINDOWS ONLY - Gets the command-line params as a string. + This is needed to avoid unicode problems with the argc type params. + */ + static String JUCE_CALLTYPE getCurrentCommandLineParams(); + #endif + private: Process(); - JUCE_DECLARE_NON_COPYABLE (Process); }; diff --git a/src/utilities/juce_WindowsRegistry.h b/src/utilities/juce_WindowsRegistry.h new file mode 100644 index 0000000000..5dfeb3e8db --- /dev/null +++ b/src/utilities/juce_WindowsRegistry.h @@ -0,0 +1,87 @@ +/* + ============================================================================== + + 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_WINDOWSREGISTRY_JUCEHEADER__ +#define __JUCE_WINDOWSREGISTRY_JUCEHEADER__ + +#if JUCE_WINDOWS || DOXYGEN + +/** + Contains some static helper functions for manipulating the MS Windows registry + (Only available on Windows, of course!) +*/ +class WindowsRegistry +{ + //============================================================================== + /** Returns a string from the registry. + + The path is a string for the entire path of a value in the registry, + e.g. "HKEY_CURRENT_USER\Software\foo\bar" + */ + static String getValue (const String& regValuePath, + const String& defaultValue = String::empty); + + /** Sets a registry value as a string. + + This will take care of creating any groups needed to get to the given + registry value. + */ + static void setValue (const String& regValuePath, + const String& value); + + /** Returns true if the given value exists in the registry. */ + static bool valueExists (const String& regValuePath); + + /** Deletes a registry value. */ + static void deleteValue (const String& regValuePath); + + /** Deletes a registry key (which is registry-talk for 'folder'). */ + static void deleteKey (const String& regKeyPath); + + /** Creates a file association in the registry. + + This lets you set the executable that should be launched by a given file extension. + @param fileExtension the file extension to associate, including the + initial dot, e.g. ".txt" + @param symbolicDescription a space-free short token to identify the file type + @param fullDescription a human-readable description of the file type + @param targetExecutable the executable that should be launched + @param iconResourceNumber the icon that gets displayed for the file type will be + found by looking up this resource number in the + executable. Pass 0 here to not use an icon + */ + static void registerFileAssociation (const String& fileExtension, + const String& symbolicDescription, + const String& fullDescription, + const File& targetExecutable, + int iconResourceNumber); + +private: + WindowsRegistry(); + JUCE_DECLARE_NON_COPYABLE (WindowsRegistry); +}; + +#endif +#endif // __JUCE_WINDOWSREGISTRY_JUCEHEADER__