This repository has been archived on 2023-07-11. You can view files and clone it, but cannot push or open issues or pull requests.
MyGameFramework/lib/gwen/gwen_controllist.h

96 lines
1.7 KiB
C
Raw Normal View History

#pragma once
#ifndef GWEN_CONTROLLIST_H
#define GWEN_CONTROLLIST_H
#include <stl/algorithm.h>
namespace Gwen
{
struct Point;
class TextObject;
namespace Controls
{
class Base;
}
namespace Event
{
class Handler;
struct Information;
struct Packet;
typedef const Gwen::Event::Information& Info;
}
template < typename TYPE >
class TEasyList
{
public:
typedef stl::list<TYPE> List;
void Add( TYPE pControl )
{
if ( Contains( pControl ) ) return;
list.push_back( pControl );
}
void Remove( TYPE pControl )
{
list.remove( pControl );
}
void Add( const List& list )
{
for ( typename List::const_iterator it = list.begin(); it != list.end(); ++it )
{
Add( *it );
}
}
void Add( const TEasyList<TYPE>& list )
{
Add( list.list );
}
bool Contains( TYPE pControl ) const
{
typename List::const_iterator it = stl::find( list.begin(), list.end(), pControl );
return it != list.end();
}
inline void Clear()
{
list.clear();
}
List list;
};
class ControlList : public TEasyList<Gwen::Controls::Base*>
{
public:
void Enable();
void Disable();
void Show();
void Hide();
template <typename T> void SetAction( Gwen::Event::Handler* ob, void (T::*f)( Gwen::Event::Info ), const Gwen::Event::Packet& packet ) { SetActionInternal( ob, static_cast<void (Gwen::Event::Handler::*)( Gwen::Event::Info )>(f), packet ); }
void MoveBy( const Gwen::Point& point );
void DoAction();
protected:
void SetActionInternal( Gwen::Event::Handler* pObject, void (Gwen::Event::Handler::*f)( Gwen::Event::Info ), const Gwen::Event::Packet& packet );
};
};
#endif