Irrlicht 3D Engine
IGUIElement.h
Go to the documentation of this file.
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 irrlicht.h
4 
5 #ifndef __I_GUI_ELEMENT_H_INCLUDED__
6 #define __I_GUI_ELEMENT_H_INCLUDED__
7 
9 #include "irrList.h"
10 #include "rect.h"
11 #include "irrString.h"
12 #include "IEventReceiver.h"
13 #include "EGUIElementTypes.h"
14 #include "EGUIAlignment.h"
15 #include "IAttributes.h"
16 #include "IGUIEnvironment.h"
17 
18 namespace irr
19 {
20 namespace gui
21 {
24 {
25 public:
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),
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);
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  core::dimension2df d((f32)(r2.getSize().Width), (f32)(r2.getSize().Height));
85 
86  if (AlignLeft == EGUIA_SCALE)
88  if (AlignRight == EGUIA_SCALE)
90  if (AlignTop == EGUIA_SCALE)
92  if (AlignBottom == EGUIA_SCALE)
94  }
95 
96  DesiredRect = r;
98  }
99 
101 
102  void setRelativePosition(const core::position2di & position)
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 
128 
129  ScaleRect = r;
130 
132  }
133 
134 
137  {
138  return AbsoluteRect;
139  }
140 
141 
144  {
145  return AbsoluteClippingRect;
146  }
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 
199  core::dimension2df d((f32)r.getSize().Width, (f32)r.getSize().Height);
200 
201  if (AlignLeft == EGUIA_SCALE)
203  if (AlignRight == EGUIA_SCALE)
205  if (AlignTop == EGUIA_SCALE)
207  if (AlignBottom == EGUIA_SCALE)
209  }
210  }
211 
212 
214  virtual void updateAbsolutePosition()
215  {
217 
218  // update all children
220  for (; it != Children.end(); ++it)
221  {
222  (*it)->updateAbsolutePosition();
223  }
224  }
225 
226 
228 
239  virtual IGUIElement* getElementFromPoint(const core::position2d<s32>& point)
240  {
241  IGUIElement* target = 0;
242 
243  // we have to search from back to front, because later children
244  // might be drawn over the top of earlier ones.
245 
247 
248  if (isVisible())
249  {
250  while(it != Children.end())
251  {
252  target = (*it)->getElementFromPoint(point);
253  if (target)
254  return target;
255 
256  --it;
257  }
258  }
259 
260  if (isVisible() && isPointInside(point))
261  target = this;
262 
263  return target;
264  }
265 
266 
268 
269  virtual bool isPointInside(const core::position2d<s32>& point) const
270  {
271  return AbsoluteClippingRect.isPointInside(point);
272  }
273 
274 
276  virtual void addChild(IGUIElement* child)
277  {
278  if ( child && child != this )
279  {
280  addChildToEnd(child);
281  child->updateAbsolutePosition();
282  }
283  }
284 
286  virtual void removeChild(IGUIElement* child)
287  {
289  for (; it != Children.end(); ++it)
290  if ((*it) == child)
291  {
292  (*it)->Parent = 0;
293  (*it)->drop();
294  Children.erase(it);
295  return;
296  }
297  }
298 
299 
301  virtual void remove()
302  {
303  if (Parent)
304  Parent->removeChild(this);
305  }
306 
307 
309  virtual void draw()
310  {
311  if ( isVisible() )
312  {
314  for (; it != Children.end(); ++it)
315  (*it)->draw();
316  }
317  }
318 
319 
321  virtual void OnPostRender(u32 timeMs)
322  {
323  if ( isVisible() )
324  {
326  for (; it != Children.end(); ++it)
327  (*it)->OnPostRender( timeMs );
328  }
329  }
330 
331 
333  virtual void move(core::position2d<s32> absoluteMovement)
334  {
335  setRelativePosition(DesiredRect + absoluteMovement);
336  }
337 
338 
340  virtual bool isVisible() const
341  {
342  return IsVisible;
343  }
344 
346 
348  virtual bool isTrulyVisible() const
349  {
350  if(!IsVisible)
351  return false;
352 
353  if(!Parent)
354  return true;
355 
356  return Parent->isTrulyVisible();
357  }
358 
360  virtual void setVisible(bool visible)
361  {
362  IsVisible = visible;
363  }
364 
365 
367  virtual bool isSubElement() const
368  {
369  return IsSubElement;
370  }
371 
372 
374 
376  virtual void setSubElement(bool subElement)
377  {
378  IsSubElement = subElement;
379  }
380 
381 
383 
385  void setTabStop(bool enable)
386  {
387  IsTabStop = enable;
388  }
389 
390 
392  bool isTabStop() const
393  {
394  return IsTabStop;
395  }
396 
397 
399 
401  void setTabOrder(s32 index)
402  {
403  // negative = autonumber
404  if (index < 0)
405  {
406  TabOrder = 0;
407  IGUIElement *el = getTabGroup();
408  while (IsTabGroup && el && el->Parent)
409  el = el->Parent;
410 
411  IGUIElement *first=0, *closest=0;
412  if (el)
413  {
414  // find the highest element number
415  el->getNextElement(-1, true, IsTabGroup, first, closest, true);
416  if (first)
417  {
418  TabOrder = first->getTabOrder() + 1;
419  }
420  }
421 
422  }
423  else
424  TabOrder = index;
425  }
426 
427 
429  s32 getTabOrder() const
430  {
431  return TabOrder;
432  }
433 
434 
436 
438  void setTabGroup(bool isGroup)
439  {
440  IsTabGroup = isGroup;
441  }
442 
443 
445  bool isTabGroup() const
446  {
447  return IsTabGroup;
448  }
449 
450 
453  {
454  IGUIElement *ret=this;
455 
456  while (ret && !ret->isTabGroup())
457  ret = ret->getParent();
458 
459  return ret;
460  }
461 
462 
464 
468  virtual bool isEnabled() const
469  {
470  if ( isSubElement() && IsEnabled && getParent() )
471  return getParent()->isEnabled();
472 
473  return IsEnabled;
474  }
475 
476 
478  virtual void setEnabled(bool enabled)
479  {
480  IsEnabled = enabled;
481  }
482 
483 
485  virtual void setText(const wchar_t* text)
486  {
487  Text = text;
488  }
489 
490 
492  virtual const wchar_t* getText() const
493  {
494  return Text.c_str();
495  }
496 
497 
499  virtual void setToolTipText(const wchar_t* text)
500  {
501  ToolTipText = text;
502  }
503 
504 
506  virtual const core::stringw& getToolTipText() const
507  {
508  return ToolTipText;
509  }
510 
511 
513  virtual s32 getID() const
514  {
515  return ID;
516  }
517 
518 
520  virtual void setID(s32 id)
521  {
522  ID = id;
523  }
524 
525 
527  virtual bool OnEvent(const SEvent& event)
528  {
529  return Parent ? Parent->OnEvent(event) : false;
530  }
531 
532 
534 
535  virtual bool bringToFront(IGUIElement* element)
536  {
538  for (; it != Children.end(); ++it)
539  {
540  if (element == (*it))
541  {
542  Children.erase(it);
543  Children.push_back(element);
544  return true;
545  }
546  }
547 
548  return false;
549  }
550 
551 
553 
554  virtual bool sendToBack(IGUIElement* child)
555  {
557  if (child == (*it)) // already there
558  return true;
559  for (; it != Children.end(); ++it)
560  {
561  if (child == (*it))
562  {
563  Children.erase(it);
564  Children.push_front(child);
565  return true;
566  }
567  }
568 
569  return false;
570  }
571 
573  virtual const core::list<IGUIElement*>& getChildren() const
574  {
575  return Children;
576  }
577 
578 
580 
586  virtual IGUIElement* getElementFromId(s32 id, bool searchchildren=false) const
587  {
588  IGUIElement* e = 0;
589 
591  for (; it != Children.end(); ++it)
592  {
593  if ((*it)->getID() == id)
594  return (*it);
595 
596  if (searchchildren)
597  e = (*it)->getElementFromId(id, true);
598 
599  if (e)
600  return e;
601  }
602 
603  return e;
604  }
605 
606 
609  bool isMyChild(IGUIElement* child) const
610  {
611  if (!child)
612  return false;
613  do
614  {
615  if (child->Parent)
616  child = child->Parent;
617 
618  } while (child->Parent && child != this);
619 
620 
621  return child == this;
622  }
623 
624 
626 
634  bool getNextElement(s32 startOrder, bool reverse, bool group,
635  IGUIElement*& first, IGUIElement*& closest, bool includeInvisible=false,
636  bool includeDisabled=false) const
637  {
638  // we'll stop searching if we find this number
639  s32 wanted = startOrder + ( reverse ? -1 : 1 );
640  if (wanted==-2)
641  wanted = 1073741824; // maximum s32
642 
644 
645  s32 closestOrder, currentOrder;
646 
647  while(it != Children.end())
648  {
649  // ignore invisible elements and their children
650  if ( ( (*it)->isVisible() || includeInvisible ) &&
651  (group == true || (*it)->isTabGroup() == false) )
652  {
653  // ignore disabled, but children are checked (disabled is currently per element ignoring parent states)
654  if ( (*it)->isEnabled() || includeDisabled )
655  {
656  // only check tab stops and those with the same group status
657  if ((*it)->isTabStop() && ((*it)->isTabGroup() == group))
658  {
659  currentOrder = (*it)->getTabOrder();
660 
661  // is this what we're looking for?
662  if (currentOrder == wanted)
663  {
664  closest = *it;
665  return true;
666  }
667 
668  // is it closer than the current closest?
669  if (closest)
670  {
671  closestOrder = closest->getTabOrder();
672  if ( ( reverse && currentOrder > closestOrder && currentOrder < startOrder)
673  ||(!reverse && currentOrder < closestOrder && currentOrder > startOrder))
674  {
675  closest = *it;
676  }
677  }
678  else
679  if ( (reverse && currentOrder < startOrder) || (!reverse && currentOrder > startOrder) )
680  {
681  closest = *it;
682  }
683 
684  // is it before the current first?
685  if (first)
686  {
687  closestOrder = first->getTabOrder();
688 
689  if ( (reverse && closestOrder < currentOrder) || (!reverse && closestOrder > currentOrder) )
690  {
691  first = *it;
692  }
693  }
694  else
695  {
696  first = *it;
697  }
698  }
699  }
700  // search within children
701  if ((*it)->getNextElement(startOrder, reverse, group, first, closest))
702  {
703  return true;
704  }
705  }
706  ++it;
707  }
708  return false;
709  }
710 
711 
713 
718  {
719  return Type;
720  }
721 
723 
731  virtual bool hasType(EGUI_ELEMENT_TYPE type) const
732  {
733  return type == Type;
734  }
735 
736 
738 
740  virtual const c8* getTypeName() const
741  {
742  return GUIElementTypeNames[Type];
743  }
744 
746 
747  virtual const c8* getName() const
748  {
749  return Name.c_str();
750  }
751 
752 
754 
755  virtual void setName(const c8* name)
756  {
757  Name = name;
758  }
759 
760 
762 
763  virtual void setName(const core::stringc& name)
764  {
765  Name = name;
766  }
767 
768 
770 
773  {
774  out->addString("Name", Name.c_str());
775  out->addInt("Id", ID );
776  out->addString("Caption", getText());
777  out->addString("ToolTip", getToolTipText().c_str());
778  out->addRect("Rect", DesiredRect);
781  out->addEnum("LeftAlign", AlignLeft, GUIAlignmentNames);
782  out->addEnum("RightAlign", AlignRight, GUIAlignmentNames);
783  out->addEnum("TopAlign", AlignTop, GUIAlignmentNames);
784  out->addEnum("BottomAlign", AlignBottom, GUIAlignmentNames);
785  out->addBool("Visible", IsVisible);
786  out->addBool("Enabled", IsEnabled);
787  out->addBool("TabStop", IsTabStop);
788  out->addBool("TabGroup", IsTabGroup);
789  out->addInt("TabOrder", TabOrder);
790  out->addBool("NoClip", NoClip);
791  }
792 
793 
795 
798  {
799  setName(in->getAttributeAsString("Name", Name));
800  setID(in->getAttributeAsInt("Id", ID));
801  setText(in->getAttributeAsStringW("Caption", Text).c_str());
802  setToolTipText(in->getAttributeAsStringW("ToolTip").c_str());
803  setVisible(in->getAttributeAsBool("Visible", IsVisible));
804  setEnabled(in->getAttributeAsBool("Enabled", IsEnabled));
805  IsTabStop = in->getAttributeAsBool("TabStop", IsTabStop);
806  IsTabGroup = in->getAttributeAsBool("TabGroup", IsTabGroup);
807  TabOrder = in->getAttributeAsInt("TabOrder", TabOrder);
808 
811 
814 
819 
821 
822  setNotClipped(in->getAttributeAsBool("NoClip", NoClip));
823  }
824 
825 protected:
826  // not virtual because needed in constructor
828  {
829  if (child)
830  {
831  child->grab(); // prevent destruction when removed
832  child->remove(); // remove from old parent
834  child->Parent = this;
835  Children.push_back(child);
836  }
837  }
838 
839  // not virtual because needed in constructor
840  void recalculateAbsolutePosition(bool recursive)
841  {
842  core::rect<s32> parentAbsolute(0,0,0,0);
843  core::rect<s32> parentAbsoluteClip;
844  f32 fw=0.f, fh=0.f;
845 
846  if (Parent)
847  {
848  parentAbsolute = Parent->AbsoluteRect;
849 
850  if (NoClip)
851  {
852  IGUIElement* p=this;
853  while (p->Parent)
854  p = p->Parent;
855  parentAbsoluteClip = p->AbsoluteClippingRect;
856  }
857  else
858  parentAbsoluteClip = Parent->AbsoluteClippingRect;
859  }
860 
861  const s32 diffx = parentAbsolute.getWidth() - LastParentRect.getWidth();
862  const s32 diffy = parentAbsolute.getHeight() - LastParentRect.getHeight();
863 
865  fw = (f32)parentAbsolute.getWidth();
866 
868  fh = (f32)parentAbsolute.getHeight();
869 
870  switch (AlignLeft)
871  {
872  case EGUIA_UPPERLEFT:
873  break;
874  case EGUIA_LOWERRIGHT:
875  DesiredRect.UpperLeftCorner.X += diffx;
876  break;
877  case EGUIA_CENTER:
878  DesiredRect.UpperLeftCorner.X += diffx/2;
879  break;
880  case EGUIA_SCALE:
882  break;
883  }
884 
885  switch (AlignRight)
886  {
887  case EGUIA_UPPERLEFT:
888  break;
889  case EGUIA_LOWERRIGHT:
890  DesiredRect.LowerRightCorner.X += diffx;
891  break;
892  case EGUIA_CENTER:
893  DesiredRect.LowerRightCorner.X += diffx/2;
894  break;
895  case EGUIA_SCALE:
897  break;
898  }
899 
900  switch (AlignTop)
901  {
902  case EGUIA_UPPERLEFT:
903  break;
904  case EGUIA_LOWERRIGHT:
905  DesiredRect.UpperLeftCorner.Y += diffy;
906  break;
907  case EGUIA_CENTER:
908  DesiredRect.UpperLeftCorner.Y += diffy/2;
909  break;
910  case EGUIA_SCALE:
912  break;
913  }
914 
915  switch (AlignBottom)
916  {
917  case EGUIA_UPPERLEFT:
918  break;
919  case EGUIA_LOWERRIGHT:
920  DesiredRect.LowerRightCorner.Y += diffy;
921  break;
922  case EGUIA_CENTER:
923  DesiredRect.LowerRightCorner.Y += diffy/2;
924  break;
925  case EGUIA_SCALE:
927  break;
928  }
929 
931 
932  const s32 w = RelativeRect.getWidth();
933  const s32 h = RelativeRect.getHeight();
934 
935  // make sure the desired rectangle is allowed
936  if (w < (s32)MinSize.Width)
938  if (h < (s32)MinSize.Height)
940  if (MaxSize.Width && w > (s32)MaxSize.Width)
942  if (MaxSize.Height && h > (s32)MaxSize.Height)
944 
946 
947  AbsoluteRect = RelativeRect + parentAbsolute.UpperLeftCorner;
948 
949  if (!Parent)
950  parentAbsoluteClip = AbsoluteRect;
951 
953  AbsoluteClippingRect.clipAgainst(parentAbsoluteClip);
954 
955  LastParentRect = parentAbsolute;
956 
957  if ( recursive )
958  {
959  // update all children
961  for (; it != Children.end(); ++it)
962  {
963  (*it)->recalculateAbsolutePosition(recursive);
964  }
965  }
966  }
967 
968 protected:
969 
972 
975 
978 
981 
984 
988 
991 
994 
997 
999  bool IsVisible;
1000 
1003 
1006 
1008  bool NoClip;
1009 
1012 
1015 
1018 
1021 
1024 
1027 
1030 
1033 
1036 
1039 };
1040 
1041 
1042 } // end namespace gui
1043 } // end namespace irr
1044 
1045 #endif
1046 
virtual bool isVisible() const
Returns true if element is visible.
Definition: IGUIElement.h:340
EGUI_ALIGNMENT AlignTop
Definition: IGUIElement.h:1032
virtual const core::list< IGUIElement * > & getChildren() const
Returns list with children of this element.
Definition: IGUIElement.h:573
virtual IGUIElement * getElementFromPoint(const core::position2d< s32 > &point)
Returns the topmost GUI element at the specific position.
Definition: IGUIElement.h:239
bool isTabStop() const
Returns true if this element can be focused by navigating with the tab key.
Definition: IGUIElement.h:392
s32 TabOrder
tab order
Definition: IGUIElement.h:1026
REALINLINE s32 round32(f32 x)
Definition: irrMath.h:718
EGUI_ELEMENT_TYPE
List of all basic Irrlicht GUI elements.
IGUIElement(EGUI_ELEMENT_TYPE type, IGUIEnvironment *environment, IGUIElement *parent, s32 id, const core::rect< s32 > &rectangle)
Constructor.
Definition: IGUIElement.h:28
bool IsVisible
is visible?
Definition: IGUIElement.h:999
EGUI_ALIGNMENT AlignBottom
Definition: IGUIElement.h:1032
An object which is able to serialize and deserialize its attributes into an attributes object.
Provides a generic interface for attributes and their values and the possibility to serialize them.
Definition: IAttributes.h:41
virtual void setToolTipText(const wchar_t *text)
Sets the new caption of this element.
Definition: IGUIElement.h:499
virtual void addInt(const c8 *attributeName, s32 value)=0
Adds an attribute as integer.
SEvents hold information about an event. See irr::IEventReceiver for details on event handling.
core::rect< s32 > DesiredRect
Definition: IGUIElement.h:987
const c8 *const GUIAlignmentNames[]
Names for alignments.
Definition: EGUIAlignment.h:25
void setTabOrder(s32 index)
Sets the priority of focus when using the tab key to navigate between a group of elements.
Definition: IGUIElement.h:401
bool IsEnabled
is enabled?
Definition: IGUIElement.h:1002
virtual core::stringc getAttributeAsString(const c8 *attributeName, const core::stringc &defaultNotFound=core::stringc()) const =0
virtual bool getAttributeAsBool(const c8 *attributeName, bool defaultNotFound=false) const =0
float f32
32 bit floating point variable.
Definition: irrTypes.h:108
virtual core::rect< s32 > getAttributeAsRect(const c8 *attributeName, const core::rect< s32 > &defaultNotFound=core::rect< s32 >()) const =0
core::rect< s32 > RelativeRect
relative rect of element
Definition: IGUIElement.h:977
bool isNotClipped() const
Gets whether the element will ignore its parent's clipping rectangle.
Definition: IGUIElement.h:160
virtual void OnPostRender(u32 timeMs)
animate the element and its children.
Definition: IGUIElement.h:321
virtual void addChild(IGUIElement *child)
Adds a GUI element as new child of this element.
Definition: IGUIElement.h:276
core::stringw Text
caption
Definition: IGUIElement.h:1011
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.h:188
char c8
8 bit character variable.
Definition: irrTypes.h:35
virtual bool OnEvent(const SEvent &event)
Called if an event happened.
Definition: IGUIElement.h:527
position2d< T > UpperLeftCorner
Upper left corner.
Definition: rect.h:270
Aligned to parent's top or left side (default)
Definition: EGUIAlignment.h:15
virtual void remove()
Removes this element from its parent.
Definition: IGUIElement.h:301
struct holding data describing options
T Y
Y coordinate of vector.
Definition: vector2d.h:385
core::list< IGUIElement * > Children
List of all children of this element.
Definition: IGUIElement.h:971
virtual s32 getID() const
Returns id. Can be used to identify the element.
Definition: IGUIElement.h:513
EGUI_ALIGNMENT AlignRight
Definition: IGUIElement.h:1032
core::stringc Name
users can set this for identifying the element by string
Definition: IGUIElement.h:1017
virtual core::position2di getAttributeAsPosition2d(const c8 *attributeName, const core::position2di &defaultNotFound=core::position2di(0, 0)) const =0
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.h:438
EGUI_ELEMENT_TYPE getType() const
Returns the type of the gui element.
Definition: IGUIElement.h:717
core::dimension2du MinSize
Definition: IGUIElement.h:996
virtual void addRect(const c8 *attributeName, const core::rect< s32 > &value)=0
Adds an attribute as rectangle.
core::dimension2du MaxSize
maximum and minimum size of the element
Definition: IGUIElement.h:996
virtual void addBool(const c8 *attributeName, bool value)=0
Adds an attribute as bool.
Everything in the Irrlicht Engine can be found in this namespace.
Definition: aabbox3d.h:12
virtual const wchar_t * getText() const
Returns caption of this element.
Definition: IGUIElement.h:492
virtual bool bringToFront(IGUIElement *element)
Brings a child to front.
Definition: IGUIElement.h:535
Stretched to fit parent.
Definition: EGUIAlignment.h:21
void setMaxSize(core::dimension2du size)
Sets the maximum size allowed for this element.
Definition: IGUIElement.h:168
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.h:385
GUI Environment. Used as factory and manager of all other GUI elements.
Specifies a 2 dimensional size.
Definition: dimension2d.h:20
void recalculateAbsolutePosition(bool recursive)
Definition: IGUIElement.h:840
Very simple string class with some useful features.
Definition: irrString.h:37
Doubly linked list template.
Definition: irrList.h:20
virtual void setSubElement(bool subElement)
Sets whether this control was created as part of its parent.
Definition: IGUIElement.h:376
virtual void updateAbsolutePosition()
Updates the absolute position.
Definition: IGUIElement.h:214
position2d< T > LowerRightCorner
Lower right corner.
Definition: rect.h:272
virtual void addEnum(const c8 *attributeName, const c8 *enumValue, const c8 *const *enumerationLiterals)=0
Adds an attribute as enum.
List iterator for const access.
Definition: irrList.h:83
virtual s32 getAttributeAsInt(const c8 *attributeName, irr::s32 defaultNotFound=0) const =0
virtual bool isPointInside(const core::position2d< s32 > &point) const
Returns true if a point is within this element.
Definition: IGUIElement.h:269
Interface of an object which can receive events.
virtual bool hasType(EGUI_ELEMENT_TYPE type) const
Returns true if the gui element supports the given type.
Definition: IGUIElement.h:731
EGUI_ALIGNMENT AlignLeft
tells the element how to act when its parent is resized
Definition: IGUIElement.h:1032
bool IsTabGroup
tab groups are containers like windows, use ctrl+tab to navigate
Definition: IGUIElement.h:1029
virtual void removeChild(IGUIElement *child)
Removes a child.
Definition: IGUIElement.h:286
bool IsSubElement
is a part of a larger whole and should not be serialized?
Definition: IGUIElement.h:1005
IGUIElement * Parent
Pointer to the parent.
Definition: IGUIElement.h:974
virtual void setID(s32 id)
Sets the id of this element.
Definition: IGUIElement.h:520
signed int s32
32 bit signed variable.
Definition: irrTypes.h:70
dimension2d< T > getSize() const
Get the dimensions of the rectangle.
Definition: rect.h:236
virtual bool isEnabled() const
Returns true if element is enabled.
Definition: IGUIElement.h:468
void setNotClipped(bool noClip)
Sets whether the element will ignore its parent's clipping rectangle.
Definition: IGUIElement.h:151
virtual const core::stringw & getToolTipText() const
Returns caption of this element.
Definition: IGUIElement.h:506
IGUIEnvironment * Environment
GUI Environment.
Definition: IGUIElement.h:1035
bool isTabGroup() const
Returns true if this element is a tab group.
Definition: IGUIElement.h:445
virtual void draw()
Draws the element and its children.
Definition: IGUIElement.h:309
const T * c_str() const
Returns character string.
Definition: irrString.h:526
void setRelativePosition(const core::rect< s32 > &r)
Sets the relative rectangle of this element.
Definition: IGUIElement.h:78
bool IsTabStop
tab stop like in windows
Definition: IGUIElement.h:1023
unsigned int u32
32 bit unsigned variable.
Definition: irrTypes.h:62
bool NoClip
does this element ignore its parent's clipping rectangle?
Definition: IGUIElement.h:1008
virtual bool isSubElement() const
Returns true if this element was created as part of its parent control.
Definition: IGUIElement.h:367
T getHeight() const
Get height of rectangle.
Definition: rect.h:195
virtual bool isTrulyVisible() const
Check whether the element is truly visible, taking into accounts its parents' visibility.
Definition: IGUIElement.h:348
s32 getTabOrder() const
Returns the number in the tab order sequence.
Definition: IGUIElement.h:429
void setRelativePositionProportional(const core::rect< f32 > &r)
Sets the relative rectangle of this element as a proportion of its parent's area.
Definition: IGUIElement.h:116
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.
core::rect< s32 > AbsoluteClippingRect
absolute clipping rect of element
Definition: IGUIElement.h:983
EGUI_ELEMENT_TYPE Type
type of element
Definition: IGUIElement.h:1038
T getWidth() const
Get width of rectangle.
Definition: rect.h:189
bool isPointInside(const position2d< T > &pos) const
Returns if a 2d point is within this rectangle.
Definition: rect.h:110
T Width
Width of the dimension.
Definition: dimension2d.h:204
virtual void addString(const c8 *attributeName, const c8 *value)=0
Adds an attribute as string.
void clipAgainst(const rect< T > &other)
Clips this rectangle with another one.
Definition: rect.h:131
void setRelativePosition(const core::position2di &position)
Sets the relative rectangle of this element, maintaining its current width and height.
Definition: IGUIElement.h:102
virtual bool sendToBack(IGUIElement *child)
Moves a child to the back, so it's siblings are drawn on top of it.
Definition: IGUIElement.h:554
virtual void setEnabled(bool enabled)
Sets the enabled state of this element.
Definition: IGUIElement.h:478
Base class of all GUI elements.
Definition: IGUIElement.h:23
void setMinSize(core::dimension2du size)
Sets the minimum size allowed for this element.
Definition: IGUIElement.h:176
virtual void serializeAttributes(io::IAttributes *out, io::SAttributeReadWriteOptions *options=0) const
Writes attributes of the scene node.
Definition: IGUIElement.h:772
Aligned to the center of parent.
Definition: EGUIAlignment.h:19
core::stringw ToolTipText
tooltip
Definition: IGUIElement.h:1014
virtual ~IGUIElement()
Destructor.
Definition: IGUIElement.h:51
virtual void setText(const wchar_t *text)
Sets the new caption of this element.
Definition: IGUIElement.h:485
core::rect< s32 > getRelativePosition() const
Returns the relative rectangle of this element.
Definition: IGUIElement.h:70
core::rect< s32 > getAbsolutePosition() const
Gets the absolute rectangle of this element.
Definition: IGUIElement.h:136
IGUIElement * getParent() const
Returns parent of this element.
Definition: IGUIElement.h:64
void grab() const
Grabs the object. Increments the reference counter by one.
virtual void deserializeAttributes(io::IAttributes *in, io::SAttributeReadWriteOptions *options=0)
Reads attributes of the scene node.
Definition: IGUIElement.h:797
Aligned to parent's bottom or right side.
Definition: EGUIAlignment.h:17
IGUIElement * getTabGroup()
Returns the container element which holds all elements in this element's tab group.
Definition: IGUIElement.h:452
core::rect< f32 > ScaleRect
relative scale of the element inside its parent
Definition: IGUIElement.h:993
2d vector template class with lots of operators and methods.
Definition: dimension2d.h:16
virtual void move(core::position2d< s32 > absoluteMovement)
Moves this element.
Definition: IGUIElement.h:333
virtual const c8 * getName() const
Returns the name of the element.
Definition: IGUIElement.h:747
const c8 *const GUIElementTypeNames[]
Names for built-in element types.
virtual const c8 * getTypeName() const
Returns the type name of the gui element.
Definition: IGUIElement.h:740
bool isMyChild(IGUIElement *child) const
Definition: IGUIElement.h:609
core::rect< s32 > LastParentRect
for calculating the difference when resizing parent
Definition: IGUIElement.h:990
void setDebugName(const c8 *newName)
Sets the debug name of the object.
virtual void setName(const core::stringc &name)
Sets the name of the element.
Definition: IGUIElement.h:763
virtual void setVisible(bool visible)
Sets the visible state of this element.
Definition: IGUIElement.h:360
T Height
Height of the dimension.
Definition: dimension2d.h:206
REALINLINE s32 floor32(f32 x)
Definition: irrMath.h:653
virtual IGUIElement * getElementFromId(s32 id, bool searchchildren=false) const
Finds the first element with the given id.
Definition: IGUIElement.h:586
s32 ID
users can set this for identifying the element by integer
Definition: IGUIElement.h:1020
void repair()
If the lower right corner of the rect is smaller then the upper left, the points are swapped.
Definition: rect.h:201
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.h:634
virtual const c8 * getAttributeAsEnumeration(const c8 *attributeName, const c8 *defaultNotFound=0) const =0
core::rect< s32 > getAbsoluteClippingRect() const
Returns the visible area of the element.
Definition: IGUIElement.h:143
core::rect< s32 > AbsoluteRect
absolute rect of element
Definition: IGUIElement.h:980
void addChildToEnd(IGUIElement *child)
Definition: IGUIElement.h:827
virtual void setName(const c8 *name)
Sets the name of the element.
Definition: IGUIElement.h:755
T X
X coordinate of vector.
Definition: vector2d.h:382
List iterator.
Definition: irrList.h:38