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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
|
/* This file is part of the KDE project
Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
Copyright 2002, 2003 David Faure <faure@kde.org>
Copyright 2003 Nicolas GOUTTE <goutte@kde.org>
Copyright 2007 Thomas Zander <zander@kde.org>
Copyright 2012 Friedrich W. H. Kossebau <kossebau@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; either
version 2 of the License, or (at your option) any later version.
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.
*/
#ifndef KOCOLUMNS_H
#define KOCOLUMNS_H
#include "koodf_export.h"
#include <QtGlobal>
#include <QColor>
#include <QVector>
class KoGenStyle;
class KoXmlElement;
/** structure for columns */
struct KoColumns {
enum SeparatorVerticalAlignment {
AlignTop = Qt::AlignTop,
AlignVCenter = Qt::AlignVCenter,
AlignBottom = Qt::AlignBottom
};
enum SeparatorStyle {
None = Qt::NoPen,
Solid = Qt::SolidLine,
Dashed = Qt::DashLine,
Dotted = Qt::DotLine,
DotDashed = Qt::DashDotLine
};
struct ColumnDatum
{
/** Left indent in points */
qreal leftMargin;
/** Right indent in points */
qreal rightMargin;
/** Top indent in points */
qreal topMargin;
/** Bottom indent in points */
qreal bottomMargin;
/** The relative width */
int relativeWidth;
ColumnDatum() {}
ColumnDatum(qreal lm, qreal rm, qreal tm, qreal bm, int rw)
: leftMargin(lm), rightMargin(rm), topMargin(tm), bottomMargin(bm), relativeWidth(rw) {}
bool operator==(const KoColumns::ColumnDatum &rhs) const
{
return
(leftMargin == rhs.leftMargin) &&
(rightMargin == rhs.rightMargin) &&
(topMargin == rhs.topMargin) &&
(bottomMargin == rhs.bottomMargin) &&
(relativeWidth == rhs.relativeWidth);
}
};
/** Number of columns */
int count;
/** Spacing between columns in points */
qreal gapWidth;
SeparatorStyle separatorStyle;
QColor separatorColor;
SeparatorVerticalAlignment separatorVerticalAlignment;
/** Width in pt */
qreal separatorWidth;
/** Height in percent. Default is 100% */
unsigned int separatorHeight;
/** data about the individual columns if there */
QVector<ColumnDatum> columnData;
/**
* Construct a columns with the default column count 1,
* default margins (2 cm), and portrait orientation.
*/
KOODF_EXPORT KoColumns();
KOODF_EXPORT void reset();
KOODF_EXPORT bool operator==(const KoColumns &l) const;
KOODF_EXPORT bool operator!=(const KoColumns &l) const;
/**
* Save this columns to ODF.
*/
KOODF_EXPORT void saveOdf(KoGenStyle &style) const;
/**
* Load this columns from ODF
*/
KOODF_EXPORT void loadOdf(const KoXmlElement &style);
qreal totalRelativeWidth() const
{
qreal result = 0.0;
foreach(const ColumnDatum &c, columnData) {
result += c.relativeWidth;
}
return result;
}
KOODF_EXPORT static const char * separatorStyleString(KoColumns::SeparatorStyle separatorStyle);
KOODF_EXPORT static const char * separatorVerticalAlignmentString(KoColumns::SeparatorVerticalAlignment separatorVerticalAlignment);
KOODF_EXPORT static KoColumns::SeparatorVerticalAlignment parseSeparatorVerticalAlignment(const QString &value);
KOODF_EXPORT static QColor parseSeparatorColor(const QString &value);
KOODF_EXPORT static int parseSeparatorHeight(const QString &value);
KOODF_EXPORT static KoColumns::SeparatorStyle parseSeparatorStyle(const QString &value);
KOODF_EXPORT static int parseRelativeWidth(const QString &value);
};
Q_DECLARE_TYPEINFO(KoColumns::ColumnDatum, Q_MOVABLE_TYPE);
#endif /* KOCOLUMNS_H */
|