Crazy Eddies GUI System  0.6.0
CEGUITooltip.h
1 /***********************************************************************
2  filename: CEGUITooltip.h
3  created: 21/2/2005
4  author: Paul D Turner
5 *************************************************************************/
6 /***************************************************************************
7  * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining
10  * a copy of this software and associated documentation files (the
11  * "Software"), to deal in the Software without restriction, including
12  * without limitation the rights to use, copy, modify, merge, publish,
13  * distribute, sublicense, and/or sell copies of the Software, and to
14  * permit persons to whom the Software is furnished to do so, subject to
15  * the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be
18  * included in all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
24  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
25  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26  * OTHER DEALINGS IN THE SOFTWARE.
27  ***************************************************************************/
28 #ifndef _CEGUITooltip_h_
29 #define _CEGUITooltip_h_
30 
31 #include "CEGUIWindow.h"
32 #include "elements/CEGUITooltipProperties.h"
33 
34 #if defined(_MSC_VER)
35 # pragma warning(push)
36 # pragma warning(disable : 4251)
37 #endif
38 
39 // Start of CEGUI namespace section
40 namespace CEGUI
41 {
46  class CEGUIEXPORT TooltipWindowRenderer : public WindowRenderer
47  {
48  public:
53  TooltipWindowRenderer(const String& name);
54 
63  virtual Size getTextSize() const = 0;
64  };
65 
81  class CEGUIEXPORT Tooltip : public Window
82  {
83  public:
84  /*************************************************************************
85  Constants
86  *************************************************************************/
87  static const String WidgetTypeName;
88  static const String EventNamespace;
92  static const String EventTooltipActive;
94 
95  /************************************************************************
96  Object Construction and Destruction
97  ************************************************************************/
102  Tooltip(const String& type, const String& name);
103 
108  ~Tooltip(void);
109 
110  /************************************************************************
111  Public interface
112  ************************************************************************/
124  void setTargetWindow(Window* wnd);
125 
133  const Window* getTargetWindow();
134 
143  void resetTimer(void);
144 
153  float getHoverTime(void) const;
154 
166  void setDisplayTime(float seconds);
167 
176  float getFadeTime(void) const;
177 
189  void setHoverTime(float seconds);
190 
199  float getDisplayTime(void) const;
200 
212  void setFadeTime(float seconds);
213 
221  void positionSelf(void);
222 
230  void sizeSelf(void);
231 
240  Size getTextSize() const;
241 
250  virtual Size getTextSize_impl() const;
251 
252  protected:
253  /*************************************************************************
254  Implementation Methods
255  *************************************************************************/
256  // methods to perform processing for each of the widget states
257  void doActiveState(float elapsed);
258  void doInactiveState(float elapsed);
259  void doFadeInState(float elapsed);
260  void doFadeOutState(float elapsed);
261 
262  // methods to switch widget states
263  void switchToInactiveState(void);
264  void switchToActiveState(void);
265  void switchToFadeInState(void);
266  void switchToFadeOutState(void);
267 
268 
279  virtual bool testClassName_impl(const String& class_name) const
280  {
281  if (class_name=="Tooltip") return true;
282  return Window::testClassName_impl(class_name);
283  }
284 
285  // validate window renderer
286  virtual bool validateWindowRenderer(const String& name) const
287  {
288  return (name == "Tooltip");
289  }
290 
291  /*************************************************************************
292  Event triggers
293  *************************************************************************/
304  virtual void onHoverTimeChanged(WindowEventArgs& e);
305 
316  virtual void onDisplayTimeChanged(WindowEventArgs& e);
317 
328  virtual void onFadeTimeChanged(WindowEventArgs& e);
329 
340  virtual void onTooltipActive(WindowEventArgs& e);
341 
352  virtual void onTooltipInactive(WindowEventArgs& e);
353 
354 
355  /************************************************************************
356  Overridden from Window.
357  ************************************************************************/
358  void updateSelf(float elapsed);
359  void onMouseEnters(MouseEventArgs& e);
360  void onTextChanged(WindowEventArgs& e);
361 
362  /************************************************************************
363  Enumerations
364  ************************************************************************/
369  enum TipState
370  {
374  FadeOut
375  };
376 
377  /************************************************************************
378  Data fields
379  ************************************************************************/
381  float d_elapsed;
382  const Window* d_target;
383  float d_hoverTime;
385  float d_fadeTime;
386 
387  private:
388  /*************************************************************************
389  Static Properties for this class
390  *************************************************************************/
391  static TooltipProperties::HoverTime d_hoverTimeProperty;
392  static TooltipProperties::DisplayTime d_displayTimeProperty;
393  static TooltipProperties::FadeTime d_fadeTimeProperty;
394 
395  /*************************************************************************
396  Private methods
397  *************************************************************************/
398  void addTooltipProperties(void);
399  };
400 
401 
402 } // End of CEGUI namespace section
403 
404 
405 #if defined(_MSC_VER)
406 # pragma warning(pop)
407 #endif
408 
409 #endif // end of guard _CEGUITooltip_h_