Add support for PAT# resources.

This commit is contained in:
Nate Weaver 2012-07-08 12:43:57 -05:00
parent db738486d1
commit 4293bc190c
9 changed files with 619 additions and 140 deletions

View File

@ -12,12 +12,13 @@
@class Resource;
@protocol ResKnifeResourceProtocol;
@interface PatternWindowController : NSWindowController <ResKnifePluginProtocol> {
NSImageView *imageView;
@interface PatternWindowController : NSWindowController <ResKnifePluginProtocol, NSTableViewDataSource, NSTableViewDelegate> {
NSTableView *tableView;
IBOutlet NSImageView *imageView;
id <ResKnifeResourceProtocol> resource;
NSImage *image;
NSMutableArray *images;
}
@property (assign) IBOutlet NSImageView *imageView;
@property (assign) IBOutlet NSTableView *tableView;
@end

View File

@ -14,39 +14,65 @@
@end
@implementation PatternWindowController
@synthesize imageView;
@synthesize tableView;
- (id)initWithWindow:(NSWindow *)window
{
self = [super initWithWindow:window];
if (self) {
// Initialization code here.
images = [[NSMutableArray alloc] init];
}
return self;
}
- (NSImage *)imageWithPATData:(NSData *)data {
unsigned char *oneBitData = (unsigned char *)[data bytes];
// make our own grayscale rep insted of a 1-bit rep to avoid some weird drawing bugs :/
NSBitmapImageRep *rep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL pixelsWide:8 pixelsHigh:8 bitsPerSample:8 samplesPerPixel:1 hasAlpha:NO isPlanar:NO colorSpaceName:NSCalibratedWhiteColorSpace bytesPerRow:8 bitsPerPixel:8];
unsigned char *grayscaleData = [rep bitmapData];
for (NSUInteger i = 0; i < 8; ++i) {
for (NSUInteger j = 0; j < 8; ++j)
grayscaleData[i * 8 + j] = (oneBitData[i] & (1 << j)) ? 0x0 : 0xff;
}
NSImage *newImage = [[NSImage alloc] init];
[newImage addRepresentation:rep];
return [newImage autorelease];
}
- (void)loadPAT:(id <ResKnifeResourceProtocol>)inResource {
NSData *data = [inResource data];
[images addObject:[self imageWithPATData:data]];
}
- (void)loadPATList:(id <ResKnifeResourceProtocol>)inResource {
NSData *data = [inResource data];
uint16_t numberOfPatterns;
[data getBytes:&numberOfPatterns length:sizeof(numberOfPatterns)];
numberOfPatterns = CFSwapInt16BigToHost(numberOfPatterns);
NSUInteger loc = sizeof(numberOfPatterns);
do {
NSData *subdata = [data subdataWithRange:(NSRange){ .location = loc, .length = 8 }];
[images addObject:[self imageWithPATData:subdata]];
} while ((loc += 8) <= [data length] - 8);
}
- (void)windowDidLoad
{
[super windowDidLoad];
// set the window's title
[[self window] setTitle:[resource defaultWindowTitle]];
NSData *data = [resource data];
unsigned char *planes[1] = { 0 };
planes[0] = (unsigned char *)[data bytes];
NSBitmapImageRep *rep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:planes pixelsWide:8 pixelsHigh:8 bitsPerSample:1 samplesPerPixel:1 hasAlpha:NO isPlanar:NO colorSpaceName:NSCalibratedWhiteColorSpace bytesPerRow:1 bitsPerPixel:1];
for (NSUInteger i = 0; i < 8; ++i)
[rep bitmapData][i] ^= 0xff;
image = [[NSImage alloc] init];
[image addRepresentation:rep];
[imageView setImage:image];
[tableView reloadData];
// we don't want this notification until we have a window! (Only register for notifications on the resource we're editing)
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(resourceDataDidChange:) name:ResourceDataDidChangeNotification object:resource];
@ -57,6 +83,10 @@
- (id)initWithResource:(id <ResKnifeResourceProtocol>)inResource {
if (self = [self initWithWindowNibName:@"PatternWindowController"]) {
resource = [inResource retain];
if ([[resource type] isEqualToString:@"PAT "]) // single 8x8 B&W pattern
[self loadPAT:resource];
else if ([[resource type] isEqualToString:@"PAT#"]) // list of 8x8 B&W patterns
[self loadPATList:resource];
[self window];
}
@ -65,6 +95,7 @@
- (void)dealloc {
[resource release];
[images release];
[super dealloc];
}
@ -73,4 +104,17 @@
return [resource defaultWindowTitle];
}
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView {
return [images count];
}
- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
return [images objectAtIndex:row];
}
- (void)tableViewSelectionDidChange:(NSNotification *)notification {
NSImage *image = [images objectAtIndex:[tableView selectedRow]];
[imageView setImage:image];
}
@end

View File

@ -11,12 +11,16 @@
<string key="NS.object.0">2182</string>
</object>
<array key="IBDocument.IntegratedClassDependencies">
<string>NSImageView</string>
<string>NSWindowTemplate</string>
<string>NSView</string>
<string>NSImageCell</string>
<string>NSCustomObject</string>
<string>NSTableView</string>
<string>NSScrollView</string>
<string>NSWindowTemplate</string>
<string>IBNSLayoutConstraint</string>
<string>NSImageCell</string>
<string>NSTableColumn</string>
<string>NSImageView</string>
<string>NSScroller</string>
<string>NSCustomObject</string>
</array>
<array key="IBDocument.PluginDependencies">
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@ -38,18 +42,18 @@
<object class="NSWindowTemplate" id="1005">
<int key="NSWindowStyleMask">15</int>
<int key="NSWindowBacking">2</int>
<string key="NSWindowRect">{{196, 240}, {478, 309}}</string>
<string key="NSWindowRect">{{196, 240}, {450, 309}}</string>
<int key="NSWTFlags">544735232</int>
<string key="NSWindowTitle">Window</string>
<string key="NSWindowClass">NSWindow</string>
<nil key="NSViewClass"/>
<nil key="NSUserInterfaceItemIdentifier"/>
<string key="NSWindowContentMinSize">{100, 100}</string>
<string key="NSWindowContentMinSize">{200, 100}</string>
<object class="NSView" key="NSWindowView" id="1006">
<reference key="NSNextResponder"/>
<int key="NSvFlags">256</int>
<array class="NSMutableArray" key="NSSubviews">
<object class="NSImageView" id="599375712">
<object class="NSImageView" id="41167696">
<reference key="NSNextResponder" ref="1006"/>
<int key="NSvFlags">268</int>
<set class="NSMutableSet" key="NSDragTypes">
@ -60,30 +64,185 @@
<string>NeXT Encapsulated PostScript v1.2 pasteboard type</string>
<string>NeXT TIFF v4.0 pasteboard type</string>
</set>
<string key="NSFrame">{{17, 17}, {444, 275}}</string>
<string key="NSFrame">{{63, 17}, {370, 275}}</string>
<reference key="NSSuperview" ref="1006"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="NSEnabled">YES</bool>
<object class="NSImageCell" key="NSCell" id="844875715">
<object class="NSImageCell" key="NSCell" id="526651189">
<int key="NSCellFlags">130560</int>
<int key="NSCellFlags2">33554432</int>
<string key="NSCellIdentifier">_NS:9</string>
<int key="NSAlign">0</int>
<int key="NSScale">0</int>
<int key="NSScale">3</int>
<int key="NSStyle">2</int>
<bool key="NSAnimates">NO</bool>
</object>
<bool key="NSEditable">YES</bool>
</object>
<object class="NSScrollView" id="410690172">
<reference key="NSNextResponder" ref="1006"/>
<int key="NSvFlags">268</int>
<array class="NSMutableArray" key="NSSubviews">
<object class="NSClipView" id="967156179">
<reference key="NSNextResponder" ref="410690172"/>
<int key="NSvFlags">2304</int>
<array class="NSMutableArray" key="NSSubviews">
<object class="NSTableView" id="404158079">
<reference key="NSNextResponder" ref="967156179"/>
<int key="NSvFlags">256</int>
<string key="NSFrameSize">{44, 267}</string>
<reference key="NSSuperview" ref="967156179"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="40289171"/>
<string key="NSReuseIdentifierKey">_NS:13</string>
<bool key="NSEnabled">YES</bool>
<object class="_NSCornerView" key="NSCornerView">
<nil key="NSNextResponder"/>
<int key="NSvFlags">-2147483392</int>
<string key="NSFrame">{{224, 0}, {16, 17}}</string>
<reference key="NSNextKeyView" ref="967156179"/>
<string key="NSReuseIdentifierKey">_NS:19</string>
</object>
<array class="NSMutableArray" key="NSTableColumns">
<object class="NSTableColumn" id="576726611">
<string key="NSIdentifier">image</string>
<double key="NSWidth">41</double>
<double key="NSMinWidth">40</double>
<double key="NSMaxWidth">1000</double>
<object class="NSTableHeaderCell" key="NSHeaderCell">
<int key="NSCellFlags">75628096</int>
<int key="NSCellFlags2">2048</int>
<string key="NSContents">Image</string>
<object class="NSFont" key="NSSupport">
<string key="NSName">LucidaGrande</string>
<double key="NSSize">11</double>
<int key="NSfFlags">3100</int>
</object>
<object class="NSColor" key="NSBackgroundColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MC4zMzMzMzI5ODU2AA</bytes>
</object>
<object class="NSColor" key="NSTextColor">
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">headerTextColor</string>
<object class="NSColor" key="NSColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MAA</bytes>
</object>
</object>
</object>
<object class="NSImageCell" key="NSDataCell" id="513548098">
<int key="NSCellFlags">67239424</int>
<int key="NSCellFlags2">33554432</int>
<object class="NSFont" key="NSSupport">
<string key="NSName">LucidaGrande</string>
<double key="NSSize">13</double>
<int key="NSfFlags">1044</int>
</object>
<string key="NSCellIdentifier">_NS:9</string>
<int key="NSAlign">0</int>
<int key="NSScale">0</int>
<int key="NSStyle">0</int>
<bool key="NSAnimates">NO</bool>
</object>
<int key="NSResizingMask">3</int>
<bool key="NSIsResizeable">YES</bool>
<bool key="NSIsEditable">YES</bool>
<reference key="NSTableView" ref="404158079"/>
</object>
</array>
<double key="NSIntercellSpacingWidth">3</double>
<double key="NSIntercellSpacingHeight">2</double>
<object class="NSColor" key="NSBackgroundColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MQA</bytes>
</object>
<object class="NSColor" key="NSGridColor">
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">gridColor</string>
<object class="NSColor" key="NSColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MC41AA</bytes>
</object>
</object>
<double key="NSRowHeight">25</double>
<int key="NSTvFlags">306184192</int>
<reference key="NSDelegate"/>
<reference key="NSDataSource"/>
<int key="NSColumnAutoresizingStyle">4</int>
<int key="NSDraggingSourceMaskForLocal">15</int>
<int key="NSDraggingSourceMaskForNonLocal">0</int>
<bool key="NSAllowsTypeSelect">YES</bool>
<int key="NSTableViewDraggingDestinationStyle">1</int>
<int key="NSTableViewGroupRowStyle">1</int>
</object>
</array>
<string key="NSFrame">{{1, 1}, {44, 267}}</string>
<reference key="NSSuperview" ref="410690172"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="404158079"/>
<string key="NSReuseIdentifierKey">_NS:11</string>
<reference key="NSDocView" ref="404158079"/>
<object class="NSColor" key="NSBGColor">
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">controlBackgroundColor</string>
<object class="NSColor" key="NSColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MC42NjY2NjY2NjY3AA</bytes>
</object>
</object>
<int key="NScvFlags">4</int>
</object>
<object class="NSScroller" id="40289171">
<reference key="NSNextResponder" ref="410690172"/>
<int key="NSvFlags">-2147483392</int>
<string key="NSFrame">{{224, 17}, {15, 102}}</string>
<reference key="NSSuperview" ref="410690172"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="41167696"/>
<string key="NSReuseIdentifierKey">_NS:58</string>
<reference key="NSTarget" ref="410690172"/>
<string key="NSAction">_doScroller:</string>
<double key="NSPercent">0.99626865671641796</double>
</object>
<object class="NSScroller" id="910793070">
<reference key="NSNextResponder" ref="410690172"/>
<int key="NSvFlags">-2147483392</int>
<string key="NSFrame">{{-100, -100}, {158, 15}}</string>
<reference key="NSSuperview" ref="410690172"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="967156179"/>
<string key="NSReuseIdentifierKey">_NS:60</string>
<int key="NSsFlags">1</int>
<reference key="NSTarget" ref="410690172"/>
<string key="NSAction">_doScroller:</string>
<double key="NSPercent">0.97777777777777775</double>
</object>
</array>
<string key="NSFrame">{{12, 20}, {46, 269}}</string>
<reference key="NSSuperview" ref="1006"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="910793070"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<int key="NSsFlags">215570</int>
<reference key="NSVScroller" ref="40289171"/>
<reference key="NSHScroller" ref="910793070"/>
<reference key="NSContentView" ref="967156179"/>
<bytes key="NSScrollAmts">QSAAAEEgAABB2AAAQdgAAA</bytes>
</object>
</array>
<string key="NSFrameSize">{478, 309}</string>
<string key="NSFrameSize">{450, 309}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="599375712"/>
<reference key="NSNextKeyView" ref="410690172"/>
</object>
<string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string>
<string key="NSMinSize">{100, 122}</string>
<string key="NSMinSize">{200, 122}</string>
<string key="NSMaxSize">{10000000000000, 10000000000000}</string>
<bool key="NSWindowIsRestorable">YES</bool>
</object>
@ -102,9 +261,17 @@
<object class="IBOutletConnection" key="connection">
<string key="label">imageView</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="599375712"/>
<reference key="destination" ref="41167696"/>
</object>
<int key="connectionID">17</int>
<int key="connectionID">110</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">tableView</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="404158079"/>
</object>
<int key="connectionID">182</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
@ -114,6 +281,22 @@
</object>
<int key="connectionID">4</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">dataSource</string>
<reference key="source" ref="404158079"/>
<reference key="destination" ref="1001"/>
</object>
<int key="connectionID">189</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">delegate</string>
<reference key="source" ref="404158079"/>
<reference key="destination" ref="1001"/>
</object>
<int key="connectionID">204</int>
</object>
</array>
<object class="IBMutableOrderedSet" key="objectRecords">
<array key="orderedObjects">
@ -153,57 +336,9 @@
<int key="objectID">2</int>
<reference key="object" ref="1006"/>
<array class="NSMutableArray" key="children">
<reference ref="599375712"/>
<object class="IBNSLayoutConstraint" id="443890170">
<reference key="firstItem" ref="1006"/>
<int key="firstAttribute">6</int>
<int key="relation">0</int>
<reference key="secondItem" ref="599375712"/>
<int key="secondAttribute">6</int>
<float key="multiplier">1</float>
<object class="IBNSLayoutSymbolicConstant" key="constant">
<double key="value">20</double>
</object>
<float key="priority">1000</float>
<int key="scoringType">8</int>
<float key="scoringTypeFloat">29</float>
<int key="contentType">3</int>
<reference key="containingView" ref="1006"/>
</object>
<object class="IBNSLayoutConstraint" id="1018290444">
<reference key="firstItem" ref="1006"/>
<int key="firstAttribute">4</int>
<int key="relation">0</int>
<reference key="secondItem" ref="599375712"/>
<int key="secondAttribute">4</int>
<float key="multiplier">1</float>
<object class="IBNSLayoutSymbolicConstant" key="constant">
<double key="value">20</double>
</object>
<float key="priority">1000</float>
<int key="scoringType">8</int>
<float key="scoringTypeFloat">29</float>
<int key="contentType">3</int>
<reference key="containingView" ref="1006"/>
</object>
<object class="IBNSLayoutConstraint" id="1175548">
<reference key="firstItem" ref="599375712"/>
<int key="firstAttribute">5</int>
<int key="relation">0</int>
<reference key="secondItem" ref="1006"/>
<int key="secondAttribute">5</int>
<float key="multiplier">1</float>
<object class="IBNSLayoutSymbolicConstant" key="constant">
<double key="value">20</double>
</object>
<float key="priority">1000</float>
<int key="scoringType">8</int>
<float key="scoringTypeFloat">29</float>
<int key="contentType">3</int>
<reference key="containingView" ref="1006"/>
</object>
<reference ref="41167696"/>
<object class="IBNSLayoutConstraint" id="109993714">
<reference key="firstItem" ref="599375712"/>
<reference key="firstItem" ref="41167696"/>
<int key="firstAttribute">3</int>
<int key="relation">0</int>
<reference key="secondItem" ref="1006"/>
@ -218,42 +353,216 @@
<int key="contentType">3</int>
<reference key="containingView" ref="1006"/>
</object>
<object class="IBNSLayoutConstraint" id="1018290444">
<reference key="firstItem" ref="1006"/>
<int key="firstAttribute">4</int>
<int key="relation">0</int>
<reference key="secondItem" ref="410690172"/>
<int key="secondAttribute">4</int>
<float key="multiplier">1</float>
<object class="IBNSLayoutSymbolicConstant" key="constant">
<double key="value">20</double>
</object>
<float key="priority">1000</float>
<int key="scoringType">8</int>
<float key="scoringTypeFloat">29</float>
<int key="contentType">3</int>
<reference key="containingView" ref="1006"/>
</object>
<reference ref="410690172"/>
<object class="IBNSLayoutConstraint" id="468040445">
<reference key="firstItem" ref="1006"/>
<int key="firstAttribute">4</int>
<int key="relation">0</int>
<reference key="secondItem" ref="41167696"/>
<int key="secondAttribute">4</int>
<float key="multiplier">1</float>
<object class="IBNSLayoutSymbolicConstant" key="constant">
<double key="value">20</double>
</object>
<float key="priority">1000</float>
<int key="scoringType">8</int>
<float key="scoringTypeFloat">29</float>
<int key="contentType">3</int>
<reference key="containingView" ref="1006"/>
</object>
<object class="IBNSLayoutConstraint" id="7360670">
<reference key="firstItem" ref="410690172"/>
<int key="firstAttribute">3</int>
<int key="relation">0</int>
<reference key="secondItem" ref="1006"/>
<int key="secondAttribute">3</int>
<float key="multiplier">1</float>
<object class="IBNSLayoutSymbolicConstant" key="constant">
<double key="value">20</double>
</object>
<float key="priority">1000</float>
<int key="scoringType">8</int>
<float key="scoringTypeFloat">29</float>
<int key="contentType">3</int>
<reference key="containingView" ref="1006"/>
</object>
<object class="IBNSLayoutConstraint" id="443890170">
<reference key="firstItem" ref="1006"/>
<int key="firstAttribute">6</int>
<int key="relation">0</int>
<reference key="secondItem" ref="41167696"/>
<int key="secondAttribute">6</int>
<float key="multiplier">1</float>
<object class="IBNSLayoutSymbolicConstant" key="constant">
<double key="value">20</double>
</object>
<float key="priority">1000</float>
<int key="scoringType">8</int>
<float key="scoringTypeFloat">29</float>
<int key="contentType">3</int>
<reference key="containingView" ref="1006"/>
</object>
<object class="IBNSLayoutConstraint" id="495643400">
<reference key="firstItem" ref="41167696"/>
<int key="firstAttribute">5</int>
<int key="relation">0</int>
<reference key="secondItem" ref="410690172"/>
<int key="secondAttribute">6</int>
<float key="multiplier">1</float>
<object class="IBNSLayoutSymbolicConstant" key="constant">
<double key="value">8</double>
</object>
<float key="priority">1000</float>
<int key="scoringType">6</int>
<float key="scoringTypeFloat">24</float>
<int key="contentType">3</int>
<reference key="containingView" ref="1006"/>
</object>
<object class="IBNSLayoutConstraint" id="73608761">
<reference key="firstItem" ref="410690172"/>
<int key="firstAttribute">5</int>
<int key="relation">0</int>
<reference key="secondItem" ref="1006"/>
<int key="secondAttribute">5</int>
<float key="multiplier">1</float>
<object class="IBLayoutConstant" key="constant">
<double key="value">12</double>
</object>
<float key="priority">1000</float>
<int key="scoringType">9</int>
<float key="scoringTypeFloat">40</float>
<int key="contentType">3</int>
<reference key="containingView" ref="1006"/>
</object>
</array>
<reference key="parent" ref="1005"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">7</int>
<reference key="object" ref="599375712"/>
<int key="objectID">95</int>
<reference key="object" ref="41167696"/>
<array class="NSMutableArray" key="children">
<reference ref="844875715"/>
<reference ref="526651189"/>
</array>
<reference key="parent" ref="1006"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">8</int>
<reference key="object" ref="844875715"/>
<reference key="parent" ref="599375712"/>
<int key="objectID">96</int>
<reference key="object" ref="526651189"/>
<reference key="parent" ref="41167696"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">13</int>
<reference key="object" ref="443890170"/>
<int key="objectID">123</int>
<reference key="object" ref="410690172"/>
<array class="NSMutableArray" key="children">
<reference ref="404158079"/>
<reference ref="910793070"/>
<reference ref="40289171"/>
<object class="IBNSLayoutConstraint" id="608978989">
<reference key="firstItem" ref="410690172"/>
<int key="firstAttribute">7</int>
<int key="relation">0</int>
<nil key="secondItem"/>
<int key="secondAttribute">0</int>
<float key="multiplier">1</float>
<object class="IBLayoutConstant" key="constant">
<double key="value">46</double>
</object>
<float key="priority">1000</float>
<int key="scoringType">9</int>
<float key="scoringTypeFloat">40</float>
<int key="contentType">1</int>
<reference key="containingView" ref="410690172"/>
</object>
</array>
<reference key="parent" ref="1006"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">14</int>
<int key="objectID">124</int>
<reference key="object" ref="404158079"/>
<array class="NSMutableArray" key="children">
<reference ref="576726611"/>
</array>
<reference key="parent" ref="410690172"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">125</int>
<reference key="object" ref="910793070"/>
<reference key="parent" ref="410690172"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">127</int>
<reference key="object" ref="40289171"/>
<reference key="parent" ref="410690172"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">128</int>
<reference key="object" ref="576726611"/>
<array class="NSMutableArray" key="children">
<reference ref="513548098"/>
</array>
<reference key="parent" ref="404158079"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">142</int>
<reference key="object" ref="109993714"/>
<reference key="parent" ref="1006"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">167</int>
<reference key="object" ref="1018290444"/>
<reference key="parent" ref="1006"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">15</int>
<reference key="object" ref="1175548"/>
<int key="objectID">176</int>
<reference key="object" ref="513548098"/>
<reference key="parent" ref="576726611"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">192</int>
<reference key="object" ref="468040445"/>
<reference key="parent" ref="1006"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">16</int>
<reference key="object" ref="109993714"/>
<int key="objectID">193</int>
<reference key="object" ref="7360670"/>
<reference key="parent" ref="1006"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">201</int>
<reference key="object" ref="443890170"/>
<reference key="parent" ref="1006"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">202</int>
<reference key="object" ref="495643400"/>
<reference key="parent" ref="1006"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">203</int>
<reference key="object" ref="73608761"/>
<reference key="parent" ref="1006"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">205</int>
<reference key="object" ref="608978989"/>
<reference key="parent" ref="410690172"/>
</object>
</array>
</object>
<dictionary class="NSMutableDictionary" key="flattenedProperties">
@ -263,26 +572,45 @@
<string key="1.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="1.IBWindowTemplateEditedContentRect">{{357, 418}, {480, 270}}</string>
<integer value="1" key="1.NSWindowTemplate.visibleAtLaunch"/>
<string key="13.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="14.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="15.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="16.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<array key="123.IBNSViewMetadataConstraints">
<reference ref="608978989"/>
</array>
<boolean value="NO" key="123.IBNSViewMetadataTranslatesAutoresizingMaskIntoConstraints"/>
<string key="123.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="124.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="125.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="127.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="128.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="142.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="167.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="176.CustomClassName">RKPatternImageCell</string>
<string key="176.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="192.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="193.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<array class="NSMutableArray" key="2.IBNSViewMetadataConstraints">
<reference ref="443890170"/>
<reference ref="1018290444"/>
<reference ref="1175548"/>
<reference ref="109993714"/>
<reference ref="1018290444"/>
<reference ref="468040445"/>
<reference ref="7360670"/>
<reference ref="443890170"/>
<reference ref="495643400"/>
<reference ref="73608761"/>
</array>
<string key="2.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<boolean value="NO" key="7.IBNSViewMetadataTranslatesAutoresizingMaskIntoConstraints"/>
<string key="7.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="8.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="201.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="202.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="203.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="205.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="95.CustomClassName">RKPatternView</string>
<boolean value="NO" key="95.IBNSViewMetadataTranslatesAutoresizingMaskIntoConstraints"/>
<string key="95.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="96.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">17</int>
<int key="maxID">205</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
@ -297,22 +625,41 @@
<object class="IBPartialClassDescription">
<string key="className">PatternWindowController</string>
<string key="superclassName">NSWindowController</string>
<object class="NSMutableDictionary" key="outlets">
<string key="NS.key.0">imageView</string>
<string key="NS.object.0">NSImageView</string>
</object>
<object class="NSMutableDictionary" key="toOneOutletInfosByName">
<string key="NS.key.0">imageView</string>
<object class="IBToOneOutletInfo" key="NS.object.0">
<dictionary class="NSMutableDictionary" key="outlets">
<string key="imageView">NSImageView</string>
<string key="tableView">NSTableView</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
<object class="IBToOneOutletInfo" key="imageView">
<string key="name">imageView</string>
<string key="candidateClassName">NSImageView</string>
</object>
</object>
<object class="IBToOneOutletInfo" key="tableView">
<string key="name">tableView</string>
<string key="candidateClassName">NSTableView</string>
</object>
</dictionary>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/PatternWindowController.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">RKPatternImageCell</string>
<string key="superclassName">NSImageCell</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/RKPatternImageCell.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">RKPatternView</string>
<string key="superclassName">NSImageView</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/RKPatternView.h</string>
</object>
</object>
</array>
</object>
<int key="IBDocument.localizationMode">0</int>

