JX Application Framework
|
#include <JXDocumentManager.h>
Classes | |
class | DocMenuNeedsUpdate |
Public Types | |
enum | { kNoShortcutForDoc = -1 } |
enum | SafetySaveReason { kTimer , kServerDead , kKillSignal , kAssertFired } |
Static Public Attributes | |
static const JUtf8Byte * | kDocMenuNeedsUpdate |
Friends | |
class | JXUpdateDocMenuTask |
Additional Inherited Members | |
![]() | |
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) |
Singleton class that manages all JXDocuments and provides the following services: 1) GetNewFileName() Convenient source of names for newly created documents. 2) JXDocumentMenu Instant menu of all open documents 3) Safety save Periodically save all unsaved documents in temporary files. Also protects against X Server crashes and calls to assert(). While it would be nice to also catch Ctrl-C, this must remain uncaught because it provides a way to quickly stop a runaway program. Also, in practice, X programs are usually backgrounded, in which case Ctrl-C is irrelevant. 4) Dependencies between documents Classes derived from JXDocument can override NeedDocument() if they require that other documents stay open. When closed, such required documents merely deactivate. 5) Searching for files that are supposed to exist Dependencies between documents usually imply that one document stores the file names of other documents that it has to open. If the user moves or renames these files, call FindFile() to search for them. Derived classes can override this function to search application specific directories. A derived class is the best place to put all the code associated with determining a file's type and creating the appropriate derived class of JXDocument.
JXDocumentManager::JXDocumentManager | ( | const bool | wantShortcuts = true | ) |
|
override |
void JXDocumentManager::ActivateDocument | ( | const JIndex | index | ) |
void JXDocumentManager::CloseDocuments | ( | ) |
Close invisible documents that are no longer needed by any other documents.
An iterator would be cleaner, but since it is recursive and keeps looping until nothing more is closed, this method wastes less stack space.
|
virtual |
|
virtual |
Automatically called by ~JXDocument.
void JXDocumentManager::DocumentMustStayOpen | ( | JXDocument * | doc, |
const bool | stayOpen | ||
) |
Call this with true if a document must remain open even if nobody else needs it.
bool JXDocumentManager::DocumentsNeedSave | ( | ) | const |
bool JXDocumentManager::FileDocumentIsOpen | ( | const JString & | fileName, |
JXFileDocument ** | doc | ||
) | const |
If there is a JXFileDocument that uses the specified file, we return it.
With full RTTI support to allow safe downcasting, this could be generalized to DocumentIsOpen() by defining a pure virtual IsEqual() function in JXDocument and requiring derived classes to implement it appropriately.
|
virtual |
Searches for the given file, assuming that it has been moved elsewhere. currPath should be the path the user selected. This can help in the cases where an entire directory subtree was moved because then the requested file is probably still somewhere in the subtree.
This function is virtual so derived classes can provide additional search techniques.
|
inline |
bool JXDocumentManager::GetDocument | ( | const JIndex | index, |
JXDocument ** | doc | ||
) | const |
The index is the JXDocumentMenu item index.
We return bool because the document might have been closed while the menu was open.
|
inline |
JString JXDocumentManager::GetNewFileName | ( | ) |
Return a suitable name for a new document. Since this is often called in the constructor for JXFileDocument, we return a JString&
JSize JXDocumentManager::GetSafetySaveInterval | ( | ) | const |
Returns the safety save interval in seconds.
|
inline |
bool JXDocumentManager::OKToCloseDocument | ( | JXDocument * | doc | ) | const |
Returns true if the given document can be closed.
void JXDocumentManager::SafetySave | ( | const SafetySaveReason | reason | ) |
void JXDocumentManager::SetSafetySaveInterval | ( | const JSize | deltaSeconds | ) |
void JXDocumentManager::ShouldSafetySave | ( | const bool | doIt | ) |
void JXDocumentManager::UpdateDocumentMenu | ( | JXDocumentMenu * | menu | ) |
|
inline |
|
friend |
|
static |