F:/KPlato/koffice/libs/kotext/styles/KoCharacterStyle.h

Aller à la documentation de ce fichier.
00001 /* This file is part of the KDE project
00002  * Copyright (C) 2006 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 #ifndef KOCHARACTERSTYLE_H
00019 #define KOCHARACTERSTYLE_H
00020 
00021 #include <QObject>
00022 #include <QVector>
00023 #include <QVariant>
00024 #include <QString>
00025 #include <QTextCharFormat>
00026 #include <koffice_export.h>
00027 
00028 class StylePrivate;
00029 class QTextBlock;
00030 
00042 class KOTEXT_EXPORT KoCharacterStyle : public QObject {
00043     Q_OBJECT
00044 public:
00045     enum Property {
00046         StyleId = QTextFormat::UserProperty+1
00047     };
00048 
00049     KoCharacterStyle(QObject *parent = 0);
00050     ~KoCharacterStyle();
00051 /*
00052     void setFont (const QFont &font) { setProperty(QTextFormat::FOO, font); }
00053     QFont font () const {
00054         return static_cast<QFont> (propertyObject(QTextFormat::FOO));
00055     }
00056 */
00058     void setFontFamily (const QString &family) { setProperty(QTextFormat::FontFamily, family); }
00060     QString fontFamily () const { return propertyString(QTextFormat::FontFamily); }
00062     void setFontPointSize (qreal size) { setProperty(QTextFormat::FontPointSize, size); }
00064     double fontPointSize () const { return propertyDouble(QTextFormat::FontPointSize); }
00066     void setFontWeight (int weight) { setProperty(QTextFormat::FontWeight, weight); }
00068     int fontWeight () const { return propertyInt(QTextFormat::FontWeight); }
00070     void setFontItalic (bool italic) { setProperty(QTextFormat::FontItalic, italic); }
00072     bool fontItalic () const { return propertyBoolean(QTextFormat::FontItalic); }
00074     void setFontOverline (bool overline) { setProperty(QTextFormat::FontOverline, overline); }
00076     bool fontOverline () const { return propertyBoolean(QTextFormat::FontOverline); }
00078     void setFontStrikeOut (bool strikeOut) { setProperty(QTextFormat::FontStrikeOut, strikeOut); }
00080     bool fontStrikeOut () const { return propertyBoolean(QTextFormat::FontStrikeOut); }
00082     void setUnderlineColor (const QColor &color) { setProperty(QTextFormat::TextUnderlineColor, color); }
00084     QColor underlineColor () const;
00086     void setFontFixedPitch (bool fixedPitch) { setProperty(QTextFormat::FontFixedPitch, fixedPitch); }
00088     bool fontFixedPitch () const { return propertyBoolean(QTextFormat::FontFixedPitch); }
00090     void setUnderlineStyle (QTextCharFormat::UnderlineStyle style) {
00091         setProperty(QTextFormat::TextUnderlineStyle, style);
00092     }
00094     QTextCharFormat::UnderlineStyle underlineStyle () const {
00095         return static_cast<QTextCharFormat::UnderlineStyle> (propertyInt(QTextFormat::TextUnderlineStyle));
00096     }
00098     void setVerticalAlignment (QTextCharFormat::VerticalAlignment alignment) {
00099         setProperty(QTextFormat::TextVerticalAlignment, alignment);
00100     }
00102     QTextCharFormat::VerticalAlignment verticalAlignment () const {
00103         return static_cast<QTextCharFormat::VerticalAlignment> (propertyInt(QTextFormat::TextVerticalAlignment));
00104     }
00106     void setTextOutline (const QPen &pen) { setProperty(QTextFormat::TextOutline, pen); }
00108     QPen textOutline () const;
00109 
00111     void setBackground (const QBrush &brush) { setProperty(QTextFormat::BackgroundBrush, brush); }
00113     QBrush background () const;
00115     void clearBackground ();
00116 
00118     void setForeground (const QBrush &brush) { setProperty(QTextFormat::ForegroundBrush, brush); }
00120     QBrush foreground () const;
00122     void clearForeground ();
00123 
00124 
00126     const QString& name() const { return m_name; }
00127 
00129     void setName(const QString &name) { m_name = name; }
00130 
00132     int styleId() const { return propertyInt(StyleId); }
00133 
00135     void setStyleId(int id) { setProperty(StyleId, id); }
00136 
00141     void applyStyle(QTextCharFormat &format) const;
00146     void applyStyle(QTextBlock &block) const;
00150     void applyStyle(QTextCursor *selection) const;
00151 
00152 private:
00153     void setProperty(int key, const QVariant &value);
00154     const QVariant *get(int key) const;
00155     double propertyDouble(int key) const;
00156     int propertyInt(int key) const;
00157     QString propertyString(int key) const;
00158     bool propertyBoolean(int key) const;
00159 
00160 private:
00161     QString m_name;
00162     StylePrivate *m_stylesPrivate;
00163 };
00164 
00165 #endif

Généré le Wed Nov 22 23:41:11 2006 pour KPlato par  doxygen 1.5.1-p1