File indexing completed on 2024-05-05 16:39:05
0001 /* This file is part of the KDE project 0002 Copyright (C) 2002 Carsten Pfeiffer <pfeiffer@kde.org> 0003 0004 This program is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU General Public 0006 License as published by the Free Software Foundation, version 2. 0007 0008 This program is distributed in the hope that it will be useful, 0009 but WITHOUT ANY WARRANTY; without even the implied warranty of 0010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0011 General Public License for more details. 0012 0013 You should have received a copy of the GNU General Public License 0014 along with this program; see the file COPYING. If not, write to 0015 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0016 Boston, MA 02110-1301, USA. 0017 */ 0018 0019 #ifndef PRINTING_H 0020 #define PRINTING_H 0021 0022 #include <QWidget> 0023 0024 class QFontMetrics; 0025 class QPrinter; 0026 class QString; 0027 class ImageWindow; 0028 class KuickPrintDialogPage; 0029 namespace Ui { class KuickPrintDialogPage; } 0030 0031 0032 class Printing 0033 { 0034 public: 0035 static bool printImage( ImageWindow& imageWin, QWidget *parent = 0L); 0036 static bool printImageWithQt( const QString& filename, QPrinter& printer, KuickPrintDialogPage& dialogPage, 0037 const QString& originalFileName ); 0038 0039 private: 0040 static void addConfigPages(); 0041 static QString minimizeString( QString text, const QFontMetrics& metrics, 0042 int maxWidth ); 0043 0044 }; 0045 0046 class KuickPrintDialogPage : public QWidget 0047 { 0048 Q_OBJECT 0049 0050 public: 0051 KuickPrintDialogPage( QWidget *parent = 0L ); 0052 ~KuickPrintDialogPage(); 0053 0054 bool printFilename(); 0055 void setPrintFilename( bool addFilename ); 0056 0057 bool printBlackWhite(); 0058 void setPrintBlackWhite( bool blackWhite ); 0059 0060 bool printShrinkToFit(); 0061 void setPrintShrinkToFit( bool shrinkToFit ); 0062 0063 bool printScale(); 0064 void setPrintScale( bool scale ); 0065 0066 QString printScaleUnit(); 0067 void setPrintScaleUnit( QString scaleUnit ); 0068 0069 int printScaleWidthPixels(); 0070 void setPrintScaleWidthPixels( int scaleWidth ); 0071 0072 int printScaleHeightPixels(); 0073 void setPrintScaleHeightPixels( int scaleHeight ); 0074 0075 private slots: 0076 void toggleScaling( bool enable ); 0077 0078 private: 0079 Ui::KuickPrintDialogPage* ui; 0080 0081 // return values in pixels! 0082 int scaleWidth() const; 0083 int scaleHeight() const; 0084 0085 void setScaleWidth( int pixels ); 0086 void setScaleHeight( int pixels ); 0087 0088 int fromUnitToPixels( float val ) const; 0089 float pixelsToUnit( int pixels ) const; 0090 0091 }; 0092 0093 #endif // PRINTING_H