Example #1
0
void GUIManager::setHandlers ()
{
  CEGUI::WindowManager & wm = CEGUI::WindowManager::getSingleton();

  CEGUI::FrameWindow *dsFrame = static_cast<CEGUI::FrameWindow *>(
      wm.getWindow("Sheet/DatasetFrame"));
  dsFrame->hide();
  // Handle behavior of options-button
  CEGUI::PushButton *button = static_cast<CEGUI::PushButton *>(
      wm.getWindow("Sheet/Options"));
  button->subscribeEvent(CEGUI::PushButton::EventClicked,
      CEGUI::Event::Subscriber(&GUIManager::handleOptionsVisibility, this));
  button = dsFrame->getCloseButton();
  button->subscribeEvent(CEGUI::PushButton::EventClicked,
      CEGUI::Event::Subscriber(&GUIManager::handleOptionsVisibility, this));
  // Connect activate buttons on tabs
  auto connectFrames = [=](CEGUI::Window *tab) {
    CEGUI::PushButton *button =
      static_cast<CEGUI::PushButton *>(tab->getChild(3));
    button->subscribeEvent(CEGUI::PushButton::EventClicked,
        CEGUI::Event::Subscriber(&GUIManager::handleDSActivation, this));
    button = static_cast<CEGUI::PushButton *>(tab->getChild(4));
    button->subscribeEvent(CEGUI::PushButton::EventClicked,
        CEGUI::Event::Subscriber(&GUIManager::handleDSDeactivation, this));
    CEGUI::Scrollbar *sb = static_cast<CEGUI::Scrollbar *>(tab->getChild(2));
    sb->subscribeEvent(CEGUI::Scrollbar::EventScrollPositionChanged,
        CEGUI::Event::Subscriber(&GUIManager::handleScrollbarChanged, this));
    CEGUI::Listbox *lb = static_cast<CEGUI::Listbox *>(tab->getChild(0));
    lb->subscribeEvent(CEGUI::Listbox::EventSelectionChanged,
        CEGUI::Event::Subscriber(&GUIManager::handleDSSelection, this));
  };
  CEGUI::Window *tab =  wm.getWindow("Sheet/DatasetFrame/TabControl/HTab");
  connectFrames(tab);
  tab = wm.getWindow("Sheet/DatasetFrame/TabControl/PTab");
  connectFrames(tab);
  tab = wm.getWindow("Sheet/DatasetFrame/TabControl/CTab");
  connectFrames(tab);
  CEGUI::Scrollbar *sb = static_cast<CEGUI::Scrollbar *>(
      wm.getWindow("Sheet/DimensionSlider"));
  sb->subscribeEvent(CEGUI::Scrollbar::EventScrollPositionChanged,
      CEGUI::Event::Subscriber(&GUIManager::handleBigScrollbarChanged, this));
}