CEGUIScrollbar.h

00001 /***********************************************************************
00002         filename:       CEGUIScrollbar.h
00003         created:        13/4/2004
00004         author:         Paul D Turner
00005         
00006         purpose:        Interface to base class for Scrollbar widget
00007 *************************************************************************/
00008 /***************************************************************************
00009  *   Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
00010  *
00011  *   Permission is hereby granted, free of charge, to any person obtaining
00012  *   a copy of this software and associated documentation files (the
00013  *   "Software"), to deal in the Software without restriction, including
00014  *   without limitation the rights to use, copy, modify, merge, publish,
00015  *   distribute, sublicense, and/or sell copies of the Software, and to
00016  *   permit persons to whom the Software is furnished to do so, subject to
00017  *   the following conditions:
00018  *
00019  *   The above copyright notice and this permission notice shall be
00020  *   included in all copies or substantial portions of the Software.
00021  *
00022  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00023  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00024  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00025  *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
00026  *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00027  *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00028  *   OTHER DEALINGS IN THE SOFTWARE.
00029  ***************************************************************************/
00030 #ifndef _CEGUIScrollbar_h_
00031 #define _CEGUIScrollbar_h_
00032 
00033 #include "CEGUIBase.h"
00034 #include "CEGUIWindow.h"
00035 #include "elements/CEGUIScrollbarProperties.h"
00036 
00037 
00038 #if defined(_MSC_VER)
00039 #       pragma warning(push)
00040 #       pragma warning(disable : 4251)
00041 #endif
00042 
00043 
00044 // Start of CEGUI namespace section
00045 namespace CEGUI
00046 {
00051 class CEGUIEXPORT ScrollbarWindowRenderer : public WindowRenderer
00052 {
00053 public:
00058     ScrollbarWindowRenderer(const String& name);
00059 
00064     virtual void    updateThumb(void)   = 0;
00065 
00073     virtual float   getValueFromThumb(void) const   = 0;
00074 
00088     virtual float   getAdjustDirectionFromPoint(const Point& pt) const  = 0;
00089 };
00090 
00099 class CEGUIEXPORT Scrollbar : public Window
00100 {
00101 public:
00102         static const String EventNamespace;                             
00103     static const String WidgetTypeName;             
00104 
00105         /*************************************************************************
00106                 Event name constants
00107         *************************************************************************/
00108         static const String EventScrollPositionChanged;         
00109         static const String EventThumbTrackStarted;                     
00110         static const String EventThumbTrackEnded;                               
00111         static const String EventScrollConfigChanged;                   
00112 
00113     /*************************************************************************
00114         Child Widget name suffix constants
00115     *************************************************************************/
00116     static const String ThumbNameSuffix;            
00117     static const String IncreaseButtonNameSuffix;   
00118     static const String DecreaseButtonNameSuffix;   
00119 
00120         /*************************************************************************
00121                 Accessor functions
00122         *************************************************************************/
00138         float   getDocumentSize(void) const                     {return d_documentSize;}
00139 
00140 
00158         float   getPageSize(void) const                         {return d_pageSize;}
00159 
00160 
00177         float   getStepSize(void) const                         {return d_stepSize;}
00178 
00179 
00197         float   getOverlapSize(void) const                      {return d_overlapSize;}
00198 
00199 
00216         float   getScrollPosition(void) const           {return d_position;}
00217 
00218 
00230     PushButton* getIncreaseButton() const;
00231 
00232 
00244     PushButton* getDecreaseButton() const;
00245 
00246 
00257     Thumb* getThumb() const;
00258 
00259 
00260         /*************************************************************************
00261                 Manipulator Commands
00262         *************************************************************************/
00273         virtual void    initialiseComponents(void);
00274 
00275 
00294         void    setDocumentSize(float document_size);
00295 
00296 
00317         void    setPageSize(float page_size);
00318 
00319 
00339         void    setStepSize(float step_size);
00340 
00341 
00362         void    setOverlapSize(float overlap_size);
00363 
00364 
00386         void    setScrollPosition(float position);
00387 
00388 
00389         /*************************************************************************
00390                 Construction / Destruction
00391         *************************************************************************/
00396         Scrollbar(const String& type, const String& name);
00397 
00398 
00403         virtual ~Scrollbar(void);
00404 
00405 
00406 protected:
00407         /*************************************************************************
00408                 Implementation Methods
00409         *************************************************************************/
00414         void    updateThumb(void);
00415 
00416 
00424         float   getValueFromThumb(void) const;
00425 
00426 
00440         float   getAdjustDirectionFromPoint(const Point& pt) const;
00441 
00442 
00447     //virtual void    updateThumb_impl(void)   = 0;
00448 
00449 
00457     //virtual float   getValueFromThumb_impl(void) const   = 0;
00458 
00459 
00473     //virtual float   getAdjustDirectionFromPoint_impl(const Point& pt) const  = 0;
00474 
00475 
00480         bool    handleThumbMoved(const EventArgs& e);
00481 
00482 
00487         bool    handleIncreaseClicked(const EventArgs& e);
00488 
00489 
00494         bool    handleDecreaseClicked(const EventArgs& e);
00495 
00496 
00501         bool    handleThumbTrackStarted(const EventArgs& e);
00502 
00503 
00508         bool    handleThumbTrackEnded(const EventArgs& e);
00509 
00510 
00521         virtual bool    testClassName_impl(const String& class_name) const
00522         {
00523                 if (class_name=="Scrollbar")    return true;
00524                 return Window::testClassName_impl(class_name);
00525         }
00526 
00527     // validate window renderer
00528     virtual bool validateWindowRenderer(const String& name) const
00529     {
00530         return (name == "Scrollbar");
00531     }
00532 
00533         /*************************************************************************
00534                 New event handlers for slider widget
00535         *************************************************************************/
00540         virtual void    onScrollPositionChanged(WindowEventArgs& e);
00541 
00542 
00547         virtual void    onThumbTrackStarted(WindowEventArgs& e);
00548 
00549 
00554         virtual void    onThumbTrackEnded(WindowEventArgs& e);
00555 
00556 
00561         virtual void    onScrollConfigChanged(WindowEventArgs& e);
00562 
00563 
00564         /*************************************************************************
00565                 Overridden event handlers
00566         *************************************************************************/
00567         virtual void    onMouseButtonDown(MouseEventArgs& e);
00568         virtual void    onMouseWheel(MouseEventArgs& e);
00569 
00570 
00571         /*************************************************************************
00572                 Implementation Data
00573         *************************************************************************/
00574         float   d_documentSize;         
00575         float   d_pageSize;                     
00576         float   d_stepSize;                     
00577         float   d_overlapSize;          
00578         float   d_position;                     
00579 
00580 
00581 private:
00582         /*************************************************************************
00583                 Static Properties for this class
00584         *************************************************************************/
00585         static ScrollbarProperties::DocumentSize        d_documentSizeProperty;
00586         static ScrollbarProperties::PageSize            d_pageSizeProperty;
00587         static ScrollbarProperties::StepSize            d_stepSizeProperty;
00588         static ScrollbarProperties::OverlapSize         d_overlapSizeProperty;
00589         static ScrollbarProperties::ScrollPosition      d_scrollPositionProperty;
00590 
00591 
00592         /*************************************************************************
00593                 Private methods
00594         *************************************************************************/
00595         void    addScrollbarProperties(void);
00596 };
00597 
00598 } // End of  CEGUI namespace section
00599 
00600 #if defined(_MSC_VER)
00601 #       pragma warning(pop)
00602 #endif
00603 
00604 #endif  // end of guard _CEGUIScrollbar_h_

Generated on Sun Nov 5 14:35:28 2006 for Crazy Eddies GUI System by  doxygen 1.4.7