JX Application Framework
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
JXDocument Class Referenceabstract

#include <JXDocument.h>

Inheritance diagram for JXDocument:
[legend]

Public Member Functions

 JXDocument (JXDirector *supervisor)
 
 ~JXDocument () override
 
bool Close () override
 
bool Deactivate () override
 
bool GetMenuIcon (const JXImage **icon) const override
 
bool NeedsSave () const override
 
virtual bool NeedDocument (JXDocument *doc) const
 
void RevertToSaved ()
 
virtual void SafetySave (const JXDocumentManager::SafetySaveReason reason)=0
 
- Public Member Functions inherited from JXWindowDirector
 JXWindowDirector (JXDirector *supervisor)
 
 ~JXWindowDirector () override
 
void Activate () override
 
bool Deactivate () override
 
void Suspend () override
 
void Resume () override
 
JXWindowGetWindow () const
 
JXDisplayGetDisplay () const
 
virtual const JStringGetName () const
 
- Public Member Functions inherited from JXDirector
 JXDirector (JXDirector *supervisor)
 
 ~JXDirector () override
 
bool IsClosing () const
 
bool IsActive () const
 
bool IsSuspended () const
 
bool HasSubdirectors () const
 
bool GetSubdirectors (const JPtrArray< JXDirector > **list) const
 
- Public Member Functions inherited from JBroadcaster
 JBroadcaster ()
 
virtual ~JBroadcaster ()
 
JBroadcasteroperator= (const JBroadcaster &source)
 
bool HasSenders () const
 
JSize GetSenderCount () const
 
bool HasRecipients () const
 
JSize GetRecipientCount () const
 
virtual JString ToString () const
 
template<class T >
void ListenTo (const JBroadcaster *sender, const std::function< void(const T &)> &f)
 

Protected Member Functions

virtual bool OKToClose ()=0
 
virtual bool OKToRevert ()=0
 
virtual bool CanRevert ()=0
 
virtual void DiscardChanges ()=0
 
bool OKToDeactivate () override
 
- Protected Member Functions inherited from JXDirector
JXDirectorGetSupervisor () const
 
bool CloseAllSubdirectors ()
 
virtual void DirectorClosed (JXDirector *theDirector)
 
- Protected Member Functions inherited from JBroadcaster
 JBroadcaster (const JBroadcaster &source)
 
void ListenTo (const JBroadcaster *sender)
 
void StopListening (const JBroadcaster *sender)
 
void ClearWhenGoingAway (const JBroadcaster *sender, void *pointerToMember)
 
void StopListening (const JBroadcaster *sender, const std::type_info &messageType)
 
template<class T >
void Send (JBroadcaster *recipient, const T &message)
 
template<class T >
void Broadcast (const T &message)
 
virtual void Receive (JBroadcaster *sender, const Message &message)
 
void SendWithFeedback (JBroadcaster *recipient, Message *message)
 
void BroadcastWithFeedback (Message *message)
 
virtual void ReceiveWithFeedback (JBroadcaster *sender, Message *message)
 
virtual void ReceiveGoingAway (JBroadcaster *sender)
 

Detailed Description

Interface for the JXDocument class

Maintains some information and a window that displays it.

Derived classes must override OKToClose so they can save data
or otherwise let the user clean things up before closing.  (Clean up
that doesn't involve the user should be done in the destructor.)

OKToDeactivate() is automatically wired to OKToClose() on the assumption
that the user can't tell the difference (and shouldn't have to, either!)
between closing a document and merely hiding its window.

Derived classes must also override the following function:

    NeedsSave
        Returns true if the data needs to be saved.

    OKToRevert
        Ask the user if it is OK to revert to the latest saved version
        of this document.

    CanRevert
        Returns true if it is possible to revert to a saved version
        of this document.

    SafetySave
        Save the data in a temporary file, in case the program crashes.
        No error reporting is allowed because one possibility is
        that the GUI itself has died.

    GetMenuIcon
        Return a small icon for the document.  This is used when building
        a menu of all the documents that are open.  JXFileDocument
        implements this to return jx_plain_file_small.

        The result is JXPM instead of JXImage because JXImage is
        restricted to a single display.

Derived classes may want to override the following functions:

    GetName
        Return a name for the document.  This is used when building
        a menu of all the documents that are open, so it should be
        unique (though it doesn't have to be).  The default implementation
        is to return the title of our window.  JXFileDocument overrides
        this to return the name of its file.

    NeedDocument
        Return true if you need the given document to stay open.
        The document dependency graph must be acyclic.

Constructor & Destructor Documentation

◆ JXDocument()

JXDocument::JXDocument ( JXDirector supervisor)

◆ ~JXDocument()

JXDocument::~JXDocument ( )
override

Member Function Documentation

◆ CanRevert()

virtual bool JXDocument::CanRevert ( )
protectedpure virtual

Implemented in JXFileDocument.

◆ Close()

bool JXDocument::Close ( )
overridevirtual

Returns true if the user ok's it and nobody needs us.

Reimplemented from JXDirector.

◆ Deactivate()

bool JXDocument::Deactivate ( )
overridevirtual

The user can't tell the difference between hiding and closing.

Reimplemented from JXDirector.

◆ DiscardChanges()

virtual void JXDocument::DiscardChanges ( )
protectedpure virtual

◆ GetMenuIcon()

bool JXDocument::GetMenuIcon ( const JXImage **  icon) const
overridevirtual

Return an icon to display in JXWDMenu.

Does not return JXImage* because that would force all derived classes to provide an icon, and many don't need it.

The client retains ownership of the JXImage.

Reimplemented from JXWindowDirector.

◆ NeedDocument()

bool JXDocument::NeedDocument ( JXDocument doc) const
virtual

Derived classes should override if they require that other documents must stay open.

The dependency graph must be acyclic!

◆ NeedsSave()

bool JXDocument::NeedsSave ( ) const
overridevirtual

Must be overridden, but can't be pure virtual because originally defined in JXWindowDirector.

Reimplemented from JXWindowDirector.

Reimplemented in JXFileDocument.

◆ OKToClose()

virtual bool JXDocument::OKToClose ( )
protectedpure virtual

Implemented in JXFileDocument.

◆ OKToDeactivate()

bool JXDocument::OKToDeactivate ( )
overrideprotectedvirtual

The user can't tell the difference between hiding and closing.

Reimplemented from JXWindowDirector.

◆ OKToRevert()

virtual bool JXDocument::OKToRevert ( )
protectedpure virtual

Implemented in JXFileDocument.

◆ RevertToSaved()

void JXDocument::RevertToSaved ( )

◆ SafetySave()

virtual void JXDocument::SafetySave ( const JXDocumentManager::SafetySaveReason  reason)
pure virtual

Implemented in JXFileDocument.


The documentation for this class was generated from the following files: