LayoutControl.h
Go to the documentation of this file.
1 /*--------------------------------------------------------------------------------------+
2 |
3 | Supplied under applicable software license agreement.
4 |
5 | Copyright (c) 2018 Bentley Systems, Incorporated. All rights reserved.
6 |
7 +---------------------------------------------------------------------------------------*/
8 #pragma once
9 
10 #include <UI/UIFramework.h>
11 #include <UI/Core/BPoint.h>
12 #include <UI/Core/BSize.h>
13 #include <UI/Core/BRect.h>
14 #include <UI/Layout/Margins.h>
15 #include <UI/Layout/SizePolicy.h>
16 
17 #include <Bentley\RefCounted.h>
18 
19 #pragma warning(disable:4275) // non EDLL-interface classkey 'identifier' used as base for DLL-interface classkey 'identifier'
20 
21 #define LCONTROL_MAX_SIZE ((1<<24)-1)
22 
24 
25 class LayoutManager;
26 class LayoutItem;
27 
28 //=======================================================================================
53 //=======================================================================================
54 class LayoutControl : public Bentley::RefCounted <IRefCounted>
55  {
56 public:
57 
60  DLLEXPORT virtual void Move(const BPoint &) = 0;
61  DLLEXPORT virtual void Move(int x, int y);
62 
65  DLLEXPORT virtual void Resize(const BSize &) = 0;
66  DLLEXPORT virtual void Resize(int w, int h);
67 
70  DLLEXPORT virtual void ShowIfNotHidden() = 0;
71 
77  DLLEXPORT virtual BSize GetDesiredSize() const;
78 
89  DLLEXPORT virtual BSize GetDesiredMinimumSize() const;
90 
102  DLLEXPORT virtual BSize GetMinimumSize() const;
103 
105  DLLEXPORT virtual int GetMinimumWidth() const;
106 
108  DLLEXPORT virtual int GetMinimumHeight() const;
109 
112  DLLEXPORT void SetMinimumSize (const BSize &minSize);
113 
117  DLLEXPORT void SetMinimumSize (int minWidth, int minHeight);
118 
121  DLLEXPORT void SetMinimumWidth (int minWidth);
122 
125  DLLEXPORT void SetMinimumHeight (int minHeight);
126 
133  DLLEXPORT virtual BSize GetMaximumSize() const;
134 
136  DLLEXPORT virtual int GetMaximumWidth() const;
137 
139  DLLEXPORT virtual int GetMaximumHeight() const;
140 
143  DLLEXPORT void SetMaximumSize (const BSize &maxSize);
144 
148  DLLEXPORT void SetMaximumSize (int maxWidth, int maxHeight);
149 
152  DLLEXPORT void SetMaximumWidth (int maxWidth);
153 
156  DLLEXPORT void SetMaximumHeight (int maxHeight);
157 
165  DLLEXPORT virtual int GetHeightForWidth (int width) const;
166 
169 
172  DLLEXPORT void SetParentControl (LayoutControl* parentCtl);
173 
175  DLLEXPORT virtual BPoint GetPosition() const;
177  DLLEXPORT virtual int GetX () const;
179  DLLEXPORT virtual int GetY () const;
180 
182  DLLEXPORT virtual BSize GetSize() const;
184  DLLEXPORT virtual int GetWidth () const;
186  DLLEXPORT virtual int GetHeight () const;
187 
191  DLLEXPORT void SetSize (const BSize &size);
192 
194  DLLEXPORT virtual BRect GetRect() const;
195 
197  DLLEXPORT virtual BRect GetContentsRect() const;
198 
205  DLLEXPORT void SetFixedSize (const BSize &size);
209  DLLEXPORT void SetFixedSize (int width, int height);
210 
212  DLLEXPORT virtual SizePolicyR GetSizePolicy() const;
219  DLLEXPORT void SetSizePolicy (SizePolicyType horizontal, SizePolicyType vertical);
220 
222  DLLEXPORT virtual LayoutManager *GetLayout() const;
224  DLLEXPORT void SetLayout (LayoutManager *layout);
225 
227  DLLEXPORT virtual LayoutManager *GetParentLayout () const;
229  DLLEXPORT void SetParentLayout (LayoutManager *layout);
230 
232  DLLEXPORT Margins GetMargins() const;
238  DLLEXPORT void GetMargins (int *left, int *top, int *right, int *bottom) const;
240  DLLEXPORT int GetLeftMargin () const;
242  DLLEXPORT int GetRightMargin () const;
244  DLLEXPORT int GetTopMargin () const;
246  DLLEXPORT int GetBottomMargin () const;
249  DLLEXPORT int GetMargin (LayoutMargin lm) const;
250 
253  DLLEXPORT void SetMargin (int margin);
256  DLLEXPORT void SetMargins (const Margins &margins);
262  DLLEXPORT void SetMargins (int left, int top, int right, int bottom);
263 
265  DLLEXPORT virtual int GetSpacing (LayoutSpacing pm) const;
266 
268  DLLEXPORT virtual BRect GetGeometry() const;
271  DLLEXPORT virtual void SetGeometry (const BRect &rect);
277  DLLEXPORT void SetGeometry (int x, int y, int w, int h);
278 
285  DLLEXPORT void UpdateGeometry();
287  DLLEXPORT void UpdateGeometry (bool forceUpdate);
288 
290  DLLEXPORT virtual void Invalidate();
291 
293  DLLEXPORT virtual void SetDirty();
294 
295  /*---------------------------------------------------------------------------------------
296  Various Flags: Enabled, Visible, LaidOut, IsWindow
297  ---------------------------------------------------------------------------------------*/
298 
300  DLLEXPORT virtual bool IsEnabled() const;
302  DLLEXPORT void SetEnabled (bool);
303 
305  DLLEXPORT virtual bool IsHidden () const;
307  DLLEXPORT void SetHidden (bool);
309  DLLEXPORT virtual bool IsVisible () const;
311  DLLEXPORT void SetVisible (bool);
312 
314  DLLEXPORT bool IsLaidOut () const;
316  DLLEXPORT void SetLaidOut (bool);
317 
319  DLLEXPORT virtual bool IsWindow () const;
321  DLLEXPORT void SetIsWindow (bool);
322 
324  DLLEXPORT virtual bool UseTrueRect () const;
326  DLLEXPORT void SetUseTrueRect (bool);
327 
329  DLLEXPORT bool WasResized () const;
330 
333 
334 
335  };
336 
void SetVisible(bool)
Sets whether the LayoutControl is visible.
LayoutMargin
Argument type in GetMargin methods.
Definition: LayoutEnums.h:104
void SetParentLayout(LayoutManager *layout)
Sets the LayoutManager controlling the size and position of this control.
The SizePolicy class is a layout attribute describing horizontal and vertical resizing policy...
Definition: SizePolicy.h:50
The LayoutControl class is the abstract base class of all user interface elements for layout manager ...
Definition: LayoutControl.h:54
void SetMinimumSize(const BSize &minSize)
Sets the Control's minimum size for layout management.
virtual BSize GetDesiredSize() const
Returns the recommended size for the control.
virtual void SetDirty()
Invalidates the layout item without updating it.
void SetMaximumWidth(int maxWidth)
Sets the Control's maximum width for layout management.
virtual int GetSpacing(LayoutSpacing pm) const
Gets the Spacing property, which defines the distance between controls in a layout.
virtual LayoutManager * GetLayout() const
Gets the LayoutManager controlling the size and position of the contents of this control.
virtual BSize GetDesiredMinimumSize() const
Returns the recommended minimum size for the control.
void SetMargins(const Margins &margins)
Sets the Margins property, which defines the four margins around the control's rectangle.
void SetLaidOut(bool)
Sets whether the LayoutControl is laid out.
void SetMinimumHeight(int minHeight)
Sets the Control's minimum height for layout management.
virtual BPoint GetPosition() const
Gets the position of the control within its parent control.
bool IsLaidOut() const
Determines if the LayoutControl is laid out.
virtual int GetX() const
Gets the X position of the control within its parent control.
virtual int GetMinimumWidth() const
Returns the Control's minimum width for layout management.
virtual int GetY() const
Gets the Y position of the control within its parent control.
LayoutControl * GetParentControl() const
Returns the parent control of this control.
void SetLayout(LayoutManager *layout)
Sets the LayoutManager controlling the size and position of the contents of this control.
The LayoutItem class provides an abstract item that a LayoutManager manipulates.
Definition: LayoutItem.h:52
int GetRightMargin() const
Gets the right margin.
The BRect class defines a rectangle using integer precision.
Definition: BRect.h:71
virtual void SetGeometry(const BRect &rect)
Sets the Geometry property, which defines the rectangle within the parent control.
virtual BSize GetMinimumSize() const
Returns the Control's minimum size for layout management.
virtual bool UseTrueRect() const
Determines if the LayoutManager should use the parent control's geometry when resizing this control...
virtual int GetHeight() const
Gets the height of the control.
Template to simplify the task of writing a class that implements the reference-counting pattern...
Definition: RefCounted.h:90
The BPoint class defines a point in the plane using integer precision.
Definition: BPoint.h:34
The BSize class defines the size of a two - dimensional object using integer point precision...
Definition: BSize.h:38
virtual int GetMaximumWidth() const
Returns the Control's maximum width.
virtual LayoutManager * GetParentLayout() const
Gets the LayoutManager controlling the size and position of this control.
Margins GetMargins() const
Gets the Margins property, which defines the four margins around the control's rectangle.
The Margins class defines the four margins of a rectangle.
Definition: Margins.h:23
#define BEGIN_BENTLEY_UIFRAMEWORK_NAMESPACE
Definition: UIFramework.h:14
virtual void Resize(const BSize &)=0
The Resize method is called by the LayoutManager to resize the control.
virtual BRect GetGeometry() const
Gets the Geometry property, which defines the rectangle within the parent control.
void UpdateGeometry()
Notifies the layout system that this LayoutControl has changed and may need to change geometry...
void SetHidden(bool)
Sets whether the LayoutControl is hidden.
void SetUseTrueRect(bool)
Sets whether the LayoutManager should use the parent control's geometry when resizing this control...
#define DLLEXPORT
Definition: basedefs.h:137
virtual int GetMinimumHeight() const
Returns the Control's minimum height for layout management.
void SetIsWindow(bool)
Sets whether the LayoutControl is a Window.
int GetMargin(LayoutMargin lm) const
Gets the appropriate margin, based on the given LayoutMargin.
int GetLeftMargin() const
Gets the left margin.
void SetEnabled(bool)
Sets whether the LayoutControl is enabled.
void SetMargin(int margin)
Sets the Margins property, which defines the four margins around the control's rectangle.
virtual bool IsVisible() const
Determines if the LayoutControl is visible.
virtual int GetHeightForWidth(int width) const
Returns the preferred height for this control, given a certain width.
void SetSize(const BSize &size)
Sets the current size of the control.
bool WasResized() const
Determines if the LayoutControl has been resized.
virtual int GetWidth() const
Gets the width of the control.
virtual BSize GetMaximumSize() const
Returns the Control's maximum size in pixels.
void SetSizePolicy(SizePolicy sp)
Sets the SizePolicy, which is a layout attribute describing horizontal and vertical resizing policy...
void SetMinimumWidth(int minWidth)
Sets the Control's minimum width for layout management.
virtual void Invalidate()
Invalidates the layout item then updates it.
#define END_BENTLEY_UIFRAMEWORK_NAMESPACE
Definition: UIFramework.h:15
virtual BRect GetRect() const
Gets the internal geometry of the control.
void SetParentControl(LayoutControl *parentCtl)
Sets the parent control of this control.
void SetMaximumHeight(int maxHeight)
Sets the Control's maximum height for layout management.
The LayoutManager class is the base class of the layout managers.
Definition: LayoutManager.h:46
LayoutSpacing
Argument type in SmartSpacing and GetSpacing methods.
Definition: LayoutEnums.h:115
virtual BRect GetContentsRect() const
Returns the area inside the control's margins.
virtual void ShowIfNotHidden()=0
The ShowIfNotHidden method is called by the LayoutManager to show the control.
void SetFixedSize(const BSize &size)
Sets both the minimum and maximum sizes of the control to 'size', thereby preventing it from ever gro...
virtual bool IsEnabled() const
Determines if the LayoutControl is enabled.
int GetTopMargin() const
Gets the top margin.
SizePolicyType
Fixed - The "desired" size is the only acceptable alternative, so the control can never grow or shrin...
Definition: LayoutEnums.r.h:67
virtual void Move(const BPoint &)=0
The Move method is called by the LayoutManager to move the control to a new point.
virtual bool IsHidden() const
Determines if the LayoutControl is hidden.
int GetBottomMargin() const
Gets the bottom margin.
void SetMaximumSize(const BSize &maxSize)
Sets the Control's maximum size for layout management.
size_type size() const
Definition: stdcxx/bstdmap.h:214
virtual SizePolicyR GetSizePolicy() const
Gets the SizePolicy, which is a layout attribute describing horizontal and vertical resizing policy...
LayoutItem * GetLayoutItem() const
Gets the LayoutItem associated with this LayoutControl.
virtual bool IsWindow() const
Determines if the LayoutControl is a Window.
virtual int GetMaximumHeight() const
Returns the Control's maximum height.
virtual BSize GetSize() const
Gets the size of the control.

Copyright © 2017 Bentley Systems, Incorporated. All rights reserved.