11#include <owl/docview.rh>
15#if defined(__BORLANDC__)
49 DocManager = parent->DocManager;
54 if (parent->ParentDoc == parent) {
57 DocManager->DocList.
Insert(
this);
60 parent->ChildDoc.
Insert(
this);
65 DocManager =
app->GetDocManager();
68 DocManager->DocList.
Insert(
this);
84 if (ParentDoc ==
this)
106 ParentDoc->ChildDoc.
Remove(
this);
109 const auto ok = DocManager !=
nullptr;
110 WARN(!
ok,
_T(
"TDocument::~TDocument: Terminating due to failed precondition."));
111 if (!
ok) std::terminate();
114 DocManager->DocList.
Remove(
this);
124static const LPCTSTR PropNames[] = {
125 _T(
"Document Class"),
129 _T(
"Document Title"),
135static int PropFlags[] = {
263 << index <<
_T(
"] specified!") );
334 while (
pdoc->ParentDoc)
347 DocManager->DocList.
Remove(
this);
348 dm.DocList.Insert(
this);
382 if (!Title ||
title!=Title)
414TDocument::ReindexFrames()
426 seq = (
seq == -2 ? 0 : 1);
431 if (
view->GetWindow() &&
view->GetWindow()->GetHandle() )
455 for ( ; *
plist;
plist = &(*plist)->NextStream) {
456 if (*
plist == &strm) {
478 return view ?
view->NextView : ViewList;
492 view.NextView =
nullptr;
608 if (!
pdoc->Revert(clear))
633 for (
auto d = ChildDoc.
Next(
nullptr);
d;
d = ChildDoc.
Next(
d))
779 if (!
pdoc->CanClose())
821 return doc ?
doc->NextDoc : DocList;
834 doc->NextDoc = DocList;
879#if OWL_PERSISTENT_STREAMS
892 o->DirtyFlag =
false;
898 char *
title =
is.freadString();
906 o->DocPath =
is.freadString();
907 o->Title =
is.freadString();
914 is >> TView::NextViewId;
923TDocument::Streamer::Write(opstream&
os)
const
927 while (!
o->CanClose())
931 os.fwriteString(
_W2A(
o->DocPath));
932 os.fwriteString(
_W2A(
o->Title));
936 os << TView::NextViewId;
Definition of class TAppDictionary.
#define WARNX(group, condition, level, message)
#define WARN(condition, message)
#define PRECONDITION(condition)
#define DIAG_DECLARE_GROUP(group)
#define TRACEX(group, level, message)
TApplication * GetApplication(uint pid=0)
Looks up and returns the application associated with a given process ID.
Derived from TModule and TMsgThread and virtually derived from TEventHandler, TApplication acts as an...
TDocManager creates a document manager object that manages the list of current documents and register...
virtual void PostEvent(int id, TDocument &doc)
changed doc status
virtual uint PostDocError(TDocument &doc, uint sid, uint choice=MB_OK)
Displays a message box with the error message passed as a string resource ID in sid.
virtual bool FlushDoc(TDocument &doc)
Method invoked when specified document is about to be closed.
bool IsFlagSet(int flag) const
Returns true if the specified flag is currently enabled by the DocManager or false otherwise.
TApplication * GetApplication() const
Returns the TApplication* object associated with this DocManager.
void UnRefTemplate(TDocTemplate &)
drop template ref
int & GetUntitledIndex()
Returns the index to be used by an untitled document.
void RefTemplate(TDocTemplate &)
add template ref
TDocTemplate is an abstract base class that contains document template functionality.
LPCTSTR GetDescription() const
Gets the template description to put in the file-selection list box or the File|New menu-selection li...
bool Contains(TDocument *doc)
Checks if doc is contained in the list.
bool Remove(TDocument *doc)
Removes a document from the document list, fails if not there.
void Destroy()
Deletes all documents.
TDocument * Next(const TDocument *doc)
If the doc parameter is 0, Next returns the first document in the list of documents.
bool Insert(TDocument *doc)
Inserts a new document into the document list. Fails if the document already exists.
An abstract base class, TDocument is the base class for all document objects and serves as an interfa...
TDocument(TDocument *parent=nullptr)
Although you do not create a TDocument object directly, you must call the constructor when you create...
TStream * NextStream(const TStream *strm)
Gets the next entry in the stream. Holds 0 if none exists.
void DestroyViews()
Destroys the views attached to this document.
virtual int GetProperty(int index, void *dest, int textlen=0)
Retrieves the property identified by the given index.
virtual int FindProperty(LPCTSTR name)
return property index
TView * NextView(const TView *view)
Gets the next view in the list of views. Holds 0 if none exists.
void SetDocManager(TDocManager &dm)
Sets the current document manager to the argument dm.
virtual void DetachStream(TStream &strm)
called from TStream destructor
bool NotifyOwnViews(int eventId, TParam2=0, TView *exclude=nullptr)
Notifies the views of this document of a change.
virtual TDocument & RootDocument()
Returns the this pointer as the root document.
bool NotifyViews(int eventId, TParam2=0, TView *exclude=nullptr)
Notifies the views of this document, and the views of any child documents, of a change.
virtual bool SetProperty(int index, const void *src)
native type
virtual bool HasFocus(HWND hwnd)
Document (or child doc) has Focus.
virtual bool CanClose()
Returns false if unable to close.
bool SetTemplate(TDocTemplate *tpl)
Sets the document template.
virtual LPCTSTR PropertyName(int index)
locale invariant name
virtual bool Close()
close document, does not delete or detach
virtual int PropertyFlags(int index)
pfXxxxx bit array
void DestroyChildren()
Destroy children first if we have any.
TView * InitView(TView *view)
called from template InitView
virtual ~TDocument()
Deletes a TDocument object.
virtual void AttachStream(TStream &strm)
called from TStream constructor
TView * QueryViews(int eventId, TParam2=0, TView *exclude=nullptr)
Queries the views of the current document, and the views of any child documents, about a specified ev...
virtual void SetTitle(LPCTSTR title)
Sets the title of the document.
virtual TDocument * DocWithFocus(HWND hwnd)
Return pointer to this document or one of its child documents if the spcecified window parameter is a...
virtual bool SetDocPath(LPCTSTR path)
Sets the document path for Open and Save operations.
virtual bool IsDirty()
Also queries doc and view hierarchy.
@ TemplateName
text property: Name of template attached to document
@ PrevProperty
Index of last property in base class (none in this case)
@ StoragePath
text property: Identifies object holding data of this document
@ NextProperty
Next index to be used by derived class.
@ ViewCount
int property: Number of views displaying this document
@ DocumentClass
text Property: Name of C++ class encapsulating document
@ DocTitle
text property: Caption of this document
virtual bool IsOpen()
Checks to see if the document has any streams in its stream list.
virtual bool Commit(bool force=false)
save current data, force write
virtual uint PostError(uint sid, uint choice=MB_OK)
Posts the error message passed as a string resource ID in sid.
virtual bool Revert(bool clear=false)
abort changes, no reload if true
A nested class, TEventInfo provides specific information about the type of message sent,...
An abstract base class, TStream provides links between streams and documents, views,...
TStream * NextStream
Points to the next stream in the list of active streams.
Abstract base class for view access from document.
static void BumpNextViewId()
Increments an internal count used by the Doc/View subsystem to identify each view.
ipstream, a specialized input stream derivative of pstream, is the base class for reading (extracting...
Definition of class TDocManager.
#define IMPLEMENT_ABSTRACT_STREAMABLE(cls)
#define _OBJ_FULLTYPENAME(obj)
const uint dtAutoDelete
delete doc when last view is deleted
const uint pfGetText
property accessible as text format
const uint vnViewOpened
a new view has just been constructed
const uint vnViewClosed
another view is about to be destructed
const uint pfConstant
property is invariant for object instance
const uint vnCommit
document is committing, flush cached changes
const uint dtAutoOpen
open document upon creation
const uint pfSettable
property settable as native format
const uint vnRevert
document has reverted, reload data from doc
const uint vnIsWindow
respond true if passed HWND is that of view
const uint vnIsDirty
respond true if uncommitted changes present
const uint pfGetBinary
property accessible as native non-text format
const uint dmMDI
Supports multiple open documents.
@ dnCreate
New document or view has been created.
@ dnClose
Document or view has been closed.
static void Raise(const tstring &msg, uint resId=0)
int LoadString(uint id, TCHAR *buf, int maxChars) const
Loads a string resource identified by id into the buffer pointed to by buff.
char * strnewdup(const char *s, size_t minAllocSize=0)
Object Windows Library (OWLNext Core)
LPARAM TParam2
Second parameter type.
TAppDictionary & OWLGetAppDictionary()
Global exported TAppDictionary in Owl.
#define COUNTOF(s)
Array element count Important: Only use this with an argument of array type.
Definition of class TString, a flexible universal string envelope class.