Cafu Engine
cf::GuiSys::ComponentBaseT Class Reference

This is the base class for the components that a window is composed/aggregated of. More...

#include "CompBase.hpp"

Inheritance diagram for cf::GuiSys::ComponentBaseT:

Public Member Functions

 ComponentBaseT ()
 The constructor. More...
 
 ComponentBaseT (const ComponentBaseT &Comp)
 The copy constructor. More...
 
virtual ComponentBaseTClone () const
 The virtual copy constructor. More...
 
virtual ~ComponentBaseT ()
 The virtual destructor. More...
 
WindowTGetWindow () const
 Returns the parent window that contains this component, or NULL if this component is currently not a part of any window. More...
 
TypeSys::VarManTGetMemberVars ()
 Returns the variable manager that keeps generic references to our member variables, providing a simple kind of "reflection" or "type introspection" feature. More...
 
bool CallLuaMethod (const char *MethodName, const char *Signature="",...)
 Calls the given Lua method of this component. More...
 
virtual const char * GetName () const
 Returns the name of this component. More...
 
virtual void UpdateDependencies (WindowT *Window)
 This method is called whenever something "external" to this component has changed: More...
 
virtual void Render () const
 This method implements the graphical output of this component. More...
 
virtual void OnPostLoad (bool OnlyStatic)
 This method is called after all windows and their components have been loaded. More...
 
virtual bool OnInputEvent (const CaKeyboardEventT &KE)
 This method handles keyboard input events. More...
 
virtual bool OnInputEvent (const CaMouseEventT &ME, float PosX, float PosY)
 This method handles mouse input events. More...
 
virtual void OnClockTickEvent (float t)
 This method handles clock-tick events. More...
 
virtual const
cf::TypeSys::TypeInfoT
GetType () const
 
- Public Member Functions inherited from RefCountedT
unsigned int GetRefCount () const
 

Static Public Member Functions

static void * CreateInstance (const cf::TypeSys::CreateParamsT &Params)
 

Static Public Attributes

static const cf::TypeSys::TypeInfoT TypeInfo
 

Static Protected Member Functions

static int Get (lua_State *LuaState)
 
static int Set (lua_State *LuaState)
 
static int GetExtraMessage (lua_State *LuaState)
 
static int Interpolate (lua_State *LuaState)
 
static int toString (lua_State *LuaState)
 

Static Protected Attributes

static const luaL_Reg MethodsList []
 The list of Lua methods for this class. More...
 
static const char * DocClass
 
static const cf::TypeSys::MethsDocT DocMethods []
 

Additional Inherited Members

- Protected Member Functions inherited from RefCountedT
 RefCountedT (const RefCountedT &)
 
RefCountedToperator= (const RefCountedT &)
 

Detailed Description

This is the base class for the components that a window is composed/aggregated of.

Components are the basic building blocks of a window: their composition defines the properties, the behaviour, and thus virtually every aspect of the window.

Components can exist in two invariants:

  • Stand-alone, independent and not a part of any window.
  • Normally, as an active part of a window.

Stand-alone components typically occur when they're newly instantiated, for example when they are loaded from disk, when they are instantiated in scripts, or when they are kept in the clipboard or managed in the Undo/Redo system of the GUI Editor. Newly created, copied or cloned components are initially stand-alone.

A component becomes a part of a window via the WindowT::AddComponent() method. The window then knows the component, because it hosts it, and reversely, the component then knows the parent window that it is a component of.

Constructor & Destructor Documentation

ComponentBaseT::ComponentBaseT ( )

The constructor.

The newly created component is initially not a part of any window.

ComponentBaseT::ComponentBaseT ( const ComponentBaseT Comp)

The copy constructor.

The newly copied component is initially not a part of any window, even if the source component was.

Parameters
CompThe component to create a copy of.
virtual cf::GuiSys::ComponentBaseT::~ComponentBaseT ( )
inlinevirtual

The virtual destructor.

Member Function Documentation

bool ComponentBaseT::CallLuaMethod ( const char *  MethodName,
const char *  Signature = "",
  ... 
)

Calls the given Lua method of this component.

This method is analogous to UniScriptStateT::CallMethod(), see there for details.

Parameters
MethodNameThe name of the Lua method to call.
SignatureSee UniScriptStateT::Call() for details.
ComponentBaseT * ComponentBaseT::Clone ( ) const
virtual

The virtual copy constructor.

Callers can use this method to create a copy of this component without knowing its concrete type. Overrides in derived classes use a covariant return type to facilitate use when the concrete type is known. The newly cloned component is initially not a part of any window, even if the source component was.

Reimplemented in cf::GuiSys::ComponentTextT, cf::GuiSys::ComponentBasicsT, cf::GuiSys::ComponentTransformT, cf::GuiSys::ComponentImageT, cf::GuiSys::ComponentModelT, cf::GuiSys::ComponentChoiceT, cf::GuiSys::ComponentListBoxT, cf::GuiSys::ComponentTextEditT, ComponentClientT, GuiEditor::ComponentSelectionT, and cf::GuiSys::ComponentBorderT.

TypeSys::VarManT& cf::GuiSys::ComponentBaseT::GetMemberVars ( )
inline

Returns the variable manager that keeps generic references to our member variables, providing a simple kind of "reflection" or "type introspection" feature.

WindowT* cf::GuiSys::ComponentBaseT::GetWindow ( ) const
inline

Returns the parent window that contains this component, or NULL if this component is currently not a part of any window.

void ComponentBaseT::OnClockTickEvent ( float  t)
virtual

This method handles clock-tick events.

Parameters
tThe time in seconds since the last clock-tick.

Reimplemented in cf::GuiSys::ComponentModelT, cf::GuiSys::ComponentTextEditT, and ComponentClientT.

virtual bool cf::GuiSys::ComponentBaseT::OnInputEvent ( const CaKeyboardEventT KE)
inlinevirtual

This method handles keyboard input events.

Parameters
KEKeyboard event instance.
Returns
Whether the component handled ("consumed") the event.

Reimplemented in cf::GuiSys::ComponentChoiceT, cf::GuiSys::ComponentListBoxT, cf::GuiSys::ComponentTextEditT, and ComponentClientT.

virtual bool cf::GuiSys::ComponentBaseT::OnInputEvent ( const CaMouseEventT ME,
float  PosX,
float  PosY 
)
inlinevirtual

This method handles mouse input events.

Parameters
MEMouse event instance.
PosXx-coordinate of the mouse cursor position.
PosYy-coordinate of the mouse cursor position.
Returns
Whether the component handled ("consumed") the event.

Reimplemented in cf::GuiSys::ComponentChoiceT, cf::GuiSys::ComponentListBoxT, and ComponentClientT.

virtual void cf::GuiSys::ComponentBaseT::OnPostLoad ( bool  OnlyStatic)
inlinevirtual

This method is called after all windows and their components have been loaded.

It is called only once when the static part of GUI initializatzion is complete, i.e. after the initial values of all windows and their components have been set. Components can override this method in order act / do something / add custom behaviour at that time.

For example, a choice component can use it to set the associated text component to the initial selection, a script component can forward it to the script by calling a related script function, a component that for backwards-compatibility supports reading old variables can convert to new ones, etc.

Parameters
OnlyStatictrue if only the loading of static data is desired, e.g. when the world is instantiated in the GUI Editor, false if also user-defined scripts with custom, initial behaviour should be loaded.

Reimplemented in cf::GuiSys::ComponentChoiceT.

virtual void cf::GuiSys::ComponentBaseT::Render ( ) const
inlinevirtual
void ComponentBaseT::UpdateDependencies ( WindowT Window)
virtual

This method is called whenever something "external" to this component has changed:

  • if the parent window has changed, because this component was added to or removed from it,
  • if other components in the parent window have changed. The component can use the opportunity to search the window for "sibling" components that it depends on, and store direct pointers to them. Note however that dependencies among components must not be cyclic, or else the deletion of a window will leave a memory leak.
    Parameters
    WindowThe parent window that contains this component, or NULL to indicate that this component is removed from the window that it used to be a part of.

Reimplemented in cf::GuiSys::ComponentTextT, cf::GuiSys::ComponentImageT, cf::GuiSys::ComponentModelT, cf::GuiSys::ComponentChoiceT, cf::GuiSys::ComponentListBoxT, and cf::GuiSys::ComponentTextEditT.

Member Data Documentation

const char * ComponentBaseT::DocClass
staticprotected
Initial value:
=
"This is the base class for the components that a window is composed/aggregated of.\n"
"Components are the basic building blocks of a window: their composition defines\n"
"the properties, the behaviour, and thus virtually every aspect of the window."
const cf::TypeSys::MethsDocT ComponentBaseT::DocMethods
staticprotected
Initial value:
=
{
META_Get,
META_Set,
META_GetExtraMessage,
META_Interpolate,
META_toString,
{ NULL, NULL, NULL, NULL }
}
const luaL_Reg ComponentBaseT::MethodsList
staticprotected
Initial value:
=
{
{ "get", Get },
{ "set", Set },
{ "GetExtraMessage", GetExtraMessage },
{ "interpolate", Interpolate },
{ "__tostring", toString },
{ NULL, NULL }
}

The list of Lua methods for this class.


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