30 #ifndef _CEGUIWindow_h_
31 #define _CEGUIWindow_h_
33 #include "CEGUI/Base.h"
34 #include "CEGUI/NamedElement.h"
35 #include "CEGUI/Vector.h"
36 #include "CEGUI/Quaternion.h"
37 #include "CEGUI/Rect.h"
38 #include "CEGUI/Size.h"
39 #include "CEGUI/EventSet.h"
40 #include "CEGUI/PropertySet.h"
41 #include "CEGUI/TplWindowProperty.h"
42 #include "CEGUI/System.h"
43 #include "CEGUI/GUIContext.h"
44 #include "CEGUI/InputEvent.h"
45 #include "CEGUI/UDim.h"
46 #include "CEGUI/WindowRenderer.h"
47 #include "CEGUI/TextUtils.h"
48 #include "CEGUI/BasicRenderedStringParser.h"
49 #include "CEGUI/DefaultRenderedStringParser.h"
54 # pragma warning(push)
55 # pragma warning(disable : 4251)
85 typedef return_type safe_method_return_type;
87 typedef String string_return_type;
89 static const String& getDataTypeName()
91 static String type(
"WindowUpdateMode");
96 static return_type fromString(
const String& str)
103 else if (str ==
"Never")
113 static string_return_type toString(pass_type val)
129 assert(
false &&
"Invalid Window Update Mode");
149 class CEGUIEXPORT Window :
157 static const String AlphaPropertyName;
159 static const String AlwaysOnTopPropertyName;
161 static const String ClippedByParentPropertyName;
163 static const String DestroyedByParentPropertyName;
165 static const String DisabledPropertyName;
167 static const String FontPropertyName;
169 static const String IDPropertyName;
171 static const String InheritsAlphaPropertyName;
173 static const String MouseCursorImagePropertyName;
177 static const String RestoreOldCapturePropertyName;
179 static const String TextPropertyName;
181 static const String ZOrderingEnabledPropertyName;
183 static const String WantsMultiClickEventsPropertyName;
185 static const String MouseAutoRepeatEnabledPropertyName;
187 static const String AutoRepeatDelayPropertyName;
189 static const String AutoRepeatRatePropertyName;
191 static const String DistributeCapturedInputsPropertyName;
193 static const String TooltipTypePropertyName;
195 static const String TooltipTextPropertyName;
197 static const String InheritsTooltipTextPropertyName;
199 static const String RiseOnClickEnabledPropertyName;
201 static const String MousePassThroughEnabledPropertyName;
203 static const String DragDropTargetPropertyName;
205 static const String AutoRenderingSurfacePropertyName;
207 static const String TextParsingEnabledPropertyName;
211 static const String UpdateModePropertyName;
213 static const String MouseInputPropagationEnabledPropertyName;
215 static const String AutoWindowPropertyName;
238 static const String EventFontChanged;
243 static const String EventAlphaChanged;
248 static const String EventIDChanged;
255 static const String EventActivated;
262 static const String EventDeactivated;
267 static const String EventShown;
272 static const String EventHidden;
277 static const String EventEnabled;
283 static const String EventDisabled;
289 static const String EventClippedByParentChanged;
295 static const String EventDestroyedByParentChanged;
301 static const String EventInheritsAlphaChanged;
307 static const String EventAlwaysOnTopChanged;
312 static const String EventInputCaptureGained;
321 static const String EventInputCaptureLost;
331 static const String EventInvalidated;
339 static const String EventRenderingStarted;
352 static const String EventDestructionStarted;
360 static const String EventDragDropItemEnters;
368 static const String EventDragDropItemLeaves;
375 static const String EventDragDropItemDropped;
381 static const String EventWindowRendererAttached;
387 static const String EventWindowRendererDetached;
394 static const String EventTextParsingChanged;
400 static const String EventMarginChanged;
407 static const String EventMouseEntersArea;
412 static const String EventMouseLeavesArea;
423 static const String EventMouseEntersSurface;
434 static const String EventMouseLeavesSurface;
439 static const String EventMouseMove;
445 static const String EventMouseWheel;
450 static const String EventMouseButtonDown;
455 static const String EventMouseButtonUp;
462 static const String EventMouseClick;
468 static const String EventMouseDoubleClick;
474 static const String EventMouseTripleClick;
483 static const String EventKeyDown;
492 static const String EventKeyUp;
506 static const String TooltipNameSuffix;
509 static const String WindowXMLElementName;
510 static const String AutoWindowXMLElementName;
511 static const String UserStringXMLElementName;
512 static const String WindowTypeXMLAttributeName;
513 static const String WindowNameXMLAttributeName;
514 static const String AutoWindowNamePathXMLAttributeName;
515 static const String UserStringNameXMLAttributeName;
516 static const String UserStringValueXMLAttributeName;
543 const String& getType(
void)
const;
554 bool isDestroyedByParent(
void)
const {
return d_destroyedByParent;}
565 bool isAlwaysOnTop(
void)
const {
return d_alwaysOnTop;}
579 bool isDisabled()
const;
593 bool isEffectiveDisabled()
const;
611 bool isVisible()
const;
629 bool isEffectiveVisible()
const;
645 bool isActive(
void)
const;
656 bool isClippedByParent(
void)
const {
return d_clippedByParent;}
665 uint getID(
void)
const {
return d_ID;}
684 bool isChild(uint ID)
const;
706 bool isChildRecursive(uint ID)
const;
723 inline Window* getChildAtIdx(
size_t idx)
const
725 return static_cast<Window*
>(getChildElementAtIdx(idx));
751 inline Window* getChild(
const String& name_path)
const
753 return static_cast<Window*
>(getChildElement(name_path));
779 return static_cast<Window*
>(getChildElementRecursive(name));
826 Window* getChildRecursive(uint ID)
const;
840 Window* getActiveChild(
void);
841 const Window* getActiveChild(
void)
const;
857 bool isAncestor(uint ID)
const;
878 const Font* getFont(
bool useDefault =
true)
const;
887 const String& getText(
void)
const {
return d_textLogical;}
890 const String& getTextVisual()
const;
900 bool inheritsAlpha(
void)
const {
return d_inheritsAlpha;}
919 float getAlpha(
void)
const {
return d_alpha;}
930 float getEffectiveAlpha(
void)
const;
944 const Rectf& getOuterRectClipper()
const;
958 const Rectf& getInnerRectClipper()
const;
978 const Rectf& getClipRect(
const bool non_client =
false)
const;
990 const Rectf& getHitTestRect()
const;
1000 Window* getCaptureWindow()
const
1001 {
return getGUIContext().getInputCaptureWindow();}
1011 bool isCapturedByThis(
void)
const {
return getCaptureWindow() ==
this;}
1022 bool isCapturedByAncestor(
void)
const
1023 {
return isAncestor(getCaptureWindow());}
1033 bool isCapturedByChild(
void)
const {
return isChild(getCaptureWindow());}
1051 virtual bool isHit(
const Vector2f& position,
1052 const bool allow_disabled =
false)
const;
1066 Window* getChildAtPosition(
const Vector2f& position)
const;
1085 Window* getTargetChildAtPosition(
const Vector2f& position,
1086 const bool allow_disabled =
false)
const;
1096 inline Window* getParent()
const
1098 return static_cast<Window*
>(getParentElement());
1115 const Image* getMouseCursor(
bool useDefault =
true)
const;
1128 void* getUserData(
void)
const {
return d_userData;}
1144 bool restoresOldCapture(
void)
const {
return d_restoreOldCapture;}
1165 bool isZOrderingEnabled(
void)
const;
1177 bool wantsMultiClickEvents(
void)
const;
1190 bool isMouseAutoRepeatEnabled(
void)
const;
1200 float getAutoRepeatDelay(
void)
const;
1211 float getAutoRepeatRate(
void)
const;
1222 bool distributesCapturedInputs(
void)
const;
1233 bool isUsingDefaultTooltip(
void)
const;
1244 Tooltip* getTooltip(
void)
const;
1254 String getTooltipType(
void)
const;
1263 const String& getTooltipText(
void)
const;
1275 const String& getTooltipTextIncludingInheritance(
void)
const;
1288 bool inheritsTooltipText(
void)
const;
1310 bool isRiseOnClickEnabled(
void)
const {
return d_riseOnClick; }
1319 GeometryBuffer& getGeometryBuffer();
1329 const String& getLookNFeel()
const;
1338 bool getModalState(
void)
const
1339 {
return(getGUIContext().getModalWindow() ==
this);}
1354 const String& getUserString(
const String& name)
const;
1367 bool isUserStringDefined(
const String& name)
const;
1384 Window* getActiveSibling();
1396 bool isMousePassThroughEnabled(
void)
const {
return d_mousePassThroughEnabled;}
1405 bool isAutoWindow(
void)
const {
return d_autoWindow;}
1411 bool isWritingXMLAllowed(
void)
const {
return d_allowWriteXML;}
1422 bool isDragDropTarget()
const;
1459 bool isUsingAutoRenderingSurface()
const;
1471 const Window* getRootWindow()
const;
1485 virtual void initialiseComponents(
void) {}
1500 void setDestroyedByParent(
bool setting);
1514 void setAlwaysOnTop(
bool setting);
1528 void setEnabled(
bool setting);
1542 void setDisabled(
bool setting);
1551 void enable(
void) {setEnabled(
true);}
1560 void disable(
void) {setEnabled(
false);}
1579 void setVisible(
bool setting);
1593 void show(
void) {setVisible(
true);}
1605 void hide(
void) {setVisible(
false);}
1615 void activate(
void);
1626 void deactivate(
void);
1640 void setClippedByParent(
bool setting);
1653 void setID(uint ID);
1665 void setText(
const String& text);
1691 void appendText(
const String& text);
1704 void setFont(
const Font* font);
1720 void setFont(
const String& name);
1736 void removeChild(uint ID);
1753 Window* createChild(
const String& type,
const String& name =
"");
1762 void destroyChild(Window* wnd);
1771 void destroyChild(
const String& name_path);
1817 void moveInFront(
const Window*
const window);
1833 void moveBehind(
const Window*
const window);
1847 size_t getZIndex()
const;
1858 bool isInFront(
const Window& wnd)
const;
1869 bool isBehind(
const Window& wnd)
const;
1880 bool captureInput(
void);
1890 void releaseInput(
void);
1910 void setRestoreOldCapture(
bool setting);
1932 void setAlpha(
const float alpha);
1945 void setInheritsAlpha(
bool setting);
1958 void invalidate(
void);
1975 void invalidate(
const bool recursive);
1988 void setMouseCursor(
const Image* image);
2007 void setMouseCursor(
const String& name);
2023 void setUserData(
void* user_data) {d_userData = user_data;}
2047 void setZOrderingEnabled(
bool setting);
2062 void setWantsMultiClickEvents(
bool setting);
2076 void setMouseAutoRepeatEnabled(
bool setting);
2089 void setAutoRepeatDelay(
float delay);
2103 void setAutoRepeatRate(
float rate);
2114 void setDistributesCapturedInputs(
bool setting);
2121 void notifyDragDropItemEnters(DragContainer* item);
2128 void notifyDragDropItemLeaves(DragContainer* item);
2135 void notifyDragDropItemDropped(DragContainer* item);
2150 virtual void destroy(
void);
2167 void setTooltip(Tooltip* tooltip);
2187 void setTooltipType(
const String& tooltipType);
2200 void setTooltipText(
const String& tip);
2216 void setInheritsTooltipText(
bool setting);
2241 void setRiseOnClickEnabled(
bool setting) { d_riseOnClick = setting; }
2274 virtual void setLookNFeel(
const String& look);
2289 void setModalState(
bool state);
2320 virtual void performChildWindowLayout(
bool nonclient_sized_hint =
false,
2321 bool client_sized_hint =
false);
2336 void setUserString(
const String& name,
const String& value);
2366 virtual void update(
float elapsed);
2378 virtual bool performCopy(Clipboard& clipboard);
2390 virtual bool performCut(Clipboard& clipboard);
2402 virtual bool performPaste(Clipboard& clipboard);
2414 virtual void writeXMLToStream(XMLSerializer& xml_stream)
const;
2424 virtual void beginInitialisation(
void) {d_initialising =
true;}
2433 virtual void endInitialisation(
void) {d_initialising =
false;}
2445 void setMousePassThroughEnabled(
bool setting) {d_mousePassThroughEnabled = setting;}
2461 void setWindowRenderer(
const String& name);
2482 const String& getWindowRendererName()
const;
2488 void setWritingXMLAllowed(
bool allow) {d_allowWriteXML = allow;}
2500 virtual void notifyScreenAreaChanged(
bool recursive =
true);
2513 void setFalagardType(
const String& type,
const String& rendererType =
"");
2524 void setDragDropTarget(
bool setting);
2554 void invalidateRenderingSurface();
2597 void setUsingAutoRenderingSurface(
bool setting);
2608 bool isTextParsingEnabled()
const;
2610 void setTextParsingEnabled(
const bool setting);
2613 virtual void setMargin(
const UBox& margin);
2615 const UBox& getMargin()
const;
2622 {
return d_bidiVisualMapping;}
2636 void banPropertyFromXML(
const String& property_name);
2650 void banPropertyFromXMLRecursive(
const String& property_name);
2663 void unbanPropertyFromXML(
const String& property_name);
2676 void unbanPropertyFromXMLRecursive(
const String& property_name);
2687 bool isPropertyBannedFromXML(
const String& property_name)
const;
2690 void banPropertyFromXML(
const Property* property);
2693 void unbanPropertyFromXML(
const Property* property);
2703 bool isPropertyBannedFromXML(
const Property* property)
const;
2753 void setMouseInputPropagationEnabled(
const bool enabled);
2765 bool isMouseInputPropagationEnabled()
const;
2777 Window* clone(
const bool deepCopy =
true)
const;
2780 virtual void clonePropertiesTo(
Window& target)
const;
2782 virtual void cloneChildWidgetsTo(
Window& target)
const;
2790 void syncTargetSurface();
2799 void setAutoWindow(
bool is_auto);
2811 bool isMouseContainedInArea()
const;
2814 const Sizef& getRootContainerSize()
const;
3360 virtual void updateSelf(
float elapsed);
3405 virtual void populateGeometryBuffer() {}
3418 virtual void setParent(Element* parent);
3437 virtual bool validateWindowRenderer(
const WindowRenderer* renderer)
const;
3445 bool isPropertyAtDefault(
const Property* property)
const;
3452 void notifyClippingChanged(
void);
3455 void allocateRenderingWindow();
3458 void releaseRenderingWindow();
3461 void initialiseClippers(
const RenderingContext& ctx);
3464 virtual void setArea_impl(
const UVector2& pos,
const USize& size,
bool topLeftSizing =
false,
bool fireEvents =
true);
3470 virtual void cleanupChildren(
void);
3475 virtual void addChild_impl(Element* element);
3480 virtual void removeChild_impl(Element* element);
3486 virtual void onZChange_impl(
void);
3492 void addWindowProperties(
void);
3502 virtual bool moveToFront_impl(
bool wasClicked);
3523 void addWindowToDrawList(Window& wnd,
bool at_back =
false);
3536 void removeWindowFromDrawList(
const Window& wnd);
3549 bool isTopOfZOrder()
const;
3556 void updateGeometryRenderSettings();
3559 void transferChildSurfaces();
3562 Rectf getParentElementClipIntersection(
const Rectf& unclipped_area)
const;
3565 void invalidate_impl(
const bool recursive);
3573 const Window* getWindowAttachedToCommonAncestor(
const Window& wnd)
const;
3575 virtual Rectf getUnclippedInnerRect_impl(
bool skipAllPixelAlignment)
const;
3577 virtual Rectf getOuterRectClipper_impl()
const;
3579 virtual Rectf getInnerRectClipper_impl()
const;
3581 virtual Rectf getHitTestRect_impl()
const;
3583 virtual int writePropertiesXML(XMLSerializer& xml_stream)
const;
3584 virtual int writeChildWindowsXML(XMLSerializer& xml_stream)
const;
3585 virtual bool writeAutoChildWindowXML(XMLSerializer& xml_stream)
const;
3587 virtual void banPropertiesForAutoWindow();
3590 virtual bool handleFontRenderSizeChange(
const EventArgs& args);
3593 void markCachedWindowRectsInvalid();
3594 void layoutLookNFeelChildWidgets();
3596 Window* getChildAtPosition(
const Vector2f& position,
3597 bool (Window::*hittestfunc)(
const Vector2f&,
bool)
const,
3598 bool allow_disabled =
false)
const;
3600 bool isHitTargetWindow(
const Vector2f& position,
bool allow_disabled)
const;
3618 class WindowRendererProperty :
public TplWindowProperty<Window, String>
3621 WindowRendererProperty();
3622 void writeXMLToStream(
const PropertyReceiver* receiver,
3623 XMLSerializer& xml_stream)
const;
3624 } d_windowRendererProperty;
3638 class LookNFeelProperty :
public TplWindowProperty<Window, String>
3641 LookNFeelProperty();
3642 void writeXMLToStream(
const PropertyReceiver* receiver,
3643 XMLSerializer& xml_stream)
const;
3644 } d_lookNFeelProperty;
3650 typedef std::vector<
Window*
3667 bool d_initialising;
3669 bool d_destructionStarted;
3680 bool d_destroyedByParent;
3683 bool d_clippedByParent;
3694 mutable bool d_needsRedraw;
3696 bool d_autoRenderingWindow;
3704 bool d_inheritsAlpha;
3709 bool d_restoreOldCapture;
3711 bool d_distCapturedInputs;
3720 mutable bool d_bidiDataValid;
3724 mutable bool d_renderedStringValid;
3732 bool d_textParsingEnabled;
3749 bool d_zOrderingEnabled;
3752 bool d_wantsMultiClicks;
3754 bool d_mousePassThroughEnabled;
3758 float d_repeatDelay;
3766 float d_repeatElapsed;
3769 bool d_dragDropTarget;
3778 bool d_inheritsTipText;
3781 bool d_allowWriteXML;
3792 mutable bool d_outerRectClipperValid;
3793 mutable bool d_innerRectClipperValid;
3794 mutable bool d_hitTestRectValid;
3800 bool d_propagateMouseInputs;
3806 bool d_containsMouse;
3816 const Font* property_getFont()
const;
3818 const Image* property_getMouseCursor()
const;
3827 #if defined(_MSC_VER)
3828 # pragma warning(pop)
3831 #endif // end of guard _CEGUIWindow_h_