lib

KoPageLayoutColumns.cpp

00001 /* This file is part of the KDE project
00002  * Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
00003  * Copyright (C) 2005 Thomas Zander <zander@kde.org>
00004  *
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Library General Public
00007  * License as published by the Free Software Foundation; version 2.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Library General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Library General Public License
00015  * along with this library; see the file COPYING.LIB.  If not, write to
00016  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018  */
00019 
00020 #include <KoPageLayoutColumns.h>
00021 #include <KoPageLayoutDia.h>
00022 #include <KoUnit.h>
00023 #include <KoUnitWidgets.h>
00024 
00025 #include <qlabel.h>
00026 #include <qlayout.h>
00027 
00028 KoPageLayoutColumns::KoPageLayoutColumns(QWidget *parent, const KoColumns& columns, KoUnit::Unit unit, const KoPageLayout& layout)
00029     : KoPageLayoutColumnsBase(parent) {
00030     m_columns = columns;
00031     QHBoxLayout *lay = new QHBoxLayout(previewPane);
00032     m_preview = new KoPagePreview( previewPane, "Preview", layout );
00033     lay->addWidget(m_preview);
00034     lay = new QHBoxLayout(columnSpacingPane);
00035     m_spacing = new KoUnitDoubleSpinBox( columnSpacingPane );
00036     m_spacing->setValue(  m_columns.ptColumnSpacing );
00037     m_spacing->setUnit( unit );
00038     double dStep = KoUnit::fromUserValue( 0.2, unit );
00039     m_spacing->setMinMaxStep( 0, layout.ptWidth/2, dStep );
00040     lay->addWidget(m_spacing);
00041     labelSpacing->setBuddy( m_spacing );
00042     nColumns->setValue( m_columns.columns );
00043     m_preview->setPageColumns( m_columns );
00044 
00045     connect( nColumns, SIGNAL( valueChanged( int ) ), this, SLOT( nColChanged( int ) ) );
00046     connect( m_spacing, SIGNAL( valueChangedPt(double) ), this, SLOT( nSpaceChanged( double ) ) );
00047 }
00048 
00049 void KoPageLayoutColumns::setEnableColumns(bool on) {
00050     nColumns->setEnabled(on);
00051     m_spacing->setEnabled(on);
00052     nColChanged(on ? nColumns->value(): 1 );
00053 }
00054 
00055 void KoPageLayoutColumns::nColChanged( int columns ) {
00056     m_columns.columns = columns;
00057     m_preview->setPageColumns( m_columns );
00058     emit propertyChange(m_columns);
00059 }
00060 
00061 void KoPageLayoutColumns::nSpaceChanged( double spacing ) {
00062     m_columns.ptColumnSpacing = spacing;
00063     emit propertyChange(m_columns);
00064 }
00065 
00066 void KoPageLayoutColumns::setLayout(KoPageLayout &layout) {
00067     m_preview->setPageLayout( layout );
00068 }
00069 
00070 #include <KoPageLayoutColumns.moc>
KDE Home | KDE Accessibility Home | Description of Access Keys