KWFrameDialog::KWFrameDialog(const QList<KWFrame*> &frames, KWDocument *document, KWCanvas *canvas) : KPageDialog(canvas) , m_frameConnectSelector(0) , m_canvas(canvas) { m_state = new FrameConfigSharedState(document); setFaceType(Tabbed); m_generalFrameProperties = new KWGeneralFrameProperties(m_state); addPage(m_generalFrameProperties, i18n("General")); m_generalFrameProperties->open(frames); m_anchoringProperties = new KWAnchoringProperties(m_state); if (m_anchoringProperties->open(frames)) addPage(m_anchoringProperties, i18n("Smart Positioning")); m_runAroundProperties = new KWRunAroundProperties(m_state); if (m_runAroundProperties->open(frames)) addPage(m_runAroundProperties, i18n("Text Run Around")); if (frames.count() == 1) { m_frameConnectSelector = new KWFrameConnectSelector(m_state); KWFrame *frame = frames.first(); m_state->setKeepAspectRatio(frame->shape()->keepAspectRatio()); if (m_frameConnectSelector->open(frame)) addPage(m_frameConnectSelector, i18n("Connect Text Frames")); else { delete m_frameConnectSelector; m_frameConnectSelector = 0; } } connect(this, SIGNAL(okClicked()), this, SLOT(okClicked())); connect(this, SIGNAL(cancelClicked()), this, SLOT(cancelClicked())); }
void KWFrameGeometry::cancel() { KWFrame *frame = m_frame; if (frame == 0) { frame = m_state->frame(); m_state->markFrameUsed(); } Q_ASSERT(frame); frame->shape()->setPosition(m_originalPosition); frame->shape()->setSize(m_originalSize); }
void KWFrameGeometry::setGeometryAlignment(KFlake::Position position) { KWFrame *frame = m_frame; if (frame == 0) { frame = m_state->frame(); m_state->markFrameUsed(); } QPointF pos = frame->shape()->absolutePosition(position); m_blockSignals = true; widget.xPos->changeValue(pos.x()); widget.yPos->changeValue(pos.y() - m_topOfPage); m_blockSignals = false; }
void KWFrameSet::cleanupFrames() { kDebug(32001) << "type=" << m_type << "frameCount=" << frames().count(); while (!frames().isEmpty()) { // deleting a shape can result in multiple KWFrame's and shapes being deleted (e.g. copy-shapes) KWFrame *f = frames().last(); if (f->shape()) { delete f->shape(); // deletes also the KWFrame and calls KWFrameSet::removeFrame Q_ASSERT(!frames().contains(f)); } else { removeFrame(f); } } }
void KWFrameGeometry::protectSizeChanged(int protectSizeState) { KWFrame *frame = m_frame; if (frame == 0) { frame = m_state->frame(); m_state->markFrameUsed(); } Q_ASSERT(frame); bool lock = (protectSizeState == Qt::Checked); frame->shape()->setGeometryProtected(lock); widget.xPos->setDisabled(lock); widget.yPos->setDisabled(lock); widget.width->setDisabled(lock); widget.height->setDisabled(lock); widget.keepAspect->setDisabled(lock); }
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(); }
void KWFrameSet::addFrame(KWFrame *frame) { Q_ASSERT(frame); kDebug(32001) << "frame=" << frame << "frameSet=" << frame->frameSet(); Q_ASSERT(!m_frames.contains(frame)); m_frames.append(frame); // this one first, so we don't enter the addFrame twice. frame->setFrameSet(this); setupFrame(frame); if (frame->isCopy()) { KWCopyShape* copyShape = dynamic_cast<KWCopyShape*>(frame->shape()); if (copyShape && copyShape->original()) { KWFrame *originalFrame = dynamic_cast<KWFrame*>(copyShape->original()->applicationData()); if (originalFrame) { originalFrame->addCopy(frame); } } } emit frameAdded(frame); }
void KWFrameSet::removeFrame(KWFrame *frame, KoShape *shape) { Q_ASSERT(frame); if (frame->isCopy()) { KWCopyShape* copyShape = dynamic_cast<KWCopyShape*>(frame->shape()); if (copyShape && copyShape->original()) { KWFrame *originalFrame = dynamic_cast<KWFrame*>(copyShape->original()->applicationData()); if (originalFrame) { originalFrame->removeCopy(frame); } } } else { //TODO use the copyFrame-list the KWFrame's remembers now // Loop over all frames to see if there is a copy frame that references the removed // frame; if it does, then delete the copy too. for(int i = frames().count() - 1; i >= 0; --i) { KWFrame *frame = frames()[i]; if (KWCopyShape *cs = dynamic_cast<KWCopyShape*>(frame->shape())) { if (cs->original() == shape) { Q_ASSERT(frame->frameSet() == this); frame->cleanupShape(cs); removeFrame(frame, cs); delete cs; } } } } if (m_frames.removeAll(frame)) { frame->setFrameSet(0); emit frameRemoved(frame); } }
void KWFrameViewTester::testGetView() { TestFrameViewManager fvm; KWFrameSet *fs = new TestFrameSet(); KWFrame *frame = new KWFrame(fs, 0, 0, 100, 100); fs->addFrame(frame); fvm.slotFrameAdded(frame); KWFrameView *fv = fvm.view(frame); CHECK(fv != 0, true); if(!fv) return; CHECK(fv->frame(), frame); fv = fvm.view( KoPoint(0,0), KWFrameViewManager::frameOnTop); CHECK(fv != 0, true); // should exist if(!fv) return; CHECK(fv->frame(), frame); fv = fvm.view( KoPoint(1,1), KWFrameViewManager::frameOnTop); CHECK(fv != 0, true); if(!fv) return; CHECK(fv->frame(), frame); fv = fvm.view( KoPoint(110,110), KWFrameViewManager::frameOnTop); CHECK(fv == 0, true); fv = fvm.view( KoPoint(100,100), KWFrameViewManager::frameOnTop); // note that 100,100 _is_ inside 0,0 100x100 CHECK(fv != 0, true); if(!fv) return; CHECK(fv->frame(), frame); fv->setSelected(true); fv = fvm.view( KoPoint(1,1), KWFrameViewManager::unselected); CHECK(fv == 0, true); frame->setZOrder(4); KWFrame *frame2 = new KWFrame(fs, 80, 50, 60, 60); frame2->setZOrder(2); fvm.slotFrameAdded(frame2); KWFrame *frame3 = new KWFrame(fs, 30, 60, 60, 60); frame3->setZOrder(5); fvm.slotFrameAdded(frame3); KWFrame *frame4 = new KWFrame(fs, 200, 0, 100, 100); fvm.slotFrameAdded(frame4); frame4->setZOrder(1); kdDebug() << "frame:" << frame << ", frame2:" << frame2<< ", frame2:" << frame3<< ", frame2:" << frame4 << endl; fv = fvm.view( KoPoint(90,60), KWFrameViewManager::frameOnTop); CHECK(fv != 0, true); if(!fv) return; CHECK(fv->frame(), frame3); fv = fvm.view( KoPoint(90,60), KWFrameViewManager::frameOnTop); // second time should give the same results CHECK(fv != 0, true); if(!fv) return; CHECK(fv->frame(), frame3); fv = fvm.view( KoPoint(90,60), KWFrameViewManager::selected); CHECK(fv != 0, true); if(!fv) return; CHECK(fv->frame(), frame); fv = fvm.view( KoPoint(90,60), KWFrameViewManager::selected); // second time should give the same results CHECK(fv != 0, true); if(!fv) return; CHECK(fv->frame(), frame); fv = fvm.view( KoPoint(90,60), KWFrameViewManager::nextUnselected); CHECK(fv != 0, true); if(!fv) return; CHECK(fv->frame(), frame2); // the one directly below the selected frame }
void KWDocStructPartItem::selectItem() { KWFrame* frame = m_part->frame(0); gui()->canvasWidget()->scrollToOffset(frame->topLeft()); }
void KWDocStructTableItem::selectItem() { KWFrame* frame = m_table->cell( 0, 0 )->frame( 0 ); gui()->canvasWidget()->scrollToOffset(frame->topLeft()); }
void KWDocStructTextFrameSetItem::selectItem() { KWFrame* frame = m_frameset->frame(0); if (!frame) return; gui()->canvasWidget()->scrollToOffset(frame->topLeft()); }