|
osgEarth 2.1.1
|
Inheritance diagram for osgEarth::Util::Controls::Grid:
Collaboration diagram for osgEarth::Util::Controls::Grid:Public Member Functions | |
| Grid () | |
| void | setControl (int col, int row, Control *control) |
| unsigned | getNumRows () const |
| unsigned | getNumColumns () const |
| virtual void | addControl (Control *control, int index=-1) |
| virtual const ControlList & | children () const |
| virtual void | clearControls () |
| virtual void | addControls (const ControlVector &controls) |
| virtual void | calcSize (const ControlContext &context, osg::Vec2f &out_size) |
| virtual void | calcFill (const ControlContext &context) |
| virtual void | calcPos (const ControlContext &context, const osg::Vec2f &cursor, const osg::Vec2f &parentSize) |
| virtual void | draw (const ControlContext &context, DrawableList &drawables) |
Private Types | |
| typedef std::vector < osg::ref_ptr< Control > > | Row |
| typedef std::vector< Row > | RowVector |
Private Member Functions | |
| osg::ref_ptr< Control > & | cell (int col, int row) |
| void | expandToInclude (int cols, int rows) |
Private Attributes | |
| RowVector | _rows |
| ControlList | _children |
| std::vector< float > | _rowHeights |
| std::vector< float > | _colWidths |
typedef std::vector< osg::ref_ptr<Control> > osgEarth::Util::Controls::Grid::Row [private] |
typedef std::vector< Row > osgEarth::Util::Controls::Grid::RowVector [private] |
| Grid::Grid | ( | ) |
Definition at line 1501 of file Controls.cpp.
{
//nop
}
| void Grid::addControl | ( | Control * | control, |
| int | index = -1 |
||
| ) | [virtual] |
Implements osgEarth::Util::Controls::Container.
Definition at line 1555 of file Controls.cpp.
{
// creates a new row and puts the control in its first column
setControl( 0, _rows.size(), control );
}
Here is the call graph for this function:| void Grid::addControls | ( | const ControlVector & | controls | ) | [virtual] |
Reimplemented from osgEarth::Util::Controls::Container.
Definition at line 1562 of file Controls.cpp.
{
unsigned row = _rows.size();
unsigned col = 0;
for( ControlVector::const_iterator i = controls.begin(); i != controls.end(); ++i, ++col )
{
if ( i->valid() )
{
setControl( col, row, i->get() );
}
}
}
Here is the call graph for this function:| void Grid::calcFill | ( | const ControlContext & | context | ) | [virtual] |
Reimplemented from osgEarth::Util::Controls::Container.
Definition at line 1641 of file Controls.cpp.
{
Container::calcFill( cx );
int numRows = _rows.size();
int numCols = numRows > 0 ? _rows[0].size() : 0;
for( int r=0; r<numRows; ++r )
{
for( int c=0; c<numCols; ++c ) //<_rows[r].size(); ++c )
{
Control* child = cell(c,r).get();
if ( child )
{
if ( child->horizFill() )
renderWidth(child) = _colWidths[c] - child->margin().x();
if ( child->vertFill() )
renderHeight(child) = _rowHeights[r] - child->margin().y();
}
}
}
//Container::calcFill( cx );
}
Here is the call graph for this function:| void Grid::calcPos | ( | const ControlContext & | context, |
| const osg::Vec2f & | cursor, | ||
| const osg::Vec2f & | parentSize | ||
| ) | [virtual] |
Reimplemented from osgEarth::Util::Controls::Container.
Definition at line 1668 of file Controls.cpp.
{
Container::calcPos( cx, cursor, parentSize );
int numRows = _rows.size();
int numCols = numRows > 0 ? _rows[0].size() : 0;
osg::Vec2f childCursor = _renderPos;
for( int r=0; r<numRows; ++r )
{
for( int c=0; c<numCols; ++c )
{
Control* child = cell(c,r).get();
if ( child )
{
osg::Vec2f cellSize( _colWidths[c], _rowHeights[r] );
child->calcPos( cx, childCursor, cellSize );
}
childCursor.x() += _colWidths[c] + childSpacing();
}
childCursor.x() = _renderPos.x();
childCursor.y() += _rowHeights[r] + childSpacing();
}
}
Here is the call graph for this function:| void Grid::calcSize | ( | const ControlContext & | context, |
| osg::Vec2f & | out_size | ||
| ) | [virtual] |
Reimplemented from osgEarth::Util::Controls::Container.
Definition at line 1586 of file Controls.cpp.
{
if ( visible() == true )
{
_renderSize.set( 0, 0 );
int numRows = _rows.size();
int numCols = numRows > 0 ? _rows[0].size() : 0;
_rowHeights.assign( numRows, 0.0f );
_colWidths.assign( numCols, 0.0f );
if ( numRows > 0 && numCols > 0 )
{
for( int r=0; r<numRows; ++r )
{
//for( int c=0; c<_rows[r].size(); ++c )
for( int c=0; c<numCols; ++c )
{
Control* child = cell(c,r).get();
if ( child )
{
osg::Vec2f childSize;
child->calcSize( cx, childSize );
if ( childSize.x() > _colWidths[c] )
_colWidths[c] = childSize.x();
if ( childSize.y() > _rowHeights[r] )
_rowHeights[r] = childSize.y();
}
}
}
for( int c=0; c<numCols; ++c )
_renderSize.x() += _colWidths[c];
_renderSize.x() += childSpacing() * (numCols-1);
for( int r=0; r<numRows; ++r )
_renderSize.y() += _rowHeights[r];
_renderSize.y() += childSpacing() * (numRows-1);
}
_renderSize.set(
_renderSize.x() + padding().x(),
_renderSize.y() + padding().y() );
out_size.set(
_renderSize.x() + margin().x(),
_renderSize.y() + margin().y() );
Container::calcSize( cx, out_size );
}
}
Here is the call graph for this function:| osg::ref_ptr< Control > & Grid::cell | ( | int | col, |
| int | row | ||
| ) | [private] |
Definition at line 1530 of file Controls.cpp.
{
return _rows[row][col];
}
Here is the caller graph for this function:| virtual const ControlList& osgEarth::Util::Controls::Grid::children | ( | ) | const [inline, virtual] |
Implements osgEarth::Util::Controls::Container.
Definition at line 538 of file Controls.
{ return _children; }
| void Grid::clearControls | ( | ) | [virtual] |
Implements osgEarth::Util::Controls::Container.
Definition at line 1576 of file Controls.cpp.
{
_rows.clear();
_children.clear();
_rowHeights.clear();
_colWidths.clear();
dirty();
}
Here is the call graph for this function:
Here is the caller graph for this function:| void Grid::draw | ( | const ControlContext & | context, |
| DrawableList & | drawables | ||
| ) | [virtual] |
Reimplemented from osgEarth::Util::Controls::Container.
Definition at line 1695 of file Controls.cpp.
{
if (visible() == true)
{
Container::draw( cx, out );
for( ControlList::const_iterator i = _children.begin(); i != _children.end(); ++i )
i->get()->draw( cx, out );
}
}
Here is the call graph for this function:| void Grid::expandToInclude | ( | int | cols, |
| int | rows | ||
| ) | [private] |
Definition at line 1536 of file Controls.cpp.
{
while( (int)_rows.size() <= row )
_rows.push_back( Row() );
int maxCol = col;
for( RowVector::iterator i = _rows.begin(); i != _rows.end(); ++i ) {
if ( ((int)i->size())-1 > maxCol )
maxCol = ((int)i->size())-1;
}
for( RowVector::iterator i = _rows.begin(); i != _rows.end(); ++i ) {
Row& row = *i;
while( (int)row.size() <= maxCol )
row.push_back( 0L );
}
}
Here is the caller graph for this function:| unsigned osgEarth::Util::Controls::Grid::getNumColumns | ( | ) | const [inline] |
Definition at line 534 of file Controls.
{ return _colWidths.size(); }
| unsigned osgEarth::Util::Controls::Grid::getNumRows | ( | ) | const [inline] |
| void Grid::setControl | ( | int | col, |
| int | row, | ||
| Control * | control | ||
| ) |
Definition at line 1507 of file Controls.cpp.
{
if ( !child ) return;
expandToInclude( col, row );
Control* oldControl = cell( col, row ).get();
if ( oldControl ) {
ControlList::iterator i = std::find( _children.begin(), _children.end(), oldControl );
if ( i != _children.end() )
_children.erase( i );
}
cell( col, row ) = child;
_children.push_back( child );
child->setParent( this );
applyChildAligns();
dirty();
}
Here is the call graph for this function:
Here is the caller graph for this function:std::vector<float> osgEarth::Util::Controls::Grid::_colWidths [private] |
std::vector<float> osgEarth::Util::Controls::Grid::_rowHeights [private] |
1.7.3