OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
oleview.h
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectComponents
3// Copyright (c) 1994, 1996 by Borland International, All Rights Reserved
4//
5//----------------------------------------------------------------------------
6
7#if !defined(OCF_OLEVIEW_H)
8#define OCF_OLEVIEW_H
9
10#include <owl/private/defs.h>
11#if defined(BI_HAS_PRAGMA_ONCE)
12# pragma once
13#endif
14
15#include <ocf/olewindo.h>
16#include <owl/docview.h>
17#include <owl/docmanag.h>
18
19namespace ocf {
20
21//
22// Additional notification messages
23//
24const owl::uint vnInvalidate = 9; // a rect in view needs repaint
25const owl::uint vnLinkView = 10; // find view with matched TOcLinkView
26const owl::uint vnLinkMoniker = 11; // find view with matched moniker
27
28#if defined(OWL5_COMPAT)
29
30NOTIFY_SIG(vnInvalidate, owl::TRect&)
31NOTIFY_SIG(vnLinkView, TOcLinkView&)
32NOTIFY_SIG(vnLinkMoniker, owl::TString&)
33
34#endif
35
36template <owl::TMsgId>
38
39template <> struct TDocViewDispatch<WM_OWLNOTIFY>
40{
41 static const owl::TMsgId MessageId = WM_OWLNOTIFY;
42
46
47 template <owl::uint NotificationCode>
48 struct TNotificationDispatch;
49
50};
51
52template <> struct TDocViewDispatch<WM_OWLNOTIFY>::TNotificationDispatch<vnInvalidate>
53{
54 template <class T, bool (T::*M)(owl::TRect&)>
55 static TResult Decode(void* i, TParam1, TParam2 p2)
56 {
57 PRECONDITION(p2);
58 return (p2 != 0 && (static_cast<T*>(i)->*M)(*reinterpret_cast<owl::TRect*>(p2))) ? TRUE : FALSE;
59 }
60};
61
62template <> struct TDocViewDispatch<WM_OWLNOTIFY>::TNotificationDispatch<vnLinkView>
63{
64 template <class T, bool (T::*M)(TOcLinkView&)>
65 static TResult Decode(void* i, TParam1, TParam2 p2)
66 {
67 PRECONDITION(p2);
68 return (p2 != 0 && (static_cast<T*>(i)->*M)(*reinterpret_cast<TOcLinkView*>(p2))) ? TRUE : FALSE;
69 }
70};
71
72template <> struct TDocViewDispatch<WM_OWLNOTIFY>::TNotificationDispatch<vnLinkMoniker>
73{
74 template <class T, bool (T::*M)(owl::TString&)>
75 static TResult Decode(void* i, TParam1, TParam2 p2)
76 {
77 PRECONDITION(p2);
78 return (p2 != 0 && (static_cast<T*>(i)->*M)(*reinterpret_cast<owl::TString*>(p2))) ? TRUE : FALSE;
79 }
80};
81
82#define OCF_EV_VN_(notificationCode, method)\
83 VN_DEFINE(notificationCode, method, ::ocf::TDocViewDispatch<WM_OWLNOTIFY>::TNotificationDispatch<notificationCode>::Decode)
84
85#define EV_VN_INVALIDATE OCF_EV_VN_(vnInvalidate, VnInvalidate)
86#define EV_VN_LINKVIEW OCF_EV_VN_(vnLinkView, VnLinkView)
87#define EV_VN_LINKMONIKER OCF_EV_VN_(vnLinkMoniker, VnLinkMoniker)
88
89// Generic definitions/compiler options (eg. alignment) preceeding the
90// definition of classes
91#include <owl/preclass.h>
92
93//
94/// \class TOleView
95// ~~~~~ ~~~~~~~~
96/// The OLE2 window view class. Used as a view in doc/view model
97//
98/// Derived from TWindowView and TView, TOleView supports the View half of the
99/// Doc/View pair and creates a window with a view that can display an associated
100/// document. Documents use views to display themselves to a user. Regardless of
101/// whether a view belongs to a server or a container, TOleView sets up a
102/// corresponding TOcDocument object (an entire compound document).
103///
104/// In the case of an OLE-enabled container application, view refers to the window
105/// where the container application draws the compound document, which may consist
106/// of one or more linked and embedded objects. To display these objects in
107/// different formats, a container can be associated with more than one view.
108/// Similarly, to display the data properly, each embedded object can also have its
109/// own view. Each container view creates a corresponding ObjectComponents TOcView
110/// object.
111/// If the view belongs to an OLE-enabled server application, TOleView creates a
112/// remote view on the server's document (a TOcRemView object). TOleView takes care
113/// of transmitting messages from the server to the container, specifically in the
114/// case of merging menus and redrawing embedded objects, and supports merging the
115/// server's and the container's pop-up menu items to form a composite menu. Because
116/// it knows the dimensions of the server's view, TOleView is responsible for
117/// telling the container how to redraw the embedded object.
118///
119/// Similarly to TView, TOleView supports the creation of views and provides several
120/// event handling functions that allow the view to query, commit, and close views.
121/// TOleView also manages the writing to storage of documents that belong to a
122/// container or a server.
123class _OCFCLASS TOleView : public TOleWindow, public owl::TView {
124 public:
125 TOleView(owl::TDocument& doc, owl::TWindow* parent = 0);
126 ~TOleView();
127
128 static LPCTSTR StaticName();
129
130 // Inherited virtuals from TView
131 //
132 auto GetViewName() -> LPCTSTR override;
133 auto GetWindow() -> owl::TWindow* override;
134 auto SetDocTitle(LPCTSTR docname, int index) -> bool override;
135 auto OleShutDown() -> bool override;
136
137 // Inherited virtuals from TWindow
138 //
139 auto CanClose() -> bool override;
140
141 protected:
142 auto CreateOcView(owl::TRegLink*, bool isEmbedded, IUnknown* outer) -> TOcView* override;
143 void CleanupWindow() override;
144 bool OtherViewExists();
145
146 /// \name View notifications
147 /// @{
148 bool VnInvalidate(owl::TRect& rect);
149 bool VnDocOpened(int omode);
150 bool VnDocClosed(int omode);
151 /// @}
152
153 auto GetViewMenu() -> owl::TMenuDescr* override;
154 auto GetFileName() -> LPCTSTR override;
155 auto EvOcViewPartInvalid(TOcPartChangeInfo& changeInfo) -> bool override;
156// owl::uint32 EvOcViewDiscardUndo(void * undo);
157
158 // Container specific messages
159 //
160// bool EvOcAppInsMenus(TOcMenuDescr &);
161
162 /// \name Server specific messages
163 /// @{
164 bool EvOcViewClose();
165 bool EvOcViewSavePart(TOcSaveLoad & ocSave);
166 bool EvOcViewLoadPart(TOcSaveLoad & ocLoad);
167 bool EvOcViewOpenDoc(LPCTSTR path);
168 bool EvOcViewInsMenus(TOcMenuDescr & sharedMenu);
169 bool EvOcViewAttachWindow(bool attach);
170 bool EvOcViewSetLink(TOcLinkView& view);
171 bool EvOcViewBreakLink(TOcLinkView& view);
172 bool EvOcViewGetItemName(TOcItemName& item);
173 /// @}
174
175 private:
176 bool Destroying;
177
178 // event handlers
179 //
180 bool VnIsWindow(HWND hWnd);
181
184};
185
187
188//
189/// \class TOleLinkView
190// ~~~~~ ~~~~~~~~~~~~
191/// Derived from TView, TOleLinkView provides embedding and linking support for a
192/// portion of a document instead of an entire document. With the added
193/// functionality of TOleLinkView, a container gains the ability to embed or link to
194/// a selection within the server document.
195///
196/// The main purpose of a class derived from TOleLinkView is to attach a view to a
197/// portion of a document whenever a link is created to a selection within a server
198/// document. After this link is established, any changes made to the linked
199/// selection in the server document are sent to the container via the following
200/// sequence of steps:
201/// - 1. When a user changes the server document, TOleLinkView receives a
202/// notification message
203/// - 2. TOleLinkView checks to see if the selection it represents has changed. If
204/// the selection has changed, TOleLinkView notifies TOcLinkView about the change.
205/// - 3. When TOcLinkView receives the change message, it notifies the container that
206/// the selection has changed.
207///
208/// Non-Doc/View servers need to maintain a list of the TOleLinkViews attached to
209/// the document so that change notifications can be sent to each one of the views.
211 public:
214
215 virtual bool VnLinkView(TOcLinkView& view);
216 virtual bool VnLinkMoniker(owl::TString& moniker);
217 virtual bool UpdateLinks();
218 owl::TString& GetMoniker();
219
220 static LPCTSTR StaticName();
221 auto GetViewName() -> LPCTSTR override;
222
223 protected:
224 TOcLinkView& OcLinkView; // TOcLinkView partner for this view
225
227};
228
229// Generic definitions/compiler options (eg. alignment) following the
230// definition of classes
231#include <owl/posclass.h>
232
233// --------------------------------------------------------------------------
234// Inline implementation
235//
236
237//
238/// Returns the constant string "Ole View" that is displayed in the user interface
239/// selection box.
240inline LPCTSTR TOleView::StaticName() {
241 return _T("Ole View");
242}
243
244//
245/// Overrides TView's virtual GetViewName function and returns the name of the class
246/// (TOleView).
247inline LPCTSTR TOleView::GetViewName() {
248 return StaticName();
249}
250
251//
252/// Overrides TView's virtual GetWindow function and returns the TWindow instance
253/// associated with this view.
255 return (owl::TWindow*)this;
256}
257
258//
259/// Overrides TView's and TWindow's virtual SetDocTitle function and stores the
260/// title of the document associated with this view.
261inline bool TOleView::SetDocTitle(LPCTSTR docname, int index) {
262# if defined(BI_COMP_BORLANDC)
263 return owl::TWindow::SetDocTitle(docname, index);
264#else
265 return TWindow::SetDocTitle(docname, index);
266#endif
267}
268
269//
270inline LPCTSTR TOleView::GetFileName() {
271 return GetDocument().GetTitle();
272}
273
274//
275/// Returns the constant string "Link View" that is displayed in the user interface
276/// selection box.
277inline LPCTSTR TOleLinkView::StaticName() {
278 return _T("Link View");
279}
280
281//
282/// Overrides TView's virtual GetViewName function and returns the static name,
283/// "Link View".
285 return StaticName();
286}
287
288} // OCF namespace
289
290#endif // OWL_OLEVIEW_H
#define PRECONDITION(condition)
Definition checks.h:227
Used to obtain the item name for building monikers.
Definition ocview.h:403
View/Data change info.
Definition ocpart.h:216
Use when doing parts save and load.
Definition ocview.h:326
The TOcView partner is a container (viewer) of a given (server/client) document.
Definition ocview.h:136
The OLE2 window view class. Used as a view in doc/view model.
Definition oleview.h:123
auto GetFileName() -> LPCTSTR override
Definition oleview.h:270
auto SetDocTitle(LPCTSTR docname, int index) -> bool override
Overrides TView's and TWindow's virtual SetDocTitle function and stores the title of the document ass...
Definition oleview.h:261
static LPCTSTR StaticName()
Returns the constant string "Ole View" that is displayed in the user interface selection box.
Definition oleview.h:240
auto GetViewName() -> LPCTSTR override
Overrides TView's virtual GetViewName function and returns the name of the class (TOleView).
Definition oleview.h:247
auto GetWindow() -> owl::TWindow *override
Overrides TView's virtual GetWindow function and returns the TWindow instance associated with this vi...
Definition oleview.h:254
The generic OLE2 window. Use as a client of a frame window.
Definition olewindo.h:91
An abstract base class, TDocument is the base class for all document objects and serves as an interfa...
Definition docview.h:187
LPCTSTR GetTitle() const
Returns the title of the document.
Definition docview.h:881
Menu with information used to allow merging.
Definition menu.h:206
TRect is a mathematical class derived from tagRect.
Definition geometry.h:308
Reference to reference counted string object TUString Lightweight reference object consisting of a po...
Definition string.h:67
Abstract base class for view access from document.
Definition docview.h:397
TDocument & GetDocument()
Returns a reference to the view's document.
Definition docview.h:1004
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
#define _T(x)
Definition cygwin.h:51
#define WM_OWLNOTIFY
Definition dispatch.h:4107
Definition of class TDocManager.
Definition of classes TDocument, TView, TWindowView, TStream, TInStream, TOutStream.
#define DECLARE_RESPONSE_TABLE(cls)
Definition eventhan.h:436
#define DECLARE_STREAMABLE_INLINES(cls)
Definition objstrm.h:1538
Object Component Framework (COM encapsulation)
Definition appdesc.h:22
const owl::uint vnInvalidate
Definition oleview.h:24
const owl::uint vnLinkMoniker
Definition oleview.h:26
const owl::uint vnLinkView
Definition oleview.h:25
UINT TMsgId
Message ID type.
Definition dispatch.h:53
LPARAM TParam2
Second parameter type.
Definition dispatch.h:55
WPARAM TParam1
First parameter type.
Definition dispatch.h:54
LRESULT TResult
Result type.
Definition dispatch.h:52
unsigned int uint
Definition number.h:25
#define DECLARE_STREAMABLE_OCF(cls, ver)
Definition defs.h:61
#define _OCFCLASS
Definition defs.h:45
TOleWindow - Class encapsulating a window which can be an OLE container or server window.