Scroll.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. #ifndef Scroll_H
  2. #define Scroll_H
  3. #include "OperatingSystem.h"
  4. #include "ReferenceCounter.h"
  5. namespace Framework
  6. {
  7. class Image; //! Image.h
  8. struct MouseEvent; //! MouseEvent.h
  9. struct ScrollData
  10. {
  11. int anzeige;
  12. int max;
  13. int scrollPos;
  14. };
  15. //! The base class for horizontal and vertical scrollbars
  16. class ScrollBar : public virtual ReferenceCounter
  17. {
  18. protected:
  19. ScrollData* data;
  20. int knopfdruck;
  21. int farbe;
  22. int bgFarbe;
  23. bool bg;
  24. int klickScroll;
  25. int mx, my;
  26. bool mp;
  27. bool rend;
  28. public:
  29. //! Constructor
  30. DLLEXPORT ScrollBar();
  31. //! Destructor
  32. DLLEXPORT virtual ~ScrollBar();
  33. //! Sets the foreground color of the scrollbar
  34. //! \param fc The color in A8R8G8B8 format
  35. DLLEXPORT void setFarbe(int fc);
  36. //! Sets the background color of the scrollbar
  37. //! \param fc The color in A8R8G8B8 format
  38. //! \param bgF 1 if a background should be drawn
  39. DLLEXPORT void setBgFarbe(int fc, bool bgF);
  40. //! Updates the scrollbar
  41. //! \param maxGr The maximum size of the window in pixels
  42. //! \param anzeigeGr The displayed size of the window in pixels
  43. DLLEXPORT void update(int maxGr, int anzeigeGr);
  44. //! Sets the scroll speed
  45. //! \param klickScroll The number of pixels scrolled per click
  46. DLLEXPORT void setKlickScroll(int klickScroll);
  47. //! Scrolls to a specific position
  48. //! \param pos The position in pixels in the window from which drawing
  49. //! should start
  50. DLLEXPORT void scroll(int pos);
  51. //! Processes a mouse event
  52. //! \param x The X position of the scroll bar in the window
  53. //! \param y The Y position of the scroll bar in the window
  54. //! \param br The width of the scroll bar
  55. //! \param hi The height of the scroll bar
  56. //! \return 1 if the message was processed. Does not set the
  57. //! processed flag of the mouse event
  58. DLLEXPORT virtual bool doMausMessage(
  59. int x, int y, int br, int hi, MouseEvent& me)
  60. = 0;
  61. //! Returns whether the scrollbar has changed since the last call of
  62. //! this function
  63. DLLEXPORT bool getRend();
  64. //! Draws the scrollbar
  65. //! \param x The X position of the scroll bar
  66. //! \param y The Y position of the scroll bar
  67. //! \param br The width of the scroll bar
  68. //! \param hi The height of the scroll bar
  69. //! \param zRObj The image to draw into
  70. DLLEXPORT virtual void render(
  71. int x, int y, int br, int hi, Image& zRObj) const = 0;
  72. //! Returns a pointer to the scroll data
  73. DLLEXPORT ScrollData* getScrollData() const;
  74. //! Returns the scroll speed. The number of pixels scrolled per click
  75. DLLEXPORT int getKlickScroll() const;
  76. //! Returns the foreground color of the scrollbar
  77. DLLEXPORT int getFarbe() const;
  78. //! Returns the background color of the scrollbar
  79. DLLEXPORT int getBgFarbe() const;
  80. //! Returns the current scroll position
  81. DLLEXPORT int getScroll() const;
  82. };
  83. //! A vertical scrollbar, as used in some 2D GUI drawings of the
  84. //! framework
  85. class VScrollBar : public ScrollBar
  86. {
  87. public:
  88. //! Constructor
  89. DLLEXPORT VScrollBar();
  90. //! Destructor
  91. DLLEXPORT virtual ~VScrollBar();
  92. //! Processes a mouse event
  93. //! \param x The X position of the scroll bar in the window
  94. //! \param y The Y position of the scroll bar in the window
  95. //! \param br The width of the scroll bar
  96. //! \param hi The height of the scroll bar
  97. //! \return 1 if the message was processed. Does not set the
  98. //! processed flag of the mouse event
  99. DLLEXPORT bool doMausMessage(
  100. int x, int y, int br, int hi, MouseEvent& me) override;
  101. //! Draws the scrollbar
  102. //! \param x The X position of the scroll bar
  103. //! \param y The Y position of the scroll bar
  104. //! \param br The width of the scroll bar
  105. //! \param hi The height of the scroll bar
  106. //! \param zRObj The image to draw into
  107. DLLEXPORT void render(
  108. int x, int y, int br, int hi, Image& zRObj) const override;
  109. };
  110. //! A horizontal scrollbar, as used in some 2D GUI drawings of the
  111. //! framework
  112. class HScrollBar : public ScrollBar
  113. {
  114. public:
  115. //! Constructor
  116. DLLEXPORT HScrollBar();
  117. //! Destructor
  118. DLLEXPORT virtual ~HScrollBar();
  119. //! Processes a mouse event
  120. //! \param x The X position of the scroll bar in the window
  121. //! \param y The Y position of the scroll bar in the window
  122. //! \param br The width of the scroll bar
  123. //! \param hi The height of the scroll bar
  124. //! \return 1 if the message was processed. Does not set the
  125. //! processed flag of the mouse event
  126. DLLEXPORT bool doMausMessage(
  127. int x, int y, int br, int hi, MouseEvent& me) override;
  128. //! Draws the scrollbar
  129. //! \param x The X position of the scroll bar
  130. //! \param y The Y position of the scroll bar
  131. //! \param br The width of the scroll bar
  132. //! \param hi The height of the scroll bar
  133. //! \param zRObj The image to draw into
  134. DLLEXPORT void render(
  135. int x, int y, int br, int hi, Image& zRObj) const override;
  136. };
  137. } // namespace Framework
  138. #endif