Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
groupcontrol.h
Go to the documentation of this file.
1 /*
2  * Vega Strike
3  * Copyright (C) 2003 Mike Byron
4  *
5  * http://vegastrike.sourceforge.net/
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20  */
21 
22 #ifndef __GROUPCONTROL_H__
23 #define __GROUPCONTROL_H__
24 
25 #include "gui/control.h"
26 
27 //See cpp file for detailed descriptions of classes, functions, etc.
28 
29 //The group control is simply a collection of controls that can be
30 //manipulated as one.
31 //Note that this Control "owns" the controls under it. They are deleted
32 //when this control is deleted.
33 class GroupControl : public Control
34 {
35 public:
36 //Whether this control has children.
37  virtual bool hasGroupChildren( void )
38  {
39  return true;
40  }
41 
42 //Add a new control to this collection.
43  void addChild( Control *child );
44 
45 //Delete a control that is in this collection.
46 //Returns true if successful.
47  bool deleteControl( Control *c );
48 
49 //Take a control away from this collection and save it elsewhere.
51 
52 //Find a control using its id. NULL returned if none found.
53 //Note that the control may be hidden.
54  Control * findControlById( const std::string &id );
55 
56 //Number of child controls.
57  int childCount( void )
58  {
59  return m_controls.size();
60  }
61 
62 //A control in this group.
64  {
65  return m_controls[index];
66  }
67 
68 //Draw the control.
69 //This should not draw outside its rectangle!
70  virtual void draw( void );
71 
72 //OVERRIDES
73  virtual bool processMouseDown( const InputEvent &event );
74  virtual bool processMouseUp( const InputEvent &event );
75  virtual bool processMouseMove( const InputEvent &event );
76  virtual bool processMouseDrag( const InputEvent &event );
77 
78 //CONSTRUCTION
79 public: GroupControl( void ) {}
80  virtual ~GroupControl( void );
81 
82 //INTERNAL IMPLEMENTATION
83 protected:
84 
85 //VARIABLES
86 protected:
87  std::vector< Control* >m_controls;
88 };
89 
90 #endif //__GROUPCONTROL_H__
91