1.1 --- a/Source/GGBLayer.m Thu Jul 03 17:44:30 2008 -0700
1.2 +++ b/Source/GGBLayer.m Tue Jul 08 13:12:01 2008 -0700
1.3 @@ -8,6 +8,10 @@
1.4
1.5 #import "GGBLayer.h"
1.6 #import "QuartzUtils.h"
1.7 +#import "GGBUtils.h"
1.8 +
1.9 +
1.10 +NSString* const GGBLayerStyleChangedNotification = @"GGBLayerStyleChanged";
1.11
1.12
1.13 @implementation GGBLayer
1.14 @@ -67,6 +71,56 @@
1.15 }
1.16
1.17
1.18 +- (void) setStyle: (NSDictionary*)style
1.19 +{
1.20 + if( style != _styleDict ) {
1.21 + if( _styleDict )
1.22 + [[NSNotificationCenter defaultCenter] removeObserver: self
1.23 + name: GGBLayerStyleChangedNotification
1.24 + object: _styleDict];
1.25 + if( style )
1.26 + [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(_styleChanged)
1.27 + name: GGBLayerStyleChangedNotification
1.28 + object: style];
1.29 + setObj(&_styleDict,style);
1.30 + }
1.31 + [super setStyle: style];
1.32 +}
1.33 +
1.34 +- (void) _styleChanged
1.35 +{
1.36 + // Reapply the style, so any changes in the dict will take effect.
1.37 + [super setStyle: _styleDict];
1.38 +}
1.39 +
1.40 +- (void) dealloc
1.41 +{
1.42 + if( _styleDict )
1.43 + [[NSNotificationCenter defaultCenter] removeObserver: self
1.44 + name: GGBLayerStyleChangedNotification
1.45 + object: _styleDict];
1.46 + [super dealloc];
1.47 +}
1.48 +
1.49 +
1.50 +- (void) setValue: (id)value ofStyleProperty: (NSString*)prop
1.51 +{
1.52 + if( _styleDict ) {
1.53 + id oldValue = [_styleDict objectForKey: prop];
1.54 + if( oldValue != value ) {
1.55 + if( value )
1.56 + [_styleDict setObject: value forKey: prop];
1.57 + else
1.58 + [_styleDict removeObjectForKey: prop];
1.59 + [[NSNotificationCenter defaultCenter] postNotificationName: GGBLayerStyleChangedNotification
1.60 + object: _styleDict];
1.61 + }
1.62 + } else
1.63 + [self setValue: value forKey: prop];
1.64 +}
1.65 +
1.66 +
1.67 +
1.68 #if TARGET_OS_IPHONE
1.69
1.70 #pragma mark -