From d07a120cf1a165e5ab90e618c45f597e71009a41 Mon Sep 17 00:00:00 2001 From: Uli Kusterer Date: Wed, 6 Aug 2003 19:27:15 +0200 Subject: [PATCH] Added ICONEditor files (bitmap editor), which can serve as an example project for plugin developers. --- .../English.lproj/ICONWindow.nib/classes.nib | 13 + .../English.lproj/ICONWindow.nib/info.nib | 18 + .../English.lproj/ICONWindow.nib/objects.nib | Bin 0 -> 1014 bytes ICONEditor/English.lproj/InfoPlist.strings | Bin 0 -> 536 bytes ICONEditor/ICONEditor.pbproj/project.pbxproj | 415 ++++++++++++++++++ ICONEditor/ICONWindowController.h | 45 ++ ICONEditor/ICONWindowController.m | 177 ++++++++ ICONEditor/Info.plist | 32 ++ ICONEditor/README.txt | 14 + ICONEditor/version.plist | 16 + 10 files changed, 730 insertions(+) create mode 100644 ICONEditor/English.lproj/ICONWindow.nib/classes.nib create mode 100644 ICONEditor/English.lproj/ICONWindow.nib/info.nib create mode 100644 ICONEditor/English.lproj/ICONWindow.nib/objects.nib create mode 100644 ICONEditor/English.lproj/InfoPlist.strings create mode 100644 ICONEditor/ICONEditor.pbproj/project.pbxproj create mode 100644 ICONEditor/ICONWindowController.h create mode 100644 ICONEditor/ICONWindowController.m create mode 100644 ICONEditor/Info.plist create mode 100644 ICONEditor/README.txt create mode 100644 ICONEditor/version.plist diff --git a/ICONEditor/English.lproj/ICONWindow.nib/classes.nib b/ICONEditor/English.lproj/ICONWindow.nib/classes.nib new file mode 100644 index 0000000..fa4aa22 --- /dev/null +++ b/ICONEditor/English.lproj/ICONWindow.nib/classes.nib @@ -0,0 +1,13 @@ +{ + IBClasses = ( + {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, + { + ACTIONS = {imageViewChanged = id; }; + CLASS = ICONWindowController; + LANGUAGE = ObjC; + OUTLETS = {imageView = NSImageView; resource = id; }; + SUPERCLASS = NSWindowController; + } + ); + IBVersion = 1; +} \ No newline at end of file diff --git a/ICONEditor/English.lproj/ICONWindow.nib/info.nib b/ICONEditor/English.lproj/ICONWindow.nib/info.nib new file mode 100644 index 0000000..3963b6f --- /dev/null +++ b/ICONEditor/English.lproj/ICONWindow.nib/info.nib @@ -0,0 +1,18 @@ + + + + + IBDocumentLocation + 239 118 356 240 0 0 1024 746 + IBFramework Version + 326.0 + IBLockedObjects + + IBOpenObjects + + 5 + + IBSystem Version + 7A202 + + diff --git a/ICONEditor/English.lproj/ICONWindow.nib/objects.nib b/ICONEditor/English.lproj/ICONWindow.nib/objects.nib new file mode 100644 index 0000000000000000000000000000000000000000..98d26c062d8f4d6c0b6088b98d8233e310871407 GIT binary patch literal 1014 zcmZuw&x_MQ6rQx*wYA-~h4tVbB%WkZmR%79@z8G8LJy|J)F0P0ovov35|ZiGJ!YNE z9}wEofD~abve3&?P!aV{@L%vK{so@IH=S-hxJh7!m+yUV-uu4EfEm;$PDdFq<<>?` ztLx8*({}rs>rmgdZS3=iGlir_fX+jquGzs)3GQz)meY*|Y>Tl~-4J2e0qQXhJlAPs z9}QymHjWa+3T1c>7LPp9qaHO|Hm>--d4w3dq#JTONR&9?Q4}e;P1>Cb79(5-KY{9J7yOLjd|JT zdDYFup=w(5zf@i-g^0rkeb3i;BKu|;Vp(ORK$A-?G;G^){9;!DVF@`d-uQzM%ZQP~ zj3SmMgdmgxAuWYZgp@_ykU}?c*ApFu%I^VNBSa`fL}J-mPoXe%TaNyC=QS{n$E7C@ zCDeuifW~gmw=jn&*hsQ*puX}?4{5FOI3ujVCy~N3f*<3%8DZE6k=VvoHDC=gYGsJNuBE4VBqsHCaoL Vuw${dr@5AER()_y-}PT{{ud4&gVF#1 literal 0 HcmV?d00001 diff --git a/ICONEditor/English.lproj/InfoPlist.strings b/ICONEditor/English.lproj/InfoPlist.strings new file mode 100644 index 0000000000000000000000000000000000000000..1beec3fe7bcb828a202d22f6eeb4c65b573ac0d2 GIT binary patch literal 536 zcmbu5$qK?i5Jc1~+g4170QWqA{XT(2rMNMhPh6Nrt2+-PPSMb$_U+ zoE-HOY9?PhZFJK@b8;8rQ71B?_C$xc + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + ICONEditor + CFBundleIconFile + + CFBundleIdentifier + com.ulikusterer.resknife.bitmapeditor + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + BNDL + CFBundleSignature + ResK + CFBundleVersion + 0.0.1d1 + NSMainNibFile + ICONWindow + NSPrincipalClass + ICONWindowController + RKEditedTypes + + ICON + ICN# + icm# + ics# + CURS + + + +"; + }; + 089C1674FE841209C02AAC07 = { + buildActionMask = 2147483647; + files = ( + 3D357B2D04DB010F00B8225B, + 3D3B99A604DBE3310056861E, + 3D3B99A704DBE3310056861E, + ); + isa = PBXHeadersBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 089C1675FE841209C02AAC07 = { + buildActionMask = 2147483647; + files = ( + 089C1680FE841241C02AAC07, + 3D357B3004DB011A00B8225B, + ); + isa = PBXResourcesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 089C1676FE841209C02AAC07 = { + buildActionMask = 2147483647; + files = ( + 3D357B2C04DB010F00B8225B, + 3D3B99A904DBE4450056861E, + ); + isa = PBXSourcesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 089C1677FE841209C02AAC07 = { + buildActionMask = 2147483647; + files = ( + 1058C7AFFEA557BF11CA2CBB, + ); + isa = PBXFrameworksBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 089C1679FE841209C02AAC07 = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXRezBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 089C167CFE841241C02AAC07 = { + children = ( + 3D357B2E04DB011A00B8225B, + 089C167DFE841241C02AAC07, + ); + isa = PBXGroup; + name = Resources; + refType = 4; + }; + 089C167DFE841241C02AAC07 = { + children = ( + 089C167EFE841241C02AAC07, + ); + isa = PBXVariantGroup; + name = InfoPlist.strings; + refType = 4; + }; + 089C167EFE841241C02AAC07 = { + fileEncoding = 10; + isa = PBXFileReference; + name = English; + path = English.lproj/InfoPlist.strings; + refType = 4; + }; + 089C167FFE841241C02AAC07 = { + isa = PBXFrameworkReference; + name = AppKit.framework; + path = /System/Library/Frameworks/AppKit.framework; + refType = 0; + }; + 089C1680FE841241C02AAC07 = { + fileRef = 089C167DFE841241C02AAC07; + isa = PBXBuildFile; + settings = { + }; + }; + 08FB77AFFE84173DC02AAC07 = { + children = ( + 3D357B2A04DB010F00B8225B, + 3D357B2B04DB010F00B8225B, + ); + isa = PBXGroup; + name = Classes; + refType = 4; + }; +//080 +//081 +//082 +//083 +//084 +//100 +//101 +//102 +//103 +//104 + 1058C7ACFEA557BF11CA2CBB = { + children = ( + 1058C7ADFEA557BF11CA2CBB, + ); + isa = PBXGroup; + name = "Linked Frameworks"; + refType = 4; + }; + 1058C7ADFEA557BF11CA2CBB = { + isa = PBXFrameworkReference; + name = Cocoa.framework; + path = /System/Library/Frameworks/Cocoa.framework; + refType = 0; + }; + 1058C7AEFEA557BF11CA2CBB = { + children = ( + 089C1672FE841209C02AAC07, + 089C167FFE841241C02AAC07, + ); + isa = PBXGroup; + name = "Other Frameworks"; + refType = 4; + }; + 1058C7AFFEA557BF11CA2CBB = { + fileRef = 1058C7ADFEA557BF11CA2CBB; + isa = PBXBuildFile; + settings = { + }; + }; +//100 +//101 +//102 +//103 +//104 +//190 +//191 +//192 +//193 +//194 + 19C28FB8FE9D52D311CA2CBB = { + children = ( + 014CEA410018CDE011CA2923, + ); + isa = PBXGroup; + name = Products; + refType = 4; + }; +//190 +//191 +//192 +//193 +//194 +//320 +//321 +//322 +//323 +//324 + 32C88E010371C26100C91783 = { + children = ( + 3D3B99A404DBE3310056861E, + 3D3B99A504DBE3310056861E, + 3D3B99A804DBE4450056861E, + ); + isa = PBXGroup; + name = "Other Sources"; + refType = 4; + }; +//320 +//321 +//322 +//323 +//324 +//3D0 +//3D1 +//3D2 +//3D3 +//3D4 + 3D357B2A04DB010F00B8225B = { + fileEncoding = 30; + isa = PBXFileReference; + path = ICONWindowController.m; + refType = 4; + }; + 3D357B2B04DB010F00B8225B = { + fileEncoding = 30; + isa = PBXFileReference; + path = ICONWindowController.h; + refType = 4; + }; + 3D357B2C04DB010F00B8225B = { + fileRef = 3D357B2A04DB010F00B8225B; + isa = PBXBuildFile; + settings = { + }; + }; + 3D357B2D04DB010F00B8225B = { + fileRef = 3D357B2B04DB010F00B8225B; + isa = PBXBuildFile; + settings = { + }; + }; + 3D357B2E04DB011A00B8225B = { + children = ( + 3D357B2F04DB011A00B8225B, + ); + isa = PBXVariantGroup; + name = ICONWindow.nib; + path = ""; + refType = 4; + }; + 3D357B2F04DB011A00B8225B = { + isa = PBXFileReference; + name = English; + path = English.lproj/ICONWindow.nib; + refType = 4; + }; + 3D357B3004DB011A00B8225B = { + fileRef = 3D357B2E04DB011A00B8225B; + isa = PBXBuildFile; + settings = { + }; + }; + 3D357B3104DB013D00B8225B = { + fileEncoding = 30; + isa = PBXFileReference; + path = README.txt; + refType = 4; + }; + 3D3B99A404DBE3310056861E = { + fileEncoding = 30; + isa = PBXFileReference; + name = ResKnifePluginProtocol.h; + path = "../Cocoa/Plug-Ins/ResKnifePluginProtocol.h"; + refType = 2; + }; + 3D3B99A504DBE3310056861E = { + fileEncoding = 30; + isa = PBXFileReference; + name = ResKnifeResourceProtocol.h; + path = "../Cocoa/Plug-Ins/ResKnifeResourceProtocol.h"; + refType = 2; + }; + 3D3B99A604DBE3310056861E = { + fileRef = 3D3B99A404DBE3310056861E; + isa = PBXBuildFile; + settings = { + }; + }; + 3D3B99A704DBE3310056861E = { + fileRef = 3D3B99A504DBE3310056861E; + isa = PBXBuildFile; + settings = { + }; + }; + 3D3B99A804DBE4450056861E = { + fileEncoding = 30; + isa = PBXFileReference; + name = Notifications.m; + path = "/Users/witness/Programming/ResKnife/Cocoa/Plug-Ins/Notifications.m"; + refType = 0; + }; + 3D3B99A904DBE4450056861E = { + fileRef = 3D3B99A804DBE4450056861E; + isa = PBXBuildFile; + settings = { + }; + }; + }; + rootObject = 089C1669FE841209C02AAC07; +} diff --git a/ICONEditor/ICONWindowController.h b/ICONEditor/ICONWindowController.h new file mode 100644 index 0000000..22398d1 --- /dev/null +++ b/ICONEditor/ICONWindowController.h @@ -0,0 +1,45 @@ +/* ============================================================================= + PROJECT: ResKnife + FILE: ICONWindowController.h + + PURPOSE: This is the main class of our bitmap resource editor. Every + resource editor's main class implements the + ResKnifePluginProtocol. Every editor should implement + initWithResource:. Only implement initWithResources: if you feel + like writing a template editor. + + Note that your plugin is responsible for committing suicide + after its window has been closed. If you subclass it from + NSWindowController, the controller will take care of that + for you, according to a guy named Doug. + + AUTHORS: M. Uli Kusterer, witness(at)zathras.de, (c) 2003. + + REVISIONS: + 2003-07-31 UK Created. + ========================================================================== */ + +/* ----------------------------------------------------------------------------- + Headers: + -------------------------------------------------------------------------- */ + +#import +#import "ResKnifePluginProtocol.h" +#import "ResKnifeResourceProtocol.h" + + +/* ----------------------------------------------------------------------------- + Interface: + -------------------------------------------------------------------------- */ + +@interface ICONWindowController : NSWindowController +{ + IBOutlet NSImageView *imageView; + NSData *resData; + NSImage *resImage; + id resource; +} + +-(IBAction) imageViewChanged: (id)sender; + +@end diff --git a/ICONEditor/ICONWindowController.m b/ICONEditor/ICONWindowController.m new file mode 100644 index 0000000..39c2adc --- /dev/null +++ b/ICONEditor/ICONWindowController.m @@ -0,0 +1,177 @@ +/* ============================================================================= + PROJECT: ResKnife + FILE: ICONWindowController.h + + PURPOSE: This is the main class of our bitmap resource editor. Every + resource editor's main class implements the + ResKnifePluginProtocol. Every editor should implement + initWithResource:. Only implement initWithResources: if you feel + like writing a template editor. + + Note that your plugin is responsible for committing suicide + after its window has been closed. If you subclass it from + NSWindowController, the controller will take care of that + for you, according to a guy named Doug. + + AUTHORS: M. Uli Kusterer, witness(at)zathras.de, (c) 2003. + + REVISIONS: + 2003-07-31 UK Created. + ========================================================================== */ + +/* ----------------------------------------------------------------------------- + Headers: + -------------------------------------------------------------------------- */ + +#import "ICONWindowController.h" + + + +@implementation ICONWindowController + + +/* ----------------------------------------------------------------------------- + initWithResource: + This is it! This is the constructor. Create your window here and + do whatever else makes you happy. A new instance is created for each + resource. Note that you are responsible for keeping track of your + resource. + -------------------------------------------------------------------------- */ + +-(id) initWithResource: (id)newResource +{ + self = [self initWithWindowNibName:@"ICONWindow"]; + if( !self ) return nil; + + resource = [newResource retain]; + resData = nil; + resImage = nil; + + // load the window from the nib + [self window]; + return self; +} + + +/* ----------------------------------------------------------------------------- + * DESTRUCTOR + -------------------------------------------------------------------------- */ + +-(void) dealloc +{ + [resImage autorelease]; + [[NSNotificationCenter defaultCenter] removeObserver:self]; + [(id)resource autorelease]; + [resData release]; + [super dealloc]; +} + + +/* ----------------------------------------------------------------------------- + reloadResData: + Loads the resource's data into our NSImageView. + -------------------------------------------------------------------------- */ + +-(void) reloadResData +{ + unsigned char* planes[2] = { 0, 0 }; + NSBitmapImageRep* bir; + NSString* resType = [resource type]; + + [resImage autorelease]; + resImage = [[NSImage alloc] init]; + + resData = [[resource data] retain]; + planes[0] = (char*) [resData bytes]; + + if( [resType isEqualToString: @"ICN#"] ) + { + planes[1] = planes[0] + (4 * 32); // 32 lines a 4 bytes. + bir = [[[NSBitmapImageRep alloc] autorelease] initWithBitmapDataPlanes:planes pixelsWide:32 pixelsHigh:32 + bitsPerSample:1 samplesPerPixel:2 hasAlpha:YES isPlanar:YES colorSpaceName:NSCalibratedBlackColorSpace + bytesPerRow:4 bitsPerPixel:1]; + } + else if( [resType isEqualToString: @"ics#"] || [resType isEqualToString: @"CURS"] ) + { + planes[1] = planes[0] + (2 * 16); // 16 lines a 2 bytes. + bir = [[[NSBitmapImageRep alloc] autorelease] initWithBitmapDataPlanes:planes pixelsWide:16 pixelsHigh:16 + bitsPerSample:1 samplesPerPixel:2 hasAlpha:YES isPlanar:YES colorSpaceName:NSCalibratedBlackColorSpace + bytesPerRow:2 bitsPerPixel:1]; + } + else if( [resType isEqualToString: @"icm#"] ) + { + planes[1] = planes[0] + (2 * 12); // 12 lines a 2 bytes. + bir = [[[NSBitmapImageRep alloc] autorelease] initWithBitmapDataPlanes:planes pixelsWide:16 pixelsHigh:12 + bitsPerSample:1 samplesPerPixel:2 hasAlpha:YES isPlanar:YES colorSpaceName:NSCalibratedBlackColorSpace + bytesPerRow:2 bitsPerPixel:1]; + } + else + bir = [[[NSBitmapImageRep alloc] autorelease] initWithBitmapDataPlanes:planes pixelsWide:32 pixelsHigh:32 + bitsPerSample:1 samplesPerPixel:1 hasAlpha:NO isPlanar:NO colorSpaceName:NSCalibratedBlackColorSpace + bytesPerRow:4 bitsPerPixel:1]; + + [resImage addRepresentation:bir]; + [imageView setImage: resImage]; + + //[[self window] setContentSize:[resImage size]]; +} + + +/* ----------------------------------------------------------------------------- + windowDidLoad: + Our window is there, stuff the image in it. + -------------------------------------------------------------------------- */ + +-(void) windowDidLoad +{ + [super windowDidLoad]; + + // set the window's title + [[self window] setTitle:[resource nameForEditorWindow]]; + + [self reloadResData]; + + // 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]; + + // finally, show the window + [self showWindow:self]; +} + + +/* ----------------------------------------------------------------------------- + resourceDataDidChange: + Notification that someone changed our resource's data and we should + update our display. + -------------------------------------------------------------------------- */ + +- (void)resourceDataDidChange:(NSNotification *)notification +{ + // ensure it's our resource which got changed (should always be true, we don't register for notifications on other resource objects) + if( [notification object] == (id)resource ) + { + [self reloadResData]; + } +} + + +/* ----------------------------------------------------------------------------- + imageViewChanged: + The user changed our image view. Convert the image data to the proper + format and stash it in our resource. + -------------------------------------------------------------------------- */ + +-(IBAction) imageViewChanged: (id)sender +{ + NSArray* reps = [resImage representations]; + + NSLog( @"# %d", [reps count] ); + + [resImage lockFocusOnRepresentation: [reps objectAtIndex:0]]; + [[imageView image] dissolveToPoint: NSMakePoint(0,0) fraction:1]; + [resImage unlockFocus]; + + [imageView setImage: resImage]; +} + +@end diff --git a/ICONEditor/Info.plist b/ICONEditor/Info.plist new file mode 100644 index 0000000..902f1e2 --- /dev/null +++ b/ICONEditor/Info.plist @@ -0,0 +1,32 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + ICON Editor + CFBundleIconFile + + CFBundleIdentifier + com.ulikusterer.resknife.PICTEditor + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + BNDL + CFBundleSignature + ResK + CFBundleVersion + 1.0 + NSPrincipalClass + ICONWindowController + RKEditedTypes + + ICON + ICN# + icm# + ics# + CURS + + + diff --git a/ICONEditor/README.txt b/ICONEditor/README.txt new file mode 100644 index 0000000..79f2467 --- /dev/null +++ b/ICONEditor/README.txt @@ -0,0 +1,14 @@ +NOTES OF INTEREST: + +A ResKnife plugin declares the types it edits in its Info.plist-file. Just add +the key "RKEditedType" to the plist, which should be a string containing the +resource's type. If you want to have it edit several types, use "RKEditedTypes" +(note the "s" at the end) instead, which is an array of type strings. + +You can also specify "Hexadecimal Editor" instead of a type code if you +want to provide a replacement for the built-in Hex editor, or "Template +Editor" for replacing the template editor. Note that the template editor uses +a different entrypoint (initWithResources:) than the other editors. + +Apart from that, this is a standard Cocoa plugin. + diff --git a/ICONEditor/version.plist b/ICONEditor/version.plist new file mode 100644 index 0000000..1740ba7 --- /dev/null +++ b/ICONEditor/version.plist @@ -0,0 +1,16 @@ + + + + + BuildVersion + 1 + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1.0 + ProjectName + DevToolsWizardTemplates + SourceVersion + 2260100 + +