Pyrogenesis  trunk
IGUIScrollBarOwner.h
Go to the documentation of this file.
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 #ifndef INCLUDED_IGUISCROLLBAROWNER
19 #define INCLUDED_IGUISCROLLBAROWNER
20 
21 #include "ps/CStrForward.h"
22 
23 #include <memory>
24 #include <vector>
25 
26 class CCanvas2D;
27 struct SGUIMessage;
28 struct SGUIScrollBarStyle;
29 class IGUIScrollBar;
30 class IGUIObject;
31 
32 /**
33  * Base-class this if you want an object to contain
34  * one, or several, scroll-bars.
35  */
37 {
39 
40  friend class IGUIScrollBar;
41 
42 public:
44  virtual ~IGUIScrollBarOwner();
45 
46  virtual void Draw(CCanvas2D& canvas);
47 
48  /**
49  * @see IGUIObject#HandleMessage()
50  */
51  virtual void HandleMessage(SGUIMessage& Message);
52 
53  /**
54  * @see IGUIObject#ResetStates()
55  */
56  virtual void ResetStates();
57 
58  /**
59  * Interface for the m_ScrollBar to use.
60  */
61  virtual const SGUIScrollBarStyle* GetScrollBarStyle(const CStr8& style) const;
62 
63  /**
64  * Add a scroll-bar
65  */
66  virtual void AddScrollBar(std::unique_ptr<IGUIScrollBar> scrollbar);
67 
68  /**
69  * Get Scroll Bar reference (it should be transparent it's actually
70  * pointers).
71  */
72  virtual IGUIScrollBar& GetScrollBar(const int& index)
73  {
74  return *m_ScrollBars[index];
75  }
76 
77  /**
78  * Get the position of the scroll bar at @param index.
79  * Equivalent to GetScrollbar(index).GetPos().
80  */
81  virtual float GetScrollBarPos(const int index) const;
82 
83 protected:
84  /**
85  * Predominately you will only have one, but you can have
86  * as many as you like.
87  */
88  std::vector<std::unique_ptr<IGUIScrollBar>> m_ScrollBars;
89 
90 private:
91  /**
92  * Reference to the IGUIObject.
93  * Private, because we don't want to inherit it in multiple classes.
94  */
96 };
97 
98 #endif // INCLUDED_IGUISCROLLBAROWNER
virtual const SGUIScrollBarStyle * GetScrollBarStyle(const CStr8 &style) const
Interface for the m_ScrollBar to use.
Definition: IGUIScrollBarOwner.cpp:45
virtual IGUIScrollBar & GetScrollBar(const int &index)
Get Scroll Bar reference (it should be transparent it&#39;s actually pointers).
Definition: IGUIScrollBarOwner.h:72
The GUI Scroll-bar style.
Definition: IGUIScrollBar.h:44
GUI object such as a button or an input-box.
Definition: IGUIObject.h:59
virtual float GetScrollBarPos(const int index) const
Get the position of the scroll bar at.
Definition: IGUIScrollBarOwner.cpp:62
IGUIScrollBarOwner(IGUIObject &m_pObject)
Definition: IGUIScrollBarOwner.cpp:26
IGUIObject & m_pObject
Reference to the IGUIObject.
Definition: IGUIScrollBarOwner.h:95
Definition: Canvas2D.h:35
std::vector< std::unique_ptr< IGUIScrollBar > > m_ScrollBars
Predominately you will only have one, but you can have as many as you like.
Definition: IGUIScrollBarOwner.h:88
virtual void AddScrollBar(std::unique_ptr< IGUIScrollBar > scrollbar)
Add a scroll-bar.
Definition: IGUIScrollBarOwner.cpp:39
virtual ~IGUIScrollBarOwner()
NONCOPYABLE(IGUIScrollBarOwner)
virtual void ResetStates()
Definition: IGUIScrollBarOwner.cpp:33
virtual void Draw(CCanvas2D &canvas)
Definition: IGUIScrollBarOwner.cpp:56
The GUI Scroll-bar, used everywhere there is a scroll-bar in the game.
Definition: IGUIScrollBar.h:154
Message send to IGUIObject::HandleMessage() in order to give life to Objects manually with a derived ...
Definition: SGUIMessage.h:67
Base-class this if you want an object to contain one, or several, scroll-bars.
Definition: IGUIScrollBarOwner.h:36
virtual void HandleMessage(SGUIMessage &Message)
Definition: IGUIScrollBarOwner.cpp:50