View File

@ -0,0 +1,13 @@
//
// RKPatternImageCell.h
// ResKnife
//
// Created by Nate Weaver on 2012-7-8.
// Copyright (c) 2012 Derailer. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@interface RKPatternImageCell : NSImageCell
@end

View File

@ -0,0 +1,21 @@
//
// RKPatternImageCell.m
// ResKnife
//
// Created by Nate Weaver on 2012-7-8.
// Copyright (c) 2012 Derailer. All rights reserved.
//
#import "RKPatternImageCell.h"
@implementation RKPatternImageCell
- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView {
NSColor *pattern = [NSColor colorWithPatternImage:[self image]];
NSPoint phasePoint = [controlView convertPoint:(NSPoint){ .x = 0.0, .y = cellFrame.origin.y } toView:nil];
[[NSGraphicsContext currentContext] setPatternPhase:phasePoint];
[pattern set];
NSRectFill(NSInsetRect(cellFrame, 1.0, 1.0));
}
@end

View File

@ -0,0 +1,17 @@
//
// RKPatternView.h
// ResKnife
//
// Created by Nate Weaver on 2012-7-8.
// Copyright (c) 2012 Derailer. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@interface RKPatternView : NSImageView {
CGFloat scale;
}
@property (assign) CGFloat scale;
@end

