summaryrefslogtreecommitdiffstats
path: root/lib/kofficeui/KoPageLayoutColumns.cpp
blob: 60057c88e6a835e83f6e5d96ffef67536880f205 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/* This file is part of the KDE project
 * Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
 * Copyright (C) 2005 Thomas Zander <zander@kde.org>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; version 2.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this library; see the file COPYING.LIB.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

#include <KoPageLayoutColumns.h>
#include <KoPageLayoutDia.h>
#include <KoUnit.h>
#include <KoUnitWidgets.h>

#include <tqlabel.h>
#include <tqlayout.h>

KoPageLayoutColumns::KoPageLayoutColumns(TQWidget *tqparent, const KoColumns& columns, KoUnit::Unit unit, const KoPageLayout& tqlayout)
    : KoPageLayoutColumnsBase(tqparent) {
    m_columns = columns;
    TQHBoxLayout *lay = new TQHBoxLayout(previewPane);
    m_preview = new KoPagePreview( previewPane, "Preview", tqlayout );
    lay->addWidget(m_preview);
    lay = new TQHBoxLayout(columnSpacingPane);
    m_spacing = new KoUnitDoubleSpinBox( columnSpacingPane );
    m_spacing->setValue(  m_columns.ptColumnSpacing );
    m_spacing->setUnit( unit );
    double dStep = KoUnit::fromUserValue( 0.2, unit );
    m_spacing->setMinMaxStep( 0, tqlayout.ptWidth/2, dStep );
    lay->addWidget(m_spacing);
    labelSpacing->setBuddy( m_spacing );
    nColumns->setValue( m_columns.columns );
    m_preview->setPageColumns( m_columns );

    connect( nColumns, TQT_SIGNAL( valueChanged( int ) ), this, TQT_SLOT( nColChanged( int ) ) );
    connect( m_spacing, TQT_SIGNAL( valueChangedPt(double) ), this, TQT_SLOT( nSpaceChanged( double ) ) );
}

void KoPageLayoutColumns::setEnableColumns(bool on) {
    nColumns->setEnabled(on);
    m_spacing->setEnabled(on);
    nColChanged(on ? nColumns->value(): 1 );
}

void KoPageLayoutColumns::nColChanged( int columns ) {
    m_columns.columns = columns;
    m_preview->setPageColumns( m_columns );
    emit propertyChange(m_columns);
}

void KoPageLayoutColumns::nSpaceChanged( double spacing ) {
    m_columns.ptColumnSpacing = spacing;
    emit propertyChange(m_columns);
}

void KoPageLayoutColumns::setLayout(KoPageLayout &tqlayout) {
    m_preview->setPageLayout( tqlayout );
}

#include <KoPageLayoutColumns.moc>