Nirtcpp 2.1.0
Nirtcpp is a high-performance c++ graphics engine.
Loading...
Searching...
No Matches
IGUIElement.hpp
1// Copyright (C) 2002-2012 Nikolaus Gebhardt
2// This file is part of the "Irrlicht Engine".
3// For conditions of distribution and use, see copyright notice in nirtcpp/nirtcpp.hpp
4
5#ifndef NIRT_I_GUI_ELEMENT_HPP_INCLUDED
6#define NIRT_I_GUI_ELEMENT_HPP_INCLUDED
7
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>
17
18namespace nirt
19{
20namespace gui
21{
24{
25public:
26
29 s32 id, const core::rect<s32>& rectangle)
30 : Parent(0), RelativeRect(rectangle), AbsoluteRect(rectangle),
31 AbsoluteClippingRect(rectangle), DesiredRect(rectangle),
32 MaxSize(0,0), MinSize(1,1), IsVisible(true), IsEnabled(true),
33 IsSubElement(false), NoClip(false), ID(id), IsTabStop(false), TabOrder(-1), IsTabGroup(false),
34 AlignLeft(EGUIA_UPPERLEFT), AlignRight(EGUIA_UPPERLEFT), AlignTop(EGUIA_UPPERLEFT), AlignBottom(EGUIA_UPPERLEFT),
35 Environment(environment), Type(type)
36 {
37 #ifdef _DEBUG
38 setDebugName("IGUIElement");
39 #endif
40
41 // if we were given a parent to attach to
42 if (parent)
43 {
44 parent->addChildToEnd(this);
45 recalculateAbsolutePosition(true);
46 }
47 }
48
49
51 virtual ~IGUIElement()
52 {
53 // delete all children
55 for (; it != Children.end(); ++it)
56 {
57 (*it)->Parent = 0;
58 (*it)->drop();
59 }
60 }
61
62
65 {
66 return Parent;
67 }
68
71 {
72 return RelativeRect;
73 }
74
75
77
79 {
80 if (Parent)
81 {
83
84 const core::dimension2df d((f32)(r2.getSize().Width), (f32)(r2.getSize().Height));
85
87 ScaleRect.UpperLeftCorner.X = (f32)r.UpperLeftCorner.X / d.Width;
88 if (AlignRight == EGUIA_SCALE)
89 ScaleRect.LowerRightCorner.X = (f32)r.LowerRightCorner.X / d.Width;
90 if (AlignTop == EGUIA_SCALE)
91 ScaleRect.UpperLeftCorner.Y = (f32)r.UpperLeftCorner.Y / d.Height;
92 if (AlignBottom == EGUIA_SCALE)
93 ScaleRect.LowerRightCorner.Y = (f32)r.LowerRightCorner.Y / d.Height;
94 }
95
96 DesiredRect = r;
98 }
99
101
103 {
104 const core::dimension2di mySize = RelativeRect.getSize();
105 const core::rect<s32> rectangle(position.X, position.Y,
106 position.X + mySize.Width, position.Y + mySize.Height);
107 setRelativePosition(rectangle);
108 }
109
110
112
117 {
118 if (!Parent)
119 return;
120
122
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));
128
129 ScaleRect = r;
130
132 }
133
134
137 {
138 return AbsoluteRect;
139 }
140
141
147
148
150
151 void setNotClipped(bool noClip)
152 {
153 NoClip = noClip;
155 }
156
157
159
160 bool isNotClipped() const
161 {
162 return NoClip;
163 }
164
165
167
169 {
170 MaxSize = size;
172 }
173
174
177 {
178 MinSize = size;
179 if (MinSize.Width < 1)
180 MinSize.Width = 1;
181 if (MinSize.Height < 1)
182 MinSize.Height = 1;
184 }
185
186
189 {
190 AlignLeft = left;
191 AlignRight = right;
192 AlignTop = top;
193 AlignBottom = bottom;
194
195 if (Parent)
196 {
198 const core::dimension2df d((f32)r.getSize().Width, (f32)r.getSize().Height);
199
200 if (AlignLeft == EGUIA_SCALE)
202 if (AlignRight == EGUIA_SCALE)
204 if (AlignTop == EGUIA_SCALE)
206 if (AlignBottom == EGUIA_SCALE)
208 }
209 }
210
213 {
214 return AlignLeft;
215 }
216
219 {
220 return AlignRight;
221 }
222
225 {
226 return AlignTop;
227 }
228
231 {
232 return AlignBottom;
233 }
234
237 {
238 recalculateAbsolutePosition(false);
239
240 // update all children
242 for (; it != Children.end(); ++it)
243 {
244 (*it)->updateAbsolutePosition();
245 }
246 }
247
248
250
262 {
263 IGUIElement* target = 0;
264
265 // we have to search from back to front, because later children
266 // might be drawn over the top of earlier ones.
267
269
270 if (isVisible())
271 {
272 while(it != Children.end())
273 {
274 target = (*it)->getElementFromPoint(point);
275 if (target)
276 return target;
277
278 --it;
279 }
280 }
281
282 if (isVisible() && isPointInside(point))
283 target = this;
284
285 return target;
286 }
287
288
290
291 virtual bool isPointInside(const core::position2d<s32>& point) const
292 {
294 }
295
296
298 virtual void addChild(IGUIElement* child)
299 {
300 if ( child && child != this )
301 {
302 addChildToEnd(child);
303 child->updateAbsolutePosition();
304 }
305 }
306
308 virtual void removeChild(IGUIElement* child)
309 {
311 for (; it != Children.end(); ++it)
312 if ((*it) == child)
313 {
314 (*it)->Parent = 0;
315 (*it)->drop();
316 Children.erase(it);
317 return;
318 }
319 }
320
321
323 virtual void remove()
324 {
325 if (Parent)
326 Parent->removeChild(this);
327 }
328
329
331 virtual void draw()
332 {
333 if ( isVisible() )
334 {
336 for (; it != Children.end(); ++it)
337 (*it)->draw();
338 }
339 }
340
341
343 virtual void OnPostRender(u32 timeMs)
344 {
345 if ( isVisible() )
346 {
348 for (; it != Children.end(); ++it)
349 (*it)->OnPostRender( timeMs );
350 }
351 }
352
353
355 virtual void move(core::position2d<s32> absoluteMovement)
356 {
357 setRelativePosition(DesiredRect + absoluteMovement);
358 }
359
360
362 virtual bool isVisible() const
363 {
364 return IsVisible;
365 }
366
368
370 virtual bool isTrulyVisible() const
371 {
372 if(!IsVisible)
373 return false;
374
375 if(!Parent)
376 return true;
377
378 return Parent->isTrulyVisible();
379 }
380
382 virtual void setVisible(bool visible)
383 {
384 IsVisible = visible;
385 }
386
387
389 virtual bool isSubElement() const
390 {
391 return IsSubElement;
392 }
393
394
396
398 virtual void setSubElement(bool subElement)
399 {
400 IsSubElement = subElement;
401 }
402
403
405
407 void setTabStop(bool enable)
408 {
409 IsTabStop = enable;
410 }
411
412
414 bool isTabStop() const
415 {
416 return IsTabStop;
417 }
418
419
421
423 void setTabOrder(s32 index)
424 {
425 // negative = autonumber
426 if (index < 0)
427 {
428 TabOrder = 0;
429 IGUIElement *el = getTabGroup();
430 while (IsTabGroup && el && el->Parent)
431 el = el->Parent;
432
433 IGUIElement *first=0, *closest=0;
434 if (el)
435 {
436 // find the highest element number
437 el->getNextElement(-1, true, IsTabGroup, first, closest, true, true);
438 if (first)
439 {
440 TabOrder = first->getTabOrder() + 1;
441 }
442 }
443
444 }
445 else
446 TabOrder = index;
447 }
448
449
452 {
453 return TabOrder;
454 }
455
456
458
460 void setTabGroup(bool isGroup)
461 {
462 IsTabGroup = isGroup;
463 }
464
465
467 bool isTabGroup() const
468 {
469 return IsTabGroup;
470 }
471
472
475 {
476 IGUIElement *ret=this;
477
478 while (ret && !ret->isTabGroup())
479 ret = ret->getParent();
480
481 return ret;
482 }
483
484
486
490 virtual bool isEnabled() const
491 {
492 if ( isSubElement() && IsEnabled && getParent() )
493 return getParent()->isEnabled();
494
495 return IsEnabled;
496 }
497
498
500 virtual void setEnabled(bool enabled)
501 {
502 IsEnabled = enabled;
503 }
504
505
507 virtual void setText(const wchar_t* text)
508 {
509 Text = text;
510 }
511
512
514 virtual const wchar_t* getText() const
515 {
516 return Text.data();
517 }
518
519
521 virtual void setToolTipText(const wchar_t* text)
522 {
523 ToolTipText = text;
524 }
525
526
528 virtual const core::stringw& getToolTipText() const
529 {
530 return ToolTipText;
531 }
532
533
535 virtual s32 getID() const
536 {
537 return ID;
538 }
539
540
542 virtual void setID(s32 id)
543 {
544 ID = id;
545 }
546
547
549 virtual bool OnEvent(const SEvent& event) override
550 {
551 return Parent ? Parent->OnEvent(event) : false;
552 }
553
554
556
557 virtual bool bringToFront(IGUIElement* element)
558 {
560 for (; it != Children.end(); ++it)
561 {
562 if (element == (*it))
563 {
564 Children.erase(it);
565 Children.push_back(element);
566 return true;
567 }
568 }
569
570 return false;
571 }
572
573
575
576 virtual bool sendToBack(IGUIElement* child)
577 {
579 if (child == (*it)) // already there
580 return true;
581 for (; it != Children.end(); ++it)
582 {
583 if (child == (*it))
584 {
585 Children.erase(it);
586 Children.push_front(child);
587 return true;
588 }
589 }
590
591 return false;
592 }
593
596 {
597 return Children;
598 }
599
600
602
608 virtual IGUIElement* getElementFromId(s32 id, bool searchchildren=false) const
609 {
610 IGUIElement* e = 0;
611
613 for (; it != Children.end(); ++it)
614 {
615 if ((*it)->getID() == id)
616 return (*it);
617
618 if (searchchildren)
619 e = (*it)->getElementFromId(id, true);
620
621 if (e)
622 return e;
623 }
624
625 return e;
626 }
627
628
631 bool isMyChild(IGUIElement* child) const
632 {
633 if (!child)
634 return false;
635 do
636 {
637 if (child->Parent)
638 child = child->Parent;
639
640 } while (child->Parent && child != this);
641
642
643 return child == this;
644 }
645
646
648
656 bool getNextElement(s32 startOrder, bool reverse, bool group,
657 IGUIElement*& first, IGUIElement*& closest, bool includeInvisible=false,
658 bool includeDisabled=false) const
659 {
660 // we'll stop searching if we find this number
661 s32 wanted = startOrder + ( reverse ? -1 : 1 );
662 if (wanted==-2)
663 wanted = 1073741824; // maximum s32
664
666
667 s32 closestOrder, currentOrder;
668
669 while(it != Children.end())
670 {
671 // ignore invisible elements and their children
672 if ( ( (*it)->isVisible() || includeInvisible ) &&
673 (group == true || (*it)->isTabGroup() == false) )
674 {
675 // ignore disabled, but children are checked (disabled is currently per element ignoring parent states)
676 if ( (*it)->isEnabled() || includeDisabled )
677 {
678 // only check tab stops and those with the same group status
679 if ((*it)->isTabStop() && ((*it)->isTabGroup() == group))
680 {
681 currentOrder = (*it)->getTabOrder();
682
683 // is this what we're looking for?
684 if (currentOrder == wanted)
685 {
686 closest = *it;
687 return true;
688 }
689
690 // is it closer than the current closest?
691 if (closest)
692 {
693 closestOrder = closest->getTabOrder();
694 if ( ( reverse && currentOrder > closestOrder && currentOrder < startOrder)
695 ||(!reverse && currentOrder < closestOrder && currentOrder > startOrder))
696 {
697 closest = *it;
698 }
699 }
700 else
701 if ( (reverse && currentOrder < startOrder) || (!reverse && currentOrder > startOrder) )
702 {
703 closest = *it;
704 }
705
706 // is it before the current first?
707 if (first)
708 {
709 closestOrder = first->getTabOrder();
710
711 if ( (reverse && closestOrder < currentOrder) || (!reverse && closestOrder > currentOrder) )
712 {
713 first = *it;
714 }
715 }
716 else
717 {
718 first = *it;
719 }
720 }
721 }
722 // search within children
723 if ((*it)->getNextElement(startOrder, reverse, group, first, closest, includeInvisible, includeDisabled))
724 {
725 return true;
726 }
727 }
728 ++it;
729 }
730 return false;
731 }
732
733
735
740 {
741 return Type;
742 }
743
745
753 virtual bool hasType(EGUI_ELEMENT_TYPE type) const
754 {
755 return type == Type;
756 }
757
758
760
762 virtual const c8* getTypeName() const
763 {
765 }
766
768
769 virtual const c8* getName() const
770 {
771 return Name.data();
772 }
773
774
776
777 virtual void setName(const c8* name)
778 {
779 Name = name;
780 }
781
782
784
785 virtual void setName(const core::stringc& name)
786 {
787 Name = name;
788 }
789
790
792
794 virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const override
795 {
796 out->addString("Name", Name.data());
797 out->addInt("Id", ID );
798 out->addString("Caption", getText());
799 out->addString("ToolTip", getToolTipText().data());
800 out->addRect("Rect", DesiredRect);
801 out->addPosition2d("MinSize", core::position2di(MinSize.Width, MinSize.Height));
803 out->addEnum("LeftAlign", AlignLeft, GUIAlignmentNames);
804 out->addEnum("RightAlign", AlignRight, GUIAlignmentNames);
805 out->addEnum("TopAlign", AlignTop, GUIAlignmentNames);
806 out->addEnum("BottomAlign", AlignBottom, GUIAlignmentNames);
807 out->addBool("Visible", IsVisible);
808 out->addBool("Enabled", IsEnabled);
809 out->addBool("TabStop", IsTabStop);
810 out->addBool("TabGroup", IsTabGroup);
811 out->addInt("TabOrder", TabOrder);
812 out->addBool("NoClip", NoClip);
813 }
814
815
817
820 {
821 setName(in->getAttributeAsString("Name", Name));
822 setID(in->getAttributeAsInt("Id", ID));
823 setText(in->getAttributeAsStringW("Caption", Text).data());
824 setToolTipText(in->getAttributeAsStringW("ToolTip").data());
825 setVisible(in->getAttributeAsBool("Visible", IsVisible));
826 setEnabled(in->getAttributeAsBool("Enabled", IsEnabled));
827 IsTabStop = in->getAttributeAsBool("TabStop", IsTabStop);
828 IsTabGroup = in->getAttributeAsBool("TabGroup", IsTabGroup);
829 TabOrder = in->getAttributeAsInt("TabOrder", TabOrder);
830
833
834 p = in->getAttributeAsPosition2d("MinSize", core::position2di(MinSize.Width, MinSize.Height));
836
838 (EGUI_ALIGNMENT)in->getAttributeAsEnumeration("RightAlign", GUIAlignmentNames, AlignRight),
840 (EGUI_ALIGNMENT)in->getAttributeAsEnumeration("BottomAlign", GUIAlignmentNames, AlignBottom));
841
843
845 }
846
847protected:
848 // not virtual because needed in constructor
849 void addChildToEnd(IGUIElement* child)
850 {
851 if (child)
852 {
853 child->grab(); // prevent destruction when removed
854 child->remove(); // remove from old parent
856 child->Parent = this;
857 Children.push_back(child);
858 }
859 }
860
861 // not virtual because needed in constructor
862 void recalculateAbsolutePosition(bool recursive)
863 {
864 core::rect<s32> parentAbsolute(0,0,0,0);
865 core::rect<s32> parentAbsoluteClip;
866 f32 fw=0.f, fh=0.f;
867
868 if (Parent)
869 {
870 parentAbsolute = Parent->AbsoluteRect;
871
872 if (NoClip)
873 {
874 IGUIElement* p=this;
875 while (p->Parent)
876 p = p->Parent;
877 parentAbsoluteClip = p->AbsoluteClippingRect;
878 }
879 else
880 parentAbsoluteClip = Parent->AbsoluteClippingRect;
881 }
882
883 const s32 diffx = parentAbsolute.getWidth() - LastParentRect.getWidth();
884 const s32 diffy = parentAbsolute.getHeight() - LastParentRect.getHeight();
885
886 if (AlignLeft == EGUIA_SCALE || AlignRight == EGUIA_SCALE)
887 fw = (f32)parentAbsolute.getWidth();
888
889 if (AlignTop == EGUIA_SCALE || AlignBottom == EGUIA_SCALE)
890 fh = (f32)parentAbsolute.getHeight();
891
892 switch (AlignLeft)
893 {
894 case EGUIA_UPPERLEFT:
895 break;
896 case EGUIA_LOWERRIGHT:
897 DesiredRect.UpperLeftCorner.X += diffx;
898 break;
899 case EGUIA_CENTER:
900 DesiredRect.UpperLeftCorner.X += diffx/2;
901 break;
902 case EGUIA_SCALE:
903 DesiredRect.UpperLeftCorner.X = core::round32(ScaleRect.UpperLeftCorner.X * fw);
904 break;
905 }
906
907 switch (AlignRight)
908 {
909 case EGUIA_UPPERLEFT:
910 break;
911 case EGUIA_LOWERRIGHT:
912 DesiredRect.LowerRightCorner.X += diffx;
913 break;
914 case EGUIA_CENTER:
915 DesiredRect.LowerRightCorner.X += diffx/2;
916 break;
917 case EGUIA_SCALE:
918 DesiredRect.LowerRightCorner.X = core::round32(ScaleRect.LowerRightCorner.X * fw);
919 break;
920 }
921
922 switch (AlignTop)
923 {
924 case EGUIA_UPPERLEFT:
925 break;
926 case EGUIA_LOWERRIGHT:
927 DesiredRect.UpperLeftCorner.Y += diffy;
928 break;
929 case EGUIA_CENTER:
930 DesiredRect.UpperLeftCorner.Y += diffy/2;
931 break;
932 case EGUIA_SCALE:
933 DesiredRect.UpperLeftCorner.Y = core::round32(ScaleRect.UpperLeftCorner.Y * fh);
934 break;
935 }
936
937 switch (AlignBottom)
938 {
939 case EGUIA_UPPERLEFT:
940 break;
941 case EGUIA_LOWERRIGHT:
942 DesiredRect.LowerRightCorner.Y += diffy;
943 break;
944 case EGUIA_CENTER:
945 DesiredRect.LowerRightCorner.Y += diffy/2;
946 break;
947 case EGUIA_SCALE:
948 DesiredRect.LowerRightCorner.Y = core::round32(ScaleRect.LowerRightCorner.Y * fh);
949 break;
950 }
951
953
954 const s32 w = RelativeRect.getWidth();
955 const s32 h = RelativeRect.getHeight();
956
957 // make sure the desired rectangle is allowed
958 if (w < (s32)MinSize.Width)
960 if (h < (s32)MinSize.Height)
962 if (MaxSize.Width && w > (s32)MaxSize.Width)
964 if (MaxSize.Height && h > (s32)MaxSize.Height)
966
968
969 AbsoluteRect = RelativeRect + parentAbsolute.UpperLeftCorner;
970
971 if (!Parent)
972 parentAbsoluteClip = AbsoluteRect;
973
975 AbsoluteClippingRect.clipAgainst(parentAbsoluteClip);
976
977 LastParentRect = parentAbsolute;
978
979 if ( recursive )
980 {
981 // update all children
982 core::list<IGUIElement*>::Iterator it = Children.begin();
983 for (; it != Children.end(); ++it)
984 {
985 (*it)->recalculateAbsolutePosition(recursive);
986 }
987 }
988 }
989
990protected:
991
994
997
1000
1003
1006
1010
1013
1016
1019
1022
1025
1028
1031
1034
1037
1040
1043
1046
1049
1052
1054 EGUI_ALIGNMENT AlignLeft, AlignRight, AlignTop, AlignBottom;
1055
1058
1061};
1062
1063
1064} // end namespace gui
1065} // end namespace nirt
1066
1067#endif
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

Nirtcpp    @cppfx.xyz

Esvcpp    esv::print