lib Library API Documentation

KoZoomHandler Class Reference

This class handles the zooming and DPI stuff (conversions between pt values and pixels). More...

#include <kozoomhandler.h>

Inheritance diagram for KoZoomHandler:

Inheritance graph
[legend]
Collaboration diagram for KoZoomHandler:

Collaboration graph
[legend]
List of all members.

Public Member Functions

virtual void setZoomAndResolution (int zoom, int dpiX, int dpiY)
double zoomedResolutionX () const
double zoomedResolutionY () const
double resolutionX () const
double resolutionY () const
double zoomFactorX () const
double zoomFactorY () const
void setResolution (double resolutionX, double resolutionY)
virtual void setZoomedResolution (double zoomedResolutionX, double zoomedResolutionY)
void setZoom (int zoom)
int zoom () const
int zoomItX (double z) const
int zoomItY (double z) const
QPoint zoomPoint (const KoPoint &p) const
QRect zoomRect (const KoRect &r) const
QSize zoomSize (const KoSize &s) const
double unzoomItX (int x) const
double unzoomItY (int y) const
KoPoint unzoomPoint (const QPoint &p) const
KoRect unzoomRect (const QRect &r) const
int pixelToLayoutUnitX (int x) const
int pixelToLayoutUnitY (int y) const
QPoint pixelToLayoutUnit (const QPoint &p) const
QRect pixelToLayoutUnit (const QRect &r) const
int layoutUnitToPixelX (int lupix) const
int layoutUnitToPixelY (int lupix) const
int layoutUnitToPixelX (int x, int w) const
int layoutUnitToPixelY (int y, int h) const
QPoint layoutUnitToPixel (const QPoint &p) const
QRect layoutUnitToPixel (const QRect &r) const
int ptToPixelX (double pt) const
int ptToPixelY (double pt) const
QPoint ptToPixel (const KoPoint &p) const
double pixelXToPt (int x) const
double pixelYToPt (int y) const
KoPoint pixelToPt (const QPoint &p) const
int ptToLayoutUnitPixX (double x_pt) const
int ptToLayoutUnitPixY (double y_pt) const
QPoint ptToLayoutUnitPix (const KoPoint &p) const
double layoutUnitToFontSize (int luSize, bool) const

Protected Attributes

int m_zoom
double m_resolutionX
double m_resolutionY
double m_zoomedResolutionX
double m_zoomedResolutionY

Detailed Description

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.

Definition at line 73 of file kozoomhandler.h.


Member Function Documentation

void KoZoomHandler::setZoomAndResolution int  zoom,
int  dpiX,
int  dpiY
[virtual]
 

Change the zoom factor to z (e.g.

150 for 150%) and/or change the resolution, given in DPI. This is done on startup, when zooming, and when printing. The same call combines both so that all the updating done behind the scenes is done only once, even if both zoom and DPI must be changed.

Reimplemented in ContextStyle.

Definition at line 37 of file kozoomhandler.cc.

References setZoom().

Referenced by ContextStyle::setZoomAndResolution().

double KoZoomHandler::zoomedResolutionX  )  const [inline]
 

Returns:
the conversion factor between pt and pixel, that takes care of the zoom and the DPI setting. Use zoomIt(pt) instead, though.

Definition at line 93 of file kozoomhandler.h.

double KoZoomHandler::zoomFactorX  )  const [inline]
 

Zoom factor for X.

Equivalent to zoomedResolutionX()/resolutionX()

Definition at line 102 of file kozoomhandler.h.

double KoZoomHandler::zoomFactorY  )  const [inline]
 

Zoom factor for Y.

Equivalent to zoomedResolutionY()/resolutionY()

Definition at line 106 of file kozoomhandler.h.

void KoZoomHandler::setResolution double  resolutionX,
double  resolutionY
 

