Mac OSX Build and Run!

OSX上でのプログラミングの初歩について、情報共有ができればと思います。

Carbon NavSample

今日からCarbon NavSampleにチャレンジです。
このサンプはCarbonlib 1.6 SDK含まれています。
これはファイルのアクセス用のダイアログのサンプルですが、クラシック用とOSX用があり、メニューで選択できる様になっています。
複数の種類のファイルダイアローグがあるのは良いのですが、もうOSX専用のサンプルだけにしてもらえた方が、コード量が少ない分、理解の手間が省けそうでいいのですが。
ただいま、バラして理解を行おうとしています。
確かこのサンプルについてもCarbonプログラミングガイドに解説があったと思います。

ちなみにOSX用では以下の様になります。

NavSample1.jpg



NavSample2.jpg


NavSample3.jpg


NavSample4.jpg

スポンサーサイト

Carbon BasicRAELのサンプル

今回はCarbonLib_1.6GM_SDKにあるBasicRAELのサンプルを理解しようとコードを読むと、このサンプルはnibファイルではなくリソースを使うもので、Clasiic環境が無くRESEDITが使えない人にはいまいち役に立たないサンプルであることが分かりました。

ftp://ftp.apple.com/developer/Development_Kits/CarbonLib_1.6GM_SDK.dmg

仕方がないので、自分でnib形式で使える様に改造を行ってみました。
尚、改造には入門CarbonやCarbonプログラミングガイドが役立ちました。
Carbonプログラミングガイドにはこのサンプルについての解説がP112
Chapter8 Carbon Managerにあります。

BaisicREAL


無事動いてめでたしめでたし。

CustomWindowの理解

今日はADCのサンプルプログラムにあるCustomWindowを理解しようと、コードを眺めていました。このサンプルはウインドウの形状をX型にするCarbonサンプルです。前から興味があったので、色々といじってみました。リージョンやウインドウ操作の基本が含まれており、色々と参考になりそうです。

CustomWindowサンプルへのリンク

CustomWindow


TSMTE.h アクセッサー関数

TextEditインターフェース用のテキストサービスマネージャー TSMTE.hで使用されているアクセッサー関数は以下の通りです。

/* data types*/
struct TSMTERec {
TEHandle textH;
TSMTEPreUpdateUPP preUpdateProc;
TSMTEPostUpdateUPP postUpdateProc;
long updateFlag;
long refCon;
};
typedef struct TSMTERec TSMTERec;
typedef TSMTERec * TSMTERecPtr;
typedef TSMTERecPtr * TSMTERecHandle;
#if !OPAQUE_TOOLBOX_STRUCTS
struct TSMDialogRecord {
DialogRecord fDialog;
TSMDocumentID fDocID;
TSMTERecHandle fTSMTERecH;
long fTSMTERsvd[3]; /* reserved*/
};
typedef struct TSMDialogRecord TSMDialogRecord;
typedef TSMDialogRecord * TSMDialogPtr;
typedef TSMDialogPtr TSMDialogPeek;
#endif /* !OPAQUE_TOOLBOX_STRUCTS */


Menus.h アクセッサー関数

メニューインターフェースマネージャー Menus.hで使用されているアクセッサー関数は以下の通りです。

/*******************************************************************************/
/* ・ Menu Types */
/*******************************************************************************/
typedef SInt16 MenuID;
typedef UInt16 MenuItemIndex;
typedef UInt32 MenuCommand;
#if !OPAQUE_TOOLBOX_STRUCTS
struct MenuInfo {
MenuID menuID; /* in Carbon use Get/SetMenuID*/
short menuWidth; /* in Carbon use Get/SetMenuWidth*/
short menuHeight; /* in Carbon use Get/SetMenuHeight*/
Handle menuProc; /* not supported in Carbon*/
long enableFlags; /* in Carbon use Enable/DisableMenuItem, IsMenuItemEnable*/
Str255 menuData; /* in Carbon use Get/SetMenuTitle*/
};
typedef struct MenuInfo MenuInfo;
typedef MenuInfo * MenuPtr;
typedef MenuPtr * MenuHandle;
#else
typedef struct OpaqueMenuRef* MenuRef;
/* MenuHandle is old name for MenuRef*/
typedef MenuRef MenuHandle;
#endif /* !OPAQUE_TOOLBOX_STRUCTS */

Dialogs.h アクセッサー関数

ダイアローグマネージャーインターフェース Dialogs.hで使用されているアクセッサー関数は以下の通りです。

/* DialogPtr is obsolete. Use DialogRef instead.*/
typedef DialogPtr DialogRef;
#if !OPAQUE_TOOLBOX_STRUCTS
struct DialogRecord {
WindowRecord window; /* in Carbon use GetDialogWindow or GetDialogPort*/
Handle items; /* in Carbon use Get/SetDialogItem*/
TEHandle textH; /* in Carbon use GetDialogTextEditHandle*/
SInt16 editField; /* in Carbon use SelectDialogItemText/GetDialogKeyboardFocusItem*/
SInt16 editOpen; /* not available in Carbon */
SInt16 aDefItem; /* in Carbon use Get/SetDialogDefaultItem*/
};
typedef struct DialogRecord DialogRecord;
typedef DialogRecord * DialogPeek;
#endif /* !OPAQUE_TOOLBOX_STRUCTS */


