Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9621 in orxonox.OLD


Ignore:
Timestamp:
Jul 30, 2006, 10:06:46 PM (18 years ago)
Author:
bensch
Message:

better packing modularity in the Box

Location:
branches/proxy/src/lib/gui/gl
Files:
2 edited

Legend:

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

    r9620 r9621  
    1818#include "glgui_box.h"
    1919#include <cassert>
     20#include "debug.h"
    2021
    2122namespace OrxGui
     
    5758  {
    5859    assert (widget != NULL);
    59 
    6060    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, 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        return;
     103      }
     104    }
     105    PRINTF(2)("WidgetPointer %p not found, inserting at the end\n", widgetPointer);
     106    this->pack(widget);
     107    this->packing(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  {
    61123    widget->setParentWidget(this);
    62 
    63124    this->resize();
    64125  }
    65 
    66126
    67127  void GLGuiBox::unpack(GLGuiWidget* widget)
  • branches/proxy/src/lib/gui/gl/glgui_box.h

    r9620 r9621  
    3030
    3131    virtual void pack(GLGuiWidget* widget);
    32     void pack(GLGuiWidget* widget, std::list<GLGuiWidget*>::iterator pos);
    3332    void pack(GLGuiWidget* widget, unsigned int position);
    34     //void
     33    void pack(GLGuiWidget* widget, GLGuiWidget* widgetPointer);
     34    void packFront(GLGuiWidget* widget);
     35    void packBack(GLGuiWidget* widget);
    3536    virtual void unpack(GLGuiWidget* widget);
     37
    3638    virtual void clear();
    3739
     
    4648  private:
    4749    void init();
     50    void packing(GLGuiWidget* widget); // the action executing when packing a widget.
     51    void pack(GLGuiWidget* widget, std::list<GLGuiWidget*>::iterator pos);
     52
     53  private:
     54
    4855
    4956    Orientation                _orientation;
Note: See TracChangeset for help on using the changeset viewer.