1 /* 2 * This source file is part of MyGUI. For the latest info, see http://mygui.info/ 3 * Distributed under the MIT License 4 * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 5 */ 6 7 #ifndef MYGUI_WINDOW_H_ 8 #define MYGUI_WINDOW_H_ 9 10 #include "MyGUI_Prerequest.h" 11 #include "MyGUI_TextBox.h" 12 #include "MyGUI_EventPair.h" 13 #include "MyGUI_ControllerFadeAlpha.h" 14 15 namespace MyGUI 16 { 17 18 // OBSOLETE 19 typedef delegates::CMultiDelegate2<Widget*, const std::string&> EventHandle_WidgetString; 20 21 typedef delegates::CMultiDelegate2<Window*, const std::string&> EventHandle_WindowPtrCStringRef; 22 typedef delegates::CMultiDelegate1<Window*> EventHandle_WindowPtr; 23 24 /** \brief @wpage{Window} 25 Window widget description should be here. 26 */ 27 class MYGUI_EXPORT Window : 28 public TextBox, // FIXME пока для кэпшена вместо виджета текст (Bug #190) 29 public MemberObsolete<Window> 30 { 31 MYGUI_RTTI_DERIVED( Window ) 32 33 public: 34 Window(); 35 36 /** @copydoc Widget::setVisible */ 37 void setVisible(bool _value) override; 38 39 /** Hide or show window smooth */ 40 void setVisibleSmooth(bool _value); 41 /** Hide window smooth and then destroy it */ 42 void destroySmooth(); 43 44 /** Enable or disable auto alpha mode */ 45 void setAutoAlpha(bool _value); 46 /** Get auto alpha mode flag */ 47 bool getAutoAlpha() const; 48 49 /** Set window caption */ 50 void setCaption(const UString& _value) override; 51 /** Get window caption */ 52 const UString& getCaption() override; 53 54 /** Get window caption widget */ 55 TextBox* getCaptionWidget(); 56 57 /** Set minimal possible window size */ 58 void setMinSize(const IntSize& _value); 59 /** Set minimal possible window size */ 60 void setMinSize(int _width, int _height); 61 /** Get minimal possible window size */ 62 IntSize getMinSize(); 63 64 /** Set maximal possible window size */ 65 void setMaxSize(const IntSize& _value); 66 /** Set maximal possible window size */ 67 void setMaxSize(int _width, int _height); 68 /** Get maximal possible window size */ 69 IntSize getMaxSize(); 70 71 //! @copydoc Widget::setPosition(const IntPoint& _value) 72 void setPosition(const IntPoint& _value) override; 73 //! @copydoc Widget::setSize(const IntSize& _value) 74 void setSize(const IntSize& _value) override; 75 //! @copydoc Widget::setCoord(const IntCoord& _value) 76 void setCoord(const IntCoord& _value) override; 77 78 using Widget::setPosition; 79 using Widget::setSize; 80 using Widget::setCoord; 81 82 /** Enable or disable snap to borders mode */ 83 void setSnap(bool _value); 84 /** Get snap to borders mode flag */ 85 bool getSnap() const; 86 87 /** Get current action applied to move/resize window. */ 88 const IntCoord& getActionScale() const; 89 90 /** Enable or disable possibility to move window. */ 91 void setMovable(bool _value); 92 /** Get possibility to move window. */ 93 bool getMovable() const; 94 95 /*events:*/ 96 /** Event : Window button pressed.\n 97 signature : void method(MyGUI::Window* _sender, const std::string& _name) 98 @param _sender widget that called this event 99 @param _name of pressed button 100 */ 101 EventPair<EventHandle_WidgetString, EventHandle_WindowPtrCStringRef> eventWindowButtonPressed; 102 103 /** Event : Window coordinate changed (window was resized or moved).\n 104 signature : void method(MyGUI::Window* _sender) 105 @param _sender widget that called this event 106 */ 107 EventPair<EventHandle_WidgetVoid, EventHandle_WindowPtr> eventWindowChangeCoord; 108 109 protected: 110 void initialiseOverride() override; 111 void shutdownOverride() override; 112 113 void onMouseChangeRootFocus(bool _focus) override; 114 void onKeyChangeRootFocus(bool _focus) override; 115 void onMouseDrag(int _left, int _top, MouseButton _id) override; 116 void onMouseButtonPressed(int _left, int _top, MouseButton _id) override; 117 void onMouseButtonReleased(int _left, int _top, MouseButton _id) override; 118 119 void notifyMousePressed(MyGUI::Widget* _sender, int _left, int _top, MouseButton _id); 120 void notifyMouseReleased(MyGUI::Widget* _sender, int _left, int _top, MouseButton _id); 121 void notifyPressedButtonEvent(MyGUI::Widget* _sender); 122 void notifyMouseDrag(MyGUI::Widget* _sender, int _left, int _top, MouseButton _id); 123 void notifyMouseWheel(MyGUI::Widget* _sender, int _rel); 124 125 // просто обновляет альфу взависимости от флагов 126 void updateAlpha(); 127 128 void animateStop(Widget* _widget, ControllerItem* _controller); 129 130 void setPropertyOverride(const std::string& _key, const std::string& _value) override; 131 132 private: 133 float getAlphaVisible() const; 134 void getSnappedCoord(IntCoord& _coord); 135 IntCoord _getActionScale(Widget* _widget); 136 137 ControllerFadeAlpha* createControllerFadeAlpha(float _alpha, float _coef, bool _enable); 138 139 private: 140 TextBox* mWidgetCaption; 141 142 // размеры окна перед началом его изменений 143 IntCoord mPreActionCoord; 144 145 // наши главные фокусы 146 bool mMouseRootFocus; 147 bool mKeyRootFocus; 148 149 // автоматическое или ручное управление альфой 150 bool mIsAutoAlpha; 151 152 // минимальные и максимальные размеры окна 153 IntRect mMinmax; 154 155 bool mSnap; // прилеплять ли к краям 156 157 IntCoord mCurrentActionScale; 158 bool mAnimateSmooth; 159 160 bool mMovable; 161 }; 162 163 } // namespace MyGUI 164 165 #endif // MYGUI_WINDOW_H_ 166