Retired Document
Important: This sample code may not represent best practices for current development. The project may use deprecated symbols and illustrate technologies and techniques that are no longer recommended.
•Mac_Classes/TBackGroundApp.h
// TBackGroundApp.h - Macintosh backround application object |
// |
// Apple Macintosh Developer Technical Support |
// Written by: Vinne Moscaritolo |
// |
// Copyright (work in progress) Apple Computer, Inc All rights reserved. |
// |
// You may incorporate this sample code into your applications without |
// restriction, though the sample code has been provided "AS IS" and the |
// responsibility for its operation is 100% yours. However, what you are |
// not permitted to do is to redistribute the source as "DSC Sample Code" |
// after having made changes. If you're going to re-distribute the source, |
// we require that you make it clear in the source that the code was |
// descended from Apple Sample Code, but that you've made changes. |
// |
#ifndef _H_TBACKGROUNDAPP |
#define _H_TBACKGROUNDAPP |
#include <AppleEvents.h> |
// --------------------------------------------------------------------------- |
// TBackGroundApp - Background Application |
// --------------------------------------------------------------------------- |
// |
class TBackGroundApp |
{ |
public: |
// ENUMS AND TYPEDEFS |
enum ESleepTimes{ |
kSleep_1_Min = 3600, // wake up every minute |
kSleep_1_Sec = 60, // wake up every 1 Secs |
kNoSleep = 0}; //wake up every 0 seconds |
enum EAppCommands{ |
kAppQuit = 1, |
kAppOpen, |
kAppOpenDocuments, |
kAppPrint |
}; |
enum EState {kSInit = 1, kSRun, kSQuit}; |
// CONSTRUCTORS AND DESTRUCTORS |
TBackGroundApp(); |
virtual ~TBackGroundApp(); |
// MAIN INTERFACE |
virtual void InitializeMemory(); // initialize our memory needs |
virtual void InitializeToolbox(); // initialize the toolbox |
// EVENT AND CONTROL METHODS |
virtual void DoEventLoop(); // handle the actual event dispatching |
virtual void DoNextEvent(); // handle the incoming events |
virtual void DoHighLevelEvent(); // handle high level events |
virtual void Start(); // start the application and let it run |
virtual void DoIdle(); // call idle handler |
virtual void Quit(); // quit the application |
// CORE AE HANDLER METHODS |
virtual void InstallAEHandler(); // install our AE dispatcher |
virtual OSErr DispatchAppleEvents(AppleEvent*, AppleEvent* , long); // Dispatch incoming Apple Events in the framework |
virtual OSErr HandleQuit (AppleEvent* , AppleEvent*, long ); // handle the quit AE |
virtual OSErr HandleOpen (AppleEvent* , AppleEvent*, long ); // handle the open AE |
virtual OSErr HandleOpenDocuments (AppleEvent*,AppleEvent*,long); // handle the open document AE |
virtual OSErr HandlePrint (AppleEvent*, AppleEvent*,long); // handle the print command |
// STATE CHANGE METHODS |
virtual void SetState(TBackGroundApp::EState theState); // change the state of the application FSM |
// PRIVATE FIELDS |
protected: |
EState fState; // internal state of the TBackGroundApp |
long fSleepTime; // Multifinder WNE delay |
EventRecord fEventRecord; // current event record |
// CLASS VARIABLES |
public: |
static TBackGroundApp* fgApplication; // global pointer to background app |
}; |
#endif |
Copyright © 2003 Apple Computer, Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2003-01-14