Set a resolution for X and Y, when no zoom applies (e.g.

when painting an embedded document. This will set the zoom to 100, and it will set zoomedResolution[XY] to the resolution[XY] parameters Helper method, equivalent to setZoomAndResolution(100,...).

Definition at line 50 of file kozoomhandler.cc.

void KoZoomHandler::setZoomedResolution double  zoomedResolutionX,
double  zoomedResolutionY
[virtual]
 

Set the zoomed resolution for X and Y.

Compared to the setZoom... methods, this allows to set a different zoom factor for X and for Y.

Definition at line 59 of file kozoomhandler.cc.

void KoZoomHandler::setZoom int  zoom  ) 
 

Change the zoom level, keeping the resolution unchanged.

Parameters:
zoom the zoom factor (e.g. 100 for 100%)

Definition at line 68 of file kozoomhandler.cc.

Referenced by setZoomAndResolution().

int KoZoomHandler::zoom  )  const [inline]
 

Returns:
the global zoom factor (e.g. 100 for 100%). Only use this to display to the user, don't use in calculations

Definition at line 134 of file kozoomhandler.h.

Referenced by Container::drawImage().

QSize KoZoomHandler::zoomSize const KoSize s  )  const [inline]
 

Returns the size in pixels for a input size in points.

This function can return a size with 1 pixel to less, depending on the reference point and the width and/or the zoom level. It's save to use if the starting point is (0/0). You can use it if you don't know the starting point yet (like when inserting a picture), but then please take care of it afterwards, when you know the reference point.

Definition at line 163 of file kozoomhandler.h.

References KoSize::height(), and KoSize::width().

int KoZoomHandler::pixelToLayoutUnitX int  x  )  const
 

The "[zoomed] view pixel" -> "layout unit pixel" conversions.

Definition at line 127 of file kozoomhandler.cc.

References KoTextZoomHandler::m_layoutUnitFactor.

Referenced by Container::moveTo().

int KoZoomHandler::layoutUnitToPixelX int  lupix  )  const
 

The "layout unit pixel" -> "[zoomed] view pixel" conversions.

Definition at line 114 of file kozoomhandler.cc.

References KoTextZoomHandler::m_layoutUnitFactor.

Referenced by Container::boundingRect(), Container::coveredRect(), EmptyElement::draw(), SymbolElement::draw(), SpaceElement::draw(), RootElement::draw(), MultilineElement::draw(), FractionElement::draw(), UnderlineElement::draw(), OverlineElement::draw(), BracketElement::draw(), NameSequence::drawCursor(), SequenceElement::drawCursor(), Container::drawImage(), and Container::recalc().

int KoZoomHandler::layoutUnitToPixelX int  x,
int  w
const
 

This variant converts a width, using a reference X position.

This prevents rounding problems.

Definition at line 98 of file kozoomhandler.cc.

int KoZoomHandler::layoutUnitToPixelY int  y,
int  h
const
 

This variant converts a height, using a reference Y position.

This prevents rounding problems.

Definition at line 106 of file kozoomhandler.cc.

int KoZoomHandler::ptToPixelX double  pt  )  const [inline]
 

Basic pt to pixel and pixel to pt conversions, valid at any zoom level, as well as at the Layout Unit level (and mostly useful for Layout Units).

Don't confuse with zoomIt, which also converts pt to pixels, but applying the zoom!

Definition at line 218 of file kozoomhandler.h.

Referenced by SequenceElement::calcSizes().

int KoZoomHandler::ptToLayoutUnitPixX double  x_pt  )  const [inline]
 

The "document pt" -> "Layout Unit pixels" conversions, for convenience.

Definition at line 234 of file kozoomhandler.h.

References KoTextZoomHandler::ptToLayoutUnitPt().

Referenced by NameSequence::drawCursor(), and ContextStyle::getLineWidth().

double KoZoomHandler::layoutUnitToFontSize int  luSize,
bool 
const
 

Given the font size for the font in layout units, in pt (use pointSize()) this returns the font size to use on screen the current zoom, in pt (use setPointSizeFloat()),.

Definition at line 88 of file kozoomhandler.cc.


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for lib Library Version 1.4.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Mon Feb 13 09:41:52 2006 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003