Example #1
0
void KWFrameGeometry::updateShape()
{
    if (m_blockSignals) return;
    KWFrame *frame = m_frame;
    if (frame == 0) {
        frame = m_state->frame();
        m_state->markFrameUsed();
    }
    Q_ASSERT(frame);
    frame->shape()->update();
    KShape *shape = frame->shape();
    QPointF currentPos(shape->absolutePosition(widget.positionSelector->position()));
    QPointF pos(widget.xPos->value(), widget.yPos->value() + m_topOfPage);
    QPointF moved = pos - currentPos;
    QPointF prev(moved);
    m_state->document()->clipToDocument(frame->shape(), moved);
    pos = currentPos + moved;

    frame->shape()->setAbsolutePosition(pos, widget.positionSelector->position());
    QSizeF size(widget.width->value(), widget.height->value());
    frame->shape()->setSize(size);

    KWTextFrame *tfs = dynamic_cast <KWTextFrame*>(frame);
    if (tfs) {
        KInsets insets(widget.topMargin->value(), widget.leftMargin->value(),
                widget.bottomMargin->value(), widget.rightMargin->value());
        tfs->setInsets(insets);
    }

    frame->shape()->update();
}
Example #2
0
 gfx::Size BoxLayout::GetPreferredSize(View* host)
 {
     gfx::Rect bounds;
     int position = 0;
     for(int i=0; i<host->GetChildViewCount(); ++i)
     {
         View* child = host->GetChildViewAt(i);
         if(child->IsVisible())
         {
             gfx::Size size(child->GetPreferredSize());
             if(orientation_ == kHorizontal)
             {
                 gfx::Rect child_bounds(position, 0, size.width(), size.height());
                 bounds = bounds.Union(child_bounds);
                 position += size.width();
             }
             else
             {
                 gfx::Rect child_bounds(0, position, size.width(), size.height());
                 bounds = bounds.Union(child_bounds);
                 position += size.height();
             }
             position += between_child_spacing_;
         }
     }
     gfx::Insets insets(host->GetInsets());
     return gfx::Size(
         bounds.width()+insets.width()+2*inside_border_horizontal_spacing_,
         bounds.height()+insets.height()+2*inside_border_vertical_spacing_);
 }
Example #3
0
 gfx::Rect Label::GetAvailableRect() const
 {
     gfx::Rect bounds(gfx::Point(), size());
     gfx::Insets insets(GetInsets());
     bounds.Inset(insets.left(), insets.top(), insets.right(), insets.bottom());
     return bounds;
 }
Example #4
0
bool KWTextFrame::canAutoGrow()
{
    if (!m_canGrow)
        return false;
    KInsets textInsets = shape()->insets();
    textInsets += insets();
    const qreal effectiveHeight = shape()->size().height() - textInsets.top - textInsets.bottom;
    if (effectiveHeight - m_lastHeight < -0.2) { // shape shrunk!
        m_canGrow = false;
        m_minimumFrameHeight = effectiveHeight;
    }
    return m_canGrow;
}
Example #5
0
void KWFrameGeometry::open(KWFrame *frame)
{
    m_frame = frame;
    open(frame->shape());

    KWTextFrame *tfs = dynamic_cast<KWTextFrame*>(frame);
    if (tfs) {
        KInsets insets(tfs->insets());
        widget.marginsGB->setVisible(true);
        widget.leftMargin->changeValue(insets.left);
        widget.rightMargin->changeValue(insets.right);
        widget.topMargin->changeValue(insets.top);
        widget.bottomMargin->changeValue(insets.bottom);
    } else {
        widget.marginsGB->setVisible(false);
    }
}