Crazy Eddie's GUI System  0.8.4
Tooltip.h
00001 /***********************************************************************
00002     created:    21/2/2005
00003     author:     Paul D Turner
00004 *************************************************************************/
00005 /***************************************************************************
00006  *   Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
00007  *
00008  *   Permission is hereby granted, free of charge, to any person obtaining
00009  *   a copy of this software and associated documentation files (the
00010  *   "Software"), to deal in the Software without restriction, including
00011  *   without limitation the rights to use, copy, modify, merge, publish,
00012  *   distribute, sublicense, and/or sell copies of the Software, and to
00013  *   permit persons to whom the Software is furnished to do so, subject to
00014  *   the following conditions:
00015  *
00016  *   The above copyright notice and this permission notice shall be
00017  *   included in all copies or substantial portions of the Software.
00018  *
00019  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00020  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00021  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00022  *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
00023  *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00024  *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00025  *   OTHER DEALINGS IN THE SOFTWARE.
00026  ***************************************************************************/
00027 #ifndef _CEGUITooltip_h_
00028 #define _CEGUITooltip_h_
00029 
00030 #include "../Window.h"
00031 
00032 #if defined(_MSC_VER)
00033 #       pragma warning(push)
00034 #       pragma warning(disable : 4251)
00035 #endif
00036 
00037 // Start of CEGUI namespace section
00038 namespace CEGUI
00039 {
00044     class CEGUIEXPORT TooltipWindowRenderer : public WindowRenderer
00045     {
00046     public:
00051         TooltipWindowRenderer(const String& name);
00052 
00061         virtual Sizef getTextSize() const = 0;
00062     };
00063 
00079     class CEGUIEXPORT Tooltip : public Window
00080     {
00081     public:
00082         /*************************************************************************
00083             Constants
00084         *************************************************************************/
00085         static const String WidgetTypeName;                 
00086         static const String EventNamespace;                 
00087 
00092         static const String EventHoverTimeChanged;
00098         static const String EventDisplayTimeChanged;
00104         static const String EventFadeTimeChanged;
00110         static const String EventTooltipActive;
00115         static const String EventTooltipInactive;
00120         static const String EventTooltipTransition;
00121 
00122         /************************************************************************
00123             Object Construction and Destruction
00124         ************************************************************************/
00129         Tooltip(const String& type, const String& name);
00130 
00135         ~Tooltip(void);
00136 
00137         /************************************************************************
00138             Public interface
00139         ************************************************************************/
00151         void setTargetWindow(Window* wnd);
00152 
00160         const Window* getTargetWindow();
00161 
00170         void resetTimer(void);
00171 
00180         float getHoverTime(void) const;
00181 
00193         void setDisplayTime(float seconds);
00194 
00206         void setHoverTime(float seconds);
00207 
00216         float getDisplayTime(void) const;
00217 
00225         void positionSelf(void);
00226 
00234         void sizeSelf(void);
00235 
00244         Sizef getTextSize() const;
00245 
00254         virtual Sizef getTextSize_impl() const;
00255 
00256     protected:
00257         /*************************************************************************
00258             Implementation Methods
00259         *************************************************************************/
00260         // methods to perform processing for each of the widget states
00261         void doActiveState(float elapsed);
00262         void doInactiveState(float elapsed);
00263 
00264         // methods to switch widget states
00265         void switchToInactiveState(void);
00266         void switchToActiveState(void);
00267 
00268         // validate window renderer
00269         virtual bool validateWindowRenderer(const WindowRenderer* renderer) const;
00270 
00271         /*************************************************************************
00272             Event triggers
00273         *************************************************************************/
00281         virtual void onHoverTimeChanged(WindowEventArgs& e);
00282 
00290         virtual void onDisplayTimeChanged(WindowEventArgs& e);
00291 
00299         virtual void onTooltipActive(WindowEventArgs& e);
00300 
00308         virtual void onTooltipInactive(WindowEventArgs& e);
00309 
00317         virtual void onTooltipTransition(WindowEventArgs& e);
00318 
00319 
00320         /************************************************************************
00321             Overridden from Window.
00322         ************************************************************************/
00323         void updateSelf(float elapsed);
00324         void onHidden(WindowEventArgs& e);
00325         void onMouseEnters(MouseEventArgs& e);
00326         void onTextChanged(WindowEventArgs& e);
00327 
00328         /************************************************************************
00329             Data fields
00330         ************************************************************************/
00331         bool        d_active;       
00332         float       d_elapsed;      
00333         const Window* d_target;     
00334         float       d_hoverTime;    
00335         float       d_displayTime;  
00336         float       d_fadeTime;     
00337 
00338         bool d_inPositionSelf;
00339 
00340     private:
00341         /*************************************************************************
00342             Private methods
00343         *************************************************************************/
00344         void addTooltipProperties(void);
00345     };
00346 } // End of  CEGUI namespace section
00347 
00348 #if defined(_MSC_VER)
00349 #       pragma warning(pop)
00350 #endif
00351 
00352 #endif  // end of guard _CEGUITooltip_h_
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends