Crazy Eddie's GUI System  0.8.4
ScrollablePane.h
00001 /***********************************************************************
00002     created:    1/3/2005
00003     author:     Paul D Turner
00004 *************************************************************************/
00005 /***************************************************************************
00006  *   Copyright (C) 2004 - 2009 Paul D Turner & The CEGUI Development Team
00007  *
00008  *   Permission is hereby granted, free of charge, to any person obtaining
00009  *   a copy of this software and associated documentation files (the
00010  *   "Software"), to deal in the Software without restriction, including
00011  *   without limitation the rights to use, copy, modify, merge, publish,
00012  *   distribute, sublicense, and/or sell copies of the Software, and to
00013  *   permit persons to whom the Software is furnished to do so, subject to
00014  *   the following conditions:
00015  *
00016  *   The above copyright notice and this permission notice shall be
00017  *   included in all copies or substantial portions of the Software.
00018  *
00019  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00020  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00021  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00022  *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
00023  *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00024  *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00025  *   OTHER DEALINGS IN THE SOFTWARE.
00026  ***************************************************************************/
00027 #ifndef _CEGUIScrollablePane_h_
00028 #define _CEGUIScrollablePane_h_
00029 
00030 #include "../Base.h"
00031 #include "../Window.h"
00032 
00033 #if defined(_MSC_VER)
00034 #   pragma warning(push)
00035 #   pragma warning(disable : 4251)
00036 #endif
00037 
00038 // Start of CEGUI namespace section
00039 namespace CEGUI
00040 {
00042 class CEGUIEXPORT ScrollablePaneWindowRenderer : public WindowRenderer
00043 {
00044 public:
00046     ScrollablePaneWindowRenderer(const String& name);
00047 
00056     virtual Rectf getViewableArea(void) const = 0;
00057 };
00058 
00067 class CEGUIEXPORT ScrollablePane : public Window
00068 {
00069 public:
00071     static const String WidgetTypeName;
00073     static const String EventNamespace;
00079     static const String EventContentPaneChanged;
00085     static const String EventVertScrollbarModeChanged;
00091     static const String EventHorzScrollbarModeChanged;
00097     static const String EventAutoSizeSettingChanged;
00102     static const String EventContentPaneScrolled;
00104     static const String VertScrollbarName;
00106     static const String HorzScrollbarName;
00108     static const String ScrolledContainerName;
00109 
00111     ScrollablePane(const String& type, const String& name);
00112 
00114     ~ScrollablePane(void);
00115 
00128     const ScrolledContainer* getContentPane(void) const;
00129 
00138     bool isVertScrollbarAlwaysShown(void) const;
00139 
00153     void setShowVertScrollbar(bool setting);
00154 
00163     bool isHorzScrollbarAlwaysShown(void) const;
00164 
00178     void setShowHorzScrollbar(bool setting);
00179 
00189     bool isContentPaneAutoSized(void) const;
00190 
00203     void setContentPaneAutoSized(bool setting);
00204 
00213     const Rectf& getContentPaneArea(void) const;
00214 
00230     void setContentPaneArea(const Rectf& area);
00231 
00241     float getHorizontalStepSize(void) const;
00242 
00255     void setHorizontalStepSize(float step);
00256 
00266     float getHorizontalOverlapSize(void) const;
00267 
00280     void setHorizontalOverlapSize(float overlap);
00281 
00290     float getHorizontalScrollPosition(void) const;
00291 
00303     void setHorizontalScrollPosition(float position);
00304 
00314     float getVerticalStepSize(void) const;
00315 
00328     void setVerticalStepSize(float step);
00329 
00339     float getVerticalOverlapSize(void) const;
00340 
00353     void setVerticalOverlapSize(float overlap);
00354 
00363     float getVerticalScrollPosition(void) const;
00364 
00376     void setVerticalScrollPosition(float position);
00377 
00386     Rectf getViewableArea(void) const;
00387 
00399     Scrollbar* getVertScrollbar() const;
00400 
00412     Scrollbar* getHorzScrollbar() const;
00413 
00414     // Overridden from Window
00415     void initialiseComponents(void);
00416     void destroy(void);
00417 
00418 protected:
00425     void configureScrollbars(void);
00426 
00435     bool isVertScrollbarNeeded(void) const;
00436 
00445     bool isHorzScrollbarNeeded(void) const;
00446 
00452     void updateContainerPosition(void);
00453 
00465     ScrolledContainer* getScrolledContainer() const;
00466 
00467     // validate window renderer
00468     virtual bool validateWindowRenderer(const WindowRenderer* renderer) const;
00469 
00470     /*************************************************************************
00471         Event triggers
00472     *************************************************************************/
00484     virtual void onContentPaneChanged(WindowEventArgs& e);
00485 
00497     virtual void onVertScrollbarModeChanged(WindowEventArgs& e);
00498 
00510     virtual void onHorzScrollbarModeChanged(WindowEventArgs& e);
00511 
00523     virtual void onAutoSizeSettingChanged(WindowEventArgs& e);
00524 
00536     virtual void onContentPaneScrolled(WindowEventArgs& e);
00537 
00538     /*************************************************************************
00539         Event handler methods
00540     *************************************************************************/
00546     bool handleScrollChange(const EventArgs& e);
00547 
00553     bool handleContentAreaChange(const EventArgs& e);
00554 
00560     bool handleAutoSizePaneChanged(const EventArgs& e);
00561 
00562     // Overridden from Window
00563     void addChild_impl(Element* element);
00564     void removeChild_impl(Element* element);
00565     
00566     void onSized(ElementEventArgs& e);
00567     void onMouseWheel(MouseEventArgs& e);
00568 
00570     NamedElement* getChildByNamePath_impl(const String& name_path) const;
00571 
00573     bool d_forceVertScroll;
00575     bool d_forceHorzScroll;
00577     Rectf d_contentRect;
00579     float d_vertStep;
00581     float d_vertOverlap;
00583     float d_horzStep;
00585     float d_horzOverlap;
00587     Event::Connection d_contentChangedConn;
00589     Event::Connection d_autoSizeChangedConn;
00590 
00591 private:
00592     void addScrollablePaneProperties(void);
00593 };
00594 
00595 } // End of  CEGUI namespace section
00596 
00597 #if defined(_MSC_VER)
00598 #   pragma warning(pop)
00599 #endif
00600 
00601 #endif  // end of guard _CEGUIScrollablePane_h_
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends