// $Revision: 1.15 $ //------------------------------------------------------------------------------ // // Copyright (C) 1994 Taligent, Inc. All rights reserved. // // Project: ConcurrentActors // File: InterfaceSubsystem.h // Build/Version: 1.0.0 // // Description: The Interface subsystem manages the program's presentation: // what it looks like to users, the quality of screen refreshes, // and what users can do (and not do) with the program's data. // //------------------------------------------------------------------------------ #ifndef TaligentSamples_INTERFACESUBSYSTEM #define TaligentSamples_INTERFACESUBSYSTEM class TSimulationModel; class TSimulationSelection; class TSimulationView; #ifndef Taligent_NOTIFICATION #include #endif #ifndef Taligent_GUICOMPOUNDDOCUMENTEMBEDDER #include #endif #ifndef TaligentSamples_GAMESUBSYSTEM #include "GameSubsystem.h" #endif //============================================================================== // TSimulationModel class TSimulationModel : public TGUIEmbedderModel { public: ModelDeclarationsMacro(TSimulationModel); public: TSimulationModel(); TSimulationModel(const TSimulationModel& source); virtual ~TSimulationModel(); TSimulationModel& operator=(const TSimulationModel& source); virtual TStream& operator>>=(TStream& toStream) const; virtual TStream& operator<<=(TStream& fromStream); virtual bool IsEqual(const MCollectible* other) const; virtual long Hash() const; virtual TModelSelection* CreateSelection() const; virtual const TImage* UseImage() const; virtual void DoneWithImage() const; virtual bool KeyDown(TKeyDownEvent& event); virtual bool KeyUp(TKeyUpEvent& event); virtual void StartSimulation(); virtual void StopSimulation(); virtual TModelInterest GetImageChangedInterest() const; virtual TSimulationLevel* CopySimulation() const; virtual void AdoptSimulation(TSimulationLevel* newSimulation); virtual TSimulationLevel* OrphanSimulation(); protected: virtual void HandleImageChanged(const TNotification& note); virtual void HandleLevelEnded(const TNotification& note); private: static const TGRect& kViewExtent; enum {kOriginalVersion}; enum ESimulationState {kBetweenLevels, kRunning, kPaused}; TSimulationLevel fSimulationLevel; ESimulationState fSimulationState; TMemberFunctionConnectionTo fConnection; }; //============================================================================== // TSimulationSelection class TSimulationSelection : public TGUIEmbedderModelSelectionFor { public: MCollectibleDeclarationsMacro(TSimulationSelection); DynamicCastDeclarationsMacro(); public: TSimulationSelection(); TSimulationSelection(const TModelReference& model); TSimulationSelection(const TSimulationModel& theModel); TSimulationSelection(const TSimulationSelection& source); ~TSimulationSelection(); TSimulationSelection& operator=(const TSimulationSelection& source); virtual TStream& operator>>=(TStream& toStream) const; virtual TStream& operator<<=(TStream& fromStream); protected: virtual void CopyDataIntoModelSubclass(TSimulationModel& destModel) const; virtual void MoveDataOutofModelSubclass(TSimulationModel& destModel); virtual void MoveDataIntoModelSubclass(TSimulationModel& sourceModel); private: enum {kOriginalVersion}; }; //============================================================================== // TSimulationView class TSimulationView : public TGUIEmbedderModelView, public MKeyEventHandler { public: MCollectibleDeclarationsMacro(TSimulationView); public: TSimulationView(TGUIBundle* theBundleToAlias); virtual ~TSimulationView(); protected: TSimulationView(); TSimulationView(const TSimulationView& source); virtual void DrawContents(TGrafPort& port) const; virtual void HandleActivate(); virtual void HandleDeactivate(); virtual void HandleRefreshNeeded(const TNotification& note); virtual bool KeyDown(TKeyDownEvent& event); virtual bool KeyUp(TKeyUpEvent& event); virtual void HandleAfterConnectionToViewRoot(); virtual void HandleBeforeDisconnectionFromViewRoot(); private: TSimulationView& operator=(const TSimulationView& source); enum {kOriginalVersion}; TRequestBasedMemberFunctionConnectionTo fRefreshConnection; bool fDrawSplashScreen; }; #endif