Controls.hアクセッサー関数

Controls.hで使用されているアクセッサー関数は以下の通りです。

/*******************************************************************************/
/* ・ ControlRef */
/*******************************************************************************/
#if !OPAQUE_TOOLBOX_STRUCTS
typedef struct ControlRecord ControlRecord;
typedef ControlRecord * ControlPtr;
typedef ControlPtr * ControlRef;
#else
typedef struct OpaqueControlRef* ControlRef;
#endif /* !OPAQUE_TOOLBOX_STRUCTS */

/* ControlHandle is obsolete. Use ControlRef.*/
typedef ControlRef ControlHandle;
typedef SInt16 ControlPartCode;

/*******************************************************************************/
/* ・ ControlRecord */
/*******************************************************************************/
#if !OPAQUE_TOOLBOX_STRUCTS
struct ControlRecord {
ControlRef nextControl; /* in Carbon use embedding heirarchy functions*/
WindowRef contrlOwner; /* in Carbon use GetControlOwner or EmbedControl*/
Rect contrlRect; /* in Carbon use Get/SetControlBounds*/
UInt8 contrlVis; /* in Carbon use IsControlVisible, SetControlVisibility*/
UInt8 contrlHilite; /* in Carbon use GetControlHilite, HiliteControl*/
SInt16 contrlValue; /* in Carbon use Get/SetControlValue, Get/SetControl32BitValue*/
SInt16 contrlMin; /* in Carbon use Get/SetControlMinimum, Get/SetControl32BitMinimum*/
SInt16 contrlMax; /* in Carbon use Get/SetControlMaximum, Get/SetControl32BitMaximum*/
Handle contrlDefProc; /* not supported in Carbon*/
Handle contrlData; /* in Carbon use Get/SetControlDataHandle*/
ControlActionUPP contrlAction; /* in Carbon use Get/SetControlAction*/
SInt32 contrlRfCon; /* in Carbon use Get/SetControlReference*/
Str255 contrlTitle; /* in Carbon use Get/SetControlTitle*/
};

#endif /* !OPAQUE_TOOLBOX_STRUCTS */

/*******************************************************************************/
/* ・ Auxiliary Control Record */
/*******************************************************************************/
#if !OPAQUE_TOOLBOX_STRUCTS
struct AuxCtlRec {
Handle acNext; /* not supported in Carbon*/
ControlRef acOwner; /* not supported in Carbon*/
CCTabHandle acCTable; /* not supported in Carbon*/
SInt16 acFlags; /* not supported in Carbon*/
SInt32 acReserved; /* not supported in Carbon*/
SInt32 acRefCon; /* in Carbon use Get/SetControlProperty if you need more refCons*/
};
typedef struct AuxCtlRec AuxCtlRec;
typedef AuxCtlRec * AuxCtlPtr;
typedef AuxCtlPtr * AuxCtlHandle;
#endif /* !OPAQUE_TOOLBOX_STRUCTS */

#if !OPAQUE_TOOLBOX_STRUCTS
/*
* GetAuxiliaryControlRecord()
*
* Availability:
* Mac OS X: not available
* CarbonLib: not available
* Non-Carbon CFM: in InterfaceLib 7.1 and later
*/


#endif /* !OPAQUE_TOOLBOX_STRUCTS */

MacWindows.hアクセッサー関数

MacWindows.hで使用されているアクセッサー関数は以下の通りです。
以下の通り全てがサポート、公開されている訳ではありません。

/******************************************************************************************/
/* ・ WindowRecord */
/******************************************************************************************/
#if !OPAQUE_TOOLBOX_STRUCTS
typedef struct WindowRecord WindowRecord;
typedef WindowRecord * WindowPeek;
struct WindowRecord {
GrafPort port; /* in Carbon use GetWindowPort*/
short windowKind; /* in Carbon use Get/SetWindowKind*/
Boolean visible; /* in Carbon use Hide/ShowWindow, ShowHide, IsWindowVisible*/
Boolean hilited; /* in Carbon use HiliteWindow, IsWindowHilited*/
Boolean goAwayFlag; /* in Carbon use ChangeWindowAttributes*/
Boolean spareFlag; /* in Carbon use ChangeWindowAttributes*/
RgnHandle strucRgn; /* in Carbon use GetWindowRegion*/
RgnHandle contRgn; /* in Carbon use GetWindowRegion*/
RgnHandle updateRgn; /* in Carbon use GetWindowRegion*/
Handle windowDefProc; /* not supported in Carbon */
Handle dataHandle; /* not supported in Carbon */
StringHandle titleHandle; /* in Carbon use Get/SetWTitle */
short titleWidth; /* in Carbon use GetWindowRegion */
Handle controlList; /* in Carbon use GetRootControl */
WindowPeek nextWindow; /* in Carbon use GetNextWindow */
PicHandle windowPic; /* in Carbon use Get/SetWindowPic */
long refCon; /* in Carbon use Get/SetWRefCon*/
};

#endif /* !OPAQUE_TOOLBOX_STRUCTS */

/******************************************************************************************/
/* ・ Color WindowRecord */
/******************************************************************************************/
#if !OPAQUE_TOOLBOX_STRUCTS
typedef struct CWindowRecord CWindowRecord;
typedef CWindowRecord * CWindowPeek;
struct CWindowRecord {
CGrafPort port; /* in Carbon use GetWindowPort*/
short windowKind; /* in Carbon use Get/SetWindowKind */
Boolean visible; /* in Carbon use Hide/ShowWindow, ShowHide, IsWindowVisible */
Boolean hilited; /* in Carbon use HiliteWindow, IsWindowHilited*/
Boolean goAwayFlag; /* in Carbon use ChangeWindowAttributes */
Boolean spareFlag; /* in Carbon use ChangeWindowAttributes */
RgnHandle strucRgn; /* in Carbon use GetWindowRegion */
RgnHandle contRgn; /* in Carbon use GetWindowRegion */
RgnHandle updateRgn; /* in Carbon use GetWindowRegion */
Handle windowDefProc; /* not supported in Carbon */
Handle dataHandle; /* not supported in Carbon */
StringHandle titleHandle; /* in Carbon use Get/SetWTitle */
short titleWidth; /* in Carbon use GetWindowRegion */
Handle controlList; /* in Carbon use GetRootControl */
CWindowPeek nextWindow; /* in Carbon use GetNextWindow */
PicHandle windowPic; /* in Carbon use Get/SetWindowPic */
long refCon; /* in Carbon use Get/SetWRefCon */
};

#endif /* !OPAQUE_TOOLBOX_STRUCTS */

/******************************************************************************************/
/* ・ AuxWinHandle */
/******************************************************************************************/
#if !OPAQUE_TOOLBOX_STRUCTS
typedef struct AuxWinRec AuxWinRec;
typedef AuxWinRec * AuxWinPtr;
typedef AuxWinPtr * AuxWinHandle;
struct AuxWinRec {
AuxWinHandle awNext; /* handle to next AuxWinRec, not supported in Carbon*/
WindowRef awOwner; /* not supported in Carbon*/
CTabHandle awCTable; /* color table for this window, use Get/SetWindowContentColor in Carbon*/
Handle reserved; /* not supported in Carbon*/
long awFlags; /* reserved for expansion, not supported in Carbon*/
CTabHandle awReserved; /* reserved for expansion, not supported in Carbon*/
long awRefCon; /* user constant, in Carbon use Get/SetWindowProperty if you need more refCons*/
};

#endif /* !OPAQUE_TOOLBOX_STRUCTS */


/******************************************************************************************/
/* ・ GetAuxWin */
/* */
/* GetAuxWin is not available in Carbon */
/******************************************************************************************/
#if !OPAQUE_TOOLBOX_STRUCTS
/*
* GetAuxWin()
*
* Availability:
* Mac OS X: not available
* CarbonLib: not available
* Non-Carbon CFM: in InterfaceLib 7.1 and later
*/

#endif /* !OPAQUE_TOOLBOX_STRUCTS */

OSX Carbonアクセッサー関数について

OSXではToolBoxの仕様が変わり従来公開かれていた構造体の一部が非公開となりました。これにより従来用いていた構造体から直接の値参照が行えなくなりました。
従来のソースコードをCarbon化しようとする時にエラーが生じるますが、主な原因はこの変更や非対応となったToolBox関数への対応を考慮して変換を行う必要があります。

この為、#if !OPAQUE_TOOLBOX_STRUCTSと言った条件マクロがあり、「不透明なツールボックス構造」と言った言葉で表現されています。この場合は対応しないので、このマクロ文の下にはClassic用のToolBoxが記載され、その右側にコメントでOSX専用のアクセッサー関数が記載されています。これを用いれば間接的に値が取り出せます。

