diff options
author | gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3> | 2009-10-08 21:30:27 +0000 |
---|---|---|
committer | gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3> | 2009-10-08 21:30:27 +0000 |
commit | 9e318781c61170fc28682d0600cd37e0c8fd5308 (patch) | |
tree | 7edff2585337e1bd9125a83779cd852a7e9775c7 /AppKit/GTMTheme.m | |
parent | fa88fbb1d4c8e8dd3541f79f5fe406493cd63fa4 (diff) |
[Author: dmaclach]
Add pattern phase the way I really want it (for now).
R=thomasvl,alcor
DELTA=91 (31 added, 52 deleted, 8 changed)
Diffstat (limited to 'AppKit/GTMTheme.m')
-rw-r--r-- | AppKit/GTMTheme.m | 59 |
1 files changed, 34 insertions, 25 deletions
diff --git a/AppKit/GTMTheme.m b/AppKit/GTMTheme.m index cb30bda..7b966f9 100644 --- a/AppKit/GTMTheme.m +++ b/AppKit/GTMTheme.m @@ -26,28 +26,53 @@ static GTMTheme *gGTMDefaultTheme = nil; NSString *const kGTMThemeDidChangeNotification = @"GTMThemeDidChangeNotification"; NSString *const kGTMThemeBackgroundColorKey = @"GTMThemeBackgroundColor"; +@interface GTMTheme () +- (void)sendChangeNotification; +@end + @implementation NSWindow (GTMTheme) +- (id<GTMThemeDelegate>)gtm_themeDelegate { + id delegate = nil; + id tempDelegate = [self delegate]; + if ([tempDelegate conformsToProtocol:@protocol(GTMThemeDelegate)]) { + delegate = tempDelegate; + } + if (!delegate) { + tempDelegate = [self windowController]; + if ([tempDelegate conformsToProtocol:@protocol(GTMThemeDelegate)]) { + delegate = tempDelegate; + } + } + return delegate; +} + - (GTMTheme *)gtm_theme { GTMTheme *theme = nil; - if ([[self delegate] conformsToProtocol: - @protocol(GTMThemeDelegate)]) { - theme = [(id <GTMThemeDelegate>)[self delegate] gtm_themeForWindow:self]; - } else if ([[self windowController] conformsToProtocol: - @protocol(GTMThemeDelegate)]) { - theme = [[self windowController] gtm_themeForWindow:self]; + id<GTMThemeDelegate>delegate = [self gtm_themeDelegate]; + if (delegate) { + theme = [delegate gtm_themeForWindow:self]; } return theme; } + +- (NSPoint)gtm_themePatternPhase { + NSPoint phase = NSZeroPoint; + id<GTMThemeDelegate>delegate = [self gtm_themeDelegate]; + if (delegate) { + phase = [delegate gtm_themePatternPhaseForWindow:self]; + } + return phase; +} @end @implementation NSView (GTMTheme) - (GTMTheme *)gtm_theme { return [[self window] gtm_theme]; } -@end -@interface GTMTheme () -- (void)sendChangeNotification; +- (NSPoint)gtm_themePatternPhase { + return [[self window] gtm_themePatternPhase]; +} @end @implementation GTMTheme @@ -88,11 +113,6 @@ NSString *const kGTMThemeBackgroundColorKey = @"GTMThemeBackgroundColor"; NSUnarchiveFromDataTransformerName, NSValueTransformerNameBindingOption, nil]]; - - [self bind:@"backgroundPatternPhase" - toObject:controller - withKeyPath:@"values.GTMThemeBackgroundPatternPhase" - options:nil]; } - (id)init { @@ -106,14 +126,12 @@ NSString *const kGTMThemeBackgroundColorKey = @"GTMThemeBackgroundColor"; - (void)finalize { [self unbind:@"backgroundColor"]; [self unbind:@"backgroundImage"]; - [self unbind:@"backgroundPatternPhase"]; [super finalize]; } - (void)dealloc { [self unbind:@"backgroundColor"]; [self unbind:@"backgroundImage"]; - [self unbind:@"backgroundPatternPhase"]; [values_ release]; [super dealloc]; } @@ -196,15 +214,6 @@ NSString *const kGTMThemeBackgroundColorKey = @"GTMThemeBackgroundColor"; return backgroundImage_; } -- (NSPoint)backgroundPatternPhase { - return backgroundPatternPhase_; -} - -- (void)setBackgroundPatternPhase:(NSPoint)phase { - backgroundPatternPhase_ = phase; - [self sendChangeNotification]; -} - - (NSImage *)backgroundImageForStyle:(GTMThemeStyle)style state:(GTMThemeState)state { id value = [self valueForSelector:_cmd style:style state:state]; |