From 9e318781c61170fc28682d0600cd37e0c8fd5308 Mon Sep 17 00:00:00 2001 From: "gtm.daemon" Date: Thu, 8 Oct 2009 21:30:27 +0000 Subject: [Author: dmaclach] Add pattern phase the way I really want it (for now). R=thomasvl,alcor DELTA=91 (31 added, 52 deleted, 8 changed) --- AppKit/GTMTheme.m | 59 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 25 deletions(-) (limited to 'AppKit/GTMTheme.m') 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)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 )[self delegate] gtm_themeForWindow:self]; - } else if ([[self windowController] conformsToProtocol: - @protocol(GTMThemeDelegate)]) { - theme = [[self windowController] gtm_themeForWindow:self]; + iddelegate = [self gtm_themeDelegate]; + if (delegate) { + theme = [delegate gtm_themeForWindow:self]; } return theme; } + +- (NSPoint)gtm_themePatternPhase { + NSPoint phase = NSZeroPoint; + iddelegate = [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]; -- cgit v1.2.3