[1092] | 1 | /************************************************************************
|
---|
| 2 | filename: CEGUITooltip.h
|
---|
| 3 | created: 21/2/2005
|
---|
| 4 | author: Paul D Turner
|
---|
| 5 | *************************************************************************/
|
---|
| 6 | /*************************************************************************
|
---|
| 7 | Crazy Eddie's GUI System (http://www.cegui.org.uk)
|
---|
| 8 | Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
|
---|
| 9 |
|
---|
| 10 | This library is free software; you can redistribute it and/or
|
---|
| 11 | modify it under the terms of the GNU Lesser General Public
|
---|
| 12 | License as published by the Free Software Foundation; either
|
---|
| 13 | version 2.1 of the License, or (at your option) any later version.
|
---|
| 14 |
|
---|
| 15 | This library is distributed in the hope that it will be useful,
|
---|
| 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
| 18 | Lesser General Public License for more details.
|
---|
| 19 |
|
---|
| 20 | You should have received a copy of the GNU Lesser General Public
|
---|
| 21 | License along with this library; if not, write to the Free Software
|
---|
| 22 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
| 23 | *************************************************************************/
|
---|
| 24 | #ifndef _CEGUITooltip_h_
|
---|
| 25 | #define _CEGUITooltip_h_
|
---|
| 26 |
|
---|
| 27 | #include "CEGUIWindow.h"
|
---|
| 28 | #include "elements/CEGUITooltipProperties.h"
|
---|
| 29 |
|
---|
| 30 | // Start of CEGUI namespace section
|
---|
| 31 | namespace CEGUI
|
---|
| 32 | {
|
---|
| 33 | class CEGUIEXPORT Tooltip : public Window
|
---|
| 34 | {
|
---|
| 35 | public:
|
---|
| 36 | /*************************************************************************
|
---|
| 37 | Constants
|
---|
| 38 | *************************************************************************/
|
---|
| 39 | static const String EventNamespace; //!< Namespace for global events
|
---|
| 40 | static const String EventHoverTimeChanged; //!< Event fired when the hover timeout gets changed.
|
---|
| 41 | static const String EventDisplayTimeChanged; //!< Event fired when the display timeout gets changed.
|
---|
| 42 | static const String EventFadeTimeChanged; //!< Event fired when the fade timeout gets changed.
|
---|
| 43 | static const String EventTooltipActive; //!< Event fired when the tooltip is about to get activated.
|
---|
| 44 | static const String EventTooltipInactive; //!< Event fired when the tooltip has been deactivated.
|
---|
| 45 |
|
---|
| 46 | /************************************************************************
|
---|
| 47 | Object Construction and Destruction
|
---|
| 48 | ************************************************************************/
|
---|
| 49 | /*!
|
---|
| 50 | \brief
|
---|
| 51 | Constructor for the Tooltip base class constructor
|
---|
| 52 | */
|
---|
| 53 | Tooltip(const String& type, const String& name);
|
---|
| 54 |
|
---|
| 55 | /*!
|
---|
| 56 | \brief
|
---|
| 57 | Destructor for the Tooltip base class.
|
---|
| 58 | */
|
---|
| 59 | ~Tooltip(void);
|
---|
| 60 |
|
---|
| 61 | /************************************************************************
|
---|
| 62 | Public interface
|
---|
| 63 | ************************************************************************/
|
---|
| 64 | /*!
|
---|
| 65 | \brief
|
---|
| 66 | Sets the target window for the tooltip. This used internally to manage tooltips, you
|
---|
| 67 | should not have to call this yourself.
|
---|
| 68 |
|
---|
| 69 | \param wnd
|
---|
| 70 | Window object that the tooltip should be associated with (for now).
|
---|
| 71 |
|
---|
| 72 | \return
|
---|
| 73 | Nothing.
|
---|
| 74 | */
|
---|
| 75 | void setTargetWindow(Window* wnd);
|
---|
| 76 |
|
---|
| 77 | /*!
|
---|
| 78 | \brief
|
---|
| 79 | return the current target window for this Tooltip.
|
---|
| 80 |
|
---|
| 81 | \return
|
---|
| 82 | Pointer to the target window for this Tooltip or 0 for none.
|
---|
| 83 | */
|
---|
| 84 | const Window* getTargetWindow();
|
---|
| 85 |
|
---|
| 86 | /*!
|
---|
| 87 | \brief
|
---|
| 88 | Resets the timer on the tooltip when in the Active / Inactive states. This is used internally
|
---|
| 89 | to control the tooltip, it is not normally necessary to call this method yourself.
|
---|
| 90 |
|
---|
| 91 | \return
|
---|
| 92 | Nothing.
|
---|
| 93 | */
|
---|
| 94 | void resetTimer(void);
|
---|
| 95 |
|
---|
| 96 | /*!
|
---|
| 97 | \brief
|
---|
| 98 | Return the number of seconds the mouse should hover stationary over the target window before
|
---|
| 99 | the tooltip gets activated.
|
---|
| 100 |
|
---|
| 101 | \return
|
---|
| 102 | float value representing a number of seconds.
|
---|
| 103 | */
|
---|
| 104 | float getHoverTime(void) const;
|
---|
| 105 |
|
---|
| 106 | /*!
|
---|
| 107 | \brief
|
---|
| 108 | Set the number of seconds the mouse should hover stationary over the target window before
|
---|
| 109 | the tooltip gets activated.
|
---|
| 110 |
|
---|
| 111 | \param seconds
|
---|
| 112 | float value representing a number of seconds.
|
---|
| 113 |
|
---|
| 114 | \return
|
---|
| 115 | Nothing.
|
---|
| 116 | */
|
---|
| 117 | void setDisplayTime(float seconds);
|
---|
| 118 |
|
---|
| 119 | /*!
|
---|
| 120 | \brief
|
---|
| 121 | Return the number of seconds that should be taken to fade the tooltip into and out of
|
---|
| 122 | visibility.
|
---|
| 123 |
|
---|
| 124 | \return
|
---|
| 125 | float value representing a number of seconds.
|
---|
| 126 | */
|
---|
| 127 | float getFadeTime(void) const;
|
---|
| 128 |
|
---|
| 129 | /*!
|
---|
| 130 | \brief
|
---|
| 131 | Set the number of seconds that should be taken to fade the tooltip into and out of
|
---|
| 132 | visibility.
|
---|
| 133 |
|
---|
| 134 | \param seconds
|
---|
| 135 | float value representing a number of seconds.
|
---|
| 136 |
|
---|
| 137 | \return
|
---|
| 138 | Nothing.
|
---|
| 139 | */
|
---|
| 140 | void setHoverTime(float seconds);
|
---|
| 141 |
|
---|
| 142 | /*!
|
---|
| 143 | \brief
|
---|
| 144 | Return the number of seconds the tooltip should be displayed for before it automatically
|
---|
| 145 | de-activates itself. 0 indicates that the tooltip never timesout and auto-deactivates.
|
---|
| 146 |
|
---|
| 147 | \return
|
---|
| 148 | float value representing a number of seconds.
|
---|
| 149 | */
|
---|
| 150 | float getDisplayTime(void) const;
|
---|
| 151 |
|
---|
| 152 | /*!
|
---|
| 153 | \brief
|
---|
| 154 | Set the number of seconds the tooltip should be displayed for before it automatically
|
---|
| 155 | de-activates itself. use a value of 0 if you never want the tooltip to timeout.
|
---|
| 156 |
|
---|
| 157 | \param seconds
|
---|
| 158 | float value representing a number of seconds.
|
---|
| 159 |
|
---|
| 160 | \return
|
---|
| 161 | Nothing.
|
---|
| 162 | */
|
---|
| 163 | void setFadeTime(float seconds);
|
---|
| 164 |
|
---|
| 165 | //
|
---|
| 166 | /*!
|
---|
| 167 | \brief
|
---|
| 168 | Causes the tooltip to position itself appropriately.
|
---|
| 169 |
|
---|
| 170 | \return
|
---|
| 171 | Nothing.
|
---|
| 172 | */
|
---|
| 173 | void positionSelf(void);
|
---|
| 174 |
|
---|
| 175 | protected:
|
---|
| 176 | /*************************************************************************
|
---|
| 177 | Implementation Methods
|
---|
| 178 | *************************************************************************/
|
---|
| 179 | /*!
|
---|
| 180 | \brief
|
---|
| 181 | Add ScrollablePane specific events
|
---|
| 182 | */
|
---|
| 183 | void addTooltipEvents(void);
|
---|
| 184 |
|
---|
| 185 | // methods to perform processing for each of the widget states
|
---|
| 186 | void doActiveState(float elapsed);
|
---|
| 187 | void doInactiveState(float elapsed);
|
---|
| 188 | void doFadeInState(float elapsed);
|
---|
| 189 | void doFadeOutState(float elapsed);
|
---|
| 190 |
|
---|
| 191 | // methods to switch widget states
|
---|
| 192 | void switchToInactiveState(void);
|
---|
| 193 | void switchToActiveState(void);
|
---|
| 194 | void switchToFadeInState(void);
|
---|
| 195 | void switchToFadeOutState(void);
|
---|
| 196 |
|
---|
| 197 |
|
---|
| 198 | /*!
|
---|
| 199 | \brief
|
---|
| 200 | Return whether this window was inherited from the given class name at some point in the inheritance heirarchy.
|
---|
| 201 |
|
---|
| 202 | \param class_name
|
---|
| 203 | The class name that is to be checked.
|
---|
| 204 |
|
---|
| 205 | \return
|
---|
| 206 | true if this window was inherited from \a class_name. false if not.
|
---|
| 207 | */
|
---|
| 208 | virtual bool testClassName_impl(const String& class_name) const
|
---|
| 209 | {
|
---|
| 210 | if (class_name==(const utf8*)"Tooltip") return true;
|
---|
| 211 | return Window::testClassName_impl(class_name);
|
---|
| 212 | }
|
---|
| 213 |
|
---|
| 214 | /*************************************************************************
|
---|
| 215 | Event triggers
|
---|
| 216 | *************************************************************************/
|
---|
| 217 | /*!
|
---|
| 218 | \brief
|
---|
| 219 | Event trigger method called when the hover timeout gets changed.
|
---|
| 220 |
|
---|
| 221 | \param e
|
---|
| 222 | WindowEventArgs object.
|
---|
| 223 |
|
---|
| 224 | \return
|
---|
| 225 | Nothing.
|
---|
| 226 | */
|
---|
| 227 | virtual void onHoverTimeChanged(WindowEventArgs& e);
|
---|
| 228 |
|
---|
| 229 | /*!
|
---|
| 230 | \brief
|
---|
| 231 | Event trigger method called when the display timeout gets changed.
|
---|
| 232 |
|
---|
| 233 | \param e
|
---|
| 234 | WindowEventArgs object.
|
---|
| 235 |
|
---|
| 236 | \return
|
---|
| 237 | Nothing.
|
---|
| 238 | */
|
---|
| 239 | virtual void onDisplayTimeChanged(WindowEventArgs& e);
|
---|
| 240 |
|
---|
| 241 | /*!
|
---|
| 242 | \brief
|
---|
| 243 | Event trigger method called when the fade timeout gets changed.
|
---|
| 244 |
|
---|
| 245 | \param e
|
---|
| 246 | WindowEventArgs object.
|
---|
| 247 |
|
---|
| 248 | \return
|
---|
| 249 | Nothing.
|
---|
| 250 | */
|
---|
| 251 | virtual void onFadeTimeChanged(WindowEventArgs& e);
|
---|
| 252 |
|
---|
| 253 | /*!
|
---|
| 254 | \brief
|
---|
| 255 | Event trigger method called just before the tooltip becomes active.
|
---|
| 256 |
|
---|
| 257 | \param e
|
---|
| 258 | WindowEventArgs object.
|
---|
| 259 |
|
---|
| 260 | \return
|
---|
| 261 | Nothing.
|
---|
| 262 | */
|
---|
| 263 | virtual void onTooltipActive(WindowEventArgs& e);
|
---|
| 264 |
|
---|
| 265 | /*!
|
---|
| 266 | \brief
|
---|
| 267 | Event trigger method called just after the tooltip is deactivated.
|
---|
| 268 |
|
---|
| 269 | \param e
|
---|
| 270 | WindowEventArgs object.
|
---|
| 271 |
|
---|
| 272 | \return
|
---|
| 273 | Nothing.
|
---|
| 274 | */
|
---|
| 275 | virtual void onTooltipInactive(WindowEventArgs& e);
|
---|
| 276 |
|
---|
| 277 |
|
---|
| 278 | /************************************************************************
|
---|
| 279 | Overridden from Window.
|
---|
| 280 | ************************************************************************/
|
---|
| 281 | void updateSelf(float elapsed);
|
---|
| 282 | void onMouseEnters(MouseEventArgs& e);
|
---|
| 283 | void onTextChanged(WindowEventArgs& e);
|
---|
| 284 |
|
---|
| 285 | /************************************************************************
|
---|
| 286 | Enumerations
|
---|
| 287 | ************************************************************************/
|
---|
| 288 | /*!
|
---|
| 289 | \brief
|
---|
| 290 | states for tooltip
|
---|
| 291 | */
|
---|
| 292 | enum TipState
|
---|
| 293 | {
|
---|
| 294 | Inactive, //!< Tooltip is currently inactive.
|
---|
| 295 | Active, //!< Tooltip is currently displayed and active.
|
---|
| 296 | FadeIn, //!< Tooltip is currently transitioning from Inactive to Active state.
|
---|
| 297 | FadeOut //!< Tooltip is currently transitioning from Active to Inactive state.
|
---|
| 298 | };
|
---|
| 299 |
|
---|
| 300 | /************************************************************************
|
---|
| 301 | Data fields
|
---|
| 302 | ************************************************************************/
|
---|
| 303 | TipState d_state; //!< Current tooltip state.
|
---|
| 304 | float d_elapsed; //!< Used to track state change timings
|
---|
| 305 | const Window* d_target; //!< Current target Window for this Tooltip.
|
---|
| 306 | float d_hoverTime; //!< tool-tip hover time (seconds mouse must stay stationary before tip shows).
|
---|
| 307 | float d_displayTime; //!< tool-tip display time (seconds that tip is showsn for).
|
---|
| 308 | float d_fadeTime; //!< tool-tip fade time (seconds it takes for tip to fade in and/or out).
|
---|
| 309 |
|
---|
| 310 | private:
|
---|
| 311 | /*************************************************************************
|
---|
| 312 | Static Properties for this class
|
---|
| 313 | *************************************************************************/
|
---|
| 314 | static TooltipProperties::HoverTime d_hoverTimeProperty;
|
---|
| 315 | static TooltipProperties::DisplayTime d_displayTimeProperty;
|
---|
| 316 | static TooltipProperties::FadeTime d_fadeTimeProperty;
|
---|
| 317 |
|
---|
| 318 | /*************************************************************************
|
---|
| 319 | Private methods
|
---|
| 320 | *************************************************************************/
|
---|
| 321 | void addTooltipProperties(void);
|
---|
| 322 | };
|
---|
| 323 |
|
---|
| 324 | } // End of CEGUI namespace section
|
---|
| 325 |
|
---|
| 326 |
|
---|
| 327 | #endif // end of guard _CEGUITooltip_h_
|
---|