Crazy Eddie's GUI System  0.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
widgets/Tooltip.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 "../Window.h"
32 
33 #if defined(_MSC_VER)
34 # pragma warning(push)
35 # pragma warning(disable : 4251)
36 #endif
37 
38 // Start of CEGUI namespace section
39 namespace CEGUI
40 {
45  class CEGUIEXPORT TooltipWindowRenderer : public WindowRenderer
46  {
47  public:
52  TooltipWindowRenderer(const String& name);
53 
62  virtual Sizef getTextSize() const = 0;
63  };
64 
80  class CEGUIEXPORT Tooltip : public Window
81  {
82  public:
83  /*************************************************************************
84  Constants
85  *************************************************************************/
86  static const String WidgetTypeName;
87  static const String EventNamespace;
88 
122 
123  /************************************************************************
124  Object Construction and Destruction
125  ************************************************************************/
130  Tooltip(const String& type, const String& name);
131 
136  ~Tooltip(void);
137 
138  /************************************************************************
139  Public interface
140  ************************************************************************/
152  void setTargetWindow(Window* wnd);
153 
161  const Window* getTargetWindow();
162 
171  void resetTimer(void);
172 
181  float getHoverTime(void) const;
182 
194  void setDisplayTime(float seconds);
195 
207  void setHoverTime(float seconds);
208 
217  float getDisplayTime(void) const;
218 
226  void positionSelf(void);
227 
235  void sizeSelf(void);
236 
245  Sizef getTextSize() const;
246 
255  virtual Sizef getTextSize_impl() const;
256 
257  protected:
258  /*************************************************************************
259  Implementation Methods
260  *************************************************************************/
261  // methods to perform processing for each of the widget states
262  void doActiveState(float elapsed);
263  void doInactiveState(float elapsed);
264 
265  // methods to switch widget states
266  void switchToInactiveState(void);
267  void switchToActiveState(void);
268 
269  // validate window renderer
270  virtual bool validateWindowRenderer(const WindowRenderer* renderer) const;
271 
272  /*************************************************************************
273  Event triggers
274  *************************************************************************/
282  virtual void onHoverTimeChanged(WindowEventArgs& e);
283 
291  virtual void onDisplayTimeChanged(WindowEventArgs& e);
292 
300  virtual void onTooltipActive(WindowEventArgs& e);
301 
309  virtual void onTooltipInactive(WindowEventArgs& e);
310 
318  virtual void onTooltipTransition(WindowEventArgs& e);
319 
320 
321  /************************************************************************
322  Overridden from Window.
323  ************************************************************************/
324  void updateSelf(float elapsed);
325  void onHidden(WindowEventArgs& e);
326  void onMouseEnters(MouseEventArgs& e);
327  void onTextChanged(WindowEventArgs& e);
328 
329  /************************************************************************
330  Data fields
331  ************************************************************************/
332  bool d_active;
333  float d_elapsed;
334  const Window* d_target;
335  float d_hoverTime;
337  float d_fadeTime;
338 
340 
341  private:
342  /*************************************************************************
343  Private methods
344  *************************************************************************/
345  void addTooltipProperties(void);
346  };
347 } // End of CEGUI namespace section
348 
349 #if defined(_MSC_VER)
350 # pragma warning(pop)
351 #endif
352 
353 #endif // end of guard _CEGUITooltip_h_