Crazy Eddies GUI System  0.7.6
CEGUITooltip.h
00001 /***********************************************************************
00002     filename:   CEGUITooltip.h
00003     created:    21/2/2005
00004     author:     Paul D Turner
00005 *************************************************************************/
00006 /***************************************************************************
00007  *   Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
00008  *
00009  *   Permission is hereby granted, free of charge, to any person obtaining
00010  *   a copy of this software and associated documentation files (the
00011  *   "Software"), to deal in the Software without restriction, including
00012  *   without limitation the rights to use, copy, modify, merge, publish,
00013  *   distribute, sublicense, and/or sell copies of the Software, and to
00014  *   permit persons to whom the Software is furnished to do so, subject to
00015  *   the following conditions:
00016  *
00017  *   The above copyright notice and this permission notice shall be
00018  *   included in all copies or substantial portions of the Software.
00019  *
00020  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00021  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00022  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00023  *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
00024  *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00025  *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00026  *   OTHER DEALINGS IN THE SOFTWARE.
00027  ***************************************************************************/
00028 #ifndef _CEGUITooltip_h_
00029 #define _CEGUITooltip_h_
00030 
00031 #include "../CEGUIWindow.h"
00032 #include "CEGUITooltipProperties.h"
00033 
00034 #if defined(_MSC_VER)
00035 #       pragma warning(push)
00036 #       pragma warning(disable : 4251)
00037 #endif
00038 
00039 // Start of CEGUI namespace section
00040 namespace CEGUI
00041 {
00046     class CEGUIEXPORT TooltipWindowRenderer : public WindowRenderer
00047     {
00048     public:
00053         TooltipWindowRenderer(const String& name);
00054 
00063         virtual Size getTextSize() const = 0;
00064     };
00065 
00081     class CEGUIEXPORT Tooltip : public Window
00082     {
00083     public:
00084         /*************************************************************************
00085             Constants
00086         *************************************************************************/
00087         static const String WidgetTypeName;                 
00088         static const String EventNamespace;                 
00089 
00094         static const String EventHoverTimeChanged;
00100         static const String EventDisplayTimeChanged;
00106         static const String EventFadeTimeChanged;
00112         static const String EventTooltipActive;
00117         static const String EventTooltipInactive;
00118 
00119         /************************************************************************
00120             Object Construction and Destruction
00121         ************************************************************************/
00126         Tooltip(const String& type, const String& name);
00127 
00132         ~Tooltip(void);
00133 
00134         /************************************************************************
00135             Public interface
00136         ************************************************************************/
00148         void setTargetWindow(Window* wnd);
00149 
00157         const Window* getTargetWindow();
00158 
00167         void resetTimer(void);
00168 
00177         float getHoverTime(void) const;
00178 
00190         void setDisplayTime(float seconds);
00191 
00200         float getFadeTime(void) const;
00201 
00213         void setHoverTime(float seconds);
00214 
00223         float getDisplayTime(void) const;
00224 
00236         void setFadeTime(float seconds);
00237 
00245         void positionSelf(void);
00246 
00254         void sizeSelf(void);
00255 
00264         Size getTextSize() const;
00265 
00274         virtual Size getTextSize_impl() const;
00275 
00276     protected:
00277         /*************************************************************************
00278             Implementation Methods
00279         *************************************************************************/
00280         // methods to perform processing for each of the widget states
00281         void doActiveState(float elapsed);
00282         void doInactiveState(float elapsed);
00283         void doFadeInState(float elapsed);
00284         void doFadeOutState(float elapsed);
00285 
00286         // methods to switch widget states
00287         void switchToInactiveState(void);
00288         void switchToActiveState(void);
00289         void switchToFadeInState(void);
00290         void switchToFadeOutState(void);
00291 
00292 
00303                 virtual bool    testClassName_impl(const String& class_name) const
00304                 {
00305                         if (class_name=="Tooltip")      return true;
00306                         return Window::testClassName_impl(class_name);
00307                 }
00308 
00309         // validate window renderer
00310         virtual bool validateWindowRenderer(const String& name) const
00311         {
00312             return (name == "Tooltip");
00313         }
00314 
00315         /*************************************************************************
00316             Event triggers
00317         *************************************************************************/
00328         virtual void onHoverTimeChanged(WindowEventArgs& e);
00329 
00340         virtual void onDisplayTimeChanged(WindowEventArgs& e);
00341 
00352         virtual void onFadeTimeChanged(WindowEventArgs& e);
00353 
00364         virtual void onTooltipActive(WindowEventArgs& e);
00365 
00376         virtual void onTooltipInactive(WindowEventArgs& e);
00377 
00378 
00379         /************************************************************************
00380             Overridden from Window.
00381         ************************************************************************/
00382         void updateSelf(float elapsed);
00383         void onMouseEnters(MouseEventArgs& e);
00384         void onTextChanged(WindowEventArgs& e);
00385 
00386         /************************************************************************
00387             Enumerations
00388         ************************************************************************/
00393         enum TipState
00394         {
00395             Inactive,   
00396             Active,     
00397             FadeIn,     
00398             FadeOut     
00399         };
00400 
00401         /************************************************************************
00402             Data fields
00403         ************************************************************************/
00404         TipState    d_state;        
00405         float       d_elapsed;      
00406         const Window* d_target;     
00407         float       d_hoverTime;    
00408         float       d_displayTime;  
00409         float       d_fadeTime;     
00410 
00411         bool d_inPositionSelf;
00412 
00413     private:
00414         /*************************************************************************
00415             Static Properties for this class
00416         *************************************************************************/
00417         static TooltipProperties::HoverTime      d_hoverTimeProperty;
00418         static TooltipProperties::DisplayTime    d_displayTimeProperty;
00419         static TooltipProperties::FadeTime       d_fadeTimeProperty;
00420 
00421         /*************************************************************************
00422             Private methods
00423         *************************************************************************/
00424         void addTooltipProperties(void);
00425     };
00426 
00427 
00428 } // End of  CEGUI namespace section
00429 
00430 
00431 #if defined(_MSC_VER)
00432 #       pragma warning(pop)
00433 #endif
00434 
00435 #endif  // end of guard _CEGUITooltip_h_