mirror of
https://github.com/nickshanks/ResKnife.git
synced 2024-06-03 01:29:40 +00:00
Merge Carbon formatting and whitespace changes from a 2007 branch into the main branch.
This commit is contained in:
commit
4948b1de3f
|
@ -260,20 +260,22 @@ OSStatus InitGlobals( void )
|
|||
error = Gestalt(gestaltDragMgrAttr, &result);
|
||||
if(!error) {
|
||||
g.dragAvailable = (Boolean) (result & (1 << gestaltDragMgrPresent));
|
||||
g.translucentDrag = (Boolean) (result & (1 << gestaltDragMgrHasImageSupport)); }
|
||||
else {
|
||||
g.translucentDrag = (Boolean) (result & (1 << gestaltDragMgrHasImageSupport));
|
||||
} else {
|
||||
g.dragAvailable = false;
|
||||
g.translucentDrag = false; }
|
||||
g.translucentDrag = false;
|
||||
}
|
||||
|
||||
// check appearance availablilty
|
||||
result = null;
|
||||
error = Gestalt(gestaltAppearanceAttr, &result);
|
||||
if(!error) {
|
||||
g.appearanceAvailable = (Boolean) (result & (1 << gestaltAppearanceExists));
|
||||
g.useAppearance = g.appearanceAvailable; } // assume if user has Appearence, s/he wants to use it
|
||||
else {
|
||||
g.useAppearance = g.appearanceAvailable; // assume if user has Appearence, s/he wants to use it
|
||||
} else {
|
||||
g.appearanceAvailable = false;
|
||||
g.useAppearance = false; }
|
||||
g.useAppearance = false;
|
||||
}
|
||||
if(g.useAppearance) RegisterAppearanceClient(); // register such with the OS
|
||||
|
||||
// check nav services availablilty
|
||||
|
@ -286,10 +288,11 @@ OSStatus InitGlobals( void )
|
|||
error = Gestalt(gestaltWindowMgrAttr, &result);
|
||||
if(!error) {
|
||||
g.windowMgrAvailable = (Boolean) (result & (1 << gestaltWindowMgrPresentBit));
|
||||
g.extendedWindowAttr = (Boolean) (result & (1 << gestaltExtendedWindowAttributes)); }
|
||||
else {
|
||||
g.extendedWindowAttr = (Boolean) (result & (1 << gestaltExtendedWindowAttributes));
|
||||
} else {
|
||||
g.windowMgrAvailable = false;
|
||||
g.extendedWindowAttr = false; }
|
||||
g.extendedWindowAttr = false;
|
||||
}
|
||||
|
||||
UpdateMenus(null);
|
||||
#endif
|
||||
|
@ -401,7 +404,8 @@ pascal OSErr ParseAppleEvents( const AppleEvent *event, AppleEvent *reply, SInt3
|
|||
#if TARGET_API_MAC_CARBON
|
||||
DisplayOpenDialog();
|
||||
#else
|
||||
if( g.useNavServices ) DisplayOpenDialog();
|
||||
if(g.useNavServices)
|
||||
DisplayOpenDialog();
|
||||
else DisplayStandardFileOpenDialog();
|
||||
#endif
|
||||
break;
|
||||
|
@ -413,8 +417,10 @@ pascal OSErr ParseAppleEvents( const AppleEvent *event, AppleEvent *reply, SInt3
|
|||
#if TARGET_API_MAC_CARBON
|
||||
AppleEventSendSelf(kCoreEventClass, kAEOpenApplication, list);
|
||||
#else
|
||||
if( g.useAppleEvents ) AppleEventSendSelf( kCoreEventClass, kAEOpenApplication, list );
|
||||
else if( g.useNavServices ) DisplayOpenDialog();
|
||||
if(g.useAppleEvents)
|
||||
AppleEventSendSelf(kCoreEventClass, kAEOpenApplication, list);
|
||||
else if(g.useNavServices)
|
||||
DisplayOpenDialog();
|
||||
else DisplayStandardFileOpenDialog();
|
||||
#endif
|
||||
}
|
||||
|
@ -753,7 +759,8 @@ pascal OSStatus CarbonEventParseMenuSelection( EventHandlerCallRef callRef, Even
|
|||
break;
|
||||
|
||||
case kMenuCommandOpenFile:
|
||||
if( g.useSheets ) error = DisplayModelessGetFileDialog();
|
||||
if(g.useSheets)
|
||||
error = DisplayModelessGetFileDialog();
|
||||
else error = DisplayOpenDialog();
|
||||
break;
|
||||
|
||||
|
@ -862,7 +869,8 @@ OSStatus ParseMenuSelection( UInt16 menu, UInt16 item )
|
|||
break;
|
||||
|
||||
case kFileMenuOpenFileItem:
|
||||
if( g.useNavServices ) DisplayOpenDialog();
|
||||
if(g.useNavServices)
|
||||
DisplayOpenDialog();
|
||||
else DisplayStandardFileOpenDialog();
|
||||
break;
|
||||
|
||||
|
@ -1065,8 +1073,7 @@ OSStatus ShowAboutBox( void )
|
|||
WindowRef window = null;
|
||||
if(g.useAppearance && g.systemVersion >= kMacOS8)
|
||||
window = GetNewCWindow(kFileWindow8, null, kFirstWindowOfClass);
|
||||
else
|
||||
window = GetNewCWindow( kFileWindow7, null, kFirstWindowOfClass );
|
||||
else window = GetNewCWindow(kFileWindow7, null, kFirstWindowOfClass);
|
||||
if(window == null) return paramErr;
|
||||
PicHandle picture = (PicHandle) GetPicture(128);
|
||||
SetWindowPic(window, picture);
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#include "Utility.h"
|
||||
extern globals g;
|
||||
|
||||
/**********************/
|
||||
/* QUICKDRAW ROUTINES */
|
||||
|
@ -13,6 +12,34 @@ void SetColour( RGBColor *colour, UInt16 red, UInt16 green, UInt16 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 */
|
||||
|
||||
/*******************/
|
||||
|
@ -151,7 +178,7 @@ OSErr MakeRelativeAliasFile(FSSpec *targetFile, FSSpec *aliasDest)
|
|||
{
|
||||
OSErr error;
|
||||
FInfo fndrInfo;
|
||||
AliasHandle theAlias = null;
|
||||
AliasHandle theAlias = NULL;
|
||||
Boolean fileCreated = false;
|
||||
SInt16 rsrc = -1;
|
||||
|
||||
|
@ -186,7 +213,7 @@ OSErr MakeRelativeAliasFile(FSSpec *targetFile, FSSpec *aliasDest)
|
|||
AddResource((Handle) theAlias, rAliasType, 0, aliasDest->name);
|
||||
error = ResError();
|
||||
if(error != noErr) goto bail;
|
||||
theAlias = null;
|
||||
theAlias = NULL;
|
||||
CloseResFile(rsrc);
|
||||
rsrc = -1;
|
||||
error = ResError();
|
||||
|
@ -197,7 +224,7 @@ OSErr MakeRelativeAliasFile(FSSpec *targetFile, FSSpec *aliasDest)
|
|||
bail:
|
||||
if(rsrc != -1) CloseResFile(rsrc);
|
||||
if(fileCreated) FSpDelete(aliasDest);
|
||||
if( theAlias != null ) DisposeHandle( (Handle) theAlias );
|
||||
if(theAlias != NULL) DisposeHandle((Handle) theAlias);
|
||||
return error;
|
||||
}
|
||||
|
||||
|
@ -210,11 +237,11 @@ OSStatus LaunchURL( char *url )
|
|||
{
|
||||
OSStatus error = noErr;
|
||||
ICInstance instance;
|
||||
error = ICStart( &instance, kResKnifeCreator );
|
||||
error = ICStart(&instance, 'rsrc');
|
||||
if(error != noErr) return error;
|
||||
|
||||
SInt32 start = 0, length = CStringLength(url);
|
||||
error = ICLaunchURL( instance, null, url, length, &start, &length );
|
||||
error = ICLaunchURL(instance, NULL, url, length, &start, &length);
|
||||
ICStop(instance);
|
||||
return error;
|
||||
}
|
|
@ -1,4 +1,10 @@
|
|||
#include "ResKnife.h"
|
||||
#if !TARGET_API_MAC_OS8
|
||||
#if defined(__APPLE_CC__) // compiling with gcc
|
||||
#include <Carbon/Carbon.h>
|
||||
#else // compiling with CodeWarrior, __MWERKS__
|
||||
#include <Carbon.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef _ResKnife_Utility_
|
||||
#define _ResKnife_Utility_
|
||||
|
@ -12,6 +18,14 @@
|
|||
@function SetColour
|
||||
*/
|
||||
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
|
||||
*/
|
||||
|
|
|
@ -13,6 +13,9 @@
|
|||
#define qdb qd.screenBits.bounds
|
||||
#endif
|
||||
|
||||
// Easier constants
|
||||
#define RGBColour RGBColor
|
||||
|
||||
// Easier API call names
|
||||
#define GetWindowRefCon(window) (long) GetWRefCon(window)
|
||||
#define SetWindowRefCon(window, refcon) SetWRefCon(window, refcon)
|
||||
|
@ -23,5 +26,13 @@
|
|||
#define RectToRegion(region, rect) RectRgn(region, rect)
|
||||
#define NewPoint() (Point) { 0, 0 }
|
||||
#define SetPoint(point, x, y) SetPt(point, x, y)
|
||||
/* apperance.h */
|
||||
#define SetThemeTextColour(c, d, cd) (OSStatus) SetThemeTextColor(c, d, cd)
|
||||
#define IsThemeInColour(d, cd) (Boolean) IsThemeInColor(d, cd)
|
||||
#define GetThemeAccentColours(out) (OSStatus) GetThemeAccentColors(out)
|
||||
#define SetThemeTextColourForWindow(w, a, d, cd) (OSStatus) SetThemeTextColorForWindow(w, a, d, cd)
|
||||
#define GetThemeBrushAsColour(b, d, cd, out) (OSStatus) GetThemeBrushAsColor(b, d, cd, out)
|
||||
#define GetThemeTextColour(c, d, cd, out) (OSStatus) GetThemeTextColor(c, d, cd, out)
|
||||
/* quickdraw.h */
|
||||
#define HighlightColour(colour) HiliteColor(colour)
|
||||
#define GetPortHighlightColour(window, colour) GetPortHiliteColor(window, colour)
|
||||
|
|
Loading…
Reference in New Issue
Block a user