• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • Examples
  • File List
  • Globals

MyGUI_Window.h

Go to the documentation of this file.
00001 
00007 /*
00008     This file is part of MyGUI.
00009     
00010     MyGUI is free software: you can redistribute it and/or modify
00011     it under the terms of the GNU Lesser General Public License as published by
00012     the Free Software Foundation, either version 3 of the License, or
00013     (at your option) any later version.
00014     
00015     MyGUI is distributed in the hope that it will be useful,
00016     but WITHOUT ANY WARRANTY; without even the implied warranty of
00017     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018     GNU Lesser General Public License for more details.
00019     
00020     You should have received a copy of the GNU Lesser General Public License
00021     along with MyGUI.  If not, see <http://www.gnu.org/licenses/>.
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         // OBSOLETE
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     /*event:*/
00108         EventPair<EventHandle_WidgetString, EventHandle_WindowPtrCStringRef> eventWindowButtonPressed;
00109 
00114         EventPair<EventHandle_WidgetVoid, EventHandle_WindowPtr> eventWindowChangeCoord;
00115 
00116     /*internal:*/
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     /*obsolete:*/
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 } // namespace MyGUI
00193 
00194 #endif // __MYGUI_WINDOW_H__

Generated on Sun Jan 30 2011 for MyGUI by  doxygen 1.7.1