This class represents a window of the GuiSys. More...
#include "Window.hpp"
Public Member Functions | |
WindowT (const WindowCreateParamsT &Params) | |
The normal constructor. More... | |
WindowT (const WindowT &Window, bool Recursive=false) | |
The copy constructor. More... | |
virtual WindowT * | Clone (bool Recursive=false) const |
The virtual copy constructor. More... | |
virtual | ~WindowT () |
The virtual destructor. Deletes this window and all its children. More... | |
GuiImplT & | GetGui () const |
IntrusivePtrT< WindowT > | GetParent () const |
Returns the parent window of this window. More... | |
const ArrayT< IntrusivePtrT < WindowT > > & | GetChildren () const |
Returns the immediate children of this window. More... | |
void | GetChildren (ArrayT< IntrusivePtrT< WindowT > > &Chld, bool Recurse=false) const |
Returns the children of this window. More... | |
bool | AddChild (IntrusivePtrT< WindowT > Child, unsigned long Pos=0xFFFFFFFF) |
Adds the given window to the children of this window, and sets this window as the parent of the child. More... | |
bool | RemoveChild (IntrusivePtrT< WindowT > Child) |
Removes the given window from the children of this window. More... | |
IntrusivePtrT< WindowT > | GetRoot () |
Returns the top-most parent of this window, that is, the root of the hierarchy this window is in. More... | |
IntrusivePtrT< ComponentBaseT > | GetApp () |
Returns the application component of this window. More... | |
IntrusivePtrT< const ComponentBaseT > | GetApp () const |
The const variant of the GetApp() method above. See GetApp() for details. More... | |
void | SetApp (IntrusivePtrT< ComponentBaseT > App) |
Sets the application component for this window. See GetApp() for details. More... | |
IntrusivePtrT< ComponentBasicsT > | GetBasics () const |
Returns the "Basics" component of this window. More... | |
IntrusivePtrT < ComponentTransformT > | GetTransform () const |
Returns the "Transform" component of this window. More... | |
const ArrayT< IntrusivePtrT < ComponentBaseT > > & | GetComponents () const |
Returns the components that this window is composed of. More... | |
IntrusivePtrT< ComponentBaseT > | GetComponent (const std::string &TypeName, unsigned int n=0) const |
Returns the (n-th) component of the given (type) name. More... | |
bool | AddComponent (IntrusivePtrT< ComponentBaseT > Comp, unsigned long Index=ULONG_MAX) |
Adds the given component to this window. More... | |
void | DeleteComponent (unsigned long CompNr) |
Deletes the component at the given index from this window. More... | |
Vector2fT | GetAbsolutePos () const |
Returns the position of the upper left corner of this window in absolute (vs. relative to the parent) coordinates. More... | |
IntrusivePtrT< WindowT > | Find (const std::string &WantedName) |
Finds the window with the name WantedName in the hierachy tree of this window. More... | |
IntrusivePtrT< WindowT > | Find (const Vector2fT &Pos, bool OnlyVisible=true) |
Finds the topmost window that contains the point Pos in the hierachy tree of this window (with Pos being in (absolute) screen coordinates, not relative to this window). More... | |
virtual void | Render () const |
Renders this window. More... | |
virtual bool | OnInputEvent (const CaKeyboardEventT &KE) |
Keyboard input event handler. More... | |
virtual bool | OnInputEvent (const CaMouseEventT &ME, float PosX, float PosY) |
Mouse input event handler. More... | |
virtual bool | OnClockTickEvent (float t) |
The clock-tick event handler. More... | |
bool | CallLuaMethod (const char *MethodName, const char *Signature="",...) |
Calls the Lua method with name MethodName of this window. 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 Attributes | |
static const luaL_Reg | MethodsList [] |
List of methods registered with Lua. More... | |
static const char * | DocClass |
static const cf::TypeSys::MethsDocT | DocMethods [] |
static const cf::TypeSys::MethsDocT | DocCallbacks [] |
Additional Inherited Members | |
Protected Member Functions inherited from RefCountedT | |
RefCountedT (const RefCountedT &) | |
RefCountedT & | operator= (const RefCountedT &) |
This class represents a window of the GuiSys.
A WindowT is the most basic element of a GUI, and all other windows are derived and/or combined from this.
WindowT instances can be created in C++ code or in Lua scripts, using the gui:new() function. They can be passed from C++ code to Lua and from Lua to C++ code at will. In C++ code, all WindowT instances are kept in IntrusivePtrT's. Their lifetime is properly managed: A window is deleted automatically when it is no longer used in Lua and in C++. That is, code like Example 1: w=gui:new("WindowT"); gui:SetRootWindow(w); w=nil; Example 2: w=gui:new("WindowT"); w:AddChild(gui:new("WindowT")); works as expected. See the cf::ScriptBinderT class for technical and implementation details.
WindowT::WindowT | ( | const WindowCreateParamsT & | Params | ) |
The normal constructor.
Params | The creation parameters for the window. |
WindowT::WindowT | ( | const WindowT & | Window, |
bool | Recursive = false |
||
) |
The copy constructor.
Copies a window (optionally with all of its children recursively). The parent of the copy is always NULL and it is up to the caller to put the copy into a window hierarchy.
Window | The window to construct this window from. |
Recursive | Whether to recursively copy all children. |
|
virtual |
The virtual destructor. Deletes this window and all its children.
bool WindowT::AddChild | ( | IntrusivePtrT< WindowT > | Child, |
unsigned long | Pos = 0xFFFFFFFF |
||
) |
Adds the given window to the children of this window, and sets this window as the parent of the child.
This method also makes sure that the name of the Child is unique among its siblings, modifying it as necessary. See SetName() for more details.
Child | The window to add to the children of this window. |
Pos | The position among the children to insert the child window at. |
bool WindowT::AddComponent | ( | IntrusivePtrT< ComponentBaseT > | Comp, |
unsigned long | Index = ULONG_MAX |
||
) |
Adds the given component to this window.
Comp | The component to add to this window. |
Index | The position among the other components to insert Comp at. |
true
on success, false
on failure (if Comp
is part of a window already). bool WindowT::CallLuaMethod | ( | const char * | MethodName, |
const char * | Signature = "" , |
||
... | |||
) |
Calls the Lua method with name MethodName
of this window.
This method is analogous to GuiI::CallLuaFunc(), see there for more details.
MethodName | The name of the lua method to call. |
Signature | DOCTODO |
|
virtual |
The virtual copy constructor.
Callers can use this method to create a copy of this window without knowing its concrete type. Overrides in derived classes use a covariant return type to facilitate use when the concrete type is known.
Recursive | Whether to recursively clone all children of this window. |
void WindowT::DeleteComponent | ( | unsigned long | CompNr | ) |
Deletes the component at the given index from this window.
IntrusivePtrT< WindowT > WindowT::Find | ( | const std::string & | WantedName | ) |
Finds the window with the name WantedName in the hierachy tree of this window.
Use GetRoot()->Find("xy") in order to search the entire GUI for the window with name "xy".
WantedName | The name of the window that is to be found. |
IntrusivePtrT< WindowT > WindowT::Find | ( | const Vector2fT & | Pos, |
bool | OnlyVisible = true |
||
) |
Finds the topmost window that contains the point Pos
in the hierachy tree of this window (with Pos
being in (absolute) screen coordinates, not relative to this window).
Use GetRoot()->Find(Pos)
in order to search the entire GUI for the window containing the point Pos
.
Pos | The coordinate of the point to test. |
OnlyVisible | If true, only visible windows are reported. If false, all windows are searched. |
Pos
. Vector2fT WindowT::GetAbsolutePos | ( | ) | const |
Returns the position of the upper left corner of this window in absolute (vs. relative to the parent) coordinates.
|
inline |
Returns the application component of this window.
This component is much like the "Basics" and "Transform" components, but it can be set by the application (see SetApp()), and is intended for the sole use by the application, e.g. for implementing a "selection gizmo" in the GUI Editor.
|
inline |
|
inline |
Returns the "Basics" component of this window.
The "Basics" component defines the name and the "show" flag of the window.
|
inline |
Returns the immediate children of this window.
This is analogous to calling GetChildren(Chld, false) with an initially empty Chld array.
void WindowT::GetChildren | ( | ArrayT< IntrusivePtrT< WindowT > > & | Chld, |
bool | Recurse = false |
||
) | const |
Returns the children of this window.
Chld | The array to which the children of this window are appended. Note that Chld gets not initially cleared by this function! |
Recurse | Determines if also the grand-children, grand-grand-children etc. are returned. |
IntrusivePtrT< ComponentBaseT > WindowT::GetComponent | ( | const std::string & | TypeName, |
unsigned int | n = 0 |
||
) | const |
Returns the (n-th) component of the given (type) name.
Covers the "custom" components as well as the application components, "Basics" and "Transform". That is, GetComponent("Basics") == GetBasics()
and GetComponent("Transform") == GetTransform()
.
|
inline |
Returns the components that this window is composed of.
Only the "custom" components are returned, does not include the application component, "Basics" or "Transform".
|
inline |
Returns the parent window of this window.
IntrusivePtrT< WindowT > WindowT::GetRoot | ( | ) |
Returns the top-most parent of this window, that is, the root of the hierarchy this window is in.
|
inline |
Returns the "Transform" component of this window.
The "Transform" component defines the position, size and orientation of the window.
|
virtual |
The clock-tick event handler.
t | The time in seconds since the last clock-tick. |
|
virtual |
Keyboard input event handler.
KE | Keyboard event. |
|
virtual |
Mouse input event handler.
ME | Mouse event. |
PosX | Mouse position x. |
PosY | Mouse position y. |
bool WindowT::RemoveChild | ( | IntrusivePtrT< WindowT > | Child | ) |
Removes the given window from the children of this window.
Child | The window to remove from the children of this window. |
|
virtual |
Renders this window.
Note that this method does not setup any of the MatSys's model, view or projection matrices: it's up to the caller to do that!
void WindowT::SetApp | ( | IntrusivePtrT< ComponentBaseT > | App | ) |
Sets the application component for this window. See GetApp() for details.
|
staticprotected |
|
staticprotected |
|
staticprotected |
List of methods registered with Lua.