Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

inputbutton_group.h

Go to the documentation of this file.
00001 /*
00002         $Id: inputbutton_group.h,v 1.1 2001/03/06 15:09:10 mbn Exp $
00003 
00004         ------------------------------------------------------------------------
00005         ClanLib, the platform independent game SDK.
00006 
00007         This library is distributed under the GNU LIBRARY GENERAL PUBLIC LICENSE
00008         version 2. See COPYING for details.
00009 
00010         For a total list of contributers see CREDITS.
00011 
00012         ------------------------------------------------------------------------
00013 */
00014 
00016 
00017 #ifndef header_inputbutton_group
00018 #define header_inputbutton_group
00019 
00020 #include "../Input/inputbutton.h"
00021 
00022 class CL_InputButton_Group : public CL_InputButton
00023 //: CL_InputButton container class.
00024 // Groups a set of buttons - if either of them are down, CL_InputButton_Groups is down.
00025 {
00026         std::list<CL_InputButton*> buttons;
00027 public:
00028         void add(CL_InputButton *add_button)
00029         {
00030                 buttons.push_back(add_button);
00031         }
00032         //: Adds a input button to the group.
00034 
00035         void remove(CL_InputButton *remove_button)
00036         {
00037                 buttons.remove(remove_button);
00038         }
00039         //: Removes a (previously added) button from the group.
00041 
00042         virtual bool is_pressed()
00043         {
00044                 for (
00045                         std::list<CL_InputButton*>::iterator it = buttons.begin();
00046                         it != buttons.end();
00047                         it++)
00048                 {
00049                         if ((*it)->is_pressed() == true) return true;
00050                 }
00051 
00052                 return false;
00053         }
00054         //: Returns true if just one of the buttons in the button group is down; 
00055         //: false otherwise.
00057 };
00058 
00059 #endif

Generated at Wed Apr 4 19:54:00 2001 for ClanLib by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001