View File

@ -0,0 +1,38 @@
//
// RKPatternView.m
// ResKnife
//
// Created by Nate Weaver on 2012-7-8.
// Copyright (c) 2012 Derailer. All rights reserved.
//
#import "RKPatternView.h"
@implementation RKPatternView
- (id)initWithFrame:(NSRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code here.
}
return self;
}
- (void)drawRect:(NSRect)dirtyRect
{
[[NSGraphicsContext currentContext] setImageInterpolation:NSImageInterpolationNone];
[super drawRect:dirtyRect];
}
- (CGFloat)scale {
return scale;
}
- (void)setScale:(CGFloat)newScale {
scale = newScale;
[self setNeedsDisplay:YES];
}
@end

View File

@ -29,6 +29,7 @@
<key>RKEditedTypes</key>
<array>
<string>PAT </string>
<string>PAT#</string>
</array>
</dict>
</plist>

View File

@ -35,6 +35,8 @@
B2B2C41615A946FB00D6F61C /* PatternWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = B2B2C3FE15A9453300D6F61C /* PatternWindowController.m */; };
B2B2C41715A9470500D6F61C /* PatternWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = B2B2C3FF15A9453300D6F61C /* PatternWindowController.xib */; };
B2B2C41815A9473C00D6F61C /* Notifications.m in Sources */ = {isa = PBXBuildFile; fileRef = F5C9ECCE027F474A01A8010C /* Notifications.m */; };
B2B2C42115A9EEEF00D6F61C /* RKPatternImageCell.m in Sources */ = {isa = PBXBuildFile; fileRef = B2B2C41E15A9EEE100D6F61C /* RKPatternImageCell.m */; };
B2B2C43A15A9FCCF00D6F61C /* RKPatternView.m in Sources */ = {isa = PBXBuildFile; fileRef = B2B2C43915A9FCCF00D6F61C /* RKPatternView.m */; };
B2FCA78B15A66ACE00696598 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F5B5884B0156D40B01000001 /* Cocoa.framework */; };
B2FCA79115A66ACF00696598 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = B2FCA78F15A66ACF00696598 /* InfoPlist.strings */; };
B2FCA79715A66B2A00696598 /* PictWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = B2FCA78015A669C800696598 /* PictWindowController.m */; };
@ -427,9 +429,13 @@
B2B2C3FE15A9453300D6F61C /* PatternWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PatternWindowController.m; path = "Pattern Editor/PatternWindowController.m"; sourceTree = "<group>"; };
B2B2C3FF15A9453300D6F61C /* PatternWindowController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = PatternWindowController.xib; path = "Pattern Editor/PatternWindowController.xib"; sourceTree = "<group>"; };
B2B2C40715A9464400D6F61C /* Pattern Editor.plugin */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Pattern Editor.plugin"; sourceTree = BUILT_PRODUCTS_DIR; };
B2B2C40B15A9464400D6F61C /* Pattern Editor-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Pattern Editor-Info.plist"; sourceTree = "<group>"; };
B2B2C40B15A9464400D6F61C /* Pattern Editor-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = "Pattern Editor-Info.plist"; path = "../../Pattern Editor/Pattern Editor-Info.plist"; sourceTree = "<group>"; };
B2B2C40D15A9464400D6F61C /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
B2B2C40F15A9464400D6F61C /* Pattern Editor-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Pattern Editor-Prefix.pch"; sourceTree = "<group>"; };
B2B2C40F15A9464400D6F61C /* Pattern Editor-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "Pattern Editor-Prefix.pch"; path = "../../Pattern Editor/Pattern Editor-Prefix.pch"; sourceTree = "<group>"; };
B2B2C41D15A9EEE100D6F61C /* RKPatternImageCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RKPatternImageCell.h; path = "Pattern Editor/RKPatternImageCell.h"; sourceTree = "<group>"; };
B2B2C41E15A9EEE100D6F61C /* RKPatternImageCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RKPatternImageCell.m; path = "Pattern Editor/RKPatternImageCell.m"; sourceTree = "<group>"; };
B2B2C43815A9FCCF00D6F61C /* RKPatternView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RKPatternView.h; path = "Pattern Editor/RKPatternView.h"; sourceTree = "<group>"; };
B2B2C43915A9FCCF00D6F61C /* RKPatternView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RKPatternView.m; path = "Pattern Editor/RKPatternView.m"; sourceTree = "<group>"; };
B2FCA77F15A669C800696598 /* PictWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PictWindowController.h; sourceTree = "<group>"; };
B2FCA78015A669C800696598 /* PictWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PictWindowController.m; sourceTree = "<group>"; };
B2FCA78115A669C800696598 /* SupportedTypes.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = SupportedTypes.plist; sourceTree = "<group>"; };
@ -805,31 +811,20 @@
sourceTree = "<group>";
};
B2B2C3FC15A9451800D6F61C /* Pattern Editor */ = {
isa = PBXGroup;
children = (
B2B2C3FD15A9453300D6F61C /* PatternWindowController.h */,
B2B2C3FE15A9453300D6F61C /* PatternWindowController.m */,
B2B2C3FF15A9453300D6F61C /* PatternWindowController.xib */,
);
name = "Pattern Editor";
sourceTree = "<group>";
};
B2B2C40915A9464400D6F61C /* Pattern Editor */ = {
isa = PBXGroup;
children = (
B2B2C40A15A9464400D6F61C /* Supporting Files */,
);
path = "Pattern Editor";
sourceTree = "<group>";
};
B2B2C40A15A9464400D6F61C /* Supporting Files */ = {
isa = PBXGroup;
children = (
B2B2C40B15A9464400D6F61C /* Pattern Editor-Info.plist */,
B2B2C40C15A9464400D6F61C /* InfoPlist.strings */,
B2B2C40F15A9464400D6F61C /* Pattern Editor-Prefix.pch */,
B2B2C3FD15A9453300D6F61C /* PatternWindowController.h */,
B2B2C3FE15A9453300D6F61C /* PatternWindowController.m */,
B2B2C3FF15A9453300D6F61C /* PatternWindowController.xib */,
B2B2C41D15A9EEE100D6F61C /* RKPatternImageCell.h */,
B2B2C41E15A9EEE100D6F61C /* RKPatternImageCell.m */,
B2B2C43815A9FCCF00D6F61C /* RKPatternView.h */,
B2B2C43915A9FCCF00D6F61C /* RKPatternView.m */,
);
name = "Supporting Files";
name = "Pattern Editor";
sourceTree = "<group>";
};
B2FCA77C15A669C800696598 /* PICT Editor */ = {
@ -996,7 +991,6 @@
F5B5887C0156D6D901000001 /* Prefix Files */,
F5B5881A0156D40B01000001 /* Cocoa */,
F5EA10690254A7B401A80001 /* External */,
B2B2C40915A9464400D6F61C /* Pattern Editor */,
F5B588490156D40B01000001 /* Frameworks */,
F5B588110156D30301000001 /* Products */,
);
@ -1793,6 +1787,8 @@
files = (
B2B2C41615A946FB00D6F61C /* PatternWindowController.m in Sources */,
B2B2C41815A9473C00D6F61C /* Notifications.m in Sources */,
B2B2C42115A9EEEF00D6F61C /* RKPatternImageCell.m in Sources */,
B2B2C43A15A9FCCF00D6F61C /* RKPatternView.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -2092,6 +2088,7 @@
B2B2C40D15A9464400D6F61C /* en */,
);
name = InfoPlist.strings;
path = "../../Pattern Editor";
sourceTree = "<group>";
};
B2FCA78F15A66ACF00696598 /* InfoPlist.strings */ = {