Crazy Eddies GUI System: CEGUIScrollbar.h Source File

Crazy Eddies GUI System 0.7.6

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

CEGUIScrollbar.h

    00001 /***********************************************************************
    00002     filename:   CEGUIScrollbar.h
    00003     created:    13/4/2004
    00004     author:     Paul D Turner
    00005 *************************************************************************/
    00006 /***************************************************************************
    00007  *   Copyright (C) 2004 - 2010 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 _CEGUIScrollbar_h_
    00029 #define _CEGUIScrollbar_h_
    00030
    00031 #include "../CEGUIBase.h"
    00032 #include "../CEGUIWindow.h"
    00033 #include "CEGUIScrollbarProperties.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 {
    00047 class CEGUIEXPORT ScrollbarWindowRenderer : public WindowRenderer
    00048 {
    00049 public:
    00054     ScrollbarWindowRenderer(const String& name);
    00055
    00061     virtual void updateThumb(void) = 0;
    00062
    00072     virtual float getValueFromThumb(void) const = 0;
    00073
    00087     virtual float getAdjustDirectionFromPoint(const Point& pt) const  = 0;
    00088 };
    00089
    00098 class CEGUIEXPORT Scrollbar : public Window
    00099 {
    00100 public:
    00102     static const String EventNamespace;
    00104     static const String WidgetTypeName;
    00105
    00106     /*************************************************************************
    00107         Event name constants
    00108     *************************************************************************/
    00114     static const String EventScrollPositionChanged;
    00120     static const String EventThumbTrackStarted;
    00126     static const String EventThumbTrackEnded;
    00132     static const String EventScrollConfigChanged;
    00133
    00134     /*************************************************************************
    00135         Child Widget name suffix constants
    00136     *************************************************************************/
    00138     static const String ThumbNameSuffix;
    00140     static const String IncreaseButtonNameSuffix;
    00142     static const String DecreaseButtonNameSuffix;
    00143
    00144     /*************************************************************************
    00145         Accessor functions
    00146     *************************************************************************/
    00163     float getDocumentSize(void) const
    00164     {
    00165         return d_documentSize;
    00166     }
    00167
    00185     float getPageSize(void) const
    00186     {
    00187         return d_pageSize;
    00188     }
    00189
    00207     float getStepSize(void) const
    00208     {
    00209         return d_stepSize;
    00210     }
    00211
    00229     float getOverlapSize(void) const
    00230     {
    00231         return d_overlapSize;
    00232     }
    00233
    00250     float getScrollPosition(void) const
    00251     {
    00252         return d_position;
    00253     }
    00254
    00266     PushButton* getIncreaseButton() const;
    00267
    00279     PushButton* getDecreaseButton() const;
    00280
    00291     Thumb* getThumb() const;
    00292
    00293     /*************************************************************************
    00294         Manipulator Commands
    00295     *************************************************************************/
    00307     virtual void initialiseComponents(void);
    00308
    00328     void setDocumentSize(float document_size);
    00329
    00350     void setPageSize(float page_size);
    00351
    00372     void setStepSize(float step_size);
    00373
    00394     void setOverlapSize(float overlap_size);
    00395
    00417     void setScrollPosition(float position);
    00418
    00453     void setConfig(const float* const document_size,
    00454                    const float* const page_size,
    00455                    const float* const step_size,
    00456                    const float* const overlap_size,
    00457                    const float* const position);
    00458
    00473     void setEndLockEnabled(const bool enabled);
    00474
    00490     bool isEndLockEnabled() const;
    00491
    00493     Scrollbar(const String& type, const String& name);
    00494
    00496     virtual ~Scrollbar(void);
    00497
    00498 protected:
    00504     void updateThumb(void);
    00505
    00515     float getValueFromThumb(void) const;
    00516
    00530     float getAdjustDirectionFromPoint(const Point& pt) const;
    00531
    00535     bool setScrollPosition_impl(const float position);
    00536
    00538     bool isAtEnd() const;
    00539
    00541     float getMaxScrollPosition() const;
    00542
    00544     bool handleThumbMoved(const EventArgs& e);
    00545
    00547     bool handleIncreaseClicked(const EventArgs& e);
    00548
    00550     bool handleDecreaseClicked(const EventArgs& e);
    00551
    00553     bool handleThumbTrackStarted(const EventArgs& e);
    00554
    00556     bool handleThumbTrackEnded(const EventArgs& e);
    00557
    00569     virtual bool testClassName_impl(const String& class_name) const
    00570     {
    00571         if (class_name == "Scrollbar")    return true;
    00572
    00573         return Window::testClassName_impl(class_name);
    00574     }
    00575
    00577     virtual bool validateWindowRenderer(const String& name) const
    00578     {
    00579         return (name == "Scrollbar");
    00580     }
    00581
    00582     // New event handlers for slider widget
    00584     virtual void onScrollPositionChanged(WindowEventArgs& e);
    00585
    00587     virtual void onThumbTrackStarted(WindowEventArgs& e);
    00588
    00590     virtual void onThumbTrackEnded(WindowEventArgs& e);
    00591
    00593     virtual void onScrollConfigChanged(WindowEventArgs& e);
    00594
    00595     // Overridden event handlers
    00596     virtual void onMouseButtonDown(MouseEventArgs& e);
    00597     virtual void onMouseWheel(MouseEventArgs& e);
    00598
    00599     // Implementation Data
    00601     float d_documentSize;
    00603     float d_pageSize;
    00605     float d_stepSize;
    00607     float d_overlapSize;
    00609     float d_position;
    00611     bool d_endLockPosition;
    00612
    00613 private:
    00614     // Static Properties for this class
    00615     static ScrollbarProperties::DocumentSize    d_documentSizeProperty;
    00616     static ScrollbarProperties::PageSize        d_pageSizeProperty;
    00617     static ScrollbarProperties::StepSize        d_stepSizeProperty;
    00618     static ScrollbarProperties::OverlapSize     d_overlapSizeProperty;
    00619     static ScrollbarProperties::ScrollPosition  d_scrollPositionProperty;
    00620     static ScrollbarProperties::EndLockEnabled  d_endLockEnabledProperty;
    00621
    00623     void addScrollbarProperties(void);
    00624 };
    00625
    00626 } // End of  CEGUI namespace section
    00627
    00628 #if defined(_MSC_VER)
    00629 #   pragma warning(pop)
    00630 #endif
    00631
    00632 #endif  // end of guard _CEGUIScrollbar_h_