Commit 0e6611cb authored by Thomas Zander's avatar Thomas Zander

To make it anywhere near workable to change the libs, I disabled much of the apps

to compile; so I can't commit every now and then (since it takes 90 min to check
if I didn't break anything)

* Refactoring kword into part/
* Merge with darcs:
Sun Jun 25 09:50:38 CEST 2006  Thomas Zander <zander@kde.org>
  * add api dox
    M ./kofficecore/KoProperties.h -1 +50

Sun Jun 25 09:33:00 CEST 2006  Thomas Zander <zander@kde.org>
  * Cleanup QDebug includes, use kDebug

    M ./flake/KoCreateShapeStrategy.cpp -3 +1
    M ./flake/KoCreateShapesTool.cpp -1
    M ./flake/KoInteractionTool.cpp -1
    M ./flake/KoRectangleShapeFactory.cpp -1
    M ./flake/KoRepaintManager.cpp -1
    M ./flake/KoSelection.cpp -1
    M ./flake/KoShape.cpp -1 +1
    M ./flake/KoShapeContainer.cpp -3 +2
    M ./flake/KoShapeManager.cpp -2 +1
    M ./flake/KoShapeMoveStrategy.cpp -1
    M ./flake/KoShapeResizeStrategy.cpp -2
    M ./flake/KoShapeRotateStrategy.cpp -1
    M ./flake/KoShapeRubberSelectStrategy.cpp -2

Fri Jun 23 22:09:11 CEST 2006  Thomas Zander <zander@kde.org>
  * add api docs

    M ./kofficecore/KoPageLayout.h +2

Fri Jun 23 16:31:23 CEST 2006  Thomas Zander <zander@kde.org>
  * Allow external document

    M ./kotext/KoTextShape.cpp -22 +22
    M ./kotext/KoTextShape.h -11 +7
    M ./kotext/KoTextShapeFactory.cpp -1 +6

Wed Jun 21 09:19:36 CEST 2006  Thomas Zander <zander@kde.org>
  * Make ID for textShape

    M ./kotext/KoTextShape.h +2
    M ./kotext/KoTextShapeFactory.cpp -1 +1

Tue Jun 20 16:43:47 CEST 2006  Thomas Zander <zander@kde.org>
  * Fix width/height reporting

    M ./flake/KoCanvasController.cpp -6 +17

Tue Jun 20 09:47:48 CEST 2006  Thomas Zander <zander@kde.org>
    * Rename viewToNormal and normalToView to
    viewToDocument and documentToView (by popular demand)


