home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.mactech.com 2010
/
ftp.mactech.com.tar
/
ftp.mactech.com
/
macintosh-c
/
macc-carbon-demos-nonbinhex.sit
/
macc-carbon-demos-nonbinhex
/
chap26-demo
/
MLTETextEditor.h
< prev
next >
Wrap
Text File
|
2001-05-31
|
7KB
|
168 lines
// *******************************************************************************************
// MTLETextEditor.h CLASSIC EVENT MODEL
// *******************************************************************************************
//
// This program demonstrates the use of the Multilingual Text Engine API to create a basic
// multi-styled text editor. New documents created by the program are created and saved as
// Textension ('txtn') documents. Existing 'TEXT' documents and Unicode ('utxt') documents
// are saved in the original format. In the case of 'TEXT' documents, style information is
// saved in a 'styl' resource.
//
// The program utilises the following resources:
//
// • A 'plst' resource.
//
// • An 'MBAR' resource, and 'MENU' resources for Apple, File, Edit, Size, Style, Colour,
// and Justification (preload, non-purgeable).
//
// • A 'WIND' resource (purgeable) (initially not visible).
//
// • A 'STR ' resource (purgeable) containing the "missing application name" string, which is
// copied to all document files created by the program.
//
// • 'STR#' resources (purgeable) containing error strings, the application's name (for
// certain Navigation Services functions), and strings for the Edit menu Undo and Redo
// items.
//
// • A 'kind' resource (purgeable) describing file types, which is used by Navigation
// Services to build the native file types section of the Show pop-up menu in the Open
// dialog box.
//
// • An 'open' resource (purgeable) containing the file type list for the Open dialog box.
//
// • The 'BNDL' resource (non-purgeable), 'FREF' resources (non-purgeable), signature
// resource (non-purgeable), and icon family resources (purgeable), required to support the
// built application.
//
// • A 'SIZE' resource with the acceptSuspendResumeEvents, canBackground,
// doesActivateOnFGSwitch, and isHighLevelEventAware flags set.
//
// *******************************************************************************************
// ………………………………………………………………………………………………………………………………………………………………………………………………………………………… includes
#include <Carbon.h>
// …………………………………………………………………………………………………………………………………………………………………………………………………………………………… defines
#define rMenubar 128
#define mAppleApplication 128
#define iAbout 1
#define mFile 129
#define iNew 1
#define iOpen 2
#define iClose 4
#define iSave 5
#define iSaveAs 6
#define iRevert 7
#define iPageSetup 9
#define iPrint 10
#define iQuit 12
#define mEdit 130
#define iUndo 1
#define iRedo 2
#define iCut 4
#define iCopy 5
#define iPaste 6
#define iClear 7
#define iSelectAll 8
#define mFont 131
#define mSize 132
#define iTwelve 4
#define mStyle 133
#define iPlain 1
#define iBold 3
#define iUnderline 5
#define mColour 134
#define iBlack 4
#define iColourPicker 6
#define mJustification 135
#define iDefault 1
#define iLeft 2
#define iForceFull 6
#define mWindow 136
#define mFirstHierarchical 160
#define rNewWindow 128
#define rAboutDialog 128
#define rErrorStrings 128
#define eInstallHandler 1000
#define eMaxWindows 1001
#define eCantFindFinderProcess 1002
#define rMiscellaneousStrings 129
#define sApplicationName 1
#define rOpenResource 128
#define kMaxWindows 8
#define kOpen 0
#define kPrint 1
#define kFileCreator 'bbJk'
#define MAX_UINT32 0xFFFFFFFF
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define topLeft(r) (((Point *) &(r))[0])
#define kATSUCGContextTag 32767L
// …………………………………………………………………………………………………………………………………………………………………………………………… function prototypes
void main (void);
void doPreliminaries (void);
void doInitialiseMTLE (void);
void doInstallAEHandlers (void);
void eventLoop (void);
UInt32 doGetSleepTime (void);
void doIdle (void);
void doEvents (EventRecord *);
void doMouseDown (EventRecord *);
void doBringFinderToFront (void);
OSStatus doFindProcess (OSType,OSType,ProcessSerialNumber *);
void doActivate (EventRecord *);
void doUpdate (EventRecord *);
Boolean isApplicationWindow (WindowRef,TXNObject *);
void doAboutDialog (void);
void doSynchroniseFiles (void);
OSStatus openAppEventHandler (AppleEvent *,AppleEvent *,SInt32);
OSStatus reopenAppEventHandler (AppleEvent *,AppleEvent *,SInt32);
OSStatus openAndPrintDocsEventHandler (AppleEvent *,AppleEvent *,SInt32);
OSStatus quitAppEventHandler (AppleEvent *,AppleEvent *,SInt32);
OSStatus doHasGotRequiredParams (AppleEvent *);
void doErrorAlert (SInt16);
void doCopyPString (Str255,Str255);
void doConcatPStrings (Str255,Str255);
void doEnableDisableMenus (Boolean);
void doAdjustAndPrepareMenus (void);
void doAdjustFileMenu (MenuRef,WindowRef);
void doAdjustEditMenu (MenuRef,WindowRef);
void doPrepareFontMenu (WindowRef);
void doPrepareSizeMenu (MenuRef,WindowRef);
void doPrepareStyleMenu (MenuRef,WindowRef);
void doPrepareColourMenu (MenuRef,WindowRef);
Boolean isEqualRGB (RGBColor *,RGBColor *);
void doPrepareJustificationMenu (MenuRef,WindowRef);
void doMenuChoice (SInt32);
void doFileMenuChoice (MenuItemIndex,WindowRef);
void doEditMenuChoice (MenuItemIndex,WindowRef);
void doFontMenuChoice (MenuID,MenuItemIndex,WindowRef);
void doSizeMenuChoice (MenuItemIndex,WindowRef);
void doStyleMenuChoice (MenuItemIndex,WindowRef);
void doColourMenuChoice (MenuItemIndex,WindowRef);
void doJustificationMenuChoice (MenuItemIndex,WindowRef);
OSStatus doNewCommand (void);
OSStatus doOpenCommand (void);
OSStatus doCloseCommand (NavAskSaveChangesAction);
OSStatus doSaveCommand (void);
OSStatus doSaveAsCommand (void);
OSStatus doRevertCommand (void);
OSStatus doQuitCommand (NavAskSaveChangesAction);
OSStatus doNewDocWindow (WindowRef *,FSSpec *,TXNFileType);
OSStatus doOpenFile (FSSpec,OSType);
void doCloseWindow (WindowRef,TXNObject);
OSStatus doWriteFile (WindowRef,Boolean);
OSStatus doCopyResources (FSSpec,TXNFileType,Boolean);
OSStatus doCopyAResource (ResType,SInt16,SInt16,SInt16);
void navEventFunction (NavEventCallbackMessage,NavCBRecPtr,
NavCallBackUserData);
// *******************************************************************************************