Merge Carbon formatting and whitespace changes from a 2007 branch into the main branch.

This commit is contained in:
Nicholas Shanks 2014-02-16 10:40:05 +00:00
commit 4948b1de3f
31 changed files with 2529 additions and 2470 deletions

File diff suppressed because it is too large Load Diff

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -37,51 +37,51 @@ const DataBrowserItemID kDataBrowserDataForkItem = 0xFFFFFFFE; // bug in data br
* @function AddDataBrowserColumn * @function AddDataBrowserColumn
* @discussion Adds columns to the data browser one at a time. * @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 * @function DataBrowserItemData
* @discussion DataBrowser callback. * @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 * @function SortDataBrowser
* @discussion DataBrowser callback. * @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 * @function DataBrowserMessage
* @discussion DataBrowser callback. * @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 * @function DataBrowserAddDragItem
* @discussion DataBrowser callback. * @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 * @function DataBrowserAcceptDrag
* @discussion DataBrowser callback. * @discussion DataBrowser callback.
*/ */
pascal Boolean DataBrowserAcceptDrag( ControlRef browser, DragRef drag, DataBrowserItemID item ); pascal Boolean DataBrowserAcceptDrag(ControlRef browser, DragRef drag, DataBrowserItemID item);
/*! /*!
* @function DataBrowserReceiveDrag * @function DataBrowserReceiveDrag
* @discussion DataBrowser callback. * @discussion DataBrowser callback.
*/ */
pascal Boolean DataBrowserReceiveDrag( ControlRef browser, DragRef drag, DataBrowserItemID item ); pascal Boolean DataBrowserReceiveDrag(ControlRef browser, DragRef drag, DataBrowserItemID item);
/*! /*!
* @function DataBrowserPostProcessDrag * @function DataBrowserPostProcessDrag
* @discussion DataBrowser callback. * @discussion DataBrowser callback.
*/ */
pascal void DataBrowserPostProcessDrag( ControlRef browser, DragRef drag, OSStatus trackDragResult ); pascal void DataBrowserPostProcessDrag(ControlRef browser, DragRef drag, OSStatus trackDragResult);
/*! /*!
* @function SendPromisedFile * @function SendPromisedFile
* @discussion Creates the promised file and sends the FSSpec for it back. * @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 * @function AddResourceToDragFile
* @discussion Adds each resource to the file created by SendPromisedFile. Called once per resource. * @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 #endif

View File

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

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -89,87 +89,87 @@ class FileWindow : WindowObject
/* methods */ /* methods */
public: public:
FileWindow( FSSpecPtr spec = null ); FileWindow(FSSpecPtr spec = null);
virtual ~FileWindow( void ); virtual ~FileWindow(void);
// overridden inherited functions // overridden inherited functions
/*! /*!
* @function Window * @function Window
* @discussion Accessor for the object&rsquo;s <tt>WindowRef</tt>. * @discussion Accessor for the object&rsquo;s <tt>WindowRef</tt>.
*/ */
virtual WindowRef Window( void ); virtual WindowRef Window(void);
virtual OSStatus BoundsChanging( EventRef event ); virtual OSStatus BoundsChanging(EventRef event);
virtual OSStatus BoundsChanged( EventRef event ); virtual OSStatus BoundsChanged(EventRef event);
#if !TARGET_API_MAC_CARBON #if !TARGET_API_MAC_CARBON
virtual OSStatus Activate( Boolean active = true ); virtual OSStatus Activate(Boolean active = true);
virtual OSStatus Update( RgnHandle region = null ); virtual OSStatus Update(RgnHandle region = null);
virtual OSStatus Click( Point mouse, EventModifiers modifiers ); virtual OSStatus Click(Point mouse, EventModifiers modifiers);
// drawing // drawing
private: private:
virtual OSStatus UpdateScrollBars( void ); virtual OSStatus UpdateScrollBars(void);
OSStatus DrawResourceIcon( ResourceObjectPtr resource, UInt16 line ); OSStatus DrawResourceIcon(ResourceObjectPtr resource, UInt16 line);
// fake data brwser // fake data brwser
OSStatus ClearSelection( void ); OSStatus ClearSelection(void);
#endif #endif
// file manipulation // file manipulation
public: public:
OSStatus ReadResourceFork( void ); OSStatus ReadResourceFork(void);
OSStatus ReadDataFork( OSStatus rfError ); OSStatus ReadDataFork(OSStatus rfError);
OSStatus InitDataBrowser( void ); OSStatus InitDataBrowser(void);
OSStatus SaveFile( FSSpecPtr saveSpec = null ); OSStatus SaveFile(FSSpecPtr saveSpec = null);
/*! /*!
@function ReadResourceMap @function ReadResourceMap
@discussion Requires the fork containing resources to be at the top of the resource chain @discussion Requires the fork containing resources to be at the top of the resource chain
*/ */
OSStatus ReadResourceMap( void ); // fork-independent resource routines OSStatus ReadResourceMap(void); // fork-independent resource routines
OSStatus SaveResourceMap( void ); OSStatus SaveResourceMap(void);
// carbon routines // carbon routines
OSStatus Zoomed( EventRef event ); OSStatus Zoomed(EventRef event);
OSStatus SetIdealSize( EventRef event ); OSStatus SetIdealSize(EventRef event);
OSStatus DisplaySaveDialog( void ); OSStatus DisplaySaveDialog(void);
OSStatus DisplayModelessAskSaveChangesDialog( void ); OSStatus DisplayModelessAskSaveChangesDialog(void);
OSStatus DisplaySaveAsDialog( void ); OSStatus DisplaySaveAsDialog(void);
OSStatus DisplayModelessPutFileDialog( void ); OSStatus DisplayModelessPutFileDialog(void);
OSStatus DisplayRevertFileDialog( void ); OSStatus DisplayRevertFileDialog(void);
OSStatus DisplayModelessAskDiscardChangesDialog( void ); OSStatus DisplayModelessAskDiscardChangesDialog(void);
OSStatus DisplayNewResourceDialog( void ); OSStatus DisplayNewResourceDialog(void);
OSStatus DisplayNewResourceSheet( void ); OSStatus DisplayNewResourceSheet(void);
// resource map processing // resource map processing
OSStatus CreateNewResource( ConstStr255Param name, ResType type, SInt16 resID, SInt16 attribs ); OSStatus CreateNewResource(ConstStr255Param name, ResType type, SInt16 resID, SInt16 attribs);
OSStatus OpenResource( DataBrowserItemID itemID, MenuCommand command ); OSStatus OpenResource(DataBrowserItemID itemID, MenuCommand command);
OSStatus DisposeResourceMap( void ); OSStatus DisposeResourceMap(void);
// sound handlers // sound handlers
OSStatus PlaySound( DataBrowserItemID itemID ); OSStatus PlaySound(DataBrowserItemID itemID);
// file accessors // file accessors
FSSpecPtr GetFileSpec( void ); FSSpecPtr GetFileSpec(void);
void SetFileSpec( FSSpecPtr spec ); void SetFileSpec(FSSpecPtr spec);
Boolean IsFileDirty( void ); Boolean IsFileDirty(void);
void SetFileDirty( Boolean dirty = true ); void SetFileDirty(Boolean dirty = true);
#if TARGET_API_MAC_CARBON #if TARGET_API_MAC_CARBON
ControlRef GetDataBrowser( void ); ControlRef GetDataBrowser(void);
#endif #endif
// resource accessors // resource accessors
UInt32 GetResourceCount( ResType wanted = 0x00000000 ); UInt32 GetResourceCount(ResType wanted = 0x00000000);
ResourceObjectPtr GetResource( DataBrowserItemID itemID ); ResourceObjectPtr GetResource(DataBrowserItemID itemID);
UInt8* GetResourceName( DataBrowserItemID itemID ); UInt8* GetResourceName(DataBrowserItemID itemID);
UInt32 GetResourceSize( DataBrowserItemID itemID ); UInt32 GetResourceSize(DataBrowserItemID itemID);
ResType GetResourceType( DataBrowserItemID itemID ); ResType GetResourceType(DataBrowserItemID itemID);
SInt16 GetResourceID( DataBrowserItemID itemID ); SInt16 GetResourceID(DataBrowserItemID itemID);
SInt16 GetResourceAttributes( DataBrowserItemID itemID ); SInt16 GetResourceAttributes(DataBrowserItemID itemID);
}; };
/* window event handler */ /* window event handler */
pascal void FileWindowScrollAction( ControlHandle control, SInt16 controlPart ); pascal void FileWindowScrollAction(ControlHandle control, SInt16 controlPart);
pascal OSStatus FileWindowEventHandler( EventHandlerCallRef callRef, EventRef event, void *userData ); pascal OSStatus FileWindowEventHandler(EventHandlerCallRef callRef, EventRef event, void *userData);
pascal OSStatus FileWindowUpdateMenus( 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 FileWindowParseMenuSelection(EventHandlerCallRef callRef, EventRef event, void *userData);
pascal OSStatus NewResourceEventHandler( 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 @function DisplayOpenDialog
@discussion Calls the appropriate <tt>Open()</tt> function for the system we are running on. @discussion Calls the appropriate <tt>Open()</tt> function for the system we are running on.
*/ */
OSStatus DisplayOpenDialog( void ); OSStatus DisplayOpenDialog(void);
/*! /*!
@function DisplayModelessGetFileDialog @function DisplayModelessGetFileDialog
@discussion Requires CarbonLib 1.1 or OS X @discussion Requires CarbonLib 1.1 or OS X
*/ */
OSStatus DisplayModelessGetFileDialog( void ); OSStatus DisplayModelessGetFileDialog(void);
/*! /*!
@function OpenFile @function OpenFile
*/ */
OSStatus OpenFile( short vRefNum, long dirID, ConstStr255Param fileName ); OSStatus OpenFile(short vRefNum, long dirID, ConstStr255Param fileName);
/*! /*!
@function DisplayStandardFileOpenDialog @function DisplayStandardFileOpenDialog
*/ */
OSStatus DisplayStandardFileOpenDialog( void ); OSStatus DisplayStandardFileOpenDialog(void);
/*! /*!
@function ModelessGetFileHandler @function ModelessGetFileHandler
@discussion Requires CarbonLib 1.1 or OS X @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 @function ModelessAskSaveChangesHandler
@discussion Requires CarbonLib 1.1 or OS X @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 @function ModelessPutFileHandler
@discussion Requires CarbonLib 1.1 or OS X @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 @function ModelessAskDiscardChangesHandler
@discussion Requires CarbonLib 1.1 or OS X @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 @function NavEventFilter
*/ */
pascal void NavEventFilter( NavEventCallbackMessage callBackSelector, NavCBRecPtr cbRecord, NavCallBackUserData callBackUD ); pascal void NavEventFilter(NavEventCallbackMessage callBackSelector, NavCBRecPtr cbRecord, NavCallBackUserData callBackUD);
/*! /*!
@function NavPreviewFilter @function NavPreviewFilter
*/ */
pascal Boolean NavPreviewFilter( NavCBRecPtr callBackParms, void *callBackUD ); pascal Boolean NavPreviewFilter(NavCBRecPtr callBackParms, void *callBackUD);
/*! /*!
@function NavFileFilter @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 #endif

View File

@ -9,20 +9,20 @@
extern globals g; extern globals g;
/* window management */ /* 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 ); EditorWindowPtr plugWindow = new EditorWindow(((ResourceObjectPtr) resource)->File(), (ResourceObjectPtr) resource, window);
((PlugObjectPtr) plug)->SetWindowObject( (WindowObjectPtr) plugWindow ); ((PlugObjectPtr) plug)->SetWindowObject((WindowObjectPtr) plugWindow);
((PlugObjectPtr) plug)->SetResourceObject( (ResourceObjectPtr) resource ); ((PlugObjectPtr) plug)->SetResourceObject((ResourceObjectPtr) resource);
return (Plug_WindowRef) plugWindow; return (Plug_WindowRef) plugWindow;
} }
/* else /* else
{ {
PickerWindowPtr plugWindow = new PickerWindow( window ); PickerWindowPtr plugWindow = new PickerWindow(window);
((PlugObjectPtr) plug)->SetWindowObject( plugWindow ); ((PlugObjectPtr) plug)->SetWindowObject(plugWindow);
((PlugObjectPtr) plug)->SetResourceObject( (ResourceObjectPtr) resource ); ((PlugObjectPtr) plug)->SetResourceObject((ResourceObjectPtr) resource);
return (Plug_WindowRef) plugWindow; return (Plug_WindowRef) plugWindow;
} }
*/ else return null; */ else return null;
@ -30,172 +30,172 @@ Plug_WindowRef Host_RegisterWindow( Plug_PlugInRef plug, Plug_ResourceRef resour
#if !TARGET_API_MAC_CARBON #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 #endif
WindowRef Host_GetWindowRefFromPlugWindow( Plug_WindowRef plugWindow ) WindowRef Host_GetWindowRefFromPlugWindow(Plug_WindowRef plugWindow)
{ {
return ((WindowObjectPtr) plugWindow)->Window(); return ((WindowObjectPtr) plugWindow)->Window();
} }
Plug_WindowRef Host_GetPlugWindowFromWindowRef( WindowRef window ) Plug_WindowRef Host_GetPlugWindowFromWindowRef(WindowRef window)
{ {
return (Plug_WindowRef) GetWindowRefCon(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; 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; // FileWindowPtr file;
if( sameFileAsResource != NULL ) if(sameFileAsResource != NULL)
{ {
// file = ((ResourceObjectPtr) sameFileAsResource)->file; // file = ((ResourceObjectPtr) sameFileAsResource)->file;
short oldResFile = CurResFile(); short oldResFile = CurResFile();
UseResFile( HomeResFile( ((ResourceObjectPtr) sameFileAsResource)->Data() ) ); UseResFile(HomeResFile(((ResourceObjectPtr) sameFileAsResource)->Data()));
Get1Resource( type, resID ); // bug: handle ignored at present Get1Resource(type, resID); // bug: handle ignored at present
UseResFile( oldResFile ); 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 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(); return (Plug_ResourceRef) ((EditorWindowPtr) plugWindow)->Resource();
} }
/* accessors */ /* accessors */
Handle Host_GetResourceData( Plug_ResourceRef resource ) Handle Host_GetResourceData(Plug_ResourceRef resource)
{ {
((ResourceObjectPtr) resource)->Retain(); ((ResourceObjectPtr) resource)->Retain();
return ((ResourceObjectPtr) resource)->Data(); 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; return null;
} }
void Host_ReleaseResourceData( Plug_ResourceRef resource ) void Host_ReleaseResourceData(Plug_ResourceRef resource)
{ {
#pragma unused( resource ) #pragma unused(resource)
// ((ResourceObjectPtr) resource)->Release(); // ((ResourceObjectPtr) resource)->Release();
return; 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; return;
} }
ResType Host_GetResourceType( Plug_ResourceRef resource ) ResType Host_GetResourceType(Plug_ResourceRef resource)
{ {
return ((ResourceObjectPtr) resource)->Type(); return ((ResourceObjectPtr) resource)->Type();
} }
SInt16 Host_GetResourceID( Plug_ResourceRef resource ) SInt16 Host_GetResourceID(Plug_ResourceRef resource)
{ {
return ((ResourceObjectPtr) resource)->ID(); return ((ResourceObjectPtr) resource)->ID();
} }
UInt32 Host_GetResourceSize( Plug_ResourceRef resource ) UInt32 Host_GetResourceSize(Plug_ResourceRef resource)
{ {
return ((ResourceObjectPtr) resource)->Size(); 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; return;
} }
UInt32 Host_GetWindowRefCon( Plug_WindowRef plugWindow ) UInt32 Host_GetWindowRefCon(Plug_WindowRef plugWindow)
{ {
return ((PlugWindowPtr) plugWindow)->GetRefCon(); return ((PlugWindowPtr) plugWindow)->GetRefCon();
} }
void Host_SetWindowRefCon( Plug_WindowRef plugWindow, UInt32 value ) void Host_SetWindowRefCon(Plug_WindowRef plugWindow, UInt32 value)
{ {
((PlugWindowPtr) plugWindow)->SetRefCon(value); ((PlugWindowPtr) plugWindow)->SetRefCon(value);
} }
UInt32 Host_GetGlobalRefCon( Plug_PlugInRef plug ) UInt32 Host_GetGlobalRefCon(Plug_PlugInRef plug)
{ {
return ((PlugObjectPtr) plug)->GetRefCon(); return ((PlugObjectPtr) plug)->GetRefCon();
} }
void Host_SetGlobalRefCon( Plug_PlugInRef plug, UInt32 value ) void Host_SetGlobalRefCon(Plug_PlugInRef plug, UInt32 value)
{ {
((PlugObjectPtr) plug)->SetRefCon(value); ((PlugObjectPtr) plug)->SetRefCon(value);
} }
Boolean Host_GetResourceDirty( Plug_ResourceRef resource ) Boolean Host_GetResourceDirty(Plug_ResourceRef resource)
{ {
return ((ResourceObjectPtr) resource)->Dirty(); 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 */ /* utilities */
Handle Host_GetDefaultTemplate( ResType type ) Handle Host_GetDefaultTemplate(ResType type)
{ {
short savedResFile = CurResFile(); short savedResFile = CurResFile();
UseResFile( g.appResFile ); UseResFile(g.appResFile);
Str255 name = "\pxxxx"; Str255 name = "\pxxxx";
BlockMoveData( &type, name +1, sizeof(ResType) ); BlockMoveData(&type, name +1, sizeof(ResType));
Handle tmpl = Get1NamedResource( 'TMPL', name ); Handle tmpl = Get1NamedResource('TMPL', name);
OSStatus error = ResError(); OSStatus error = ResError();
UseResFile( savedResFile ); UseResFile(savedResFile);
if( error ) return null; if(error) return null;
else return tmpl; 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; 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; return;
} }
void Host_UpdateMenus( Plug_ResourceRef resource ) void Host_UpdateMenus(Plug_ResourceRef resource)
{ {
OSStatus error = noErr; OSStatus error = noErr;
#if TARGET_API_MAC_CARBON #if TARGET_API_MAC_CARBON
error = CarbonEventUpdateMenus( null, null, null ); error = CarbonEventUpdateMenus(null, null, null);
// if( error ) DebugError( "\pHost_UpdateMenus hit an error when calling CarbonEventUpdateMenus()" ); // if(error) DebugError("\pHost_UpdateMenus hit an error when calling CarbonEventUpdateMenus()");
error = FileWindowUpdateMenus( null, null, ((ResourceObjectPtr) resource)->File() ); error = FileWindowUpdateMenus(null, null, ((ResourceObjectPtr) resource)->File());
// if( error ) DebugError( "\pHost_UpdateMenus hit an error when calling FileWindowUpdateMenus()" ); // if(error) DebugError("\pHost_UpdateMenus hit an error when calling FileWindowUpdateMenus()");
#else #else
UpdateMenus( ((ResourceObjectPtr) resource)->File()->Window() ); UpdateMenus(((ResourceObjectPtr) resource)->File()->Window());
#endif #endif
} }
void Host_DisplayError( ConstStr255Param errorStr, ConstStr255Param explanationStr, UInt8 severity ) void Host_DisplayError(ConstStr255Param errorStr, ConstStr255Param explanationStr, UInt8 severity)
{ {
#pragma unused( severity ) #pragma unused(severity)
DisplayError( errorStr, explanationStr ); 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> * @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. * 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 * @function Host_InstallClassicWindowEventHandler
* @abstract Without this, non-carbon plugs will not receive events * @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 * &bull; kEventWindowClickContentRgn
*/ */
ResCall void Host_InstallClassicWindowEventHandler( Plug_WindowRef plugWindow, RoutineDescriptor *handler ); ResCall void Host_InstallClassicWindowEventHandler(Plug_WindowRef plugWindow, RoutineDescriptor *handler);
/*! /*!
* @function Host_GetWindowRefFromPlugWindow * @function Host_GetWindowRefFromPlugWindow
* @abstract Allows plug-ins to obtain a Mac OS <tt>WindowRef</tt> from their <tt>Plug_WindowRef</tt> * @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> * @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 * @function Host_GetPlugWindowFromWindowRef
* @abstract Allows plug-ins to obtain a <tt>Plug_WindowRef</tt> from their Mac OS <tt>WindowRef</tt> * @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> * @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 * @function Host_GetPlugRef
* @discussion You will probably need to call this if the system calls one of your routines directly. * @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 * @function Host_GetResource
* @discussion Returns a reference to any arbitrary resource. * @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. * @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 * @function Host_GetTargetResource
* @discussion Returns the reference to the resource you're actually editing. * @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 * @function Host_GetResourceData
* @discussion Dispose of with <tt>Host_ReleaseResourceData()</tt> * @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 * @function Host_GetPartialResourceData
* @discussion Dispose of with <tt>Host_ReleasePartialResourceData()</tt> * @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 * @function Host_ReleaseResourceData
*/ */
ResCall void Host_ReleaseResourceData( Plug_ResourceRef resource ); ResCall void Host_ReleaseResourceData(Plug_ResourceRef resource);
/*! /*!
* @function Host_ReleasePartialResourceData * @function Host_ReleasePartialResourceData
*/ */
ResCall void Host_ReleasePartialResourceData( Plug_ResourceRef resource, Handle data ); ResCall void Host_ReleasePartialResourceData(Plug_ResourceRef resource, Handle data);
/*! /*!
* @function Host_GetResourceType * @function Host_GetResourceType
*/ */
ResCall ResType Host_GetResourceType( Plug_ResourceRef resource ); ResCall ResType Host_GetResourceType(Plug_ResourceRef resource);
/*! /*!
* @function Host_GetResourceID * @function Host_GetResourceID
*/ */
ResCall SInt16 Host_GetResourceID( Plug_ResourceRef resource ); ResCall SInt16 Host_GetResourceID(Plug_ResourceRef resource);
/*! /*!
* @function Host_GetResourceSize * @function Host_GetResourceSize
*/ */
ResCall UInt32 Host_GetResourceSize( Plug_ResourceRef resource ); ResCall UInt32 Host_GetResourceSize(Plug_ResourceRef resource);
/*! /*!
* @function Host_GetResourceName * @function Host_GetResourceName
*/ */
ResCall void Host_GetResourceName( Plug_ResourceRef resource, Str255 name ); ResCall void Host_GetResourceName(Plug_ResourceRef resource, Str255 name);
/* ResCall void Host_SetResourceName( Plug_ResourceRef resource, ConstStr255Param name ); */ /* ResCall void Host_SetResourceName(Plug_ResourceRef resource, ConstStr255Param name); */
/*! /*!
* @function Host_GetResourceDirty * @function Host_GetResourceDirty
*/ */
ResCall Boolean Host_GetResourceDirty( Plug_ResourceRef resource ); ResCall Boolean Host_GetResourceDirty(Plug_ResourceRef resource);
/*! /*!
* @function Host_SetResourceDirty * @function Host_SetResourceDirty
*/ */
ResCall void Host_SetResourceDirty( Plug_ResourceRef resource, Boolean dirty ); ResCall void Host_SetResourceDirty(Plug_ResourceRef resource, Boolean dirty);
/* ResCall Boolean Host_GetResourceIsOnDisk( Plug_ResourceRef resource ); */ // name may change soon /* ResCall Boolean Host_GetResourceIsOnDisk(Plug_ResourceRef resource); */ // name may change soon
/*! /*!
* @function Host_GetWindowRefCon * @function Host_GetWindowRefCon
*/ */
ResCall UInt32 Host_GetWindowRefCon( Plug_WindowRef plugWindow ); ResCall UInt32 Host_GetWindowRefCon(Plug_WindowRef plugWindow);
/*! /*!
* @function Host_SetWindowRefCon * @function Host_SetWindowRefCon
*/ */
ResCall void Host_SetWindowRefCon( Plug_WindowRef plugWindow, UInt32 value ); ResCall void Host_SetWindowRefCon(Plug_WindowRef plugWindow, UInt32 value);
/*! /*!
* @function Host_GetGlobalRefCon * @function Host_GetGlobalRefCon
*/ */
ResCall UInt32 Host_GetGlobalRefCon( Plug_PlugInRef plugRef ); ResCall UInt32 Host_GetGlobalRefCon(Plug_PlugInRef plugRef);
/*! /*!
* @function Host_SetGlobalRefCon * @function Host_SetGlobalRefCon
*/ */
ResCall void Host_SetGlobalRefCon( Plug_PlugInRef plugRef, UInt32 value ); ResCall void Host_SetGlobalRefCon(Plug_PlugInRef plugRef, UInt32 value);
/* ResCall OSStatus Host_OpenEditor( Plug_ResourceRef resource, ResOpenMode mode ); /* ResCall OSStatus Host_OpenEditor(Plug_ResourceRef resource, ResOpenMode mode);
ResCall OSStatus Host_SaveResource( Plug_ResourceRef resource ); // VERY IMPORTANT CALL! - Make when closing window 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_SetCursor(Plug_PlugInRef plugRef, Cursor *cursor);
ResCall void Host_SetCursorToID( Plug_PlugInRef plugRef, SInt16 resID ); ResCall void Host_SetCursorToID(Plug_PlugInRef plugRef, SInt16 resID);
*/ */
/*! /*!
* @function Host_GetDefaultTemplate * @function Host_GetDefaultTemplate
* @abstract Returns the default TMPL resource for the resource type passed in. * @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. * @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 * @function Host_AppendMenuToBar
* @discussion The host will track your window, and hide the menu when you are not fromtmost. * @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 * @function Host_RemoveMenuFromBar
*/ */
ResCall void Host_RemoveMenuFromBar( Plug_PlugInRef plug, SInt16 resID ); ResCall void Host_RemoveMenuFromBar(Plug_PlugInRef plug, SInt16 resID);
/*! /*!
* @function Host_UpdateMenus * @function Host_UpdateMenus
*/ */
ResCall void Host_UpdateMenus( Plug_ResourceRef resource ); ResCall void Host_UpdateMenus(Plug_ResourceRef resource);
/*! /*!
* @function Host_DisplayError * @function Host_DisplayError
* @discussion Errors the user should see * @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 * @function Host_DebugError
* @discussion Errors the user shouldn't see * @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 ***/ /*** EXPORTED FUNCTIONS ***/
extern "C" // functions beginning "Plug_" should be in your plug-in editor 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 */ /* 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 * @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 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. * @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_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_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_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 */ */ /* optional functions - only called if they are requested & found */
/* ResCallBack OSStatus Plug_UpdateMenu( Plug_PlugInRef plugRef, Plug_WindowRef windowObject ); /* 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_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_HandleMenuItem(Plug_PlugInRef plugRef, SInt16 menuID, SInt16 itemID, Boolean *handled); // name change
ResCallBack OSStatus Plug_AboutBox( Plug_PlugInRef plugRef ); ResCallBack OSStatus Plug_AboutBox(Plug_PlugInRef plugRef);
*/} */}
#endif #endif

View File

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

View File

@ -10,12 +10,12 @@
class InspectorWindow : WindowObject class InspectorWindow : WindowObject
{ {
public: public:
InspectorWindow( void ); InspectorWindow(void);
~InspectorWindow( void ); ~InspectorWindow(void);
virtual OSStatus Update( RgnHandle region = null ); // unused parameter 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 // inspector window dimentions
const UInt16 kInspectorHeaderHeight = 48 + 4; // 48 for huge icon const UInt16 kInspectorHeaderHeight = 48 + 4; // 48 for huge icon

View File

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

View File

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

View File

@ -3,80 +3,80 @@
extern globals g; extern globals g;
/*** LOAD EDITOR ***/ /*** 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 // create editor window structure and save resource to be edited into it
OSStatus error = noErr; OSStatus error = noErr;
PlugObjectPtr plug = (PlugObjectPtr) NewPtrClear( sizeof(PlugObject) ); // bug: this function calls itself, so memory leak may exist here 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 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 // load editor's library into memory
CFragConnectionID connID = null; CFragConnectionID connID = null;
Ptr mainAddr = null; Ptr mainAddr = null;
Str255 errMessage; Str255 errMessage;
error = GetSharedLibrary( libName, kPowerPCCFragArch, kLoadCFrag, &connID, &mainAddr, errMessage ); error = GetSharedLibrary(libName, kPowerPCCFragArch, kLoadCFrag, &connID, &mainAddr, errMessage);
DebugError( errMessage ); DebugError(errMessage);
if( error ) 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 DisposePtr((Ptr) plug); // only dispose if was created just now
DisplayError( "\pNo editors are available for this resource!", "\pI suggest you reinstall the program." ); DisplayError("\pNo editors are available for this resource!", "\pI suggest you reinstall the program.");
return error; 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; return error;
} }
else else
{ {
error = LoadEditor( resource, "\pTemplate Editor" ); error = LoadEditor(resource, "\pTemplate Editor");
if( error ) if(error)
error = LoadEditor( resource, "\pHex Editor" ); error = LoadEditor(resource, "\pHex Editor");
return error; return error;
} }
} }
plug->SetConnectionID( connID ); plug->SetConnectionID(connID);
// find and call InitInstance symbol // find and call InitInstance symbol
InitPlugProcPtr symAddr; InitPlugProcPtr symAddr;
CFragSymbolClass symClass; CFragSymbolClass symClass;
error = FindSymbol( connID, "\pPlug_InitInstance", (Ptr *) &symAddr, &symClass ); error = FindSymbol(connID, "\pPlug_InitInstance", (Ptr *) &symAddr, &symClass);
if( error ) if(error)
{ {
DisposePtr( (Ptr) plug ); // only dispose if was created just now DisposePtr((Ptr) plug); // only dispose if was created just now
if( g.debug ) DebugError( "\pPlug_InitInstance() could not be found." ); 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." ); else DisplayError("\pCannot load up requested editor.", "\pPlease obtain an update from the plug-in's author.");
return error; return error;
} }
error = (* symAddr)( plug, resource ); error = (* symAddr)(plug, resource);
if( error ) if(error)
{ {
DisposePtr( (Ptr) plug ); // only dispose if was created just now 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." ); 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; return error;
} }
/*** UNLOAD EDITOR ***/ /*** UNLOAD EDITOR ***/
OSStatus UnloadEditor( PlugObjectPtr plug ) OSStatus UnloadEditor(PlugObjectPtr plug)
{ {
#pragma unused( plug ) #pragma unused(plug)
OSStatus error = noErr; OSStatus error = noErr;
CFragConnectionID connID = plug->GetConnectionID(); CFragConnectionID connID = plug->GetConnectionID();
// find and call DisposeEditor symbol // find and call DisposeEditor symbol
/* DisposePlugProcPtr symAddr; /* DisposePlugProcPtr symAddr;
CFragSymbolClass symClass; CFragSymbolClass symClass;
error = FindSymbol( connID, "\pPlug_DisposeEditor", (Ptr *) &symAddr, &symClass ); error = FindSymbol(connID, "\pPlug_DisposeEditor", (Ptr *) &symAddr, &symClass);
if( error ) return error; if(error) return error;
(* symAddr)( plug ); (* symAddr)(plug);
*/ */
// close connection to editor // close connection to editor
error = CloseConnection( &connID ); error = CloseConnection(&connID);
plug->SetConnectionID( null ); plug->SetConnectionID(null);
return error; return error;
} }
@ -85,11 +85,11 @@ OSStatus UnloadEditor( PlugObjectPtr plug )
/**************************/ /**************************/
/*** ACCESSORS ***/ /*** ACCESSORS ***/
void PlugObject::SetRefCon( UInt32 value ) { refcon = value; } void PlugObject::SetRefCon(UInt32 value) { refcon = value; }
UInt32 PlugObject::GetRefCon( void ) { return refcon; } UInt32 PlugObject::GetRefCon(void) { return refcon; }
CFragConnectionID PlugObject::GetConnectionID( void ) { return connID; } CFragConnectionID PlugObject::GetConnectionID(void) { return connID; }
void PlugObject::SetConnectionID( CFragConnectionID newID ) { connID = newID; } void PlugObject::SetConnectionID(CFragConnectionID newID) { connID = newID; }
WindowObjectPtr PlugObject::GetWindowObject( void ) { return windowObj; } WindowObjectPtr PlugObject::GetWindowObject(void) { return windowObj; }
void PlugObject::SetWindowObject( WindowObjectPtr newWindowObj ) { windowObj = newWindowObj; } void PlugObject::SetWindowObject(WindowObjectPtr newWindowObj) { windowObj = newWindowObj; }
ResourceObjectPtr PlugObject::GetResourceObject( void ) { return resourceObj; } ResourceObjectPtr PlugObject::GetResourceObject(void) { return resourceObj; }
void PlugObject::SetResourceObject( ResourceObjectPtr newResourceObj ) { resourceObj = newResourceObj; } void PlugObject::SetResourceObject(ResourceObjectPtr newResourceObj) { resourceObj = newResourceObj; }

View File

@ -36,42 +36,42 @@ public:
@function GetConnectionID @function GetConnectionID
@discussion Accessor function. @discussion Accessor function.
*/ */
CFragConnectionID GetConnectionID( void ); CFragConnectionID GetConnectionID(void);
/*! /*!
@function SetConnectionID @function SetConnectionID
@discussion Accessor function. @discussion Accessor function.
*/ */
void SetConnectionID( CFragConnectionID newID ); void SetConnectionID(CFragConnectionID newID);
/*! /*!
@function GetWindowObject @function GetWindowObject
@discussion Accessor function. @discussion Accessor function.
*/ */
WindowObjectPtr GetWindowObject( void ); WindowObjectPtr GetWindowObject(void);
/*! /*!
@function SetWindowObject @function SetWindowObject
@discussion Accessor function. @discussion Accessor function.
*/ */
void SetWindowObject( WindowObjectPtr newWindowObj ); void SetWindowObject(WindowObjectPtr newWindowObj);
/*! /*!
@function GetResourceObject @function GetResourceObject
@discussion Accessor function. @discussion Accessor function.
*/ */
ResourceObjectPtr GetResourceObject( void ); ResourceObjectPtr GetResourceObject(void);
/*! /*!
@function SetResourceObject @function SetResourceObject
@discussion Accessor function. @discussion Accessor function.
*/ */
void SetResourceObject( ResourceObjectPtr newResourceObj ); void SetResourceObject(ResourceObjectPtr newResourceObj);
/*! /*!
@function SetRefCon @function SetRefCon
@discussion Accessor function. @discussion Accessor function.
*/ */
void SetRefCon( UInt32 value ); void SetRefCon(UInt32 value);
/*! /*!
@function GetRefCon @function GetRefCon
@discussion Accessor function. @discussion Accessor function.
*/ */
UInt32 GetRefCon( void ); UInt32 GetRefCon(void);
} PlugObject, *PlugObjectPtr; } PlugObject, *PlugObjectPtr;
/*! /*!
@ -80,18 +80,18 @@ public:
@param resource The resource to be edited. @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". @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 @function UnloadEditor
@discussion Unloads the given plug. @discussion Unloads the given plug.
@param plug The plug-in to be killed. @param plug The plug-in to be killed.
*/ */
OSStatus UnloadEditor( PlugObjectPtr plug ); OSStatus UnloadEditor(PlugObjectPtr plug);
/*! /*!
@typedef InitPlugProcPtr @typedef InitPlugProcPtr
@discussion The pointer to Plug_InitInstance() that FindSymbol returns. @discussion The pointer to Plug_InitInstance() that FindSymbol returns.
*/ */
typedef OSStatus (* InitPlugProcPtr)( PlugObjectPtr plug, ResourceObjectPtr resource ); typedef OSStatus (* InitPlugProcPtr)(PlugObjectPtr plug, ResourceObjectPtr resource);
#endif #endif

View File

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

View File

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

View File

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

View File

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

View File

@ -1,18 +1,45 @@
#include "Utility.h" #include "Utility.h"
extern globals g;
/**********************/ /**********************/
/* QUICKDRAW ROUTINES */ /* QUICKDRAW ROUTINES */
/**********************/ /**********************/
/*** SET COLOUR ***/ /*** 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->red = red;
colour->green = green; colour->green = green;
colour->blue = blue; 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 */ /* 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 ***/ /*** C STRING LENGTH ***/
unsigned long CStringLength( char *string ) unsigned long CStringLength(char *string)
{ {
unsigned long length; unsigned long length;
Boolean end = false; Boolean end = false;
for( length = 0; end == false; length++ ) for(length = 0; end == false; length++)
if( *(string + length) == 0x00 ) end = true; if(*(string + length) == 0x00) end = true;
return length; return length;
} }
/*** PASCAL STRING LENGTH ***/ /*** PASCAL STRING LENGTH ***/
unsigned char PStringLength( unsigned char *string ) unsigned char PStringLength(unsigned char *string)
{ {
return *string; return *string;
} }
/*** TYPE TO C 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; string[sizeof(OSType)] = 0x00;
} }
/*** TYPE TO PASCAL STRING ***/ /*** TYPE TO PASCAL STRING ***/
void TypeToPString( const OSType type, Str255 string ) void TypeToPString(const OSType type, Str255 string)
{ {
string[0] = sizeof(OSType); string[0] = sizeof(OSType);
BlockMoveData( &type, &string[1], sizeof(OSType) ); BlockMoveData(&type, &string[1], sizeof(OSType));
} }
/*** TYPE TO CORE FOUNDATION STRING ***/ /*** TYPE TO CORE FOUNDATION STRING ***/
void TypeToCFString( const OSType type, CFStringRef *string ) void TypeToCFString(const OSType type, CFStringRef *string)
{ {
char cString[5]; char cString[5];
TypeToCString( type, (char *) &cString ); TypeToCString(type, (char *) &cString);
*string = CFStringCreateWithCString( CFAllocatorGetDefault(), (char *) &cString, kCFStringEncodingMacRoman ); *string = CFStringCreateWithCString(CFAllocatorGetDefault(), (char *) &cString, kCFStringEncodingMacRoman);
} }
/*** COPY C STRING ***/ /*** COPY C STRING ***/
void CopyCString( const UInt8 *source, UInt8 *dest ) void CopyCString(const UInt8 *source, UInt8 *dest)
{ {
//#pragma warning off //#pragma warning off
while( *dest++ = *source++ ); while(*dest++ = *source++);
//#pragma warning reset //#pragma warning reset
} }
/*** COPY PASCAL STRING ***/ /*** COPY PASCAL STRING ***/
void CopyPString( const UInt8 *source, UInt8 *dest ) void CopyPString(const UInt8 *source, UInt8 *dest)
{ {
UInt8 length = *source, count; UInt8 length = *source, count;
for( count = 0; count <= length; count++ ) for(count = 0; count <= length; count++)
*dest++ = *source++; *dest++ = *source++;
} }
/*** EQUAL C STRINGS ***/ /*** EQUAL C STRINGS ***/
Boolean EqualCStrings( UInt8 *source, UInt8 *dest ) Boolean EqualCStrings(UInt8 *source, UInt8 *dest)
{ {
while( *source != 0x00 ) while(*source != 0x00)
if( *source++ != *dest++ ) return false; if(*source++ != *dest++) return false;
return true; return true;
} }
/*** EQUAL PASCAL STRINGS ***/ /*** EQUAL PASCAL STRINGS ***/
Boolean EqualPStrings( UInt8 *source, UInt8 *dest ) Boolean EqualPStrings(UInt8 *source, UInt8 *dest)
{ {
UInt8 length = *source, count; UInt8 length = *source, count;
for( count = 0; count <= length; count++ ) for(count = 0; count <= length; count++)
if( *source++ != *dest++ ) return false; if(*source++ != *dest++) return false;
return true; return true;
} }
/*** APPEND ONE PASCAL STRING ONTO ANOTHER ***/ /*** 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 numberBytes = added[0]; // length of string to be added
short totalLength = added[0] + original[0]; 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; totalLength = 255;
numberBytes = totalLength - original[0]; 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 original[0] = totalLength; // new length of original string
while( ++totalLength <= 255 ) while(++totalLength <= 255)
original[totalLength] = 0x00; // set rest of string to zero original[totalLength] = 0x00; // set rest of string to zero
} }
@ -113,29 +140,29 @@ void AppendPString( Str255 original, ConstStr255Param added )
/*****************/ /*****************/
/*** MENU ITEM ENABLE ***/ /*** 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 !TARGET_API_MAC_CARBON
if( g.systemVersion >= kMacOS85 ) if(g.systemVersion >= kMacOS85)
{ {
#endif #endif
if( enable ) EnableMenuItem( menu, item ); if(enable) EnableMenuItem(menu, item);
else DisableMenuItem( menu, item ); else DisableMenuItem(menu, item);
#if !TARGET_API_MAC_CARBON #if !TARGET_API_MAC_CARBON
} }
else else
{ {
if( enable ) EnableItem( menu, item ); if(enable) EnableItem(menu, item);
else DisableItem( menu, item ); else DisableItem(menu, item);
} }
#endif #endif
} }
/*** ENABLE MENU COMMAND ***/ /*** ENABLE MENU COMMAND ***/
void EnableCommand( MenuRef menu, MenuCommand command, Boolean enable ) void EnableCommand(MenuRef menu, MenuCommand command, Boolean enable)
{ {
if( enable ) EnableMenuCommand( menu, command ); if(enable) EnableMenuCommand(menu, command);
else DisableMenuCommand( menu, command ); else DisableMenuCommand(menu, command);
} }
/******************/ /******************/
@ -151,53 +178,53 @@ OSErr MakeRelativeAliasFile(FSSpec *targetFile, FSSpec *aliasDest)
{ {
OSErr error; OSErr error;
FInfo fndrInfo; FInfo fndrInfo;
AliasHandle theAlias = null; AliasHandle theAlias = NULL;
Boolean fileCreated = false; Boolean fileCreated = false;
SInt16 rsrc = -1; SInt16 rsrc = -1;
// set up our the alias' file information // set up our the alias' file information
error = FSpGetFInfo( targetFile, &fndrInfo ); error = FSpGetFInfo(targetFile, &fndrInfo);
if( error != noErr ) goto bail; if(error != noErr) goto bail;
if( fndrInfo.fdType == 'APPL') if(fndrInfo.fdType == 'APPL')
fndrInfo.fdType = kApplicationAliasType; fndrInfo.fdType = kApplicationAliasType;
fndrInfo.fdFlags = kIsAlias; // implicitly clear the inited bit fndrInfo.fdFlags = kIsAlias; // implicitly clear the inited bit
// create the new file // create the new file
FSpCreateResFile( aliasDest, 'TEMP', 'TEMP', smSystemScript ); FSpCreateResFile(aliasDest, 'TEMP', 'TEMP', smSystemScript);
if( (error = ResError() ) != noErr) goto bail; if((error = ResError()) != noErr) goto bail;
fileCreated = true; fileCreated = true;
// set the file information or the new file // set the file information or the new file
error = FSpSetFInfo( aliasDest, &fndrInfo ); error = FSpSetFInfo(aliasDest, &fndrInfo);
if( error != noErr ) goto bail; if(error != noErr) goto bail;
// create the alias record, relative to the new alias file // create the alias record, relative to the new alias file
error = NewAlias( aliasDest, targetFile, &theAlias ); error = NewAlias(aliasDest, targetFile, &theAlias);
if( error != noErr ) goto bail; if(error != noErr) goto bail;
// save the resource // save the resource
rsrc = FSpOpenResFile( aliasDest, fsRdWrPerm ); rsrc = FSpOpenResFile(aliasDest, fsRdWrPerm);
if( rsrc == -1) if(rsrc == -1)
{ {
error = ResError(); error = ResError();
goto bail; goto bail;
} }
UseResFile( rsrc ); UseResFile(rsrc);
AddResource( (Handle) theAlias, rAliasType, 0, aliasDest->name ); AddResource((Handle) theAlias, rAliasType, 0, aliasDest->name);
error = ResError(); error = ResError();
if( error != noErr) goto bail; if(error != noErr) goto bail;
theAlias = null; theAlias = NULL;
CloseResFile( rsrc ); CloseResFile(rsrc);
rsrc = -1; rsrc = -1;
error = ResError(); error = ResError();
if( error != noErr) goto bail; if(error != noErr) goto bail;
// done // done
return noErr; return noErr;
bail: bail:
if( rsrc != -1 ) CloseResFile( rsrc ); if(rsrc != -1) CloseResFile(rsrc);
if( fileCreated ) FSpDelete( aliasDest ); if(fileCreated) FSpDelete(aliasDest);
if( theAlias != null ) DisposeHandle( (Handle) theAlias ); if(theAlias != NULL) DisposeHandle((Handle) theAlias);
return error; return error;
} }
@ -206,15 +233,15 @@ bail:
/**********************/ /**********************/
/*** LAUNCH WEB BROWSER ***/ /*** LAUNCH WEB BROWSER ***/
OSStatus LaunchURL( char *url ) OSStatus LaunchURL(char *url)
{ {
OSStatus error = noErr; OSStatus error = noErr;
ICInstance instance; ICInstance instance;
error = ICStart( &instance, kResKnifeCreator ); error = ICStart(&instance, 'rsrc');
if( error != noErr ) return error; if(error != noErr) return error;
SInt32 start = 0, length = CStringLength( url ); SInt32 start = 0, length = CStringLength(url);
error = ICLaunchURL( instance, null, url, length, &start, &length ); error = ICLaunchURL(instance, NULL, url, length, &start, &length);
ICStop( instance ); ICStop(instance);
return error; 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_ #ifndef _ResKnife_Utility_
#define _ResKnife_Utility_ #define _ResKnife_Utility_
@ -11,55 +17,63 @@
/*! /*!
@function SetColour @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 @function CStringLength
*/ */
unsigned long CStringLength( char *string ); unsigned long CStringLength(char *string);
/*! /*!
@function PStringLength @function PStringLength
*/ */
unsigned char PStringLength( unsigned char *string ); unsigned char PStringLength(unsigned char *string);
/*! /*!
@function TypeToCString @function TypeToCString
*/ */
void TypeToCString( const OSType type, char *string ); void TypeToCString(const OSType type, char *string);
/*! /*!
@function TypeToPString @function TypeToPString
*/ */
void TypeToPString( const OSType type, Str255 string ); void TypeToPString(const OSType type, Str255 string);
/*! /*!
@function TypeToCFString @function TypeToCFString
*/ */
void TypeToCFString( const OSType type, CFStringRef *string ); void TypeToCFString(const OSType type, CFStringRef *string);
/*! /*!
@function CopyCString @function CopyCString
*/ */
void CopyCString( const UInt8 *source, UInt8 *dest ); void CopyCString(const UInt8 *source, UInt8 *dest);
/*! /*!
@function CopyPString @function CopyPString
*/ */
void CopyPString( const UInt8 *source, UInt8 *dest ); void CopyPString(const UInt8 *source, UInt8 *dest);
/*! /*!
@function EqualCStrings @function EqualCStrings
*/ */
Boolean EqualCStrings( UInt8 *source, UInt8 *dest ); Boolean EqualCStrings(UInt8 *source, UInt8 *dest);
/*! /*!
@function EqualPStrings @function EqualPStrings
*/ */
Boolean EqualPStrings( UInt8 *source, UInt8 *dest ); Boolean EqualPStrings(UInt8 *source, UInt8 *dest);
/*! /*!
@function AppendPString @function AppendPString
*/ */
void AppendPString( Str255 original, ConstStr255Param added ); void AppendPString(Str255 original, ConstStr255Param added);
/*! /*!
@function MenuItemEnable @function MenuItemEnable
*/ */
void MenuItemEnable( MenuRef menu, MenuItemIndex item, Boolean enable ); void MenuItemEnable(MenuRef menu, MenuItemIndex item, Boolean enable);
/*! /*!
@function EnableCommand @function EnableCommand
*/ */
void EnableCommand( MenuRef menu, MenuCommand command, Boolean enable ); void EnableCommand(MenuRef menu, MenuCommand command, Boolean enable);
/*! /*!
@function MakeRelativeAliasFile @function MakeRelativeAliasFile
*/ */
@ -68,6 +82,6 @@ OSErr MakeRelativeAliasFile(FSSpec *targetFile, FSSpec *aliasDest);
@function LaunchURL @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. @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 #endif

View File

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

View File

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

View File

@ -1,27 +1,38 @@
// abbreviations // abbreviations
#define null NULL #define null NULL
#if TARGET_API_MAC_CARBON #if TARGET_API_MAC_CARBON
#define qdb ScreenBounds() #define qdb ScreenBounds()
inline Rect ScreenBounds() inline Rect ScreenBounds()
{ {
Rect rect; Rect rect;
GetAvailableWindowPositioningBounds( GetMainDevice(), &rect ); GetAvailableWindowPositioningBounds(GetMainDevice(), &rect);
return rect; return rect;
} }
#else #else
#define qdb qd.screenBits.bounds #define qdb qd.screenBits.bounds
#endif #endif
// Easier constants
#define RGBColour RGBColor
// Easier API call names // Easier API call names
#define GetWindowRefCon( window ) (long) GetWRefCon( window ) #define GetWindowRefCon(window) (long) GetWRefCon(window)
#define SetWindowRefCon( window, refcon ) SetWRefCon( window, refcon ) #define SetWindowRefCon(window, refcon) SetWRefCon(window, refcon)
#define GetWindowTitle( window, string ) GetWTitle( window, string ) #define GetWindowTitle(window, string) GetWTitle(window, string)
#define SetWindowTitle( window, name ) SetWTitle( window, name ) #define SetWindowTitle(window, name) SetWTitle(window, name)
#define InvalidateRect( bounds ) InvalRect( bounds ) #define InvalidateRect(bounds) InvalRect(bounds)
#define InvalidateWindowRect( window, bounds ) (OSStatus) InvalWindowRect( window, bounds ) #define InvalidateWindowRect(window, bounds) (OSStatus) InvalWindowRect(window, bounds)
#define RectToRegion( region, rect ) RectRgn( region, rect ) #define RectToRegion(region, rect) RectRgn(region, rect)
#define NewPoint() (Point) { 0, 0 } #define NewPoint() (Point) { 0, 0 }
#define SetPoint( point, x, y ) SetPt( point, x, y ) #define SetPoint(point, x, y) SetPt(point, x, y)
#define HighlightColour( colour ) HiliteColor( colour ) /* apperance.h */
#define GetPortHighlightColour( window, colour ) GetPortHiliteColor( window, colour ) #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)