Fixes for many (though not all) endian problems when running native on Intel.

This commit is contained in:
Nicholas Shanks 2010-08-30 23:38:46 +00:00
parent 5acb769f40
commit 8093fe18eb
32 changed files with 260 additions and 158 deletions

View File

@ -968,7 +968,7 @@ Boolean GotRequiredParams( const AppleEvent *event )
DescType actualType; DescType actualType;
Size actualSize; Size actualSize;
// check if we have retreived the required parameters // check if we have retrieved the required parameters
error = AEGetAttributePtr( event, keyMissedKeywordAttr, typeWildCard, &actualType, null, 0, &actualSize ); error = AEGetAttributePtr( event, keyMissedKeywordAttr, typeWildCard, &actualType, null, 0, &actualSize );
return error == errAEDescNotFound; return error == errAEDescNotFound;
} }

View File

@ -566,7 +566,7 @@ OSErr SHQueueCallback( SndChannel *channel )
// causes a crash if more than one SndPlay call is made on the same channel. Helper // causes a crash if more than one SndPlay call is made on the same channel. Helper
// will never do this on its own, and you shouldn't either. If you want a sound // will never do this on its own, and you shouldn't either. If you want a sound
// channel that you want to send commands to, call SHPlayByHandle with a nil handle, // channel that you want to send commands to, call SHPlayByHandle with a nil handle,
// then call SHGetChannel to retreive a pointer to the channel. // then call SHGetChannel to retrieve a pointer to the channel.
// //
//======================================================================================= //=======================================================================================
OSErr SHBeginPlayback( SHOutPtr outRec ) OSErr SHBeginPlayback( SHOutPtr outRec )

View File

@ -2,22 +2,31 @@
/* The methods in the following catagory were based upon those in OmniAppKit */ /* The methods in the following catagory were based upon those in OmniAppKit */
@implementation NSOutlineView (ResKnifeSelectedItemExtensions) @implementation NSOutlineView (RKSelectedItemExtensions)
- (id)selectedItem - (id)selectedItem
{ {
if( [self numberOfSelectedRows] != 1 ) return nil; if ([self numberOfSelectedRows] != 1) return nil;
else return [self itemAtRow:[self selectedRow]]; else return [self itemAtRow:[self selectedRow]];
} }
- (NSArray *)selectedItems - (NSArray *)selectedItems
{ {
NSNumber *row;
NSMutableArray *items = [NSMutableArray array]; NSMutableArray *items = [NSMutableArray array];
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3
NSIndexSet *indicies = [self selectedRowIndexes];
unsigned int rowIndex = [indicies firstIndex];
while (rowIndex != NSNotFound)
{
[items addObject:[self itemAtRow:rowIndex]];
rowIndex = [indicies indexGreaterThanIndex:rowIndex];
}
#else
NSNumber *row;
NSEnumerator *enumerator = [self selectedRowEnumerator]; NSEnumerator *enumerator = [self selectedRowEnumerator];
while (row = [enumerator nextObject])
while( row = [enumerator nextObject] )
[items addObject:[self itemAtRow:[row intValue]]]; [items addObject:[self itemAtRow:[row intValue]]];
#endif
return items; return items;
} }

View File

