home *** CD-ROM | disk | FTP | other *** search
- /*
- File: RlShell.h
-
- Contains: definition of RealShell class
-
- Owned by: Nick Pilch
-
- Copyright: © 1993 - 1996 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <7> 6/21/96 CSL 1341242: Shouldn't be able to activate
- windows w/modal dialog up
- <6> 6/20/96 JP 1339269: Made quit handle the saving
- parameter too
- <5> 5/31/96 jpa T10012: OpenFile takes forceOpenApp param,
- returns document. Added dreaded Quit
- command.
- <4> .03.1996 NP 1307182: Stuff for caching shell menu
- items.
- <3> .03.1996 NP 1304875,1317218: Fix can't-cancel problem
- on receipt of quit event.
- <2> 3/1/96 JP 1314798: Added param to OpenAnotherFile
-
- To Do:
- In Progress:
-
- */
-
-
- #ifndef _RLSHELL_
- #define _RLSHELL_
-
- #ifndef _PLFMDEF_
- #include "PlfmDef.h"
- #endif
-
- #ifndef _ODTYPES_
- #include <ODTypes.h>
- #endif
-
- #ifndef SOM_ODDraft_xh
- #include <Draft.xh> /* for ODDraftPermissions */
- #endif
-
- #ifndef _PLFMFILE_
- #include "PlfmFile.h"
- #endif
-
- #ifndef _LINKLIST_
- #include <LinkList.h>
- #endif
-
- #ifndef __PROCESSES__
- #include <Processes.h> /* For ProcessSerialNumber */
- #endif
-
- #ifndef __DIALOGS__
- #include <Dialogs.h>
- #endif
-
-
- //==============================================================================
- // Theory of Operation
- //==============================================================================
-
- /*
- The Shell contains all code which interfaces a particular platform's
- user interface with the OpenDoc parts underneath.
- Each document is run in its own process.
-
- */
-
- //==============================================================================
- // Constants
- //==============================================================================
-
-
- //-------------------------------------------------------------------------------------
- // Menus
- //-------------------------------------------------------------------------------------
-
- #define kSHLMenuAbout 1
-
- enum {
- kSHLMenuNew = 1
- ,kSHLMenuOpen
- ,kSHLMenuOpenDocument
- ,kSHLMenuInsert
- ,kSHLMenuClose
- ,kSHLMenuDeleteDocument
-
- // menu separator
-
- ,kSHLMenuSave = 8
- ,kSHLMenuSaveACopy
- ,kSHLMenuRevert
- ,kSHLMenuDraft
- ,kSHLMenuDocumentInfo
-
- // menu separator
-
- ,kSHLMenuPageSetup = 14
- ,kSHLMenuPrint
-
- #ifdef SUPPORT_QUIT
- // menu separator
-
- ,kSHLMenuQuit = 17 /* Used only in APPL processes like CyberDog */
- #endif
- };
-
-
- enum {
- kSHLMenuUndo = 1
- ,kSHLMenuRedo
-
- // menu separator
-
- ,kSHLMenuCut = 4
- ,kSHLMenuCopy
- ,kSHLMenuPaste
- ,kSHLMenuPasteAs
- ,kSHLMenuClear
- ,kSHLMenuSelectAll
-
- // menu separator
-
- ,kSHLMenuGetPartInfo= 11
- ,kSHLMenuPreferences
-
- // menu separator
-
- ,kSHLMenuViewAsWin = 14
- };
-
-
- //-------------------------------------------------------------------------------------
- // Dialogs
- //-------------------------------------------------------------------------------------
-
- const ODSShort kSHLscOK = 1; //OK button
- const ODSShort kSHLscCancel = 2; //Cancel button
- const ODSShort kSHLscNo = 3; //no, don't save
-
- //==============================================================================
- // Scalar Types
- //==============================================================================
-
- typedef ODSShort ODResNumber;
-
- typedef struct {
- UserItemUPP iconUPP;
- ODBoolean makeStationery;
- ODSession* session;
- ODType changeKind;
- ODType partKind;
- ODTypeList* kindList;
- } SaveCopyStruct;
-
- //==============================================================================
- // Classes defined in this interface
- //==============================================================================
-
- class RealShell;
-
- //==============================================================================
- // Classes used by this interface
- //==============================================================================
-
- class ODSession;
- class ODDispatcher;
- class ODWindowState;
- class ODArbitrator;
- class ODDraft;
- class ODDocument;
- class ODContainer;
- class ODMenuBar;
- class ShellSI;
- class SIHelper;
- class PlatformFile;
- class StandardFileReply;
- class OrderedCollection;
- class ODAppleEvent;
- class ODDesc;
-
- //==============================================================================
- // Functions defined in this interface
- //==============================================================================
-
- void CreateNewUntitledFile(PlatformFile* newFile); // newFile is in/out
- // Will be moved to DocUtils. - TÇ
-
- //==============================================================================
- // RealShell
- //==============================================================================
-
- class RealShell
- {
- public:
-
- //-------------------------------------------------------------------------------------
- // Constructor/Destructor/Initialize/Shutdown/Go
- //-------------------------------------------------------------------------------------
-
- RealShell();
- ODNVMethod ~RealShell();
-
- ODNVMethod void Initialize();
- ODNVMethod void InstallMenuBar();
- ODNVMethod void InstallShellPlugIns(ODDraft* draft);
- ODNVMethod void ScanShellPlugInsFldr(ODSShort fldrVRefNum, ODSLong fldrDirID,
- ODDraft* draft);
-
- ODNVMethod void go();
-
- //-------------------------------------------------------------------------------------
- // public for AppleEvent handlers, but private by convention
- //-------------------------------------------------------------------------------------
-
- //-------------------------------------------------------------------------------------
- // Getters/Setters
-
- ODNVMethod ODSession* GetSession() {return fSession;}
- ODNVMethod Environment* GetEV() {return fEV;}
-
- ODNVMethod void SetAEError(ODError error);
-
- //-------------------------------------------------------------------------------------
- // Close
-
- ODNVMethod void CloseWindow(ODPlatformWindow window,
- DescType saveOptions);
-
- ODNVMethod ODBoolean CloseDocument(ODDocument* document,
- DescType saveOptions);
-
- ODNVMethod void CloseAllDocs( DescType saveOptions );
-
-
- //-------------------------------------------------------------------------------------
- // Save
-
- ODNVMethod ODBoolean Save(ODDocument* document,
- ODBoolean isClosing = kODFalse,
- ODDescType saveOptions = kAEAsk);
- // if it was a first save, and the user canceled, then it returns kODFalse.
- // The second parameter is needed because if it is a first save in response to the (Save) button from the
- // DontSave/Save/Cancel dialog, and if the user is saving to a different volume, then there is no need to
- // reopen the document after closing and moving it to the new volume.
- // The third parameter is needed because if the user requested that the file be closed and saved,
- // he doesn't want a save dialog to appear
-
- protected:
-
-
- //-------------------------------------------------------------------------------------
- // Event Dispatching
- //-------------------------------------------------------------------------------------
-
- ODNVMethod void DispatchEvent(ODEventData* event);
- ODNVMethod void DispatchMouseDownEvent(ODEventData* event);
- ODNVMethod void DispatchMenuEvent(ODEventData* event);
- ODNVMethod void DispatchKeyDownEvent(ODEventData* event);
-
- ODNVMethod void HandleOSEvent(ODEventData* event);
- ODNVMethod void HandleHighLevelEvent(ODEventData* event);
-
- ODNVMethod void HandleMenuCommand(ODSLong menuResult, ODEventData* event);
- ODNVMethod void HandleMouseDownInWindow(WindowPtr window, ODSShort partcode, ODEventData* event);
- ODNVMethod void HandleMouseDownInCloseBox(WindowPtr window, ODEventData* event);
- ODNVMethod void HandleMouseDownInDragRegion(WindowPtr window, ODEventData* event);
- ODNVMethod void HandleMouseDownInGrowBox(WindowPtr window, ODEventData* event);
- ODNVMethod void HandleMouseDownInZoomBox(WindowPtr window, ODSShort partcode, ODEventData* event);
-
- ODNVMethod void ExportClipboard(ODBoolean canAlert);
-
- ODNVMethod ODBoolean CheckFileLocation( );
- ODNVMethod void NotifyDragToTrash( ODULong );
- ODNVMethod void CloseTrashedDocument(ODDocument* document, DescType saveOptions );
-
- ODNVMethod ODBoolean IsSessionModal();
-
- //-------------------------------------------------------------------------
- // Update menus
-
- struct MenuItemInfo
- {
- Str255 text;
- short cmdChar;
- short iconID;
- short markChar;
- Style textStyle;
- };
-
- ODNVMethod void CheckMenuBar();
- ODNVMethod void UpdateMenus();
- ODNVMethod void UpdateUndoMenus();
- ODNVMethod void SaveMenuItem(MenuHandle menu, short itemNum,
- MenuItemInfo* info);
- ODNVMethod void RestoreMenuItem(MenuHandle menu, short itemNum,
- MenuItemInfo* info);
- ODNVMethod void ResetUndoText(MenuHandle editMenu);
- ODNVMethod void ResetRedoText(MenuHandle editMenu);
-
- //-------------------------------------------------------------------------------------
- // Memory Management
- //-------------------------------------------------------------------------------------
-
- ODNVMethod void InitMemory( );
-
- ODNVMethod ODSize Purge(ODSize size);
-
- ODNVMethod ODSize IsFreeMemoryLow( ODBoolean &appIsLow, ODBoolean &tempIsLow );
-
- ODNVMethod ODBoolean CheckFreeMemory( ); // Returns false if low on memory
-
- ODNVMethod void LowMemoryAlert( ODBoolean tempMem );
-
- //-------------------------------------------------------------------------------------
- // Shell User Functionality
- //-------------------------------------------------------------------------------------
-
- //-------------------------------------------------------------------------
- // New (document)
-
- ODNVMethod PlatformFile* New();
- // implements the menu command
- // create a new document with the same part as the root part of the active window
-
- //-------------------------------------------------------------------------
- // Open (document)
-
- ODNVMethod ODDocument* OpenFile(PlatformFile* file,
- ODBoolean forceOpenApp =kODFalse);
-
- ODNVMethod void OpenAnotherFile(PlatformFile* file,
- AEDescList* replyInfo = kODNULL,
- ODBoolean deleteOnFailure = kODFalse,
- ODBoolean unsavedDoc = kODFalse);
-
- ODNVMethod void OpenStdFile();
-
- //-------------------------------------------------------------------------
- // Close (window/document)
-
- ODNVMethod ODBoolean DoesUserCancelClose(ODDocument* document, DescType saveOptions);
-
- //-------------------------------------------------------------------------
- // Delete (document)
-
- ODNVMethod void DeleteDocument(ODDocument* document);
-
- //-------------------------------------------------------------------------
- // Save (document)
-
- ODNVMethod void ShowSaveDiffVolDialog( );
- ODNVMethod void CloseSaveDiffVolDialog( );
-
-
- ODNVMethod ODBoolean AskUserWhereToPutIt(
- ODDraft* whichDraft, Str255 defaultName,
- Str255 msg, StandardFileReply* reply );
-
- ODNVMethod void SaveACopy(ODDraft* draft);
-
- //-------------------------------------------------------------------------
- // Revert (document)
-
- ODNVMethod void Revert(ODDocument* document);
-
- ODNVMethod ODBoolean DoesUserOKRevert(ODDocument* document);
-
- //-------------------------------------------------------------------------
- // Drafts (of document)
-
- ODNVMethod void Drafts(ODDocument* document);
-
- //-------------------------------------------------------------------------
- // Info
-
- ODNVMethod void DocumentInfo(ODDocument* document);
- // ODNVMethod void PartInfo();
-
- //-------------------------------------------------------------------------------------
- // Error Handling & Notification
- //-------------------------------------------------------------------------------------
-
- ODNVMethod void ExceptionAlert(ODError exceptionCode, const char message[]);
-
- ODNVMethod ODBoolean SearchErrTable( ODError value,
- ODResNumber resourceID,
- Str255 str);
-
- ODNVMethod ODBoolean LookupErrString(ODError value,
- ODResNumber resourceID,
- Str255 str);
-
- ODNVMethod ODError GetAEError();
-
-
- // Pointer to notifier method which returns void and takes a refCon:
- typedef void (RealShell::*Notifier) ( ODULong refCon );
-
- ODNVMethod void Notify( RealShell::Notifier, ODULong refCon =0 );
-
- ODNVMethod void CancelNotification( RealShell::Notifier );
-
- ODNVMethod void ShowPendingNotifications( );
-
- ODNVMethod void LaunchFailed( ODSLong launchErr,
- const ProcessSerialNumber &psn,
- Str255 appName, Str255 libName );
-
- //-------------------------------------------------------------------------------------
- // Apple Event Support
- //-------------------------------------------------------------------------------------
-
- ODNVMethod void InitAE();
-
- ODNVMethod void FakePrintMenuEvent();
-
- static pascal ODError HandleOpenAppEvent(ODPart* thePart,
- ODAppleEvent* message,
- ODAppleEvent* reply,
- ODSLong refCon);
-
- static pascal ODError HandleOpenPrintDocsEvent( ODPart* thePart,
- ODAppleEvent* message,
- ODAppleEvent* reply,
- ODSLong refCon);
-
- static pascal ODError HandleQuitEvent( ODPart* thePart,
- ODAppleEvent* message,
- ODAppleEvent* reply,
- ODSLong refCon);
-
- static pascal ODError HandleLaunchFailedEvent( ODPart* thePart,
- ODAppleEvent* message,
- ODAppleEvent* reply,
- ODSLong refCon);
-
- static pascal ODError HandleODActivate( ODPart* thePart,
- ODAppleEvent* message,
- ODAppleEvent* reply,
- ODSLong handlerRefcon );
-
- static pascal ODError CoerceToFSSpec(ODPart* thePart,
- ODDesc* theAEDesc,
- DescType toType,
- ODSLong handlerRefCon,
- ODDesc* result);
-
-
- //-------------------------------------------------------------------------------------
- // Utilities for setting/getting file names ($opt: can probably inline these)
- //-------------------------------------------------------------------------------------
-
- void GetUserFileName(char* fileName, ODULong maxLen);
-
- //-------------------------------------------------------------------------------------
- // Utilities to be moved to DocUtils
- //-------------------------------------------------------------------------------------
-
- ODNVMethod void CreateUniqueTmpFolderForFile(FSSpec* result,
- Str63 fileName);
-
- ODNVMethod void CreateUntitledContainer(ODDocument** documentPtr,
- ODContainer** containerPtr, PlatformFile* newFile, ODName* fileNameSeed = kODNULL);
- // *documentPtr, *containerPtr are filled in
- // newFile is in/out
-
- ODNVMethod void CreateTitledContainer(ODDocument** documentPtr,
- ODContainer** containerPtr, PlatformFile* newFile, char* newName);
- // *documentPtr, *containerPtr are filled in
- // newFile is in/out
-
- ODNVMethod void GetCurrentProcessInfo( ProcessInfoRec *info,
- StringPtr name =kODNULL, FSSpec *appLoc =kODNULL );
-
- //-------------------------------------------------------------------------------------
- // private fields
- //-------------------------------------------------------------------------------------
-
- //-------------------------------------------------------------
- // session fields
-
- Environment* fEV;
- ODSession* fSession;
- ODDispatcher* fDispatcher;
- ODWindowState* fWindowState;
- ODArbitrator* fArbitrator;
- SIHelper* fSIHelper;
- short fUniqueNameSeed;
- ODTypeToken fModalFocusToken;
-
- MenuItemInfo fDefaultUndoMenuItem;
- MenuItemInfo fDefaultRedoMenuItem;
- MenuItemInfo fDefaultAboutMenuItem;
- MenuItemInfo fDefaultPrefsMenuItem;
-
- ODBoolean fAPPLProcess;
-
- //-------------------------------------------------------------
- // transitional state fields
-
- ODBoolean fOptionKeyDownOnMenuBarClick;
- ODBoolean fShellHasMenuFocus;
- ODBoolean fAlreadyInCoercion;
- ODError fErrorFromOpenEvents;
- ODBoolean fProcessIsActive;
-
- ProcessSerialNumber fLastNewDocPSN;
- ODFileSpec fLastNewDocSpec;
- SaveCopyStruct* fSaveCopyData;
- DialogPtr fSaveDiffVolDialog;
-
- //-------------------------------------------------------------
- // error/notification fields
-
- ODBoolean fLowMemNotified;
-
- Str63 fFailedPlugInName;
-
- LinkedList fNotifiers;
-
- friend struct NotEntry; // It has a Notifier as a member
- };
-
-
-
- #endif // _RLSHELL_
-