• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kdeui

ksyntaxhighlighter.h

Go to the documentation of this file.
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., 51 Franklin Street, Fifth Floor,
00021  Boston, MA 02110-1301, 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 #include <kdelibs_export.h>
00033 
00034 class QAccel;
00035 class QTimer;
00036 class KSpell;
00037 class KSpellConfig;
00038 
00042 class KDEUI_EXPORT KSyntaxHighlighter : public QSyntaxHighlighter
00043 {
00044 public:
00045     enum SyntaxMode {
00046     PlainTextMode,
00047     RichTextMode
00048     };
00049     KSyntaxHighlighter( QTextEdit *textEdit,
00050              bool colorQuoting = false,
00051              const QColor& QuoteColor0 = black,
00052              const QColor& QuoteColor1 = QColor( 0x00, 0x80, 0x00 ),
00053              const QColor& QuoteColor2 = QColor( 0x00, 0x80, 0x00 ),
00054              const QColor& QuoteColor3 = QColor( 0x00, 0x80, 0x00 ),
00055              SyntaxMode mode = PlainTextMode );
00056     ~KSyntaxHighlighter();
00057 
00058     int highlightParagraph( const QString& text, int endStateOfLastPara );
00059 
00060 private:
00061     class KSyntaxHighlighterPrivate;
00062     KSyntaxHighlighterPrivate *d;
00063 };
00064 
00065 class KDEUI_EXPORT KSpellingHighlighter : public KSyntaxHighlighter
00066 {
00067 public:
00068     KSpellingHighlighter( QTextEdit *textEdit,
00069               const QColor& spellColor = red,
00070               bool colorQuoting = false,
00071               const QColor& QuoteColor0 = black,
00072               const QColor& QuoteColor1 = QColor( 0x00, 0x80, 0x00 ),
00073               const QColor& QuoteColor2 = QColor( 0x00, 0x80, 0x00 ),
00074               const QColor& QuoteColor3 = QColor( 0x00, 0x80, 0x00 ) );
00075     ~KSpellingHighlighter();
00076 
00077     virtual int highlightParagraph( const QString &text,
00078                     int endStateOfLastPara );
00079     virtual bool isMisspelled( const QString& word ) = 0;
00080     bool intraWordEditing() const;
00081     void setIntraWordEditing( bool editing );
00082     static QStringList personalWords();
00083 
00084 private:
00085     void flushCurrentWord();
00086 
00087     class KSpellingHighlighterPrivate;
00088     KSpellingHighlighterPrivate *d;
00089 };
00090 
00094 class KDEUI_EXPORT KDictSpellingHighlighter : public QObject, public KSpellingHighlighter
00095 {
00096 Q_OBJECT
00097 
00098 public:
00099     KDictSpellingHighlighter( QTextEdit *textEdit,
00100                   bool spellCheckingActive = true,
00101                   bool autoEnable = true,
00102                   const QColor& spellColor = red,
00103                   bool colorQuoting = false,
00104                   const QColor& QuoteColor0 = black,
00105                   const QColor& QuoteColor1 = QColor( 0x00, 0x80, 0x00 ),
00106                   const QColor& QuoteColor2 = QColor( 0x00, 0x70, 0x00 ),
00107                   const QColor& QuoteColor3 = QColor( 0x00, 0x60, 0x00 ),
00108                               KSpellConfig *spellConfig = 0 );
00109     ~KDictSpellingHighlighter();
00110 
00111     virtual bool isMisspelled( const QString &word );
00112     static void dictionaryChanged();
00113     void restartBackgroundSpellCheck();
00114 
00127     void setActive( bool active );
00128 
00136     bool isActive() const;
00137 
00149     void setAutomatic( bool automatic );
00150 
00158     bool automatic() const;
00159 
00160 signals:
00161     void activeChanged(const QString &);
00162     void newSuggestions(const QString& originalword, const QStringList& suggestions,
00163                         unsigned int pos);
00164 
00165 protected:
00166     QString spellKey();
00167     bool eventFilter(QObject *o, QEvent *e);
00168 
00169 protected slots:
00170     void slotMisspelling( const QString &originalWord, const QStringList &suggestions, unsigned int pos );
00171     void slotCorrected( const QString &originalWord, const QString &, unsigned int );
00172     void slotRehighlight();
00173     void slotDictionaryChanged();
00174     void slotSpellReady( KSpell *spell );
00175     void slotAutoDetection();
00176     void slotLocalSpellConfigChanged();
00177     void slotKSpellNotResponding();
00178 
00179 private:
00180     class KDictSpellingHighlighterPrivate;
00181     KDictSpellingHighlighterPrivate *d;
00182 };
00183 
00184 #endif

kdeui

Skip menu "kdeui"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • dcop
  • DNSSD
  • interfaces
  • Kate
  • kconf_update
  • KDECore
  • KDED
  • kdefx
  • KDEsu
  • kdeui
  • KDocTools
  • KHTML
  • KImgIO
  • KInit
  • kio
  • kioslave
  • KJS
  • KNewStuff
  • KParts
  • KUtils
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal