diff --git a/modules/juce_audio_devices/native/juce_mac_AudioCDBurner.mm b/modules/juce_audio_devices/native/juce_mac_AudioCDBurner.mm index 2782ba5ff9..137d44380b 100644 --- a/modules/juce_audio_devices/native/juce_mac_AudioCDBurner.mm +++ b/modules/juce_audio_devices/native/juce_mac_AudioCDBurner.mm @@ -48,8 +48,8 @@ struct AudioTrackProducerClass : public ObjCClass struct AudioSourceHolder { - AudioSourceHolder (AudioSource* source_, int numFrames) - : source (source_), readPosition (0), lengthInFrames (numFrames) + AudioSourceHolder (AudioSource* s, int numFrames) + : source (s), readPosition (0), lengthInFrames (numFrames) { } @@ -125,15 +125,9 @@ private: source->source->getNextAudioBlock (info); - typedef AudioData::Pointer CDSampleFormat; + typedef AudioData::Pointer CDSampleFormat; + typedef AudioData::Pointer SourceSampleFormat; - typedef AudioData::Pointer SourceSampleFormat; CDSampleFormat left (buffer, 2); left.convertSamples (SourceSampleFormat (tempBuffer.getSampleData (0)), numSamples); CDSampleFormat right (buffer + 2, 2); @@ -166,8 +160,8 @@ private: struct OpenDiskDevice { - OpenDiskDevice (DRDevice* device_) - : device (device_), + OpenDiskDevice (DRDevice* d) + : device (d), tracks ([[NSMutableArray alloc] init]), underrunProtection (true) { @@ -254,9 +248,8 @@ struct OpenDiskDevice NSString* err = (NSString*) [[[burn status] objectForKey: DRErrorStatusKey] objectForKey: DRErrorStatusErrorStringKey]; - if ([err length] > 0) - return CharPointer_UTF8 ([err UTF8String]); + return nsStringToJuce (err); } [device releaseMediaReservation]; @@ -273,12 +266,9 @@ struct OpenDiskDevice class AudioCDBurner::Pimpl : public Timer { public: - Pimpl (AudioCDBurner& owner_, const int deviceIndex) - : device (0), owner (owner_) + Pimpl (AudioCDBurner& b, int deviceIndex) : owner (b) { - DRDevice* dev = [[DRDevice devices] objectAtIndex: deviceIndex]; - - if (dev != nil) + if (DRDevice* dev = [[DRDevice devices] objectAtIndex: deviceIndex]) { device = new OpenDiskDevice (dev); lastState = getDiskState(); @@ -307,7 +297,6 @@ public: if ([device->device isValid]) { NSDictionary* status = [device->device status]; - NSString* state = [status objectForKey: DRDeviceMediaStateKey]; if ([state isEqualTo: DRDeviceMediaStateNone]) @@ -322,8 +311,8 @@ public: { if ([[[status objectForKey: DRDeviceMediaInfoKey] objectForKey: DRDeviceMediaBlocksFreeKey] intValue] > 0) return writableDiskPresent; - else - return readOnlyDiskPresent; + + return readOnlyDiskPresent; } } @@ -337,14 +326,8 @@ public: Array results; if ([device->device isValid]) - { - NSArray* speeds = [[[device->device status] objectForKey: DRDeviceMediaInfoKey] objectForKey: DRDeviceBurnSpeedsKey]; - for (unsigned int i = 0; i < [speeds count]; ++i) - { - const int kbPerSec = [[speeds objectAtIndex: i] intValue]; - results.add (kbPerSec / kilobytesPerSecond1x); - } - } + for (id kbPerSec in [[[device->device status] objectForKey: DRDeviceMediaInfoKey] objectForKey: DRDeviceBurnSpeedsKey]) + results.add ([kbPerSec intValue] / kilobytesPerSecond1x); return results; } @@ -385,40 +368,21 @@ AudioCDBurner::~AudioCDBurner() AudioCDBurner* AudioCDBurner::openDevice (const int deviceIndex) { - ScopedPointer b (new AudioCDBurner (deviceIndex)); + ScopedPointer b (new AudioCDBurner (deviceIndex)); if (b->pimpl->device == nil) - b = 0; + b = nullptr; return b.release(); } -namespace -{ - NSArray* findDiskBurnerDevices() - { - NSMutableArray* results = [NSMutableArray array]; - NSArray* devs = [DRDevice devices]; - - for (int i = 0; i < [devs count]; ++i) - { - NSDictionary* dic = [[devs objectAtIndex: i] info]; - NSString* name = [dic valueForKey: DRDeviceProductNameKey]; - if (name != nil) - [results addObject: name]; - } - - return results; - } -} - StringArray AudioCDBurner::findAvailableDevices() { - NSArray* names = findDiskBurnerDevices(); StringArray s; - for (unsigned int i = 0; i < [names count]; ++i) - s.add (CharPointer_UTF8 ([[names objectAtIndex: i] UTF8String])); + for (NSDictionary* dic in [DRDevice devices]) + if (NSString* name = [dic valueForKey: DRDeviceProductNameKey]) + s.add (nsStringToJuce (name)); return s; } diff --git a/modules/juce_events/native/juce_mac_MessageManager.mm b/modules/juce_events/native/juce_mac_MessageManager.mm index 8f41f16d5b..29336640f5 100644 --- a/modules/juce_events/native/juce_mac_MessageManager.mm +++ b/modules/juce_events/native/juce_mac_MessageManager.mm @@ -150,8 +150,9 @@ private: if (JUCEApplicationBase* const app = JUCEApplicationBase::getInstance()) { StringArray files; - for (unsigned int i = 0; i < [filenames count]; ++i) - files.add (quotedIfContainsSpaces ((NSString*) [filenames objectAtIndex: i])); + + for (NSString* f in filenames) + files.add (quotedIfContainsSpaces (f)); if (files.size() > 0) app->anotherInstanceStarted (files.joinIntoString (" ")); diff --git a/modules/juce_graphics/native/juce_mac_Fonts.mm b/modules/juce_graphics/native/juce_mac_Fonts.mm index 9de32e745b..4c482432a1 100644 --- a/modules/juce_graphics/native/juce_mac_Fonts.mm +++ b/modules/juce_graphics/native/juce_mac_Fonts.mm @@ -1114,13 +1114,11 @@ StringArray Font::findAllTypefaceNames() JUCE_AUTORELEASEPOOL { #if JUCE_IOS - NSArray* fonts = [UIFont familyNames]; + for (NSString* name in [UIFont familyNames]) #else - NSArray* fonts = [[NSFontManager sharedFontManager] availableFontFamilies]; + for (NSString* name in [[NSFontManager sharedFontManager] availableFontFamilies]) #endif - - for (unsigned int i = 0; i < [fonts count]; ++i) - names.add (nsStringToJuce ((NSString*) [fonts objectAtIndex: i])); + names.add (nsStringToJuce (name)); names.sort (true); } @@ -1137,13 +1135,8 @@ StringArray Font::findAllTypefaceStyles (const String& family) JUCE_AUTORELEASEPOOL { - NSArray* styles = [[NSFontManager sharedFontManager] availableMembersOfFontFamily: juceStringToNS (family)]; - - for (unsigned int i = 0; i < [styles count]; ++i) - { - NSArray* style = [styles objectAtIndex: i]; + for (NSArray* style in [[NSFontManager sharedFontManager] availableMembersOfFontFamily: juceStringToNS (family)]) results.add (nsStringToJuce ((NSString*) [style objectAtIndex: 1])); - } } return results; diff --git a/modules/juce_gui_basics/native/juce_mac_Windowing.mm b/modules/juce_gui_basics/native/juce_mac_Windowing.mm index aa4d3c1f80..709993eeb7 100644 --- a/modules/juce_gui_basics/native/juce_mac_Windowing.mm +++ b/modules/juce_gui_basics/native/juce_mac_Windowing.mm @@ -360,17 +360,21 @@ void Desktop::Displays::findDisplays (const float masterScale) { DisplaySettingsChangeCallback::getInstance(); - NSArray* screens = [NSScreen screens]; - const CGFloat mainScreenBottom = [[screens objectAtIndex: 0] frame].size.height; + CGFloat mainScreenBottom = 0; - for (unsigned int i = 0; i < [screens count]; ++i) + for (NSScreen* s in [NSScreen screens]) { - NSScreen* s = (NSScreen*) [screens objectAtIndex: i]; - Display d; + d.isMain = false; + + if (mainScreenBottom == 0) + { + mainScreenBottom = [s frame].size.height; + d.isMain = true; + } + d.userArea = convertDisplayRect ([s visibleFrame], mainScreenBottom) / masterScale; d.totalArea = convertDisplayRect ([s frame], mainScreenBottom) / masterScale; - d.isMain = (i == 0); d.scale = masterScale; #if defined (MAC_OS_X_VERSION_10_7) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7) @@ -389,17 +393,9 @@ void Desktop::Displays::findDisplays (const float masterScale) //============================================================================== bool juce_areThereAnyAlwaysOnTopWindows() { - NSArray* windows = [NSApp windows]; - - for (unsigned int i = 0; i < [windows count]; ++i) - { - const NSInteger level = [((NSWindow*) [windows objectAtIndex: i]) level]; - - if (level == NSFloatingWindowLevel - || level == NSStatusWindowLevel - || level == NSModalPanelWindowLevel) + for (NSWindow* window in [NSApp windows]) + if ([window level] > NSNormalWindowLevel) return true; - } return false; }