File indexing completed on 2024-05-19 15:27:51
0001 /* This file is part of KGraphViewer. 0002 Copyright (C) 2005-2007 Gael de Chalendar <kleag@free.fr> 0003 0004 KGraphViewer 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; if not, write to the Free Software 0015 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 0016 02110-1301, USA 0017 */ 0018 0019 /* This file was part of the KDE project 0020 Copyright (C) 2005 Jarosław Staniek <staniek@kde.org> 0021 0022 This program is free software; you can redistribute it and/or 0023 modify it under the terms of the GNU Library General Public 0024 License as published by the Free Software Foundation; either 0025 version 2 of the License, or (at your option) any later version. 0026 */ 0027 0028 #ifndef kgvpagelayoutsize_h 0029 #define kgvpagelayoutsize_h 0030 0031 #include <QButtonGroup> 0032 #include <QGroupBox> 0033 // #include <KgvGlobal.h> 0034 #include <KgvPageLayout.h> 0035 #include <KgvPageLayoutDia.h> 0036 #include <KgvUnit.h> 0037 #include <QComboBox> 0038 #include <QDialog> 0039 0040 class KComboBox; 0041 class KgvUnitDoubleSpinBox; 0042 0043 /** 0044 * This class is a widget that shows the KgvPageLayout data structure and allows the user to change it. 0045 */ 0046 class KgvPageLayoutSize : public QWidget 0047 { 0048 Q_OBJECT 0049 0050 public: 0051 /** 0052 * Constructor 0053 * @param parent the parent widget 0054 * @param layout the page layout that this widget should be initialized with. 0055 * @param unit the unit-type (mm/cm/inch) that the dialog should show 0056 * @param columns the KgvColumns (amout of columns) that the preview should be initialized with 0057 * @param unitChooser if true a combobox with the unit-type is shown for the user to change 0058 * @param enableBorders if true enable the user to change the margins (aka borders) of the page 0059 */ 0060 KgvPageLayoutSize(QWidget *parent, const KgvPageLayout &layout, KgvUnit::Unit unit, const KgvColumns &columns, bool unitChooser, bool enableBorders); 0061 0062 /** 0063 * @return if the dialog is in a sane state and the values can be used. 0064 */ 0065 bool queryClose(); 0066 /** 0067 * Update the page preview widget with the param columns. 0068 * @param columns the new columns 0069 */ 0070 void setColumns(KgvColumns &columns); 0071 0072 public Q_SLOTS: 0073 /** 0074 * Set a new unit for the widget updating the widgets. 0075 * @param unit the new unit 0076 */ 0077 void setUnit(KgvUnit::Unit unit); 0078 /** 0079 * Enable the user to edit the page border size 0080 * @param on if true enable the user to change the margins (aka borders) of the page 0081 */ 0082 void setEnableBorders(bool on); 0083 0084 Q_SIGNALS: 0085 /** 0086 * Emitted whenever the user changed something in the dialog. 0087 * @param layout the update layout structure with currently displayed info. 0088 * Note that the info may not be fully correct and physically possible (in which 0089 * case queryClose will return false) 0090 */ 0091 void propertyChange(KgvPageLayout &layout); 0092 0093 protected: 0094 QComboBox *cpgFormat; 0095 KgvUnitDoubleSpinBox *epgWidth; 0096 KgvUnitDoubleSpinBox *epgHeight; 0097 KgvUnitDoubleSpinBox *ebrLeft; 0098 KgvUnitDoubleSpinBox *ebrRight; 0099 KgvUnitDoubleSpinBox *ebrTop; 0100 KgvUnitDoubleSpinBox *ebrBottom; 0101 KgvPagePreview *pgPreview; 0102 QGroupBox *m_orientGroup; 0103 QButtonGroup m_orientButtons; 0104 0105 protected Q_SLOTS: 0106 void formatChanged(int); 0107 void widthChanged(double); 0108 void heightChanged(double); 0109 void leftChanged(double); 0110 void rightChanged(double); 0111 void topChanged(double); 0112 void bottomChanged(double); 0113 void orientationChanged(int); 0114 void setUnitInt(int unit); 0115 0116 private: 0117 void updatePreview(); 0118 void setValues(); 0119 0120 KgvUnit::Unit m_unit; 0121 KgvPageLayout m_layout; 0122 0123 bool m_blockSignals, m_haveBorders; 0124 }; 0125 0126 #endif