svn path=/trunk/koffice/; revision=554763
parent b705ed1a
......@@ -20,12 +20,12 @@
#include "KoCanvasController.h"
#include <QGridLayout>
#include <QDebug>
#include <QScrollBar>
KoCanvasController::KoCanvasController(QWidget *parent)
: QScrollArea(parent)
, m_canvas(0)
, m_canvasWidget(0)
{
m_viewport = new Viewport();
setWidget(m_viewport);
......@@ -49,11 +49,27 @@ KoCanvasBase* KoCanvasController::canvas() const {
}
int KoCanvasController::visibleHeight() const {
return qMin(m_viewport->width(), m_canvasWidget->width());
int height1;
if(m_canvasWidget == 0)
height1 = m_viewport->height();
else
height1 = qMin(m_viewport->height(), m_canvasWidget->height());
int height2 = height();
if(horizontalScrollBar())
height2 -= horizontalScrollBar()->height();
return qMin(height1, height2);
}
int KoCanvasController::visibleWidth() const {
return qMin(m_viewport->height(), m_canvasWidget->height());
int width1;
if(m_canvasWidget == 0)
width1 = m_viewport->width();
else
width1 = qMin(m_viewport->width(), m_canvasWidget->width());
int width2 = width();
if(verticalScrollBar())
width2 -= verticalScrollBar()->width();
return qMin(width1, width2);
}
void KoCanvasController::centerCanvas(bool centered) {
......
......@@ -24,9 +24,7 @@
#include "KoCommand.h"
#include "KoCanvasBase.h"
#include "KoProperties.h"
#include <kdebug.h>
#include "KoProperties.h"
KoCreateShapeStrategy::KoCreateShapeStrategy( KoCreateShapesTool *tool, KoCanvasBase *canvas, const QPointF &clicked)
: KoShapeRubberSelectStrategy(tool, canvas, clicked)
......
......@@ -20,7 +20,6 @@
#include "KoCreateShapesTool.h"
#include <QDebug>
#include <QMouseEvent>
#include <QPainter>
......
......@@ -21,7 +21,6 @@
#include "KoInteractionTool.h"
#include <QDebug>
#include <QMouseEvent>
#include <QPainter>
......@@ -112,7 +111,7 @@ void KoInteractionTool::paint( QPainter &painter, KoViewConverter &converter) {
painter.setPen( pen );
bool editable=false;
foreach(KoShape *shape, selection()->selectedObjects(KoFlake::StrippedSelection)) {
painter.drawRect( converter.normalToView(shape->boundingRect()) );
painter.drawRect( converter.documentToView(shape->boundingRect()) );
if(!shape->isLocked())
editable = true;
}
......@@ -163,7 +162,7 @@ void KoInteractionTool::mouseMoveEvent( KoPointerEvent *event ) {
QRectF KoInteractionTool::handlesSize() {
QRectF bound = selection()->boundingRect();
// expansion Border
QPointF border = m_canvas->viewConverter()->viewToNormal(QPointF(HANDLE_DISTANCE, HANDLE_DISTANCE));
QPointF border = m_canvas->viewConverter()->viewToDocument(QPointF(HANDLE_DISTANCE, HANDLE_DISTANCE));
bound.adjust(-border.x(), -border.y(), border.x(), border.y());
return bound;
}
......@@ -226,7 +225,7 @@ KoFlake::SelectionHandle KoInteractionTool::handleAt(const QPointF &point, bool
if(innerHandleMeaning != 0)
*innerHandleMeaning = false;
for ( int i = 0; i < KoFlake::NoHandle; ++i ) {
QPointF pt = converter->normalToView( point ) - converter->normalToView( m_selectionBox[i] ) - m_handleDiff[i];
QPointF pt = converter->documentToView( point ) - converter->documentToView( m_selectionBox[i] ) - m_handleDiff[i];
// if between outline and out handles;
if(qAbs(pt.x()) < HANDLE_DISTANCE && qAbs(pt.y()) < HANDLE_DISTANCE)
return static_cast<KoFlake::SelectionHandle> (i);
......@@ -289,7 +288,7 @@ void SelectionDecorator::paint(QPainter &painter, KoViewConverter &converter) {
painter.setPen(pen);
painter.setBrush(Qt::yellow);
QRectF bounds = converter.normalToView(m_bounds);
QRectF bounds = converter.documentToView(m_bounds);
// the 4 move rects
pen.setWidthF(0);
......
......@@ -29,5 +29,5 @@ KoRectangleShape::KoRectangleShape() : KoShape() {
void KoRectangleShape::paint(QPainter &painter, KoViewConverter &converter) {
painter.setBrush(background());
painter.drawRect( converter.normalToView(QRectF( 0, 0, size().width(), size().height() ) ));
painter.drawRect( converter.documentToView(QRectF( 0, 0, size().width(), size().height() ) ));
}
......@@ -23,7 +23,6 @@
#include <klocale.h>
#include <kglobal.h>
#include <kdebug.h>
KoRectangleShapeFactory::KoRectangleShapeFactory(QObject *parent, const QStringList&)
: KoShapeFactory(parent, KoRectangleShape_SHAPEID, i18n("A simple square shape"))
......
......@@ -24,7 +24,6 @@
#include "KoTool.h"
#include <QRectF>
#include <QDebug>
KoRepaintManager::KoRepaintManager(KoCanvasBase *canvas, KoSelection *selection)
: m_canvas (canvas)
......
......@@ -25,7 +25,6 @@
#include "KoPointerEvent.h"
#include <QPainter>
#include <QDebug>
#include <QTimer>
KoSelection::KoSelection()
......@@ -42,7 +41,7 @@ void KoSelection::paint( QPainter &painter, KoViewConverter &converter)
if ( count() == 0 )
return;
painter.setRenderHint( QPainter::Antialiasing, false );
QRectF bb = converter.normalToView( boundingRect() );
QRectF bb = converter.documentToView( boundingRect() );
QPen pen( Qt::blue ); //TODO make it configurable
painter.setPen( pen );
painter.drawRect( bb );
......
......@@ -65,7 +65,7 @@ void KoShape::paintDecorations(QPainter &painter, KoViewConverter &converter, bo
painter.setBrush( Qt::NoBrush );
for ( int i = 0; i < m_connectors.size(); ++i )
{
QPointF p = converter.normalToView(m_connectors[ i ]);
QPointF p = converter.documentToView(m_connectors[ i ]);
painter.drawLine( QPointF( p.x() - 2, p.y() + 2 ), QPointF( p.x() + 2, p.y() - 2 ) );
painter.drawLine( QPointF( p.x() + 2, p.y() + 2 ), QPointF( p.x() - 2, p.y() - 2 ) );
}
......@@ -147,7 +147,7 @@ QMatrix KoShape::transformationMatrix(KoViewConverter *converter) const {
QMatrix matrix;
QRectF zoomedRect = QRectF(position(), size());
if(converter)
zoomedRect = converter->normalToView(zoomedRect);
zoomedRect = converter->documentToView(zoomedRect);
matrix.translate( zoomedRect.x(), zoomedRect.y() );
// apply parents matrix to inherit any transformations done there.
......@@ -159,7 +159,7 @@ QMatrix KoShape::transformationMatrix(KoViewConverter *converter) const {
else {
QPointF containerPos =container->position();
if(converter)
containerPos = converter->normalToView(containerPos);
containerPos = converter->documentToView(containerPos);
matrix.translate(containerPos.x(), containerPos.y());
}
container = dynamic_cast<KoShapeContainer*>(container->parent());
......@@ -274,7 +274,7 @@ void KoShape::setAbsolutePosition(QPointF newPosition) {
matrix.translate( -size().width() / 2.0, -size().height() / 2.0 );
QPointF vector2 = matrix.map( QPointF(size().width() / 2.0, size().height() / 2.0) );
//qDebug() << "vector1: " << vector1 << ", vector2: " << vector2;
//kDebug() << "vector1: " << vector1 << ", vector2: " << vector2 << endl;
setPosition(newPosition + vector1 - vector2);
}
......
......@@ -21,7 +21,6 @@
#include <QPointF>
#include <QPainter>
#include <QDebug>
KoShapeContainer::KoShapeContainer() : KoShape() {
m_children = 0;
......@@ -88,14 +87,14 @@ void KoShapeContainer::paint(QPainter &painter, KoViewConverter &converter) {
if( childClipped(shape) ) {
QRectF clipRect(QPointF(0, 0), size());
clipRect = converter.normalToView(clipRect);
clipRect = converter.documentToView(clipRect);
QPolygon clip = myMatrix.mapToPolygon(clipRect.toRect());
clip.translate( (position() - converter.normalToView(position())).toPoint() );
clip.translate( (position() - converter.documentToView(position())).toPoint() );
painter.setClipRegion(QRegion(clip));
}
//qDebug() << "rect: " << position();
//qDebug() << "polygon: " << clip.boundingRect();
//kDebug() << "rect: " << position() << endl;
//kDebug() << "polygon: " << clip.boundingRect() << endl;
//painter.drawPolygon(clip);
painter.setMatrix( shape->transformationMatrix(&converter) * painter.matrix() );
shape->paint(painter, converter);
......
......@@ -28,7 +28,6 @@
#include "KoShapeBorderModel.h"
#include "KoRepaintManager.moc"
#include <QDebug>
#include <QPainter>
KoShapeManager::KoShapeManager( KoCanvasBase *canvas, const QList<KoShape *> &shapes )
......@@ -87,7 +86,7 @@ void KoShapeManager::paint( QPainter &painter, KoViewConverter &converter, bool
continue;
if(painter.hasClipping()) {
QRectF shapeBox = shape->boundingRect();
shapeBox = converter.normalToView(shapeBox);
shapeBox = converter.documentToView(shapeBox);
QRegion shapeRegion = QRegion(shapeBox.toRect());
if(clipRegion.intersect(shapeRegion).isEmpty())
......@@ -124,7 +123,7 @@ KoShape * KoShapeManager::shapeAt( const QPointF &position )
for(int count = sorterdShapes.count()-1; count >= 0; count--) {
if ( sorterdShapes.at(count)->hitTest( position ) )
{
//qDebug() << "Hittest succeeded";
//kDebug() << "Hittest succeeded" << endl;
return sorterdShapes.at(count);
}
}
......
......@@ -22,7 +22,6 @@
#include "KoShapeMoveStrategy.h"
#include <QPainter>
#include <QDebug>
#include <QMouseEvent>
#include "KoCanvasBase.h"
......
......@@ -23,8 +23,6 @@
#include "KoCanvasBase.h"
#include "KoCommand.h"
#include <QDebug>
KoShapeResizeStrategy::KoShapeResizeStrategy( KoTool *tool, KoCanvasBase *canvas,
const QPointF &clicked, KoFlake::SelectionHandle direction )
: KoInteractionStrategy(tool, canvas)
......
......@@ -24,7 +24,6 @@
#include "KoShapeManager.h"
#include "KoCommand.h"
#include <QDebug>
#include <QPointF>
#include <math.h>
......
......@@ -22,7 +22,6 @@
#include "KoShapeRubberSelectStrategy.h"
#include <QPainter>
#include <QDebug>
#include <QMouseEvent>
#include "KoPointerEvent.h"
......@@ -52,7 +51,7 @@ void KoShapeRubberSelectStrategy::paint( QPainter &painter, KoViewConverter &con
QBrush sb( selectColor, Qt::SolidPattern );
painter.setPen( QPen( sb, 0 ) );
painter.setBrush( sb );
QRectF paintRect = converter.normalToView(m_selectRect);
QRectF paintRect = converter.documentToView(m_selectRect);
if(painter.hasClipping())
paintRect = paintRect.intersect(painter.clipRegion().boundingRect());
painter.drawRect( paintRect);
......@@ -91,7 +90,6 @@ void KoShapeRubberSelectStrategy::finishInteraction()
const QList<KoShape *> &shapes = m_canvas->shapeManager()->shapes();
foreach ( KoShape * object, shapes )
{
//qDebug() << "o bb:" << object->boundingRect() << ", m_selectRect:" << m_selectRect;
if ( object->boundingRect().intersects( m_selectRect ) )
{
selection->select( object );
......
......@@ -37,27 +37,27 @@ public:
/**
* Convert a coordinate in pt to pixels.
* @param normalPoint the point in the normal coordinate system of a KoShape.
* @param documentPoint the point in the document coordinate system of a KoShape.
*/
virtual QPointF normalToView( const QPointF &normalPoint ) = 0;
virtual QPointF documentToView( const QPointF &documentPoint ) = 0;
/**
* Convert a coordinate in pixels to pt.
* @param viewPoint the point in the coordinate system of the widget, or window.
*/
virtual QPointF viewToNormal( const QPointF &viewPoint ) = 0;
virtual QPointF viewToDocument( const QPointF &viewPoint ) = 0;
/**
* Convert a rectangle in pt to pixels.
* @param normalRect the rect in the normal coordinate system of a KoShape.
* @param documentRect the rect in the document coordinate system of a KoShape.
*/
virtual QRectF normalToView( const QRectF &normalRect ) = 0;
virtual QRectF documentToView( const QRectF &documentRect ) = 0;
/**
* Convert a rectangle in pixels to pt.
* @param viewRect the rect in the coordinate system of the widget, or window.
*/
virtual QRectF viewToNormal( const QRectF &viewRect ) = 0;
virtual QRectF viewToDocument( const QRectF &viewRect ) = 0;
/**
* set the zoom levels of the individual x and y axis to the pointer paramets.
......
......@@ -583,7 +583,7 @@ QImage Container::drawImage( int width, int height )
double f = qMax( static_cast<double>( width )/static_cast<double>( realWidth ),
static_cast<double>( height )/static_cast<double>( realHeight ) );
int oldZoom = context.zoom();
int oldZoom = context.zoomInPercent();
context.setZoomAndResolution( qRound( oldZoom*f ), KoGlobal::dpiX(), KoGlobal::dpiY() );
QPixmap pm( context.layoutUnitToPixelX( m_formulaElement->getWidth() ),
......@@ -592,6 +592,7 @@ QImage Container::drawImage( int width, int height )
QPainter paint(&pm);
m_formulaElement->draw(paint, rect.toRect(), context);
paint.end();
// FIXME store and reset zoomedResolution as well as zoom. This is lossy
context.setZoomAndResolution( oldZoom, KoGlobal::dpiX(), KoGlobal::dpiY() );
return pm.toImage();
}
......
......@@ -176,7 +176,9 @@ struct KoPageLayout
double ptTop;
/** Bottom margin in pt */
double ptBottom;
/// margin on page edge
double ptPageEdge;
/// margin on page-binding edge
double ptBindingSide;
bool operator==( const KoPageLayout& l ) const {
......
......@@ -22,7 +22,6 @@
#include <QString>
#include <QMap>
#include <QVariant>
#include <kdebug.h>
#include "koffice_export.h"
......@@ -73,11 +72,61 @@ public:
*/
virtual bool getProperty(const QString & name, QVariant & value) const;
/**
* Return a property by name, wrapped in a QVariant.
* A typical usage:
* @code
* KoProperties *props = new KoProperties();
* props->setProperty("name", "Marcy");
* props->setProperty("age", 25);
* QString name = props->getProperty("name").toString();
* int age = props->getProperty("age").toInt();
* @endcode
* @return a property by name, wrapped in a QVariant.
* @param name the name (or key) with which the variant was registred.
* @see getInt() getString()
*/
virtual QVariant getProperty(const QString & name) const;
/**
* Return an integer property by name.
* A typical usage:
* @code
* KoProperties *props = new KoProperties();
* props->setProperty("age", 25);
* int age = props->getInt("age");
* @endcode
* @return an integer property by name
* @param name the name (or key) with which the variant was registred.
* @param def the default value, should there not be no propery by the name this will be returned.
* @see getProperty() getString()
*/
int getInt(const QString & name, int def = 0) const;
/**
* Return a double property by name.
* @param name the name (or key) with which the variant was registred.
* @param def the default value, should there not be no propery by the name this will be returned.
*/
double getDouble(const QString & name, double def = 0.0) const;
/**
* Return a boolean property by name.
* @param name the name (or key) with which the variant was registred.
* @param def the default value, should there not be no propery by the name this will be returned.
*/
bool getBool(const QString & name, bool def = false) const;
/**
* Return an QString property by name.
* A typical usage:
* @code
* KoProperties *props = new KoProperties();
* props->setProperty("name", "Marcy");
* QString name = props->getString("name");
* @endcode
* @return an QString property by name
* @param name the name (or key) with which the variant was registred.
* @see getProperty() getInt()
* @param def the default value, should there not be no propery by the name this will be returned.
*/
QString getString(const QString & name, QString def = QString::null) const;
private:
......
......@@ -191,17 +191,17 @@ void KoShapeSelector::add(KoShape *shape) {
// event handlers
void KoShapeSelector::mouseMoveEvent(QMouseEvent *e) {
KoPointerEvent ev(e, QPointF( m_canvas->viewConverter()->viewToNormal(e->pos()) ));
KoPointerEvent ev(e, QPointF( m_canvas->viewConverter()->viewToDocument(e->pos()) ));
m_tool->mouseMoveEvent( &ev );
}
void KoShapeSelector::mousePressEvent(QMouseEvent *e) {
KoPointerEvent ev(e, QPointF( m_canvas->viewConverter()->viewToNormal(e->pos()) ));
KoPointerEvent ev(e, QPointF( m_canvas->viewConverter()->viewToDocument(e->pos()) ));
m_tool->mousePressEvent( &ev );
}
void KoShapeSelector::mouseReleaseEvent(QMouseEvent *e) {
KoPointerEvent ev(e, QPointF( m_canvas->viewConverter()->viewToNormal(e->pos()) ));
KoPointerEvent ev(e, QPointF( m_canvas->viewConverter()->viewToDocument(e->pos()) ));
m_tool->mouseReleaseEvent( &ev );
}
......@@ -239,19 +239,19 @@ bool KoShapeSelector::event(QEvent *e) {
}
// ************ DummyViewConverter **********
QPointF KoShapeSelector::DummyViewConverter::normalToView (const QPointF &normalPoint) {
return normalPoint;
QPointF KoShapeSelector::DummyViewConverter::documentToView (const QPointF &documentPoint) {
return documentPoint;
}
QPointF KoShapeSelector::DummyViewConverter::viewToNormal (const QPointF &viewPoint) {
QPointF KoShapeSelector::DummyViewConverter::viewToDocument (const QPointF &viewPoint) {
return viewPoint;
}
QRectF KoShapeSelector::DummyViewConverter::normalToView (const QRectF &normalRect) {
return normalRect;
QRectF KoShapeSelector::DummyViewConverter::documentToView (const QRectF &documentRect) {
return documentRect;
}
QRectF KoShapeSelector::DummyViewConverter::viewToNormal (const QRectF &viewRect) {
QRectF KoShapeSelector::DummyViewConverter::viewToDocument (const QRectF &viewRect) {
return viewRect;
}
......
......@@ -59,10 +59,10 @@ private:
private:
/// \internal
class DummyViewConverter : public KoViewConverter {
QPointF normalToView (const QPointF &normalPoint);
QPointF viewToNormal (const QPointF &viewPoint);
QRectF normalToView (const QRectF &normalRect);
QRectF viewToNormal (const QRectF &viewRect);
QPointF documentToView (const QPointF &documentPoint);
QPointF viewToDocument (const QPointF &viewPoint);
QRectF documentToView (const QRectF &documentRect);
QRectF viewToDocument (const QRectF &viewRect);
void zoom (double *zoomX, double *zoomY) const;
};
......
......@@ -107,6 +107,7 @@ private:
QStack<KoTool*> m_stack;
};
/// \internal
class ToolHelper : public QObject {
Q_OBJECT
public:
......
......@@ -34,7 +34,7 @@ void KoZoomHandler::setZoomAndResolution( int zoom, int dpiX, int dpiY )
// m_resolution[XY] is in pixel per pt
m_resolutionX = POINT_TO_INCH( static_cast<double>(dpiX) );
m_resolutionY = POINT_TO_INCH( static_cast<double>(dpiY) );
setZoom( zoom );
setZoom( zoom / 100.0 );
/*kDebug(32500) << "KoZoomHandler::setZoomAndResolution " << zoom << " " << dpiX << "," << dpiY
<< " m_resolutionX=" << m_resolutionX
<< " m_zoomedResolutionX=" << m_zoomedResolutionX
......@@ -44,7 +44,7 @@ void KoZoomHandler::setZoomAndResolution( int zoom, int dpiX, int dpiY )
void KoZoomHandler::setResolution( double resolutionX, double resolutionY )
{
m_zoom = 100;
m_zoom = 1.0;
m_resolutionX = resolutionX;
m_resolutionY = resolutionY;
m_zoomedResolutionX = resolutionX;
......@@ -60,34 +60,39 @@ void KoZoomHandler::setZoomedResolution( double zoomedResolutionX, double zoomed
m_zoomedResolutionY = zoomedResolutionY;
}
void KoZoomHandler::setZoom( int zoom )
void KoZoomHandler::setZoom( double zoom )
{
m_zoom = zoom;
if( m_zoom == 100 ) {
if( m_zoom == 1.0 ) {
m_zoomedResolutionX = m_resolutionX;
m_zoomedResolutionY = m_resolutionY;
} else {
m_zoomedResolutionX = static_cast<double>(m_zoom) * m_resolutionX / 100.0;
m_zoomedResolutionY = static_cast<double>(m_zoom) * m_resolutionY / 100.0;
m_zoomedResolutionX = m_zoom * m_resolutionX;
m_zoomedResolutionY = m_zoom * m_resolutionY;
}
}
QPointF KoZoomHandler::normalToView( const QPointF &normalPoint ) {
return QPointF( zoomItX( normalPoint.x() ), zoomItY( normalPoint.y() ) );
void KoZoomHandler::setZoom( int zoom )
{
setZoom(zoom / 100.0);
}
QPointF KoZoomHandler::documentToView( const QPointF &documentPoint ) {
return QPointF( zoomItX( documentPoint.x() ), zoomItY( documentPoint.y() ) );
}
QPointF KoZoomHandler::viewToNormal( const QPointF &viewPoint ) {
QPointF KoZoomHandler::viewToDocument( const QPointF &viewPoint ) {
return QPointF( unzoomItX( viewPoint.x() ), unzoomItY( viewPoint.y() ) );
}
QRectF KoZoomHandler::normalToView( const QRectF &normalRect ) {
QRectF KoZoomHandler::documentToView( const QRectF &documentRect ) {
QRectF r;
r.setCoords( zoomItX( normalRect.left() ), zoomItY( normalRect.top() ),
zoomItX( normalRect.right() ), zoomItY( normalRect.bottom() ) );
r.setCoords( zoomItX( documentRect.left() ), zoomItY( documentRect.top() ),
zoomItX( documentRect.right() ), zoomItY( documentRect.bottom() ) );
return r;
}
QRectF KoZoomHandler::viewToNormal( const QRectF &viewRect ) {
QRectF KoZoomHandler::viewToDocument( const QRectF &viewRect ) {
QRectF r;
r.setCoords( unzoomItX( viewRect.left() ), unzoomItY( viewRect.top() ),
unzoomItX( viewRect.right() ), unzoomItY( viewRect.bottom() ) );
......
......@@ -84,8 +84,15 @@ public:
/**
* Change the zoom level, keeping the resolution unchanged.
* @param zoom the zoom factor (e.g. 100 for 100%)
* \deprecated
*/
void setZoom( int zoom );
/**
* Change the zoom level, keeping the resolution unchanged.
* @param zoom the zoom factor (e.g. 1.0 for 100%)
*/
void setZoom( double zoom );
/**
* Change the zoom mode
* @param zoomMode the zoom mode.
......@@ -95,13 +102,13 @@ public:
* @return the global zoom factor (e.g. 100 for 100%).
* Only use this to display to the user, don't use in calculations
*/
int zoom() const { return m_zoom; }
int zoomInPercent() const { return qRound(m_zoom * 100); }
/**
* @return the global zoom mode (e.g. KoZoomMode::ZOOM_WIDTH).
* use this to determine how to zoom
*/
KoZoomMode::Mode zoomMode() const { return m_zoomMode; }
// Input: pt. Output: pixels. Resolution and zoom are applied.
int zoomItXOld( double z ) const {
return qRound( m_zoomedResolutionX * z );
......@@ -166,27 +173,27 @@ public:
/**
* Convert a coordinate in pt to pixels.
* @param normalPoint the point in the normal coordinate system of a KoShape.
* @param documentPoint the point in the document coordinate system of a KoShape.
*/
QPointF normalToView( const QPointF &normalPoint );
QPointF documentToView( const QPointF &documentPoint );
/**
* Convert a coordinate in pixels to pt.
* @param viewPoint the point in the coordinate system of the widget, or window.
*/
QPointF viewToNormal( const QPointF &viewPoint );
QPointF viewToDocument( const QPointF &viewPoint );
/**
* Convert a rectangle in pt to pixels.
* @param normalRect the rect in the normal coordinate system of a KoShape.
* @param documentRect the rect in the document coordinate system of a KoShape.
*/
QRectF normalToView( const QRectF &normalRect );
QRectF documentToView( const QRectF &documentRect );
/**
* Convert a rectangle in pixels to pt.
* @param viewRect the rect in the coordinate system of the widget, or window.
*/
QRectF viewToNormal( const QRectF &viewRect );
QRectF viewToDocument( const QRectF &viewRect );
/**
* set the zoom levels of the individual x and y axis to the pointer paramets.
......@@ -197,7 +204,7 @@ public:
protected:
int m_zoom;
double m_zoom;
KoZoomMode::Mode m_zoomMode;
double m_resolutionX;
......
......@@ -19,6 +19,8 @@ set(libkohyphen_SRCS
# KoComplexText.cpp not compiled
set(kotext_LIB_SRCS ${libkohyphen_SRCS}
KoTextShape.cpp
KoTextShapeFactory.cpp
KoRichText.cpp
KoTextZoomHandler.cpp
KoBorder.cpp
......
......@@ -24,40 +24,40 @@
#include <QFont>
#include <QAbstractTextDocumentLayout>
// ############ KoTextShapePrivate ################
KoTextShape::KoTextShapePrivate::KoTextShapePrivate()
{
m_document = new QTextDocument();
// The following avoids the normal case where the glyph metrices are rounded to integers and
// hinted to the screen by freetype, which you of course don't want to wysiwyg
m_document->setUseDesignMetrics(true);
m_document->setDefaultFont(QFont("Sans", 10, QFont::Normal, false));
m_document->setHtml( "<b>Koffie</b>, koffie... Querelanten\ndrinken geen KOffice maar groene thee.");
}
KoTextShape::KoTextShapePrivate::~KoTextShapePrivate() {
delete m_document;
}
// ############ KoTextShape ################
KoTextShape::KoTextShape() {
m_private = new KoTextShapePrivate();
KoTextShape::KoTextShape()
: m_document(0)
{
setDocument(new QTextDocument());
}
KoTextShape::~KoTextShape() {
delete m_private;
delete m_document;
}
void KoTextShape::paint(QPainter &painter, KoViewConverter &converter) {
painter.fillRect(converter.normalToView(QRectF(QPointF(0.0,0.0), size())), background());
painter.fillRect(converter.documentToView(QRectF(QPointF(0.0,0.0), size())), background());
applyConversion(painter, converter);
QAbstractTextDocumentLayout::PaintContext pc;
pc.cursorPosition = -1;
m_private->m_document->setPageSize(size());
m_private->m_document->documentLayout()->draw( &painter, pc);
m_document->setPageSize(size());
m_document->documentLayout()->draw( &painter, pc);
}
void KoTextShape::setDocument(QTextDocument *document) {