diff -r 6c78cc6bd7a6 -r 436cbdf56810 Source/GGBLayer.m --- a/Source/GGBLayer.m Thu Jul 03 17:44:30 2008 -0700 +++ b/Source/GGBLayer.m Sat Jul 05 17:46:43 2008 -0700 @@ -8,6 +8,10 @@ #import "GGBLayer.h" #import "QuartzUtils.h" +#import "GGBUtils.h" + + +NSString* const GGBLayerStyleChangedNotification = @"GGBLayerStyleChanged"; @implementation GGBLayer @@ -67,6 +71,56 @@ } +- (void) setStyle: (NSDictionary*)style +{ + if( style != _styleDict ) { + if( _styleDict ) + [[NSNotificationCenter defaultCenter] removeObserver: self + name: GGBLayerStyleChangedNotification + object: _styleDict]; + if( style ) + [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(_styleChanged) + name: GGBLayerStyleChangedNotification + object: style]; + setObj(&_styleDict,style); + } + [super setStyle: style]; +} + +- (void) _styleChanged +{ + // Reapply the style, so any changes in the dict will take effect. + [super setStyle: _styleDict]; +} + +- (void) dealloc +{ + if( _styleDict ) + [[NSNotificationCenter defaultCenter] removeObserver: self + name: GGBLayerStyleChangedNotification + object: _styleDict]; + [super dealloc]; +} + + +- (void) setValue: (id)value ofStyleProperty: (NSString*)prop +{ + if( _styleDict ) { + id oldValue = [_styleDict objectForKey: prop]; + if( oldValue != value ) { + if( value ) + [_styleDict setObject: value forKey: prop]; + else + [_styleDict removeObjectForKey: prop]; + [[NSNotificationCenter defaultCenter] postNotificationName: GGBLayerStyleChangedNotification + object: _styleDict]; + } + } else + [self setValue: value forKey: prop]; +} + + + #if TARGET_OS_IPHONE #pragma mark -