@ -6,7 +6,7 @@
{ {
// caller is responsible for disposing of the FSRef (method is a 'create' method) // caller is responsible for disposing of the FSRef (method is a 'create' method)
FSRef *fsRef = (FSRef *) NewPtrClear(sizeof(FSRef)); FSRef *fsRef = (FSRef *) NewPtrClear(sizeof(FSRef));
OSStatus error = FSPathMakeRef([self fileSystemRepresentation], fsRef, NULL); OSStatus error = FSPathMakeRef((unsigned char *)[self fileSystemRepresentation], fsRef, NULL);
if(error == noErr) if(error == noErr)
return fsRef; return fsRef;
return NULL; return NULL;
@ -17,7 +17,7 @@
// caller is responsible for disposing of the FSSpec (method is a 'create' method) // caller is responsible for disposing of the FSSpec (method is a 'create' method)
FSRef *fsRef = (FSRef *) NewPtrClear(sizeof(FSRef)); FSRef *fsRef = (FSRef *) NewPtrClear(sizeof(FSRef));
FSSpec *fsSpec = (FSSpec *) NewPtrClear(sizeof(FSSpec)); FSSpec *fsSpec = (FSSpec *) NewPtrClear(sizeof(FSSpec));
OSStatus error = FSPathMakeRef([self fileSystemRepresentation], fsRef, NULL); OSStatus error = FSPathMakeRef((unsigned char *)[self fileSystemRepresentation], fsRef, NULL);
if(error == noErr) if(error == noErr)
{ {
error = FSGetCatalogInfo(fsRef, kFSCatInfoNone, NULL, NULL, fsSpec, NULL); error = FSGetCatalogInfo(fsRef, kFSCatInfoNone, NULL, NULL, fsSpec, NULL);

View File

@ -65,6 +65,8 @@
- (void)precacheIcons:(NSTimer *)timer - (void)precacheIcons:(NSTimer *)timer
{ {
// pre-cache a number of common icons (ignores return value, relies on iconForResourceType: to do the actual caching) // pre-cache a number of common icons (ignores return value, relies on iconForResourceType: to do the actual caching)
[self iconForResourceType:@" "];
[self iconForResourceType:@"????"];
[self iconForResourceType:@"CODE"]; [self iconForResourceType:@"CODE"];
[self iconForResourceType:@"icns"]; [self iconForResourceType:@"icns"];
[self iconForResourceType:@"PICT"]; [self iconForResourceType:@"PICT"];
@ -231,70 +233,82 @@
@author Nicholas Shanks @author Nicholas Shanks
@created 2003-10-24 @created 2003-10-24
@abstract Manages the cache of icons used for representing resource types. @abstract Manages the cache of icons used for representing resource types.
@description This method loads icons for each resource type from a variety of places and caches them for faster access. Your plug-in may be asked to return an icon for any resource type it declares it can edit. To implement this, your plug should respond to the iconForResourceType: selector with the same method signature as this method. The icons can be in any format recognised by NSImage. Alternativly, just leave your icons in "Your.plugin/Contents/Resources/Resource Type Icons/" (or any equivalent localised directory) with a name like "TYPE.tiff" and ResKnife will retreive them automatically. @description This method loads icons for each resource type from a variety of places and caches them for faster access. Your plug-in may be asked to return an icon for any resource type it declares it can edit. To implement this, your plug should respond to the iconForResourceType: selector with the same method signature as this method. The icons can be in any format recognised by NSImage. Alternativly, just leave your icons in "Your.plugin/Contents/Resources/Resource Type Icons/" (or any equivalent localised directory) with a name like "TYPE.tiff" and ResKnife will retrieve them automatically.
@pending I don't like the name I chose here for the resource type icons directory. Can anyone think of something better? @pending I don't like the name I chose here for the resource type icons directory. Can anyone think of something better?
*/ */
- (NSImage *)iconForResourceType:(NSString *)resourceType - (NSImage *)iconForResourceType:(NSString *)resourceType
{ {
// check if we have image in cache already
NSImage *icon = nil; NSImage *icon = nil;
if([resourceType isEqualToString:@""]) if([resourceType isEqualToString:@""])
resourceType = nil; resourceType = nil;
if(resourceType); if(resourceType)
icon = [[self _icons] valueForKey:resourceType];
if(!icon)
{ {
NSString *iconPath = nil; // check if we have image in cache already
icon = [[self _icons] objectForKey:resourceType]; // valueForKey: raises when the resourceType begins with '@' (e.g. the @GN4 owner resource from Gene!)
// try to load icon from the default editor for that type if(!icon)
Class editor = [[RKEditorRegistry defaultRegistry] editorForType:resourceType];
if(editor && resourceType)
{ {
// ask politly for icon NSString *iconPath = nil;
if([editor respondsToSelector:@selector(iconForResourceType:)])
icon = [editor iconForResourceType:resourceType];
// try getting it myself // try to load icon from the default editor for that type
Class editor = [[RKEditorRegistry defaultRegistry] editorForType:resourceType];
if(editor)
{
// ask politly for icon
if([editor respondsToSelector:@selector(iconForResourceType:)])
icon = [editor iconForResourceType:resourceType];
// try getting it myself
if(!icon)
{
iconPath = [[NSBundle bundleForClass:editor] pathForResource:resourceType ofType:nil inDirectory:@"Resource Type Icons"];
if(iconPath)
icon = [[[NSImage alloc] initWithContentsOfFile:iconPath] autorelease];
}
}
// try to load icon from the ResKnife app bundle itself
if(!icon) if(!icon)
{ {
iconPath = [[NSBundle bundleForClass:editor] pathForResource:resourceType ofType:nil inDirectory:@"Resource Type Icons"]; iconPath = [[NSBundle mainBundle] pathForResource:resourceType ofType:nil inDirectory:@"Resource Type Icons"];
if(iconPath) if(iconPath)
icon = [[[NSImage alloc] initWithContentsOfFile:iconPath] autorelease]; icon = [[[NSImage alloc] initWithContentsOfFile:iconPath] autorelease];
} }
}
// try to retrieve from file system using our resource type to file name extension/bundle identifier code
// try to load icon from the ResKnife app bundle itself if(!icon)
if(!icon && resourceType)
{
iconPath = [[NSBundle mainBundle] pathForResource:resourceType ofType:nil inDirectory:@"Resource Type Icons"];
if(iconPath)
icon = [[[NSImage alloc] initWithContentsOfFile:iconPath] autorelease];
}
// try to retreive from file system (after first mangling the type through our converter strings file)
if(!icon && resourceType)
{
NSString *fileType = [[NSBundle mainBundle] localizedStringForKey:resourceType value:@"" table:@"Resource Type Mappings"];
NSRange range = [fileType rangeOfString:@"."];
if(range.location == NSNotFound)
icon = [[NSWorkspace sharedWorkspace] iconForFileType:fileType];
else // a '.' character in a file type means ResKnife should look for a bundle icon with fileType as the bundle's identifier
{ {
NSString *bundlePath = [[NSBundle bundleWithIdentifier:fileType] bundlePath]; NSString *fileType = [[NSBundle mainBundle] localizedStringForKey:resourceType value:@"" table:@"Resource Type Mappings"];
if(bundlePath) NSRange range = [fileType rangeOfString:@"."];
icon = [[NSWorkspace sharedWorkspace] iconForFile:bundlePath]; if(range.location == NSNotFound)
icon = [[NSWorkspace sharedWorkspace] iconForFileType:fileType];
else // a '.' character in a file type means ResKnife should look for a bundle icon with fileType as the bundle's identifier
{
NSString *bundlePath = [[NSBundle bundleWithIdentifier:fileType] bundlePath];
if(bundlePath)
icon = [[NSWorkspace sharedWorkspace] iconForFile:bundlePath];
}
} }
// TODO: convert to a UTI and try that
// try to retrieve from file system as an OSType code
if(!icon)
icon = [[NSWorkspace sharedWorkspace] iconForFileType:[NSString stringWithFormat:@"'%@'", resourceType]];
// save the newly retrieved icon in the cache
if(icon)
[[self _icons] setObject:icon forKey:resourceType];
} }
}
// if we still don't have an icon, try to get the generic one - this is what icon represented forks get else
if(!icon) {
icon = [[NSWorkspace sharedWorkspace] iconForFileType:@"????"]; // we have no resource type, try to get a generic icon - this is what icon represented forks get
// if(!icon) icon = [NSImage imageNamed:@"NSMysteryDocument"];
// save the newly retreived icon in the cache // if(!icon) icon = [[NSWorkspace sharedWorkspace] iconForFileType:@"' '"];
if(icon && resourceType) if(!icon) icon = [[NSWorkspace sharedWorkspace] iconForFileType:[NSString stringWithFormat:@"'%@'", @"????"]];
[[self _icons] setObject:icon forKey:resourceType];
} }
// return the cached icon, or nil if none was found // return the cached icon, or nil if none was found

View File

@ -36,9 +36,9 @@
/*! /*!
@method updateInfoWindow @method updateInfoWindow
@change 2003-11-06 NS: Fixed creator/type handling. @updated 2003-11-06 NGS: Fixed creator/type handling.
@change 2003-10-26 NS: Now asks app delegate for icon instead of NSWorkspace. @updated 2003-10-26 NGS: Now asks app delegate for icon instead of NSWorkspace.
@change 2003-10-26 NS: Improved document name & icon display. @updated 2003-10-26 NGS: Improved document name & icon display.
*/ */
- (void)updateInfoWindow - (void)updateInfoWindow
@ -48,6 +48,8 @@
if(selectedResource) if(selectedResource)
{ {
NSLog(@"selected resource data: %@", [selectedResource data]);
// set UI values // set UI values
[[self window] setTitle:NSLocalizedString(@"Resource Info",nil)]; [[self window] setTitle:NSLocalizedString(@"Resource Info",nil)];
[nameView setStringValue:[selectedResource name]]; [nameView setStringValue:[selectedResource name]];
@ -86,8 +88,8 @@
[iconView setImage:[NSImage imageNamed:@"Resource file"]]; [iconView setImage:[NSImage imageNamed:@"Resource file"]];
[nameView setStringValue:[currentDocument displayName]]; [nameView setStringValue:[currentDocument displayName]];
} }
[currentDocument creator];
[[NSString alloc] initWithData:[currentDocument creator] encoding:NSMacOSRomanStringEncoding]; #warning FIXME: the creator and type codes need to be swapped on intel
[[filePropertyForm cellAtIndex:0] setStringValue:[[[NSString alloc] initWithData:[currentDocument creator] encoding:NSMacOSRomanStringEncoding] autorelease]]; [[filePropertyForm cellAtIndex:0] setStringValue:[[[NSString alloc] initWithData:[currentDocument creator] encoding:NSMacOSRomanStringEncoding] autorelease]];
[[filePropertyForm cellAtIndex:1] setStringValue:[[[NSString alloc] initWithData:[currentDocument type] encoding:NSMacOSRomanStringEncoding] autorelease]]; [[filePropertyForm cellAtIndex:1] setStringValue:[[[NSString alloc] initWithData:[currentDocument type] encoding:NSMacOSRomanStringEncoding] autorelease]];
// [[filePropertyForm cellAtIndex:2] setObjectValue:[NSNumber numberWithUnsignedLongLong:dataLogicalSize]]; // [[filePropertyForm cellAtIndex:2] setObjectValue:[NSNumber numberWithUnsignedLongLong:dataLogicalSize]];
@ -101,7 +103,7 @@
else else
{ {
[iconView setImage:nil]; [iconView setImage:nil];
[nameView setStringValue:nil]; [nameView setStringValue:@""];
[placeholderView setContentView:nil]; [placeholderView setContentView:nil];
} }
} }

View File

@ -250,13 +250,12 @@ extern NSString *RKResourcePboardType;
for(unsigned short i = 1; i <= Count1Types(); i++) for(unsigned short i = 1; i <= Count1Types(); i++)
{ {
ResType resType; ResType resTypeCode;
Get1IndType(&resType, i); Get1IndType(&resTypeCode, i);
ResType swappedType = EndianS32_NtoB(resType); // Swapped type for use as string (types are treated as numbers by the resource manager and swapped on Intel). unsigned short n = Count1Resources(resTypeCode);
unsigned short n = Count1Resources(resType);
for(unsigned short j = 1; j <= n; j++) for(unsigned short j = 1; j <= n; j++)
{ {
Handle resourceHandle = Get1IndResource(resType, j); Handle resourceHandle = Get1IndResource(resTypeCode, j);
error = ResError(); error = ResError();
if(error != noErr) if(error != noErr)
{ {
@ -267,21 +266,33 @@ extern NSString *RKResourcePboardType;
Str255 nameStr; Str255 nameStr;
short resIDShort; short resIDShort;
GetResInfo(resourceHandle, &resIDShort, &resType, nameStr); GetResInfo(resourceHandle, &resIDShort, &resTypeCode, nameStr);
long sizeLong = GetResourceSizeOnDisk(resourceHandle); long sizeLong = GetResourceSizeOnDisk(resourceHandle), badSize = 0;
if (sizeLong < 0 || sizeLong > 16777215) // the max size of resource manager file is ~12 MB; I am rounding up to three bytes
{
// this only happens when opening ResEdit using the x86 binary (not under Rosetta, for example)
badSize = sizeLong;
sizeLong = EndianS32_BtoL(sizeLong);
}
short attrsShort = GetResAttrs(resourceHandle); short attrsShort = GetResAttrs(resourceHandle);
HLockHi(resourceHandle); HLockHi(resourceHandle);
#if __LITTLE_ENDIAN__
CoreEndianFlipData(kCoreEndianResourceManagerDomain, resTypeCode, resIDShort, *resourceHandle, sizeLong, true);
#endif
// cool: "The advantage of obtaining a methodÕs implementation and calling it as a function is that you can invoke the implementation multiple times within a loop, or similar C construct, without the overhead of Objective-C messaging." // cool: "The advantage of obtaining a methodÕs implementation and calling it as a function is that you can invoke the implementation multiple times within a loop, or similar C construct, without the overhead of Objective-C messaging."
// create the resource & add it to the array // create the resource & add it to the array
ResType logicalType = EndianS32_NtoB(resTypeCode); // swapped type for use as string (types are treated as numbers by the resource manager and swapped on Intel).
NSString *name = [[NSString alloc] initWithBytes:&nameStr[1] length:nameStr[0] encoding:NSMacOSRomanStringEncoding]; NSString *name = [[NSString alloc] initWithBytes:&nameStr[1] length:nameStr[0] encoding:NSMacOSRomanStringEncoding];
NSString *resType = [[NSString alloc] initWithBytes:(char *) &swappedType length:4 encoding:NSMacOSRomanStringEncoding]; NSString *resType = [[NSString alloc] initWithBytes:(char *) &logicalType length:4 encoding:NSMacOSRomanStringEncoding];
NSNumber *resID = [NSNumber numberWithShort:resIDShort]; NSNumber *resID = [NSNumber numberWithShort:resIDShort];
NSNumber *attributes = [NSNumber numberWithShort:attrsShort]; NSNumber *attributes = [NSNumber numberWithShort:attrsShort];
NSData *data = [NSData dataWithBytes:*resourceHandle length:sizeLong]; NSData *data = [NSData dataWithBytes:*resourceHandle length:sizeLong];
Resource *resource = [Resource resourceOfType:resType andID:resID withName:name andAttributes:attributes data:data]; Resource *resource = [Resource resourceOfType:resType andID:resID withName:name andAttributes:attributes data:data];
[resources addObject:resource]; // array retains resource [resources addObject:resource]; // array retains resource
if (badSize != 0)
NSLog(@"GetResourceSizeOnDisk() reported incorrect size for %@ resource %@ in %@: %li should be %li", resType, resID, [self displayName], badSize, sizeLong);
[name release]; [name release];
[resType release]; [resType release];
@ -296,8 +307,8 @@ extern NSString *RKResourcePboardType;
} }
/*! /*!
@pending Uli's changed this routine - see what I had and unify the two @pending Uli has changed this routine - see what I had and unify the two
@pending Doesn't write correct type/creator info - always ResKnife's! @pending Doesn't write correct type/creator info - always ResKnife's!
*/ */
- (BOOL)writeToFile:(NSString *)fileName ofType:(NSString *)type - (BOOL)writeToFile:(NSString *)fileName ofType:(NSString *)type
@ -406,32 +417,39 @@ extern NSString *RKResourcePboardType;
while(Resource *resource = [enumerator nextObject]) while(Resource *resource = [enumerator nextObject])
{ {
Str255 nameStr; Str255 nameStr;
char resType[5]; // includes null char for getCString: ResType resTypeCode;
char resTypeStr[5]; // includes null char for getCString:
short resIDShort; short resIDShort;
short attrsShort; short attrsShort;
long sizeLong;
Handle resourceHandle; Handle resourceHandle;
// if the resource represents another fork in the file, skip it // if the resource represents another fork in the file, skip it
if([resource representedFork] != nil) continue; if([resource representedFork] != nil) continue;
sizeLong = [[resource data] length];
resIDShort = [[resource resID] shortValue]; resIDShort = [[resource resID] shortValue];
attrsShort = [[resource attributes] shortValue]; attrsShort = [[resource attributes] shortValue];
resourceHandle = NewHandleClear([[resource data] length]); resourceHandle = NewHandleClear(sizeLong);
// convert unicode name to pascal string // convert unicode name to pascal string
nameStr[0] = [[resource name] lengthOfBytesUsingEncoding:NSMacOSRomanStringEncoding]; nameStr[0] = [[resource name] lengthOfBytesUsingEncoding:NSMacOSRomanStringEncoding];
BlockMoveData([[resource name] cStringUsingEncoding:NSMacOSRomanStringEncoding], &nameStr[1], nameStr[0]); BlockMoveData([[resource name] cStringUsingEncoding:NSMacOSRomanStringEncoding], &nameStr[1], nameStr[0]);
// convert type string to ResType // convert type string to ResType
[[resource type] getCString:resType maxLength:4]; [[resource type] getCString:resTypeStr maxLength:4];
resTypeCode = CFSwapInt32HostToBig(*(ResType *)resTypeStr);
// convert NSData to resource handle // convert NSData to resource handle
HLockHi(resourceHandle); HLockHi(resourceHandle);
[[resource data] getBytes:*resourceHandle]; [[resource data] getBytes:*resourceHandle];
#if __LITTLE_ENDIAN__
CoreEndianFlipData(kCoreEndianResourceManagerDomain, resTypeCode, resIDShort, *resourceHandle, sizeLong, false);
#endif
HUnlock(resourceHandle); HUnlock(resourceHandle);
// now that everything's converted, tell the resource manager we want to create this resource // now that everything's converted, tell the resource manager we want to create this resource
AddResource(resourceHandle, *(ResType *)resType, resIDShort, nameStr); AddResource(resourceHandle, resTypeCode, resIDShort, nameStr);
if(ResError() == addResFailed) if(ResError() == addResFailed)
{ {
NSLog(@"*Saving failed*; could not add resource ID %@ of type %@ to file.", [resource resID], [resource type]); NSLog(@"*Saving failed*; could not add resource ID %@ of type %@ to file.", [resource resID], [resource type]);

View File

@ -10,15 +10,18 @@
<key>CFBundleTypeExtensions</key> <key>CFBundleTypeExtensions</key>
<array> <array>
<string>rsrc</string> <string>rsrc</string>
<string>*</string>
</array> </array>
<key>CFBundleTypeIconFile</key> <key>CFBundleTypeIconFile</key>
<string>Resource file.icns</string> <string>Resource file.icns</string>
<key>CFBundleTypeName</key> <key>CFBundleTypeName</key>
<string>com.apple.resource-map</string> <string>ResourceMap</string>
<key>CFBundleTypeOSTypes</key> <key>CFBundleTypeOSTypes</key>
<array> <array>
<string>rsrc</string> <string>rsrc</string>
<string>RSRC</string> <string>RSRC</string>
<string>????</string>
<string>****</string>
</array> </array>
<key>CFBundleTypeRole</key> <key>CFBundleTypeRole</key>
<string>Editor</string> <string>Editor</string>
@ -29,27 +32,6 @@
<key>NSDocumentClass</key> <key>NSDocumentClass</key>
<string>ResourceDocument</string> <string>ResourceDocument</string>
</dict> </dict>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>*</string>
</array>
<key>CFBundleTypeOSTypes</key>
<array>
<string>****</string>
<string>????</string>
</array>
<key>CFBundleTypeName</key>
<string>public.data</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>LSItemContentTypes</key>
<array>
<string>public.data</string>
</array>
<key>NSDocumentClass</key>
<string>ResourceDocument</string>
</dict>
</array> </array>
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
<string>ResKnife Cocoa</string> <string>ResKnife Cocoa</string>
@ -66,11 +48,11 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>0.6 beta 4</string> <string>0.6 cvs</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>ResK</string> <string>ResK</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>18</string> <string>19</string>
<key>NSAppleScriptEnabled</key> <key>NSAppleScriptEnabled</key>
<true/> <true/>
<key>NSMainNibFile</key> <key>NSMainNibFile</key>

View File

@ -143,7 +143,7 @@ OSStatus Plug_InitInstance(Plug_PlugInRef plug, Plug_ResourceRef resource)
{ {
if([[self window] isDocumentEdited]) if([[self window] isDocumentEdited])
{ {
NSBeginAlertSheet(@"Do you want to keep the changes you made to this resource?", @"Keep", @"DonÕt Keep", @"Cancel", sender, self, @selector(saveSheetDidClose:returnCode:contextInfo:), nil, nil, @"Your changes cannot be saved later if you don't keep them."); NSBeginAlertSheet(@"Do you want to keep the changes you made to this resource?", @"Keep", @"Don't Keep", @"Cancel", sender, self, @selector(saveSheetDidClose:returnCode:contextInfo:), nil, nil, @"Your changes cannot be saved later if you don't keep them.");
return NO; return NO;
} }
else return YES; else return YES;

View File

@ -78,4 +78,10 @@
+ (NSString *)filenameExtensionForFileExport:(id <ResKnifeResourceProtocol>)resource; + (NSString *)filenameExtensionForFileExport:(id <ResKnifeResourceProtocol>)resource;
/*!
@@method iconForResourceType:
@abstract Returns the icon to be used throughout the UI for any given resource type.
*/
- (NSImage *)iconForResourceType:(NSString *)resourceType;
@end @end

View File

@ -41,7 +41,7 @@
- (void)setData:(NSData *)newData; - (void)setData:(NSData *)newData;
- (NSString *)defaultWindowTitle; - (NSString *)defaultWindowTitle;
- (NSDocument *)document; - (NSDocument *)document; // Owner of this resource. Useful for looking for resources in same file as yours.
// These methods are used to retrieve resources other than the one you're editing. // These methods are used to retrieve resources other than the one you're editing.
// Passing a document of nil will indicate to search in all open documents. // Passing a document of nil will indicate to search in all open documents.
@ -56,6 +56,8 @@
@end @end
// See note in Notifications.m about usage of these
extern NSString *ResourceWillChangeNotification; extern NSString *ResourceWillChangeNotification;
extern NSString *ResourceNameWillChangeNotification; extern NSString *ResourceNameWillChangeNotification;
extern NSString *ResourceTypeWillChangeNotification; extern NSString *ResourceTypeWillChangeNotification;

View File

@ -1,5 +1,7 @@
#import "ElementDBYT.h" #import "ElementDBYT.h"
#define SIZE_ON_DISK (1)
@implementation ElementDBYT @implementation ElementDBYT
- (id)copyWithZone:(NSZone *)zone - (id)copyWithZone:(NSZone *)zone
@ -11,17 +13,17 @@
- (void)readDataFrom:(TemplateStream *)stream - (void)readDataFrom:(TemplateStream *)stream
{ {
[stream readAmount:sizeof(value) toBuffer:&value]; [stream readAmount:SIZE_ON_DISK toBuffer:&value];
} }
- (unsigned int)sizeOnDisk - (unsigned int)sizeOnDisk
{ {
return sizeof(value); return SIZE_ON_DISK;
} }
- (void)writeDataTo:(TemplateStream *)stream - (void)writeDataTo:(TemplateStream *)stream
{ {
[stream writeAmount:sizeof(value) fromBuffer:&value]; [stream writeAmount:SIZE_ON_DISK fromBuffer:&value];
} }
- (void)setValue:(SInt8)v - (void)setValue:(SInt8)v

View File

@ -1,5 +1,7 @@
#import "ElementDLLG.h" #import "ElementDLLG.h"
#define SIZE_ON_DISK (8)
@implementation ElementDLLG @implementation ElementDLLG
- (id)copyWithZone:(NSZone*)zone - (id)copyWithZone:(NSZone*)zone
@ -11,17 +13,20 @@
- (void)readDataFrom:(TemplateStream *)stream - (void)readDataFrom:(TemplateStream *)stream
{ {
[stream readAmount:sizeof(value) toBuffer:&value]; SInt64 tmp;
[stream readAmount:SIZE_ON_DISK toBuffer:&tmp];
value = CFSwapInt64BigToHost(tmp);
} }
- (unsigned int)sizeOnDisk - (unsigned int)sizeOnDisk
{ {
return sizeof(value); return SIZE_ON_DISK;
} }
- (void)writeDataTo:(TemplateStream *)stream - (void)writeDataTo:(TemplateStream *)stream
{ {
[stream writeAmount:sizeof(value) fromBuffer:&value]; SInt64 tmp = CFSwapInt64HostToBig(value);
[stream writeAmount:SIZE_ON_DISK fromBuffer:&tmp];
} }
- (void)setValue:(SInt64)v - (void)setValue:(SInt64)v

View File

@ -1,5 +1,7 @@
#import "ElementDLNG.h" #import "ElementDLNG.h"
#define SIZE_ON_DISK (4)
@implementation ElementDLNG @implementation ElementDLNG
- (id)copyWithZone:(NSZone *)zone - (id)copyWithZone:(NSZone *)zone
@ -11,17 +13,20 @@
- (void)readDataFrom:(TemplateStream *)stream - (void)readDataFrom:(TemplateStream *)stream
{ {
[stream readAmount:sizeof(value) toBuffer:&value]; SInt32 tmp;
[stream readAmount:SIZE_ON_DISK toBuffer:&tmp];
value = CFSwapInt32BigToHost(tmp);
} }
- (unsigned int)sizeOnDisk - (unsigned int)sizeOnDisk
{ {
return sizeof(value); return SIZE_ON_DISK;
} }
- (void)writeDataTo:(TemplateStream *)stream - (void)writeDataTo:(TemplateStream *)stream
{ {
[stream writeAmount:sizeof(value) fromBuffer:&value]; SInt32 tmp = CFSwapInt32HostToBig(value);
[stream writeAmount:SIZE_ON_DISK fromBuffer:&tmp];
} }
- (void)setValue:(SInt32)v - (void)setValue:(SInt32)v

View File

@ -1,5 +1,7 @@
#import "ElementDWRD.h" #import "ElementDWRD.h"
#define SIZE_ON_DISK (2)
@implementation ElementDWRD @implementation ElementDWRD
- (id)copyWithZone:(NSZone *)zone - (id)copyWithZone:(NSZone *)zone
@ -11,17 +13,20 @@
- (void)readDataFrom:(TemplateStream *)stream - (void)readDataFrom:(TemplateStream *)stream
{ {
[stream readAmount:sizeof(value) toBuffer:&value]; SInt16 tmp;
[stream readAmount:SIZE_ON_DISK toBuffer:&tmp];
value = CFSwapInt16BigToHost(tmp);
} }
- (unsigned int)sizeOnDisk - (unsigned int)sizeOnDisk
{ {
return sizeof(value); return SIZE_ON_DISK;
} }
- (void)writeDataTo:(TemplateStream *)stream - (void)writeDataTo:(TemplateStream *)stream
{ {
[stream writeAmount:sizeof(value) fromBuffer:&value]; SInt16 tmp = CFSwapInt16HostToBig(value);
[stream writeAmount:SIZE_ON_DISK fromBuffer:&tmp];
} }
- (void)setValue:(SInt16)v - (void)setValue:(SInt16)v

View File

@ -19,6 +19,7 @@
if ([type isEqualToString:@"LCNT"] || [type isEqualToString:@"LZCT"]) [stream readAmount:4 toBuffer:&value]; if ([type isEqualToString:@"LCNT"] || [type isEqualToString:@"LZCT"]) [stream readAmount:4 toBuffer:&value];
else if([type isEqualToString:@"BCNT"] || [type isEqualToString:@"BZCT"]) [stream readAmount:1 toBuffer:(char *)(&value)+3]; else if([type isEqualToString:@"BCNT"] || [type isEqualToString:@"BZCT"]) [stream readAmount:1 toBuffer:(char *)(&value)+3];
else [stream readAmount:2 toBuffer:(short *)(&value)+1]; else [stream readAmount:2 toBuffer:(short *)(&value)+1];
value = CFSwapInt32BigToHost(value);
if([self countFromZero]) value += 1; if([self countFromZero]) value += 1;
} }
@ -32,9 +33,10 @@
- (void)writeDataTo:(TemplateStream *)stream - (void)writeDataTo:(TemplateStream *)stream
{ {
if([self countFromZero]) value -= 1; if([self countFromZero]) value -= 1;
if ([type isEqualToString:@"LCNT"] || [type isEqualToString:@"LZCT"]) [stream writeAmount:4 fromBuffer:&value]; unsigned long tmp = CFSwapInt32HostToBig(value);
else if([type isEqualToString:@"BCNT"] || [type isEqualToString:@"BZCT"]) [stream writeAmount:1 fromBuffer:(char *)(&value)+3]; if ([type isEqualToString:@"LCNT"] || [type isEqualToString:@"LZCT"]) [stream writeAmount:4 fromBuffer:&tmp];
else [stream writeAmount:2 fromBuffer:(short *)(&value)+1]; else if([type isEqualToString:@"BCNT"] || [type isEqualToString:@"BZCT"]) [stream writeAmount:1 fromBuffer:(char *)(&tmp)+3];
else [stream writeAmount:2 fromBuffer:(short *)(&tmp)+1];
if([self countFromZero]) value += 1; if([self countFromZero]) value += 1;
} }

View File

@ -51,7 +51,11 @@
if(_lengthBytes > 0) if(_lengthBytes > 0)
{ {
[stream readAmount:_lengthBytes toBuffer:&length]; [stream readAmount:_lengthBytes toBuffer:&length];
#if __BIG_ENDIAN__
length >>= (4 - _lengthBytes) << 3; length >>= (4 - _lengthBytes) << 3;
#else
#warning FIXME: This probably doesn't work for WSTR and LSTR on intel machines
#endif
} }
if(_terminatingByte) if(_terminatingByte)
length += [stream bytesToNull]; length += [stream bytesToNull];
@ -72,8 +76,8 @@
// skip over empty bytes // skip over empty bytes
if(_terminatingByte) [stream advanceAmount:1 pad:NO]; if(_terminatingByte) [stream advanceAmount:1 pad:NO];
if(_pad == kPadToOddLength && (length + _lengthBytes) % 2 == 0) [stream advanceAmount:1 pad:NO]; if(_pad == kPadToOddLength && (length + _terminatingByte ? 1:0) % 2 == 0) [stream advanceAmount:1 pad:NO];
if(_pad == kPadToEvenLength && (length + _lengthBytes) % 2 == 1) [stream advanceAmount:1 pad:NO]; if(_pad == kPadToEvenLength && (length + _terminatingByte ? 1:0) % 2 == 1) [stream advanceAmount:1 pad:NO];
// alignment unhandled here // alignment unhandled here
} }
@ -97,22 +101,30 @@
// write string // write string
UInt32 length = [value length], writeLength; UInt32 length = [value length], writeLength;
if(_maxLength && length > _maxLength) length = _maxLength; if(_maxLength && length > _maxLength) length = _maxLength;
#if __BIG_ENDIAN__
writeLength = length << ((4 - _lengthBytes) << 3); writeLength = length << ((4 - _lengthBytes) << 3);
#else
#warning FIXME: This probably doesn't work for WSTR and LSTR on intel machines
#endif
if(_lengthBytes) if(_lengthBytes)
[stream writeAmount:_lengthBytes fromBuffer:&writeLength]; [stream writeAmount:_lengthBytes fromBuffer:&writeLength];
#warning FIXME: This code should display a warning saying that the string in the PSTR is not MacOSRoman if ([value canBeConvertedToEncoding:NSMacOSRomanStringEncoding])
if([value respondsToSelector:@selector(cStringUsingEncoding:)])
{ {
const void *buffer = [value cStringUsingEncoding:NSMacOSRomanStringEncoding]; const void *buffer = NULL;
if([value respondsToSelector:@selector(cStringUsingEncoding:)]) // 10.4
buffer = [value cStringUsingEncoding:NSMacOSRomanStringEncoding];
else
{
NSData *data = [value dataUsingEncoding:NSMacOSRomanStringEncoding];
buffer = [data bytes];
}
if(buffer) [stream writeAmount:length fromBuffer:buffer]; if(buffer) [stream writeAmount:length fromBuffer:buffer];
else [stream advanceAmount:length pad:YES]; else [stream advanceAmount:length pad:YES];
} }
else else
{ {
const void *buffer = [value cString]; #warning FIXME: This code should display a warning saying that the string in the PSTR is not MacOSRoman
if(buffer) [stream writeAmount:length fromBuffer:buffer];
else [stream advanceAmount:length pad:YES];
} }
// pad to minimum length with spaces // pad to minimum length with spaces

View File

@ -1,5 +1,7 @@
#import "ElementUBYT.h" #import "ElementUBYT.h"
#define SIZE_ON_DISK (1)
@implementation ElementUBYT @implementation ElementUBYT
- (id)copyWithZone:(NSZone *)zone - (id)copyWithZone:(NSZone *)zone
@ -11,17 +13,17 @@
- (void)readDataFrom:(TemplateStream *)stream - (void)readDataFrom:(TemplateStream *)stream
{ {
[stream readAmount:sizeof(value) toBuffer:&value]; [stream readAmount:SIZE_ON_DISK toBuffer:&value];
} }
- (unsigned int)sizeOnDisk - (unsigned int)sizeOnDisk
{ {
return sizeof(value); return SIZE_ON_DISK;
} }
- (void)writeDataTo:(TemplateStream *)stream - (void)writeDataTo:(TemplateStream *)stream
{ {
[stream writeAmount:sizeof(value) fromBuffer:&value]; [stream writeAmount:SIZE_ON_DISK fromBuffer:&value];
} }
- (void)setValue:(UInt8)v - (void)setValue:(UInt8)v

View File

@ -1,5 +1,7 @@
#import "ElementULLG.h" #import "ElementULLG.h"
#define SIZE_ON_DISK (8)
@implementation ElementULLG @implementation ElementULLG
- (id)copyWithZone:(NSZone*)zone - (id)copyWithZone:(NSZone*)zone
@ -11,17 +13,20 @@
- (void)readDataFrom:(TemplateStream *)stream - (void)readDataFrom:(TemplateStream *)stream
{ {
[stream readAmount:sizeof(value) toBuffer:&value]; UInt64 tmp;
[stream readAmount:SIZE_ON_DISK toBuffer:&tmp];
value = CFSwapInt64BigToHost(tmp);
} }
- (unsigned int)sizeOnDisk - (unsigned int)sizeOnDisk
{ {
return sizeof(value); return SIZE_ON_DISK;
} }
- (void)writeDataTo:(TemplateStream *)stream - (void)writeDataTo:(TemplateStream *)stream
{ {
[stream writeAmount:sizeof(value) fromBuffer:&value]; UInt64 tmp = CFSwapInt64HostToBig(value);
[stream writeAmount:SIZE_ON_DISK fromBuffer:&tmp];
} }
- (void)setValue:(UInt64)v - (void)setValue:(UInt64)v

View File

@ -1,5 +1,7 @@
#import "ElementULNG.h" #import "ElementULNG.h"
#define SIZE_ON_DISK (4)
@implementation ElementULNG @implementation ElementULNG
- (id)copyWithZone:(NSZone *)zone - (id)copyWithZone:(NSZone *)zone
@ -11,17 +13,20 @@
- (void)readDataFrom:(TemplateStream *)stream - (void)readDataFrom:(TemplateStream *)stream
{ {
[stream readAmount:sizeof(value) toBuffer:&value]; UInt32 tmp;
[stream readAmount:SIZE_ON_DISK toBuffer:&tmp];
value = CFSwapInt32BigToHost(tmp);
} }
- (unsigned int)sizeOnDisk - (unsigned int)sizeOnDisk
{ {
return sizeof(value); return SIZE_ON_DISK;
} }
- (void)writeDataTo:(TemplateStream *)stream - (void)writeDataTo:(TemplateStream *)stream
{ {
[stream writeAmount:sizeof(value) fromBuffer:&value]; UInt32 tmp = CFSwapInt32HostToBig(value);
[stream writeAmount:SIZE_ON_DISK fromBuffer:&tmp];
} }
- (void)setValue:(UInt32)v - (void)setValue:(UInt32)v

View File

@ -1,5 +1,7 @@
#import "ElementUWRD.h" #import "ElementUWRD.h"
#define SIZE_ON_DISK (2)
@implementation ElementUWRD @implementation ElementUWRD
- (id)copyWithZone:(NSZone *)zone - (id)copyWithZone:(NSZone *)zone
@ -11,17 +13,20 @@
- (void)readDataFrom:(TemplateStream *)stream - (void)readDataFrom:(TemplateStream *)stream
{ {
[stream readAmount:sizeof(value) toBuffer:&value]; UInt16 tmp;
[stream readAmount:SIZE_ON_DISK toBuffer:&tmp];
value = CFSwapInt16BigToHost(tmp);
} }
- (unsigned int)sizeOnDisk - (unsigned int)sizeOnDisk
{ {
return sizeof(value); return SIZE_ON_DISK;
} }
- (void)writeDataTo:(TemplateStream *)stream - (void)writeDataTo:(TemplateStream *)stream
{ {
[stream writeAmount:sizeof(value) fromBuffer:&value]; UInt16 tmp = CFSwapInt16HostToBig(value);
[stream writeAmount:SIZE_ON_DISK fromBuffer:&tmp];
} }
- (void)setValue:(UInt16)v - (void)setValue:(UInt16)v

View File

@ -5,7 +5,8 @@
"Error: Hex Dump" = "Error: Dumping Hex"; "Error: Hex Dump" = "Error: Dumping Hex";
/* Keep changes dialog */ /* Keep changes dialog */
"Do you want to keep the changes you made to this resource?" = "Do you want to keep the changes you made to this resource?"; "KeepChangesDialogTitle" = "Do you want to keep the changes you made to this resource?";
"Keep" = "Keep"; "KeepChangesDialogMessage" = "Your changes cannot be saved later if you dont keep them.";
"Don't Keep" = "Dont Keep"; "KeepChangesButton" = "Keep";
"Your changes cannot be saved later if you don't keep them." = "Your changes cannot be saved later if you dont keep them."; "DiscardChangesButton" = "Discard";
"CancelButton" = "Cancel";

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>CFBundleDevelopmentRegion</key> <key>CFBundleDevelopmentRegion</key>
@ -15,7 +15,7 @@
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>ResK</string> <string>ResK</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>3</string> <string>4</string>
<key>NSPrincipalClass</key> <key>NSPrincipalClass</key>
<string>TemplateWindowController</string> <string>TemplateWindowController</string>
<key>RKSupportedTypes</key> <key>RKSupportedTypes</key>

View File

@ -1,6 +1,6 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
@class Element; @class Element, ElementOCNT;
@interface TemplateStream : NSObject @interface TemplateStream : NSObject
{ {
char *data; char *data;
@ -18,8 +18,8 @@
- (char *)data; - (char *)data;
- (unsigned int)bytesToGo; - (unsigned int)bytesToGo;
- (void)setBytesToGo:(unsigned int)b; - (void)setBytesToGo:(unsigned int)b;
- (Element *)counter; - (ElementOCNT *)counter;
- (void)pushCounter:(Element *)c; - (void)pushCounter:(ElementOCNT *)c;
- (void)popCounter; - (void)popCounter;
- (Element *)key; - (Element *)key;
- (void)pushKey:(Element *)k; - (void)pushKey:(Element *)k;

View File

@ -126,7 +126,7 @@
BOOL pushedCounter = NO; BOOL pushedCounter = NO;
BOOL pushedKey = NO; BOOL pushedKey = NO;
if(cc == [ElementOCNT class]) if(cc == [ElementOCNT class])
{ [stream pushCounter:clone]; pushedCounter = YES; } { [stream pushCounter:(ElementOCNT *)clone]; pushedCounter = YES; }
if(cc == [ElementKBYT class] || if(cc == [ElementKBYT class] ||
cc == [ElementKWRD class] || cc == [ElementKWRD class] ||
cc == [ElementKLNG class] ) cc == [ElementKLNG class] )
@ -156,7 +156,8 @@
if([[self window] isDocumentEdited]) if([[self window] isDocumentEdited])
{ {
NSBeginAlertSheet(NSLocalizedString(@"Do you want to keep the changes you made to this resource?", nil), NSLocalizedString(@"Keep", nil), NSLocalizedString(@"Don't Keep", nil), NSLocalizedString(@"Cancel", nil), sender, self, @selector(saveSheetDidClose:returnCode:contextInfo:), nil, nil, NSLocalizedString(@"Your changes cannot be saved later if you don't keep them.", nil)); NSBundle *bundle = [NSBundle bundleForClass:[self class]];
NSBeginAlertSheet(NSLocalizedStringFromTableInBundle(@"KeepChangesDialogTitle", nil, bundle, nil), NSLocalizedStringFromTableInBundle(@"KeepChangesButton", nil, bundle, nil), NSLocalizedStringFromTableInBundle(@"DiscardChangesButton", nil, bundle, nil), NSLocalizedStringFromTableInBundle(@"CancelButton", nil, bundle, nil), sender, self, @selector(saveSheetDidClose:returnCode:contextInfo:), nil, nil, NSLocalizedStringFromTableInBundle(@"KeepChangesDialogMessage", nil, bundle, nil));
return NO; return NO;
} }
else return YES; else return YES;
@ -307,7 +308,7 @@
#pragma mark - #pragma mark -
#pragma mark Menu Management #pragma mark Menu Management
// these next five methods are a crude hack - the items ought ot be in the responder chain themselves // these next five methods are a crude hack - the items ought to be in the responder chain themselves
- (IBAction)createListEntry:(id)sender; - (IBAction)createListEntry:(id)sender;
{ {
// This works by selecting an item that serves as a template (another LSTB), or knows how to create an item (LSTE) and passing the message on to it. // This works by selecting an item that serves as a template (another LSTB), or knows how to create an item (LSTE) and passing the message on to it.

View File

@ -28,7 +28,7 @@
<dict> <dict>
<key>orderedDocuments</key> <key>orderedDocuments</key>
<dict> <dict>
<key>AppleEventCode<</key> <key>AppleEventCode</key>
<string>docu</string> <string>docu</string>
<key>Type</key> <key>Type</key>
<string>ResourceDocument</string> <string>ResourceDocument</string>

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
#include "Initalisation.h" globals g; /*** INITALISE NEW EDITOR INSTANCE ***/ OSStatus Plug_InitInstance( Plug_PlugInRef plug, Plug_ResourceRef resource ) { // get system version OSStatus error = Gestalt( gestaltSystemVersion, &g.systemVersion ); if( error ) return error; // create window Rect creationBounds; WindowRef window; SetRect( &creationBounds, 0, 0, kDefaultWindowWidth, kDefaultWindowHeight ); OffsetRect( &creationBounds, 8, 48 ); WindowAttributes attributes = kWindowCloseBoxAttribute | kWindowCollapseBoxAttribute | kWindowStandardHandlerAttribute | kWindowInWindowMenuAttribute; if( g.systemVersion >= kMacOSX ) attributes |= kWindowLiveResizeAttribute; error = CreateNewWindow( kDocumentWindowClass, attributes, &creationBounds, &window ); // register mac window with host and retreive plug window Plug_WindowRef plugWindow = Host_RegisterWindow( plug, resource, window ); // cerate new pict window class PictWindowPtr pictWindow = new PictWindow( window ); // set window refCon to my class Host_SetWindowRefCon( plugWindow, (UInt32) pictWindow ); // set the window pic to the data handle PicHandle picture = (PicHandle) Host_GetResourceData( resource ); if( picture == null ) Host_DisplayError( "\pNo picture could be obtained.", "\p", 0 ); // get pict rect PictInfo pictInfo; GetPictInfo( picture, &pictInfo, 0, 0, 0, 0 ); Rect pictRect; pictRect.top = 0; pictRect.left = 0; pictRect.right = pictInfo.sourceRect.right - pictInfo.sourceRect.left; pictRect.bottom = pictInfo.sourceRect.bottom - pictInfo.sourceRect.top; SizeWindow( window, pictRect.right, pictRect.bottom, false ); #if TARGET_API_MAC_CARBON ControlRef picControl; // this is better than SetWindowPic() in Carbon ControlButtonContentInfo content; content.contentType = kControlContentPictHandle; content.u.picture = picture; // bug: if handle dissapears, control is fucked CreatePictureControl( window, &pictRect, &content, true, &picControl ); // DrawOneControl( picControl ); // bug: work around for bug in ControlManager /* HLockHi( picture ); SetControlData( picControl, kControlPicturePart, kControlPictureHandleTag, sizeof(picture), *picture ); */ #else SetWindowPic( window, picture ); // this doesn't work properly on X #endif // show window ShowWindow( window ); SelectWindow( window ); return error; } #include "Initalisation.h" globals g; /*** INITALISE NEW EDITOR INSTANCE ***/ OSStatus Plug_InitInstance( Plug_PlugInRef plug, Plug_ResourceRef resource ) { // get system version OSStatus error = Gestalt( gestaltSystemVersion, &g.systemVersion ); if( error ) return error; // create window Rect creationBounds; WindowRef window; SetRect( &creationBounds, 0, 0, kDefaultWindowWidth, kDefaultWindowHeight ); OffsetRect( &creationBounds, 8, 48 ); WindowAttributes attributes = kWindowCloseBoxAttribute | kWindowCollapseBoxAttribute | kWindowStandardHandlerAttribute | kWindowInWindowMenuAttribute; if( g.systemVersion >= kMacOSX ) attributes |= kWindowLiveResizeAttribute; error = CreateNewWindow( kDocumentWindowClass, attributes, &creationBounds, &window ); // register mac window with host and retrieve plug window Plug_WindowRef plugWindow = Host_RegisterWindow( plug, resource, window ); // cerate new pict window class PictWindowPtr pictWindow = new PictWindow( window ); // set window refCon to my class Host_SetWindowRefCon( plugWindow, (UInt32) pictWindow ); // set the window pic to the data handle PicHandle picture = (PicHandle) Host_GetResourceData( resource ); if( picture == null ) Host_DisplayError( "\pNo picture could be obtained.", "\p", 0 ); // get pict rect PictInfo pictInfo; GetPictInfo( picture, &pictInfo, 0, 0, 0, 0 ); Rect pictRect; pictRect.top = 0; pictRect.left = 0; pictRect.right = pictInfo.sourceRect.right - pictInfo.sourceRect.left; pictRect.bottom = pictInfo.sourceRect.bottom - pictInfo.sourceRect.top; SizeWindow( window, pictRect.right, pictRect.bottom, false ); #if TARGET_API_MAC_CARBON ControlRef picControl; // this is better than SetWindowPic() in Carbon ControlButtonContentInfo content; content.contentType = kControlContentPictHandle; content.u.picture = picture; // bug: if handle dissapears, control is fucked CreatePictureControl( window, &pictRect, &content, true, &picControl ); // DrawOneControl( picControl ); // bug: work around for bug in ControlManager /* HLockHi( picture ); SetControlData( picControl, kControlPicturePart, kControlPictureHandleTag, sizeof(picture), *picture ); */ #else SetWindowPic( window, picture ); // this doesn't work properly on X #endif // show window ShowWindow( window ); SelectWindow( window ); return error; }

View File

@ -72,7 +72,7 @@ ResKnife methods, functions, headers, classes, ivars and practically anything el
@abstract @abstract
@author @author
@created @created
@change [reverse chronological, i.e. most recent at the top] @updated [reverse chronological, i.e. most recent at the top]
... ...
@pending [higher priority TODO items should be above lower priority ones] @pending [higher priority TODO items should be above lower priority ones]
... ...

View File

@ -7,7 +7,7 @@
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
0E85D4AC10A72953004240C0 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 3D2EE5E204E5C56F00515930 /* Localizable.strings */; }; 0EF71540122BD0D0005DF94E /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 0EF7153F122BD0D0005DF94E /* Localizable.strings */; };
E1193609099830D300A3A6EA /* FontDocument.nib in Resources */ = {isa = PBXBuildFile; fileRef = E1193607099830D200A3A6EA /* FontDocument.nib */; }; E1193609099830D300A3A6EA /* FontDocument.nib in Resources */ = {isa = PBXBuildFile; fileRef = E1193607099830D200A3A6EA /* FontDocument.nib */; };
E119363A099833AE00A3A6EA /* Categories.h in Headers */ = {isa = PBXBuildFile; fileRef = E1193638099833AE00A3A6EA /* Categories.h */; }; E119363A099833AE00A3A6EA /* Categories.h in Headers */ = {isa = PBXBuildFile; fileRef = E1193638099833AE00A3A6EA /* Categories.h */; };
E119363B099833AE00A3A6EA /* Categories.mm in Sources */ = {isa = PBXBuildFile; fileRef = E1193639099833AE00A3A6EA /* Categories.mm */; }; E119363B099833AE00A3A6EA /* Categories.mm in Sources */ = {isa = PBXBuildFile; fileRef = E1193639099833AE00A3A6EA /* Categories.mm */; };
@ -302,7 +302,7 @@
E18BF6AD069FEA1800F076B8 /* ElementOCNT.h in Headers */ = {isa = PBXBuildFile; fileRef = 3D50046F04EF040900F3B64D /* ElementOCNT.h */; }; E18BF6AD069FEA1800F076B8 /* ElementOCNT.h in Headers */ = {isa = PBXBuildFile; fileRef = 3D50046F04EF040900F3B64D /* ElementOCNT.h */; };
E18BF6AE069FEA1800F076B8 /* ElementLSTC.h in Headers */ = {isa = PBXBuildFile; fileRef = 3D50047404EF122000F3B64D /* ElementLSTC.h */; }; E18BF6AE069FEA1800F076B8 /* ElementLSTC.h in Headers */ = {isa = PBXBuildFile; fileRef = 3D50047404EF122000F3B64D /* ElementLSTC.h */; };
E18BF6B0069FEA1800F076B8 /* TemplateWindow.nib in Resources */ = {isa = PBXBuildFile; fileRef = 3D0B38B504DEF465005AED5E /* TemplateWindow.nib */; }; E18BF6B0069FEA1800F076B8 /* TemplateWindow.nib in Resources */ = {isa = PBXBuildFile; fileRef = 3D0B38B504DEF465005AED5E /* TemplateWindow.nib */; };
E18BF6B4069FEA1800F076B8 /* TemplateWindowController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3D0B38B304DEF41E005AED5E /* TemplateWindowController.mm */; }; E18BF6B4069FEA1800F076B8 /* TemplateWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D0B38B304DEF41E005AED5E /* TemplateWindowController.m */; };
E18BF6B5069FEA1800F076B8 /* Notifications.m in Sources */ = {isa = PBXBuildFile; fileRef = F5C9ECCE027F474A01A8010C /* Notifications.m */; }; E18BF6B5069FEA1800F076B8 /* Notifications.m in Sources */ = {isa = PBXBuildFile; fileRef = F5C9ECCE027F474A01A8010C /* Notifications.m */; };
E18BF6B6069FEA1800F076B8 /* Element.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D0933A704DEFEE600DD74B1 /* Element.m */; }; E18BF6B6069FEA1800F076B8 /* Element.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D0933A704DEFEE600DD74B1 /* Element.m */; };
E18BF6B8069FEA1800F076B8 /* TemplateStream.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D0933BF04DF151C00DD74B1 /* TemplateStream.m */; }; E18BF6B8069FEA1800F076B8 /* TemplateStream.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D0933BF04DF151C00DD74B1 /* TemplateStream.m */; };
@ -430,9 +430,9 @@
3D0ABFB904E152CA00C85300 /* Read Me.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "Read Me.txt"; sourceTree = "<group>"; }; 3D0ABFB904E152CA00C85300 /* Read Me.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "Read Me.txt"; sourceTree = "<group>"; };
3D0ABFBC04E172F700C85300 /* README.txt */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = README.txt; sourceTree = SOURCE_ROOT; }; 3D0ABFBC04E172F700C85300 /* README.txt */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = README.txt; sourceTree = SOURCE_ROOT; };
3D0B38B204DEF41E005AED5E /* TemplateWindowController.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = TemplateWindowController.h; sourceTree = "<group>"; }; 3D0B38B204DEF41E005AED5E /* TemplateWindowController.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = TemplateWindowController.h; sourceTree = "<group>"; };
3D0B38B304DEF41E005AED5E /* TemplateWindowController.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = TemplateWindowController.mm; sourceTree = "<group>"; }; 3D0B38B304DEF41E005AED5E /* TemplateWindowController.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = TemplateWindowController.m; sourceTree = "<group>"; };
3D0B38B604DEF465005AED5E /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/TemplateWindow.nib; sourceTree = "<group>"; }; 3D0B38B604DEF465005AED5E /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/TemplateWindow.nib; sourceTree = "<group>"; };
3D2EE5E204E5C56F00515930 /* Localizable.strings */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; path = Localizable.strings; sourceTree = "<group>"; }; 3D2EE5E204E5C56F00515930 /* English */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/Localizable.strings; sourceTree = "<group>"; };
3D35755A04DAEB4300B8225B /* main.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; }; 3D35755A04DAEB4300B8225B /* main.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
3D35755C04DAEB6200B8225B /* RKEditorRegistry.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RKEditorRegistry.h; sourceTree = "<group>"; }; 3D35755C04DAEB6200B8225B /* RKEditorRegistry.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RKEditorRegistry.h; sourceTree = "<group>"; };
3D35755D04DAEB6200B8225B /* RKEditorRegistry.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = RKEditorRegistry.m; sourceTree = "<group>"; }; 3D35755D04DAEB6200B8225B /* RKEditorRegistry.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = RKEditorRegistry.m; sourceTree = "<group>"; };
@ -607,7 +607,7 @@
F5B5883B0156D40B01000001 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/InfoWindow.nib; sourceTree = "<group>"; }; F5B5883B0156D40B01000001 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/InfoWindow.nib; sourceTree = "<group>"; };
F5B5883F0156D40B01000001 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/PrefsWindow.nib; sourceTree = "<group>"; }; F5B5883F0156D40B01000001 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/PrefsWindow.nib; sourceTree = "<group>"; };
F5B588410156D40B01000001 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/ResourceDocument.nib; sourceTree = "<group>"; }; F5B588410156D40B01000001 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/ResourceDocument.nib; sourceTree = "<group>"; };
F5B588430156D40B01000001 /* English */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; }; F5B588430156D40B01000001 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
F5B588450156D40B01000001 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; lineEnding = 0; name = English; path = English.lproj/Localizable.strings; sourceTree = "<group>"; }; F5B588450156D40B01000001 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; lineEnding = 0; name = English; path = English.lproj/Localizable.strings; sourceTree = "<group>"; };
F5B588460156D40B01000001 /* ResKnife.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = ResKnife.icns; sourceTree = "<group>"; }; F5B588460156D40B01000001 /* ResKnife.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = ResKnife.icns; sourceTree = "<group>"; };
F5B588470156D40B01000001 /* Resource file.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = "Resource file.icns"; sourceTree = "<group>"; }; F5B588470156D40B01000001 /* Resource file.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = "Resource file.icns"; sourceTree = "<group>"; };
@ -881,7 +881,7 @@
children = ( children = (
3D0ABFB904E152CA00C85300 /* Read Me.txt */, 3D0ABFB904E152CA00C85300 /* Read Me.txt */,
3D0B38B204DEF41E005AED5E /* TemplateWindowController.h */, 3D0B38B204DEF41E005AED5E /* TemplateWindowController.h */,
3D0B38B304DEF41E005AED5E /* TemplateWindowController.mm */, 3D0B38B304DEF41E005AED5E /* TemplateWindowController.m */,
3D0933BE04DF151C00DD74B1 /* TemplateStream.h */, 3D0933BE04DF151C00DD74B1 /* TemplateStream.h */,
3D0933BF04DF151C00DD74B1 /* TemplateStream.m */, 3D0933BF04DF151C00DD74B1 /* TemplateStream.m */,
3D0933A604DEFEE600DD74B1 /* Element.h */, 3D0933A604DEFEE600DD74B1 /* Element.h */,
@ -890,7 +890,7 @@
E1A984F7099C2D7F00A70612 /* Resources */, E1A984F7099C2D7F00A70612 /* Resources */,
E11937F309991C1100A3A6EA /* Support Resources */, E11937F309991C1100A3A6EA /* Support Resources */,
E18BFA3606A20B7A00F076B8 /* Info.plist */, E18BFA3606A20B7A00F076B8 /* Info.plist */,
3D2EE5E204E5C56F00515930 /* Localizable.strings */, 0EF7153F122BD0D0005DF94E /* Localizable.strings */,
); );
path = "Template Editor"; path = "Template Editor";
sourceTree = "<group>"; sourceTree = "<group>";
@ -2046,7 +2046,7 @@
files = ( files = (
E18BF6B0069FEA1800F076B8 /* TemplateWindow.nib in Resources */, E18BF6B0069FEA1800F076B8 /* TemplateWindow.nib in Resources */,
E1A984FE099C309400A70612 /* DisplayTMPL.png in Resources */, E1A984FE099C309400A70612 /* DisplayTMPL.png in Resources */,
0E85D4AC10A72953004240C0 /* Localizable.strings in Resources */, 0EF71540122BD0D0005DF94E /* Localizable.strings in Resources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -2326,7 +2326,7 @@
isa = PBXSourcesBuildPhase; isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
E18BF6B4069FEA1800F076B8 /* TemplateWindowController.mm in Sources */, E18BF6B4069FEA1800F076B8 /* TemplateWindowController.m in Sources */,
E18BF6B5069FEA1800F076B8 /* Notifications.m in Sources */, E18BF6B5069FEA1800F076B8 /* Notifications.m in Sources */,
E18BF6B6069FEA1800F076B8 /* Element.m in Sources */, E18BF6B6069FEA1800F076B8 /* Element.m in Sources */,
E18BF6B8069FEA1800F076B8 /* TemplateStream.m in Sources */, E18BF6B8069FEA1800F076B8 /* TemplateStream.m in Sources */,
@ -2383,6 +2383,14 @@
/* End PBXTargetDependency section */ /* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */ /* Begin PBXVariantGroup section */
0EF7153F122BD0D0005DF94E /* Localizable.strings */ = {
isa = PBXVariantGroup;
children = (
3D2EE5E204E5C56F00515930 /* English */,
);
name = Localizable.strings;
sourceTree = "<group>";
};
3D0B38B504DEF465005AED5E /* TemplateWindow.nib */ = { 3D0B38B504DEF465005AED5E /* TemplateWindow.nib */ = {
isa = PBXVariantGroup; isa = PBXVariantGroup;
children = ( children = (
@ -3300,6 +3308,8 @@
E13F7F0708F0411100E2A5CB /* Release */ = { E13F7F0708F0411100E2A5CB /* Release */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_BIT_PRE_XCODE_3_1)";
ARCHS_STANDARD_32_BIT_PRE_XCODE_3_1 = "ppc i386";
GCC_VERSION = 4.0; GCC_VERSION = 4.0;
SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk;
}; };

View File

@ -6,3 +6,12 @@ Auto-uncollapse list items in template editor when they are created and when a r
Add preference to "Show Resource Fork even if empty." Add preference to "Show Resource Fork even if empty."
Add viewers for MooV and PICT. Add viewers for MooV and PICT.
Modify -[Resource data] and -[Resource setData] to use ResourceManager functions behind the scenes instead of an NSData object. This should fix the problem with new resources not being saved at times. Modify -[Resource data] and -[Resource setData] to use ResourceManager functions behind the scenes instead of an NSData object. This should fix the problem with new resources not being saved at times.
// some old to-dos. don't know if these still apply
-> "Open as Hex" displays "(null)" as the document name. Why?
-> Changing the type/creator of a file isn't written to disk by ResourceDocument.
-> Create small versions of the doc icons in Photoshop instead of letting IconComposer use its cheap scaling on them.
-> Auto-uncollapse list items in template editor when they are created and when a resource is opened.
-> Template editor should maintain "dirty" flag for resource.