1 /* This file is part of the KDE project 2 3 Copyright 2010 Johannes Simon <johannes.simon@gmail.com> 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Library General Public 7 License as published by the Free Software Foundation; either 8 version 2 of the License, or (at your option) any later version. 9 10 This library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Library General Public License for more details. 14 15 You should have received a copy of the GNU Library General Public License 16 along with this library; see the file COPYING.LIB. If not, write to 17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 Boston, MA 02110-1301, USA. 19 */ 20 21 #ifndef KCHART_SCREEN_CONVERSIONS_H 22 #define KCHART_SCREEN_CONVERSIONS_H 23 24 class QPainter; 25 class QPaintDevice; 26 class QPoint; 27 class QPointF; 28 class QSize; 29 class QSizeF; 30 class QRect; 31 class QRectF; 32 33 namespace KoChart { 34 35 class ScreenConversions 36 { 37 public: 38 // pt --> px 39 static qreal ptToPxX(qreal pt, const QPaintDevice* paintDevice); 40 static qreal ptToPxY(qreal pt, const QPaintDevice* paintDevice); 41 static qreal ptToPxX(qreal pt); 42 static qreal ptToPxY(qreal pt); 43 static void scaleFromPtToPx(QPainter &painter); 44 static QPoint scaleFromPtToPx(const QPointF &point, const QPaintDevice* paintDevice); 45 static QSize scaleFromPtToPx(const QSizeF &size, const QPaintDevice* paintDevice); 46 static QSize scaleFromPtToPx(const QSizeF &size, QPainter &painter); 47 static QSize scaleFromPtToPx(const QSizeF &size); 48 static QRect scaleFromPtToPx(const QRectF &rect, QPainter &painter); 49 50 // px --> pt 51 static qreal pxToPtX(qreal px); 52 static qreal pxToPtY(qreal px); 53 static QSizeF scaleFromPxToPt(const QSize &size); 54 55 // auxcilliary 56 static QSizeF toWidgetDpi(QWidget *widget, const QSizeF &size); 57 static QSizeF fromWidgetDpi(QWidget *widget, const QSizeF &size); 58 static void scaleToWidgetDpi(QWidget *widget, QPainter &painter); 59 }; 60 61 } // namespace KoChart 62 63 #endif // KCHART_SCREEN_CONVERSIONS_H 64