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

GUIBehaviourDecorator base class. More...

#include <GUIBehaviourDecorator.h>

Inheritance diagram for CGUIBehaviourDecorator:

Public Member Functions

virtual ~CGUIBehaviourDecorator ()
 
virtual CGUIBehaviourDecoratorClone () const
 
virtual eC_Bool IsCompositeBehaviour () const
 
- Public Member Functions inherited from CGUIBehaviour
virtual eC_Bool DoScale (const eC_Value &vDelta)
 
virtual eC_Bool DoUserEvent (CGUIEvent *const pEvent)
 
virtual void OnCreate ()
 
virtual void OnDataPool (const DataPoolResource_t &eID)
 
virtual void OnDelete ()
 
virtual void OnHide ()
 
virtual void OnShow ()
 
virtual eC_Bool DoClick (const eC_Value &vAbsX=eC_FromInt(-1), const eC_Value &vAbsY=eC_FromInt(-1))
 
virtual eC_Bool DoLongClick (const eC_Value &vAbsX=eC_FromInt(-1), const eC_Value &vAbsY=eC_FromInt(-1))
 
virtual eC_Bool DoDoubleClick (const eC_Value &vAbsX=eC_FromInt(-1), const eC_Value &vAbsY=eC_FromInt(-1))
 
virtual eC_Bool DoButtonDown (const eC_Value &vAbsX=eC_FromInt(-1), const eC_Value &vAbsY=eC_FromInt(-1))
 
virtual eC_Bool DoButtonUp (const eC_Value &vAbsX=eC_FromInt(-1), const eC_Value &vAbsY=eC_FromInt(-1))
 
virtual eC_Bool DoDrag (const eC_Value &vDeltaX=eC_FromInt(-1), const eC_Value &vDeltaY=eC_FromInt(-1), const eC_Value &vAbsX=eC_FromInt(-1), const eC_Value &vAbsY=eC_FromInt(-1))
 
virtual eC_Bool DoDragEnd (const eC_Value &vAbsX=eC_FromInt(-1), const eC_Value &vAbsY=eC_FromInt(-1))
 
virtual eC_Bool DoMouseEnter (const eC_Value &vAbsX=eC_FromInt(-1), const eC_Value &vAbsY=eC_FromInt(-1))
 
virtual eC_Bool DoMouseLeave (const eC_Value &vAbsX=eC_FromInt(-1), const eC_Value &vAbsY=eC_FromInt(-1))
 
virtual eC_Bool DoMouseMove (const eC_Value &vAbsX=eC_FromInt(-1), const eC_Value &vAbsY=eC_FromInt(-1))
 
virtual eC_Bool FocusPrevious (CGUIObject *const pRefObj=NULL, const eC_Bool &bSubTreeOfRefObjDone=false)
 
virtual eC_Bool FocusNext (CGUIObject *const pRefObj=NULL, const eC_Bool &bSubTreeOfRefObjDone=false)
 
virtual void GetFocus ()
 
virtual void LoseFocus ()
 
virtual eC_Bool Decrease ()
 
virtual eC_Bool Increase ()
 
virtual eC_Bool DoKeyDown (const GUIKeyIdentifier_t &eKeyIdentifier, const eC_UInt &uiModifiers)
 
virtual eC_Bool DoKeyUp (const GUIKeyIdentifier_t &eKeyIdentifier, const eC_UInt &uiModifiers)
 
virtual eC_Bool DoChar (const eC_UInt &uiKey, const GUIKeyIdentifier_t &eKeyIdentifier, const eC_UInt &uiModifiers)
 
virtual eC_Bool DoScroll (const eC_Value &vAbsX, const eC_Value &vAbsY, const eC_Value &vDelta, const eC_Bool &bModifierActive)
 
- 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)
 

Protected Member Functions

 CGUIBehaviourDecorator (CGUIObject *const pkObject=NULL)
 
 CGUIBehaviourDecorator (const CGUIBehaviourDecorator &kSource)
 
virtual void AssociatedObjectChanges (CGUIObject *const pkNewAssociatedObject)
 
CGUIObjectGetAssociatedObject () const
 
- 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
 

Friends

class CGUICompositeBehaviour
 < More...
 
void CGUIObject::ReadFromStream ()
 
void CGUIObject::SetBehaviour (CGUIBehaviourDecorator *pBehaviour)
 

Additional Inherited Members

- Static Public Member Functions inherited from CGUIStreamableObject
static UUID_t GenerateUUID ()
 
- Static Public Attributes inherited from CGUIBehaviour
static const eC_Char XMLTAG_BEHAVIOURCLASSID []
 XML tag to be used when writing a behaviour class ID into a stream.
 
static const eC_Char XMLTAG_BEHAVIOURCOUNT []
 XML tag for count.
 
- Static Public Attributes inherited from CGUIStreamableObject
static const eC_Char XMLTAG_CLASSVERSION []
 

Detailed Description

GUIBehaviourDecorator base class.

Behavioural decorators enable the developer to implement standard object behaviours which are not integral part of a specific control, but can in fact be appended to any CGUIObject. A behaviour's event handling slots are always called before those of its corresponding CGUIObject. You can thus override the object's reaction to a given event without having the need to derive a whole new class for this task. As always, a method's return value indicates whether the corresponding object's event-handling method will still be called (=false) or the event was already completed and no further treatment is required (=true).

