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 Class Reference

#include <groupcontrol.h>

Inheritance diagram for GroupControl:
Control EventResponder Scroller

Public Member Functions

virtual bool hasGroupChildren (void)
 
void addChild (Control *child)
 
bool deleteControl (Control *c)
 
ControlremoveControlFromGroup (Control *c)
 
ControlfindControlById (const std::string &id)
 
int childCount (void)
 
ControlchildAt (int index)
 
virtual void draw (void)
 
virtual bool processMouseDown (const InputEvent &event)
 
virtual bool processMouseUp (const InputEvent &event)
 
virtual bool processMouseMove (const InputEvent &event)
 
virtual bool processMouseDrag (const InputEvent &event)
 
 GroupControl (void)
 
virtual ~GroupControl (void)
 
- Public Member Functions inherited from Control
virtual Rect rect (void)
 
virtual void setRect (const Rect &r)
 
virtual bool hitTest (const Point &p)
 
virtual bool hidden (void)
 
virtual void setHidden (bool h=true)
 
virtual const std::string & id (void)
 
virtual void setId (const std::string &newId)
 
virtual GFXColor color (void)
 
virtual void setColor (const GFXColor &c)
 
virtual GFXColor outlineColor (void)
 
virtual void setOutlineColor (const GFXColor &c)
 
virtual GFXColor textColor (void)
 
virtual void setTextColor (const GFXColor &c)
 
virtual Font font (void)
 
virtual void setFont (const Font &f)
 
 Control (void)
 
virtual ~Control (void)
 
- Public Member Functions inherited from EventResponder
virtual bool processCommand (const EventCommandId &command, Control *control)
 
virtual bool processKeyDown (const InputEvent &event)
 
virtual bool processKeyUp (const InputEvent &event)
 
virtual void processUnfocus (const InputEvent &event)
 
virtual void sendCommand (const EventCommandId &command, Control *control)
 
virtual void setCommandTarget (EventResponder *responder)
 
virtual void setModal (bool modal)
 
 EventResponder (void)
 
virtual ~EventResponder (void)
 

Protected Attributes

std::vector< Control * > m_controls
 
- Protected Attributes inherited from Control
Rect m_rect
 
std::string m_id
 
GFXColor m_color
 
GFXColor m_outlineColor
 
GFXColor m_textColor
 
Font m_font
 
bool m_hidden
 
- Protected Attributes inherited from EventResponder
bool m_modal
 
EventResponderm_commandTarget
 

Additional Inherited Members

- Protected Member Functions inherited from Control
virtual void drawBackground (void)
 

Detailed Description

Definition at line 33 of file groupcontrol.h.

Constructor & Destructor Documentation

GroupControl::GroupControl ( void  )
inline

Definition at line 79 of file groupcontrol.h.

79 : GroupControl( void ) {}
GroupControl::~GroupControl ( void  )
virtual

Definition at line 198 of file groupcontrol.cpp.

References EventManager::addToDeleteQueue(), i, and m_controls.

199 {
200  for (vector< Control* >::size_type i = 0; i < m_controls.size(); ++i)
202 }

Member Function Documentation

void GroupControl::addChild ( Control child)
int GroupControl::childCount ( void  )
inline

Definition at line 57 of file groupcontrol.h.

References m_controls.

Referenced by Scroller::calcLayout(), Scroller::setButtonColor(), Scroller::setColor(), Scroller::setTextColor(), and Scroller::setThumbColor().

58  {
59  return m_controls.size();
60  }
bool GroupControl::deleteControl ( Control c)

Definition at line 38 of file groupcontrol.cpp.

References EventManager::addToDeleteQueue(), deleteControl(), Control::hasGroupChildren(), and m_controls.

Referenced by deleteControl(), and Window::deleteControl().

39 {
40  std::vector< Control* >::iterator iter;
41  for (iter = m_controls.begin(); iter != m_controls.end(); iter++) {
42  Control *currentControl = *iter;
43  if (c == currentControl) {
44  //Found it in this group.
45  m_controls.erase( iter );
46  EventManager::addToDeleteQueue( currentControl );
47  return true;
48  }
49  if ( currentControl->hasGroupChildren() ) {
50  //Check the children.
51  GroupControl *group = static_cast< GroupControl* > (currentControl);
52  if ( group->deleteControl( c ) )
53  return true;
54  }
55  }
56  return false;
57 }
void GroupControl::draw ( void  )
virtual

Implements Control.

Reimplemented in Scroller.

Definition at line 104 of file groupcontrol.cpp.

References Control::draw(), Control::hidden(), and m_controls.

Referenced by Scroller::draw(), and Window::draw().

105 {
106  std::vector< Control* >::iterator iter;
107  for (iter = m_controls.begin(); iter != m_controls.end(); iter++) {
108  Control *currentControl = *iter;
109  if ( !currentControl->hidden() )
110  //If it's not hidden, draw it.
111  currentControl->draw();
112  }
113 }
Control * GroupControl::findControlById ( const std::string &  id)

Definition at line 83 of file groupcontrol.cpp.

References findControlById(), Control::hasGroupChildren(), Control::id(), and m_controls.

Referenced by findControlById(), and Window::findControlById().

84 {
85  std::vector< Control* >::iterator iter;
86  for (iter = m_controls.begin(); iter != m_controls.end(); iter++) {
87  Control *currentControl = *iter;
88  if (currentControl->id() == id)
89  //Found it in this group.
90  return currentControl;
91  if ( currentControl->hasGroupChildren() ) {
92  //Check the children.
93  GroupControl *group = static_cast< GroupControl* > (currentControl);
94  Control *ret = group->findControlById( id );
95  if (ret)
96  return ret;
97  }
98  }
99  return NULL;
100 }
virtual bool GroupControl::hasGroupChildren ( void  )
inlinevirtual

