OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
splitter.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/// Definition of helper classes for Pane Splitters
7//----------------------------------------------------------------------------
8
9#if !defined(OWL_SPLITTER_H)
10#define OWL_SPLITTER_H
11
12#include <owl/private/defs.h>
13#if defined(BI_HAS_PRAGMA_ONCE)
14# pragma once
15#endif
16
17#include <owl/layoutwi.h>
18#include <owl/shddel.h>
19#include <owl/template.h> //added by DLN
20
21namespace owl {
22
23class _OWLCLASS TDC;
24
25#include <owl/preclass.h>
26
27//
28/// Enumeration describing whether to split a window in the X or Y plane.
29//
31 psHorizontal, ///< Horizontal split
32 psVertical, ///< Vertical split
33 psNone ///< Unspecified split
34};
35
36class _OWLCLASS TSplitterIndicator;
37class _OWLCLASS TPaneSplitter;
38
39//
40/// \class TSplitter
41// ~~~~~ ~~~~~~~~~
42/// Abstract base class for TVSplitter and THSplitter.
43//
45 public:
46 TSplitter(TWindow* parent, TPaneSplitter* ps, float percent);
47
48 int operator ==(const TSplitter& splitter) const;
49 float GetPercent();
50 void SetPercent(float p);
51 virtual TRect GetRect() = 0;
52 TRect GetScreenRect();
55 virtual TWindow* Pane1() = 0;
56 virtual TWindow* Pane2() = 0;
57 virtual void Split(TWindow* targetPane,
60 float percent) = 0;
63 float percent) = 0;
64 virtual void AdjForResize(const TSize& sz) = 0;
65 TLayoutWindow* RemovePane(TWindow* pane,
67 TShouldDelete::DefDelete);
68 TRect GetMoveArea();
69 virtual void Move(int dist) = 0;
70 virtual void AdjSplitterWidth(int w) = 0;
71
72 protected:
73 void EvLButtonDown(uint modKeys, const TPoint& point);
74 void EvLButtonUp(uint modKeys, const TPoint& point);
75 void EvMouseMove(uint modKeys, const TPoint& point);
76 bool EvSetCursor(HWND hwndCursor, uint codeHitTest, TMsgId mouseMsg);
77 void EvSize(uint sizeType, const TSize& size);
78 void Paint(TDC&, bool erase, TRect&) override;
79
80 void SetupEpilog(TSplitter* s, TWindow* targetPane,
84
86 // Represents the percent 'pane1' is of splitter (.5, .25, etc.).
87 //
88 float PercentOf;
89 TPaneSplitter* PaneSplitter;
90
92};
93
94//
95/// \class TVSplitter
96// ~~~~~ ~~~~~~~~~~
97/// Represents a vertical splitter.
98//
100 public:
101 TVSplitter(TWindow* parent, TPaneSplitter* ps, float percent=50.0f);
102
103 // Pane1 is left of splitter and pane2 is right.
104 //
105 TWindow* Pane1();
106 TWindow* Pane2();
107 void Split(TWindow* targetPane, TWindow* newPane,
108 TSplitDirection sd, float percent=50.0f);
110 TRect GetRect();
111 TSplitDirection SplitDirection();
112 TSplitterIndicator* CreateSplitterIndicator();
113 void AdjForResize(const TSize& sz);
114 void Move(int dist);
115 void AdjSplitterWidth(int w);
116};
117
118//
119/// \class THSplitter
120// ~~~~~ ~~~~~~~~~~
121/// Represents a horizontal splitter.
122//
124 public:
125 THSplitter(TWindow* parent, TPaneSplitter* ps, float percent=50.0f);
126
127 // Pane1 is above splitter and pane2 is below.
128 //
129 TWindow* Pane1();
130 TWindow* Pane2();
131 void Split(TWindow* targetPane, TWindow* newPane,
132 TSplitDirection sd, float percent=50.0f);
134 TRect GetRect();
135 TSplitDirection SplitDirection();
136 TSplitterIndicator* CreateSplitterIndicator();
137 void AdjForResize(const TSize& sz);
138 void Move(int dist);
139 void AdjSplitterWidth(int w);
140};
141
142//
143/// \class TSplitterIndicator
144// ~~~~~ ~~~~~~~~~~~~~~~~~~
145/// Indicates to the user where the splitter will be moved to when dragging
146/// completes. Abstract base class for TVSplitterIndicator and
147/// THSplitterIndicator.
148//
150 public:
153
154 bool operator == (const TSplitterIndicator& si) const;
155 // make happy STL
157 virtual void ConnectToRect(const TRect& rect) = 0;
158 virtual void Move(int dist) = 0;
159 uint GetDistMoved();
160 void Draw();
161 void Clear();
162 virtual int CalcDistMoved(const TPoint& start, const TPoint& cur) = 0;
163 virtual bool CouldContain(const TPoint& point) = 0;
164 TSplitter* GetSplitter();
166 void SetCushion(const uint cushion);
167
168 protected:
172 //
173 // Minimum distance btwn separators.
174 //
176};
177
178//
179/// \class TVSplitterIndicator
180// ~~~~~ ~~~~~~~~~~~~~~~~~~~
181/// Vertical indicator.
182//
184 public:
186
187 // Override virtuals
188 //
189 void ConnectToRect(const TRect& rect);
190 void Move(int dist);
191 int CalcDistMoved(const TPoint& start, const TPoint& cur);
192 bool CouldContain(const TPoint& point);
193 TRect CalcAreaOfSplitterMove();
194};
195
196//
197/// \class THSplitterIndicator
198// ~~~~~ ~~~~~~~~~~~~~~~~~~~
199/// Horizontal indicator.
200//
202 public:
204
205 // Override virtuals
206 //
207 void ConnectToRect(const TRect& rect);
208 void Move(int dist);
209 int CalcDistMoved(const TPoint& start, const TPoint& cur);
210 bool CouldContain(const TPoint& point);
211 TRect CalcAreaOfSplitterMove();
212};
213
214//
215//DLN replaced by class decl below class TSplitterIndicatorList;
216
217//------------------------------------------------------------------------------
218/// \class TSplitterIndicatorList
219// ~~~~~ ~~~~~~~~~~~~~~~~~~~~~~
220class _OWLCLASS TSplitterIndicatorList: public TBaseList<TSplitterIndicator*>{
221 public:
223 uint NSplitterIndicators() { return Size(); }
224 TSplitterIndicator* FindIndicatorWithSplitter(TSplitter* splitter);
225 void Flush(bool del);
226};
228
229//
230/// \class TSplitterIndicatorMgr
231// ~~~~~ ~~~~~~~~~~~~~~~~~~~~~
232/// Handles the moving of the indicators.
233//
235 public:
237
238 void StartMove(TSplitterIndicatorList& sil, const TPoint& point);
239 void EndMove();
240 void MoveIndicators(const TPoint& point);
241
242 private:
243 TSplitterIndicatorList* SplitterIndicatorList;
244 TPoint StartDragPoint;
245
246 void DrawIndicators();
247 void ClearIndicators();
248};
249
250#include <owl/posclass.h>
251
252
253//----------------------------------------------------------------------------
254// Inline implementations
255
256//
258{
259 return this == &splitter;
260}
261
262//
264{
265 return PercentOf;
266}
267
268//
269inline void TSplitter::SetPercent(float p)
270{
271 PercentOf = p;
272}
273
274//
275/// Return the area the splitter can move in (bounding rectangle).
276/// The rect is in client coordinates.
277//
279{
280 return GetWindowRect();
281}
282
283//
284/// Similar to above except rect is in screen coordinates.
285//
287{
288 TRect rect = GetRect();
289 MapWindowPoints(nullptr, reinterpret_cast<TPoint*>(&rect), 2); // map to screen
290 return rect;
291}
292
293//
298
299//
300inline TSplitDirection
305
306//
308:
309 TRect(rect), Splitter(splitter), Showing(false), DistMoved(0), Cushion(cushion)
310{
311}
312
313//
315{
316 return this == &si;
317}
318
319//
320inline uint
325
326//
327/// Clear indicator from screen.
328//
329inline void
331{
332 if (Showing) {
333 Showing = false;
334 Draw();
335 Showing = false;
336 }
337}
338
339//
340/// Return splitter from which this indicator was created.
341//
342inline TSplitter*
347
348//
349/// Set cushion
350//
351inline void
356
357//
363
364//
370
371/*
372inline uint TSplitterIndicatorList::NSplitterIndicators()
373{
374 return size();
375}
376inline void TSplitterIndicatorList::Flush(bool del){
377 if(del){
378 TSplitterIndicatorList::iterator i = begin();
379 while(i != end())
380 delete *i;
381 }
382 this->erase(begin(),end());
383}
384*/
385//
387:
388 SplitterIndicatorList(nullptr)
389{
390}
391
392} // OWL namespace
393
394
395#endif // OWL_SPLITTER_H
TDC is the root class for GDI DC wrappers.
Definition dc.h:64
Represents a horizontal splitter.
Definition splitter.h:123
TSplitDirection SplitDirection()
Definition splitter.h:301
Horizontal indicator.
Definition splitter.h:201
THSplitterIndicator(TSplitter *splitter, const TRect &rect, uint cushion=0)
Definition splitter.h:365
When specifying the layout metrics for a window, four layout constraints are needed.
Definition layoutwi.h:54
Derived from TWindow, TLayoutWindow provides functionality for defining the layout metrics for a wind...
Definition layoutwi.h:122
TPaneSplitter is a class that acts as a container for child windows (called panes) and splitters (pan...
Definition panespli.h:52
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
Abstract base class for TVSplitter and THSplitter.
Definition splitter.h:44
virtual TRect GetRect()=0
int operator==(const TSplitter &splitter) const
Definition splitter.h:257
float GetPercent()
Definition splitter.h:263
TRect GetScreenRect()
Similar to above except rect is in screen coordinates.
Definition splitter.h:286
virtual TSplitDirection SplitDirection()=0
virtual void AdjForResize(const TSize &sz)=0
virtual TSplitterIndicator * CreateSplitterIndicator()=0
TRect GetMoveArea()
Return the area the splitter can move in (bounding rectangle).
Definition splitter.h:278
virtual void AdjSplitterWidth(int w)=0
void SetPercent(float p)
Definition splitter.h:269
virtual void Move(int dist)=0
virtual TWindow * Pane1()=0
virtual TLayoutMetrics Setup(TWindow *targetPane, TWindow *newPane, float percent)=0
virtual TWindow * Pane2()=0
virtual void Split(TWindow *targetPane, TWindow *newPane, TSplitDirection sd, float percent)=0
Indicates to the user where the splitter will be moved to when dragging completes.
Definition splitter.h:149
TSplitter * GetSplitter()
Return splitter from which this indicator was created.
Definition splitter.h:343
virtual bool CouldContain(const TPoint &point)=0
void Clear()
Clear indicator from screen.
Definition splitter.h:330
virtual TRect CalcAreaOfSplitterMove()=0
void SetCushion(const uint cushion)
Set cushion.
Definition splitter.h:352
TSplitterIndicator(TSplitter *splitter, const TRect &rect, uint cushion=0)
Definition splitter.h:307
virtual void ConnectToRect(const TRect &rect)=0
virtual int CalcDistMoved(const TPoint &start, const TPoint &cur)=0
virtual void Move(int dist)=0
virtual ~TSplitterIndicator()
Definition splitter.h:152
bool operator==(const TSplitterIndicator &si) const
Definition splitter.h:314
Handles the moving of the indicators.
Definition splitter.h:234
Represents a vertical splitter.
Definition splitter.h:99
TSplitDirection SplitDirection()
Definition splitter.h:294
Vertical indicator.
Definition splitter.h:183
TVSplitterIndicator(TSplitter *splitter, const TRect &rect, uint cushion=0)
Definition splitter.h:358
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
Definition window.h:414
TRect GetWindowRect() const
Gets the screen coordinates of the window's rectangle.
Definition window.h:2257
void MapWindowPoints(HWND hWndTo, TPoint *pts, int count) const
Maps a set of points in one window to a relative set of points in another window.
Definition window.h:2206
#define DECLARE_RESPONSE_TABLE(cls)
Definition eventhan.h:436
Definition of classes TLayoutMetrics & TLayoutWindow.
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
UINT TMsgId
Message ID type.
Definition dispatch.h:53
TSplitDirection
Enumeration describing whether to split a window in the X or Y plane.
Definition splitter.h:30
@ psNone
Unspecified split.
Definition splitter.h:33
@ psHorizontal
Horizontal split.
Definition splitter.h:31
@ psVertical
Vertical split.
Definition splitter.h:32
TSplitterIndicatorList::Iterator TSplitterIndicatorListIterator
Definition splitter.h:227
unsigned int uint
Definition number.h:25
#define protected_data
Definition defs.h:208
#define _OWLCLASS
Definition defs.h:338
Definition of container classes used and made available by OWL.