Guiliani  Version 2.6 revision 7293 (documentation build 12)
CGUILayouterAnchor Class Reference

This is a layouter, which implements the "anchor"-concept. More...

#include <GUILayouterAnchor.h>

Inheritance diagram for CGUILayouterAnchor:

Public Types

enum  Anchors_t { ANCHOR_TOP = 0x0001 , ANCHOR_BOTTOM = 0x0002 , ANCHOR_LEFT = 0x0004 , ANCHOR_RIGHT = 0x0008 }
 Enumeration for anchors to all four sides of an object.
 
- Public Types inherited from CGUILayouter
enum  eMovedEdges_t {
  CHANGED_WIDTH , CHANGED_HEIGHT , CHANGED_RELXPOS , CHANGED_RELYPOS ,
  CHANGED_EDGE_ALL
}
 Enumerate possible reasons for calling layout,. More...
 

Public Member Functions

 CGUILayouterAnchor (CGUIObject *const pkObject=NULL)
 
 ~CGUILayouterAnchor ()
 Destructs an Anchor-Layouter.
 
virtual void DoLayout (eMovedEdges_t eMovedEdges)
 
virtual void InitLayouter (eMovedEdges_t eMovedEdges)
 
eC_Bool IsAnchorSet (const Anchors_t eAnchor) const
 
virtual eC_Bool IsDependentOnParentSize ()
 
virtual void ReadFromStream ()
 
void SetAnchors (const eC_Bool &bTop, const eC_Bool &bBottom, const eC_Bool &bLeft, const eC_Bool &bRight)
 
void SetAnchors (const eC_UByte &ubAnchors)
 
virtual void WriteToStream (const eC_Bool bWriteClassID=false)
 
- Public Member Functions inherited from CGUILayouter
virtual ~CGUILayouter ()
 Destructor. More...
 
virtual void DoLayout (eMovedEdges_t eMovedEdges)=0
 
CGUIObjectGetAssociatedObject () const
 
virtual void InitLayouter (eMovedEdges_t eMovedEdges)
 
virtual eC_Bool IsDependentOnParentSize ()=0
 
virtual eC_Bool IsGroupLayouter () const
 
virtual void SetAssociatedObject (CGUIObject *const pkObject)
 
- Public Member Functions inherited from CGUIStreamableObject
const eC_String & GetXMLTag () const
 
virtual void ReadFromStream ()
 
void SetXMLTag (const eC_String &kXMLTag)
 
virtual void WriteToStream (const eC_Bool bWriteClassID=false)
 

Static Public Attributes

static const eC_UInt LAYOUTER_ANCHOR_CLASS_VERSION
 Class version of anchor layouter class.
 
- Static Public Attributes inherited from CGUILayouter
static const eC_Char XMLTAG_LAYOUTERCLASSID []
 XML tag to be used when writing a layouter class ID into a stream.
 
- Static Public Attributes inherited from CGUIStreamableObject
static const eC_Char XMLTAG_CLASSVERSION []
 

Additional Inherited Members

- Static Public Member Functions inherited from CGUIStreamableObject
static UUID_t GenerateUUID ()
 
- Protected Member Functions inherited from CGUILayouter
 CGUILayouter (CGUIObject *const pkObject=NULL)
 
- Protected Member Functions inherited from CGUIStreamableObject
eC_UInt ReadStreamingHeader (const eC_UInt &uiClassVersion, const eC_UInt &uiClassMinVersion=0) const
 
void WriteStreamingFooter (const eC_Bool &bWriteClassID) const
 
void WriteStreamingHeader (const eC_Bool &bWriteClassID, const eC_Char *const pkClassIDTag, const eC_Int &iClassID, const eC_UInt &uiClassVersion) const
 

Detailed Description

This is a layouter, which implements the "anchor"-concept.

Anchor-Layoutes allow the user to specify the way in which a GUI layout adapts to changes of the screen-, window- or Object-sizes. Hence, you can define whether an object gets scaled along with its containing object, or whether it moves along with it. Visually speaking, an anchor "glues" a side of an object to the respective side of its parent object, and whenever that parent object changes its dimensions, the child object's layouter will scale/move the child accordingly.

The following table gives you some examples on which behaviour will result from which anchor-settings:

top bottom left right result
ON ON ON ON Object gets stretched in X/Y directions
off off off off Object will not get stretched, but will scale its position along with the change in size of its parent. i.e. If the width of the parent object gets doubled, the relative X position of the child object will double as well.
ON ON ON off Object gets stretched in Y direction and is locked to the left border of its parent
ON ON off ON Object gets stretched in Y direction and is locked to the right border of its parent
ON ON off off Object gets stretched in Y direction and will scale its X position along with the change in size of its parent/td>

The typical usage of a layouter is as follows:

  1. You instantiate the layouter...
  2. set its anchors as required...
  3. and attach it to an object. The object will automatically gain ownership of the layouter and delete it upon its own destruction. (Note that there is always a One on One relationship between objects and layouters.)
    pLayouter->SetAnchors(false, false, true, true);
    pkObject->SetLayouter(pLayouter);
    This is a layouter, which implements the "anchor"-concept.
    Definition: GUILayouterAnchor.h:87
    CGUILayouterAnchor(CGUIObject *const pkObject=NULL)
    void SetAnchors(const eC_Bool &bTop, const eC_Bool &bBottom, const eC_Bool &bLeft, const eC_Bool &bRight)

Constructor & Destructor Documentation

◆ CGUILayouterAnchor()

CGUILayouterAnchor::CGUILayouterAnchor ( CGUIObject *const  pkObject = NULL)

Constructs an Anchor-Layouter.

Parameters
pkObjectPointer to the object to which the layouter is attached.

Member Function Documentation

◆ DoLayout()

virtual void CGUILayouterAnchor::DoLayout ( eMovedEdges_t  eMovedEdges)
virtual

Called when the size of the parent of the associated object has changed.

This method must be re-implemented in derived classes to perform the actual layout change, typically adjustments to the associated object's dimension or position.

It is called by the framework every time the width or height of the parent of the associated object has changed. The framework first calls DoLayout() on the associated object itself and then on all children of the associated object in any depth in the hierarchy.

There are two valid types of layouters: Either: Implementations of DoLayout() shall only adjust the associated object and/or direct children of it. No other decendants of the associated object shall be changed in position or size! This is called a group layouter. CGUILayouterReposition and CGUILayouterGrid are examples of group layouters. Or: Implementations of DoLayout() shall only adjust the associated object depending on the layout of its parent object. No other objects shall be changed in position or size! This is called a child layouter. CGUILayouterAnchor is an example of a child layouter.

Implementing other types of layouters may compromise the framework architecture.

The two use cases may overlap: If a direct child of a group layouter composite object has a child layouter then while streaming in the composite object associated with the group layouter, the composite will first call DoLayout() on its layouter and then call InitLayouter() on the layouters of all direct children of that composite object. Therefore, the group layouter will re-initialize the child layouter. For an anchor layouter this implies that the child layouter will have no effect and should be removed. Still the child layouter's DoLayout() will be called after the parent layouter's DoLayout() later on for any change of the size of the parent so that the child layouter might change (override) the layouting of the group layouter concerning its child layout, for example if using hardcoded values for anchor distances.

Parameters
eMovedEdgesReason for layouter call

Implements CGUILayouter.

◆ InitLayouter()

virtual void CGUILayouterAnchor::InitLayouter ( eMovedEdges_t  eMovedEdges)
virtual

Recalculate the distances of the associated object's right border to the parent's right border and of the associated object's bottom border to the parent's bottom border and set these to be the new anchor lengths.

Note
This is useful for example when the height or width of the associated object changes so that when resizing the parent later on, the current anchor length are used and not those that were saved when the anchors were chosen.
Parameters
eMovedEdgesReason for layouter call

Reimplemented from CGUILayouter.

◆ IsAnchorSet()

eC_Bool CGUILayouterAnchor::IsAnchorSet ( const Anchors_t  eAnchor) const
inline

Returns whether the specified anchor is set or not

Parameters
eAnchorEnumeration identifying the anchor
Returns
True if the anchor is activated, False otherwise.

◆ IsDependentOnParentSize()

virtual eC_Bool CGUILayouterAnchor::IsDependentOnParentSize ( )
inlinevirtual

This function shall determine if the layouter shall initially be called due to resizing the parent of the associated object or if it shall initially be called by resizing the associated object. If it returns false the framework will call DoLayout() on this layouter of the object that is triggering the layout procedure, that is, the composite object on which the first (in the current call stack) SetWidth() or SetHeight() is called.

Returning false is the typical use case for a group layouter that does not consider the layout of the parent of the associated object. In this case the initially resized object starting the layout procedure is the 'group object' itself, therefore you can say changing the 'group object' starts the layout procedure in this case.

If it returns true, the first DoLayout() is called on a child of the initially resized object. This is the typical use case for a child layouter or a group layouter that is considering the layout of 'its' parent. Therefore, you can say changing the parent is starting the layout procedure in this case.

Returns
eC_Bool True if dependend, False otherwise

Implements CGUILayouter.

◆ ReadFromStream()

virtual void CGUILayouterAnchor::ReadFromStream ( )
virtual

Reads attributes from the streaming file. Only for use with GUIFactoryManager.

See also
CGUIObject::ReadFromStream()

Reimplemented from CGUIStreamableObject.

◆ SetAnchors() [1/2]

void CGUILayouterAnchor::SetAnchors ( const eC_Bool &  bTop,
const eC_Bool &  bBottom,
const eC_Bool &  bLeft,
const eC_Bool &  bRight 
)

Set the status of all four anchors. TRUE means that an anchor is activated, FALSE marks the respective anchor as deactivated.

Parameters
bTopSpecifies whether the top anchor is activated
bBottomSpecifies whether the bottom anchor is activated
bLeftSpecifies whether the left anchor is activated
bRightSpecifies whether the right anchor is activated

◆ SetAnchors() [2/2]

void CGUILayouterAnchor::SetAnchors ( const eC_UByte &  ubAnchors)

Set the status of all four anchors. Combine the respective anchors by a logical OR to set several anchors.

Parameters
ubAnchorsStates of all four anchors, by combining the values in Anchors_t using logical ORs

◆ WriteToStream()

virtual void CGUILayouterAnchor::WriteToStream ( const eC_Bool  bWriteClassID = false)
virtual

Writes attributes to the streaming file. A CGUIStreamWriter has to be initialized.

Parameters
bWriteClassIDThis flag is used to switch writing of the class ID, leading and trailing tags. When implementing a new streamable object, check this flag. If it is true, first write the class ID, then continue with this object's attributes, and finally call the base class implementation with this flag set to false (this is the default).

Reimplemented from CGUIStreamableObject.


The documentation for this class was generated from the following file: