Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9656 in orxonox.OLD for trunk/src/lib/gui/gl/glgui_box.cc


Ignore:
Timestamp:
Aug 4, 2006, 11:01:28 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the proxy bache back with no conflicts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/gui/gl/glgui_box.cc

    r9110 r9656  
    1818#include "glgui_box.h"
    1919#include <cassert>
     20#include "debug.h"
    2021
    2122namespace OrxGui
     
    3637  */
    3738  GLGuiBox::~GLGuiBox()
    38   {}
     39  {
     40    // unpack all the widgets.
     41    while(!this->_children.empty())
     42    {
     43      /// not deleting children here.
     44      this->_children.front()->setParentWidget(NULL);
     45      this->_children.pop_front();
     46    }
     47  }
    3948
    4049  /**
     
    4958  {
    5059    assert (widget != NULL);
    51 
    52     this->children.push_back(widget);
     60    this->_children.push_back(widget);
     61
     62    this->packing(widget);
     63  }
     64
     65
     66  void GLGuiBox::pack(GLGuiWidget* widget, std::list<GLGuiWidget*>::iterator pos)
     67  {
     68    this->_children.insert(pos, widget);
     69    this->packing(widget);
     70  }
     71
     72  void GLGuiBox::pack(GLGuiWidget* widget, unsigned int position)
     73  {
     74    if (this->_children.empty())
     75      this->pack(widget);
     76
     77    unsigned int pos = 0;
     78    std::list<GLGuiWidget*>::iterator it = this->_children.begin();
     79
     80    for (; pos < position; ++pos)
     81    {
     82      if (this->_children.end() == ++it)
     83      {
     84        PRINTF(2)("Reached end of packing list, without getting to the designated position %d (i am at %d)\n", position, pos);
     85        this->pack(widget);
     86      }
     87    }
     88    this->_children.insert(it, widget);
     89    this->packing(widget);
     90  }
     91
     92  void GLGuiBox::pack(GLGuiWidget* widget, const GLGuiWidget* widgetPointer)
     93  {
     94    assert (widget != NULL && widgetPointer != NULL);
     95
     96    std::list<GLGuiWidget*>::iterator it = this->_children.begin();
     97    for (; it != this->_children.end(); ++it)
     98    {
     99      if (widgetPointer == *it)
     100      {
     101        this->_children.insert(it, widget);
     102        this->packing(widget);
     103        return;
     104      }
     105    }
     106    PRINTF(2)("WidgetPointer %p not found, inserting at the end\n", widgetPointer);
     107    this->pack(widget);
     108  }
     109
     110  void GLGuiBox::packFront(GLGuiWidget* widget)
     111  {
     112    this->_children.push_front(widget);
     113    this->packing(widget);
     114  }
     115
     116  void GLGuiBox::packBack(GLGuiWidget* widget)
     117  {
     118    this->pack(widget);
     119  }
     120
     121  void GLGuiBox::packing(GLGuiWidget* widget)
     122  {
    53123    widget->setParentWidget(this);
    54 
    55124    this->resize();
    56125  }
    57126
    58 
    59127  void GLGuiBox::unpack(GLGuiWidget* widget)
    60128  {
    61129    assert(widget != NULL);
    62130
    63     std::vector<GLGuiWidget*>::iterator delWidget = std::find(this->children.begin(), this->children.end(), widget);
    64     if (delWidget != this->children.end())
     131    std::list<GLGuiWidget*>::iterator delWidget = std::find(this->_children.begin(), this->_children.end(), widget);
     132    if (delWidget != this->_children.end())
    65133    {
    66134      (*delWidget)->setParentWidget(NULL);
    67       this->children.erase(delWidget);
     135      this->_children.erase(delWidget);
    68136    }
    69137    this->resize();
     
    72140  void GLGuiBox::clear()
    73141  {
    74     this->children.clear();
     142    this->_children.clear();
    75143    this->resize();
    76144  }
     
    78146  void GLGuiBox::showAll()
    79147  {
    80     std::vector<GLGuiWidget*>::iterator itC = this->children.begin();
    81     while (itC != this->children.end())
     148    std::list<GLGuiWidget*>::iterator itC = this->_children.begin();
     149    while (itC != this->_children.end())
    82150    {
    83151      if ((*itC)->isA(CL_GLGUI_CONTAINER))
     
    93161  void GLGuiBox::hideAll()
    94162  {
    95     std::vector<GLGuiWidget*>::iterator itC = this->children.begin();
    96     while (itC != this->children.end())
     163    std::list<GLGuiWidget*>::iterator itC = this->_children.begin();
     164    while (itC != this->_children.end())
    97165    {
    98166      if ((*itC)->isA(CL_GLGUI_CONTAINER))
     
    112180      float height = borderTop();
    113181      float width = 0.0f;
    114       std::vector<GLGuiWidget*>::iterator widget;
     182      std::list<GLGuiWidget*>::iterator widget;
    115183
    116184      // find out how big the Widgets are.
    117       for (widget = this->children.begin(); widget != this->children.end(); ++widget)
     185      for (widget = this->_children.begin(); widget != this->_children.end(); ++widget)
    118186      {
    119187        (*widget)->setRelCoor2D(borderLeft(), height);
     
    131199      float height = borderTop();
    132200      float width = borderLeft();
    133       std::vector<GLGuiWidget*>::iterator widget;
     201      std::list<GLGuiWidget*>::iterator widget;
    134202
    135203      // find out how big the Widgets are.
    136       for (widget = this->children.begin(); widget != this->children.end(); ++widget)
     204      for (widget = this->_children.begin(); widget != this->_children.end(); ++widget)
    137205      {
    138206        (*widget)->setRelCoor2D(width, borderTop());
     
    149217
    150218    // resize everything.
    151     //for (widget = this->children.begin(); widget != this->children.end(); ++widget)
     219    //for (widget = this->_children.begin(); widget != this->_children.end(); ++widget)
    152220    //{}
    153221  }
Note: See TracChangeset for help on using the changeset viewer.