Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7779 in orxonox.OLD for trunk/src/lib/gui/gl_gui/glgui_widget.cc


Ignore:
Timestamp:
May 23, 2006, 10:04:17 PM (18 years ago)
Author:
bensch
Message:

3088 linews changed :): trunk: namespaces

File:
1 edited

Legend:

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

    r7062 r7779  
    2222#include "debug.h"
    2323
    24 using namespace std;
     24namespace OrxGui
     25{
    2526
    26 /**
    27  * standard constructor
    28 */
    29 GLGuiWidget::GLGuiWidget ( )
    30 {
    31   this->init();
    32 }
     27  /**
     28   * standard constructor
     29  */
     30  GLGuiWidget::GLGuiWidget ( )
     31  {
     32    this->init();
     33  }
    3334
    3435
    35 /**
    36  * standard deconstructor
    37  */
    38 GLGuiWidget::~GLGuiWidget()
    39 {
     36  /**
     37   * standard deconstructor
     38   */
     39  GLGuiWidget::~GLGuiWidget()
     40  {
     41  }
     42
     43
     44  /**
     45   * initializes the GUI-element
     46   */
     47  void GLGuiWidget::init()
     48  {
     49    this->setClassID(CL_GLGUI_WIDGET, "GLGuiWidget");
     50
     51    this->focusable = true;
     52    this->clickable = true;
     53    this->setVisibility(GLGUI_WIDGET_DEFAULT_VISIBLE);
     54    //  this->setParent2D((Element2D*)NULL);
     55
     56    this->backMat.setDiffuse(1.0, 1.0, 1.0);
     57
     58    this->frontModel = 0;
     59
     60    this->widgetSignals.resize(GLGuiSignalCount, NULL);
     61  }
     62
     63
     64  bool GLGuiWidget::focusOverWidget(float x, float y)
     65  {
     66    if (this->getAbsCoor2D().x < x && this->getAbsCoor2D().x+ this->getSizeX2D() > x &&
     67        this->getAbsCoor2D().y < y && this->getAbsCoor2D().y+ this->getSizeX2D() > y)
     68      return true;
     69    else
     70      return false;
     71  }
     72
     73  /**
     74   * @brief connects a Signal to the Gui-Elements' Event.
     75   * @param sinalType the Type of Signal to set. @see GLGuiSignalType
     76   * @param signal the name of the Signal
     77   */
     78  void GLGuiWidget::connectSignal(GLGuiSignalType signalType, BaseObject*, const Executor* signal)
     79  {
     80    if (signalType >= GLGuiSignalCount)
     81      return;
     82
     83    if (this->widgetSignals[signalType] != NULL)
     84      PRINTF(2)("Already connected a Signal to '%s::%s' type %s... overwriting\n", this->getClassName(), this->getName(), "TEST");
     85
     86    //this->widgetSignals[signalType] = ;
     87  }
     88
     89  /**
     90   * @brief removes a Signal from a Gui-ELements' Event
     91   * @param signalType the type of Signal to remove.
     92   */
     93  void GLGuiWidget::disconnectSignal(GLGuiSignalType signalType)
     94  {
     95    if (signalType > GLGuiSignalCount)
     96      return;
     97
     98    this->widgetSignals[signalType] = NULL;
     99  }
     100
     101
     102  void GLGuiWidget::show()
     103  {
     104    this->setVisibility(true);
     105  }
     106
     107  void GLGuiWidget::hide()
     108  {
     109    this->setVisibility(false);
     110  }
     111
     112
     113  void GLGuiWidget::draw() const
     114  {
     115    this->backMat.select();
     116
     117    glBegin(GL_QUADS);
     118    glTexCoord2i(0,1); glVertex2d(0, 0);
     119    glTexCoord2i(0,0); glVertex2d(0, this->getSizeY2D());
     120    glTexCoord2i(1,0); glVertex2d(this->getSizeX2D(), this->getSizeY2D());
     121    glTexCoord2i(1,1); glVertex2d(this->getSizeX2D(), 0);
     122    glEnd();
     123  }
    40124
    41125}
    42 
    43 
    44 /**
    45  * initializes the GUI-element
    46  */
    47 void GLGuiWidget::init()
    48 {
    49   this->setClassID(CL_GLGUI_WIDGET, "GLGuiWidget");
    50 
    51   this->focusable = true;
    52   this->clickable = true;
    53   this->setVisibility(GLGUI_WIDGET_DEFAULT_VISIBLE);
    54 //  this->setParent2D((Element2D*)NULL);
    55 
    56   this->backMat.setDiffuse(1.0, 1.0, 1.0);
    57 
    58   this->frontModel = 0;
    59 
    60   for (unsigned int i = 0; i < GLGuiSignalCount; i++)
    61     this->widgetSignals[i] = NULL;
    62 }
    63 
    64 
    65 bool GLGuiWidget::focusOverWidget(float x, float y)
    66 {
    67   if (this->getAbsCoor2D().x < x && this->getAbsCoor2D().x+ this->getSizeX2D() > x &&
    68       this->getAbsCoor2D().y < y && this->getAbsCoor2D().y+ this->getSizeX2D() > y)
    69     return true;
    70   else
    71     return false;
    72 }
    73 
    74 /**
    75  * @brief connects a Signal to the Gui-Elements' Event.
    76  * @param sinalType the Type of Signal to set. @see GLGuiSignalType
    77  * @param signal the name of the Signal
    78  */
    79 void GLGuiWidget::connectSignal(GLGuiSignalType signalType, const Executor& signal)
    80 {
    81   if (signalType >= GLGuiSignalCount)
    82     return;
    83 
    84   if (this->widgetSignals[signalType] != NULL)
    85     PRINTF(2)("Already connected a Signal to %s (%s) type %s... overwriting\n");
    86 
    87   this->widgetSignals[signalType] = signal.clone();
    88 }
    89 
    90 /**
    91  * @brief removes a Signal from a Gui-ELements' Event
    92  * @param signalType the type of Signal to remove.
    93  */
    94 void GLGuiWidget::disconnectSignal(GLGuiSignalType signalType)
    95 {
    96   if (signalType > GLGuiSignalCount)
    97     return;
    98 
    99   this->widgetSignals[signalType] = NULL;
    100 }
    101 
    102 
    103 void GLGuiWidget::show()
    104 {
    105   this->setVisibility(true);
    106 }
    107 
    108 void GLGuiWidget::hide()
    109 {
    110   this->setVisibility(false);
    111 }
    112 
    113 
    114 void GLGuiWidget::draw() const
    115 {
    116   this->backMat.select();
    117 
    118   glBegin(GL_QUADS);
    119    glTexCoord2i(0,1); glVertex2d(0, 0);
    120    glTexCoord2i(0,0); glVertex2d(0, this->getSizeY2D());
    121    glTexCoord2i(1,0); glVertex2d(this->getSizeX2D(), this->getSizeY2D());
    122    glTexCoord2i(1,1); glVertex2d(this->getSizeX2D(), 0);
    123   glEnd();
    124 }
    125 
Note: See TracChangeset for help on using the changeset viewer.