예제 #1
0
파일: WidgetLoader.cpp 프로젝트: wpbest/XPF
    TGUI_API Widget::Ptr loadButton(std::shared_ptr<DataIO::Node> node, Widget::Ptr widget = nullptr)
    {
        Button::Ptr button;
        if (widget)
            button = std::static_pointer_cast<Button>(widget);
        else
            button = std::make_shared<Button>();

        loadWidget(node, button);
        if (node->propertyValuePairs["text"])
            button->setText(DESERIALIZE_STRING("text"));
        if (node->propertyValuePairs["textsize"])
            button->setTextSize(tgui::stoi(node->propertyValuePairs["textsize"]->value));

        return button;
    }
예제 #2
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();
    }