MyGUI  3.0.3
MyGUI_ScrollView.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_SCROLL_VIEW_H__
00024 #define __MYGUI_SCROLL_VIEW_H__
00025 
00026 #include "MyGUI_Prerequest.h"
00027 #include "MyGUI_Widget.h"
00028 #include "MyGUI_ScrollViewBase.h"
00029 
00030 namespace MyGUI
00031 {
00032 
00033     class MYGUI_EXPORT ScrollView :
00034         public Widget,
00035         protected ScrollViewBase
00036     {
00037         MYGUI_RTTI_DERIVED( ScrollView )
00038 
00039     public:
00040         ScrollView();
00041 
00043         virtual void setPosition(const IntPoint& _value);
00045         virtual void setSize(const IntSize& _value);
00047         virtual void setCoord(const IntCoord& _value);
00048 
00050         void setPosition(int _left, int _top) { setPosition(IntPoint(_left, _top)); }
00052         void setSize(int _width, int _height) { setSize(IntSize(_width, _height)); }
00054         void setCoord(int _left, int _top, int _width, int _height) { setCoord(IntCoord(_left, _top, _width, _height)); }
00055 
00057         void setVisibleVScroll(bool _value);
00059         bool isVisibleVScroll() { return mVisibleVScroll; }
00060 
00062         void setVisibleHScroll(bool _value);
00064         bool isVisibleHScroll() { return mVisibleHScroll; }
00065 
00067         void setCanvasAlign(Align _value);
00069         Align getCanvasAlign() { return mContentAlign; }
00070 
00072         void setCanvasSize(const IntSize& _value);
00074         void setCanvasSize(int _width, int _height) { setCanvasSize(IntSize(_width, _height)); }
00076         IntSize getCanvasSize();
00077 
00079         const IntCoord& getClientCoord();
00080 
00082         virtual void setProperty(const std::string& _key, const std::string& _value);
00083 
00084     /*internal:*/
00085         virtual void _initialise(WidgetStyle _style, const IntCoord& _coord, Align _align, ResourceSkin* _info, Widget* _parent, ICroppedRectangle * _croppedParent, IWidgetCreator * _creator, const std::string& _name);
00086 
00087     /*obsolete:*/
00088 #ifndef MYGUI_DONT_USE_OBSOLETE
00089 
00090         MYGUI_OBSOLETE("use : void Widget::setCoord(const IntCoord& _coord)")
00091         void setPosition(const IntCoord& _coord) { setCoord(_coord); }
00092         MYGUI_OBSOLETE("use : void Widget::setCoord(int _left, int _top, int _width, int _height)")
00093         void setPosition(int _left, int _top, int _width, int _height) { setCoord(_left, _top, _width, _height); }
00094 
00095         MYGUI_OBSOLETE("use : void ScrollView::setVisibleVScroll(bool _visible)")
00096         void showVScroll(bool _visible) { setVisibleVScroll(_visible); }
00097         MYGUI_OBSOLETE("use : bool ScrollView::isVisibleVScroll()")
00098         bool isShowVScroll() { return isVisibleVScroll(); }
00099         MYGUI_OBSOLETE("use : void ScrollView::setVisibleHScroll(bool _visible)")
00100         void showHScroll(bool _visible) { setVisibleHScroll(_visible); }
00101         MYGUI_OBSOLETE("use : bool ScrollView::isVisibleHScroll()")
00102         bool isShowHScroll() { return isVisibleHScroll(); }
00103 
00104 #endif // MYGUI_DONT_USE_OBSOLETE
00105 
00106     protected:
00107         virtual ~ScrollView();
00108 
00109         void baseChangeWidgetSkin(ResourceSkin* _info);
00110 
00111         // переопределяем для присвоению холста
00112         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);
00113 
00114         void notifyMouseSetFocus(Widget* _sender, Widget* _old);
00115         void notifyMouseLostFocus(Widget* _sender, Widget* _new);
00116         void notifyMousePressed(Widget* _sender, int _left, int _top, MouseButton _id);
00117         void notifyMouseReleased(Widget* _sender, int _left, int _top, MouseButton _id);
00118 
00119         void notifyScrollChangePosition(VScroll* _sender, size_t _position);
00120         void notifyMouseWheel(Widget* _sender, int _rel);
00121 
00122         virtual void onKeyLostFocus(Widget* _new);
00123         virtual void onKeySetFocus(Widget* _old);
00124 
00125         void updateScrollViewState();
00126         void updateView();
00127 
00128     private:
00129         void initialiseWidgetSkin(ResourceSkin* _info);
00130         void shutdownWidgetSkin();
00131 
00132         // размер данных
00133         virtual IntSize getContentSize();
00134         // смещение данных
00135         virtual IntPoint getContentPosition();
00136         virtual void setContentPosition(const IntPoint& _point);
00137         // размер окна, через которые видно данные
00138         virtual IntSize getViewSize() const;
00139         // размер на который прокручиваются данные при щелчке по скролу
00140         virtual size_t getVScrollPage();
00141         virtual size_t getHScrollPage();
00142 
00143         virtual Align getContentAlign() { return mContentAlign; }
00144 
00145     protected:
00146         bool mIsFocus;
00147         bool mIsPressed;
00148 
00149         Widget* mScrollClient;
00150         Align mContentAlign;
00151 
00152     };
00153 
00154 } // namespace MyGUI
00155 
00156 #endif // __MYGUI_SCROLL_VIEW_H__