Compare commits

...

No commits in common. "0.5" and "master" have entirely different histories.
0.5 ... master

298 changed files with 15979 additions and 19583 deletions

10
.gitignore vendored Normal file
View File

@ -0,0 +1,10 @@
.DS_Store
*~
*~.nib
build/
*.pbxuser
*.mode1v3
*.mode2v3
*.perspectivev3
*.xcworkspace/
xcuserdata/

File diff suppressed because it is too large Load Diff

View File

@ -15,23 +15,23 @@
/*!
@function InitToolbox
*/
OSStatus InitToolbox( void );
OSStatus InitToolbox(void);
/*!
@function InitMenubar
*/
OSStatus InitMenubar( void );
OSStatus InitMenubar(void);
/*!
@function InitAppleEvents
*/
OSStatus InitAppleEvents( void );
OSStatus InitAppleEvents(void);
/*!
@function InitCarbonEvents
*/
OSStatus InitCarbonEvents( void );
OSStatus InitCarbonEvents(void);
/*!
@function InitGlobals
*/
OSStatus InitGlobals( void );
OSStatus InitGlobals(void);
/*****************/
/* EVENT PARSING */
@ -42,22 +42,22 @@ OSStatus InitGlobals( void );
/*!
@function ParseEvents
*/
OSStatus ParseEvents( EventRecord *event );
OSStatus ParseEvents(EventRecord *event);
/*!
@function ParseDialogEvents
*/
pascal Boolean ParseDialogEvents( DialogPtr dialog, EventRecord *event, DialogItemIndex *itemHit );
pascal Boolean ParseDialogEvents(DialogPtr dialog, EventRecord *event, DialogItemIndex *itemHit);
/*!
@function ParseOSEvents
*/
OSStatus ParseOSEvents( EventRecord *event );
OSStatus ParseOSEvents(EventRecord *event);
#endif
/*!
@function ParseAppleEvents
*/
pascal OSErr ParseAppleEvents( const AppleEvent *event, AppleEvent *reply, SInt32 refCon );
pascal OSErr ParseAppleEvents(const AppleEvent *event, AppleEvent *reply, SInt32 refCon);
/******************/
/* EVENT HANDLING */
@ -68,42 +68,42 @@ pascal OSErr ParseAppleEvents( const AppleEvent *event, AppleEvent *reply, SInt
/*!
@function MouseDownEventOccoured
*/
OSStatus MouseDownEventOccoured( EventRecord *event );
OSStatus MouseDownEventOccoured(EventRecord *event);
/*!
@function MouseUpEventOccoured
*/
OSStatus MouseUpEventOccoured( EventRecord *event );
OSStatus MouseUpEventOccoured(EventRecord *event);
/*!
@function KeyDownEventOccoured
*/
OSStatus KeyDownEventOccoured( EventRecord *event );
OSStatus KeyDownEventOccoured(EventRecord *event);
/*!
@function KeyRepeatEventOccoured
*/
OSStatus KeyRepeatEventOccoured( EventRecord *event );
OSStatus KeyRepeatEventOccoured(EventRecord *event);
/*!
@function KeyUpEventOccoured
*/
OSStatus KeyUpEventOccoured( EventRecord *event );
OSStatus KeyUpEventOccoured(EventRecord *event);
/*!
@function UpdateEventOccoured
*/
OSStatus UpdateEventOccoured( EventRecord *event );
OSStatus UpdateEventOccoured(EventRecord *event);
/*!
@function ActivateEventOccoured
*/
OSStatus ActivateEventOccoured( EventRecord *event );
OSStatus ActivateEventOccoured(EventRecord *event);
/*!
@function IdleEvent
*/
OSStatus IdleEvent( void );
OSStatus IdleEvent(void);
#endif
/*!
@function QuitResKnife
*/
void QuitResKnife( void );
void QuitResKnife(void);
/*****************/
/* MENU HANDLING */
@ -114,26 +114,26 @@ void QuitResKnife( void );
/*!
@function CarbonEventUpdateMenus
*/
pascal OSStatus CarbonEventUpdateMenus( EventHandlerCallRef callRef, EventRef event, void *userData );
pascal OSStatus CarbonEventUpdateMenus(EventHandlerCallRef callRef, EventRef event, void *userData);
/*!
@function CarbonEventParseMenuSelection
*/
pascal OSStatus CarbonEventParseMenuSelection( EventHandlerCallRef callRef, EventRef event, void *userData );
pascal OSStatus CarbonEventParseMenuSelection(EventHandlerCallRef callRef, EventRef event, void *userData);
/*!
@function DefaultIdleTimer
*/
pascal void DefaultIdleTimer( EventLoopTimerRef timer, void *data );
pascal void DefaultIdleTimer(EventLoopTimerRef timer, void *data);
#else
/*!
@function UpdateMenus
*/
OSStatus UpdateMenus( WindowRef window );
OSStatus UpdateMenus(WindowRef window);
/*!
@function ParseMenuSelection
*/
OSStatus ParseMenuSelection( UInt16 menu, UInt16 item );
OSStatus ParseMenuSelection(UInt16 menu, UInt16 item);
#endif
@ -144,19 +144,19 @@ OSStatus ParseMenuSelection( UInt16 menu, UInt16 item );
/*!
@function AppleEventSendSelf
*/
OSStatus AppleEventSendSelf( DescType eventClass, DescType eventID, AEDescList list );
OSStatus AppleEventSendSelf(DescType eventClass, DescType eventID, AEDescList list);
/*!
@function GotRequiredParams
*/
Boolean GotRequiredParams( const AppleEvent *event );
Boolean GotRequiredParams(const AppleEvent *event);
/*!
@function AppleEventOpen
*/
OSStatus AppleEventOpen( const AppleEvent *event );
OSStatus AppleEventOpen(const AppleEvent *event);
/*!
@function AppleEventPrint
*/
OSStatus AppleEventPrint( const AppleEvent *event );
OSStatus AppleEventPrint(const AppleEvent *event);
/*********************/
/* NIBÑBASED WINDOWS */
@ -165,14 +165,14 @@ OSStatus AppleEventPrint( const AppleEvent *event );
/*!
@function ShowAboutBox
*/
OSStatus ShowAboutBox( void );
OSStatus ShowAboutBox(void);
/*!
@function ShowPrefsWindow
*/
OSStatus ShowPrefsWindow( void );
OSStatus ShowPrefsWindow(void);
/*!
@function PrefsTabEventHandler
*/
pascal OSStatus PrefsTabEventHandler( EventHandlerCallRef handlerRef, EventRef event, void* userData );
pascal OSStatus PrefsTabEventHandler(EventHandlerCallRef handlerRef, EventRef event, void* userData);
#endif

File diff suppressed because it is too large Load Diff

View File

@ -94,28 +94,28 @@ typedef struct
} SHInputVars;
// Initialization, idle, and termination
pascal OSErr SHInitSoundHelper( Boolean *attnFlag, short numChannels );
pascal void SHIdle( void );
pascal void SHKillSoundHelper(void );
pascal OSErr SHInitSoundHelper(Boolean *attnFlag, short numChannels);
pascal void SHIdle(void);
pascal void SHKillSoundHelper(void);
// Easy sound output
pascal OSErr SHPlayByID( short resID, long *refNum );
pascal OSErr SHPlayByHandle( Handle sound, long *refNum );
pascal OSErr SHPlayStop( long refNum );
pascal OSErr SHPlayStopAll( void );
pascal OSErr SHPlayByID(short resID, long *refNum);
pascal OSErr SHPlayByHandle(Handle sound, long *refNum);
pascal OSErr SHPlayStop(long refNum);
pascal OSErr SHPlayStopAll(void);
// Advanced sound output
pascal OSErr SHPlayPause( long refNum );
pascal OSErr SHPlayContinue( long refNum );
pascal SHPlayStat SHPlayStatus( long refNum );
pascal OSErr SHGetChannel( long refNum, SndChannelPtr *channel );
pascal OSErr SHPlayPause(long refNum);
pascal OSErr SHPlayContinue(long refNum);
pascal SHPlayStat SHPlayStatus(long refNum);
pascal OSErr SHGetChannel(long refNum, SndChannelPtr *channel);
// Easy sound input
pascal OSErr SHRecordStart( short maxK, OSType quality, Boolean *doneFlag );
pascal OSErr SHGetRecordedSound( Handle *theSound );
pascal OSErr SHRecordStop( void );
pascal OSErr SHRecordStart(short maxK, OSType quality, Boolean *doneFlag);
pascal OSErr SHGetRecordedSound(Handle *theSound);
pascal OSErr SHRecordStop(void);
// Advanced sound input
pascal OSErr SHRecordPause( void );
pascal OSErr SHRecordContinue( void );
pascal OSErr SHRecordStatus( SHRecordStatusRec *recordStatus );
pascal OSErr SHRecordPause(void);
pascal OSErr SHRecordContinue(void);
pascal OSErr SHRecordStatus(SHRecordStatusRec *recordStatus);

View File

@ -9,73 +9,73 @@ extern globals g;
#if TARGET_API_MAC_CARBON // CarbonLib 1.1+ or Public Beta only
/*** INITALISE DATA BROWSER ***/
OSStatus FileWindow::InitDataBrowser( void )
OSStatus FileWindow::InitDataBrowser(void)
{
OSStatus error = noErr;
// get the db control - compatable with both CarbonLib and nib based versions
ControlID id = { kDataBrowserSignature, 0 };
GetControlByID( window, &id, &dataBrowser );
GetControlByID(window, &id, &dataBrowser);
// set control ref to FileWindow
SetControlReference( dataBrowser, (long) this );
SetControlReference(dataBrowser, (long) this);
// turn off frame and focus
Boolean frame = false;
SetControlData( dataBrowser, kControlNoPart, kControlDataBrowserIncludesFrameAndFocusTag, sizeof(Boolean), &frame );
SetControlData(dataBrowser, kControlNoPart, kControlDataBrowserIncludesFrameAndFocusTag, sizeof(Boolean), &frame);
#if !USE_NIBS
// add empty columns
AddDataBrowserColumn( dataBrowser, kDBNameColumn, 0 ); // save column order into prefs file: Get/SetDataBrowserUserState()
AddDataBrowserColumn( dataBrowser, kDBTypeColumn, 1 );
AddDataBrowserColumn( dataBrowser, kDBIDColumn, 2 );
AddDataBrowserColumn( dataBrowser, kDBSizeColumn, 3 );
AddDataBrowserColumn(dataBrowser, kDBNameColumn, 0); // save column order into prefs file: Get/SetDataBrowserUserState()
AddDataBrowserColumn(dataBrowser, kDBTypeColumn, 1);
AddDataBrowserColumn(dataBrowser, kDBIDColumn, 2);
AddDataBrowserColumn(dataBrowser, kDBSizeColumn, 3);
#endif
// add callbacks
DataBrowserCallbacks theCallbacks;
theCallbacks.version = kDataBrowserLatestCallbacks;
InitDataBrowserCallbacks( &theCallbacks );
theCallbacks.u.v1.itemDataCallback = NewDataBrowserItemDataUPP( DataBrowserItemData );
theCallbacks.u.v1.itemCompareCallback = NewDataBrowserItemCompareUPP( SortDataBrowser );
theCallbacks.u.v1.itemNotificationCallback = NewDataBrowserItemNotificationUPP( DataBrowserMessage );
theCallbacks.u.v1.addDragItemCallback = NewDataBrowserAddDragItemUPP( DataBrowserAddDragItem );
theCallbacks.u.v1.acceptDragCallback = NewDataBrowserAcceptDragUPP( DataBrowserAcceptDrag );
theCallbacks.u.v1.receiveDragCallback = NewDataBrowserReceiveDragUPP( DataBrowserReceiveDrag );
theCallbacks.u.v1.postProcessDragCallback = NewDataBrowserPostProcessDragUPP( DataBrowserPostProcessDrag );
SetDataBrowserCallbacks( dataBrowser, &theCallbacks );
InitDataBrowserCallbacks(&theCallbacks);
theCallbacks.u.v1.itemDataCallback = NewDataBrowserItemDataUPP(DataBrowserItemData);
theCallbacks.u.v1.itemCompareCallback = NewDataBrowserItemCompareUPP(SortDataBrowser);
theCallbacks.u.v1.itemNotificationCallback = NewDataBrowserItemNotificationUPP(DataBrowserMessage);
theCallbacks.u.v1.addDragItemCallback = NewDataBrowserAddDragItemUPP(DataBrowserAddDragItem);
theCallbacks.u.v1.acceptDragCallback = NewDataBrowserAcceptDragUPP(DataBrowserAcceptDrag);
theCallbacks.u.v1.receiveDragCallback = NewDataBrowserReceiveDragUPP(DataBrowserReceiveDrag);
theCallbacks.u.v1.postProcessDragCallback = NewDataBrowserPostProcessDragUPP(DataBrowserPostProcessDrag);
SetDataBrowserCallbacks(dataBrowser, &theCallbacks);
// setup rest of browser, inc. adding all resources
DataBrowserItemID item;
for( UInt32 n = 1; n <= numResources; n++ )
for(UInt32 n = 1; n <= numResources; n++)
{
item = n;
error = AddDataBrowserItems( dataBrowser, kDataBrowserNoItem, 1, &item, kDataBrowserItemNoProperty );
if( error ) DebugError( "\pError occoured adding resource to data browser." );
error = AddDataBrowserItems(dataBrowser, kDataBrowserNoItem, 1, &item, kDataBrowserItemNoProperty);
if(error) DebugError("\pError occoured adding resource to data browser.");
}
// add data fork if present
if( resourceMap->RepresentsDataFork() ) // requires data fork to be first in chain
if(resourceMap->RepresentsDataFork()) // requires data fork to be first in chain
{
item = kDataBrowserDataForkItem; // curently 0xFFFFFFFF
error = AddDataBrowserItems( dataBrowser, kDataBrowserNoItem, 1, &item, kDataBrowserItemNoProperty );
if( error ) DebugError( "\pError occoured adding data fork to data browser." );
error = AddDataBrowserItems(dataBrowser, kDataBrowserNoItem, 1, &item, kDataBrowserItemNoProperty);
if(error) DebugError("\pError occoured adding data fork to data browser.");
}
SetDataBrowserSortProperty( dataBrowser, kDBTypeColumn );
SetDataBrowserTableViewRowHeight( dataBrowser, 16 +2 );
SetDataBrowserListViewDisclosureColumn( dataBrowser, kDBNameColumn, true );
SetDataBrowserSortProperty(dataBrowser, kDBTypeColumn);
SetDataBrowserTableViewRowHeight(dataBrowser, 16 +2);
SetDataBrowserListViewDisclosureColumn(dataBrowser, kDBNameColumn, true);
// set up drag tracking
SetControlDragTrackingEnabled( dataBrowser, true );
SetControlDragTrackingEnabled(dataBrowser, true);
return error;
}
/*** ADD DATA BROWSER COLUMN ***/
void AddDataBrowserColumn( ControlRef browser, DataBrowserPropertyID column, UInt16 position )
void AddDataBrowserColumn(ControlRef browser, DataBrowserPropertyID column, UInt16 position)
{
DataBrowserListViewColumnDesc columnDesc;
switch( column )
switch(column)
{
case kDataBrowserNameColumn:
columnDesc.propertyDesc.propertyID = kDataBrowserNameColumn;
@ -151,110 +151,110 @@ void AddDataBrowserColumn( ControlRef browser, DataBrowserPropertyID column, UIn
}
// create column and make respond to sorting
AddDataBrowserListViewColumn( browser, &columnDesc, position );
AddDataBrowserListViewColumn(browser, &columnDesc, position);
}
/*** HANDLE ITEM DATA I/O ***/
pascal OSStatus DataBrowserItemData( ControlRef browser, DataBrowserItemID itemID, DataBrowserPropertyID property, DataBrowserItemDataRef itemData, Boolean setValue )
pascal OSStatus DataBrowserItemData(ControlRef browser, DataBrowserItemID itemID, DataBrowserPropertyID property, DataBrowserItemDataRef itemData, Boolean setValue)
{
#pragma unused( setValue )
#pragma unused(setValue)
OSStatus result = noErr;
if( setValue ) return result;
FileWindowPtr file = (FileWindowPtr) GetControlReference( browser );
ResourceObjectPtr resource = file->GetResource( itemID );
if(setValue) return result;
FileWindowPtr file = (FileWindowPtr) GetControlReference(browser);
ResourceObjectPtr resource = file->GetResource(itemID);
if( resource == null )
DebugError( "\pNull resource returned within DataBrowserItemData()" );
if(resource == null)
DebugError("\pNull resource returned within DataBrowserItemData()");
switch( property )
switch(property)
{
case kDataBrowserItemIsEditableProperty:
if( true ) // should item be editable? (i.e. is it a name, ID or type?)
SetDataBrowserItemDataBooleanValue( itemData, true );
if(true) // should item be editable? (i.e. is it a name, ID or type?)
SetDataBrowserItemDataBooleanValue(itemData, true);
break;
case kDataBrowserItemIsContainerProperty:
if( resource->Type() == kIconFamilyType )
SetDataBrowserItemDataBooleanValue( itemData, true );
if(resource->Type() == kIconFamilyType)
SetDataBrowserItemDataBooleanValue(itemData, true);
break;
case kDBNameColumn:
{ // icon Ñ no resource for the icon!
IconRef theIcon = null;
#if !USE_NIBS
if( itemID != kDataBrowserDataForkItem )
if(itemID != kDataBrowserDataForkItem)
{
Str255 iconString;
TypeToPString( resource->Type(), iconString );
IconFamilyHandle iconFamily = (IconFamilyHandle) Get1NamedResource( kIconFamilyType, iconString );
if( iconFamily )
TypeToPString(resource->Type(), iconString);
IconFamilyHandle iconFamily = (IconFamilyHandle) Get1NamedResource(kIconFamilyType, iconString);
if(iconFamily)
{
RegisterIconRefFromIconFamily( kResKnifeCreator, resource->Type(), iconFamily, &theIcon );
ReleaseResource( (Handle) iconFamily ); // when dragging a rect this call caused other columns not to be displayed !?!
RegisterIconRefFromIconFamily(kResKnifeCreator, resource->Type(), iconFamily, &theIcon);
ReleaseResource((Handle) iconFamily); // when dragging a rect this call caused other columns not to be displayed !?!
}
}
#endif
if( theIcon == null )
GetIconRef( kOnSystemDisk, kResKnifeCreator, kResourceFileType, &theIcon );
SetDataBrowserItemDataIcon( itemData, theIcon );
ReleaseIconRef( theIcon );
if(theIcon == null)
GetIconRef(kOnSystemDisk, kResKnifeCreator, kResourceFileType, &theIcon);
SetDataBrowserItemDataIcon(itemData, theIcon);
ReleaseIconRef(theIcon);
// resource name
CFStringRef nameCFStr;
if( itemID == kDataBrowserDataForkItem )
if(itemID == kDataBrowserDataForkItem)
{
#if USE_NIBS // OS 9 version is not bundled at the present time
nameCFStr = CFBundleCopyLocalizedString( CFBundleGetMainBundle(), CFSTR("Data Fork"), null, null ); // bug: doesn't actually get localized string!
nameCFStr = CFBundleCopyLocalizedString(CFBundleGetMainBundle(), CFSTR("Data Fork"), null, null); // bug: doesn't actually get localized string!
#else
nameCFStr = CFSTR("Data Fork");
#endif
SetDataBrowserItemDataRGBColor( itemData, &g.textColour );
SetDataBrowserItemDataRGBColor(itemData, &g.textColour);
}
else if( *resource->Name() == 0x00 )
else if(*resource->Name() == 0x00)
{
#if USE_NIBS // OS 9 version is not bundled at the present time
nameCFStr = CFBundleCopyLocalizedString( CFBundleGetMainBundle(), CFSTR("Untitled Resource"), null, null ); // bug: doesn't actually get localized string!
nameCFStr = CFBundleCopyLocalizedString(CFBundleGetMainBundle(), CFSTR("Untitled Resource"), null, null); // bug: doesn't actually get localized string!
#else
nameCFStr = CFSTR("Untitled Resource");
#endif
SetDataBrowserItemDataRGBColor( itemData, &g.textColour );
SetDataBrowserItemDataRGBColor(itemData, &g.textColour);
}
else nameCFStr = CFStringCreateWithPascalString( CFAllocatorGetDefault(), resource->Name(), kCFStringEncodingMacRoman );
SetDataBrowserItemDataText( itemData, nameCFStr );
else nameCFStr = CFStringCreateWithPascalString(CFAllocatorGetDefault(), resource->Name(), kCFStringEncodingMacRoman);
SetDataBrowserItemDataText(itemData, nameCFStr);
#if USE_NIBS // OS 9 uses CFSTR()
CFRelease( nameCFStr );
CFRelease(nameCFStr);
#endif
} break;
case kDBTypeColumn:
{ // resource type
if( itemID == kDataBrowserDataForkItem )
if(itemID == kDataBrowserDataForkItem)
{
SetDataBrowserItemDataText( itemData, CFSTR("-") );
SetDataBrowserItemDataText(itemData, CFSTR("-"));
}
else
{
CFStringRef typeString;
TypeToCFString( resource->Type(), &typeString );
SetDataBrowserItemDataText( itemData, typeString );
CFRelease( typeString );
TypeToCFString(resource->Type(), &typeString);
SetDataBrowserItemDataText(itemData, typeString);
CFRelease(typeString);
}
} break;
case kDBIDColumn:
{ // resource ID
if( itemID == kDataBrowserDataForkItem )
if(itemID == kDataBrowserDataForkItem)
{
SetDataBrowserItemDataText( itemData, CFSTR("-") );
SetDataBrowserItemDataText(itemData, CFSTR("-"));
}
else
{
SInt16 id = resource->ID();
Str255 idPString;
NumToString( id, (StringPtr) &idPString );
CFStringRef idString = CFStringCreateWithPascalString( CFAllocatorGetDefault(), idPString, kCFStringEncodingMacRoman );
SetDataBrowserItemDataText( itemData, idString );
CFRelease( idString );
NumToString(id, (StringPtr) &idPString);
CFStringRef idString = CFStringCreateWithPascalString(CFAllocatorGetDefault(), idPString, kCFStringEncodingMacRoman);
SetDataBrowserItemDataText(itemData, idString);
CFRelease(idString);
}
} break;
@ -262,28 +262,28 @@ pascal OSStatus DataBrowserItemData( ControlRef browser, DataBrowserItemID itemI
{ SInt32 size = resource->Size();
UInt8 power = 0, remainder = 0;
Str255 sizePString, frac;
while( size >= 1024 && power <= 30 )
while(size >= 1024 && power <= 30)
{
power += 10; // 10 == KB, 20 == MB, 30 == GB
remainder = (UInt8) ((size % 1024) / 102.4); // 102.4 gives one dp, 10.24 would give two dps, 1.024 would give three dps
size /= 1024;
}
NumToString( (long) size, (StringPtr) &sizePString );
NumToString( remainder, (StringPtr) &frac );
if( power ) // some division has occoured
NumToString((long) size, (StringPtr) &sizePString);
NumToString(remainder, (StringPtr) &frac);
if(power) // some division has occoured
{
if( sizePString[0] < 3 && remainder > 0 )
if(sizePString[0] < 3 && remainder > 0)
{
AppendPString( (unsigned char *) &sizePString, "\p." ); // bug: should be a comma on european systems
AppendPString( (unsigned char *) &sizePString, (unsigned char *) &frac );
AppendPString((unsigned char *) &sizePString, "\p."); // bug: should be a comma on european systems
AppendPString((unsigned char *) &sizePString, (unsigned char *) &frac);
}
if( power == 10 ) AppendPString( (unsigned char *) &sizePString, "\p KB" );
else if( power == 20 ) AppendPString( (unsigned char *) &sizePString, "\p MB" );
else if( power == 30 ) AppendPString( (unsigned char *) &sizePString, "\p GB" ); // everything bigger will be given in GB
if(power == 10) AppendPString((unsigned char *) &sizePString, "\p KB");
else if(power == 20) AppendPString((unsigned char *) &sizePString, "\p MB");
else if(power == 30) AppendPString((unsigned char *) &sizePString, "\p GB"); // everything bigger will be given in GB
}
CFStringRef sizeString = CFStringCreateWithPascalString( CFAllocatorGetDefault(), sizePString, kCFStringEncodingMacRoman );
SetDataBrowserItemDataText( itemData, sizeString );
CFRelease( sizeString );
CFStringRef sizeString = CFStringCreateWithPascalString(CFAllocatorGetDefault(), sizePString, kCFStringEncodingMacRoman);
SetDataBrowserItemDataText(itemData, sizeString);
CFRelease(sizeString);
} break;
default:
@ -294,48 +294,48 @@ pascal OSStatus DataBrowserItemData( ControlRef browser, DataBrowserItemID itemI
}
/*** SORT DATA BROWSER ***/
pascal Boolean SortDataBrowser( ControlRef browser, DataBrowserItemID itemOne, DataBrowserItemID itemTwo, DataBrowserPropertyID sortProperty )
pascal Boolean SortDataBrowser(ControlRef browser, DataBrowserItemID itemOne, DataBrowserItemID itemTwo, DataBrowserPropertyID sortProperty)
{
short result;
Str255 typeOne, typeTwo;
StringPtr nameOne, nameTwo;
FileWindowPtr file = (FileWindowPtr) GetControlReference( browser );
FileWindowPtr file = (FileWindowPtr) GetControlReference(browser);
// send data fork to top regardless of property
if( itemOne == kDataBrowserDataForkItem ) return true;
if( itemTwo == kDataBrowserDataForkItem ) return false;
if(itemOne == kDataBrowserDataForkItem) return true;
if(itemTwo == kDataBrowserDataForkItem) return false;
// validate data browser item IDs
if( itemOne <= kDataBrowserNoItem || itemOne > file->GetResourceCount() )
if(itemOne <= kDataBrowserNoItem || itemOne > file->GetResourceCount())
{
DebugError( "\psort item one was invalid" );
DebugError("\psort item one was invalid");
return false;
}
if( itemTwo <= kDataBrowserNoItem || itemTwo > file->GetResourceCount() )
if(itemTwo <= kDataBrowserNoItem || itemTwo > file->GetResourceCount())
{
DebugError( "\psort item two was invalid" );
DebugError("\psort item two was invalid");
return false;
}
// get resource corrisponding to item ID
ResourceObjectPtr resourceOne = file->GetResource( itemOne );
ResourceObjectPtr resourceTwo = file->GetResource( itemTwo );
if( resourceOne == null || resourceTwo == null )
DebugError( "\pNull resource returned within SortDataBrowser()" );
ResourceObjectPtr resourceOne = file->GetResource(itemOne);
ResourceObjectPtr resourceTwo = file->GetResource(itemTwo);
if(resourceOne == null || resourceTwo == null)
DebugError("\pNull resource returned within SortDataBrowser()");
// sort resources according to property user has selected
switch( sortProperty )
switch(sortProperty)
{
case kDBNameColumn:
nameOne = resourceOne->Name();
nameTwo = resourceTwo->Name();
result = CompareString( nameOne, nameTwo, null );
result = CompareString(nameOne, nameTwo, null);
return result < 0;
case kDBTypeColumn:
TypeToPString( resourceOne->Type(), typeOne );
TypeToPString( resourceTwo->Type(), typeTwo );
result = CompareString( typeOne, typeTwo, null );
TypeToPString(resourceOne->Type(), typeOne);
TypeToPString(resourceTwo->Type(), typeTwo);
result = CompareString(typeOne, typeTwo, null);
return result < 0;
case kDBIDColumn:
@ -345,42 +345,42 @@ pascal Boolean SortDataBrowser( ControlRef browser, DataBrowserItemID itemOne, D
return resourceOne->Size() < resourceTwo->Size();
case kDataBrowserItemNoProperty: // this is valid when first constructing the data browser
// DebugError( "\pkDataBrowserItemNoProperty passed to sort function" );
// DebugError("\pkDataBrowserItemNoProperty passed to sort function");
return false;
default:
DebugError( "\pInvalid sort property given" );
DebugError("\pInvalid sort property given");
return false;
}
return false;
}
/*** 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*/ )
FileWindowPtr file = (FileWindowPtr) GetControlReference( browser );
switch( message )
#pragma unused(itemID/*, itemData*/)
FileWindowPtr file = (FileWindowPtr) GetControlReference(browser);
switch(message)
{
case kDataBrowserItemDoubleClicked:
{ KeyMap theKeys;
Boolean shiftKeyDown = false,
optionKeyDown = false,
controlKeyDown = false;
GetKeys( theKeys );
if( theKeys[1] & (shiftKey >> shiftKeyBit) ) shiftKeyDown = true;
if( theKeys[1] & (optionKey >> shiftKeyBit) ) optionKeyDown = true;
if( theKeys[1] & (controlKey >> shiftKeyBit) ) controlKeyDown = true;
if( optionKeyDown ) file->OpenResource( itemID, kMenuCommandOpenHex );
else if( controlKeyDown ) file->OpenResource( itemID, kMenuCommandOpenTemplate );
else file->OpenResource( itemID, kMenuCommandOpenDefault );
GetKeys(theKeys);
if(theKeys[1] & (shiftKey >> shiftKeyBit)) shiftKeyDown = true;
if(theKeys[1] & (optionKey >> shiftKeyBit)) optionKeyDown = true;
if(theKeys[1] & (controlKey >> shiftKeyBit)) controlKeyDown = true;
if(optionKeyDown) file->OpenResource(itemID, kMenuCommandOpenHex);
else if(controlKeyDown) file->OpenResource(itemID, kMenuCommandOpenTemplate);
else file->OpenResource(itemID, kMenuCommandOpenDefault);
} break;
case kDataBrowserItemSelected:
case kDataBrowserItemDeselected:
case kDataBrowserSelectionSetChanged:
// file->SetHeaderText();
if( g.inspector )
if(g.inspector)
g.inspector->Update();
break;
@ -400,20 +400,20 @@ pascal void DataBrowserMessage( ControlRef browser, DataBrowserItemID itemID, Da
}
/*** ADD DRAG ITEM ***/
pascal Boolean DataBrowserAddDragItem( ControlRef browser, DragRef drag, DataBrowserItemID item, DragItemRef *itemRef )
pascal Boolean DataBrowserAddDragItem(ControlRef browser, DragRef drag, DataBrowserItemID item, DragItemRef *itemRef)
{
#pragma unused( item )
#pragma unused(item)
// if drag already has phfs flavour, don't add another
UInt16 numFlavours;
CountDragItemFlavors( drag, *itemRef, &numFlavours );
if( numFlavours > 0 ) return true;
CountDragItemFlavors(drag, *itemRef, &numFlavours);
if(numFlavours > 0) return true;
// add 'create file' callback
if( itemRef ) *itemRef = ItemReference( item );
if(itemRef) *itemRef = ItemReference(item);
FlavorFlags flags = flavorNotSaved;
DragSendDataUPP sendData = NewDragSendDataUPP( SendPromisedFile );
SetDragSendProc( drag, sendData, browser );
DragSendDataUPP sendData = NewDragSendDataUPP(SendPromisedFile);
SetDragSendProc(drag, sendData, browser);
// setup imaginary file
PromiseHFSFlavor promisedFile;
@ -423,7 +423,7 @@ pascal Boolean DataBrowserAddDragItem( ControlRef browser, DragRef drag, DataBro
promisedFile.promisedFlavor = kResourceTransferType;
// add phfs and TEXT flavours
AddDragItemFlavor( drag, *itemRef, flavorTypePromiseHFS, &promisedFile, sizeof(PromiseHFSFlavor), flags );
AddDragItemFlavor(drag, *itemRef, flavorTypePromiseHFS, &promisedFile, sizeof(PromiseHFSFlavor), flags);
return true;
/* OSErr error = noErr;
@ -431,9 +431,9 @@ pascal Boolean DataBrowserAddDragItem( ControlRef browser, DragRef drag, DataBro
ItemReference theItemRef = 1;
// create the drag reference
NewDrag( &theDragRef );
if( MemError() ) return;
SetDragSendProc( theDragRef, sendProc, this );
NewDrag(&theDragRef);
if(MemError()) return;
SetDragSendProc(theDragRef, sendProc, this);
RgnHandle dragRgn = NewRgn(),
subtractRgn = NewRgn();
@ -442,106 +442,106 @@ pascal Boolean DataBrowserAddDragItem( ControlRef browser, DragRef drag, DataBro
Point dragOffset;
GWorldPtr imageGWorld = nil;
resData = GetResourceData( ownerWindow );
while( resData )
resData = GetResourceData(ownerWindow);
while(resData)
{
if( r.selected )
UnionRgn( r.nameIconRgn, dragRgn, dragRgn ); // add new region to rest of drag region
if(r.selected)
UnionRgn(r.nameIconRgn, dragRgn, dragRgn); // add new region to rest of drag region
resData = r.next;
}
if( g.translucentDrag )
if(g.translucentDrag)
{
short resCounter = 0;
SetPt( &dragOffset, 0, kFileHeaderHeight );
resData = GetResourceData( ownerWindow );
SetPt(&dragOffset, 0, kFileHeaderHeight);
resData = GetResourceData(ownerWindow);
while( !r.selected )
while(!r.selected)
{
resCounter++;
resData = r.next;
}
error = CreateDragImage( resData, &imageGWorld );
if( !error )
error = CreateDragImage(resData, &imageGWorld);
if(!error)
{
// init mask region
RgnHandle maskRgn = NewRgn();
CopyRgn( r.nameIconRgn, maskRgn );
OffsetRgn( maskRgn, 0, -kFileLineHeight * resCounter );
CopyRgn(r.nameIconRgn, maskRgn);
OffsetRgn(maskRgn, 0, -kFileLineHeight * resCounter);
// init rects
Rect sourceRect, destRect;
SetRect( &sourceRect, 0, 0, g.nameColumnWidth, kFileLineHeight );
SetRect( &destRect, 0, 0, g.nameColumnWidth, kFileLineHeight );
OffsetRect( &destRect, 0, kFileHeaderHeight );
SetRect(&sourceRect, 0, 0, g.nameColumnWidth, kFileLineHeight);
SetRect(&destRect, 0, 0, g.nameColumnWidth, kFileLineHeight);
OffsetRect(&destRect, 0, kFileHeaderHeight);
// init GWorld
PixMapHandle imagePixMap = GetGWorldPixMap( imageGWorld );
PixMapHandle imagePixMap = GetGWorldPixMap(imageGWorld);
DragImageFlags imageFlags = kDragStandardTranslucency | kDragRegionAndImage;
error = SetDragImage( theDragRef, imagePixMap, maskRgn, dragOffset, imageFlags );
CopyBits( &GrafPtr( imageGWorld )->portBits, &GrafPtr( ownerWindow )->portBits, &sourceRect, &destRect, srcCopy, maskRgn );
if( error ) SysBeep(0);
DisposeGWorld( imageGWorld );
DisposeRgn( maskRgn );
error = SetDragImage(theDragRef, imagePixMap, maskRgn, dragOffset, imageFlags);
CopyBits(&GrafPtr(imageGWorld)->portBits, &GrafPtr(ownerWindow)->portBits, &sourceRect, &destRect, srcCopy, maskRgn);
if(error) SysBeep(0);
DisposeGWorld(imageGWorld);
DisposeRgn(maskRgn);
}
}
// subtract middles from icons
MakeGlobal( ownerWindow, NewPoint(), &globalMouse );
CopyRgn( dragRgn, subtractRgn ); // duplicate region
InsetRgn( subtractRgn, 2, 2 ); // inset it by 2 pixels
DiffRgn( dragRgn, subtractRgn, dragRgn ); // subtract subRgn from addRgn, save in nameIconRgn
OffsetRgn( dragRgn, globalMouse.h, globalMouse.v ); // change drag region to global coords
MakeGlobal(ownerWindow, NewPoint(), &globalMouse);
CopyRgn(dragRgn, subtractRgn); // duplicate region
InsetRgn(subtractRgn, 2, 2); // inset it by 2 pixels
DiffRgn(dragRgn, subtractRgn, dragRgn); // subtract subRgn from addRgn, save in nameIconRgn
OffsetRgn(dragRgn, globalMouse.h, globalMouse.v); // change drag region to global coords
// add flavour data to drag
error = AddDragItemFlavor( theDragRef, theItemRef, flavorTypePromiseHFS, &theFile, sizeof(PromiseHFSFlavor), theFlags );
error = AddDragItemFlavor( theDragRef, theItemRef, kResType, nil, 0, theFlags );
error = AddDragItemFlavor(theDragRef, theItemRef, flavorTypePromiseHFS, &theFile, sizeof(PromiseHFSFlavor), theFlags);
error = AddDragItemFlavor(theDragRef, theItemRef, kResType, nil, 0, theFlags);
// track the drag, then clean up
error = TrackDrag( theDragRef, theEvent, dragRgn );
if( theDragRef ) DisposeDrag( theDragRef );
if( subtractRgn ) DisposeRgn( subtractRgn );
if( dragRgn ) DisposeRgn( dragRgn );
error = TrackDrag(theDragRef, theEvent, dragRgn);
if(theDragRef) DisposeDrag(theDragRef);
if(subtractRgn) DisposeRgn(subtractRgn);
if(dragRgn) DisposeRgn(dragRgn);
return error == noErr; */
}
/*** ACCEPT DRAG ***/
pascal Boolean DataBrowserAcceptDrag( ControlRef browser, DragRef drag, DataBrowserItemID item )
pascal Boolean DataBrowserAcceptDrag(ControlRef browser, DragRef drag, DataBrowserItemID item)
{
#pragma unused( browser, drag, item )
#pragma unused(browser, drag, item)
/* OSStatus error = noErr;
Size size = null;
DragItemRef dragItem = 1;
UInt16 index, totalItems;
CountDragItems( theDrag, &totalItems );
for( index = 1; index <= totalItems; index++ )
CountDragItems(theDrag, &totalItems);
for(index = 1; index <= totalItems; index++)
{
GetDragItemReferenceNumber( theDrag, index, &dragItem );
error = GetFlavourDataSize( theDrag, dragItem, kDragFlavourTypeResource, &size );
// if( error ) return false;
if( !error ) index = totalItems; // stop when valid item is reached
GetDragItemReferenceNumber(theDrag, index, &dragItem);
error = GetFlavourDataSize(theDrag, dragItem, kDragFlavourTypeResource, &size);
// if(error) return false;
if(!error) index = totalItems; // stop when valid item is reached
}
return size >= sizeof(ResTransferDesc);
*/ return true;
}
/*** RECEIVE DRAG ***/
pascal Boolean DataBrowserReceiveDrag( ControlRef browser, DragRef drag, DataBrowserItemID item )
pascal Boolean DataBrowserReceiveDrag(ControlRef browser, DragRef drag, DataBrowserItemID item)
{
#pragma unused( browser, drag, item )
#pragma unused(browser, drag, item)
return true;
}
/*** POSTÐPROCESS DRAG ***/
pascal void DataBrowserPostProcessDrag( ControlRef browser, DragRef drag, OSStatus trackDragResult )
pascal void DataBrowserPostProcessDrag(ControlRef browser, DragRef drag, OSStatus trackDragResult)
{
#pragma unused( browser, drag, trackDragResult )
#pragma unused(browser, drag, trackDragResult)
}
/*** SEND PROMISED FILE ***/
pascal OSErr SendPromisedFile( FlavorType type, void *dragSendRefCon, ItemReference item, DragReference drag )
pascal OSErr SendPromisedFile(FlavorType type, void *dragSendRefCon, ItemReference item, DragReference drag)
{
OSErr error = noErr;
ControlRef browser = (ControlRef) dragSendRefCon;
@ -550,67 +550,67 @@ pascal OSErr SendPromisedFile( FlavorType type, void *dragSendRefCon, ItemRefere
short vRefNum;
long dirID;
if( type != flavorTypePromiseHFS ) return badDragFlavorErr;
if(type != flavorTypePromiseHFS) return badDragFlavorErr;
// create file
GetIndString( fileName, kFileNameStrings, kStringNewDragFileName );
FindFolder( kOnSystemDisk, /*kTemporaryFolderType*/kDesktopFolderType, kCreateFolder, &vRefNum, &dirID );
FSMakeFSSpec( vRefNum, dirID, fileName, &fileSpec );
FSpCreateResFile( &fileSpec, kResKnifeCreator, kResourceFileType, smSystemScript );
GetIndString(fileName, kFileNameStrings, kStringNewDragFileName);
FindFolder(kOnSystemDisk, /*kTemporaryFolderType*/kDesktopFolderType, kCreateFolder, &vRefNum, &dirID);
FSMakeFSSpec(vRefNum, dirID, fileName, &fileSpec);
FSpCreateResFile(&fileSpec, kResKnifeCreator, kResourceFileType, smSystemScript);
// save resources into file
DragData clientData; // waiting for jim to add a ControlRef to DataBrowserItemUPP; bug: jim no longer works at Apple
clientData.browser = browser;
clientData.fileSpec = &fileSpec;
DataBrowserItemUPP callback = NewDataBrowserItemUPP( AddResourceToDragFile );
DataBrowserItemUPP callback = NewDataBrowserItemUPP(AddResourceToDragFile);
/* control, container, recurse, state, callback, clientData */
ForEachDataBrowserItem( browser, kDataBrowserNoItem, true, kDataBrowserItemIsSelected, callback, &clientData );
ForEachDataBrowserItem(browser, kDataBrowserNoItem, true, kDataBrowserItemIsSelected, callback, &clientData);
// save resources in file
/* ResourceObjectPtr resource = GetResourceData( file->window );
short refNum = FSpOpenResFile( &fileSpec, fsRdWrPerm );
UseResFile( refNum );
while( resData )
/* ResourceObjectPtr resource = GetResourceData(file->window);
short refNum = FSpOpenResFile(&fileSpec, fsRdWrPerm);
UseResFile(refNum);
while(resData)
{
if( resource->Selected() )
AddResource( resource->Data(), resource->Type(), resource->ID(), resource->Name() );
if(resource->Selected())
AddResource(resource->Data(), resource->Type(), resource->ID(), resource->Name());
resData = resource->Next();
}
CloseResFile( refNum );
UseResFile( g.appResFile );
CloseResFile(refNum);
UseResFile(g.appResFile);
*/
error = SetDragItemFlavorData( drag, item, type, &fileSpec, sizeof(FSSpec), 0 );
error = SetDragItemFlavorData(drag, item, type, &fileSpec, sizeof(FSSpec), 0);
return error;
}
/*** ADD RESOURCE TO DRAG FILE ***/
pascal void AddResourceToDragFile( DataBrowserItemID item, DataBrowserItemState state, void *clientData )
pascal void AddResourceToDragFile(DataBrowserItemID item, DataBrowserItemState state, void *clientData)
{
#pragma unused( state )
#pragma unused(state)
// FSSpecPtr fileSpec = (FSSpecPtr) clientData;
WindowRef window = GetControlOwner( ((DragDataPtr) clientData)->browser );
FileWindowPtr file = (FileWindowPtr) GetWindowRefCon( window );
ResourceObjectPtr resource = file->GetResource( item );
WindowRef window = GetControlOwner(((DragDataPtr) clientData)->browser);
FileWindowPtr file = (FileWindowPtr) GetWindowRefCon(window);
ResourceObjectPtr resource = file->GetResource(item);
// add resource to file
short oldFile = CurResFile();
short refNum = FSpOpenResFile( ((DragDataPtr) clientData)->fileSpec, fsRdWrPerm );
UseResFile( refNum );
AddResource( resource->Data(), resource->Type(), resource->ID(), resource->Name() );
if( ResError() == addResFailed )
short refNum = FSpOpenResFile(((DragDataPtr) clientData)->fileSpec, fsRdWrPerm);
UseResFile(refNum);
AddResource(resource->Data(), resource->Type(), resource->ID(), resource->Name());
if(ResError() == addResFailed)
{
DisplayError( "\pDrag Partially Failed", "\pCould not add a resource to file." );
DisplayError("\pDrag Partially Failed", "\pCould not add a resource to file.");
}
else
{
SetResAttrs( resource->Data(), resource->Attributes() );
ChangedResource( resource->Data() );
SetResAttrs(resource->Data(), resource->Attributes());
ChangedResource(resource->Data());
// clean up & move on
DetachResource( resource->Data() );
DetachResource(resource->Data());
}
CloseResFile( refNum );
UseResFile( oldFile );
CloseResFile(refNum);
UseResFile(oldFile);
}
#else
@ -620,12 +620,12 @@ pascal void AddResourceToDragFile( DataBrowserItemID item, DataBrowserItemState
/*********************/
/*** CLEAR SELECTION ***/
OSStatus FileWindow::ClearSelection( void )
OSStatus FileWindow::ClearSelection(void)
{
ResourceObjectPtr resource = resourceMap;
while( resource )
while(resource)
{
resource->Select( false );
resource->Select(false);
resource = resource->Next();
}
return noErr;

View File

@ -37,51 +37,51 @@ const DataBrowserItemID kDataBrowserDataForkItem = 0xFFFFFFFE; // bug in data br
* @function AddDataBrowserColumn
* @discussion Adds columns to the data browser one at a time.
*/
void AddDataBrowserColumn( ControlRef browser, DataBrowserPropertyID column, UInt16 position );
void AddDataBrowserColumn(ControlRef browser, DataBrowserPropertyID column, UInt16 position);
/*!
* @function DataBrowserItemData
* @discussion DataBrowser callback.
*/
pascal OSStatus DataBrowserItemData( ControlRef browser, DataBrowserItemID itemID, DataBrowserPropertyID property, DataBrowserItemDataRef itemData, Boolean changeValue );
pascal OSStatus DataBrowserItemData(ControlRef browser, DataBrowserItemID itemID, DataBrowserPropertyID property, DataBrowserItemDataRef itemData, Boolean changeValue);
/*!
* @function SortDataBrowser
* @discussion DataBrowser callback.
*/
pascal Boolean SortDataBrowser( ControlRef browser, DataBrowserItemID itemOne, DataBrowserItemID itemTwo, DataBrowserPropertyID sortProperty );
pascal Boolean SortDataBrowser(ControlRef browser, DataBrowserItemID itemOne, DataBrowserItemID itemTwo, DataBrowserPropertyID sortProperty);
/*!
* @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.
*/
pascal Boolean DataBrowserAddDragItem( ControlRef browser, DragRef drag, DataBrowserItemID item, DragItemRef *itemRef );
pascal Boolean DataBrowserAddDragItem(ControlRef browser, DragRef drag, DataBrowserItemID item, DragItemRef *itemRef);
/*!
* @function DataBrowserAcceptDrag
* @discussion DataBrowser callback.
*/
pascal Boolean DataBrowserAcceptDrag( ControlRef browser, DragRef drag, DataBrowserItemID item );
pascal Boolean DataBrowserAcceptDrag(ControlRef browser, DragRef drag, DataBrowserItemID item);
/*!
* @function DataBrowserReceiveDrag
* @discussion DataBrowser callback.
*/
pascal Boolean DataBrowserReceiveDrag( ControlRef browser, DragRef drag, DataBrowserItemID item );
pascal Boolean DataBrowserReceiveDrag(ControlRef browser, DragRef drag, DataBrowserItemID item);
/*!
* @function DataBrowserPostProcessDrag
* @discussion DataBrowser callback.
*/
pascal void DataBrowserPostProcessDrag( ControlRef browser, DragRef drag, OSStatus trackDragResult );
pascal void DataBrowserPostProcessDrag(ControlRef browser, DragRef drag, OSStatus trackDragResult);
/*!
* @function SendPromisedFile
* @discussion Creates the promised file and sends the FSSpec for it back.
*/
pascal OSErr SendPromisedFile( FlavorType theType, void *dragSendRefCon, ItemReference item, DragReference drag );
pascal OSErr SendPromisedFile(FlavorType theType, void *dragSendRefCon, ItemReference item, DragReference drag);
/*!
* @function AddResourceToDragFile
* @discussion Adds each resource to the file created by SendPromisedFile. Called once per resource.
*/
pascal void AddResourceToDragFile( DataBrowserItemID item, DataBrowserItemState state, void *clientData );
pascal void AddResourceToDragFile(DataBrowserItemID item, DataBrowserItemState state, void *clientData);
#endif

View File

@ -6,7 +6,7 @@
extern globals g;
/*** CREATOR ***/
EditorWindow::EditorWindow( FileWindowPtr ownerFile, ResourceObjectPtr targetResource, WindowRef inputWindow ) : PlugWindow( ownerFile )
EditorWindow::EditorWindow(FileWindowPtr ownerFile, ResourceObjectPtr targetResource, WindowRef inputWindow) : PlugWindow(ownerFile)
{
// OSStatus error = noErr;
@ -17,33 +17,33 @@ EditorWindow::EditorWindow( FileWindowPtr ownerFile, ResourceObjectPtr targetRes
// set up default window title
Str255 windowTitle, resTypeStr, resIDStr;
FSSpec spec = *ownerFile->GetFileSpec();
CopyPString( spec.name, windowTitle );
TypeToPString( resource->Type(), resTypeStr );
NumToString( resource->ID(), resIDStr );
AppendPString( windowTitle, "\p: " );
AppendPString( windowTitle, resTypeStr );
AppendPString( windowTitle, "\p " );
AppendPString( windowTitle, resIDStr );
if( *resource->Name() != 0x00 ) // resource has name
CopyPString(spec.name, windowTitle);
TypeToPString(resource->Type(), resTypeStr);
NumToString(resource->ID(), resIDStr);
AppendPString(windowTitle, "\p: ");
AppendPString(windowTitle, resTypeStr);
AppendPString(windowTitle, "\p ");
AppendPString(windowTitle, resIDStr);
if(*resource->Name() != 0x00) // resource has name
{
AppendPString( windowTitle, "\p, Ò" );
AppendPString( windowTitle, resource->Name() );
AppendPString( windowTitle, "\" );
AppendPString(windowTitle, "\p, Ò");
AppendPString(windowTitle, resource->Name());
AppendPString(windowTitle, "\");
}
// save EditorWindow class in window's refcon
SetWindowRefCon( window, (UInt32) this );
SetWindowKind( window, kEditorWindowKind );
SetWindowTitle( window, windowTitle );
SetWindowRefCon(window, (UInt32) this);
SetWindowKind(window, kEditorWindowKind);
SetWindowTitle(window, windowTitle);
}
#if !TARGET_API_MAC_CARBON
/*** CLOSE ***/
OSStatus EditorWindow::Close( void )
OSStatus EditorWindow::Close(void)
{
// bug: need to tell plug it is about to die.
CloseWindow( window );
CloseWindow(window);
delete this;
return noErr;
}
@ -51,7 +51,7 @@ OSStatus EditorWindow::Close( void )
#endif
/*** RESOURCE ACCESSOR ***/
ResourceObjectPtr EditorWindow::Resource( void )
ResourceObjectPtr EditorWindow::Resource(void)
{
return resource;
}

View File

@ -25,13 +25,13 @@ public:
* @function EditorWindow
* @discussion Constructor function.
*/
EditorWindow( FileWindowPtr ownerFile, ResourceObjectPtr targetResource, WindowRef inputWindow );
EditorWindow(FileWindowPtr ownerFile, ResourceObjectPtr targetResource, WindowRef inputWindow);
/*!
* @function Close
* @discussion Sends a close message to the plug, then closes the window.
*/
OSStatus Close( void );
ResourceObjectPtr Resource( void );
OSStatus Close(void);
ResourceObjectPtr Resource(void);
};
#endif

View File

@ -7,32 +7,32 @@ extern globals g;
extern prefs p;
/*** DISPLAY ANY ERROR ***/
OSStatus DisplayError( CFStringRef errorStr )
OSStatus DisplayError(CFStringRef errorStr)
{
#pragma unused( errorStr )
#pragma unused(errorStr)
return noErr;
}
/*** DISPLAY SIMPLE ERROR ***/
OSStatus DisplayError( ConstStr255Param errorStr )
OSStatus DisplayError(ConstStr255Param errorStr)
{
return DisplayError( errorStr, "\p" );
return DisplayError(errorStr, "\p");
}
/*** DISPLAY ERROR WITH EXPLANATION */
OSStatus DisplayError( UInt16 error, UInt16 explanation )
OSStatus DisplayError(UInt16 error, UInt16 explanation)
{
Str255 errorStr, explanationStr;
GetIndString( errorStr, kErrorStrings, error );
GetIndString( explanationStr, kErrorStrings, explanation );
return DisplayError( errorStr, explanationStr );
GetIndString(errorStr, kErrorStrings, error);
GetIndString(explanationStr, kErrorStrings, explanation);
return DisplayError(errorStr, explanationStr);
}
/*** DISPLAY ERROR WITH EXPLANATION */
OSStatus DisplayError( ConstStr255Param errorStr, ConstStr255Param explanationStr )
OSStatus DisplayError(ConstStr255Param errorStr, ConstStr255Param explanationStr)
{
if( g.surpressErrors ) return noErr;
if( g.useAppearance )
if(g.surpressErrors) return noErr;
if(g.useAppearance)
{
SInt16 item;
AlertStdAlertParamRec params = {};
@ -41,49 +41,49 @@ OSStatus DisplayError( ConstStr255Param errorStr, ConstStr255Param explanationSt
params.position = kWindowDefaultPosition;
#if __profile__
ProfilerSetStatus( false );
ProfilerSetStatus(false);
#endif
SysBeep(0);
StandardAlert( kAlertStopAlert, errorStr, explanationStr, &params, &item );
StandardAlert(kAlertStopAlert, errorStr, explanationStr, &params, &item);
#if __profile__
ProfilerSetStatus( true );
ProfilerSetStatus(true);
#endif
return item == kAlertStdAlertOKButton? noErr:paramErr;
}
else
{
ParamText( errorStr, explanationStr, "\p", "\p" );
ModalFilterUPP filter = null; // NewModalFilterUPP( ParseDialogEvents );
ParamText(errorStr, explanationStr, "\p", "\p");
ModalFilterUPP filter = null; // NewModalFilterUPP(ParseDialogEvents);
#if __profile__
ProfilerSetStatus( false );
ProfilerSetStatus(false);
#endif
SysBeep(0);
DialogItemIndex item = StopAlert( 128, filter );
DialogItemIndex item = StopAlert(128, filter);
#if __profile__
ProfilerSetStatus( true );
ProfilerSetStatus(true);
#endif
return item == kAlertStdAlertOKButton? noErr:paramErr;
}
}
/*** DISPLAY ERROR WITH EXPLANATION */
OSStatus DebugError( UInt16 error, OSStatus number )
OSStatus DebugError(UInt16 error, OSStatus number)
{
Str255 errorStr;
GetIndString( errorStr, kDebugStrings, error );
return DebugError( errorStr, number );
GetIndString(errorStr, kDebugStrings, error);
return DebugError(errorStr, number);
}
/*** DISPLAY A DEBUGGING ERROR ***/
OSStatus DebugError( ConstStr255Param errorStr, OSStatus number )
OSStatus DebugError(ConstStr255Param errorStr, OSStatus number)
{
OSStatus error = noErr;
if( g.debug )
if(g.debug)
{
Str255 message = "\pDebugging Error ID: ", numString = "\p";
NumToString( number, numString );
AppendPString( message, numString );
error = DisplayError( message, errorStr );
NumToString(number, numString);
AppendPString(message, numString);
error = DisplayError(message, errorStr);
}
return error;
}

View File

@ -12,31 +12,31 @@
@function DisplayError
@discussion Pass a CFStringRef and ResKnife will do noting at all. (yet :)
*/
OSStatus DisplayError( CFStringRef error );
OSStatus DisplayError(CFStringRef error);
/*!
@function DisplayError
@discussion Pass one pascal string and ResKnife will display a simple error message.
*/
OSStatus DisplayError( ConstStr255Param error );
OSStatus DisplayError(ConstStr255Param error);
/*!
@function DisplayError
@discussion Pass two string indecies within kErrorStrings, and they will be displayed as an error message.
*/
OSStatus DisplayError( UInt16 error, UInt16 explanation );
OSStatus DisplayError(UInt16 error, UInt16 explanation);
/*!
@function DisplayError
@discussion Pass two pascal strings and ResKnife will display a more refined error message.
*/
OSStatus DisplayError( ConstStr255Param error, ConstStr255Param explanation );
OSStatus DisplayError(ConstStr255Param error, ConstStr255Param explanation);
/*!
@function DebugError
@discussion Pass an index of a string with kDebugStrings and if debugging mode is on, ResKnife will display the message.
*/
OSStatus DebugError( UInt16 error, OSStatus number = noErr );
OSStatus DebugError(UInt16 error, OSStatus number = noErr);
/*!
@function DebugError
@discussion Pass a pascal string and if debugging mode is on, ResKnife will display the message.
*/
OSStatus DebugError( ConstStr255Param errorStr, OSStatus number = noErr );
OSStatus DebugError(ConstStr255Param errorStr, OSStatus number = noErr);
#endif

File diff suppressed because it is too large Load Diff

View File

@ -89,91 +89,87 @@ class FileWindow : WindowObject
/* methods */
public:
FileWindow( FSSpecPtr spec = null );
virtual ~FileWindow( void );
FileWindow(FSSpecPtr spec = null);
virtual ~FileWindow(void);
// overridden inherited functions
/*!
* @function Window
* @discussion Accessor for the object&rsquo;s <tt>WindowRef</tt>.
*/
virtual WindowRef Window( void );
virtual OSStatus BoundsChanging( EventRef event );
virtual OSStatus BoundsChanged( EventRef event );
virtual WindowRef Window(void);
virtual OSStatus BoundsChanging(EventRef event);
virtual OSStatus BoundsChanged(EventRef event);
#if !TARGET_API_MAC_CARBON
virtual OSStatus Activate( Boolean active = true );
virtual OSStatus Update( RgnHandle region = null );
virtual OSStatus Click( Point mouse, EventModifiers modifiers );
virtual OSStatus Activate(Boolean active = true);
virtual OSStatus Update(RgnHandle region = null);
virtual OSStatus Click(Point mouse, EventModifiers modifiers);
// drawing
private:
virtual OSStatus UpdateScrollBars( void );
OSStatus DrawResourceIcon( ResourceObjectPtr resource, UInt16 line );
virtual OSStatus UpdateScrollBars(void);
OSStatus DrawResourceIcon(ResourceObjectPtr resource, UInt16 line);
// fake data brwser
OSStatus ClearSelection( void );
OSStatus ClearSelection(void);
#endif
// file manipulation
public:
OSStatus ReadResourceFork( void );
OSStatus ReadDataFork( OSStatus rfError );
OSStatus InitDataBrowser( void );
OSStatus SaveFile( FSSpecPtr saveSpec = null );
private:
OSStatus ReadResourceFork(void);
OSStatus ReadDataFork(OSStatus rfError);
OSStatus InitDataBrowser(void);
OSStatus SaveFile(FSSpecPtr saveSpec = null);
/*!
@function ReadResourceMap
@discussion Requires the fork containing resources to be at the top of the resource chain
*/
OSStatus ReadResourceMap( void ); // fork-independent resource routines
OSStatus SaveResourceMap( void );
OSStatus ReadResourceMap(void); // fork-independent resource routines
OSStatus SaveResourceMap(void);
// carbon routines
public:
OSStatus Zoomed( EventRef event );
OSStatus SetIdealSize( EventRef event );
OSStatus DisplaySaveDialog( void );
OSStatus DisplayModelessAskSaveChangesDialog( void );
OSStatus DisplaySaveAsDialog( void );
OSStatus DisplayModelessPutFileDialog( void );
OSStatus DisplayRevertFileDialog( void );
OSStatus DisplayModelessAskDiscardChangesDialog( void );
OSStatus DisplayNewResourceDialog( void );
OSStatus DisplayNewResourceSheet( void );
OSStatus Zoomed(EventRef event);
OSStatus SetIdealSize(EventRef event);
OSStatus DisplaySaveDialog(void);
OSStatus DisplayModelessAskSaveChangesDialog(void);
OSStatus DisplaySaveAsDialog(void);
OSStatus DisplayModelessPutFileDialog(void);
OSStatus DisplayRevertFileDialog(void);
OSStatus DisplayModelessAskDiscardChangesDialog(void);
OSStatus DisplayNewResourceDialog(void);
OSStatus DisplayNewResourceSheet(void);
// resource map processing
OSStatus CreateNewResource( ConstStr255Param name, ResType type, SInt16 resID, SInt16 attribs );
OSStatus OpenResource( DataBrowserItemID itemID, MenuCommand command );
private:
OSStatus DisposeResourceMap( void );
OSStatus CreateNewResource(ConstStr255Param name, ResType type, SInt16 resID, SInt16 attribs);
OSStatus OpenResource(DataBrowserItemID itemID, MenuCommand command);
OSStatus DisposeResourceMap(void);
public:
// sound handlers
OSStatus PlaySound( DataBrowserItemID itemID );
OSStatus PlaySound(DataBrowserItemID itemID);
// file accessors
FSSpecPtr GetFileSpec( void );
void SetFileSpec( FSSpecPtr spec );
Boolean IsFileDirty( void );
void SetFileDirty( Boolean dirty = true );
FSSpecPtr GetFileSpec(void);
void SetFileSpec(FSSpecPtr spec);
Boolean IsFileDirty(void);
void SetFileDirty(Boolean dirty = true);
#if TARGET_API_MAC_CARBON
ControlRef GetDataBrowser( void );
ControlRef GetDataBrowser(void);
#endif
// resource accessors
UInt32 GetResourceCount( ResType wanted = 0x00000000 );
ResourceObjectPtr GetResource( DataBrowserItemID itemID );
UInt8* GetResourceName( DataBrowserItemID itemID );
UInt32 GetResourceSize( DataBrowserItemID itemID );
ResType GetResourceType( DataBrowserItemID itemID );
SInt16 GetResourceID( DataBrowserItemID itemID );
SInt16 GetResourceAttributes( DataBrowserItemID itemID );
UInt32 GetResourceCount(ResType wanted = 0x00000000);
ResourceObjectPtr GetResource(DataBrowserItemID itemID);
UInt8* GetResourceName(DataBrowserItemID itemID);
UInt32 GetResourceSize(DataBrowserItemID itemID);
ResType GetResourceType(DataBrowserItemID itemID);
SInt16 GetResourceID(DataBrowserItemID itemID);
SInt16 GetResourceAttributes(DataBrowserItemID itemID);
};
/* window event handler */
pascal void FileWindowScrollAction( ControlHandle control, SInt16 controlPart );
pascal OSStatus FileWindowEventHandler( EventHandlerCallRef callRef, EventRef event, void *userData );
pascal OSStatus FileWindowUpdateMenus( EventHandlerCallRef callRef, EventRef event, void *userData );
pascal OSStatus FileWindowParseMenuSelection( EventHandlerCallRef callRef, EventRef event, void *userData );
pascal OSStatus NewResourceEventHandler( EventHandlerCallRef callRef, EventRef event, void *userData );
pascal void FileWindowScrollAction(ControlHandle control, SInt16 controlPart);
pascal OSStatus FileWindowEventHandler(EventHandlerCallRef callRef, EventRef event, void *userData);
pascal OSStatus FileWindowUpdateMenus(EventHandlerCallRef callRef, EventRef event, void *userData);
pascal OSStatus FileWindowParseMenuSelection(EventHandlerCallRef callRef, EventRef event, void *userData);
pascal OSStatus NewResourceEventHandler(EventHandlerCallRef callRef, EventRef event, void *userData);
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -12,51 +12,51 @@
@function DisplayOpenDialog
@discussion Calls the appropriate <tt>Open()</tt> function for the system we are running on.
*/
OSStatus DisplayOpenDialog( void );
OSStatus DisplayOpenDialog(void);
/*!
@function DisplayModelessGetFileDialog
@discussion Requires CarbonLib 1.1 or OS X
*/
OSStatus DisplayModelessGetFileDialog( void );
OSStatus DisplayModelessGetFileDialog(void);
/*!
@function OpenFile
*/
OSStatus OpenFile( short vRefNum, long dirID, ConstStr255Param fileName );
OSStatus OpenFile(short vRefNum, long dirID, ConstStr255Param fileName);
/*!
@function DisplayStandardFileOpenDialog
*/
OSStatus DisplayStandardFileOpenDialog( void );
OSStatus DisplayStandardFileOpenDialog(void);
/*!
@function ModelessGetFileHandler
@discussion Requires CarbonLib 1.1 or OS X
*/
pascal void ModelessGetFileHandler( const NavEventCallbackMessage callBackSelector, NavCBRecPtr cbRecord, NavCallBackUserData callBackUD );
pascal void ModelessGetFileHandler(const NavEventCallbackMessage callBackSelector, NavCBRecPtr cbRecord, NavCallBackUserData callBackUD);
/*!
@function ModelessAskSaveChangesHandler
@discussion Requires CarbonLib 1.1 or OS X
*/
pascal void ModelessAskSaveChangesHandler( const NavEventCallbackMessage callBackSelector, NavCBRecPtr cbRecord, NavCallBackUserData callBackUD );
pascal void ModelessAskSaveChangesHandler(const NavEventCallbackMessage callBackSelector, NavCBRecPtr cbRecord, NavCallBackUserData callBackUD);
/*!
@function ModelessPutFileHandler
@discussion Requires CarbonLib 1.1 or OS X
*/
pascal void ModelessPutFileHandler( const NavEventCallbackMessage callBackSelector, NavCBRecPtr cbRecord, NavCallBackUserData callBackUD );
pascal void ModelessPutFileHandler(const NavEventCallbackMessage callBackSelector, NavCBRecPtr cbRecord, NavCallBackUserData callBackUD);
/*!
@function ModelessAskDiscardChangesHandler
@discussion Requires CarbonLib 1.1 or OS X
*/
pascal void ModelessAskDiscardChangesHandler( const NavEventCallbackMessage callBackSelector, NavCBRecPtr cbRecord, NavCallBackUserData callBackUD );
pascal void ModelessAskDiscardChangesHandler(const NavEventCallbackMessage callBackSelector, NavCBRecPtr cbRecord, NavCallBackUserData callBackUD);
/*!
@function NavEventFilter
*/
pascal void NavEventFilter( NavEventCallbackMessage callBackSelector, NavCBRecPtr cbRecord, NavCallBackUserData callBackUD );
pascal void NavEventFilter(NavEventCallbackMessage callBackSelector, NavCBRecPtr cbRecord, NavCallBackUserData callBackUD);
/*!
@function NavPreviewFilter
*/
pascal Boolean NavPreviewFilter( NavCBRecPtr callBackParms, void *callBackUD );
pascal Boolean NavPreviewFilter(NavCBRecPtr callBackParms, void *callBackUD);
/*!
@function NavFileFilter
*/
pascal Boolean NavFileFilter( AEDescPtr theItem, void *info, void *callBackUD, NavFilterModes filterMode );
pascal Boolean NavFileFilter(AEDescPtr theItem, void *info, void *callBackUD, NavFilterModes filterMode);
#endif

View File

@ -9,20 +9,20 @@
extern globals g;
/* window management */
Plug_WindowRef Host_RegisterWindow( Plug_PlugInRef plug, Plug_ResourceRef resource, WindowRef window )
Plug_WindowRef Host_RegisterWindow(Plug_PlugInRef plug, Plug_ResourceRef resource, WindowRef window)
{
if( resource )
if(resource)
{
EditorWindowPtr plugWindow = new EditorWindow( ((ResourceObjectPtr) resource)->File(), (ResourceObjectPtr) resource, window );
((PlugObjectPtr) plug)->SetWindowObject( (WindowObjectPtr) plugWindow );
((PlugObjectPtr) plug)->SetResourceObject( (ResourceObjectPtr) resource );
EditorWindowPtr plugWindow = new EditorWindow(((ResourceObjectPtr) resource)->File(), (ResourceObjectPtr) resource, window);
((PlugObjectPtr) plug)->SetWindowObject((WindowObjectPtr) plugWindow);
((PlugObjectPtr) plug)->SetResourceObject((ResourceObjectPtr) resource);
return (Plug_WindowRef) plugWindow;
}
/* else
{
PickerWindowPtr plugWindow = new PickerWindow( window );
((PlugObjectPtr) plug)->SetWindowObject( plugWindow );
((PlugObjectPtr) plug)->SetResourceObject( (ResourceObjectPtr) resource );
PickerWindowPtr plugWindow = new PickerWindow(window);
((PlugObjectPtr) plug)->SetWindowObject(plugWindow);
((PlugObjectPtr) plug)->SetResourceObject((ResourceObjectPtr) resource);
return (Plug_WindowRef) plugWindow;
}
*/ else return null;
@ -30,172 +30,172 @@ Plug_WindowRef Host_RegisterWindow( Plug_PlugInRef plug, Plug_ResourceRef resour
#if !TARGET_API_MAC_CARBON
void Host_InstallClassicWindowEventHandler( Plug_WindowRef plugWindow, RoutineDescriptor *handler )
void Host_InstallClassicWindowEventHandler(Plug_WindowRef plugWindow, RoutineDescriptor *handler)
{
((PlugWindowPtr) plugWindow)->InstallClassicEventHandler( (ClassicEventHandlerProcPtr) handler );
((PlugWindowPtr) plugWindow)->InstallClassicEventHandler((ClassicEventHandlerProcPtr) handler);
}
#endif
WindowRef Host_GetWindowRefFromPlugWindow( Plug_WindowRef plugWindow )
WindowRef Host_GetWindowRefFromPlugWindow(Plug_WindowRef plugWindow)
{
return ((WindowObjectPtr) plugWindow)->Window();
}
Plug_WindowRef Host_GetPlugWindowFromWindowRef( WindowRef window )
Plug_WindowRef Host_GetPlugWindowFromWindowRef(WindowRef window)
{
return (Plug_WindowRef) GetWindowRefCon(window);
}
Plug_PlugInRef Host_GetPlugRef( WindowRef window )
Plug_PlugInRef Host_GetPlugRef(WindowRef window)
{
#pragma unused( window )
#pragma unused(window)
return null;
}
Plug_ResourceRef Host_GetResource( ResType type, SInt32 resID, Plug_ResourceRef sameFileAsResource )
Plug_ResourceRef Host_GetResource(ResType type, SInt32 resID, Plug_ResourceRef sameFileAsResource)
{
// FileWindowPtr file;
if( sameFileAsResource != NULL )
if(sameFileAsResource != NULL)
{
// file = ((ResourceObjectPtr) sameFileAsResource)->file;
short oldResFile = CurResFile();
UseResFile( HomeResFile( ((ResourceObjectPtr) sameFileAsResource)->Data() ) );
Get1Resource( type, resID ); // bug: handle ignored at present
UseResFile( oldResFile );
UseResFile(HomeResFile(((ResourceObjectPtr) sameFileAsResource)->Data()));
Get1Resource(type, resID); // bug: handle ignored at present
UseResFile(oldResFile);
}
else GetResource( type, resID ); // bug: handle ignored at present
else GetResource(type, resID); // bug: handle ignored at present
return nil; // bug: handle ignored at present
}
Plug_ResourceRef Host_GetTargetResource( Plug_WindowRef plugWindow )
Plug_ResourceRef Host_GetTargetResource(Plug_WindowRef plugWindow)
{
return (Plug_ResourceRef) ((EditorWindowPtr) plugWindow)->Resource();
}
/* accessors */
Handle Host_GetResourceData( Plug_ResourceRef resource )
Handle Host_GetResourceData(Plug_ResourceRef resource)
{
((ResourceObjectPtr) resource)->Retain();
return ((ResourceObjectPtr) resource)->Data();
}
Handle Host_GetPartialResourceData( Plug_ResourceRef resource, UInt32 offset, UInt32 length )
Handle Host_GetPartialResourceData(Plug_ResourceRef resource, UInt32 offset, UInt32 length)
{
#pragma unused( resource, offset, length )
#pragma unused(resource, offset, length)
return null;
}
void Host_ReleaseResourceData( Plug_ResourceRef resource )
void Host_ReleaseResourceData(Plug_ResourceRef resource)
{
#pragma unused( resource )
#pragma unused(resource)
// ((ResourceObjectPtr) resource)->Release();
return;
}
void Host_ReleasePartialResourceData( Plug_ResourceRef resource, Handle data )
void Host_ReleasePartialResourceData(Plug_ResourceRef resource, Handle data)
{
#pragma unused( resource, data )
#pragma unused(resource, data)
return;
}
ResType Host_GetResourceType( Plug_ResourceRef resource )
ResType Host_GetResourceType(Plug_ResourceRef resource)
{
return ((ResourceObjectPtr) resource)->Type();
}
SInt16 Host_GetResourceID( Plug_ResourceRef resource )
SInt16 Host_GetResourceID(Plug_ResourceRef resource)
{
return ((ResourceObjectPtr) resource)->ID();
}
UInt32 Host_GetResourceSize( Plug_ResourceRef resource )
UInt32 Host_GetResourceSize(Plug_ResourceRef resource)
{
return ((ResourceObjectPtr) resource)->Size();
}
void Host_GetResourceName( Plug_ResourceRef resource, Str255 name )
void Host_GetResourceName(Plug_ResourceRef resource, Str255 name)
{
#pragma unused( resource, name )
#pragma unused(resource, name)
return;
}
UInt32 Host_GetWindowRefCon( Plug_WindowRef plugWindow )
UInt32 Host_GetWindowRefCon(Plug_WindowRef plugWindow)
{
return ((PlugWindowPtr) plugWindow)->GetRefCon();
}
void Host_SetWindowRefCon( Plug_WindowRef plugWindow, UInt32 value )
void Host_SetWindowRefCon(Plug_WindowRef plugWindow, UInt32 value)
{
((PlugWindowPtr) plugWindow)->SetRefCon(value);
}
UInt32 Host_GetGlobalRefCon( Plug_PlugInRef plug )
UInt32 Host_GetGlobalRefCon(Plug_PlugInRef plug)
{
return ((PlugObjectPtr) plug)->GetRefCon();
}
void Host_SetGlobalRefCon( Plug_PlugInRef plug, UInt32 value )
void Host_SetGlobalRefCon(Plug_PlugInRef plug, UInt32 value)
{
((PlugObjectPtr) plug)->SetRefCon(value);
}
Boolean Host_GetResourceDirty( Plug_ResourceRef resource )
Boolean Host_GetResourceDirty(Plug_ResourceRef resource)
{
return ((ResourceObjectPtr) resource)->Dirty();
}
void Host_SetResourceDirty( Plug_ResourceRef resource, Boolean dirty )
void Host_SetResourceDirty(Plug_ResourceRef resource, Boolean dirty)
{
((ResourceObjectPtr) resource)->SetDirty( dirty );
((ResourceObjectPtr) resource)->SetDirty(dirty);
}
/* utilities */
Handle Host_GetDefaultTemplate( ResType type )
Handle Host_GetDefaultTemplate(ResType type)
{
short savedResFile = CurResFile();
UseResFile( g.appResFile );
UseResFile(g.appResFile);
Str255 name = "\pxxxx";
BlockMoveData( &type, name +1, sizeof(ResType) );
Handle tmpl = Get1NamedResource( 'TMPL', name );
BlockMoveData(&type, name +1, sizeof(ResType));
Handle tmpl = Get1NamedResource('TMPL', name);
OSStatus error = ResError();
UseResFile( savedResFile );
if( error ) return null;
UseResFile(savedResFile);
if(error) return null;
else return tmpl;
}
void Host_AppendMenuToBar( Plug_PlugInRef plug, SInt16 resID )
void Host_AppendMenuToBar(Plug_PlugInRef plug, SInt16 resID)
{
#pragma unused( plug, resID )
#pragma unused(plug, resID)
return;
}
void Host_RemoveMenuFromBar( Plug_PlugInRef plug, SInt16 resID )
void Host_RemoveMenuFromBar(Plug_PlugInRef plug, SInt16 resID)
{
#pragma unused( plug, resID )
#pragma unused(plug, resID)
return;
}
void Host_UpdateMenus( Plug_ResourceRef resource )
void Host_UpdateMenus(Plug_ResourceRef resource)
{
OSStatus error = noErr;
#if TARGET_API_MAC_CARBON
error = CarbonEventUpdateMenus( null, null, null );
// if( error ) DebugError( "\pHost_UpdateMenus hit an error when calling CarbonEventUpdateMenus()" );
error = FileWindowUpdateMenus( null, null, ((ResourceObjectPtr) resource)->File() );
// if( error ) DebugError( "\pHost_UpdateMenus hit an error when calling FileWindowUpdateMenus()" );
error = CarbonEventUpdateMenus(null, null, null);
// if(error) DebugError("\pHost_UpdateMenus hit an error when calling CarbonEventUpdateMenus()");
error = FileWindowUpdateMenus(null, null, ((ResourceObjectPtr) resource)->File());
// if(error) DebugError("\pHost_UpdateMenus hit an error when calling FileWindowUpdateMenus()");
#else
UpdateMenus( ((ResourceObjectPtr) resource)->File()->Window() );
UpdateMenus(((ResourceObjectPtr) resource)->File()->Window());
#endif
}
void Host_DisplayError( ConstStr255Param errorStr, ConstStr255Param explanationStr, UInt8 severity )
void Host_DisplayError(ConstStr255Param errorStr, ConstStr255Param explanationStr, UInt8 severity)
{
#pragma unused( severity )
DisplayError( errorStr, explanationStr );
#pragma unused(severity)
DisplayError(errorStr, explanationStr);
}
void Host_DebugError( ConstStr255Param errorStr, OSStatus number )
void Host_DebugError(ConstStr255Param errorStr, OSStatus number)
{
DebugError( errorStr, number );
DebugError(errorStr, number);
}

View File

@ -94,7 +94,7 @@ extern "C" // functions beginning "Host_" are in ResKnife/Resurrection
* @discussion Plug-ins should call this function immediatly after creating a window to swap their Mac OS <tt>WindowRef</tt>
* for a <tt>Plug_WindowRef</tt>, which allows the host to track the window, it's contents, and to send events there.
*/
ResCall Plug_WindowRef Host_RegisterWindow( Plug_PlugInRef plug, Plug_ResourceRef resource, WindowRef window );
ResCall Plug_WindowRef Host_RegisterWindow(Plug_PlugInRef plug, Plug_ResourceRef resource, WindowRef window);
/*!
* @function Host_InstallClassicWindowEventHandler
* @abstract Without this, non-carbon plugs will not receive events
@ -103,136 +103,136 @@ extern "C" // functions beginning "Host_" are in ResKnife/Resurrection
*
* &bull; kEventWindowClickContentRgn
*/
ResCall void Host_InstallClassicWindowEventHandler( Plug_WindowRef plugWindow, RoutineDescriptor *handler );
ResCall void Host_InstallClassicWindowEventHandler(Plug_WindowRef plugWindow, RoutineDescriptor *handler);
/*!
* @function Host_GetWindowRefFromPlugWindow
* @abstract Allows plug-ins to obtain a Mac OS <tt>WindowRef</tt> from their <tt>Plug_WindowRef</tt>
* @discussion This call must not be made before the window has been registered using <tt>Host_RegisterWindow()</tt>
*/
ResCall WindowRef Host_GetWindowRefFromPlugWindow( Plug_WindowRef plugWindow );
ResCall WindowRef Host_GetWindowRefFromPlugWindow(Plug_WindowRef plugWindow);
/*!
* @function Host_GetPlugWindowFromWindowRef
* @abstract Allows plug-ins to obtain a <tt>Plug_WindowRef</tt> from their Mac OS <tt>WindowRef</tt>
* @discussion This call must not be made before the window has been registered using <tt>Host_RegisterWindow()</tt>
*/
ResCall Plug_WindowRef Host_GetPlugWindowFromWindowRef( WindowRef window );
ResCall Plug_WindowRef Host_GetPlugWindowFromWindowRef(WindowRef window);
/*!
* @function Host_GetPlugRef
* @discussion You will probably need to call this if the system calls one of your routines directly.
*/
ResCall Plug_PlugInRef Host_GetPlugRef( WindowRef window );
ResCall Plug_PlugInRef Host_GetPlugRef(WindowRef window);
/*!
* @function Host_GetResource
* @discussion Returns a reference to any arbitrary resource.
* @param limitToDoc If true, the function will only search the same document that contains the resource returned by Host_GetTargetResource. If false, it will return any resource in the current resource chain.
*/
ResCall Plug_ResourceRef Host_GetResource( SInt32 type, SInt32 resID, Boolean limitToDoc );
ResCall Plug_ResourceRef Host_GetResource(SInt32 type, SInt32 resID, Boolean limitToDoc);
/*!
* @function Host_GetTargetResource
* @discussion Returns the reference to the resource you're actually editing.
*/
ResCall Plug_ResourceRef Host_GetTargetResource( Plug_WindowRef plugWindow );
ResCall Plug_ResourceRef Host_GetTargetResource(Plug_WindowRef plugWindow);
/*!
* @function Host_GetResourceData
* @discussion Dispose of with <tt>Host_ReleaseResourceData()</tt>
*/
ResCall Handle Host_GetResourceData( Plug_ResourceRef resource );
ResCall Handle Host_GetResourceData(Plug_ResourceRef resource);
/*!
* @function Host_GetPartialResourceData
* @discussion Dispose of with <tt>Host_ReleasePartialResourceData()</tt>
*/
ResCall Handle Host_GetPartialResourceData( Plug_ResourceRef resource, UInt32 offset, UInt32 length );
ResCall Handle Host_GetPartialResourceData(Plug_ResourceRef resource, UInt32 offset, UInt32 length);
/*!
* @function Host_ReleaseResourceData
*/
ResCall void Host_ReleaseResourceData( Plug_ResourceRef resource );
ResCall void Host_ReleaseResourceData(Plug_ResourceRef resource);
/*!
* @function Host_ReleasePartialResourceData
*/
ResCall void Host_ReleasePartialResourceData( Plug_ResourceRef resource, Handle data );
ResCall void Host_ReleasePartialResourceData(Plug_ResourceRef resource, Handle data);
/*!
* @function Host_GetResourceType
*/
ResCall ResType Host_GetResourceType( Plug_ResourceRef resource );
ResCall ResType Host_GetResourceType(Plug_ResourceRef resource);
/*!
* @function Host_GetResourceID
*/
ResCall SInt16 Host_GetResourceID( Plug_ResourceRef resource );
ResCall SInt16 Host_GetResourceID(Plug_ResourceRef resource);
/*!
* @function Host_GetResourceSize
*/
ResCall UInt32 Host_GetResourceSize( Plug_ResourceRef resource );
ResCall UInt32 Host_GetResourceSize(Plug_ResourceRef resource);
/*!
* @function Host_GetResourceName
*/
ResCall void Host_GetResourceName( Plug_ResourceRef resource, Str255 name );
/* ResCall void Host_SetResourceName( Plug_ResourceRef resource, ConstStr255Param name ); */
ResCall void Host_GetResourceName(Plug_ResourceRef resource, Str255 name);
/* ResCall void Host_SetResourceName(Plug_ResourceRef resource, ConstStr255Param name); */
/*!
* @function Host_GetResourceDirty
*/
ResCall Boolean Host_GetResourceDirty( Plug_ResourceRef resource );
ResCall Boolean Host_GetResourceDirty(Plug_ResourceRef resource);
/*!
* @function Host_SetResourceDirty
*/
ResCall void Host_SetResourceDirty( Plug_ResourceRef resource, Boolean dirty );
/* ResCall Boolean Host_GetResourceIsOnDisk( Plug_ResourceRef resource ); */ // name may change soon
ResCall void Host_SetResourceDirty(Plug_ResourceRef resource, Boolean dirty);
/* ResCall Boolean Host_GetResourceIsOnDisk(Plug_ResourceRef resource); */ // name may change soon
/*!
* @function Host_GetWindowRefCon
*/
ResCall UInt32 Host_GetWindowRefCon( Plug_WindowRef plugWindow );
ResCall UInt32 Host_GetWindowRefCon(Plug_WindowRef plugWindow);
/*!
* @function Host_SetWindowRefCon
*/
ResCall void Host_SetWindowRefCon( Plug_WindowRef plugWindow, UInt32 value );
ResCall void Host_SetWindowRefCon(Plug_WindowRef plugWindow, UInt32 value);
/*!
* @function Host_GetGlobalRefCon
*/
ResCall UInt32 Host_GetGlobalRefCon( Plug_PlugInRef plugRef );
ResCall UInt32 Host_GetGlobalRefCon(Plug_PlugInRef plugRef);
/*!
* @function Host_SetGlobalRefCon
*/
ResCall void Host_SetGlobalRefCon( Plug_PlugInRef plugRef, UInt32 value );
/* ResCall OSStatus Host_OpenEditor( Plug_ResourceRef resource, ResOpenMode mode );
ResCall OSStatus Host_SaveResource( Plug_ResourceRef resource ); // VERY IMPORTANT CALL! - Make when closing window
ResCall void Host_SetCursor( Plug_PlugInRef plugRef, Cursor *cursor );
ResCall void Host_SetCursorToID( Plug_PlugInRef plugRef, SInt16 resID );
ResCall void Host_SetGlobalRefCon(Plug_PlugInRef plugRef, UInt32 value);
/* ResCall OSStatus Host_OpenEditor(Plug_ResourceRef resource, ResOpenMode mode);
ResCall OSStatus Host_SaveResource(Plug_ResourceRef resource); // VERY IMPORTANT CALL! - Make when closing window
ResCall void Host_SetCursor(Plug_PlugInRef plugRef, Cursor *cursor);
ResCall void Host_SetCursorToID(Plug_PlugInRef plugRef, SInt16 resID);
*/
/*!
* @function Host_GetDefaultTemplate
* @abstract Returns the default TMPL resource for the resource type passed in.
* @discussion Handle is <tt>NULL</tt> if no template exists. You must dispose of the handle yourself.
*/
ResCall Handle Host_GetDefaultTemplate( ResType type );
ResCall Handle Host_GetDefaultTemplate(ResType type);
/*!
* @function Host_AppendMenuToBar
* @discussion The host will track your window, and hide the menu when you are not fromtmost.
*/
ResCall void Host_AppendMenuToBar( Plug_PlugInRef plug, SInt16 resID );
ResCall void Host_AppendMenuToBar(Plug_PlugInRef plug, SInt16 resID);
/*!
* @function Host_RemoveMenuFromBar
*/
ResCall void Host_RemoveMenuFromBar( Plug_PlugInRef plug, SInt16 resID );
ResCall void Host_RemoveMenuFromBar(Plug_PlugInRef plug, SInt16 resID);
/*!
* @function Host_UpdateMenus
*/
ResCall void Host_UpdateMenus( Plug_ResourceRef resource );
ResCall void Host_UpdateMenus(Plug_ResourceRef resource);
/*!
* @function Host_DisplayError
* @discussion Errors the user should see
*/
ResCall void Host_DisplayError( ConstStr255Param error, ConstStr255Param explanation, UInt8 severity );
ResCall void Host_DisplayError(ConstStr255Param error, ConstStr255Param explanation, UInt8 severity);
/*!
* @function Host_DebugError
* @discussion Errors the user shouldn't see
*/
ResCall void Host_DebugError( ConstStr255Param error, OSStatus number );
ResCall void Host_DebugError(ConstStr255Param error, OSStatus number);
}
/*** EXPORTED FUNCTIONS ***/
extern "C" // functions beginning "Plug_" should be in your plug-in editor
{
/* required functions - plug-in won't be loaded if all these symbols cannot be found */
/* ResCallBack OSStatus Plug_EditorType( Plug_PlugInRef plugRef, EditorType *type, ResType *kind, UInt8 *number ); // called to identify the number of different types of resources it can handle
/* ResCallBack OSStatus Plug_EditorType(Plug_PlugInRef plugRef, EditorType *type, ResType *kind, UInt8 *number); // called to identify the number of different types of resources it can handle
*/
/*!
* @function Plug_InitInstance
@ -241,14 +241,14 @@ extern "C" // functions beginning "Plug_" should be in your plug-in editor
* @param plug A reference which has been assigned to this plug-in. It will not necessarily remain constant, so do not save it beyond this call returning.
* @param resource A reference to the resource whose editing session has been requested.
*/
ResCallBack OSStatus Plug_InitInstance( Plug_PlugInRef plug, Plug_ResourceRef resource );
/* ResCallBack OSStatus Plug_FlattenResource( Plug_PlugInRef plugRef, Plug_ResourceRef resource ); // update the handle provided by the host (see Host_GetResData)
ResCallBack OSStatus Plug_ResourceChanged( Plug_PlugInRef plugRef, Plug_ResourceRef resource ); // another editor has changed the resource your working on (normally responded to by calling Host_GetResData and a window update)
ResCallBack OSStatus Plug_InitInstance(Plug_PlugInRef plug, Plug_ResourceRef resource);
/* ResCallBack OSStatus Plug_FlattenResource(Plug_PlugInRef plugRef, Plug_ResourceRef resource); // update the handle provided by the host (see Host_GetResData)
ResCallBack OSStatus Plug_ResourceChanged(Plug_PlugInRef plugRef, Plug_ResourceRef resource); // another editor has changed the resource your working on (normally responded to by calling Host_GetResData and a window update)
*/ /* optional functions - only called if they are requested & found */
/* ResCallBack OSStatus Plug_UpdateMenu( Plug_PlugInRef plugRef, Plug_WindowRef windowObject );
ResCallBack OSStatus Plug_HandleMenuCommand( Plug_PlugInRef plugRef, Plug_MenuCommand menuCmd, Boolean *handled );
ResCallBack OSStatus Plug_HandleMenuItem( Plug_PlugInRef plugRef, SInt16 menuID, SInt16 itemID, Boolean *handled ); // name change
ResCallBack OSStatus Plug_AboutBox( Plug_PlugInRef plugRef );
/* ResCallBack OSStatus Plug_UpdateMenu(Plug_PlugInRef plugRef, Plug_WindowRef windowObject);
ResCallBack OSStatus Plug_HandleMenuCommand(Plug_PlugInRef plugRef, Plug_MenuCommand menuCmd, Boolean *handled);
ResCallBack OSStatus Plug_HandleMenuItem(Plug_PlugInRef plugRef, SInt16 menuID, SInt16 itemID, Boolean *handled); // name change
ResCallBack OSStatus Plug_AboutBox(Plug_PlugInRef plugRef);
*/}
#endif

View File

@ -9,12 +9,12 @@ extern globals g;
/*******************/
/*** CONSTRUCTOR ***/
InspectorWindow::InspectorWindow( void )
InspectorWindow::InspectorWindow(void)
{
// if inspector already exists, return
if( g.inspector )
if(g.inspector)
{
SelectWindow( g.inspector->Window() );
SelectWindow(g.inspector->Window());
return;
}
@ -22,37 +22,37 @@ InspectorWindow::InspectorWindow( void )
// create window
Str255 windowName;
Rect creationBounds;
SetRect( &creationBounds, 0, 0, kInspectorWindowWidth, kInspectorWindowHeight );
OffsetRect( &creationBounds, 520, 45 );
OSStatus error = CreateNewWindow( kFloatingWindowClass, kWindowStandardFloatingAttributes | kWindowStandardHandlerAttribute, &creationBounds, &window );
if( !error )
SetRect(&creationBounds, 0, 0, kInspectorWindowWidth, kInspectorWindowHeight);
OffsetRect(&creationBounds, 520, 45);
OSStatus error = CreateNewWindow(kFloatingWindowClass, kWindowStandardFloatingAttributes | kWindowStandardHandlerAttribute, &creationBounds, &window);
if(!error)
{
GetIndString( windowName, kWindowNameStrings, kStringInspectorWindowName );
SetWindowTitle( window, windowName );
SetWindowKind( window, kInspectorWindowKind );
SetThemeWindowBackground( window, kThemeBrushUtilityWindowBackgroundActive, false );
GetIndString(windowName, kWindowNameStrings, kStringInspectorWindowName);
SetWindowTitle(window, windowName);
SetWindowKind(window, kInspectorWindowKind);
SetThemeWindowBackground(window, kThemeBrushUtilityWindowBackgroundActive, false);
// install window event handler
EventHandlerRef ref = null;
EventHandlerUPP eventHandler = NewEventHandlerUPP( CloseInspectorWindow );
EventHandlerUPP eventHandler = NewEventHandlerUPP(CloseInspectorWindow);
EventTypeSpec events[] = { { kEventClassWindow, kEventWindowClose } };
InstallWindowEventHandler( window, eventHandler, GetEventTypeCount(events), (EventTypeSpec *) &events, this, &ref );
InstallWindowEventHandler(window, eventHandler, GetEventTypeCount(events), (EventTypeSpec *) &events, this, &ref);
// create root control
Rect bounds;
if( g.systemVersion < kMacOSX )
if(g.systemVersion < kMacOSX)
{
ControlRef root;
CreateRootControl( window, &root );
CreateRootControl(window, &root);
}
// create image well
ControlRef imageWell;
ControlButtonContentInfo content;
content.contentType = kControlNoContent;
SetRect( &bounds, 0, 0, 44, 44 );
OffsetRect( &bounds, 8, 8 );
CreateImageWellControl( window, &bounds, &content, &imageWell );
SetRect(&bounds, 0, 0, 44, 44);
OffsetRect(&bounds, 8, 8);
CreateImageWellControl(window, &bounds, &content, &imageWell);
// create static text controls
Rect windowRect;
@ -61,210 +61,210 @@ InspectorWindow::InspectorWindow( void )
fontStyle.flags = kControlUseFontMask + kControlUseJustMask;
fontStyle.font = kControlFontSmallSystemFont;
fontStyle.just = teJustLeft;
GetWindowPortBounds( window, &windowRect );
SetRect( &bounds, windowRect.left +60, windowRect.top +8, windowRect.right - windowRect.left -8, windowRect.top +36 );
CreateStaticTextControl( window, &bounds, CFSTR(""), &fontStyle, &name );
GetWindowPortBounds(window, &windowRect);
SetRect(&bounds, windowRect.left +60, windowRect.top +8, windowRect.right - windowRect.left -8, windowRect.top +36);
CreateStaticTextControl(window, &bounds, CFSTR(""), &fontStyle, &name);
fontStyle.font = kControlFontSmallBoldSystemFont;
SetRect( &bounds, windowRect.left +60, windowRect.top +38, windowRect.right - windowRect.left -70, windowRect.top +52 );
CreateStaticTextControl( window, &bounds, CFSTR(""), &fontStyle, &type );
SetRect( &bounds, windowRect.right - windowRect.left -70, windowRect.top +38, windowRect.right - windowRect.left -8, windowRect.top +52 );
CreateStaticTextControl( window, &bounds, CFSTR(""), &fontStyle, &id );
SetRect(&bounds, windowRect.left +60, windowRect.top +38, windowRect.right - windowRect.left -70, windowRect.top +52);
CreateStaticTextControl(window, &bounds, CFSTR(""), &fontStyle, &type);
SetRect(&bounds, windowRect.right - windowRect.left -70, windowRect.top +38, windowRect.right - windowRect.left -8, windowRect.top +52);
CreateStaticTextControl(window, &bounds, CFSTR(""), &fontStyle, &id);
// create group control
ControlRef group;
GetWindowPortBounds( window, &bounds );
InsetRect( &bounds, 8, 8 );
GetWindowPortBounds(window, &bounds);
InsetRect(&bounds, 8, 8);
bounds.top += kInspectorHeaderHeight;
CreateGroupBoxControl( window, &bounds, CFSTR("Attributes"), true, &group );
CreateGroupBoxControl(window, &bounds, CFSTR("Attributes"), true, &group);
// create checkboxes
ControlRef changedBox, preloadBox, protectedBox,
lockedBox, purgeableBox, sysHeapBox;
InsetRect( &bounds, 4, 4 );
InsetRect(&bounds, 4, 4);
bounds.top = bounds.bottom - kControlCheckBoxHeight;
CreateCheckBoxControl( window, &bounds, CFSTR("System Heap"), kControlCheckBoxUncheckedValue, true, &sysHeapBox );
CreateCheckBoxControl(window, &bounds, CFSTR("System Heap"), kControlCheckBoxUncheckedValue, true, &sysHeapBox);
bounds.top -= kControlCheckBoxHeight;
bounds.bottom -= kControlCheckBoxHeight;
CreateCheckBoxControl( window, &bounds, CFSTR("Purgeable"), kControlCheckBoxUncheckedValue, true, &purgeableBox );
CreateCheckBoxControl(window, &bounds, CFSTR("Purgeable"), kControlCheckBoxUncheckedValue, true, &purgeableBox);
bounds.top -= kControlCheckBoxHeight;
bounds.bottom -= kControlCheckBoxHeight;
CreateCheckBoxControl( window, &bounds, CFSTR("Locked"), kControlCheckBoxUncheckedValue, true, &lockedBox );
CreateCheckBoxControl(window, &bounds, CFSTR("Locked"), kControlCheckBoxUncheckedValue, true, &lockedBox);
bounds.top -= kControlCheckBoxHeight;
bounds.bottom -= kControlCheckBoxHeight;
CreateCheckBoxControl( window, &bounds, CFSTR("Protected"), kControlCheckBoxUncheckedValue, true, &protectedBox );
CreateCheckBoxControl(window, &bounds, CFSTR("Protected"), kControlCheckBoxUncheckedValue, true, &protectedBox);
bounds.top -= kControlCheckBoxHeight;
bounds.bottom -= kControlCheckBoxHeight;
CreateCheckBoxControl( window, &bounds, CFSTR("Preload"), kControlCheckBoxUncheckedValue, true, &preloadBox );
CreateCheckBoxControl(window, &bounds, CFSTR("Preload"), kControlCheckBoxUncheckedValue, true, &preloadBox);
bounds.top -= kControlCheckBoxHeight;
bounds.bottom -= kControlCheckBoxHeight;
CreateCheckBoxControl( window, &bounds, CFSTR("Changed"), kControlCheckBoxUncheckedValue, true, &changedBox );
CreateCheckBoxControl(window, &bounds, CFSTR("Changed"), kControlCheckBoxUncheckedValue, true, &changedBox);
// embed controls
EmbedControl( changedBox, group );
EmbedControl( preloadBox, group );
EmbedControl( protectedBox, group );
EmbedControl( lockedBox, group );
EmbedControl( purgeableBox, group );
EmbedControl( sysHeapBox, group );
EmbedControl(changedBox, group);
EmbedControl(preloadBox, group);
EmbedControl(protectedBox, group);
EmbedControl(lockedBox, group);
EmbedControl(purgeableBox, group);
EmbedControl(sysHeapBox, group);
}
else window = NULL;
#else
if( g.useAppearance && g.systemVersion >= kMacOS8 )
window = GetNewCWindow( kFileWindow8, null, kFirstWindowOfClass );
if(g.useAppearance && g.systemVersion >= kMacOS8)
window = GetNewCWindow(kFileWindow8, null, kFirstWindowOfClass);
else
window = GetNewCWindow( kFileWindow7, null, kFirstWindowOfClass );
window = GetNewCWindow(kFileWindow7, null, kFirstWindowOfClass);
#endif
if( window )
if(window)
{
// update and show window
Update();
ShowWindow( window );
ShowWindow(window);
g.inspector = this;
}
else g.inspector = NULL;
}
/*** DESTRUCTOR ***/
InspectorWindow::~InspectorWindow( void )
InspectorWindow::~InspectorWindow(void)
{
g.inspector = null;
}
/*** CLOSW WINDOW EVENT HANDLER ***/
pascal OSStatus CloseInspectorWindow( EventHandlerCallRef callRef, EventRef event, void *userData )
pascal OSStatus CloseInspectorWindow(EventHandlerCallRef callRef, EventRef event, void *userData)
{
#pragma unused( callRef, event, userData )
if( g.inspector ) delete g.inspector;
#pragma unused(callRef, event, userData)
if(g.inspector) delete g.inspector;
return eventNotHandledErr;
}
/*** UPDATE WINDOW ***/
OSStatus InspectorWindow::Update( RgnHandle region )
OSStatus InspectorWindow::Update(RgnHandle region)
{
#pragma unused( region )
#pragma unused(region)
#if TARGET_API_MAC_CARBON
// get target file
FileWindowPtr file = null;
WindowRef fileWindow = GetFrontWindowOfClass( kDocumentWindowClass, true );
if( !fileWindow ) return noErr; // no window is open - BUG: items in window are not cleared
WindowRef fileWindow = GetFrontWindowOfClass(kDocumentWindowClass, true);
if(!fileWindow) return noErr; // no window is open - BUG: items in window are not cleared
OSStatus error = noErr;
Boolean validWindow = false;
while( !validWindow || error )
while(!validWindow || error)
{
WindowKind kind = (WindowKind) GetWindowKind( fileWindow );
if( kind != kFileWindowKind )
WindowKind kind = (WindowKind) GetWindowKind(fileWindow);
if(kind != kFileWindowKind)
{
fileWindow = GetNextWindowOfClass( fileWindow, kDocumentWindowClass, true );
if( !window ) error = paramErr;
fileWindow = GetNextWindowOfClass(fileWindow, kDocumentWindowClass, true);
if(!window) error = paramErr;
}
else
{
file = (FileWindowPtr) GetWindowRefCon( fileWindow );
if( file ) validWindow = true;
file = (FileWindowPtr) GetWindowRefCon(fileWindow);
if(file) validWindow = true;
else error = paramErr;
}
}
if( error ) return error;
if(error) return error;
// get selection
UInt32 itemCount;
ControlRef browser = null;
GetWindowProperty( fileWindow, kResKnifeCreator, kDataBrowserSignature, sizeof(ControlRef), null, &browser );
GetDataBrowserItemCount( browser, kDataBrowserNoItem, true, kDataBrowserItemIsSelected, &itemCount );
GetWindowProperty(fileWindow, kResKnifeCreator, kDataBrowserSignature, sizeof(ControlRef), null, &browser);
GetDataBrowserItemCount(browser, kDataBrowserNoItem, true, kDataBrowserItemIsSelected, &itemCount);
// get controls
ControlRef root, well, name, type, id, group;
ControlRef changedBox, preloadBox, protectedBox, lockedBox, purgeableBox, sysHeapBox;
ControlButtonContentInfo content;
GetRootControl( window, &root );
GetIndexedSubControl( root, 1, &well );
GetIndexedSubControl( root, 2, &name );
GetIndexedSubControl( root, 3, &type );
GetIndexedSubControl( root, 4, &id );
GetIndexedSubControl( root, 5, &group );
GetIndexedSubControl( group, 1, &changedBox );
GetIndexedSubControl( group, 2, &preloadBox );
GetIndexedSubControl( group, 3, &protectedBox );
GetIndexedSubControl( group, 4, &lockedBox );
GetIndexedSubControl( group, 5, &purgeableBox );
GetIndexedSubControl( group, 6, &sysHeapBox );
GetRootControl(window, &root);
GetIndexedSubControl(root, 1, &well);
GetIndexedSubControl(root, 2, &name);
GetIndexedSubControl(root, 3, &type);
GetIndexedSubControl(root, 4, &id);
GetIndexedSubControl(root, 5, &group);
GetIndexedSubControl(group, 1, &changedBox);
GetIndexedSubControl(group, 2, &preloadBox);
GetIndexedSubControl(group, 3, &protectedBox);
GetIndexedSubControl(group, 4, &lockedBox);
GetIndexedSubControl(group, 5, &purgeableBox);
GetIndexedSubControl(group, 6, &sysHeapBox);
if( itemCount != 1 )
if(itemCount != 1)
{
// set icon
content.contentType = kControlNoContent;
SetImageWellContentInfo( well, &content );
DrawOneControl( well ); // bug: work around for bug in ControlManager
// DisableControl( well );
SetImageWellContentInfo(well, &content);
DrawOneControl(well); // bug: work around for bug in ControlManager
// DisableControl(well);
// set name
StringPtr blank = (StringPtr) NewPtrClear( sizeof(Str255) );
CopyPascalStringToC( "\p", (char *) blank );
SetControlData( name, kControlLabelPart, kControlStaticTextTextTag, 1, blank );
SetControlTitle( name, "\p" );
StringPtr blank = (StringPtr) NewPtrClear(sizeof(Str255));
CopyPascalStringToC("\p", (char *) blank);
SetControlData(name, kControlLabelPart, kControlStaticTextTextTag, 1, blank);
SetControlTitle(name, "\p");
// set type
SetControlData( type, kControlLabelPart, kControlStaticTextTextTag, 1, blank );
SetControlTitle( type, "\p" );
SetControlData(type, kControlLabelPart, kControlStaticTextTextTag, 1, blank);
SetControlTitle(type, "\p");
// set ID
SetControlData( id, kControlLabelPart, kControlStaticTextTextTag, 1, blank );
SetControlTitle( id, "\p" );
SetControlData(id, kControlLabelPart, kControlStaticTextTextTag, 1, blank);
SetControlTitle(id, "\p");
// set control values
SetControlValue( changedBox, kControlCheckBoxUncheckedValue );
SetControlValue( preloadBox, kControlCheckBoxUncheckedValue );
SetControlValue( protectedBox, kControlCheckBoxUncheckedValue );
SetControlValue( lockedBox, kControlCheckBoxUncheckedValue );
SetControlValue( purgeableBox, kControlCheckBoxUncheckedValue );
SetControlValue( sysHeapBox, kControlCheckBoxUncheckedValue );
// DisableControl( group );
SetControlValue(changedBox, kControlCheckBoxUncheckedValue);
SetControlValue(preloadBox, kControlCheckBoxUncheckedValue);
SetControlValue(protectedBox, kControlCheckBoxUncheckedValue);
SetControlValue(lockedBox, kControlCheckBoxUncheckedValue);
SetControlValue(purgeableBox, kControlCheckBoxUncheckedValue);
SetControlValue(sysHeapBox, kControlCheckBoxUncheckedValue);
// DisableControl(group);
}
else
{
// get selected resource
DataBrowserItemID first, last;
GetDataBrowserSelectionAnchor( browser, &first, &last ); // first must == last
GetDataBrowserSelectionAnchor(browser, &first, &last); // first must == last
ResourceObjectPtr resource = file->GetResource(first);
// set icon
content.contentType = kControlContentIconSuiteRes;
content.u.resID = kDefaultResourceIcon;
SetImageWellContentInfo( well, &content );
DrawOneControl( well ); // bug: work around for bug in ControlManager
// EnableControl( well );
SetImageWellContentInfo(well, &content);
DrawOneControl(well); // bug: work around for bug in ControlManager
// EnableControl(well);
// set name
StringPtr label = (StringPtr) NewPtrClear( sizeof(Str255) );
if( PStringLength( resource->Name()) == 0 ) GetIndString( label, kResourceNameStrings, kStringUntitledResource );
else CopyPascalStringToC( resource->Name(), (char *) label );
SetControlData( name, kControlLabelPart, kControlStaticTextTextTag, PStringLength(resource->Name()), label );
SetControlTitle( name, resource->Name() );
StringPtr label = (StringPtr) NewPtrClear(sizeof(Str255));
if(PStringLength(resource->Name()) == 0) GetIndString(label, kResourceNameStrings, kStringUntitledResource);
else CopyPascalStringToC(resource->Name(), (char *) label);
SetControlData(name, kControlLabelPart, kControlStaticTextTextTag, PStringLength(resource->Name()), label);
SetControlTitle(name, resource->Name());
// set type
Str255 string;
TypeToPString( resource->Type(), string );
CopyPascalStringToC( string, (char *) label );
SetControlData( type, kControlLabelPart, kControlStaticTextTextTag, string[0], label );
SetControlTitle( type, string );
TypeToPString(resource->Type(), string);
CopyPascalStringToC(string, (char *) label);
SetControlData(type, kControlLabelPart, kControlStaticTextTextTag, string[0], label);
SetControlTitle(type, string);
// set ID
NumToString( resource->ID(), string );
CopyPascalStringToC( string, (char *) label );
SetControlData( id, kControlLabelPart, kControlStaticTextTextTag, string[0], label );
SetControlTitle( id, string );
NumToString(resource->ID(), string);
CopyPascalStringToC(string, (char *) label);
SetControlData(id, kControlLabelPart, kControlStaticTextTextTag, string[0], label);
SetControlTitle(id, string);
// set control values
SetControlValue( changedBox, (resource->Attributes() & resChanged)? kControlCheckBoxCheckedValue : kControlCheckBoxUncheckedValue );
SetControlValue( preloadBox, (resource->Attributes() & resPreload)? kControlCheckBoxCheckedValue : kControlCheckBoxUncheckedValue );
SetControlValue( protectedBox, (resource->Attributes() & resProtected)? kControlCheckBoxCheckedValue : kControlCheckBoxUncheckedValue );
SetControlValue( lockedBox, (resource->Attributes() & resLocked)? kControlCheckBoxCheckedValue : kControlCheckBoxUncheckedValue );
SetControlValue( purgeableBox, (resource->Attributes() & resPurgeable)? kControlCheckBoxCheckedValue : kControlCheckBoxUncheckedValue );
SetControlValue( sysHeapBox, (resource->Attributes() & resSysHeap)? kControlCheckBoxCheckedValue : kControlCheckBoxUncheckedValue );
DeactivateControl( changedBox );
// EnableControl( group );
SetControlValue(changedBox, (resource->Attributes() & resChanged)? kControlCheckBoxCheckedValue : kControlCheckBoxUncheckedValue);
SetControlValue(preloadBox, (resource->Attributes() & resPreload)? kControlCheckBoxCheckedValue : kControlCheckBoxUncheckedValue);
SetControlValue(protectedBox, (resource->Attributes() & resProtected)? kControlCheckBoxCheckedValue : kControlCheckBoxUncheckedValue);
SetControlValue(lockedBox, (resource->Attributes() & resLocked)? kControlCheckBoxCheckedValue : kControlCheckBoxUncheckedValue);
SetControlValue(purgeableBox, (resource->Attributes() & resPurgeable)? kControlCheckBoxCheckedValue : kControlCheckBoxUncheckedValue);
SetControlValue(sysHeapBox, (resource->Attributes() & resSysHeap)? kControlCheckBoxCheckedValue : kControlCheckBoxUncheckedValue);
DeactivateControl(changedBox);
// EnableControl(group);
}
return error;
#else

View File

@ -10,12 +10,12 @@
class InspectorWindow : WindowObject
{
public:
InspectorWindow( void );
~InspectorWindow( void );
virtual OSStatus Update( RgnHandle region = null ); // unused parameter
InspectorWindow(void);
~InspectorWindow(void);
virtual OSStatus Update(RgnHandle region = null); // unused parameter
};
pascal OSStatus CloseInspectorWindow( EventHandlerCallRef callRef, EventRef event, void *userData );
pascal OSStatus CloseInspectorWindow(EventHandlerCallRef callRef, EventRef event, void *userData);
// inspector window dimentions
const UInt16 kInspectorHeaderHeight = 48 + 4; // 48 for huge icon

View File

@ -6,45 +6,45 @@
extern globals g;
/*** CREATOR ***/
PickerWindow::PickerWindow( FileWindowPtr ownerFile, ResType resType ) : PlugWindow( ownerFile )
PickerWindow::PickerWindow(FileWindowPtr ownerFile, ResType resType) : PlugWindow(ownerFile)
{
OSStatus error = noErr;
#if USE_NIBS
// create a nib reference (only searches the application bundle)
IBNibRef nibRef = null;
error = CreateNibReference( CFSTR("ResKnife"), &nibRef );
if( error != noErr || nibRef == null )
error = CreateNibReference(CFSTR("ResKnife"), &nibRef);
if(error != noErr || nibRef == null)
{
DisplayError( "\pThe nib file reference could not be obtained." );
DisplayError("\pThe nib file reference could not be obtained.");
return;
}
// create window
error = CreateWindowFromNib( nibRef, CFSTR("Picker Window"), &window );
if( error != noErr || window == null )
error = CreateWindowFromNib(nibRef, CFSTR("Picker Window"), &window);
if(error != noErr || window == null)
{
DisplayError( "\pA picker window could not be obtained from the nib file." );
DisplayError("\pA picker window could not be obtained from the nib file.");
return;
}
// dispose of nib ref
DisposeNibReference( nibRef );
DisposeNibReference(nibRef);
#elif TARGET_API_MAC_CARBON
// create window
Rect creationBounds;
SetRect( &creationBounds, 9, 45, 256 +9, 256 +45 );
error = CreateNewWindow( kDocumentWindowClass, kWindowStandardDocumentAttributes | kWindowStandardHandlerAttribute, &creationBounds, &window );
SetRect(&creationBounds, 9, 45, 256 +9, 256 +45);
error = CreateNewWindow(kDocumentWindowClass, kWindowStandardDocumentAttributes | kWindowStandardHandlerAttribute, &creationBounds, &window);
#else
if( g.useAppearance && g.systemVersion >= kMacOS8 )
if(g.useAppearance && g.systemVersion >= kMacOS8)
{
window = GetNewCWindow( kFileWindow8, null, kFirstWindowOfClass );
window = GetNewCWindow(kFileWindow8, null, kFirstWindowOfClass);
themeSavvy = true;
}
else
{
window = GetNewCWindow( kFileWindow7, null, kFirstWindowOfClass );
window = GetNewCWindow(kFileWindow7, null, kFirstWindowOfClass);
themeSavvy = false;
}
#endif
@ -52,22 +52,22 @@ PickerWindow::PickerWindow( FileWindowPtr ownerFile, ResType resType ) : PlugWin
// set up default window title
Str255 windowTitle, resTypeStr;
FSSpec spec = *ownerFile->GetFileSpec();
CopyPString( spec.name, windowTitle );
TypeToPString( resType, resTypeStr );
AppendPString( windowTitle, "\p: " );
AppendPString( windowTitle, resTypeStr );
AppendPString( windowTitle, "\p resources" );
CopyPString(spec.name, windowTitle);
TypeToPString(resType, resTypeStr);
AppendPString(windowTitle, "\p: ");
AppendPString(windowTitle, resTypeStr);
AppendPString(windowTitle, "\p resources");
// save PickerWindow class in window's refcon
SetWindowRefCon( window, (UInt32) this );
SetWindowKind( window, kPickerWindowKind );
SetWindowTitle( window, windowTitle );
SetWindowRefCon(window, (UInt32) this);
SetWindowKind(window, kPickerWindowKind);
SetWindowTitle(window, windowTitle);
// set window's background to default for theme
#if TARGET_API_MAC_CARBON
SetThemeWindowBackground( window, kThemeBrushDocumentWindowBackground, true );
SetThemeWindowBackground(window, kThemeBrushDocumentWindowBackground, true);
#else
if( g.useAppearance )
SetThemeWindowBackground( window, kThemeBrushDocumentWindowBackground, false );
if(g.useAppearance)
SetThemeWindowBackground(window, kThemeBrushDocumentWindowBackground, false);
#endif
}

View File

@ -17,7 +17,7 @@ class PickerWindow : PlugWindow
{
public:
// methods
PickerWindow( FileWindowPtr ownerFile, ResType resType );
PickerWindow(FileWindowPtr ownerFile, ResType resType);
};
#endif

View File

@ -3,80 +3,80 @@
extern globals g;
/*** LOAD EDITOR ***/
OSStatus LoadEditor( ResourceObjectPtr resource, ConstStr63Param libName )
OSStatus LoadEditor(ResourceObjectPtr resource, ConstStr63Param libName)
{
// create editor window structure and save resource to be edited into it
OSStatus error = noErr;
PlugObjectPtr plug = (PlugObjectPtr) NewPtrClear( sizeof(PlugObject) ); // bug: this function calls itself, so memory leak may exist here
if( !plug ) return memFullErr; // another bug: should check if plug already has associated PlugObject (ie it is loaded already) - globalRefCon won't work
PlugObjectPtr plug = (PlugObjectPtr) NewPtrClear(sizeof(PlugObject)); // bug: this function calls itself, so memory leak may exist here
if(!plug) return memFullErr; // another bug: should check if plug already has associated PlugObject (ie it is loaded already) - globalRefCon won't work
// load editor's library into memory
CFragConnectionID connID = null;
Ptr mainAddr = null;
Str255 errMessage;
error = GetSharedLibrary( libName, kPowerPCCFragArch, kLoadCFrag, &connID, &mainAddr, errMessage );
DebugError( errMessage );
if( error )
error = GetSharedLibrary(libName, kPowerPCCFragArch, kLoadCFrag, &connID, &mainAddr, errMessage);
DebugError(errMessage);
if(error)
{
if( EqualString( libName, "\pHex Editor", true, true ) )
if(EqualString(libName, "\pHex Editor", true, true))
{
DisposePtr( (Ptr) plug ); // only dispose if was created just now
DisplayError( "\pNo editors are available for this resource!", "\pI suggest you reinstall the program." );
DisposePtr((Ptr) plug); // only dispose if was created just now
DisplayError("\pNo editors are available for this resource!", "\pI suggest you reinstall the program.");
return error;
}
else if( EqualString( libName, "\pTemplate Editor", true, true ) )
else if(EqualString(libName, "\pTemplate Editor", true, true))
{
error = LoadEditor( resource, "\pHex Editor" );
error = LoadEditor(resource, "\pHex Editor");
return error;
}
else
{
error = LoadEditor( resource, "\pTemplate Editor" );
if( error )
error = LoadEditor( resource, "\pHex Editor" );
error = LoadEditor(resource, "\pTemplate Editor");
if(error)
error = LoadEditor(resource, "\pHex Editor");
return error;
}
}
plug->SetConnectionID( connID );
plug->SetConnectionID(connID);
// find and call InitInstance symbol
InitPlugProcPtr symAddr;
CFragSymbolClass symClass;
error = FindSymbol( connID, "\pPlug_InitInstance", (Ptr *) &symAddr, &symClass );
if( error )
error = FindSymbol(connID, "\pPlug_InitInstance", (Ptr *) &symAddr, &symClass);
if(error)
{
DisposePtr( (Ptr) plug ); // only dispose if was created just now
if( g.debug ) DebugError( "\pPlug_InitInstance() could not be found." );
else DisplayError( "\pCannot load up requested editor.", "\pPlease obtain an update from the plug-in's author." );
DisposePtr((Ptr) plug); // only dispose if was created just now
if(g.debug) DebugError("\pPlug_InitInstance() could not be found.");
else DisplayError("\pCannot load up requested editor.", "\pPlease obtain an update from the plug-in's author.");
return error;
}
error = (* symAddr)( plug, resource );
if( error )
error = (* symAddr)(plug, resource);
if(error)
{
DisposePtr( (Ptr) plug ); // only dispose if was created just now
DebugError( "\pPlug_InitInstance() returned an error. This is quite normal for the Template Editor, thus if no XXXX Editor exists, and no template is found, you will see this dialog, then a hex editor appear." );
DisposePtr((Ptr) plug); // only dispose if was created just now
DebugError("\pPlug_InitInstance() returned an error. This is quite normal for the Template Editor, thus if no XXXX Editor exists, and no template is found, you will see this dialog, then a hex editor appear.");
}
return error;
}
/*** UNLOAD EDITOR ***/
OSStatus UnloadEditor( PlugObjectPtr plug )
OSStatus UnloadEditor(PlugObjectPtr plug)
{
#pragma unused( plug )
#pragma unused(plug)
OSStatus error = noErr;
CFragConnectionID connID = plug->GetConnectionID();
// find and call DisposeEditor symbol
/* DisposePlugProcPtr symAddr;
CFragSymbolClass symClass;
error = FindSymbol( connID, "\pPlug_DisposeEditor", (Ptr *) &symAddr, &symClass );
if( error ) return error;
(* symAddr)( plug );
error = FindSymbol(connID, "\pPlug_DisposeEditor", (Ptr *) &symAddr, &symClass);
if(error) return error;
(* symAddr)(plug);
*/
// close connection to editor
error = CloseConnection( &connID );
plug->SetConnectionID( null );
error = CloseConnection(&connID);
plug->SetConnectionID(null);
return error;
}
@ -85,11 +85,11 @@ OSStatus UnloadEditor( PlugObjectPtr plug )
/**************************/
/*** ACCESSORS ***/
void PlugObject::SetRefCon( UInt32 value ) { refcon = value; }
UInt32 PlugObject::GetRefCon( void ) { return refcon; }
CFragConnectionID PlugObject::GetConnectionID( void ) { return connID; }
void PlugObject::SetConnectionID( CFragConnectionID newID ) { connID = newID; }
WindowObjectPtr PlugObject::GetWindowObject( void ) { return windowObj; }
void PlugObject::SetWindowObject( WindowObjectPtr newWindowObj ) { windowObj = newWindowObj; }
ResourceObjectPtr PlugObject::GetResourceObject( void ) { return resourceObj; }
void PlugObject::SetResourceObject( ResourceObjectPtr newResourceObj ) { resourceObj = newResourceObj; }
void PlugObject::SetRefCon(UInt32 value) { refcon = value; }
UInt32 PlugObject::GetRefCon(void) { return refcon; }
CFragConnectionID PlugObject::GetConnectionID(void) { return connID; }
void PlugObject::SetConnectionID(CFragConnectionID newID) { connID = newID; }
WindowObjectPtr PlugObject::GetWindowObject(void) { return windowObj; }
void PlugObject::SetWindowObject(WindowObjectPtr newWindowObj) { windowObj = newWindowObj; }
ResourceObjectPtr PlugObject::GetResourceObject(void) { return resourceObj; }
void PlugObject::SetResourceObject(ResourceObjectPtr newResourceObj) { resourceObj = newResourceObj; }

View File

@ -36,42 +36,42 @@ public:
@function GetConnectionID
@discussion Accessor function.
*/
CFragConnectionID GetConnectionID( void );
CFragConnectionID GetConnectionID(void);
/*!
@function SetConnectionID
@discussion Accessor function.
*/
void SetConnectionID( CFragConnectionID newID );
void SetConnectionID(CFragConnectionID newID);
/*!
@function GetWindowObject
@discussion Accessor function.
*/
WindowObjectPtr GetWindowObject( void );
WindowObjectPtr GetWindowObject(void);
/*!
@function SetWindowObject
@discussion Accessor function.
*/
void SetWindowObject( WindowObjectPtr newWindowObj );
void SetWindowObject(WindowObjectPtr newWindowObj);
/*!
@function GetResourceObject
@discussion Accessor function.
*/
ResourceObjectPtr GetResourceObject( void );
ResourceObjectPtr GetResourceObject(void);
/*!
@function SetResourceObject
@discussion Accessor function.
*/
void SetResourceObject( ResourceObjectPtr newResourceObj );
void SetResourceObject(ResourceObjectPtr newResourceObj);
/*!
@function SetRefCon
@discussion Accessor function.
*/
void SetRefCon( UInt32 value );
void SetRefCon(UInt32 value);
/*!
@function GetRefCon
@discussion Accessor function.
*/
UInt32 GetRefCon( void );
UInt32 GetRefCon(void);
} PlugObject, *PlugObjectPtr;
/*!
@ -80,18 +80,18 @@ public:
@param resource The resource to be edited.
@param libName A string containing the fragment name of the editor to be used, for example "icns Editor" or "PICT Picker".
*/
OSStatus LoadEditor( ResourceObjectPtr resource, ConstStr63Param libName );
OSStatus LoadEditor(ResourceObjectPtr resource, ConstStr63Param libName);
/*!
@function UnloadEditor
@discussion Unloads the given plug.
@param plug The plug-in to be killed.
*/
OSStatus UnloadEditor( PlugObjectPtr plug );
OSStatus UnloadEditor(PlugObjectPtr plug);
/*!
@typedef InitPlugProcPtr
@discussion The pointer to Plug_InitInstance() that FindSymbol returns.
*/
typedef OSStatus (* InitPlugProcPtr)( PlugObjectPtr plug, ResourceObjectPtr resource );
typedef OSStatus (* InitPlugProcPtr)(PlugObjectPtr plug, ResourceObjectPtr resource);
#endif

View File

@ -8,14 +8,14 @@ extern globals g;
/*********************/
/*** CREATOR ***/
PlugWindow::PlugWindow( FileWindowPtr ownerFile )
PlugWindow::PlugWindow(FileWindowPtr ownerFile)
{
memset( this, 0, sizeof(PlugWindow) );
memset(this, 0, sizeof(PlugWindow));
file = ownerFile;
}
/*** GET FILE WINDOW ***/
FileWindowPtr PlugWindow::File( void )
FileWindowPtr PlugWindow::File(void)
{
return file;
}
@ -23,13 +23,13 @@ FileWindowPtr PlugWindow::File( void )
#if !TARGET_API_MAC_CARBON
/*** INSTALL CLASSIC EVENT HANDLER ***/
void PlugWindow::InstallClassicEventHandler( ClassicEventHandlerProcPtr newHandler )
void PlugWindow::InstallClassicEventHandler(ClassicEventHandlerProcPtr newHandler)
{
handler = newHandler;
}
/*** UPDATE WINDOW ***/
OSStatus PlugWindow::Update( RgnHandle region )
OSStatus PlugWindow::Update(RgnHandle region)
{
EventRecord event;
event.what = updateEvt;
@ -38,12 +38,12 @@ OSStatus PlugWindow::Update( RgnHandle region )
event.where = NewPoint();
event.modifiers = null;
OSStatus error = (* handler)( &event, kEventWindowUpdate, null );
OSStatus error = (* handler)(&event, kEventWindowUpdate, null);
return error;
}
/*** ACTIVATE WINDOW ***/
OSStatus PlugWindow::Activate( Boolean active )
OSStatus PlugWindow::Activate(Boolean active)
{
EventRecord event;
event.what = activateEvt;
@ -52,12 +52,12 @@ OSStatus PlugWindow::Activate( Boolean active )
event.where = NewPoint();
event.modifiers = null;
OSStatus error = (* handler)( &event, active? kEventWindowActivated:kEventWindowDeactivated, null );
OSStatus error = (* handler)(&event, active? kEventWindowActivated:kEventWindowDeactivated, null);
return error;
}
/*** CLOSE WINDOW ***/
OSStatus PlugWindow::Close( void )
OSStatus PlugWindow::Close(void)
{
EventRecord event;
event.what = mouseUp;
@ -66,12 +66,12 @@ OSStatus PlugWindow::Close( void )
event.where = NewPoint();
event.modifiers = null;
OSStatus error = (* handler)( &event, kEventWindowClose, null );
OSStatus error = (* handler)(&event, kEventWindowClose, null);
return error;
}
/*** HANDLE CLICK IN WINDOW ***/
OSStatus PlugWindow::Click( Point mouse, EventModifiers modifiers )
OSStatus PlugWindow::Click(Point mouse, EventModifiers modifiers)
{
EventRecord event;
event.what = mouseDown;
@ -80,12 +80,12 @@ OSStatus PlugWindow::Click( Point mouse, EventModifiers modifiers )
event.where = mouse;
event.modifiers = modifiers;
OSStatus error = (* handler)( &event, kEventWindowClickContentRgn, null );
OSStatus error = (* handler)(&event, kEventWindowClickContentRgn, null);
return error;
}
#endif
/*** ACCESSORS ***/
void PlugWindow::SetRefCon( UInt32 value ) { refcon = value; }
UInt32 PlugWindow::GetRefCon( void ) { return refcon; }
void PlugWindow::SetRefCon(UInt32 value) { refcon = value; }
UInt32 PlugWindow::GetRefCon(void) { return refcon; }

View File

@ -44,35 +44,35 @@ public:
/*!
* @function PlugWindow
*/
PlugWindow( FileWindowPtr ownerFile );
PlugWindow(FileWindowPtr ownerFile);
/*!
* @function File
*/
FileWindowPtr File( void );
FileWindowPtr File(void);
#if !TARGET_API_MAC_CARBON
/*!
* @function InstallClassicEventHandler
*/
void InstallClassicEventHandler( ClassicEventHandlerProcPtr newHandler );
void InstallClassicEventHandler(ClassicEventHandlerProcPtr newHandler);
/*!
* @function Close
*/
virtual OSStatus Close( void );
virtual OSStatus Close(void);
/*!
* @function Activate
*/
virtual OSStatus Activate( Boolean active = true );
virtual OSStatus Activate(Boolean active = true);
/*!
* @function Update
*/
virtual OSStatus Update( RgnHandle region = null );
virtual OSStatus Update(RgnHandle region = null);
/*!
* @function Click
*/
virtual OSStatus Click( Point mouse, EventModifiers modifiers );
virtual OSStatus Click(Point mouse, EventModifiers modifiers);
#endif
void SetRefCon( UInt32 value );
UInt32 GetRefCon( void );
void SetRefCon(UInt32 value);
UInt32 GetRefCon(void);
};
#endif

View File

@ -3,57 +3,57 @@
#include "string.h"
/*** CREATOR ***/
ResourceObject::ResourceObject( FileWindowPtr owner )
ResourceObject::ResourceObject(FileWindowPtr owner)
{
// set contents to zero
memset( this, 0, sizeof(ResourceObject) );
memset(this, 0, sizeof(ResourceObject));
file = owner;
nameIconRgn = NewRgn();
}
/*** DESTRUCTOR ***/
ResourceObject::~ResourceObject( void )
ResourceObject::~ResourceObject(void)
{
if( nameIconRgn ) DisposeRgn( nameIconRgn );
if( data ) DisposeHandle( data );
if(nameIconRgn) DisposeRgn(nameIconRgn);
if(data) DisposeHandle(data);
}
/*** RETAIN ***/
OSStatus ResourceObject::Retain( void )
OSStatus ResourceObject::Retain(void)
{
OSStatus error = noErr;
/* if( retainCount == 0 )
/* if(retainCount == 0)
{
if( dataFork )
if(dataFork)
{
// open file for reading
SInt16 refNum;
error = FSpOpenDF( file->GetFileSpec(), fsRdPerm, &refNum );
if( error )
error = FSpOpenDF(file->GetFileSpec(), fsRdPerm, &refNum);
if(error)
{
DisplayError( "\pData fork could not be read", "\pThis file appears to be corrupted. Although the resources could be read in correctly, the data fork could not be found. Please run Disk First Aid to correct the problem." );
DisplayError("\pData fork could not be read", "\pThis file appears to be corrupted. Although the resources could be read in correctly, the data fork could not be found. Please run Disk First Aid to correct the problem.");
return error;
}
// get new handle
data = NewHandleClear( size );
if( !data || MemError() )
data = NewHandleClear(size);
if(!data || MemError())
{
DisplayError( "\pNot enough memory to read data fork", "\pPlease quit other applications and try again." );
FSClose( refNum );
DisplayError("\pNot enough memory to read data fork", "\pPlease quit other applications and try again.");
FSClose(refNum);
return memFullErr;
}
// read data fork
HLock( data );
error = FSRead( refNum, (long *) &size, *data );
HUnlock( data );
FSClose( refNum );
HLock(data);
error = FSRead(refNum, (long *) &size, *data);
HUnlock(data);
FSClose(refNum);
}
else
{
LoadResource( data );
LoadResource(data);
}
}
*/ retainCount++;
@ -61,40 +61,40 @@ OSStatus ResourceObject::Retain( void )
}
/*** RELEASE ***/
void ResourceObject::Release( void )
void ResourceObject::Release(void)
{
if( retainCount > 0 )
if(retainCount > 0)
{
/* if( retainCount == 1 )
DisposeHandle( data );
/* if(retainCount == 1)
DisposeHandle(data);
*/ retainCount--;
}
}
/*** SET RESOURCE DIRTY ***/
void ResourceObject::SetDirty( Boolean value )
void ResourceObject::SetDirty(Boolean value)
{
dirty = value;
file->SetFileDirty( value );
file->SetFileDirty(value);
// being here indicates the resource size parameter also needs updating
size = GetHandleSize( data );
size = GetHandleSize(data);
// bug: should now tell all open copies of this resource to update themselves
}
/*** RES INFO RECORD ACCESSORS ***/
FileWindowPtr ResourceObject::File( void ) { return file; }
ResourceObjectPtr ResourceObject::Next( void ) { return next; }
Boolean ResourceObject::Dirty( void ) { return dirty; }
void ResourceObject::Select( Boolean select ) { selected = select; }
Boolean ResourceObject::Selected( void ) { return selected; }
DataBrowserItemID ResourceObject::Number( void ) { return number; }
Boolean ResourceObject::RepresentsDataFork( void ) { return dataFork; }
FileWindowPtr ResourceObject::File(void) { return file; }
ResourceObjectPtr ResourceObject::Next(void) { return next; }
Boolean ResourceObject::Dirty(void) { return dirty; }
void ResourceObject::Select(Boolean select) { selected = select; }
Boolean ResourceObject::Selected(void) { return selected; }
DataBrowserItemID ResourceObject::Number(void) { return number; }
Boolean ResourceObject::RepresentsDataFork(void) { return dataFork; }
Handle ResourceObject::Data( void ) { return data; }
UInt8* ResourceObject::Name( void ) { return name; }
UInt32 ResourceObject::Size( void ) { return size; }
ResType ResourceObject::Type( void ) { return type; }
SInt16 ResourceObject::ID( void ) { return resID; }
SInt16 ResourceObject::Attributes( void ) { return attribs; }
Handle ResourceObject::Data(void) { return data; }
UInt8* ResourceObject::Name(void) { return name; }
UInt32 ResourceObject::Size(void) { return size; }
ResType ResourceObject::Type(void) { return type; }
SInt16 ResourceObject::ID(void) { return resID; }
SInt16 ResourceObject::Attributes(void) { return attribs; }

View File

@ -57,103 +57,103 @@ public:
@function ResourceObject
@discussion Creator function.
*/
ResourceObject( FileWindowPtr owner = null );
ResourceObject(FileWindowPtr owner = null);
/*!
@function ~ResourceObject
@discussion Destructor function.
*/
~ResourceObject( void );
~ResourceObject(void);
/*!
@function Retain
@discussion Accessor function.
*/
OSStatus Retain( void );
OSStatus Retain(void);
/*!
@function Release
@discussion Accessor function.
*/
void Release( void );
void Release(void);
/*!
@function File
@discussion Accessor function.
*/
FileWindowPtr File( void );
FileWindowPtr File(void);
/*!
@function Next
@discussion Accessor function.
*/
ResourceObjectPtr Next( void );
ResourceObjectPtr Next(void);
/*!
@function SetDirty
@discussion Accessor function.
*/
void SetDirty( Boolean value );
void SetDirty(Boolean value);
/*!
@function Dirty
@discussion Accessor function.
*/
Boolean Dirty( void );
Boolean Dirty(void);
/*!
@function Select
@discussion Accessor function.
@param select Pass true to select, false to deselect this resource in the file window.
*/
void Select( Boolean select );
void Select(Boolean select);
/*!
@function Selected
@discussion Accessor function.
*/
Boolean Selected( void );
Boolean Selected(void);
/*!
@function Number
@discussion Accessor function.
*/
DataBrowserItemID Number( void );
DataBrowserItemID Number(void);
/*!
@function RepresentsDataFork
@discussion Accessor function.
*/
Boolean RepresentsDataFork( void );
Boolean RepresentsDataFork(void);
/*!
@function Data
@discussion Accessor function. Warning: This functions returns the ACTUAL data handle - do not dispose of it.
*/
Handle Data( void );
Handle Data(void);
/*!
@function Name
@discussion Accessor function.
*/
UInt8* Name( void );
UInt8* Name(void);
/*!
@function Size
@discussion Accessor function.
*/
UInt32 Size( void );
UInt32 Size(void);
/*!
@function Type
@discussion Accessor function.
*/
ResType Type( void );
ResType Type(void);
/*!
@function ID
@discussion Accessor function.
*/
SInt16 ID( void );
SInt16 ID(void);
/*!
@function Attributes
@discussion Accessor function.
*/
SInt16 Attributes( void );
SInt16 Attributes(void);
friend OSStatus FileWindow::ReadResourceMap( void );
friend OSStatus FileWindow::ReadDataFork( OSStatus RFError );
friend OSStatus FileWindow::InitDataBrowser( void );
friend OSStatus FileWindow::ReadResourceMap(void);
friend OSStatus FileWindow::ReadDataFork(OSStatus RFError);
friend OSStatus FileWindow::InitDataBrowser(void);
#if !TARGET_API_MAC_CARBON
friend OSStatus FileWindow::Click( Point mouse, EventModifiers modifiers );
friend OSStatus FileWindow::DrawResourceIcon( ResourceObjectPtr resource, UInt16 line );
friend OSStatus FileWindow::Click(Point mouse, EventModifiers modifiers);
friend OSStatus FileWindow::DrawResourceIcon(ResourceObjectPtr resource, UInt16 line);
#endif
friend OSStatus FileWindow::CreateNewResource( ConstStr255Param name, ResType type, SInt16 resID, SInt16 attribs );
friend OSStatus FileWindow::DisposeResourceMap( void );
friend OSStatus FileWindow::CreateNewResource(ConstStr255Param name, ResType type, SInt16 resID, SInt16 attribs);
friend OSStatus FileWindow::DisposeResourceMap(void);
};
#endif

View File

@ -1,18 +1,45 @@
#include "Utility.h"
extern globals g;
/**********************/
/* QUICKDRAW ROUTINES */
/**********************/
/*** SET COLOUR ***/
void SetColour( RGBColor *colour, UInt16 red, UInt16 green, UInt16 blue )
void SetColour(RGBColor *colour, UInt16 red, UInt16 green, UInt16 blue)
{
colour->red = red;
colour->green = green;
colour->blue = blue;
}
/*** MAKE LOCAL ***/
void MakeLocal( WindowRef window, Point globalPoint, Point *localPoint )
{
GrafPtr oldPort;
GetPort( &oldPort );
SetPortWindowPort( window );
localPoint->h = globalPoint.h;
localPoint->v = globalPoint.v;
GlobalToLocal( localPoint );
SetPort( oldPort );
}
/*** MAKE GLOBAL ***/
void MakeGlobal( WindowRef window, Point localPoint, Point *globalPoint )
{
GrafPtr oldPort;
GetPort( &oldPort );
SetPortWindowPort( window );
globalPoint->h = localPoint.h;
globalPoint->v = localPoint.v;
LocalToGlobal( globalPoint );
SetPort( oldPort );
}
/* investigate the call ShieldCursor() - it hides the mouse when it enters a certain rect */
/*******************/
@ -20,91 +47,91 @@ void SetColour( RGBColor *colour, UInt16 red, UInt16 green, UInt16 blue )
/*******************/
/*** C STRING LENGTH ***/
unsigned long CStringLength( char *string )
unsigned long CStringLength(char *string)
{
unsigned long length;
Boolean end = false;
for( length = 0; end == false; length++ )
if( *(string + length) == 0x00 ) end = true;
for(length = 0; end == false; length++)
if(*(string + length) == 0x00) end = true;
return length;
}
/*** PASCAL STRING LENGTH ***/
unsigned char PStringLength( unsigned char *string )
unsigned char PStringLength(unsigned char *string)
{
return *string;
}
/*** TYPE TO C STRING ***/
void TypeToCString( const OSType type, char *string )
void TypeToCString(const OSType type, char *string)
{
BlockMoveData( &type, &string[0], sizeof(OSType) );
BlockMoveData(&type, &string[0], sizeof(OSType));
string[sizeof(OSType)] = 0x00;
}
/*** TYPE TO PASCAL STRING ***/
void TypeToPString( const OSType type, Str255 string )
void TypeToPString(const OSType type, Str255 string)
{
string[0] = sizeof(OSType);
BlockMoveData( &type, &string[1], sizeof(OSType) );
BlockMoveData(&type, &string[1], sizeof(OSType));
}
/*** TYPE TO CORE FOUNDATION STRING ***/
void TypeToCFString( const OSType type, CFStringRef *string )
void TypeToCFString(const OSType type, CFStringRef *string)
{
char cString[5];
TypeToCString( type, (char *) &cString );
*string = CFStringCreateWithCString( CFAllocatorGetDefault(), (char *) &cString, kCFStringEncodingMacRoman );
TypeToCString(type, (char *) &cString);
*string = CFStringCreateWithCString(CFAllocatorGetDefault(), (char *) &cString, kCFStringEncodingMacRoman);
}
/*** COPY C STRING ***/
void CopyCString( const UInt8 *source, UInt8 *dest )
void CopyCString(const UInt8 *source, UInt8 *dest)
{
//#pragma warning off
while( *dest++ = *source++ );
while(*dest++ = *source++);
//#pragma warning reset
}
/*** COPY PASCAL STRING ***/
void CopyPString( const UInt8 *source, UInt8 *dest )
void CopyPString(const UInt8 *source, UInt8 *dest)
{
UInt8 length = *source, count;
for( count = 0; count <= length; count++ )
for(count = 0; count <= length; count++)
*dest++ = *source++;
}
/*** EQUAL C STRINGS ***/
Boolean EqualCStrings( UInt8 *source, UInt8 *dest )
Boolean EqualCStrings(UInt8 *source, UInt8 *dest)
{
while( *source != 0x00 )
if( *source++ != *dest++ ) return false;
while(*source != 0x00)
if(*source++ != *dest++) return false;
return true;
}
/*** EQUAL PASCAL STRINGS ***/
Boolean EqualPStrings( UInt8 *source, UInt8 *dest )
Boolean EqualPStrings(UInt8 *source, UInt8 *dest)
{
UInt8 length = *source, count;
for( count = 0; count <= length; count++ )
if( *source++ != *dest++ ) return false;
for(count = 0; count <= length; count++)
if(*source++ != *dest++) return false;
return true;
}
/*** APPEND ONE PASCAL STRING ONTO ANOTHER ***/
void AppendPString( Str255 original, ConstStr255Param added )
void AppendPString(Str255 original, ConstStr255Param added)
{
short numberBytes = added[0]; // length of string to be added
short totalLength = added[0] + original[0];
if( totalLength > 255 ) // too long, adjust number of bytes to add
if(totalLength > 255) // too long, adjust number of bytes to add
{
totalLength = 255;
numberBytes = totalLength - original[0];
}
BlockMoveData( &added[1], &original[totalLength-numberBytes + 1], numberBytes );
BlockMoveData(&added[1], &original[totalLength-numberBytes + 1], numberBytes);
original[0] = totalLength; // new length of original string
while( ++totalLength <= 255 )
while(++totalLength <= 255)
original[totalLength] = 0x00; // set rest of string to zero
}
@ -113,29 +140,29 @@ void AppendPString( Str255 original, ConstStr255Param added )
/*****************/
/*** MENU ITEM ENABLE ***/
void MenuItemEnable( MenuRef menu, MenuItemIndex item, Boolean enable )
void MenuItemEnable(MenuRef menu, MenuItemIndex item, Boolean enable)
{
#if !TARGET_API_MAC_CARBON
if( g.systemVersion >= kMacOS85 )
if(g.systemVersion >= kMacOS85)
{
#endif
if( enable ) EnableMenuItem( menu, item );
else DisableMenuItem( menu, item );
if(enable) EnableMenuItem(menu, item);
else DisableMenuItem(menu, item);
#if !TARGET_API_MAC_CARBON
}
else
{
if( enable ) EnableItem( menu, item );
else DisableItem( menu, item );
if(enable) EnableItem(menu, item);
else DisableItem(menu, item);
}
#endif
}
/*** ENABLE MENU COMMAND ***/
void EnableCommand( MenuRef menu, MenuCommand command, Boolean enable )
void EnableCommand(MenuRef menu, MenuCommand command, Boolean enable)
{
if( enable ) EnableMenuCommand( menu, command );
else DisableMenuCommand( menu, command );
if(enable) EnableMenuCommand(menu, command);
else DisableMenuCommand(menu, command);
}
/******************/
@ -151,53 +178,53 @@ OSErr MakeRelativeAliasFile(FSSpec *targetFile, FSSpec *aliasDest)
{
OSErr error;
FInfo fndrInfo;
AliasHandle theAlias = null;
AliasHandle theAlias = NULL;
Boolean fileCreated = false;
SInt16 rsrc = -1;
// set up our the alias' file information
error = FSpGetFInfo( targetFile, &fndrInfo );
if( error != noErr ) goto bail;
if( fndrInfo.fdType == 'APPL')
error = FSpGetFInfo(targetFile, &fndrInfo);
if(error != noErr) goto bail;
if(fndrInfo.fdType == 'APPL')
fndrInfo.fdType = kApplicationAliasType;
fndrInfo.fdFlags = kIsAlias; // implicitly clear the inited bit
// create the new file
FSpCreateResFile( aliasDest, 'TEMP', 'TEMP', smSystemScript );
if( (error = ResError() ) != noErr) goto bail;
FSpCreateResFile(aliasDest, 'TEMP', 'TEMP', smSystemScript);
if((error = ResError()) != noErr) goto bail;
fileCreated = true;
// set the file information or the new file
error = FSpSetFInfo( aliasDest, &fndrInfo );
if( error != noErr ) goto bail;
error = FSpSetFInfo(aliasDest, &fndrInfo);
if(error != noErr) goto bail;
// create the alias record, relative to the new alias file
error = NewAlias( aliasDest, targetFile, &theAlias );
if( error != noErr ) goto bail;
error = NewAlias(aliasDest, targetFile, &theAlias);
if(error != noErr) goto bail;
// save the resource
rsrc = FSpOpenResFile( aliasDest, fsRdWrPerm );
if( rsrc == -1)
rsrc = FSpOpenResFile(aliasDest, fsRdWrPerm);
if(rsrc == -1)
{
error = ResError();
goto bail;
}
UseResFile( rsrc );
AddResource( (Handle) theAlias, rAliasType, 0, aliasDest->name );
UseResFile(rsrc);
AddResource((Handle) theAlias, rAliasType, 0, aliasDest->name);
error = ResError();
if( error != noErr) goto bail;
theAlias = null;
CloseResFile( rsrc );
if(error != noErr) goto bail;
theAlias = NULL;
CloseResFile(rsrc);
rsrc = -1;
error = ResError();
if( error != noErr) goto bail;
if(error != noErr) goto bail;
// done
return noErr;
bail:
if( rsrc != -1 ) CloseResFile( rsrc );
if( fileCreated ) FSpDelete( aliasDest );
if( theAlias != null ) DisposeHandle( (Handle) theAlias );
if(rsrc != -1) CloseResFile(rsrc);
if(fileCreated) FSpDelete(aliasDest);
if(theAlias != NULL) DisposeHandle((Handle) theAlias);
return error;
}
@ -206,15 +233,15 @@ bail:
/**********************/
/*** LAUNCH WEB BROWSER ***/
OSStatus LaunchURL( char *url )
OSStatus LaunchURL(char *url)
{
OSStatus error = noErr;
ICInstance instance;
error = ICStart( &instance, kResKnifeCreator );
if( error != noErr ) return error;
error = ICStart(&instance, 'rsrc');
if(error != noErr) return error;
SInt32 start = 0, length = CStringLength( url );
error = ICLaunchURL( instance, null, url, length, &start, &length );
ICStop( instance );
SInt32 start = 0, length = CStringLength(url);
error = ICLaunchURL(instance, NULL, url, length, &start, &length);
ICStop(instance);
return error;
}

View File

@ -1,4 +1,10 @@
#include "ResKnife.h"
#if !TARGET_API_MAC_OS8
#if defined(__APPLE_CC__) // compiling with gcc
#include <Carbon/Carbon.h>
#else // compiling with CodeWarrior, __MWERKS__
#include <Carbon.h>
#endif
#endif
#ifndef _ResKnife_Utility_
#define _ResKnife_Utility_
@ -11,55 +17,63 @@
/*!
@function SetColour
*/
void SetColour( RGBColor *colour, UInt16 red, UInt16 green, UInt16 blue );
void SetColour(RGBColor *colour, UInt16 red, UInt16 green, UInt16 blue);
/*!
@function MakeLocal
*/
void MakeLocal( WindowRef window, Point globalPoint, Point *localPoint );
/*!
@function MakeGlobal
*/
void MakeGlobal( WindowRef window, Point localPoint, Point *globalPoint );
/*!
@function CStringLength
*/
unsigned long CStringLength( char *string );
unsigned long CStringLength(char *string);
/*!
@function PStringLength
*/
unsigned char PStringLength( unsigned char *string );
unsigned char PStringLength(unsigned char *string);
/*!
@function TypeToCString
*/
void TypeToCString( const OSType type, char *string );
void TypeToCString(const OSType type, char *string);
/*!
@function TypeToPString
*/
void TypeToPString( const OSType type, Str255 string );
void TypeToPString(const OSType type, Str255 string);
/*!
@function TypeToCFString
*/
void TypeToCFString( const OSType type, CFStringRef *string );
void TypeToCFString(const OSType type, CFStringRef *string);
/*!
@function CopyCString
*/
void CopyCString( const UInt8 *source, UInt8 *dest );
void CopyCString(const UInt8 *source, UInt8 *dest);
/*!
@function CopyPString
*/
void CopyPString( const UInt8 *source, UInt8 *dest );
void CopyPString(const UInt8 *source, UInt8 *dest);
/*!
@function EqualCStrings
*/
Boolean EqualCStrings( UInt8 *source, UInt8 *dest );
Boolean EqualCStrings(UInt8 *source, UInt8 *dest);
/*!
@function EqualPStrings
*/
Boolean EqualPStrings( UInt8 *source, UInt8 *dest );
Boolean EqualPStrings(UInt8 *source, UInt8 *dest);
/*!
@function AppendPString
*/
void AppendPString( Str255 original, ConstStr255Param added );
void AppendPString(Str255 original, ConstStr255Param added);
/*!
@function MenuItemEnable
*/
void MenuItemEnable( MenuRef menu, MenuItemIndex item, Boolean enable );
void MenuItemEnable(MenuRef menu, MenuItemIndex item, Boolean enable);
/*!
@function EnableCommand
*/
void EnableCommand( MenuRef menu, MenuCommand command, Boolean enable );
void EnableCommand(MenuRef menu, MenuCommand command, Boolean enable);
/*!
@function MakeRelativeAliasFile
*/
@ -68,6 +82,6 @@ OSErr MakeRelativeAliasFile(FSSpec *targetFile, FSSpec *aliasDest);
@function LaunchURL
@param url A C string containing the address to which you want the user to go. You must include 'http://' if necessary, and all addresses to a directory should have a trailing slash.
*/
OSStatus LaunchURL( char *url );
OSStatus LaunchURL(char *url);
#endif

View File

@ -3,74 +3,74 @@
/*** CONSTRUCTOR ***/
WindowObject::WindowObject( void )
WindowObject::WindowObject(void)
{
memset( this, 0, sizeof(WindowObject) );
memset(this, 0, sizeof(WindowObject));
}
/*** DESTRUCTOR ***/
WindowObject::~WindowObject( void )
WindowObject::~WindowObject(void)
{
if( window )
if(window)
{
HideWindow( window );
DisposeWindow( window );
HideWindow(window);
DisposeWindow(window);
}
}
/*** WINDOW ACCESSOR ***/
WindowRef WindowObject::Window( void )
WindowRef WindowObject::Window(void)
{
return window;
}
/*** WINDOW BOUNDS ARE CHANGING ***/
OSStatus WindowObject::BoundsChanging( EventRef event )
OSStatus WindowObject::BoundsChanging(EventRef event)
{
#pragma unused( event )
#pragma unused(event)
return eventNotHandledErr;
}
/*** WINDOW BOUNDS HAVE CHANGED ***/
OSStatus WindowObject::BoundsChanged( EventRef event )
OSStatus WindowObject::BoundsChanged(EventRef event)
{
#pragma unused( event )
#pragma unused(event)
return eventNotHandledErr;
}
#if !TARGET_API_MAC_CARBON
/*** CLOSE ***/
OSStatus WindowObject::Close( void )
OSStatus WindowObject::Close(void)
{
delete this;
return noErr;
}
/*** ACTIVATE ***/
OSStatus WindowObject::Activate( Boolean active )
OSStatus WindowObject::Activate(Boolean active)
{
#pragma unused( active )
#pragma unused(active)
return eventNotHandledErr;
}
/*** UPDATE ***/
OSStatus WindowObject::Update( RgnHandle region )
OSStatus WindowObject::Update(RgnHandle region)
{
#pragma unused( region )
#pragma unused(region)
return eventNotHandledErr;
}
/*** UPDATE SCROLL BARS ***/
OSStatus WindowObject::UpdateScrollBars( void )
OSStatus WindowObject::UpdateScrollBars(void)
{
return eventNotHandledErr;
}
/*** MOUSE CLICK ***/
OSStatus WindowObject::Click( Point mouse, EventModifiers modifiers )
OSStatus WindowObject::Click(Point mouse, EventModifiers modifiers)
{
#pragma unused( mouse, modifiers )
#pragma unused(mouse, modifiers)
return eventNotHandledErr;
}

View File

@ -40,46 +40,46 @@ public:
* @function WindowObject
* @discussion Constructor function.
*/
WindowObject( void );
WindowObject(void);
/*!
* @function WindowObject
* @discussion Desturctor function.
*/
virtual ~WindowObject( void );
virtual ~WindowObject(void);
/*!
* @function Window
* @discussion Accessor for the object&rsquo;s <tt>WindowRef</tt>.
*/
virtual WindowRef Window( void );
virtual WindowRef Window(void);
/*!
* @function BoundsChanging
*/
virtual OSStatus BoundsChanging( EventRef event );
virtual OSStatus BoundsChanging(EventRef event);
/*!
* @function BoundsChanged
*/
virtual OSStatus BoundsChanged( EventRef event );
virtual OSStatus BoundsChanged(EventRef event);
#if !TARGET_API_MAC_CARBON
/*!
* @function Close
*/
virtual OSStatus Close( void );
virtual OSStatus Close(void);
/*!
* @function Activate
*/
virtual OSStatus Activate( Boolean active = true );
virtual OSStatus Activate(Boolean active = true);
/*!
* @function Update
*/
virtual OSStatus Update( RgnHandle region = null );
virtual OSStatus Update(RgnHandle region = null);
/*!
* @function UpdateScrollBars
*/
virtual OSStatus UpdateScrollBars( void );
virtual OSStatus UpdateScrollBars(void);
/*!
* @function Click
*/
virtual OSStatus Click( Point mouse, EventModifiers modifiers );
virtual OSStatus Click(Point mouse, EventModifiers modifiers);
#endif
};

View File

@ -1,27 +1,38 @@
// abbreviations
#define null NULL
#define null NULL
#if TARGET_API_MAC_CARBON
#define qdb ScreenBounds()
#define qdb ScreenBounds()
inline Rect ScreenBounds()
{
Rect rect;
GetAvailableWindowPositioningBounds( GetMainDevice(), &rect );
GetAvailableWindowPositioningBounds(GetMainDevice(), &rect);
return rect;
}
#else
#define qdb qd.screenBits.bounds
#define qdb qd.screenBits.bounds
#endif
// Easier constants
#define RGBColour RGBColor
// Easier API call names
#define GetWindowRefCon( window ) (long) GetWRefCon( window )
#define SetWindowRefCon( window, refcon ) SetWRefCon( window, refcon )
#define GetWindowTitle( window, string ) GetWTitle( window, string )
#define SetWindowTitle( window, name ) SetWTitle( window, name )
#define InvalidateRect( bounds ) InvalRect( bounds )
#define InvalidateWindowRect( window, bounds ) (OSStatus) InvalWindowRect( window, bounds )
#define RectToRegion( region, rect ) RectRgn( region, rect )
#define NewPoint() (Point) { 0, 0 }
#define SetPoint( point, x, y ) SetPt( point, x, y )
#define HighlightColour( colour ) HiliteColor( colour )
#define GetPortHighlightColour( window, colour ) GetPortHiliteColor( window, colour )
#define GetWindowRefCon(window) (long) GetWRefCon(window)
#define SetWindowRefCon(window, refcon) SetWRefCon(window, refcon)
#define GetWindowTitle(window, string) GetWTitle(window, string)
#define SetWindowTitle(window, name) SetWTitle(window, name)
#define InvalidateRect(bounds) InvalRect(bounds)
#define InvalidateWindowRect(window, bounds) (OSStatus) InvalWindowRect(window, bounds)
#define RectToRegion(region, rect) RectRgn(region, rect)
#define NewPoint() (Point) { 0, 0 }
#define SetPoint(point, x, y) SetPt(point, x, y)
/* apperance.h */
#define SetThemeTextColour(c, d, cd) (OSStatus) SetThemeTextColor(c, d, cd)
#define IsThemeInColour(d, cd) (Boolean) IsThemeInColor(d, cd)
#define GetThemeAccentColours(out) (OSStatus) GetThemeAccentColors(out)
#define SetThemeTextColourForWindow(w, a, d, cd) (OSStatus) SetThemeTextColorForWindow(w, a, d, cd)
#define GetThemeBrushAsColour(b, d, cd, out) (OSStatus) GetThemeBrushAsColor(b, d, cd, out)
#define GetThemeTextColour(c, d, cd, out) (OSStatus) GetThemeTextColor(c, d, cd, out)
/* quickdraw.h */
#define HighlightColour(colour) HiliteColor(colour)
#define GetPortHighlightColour(window, colour) GetPortHiliteColor(window, colour)

64
Carbon/Info.plist Normal file
View File

@ -0,0 +1,64 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>rsrc</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>Resource file.icns</string>
<key>CFBundleTypeName</key>
<string>Resource file</string>
<key>CFBundleTypeOSTypes</key>
<array>
<string>rsrc</string>
<string>RSRC</string>
</array>
<key>CFBundleTypeRole</key>
<string>Editor</string>
</dict>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>icns</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>Icon file.icns</string>
<key>CFBundleTypeName</key>
<string>Icon file</string>
<key>CFBundleTypeOSTypes</key>
<array>
<string>icns</string>
</array>
<key>CFBundleTypeRole</key>
<string>Editor</string>
</dict>
</array>
<key>CFBundleExecutable</key>
<string>ResKnife Carbon</string>
<key>CFBundleGetInfoString</key>
<string>A resource editor for Mac OS X</string>
<key>CFBundleIconFile</key>
<string>ResKnife.icns</string>
<key>CFBundleIdentifier</key>
<string>com.nickshanks.resknife</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>ResKnife</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>Development version 0.4d3</string>
<key>CFBundleSignature</key>
<string>ResK</string>
<key>CFBundleVersion</key>
<string>0.4d3</string>
</dict>
</plist>

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

Binary file not shown.

View File

@ -1,295 +1,4 @@
{
IBClasses = (
{CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
{CLASS = IBCarbonBevelButton; LANGUAGE = ObjC; SUPERCLASS = IBCarbonControl; },
{CLASS = IBCarbonButton; LANGUAGE = ObjC; SUPERCLASS = IBCarbonControl; },
{
CLASS = IBCarbonChasingArrows;
LANGUAGE = ObjC;
OUTLETS = {
carbonBounds = id;
command = id;
controlHandle = id;
controlID = id;
controlMaximum = id;
controlMinimum = id;
controlName = id;
controlSignature = id;
controlSize = id;
controlTitle = id;
controlValue = id;
enabled = id;
hidden = id;
isEnabled = id;
isHidden = id;
objectNameForInspectorTitle = id;
targetFrameworkName = id;
targetFrameworkSupportsConnections = id;
titleRect = id;
};
SUPERCLASS = IBCarbonControl;
},
{CLASS = IBCarbonCheckBox; LANGUAGE = ObjC; SUPERCLASS = IBCarbonControl; },
{
CLASS = IBCarbonClockDate;
LANGUAGE = ObjC;
OUTLETS = {
carbonBounds = id;
clockType = id;
command = id;
controlHandle = id;
controlID = id;
controlMaximum = id;
controlMinimum = id;
controlName = id;
controlSignature = id;
controlSize = id;
controlTitle = id;
controlValue = id;
enabled = id;
hidden = id;
isEditable = id;
isEnabled = id;
isHidden = id;
isLive = id;
objectNameForInspectorTitle = id;
targetFrameworkName = id;
targetFrameworkSupportsConnections = id;
titleRect = id;
};
SUPERCLASS = IBCarbonControl;
},
{
CLASS = IBCarbonControl;
LANGUAGE = ObjC;
OUTLETS = {
carbonBounds = id;
command = id;
controlHandle = id;
controlID = id;
controlMaximum = id;
controlMinimum = id;
controlName = id;
controlSignature = id;
controlSize = id;
controlTitle = id;
controlValue = id;
enabled = id;
hidden = id;
isEnabled = id;
isHidden = id;
objectNameForInspectorTitle = id;
targetFrameworkName = id;
targetFrameworkSupportsConnections = id;
titleRect = id;
};
SUPERCLASS = NSObject;
},
{
CLASS = IBCarbonDBListView;
LANGUAGE = ObjC;
SUPERCLASS = IBCarbonDataBrowser;
},
{CLASS = IBCarbonDataBrowser; LANGUAGE = ObjC; SUPERCLASS = IBCarbonControl; },
{CLASS = IBCarbonEditText; LANGUAGE = ObjC; SUPERCLASS = IBCarbonControl; },
{
CLASS = IBCarbonGroupBox;
LANGUAGE = ObjC;
OUTLETS = {
autoToggle = id;
carbonBounds = id;
command = id;
contentRect = id;
controlHandle = id;
controlID = id;
controlMaximum = id;
controlMinimum = id;
controlName = id;
controlSignature = id;
controlSize = id;
controlTitle = id;
controlValue = id;
enabled = id;
groupBoxTitleType = id;
groupBoxType = id;
hasVariableWidth = id;
hidden = id;
isAutoToggle = id;
isEnabled = id;
isHidden = id;
isPrimary = id;
objectNameForInspectorTitle = id;
primary = id;
selectedItem = id;
supportsInsideOutSelection = id;
targetFrameworkName = id;
targetFrameworkSupportsConnections = id;
titleJustification = id;
titleRect = id;
variableWidth = id;
};
SUPERCLASS = IBCarbonControl;
},
{
CLASS = IBCarbonIcon;
LANGUAGE = ObjC;
OUTLETS = {
carbonBounds = id;
command = id;
contentResID = id;
contentType = id;
controlHandle = id;
controlID = id;
controlMaximum = id;
controlMinimum = id;
controlName = id;
controlSignature = id;
controlSize = id;
controlTitle = id;
controlValue = id;
dontTrack = id;
enabled = id;
hidden = id;
isEnabled = id;
isHidden = id;
objectNameForInspectorTitle = id;
targetFrameworkName = id;
targetFrameworkSupportsConnections = id;
titleRect = id;
};
SUPERCLASS = IBCarbonControl;
},
{CLASS = IBCarbonImageWell; LANGUAGE = ObjC; SUPERCLASS = IBCarbonControl; },
{
CLASS = IBCarbonLittleArrows;
LANGUAGE = ObjC;
OUTLETS = {
carbonBounds = id;
command = id;
controlHandle = id;
controlID = id;
controlMaximum = id;
controlMinimum = id;
controlName = id;
controlSignature = id;
controlSize = id;
controlTitle = id;
controlValue = id;
enabled = id;
hidden = id;
increment = id;
initialValue = id;
isEnabled = id;
isHidden = id;
maximumValue = id;
minimumValue = id;
objectNameForInspectorTitle = id;
targetFrameworkName = id;
targetFrameworkSupportsConnections = id;
titleRect = id;
};
SUPERCLASS = IBCarbonControl;
},
{CLASS = IBCarbonMenu; LANGUAGE = ObjC; SUPERCLASS = NSMenu; },
{CLASS = IBCarbonMenuItem; LANGUAGE = ObjC; SUPERCLASS = NSMenuItem; },
{CLASS = IBCarbonPopupButton; LANGUAGE = ObjC; SUPERCLASS = IBCarbonControl; },
{CLASS = IBCarbonRadioGroup; LANGUAGE = ObjC; SUPERCLASS = IBCarbonControl; },
{CLASS = IBCarbonRelevanceBar; LANGUAGE = ObjC; SUPERCLASS = IBCarbonControl; },
{CLASS = IBCarbonRootControl; LANGUAGE = ObjC; SUPERCLASS = IBCarbonControl; },
{CLASS = IBCarbonRoundButton; LANGUAGE = ObjC; SUPERCLASS = IBCarbonControl; },
{CLASS = IBCarbonScrollBar; LANGUAGE = ObjC; SUPERCLASS = IBCarbonControl; },
{
CLASS = IBCarbonSeparator;
LANGUAGE = ObjC;
OUTLETS = {
carbonBounds = id;
command = id;
controlHandle = id;
controlID = id;
controlMaximum = id;
controlMinimum = id;
controlName = id;
controlSignature = id;
controlSize = id;
controlTitle = id;
controlValue = id;
enabled = id;
hidden = id;
isEnabled = id;
isHidden = id;
objectNameForInspectorTitle = id;
targetFrameworkName = id;
targetFrameworkSupportsConnections = id;
titleRect = id;
};
SUPERCLASS = IBCarbonControl;
},
{
CLASS = IBCarbonSlider;
LANGUAGE = ObjC;
OUTLETS = {
carbonBounds = id;
command = id;
controlHandle = id;
controlID = id;
controlMaximum = id;
controlMinimum = id;
controlName = id;
controlSignature = id;
controlSize = id;
controlTitle = id;
controlValue = id;
enabled = id;
hidden = id;
initialValue = id;
isEnabled = id;
isHidden = id;
isLive = id;
maximumValue = id;
minimumValue = id;
numTickMarks = id;
objectNameForInspectorTitle = id;
orientation = id;
targetFrameworkName = id;
targetFrameworkSupportsConnections = id;
titleRect = id;
};
SUPERCLASS = IBCarbonControl;
},
{CLASS = IBCarbonStaticText; LANGUAGE = ObjC; SUPERCLASS = IBCarbonControl; },
{CLASS = IBCarbonTab; LANGUAGE = ObjC; SUPERCLASS = IBCarbonControl; },
{
CLASS = IBCarbonTriangle;
LANGUAGE = ObjC;
OUTLETS = {
autoToggle = id;
carbonBounds = id;
collapsed = id;
command = id;
controlHandle = id;
controlID = id;
controlMaximum = id;
controlMinimum = id;
controlName = id;
controlSignature = id;
controlSize = id;
controlTitle = id;
controlValue = id;
drawTitle = id;
enabled = id;
hidden = id;
isCollapsed = id;
isEnabled = id;
isHidden = id;
objectNameForInspectorTitle = id;
orientation = id;
targetFrameworkName = id;
targetFrameworkSupportsConnections = id;
titleRect = id;
};
SUPERCLASS = IBCarbonControl;
},
{CLASS = IBCarbonUserPane; LANGUAGE = ObjC; SUPERCLASS = IBCarbonControl; }
);
IBVersion = 1;
}
IBClasses = ();
IBVersion = 1;
}

View File

@ -1,11 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
<plist version="0.9">
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IBDocumentLocation</key>
<string>70 160 588 603 0 73 1152 775 </string>
<key>IBMainMenuLocation</key>
<string>157 692 404 44 0 72 1024 674 </string>
<key>IBEditorPositions</key>
<dict>
<key>29</key>
<string>126 846 404 44 0 0 1600 1002 </string>
</dict>
<key>IBFramework Version</key>
<string>313.0</string>
<key>IBOpenObjects</key>
<array>
<integer>29</integer>
<integer>297</integer>
<integer>166</integer>
</array>
<key>IBSystem Version</key>
<string>6L60</string>
<key>IBUserGuides</key>
<dict>
<key>About Box</key>

View File

@ -4,7 +4,7 @@
<object name="rootObject" class="NSCustomObject" id="1">
<string name="customClass">NSApplication</string>
</object>
<array count="120" name="allObjects">
<array count="125" name="allObjects">
<object class="IBCarbonMenu" id="29">
<string name="title">ResKnife</string>
<array count="7" name="items">
@ -302,14 +302,14 @@
<reference idRef="157"/>
<reference idRef="159"/>
<object class="IBCarbonWindow" id="166">
<string name="windowRect">53 8 413 488 </string>
<string name="windowRect">454 84 814 564 </string>
<string name="title">New Resource File</string>
<object name="rootControl" class="IBCarbonRootControl" id="167">
<string name="bounds">0 0 360 480 </string>
<array count="3" name="subviews">
<object class="IBCarbonDBListView" id="188">
<string name="bounds">21 0 360 480 </string>
<ostype name="controlSignature">brow</ostype>
<ostype name="controlSignature">ResK</ostype>
<boolean name="showFocusRing">FALSE</boolean>
<array count="4" name="listViewColumns">
<object class="IBCarbonDBListViewColumn">
@ -346,20 +346,23 @@
</array>
</object>
<object class="IBCarbonStaticText" id="295">
<string name="bounds">2 5 18 240 </string>
<ostype name="controlSignature">left</ostype>
<string name="title">left hand side message</string>
<string name="bounds">4 5 15 233 </string>
<ostype name="controlSignature">ResK</ostype>
<int name="controlID">1</int>
<boolean name="small">TRUE</boolean>
<string name="title">Number of resources</string>
</object>
<object class="IBCarbonStaticText" id="296">
<string name="bounds">2 240 18 475 </string>
<ostype name="controlSignature">left</ostype>
<string name="title">right hand side message</string>
<string name="bounds">4 241 15 474 </string>
<ostype name="controlSignature">ResK</ostype>
<int name="controlID">2</int>
<boolean name="small">TRUE</boolean>
<string name="title">File size</string>
<int name="justification">-1</int>
</object>
</array>
</object>
<boolean name="liveResize">TRUE</boolean>
<int name="carbonWindowClass">6</int>
<int name="themeBrush">0</int>
</object>
<reference idRef="167"/>
<reference idRef="168"/>
@ -395,20 +398,8 @@
<object class="IBCarbonTab" id="216">
<string name="bounds">8 10 248 390 </string>
<array count="2" name="subviews">
<object class="IBCarbonUserPane" id="217">
<string name="bounds">53 0 261 380 </string>
<array count="1" name="subviews">
<object class="IBCarbonStaticText" id="275">
<string name="bounds">86 46 102 122 </string>
<string name="title">Pane 1</string>
</object>
</array>
<ostype name="controlSignature">pane</ostype>
<int name="controlID">1</int>
<int name="featureBits">2</int>
</object>
<object class="IBCarbonUserPane" id="218">
<string name="bounds">53 0 261 380 </string>
<string name="bounds">38 10 248 390 </string>
<array count="1" name="subviews">
<object class="IBCarbonStaticText" id="276">
<string name="bounds">100 209 116 285 </string>
@ -419,6 +410,18 @@
<int name="controlID">2</int>
<int name="featureBits">2</int>
</object>
<object class="IBCarbonUserPane" id="217">
<string name="bounds">38 10 248 390 </string>
<array count="1" name="subviews">
<object class="IBCarbonStaticText" id="275">
<string name="bounds">86 46 102 122 </string>
<string name="title">Pane 1</string>
</object>
</array>
<ostype name="controlSignature">pane</ostype>
<int name="controlID">1</int>
<int name="featureBits">2</int>
</object>
</array>
<ostype name="controlSignature">tabs</ostype>
<int name="controlID">1</int>
@ -460,7 +463,6 @@
<boolean name="isResizable">FALSE</boolean>
<boolean name="hasVerticalZoom">FALSE</boolean>
<int name="carbonWindowClass">11</int>
<int name="themeBrush">0</int>
</object>
<reference idRef="214"/>
<reference idRef="215"/>
@ -493,7 +495,7 @@
<int name="initialValue">50</int>
</object>
<object class="IBCarbonSlider" id="234">
<string name="bounds">33 213 53 299 </string>
<string name="bounds">33 213 57 299 </string>
<boolean name="isLive">TRUE</boolean>
<int name="numTickMarks">5</int>
<int name="orientation">1</int>
@ -502,7 +504,7 @@
<int name="maximumValue">5</int>
</object>
<object class="IBCarbonLittleArrows" id="235">
<string name="bounds">24 341 48 357 </string>
<string name="bounds">24 341 46 354 </string>
<int name="initialValue">3</int>
<int name="minimumValue">1</int>
<int name="maximumValue">5</int>
@ -513,10 +515,10 @@
<int name="orientation">1</int>
</object>
<object class="IBCarbonSeparator" id="237">
<string name="bounds">156 18 161 384 </string>
<string name="bounds">156 18 157 384 </string>
</object>
<object class="IBCarbonSeparator" id="238">
<string name="bounds">9 144 142 149 </string>
<string name="bounds">9 144 142 145 </string>
</object>
<object class="IBCarbonRadioGroup" id="239">
<string name="bounds">93 17 134 139 </string>
@ -558,6 +560,7 @@
<string name="title">BevelMenu</string>
<array count="3" name="items">
<object class="IBCarbonMenuItem" id="290">
<boolean name="checked">TRUE</boolean>
<string name="title">Item1</string>
</object>
<object class="IBCarbonMenuItem" id="291">
@ -568,6 +571,7 @@
</object>
</array>
</object>
<int name="selectedItem">1</int>
</object>
<object class="IBCarbonBevelButton" id="247">
<string name="bounds">177 181 214 240 </string>
@ -616,8 +620,6 @@
<boolean name="hasHorizontalZoom">FALSE</boolean>
<boolean name="isResizable">FALSE</boolean>
<boolean name="hasVerticalZoom">FALSE</boolean>
<int name="carbonWindowClass">6</int>
<int name="themeBrush">0</int>
</object>
<reference idRef="228"/>
<reference idRef="230"/>
@ -697,8 +699,6 @@
<boolean name="hasHorizontalZoom">FALSE</boolean>
<boolean name="isResizable">FALSE</boolean>
<boolean name="hasVerticalZoom">FALSE</boolean>
<int name="carbonWindowClass">6</int>
<int name="themeBrush">0</int>
</object>
<reference idRef="255"/>
<reference idRef="256"/>
@ -731,55 +731,68 @@
<reference idRef="295"/>
<reference idRef="296"/>
<object class="IBCarbonWindow" id="297">
<string name="windowRect">96 300 326 534 </string>
<string name="windowRect">120 772 296 972 </string>
<string name="title">Inspector</string>
<object name="rootControl" class="IBCarbonRootControl" id="298">
<string name="bounds">0 0 230 234 </string>
<string name="bounds">0 0 176 200 </string>
<array count="5" name="subviews">
<object class="IBCarbonGroupBox" id="299">
<string name="bounds">59 16 214 220 </string>
<array count="1" name="subviews">
<object class="IBCarbonRadioGroup" id="300">
<string name="bounds">80 22 204 214 </string>
<int name="numRows">6</int>
<array count="6" name="radioTitles">
<array count="1">
<string>Changed</string>
</array>
<array count="1">
<string>Radio2</string>
</array>
<array count="1">
<string>Radio</string>
</array>
<array count="1">
<string>Radio</string>
</array>
<array count="1">
<string>Radio</string>
</array>
<array count="1">
<string>SysHeap</string>
</array>
</array>
<string name="bounds">75 5 171 195 </string>
<array count="6" name="subviews">
<object class="IBCarbonCheckBox" id="305">
<string name="bounds">101 21 115 96 </string>
<boolean name="small">TRUE</boolean>
<string name="title">Changed</string>
</object>
<object class="IBCarbonCheckBox" id="306">
<string name="bounds">121 21 135 96 </string>
<boolean name="small">TRUE</boolean>
<string name="title">Preload</string>
</object>
<object class="IBCarbonCheckBox" id="307">
<string name="bounds">141 21 155 96 </string>
<boolean name="small">TRUE</boolean>
<string name="title">Protected</string>
</object>
<object class="IBCarbonCheckBox" id="308">
<string name="bounds">101 104 115 179 </string>
<boolean name="small">TRUE</boolean>
<string name="title">Locked</string>
</object>
<object class="IBCarbonCheckBox" id="309">
<string name="bounds">121 104 135 179 </string>
<boolean name="small">TRUE</boolean>
<string name="title">Purgable</string>
</object>
<object class="IBCarbonCheckBox" id="310">
<string name="bounds">141 104 155 179 </string>
<boolean name="small">TRUE</boolean>
<string name="title">Sysheap</string>
</object>
</array>
<string name="title">Box</string>
<boolean name="small">TRUE</boolean>
<string name="title">Attributes</string>
</object>
<object class="IBCarbonImageWell" id="301">
<string name="bounds">10 12 54 56 </string>
<string name="bounds">5 5 65 65 </string>
</object>
<object class="IBCarbonStaticText" id="302">
<string name="bounds">10 67 45 219 </string>
<string name="bounds">5 73 41 195 </string>
<boolean name="small">TRUE</boolean>
<string name="title">The title of the resource goes here</string>
</object>
<object class="IBCarbonStaticText" id="303">
<string name="bounds">49 67 65 106 </string>
<string name="bounds">49 73 65 195 </string>
<boolean name="small">TRUE</boolean>
<string name="title">Type</string>
<int name="justification">-2</int>
</object>
<object class="IBCarbonStaticText" id="304">
<string name="bounds">50 200 66 222 </string>
<string name="bounds">49 73 65 195 </string>
<ostype name="controlSignature">ResK</ostype>
<boolean name="small">TRUE</boolean>
<string name="title">ID</string>
<int name="justification">-1</int>
</object>
</array>
</object>
@ -787,17 +800,21 @@
<boolean name="isResizable">FALSE</boolean>
<boolean name="hasVerticalZoom">FALSE</boolean>
<int name="carbonWindowClass">5</int>
<int name="themeBrush">0</int>
</object>
<reference idRef="298"/>
<reference idRef="299"/>
<reference idRef="300"/>
<reference idRef="301"/>
<reference idRef="302"/>
<reference idRef="303"/>
<reference idRef="304"/>
<reference idRef="305"/>
<reference idRef="306"/>
<reference idRef="307"/>
<reference idRef="308"/>
<reference idRef="309"/>
<reference idRef="310"/>
</array>
<array count="120" name="allParents">
<array count="125" name="allParents">
<reference idRef="1"/>
<reference idRef="29"/>
<reference idRef="131"/>
@ -913,11 +930,16 @@
<reference idRef="1"/>
<reference idRef="297"/>
<reference idRef="298"/>
<reference idRef="298"/>
<reference idRef="298"/>
<reference idRef="298"/>
<reference idRef="298"/>
<reference idRef="299"/>
<reference idRef="299"/>
<reference idRef="299"/>
<reference idRef="299"/>
<reference idRef="299"/>
<reference idRef="299"/>
<reference idRef="298"/>
<reference idRef="298"/>
<reference idRef="298"/>
<reference idRef="298"/>
</array>
<dictionary count="49" name="nameTable">
<string>About Box</string>
@ -1019,5 +1041,5 @@
<string>Preferences</string>
<reference idRef="254"/>
</dictionary>
<unsigned_int name="nextObjectID">305</unsigned_int>
<unsigned_int name="nextObjectID">311</unsigned_int>
</object>

Binary file not shown.

View File

@ -0,0 +1,183 @@
#import <Foundation/Foundation.h>
/*******************************/
/***** WARNING *****/
/* This file is being broken */
/* apart into smaller files. */
/* If you want to change any */
/* methods here, split them */
/* into new files beforehand. */
/*******************************/
/*!
@header
@abstract Numerous small category methods on Foundation and AppKit classes.
@author Nicholas Shanks
*/
@interface NSArray (NGSIndexExtensions)
/*!
@method subarrayWithIndicies:
@updated January 2004
@abstract Returns an immutable array of the objects at the given indicies.
*/
- (NSArray *)subarrayWithIndicies:(NSIndexSet *)indicies;
@end
@interface NSArray (NGSKeyValueExtensions)
/*!
@method indexOfFirstObjectReturningValue:forKey:
@updated January 2003
@discussion Calls <tt>valueForKey:</tt> on each object in the array, returning the index of the first one encountered which itself returned the value passed in, according to <tt>isEqual:</tt>, or returns <tt>NSNotFound</tt> if no object matched for the given key/value pair. Mostly useful just for increasing code readability, as the methd is only one line long, but one that's not easy to understand at first glance.
@updated 2005-02-23 NGS: Removed unnecessary code, <tt>indexOfObject:</tt> already returns <tt>NSNotFound</tt> for me.
*/
- (int)indexOfFirstObjectReturningValue:(id)value forKey:(id)key;
/*!
@method firstObjectReturningValue:forKey:
@updated January 2003
@discussion Calls <tt>valueForKey:</tt> on each object in the array, returning the first one encountered which itself returned the value passed in, according to <tt>isEqual:</tt>. Returns <tt>nil</tt> if no matching object is found.
@updated 2005-02-23 NGS: Removed message to <tt>indexOfFirstObjectReturningValue:forKey:</tt>, incorperated that method's code into this one.
*/
- (id)firstObjectReturningValue:(id)value forKey:(id)key;
/*!
@method objectsReturningValue:forKey:
@updated January 2003
@abstract Returns an array containing all objects in the receiver which have <tt>value</tt> set for key <tt>key</tt>.
@discussion Calls <tt>valueForKey:</tt> on each object in the array, returning a new array containing all objects which themselves returned the value passed in, according to <tt>isEqual:</tt>. If no objects matched, this method returns an empty array.
*/
- (NSArray *)objectsReturningValue:(id)value forKey:(id)key;
- (NSArray *)arrayByMakingObjectsPerformSelector:(SEL)selector withObject:(id)inObject;
@end
@interface NSCharacterSet (NGSNewlineExtensions)
#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
/*!
@method newlineCharacterSet
@updated March 2005
@abstract Returns a character set containing only the newline and nextline characters (U+000AU+000D, U+0085).
@availability In 10.4 and above, this method is available from the OS.
*/
+ (NSCharacterSet *)newlineCharacterSet;
#endif
/*!
@method tabCharacterSet
@updated March 2005
@abstract Returns a character set containing only the horizontal and vertical tab characters (U+0009, U+000B).
*/
+ (NSCharacterSet *)tabCharacterSet;
@end
@interface NSIndexSet (NGSIndicies)
+ (id)indexSetWithIndiciesInRange:(NSRange)range;
- (id)initWithIndiciesInRange:(NSRange)range;
- (unsigned int)getIndicies:(unsigned int *)indexBuffer maxCount:(unsigned int)bufferSize inIndexRange:(NSRangePointer)range;
- (BOOL)containsIndiciesInRange:(NSRange)range;
- (BOOL)containsIndicies:(NSIndexSet *)indexSet;
- (BOOL)intersectsIndiciesInRange:(NSRange)range;
@end
@interface NSMutableIndexSet (NGSIndicies)
- (void)addIndicies:(NSIndexSet *)indexSet;
- (void)removeIndicies:(NSIndexSet *)indexSet;
- (void)removeAllIndicies;
- (void)addIndiciesInRange:(NSRange)range;
- (void)removeIndiciesInRange:(NSRange)range;
- (void)shiftIndiciesStartingAtIndex:(unsigned int)index by:(int)delta;
@end
@interface NSNumber (NGSRangeExtensions)
/*!
@method isWithinRange:
@updated February 2003
*/
- (BOOL)isWithinRange:(NSRange)range; // location <= self <= location+length
/*!
@method isExclusivelyWithinRange:
@updated February 2003
*/
- (BOOL)isExclusivelyWithinRange:(NSRange)range; // location < self < location+length
/*!
@method isBoundedByRange:
@updated February 2003
*/
- (BOOL)isBoundedByRange:(NSRange)range; // location <= self < location+length
@end
@interface NSString (NGSFSSpecExtensions)
/*!
@method createFSRef
@updated November 2002
@abstract Returns an <tt>FSRef</tt> for the absolute path represented by the receiver. The caller is responsible for disposing of the <tt>FSRef</tt>.
*/
- (FSRef *)createFSRef;
/*!
@method createFSSpec
@updated November 2002
@abstract Returns an <tt>FSSpec</tt> for the absolute path represented by the receiver. The caller is responsible for disposing of the <tt>FSSpec</tt>.
*/
- (FSSpec *)createFSSpec;
@end
@interface NSString (NGSBooleanExtensions)
#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
/*!
@method boolValue
@updated March 2001
@availability In 10.4 and above, this method is available from the OS.
*/
- (BOOL)boolValue;
#endif
/*!
@method stringWithBool:
@updated March 2001
*/
+ (NSString *)stringWithBool:(BOOL)boolean;
@end
#pragma mark -
#import <AppKit/AppKit.h>
#if MAC_OS_X_VERSION_10_3 <= MAC_OS_X_VERSION_MAX_ALLOWED
/*
@interface NSMatrix (NGSSelectionIndicies)
- (NSIndexSet *)selectedRows;
- (NSIndexSet *)selectedColumns;
@end
*/
#endif
@interface NSOutlineView (NGSSelectedItemExtensions)
/*!
@method selectedItem
@updated September 2001
*/
- (id)selectedItem;
/*!
@method selectedItems
@updated September 2001
*/
- (NSArray *)selectedItems;
@end
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
@interface NSGradient (NGSGradientExtensions)
/*!
@method aquaGradient
@method aquaGradientWithAlpha:
@method gradientWithAlpha:
@updated May 2007
*/
+ (NSGradient *)aquaGradient;
+ (NSGradient *)aquaGradientWithAlpha:(CGFloat)alpha;
- (NSGradient *)gradientWithAlpha:(CGFloat)alpha;
@end
#endif
#pragma mark -
#import <OpenGL/OpenGL.h>
@interface NSOpenGLContext (CGLContextAccess)
- (CGLContextObj)cglContext;
@end

View File

@ -0,0 +1,281 @@
#import "NGSCategories.h"
@implementation NSArray (NGSIndexExtensions)
- (NSArray *)subarrayWithIndicies:(NSIndexSet *)indicies
{
NSRange range = {0,[self count]};
unsigned int count = [indicies count];
unsigned int *buffer = (unsigned int *) calloc(count, sizeof(int));
NSMutableArray *newArray = [NSMutableArray arrayWithCapacity:count];
[indicies getIndexes:buffer maxCount:count inIndexRange:&range];
for(unsigned int i = 0; i < count; i++)
[newArray addObject:[self objectAtIndex:*(buffer+i)]];
return [NSArray arrayWithArray:newArray];
}
@end
@implementation NSArray (NGSKeyValueExtensions)
- (int)indexOfFirstObjectReturningValue:(id)value forKey:(id)key
{
return [[self valueForKey:key] indexOfObject:value];
}
- (id)firstObjectReturningValue:(id)value forKey:(id)key
{
int index = [[self valueForKey:key] indexOfObject:value];
if(index != NSNotFound)
return [self objectAtIndex:index];
else return nil;
}
- (NSArray *)objectsReturningValue:(id)value forKey:(id)key
{
id object;
NSMutableArray *array = [NSMutableArray array];
NSEnumerator *enumerator = [self objectEnumerator];
while(object = [enumerator nextObject])
if([[object valueForKey:key] isEqual:value])
[array addObject:object];
return [NSArray arrayWithArray:array];
}
- (NSArray *)arrayByMakingObjectsPerformSelector:(SEL)selector withObject:(id)inObject
{
id object;
NSMutableArray *array = [NSMutableArray array];
NSEnumerator *enumerator = [self objectEnumerator];
while(object = [enumerator nextObject])
[array addObject:[object performSelector:selector withObject:inObject]];
return [NSArray arrayWithArray:array];
}
@end
#pragma mark -
@implementation NSCharacterSet (NGSCharacterSetExtensions)
#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
+ (NSCharacterSet *)newlineCharacterSet
{
unsigned char bitmapRep[8192];
bitmapRep[0x0A >> 3] |= (((unsigned int)1) << (0x0A & 7));
bitmapRep[0x0B >> 3] |= (((unsigned int)1) << (0x0B & 7));
bitmapRep[0x0C >> 3] |= (((unsigned int)1) << (0x0C & 7));
bitmapRep[0x0D >> 3] |= (((unsigned int)1) << (0x0D & 7));
bitmapRep[0x85 >> 3] |= (((unsigned int)1) << (0x85 & 7));
NSData *data = [NSData dataWithBytesNoCopy:bitmapRep length:8192 freeWhenDone:YES];
return [NSCharacterSet characterSetWithBitmapRepresentation:data];
}
#endif
+ (NSCharacterSet *)tabCharacterSet
{
unsigned char bitmapRep[8192];
bitmapRep[0x09 >> 3] |= (((unsigned int)1) << (0x09 & 7));
bitmapRep[0x0B >> 3] |= (((unsigned int)1) << (0x0B & 7));
NSData *data = [NSData dataWithBytesNoCopy:bitmapRep length:8192 freeWhenDone:YES];
return [NSCharacterSet characterSetWithBitmapRepresentation:data];
}
@end
#pragma mark -
@implementation NSIndexSet (NGSIndicies)
+ (id)indexSetWithIndiciesInRange:(NSRange)range
{ return [NSIndexSet indexSetWithIndexesInRange:range]; }
- (id)initWithIndiciesInRange:(NSRange)range
{ return [self initWithIndexesInRange:range]; }
- (unsigned int)getIndicies:(unsigned int *)indexBuffer maxCount:(unsigned int)bufferSize inIndexRange:(NSRangePointer)range
{ return [self getIndexes:indexBuffer maxCount:bufferSize inIndexRange:range]; }
- (BOOL)containsIndiciesInRange:(NSRange)range
{ return [self containsIndexesInRange:range]; }
- (BOOL)containsIndicies:(NSIndexSet *)indexSet
{ return [self containsIndexes:indexSet]; }
- (BOOL)intersectsIndiciesInRange:(NSRange)range
{ return [self intersectsIndexesInRange:range]; }
@end
@implementation NSMutableIndexSet (NGSIndicies)
- (void)addIndicies:(NSIndexSet *)indexSet
{ [self addIndexes:indexSet]; }
- (void)removeIndicies:(NSIndexSet *)indexSet
{ [self removeIndexes:indexSet]; }
- (void)removeAllIndicies
{ [self removeAllIndexes]; }
- (void)addIndiciesInRange:(NSRange)range
{ [self addIndexesInRange:range]; }
- (void)removeIndiciesInRange:(NSRange)range
{ [self removeIndexesInRange:range]; }
- (void)shiftIndiciesStartingAtIndex:(unsigned int)index by:(int)delta
{ [self shiftIndexesStartingAtIndex:index by:delta]; }
@end
#pragma mark -
@implementation NSNumber (NGSRangeExtensions)
- (BOOL)isWithinRange:(NSRange)range // location <= self <= location+length
{
// e.g. for {6,1} a value of 6.000 will return true, as will 7.000
return [self compare:[NSNumber numberWithInt:range.location]] != NSOrderedAscending && [self compare:[NSNumber numberWithInt:range.location+range.length]] != NSOrderedDescending;
}
- (BOOL)isExclusivelyWithinRange:(NSRange)range // location < self < location+length
{
// e.g. for {6,1} a value of 6.000 will return false, 6.001 will return true, 6.999 will return true, 7.000 false
return [self compare:[NSNumber numberWithInt:range.location]] == NSOrderedDescending && [self compare:[NSNumber numberWithInt:range.location+range.length]] == NSOrderedAscending;
}
- (BOOL)isBoundedByRange:(NSRange)range // location <= self < location+length
{
// e.g. for {6,1} a value of 6.000 will return true, 6.999 will return true, 7.000 will not
return [self compare:[NSNumber numberWithInt:range.location]] != NSOrderedAscending && [self compare:[NSNumber numberWithInt:range.location+range.length]] == NSOrderedAscending;
}
@end
#pragma mark -
@implementation NSString (NGSFSSpecExtensions)
- (FSRef *)createFSRef
{
// caller is responsible for disposing of the FSRef (method is a 'create' method)
FSRef *fsRef = (FSRef *) NewPtrClear(sizeof(FSRef));
OSStatus error = FSPathMakeRef((const UInt8 *)[self fileSystemRepresentation], fsRef, NULL);
if(error != noErr) fsRef = NULL;
return fsRef;
}
- (FSSpec *)createFSSpec
{
// caller is responsible for disposing of the FSSpec (method is a 'create' method)
FSRef *fsRef = (FSRef *) NewPtrClear(sizeof(FSRef));
FSSpec *fsSpec = (FSSpec *) NewPtrClear(sizeof(FSSpec));
OSStatus error = FSPathMakeRef((const UInt8 *)[self fileSystemRepresentation], fsRef, NULL);
if(error == noErr)
{
error = FSGetCatalogInfo(fsRef, kFSCatInfoNone, NULL, NULL, fsSpec, NULL);
if(error == noErr)
{
DisposePtr((Ptr)fsRef);
return fsSpec;
}
}
DisposePtr((Ptr)fsRef);
DisposePtr((Ptr)fsSpec);
return NULL;
}
@end
@implementation NSString (NGSBooleanExtensions)
#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
- (BOOL)boolValue
{
return ![self isEqualToString:@"NO"];
}
#endif
+ (NSString *)stringWithBool:(BOOL)boolean
{
return boolean? @"YES" : @"NO";
}
@end
#pragma mark -
#if MAC_OS_X_VERSION_10_3 <= MAC_OS_X_VERSION_MAX_ALLOWED
/*
@implementation NSMatrix (NGSSelectionIndicies)
- (NSIndexSet *)selectedRows
{
int numRows, numCols;
NSMutableIndexSet *rows = [[NSMutableIndexSet alloc] init];
[self getNumberOfRows:&numRows columns:&numCols];
for(int r = 0; r < numRows; r++)
{
for(int c = 0; c < numCols; c++)
{
if()
{
c = numCols;
continue;
}
}
}
}
- (NSIndexSet *)selectedColumns
{
NSMutableIndexSet *columns = [[NSMutableIndexSet alloc] init];
}
@end
*/
#endif
@implementation NSOutlineView (NGSSelectedItemExtensions)
- (id)selectedItem
{
if([self numberOfSelectedRows] != 1) return nil;
else return [self itemAtRow:[self selectedRow]];
}
- (NSArray *)selectedItems;
{
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];
while(row = [enumerator nextObject])
[items addObject:[self itemAtRow:[row intValue]]];
#endif
return items;
}
@end
#pragma mark -
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
@implementation NSGradient (NGSGradientExtensions)
+ (NSGradient *)aquaGradient
{
NSGradient *gradient = [[NSGradient alloc] initWithColorsAndLocations:
[NSColor colorWithCalibratedWhite: 0.95 alpha: 1.0], 0.0,
[NSColor colorWithCalibratedWhite: 0.83 alpha: 1.0], 0.5,
[NSColor colorWithCalibratedWhite: 0.95 alpha: 1.0], 0.5,
[NSColor colorWithCalibratedWhite: 0.92 alpha: 1.0], 1.0, nil];
return [gradient autorelease];
}
+ (NSGradient *)aquaGradientWithAlpha:(CGFloat)alpha
{
NSGradient *gradient = [[NSGradient alloc] initWithColorsAndLocations:
[NSColor colorWithCalibratedWhite: 0.95 alpha: alpha], 0.0,
[NSColor colorWithCalibratedWhite: 0.83 alpha: alpha], 0.5,
[NSColor colorWithCalibratedWhite: 0.95 alpha: alpha], 0.5,
[NSColor colorWithCalibratedWhite: 0.92 alpha: alpha], 1.0, nil];
return [gradient autorelease];
}
- (NSGradient *)gradientWithAlpha:(CGFloat)alpha
{
NSColor *colour;
NSInteger stops = [self numberOfColorStops];
NSMutableArray *colours = [NSMutableArray array];
CGFloat *locations = (CGFloat *) calloc(sizeof(CGFloat), stops);
for(NSInteger i = 0; i < stops; i++)
{
[self getColor: &colour location: &(locations[i]) atIndex: i];
[colours addObject: [colour colorWithAlphaComponent: alpha]];
}
NSGradient *gradient = [[NSGradient alloc] initWithColors: colours atLocations: locations colorSpace: [self colorSpace]];
return [gradient autorelease];
}
@end
#endif
#pragma mark -
/* CGLContext access for pre-10.3 */
@implementation NSOpenGLContext (CGLContextAccess)
- (CGLContextObj)cglContext;
{
if(NSAppKitVersionNumber < 700.0)
return _contextAuxiliary;
else return (CGLContextObj) [self CGLContextObj];
}
@end

View File

@ -1,11 +1,11 @@
#import <Carbon/Carbon.h>
#import <AppKit/AppKit.h>
@interface NSEvent (ModifierKeys)
@interface NSEvent (NGSModifierKeys)
+ (BOOL) isControlKeyDown;
+ (BOOL) isOptionKeyDown;
+ (BOOL) isCommandKeyDown;
+ (BOOL) isShiftKeyDown;
+ (BOOL)isControlKeyDown;
+ (BOOL)isOptionKeyDown;
+ (BOOL)isCommandKeyDown;
+ (BOOL)isShiftKeyDown;
@end

View File

@ -1,23 +1,23 @@
#import "NSEvent-ModifierKeys.h"
@implementation NSEvent (ModifierKeys)
@implementation NSEvent (NGSModifierKeys)
+ (BOOL) isControlKeyDown
+ (BOOL)isControlKeyDown
{
return (GetCurrentKeyModifiers() & controlKey) != 0;
}
+ (BOOL) isOptionKeyDown
+ (BOOL)isOptionKeyDown
{
return (GetCurrentKeyModifiers() & optionKey) != 0;
}
+ (BOOL) isCommandKeyDown
+ (BOOL)isCommandKeyDown
{
return (GetCurrentKeyModifiers() & cmdKey) != 0;
}
+ (BOOL) isShiftKeyDown
+ (BOOL)isShiftKeyDown
{
return (GetCurrentKeyModifiers() & shiftKey) != 0;
}

View File

@ -1,6 +1,6 @@
#import <Foundation/Foundation.h>
@interface NSNumber (ResKnifeRangeExtensions)
@interface NSNumber (NGSRange)
- (BOOL)isWithinRange:(NSRange)range; // location <= self <= location+length
- (BOOL)isExclusivelyWithinRange:(NSRange)range; // location < self < location+length

View File

@ -1,6 +1,6 @@
#import "NSNumber-Range.h"
@implementation NSNumber (ResKnifeRangeExtensions)
@implementation NSNumber (NGSRange)
- (BOOL)isWithinRange:(NSRange)range // location <= self <= location+length
{

View File

@ -1,6 +1,6 @@
#import <Cocoa/Cocoa.h>
@interface NSOutlineView (ResKnifeSelectedItemExtensions)
@interface NSOutlineView (NGSSelectedItems)
- (id)selectedItem;
- (NSArray *)selectedItems;

View File

@ -2,22 +2,31 @@
/* The methods in the following catagory were based upon those in OmniAppKit */
@implementation NSOutlineView (ResKnifeSelectedItemExtensions)
@implementation NSOutlineView (NGSSelectedItems)
- (id)selectedItem
{
if( [self numberOfSelectedRows] != 1 ) return nil;
if ([self numberOfSelectedRows] != 1) return nil;
else return [self itemAtRow:[self selectedRow]];
}
- (NSArray *)selectedItems;
- (NSArray *)selectedItems
{
NSNumber *row;
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];
while( row = [enumerator nextObject] )
while (row = [enumerator nextObject])
[items addObject:[self itemAtRow:[row intValue]]];
#endif
return items;
}

View File

@ -1,8 +1,16 @@
#import <Foundation/Foundation.h>
@interface NSString (ResKnifeFSSpecExtensions)
@interface NSString (NGSFSSpec)
- (FSRef *)createFSRef;
- (FSSpec *)createFSSpec;
@end
@interface NSString (NGSBoolean)
- (BOOL)boolValue;
+ (NSString *)stringWithBool:(BOOL)boolean;
@end

View File

@ -1,28 +1,49 @@
#import "NSString-FSSpec.h"
@implementation NSString (ResKnifeFSSpecExtensions)
@implementation NSString (NGSFSSpec)
- (FSRef *)createFSRef
{
FSRef *fsRef = NULL;
OSStatus error = FSPathMakeRef( [self fileSystemRepresentation], fsRef, NULL );
if( error == noErr )
// caller is responsible for disposing of the FSRef (method is a 'create' method)
FSRef *fsRef = (FSRef *) NewPtrClear(sizeof(FSRef));
OSStatus error = FSPathMakeRef((unsigned char *)[self fileSystemRepresentation], fsRef, NULL);
if(error == noErr)
return fsRef;
return NULL;
}
- (FSSpec *)createFSSpec
{
FSRef *fsRef = NULL;
FSSpec *fsSpec = NULL;
OSStatus error = FSPathMakeRef( [self fileSystemRepresentation], fsRef, NULL );
if( error == noErr )
// caller is responsible for disposing of the FSSpec (method is a 'create' method)
FSRef *fsRef = (FSRef *) NewPtrClear(sizeof(FSRef));
FSSpec *fsSpec = (FSSpec *) NewPtrClear(sizeof(FSSpec));
OSStatus error = FSPathMakeRef((unsigned char *)[self fileSystemRepresentation], fsRef, NULL);
if(error == noErr)
{
error = FSGetCatalogInfo( fsRef, kFSCatInfoNone, NULL, NULL, fsSpec, NULL );
if( error == noErr )
error = FSGetCatalogInfo(fsRef, kFSCatInfoNone, NULL, NULL, fsSpec, NULL);
if(error == noErr)
{
DisposePtr((Ptr) fsRef);
return fsSpec;
}
}
DisposePtr((Ptr) fsRef);
return NULL;
}
@end
@implementation NSString (NGSBoolean)
- (BOOL)boolValue
{
return ![self isEqualToString:@"NO"];
// return [self isEqualToString:@"YES"];
}
+ (NSString *)stringWithBool:(BOOL)boolean
{
return boolean? @"YES" : @"NO";
}
@end

View File

@ -1,75 +1,100 @@
#import <Cocoa/Cocoa.h>
/*! @header ApplicationDelegate.h
* @discussion This class is the delegate object for NSApp.
*/
/*!
@header ApplicationDelegate.h
@abstract This class is the delegate object for NSApp.
*/
/*! @class ApplicationDelegate
* @discussion This class is the delegate object for NSApp.
*/
/*!
@class ApplicationDelegate
@abstract This class is the delegate object for NSApp.
*/
@class OpenPanelDelegate;
@interface ApplicationDelegate : NSObject
{
/*! @var openAuxView Accessory view for <tt>NSOpenPanels</tt>. */
IBOutlet NSView *openAuxView;
/*! @var forkTableView Table view inside <tt>openAuxView</tt>. */
IBOutlet NSTableView *forkTableView;
/*! @var icons A dictionary within which to cache icons. Keys are four-character <tt>NSStrings</tt> representing <tt>ResTypes</tt>. */
NSMutableDictionary *icons;
/*! @var openPanelDelegate Delegate for <tt>NSOpenPanels</tt>. */
IBOutlet OpenPanelDelegate *openPanelDelegate;
/*! @var icons A dictionary within which to cache icons. Keys are four-character <tt>NSStrings</tt> representing <tt>ResTypes</tt>. */
NSMutableDictionary *_icons;
}
/*! @function showAbout:
* @discussion Displays the about box located in <b>AboutPanel.nib</b>.
*/
/*!
@method showAbout:
@abstract Displays the about box located in <b>AboutPanel.nib</b>.
*/
- (IBAction)showAbout:(id)sender;
/*! @function visitWebsite:
* @discussion Takes the user to <i>http://web.nickshanks.com/resknife/</i>.
*/
/*!
@method visitWebsite:
@abstract Takes the user to <i>http://web.nickshanks.com/resknife/</i>.
*/
- (IBAction)visitWebsite:(id)sender;
/*! @function visitSourceforge:
* @discussion Takes the user to <i>http://resknife.sourceforge.net/</i>.
*/
/*!
@method visitSourceforge:
@abstract Takes the user to <i>http://resknife.sourceforge.net/</i>.
*/
- (IBAction)visitSourceforge:(id)sender;
/*! @function emailDeveloper:
* @discussion Launches email client and inserts <i>resknife@nickshanks.com</i> into To field.
*/
/*!
@method emailDeveloper:
@abstract Launches email client and inserts <i>resknife@nickshanks.com</i> into To field.
*/
- (IBAction)emailDeveloper:(id)sender;
/*! @function showInfo:
* @discussion Displays the Info panel stored in <b>InfoWindow.nib</b>
*/
/*!
@method showInfo:
@abstract Displays the Info panel stored in <b>InfoWindow.nib</b>
*/
- (IBAction)showInfo:(id)sender;
/*! @function showPasteboard:
* @discussion Displays the pasteboard document, a singleton instance of class <tt>PasteboardDocument</tt>
*/
/*!
@method showPasteboard:
@abstract Displays the pasteboard document, a singleton instance of class <tt>PasteboardDocument</tt>
*/
- (IBAction)showPasteboard:(id)sender;
/*! @function showPrefs:
* @discussion Displays the preferences panel stored in <b>PrefsWindow.nib</b>
*/
/*!
@method showPrefs:
@abstract Displays the preferences panel stored in <b>PrefsWindow.nib</b>
*/
- (IBAction)showPrefs:(id)sender;
/*! @function initUserDefaults
* @discussion Initalises any unset user preferences to default values as read in from <b>defaults.plist</b>.
*/
/*!
@method initUserDefaults
@abstract Initalises any unset user preferences to default values as read in from <b>defaults.plist</b>.
*/
- (void)initUserDefaults;
/*! @function openAuxView
* @discussion Accessor method for the <tt>openAuxView</tt> instance variable.
*/
- (NSView *)openAuxView;
/* accessors */
/*! @function icons
* @discussion Accessor method for the <tt>icons</tt> instance variable.
*/
/*!
@method openPanelDelegate
@abstract Accessor method for the <tt>openPanelDelegate</tt> instance variable.
*/
- (OpenPanelDelegate *)openPanelDelegate;
/*!
@@method iconForResourceType:
@abstract Returns the icon to be used throughout the UI for any given resource type.
*/
- (NSImage *)iconForResourceType:(NSString *)resourceType;
/*!
@@method _icons
@abstract Private accessor method for the <tt>_icons</tt> instance variable.
*/
- (NSMutableDictionary *)_icons;
/*!
@method icons
@abstract Accessor method for the <tt>_icons</tt> instance variable. Returns an immutable dictionary.
*/
- (NSDictionary *)icons;
@end
@interface NSSavePanel (PackageBrowser)
/* utility methods */
- (NSArray *)forksForFile:(FSRef *)fileRef;
@end

View File

@ -1,4 +1,5 @@
#import "ApplicationDelegate.h"
#import "OpenPanelDelegate.h"
#import "RKDocumentController.h"
#import "InfoWindowController.h"
#import "PasteboardWindowController.h"
@ -6,8 +7,11 @@
#import "CreateResourceSheetController.h"
#import "ResourceDocument.h"
#import "ResourceDataSource.h"
#import "RKEditorRegistry.h"
#import "ResKnifePluginProtocol.h"
#import "RKSupportResourceRegistry.h"
#import "ResknifePluginProtocol.h"
@implementation ApplicationDelegate
@ -21,48 +25,104 @@
- (void)applicationWillFinishLaunching:(NSNotification *)notification
{
// instanciate my own subclass of NSDocumentController so I can override the open dialog
RKDocumentController *docController = [[RKDocumentController alloc] init];
#pragma unused( docController )
[[RKDocumentController alloc] init];
[RKSupportResourceRegistry scanForSupportResources];
}
/*!
@method awakeFromNib
@updated 2003-10-24 NGS: moved icon caching into method called by timer (to speed up app launch time)
*/
- (void)awakeFromNib
{
NSTableColumn *tableColumn;
NSButtonCell *buttonCell;
// Part of my EvilPlanª to find out how many people use ResKnife and how often!
int launchCount = [[NSUserDefaults standardUserDefaults] integerForKey:@"LaunchCount"];
[[NSUserDefaults standardUserDefaults] setInteger:launchCount + 1 forKey:@"LaunchCount"];
// save a number of icons
icons = [[NSMutableDictionary alloc] init];
[icons setObject:[[NSWorkspace sharedWorkspace] iconForFileType:@"TEXT"] forKey:@"TEXT"];
[icons setObject:[[NSWorkspace sharedWorkspace] iconForFileType:@"PICT"] forKey:@"PICT"];
[icons setObject:[[NSWorkspace sharedWorkspace] iconForFileType:@"icns"] forKey:@"icns"];
// set up open dialog's aux table view
tableColumn = [forkTableView tableColumnWithIdentifier:@"parse"];
buttonCell = [[[NSButtonCell alloc] initTextCell:@""] autorelease];
[buttonCell setEditable:YES];
[buttonCell setButtonType:NSSwitchButton];
[tableColumn setDataCell:buttonCell];
// initalise an empty icon cache and create timer used to pre-cache a number of common icons
_icons = [[NSMutableDictionary alloc] init];
[NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(precacheIcons:) userInfo:nil repeats:NO];
// set default preferences
[self initUserDefaults];
}
- (void)dealloc
{
[icons release];
[_icons release];
[super dealloc];
}
/*!
@method precacheIcons:
@author Nicholas Shanks
@created 2003-10-24
@abstract Pre-caches the icons for a number of common resource types.
@description Icon pre-caching now uses the more sophisticated iconForResourceType: instead of obtaining the images directly from the file system (otherwise pre-cached icons would not be overridable by plug-ins). In addition it has been moved from the awakeFromNib: method into one called by a timer. This method should not be called until after the editor registry has been built.
*/
- (void)precacheIcons:(NSTimer *)timer
{
// 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:@"icns"];
[self iconForResourceType:@"PICT"];
[self iconForResourceType:@"plst"];
[self iconForResourceType:@"snd "];
[self iconForResourceType:@"TEXT"];
}
- (NSArray *)forksForFile:(FSRef *)fileRef
{
if(!fileRef) return nil;
FSCatalogInfo catalogInfo;
FSCatalogInfoBitmap whichInfo = kFSCatInfoNodeFlags;
CatPositionRec forkIterator = { 0 };
NSMutableArray *forks = [NSMutableArray array];
// check we have a file, not a folder
OSErr error = FSGetCatalogInfo(fileRef, whichInfo, &catalogInfo, NULL, NULL, NULL);
if(!error && !(catalogInfo.nodeFlags & kFSNodeIsDirectoryMask))
{
// iterate over file and populate forks array
while(error == noErr)
{
HFSUniStr255 forkName;
SInt64 forkSize;
UInt64 forkPhysicalSize; // used if opening selected fork fails to find empty forks
error = FSIterateForks(fileRef, &forkIterator, &forkName, &forkSize, &forkPhysicalSize);
if(!error)
{
NSString *fName = [NSString stringWithCharacters:forkName.unicode length:forkName.length];
NSNumber *fSize = [NSNumber numberWithLongLong:forkSize];
NSNumber *fAlloc = [NSNumber numberWithUnsignedLongLong:forkPhysicalSize];
[forks addObject:[NSDictionary dictionaryWithObjectsAndKeys:fName, @"forkname", fSize, @"forksize", fAlloc, @"forkallocation", nil]];
}
else if(error != errFSNoMoreItems)
{
NSLog(@"FSIterateForks() error: %d", error);
}
}
}
else if(error)
{
NSLog(@"FSGetCatalogInfo() error: %d", error);
}
return forks;
}
- (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender
{
#pragma unused( sender )
#pragma unused(sender)
NSString *launchAction = [[NSUserDefaults standardUserDefaults] stringForKey:@"LaunchAction"];
if( [launchAction isEqualToString:@"OpenUntitledFile"] )
if([launchAction isEqualToString:@"OpenUntitledFile"])
return YES;
else if( [launchAction isEqualToString:@"DisplayOpenPanel"] )
else if([launchAction isEqualToString:@"DisplayOpenPanel"])
{
[[NSDocumentController sharedDocumentController] openDocument:sender];
return NO;
@ -72,7 +132,7 @@
- (BOOL)application:(NSApplication *)application openFile:(NSString *)file
{
#pragma unused( application )
#pragma unused(application)
// bug: check if application was an external editor (e.g. Iconographer) and update existing open file instead
[[NSDocumentController sharedDocumentController] openDocumentWithContentsOfFile:file display:YES];
return YES;
@ -80,14 +140,20 @@
- (BOOL)applicationShouldHandleReopen:(NSApplication *)sender hasVisibleWindows:(BOOL)flag
{
#pragma unused( sender )
#pragma unused(sender)
return !flag;
}
- (IBAction)showAbout:(id)sender
{
[NSApp orderFrontStandardAboutPanel:sender];
// get about box code from http://cocoadevcentral.com/tutorials/showpage.php?show=00000041.php
// could do with a better about box
/* NSWindowController *wc = [[NSWindowController alloc] initWithWindowNibName:@"AboutPanel"];
if([(NSTextView *)[[wc window] initialFirstResponder] readRTFDFromFile:[[NSBundle mainBundle] pathForResource:@"Credits" ofType:@"rtf"]])
{
[[wc window] center];
[[wc window] orderFront:nil];
}
else*/ [NSApp orderFrontStandardAboutPanel:sender];
}
- (IBAction)visitWebsite:(id)sender
@ -142,12 +208,12 @@
// enumerate over all the keys in the dictionary
overDefaults = [[defaultsPlist allKeys] objectEnumerator];
while( eachDefault = [overDefaults nextObject] )
while(eachDefault = [overDefaults nextObject])
{
// for each key in the dictionary
// check if there is a value already registered for it
// and if there isn't, then register the value that was in the file
if( ![defaults stringForKey:eachDefault] )
if(![defaults stringForKey:eachDefault])
{
[defaults setObject:[defaultsPlist objectForKey:eachDefault] forKey:eachDefault];
}
@ -157,26 +223,106 @@
[defaults synchronize];
}
- (NSView *)openAuxView
- (OpenPanelDelegate *)openPanelDelegate
{
return openAuxView;
return openPanelDelegate;
}
/*!
@method iconForResourceType:
@author Nicholas Shanks
@created 2003-10-24
@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 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?
*/
- (NSImage *)iconForResourceType:(NSString *)resourceType
{
NSImage *icon = nil;
if([resourceType isEqualToString:@""])
resourceType = nil;
if(resourceType)
{
// 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!)
if(!icon)
{
NSString *iconPath = nil;
// 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)
{
iconPath = [[NSBundle mainBundle] pathForResource:resourceType ofType:nil inDirectory:@"Resource Type Icons"];
if(iconPath)
icon = [[[NSImage alloc] initWithContentsOfFile:iconPath] autorelease];
}
// try to retrieve from file system using our resource type to file name extension/bundle identifier code
if(!icon)
{
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];
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];
}
}
else
{
// we have no resource type, try to get a generic icon - this is what icon represented forks get
// if(!icon) icon = [NSImage imageNamed:@"NSMysteryDocument"];
// if(!icon) icon = [[NSWorkspace sharedWorkspace] iconForFileType:@"' '"];
if(!icon) icon = [[NSWorkspace sharedWorkspace] iconForFileType:[NSString stringWithFormat:@"'%@'", @"????"]];
}
// return the cached icon, or nil if none was found
return icon;
}
- (NSMutableDictionary *)_icons
{
return _icons;
}
- (NSDictionary *)icons
{
return icons;
return [NSDictionary dictionaryWithDictionary:[self _icons]];
}
@end
@implementation NSSavePanel (PackageBrowser)
/* Don't tell anyone I did this... */
/*- (void)setTreatsFilePackagesAsDirectories:(BOOL)flag
{
#pragma unused( flag )
_spFlags.treatsFilePackagesAsDirectories = YES;
}*/
@end

View File

@ -5,62 +5,55 @@
@implementation CreateResourceSheetController
/* -----------------------------------------------------------------------------
controlTextDidChange:
Someone changed the control ID edit field. Check whether this is
a unique ID and appropriately enable the "create" button.
Check "notification" against being nil, which is how we call it when
we need to explicitly update the enabled state of the "create" button.
REVISIONS:
2003-08-01 UK Commented, changed to use data source's resourceOfType
instead of directly messing with the resource list's
enumerator Removed ID > 0 check -- negative IDs are
allowed as well.
-------------------------------------------------------------------------- */
/*!
@method controlTextDidChange:
@abstract Handles updating of the 'Create' button when valid values are present in the sheet's fields.
@updated 2003-08-01 UK: Changed to use data source's resourceOfType instead of directly messing with the resource list's enumerator.
@updated 2003-08-01 UK: Removed ID > 0 check -- negative IDs are allowed as well.<br/><small>Note from Nick: IIRC this was there as a workaround for another bug which prohibited negative IDs from being used. Not sure if that got fixed though :)</small>
@description Someone changed the control ID edit field. Check whether this is a unique ID and appropriately enable the "create" button.</p><p>Check "notification" against being nil, which is how we call it when we need to explicitly update the enabled state of the "create" button.
*/
-(void) controlTextDidChange: (NSNotification*)notification
- (void)controlTextDidChange:(NSNotification *)notification
{
BOOL enableButton = NO;
NSString *type = [typeView stringValue];
NSNumber *resID = [NSNumber numberWithInt:[resIDView intValue]];
if( [type length] == 4 )
if([type length] == 4)
{
// I could use +[Resource getResourceOfType:andID:inDocument:] != nil, but that would be much slower
Resource *resource = [[document dataSource] resourceOfType:type andID:resID];
if( resource == nil ) // No resource with that type and ID yet?
if(resource == nil) // No resource with that type and ID yet?
enableButton = YES;
}
[createButton setEnabled:enableButton];
}
/*!
@method showCreateResourceSheet:
@abstract Shows the sheet allowing the user to define the properties of a new resource.
@updated 2003-08-01 UK: Made it "fake" a popup selection so type field and popup match.
@updated 2003-08-01 UK: Made it suggest an unused resource ID.
*/
/* -----------------------------------------------------------------------------
showCreateResourceSheet:
Show our sheet and set it up before that.
REVISIONS:
2003-08-01 UK Commented, made it "fake" a popup selection so
type field and popup match. Made it suggest an unused
resource ID.
-------------------------------------------------------------------------- */
-(void) showCreateResourceSheet: (ResourceDocument*)sheetDoc
- (void)showCreateResourceSheet:(ResourceDocument *)sheetDoc
{
// bug: didEndSelector could be better employed than using the button's targets from interface builder
document = sheetDoc;
[NSApp beginSheet:[self window] modalForWindow:[document mainWindow] modalDelegate:self didEndSelector:NULL contextInfo:nil];
[resIDView setObjectValue: [[document dataSource] uniqueIDForType: [typeView stringValue]]];
[self typePopupSelection: typePopup]; // Puts current popup value in text field and updates state of "create" button.
[resIDView setObjectValue:[[document dataSource] uniqueIDForType:[typeView stringValue]]];
// put current popup value in text field and updates state of "create" button.
[self typePopupSelection:typePopup];
}
- (IBAction)hideCreateResourceSheet:(id)sender
{
if( sender == createButton )
if(sender == createButton)
{
// bug should be using cell's tag rather than position (so cells can be moved around if needed)
// attributes ^= [[attributesMatrix cellAtRow:0 column:0] intValue]? [[attributesMatrix cellAtRow:0 column:0] tag]:0;
unsigned short attributes = 0;
attributes ^= [[attributesMatrix cellAtRow:0 column:0] intValue]? resPreload:0;
attributes ^= [[attributesMatrix cellAtRow:1 column:0] intValue]? resPurgeable:0;
@ -68,28 +61,26 @@
attributes ^= [[attributesMatrix cellAtRow:0 column:1] intValue]? resSysHeap:0;
attributes ^= [[attributesMatrix cellAtRow:1 column:1] intValue]? resProtected:0;
Resource *resource = [Resource resourceOfType:[typeView stringValue] andID:[NSNumber numberWithShort:(short) [resIDView intValue]] withName:[nameView stringValue] andAttributes:[NSNumber numberWithUnsignedShort:attributes]];
[resource setDocumentName:[document displayName]];
[[document undoManager] beginUndoGrouping];
[[document dataSource] addResource:[Resource resourceOfType:[typeView stringValue] andID:[NSNumber numberWithShort:(short) [resIDView intValue]] withName:[nameView stringValue] andAttributes:[NSNumber numberWithUnsignedShort:attributes]]];
if( [[nameView stringValue] length] == 0 )
[[document dataSource] addResource:resource];
if([[nameView stringValue] length] == 0)
[[document undoManager] setActionName:NSLocalizedString(@"Create Resource", nil)];
else [[document undoManager] setActionName:[NSString stringWithFormat:NSLocalizedString(@"Create Resource Ò%@Ó", nil), [nameView stringValue]]];
else [[document undoManager] setActionName:[NSString stringWithFormat:NSLocalizedString(@"Create Resource '%@'", nil), [nameView stringValue]]];
[[document undoManager] endUndoGrouping];
}
[[self window] orderOut:nil];
[NSApp endSheet:[self window]];
}
/*!
@method typePopupSelection:
@abstract Updates the edit text field when the type pop-up selection is changed.
@updated 2003-08-01 UK: Commented, made it update state of "create" button.
*/
/* -----------------------------------------------------------------------------
typePopupSelection:
Someone chose an item from our "res type" popup menu. Update our
edit field to show that.
REVISIONS:
2003-08-01 UK Commented, made it update state of "create" button..
-------------------------------------------------------------------------- */
-(IBAction) typePopupSelection:(id)sender
- (IBAction)typePopupSelection:(id)sender
{
[typeView setStringValue:[typePopup titleOfSelectedItem]];
[typeView selectText:sender];

View File

@ -35,7 +35,7 @@ enum Attributes
- (void)updateInfoWindow;
- (void)setMainWindow:(NSWindow *)mainWindow;
- (IBAction)attributesChanged:(id)sender;
- (IBAction)nameChanged: (id)sender;
- (IBAction)nameDidChange:(id)sender;
- (void)resourceAttributesDidChange:(NSNotification *)notification;
- (void)documentInfoDidChange:(NSNotification *)notification;
@ -46,7 +46,7 @@ enum Attributes
@interface NSWindowController (InfoWindowAdditions)
/*! @function resource
@discussion Your plug-in should override this method to return the resource it's editing. Default implementation returns nil.
@discussion Your plug-in should override this method to return the primary resource it's editing. Default implementation returns nil.
*/
- (Resource *)resource;

View File

@ -2,18 +2,12 @@
#import <Carbon/Carbon.h> // Actually I only need CarbonCore.framework, but <Carbon/CarbonCore.h> and <CarbonCore/CarbonCore.h> don't work, so I don't know what else to do
#import "ResourceDocument.h"
#import "Resource.h"
#import "ApplicationDelegate.h"
#import "NSOutlineView-SelectedItems.h"
#import "MoreFilesX.h"
@implementation InfoWindowController
- (id)init
{
self = [self initWithWindowNibName:@"InfoWindow"];
if( self ) [self setWindowFrameAutosaveName:@"InfoWindow"];
return self;
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
@ -40,59 +34,87 @@
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(documentInfoDidChange:) name:DocumentInfoDidChangeNotification object:nil];
}
-(void) updateInfoWindow
/*!
@method updateInfoWindow
@updated 2003-11-06 NGS: Fixed creator/type handling.
@updated 2003-10-26 NGS: Now asks app delegate for icon instead of NSWorkspace.
@updated 2003-10-26 NGS: Improved document name & icon display.
*/
- (void)updateInfoWindow
{
[nameView setEditable:(selectedResource != nil)];
[nameView setDrawsBackground:(selectedResource != nil)];
if( selectedResource )
if(selectedResource)
{
[[self window] setTitle:@"Resource Info"];
[placeholderView setContentView:resourceView];
// set UI values
[[self window] setTitle:NSLocalizedString(@"Resource Info",nil)];
[nameView setStringValue:[selectedResource name]];
[iconView setImage:[[NSWorkspace sharedWorkspace] iconForFileType:[selectedResource type]]];
[iconView setImage:[(ApplicationDelegate *)[NSApp delegate] iconForResourceType:[selectedResource type]]];
[[attributesMatrix cellAtRow:changedBox column:0] setState:[[selectedResource attributes] shortValue] & resChanged];
[[attributesMatrix cellAtRow:preloadBox column:0] setState:[[selectedResource attributes] shortValue] & resPreload];
[[attributesMatrix cellAtRow:protectedBox column:0] setState:[[selectedResource attributes] shortValue] & resProtected];
[[attributesMatrix cellAtRow:lockedBox column:0] setState:[[selectedResource attributes] shortValue] & resLocked];
[[attributesMatrix cellAtRow:purgableBox column:0] setState:[[selectedResource attributes] shortValue] & resPurgeable];
[[attributesMatrix cellAtRow:systemHeapBox column:0] setState:[[selectedResource attributes] shortValue] & resSysHeap];
// swap box
[placeholderView setContentView:resourceView];
}
else if( currentDocument != nil )
else if(currentDocument != nil)
{
// get sizes of forks as they are on disk
UInt64 dataLogicalSize = 0, rsrcLogicalSize = 0;
FSRef *fileRef = (FSRef *) NewPtrClear( sizeof(FSRef) );
if( fileRef && [currentDocument fileName] )
FSRef *fileRef = (FSRef *) NewPtrClear(sizeof(FSRef));
if(fileRef && [currentDocument fileName])
{
OSStatus error = FSPathMakeRef( [[currentDocument fileName] cString], fileRef, nil );
if( !error ) FSGetForkSizes( fileRef, &dataLogicalSize, &rsrcLogicalSize );
OSStatus error = FSPathMakeRef((unsigned char *)[[currentDocument fileName] fileSystemRepresentation], fileRef, nil);
if(!error) FSGetForkSizes(fileRef, &dataLogicalSize, &rsrcLogicalSize);
}
if( fileRef ) DisposePtr( (Ptr) fileRef );
if(fileRef) DisposePtr((Ptr) fileRef);
// set info window elements to correct values
[[self window] setTitle:@"Document Info"];
[iconView setImage:[NSImage imageNamed:@"Resource file"]];
[nameView setStringValue:[currentDocument fileName]? [[currentDocument fileName] lastPathComponent]:[currentDocument displayName]];
[[filePropertyForm cellAtIndex:0] setStringValue:[currentDocument creator]];
[[filePropertyForm cellAtIndex:1] setStringValue:[currentDocument type]];
[[self window] setTitle:NSLocalizedString(@"Document Info",nil)];
if([currentDocument fileName]) // document has been saved
{
[iconView setImage:[[NSWorkspace sharedWorkspace] iconForFile:[currentDocument fileName]]];
[nameView setStringValue:[[currentDocument fileName] lastPathComponent]];
}
else // new, untitled document
{
[iconView setImage:[NSImage imageNamed:@"Resource file"]];
[nameView setStringValue:[currentDocument displayName]];
}
#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:1] setStringValue:[[[NSString alloc] initWithData:[currentDocument type] encoding:NSMacOSRomanStringEncoding] autorelease]];
// [[filePropertyForm cellAtIndex:2] setObjectValue:[NSNumber numberWithUnsignedLongLong:dataLogicalSize]];
// [[filePropertyForm cellAtIndex:3] setObjectValue:[NSNumber numberWithUnsignedLongLong:rsrcLogicalSize]];
[[filePropertyForm cellAtIndex:2] setStringValue:[[NSNumber numberWithUnsignedLongLong:dataLogicalSize] description]];
[[filePropertyForm cellAtIndex:3] setStringValue:[[NSNumber numberWithUnsignedLongLong:rsrcLogicalSize] description]];
// swap box
[placeholderView setContentView:documentView];
}
else
{
[iconView setImage:nil];
[nameView setStringValue:@""];
[placeholderView setContentView:nil];
}
}
- (void)setMainWindow:(NSWindow *)mainWindow
{
NSWindowController *controller = [mainWindow windowController];
if( [[controller document] isKindOfClass:[ResourceDocument class]] )
if([[controller document] isKindOfClass:[ResourceDocument class]])
currentDocument = [controller document];
else currentDocument = nil;
if( currentDocument )
if(currentDocument)
selectedResource = [[currentDocument outlineView] selectedItem];
else selectedResource = [controller resource];
[self updateInfoWindow];
@ -105,15 +127,15 @@
- (void)selectedResourceChanged:(NSNotification *)notification
{
if( ![[nameView stringValue] isEqualToString: [selectedResource name]] )
[self nameChanged:nameView];
selectedResource = [[notification object] selectedItem];
if(![[nameView stringValue] isEqualToString:[selectedResource name]])
[self nameDidChange:nameView];
selectedResource = (Resource *) [[notification object] selectedItem];
[self updateInfoWindow];
}
- (void)documentInfoDidChange:(NSNotification *)notification
{
#pragma unused( notification )
#pragma unused(notification)
[self updateInfoWindow];
}
@ -124,23 +146,21 @@
[selectedResource setAttributes:[NSNumber numberWithShort:number]];
}
-(IBAction) nameChanged: (id)sender
- (IBAction)nameDidChange:(id)sender
{
[selectedResource setName: [nameView stringValue]];
[selectedResource setName:[nameView stringValue]];
}
- (void)resourceAttributesDidChange:(NSNotification *)notification;
{
if( ![[nameView stringValue] isEqualToString: [selectedResource name]] )
[self nameChanged:nameView];
[self updateInfoWindow];
}
+ (id)sharedInfoWindowController
{
static InfoWindowController *sharedInfoWindowController = nil;
if( !sharedInfoWindowController )
sharedInfoWindowController = [[InfoWindowController allocWithZone:[self zone]] init];
if(!sharedInfoWindowController)
sharedInfoWindowController = [[InfoWindowController allocWithZone:[self zone]] initWithWindowNibName:@"InfoWindow"];
return sharedInfoWindowController;
}

View File

@ -2,6 +2,9 @@
#import "NSOutlineView-SelectedItems.h"
#import "Resource.h"
/* NameFormatter has been deprecated (it never did what I wanted anyway :-) */
/* functionality is now in -outlineView:willDisplayCell:forTableColumn:item: */
@implementation NameFormatter
- (NSString *)stringForObjectValue:(id)obj

View File

@ -1,19 +0,0 @@
/* OpenFileDataSource */
#import <Cocoa/Cocoa.h>
@interface OpenFileDataSource : NSObject
{
IBOutlet NSTableView *forkTableView;
}
@end
@interface OpenPanelDelegate : NSObject
{
id originalDelegate;
}
@end
@interface NSSavePanel (ResKnife)
- (NSBrowser *)browser;
@end

View File

@ -1,113 +0,0 @@
#import "OpenFileDataSource.h"
#import <unistd.h>
#import <sys/attr.h>
struct directoryinfo {
unsigned long length;
u_int32_t dirid;
};
struct dunnowhat
{
unsigned long length;
u_int32_t data1;
u_int32_t data2;
u_int32_t data3;
u_int32_t data4;
u_int32_t data5;
u_int32_t data6;
};
@implementation OpenFileDataSource
//get action method and target of browser, intercept (or re-route and call it myself)
/* NSTableView data source protocol implementation */
- (int)numberOfRowsInTableView:(NSTableView *)tableView
{
//NSBrowser *browser = [(NSOpenPanel *)[tableView window] browser];
//if( [[browser selectedCells] count] == 1 )
{
// only one file is selected, parse it for forks
/* const char *path = [[browser path] cString];
struct attrlist attributes;
struct directoryinfo fileinfo;
NSLog( @"%s", path );
// memset( &attributes, 0, sizeof(struct attrlist) );
bzero( &attributes, sizeof(struct attrlist) );
attributes.bitmapcount = ATTR_BIT_MAP_COUNT;
// attributes.fileattr = ATTR_FILE_FORKCOUNT;
attributes.commonattr = ATTR_CMN_OBJID;
int result = getattrlist( path, &attributes, &fileinfo, sizeof(struct directoryinfo), 0 );
NSLog( @"%d", result );
if( result != 0 ) return 0;
NSLog( @"%d", fileinfo.length );
NSLog( @"%d", fileinfo.dirid );
*/
/*struct attrlist alist;
struct directoryinfo dirinfo;
char *path = [[browser path] cString];
bzero(&alist, sizeof(alist));
alist.bitmapcount = 5;
alist.commonattr = ATTR_CMN_OBJID;
int result = getattrlist(path, &alist, &dirinfo, sizeof(dirinfo), 0);
printf("result: %d; directory id: %lu; %s\n", result, dirinfo.dirid, path);
return 3;*/
}
// multiple/no selected files, return nothing
/*else*/ return 0;
}
- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
{
return nil;
}
- (void)tableView:(NSTableView *)tableView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn row:(int)row
{
;
}
/*
NSLog( [browser path] );
CatPositionRec forkIterator;
forkIterator.initialize = 0;
FSIterateForks( FSRef *ref, &forkIterator, NULL, NULL, NULL );
*/
@end
@implementation OpenPanelDelegate
- (NSMethodSignature *)methodSignatureForSelector:(SEL)selector
{
/* NSMethodSignature *sig;
NS_DURING
sig = [super methodSignatureForSelector:selector];
NS_HANDLER
sig = [originalDelegate methodSignatureForSelector:selector];
NS_ENDHANDLER
return sig; */
return [originalDelegate methodSignatureForSelector:selector];
}
- (void)forwardInvocation:(NSInvocation *)invocation
{
if( [originalDelegate respondsToSelector:[invocation selector]] )
[invocation invokeWithTarget:originalDelegate];
else [self doesNotRecognizeSelector:[invocation selector]];
}
@end
@implementation NSSavePanel (ResKnife)
- (NSBrowser *)browser
{
return nil; //return _browser;
}
@end

View File

@ -0,0 +1,43 @@
#import <Cocoa/Cocoa.h>
@interface OpenPanelDelegate : NSObject
{
/*! @var openPanelAccessoryView Accessory view for <tt>NSOpenPanels</tt>. */
IBOutlet NSView *openPanelAccessoryView;
/*! @var forkTableView Table view inside <tt>openPanelAccessoryView</tt>. */
IBOutlet NSTableView *forkTableView;
/*! @var addForkButton Button for adding forks to a file. */
IBOutlet NSButton *addForkButton;
/*! @var removeForkButton Button for removing forks from a file. */
IBOutlet NSButton *removeForkButton;
/*! @var forks Array of forks representing the currently selected file. */
NSMutableArray *forks;
/*! @var readOpenPanelForFork Flag indicating whether ResKnife should ask for a fork to parse in a secondary dialog (false) or obtain it from the selected item in the open dialog (true). */
BOOL readOpenPanelForFork;
}
/* actions from aux view controls */
- (IBAction)addFork:(id)sender;
- (IBAction)removeFork:(id)sender;
/* accessors */
/*!
@method openPanelAccessoryView
@abstract Accessor method for the <tt>openPanelAccessoryView</tt> instance variable.
*/
- (NSView *)openPanelAccessoryView;
/*!
@method forkTableView
@abstract Accessor method for the <tt>forkTableView</tt> instance variable.
*/
- (NSTableView *)forkTableView;
- (NSArray *)forks;
- (void)setReadOpenPanelForFork:(BOOL)flag;
- (BOOL)readOpenPanelForFork;
@end

View File

@ -0,0 +1,131 @@
#import "OpenPanelDelegate.h"
#import "ApplicationDelegate.h"
#import "SizeFormatter.h"
#import "../Categories/NSString-FSSpec.h"
@implementation OpenPanelDelegate
- (id)init
{
self = [super init];
if(self)
{
forks = [[NSMutableArray alloc] init];
readOpenPanelForFork = NO;
}
return self;
}
- (void)awakeFromNib
{
// remove this when functionality actually works
[addForkButton setEnabled:NO];
[removeForkButton setEnabled:NO];
}
- (void)dealloc
{
[forks release];
[super dealloc];
}
// open panel delegate method
- (void)panelSelectionDidChange:(id)sender
{
[forks setArray:[(ApplicationDelegate *)[NSApp delegate] forksForFile:[[sender filename] createFSRef]]];
[forkTableView reloadData];
}
- (BOOL)readOpenPanelForFork
{
return readOpenPanelForFork;
}
- (void)setReadOpenPanelForFork:(BOOL)flag
{
readOpenPanelForFork = flag;
}
// table view data source methods
- (int)numberOfRowsInTableView:(NSTableView *)tableView
{
return [forks count];
}
- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
{
// return object in array
if(row < [forks count])
{
if([[tableColumn identifier] isEqualToString:@"forkname"])
{
NSString *forkName = nil;
HFSUniStr255 *resourceForkName = (HFSUniStr255 *) NewPtrClear(sizeof(HFSUniStr255));
OSErr error = FSGetResourceForkName(resourceForkName);
forkName = [(NSDictionary *)[forks objectAtIndex:row] objectForKey:[tableColumn identifier]];
// return custom names for data and resource forks
if([forkName isEqualToString:@""])
forkName = NSLocalizedString(@"Data Fork", nil);
else if(!error && [forkName isEqualToString:[NSString stringWithCharacters:resourceForkName->unicode length:resourceForkName->length]])
forkName = NSLocalizedString(@"Resource Fork", nil);
DisposePtr((Ptr) resourceForkName);
return forkName;
}
// return default value otherwise
return [(NSDictionary *)[forks objectAtIndex:row] objectForKey:[tableColumn identifier]];
}
else return nil;
}
- (void)tableView:(NSTableView *)tableView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn row:(int)row
{
if([[tableColumn identifier] isEqualToString:@"forkname"])
{
// update forks array
// create fork with new name
}
}
- (IBAction)addFork:(id)sender
{
// add placeholder to forks array
[forks addObject:[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"UNTITLED_FORK", nil), @"forkname", [NSNumber numberWithInt:0], @"forksize", [NSNumber numberWithInt:0], @"forkallocation", nil]];
[forkTableView noteNumberOfRowsChanged];
[forkTableView reloadData];
// start editing placeholder
[forkTableView selectRow:[forks count]-1 byExtendingSelection:NO];
[forkTableView editColumn:0 row:[forks count]-1 withEvent:nil select:YES];
}
- (IBAction)removeFork:(id)sender
{
// display warning
// delete fork
// update table view
[forks removeObjectAtIndex:[forkTableView selectedRow]+1];
[forkTableView noteNumberOfRowsChanged];
[forkTableView reloadData];
}
- (NSArray *)forks
{
// returns an immutable array
return [NSArray arrayWithArray:forks];
}
- (NSView *)openPanelAccessoryView
{
return openPanelAccessoryView;
}
- (NSTableView *)forkTableView
{
return forkTableView;
}
@end

View File

@ -1,5 +1,4 @@
#import <Cocoa/Cocoa.h>
#import "NameFormatter.h"
#import "SizeFormatter.h"
#import "AttributesFormatter.h"
@ -7,20 +6,16 @@
@interface OutlineViewDelegate : NSObject
{
IBOutlet NSWindow *window;
IBOutlet NameFormatter *nameFormatter;
IBOutlet SizeFormatter *sizeFormatter;
IBOutlet AttributesFormatter *attributesFormatter;
IBOutlet NSWindow *window;
IBOutlet NSOutlineView *outlineView;
IBOutlet SizeFormatter *sizeFormatter;
IBOutlet AttributesFormatter *attributesFormatter;
}
int compareResourcesAscending( Resource *r1, Resource *r2, void *context );
int compareResourcesDescending( Resource *r1, Resource *r2, void *context );
int compareResourcesAscending(Resource *r1, Resource *r2, void *context);
int compareResourcesDescending(Resource *r1, Resource *r2, void *context);
@end
@interface NSOutlineView (OutlineSortView)
- (void)swapForOutlineSortView;
@end
@interface OutlineSortView : NSOutlineView
@interface RKOutlineView : NSOutlineView
@end

View File

@ -1,11 +1,42 @@
#import "OutlineViewDelegate.h"
#import "Resource.h"
#import "ResourceDocument.h"
#import "ResourceDataSource.h"
#import "ResourceNameCell.h"
#import "ApplicationDelegate.h"
@implementation OutlineViewDelegate
- (id)init
{
self = [super init];
if(!self) return nil;
if(NSAppKitVersionNumber >= 700.0) // darwin 7.0 == Mac OS 10.3, needed for -setPlaceholderString:
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updatePlaceholder:) name:ResourceNameDidChangeNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updatePlaceholder:) name:ResourceTypeDidChangeNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updatePlaceholder:) name:ResourceIDDidChangeNotification object:nil];
}
return self;
}
- (void)updatePlaceholder:(NSNotification *)notification
{
Resource *resource = [notification object];
ResourceNameCell *cell = (ResourceNameCell *) [[outlineView tableColumnWithIdentifier:@"name"] dataCellForRow:[outlineView rowForItem:resource]];
if([[resource name] isEqualToString:@""])
{
if([[resource resID] shortValue] == -16455)
[cell setPlaceholderString:NSLocalizedString(@"Custom Icon", nil)];
else [cell setPlaceholderString:NSLocalizedString(@"Untitled Resource", nil)];
}
}
/*!
@method tableView:didClickTableColumn:
@pending not needed in 10.3+, use existing sort functionality
*/
- (void)tableView:(NSTableView*)tableView didClickTableColumn:(NSTableColumn *)tableColumn
{
NSArray *newResources;
@ -14,111 +45,156 @@
// sort the array
NSImage *indicator = [tableView indicatorImageInTableColumn:tableColumn];
NSImage *upArrow = [NSTableView _defaultTableHeaderSortImage];
if( indicator == upArrow )
{
newResources = [oldResources sortedArrayUsingFunction:compareResourcesAscending context:(void*)[tableColumn identifier]];
}
else
{
newResources = [oldResources sortedArrayUsingFunction:compareResourcesDescending context:(void*)[tableColumn identifier]];
}
if(indicator == upArrow)
newResources = [oldResources sortedArrayUsingFunction:compareResourcesAscending context:[tableColumn identifier]];
else newResources = [oldResources sortedArrayUsingFunction:compareResourcesDescending context:[tableColumn identifier]];
// swap new array for old one
[(ResourceDataSource *)[tableView dataSource] setResources:[NSMutableArray arrayWithArray:newResources]];
[tableView reloadData];
}
int compareResourcesAscending( Resource *r1, Resource *r2, void *context )
/*!
@function compareResourcesAscending
@updated 2003-10-25 NGS: now uses KVC methods to obtain the strings to compare
*/
int compareResourcesAscending(Resource *r1, Resource *r2, void *context)
{
NSString *key = (NSString *)context;
SEL sel = NSSelectorFromString(key);
if( [key isEqualToString:@"name"] || [key isEqualToString:@"type"] )
{
// compare two NSStrings (case-insensitive)
return [(NSString *)[r1 performSelector:sel] caseInsensitiveCompare: (NSString *)[r2 performSelector:sel]];
}
else
{
// compare two NSNumbers (or any other class)
return [(NSNumber *)[r1 performSelector:sel] compare: (NSNumber *)[r2 performSelector:sel]];
}
// compare two NSStrings (case-insensitive)
if([key isEqualToString:@"name"] || [key isEqualToString:@"type"])
return [(NSString *)[r1 valueForKey:key] caseInsensitiveCompare:(NSString *)[r2 valueForKey:key]];
// compare two NSNumbers (or any other class)
else return [(NSNumber *)[r1 valueForKey:key] compare:(NSNumber *)[r2 valueForKey:key]];
}
int compareResourcesDescending( Resource *r1, Resource *r2, void *context )
/*!
@function compareResourcesDescending
@updated 2003-10-25 NGS: now uses KVC methods to obtain the strings to compare
*/
int compareResourcesDescending(Resource *r1, Resource *r2, void *context)
{
NSString *key = (NSString *)context;
SEL sel = NSSelectorFromString(key);
if( [key isEqualToString:@"name"] || [key isEqualToString:@"type"] )
{
// compare two NSStrings (case-insensitive)
return -1 * [(NSString *)[r1 performSelector:sel] caseInsensitiveCompare: (NSString *)[r2 performSelector:sel]];
}
else
{
// compare two NSNumbers (or any other class)
return -1 * [(NSNumber *)[r1 performSelector:sel] compare: (NSNumber *)[r2 performSelector:sel]];
}
// compare two NSStrings (case-insensitive)
if([key isEqualToString:@"name"] || [key isEqualToString:@"type"])
return -1 * [(NSString *)[r1 valueForKey:key] caseInsensitiveCompare: (NSString *)[r2 valueForKey:key]];
// compare two NSNumbers (or any other class)
else return -1 * [(NSNumber *)[r1 valueForKey:key] compare: (NSNumber *)[r2 valueForKey:key]];
}
- (BOOL)outlineView:(NSOutlineView *)outlineView shouldEditTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
return YES;
if([[tableColumn identifier] isEqualToString:@"size"] || [[tableColumn identifier] isEqualToString:@"attributes"])
return NO;
else return YES;
}
/*!
@method outlineView:willDisplayCell:forTableColumn:item:
@updated 2003-10-25 NGS: Moved functionality of NameFormatter into this method, removed NameFormatter class.
@updated 2003-10-24 NGS: Swapped row colours so first row is white (as per 10.3), conditionalised drawing line background colours to system versions < 10.3, since in 10.3 it is handled by the nib file.
@updated 2003-10-24 NGS: Added iconForResourceType method to app delegate instead of interrogating the cache here.
@pending remove setting of the cell formatter when that capability is in interface builder
*/
- (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
int row = [outlineView rowForItem:item];
Resource *resource = (Resource *)item;
NSString *identifier = [tableColumn identifier];
if( [identifier isEqualToString:@"name"] ) [cell setFormatter:nameFormatter];
else if( [identifier isEqualToString:@"size"] ) [cell setFormatter:sizeFormatter];
else if( [identifier isEqualToString:@"attributes"] ) [cell setFormatter:attributesFormatter];
// set formatters for cells (remove when IB can set a formatter for an entire table column)
if([identifier isEqualToString:@"size"]) [cell setFormatter:sizeFormatter];
else if([identifier isEqualToString:@"attributes"]) [cell setFormatter:attributesFormatter];
// set resource icon
if( [identifier isEqualToString:@"name"] )
if([identifier isEqualToString:@"name"])
{
// [(ResourceNameCell *)cell setImage:[NSImage imageNamed:@"Resource file"]];
// [(ResourceNameCell *)cell setImage:[[NSWorkspace sharedWorkspace] iconForFileType:[(Resource *)item type]]];
[(ResourceNameCell *)cell setImage:[[(ApplicationDelegate *)[NSApp delegate] icons] valueForKey:[(Resource *)item type]]];
if(![resource representedFork])
[(ResourceNameCell *)cell setImage:[(ApplicationDelegate *)[NSApp delegate] iconForResourceType:[resource type]]];
else [(ResourceNameCell *)cell setImage:[(ApplicationDelegate *)[NSApp delegate] iconForResourceType:nil]];
if([[resource name] isEqualToString:@""])
{
if([cell respondsToSelector:@selector(setPlaceholderString:)]) // 10.3+
{
// 10.3+ uses placeholder strings
if([[resource resID] shortValue] == -16455) // don't bother checking type since there are too many icon types
[cell setPlaceholderString:NSLocalizedString(@"Custom Icon", nil)];
else if([[resource type] isEqualToString:@"carb"] && [[resource resID] shortValue] == 0)
[cell setPlaceholderString:NSLocalizedString(@"Carbon Identifier", nil)];
else if([[resource type] isEqualToString:@"pnot"] && [[resource resID] shortValue] == 0)
[cell setPlaceholderString:NSLocalizedString(@"File Preview", nil)];
else if([[resource type] isEqualToString:@"STR "] && [[resource resID] shortValue] == -16396)
[cell setPlaceholderString:NSLocalizedString(@"Creator Information", nil)];
else if([[resource type] isEqualToString:@"vers"] && [[resource resID] shortValue] == 1)
[cell setPlaceholderString:NSLocalizedString(@"File Version", nil)];
else if([[resource type] isEqualToString:@"vers"] && [[resource resID] shortValue] == 2)
[cell setPlaceholderString:NSLocalizedString(@"Package Version", nil)];
else [cell setPlaceholderString:NSLocalizedString(@"Untitled Resource", nil)];
}
else
{
// pre-10.3, set text colour to grey and set title accordingly
if([[resource resID] shortValue] == -16455)
[cell setTitle:NSLocalizedString(@"Custom Icon", nil)];
else if([[resource type] isEqualToString:@"carb"] && [[resource resID] shortValue] == 0)
[cell setTitle:NSLocalizedString(@"Carbon Identifier", nil)];
else if([[resource type] isEqualToString:@"pnot"] && [[resource resID] shortValue] == 0)
[cell setTitle:NSLocalizedString(@"File Preview", nil)];
else if([[resource type] isEqualToString:@"STR "] && [[resource resID] shortValue] == -16396)
[cell setTitle:NSLocalizedString(@"Creator Information", nil)];
else if([[resource type] isEqualToString:@"vers"] && [[resource resID] shortValue] == 1)
[cell setTitle:NSLocalizedString(@"File Version", nil)];
else if([[resource type] isEqualToString:@"vers"] && [[resource resID] shortValue] == 2)
[cell setTitle:NSLocalizedString(@"Package Version", nil)];
else [cell setTitle:NSLocalizedString(@"Untitled Resource", nil)];
// if([[outlineView selectedItems] containsObject:resource])
// [cell setTextColor:[NSColor whiteColor]];
// else [cell setTextColor:[NSColor grayColor]];
}
}
}
if( row % 2 )
// draw alternating blue/white backgrounds (if pre-10.3)
if(NSAppKitVersionNumber < 700.0)
{
[cell setDrawsBackground:NO];
[cell setBackgroundColor:[NSColor whiteColor]];
}
else
{
[cell setDrawsBackground:YES];
[cell setBackgroundColor:[NSColor colorWithCalibratedRed:0.93 green:0.95 blue:1.0 alpha:1.0]];
int row = [outlineView rowForItem:item];
if(row % 2) [cell setBackgroundColor:[NSColor colorWithCalibratedRed:0.93 green:0.95 blue:1.0 alpha:1.0]];
else [cell setBackgroundColor:[NSColor whiteColor]];
[cell setDrawsBackground:YES];
}
}
@end
@implementation NSOutlineView (OutlineSortView)
@implementation RKOutlineView
- (void)swapForOutlineSortView
/*!
@method draggingSourceOperationMaskForLocal:
*/
- (unsigned int)draggingSourceOperationMaskForLocal:(BOOL)local
{
isa = [OutlineSortView class];
if(local) return NSDragOperationEvery;
else return NSDragOperationCopy;
}
@end
@implementation OutlineSortView
- (void)keyDown:(NSEvent *)event
{
if( [self selectedRow] != -1 && [[event characters] isEqualToString:[NSString stringWithCString:"\r"]] )
[self editColumn:0 row:[self selectedRow] withEvent:nil select:YES];
int selectedRow = [self selectedRow];
if(selectedRow != -1 && [[event characters] isEqualToString:[NSString stringWithCString:"\r"]])
[self editColumn:0 row:selectedRow withEvent:nil select:YES];
else if(selectedRow != -1 && [[event characters] isEqualToString:[NSString stringWithCString:"\x7F"]])
[(ResourceDocument *)[[[self window] windowController] document] deleteSelectedResources];
else [super keyDown:event];
}
- (BOOL)textView:(NSTextView *)textView doCommandBySelector:(SEL)selector
{
// pressed return, end editing
if( selector == @selector(insertNewline:) )
if(selector == @selector(insertNewline:))
{
[[self window] makeFirstResponder:self];
[self abortEditing];
@ -126,15 +202,15 @@ int compareResourcesDescending( Resource *r1, Resource *r2, void *context )
}
// pressed tab, move to next editable field
else if( selector == @selector(insertTab:) )
else if(selector == @selector(insertTab:))
{
int newColumn = ([self editedColumn] +1) % [self numberOfColumns];
NSString *newColIdentifier = [[[self tableColumns] objectAtIndex:newColumn] identifier];
if( [newColIdentifier isEqualToString:@"size"] || [newColIdentifier isEqualToString:@"attributes"] )
if([newColIdentifier isEqualToString:@"size"] || [newColIdentifier isEqualToString:@"attributes"])
{
newColumn = (newColumn +1) % [self numberOfColumns];
newColIdentifier = [[[self tableColumns] objectAtIndex:newColumn] identifier];
if( [newColIdentifier isEqualToString:@"size"] || [newColIdentifier isEqualToString:@"attributes"] )
if([newColIdentifier isEqualToString:@"size"] || [newColIdentifier isEqualToString:@"attributes"])
newColumn = (newColumn +1) % [self numberOfColumns];
}
@ -143,15 +219,15 @@ int compareResourcesDescending( Resource *r1, Resource *r2, void *context )
}
// pressed shift-tab, move to previous editable field
else if( selector == @selector(insertBacktab:) )
else if(selector == @selector(insertBacktab:))
{
int newColumn = ([self editedColumn] + [self numberOfColumns] -1) % [self numberOfColumns];
NSString *newColIdentifier = [[[self tableColumns] objectAtIndex:newColumn] identifier];
if( [newColIdentifier isEqualToString:@"size"] || [newColIdentifier isEqualToString:@"attributes"] )
if([newColIdentifier isEqualToString:@"size"] || [newColIdentifier isEqualToString:@"attributes"])
{
newColumn = (newColumn + [self numberOfColumns] -1) % [self numberOfColumns];
newColIdentifier = [[[self tableColumns] objectAtIndex:newColumn] identifier];
if( [newColIdentifier isEqualToString:@"size"] || [newColIdentifier isEqualToString:@"attributes"] )
if([newColIdentifier isEqualToString:@"size"] || [newColIdentifier isEqualToString:@"attributes"])
newColumn = (newColumn + [self numberOfColumns] -1) % [self numberOfColumns];
}
@ -162,42 +238,43 @@ int compareResourcesDescending( Resource *r1, Resource *r2, void *context )
return NO;
}
/*!
@method _sendDelegateDidClickColumn:
@pending not needed in 10.3+, use existing sort functionality
*/
//- (void)_sendDelegateDidMouseDownInHeader:(int)columnIndex
- (void)_sendDelegateDidClickColumn:(int)columnIndex
{
NSTableColumn *tableColumn = [[self tableColumns] objectAtIndex:columnIndex];
NSImage *indicator = [self indicatorImageInTableColumn:tableColumn];
NSImage *upArrow = [NSTableView _defaultTableHeaderSortImage];
NSImage *downArrow = [NSTableView _defaultTableHeaderReverseSortImage];
if( indicator )
// if(NSAppKitVersionNumber < 700.0)
{
// column already selected
if( indicator == upArrow )
[self setIndicatorImage:downArrow inTableColumn:tableColumn];
else [self setIndicatorImage:upArrow inTableColumn:tableColumn];
}
else
{
// new column selected
if( [self highlightedTableColumn] != nil )
NSTableColumn *tableColumn = [[self tableColumns] objectAtIndex:columnIndex];
NSImage *indicator = [self indicatorImageInTableColumn:tableColumn];
NSImage *upArrow = [NSTableView _defaultTableHeaderSortImage];
NSImage *downArrow = [NSTableView _defaultTableHeaderReverseSortImage];
if(indicator)
{
// column already selected
if(indicator == upArrow)
[self setIndicatorImage:downArrow inTableColumn:tableColumn];
else [self setIndicatorImage:upArrow inTableColumn:tableColumn];
}
else // new column selected
{
// if there is an existing selection, clear it's image
[self setIndicatorImage:nil inTableColumn:[self highlightedTableColumn]];
}
if( [[tableColumn identifier] isEqualToString:@"name"] || [[tableColumn identifier] isEqualToString:@"type"] )
{
if([self highlightedTableColumn] != nil)
[self setIndicatorImage:nil inTableColumn:[self highlightedTableColumn]];
// sort name and type columns ascending by default
[self setIndicatorImage:upArrow inTableColumn:tableColumn];
}
else
{
if([[tableColumn identifier] isEqualToString:@"name"] || [[tableColumn identifier] isEqualToString:@"type"])
[self setIndicatorImage:upArrow inTableColumn:tableColumn];
// sort all other columns descending by default
[self setIndicatorImage:downArrow inTableColumn:tableColumn];
else [self setIndicatorImage:downArrow inTableColumn:tableColumn];
[self setHighlightedTableColumn:tableColumn];
}
[self setHighlightedTableColumn:tableColumn];
[[self delegate] tableView:self didClickTableColumn:tableColumn];
}
[[self delegate] tableView:self didClickTableColumn:tableColumn];
// else [super _sendDelegateDidClickColumn:columnIndex];
}
@end

View File

@ -3,7 +3,7 @@
@interface PasteboardDocument : ResourceDocument
{
unsigned long generalChangeCount; // change count for the general pasteboard
int generalChangeCount; // change count for the general pasteboard
}
- (void)readPasteboard:(NSString *)pbName;

View File

@ -1,6 +1,8 @@
#import "PasteboardDocument.h"
#import "Resource.h"
extern NSString *RKResourcePboardType;
@implementation PasteboardDocument
- (id)init
@ -13,35 +15,51 @@
return self;
}
- (void)readPasteboard:(NSString *)pbName
-(void)readPasteboard:(NSString *)pbName
{
// this method is mostly a duplicate of -[ResourceDocument paste:] but takes a pasteboard name for an argument
NSPasteboard *pb = [NSPasteboard pasteboardWithName:pbName];
NSArray *types = [pb types];
NSEnumerator *enumerator = [types objectEnumerator];
NSString *currentType;
NSEnumerator *enumerator = [[pb types] objectEnumerator];
NSString *pbType;
// clear current pasteboard representation
[self selectAll:nil];
[self clear:nil];
// set the window's title to represent the pasteboard being shown (at some point I anticipate having several of these)
[[self window] setTitle:pbName];
// disable undos during loading
[[self undoManager] disableUndoRegistration];
while( currentType = [enumerator nextObject] )
// get all types off the pasteboard
while( pbType = [enumerator nextObject] )
{
// create the resource & add it to the array
NSString *name = pbName;
NSString *type;
NSNumber *resID;
NSNumber *attributes;
NSData *data;
Resource *resource;
NS_DURING
type = [currentType substringToIndex:3];
NS_HANDLER
type = currentType;
NS_ENDHANDLER
resID = [NSNumber numberWithShort:0];
attributes = [NSNumber numberWithShort:0];
data = [pb dataForType:type];
resource = [Resource resourceOfType:type andID:resID withName:name andAttributes:attributes data:data];
[resources addObject:resource]; // array retains resource
// 'paste' any resources into pbdoc's data source
if( [pbType isEqualToString:RKResourcePboardType] )
[self pasteResources:[NSUnarchiver unarchiveObjectWithData:[pb dataForType:RKResourcePboardType]]];
else
{
// create the faux resource & add it to the array
Resource *resource = [Resource resourceOfType:nil andID:nil withName:pbType andAttributes:nil data:[pb dataForType:pbType]];
[resources addObject:resource]; // array retains resource
}
}
// re-enable undos
[[self undoManager] enableUndoRegistration];
[outlineView reloadData];
}
-(void)windowDidBecomeKey:(NSNotification *)notification
{
// This mess sponsored by Uli Kusterer ;-)
generalChangeCount = [[NSPasteboard generalPasteboard] changeCount];
[resources removeAllObjects];
[self readPasteboard:NSGeneralPboard]; // Update window contents.
}
@end

View File

@ -13,7 +13,9 @@
{
static PasteboardWindowController *sharedPasteboardWindowController = nil;
if( !sharedPasteboardWindowController )
{
sharedPasteboardWindowController = [[PasteboardWindowController allocWithZone:[self zone]] init];
}
return sharedPasteboardWindowController;
}

View File

@ -31,10 +31,3 @@ enum LaunchAction
+ (id)sharedPrefsWindowController;
@end
@interface NSString (BooleanSupport)
- (BOOL)boolValue;
+ (NSString *)stringWithBool:(BOOL)boolean;
@end

View File

@ -4,9 +4,7 @@
- (id)init
{
self = [self initWithWindowNibName:@"PrefsWindow"];
if( self ) [self setWindowFrameAutosaveName:@"ResKnife Preferences"];
return self;
return [self initWithWindowNibName:@"PrefsWindow"];
}
- (void)dealloc
@ -19,6 +17,7 @@
{
// represent current prefs in window state
[self updatePrefs:nil];
[[self window] center];
// listen out for pref changes from elsewhere
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updatePrefs:) name:NSUserDefaultsDidChangeNotification object:nil];
@ -63,8 +62,8 @@
[defaults setBool:autosave forKey:@"Autosave"];
[defaults setInteger:autosaveInterval forKey:@"AutosaveInterval"];
[defaults setBool:deleteResourceWarning forKey:@"DeleteResourceWarning"];
if( createNewDocument ) [defaults setObject:@"OpenUntitledFile" forKey:@"LaunchAction"];
else if( displayOpenPanel ) [defaults setObject:@"DisplayOpenPanel" forKey:@"LaunchAction"];
if(createNewDocument) [defaults setObject:@"OpenUntitledFile" forKey:@"LaunchAction"];
else if(displayOpenPanel) [defaults setObject:@"DisplayOpenPanel" forKey:@"LaunchAction"];
else [defaults setObject:@"None" forKey:@"LaunchAction"];
[defaults synchronize];
}
@ -101,26 +100,9 @@
+ (id)sharedPrefsWindowController
{
static PrefsWindowController *sharedPrefsWindowController = nil;
if( !sharedPrefsWindowController )
{
sharedPrefsWindowController = [[PrefsWindowController allocWithZone:[self zone]] init];
}
return sharedPrefsWindowController;
}
@end
@implementation NSString (BooleanSupport)
- (BOOL)boolValue
{
return [self isEqualToString:@"YES"];
}
+ (NSString *)stringWithBool:(BOOL)boolean
{
return boolean? @"YES" : @"NO";
}
@end

View File

@ -1,29 +1,26 @@
#import "RKDocumentController.h"
#import "ApplicationDelegate.h"
#import "OpenFileDataSource.h"
#import "OpenPanelDelegate.h"
@implementation RKDocumentController
// because I swap the isa pointer I can't add instance variables, so use statics instead (there will only ever be one RKDocumentController)
static id oldDelegate = nil;
- (id)init
{
self = [super init];
if( self )
{
// for some reason calling -[super init] causes a new instance of self to be returned (which is not of my subclass) so to get my overridden methods called again, I have to do this...
isa = [RKDocumentController class];
oldDelegate = [[NSOpenPanel openPanel] delegate];
[[NSOpenPanel openPanel] setDelegate:[[[OpenPanelDelegate alloc] init] autorelease]];
}
return self;
}
- (int)runModalOpenPanel:(NSOpenPanel *)openPanel forTypes:(NSArray *)extensions
{
[openPanel setAccessoryView:[(ApplicationDelegate *)[NSApp delegate] openAuxView]];
return [super runModalOpenPanel:openPanel forTypes:extensions];
// set-up open panel (this happens every time, but no harm done)
ApplicationDelegate *appDelegate = [NSApp delegate];
OpenPanelDelegate *openPanelDelegate = [appDelegate openPanelDelegate];
NSView *openPanelAccessoryView = [openPanelDelegate openPanelAccessoryView];
[openPanel setDelegate:openPanelDelegate];
[openPanel setAccessoryView:openPanelAccessoryView];
[openPanel setAllowsOtherFileTypes:YES];
[openPanel setTreatsFilePackagesAsDirectories:YES];
[openPanelAccessoryView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
// run panel
int button = [super runModalOpenPanel:openPanel forTypes:extensions];
if(button == NSOKButton)
[openPanelDelegate setReadOpenPanelForFork:YES];
return button;
}
@end

View File

@ -32,13 +32,12 @@
@interface RKEditorRegistry : NSObject
{
NSMutableDictionary* typeRegistry; // Private. Use editorForType: to access this.
@private
NSMutableDictionary *typeRegistry;
}
+(RKEditorRegistry*) mainRegistry; // There's usually only one object, and this returns or creates it.
-(IBAction) scanForPlugins: (id)sender; // Called automatically by mainRegistry.
-(Class) editorForType: (NSString*)typeStr; // You probably want to call this.
+ (RKEditorRegistry *)defaultRegistry; // There's usually only one object, and this returns or creates it.
- (IBAction)scanForPlugins:(id)sender; // Called automatically by mainRegistry.
- (Class)editorForType:(NSString *)typeStr; // You probably want to call this.
@end

View File

@ -22,134 +22,159 @@
-------------------------------------------------------------------------- */
#import "RKEditorRegistry.h"
#import "RKSupportResourceRegistry.h"
#import "NSString-FSSpec.h" // for ResKnifeBoolExtensions (in wrong file)
/* -----------------------------------------------------------------------------
Globals:
-------------------------------------------------------------------------- */
RKEditorRegistry* gRKEditorRegistryMainRegistry = nil; // Access through +mainRegistry!
/*!
@class RKEditorRegistry
@author Uli Kusterer
@created 2003-07-31
@description This is a registry where all our resource-editor plugins are looked
up and entered in a list, so you can ask for the editor for a specific
resource type and it is returned immediately. This registry reads the
types a plugin handles from their info.plist. This is better than
encoding the type in the plugin file name, as file names are not
guaranteed to be on a case-sensitive file system on Mac, and this also
allows an editor to register for several resource types.
*/
@implementation RKEditorRegistry
/* -----------------------------------------------------------------------------
mainRegistry:
Returns the main plugin registry of this application, instantiating
it first if there is none yet. As soon as this is instantiated, the
plugins are loaded.
REVISIONS:
2003-07-31 UK Created.
-------------------------------------------------------------------------- */
+(RKEditorRegistry*) mainRegistry
/*!
@method +defaultRegistry
@author Uli Kusterer
@created 2003-07-31
@updated 2003-10-28 NGS: Changed method name from +mainRegistry (so it more closly matchs +defaultCenter) and moved global var inside method, making it a static.
@description Returns the default plugin registry of this application, instantiating it first if there is none yet. As soon as this is instantiated, the plugins are loaded.
*/
+ (RKEditorRegistry *)defaultRegistry
{
if( !gRKEditorRegistryMainRegistry )
static RKEditorRegistry *defaultRegistry = nil;
if(!defaultRegistry)
{
gRKEditorRegistryMainRegistry = [[RKEditorRegistry alloc] init];
[gRKEditorRegistryMainRegistry scanForPlugins: gRKEditorRegistryMainRegistry];
defaultRegistry = [[RKEditorRegistry alloc] init];
[defaultRegistry scanForPlugins:nil];
}
return gRKEditorRegistryMainRegistry;
return defaultRegistry;
}
/* -----------------------------------------------------------------------------
awakeFromNib:
Makes sure that if an instance of this is instantiated from a NIB file,
it automatically loads the plugins.
REVISIONS:
2003-07-31 UK Created.
-------------------------------------------------------------------------- */
-(void) awakeFromNib
/*!
@method awakeFromNib
@abstract Makes sure that if an instance of this is instantiated from a nib file, it automatically loads the plugins.
@author Uli Kusterer
@created 2003-07-31
*/
- (void)awakeFromNib
{
[self scanForPlugins: self];
[self scanForPlugins:nil];
}
/*!
@method scanForPlugins:
@abstract (Re)loads our list of plugins. You can use this as an action for a menu item, if you want.
@author Uli Kusterer
@created 2003-07-31
@updated 2003-10-28 NGS: Updated to look for more sophisticated RKSupportedTypes key in addition to (the now deprecated) RKEditedTypes.
@pending Use NSSearchPathForDirectoriesInDomains() or equivalent to get folder paths instead of hard coding them.
@pending Currently, Cocoa classes can't be unloaded, which means we're
not leaking the NSBundles we load here. However, if this one
day shouldn't hold true anymore, we'll want to retain these
bundles in our dictionary and do the principalClass thingie
in editorForType: instead, which allows us to get rid of the
class and its bundle when reloading the plugin list by simply
relying on NSMutableDictionary to release it.
/* -----------------------------------------------------------------------------
scanForPlugins:
(Re)loads our list of plugins. You can use this as an action for a menu
item, if you want.
This scans the application's internal Plugins folder,
~/Library/Application Support/ResKnife/Plugins/ and
/Library/Application Support/ResKnife/Plugins/ for plugins that have
the extension ".plugin" and implement initWithResource: (which means
this won't get into the way if you want to support other kinds of
plugins).
It builds a registry of Class objects in an NSMutableDictionary, where
the key is the resource type. If a plugin supports several resource
types (as indicated by the RKEditedTypes key in its Info.plist), it
will be registered for these types as well. If several plugins register
for the same type, the last one loaded wins.
To instantiate an object from a plugin, see the method below.
TODO:
Currently, Cocoa classes can't be unloaded, which means we're not
leaking the NSBundles we load here. However, if this one day shouldn't
hold true anymore, we'll want to retain these bundles in our dictionary
and do the principalClass thingie in editorForType: instead, which
allows us to get rid of the class and its bundle when reloading the
plugin list by simply relying on NSMutableDictionary to release it.
REVISIONS:
2003-07-31 UK Created.
-------------------------------------------------------------------------- */
-(IBAction) scanForPlugins: (id)sender
@description This scans the application's internal Plugins folder,
<tt>~/Library/Application Support/ResKnife/Plugins/</tt> and
<tt>/Library/Application Support/ResKnife/Plugins/</tt> for
plugins that have the extension ".plugin" and implement
<tt>initWithResource:</tt> (which means this won't get into
the way if you want to support other kinds of plugins).</p>
<p>It builds a registry of Class objects in an NSMutableDictionary,
where the key is the resource type. If a plugin supports several
resource types (as indicated by the RKEditedTypes key in it's
Info.plist), it will be registered for these types as well.
If several plugins register for the same type, the last one
loaded wins.</p>
<p>To instantiate an object from a plugin, see <tt>editorForType:</tt>
*/
- (IBAction)scanForPlugins:(id)sender
{
// TODO: Instead of hard-coding sysPath we should use some FindFolder-like API!
Class pluginClass;
NSString *appSupport = @"Library/Application Support/ResKnife/Plugins/";
NSString *appPath = [[NSBundle mainBundle] builtInPlugInsPath];
NSString *userPath = [NSHomeDirectory() stringByAppendingPathComponent:appSupport];
NSString *sysPath = [@"/" stringByAppendingPathComponent:appSupport];
NSArray *paths = [NSArray arrayWithObjects:appPath, userPath, sysPath, nil];
NSEnumerator *pathEnum = [paths objectEnumerator];
// NSArray *paths = NSSearchPathForDirectoriesInDomains(NSAllLibrariesDirectory, NSAllDomainsMask, YES);
NSEnumerator *pathEnumerator = [[NSArray arrayWithObjects:appPath, userPath, sysPath, nil] objectEnumerator];
NSString *path;
if( typeRegistry )
[typeRegistry release];
// release any existing registry to clear old values
if(typeRegistry) [typeRegistry release];
typeRegistry = [[NSMutableDictionary alloc] init];
while( path = [pathEnum nextObject] )
// scan all paths
while(path = [pathEnumerator nextObject])
{
NSEnumerator *e = [[[NSFileManager defaultManager] directoryContentsAtPath:path] objectEnumerator];
NSString *name;
NSEnumerator *fileEnumerator = [[[NSFileManager defaultManager] directoryContentsAtPath:path] objectEnumerator];
NSString *pluginName;
NSLog(@"Looking for plugins at %@", path);
while( name = [e nextObject] )
// enumerate all files in this directory
while(pluginName = [fileEnumerator nextObject])
{
name = [path stringByAppendingPathComponent:name];
NSLog(@"Examining %@", name);
if( [[name pathExtension] isEqualToString:@"plugin"] )
NSString *pluginPath = [path stringByAppendingPathComponent:pluginName];
// NSLog(@"Examining %@", pluginPath);
// verify file is a plugin
if([[pluginName pathExtension] isEqualToString:@"plugin"])
{
NSBundle *plugin = [NSBundle bundleWithPath: name];
NSLog(@"Identifier %@", [plugin bundleIdentifier]);
if( pluginClass = [plugin principalClass] )
NSBundle *plugin = [NSBundle bundleWithPath:pluginPath];
Class pluginClass = [plugin principalClass];
if(plugin && pluginClass)
{
NSLog(@"Found plugin: %@", name);
if( [pluginClass instancesRespondToSelector:@selector(initWithResource:)] )
// NSLog(@"Principal class %@ %@ to ResKnifePluginProtocol", NSStringFromClass(pluginClass), [pluginClass conformsToProtocol:@protocol(ResKnifePluginProtocol)]? @"conforms":@"does not conform");
// check principal class implements ResKnifePluginProtocol
if([pluginClass conformsToProtocol:@protocol(ResKnifePluginProtocol)])
{
NSString *resType;
NSArray *types = [[plugin infoDictionary] objectForKey:@"RKEditedTypes"];
NSEnumerator *enny;
if( types == nil )
types = [NSArray arrayWithObject: [[plugin infoDictionary] objectForKey:@"RKEditedType"]];
for( enny = [types objectEnumerator]; resType = [enny nextObject]; )
NSArray *supportedTypes = [[plugin infoDictionary] objectForKey:@"RKSupportedTypes"];
if(supportedTypes)
{
[typeRegistry setObject:pluginClass forKey:resType];
NSLog(@"Registered for type %@.",resType);
NSDictionary *typeEntry;
NSEnumerator *typesEnumerator = [supportedTypes objectEnumerator];
// enumerate entries
while(typeEntry = [typesEnumerator nextObject])
{
// get values for type entry
NSString *name = [typeEntry objectForKey:@"RKTypeName"];
// NSString *role = [typeEntry objectForKey:@"RKTypeRole"];
// BOOL isDefault = [(NSString *)[typeEntry objectForKey:@"IsResKnifeDefaultForType"] boolValue];
// register them
[typeRegistry setObject:pluginClass forKey:name]; // bug: very primative, doesn't use extra data
// NSLog(@"Plug-in class %@ registered as %@%@ for type %@.", NSStringFromClass(pluginClass), isDefault? @"default ":@"", role, name);
}
}
else
{
// try the old way of looking up types
NSString *resType;
NSEnumerator *enny;
supportedTypes = [[plugin infoDictionary] objectForKey:@"RKEditedTypes"];
if(supportedTypes == nil)
supportedTypes = [NSArray arrayWithObject: [[plugin infoDictionary] objectForKey:@"RKEditedType"]];
for(enny = [supportedTypes objectEnumerator]; resType = [enny nextObject];)
{
[typeRegistry setObject:pluginClass forKey:resType];
// NSLog(@"Registered for type %@.",resType);
}
}
// load any support resources in the plug-in
[RKSupportResourceRegistry scanForSupportResourcesInFolder:[[plugin resourcePath] stringByAppendingPathComponent:@"Support Resources"]];
}
}
}
@ -173,13 +198,11 @@ RKEditorRegistry* gRKEditorRegistryMainRegistry = nil; // Access through +mainR
2003-07-31 UK Created.
-------------------------------------------------------------------------- */
-(Class) editorForType: (NSString*)typeStr
- (Class)editorForType:(NSString *)typeStr
{
Class theClass = [typeRegistry objectForKey: typeStr];
if( !theClass )
return Nil;
return theClass;
Class theClass = [typeRegistry objectForKey: typeStr];
if(!theClass) return Nil;
else return theClass;
}
@end

View File

@ -0,0 +1,17 @@
//
// RKSupportResourceRegistry.h
// ResKnife
//
// Created by Uli Kusterer on Mon Aug 18 2003.
// Copyright (c) 2003 __MyCompanyName__. All rights reserved.
//
#import <AppKit/AppKit.h>
@interface RKSupportResourceRegistry : NSObject
{
}
+ (void)scanForSupportResources;
+ (void)scanForSupportResourcesInFolder:(NSString *)path;
@end

View File

@ -0,0 +1,33 @@
#import "RKSupportResourceRegistry.h"
#import "../Categories/NGSCategories.h"
@implementation RKSupportResourceRegistry
+ (void)scanForSupportResources
{
#if MAC_OS_X_VERSION_10_4 <= MAC_OS_X_VERSION_MAX_ALLOWED
NSArray *dirsArray = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSAllDomainsMask, YES);
dirsArray = [dirsArray arrayByMakingObjectsPerformSelector:@selector(stringByAppendingPathComponent:) withObject:@"ResKnife/Support Resources"];
// FIXME: log content of dirsArray and merge with the following:
#endif
[RKSupportResourceRegistry scanForSupportResourcesInFolder:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Support Resources"]];
[RKSupportResourceRegistry scanForSupportResourcesInFolder:[NSHomeDirectory() stringByAppendingPathComponent:@"Library/Application Support/ResKnife/Support Resources"]];
[RKSupportResourceRegistry scanForSupportResourcesInFolder:@"/Library/Application Support/ResKnife/Support Resources"];
[RKSupportResourceRegistry scanForSupportResourcesInFolder:@"/Network/Library/Application Support/ResKnife/Support Resources"];
}
+ (void)scanForSupportResourcesInFolder:(NSString *)path
{
// NSLog(@"Looking for resources in %@", path);
NSString *name;
NSEnumerator *enumerator = [[[NSFileManager defaultManager] directoryContentsAtPath:path] objectEnumerator];
while(name = [enumerator nextObject])
{
// NSLog(@"Examining %@", name);
if([[name pathExtension] isEqualToString:@"rsrc"])
// FIXME: this method was deprecated in 10.4 in favour of - (id)openDocumentWithContentsOfURL:(NSURL *)absoluteURL display:(BOOL)displayDocument error:(NSError **)outError;
[[NSDocumentController sharedDocumentController] openDocumentWithContentsOfFile:[path stringByAppendingPathComponent:name] display:YES];
}
}
@end

View File

@ -1,5 +1,12 @@
#import <Foundation/Foundation.h>
#import "ResKnifeResourceProtocol.h"
#import "../Plug-Ins/ResKnifeResourceProtocol.h"
/*!
@class Resource
@author Nicholas Shanks
@abstract Encapsulates a single resource and all associated meta-data.
@description The Resource class fully complies with key-value coding, with the keys @"name", @"type", @"resID", @"attributes", @"data", @"dirty" and @"representedFork" available.
*/
@interface Resource : NSObject <NSCopying, NSCoding, ResKnifeResourceProtocol>
{
@ -17,13 +24,16 @@
// the actual data
NSData *data;
NSDocument *document; // Our owner.
// the document name for display to the user; updating this is the responsibility of the document itself
NSString *_docName;
}
// accessor methods not part of the protocol
- (void)_setName:(NSString *)newName;
- (void)setDirty:(BOOL)newValue;
- (NSString *)representedFork;
- (void)setRepresentedFork:(NSString *)forkName;
- (void)setDocumentName:(NSString *)docName;
// init methods
- (id)initWithType:(NSString *)typeValue andID:(NSNumber *)resIDValue;
@ -35,7 +45,4 @@
+ (id)resourceOfType:(NSString *)typeValue andID:(NSNumber *)resIDValue withName:(NSString *)nameValue andAttributes:(NSNumber *)attributesValue;
+ (id)resourceOfType:(NSString *)typeValue andID:(NSNumber *)resIDValue withName:(NSString *)nameValue andAttributes:(NSNumber *)attributesValue data:(NSData *)dataValue;
-(void) setDocument: (NSDocument*)doc;
-(NSDocument*) document; // Resource protocol guarantees this.
@end

View File

@ -2,7 +2,7 @@
#import "ResourceDocument.h"
#import "ResourceDataSource.h"
NSString *RKResourcePboardType = @"RKResourcePboardType";
NSString *RKResourcePboardType = @"RKResourcePboardType";
@implementation Resource
@ -58,17 +58,17 @@ NSString *RKResourcePboardType = @"RKResourcePboardType";
return [resource autorelease];
}
+ (Resource *)getResourceOfType:(NSString *)typeValue andID:(NSNumber *)resIDValue inDocument:(NSDocument *)document
+ (Resource *)getResourceOfType:(NSString *)typeValue andID:(NSNumber *)resIDValue inDocument:(NSDocument *)searchDoc
{
NSDocument *doc;
NSEnumerator *enumerator = [[[NSDocumentController sharedDocumentController] documents] objectEnumerator];
while( doc = [enumerator nextObject] )
while(doc = [enumerator nextObject])
{
if( document == nil || document == doc )
if(searchDoc == nil || searchDoc == doc)
{
// parse document for correct resource
Resource *resource = [[(ResourceDocument *)doc dataSource] resourceOfType:typeValue andID:resIDValue];
if( resource ) return resource;
if(resource) return resource;
}
}
return nil;
@ -76,47 +76,65 @@ NSString *RKResourcePboardType = @"RKResourcePboardType";
/* ResKnifeResourceProtocol implementation */
+ (NSArray *)allResourcesOfType:(NSString *)typeValue inDocument:(NSDocument *)document
+ (NSArray *)allResourcesOfType:(NSString *)typeValue inDocument:(NSDocument *)searchDoc
{
NSMutableArray *array = [NSMutableArray array];
NSDocument *doc;
NSEnumerator *enumerator = [[[NSDocumentController sharedDocumentController] documents] objectEnumerator];
while( doc = [enumerator nextObject] )
while(doc = [enumerator nextObject])
{
// parse document for resources
if( document == nil || document == doc )
if(searchDoc == nil || searchDoc == doc)
[array addObjectsFromArray:[[(ResourceDocument *)doc dataSource] allResourcesOfType:typeValue]];
}
return [NSArray arrayWithArray:array];
}
+ (Resource *)resourceOfType:(NSString *)typeValue withName:(NSString *)nameValue inDocument:(NSDocument *)document
+ (Resource *)resourceOfType:(NSString *)typeValue withName:(NSString *)nameValue inDocument:(NSDocument *)searchDoc
{
NSDocument *doc;
NSEnumerator *enumerator = [[[NSDocumentController sharedDocumentController] documents] objectEnumerator];
while( doc = [enumerator nextObject] )
while(doc = [enumerator nextObject])
{
if( document == nil || document == doc )
if(searchDoc == nil || searchDoc == doc)
{
// parse document for correct resource
Resource *resource = [[(ResourceDocument *)doc dataSource] resourceOfType:typeValue withName:nameValue];
if( resource ) return resource;
if(resource) return resource;
}
}
return nil;
}
+ (id)resourceOfType:(NSString *)typeValue andID:(NSNumber *)resIDValue inDocument:(NSDocument *)document
+ (Resource *)resourceOfType:(NSString *)typeValue andID:(NSNumber *)resIDValue inDocument:(NSDocument *)searchDoc
{
NSDocument *doc;
NSEnumerator *enumerator = [[[NSDocumentController sharedDocumentController] documents] objectEnumerator];
while( doc = [enumerator nextObject] )
while(doc = [enumerator nextObject])
{
if( document == nil || document == doc )
if(searchDoc == nil || searchDoc == doc)
{
// parse document for correct resource
Resource *resource = [[(ResourceDocument *)doc dataSource] resourceOfType:typeValue andID:resIDValue];
if( resource ) return resource;
if(resource) return resource;
}
}
return nil;
}
// should probably be in resource document, not resource, but it fits in with the above methods quite well
+ (NSDocument *)documentForResource:(Resource *)resource
{
NSDocument *doc;
NSEnumerator *enumerator = [[[NSDocumentController sharedDocumentController] documents] objectEnumerator];
while(doc = [enumerator nextObject])
{
Resource *res;
NSEnumerator *enumerator2 = [[(ResourceDocument *)doc resources] objectEnumerator];
while(res = [enumerator2 nextObject])
{
if([res isEqual:resource])
return doc;
}
}
return nil;
@ -130,16 +148,18 @@ NSString *RKResourcePboardType = @"RKResourcePboardType";
[resID release];
[attributes release];
[data release];
[_docName release];
[super dealloc];
}
- (id)copyWithZone:(NSZone *)zone
{
Resource *copy = [[Resource alloc] initWithType:type andID:resID withName:name andAttributes:attributes data:[data copy]];
[copy setDocumentName:_docName];
return copy;
}
/* Accessors */
/* accessors */
- (void)touch
{
@ -157,19 +177,16 @@ NSString *RKResourcePboardType = @"RKResourcePboardType";
[[NSNotificationCenter defaultCenter] postNotificationName:ResourceDidChangeNotification object:self];
}
-(void) setDocument: (NSDocument*)doc
- (NSDocument *)document
{
document = doc; // It owns us, so don't retain, or we could get a closed loop!
return [Resource documentForResource:self];
}
-(NSDocument*) document
- (void)setDocumentName:(NSString *)docName
{
return document;
_docName = [docName copy];
}
- (NSString *)representedFork
{
return representedFork;
@ -185,31 +202,37 @@ NSString *RKResourcePboardType = @"RKResourcePboardType";
return name;
}
// shouldn't need this - it's used by forks to give them alternate names - should use name formatter replacement instead
- (void)_setName:(NSString *)newName
{
id old = name;
name = [newName copy];
[old release];
}
- (void)setName:(NSString *)newName
{
if( ![name isEqualToString:newName] )
if(![name isEqualToString:newName])
{
[[NSNotificationCenter defaultCenter] postNotificationName:ResourceWillChangeNotification object:self];
[[NSNotificationCenter defaultCenter] postNotificationName:ResourceNameWillChangeNotification object:self];
[name autorelease];
id old = name;
name = [newName copy];
[old release];
[[NSNotificationCenter defaultCenter] postNotificationName:ResourceNameDidChangeNotification object:self];
// bug: this line is causing crashes!
// [[NSNotificationCenter defaultCenter] postNotificationName:ResourceNameDidChangeNotification object:self];
[self setDirty:YES];
}
}
-(NSString*) nameForEditorWindow
- (NSString *)defaultWindowTitle
{
if( [name length] > 0 )
return [NSString stringWithFormat: @"%@: '%@' ID=%@ \"%@\"", [document displayName], type, resID, name];
else
return [NSString stringWithFormat: @"%@: '%@' ID=%@", [document displayName], type, resID];
if([name length] > 0) return [NSString stringWithFormat: NSLocalizedString(@"%@: %@ %@ '%@'", @"default window title format with resource name"), _docName, type, resID, name];
else return [NSString stringWithFormat: NSLocalizedString(@"%@: %@ %@", @"default window title format without resource name"), _docName, type, resID];
}
- (NSString *)type
{
return type;
@ -217,15 +240,17 @@ NSString *RKResourcePboardType = @"RKResourcePboardType";
- (void)setType:(NSString *)newType
{
if( ![type isEqualToString:newType] )
if(![type isEqualToString:newType])
{
[[NSNotificationCenter defaultCenter] postNotificationName:ResourceWillChangeNotification object:self];
[[NSNotificationCenter defaultCenter] postNotificationName:ResourceTypeWillChangeNotification object:self];
[type autorelease];
id old = type;
type = [newType copy];
[old release];
[[NSNotificationCenter defaultCenter] postNotificationName:ResourceTypeDidChangeNotification object:self];
// bug: this line is causing crashes!
// [[NSNotificationCenter defaultCenter] postNotificationName:ResourceTypeDidChangeNotification object:self];
[self setDirty:YES];
}
}
@ -237,15 +262,17 @@ NSString *RKResourcePboardType = @"RKResourcePboardType";
- (void)setResID:(NSNumber *)newResID
{
if( ![resID isEqualToNumber:newResID] )
if(![resID isEqualToNumber:newResID])
{
[[NSNotificationCenter defaultCenter] postNotificationName:ResourceWillChangeNotification object:self];
[[NSNotificationCenter defaultCenter] postNotificationName:ResourceIDWillChangeNotification object:self];
[resID autorelease];
id old = resID;
resID = [newResID copy];
[old release];
[[NSNotificationCenter defaultCenter] postNotificationName:ResourceIDDidChangeNotification object:self];
// bug: this line is causing crashes!
// [[NSNotificationCenter defaultCenter] postNotificationName:ResourceIDDidChangeNotification object:self];
[self setDirty:YES];
}
}
@ -257,15 +284,17 @@ NSString *RKResourcePboardType = @"RKResourcePboardType";
- (void)setAttributes:(NSNumber *)newAttributes
{
if( ![attributes isEqualToNumber:newAttributes] )
if(![attributes isEqualToNumber:newAttributes])
{
[[NSNotificationCenter defaultCenter] postNotificationName:ResourceWillChangeNotification object:self];
[[NSNotificationCenter defaultCenter] postNotificationName:ResourceAttributesWillChangeNotification object:self];
[attributes autorelease];
id old = attributes;
attributes = [newAttributes copy];
[old release];
[[NSNotificationCenter defaultCenter] postNotificationName:ResourceAttributesDidChangeNotification object:self];
// bug: this line is causing crashes!
// [[NSNotificationCenter defaultCenter] postNotificationName:ResourceAttributesDidChangeNotification object:self];
[self setDirty:YES];
}
}
@ -282,14 +311,15 @@ NSString *RKResourcePboardType = @"RKResourcePboardType";
- (void)setData:(NSData *)newData
{
if( ![data isEqualToData:newData] )
if(![data isEqualToData:newData])
{
[[NSNotificationCenter defaultCenter] postNotificationName:ResourceWillChangeNotification object:self];
[[NSNotificationCenter defaultCenter] postNotificationName:ResourceDataWillChangeNotification object:self];
// note: this function retains, rather than copies, the supplied data
[data autorelease];
id old = data;
data = [newData retain];
[old release];
[[NSNotificationCenter defaultCenter] postNotificationName:ResourceDataDidChangeNotification object:self];
[self setDirty:YES];
@ -301,7 +331,7 @@ NSString *RKResourcePboardType = @"RKResourcePboardType";
- (id)initWithCoder:(NSCoder *)decoder
{
self = [super init];
if( self )
if(self)
{
dirty = YES;
name = [[decoder decodeObject] retain];

View File

@ -2,6 +2,11 @@
@class ResourceDocument, Resource;
/*!
@class ResourceDataSource
@pending This class needs to be made KVC compliant.
*/
@interface ResourceDataSource : NSObject
{
IBOutlet NSOutlineView *outlineView;
@ -11,18 +16,59 @@
NSMutableArray *resources;
}
/*!
@method window
*/
- (NSWindow *)window;
/*!
@method resources
*/
- (NSArray *)resources;
/*!
@method setResources:
*/
- (void)setResources:(NSMutableArray *)newResources;
/*!
@method addResource:
*/
- (void)addResource:(Resource *)resource;
/*!
@method removeResource:
*/
- (void)removeResource:(Resource *)resource;
/*!
@method uniqueIDForType:
*/
- (NSNumber *)uniqueIDForType:(NSString *)type;
// accessors
-(Resource*) resourceOfType: (NSString*)type andID: (NSNumber*)resID;
-(Resource*) resourceOfType: (NSString*)type withName: (NSString*)name;
-(NSArray*) allResourcesOfType: (NSString*)type;
-(NSArray*) allResourceIDsOfType: (NSString*)type;
/*!
@method defaultIDForType:
*/
- (NSNumber *)defaultIDForType:(NSString *)type;
/*!
@method resourceOfType:andID:
*/
- (Resource *)resourceOfType:(NSString *)type andID:(NSNumber *)resID;
/*!
@method resourceOfType:withName:
*/
- (Resource *)resourceOfType:(NSString *)type withName:(NSString *)name;
/*!
@method allResourcesOfType:
*/
- (NSArray *)allResourcesOfType:(NSString *)type;
/*!
@method allResourceIDsOfType:
*/
- (NSArray *)allResourceIDsOfType:(NSString *)type;
@end

View File

@ -1,37 +1,14 @@
/* =============================================================================
PROJECT: ResKnife
FILE: ResourceDataSource.m
PURPOSE:
Dedicated data source for our resource list. Shares its list of
resources with ResourceDocument. I have no idea why Nick did this
split, though...
AUTHORS: Nick Shanks, nick(at)nickshanks.com, (c) ~2001.
M. Uli Kusterer, witness(at)zathras.de, (c) 2003.
REVISIONS:
2003-07-31 UK Added storing document pointer in resource, commented.
========================================================================== */
/* -----------------------------------------------------------------------------
Headers:
-------------------------------------------------------------------------- */
#import "ResourceDataSource.h"
#import "ResourceDocument.h"
#import "Resource.h"
#import <limits.h>
NSString *DataSourceWillAddResourceNotification = @"DataSourceWillAddResource";
NSString *DataSourceDidAddResourceNotification = @"DataSourceDidAddResource";
NSString *DataSourceWillRemoveResourceNotification = @"DataSourceWillRemoveResource";
NSString *DataSourceDidRemoveResourceNotification = @"DataSourceDidRemoveResource";
/* -----------------------------------------------------------------------------
Notification names:
-------------------------------------------------------------------------- */
NSString *DataSourceWillAddResourceNotification = @"DataSourceWillAddResourceNotification";
NSString *DataSourceDidAddResourceNotification = @"DataSourceDidAddResourceNotification";
NSString *DataSourceWillRemoveResourceNotification = @"DataSourceWillRemoveResourceNotification";
NSString *DataSourceDidRemoveResourceNotification = @"DataSourceDidRemoveResourceNotification";
extern NSString *RKResourcePboardType;
@implementation ResourceDataSource
@ -60,8 +37,9 @@ NSString *DataSourceDidRemoveResourceNotification = @"DataSourceDidRemoveResourc
- (void)setResources:(NSMutableArray *)newResources
{
[resources autorelease];
id old = resources;
resources = [newResources retain];
[old release];
[outlineView reloadData];
}
@ -71,8 +49,7 @@ NSString *DataSourceDidRemoveResourceNotification = @"DataSourceDidRemoveResourc
[[NSNotificationCenter defaultCenter] postNotificationName:DataSourceWillAddResourceNotification object:dictionary];
// it seems very inefficient to reload the entire data source when just adding/removing one item
// for large resource files, the data source gets reloaded hundereds of times upon load
[resource setDocument:document];
// for large resource files, the data source gets reloaded hundreds of times upon load
[resources addObject:resource];
[outlineView reloadData];
@ -93,67 +70,57 @@ NSString *DataSourceDidRemoveResourceNotification = @"DataSourceDidRemoveResourc
[[document undoManager] registerUndoWithTarget:self selector:@selector(addResource:) object:resource]; // NB: I hope the undo manager retains the resource, because it just got deleted :) - undo action name set by calling function
}
/* -----------------------------------------------------------------------------
resourceDidChange:
Notification from the Resource class that we're registered to. It's
sent whenever the resource is "touch"ed.
REVISIONS:
2003-08-01 UK Commented, made this "touch" the document as well.
-------------------------------------------------------------------------- */
-(void) resourceDidChange: (NSNotification*)notification
- (void)resourceDidChange:(NSNotification *)notification
{
// reload the data for the changed resource
[outlineView reloadItem:[notification object]];
[document updateChangeCount: NSChangeDone]; // TODO: We shouldn't need to do this, Undo should take care of this, according to the docs, but somehow the document always forgets its changes.
}
/* Data source protocol implementation */
- (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item
{
#pragma unused( outlineView, item )
#pragma unused(outlineView, item)
return [resources objectAtIndex:index];
}
- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item
{
#pragma unused( outlineView, item )
#pragma unused(outlineView, item)
return NO;
}
- (int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item
{
#pragma unused( outlineView, item )
#pragma unused(outlineView, item)
return [resources count];
}
- (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
{
#pragma unused( outlineView )
#pragma unused(outlineView)
return [item valueForKey:[tableColumn identifier]];
}
- (void)outlineView:(NSOutlineView *)outlineView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
{
#pragma unused( outlineView )
#pragma unused(outlineView)
NSString *identifier = [tableColumn identifier];
if( [identifier isEqualToString:@"resID"] )
[item takeValue:[NSNumber numberWithInt:[object intValue]] forKey:identifier];
else [item takeValue:object forKey:identifier];
if([identifier isEqualToString:@"resID"])
[item setValue:[NSNumber numberWithInt:[object intValue]] forKey:identifier];
else [item setValue:object forKey:identifier];
}
#pragma mark -
/* ACCESSORS */
- (Resource *)resourceOfType:(NSString *)type andID:(NSNumber *)resID
{
Resource *resource;
NSEnumerator *enumerator = [resources objectEnumerator];
while( resource = [enumerator nextObject] )
while(resource = [enumerator nextObject])
{
if( resID && [[resource resID] isEqualToNumber:resID] && type && [[resource type] isEqualToString:type] )
if(resID && [[resource resID] isEqualToNumber:resID] && type && [[resource type] isEqualToString:type])
return resource;
}
return nil;
@ -163,9 +130,9 @@ NSString *DataSourceDidRemoveResourceNotification = @"DataSourceDidRemoveResourc
{
Resource *resource;
NSEnumerator *enumerator = [resources objectEnumerator];
while( resource = [enumerator nextObject] )
while(resource = [enumerator nextObject])
{
if( [[resource name] isEqualToString:name] && [[resource type] isEqualToString:type] )
if([[resource name] isEqualToString:name] && [[resource type] isEqualToString:type])
return resource;
}
return nil;
@ -173,65 +140,108 @@ NSString *DataSourceDidRemoveResourceNotification = @"DataSourceDidRemoveResourc
- (NSArray *)allResourcesOfType:(NSString *)type
{
Resource *resource;
NSMutableArray *array = [NSMutableArray array];
NSEnumerator *enumerator = [resources objectEnumerator];
while( resource = [enumerator nextObject] )
Resource *resource;
NSMutableArray *array = [NSMutableArray array];
NSEnumerator *enumerator = [resources objectEnumerator];
while(resource = [enumerator nextObject])
{
if( [[resource type] isEqualToString:type] )
if([[resource type] isEqualToString:type])
[array addObject:resource];
}
return [NSArray arrayWithArray:array];
}
/*!
@method allResourceIDsOfType:
@discussion Returns an NSArray full of NSNumber* objects containing the IDs of all resources of specified type. Used by uniqueIDForType:.
@updated 2003-08-01 UK Created based on allResourcesOfType:
*/
/* -----------------------------------------------------------------------------
allResourceIDsOfType:
Returns an NSArray full of NSNumber* objects containing the IDs of all
resources of specified type. Used by uniqueIDForType:.
REVISIONS:
2003-08-01 UK Created based on allResourcesOfType:.
-------------------------------------------------------------------------- */
-(NSArray*) allResourceIDsOfType: (NSString*)type
- (NSArray*)allResourceIDsOfType:(NSString *)type
{
if(!type || [type isEqualToString:@""])
return [NSArray array];
Resource *resource;
NSMutableArray *array = [NSMutableArray array];
NSEnumerator *enumerator = [resources objectEnumerator];
while( resource = [enumerator nextObject] )
while(resource = [enumerator nextObject])
{
if( [[resource type] isEqualToString:type] )
if([[resource type] isEqualToString:type])
[array addObject:[resource resID]];
}
return [NSArray arrayWithArray:array];
}
/*!
@method uniqueIDForType:
@discussion Tries to return an unused resource ID for a new resource of specified type. If all IDs are used up (can't really happen, because the resource manager can't take more than 2727 resources per file without crashing, but just in theory...), this will return 128 no matter whether it's used or not.
@updated 2003-08-01 UK: Created.
@updated 2003-10-21 NGS: Changed to obtain initial ID from -[resource defaultIDForType:], so we can vary it on a pre-resource-type basis (like Resourcerer can)
*/
/* -----------------------------------------------------------------------------
uniqueIDForType:
Tries to return an unused resource ID for a new resource of specified
type. If all IDs are used up (can't really happen, because the resource
manager can't take more than 2727 resources per file without crashing,
but just in theory...), this will return 128 no matter whether it's
used or not.
REVISIONS:
2003-08-01 UK Created.
-------------------------------------------------------------------------- */
-(NSNumber*) uniqueIDForType: (NSString*)type
- (NSNumber *)uniqueIDForType:(NSString *)type
{
short theID = 128;
NSArray *array = [self allResourceIDsOfType: type];
short theID = [[self defaultIDForType:type] shortValue];
NSArray *array = [self allResourceIDsOfType:type];
if( [array count] <= USHRT_MAX )
if([array count] <= USHRT_MAX)
{
while( [array containsObject: [NSNumber numberWithShort:theID]] )
while([array containsObject:[NSNumber numberWithShort:theID]])
theID++;
}
return [NSNumber numberWithShort: theID];
}
/*!
@method defaultIDForType:
@pending Method should look for resources specifying what the initial ID is for this resource type (e.g. 'vers' resources start at 0)
*/
- (NSNumber *)defaultIDForType:(NSString *)type
{
short defaultID = 128;
return [NSNumber numberWithShort:defaultID];
}
#pragma mark -
/*!
@method outlineView:writeItems:toPasteboard:
@abstract Called at the start of a drag event.
*/
- (BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray *)items toPasteboard:(NSPasteboard *)pb
{
[pb declareTypes:[NSArray arrayWithObject:RKResourcePboardType] owner:self];
[pb setData:[NSArchiver archivedDataWithRootObject:items] forType:RKResourcePboardType];
return YES;
}
/*!
@method outlineView:validateDrop:proposedItem:proposedChildIndex:
@abstract Called when the user is hovering with a drop over our outline view.
*/
- (NSDragOperation)outlineView:(NSOutlineView *)outlineView validateDrop:(id <NSDraggingInfo>)info proposedItem:(id)item proposedChildIndex:(int)childIndex
{
if([info draggingSource] != outlineView)
{
[outlineView setDropItem:nil dropChildIndex:NSOutlineViewDropOnItemIndex];
return NSDragOperationCopy;
}
else return NSDragOperationNone;
}
/*!
@method outlineView:acceptDrop:item:childIndex:
@abstract Called when the user drops something on our outline view.
*/
- (BOOL)outlineView:(NSOutlineView *)outlineView acceptDrop:(id <NSDraggingInfo>)info item:(id)targetItem childIndex:(int)childIndex
{
NSPasteboard *pb = [info draggingPasteboard];
if([pb availableTypeFromArray:[NSArray arrayWithObject:RKResourcePboardType]])
[document pasteResources:[NSUnarchiver unarchiveObjectWithData:[pb dataForType:RKResourcePboardType]]];
return YES;
}
@end

View File

@ -12,10 +12,20 @@
NSMutableDictionary *toolbarItems;
NSMutableArray *resources;
HFSUniStr255 *fork; // name of fork to save to, usually empty string (data fork) or 'RESOURCE_FORK' as returned from FSGetResourceForkName()
NSString *creator;
NSString *type;
NSData *creator;
NSData *type;
BOOL _createFork; // file had no existing resource map when opened
}
- (BOOL)readFork:(NSString *)forkName asStreamFromFile:(FSRef *)fileRef;
- (BOOL)readResourceMap:(SInt16)fileRefNum;
- (BOOL)writeResourceMap:(SInt16)fileRefNum;
- (BOOL)writeForkStreamsToFile:(NSString *)fileName;
- (IBAction)exportResources:(id)sender;
- (void)exportResource:(Resource *)resource;
- (void)exportPanelDidEnd:(NSSavePanel *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo;
- (void)setupToolbar:(NSWindowController *)windowController;
- (IBAction)showCreateResourceSheet:(id)sender;
@ -29,9 +39,6 @@
- (IBAction)playSound:(id)sender;
- (void)sound:(NSSound *)sound didFinishPlaying:(BOOL)finished;
-(IBAction) exportResourceToFile: (id)sender;
-(IBAction) exportResourceToImageFile: (id)sender;
- (IBAction)copy:(id)sender;
- (IBAction)paste:(id)sender;
- (void)pasteResources:(NSArray *)pastedResources;
@ -45,21 +52,17 @@
- (void)resourceTypeWillChange:(NSNotification *)notification;
- (void)resourceAttributesWillChange:(NSNotification *)notification;
- (BOOL)readFork:(NSString *)forkName asStreamFromFile:(NSString *)fileName;
- (BOOL)readResourceMap:(SInt16)fileRefNum;
- (BOOL)writeResourceMap:(SInt16)fileRefNum;
- (NSWindow *)mainWindow;
- (ResourceDataSource *)dataSource;
- (NSOutlineView *)outlineView;
- (NSArray *)resources; // return the array as non-mutable
- (NSString *)creator;
- (NSString *)type;
- (NSData *)creator;
- (NSData *)type;
- (IBAction)creatorChanged:(id)sender;
- (IBAction)typeChanged:(id)sender;
- (void)setCreator:(NSString *)oldCreator;
- (void)setType:(NSString *)oldType;
- (void)setCreator:(NSString *)newCreator andType:(NSString *)newType;
- (BOOL)setCreator:(NSData *)newCreator;
- (BOOL)setType:(NSData *)newType;
- (BOOL)setCreator:(NSData *)newCreator andType:(NSData *)newType;
@end

File diff suppressed because it is too large Load Diff

View File

@ -5,10 +5,9 @@
- (id)init
{
self = [super init];
if( self )
{
drawImage = YES;
}
if(!self) return nil;
[self setWraps:NO];
drawImage = YES;
return self;
}
@ -42,7 +41,7 @@
- (void)setImage:(NSImage *)newImage
{
if( image != newImage )
if(image != newImage)
{
// save image and set to 16x16 pixels
id old = image;
@ -55,7 +54,7 @@
- (NSRect)imageFrameForCellFrame:(NSRect)cellFrame
{
if( image != nil && drawImage == YES )
if(image != nil && drawImage == YES)
{
// center image vertically in frame, offset right by three
NSRect imageFrame;
@ -70,11 +69,11 @@
- (void)editWithFrame:(NSRect)cellFrame inView:(NSView *)controlView editor:(NSText *)textObject delegate:(id)delegateObject event:(NSEvent *)theEvent
{
if( drawImage == YES )
if(drawImage == YES)
{
// split cell frame into two, pass the text part to the superclass
NSRect textFrame, imageFrame;
NSDivideRect( cellFrame, &imageFrame, &textFrame, 3 + [image size].width, NSMinXEdge );
NSDivideRect(cellFrame, &imageFrame, &textFrame, 3 + [image size].width, NSMinXEdge);
[super editWithFrame:textFrame inView:controlView editor:textObject delegate:delegateObject event:theEvent];
}
else
@ -85,11 +84,11 @@
- (void)selectWithFrame:(NSRect)cellFrame inView:(NSView *)controlView editor:(NSText *)textObject delegate:(id)delegateObject start:(int)selStart length:(int)selLength
{
if( drawImage == YES )
if(drawImage == YES)
{
// split cell frame into two, pass the text part to the superclass
NSRect textFrame, imageFrame;
NSDivideRect( cellFrame, &imageFrame, &textFrame, 3 + [image size].width, NSMinXEdge);
NSDivideRect(cellFrame, &imageFrame, &textFrame, 3 + [image size].width, NSMinXEdge);
[super selectWithFrame:textFrame inView:controlView editor:textObject delegate:delegateObject start:selStart length:selLength];
}
else
@ -100,15 +99,14 @@
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
if( image != nil && drawImage == YES )
if(image != nil && drawImage == YES)
{
NSRect imageFrame;
NSSize imageSize = [image size];
// get image frame
NSDivideRect( cellFrame, &imageFrame, &cellFrame, 3 + imageSize.width, NSMinXEdge );
// NSLog( "drawing name cell with bg: %@ colour: %@", [self drawsBackground]? @"YES":@"NO", [self backgroundColor] );
if( [self drawsBackground] && ![self isHighlighted] /* ![self cellAttribute:NSCellHighlighted] */ )
NSDivideRect(cellFrame, &imageFrame, &cellFrame, 3 + imageSize.width, NSMinXEdge);
if([self drawsBackground] && ![self isHighlighted] /* ![self cellAttribute:NSCellHighlighted] */)
{
[[self backgroundColor] set];
NSRectFill(imageFrame);
@ -117,7 +115,7 @@
imageFrame.size = imageSize;
// center vertically
if( [controlView isFlipped] )
if([controlView isFlipped])
imageFrame.origin.y += ceil((cellFrame.size.height + imageFrame.size.height) / 2);
else imageFrame.origin.y += ceil((cellFrame.size.height - imageFrame.size.height) / 2);
@ -132,7 +130,7 @@
- (NSSize)cellSize
{
NSSize cellSize = [super cellSize];
if( drawImage == YES )
if(drawImage == YES)
cellSize.width += (image? [image size].width:0) + 3;
return cellSize;
}

View File

@ -15,7 +15,7 @@
float value = [obj floatValue];
int power = 0;
while( value >= 1024 && power <= 30 )
while( value >= 1024 /*&& power <= 30*/ )
{
power += 10; // 10 == KB, 20 == MB, 30+ == GB
value /= 1024;

View File

@ -1,20 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
<plist version="0.9">
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IBDocumentLocation</key>
<string>109 310 356 240 0 0 1280 1002 </string>
<string>147 310 356 240 0 0 1600 1002 </string>
<key>IBFramework Version</key>
<string>248.0</string>
<string>446.1</string>
<key>IBLockedObjects</key>
<array>
<integer>25</integer>
</array>
<key>IBOpenObjects</key>
<array>
<integer>23</integer>
<integer>21</integer>
</array>
<key>IBSystem Version</key>
<string>5P48</string>
<string>8L127</string>
</dict>
</plist>

Binary file not shown.

View File

@ -1,10 +1,18 @@
{
IBClasses = (
{
ACTIONS = {showInfo = id; showPasteboard = id; showPrefs = id; };
ACTIONS = {
emailDeveloper = id;
showAbout = id;
showInfo = id;
showPasteboard = id;
showPrefs = id;
visitSourceforge = id;
visitWebsite = id;
};
CLASS = ApplicationDelegate;
LANGUAGE = ObjC;
OUTLETS = {forkTableView = NSTableView; openAuxView = NSView; };
OUTLETS = {openPanelDelegate = OpenPanelDelegate; };
SUPERCLASS = NSObject;
},
{
@ -15,30 +23,41 @@
findNext = id;
findPrevious = id;
findWithSelection = id;
myAction = id;
openResources = id;
openResourcesAsHex = id;
openResourcesInTemplate = id;
playSound = id;
revertResourceToSaved = id;
revertResource = id;
saveResource = id;
scrollToSelection = id;
showAbout = id;
showCreateResourceSheet = id;
showExportToDFSheet = id;
showFind = id;
showInfo = id;
showPrefs = id;
showSelectTemplateSheet = id;
useIconView = id;
useListView = id;
};
CLASS = FirstResponder;
LANGUAGE = ObjC;
SUPERCLASS = NSObject;
},
{CLASS = NSOutlineView; LANGUAGE = ObjC; SUPERCLASS = NSTableView; },
{
CLASS = OpenFileDataSource;
ACTIONS = {addFork = id; removeFork = id; };
CLASS = OpenPanelDelegate;
LANGUAGE = ObjC;
OUTLETS = {forkTableView = NSTableView; };
OUTLETS = {
addForkButton = NSButton;
forkTableView = NSTableView;
openPanelAccessoryView = NSView;
removeForkButton = NSButton;
};
SUPERCLASS = NSObject;
},
{CLASS = OutlineSortView; LANGUAGE = ObjC; SUPERCLASS = NSOutlineView; },
{
ACTIONS = {
clear = id;

View File

@ -3,22 +3,25 @@
<plist version="1.0">
<dict>
<key>IBDocumentLocation</key>
<string>434 99 432 426 0 0 1024 746 </string>
<string>75 727 356 240 0 0 1600 1002 </string>
<key>IBEditorPositions</key>
<dict>
<key>246</key>
<string>12 513 340 222 0 0 1024 746 </string>
<string>569 580 520 175 0 0 1600 1002 </string>
<key>29</key>
<string>28 222 347 44 0 0 1024 746 </string>
<string>66 658 366 44 0 0 1600 1002 </string>
</dict>
<key>IBFramework Version</key>
<string>326.0</string>
<string>446.1</string>
<key>IBLockedObjects</key>
<array/>
<key>IBOldestOS</key>
<integer>1</integer>
<key>IBOpenObjects</key>
<array>
<integer>246</integer>
<integer>29</integer>
</array>
<key>IBSystem Version</key>
<string>7A202</string>
<string>8L127</string>
</dict>
</plist>

Binary file not shown.

Binary file not shown.

View File

@ -6,7 +6,13 @@
<string>58 46 387 357 0 0 832 602 </string>
<key>IBFramework Version</key>
<string>326.0</string>
<key>IBOldestOS</key>
<integer>3</integer>
<key>IBOpenObjects</key>
<array>
<integer>20</integer>
</array>
<key>IBSystem Version</key>
<string>7A202</string>
<string>7A179</string>
</dict>
</plist>

Binary file not shown.

View File

@ -0,0 +1,30 @@
{\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410
{\fonttbl\f0\fswiss\fcharset77 Helvetica-Bold;\f1\fswiss\fcharset77 Helvetica;}
{\colortbl;\red255\green255\blue255;}
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
\f0\b\fs24 \cf0 Lead Developer:
\f1\b0 \
Nicholas Shanks\
\
\f0\b Developers:
\f1\b0 \
Uli Kusterer\
\
\f0\b Other Contributors:
\f1\b0 \
Thomas Castiglione\
Philippe Devallois\
Mike Margolis\
Lane Roathe\
Jeffrey Seibert\
\
\f0\b Wanted:
\f1\b0 \
Plug-in editors for resource types.\
Translations for any language.\
Application, document & toolbar icons.\
}

View File

@ -7,7 +7,7 @@
SUPERCLASS = NSObject;
},
{
ACTIONS = {attributesChanged = id; nameChanged = id; };
ACTIONS = {attributesChanged = id; };
CLASS = InfoWindowController;
LANGUAGE = ObjC;
OUTLETS = {
@ -21,7 +21,6 @@
};
SUPERCLASS = NSWindowController;
},
{CLASS = NSWindowController; LANGUAGE = ObjC; SUPERCLASS = NSResponder; },
{CLASS = SizeFormatter; LANGUAGE = ObjC; SUPERCLASS = NSNumberFormatter; }
);
IBVersion = 1;

View File

@ -3,16 +3,12 @@
<plist version="1.0">
<dict>
<key>IBDocumentLocation</key>
<string>142 473 384 240 0 0 1024 746 </string>
<string>267 434 384 240 0 0 1600 1002 </string>
<key>IBFramework Version</key>
<string>326.0</string>
<key>IBOpenObjects</key>
<array>
<integer>35</integer>
<integer>5</integer>
<integer>50</integer>
</array>
<string>439.0</string>
<key>IBOldestOS</key>
<integer>0</integer>
<key>IBSystem Version</key>
<string>7A202</string>
<string>8I127</string>
</dict>
</plist>

Binary file not shown.

Binary file not shown.

View File

@ -2,23 +2,17 @@
IBClasses = (
{CLASS = AttributesFormatter; LANGUAGE = ObjC; SUPERCLASS = NSFormatter; },
{CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
{
CLASS = NameFormatter;
LANGUAGE = ObjC;
OUTLETS = {outlineView = NSOutlineView; };
SUPERCLASS = NSFormatter;
},
{
CLASS = OutlineViewDelegate;
LANGUAGE = ObjC;
OUTLETS = {
attributesFormatter = NSFormatter;
nameFormatter = NSFormatter;
sizeFormatter = NSNumberFormatter;
window = NSWindow;
};
SUPERCLASS = NSObject;
},
{CLASS = RKOutlineView; LANGUAGE = ObjC; SUPERCLASS = NSOutlineView; },
{
CLASS = ResourceDataSource;
LANGUAGE = ObjC;

View File

@ -3,11 +3,15 @@
<plist version="1.0">
<dict>
<key>IBDocumentLocation</key>
<string>71 141 530 549 0 0 1600 1002 </string>
<string>579 557 418 241 0 0 1600 1002 </string>
<key>IBFramework Version</key>
<string>286.0</string>
<string>349.0</string>
<key>IBLockedObjects</key>
<array>
<integer>146</integer>
</array>
<key>IBSystem Version</key>
<string>6F21</string>
<string>7H63</string>
<key>IBUserGuides</key>
<dict>
<key>CreateResourceSheet</key>

90
Cocoa/Info.plist Normal file
View File

@ -0,0 +1,90 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>rsrc</string>
<string>*</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>Resource file.icns</string>
<key>CFBundleTypeName</key>
<string>ResourceMap</string>
<key>CFBundleTypeOSTypes</key>
<array>
<string>rsrc</string>
<string>RSRC</string>
<string>????</string>
<string>****</string>
</array>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>LSItemContentTypes</key>
<array>
<string>com.apple.resource-map</string>
</array>
<key>NSDocumentClass</key>
<string>ResourceDocument</string>
</dict>
</array>
<key>CFBundleExecutable</key>
<string>ResKnife Cocoa</string>
<key>CFBundleGetInfoString</key>
<string>A resource editor for Mac OS X.</string>
<key>CFBundleIconFile</key>
<string>ResKnife.icns</string>
<key>CFBundleIdentifier</key>
<string>com.nickshanks.resknife</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>ResKnife</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string></string>
<key>CFBundleSignature</key>
<string>ResK</string>
<key>CFBundleVersion</key>
<string></string>
<key>NSAppleScriptEnabled</key>
<true/>
<key>NSMainNibFile</key>
<string>Application</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>UTImportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
<string>public.archive</string>
<string>public.composite-content</string>
</array>
<key>UTTypeDescription</key>
<string>Resource Map</string>
<key>UTTypeIconFile</key>
<string>Resource file.icns</string>
<key>UTTypeIdentifier</key>
<string>com.apple.resource-map</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>com.apple.ostype</key>
<array>
<string>rsrc</string>
<string>RSRC</string>
</array>
<key>public.filename-extension</key>
<string>rsrc</string>
</dict>
</dict>
</array>
</dict>
</plist>

View File

@ -2,9 +2,9 @@
IBClasses = (
{CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
{
CLASS = NuTemplateWindowController;
ACTIONS = {openTableInEditor = id; };
CLASS = FontWindowController;
LANGUAGE = ObjC;
OUTLETS = {dataList = NSOutlineView; displayList = NSOutlineView; resource = id; };
SUPERCLASS = NSWindowController;
}
);

View File

@ -3,22 +3,20 @@
<plist version="1.0">
<dict>
<key>IBDocumentLocation</key>
<string>235 41 356 240 0 0 1024 746 </string>
<key>IBEditorPositions</key>
<dict>
<key>23</key>
<string>412 326 270 342 0 0 1024 746 </string>
</dict>
<string>137 216 356 240 0 0 1600 1002 </string>
<key>IBFramework Version</key>
<string>326.0</string>
<string>446.1</string>
<key>IBLockedObjects</key>
<array/>
<key>IBOpenObjects</key>
<array>
<integer>21</integer>
<integer>23</integer>
</array>
<key>IBOldestOS</key>
<integer>3</integer>
<key>IBOpenObjects</key>
<array>
<integer>5</integer>
</array>
<key>IBSystem Version</key>
<string>7A202</string>
<string>8L127</string>
</dict>
</plist>

Some files were not shown because too many files have changed in this diff Show More