Revision: 3995
http://skim-app.svn.sourceforge.net/skim-app/?rev=3995&view=rev
Author: hofman
Date: 2008-06-10 08:17:30 -0700 (Tue, 10 Jun 2008)
Log Message:
-----------
Factor common initialization of color swatch.
Modified Paths:
--------------
trunk/SKColorSwatch.m
Modified: trunk/SKColorSwatch.m
===================================================================
--- trunk/SKColorSwatch.m 2008-06-09 10:18:16 UTC (rev 3994)
+++ trunk/SKColorSwatch.m 2008-06-10 15:17:30 UTC (rev 3995)
@@ -47,6 +47,7 @@
static NSString *SKColorSwatchTargetKey = @"target";
static NSString *SKColorSwatchActionKey = @"action";
+static NSString *SKColorSwatchAutoresizesKey = @"autoResizes";
static NSString *SKColorSwatchColorsObservationContext =
@"SKColorSwatchColorsObservationContext";
@@ -76,19 +77,25 @@
return [super valueClassForBinding:binding];
}
+- (void)commonInit {
+ highlightedIndex = -1;
+ insertionIndex = -1;
+ focusedIndex = 0;
+ clickedIndex = -1;
+ draggedIndex = -1;
+
+ bindingInfo = [[NSMutableDictionary alloc] init];
+ [self registerForDraggedTypes:[NSArray arrayWithObjects:NSColorPboardType,
nil]];
+}
+
- (id)initWithFrame:(NSRect)frame {
self = [super initWithFrame:frame];
if (self) {
colors = [[NSMutableArray alloc] initWithObjects:[NSColor whiteColor],
nil];
- highlightedIndex = -1;
- insertionIndex = -1;
- focusedIndex = 0;
- clickedIndex = -1;
- draggedIndex = -1;
+ action = NULL;
+ target = nil;
autoResizes = YES;
-
- bindingInfo = [[NSMutableDictionary alloc] init];
- [self registerForDraggedTypes:[NSArray
arrayWithObjects:NSColorPboardType, nil]];
+ [self commonInit];
}
return self;
}
@@ -99,21 +106,14 @@
colors = [[NSMutableArray alloc] initWithArray:[decoder
decodeObjectForKey:SKColorSwatchColorsKey]];
action = NSSelectorFromString([decoder
decodeObjectForKey:SKColorSwatchActionKey]);
target = [decoder decodeObjectForKey:SKColorSwatchTargetKey];
+ autoResizes = [decoder
decodeBoolForKey:SKColorSwatchAutoresizesKey];
} else {
colors = [[NSMutableArray alloc] initWithArray:[decoder
decodeObject]];
[decoder decodeValueOfObjCType:@encode(SEL) at:&action];
target = [decoder decodeObject];
+ [decoder decodeValueOfObjCType:@encode(BOOL) at:&autoResizes];
}
-
- highlightedIndex = -1;
- insertionIndex = -1;
- focusedIndex = 0;
- clickedIndex = -1;
- draggedIndex = -1;
- autoResizes = YES;
-
- bindingInfo = [[NSMutableDictionary alloc] init];
- [self registerForDraggedTypes:[NSArray
arrayWithObjects:NSColorPboardType, nil]];
+ [self commonInit];
}
return self;
}
@@ -124,10 +124,12 @@
[coder encodeObject:colors forKey:SKColorSwatchColorsKey];
[coder encodeObject:NSStringFromSelector(action)
forKey:SKColorSwatchActionKey];
[coder encodeConditionalObject:target forKey:SKColorSwatchTargetKey];
+ [coder encodeBool:autoResizes forKey:SKColorSwatchAutoresizesKey];
} else {
[coder encodeObject:colors];
[coder encodeValueOfObjCType:@encode(SEL) at:action];
[coder encodeConditionalObject:target];
+ [coder encodeValueOfObjCType:@encode(BOOL) at:&autoResizes];
}
}
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