Home | Namespaces | Hierarchy | Alphabetical List | Class list | Files | Namespace Members | Class members | File members | Tutorials

# IGUIElement.h

Go to the documentation of this file.

    00001 // Copyright (C) 2002-2009 Nikolaus Gebhardt
    00002 // This file is part of the "Irrlicht Engine".
    00003 // For conditions of distribution and use, see copyright notice in irrlicht.h
    00004
    00005 #ifndef __I_GUI_ELEMENT_H_INCLUDED__
    00006 #define __I_GUI_ELEMENT_H_INCLUDED__
    00007
    00008 #include "IAttributeExchangingObject.h"
    00009 #include "irrList.h"
    00010 #include "rect.h"
    00011 #include "irrString.h"
    00012 #include "IEventReceiver.h"
    00013 #include "EGUIElementTypes.h"
    00014 #include "EGUIAlignment.h"
    00015 #include "IAttributes.h"
    00016
    00017 namespace irr
    00018 {
    00019 namespace gui
    00020 {
    00021
    00022 class IGUIEnvironment;
    00023
    00025 class IGUIElement : public virtual io::IAttributeExchangingObject, public IEventReceiver
    00026 {
    00027 public:
    00028
    00030         IGUIElement(EGUI_ELEMENT_TYPE type, IGUIEnvironment* environment, IGUIElement* parent,
    00031                 s32 id, core::rect<s32> rectangle)
    00032                 : Parent(0), RelativeRect(rectangle), AbsoluteRect(rectangle),
    00033                 AbsoluteClippingRect(rectangle), DesiredRect(rectangle),
    00034                 MaxSize(0,0), MinSize(1,1), IsVisible(true), IsEnabled(true),
    00035                 IsSubElement(false), NoClip(false), ID(id), IsTabStop(false), TabOrder(-1), IsTabGroup(false),
    00036                 AlignLeft(EGUIA_UPPERLEFT), AlignRight(EGUIA_UPPERLEFT), AlignTop(EGUIA_UPPERLEFT), AlignBottom(EGUIA_UPPERLEFT),
    00037                 Environment(environment), Type(type)
    00038         {
    00039                 #ifdef _DEBUG
    00040                 setDebugName("IGUIElement");
    00041                 #endif
    00042
    00043                 // if we were given a parent to attach to
    00044                 if (parent)
    00045                         parent->addChild(this);
    00046
    00047         }
    00048
    00049
    00051         virtual ~IGUIElement()
    00052         {
    00053                 // delete all children
    00054                 core::list<IGUIElement*>::Iterator it = Children.begin();
    00055                 for (; it != Children.end(); ++it)
    00056                 {
    00057                         (*it)->Parent = 0;
    00058                         (*it)->drop();
    00059                 }
    00060         }
    00061
    00062
    00064         IGUIElement* getParent() const
    00065         {
    00066                 return Parent;
    00067         }
    00068
    00069
    00071         core::rect<s32> getRelativePosition() const
    00072         {
    00073                 return RelativeRect;
    00074         }
    00075
    00076
    00078
    00079         void setRelativePosition(const core::rect<s32>& r)
    00080         {
    00081                 if (Parent)
    00082                 {
    00083                         const core::rect<s32>& r2 = Parent->getAbsolutePosition();
    00084
    00085                         core::dimension2df d((f32)(r2.getSize().Width), (f32)(r2.getSize().Height));
    00086
    00087                         if (AlignLeft   == EGUIA_SCALE)
    00088                                 ScaleRect.UpperLeftCorner.X = (f32)r.UpperLeftCorner.X / d.Width;
    00089                         if (AlignRight  == EGUIA_SCALE)
    00090                                 ScaleRect.LowerRightCorner.X = (f32)r.LowerRightCorner.X / d.Width;
    00091                         if (AlignTop    == EGUIA_SCALE)
    00092                                 ScaleRect.UpperLeftCorner.Y = (f32)r.UpperLeftCorner.Y / d.Height;
    00093                         if (AlignBottom == EGUIA_SCALE)
    00094                                 ScaleRect.LowerRightCorner.Y = (f32)r.LowerRightCorner.Y / d.Height;
    00095                 }
    00096
    00097                 DesiredRect = r;
    00098                 updateAbsolutePosition();
    00099         }
    00100
    00102
    00103         void setRelativePosition(const core::position2di & position)
    00104         {
    00105                 const core::dimension2di mySize = RelativeRect.getSize();
    00106                 const core::rect<s32> rectangle(position.X, position.Y,
    00107                                                 position.X + mySize.Width, position.Y + mySize.Height);
    00108                 setRelativePosition(rectangle);
    00109         }
    00110
    00111
    00113
    00117         void setRelativePositionProportional(const core::rect<f32>& r)
    00118         {
    00119                 if (!Parent)
    00120                         return;
    00121
    00122                 const core::dimension2di& d = Parent->getAbsolutePosition().getSize();
    00123
    00124                 DesiredRect = core::rect<s32>(
    00125                                         core::floor32((f32)d.Width * r.UpperLeftCorner.X),
    00126                                         core::floor32((f32)d.Height * r.UpperLeftCorner.Y),
    00127                                         core::floor32((f32)d.Width * r.LowerRightCorner.X),
    00128                                         core::floor32((f32)d.Height * r.LowerRightCorner.Y));
    00129
    00130                 ScaleRect = r;
    00131
    00132                 updateAbsolutePosition();
    00133         }
    00134
    00135
    00137         core::rect<s32> getAbsolutePosition() const
    00138         {
    00139                 return AbsoluteRect;
    00140         }
    00141
    00142
    00144         core::rect<s32> getAbsoluteClippingRect() const
    00145         {
    00146                 return AbsoluteClippingRect;
    00147         }
    00148
    00149
    00151
    00152         void setNotClipped(bool noClip)
    00153         {
    00154                 NoClip = noClip;
    00155                 updateAbsolutePosition();
    00156         }
    00157
    00158
    00160
    00161         bool isNotClipped() const
    00162         {
    00163                 return NoClip;
    00164         }
    00165
    00166
    00168
    00169         void setMaxSize(core::dimension2du size)
    00170         {
    00171                 MaxSize = size;
    00172                 updateAbsolutePosition();
    00173         }
    00174
    00175
    00177         void setMinSize(core::dimension2du size)
    00178         {
    00179                 MinSize = size;
    00180                 if (MinSize.Width < 1)
    00181                         MinSize.Width = 1;
    00182                 if (MinSize.Height < 1)
    00183                         MinSize.Height = 1;
    00184                 updateAbsolutePosition();
    00185         }
    00186
    00187
    00188         void setAlignment(EGUI_ALIGNMENT left, EGUI_ALIGNMENT right, EGUI_ALIGNMENT top, EGUI_ALIGNMENT bottom)
    00189         {
    00190                 AlignLeft = left;
    00191                 AlignRight = right;
    00192                 AlignTop = top;
    00193                 AlignBottom = bottom;
    00194
    00195                 if (Parent)
    00196                 {
    00197                         core::rect<s32> r(Parent->getAbsolutePosition());
    00198
    00199                         core::dimension2df d((f32)r.getSize().Width, (f32)r.getSize().Height);
    00200
    00201                         if (AlignLeft   == EGUIA_SCALE)
    00202                                 ScaleRect.UpperLeftCorner.X = (f32)DesiredRect.UpperLeftCorner.X / d.Width;
    00203                         if (AlignRight  == EGUIA_SCALE)
    00204                                 ScaleRect.LowerRightCorner.X = (f32)DesiredRect.LowerRightCorner.X / d.Width;
    00205                         if (AlignTop    == EGUIA_SCALE)
    00206                                 ScaleRect.UpperLeftCorner.Y = (f32)DesiredRect.UpperLeftCorner.Y / d.Height;
    00207                         if (AlignBottom == EGUIA_SCALE)
    00208                                 ScaleRect.LowerRightCorner.Y = (f32)DesiredRect.LowerRightCorner.Y / d.Height;
    00209                 }
    00210         }
    00211
    00212
    00214         virtual void updateAbsolutePosition()
    00215         {
    00216                 core::rect<s32> parentAbsolute(0,0,0,0);
    00217                 core::rect<s32> parentAbsoluteClip;
    00218                 f32 fw=0.f, fh=0.f;
    00219
    00220                 if (Parent)
    00221                 {
    00222                         parentAbsolute = Parent->AbsoluteRect;
    00223
    00224                         if (NoClip)
    00225                         {
    00226                                 IGUIElement* p=this;
    00227                                 while (p && p->Parent)
    00228                                         p = p->Parent;
    00229                                 parentAbsoluteClip = p->AbsoluteClippingRect;
    00230                         }
    00231                         else
    00232                                 parentAbsoluteClip = Parent->AbsoluteClippingRect;
    00233                 }
    00234
    00235                 const s32 diffx = parentAbsolute.getWidth() - LastParentRect.getWidth();
    00236                 const s32 diffy = parentAbsolute.getHeight() - LastParentRect.getHeight();
    00237
    00238                 if (AlignLeft == EGUIA_SCALE || AlignRight == EGUIA_SCALE)
    00239                         fw = (f32)parentAbsolute.getWidth();
    00240
    00241                 if (AlignTop == EGUIA_SCALE || AlignBottom == EGUIA_SCALE)
    00242                         fh = (f32)parentAbsolute.getHeight();
    00243
    00244                 switch (AlignLeft)
    00245                 {
    00246                         case EGUIA_UPPERLEFT:
    00247                                 break;
    00248                         case EGUIA_LOWERRIGHT:
    00249                                 DesiredRect.UpperLeftCorner.X += diffx;
    00250                                 break;
    00251                         case EGUIA_CENTER:
    00252                                 DesiredRect.UpperLeftCorner.X += diffx/2;
    00253                                 break;
    00254                         case EGUIA_SCALE:
    00255                                 DesiredRect.UpperLeftCorner.X = (s32)(ScaleRect.UpperLeftCorner.X * fw);
    00256                                 break;
    00257                 }
    00258
    00259                 switch (AlignRight)
    00260                 {
    00261                         case EGUIA_UPPERLEFT:
    00262                                 break;
    00263                         case EGUIA_LOWERRIGHT:
    00264                                 DesiredRect.LowerRightCorner.X += diffx;
    00265                                 break;
    00266                         case EGUIA_CENTER:
    00267                                 DesiredRect.LowerRightCorner.X += diffx/2;
    00268                                 break;
    00269                         case EGUIA_SCALE:
    00270                                 DesiredRect.LowerRightCorner.X = (s32)(ScaleRect.LowerRightCorner.X * fw);
    00271                                 break;
    00272                 }
    00273
    00274                 switch (AlignTop)
    00275                 {
    00276                         case EGUIA_UPPERLEFT:
    00277                                 break;
    00278                         case EGUIA_LOWERRIGHT:
    00279                                 DesiredRect.UpperLeftCorner.Y += diffy;
    00280                                 break;
    00281                         case EGUIA_CENTER:
    00282                                 DesiredRect.UpperLeftCorner.Y += diffy/2;
    00283                                 break;
    00284                         case EGUIA_SCALE:
    00285                                 DesiredRect.UpperLeftCorner.Y = (s32)(ScaleRect.UpperLeftCorner.Y * fh);
    00286                                 break;
    00287                 }
    00288
    00289                 switch (AlignBottom)
    00290                 {
    00291                         case EGUIA_UPPERLEFT:
    00292                                 break;
    00293                         case EGUIA_LOWERRIGHT:
    00294                                 DesiredRect.LowerRightCorner.Y += diffy;
    00295                                 break;
    00296                         case EGUIA_CENTER:
    00297                                 DesiredRect.LowerRightCorner.Y += diffy/2;
    00298                                 break;
    00299                         case EGUIA_SCALE:
    00300                                 DesiredRect.LowerRightCorner.Y = (s32)(ScaleRect.LowerRightCorner.Y * fh);
    00301                                 break;
    00302                 }
    00303
    00304                 RelativeRect = DesiredRect;
    00305
    00306                 const s32 w = RelativeRect.getWidth();
    00307                 const s32 h = RelativeRect.getHeight();
    00308
    00309                 // make sure the desired rectangle is allowed
    00310                 if (w < (s32)MinSize.Width)
    00311                         RelativeRect.LowerRightCorner.X = RelativeRect.UpperLeftCorner.X + MinSize.Width;
    00312                 if (h < (s32)MinSize.Height)
    00313                         RelativeRect.LowerRightCorner.Y = RelativeRect.UpperLeftCorner.Y + MinSize.Height;
    00314                 if (MaxSize.Width && w > (s32)MaxSize.Width)
    00315                         RelativeRect.LowerRightCorner.X = RelativeRect.UpperLeftCorner.X + MaxSize.Width;
    00316                 if (MaxSize.Height && h > (s32)MaxSize.Height)
    00317                         RelativeRect.LowerRightCorner.Y = RelativeRect.UpperLeftCorner.Y + MaxSize.Height;
    00318
    00319                 RelativeRect.repair();
    00320
    00321                 AbsoluteRect = RelativeRect + parentAbsolute.UpperLeftCorner;
    00322
    00323                 if (!Parent)
    00324                         parentAbsoluteClip = AbsoluteRect;
    00325
    00326                 AbsoluteClippingRect = AbsoluteRect;
    00327                 AbsoluteClippingRect.clipAgainst(parentAbsoluteClip);
    00328
    00329                 LastParentRect = parentAbsolute;
    00330
    00331                 // update all children
    00332                 core::list<IGUIElement*>::Iterator it = Children.begin();
    00333                 for (; it != Children.end(); ++it)
    00334                 {
    00335                         (*it)->updateAbsolutePosition();
    00336                 }
    00337         }
    00338
    00339
    00341
    00352         IGUIElement* getElementFromPoint(const core::position2d<s32>& point)
    00353         {
    00354                 IGUIElement* target = 0;
    00355
    00356                 // we have to search from back to front, because later children
    00357                 // might be drawn over the top of earlier ones.
    00358
    00359                 core::list<IGUIElement*>::Iterator it = Children.getLast();
    00360
    00361                 if (isVisible())
    00362                 {
    00363                         while(it != Children.end())
    00364                         {
    00365                                 target = (*it)->getElementFromPoint(point);
    00366                                 if (target)
    00367                                         return target;
    00368
    00369                                 --it;
    00370                         }
    00371                 }
    00372
    00373                 if (isVisible() && isPointInside(point))
    00374                         target = this;
    00375
    00376                 return target;
    00377         }
    00378
    00379
    00381
    00382         virtual bool isPointInside(const core::position2d<s32>& point) const
    00383         {
    00384                 return AbsoluteClippingRect.isPointInside(point);
    00385         }
    00386
    00387
    00389         virtual void addChild(IGUIElement* child)
    00390         {
    00391                 if (child)
    00392                 {
    00393                         child->grab(); // prevent destruction when removed
    00394                         child->remove(); // remove from old parent
    00395                         child->LastParentRect = getAbsolutePosition();
    00396                         child->Parent = this;
    00397                         Children.push_back(child);
    00398                         child->updateAbsolutePosition();
    00399                 }
    00400         }
    00401
    00403         virtual void removeChild(IGUIElement* child)
    00404         {
    00405                 core::list<IGUIElement*>::Iterator it = Children.begin();
    00406                 for (; it != Children.end(); ++it)
    00407                         if ((*it) == child)
    00408                         {
    00409                                 (*it)->Parent = 0;
    00410                                 (*it)->drop();
    00411                                 Children.erase(it);
    00412                                 return;
    00413                         }
    00414         }
    00415
    00416
    00418         virtual void remove()
    00419         {
    00420                 if (Parent)
    00421                         Parent->removeChild(this);
    00422         }
    00423
    00424
    00426         virtual void draw()
    00427         {
    00428                 if ( isVisible() )
    00429                 {
    00430                         core::list<IGUIElement*>::Iterator it = Children.begin();
    00431                         for (; it != Children.end(); ++it)
    00432                                 (*it)->draw();
    00433                 }
    00434         }
    00435
    00436
    00438         virtual void OnPostRender(u32 timeMs)
    00439         {
    00440                 if ( isVisible() )
    00441                 {
    00442                         core::list<IGUIElement*>::Iterator it = Children.begin();
    00443                         for (; it != Children.end(); ++it)
    00444                                 (*it)->OnPostRender( timeMs );
    00445                 }
    00446         }
    00447
    00448
    00450         virtual void move(core::position2d<s32> absoluteMovement)
    00451         {
    00452                 setRelativePosition(DesiredRect + absoluteMovement);
    00453         }
    00454
    00455
    00457         virtual bool isVisible() const
    00458         {
    00459                 _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
    00460                 return IsVisible;
    00461         }
    00462
    00463
    00465         virtual void setVisible(bool visible)
    00466         {
    00467                 IsVisible = visible;
    00468         }
    00469
    00470
    00472         virtual bool isSubElement() const
    00473         {
    00474                 _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
    00475                 return IsSubElement;
    00476         }
    00477
    00478
    00480
    00482         virtual void setSubElement(bool subElement)
    00483         {
    00484                 IsSubElement = subElement;
    00485         }
    00486
    00487
    00489
    00491         void setTabStop(bool enable)
    00492         {
    00493                 IsTabStop = enable;
    00494         }
    00495
    00496
    00498         bool isTabStop() const
    00499         {
    00500                 _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
    00501                 return IsTabStop;
    00502         }
    00503
    00504
    00506
    00508         void setTabOrder(s32 index)
    00509         {
    00510                 // negative = autonumber
    00511                 if (index < 0)
    00512                 {
    00513                         TabOrder = 0;
    00514                         IGUIElement *el = getTabGroup();
    00515                         while (IsTabGroup && el && el->Parent)
    00516                                 el = el->Parent;
    00517
    00518                         IGUIElement *first=0, *closest=0;
    00519                         if (el)
    00520                         {
    00521                                 // find the highest element number
    00522                                 el->getNextElement(-1, true, IsTabGroup, first, closest, true);
    00523                                 if (first)
    00524                                 {
    00525                                         TabOrder = first->getTabOrder() + 1;
    00526                                 }
    00527                         }
    00528
    00529                 }
    00530                 else
    00531                         TabOrder = index;
    00532         }
    00533
    00534
    00536         s32 getTabOrder() const
    00537         {
    00538                 return TabOrder;
    00539         }
    00540
    00541
    00543
    00545         void setTabGroup(bool isGroup)
    00546         {
    00547                 IsTabGroup = isGroup;
    00548         }
    00549
    00550
    00552         bool isTabGroup() const
    00553         {
    00554                 _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
    00555                 return IsTabGroup;
    00556         }
    00557
    00558
    00560         IGUIElement* getTabGroup()
    00561         {
    00562                 IGUIElement *ret=this;
    00563
    00564                 while (ret && !ret->isTabGroup())
    00565                         ret = ret->getParent();
    00566
    00567                 return ret;
    00568         }
    00569
    00570
    00572         virtual bool isEnabled() const
    00573         {
    00574                 _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
    00575                 return IsEnabled;
    00576         }
    00577
    00578
    00580         virtual void setEnabled(bool enabled)
    00581         {
    00582                 IsEnabled = enabled;
    00583         }
    00584
    00585
    00587         virtual void setText(const wchar_t* text)
    00588         {
    00589                 Text = text;
    00590         }
    00591
    00592
    00594         virtual const wchar_t* getText() const
    00595         {
    00596                 return Text.c_str();
    00597         }
    00598
    00599
    00601         virtual void setToolTipText(const wchar_t* text)
    00602         {
    00603                 ToolTipText = text;
    00604         }
    00605
    00606
    00608         virtual const core::stringw& getToolTipText() const
    00609         {
    00610                 return ToolTipText;
    00611         }
    00612
    00613
    00615         virtual s32 getID() const
    00616         {
    00617                 return ID;
    00618         }
    00619
    00620
    00622         virtual void setID(s32 id)
    00623         {
    00624                 ID = id;
    00625         }
    00626
    00627
    00629         virtual bool OnEvent(const SEvent& event)
    00630         {
    00631                 return Parent ? Parent->OnEvent(event) : false;
    00632         }
    00633
    00634
    00636
    00637         virtual bool bringToFront(IGUIElement* element)
    00638         {
    00639                 core::list<IGUIElement*>::Iterator it = Children.begin();
    00640                 for (; it != Children.end(); ++it)
    00641                 {
    00642                         if (element == (*it))
    00643                         {
    00644                                 Children.erase(it);
    00645                                 Children.push_back(element);
    00646                                 return true;
    00647                         }
    00648                 }
    00649
    00650                 _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
    00651                 return false;
    00652         }
    00653
    00654
    00656         virtual const core::list<IGUIElement*>& getChildren() const
    00657         {
    00658                 return Children;
    00659         }
    00660
    00661
    00663
    00669         virtual IGUIElement* getElementFromId(s32 id, bool searchchildren=false) const
    00670         {
    00671                 IGUIElement* e = 0;
    00672
    00673                 core::list<IGUIElement*>::ConstIterator it = Children.begin();
    00674                 for (; it != Children.end(); ++it)
    00675                 {
    00676                         if ((*it)->getID() == id)
    00677                                 return (*it);
    00678
    00679                         if (searchchildren)
    00680                                 e = (*it)->getElementFromId(id, true);
    00681
    00682                         if (e)
    00683                                 return e;
    00684                 }
    00685
    00686                 return e;
    00687         }
    00688
    00689
    00692         bool isMyChild(IGUIElement* child) const
    00693         {
    00694                 if (!child)
    00695                         return false;
    00696                 do
    00697                 {
    00698                         if (child->Parent)
    00699                                 child = child->Parent;
    00700
    00701                 } while (child->Parent && child != this);
    00702
    00703                 _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
    00704                 return child == this;
    00705         }
    00706
    00707
    00709
    00716         bool getNextElement(s32 startOrder, bool reverse, bool group,
    00717                 IGUIElement*& first, IGUIElement*& closest, bool includeInvisible=false) const
    00718         {
    00719                 // we'll stop searching if we find this number
    00720                 s32 wanted = startOrder + ( reverse ? -1 : 1 );
    00721                 if (wanted==-2)
    00722                         wanted = 1073741824; // maximum s32
    00723
    00724                 core::list<IGUIElement*>::ConstIterator it = Children.begin();
    00725
    00726                 s32 closestOrder, currentOrder;
    00727
    00728                 while(it != Children.end())
    00729                 {
    00730                         // ignore invisible elements and their children
    00731                         if ( ( (*it)->isVisible() || includeInvisible ) &&
    00732                                 (group == true || (*it)->isTabGroup() == false) )
    00733                         {
    00734                                 // only check tab stops and those with the same group status
    00735                                 if ((*it)->isTabStop() && ((*it)->isTabGroup() == group))
    00736                                 {
    00737                                         currentOrder = (*it)->getTabOrder();
    00738
    00739                                         // is this what we're looking for?
    00740                                         if (currentOrder == wanted)
    00741                                         {
    00742                                                 closest = *it;
    00743                                                 return true;
    00744                                         }
    00745
    00746                                         // is it closer than the current closest?
    00747                                         if (closest)
    00748                                         {
    00749                                                 closestOrder = closest->getTabOrder();
    00750                                                 if ( ( reverse && currentOrder > closestOrder && currentOrder < startOrder)
    00751                                                         ||(!reverse && currentOrder < closestOrder && currentOrder > startOrder))
    00752                                                 {
    00753                                                         closest = *it;
    00754                                                 }
    00755                                         }
    00756                                         else
    00757                                         if ( (reverse && currentOrder < startOrder) || (!reverse && currentOrder > startOrder) )
    00758                                         {
    00759                                                 closest = *it;
    00760                                         }
    00761
    00762                                         // is it before the current first?
    00763                                         if (first)
    00764                                         {
    00765                                                 closestOrder = first->getTabOrder();
    00766
    00767                                                 if ( (reverse && closestOrder < currentOrder) || (!reverse && closestOrder > currentOrder) )
    00768                                                 {
    00769                                                         first = *it;
    00770                                                 }
    00771                                         }
    00772                                         else
    00773                                         {
    00774                                                 first = *it;
    00775                                         }
    00776                                 }
    00777                                 // search within children
    00778                                 if ((*it)->getNextElement(startOrder, reverse, group, first, closest))
    00779                                 {
    00780                                         _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
    00781                                         return true;
    00782                                 }
    00783                         }
    00784                         ++it;
    00785                 }
    00786                 _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
    00787                 return false;
    00788         }
    00789
    00790
    00792
    00796         EGUI_ELEMENT_TYPE getType() const
    00797         {
    00798                 return Type;
    00799         }
    00800
    00801
    00803
    00805         virtual const c8* getTypeName() const
    00806         {
    00807                 return GUIElementTypeNames[Type];
    00808         }
    00809
    00810
    00812
    00814         virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const
    00815         {
    00816                 out->addInt("Id", ID );
    00817                 out->addString("Caption", getText());
    00818                 out->addRect("Rect", DesiredRect);
    00819                 out->addPosition2d("MinSize", core::position2di(MinSize.Width, MinSize.Height));
    00820                 out->addPosition2d("MaxSize", core::position2di(MaxSize.Width, MaxSize.Height));
    00821                 out->addEnum("LeftAlign", AlignLeft, GUIAlignmentNames);
    00822                 out->addEnum("RightAlign", AlignRight, GUIAlignmentNames);
    00823                 out->addEnum("TopAlign", AlignTop, GUIAlignmentNames);
    00824                 out->addEnum("BottomAlign", AlignBottom, GUIAlignmentNames);
    00825                 out->addBool("Visible", IsVisible);
    00826                 out->addBool("Enabled", IsEnabled);
    00827                 out->addBool("TabStop", IsTabStop);
    00828                 out->addBool("TabGroup", IsTabGroup);
    00829                 out->addInt("TabOrder", TabOrder);
    00830                 out->addBool("NoClip", NoClip);
    00831         }
    00832
    00833
    00835
    00837         virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0)
    00838         {
    00839                 setID(in->getAttributeAsInt("Id"));
    00840                 setText(in->getAttributeAsStringW("Caption").c_str());
    00841                 setVisible(in->getAttributeAsBool("Visible"));
    00842                 setEnabled(in->getAttributeAsBool("Enabled"));
    00843                 IsTabStop = in->getAttributeAsBool("TabStop");
    00844                 IsTabGroup = in->getAttributeAsBool("TabGroup");
    00845                 TabOrder = in->getAttributeAsInt("TabOrder");
    00846
    00847                 core::position2di p = in->getAttributeAsPosition2d("MaxSize");
    00848                 setMaxSize(core::dimension2du(p.X,p.Y));
    00849
    00850                 p = in->getAttributeAsPosition2d("MinSize");
    00851                 setMinSize(core::dimension2du(p.X,p.Y));
    00852
    00853                 setAlignment((EGUI_ALIGNMENT) in->getAttributeAsEnumeration("LeftAlign", GUIAlignmentNames),
    00854                         (EGUI_ALIGNMENT)in->getAttributeAsEnumeration("RightAlign", GUIAlignmentNames),
    00855                         (EGUI_ALIGNMENT)in->getAttributeAsEnumeration("TopAlign", GUIAlignmentNames),
    00856                         (EGUI_ALIGNMENT)in->getAttributeAsEnumeration("BottomAlign", GUIAlignmentNames));
    00857
    00858                 setRelativePosition(in->getAttributeAsRect("Rect"));
    00859
    00860                 setNotClipped(in->getAttributeAsBool("NoClip"));
    00861         }
    00862
    00863 protected:
    00864
    00866         core::list<IGUIElement*> Children;
    00867
    00869         IGUIElement* Parent;
    00870
    00872         core::rect<s32> RelativeRect;
    00873
    00875         core::rect<s32> AbsoluteRect;
    00876
    00878         core::rect<s32> AbsoluteClippingRect;
    00879
    00882         core::rect<s32> DesiredRect;
    00883
    00885         core::rect<s32> LastParentRect;
    00886
    00888         core::rect<f32> ScaleRect;
    00889
    00891         core::dimension2du MaxSize, MinSize;
    00892
    00894         bool IsVisible;
    00895
    00897         bool IsEnabled;
    00898
    00900         bool IsSubElement;
    00901
    00903         bool NoClip;
    00904
    00906         core::stringw Text;
    00907
    00909         core::stringw ToolTipText;
    00910
    00912         s32 ID;
    00913
    00915         bool IsTabStop;
    00916
    00918         s32 TabOrder;
    00919
    00921         bool IsTabGroup;
    00922
    00924         EGUI_ALIGNMENT AlignLeft, AlignRight, AlignTop, AlignBottom;
    00925
    00927         IGUIEnvironment* Environment;
    00928
    00930         EGUI_ELEMENT_TYPE Type;
    00931 };
    00932
    00933
    00934 } // end namespace gui
    00935 } // end namespace irr
    00936
    00937 #endif
    00938

| The Irrlicht Engine Documentation © 2003-2009 by Nikolaus Gebhardt. Generated on Sun Jan 10 09:24:03 2010 by Doxygen (1.5.6)