File indexing completed on 2024-05-12 16:15:44
0001 /* This file is part of the KDE project 0002 Copyright (C) 2005 Johannes Schaub <litb_devel@web.de> 0003 Copyright (C) 2011 Arjen Hiemstra <ahiemstra@heimr.nl> 0004 0005 This library is free software; you can redistribute it and/or 0006 modify it under the terms of the GNU Library General Public 0007 License as published by the Free Software Foundation; either 0008 version 2 of the License, or (at your option) any later version. 0009 0010 This library is distributed in the hope that it will be useful, 0011 but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0013 Library General Public License for more details. 0014 0015 You should have received a copy of the GNU Library General Public License 0016 along with this library; see the file COPYING.LIB. If not, write to 0017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0018 * Boston, MA 02110-1301, USA. 0019 */ 0020 0021 #ifndef _KREPORTZOOMMODE_H_ 0022 #define _KREPORTZOOMMODE_H_ 0023 0024 #include <QCoreApplication> 0025 0026 #include "kreport_export.h" 0027 0028 /** 0029 * The ZoomMode container 0030 */ 0031 class KReportZoomMode 0032 { 0033 Q_DECLARE_TR_FUNCTIONS(KReportZoomMode) 0034 public: 0035 enum class Type 0036 { 0037 Constant, ///< zoom x % 0038 Width, ///< zoom pagewidth 0039 Page, ///< zoom to pagesize 0040 Pixels, ///< zoom to actual pixels 0041 Text ///< zoom to text 0042 }; 0043 0044 /// \param type name 0045 /// \return type converted 0046 static Type toType(const QString &string); 0047 0048 /// \return QString converted and translated for type 0049 static QString toString(Type type); 0050 0051 /// \param type name 0052 /// \return true if \c mode isn't dependent on windowsize 0053 static bool isConstant(const QString& mode) 0054 { return toType(mode) == Type::Constant; } 0055 0056 /** 0057 * Return the minimum zoom possible for documents. 0058 * 0059 * \return The minimum zoom possible. 0060 */ 0061 static qreal minimumZoom(); 0062 /** 0063 * Return the maximum zoom possible for documents. 0064 * 0065 * \return The maximum zoom possible. 0066 */ 0067 static qreal maximumZoom(); 0068 /** 0069 * Clamp the zoom value so that mimimumZoom <= zoom <= maximumZoom. 0070 * 0071 * \param zoom The value to clamp. 0072 * 0073 * \return minimumZoom if zoom < minimumZoom, maximumZoom if zoom > 0074 * maximumZoom, zoom if otherwise. 0075 */ 0076 static qreal clampZoom(qreal zoom); 0077 0078 /** 0079 * Set the minimum zoom possible for documents. 0080 * 0081 * Note that after calling this, any existing KoZoomAction instances 0082 * should be recreated. 0083 * 0084 * \param zoom The minimum zoom to use. 0085 */ 0086 static void setMinimumZoom(qreal zoom); 0087 /** 0088 * Set the maximum zoom possible for documents. 0089 * 0090 * Note that after calling this, any existing KoZoomAction instances 0091 * should be recreated. 0092 * 0093 * \param zoom The maximum zoom to use. 0094 */ 0095 static void setMaximumZoom(qreal zoom); 0096 }; 0097 0098 #endif