예제 #1
0
void UIWidget::setLayout(const UILayoutPtr& layout)
{
    if(!layout)
        stdext::throw_exception("attempt to set a nil layout to a widget");

    if(m_layout)
        m_layout->disableUpdates();

    layout->setParent(static_self_cast<UIWidget>());
    layout->disableUpdates();

    for(const UIWidgetPtr& child : m_children) {
        if(m_layout)
            m_layout->removeWidget(child);
        layout->addWidget(child);
    }

    if(m_layout) {
        m_layout->enableUpdates();
        m_layout->setParent(nullptr);
        m_layout->update();
    }

    layout->enableUpdates();
    m_layout = layout;
}
예제 #2
0
파일: uiwidget.cpp 프로젝트: Cayan/otclient
void UIWidget::setLayout(const UILayoutPtr& layout)
{
    if(m_layout)
        m_layout->disableUpdates();

    layout->setParent(asUIWidget());
    layout->disableUpdates();

    for(const UIWidgetPtr& child : m_children) {
        if(m_layout)
            m_layout->removeWidget(child);
        layout->addWidget(child);
    }

    if(m_layout) {
        m_layout->enableUpdates();
        m_layout->setParent(nullptr);
        m_layout->update();
    }

    layout->enableUpdates();
    m_layout = layout;
}