Revision: 3444
          http://skim-app.svn.sourceforge.net/skim-app/?rev=3444&view=rev
Author:   hofman
Date:     2008-02-25 08:24:16 -0800 (Mon, 25 Feb 2008)

Log Message:
-----------
Allow circle line well.

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

Modified: trunk/SKLineWell.h
===================================================================
--- trunk/SKLineWell.h  2008-02-25 13:23:58 UTC (rev 3443)
+++ trunk/SKLineWell.h  2008-02-25 16:24:16 UTC (rev 3444)
@@ -41,16 +41,22 @@
 
 extern NSString *SKLineStylePboardType;
 
+typedef enum _SKLineWellDisplayStyle {
+    SKLineWellDisplayStyleLine,
+    SKLineWellDisplayStyleRectangle,
+    SKLineWellDisplayStyleOval
+} SKLineWellDisplayStyle;
+
 @interface SKLineWell : NSControl {
     float lineWidth;
     PDFBorderStyle style;
     NSArray *dashPattern;
     PDFLineStyle startLineStyle;
     PDFLineStyle endLineStyle;
+    SKLineWellDisplayStyle displayStyle;
     BOOL active;
     BOOL canActivate;
     BOOL isHighlighted;
-    BOOL ignoresLineEndings;
     BOOL existsActiveLineWell;
     
     id target;
@@ -73,8 +79,8 @@
 - (BOOL)isHighlighted;
 - (void)setHighlighted:(BOOL)flag;
 
-- (BOOL)ignoresLineEndings;
-- (void)setIgnoresLineEndings:(BOOL)flag;
+- (SKLineWellDisplayStyle)displayStyle;
+- (void)setDisplayStyle:(SKLineWellDisplayStyle)newStyle;
 
 - (float)lineWidth;
 - (void)setLineWidth:(float)width;

Modified: trunk/SKLineWell.m
===================================================================
--- trunk/SKLineWell.m  2008-02-25 13:23:58 UTC (rev 3443)
+++ trunk/SKLineWell.m  2008-02-25 16:24:16 UTC (rev 3444)
@@ -76,9 +76,9 @@
         dashPattern = nil;
         startLineStyle = kPDFLineStyleNone;
         endLineStyle = kPDFLineStyleNone;
+        displayStyle = SKLineWellDisplayStyleLine;
         active = NO;
         canActivate = YES;
-        ignoresLineEndings = NO;
         
         target = nil;
         action = NULL;
@@ -103,8 +103,8 @@
             dashPattern = [[decoder decodeObjectForKey:@"dashPattern"] retain];
             startLineStyle = [decoder decodeIntForKey:@"startLineStyle"];
             endLineStyle = [decoder decodeIntForKey:@"endLineStyle"];
+            displayStyle = [decoder decodeIntForKey:@"displayStyle"];
             active = [decoder decodeBoolForKey:@"active"];
-            ignoresLineEndings = [decoder 
decodeBoolForKey:@"ignoresLineEndings"];
             action = NSSelectorFromString([decoder 
decodeObjectForKey:@"action"]);
             target = [decoder decodeObjectForKey:@"target"];
         } else {
@@ -113,8 +113,8 @@
             dashPattern = [[decoder decodeObject] retain];
             [decoder decodeValueOfObjCType:@encode(int) at:&startLineStyle];
             [decoder decodeValueOfObjCType:@encode(int) at:&endLineStyle];
+            [decoder decodeValueOfObjCType:@encode(int) at:&displayStyle];
             [decoder decodeValueOfObjCType:@encode(BOOL) at:&active];
-            [decoder decodeValueOfObjCType:@encode(BOOL) 
at:&ignoresLineEndings];
             [decoder decodeValueOfObjCType:@encode(SEL) at:&action];
             target = [decoder decodeObject];
         }
@@ -139,8 +139,8 @@
         [coder encodeObject:dashPattern forKey:@"dashPattern"];
         [coder encodeInt:startLineStyle forKey:@"startLineStyle"];
         [coder encodeInt:endLineStyle forKey:@"endLineStyle"];
+        [coder encodeInt:displayStyle forKey:@"displayStyle"];
         [coder encodeBool:active forKey:@"active"];
-        [coder encodeBool:ignoresLineEndings forKey:@"ignoresLineEndings"];
         [coder encodeObject:NSStringFromSelector(action) forKey:@"action"];
         [coder encodeConditionalObject:target forKey:@"target"];
     } else {
@@ -149,8 +149,8 @@
         [coder encodeObject:dashPattern];
         [coder encodeValueOfObjCType:@encode(int) at:&startLineStyle];
         [coder encodeValueOfObjCType:@encode(int) at:&endLineStyle];
+        [coder encodeValueOfObjCType:@encode(int) at:&displayStyle];
         [coder encodeValueOfObjCType:@encode(BOOL) at:&active];
-        [coder encodeValueOfObjCType:@encode(BOOL) at:&ignoresLineEndings];
         [coder encodeValueOfObjCType:@encode(SEL) at:action];
         [coder encodeConditionalObject:target];
     }
@@ -184,7 +184,7 @@
     NSBezierPath *path = [NSBezierPath bezierPath];
     NSRect bounds = [self bounds];
     
-    if ([self ignoresLineEndings] == NO) {
+    if ([self displayStyle] == SKLineWellDisplayStyleLine) {
         float offset = 0.5 * lineWidth - floorf(0.5 * lineWidth);
         NSPoint startPoint = NSMakePoint(NSMinX(bounds) + ceilf(0.5 * 
NSHeight(bounds)), roundf(NSMidY(bounds)) - offset);
         NSPoint endPoint = NSMakePoint(NSMaxX(bounds) - ceilf(0.5 * 
NSHeight(bounds)), roundf(NSMidY(bounds)) - offset);
@@ -193,10 +193,10 @@
             case kPDFLineStyleNone:
                 break;
             case kPDFLineStyleSquare:
-                [path appendBezierPath:[NSBezierPath 
bezierPathWithRect:NSMakeRect(startPoint.x - 1.5 * lineWidth, startPoint.y - 
1.5 * lineWidth, 3 * lineWidth, 3 * lineWidth)]];
+                [path appendBezierPathWithRect:NSMakeRect(startPoint.x - 1.5 * 
lineWidth, startPoint.y - 1.5 * lineWidth, 3 * lineWidth, 3 * lineWidth)];
                 break;
             case kPDFLineStyleCircle:
-                [path appendBezierPath:[NSBezierPath 
bezierPathWithOvalInRect:NSMakeRect(startPoint.x - 1.5 * lineWidth, 
startPoint.y - 1.5 * lineWidth, 3 * lineWidth, 3 * lineWidth)]];
+                [path appendBezierPathWithOvalInRect:NSMakeRect(startPoint.x - 
1.5 * lineWidth, startPoint.y - 1.5 * lineWidth, 3 * lineWidth, 3 * lineWidth)];
                 break;
             case kPDFLineStyleDiamond:
                 [path moveToPoint:NSMakePoint(startPoint.x - 2.0 * lineWidth, 
startPoint.y)];
@@ -225,10 +225,10 @@
             case kPDFLineStyleNone:
                 break;
             case kPDFLineStyleSquare:
-                [path appendBezierPath:[NSBezierPath 
bezierPathWithRect:NSMakeRect(endPoint.x - 1.5 * lineWidth, endPoint.y - 1.5 * 
lineWidth, 3 * lineWidth, 3 * lineWidth)]];
+                [path appendBezierPathWithRect:NSMakeRect(endPoint.x - 1.5 * 
lineWidth, endPoint.y - 1.5 * lineWidth, 3 * lineWidth, 3 * lineWidth)];
                 break;
             case kPDFLineStyleCircle:
-                [path appendBezierPath:[NSBezierPath 
bezierPathWithOvalInRect:NSMakeRect(endPoint.x - 1.5 * lineWidth, endPoint.y - 
1.5 * lineWidth, 3 * lineWidth, 3 * lineWidth)]];
+                [path appendBezierPathWithOvalInRect:NSMakeRect(endPoint.x - 
1.5 * lineWidth, endPoint.y - 1.5 * lineWidth, 3 * lineWidth, 3 * lineWidth)];
                 break;
             case kPDFLineStyleDiamond:
                 [path moveToPoint:NSMakePoint(endPoint.x + 2.0 * lineWidth, 
endPoint.y)];
@@ -249,9 +249,12 @@
                 [path closePath];
                 break;
         }
+    } else if ([self displayStyle] == SKLineWellDisplayStyleRectangle) {
+        float inset = 7.0 + 0.5 * lineWidth;
+        [path appendBezierPathWithRect:NSInsetRect(bounds, inset, inset)];
     } else {
         float inset = 7.0 + 0.5 * lineWidth;
-        [path appendBezierPath:[NSBezierPath 
bezierPathWithRect:NSInsetRect(bounds, inset, inset)]];
+        [path appendBezierPathWithOvalInRect:NSInsetRect(bounds, inset, 
inset)];
     }
     
     [path setLineWidth:lineWidth];
@@ -356,7 +359,7 @@
                     [pboard declareTypes:[NSArray 
arrayWithObjects:SKLineStylePboardType, nil] owner:nil];
                     NSMutableDictionary *dict = [NSMutableDictionary 
dictionaryWithObjectsAndKeys:
                         [NSNumber numberWithFloat:lineWidth], @"lineWidth", 
[NSNumber numberWithInt:style], @"style", dashPattern, @"dashPattern", nil];
-                    if ([self ignoresLineEndings] == NO) {
+                    if ([self displayStyle] == SKLineWellDisplayStyleLine) {
                         [dict setObject:[NSNumber 
numberWithInt:startLineStyle] forKey:@"startLineStyle"];
                         [dict setObject:[NSNumber numberWithInt:endLineStyle] 
forKey:@"endLineStyle"];
                     }
@@ -427,7 +430,7 @@
             [self setLineWidth:[inspector lineWidth]];
             [self setDashPattern:[inspector dashPattern]];
             [self setStyle:[inspector style]];
-            if ([self ignoresLineEndings] == NO) {
+            if ([self displayStyle] == SKLineWellDisplayStyleLine) {
                 [self setStartLineStyle:[inspector startLineStyle]];
                 [self setEndLineStyle:[inspector endLineStyle]];
             }
@@ -436,7 +439,7 @@
             [inspector setLineWidth:[self lineWidth]];
             [inspector setDashPattern:[self dashPattern]];
             [inspector setStyle:[self style]];
-            if ([self ignoresLineEndings] == NO) {
+            if ([self displayStyle] == SKLineWellDisplayStyleLine) {
                 [inspector setStartLineStyle:[self startLineStyle]];
                 [inspector setEndLineStyle:[self endLineStyle]];
             }
@@ -453,7 +456,7 @@
                    name:SKLineInspectorLineStyleDidChangeNotification 
object:inspector];
         [nc addObserver:self 
selector:@selector(lineInspectorDashPatternChanged:)
                    name:SKLineInspectorDashPatternDidChangeNotification 
object:inspector];
-        if ([self ignoresLineEndings] == NO) {
+        if ([self displayStyle] == SKLineWellDisplayStyleLine) {
             [nc addObserver:self 
selector:@selector(lineInspectorStartLineStyleChanged:)
                        name:SKLineInspectorStartLineStyleDidChangeNotification 
object:inspector];
             [nc addObserver:self 
selector:@selector(lineInspectorEndLineStyleChanged:)
@@ -534,24 +537,24 @@
     }
 }
 
-- (BOOL)ignoresLineEndings {
-    return ignoresLineEndings;
+- (SKLineWellDisplayStyle)displayStyle {
+    return displayStyle;
 }
 
-- (void)setIgnoresLineEndings:(BOOL)flag {
-    if (ignoresLineEndings != flag) {
-        ignoresLineEndings = flag;
+- (void)setDisplayStyle:(SKLineWellDisplayStyle)newStyle {
+    if (displayStyle != newStyle) {
+        displayStyle = newStyle;
         if ([self isActive]) {
             NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
             SKLineInspector *inspector = [SKLineInspector sharedLineInspector];
-            if ([self ignoresLineEndings]) {
-                [nc removeObserver:self 
name:SKLineInspectorStartLineStyleDidChangeNotification object:inspector];
-                [nc removeObserver:self 
name:SKLineInspectorEndLineStyleDidChangeNotification object:inspector];
-            } else {
+            if ([self displayStyle] == SKLineWellDisplayStyleLine) {
                 [nc addObserver:self 
selector:@selector(lineInspectorStartLineStyleChanged:)
                           
name:SKLineInspectorStartLineStyleDidChangeNotification object:inspector];
                 [nc addObserver:self 
selector:@selector(lineInspectorEndLineStyleChanged:)
                           
name:SKLineInspectorEndLineStyleDidChangeNotification object:inspector];
+            } else {
+                [nc removeObserver:self 
name:SKLineInspectorStartLineStyleDidChangeNotification object:inspector];
+                [nc removeObserver:self 
name:SKLineInspectorEndLineStyleDidChangeNotification object:inspector];
             }
         }
         [self setNeedsDisplay:YES];
@@ -767,7 +770,7 @@
     if (number = [dict objectForKey:@"style"])
         [self setStyle:[number intValue]];
     [self setDashPattern:[dict objectForKey:@"dashPattern"]];
-    if ([self ignoresLineEndings] == NO) {
+    if ([self displayStyle] == SKLineWellDisplayStyleLine) {
         if (number = [dict objectForKey:@"startLineStyle"])
             [self setStartLineStyle:[number intValue]];
         if (number = [dict objectForKey:@"endLineStyle"])

Modified: trunk/SKPreferenceController.m
===================================================================
--- trunk/SKPreferenceController.m      2008-02-25 13:23:58 UTC (rev 3443)
+++ trunk/SKPreferenceController.m      2008-02-25 16:24:16 UTC (rev 3444)
@@ -134,17 +134,17 @@
     [textLineWell bind:@"lineWidth" toObject:sudc 
withKeyPath:VALUES_KEY_PATH(SKFreeTextNoteLineWidthKey) options:nil];
     [textLineWell bind:@"style" toObject:sudc 
withKeyPath:VALUES_KEY_PATH(SKFreeTextNoteLineStyleKey) options:nil];
     [textLineWell bind:@"dashPattern" toObject:sudc 
withKeyPath:VALUES_KEY_PATH(SKFreeTextNoteDashPatternKey) options:nil];
-    [textLineWell setIgnoresLineEndings:YES];
+    [textLineWell setDisplayStyle:SKLineWellDisplayStyleRectangle];
     
     [circleLineWell bind:@"lineWidth" toObject:sudc 
withKeyPath:VALUES_KEY_PATH(SKCircleNoteLineWidthKey) options:nil];
     [circleLineWell bind:@"style" toObject:sudc 
withKeyPath:VALUES_KEY_PATH(SKCircleNoteLineStyleKey) options:nil];
     [circleLineWell bind:@"dashPattern" toObject:sudc 
withKeyPath:VALUES_KEY_PATH(SKCircleNoteDashPatternKey) options:nil];
-    [circleLineWell setIgnoresLineEndings:YES];
+    [circleLineWell setDisplayStyle:SKLineWellDisplayStyleOval];
     
     [boxLineWell bind:@"lineWidth" toObject:sudc 
withKeyPath:VALUES_KEY_PATH(SKSquareNoteLineWidthKey) options:nil];
     [boxLineWell bind:@"style" toObject:sudc 
withKeyPath:VALUES_KEY_PATH(SKSquareNoteLineStyleKey) options:nil];
     [boxLineWell bind:@"dashPattern" toObject:sudc 
withKeyPath:VALUES_KEY_PATH(SKSquareNoteDashPatternKey) options:nil];
-    [boxLineWell setIgnoresLineEndings:YES];
+    [boxLineWell setDisplayStyle:SKLineWellDisplayStyleRectangle];
     
     [lineLineWell bind:@"lineWidth" toObject:sudc 
withKeyPath:VALUES_KEY_PATH(SKLineNoteLineWidthKey) options:nil];
     [lineLineWell bind:@"style" toObject:sudc 
withKeyPath:VALUES_KEY_PATH(SKLineNoteLineStyleKey) options:nil];


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

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to