00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef kotextzoomhandler_h
00021 #define kotextzoomhandler_h
00022
00023 #include <KoZoomHandler.h>
00024
00028 class KOTEXT_EXPORT KoTextZoomHandler : public KoZoomHandler
00029 {
00030 public:
00031 KoTextZoomHandler() {}
00032 virtual ~KoTextZoomHandler() {}
00033
00035
00037 int pixelToLayoutUnitX( int x ) const;
00038 int pixelToLayoutUnitY( int y ) const;
00039 QPoint pixelToLayoutUnit( const QPoint &p ) const
00040 { return QPoint( pixelToLayoutUnitX( p.x() ),
00041 pixelToLayoutUnitY( p.y() ) ); }
00042 QRect pixelToLayoutUnit( const QRect &r ) const
00043 { return QRect( pixelToLayoutUnit( r.topLeft() ),
00044 pixelToLayoutUnit( r.bottomRight() ) ); }
00045
00047 int layoutUnitToPixelX( int lupix ) const;
00048 int layoutUnitToPixelY( int lupix ) const;
00049
00052 int layoutUnitToPixelX( int x, int w ) const;
00055 int layoutUnitToPixelY( int y, int h ) const;
00056
00057 QPoint layoutUnitToPixel( const QPoint &p ) const
00058 { return QPoint( layoutUnitToPixelX( p.x() ),
00059 layoutUnitToPixelY( p.y() ) ); }
00060 QRect layoutUnitToPixel( const QRect &r ) const
00061 { return QRect( layoutUnitToPixel( r.topLeft() ),
00062 layoutUnitToPixel( r.bottomRight() ) ); }
00063
00067 int ptToPixelX( double pt ) const
00068 { return qRound( pt * m_resolutionX ); }
00069 int ptToPixelY( double pt ) const
00070 { return qRound( pt * m_resolutionY ); }
00071 QPoint ptToPixel( const KoPoint & p ) const {
00072 return QPoint( ptToPixelX( p.x() ), ptToPixelY( p.y() ) );
00073 }
00074 double pixelXToPt( int x ) const
00075 { return static_cast<double>(x) / m_resolutionX; }
00076 double pixelYToPt( int y ) const
00077 { return static_cast<double>(y) / m_resolutionY; }
00078 KoPoint pixelToPt( const QPoint& p ) const {
00079 return KoPoint( pixelXToPt( p.x() ), pixelYToPt( p.y() ) );
00080 }
00081
00083 int ptToLayoutUnitPixX( double x_pt ) const
00084 { return ptToPixelX( ptToLayoutUnitPt( x_pt ) ); }
00085 int ptToLayoutUnitPixY( double y_pt ) const
00086 { return ptToPixelY( ptToLayoutUnitPt( y_pt ) ); }
00087 QPoint ptToLayoutUnitPix( const KoPoint & p ) const {
00088 return QPoint( ptToLayoutUnitPixX( p.x() ), ptToLayoutUnitPixY( p.y() ) );
00089 }
00090
00095 double layoutUnitToFontSize( int luSize, bool ) const;
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00108 static void setPtToLayoutUnitFactor( int factor ) { m_layoutUnitFactor = factor; }
00109
00112 static double ptToLayoutUnitPt( double pt )
00113 { return pt * static_cast<double>( m_layoutUnitFactor ); }
00115 static int ptToLayoutUnitPt( int ptSize )
00116 { return ptSize * m_layoutUnitFactor; }
00117
00118 static KoPoint ptToLayoutUnitPt( const KoPoint &p )
00119 { return KoPoint( ptToLayoutUnitPt( p.x() ),
00120 ptToLayoutUnitPt( p.y() ) ); }
00121 static KoRect ptToLayoutUnitPt( const KoRect &r )
00122 { return KoRect( ptToLayoutUnitPt( r.topLeft() ),
00123 ptToLayoutUnitPt( r.bottomRight() ) ); }
00124
00125 static double layoutUnitPtToPt( double lupt )
00126 { return lupt / static_cast<double>( m_layoutUnitFactor ); }
00127 static KoPoint layoutUnitPtToPt( const KoPoint& p )
00128 { return KoPoint( layoutUnitPtToPt( p.x() ),
00129 layoutUnitPtToPt( p.y() ) ); }
00130
00131 protected:
00133 static int m_layoutUnitFactor;
00134 };
00135
00136 #endif