OWLNext    7.0
Borland's Object Windows Library for the modern age
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
docview.h
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectWindows
3// Copyright (c) 1993, 1996 by Borland International, All Rights Reserved
4//
5/// \file
6/// Definition of classes TDocument, TView, TWindowView, TStream, TInStream,
7/// TOutStream
8//----------------------------------------------------------------------------
9
10#if !defined(OWL_DOCVIEW_H)
11#define OWL_DOCVIEW_H
12
13#include <owl/private/defs.h>
14#if defined(BI_HAS_PRAGMA_ONCE)
15# pragma once
16#endif
17
18# include <owl/applicat.h>
19# include <owl/dialog.h>
20# include <owl/framewin.h>
21
22#if !defined(_INC_COMMDLG)
23# include <commdlg.h>
24#endif
25
27
30
31namespace owl {
32
33class _OWLCLASS TDocManager;
34class _OWLCLASS TDocTemplate;
35class _OWLCLASS TMenuDescr;
36class _OWLCLASS TBarDescr;
37
38/// \addtogroup docview
39/// @{
40
41//
42// This is a workaround for a compiler issue in BCC64 7.30 (10.3 Rio).
43// See TDocMode::ofReadWrite below.
44//
45enum {ofRead_workaround = std::ios::in, ofWrite_workaround = std::ios::out};
46
47//
48/// Document open and sharing modes - used in storage and stream constructors
49//
50/// Defines the document and open sharing modes used for constructing streams and
51/// storing data. Any constants that have the same functionality as those used by
52/// OLE 2.0 doc files are indicated in the following table; for example,
53/// STGM_TRANSACTED, STGM_CONVERT, STGM_PRIORITY, and STGM_DELETEONRELEASE.
54/// Although files are typically used for data storage, databases or spreadsheets
55/// can also be used. I/O streams rather than DOS use these bit values. Documents
56/// open the object used for storage in one of the following modes:
57//
58/// \note the bits values are those of file streams, not same as RTL or OLE
59//
61// ofParent = (IOS_OMODE_LAST << 1), // use open mode of parent storage
62 ofParent = 0, ///< use open mode of parent storage
63 ofRead = std::ios::in, ///< ios::in, open for reading
64 ofWrite = std::ios::out, ///< ios::out, open for writing
65 ofReadWrite = ofRead_workaround | ofWrite_workaround, // NOTE: (ofRead | ofWrite) gives error E2313 with BCC64 7.30 (10.3 Rio).
66 ofAtEnd = std::ios::ate, ///< ios::ate, seek to eof upon original open
67 ofAppend = std::ios::app, ///< ios::app, append mode: all additions at eof
68 ofTruncate = std::ios::trunc, ///< ios::trunc, truncate file if already exists
69// ofNoCreate = (IOS_OMODE_LAST << 2), // ios::nocreate, open fails if file doesn't exist
70// ofNoReplace = (IOS_OMODE_LAST << 3), // ios::noreplace, open fails if file already exists
71#if defined(_IOS_Nocreate)
72 ofNoCreate = _IOS_Nocreate, ///< ios::nocreate, open fails if file doesn't exist
73#else
74 ofNoCreate = 0x40, ///< ios::nocreate, open fails if file doesn't exist
75#endif
76#if defined(_IOS_Noreplace)
77 ofNoReplace = _IOS_Noreplace, ///< ios::noreplace, open fails if file already exists
78#else
79 ofNoReplace = 0x80, ///< ios::noreplace, open fails if file already exists
80#endif
81 ofBinary = std::ios::binary, // ios::binary, binary (not text) file, no CR stripping
82 ofIosMask = 0x00FF, // all of the above bits as used by class ios
83
84 ofTransacted= 0x1000, ///< STGM_TRANSACTED, supports commit and revert
85 ofPreserve = 0x2000, ///< STGM_CONVERT, backup old data of same name
86 ofPriority = 0x4000, ///< STGM_PRIORITY, temporary efficient peeking
87 ofTemporary = 0x8000, ///< STGM_DELETEONRELEASE, delete when destructed
88
89 shCompat = 0x0600, ///< for non-compliant applications, avoid if possible
90 shNone = 0x0800, ///< EXCLUSIVE functionality
91 shRead = 0x0A00, ///< DENY_WRITE functionality
92 shWrite = 0x0C00, ///< DENY_READ functionality
93 shReadWrite = 0x0E00, ///< DENY_NONE functionality
94 shDefault = 0, ///< use stream implementation default value
96};
97#define PREV_OPEN (ofNoCreate|ofNoReplace)
98#define IS_PREV_OPEN(omode) ((omode & PREV_OPEN)==PREV_OPEN)
99
100//
101/// \name Definitions of WM_OWLNOTIFY event IDs (view notifications)
102/// @{
103/// event ID's up to vnCustomBase reserved for general doc-view notifications
104//
105const uint vnViewOpened = 1; ///< a new view has just been constructed
106const uint vnViewClosed = 2; ///< another view is about to be destructed
107const uint vnDocOpened = 3; ///< document has just been opened
108const uint vnDocClosed = 4; ///< document has just been closed
109const uint vnCommit = 5; ///< document is committing, flush cached changes
110const uint vnRevert = 6; ///< document has reverted, reload data from doc
111const uint vnIsDirty = 7; ///< respond true if uncommitted changes present
112const uint vnIsWindow = 8; ///< respond true if passed HWND is that of view
113const uint vnCustomBase = 100; ///< base of document class specific notifications
114/// @}
115
116//
117/// \name Document and view property access flags
118/// @{
119/// Define document and view property attributes. Documents, views, and applications
120/// use these attributes to determine how to process a document or view.
121//
122const uint pfGetText = 1; ///< property accessible as text format
123const uint pfGetBinary = 2; ///< property accessible as native non-text format
124const uint pfConstant = 4; ///< property is invariant for object instance
125const uint pfSettable = 8; ///< property settable as native format
126const uint pfUnknown = 16; ///< property defined but unavailable in object
127const uint pfHidden = 32; ///< property should be hidden from normal browse
128const uint pfUserDef =128; ///< property has been user-defined at run time
129/// @}
130
131//
132// Classes defined later in this file
133//
134class _OWLCLASS TStream;
135
136//
137// This causes
138// fatal error C1001: INTERNAL COMPILER ERROR (compiler file 'f:\vs70builds\3077\vc\Compiler\Utc\src\P2\p2symtab.c', line 4533)
139//class _OWLCLASS TInStream;
140//class _OWLCLASS TOutStream;
141class TInStream;
142class TOutStream;
143
144class _OWLCLASS TDocument;
145class _OWLCLASS TView;
146
147#include <owl/preclass.h>
148
149//
150/// \class TDocument
151// ~~~~~ ~~~~~~~~~
152/// An abstract base class, TDocument is the base class for all document objects and
153/// serves as an interface between the document, its views, and the document manager
154/// (TDocManager class). TDocument creates, destroys, and sends messages about the
155/// view. For example, if the user changes a document, TDocument tells the view that
156/// the document has been updated. The DEFINE_DOC_TEMPLATE_CLASS macro associates a
157/// document with its views.
158///
159/// In order to send messages to its associated views, the document maintains a list
160/// of all the views existing for that document and communicates with the views
161/// using ObjectWindows event-handling mechanism. Rather than using the function
162/// SendMessage(), the document accesses the view's event table. The views can update
163/// the document's data by calling the member functions of the particular document.
164/// Views can also request streams, which are constructed by the document.
165///
166/// Both documents and views have lists of properties for their applications to use.
167/// When documents and views are created or destroyed, messages are sent to the
168/// application, which can then query the properties to determine how to process the
169/// document or view. It is the document manager's responsibility to determine if a
170/// particular view is appropriate for the given document.
171///
172/// Because the property attribute functions are virtual, a derived class (which is
173/// called first) might override the properties defined in a base class. Each
174/// derived class must implement its own property attribute types of either string
175/// or binary data. If the derived class duplicates the property names of the parent
176/// class, it should provide the same behavior and data type as the parent.
177///
178/// In order to add persistence to documents, TDocument contains several virtual
179/// functions (for example, InStream and OutStream) that support streaming. Your
180/// derived classes need to override these functions in order to read and write
181/// data.
182///
183/// Although documents are usually associated with files, they do not necessarily
184/// have to be files; they can also consist of database tables, mail systems, fax or
185/// modem transmissions, disk directories, and so on.
186//
188 public:
189
190 /// These property values, which describe the basic properties of a document, are
191 /// available in classes derived from TDocument. They can be used to update and
192 /// query the attributes of a document. PrevProperty and NextProperty are delimiters
193 /// for every document's property list.
194 /// See GetProperty() and SetProperty() for more information.
195 //
196 enum TDocProp {
197 PrevProperty = 0, ///< Index of last property in base class (none in this case)
198 DocumentClass, ///< text Property: Name of C++ class encapsulating document
199 TemplateName, ///< text property: Name of template attached to document
200 ViewCount, ///< int property: Number of views displaying this document
201 StoragePath, ///< text property: Identifies object holding data of this document
202 DocTitle, ///< text property: Caption of this document
203 NextProperty, ///< Next index to be used by derived class
204 };
205
206 /// Document list class
207 //
208 /// The TDocument::TList nested class encapsulates the chain of documents. It allows
209 /// addition, removal, and destruction of documents from the document list.
211 public:
212/// Constructs a TDocument::TList object.
213 TList() : DocList(nullptr) {}
214
215/// Destroys a TDocument::TList object.
216 ~TList() {Destroy();}
217
218 bool Insert(TDocument* doc); ///< Inserts a new document into the document list. Fails if the document already exists.
219 bool Remove(TDocument* doc); ///< Removes a document from the document list, fails if not there
220 TDocument* Next(const TDocument* doc); ///< If the doc parameter is 0, Next returns the first document in the list of documents.
221 void Destroy(); ///< Deletes all documents
222 bool Contains(TDocument* doc); ///< Checks if doc is contained in the list
223 private:
224 TDocument* DocList;
225 };
226 typedef TList List; // for compatibility
227
228 // Document constructor / destructor
229 //
230 TDocument(TDocument* parent = nullptr);
231 virtual ~TDocument();
232
233 virtual TInStream* InStream(int mode, LPCTSTR strmId=nullptr);
234 TInStream* InStream(int mode, const tstring& streamId) {return InStream(mode, streamId.c_str());}
235 virtual TOutStream* OutStream(int mode, LPCTSTR strmId=nullptr);
236 TOutStream* OutStream(int mode, const tstring& streamId) {return OutStream(mode, streamId.c_str());}
237
238 virtual bool Open(int mode, LPCTSTR path=nullptr);
239 bool Open(int mode, const tstring& path) {return Open(mode, path.c_str());}
240
241 virtual bool Close(); ///< close document, does not delete or detach
242 virtual bool Commit(bool force=false); ///< save current data, force write
243 virtual bool Revert(bool clear=false); ///< abort changes, no reload if true
244 virtual TDocument& RootDocument();
245
246 TDocManager& GetDocManager();
247 void SetDocManager(TDocManager& dm);
248 TDocument* GetParentDoc();
249
250 TDocTemplate* GetTemplate();
251 bool SetTemplate(TDocTemplate* tpl);
252
253 LPCTSTR GetDocPath() const;
254 virtual bool SetDocPath(LPCTSTR path);
255 bool SetDocPath(const tstring& path) {return SetDocPath(path.c_str());}
256
257 LPCTSTR GetTitle() const;
258 virtual void SetTitle(LPCTSTR title);
259 void SetTitle(const tstring& title) {SetTitle(title.c_str());}
260
261 virtual bool IsDirty(); ///< Also queries doc and view hierarchy
262 void SetDirty(bool dirty = true);
263
264 virtual bool IsOpen();
265 virtual bool CanClose(); ///< Returns false if unable to close
266 virtual bool HasFocus(HWND hwnd); ///< Document (or child doc) has Focus
267 virtual TDocument* DocWithFocus(HWND hwnd); // Doc/ChildDoc with focus
268
269 bool NotifyViews(int eventId, TParam2 = 0, TView* exclude = nullptr);
270 bool NotifyOwnViews(int eventId, TParam2 = 0, TView* exclude = nullptr);
271 TView* QueryViews(int eventId, TParam2 = 0, TView* exclude = nullptr);
272 virtual uint PostError(uint sid, uint choice = MB_OK);
273
274 // Property access and info
275 //
276 virtual int PropertyCount();
277 virtual int FindProperty(LPCTSTR name); ///< return property index
278 int FindProperty(const tstring& name) {return FindProperty(name.c_str());}
279 virtual int PropertyFlags(int index); ///< pfXxxxx bit array
280 virtual LPCTSTR PropertyName(int index); ///< locale invariant name
281 virtual int GetProperty(int index, void * dest, int textlen=0);
282 virtual bool SetProperty(int index, const void * src); ///< native type
283
284 TList& GetChildren();
285
286 TView* GetViewList() const;
287 TView* NextView(const TView* view);
288
289 TStream* GetStreamList() const;
290 TStream* NextStream(const TStream* strm);
291
292 void * GetTag() const;
293 void SetTag(void* * tag);
294
295 int GetOpenMode() const;
296 void SetOpenMode(int mode);
297
298 TView* InitView(TView* view); ///< called from template InitView
299
300 bool IsEmbedded() const;
301 void SetEmbedded(bool embed);
302
303 virtual bool InitDoc();
304
305 public:
306 TDocument(TDocManager* docMan); ///< create a dummy document to hold docmgr
307
308 protected:
309 virtual void AttachStream(TStream& strm);///< called from TStream constructor
310 virtual void DetachStream(TStream& strm);///< called from TStream destructor
311
312 void DestroyViews();
313 void DestroyChildren();
314
316 /// Holds a pointer to the application-defined data. Typically, you can use Tag to
317 /// install a pointer to your own application's associated data structure. Tag,
318 /// which is initialized to 0 at the time a TDocument object is constructed, is not
319 /// otherwise used by the document view classes.
320 void * Tag;
321
322 TList ChildDoc; ///< The list of child documents associated with this document.
323
325
326/// Indicates that unsaved changes have been made to the document. Views can also
327/// independently maintain their local disk status.
328 bool DirtyFlag;
329
330 bool Embedded; ///< Indicates whether the document is embedded.
331
332// static int UntitledIndex;// last used index for Untitled document
333
334 private:
335 TDocManager* DocManager; ///< pointer back to document manager
336 TDocument* ParentDoc; ///< parent document, 0 if this is root document
337 TDocument* NextDoc; ///< next in linked chain of active documents
338 int OpenMode; ///< mode and protection flags
339 tchar * Title; ///< current document title, 0 if untitled
340 TDocTemplate* Template; ///< template associated with this document
341 TView* ViewList; ///< head of linked view chain, 0 if no views
342 TStream* StreamList; ///< head of linked stream chain, 0 if no streams
343 tchar * DocPath; ///< path used to open/save document
344
345 void ReindexFrames(); ///< force view title and index update
346 void AttachView(TView& view); ///< called from TView constructor
347 bool DetachView(TView& view); ///< called from TView destructor
348
349
350 friend class _OWLCLASS TDocTemplate; ///< access to InitView()
351 friend class _OWLCLASS TView; ///< access to Attach/DetatchView()
352 friend class _OWLCLASS TStream; ///< access to Attach/DetachStream()
353 friend class _OWLCLASS TDocManager;
354 friend class _OWLCLASS TList; ///< access to NextDoc
355
357};
358
360
361//
362/// \class TView
363// ~~~~~ ~~~~~
364/// Abstract base class for view access from document
365//
366/// Derived virtually from both TEventHandler and TStreamableBase, TView is the
367/// interface presented to a document so it can access its client views. Views then
368/// call the document functions to request input and output streams. Views own the
369/// streams and are responsible for attaching and deleting them.
370///
371/// Instead of creating an instance of TView, you create a derived class that can
372/// implement TView's virtual functions. The derived class must have a way of
373/// knowing the associated window (provided by GetWindow()) and of describing the view
374/// (provided by GetViewName()). The view must also be able to display the document
375/// title in its window (SetDocTitle()).
376/// Classes derived from TView may need to handle several notification messages. For
377/// example, if a view is associated with a window that can gain focus, then the
378/// view should handle the vnIsWindow notification message.
379///
380/// View classes can take various forms. For example, a view class can be a window
381/// (through inheritance), can contain a window (an embedded object), can reference
382/// a window, or can be contained within a window object. A view class might not
383/// even have a window, as in the case of a voice mail or a format converter. Some
384/// remote views (for example, those displayed by DDE servers) might not have local
385/// windows.
386///
387/// Other viewer classes derived from TView include TEditView, TListBoxView, and
388/// TWindowView. These classes display different types of data: TEditView displays
389/// unformatted text files, TListBoxView displays text information in a list box, and
390/// TWindowView is a basic viewer from which you can derive other types of viewers
391/// such as hexadecimal file viewers.
392///
393/// For OLE-enabled applications, use TOleView, which supports views for embedded
394/// objects and compound documents.
395//
396class _OWLCLASS TView : virtual public TEventHandler,
397 virtual public TStreamableBase {
398 public:
399/// These property values, which describe the basic properties of a view, are
400/// available in classes derived from TView. They can be used to update and query
401/// the attributes of a view. PrevProperty and NextProperty are delimiters for every
402/// view's property list.
404 PrevProperty = 0, ///< Index of last property in base class.
405 ViewClass, ///< Name of the C++ class encapsulating the view. (text)
406 ViewName, ///< Name of the view. (text)
407 NextProperty, ///< Next index to be used by derived class.
408 };
409
411 virtual ~TView();
412
413 TDocument& GetDocument();
414 void SetDocument(TDocument&); // Added by Vidar Hasfjord, 2007-08-27.
415
416 uint GetViewId();
417
418 virtual TMenuDescr* GetViewMenu();
419 virtual TBarDescr* GetViewBar();
420 void SetViewMenu(TMenuDescr* menu);
421 void SetViewBar(TBarDescr* bar);
422
423 bool IsOK(); ///< true if successfully created
424
425 static uint GetNextViewId(); ///< Next global ID to assign
426 static void BumpNextViewId();
427
428 TView* GetNextView();
429
430 /// Pure virtual function that returns 0. Override this function in your derived
431 /// class to return the name of the class.
432 /// Must implement, used by template manager for selection
433 /// \code
434 /// static LPCTSTR StaticName() {return "name of view";}
435 /// \endcode
436 virtual LPCTSTR GetViewName() = 0;
437
438/// Returns the TWindow instance associated with the view, or 0 if no view exists.
439 virtual TWindow* GetWindow(); // if not derived from TWindow
440
441 virtual bool SetDocTitle(LPCTSTR docname, int index);
442 bool SetDocTitle(const tstring& docname, int index) {return SetDocTitle(docname.c_str(), index);}
443
444 // Property access and info
445 //
446 virtual int PropertyCount();
447 virtual int FindProperty(LPCTSTR name);///< return property index
448 int FindProperty(const tstring& name) {return FindProperty(name.c_str());}
449 virtual int PropertyFlags(int index); ///< pfXxxxx bit array
450 virtual LPCTSTR PropertyName(int index); ///< locale invariant name
451 virtual int GetProperty(int index, void * dest, int textlen=0);
452 virtual bool SetProperty(int index, const void * src);
453
454 void * GetTag() const;
455 void SetTag(void* * tag);
456
457 protected:
458 void NotOK(); ///< To flag errors in creation
459
461 TDocument* Doc; ///< Holds the current document.
462
464 /// Application hook, not used internally
465 /// Holds a pointer to the application-defined data. Typically, you can use Tag to
466 /// install a pointer to your own application's associated data structure. TView
467 /// zeros Tag during construction and does not access it again.
468 void * Tag;
469
470 private:
471 TView* NextView; ///< Linked view chain, 0 if no more views
472 uint ViewId; ///< Unique ID for this view, used for controls
473 TMenuDescr* ViewMenu; ///< Menu descriptor specific for this view or 0
474 TBarDescr* ViewBar; ///< Bar descriptor specific for this view or 0
475 static uint NextViewId; ///< Next view ID to be assigned to a view
476
477 friend class _OWLCLASS TDocument; ///< needs access to NextView
478#if OWL_PERSISTENT_STREAMS
479 friend class TDocument::Streamer; ///< needs access to NextView
480#endif
482};
483
485
486//
487/// \class TWindowView
488// ~~~~~ ~~~~~~~~~~~
489/// Derived from both TWindow and TView, TWindowView is a streamable base class that
490/// can be used for deriving window-based views. TWindowView's functions override
491/// TView's virtual function to provide their own implementation. By deriving a
492/// window-view class from TWindow and TView, you add window functionality to the
493/// view of your document.
494class _OWLCLASS TWindowView : public TWindow, public TView {
495 public:
496 TWindowView(TDocument& doc, TWindow* parent = nullptr);
497 ~TWindowView() override;
498
499 static LPCTSTR StaticName(); ///< put in resource
500
501 // Override virtuals from TWindow
502 //
503 auto CanClose() -> bool override;
504
505 // Override virtuals from TView
506 //
507 auto GetViewName() -> LPCTSTR override;
508 auto GetWindow() -> TWindow* override;
509 auto SetDocTitle(LPCTSTR docname, int index) -> bool override;
510 using TView::SetDocTitle; ///< String-aware overload
511
512 private:
513 // Event handlers
514 //
515 bool VnIsWindow(HWND hWnd);
516
519};
520
522
523
524//
525/// \class TDialogView
526// ~~~~~ ~~~~~~~~~~~
527/// Derived from TDialog and TView.
528/// Must be overriden, derived class have to define resId
529//
530class _OWLCLASS TDialogView : public TDialog, public TView {
531 public:
535 ~TDialogView() override;
536
537 static LPCTSTR StaticName(); // put in resource
538
539 // Override virtuals from TWindow
540 //
541 auto CanClose() -> bool override;
542
543 // Override virtuals from TView
544 //
545 auto GetViewName() -> LPCTSTR override;
546 auto GetWindow() -> TWindow* override;
547 auto SetDocTitle(LPCTSTR docname, int index) -> bool override;
548 using TView::SetDocTitle; ///< String-aware overload
549
550 private:
551 // Event handlers
552 //
553 bool VnIsWindow(HWND hWnd);
554
557
558};
559
561
562//
563/// \class TStream
564// ~~~~~ ~~~~~~~
565/// An abstract base class, TStream provides links between streams and documents,
566/// views, and document files.
567//
569 public:
570 TDocument& GetDocument();
571 ~TStream();
572 int GetOpenMode();
573 LPCTSTR GetStreamName();
574
575 protected:
576 TDocument& Doc; ///< Stores the document that owns this stream.
577 TStream* NextStream; ///< Points to the next stream in the list of active streams.
578
579 TStream(TDocument& doc, LPCTSTR name, int mode);
580
581 private:
582 int OpenMode;
583 LPCTSTR StreamName;
584
585 friend class TDocument;
586};
587
588//
589/// \class TInStream
590// ~~~~~ ~~~~~~~~~
591/// Derived from TStream and istream, TInStream is a base class used to define input
592/// streams for documents.
593//
594class TInStream : public TStream, public tistream {
595 public:
596 TInStream(TDocument& doc, LPCTSTR name, int mode);
597};
598
599//
600/// \class TOutStream
601// ~~~~~ ~~~~~~~~~~
602/// Derived from TStream and ostream, TOutStream is a base class used to create
603/// output storage streams for a document.
604//
605class TOutStream : public TStream, public tostream {
606 public:
607 TOutStream(TDocument& doc, LPCTSTR name, int mode);
608};
609
610#include <owl/posclass.h>
611
612//----------------------------------------------------------------------------
613// View Notification Handler Definitions
614//
615
616#if defined(OWL5_COMPAT)
617
618//
619// DocView aliases to actual dispatchers
620//
621#define Dispatch_B_void Dispatch_B ///< No parameters
622#define Dispatch_B_int Dispatch_B_I ///< TParam2 as int
623#define Dispatch_B_pointer Dispatch_B_POINTER ///< TParam2 as void*
624
625//
626// Define a DocView notification signature
627// 'id' is the vnXxxXxx name of the notification
628// 'arg' is the type of the arg passed to the handler
629//
630#define NOTIFY_SIG(id, arg) \
631 template <class T> \
632 inline bool (T::*id##_Sig(bool (T::*pmf)(arg)))(arg) {return pmf;}
633
638NOTIFY_SIG(vnCommit, bool)
639NOTIFY_SIG(vnRevert, bool)
642
643#endif
644
645//
646// TDispatch specializations for the DocView messages
647//
648
649template <> struct TDispatch<WM_OWLDOCUMENT>
650{
651 template <class F>
653 {sendMessage(wnd, WM_OWLDOCUMENT, 0, reinterpret_cast<TParam2>(&d));}
654
655#if OWL_EV_SIGNATURE_CHECK
656
657 template <class T> struct THandler {typedef void (T::*type)(TDocument&);};
658
659#endif
660
661 template <class T, void (T::*M)(TDocument&)>
663 {
665 return p2 != 0 ? ((static_cast<T*>(i)->*M)(*reinterpret_cast<TDocument*>(p2)), 0) : 0;
666 }
667};
668
669template <> struct TDispatch<WM_OWLVIEW>
670{
671 template <class F>
672 static void Encode(F sendMessage, HWND wnd, TView& v)
673 {sendMessage(wnd, WM_OWLVIEW, 0, reinterpret_cast<TParam2>(&v));}
674
675#if OWL_EV_SIGNATURE_CHECK
676
677 template <class T> struct THandler {typedef void (T::*type)(TView&);};
678
679#endif
680
681 template <class T, void (T::*M)(TView&)>
683 {
685 return p2 != 0 ? ((static_cast<T*>(i)->*M)(*reinterpret_cast<TView*>(p2)), 0) : 0;
686 }
687};
688
689template <> struct TDispatch<WM_OWLNOTIFY>
690{
691 static const TMsgId MessageId = WM_OWLNOTIFY;
692
693 template <class F>
695 {return static_cast<bool>(sendMessage(wnd, MessageId, 0, p2));}
696
697#if OWL_EV_SIGNATURE_CHECK
698
699 template <class T> struct THandler {typedef bool (T::*type)(TParam2);};
700
701#endif
702
703 template <class T, bool (T::*M)(TParam2)>
705 {return (static_cast<T*>(i)->*M)(p2) ? TRUE : FALSE;}
706
707 template <uint NotificationCode>
709
710 //
711 // All the standard DocView notifications return 'bool' and have a single (or no) parameter
712 // passed through TParam2. We can implement this as a common base template.
713 //
714 template <uint NotificationCode, class P>
715 struct TNotificationDispatchBase
716 {
717 template <class F>
718 static bool Encode(F sendMessage, HWND wnd, P p)
719 {return static_cast<bool>(sendMessage(wnd, MessageId, NotificationCode, static_cast<TParam2>(p)));}
720
721#if OWL_EV_SIGNATURE_CHECK
722
723 template <class T> struct THandler {typedef bool (T::*type)(P);};
724
725#endif
726
727 template <class T, bool (T::*M)(P)>
729 {return (static_cast<T*>(i)->*M)((P) p2) ? TRUE : FALSE;}
730 };
731
732 //
733 // Specialization for the void parameter case
734 //
735 template <uint NotificationCode>
736 struct TNotificationDispatchBase<NotificationCode, void>
737 {
738 template <class F>
739 static bool Encode(F sendMessage, HWND wnd)
740 {return static_cast<bool>(sendMessage(wnd, MessageId, NotificationCode));}
741
742#if OWL_EV_SIGNATURE_CHECK
743
744 template <class T> struct THandler {typedef bool (T::*type)();};
745
746#endif
747
748 template <class T, bool (T::*M)()>
750 {return (static_cast<T*>(i)->*M)() ? TRUE : FALSE;}
751 };
752
753};
754
755template <> struct TDispatch<WM_OWLNOTIFY>::TNotificationDispatch<vnDocOpened> : TNotificationDispatchBase<vnDocOpened, int> {};
756template <> struct TDispatch<WM_OWLNOTIFY>::TNotificationDispatch<vnDocClosed> : TNotificationDispatchBase<vnDocClosed, int> {};
757template <> struct TDispatch<WM_OWLNOTIFY>::TNotificationDispatch<vnViewOpened> : TNotificationDispatchBase<vnViewOpened, TView*> {};
758template <> struct TDispatch<WM_OWLNOTIFY>::TNotificationDispatch<vnViewClosed> : TNotificationDispatchBase<vnViewClosed, TView*> {};
759template <> struct TDispatch<WM_OWLNOTIFY>::TNotificationDispatch<vnCommit> : TNotificationDispatchBase<vnCommit, bool> {};
760template <> struct TDispatch<WM_OWLNOTIFY>::TNotificationDispatch<vnRevert> : TNotificationDispatchBase<vnRevert, bool> {};
761template <> struct TDispatch<WM_OWLNOTIFY>::TNotificationDispatch<vnIsDirty> : TNotificationDispatchBase<vnIsDirty, void> {};
762template <> struct TDispatch<WM_OWLNOTIFY>::TNotificationDispatch<vnIsWindow> : TNotificationDispatchBase<vnIsWindow, HWND> {};
763
764//
765/// Defines a DocView notification response entry.
766/// - 'id' is the notification id,
767/// - 'method' is the name of the method to be notified, and
768/// - 'dispatcher' is the name of the dispatcher to use.
769//
770#define VN_DEFINE(id, method, dispatcher)\
771 {{WM_OWLNOTIFY}, static_cast<::owl::uint>(id), OWL_DISPATCH(dispatcher, method)}
772
773#if OWL_EV_SIGNATURE_CHECK
774
775//
776// Internal macro using dispatcher lookup in the TDispatch<WM_OWLNOTIFY> specialization
777//
778#define VN_DEFINE_STANDARD_(id, method)\
779 {{WM_OWLNOTIFY}, static_cast<::owl::uint>(id),\
780 (::owl::CheckSignature<TMyClass, WM_OWLNOTIFY, static_cast<::owl::uint>(id), ::owl::TDispatch>(&TMyClass::method),\
781 OWL_DISPATCH(::owl::TDispatch<WM_OWLNOTIFY>::TNotificationDispatch<static_cast<::owl::uint>(id)>::Decode, method))}
782
783#else
784
785//
786// Internal macro using dispatcher lookup in the TDispatch<WM_OWLNOTIFY> specialization
787//
788#define VN_DEFINE_STANDARD_(id, method)\
789 {{WM_OWLNOTIFY}, static_cast<::owl::uint>(id),\
790 OWL_DISPATCH(::owl::TDispatch<WM_OWLNOTIFY>::TNotificationDispatch<static_cast<::owl::uint>(id)>::Decode, method)}
791
792#endif
793
794//
795/// \name Standard view notificaton events
796/// @{
797/// These macros handle view-related messages generated by the document manager.
798//
799#define EV_VN_VIEWOPENED VN_DEFINE_STANDARD_(::owl::vnViewOpened, VnViewOpened)
800#define EV_VN_VIEWCLOSED VN_DEFINE_STANDARD_(::owl::vnViewClosed, VnViewClosed)
801#define EV_VN_DOCOPENED VN_DEFINE_STANDARD_(::owl::vnDocOpened, VnDocOpened)
802#define EV_VN_DOCCLOSED VN_DEFINE_STANDARD_(::owl::vnDocClosed, VnDocClosed)
803#define EV_VN_COMMIT VN_DEFINE_STANDARD_(::owl::vnCommit, VnCommit)
804#define EV_VN_REVERT VN_DEFINE_STANDARD_(::owl::vnRevert, VnRevert)
805#define EV_VN_ISDIRTY VN_DEFINE_STANDARD_(::owl::vnIsDirty, VnIsDirty)
806#define EV_VN_ISWINDOW VN_DEFINE_STANDARD_(::owl::vnIsWindow, VnIsWindow)
807
808/// @}
809
810/// @}
811
812//----------------------------------------------------------------------------
813// Inline implementations
814//
815
816//
817/// Generic input for the particular storage medium, InStream returns a pointer to a
818/// TInStream. mode is a combination of the ios bits defined in iostream.h. See the
819/// document open mode constants for a list of the open modes. Used for documents
820/// that support named streams, strmId is a pointer to the name of a stream.
821/// Override this function to provide streaming for your document class.
822//
823inline TInStream* TDocument::InStream(int /*mode*/, LPCTSTR /*strmId*/) {
824 return nullptr;
825}
826
827//
828/// Generic output for the particular storage medium, OutStream returns a pointer to
829/// a TOutStream. mode is a combination of the ios bits defined in iostream.h. Used
830/// for documents that support named streams, strmId points to the name of the
831/// stream. TDocument::OutStream version always returns 0. Override this function to
832/// provide streaming for your document class.
833//
834inline TOutStream* TDocument::OutStream(int /*mode*/, LPCTSTR /*strmId*/) {
835 return nullptr;
836}
837
838//
839/// Opens the document using the path specified by DocPath. Sets OpenMode to mode.
840/// TDocument::Open always returns true and actually performs no actions. Other
841/// classes override this function to open specified file documents and views.
842//
843inline bool TDocument::Open(int /*mode*/, LPCTSTR /*path*/) {
844 return true;
845}
846
847//
848/// Returns a pointer to the current document manager.
849//
851 return *DocManager;
852}
853
854//
855/// Returns either the parent document of the current document or 0 if there is no
856/// parent document.
857//
859 return ParentDoc;
860}
861
862//
863/// Gets the template used for document creation. The template can be changed during
864/// a SaveAs operation.
865//
867 return Template;
868}
869
870//
871/// Returns the directory path for the document. This might change the SaveAs
872/// operation.
873//
875 return DocPath;
876}
877
878//
879/// Returns the title of the document.
880//
882 return Title;
883}
884
885//
886/// Updates the document's dirty flag using the specified parameter.
887//
888inline void TDocument::SetDirty(bool dirty) {
889 DirtyFlag = dirty;
890}
891
892//
893/// Checks to see if the document has any streams in its stream list. Returns false
894/// if no streams are open; otherwise, returns true.
895//
896inline bool TDocument::IsOpen() {
897 return StreamList != nullptr;
898}
899
900//
901/// Gets the total number of properties for the TDocument object. Returns
902/// NextProperty -1.
903//
905 return NextProperty-1;
906}
907
908//
909/// Returns true if the document is embedded in an OLE 2 container.
910//
911inline bool TDocument::IsEmbedded() const {
912 return Embedded;
913}
914
915//
916/// Marks the document as being embedded in an OLE 2 container. Typically, this
917/// happens when the server is created and when the factory template class creates
918/// the component.
919//
920inline void TDocument::SetEmbedded(bool embed) {
921 Embedded = embed;
922}
923
924//
925/// A virtual method that is overridden by TOleDocument::InitDoc. You can use this
926/// function to prepare the document before the view is constructed and before the
927/// dnCreate event, which indicates that the document has been created and is
928/// posted.
929//
930inline bool TDocument::InitDoc() {
931 return true;
932}
933
934//
935/// Return reference to the children document list.
936//
938 return ChildDoc;
939}
940
941//
942/// Return pointer to the head of the link list of views associated with this
943/// document.
944/// \note To iterate through all the views, use the 'NextView' method with
945/// the pointer obtained from this method.
946//
948 return ViewList;
949}
950
951//
952/// Returns head of the link list of streams associated with this document.
953/// \note To iterate through all the streams, use the 'NextStream' method with the
954/// pointer returned from this method.
955//
957 return StreamList;
958}
959
960//
961/// Returns pointer to user-defined data [i.e. tag] attached to this document.
962//
963inline void * TDocument::GetTag() const {
964 return Tag;
965}
966
967//
968/// Attach an arbitrary (user-defined) pointer with this document.
969/// \note The 'Tag' is a place-holder. It is not used by the Doc/View subsystem.
970//
971inline void TDocument::SetTag(void* * tag) {
972 Tag = tag;
973}
974
975//
976/// Create a dummy document to hold docmgr.
977//
979:
980 DocManager(docMan), ParentDoc(this)
981{}
982
983//
984/// Gets the mode and protection flag values for the current document.
985//
986inline int
988{
989 return OpenMode;
990}
991
992//
993/// Sets the mode and protection flag values for the current document.
994//
995inline void
997{
998 OpenMode = mode;
999}
1000
1001//
1002/// Returns a reference to the view's document.
1003//
1005 return *Doc;
1006}
1007
1008//
1009/// Returns the unique ID for this view.
1010//
1012 return ViewId;
1013}
1014
1015//
1016/// Returns the menu descriptor for this view. This can be any existing TMenuDescr
1017/// object. If no descriptor exists, ViewMenu is 0.
1018//
1020 return ViewMenu;
1021}
1022
1023//
1025 return ViewBar;
1026}
1027
1028//
1029/// Returns a nonzero value if the view is successfully constructed.
1030//
1031inline bool TView::IsOK() {
1032 return ViewId != 0;
1033}
1034//
1035/// Returns the next view ID to be assigned.
1036//
1038 return NextViewId;
1039}
1040
1041//
1042/// Returns the next global view ID to be assigned.
1043//
1045 return NextView;
1046}
1047
1048//
1050 return nullptr;
1051}
1052
1053//
1054/// Retrieves the user-defined pointer attached to this view.
1055//
1056inline void * TView::GetTag() const {
1057 return Tag;
1058}
1059
1060//
1061/// Associates an arbitrary (user-defined) pointer with this view.
1062/// \note The 'Tag' is not used by the Doc/View subsystem.
1063//
1064inline void TView::SetTag(void* * tag) {
1065 Tag = tag;
1066}
1067
1068//
1069/// Stores the document title.
1070//
1071inline bool TView::SetDocTitle(LPCTSTR /*docname*/, int /*index*/) {
1072 return false;
1073}
1074
1075//
1076/// Gets the total number of properties for the TDocument object.
1077//
1079 return NextProperty - 1;
1080}
1081
1082//
1083/// Sets the value of the property, given the index of the property, and src, the
1084/// data type (either binary or text) to which the property must be set.
1085//
1086inline bool TView::SetProperty(int /*index*/, const void * /*src*/) {
1087 return false;
1088}
1089
1090//
1091/// Sets the view to an invalid state, causing IsOK to return 0.
1092//
1093inline void TView::NotOK() {
1094 ViewId = 0;
1095}
1096
1097//
1098// class TWindowView
1099// ~~~~~ ~~~~~~~~~~~
1100/// Destroys a TWindowView object and calls the associated document's DetachView
1101/// function (a private TDocument function) to detach the view from the associated
1102/// document.
1103//
1106
1107//
1108/// Returns "Window View," the descriptive name of the view. This title is displayed
1109/// in the user-interface box.
1110//
1112 return _T("Window View");
1113}
1114
1115//
1116/// Does a given HWND belong to this view? Yes if it is us, or a child of us
1117//
1118inline bool TWindowView::VnIsWindow(HWND hWnd){
1119 return hWnd == GetHandle() || IsChild(hWnd);
1120}
1121//
1122/// Overrides TWindow::CanClose and returns a nonzero value if the window can be
1123/// closed. CanClose checks all the associated document's CanClose functions. These
1124/// must return nonzero values before the window view can be closed.
1125//
1126/// Only query document if this is the last view open to it.
1127//
1129 return TWindow::CanClose() &&
1130 (Doc->NextView(this) ||
1131 Doc->NextView(nullptr) != this ||
1132 Doc->CanClose());
1133}
1134
1135//
1136/// Overrides TView::GetViewName and returns StaticName, the name of the view.
1137//
1139 return StaticName();
1140}
1141
1142//
1143/// Overrides TView::GetWindow and returns the TWindowView object as a TWindow.
1144//
1146 return static_cast<TWindow*>(this);
1147}
1148
1149//
1150/// Overrides TView::SetDocTitle and stores the document title. This name is
1151/// forwarded up the parent chain until a TFrameWindow object accepts the data and
1152/// displays it in its caption.
1153//
1155 return TWindow::SetDocTitle(docname, index);
1156}
1157
1158//
1159/// class TDialogView
1160// ~~~~~ ~~~~~~~~~~~
1163
1164//
1166 return _T("Dialog View");
1167}
1168
1169//
1170/// Only query document if this is the last view open to it.
1171//
1173 return TDialog::CanClose() &&
1174 (Doc->NextView(this) ||
1175 Doc->NextView(nullptr) != this ||
1176 Doc->CanClose());
1177}
1178
1179//
1181 return StaticName();
1182}
1183
1184//
1186 return static_cast<TWindow*>(this);
1187}
1188
1189//
1190/// Does a given HWND belong to this view? Yes if it is us, or a child of us
1191//
1192inline bool TDialogView::VnIsWindow(HWND hWnd){
1193 return hWnd == GetHandle() || IsChild(hWnd);
1194}
1195
1196//
1198 return TDialog::SetDocTitle(docname, index);
1199}
1200
1201//
1202// class TStream
1203// ~~~~~ ~~~~~~~
1204//
1205/// Returns the current document that is open for streaming.
1206//
1208 return Doc;
1209}
1210
1211//
1212/// Closes the stream. Derived classes generally close the document if it was opened
1213/// especially for this stream.
1214//
1216 Doc.DetachStream(*this);
1217}
1218
1219//
1220/// Constructs a TStream object.
1221/// 'name' is the user-defined name of the stream and can be 0.
1222/// Note: If 'name' is not null, the referenced string must outlive the object. No copy is made.
1223//
1225:
1226 Doc(doc),
1227 OpenMode(mode),
1228 StreamName(name)
1229{
1230 Doc.AttachStream(*this);
1231}
1232
1233//
1234/// Gets the name of the stream used for opening the document.
1235//
1237 return StreamName;
1238}
1239
1240//
1241/// Gets mode flags used when opening document streams. For example, the stream can
1242/// be opened in ofRead mode to allow reading, but not changing (writing to) the
1243/// file.
1244//
1246 return OpenMode;
1247}
1248
1249//
1250// WORK-AROUND: Fix for a bug in the Dinkumware standard library; double-init memory leak.
1251// Using 0 as the stream initializer in the Dinkumware version of the library sets the stream buffer
1252// to 0 and also sets an error state of the stream. Also, research on the net indicate that this causes
1253// a double-init memory leak.
1254//
1255// TODO: Research which versions are affected and how, and reliably detect only these.
1256//
1257#if defined(_CPPLIB_VER) // Defined by Dinkumware - assume this detects the library.
1258#define OWL_STREAM_NULL_INITIALIZER std::_Noinit
1259#else
1260#define OWL_STREAM_NULL_INITIALIZER 0
1261#endif
1262
1263//
1264/// Constructs a TInStream object.
1265/// 'name' is the user-defined name of the stream and can be 0.
1266/// Note: If 'name' is not null, the referenced string must outlive the object. No copy is made.
1267//
1269:
1270 TStream(doc, name, mode),
1271 tistream(OWL_STREAM_NULL_INITIALIZER) // init base to null, don't forget to call init.
1272{}
1273
1274//
1275/// Constructs a TOutStream object.
1276/// 'name' is the user-defined name of the stream and can be 0.
1277/// Note: If 'name' is not null, the referenced string must outlive the object. No copy is made.
1278//
1280:
1281 TStream(doc, name, mode),
1282 tostream(OWL_STREAM_NULL_INITIALIZER) // init base to null, don't forget to call init.
1283{}
1284
1285
1286} // OWL namespace
1287
1289
1290#endif // OWL_DOCVIEW_H
Definition of class TApplication.
#define PRECONDITION(condition)
Definition checks.h:227
Descriptor of Bar Implementation.
Definition bardescr.h:71
Typically used to obtain information from a user, a dialog box is a window inside of which other cont...
Definition dialog.h:85
Derived from TDialog and TView.
Definition docview.h:530
auto GetWindow() -> TWindow *override
Definition docview.h:1185
auto GetViewName() -> LPCTSTR override
Definition docview.h:1180
~TDialogView() override
class TDialogView
Definition docview.h:1161
static LPCTSTR StaticName()
Definition docview.h:1165
auto SetDocTitle(LPCTSTR docname, int index) -> bool override
Definition docview.h:1197
auto CanClose() -> bool override
Only query document if this is the last view open to it.
Definition docview.h:1172
TDocManager creates a document manager object that manages the list of current documents and register...
Definition docmanag.h:100
TDocTemplate is an abstract base class that contains document template functionality.
Definition doctpl.h:54
Document list class.
Definition docview.h:210
TList()
Constructs a TDocument::TList object.
Definition docview.h:213
~TList()
Destroys a TDocument::TList object.
Definition docview.h:216
An abstract base class, TDocument is the base class for all document objects and serves as an interfa...
Definition docview.h:187
virtual TInStream * InStream(int mode, LPCTSTR strmId=nullptr)
Generic input for the particular storage medium, InStream returns a pointer to a TInStream.
Definition docview.h:823
void SetTitle(const tstring &title)
Definition docview.h:259
void * GetTag() const
Returns pointer to user-defined data [i.e. tag] attached to this document.
Definition docview.h:963
TInStream * InStream(int mode, const tstring &streamId)
Definition docview.h:234
TDocument(TDocument *parent=nullptr)
Although you do not create a TDocument object directly, you must call the constructor when you create...
Definition document.cpp:34
bool Open(int mode, const tstring &path)
Definition docview.h:239
TDocTemplate * GetTemplate()
Gets the template used for document creation.
Definition docview.h:866
TList & GetChildren()
Return reference to the children document list.
Definition docview.h:937
bool SetDocPath(const tstring &path)
Definition docview.h:255
virtual void DetachStream(TStream &strm)
called from TStream destructor
Definition document.cpp:452
virtual bool InitDoc()
A virtual method that is overridden by TOleDocument::InitDoc.
Definition docview.h:930
LPCTSTR GetDocPath() const
Returns the directory path for the document.
Definition docview.h:874
TStream * GetStreamList() const
Returns head of the link list of streams associated with this document.
Definition docview.h:956
virtual void AttachStream(TStream &strm)
called from TStream constructor
Definition document.cpp:441
int FindProperty(const tstring &name)
Definition docview.h:278
TDocManager & GetDocManager()
Returns a pointer to the current document manager.
Definition docview.h:850
LPCTSTR GetTitle() const
Returns the title of the document.
Definition docview.h:881
virtual int PropertyCount()
Gets the total number of properties for the TDocument object.
Definition docview.h:904
void SetTag(void **tag)
Attach an arbitrary (user-defined) pointer with this document.
Definition docview.h:971
void SetOpenMode(int mode)
Sets the mode and protection flag values for the current document.
Definition docview.h:996
void SetDirty(bool dirty=true)
Updates the document's dirty flag using the specified parameter.
Definition docview.h:888
TView * GetViewList() const
Return pointer to the head of the link list of views associated with this document.
Definition docview.h:947
bool IsEmbedded() const
Returns true if the document is embedded in an OLE 2 container.
Definition docview.h:911
TOutStream * OutStream(int mode, const tstring &streamId)
Definition docview.h:236
virtual bool Open(int mode, LPCTSTR path=nullptr)
Opens the document using the path specified by DocPath.
Definition docview.h:843
TDocProp
These property values, which describe the basic properties of a document, are available in classes de...
Definition docview.h:196
@ TemplateName
text property: Name of template attached to document
Definition docview.h:199
@ StoragePath
text property: Identifies object holding data of this document
Definition docview.h:201
@ NextProperty
Next index to be used by derived class.
Definition docview.h:203
@ ViewCount
int property: Number of views displaying this document
Definition docview.h:200
@ DocumentClass
text Property: Name of C++ class encapsulating document
Definition docview.h:198
@ DocTitle
text property: Caption of this document
Definition docview.h:202
virtual bool IsOpen()
Checks to see if the document has any streams in its stream list.
Definition docview.h:896
int GetOpenMode() const
Gets the mode and protection flag values for the current document.
Definition docview.h:987
virtual TOutStream * OutStream(int mode, LPCTSTR strmId=nullptr)
Generic output for the particular storage medium, OutStream returns a pointer to a TOutStream.
Definition docview.h:834
void SetEmbedded(bool embed)
Marks the document as being embedded in an OLE 2 container.
Definition docview.h:920
TDocument * GetParentDoc()
Returns either the parent document of the current document or 0 if there is no parent document.
Definition docview.h:858
TEventHandler is a base class from which you can derive classes that handle messages.
Definition eventhan.h:162
Derived from TStream and istream, TInStream is a base class used to define input streams for document...
Definition docview.h:594
TInStream(TDocument &doc, LPCTSTR name, int mode)
Constructs a TInStream object.
Definition docview.h:1268
Menu with information used to allow merging.
Definition menu.h:206
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
Definition module.h:75
Derived from TStream and ostream, TOutStream is a base class used to create output storage streams fo...
Definition docview.h:605
TOutStream(TDocument &doc, LPCTSTR name, int mode)
Constructs a TOutStream object.
Definition docview.h:1279
An abstract base class, TStream provides links between streams and documents, views,...
Definition docview.h:568
TStream * NextStream
Points to the next stream in the list of active streams.
Definition docview.h:577
TStream(TDocument &doc, LPCTSTR name, int mode)
Constructs a TStream object.
Definition docview.h:1224
TDocument & Doc
Stores the document that owns this stream.
Definition docview.h:576
int GetOpenMode()
Gets mode flags used when opening document streams.
Definition docview.h:1245
LPCTSTR GetStreamName()
Gets the name of the stream used for opening the document.
Definition docview.h:1236
TDocument & GetDocument()
Returns the current document that is open for streaming.
Definition docview.h:1207
~TStream()
Closes the stream.
Definition docview.h:1215
Classes that inherit from TStreamableBase are known as streamable classes (their objects can be writt...
Definition objstrm.h:108
Abstract base class for view access from document.
Definition docview.h:397
bool IsOK()
true if successfully created
Definition docview.h:1031
TViewProp
These property values, which describe the basic properties of a view, are available in classes derive...
Definition docview.h:403
@ ViewClass
Name of the C++ class encapsulating the view. (text)
Definition docview.h:405
@ ViewName
Name of the view. (text)
Definition docview.h:406
@ NextProperty
Next index to be used by derived class.
Definition docview.h:407
int FindProperty(const tstring &name)
Definition docview.h:448
virtual bool SetDocTitle(LPCTSTR docname, int index)
Stores the document title.
Definition docview.h:1071
uint GetViewId()
Returns the unique ID for this view.
Definition docview.h:1011
void * GetTag() const
Retrieves the user-defined pointer attached to this view.
Definition docview.h:1056
TView * GetNextView()
Returns the next global view ID to be assigned.
Definition docview.h:1044
virtual TMenuDescr * GetViewMenu()
Returns the menu descriptor for this view.
Definition docview.h:1019
bool SetDocTitle(const tstring &docname, int index)
Definition docview.h:442
virtual LPCTSTR GetViewName()=0
Pure virtual function that returns 0.
void SetTag(void **tag)
Associates an arbitrary (user-defined) pointer with this view.
Definition docview.h:1064
TDocument & GetDocument()
Returns a reference to the view's document.
Definition docview.h:1004
static uint GetNextViewId()
Next global ID to assign.
Definition docview.h:1037
virtual TBarDescr * GetViewBar()
Definition docview.h:1024
virtual int PropertyCount()
Gets the total number of properties for the TDocument object.
Definition docview.h:1078
virtual TWindow * GetWindow()
Returns the TWindow instance associated with the view, or 0 if no view exists.
Definition docview.h:1049
void NotOK()
To flag errors in creation.
Definition docview.h:1093
virtual bool SetProperty(int index, const void *src)
Sets the value of the property, given the index of the property, and src, the data type (either binar...
Definition docview.h:1086
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
Definition window.h:414
virtual bool SetDocTitle(LPCTSTR docname, int index)
Default behavior for updating document title is to pass it to parent frame.
Definition window.cpp:778
bool IsChild(HWND hWnd) const
Returns true if the window is a child window or a descendant window of this window.
Definition window.h:3176
virtual bool CanClose()
Use this function to determine if it is okay to close a window.
Definition window.cpp:2795
HWND GetHandle() const
Returns the handle of the window.
Definition window.h:2020
Derived from both TWindow and TView, TWindowView is a streamable base class that can be used for deri...
Definition docview.h:494
auto CanClose() -> bool override
Overrides TWindow::CanClose and returns a nonzero value if the window can be closed.
Definition docview.h:1128
static LPCTSTR StaticName()
put in resource
Definition docview.h:1111
auto GetViewName() -> LPCTSTR override
Overrides TView::GetViewName and returns StaticName, the name of the view.
Definition docview.h:1138
~TWindowView() override
Destroys a TWindowView object and calls the associated document's DetachView function (a private TDoc...
Definition docview.h:1104
auto SetDocTitle(LPCTSTR docname, int index) -> bool override
Overrides TView::SetDocTitle and stores the document title.
Definition docview.h:1154
auto GetWindow() -> TWindow *override
Overrides TView::GetWindow and returns the TWindowView object as a TWindow.
Definition docview.h:1145
#define _T(x)
Definition cygwin.h:51
Definition of TDialog class and TDialogAttr struct.
#define WM_OWLVIEW
Definition dispatch.h:4106
#define WM_OWLNOTIFY
Definition dispatch.h:4107
#define WM_OWLDOCUMENT
Definition dispatch.h:4105
#define OWL_STREAM_NULL_INITIALIZER
Definition docview.h:1260
#define DECLARE_RESPONSE_TABLE(cls)
Definition eventhan.h:436
Definition of class TFrameWindow.
#define DECLARE_STREAMABLE_OWL(cls, ver)
Definition objstrm.h:1529
#define DECLARE_ABSTRACT_STREAMABLE_OWL(cls, ver)
Definition objstrm.h:1535
TAutoDelete
Flag for Handle ctors to control Handle deletion in dtor.
Definition gdibase.h:70
#define DECLARE_STREAMABLE_INLINES(cls)
Definition objstrm.h:1538
@ AutoDelete
Definition gdibase.h:70
const uint pfGetText
property accessible as text format
Definition docview.h:122
const uint vnViewOpened
a new view has just been constructed
Definition docview.h:105
const uint pfHidden
property should be hidden from normal browse
Definition docview.h:127
const uint vnViewClosed
another view is about to be destructed
Definition docview.h:106
const uint vnDocClosed
document has just been closed
Definition docview.h:108
const uint vnDocOpened
document has just been opened
Definition docview.h:107
const uint pfConstant
property is invariant for object instance
Definition docview.h:124
const uint vnCommit
document is committing, flush cached changes
Definition docview.h:109
const uint pfSettable
property settable as native format
Definition docview.h:125
TDocMode
Document open and sharing modes - used in storage and stream constructors.
Definition docview.h:60
const uint pfUserDef
property has been user-defined at run time
Definition docview.h:128
const uint vnCustomBase
base of document class specific notifications
Definition docview.h:113
const uint pfUnknown
property defined but unavailable in object
Definition docview.h:126
const uint vnRevert
document has reverted, reload data from doc
Definition docview.h:110
const uint vnIsWindow
respond true if passed HWND is that of view
Definition docview.h:112
const uint vnIsDirty
respond true if uncommitted changes present
Definition docview.h:111
const uint pfGetBinary
property accessible as native non-text format
Definition docview.h:123
@ ofRead_workaround
Definition docview.h:45
@ ofWrite_workaround
Definition docview.h:45
@ ofRead
ios::in, open for reading
Definition docview.h:63
@ ofTruncate
ios::trunc, truncate file if already exists
Definition docview.h:68
@ shMask
Definition docview.h:95
@ ofReadWrite
Definition docview.h:65
@ shRead
DENY_WRITE functionality.
Definition docview.h:91
@ shDefault
use stream implementation default value
Definition docview.h:94
@ ofParent
use open mode of parent storage
Definition docview.h:62
@ ofNoReplace
ios::noreplace, open fails if file already exists
Definition docview.h:79
@ ofPriority
STGM_PRIORITY, temporary efficient peeking.
Definition docview.h:86
@ ofPreserve
STGM_CONVERT, backup old data of same name.
Definition docview.h:85
@ ofAppend
ios::app, append mode: all additions at eof
Definition docview.h:67
@ ofWrite
ios::out, open for writing
Definition docview.h:64
@ ofAtEnd
ios::ate, seek to eof upon original open
Definition docview.h:66
@ shWrite
DENY_READ functionality.
Definition docview.h:92
@ ofBinary
Definition docview.h:81
@ ofTransacted
STGM_TRANSACTED, supports commit and revert.
Definition docview.h:84
@ shReadWrite
DENY_NONE functionality.
Definition docview.h:93
@ shNone
EXCLUSIVE functionality.
Definition docview.h:90
@ ofNoCreate
ios::nocreate, open fails if file doesn't exist
Definition docview.h:74
@ shCompat
for non-compliant applications, avoid if possible
Definition docview.h:89
@ ofIosMask
Definition docview.h:82
@ ofTemporary
STGM_DELETEONRELEASE, delete when destructed.
Definition docview.h:87
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
UINT TMsgId
Message ID type.
Definition dispatch.h:53
char tchar
Definition defs.h:77
LPARAM TParam2
Second parameter type.
Definition dispatch.h:55
std::istream tistream
Definition strmdefs.h:39
std::string tstring
Definition defs.h:79
unsigned int uint
Definition number.h:25
TModule & GetGlobalModule()
Definition global.cpp:48
std::ostream tostream
Definition strmdefs.h:40
#define protected_data
Definition defs.h:208
#define public_data
Definition defs.h:207
#define OWL_DISABLE_WARNING_POP
Definition defs.h:156
#define _OWLCLASS
Definition defs.h:338
#define OWL_DISABLE_WARNING_PUSH
Definition defs.h:155
#define OWL_DISABLE_WARNING_OLD_STYLE_CAST
Definition defs.h:161
static void Encode(F sendMessage, HWND wnd, TDocument &d)
Definition docview.h:652
static TResult Decode(void *i, TParam1, TParam2 p2)
Definition docview.h:662
static TResult Decode(void *i, TParam1, TParam2 p2)
Definition docview.h:728
static bool Encode(F sendMessage, HWND wnd, P p)
Definition docview.h:718
static TResult Decode(void *i, TParam1, TParam2 p2)
Definition docview.h:704
static bool Encode(F sendMessage, HWND wnd, TParam2 p2)
Definition docview.h:694
static TResult Decode(void *i, TParam1, TParam2 p2)
Definition docview.h:682
static void Encode(F sendMessage, HWND wnd, TView &v)
Definition docview.h:672
Undefined default template for dispatchers Template specialization is used to allow the compiler to l...
Definition dispatch.h:258