31 #ifndef _CEGUIElement_h_
32 #define _CEGUIElement_h_
34 #include "CEGUI/Base.h"
35 #include "CEGUI/PropertySet.h"
36 #include "CEGUI/EventSet.h"
37 #include "CEGUI/EventArgs.h"
40 # pragma warning(push)
41 # pragma warning(disable : 4251)
76 typedef return_type safe_method_return_type;
78 typedef String string_return_type;
80 static const String& getDataTypeName()
82 static String type(
"HorizontalAlignment");
87 static return_type fromString(
const String& str)
93 else if (str ==
"Right")
103 static string_return_type toString(pass_type val)
119 assert(
false &&
"Invalid horizontal alignment");
154 typedef return_type safe_method_return_type;
156 typedef String string_return_type;
158 static const String& getDataTypeName()
160 static String type(
"VerticalAlignment");
165 static return_type fromString(
const String& str)
171 else if (str ==
"Bottom")
181 static string_return_type toString(pass_type val)
197 assert(
false &&
"Invalid vertical alignment");
210 class CEGUIEXPORT ElementEventArgs :
public EventArgs
213 ElementEventArgs(Element* element):
242 class CEGUIEXPORT Element :
245 public AllocatedObject<Element>
249 static const String EventNamespace;
255 static const String EventSized;
261 static const String EventParentSized;
266 static const String EventMoved;
272 static const String EventHorizontalAlignmentChanged;
278 static const String EventVerticalAlignmentChanged;
283 static const String EventRotated;
288 static const String EventChildAdded;
293 static const String EventChildRemoved;
299 static const String EventZOrderChanged;
305 static const String EventNonClientChanged;
327 d_generator(generator),
336 inline const Rectf& get()
const
352 inline Rectf getFresh(
bool skipAllPixelAlignment =
false)
const
356 if (!d_cacheValid && !skipAllPixelAlignment)
361 return CEGUI_CALL_MEMBER_FN(*d_element, d_generator)(skipAllPixelAlignment);
370 inline void invalidateCache()
const
372 d_cacheValid =
false;
375 inline bool isCacheValid()
const
380 inline void regenerateCache()
const
384 d_cachedData = CEGUI_CALL_MEMBER_FN(*d_element, d_generator)(
false);
391 const DataGenerator d_generator;
394 mutable bool d_cacheValid;
414 inline Element* getParentElement()
const
438 virtual void setArea(
const UVector2& pos,
const USize& size);
441 inline void setArea(
const UDim& xpos,
const UDim& ypos,
442 const UDim& width,
const UDim& height)
448 inline void setArea(
const URect& area)
450 setArea(area.d_min, area.getSize());
467 inline const URect& getArea()
const
487 inline void setPosition(
const UVector2& pos)
489 setArea_impl(pos, d_area.getSize());
493 inline void setXPosition(
const UDim& pos)
495 setPosition(
UVector2(pos, getYPosition()));
499 inline void setYPosition(
const UDim& pos)
501 setPosition(UVector2(getXPosition(), pos));
518 inline const UVector2& getPosition()
const
520 return d_area.getPosition();
524 inline const UDim& getXPosition()
const
526 return getPosition().d_x;
530 inline const UDim& getYPosition()
const
532 return getPosition().d_y;
559 return d_horizontalAlignment;
586 return d_verticalAlignment;
600 inline void setSize(
const USize& size)
602 setArea(d_area.getPosition(), size);
606 inline void setWidth(
const UDim& width)
608 setSize(
USize(width, getSize().d_height));
612 inline void setHeight(
const UDim& height)
614 setSize(
USize(getSize().d_width, height));
628 inline USize getSize()
const
630 return d_area.getSize();
634 inline UDim getWidth()
const
636 return getSize().d_width;
640 inline UDim getHeight()
const
642 return getSize().d_height;
662 void setMinSize(
const USize& size);
677 inline const USize& getMinSize()
const
701 void setMaxSize(
const USize& size);
716 inline const USize& getMaxSize()
const
755 void setAspectRatio(
const float ratio);
763 inline float getAspectRatio()
const
765 return d_aspectRatio;
789 void setPixelAligned(
const bool setting);
798 inline bool isPixelAligned()
const
800 return d_pixelAligned;
810 inline const Vector2f& getPixelPosition()
const
812 return getUnclippedOuterRect().get().d_min;
822 inline const Sizef& getPixelSize()
const
837 Sizef calculatePixelSize(
bool skipAllPixelAlignment =
false)
const;
848 Sizef getParentPixelSize(
bool skipAllPixelAlignment =
false)
const;
862 void setRotation(
const Quaternion& rotation);
869 inline const Quaternion& getRotation()
const
894 void addChild(Element* element);
906 void removeChild(Element* element);
921 inline Element* getChildElementAtIdx(
size_t idx)
const
923 return d_children[idx];
929 inline size_t getChildCount()
const
931 return d_children.size();
937 bool isChild(
const Element* element)
const;
952 bool isAncestor(
const Element* element)
const;
967 void setNonClient(
const bool setting);
974 inline bool isNonClient()
const
992 inline const CachedRectf& getUnclippedOuterRect()
const
994 return d_unclippedOuterRect;
1010 inline const CachedRectf& getUnclippedInnerRect()
const
1012 return d_unclippedInnerRect;
1028 inline const CachedRectf& getUnclippedRect(
const bool inner)
const
1030 return inner ? getUnclippedInnerRect() : getUnclippedOuterRect();
1041 virtual const CachedRectf& getClientChildContentArea()
const;
1074 inline const CachedRectf& getChildContentArea(
const bool non_client =
false)
const
1076 return non_client ? getNonClientChildContentArea() : getClientChildContentArea();
1092 virtual void notifyScreenAreaChanged(
bool recursive =
true);
1103 virtual const Sizef& getRootContainerSize()
const;
1110 void addElementProperties();
1142 virtual void setArea_impl(
const UVector2& pos,
const USize& size,
1143 bool topLeftSizing =
false,
bool fireEvents =
true);
1146 inline bool isInnerRectSizeChanged()
const
1148 const Sizef old_sz(d_unclippedInnerRect.get().getSize());
1149 d_unclippedInnerRect.invalidateCache();
1150 return old_sz != d_unclippedInnerRect.get().getSize();
1164 virtual void setParent(Element* parent);
1170 virtual void addChild_impl(Element* element);
1176 virtual void removeChild_impl(Element* element);
1179 virtual Rectf getUnclippedOuterRect_impl(
bool skipAllPixelAlignment)
const;
1181 virtual Rectf getUnclippedInnerRect_impl(
bool skipAllPixelAlignment)
const;
1184 void fireAreaChangeEvents(
const bool moved,
const bool sized);
1185 void notifyChildrenOfSizeChange(
const bool non_client,
1199 virtual void onSized(ElementEventArgs& e);
1212 virtual void onParentSized(ElementEventArgs& e);
1222 virtual void onMoved(ElementEventArgs& e);
1234 virtual void onHorizontalAlignmentChanged(ElementEventArgs& e);
1246 virtual void onVerticalAlignmentChanged(ElementEventArgs& e);
1256 virtual void onRotated(ElementEventArgs& e);
1266 virtual void onChildAdded(ElementEventArgs& e);
1276 virtual void onChildRemoved(ElementEventArgs& e);
1288 virtual void onNonClientChanged(ElementEventArgs& e);
1294 typedef std::vector<Element*
1295 CEGUI_VECTOR_ALLOC(Element*)> ChildList;
1298 ChildList d_children;
1318 float d_aspectRatio;
1320 bool d_pixelAligned;
1343 #if defined(_MSC_VER)
1344 # pragma warning(pop)
1347 #endif // end of guard _CEGUIElement_h_