- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

# qtextoption.h

Go to the documentation of this file.

    00001 /****************************************************************************
    00002 **
    00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    00004 ** All rights reserved.
    00005 ** Contact: Nokia Corporation (qt-info@nokia.com)
    00006 **
    00007 ** This file is part of the QtGui module of the Qt Toolkit.
    00008 **
    00009 ** $QT_BEGIN_LICENSE:LGPL$
    00010 ** Commercial Usage
    00011 ** Licensees holding valid Qt Commercial licenses may use this file in
    00012 ** accordance with the Qt Commercial License Agreement provided with the
    00013 ** Software or, alternatively, in accordance with the terms contained in
    00014 ** a written agreement between you and Nokia.
    00015 **
    00016 ** GNU Lesser General Public License Usage
    00017 ** Alternatively, this file may be used under the terms of the GNU Lesser
    00018 ** General Public License version 2.1 as published by the Free Software
    00019 ** Foundation and appearing in the file LICENSE.LGPL included in the
    00020 ** packaging of this file.  Please review the following information to
    00021 ** ensure the GNU Lesser General Public License version 2.1 requirements
    00022 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    00023 **
    00024 ** In addition, as a special exception, Nokia gives you certain additional
    00025 ** rights.  These rights are described in the Nokia Qt LGPL Exception
    00026 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this module.
    00027 **
    00028 ** GNU General Public License Usage
    00029 ** Alternatively, this file may be used under the terms of the GNU
    00030 ** General Public License version 3.0 as published by the Free Software
    00031 ** Foundation and appearing in the file LICENSE.GPL included in the
    00032 ** packaging of this file.  Please review the following information to
    00033 ** ensure the GNU General Public License version 3.0 requirements will be
    00034 ** met: http://www.gnu.org/copyleft/gpl.html.
    00035 **
    00036 ** If you have questions regarding the use of this file, please contact
    00037 ** Nokia at qt-info@nokia.com.
    00038 ** $QT_END_LICENSE$
    00039 **
    00040 ****************************************************************************/
    00041
    00042 #ifndef QTEXTOPTION_H
    00043 #define QTEXTOPTION_H
    00044
    00045 #include <QtCore/qnamespace.h>
    00046 #include <QtCore/qchar.h>
    00047 #include <QtCore/qmetatype.h>
    00048
    00049
    00050 QT_BEGIN_HEADER
    00051
    00052 QT_BEGIN_NAMESPACE
    00053
    00054 QT_MODULE(Gui)
    00055
    00056 template <typename T> class QList;
    00057 struct QTextOptionPrivate;
    00058
    00059 class Q_GUI_EXPORT QTextOption
    00060 {
    00061 public:
    00062     enum TabType {
    00063         LeftTab,
    00064         RightTab,
    00065         CenterTab,
    00066         DelimiterTab
    00067     };
    00068
    00069     struct Q_GUI_EXPORT Tab {
    00070         inline Tab() : position(80), type(QTextOption::LeftTab) { }
    00071         inline Tab(qreal pos, TabType tabType, QChar delim = QChar())
    00072             : position(pos), type(tabType), delimiter(delim) {}
    00073
    00074         inline bool operator==(const Tab &other) const {
    00075             return type == other.type
    00076                    && qFuzzyCompare(position, other.position)
    00077                    && delimiter == other.delimiter;
    00078         }
    00079
    00080         inline bool operator!=(const Tab &other) const {
    00081             return !operator==(other);
    00082         }
    00083
    00084         qreal position;
    00085         TabType type;
    00086         QChar delimiter;
    00087     };
    00088
    00089     QTextOption();
    00090     QTextOption(Qt::Alignment alignment);
    00091     ~QTextOption();
    00092
    00093     QTextOption(const QTextOption &o);
    00094     QTextOption &operator=(const QTextOption &o);
    00095
    00096     inline void setAlignment(Qt::Alignment alignment);
    00097     inline Qt::Alignment alignment() const { return Qt::Alignment(align); }
    00098
    00099     inline void setTextDirection(Qt::LayoutDirection aDirection) { this->direction = aDirection; }
    00100     inline Qt::LayoutDirection textDirection() const { return Qt::LayoutDirection(direction); }
    00101
    00102     enum WrapMode {
    00103         NoWrap,
    00104         WordWrap,
    00105         ManualWrap,
    00106         WrapAnywhere,
    00107         WrapAtWordBoundaryOrAnywhere
    00108     };
    00109     inline void setWrapMode(WrapMode wrap) { wordWrap = wrap; }
    00110     inline WrapMode wrapMode() const { return static_cast<WrapMode>(wordWrap); }
    00111
    00112     enum Flag {
    00113         ShowTabsAndSpaces = 0x1,
    00114         ShowLineAndParagraphSeparators = 0x2,
    00115         AddSpaceForLineAndParagraphSeparators = 0x4,
    00116         SuppressColors = 0x8,
    00117         IncludeTrailingSpaces = 0x80000000
    00118     };
    00119     Q_DECLARE_FLAGS(Flags, Flag)
    00120     inline void setFlags(Flags flags);
    00121     inline Flags flags() const { return Flags(f); }
    00122
    00123     inline void setTabStop(qreal tabStop);
    00124     inline qreal tabStop() const { return tab; }
    00125
    00126     void setTabArray(QList<qreal> tabStops);
    00127     QList<qreal> tabArray() const;
    00128
    00129     void setTabs(QList<Tab> tabStops);
    00130     QList<Tab> tabs() const;
    00131
    00132     void setUseDesignMetrics(bool b) { design = b; }
    00133     bool useDesignMetrics() const { return design; }
    00134
    00135 private:
    00136     uint align : 8;
    00137     uint wordWrap : 4;
    00138     uint design : 1;
    00139     uint direction : 2;
    00140     uint unused : 18;
    00141     uint f;
    00142     qreal tab;
    00143     QTextOptionPrivate *d;
    00144 };
    00145
    00146 Q_DECLARE_OPERATORS_FOR_FLAGS(QTextOption::Flags)
    00147
    00148 inline void QTextOption::setAlignment(Qt::Alignment aalignment)
    00149 { align = aalignment; }
    00150
    00151 inline void QTextOption::setFlags(Flags aflags)
    00152 { f = aflags; }
    00153
    00154 inline void QTextOption::setTabStop(qreal atabStop)
    00155 { tab = atabStop; }
    00156
    00157 QT_END_NAMESPACE
    00158
    00159 Q_DECLARE_METATYPE( QTextOption::Tab )
    00160
    00161 QT_END_HEADER
    00162
    00163 #endif // QTEXTOPTION_H