Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8003 in orxonox.OLD for branches/gui/src


Ignore:
Timestamp:
May 31, 2006, 12:21:36 AM (19 years ago)
Author:
bensch
Message:

gui: introducing a Box

Location:
branches/gui/src
Files:
3 edited

Legend:

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

    r8002 r8003  
    5050
    5151    this->children.push_back(widget);
     52    this->addChild2D(widget);
     53
     54    this->resize();
    5255  }
    5356
     
    5760    assert(widget == NULL);
    5861
    59     this->children.remove(widget);
     62    std::vector<GLGuiWidget*>::iterator delWidget = std::find(this->children.begin(), this->children.end(), widget);
     63    if (delWidget != this->children.end())
     64      this->children.erase(delWidget);
     65  }
     66
     67  void GLGuiBox::clear()
     68  {
     69    this->children.clear();
     70    this->resize();
    6071  }
    6172
    6273  void GLGuiBox::showAll()
    6374  {
    64     std::list<GLGuiWidget*>::iterator itC = this->children.begin();
     75    std::vector<GLGuiWidget*>::iterator itC = this->children.begin();
    6576    while (itC != this->children.end())
    6677    {
     
    7788  void GLGuiBox::hideAll()
    7889  {
    79     std::list<GLGuiWidget*>::iterator itC = this->children.begin();
     90    std::vector<GLGuiWidget*>::iterator itC = this->children.begin();
    8091    while (itC != this->children.end())
    8192    {
     
    90101  }
    91102
     103  void GLGuiBox::resize()
     104  {
     105    float height = 0.0f;
     106    float width = 0.0f;
     107    std::vector<GLGuiWidget*>::iterator widget;
     108
     109    // find out how big the Widgets are.
     110    for (widget = this->children.begin(); widget != this->children.end(); ++widget)
     111    {
     112      (*widget)->setAbsCoor2D(0, height);
     113      height += (*widget)->getSizeY2D();
     114      width = fmax(width, (*widget)->getSizeX2D());
     115    }
     116
     117    GLGuiWidget::resize();
     118    // resize everything.
     119    //for (widget = this->children.begin(); widget != this->children.end(); ++widget)
     120    //{}
     121  }
    92122
    93123  /**
    94    * draws the GLGuiBox
     124   * @brief draws the GLGuiBox
    95125   */
    96126  void GLGuiBox::draw() const
    97127  {
     128    this->beginDraw();
     129    GLGuiWidget::draw();
     130    this->endDraw();
    98131  }
    99132}
  • branches/gui/src/lib/gui/gl_gui/glgui_box.h

    r8002 r8003  
    2424    virtual ~GLGuiBox();
    2525
    26     void init();
    2726    /** @returns the Orientation of the Box */
    2827    OrxGui::Orientation orientation() const { return this->_orientation; };
     
    3837    virtual void draw() const;
    3938
    40   private:
     39  protected:
    4140    virtual void resize();
    4241
    43     Orientation              _orientation;
    44     std::list<GLGuiWidget*>  children;
     42  private:
     43    void init();
     44
     45    Orientation                _orientation;
     46    std::vector<GLGuiWidget*>  children;
    4547  };
    4648}
  • branches/gui/src/story_entities/simple_game_menu.cc

    r8002 r8003  
    8585void SimpleGameMenu::enterGui()
    8686{
    87   ///
    88   OrxGui::GLGuiButton* dnpb = new OrxGui::GLGuiCheckButton("Push the button");
    89   dnpb->show();
    90   dnpb->setAbsCoor2D(350, 50);
    91 
    92 
    93   OrxGui::GLGuiPushButton* rdnpb = new OrxGui::GLGuiPushButton("Quit ORXONOX!!");
    94   rdnpb->show();
    95   rdnpb->setAbsCoor2D(200, 180);
    96   rdnpb->connect(SIGNAL(rdnpb, released), this, SLOT(SimpleGameMenu, quitMenu));
    97 
    98   OrxGui::GLGuiInputLine* input = new OrxGui::GLGuiInputLine();
    99   input->setText("input some text here");
    100   input->connect(SIGNAL(input, textChanged), this, SLOT(SimpleGameMenu, TEST));
    101   input->show();
    102   input->setAbsCoor2D(200, 230);
    103 
    104   OrxGui::GLGuiSlider* slider = new OrxGui::GLGuiSlider();
    105   slider->connect(SIGNAL(slider, valueChanged), this, SLOT(SimpleGameMenu, TEST));
    106   slider->connect(SIGNAL(slider, valueChanged), slider, SLOT(OrxGui::GLGuiWidget, setBackgroundColor));
    107   slider->setRange(0, 1);
    108   slider->setValue(slider->min());
    109   slider->show();
    110   slider->setAbsCoor2D(200, 270);
    111 
     87
     88  OrxGui::GLGuiBox* box = new OrxGui::GLGuiBox();
     89  {
     90    ///
     91    OrxGui::GLGuiButton* dnpb = new OrxGui::GLGuiCheckButton("Push the button");
     92    dnpb->show();
     93    dnpb->setAbsCoor2D(350, 50);
     94
     95    box->pack(dnpb);
     96
     97    OrxGui::GLGuiPushButton* rdnpb = new OrxGui::GLGuiPushButton("Quit ORXONOX!!");
     98    rdnpb->show();
     99    rdnpb->setAbsCoor2D(200, 180);
     100    rdnpb->connect(SIGNAL(rdnpb, released), this, SLOT(SimpleGameMenu, quitMenu));
     101
     102    box->pack(rdnpb);
     103
     104    OrxGui::GLGuiInputLine* input = new OrxGui::GLGuiInputLine();
     105    input->setText("input some text here");
     106    input->connect(SIGNAL(input, textChanged), this, SLOT(SimpleGameMenu, TEST));
     107    input->show();
     108    input->setAbsCoor2D(200, 230);
     109    box->pack(input);
     110
     111    OrxGui::GLGuiSlider* slider = new OrxGui::GLGuiSlider();
     112    slider->connect(SIGNAL(slider, valueChanged), this, SLOT(SimpleGameMenu, TEST));
     113    slider->connect(SIGNAL(slider, valueChanged), dnpb, SLOT(OrxGui::GLGuiWidget, setBackgroundColor));
     114    slider->setRange(0, 1);
     115    slider->setValue(slider->min());
     116    slider->show();
     117    slider->setAbsCoor2D(200, 270);
     118    box->pack(slider);
     119  }
     120  box->setAbsCoor2D(50, 200);
    112121  /////
    113122}
     
    133142  system ((std::string("firefox ") + URL).c_str());
    134143#elif defined __OSX__
    135     CFURLRef url_handle = CFURLCreateWithBytes (NULL, (UInt8 *)URL.c_str(), URL.size(),
    136                                          kCFStringEncodingASCII, NULL);
    137     LSOpenCFURLRef (url_handle, NULL);
    138     CFRelease (url_handle);
     144  CFURLRef url_handle = CFURLCreateWithBytes (NULL, (UInt8 *)URL.c_str(), URL.size(),
     145                        kCFStringEncodingASCII, NULL);
     146  LSOpenCFURLRef (url_handle, NULL);
     147  CFRelease (url_handle);
    139148#elif defined __WIN32__
    140     ShellExecute(GetActiveWindow(),
    141                  "open", URL.c_str(), NULL, NULL, SW_SHOWNORMAL);
    142   }
     149  ShellExecute(GetActiveWindow(),
     150               "open", URL.c_str(), NULL, NULL, SW_SHOWNORMAL);
     151}
    143152#endif
    144153  PRINTF(3)("loaded external webpage %s\n", URL.c_str());
Note: See TracChangeset for help on using the changeset viewer.