00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __MYGUI_WINDOW_H__
00024 #define __MYGUI_WINDOW_H__
00025
00026 #include "MyGUI_Prerequest.h"
00027 #include "MyGUI_Widget.h"
00028 #include "MyGUI_EventPair.h"
00029 #include "MyGUI_ControllerFadeAlpha.h"
00030
00031 namespace MyGUI
00032 {
00033
00034
00035 typedef delegates::CDelegate2<Widget*, const std::string&> EventHandle_WidgetString;
00036 typedef delegates::CDelegate2<Window*, const std::string&> EventHandle_WindowPtrCStringRef;
00037 typedef delegates::CDelegate1<Window*> EventHandle_WindowPtr;
00038
00039 class MYGUI_EXPORT Window :
00040 public Widget
00041 {
00042 MYGUI_RTTI_DERIVED( Window )
00043
00044 public:
00045 Window();
00046
00048 virtual void setVisible(bool _value);
00049
00051 void setVisibleSmooth(bool _value);
00053 void destroySmooth();
00054
00056 void setAutoAlpha(bool _value);
00058 bool getAutoAlpha() { return mIsAutoAlpha; }
00059
00061 virtual void setCaption(const UString& _value);
00063 virtual const UString& getCaption();
00064
00066 Widget* getCaptionWidget() { return mWidgetCaption; }
00067
00069 void setMinSize(const IntSize& _value);
00071 void setMinSize(int _width, int _height) { setMinSize(IntSize(_width, _height)); }
00073 IntSize getMinSize();
00074
00076 void setMaxSize(const IntSize& _value);
00078 void setMaxSize(int _width, int _height) { setMaxSize(IntSize(_width, _height)); }
00080 IntSize getMaxSize();
00081
00083 virtual void setPosition(const IntPoint& _value);
00085 virtual void setSize(const IntSize& _value);
00087 virtual void setCoord(const IntCoord& _value);
00088
00090 void setPosition(int _left, int _top) { setPosition(IntPoint(_left, _top)); }
00092 void setSize(int _width, int _height) { setSize(IntSize(_width, _height)); }
00094 void setCoord(int _left, int _top, int _width, int _height) { setCoord(IntCoord(_left, _top, _width, _height)); }
00095
00097 bool getSnap() { return mSnap; }
00099 void setSnap(bool _value) { mSnap = _value; }
00100
00102 virtual void setProperty(const std::string& _key, const std::string& _value);
00103
00104
00110 EventPair<EventHandle_WidgetString, EventHandle_WindowPtrCStringRef> eventWindowButtonPressed;
00111
00116 EventPair<EventHandle_WidgetVoid, EventHandle_WindowPtr> eventWindowChangeCoord;
00117
00118
00119 virtual void _initialise(WidgetStyle _style, const IntCoord& _coord, Align _align, ResourceSkin* _info, Widget* _parent, ICroppedRectangle * _croppedParent, IWidgetCreator * _creator, const std::string& _name);
00120
00121
00122 #ifndef MYGUI_DONT_USE_OBSOLETE
00123
00124 MYGUI_OBSOLETE("use : void Widget::setCoord(const IntCoord& _coord)")
00125 void setPosition(const IntCoord& _coord) { setCoord(_coord); }
00126 MYGUI_OBSOLETE("use : void Widget::setCoord(int _left, int _top, int _width, int _height)")
00127 void setPosition(int _left, int _top, int _width, int _height) { setCoord(_left, _top, _width, _height); }
00128 MYGUI_OBSOLETE("use : void setVisibleSmooth(bool _visible)")
00129 void showSmooth(bool _reset = false) { setVisibleSmooth(true); }
00130 MYGUI_OBSOLETE("use : void setVisibleSmooth(bool _visible)")
00131 void hideSmooth() { setVisibleSmooth(false); }
00132 MYGUI_OBSOLETE("use : void setMinSize(const IntSize& _min) , void setMaxSize(const IntSize& _min)")
00133 void setMinMax(const IntRect& _minmax) { setMinSize(_minmax.left, _minmax.top); setMaxSize(_minmax.right, _minmax.bottom); }
00134 MYGUI_OBSOLETE("use : void setMinSize(const IntSize& _min) , void setMaxSize(const IntSize& _min)")
00135 void setMinMax(int _min_w, int _min_h, int _max_w, int _max_h) { setMinSize(_min_w, _min_h); setMaxSize(_max_w, _max_h); }
00136 MYGUI_OBSOLETE("use : IntSize getMinSize() , IntSize getMaxSize()")
00137 IntRect getMinMax() { return IntRect(getMinSize().width, getMinSize().height, getMaxSize().width, getMaxSize().height); }
00138
00139 #endif // MYGUI_DONT_USE_OBSOLETE
00140
00141 protected:
00142 virtual ~Window();
00143
00144 void baseChangeWidgetSkin(ResourceSkin* _info);
00145
00146
00147 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);
00148
00149 void onMouseChangeRootFocus(bool _focus);
00150 void onKeyChangeRootFocus(bool _focus);
00151 void onMouseDrag(int _left, int _top);
00152 void onMouseButtonPressed(int _left, int _top, MouseButton _id);
00153
00154 void notifyMousePressed(MyGUI::Widget* _sender, int _left, int _top, MouseButton _id);
00155 void notifyPressedButtonEvent(MyGUI::Widget* _sender);
00156 void notifyMouseDrag(MyGUI::Widget* _sender, int _left, int _top);
00157
00158
00159 void updateAlpha();
00160
00161 void animateStop(Widget* _widget);
00162
00163 private:
00164 void initialiseWidgetSkin(ResourceSkin* _info);
00165 void shutdownWidgetSkin();
00166
00167 float getAlphaVisible();
00168 void getSnappedCoord(IntCoord& _coord);
00169
00170 ControllerFadeAlpha* createControllerFadeAlpha(float _alpha, float _coef, bool _enable);
00171
00172 private:
00173 Widget* mWidgetCaption;
00174
00175
00176 IntCoord mPreActionCoord;
00177
00178
00179 bool mMouseRootFocus;
00180 bool mKeyRootFocus;
00181
00182
00183 bool mIsAutoAlpha;
00184
00185
00186 IntRect mMinmax;
00187
00188 bool mSnap;
00189
00190 IntCoord mCurrentActionScale;
00191 bool mAnimateSmooth;
00192
00193 };
00194
00195 }
00196
00197 #endif // __MYGUI_WINDOW_H__