| @@ -99,7 +99,7 @@ private: | |||
| owner.setParameter (index, newVal); | |||
| } | |||
| const String getTextFromValue (double /*value*/) | |||
| String getTextFromValue (double /*value*/) | |||
| { | |||
| return owner.getParameterText (index); | |||
| } | |||
| @@ -125,7 +125,7 @@ private: | |||
| CFRunLoopSourceRef runLoopSource; | |||
| MessageQueue messageQueue; | |||
| static const String quotedIfContainsSpaces (NSString* file) | |||
| static String quotedIfContainsSpaces (NSString* file) | |||
| { | |||
| String s (nsStringToJuce (file)); | |||
| if (s.containsChar (' ')) | |||
| @@ -144,15 +144,13 @@ using namespace juce; | |||
| //============================================================================== | |||
| @interface JuceAppDelegate : NSObject | |||
| { | |||
| @private | |||
| id oldDelegate; | |||
| @public | |||
| AppDelegateRedirector* redirector; | |||
| } | |||
| - (JuceAppDelegate*) init; | |||
| - (void) dealloc; | |||
| - (void) unregisterObservers; | |||
| - (BOOL) application: (NSApplication*) theApplication openFile: (NSString*) filename; | |||
| - (void) application: (NSApplication*) sender openFiles: (NSArray*) filenames; | |||
| - (NSApplicationTerminateReply) applicationShouldTerminate: (NSApplication*) app; | |||
| @@ -173,11 +171,8 @@ using namespace juce; | |||
| redirector = new AppDelegateRedirector(); | |||
| NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; | |||
| if (JUCEApplicationBase::isStandaloneApp()) | |||
| { | |||
| oldDelegate = [NSApp delegate]; | |||
| [NSApp setDelegate: self]; | |||
| [[NSDistributedNotificationCenter defaultCenter] addObserver: self | |||
| @@ -187,7 +182,8 @@ using namespace juce; | |||
| } | |||
| else | |||
| { | |||
| oldDelegate = nil; | |||
| NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; | |||
| [center addObserver: self selector: @selector (applicationDidResignActive:) | |||
| name: NSApplicationDidResignActiveNotification object: NSApp]; | |||
| @@ -203,17 +199,25 @@ using namespace juce; | |||
| - (void) dealloc | |||
| { | |||
| if (oldDelegate != nil) | |||
| [NSApp setDelegate: oldDelegate]; | |||
| [[NSDistributedNotificationCenter defaultCenter] removeObserver: self | |||
| name: AppDelegateRedirector::getBroacastEventName() | |||
| object: nil]; | |||
| redirector->deleteSelf(); | |||
| [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 | |||
| { | |||
| (void) app; | |||
| @@ -357,10 +361,8 @@ bool MessageManager::runDispatchLoopUntil (int millisecondsToRunFor) | |||
| //============================================================================== | |||
| void initialiseNSApplication() | |||
| { | |||
| #if JUCE_MAC | |||
| JUCE_AUTORELEASEPOOL | |||
| [NSApplication sharedApplication]; | |||
| #endif | |||
| } | |||
| void MessageManager::doPlatformSpecificInitialisation() | |||
| @@ -368,20 +370,20 @@ void MessageManager::doPlatformSpecificInitialisation() | |||
| if (juceAppDelegate == nil) | |||
| 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]) | |||
| [NSThread detachNewThreadSelector: @selector (dummyMethod) | |||
| toTarget: juceAppDelegate | |||
| withObject: nil]; | |||
| #endif | |||
| } | |||
| void MessageManager::doPlatformSpecificShutdown() | |||
| { | |||
| if (juceAppDelegate != nil) | |||
| { | |||
| [[NSRunLoop currentRunLoop] cancelPerformSelectorsWithTarget: juceAppDelegate]; | |||
| [[NSNotificationCenter defaultCenter] removeObserver: juceAppDelegate]; | |||
| [juceAppDelegate unregisterObservers]; | |||
| [juceAppDelegate release]; | |||
| juceAppDelegate = nil; | |||
| } | |||
| @@ -646,11 +646,11 @@ private: | |||
| const int idRangeOffsetOffset = idDeltaOffset + 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); | |||
| glyphIndexes = CFDataCreate (kCFAllocatorDefault, CFDataGetBytePtr (cmapTable) + glyphIndexesOffset, offset + length - glyphIndexesOffset); | |||
| glyphIndexes = CFDataCreate (kCFAllocatorDefault, CFDataGetBytePtr (cmapTable) + glyphIndexesOffset, offset + length - glyphIndexesOffset); | |||
| } | |||
| break; | |||
| @@ -195,7 +195,7 @@ namespace KeyPressHelpers | |||
| } | |||
| //============================================================================== | |||
| const KeyPress KeyPress::createFromDescription (const String& desc) | |||
| KeyPress KeyPress::createFromDescription (const String& desc) | |||
| { | |||
| int modifiers = 0; | |||
| @@ -105,7 +105,7 @@ public: | |||
| @see ModifierKeys | |||
| */ | |||
| const ModifierKeys getModifiers() const noexcept { return mods; } | |||
| ModifierKeys getModifiers() const noexcept { return mods; } | |||
| /** Returns the character that is associated with this keypress. | |||
| @@ -136,7 +136,7 @@ public: | |||
| @see getTextDescription | |||
| */ | |||
| static const KeyPress createFromDescription (const String& textVersion); | |||
| static KeyPress createFromDescription (const String& textVersion); | |||
| /** Creates a textual description of the key combination. | |||
| @@ -25,7 +25,7 @@ | |||
| BEGIN_JUCE_NAMESPACE | |||
| //============================================================================== | |||
| ModifierKeys::ModifierKeys() noexcept | |||
| : flags (0) | |||
| { | |||
| @@ -64,7 +64,7 @@ public: | |||
| 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. | |||
| */ | |||
| 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. | |||
| @@ -74,28 +74,28 @@ public: | |||
| 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. | |||
| */ | |||
| 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. */ | |||
| 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. | |||
| 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). | |||
| */ | |||
| 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. */ | |||
| 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. */ | |||
| 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. */ | |||
| 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. | |||
| @@ -104,10 +104,10 @@ public: | |||
| @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. */ | |||
| inline bool isAltDown() const noexcept { return (flags & altModifier) != 0; } | |||
| inline bool isAltDown() const noexcept { return testFlags (altModifier); } | |||
| //============================================================================== | |||
| /** Flags that represent the different keys. */ | |||
| @@ -206,11 +206,11 @@ private: | |||
| //============================================================================== | |||
| int flags; | |||
| static ModifierKeys currentModifiers; | |||
| friend class ComponentPeer; | |||
| friend class MouseInputSource; | |||
| friend class MouseInputSourceInternal; | |||
| static ModifierKeys currentModifiers; | |||
| static void updateCurrentModifiers() noexcept; | |||
| }; | |||
| @@ -643,7 +643,7 @@ String Slider::getTextValueSuffix() const | |||
| return textSuffix; | |||
| } | |||
| const String Slider::getTextFromValue (double v) | |||
| String Slider::getTextFromValue (double v) | |||
| { | |||
| if (getNumDecimalPlacesToDisplay() > 0) | |||
| return String (v, getNumDecimalPlacesToDisplay()) + getTextValueSuffix(); | |||
| @@ -671,7 +671,7 @@ public: | |||
| @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 | |||
| a string. | |||
| @@ -35,7 +35,7 @@ public: | |||
| 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); | |||
| } | |||