OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
layoutwi.h
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectWindows
3// Copyright (c) 1992, 1996 by Borland International, All Rights Reserved
4//
5/// \file
6/// Definition of classes TLayoutMetrics & TLayoutWindow
7//----------------------------------------------------------------------------
8
9#if !defined(OWL_LAYOUTWI_H)
10#define OWL_LAYOUTWI_H
11
12#include <owl/private/defs.h>
13#if defined(BI_HAS_PRAGMA_ONCE)
14# pragma once
15#endif
16
17#include <owl/window.h>
18#include <owl/layoutco.h>
19
20
21namespace owl {
22
23#include <owl/preclass.h>
24
25/// \addtogroup Layout
26/// @{
27/// \class TLayoutMetrics
28// ~~~~~ ~~~~~~~~~~~~~~
29/// When specifying the layout metrics for a window, four layout constraints
30/// are needed.
31///
32/// TLayoutMetrics contains the four layout constraints used to define the layout metrics for a
33/// window. The following table lists the constraints you can use for the X, Y,
34/// Height, and Width fields.
35///
36/// - \c \b X lmLeft, lmCenter, lmRight
37/// - \c \b Y lmTop, lmCenter, lmBottom
38/// - \c \b Height lmCenter, lmRight, lmWidth
39/// - \c \b Width lmCenter, lmBottom, lmHeight
40///
41/// If the metrics for the child window are relative to the parent window, the
42/// relation window pointer needs to be lmParent (not the actual parent window
43/// pointer). For example,
44/// \code
45/// TWindow* child = new TWindow(this, "");
46/// TLayoutMetrics metrics;
47/// metrics.X.Set(lmCenter, lmSameAs, lmParent, lmCenter);
48/// metrics.Y.Set(lmCenter, lmSameAs, lmParent, lmCenter);
49/// SetChildLayoutMetrics(*child, metrics);
50/// \endcode
51/// The parent window pointer (this) should not be used as the relation window
52/// pointer of the child window.
53//
55 public:
56/// X contains the X (left, center, right) edge constraint of the window.
57 TEdgeConstraint X; ///< Horz1 can be lmLeft, lmCenter, lmRight
58
59/// Y contains the Y (top, center, bottom) edge constraint of the window.
60 TEdgeConstraint Y; ///< Vert1 can be lmTop, lmCenter, lmBottom
61
62/// Contains the width size constraint, center edge constraint, or right edge
63/// (lmRight) constraint of the window.
64 TEdgeOrWidthConstraint Width; ///< Horz2 can be lmWidth, lmCenter, lmRight
65
66/// Contains the height size constraint, center edge constraint, or bottom edge
67/// constraint of the window.
68 TEdgeOrHeightConstraint Height; ///< Vert2 can be lmHeight, lmCenter, lmBottom
69
70 /// Defaults each co: RelWin=0, MyEdge=(1st from above), Relationship=AsIs
71 //
73
74 void SetMeasurementUnits(TMeasurementUnits units);
75};
76
77//
78// Private structs used by TLayoutWindow
79//
80struct TChildMetrics;
81struct TConstraint;
82struct TVariable;
83
84//
85/// \class TLayoutWindow
86// ~~~~~ ~~~~~~~~~~~~~
87/// Derived from TWindow, TLayoutWindow provides functionality for defining the
88/// layout metrics for a window. By using layout constraints, you can create windows
89/// whose position and size are proportional to another window's dimensions, so that
90/// one window constrains the size of the other window. Toolbars and status bars are
91/// examples of constrained windows.
92///
93/// When specifying the layout metrics for a window, there are several options:
94/// e.g. in the horizontal direction,
95///
96/// Two Edge Constraints in X and Width
97/// - 1. left edge and right edge
98/// - 2. center edge and right edge
99/// - 3. left edge and center edge
100///
101/// Edge Constraint and Size constraint in X and Width
102/// - 4. left edge and size
103/// - 5. right edge and size
104/// - 6. center edge and size
105///
106/// The same holds true in the vertical direction for Y and Height
107///
108/// It is also possible to specify "lmAsIs" in which case we use the windows
109/// current value
110///
111/// Specifying "lmAbsolute" means that we will use whatever is in data member
112/// "Value"
113///
114/// We just name the fields "X" and "Width" and "Y" and "Height",
115/// although its okay to place a right or center edge constraint in the
116/// "Width" field and its also okay to place a right edge constraint in
117/// the "X" field (i.e. option #3)
118///
119/// However, it's NOT okay to place a width constraint in the "X" or
120/// "Height" fields or a height constraint in the "Y" or "Width" fields.
121//
122class _OWLCLASS TLayoutWindow : virtual public TWindow {
123 public:
124 TLayoutWindow(TWindow* parent,
125 LPCTSTR title = 0,
126 TModule* module = 0);
127 TLayoutWindow(TWindow* parent, const tstring& title, TModule* = 0);
128 ~TLayoutWindow() override;
129
130 virtual void Layout();
131
132 void SetChildLayoutMetrics(TWindow& child, const TLayoutMetrics& metrics);
133 bool GetChildLayoutMetrics(const TWindow& child, TLayoutMetrics& metrics);
134 auto GetChildLayoutMetrics(const TWindow& child) -> TLayoutMetrics;
135 bool RemoveChildLayoutMetrics(const TWindow& child);
136
137 protected:
138
139 void Init(TWindow* parent, LPCTSTR title, TModule* module);
140
141 void EvSize(uint sizeType, const TSize& size);
142 auto EvGetFont() -> HFONT;
143 void EvSetFont(HFONT, bool redraw);
144
145 void RemoveChild(TWindow*) override;
146
148 /// Contains the size of the client area.
149 TSize ClientSize;
150
151 private:
152 enum TWhichConstraint {
153 XConstraint,
154 YConstraint,
155 WidthConstraint,
156 HeightConstraint
157 };
158
159 TChildMetrics* ChildMetrics;
160 TConstraint* Constraints;
161 TConstraint* Plan;
162 TVariable* Variables;
163 bool PlanIsDirty;
164 int NumChildMetrics;
165 HFONT Font;
166 int FontHeight;
167
168 TChildMetrics* GetChildMetrics(const TWindow& child);
169
170 void AddConstraint(TChildMetrics& metrics,
172 TWhichConstraint whichContraint);
173 void BuildConstraints(TChildMetrics& childMetrics);
174 void RemoveConstraints(TChildMetrics& childMetrics);
175
176 void BuildPlan();
177 void ExecutePlan();
178 void ClearPlan();
179
180 int LayoutUnitsToPixels(int);
181 void GetFontHeight();
182
183 // Hidden to prevent accidental copying or assignment
184 //
187
189 //DECLARE_CASTABLE;
191};
192/// @}
193
195
196#include <owl/posclass.h>
197
198
199} // OWL namespace
200
201
202#endif // OWL_LAYOUTWIN_H
When specifying the layout metrics for a window, four layout constraints are needed.
Definition layoutwi.h:54
TEdgeConstraint Y
Y contains the Y (top, center, bottom) edge constraint of the window.
Definition layoutwi.h:60
TEdgeOrWidthConstraint Width
Contains the width size constraint, center edge constraint, or right edge (lmRight) constraint of the...
Definition layoutwi.h:64
TEdgeOrHeightConstraint Height
Contains the height size constraint, center edge constraint, or bottom edge constraint of the window.
Definition layoutwi.h:68
TEdgeConstraint X
X contains the X (left, center, right) edge constraint of the window.
Definition layoutwi.h:57
Derived from TWindow, TLayoutWindow provides functionality for defining the layout metrics for a wind...
Definition layoutwi.h:122
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
Definition module.h:75
The tagSIZE struct is defined as.
Definition geometry.h:234
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
Definition window.h:414
#define DECLARE_RESPONSE_TABLE(cls)
Definition eventhan.h:436
TMeasurementUnits
Used by the TLayoutConstraint struct, TMeasurementUnits enumerates the measurement units (lmPixels or...
Definition layoutco.h:58
#define DECLARE_STREAMABLE_OWL(cls, ver)
Definition objstrm.h:1529
#define DECLARE_STREAMABLE_INLINES(cls)
Definition objstrm.h:1538
Definition of class TLayoutConstraint.
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
std::string tstring
Definition defs.h:79
unsigned int uint
Definition number.h:25
#define protected_data
Definition defs.h:208
#define _OWLCLASS
Definition defs.h:338
TEdgeConstraint adds member functions that set edge (but not size) constraints.
Definition layoutco.h:173
TLayoutConstraint is a structure that defines a relationship (a layout constraint) between an edge or...
Definition layoutco.h:121
Base window class TWindow definition, including HWND encapsulation.