Source-highlight Qt Library
srchiliteqt::Qt4TextFormatter Class Reference

The implementation of TextFormatter for Qt4, relying on QTextCharFormat. More...

#include <Qt4TextFormatter.h>

Inheritance diagram for srchiliteqt::Qt4TextFormatter:
Collaboration diagram for srchiliteqt::Qt4TextFormatter:

Public Member Functions

 Qt4TextFormatter (const std::string &elem_="normal")
 
const QTextCharFormat & getQTextCharFormat () const
 
virtual void setQSyntaxHighlighter (QSyntaxHighlighter *qSyntaxHighlighter_)
 
void format (const std::string &s, const srchilite::FormatterParams *params)
 Formats the passed string. More...
 
const QString toString () const
 
const QString toSourceHighlightStyleString () const
 Starting from this formatter, it builds a string representation using the syntax of source-highlight style file. More...
 
bool isBold () const
 
void setBold (bool b)
 
bool isItalic () const
 
void setItalic (bool i)
 
bool isUnderline () const
 
void setUnderline (bool u)
 
bool isMonospace () const
 
void setMonospace (bool m)
 
const QColor & getForegroundColor () const
 
void setForegroundColor (const QColor &color)
 
const QColor & getBackgroundColor () const
 
void setBackgroundColor (const QColor &color)
 
const std::string & getElem () const
 
void setElem (const std::string &e)
 

Protected Attributes

QTextCharFormat textFormat
 The format represented by this formatter.
 
QColor foregroundColor
 the (possibly invalid) foreground color. More...
 
QColor backgroundColor
 the (possibly invalid) background color
 
Qt4SyntaxHighlighterqSyntaxHighlighter
 The reference to QSyntaxHighlighter object. More...
 
std::string elem
 the language element represented by this formatter
 

Detailed Description

The implementation of TextFormatter for Qt4, relying on QTextCharFormat.

Member Function Documentation

void srchiliteqt::Qt4TextFormatter::format ( const std::string &  s,
const srchilite::FormatterParams *  params 
)

Formats the passed string.

Parameters
thestring to format
paramspossible additional parameters for the formatter (NOT USED)
const QColor& srchiliteqt::Qt4TextFormatter::getBackgroundColor ( ) const
inline
Returns
the (possibly invalid, if not set) background color
const std::string& srchiliteqt::TextFormatter::getElem ( ) const
inlineinherited
Returns
the language element represented by this formatter
const QColor& srchiliteqt::Qt4TextFormatter::getForegroundColor ( ) const
inline
Returns
the (possibly invalid, if not set) foreground color
const QString srchiliteqt::Qt4TextFormatter::toSourceHighlightStyleString ( ) const

Starting from this formatter, it builds a string representation using the syntax of source-highlight style file.

Returns
a string representation using the syntax of source-highlight style file
const QString srchiliteqt::Qt4TextFormatter::toString ( ) const
Returns
a string representation of this formatter

Member Data Documentation

QColor srchiliteqt::Qt4TextFormatter::foregroundColor
protected

the (possibly invalid) foreground color.

We need to keep a copy to be sure whether the color is valid or not, since QTextCharFormat has always a default (valid) color

Qt4SyntaxHighlighter* srchiliteqt::Qt4TextFormatter::qSyntaxHighlighter
protected

The reference to QSyntaxHighlighter object.

Since this header file does not include the header file for QSyntaxHighlighter, then this same class can be re-used both for Qt3 and for Qt4 (the subclasses of this class will include the correct header file for QSyntaxHighlighter).


The documentation for this class was generated from the following files: