5#ifndef NIRT_I_GUI_ELEMENT_HPP_INCLUDED
6#define NIRT_I_GUI_ELEMENT_HPP_INCLUDED
8#include <nirtcpp/core/engine/IAttributeExchangingObject.hpp>
9#include <nirtcpp/core/engine/irrList.hpp>
10#include <nirtcpp/core/engine/rect.hpp>
11#include <nirtcpp/core/engine/irrString.hpp>
12#include <nirtcpp/core/engine/IEventReceiver.hpp>
13#include <nirtcpp/core/engine/EGUIElementTypes.hpp>
14#include <nirtcpp/core/engine/EGUIAlignment.hpp>
15#include <nirtcpp/core/engine/IAttributes.hpp>
16#include <nirtcpp/core/engine/IGUIEnvironment.hpp>
44 parent->addChildToEnd(
this);
45 recalculateAbsolutePosition(
true);
106 position.X + mySize.Width, position.Y + mySize.Height);
124 core::floor32((
f32)d.Width * r.UpperLeftCorner.X),
125 core::floor32((
f32)d.Height * r.UpperLeftCorner.Y),
126 core::floor32((
f32)d.Width * r.LowerRightCorner.X),
127 core::floor32((
f32)d.Height * r.LowerRightCorner.Y));
179 if (MinSize.
Width < 1)
193 AlignBottom = bottom;
238 recalculateAbsolutePosition(
false);
244 (*it)->updateAbsolutePosition();
300 if ( child && child !=
this )
302 addChildToEnd(child);
349 (*it)->OnPostRender( timeMs );
562 if (element == (*it))
615 if ((*it)->getID() ==
id)
640 }
while (child->
Parent && child !=
this);
643 return child ==
this;
658 bool includeDisabled=
false)
const
661 s32 wanted = startOrder + ( reverse ? -1 : 1 );
667 s32 closestOrder, currentOrder;
672 if ( ( (*it)->isVisible() || includeInvisible ) &&
673 (group ==
true || (*it)->isTabGroup() ==
false) )
676 if ( (*it)->isEnabled() || includeDisabled )
679 if ((*it)->isTabStop() && ((*it)->isTabGroup() == group))
681 currentOrder = (*it)->getTabOrder();
684 if (currentOrder == wanted)
694 if ( ( reverse && currentOrder > closestOrder && currentOrder < startOrder)
695 ||(!reverse && currentOrder < closestOrder && currentOrder > startOrder))
701 if ( (reverse && currentOrder < startOrder) || (!reverse && currentOrder > startOrder) )
711 if ( (reverse && closestOrder < currentOrder) || (!reverse && closestOrder > currentOrder) )
723 if ((*it)->getNextElement(startOrder, reverse, group, first, closest, includeInvisible, includeDisabled))
862 void recalculateAbsolutePosition(
bool recursive)
864 core::rect<s32> parentAbsolute(0,0,0,0);
865 core::rect<s32> parentAbsoluteClip;
877 parentAbsoluteClip = p->AbsoluteClippingRect;
887 fw = (
f32)parentAbsolute.getWidth();
890 fh = (
f32)parentAbsolute.getHeight();
982 core::list<IGUIElement*>::Iterator it =
Children.begin();
985 (*it)->recalculateAbsolutePosition(recursive);
Interface of an object which can receive events.
Definition IEventReceiver.hpp:484
void setDebugName(const c8 *newName)
Sets the debug name of the object.
Definition IReferenceCounted.hpp:163
void grab() const
Grabs the object. Increments the reference counter by one.
Definition IReferenceCounted.hpp:96
SEvents hold information about an event. See nirt::IEventReceiver for details on event handling.
Definition IEventReceiver.hpp:282
Axis aligned bounding box in 3d dimensional space.
Definition aabbox3d.hpp:22
T Height
Height of the dimension.
Definition dimension2d.hpp:206
T Width
Width of the dimension.
Definition dimension2d.hpp:204
List iterator for const access.
Definition irrList.hpp:85
List iterator.
Definition irrList.hpp:40
T getWidth() const
Get width of rectangle.
Definition rect.hpp:193
dimension2d< T > getSize() const
Get the dimensions of the rectangle.
Definition rect.hpp:240
T getHeight() const
Get height of rectangle.
Definition rect.hpp:199
void clipAgainst(const rect< T > &other)
Clips this rectangle with another one.
Definition rect.hpp:131
position2d< T > LowerRightCorner
Lower right corner.
Definition rect.hpp:276
void repair()
If the lower right corner of the rect is smaller then the upper left, the points are swapped.
Definition rect.hpp:205
position2d< T > UpperLeftCorner
Upper left corner.
Definition rect.hpp:274
bool isPointInside(const position2d< T > &pos) const
Returns if a 2d point is within this rectangle.
Definition rect.hpp:110
Very simple string class with some useful features.
Definition irrString.hpp:94
const T * data() const
Returns character string.
Definition irrString.hpp:525
Base class of all GUI elements.
Definition IGUIElement.hpp:24
void setMinSize(core::dimension2du size)
Sets the minimum size allowed for this element.
Definition IGUIElement.hpp:176
bool IsTabStop
tab stop like in windows
Definition IGUIElement.hpp:1045
virtual void removeChild(IGUIElement *child)
Removes a child.
Definition IGUIElement.hpp:308
virtual void move(core::position2d< s32 > absoluteMovement)
Moves this element.
Definition IGUIElement.hpp:355
virtual bool OnEvent(const SEvent &event) override
Called if an event happened.
Definition IGUIElement.hpp:549
virtual void updateAbsolutePosition()
Updates the absolute position.
Definition IGUIElement.hpp:236
bool IsVisible
is visible?
Definition IGUIElement.hpp:1021
EGUI_ALIGNMENT getAlignLeft() const
How left element border is aligned when parent is resized.
Definition IGUIElement.hpp:212
void setRelativePosition(const core::position2di &position)
Sets the relative rectangle of this element, maintaining its current width and height.
Definition IGUIElement.hpp:102
IGUIEnvironment * Environment
GUI Environment.
Definition IGUIElement.hpp:1057
bool isNotClipped() const
Gets whether the element will ignore its parent's clipping rectangle.
Definition IGUIElement.hpp:160
void setRelativePosition(const core::rect< s32 > &r)
Sets the relative rectangle of this element.
Definition IGUIElement.hpp:78
virtual bool isEnabled() const
Returns true if element is enabled.
Definition IGUIElement.hpp:490
void setTabGroup(bool isGroup)
Sets whether this element is a container for a group of elements which can be navigated using the tab...
Definition IGUIElement.hpp:460
virtual bool isPointInside(const core::position2d< s32 > &point) const
Returns true if a point is within this element.
Definition IGUIElement.hpp:291
bool IsSubElement
is a part of a larger whole and should not be serialized?
Definition IGUIElement.hpp:1027
virtual ~IGUIElement()
Destructor.
Definition IGUIElement.hpp:51
virtual void setText(const wchar_t *text)
Sets the new caption of this element.
Definition IGUIElement.hpp:507
s32 TabOrder
tab order
Definition IGUIElement.hpp:1048
s32 ID
users can set this for identifying the element by integer
Definition IGUIElement.hpp:1042
virtual bool bringToFront(IGUIElement *element)
Brings a child to front.
Definition IGUIElement.hpp:557
bool isMyChild(IGUIElement *child) const
Definition IGUIElement.hpp:631
core::rect< s32 > LastParentRect
for calculating the difference when resizing parent
Definition IGUIElement.hpp:1012
void setMaxSize(core::dimension2du size)
Sets the maximum size allowed for this element.
Definition IGUIElement.hpp:168
virtual void setSubElement(bool subElement)
Sets whether this control was created as part of its parent.
Definition IGUIElement.hpp:398
virtual void draw()
Draws the element and its children.
Definition IGUIElement.hpp:331
bool IsTabGroup
tab groups are containers like windows, use ctrl+tab to navigate
Definition IGUIElement.hpp:1051
virtual IGUIElement * getElementFromPoint(const core::position2d< s32 > &point)
Returns the topmost GUI element at the specific position.
Definition IGUIElement.hpp:261
core::rect< s32 > AbsoluteClippingRect
absolute clipping rect of element
Definition IGUIElement.hpp:1005
virtual bool isSubElement() const
Returns true if this element was created as part of its parent control.
Definition IGUIElement.hpp:389
virtual const core::stringw & getToolTipText() const
Returns caption of this element.
Definition IGUIElement.hpp:528
virtual void setName(const core::stringc &name)
Sets the name of the element.
Definition IGUIElement.hpp:785
void setAlignment(EGUI_ALIGNMENT left, EGUI_ALIGNMENT right, EGUI_ALIGNMENT top, EGUI_ALIGNMENT bottom)
The alignment defines how the borders of this element will be positioned when the parent element is r...
Definition IGUIElement.hpp:188
core::stringw ToolTipText
tooltip
Definition IGUIElement.hpp:1036
virtual const c8 * getTypeName() const
Returns the type name of the gui element.
Definition IGUIElement.hpp:762
bool IsEnabled
is enabled?
Definition IGUIElement.hpp:1024
virtual void setToolTipText(const wchar_t *text)
Sets the new caption of this element.
Definition IGUIElement.hpp:521
EGUI_ALIGNMENT AlignLeft
tells the element how to act when its parent is resized
Definition IGUIElement.hpp:1054
virtual bool isVisible() const
Returns true if element is visible.
Definition IGUIElement.hpp:362
IGUIElement * Parent
Pointer to the parent.
Definition IGUIElement.hpp:996
virtual void remove()
Removes this element from its parent.
Definition IGUIElement.hpp:323
core::rect< s32 > getAbsolutePosition() const
Gets the absolute rectangle of this element.
Definition IGUIElement.hpp:136
virtual void setEnabled(bool enabled)
Sets the enabled state of this element.
Definition IGUIElement.hpp:500
EGUI_ALIGNMENT getAlignBottom() const
How bottom element border is aligned when parent is resized.
Definition IGUIElement.hpp:230
core::dimension2du MaxSize
maximum and minimum size of the element
Definition IGUIElement.hpp:1018
bool isTabGroup() const
Returns true if this element is a tab group.
Definition IGUIElement.hpp:467
EGUI_ALIGNMENT getAlignRight() const
How right element border is aligned when parent is resized.
Definition IGUIElement.hpp:218
virtual bool hasType(EGUI_ELEMENT_TYPE type) const
Returns true if the gui element supports the given type.
Definition IGUIElement.hpp:753
virtual const wchar_t * getText() const
Returns caption of this element.
Definition IGUIElement.hpp:514
bool NoClip
does this element ignore its parent's clipping rectangle?
Definition IGUIElement.hpp:1030
IGUIElement * getTabGroup()
Returns the container element which holds all elements in this element's tab group.
Definition IGUIElement.hpp:474
s32 getTabOrder() const
Returns the number in the tab order sequence.
Definition IGUIElement.hpp:451
EGUI_ELEMENT_TYPE Type
type of element
Definition IGUIElement.hpp:1060
IGUIElement * getParent() const
Returns parent of this element.
Definition IGUIElement.hpp:64
virtual void serializeAttributes(io::IAttributes *out, io::SAttributeReadWriteOptions *options=0) const override
Writes attributes of the scene node.
Definition IGUIElement.hpp:794
void setTabOrder(s32 index)
Sets the priority of focus when using the tab key to navigate between a group of elements.
Definition IGUIElement.hpp:423
core::rect< s32 > getRelativePosition() const
Returns the relative rectangle of this element.
Definition IGUIElement.hpp:70
core::stringc Name
users can set this for identifying the element by string
Definition IGUIElement.hpp:1039
core::rect< f32 > ScaleRect
relative scale of the element inside its parent
Definition IGUIElement.hpp:1015
void setNotClipped(bool noClip)
Sets whether the element will ignore its parent's clipping rectangle.
Definition IGUIElement.hpp:151
virtual s32 getID() const
Returns id. Can be used to identify the element.
Definition IGUIElement.hpp:535
virtual void addChild(IGUIElement *child)
Adds a GUI element as new child of this element.
Definition IGUIElement.hpp:298
virtual void OnPostRender(u32 timeMs)
animate the element and its children.
Definition IGUIElement.hpp:343
virtual const c8 * getName() const
Returns the name of the element.
Definition IGUIElement.hpp:769
core::rect< s32 > getAbsoluteClippingRect() const
Returns the visible area of the element.
Definition IGUIElement.hpp:143
core::rect< s32 > DesiredRect
Definition IGUIElement.hpp:1009
core::rect< s32 > AbsoluteRect
absolute rect of element
Definition IGUIElement.hpp:1002
bool getNextElement(s32 startOrder, bool reverse, bool group, IGUIElement *&first, IGUIElement *&closest, bool includeInvisible=false, bool includeDisabled=false) const
searches elements to find the closest next element to tab to
Definition IGUIElement.hpp:656
IGUIElement(EGUI_ELEMENT_TYPE type, IGUIEnvironment *environment, IGUIElement *parent, s32 id, const core::rect< s32 > &rectangle)
Constructor.
Definition IGUIElement.hpp:28
virtual bool sendToBack(IGUIElement *child)
Moves a child to the back, so it's siblings are drawn on top of it.
Definition IGUIElement.hpp:576
EGUI_ELEMENT_TYPE getType() const
Returns the type of the gui element.
Definition IGUIElement.hpp:739
void setTabStop(bool enable)
If set to true, the focus will visit this element when using the tab key to cycle through elements.
Definition IGUIElement.hpp:407
void setRelativePositionProportional(const core::rect< f32 > &r)
Sets the relative rectangle of this element as a proportion of its parent's area.
Definition IGUIElement.hpp:116
core::list< IGUIElement * > Children
List of all children of this element.
Definition IGUIElement.hpp:993
virtual bool isTrulyVisible() const
Check whether the element is truly visible, taking into accounts its parents' visibility.
Definition IGUIElement.hpp:370
EGUI_ALIGNMENT getAlignTop() const
How top element border is aligned when parent is resized.
Definition IGUIElement.hpp:224
core::stringw Text
caption
Definition IGUIElement.hpp:1033
virtual IGUIElement * getElementFromId(s32 id, bool searchchildren=false) const
Finds the first element with the given id.
Definition IGUIElement.hpp:608
virtual void setVisible(bool visible)
Sets the visible state of this element.
Definition IGUIElement.hpp:382
bool isTabStop() const
Returns true if this element can be focused by navigating with the tab key.
Definition IGUIElement.hpp:414
virtual const core::list< IGUIElement * > & getChildren() const
Returns list with children of this element.
Definition IGUIElement.hpp:595
virtual void setID(s32 id)
Sets the id of this element.
Definition IGUIElement.hpp:542
core::rect< s32 > RelativeRect
relative rect of element
Definition IGUIElement.hpp:999
virtual void deserializeAttributes(io::IAttributes *in, io::SAttributeReadWriteOptions *options=0) override
Reads attributes of the scene node.
Definition IGUIElement.hpp:819
virtual void setName(const c8 *name)
Sets the name of the element.
Definition IGUIElement.hpp:777
GUI Environment. Used as factory and manager of all other GUI elements.
Definition IGUIEnvironment.hpp:73
An object which is able to serialize and deserialize its attributes into an attributes object.
Definition IAttributeExchangingObject.hpp:54
Provides a generic interface for attributes and their values and the possibility to serialize them.
Definition IAttributes.hpp:42
virtual core::stringw getAttributeAsStringW(const c8 *attributeName, const core::stringw &defaultNotFound=core::stringw()) const =0
virtual void addPosition2d(const c8 *attributeName, const core::position2di &value)=0
Adds an attribute as 2d position.
virtual s32 getAttributeAsInt(const c8 *attributeName, nirt::s32 defaultNotFound=0) const =0
virtual void addString(const c8 *attributeName, const c8 *value)=0
Adds an attribute as string.
virtual bool getAttributeAsBool(const c8 *attributeName, bool defaultNotFound=false) const =0
virtual core::rect< s32 > getAttributeAsRect(const c8 *attributeName, const core::rect< s32 > &defaultNotFound=core::rect< s32 >()) const =0
virtual core::position2di getAttributeAsPosition2d(const c8 *attributeName, const core::position2di &defaultNotFound=core::position2di(0, 0)) const =0
virtual void addEnum(const c8 *attributeName, const c8 *enumValue, const c8 *const *enumerationLiterals)=0
Adds an attribute as enum.
virtual core::stringc getAttributeAsString(const c8 *attributeName, const core::stringc &defaultNotFound=core::stringc()) const =0
virtual void addBool(const c8 *attributeName, bool value)=0
Adds an attribute as bool.
virtual void addRect(const c8 *attributeName, const core::rect< s32 > &value)=0
Adds an attribute as rectangle.
virtual const c8 * getAttributeAsEnumeration(const c8 *attributeName, const c8 *defaultNotFound=0) const =0
virtual void addInt(const c8 *attributeName, s32 value)=0
Adds an attribute as integer.
class holding data describing options
Definition IAttributeExchangingObject.hpp:35
EGUI_ELEMENT_TYPE
List of all basic Nirtcpp GUI elements.
Definition EGUIElementTypes.hpp:18
EGUI_ALIGNMENT
Definition EGUIAlignment.hpp:15
@ EGUIA_SCALE
Stretched to fit parent.
Definition EGUIAlignment.hpp:23
@ EGUIA_UPPERLEFT
Aligned to parent's top or left side (default)
Definition EGUIAlignment.hpp:17
@ EGUIA_LOWERRIGHT
Aligned to parent's bottom or right side.
Definition EGUIAlignment.hpp:19
@ EGUIA_CENTER
Aligned to the center of parent.
Definition EGUIAlignment.hpp:21
const c8 *const GUIElementTypeNames[]
Names for built-in element types.
Definition EGUIElementTypes.hpp:106
const c8 *const GUIAlignmentNames[]
Names for alignments.
Definition EGUIAlignment.hpp:27
As of Nirtcpp 1.6, position2d is a synonym for vector2d.
Definition vector3d.hpp:11
signed int s32
32 bit signed variable.
Definition irrTypes.hpp:72
unsigned int u32
32 bit unsigned variable.
Definition irrTypes.hpp:64
char c8
8 bit character variable.
Definition irrTypes.hpp:37
float f32
32 bit floating point variable.
Definition irrTypes.hpp:110