Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5393 in orxonox.OLD for trunk/src/lib/gui/gl_gui


Ignore:
Timestamp:
Oct 16, 2005, 2:28:55 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: container-packing

Location:
trunk/src/lib/gui/gl_gui
Files:
6 edited

Legend:

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

    r5391 r5393  
    1818#include "glgui_box.h"
    1919
     20#include "list.h"
     21
    2022using namespace std;
    2123
     
    3638GLGuiBox::~GLGuiBox()
    3739{
    38 
     40  delete this->children;
    3941}
    4042
     
    4547{
    4648  this->setClassID(CL_GLGUI_BOX, "GLGuiBox");
     49  this->children = new tList<GLGuiWidget>;
     50}
     51
     52void GLGuiBox::pack(GLGuiWidget* widget)
     53{
     54  if (widget == NULL)
     55    return;
     56
     57  this->children->add(widget);
     58}
     59
     60
     61void GLGuiBox::unpack(GLGuiWidget* widget)
     62{
     63  if (widget == NULL)
     64  {
     65    delete this->children;
     66    this->children = new tList<GLGuiWidget>;
     67  }
     68  else
     69  {
     70    this->children->remove(widget);
     71  }
     72}
     73
     74void GLGuiBox::showAll()
     75{
     76  tIterator<GLGuiWidget>* itC = this->children->getIterator();
     77  GLGuiWidget* enumC = itC->firstElement();
     78  while (enumC != NULL)
     79  {
     80    if (enumC->isA(CL_GLGUI_CONTAINER))
     81      static_cast<GLGuiContainer*>(enumC)->showAll();
     82    else
     83      enumC->show();
     84    enumC = itC->nextElement();
     85  }
     86  delete itC;
     87
     88  this->show();
    4789
    4890}
     91
     92void GLGuiBox::hideAll()
     93{
     94  tIterator<GLGuiWidget>* itC = this->children->getIterator();
     95  GLGuiWidget* enumC = itC->firstElement();
     96  while (enumC != NULL)
     97  {
     98    if (enumC->isA(CL_GLGUI_CONTAINER))
     99      static_cast<GLGuiContainer*>(enumC)->showAll();
     100    else
     101      enumC->hide();
     102    enumC = itC->nextElement();
     103  }
     104  delete itC;
     105
     106  this->hide();
     107}
     108
    49109
    50110/**
  • trunk/src/lib/gui/gl_gui/glgui_box.h

    r5391 r5393  
    1111
    1212// FORWARD DECLARATION
     13template<class T> class tList;
    1314
    1415typedef enum
     
    3132  void setType(GLGuiBoxType type) { this->type = type; };
    3233
     34  virtual void pack(GLGuiWidget* widget);
     35  virtual void unpack(GLGuiWidget* widget);
     36  virtual void showAll();
     37  virtual void hideAll();
     38
    3339  virtual void draw();
    3440
    3541 private:
    36    GLGuiBoxType         type;
     42   GLGuiBoxType             type;
     43   tList<GLGuiWidget>*      children;
    3744
    3845};
  • trunk/src/lib/gui/gl_gui/glgui_container.cc

    r5387 r5393  
    1818#include "glgui_container.h"
    1919
    20 #include "list.h"
    21 
    22 
    2320using namespace std;
    2421
     
    2926{
    3027  this->init();
    31   this->children = new tList<GLGuiWidget>;
    3228}
    3329
     
    3834GLGuiContainer::~GLGuiContainer()
    3935{
    40   delete this->children;
    4136}
    4237
     
    5045}
    5146
    52 void GLGuiContainer::showAll()
    53 {
    54   tIterator<GLGuiWidget>* itC = this->children->getIterator();
    55   GLGuiWidget* enumC = itC->firstElement();
    56   while (enumC != NULL)
    57   {
    58     if (enumC->isA(CL_GLGUI_CONTAINER))
    59       static_cast<GLGuiContainer*>(enumC)->showAll();
    60     else
    61       enumC->show();
    62     enumC = itC->nextElement();
    63   }
    64   delete itC;
    65 
    66   this->show();
    67 
    68 }
    69 
    70 void GLGuiContainer::hideAll()
    71 {
    72   tIterator<GLGuiWidget>* itC = this->children->getIterator();
    73   GLGuiWidget* enumC = itC->firstElement();
    74   while (enumC != NULL)
    75   {
    76     if (enumC->isA(CL_GLGUI_CONTAINER))
    77       static_cast<GLGuiContainer*>(enumC)->showAll();
    78     else
    79       enumC->hide();
    80     enumC = itC->nextElement();
    81   }
    82   delete itC;
    83 
    84   this->hide();
    85 }
    86 
    8747
    8848/**
  • trunk/src/lib/gui/gl_gui/glgui_container.h

    r5391 r5393  
    1111
    1212// FORWARD DECLARATION
    13 template<class T> class tList;
    1413
    1514//! This is part of the openglGUI class
     
    2524  void init();
    2625
    27   void add(GLGuiWidget* widget);
    2826
    2927  void setBorderWidth(float borderwidth);
    3028
    31   void hideAll();
    32   void showAll();
     29
     30  virtual void pack(GLGuiWidget* widget) = 0;
     31  /** unpacks a Widget from this container. @param widget the GLGuiWidget to unpack, if NULL all subwidgets will be unpackt. */
     32  virtual void unpack(GLGuiWidget* widget) = 0;
     33  virtual void hideAll() = 0;
     34  virtual void showAll() = 0;
    3335
    3436
     
    3638
    3739 private:
    38   tList<GLGuiWidget>*           children;
    3940
    4041};
  • trunk/src/lib/gui/gl_gui/glgui_frame.cc

    r5364 r5393  
    1717
    1818#include "glgui_frame.h"
     19
     20#include "debug.h"
    1921
    2022using namespace std;
     
    4446{
    4547  this->setClassID(CL_GLGUI_FRAME, "GLGuiFrame");
     48  this->child = NULL;
     49}
    4650
     51void GLGuiFrame::pack(GLGuiWidget* widget)
     52{
     53  if (widget == NULL)
     54    return;
     55
     56  if (this->child == NULL)
     57    this->child = widget;
     58  else
     59  {
     60    PRINTF(2)("Frame %s is already filled, not filling with %s\n", this->getName(), widget->getName());
     61  }
    4762}
     63
     64void GLGuiFrame::unpack(GLGuiWidget* widget)
     65{
     66  if (widget == NULL || widget == this->child)
     67    this->child = NULL;
     68}
     69
     70void GLGuiFrame::showAll()
     71{
     72  if (this->child != NULL)
     73  {
     74    if (this->child->isA(CL_GLGUI_CONTAINER))
     75      static_cast<GLGuiContainer*>(this->child)->showAll();
     76    else
     77      this->child->show();
     78  }
     79  this->show();
     80}
     81
     82void GLGuiFrame::hideAll()
     83{
     84  if (this->child != NULL)
     85  {
     86    if (this->child->isA(CL_GLGUI_CONTAINER))
     87      static_cast<GLGuiContainer*>(this->child)->hideAll();
     88    else
     89      this->child->hide();
     90  }
     91  this->hide();
     92}
     93
    4894
    4995/**
  • trunk/src/lib/gui/gl_gui/glgui_frame.h

    r5364 r5393  
    2424  void init();
    2525
     26  virtual void pack(GLGuiWidget* widget);
     27  virtual void unpack(GLGuiWidget* widget);
     28  virtual void showAll();
     29  virtual void hideAll();
     30
    2631  virtual void draw();
    2732
    2833 private:
     34   GLGuiWidget*           child;
    2935
    3036};
Note: See TracChangeset for help on using the changeset viewer.