Line data Source code
1 : /* Copyright (C) 2021 Wildfire Games.
2 : * This file is part of 0 A.D.
3 : *
4 : * 0 A.D. is free software: you can redistribute it and/or modify
5 : * it under the terms of the GNU General Public License as published by
6 : * the Free Software Foundation, either version 2 of the License, or
7 : * (at your option) any later version.
8 : *
9 : * 0 A.D. is distributed in the hope that it will be useful,
10 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 : * GNU General Public License for more details.
13 : *
14 : * You should have received a copy of the GNU General Public License
15 : * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16 : */
17 :
18 : /*
19 : A GUI Scrollbar, this class doesn't present all functionality
20 : to the scrollbar, it just controls the drawing and a wrapper
21 : for interaction with it.
22 : */
23 :
24 : #ifndef INCLUDED_CGUISCROLLBARVERTICAL
25 : #define INCLUDED_CGUISCROLLBARVERTICAL
26 :
27 : #include "IGUIScrollBar.h"
28 :
29 : /**
30 : * Vertical implementation of IGUIScrollBar
31 : *
32 : * @see IGUIScrollBar
33 : */
34 : class CGUIScrollBarVertical : public IGUIScrollBar
35 : {
36 : public:
37 : CGUIScrollBarVertical(CGUI& pGUI);
38 : virtual ~CGUIScrollBarVertical();
39 :
40 : public:
41 : /**
42 : * Draw the scroll-bar
43 : */
44 : virtual void Draw(CCanvas2D& canvas);
45 :
46 : /**
47 : * If an object that contains a scrollbar has got messages, send
48 : * them to the scroll-bar and it will see if the message regarded
49 : * itself.
50 : *
51 : * @see IGUIObject#HandleMessage()
52 : */
53 : virtual void HandleMessage(SGUIMessage& Message);
54 :
55 : /**
56 : * Set m_Pos with g_mouse_x/y input, i.e. when dragging.
57 : */
58 : virtual void SetPosFromMousePos(const CVector2D& mouse);
59 :
60 : /**
61 : * @see IGUIScrollBar#HoveringButtonMinus
62 : */
63 : virtual bool HoveringButtonMinus(const CVector2D& mouse);
64 :
65 : /**
66 : * @see IGUIScrollBar#HoveringButtonPlus
67 : */
68 : virtual bool HoveringButtonPlus(const CVector2D& mouse);
69 :
70 : /**
71 : * Set Right Aligned
72 : * @param align Alignment
73 : */
74 0 : void SetRightAligned(const bool& align) { m_RightAligned = align; }
75 :
76 : /**
77 : * Get the rectangle of the actual BAR.
78 : * @return Rectangle, CRect
79 : */
80 : virtual CRect GetBarRect() const;
81 :
82 : /**
83 : * Get the rectangle of the outline of the scrollbar, every component of the
84 : * scroll-bar should be inside this area.
85 : * @return Rectangle, CRect
86 : */
87 : virtual CRect GetOuterRect() const;
88 :
89 : protected:
90 : /**
91 : * Should the scroll bar proceed to the left or to the right of the m_X value.
92 : * Notice, this has nothing to do with where the owner places it.
93 : */
94 : bool m_RightAligned;
95 : };
96 :
97 : #endif // INCLUDED_CGUISCROLLBARVERTICAL
|