Grantlee  0.3.0
texthtmlbuilder.h
1 /*
2  This file is part of the Grantlee template system.
3 
4  Copyright (c) 2008 Stephen Kelly <steveire@gmail.com>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Lesser General Public
8  License as published by the Free Software Foundation; either version
9  2.1 of the Licence, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public
17  License along with this library. If not, see <http://www.gnu.org/licenses/>.
18 
19 */
20 
21 #ifndef GRANTLEE_TEXTHTMLBUILDER_H
22 #define GRANTLEE_TEXTHTMLBUILDER_H
23 
24 #ifdef Q_CC_MSVC
25 #pragma warning( disable : 4250 )
26 #endif
27 
28 #include "abstractmarkupbuilder.h"
29 #include "grantlee_gui_export.h"
30 #include "markupdirector.h"
31 
32 
33 namespace Grantlee
34 {
35 
36 class TextHTMLBuilderPrivate;
37 
39 
90 class GRANTLEE_GUI_EXPORT TextHTMLBuilder : virtual public AbstractMarkupBuilder
91 {
92 public:
93 
98  virtual ~TextHTMLBuilder();
99 
100  /* reimp */ void beginStrong();
101  /* reimp */ void endStrong();
102  /* reimp */ void beginEmph();
103  /* reimp */ void endEmph();
104  /* reimp */ void beginUnderline();
105  /* reimp */ void endUnderline();
106  /* reimp */ void beginStrikeout();
107  /* reimp */ void endStrikeout();
108  /* reimp */ void beginForeground( const QBrush &brush );
109  /* reimp */ void endForeground();
110  /* reimp */ void beginBackground( const QBrush &brush );
111  /* reimp */ void endBackground();
112  /* reimp */ void beginAnchor( const QString &href = QString(), const QString &name = QString() );
113  /* reimp */ void endAnchor();
114 
115  // Maybe this stuff should just be added to a list, and then when I add literal text,
116  // add some kind of style attribute in one span instead of many.
117  /* reimp */ void beginFontFamily( const QString &family );
118  /* reimp */ void endFontFamily();
119 
124  /* reimp */ void beginFontPointSize( int size );
125  /* reimp */ void endFontPointSize();
126 
135  /* reimp */ void beginParagraph( Qt::Alignment al = Qt::AlignLeft, qreal topMargin = 0.0, qreal bottomMargin = 0.0, qreal leftMargin = 0.0, qreal rightMargin = 0.0 );
136 
141  /* reimp */ void beginHeader( int level );
142 
147  /* reimp */ void endHeader( int level );
148 
149  /* reimp */ void endParagraph();
150  /* reimp */ void addNewline();
151 
152  /* reimp */ void insertHorizontalRule( int width = -1 );
153 
154  /* reimp */ void insertImage( const QString &src, qreal width, qreal height );
155 
156  /* reimp */ void beginList( QTextListFormat::Style type );
157 
158  /* reimp */ void endList();
159 
160  /* reimp */ void beginListItem();
161  /* reimp */ void endListItem();
162 
163  /* reimp */ void beginSuperscript();
164 
165  /* reimp */ void endSuperscript();
166 
167  /* reimp */ void beginSubscript();
168 
169  /* reimp */ void endSubscript();
170 
171 
172  /* reimp */ void beginTable( qreal cellpadding, qreal cellspacing, const QString &width );
173 
174  /* reimp */ void beginTableRow();
175  /* reimp */ void beginTableHeaderCell( const QString &width, int colspan, int rowspan );
176 
177  /* reimp */ void beginTableCell( const QString &width, int colspan, int rowspan );
178 
179  /* reimp */ void endTable();
180  /* reimp */ void endTableRow();
181  /* reimp */ void endTableHeaderCell();
182  /* reimp */ void endTableCell();
183 
199  /* reimp */ void appendLiteralText( const QString &text );
200 
206  /* reimp */ void appendRawText( const QString &text );
207 
208  /* reimp */ QString getResult();
209 
210 private:
211  TextHTMLBuilderPrivate *d_ptr;
212  Q_DECLARE_PRIVATE( TextHTMLBuilder )
213 
214 };
215 
216 }
217 
218 #endif