lib
KoTextZoomHandler.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "KoTextZoomHandler.h"
00021 #include <kdebug.h>
00022 #include <qpaintdevice.h>
00023 #include <KoUnit.h>
00024 #include <KoGlobal.h>
00025
00026
00027
00028
00029 int KoTextZoomHandler::m_layoutUnitFactor = 20;
00030
00031 #if 0
00032 int KoTextZoomHandler::fontSizeToLayoutUnit( double ptSizeFloat, bool forPrint ) const
00033 {
00034 return ptToLayoutUnit( ptSizeFloat / ( m_zoomedResolutionY *
00035 ( forPrint ? 1.0 : (72.0 / KoGlobal::dpiY()) ) ) );
00036 }
00037 #endif
00038
00039 double KoTextZoomHandler::layoutUnitToFontSize( int luSize, bool ) const
00040 {
00041
00042 return layoutUnitPtToPt( luSize ) * m_zoomedResolutionY
00043 #ifdef Q_WS_X11
00044 / POINT_TO_INCH(QPaintDevice::x11AppDpiY())
00045 #endif
00046 ;
00047 }
00048
00049 int KoTextZoomHandler::layoutUnitToPixelX( int x, int w ) const
00050 {
00051
00052
00053
00054 return layoutUnitToPixelY( x + w - 1 ) - layoutUnitToPixelY( x ) + 1;
00055 }
00056
00057 int KoTextZoomHandler::layoutUnitToPixelY( int y, int h ) const
00058 {
00059
00060
00061
00062 return layoutUnitToPixelY( y + h - 1 ) - layoutUnitToPixelY( y ) + 1;
00063 }
00064
00065 int KoTextZoomHandler::layoutUnitToPixelX( int lupix ) const
00066 {
00067 return int( static_cast<double>( lupix * m_zoomedResolutionX )
00068 / ( static_cast<double>( m_layoutUnitFactor ) * m_resolutionX ) );
00069 }
00070
00071 int KoTextZoomHandler::layoutUnitToPixelY( int lupix ) const
00072 {
00073
00074 return int( static_cast<double>( lupix * m_zoomedResolutionY )
00075 / ( static_cast<double>( m_layoutUnitFactor ) * m_resolutionY ) );
00076 }
00077
00078 int KoTextZoomHandler::pixelToLayoutUnitX( int x ) const
00079 {
00080 return qRound( static_cast<double>( x * m_layoutUnitFactor * m_resolutionX )
00081 / m_zoomedResolutionX );
00082 }
00083
00084 int KoTextZoomHandler::pixelToLayoutUnitY( int y ) const
00085 {
00086 return qRound( static_cast<double>( y * m_layoutUnitFactor * m_resolutionY )
00087 / m_zoomedResolutionY );
00088 }
00089
|