2009-04-18 19:00:33 +02:00
|
|
|
/* Copyright (C) 2009 Wildfire Games.
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2003-12-27 07:26:03 +01:00
|
|
|
/*
|
|
|
|
IGUIScrollBarOwner
|
|
|
|
*/
|
|
|
|
|
2004-06-03 20:38:14 +02:00
|
|
|
#include "precompiled.h"
|
2003-12-27 07:26:03 +01:00
|
|
|
#include "GUI.h"
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
// Constructor / Destructor
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
IGUIScrollBarOwner::IGUIScrollBarOwner()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
IGUIScrollBarOwner::~IGUIScrollBarOwner()
|
|
|
|
{
|
|
|
|
// Delete scroll-bars
|
2008-07-13 23:22:03 +02:00
|
|
|
std::vector<IGUIScrollBar*>::iterator it;
|
2003-12-27 07:26:03 +01:00
|
|
|
for (it=m_ScrollBars.begin(); it!=m_ScrollBars.end(); ++it)
|
|
|
|
{
|
|
|
|
delete *it;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void IGUIScrollBarOwner::ResetStates()
|
|
|
|
{
|
|
|
|
IGUIObject::ResetStates();
|
|
|
|
|
2008-07-13 23:22:03 +02:00
|
|
|
std::vector<IGUIScrollBar*>::iterator it;
|
2003-12-27 07:26:03 +01:00
|
|
|
for (it=m_ScrollBars.begin(); it!=m_ScrollBars.end(); ++it)
|
|
|
|
{
|
|
|
|
(*it)->SetBarPressed(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void IGUIScrollBarOwner::AddScrollBar(IGUIScrollBar * scrollbar)
|
|
|
|
{
|
|
|
|
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
|
|
|
|
2009-07-28 18:59:19 +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
|
|
|
}
|
|
|
|
|
|
|
|
void IGUIScrollBarOwner::HandleMessage(const SGUIMessage &Message)
|
|
|
|
{
|
2008-07-13 23:22:03 +02:00
|
|
|
std::vector<IGUIScrollBar*>::iterator it;
|
2003-12-27 07:26:03 +01:00
|
|
|
for (it=m_ScrollBars.begin(); it!=m_ScrollBars.end(); ++it)
|
|
|
|
{
|
|
|
|
(*it)->HandleMessage(Message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void IGUIScrollBarOwner::Draw()
|
|
|
|
{
|
2008-07-13 23:22:03 +02:00
|
|
|
std::vector<IGUIScrollBar*>::iterator it;
|
2003-12-27 07:26:03 +01:00
|
|
|
for (it=m_ScrollBars.begin(); it!=m_ScrollBars.end(); ++it)
|
|
|
|
{
|
|
|
|
(*it)->Draw();
|
|
|
|
}
|
2004-06-11 04:14:18 +02:00
|
|
|
}
|