Ejemplo n.º 1
0
//-----------------------------------------------------------------------------------
    bool ItemSelectorViewManager::handleCheckStateChanged(const CEGUI::EventArgs& e)
    {
        // activate controller if set
        if (mItemSelectorController)
        {
            CEGUI::Checkbox* checkbox = static_cast<CEGUI::Checkbox*>(
                static_cast<const CEGUI::WindowEventArgs&>(e).window);
            mItemSelectorController->itemStateChanged(checkbox->getID(), checkbox->isSelected());
            float selectColour = checkbox->isSelected() ? 0.0f : 1.0f;
            checkbox->setProperty("NormalTextColour",
                CEGUI::PropertyHelper::colourToString(CEGUI::colour(selectColour, 1.0f, selectColour)));
        }
        return true;
    }
Ejemplo n.º 2
0
//-----------------------------------------------------------------------------------
    void ItemSelectorViewManager::addItemSelector(const Ogre::String& displayText)
    {
        // add a new item selector
        // determine new index for item
        assert(mScrollablePane);
        const size_t idx = mItemSelectorContainer.size();
        mItemSelectorContainer.push_back(ItemSelector());
        ItemSelector& item = mItemSelectorContainer.back();
        // create new checkbox
        CEGUI::Checkbox* checkbox = item.CheckBoxWidget = (CEGUI::Checkbox*)CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/Checkbox",
                                    ( ("ItemCheckbox" + Ogre::StringConverter::toString(idx)).c_str() ));
        // set checkbox ID to selector ID
        checkbox->setID(idx);
        checkbox->setSize(CEGUI::UVector2(CEGUI::UDim(0, 140), CEGUI::UDim(0, ITEM_YSIZE)));
        checkbox->setText(displayText.c_str());
        checkbox->setProperty("HoverTextColour", CEGUI::PropertyHelper::colourToString(CEGUI::colour(1.0, 1.0, 0.0)));
        // add event handler for when checkbox state changes
        checkbox->subscribeEvent(CEGUI::Checkbox::EventCheckStateChanged, CEGUI::Event::Subscriber(&ItemSelectorViewManager::handleCheckStateChanged, this ));
        checkbox->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 0), CEGUI::UDim(0, 12 + (ITEM_YSIZE + ITEM_YSPACING)* static_cast<float>(idx))));
        // add checkbox to the scroll pane
        mScrollablePane->addChildWindow(checkbox);
    }