OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
mdi.h
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectWindows
3// Copyright (c) 1991, 1996 by Borland International, All Rights Reserved
4//
5/// \file
6/// Definition of TMDIClient and TMDIFrame classes
7//----------------------------------------------------------------------------
8
9#if !defined(OWL_MDI_H)
10#define OWL_MDI_H
11
12#include <owl/private/defs.h>
13#if defined(BI_HAS_PRAGMA_ONCE)
14# pragma once
15#endif
16
17#include <owl/framewin.h>
18#include <owl/mdichild.h>
19#include <owl/mdi.rh>
20#include <memory>
21
22namespace owl {
23
24#include <owl/preclass.h>
25
26/// \addtogroup frame
27/// @{
28
30
31//
32/// \class TMDIClient
33// ~~~~~ ~~~~~~~~~~
34/// Multiple Document Interface (MDI) client windows (represented by a TMDIClient
35/// object) manage the MDI child windows of a TMDIFrame parent. TMDIClient is a
36/// streamable class.
37class _OWLCLASS TMDIClient : public virtual TWindow {
38 public:
39 TMDIClient(TModule* module = 0);
41
42 virtual bool CloseChildren();
44
45 // Member functions to arrange the MDI children
46 //
47 virtual void ArrangeIcons();
48 virtual void CascadeChildren();
49 virtual void TileChildren(int tile = MDITILE_VERTICAL);
50
51 // Override member functions defined by TWindow
52 //
53 auto PreProcessMsg(MSG&) -> bool override;
54 auto Create() -> bool override;
55
56 /// \name Child factory functions
57 /// @{
58 virtual TMDIChild* CreateChild();
59 virtual TMDIChild* InitChild();
60 /// @}
61
62 LPCLIENTCREATESTRUCT GetClientAttr();
63 void SetClientAttr(LPCLIENTCREATESTRUCT clientattr);
64
65 protected:
66 auto GetWindowClassName() -> TWindowClassName override;
67
68 // Menu command handlers & enabler
69 //
70 void CmCreateChild(); ///< CM_CREATECHILD
71 void CmTileChildren(); ///< CM_TILECHILDREN
72 void CmTileChildrenHoriz(); ///< CM_TILECHILDREN
73 void CmCascadeChildren(); ///< CM_CASCADECHILDREN
74 void CmArrangeIcons(); ///< CM_ARRANGEICONS
75 void CmCloseChildren(); ///< CM_CLOSECHILDREN
76 void CmChildActionEnable(TCommandEnabler& commandEnabler);
77
78 HWND EvMDICreate(MDICREATESTRUCT& createStruct);
79 void EvMDIDestroy(HWND hWnd);
80
82
84/// ClientAttr holds a pointer to a structure of the MDI client window's attributes.
85 LPCLIENTCREATESTRUCT ClientAttr;
86
87 private:
88 TMDIClient(HWND hWnd, TModule* module = 0);
89
90 // Hidden to prevent accidental copying or assignment
91 //
92 TMDIClient(const TMDIClient&);
93 TMDIClient& operator =(const TMDIClient&);
94
95 DECLARE_RESPONSE_TABLE(TMDIClient);
97
98 friend class TMDIFrame; // To allow access to private ctor
99};
100
102
104
105//
106/// \class TMDIFrame
107// ~~~~~ ~~~~~~~~~
108/// Multiple Document Interface (MDI) frame windows, represented by TMDIFrame, are
109/// overlapped windows that serve as main windows of MDI-compliant applications.
110/// TMDIFrame objects automatically handle creating and initializing an MDI client
111/// window (represented by a TMDIClient object) required by Windows. TMDIFrame sets
112/// window style WS_CLIPCHILDREN by default so that minimal flicker occurs when the
113/// MDI frame erases its background and the backgrounds of its children. TMDIFrame
114/// is a streamable class.
115/// Because TMDIFrame is derived from TFrameWindow, it inherits keyboard navigation.
116/// As a result, all children of the MDI frame acquire keyboard navigation. However,
117/// it's best to enable keyboard navigation only for those children who require it.
118///
119/// To create an OLE-enabled MDI frame window, use TOleMDIFrame, which inherits
120/// functionality from both TMDIFrame and TOleFrame.
121//
122class _OWLCLASS TMDIFrame : virtual public TFrameWindow {
123 public:
124
125 TMDIFrame(
126 LPCTSTR title,
127 TResId menuResId,
128 std::unique_ptr<TMDIClient> clientWnd = nullptr,
129 TModule* = nullptr);
130
131 TMDIFrame(
132 const tstring& title,
133 TResId menuResId,
134 std::unique_ptr<TMDIClient> clientWnd = nullptr,
135 TModule* = nullptr);
136
137#if defined(OWL5_COMPAT)
138
139 TMDIFrame(LPCTSTR title,
140 TResId menuResId,
141 TMDIClient& clientWnd,
142 TModule* module = 0);
143
144 TMDIFrame(
145 const tstring& title,
146 TResId menuResId,
147 TMDIClient& clientWnd,
148 TModule* = 0);
149
150#endif
151
152 TMDIFrame(HWND frameHandle, HWND clientHandle, TModule* module = 0);
153
154 // Override virtual functions defined by TFrameWindow or TWindow
155 //
156 auto SetMenu(HMENU) -> bool override;
157 auto GetClientWindow() -> TMDIClient* override;
158 auto GetCommandTarget() -> HWND override;
159
160 /// Find & return the child menu of an MDI frame's (or anyone's) menu bar.
161 //
162 static HMENU FindChildMenu(HMENU);
163
164 protected:
166 auto PerformCreate() -> THandle override;
167
168 private:
169 /// Hidden to prevent accidental copying or assignment
170 //
171 TMDIFrame(const TMDIFrame&);
172 TMDIFrame& operator=(const TMDIFrame&);
173
174 DECLARE_RESPONSE_TABLE(TMDIFrame);
176};
177
179
181
182/// @}
183
184#include <owl/posclass.h>
185
186
187//----------------------------------------------------------------------------
188// Inline implementations
189//
190
191//
192/// Returns the client create struct for the MDI client.
193//
194inline LPCLIENTCREATESTRUCT TMDIClient::GetClientAttr() {
195 return ClientAttr;
196}
197
198//
199/// Sets the client create struct for the MDI client.
200/// \todo Assumes ownership of the pointer, so it will be deleted ? And the old one is orphaned and leaks?
201//
202inline void TMDIClient::SetClientAttr(LPCLIENTCREATESTRUCT clientattr) {
203 ClientAttr = clientattr;
204}
205
206//
207/// Calls CreateChild to produce a new child window in response to a menu selection
208/// with a menu ID of CM_CREATECHILD.
210 CreateChild();
211}
212
213//
214/// Calls TileChildren in response to a menu selection with an ID of
215/// CM_TILECHILDREN.
217 TileChildren();
218}
219
220//
221/// Calls TileChildren in response to a menu selection with an ID of CM_TILECHILDREN
222/// and passes MDI child tile flag as MDITILE_HORIZONTAL.
224 TileChildren(MDITILE_HORIZONTAL);
225}
226
227//
228/// Calls CascadeChildren in response to a menu selection with an ID of
229/// CM_CASCADECHILDREN.
233
234//
235/// Calls ArrangeIcons in response to a menu selection with an ID of
236/// CM_ARRANGEICONS.
238 ArrangeIcons();
239}
240
241//
242/// Calls CloseChildren in response to a menu selection with an ID of
243/// CM_CLOSECHILDREN.
246}
247
248
249} // OWL namespace
250
251
252#endif // OWL_MDI_H
Base class for an extensible interface for auto enabling/disabling of commands (menu items,...
Definition window.h:209
TDropInfo is a simple class that supports file-name drag-and-drop operations using the WM_DROPFILES m...
Definition wsyscls.h:257
TFrameWindow(TWindow *parent, LPCTSTR title=nullptr, TWindow *clientWnd=nullptr, bool shrinkToClient=false, TModule *module=nullptr)
Constructs a window object with the parent window supplied in parent, which is zero if this is the ma...
Definition framewin.cpp:91
TMDIChild defines the basic behavior of all MDI child windows.
Definition mdichild.h:42
Multiple Document Interface (MDI) client windows (represented by a TMDIClient object) manage the MDI ...
Definition mdi.h:37
friend class TMDIFrame
Definition mdi.h:98
LPCLIENTCREATESTRUCT GetClientAttr()
Returns the client create struct for the MDI client.
Definition mdi.h:194
virtual bool CloseChildren()
Closes the TMDIChild windows owned by this MDI client.
Definition mdiclien.cpp:217
void CmTileChildren()
CM_TILECHILDREN.
Definition mdi.h:216
auto GetWindowClassName() -> TWindowClassName override
Returns TMDIClient's registration class name, "MDICLIENT.".
Definition mdiclien.cpp:97
void SetClientAttr(LPCLIENTCREATESTRUCT clientattr)
Sets the client create struct for the MDI client.
Definition mdi.h:202
TMDIClient(TModule *module=0)
Constructor for a TMDIClient.
Definition mdiclien.cpp:49
void CmChildActionEnable(TCommandEnabler &commandEnabler)
If there are MDI child windows, CmChildActionEnalbe enables any one of the child window action menu i...
Definition mdiclien.cpp:344
void CmTileChildrenHoriz()
CM_TILECHILDREN.
Definition mdi.h:223
void CmArrangeIcons()
CM_ARRANGEICONS.
Definition mdi.h:237
void EvDropFiles(TDropInfo)
Forwards dropped file messages by default to the parent (MDI Frame) where they can be handled,...
Definition mdiclien.cpp:334
void CmCreateChild()
CM_CREATECHILD.
Definition mdi.h:209
TMDIChild * GetActiveMDIChild()
Use the Windows message to get the active mdi child, and then down cast to our MDI child derived clas...
Definition mdiclien.cpp:107
virtual TMDIChild * InitChild()
Constructs an instance of a TMDIChild with this TMDIClient as parent.
Definition mdiclien.cpp:200
void CmCloseChildren()
CM_CLOSECHILDREN.
Definition mdi.h:244
virtual void TileChildren(int tile=MDITILE_VERTICAL)
Sizes and arranges all of the non-iconized MDI child windows within the MDI client window.
Definition mdiclien.cpp:138
virtual void ArrangeIcons()
Arranges the MDI child window icons at the bottom of the MDI client window.
Definition mdiclien.cpp:118
auto Create() -> bool override
Creates the interface element associated with the MDI client window.
Definition mdiclien.cpp:165
virtual TMDIChild * CreateChild()
Initializes and creates a new TMDIChild by calling InitChild and Create.
Definition mdiclien.cpp:179
void CmCascadeChildren()
CM_CASCADECHILDREN.
Definition mdi.h:230
HWND EvMDICreate(MDICREATESTRUCT &createStruct)
Intercepts the WM_MDICREATE message sent when MDI child windows are created, and, if the client's sty...
Definition mdiclien.cpp:250
virtual void CascadeChildren()
Sizes and arranges all of the non-iconized MDI child windows within the MDI client window.
Definition mdiclien.cpp:128
auto PreProcessMsg(MSG &) -> bool override
Preprocess messages in order to translate MDI accelerator keys.
Definition mdiclien.cpp:150
void EvMDIDestroy(HWND hWnd)
Destroys an MDI child window.
Definition mdiclien.cpp:284
Multiple Document Interface (MDI) frame windows, represented by TMDIFrame, are overlapped windows tha...
Definition mdi.h:122
auto SetMenu(HMENU) -> bool override
Searches for the MDI child menu in the new menu bar and updates the child menu position with the spec...
Definition mdiframe.cpp:192
auto GetClientWindow() -> TMDIClient *override
Returns a pointer to the MDI client window.
Definition mdiframe.cpp:215
auto PerformCreate() -> THandle override
Overrides TWindow's virtual PerformCreate function.
Definition mdiframe.cpp:122
virtual TResult DefWindowProc(TMsgId, TParam1, TParam2)
Overrides TWindow::DefWindowProc and provides default processing for any incoming message the MDI fra...
Definition mdiframe.cpp:243
static HMENU FindChildMenu(HMENU)
Find & return the child menu of an MDI frame's (or anyone's) menu bar.
Definition mdiframe.cpp:166
auto GetCommandTarget() -> HWND override
Locates and returns the child window that is the target of the command and the command enabling messa...
Definition mdiframe.cpp:227
TMDIFrame(LPCTSTR title, TResId menuResId, std::unique_ptr< TMDIClient > clientWnd=nullptr, TModule *=nullptr)
Constructs an MDI frame window object using the caption (title) and resource ID (menuResId).
Definition mdiframe.cpp:36
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
Definition module.h:78
Type-safe encapsulation of a Windows class name, a union between ATOM and LPCTSTR.
Definition module.h:50
TWindow(TWindow *parent, LPCTSTR title=nullptr, TModule *module=nullptr)
Adds this to the child list of parent if nonzero, and calls EnableAutoCreate so that this will be cre...
Definition window.cpp:341
HWND THandle
TWindow encapsulates an HWND.
Definition window.h:418
Definition of class TFrameWindow.
#define DECLARE_STREAMABLE_OWL(cls, ver)
Definition objstrm.h:1529
#define DECLARE_STREAMABLE_INLINES(cls)
Definition objstrm.h:1538
TMDIFrame TMdiFrame
Definition mdi.h:180
TMDIClient TMdiClient
Definition mdi.h:103
Definition of class TMDIChild.
Object Windows Library (OWLNext Core).
Definition animctrl.h:22
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
std::string tstring
Definition defs.h:79
#define public_data
Definition defs.h:207
#define _OWLCLASS
Definition defs.h:338