OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
layoutco.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 class TLayoutConstraint.
7//----------------------------------------------------------------------------
8
9#if !defined(OWL_LAYOUTCO_H)
10#define OWL_LAYOUTCO_H
11
12#include <owl/private/defs.h>
13#if defined(BI_HAS_PRAGMA_ONCE)
14# pragma once
15#endif
16
17#include <owl/defs.h>
18
19
20namespace owl {
21
22#include <owl/preclass.h>
23
24class _OWLCLASS TWindow;
25
26/// \addtogroup Layout
27/// @{
28//
29/// Use to represent the parent in layout metrics
30//
31#define lmParent nullptr
32
33/// The TEdge enum describes the following constants that define the boundaries of a
34/// window:
36{
37 lmLeft, ///< The left edge of the window
38 lmTop, ///< The top edge of the window
39 lmRight, ///< The right edge of the window
40 lmBottom, ///< The bottom edge of the window
41 lmCenter ///< The center of the window. The object that owns the constraint, such as
42 ///< TLayoutMetrics, determines whether the center of the window is the vertical
43 ///< center or the horizontal center.
44};
45
46/// Used by the TLayoutConstraint struct, TWidthHeight enumerates the values that
47/// control the width (lmWidth) and height (lmHeight) of the window.
49
50/// Used by the TLayoutConstraint struct, TMeasurementUnits enumerates the
51/// measurement units (lmPixels or lmLayoutUnits) that control the dimension of the
52/// window. These can be either pixels or layout units that are obtained by dividing
53/// the font height into eight vertical and eight horizontal segments.
54//
55/// \note To set the font, to which lmLayoutUnits are relative, you should call SetWindowFont.
56/// Otherwise, TLayoutWindow will use the obsolete SYSTEM_FONT to calculate the units.
57//
59
60/// Used by the TLayoutConstraint struct, TRelationship specifies the relationship
61/// between the edges and sizes of one window and the edges and sizes of another
62/// window (which can be a parent or sibling). These relationships can be specified
63/// as either the same value as the sibling or parent window (lmAsIs), an absolute
64/// value (lmAbsolute), a percent of one of the windows (lmPercentOf), a value that
65/// is either added above (lmAbove) or left (lmLeftOf) of one of the windows, or a
66/// value that is subtracted from below (lmBelow) or right (lmRightOf) of one of the
67/// windows.
76
77//
78/// \struct TLayoutConstraint
79// ~~~~~~ ~~~~~~~~~~~~~~~~~
80/// TLayoutConstraint is a structure that defines a relationship (a layout
81/// constraint) between an edge or size of one window and an edge or size of one of
82/// the window's siblings or its parent. If a parent-child relationship is
83/// established between windows, the dimensions of the child windows are dependent
84/// on the parent window. A window can have one of its sizes depend on the size of
85/// the opposite dimension.
86///
87/// For example, the width can be twice the height. TLayoutMetrics lists the
88/// relationships you can have among size and edge constraints
89///
90/// The following window is displayed by the sample program LAYOUT.CPP, which
91/// demonstrates layout constraints:
92/// \image html bm210.BMP
93///
94/// Layout constraints are specified as a relationship between an edge/size
95/// of one window and an edge/size of one of the window's siblings or parent
96///
97/// It is acceptable for a window to have one of its sizes depend on the
98/// size of the opposite dimension (e.g. width is twice height)
99///
100/// Distances can be specified in either pixels or layout units
101///
102/// A layout unit is defined by dividing the font "em" quad into 8 vertical
103/// and 8 horizontal segments. we get the font by self-sending WM_GETFONT
104/// (we use the system font if WM_GETFONT returns 0)
105///
106/// "lmAbove", "lmBelow", "lmLeftOf", and "lmRightOf" are only used with edge
107/// constraints. They place the window 1 pixel to the indicated side (i.e.
108/// adjacent to the other window) and then adjust it by "Margin" (e.g. above
109/// window "A" by 6)
110///
111/// \note "Margin" is either added to ("lmAbove" and "lmLeftOf") or subtracted
112/// from("lmBelow" and "lmRightOf") depending on the relationship
113///
114/// "lmSameAs" can be used with either edges or sizes, and it doesn't offset
115/// by 1 pixel like the above four relationships did. it also uses "Value"
116/// (e.g. same width as window "A" plus 10)
117///
118/// \note "Value" is always *added*. use a negative number if you want the
119/// effect to be subtractive
120//
122/// RelWin is a pointer to the sibling windows or lmParent if the child is a
123/// proportion of the parent's dimensions. RelWin points to the window itself (this)
124/// if a child window's dimension is a proportion of one of its other dimensions
125/// (for example, its height is a proportion of its width).
126 TWindow* RelWin; // relative window, lmParent for parent
127
128/// MyEdge contains the name of the edge or size constraint (lmTop, lmBottom,
129/// lmLeft, lmRight, lmCenter, lmWidth, or lmHeight) for your window.
130 uint MyEdge : 4; // edge or size (width/height)
131
132/// Relationship specifies the type of relationship that exists between the two
133/// windows (that is, lmRightOf, lmLeftOf, lmAbove, lmBelow, lmSameAs, or
134/// lmPercentOf). A value of lmAbsolute actually indicates that no relationship
135/// exists.
137
138/// Units enumerates the units of measurement (either pixels or layout units) used
139/// to measure the height and width of the windows. Unlike pixels, layout units are
140/// based on system font size and will be consistent in their perceived size even if
141/// the screen resolution changes.
143
144/// OtherEdge contains the name of the edge or size constraint (lmTop, lmBottom,
145/// lmLeft, lmRight, lmCenter, lmWidth, or lmHeight) for the other window.
146 uint OtherEdge : 4; // edge or size (width/height)
147
148/// This union is included for the convenience of naming the layout constraints.
149/// Margin is used for the ImAbove, ImLeftOf, ImLeftOf, or ImRightOf enumerated
150/// values in TRelationship. Value is used for the ImSameAs or ImAbsolute enumerated
151/// values in TRelationship. Percent is used for the ImPercentOf enumerated value in
152/// TRelationship.
153 union {
154 int Margin; ///< used for "lmAbove", "lmBelow", "lmLeftOf", "lmRightOf"
155 int Value; ///< used for "lmSameAs" and "lmAbsolute"
156 int Percent; ///< used for "lmPercentOf"
157 };
158};
159
160//
161/// \struct TEdgeConstraint
162// ~~~~~~ ~~~~~~~~~~~~~~~
163/// TEdgeConstraint adds member functions that set edge (but not size) constraints.
164/// TEdgeConstraint always places your window one pixel above the other window and
165/// then adds margins.
166///
167/// For example, if the margin is 4, TEdgeConstraint places your window 5 pixels
168/// above the other window. The margin, which does not need to be measured in
169/// pixels, is defined using the units specified by the constraint. Therefore, if
170/// the margin is specified as 8 layout units (which are then converted to 12
171/// pixels), your window would be placed 13 pixels above the other window.
172//
174
175 /// For setting arbitrary edge constraints. use it like this:
176 /// \code
177 /// metrics->X.Set(lmLeft, lmRightOf, lmParent, lmLeft, 10);
178 /// \endcode
180 TEdge otherEdge, int value = 0);
181
182 // These four member functions can be used to position your window with
183 // respective to a sibling window. you specify the sibling window and an
184 // optional margin between the two windows
185 //
186 void LeftOf(TWindow* sibling, int margin = 0);
187 void RightOf(TWindow* sibling, int margin = 0);
188 void Above(TWindow* sibling, int margin = 0);
189 void Below(TWindow* sibling, int margin = 0);
190
191 // These two work on the same edge, e.g. "SameAs(win, lmLeft)" means
192 // that your left edge should be the same as the left edge of "otherWin"
193 //
196
197 // Setting an edge to a fixed value
198 //
199 void Absolute(TEdge edge, int value);
200
201 // Letting an edge remain as-is
202 //
203 void AsIs(TEdge edge);
204};
205
206//
207/// \struct TEdgeOrSizeConstraint
208// ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~
210
211 // Redefine member functions defined by TEdgeConstraint that are hidden by
212 // TEdgeOrSizeConstraint because of extra/different params
213 //
217 void AsIs(TEdge edge);
218 void AsIs(TWidthHeight edge);
219};
220
222
223 // Redefine member functions defined by TEdgeOrSizeConstraint that are hidden by
224 // TEdgeOrWidthConstraint because of extra/different params
225 //
226 void Absolute(TEdge edge, int value);
229
230 /// Setting a width/height to a fixed value
231 //
232 void Absolute(int value);
233
234 /// Percent of another window's width/height (defaults to being the same
235 /// dimension but could be the opposite dimension, e.g. make my width 50%
236 /// of my parent's height)
237 //
239 int percent,
241
242 /// Same as another window's width/height (defaults to being the same
243 /// dimension but could be the opposite dimension, e.g. make my width
244 /// the same as my height)
245 //
246 void SameAs(TWindow* otherWin,
248 int value = 0);
249
250};
251
253
254 // Redefine member functions defined by TEdgeOrSizeConstraint that are hidden by
255 // TEdgeOrHeightConstraint because of extra/different params
256 //
257 void Absolute(TEdge edge, int value);
260
261 /// Setting a width/height to a fixed value
262 //
263 void Absolute(int value);
264
265 /// Percent of another window's width/height (defaults to being the same
266 /// dimension but could be the opposite dimension, e.g. make my width 50%
267 /// of my parent's height)
268 //
270 int percent,
272
273 /// Same as another window's width/height (defaults to being the same
274 /// dimension but could be the opposite dimension, e.g. make my width
275 /// the same as my height)
276 //
277 void SameAs(TWindow* otherWin,
279 int value = 0);
280
281};
282
283/// @}
284
285#include <owl/posclass.h>
286
287//----------------------------------------------------------------------------
288// Inline implementations
289
290//
291/// Used for setting arbitrary edge constraints, Set specifies that your window's
292/// edge should be of a specified relationship to otherWin's specified edge.
302
303//
304/// Positions one window with respect to a sibling window. You can specify the
305/// sibling window and an optional margin between the two windows.
310
311//
312/// Positions one window with respect to a sibling window. You can specify the
313/// sibling window and an optional margin between the two windows.
318
319//
320/// Positions your window above a sibling window. You must specify the sibling
321/// window and an optional margin between the two windows. If no margin is
322/// specified, Above sets the bottom of one window one pixel above the top of the
323/// other window.
328
329//
330/// Positions your window with respect to a sibling window. You must specify the
331/// sibling window and an optional margin between the two windows. If no margin is
332/// specified, Below sets the top of one window one pixel below the bottom of the
333/// other window.
338
339//
340/// Sets the edge of your window indicated by edge equivalent to the corresponding
341/// edge of the window in otherWin.
346
347//
348/// Specifies that the edge of one window indicated in edge should be a percentage
349/// of the corresponding edge of another window (otherWin.
354
355//
356/// Sets an edge of your window to a fixed value.
358{
359 MyEdge = edge;
360 Value = value;
362}
363
364//
366{
367 MyEdge = edge;
369}
370
371//---
372
373//
378
379//
384
385//---
386
387//
392
393//
398
399//
404
405//
412
413//
423
424//
434
435//---
436
437//
442
443//
448
449//
454
455//
462
463//
473
474//
484
485
486
487} // OWL namespace
488
489
490#endif // OWL_LAYOUTCO_H
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
Definition window.h:414
TEdge
The TEdge enum describes the following constants that define the boundaries of a window:
Definition layoutco.h:36
TMeasurementUnits
Used by the TLayoutConstraint struct, TMeasurementUnits enumerates the measurement units (lmPixels or...
Definition layoutco.h:58
TRelationship
Used by the TLayoutConstraint struct, TRelationship specifies the relationship between the edges and ...
Definition layoutco.h:68
TWidthHeight
Used by the TLayoutConstraint struct, TWidthHeight enumerates the values that control the width (lmWi...
Definition layoutco.h:48
@ lmTop
The top edge of the window.
Definition layoutco.h:38
@ lmBottom
The bottom edge of the window.
Definition layoutco.h:40
@ lmCenter
The center of the window.
Definition layoutco.h:41
@ lmRight
The right edge of the window.
Definition layoutco.h:39
@ lmLeft
The left edge of the window.
Definition layoutco.h:37
@ lmLayoutUnits
Definition layoutco.h:58
@ lmPixels
Definition layoutco.h:58
@ lmLeftOf
Definition layoutco.h:71
@ lmAbove
Definition layoutco.h:71
@ lmAbsolute
Definition layoutco.h:74
@ lmSameAs
Definition layoutco.h:73
@ lmPercentOf
Definition layoutco.h:70
@ lmRightOf
Definition layoutco.h:72
@ lmBelow
Definition layoutco.h:72
@ lmAsIs
Definition layoutco.h:69
@ lmWidth
Definition layoutco.h:48
@ lmHeight
Definition layoutco.h:48
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
General definitions used by all ObjectWindows programs.
#define _OWLCLASS
Definition defs.h:338
TEdgeConstraint adds member functions that set edge (but not size) constraints.
Definition layoutco.h:173
void Below(TWindow *sibling, int margin=0)
Positions your window with respect to a sibling window.
Definition layoutco.h:334
void RightOf(TWindow *sibling, int margin=0)
Positions one window with respect to a sibling window.
Definition layoutco.h:314
void Above(TWindow *sibling, int margin=0)
Positions your window above a sibling window.
Definition layoutco.h:324
void AsIs(TEdge edge)
Definition layoutco.h:365
void LeftOf(TWindow *sibling, int margin=0)
Positions one window with respect to a sibling window.
Definition layoutco.h:306
void SameAs(TWindow *otherWin, TEdge edge)
Sets the edge of your window indicated by edge equivalent to the corresponding edge of the window in ...
Definition layoutco.h:342
void Absolute(TEdge edge, int value)
Sets an edge of your window to a fixed value.
Definition layoutco.h:357
void Set(TEdge edge, TRelationship rel, TWindow *otherWin, TEdge otherEdge, int value=0)
For setting arbitrary edge constraints.
Definition layoutco.h:293
void PercentOf(TWindow *otherWin, TEdge edge, int percent)
Specifies that the edge of one window indicated in edge should be a percentage of the corresponding e...
Definition layoutco.h:350
void PercentOf(TWindow *otherWin, TEdge edge, int percent)
Definition layoutco.h:444
void SameAs(TWindow *otherWin, TEdge edge)
Definition layoutco.h:450
void Absolute(TEdge edge, int value)
Definition layoutco.h:438
void Absolute(TEdge edge, int value)
void SameAs(TWindow *otherWin, TEdge edge)
void AsIs(TEdge edge)
Definition layoutco.h:374
void PercentOf(TWindow *otherWin, TEdge edge, int percent)
void PercentOf(TWindow *otherWin, TEdge edge, int percent)
Definition layoutco.h:394
void Absolute(TEdge edge, int value)
Definition layoutco.h:388
void SameAs(TWindow *otherWin, TEdge edge)
Definition layoutco.h:400
TLayoutConstraint is a structure that defines a relationship (a layout constraint) between an edge or...
Definition layoutco.h:121
int Value
used for "lmSameAs" and "lmAbsolute"
Definition layoutco.h:155
TWindow * RelWin
RelWin is a pointer to the sibling windows or lmParent if the child is a proportion of the parent's d...
Definition layoutco.h:126
uint MyEdge
MyEdge contains the name of the edge or size constraint (lmTop, lmBottom, lmLeft, lmRight,...
Definition layoutco.h:130
int Percent
used for "lmPercentOf"
Definition layoutco.h:156
TRelationship Relationship
Relationship specifies the type of relationship that exists between the two windows (that is,...
Definition layoutco.h:136
int Margin
used for "lmAbove", "lmBelow", "lmLeftOf", "lmRightOf"
Definition layoutco.h:154
TMeasurementUnits Units
Units enumerates the units of measurement (either pixels or layout units) used to measure the height ...
Definition layoutco.h:142
uint OtherEdge
OtherEdge contains the name of the edge or size constraint (lmTop, lmBottom, lmLeft,...
Definition layoutco.h:146