MyGUI  3.0.1
MyGUI_Window.h
Go to the documentation of this file.
1 
7 /*
8  This file is part of MyGUI.
9 
10  MyGUI is free software: you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  MyGUI is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with MyGUI. If not, see <http://www.gnu.org/licenses/>.
22 */
23 #ifndef __MYGUI_WINDOW_H__
24 #define __MYGUI_WINDOW_H__
25 
26 #include "MyGUI_Prerequest.h"
27 #include "MyGUI_Widget.h"
28 #include "MyGUI_EventPair.h"
30 
31 namespace MyGUI
32 {
33 
34  // OBSOLETE
38 
40  public Widget
41  {
43 
44  public:
45  Window();
46 
48  virtual void setVisible(bool _value);
49 
51  void setVisibleSmooth(bool _value);
53  void destroySmooth();
54 
56  void setAutoAlpha(bool _value);
58  bool getAutoAlpha() { return mIsAutoAlpha; }
59 
61  virtual void setCaption(const UString& _value);
63  virtual const UString& getCaption();
64 
66  Widget* getCaptionWidget() { return mWidgetCaption; }
67 
69  void setMinSize(const IntSize& _value);
71  void setMinSize(int _width, int _height) { setMinSize(IntSize(_width, _height)); }
73  IntSize getMinSize();
74 
76  void setMaxSize(const IntSize& _value);
78  void setMaxSize(int _width, int _height) { setMaxSize(IntSize(_width, _height)); }
80  IntSize getMaxSize();
81 
83  virtual void setPosition(const IntPoint& _value);
85  virtual void setSize(const IntSize& _value);
87  virtual void setCoord(const IntCoord& _value);
88 
90  void setPosition(int _left, int _top) { setPosition(IntPoint(_left, _top)); }
92  void setSize(int _width, int _height) { setSize(IntSize(_width, _height)); }
94  void setCoord(int _left, int _top, int _width, int _height) { setCoord(IntCoord(_left, _top, _width, _height)); }
95 
97  bool getSnap() { return mSnap; }
99  void setSnap(bool _value) { mSnap = _value; }
100 
102  virtual void setProperty(const std::string& _key, const std::string& _value);
103 
104  /*event:*/
111 
117 
118  /*internal:*/
119  virtual void _initialise(WidgetStyle _style, const IntCoord& _coord, Align _align, ResourceSkin* _info, Widget* _parent, ICroppedRectangle * _croppedParent, IWidgetCreator * _creator, const std::string& _name);
120 
121  /*obsolete:*/
122 #ifndef MYGUI_DONT_USE_OBSOLETE
123 
124  MYGUI_OBSOLETE("use : void Widget::setCoord(const IntCoord& _coord)")
125  void setPosition(const IntCoord& _coord) { setCoord(_coord); }
126  MYGUI_OBSOLETE("use : void Widget::setCoord(int _left, int _top, int _width, int _height)")
127  void setPosition(int _left, int _top, int _width, int _height) { setCoord(_left, _top, _width, _height); }
128  MYGUI_OBSOLETE("use : void setVisibleSmooth(bool _visible)")
129  void showSmooth(bool _reset = false) { setVisibleSmooth(true); }
130  MYGUI_OBSOLETE("use : void setVisibleSmooth(bool _visible)")
131  void hideSmooth() { setVisibleSmooth(false); }
132  MYGUI_OBSOLETE("use : void setMinSize(const IntSize& _min) , void setMaxSize(const IntSize& _min)")
133  void setMinMax(const IntRect& _minmax) { setMinSize(_minmax.left, _minmax.top); setMaxSize(_minmax.right, _minmax.bottom); }
134  MYGUI_OBSOLETE("use : void setMinSize(const IntSize& _min) , void setMaxSize(const IntSize& _min)")
135  void setMinMax(int _min_w, int _min_h, int _max_w, int _max_h) { setMinSize(_min_w, _min_h); setMaxSize(_max_w, _max_h); }
136  MYGUI_OBSOLETE("use : IntSize getMinSize() , IntSize getMaxSize()")
137  IntRect getMinMax() { return IntRect(getMinSize().width, getMinSize().height, getMaxSize().width, getMaxSize().height); }
138 
139 #endif // MYGUI_DONT_USE_OBSOLETE
140 
141  protected:
142  virtual ~Window();
143 
144  void baseChangeWidgetSkin(ResourceSkin* _info);
145 
146  // переопределяем для присвоению клиенту
147  virtual Widget* baseCreateWidget(WidgetStyle _style, const std::string& _type, const std::string& _skin, const IntCoord& _coord, Align _align, const std::string& _layer, const std::string& _name);
148 
149  void onMouseChangeRootFocus(bool _focus);
150  void onKeyChangeRootFocus(bool _focus);
151  void onMouseDrag(int _left, int _top);
152  void onMouseButtonPressed(int _left, int _top, MouseButton _id);
153 
154  void notifyMousePressed(MyGUI::Widget* _sender, int _left, int _top, MouseButton _id);
155  void notifyPressedButtonEvent(MyGUI::Widget* _sender);
156  void notifyMouseDrag(MyGUI::Widget* _sender, int _left, int _top);
157 
158  // просто обновляет альфу взависимости от флагов
159  void updateAlpha();
160 
161  void animateStop(Widget* _widget);
162 
163  private:
164  void initialiseWidgetSkin(ResourceSkin* _info);
165  void shutdownWidgetSkin();
166 
167  float getAlphaVisible();
168  void getSnappedCoord(IntCoord& _coord);
169 
170  ControllerFadeAlpha* createControllerFadeAlpha(float _alpha, float _coef, bool _enable);
171 
172  private:
173  Widget* mWidgetCaption;
174 
175  // размеры окна перед началом его изменений
176  IntCoord mPreActionCoord;
177 
178  // наши главные фокусы
179  bool mMouseRootFocus;
180  bool mKeyRootFocus;
181 
182  // автоматическое или ручное управление альфой
183  bool mIsAutoAlpha;
184 
185  // минимальные и максимальные размеры окна
186  IntRect mMinmax;
187 
188  bool mSnap; // прилеплять ли к краям
189 
190  IntCoord mCurrentActionScale;
191  bool mAnimateSmooth;
192 
193  };
194 
195 } // namespace MyGUI
196 
197 #endif // __MYGUI_WINDOW_H__