The following example shows a simple behaviour decorator which prints out a debug message whenever the GUIObject to which it is attached is being clicked. Note that the DoClick()-implementation returns false, which means that the click will still be forwarded to the corresponding GUIObject afterwards.

You can even attach such a behaviour-decorator to objects which do otherwise not implement any standard behaviour. For instance, you could attach the example behaviour to a CGUIImage-object, let it receive events by calling pPointerToImageObject->SetDisabled(false), and the behaviour will print out a debug-message upon every click on the corresponding GUIImage:

class CExampleBehaviour
{
public:
eC_Bool DoClick(const eC_Value& vAbsX, const eC_Value& vAbsY)
{
GUILOG(GUI_TRACE_DEBUG, "some incredibly impressive clicking behaviour \n");
return false;
}
};
GUIBehaviourDecorator base class.
Definition: GUIBehaviourDecorator.h:78
virtual eC_Bool DoClick(const eC_Value &vAbsX=eC_FromInt(-1), const eC_Value &vAbsY=eC_FromInt(-1))

The following line shows how to attach a BehaviourDecorator to an object:

pPointerToObject->SetBehaviour(new CExampleBehaviour());

Ownership

Note that there is always a one-on-one relationship between a CGUIBehaviourDecorator and its associated CGUIObject OR its parent CGUICompositeBehaviour. That means if you first attach your behaviour to an object within the GUI, and then add it as a child-object to a composite-behaviour, it will be removed from the CGUIObject.

Note also that a behaviour will automatically delete itself if nobody (i.e. neither any CGUIObject, nor any CGUICompositeBehaviour) is still using it!

The following code demonstrates the ownership philosophy

// Create a behaviour decorator
// Create an object
CGUIObject* pkObject = new CGUIObject(&GETGUI, 0,0,100,10);
// Assign the behaviour to the object
pkObject->SetBehaviour(pDemoBhv);
// Now we delete the object ... This deletes the behaviour as well!
delete pkObject;
This is the Guiliani base class all controls are derived from.
Definition: GUIObject.h:81
void SetBehaviour(CGUIBehaviourDecorator *pkBehaviour)
Execute a command when a specific event occurs.
Definition: GUISingleCmdBehaviour.h:21

Constructor & Destructor Documentation

◆ ~CGUIBehaviourDecorator()

virtual CGUIBehaviourDecorator::~CGUIBehaviourDecorator ( )
virtual

Destructor. The Behaviour will unregister itself from its associated object and/or composite behaviour.

◆ CGUIBehaviourDecorator() [1/2]

CGUIBehaviourDecorator::CGUIBehaviourDecorator ( CGUIObject *const  pkObject = NULL)
protected

Constructor. If the given object parameter is not NULL, it calls the SetBehaviour method of the object.

Parameters
pkObjectThe object that contains this behaviour.

◆ CGUIBehaviourDecorator() [2/2]

CGUIBehaviourDecorator::CGUIBehaviourDecorator ( const CGUIBehaviourDecorator kSource)
protected

This is the empty implementation of the copy-constructor. All attributes will be initialized with NULL.

Parameters
kSourceSource behaviour.

Member Function Documentation

◆ AssociatedObjectChanges()

virtual void CGUIBehaviourDecorator::AssociatedObjectChanges ( CGUIObject *const  pkNewAssociatedObject)
protectedvirtual

This slot is being called whenever the associated object pointer is changing. The internal m_pkObject pointer will still point to the "old" associated object, while the supplied parameter points to the "new" one.

Parameters
pkNewAssociatedObjectPointer to new associated object

◆ Clone()

virtual CGUIBehaviourDecorator * CGUIBehaviourDecorator::Clone ( ) const
virtual

Creates an exact copy of this behaviour. Should be re-implemented by each derived class to return the correct type of behaviour.

Returns
the created copy.

Reimplemented in CGUICompositeBehaviour, CGUIHotkeysBehaviour, CGUIMultiCmdBehaviour, and CGUISingleCmdBehaviour.

◆ GetAssociatedObject()

CGUIObject * CGUIBehaviourDecorator::GetAssociatedObject ( ) const
protected

Gets the object that contains this behaviour. If this behaviour is a child of a CGUICompositeBehaviour, the parent's associated object is returned.

Returns
The object that contains this behaviour.

◆ IsCompositeBehaviour()

virtual eC_Bool CGUIBehaviourDecorator::IsCompositeBehaviour ( ) const
inlinevirtual

Indicates whether this is a CGUICompositeBehaviour. Please do not reimplement this method in any derived class. It is only used in the CGUIBehaviourDecorator and CGUICompositeBehaviour to distinguish those two basic types.

Returns
False.

Reimplemented in CGUICompositeBehaviour.

Friends And Related Function Documentation

◆ CGUICompositeBehaviour

friend class CGUICompositeBehaviour
friend

<

◆ CGUIObject::ReadFromStream

void CGUIObject::ReadFromStream ( )
friend

◆ CGUIObject::SetBehaviour

void CGUIObject::SetBehaviour ( CGUIBehaviourDecorator pBehaviour)
friend
Parameters
pBehaviour

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