Reimplemented from Control.

Definition at line 37 of file groupcontrol.h.

38  {
39  return true;
40  }
bool GroupControl::processMouseDown ( const InputEvent event)
virtual

Reimplemented from EventResponder.

Definition at line 116 of file groupcontrol.cpp.

References Control::hasGroupChildren(), Control::hidden(), Control::hitTest(), InputEvent::loc, m_controls, EventResponder::processMouseDown(), processMouseDown(), and EventResponder::processUnfocus().

Referenced by processMouseDown(), and Window::processMouseDown().

117 {
118  std::vector< Control* >::reverse_iterator iter;
119  bool retval = false;
120  //Give this to the appropriate control.
121  for (iter = m_controls.rbegin(); iter != m_controls.rend(); iter++) {
122  Control &control = **iter;
123  if ( !control.hidden() ) {
124  if (control.hasGroupChildren() && !retval) {
125  //Do children first.
126  GroupControl &group = static_cast< GroupControl& > (control);
127  retval = group.processMouseDown( event );
128  }
129  if (control.hitTest( event.loc ) && !retval)
130  retval = control.processMouseDown( event );
131  else
132  control.processUnfocus( event );
133  }
134  }
135  return retval;
136 }
bool GroupControl::processMouseDrag ( const InputEvent event)
virtual

Reimplemented from EventResponder.

Definition at line 178 of file groupcontrol.cpp.

References Control::hasGroupChildren(), Control::hidden(), Control::hitTest(), InputEvent::loc, m_controls, EventResponder::processMouseDrag(), and processMouseDrag().

Referenced by processMouseDrag(), and Window::processMouseDrag().

179 {
180  std::vector< Control* >::reverse_iterator iter;
181  //Give this to the appropriate control.
182  for (iter = m_controls.rbegin(); iter != m_controls.rend(); iter++) {
183  Control &control = **iter;
184  if ( !control.hidden() ) {
185  if ( control.hasGroupChildren() ) {
186  //Do children first.
187  GroupControl &group = static_cast< GroupControl& > (control);
188  if ( group.processMouseDrag( event ) )
189  return true;
190  }
191  if ( control.hitTest( event.loc ) )
192  return control.processMouseDrag( event );
193  }
194  }
195  return false;
196 }
bool GroupControl::processMouseMove ( const InputEvent event)
virtual

Reimplemented from EventResponder.

Definition at line 158 of file groupcontrol.cpp.

References Control::hasGroupChildren(), Control::hidden(), Control::hitTest(), InputEvent::loc, m_controls, EventResponder::processMouseMove(), and processMouseMove().

Referenced by processMouseMove(), and Window::processMouseMove().

159 {
160  std::vector< Control* >::reverse_iterator iter;
161  //Give this to the appropriate control.
162  for (iter = m_controls.rbegin(); iter != m_controls.rend(); iter++) {
163  Control &control = **iter;
164  if ( !control.hidden() ) {
165  if ( control.hasGroupChildren() ) {
166  //Do children first.
167  GroupControl &group = static_cast< GroupControl& > (control);
168  if ( group.processMouseMove( event ) )
169  return true;
170  }
171  if ( control.hitTest( event.loc ) )
172  return control.processMouseMove( event );
173  }
174  }
175  return false;
176 }
bool GroupControl::processMouseUp ( const InputEvent event)
virtual

Reimplemented from EventResponder.

Definition at line 138 of file groupcontrol.cpp.

References Control::hasGroupChildren(), Control::hidden(), Control::hitTest(), InputEvent::loc, m_controls, EventResponder::processMouseUp(), and processMouseUp().

Referenced by processMouseUp(), and Window::processMouseUp().

139 {
140  std::vector< Control* >::reverse_iterator iter;
141  //Give this to the appropriate control.
142  for (iter = m_controls.rbegin(); iter != m_controls.rend(); iter++) {
143  Control &control = **iter;
144  if ( !control.hidden() ) {
145  if ( control.hasGroupChildren() ) {
146  //Do children first.
147  GroupControl &group = static_cast< GroupControl& > (control);
148  if ( group.processMouseUp( event ) )
149  return true;
150  }
151  if ( control.hitTest( event.loc ) )
152  return control.processMouseUp( event );
153  }
154  }
155  return false;
156 }
Control * GroupControl::removeControlFromGroup ( Control c)

Definition at line 60 of file groupcontrol.cpp.

References Control::hasGroupChildren(), m_controls, and removeControlFromGroup().

Referenced by removeControlFromGroup(), and Window::removeControlFromWindow().

61 {
62  std::vector< Control* >::iterator iter;
63  for (iter = m_controls.begin(); iter != m_controls.end(); iter++) {
64  Control *currentControl = *iter;
65  if (c == currentControl) {
66  //Found it in this group.
67  m_controls.erase( iter );
68  return currentControl;
69  }
70  if ( currentControl->hasGroupChildren() ) {
71  //Check the children.
72  GroupControl *group = static_cast< GroupControl* > (currentControl);
73  Control *ret = group->removeControlFromGroup( c );
74  if (ret)
75  return ret;
76  }
77  }
78  return NULL;
79 }

Member Data Documentation


The documentation for this class was generated from the following files: