| @@ -99,7 +99,7 @@ private: | |||||
| owner.setParameter (index, newVal); | owner.setParameter (index, newVal); | ||||
| } | } | ||||
| const String getTextFromValue (double /*value*/) | |||||
| String getTextFromValue (double /*value*/) | |||||
| { | { | ||||
| return owner.getParameterText (index); | return owner.getParameterText (index); | ||||
| } | } | ||||
| @@ -125,7 +125,7 @@ private: | |||||
| CFRunLoopSourceRef runLoopSource; | CFRunLoopSourceRef runLoopSource; | ||||
| MessageQueue messageQueue; | MessageQueue messageQueue; | ||||
| static const String quotedIfContainsSpaces (NSString* file) | |||||
| static String quotedIfContainsSpaces (NSString* file) | |||||
| { | { | ||||
| String s (nsStringToJuce (file)); | String s (nsStringToJuce (file)); | ||||
| if (s.containsChar (' ')) | if (s.containsChar (' ')) | ||||
| @@ -144,15 +144,13 @@ using namespace juce; | |||||
| //============================================================================== | //============================================================================== | ||||
| @interface JuceAppDelegate : NSObject | @interface JuceAppDelegate : NSObject | ||||
| { | { | ||||
| @private | |||||
| id oldDelegate; | |||||
| @public | @public | ||||
| AppDelegateRedirector* redirector; | AppDelegateRedirector* redirector; | ||||
| } | } | ||||
| - (JuceAppDelegate*) init; | - (JuceAppDelegate*) init; | ||||
| - (void) dealloc; | - (void) dealloc; | ||||
| - (void) unregisterObservers; | |||||
| - (BOOL) application: (NSApplication*) theApplication openFile: (NSString*) filename; | - (BOOL) application: (NSApplication*) theApplication openFile: (NSString*) filename; | ||||
| - (void) application: (NSApplication*) sender openFiles: (NSArray*) filenames; | - (void) application: (NSApplication*) sender openFiles: (NSArray*) filenames; | ||||
| - (NSApplicationTerminateReply) applicationShouldTerminate: (NSApplication*) app; | - (NSApplicationTerminateReply) applicationShouldTerminate: (NSApplication*) app; | ||||
| @@ -173,11 +171,8 @@ using namespace juce; | |||||
| redirector = new AppDelegateRedirector(); | redirector = new AppDelegateRedirector(); | ||||
| NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; | |||||
| if (JUCEApplicationBase::isStandaloneApp()) | if (JUCEApplicationBase::isStandaloneApp()) | ||||
| { | { | ||||
| oldDelegate = [NSApp delegate]; | |||||
| [NSApp setDelegate: self]; | [NSApp setDelegate: self]; | ||||
| [[NSDistributedNotificationCenter defaultCenter] addObserver: self | [[NSDistributedNotificationCenter defaultCenter] addObserver: self | ||||
| @@ -187,7 +182,8 @@ using namespace juce; | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| oldDelegate = nil; | |||||
| NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; | |||||
| [center addObserver: self selector: @selector (applicationDidResignActive:) | [center addObserver: self selector: @selector (applicationDidResignActive:) | ||||
| name: NSApplicationDidResignActiveNotification object: NSApp]; | name: NSApplicationDidResignActiveNotification object: NSApp]; | ||||
| @@ -203,17 +199,25 @@ using namespace juce; | |||||
| - (void) dealloc | - (void) dealloc | ||||
| { | { | ||||
| if (oldDelegate != nil) | |||||
| [NSApp setDelegate: oldDelegate]; | |||||
| [[NSDistributedNotificationCenter defaultCenter] removeObserver: self | |||||
| name: AppDelegateRedirector::getBroacastEventName() | |||||
| object: nil]; | |||||
| redirector->deleteSelf(); | redirector->deleteSelf(); | ||||
| [super dealloc]; | [super dealloc]; | ||||
| } | } | ||||
| - (void) unregisterObservers | |||||
| { | |||||
| [[NSRunLoop currentRunLoop] cancelPerformSelectorsWithTarget: self]; | |||||
| [[NSNotificationCenter defaultCenter] removeObserver: self]; | |||||
| if (JUCEApplicationBase::isStandaloneApp()) | |||||
| { | |||||
| [NSApp setDelegate: nil]; | |||||
| [[NSDistributedNotificationCenter defaultCenter] removeObserver: self | |||||
| name: AppDelegateRedirector::getBroacastEventName() | |||||
| object: nil]; | |||||
| } | |||||
| } | |||||
| - (NSApplicationTerminateReply) applicationShouldTerminate: (NSApplication*) app | - (NSApplicationTerminateReply) applicationShouldTerminate: (NSApplication*) app | ||||
| { | { | ||||
| (void) app; | (void) app; | ||||
| @@ -357,10 +361,8 @@ bool MessageManager::runDispatchLoopUntil (int millisecondsToRunFor) | |||||
| //============================================================================== | //============================================================================== | ||||
| void initialiseNSApplication() | void initialiseNSApplication() | ||||
| { | { | ||||
| #if JUCE_MAC | |||||
| JUCE_AUTORELEASEPOOL | JUCE_AUTORELEASEPOOL | ||||
| [NSApplication sharedApplication]; | [NSApplication sharedApplication]; | ||||
| #endif | |||||
| } | } | ||||
| void MessageManager::doPlatformSpecificInitialisation() | void MessageManager::doPlatformSpecificInitialisation() | ||||
| @@ -368,20 +370,20 @@ void MessageManager::doPlatformSpecificInitialisation() | |||||
| if (juceAppDelegate == nil) | if (juceAppDelegate == nil) | ||||
| juceAppDelegate = [[JuceAppDelegate alloc] init]; | juceAppDelegate = [[JuceAppDelegate alloc] init]; | ||||
| // This launches a dummy thread, which forces Cocoa to initialise NSThreads | |||||
| // correctly (needed prior to 10.5) | |||||
| #if ! (defined (MAC_OS_X_VERSION_10_5) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5) | |||||
| // This launches a dummy thread, which forces Cocoa to initialise NSThreads correctly (needed prior to 10.5) | |||||
| if (! [NSThread isMultiThreaded]) | if (! [NSThread isMultiThreaded]) | ||||
| [NSThread detachNewThreadSelector: @selector (dummyMethod) | [NSThread detachNewThreadSelector: @selector (dummyMethod) | ||||
| toTarget: juceAppDelegate | toTarget: juceAppDelegate | ||||
| withObject: nil]; | withObject: nil]; | ||||
| #endif | |||||
| } | } | ||||
| void MessageManager::doPlatformSpecificShutdown() | void MessageManager::doPlatformSpecificShutdown() | ||||
| { | { | ||||
| if (juceAppDelegate != nil) | if (juceAppDelegate != nil) | ||||
| { | { | ||||
| [[NSRunLoop currentRunLoop] cancelPerformSelectorsWithTarget: juceAppDelegate]; | |||||
| [[NSNotificationCenter defaultCenter] removeObserver: juceAppDelegate]; | |||||
| [juceAppDelegate unregisterObservers]; | |||||
| [juceAppDelegate release]; | [juceAppDelegate release]; | ||||
| juceAppDelegate = nil; | juceAppDelegate = nil; | ||||
| } | } | ||||
| @@ -646,11 +646,11 @@ private: | |||||
| const int idRangeOffsetOffset = idDeltaOffset + segCountX2; | const int idRangeOffsetOffset = idDeltaOffset + segCountX2; | ||||
| const int glyphIndexesOffset = idRangeOffsetOffset + segCountX2; | const int glyphIndexesOffset = idRangeOffsetOffset + segCountX2; | ||||
| endCode = CFDataCreate (kCFAllocatorDefault, CFDataGetBytePtr (cmapTable) + endCodeOffset, segCountX2); | |||||
| startCode = CFDataCreate (kCFAllocatorDefault, CFDataGetBytePtr (cmapTable) + startCodeOffset, segCountX2); | |||||
| idDelta = CFDataCreate (kCFAllocatorDefault, CFDataGetBytePtr (cmapTable) + idDeltaOffset, segCountX2); | |||||
| endCode = CFDataCreate (kCFAllocatorDefault, CFDataGetBytePtr (cmapTable) + endCodeOffset, segCountX2); | |||||
| startCode = CFDataCreate (kCFAllocatorDefault, CFDataGetBytePtr (cmapTable) + startCodeOffset, segCountX2); | |||||
| idDelta = CFDataCreate (kCFAllocatorDefault, CFDataGetBytePtr (cmapTable) + idDeltaOffset, segCountX2); | |||||
| idRangeOffset = CFDataCreate (kCFAllocatorDefault, CFDataGetBytePtr (cmapTable) + idRangeOffsetOffset, segCountX2); | idRangeOffset = CFDataCreate (kCFAllocatorDefault, CFDataGetBytePtr (cmapTable) + idRangeOffsetOffset, segCountX2); | ||||
| glyphIndexes = CFDataCreate (kCFAllocatorDefault, CFDataGetBytePtr (cmapTable) + glyphIndexesOffset, offset + length - glyphIndexesOffset); | |||||
| glyphIndexes = CFDataCreate (kCFAllocatorDefault, CFDataGetBytePtr (cmapTable) + glyphIndexesOffset, offset + length - glyphIndexesOffset); | |||||
| } | } | ||||
| break; | break; | ||||
| @@ -195,7 +195,7 @@ namespace KeyPressHelpers | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| const KeyPress KeyPress::createFromDescription (const String& desc) | |||||
| KeyPress KeyPress::createFromDescription (const String& desc) | |||||
| { | { | ||||
| int modifiers = 0; | int modifiers = 0; | ||||
| @@ -105,7 +105,7 @@ public: | |||||
| @see ModifierKeys | @see ModifierKeys | ||||
| */ | */ | ||||
| const ModifierKeys getModifiers() const noexcept { return mods; } | |||||
| ModifierKeys getModifiers() const noexcept { return mods; } | |||||
| /** Returns the character that is associated with this keypress. | /** Returns the character that is associated with this keypress. | ||||
| @@ -136,7 +136,7 @@ public: | |||||
| @see getTextDescription | @see getTextDescription | ||||
| */ | */ | ||||
| static const KeyPress createFromDescription (const String& textVersion); | |||||
| static KeyPress createFromDescription (const String& textVersion); | |||||
| /** Creates a textual description of the key combination. | /** Creates a textual description of the key combination. | ||||
| @@ -25,7 +25,7 @@ | |||||
| BEGIN_JUCE_NAMESPACE | BEGIN_JUCE_NAMESPACE | ||||
| //============================================================================== | |||||
| ModifierKeys::ModifierKeys() noexcept | ModifierKeys::ModifierKeys() noexcept | ||||
| : flags (0) | : flags (0) | ||||
| { | { | ||||
| @@ -64,7 +64,7 @@ public: | |||||
| preferred command-key modifier - so on the Mac it tests for the Apple key, on | preferred command-key modifier - so on the Mac it tests for the Apple key, on | ||||
| Windows/Linux, it's actually checking for the CTRL key. | Windows/Linux, it's actually checking for the CTRL key. | ||||
| */ | */ | ||||
| inline bool isCommandDown() const noexcept { return (flags & commandModifier) != 0; } | |||||
| inline bool isCommandDown() const noexcept { return testFlags (commandModifier); } | |||||
| /** Checks whether the user is trying to launch a pop-up menu. | /** Checks whether the user is trying to launch a pop-up menu. | ||||
| @@ -74,28 +74,28 @@ public: | |||||
| So on Windows/Linux, this method is really testing for a right-click. | So on Windows/Linux, this method is really testing for a right-click. | ||||
| On the Mac, it tests for either the CTRL key being down, or a right-click. | On the Mac, it tests for either the CTRL key being down, or a right-click. | ||||
| */ | */ | ||||
| inline bool isPopupMenu() const noexcept { return (flags & popupMenuClickModifier) != 0; } | |||||
| inline bool isPopupMenu() const noexcept { return testFlags (popupMenuClickModifier); } | |||||
| /** Checks whether the flag is set for the left mouse-button. */ | /** Checks whether the flag is set for the left mouse-button. */ | ||||
| inline bool isLeftButtonDown() const noexcept { return (flags & leftButtonModifier) != 0; } | |||||
| inline bool isLeftButtonDown() const noexcept { return testFlags (leftButtonModifier); } | |||||
| /** Checks whether the flag is set for the right mouse-button. | /** Checks whether the flag is set for the right mouse-button. | ||||
| Note that for detecting popup-menu clicks, you should be using isPopupMenu() instead, as | Note that for detecting popup-menu clicks, you should be using isPopupMenu() instead, as | ||||
| this is platform-independent (and makes your code more explanatory too). | this is platform-independent (and makes your code more explanatory too). | ||||
| */ | */ | ||||
| inline bool isRightButtonDown() const noexcept { return (flags & rightButtonModifier) != 0; } | |||||
| inline bool isRightButtonDown() const noexcept { return testFlags (rightButtonModifier); } | |||||
| inline bool isMiddleButtonDown() const noexcept { return (flags & middleButtonModifier) != 0; } | |||||
| inline bool isMiddleButtonDown() const noexcept { return testFlags (middleButtonModifier); } | |||||
| /** Tests for any of the mouse-button flags. */ | /** Tests for any of the mouse-button flags. */ | ||||
| inline bool isAnyMouseButtonDown() const noexcept { return (flags & allMouseButtonModifiers) != 0; } | |||||
| inline bool isAnyMouseButtonDown() const noexcept { return testFlags (allMouseButtonModifiers); } | |||||
| /** Tests for any of the modifier key flags. */ | /** Tests for any of the modifier key flags. */ | ||||
| inline bool isAnyModifierKeyDown() const noexcept { return (flags & (shiftModifier | ctrlModifier | altModifier | commandModifier)) != 0; } | |||||
| inline bool isAnyModifierKeyDown() const noexcept { return testFlags ((shiftModifier | ctrlModifier | altModifier | commandModifier)); } | |||||
| /** Checks whether the shift key's flag is set. */ | /** Checks whether the shift key's flag is set. */ | ||||
| inline bool isShiftDown() const noexcept { return (flags & shiftModifier) != 0; } | |||||
| inline bool isShiftDown() const noexcept { return testFlags (shiftModifier); } | |||||
| /** Checks whether the CTRL key's flag is set. | /** Checks whether the CTRL key's flag is set. | ||||
| @@ -104,10 +104,10 @@ public: | |||||
| @see isCommandDown, isPopupMenu | @see isCommandDown, isPopupMenu | ||||
| */ | */ | ||||
| inline bool isCtrlDown() const noexcept { return (flags & ctrlModifier) != 0; } | |||||
| inline bool isCtrlDown() const noexcept { return testFlags (ctrlModifier); } | |||||
| /** Checks whether the shift key's flag is set. */ | /** Checks whether the shift key's flag is set. */ | ||||
| inline bool isAltDown() const noexcept { return (flags & altModifier) != 0; } | |||||
| inline bool isAltDown() const noexcept { return testFlags (altModifier); } | |||||
| //============================================================================== | //============================================================================== | ||||
| /** Flags that represent the different keys. */ | /** Flags that represent the different keys. */ | ||||
| @@ -206,11 +206,11 @@ private: | |||||
| //============================================================================== | //============================================================================== | ||||
| int flags; | int flags; | ||||
| static ModifierKeys currentModifiers; | |||||
| friend class ComponentPeer; | friend class ComponentPeer; | ||||
| friend class MouseInputSource; | friend class MouseInputSource; | ||||
| friend class MouseInputSourceInternal; | friend class MouseInputSourceInternal; | ||||
| static ModifierKeys currentModifiers; | |||||
| static void updateCurrentModifiers() noexcept; | static void updateCurrentModifiers() noexcept; | ||||
| }; | }; | ||||
| @@ -643,7 +643,7 @@ String Slider::getTextValueSuffix() const | |||||
| return textSuffix; | return textSuffix; | ||||
| } | } | ||||
| const String Slider::getTextFromValue (double v) | |||||
| String Slider::getTextFromValue (double v) | |||||
| { | { | ||||
| if (getNumDecimalPlacesToDisplay() > 0) | if (getNumDecimalPlacesToDisplay() > 0) | ||||
| return String (v, getNumDecimalPlacesToDisplay()) + getTextValueSuffix(); | return String (v, getNumDecimalPlacesToDisplay()) + getTextValueSuffix(); | ||||
| @@ -671,7 +671,7 @@ public: | |||||
| @see getValueFromText | @see getValueFromText | ||||
| */ | */ | ||||
| virtual const String getTextFromValue (double value); | |||||
| virtual String getTextFromValue (double value); | |||||
| /** Sets a suffix to append to the end of the numeric value when it's displayed as | /** Sets a suffix to append to the end of the numeric value when it's displayed as | ||||
| a string. | a string. | ||||
| @@ -35,7 +35,7 @@ public: | |||||
| setRange (0.0, 255.0, 1.0); | setRange (0.0, 255.0, 1.0); | ||||
| } | } | ||||
| const String getTextFromValue (double value) | |||||
| String getTextFromValue (double value) | |||||
| { | { | ||||
| return String::toHexString ((int) value).toUpperCase().paddedLeft ('0', 2); | return String::toHexString ((int) value).toUpperCase().paddedLeft ('0', 2); | ||||
| } | } | ||||