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 // Description: Page Layout Dialog (header)
0029 
0030 #ifndef KGVPAGELAYOUTDIA_H
0031 #define KGVPAGELAYOUTDIA_H
0032 
0033 #include <KgvPageLayout.h>
0034 #include <KgvUnit.h>
0035 #include <QGroupBox>
0036 #include <QLineEdit>
0037 #include <kpagedialog.h>
0038 
0039 class KLineEdit;
0040 class QPaintEvent;
0041 
0042 class KgvPageLayoutColumns;
0043 class KgvPageLayoutSize;
0044 class KgvPageLayoutHeader;
0045 
0046 enum { FORMAT_AND_BORDERS = 1, HEADER_AND_FOOTER = 2, COLUMNS = 4, DISABLE_BORDERS = 8, KW_HEADER_AND_FOOTER = 16, DISABLE_UNIT = 32 };
0047 
0048 /**
0049  *  KgvPagePreview.
0050  *  Internal to KgvPageLayoutDia.
0051  */
0052 class KgvPagePreview : public QGroupBox
0053 {
0054     Q_OBJECT
0055 
0056 public:
0057     /**
0058      *  constructor
0059      */
0060     KgvPagePreview(QWidget *, const char *, const KgvPageLayout &);
0061     /**
0062      *  destructor
0063      */
0064     ~KgvPagePreview();
0065 
0066     /**
0067      *  set page layout
0068      */
0069     void setPageLayout(const KgvPageLayout &);
0070     void setPageColumns(const KgvColumns &);
0071 
0072 protected:
0073     // paint page
0074     void paintEvent(QPaintEvent *event) override;
0075 
0076     double m_pageHeight, m_pageWidth, m_textFrameX, m_textFrameY, m_textFrameWidth, m_textFrameHeight;
0077     int columns;
0078 };
0079 
0080 class KgvPageLayoutDiaPrivate;
0081 
0082 /**
0083  *  With this dialog the user can specify the layout of the paper during printing.
0084  */
0085 class KgvPageLayoutDia : public KPageDialog
0086 {
0087     Q_OBJECT
0088 
0089 public:
0090     /**
0091      *  Constructor.
0092      *
0093      *  @param parent   The parent of the dialog.
0094      *  @param name     The name of the dialog.
0095      *  @param layout   The layout.
0096      *  @param headfoot The header and the footer.
0097      *  @param flags     a variable with all features this dialog should show.
0098      *  @param unit     The unit to use for displaying the values to the user.
0099      *  @param modal    Whether the dialog is modal or not.
0100      */
0101     KgvPageLayoutDia(QWidget *parent, KgvPageLayout &layout, int flags, KgvUnit::Unit unit);
0102 
0103     /**
0104      *  Constructor.
0105      *
0106      *  @param parent     The parent of the dialog.
0107      *  @param name       The name of the dialog.
0108      *  @param layout     The layout.
0109      *  @param headfoot   The header and the footer.
0110      *  @param columns    The number of columns on the page.
0111      *  @param kwheadfoot The KWord header and footer.
0112      *  @param tabs       The number of tabs.
0113      *  @param unit       The unit to use for displaying the values to the user
0114      */
0115     KgvPageLayoutDia(QWidget *parent, KgvPageLayout &layout, const KgvColumns &columns, int tabs, KgvUnit::Unit unit);
0116 
0117     /**
0118      *  Destructor.
0119      */
0120     ~KgvPageLayoutDia();
0121 
0122     /**
0123      *  Show page layout dialog.
0124      *  See constructor for documentation on the parameters
0125      */
0126     static bool pageLayout(KgvPageLayout &, KgvHeadFoot &, int tabs, KgvUnit::Unit &unit, QWidget *parent = nullptr);
0127 
0128     /**
0129      *  Show page layout dialog.
0130      *  See constructor for documentation on the parameters
0131      */
0132     static bool pageLayout(KgvPageLayout &, KgvHeadFoot &, KgvColumns &, KgvKWHeaderFooter &, int tabs, KgvUnit::Unit &unit, QWidget *parent = nullptr);
0133 
0134     /**
0135      *  Returns the layout
0136      */
0137     const KgvPageLayout &layout() const
0138     {
0139         return m_layout;
0140     }
0141 
0142     /**
0143      *  Returns the header and footer information
0144      */
0145     struct ::KgvHeadFoot headFoot() const;
0146 
0147     /**
0148      *  Returns the unit
0149      */
0150     KgvUnit::Unit unit() const
0151     {
0152         return m_unit;
0153     }
0154 
0155 private:
0156     const KgvColumns &columns()
0157     {
0158         return m_column;
0159     }
0160     const KgvKWHeaderFooter &headerFooter();
0161 
0162     // setup tabs
0163     void setupTab1(bool enableBorders);
0164     //     void setupTab2( const KgvHeadFoot& hf );
0165     //     void setupTab3();
0166     //     void setupTab4( const KgvKWHeaderFooter kwhf );
0167 
0168     // dialog objects
0169     QLineEdit *eHeadLeft;
0170     QLineEdit *eHeadMid;
0171     QLineEdit *eHeadRight;
0172     QLineEdit *eFootLeft;
0173     QLineEdit *eFootMid;
0174     QLineEdit *eFootRight;
0175 
0176     // layout
0177     struct ::KgvPageLayout &m_layout;
0178     KgvColumns m_column;
0179 
0180     KgvUnit::Unit m_unit;
0181 
0182     int flags;
0183 
0184 protected Q_SLOTS:
0185     void slotOk();
0186 
0187 private Q_SLOTS:
0188     void sizeUpdated(struct ::KgvPageLayout &layout);
0189     //     void columnsUpdated(KgvColumns &columns);
0190 
0191 private:
0192     KgvPageLayoutSize *m_pageSizeTab;
0193     KgvPageLayoutColumns *m_columnsTab;
0194     KgvPageLayoutHeader *m_headerTab;
0195     KgvPageLayoutDiaPrivate *d;
0196 };
0197 
0198 #endif // KGVPAGELAYOUTDIA_H