Example #1
0
void EventsHandler::actionPerformed(GUIEvent &evt)
{
static int num  = 0;
  const std::string &callbackString  = evt.getCallbackString();
  GUIRectangle      *sourceRectangle = evt.getEventSource(),
                    *parent          = sourceRectangle ? sourceRectangle->getParent() : NULL;
  int                widgetType      = sourceRectangle->getWidgetType();

  if(widgetType == WT_SLIDER )
  {
    GUISlider  *slider = (GUISlider*)sourceRectangle;
    if(callbackString == "s1" || callbackString == "s2")
    {
      sprintf(charBuffer, "%s: %.2f",  (callbackString == "s1") ? "Slider 1" : "Slider 2",  slider->getProgress());
      slider->setLabelString(charBuffer);
    }

    if(callbackString == "red")   red   = slider->getProgress();
    if(callbackString == "blue")  blue  = slider->getProgress();
    if(callbackString == "green") green = slider->getProgress();
  }

  if(widgetType == WT_BUTTON)
  {
    GUIButton   *button = (GUIButton*)sourceRectangle;
    if(callbackString == "exit")
      if(button->isClicked())
        exit(0);
  }

  if(widgetType == WT_COMBO_BOX)
  {
    GUIComboBox  *comboBox = (GUIComboBox*)sourceRectangle;
    if(callbackString == "cb1")
    if(comboBox->getSelectedItem() == std::string("Select this item to exit"))
      exit(0);
  }

  if(widgetType == WT_RADIO_BUTTON)
  {
    GUIRadioButton   *radioButton = (GUIRadioButton*)sourceRectangle;
  }

}