~ubuntu-branches/ubuntu/saucy/goldencheetah/saucy

« back to all changes in this revision

Viewing changes to qwt/src/qwt_text.h

  • Committer: Package Import Robot
  • Author(s): KURASHIKI Satoru
  • Date: 2013-08-18 07:02:45 UTC
  • mfrom: (4.1.8 sid)
  • Revision ID: package-import@ubuntu.com-20130818070245-zgdvb47e1k3mtgil
Tags: 3.0-3
debian/control: remove needless dependency. (Closes: #719571)

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 * modify it under the terms of the Qwt License, Version 1.0
8
8
 *****************************************************************************/
9
9
 
10
 
// vim: expandtab
11
 
 
12
10
#ifndef QWT_TEXT_H
13
11
#define QWT_TEXT_H
14
12
 
 
13
#include "qwt_global.h"
15
14
#include <qstring.h>
16
15
#include <qsize.h>
17
16
#include <qfont.h>
18
 
#include "qwt_global.h"
19
17
 
20
18
class QColor;
21
19
class QPen;
22
20
class QBrush;
23
 
class QRect;
 
21
class QRectF;
24
22
class QPainter;
25
23
class QwtTextEngine;
26
24
 
58
56
      The text format defines the QwtTextEngine, that is used to render
59
57
      the text.
60
58
 
61
 
      - AutoText\n
62
 
        The text format is determined using QwtTextEngine::mightRender for
63
 
        all available text engines in increasing order > PlainText.
64
 
        If none of the text engines can render the text is rendered
65
 
        like PlainText.
66
 
      - PlainText\n
67
 
        Draw the text as it is, using a QwtPlainTextEngine.
68
 
      - RichText\n
69
 
        Use the Scribe framework (Qt Rich Text) to render the text.
70
 
      - MathMLText\n
71
 
        Use a MathML (http://en.wikipedia.org/wiki/MathML) render engine
72
 
        to display the text. The Qwt MathML extension offers such an engine
73
 
        based on the MathML renderer of the Qt solutions package. Unfortunately
74
 
        it is only available for owners of a commercial Qt license.
75
 
      - TeXText\n
76
 
        Use a TeX (http://en.wikipedia.org/wiki/TeX) render engine
77
 
        to display the text. 
78
 
      - OtherFormat\n
79
 
        The number of text formats can be extended using setTextEngine.
80
 
        Formats >= OtherFormat are not used by Qwt.
81
 
 
82
59
      \sa QwtTextEngine, setTextEngine()
83
60
    */
84
61
 
85
62
    enum TextFormat
86
63
    {
 
64
        /*!
 
65
          The text format is determined using QwtTextEngine::mightRender for
 
66
          all available text engines in increasing order > PlainText.
 
67
          If none of the text engines can render the text is rendered
 
68
          like QwtText::PlainText.
 
69
         */
87
70
        AutoText = 0,
88
 
        
 
71
 
 
72
        //! Draw the text as it is, using a QwtPlainTextEngine.
89
73
        PlainText,
 
74
 
 
75
        //! Use the Scribe framework (Qt Rich Text) to render the text.
90
76
        RichText,
91
77
 
 
78
        /*!
 
79
          Use a MathML (http://en.wikipedia.org/wiki/MathML) render engine
 
80
          to display the text. The Qwt MathML extension offers such an engine
 
81
          based on the MathML renderer of the Qt solutions package.
 
82
          To enable MathML support the following code needs to be added to the
 
83
          application:
 
84
\verbatim QwtText::setTextEngine(QwtText::MathMLText, new QwtMathMLTextEngine()); \endverbatim
 
85
         */
92
86
        MathMLText,
 
87
 
 
88
        /*!
 
89
          Use a TeX (http://en.wikipedia.org/wiki/TeX) render engine
 
90
          to display the text ( not implemented yet ).
 
91
         */
93
92
        TeXText,
94
93
 
 
94
        /*!
 
95
          The number of text formats can be extended using setTextEngine.
 
96
          Formats >= QwtText::OtherFormat are not used by Qwt.
 
97
         */
95
98
        OtherFormat = 100
96
99
    };
97
100
 
98
101
    /*!
99
102
      \brief Paint Attributes
100
103
 
101
 
      Font and color and background are optional attributes of a QwtText. 
 
104
      Font and color and background are optional attributes of a QwtText.
102
105
      The paint attributes hold the information, if they are set.
103
 
 
104
 
      - PaintUsingTextFont\n
105
 
        The text has an individual font.
106
 
      - PaintUsingTextColor\n
107
 
        The text has an individual color.
108
 
      - PaintBackground\n
109
 
        The text has an individual background.
110
106
    */
111
107
    enum PaintAttribute
112
108
    {
113
 
        PaintUsingTextFont = 1,
114
 
        PaintUsingTextColor = 2,
115
 
        PaintBackground = 4
 
109
        //! The text has an individual font.
 
110
        PaintUsingTextFont = 0x01,
 
111
 
 
112
        //! The text has an individual color.
 
113
        PaintUsingTextColor = 0x02,
 
114
 
 
115
        //! The text has an individual background.
 
116
        PaintBackground = 0x04
116
117
    };
117
118
 
 
119
    //! Paint attributes
 
120
    typedef QFlags<PaintAttribute> PaintAttributes;
 
121
 
118
122
    /*!
119
123
      \brief Layout Attributes
120
 
 
121
124
      The layout attributes affects some aspects of the layout of the text.
122
 
 
123
 
      - MinimumLayout\n
124
 
        Layout the text without its margins. This mode is useful if a
125
 
        text needs to be aligned accurately, like the tick labels of a scale.
126
 
        If QwtTextEngine::textMargins is not implemented for the format
127
 
        of the text, MinimumLayout has no effect.
128
125
    */
129
126
    enum LayoutAttribute
130
127
    {
131
 
        MinimumLayout = 1
 
128
        /*!
 
129
          Layout the text without its margins. This mode is useful if a
 
130
          text needs to be aligned accurately, like the tick labels of a scale.
 
131
          If QwtTextEngine::textMargins is not implemented for the format
 
132
          of the text, MinimumLayout has no effect.
 
133
         */
 
134
        MinimumLayout = 0x01
132
135
    };
133
136
 
134
 
    QwtText(const QString & = QString::null, 
135
 
        TextFormat textFormat = AutoText);
136
 
    QwtText(const QwtText &);
 
137
    //! Layout attributes
 
138
    typedef QFlags<LayoutAttribute> LayoutAttributes;
 
139
 
 
140
    QwtText( const QString & = QString::null,
 
141
             TextFormat textFormat = AutoText );
 
142
    QwtText( const QwtText & );
137
143
    ~QwtText();
138
144
 
139
 
    QwtText &operator=(const QwtText &);
140
 
 
141
 
    int operator==(const QwtText &) const;
142
 
    int operator!=(const QwtText &) const;
143
 
 
144
 
    void setText(const QString &, 
145
 
        QwtText::TextFormat textFormat = AutoText);
 
145
    QwtText &operator=( const QwtText & );
 
146
 
 
147
    bool operator==( const QwtText & ) const;
 
148
    bool operator!=( const QwtText & ) const;
 
149
 
 
150
    void setText( const QString &,
 
151
        QwtText::TextFormat textFormat = AutoText );
146
152
    QString text() const;
147
153
 
148
154
    bool isNull() const;
149
155
    bool isEmpty() const;
150
156
 
151
 
    void setFont(const QFont &);
 
157
    void setFont( const QFont & );
152
158
    QFont font() const;
153
159
 
154
 
    QFont usedFont(const QFont &) const;
 
160
    QFont usedFont( const QFont & ) const;
155
161
 
156
 
    void setRenderFlags(int flags);
 
162
    void setRenderFlags( int flags );
157
163
    int renderFlags() const;
158
164
 
159
 
    void setColor(const QColor &);
 
165
    void setColor( const QColor & );
160
166
    QColor color() const;
161
167
 
162
 
    QColor usedColor(const QColor &) const;
 
168
    QColor usedColor( const QColor & ) const;
163
169
 
164
 
    void setBackgroundPen(const QPen &);
 
170
    void setBackgroundPen( const QPen & );
165
171
    QPen backgroundPen() const;
166
172
 
167
 
    void setBackgroundBrush(const QBrush &);
 
173
    void setBackgroundBrush( const QBrush & );
168
174
    QBrush backgroundBrush() const;
169
175
 
170
 
    void setPaintAttribute(PaintAttribute, bool on = true);
171
 
    bool testPaintAttribute(PaintAttribute) const;
172
 
 
173
 
    void setLayoutAttribute(LayoutAttribute, bool on = true);
174
 
    bool testLayoutAttribute(LayoutAttribute) const;
175
 
 
176
 
    int heightForWidth(int width, const QFont & = QFont()) const;
177
 
    QSize textSize(const QFont & = QFont()) const;
178
 
 
179
 
    void draw(QPainter *painter, const QRect &rect) const;
180
 
 
181
 
    static const QwtTextEngine *textEngine(const QString &text,
182
 
        QwtText::TextFormat = AutoText);
183
 
 
184
 
    static const QwtTextEngine *textEngine(QwtText::TextFormat);
185
 
    static void setTextEngine(QwtText::TextFormat, QwtTextEngine *);
 
176
    void setPaintAttribute( PaintAttribute, bool on = true );
 
177
    bool testPaintAttribute( PaintAttribute ) const;
 
178
 
 
179
    void setLayoutAttribute( LayoutAttribute, bool on = true );
 
180
    bool testLayoutAttribute( LayoutAttribute ) const;
 
181
 
 
182
    double heightForWidth( double width, const QFont & = QFont() ) const;
 
183
    QSizeF textSize( const QFont & = QFont() ) const;
 
184
 
 
185
    void draw( QPainter *painter, const QRectF &rect ) const;
 
186
 
 
187
    static const QwtTextEngine *textEngine(
 
188
        const QString &text, QwtText::TextFormat = AutoText );
 
189
 
 
190
    static const QwtTextEngine *textEngine( QwtText::TextFormat );
 
191
    static void setTextEngine( QwtText::TextFormat, QwtTextEngine * );
186
192
 
187
193
private:
188
194
    class PrivateData;
193
199
};
194
200
 
195
201
//! \return text().isNull()
196
 
inline bool QwtText::isNull() const 
197
 
198
 
    return text().isNull(); 
 
202
inline bool QwtText::isNull() const
 
203
{
 
204
    return text().isNull();
199
205
}
200
206
 
201
207
//! \return text().isEmpty()
202
 
inline bool QwtText::isEmpty() const 
203
 
204
 
    return text().isEmpty(); 
 
208
inline bool QwtText::isEmpty() const
 
209
{
 
210
    return text().isEmpty();
205
211
}
206
212
 
 
213
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtText::PaintAttributes )
 
214
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtText::LayoutAttributes )
 
215
 
207
216
#endif