Crazy Eddies GUI System 0.7.5
CEGUIScrollablePane.h
00001 /***********************************************************************
00002     filename:   CEGUIScrollablePane.h
00003     created:    1/3/2005
00004     author:     Paul D Turner
00005 *************************************************************************/
00006 /***************************************************************************
00007  *   Copyright (C) 2004 - 2009 Paul D Turner & The CEGUI Development Team
00008  *
00009  *   Permission is hereby granted, free of charge, to any person obtaining
00010  *   a copy of this software and associated documentation files (the
00011  *   "Software"), to deal in the Software without restriction, including
00012  *   without limitation the rights to use, copy, modify, merge, publish,
00013  *   distribute, sublicense, and/or sell copies of the Software, and to
00014  *   permit persons to whom the Software is furnished to do so, subject to
00015  *   the following conditions:
00016  *
00017  *   The above copyright notice and this permission notice shall be
00018  *   included in all copies or substantial portions of the Software.
00019  *
00020  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00021  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00022  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00023  *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
00024  *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00025  *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00026  *   OTHER DEALINGS IN THE SOFTWARE.
00027  ***************************************************************************/
00028 #ifndef _CEGUIScrollablePane_h_
00029 #define _CEGUIScrollablePane_h_
00030 
00031 #include "../CEGUIBase.h"
00032 #include "../CEGUIWindow.h"
00033 #include "CEGUIScrollablePaneProperties.h"
00034 
00035 #if defined(_MSC_VER)
00036 #   pragma warning(push)
00037 #   pragma warning(disable : 4251)
00038 #endif
00039 
00040 // Start of CEGUI namespace section
00041 namespace CEGUI
00042 {
00044 class CEGUIEXPORT ScrollablePaneWindowRenderer : public WindowRenderer
00045 {
00046 public:
00048     ScrollablePaneWindowRenderer(const String& name);
00049 
00058     virtual Rect getViewableArea(void) const = 0;
00059 };
00060 
00069 class CEGUIEXPORT ScrollablePane : public Window
00070 {
00071 public:
00073     static const String WidgetTypeName;
00075     static const String EventNamespace;
00081     static const String EventContentPaneChanged;
00087     static const String EventVertScrollbarModeChanged;
00093     static const String EventHorzScrollbarModeChanged;
00099     static const String EventAutoSizeSettingChanged;
00104     static const String EventContentPaneScrolled;
00106     static const String VertScrollbarNameSuffix;
00108     static const String HorzScrollbarNameSuffix;
00110     static const String ScrolledContainerNameSuffix;
00111 
00113     ScrollablePane(const String& type, const String& name);
00114 
00116     ~ScrollablePane(void);
00117 
00130     const ScrolledContainer* getContentPane(void) const;
00131 
00140     bool isVertScrollbarAlwaysShown(void) const;
00141 
00155     void setShowVertScrollbar(bool setting);
00156 
00165     bool isHorzScrollbarAlwaysShown(void) const;
00166 
00180     void setShowHorzScrollbar(bool setting);
00181 
00191     bool isContentPaneAutoSized(void) const;
00192 
00205     void setContentPaneAutoSized(bool setting);
00206 
00215     const Rect& getContentPaneArea(void) const;
00216 
00232     void setContentPaneArea(const Rect& area);
00233 
00243     float getHorizontalStepSize(void) const;
00244 
00257     void setHorizontalStepSize(float step);
00258 
00268     float getHorizontalOverlapSize(void) const;
00269 
00282     void setHorizontalOverlapSize(float overlap);
00283 
00292     float getHorizontalScrollPosition(void) const;
00293 
00305     void setHorizontalScrollPosition(float position);
00306 
00316     float getVerticalStepSize(void) const;
00317 
00330     void setVerticalStepSize(float step);
00331 
00341     float getVerticalOverlapSize(void) const;
00342 
00355     void setVerticalOverlapSize(float overlap);
00356 
00365     float getVerticalScrollPosition(void) const;
00366 
00378     void setVerticalScrollPosition(float position);
00379 
00388     Rect getViewableArea(void) const;
00389 
00401     Scrollbar* getVertScrollbar() const;
00402 
00414     Scrollbar* getHorzScrollbar() const;
00415 
00416     // Overridden from Window
00417     void initialiseComponents(void);
00418     void destroy(void);
00419 
00420 protected:
00427     void configureScrollbars(void);
00428 
00437     bool isVertScrollbarNeeded(void) const;
00438 
00447     bool isHorzScrollbarNeeded(void) const;
00448 
00454     void updateContainerPosition(void);
00455 
00456 
00468     virtual bool testClassName_impl(const String& class_name) const
00469     {
00470         if (class_name=="ScrollablePane")
00471             return true;
00472 
00473         return Window::testClassName_impl(class_name);
00474     }
00475 
00487     ScrolledContainer* getScrolledContainer() const;
00488 
00489     // validate window renderer
00490     virtual bool validateWindowRenderer(const String& name) const
00491     {
00492         return (name == "ScrollablePane");
00493     }
00494 
00495     /*************************************************************************
00496         Event triggers
00497     *************************************************************************/
00509     virtual void onContentPaneChanged(WindowEventArgs& e);
00510 
00522     virtual void onVertScrollbarModeChanged(WindowEventArgs& e);
00523 
00535     virtual void onHorzScrollbarModeChanged(WindowEventArgs& e);
00536 
00548     virtual void onAutoSizeSettingChanged(WindowEventArgs& e);
00549 
00561     virtual void onContentPaneScrolled(WindowEventArgs& e);
00562 
00563     /*************************************************************************
00564         Event handler methods
00565     *************************************************************************/
00571     bool handleScrollChange(const EventArgs& e);
00572 
00578     bool handleContentAreaChange(const EventArgs& e);
00579 
00585     bool handleAutoSizePaneChanged(const EventArgs& e);
00586 
00587     // Overridden from Window
00588     void addChild_impl(Window* wnd);
00589     void removeChild_impl(Window* wnd);
00590     void onSized(WindowEventArgs& e);
00591     void onMouseWheel(MouseEventArgs& e);
00592 
00594     bool d_forceVertScroll;
00596     bool d_forceHorzScroll;
00598     Rect d_contentRect;
00600     float d_vertStep;
00602     float d_vertOverlap;
00604     float d_horzStep;
00606     float d_horzOverlap;
00608     Event::Connection d_contentChangedConn;
00610     Event::Connection d_autoSizeChangedConn;
00611 
00612 private:
00613     static ScrollablePaneProperties::ForceHorzScrollbar     d_horzScrollbarProperty;
00614     static ScrollablePaneProperties::ForceVertScrollbar     d_vertScrollbarProperty;
00615     static ScrollablePaneProperties::ContentPaneAutoSized   d_autoSizedProperty;
00616     static ScrollablePaneProperties::ContentArea            d_contentAreaProperty;
00617     static ScrollablePaneProperties::HorzStepSize           d_horzStepProperty;
00618     static ScrollablePaneProperties::HorzOverlapSize        d_horzOverlapProperty;
00619     static ScrollablePaneProperties::HorzScrollPosition     d_horzScrollPositionProperty;
00620     static ScrollablePaneProperties::VertStepSize           d_vertStepProperty;
00621     static ScrollablePaneProperties::VertOverlapSize        d_vertOverlapProperty;
00622     static ScrollablePaneProperties::VertScrollPosition     d_vertScrollPositionProperty;
00623 
00624     void addScrollablePaneProperties(void);
00625 };
00626 
00627 } // End of  CEGUI namespace section
00628 
00629 #if defined(_MSC_VER)
00630 #   pragma warning(pop)
00631 #endif
00632 
00633 #endif  // end of guard _CEGUIScrollablePane_h_