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 class MYGUI_EXPORT Window :
00035 public Widget
00036 {
00037 MYGUI_RTTI_DERIVED( Window );
00038
00039 public:
00040
00041 typedef delegates::CDelegate2<WidgetPtr, const std::string&> EventHandle_WidgetString;
00042 typedef delegates::CDelegate2<WindowPtr, const std::string&> EventHandle_WindowPtrCStringRef;
00043 typedef delegates::CDelegate1<WindowPtr> EventHandle_WindowPtr;
00044
00045 public:
00046 Window();
00047
00049 virtual void setVisible(bool _value);
00050
00052 void setVisibleSmooth(bool _value);
00054 void destroySmooth();
00055
00057 void setAutoAlpha(bool _value);
00059 bool getAutoAlpha() { return mIsAutoAlpha; }
00060
00062 virtual void setCaption(const UString& _value);
00064 virtual const UString& getCaption();
00065
00067 void setMinSize(const IntSize& _value);
00069 void setMinSize(int _width, int _height) { setMinSize(IntSize(_width, _height)); }
00071 IntSize getMinSize();
00072
00074 void setMaxSize(const IntSize& _value);
00076 void setMaxSize(int _width, int _height) { setMaxSize(IntSize(_width, _height)); }
00078 IntSize getMaxSize();
00079
00081 virtual void setPosition(const IntPoint& _value);
00083 virtual void setSize(const IntSize& _value);
00085 virtual void setCoord(const IntCoord& _value);
00086
00088 void setPosition(int _left, int _top) { setPosition(IntPoint(_left, _top)); }
00090 void setSize(int _width, int _height) { setSize(IntSize(_width, _height)); }
00092 void setCoord(int _left, int _top, int _width, int _height) { setCoord(IntCoord(_left, _top, _width, _height)); }
00093
00095 bool getSnap() { return mSnap; }
00097 void setSnap(bool _value) { mSnap = _value; }
00098
00100 virtual void setProperty(const std::string& _key, const std::string& _value);
00101
00102
00108 EventPair<EventHandle_WidgetString, EventHandle_WindowPtrCStringRef> eventWindowButtonPressed;
00109
00114 EventPair<EventHandle_WidgetVoid, EventHandle_WindowPtr> eventWindowChangeCoord;
00115
00116
00117 virtual void _initialise(WidgetStyle _style, const IntCoord& _coord, Align _align, ResourceSkin* _info, WidgetPtr _parent, ICroppedRectangle * _croppedParent, IWidgetCreator * _creator, const std::string& _name);
00118
00119
00120 #ifndef MYGUI_DONT_USE_OBSOLETE
00121
00122 MYGUI_OBSOLETE("use : void Widget::setCoord(const IntCoord& _coord)")
00123 void setPosition(const IntCoord& _coord) { setCoord(_coord); }
00124 MYGUI_OBSOLETE("use : void Widget::setCoord(int _left, int _top, int _width, int _height)")
00125 void setPosition(int _left, int _top, int _width, int _height) { setCoord(_left, _top, _width, _height); }
00126 MYGUI_OBSOLETE("use : void setVisibleSmooth(bool _visible)")
00127 void showSmooth(bool _reset = false) { setVisibleSmooth(true); }
00128 MYGUI_OBSOLETE("use : void setVisibleSmooth(bool _visible)")
00129 void hideSmooth() { setVisibleSmooth(false); }
00130 MYGUI_OBSOLETE("use : void setMinSize(const IntSize& _min) , void setMaxSize(const IntSize& _min)")
00131 void setMinMax(const IntRect& _minmax) { setMinSize(_minmax.left, _minmax.top); setMaxSize(_minmax.right, _minmax.bottom); }
00132 MYGUI_OBSOLETE("use : void setMinSize(const IntSize& _min) , void setMaxSize(const IntSize& _min)")
00133 void setMinMax(int _min_w, int _min_h, int _max_w, int _max_h) { setMinSize(_min_w, _min_h); setMaxSize(_max_w, _max_h); }
00134 MYGUI_OBSOLETE("use : IntSize getMinSize() , IntSize getMaxSize()")
00135 IntRect getMinMax() { return IntRect(getMinSize().width, getMinSize().height, getMaxSize().width, getMaxSize().height); }
00136
00137 #endif // MYGUI_DONT_USE_OBSOLETE
00138
00139 protected:
00140 virtual ~Window();
00141
00142 void baseChangeWidgetSkin(ResourceSkin* _info);
00143
00144
00145 virtual WidgetPtr baseCreateWidget(WidgetStyle _style, const std::string& _type, const std::string& _skin, const IntCoord& _coord, Align _align, const std::string& _layer, const std::string& _name);
00146
00147 void onMouseChangeRootFocus(bool _focus);
00148 void onKeyChangeRootFocus(bool _focus);
00149 void onMouseDrag(int _left, int _top);
00150 void onMouseButtonPressed(int _left, int _top, MouseButton _id);
00151
00152 void notifyMousePressed(MyGUI::WidgetPtr _sender, int _left, int _top, MouseButton _id);
00153 void notifyPressedButtonEvent(MyGUI::WidgetPtr _sender);
00154 void notifyMouseDrag(MyGUI::WidgetPtr _sender, int _left, int _top);
00155
00156
00157 void updateAlpha();
00158
00159 void animateStop(WidgetPtr _widget);
00160
00161 private:
00162 void initialiseWidgetSkin(ResourceSkin* _info);
00163 void shutdownWidgetSkin();
00164
00165 float getAlphaVisible();
00166
00167 ControllerFadeAlpha* createControllerFadeAlpha(float _alpha, float _coef, bool _enable);
00168
00169 private:
00170 WidgetPtr mWidgetCaption;
00171
00172
00173 IntCoord mPreActionCoord;
00174
00175
00176 bool mMouseRootFocus;
00177 bool mKeyRootFocus;
00178
00179
00180 bool mIsAutoAlpha;
00181
00182
00183 IntRect mMinmax;
00184
00185 bool mSnap;
00186
00187 IntCoord mCurrentActionScale;
00188 bool mAnimateSmooth;
00189
00190 };
00191
00192 }
00193
00194 #endif // __MYGUI_WINDOW_H__