[1092] | 1 | /************************************************************************
|
---|
| 2 | filename: CEGUIProgressBar.h
|
---|
| 3 | created: 13/4/2004
|
---|
| 4 | author: Paul D Turner
|
---|
| 5 |
|
---|
| 6 | purpose: Interface to base class for ProgressBar widget
|
---|
| 7 | *************************************************************************/
|
---|
| 8 | /*************************************************************************
|
---|
| 9 | Crazy Eddie's GUI System (http://www.cegui.org.uk)
|
---|
| 10 | Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
|
---|
| 11 |
|
---|
| 12 | This library is free software; you can redistribute it and/or
|
---|
| 13 | modify it under the terms of the GNU Lesser General Public
|
---|
| 14 | License as published by the Free Software Foundation; either
|
---|
| 15 | version 2.1 of the License, or (at your option) any later version.
|
---|
| 16 |
|
---|
| 17 | This library is distributed in the hope that it will be useful,
|
---|
| 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
| 20 | Lesser General Public License for more details.
|
---|
| 21 |
|
---|
| 22 | You should have received a copy of the GNU Lesser General Public
|
---|
| 23 | License along with this library; if not, write to the Free Software
|
---|
| 24 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
| 25 | *************************************************************************/
|
---|
| 26 | #ifndef _CEGUIProgressBar_h_
|
---|
| 27 | #define _CEGUIProgressBar_h_
|
---|
| 28 |
|
---|
| 29 | #include "CEGUIBase.h"
|
---|
| 30 | #include "CEGUIWindow.h"
|
---|
| 31 | #include "elements/CEGUIProgressBarProperties.h"
|
---|
| 32 |
|
---|
| 33 |
|
---|
| 34 | #if defined(_MSC_VER)
|
---|
| 35 | # pragma warning(push)
|
---|
| 36 | # pragma warning(disable : 4251)
|
---|
| 37 | #endif
|
---|
| 38 |
|
---|
| 39 |
|
---|
| 40 | // Start of CEGUI namespace section
|
---|
| 41 | namespace CEGUI
|
---|
| 42 | {
|
---|
| 43 | /*!
|
---|
| 44 | \brief
|
---|
| 45 | Base class for progress bars.
|
---|
| 46 | */
|
---|
| 47 | class CEGUIEXPORT ProgressBar : public Window
|
---|
| 48 | {
|
---|
| 49 | public:
|
---|
| 50 | static const String EventNamespace; //!< Namespace for global events
|
---|
| 51 |
|
---|
| 52 |
|
---|
| 53 | /*************************************************************************
|
---|
| 54 | Event name constants
|
---|
| 55 | *************************************************************************/
|
---|
| 56 | static const String EventProgressChanged; //!< Event fired whenever the progress value changes.
|
---|
| 57 | static const String EventProgressDone; //!< Event fired when the progress bar reaches 100%.
|
---|
| 58 |
|
---|
| 59 |
|
---|
| 60 | /************************************************************************
|
---|
| 61 | Accessor Functions
|
---|
| 62 | ************************************************************************/
|
---|
| 63 | /*!
|
---|
| 64 | \brief
|
---|
| 65 | return the current progress value
|
---|
| 66 | */
|
---|
| 67 | float getProgress(void) const {return d_progress;}
|
---|
| 68 |
|
---|
| 69 | /*!
|
---|
| 70 | \brief
|
---|
| 71 | return the current step size
|
---|
| 72 | */
|
---|
| 73 | float getStep(void) const {return d_step;}
|
---|
| 74 |
|
---|
| 75 |
|
---|
| 76 | /*************************************************************************
|
---|
| 77 | Manipulator Functions
|
---|
| 78 | *************************************************************************/
|
---|
| 79 | /*!
|
---|
| 80 | \brief
|
---|
| 81 | set the current progress.
|
---|
| 82 |
|
---|
| 83 | \param progress
|
---|
| 84 | The level of progress to set. If this value is >1.0f (100%) progress will be limited to 1.0f.
|
---|
| 85 |
|
---|
| 86 | \return
|
---|
| 87 | Nothing.
|
---|
| 88 | */
|
---|
| 89 | void setProgress(float progress);
|
---|
| 90 |
|
---|
| 91 |
|
---|
| 92 | /*!
|
---|
| 93 | \brief
|
---|
| 94 | set the size of the 'step' in percentage points (default is 0.01f or 1%).
|
---|
| 95 |
|
---|
| 96 | \param step
|
---|
| 97 | Amount to increase the progress by each time the step method is called.
|
---|
| 98 |
|
---|
| 99 | \return
|
---|
| 100 | Nothing.
|
---|
| 101 | */
|
---|
| 102 | void setStepSize(float step) {d_step = step;}
|
---|
| 103 |
|
---|
| 104 |
|
---|
| 105 | /*!
|
---|
| 106 | \brief
|
---|
| 107 | cause the progress to step
|
---|
| 108 |
|
---|
| 109 | The amount the progress bar will step can be changed by calling the setStepSize method. The
|
---|
| 110 | default step size is 0.01f which is equal to 1%.
|
---|
| 111 |
|
---|
| 112 | \return
|
---|
| 113 | Nothing.
|
---|
| 114 | */
|
---|
| 115 | void step(void) {setProgress(d_progress + d_step);}
|
---|
| 116 |
|
---|
| 117 |
|
---|
| 118 | /*!
|
---|
| 119 | \brief
|
---|
| 120 | Modify the progress level by a specified delta.
|
---|
| 121 |
|
---|
| 122 | \param delta
|
---|
| 123 | amount to adjust the progress by. Whatever this value is, the progress of the bar will be kept
|
---|
| 124 | within the range: 0.0f <= progress <= 1.0f.
|
---|
| 125 |
|
---|
| 126 | \return
|
---|
| 127 | Nothing.
|
---|
| 128 | */
|
---|
| 129 | void adjustProgress(float delta) {setProgress(d_progress + delta);}
|
---|
| 130 |
|
---|
| 131 |
|
---|
| 132 | /*************************************************************************
|
---|
| 133 | Construction / Destruction
|
---|
| 134 | *************************************************************************/
|
---|
| 135 | /*!
|
---|
| 136 | \brief
|
---|
| 137 | Constructor for ProgressBar class
|
---|
| 138 | */
|
---|
| 139 | ProgressBar(const String& type, const String& name);
|
---|
| 140 |
|
---|
| 141 |
|
---|
| 142 | /*!
|
---|
| 143 | \brief
|
---|
| 144 | Destructor for ProgressBar
|
---|
| 145 | */
|
---|
| 146 | virtual ~ProgressBar(void);
|
---|
| 147 |
|
---|
| 148 |
|
---|
| 149 | protected:
|
---|
| 150 | /*************************************************************************
|
---|
| 151 | Implementation methods
|
---|
| 152 | *************************************************************************/
|
---|
| 153 | /*!
|
---|
| 154 | \brief
|
---|
| 155 | Add progress bar specific events to the window
|
---|
| 156 | */
|
---|
| 157 | void addProgressBarEvents(void);
|
---|
| 158 |
|
---|
| 159 |
|
---|
| 160 | /*!
|
---|
| 161 | \brief
|
---|
| 162 | Return whether this window was inherited from the given class name at some point in the inheritance heirarchy.
|
---|
| 163 |
|
---|
| 164 | \param class_name
|
---|
| 165 | The class name that is to be checked.
|
---|
| 166 |
|
---|
| 167 | \return
|
---|
| 168 | true if this window was inherited from \a class_name. false if not.
|
---|
| 169 | */
|
---|
| 170 | virtual bool testClassName_impl(const String& class_name) const
|
---|
| 171 | {
|
---|
| 172 | if (class_name==(const utf8*)"ProgressBar") return true;
|
---|
| 173 | return Window::testClassName_impl(class_name);
|
---|
| 174 | }
|
---|
| 175 |
|
---|
| 176 |
|
---|
| 177 | /*************************************************************************
|
---|
| 178 | Event handlers for progress bar specific events
|
---|
| 179 | *************************************************************************/
|
---|
| 180 | /*!
|
---|
| 181 | \brief
|
---|
| 182 | event triggered when progress changes
|
---|
| 183 | */
|
---|
| 184 | virtual void onProgressChanged(WindowEventArgs& e);
|
---|
| 185 |
|
---|
| 186 |
|
---|
| 187 | /*!
|
---|
| 188 | \brief
|
---|
| 189 | event triggered when progress reaches 100%
|
---|
| 190 | */
|
---|
| 191 | virtual void onProgressDone(WindowEventArgs& e);
|
---|
| 192 |
|
---|
| 193 |
|
---|
| 194 | /*************************************************************************
|
---|
| 195 | Implementation Data
|
---|
| 196 | *************************************************************************/
|
---|
| 197 | float d_progress; //!< current progress (from 0.0f to 1.0f)
|
---|
| 198 | float d_step; //!< amount to 'step' progress by on a call to step()
|
---|
| 199 |
|
---|
| 200 |
|
---|
| 201 | private:
|
---|
| 202 | /*************************************************************************
|
---|
| 203 | Static Properties for this class
|
---|
| 204 | *************************************************************************/
|
---|
| 205 | static ProgressBarProperties::CurrentProgress d_currentProgressProperty;
|
---|
| 206 | static ProgressBarProperties::StepSize d_stepSizeProperty;
|
---|
| 207 |
|
---|
| 208 |
|
---|
| 209 | /*************************************************************************
|
---|
| 210 | Private methods
|
---|
| 211 | *************************************************************************/
|
---|
| 212 | void addProgressBarProperties(void);
|
---|
| 213 | };
|
---|
| 214 |
|
---|
| 215 |
|
---|
| 216 | } // End of CEGUI namespace section
|
---|
| 217 |
|
---|
| 218 | #if defined(_MSC_VER)
|
---|
| 219 | # pragma warning(pop)
|
---|
| 220 | #endif
|
---|
| 221 |
|
---|
| 222 | #endif // end of guard _CEGUIProgressBar_h_
|
---|