-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added replacement methods for faulty CGSizeMakeWithDictionaryRepresentation - Made DTVersion NSCopying-compliant - Added category for NSWindowController to modally present a modal sheet, more like UIKit
- Loading branch information
Showing
11 changed files
with
212 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// NSDocument+DTFoundation.h | ||
// DTFoundation | ||
// | ||
// Created by Oliver Drobnik on 10/1/12. | ||
// Copyright (c) 2012 Cocoanetics. All rights reserved. | ||
// | ||
|
||
#import <Cocoa/Cocoa.h> | ||
|
||
@interface NSDocument (DTFoundation) | ||
|
||
- (NSWindowController *)mainDocumentWindowController; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// NSDocument+DTFoundation.m | ||
// DTFoundation | ||
// | ||
// Created by Oliver Drobnik on 10/1/12. | ||
// Copyright (c) 2012 Cocoanetics. All rights reserved. | ||
// | ||
|
||
#import "NSDocument+DTFoundation.h" | ||
|
||
@implementation NSDocument (DTFoundation) | ||
|
||
- (NSWindowController *)mainDocumentWindowController | ||
{ | ||
// TODO: what if there are more than one window for a document? | ||
return [self.windowControllers objectAtIndex:0]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
Core/Source/NSWindowController+DTPanelControllerPresenting.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// NSWindowController+DTViewControllerPresenting.h | ||
// DTFoundation | ||
// | ||
// Created by Oliver Drobnik on 10/1/12. | ||
// Copyright (c) 2012 Cocoanetics. All rights reserved. | ||
// | ||
|
||
typedef void (^DTPanelControllerPresentingCompletionBlock)(NSUInteger result); | ||
|
||
@interface NSWindowController (DTPanelControllerPresenting) | ||
|
||
@property (nonatomic, readonly, strong) NSWindowController *modalPanelController; | ||
|
||
- (void)presentModalPanelController:(NSWindowController *)panelController; | ||
|
||
- (void)dismissModalPanelController; | ||
|
||
@end |
55 changes: 55 additions & 0 deletions
55
Core/Source/NSWindowController+DTPanelControllerPresenting.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// | ||
// NSWindow+DTViewControllerPresenting.m | ||
// DTFoundation | ||
// | ||
// Created by Oliver Drobnik on 10/1/12. | ||
// Copyright (c) 2012 Cocoanetics. All rights reserved. | ||
// | ||
|
||
#import "objc/runtime.h" | ||
|
||
#import "NSWindowController+DTPanelControllerPresenting.h" | ||
|
||
static char DTPresentedViewControllerKey; | ||
|
||
@implementation NSWindowController (DTPanelControllerPresenting) | ||
|
||
- (void)presentModalPanelController:(NSWindowController *)panelController | ||
{ | ||
NSWindowController *windowController = self.modalPanelController; | ||
|
||
if (windowController) | ||
{ | ||
NSLog(@"Already presenting %@, cannot modally present another panel", NSStringFromClass([windowController class])); | ||
return; | ||
} | ||
|
||
[NSApp beginSheet:panelController.window modalForWindow:self.window modalDelegate:nil didEndSelector:nil contextInfo:nil]; | ||
|
||
// retain the panel view controller | ||
objc_setAssociatedObject(self, &DTPresentedViewControllerKey, panelController, OBJC_ASSOCIATION_RETAIN_NONATOMIC); | ||
} | ||
|
||
- (void)dismissModalPanelController | ||
{ | ||
NSWindowController *windowController = self.modalPanelController; | ||
|
||
if (!windowController) | ||
{ | ||
return; | ||
} | ||
|
||
// slide out | ||
[NSApp endSheet:windowController.window]; | ||
[windowController.window close]; | ||
|
||
// free the panel view controller | ||
objc_setAssociatedObject(self, &DTPresentedViewControllerKey, nil, OBJC_ASSOCIATION_RETAIN_NONATOMIC); | ||
} | ||
|
||
- (NSWindowController *)modalPanelController | ||
{ | ||
return objc_getAssociatedObject(self, &DTPresentedViewControllerKey); | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters