Revision: 4814
          http://skim-app.svn.sourceforge.net/skim-app/?rev=4814&view=rev
Author:   hofman
Date:     2008-10-18 11:53:18 +0000 (Sat, 18 Oct 2008)

Log Message:
-----------
nscoder for new font well properties

Modified Paths:
--------------
    trunk/SKFontWell.h
    trunk/SKFontWell.m

Modified: trunk/SKFontWell.h
===================================================================
--- trunk/SKFontWell.h  2008-10-18 11:21:25 UTC (rev 4813)
+++ trunk/SKFontWell.h  2008-10-18 11:53:18 UTC (rev 4814)
@@ -41,6 +41,7 @@
 extern NSString *SKFontWellFontNameKey;
 extern NSString *SKFontWellFontSizeKey;
 extern NSString *SKFontWellTextColorKey;
+extern NSString *SKFontWellHasTextColorKey;
 
 extern NSString *SKFontWellFontKey;
 extern NSString *SKFontWellActionKey;

Modified: trunk/SKFontWell.m
===================================================================
--- trunk/SKFontWell.m  2008-10-18 11:21:25 UTC (rev 4813)
+++ trunk/SKFontWell.m  2008-10-18 11:53:18 UTC (rev 4814)
@@ -48,6 +48,7 @@
 NSString *SKFontWellFontNameKey = @"fontName";
 NSString *SKFontWellFontSizeKey = @"fontSize";
 NSString *SKFontWellTextColorKey = @"textColor";
+NSString *SKFontWellHasTextColorKey = @"hasTextColor";
 
 NSString *SKFontWellFontKey = @"font";
 NSString *SKFontWellActionKey = @"action";
@@ -112,8 +113,7 @@
     if (self = [super initWithCoder:decoder]) {
                NSButtonCell *oldCell = [self cell];
                if (NO == [oldCell isKindOfClass:[[self class] cellClass]]) {
-                       SKFontWellCell *newCell = [[SKFontWellCell alloc] init];
-                       [newCell setBezelStyle:[oldCell bezelStyle]];
+                       SKFontWellCell *newCell = [[[self class] alloc] init];
                        [newCell setAlignment:[oldCell alignment]];
                        [newCell setEditable:[oldCell isEditable]];
                        [newCell setTarget:[oldCell target]];
@@ -452,7 +452,8 @@
 @implementation SKFontWellCell
 
 - (void)commonInit {
-    [self setTextColor:[NSColor blackColor]];
+    if (textColor == nil)
+        [self setTextColor:[NSColor blackColor]];
     [self setBezelStyle:NSShadowlessSquareBezelStyle]; // this is mainly to 
make it selectable
     [self setButtonType:NSPushOnPushOffButton];
     [self setState:NSOffState];
@@ -465,13 +466,31 @@
        return self;
 }
 
-- (id)initWithCoder:(NSCoder *)coder {
-       if (self = [super initWithCoder:coder]) {
-               [self commonInit];
+- (id)initWithCoder:(NSCoder *)decoder {
+       if (self = [super initWithCoder:decoder]) {
+        if ([decoder allowsKeyedCoding]) {
+            [self setTextColor:[decoder 
decodeObjectForKey:SKFontWellTextColorKey]];
+            [self setHasTextColor:[decoder 
decodeBoolForKey:SKFontWellHasTextColorKey]];
+        } else {
+            [self setTextColor:[decoder decodeObject]];
+            [decoder decodeValueOfObjCType:@encode(BOOL) at:&hasTextColor];
+               }
+        [self commonInit];
        }
        return self;
 }
 
+- (void)encodeWithCoder:(NSCoder *)coder {
+    [super encodeWithCoder:coder];
+    if ([coder allowsKeyedCoding]) {
+        [coder encodeConditionalObject:textColor 
forKey:SKFontWellTextColorKey];
+        [coder encodeObject:textColor forKey:SKFontWellHasTextColorKey];
+    } else {
+        [coder encodeObject:textColor];
+        [coder encodeValueOfObjCType:@encode(BOOL) at:&hasTextColor];
+    }
+}
+
 - (void)dealloc {
     [textColor release];
     [super dealloc];


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 the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to