Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8616 in orxonox.OLD for branches/gui


Ignore:
Timestamp:
Jun 20, 2006, 12:51:20 PM (18 years ago)
Author:
bensch
Message:

orxonox/gui: start the stuff

Location:
branches/gui/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/gui/src/lib/gui/gl/glgui.h

    r8145 r8616  
    1616#include "glgui_button.h"
    1717#include "glgui_checkbutton.h"
    18 //#include "glgui_colorselector.h"
    1918#include "glgui_pushbutton.h"
    2019#include "glgui_slider.h"
     
    2221#include "glgui_inputline.h"
    2322#include "glgui_textfield.h"
     23#include "glgui_table.h"
    2424#include "glgui_image.h"
    2525
  • branches/gui/src/lib/gui/gl/glgui_table.cc

    r8615 r8616  
    1717
    1818#include "glgui_table.h"
     19#include "debug.h"
    1920
    2021namespace OrxGui
     
    2324   * @brief standard constructor
    2425   */
    25   GLGuiTable::GLGuiTable ()
     26  GLGuiTable::GLGuiTable (unsigned int rows, unsigned int columns)
    2627  {
    2728    this->init();
     29    this->setRowCount(rows);
     30    this->setColumnCount(columns);
    2831  }
    2932
     
    5154  void GLGuiTable::setRowCount(unsigned int rowCount)
    5255  {
    53     this->_headers.resize(rowCount);
    54     for (unsigned int i = 0; i < rowCount; i++)
    55       this->_entries[i].resize(rowCount);
     56
     57    unsigned int currentRowCount = this->rowCount();
     58    this->_entries.resize(rowCount);
     59    for (unsigned int i = currentRowCount; i < this->rowCount(); ++i)
     60      this->_entries[i].resize(columnCount(), LimitedWidthText("fonts/final_frontier.ttf", 20));
     61
     62    assert(this->checkIntegrity());
     63    this->debug();
    5664
    5765    if (!this->isVisible())
     
    6169  void GLGuiTable::setColumnCount(unsigned int columnCount)
    6270  {
    63     this->_entries.resize(columnCount);
     71    this->_headers.resize(columnCount, LimitedWidthText("fonts/final_frontier.ttf", 20));
     72    for (unsigned int i = 0; i < rowCount(); i++)
     73      this->_entries[i].resize(columnCount, LimitedWidthText("fonts/final_frontier.ttf", 20));
     74
     75    assert(this->checkIntegrity());
     76    this->debug();
     77
    6478    if (!this->isVisible())
    6579      this->hiding();
     
    6983  void GLGuiTable::setHeader(unsigned int number, const std::string& headerName)
    7084  {
    71     if (number >= this->_headers.size())
     85    if (number >= this->columnCount())
    7286      this->setColumnCount(number + 1);
    7387    this->_headers[number].setText(headerName);
     
    97111  }
    98112
     113  /// TODO.
    99114  void GLGuiTable::setRowHeight(unsigned int row, unsigned int size)
    100   {}
     115{}
    101116
    102117
     
    134149  void GLGuiTable::updateFrontColor()
    135150  {
    136     for (unsigned int i = 0; i < this->rowCount(); ++i)
     151    for (unsigned int i = 0; i < this->columnCount(); ++i)
    137152    {
    138153      this->_headers[i].setColor(this->foregroundColor());
    139       for (unsigned int j = 0; j < this->columnCount(); ++j)
    140         this->_entries[i][j].setColor(this->foregroundColor());
     154      for (unsigned int j = 0; j < this->rowCount(); ++j)
     155        this->_entries[j][i].setColor(this->foregroundColor());
    141156    }
    142157  }
     
    144159  void GLGuiTable::hiding()
    145160  {
    146     for (unsigned int i = 0; i < this->rowCount(); ++i)
     161    for (unsigned int i = 0; i < this->columnCount(); ++i)
    147162    {
    148163      this->_headers[i].setVisibility(false);
    149       for (unsigned int j = 0; j < this->columnCount(); ++j)
    150         this->_entries[i][j].setVisibility(false);
     164      for (unsigned int j = 0; j < this->rowCount(); ++j)
     165        this->_entries[j][i].setVisibility(false);
    151166    }
    152167  }
     
    154169  void GLGuiTable::showing()
    155170  {
    156     for (unsigned int i = 0; i < this->rowCount(); ++i)
     171    for (unsigned int i = 0; i < this->columnCount(); ++i)
    157172    {
    158173      this->_headers[i].setVisibility(true);
    159       for (unsigned int j = 0; j < this->columnCount(); ++j)
    160         this->_entries[i][j].setVisibility(true);
    161     }
    162   }
     174      for (unsigned int j = 0; j < this->rowCount(); ++j)
     175        this->_entries[j][i].setVisibility(true);
     176    }
     177  }
     178
    163179
    164180  /**
     
    182198    this->endDraw();
    183199  }
     200
     201  void GLGuiTable::debug() const
     202  {
     203    PRINT(0)("Table: Size = %dx%d\n", this->rowCount(), this->columnCount());
     204
     205    for (unsigned int i = 0; i < this->rowCount(); ++i)
     206      PRINT(0)("line %d: columns %d\n", i, this->_entries[i].size());
     207  }
     208
     209
     210  bool GLGuiTable::checkIntegrity() const
     211  {
     212    bool retVal = true;
     213    if (rowCount() != this->_entries.size())
     214    {
     215      PRINTF(1)("ROW COUNT WRONG (is %d should be %d)\n", rowCount(), this->_entries.size());
     216      retVal = false;
     217    }
     218    if (columnCount() != this->_headers.size())
     219    {
     220      PRINTF(1)("COLUMN COUNT WRONG (is %d should be %d)\n", columnCount(), this->_headers.size());
     221      retVal = false;
     222    }
     223    for (unsigned int i = 0; i < this->rowCount(); ++i)
     224      if (this->_entries[i].size() != this->columnCount())
     225    {
     226      PRINTF(1)("COLUMN-COUNT OF ROW %d WRONG (is %d should be %d)\n", i, this->_entries[i].size(), this->columnCount());
     227      retVal = false;
     228    }
     229    return retVal;
     230  }
     231
    184232}
  • branches/gui/src/lib/gui/gl/glgui_table.h

    r8615 r8616  
    2727
    2828  public:
    29     GLGuiTable();
     29    GLGuiTable(unsigned int rows, unsigned int columns);
    3030    virtual ~GLGuiTable();
    3131
     32    unsigned int rowCount() const { return this->_entries.size(); };
    3233    unsigned int columnCount() const { return this->_headers.size(); };
    33     unsigned int rowCount() const { return this->_entries.size(); };
    34     //const std::vector<std::string>& headers() const { return this->_headers; };
    35     //const std::vector<std::vector<std::string> >& entries() const { return this->_entries; };
    3634
    3735    void setRowCount(unsigned int rowCount);
     
    5048
    5149
     50    void debug() const;
     51
    5252  protected:
    5353    virtual void removedFocus();
     
    6464    void init();
    6565
     66    bool checkIntegrity() const;
     67
    6668  private:
    6769    typedef std::vector<LimitedWidthText> TableTextList;
  • branches/gui/src/story_entities/simple_game_menu.cc

    r8583 r8616  
    123123    slider->setValue(slider->min());
    124124    box->pack(slider);
     125
     126
     127    OrxGui::GLGuiTable* table = new OrxGui::GLGuiTable(3, 3);
     128    std::vector<std::string> headers;
     129    headers.push_back("1");
     130    headers.push_back("2");
     131    headers.push_back("3");
     132    table->setHeader(headers);
     133
     134
     135    box->pack(table);
    125136  }
    126137  box->setAbsCoor2D(50, 200);
Note: See TracChangeset for help on using the changeset viewer.