00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
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
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
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
00097
00102 Tooltip(const String& type, const String& name);
00103
00108 ~Tooltip(void);
00109
00110
00111
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
00255
00256
00257 void doActiveState(float elapsed);
00258 void doInactiveState(float elapsed);
00259 void doFadeInState(float elapsed);
00260 void doFadeOutState(float elapsed);
00261
00262
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
00286 virtual bool validateWindowRenderer(const String& name) const
00287 {
00288 return (name == "Tooltip");
00289 }
00290
00291
00292
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
00357
00358 void updateSelf(float elapsed);
00359 void onMouseEnters(MouseEventArgs& e);
00360 void onTextChanged(WindowEventArgs& e);
00361
00362
00363
00364
00369 enum TipState
00370 {
00371 Inactive,
00372 Active,
00373 FadeIn,
00374 FadeOut
00375 };
00376
00377
00378
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
00390
00391 static TooltipProperties::HoverTime d_hoverTimeProperty;
00392 static TooltipProperties::DisplayTime d_displayTimeProperty;
00393 static TooltipProperties::FadeTime d_fadeTimeProperty;
00394
00395
00396
00397
00398 void addTooltipProperties(void);
00399 };
00400
00401
00402 }
00403
00404
00405 #if defined(_MSC_VER)
00406 # pragma warning(pop)
00407 #endif
00408
00409 #endif // end of guard _CEGUITooltip_h_