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
docking.h
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectWindows
3// Copyright (c) 1995, 1996 by Borland International, All Rights Reserved
4//
5/// \file
6/// TDockable classes: TDockableGadgetWindow & TDockableControlBar
7/// TDockingSlip classes: TFloatingSlip & TEdgeSlip
8/// and the THarbor docking manager
9//----------------------------------------------------------------------------
10#if !defined(OWL_DOCKING_H)
11#define OWL_DOCKING_H
12
13#include <owl/private/defs.h>
14#if defined(BI_HAS_PRAGMA_ONCE)
15# pragma once
16#endif
17
18#include <owl/decframe.h>
19#include <owl/floatfra.h>
20#include <owl/gadgetwi.h>
21#include <owl/controlb.h>
22
23
24namespace owl {
25
26class _OWLCLASS THarbor;
27class _OWLCLASS TDockingSlip;
28
29
30#include <owl/preclass.h>
31
32/// \addtogroup Docking
33/// @{
34
35/// General use 2-D rectangular relative position enum
36//
37/// Used here to described the location of a docking window [more specifically
38/// the location of the EdgeSlip containing docking windows].
39//
40/// \note This enumeration corresponds to the TLocation enumeration of
41/// TDecoratedFrame.
42//
44 rpNone, ///< No location specified
45 rpAbove, ///< Refers to top edge of frame
46 rpBelow, ///< Refers to bottom edge of frame
47 rpRightOf, ///< Refers to left edge of frame
48 rpLeftOf ///< Refers to right edge of frame
49};
50
51//
52/// \class TDockable
53// ~~~~~ ~~~~~~~~~
54/// TDockable is an abstract base class for fixed or floating docking windows that
55/// want to be dockable into docking slips.
56//
58 public:
59
60/// Returns the rectangle of the dockable window in the given location. The dockable
61/// chooses its layout (horizontal, vertical or rectangle) in that position.
63
64/// Return the rectangle of the dockable window in the given location. The dockable
65/// chooses its layout (horizontal, vertical or rectangle) in that position.
66 virtual void GetRect(TRect& rect) = 0;
67
68/// Changes the window to be equal to the size returned from ComputeNNNNN.
69 virtual void Layout(TAbsLocation loc, TSize* dim=0) = 0;
70
71/// This is overriden for any window that wants to be docked. This routine is called
72/// from an LButtonDown to determine if the mouse down should move the window or
73/// perform an action within the docked window. For example, if a gadget window is
74/// docked, this routine would decide if the mousedown is on an enabled gadget; if
75/// so, the control is not to be moved. Instead, the action of the gadget being
76/// depressed is performed. Otherwise, the gadget window is moved within the docking
77/// window.
78 virtual bool ShouldBeginDrag(TPoint& pt) = 0;
79
80/// Gets dockable's window and hides it, in case we have to toss it around a bit.
81 virtual TWindow* GetWindow() = 0;
82
83/// Returns the harbor containing the dockable object.
84 virtual THarbor* GetHarbor() = 0;
85};
86
87//
88/// \class TDockableGadgetWindow
89// ~~~~~ ~~~~~~~~~~~~~~~~~~~~~
90/// A version of TGadgetWindow which is dockable
91//
93 public:
95 TTileDirection direction = Horizontal,
96 TFont* font = 0,
97 TModule* module = 0);
98 ~TDockableGadgetWindow() override;
99
100 // Override TDockable virtuals
101 //
102 auto ComputeSize(TAbsLocation, TSize*) -> TSize override;
103 void GetRect(TRect&) override;
104 void Layout(TAbsLocation, TSize* = nullptr) override;
105 auto ShouldBeginDrag(TPoint&) -> bool override;
106 auto GetWindow() -> TWindow* override;
107 auto GetHarbor() -> THarbor* override;
108 virtual TGadget* GetGripGadget();
109
110 // Override TGadgetWindow virtuals
111 //
112 void LayoutSession() override;
113
114 protected:
115 void EvLButtonDown(uint modKeys, const TPoint& point);
116 void EvOwlWindowDocked(uint pos, const TDockingSlip& slip);
117 bool EvSetCursor(HWND hWndCursor, uint codeHitTest, TMsgId mouseMsg);
118
119 /// Returns the layout direction to use when placed in a slip
120 /// This can be overridden to provide different docking behaviour
121 //
122 virtual TTileDirection GetDirectionForLocation(TAbsLocation loc);
123
126};
127
128//
129/// \class TDockableControlBar
130// ~~~~~ ~~~~~~~~~~~~~~~~~~~
131/// A control bar class that is dockable
132//
134 public:
135 TDockableControlBar(TWindow* parent = 0,
136 TTileDirection direction = Horizontal,
137 TFont* font = 0,
138 TModule* module = 0);
139
140 protected:
141 void AdjustMargins();
142 void EvOwlWindowDocked(uint pos, const TDockingSlip& slip);
143
146};
147
148//
149/// \class TDockingSlip
150// ~~~~~ ~~~~~~~~~~~~
151/// TDockingSlip is an abstract base class for windows which accepts and holds
152/// dockable windows.
153//
155 public:
156 // These are overriden for any window that wants to be notified on dockable
157 // windows being moved or removed.
158 //
159/// Inserts the dockable into the slip, based on arguments given.
162
165
166 virtual void DockableRemoved(const TRect& orgRect) = 0;
167
168 virtual TAbsLocation GetLocation() const = 0;
169
170 // Called by Harbor to initialize back pointer
171 //
172 void SetHarbor(THarbor* harbor);
173 THarbor* GetHarbor() const;
174
175 protected:
177};
178
179//
180/// \class TFloatingSlip
181// ~~~~~ ~~~~~~~~~~~~~
182/// TFloatingSlip is a floating frame which can hold a dockable window. It is also
183/// dockable in order to act as a proxy for its held dockable when dragging.
184//
186 public TDockingSlip, public TDockable
187{
188 public:
189 TFloatingSlip(TWindow* parent,
190 int x, int y,
191 TWindow* clientWnd = 0,
192 bool shrinkToClient = true,
193 int captionHeight = DefaultCaptionHeight,
194 bool popupPalette = true, // false?
195 TModule* module = 0);
196
197 // Override TDockingSlip virtuals
198 //
199 void DockableInsert(TDockable&, const TPoint* topLeft, TRelPosition, TDockable* relDockable) override;
200 void DockableMove(TDockable&, const TPoint* topLeft, TRelPosition, TDockable* relDockable) override;
201 void DockableRemoved(const TRect&) override;
202
203 auto GetLocation() const -> TAbsLocation override;
204
205 // Override TDockable virtuals
206 //
207 auto ComputeSize(TAbsLocation, TSize*) -> TSize override;
208 void GetRect(TRect&) override;
209 void Layout(TAbsLocation, TSize* = nullptr) override;
210 auto ShouldBeginDrag(TPoint&) -> bool override;
211 auto GetWindow() -> TWindow* override;
212 auto GetHarbor() -> THarbor* override;
213
214 protected:
215 void EvNCLButtonDown(uint hitTest, const TPoint& point);
216 void EvLButtonDown(uint hitTest, const TPoint& point);
217 bool EvSizing(uint side, TRect& rect);
218 bool EvWindowPosChanging(WINDOWPOS & windowPos);
219 void EvWindowPosChanged(const WINDOWPOS& windowPos);
220 void EvClose();
221 void EvSettingChange(uint, LPCTSTR);
222 void EvGetMinMaxInfo(MINMAXINFO & info);
223
225};
226
227enum TGridType { ///< Grid type corresponds with Location:
228 YCoord, ///< Top & bottom edge have Y coords parallel horiz
229 XCoord, ///< Left & right edge have X coords parallel vertically
230};
231
232//
233/// \class TEdgeSlip
234// ~~~~~ ~~~~~~~~~
235/// TEdgeSlip is the class of windows used by THarbor as the actual docking slips
236/// along the decorated frame client's edges.
237//
238class _OWLCLASS TEdgeSlip : public TWindow, public TDockingSlip {
239 public:
241
242 // Overridden TWindow virtuals
243 //
244 auto EvCommand(uint id, THandle hWndCtl, uint notifyCode) -> TResult override;
245 void EvCommandEnable(TCommandEnabler& commandEnabler) override;
246 void SetupWindow() override;
247
248 // Overridden TDockingSlip virtuals
249 //
250 void DockableInsert(TDockable& dockable, const TPoint* topLeft,
252 void DockableMove(TDockable& dockable, const TPoint* topLeft,
254 void DockableRemoved(const TRect& orgRect) override;
255 auto GetLocation() const -> TAbsLocation override;
256
257 /// Called by Harbor when creating this docking window on a drop
258 // !CQ fairly kludgy. Should be handled by above docking slip handlers
259 //
260 void ReLayout(bool forcedLayout);
261
262 protected:
263 void EvLButtonDown(uint modKeys, const TPoint& point);
264 void EvLButtonDblClk(uint modKeys, const TPoint& point);
265 uint EvNCCalcSize(bool calcValidRects, NCCALCSIZE_PARAMS & calcSize);
266
267 void EvNCPaint(HRGN);
268
269 bool EvEraseBkgnd(HDC);
270 void EvParentNotify(const TParentNotify&);
271 bool EvWindowPosChanging(WINDOWPOS & windowPos);
272
273 // Internal dockable tiling support
274 //
275 void CompressGridLines();
276 void CompressParallel(int width);
277 TSize ComputeDockingArea();
278
279 TWindow* MoveDraggedWindow(TWindow* draggedWindow);
280 void MoveAllOthers(TWindow* draggedWindow, TWindow* movedWindow);
281
282 int GridSize(int baseCoord);
283
285 TAbsLocation Location; ///< Location on the frame
286 TGridType GridType; ///< Type of grid
287
289};
290
291//
292/// \class THarbor
293// ~~~~~ ~~~~~~~
294/// THarbor is the object that holds all the docking slips. It performs the actual
295/// docking insertion and coordination. It is never visible; it is a window in order
296/// to capture the mouse.
297//
298class _OWLCLASS THarbor : public TWindow {
299 public:
301 ~THarbor() override;
302
303 /// Dockable window insertion
304 //
307 const TPoint* where = 0,
309 TDockable* relativeTo = 0);
310
311 /// Move a dockable from one slip to another, programatically
312 //
313 void Move(TDockable& dockable,
315 const TPoint* where = 0,
317 TDockable* relativeTo = 0);
318
319 /// Remove a dockable from the harbor
320 //
321 void Remove(TDockable& dockable);
322
323 /// Called by docking slips
324 //
325 bool DockDraggingBegin(TDockable& dockable, const TPoint& pt,
328
329 protected:
330 TEdgeSlip* GetEdgeSlip(TAbsLocation location);
331 void SetEdgeSlip(TAbsLocation location, TEdgeSlip* slip);
332 TRelPosition GetSlipPosition(TAbsLocation location);
333
334 // Factory members - could be overridden by derived THarbor class
335 //
336 virtual TEdgeSlip* ConstructEdgeSlip(TDecoratedFrame& df,
338 virtual TFloatingSlip* ConstructFloatingSlip(TDecoratedFrame& df,
339 int x, int y,
341
342 // Mouse handlers - invoked when harbor grabs capture
343 //
344 void EvMouseMove(uint modKeys, const TPoint& point);
345 void EvLButtonUp(uint modKeys, const TPoint& point);
346 void EvLButtonDblClk(uint modKeys, const TPoint& point);
347
348// private:
349 protected: //Sirma (Krasi)
351
352 // Docking slip windows
353 //
358
359 // Dockable dragging state. Put into a struct packet
360 //
363 TAbsLocation DragOrgSlipLoc; ///< Original slip location on mouseDown.
366 TSize DragVSize; ///< Size of dockable when vertical
367 TSize DragHSize; ///< Size of dockable when horizontal
368 TSize DragNSize; ///< Size of dockable when a natural shape
370 TDockingSlip* DragNotificatee; ///< Slip notified on drag operations
371
376
378};
379/// @}
380#include <owl/posclass.h>
381
382
383//----------------------------------------------------------------------------
384// Inline implementations
385//
386
387//
388/// Set the back pointer to the harbor.
389//
391{
392 Harbor = harbor;
393}
394
395//
396/// Retrieve the associated harbor.
397//
399{
400 return Harbor;
401}
402
403} // OWL namespace
404
405
406#endif // OWL_DOCKING_H
Base class for an extensible interface for auto enabling/disabling of commands (menu items,...
Definition window.h:209
TCursor, derived from TGdiBase, represents the GDI cursor object class.
Definition gdiobjec.h:730
TDecoratedFrame automatically positions its client window (you must supply a client window) so that i...
Definition decframe.h:74
A control bar class that is dockable.
Definition docking.h:133
DECLARE_RESPONSE_TABLE(TDockableControlBar)
A version of TGadgetWindow which is dockable.
Definition docking.h:92
DECLARE_RESPONSE_TABLE(TDockableGadgetWindow)
TDockable is an abstract base class for fixed or floating docking windows that want to be dockable in...
Definition docking.h:57
virtual TWindow * GetWindow()=0
Gets dockable's window and hides it, in case we have to toss it around a bit.
virtual TSize ComputeSize(TAbsLocation loc, TSize *dim)=0
Returns the rectangle of the dockable window in the given location.
virtual void GetRect(TRect &rect)=0
Return the rectangle of the dockable window in the given location.
virtual void Layout(TAbsLocation loc, TSize *dim=0)=0
Changes the window to be equal to the size returned from ComputeNNNNN.
virtual bool ShouldBeginDrag(TPoint &pt)=0
This is overriden for any window that wants to be docked.
virtual THarbor * GetHarbor()=0
Returns the harbor containing the dockable object.
TDockingSlip is an abstract base class for windows which accepts and holds dockable windows.
Definition docking.h:154
virtual void DockableMove(TDockable &dockable, const TPoint *topLeft=0, TRelPosition position=rpNone, TDockable *relDockable=0)=0
void SetHarbor(THarbor *harbor)
Set the back pointer to the harbor.
Definition docking.h:390
THarbor * GetHarbor() const
Retrieve the associated harbor.
Definition docking.h:398
virtual TAbsLocation GetLocation() const =0
THarbor * Harbor
Definition docking.h:176
virtual void DockableRemoved(const TRect &orgRect)=0
virtual void DockableInsert(TDockable &dockable, const TPoint *topLeft=0, TRelPosition position=rpNone, TDockable *relDockable=0)=0
Inserts the dockable into the slip, based on arguments given.
TEdgeSlip is the class of windows used by THarbor as the actual docking slips along the decorated fra...
Definition docking.h:238
Derived from TFrameWindow and TTinyCaption, TFloatingFrame implements a floating frame that can be po...
Definition floatfra.h:52
TFloatingSlip is a floating frame which can hold a dockable window.
Definition docking.h:187
DECLARE_RESPONSE_TABLE(TFloatingSlip)
TFont derived from TGdiObject provides constructors for creating font objects from explicit informati...
Definition gdiobjec.h:296
TGadget is the base class for the following derived gadget classes:
Definition gadget.h:120
Derived from TWindow, TGadgetWindow maintains a list of tiled gadgets for a window and lets you dynam...
Definition gadgetwi.h:122
TTileDirection
Enumeration describing how gadgets should be laid out within the gadget window.
Definition gadgetwi.h:130
THarbor is the object that holds all the docking slips.
Definition docking.h:298
TDockable * DragDockable
Definition docking.h:361
TEdgeSlip * SlipLeft
Definition docking.h:355
TRect SlipRR
Definition docking.h:375
TWindowDC * DragDC
Definition docking.h:362
TEdgeSlip * SlipRight
Definition docking.h:357
TSize DragNSize
Size of dockable when a natural shape.
Definition docking.h:368
TDecoratedFrame & DecFrame
Definition docking.h:350
TRect DragFrame
Definition docking.h:365
DECLARE_RESPONSE_TABLE(THarbor)
TRect SlipBR
Definition docking.h:373
TAbsLocation DragSlipLoc
Definition docking.h:364
TEdgeSlip * SlipBottom
Definition docking.h:356
TSize DragVSize
Size of dockable when vertical.
Definition docking.h:366
TPoint DragAnchor
Definition docking.h:369
TSize DragHSize
Size of dockable when horizontal.
Definition docking.h:367
TRect SlipTR
Definition docking.h:372
TRect SlipLR
Definition docking.h:374
TDockingSlip * DragNotificatee
Slip notified on drag operations.
Definition docking.h:370
TEdgeSlip * SlipTop
Definition docking.h:354
TAbsLocation DragOrgSlipLoc
Original slip location on mouseDown.
Definition docking.h:363
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
Definition module.h:75
TPoint is a support class, derived from tagPOINT.
Definition geometry.h:87
TRect is a mathematical class derived from tagRect.
Definition geometry.h:308
The tagSIZE struct is defined as.
Definition geometry.h:234
Derived from TDC, TWindowDC is a device context (DC) class that provides access to the entire area ow...
Definition dc.h:588
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
Definition window.h:414
HWND THandle
TWindow encapsulates an HWND.
Definition window.h:418
Definition of class TControlBar.
Definition of class TDecoratedFrame, a TFrameWindow that can manage decorations around the client win...
#define DECLARE_RESPONSE_TABLE(cls)
Definition eventhan.h:436
Definition of class TFloatingFrame.
Definition of TGadgetList, TGadgetWindow & TGadgetWindowFont A list holding gadgets,...
TRelPosition
General use 2-D rectangular relative position enum.
Definition docking.h:43
TGridType
Definition docking.h:227
@ rpNone
No location specified.
Definition docking.h:44
@ rpAbove
Refers to top edge of frame.
Definition docking.h:45
@ rpBelow
Refers to bottom edge of frame.
Definition docking.h:46
@ rpRightOf
Refers to left edge of frame.
Definition docking.h:47
@ rpLeftOf
Refers to right edge of frame.
Definition docking.h:48
@ XCoord
Left & right edge have X coords parallel vertically.
Definition docking.h:229
@ YCoord
Grid type corresponds with Location:
Definition docking.h:228
TAbsLocation
General use absolute 2-D rectangular location enum.
Definition geometry.h:62
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
UINT TMsgId
Message ID type.
Definition dispatch.h:53
TDispatch< WM_PARENTNOTIFY >::TArgs TParentNotify
Alias for convenience.
Definition dispatch.h:2894
unsigned int uint
Definition number.h:25
#define protected_data
Definition defs.h:208
#define _OWLCLASS
Definition defs.h:338