lib

KoPageLayoutHeader.cpp

00001 /* This file is part of the KDE project
00002  * Copyright (C) 2005 Thomas Zander <zander@kde.org>
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Library General Public
00006  * License as published by the Free Software Foundation; version 2.
00007  *
00008  * This library is distributed in the hope that it will be useful,
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011  * Library General Public License for more details.
00012  *
00013  * You should have received a copy of the GNU Library General Public License
00014  * along with this library; see the file COPYING.LIB.  If not, write to
00015  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00016  * Boston, MA 02110-1301, USA.
00017  */
00018 
00019 #include <KoPageLayoutHeader.h>
00020 #include <KoPageLayoutHeader.moc>
00021 #include <KoUnitWidgets.h>
00022 
00023 #include <qlayout.h>
00024 #include <qcheckbox.h>
00025 
00026 KoPageLayoutHeader::KoPageLayoutHeader(QWidget *parent, KoUnit::Unit unit, const KoKWHeaderFooter &kwhf)
00027     : KoPageLayoutHeaderBase(parent) {
00028     m_headerFooters = kwhf;
00029     QHBoxLayout *lay = new QHBoxLayout(headerSpacingPane);
00030     m_headerSpacing = new KoUnitDoubleSpinBox( headerSpacingPane, 0.0, 999.0, 0.5, kwhf.ptHeaderBodySpacing, unit );
00031     lay->addWidget(m_headerSpacing);
00032 
00033     lay = new QHBoxLayout(footerSpacingPane);
00034     m_footerSpacing = new KoUnitDoubleSpinBox( footerSpacingPane, 0.0, 999.0, 0.5, kwhf.ptFooterBodySpacing, unit );
00035     lay->addWidget(m_footerSpacing);
00036 
00037     lay = new QHBoxLayout(footnotePane);
00038     m_footnoteSpacing = new KoUnitDoubleSpinBox( footnotePane, 0.0, 999.0, 0.5, kwhf.ptFootNoteBodySpacing, unit );
00039     lay->addWidget(m_footnoteSpacing);
00040 
00041     if ( kwhf.header == HF_FIRST_DIFF || kwhf.header == HF_FIRST_EO_DIFF )
00042         rhFirst->setChecked( true );
00043     if ( kwhf.header == HF_EO_DIFF || kwhf.header == HF_FIRST_EO_DIFF )
00044         rhEvenOdd->setChecked( true );
00045     if ( kwhf.footer == HF_FIRST_DIFF || kwhf.footer == HF_FIRST_EO_DIFF )
00046         rfFirst->setChecked( true );
00047     if ( kwhf.footer == HF_EO_DIFF || kwhf.footer == HF_FIRST_EO_DIFF )
00048         rfEvenOdd->setChecked( true );
00049 }
00050 
00051 const KoKWHeaderFooter& KoPageLayoutHeader::headerFooter() {
00052     if ( rhFirst->isChecked() && rhEvenOdd->isChecked() )
00053         m_headerFooters.header = HF_FIRST_EO_DIFF;
00054     else if ( rhFirst->isChecked() )
00055         m_headerFooters.header = HF_FIRST_DIFF;
00056     else if ( rhEvenOdd->isChecked() )
00057         m_headerFooters.header = HF_EO_DIFF;
00058     else
00059         m_headerFooters.header = HF_SAME;
00060 
00061     m_headerFooters.ptHeaderBodySpacing = m_headerSpacing->value();
00062     m_headerFooters.ptFooterBodySpacing = m_footerSpacing->value();
00063     m_headerFooters.ptFootNoteBodySpacing = m_footnoteSpacing->value();
00064     if ( rfFirst->isChecked() && rfEvenOdd->isChecked() )
00065         m_headerFooters.footer = HF_FIRST_EO_DIFF;
00066     else if ( rfFirst->isChecked() )
00067         m_headerFooters.footer = HF_FIRST_DIFF;
00068     else if ( rfEvenOdd->isChecked() )
00069         m_headerFooters.footer = HF_EO_DIFF;
00070     else
00071         m_headerFooters.footer = HF_SAME;
00072     return m_headerFooters;
00073 }
KDE Home | KDE Accessibility Home | Description of Access Keys