2015-08-21 19:08:41 +02:00
|
|
|
/* Copyright (C) 2015 Wildfire Games.
|
2009-04-18 19:00:33 +02:00
|
|
|
* This file is part of 0 A.D.
|
|
|
|
*
|
|
|
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 0 A.D. is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2004-06-03 20:38:14 +02:00
|
|
|
#include "precompiled.h"
|
2003-12-27 07:26:03 +01:00
|
|
|
|
2015-08-21 19:08:41 +02:00
|
|
|
#include "GUI.h"
|
2003-12-27 07:26:03 +01:00
|
|
|
|
|
|
|
IGUIScrollBarOwner::IGUIScrollBarOwner()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
IGUIScrollBarOwner::~IGUIScrollBarOwner()
|
|
|
|
{
|
2015-08-21 19:08:41 +02:00
|
|
|
for (IGUIScrollBar* const& sb : m_ScrollBars)
|
|
|
|
delete sb;
|
2003-12-27 07:26:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void IGUIScrollBarOwner::ResetStates()
|
|
|
|
{
|
|
|
|
IGUIObject::ResetStates();
|
2015-08-21 19:08:41 +02:00
|
|
|
|
|
|
|
for (IGUIScrollBar* const& sb : m_ScrollBars)
|
|
|
|
sb->SetBarPressed(false);
|
2003-12-27 07:26:03 +01:00
|
|
|
}
|
|
|
|
|
2015-08-21 19:08:41 +02:00
|
|
|
void IGUIScrollBarOwner::AddScrollBar(IGUIScrollBar* scrollbar)
|
2003-12-27 07:26:03 +01:00
|
|
|
{
|
|
|
|
scrollbar->SetHostObject(this);
|
2004-05-29 06:06:50 +02:00
|
|
|
scrollbar->SetGUI(GetGUI());
|
2003-12-27 07:26:03 +01:00
|
|
|
m_ScrollBars.push_back(scrollbar);
|
|
|
|
}
|
2004-08-31 04:09:58 +02:00
|
|
|
|
2015-08-21 19:08:41 +02:00
|
|
|
const SGUIScrollBarStyle* IGUIScrollBarOwner::GetScrollBarStyle(const CStr& style) const
|
2003-12-27 07:26:03 +01:00
|
|
|
{
|
|
|
|
if (!GetGUI())
|
|
|
|
{
|
|
|
|
// TODO Gee: Output in log
|
2004-05-29 06:06:50 +02:00
|
|
|
return NULL;
|
2003-12-27 07:26:03 +01:00
|
|
|
}
|
2009-07-28 18:59:19 +02:00
|
|
|
|
|
|
|
std::map<CStr, SGUIScrollBarStyle>::const_iterator it = GetGUI()->m_ScrollBarStyles.find(style);
|
|
|
|
if (it == GetGUI()->m_ScrollBarStyles.end())
|
2003-12-27 07:26:03 +01:00
|
|
|
{
|
|
|
|
// TODO Gee: Output in log
|
2004-05-29 06:06:50 +02:00
|
|
|
return NULL;
|
2003-12-27 07:26:03 +01:00
|
|
|
}
|
|
|
|
|
2009-07-28 18:59:19 +02:00
|
|
|
return &it->second;
|
2003-12-27 07:26:03 +01:00
|
|
|
}
|
|
|
|
|
2015-08-21 19:08:41 +02:00
|
|
|
void IGUIScrollBarOwner::HandleMessage(SGUIMessage& msg)
|
2003-12-27 07:26:03 +01:00
|
|
|
{
|
2015-08-21 19:08:41 +02:00
|
|
|
for (IGUIScrollBar* const& sb : m_ScrollBars)
|
|
|
|
sb->HandleMessage(msg);
|
2003-12-27 07:26:03 +01:00
|
|
|
}
|
|
|
|
|
2015-08-21 19:08:41 +02:00
|
|
|
void IGUIScrollBarOwner::Draw()
|
2003-12-27 07:26:03 +01:00
|
|
|
{
|
2015-08-21 19:08:41 +02:00
|
|
|
for (IGUIScrollBar* const& sb : m_ScrollBars)
|
|
|
|
sb->Draw();
|
|
|
|
}
|
|
|
|
|
|
|
|
float IGUIScrollBarOwner::GetScrollBarPos(const int index) const
|
|
|
|
{
|
|
|
|
return m_ScrollBars[index]->GetPos();
|
2004-06-11 04:14:18 +02:00
|
|
|
}
|