ToolTip.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #ifndef ToolTip_H
  2. #define ToolTip_H
  3. #include <functional>
  4. #include "Array.h"
  5. #include "Drawing.h"
  6. namespace Framework
  7. {
  8. class Font; //! Font.h
  9. class Image; //! Image.h
  10. class AlphaField; //! AlphaField.h
  11. class Text; //! Text.h
  12. class Border; //! Border.h
  13. struct MouseEvent; //! MouseEvent.h
  14. class Screen; //! Screen.h
  15. #ifdef WIN32
  16. # pragma vtordisp(push, 2)
  17. #endif
  18. class ToolTip : public DrawableBackground
  19. {
  20. private:
  21. RCArray<Drawable>* members;
  22. Punkt size;
  23. double animationSpeed;
  24. double warten;
  25. double wartenCount;
  26. double tval;
  27. bool mausIn;
  28. unsigned char alpha;
  29. bool sichtbar;
  30. bool zeichnen;
  31. bool mausIn2;
  32. Screen* bildschirm;
  33. std::function<void(ToolTip*)> onShow;
  34. std::function<void(ToolTip*)> onHide;
  35. //! Processes mouse messages
  36. //! \param me The event triggered by the mouse input
  37. DLLEXPORT void doMouseEvent(MouseEvent& me, bool userRet) override;
  38. public:
  39. //! Constructor
  40. DLLEXPORT ToolTip(Screen* zSceen);
  41. //! Destructor
  42. DLLEXPORT ~ToolTip();
  43. //! Adds a drawing to the tooltip
  44. //! \param m The new drawing
  45. DLLEXPORT void addMember(Drawable* m);
  46. //! Removes a drawing from the tooltip
  47. //! \param m The drawing
  48. DLLEXPORT void removeMember(Drawable* zM);
  49. //! Removes a drawing from the tooltip
  50. //! \param i The index of the drawing
  51. DLLEXPORT void removeMember(int i);
  52. //! Sets a function that is called when the tooltip is shown
  53. //! \param onShow The function
  54. DLLEXPORT void setShowEvent(std::function<void(ToolTip*)> onShow);
  55. //! Sets a function that is called when the tooltip is no longer shown
  56. //! \param onShow The function
  57. DLLEXPORT void setHideEvent(std::function<void(ToolTip*)> onHide);
  58. //! Sets the number of seconds to wait before the tip appears
  59. //! \param warten The number of seconds
  60. DLLEXPORT void setWarten(double warten);
  61. //! Sets how fast the tip appears
  62. //! \param speed Number of pixels faded in per second. (Default: 250)
  63. DLLEXPORT void setAnimationSpeed(double speed);
  64. //! Sets whether the mouse is inside the drawing the tip belongs to
  65. //! \param mausIn 1 if the mouse is inside the drawing. 0 otherwise
  66. DLLEXPORT void setMausIn(bool mausIn);
  67. //! Resets the counter that tracks when the tip should appear
  68. DLLEXPORT void wartenReset();
  69. //! Indicates that the drawing the tip belongs to was drawn,
  70. //! so the tip could also be drawn
  71. DLLEXPORT void setZeichnen();
  72. //! Updates the tip. Called by the framework
  73. //! \param tickVal The time in seconds since the last call
  74. //! of this function \return 1 if something changed
  75. //! and the image needs to be redrawn. 0 otherwise
  76. DLLEXPORT bool tick(double tickVal) override;
  77. //! Draws the tip to zRObj if it is visible and the associated
  78. //! drawing was also drawn \param zRObj The image to draw into
  79. DLLEXPORT void render(Image& zRObj) override;
  80. //! Returns a pointer to the screen without increased reference counter
  81. //! that this tooltip belongs to
  82. DLLEXPORT Screen* zScreen() const;
  83. //! Returns a specific member (without increased reference counter)
  84. //! \param i The index of the member
  85. DLLEXPORT Drawable* zMember(int i) const;
  86. //! Returns a specific member
  87. //! \param i The index of the member
  88. DLLEXPORT Drawable* getMember(int i) const;
  89. //! Returns the number of drawings belonging to the tooltip
  90. DLLEXPORT int getMemberAnzahl() const;
  91. //! Creates a complete copy of a tooltip
  92. DLLEXPORT Drawable* dublizieren() const override;
  93. //! Checks whether the tooltip is currently visible
  94. DLLEXPORT bool isVisible() const;
  95. };
  96. #ifdef WIN32
  97. # pragma vtordisp(pop)
  98. #endif
  99. } // namespace Framework
  100. #endif