LayoutManager.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 
12 #include <UI/Core/BRect.h>
13 #include <UI/Core/BSize.h>
14 #include <UI/Layout/SizePolicy.h>
15 #include <UI/Layout/LayoutItem.h>
16 #include <UI/Layout/Margins.h>
17 
18 
20 
21 class LayoutManager;
22 class LayoutControl;
23 
24 
25 //=======================================================================================
45 //=======================================================================================
46 class LayoutManager : public LayoutItem
47  {
48 public:
49 
63  DLLEXPORT virtual void AddItem (LayoutItem *item) = 0;
64 
74  DLLEXPORT virtual LayoutItem *ItemAt (int index) const = 0;
75 
86  DLLEXPORT virtual LayoutItem *TakeAt (int index) = 0;
87 
92  DLLEXPORT virtual size_t Count() const = 0;
93 
95  DLLEXPORT virtual void Invalidate ();
96 
98  DLLEXPORT virtual void SetDirty ();
99 
101  DLLEXPORT virtual int GetSpacing () const;
102 
105  DLLEXPORT virtual void SetSpacing (int spacing);
106 
111  DLLEXPORT virtual int IndexOf (LayoutControl *ctl) const;
112 
117  DLLEXPORT virtual int IndexOf (LayoutItem *item) const;
118 
121  DLLEXPORT void WindowSizeDoLayout (const BSize& size);
122 
124  DLLEXPORT void VisibleDoLayout ();
125 
127  DLLEXPORT void ItemSizeDoLayout ();
128 
132 
136 
139 
142 
145 
148 
150  DLLEXPORT int GetMargin() const;
151 
154  DLLEXPORT void SetMargin (int margin);
155 
161  DLLEXPORT void SetLayoutMargins (int left, int top, int right, int bottom);
162 
165  DLLEXPORT void SetLayoutMargins (const Margins &margins);
166 
172  DLLEXPORT void GetLayoutMargins (int *left, int *top, int *right, int *bottom) const;
173 
177 
180 
184  DLLEXPORT bool SetAlignment (LayoutControl *ctl, LayoutAlignment alignment);
185 
189  DLLEXPORT bool SetAlignment (LayoutManager *layout, LayoutAlignment alignment);
191 
193  DLLEXPORT bool Activate ();
194 
196  DLLEXPORT void Update ();
197 
201 
204  DLLEXPORT void RemoveItem (LayoutItem *item);
205 
208  DLLEXPORT int GetTotalHeightForWidth (int width) const;
209 
216 
218  DLLEXPORT void SetEnabled (bool);
220  DLLEXPORT bool IsEnabled () const;
221 
223  DLLEXPORT void SetTopLevel (bool);
225  DLLEXPORT bool IsTopLevel () const;
226 
230  DLLEXPORT bool IsSharedSizeGroupBoundary () const;
231 
233  DLLEXPORT virtual bool IsEmpty() const override;
234 
236  DLLEXPORT virtual bool IsVisible() const override;
237 
239  DLLEXPORT virtual BSize GetMinimumSize() const override;
240 
242  DLLEXPORT virtual BSize GetMaximumSize() const override;
243 
246  DLLEXPORT virtual void SetGeometry(const BRect& rect) override;
247 
249  DLLEXPORT virtual BRect GetGeometry() const override;
250 
252  DLLEXPORT virtual LayoutManager *GetLayout() override;
253 
256  DLLEXPORT virtual LayoutOrientations GetExpandingOrientations() const override;
257 
258  };
259 
bool SetAlignment(LayoutControl *ctl, LayoutAlignment alignment)
Sets the alignment for a child control.
virtual BRect GetGeometry() const override
Retrieves the geometry for this layout item.
virtual bool IsVisible() const override
Returns whether the layout item is visible.
bool IsSharedSizeGroupBoundary() const
Determines whether the layout is a Shared Group Boundary.
The LayoutControl class is the abstract base class of all user interface elements for layout manager ...
Definition: LayoutControl.h:54
virtual LayoutOrientations GetExpandingOrientations() const override
Returns whether this layout item can make use of more space than GetDesiredSize().
void ItemSizeDoLayout()
Notifies this LayoutManager that a child has changed size and all child items should be laid out acco...
Margins GetLayoutMargins() const
Gets the 4 margins for the LayoutManager.
virtual void SetDirty()
Resets the layout's rectangle.
int GetMargin() const
Retrieves the margin for the LayoutManager, but only if all 4 margins are the same. Otherwise, -1 is returned.
virtual void AddItem(LayoutItem *item)=0
Adds a LayoutItem to this Layout Manager.
virtual bool IsEmpty() const override
Returns whether the layout item is empty.
void WindowSizeDoLayout(const BSize &size)
Notifies this LayoutManager that the Window size has changed and all child items should be laid out a...
void RemoveItem(LayoutItem *item)
Removes a child item.
LayoutFlags - Creates a "Flags" class out of an enum with constructors and operator overloading...
Definition: LayoutFlags.h:43
The LayoutItem class provides an abstract item that a LayoutManager manipulates.
Definition: LayoutItem.h:52
BSize GetTotalMinimumSize() const
Retrieves the total minimum size for the layout.
void SetEnabled(bool)
Sets whether the layout is enabled.
virtual BSize GetMinimumSize() const override
Returns the minimum size for this layout item.
virtual int GetSpacing() const
Gets the spacing between items in the layout.
The BRect class defines a rectangle using integer precision.
Definition: BRect.h:71
void SetSharedSizeGroupBoundary(bool)
Sets whether the layout is a Shared Group Boundary.
int GetTotalHeightForWidth(int width) const
Retrieves the required height for a given width.
bool Activate()
Invalidates the layout item then updates it.
The BSize class defines the size of a two - dimensional object using integer point precision...
Definition: BSize.h:38
virtual void SetGeometry(const BRect &rect) override
Sets the geometry for this layout item to the given rectangle.
The Margins class defines the four margins of a rectangle.
Definition: Margins.h:23
#define BEGIN_BENTLEY_UIFRAMEWORK_NAMESPACE
Definition: UIFramework.h:14
#define DLLEXPORT
Definition: basedefs.h:137
LayoutControl * GetParentControl() const
Retrieves the parent LayoutControl associated with this Layout Manager.
void Update()
Invalidates the layout item without updating it.
void VisibleDoLayout()
Notifies this LayoutManager that the layout has changed visibility and all child items should be laid...
bool IsTopLevel() const
Determines whether the layout is top-level.
virtual int IndexOf(LayoutControl *ctl) const
Searches for the control in this layout (not including child layouts).
virtual LayoutManager * GetLayout() override
If the concrete item is a LayoutManager, it can be retrieved using GetLayout().
BRect GetContentsRect() const
Gets the bounding rectangle for the contents in the LayoutManager.
void SetTopLevel(bool)
Sets whether the layout is top-level.
LayoutManager * GetSharedSizeGroupBoundary()
Retrieves the next Shared Size Group Boundary associated with this Layout Manager.
virtual size_t Count() const =0
Returns the number of items in this layout.
LayoutManager * GetParentLayout() const
Retrieves the parent LayoutManager associated with this Layout Manager.
#define END_BENTLEY_UIFRAMEWORK_NAMESPACE
Definition: UIFramework.h:15
void SetParentControl(LayoutControl *)
Sets the parent LayoutControl for this Layout Manager.
virtual BSize GetMaximumSize() const override
Retrieves the maximum size for this layout item.
void SetLayoutMargins(int left, int top, int right, int bottom)
Sets the 4 margins for the LayoutManager.
bool IsEnabled() const
Determines whether the layout is enabled.
virtual void Invalidate()
Resets the layout's rectangle then calls Update()
The LayoutManager class is the base class of the layout managers.
Definition: LayoutManager.h:46
virtual void SetSpacing(int spacing)
Sets the spacing between items in the layout.
BSize GetTotalMaximumSize() const
Retrieves the total maximum size for the layout.
void SetParentLayout(LayoutManager *)
Sets the parent LayoutManager for this Layout Manager.
LayoutManager * GetMainLayout()
Retrieves the main LayoutManager associated with this Layout Manager.
void RemoveControl(LayoutControl *ctl)
Removes a child control.
virtual LayoutItem * TakeAt(int index)=0
Removes the item at index from the layout, and returns the item.
void SetMargin(int margin)
Sets the 4 margins for the LayoutManager to the same value.
size_type size() const
Definition: stdcxx/bstdmap.h:214
virtual LayoutItem * ItemAt(int index) const =0
Retrieves the item at index in the layout and returns the item.
void SetAlignment(LayoutAlignment alignment)
Sets the alignment within the layout for this layout item.
BSize GetTotalDesiredSize() const
Retrieves the total desired size for the layout.

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