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 "elements/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         static const String EventHoverTimeChanged;          
00090         static const String EventDisplayTimeChanged;        
00091         static const String EventFadeTimeChanged;           
00092         static const String EventTooltipActive;             
00093         static const String EventTooltipInactive;           
00094 
00095         /************************************************************************
00096             Object Construction and Destruction
00097         ************************************************************************/
00102         Tooltip(const String& type, const String& name);
00103 
00108         ~Tooltip(void);
00109 
00110         /************************************************************************
00111             Public interface
00112         ************************************************************************/
00124         void setTargetWindow(Window* wnd);
00125 
00133         const Window* getTargetWindow();
00134 
00143         void resetTimer(void);
00144 
00153         float getHoverTime(void) const;
00154 
00166         void setDisplayTime(float seconds);
00167 
00176         float getFadeTime(void) const;
00177 
00189         void setHoverTime(float seconds);
00190 
00199         float getDisplayTime(void) const;
00200 
00212         void setFadeTime(float seconds);
00213 
00221         void positionSelf(void);
00222 
00230         void sizeSelf(void);
00231 
00240         Size getTextSize() const;
00241 
00250         virtual Size getTextSize_impl() const;
00251 
00252     protected:
00253         /*************************************************************************
00254             Implementation Methods
00255         *************************************************************************/
00256         // methods to perform processing for each of the widget states
00257         void doActiveState(float elapsed);
00258         void doInactiveState(float elapsed);
00259         void doFadeInState(float elapsed);
00260         void doFadeOutState(float elapsed);
00261 
00262         // methods to switch widget states
00263         void switchToInactiveState(void);
00264         void switchToActiveState(void);
00265         void switchToFadeInState(void);
00266         void switchToFadeOutState(void);
00267 
00268 
00279                 virtual bool    testClassName_impl(const String& class_name) const
00280                 {
00281                         if (class_name=="Tooltip")      return true;
00282                         return Window::testClassName_impl(class_name);
00283                 }
00284 
00285         // validate window renderer
00286         virtual bool validateWindowRenderer(const String& name) const
00287         {
00288             return (name == "Tooltip");
00289         }
00290 
00291         /*************************************************************************
00292             Event triggers
00293         *************************************************************************/
00304         virtual void onHoverTimeChanged(WindowEventArgs& e);
00305 
00316         virtual void onDisplayTimeChanged(WindowEventArgs& e);
00317 
00328         virtual void onFadeTimeChanged(WindowEventArgs& e);
00329 
00340         virtual void onTooltipActive(WindowEventArgs& e);
00341 
00352         virtual void onTooltipInactive(WindowEventArgs& e);
00353 
00354 
00355         /************************************************************************
00356             Overridden from Window.
00357         ************************************************************************/
00358         void updateSelf(float elapsed);
00359         void onMouseEnters(MouseEventArgs& e);
00360         void onTextChanged(WindowEventArgs& e);
00361 
00362         /************************************************************************
00363             Enumerations
00364         ************************************************************************/
00369         enum TipState
00370         {
00371             Inactive,   
00372             Active,     
00373             FadeIn,     
00374             FadeOut     
00375         };
00376 
00377         /************************************************************************
00378             Data fields
00379         ************************************************************************/
00380         TipState    d_state;        
00381         float       d_elapsed;      
00382         const Window* d_target;     
00383         float       d_hoverTime;    
00384         float       d_displayTime;  
00385         float       d_fadeTime;     
00386 
00387     private:
00388         /*************************************************************************
00389             Static Properties for this class
00390         *************************************************************************/
00391         static TooltipProperties::HoverTime      d_hoverTimeProperty;
00392         static TooltipProperties::DisplayTime    d_displayTimeProperty;
00393         static TooltipProperties::FadeTime       d_fadeTimeProperty;
00394 
00395         /*************************************************************************
00396             Private methods
00397         *************************************************************************/
00398         void addTooltipProperties(void);
00399     };
00400 
00401 
00402 } // End of  CEGUI namespace section
00403 
00404 
00405 #if defined(_MSC_VER)
00406 #       pragma warning(pop)
00407 #endif
00408 
00409 #endif  // end of guard _CEGUITooltip_h_

Generated on Sat Jun 28 14:35:44 2008 for Crazy Eddies GUI System by  doxygen 1.5.4