#pragma once #ifndef GWEN_CONTROLLIST_H #define GWEN_CONTROLLIST_H #include 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 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& 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 { public: void Enable(); void Disable(); void Show(); void Hide(); template void SetAction( Gwen::Event::Handler* ob, void (T::*f)( Gwen::Event::Info ), const Gwen::Event::Packet& packet ) { SetActionInternal( ob, static_cast(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