@@ -1041,6 +1041,10 @@ | |||||
RelativePath="..\..\..\src\core\juce_SystemStats.h" | RelativePath="..\..\..\src\core\juce_SystemStats.h" | ||||
> | > | ||||
</File> | </File> | ||||
<File | |||||
RelativePath="..\..\..\src\core\juce_TargetPlatform.h" | |||||
> | |||||
</File> | |||||
<File | <File | ||||
RelativePath="..\..\..\src\core\juce_Time.cpp" | RelativePath="..\..\..\src\core\juce_Time.cpp" | ||||
> | > | ||||
@@ -120,10 +120,10 @@ NPError NP_GetValue (void* future, NPPVariable variable, void* value) | |||||
return NPP_GetValue ((NPP_t*) future, variable, value); | return NPP_GetValue ((NPP_t*) future, variable, value); | ||||
} | } | ||||
#if JUCE_WIN32 || JUCE_MAC | |||||
#if JUCE_WINDOWS || JUCE_MAC | |||||
NPError OSCALL NP_GetEntryPoints (NPPluginFuncs* funcs) | NPError OSCALL NP_GetEntryPoints (NPPluginFuncs* funcs) | ||||
{ | { | ||||
#if JUCE_WIN32 | |||||
#if JUCE_WINDOWS | |||||
#pragma EXPORTED_FUNCTION | #pragma EXPORTED_FUNCTION | ||||
#endif | #endif | ||||
@@ -162,7 +162,7 @@ NPError OSCALL NP_Initialize (NPNetscapeFuncs* funcs | |||||
#endif | #endif | ||||
) | ) | ||||
{ | { | ||||
#if JUCE_WIN32 | |||||
#if JUCE_WINDOWS | |||||
#pragma EXPORTED_FUNCTION | #pragma EXPORTED_FUNCTION | ||||
#endif | #endif | ||||
@@ -201,7 +201,7 @@ NPError OSCALL NP_Initialize (NPNetscapeFuncs* funcs | |||||
NPError OSCALL NP_Shutdown() | NPError OSCALL NP_Shutdown() | ||||
{ | { | ||||
#if JUCE_WIN32 | |||||
#if JUCE_WINDOWS | |||||
#pragma EXPORTED_FUNCTION | #pragma EXPORTED_FUNCTION | ||||
#endif | #endif | ||||
@@ -269,7 +269,7 @@ public: | |||||
child (0) | child (0) | ||||
{ | { | ||||
log ("BrowserPluginHolderComponent created"); | log ("BrowserPluginHolderComponent created"); | ||||
#if JUCE_WIN32 | |||||
#if JUCE_WINDOWS | |||||
parentHWND = 0; | parentHWND = 0; | ||||
oldWinProc = 0; | oldWinProc = 0; | ||||
#else | #else | ||||
@@ -314,7 +314,7 @@ public: | |||||
private: | private: | ||||
//============================================================================== | //============================================================================== | ||||
#if JUCE_WIN32 | |||||
#if JUCE_WINDOWS | |||||
HWND parentHWND; | HWND parentHWND; | ||||
WNDPROC oldWinProc; | WNDPROC oldWinProc; | ||||
@@ -1160,7 +1160,7 @@ const String BrowserPluginComponent::getBrowserVersion() const | |||||
} | } | ||||
//============================================================================== | //============================================================================== | ||||
#if JUCE_WIN32 | |||||
#if JUCE_WINDOWS | |||||
extern const String getActiveXBrowserURL (const BrowserPluginComponent* comp); | extern const String getActiveXBrowserURL (const BrowserPluginComponent* comp); | ||||
#endif | #endif | ||||
@@ -1168,7 +1168,7 @@ const String BrowserPluginComponent::getBrowserURL() const | |||||
{ | { | ||||
String result; | String result; | ||||
#if JUCE_WIN32 | |||||
#if JUCE_WINDOWS | |||||
result = getActiveXBrowserURL (this); | result = getActiveXBrowserURL (this); | ||||
if (result.isNotEmpty()) | if (result.isNotEmpty()) | ||||
@@ -321,9 +321,9 @@ | |||||
GCC_VERSION = 4.0; | GCC_VERSION = 4.0; | ||||
GCC_WARN_ABOUT_RETURN_TYPE = YES; | GCC_WARN_ABOUT_RETURN_TYPE = YES; | ||||
GCC_WARN_UNUSED_VARIABLE = YES; | GCC_WARN_UNUSED_VARIABLE = YES; | ||||
MACOSX_DEPLOYMENT_TARGET = 10.4; | |||||
ONLY_ACTIVE_ARCH = YES; | ONLY_ACTIVE_ARCH = YES; | ||||
PREBINDING = NO; | PREBINDING = NO; | ||||
SDKROOT = macosx10.4; | |||||
}; | }; | ||||
name = Debug; | name = Debug; | ||||
}; | }; | ||||
@@ -26,7 +26,6 @@ | |||||
#include "jucedemo_headers.h" | #include "jucedemo_headers.h" | ||||
#include "MainDemoWindow.h" | #include "MainDemoWindow.h" | ||||
//============================================================================== | //============================================================================== | ||||
class JUCEDemoApplication : public JUCEApplication | class JUCEDemoApplication : public JUCEApplication | ||||
{ | { | ||||
@@ -63,7 +62,13 @@ public: | |||||
{ | { | ||||
// just create the main window... | // just create the main window... | ||||
theMainWindow = new MainDemoWindow(); | theMainWindow = new MainDemoWindow(); | ||||
#if JUCE_IPHONE | |||||
theMainWindow->setVisible (true); | |||||
theMainWindow->setBounds (0, 20, 320, 460); | |||||
#else | |||||
theMainWindow->centreWithSize (700, 600); | theMainWindow->centreWithSize (700, 600); | ||||
#endif | |||||
theMainWindow->setVisible (true); | theMainWindow->setVisible (true); | ||||
// this little function just demonstrates a few system info calls | // this little function just demonstrates a few system info calls | ||||
@@ -1262,6 +1262,8 @@ public: | |||||
= AlertWindow::showOkCancelBox (AlertWindow::QuestionIcon, | = AlertWindow::showOkCancelBox (AlertWindow::QuestionIcon, | ||||
T("This is an ok/cancel AlertWindow"), | T("This is an ok/cancel AlertWindow"), | ||||
T("And this is the AlertWindow's message. Blah blah blah blah blah blah blah blah blah blah blah blah blah.")); | T("And this is the AlertWindow's message. Blah blah blah blah blah blah blah blah blah blah blah blah blah.")); | ||||
(void) userPickedOk; // (just avoids a compiler warning about unused variables) | |||||
} | } | ||||
else if (result == 111) | else if (result == 111) | ||||
{ | { | ||||
@@ -1285,6 +1287,8 @@ public: | |||||
{ | { | ||||
// this is the item they chose in the drop-down list.. | // this is the item they chose in the drop-down list.. | ||||
const int optionIndexChosen = w.getComboBoxComponent (T("option"))->getSelectedItemIndex(); | const int optionIndexChosen = w.getComboBoxComponent (T("option"))->getSelectedItemIndex(); | ||||
(void) optionIndexChosen; // (just avoids a compiler warning about unused variables) | |||||
// this is the text they entered.. | // this is the text they entered.. | ||||
String text = w.getTextEditorContents (T("text")); | String text = w.getTextEditorContents (T("text")); | ||||
@@ -38,6 +38,8 @@ | |||||
to an explicit 0 or 1 in here. | to an explicit 0 or 1 in here. | ||||
*/ | */ | ||||
#include "../../../src/core/juce_TargetPlatform.h" | |||||
//#define JUCE_ONLY_BUILD_CORE_LIBRARY 1 | //#define JUCE_ONLY_BUILD_CORE_LIBRARY 1 | ||||
//#define JUCE_FORCE_DEBUG 1 | //#define JUCE_FORCE_DEBUG 1 | ||||
//#define JUCE_LOG_ASSERTIONS 1 | //#define JUCE_LOG_ASSERTIONS 1 | ||||
@@ -45,12 +47,17 @@ | |||||
//#define JUCE_ASIO 1 | //#define JUCE_ASIO 1 | ||||
//#define JUCE_ALSA 1 | //#define JUCE_ALSA 1 | ||||
#ifdef _MSC_VER | |||||
#if JUCE_WINDOWS || JUCE_IPHONE | |||||
#define JUCE_QUICKTIME 0 // (This is disabled here by default because on windows it requires the QT SDK, | #define JUCE_QUICKTIME 0 // (This is disabled here by default because on windows it requires the QT SDK, | ||||
// but you can turn it on again if you've got the SDK) | // but you can turn it on again if you've got the SDK) | ||||
#endif | #endif | ||||
#define JUCE_OPENGL 1 | |||||
#if JUCE_IPHONE | |||||
#define JUCE_OPENGL 0 | |||||
#else | |||||
#define JUCE_OPENGL 1 | |||||
#endif | |||||
//#define JUCE_USE_FLAC 1 | //#define JUCE_USE_FLAC 1 | ||||
//#define JUCE_USE_OGGVORBIS 1 | //#define JUCE_USE_OGGVORBIS 1 | ||||
//#define JUCE_USE_CDBURNER 1 | //#define JUCE_USE_CDBURNER 1 | ||||
@@ -60,8 +67,8 @@ | |||||
#define JUCE_PLUGINHOST_VST 0 | #define JUCE_PLUGINHOST_VST 0 | ||||
#define JUCE_PLUGINHOST_AU 0 | #define JUCE_PLUGINHOST_AU 0 | ||||
#ifndef LINUX | |||||
#define JUCE_USE_CAMERA 1 | |||||
#if JUCE_LINUX || JUCE_IPHONE | |||||
#define JUCE_USE_CAMERA 0 | |||||
#endif | #endif | ||||
//#define JUCE_CHECK_MEMORY_LEAKS 1 | //#define JUCE_CHECK_MEMORY_LEAKS 1 | ||||
@@ -45,7 +45,7 @@ BEGIN_JUCE_NAMESPACE | |||||
#pragma warning (disable: 4786) // (old vc6 warning about long class names) | #pragma warning (disable: 4786) // (old vc6 warning about long class names) | ||||
#endif | #endif | ||||
#if JUCE_MAC | |||||
#if JUCE_MAC || JUCE_IPHONE | |||||
#pragma align=natural | #pragma align=natural | ||||
#endif | #endif | ||||
@@ -65,7 +65,7 @@ BEGIN_JUCE_NAMESPACE | |||||
#pragma pack (pop) | #pragma pack (pop) | ||||
#endif | #endif | ||||
#if JUCE_MAC | |||||
#if JUCE_MAC || JUCE_IPHONE | |||||
#pragma align=reset | #pragma align=reset | ||||
#endif | #endif | ||||
@@ -102,7 +102,7 @@ END_JUCE_NAMESPACE | |||||
files, you may need to use the juce_WithoutMacros.h file - see the comments in that | files, you may need to use the juce_WithoutMacros.h file - see the comments in that | ||||
file for more information. | file for more information. | ||||
*/ | */ | ||||
#if JUCE_WIN32 && ! JUCE_DONT_DEFINE_MACROS | |||||
#if JUCE_WINDOWS && ! JUCE_DONT_DEFINE_MACROS | |||||
#define Rectangle JUCE_NAMESPACE::Rectangle | #define Rectangle JUCE_NAMESPACE::Rectangle | ||||
#endif | #endif | ||||
#endif | #endif | ||||
@@ -176,7 +176,7 @@ END_JUCE_NAMESPACE | |||||
return JUCE_NAMESPACE::JUCEApplication::main (argc, argv, new AppClass()); \ | return JUCE_NAMESPACE::JUCEApplication::main (argc, argv, new AppClass()); \ | ||||
} | } | ||||
#elif JUCE_WIN32 | |||||
#elif JUCE_WINDOWS | |||||
#ifdef _CONSOLE | #ifdef _CONSOLE | ||||
#define START_JUCE_APPLICATION(AppClass) \ | #define START_JUCE_APPLICATION(AppClass) \ | ||||
@@ -101,7 +101,7 @@ | |||||
On Windows, if you enable this, you'll need to have the QuickTime SDK | On Windows, if you enable this, you'll need to have the QuickTime SDK | ||||
installed, and its header files will need to be on your include path. | installed, and its header files will need to be on your include path. | ||||
*/ | */ | ||||
#if ! (defined (JUCE_QUICKTIME) || defined (LINUX) || defined (TARGET_OS_IPHONE) || defined (TARGET_IPHONE_SIMULATOR) || (defined (_WIN32) && ! defined (_MSC_VER))) | |||||
#if ! (defined (JUCE_QUICKTIME) || JUCE_LINUX || JUCE_IPHONE || (JUCE_WINDOWS && ! JUCE_MSVC)) | |||||
#define JUCE_QUICKTIME 1 | #define JUCE_QUICKTIME 1 | ||||
#endif | #endif | ||||
@@ -133,7 +133,7 @@ | |||||
/** This flag lets you enable support for CD-burning. You might want to disable | /** This flag lets you enable support for CD-burning. You might want to disable | ||||
it to build without the MS SDK under windows. | it to build without the MS SDK under windows. | ||||
*/ | */ | ||||
#if (! defined (JUCE_USE_CDBURNER)) && ! (defined (_WIN32) && ! defined (_MSC_VER)) | |||||
#if (! defined (JUCE_USE_CDBURNER)) && ! (JUCE_WINDOWS && ! JUCE_MSVC) | |||||
#define JUCE_USE_CDBURNER 1 | #define JUCE_USE_CDBURNER 1 | ||||
#endif | #endif | ||||
@@ -72,6 +72,147 @@ | |||||
*/ | */ | ||||
#define JUCE_VERSION ((JUCE_MAJOR_VERSION << 16) + (JUCE_MINOR_VERSION << 8)) | #define JUCE_VERSION ((JUCE_MAJOR_VERSION << 16) + (JUCE_MINOR_VERSION << 8)) | ||||
/********* Start of inlined file: juce_TargetPlatform.h *********/ | |||||
#ifndef __JUCE_TARGETPLATFORM_JUCEHEADER__ | |||||
#define __JUCE_TARGETPLATFORM_JUCEHEADER__ | |||||
/* This file figures out which platform is being built, and defines some macros | |||||
that the rest of the code can use for OS-specific compilation. | |||||
Macros that will be set here are: | |||||
- One of JUCE_WINDOWS, JUCE_MAC or JUCE_LINUX. | |||||
- Either JUCE_32BIT or JUCE_64BIT, depending on the architecture. | |||||
- Either JUCE_LITTLE_ENDIAN or JUCE_BIG_ENDIAN. | |||||
- Either JUCE_INTEL or JUCE_PPC | |||||
- Either JUCE_GCC or JUCE_MSVC | |||||
*/ | |||||
#if (defined (_WIN32) || defined (_WIN64)) | |||||
#define JUCE_WIN32 1 | |||||
#define JUCE_WINDOWS 1 | |||||
#elif defined (LINUX) || defined (__linux__) | |||||
#define JUCE_LINUX 1 | |||||
#elif defined(__APPLE_CPP__) || defined(__APPLE_CC__) | |||||
#include <CoreFoundation/CoreFoundation.h> // (needed to find out what platform we're using) | |||||
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR | |||||
#define JUCE_IPHONE 1 | |||||
#else | |||||
#define JUCE_MAC 1 | |||||
#endif | |||||
#else | |||||
#error "Unknown platform!" | |||||
#endif | |||||
#if JUCE_WINDOWS | |||||
#ifdef _MSC_VER | |||||
#ifdef _WIN64 | |||||
#define JUCE_64BIT 1 | |||||
#else | |||||
#define JUCE_32BIT 1 | |||||
#endif | |||||
#endif | |||||
#ifdef _DEBUG | |||||
#define JUCE_DEBUG 1 | |||||
#endif | |||||
/** If defined, this indicates that the processor is little-endian. */ | |||||
#define JUCE_LITTLE_ENDIAN 1 | |||||
#define JUCE_INTEL 1 | |||||
#endif | |||||
#if JUCE_MAC | |||||
#ifndef NDEBUG | |||||
#define JUCE_DEBUG 1 | |||||
#endif | |||||
#ifdef __LITTLE_ENDIAN__ | |||||
#define JUCE_LITTLE_ENDIAN 1 | |||||
#else | |||||
#define JUCE_BIG_ENDIAN 1 | |||||
#endif | |||||
#if defined (__ppc__) || defined (__ppc64__) | |||||
#define JUCE_PPC 1 | |||||
#else | |||||
#define JUCE_INTEL 1 | |||||
#endif | |||||
#ifdef __LP64__ | |||||
#define JUCE_64BIT 1 | |||||
#else | |||||
#define JUCE_32BIT 1 | |||||
#endif | |||||
#if (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_3) | |||||
#error "Building for OSX 10.2 is no longer supported!" | |||||
#endif | |||||
#if (! defined (MAC_OS_X_VERSION_10_4)) || (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_4) | |||||
#define MACOS_10_3_OR_EARLIER 1 | |||||
#endif | |||||
#if (! defined (MAC_OS_X_VERSION_10_5)) || (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5) | |||||
#define MACOS_10_4_OR_EARLIER 1 | |||||
#endif | |||||
#endif | |||||
#if JUCE_IPHONE | |||||
#ifndef NDEBUG | |||||
#define JUCE_DEBUG 1 | |||||
#endif | |||||
#ifdef __LITTLE_ENDIAN__ | |||||
#define JUCE_LITTLE_ENDIAN 1 | |||||
#else | |||||
#define JUCE_BIG_ENDIAN 1 | |||||
#endif | |||||
#endif | |||||
#if JUCE_LINUX | |||||
#ifdef _DEBUG | |||||
#define JUCE_DEBUG 1 | |||||
#endif | |||||
// Allow override for big-endian Linux platforms | |||||
#ifndef JUCE_BIG_ENDIAN | |||||
#define JUCE_LITTLE_ENDIAN 1 | |||||
#endif | |||||
#if defined (__LP64__) || defined (_LP64) | |||||
#define JUCE_64BIT 1 | |||||
#else | |||||
#define JUCE_32BIT 1 | |||||
#endif | |||||
#define JUCE_INTEL 1 | |||||
#endif | |||||
// Compiler type macros. | |||||
#ifdef __GNUC__ | |||||
#define JUCE_GCC 1 | |||||
#elif defined (_MSC_VER) | |||||
#define JUCE_MSVC 1 | |||||
#if _MSC_VER >= 1400 | |||||
#define JUCE_USE_INTRINSICS 1 | |||||
#endif | |||||
#else | |||||
#error unknown compiler | |||||
#endif | |||||
#endif // __JUCE_PLATFORMDEFS_JUCEHEADER__ | |||||
/********* End of inlined file: juce_TargetPlatform.h *********/ | |||||
// (sets up the various JUCE_WINDOWS, JUCE_MAC, etc flags) | |||||
/********* Start of inlined file: juce_Config.h *********/ | /********* Start of inlined file: juce_Config.h *********/ | ||||
#ifndef __JUCE_CONFIG_JUCEHEADER__ | #ifndef __JUCE_CONFIG_JUCEHEADER__ | ||||
#define __JUCE_CONFIG_JUCEHEADER__ | #define __JUCE_CONFIG_JUCEHEADER__ | ||||
@@ -145,7 +286,7 @@ | |||||
On Windows, if you enable this, you'll need to have the QuickTime SDK | On Windows, if you enable this, you'll need to have the QuickTime SDK | ||||
installed, and its header files will need to be on your include path. | installed, and its header files will need to be on your include path. | ||||
*/ | */ | ||||
#if ! (defined (JUCE_QUICKTIME) || defined (LINUX) || defined (TARGET_OS_IPHONE) || defined (TARGET_IPHONE_SIMULATOR) || (defined (_WIN32) && ! defined (_MSC_VER))) | |||||
#if ! (defined (JUCE_QUICKTIME) || JUCE_LINUX || JUCE_IPHONE || (JUCE_WINDOWS && ! JUCE_MSVC)) | |||||
#define JUCE_QUICKTIME 1 | #define JUCE_QUICKTIME 1 | ||||
#endif | #endif | ||||
@@ -173,7 +314,7 @@ | |||||
/** This flag lets you enable support for CD-burning. You might want to disable | /** This flag lets you enable support for CD-burning. You might want to disable | ||||
it to build without the MS SDK under windows. | it to build without the MS SDK under windows. | ||||
*/ | */ | ||||
#if (! defined (JUCE_USE_CDBURNER)) && ! (defined (_WIN32) && ! defined (_MSC_VER)) | |||||
#if (! defined (JUCE_USE_CDBURNER)) && ! (JUCE_WINDOWS && ! JUCE_MSVC) | |||||
#define JUCE_USE_CDBURNER 1 | #define JUCE_USE_CDBURNER 1 | ||||
#endif | #endif | ||||
@@ -300,131 +441,13 @@ | |||||
#define END_JUCE_NAMESPACE | #define END_JUCE_NAMESPACE | ||||
#endif | #endif | ||||
// This sets up the JUCE_WIN32, JUCE_MAC, or JUCE_LINUX macros | |||||
/********* Start of inlined file: juce_PlatformDefs.h *********/ | /********* Start of inlined file: juce_PlatformDefs.h *********/ | ||||
#ifndef __JUCE_PLATFORMDEFS_JUCEHEADER__ | #ifndef __JUCE_PLATFORMDEFS_JUCEHEADER__ | ||||
#define __JUCE_PLATFORMDEFS_JUCEHEADER__ | #define __JUCE_PLATFORMDEFS_JUCEHEADER__ | ||||
/* This file figures out which platform is being built, and defines some macros | |||||
that the rest of the code can use for OS-specific compilation. | |||||
Macros that will be set here are: | |||||
- One of JUCE_WIN32, JUCE_MAC or JUCE_LINUX. | |||||
- Either JUCE_32BIT or JUCE_64BIT, depending on the architecture. | |||||
- Either JUCE_LITTLE_ENDIAN or JUCE_BIG_ENDIAN. | |||||
- Either JUCE_INTEL or JUCE_PPC | |||||
- Either JUCE_GCC or JUCE_MSVC | |||||
It also includes a set of macros for debug console output and assertions. | |||||
/* This file defines miscellaneous macros for debugging, assertions, etc. | |||||
*/ | */ | ||||
#if (defined (_WIN32) || defined (_WIN64)) | |||||
#define JUCE_WIN32 1 | |||||
#else | |||||
#if defined (LINUX) || defined (__linux__) | |||||
#define JUCE_LINUX 1 | |||||
#elif TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR | |||||
#define JUCE_IPHONE 1 | |||||
#else | |||||
#define JUCE_MAC 1 | |||||
#endif | |||||
#endif | |||||
#if JUCE_WIN32 | |||||
#ifdef _MSC_VER | |||||
#ifdef _WIN64 | |||||
#define JUCE_64BIT 1 | |||||
#else | |||||
#define JUCE_32BIT 1 | |||||
#endif | |||||
#endif | |||||
#ifdef _DEBUG | |||||
#define JUCE_DEBUG 1 | |||||
#endif | |||||
/** If defined, this indicates that the processor is little-endian. */ | |||||
#define JUCE_LITTLE_ENDIAN 1 | |||||
#define JUCE_INTEL 1 | |||||
#endif | |||||
#if JUCE_MAC | |||||
#include <CoreFoundation/CoreFoundation.h> | |||||
#ifndef NDEBUG | |||||
#define JUCE_DEBUG 1 | |||||
#endif | |||||
#ifdef __LITTLE_ENDIAN__ | |||||
#define JUCE_LITTLE_ENDIAN 1 | |||||
#else | |||||
#define JUCE_BIG_ENDIAN 1 | |||||
#endif | |||||
#if defined (__ppc__) || defined (__ppc64__) | |||||
#define JUCE_PPC 1 | |||||
#else | |||||
#define JUCE_INTEL 1 | |||||
#endif | |||||
#ifdef __LP64__ | |||||
#define JUCE_64BIT 1 | |||||
#else | |||||
#define JUCE_32BIT 1 | |||||
#endif | |||||
#if (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_3) | |||||
#error "Building for OSX 10.2 is no longer supported!" | |||||
#endif | |||||
#if (! defined (MAC_OS_X_VERSION_10_4)) || (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_4) | |||||
#define MACOS_10_3_OR_EARLIER 1 | |||||
#endif | |||||
#if (! defined (MAC_OS_X_VERSION_10_5)) || (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5) | |||||
#define MACOS_10_4_OR_EARLIER 1 | |||||
#endif | |||||
#endif | |||||
#if JUCE_IPHONE | |||||
#include <CoreFoundation/CoreFoundation.h> | |||||
#ifndef NDEBUG | |||||
#define JUCE_DEBUG 1 | |||||
#endif | |||||
#ifdef __LITTLE_ENDIAN__ | |||||
#define JUCE_LITTLE_ENDIAN 1 | |||||
#else | |||||
#define JUCE_BIG_ENDIAN 1 | |||||
#endif | |||||
#endif | |||||
#if JUCE_LINUX | |||||
#ifdef _DEBUG | |||||
#define JUCE_DEBUG 1 | |||||
#endif | |||||
// Allow override for big-endian Linux platforms | |||||
#ifndef JUCE_BIG_ENDIAN | |||||
#define JUCE_LITTLE_ENDIAN 1 | |||||
#endif | |||||
#if defined (__LP64__) || defined (_LP64) | |||||
#define JUCE_64BIT 1 | |||||
#else | |||||
#define JUCE_32BIT 1 | |||||
#endif | |||||
#define JUCE_INTEL 1 | |||||
#endif | |||||
#ifdef JUCE_FORCE_DEBUG | #ifdef JUCE_FORCE_DEBUG | ||||
#undef JUCE_DEBUG | #undef JUCE_DEBUG | ||||
@@ -433,20 +456,6 @@ | |||||
#endif | #endif | ||||
#endif | #endif | ||||
// Compiler type macros. | |||||
#ifdef __GNUC__ | |||||
#define JUCE_GCC 1 | |||||
#elif defined (_MSC_VER) | |||||
#define JUCE_MSVC 1 | |||||
#if _MSC_VER >= 1400 | |||||
#define JUCE_USE_INTRINSICS 1 | |||||
#endif | |||||
#else | |||||
#error unknown compiler | |||||
#endif | |||||
/** This macro defines the C calling convention used as the standard for Juce calls. */ | /** This macro defines the C calling convention used as the standard for Juce calls. */ | ||||
#if JUCE_MSVC | #if JUCE_MSVC | ||||
#define JUCE_CALLTYPE __stdcall | #define JUCE_CALLTYPE __stdcall | ||||
@@ -487,7 +496,7 @@ | |||||
// Assertions.. | // Assertions.. | ||||
#if JUCE_WIN32 || DOXYGEN | |||||
#if JUCE_WINDOWS || DOXYGEN | |||||
#if JUCE_USE_INTRINSICS | #if JUCE_USE_INTRINSICS | ||||
#pragma intrinsic (__debugbreak) | #pragma intrinsic (__debugbreak) | ||||
@@ -511,7 +520,7 @@ | |||||
#elif JUCE_MAC | #elif JUCE_MAC | ||||
#define juce_breakDebugger Debugger(); | #define juce_breakDebugger Debugger(); | ||||
#elif JUCE_IPHONE | #elif JUCE_IPHONE | ||||
#define juce_breakDebugger assert (false); | |||||
#define juce_breakDebugger kill (0, SIGTRAP); | |||||
#elif JUCE_LINUX | #elif JUCE_LINUX | ||||
#define juce_breakDebugger kill (0, SIGTRAP); | #define juce_breakDebugger kill (0, SIGTRAP); | ||||
#endif | #endif | ||||
@@ -1027,7 +1036,7 @@ inline void swapVariables (Type& variable1, Type& variable2) throw() | |||||
// Some useful maths functions that aren't always present with all compilers and build settings. | // Some useful maths functions that aren't always present with all compilers and build settings. | ||||
#if JUCE_WIN32 || defined (DOXYGEN) | |||||
#if JUCE_WINDOWS || defined (DOXYGEN) | |||||
/** Using juce_hypot and juce_hypotf is easier than dealing with all the different | /** Using juce_hypot and juce_hypotf is easier than dealing with all the different | ||||
versions of these functions of various platforms and compilers. */ | versions of these functions of various platforms and compilers. */ | ||||
forcedinline double juce_hypot (double a, double b) { return _hypot (a, b); } | forcedinline double juce_hypot (double a, double b) { return _hypot (a, b); } | ||||
@@ -1075,7 +1084,7 @@ const float float_Pi = 3.14159265358979323846f; | |||||
#else | #else | ||||
#define juce_isfinite(v) std::isfinite(v) | #define juce_isfinite(v) std::isfinite(v) | ||||
#endif | #endif | ||||
#elif JUCE_WIN32 && ! defined (isfinite) | |||||
#elif JUCE_WINDOWS && ! defined (isfinite) | |||||
#define juce_isfinite(v) _finite(v) | #define juce_isfinite(v) _finite(v) | ||||
#else | #else | ||||
#define juce_isfinite(v) isfinite(v) | #define juce_isfinite(v) isfinite(v) | ||||
@@ -1094,12 +1103,20 @@ const float float_Pi = 3.14159265358979323846f; | |||||
// Endianness conversions.. | // Endianness conversions.. | ||||
#if JUCE_IPHONE | |||||
// a gcc compiler error seems to mean that these functions only work properly | |||||
// on the iPhone if they are declared static.. | |||||
static forcedinline uint32 swapByteOrder (uint32 n) throw(); | |||||
static inline uint16 swapByteOrder (const uint16 n) throw(); | |||||
static inline uint64 swapByteOrder (const uint64 value) throw(); | |||||
#endif | |||||
/** Swaps the byte-order in an integer from little to big-endianness or vice-versa. */ | /** Swaps the byte-order in an integer from little to big-endianness or vice-versa. */ | ||||
forcedinline uint32 swapByteOrder (uint32 n) throw() | forcedinline uint32 swapByteOrder (uint32 n) throw() | ||||
{ | { | ||||
#if JUCE_MAC || JUCE_IPHONE | #if JUCE_MAC || JUCE_IPHONE | ||||
// Mac version | // Mac version | ||||
return CFSwapInt32 (n); | |||||
return OSSwapInt32 (n); | |||||
#elif JUCE_GCC | #elif JUCE_GCC | ||||
// Inpenetrable GCC version.. | // Inpenetrable GCC version.. | ||||
asm("bswap %%eax" : "=a"(n) : "a"(n)); | asm("bswap %%eax" : "=a"(n) : "a"(n)); | ||||
@@ -1132,7 +1149,7 @@ inline uint16 swapByteOrder (const uint16 n) throw() | |||||
inline uint64 swapByteOrder (const uint64 value) throw() | inline uint64 swapByteOrder (const uint64 value) throw() | ||||
{ | { | ||||
#if JUCE_MAC || JUCE_IPHONE | #if JUCE_MAC || JUCE_IPHONE | ||||
return CFSwapInt64 (value); | |||||
return OSSwapInt64 (value); | |||||
#elif JUCE_USE_INTRINSICS | #elif JUCE_USE_INTRINSICS | ||||
return _byteswap_uint64 (value); | return _byteswap_uint64 (value); | ||||
#else | #else | ||||
@@ -2534,7 +2551,7 @@ BEGIN_JUCE_NAMESPACE | |||||
#pragma warning (disable: 4786) // (old vc6 warning about long class names) | #pragma warning (disable: 4786) // (old vc6 warning about long class names) | ||||
#endif | #endif | ||||
#if JUCE_MAC | |||||
#if JUCE_MAC || JUCE_IPHONE | |||||
#pragma align=natural | #pragma align=natural | ||||
#endif | #endif | ||||
@@ -2558,10 +2575,11 @@ BEGIN_JUCE_NAMESPACE | |||||
#if ! MACOS_10_3_OR_EARLIER | #if ! MACOS_10_3_OR_EARLIER | ||||
forcedinline void atomicIncrement (int& variable) throw() { OSAtomicIncrement32 ((int32_t*) &variable); } | |||||
forcedinline int atomicIncrementAndReturn (int& variable) throw() { return OSAtomicIncrement32 ((int32_t*) &variable); } | |||||
forcedinline void atomicDecrement (int& variable) throw() { OSAtomicDecrement32 ((int32_t*) &variable); } | |||||
forcedinline int atomicDecrementAndReturn (int& variable) throw() { return OSAtomicDecrement32 ((int32_t*) &variable); } | |||||
#include <libkern/OSAtomic.h> | |||||
static forcedinline void atomicIncrement (int& variable) throw() { OSAtomicIncrement32 ((int32_t*) &variable); } | |||||
static forcedinline int atomicIncrementAndReturn (int& variable) throw() { return OSAtomicIncrement32 ((int32_t*) &variable); } | |||||
static forcedinline void atomicDecrement (int& variable) throw() { OSAtomicDecrement32 ((int32_t*) &variable); } | |||||
static forcedinline int atomicDecrementAndReturn (int& variable) throw() { return OSAtomicDecrement32 ((int32_t*) &variable); } | |||||
#else | #else | ||||
forcedinline void atomicIncrement (int& variable) throw() { OTAtomicAdd32 (1, (SInt32*) &variable); } | forcedinline void atomicIncrement (int& variable) throw() { OTAtomicAdd32 (1, (SInt32*) &variable); } | ||||
@@ -7194,7 +7212,7 @@ public: | |||||
static void addItemToDock (const File& file); | static void addItemToDock (const File& file); | ||||
#endif | #endif | ||||
#if JUCE_WIN32 || DOXYGEN | |||||
#if JUCE_WINDOWS || DOXYGEN | |||||
// Some registry helper functions: | // Some registry helper functions: | ||||
@@ -7272,7 +7290,7 @@ public: | |||||
*/ | */ | ||||
static void fpuReset(); | static void fpuReset(); | ||||
#if JUCE_LINUX || JUCE_WIN32 | |||||
#if JUCE_LINUX || JUCE_WINDOWS | |||||
/** Loads a dynamically-linked library into the process's address space. | /** Loads a dynamically-linked library into the process's address space. | ||||
@@ -23872,7 +23890,12 @@ private: | |||||
String commandLineParameters; | String commandLineParameters; | ||||
int appReturnValue; | int appReturnValue; | ||||
bool stillInitialising; | bool stillInitialising; | ||||
InterProcessLock* appLock; | |||||
public: | |||||
/** @internal */ | |||||
bool initialiseApp (String& commandLine); | |||||
/** @internal */ | |||||
static int shutdownAppAndClearUp(); | static int shutdownAppAndClearUp(); | ||||
}; | }; | ||||
@@ -37075,7 +37098,7 @@ public: | |||||
static int compareElements (const File* const, const File* const) throw(); | static int compareElements (const File* const, const File* const) throw(); | ||||
private: | private: | ||||
#elif JUCE_WIN32 | |||||
#elif JUCE_WINDOWS | |||||
int numTracks; | int numTracks; | ||||
int trackStarts[100]; | int trackStarts[100]; | ||||
bool audioTracks [100]; | bool audioTracks [100]; | ||||
@@ -51964,7 +51987,7 @@ private: | |||||
#ifndef __JUCE_ACTIVEXCONTROLCOMPONENT_JUCEHEADER__ | #ifndef __JUCE_ACTIVEXCONTROLCOMPONENT_JUCEHEADER__ | ||||
#define __JUCE_ACTIVEXCONTROLCOMPONENT_JUCEHEADER__ | #define __JUCE_ACTIVEXCONTROLCOMPONENT_JUCEHEADER__ | ||||
#if JUCE_WIN32 || DOXYGEN | |||||
#if JUCE_WINDOWS || DOXYGEN | |||||
/** | /** | ||||
A Windows-specific class that can create and embed an ActiveX control inside | A Windows-specific class that can create and embed an ActiveX control inside | ||||
@@ -53629,7 +53652,7 @@ private: | |||||
// this is used to disable QuickTime, and is defined in juce_Config.h | // this is used to disable QuickTime, and is defined in juce_Config.h | ||||
#if JUCE_QUICKTIME || DOXYGEN | #if JUCE_QUICKTIME || DOXYGEN | ||||
#if JUCE_WIN32 | |||||
#if JUCE_WINDOWS | |||||
typedef ActiveXControlComponent QTCompBaseClass; | typedef ActiveXControlComponent QTCompBaseClass; | ||||
#else | #else | ||||
@@ -53773,7 +53796,7 @@ private: | |||||
File movieFile; | File movieFile; | ||||
bool movieLoaded, controllerVisible, looping; | bool movieLoaded, controllerVisible, looping; | ||||
#if JUCE_WIN32 | |||||
#if JUCE_WINDOWS | |||||
/** @internal */ | /** @internal */ | ||||
void parentHierarchyChanged(); | void parentHierarchyChanged(); | ||||
/** @internal */ | /** @internal */ | ||||
@@ -53801,7 +53824,7 @@ private: | |||||
#ifndef __JUCE_SYSTEMTRAYICONCOMPONENT_JUCEHEADER__ | #ifndef __JUCE_SYSTEMTRAYICONCOMPONENT_JUCEHEADER__ | ||||
#define __JUCE_SYSTEMTRAYICONCOMPONENT_JUCEHEADER__ | #define __JUCE_SYSTEMTRAYICONCOMPONENT_JUCEHEADER__ | ||||
#if JUCE_WIN32 || JUCE_LINUX || DOXYGEN | |||||
#if JUCE_WINDOWS || JUCE_LINUX || DOXYGEN | |||||
/** | /** | ||||
On Windows only, this component sits in the taskbar tray as a small icon. | On Windows only, this component sits in the taskbar tray as a small icon. | ||||
@@ -55028,7 +55051,7 @@ public: | |||||
#pragma pack (pop) | #pragma pack (pop) | ||||
#endif | #endif | ||||
#if JUCE_MAC | |||||
#if JUCE_MAC || JUCE_IPHONE | |||||
#pragma align=reset | #pragma align=reset | ||||
#endif | #endif | ||||
@@ -55063,7 +55086,7 @@ END_JUCE_NAMESPACE | |||||
files, you may need to use the juce_WithoutMacros.h file - see the comments in that | files, you may need to use the juce_WithoutMacros.h file - see the comments in that | ||||
file for more information. | file for more information. | ||||
*/ | */ | ||||
#if JUCE_WIN32 && ! JUCE_DONT_DEFINE_MACROS | |||||
#if JUCE_WINDOWS && ! JUCE_DONT_DEFINE_MACROS | |||||
#define Rectangle JUCE_NAMESPACE::Rectangle | #define Rectangle JUCE_NAMESPACE::Rectangle | ||||
#endif | #endif | ||||
#endif | #endif | ||||
@@ -55164,7 +55187,7 @@ END_JUCE_NAMESPACE | |||||
return JUCE_NAMESPACE::JUCEApplication::main (argc, argv, new AppClass()); \ | return JUCE_NAMESPACE::JUCEApplication::main (argc, argv, new AppClass()); \ | ||||
} | } | ||||
#elif JUCE_WIN32 | |||||
#elif JUCE_WINDOWS | |||||
#ifdef _CONSOLE | #ifdef _CONSOLE | ||||
#define START_JUCE_APPLICATION(AppClass) \ | #define START_JUCE_APPLICATION(AppClass) \ | ||||
@@ -44,7 +44,6 @@ BEGIN_JUCE_NAMESPACE | |||||
#include "../core/juce_Time.h" | #include "../core/juce_Time.h" | ||||
#include "../core/juce_Initialisation.h" | #include "../core/juce_Initialisation.h" | ||||
#include "../threads/juce_Process.h" | #include "../threads/juce_Process.h" | ||||
#include "../threads/juce_InterProcessLock.h" | |||||
#include "../core/juce_PlatformUtilities.h" | #include "../core/juce_PlatformUtilities.h" | ||||
void juce_setCurrentThreadName (const String& name) throw(); | void juce_setCurrentThreadName (const String& name) throw(); | ||||
@@ -55,12 +54,18 @@ static JUCEApplication* appInstance = 0; | |||||
//============================================================================== | //============================================================================== | ||||
JUCEApplication::JUCEApplication() | JUCEApplication::JUCEApplication() | ||||
: appReturnValue (0), | : appReturnValue (0), | ||||
stillInitialising (true) | |||||
stillInitialising (true), | |||||
appLock (0) | |||||
{ | { | ||||
} | } | ||||
JUCEApplication::~JUCEApplication() | JUCEApplication::~JUCEApplication() | ||||
{ | { | ||||
if (appLock != 0) | |||||
{ | |||||
appLock->exit(); | |||||
delete appLock; | |||||
} | |||||
} | } | ||||
JUCEApplication* JUCEApplication::getInstance() throw() | JUCEApplication* JUCEApplication::getInstance() throw() | ||||
@@ -156,68 +161,65 @@ bool JUCEApplication::perform (const InvocationInfo& info) | |||||
//============================================================================== | //============================================================================== | ||||
int JUCEApplication::main (String& commandLine, JUCEApplication* const app) | int JUCEApplication::main (String& commandLine, JUCEApplication* const app) | ||||
{ | |||||
if (! app->initialiseApp (commandLine)) | |||||
return 0; | |||||
// now loop until a quit message is received.. | |||||
JUCE_TRY | |||||
{ | |||||
MessageManager::getInstance()->runDispatchLoop(); | |||||
} | |||||
#if JUCE_CATCH_UNHANDLED_EXCEPTIONS | |||||
catch (const std::exception& e) | |||||
{ | |||||
app->unhandledException (&e, __FILE__, __LINE__); | |||||
} | |||||
catch (...) | |||||
{ | |||||
app->unhandledException (0, __FILE__, __LINE__); | |||||
} | |||||
#endif | |||||
return shutdownAppAndClearUp(); | |||||
} | |||||
bool JUCEApplication::initialiseApp (String& commandLine) | |||||
{ | { | ||||
jassert (appInstance == 0); | jassert (appInstance == 0); | ||||
appInstance = app; | |||||
appInstance = this; | |||||
app->commandLineParameters = commandLine.trim(); | |||||
commandLineParameters = commandLine.trim(); | |||||
commandLine = String::empty; | commandLine = String::empty; | ||||
initialiseJuce_GUI(); | initialiseJuce_GUI(); | ||||
InterProcessLock* appLock = 0; | InterProcessLock* appLock = 0; | ||||
if (! app->moreThanOneInstanceAllowed()) | |||||
if (! moreThanOneInstanceAllowed()) | |||||
{ | { | ||||
appLock = new InterProcessLock ("juceAppLock_" + app->getApplicationName()); | |||||
appLock = new InterProcessLock ("juceAppLock_" + getApplicationName()); | |||||
if (! appLock->enter(0)) | if (! appLock->enter(0)) | ||||
{ | { | ||||
MessageManager::broadcastMessage (app->getApplicationName() + "/" + app->commandLineParameters); | |||||
MessageManager::broadcastMessage (getApplicationName() + "/" + commandLineParameters); | |||||
delete appInstance; | delete appInstance; | ||||
appInstance = 0; | appInstance = 0; | ||||
DBG ("Another instance is running - quitting..."); | DBG ("Another instance is running - quitting..."); | ||||
return 0; | |||||
return false; | |||||
} | } | ||||
} | } | ||||
JUCE_TRY | |||||
{ | |||||
juce_setCurrentThreadName ("Juce Message Thread"); | |||||
// let the app do its setting-up.. | |||||
app->initialise (app->commandLineParameters); | |||||
// register for broadcast new app messages | |||||
MessageManager::getInstance()->registerBroadcastListener (app); | |||||
// let the app do its setting-up.. | |||||
initialise (commandLineParameters); | |||||
app->stillInitialising = false; | |||||
// register for broadcast new app messages | |||||
MessageManager::getInstance()->registerBroadcastListener (this); | |||||
// now loop until a quit message is received.. | |||||
MessageManager::getInstance()->runDispatchLoop(); | |||||
MessageManager::getInstance()->deregisterBroadcastListener (app); | |||||
if (appLock != 0) | |||||
{ | |||||
appLock->exit(); | |||||
delete appLock; | |||||
} | |||||
} | |||||
#if JUCE_CATCH_UNHANDLED_EXCEPTIONS | |||||
catch (const std::exception& e) | |||||
{ | |||||
app->unhandledException (&e, __FILE__, __LINE__); | |||||
} | |||||
catch (...) | |||||
{ | |||||
app->unhandledException (0, __FILE__, __LINE__); | |||||
} | |||||
#endif | |||||
return shutdownAppAndClearUp(); | |||||
stillInitialising = false; | |||||
return true; | |||||
} | } | ||||
int JUCEApplication::shutdownAppAndClearUp() | int JUCEApplication::shutdownAppAndClearUp() | ||||
@@ -226,6 +228,8 @@ int JUCEApplication::shutdownAppAndClearUp() | |||||
JUCEApplication* const app = appInstance; | JUCEApplication* const app = appInstance; | ||||
int returnValue = 0; | int returnValue = 0; | ||||
MessageManager::getInstance()->deregisterBroadcastListener (app); | |||||
static bool reentrancyCheck = false; | static bool reentrancyCheck = false; | ||||
if (! reentrancyCheck) | if (! reentrancyCheck) | ||||
@@ -265,9 +269,18 @@ int JUCEApplication::shutdownAppAndClearUp() | |||||
return returnValue; | return returnValue; | ||||
} | } | ||||
#if JUCE_IPHONE | |||||
extern int juce_IPhoneMain (int argc, char* argv[], JUCEApplication* app); | |||||
#endif | |||||
int JUCEApplication::main (int argc, char* argv[], | int JUCEApplication::main (int argc, char* argv[], | ||||
JUCEApplication* const newApp) | JUCEApplication* const newApp) | ||||
{ | { | ||||
#if JUCE_IPHONE | |||||
const ScopedAutoReleasePool pool; | |||||
return juce_IPhoneMain (argc, argv, newApp); | |||||
#else | |||||
#if JUCE_MAC | #if JUCE_MAC | ||||
const ScopedAutoReleasePool pool; | const ScopedAutoReleasePool pool; | ||||
#endif | #endif | ||||
@@ -277,6 +290,7 @@ int JUCEApplication::main (int argc, char* argv[], | |||||
cmd << String::fromUTF8 ((const uint8*) argv[i]) << T(' '); | cmd << String::fromUTF8 ((const uint8*) argv[i]) << T(' '); | ||||
return JUCEApplication::main (cmd, newApp); | return JUCEApplication::main (cmd, newApp); | ||||
#endif | |||||
} | } | ||||
void JUCEApplication::actionListenerCallback (const String& message) | void JUCEApplication::actionListenerCallback (const String& message) | ||||
@@ -293,7 +307,7 @@ void JUCE_PUBLIC_FUNCTION initialiseJuce_GUI() | |||||
{ | { | ||||
if (! juceInitialisedGUI) | if (! juceInitialisedGUI) | ||||
{ | { | ||||
#if JUCE_MAC | |||||
#if JUCE_MAC || JUCE_IPHONE | |||||
const ScopedAutoReleasePool pool; | const ScopedAutoReleasePool pool; | ||||
#endif | #endif | ||||
juceInitialisedGUI = true; | juceInitialisedGUI = true; | ||||
@@ -301,8 +315,9 @@ void JUCE_PUBLIC_FUNCTION initialiseJuce_GUI() | |||||
initialiseJuce_NonGUI(); | initialiseJuce_NonGUI(); | ||||
MessageManager::getInstance(); | MessageManager::getInstance(); | ||||
LookAndFeel::setDefaultLookAndFeel (0); | LookAndFeel::setDefaultLookAndFeel (0); | ||||
juce_setCurrentThreadName ("Juce Message Thread"); | |||||
#if JUCE_WIN32 && JUCE_DEBUG | |||||
#if JUCE_WINDOWS && JUCE_DEBUG | |||||
// This section is just for catching people who mess up their project settings and | // This section is just for catching people who mess up their project settings and | ||||
// turn RTTI off.. | // turn RTTI off.. | ||||
try | try | ||||
@@ -28,6 +28,7 @@ | |||||
#include "juce_ApplicationCommandTarget.h" | #include "juce_ApplicationCommandTarget.h" | ||||
#include "../events/juce_ActionListener.h" | #include "../events/juce_ActionListener.h" | ||||
#include "../threads/juce_InterProcessLock.h" | |||||
//============================================================================== | //============================================================================== | ||||
@@ -288,7 +289,12 @@ private: | |||||
String commandLineParameters; | String commandLineParameters; | ||||
int appReturnValue; | int appReturnValue; | ||||
bool stillInitialising; | bool stillInitialising; | ||||
InterProcessLock* appLock; | |||||
public: | |||||
/** @internal */ | |||||
bool initialiseApp (String& commandLine); | |||||
/** @internal */ | |||||
static int shutdownAppAndClearUp(); | static int shutdownAppAndClearUp(); | ||||
}; | }; | ||||
@@ -26,17 +26,17 @@ | |||||
// This file is included at the start of each FLAC .c file, just to do a few housekeeping | // This file is included at the start of each FLAC .c file, just to do a few housekeeping | ||||
// tasks.. | // tasks.. | ||||
#include "../../../../core/juce_TargetPlatform.h" | |||||
#include "../../../../../juce_Config.h" | #include "../../../../../juce_Config.h" | ||||
#define VERSION "1.2.1" | #define VERSION "1.2.1" | ||||
#define FLAC__NO_DLL 1 | #define FLAC__NO_DLL 1 | ||||
#ifdef _MSC_VER | |||||
#if JUCE_MSVC | |||||
#pragma warning (disable: 4267 4127 4244 4996 4100 4701 4702 4013 4133 4206 4312) | #pragma warning (disable: 4267 4127 4244 4996 4100 4701 4702 4013 4133 4206 4312) | ||||
#endif | #endif | ||||
#if ! (defined (_WIN32) || defined (_WIN64) || defined (LINUX)) | |||||
#if JUCE_MAC | |||||
#define FLAC__SYS_DARWIN 1 | #define FLAC__SYS_DARWIN 1 | ||||
#endif | #endif |
@@ -158,7 +158,7 @@ public: | |||||
static int compareElements (const File* const, const File* const) throw(); | static int compareElements (const File* const, const File* const) throw(); | ||||
private: | private: | ||||
#elif JUCE_WIN32 | |||||
#elif JUCE_WINDOWS | |||||
int numTracks; | int numTracks; | ||||
int trackStarts[100]; | int trackStarts[100]; | ||||
bool audioTracks [100]; | bool audioTracks [100]; | ||||
@@ -23,13 +23,15 @@ | |||||
============================================================================== | ============================================================================== | ||||
*/ | */ | ||||
#include "../../core/juce_TargetPlatform.h" | |||||
#include "../../../juce_Config.h" | #include "../../../juce_Config.h" | ||||
#ifdef _MSC_VER | |||||
#include <windows.h> | |||||
#endif | |||||
#if JUCE_USE_FLAC | #if JUCE_USE_FLAC | ||||
#if JUCE_WINDOWS | |||||
#include <windows.h> | |||||
#endif | |||||
#include "../../core/juce_StandardHeader.h" | #include "../../core/juce_StandardHeader.h" | ||||
#ifdef _MSC_VER | #ifdef _MSC_VER | ||||
@@ -23,6 +23,7 @@ | |||||
============================================================================== | ============================================================================== | ||||
*/ | */ | ||||
#include "../../core/juce_TargetPlatform.h" | |||||
#include "../../../juce_Config.h" | #include "../../../juce_Config.h" | ||||
#if JUCE_USE_OGGVORBIS | #if JUCE_USE_OGGVORBIS | ||||
@@ -23,18 +23,19 @@ | |||||
============================================================================== | ============================================================================== | ||||
*/ | */ | ||||
#include "../../core/juce_TargetPlatform.h" | |||||
#include "../../../juce_Config.h" | #include "../../../juce_Config.h" | ||||
#if JUCE_QUICKTIME | |||||
#if JUCE_QUICKTIME && ! (JUCE_64BIT || JUCE_IPHONE) | |||||
#if ! defined (_WIN32) | |||||
#if ! JUCE_WINDOWS | |||||
#include <QuickTime/Movies.h> | #include <QuickTime/Movies.h> | ||||
#include <QuickTime/QTML.h> | #include <QuickTime/QTML.h> | ||||
#include <QuickTime/QuickTimeComponents.h> | #include <QuickTime/QuickTimeComponents.h> | ||||
#include <QuickTime/MediaHandlers.h> | #include <QuickTime/MediaHandlers.h> | ||||
#include <QuickTime/ImageCodec.h> | #include <QuickTime/ImageCodec.h> | ||||
#else | #else | ||||
#ifdef _MSC_VER | |||||
#if JUCE_MSVC | |||||
#pragma warning (push) | #pragma warning (push) | ||||
#pragma warning (disable : 4100) | #pragma warning (disable : 4100) | ||||
#endif | #endif | ||||
@@ -51,15 +52,13 @@ | |||||
#include <MediaHandlers.h> | #include <MediaHandlers.h> | ||||
#include <ImageCodec.h> | #include <ImageCodec.h> | ||||
#ifdef _MSC_VER | |||||
#if JUCE_MSVC | |||||
#pragma warning (pop) | #pragma warning (pop) | ||||
#endif | #endif | ||||
#endif | #endif | ||||
#include "../../core/juce_StandardHeader.h" | #include "../../core/juce_StandardHeader.h" | ||||
#if ! (JUCE_MAC && JUCE_64BIT) | |||||
BEGIN_JUCE_NAMESPACE | BEGIN_JUCE_NAMESPACE | ||||
#include "juce_QuickTimeAudioFormat.h" | #include "juce_QuickTimeAudioFormat.h" | ||||
@@ -404,4 +403,3 @@ AudioFormatWriter* QuickTimeAudioFormat::createWriterFor (OutputStream* /*stream | |||||
END_JUCE_NAMESPACE | END_JUCE_NAMESPACE | ||||
#endif | #endif | ||||
#endif |
@@ -27,8 +27,9 @@ | |||||
// tasks.. | // tasks.. | ||||
#include "../../../../src/core/juce_TargetPlatform.h" | |||||
#include "../../../../juce_Config.h" | #include "../../../../juce_Config.h" | ||||
#ifdef _MSC_VER | |||||
#if JUCE_MSVC | |||||
#pragma warning (disable: 4267 4127 4244 4996 4100 4701 4702 4013 4133 4206 4305 4189 4706) | #pragma warning (disable: 4267 4127 4244 4996 4100 4701 4702 4013 4133 4206 4305 4189 4706) | ||||
#endif | #endif |
@@ -115,10 +115,10 @@ AudioIODeviceType* juce_createAudioIODeviceType_ALSA(); | |||||
void AudioDeviceManager::createAudioDeviceTypes (OwnedArray <AudioIODeviceType>& list) | void AudioDeviceManager::createAudioDeviceTypes (OwnedArray <AudioIODeviceType>& list) | ||||
{ | { | ||||
#if JUCE_WIN32 | |||||
#if JUCE_WINDOWS | |||||
#if JUCE_WASAPI | #if JUCE_WASAPI | ||||
if (SystemStats::getOperatingSystemType() >= SystemStats::WinVista) | if (SystemStats::getOperatingSystemType() >= SystemStats::WinVista) | ||||
list.add (juce_createAudioIODeviceType_WASAPI()); | |||||
list.add (juce_createAudioIODeviceType_WASAPI()); | |||||
#endif | #endif | ||||
#if JUCE_DIRECTSOUND | #if JUCE_DIRECTSOUND | ||||
@@ -23,6 +23,7 @@ | |||||
============================================================================== | ============================================================================== | ||||
*/ | */ | ||||
#include "../../../core/juce_TargetPlatform.h" | |||||
#include "../../../../juce_Config.h" | #include "../../../../juce_Config.h" | ||||
#if JUCE_PLUGINHOST_AU && (! (defined (LINUX) || defined (_WIN32))) | #if JUCE_PLUGINHOST_AU && (! (defined (LINUX) || defined (_WIN32))) | ||||
@@ -23,6 +23,7 @@ | |||||
============================================================================== | ============================================================================== | ||||
*/ | */ | ||||
#include "../../../core/juce_TargetPlatform.h" | |||||
#include "../../../../juce_Config.h" | #include "../../../../juce_Config.h" | ||||
#if JUCE_PLUGINHOST_VST | #if JUCE_PLUGINHOST_VST | ||||
@@ -35,10 +35,11 @@ | |||||
#if ! MACOS_10_3_OR_EARLIER | #if ! MACOS_10_3_OR_EARLIER | ||||
//============================================================================== | //============================================================================== | ||||
forcedinline void atomicIncrement (int& variable) throw() { OSAtomicIncrement32 ((int32_t*) &variable); } | |||||
forcedinline int atomicIncrementAndReturn (int& variable) throw() { return OSAtomicIncrement32 ((int32_t*) &variable); } | |||||
forcedinline void atomicDecrement (int& variable) throw() { OSAtomicDecrement32 ((int32_t*) &variable); } | |||||
forcedinline int atomicDecrementAndReturn (int& variable) throw() { return OSAtomicDecrement32 ((int32_t*) &variable); } | |||||
#include <libkern/OSAtomic.h> | |||||
static forcedinline void atomicIncrement (int& variable) throw() { OSAtomicIncrement32 ((int32_t*) &variable); } | |||||
static forcedinline int atomicIncrementAndReturn (int& variable) throw() { return OSAtomicIncrement32 ((int32_t*) &variable); } | |||||
static forcedinline void atomicDecrement (int& variable) throw() { OSAtomicDecrement32 ((int32_t*) &variable); } | |||||
static forcedinline int atomicDecrementAndReturn (int& variable) throw() { return OSAtomicDecrement32 ((int32_t*) &variable); } | |||||
#else | #else | ||||
//============================================================================== | //============================================================================== | ||||
forcedinline void atomicIncrement (int& variable) throw() { OTAtomicAdd32 (1, (SInt32*) &variable); } | forcedinline void atomicIncrement (int& variable) throw() { OTAtomicAdd32 (1, (SInt32*) &variable); } | ||||
@@ -26,8 +26,6 @@ | |||||
#ifndef __JUCE_DATACONVERSIONS_JUCEHEADER__ | #ifndef __JUCE_DATACONVERSIONS_JUCEHEADER__ | ||||
#define __JUCE_DATACONVERSIONS_JUCEHEADER__ | #define __JUCE_DATACONVERSIONS_JUCEHEADER__ | ||||
#include "juce_PlatformDefs.h" | |||||
#if JUCE_USE_INTRINSICS | #if JUCE_USE_INTRINSICS | ||||
#pragma intrinsic (_byteswap_ulong) | #pragma intrinsic (_byteswap_ulong) | ||||
#endif | #endif | ||||
@@ -35,12 +33,20 @@ | |||||
//============================================================================== | //============================================================================== | ||||
// Endianness conversions.. | // Endianness conversions.. | ||||
#if JUCE_IPHONE | |||||
// a gcc compiler error seems to mean that these functions only work properly | |||||
// on the iPhone if they are declared static.. | |||||
static forcedinline uint32 swapByteOrder (uint32 n) throw(); | |||||
static inline uint16 swapByteOrder (const uint16 n) throw(); | |||||
static inline uint64 swapByteOrder (const uint64 value) throw(); | |||||
#endif | |||||
/** Swaps the byte-order in an integer from little to big-endianness or vice-versa. */ | /** Swaps the byte-order in an integer from little to big-endianness or vice-versa. */ | ||||
forcedinline uint32 swapByteOrder (uint32 n) throw() | forcedinline uint32 swapByteOrder (uint32 n) throw() | ||||
{ | { | ||||
#if JUCE_MAC || JUCE_IPHONE | #if JUCE_MAC || JUCE_IPHONE | ||||
// Mac version | // Mac version | ||||
return CFSwapInt32 (n); | |||||
return OSSwapInt32 (n); | |||||
#elif JUCE_GCC | #elif JUCE_GCC | ||||
// Inpenetrable GCC version.. | // Inpenetrable GCC version.. | ||||
asm("bswap %%eax" : "=a"(n) : "a"(n)); | asm("bswap %%eax" : "=a"(n) : "a"(n)); | ||||
@@ -73,7 +79,7 @@ inline uint16 swapByteOrder (const uint16 n) throw() | |||||
inline uint64 swapByteOrder (const uint64 value) throw() | inline uint64 swapByteOrder (const uint64 value) throw() | ||||
{ | { | ||||
#if JUCE_MAC || JUCE_IPHONE | #if JUCE_MAC || JUCE_IPHONE | ||||
return CFSwapInt64 (value); | |||||
return OSSwapInt64 (value); | |||||
#elif JUCE_USE_INTRINSICS | #elif JUCE_USE_INTRINSICS | ||||
return _byteswap_uint64 (value); | return _byteswap_uint64 (value); | ||||
#else | #else | ||||
@@ -207,7 +207,7 @@ inline void swapVariables (Type& variable1, Type& variable2) throw() | |||||
//============================================================================== | //============================================================================== | ||||
// Some useful maths functions that aren't always present with all compilers and build settings. | // Some useful maths functions that aren't always present with all compilers and build settings. | ||||
#if JUCE_WIN32 || defined (DOXYGEN) | |||||
#if JUCE_WINDOWS || defined (DOXYGEN) | |||||
/** Using juce_hypot and juce_hypotf is easier than dealing with all the different | /** Using juce_hypot and juce_hypotf is easier than dealing with all the different | ||||
versions of these functions of various platforms and compilers. */ | versions of these functions of various platforms and compilers. */ | ||||
forcedinline double juce_hypot (double a, double b) { return _hypot (a, b); } | forcedinline double juce_hypot (double a, double b) { return _hypot (a, b); } | ||||
@@ -259,7 +259,7 @@ const float float_Pi = 3.14159265358979323846f; | |||||
#else | #else | ||||
#define juce_isfinite(v) std::isfinite(v) | #define juce_isfinite(v) std::isfinite(v) | ||||
#endif | #endif | ||||
#elif JUCE_WIN32 && ! defined (isfinite) | |||||
#elif JUCE_WINDOWS && ! defined (isfinite) | |||||
#define juce_isfinite(v) _finite(v) | #define juce_isfinite(v) _finite(v) | ||||
#else | #else | ||||
#define juce_isfinite(v) isfinite(v) | #define juce_isfinite(v) isfinite(v) | ||||
@@ -27,130 +27,9 @@ | |||||
#define __JUCE_PLATFORMDEFS_JUCEHEADER__ | #define __JUCE_PLATFORMDEFS_JUCEHEADER__ | ||||
//============================================================================== | //============================================================================== | ||||
/* This file figures out which platform is being built, and defines some macros | |||||
that the rest of the code can use for OS-specific compilation. | |||||
Macros that will be set here are: | |||||
- One of JUCE_WIN32, JUCE_MAC or JUCE_LINUX. | |||||
- Either JUCE_32BIT or JUCE_64BIT, depending on the architecture. | |||||
- Either JUCE_LITTLE_ENDIAN or JUCE_BIG_ENDIAN. | |||||
- Either JUCE_INTEL or JUCE_PPC | |||||
- Either JUCE_GCC or JUCE_MSVC | |||||
It also includes a set of macros for debug console output and assertions. | |||||
/* This file defines miscellaneous macros for debugging, assertions, etc. | |||||
*/ | */ | ||||
//============================================================================== | |||||
#if (defined (_WIN32) || defined (_WIN64)) | |||||
#define JUCE_WIN32 1 | |||||
#else | |||||
#if defined (LINUX) || defined (__linux__) | |||||
#define JUCE_LINUX 1 | |||||
#elif TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR | |||||
#define JUCE_IPHONE 1 | |||||
#else | |||||
#define JUCE_MAC 1 | |||||
#endif | |||||
#endif | |||||
//============================================================================== | |||||
#if JUCE_WIN32 | |||||
#ifdef _MSC_VER | |||||
#ifdef _WIN64 | |||||
#define JUCE_64BIT 1 | |||||
#else | |||||
#define JUCE_32BIT 1 | |||||
#endif | |||||
#endif | |||||
#ifdef _DEBUG | |||||
#define JUCE_DEBUG 1 | |||||
#endif | |||||
/** If defined, this indicates that the processor is little-endian. */ | |||||
#define JUCE_LITTLE_ENDIAN 1 | |||||
#define JUCE_INTEL 1 | |||||
#endif | |||||
//============================================================================== | |||||
#if JUCE_MAC | |||||
#include <CoreFoundation/CoreFoundation.h> | |||||
#ifndef NDEBUG | |||||
#define JUCE_DEBUG 1 | |||||
#endif | |||||
#ifdef __LITTLE_ENDIAN__ | |||||
#define JUCE_LITTLE_ENDIAN 1 | |||||
#else | |||||
#define JUCE_BIG_ENDIAN 1 | |||||
#endif | |||||
#if defined (__ppc__) || defined (__ppc64__) | |||||
#define JUCE_PPC 1 | |||||
#else | |||||
#define JUCE_INTEL 1 | |||||
#endif | |||||
#ifdef __LP64__ | |||||
#define JUCE_64BIT 1 | |||||
#else | |||||
#define JUCE_32BIT 1 | |||||
#endif | |||||
#if (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_3) | |||||
#error "Building for OSX 10.2 is no longer supported!" | |||||
#endif | |||||
#if (! defined (MAC_OS_X_VERSION_10_4)) || (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_4) | |||||
#define MACOS_10_3_OR_EARLIER 1 | |||||
#endif | |||||
#if (! defined (MAC_OS_X_VERSION_10_5)) || (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5) | |||||
#define MACOS_10_4_OR_EARLIER 1 | |||||
#endif | |||||
#endif | |||||
//============================================================================== | |||||
#if JUCE_IPHONE | |||||
#include <CoreFoundation/CoreFoundation.h> | |||||
#ifndef NDEBUG | |||||
#define JUCE_DEBUG 1 | |||||
#endif | |||||
#ifdef __LITTLE_ENDIAN__ | |||||
#define JUCE_LITTLE_ENDIAN 1 | |||||
#else | |||||
#define JUCE_BIG_ENDIAN 1 | |||||
#endif | |||||
#endif | |||||
//============================================================================== | |||||
#if JUCE_LINUX | |||||
#ifdef _DEBUG | |||||
#define JUCE_DEBUG 1 | |||||
#endif | |||||
// Allow override for big-endian Linux platforms | |||||
#ifndef JUCE_BIG_ENDIAN | |||||
#define JUCE_LITTLE_ENDIAN 1 | |||||
#endif | |||||
#if defined (__LP64__) || defined (_LP64) | |||||
#define JUCE_64BIT 1 | |||||
#else | |||||
#define JUCE_32BIT 1 | |||||
#endif | |||||
#define JUCE_INTEL 1 | |||||
#endif | |||||
//============================================================================== | //============================================================================== | ||||
#ifdef JUCE_FORCE_DEBUG | #ifdef JUCE_FORCE_DEBUG | ||||
#undef JUCE_DEBUG | #undef JUCE_DEBUG | ||||
@@ -160,21 +39,6 @@ | |||||
#endif | #endif | ||||
#endif | #endif | ||||
//============================================================================== | |||||
// Compiler type macros. | |||||
#ifdef __GNUC__ | |||||
#define JUCE_GCC 1 | |||||
#elif defined (_MSC_VER) | |||||
#define JUCE_MSVC 1 | |||||
#if _MSC_VER >= 1400 | |||||
#define JUCE_USE_INTRINSICS 1 | |||||
#endif | |||||
#else | |||||
#error unknown compiler | |||||
#endif | |||||
/** This macro defines the C calling convention used as the standard for Juce calls. */ | /** This macro defines the C calling convention used as the standard for Juce calls. */ | ||||
#if JUCE_MSVC | #if JUCE_MSVC | ||||
#define JUCE_CALLTYPE __stdcall | #define JUCE_CALLTYPE __stdcall | ||||
@@ -217,7 +81,7 @@ | |||||
//============================================================================== | //============================================================================== | ||||
// Assertions.. | // Assertions.. | ||||
#if JUCE_WIN32 || DOXYGEN | |||||
#if JUCE_WINDOWS || DOXYGEN | |||||
#if JUCE_USE_INTRINSICS | #if JUCE_USE_INTRINSICS | ||||
#pragma intrinsic (__debugbreak) | #pragma intrinsic (__debugbreak) | ||||
@@ -241,7 +105,7 @@ | |||||
#elif JUCE_MAC | #elif JUCE_MAC | ||||
#define juce_breakDebugger Debugger(); | #define juce_breakDebugger Debugger(); | ||||
#elif JUCE_IPHONE | #elif JUCE_IPHONE | ||||
#define juce_breakDebugger assert (false); | |||||
#define juce_breakDebugger kill (0, SIGTRAP); | |||||
#elif JUCE_LINUX | #elif JUCE_LINUX | ||||
#define juce_breakDebugger kill (0, SIGTRAP); | #define juce_breakDebugger kill (0, SIGTRAP); | ||||
#endif | #endif | ||||
@@ -76,7 +76,7 @@ public: | |||||
#endif | #endif | ||||
#if JUCE_WIN32 || DOXYGEN | |||||
#if JUCE_WINDOWS || DOXYGEN | |||||
//============================================================================== | //============================================================================== | ||||
// Some registry helper functions: | // Some registry helper functions: | ||||
@@ -155,7 +155,7 @@ public: | |||||
static void fpuReset(); | static void fpuReset(); | ||||
#if JUCE_LINUX || JUCE_WIN32 | |||||
#if JUCE_LINUX || JUCE_WINDOWS | |||||
//============================================================================== | //============================================================================== | ||||
/** Loads a dynamically-linked library into the process's address space. | /** Loads a dynamically-linked library into the process's address space. | ||||
@@ -46,6 +46,8 @@ | |||||
//============================================================================== | //============================================================================== | ||||
#include "juce_TargetPlatform.h" // (sets up the various JUCE_WINDOWS, JUCE_MAC, etc flags) | |||||
#include "../../juce_Config.h" | #include "../../juce_Config.h" | ||||
//============================================================================== | //============================================================================== | ||||
@@ -58,7 +60,6 @@ | |||||
#endif | #endif | ||||
//============================================================================== | //============================================================================== | ||||
// This sets up the JUCE_WIN32, JUCE_MAC, or JUCE_LINUX macros | |||||
#include "juce_PlatformDefs.h" | #include "juce_PlatformDefs.h" | ||||
// Now we'll include any OS headers we need.. (at this point we are outside the Juce namespace). | // Now we'll include any OS headers we need.. (at this point we are outside the Juce namespace). | ||||
@@ -52,7 +52,7 @@ void JUCE_PUBLIC_FUNCTION initialiseJuce_NonGUI() | |||||
{ | { | ||||
if (! juceInitialisedNonGUI) | if (! juceInitialisedNonGUI) | ||||
{ | { | ||||
#if JUCE_MAC | |||||
#if JUCE_MAC || JUCE_IPHONE | |||||
const ScopedAutoReleasePool pool; | const ScopedAutoReleasePool pool; | ||||
#endif | #endif | ||||
@@ -84,7 +84,7 @@ void JUCE_PUBLIC_FUNCTION initialiseJuce_NonGUI() | |||||
} | } | ||||
} | } | ||||
#if JUCE_WIN32 | |||||
#if JUCE_WINDOWS | |||||
// This is imported from the sockets code.. | // This is imported from the sockets code.. | ||||
typedef int (__stdcall juce_CloseWin32SocketLibCall) (void); | typedef int (__stdcall juce_CloseWin32SocketLibCall) (void); | ||||
extern juce_CloseWin32SocketLibCall* juce_CloseWin32SocketLib; | extern juce_CloseWin32SocketLibCall* juce_CloseWin32SocketLib; | ||||
@@ -98,11 +98,11 @@ void JUCE_PUBLIC_FUNCTION shutdownJuce_NonGUI() | |||||
{ | { | ||||
if (juceInitialisedNonGUI) | if (juceInitialisedNonGUI) | ||||
{ | { | ||||
#if JUCE_MAC | |||||
#if JUCE_MAC || JUCE_IPHONE | |||||
const ScopedAutoReleasePool pool; | const ScopedAutoReleasePool pool; | ||||
#endif | #endif | ||||
#if JUCE_WIN32 | |||||
#if JUCE_WINDOWS | |||||
// need to shut down sockets if they were used.. | // need to shut down sockets if they were used.. | ||||
if (juce_CloseWin32SocketLib != 0) | if (juce_CloseWin32SocketLib != 0) | ||||
(*juce_CloseWin32SocketLib)(); | (*juce_CloseWin32SocketLib)(); | ||||
@@ -0,0 +1,169 @@ | |||||
/* | |||||
============================================================================== | |||||
This file is part of the JUCE library - "Jules' Utility Class Extensions" | |||||
Copyright 2004-9 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_TARGETPLATFORM_JUCEHEADER__ | |||||
#define __JUCE_TARGETPLATFORM_JUCEHEADER__ | |||||
//============================================================================== | |||||
/* This file figures out which platform is being built, and defines some macros | |||||
that the rest of the code can use for OS-specific compilation. | |||||
Macros that will be set here are: | |||||
- One of JUCE_WINDOWS, JUCE_MAC or JUCE_LINUX. | |||||
- Either JUCE_32BIT or JUCE_64BIT, depending on the architecture. | |||||
- Either JUCE_LITTLE_ENDIAN or JUCE_BIG_ENDIAN. | |||||
- Either JUCE_INTEL or JUCE_PPC | |||||
- Either JUCE_GCC or JUCE_MSVC | |||||
*/ | |||||
//============================================================================== | |||||
#if (defined (_WIN32) || defined (_WIN64)) | |||||
#define JUCE_WIN32 1 | |||||
#define JUCE_WINDOWS 1 | |||||
#elif defined (LINUX) || defined (__linux__) | |||||
#define JUCE_LINUX 1 | |||||
#elif defined(__APPLE_CPP__) || defined(__APPLE_CC__) | |||||
#include <CoreFoundation/CoreFoundation.h> // (needed to find out what platform we're using) | |||||
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR | |||||
#define JUCE_IPHONE 1 | |||||
#else | |||||
#define JUCE_MAC 1 | |||||
#endif | |||||
#else | |||||
#error "Unknown platform!" | |||||
#endif | |||||
//============================================================================== | |||||
#if JUCE_WINDOWS | |||||
#ifdef _MSC_VER | |||||
#ifdef _WIN64 | |||||
#define JUCE_64BIT 1 | |||||
#else | |||||
#define JUCE_32BIT 1 | |||||
#endif | |||||
#endif | |||||
#ifdef _DEBUG | |||||
#define JUCE_DEBUG 1 | |||||
#endif | |||||
/** If defined, this indicates that the processor is little-endian. */ | |||||
#define JUCE_LITTLE_ENDIAN 1 | |||||
#define JUCE_INTEL 1 | |||||
#endif | |||||
//============================================================================== | |||||
#if JUCE_MAC | |||||
#ifndef NDEBUG | |||||
#define JUCE_DEBUG 1 | |||||
#endif | |||||
#ifdef __LITTLE_ENDIAN__ | |||||
#define JUCE_LITTLE_ENDIAN 1 | |||||
#else | |||||
#define JUCE_BIG_ENDIAN 1 | |||||
#endif | |||||
#if defined (__ppc__) || defined (__ppc64__) | |||||
#define JUCE_PPC 1 | |||||
#else | |||||
#define JUCE_INTEL 1 | |||||
#endif | |||||
#ifdef __LP64__ | |||||
#define JUCE_64BIT 1 | |||||
#else | |||||
#define JUCE_32BIT 1 | |||||
#endif | |||||
#if (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_3) | |||||
#error "Building for OSX 10.2 is no longer supported!" | |||||
#endif | |||||
#if (! defined (MAC_OS_X_VERSION_10_4)) || (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_4) | |||||
#define MACOS_10_3_OR_EARLIER 1 | |||||
#endif | |||||
#if (! defined (MAC_OS_X_VERSION_10_5)) || (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5) | |||||
#define MACOS_10_4_OR_EARLIER 1 | |||||
#endif | |||||
#endif | |||||
//============================================================================== | |||||
#if JUCE_IPHONE | |||||
#ifndef NDEBUG | |||||
#define JUCE_DEBUG 1 | |||||
#endif | |||||
#ifdef __LITTLE_ENDIAN__ | |||||
#define JUCE_LITTLE_ENDIAN 1 | |||||
#else | |||||
#define JUCE_BIG_ENDIAN 1 | |||||
#endif | |||||
#endif | |||||
//============================================================================== | |||||
#if JUCE_LINUX | |||||
#ifdef _DEBUG | |||||
#define JUCE_DEBUG 1 | |||||
#endif | |||||
// Allow override for big-endian Linux platforms | |||||
#ifndef JUCE_BIG_ENDIAN | |||||
#define JUCE_LITTLE_ENDIAN 1 | |||||
#endif | |||||
#if defined (__LP64__) || defined (_LP64) | |||||
#define JUCE_64BIT 1 | |||||
#else | |||||
#define JUCE_32BIT 1 | |||||
#endif | |||||
#define JUCE_INTEL 1 | |||||
#endif | |||||
//============================================================================== | |||||
// Compiler type macros. | |||||
#ifdef __GNUC__ | |||||
#define JUCE_GCC 1 | |||||
#elif defined (_MSC_VER) | |||||
#define JUCE_MSVC 1 | |||||
#if _MSC_VER >= 1400 | |||||
#define JUCE_USE_INTRINSICS 1 | |||||
#endif | |||||
#else | |||||
#error unknown compiler | |||||
#endif | |||||
#endif // __JUCE_PLATFORMDEFS_JUCEHEADER__ |
@@ -30,7 +30,7 @@ | |||||
#include "juce_StandardHeader.h" | #include "juce_StandardHeader.h" | ||||
#ifndef JUCE_WIN32 | |||||
#ifndef JUCE_WINDOWS | |||||
#include <sys/time.h> | #include <sys/time.h> | ||||
#else | #else | ||||
#include <ctime> | #include <ctime> | ||||
@@ -90,7 +90,7 @@ static void millisToLocal (const int64 millis, struct tm& result) throw() | |||||
{ | { | ||||
time_t now = (time_t) (seconds); | time_t now = (time_t) (seconds); | ||||
#if JUCE_WIN32 | |||||
#if JUCE_WINDOWS | |||||
#ifdef USE_NEW_SECURE_TIME_FNS | #ifdef USE_NEW_SECURE_TIME_FNS | ||||
if (now >= 0 && now <= 0x793406fff) | if (now >= 0 && now <= 0x793406fff) | ||||
localtime_s (&result, &now); | localtime_s (&result, &now); | ||||
@@ -195,7 +195,7 @@ int64 Time::currentTimeMillis() throw() | |||||
{ | { | ||||
// get the time once using normal library calls, and store the difference needed to | // get the time once using normal library calls, and store the difference needed to | ||||
// turn the millisecond counter into a real time. | // turn the millisecond counter into a real time. | ||||
#if JUCE_WIN32 | |||||
#if JUCE_WINDOWS | |||||
struct _timeb t; | struct _timeb t; | ||||
#ifdef USE_NEW_SECURE_TIME_FNS | #ifdef USE_NEW_SECURE_TIME_FNS | ||||
_ftime_s (&t); | _ftime_s (&t); | ||||
@@ -446,7 +446,7 @@ const String Time::getTimeZone() const throw() | |||||
{ | { | ||||
String zone[2]; | String zone[2]; | ||||
#if JUCE_WIN32 | |||||
#if JUCE_WINDOWS | |||||
_tzset(); | _tzset(); | ||||
#ifdef USE_NEW_SECURE_TIME_FNS | #ifdef USE_NEW_SECURE_TIME_FNS | ||||
@@ -129,7 +129,7 @@ void MessageManager::deliverMessage (void* message) | |||||
} | } | ||||
//============================================================================== | //============================================================================== | ||||
#if ! JUCE_MAC | |||||
#if ! (JUCE_MAC || JUCE_IPHONE) | |||||
void MessageManager::runDispatchLoop() | void MessageManager::runDispatchLoop() | ||||
{ | { | ||||
jassert (isThisTheMessageThread()); // must only be called by the message thread | jassert (isThisTheMessageThread()); // must only be called by the message thread | ||||
@@ -249,7 +249,7 @@ bool DirectoryContentsList::checkNextFile (bool& hasChanged) | |||||
int DirectoryContentsList::compareElements (const DirectoryContentsList::FileInfo* const first, | int DirectoryContentsList::compareElements (const DirectoryContentsList::FileInfo* const first, | ||||
const DirectoryContentsList::FileInfo* const second) throw() | const DirectoryContentsList::FileInfo* const second) throw() | ||||
{ | { | ||||
#if JUCE_WIN32 | |||||
#if JUCE_WINDOWS | |||||
if (first->isDirectory != second->isDirectory) | if (first->isDirectory != second->isDirectory) | ||||
return first->isDirectory ? -1 : 1; | return first->isDirectory ? -1 : 1; | ||||
#endif | #endif | ||||
@@ -342,7 +342,7 @@ void FileBrowserComponent::fileDoubleClicked (const File& f) | |||||
bool FileBrowserComponent::keyPressed (const KeyPress& key) | bool FileBrowserComponent::keyPressed (const KeyPress& key) | ||||
{ | { | ||||
#if JUCE_LINUX || JUCE_WIN32 | |||||
#if JUCE_LINUX || JUCE_WINDOWS | |||||
if (key.getModifiers().isCommandDown() | if (key.getModifiers().isCommandDown() | ||||
&& (key.getKeyCode() == 'H' || key.getKeyCode() == 'h')) | && (key.getKeyCode() == 'H' || key.getKeyCode() == 'h')) | ||||
{ | { | ||||
@@ -441,7 +441,7 @@ const BitArray FileBrowserComponent::getRoots (StringArray& rootNames, StringArr | |||||
{ | { | ||||
BitArray separators; | BitArray separators; | ||||
#if JUCE_WIN32 | |||||
#if JUCE_WINDOWS | |||||
OwnedArray<File> roots; | OwnedArray<File> roots; | ||||
File::findFileSystemRoots (roots); | File::findFileSystemRoots (roots); | ||||
rootPaths.clear(); | rootPaths.clear(); | ||||
@@ -113,7 +113,7 @@ bool FileChooser::showDialog (const bool isDirectory, | |||||
jassert (previewComponent == 0 || (previewComponent->getWidth() > 10 | jassert (previewComponent == 0 || (previewComponent->getWidth() > 10 | ||||
&& previewComponent->getHeight() > 10)); | && previewComponent->getHeight() > 10)); | ||||
#if JUCE_WIN32 | |||||
#if JUCE_WINDOWS | |||||
if (useNativeDialogBox) | if (useNativeDialogBox) | ||||
#else | #else | ||||
if (useNativeDialogBox && (previewComponent == 0)) | if (useNativeDialogBox && (previewComponent == 0)) | ||||
@@ -28,7 +28,7 @@ | |||||
#include "../juce_Component.h" | #include "../juce_Component.h" | ||||
#if JUCE_WIN32 || DOXYGEN | |||||
#if JUCE_WINDOWS || DOXYGEN | |||||
//============================================================================== | //============================================================================== | ||||
/** | /** | ||||
@@ -31,7 +31,7 @@ | |||||
// this is used to disable QuickTime, and is defined in juce_Config.h | // this is used to disable QuickTime, and is defined in juce_Config.h | ||||
#if JUCE_QUICKTIME || DOXYGEN | #if JUCE_QUICKTIME || DOXYGEN | ||||
#if JUCE_WIN32 | |||||
#if JUCE_WINDOWS | |||||
#include "juce_ActiveXControlComponent.h" | #include "juce_ActiveXControlComponent.h" | ||||
typedef ActiveXControlComponent QTCompBaseClass; | typedef ActiveXControlComponent QTCompBaseClass; | ||||
#else | #else | ||||
@@ -179,7 +179,7 @@ private: | |||||
File movieFile; | File movieFile; | ||||
bool movieLoaded, controllerVisible, looping; | bool movieLoaded, controllerVisible, looping; | ||||
#if JUCE_WIN32 | |||||
#if JUCE_WINDOWS | |||||
/** @internal */ | /** @internal */ | ||||
void parentHierarchyChanged(); | void parentHierarchyChanged(); | ||||
/** @internal */ | /** @internal */ | ||||
@@ -25,7 +25,7 @@ | |||||
#include "../../../core/juce_StandardHeader.h" | #include "../../../core/juce_StandardHeader.h" | ||||
#if JUCE_WIN32 || JUCE_LINUX | |||||
#if JUCE_WINDOWS || JUCE_LINUX | |||||
BEGIN_JUCE_NAMESPACE | BEGIN_JUCE_NAMESPACE | ||||
@@ -26,7 +26,7 @@ | |||||
#ifndef __JUCE_SYSTEMTRAYICONCOMPONENT_JUCEHEADER__ | #ifndef __JUCE_SYSTEMTRAYICONCOMPONENT_JUCEHEADER__ | ||||
#define __JUCE_SYSTEMTRAYICONCOMPONENT_JUCEHEADER__ | #define __JUCE_SYSTEMTRAYICONCOMPONENT_JUCEHEADER__ | ||||
#if JUCE_WIN32 || JUCE_LINUX || DOXYGEN | |||||
#if JUCE_WINDOWS || JUCE_LINUX || DOXYGEN | |||||
#include "../juce_Component.h" | #include "../juce_Component.h" | ||||
@@ -35,11 +35,11 @@ BEGIN_JUCE_NAMESPACE | |||||
#include "../geometry/juce_Rectangle.h" | #include "../geometry/juce_Rectangle.h" | ||||
#include "../../../core/juce_SystemStats.h" | #include "../../../core/juce_SystemStats.h" | ||||
#if ! (defined (JUCE_MAC) || (defined (JUCE_WIN32) && defined (JUCE_64BIT))) | |||||
#if (JUCE_WINDOWS || JUCE_LINUX) && ! JUCE_64BIT | |||||
#define JUCE_USE_SSE_INSTRUCTIONS 1 | #define JUCE_USE_SSE_INSTRUCTIONS 1 | ||||
#endif | #endif | ||||
#if defined (JUCE_DEBUG) && JUCE_MSVC | |||||
#if JUCE_DEBUG && JUCE_MSVC | |||||
#pragma warning (disable: 4714) | #pragma warning (disable: 4714) | ||||
#endif | #endif | ||||
@@ -163,7 +163,7 @@ static void blendRectRGB (uint8* pixels, const int w, int h, const int stride, c | |||||
if (alpha <= 0) | if (alpha <= 0) | ||||
return; | return; | ||||
#if defined (JUCE_USE_SSE_INSTRUCTIONS) && ! JUCE_64BIT | |||||
#if JUCE_USE_SSE_INSTRUCTIONS | |||||
if (SystemStats::hasSSE()) | if (SystemStats::hasSSE()) | ||||
{ | { | ||||
int64 rgb0 = (((int64) blendColour.getRed()) << 32) | int64 rgb0 = (((int64) blendColour.getRed()) << 32) | ||||
@@ -30,7 +30,7 @@ | |||||
#include "../../core/juce_StandardHeader.h" | #include "../../core/juce_StandardHeader.h" | ||||
#ifndef JUCE_WIN32 | |||||
#if ! JUCE_WINDOWS | |||||
#include <pwd.h> | #include <pwd.h> | ||||
#endif | #endif | ||||
@@ -103,7 +103,7 @@ static const String parseAbsolutePath (String path) throw() | |||||
if (path.isEmpty()) | if (path.isEmpty()) | ||||
return String::empty; | return String::empty; | ||||
#if JUCE_WIN32 | |||||
#if JUCE_WINDOWS | |||||
// Windows.. | // Windows.. | ||||
path = path.replaceCharacter (T('/'), T('\\')); | path = path.replaceCharacter (T('/'), T('\\')); | ||||
@@ -271,7 +271,7 @@ bool File::hasWriteAccess() const throw() | |||||
if (exists()) | if (exists()) | ||||
return juce_canWriteToFile (fullPath); | return juce_canWriteToFile (fullPath); | ||||
#ifndef JUCE_WIN32 | |||||
#if ! JUCE_WINDOWS | |||||
else if ((! isDirectory()) && fullPath.containsChar (separator)) | else if ((! isDirectory()) && fullPath.containsChar (separator)) | ||||
return getParentDirectory().hasWriteAccess(); | return getParentDirectory().hasWriteAccess(); | ||||
else | else | ||||
@@ -444,7 +444,7 @@ bool File::isAChildOf (const File& potentialParent) const throw() | |||||
bool File::isAbsolutePath (const String& path) throw() | bool File::isAbsolutePath (const String& path) throw() | ||||
{ | { | ||||
return path.startsWithChar (T('/')) || path.startsWithChar (T('\\')) | return path.startsWithChar (T('/')) || path.startsWithChar (T('\\')) | ||||
#if JUCE_WIN32 | |||||
#if JUCE_WINDOWS | |||||
|| (path.isNotEmpty() && ((const String&) path)[1] == T(':')); | || (path.isNotEmpty() && ((const String&) path)[1] == T(':')); | ||||
#else | #else | ||||
|| path.startsWithChar (T('~')); | || path.startsWithChar (T('~')); | ||||
@@ -465,7 +465,7 @@ const File File::getChildFile (String relativePath) const throw() | |||||
if (relativePath[0] == T('.')) | if (relativePath[0] == T('.')) | ||||
{ | { | ||||
#if JUCE_WIN32 | |||||
#if JUCE_WINDOWS | |||||
relativePath = relativePath.replaceCharacter (T('/'), T('\\')).trimStart(); | relativePath = relativePath.replaceCharacter (T('/'), T('\\')).trimStart(); | ||||
#else | #else | ||||
relativePath = relativePath.replaceCharacter (T('\\'), T('/')).trimStart(); | relativePath = relativePath.replaceCharacter (T('\\'), T('/')).trimStart(); | ||||
@@ -1100,7 +1100,7 @@ const String File::getRelativePathFrom (const File& dir) const throw() | |||||
while (dirPath.isNotEmpty()) | while (dirPath.isNotEmpty()) | ||||
{ | { | ||||
#if JUCE_WIN32 | |||||
#if JUCE_WINDOWS | |||||
thisPath = T("..\\") + thisPath; | thisPath = T("..\\") + thisPath; | ||||
#else | #else | ||||
thisPath = T("../") + thisPath; | thisPath = T("../") + thisPath; | ||||
@@ -23,7 +23,9 @@ | |||||
============================================================================== | ============================================================================== | ||||
*/ | */ | ||||
#ifdef _WIN32 | |||||
#include "../../core/juce_TargetPlatform.h" | |||||
#if JUCE_WINDOWS | |||||
#include <winsock2.h> | #include <winsock2.h> | ||||
#ifdef _MSC_VER | #ifdef _MSC_VER | ||||
@@ -31,16 +33,14 @@ | |||||
#endif | #endif | ||||
#else | #else | ||||
#if defined (LINUX) || defined (__linux__) | |||||
#if JUCE_LINUX | |||||
#include <sys/types.h> | #include <sys/types.h> | ||||
#include <sys/socket.h> | #include <sys/socket.h> | ||||
#include <sys/errno.h> | #include <sys/errno.h> | ||||
#include <unistd.h> | #include <unistd.h> | ||||
#include <netinet/in.h> | #include <netinet/in.h> | ||||
#else | |||||
#if (MACOSX_DEPLOYMENT_TARGET <= MAC_OS_X_VERSION_10_4) && ! (TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR) | |||||
#include <CoreServices/CoreServices.h> | |||||
#endif | |||||
#elif (MACOSX_DEPLOYMENT_TARGET <= MAC_OS_X_VERSION_10_4) && ! JUCE_IPHONE | |||||
#include <CoreServices/CoreServices.h> | |||||
#endif | #endif | ||||
#include <fcntl.h> | #include <fcntl.h> | ||||
@@ -65,7 +65,7 @@ BEGIN_JUCE_NAMESPACE | |||||
//============================================================================== | //============================================================================== | ||||
#if JUCE_WIN32 | |||||
#if JUCE_WINDOWS | |||||
typedef int (__stdcall juce_CloseWin32SocketLibCall) (void); | typedef int (__stdcall juce_CloseWin32SocketLibCall) (void); | ||||
juce_CloseWin32SocketLibCall* juce_CloseWin32SocketLib = 0; | juce_CloseWin32SocketLibCall* juce_CloseWin32SocketLib = 0; | ||||
@@ -126,7 +126,7 @@ static int readSocket (const int handle, | |||||
{ | { | ||||
int bytesThisTime; | int bytesThisTime; | ||||
#if JUCE_WIN32 | |||||
#if JUCE_WINDOWS | |||||
bytesThisTime = recv (handle, ((char*) destBuffer) + bytesRead, maxBytesToRead - bytesRead, 0); | bytesThisTime = recv (handle, ((char*) destBuffer) + bytesRead, maxBytesToRead - bytesRead, 0); | ||||
#else | #else | ||||
while ((bytesThisTime = ::read (handle, ((char*) destBuffer) + bytesRead, maxBytesToRead - bytesRead)) < 0 | while ((bytesThisTime = ::read (handle, ((char*) destBuffer) + bytesRead, maxBytesToRead - bytesRead)) < 0 | ||||
@@ -179,7 +179,7 @@ static int waitForReadiness (const int handle, const bool forReading, | |||||
fd_set* const prset = forReading ? &rset : 0; | fd_set* const prset = forReading ? &rset : 0; | ||||
fd_set* const pwset = forReading ? 0 : &wset; | fd_set* const pwset = forReading ? 0 : &wset; | ||||
#if JUCE_WIN32 | |||||
#if JUCE_WINDOWS | |||||
if (select (handle + 1, prset, pwset, 0, timeoutp) < 0) | if (select (handle + 1, prset, pwset, 0, timeoutp) < 0) | ||||
return -1; | return -1; | ||||
#else | #else | ||||
@@ -213,7 +213,7 @@ static int waitForReadiness (const int handle, const bool forReading, | |||||
static bool setSocketBlockingState (const int handle, const bool shouldBlock) throw() | static bool setSocketBlockingState (const int handle, const bool shouldBlock) throw() | ||||
{ | { | ||||
#if JUCE_WIN32 | |||||
#if JUCE_WINDOWS | |||||
u_long nonBlocking = shouldBlock ? 0 : 1; | u_long nonBlocking = shouldBlock ? 0 : 1; | ||||
if (ioctlsocket (handle, FIONBIO, &nonBlocking) != 0) | if (ioctlsocket (handle, FIONBIO, &nonBlocking) != 0) | ||||
@@ -279,7 +279,7 @@ static bool connectSocket (int volatile& handle, | |||||
if (result < 0) | if (result < 0) | ||||
{ | { | ||||
#if JUCE_WIN32 | |||||
#if JUCE_WINDOWS | |||||
if (result == SOCKET_ERROR && WSAGetLastError() == WSAEWOULDBLOCK) | if (result == SOCKET_ERROR && WSAGetLastError() == WSAEWOULDBLOCK) | ||||
#else | #else | ||||
if (errno == EINPROGRESS) | if (errno == EINPROGRESS) | ||||
@@ -306,7 +306,7 @@ StreamingSocket::StreamingSocket() | |||||
connected (false), | connected (false), | ||||
isListener (false) | isListener (false) | ||||
{ | { | ||||
#if JUCE_WIN32 | |||||
#if JUCE_WINDOWS | |||||
initWin32Sockets(); | initWin32Sockets(); | ||||
#endif | #endif | ||||
} | } | ||||
@@ -320,7 +320,7 @@ StreamingSocket::StreamingSocket (const String& hostName_, | |||||
connected (true), | connected (true), | ||||
isListener (false) | isListener (false) | ||||
{ | { | ||||
#if JUCE_WIN32 | |||||
#if JUCE_WINDOWS | |||||
initWin32Sockets(); | initWin32Sockets(); | ||||
#endif | #endif | ||||
@@ -344,7 +344,7 @@ int StreamingSocket::write (const void* sourceBuffer, const int numBytesToWrite) | |||||
if (isListener || ! connected) | if (isListener || ! connected) | ||||
return -1; | return -1; | ||||
#if JUCE_WIN32 | |||||
#if JUCE_WINDOWS | |||||
return send (handle, (const char*) sourceBuffer, numBytesToWrite, 0); | return send (handle, (const char*) sourceBuffer, numBytesToWrite, 0); | ||||
#else | #else | ||||
int result; | int result; | ||||
@@ -403,7 +403,7 @@ bool StreamingSocket::connect (const String& remoteHostName, | |||||
void StreamingSocket::close() | void StreamingSocket::close() | ||||
{ | { | ||||
#if JUCE_WIN32 | |||||
#if JUCE_WINDOWS | |||||
closesocket (handle); | closesocket (handle); | ||||
connected = false; | connected = false; | ||||
#else | #else | ||||
@@ -497,7 +497,7 @@ DatagramSocket::DatagramSocket (const int localPortNumber, const bool allowBroad | |||||
allowBroadcast (allowBroadcast_), | allowBroadcast (allowBroadcast_), | ||||
serverAddress (0) | serverAddress (0) | ||||
{ | { | ||||
#if JUCE_WIN32 | |||||
#if JUCE_WINDOWS | |||||
initWin32Sockets(); | initWin32Sockets(); | ||||
#endif | #endif | ||||
@@ -514,7 +514,7 @@ DatagramSocket::DatagramSocket (const String& hostName_, const int portNumber_, | |||||
allowBroadcast (false), | allowBroadcast (false), | ||||
serverAddress (0) | serverAddress (0) | ||||
{ | { | ||||
#if JUCE_WIN32 | |||||
#if JUCE_WINDOWS | |||||
initWin32Sockets(); | initWin32Sockets(); | ||||
#endif | #endif | ||||
@@ -532,7 +532,7 @@ DatagramSocket::~DatagramSocket() | |||||
void DatagramSocket::close() | void DatagramSocket::close() | ||||
{ | { | ||||
#if JUCE_WIN32 | |||||
#if JUCE_WINDOWS | |||||
closesocket (handle); | closesocket (handle); | ||||
connected = false; | connected = false; | ||||
#else | #else | ||||
@@ -38,17 +38,18 @@ | |||||
#error | #error | ||||
#endif | #endif | ||||
#include "core/juce_TargetPlatform.h" // FORCE_AMALGAMATOR_INCLUDE | |||||
#include "../juce_Config.h" // FORCE_AMALGAMATOR_INCLUDE | #include "../juce_Config.h" // FORCE_AMALGAMATOR_INCLUDE | ||||
//============================================================================== | //============================================================================== | ||||
#ifdef _WIN32 | |||||
#if JUCE_WINDOWS | |||||
#include "native/windows/juce_win32_NativeIncludes.h" | #include "native/windows/juce_win32_NativeIncludes.h" | ||||
#elif defined (LINUX) | |||||
#elif JUCE_LINUX | |||||
#include "native/linux/juce_linux_NativeIncludes.h" | #include "native/linux/juce_linux_NativeIncludes.h" | ||||
#elif TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR | |||||
#include "native/mac/juce_iphone_NativeIncludes.h" | |||||
#else | |||||
#elif JUCE_MAC || JUCE_IPHONE | |||||
#include "native/mac/juce_mac_NativeIncludes.h" | #include "native/mac/juce_mac_NativeIncludes.h" | ||||
#else | |||||
#error "Unknown platform!" | |||||
#endif | #endif | ||||
//============================================================================== | //============================================================================== | ||||
@@ -338,7 +339,7 @@ | |||||
#endif | #endif | ||||
//============================================================================== | //============================================================================== | ||||
#if JUCE_WIN32 | |||||
#if JUCE_WINDOWS | |||||
#include "native/juce_win32_NativeCode.cpp" | #include "native/juce_win32_NativeCode.cpp" | ||||
#endif | #endif | ||||
@@ -346,10 +347,6 @@ | |||||
#include "native/juce_linux_NativeCode.cpp" | #include "native/juce_linux_NativeCode.cpp" | ||||
#endif | #endif | ||||
#if JUCE_MAC | |||||
#if JUCE_MAC || JUCE_IPHONE | |||||
#include "native/juce_mac_NativeCode.mm" | #include "native/juce_mac_NativeCode.mm" | ||||
#endif | #endif | ||||
#if JUCE_IPHONE | |||||
#include "native/juce_iphone_NativeCode.mm" | |||||
#endif |
@@ -1,111 +0,0 @@ | |||||
/* | |||||
============================================================================== | |||||
This file is part of the JUCE library - "Jules' Utility Class Extensions" | |||||
Copyright 2004-9 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. | |||||
============================================================================== | |||||
*/ | |||||
/* | |||||
This file wraps together all the mac-specific code, so that | |||||
we can include all the native headers just once, and compile all our | |||||
platform-specific stuff in one big lump, keeping it out of the way of | |||||
the rest of the codebase. | |||||
*/ | |||||
#include "mac/juce_iphone_NativeIncludes.h" | |||||
BEGIN_JUCE_NAMESPACE | |||||
//============================================================================== | |||||
#include "../core/juce_Singleton.h" | |||||
#include "../core/juce_Random.h" | |||||
#include "../core/juce_SystemStats.h" | |||||
#include "../threads/juce_Process.h" | |||||
#include "../threads/juce_Thread.h" | |||||
#include "../threads/juce_InterProcessLock.h" | |||||
#include "../io/files/juce_FileInputStream.h" | |||||
#include "../io/files/juce_NamedPipe.h" | |||||
#include "../io/network/juce_URL.h" | |||||
#include "../core/juce_PlatformUtilities.h" | |||||
#include "../text/juce_LocalisedStrings.h" | |||||
#include "../utilities/juce_DeletedAtShutdown.h" | |||||
#include "../application/juce_Application.h" | |||||
#include "../utilities/juce_SystemClipboard.h" | |||||
#include "../events/juce_MessageManager.h" | |||||
#include "../gui/graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.h" | |||||
#include "../gui/graphics/imaging/juce_ImageFileFormat.h" | |||||
#include "../gui/graphics/imaging/juce_CameraDevice.h" | |||||
#include "../gui/components/windows/juce_AlertWindow.h" | |||||
#include "../gui/components/juce_Desktop.h" | |||||
#include "../gui/components/menus/juce_MenuBarModel.h" | |||||
#include "../gui/components/special/juce_OpenGLComponent.h" | |||||
#include "../gui/components/special/juce_QuickTimeMovieComponent.h" | |||||
#include "../gui/components/mouse/juce_DragAndDropContainer.h" | |||||
#include "../gui/components/keyboard/juce_KeyPressMappingSet.h" | |||||
#include "../gui/components/special/juce_NSViewComponent.h" | |||||
#include "../gui/components/layout/juce_ComponentMovementWatcher.h" | |||||
#include "../gui/components/special/juce_WebBrowserComponent.h" | |||||
#include "../gui/components/filebrowser/juce_FileChooser.h" | |||||
#include "../audio/audio_file_formats/juce_AudioCDBurner.h" | |||||
#include "../audio/audio_file_formats/juce_AudioCDReader.h" | |||||
#include "../audio/audio_sources/juce_AudioSource.h" | |||||
#include "../audio/dsp/juce_AudioDataConverters.h" | |||||
#include "../audio/devices/juce_AudioIODeviceType.h" | |||||
#include "../audio/devices/juce_MidiOutput.h" | |||||
#include "../audio/devices/juce_MidiInput.h" | |||||
#undef Point | |||||
//============================================================================== | |||||
#define JUCE_INCLUDED_FILE 1 | |||||
// Now include the actual code files.. | |||||
#include "mac/juce_mac_ObjCSuffix.h" | |||||
#include "mac/juce_mac_Strings.mm" | |||||
#include "mac/juce_mac_SystemStats.mm" | |||||
#include "mac/juce_mac_Network.mm" | |||||
#include "common/juce_posix_NamedPipe.cpp" | |||||
#include "mac/juce_mac_Threads.mm" | |||||
#include "common/juce_posix_SharedCode.h" | |||||
#include "mac/juce_mac_Files.mm" | |||||
#include "mac/juce_iphone_MiscUtilities.mm" | |||||
#include "mac/juce_mac_Debugging.mm" | |||||
#if ! JUCE_ONLY_BUILD_CORE_LIBRARY | |||||
/*#include "mac/juce_mac_NSViewComponentPeer.mm" | |||||
#include "mac/juce_mac_MouseCursor.mm" | |||||
#include "mac/juce_mac_NSViewComponent.mm" | |||||
#include "mac/juce_mac_AppleRemote.mm" | |||||
#include "mac/juce_mac_OpenGLComponent.mm" | |||||
#include "mac/juce_mac_MainMenu.mm" | |||||
#include "mac/juce_mac_FileChooser.mm" | |||||
#include "mac/juce_mac_QuickTimeMovieComponent.mm" | |||||
#include "mac/juce_mac_AudioCDBurner.mm" | |||||
#include "mac/juce_mac_Fonts.mm" | |||||
#include "mac/juce_mac_MessageManager.mm" | |||||
#include "mac/juce_mac_WebBrowserComponent.mm" | |||||
#include "mac/juce_mac_CoreAudio.cpp" | |||||
#include "mac/juce_mac_CoreMidi.cpp" | |||||
#include "mac/juce_mac_CameraDevice.mm"*/ | |||||
#endif | |||||
END_JUCE_NAMESPACE |
@@ -86,25 +86,44 @@ BEGIN_JUCE_NAMESPACE | |||||
#include "mac/juce_mac_Threads.mm" | #include "mac/juce_mac_Threads.mm" | ||||
#include "common/juce_posix_SharedCode.h" | #include "common/juce_posix_SharedCode.h" | ||||
#include "mac/juce_mac_Files.mm" | #include "mac/juce_mac_Files.mm" | ||||
#include "mac/juce_mac_MiscUtilities.mm" | |||||
#if JUCE_IPHONE | |||||
#include "mac/juce_iphone_MiscUtilities.mm" | |||||
#else | |||||
#include "mac/juce_mac_MiscUtilities.mm" | |||||
#endif | |||||
#include "mac/juce_mac_Debugging.mm" | #include "mac/juce_mac_Debugging.mm" | ||||
#if ! JUCE_ONLY_BUILD_CORE_LIBRARY | #if ! JUCE_ONLY_BUILD_CORE_LIBRARY | ||||
#include "mac/juce_mac_NSViewComponentPeer.mm" | |||||
#include "mac/juce_mac_MouseCursor.mm" | |||||
#include "mac/juce_mac_NSViewComponent.mm" | |||||
#include "mac/juce_mac_AppleRemote.mm" | |||||
#include "mac/juce_mac_OpenGLComponent.mm" | |||||
#include "mac/juce_mac_MainMenu.mm" | |||||
#include "mac/juce_mac_FileChooser.mm" | |||||
#include "mac/juce_mac_QuickTimeMovieComponent.mm" | |||||
#include "mac/juce_mac_AudioCDBurner.mm" | |||||
#include "mac/juce_mac_Fonts.mm" | |||||
#include "mac/juce_mac_MessageManager.mm" | |||||
#include "mac/juce_mac_WebBrowserComponent.mm" | |||||
#include "mac/juce_mac_CoreAudio.cpp" | |||||
#include "mac/juce_mac_CoreMidi.cpp" | |||||
#include "mac/juce_mac_CameraDevice.mm" | |||||
#if JUCE_IPHONE | |||||
#include "mac/juce_iphone_UIViewComponentPeer.mm" | |||||
#include "mac/juce_iphone_Fonts.mm" | |||||
#include "mac/juce_iphone_MessageManager.mm" | |||||
#include "mac/juce_mac_FileChooser.mm" | |||||
#include "mac/juce_mac_OpenGLComponent.mm" | |||||
#include "mac/juce_mac_MouseCursor.mm" | |||||
#include "mac/juce_mac_WebBrowserComponent.mm" | |||||
//#include "mac/juce_mac_CoreAudio.cpp" | |||||
//#include "mac/juce_mac_CameraDevice.mm" | |||||
#include "mac/juce_mac_CoreMidi.cpp" | |||||
#else | |||||
#include "mac/juce_mac_NSViewComponentPeer.mm" | |||||
#include "mac/juce_mac_MouseCursor.mm" | |||||
#include "mac/juce_mac_NSViewComponent.mm" | |||||
#include "mac/juce_mac_AppleRemote.mm" | |||||
#include "mac/juce_mac_OpenGLComponent.mm" | |||||
#include "mac/juce_mac_MainMenu.mm" | |||||
#include "mac/juce_mac_FileChooser.mm" | |||||
#include "mac/juce_mac_QuickTimeMovieComponent.mm" | |||||
#include "mac/juce_mac_AudioCDBurner.mm" | |||||
#include "mac/juce_mac_Fonts.mm" | |||||
#include "mac/juce_mac_MessageManager.mm" | |||||
#include "mac/juce_mac_WebBrowserComponent.mm" | |||||
#include "mac/juce_mac_CoreAudio.cpp" | |||||
#include "mac/juce_mac_CoreMidi.cpp" | |||||
#include "mac/juce_mac_CameraDevice.mm" | |||||
#endif | |||||
#endif | #endif | ||||
END_JUCE_NAMESPACE | END_JUCE_NAMESPACE |
@@ -0,0 +1,449 @@ | |||||
/* | |||||
============================================================================== | |||||
This file is part of the JUCE library - "Jules' Utility Class Extensions" | |||||
Copyright 2004-9 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. | |||||
============================================================================== | |||||
*/ | |||||
// (This file gets included by juce_mac_NativeCode.mm, rather than being | |||||
// compiled on its own). | |||||
#ifdef JUCE_INCLUDED_FILE | |||||
@interface UIKitAUIOHost : UIViewController | |||||
{ | |||||
@public | |||||
/** READONLY The audio format of the data stream. */ | |||||
AudioStreamBasicDescription format; | |||||
AURenderCallbackStruct inputProc; | |||||
Float64 hwSampleRate; | |||||
AudioUnit rioUnit; | |||||
UGen rawInput; | |||||
UGen postFadeOutput; | |||||
UGen preFadeOutput; | |||||
int bufferSize; | |||||
float *floatBuffer; | |||||
UInt32 audioInputIsAvailable; | |||||
UInt32 numInputChannels; | |||||
UInt32 numOutputChannels; | |||||
bool isRunning; | |||||
float fadeInTime; | |||||
UGenArray others; | |||||
NSLock* nsLock; | |||||
} | |||||
/** Initialises the AudioUnit framework and structures. | |||||
Do not call this method, it is called automatically when the application launches. */ | |||||
- (void)initAudio; | |||||
/** Construct a UGen graph. | |||||
You must implement this in your subclass. You should return a UGen which will be the UGen graph which is | |||||
performed and rendered to the host. The input parameter may be ignored if only signal generation is required | |||||
or may be used if a processing algorithm is being implemented (e.g., filtering incoming audio data). | |||||
@param input The input UGen which will contain audio data from the host. | |||||
@return the UGen graph which will be performed */ | |||||
- (UGen)constructGraph:(UGen)input; | |||||
- (void)addOther:(UGen)ugen; | |||||
- (void)lock; | |||||
- (void)unlock; | |||||
- (BOOL)tryLock; | |||||
@end | |||||
#define NUM_CHANNELS 2 | |||||
void SetFormat(AudioStreamBasicDescription& format) | |||||
{ | |||||
memset(&format, 0, sizeof(AudioStreamBasicDescription)); | |||||
format.mFormatID = kAudioFormatLinearPCM; | |||||
int sampleSize = sizeof(AudioSampleType); | |||||
format.mFormatFlags = kAudioFormatFlagsCanonical; | |||||
format.mBitsPerChannel = 8 * sampleSize; | |||||
format.mChannelsPerFrame = NUM_CHANNELS; | |||||
format.mFramesPerPacket = 1; | |||||
format.mBytesPerPacket = format.mBytesPerFrame = sampleSize; | |||||
format.mFormatFlags |= kAudioFormatFlagIsNonInterleaved; | |||||
} | |||||
int SetupRemoteIO (AudioUnit& inRemoteIOUnit, AURenderCallbackStruct inRenderProc, AudioStreamBasicDescription& outFormat) | |||||
{ | |||||
// Open the output unit | |||||
AudioComponentDescription desc; | |||||
desc.componentType = kAudioUnitType_Output; | |||||
desc.componentSubType = kAudioUnitSubType_RemoteIO; | |||||
desc.componentManufacturer = kAudioUnitManufacturer_Apple; | |||||
desc.componentFlags = 0; | |||||
desc.componentFlagsMask = 0; | |||||
AudioComponent comp = AudioComponentFindNext (NULL, &desc); | |||||
AudioComponentInstanceNew (comp, &inRemoteIOUnit); | |||||
const UInt32 one = 1; | |||||
AudioUnitSetProperty(inRemoteIOUnit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Input, 1, &one, sizeof(one)); | |||||
AudioUnitSetProperty(inRemoteIOUnit, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Input, 0, &inRenderProc, sizeof(inRenderProc)); | |||||
AudioUnitSetProperty(inRemoteIOUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &outFormat, sizeof(outFormat)); | |||||
AudioUnitSetProperty(inRemoteIOUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, 1, &outFormat, sizeof(outFormat)); | |||||
AudioUnitInitialize(inRemoteIOUnit); | |||||
return 0; | |||||
} | |||||
static const float FloatToFixed824_Factor = 16777216.f; | |||||
static const float Fixed824ToFloat_Factor = 5.960464477539e-08f; | |||||
static const float FloatToPCM16Bit_Factor = 32767.f; | |||||
static const float PCM16BitToFloat_Factor = 3.051850947600e-05f; | |||||
static OSStatus PerformThru(void *inRefCon, | |||||
AudioUnitRenderActionFlags *ioActionFlags, | |||||
const AudioTimeStamp *inTimeStamp, | |||||
UInt32 inBusNumber, | |||||
UInt32 inNumberFrames, | |||||
AudioBufferList *ioData) | |||||
{ | |||||
OSStatus err = 0; | |||||
UIKitAUIOHost *x = (UIKitAUIOHost *)inRefCon; | |||||
[x lock]; | |||||
if(x->audioInputIsAvailable) | |||||
{ | |||||
err = AudioUnitRender(x->rioUnit, ioActionFlags, inTimeStamp, 1, inNumberFrames, ioData); | |||||
if (err) { printf("PerformThru: error %d\n", (int)err); return err; } | |||||
} | |||||
if(inNumberFrames > x->bufferSize) | |||||
{ | |||||
delete [] x->floatBuffer; | |||||
x->bufferSize = inNumberFrames; | |||||
x->floatBuffer = new float[inNumberFrames * NUM_CHANNELS]; | |||||
} | |||||
long blockID = UGen::getNextBlockID(inNumberFrames); | |||||
float *floatBufferData[2]; | |||||
floatBufferData[0] = x->floatBuffer; | |||||
floatBufferData[1] = floatBufferData[0] + inNumberFrames; | |||||
if(x->audioInputIsAvailable) | |||||
{ | |||||
for (UInt32 channel = 0; channel < x->numInputChannels; channel++) | |||||
{ | |||||
AudioSampleType *audioUnitBuffer = (AudioSampleType*)ioData->mBuffers[0].mData; | |||||
float *floatBuffer = floatBufferData[channel]; | |||||
for(int sample = 0; sample < inNumberFrames; sample++) | |||||
{ | |||||
floatBuffer[sample] = (float)audioUnitBuffer[sample] * PCM16BitToFloat_Factor; | |||||
} | |||||
} | |||||
x->rawInput.getSource().setInputs((const float**)floatBufferData, inNumberFrames, x->numInputChannels); | |||||
} | |||||
else | |||||
{ | |||||
memset(x->floatBuffer, 0, x->numInputChannels * inNumberFrames * sizeof(float)); | |||||
} | |||||
x->postFadeOutput.setOutputs(floatBufferData, inNumberFrames, 2); | |||||
x->postFadeOutput.prepareAndProcessBlock(inNumberFrames, blockID); | |||||
for (UInt32 channel = 0; channel < ioData->mNumberBuffers; channel++) | |||||
{ | |||||
AudioSampleType *audioUnitBuffer = (AudioSampleType*)ioData->mBuffers[channel].mData; | |||||
float *floatBuffer = floatBufferData[channel]; | |||||
for(int sample = 0; sample < inNumberFrames; sample++) | |||||
{ | |||||
audioUnitBuffer[sample] = (AudioSampleType)(floatBuffer[sample] * FloatToPCM16Bit_Factor); | |||||
} | |||||
} | |||||
for(int i = 0; i < x->others.size(); i++) | |||||
{ | |||||
x->others[i].prepareAndProcessBlock(inNumberFrames, blockID); | |||||
} | |||||
[x unlock]; | |||||
return err; | |||||
} | |||||
void propListener(void * inClientData, | |||||
AudioSessionPropertyID inID, | |||||
UInt32 inDataSize, | |||||
const void * inPropertyValue) | |||||
{ | |||||
printf("Property changed!\n"); | |||||
UIKitAUIOHost *x = (UIKitAUIOHost *)inClientData; | |||||
if(!x->isRunning) return; | |||||
if(inPropertyValue) | |||||
{ | |||||
CFDictionaryRef routeChangeDictionary = (CFDictionaryRef)inPropertyValue; | |||||
CFNumberRef routeChangeReasonRef = | |||||
(CFNumberRef)CFDictionaryGetValue (routeChangeDictionary, | |||||
CFSTR (kAudioSession_AudioRouteChangeKey_Reason)); | |||||
SInt32 routeChangeReason; | |||||
CFNumberGetValue(routeChangeReasonRef, kCFNumberSInt32Type, &routeChangeReason); | |||||
CFStringRef newAudioRoute; | |||||
UInt32 propertySize = sizeof (CFStringRef); | |||||
AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &propertySize, &newAudioRoute); | |||||
printf("route=%s\n", CFStringGetCStringPtr(newAudioRoute, CFStringGetSystemEncoding())); | |||||
} | |||||
UInt32 size = sizeof(UInt32); | |||||
AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareInputNumberChannels, &size, &x->numInputChannels); | |||||
AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareOutputNumberChannels, &size, &x->numOutputChannels); | |||||
AudioSessionGetProperty(kAudioSessionProperty_AudioInputAvailable, &size, &x->audioInputIsAvailable); | |||||
printf("inputs=%d outputs=%d audioInputIsAvailable=%d\n", x->numInputChannels, x->numOutputChannels, x->audioInputIsAvailable); | |||||
if(x->rioUnit) | |||||
{ | |||||
AudioComponentInstanceDispose(x->rioUnit); | |||||
} | |||||
SetFormat(x->format); | |||||
SetupRemoteIO(x->rioUnit, x->inputProc, x->format); | |||||
x->rawInput.setSource(AudioIn::AR(x->numInputChannels), true); | |||||
x->postFadeOutput = Plug::AR(UGen::emptyChannels(x->preFadeOutput.getNumChannels())); | |||||
x->postFadeOutput.fadeSourceAndRelease(x->preFadeOutput, x->fadeInTime); | |||||
AudioSessionSetActive(true); | |||||
AudioOutputUnitStart(x->rioUnit); | |||||
} | |||||
void rioInterruptionListener(void *inClientData, UInt32 inInterruption) | |||||
{ | |||||
printf("Session interrupted! --- %s ---\n", inInterruption == kAudioSessionBeginInterruption ? "Begin Interruption" : "End Interruption"); | |||||
UIKitAUIOHost *x = (UIKitAUIOHost *)inClientData; | |||||
if (inInterruption == kAudioSessionEndInterruption) { | |||||
// make sure we are again the active session | |||||
//AudioSessionSetActive(false); | |||||
AudioSessionSetActive(true); | |||||
x->isRunning = true; | |||||
AudioOutputUnitStart(x->rioUnit); | |||||
} | |||||
if (inInterruption == kAudioSessionBeginInterruption) { | |||||
x->isRunning = false; | |||||
AudioOutputUnitStop(x->rioUnit); | |||||
printf("rioInterruptionListener audioInputIsAvailable=%d\n", x->audioInputIsAvailable); | |||||
UIAlertView *baseAlert = [[UIAlertView alloc] initWithTitle:@"Audio interrupted" | |||||
message:@"This could have been interrupted by another application or due to unplugging a headset:" | |||||
delegate:x | |||||
cancelButtonTitle:nil | |||||
otherButtonTitles:@"Resume", @"Cancel", nil]; | |||||
[baseAlert show]; | |||||
} | |||||
} | |||||
@implementation UIKitAUIOHost | |||||
- (id)init | |||||
{ | |||||
if (self = [super init]) | |||||
{ | |||||
nsLock = [[NSLock alloc] init]; | |||||
fadeInTime = 1.0; | |||||
[self performSelector:@selector(initAudio) withObject:nil afterDelay:1.0]; | |||||
} | |||||
return self; | |||||
} | |||||
- (void)initAudio | |||||
{ | |||||
// render proc | |||||
inputProc.inputProc = PerformThru; | |||||
inputProc.inputProcRefCon = self; | |||||
// session | |||||
AudioSessionInitialize (NULL, NULL, rioInterruptionListener, self); | |||||
AudioSessionSetActive (true); | |||||
UInt32 audioCategory = kAudioSessionCategory_PlayAndRecord; | |||||
AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(audioCategory), &audioCategory); | |||||
AudioSessionAddPropertyListener(kAudioSessionProperty_AudioRouteChange, propListener, self); | |||||
UInt32 size = sizeof(hwSampleRate); | |||||
AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareSampleRate, &size, &hwSampleRate); | |||||
Float32 bufferDuration = 512 / hwSampleRate; | |||||
AudioSessionSetProperty(kAudioSessionProperty_PreferredHardwareIOBufferDuration, sizeof(bufferDuration), &bufferDuration); | |||||
UGen::initialise(); | |||||
UGen::prepareToPlay(hwSampleRate, 512); | |||||
rawInput = Plug::AR(UGen::emptyChannels(2)); | |||||
preFadeOutput = [self constructGraph: rawInput]; | |||||
rioUnit = NULL; | |||||
isRunning = true; | |||||
propListener((void*)self, 0,0,0); | |||||
size = sizeof(format); | |||||
AudioUnitGetProperty(rioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, 1, &format, &size); | |||||
//Float32 bufferDuration; | |||||
size = sizeof(bufferDuration); | |||||
AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareIOBufferDuration, &size, &bufferDuration); | |||||
bufferSize = (int)(hwSampleRate*bufferDuration+0.5); | |||||
floatBuffer = new float[bufferSize * NUM_CHANNELS]; | |||||
} | |||||
- (UGen)constructGraph:(UGen)input | |||||
{ | |||||
return UGen::emptyChannels(NUM_CHANNELS); | |||||
} | |||||
- (void)addOther:(UGen)ugen | |||||
{ | |||||
[self lock]; | |||||
others <<= ugen; | |||||
[self unlock]; | |||||
} | |||||
- (void)lock | |||||
{ | |||||
[nsLock lock]; | |||||
} | |||||
- (void)unlock | |||||
{ | |||||
[nsLock unlock]; | |||||
} | |||||
- (BOOL)tryLock | |||||
{ | |||||
return [nsLock tryLock]; | |||||
} | |||||
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex | |||||
{ | |||||
printf("buttonIndex=%d\n", buttonIndex); | |||||
if(buttonIndex == 0) | |||||
{ | |||||
// resume | |||||
isRunning = true; | |||||
propListener((void*)self, 0,0,0); | |||||
} | |||||
[alertView release]; | |||||
} | |||||
-(void) dealloc | |||||
{ | |||||
UGen::shutdown(); | |||||
delete [] floatBuffer; | |||||
[nsLock release]; | |||||
[super dealloc]; | |||||
} | |||||
@end | |||||
//============================================================================== | |||||
class IPhoneAudioIODeviceType : public AudioIODeviceType | |||||
{ | |||||
public: | |||||
//============================================================================== | |||||
IPhoneAudioIODeviceType() | |||||
: AudioIODeviceType (T("iPhone Audio")), | |||||
hasScanned (false) | |||||
{ | |||||
} | |||||
~IPhoneAudioIODeviceType() | |||||
{ | |||||
} | |||||
//============================================================================== | |||||
void scanForDevices() | |||||
{ | |||||
} | |||||
const StringArray getDeviceNames (const bool wantInputNames) const | |||||
{ | |||||
StringArray s; | |||||
return s; | |||||
} | |||||
int getDefaultDeviceIndex (const bool forInput) const | |||||
{ | |||||
return 0; | |||||
} | |||||
int getIndexOfDevice (AudioIODevice* device, const bool asInput) const | |||||
{ | |||||
return 0; | |||||
} | |||||
bool hasSeparateInputsAndOutputs() const { return true; } | |||||
AudioIODevice* createDevice (const String& outputDeviceName, | |||||
const String& inputDeviceName) | |||||
{ | |||||
if (outputDeviceName.isNotEmpty() && inputDeviceName.isNotEmpty()) | |||||
return new CoreAudioIODevice (deviceName, | |||||
inputIds [inputIndex], | |||||
inputIndex, | |||||
outputIds [outputIndex], | |||||
outputIndex); | |||||
return 0; | |||||
} | |||||
//============================================================================== | |||||
juce_UseDebuggingNewOperator | |||||
private: | |||||
IPhoneAudioIODeviceType (const IPhoneAudioIODeviceType&); | |||||
const IPhoneAudioIODeviceType& operator= (const IPhoneAudioIODeviceType&); | |||||
}; | |||||
//============================================================================== | |||||
AudioIODeviceType* juce_createAudioIODeviceType_iPhoneAudio() | |||||
{ | |||||
return new IPhoneAudioIODeviceType(); | |||||
} | |||||
#endif |
@@ -0,0 +1,352 @@ | |||||
/* | |||||
============================================================================== | |||||
This file is part of the JUCE library - "Jules' Utility Class Extensions" | |||||
Copyright 2004-9 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. | |||||
============================================================================== | |||||
*/ | |||||
// (This file gets included by juce_mac_NativeCode.mm, rather than being | |||||
// compiled on its own). | |||||
#ifdef JUCE_INCLUDED_FILE | |||||
//============================================================================== | |||||
class FontHelper | |||||
{ | |||||
UIFont* font; | |||||
public: | |||||
String name; | |||||
bool isBold, isItalic, needsItalicTransform; | |||||
float fontSize, totalSize, ascent; | |||||
int refCount; | |||||
FontHelper (const String& name_, | |||||
const bool bold_, | |||||
const bool italic_, | |||||
const float size_) | |||||
: font (0), | |||||
name (name_), | |||||
isBold (bold_), | |||||
isItalic (italic_), | |||||
needsItalicTransform (false), | |||||
fontSize (size_), | |||||
refCount (1) | |||||
{ | |||||
//attributes = [[NSMutableDictionary dictionaryWithObject: [NSNumber numberWithInt: 0] | |||||
// forKey: NSLigatureAttributeName] retain]; | |||||
font = [UIFont fontWithName: juceStringToNS (name_) size: size_]; | |||||
if (italic_) | |||||
{ | |||||
/* NSFont* newFont = [[NSFontManager sharedFontManager] convertFont: font toHaveTrait: NSItalicFontMask]; | |||||
if (newFont == font) | |||||
needsItalicTransform = true; // couldn't find a proper italic version, so fake it with a transform.. | |||||
font = newFont;*/ | |||||
} | |||||
// if (bold_) | |||||
// font = [[NSFontManager sharedFontManager] convertFont: font toHaveTrait: NSBoldFontMask]; | |||||
[font retain]; | |||||
ascent = fabsf (font.ascender); | |||||
totalSize = ascent + fabsf (font.descender); | |||||
} | |||||
~FontHelper() | |||||
{ | |||||
[font release]; | |||||
} | |||||
bool getPathAndKerning (const juce_wchar char1, | |||||
const juce_wchar char2, | |||||
Path* path, | |||||
float& kerning, | |||||
float* ascent, | |||||
float* descent) | |||||
{ | |||||
const ScopedAutoReleasePool pool; | |||||
return false; | |||||
/* if (font == 0 | |||||
|| ! [[font coveredCharacterSet] longCharacterIsMember: (UTF32Char) char1]) | |||||
return false; | |||||
String chars; | |||||
chars << ' ' << char1 << char2; | |||||
NSTextStorage* textStorage = [[[NSTextStorage alloc] initWithString: juceStringToNS (chars) | |||||
attributes: attributes] autorelease]; | |||||
NSLayoutManager* layoutManager = [[[NSLayoutManager alloc] init] autorelease]; | |||||
NSTextContainer* textContainer = [[[NSTextContainer alloc] init] autorelease]; | |||||
[layoutManager addTextContainer: textContainer]; | |||||
[textStorage addLayoutManager: layoutManager]; | |||||
[textStorage setFont: font]; | |||||
unsigned int glyphIndex = [layoutManager glyphRangeForCharacterRange: NSMakeRange (1, 1) | |||||
actualCharacterRange: 0].location; | |||||
NSPoint p1 = [layoutManager locationForGlyphAtIndex: glyphIndex]; | |||||
NSPoint p2 = [layoutManager locationForGlyphAtIndex: glyphIndex + 1]; | |||||
kerning = p2.x - p1.x; | |||||
if (ascent != 0) | |||||
*ascent = this->ascent; | |||||
if (descent != 0) | |||||
*descent = fabsf ([font descender]); | |||||
if (path != 0) | |||||
{ | |||||
NSBezierPath* bez = [NSBezierPath bezierPath]; | |||||
[bez moveToPoint: NSMakePoint (0, 0)]; | |||||
[bez appendBezierPathWithGlyph: [layoutManager glyphAtIndex: glyphIndex] | |||||
inFont: font]; | |||||
for (int i = 0; i < [bez elementCount]; ++i) | |||||
{ | |||||
NSPoint p[3]; | |||||
switch ([bez elementAtIndex: i associatedPoints: p]) | |||||
{ | |||||
case NSMoveToBezierPathElement: | |||||
path->startNewSubPath (p[0].x, -p[0].y); | |||||
break; | |||||
case NSLineToBezierPathElement: | |||||
path->lineTo (p[0].x, -p[0].y); | |||||
break; | |||||
case NSCurveToBezierPathElement: | |||||
path->cubicTo (p[0].x, -p[0].y, p[1].x, -p[1].y, p[2].x, -p[2].y); | |||||
break; | |||||
case NSClosePathBezierPathElement: | |||||
path->closeSubPath(); | |||||
break; | |||||
default: | |||||
jassertfalse | |||||
break; | |||||
} | |||||
} | |||||
if (needsItalicTransform) | |||||
path->applyTransform (AffineTransform::identity.sheared (-0.15, 0)); | |||||
} | |||||
return kerning != 0;*/ | |||||
} | |||||
juce_wchar getDefaultChar() | |||||
{ | |||||
return 0; | |||||
} | |||||
}; | |||||
//============================================================================== | |||||
class FontHelperCache : public Timer, | |||||
public DeletedAtShutdown | |||||
{ | |||||
VoidArray cache; | |||||
public: | |||||
FontHelperCache() | |||||
{ | |||||
} | |||||
~FontHelperCache() | |||||
{ | |||||
for (int i = cache.size(); --i >= 0;) | |||||
{ | |||||
FontHelper* const f = (FontHelper*) cache.getUnchecked(i); | |||||
delete f; | |||||
} | |||||
clearSingletonInstance(); | |||||
} | |||||
FontHelper* getFont (const String& name, | |||||
const bool bold, | |||||
const bool italic, | |||||
const float size = 1024) | |||||
{ | |||||
for (int i = cache.size(); --i >= 0;) | |||||
{ | |||||
FontHelper* const f = (FontHelper*) cache.getUnchecked(i); | |||||
if (f->name == name | |||||
&& f->isBold == bold | |||||
&& f->isItalic == italic | |||||
&& f->fontSize == size) | |||||
{ | |||||
f->refCount++; | |||||
return f; | |||||
} | |||||
} | |||||
FontHelper* const f = new FontHelper (name, bold, italic, size); | |||||
cache.add (f); | |||||
return f; | |||||
} | |||||
void releaseFont (FontHelper* f) | |||||
{ | |||||
for (int i = cache.size(); --i >= 0;) | |||||
{ | |||||
FontHelper* const f2 = (FontHelper*) cache.getUnchecked(i); | |||||
if (f == f2) | |||||
{ | |||||
f->refCount--; | |||||
if (f->refCount == 0) | |||||
startTimer (5000); | |||||
break; | |||||
} | |||||
} | |||||
} | |||||
void timerCallback() | |||||
{ | |||||
stopTimer(); | |||||
for (int i = cache.size(); --i >= 0;) | |||||
{ | |||||
FontHelper* const f = (FontHelper*) cache.getUnchecked(i); | |||||
if (f->refCount == 0) | |||||
{ | |||||
cache.remove (i); | |||||
delete f; | |||||
} | |||||
} | |||||
if (cache.size() == 0) | |||||
delete this; | |||||
} | |||||
juce_DeclareSingleton_SingleThreaded_Minimal (FontHelperCache) | |||||
}; | |||||
juce_ImplementSingleton_SingleThreaded (FontHelperCache) | |||||
//============================================================================== | |||||
void Typeface::initialiseTypefaceCharacteristics (const String& fontName, | |||||
bool bold, | |||||
bool italic, | |||||
bool addAllGlyphsToFont) throw() | |||||
{ | |||||
// This method is only safe to be called from the normal UI thread.. | |||||
jassert (MessageManager::getInstance()->isThisTheMessageThread()); | |||||
FontHelper* const helper = FontHelperCache::getInstance() | |||||
->getFont (fontName, bold, italic); | |||||
clear(); | |||||
setAscent (helper->ascent / helper->totalSize); | |||||
setName (fontName); | |||||
setDefaultCharacter (helper->getDefaultChar()); | |||||
setBold (bold); | |||||
setItalic (italic); | |||||
if (addAllGlyphsToFont) | |||||
{ | |||||
//xxx | |||||
jassertfalse | |||||
} | |||||
FontHelperCache::getInstance()->releaseFont (helper); | |||||
} | |||||
bool Typeface::findAndAddSystemGlyph (juce_wchar character) throw() | |||||
{ | |||||
// This method is only safe to be called from the normal UI thread.. | |||||
jassert (MessageManager::getInstance()->isThisTheMessageThread()); | |||||
if (character == 0) | |||||
return false; | |||||
FontHelper* const helper = FontHelperCache::getInstance() | |||||
->getFont (getName(), isBold(), isItalic()); | |||||
Path path; | |||||
float width; | |||||
bool foundOne = false; | |||||
if (helper->getPathAndKerning (character, T('I'), &path, width, 0, 0)) | |||||
{ | |||||
path.applyTransform (AffineTransform::scale (1.0f / helper->totalSize, | |||||
1.0f / helper->totalSize)); | |||||
addGlyph (character, path, width / helper->totalSize); | |||||
for (int i = 0; i < glyphs.size(); ++i) | |||||
{ | |||||
const TypefaceGlyphInfo* const g = (const TypefaceGlyphInfo*) glyphs.getUnchecked(i); | |||||
float kerning; | |||||
if (helper->getPathAndKerning (character, g->getCharacter(), 0, kerning, 0, 0)) | |||||
{ | |||||
kerning = (kerning - width) / helper->totalSize; | |||||
if (kerning != 0) | |||||
addKerningPair (character, g->getCharacter(), kerning); | |||||
} | |||||
if (helper->getPathAndKerning (g->getCharacter(), character, 0, kerning, 0, 0)) | |||||
{ | |||||
kerning = kerning / helper->totalSize - g->width; | |||||
if (kerning != 0) | |||||
addKerningPair (g->getCharacter(), character, kerning); | |||||
} | |||||
} | |||||
foundOne = true; | |||||
} | |||||
FontHelperCache::getInstance()->releaseFont (helper); | |||||
return foundOne; | |||||
} | |||||
//============================================================================== | |||||
const StringArray Font::findAllTypefaceNames() throw() | |||||
{ | |||||
StringArray names; | |||||
const ScopedAutoReleasePool pool; | |||||
NSArray* fonts = [UIFont familyNames]; | |||||
for (unsigned int i = 0; i < [fonts count]; ++i) | |||||
names.add (nsStringToJuce ((NSString*) [fonts objectAtIndex: i])); | |||||
names.sort (true); | |||||
return names; | |||||
} | |||||
void Typeface::getDefaultFontNames (String& defaultSans, String& defaultSerif, String& defaultFixed) throw() | |||||
{ | |||||
defaultSans = "Lucida Grande"; | |||||
defaultSerif = "Times New Roman"; | |||||
defaultFixed = "Monaco"; | |||||
} | |||||
#endif |
@@ -0,0 +1,325 @@ | |||||
/* | |||||
============================================================================== | |||||
This file is part of the JUCE library - "Jules' Utility Class Extensions" | |||||
Copyright 2004-9 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. | |||||
============================================================================== | |||||
*/ | |||||
// (This file gets included by juce_mac_NativeCode.mm, rather than being | |||||
// compiled on its own). | |||||
#ifdef JUCE_INCLUDED_FILE | |||||
struct CallbackMessagePayload | |||||
{ | |||||
MessageCallbackFunction* function; | |||||
void* parameter; | |||||
void* volatile result; | |||||
bool volatile hasBeenExecuted; | |||||
}; | |||||
/* When you use multiple DLLs which share similarly-named obj-c classes - like | |||||
for example having more than one juce plugin loaded into a host, then when a | |||||
method is called, the actual code that runs might actually be in a different module | |||||
than the one you expect... So any calls to library functions or statics that are | |||||
made inside obj-c methods will probably end up getting executed in a different DLL's | |||||
memory space. Not a great thing to happen - this obviously leads to bizarre crashes. | |||||
To work around this insanity, I'm only allowing obj-c methods to make calls to | |||||
virtual methods of an object that's known to live inside the right module's space. | |||||
*/ | |||||
class AppDelegateRedirector | |||||
{ | |||||
public: | |||||
AppDelegateRedirector() {} | |||||
virtual ~AppDelegateRedirector() {} | |||||
virtual BOOL openFile (const NSString* filename) | |||||
{ | |||||
if (JUCEApplication::getInstance() != 0) | |||||
{ | |||||
JUCEApplication::getInstance()->anotherInstanceStarted (nsStringToJuce (filename)); | |||||
return YES; | |||||
} | |||||
return NO; | |||||
} | |||||
virtual void openFiles (NSArray* filenames) | |||||
{ | |||||
StringArray files; | |||||
for (unsigned int i = 0; i < [filenames count]; ++i) | |||||
files.add (nsStringToJuce ((NSString*) [filenames objectAtIndex: i])); | |||||
if (files.size() > 0 && JUCEApplication::getInstance() != 0) | |||||
{ | |||||
JUCEApplication::getInstance()->anotherInstanceStarted (files.joinIntoString (T(" "))); | |||||
} | |||||
} | |||||
virtual void focusChanged() | |||||
{ | |||||
juce_HandleProcessFocusChange(); | |||||
} | |||||
virtual void deliverMessage (void* message) | |||||
{ | |||||
// no need for an mm lock here - deliverMessage locks it | |||||
MessageManager::getInstance()->deliverMessage (message); | |||||
} | |||||
virtual void performCallback (CallbackMessagePayload* pl) | |||||
{ | |||||
pl->result = (*pl->function) (pl->parameter); | |||||
pl->hasBeenExecuted = true; | |||||
} | |||||
virtual void deleteSelf() | |||||
{ | |||||
delete this; | |||||
} | |||||
}; | |||||
END_JUCE_NAMESPACE | |||||
using namespace JUCE_NAMESPACE; | |||||
#define JuceAppDelegate MakeObjCClassName(JuceAppDelegate) | |||||
static int numPendingMessages = 0; | |||||
@interface JuceAppDelegate : NSObject <UIApplicationDelegate> | |||||
{ | |||||
@private | |||||
id oldDelegate; | |||||
AppDelegateRedirector* redirector; | |||||
@public | |||||
bool flushingMessages; | |||||
} | |||||
- (JuceAppDelegate*) init; | |||||
- (void) dealloc; | |||||
- (BOOL) application: (UIApplication*) application handleOpenURL: (NSURL*) url; | |||||
- (void) applicationDidBecomeActive: (NSNotification*) aNotification; | |||||
- (void) applicationDidResignActive: (NSNotification*) aNotification; | |||||
- (void) applicationWillUnhide: (NSNotification*) aNotification; | |||||
- (void) customEvent: (id) data; | |||||
- (void) performCallback: (id) info; | |||||
- (void) dummyMethod; | |||||
@end | |||||
@implementation JuceAppDelegate | |||||
- (JuceAppDelegate*) init | |||||
{ | |||||
[super init]; | |||||
redirector = new AppDelegateRedirector(); | |||||
numPendingMessages = 0; | |||||
flushingMessages = false; | |||||
oldDelegate = [[UIApplication sharedApplication] delegate]; | |||||
[[UIApplication sharedApplication] setDelegate: self]; | |||||
return self; | |||||
} | |||||
- (void) dealloc | |||||
{ | |||||
if (oldDelegate != 0) | |||||
[[UIApplication sharedApplication] setDelegate: oldDelegate]; | |||||
redirector->deleteSelf(); | |||||
[super dealloc]; | |||||
} | |||||
- (BOOL) application: (UIApplication*) application handleOpenURL: (NSURL*) url | |||||
{ | |||||
return redirector->openFile ([url absoluteString]); | |||||
} | |||||
- (void) applicationDidBecomeActive: (NSNotification*) aNotification | |||||
{ | |||||
redirector->focusChanged(); | |||||
} | |||||
- (void) applicationDidResignActive: (NSNotification*) aNotification | |||||
{ | |||||
redirector->focusChanged(); | |||||
} | |||||
- (void) applicationWillUnhide: (NSNotification*) aNotification | |||||
{ | |||||
redirector->focusChanged(); | |||||
} | |||||
- (void) customEvent: (id) n | |||||
{ | |||||
atomicDecrement (numPendingMessages); | |||||
NSData* data = (NSData*) n; | |||||
void* message = 0; | |||||
[data getBytes: &message length: sizeof (message)]; | |||||
[data release]; | |||||
if (message != 0 && ! flushingMessages) | |||||
redirector->deliverMessage (message); | |||||
} | |||||
- (void) performCallback: (id) info | |||||
{ | |||||
if ([info isKindOfClass: [NSData class]]) | |||||
{ | |||||
CallbackMessagePayload* pl = (CallbackMessagePayload*) [((NSData*) info) bytes]; | |||||
if (pl != 0) | |||||
redirector->performCallback (pl); | |||||
} | |||||
else | |||||
{ | |||||
jassertfalse // should never get here! | |||||
} | |||||
} | |||||
- (void) dummyMethod {} // (used as a way of running a dummy thread) | |||||
@end | |||||
BEGIN_JUCE_NAMESPACE | |||||
static JuceAppDelegate* juceAppDelegate = 0; | |||||
void MessageManager::runDispatchLoop() | |||||
{ | |||||
jassert (isThisTheMessageThread()); // must only be called by the message thread | |||||
runDispatchLoopUntil (-1); | |||||
} | |||||
static const int quitMessageId = 0xfffff321; | |||||
void MessageManager::stopDispatchLoop() | |||||
{ | |||||
Message* const m = new Message (quitMessageId, 0, 0, 0); | |||||
m->messageRecipient = 0; | |||||
postMessageToQueue (m); | |||||
quitMessagePosted = true; | |||||
} | |||||
bool MessageManager::runDispatchLoopUntil (int millisecondsToRunFor) | |||||
{ | |||||
const ScopedAutoReleasePool pool; | |||||
jassert (isThisTheMessageThread()); // must only be called by the message thread | |||||
uint32 endTime = Time::getMillisecondCounter() + millisecondsToRunFor; | |||||
NSDate* endDate = [NSDate dateWithTimeIntervalSinceNow: millisecondsToRunFor * 0.001]; | |||||
while (! quitMessagePosted) | |||||
{ | |||||
const ScopedAutoReleasePool pool; | |||||
[[NSRunLoop currentRunLoop] runMode: NSDefaultRunLoopMode | |||||
beforeDate: endDate]; | |||||
if (millisecondsToRunFor >= 0 && Time::getMillisecondCounter() >= endTime) | |||||
break; | |||||
} | |||||
return ! quitMessagePosted; | |||||
} | |||||
//============================================================================== | |||||
void MessageManager::doPlatformSpecificInitialisation() | |||||
{ | |||||
if (juceAppDelegate == 0) | |||||
juceAppDelegate = [[JuceAppDelegate alloc] init]; | |||||
} | |||||
void MessageManager::doPlatformSpecificShutdown() | |||||
{ | |||||
if (juceAppDelegate != 0) | |||||
{ | |||||
[[NSRunLoop currentRunLoop] cancelPerformSelectorsWithTarget: juceAppDelegate]; | |||||
[[NSNotificationCenter defaultCenter] removeObserver: juceAppDelegate]; | |||||
// Annoyingly, cancelPerformSelectorsWithTarget can't actually cancel the messages | |||||
// sent by performSelectorOnMainThread, so need to manually flush these before quitting.. | |||||
juceAppDelegate->flushingMessages = true; | |||||
for (int i = 100; --i >= 0 && numPendingMessages > 0;) | |||||
{ | |||||
const ScopedAutoReleasePool pool; | |||||
[[NSRunLoop currentRunLoop] runMode: NSDefaultRunLoopMode | |||||
beforeDate: [NSDate dateWithTimeIntervalSinceNow: 5 * 0.001]]; | |||||
} | |||||
[juceAppDelegate release]; | |||||
juceAppDelegate = 0; | |||||
} | |||||
} | |||||
bool juce_postMessageToSystemQueue (void* message) | |||||
{ | |||||
atomicIncrement (numPendingMessages); | |||||
[juceAppDelegate performSelectorOnMainThread: @selector (customEvent:) | |||||
withObject: (id) [[NSData alloc] initWithBytes: &message length: (int) sizeof (message)] | |||||
waitUntilDone: NO]; | |||||
return true; | |||||
} | |||||
void MessageManager::broadcastMessage (const String& value) throw() | |||||
{ | |||||
} | |||||
void* MessageManager::callFunctionOnMessageThread (MessageCallbackFunction* callback, | |||||
void* data) | |||||
{ | |||||
if (isThisTheMessageThread()) | |||||
{ | |||||
return (*callback) (data); | |||||
} | |||||
else | |||||
{ | |||||
// If a thread has a MessageManagerLock and then tries to call this method, it'll | |||||
// deadlock because the message manager is blocked from running, so can never | |||||
// call your function.. | |||||
jassert (! MessageManager::getInstance()->currentThreadHasLockedMessageManager()); | |||||
const ScopedAutoReleasePool pool; | |||||
CallbackMessagePayload cmp; | |||||
cmp.function = callback; | |||||
cmp.parameter = data; | |||||
cmp.result = 0; | |||||
cmp.hasBeenExecuted = false; | |||||
[juceAppDelegate performSelectorOnMainThread: @selector (performCallback:) | |||||
withObject: [NSData dataWithBytesNoCopy: &cmp | |||||
length: sizeof (cmp) | |||||
freeWhenDone: NO] | |||||
waitUntilDone: YES]; | |||||
return cmp.result; | |||||
} | |||||
} | |||||
#endif |
@@ -28,6 +28,46 @@ | |||||
#ifdef JUCE_INCLUDED_FILE | #ifdef JUCE_INCLUDED_FILE | ||||
//============================================================================== | |||||
static JUCEApplication* juce_intialisingApp; | |||||
END_JUCE_NAMESPACE | |||||
@interface JuceAppStartupDelegate : NSObject <UIApplicationDelegate> | |||||
{ | |||||
} | |||||
- (void) applicationDidFinishLaunching: (UIApplication*) application; | |||||
- (void) applicationWillResignActive: (UIApplication*) application; | |||||
@end | |||||
@implementation JuceAppStartupDelegate | |||||
- (void) applicationDidFinishLaunching: (UIApplication*) application | |||||
{ | |||||
String dummy; | |||||
if (! juce_intialisingApp->initialiseApp (dummy)) | |||||
{ | |||||
// (should quit) | |||||
} | |||||
} | |||||
- (void) applicationWillResignActive: (UIApplication*) application | |||||
{ | |||||
JUCEApplication::shutdownAppAndClearUp(); | |||||
} | |||||
@end | |||||
BEGIN_JUCE_NAMESPACE | |||||
int juce_IPhoneMain (int argc, char* argv[], JUCEApplication* app) | |||||
{ | |||||
juce_intialisingApp = app; | |||||
return UIApplicationMain (argc, argv, nil, @"JuceAppStartupDelegate"); | |||||
} | |||||
//============================================================================== | //============================================================================== | ||||
ScopedAutoReleasePool::ScopedAutoReleasePool() | ScopedAutoReleasePool::ScopedAutoReleasePool() | ||||
{ | { | ||||
@@ -1,58 +0,0 @@ | |||||
/* | |||||
============================================================================== | |||||
This file is part of the JUCE library - "Jules' Utility Class Extensions" | |||||
Copyright 2004-9 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_MAC_NATIVEINCLUDES_JUCEHEADER__ | |||||
#define __JUCE_MAC_NATIVEINCLUDES_JUCEHEADER__ | |||||
/* | |||||
This file wraps together all the mac-specific code, so that | |||||
we can include all the native headers just once, and compile all our | |||||
platform-specific stuff in one big lump, keeping it out of the way of | |||||
the rest of the codebase. | |||||
*/ | |||||
#include "../../core/juce_StandardHeader.h" | |||||
#import <Foundation/Foundation.h> | |||||
#import <UIKit/UIKit.h> | |||||
#import <AudioToolbox/AudioToolbox.h> | |||||
#import <AVFoundation/AVFoundation.h> | |||||
#import <CoreData/CoreData.h> | |||||
#import <MobileCoreServices/MobileCoreServices.h> | |||||
#include <libkern/OSAtomic.h> | |||||
#include <sys/sysctl.h> | |||||
#include <sys/stat.h> | |||||
//#include <sys/dir.h> | |||||
#include <sys/param.h> | |||||
#include <sys/mount.h> | |||||
#include <fnmatch.h> | |||||
#include <utime.h> | |||||
#include <dlfcn.h> | |||||
#include <ifaddrs.h> | |||||
#include <net/if_dl.h> | |||||
#include <mach/mach_time.h> | |||||
#endif // __JUCE_MAC_NATIVEINCLUDES_JUCEHEADER__ |
@@ -0,0 +1,926 @@ | |||||
/* | |||||
============================================================================== | |||||
This file is part of the JUCE library - "Jules' Utility Class Extensions" | |||||
Copyright 2004-9 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. | |||||
============================================================================== | |||||
*/ | |||||
// (This file gets included by juce_mac_NativeCode.mm, rather than being | |||||
// compiled on its own). | |||||
#ifdef JUCE_INCLUDED_FILE | |||||
class UIViewComponentPeer; | |||||
//============================================================================== | |||||
END_JUCE_NAMESPACE | |||||
#define JuceUIView MakeObjCClassName(JuceUIView) | |||||
@interface JuceUIView : UIView | |||||
{ | |||||
@public | |||||
UIViewComponentPeer* owner; | |||||
} | |||||
- (JuceUIView*) initWithOwner: (UIViewComponentPeer*) owner withFrame: (CGRect) frame; | |||||
- (void) dealloc; | |||||
- (void) drawRect: (CGRect) r; | |||||
- (void) touchesBegan: (NSSet*) touches withEvent: (UIEvent*) event; | |||||
- (void) touchesMoved: (NSSet*) touches withEvent: (UIEvent*) event; | |||||
- (void) touchesEnded: (NSSet*) touches withEvent: (UIEvent*) event; | |||||
- (void) touchesCancelled: (NSSet*) touches withEvent: (UIEvent*) event; | |||||
- (BOOL) becomeFirstResponder; | |||||
- (BOOL) resignFirstResponder; | |||||
- (BOOL) canBecomeFirstResponder; | |||||
@end | |||||
//============================================================================== | |||||
#define JuceUIWindow MakeObjCClassName(JuceUIWindow) | |||||
@interface JuceUIWindow : UIWindow | |||||
{ | |||||
@private | |||||
UIViewComponentPeer* owner; | |||||
bool isZooming; | |||||
} | |||||
- (void) setOwner: (UIViewComponentPeer*) owner; | |||||
- (void) becomeKeyWindow; | |||||
@end | |||||
BEGIN_JUCE_NAMESPACE | |||||
//============================================================================== | |||||
class UIViewComponentPeer : public ComponentPeer | |||||
{ | |||||
public: | |||||
UIViewComponentPeer (Component* const component, | |||||
const int windowStyleFlags, | |||||
UIView* viewToAttachTo); | |||||
~UIViewComponentPeer(); | |||||
//============================================================================== | |||||
void* getNativeHandle() const; | |||||
void setVisible (bool shouldBeVisible); | |||||
void setTitle (const String& title); | |||||
void setPosition (int x, int y); | |||||
void setSize (int w, int h); | |||||
void setBounds (int x, int y, int w, int h, const bool isNowFullScreen); | |||||
void getBounds (int& x, int& y, int& w, int& h, const bool global) const; | |||||
void getBounds (int& x, int& y, int& w, int& h) const; | |||||
int getScreenX() const; | |||||
int getScreenY() const; | |||||
void relativePositionToGlobal (int& x, int& y); | |||||
void globalPositionToRelative (int& x, int& y); | |||||
void setMinimised (bool shouldBeMinimised); | |||||
bool isMinimised() const; | |||||
void setFullScreen (bool shouldBeFullScreen); | |||||
bool isFullScreen() const; | |||||
bool contains (int x, int y, bool trueIfInAChildWindow) const; | |||||
const BorderSize getFrameSize() const; | |||||
bool setAlwaysOnTop (bool alwaysOnTop); | |||||
void toFront (bool makeActiveWindow); | |||||
void toBehind (ComponentPeer* other); | |||||
void setIcon (const Image& newIcon); | |||||
virtual void drawRect (CGRect r); | |||||
virtual bool canBecomeKeyWindow(); | |||||
virtual bool windowShouldClose(); | |||||
virtual void redirectMovedOrResized(); | |||||
virtual CGRect constrainRect (CGRect r); | |||||
//============================================================================== | |||||
virtual void viewFocusGain(); | |||||
virtual void viewFocusLoss(); | |||||
bool isFocused() const; | |||||
void grabFocus(); | |||||
void textInputRequired (int x, int y); | |||||
//============================================================================== | |||||
void repaint (int x, int y, int w, int h); | |||||
void performAnyPendingRepaintsNow(); | |||||
//============================================================================== | |||||
juce_UseDebuggingNewOperator | |||||
UIWindow* window; | |||||
JuceUIView* view; | |||||
bool isSharedWindow, fullScreen; | |||||
}; | |||||
//============================================================================== | |||||
END_JUCE_NAMESPACE | |||||
@implementation JuceUIView | |||||
- (JuceUIView*) initWithOwner: (UIViewComponentPeer*) owner_ | |||||
withFrame: (CGRect) frame | |||||
{ | |||||
[super initWithFrame: frame]; | |||||
owner = owner_; | |||||
return self; | |||||
} | |||||
- (void) dealloc | |||||
{ | |||||
[super dealloc]; | |||||
} | |||||
//============================================================================== | |||||
- (void) drawRect: (CGRect) r | |||||
{ | |||||
if (owner != 0) | |||||
owner->drawRect (r); | |||||
} | |||||
//============================================================================== | |||||
bool KeyPress::isKeyCurrentlyDown (const int keyCode) throw() | |||||
{ | |||||
return false; | |||||
} | |||||
static int currentModifiers = 0; | |||||
const ModifierKeys ModifierKeys::getCurrentModifiersRealtime() throw() | |||||
{ | |||||
return ModifierKeys (currentModifiers); | |||||
} | |||||
void ModifierKeys::updateCurrentModifiers() throw() | |||||
{ | |||||
currentModifierFlags = currentModifiers; | |||||
} | |||||
static int getModifierForButtonNumber (const int num) throw() | |||||
{ | |||||
return num == 0 ? ModifierKeys::leftButtonModifier | |||||
: (num == 1 ? ModifierKeys::rightButtonModifier | |||||
: (num == 2 ? ModifierKeys::middleButtonModifier : 0)); | |||||
} | |||||
static int64 getMouseTime (UIEvent* e) { return (int64) [e timestamp] * 1000.0; } | |||||
//============================================================================== | |||||
- (void) touchesBegan: (NSSet*) touches withEvent: (UIEvent*) event | |||||
{ | |||||
NSArray* const t = [[event touchesForView: self] allObjects]; | |||||
switch ([t count]) | |||||
{ | |||||
case 1: // One finger.. | |||||
{ | |||||
CGPoint p = [[t objectAtIndex: 0] locationInView: self]; | |||||
currentModifiers |= getModifierForButtonNumber (0); | |||||
owner->handleMouseDown (p.x, p.y, getMouseTime (event)); | |||||
} | |||||
default: | |||||
//xxx multi-touch.. | |||||
break; | |||||
} | |||||
} | |||||
- (void) touchesMoved: (NSSet*) touches withEvent: (UIEvent*) event | |||||
{ | |||||
NSArray* const t = [[event touchesForView: self] allObjects]; | |||||
switch ([t count]) | |||||
{ | |||||
case 1: // One finger.. | |||||
{ | |||||
CGPoint p = [[t objectAtIndex: 0] locationInView: self]; | |||||
owner->handleMouseDrag (p.x, p.y, getMouseTime (event)); | |||||
} | |||||
default: | |||||
//xxx multi-touch.. | |||||
break; | |||||
} | |||||
} | |||||
- (void) touchesEnded: (NSSet*) touches withEvent: (UIEvent*) event | |||||
{ | |||||
NSArray* const t = [[event touchesForView: self] allObjects]; | |||||
switch ([t count]) | |||||
{ | |||||
case 1: // One finger.. | |||||
{ | |||||
CGPoint p = [[t objectAtIndex: 0] locationInView: self]; | |||||
const int oldMods = currentModifiers; | |||||
currentModifiers &= ~getModifierForButtonNumber (0); | |||||
owner->handleMouseUp (oldMods, p.x, p.y, getMouseTime (event)); | |||||
} | |||||
default: | |||||
//xxx multi-touch.. | |||||
break; | |||||
} | |||||
} | |||||
- (void) touchesCancelled: (NSSet*) touches withEvent: (UIEvent*) event | |||||
{ | |||||
[self touchesEnded: touches withEvent: event]; | |||||
} | |||||
//============================================================================== | |||||
- (BOOL) becomeFirstResponder | |||||
{ | |||||
if (owner != 0) | |||||
owner->viewFocusGain(); | |||||
return true; | |||||
} | |||||
- (BOOL) resignFirstResponder | |||||
{ | |||||
if (owner != 0) | |||||
owner->viewFocusLoss(); | |||||
return true; | |||||
} | |||||
- (BOOL) canBecomeFirstResponder | |||||
{ | |||||
return owner != 0 && owner->canBecomeKeyWindow(); | |||||
} | |||||
@end | |||||
//============================================================================== | |||||
@implementation JuceUIWindow | |||||
- (void) setOwner: (UIViewComponentPeer*) owner_ | |||||
{ | |||||
owner = owner_; | |||||
isZooming = false; | |||||
} | |||||
- (void) becomeKeyWindow | |||||
{ | |||||
[super becomeKeyWindow]; | |||||
if (owner != 0) | |||||
owner->grabFocus(); | |||||
} | |||||
@end | |||||
//============================================================================== | |||||
//============================================================================== | |||||
BEGIN_JUCE_NAMESPACE | |||||
//============================================================================== | |||||
class JuceUIImage | |||||
{ | |||||
public: | |||||
JuceUIImage (const int width, const int height, const bool hasAlpha) | |||||
: juceImage (hasAlpha ? Image::ARGB : Image::RGB, | |||||
width, height, hasAlpha) | |||||
{ | |||||
lineStride = 0; | |||||
pixelStride = 0; | |||||
imageData = juceImage.lockPixelDataReadWrite (0, 0, width, height, | |||||
lineStride, pixelStride); | |||||
CGDataProviderRef provider = CGDataProviderCreateWithData (0, imageData, lineStride * pixelStride, 0); | |||||
imageRef = CGImageCreate (width, height, | |||||
8, pixelStride * 8, lineStride, | |||||
CGColorSpaceCreateDeviceRGB(), | |||||
hasAlpha ? (kCGImageAlphaFirst | kCGBitmapByteOrder32Little) : kCGBitmapByteOrderDefault, | |||||
provider, | |||||
0, | |||||
true, kCGRenderingIntentDefault); | |||||
juceImage.releasePixelDataReadWrite (imageData); | |||||
uiImage = [[UIImage imageWithCGImage: imageRef] retain]; | |||||
} | |||||
~JuceUIImage() | |||||
{ | |||||
[uiImage release]; | |||||
CFRelease (imageRef); | |||||
} | |||||
Image& getJuceImage() throw() { return juceImage; } | |||||
void draw (const float x, const float y) const | |||||
{ | |||||
[uiImage drawAtPoint: CGPointMake (x, y) | |||||
blendMode: kCGBlendModeCopy | |||||
alpha: 1.0f]; | |||||
} | |||||
void drawUIImage (UIImage* imageToDraw) | |||||
{ | |||||
const ScopedAutoReleasePool pool; | |||||
jassertfalse | |||||
/*[NSGraphicsContext saveGraphicsState]; | |||||
[NSGraphicsContext setCurrentContext: | |||||
[NSGraphicsContext graphicsContextWithBitmapImageRep: imageRep]]; | |||||
[imageToDraw drawAtPoint: NSZeroPoint | |||||
fromRect: NSMakeRect (0, 0, [imageToDraw size].width, [imageToDraw size].height) | |||||
operation: NSCompositeSourceOver | |||||
fraction: 1.0f]; | |||||
[[NSGraphicsContext currentContext] flushGraphics]; | |||||
[NSGraphicsContext restoreGraphicsState]; | |||||
if (juceImage.hasAlphaChannel()) | |||||
swapRGBOrder (0, 0, juceImage.getWidth(), juceImage.getHeight());*/ | |||||
} | |||||
private: | |||||
Image juceImage; | |||||
CGImageRef imageRef; | |||||
CGDataProviderRef provider; | |||||
UIImage* uiImage; | |||||
uint8* imageData; | |||||
int pixelStride, lineStride; | |||||
/* void swapRGBOrder (const int x, const int y, const int w, int h) const | |||||
{ | |||||
#if JUCE_BIG_ENDIAN | |||||
jassert (pixelStride == 4); | |||||
#endif | |||||
jassert (Rectangle (0, 0, juceImage.getWidth(), juceImage.getHeight()) | |||||
.contains (Rectangle (x, y, w, h))); | |||||
uint8* start = imageData + x * pixelStride + y * lineStride; | |||||
while (--h >= 0) | |||||
{ | |||||
uint8* p = start; | |||||
start += lineStride; | |||||
for (int i = w; --i >= 0;) | |||||
{ | |||||
#if JUCE_BIG_ENDIAN | |||||
const uint8 oldp3 = p[3]; | |||||
const uint8 oldp1 = p[1]; | |||||
p[3] = p[0]; | |||||
p[0] = oldp1; | |||||
p[1] = p[2]; | |||||
p[2] = oldp3; | |||||
#else | |||||
const uint8 oldp0 = p[0]; | |||||
p[0] = p[2]; | |||||
p[2] = oldp0; | |||||
#endif | |||||
p += pixelStride; | |||||
} | |||||
} | |||||
}*/ | |||||
}; | |||||
//============================================================================== | |||||
UIViewComponentPeer::UIViewComponentPeer (Component* const component, | |||||
const int windowStyleFlags, | |||||
UIView* viewToAttachTo) | |||||
: ComponentPeer (component, windowStyleFlags), | |||||
window (0), | |||||
view (0), | |||||
isSharedWindow (viewToAttachTo != 0), | |||||
fullScreen (false) | |||||
{ | |||||
CGRect r; | |||||
r.origin.x = 0; | |||||
r.origin.y = 0; | |||||
r.size.width = (float) component->getWidth(); | |||||
r.size.height = (float) component->getHeight(); | |||||
view = [[JuceUIView alloc] initWithOwner: this withFrame: r]; | |||||
if (isSharedWindow) | |||||
{ | |||||
window = [viewToAttachTo window]; | |||||
[viewToAttachTo addSubview: view]; | |||||
setVisible (component->isVisible()); | |||||
} | |||||
else | |||||
{ | |||||
r.origin.x = (float) component->getX(); | |||||
r.origin.y = (float) component->getY(); | |||||
r.origin.y = [[UIScreen mainScreen] bounds].size.height - (r.origin.y + r.size.height); | |||||
window = [[JuceUIWindow alloc] init]; | |||||
window.frame = r; | |||||
[((JuceUIWindow*) window) setOwner: this]; | |||||
if (component->isAlwaysOnTop()) | |||||
window.windowLevel = UIWindowLevelAlert; | |||||
[window addSubview: view]; | |||||
view.frame = CGRectMake (0, 0, r.size.width, r.size.height); | |||||
} | |||||
setTitle (component->getName()); | |||||
} | |||||
UIViewComponentPeer::~UIViewComponentPeer() | |||||
{ | |||||
view->owner = 0; | |||||
[view removeFromSuperview]; | |||||
[view release]; | |||||
if (! isSharedWindow) | |||||
{ | |||||
[((JuceUIWindow*) window) setOwner: 0]; | |||||
[window release]; | |||||
} | |||||
} | |||||
//============================================================================== | |||||
void* UIViewComponentPeer::getNativeHandle() const | |||||
{ | |||||
return view; | |||||
} | |||||
void UIViewComponentPeer::setVisible (bool shouldBeVisible) | |||||
{ | |||||
view.hidden = ! shouldBeVisible; | |||||
} | |||||
void UIViewComponentPeer::setTitle (const String& title) | |||||
{ | |||||
// xxx is this possible? | |||||
} | |||||
void UIViewComponentPeer::setPosition (int x, int y) | |||||
{ | |||||
setBounds (x, y, component->getWidth(), component->getHeight(), false); | |||||
} | |||||
void UIViewComponentPeer::setSize (int w, int h) | |||||
{ | |||||
setBounds (component->getX(), component->getY(), w, h, false); | |||||
} | |||||
void UIViewComponentPeer::setBounds (int x, int y, int w, int h, const bool isNowFullScreen) | |||||
{ | |||||
fullScreen = isNowFullScreen; | |||||
w = jmax (0, w); | |||||
h = jmax (0, h); | |||||
CGRect r; | |||||
r.origin.x = (float) x; | |||||
r.origin.y = (float) y; | |||||
r.size.width = (float) w; | |||||
r.size.height = (float) h; | |||||
if (isSharedWindow) | |||||
{ | |||||
//r.origin.y = [[view superview] frame].size.height - (r.origin.y + r.size.height); | |||||
if ([view frame].size.width != r.size.width | |||||
|| [view frame].size.height != r.size.height) | |||||
[view setNeedsDisplay]; | |||||
view.frame = r; | |||||
} | |||||
else | |||||
{ | |||||
//r.origin.y = [[UIScreen mainScreen] bounds].size.height - (r.origin.y + r.size.height); | |||||
window.frame = r; | |||||
view.frame = CGRectMake (0, 0, r.size.width, r.size.height); | |||||
} | |||||
} | |||||
void UIViewComponentPeer::getBounds (int& x, int& y, int& w, int& h, const bool global) const | |||||
{ | |||||
CGRect r = [view frame]; | |||||
if (global && [view window] != 0) | |||||
{ | |||||
r = [view convertRect: r toView: nil]; | |||||
CGRect wr = [[view window] frame]; | |||||
r.origin.x += wr.origin.x; | |||||
r.origin.y += wr.origin.y; | |||||
y = (int) ([[UIScreen mainScreen] bounds].size.height - r.origin.y - r.size.height); | |||||
} | |||||
else | |||||
{ | |||||
y = (int) ([[view superview] frame].size.height - r.origin.y - r.size.height); | |||||
} | |||||
x = (int) r.origin.x; | |||||
w = (int) r.size.width; | |||||
h = (int) r.size.height; | |||||
} | |||||
void UIViewComponentPeer::getBounds (int& x, int& y, int& w, int& h) const | |||||
{ | |||||
getBounds (x, y, w, h, ! isSharedWindow); | |||||
} | |||||
int UIViewComponentPeer::getScreenX() const | |||||
{ | |||||
int x, y, w, h; | |||||
getBounds (x, y, w, h, true); | |||||
return x; | |||||
} | |||||
int UIViewComponentPeer::getScreenY() const | |||||
{ | |||||
int x, y, w, h; | |||||
getBounds (x, y, w, h, true); | |||||
return y; | |||||
} | |||||
void UIViewComponentPeer::relativePositionToGlobal (int& x, int& y) | |||||
{ | |||||
int wx, wy, ww, wh; | |||||
getBounds (wx, wy, ww, wh, true); | |||||
x += wx; | |||||
y += wy; | |||||
} | |||||
void UIViewComponentPeer::globalPositionToRelative (int& x, int& y) | |||||
{ | |||||
int wx, wy, ww, wh; | |||||
getBounds (wx, wy, ww, wh, true); | |||||
x -= wx; | |||||
y -= wy; | |||||
} | |||||
CGRect UIViewComponentPeer::constrainRect (CGRect r) | |||||
{ | |||||
if (constrainer != 0) | |||||
{ | |||||
CGRect current = [window frame]; | |||||
current.origin.y = [[UIScreen mainScreen] bounds].size.height - current.origin.y - current.size.height; | |||||
r.origin.y = [[UIScreen mainScreen] bounds].size.height - r.origin.y - r.size.height; | |||||
int x = (int) r.origin.x; | |||||
int y = (int) r.origin.y; | |||||
int w = (int) r.size.width; | |||||
int h = (int) r.size.height; | |||||
Rectangle original ((int) current.origin.x, (int) current.origin.y, | |||||
(int) current.size.width, (int) current.size.height); | |||||
constrainer->checkBounds (x, y, w, h, | |||||
original, | |||||
Desktop::getInstance().getAllMonitorDisplayAreas().getBounds(), | |||||
y != original.getY() && y + h == original.getBottom(), | |||||
x != original.getX() && x + w == original.getRight(), | |||||
y == original.getY() && y + h != original.getBottom(), | |||||
x == original.getX() && x + w != original.getRight()); | |||||
r.origin.x = x; | |||||
r.origin.y = [[UIScreen mainScreen] bounds].size.height - r.size.height - y; | |||||
r.size.width = w; | |||||
r.size.height = h; | |||||
} | |||||
return r; | |||||
} | |||||
void UIViewComponentPeer::setMinimised (bool shouldBeMinimised) | |||||
{ | |||||
// xxx | |||||
} | |||||
bool UIViewComponentPeer::isMinimised() const | |||||
{ | |||||
return false; | |||||
} | |||||
void UIViewComponentPeer::setFullScreen (bool shouldBeFullScreen) | |||||
{ | |||||
if (! isSharedWindow) | |||||
{ | |||||
Rectangle r (lastNonFullscreenBounds); | |||||
setMinimised (false); | |||||
if (fullScreen != shouldBeFullScreen) | |||||
{ | |||||
if (shouldBeFullScreen) | |||||
r = Desktop::getInstance().getMainMonitorArea(); | |||||
// (can't call the component's setBounds method because that'll reset our fullscreen flag) | |||||
if (r != getComponent()->getBounds() && ! r.isEmpty()) | |||||
setBounds (r.getX(), r.getY(), r.getWidth(), r.getHeight(), shouldBeFullScreen); | |||||
} | |||||
} | |||||
} | |||||
bool UIViewComponentPeer::isFullScreen() const | |||||
{ | |||||
return fullScreen; | |||||
} | |||||
bool UIViewComponentPeer::contains (int x, int y, bool trueIfInAChildWindow) const | |||||
{ | |||||
if (((unsigned int) x) >= (unsigned int) component->getWidth() | |||||
|| ((unsigned int) y) >= (unsigned int) component->getHeight()) | |||||
return false; | |||||
CGPoint p; | |||||
p.x = (float) x; | |||||
p.y = (float) y; | |||||
UIView* v = [view hitTest: p withEvent: nil]; | |||||
if (trueIfInAChildWindow) | |||||
return v != nil; | |||||
return v == view; | |||||
} | |||||
const BorderSize UIViewComponentPeer::getFrameSize() const | |||||
{ | |||||
BorderSize b; | |||||
if (! isSharedWindow) | |||||
{ | |||||
CGRect v = [view convertRect: [view frame] toView: nil]; | |||||
CGRect w = [window frame]; | |||||
b.setTop ((int) (w.size.height - (v.origin.y + v.size.height))); | |||||
b.setBottom ((int) v.origin.y); | |||||
b.setLeft ((int) v.origin.x); | |||||
b.setRight ((int) (w.size.width - (v.origin.x + v.size.width))); | |||||
} | |||||
return b; | |||||
} | |||||
bool UIViewComponentPeer::setAlwaysOnTop (bool alwaysOnTop) | |||||
{ | |||||
if (! isSharedWindow) | |||||
window.windowLevel = alwaysOnTop ? UIWindowLevelAlert : UIWindowLevelNormal; | |||||
return true; | |||||
} | |||||
void UIViewComponentPeer::toFront (bool makeActiveWindow) | |||||
{ | |||||
if (isSharedWindow) | |||||
[[view superview] bringSubviewToFront: view]; | |||||
if (window != 0 && component->isVisible()) | |||||
[window makeKeyAndVisible]; | |||||
} | |||||
void UIViewComponentPeer::toBehind (ComponentPeer* other) | |||||
{ | |||||
UIViewComponentPeer* o = (UIViewComponentPeer*) other; | |||||
if (isSharedWindow) | |||||
{ | |||||
[[view superview] insertSubview: view belowSubview: o->view]; | |||||
} | |||||
else | |||||
{ | |||||
jassertfalse // don't know how to do this | |||||
} | |||||
} | |||||
void UIViewComponentPeer::setIcon (const Image& /*newIcon*/) | |||||
{ | |||||
// to do.. | |||||
} | |||||
//============================================================================== | |||||
static UIViewComponentPeer* currentlyFocusedPeer = 0; | |||||
void UIViewComponentPeer::viewFocusGain() | |||||
{ | |||||
if (currentlyFocusedPeer != this) | |||||
{ | |||||
if (ComponentPeer::isValidPeer (currentlyFocusedPeer)) | |||||
currentlyFocusedPeer->handleFocusLoss(); | |||||
currentlyFocusedPeer = this; | |||||
handleFocusGain(); | |||||
} | |||||
} | |||||
void UIViewComponentPeer::viewFocusLoss() | |||||
{ | |||||
if (currentlyFocusedPeer == this) | |||||
{ | |||||
currentlyFocusedPeer = 0; | |||||
handleFocusLoss(); | |||||
} | |||||
} | |||||
void juce_HandleProcessFocusChange() | |||||
{ | |||||
if (UIViewComponentPeer::isValidPeer (currentlyFocusedPeer)) | |||||
{ | |||||
if (Process::isForegroundProcess()) | |||||
{ | |||||
currentlyFocusedPeer->handleFocusGain(); | |||||
ComponentPeer::bringModalComponentToFront(); | |||||
} | |||||
else | |||||
{ | |||||
currentlyFocusedPeer->handleFocusLoss(); | |||||
// turn kiosk mode off if we lose focus.. | |||||
Desktop::getInstance().setKioskModeComponent (0); | |||||
} | |||||
} | |||||
} | |||||
bool UIViewComponentPeer::isFocused() const | |||||
{ | |||||
return isSharedWindow ? this == currentlyFocusedPeer | |||||
: (window != 0 && [window isKeyWindow]); | |||||
} | |||||
void UIViewComponentPeer::grabFocus() | |||||
{ | |||||
if (window != 0) | |||||
{ | |||||
[window makeKeyWindow]; | |||||
viewFocusGain(); | |||||
} | |||||
} | |||||
void UIViewComponentPeer::textInputRequired (int /*x*/, int /*y*/) | |||||
{ | |||||
} | |||||
//============================================================================== | |||||
void UIViewComponentPeer::drawRect (CGRect r) | |||||
{ | |||||
if (r.size.width < 1.0f || r.size.height < 1.0f) | |||||
return; | |||||
DBG (Rectangle (r.origin.x, r.origin.y, r.size.width, r.size.height).toString()); | |||||
const float y = r.origin.y;//[view frame].size.height - (r.origin.y + r.size.height); | |||||
JuceUIImage temp ((int) (r.size.width + 0.5f), | |||||
(int) (r.size.height + 0.5f), | |||||
true);//! getComponent()->isOpaque()); | |||||
LowLevelGraphicsSoftwareRenderer context (temp.getJuceImage()); | |||||
const int originX = -roundFloatToInt (r.origin.x); | |||||
const int originY = -roundFloatToInt (y); | |||||
context.setOrigin (originX, originY); | |||||
handlePaint (context); | |||||
//CGContextClipToRect (UIGraphicsGetCurrentContext(), r); | |||||
temp.draw (r.origin.x, r.origin.y); | |||||
} | |||||
bool UIViewComponentPeer::canBecomeKeyWindow() | |||||
{ | |||||
return (getStyleFlags() & juce::ComponentPeer::windowIgnoresKeyPresses) == 0; | |||||
} | |||||
bool UIViewComponentPeer::windowShouldClose() | |||||
{ | |||||
if (! isValidPeer (this)) | |||||
return YES; | |||||
handleUserClosingWindow(); | |||||
return NO; | |||||
} | |||||
void UIViewComponentPeer::redirectMovedOrResized() | |||||
{ | |||||
handleMovedOrResized(); | |||||
} | |||||
//============================================================================== | |||||
void juce_setKioskComponent (Component* kioskModeComponent, bool enableOrDisable, bool allowMenusAndBars) | |||||
{ | |||||
} | |||||
//============================================================================== | |||||
void UIViewComponentPeer::repaint (int x, int y, int w, int h) | |||||
{ | |||||
[view setNeedsDisplayInRect: | |||||
CGRectMake ((float) x, (float) y,//([view frame].size.height - (y + h)), | |||||
(float) w, (float) h)]; | |||||
} | |||||
void UIViewComponentPeer::performAnyPendingRepaintsNow() | |||||
{ | |||||
} | |||||
ComponentPeer* Component::createNewPeer (int styleFlags, void* windowToAttachTo) | |||||
{ | |||||
return new UIViewComponentPeer (this, styleFlags, (UIView*) windowToAttachTo); | |||||
} | |||||
//============================================================================== | |||||
static Image* UIImageToJuceImage (UIImage* image) | |||||
{ | |||||
JuceUIImage juceIm ((int) [image size].width, | |||||
(int) [image size].height, | |||||
true); | |||||
juceIm.drawUIImage (image); | |||||
return juceIm.getJuceImage().createCopy(); | |||||
} | |||||
Image* juce_createIconForFile (const File& file) | |||||
{ | |||||
return 0; | |||||
} | |||||
//============================================================================== | |||||
const int KeyPress::spaceKey = ' '; | |||||
const int KeyPress::returnKey = 0x0d; | |||||
const int KeyPress::escapeKey = 0x1b; | |||||
const int KeyPress::backspaceKey = 0x7f; | |||||
const int KeyPress::leftKey = 0x1000; | |||||
const int KeyPress::rightKey = 0x1001; | |||||
const int KeyPress::upKey = 0x1002; | |||||
const int KeyPress::downKey = 0x1003; | |||||
const int KeyPress::pageUpKey = 0x1004; | |||||
const int KeyPress::pageDownKey = 0x1005; | |||||
const int KeyPress::endKey = 0x1006; | |||||
const int KeyPress::homeKey = 0x1007; | |||||
const int KeyPress::deleteKey = 0x1008; | |||||
const int KeyPress::insertKey = -1; | |||||
const int KeyPress::tabKey = 9; | |||||
const int KeyPress::F1Key = 0x2001; | |||||
const int KeyPress::F2Key = 0x2002; | |||||
const int KeyPress::F3Key = 0x2003; | |||||
const int KeyPress::F4Key = 0x2004; | |||||
const int KeyPress::F5Key = 0x2005; | |||||
const int KeyPress::F6Key = 0x2006; | |||||
const int KeyPress::F7Key = 0x2007; | |||||
const int KeyPress::F8Key = 0x2008; | |||||
const int KeyPress::F9Key = 0x2009; | |||||
const int KeyPress::F10Key = 0x200a; | |||||
const int KeyPress::F11Key = 0x200b; | |||||
const int KeyPress::F12Key = 0x200c; | |||||
const int KeyPress::F13Key = 0x200d; | |||||
const int KeyPress::F14Key = 0x200e; | |||||
const int KeyPress::F15Key = 0x200f; | |||||
const int KeyPress::F16Key = 0x2010; | |||||
const int KeyPress::numberPad0 = 0x30020; | |||||
const int KeyPress::numberPad1 = 0x30021; | |||||
const int KeyPress::numberPad2 = 0x30022; | |||||
const int KeyPress::numberPad3 = 0x30023; | |||||
const int KeyPress::numberPad4 = 0x30024; | |||||
const int KeyPress::numberPad5 = 0x30025; | |||||
const int KeyPress::numberPad6 = 0x30026; | |||||
const int KeyPress::numberPad7 = 0x30027; | |||||
const int KeyPress::numberPad8 = 0x30028; | |||||
const int KeyPress::numberPad9 = 0x30029; | |||||
const int KeyPress::numberPadAdd = 0x3002a; | |||||
const int KeyPress::numberPadSubtract = 0x3002b; | |||||
const int KeyPress::numberPadMultiply = 0x3002c; | |||||
const int KeyPress::numberPadDivide = 0x3002d; | |||||
const int KeyPress::numberPadSeparator = 0x3002e; | |||||
const int KeyPress::numberPadDecimalPoint = 0x3002f; | |||||
const int KeyPress::numberPadEquals = 0x30030; | |||||
const int KeyPress::numberPadDelete = 0x30031; | |||||
const int KeyPress::playKey = 0x30000; | |||||
const int KeyPress::stopKey = 0x30001; | |||||
const int KeyPress::fastForwardKey = 0x30002; | |||||
const int KeyPress::rewindKey = 0x30003; | |||||
#endif |
@@ -27,7 +27,6 @@ | |||||
// compiled on its own). | // compiled on its own). | ||||
#if JUCE_INCLUDED_FILE && JUCE_QUICKTIME && JUCE_USE_CAMERA | #if JUCE_INCLUDED_FILE && JUCE_QUICKTIME && JUCE_USE_CAMERA | ||||
//============================================================================== | //============================================================================== | ||||
#define QTCaptureCallbackDelegate MakeObjCClassName(QTCaptureCallbackDelegate) | #define QTCaptureCallbackDelegate MakeObjCClassName(QTCaptureCallbackDelegate) | ||||
@@ -399,5 +398,4 @@ CameraDevice* CameraDevice::openDevice (int index, | |||||
return 0; | return 0; | ||||
} | } | ||||
#endif | #endif |
@@ -27,6 +27,8 @@ | |||||
// compiled on its own). | // compiled on its own). | ||||
#ifdef JUCE_INCLUDED_FILE | #ifdef JUCE_INCLUDED_FILE | ||||
#if JUCE_MAC | |||||
//============================================================================== | //============================================================================== | ||||
#undef log | #undef log | ||||
#define log(a) Logger::writeToLog(a) | #define log(a) Logger::writeToLog(a) | ||||
@@ -586,4 +588,50 @@ void MidiInput::stop() | |||||
#undef log | #undef log | ||||
#else | |||||
MidiOutput::~MidiOutput() | |||||
{ | |||||
} | |||||
void MidiOutput::reset() | |||||
{ | |||||
} | |||||
bool MidiOutput::getVolume (float& leftVol, float& rightVol) | |||||
{ | |||||
return false; | |||||
} | |||||
void MidiOutput::setVolume (float leftVol, float rightVol) | |||||
{ | |||||
} | |||||
void MidiOutput::sendMessageNow (const MidiMessage& message) | |||||
{ | |||||
} | |||||
const StringArray MidiOutput::getDevices() | |||||
{ | |||||
return StringArray(); | |||||
} | |||||
MidiOutput* MidiOutput::openDevice (int index) | |||||
{ | |||||
return 0; | |||||
} | |||||
const StringArray MidiInput::getDevices() | |||||
{ | |||||
return StringArray(); | |||||
} | |||||
MidiInput* MidiInput::openDevice (int index, MidiInputCallback* callback) | |||||
{ | |||||
return 0; | |||||
} | |||||
#endif | |||||
#endif | #endif |
@@ -27,6 +27,8 @@ | |||||
// compiled on its own). | // compiled on its own). | ||||
#ifdef JUCE_INCLUDED_FILE | #ifdef JUCE_INCLUDED_FILE | ||||
#if JUCE_MAC | |||||
//============================================================================== | //============================================================================== | ||||
END_JUCE_NAMESPACE | END_JUCE_NAMESPACE | ||||
using namespace JUCE_NAMESPACE; | using namespace JUCE_NAMESPACE; | ||||
@@ -147,4 +149,24 @@ void FileChooser::showPlatformDialog (OwnedArray<File>& results, | |||||
[panel setDelegate: nil]; | [panel setDelegate: nil]; | ||||
} | } | ||||
#else | |||||
//============================================================================== | |||||
void FileChooser::showPlatformDialog (OwnedArray<File>& results, | |||||
const String& title, | |||||
const File& currentFileOrDirectory, | |||||
const String& filter, | |||||
bool selectsDirectory, | |||||
bool isSaveDialogue, | |||||
bool warnAboutOverwritingExistingFiles, | |||||
bool selectMultipleFiles, | |||||
FilePreviewComponent* extraInfoComponent) | |||||
{ | |||||
const ScopedAutoReleasePool pool; | |||||
jassertfalse //xxx to do | |||||
} | |||||
#endif | |||||
#endif | #endif |
@@ -295,8 +295,13 @@ const String File::getVersion() const throw() | |||||
//============================================================================== | //============================================================================== | ||||
const File File::getLinkedTarget() const throw() | const File File::getLinkedTarget() const throw() | ||||
{ | { | ||||
#if JUCE_IPHONE || (defined (MAC_OS_X_VERSION_10_5) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) | |||||
NSString* dest = [[NSFileManager defaultManager] destinationOfSymbolicLinkAtPath: juceStringToNS (getFullPathName()) error: nil]; | NSString* dest = [[NSFileManager defaultManager] destinationOfSymbolicLinkAtPath: juceStringToNS (getFullPathName()) error: nil]; | ||||
#else | |||||
NSString* dest = [[NSFileManager defaultManager] pathContentOfSymbolicLinkAtPath: juceStringToNS (getFullPathName())]; | |||||
#endif | |||||
if (dest != nil) | if (dest != nil) | ||||
return File (nsStringToJuce (dest)); | return File (nsStringToJuce (dest)); | ||||
@@ -332,31 +337,6 @@ struct FindFileStruct | |||||
String parentDir; | String parentDir; | ||||
}; | }; | ||||
void* juce_findFileStart (const String& directory, const String& wildCard, String& firstResultFile, | |||||
bool* isDir, bool* isHidden, int64* fileSize, Time* modTime, | |||||
Time* creationTime, bool* isReadOnly) throw() | |||||
{ | |||||
NSDirectoryEnumerator* e = [[NSFileManager defaultManager] enumeratorAtPath: juceStringToNS (directory)]; | |||||
if (e != 0) | |||||
{ | |||||
FindFileStruct* ff = new FindFileStruct(); | |||||
ff->enumerator = [e retain]; | |||||
ff->parentDir = directory; | |||||
if (! ff->parentDir.endsWithChar (File::separator)) | |||||
ff->parentDir += File::separator; | |||||
if (juce_findFileNext (ff, firstResultFile, isDir, isHidden, fileSize, modTime, creationTime, isReadOnly)) | |||||
return ff; | |||||
[e release]; | |||||
delete ff; | |||||
} | |||||
return 0; | |||||
} | |||||
bool juce_findFileNext (void* handle, String& resultFile, | bool juce_findFileNext (void* handle, String& resultFile, | ||||
bool* isDir, bool* isHidden, int64* fileSize, Time* modTime, Time* creationTime, bool* isReadOnly) throw() | bool* isDir, bool* isHidden, int64* fileSize, Time* modTime, Time* creationTime, bool* isReadOnly) throw() | ||||
{ | { | ||||
@@ -404,6 +384,31 @@ bool juce_findFileNext (void* handle, String& resultFile, | |||||
return true; | return true; | ||||
} | } | ||||
void* juce_findFileStart (const String& directory, const String& wildCard, String& firstResultFile, | |||||
bool* isDir, bool* isHidden, int64* fileSize, Time* modTime, | |||||
Time* creationTime, bool* isReadOnly) throw() | |||||
{ | |||||
NSDirectoryEnumerator* e = [[NSFileManager defaultManager] enumeratorAtPath: juceStringToNS (directory)]; | |||||
if (e != 0) | |||||
{ | |||||
FindFileStruct* ff = new FindFileStruct(); | |||||
ff->enumerator = [e retain]; | |||||
ff->parentDir = directory; | |||||
if (! ff->parentDir.endsWithChar (File::separator)) | |||||
ff->parentDir += File::separator; | |||||
if (juce_findFileNext (ff, firstResultFile, isDir, isHidden, fileSize, modTime, creationTime, isReadOnly)) | |||||
return ff; | |||||
[e release]; | |||||
delete ff; | |||||
} | |||||
return 0; | |||||
} | |||||
void juce_findFileClose (void* handle) throw() | void juce_findFileClose (void* handle) throw() | ||||
{ | { | ||||
FindFileStruct* ff = (FindFileStruct*) handle; | FindFileStruct* ff = (FindFileStruct*) handle; | ||||
@@ -437,7 +442,7 @@ bool juce_launchFile (const String& fileName, | |||||
const String& parameters) throw() | const String& parameters) throw() | ||||
{ | { | ||||
#if JUCE_IPHONE | #if JUCE_IPHONE | ||||
return false; // is this possible? | |||||
return [[UIApplication sharedApplication] openURL: [NSURL fileURLWithPath: juceStringToNS (fileName)]]; | |||||
#else | #else | ||||
const ScopedAutoReleasePool pool; | const ScopedAutoReleasePool pool; | ||||
@@ -502,7 +507,12 @@ const String PlatformUtilities::makePathFromFSRef (FSRef* file) | |||||
OSType PlatformUtilities::getTypeOfFile (const String& filename) | OSType PlatformUtilities::getTypeOfFile (const String& filename) | ||||
{ | { | ||||
const ScopedAutoReleasePool pool; | const ScopedAutoReleasePool pool; | ||||
#if JUCE_IPHONE || (defined (MAC_OS_X_VERSION_10_5) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) | |||||
NSDictionary* fileDict = [[NSFileManager defaultManager] attributesOfItemAtPath: juceStringToNS (filename) error: nil]; | |||||
#else | |||||
NSDictionary* fileDict = [[NSFileManager defaultManager] fileAttributesAtPath: juceStringToNS (filename) traverseLink: NO]; | NSDictionary* fileDict = [[NSFileManager defaultManager] fileAttributesAtPath: juceStringToNS (filename) traverseLink: NO]; | ||||
#endif | |||||
return (OSType) [fileDict objectForKey: NSFileHFSTypeCode]; | return (OSType) [fileDict objectForKey: NSFileHFSTypeCode]; | ||||
} | } | ||||
@@ -27,6 +27,8 @@ | |||||
// compiled on its own). | // compiled on its own). | ||||
#ifdef JUCE_INCLUDED_FILE | #ifdef JUCE_INCLUDED_FILE | ||||
#if JUCE_MAC | |||||
//============================================================================== | //============================================================================== | ||||
static NSImage* juceImageToNSImage (const Image& image) | static NSImage* juceImageToNSImage (const Image& image) | ||||
{ | { | ||||
@@ -187,4 +189,14 @@ void MouseCursor::showInWindow (ComponentPeer*) const throw() | |||||
[c set]; | [c set]; | ||||
} | } | ||||
#else | |||||
void* juce_createMouseCursorFromImage (const Image& image, int hotspotX, int hotspotY) throw() { return 0; } | |||||
void* juce_createStandardMouseCursor (MouseCursor::StandardCursorType type) throw() { return 0; } | |||||
void juce_deleteMouseCursor (void* const cursorHandle, const bool isStandard) throw() {} | |||||
void MouseCursor::showInAllWindows() const throw() {} | |||||
void MouseCursor::showInWindow (ComponentPeer*) const throw() {} | |||||
#endif | |||||
#endif | #endif |
@@ -35,22 +35,33 @@ | |||||
#include "../../core/juce_StandardHeader.h" | #include "../../core/juce_StandardHeader.h" | ||||
#import <Cocoa/Cocoa.h> | |||||
#import <CoreAudio/HostTime.h> | |||||
#import <CoreAudio/AudioHardware.h> | |||||
#import <CoreMIDI/MIDIServices.h> | |||||
#import <QTKit/QTKit.h> | |||||
#import <WebKit/WebKit.h> | |||||
#import <DiscRecording/DiscRecording.h> | |||||
#import <IOKit/IOKitLib.h> | |||||
#import <IOKit/IOCFPlugIn.h> | |||||
#import <IOKit/hid/IOHIDLib.h> | |||||
#import <IOKit/hid/IOHIDKeys.h> | |||||
#import <IOKit/pwr_mgt/IOPMLib.h> | |||||
#if JUCE_IPHONE | |||||
#import <Foundation/Foundation.h> | |||||
#import <UIKit/UIKit.h> | |||||
#import <AudioToolbox/AudioToolbox.h> | |||||
#import <AVFoundation/AVFoundation.h> | |||||
#import <CoreData/CoreData.h> | |||||
#import <MobileCoreServices/MobileCoreServices.h> | |||||
#include <sys/fcntl.h> | |||||
#else | |||||
#import <Cocoa/Cocoa.h> | |||||
#import <CoreAudio/HostTime.h> | |||||
#import <CoreAudio/AudioHardware.h> | |||||
#import <CoreMIDI/MIDIServices.h> | |||||
#import <QTKit/QTKit.h> | |||||
#import <WebKit/WebKit.h> | |||||
#import <DiscRecording/DiscRecording.h> | |||||
#import <IOKit/IOKitLib.h> | |||||
#import <IOKit/IOCFPlugIn.h> | |||||
#import <IOKit/hid/IOHIDLib.h> | |||||
#import <IOKit/hid/IOHIDKeys.h> | |||||
#import <IOKit/pwr_mgt/IOPMLib.h> | |||||
#include <sys/dir.h> | |||||
#include <sys/socket.h> | |||||
#endif | |||||
#include <sys/sysctl.h> | #include <sys/sysctl.h> | ||||
#include <sys/stat.h> | #include <sys/stat.h> | ||||
#include <sys/dir.h> | |||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/mount.h> | #include <sys/mount.h> | ||||
#include <fnmatch.h> | #include <fnmatch.h> | ||||
@@ -27,6 +27,8 @@ | |||||
// compiled on its own). | // compiled on its own). | ||||
#if JUCE_INCLUDED_FILE && JUCE_OPENGL | #if JUCE_INCLUDED_FILE && JUCE_OPENGL | ||||
#if JUCE_MAC | |||||
END_JUCE_NAMESPACE | END_JUCE_NAMESPACE | ||||
#define ThreadSafeNSOpenGLView MakeObjCClassName(ThreadSafeNSOpenGLView) | #define ThreadSafeNSOpenGLView MakeObjCClassName(ThreadSafeNSOpenGLView) | ||||
@@ -315,4 +317,21 @@ void OpenGLPixelFormat::getAvailablePixelFormats (Component* /*component*/, | |||||
//jassertfalse //xxx can't see how you do this in cocoa! | //jassertfalse //xxx can't see how you do this in cocoa! | ||||
} | } | ||||
#else | |||||
//============================================================================== | |||||
OpenGLContext* OpenGLContext::createContextForWindow (Component* const component, | |||||
const OpenGLPixelFormat& pixelFormat, | |||||
const OpenGLContext* const contextToShareWith) | |||||
{ | |||||
return 0; | |||||
} | |||||
void juce_glViewport (const int w, const int h) | |||||
{ | |||||
//glViewport (0, 0, w, h); | |||||
} | |||||
#endif | |||||
#endif | #endif |
@@ -170,7 +170,7 @@ void SystemClipboard::copyTextToClipboard (const String& text) throw() | |||||
{ | { | ||||
#if JUCE_IPHONE | #if JUCE_IPHONE | ||||
[[UIPasteboard generalPasteboard] setValue: juceStringToNS (text) | [[UIPasteboard generalPasteboard] setValue: juceStringToNS (text) | ||||
forPasteboardType: (NSString*) kUTTypePlainText]; | |||||
forPasteboardType: @"public.text"]; | |||||
#else | #else | ||||
[[NSPasteboard generalPasteboard] declareTypes: [NSArray arrayWithObject: NSStringPboardType] | [[NSPasteboard generalPasteboard] declareTypes: [NSArray arrayWithObject: NSStringPboardType] | ||||
owner: nil]; | owner: nil]; | ||||
@@ -183,7 +183,7 @@ void SystemClipboard::copyTextToClipboard (const String& text) throw() | |||||
const String SystemClipboard::getTextFromClipboard() throw() | const String SystemClipboard::getTextFromClipboard() throw() | ||||
{ | { | ||||
#if JUCE_IPHONE | #if JUCE_IPHONE | ||||
NSString* text = [[UIPasteboard generalPasteboard] valueForPasteboardType: (NSString*) kUTTypePlainText]; | |||||
NSString* text = [[UIPasteboard generalPasteboard] valueForPasteboardType: @"public.text"]; | |||||
#else | #else | ||||
NSString* text = [[NSPasteboard generalPasteboard] stringForType: NSStringPboardType]; | NSString* text = [[NSPasteboard generalPasteboard] stringForType: NSStringPboardType]; | ||||
#endif | #endif | ||||
@@ -27,6 +27,8 @@ | |||||
// compiled on its own). | // compiled on its own). | ||||
#if JUCE_INCLUDED_FILE && JUCE_WEB_BROWSER | #if JUCE_INCLUDED_FILE && JUCE_WEB_BROWSER | ||||
#if JUCE_MAC | |||||
//============================================================================== | //============================================================================== | ||||
END_JUCE_NAMESPACE | END_JUCE_NAMESPACE | ||||
@@ -266,4 +268,70 @@ bool WebBrowserComponent::pageAboutToLoad (const String& url) | |||||
return true; | return true; | ||||
} | } | ||||
#else | |||||
//============================================================================== | |||||
WebBrowserComponent::WebBrowserComponent (const bool unloadPageWhenBrowserIsHidden_) | |||||
{ | |||||
} | |||||
WebBrowserComponent::~WebBrowserComponent() | |||||
{ | |||||
} | |||||
//============================================================================== | |||||
void WebBrowserComponent::goToURL (const String& url, | |||||
const StringArray* headers, | |||||
const MemoryBlock* postData) | |||||
{ | |||||
} | |||||
void WebBrowserComponent::stop() | |||||
{ | |||||
} | |||||
void WebBrowserComponent::goBack() | |||||
{ | |||||
} | |||||
void WebBrowserComponent::goForward() | |||||
{ | |||||
} | |||||
void WebBrowserComponent::refresh() | |||||
{ | |||||
} | |||||
//============================================================================== | |||||
void WebBrowserComponent::paint (Graphics& g) | |||||
{ | |||||
} | |||||
void WebBrowserComponent::checkWindowAssociation() | |||||
{ | |||||
} | |||||
void WebBrowserComponent::reloadLastURL() | |||||
{ | |||||
} | |||||
void WebBrowserComponent::parentHierarchyChanged() | |||||
{ | |||||
} | |||||
void WebBrowserComponent::resized() | |||||
{ | |||||
} | |||||
void WebBrowserComponent::visibilityChanged() | |||||
{ | |||||
} | |||||
bool WebBrowserComponent::pageAboutToLoad (const String& url) | |||||
{ | |||||
return true; | |||||
} | |||||
#endif | |||||
#endif | #endif |
@@ -28,6 +28,7 @@ | |||||
#define __JUCE_WIN32_NATIVEINCLUDES_JUCEHEADER__ | #define __JUCE_WIN32_NATIVEINCLUDES_JUCEHEADER__ | ||||
#include "../../core/juce_TargetPlatform.h" | |||||
#include "../../../juce_Config.h" | #include "../../../juce_Config.h" | ||||
#ifndef STRICT | #ifndef STRICT | ||||