Commit ba426561 authored by Thomas Zander's avatar Thomas Zander

* Make the KoZoomHandler implement the KoViewConverter interface.

* Fix kformula includes to use the macro KOFFICEUI_INCLUDES
* Finish the KoCanvasBase implementation in KWCanvas.

svn path=/trunk/koffice/; revision=545104
parent 5a5cbf2c
......@@ -31,12 +31,14 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY
# for config.h and <toplevel/foo.h> includes (if any?)
include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} )
# flake is the lib that depends on nothing, but lost of the libs depend on flake
set(FLAKE_INCLUDES ${CMAKE_SOURCE_DIR}/libs/flake ${CMAKE_BINARY_DIR}/libs/flake)
# kostore is at the bottom of stack, so it has the dependency on the kde4 includes.
set(KOSTORE_INCLUDES ${CMAKE_SOURCE_DIR}/libs/store ${CMAKE_BINARY_DIR}/libs/store ${KDE4_INCLUDES})
# kofficecore depends on kostore
set(KOFFICECORE_INCLUDES ${CMAKE_SOURCE_DIR}/libs/kofficecore ${CMAKE_BINARY_DIR}/libs/kofficecore ${KOSTORE_INCLUDES})
# kofficeui depends on kofficecore
set(KOFFICEUI_INCLUDES ${CMAKE_SOURCE_DIR}/libs/kofficeui ${CMAKE_BINARY_DIR}/libs/kofficeui ${KOFFICECORE_INCLUDES})
set(KOFFICEUI_INCLUDES ${CMAKE_SOURCE_DIR}/libs/kofficeui ${CMAKE_BINARY_DIR}/libs/kofficeui ${KOFFICECORE_INCLUDES} ${FLAKE_INCLUDES} )
# The rest must be specified independently, in addition to one of the above three
set(KWMF_INCLUDES ${CMAKE_SOURCE_DIR}/libs/kwmf ${CMAKE_BINARY_DIR}/libs/kwmf)
......@@ -45,7 +47,6 @@ set(KOPAINTER_INCLUDES ${CMAKE_SOURCE_DIR}/libs/kopainter ${CMAKE_BINARY_DIR}/li
set(KOPALETTE_INCLUDES ${CMAKE_SOURCE_DIR}/libs/kopalette ${CMAKE_BINARY_DIR}/libs/kopalette)
set(KFORMULA_INCLUDES ${CMAKE_SOURCE_DIR}/libs/kformula ${CMAKE_BINARY_DIR}/libs/kformula)
set(KROSS_INCLUDES ${CMAKE_SOURCE_DIR}/libs/kross ${CMAKE_BINARY_DIR}/libs/kross)
set(FLAKE_INCLUDES ${CMAKE_SOURCE_DIR}/libs/flake ${CMAKE_BINARY_DIR}/libs/flake)
# Those are included with e.g. <koproperty/set.h>
set(KOPROPERTY_INCLUDES ${CMAKE_SOURCE_DIR}/libs ${CMAKE_BINARY_DIR}/libs)
......
......@@ -23,6 +23,8 @@
#include <QPointF>
#include <QRectF>
#include <koffice_export.h>
/**
* The interface for view conversions.
* All KoShape based objects are using a postscript-point (pt) based measurement system
......@@ -30,7 +32,7 @@
* we are painting, and a conversion to the normalized coordinate system if we
* receive mouse events so we can figure out which KoShape object was touched.
*/
class KoViewConverter {
class FLAKE_EXPORT KoViewConverter {
public:
KoViewConverter() {};
virtual ~KoViewConverter() {};
......
......@@ -4,10 +4,7 @@ add_subdirectory( pics )
add_subdirectory( fonts )
add_subdirectory( dtd )
include_directories(
${CMAKE_SOURCE_DIR}/libs/kotext/
${CMAKE_SOURCE_DIR}/libs/kofficeui/
${KOFFICECORE_INCLUDES} )
include_directories( ${KOTEXT_INCLUDES} ${KOFFICEUI_INCLUDES})
########### next target ###############
......
......@@ -71,3 +71,30 @@ void KoZoomHandler::setZoom( int zoom )
m_zoomedResolutionY = static_cast<double>(m_zoom) * m_resolutionY / 100.0;
}
}
QPointF KoZoomHandler::normalToView( const QPointF normalPoint ) {
return QPointF( zoomItX( normalPoint.x() ), zoomItY( normalPoint.y() ) );
}
QPointF KoZoomHandler::viewToNormal( const QPointF viewPoint ) {
return QPointF( unzoomItX( viewPoint.x() ), unzoomItY( viewPoint.y() ) );
}
QRectF KoZoomHandler::normalToView( const QRectF normalRect ) {
QRectF r;
r.setCoords( zoomItX( normalRect.left() ), zoomItY( normalRect.top() ),
zoomItX( normalRect.right() ), zoomItY( normalRect.bottom() ) );
return r;
}
QRectF KoZoomHandler::viewToNormal( const QRectF viewRect ) {
QRectF r;
r.setCoords( unzoomItX( viewRect.left() ), unzoomItY( viewRect.top() ),
unzoomItX( viewRect.right() ), unzoomItY( viewRect.bottom() ) );
return r;
}
void KoZoomHandler::zoom(double *zoomX, double *zoomY) const {
*zoomX = zoomItX(100.0) / 100.0;
*zoomY = zoomItY(100.0) / 100.0;
}
......@@ -23,13 +23,14 @@
#include <KoRect.h>
#include <koffice_export.h>
#include <KoZoomMode.h>
#include <KoViewConverter.h>
/**
* This class handles the zooming and DPI stuff (conversions between pt values and pixels).
* An instance of KoZoomHandler operates at a given zoom (see setZoomAndResolution() and setZoom())
* so there is usually one instance of KoZoomHandler per view.
*/
class KOFFICEUI_EXPORT KoZoomHandler
class KOFFICEUI_EXPORT KoZoomHandler : public KoViewConverter
{
public:
KoZoomHandler();
......@@ -108,6 +109,12 @@ public:
int zoomItYOld( double z ) const {
return qRound( m_zoomedResolutionY * z );
}
double zoomItX( double z ) const {
return m_zoomedResolutionX * z;
}
double zoomItY( double z ) const {
return m_zoomedResolutionY * z ;
}
QPoint zoomPointOld( const KoPoint & p ) const {
return QPoint( zoomItXOld( p.x() ), zoomItYOld( p.y() ) );
......@@ -139,6 +146,12 @@ public:
double unzoomItYOld( int y ) const {
return static_cast<double>( y ) / m_zoomedResolutionY;
}
double unzoomItX( double x ) const {
return x / m_zoomedResolutionX;
}
double unzoomItY( double y ) const {
return y / m_zoomedResolutionY;
}
KoPoint unzoomPointOld( const QPoint & p ) const {
return KoPoint( unzoomItXOld( p.x() ), unzoomItYOld( p.y() ) );
}
......@@ -149,6 +162,39 @@ public:
return _r;
}
// KoViewConverter-interface methods
/**
* Convert a coordinate in pt to pixels.
* @param normalPoint the point in the normal coordinate system of a KoShape.
*/
QPointF normalToView( const QPointF normalPoint );
/**
* 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 );
/**
* Convert a rectangle in pt to pixels.
* @param normalRect the rect in the normal coordinate system of a KoShape.
*/
QRectF normalToView( const QRectF normalRect );
/**
* 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 );
/**
* set the zoom levels of the individual x and y axis to the pointer paramets.
* @param zoomX a pointer to a double which will be modified to set the horizontal zoom.
* @param zoomY a pointer to a double which will be modified to set the vertical zoom.
*/
void zoom(double *zoomX, double *zoomY) const;
protected:
int m_zoom;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment