Support for plug-in editors added.

This commit is contained in:
Nicholas Shanks 2002-02-02 11:31:28 +00:00
parent 49bbbf24fb
commit 5c6b25570d
31 changed files with 938 additions and 129 deletions

View File

@ -1057,7 +1057,7 @@ OSStatus ShowAboutBox( void )
#endif
#else
WindowRef window = null;
if( g.useAppearance && g.systemVersion >= kMacOSEight )
if( g.useAppearance && g.systemVersion >= kMacOS8 )
window = GetNewCWindow( kFileWindow8, null, kFirstWindowOfClass );
else
window = GetNewCWindow( kFileWindow7, null, kFirstWindowOfClass );

View File

@ -356,9 +356,9 @@ pascal Boolean SortDataBrowser( ControlRef browser, DataBrowserItemID itemOne, D
}
/*** DATA BROWSER MESSAGE ***/
pascal void DataBrowserMessage( ControlRef browser, DataBrowserItemID itemID, DataBrowserItemNotification message, DataBrowserItemDataRef itemData )
pascal void DataBrowserMessage( ControlRef browser, DataBrowserItemID itemID, DataBrowserItemNotification message/*, DataBrowserItemDataRef itemData*/ )
{
#pragma unused( itemID, itemData )
#pragma unused( itemID/*, itemData*/ )
FileWindowPtr file = (FileWindowPtr) GetControlReference( browser );
switch( message )
{

View File

@ -52,7 +52,7 @@ pascal Boolean SortDataBrowser( ControlRef browser, DataBrowserItemID itemOne, D
* @function DataBrowserMessage
* @discussion DataBrowser callback.
*/
pascal void DataBrowserMessage( ControlRef browser, DataBrowserItemID itemID, DataBrowserItemNotification message, DataBrowserItemDataRef itemData );
pascal void DataBrowserMessage( ControlRef browser, DataBrowserItemID itemID, DataBrowserItemNotification message/*, DataBrowserItemDataRef itemData*/ );
/*!
* @function DataBrowserAddDragItem
* @discussion DataBrowser callback.

View File

@ -39,15 +39,18 @@ FileWindow::FileWindow( FSSpecPtr spec )
#elif TARGET_API_MAC_CARBON
// create window
Rect creationBounds;
Rect creationBounds, sectRect;
SetRect( &creationBounds, 0, 0, kDefaultFileWindowWidth, kDefaultFileWindowHeight );
OffsetRect( &creationBounds, 10, 48 );
GetAvailableWindowPositioningBounds( GetMainDevice(), &sectRect );
InsetRect( &sectRect, 0, 10 );
SectRect( &sectRect, &creationBounds, &creationBounds );
OffsetRect( &creationBounds, 10, 0 );
WindowAttributes attributes = kWindowStandardDocumentAttributes | kWindowStandardHandlerAttribute | kWindowInWindowMenuAttribute;
if( g.systemVersion >= kMacOSX ) attributes |= kWindowLiveResizeAttribute;
error = CreateNewWindow( kDocumentWindowClass, attributes, &creationBounds, &window );
if( error ) return;
#else
if( g.useAppearance && g.systemVersion >= kMacOSEight )
if( g.useAppearance && g.systemVersion >= kMacOS8 )
{
window = GetNewCWindow( kFileWindow8, null, kFirstWindowOfClass );
themeSavvy = true;
@ -596,7 +599,7 @@ OSStatus FileWindow::BoundsChanged( EventRef event )
SizeControl( horizScroll, windowBounds.right - (kScrollBarWidth -3), kScrollBarWidth );
MoveControl( vertScroll, windowBounds.right - (kScrollBarWidth -1), kFileWindowHeaderHeight );
SizeControl( vertScroll, kScrollBarWidth, windowBounds.bottom - kFileWindowHeaderHeight - (kScrollBarWidth -2) );
if( themeSavvy && g.systemVersion >= kMacOSEightPointFive )
if( themeSavvy && g.systemVersion >= kMacOS85 )
{
SetControlViewSize( horizScroll, nameColumnWidth + kFileWindowAllOtherColumnWidths );
SetControlViewSize( vertScroll, windowBounds.bottom - (kScrollBarWidth -1) - kFileWindowHeaderHeight );

View File

@ -1,5 +1,7 @@
#if !TARGET_API_MAC_OS8
#include <Carbon/Carbon.h>
#if !defined(__MWERKS__) // compiling with ProjectBuilder
#include <Carbon/Carbon.h>
#endif
#endif
#ifndef _ResKnife_HostCallbacks_

View File

@ -105,7 +105,7 @@ InspectorWindow::InspectorWindow( void )
EmbedControl( purgeableBox, group );
EmbedControl( sysHeapBox, group );
#else
if( g.useAppearance && g.systemVersion >= kMacOSEight )
if( g.useAppearance && g.systemVersion >= kMacOS8 )
window = GetNewCWindow( kFileWindow8, null, kFirstWindowOfClass );
else
window = GetNewCWindow( kFileWindow7, null, kFirstWindowOfClass );

View File

@ -37,7 +37,7 @@ PickerWindow::PickerWindow( FileWindowPtr ownerFile, ResType resType ) : PlugWin
SetRect( &creationBounds, 9, 45, 256 +9, 256 +45 );
error = CreateNewWindow( kDocumentWindowClass, kWindowStandardDocumentAttributes | kWindowStandardHandlerAttribute, &creationBounds, &window );
#else
if( g.useAppearance && g.systemVersion >= kMacOSEight )
if( g.useAppearance && g.systemVersion >= kMacOS8 )
{
window = GetNewCWindow( kFileWindow8, null, kFirstWindowOfClass );
themeSavvy = true;

View File

@ -116,7 +116,7 @@ void AppendPString( Str255 original, ConstStr255Param added )
void MenuItemEnable( MenuRef menu, MenuItemIndex item, Boolean enable )
{
#if !TARGET_API_MAC_CARBON
if( g.systemVersion >= kMacOSEightPointFive )
if( g.systemVersion >= kMacOS85 )
{
#endif
if( enable ) EnableMenuItem( menu, item );

View File

@ -1,4 +1,6 @@
#include "WindowObject.h"
#include "string.h"
/*** CONSTRUCTOR ***/
WindowObject::WindowObject( void )

View File

@ -29,7 +29,7 @@ With thanks to: For:
// compile options
#if TARGET_API_MAC_CARBON
#define USE_NIBS 0 // toggle this
#define USE_NIBS 1 // toggle this
#else
#define USE_NIBS 0 // leave this set to zero
#endif

View File

@ -1 +1,81 @@
#include "MacTypes.r" /*** CARBON RESOURCES ***/ data 'carb' ( 0 ) { $"00000000" }; data 'plst' ( 0 ) { "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" "<!DOCTYPE plist SYSTEM \"file://localhost/System/Library/DTDs/PropertyList.dtd\">\n" "<plist version=\"0.9\">\n" "<dict>\n" " <key>CFBundleDevelopmentRegion</key>\n" " <string>English</string>\n" " <key>CFBundleDocumentTypes</key>\n" " <array>\n" " <dict>\n" " <key>CFBundleTypeExtensions</key>\n" " <array>\n" " <string>rsrc</string>\n" " </array>\n" " <key>CFBundleTypeIconFile</key>\n" " <string>129</string>\n" " <key>CFBundleTypeName</key>\n" " <string>Resource file</string>\n" " <key>CFBundleTypeOSTypes</key>\n" " <array>\n" " <string>rsrc</string>\n" " <string>RSRC</string>\n" " </array>\n" " <key>CFBundleTypeRole</key>\n" " <string>Editor</string>\n" " </dict>\n" " <dict>\n" " <key>CFBundleTypeExtensions</key>\n" " <array>\n" " <string>icns</string>\n" " </array>\n" " <key>CFBundleTypeIconFile</key>\n" " <string>129</string>\n" " <key>CFBundleTypeName</key>\n" " <string>Icon file</string>\n" " <key>CFBundleTypeOSTypes</key>\n" " <array>\n" " <string>icns</string>\n" " </array>\n" " <key>CFBundleTypeRole</key>\n" " <string>Editor</string>\n" " </dict>\n" " </array>\n" " <key>CFBundleExecutable</key>\n" " <string>ResKnife (Carbon)</string>\n" " <key>CFBundleGetInfoString</key>\n" " <string>A resource editor for Mac OS X</string>\n" " <key>CFBundleIconFile</key>\n" " <string>128</string>\n" " <key>CFBundleIdentifier</key>\n" " <string>com.nickshanks.resknife</string>\n" " <key>CFBundleInfoDictionaryVersion</key>\n" " <string>6.0</string>\n" " <key>CFBundleName</key>\n" " <string>ResKnife</string>\n" " <key>CFBundlePackageType</key>\n" " <string>APPL</string>\n" " <key>CFBundleShortVersionString</key>\n" " <string>Development version 0.4d1</string>\n" " <key>CFBundleSignature</key>\n" " <string>ResK</string>\n" " <key>CFBundleVersion</key>\n" " <string>0.4d1</string>\n" " <key>CSResourcesFileMapped</key>\n" " <true/>\n" "</dict>\n" "</plist>" };
#if defined(__MWERKS__) // compiling with CodeWarrior
#include "MacTypes.r"
#else
#include <Carbon/Carbon.r>
#endif
/*** CARBON RESOURCES ***/
data 'carb' ( 0 )
{
$"00000000"
};
data 'plst' ( 0 )
{
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
"<!DOCTYPE plist SYSTEM \"file://localhost/System/Library/DTDs/PropertyList.dtd\">\n"
"<plist version=\"0.9\">\n"
"<dict>\n"
" <key>CFBundleDevelopmentRegion</key>\n"
" <string>English</string>\n"
" <key>CFBundleDocumentTypes</key>\n"
" <array>\n"
" <dict>\n"
" <key>CFBundleTypeExtensions</key>\n"
" <array>\n"
" <string>rsrc</string>\n"
" </array>\n"
" <key>CFBundleTypeIconFile</key>\n"
" <string>129</string>\n"
" <key>CFBundleTypeName</key>\n"
" <string>Resource file</string>\n"
" <key>CFBundleTypeOSTypes</key>\n"
" <array>\n"
" <string>rsrc</string>\n"
" <string>RSRC</string>\n"
" </array>\n"
" <key>CFBundleTypeRole</key>\n"
" <string>Editor</string>\n"
" </dict>\n"
" <dict>\n"
" <key>CFBundleTypeExtensions</key>\n"
" <array>\n"
" <string>icns</string>\n"
" </array>\n"
" <key>CFBundleTypeIconFile</key>\n"
" <string>129</string>\n"
" <key>CFBundleTypeName</key>\n"
" <string>Icon file</string>\n"
" <key>CFBundleTypeOSTypes</key>\n"
" <array>\n"
" <string>icns</string>\n"
" </array>\n"
" <key>CFBundleTypeRole</key>\n"
" <string>Editor</string>\n"
" </dict>\n"
" </array>\n"
" <key>CFBundleExecutable</key>\n"
" <string>ResKnife (Carbon)</string>\n"
" <key>CFBundleGetInfoString</key>\n"
" <string>A resource editor for Mac OS X</string>\n"
" <key>CFBundleIconFile</key>\n"
" <string>128</string>\n"
" <key>CFBundleIdentifier</key>\n"
" <string>com.nickshanks.resknife</string>\n"
" <key>CFBundleInfoDictionaryVersion</key>\n"
" <string>6.0</string>\n"
" <key>CFBundleName</key>\n"
" <string>ResKnife</string>\n"
" <key>CFBundlePackageType</key>\n"
" <string>APPL</string>\n"
" <key>CFBundleShortVersionString</key>\n"
" <string>Development version 0.4d1</string>\n"
" <key>CFBundleSignature</key>\n"
" <string>ResK</string>\n"
" <key>CFBundleVersion</key>\n"
" <string>0.4d1</string>\n"
" <key>CSResourcesFileMapped</key>\n"
" <true/>\n"
"</dict>\n"
"</plist>"
};

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 147 KiB

After

Width:  |  Height:  |  Size: 0 B

View File

@ -4,6 +4,7 @@
{
}
- (IBAction)showAbout:(id)sender;
- (IBAction)showInfo:(id)sender;
- (IBAction)showPrefs:(id)sender;
- (IBAction)showCreateResourceSheet:(id)sender;

View File

@ -1,8 +1,11 @@
#import "ApplicationDelegate.h"
#import "InfoWindowController.h"
#import "PrefsWindowController.h"
#import "ResourceDataSource.h"
#import "CreateResourceSheetController.h"
#import "ResourceDocument.h"
#import "ResourceDataSource.h"
#import "ResknifePluginProtocol.h"
@implementation ApplicationDelegate
@ -22,6 +25,12 @@
[self initUserDefaults];
}
- (IBAction)showAbout:(id)sender
{
[NSApp orderFrontStandardAboutPanel:sender];
// get about box code from http://cocoadevcentral.com/tutorials/showpage.php?show=00000041.php
}
- (IBAction)showInfo:(id)sender
{
[[InfoWindowController sharedInfoWindowController] showWindow:sender];
@ -34,17 +43,24 @@
- (IBAction)showCreateResourceSheet:(id)sender
{
// bug: requires ALL main window's delegates to have 'dataSource' declared,
// would be better to use a resourceDocument variable which could point to self for document windows.
return [[[[[NSApp mainWindow] delegate] dataSource] createResourceSheetController] showCreateResourceSheet:sender];
// requires ALL main windows' controllers (even plugs) to have their document set correctly
NSDocument *document = [[[NSApp mainWindow] windowController] document];
return [[[(ResourceDocument *)document dataSource] createResourceSheetController] showCreateResourceSheet:document];
}
- (IBAction)openResource:(id)sender
{
// [NSBundle loadNibNamed:@"HexWindow" owner:self];
//- (NSString *)pathForAuxiliaryExecutable:(NSString *)executableName;
// [[NSBundle bundleWithIdentifier:@"com.nickshanks.resknife.hexadecimal"] load];
[[NSBundle bundleWithPath:[[[NSBundle mainBundle] builtInPlugInsPath] stringByAppendingPathComponent:@"HexEditor.plugin"]] load];
// bug: only opens the hex editor!
// NSBundle *hexEditor = [NSBundle bundleWithIdentifier:@"com.nickshanks.resknife.hexadecimal"];
// NSBundle *hexEditor = [NSBundle bundleWithPath:[[[NSBundle mainBundle] builtInPlugInsPath] stringByAppendingPathComponent:@"Hexadecimal Editor.plugin"]];
NSBundle *hexEditor = [NSBundle bundleWithPath:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Hexadecimal Editor.bundle"]];
// [hexEditor load];
// bug: possible lack of necessary retains here, esp. resource - should the plug retain it?
ResourceDocument *resDocument = (ResourceDocument *) [[[NSApp mainWindow] windowController] document];
Resource *resource = [[resDocument outlineView] itemAtRow:[[resDocument outlineView] selectedRow]];
// bug: I alloc a plug instance here, but have no idea where it gets dealloc'd
id hexWindow = [[[hexEditor principalClass] alloc] initWithResource:resource];
}
- (IBAction)playSound:(id)sender

View File

@ -8,34 +8,49 @@
BOOL addComma = NO;
short attributes = [obj shortValue];
NSMutableString *string = [NSMutableString string];
// there's probably a smarter, bitwise, way to do this
short attributeCount = 0;
if( attributes & resPreload ) attributeCount++;
if( attributes & resProtected ) attributeCount++;
if( attributes & resLocked ) attributeCount++;
if( attributes & resPurgeable ) attributeCount++;
if( attributes & resSysHeap ) attributeCount++;
// create string
if( attributes & resPreload )
{
if( addComma ) [string appendString:@", "];
[string appendString:@"Preload"];
if( addComma ) [string appendString:@", "];
if( attributeCount > 2 ) [string appendString:@"Pre"];
else [string appendString:@"Preload"];
addComma = YES;
}
if( attributes & resProtected )
{
if( addComma ) [string appendString:@", "];
[string appendString:@"Protected"];
if( addComma ) [string appendString:@", "];
if( attributeCount > 2 ) [string appendString:@"Pro"];
else [string appendString:@"Protected"];
addComma = YES;
}
if( attributes & resLocked )
{
if( addComma ) [string appendString:@", "];
[string appendString:@"Locked"];
if( addComma ) [string appendString:@", "];
if( attributeCount > 2 ) [string appendString:@"L"];
else [string appendString:@"Locked"];
addComma = YES;
}
if( attributes & resPurgeable )
{
if( addComma ) [string appendString:@", "];
[string appendString:@"Purgeable"];
if( addComma ) [string appendString:@", "];
if( attributeCount > 2 ) [string appendString:@"Pur"];
else [string appendString:@"Purgeable"];
addComma = YES;
}
if( attributes & resSysHeap )
{
if( addComma ) [string appendString:@", "];
[string appendString:@"SysHeap"];
if( addComma ) [string appendString:@", "];
if( attributeCount > 2 ) [string appendString:@"Sys"];
else [string appendString:@"SysHeap"];
addComma = YES;
}
return string;

View File

@ -8,6 +8,7 @@
if( ![obj isKindOfClass:[NSString class]] ) return nil;
if( [obj isEqualToString:@""] )
{
// bug: the NO should be some kind of 'icns' resource type identification
if( NO ) return NSLocalizedString( @"Custom Icon", nil );
else return NSLocalizedString( @"Untitled Resource", nil );
}

View File

@ -27,6 +27,7 @@
- (IBAction)acceptPrefs:(id)sender
{
// bug: hey! where's NSValue's boolValue method? I have to use "intValue? YES:NO" :(
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
BOOL preserveBackups = [[dataProtectionMatrix cellAtRow:preserveBackupsBox column:0] intValue]? YES:NO;
BOOL autosave = [[dataProtectionMatrix cellAtRow:autosaveBox column:0] intValue]? YES:NO;
@ -37,7 +38,7 @@
[[self window] orderOut:nil];
// now save the data to the defaults file
[defaults setBool:preserveBackups forKey:@"PreserveBackups"]; // bug: this put 1 or 0 into the defaults file rather than YES or NO
[defaults setBool:preserveBackups forKey:@"PreserveBackups"]; // bug: this puts 1 or 0 into the defaults file rather than YES or NO
[defaults setBool:autosave forKey:@"Autosave"];
[defaults setInteger:autosaveInterval forKey:@"AutosaveInterval"];
[defaults setBool:deleteResourceWarning forKey:@"DeleteResourceWarning"];
@ -72,7 +73,7 @@
int autosaveInterval = [[defaultsPlist objectForKey:@"AutosaveInterval"] intValue];
BOOL deleteResourceWarning = [[defaultsPlist objectForKey:@"DeleteResourceWarning"] intValue]? YES:NO;
// note that this function does notmodify the user defaults - the user still has to accept or cancel the panel
// note that this function does not modify the user defaults - the user still has to accept or cancel the panel
[[dataProtectionMatrix cellAtRow:preserveBackupsBox column:0] setState:preserveBackups];
[[dataProtectionMatrix cellAtRow:autosaveBox column:0] setState:autosave];
[autosaveIntervalField setStringValue:[NSString stringWithFormat:@"%d", autosaveInterval]];

View File

@ -1,9 +1,11 @@
#import <Foundation/Foundation.h>
#import "ResKnifeResourceProtocol.h"
extern NSString *ResourceChangedNotification;
@interface Resource : NSObject
@interface Resource : NSObject <ResKnifeResourceProtocol>
{
@private
// resource information
NSString *name;
NSString *type;

View File

@ -32,7 +32,7 @@ NSString *ResourceChangedNotification = @"ResourceChangedNotification";
[name autorelease];
name = [newName copy];
[[NSNotificationCenter defaultCenter] postNotificationName:ResourceChangedNotification object:self];
// NSLog( @"%@ posted beacause name changed to %@", ResourceChangedNotification, name );
// NSLog( @"%@ posted because name changed to %@", ResourceChangedNotification, name );
}
- (NSString *)type
@ -45,7 +45,7 @@ NSString *ResourceChangedNotification = @"ResourceChangedNotification";
[type autorelease];
type = [newType copy];
[[NSNotificationCenter defaultCenter] postNotificationName:ResourceChangedNotification object:self];
// NSLog( @"%@ posted beacause type changed to %@", ResourceChangedNotification, type );
// NSLog( @"%@ posted because type changed to %@", ResourceChangedNotification, type );
}
- (NSNumber *)resID
@ -58,7 +58,7 @@ NSString *ResourceChangedNotification = @"ResourceChangedNotification";
[resID autorelease];
resID = [newResID copy];
[[NSNotificationCenter defaultCenter] postNotificationName:ResourceChangedNotification object:self];
// NSLog( @"%@ posted beacause res ID changed to %@", ResourceChangedNotification, [resID stringValue] );
// NSLog( @"%@ posted because res ID changed to %@", ResourceChangedNotification, [resID stringValue] );
}
- (NSNumber *)size
@ -71,7 +71,7 @@ NSString *ResourceChangedNotification = @"ResourceChangedNotification";
[size autorelease];
size = [newSize copy];
[[NSNotificationCenter defaultCenter] postNotificationName:ResourceChangedNotification object:self];
// NSLog( @"%@ posted beacause size changed to %@", ResourceChangedNotification, [size stringValue] );
// NSLog( @"%@ posted because size changed to %@", ResourceChangedNotification, [size stringValue] );
}
- (NSNumber *)attributes
@ -84,7 +84,7 @@ NSString *ResourceChangedNotification = @"ResourceChangedNotification";
[attributes autorelease];
attributes = [newAttributes copy];
[[NSNotificationCenter defaultCenter] postNotificationName:ResourceChangedNotification object:self];
// NSLog( @"%@ posted beacause attributes changed to %@", ResourceChangedNotification, [attributes stringValue] );
// NSLog( @"%@ posted because attributes changed to %@", ResourceChangedNotification, [attributes stringValue] );
}
- (BOOL)dirty
@ -96,7 +96,7 @@ NSString *ResourceChangedNotification = @"ResourceChangedNotification";
{
dirty = newValue;
[[NSNotificationCenter defaultCenter] postNotificationName:ResourceChangedNotification object:self];
// NSLog( @"%@ posted beacause resource became %@", ResourceChangedNotification, dirty? @"dirty":@"clean" );
// NSLog( @"%@ posted because resource became %@", ResourceChangedNotification, dirty? @"dirty":@"clean" );
}
- (NSData *)data
@ -109,7 +109,7 @@ NSString *ResourceChangedNotification = @"ResourceChangedNotification";
[data autorelease];
data = [newData retain];
[[NSNotificationCenter defaultCenter] postNotificationName:ResourceChangedNotification object:self];
// NSLog( @"%@ posted beacause data changed", ResourceChangedNotification );
// NSLog( @"%@ posted because data changed", ResourceChangedNotification );
}
- (id)initWithType:(NSString *)typeValue andID:(NSNumber *)resIDValue
@ -126,7 +126,7 @@ NSString *ResourceChangedNotification = @"ResourceChangedNotification";
- (id)initWithType:(NSString *)typeValue andID:(NSNumber *)resIDValue withName:(NSString *)nameValue andAttributes:(NSNumber *)attributesValue data:(NSData *)dataValue ofLength:(NSNumber *)sizeValue
{
[super init];
self = [super init];
[self setName:nameValue];
[self setType:typeValue];
[self setResID:resIDValue];
@ -138,17 +138,20 @@ NSString *ResourceChangedNotification = @"ResourceChangedNotification";
+ (id)resourceOfType:(NSString *)typeValue andID:(NSNumber *)resIDValue
{
return [[Resource allocWithZone:[self zone]] initWithType:typeValue andID:resIDValue];
Resource *resource = [[Resource allocWithZone:[self zone]] initWithType:typeValue andID:resIDValue];
return [resource autorelease];
}
+ (id)resourceOfType:(NSString *)typeValue andID:(NSNumber *)resIDValue withName:(NSString *)nameValue andAttributes:(NSNumber *)attributesValue
{
return [[Resource allocWithZone:[self zone]] initWithType:typeValue andID:resIDValue withName:nameValue andAttributes:attributesValue];
Resource *resource = [[Resource allocWithZone:[self zone]] initWithType:typeValue andID:resIDValue withName:nameValue andAttributes:attributesValue];
return [resource autorelease];
}
+ (id)resourceOfType:(NSString *)typeValue andID:(NSNumber *)resIDValue withName:(NSString *)nameValue andAttributes:(NSNumber *)attributesValue data:(NSData *)dataValue ofLength:(NSNumber *)sizeValue
{
return [[Resource allocWithZone:[self zone]] initWithType:typeValue andID:resIDValue withName:nameValue andAttributes:attributesValue data:dataValue ofLength:sizeValue];
Resource *resource = [[Resource allocWithZone:[self zone]] initWithType:typeValue andID:resIDValue withName:nameValue andAttributes:attributesValue data:dataValue ofLength:sizeValue];
return [resource autorelease];
}

View File

@ -16,7 +16,6 @@
- (NSWindow *)window;
- (NSArray *)resources;
- (void)setResources:(NSMutableArray *)newResources;
- (void)addResource:(Resource *)resource;
- (void)generateTestData;

View File

@ -6,7 +6,7 @@
- (id)init
{
self = [super init];
resources = [NSMutableArray array];
resources = [[NSMutableArray alloc] init];
otherFork = nil;
return self;
}
@ -26,10 +26,11 @@
return @"ResourceDocument";
}
- (void)windowControllerDidLoadNib:(NSWindowController *) aController
- (void)windowControllerDidLoadNib:(NSWindowController *)controller
{
[super windowControllerDidLoadNib:aController];
[super windowControllerDidLoadNib:controller];
// Add any code here that need to be executed once the windowController has loaded the document's window.
// [controller setDocumet:self];
[dataSource setResources:resources];
}
@ -93,11 +94,6 @@
return succeeded;
}
- (BOOL)readFromURL:(NSURL *)url ofType:(NSString *)type
{
return NO;
}
- (BOOL)readResourceMap:(SInt16)fileRefNum
{
OSStatus error = noErr;
@ -131,7 +127,7 @@
attrsShort = GetResAttrs( resourceHandle );
HLockHi( resourceHandle );
// create the resource & add it to the array (am I leaking huge amounts of memory here, or are they dealloced automatically?)
// create the resource & add it to the array
{
NSString *name = [NSString stringWithCString:&nameStr[1] length:nameStr[0]];
NSString *type = [NSString stringWithCString:(char *) &resType length:4];
@ -140,8 +136,7 @@
NSNumber *attributes = [NSNumber numberWithShort:attrsShort];
NSData *data = [NSData dataWithBytes:*resourceHandle length:sizeLong];
Resource *resource = [Resource resourceOfType:type andID:resID withName:name andAttributes:attributes data:data ofLength:size];
[resources addObject:resource];
[resource autorelease];
[resources addObject:resource]; // array retains resource
}
HUnlock( resourceHandle );
@ -192,11 +187,6 @@
return succeeded;
}
- (BOOL)writeToURL:(NSURL *)url ofType:(NSString *)type
{
return NO;
}
- (BOOL)writeResourceMap:(SInt16)fileRefNum
{
OSStatus error = noErr;
@ -227,11 +217,12 @@
AddResource( resourceHandle, resType, resIDShort, nameStr );
if( ResError() == addResFailed )
{
NSLog( @"Saving failed; could not add resource \"%@\" of type %@ to file.", [resource name], [resource type] );
NSLog( @"*Saving failed*; could not add resource \"%@\" of type %@ to file.", [resource name], [resource type] );
error = addResFailed;
}
else
{
NSLog( @"Added resource %@, \"%@\", of type %@ to file.", [resource resID], [resource name], [resource type] );
SetResAttrs( resourceHandle, attrsShort );
ChangedResource( resourceHandle );
UpdateResFile( fileRefNum );

View File

@ -2,15 +2,19 @@
<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
<plist version="0.9">
<dict>
<key>IBUserGuides</key>
<dict>
<key>AboutPanel</key>
<dict>
<key>guideLocations</key>
<array/>
<key>guidesLocked</key>
<string>NO</string>
</dict>
</dict>
<key>IBDocumentLocation</key>
<string>109 310 356 240 0 0 1280 1002 </string>
<key>IBFramework Version</key>
<string>248.0</string>
<key>IBLockedObjects</key>
<array>
<integer>25</integer>
</array>
<key>IBOpenObjects</key>
<array>
<integer>23</integer>
</array>
<key>IBSystem Version</key>
<string>5P48</string>
</dict>
</plist>

Binary file not shown.

View File

@ -16,6 +16,7 @@
ACTIONS = {
openResource = id;
playSound = id;
showAbout = id;
showCreateResourceSheet = id;
showInfo = id;
showPrefs = id;

View File

@ -3,10 +3,19 @@
<plist version="0.9">
<dict>
<key>IBDocumentLocation</key>
<string>156 127 432 426 0 74 1280 928 </string>
<key>IBMainMenuLocation</key>
<string>205 655 347 44 0 74 1280 928 </string>
<key>IBUserGuides</key>
<dict/>
<string>260 559 432 426 0 0 1280 1002 </string>
<key>IBEditorPositions</key>
<dict>
<key>29</key>
<string>156 558 347 44 0 0 1280 1002 </string>
</dict>
<key>IBFramework Version</key>
<string>248.0</string>
<key>IBOpenObjects</key>
<array>
<integer>29</integer>
</array>
<key>IBSystem Version</key>
<string>5P48</string>
</dict>
</plist>

Binary file not shown.

View File

@ -4,8 +4,10 @@
<dict>
<key>IBDocumentLocation</key>
<string>14 132 480 547 0 74 1280 928 </string>
<key>IBMainMenuLocation</key>
<string>52 694 73 138 0 74 1280 928 </string>
<key>IBFramework Version</key>
<string>248.0</string>
<key>IBSystem Version</key>
<string>5P48</string>
<key>IBUserGuides</key>
<dict>
<key>CreateResourceSheet</key>

View File

@ -1 +1,10 @@
// include file #define CALL_NOT_IN_CARBON 0 #define TARGET_API_MAC_OS8 1 #define TARGET_API_MAC_CARBON 1 #define TARGET_API_MAC_OSX 0 #define OPAQUE_UPP_TYPES 1 #define OPAQUE_TOOLBOX_STRUCTS 1 #define ACCESSOR_CALLS_ARE_FUNCTIONS 1 #include <Carbon.h>
// include file
#define CALL_NOT_IN_CARBON 0
#define TARGET_API_MAC_OS8 0
#define TARGET_API_MAC_CARBON 1
#define TARGET_API_MAC_OSX 0
#define OPAQUE_UPP_TYPES 1
#define OPAQUE_TOOLBOX_STRUCTS 1
#define ACCESSOR_CALLS_ARE_FUNCTIONS 1
#include <Carbon.h>

View File

@ -3,8 +3,50 @@
archiveVersion = 1;
classes = {
};
objectVersion = 32;
objectVersion = 34;
objects = {
F53B5F3001C97EFB01A8010C = {
fileRef = F5B588210156D40B01000001;
isa = PBXBuildFile;
settings = {
};
};
F53B5F3101C97EFB01A8010C = {
fileRef = F5B5881D0156D40B01000001;
isa = PBXBuildFile;
settings = {
};
};
F53B5F3201C984F301A8010C = {
fileRef = F5B5884A0156D40B01000001;
isa = PBXBuildFile;
settings = {
};
};
F5502C3301C5586301C57124 = {
fileRef = F5B5884B0156D40B01000001;
isa = PBXBuildFile;
settings = {
};
};
F5502C3401C5588601C57124 = {
fileRef = F57CEE0D0189C95101A8010B;
isa = PBXBuildFile;
settings = {
};
};
F5502C4001C579FF01C57124 = {
isa = PBXFileReference;
name = ResKnifePluginProtocol.h;
path = "PlugIns/ResKnifePluginProtocol.h";
refType = 4;
};
F5502C4101C579FF01C57124 = {
fileRef = F5502C4001C579FF01C57124;
isa = PBXBuildFile;
settings = {
};
};
F5730B930159528A01000001 = {
isa = PBXFileReference;
path = defaults.plist;
@ -16,6 +58,216 @@
settings = {
};
};
F57CEE0B0189C95101A8010B = {
children = (
F5502C4001C579FF01C57124,
F5CDEBAB01FC893201A80001,
F57CEE0C0189C95101A8010B,
);
isa = PBXGroup;
name = "Plug-Ins";
refType = 4;
};
F57CEE0C0189C95101A8010B = {
children = (
F5CDEBA101FBD4E001A80001,
F5CDEBA201FBD4E001A80001,
F5CDEB9D01FB7C8601A80001,
F5CDEB9E01FB7C8601A80001,
F59CEE9E01A28CA001A8010B,
F59CEE9F01A28CA001A8010B,
F59CEEA201A28D4201A8010B,
F59CEEA301A28D4201A8010B,
F57CEE180189CE8801A8010B,
F5CDEBA901FC86CA01A80001,
);
isa = PBXGroup;
name = "Hex Editor";
refType = 4;
};
F57CEE0D0189C95101A8010B = {
isa = PBXBundleReference;
path = "Hexadecimal Editor.bundle";
refType = 3;
};
F57CEE0E0189C95101A8010B = {
buildPhases = (
F57CEE0F0189C95101A8010B,
F57CEE100189C95101A8010B,
F57CEE110189C95101A8010B,
F57CEE120189C95101A8010B,
F57CEE130189C95101A8010B,
);
buildSettings = {
OTHER_CFLAGS = "";
OTHER_LDFLAGS = "-bundle -undefined error";
OTHER_REZFLAGS = "";
PRODUCT_NAME = "Hexadecimal Editor";
SECTORDER_FLAGS = "";
WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas";
WRAPPER_EXTENSION = bundle;
};
dependencies = (
);
isa = PBXBundleTarget;
name = "Hex Editor Cocoa";
productName = "Hex Editor Cocoa";
productReference = F57CEE0D0189C95101A8010B;
productSettingsXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<!DOCTYPE plist SYSTEM \"file://localhost/System/Library/DTDs/PropertyList.dtd\">
<plist version=\"0.9\">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>Hexadecimal Editor</string>
<key>CFBundleGetInfoString</key>
<string></string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>com.nickshanks.resknife.hexadecimal</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string></string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string></string>
<key>CFBundleSignature</key>
<string>ResK</string>
<key>CFBundleVersion</key>
<string>0.0.1d1</string>
<key>NSMainNibFile</key>
<string>HexWindow</string>
<key>NSPrincipalClass</key>
<string>HexWindowController</string>
</dict>
</plist>
";
shouldUseHeadermap = 0;
};
F57CEE0F0189C95101A8010B = {
buildActionMask = 2147483647;
files = (
F59CEEA001A28CA101A8010B,
F59CEEA401A28D4301A8010B,
F5CDEBA301FBD4E101A80001,
F5CDEBAD01FC893301A80001,
F5CDEBAE01FC90AD01A80001,
F583B47802083A0A01A80001,
);
isa = PBXHeadersBuildPhase;
name = Headers;
};
F57CEE100189C95101A8010B = {
buildActionMask = 2147483647;
files = (
F57CEE190189CE8901A8010B,
F5CDEBAA01FC86CB01A80001,
);
isa = PBXResourcesBuildPhase;
name = "Bundle Resources";
};
F57CEE110189C95101A8010B = {
buildActionMask = 2147483647;
files = (
F59CEEA101A28CA101A8010B,
F59CEEA501A28D4301A8010B,
F5CDEBA401FBD4E101A80001,
F583B47902083A0A01A80001,
);
isa = PBXSourcesBuildPhase;
name = Sources;
};
F57CEE120189C95101A8010B = {
buildActionMask = 2147483647;
files = (
F5502C3301C5586301C57124,
);
isa = PBXFrameworksBuildPhase;
name = "Frameworks & Libraries";
};
F57CEE130189C95101A8010B = {
buildActionMask = 2147483647;
files = (
);
isa = PBXRezBuildPhase;
name = "ResourceManager Resources";
};
F57CEE180189CE8801A8010B = {
isa = PBXFileReference;
name = HexWindow.nib;
path = "Cocoa/PlugIns/Hex Editor/HexWindow.nib";
refType = 2;
};
F57CEE190189CE8901A8010B = {
fileRef = F57CEE180189CE8801A8010B;
isa = PBXBuildFile;
settings = {
};
};
F583B47802083A0A01A80001 = {
fileRef = F5CDEB9D01FB7C8601A80001;
isa = PBXBuildFile;
settings = {
};
};
F583B47902083A0A01A80001 = {
fileRef = F5CDEB9E01FB7C8601A80001;
isa = PBXBuildFile;
settings = {
};
};
F59CEE9E01A28CA001A8010B = {
isa = PBXFileReference;
name = HexWindow.h;
path = "PlugIns/Hex Editor/HexWindow.h";
refType = 4;
};
F59CEE9F01A28CA001A8010B = {
isa = PBXFileReference;
name = HexWindow.m;
path = "PlugIns/Hex Editor/HexWindow.m";
refType = 4;
};
F59CEEA001A28CA101A8010B = {
fileRef = F59CEE9E01A28CA001A8010B;
isa = PBXBuildFile;
settings = {
};
};
F59CEEA101A28CA101A8010B = {
fileRef = F59CEE9F01A28CA001A8010B;
isa = PBXBuildFile;
settings = {
};
};
F59CEEA201A28D4201A8010B = {
isa = PBXFileReference;
name = HexWindowController.h;
path = "PlugIns/Hex Editor/HexWindowController.h";
refType = 4;
};
F59CEEA301A28D4201A8010B = {
isa = PBXFileReference;
name = HexWindowController.m;
path = "PlugIns/Hex Editor/HexWindowController.m";
refType = 4;
};
F59CEEA401A28D4301A8010B = {
fileRef = F59CEEA201A28D4201A8010B;
isa = PBXBuildFile;
settings = {
};
};
F59CEEA501A28D4301A8010B = {
fileRef = F59CEEA301A28D4201A8010B;
isa = PBXBuildFile;
settings = {
};
};
F5B5880F0156D2A601000001 = {
buildStyles = (
F5EBF6B801573EC201000001,
@ -29,6 +281,7 @@
F5B588130156D30301000001,
F5B588750156D5CB01000001,
F5B588D20156D78201000001,
F57CEE0E0189C95101A8010B,
F5B588EE0156DAF301000001,
F5B5890B0156DC2201000001,
);
@ -54,6 +307,7 @@
F5B588D10156D78201000001,
F5B588ED0156DAF301000001,
F5B589030156DC2201000001,
F57CEE0D0189C95101A8010B,
);
isa = PBXGroup;
name = Products;
@ -73,7 +327,6 @@
F5B588180156D30301000001,
);
buildSettings = {
OPTIMIZATION_CFLAGS = "";
OTHER_CFLAGS = "";
OTHER_LDFLAGS = "";
OTHER_REZFLAGS = "";
@ -83,6 +336,7 @@
WRAPPER_EXTENSION = app;
};
dependencies = (
F5CDEBAF01FCA71501A80001,
);
isa = PBXApplicationTarget;
name = "ResKnife Cocoa";
@ -165,9 +419,7 @@
F5B588140156D30301000001 = {
buildActionMask = 2147483647;
files = (
F5B5884E0156D40B01000001,
F5B5884F0156D40B01000001,
F5B588500156D40B01000001,
F5B588510156D40B01000001,
F5B588520156D40B01000001,
F5B588530156D40B01000001,
@ -177,6 +429,10 @@
F5B588570156D40B01000001,
F5B588580156D40B01000001,
F5B588590156D40B01000001,
F5502C4101C579FF01C57124,
F53B5F3001C97EFB01A8010C,
F53B5F3101C97EFB01A8010C,
F5CDEBAC01FC893201A80001,
);
isa = PBXHeadersBuildPhase;
name = Headers;
@ -196,6 +452,7 @@
F5B588630156D40B01000001,
F5B588640156D40B01000001,
F5730B940159528A01000001,
F5502C3401C5588601C57124,
);
isa = PBXResourcesBuildPhase;
name = "Bundle Resources";
@ -241,6 +498,7 @@
F5B5881B0156D40B01000001,
F5B5881C0156D40B01000001,
F5B588350156D40B01000001,
F57CEE0B0189C95101A8010B,
);
isa = PBXGroup;
path = Cocoa;
@ -591,24 +849,12 @@
path = /System/Library/Frameworks/Foundation.framework;
refType = 0;
};
F5B5884E0156D40B01000001 = {
fileRef = F5B5881D0156D40B01000001;
isa = PBXBuildFile;
settings = {
};
};
F5B5884F0156D40B01000001 = {
fileRef = F5B5881F0156D40B01000001;
isa = PBXBuildFile;
settings = {
};
};
F5B588500156D40B01000001 = {
fileRef = F5B588210156D40B01000001;
isa = PBXBuildFile;
settings = {
};
};
F5B588510156D40B01000001 = {
fileRef = F5B588230156D40B01000001;
isa = PBXBuildFile;
@ -833,8 +1079,7 @@
F5B5887A0156D5CB01000001,
);
buildSettings = {
LIBRARY_SEARCH_PATHS = "";
OPTIMIZATION_CFLAGS = "";
LIBRARY_SEARCH_PATHS = /Volumes/DeskStar/nicholas/Projects/ResKnife/Carbon;
OTHER_CFLAGS = "";
OTHER_LDFLAGS = "";
OTHER_REZFLAGS = "";
@ -938,7 +1183,6 @@
F5B588B70156D6D901000001,
F5B588B80156D6D901000001,
F5B588B90156D6D901000001,
F5B588BA0156D6D901000001,
);
isa = PBXHeadersBuildPhase;
name = Headers;
@ -976,7 +1220,8 @@
F5B588790156D5CB01000001 = {
buildActionMask = 2147483647;
files = (
F5B588CC0156D6D901000001,
F53B5F3201C984F301A8010C,
F5D0BAFC0202558901A80001,
);
isa = PBXFrameworksBuildPhase;
name = "Frameworks & Libraries";
@ -984,7 +1229,6 @@
F5B5887A0156D5CB01000001 = {
buildActionMask = 2147483647;
files = (
F5B588CE0156D6D901000001,
F5B588CF0156D6D901000001,
F5B588D00156D6D901000001,
);
@ -1370,12 +1614,6 @@
settings = {
};
};
F5B588BA0156D6D901000001 = {
fileRef = F5B5887D0156D6D901000001;
isa = PBXBuildFile;
settings = {
};
};
F5B588BC0156D6D901000001 = {
fileRef = F5B588A60156D6D901000001;
isa = PBXBuildFile;
@ -1472,18 +1710,6 @@
settings = {
};
};
F5B588CC0156D6D901000001 = {
fileRef = F5B588A70156D6D901000001;
isa = PBXBuildFile;
settings = {
};
};
F5B588CE0156D6D901000001 = {
fileRef = F5B588A30156D6D901000001;
isa = PBXBuildFile;
settings = {
};
};
F5B588CF0156D6D901000001 = {
fileRef = F5B588A40156D6D901000001;
isa = PBXBuildFile;
@ -1510,9 +1736,7 @@
F5B588D70156D78201000001,
);
buildSettings = {
OPTIMIZATION_CFLAGS = "";
OTHER_CFLAGS = "";
OTHER_LDFLAGS = "-bundle -undefined suppress";
OTHER_LDFLAGS = "-bundle -bundle_loader \"$HOME/Projects/ResKnife/build/ResKnife Cocoa.app/Contents/MacOS/ResKnife Cocoa\" -undefined error";
OTHER_REZFLAGS = "";
PRODUCT_NAME = "Hex Editor";
SECTORDER_FLAGS = "";
@ -1523,7 +1747,6 @@
);
isa = PBXBundleTarget;
name = "Hex Editor";
productInstallPath = "$(USER_LIBRARY_DIR)/Bundles";
productName = "Hex Editor";
productReference = F5B588D10156D78201000001;
productSettingsXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
@ -1745,7 +1968,6 @@
F5B588F30156DAF301000001,
);
buildSettings = {
OPTIMIZATION_CFLAGS = "";
OTHER_CFLAGS = "";
OTHER_LDFLAGS = "-bundle -undefined suppress";
OTHER_REZFLAGS = "";
@ -1837,8 +2059,8 @@
F5B588F40156DC2201000001 = {
children = (
F5B588F50156DC2201000001,
F5B588F60156DC2201000001,
F5B588FB0156DC2201000001,
F5B588F60156DC2201000001,
);
isa = PBXGroup;
path = "Template Editor";
@ -1986,7 +2208,6 @@
F5B589160156DC2201000001,
);
buildSettings = {
OPTIMIZATION_CFLAGS = "";
OTHER_CFLAGS = "";
OTHER_LDFLAGS = "-bundle -undefined suppress";
OTHER_REZFLAGS = "";
@ -2110,11 +2331,94 @@
isa = PBXRezBuildPhase;
name = "ResourceManager Resources";
};
F5CDEB9D01FB7C8601A80001 = {
isa = PBXFileReference;
name = HexTextView.h;
path = "PlugIns/Hex Editor/HexTextView.h";
refType = 4;
};
F5CDEB9E01FB7C8601A80001 = {
isa = PBXFileReference;
name = HexTextView.m;
path = "PlugIns/Hex Editor/HexTextView.m";
refType = 4;
};
F5CDEBA101FBD4E001A80001 = {
isa = PBXFileReference;
name = HexEditorDelegate.h;
path = "PlugIns/Hex Editor/HexEditorDelegate.h";
refType = 4;
};
F5CDEBA201FBD4E001A80001 = {
isa = PBXFileReference;
name = HexEditorDelegate.m;
path = "PlugIns/Hex Editor/HexEditorDelegate.m";
refType = 4;
};
F5CDEBA301FBD4E101A80001 = {
fileRef = F5CDEBA101FBD4E001A80001;
isa = PBXBuildFile;
settings = {
};
};
F5CDEBA401FBD4E101A80001 = {
fileRef = F5CDEBA201FBD4E001A80001;
isa = PBXBuildFile;
settings = {
};
};
F5CDEBA901FC86CA01A80001 = {
isa = PBXFileReference;
name = SupportedTypes.plist;
path = "Cocoa/PlugIns/Hex Editor/SupportedTypes.plist";
refType = 2;
};
F5CDEBAA01FC86CB01A80001 = {
fileRef = F5CDEBA901FC86CA01A80001;
isa = PBXBuildFile;
settings = {
};
};
F5CDEBAB01FC893201A80001 = {
isa = PBXFileReference;
name = ResKnifeResourceProtocol.h;
path = "PlugIns/ResKnifeResourceProtocol.h";
refType = 4;
};
F5CDEBAC01FC893201A80001 = {
fileRef = F5CDEBAB01FC893201A80001;
isa = PBXBuildFile;
settings = {
};
};
F5CDEBAD01FC893301A80001 = {
fileRef = F5CDEBAB01FC893201A80001;
isa = PBXBuildFile;
settings = {
};
};
F5CDEBAE01FC90AD01A80001 = {
fileRef = F5502C4001C579FF01C57124;
isa = PBXBuildFile;
settings = {
};
};
F5CDEBAF01FCA71501A80001 = {
isa = PBXTargetDependency;
target = F57CEE0E0189C95101A8010B;
};
F5D0BAFC0202558901A80001 = {
fileRef = F5B588A70156D6D901000001;
isa = PBXBuildFile;
settings = {
};
};
F5EBF6B801573EC201000001 = {
buildRules = (
);
buildSettings = {
COPY_PHASE_STRIP = NO;
OPTIMIZATION_CFLAGS = "-O0";
};
isa = PBXBuildStyle;
name = Development;