kdeui Library API Documentation

ksyntaxhighlighter.h

00001 /*
00002  ksyntaxhighlighter.cpp
00003 
00004  Copyright (c) 2003 Trolltech AS
00005  Copyright (c) 2003 Scott Wheeler <wheeler@kde.org>
00006 
00007  This file is part of the KDE libraries
00008 
00009  This library is free software; you can redistribute it and/or
00010  modify it under the terms of the GNU Library General Public
00011  License version 2 as published by the Free Software Foundation.
00012 
00013  This library is distributed in the hope that it will be useful,
00014  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016  Library General Public License for more details.
00017 
00018  You should have received a copy of the GNU Library General Public License
00019  along with this library; see the file COPYING.LIB.  If not, write to
00020  the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00021  Boston, MA 02111-1307, USA.
00022 */
00023 
00024 #ifndef KSYNTAXHIGHLIGHTER_H
00025 #define KSYNTAXHIGHLIGHTER_H
00026 
00027 #include <qtextedit.h>
00028 #include <qsyntaxhighlighter.h>
00029 #include <qcolor.h>
00030 #include <qstringlist.h>
00031 
00032 class QAccel;
00033 class QTimer;
00034 class KSpell;
00035 class KSpellConfig;
00036 
00037 class KSyntaxHighlighter : public QSyntaxHighlighter
00038 {
00039 public:
00040     enum SyntaxMode {
00041     PlainTextMode,
00042     RichTextMode
00043     };
00044     KSyntaxHighlighter( QTextEdit *textEdit,
00045              bool colorQuoting = false,
00046              const QColor& QuoteColor0 = black,
00047              const QColor& QuoteColor1 = QColor( 0x00, 0x80, 0x00 ),
00048              const QColor& QuoteColor2 = QColor( 0x00, 0x80, 0x00 ),
00049              const QColor& QuoteColor3 = QColor( 0x00, 0x80, 0x00 ),
00050              SyntaxMode mode = PlainTextMode );
00051     ~KSyntaxHighlighter();
00052 
00053     int highlightParagraph( const QString& text, int endStateOfLastPara );
00054 
00055 private:
00056     class KSyntaxHighlighterPrivate;
00057     KSyntaxHighlighterPrivate *d;
00058 };
00059 
00060 class KSpellingHighlighter : public KSyntaxHighlighter
00061 {
00062 public:
00063     KSpellingHighlighter( QTextEdit *textEdit,
00064               const QColor& spellColor = red,
00065               bool colorQuoting = false,
00066               const QColor& QuoteColor0 = black,
00067               const QColor& QuoteColor1 = QColor( 0x00, 0x80, 0x00 ),
00068               const QColor& QuoteColor2 = QColor( 0x00, 0x80, 0x00 ),
00069               const QColor& QuoteColor3 = QColor( 0x00, 0x80, 0x00 ) );
00070     ~KSpellingHighlighter();
00071 
00072     virtual int highlightParagraph( const QString &text,
00073                     int endStateOfLastPara );
00074     virtual bool isMisspelled( const QString& word ) = 0;
00075     bool intraWordEditing() const;
00076     void setIntraWordEditing( bool editing );
00077     static QStringList personalWords();
00078 
00079 private:
00080     void flushCurrentWord();
00081 
00082     class KSpellingHighlighterPrivate;
00083     KSpellingHighlighterPrivate *d;
00084 };
00085 
00086 class KDictSpellingHighlighter : public QObject, public KSpellingHighlighter
00087 {
00088 Q_OBJECT
00089 
00090 public:
00091     KDictSpellingHighlighter( QTextEdit *textEdit,
00092                   bool spellCheckingActive = true,
00093                   bool autoEnable = true,
00094                   const QColor& spellColor = red,
00095                   bool colorQuoting = false,
00096                   const QColor& QuoteColor0 = black,
00097                   const QColor& QuoteColor1 = QColor( 0x00, 0x80, 0x00 ),
00098                   const QColor& QuoteColor2 = QColor( 0x00, 0x70, 0x00 ),
00099                   const QColor& QuoteColor3 = QColor( 0x00, 0x60, 0x00 ),
00100                               KSpellConfig *spellConfig = 0 );
00101     ~KDictSpellingHighlighter();
00102 
00103     virtual bool isMisspelled( const QString &word );
00104     static void dictionaryChanged();
00105     void restartBackgroundSpellCheck();
00106 
00119     void setActive( bool active );
00120 
00128     bool isActive() const;
00129 
00141     void setAutomatic( bool automatic );
00142 
00150     bool automatic() const;
00151 
00152 signals:
00153     void activeChanged(const QString &);
00154     void newSuggestions(const QString& originalword, const QStringList& suggestions,
00155                         unsigned int pos);
00156 
00157 protected:
00158     QString spellKey();
00159     bool eventFilter(QObject *o, QEvent *e);
00160 
00161 protected slots:
00162     void slotMisspelling( const QString &originalWord, const QStringList &suggestions, unsigned int pos );
00163     void slotCorrected( const QString &originalWord, const QString &, unsigned int );
00164     void slotRehighlight();
00165     void slotDictionaryChanged();
00166     void slotSpellReady( KSpell *spell );
00167     void slotAutoDetection();
00168     void slotLocalSpellConfigChanged();
00169     void slotKSpellNotResponding();
00170 
00171 private:
00172     class KDictSpellingHighlighterPrivate;
00173     KDictSpellingHighlighterPrivate *d;
00174 };
00175 
00176 #endif
KDE Logo
This file is part of the documentation for kdeui Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Feb 14 09:16:36 2006 by doxygen 1.3.6 written by Dimitri van Heesch, © 1997-2003