例として
MacWindows.hヘッダーファイルで使用されるアクセッサーは以下の様になっています。
/*---------------------------------------------------------------------------*/
/* ・ WindowRecord */
/*---------------------------------------------------------------------------*/
#if !OPAQUE_TOOLBOX_STRUCTS
typedef struct WindowRecord WindowRecord;
typedef WindowRecord * WindowPeek;
struct WindowRecord {
GrafPort port; /* in Carbon use GetWindowPort*/
short windowKind; /* in Carbon use Get/SetWindowKind*/

//


Tool Box関連書籍

Tool Boxを理解するには 新居雅行著 Macintosh アプリケーションプログラミング上・下巻が良いと思います。1999年第3版

だだし、この本はCarbon以前のOS8 ~8.5ぐらいのClassicの内容のためOSXにそのままでは適用できないこともありますが、インサイドマックのエッセンスがつまっていています。



P1000031.jpg




P1000032.jpg



こんな本がCocoaにもあれば、最高なんですけどね。




アップルにて書かれた入門書です。OSXでプログラミングをするなら、ここからスタートすると良いと思います。

入門Carbon





中級向けの解説書です。Classic環境からCarbonへの移行等、読みこなすにはある程度経験が必要な気がします。

カーボンプログラミングガイド





C言語ではないのですが、Real BASICとFutureBASICの解説書があります。

toolboxbook.gif


REALbasicとFutureBASICで使おうToolbox最新活用テクニック
MAC POWER BOOKS
水野 貴明 (著), 重松 修 (著)
2002年

珍しい珍客

ここの山にはキボシカミキリがいたりします。今朝、部屋の網戸にとまってました。
P1000058.jpg

今日の実

鮮やかな実がなっていました。
P1000068.jpg

散歩中に見つけた今の花

何と言う花なんだろう???P1000064.jpg

夏らしく

特に意図はないのですが夏向きの大胆な背景画像に変えてまいました。
hitomiみたいなセンスがあるような気がして使ってみました。
仕事場でみたら何か言われそうですが、、、、

これだと、ソースコード集中して読めないかもね!
では。

OSX ClassicサンプルのCarbon対応(Quick Draw)

Quick DrawのClassic版サンプルをCarbon化してみました。
尚、作者の方とは連絡がつかなかったので無断となってしまいました。
(ごめんなさい)
完全非保証のサンプルです。利用者が責任を持つ場合のみ使用可能です。

以下のサンプルはフルスクリーンに描画を行うものです。


Diamond.jpg




Diamond7X ダウンロード


DiamondX ダウンロード

ToolBox用構造体(C&FB)SCRAP MANAGER

SCRAP MANAGERで使用される構造体です。CとFutureBasicのヘッダーを対応させています。

//--------------------------------------------------

/*
________________________________________________________________
CARBON SCRAP MANAGER INTERFACES
________________________________________________________________
The following interfaces are available only when compiling for
Carbon.
________________________________________________________________
*/

/*
When promising a scrap flavor, it's OK if you
don't yet know how big the flavor data will be.
In this case, just pass kScrapFlavorSizeUnknown
for the flavor data size.
*/

enum {
kScrapFlavorSizeUnknown = -1
};

/*
kScrapReservedFlavorType is a flavor type which is reserved
for use by Scrap Manager. If you pass it to Scrap Manager,
it will be rejected.
*/

enum {
kScrapReservedFlavorType = 'srft'
};

/*
We've added scrap flavor flags ala Drag Manager.

kScrapFlavorMaskNone means you want none of the flags.

kScrapFlavorSenderOnlyMask means only the process which
put the flavor on the scrap can see it. If some other
process put a flavor with this flag on the scrap,
your process will never see the flavor, so there's
no point in testing for this flag.

kScrapFlavorTranslated means the flavor was translated
from some other flavor in the scrap by Translation Manager.
Most callers should not care about this bit.
*/
enum {
kScrapFlavorMaskNone = 0x00000000,
kScrapFlavorMaskSenderOnly = 0x00000001,
kScrapFlavorMaskTranslated = 0x00000002
};

typedef UInt32 ScrapFlavorFlags;
/*
ScrapFlavorInfo describes a single flavor within
a scrap.
*/
struct ScrapFlavorInfo {
ScrapFlavorType flavorType;
ScrapFlavorFlags flavorFlags;
};
typedef struct ScrapFlavorInfo ScrapFlavorInfo;
typedef struct OpaqueScrapRef* ScrapRef;



_kScrapFlavorSizeUnknown = -1
_kScrapReservedFlavorType = _"srft"
_kScrapFlavorMaskNone = 0
_kScrapFlavorMaskSenderOnly = 1
_kScrapFlavorMaskTranslated = 2
_kScrapRefNone = _nil

#define ScrapFlavorFlags as UInt32
#define ScrapFlavorType as OSType

begin record ScrapFlavorInfo
dim flavorType as ScrapFlavorType
dim flavorFlags as ScrapFlavorFlags
end record

#define ScrapRef as UInt32
#endif

//--------------------------------------------------

ToolBox用構造体(C&FB)AEDataModel.h


//--------------------------------------------------

struct AEDesc {
DescType descriptorType;
AEDataStorage dataHandle;
};
typedef struct AEDesc AEDesc;
/* a list of AEDesc's is a special kind of AEDesc */

typedef AEDesc AEDescList;
/* AERecord is a list of keyworded AEDesc's */
typedef AEDescList AERecord;
/* an AEDesc which contains address data */
typedef AEDesc AEAddressDesc;
/* an AERecord that contains an AppleEvent, and related data types */
typedef AERecord AppleEvent;
typedef AppleEvent * AppleEventPtr;
typedef SInt16 AEReturnID;
typedef SInt32 AETransactionID;
typedef FourCharCode AEEventClass;
typedef FourCharCode AEEventID;
typedef SInt8 AEArrayType;
enum {
kAEDataArray = 0,
kAEPackedArray = 1,
kAEDescArray = 3,
kAEKeyDescArray = 4
};


enum {
kAEHandleArray = 2
};

union AEArrayData {
short kAEDataArray[1];
char kAEPackedArray[1];
Handle kAEHandleArray[1];
AEDesc kAEDescArray[1];
AEKeyDesc kAEKeyDescArray[1];
};
typedef union AEArrayData AEArrayData;
typedef AEArrayData * AEArrayDataPointer;
/**************************************************************************
These constants are used by AEMach and AEInteraction APIs. They are not
strictly part of the data format, but are declared here due to layering.
**************************************************************************/
typedef SInt16 AESendPriority;
enum {
kAENormalPriority = 0x00000000, /* post message at the end of the event queue */
kAEHighPriority = 0x00000001 /* post message at the front of the event queue (same as nAttnMsg) */
};


typedef SInt32 AESendMode;
enum {
kAENoReply = 0x00000001, /* sender doesn't want a reply to event */
kAEQueueReply = 0x00000002, /* sender wants a reply but won't wait */
kAEWaitReply = 0x00000003, /* sender wants a reply and will wait */
kAEDontReconnect = 0x00000080, /* don't reconnect if there is a sessClosedErr from PPCToolbox */
kAEWantReceipt = 0x00000200, /* (nReturnReceipt) sender wants a receipt of message */
kAENeverInteract = 0x00000010, /* server should not interact with user */
kAECanInteract = 0x00000020, /* server may try to interact with user */
kAEAlwaysInteract = 0x00000030, /* server should always interact with user where appropriate */
kAECanSwitchLayer = 0x00000040, /* interaction may switch layer */
kAEDontRecord = 0x00001000, /* don't record this event - available only in vers 1.0.1 and greater */
kAEDontExecute = 0x00002000, /* don't send the event for recording - available only in vers 1.0.1 and greater */
kAEProcessNonReplyEvents = 0x00008000 /* allow processing of non-reply events while awaiting synchronous AppleEvent reply */
};


/* Constants for timeout durations */
enum {
kAEDefaultTimeout = -1, /* timeout value determined by AEM */
kNoTimeOut = -2 /* wait until reply comes back, however long it takes */
};

Apple Event Descriptor Recordで使用される構造体です。CとFutureBasicのヘッダーを対応させています。



// Apple Event Descriptor Record

begin record AEDesc
dim descType as long
dim dataHandle as Handle
end record

#define AEDescList as AEDesc
#define AERecord as AEDesc
#define AppleEvent as AEDesc
#define AESendPriority as short
#define AESendMode as long

//--------------------------------------------------

ToolBox用構造体(C&FB)TextEdit.h

TextEditで使用される構造体です。CとFutureBasicのヘッダーを対応させています。

//--------------------------------------------------

struct TERec {
Rect destRect;
Rect viewRect;
Rect selRect;
short lineHeight;
short fontAscent;
Point selPoint;
short selStart;
short selEnd;
short active;
WordBreakUPP wordBreak; /* NOTE: This field is ignored on non-Roman systems and on Carbon (see IM-Text 2-60) */
TEClickLoopUPP clickLoop;
long clickTime;
short clickLoc;
long caretTime;
short caretState;
short just;
short teLength;
Handle hText;
long hDispatchRec; /* added to replace recalBack & recalLines. it's a handle anyway */
short clikStuff;
short crOnly;
short txFont;
StyleField txFace; /*StyleField occupies 16-bits, but only first 8-bits are used*/
short txMode;
short txSize;
GrafPtr inPort;
HighHookUPP highHook;
CaretHookUPP caretHook;
short nLines;
short lineStarts[16001];
};


typedef struct TERec TERec;
typedef TERec * TEPtr;
typedef TEPtr * TEHandle;


begin record TERec
dim destRect as Rect
dim viewRect as Rect
dim selRect as Rect
dim lineHeight as short
dim fontAscent as short
dim selPoint as point
dim selStart as short
dim selEnd as short
dim active as short
dim WordBreak as proc
dim clickLoop as proc
dim clickTime as long
dim clickLoc as short
dim caretTime as long
dim caretState as short
dim just as short
dim teLength as short
dim hText as Handle
dim hDispatchRec as long
dim clikStuff as short
dim crOnly as short
dim txFont as short
dim txFace as char // really leads to style record
dim txStyleSpare as char
dim txMode as short
dim txSize as short
dim inPort as Ptr
dim highHook as proc
dim caretHook as proc
dim nLines as short
begin union
dim lineStarts;0
dim lineStartTable[_maxInt] as short
end union
end record

//--------------------------------------------------

ToolBox用構造体(C&FB)Finder.h

Finderで使用される構造体です。CとFutureBasicのヘッダーを対応させています。

//--------------------------------------------------

/*------------------------------------------------------------------------*/
/*
The following data structures are here for compatibility.
Use the new data structures replacing them if possible (i.e. FileInfo
instead of FInfo, etc...)
*/
/*------------------------------------------------------------------------*/
/* File info */
/*
IMPORTANT:
In MacOS 8, the fdFldr field has become reserved for the Finder.
*/
struct FInfo {
OSType fdType; /* The type of the file */
OSType fdCreator; /* The file's creator */
UInt16 fdFlags; /* Flags ex. kHasBundle, kIsInvisible, etc. */
Point fdLocation; /* File's location in folder. */
/* If set to {0, 0}, the Finder will place the item automatically */
SInt16 fdFldr; /* Reserved (set to 0) */
};
typedef struct FInfo FInfo;

begin record FInfo
dim fdType as OSType/*the type of the file*/
dim fdCreator as OSType/*file's creator*/
dim fdFlags as unsigned short/*flags ex. hasbundle,invisible,locked, etc.*/
dim fdLocation as point/*file's location in folder -- pixel position as point*/
dim fdFldr as short/*folder containing file*/
end record


/*------------------------------------------------------------------------*/
/*
The following data structures are binary compatible with FInfo, DInfo,
FXInfo and DXInfo but represent the Mac OS 8 semantic of the fields.
Use these data structures preferably to FInfo, etc...
*/
/*------------------------------------------------------------------------*/

struct FileInfo {
OSType fileType; /* The type of the file */
OSType fileCreator; /* The file's creator */
UInt16 finderFlags; /* ex: kHasBundle, kIsInvisible... */
Point location; /* File's location in the folder */
/* If set to {0, 0}, the Finder will place the item automatically */
UInt16 reservedField; /* (set to 0) */
};
typedef struct FileInfo FileInfo;

//--------------------------------------------------

ToolBox用構造体(C&FB)Events.h

Events.hで使用される構造体です。CとFutureBasicのヘッダーを対応させています。

//--------------------------------------------------

struct EventRecord {
EventKind what;
UInt32 message;
UInt32 when;
Point where;
EventModifiers modifiers;
};
typedef struct EventRecord EventRecord;


begin record EventRecord
dim what as short
dim message as UInt32
dim when as UInt32
dim where as point
dim modifiers as short
end record

ToolBox用構造体(C&FB)Menus.h

Menus.hで使用される構造体です。CとFutureBasicのヘッダーを対応させています。
//--------------------------------------------------

/*
* MenuTrackingData
*
* Summary:
* The MenuTrackingData structure contains information about a menu
* currently being displayed. It is used with the
* GetMenuTrackingData API.
*/
struct MenuTrackingData {
MenuRef menu;
MenuItemIndex itemSelected;
MenuItemIndex itemUnderMouse;
Rect itemRect;
SInt32 virtualMenuTop;
SInt32 virtualMenuBottom;
};
typedef struct MenuTrackingData MenuTrackingData;
typedef MenuTrackingData * MenuTrackingDataPtr;


begin record MenuTrackingData
dim menu as MenuRef
dim itemSelected as MenuItemIndex
dim itemUnderMouse as MenuItemIndex
dim itemRect as Rect
dim virtualMenuTop as SInt32
dim virtualMenuBottom as SInt32
end record
#endif

//--------------------------------------------------

ToolBox用構造体(C&FB)QuickDrawText.h

Quick DrawTextで使用される構造体です。CとFutureBasicのヘッダーを対応させています。

//--------------------------------------------------

struct FontInfo {
short ascent;
short descent;
short widMax;
short leading;
};
typedef struct FontInfo FontInfo;

begin record FontInfo
dim as short ascent
dim as short descent
dim as short widMax
dim as short leading
end record

//--------------------------------------------------

typedef short CharParameter;
enum {
normal = 0,
bold = 1,
italic = 2,
underline = 4,
outline = 8,
shadow = 0x10,
condense = 0x20,
extend = 0x40
};

typedef unsigned char Style;
typedef short StyleParameter;
typedef Style StyleField;


#define StyleField as unsigned char

//--------------------------------------------------

struct TextStyle {
short tsFont; /*font (family) number*/
StyleField tsFace; /*StyleField occupies 16-bits, but only first 8-bits are used*/
short tsSize; /*size in point*/
RGBColor tsColor; /*absolute (RGB) color*/
};
typedef struct TextStyle TextStyle;
typedef TextStyle * TextStylePtr;
typedef TextStylePtr * TextStyleHandle;
typedef short TEIntHook;


begin record TextStyle
dim as short tsFont/*font (family) number*/
dim as StyleField tsFace/*character Style*/
dim as byte tsFiller
dim as short tsSize/*size in point*/
dim as RGBColor tsColor/*absolute (RGB) color*/
end record

//--------------------------------------------------

ToolBox用構造体(C&FB)MacTypes.h

MacTypes.hで指定される構造体です。CとFutureBasicのヘッダーを対応させています。

//--------------------------------------------------

typedef signed long long SInt64;

begin record SInt64
begin union
dim hiLong as long
dim hi as long
end union
begin union
dim loLong as long
dim lo as long
end union
end record

//--------------------------------------------------

typedef struct wide wide;
struct UnsignedWide {
UInt32 hi;
UInt32 lo;
};
typedef struct UnsignedWide UnsignedWide;

begin record UnsignedWide
dim as unsigned long hi, lo
end record

//--------------------------------------------------

typedef unsigned long long UInt64;

#define UInt64 as UnsignedWide

//--------------------------------------------------

ToolBox用構造体(C&FB)QuickDraw

Quick Drawで使用される構造体です。CとFutureBasicのヘッダーを対応させています。
//--------------------------------------------------

struct Pattern {
UInt8 pat[8];
};
typedef struct Pattern Pattern;

begin record Pattern
dim pat`(7)
end record

//--------------------------------------------------

struct PenState {
Point pnLoc;
Point pnSize;
short pnMode;
Pattern pnPat;
};
typedef struct PenState PenState;

begin record PenState
dim pnLoc as point
dim pnSize as point
dim pnMode as short
dim pnPat as Pattern
end record

//--------------------------------------------------

struct RGBColor {
unsigned short red; /*magnitude of red component*/
unsigned short green; /*magnitude of green component*/
unsigned short blue; /*magnitude of blue component*/
};
typedef struct RGBColor RGBColor;

begin record RGBColor
dim red as unsigned short
dim green as unsigned short
dim blue as unsigned short
end record

//--------------------------------------------------

struct Rect {
short top;
short left;
short bottom;
short right;
};
typedef struct Rect Rect;

typedef Rect * RectPtr;

begin record Rect
dim top as short
dim left as short
dim bottom as short
dim right as short
end record

//--------------------------------------------------

struct Picture {
short picSize;
Rect picFrame;
};
typedef struct Picture Picture;

typedef Picture * PicPtr;
typedef PicPtr * PicHandle;

begin record Picture
dim picSize as short
dim picFrame as Rect
end record

//--------------------------------------------------

struct PixMap {
Ptr baseAddr; /*pointer to pixels*/
short rowBytes; /*offset to next line*/
Rect bounds; /*encloses bitmap*/
short pmVersion; /*pixMap version number*/
short packType; /*defines packing format*/
long packSize; /*length of pixel data*/
Fixed hRes; /*horiz. resolution (ppi)*/
Fixed vRes; /*vert. resolution (ppi)*/
short pixelType; /*defines pixel type*/
short pixelSize; /*# bits in pixel*/
short cmpCount; /*# components in pixel*/
short cmpSize; /*# bits per component*/
#if OLDPIXMAPSTRUCT
long planeBytes; /*offset to next plane*/
CTabHandle pmTable; /*color map for this pixMap*/
long pmReserved;
#else
OSType pixelFormat; /*fourCharCode representation*/
CTabHandle pmTable; /*color map for this pixMap*/
void* pmExt; /*Handle to pixMap extension*/
#endif
};
typedef struct PixMap PixMap;
typedef PixMap * PixMapPtr;
typedef PixMapPtr * PixMapHandle;


begin record PixMap
dim baseAddr as Ptr//Ptr to pixels
dim rowBytes as short//offset to next line
dim bounds as Rect//encloses bitmap
dim pmVersion as short//pixMap version number
dim packType as short//defines packing format
dim packSize as long//length of pixel data
dim hRes as Fixed//horiz. resolution (ppi)
dim vRes as Fixed//vert. resolution (ppi)
dim pixelType as short//defines pixel type
dim pixelSize as short//# bits in pixel
dim cmpCount as short//# components in pixel
dim cmpSize as short//# bits per component
dim planeBytes as long//offset to next plane
dim pmTable as Handle//・・CTabHandle - color map for this pixMap
dim pmReserved as long//for future use. MUST BE 0
end record

#define PixMapHandle as Handle// to PixMap
#define PixPatHandle as handle

//--------------------------------------------------

#ifndef OLDGDEVICESTRUCT
#if TARGET_API_MAC_OS8
#define OLDGDEVICESTRUCT 1
#else
#define OLDGDEVICESTRUCT 0
#endif /* TARGET_API_MAC_OS8 */

#endif /* !defined(OLDGDEVICESTRUCT) */


typedef struct GDevice GDevice;
typedef GDevice * GDPtr;
typedef GDPtr * GDHandle;

struct GDevice {
short gdRefNum; /*driver's unit number*/
short gdID; /*client ID for search procs*/
short gdType; /*fixed/CLUT/direct*/
ITabHandle gdITable; /*Handle to inverse lookup table*/
short gdResPref; /*preferred resolution of GDITable*/
SProcHndl gdSearchProc; /*search proc list head*/
CProcHndl gdCompProc; /*complement proc list*/
short gdFlags; /*grafDevice flags word*/
PixMapHandle gdPMap; /*describing pixMap*/
long gdRefCon; /*reference value*/
GDHandle gdNextGD; /*GDHandle Handle of next gDevice*/
Rect gdRect; /* device's bounds in global coordinates*/
long gdMode; /*device's current mode*/
short gdCCBytes; /*depth of expanded cursor data*/
short gdCCDepth; /*depth of expanded cursor data*/
Handle gdCCXData; /*Handle to cursor's expanded data*/
Handle gdCCXMask; /*Handle to cursor's expanded mask*/
#if OLDGDEVICESTRUCT
long gdReserved; /*future use. MUST BE 0*/
#else
Handle gdExt; /*QuickTime 3.0 private info*/
#endif
};


begin record GDevice
dim gdRefNum as short//driver's unit number
dim gdID as short//client ID for search procs
dim gdType as short//fixed/CLUT/direct
dim gdITable as Handle//ITabHandle - Handle to inverse lookup table
dim gdResPref as short//preferred resolution of GDITable
dim gdSearchProc as Handle//SProcHndl - search proc list head
dim gdCompProc as Handle//CProcHndl - complement proc list
dim gdFlags as short//grafDevice flags word
dim gdPMap as PixMapHandle//PixMapHandle - describing pixMap
dim gdRefCon as long//reference value
dim gdNextGD as Handle//GDHandle Handle of next gDevice
dim gdRect as Rect//device's bounds in global coordinates
dim gdMode as long//device's current mode
dim gdCCBytes as short//depth of expanded cursor data
dim gdCCDepth as short//depth of expanded cursor data
dim gdCCXData as Handle//Handle to cursor's expanded data
dim gdCCXMask as Handle//Handle to cursor's expanded mask
dim gdReserved as long//future use. MUST BE 0
end record

#define GDHandle as Handle// to GDevice'Date

//--------------------------------------------------

struct BitMap {
Ptr baseAddr;
short rowBytes;
Rect bounds;
};
typedef struct BitMap BitMap;
typedef BitMap * BitMapPtr;
typedef BitMapPtr * BitMapHandle;


begin record BitMap
dim baseAddr as Ptr
dim rowBytes as short
dim bounds as Rect
end record

//--------------------------------------------------

#if CarbonLib and def _opaqueStructures // may help pick up some illegal dereferencing
begin record Region
end record

//--------------------------------------------------

#if !OPAQUE_TOOLBOX_STRUCTS
struct GrafPort {
short device; /* not available in Carbon*/
BitMap portBits; /* in Carbon use GetPortBitMapForCopyBits or IsPortColor*/
Rect portRect; /* in Carbon use Get/SetPortBounds*/
RgnHandle visRgn; /* in Carbon use Get/SetPortVisibleRegion*/
RgnHandle clipRgn; /* in Carbon use Get/SetPortClipRegion*/
Pattern bkPat; /* not available in Carbon all GrafPorts are CGrafPorts*/
Pattern fillPat; /* not available in Carbon all GrafPorts are CGrafPorts*/
Point pnLoc; /* in Carbon use GetPortPenLocation or MoveTo*/
Point pnSize; /* in Carbon use Get/SetPortPenSize*/
short pnMode; /* in Carbon use Get/SetPortPenMode*/
Pattern pnPat; /* not available in Carbon all GrafPorts are CGrafPorts*/
short pnVis; /* in Carbon use GetPortPenVisibility or Show/HidePen*/
short txFont; /* in Carbon use GetPortTextFont or TextFont*/
StyleField txFace; /* in Carbon use GetPortTextFace or TextFace*/
/*StyleField occupies 16-bits, but only first 8-bits are used*/
short txMode; /* in Carbon use GetPortTextMode or TextMode*/
short txSize; /* in Carbon use GetPortTextSize or TextSize*/
Fixed spExtra; /* in Carbon use GetPortSpExtra or SpaceExtra*/
long fgColor; /* not available in Carbon */
long bkColor; /* not available in Carbon*/
short colrBit; /* not available in Carbon*/
short patStretch; /* not available in Carbon*/
Handle picSave; /* in Carbon use IsPortPictureBeingDefined*/
Handle rgnSave; /* not available in Carbon*/
Handle polySave; /* not available in Carbon*/
QDProcsPtr grafProcs; /* not available in Carbon all GrafPorts are CGrafPorts*/
};
typedef struct GrafPort GrafPort;
typedef GrafPort * GrafPtr;
/*
* This set of definitions "belongs" in Windows.
* But, there is a circularity in the headers where Windows includes Controls and
* Controls includes Windows. To break the circle, the information
* needed by Controls is moved from Windows to Quickdraw.
*/
typedef GrafPtr WindowPtr;
typedef WindowPtr DialogPtr;
#else
typedef struct OpaqueWindowPtr* WindowPtr;
typedef struct OpaqueDialogPtr* DialogPtr;
typedef struct OpaqueGrafPtr* GrafPtr;
#endif /* !OPAQUE_TOOLBOX_STRUCTS */

typedef WindowPtr WindowRef;


begin record cGrafPort// {1/23/05} b232 STAZ
dim device as int// device ID for font selection
dim portPixMap as PixMapHandle// handle to PixMap record
dim portVersion as Integer//highest 2 bits always set
dim grafVars as Handle//handle to a GrafVars record
dim chExtra as Integer//added width for nonspace characters
dim pnLocHFrac as Integer//pen fraction
dim portRect as Rect//port rectangle
dim visRgn as RgnHandle//visible region
dim clipRgn as RgnHandle//clipping region
dim bkPixPat as PixPatHandle//background pattern
dim rgbFgColor as RGBColor//requested foreground color
dim rgbBkColor as RGBColor//requested background color
dim pnLoc as Point//pen location
dim pnSize as Point//pen size
dim pnMode as Integer//pattern mode
dim pnPixPat as PixPatHandle//pen pattern
dim fillPixPat as PixPatHandle//fill pattern
dim pnVis as Integer//pen visibility
dim txFont as Integer//font number for text
dim txFace as Style//text's font style
dim txFaceFiller as byte//fb impropperly defines this
dim txMode as Integer//source mode for text
dim txSize as Integer//font size for text
dim spExtra as Fixed//added width for space characters
dim fgColor as LongInt//actual foreground color
dim bkColor as LongInt//actual background color
dim colrBit as Integer//plane being drawn
dim patStretch as Integer//used internally
dim picSave as Handle//picture being saved, used internally
dim rgnSave as Handle//region being saved, used internally
dim polySave as Handle//polygon being saved, used internally
dim grafProcs as CQDProcsPtr//low-level drawing routines
end record

begin record CWindowRecord
end record

begin record ControlRecord
end record


//------------------------------------