| 1 |
// |
| 2 |
// NSWindowControllerAdditions.m |
| 3 |
// |
| 4 |
// Created by Toshi Nagata on Mon Nov 08 2004. |
| 5 |
// |
| 6 |
/* |
| 7 |
Copyright (c) 2004-2011 Toshi Nagata. All rights reserved. |
| 8 |
|
| 9 |
This program is free software; you can redistribute it and/or modify |
| 10 |
it under the terms of the GNU General Public License as published by |
| 11 |
the Free Software Foundation version 2 of the License. |
| 12 |
|
| 13 |
This program is distributed in the hope that it will be useful, |
| 14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
GNU General Public License for more details. |
| 17 |
*/ |
| 18 |
|
| 19 |
#import "NSWindowControllerAdditions.h" |
| 20 |
//#import "TrackWindowController.h" |
| 21 |
#import "ListWindowController.h" |
| 22 |
#import "GraphicWindowController.h" |
| 23 |
|
| 24 |
//NSString *gTrackWindowType = @"track window"; |
| 25 |
NSString *gGraphicWindowType = @"graphic window"; |
| 26 |
NSString *gListWindowType = @"list window"; |
| 27 |
|
| 28 |
NSLayoutManager *gSharedLayoutManager = nil; |
| 29 |
|
| 30 |
@implementation NSWindowController (MyWindowControllerAddition) |
| 31 |
|
| 32 |
+ (BOOL)canContainMultipleTracks |
| 33 |
{ |
| 34 |
return NO; |
| 35 |
} |
| 36 |
|
| 37 |
+ (Class)classForWindowType: (NSString *)windowType |
| 38 |
{ |
| 39 |
Class class; |
| 40 |
// if ([windowType isEqualToString: gTrackWindowType]) { |
| 41 |
// class = [TrackWindowController class]; |
| 42 |
// } else |
| 43 |
if ([windowType isEqualToString: gGraphicWindowType]) { |
| 44 |
class = [GraphicWindowController class]; |
| 45 |
} else if ([windowType isEqualToString: gListWindowType]) { |
| 46 |
class = [ListWindowController class]; |
| 47 |
} else class = nil; |
| 48 |
return class; |
| 49 |
} |
| 50 |
|
| 51 |
- (NSMutableDictionary *)encodeWindow |
| 52 |
{ |
| 53 |
NSMutableDictionary *dict; |
| 54 |
dict = [NSMutableDictionary dictionary]; |
| 55 |
[dict setObject: [self className] forKey: @"class name"]; |
| 56 |
[dict setObject: [[self window] stringWithSavedFrame] forKey: @"frame"]; |
| 57 |
return dict; |
| 58 |
} |
| 59 |
|
| 60 |
- (void)decodeWindowWithDictionary: (NSDictionary *)dictionary |
| 61 |
{ |
| 62 |
[[self window] setFrameFromString: [dictionary objectForKey: @"frame"]]; |
| 63 |
} |
| 64 |
|
| 65 |
- (NSString *)windowType |
| 66 |
{ |
| 67 |
return @""; |
| 68 |
} |
| 69 |
|
| 70 |
- (BOOL)containsTrack: (int)trackNum |
| 71 |
{ |
| 72 |
return NO; |
| 73 |
} |
| 74 |
|
| 75 |
- (void)addTrack: (int)trackNum |
| 76 |
{ |
| 77 |
} |
| 78 |
|
| 79 |
- (void)setFocusFlag: (BOOL) flag onTrack: (int)trackNum extending: (BOOL)extendFlag |
| 80 |
{ |
| 81 |
} |
| 82 |
|
| 83 |
- (BOOL)isFocusTrack: (int)trackNum |
| 84 |
{ |
| 85 |
return NO; |
| 86 |
} |
| 87 |
|
| 88 |
- (void)reloadSelection |
| 89 |
{ |
| 90 |
} |
| 91 |
|
| 92 |
+ (NSLayoutManager *)sharedLayoutManager |
| 93 |
{ |
| 94 |
if (gSharedLayoutManager == nil) { |
| 95 |
gSharedLayoutManager = [[NSLayoutManager alloc] init]; |
| 96 |
} |
| 97 |
return gSharedLayoutManager; |
| 98 |
} |
| 99 |
|
| 100 |
@end |
| 101 |
|
| 102 |
@implementation NSWindowController (viewWithTag) |
| 103 |
|
| 104 |
- (id)viewWithTag: (NSInteger)tag |
| 105 |
{ |
| 106 |
return [[[self window] contentView] viewWithTag: tag]; |
| 107 |
} |
| 108 |
|
| 109 |
@end |