KoPageLayoutColumns.cpp
1/* This file is part of the KDE project
2 * Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
3 * Copyright (C) 2005 Thomas Zander <zander@kde.org>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; version 2.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20#include <KoPageLayoutColumns.h>
21#include <KoPageLayoutDia.h>
22#include <KoUnit.h>
23#include <KoUnitWidgets.h>
24
25#include <tqlabel.h>
26#include <tqlayout.h>
27
28KoPageLayoutColumns::KoPageLayoutColumns(TQWidget *parent, const KoColumns& columns, KoUnit::Unit unit, const KoPageLayout& layout)
29 : KoPageLayoutColumnsBase(parent) {
30 m_columns = columns;
31 TQHBoxLayout *lay = new TQHBoxLayout(previewPane);
32 m_preview = new KoPagePreview( previewPane, "Preview", layout );
33 lay->addWidget(m_preview);
34 lay = new TQHBoxLayout(columnSpacingPane);
35 m_spacing = new KoUnitDoubleSpinBox( columnSpacingPane );
36 m_spacing->setValue( m_columns.ptColumnSpacing );
37 m_spacing->setUnit( unit );
38 double dStep = KoUnit::fromUserValue( 0.2, unit );
39 m_spacing->setMinMaxStep( 0, layout.ptWidth/2, dStep );
40 lay->addWidget(m_spacing);
41 labelSpacing->setBuddy( m_spacing );
42 nColumns->setValue( m_columns.columns );
43 m_preview->setPageColumns( m_columns );
44
45 connect( nColumns, TQ_SIGNAL( valueChanged( int ) ), this, TQ_SLOT( nColChanged( int ) ) );
46 connect( m_spacing, TQ_SIGNAL( valueChangedPt(double) ), this, TQ_SLOT( nSpaceChanged( double ) ) );
47}
48
50 nColumns->setEnabled(on);
51 m_spacing->setEnabled(on);
52 nColChanged(on ? nColumns->value(): 1 );
53}
54
55void KoPageLayoutColumns::nColChanged( int columns ) {
56 m_columns.columns = columns;
57 m_preview->setPageColumns( m_columns );
58 emit propertyChange(m_columns);
59}
60
61void KoPageLayoutColumns::nSpaceChanged( double spacing ) {
62 m_columns.ptColumnSpacing = spacing;
63 emit propertyChange(m_columns);
64}
65
67 m_preview->setPageLayout( layout );
68}
69
70#include <KoPageLayoutColumns.moc>
virtual void setValue(double value)
KoPageLayoutColumns(TQWidget *parent, const KoColumns &columns, KoUnit::Unit unit, const KoPageLayout &layout)
Contructor.
void setEnableColumns(bool on)
Enable the user to edit the columns.
void setLayout(KoPageLayout &layout)
Update the page preview widget with the param layout.
KoPagePreview.
void setPageLayout(const KoPageLayout &)
set page layout
Spin box for double precision numbers with unit display.
void setMinMaxStep(double min, double max, double step)
Set minimum, maximum value and the step size (all in points) (by Tymoteusz Majewski,...
static double fromUserValue(double value, Unit unit)
This method is the one to use to read a value from a dialog.
Definition KoUnit.cpp:120
Unit
Length units supported by KOffice.
Definition KoUnit.h:63
structure for columns
This structure defines the page layout, including its size in pt, its format (e.g.
double ptWidth
Page width in pt.