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 "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
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
00121
00126 Tooltip(const String& type, const String& name);
00127
00132 ~Tooltip(void);
00133
00134
00135
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
00279
00280
00281 void doActiveState(float elapsed);
00282 void doInactiveState(float elapsed);
00283 void doFadeInState(float elapsed);
00284 void doFadeOutState(float elapsed);
00285
00286
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
00310 virtual bool validateWindowRenderer(const String& name) const
00311 {
00312 return (name == "Tooltip");
00313 }
00314
00315
00316
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
00381
00382 void updateSelf(float elapsed);
00383 void onMouseEnters(MouseEventArgs& e);
00384 void onTextChanged(WindowEventArgs& e);
00385
00386
00387
00388
00393 enum TipState
00394 {
00395 Inactive,
00396 Active,
00397 FadeIn,
00398 FadeOut
00399 };
00400
00401
00402
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 private:
00412
00413
00414
00415 static TooltipProperties::HoverTime d_hoverTimeProperty;
00416 static TooltipProperties::DisplayTime d_displayTimeProperty;
00417 static TooltipProperties::FadeTime d_fadeTimeProperty;
00418
00419
00420
00421
00422 void addTooltipProperties(void);
00423 };
00424
00425
00426 }
00427
00428
00429 #if defined(_MSC_VER)
00430 # pragma warning(pop)
00431 #endif
00432
00433 #endif // end of guard _CEGUITooltip_h_