Exemplo n.º 1
0
EventPropagation BubbleWidget::focused(const int playerID)
{
    if (m_element != NULL)
    {
        // bring element to top (with a hack because irrlicht does not appear to offer a built-in way to do this)
        m_element->grab();

        IGUIElement* parent = m_parent;
        if (parent == NULL) parent = GUIEngine::getGUIEnv()->getRootGUIElement();

        parent->removeChild(m_element);
        parent->addChild(m_element);
        m_element->drop();
    }
    return EVENT_LET;
}
Exemplo n.º 2
0
//! constructor
CGUIFileOpenDialog::CGUIFileOpenDialog(const wchar_t* title,
                                       IGUIEnvironment* environment, IGUIElement* parent, s32 id)
    : IGUIFileOpenDialog(environment, parent, id,
                         core::rect<s32>((parent->getAbsolutePosition().getWidth()-FOD_WIDTH)/2,
                                         (parent->getAbsolutePosition().getHeight()-FOD_HEIGHT)/2,
                                         (parent->getAbsolutePosition().getWidth()-FOD_WIDTH)/2+FOD_WIDTH,
                                         (parent->getAbsolutePosition().getHeight()-FOD_HEIGHT)/2+FOD_HEIGHT)),
      FileNameText(0), FileList(0), Dragging(false)
{
#ifdef _DEBUG
    IGUIElement::setDebugName("CGUIFileOpenDialog");
#endif

    Text = title;

    IGUISkin* skin = Environment->getSkin();
    IGUISpriteBank* sprites = 0;
    video::SColor color(255,255,255,255);
    if (skin)
    {
        sprites = skin->getSpriteBank();
        color = skin->getColor(EGDC_WINDOW_SYMBOL);
    }

    const s32 buttonw = environment->getSkin()->getSize(EGDS_WINDOW_BUTTON_WIDTH);
    const s32 posx = RelativeRect.getWidth() - buttonw - 4;

    CloseButton = Environment->addButton(core::rect<s32>(posx, 3, posx + buttonw, 3 + buttonw), this, -1,
                                         L"", skin ? skin->getDefaultText(EGDT_WINDOW_CLOSE) : L"Close");
    CloseButton->setSubElement(true);
    CloseButton->setTabStop(false);
    if (sprites)
    {
        CloseButton->setSpriteBank(sprites);
        CloseButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_WINDOW_CLOSE), color);
        CloseButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_WINDOW_CLOSE), color);
    }
    CloseButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
    CloseButton->grab();

    OKButton = Environment->addButton(
                   core::rect<s32>(RelativeRect.getWidth()-80, 30, RelativeRect.getWidth()-10, 50),
                   this, -1, skin ? skin->getDefaultText(EGDT_MSG_BOX_OK) : L"OK");
    OKButton->setSubElement(true);
    OKButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
    OKButton->grab();

    CancelButton = Environment->addButton(
                       core::rect<s32>(RelativeRect.getWidth()-80, 55, RelativeRect.getWidth()-10, 75),
                       this, -1, skin ? skin->getDefaultText(EGDT_MSG_BOX_CANCEL) : L"Cancel");
    CancelButton->setSubElement(true);
    CancelButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
    CancelButton->grab();

    FileBox = Environment->addListBox(core::rect<s32>(10, 55, RelativeRect.getWidth()-90, RelativeRect.getHeight() - 20), this, -1, true);
    FileBox->setSubElement(true);
    FileBox->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT);
    FileBox->grab();

    FileNameText = Environment->addEditBox(0, core::rect<s32>(10, 30, RelativeRect.getWidth()-90, 50), true, this);
    FileNameText->setSubElement(true);
    FileNameText->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
    FileNameText->grab();

    FileSystem = Environment->getFileSystem();

    if (FileSystem)
        FileSystem->grab();

    setTabGroup(true);

    fillListBox();

    //CGUIFileOpenDialog changes:

    // Careful, don't just set the modal as parent above. That will mess up the focus (and is hard to change because we have to be very
    // careful not to get virtual function call, like OnEvent, in the window.
    IGUIElement * modalScreen = Environment->addModalScreen(parent);
    modalScreen->addChild(this);

    initialWorkingDirectory = FileSystem->getWorkingDirectory();
}