示例#1
0
文件: MessageBox.cpp 项目: texus/TGUI
    void MessageBox::addButton(const sf::String& caption)
    {
        Button::Ptr button;
        if (!getTheme() || m_buttonClassName.empty())
            button = std::make_shared<Button>();
        else
            button = getTheme()->internalLoad(getPrimaryLoadingParameter(), m_buttonClassName);

        button->setTextSize(m_textSize);
        button->setText(caption);
        button->connect("Pressed", [=](){ m_callback.text = caption; sendSignal("ButtonPressed", caption); });

        add(button, "#TGUI_INTERNAL$MessageBoxButton$" + caption + "#");
        m_buttons.push_back(button);

        rearrange();
    }
示例#2
0
文件: MessageBox.cpp 项目: texus/TGUI
    MessageBox::MessageBox(const MessageBox& messageBoxToCopy) :
        ChildWindow      {messageBoxToCopy},
        m_loadedThemeFile(messageBoxToCopy.m_loadedThemeFile), // Did not compile in VS2013 when using braces
        m_buttonClassName(messageBoxToCopy.m_buttonClassName), // Did not compile in VS2013 when using braces
        m_textSize       {messageBoxToCopy.m_textSize}
    {
        m_label = Label::copy(messageBoxToCopy.m_label);
        add(m_label, "#TGUI_INTERNAL$MessageBoxText#");

        for (auto it = messageBoxToCopy.m_buttons.begin(); it != messageBoxToCopy.m_buttons.end(); ++it)
        {
            Button::Ptr button = Button::copy(*it);
            button->disconnectAll();
            button->connect("Pressed", [=]() { m_callback.text = button->getText(); sendSignal("ButtonPressed", button->getText()); });

            m_buttons.push_back(button);
        }
    }