void SubEventShopCityChild(Window* pageWnd)
{
	TabControl* tbc = WTabControl(pageWnd);
	//
	tbc->subscribeEvent(TabControl::EventSelectionChanged,CEGUI::SubscriberSlot(OnShopCityChildTabContentSelChanged));
}
Beispiel #2
0
/*************************************************************************ech
Sample specific initialisation goes here.
*************************************************************************/
bool MenuNavigationSample::initialise(CEGUI::GUIContext* gui_context)
{
    using namespace CEGUI;

    d_usedFiles = CEGUI::String(__FILE__);

    SchemeManager::getSingleton().createFromFile("TaharezLook.scheme");
    gui_context->getCursor().setDefaultImage("TaharezLook/MouseArrow");

    WindowManager& win_mgr = WindowManager::getSingleton();
    d_root = win_mgr.loadLayoutFromFile("MenuNavigationSample.layout");

    FontManager::FontList loadedFonts = FontManager::getSingleton().createFromFile("DejaVuSans-12.font");
    Font* defaultFont = loadedFonts.empty() ? 0 : loadedFonts.front();
    gui_context->setDefaultFont(defaultFont);

    gui_context->setRootWindow(d_root);

    MatrixNavigationStrategy* d_matrixNavigationStrategy = new MatrixNavigationStrategy();
    d_matrixWindowNavigator = new WindowNavigator(createMatrixNavigationMappings(),
        d_matrixNavigationStrategy);
    gui_context->setWindowNavigator(d_matrixWindowNavigator);

    LinearNavigationStrategy* d_linearNavigatorStrategy = new LinearNavigationStrategy();
    d_linearWindowNavigator = new WindowNavigator(createLinearNavigationMappings(),
        d_linearNavigatorStrategy);

    TabControl* tabControl = static_cast<TabControl*>(d_root->getChild("FrameWindow/TabControl"));
    tabControl->subscribeEvent(TabControl::EventSelectionChanged,
        Event::Subscriber(&MenuNavigationSample::handleTabSelectionChanged, this));

    Window* page1Window = win_mgr.loadLayoutFromFile("MenuNavigationSampleTabPage1.layout");
    d_logWidget1 = page1Window->getChild("StaticText");
    d_logWidget1->setText("OK");

    // 4 rows
    d_matrixNavigationStrategy->d_windows.resize(4);
    for (int i = 1; i <= 16; ++i)
    {
        std::ostringstream os;
        os << "Button" << i;

        PushButton* button = static_cast<PushButton*>(page1Window->getChild(os.str()));
        button->subscribeEvent(PushButton::EventClicked,
            Event::Subscriber(&MenuNavigationSample::handleNumberButtonClicked, this));

        d_matrixNavigationStrategy->d_windows.at((i - 1) % 4).push_back(button);
    }

    tabControl->addTab(page1Window);

    Window* page2Window = win_mgr.loadLayoutFromFile("MenuNavigationSampleTabPage2.layout");
    d_logWidget2 = page2Window->getChild("StaticText");
    d_logWidget2->setText("OK");

    Window* selectButton = page2Window->getChild("SelectButton");
    selectButton->subscribeEvent(PushButton::EventClicked,
        Event::Subscriber(&MenuNavigationSample::handleSelectButtonClicked, this));

    tabControl->addTab(page2Window);

    d_classesList = static_cast<ListWidget*>(page2Window->getChild("ClassesList"));
    d_classesList->setMultiSelectEnabled(true);
    initialiseClasses(d_classesList);

    d_linearNavigatorStrategy->d_windows.push_back(d_classesList);
    d_linearNavigatorStrategy->d_windows.push_back(selectButton);

    return true;
}