Crazy Eddies GUI System  0.7.7
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 "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;
89 
118 
119  /************************************************************************
120  Object Construction and Destruction
121  ************************************************************************/
126  Tooltip(const String& type, const String& name);
127 
132  ~Tooltip(void);
133 
134  /************************************************************************
135  Public interface
136  ************************************************************************/
148  void setTargetWindow(Window* wnd);
149 
157  const Window* getTargetWindow();
158 
167  void resetTimer(void);
168 
177  float getHoverTime(void) const;
178 
190  void setDisplayTime(float seconds);
191 
200  float getFadeTime(void) const;
201 
213  void setHoverTime(float seconds);
214 
223  float getDisplayTime(void) const;
224 
236  void setFadeTime(float seconds);
237 
245  void positionSelf(void);
246 
254  void sizeSelf(void);
255 
264  Size getTextSize() const;
265 
274  virtual Size getTextSize_impl() const;
275 
276  protected:
277  /*************************************************************************
278  Implementation Methods
279  *************************************************************************/
280  // methods to perform processing for each of the widget states
281  void doActiveState(float elapsed);
282  void doInactiveState(float elapsed);
283  void doFadeInState(float elapsed);
284  void doFadeOutState(float elapsed);
285 
286  // methods to switch widget states
287  void switchToInactiveState(void);
288  void switchToActiveState(void);
289  void switchToFadeInState(void);
290  void switchToFadeOutState(void);
291 
292 
303  virtual bool testClassName_impl(const String& class_name) const
304  {
305  if (class_name=="Tooltip") return true;
306  return Window::testClassName_impl(class_name);
307  }
308 
309  // validate window renderer
310  virtual bool validateWindowRenderer(const String& name) const
311  {
312  return (name == "Tooltip");
313  }
314 
315  /*************************************************************************
316  Event triggers
317  *************************************************************************/
328  virtual void onHoverTimeChanged(WindowEventArgs& e);
329 
340  virtual void onDisplayTimeChanged(WindowEventArgs& e);
341 
352  virtual void onFadeTimeChanged(WindowEventArgs& e);
353 
364  virtual void onTooltipActive(WindowEventArgs& e);
365 
376  virtual void onTooltipInactive(WindowEventArgs& e);
377 
378 
379  /************************************************************************
380  Overridden from Window.
381  ************************************************************************/
382  void updateSelf(float elapsed);
383  void onMouseEnters(MouseEventArgs& e);
384  void onTextChanged(WindowEventArgs& e);
385 
386  /************************************************************************
387  Enumerations
388  ************************************************************************/
393  enum TipState
394  {
398  FadeOut
399  };
400 
401  /************************************************************************
402  Data fields
403  ************************************************************************/
405  float d_elapsed;
406  const Window* d_target;
407  float d_hoverTime;
409  float d_fadeTime;
410 
412 
413  private:
414  /*************************************************************************
415  Static Properties for this class
416  *************************************************************************/
417  static TooltipProperties::HoverTime d_hoverTimeProperty;
418  static TooltipProperties::DisplayTime d_displayTimeProperty;
419  static TooltipProperties::FadeTime d_fadeTimeProperty;
420 
421  /*************************************************************************
422  Private methods
423  *************************************************************************/
424  void addTooltipProperties(void);
425  };
426 
427 
428 } // End of CEGUI namespace section
429 
430 
431 #if defined(_MSC_VER)
432 # pragma warning(pop)
433 #endif
434 
435 #endif // end of guard _CEGUITooltip_h_