Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
IGUIScrollBarOwner.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2009 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 IGUIScrollBarOwner
20 */
21 
22 #include "precompiled.h"
23 #include "GUI.h"
24 
25 
26 //-------------------------------------------------------------------
27 // Constructor / Destructor
28 //-------------------------------------------------------------------
30 {
31 }
32 
34 {
35  // Delete scroll-bars
36  std::vector<IGUIScrollBar*>::iterator it;
37  for (it=m_ScrollBars.begin(); it!=m_ScrollBars.end(); ++it)
38  {
39  delete *it;
40  }
41 }
42 
44 {
46 
47  std::vector<IGUIScrollBar*>::iterator it;
48  for (it=m_ScrollBars.begin(); it!=m_ScrollBars.end(); ++it)
49  {
50  (*it)->SetBarPressed(false);
51  }
52 }
53 
55 {
56  scrollbar->SetHostObject(this);
57  scrollbar->SetGUI(GetGUI());
58  m_ScrollBars.push_back(scrollbar);
59 }
60 
62 {
63  if (!GetGUI())
64  {
65  // TODO Gee: Output in log
66  return NULL;
67  }
68 
69  std::map<CStr, SGUIScrollBarStyle>::const_iterator it = GetGUI()->m_ScrollBarStyles.find(style);
70  if (it == GetGUI()->m_ScrollBarStyles.end())
71  {
72  // TODO Gee: Output in log
73  return NULL;
74  }
75 
76  return &it->second;
77 }
78 
80 {
81  std::vector<IGUIScrollBar*>::iterator it;
82  for (it=m_ScrollBars.begin(); it!=m_ScrollBars.end(); ++it)
83  {
84  (*it)->HandleMessage(Message);
85  }
86 }
87 
89 {
90  std::vector<IGUIScrollBar*>::iterator it;
91  for (it=m_ScrollBars.begin(); it!=m_ScrollBars.end(); ++it)
92  {
93  (*it)->Draw();
94  }
95 }
virtual void ResetStates()
Reset internal state of this object.
Definition: IGUIObject.h:381
virtual const SGUIScrollBarStyle * GetScrollBarStyle(const CStr &style) const
Interface for the m_ScrollBar to use.
The GUI Scroll-bar style.
Definition: IGUIScrollBar.h:57
void SetGUI(CGUI *pGUI)
Set GUI pointer.
std::vector< IGUIScrollBar * > m_ScrollBars
Predominately you will only have one, but you can have as many as you like.
virtual void AddScrollBar(IGUIScrollBar *scrollbar)
Add a scroll-bar.
virtual void Draw()
Draws the object.
void SetHostObject(IGUIScrollBarOwner *pOwner)
Set host object, must be done almost at creation of scroll bar.
CGUI * GetGUI()
Definition: IGUIObject.h:388
virtual void ResetStates()
std::map< CStr, SGUIScrollBarStyle > m_ScrollBarStyles
Definition: CGUI.h:679
The GUI Scroll-bar, used everywhere there is a scroll-bar in the game.
Message send to IGUIObject::HandleMessage() in order to give life to Objects manually with a derived ...
Definition: GUIbase.h:106
virtual void HandleMessage(SGUIMessage &Message)