Revision: 4045
          http://skim-app.svn.sourceforge.net/skim-app/?rev=4045&view=rev
Author:   hofman
Date:     2008-06-20 08:29:13 -0700 (Fri, 20 Jun 2008)

Log Message:
-----------
avoid code duplication in line well

Modified Paths:
--------------
    trunk/SKLineWell.m

Modified: trunk/SKLineWell.m
===================================================================
--- trunk/SKLineWell.m  2008-06-20 11:56:01 UTC (rev 4044)
+++ trunk/SKLineWell.m  2008-06-20 15:29:13 UTC (rev 4045)
@@ -81,6 +81,16 @@
         return [NSNumber class];
 }
 
+- (void)commonInit {
+    bindingInfo = [[NSMutableDictionary alloc] init];
+    
+    existsActiveLineWell = NO;
+    updatingFromLineInspector = NO;
+    updatingFromBinding = NO;
+    
+    [self registerForDraggedTypes:[NSArray 
arrayWithObjects:SKLineStylePboardType, nil]];
+}
+
 - (id)initWithFrame:(NSRect)frame {
     if (self = [super initWithFrame:frame]) {
         lineWidth = 1.0;
@@ -95,14 +105,7 @@
         target = nil;
         action = NULL;
         
-        bindingInfo = [[NSMutableDictionary alloc] init];
-        
-        existsActiveLineWell = NO;
-        
-        updatingFromLineInspector = NO;
-        updatingFromBinding = NO;
-        
-        [self registerForDraggedTypes:[NSArray 
arrayWithObjects:SKLineStylePboardType, nil]];
+        [self commonInit];
     }
     return self;
 }
@@ -130,15 +133,7 @@
             [decoder decodeValueOfObjCType:@encode(SEL) at:&action];
             target = [decoder decodeObject];
         }
-        
-        bindingInfo = [[NSMutableDictionary alloc] init];
-        
-        existsActiveLineWell = NO;
-        
-        updatingFromLineInspector = NO;
-        updatingFromBinding = NO;
-        
-        [self registerForDraggedTypes:[NSArray 
arrayWithObjects:SKLineStylePboardType, nil]];
+        [self commonInit];
     }
     return self;
 }
@@ -181,7 +176,7 @@
     [super dealloc];
 }
 
-- (BOOL)isOpaque{  return YES; }
+- (BOOL)isOpaque{ return YES; }
 
 - (BOOL)acceptsFirstResponder { return [self canActivate]; }
 
@@ -640,44 +635,32 @@
 
 #pragma mark Notification handlers
 
-- (void)lineInspectorLineWidthChanged:(NSNotification *)notification {
+- (void)lineInspectorChangedValueForKey:(NSString *)key {
     BOOL savedUpdatingFromLineInspector = updatingFromLineInspector;
     updatingFromLineInspector = YES;
-    [self setLineWidth:[[notification object] lineWidth]];
+    [self setValue:[[SKLineInspector sharedLineInspector] valueForKey:key] 
forKey:key];
     [self sendAction:[self action] to:[self target]];
     updatingFromLineInspector = savedUpdatingFromLineInspector;
 }
 
+- (void)lineInspectorLineWidthChanged:(NSNotification *)notification {
+    [self lineInspectorChangedValueForKey:SKLineWellLineWidthKey];
+}
+
 - (void)lineInspectorLineStyleChanged:(NSNotification *)notification {
-    BOOL savedUpdatingFromLineInspector = updatingFromLineInspector;
-    updatingFromLineInspector = YES;
-    [self setStyle:[[notification object] style]];
-    [self sendAction:[self action] to:[self target]];
-    updatingFromLineInspector = savedUpdatingFromLineInspector;
+    [self lineInspectorChangedValueForKey:SKLineWellStyleKey];
 }
 
 - (void)lineInspectorDashPatternChanged:(NSNotification *)notification {
-    BOOL savedUpdatingFromLineInspector = updatingFromLineInspector;
-    updatingFromLineInspector = YES;
-    [self setDashPattern:[[notification object] dashPattern]];
-    [self sendAction:[self action] to:[self target]];
-    updatingFromLineInspector = savedUpdatingFromLineInspector;
+    [self lineInspectorChangedValueForKey:SKLineWellDashPatternKey];
 }
 
 - (void)lineInspectorStartLineStyleChanged:(NSNotification *)notification {
-    BOOL savedUpdatingFromLineInspector = updatingFromLineInspector;
-    updatingFromLineInspector = YES;
-    [self setStartLineStyle:[[notification object] startLineStyle]];
-    [self sendAction:[self action] to:[self target]];
-    updatingFromLineInspector = savedUpdatingFromLineInspector;
+    [self lineInspectorChangedValueForKey:SKLineWellStartLineStyleKey];
 }
 
 - (void)lineInspectorEndLineStyleChanged:(NSNotification *)notification {
-    BOOL savedUpdatingFromLineInspector = updatingFromLineInspector;
-    updatingFromLineInspector = YES;
-    [self setEndLineStyle:[[notification object] endLineStyle]];
-    [self sendAction:[self action] to:[self target]];
-    updatingFromLineInspector = savedUpdatingFromLineInspector;
+    [self lineInspectorChangedValueForKey:SKLineWellEndLineStyleKey];
 }
 
 #pragma mark Binding support


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to