Ejemplo n.º 1
0
void KWFrameGeometry::open(KShape *shape)
{
    KWPage page = m_state->document()->pageManager()->page(shape);
    m_topOfPage = page.offsetInDocument();
    m_originalPosition = shape->position();
    m_originalSize = shape->size();
    QPointF position = shape->absolutePosition(widget.positionSelector->position());

    widget.xPos->changeValue(position.x());
    widget.yPos->changeValue(position.y() - m_topOfPage);
    widget.width->changeValue(m_originalSize.width());
    widget.height->changeValue(m_originalSize.height());

    if (m_frame == 0) {
        // default values for new frames
        widget.leftMargin->changeValue(MM_TO_POINT(3));
        widget.rightMargin->changeValue(MM_TO_POINT(3));
        widget.topMargin->changeValue(MM_TO_POINT(3));
        widget.bottomMargin->changeValue(MM_TO_POINT(3));
    }

    connect(widget.protectSize, SIGNAL(stateChanged(int)),
            this, SLOT(protectSizeChanged(int)));

    m_originalGeometryLock = shape->isGeometryProtected();
    if (m_originalGeometryLock) {
        widget.protectSize->setCheckState(Qt::Checked);
        KWTextFrame *tf = dynamic_cast<KWTextFrame*>(shape->applicationData());
        if (tf && static_cast<KWTextFrameSet*>(tf->frameSet())->textFrameSetType() != KWord::OtherTextFrameSet)
            widget.protectSize->setEnabled(false); // auto-generated frame, can't edit
    }

    connect(widget.xPos, SIGNAL(valueChanged(double)), this, SLOT(updateShape()));
    connect(widget.yPos, SIGNAL(valueChanged(double)), this, SLOT(updateShape()));
    connect(widget.width, SIGNAL(valueChanged(double)), this, SLOT(updateShape()));
    connect(widget.height, SIGNAL(valueChanged(double)), this, SLOT(updateShape()));
}