00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef QTEXTDOCUMENTADAPTER_H
00010 #define QTEXTDOCUMENTADAPTER_H
00011
00012 #include "JavaQxQSwing.h"
00013
00014
00015
00016
00017
00018 class QTextDocumentAdapter;
00019
00026 class JAVAQX_EXPORT TextDocumentHighlighter : public QSyntaxHighlighter
00027 {
00028 Q_OBJECT
00029 public:
00030 TextDocumentHighlighter();
00031 public:
00032 void setDocument(QTextDocumentAdapter *document);
00033 void setFormat(int start, int length, const QTextCharFormat &format);
00034 protected slots:
00035 void contentsChangeSlot(int position, int charsRemoved, int charsAdded);
00036 protected:
00037 virtual void highlightBlock(const QString &text);
00038 private:
00039 QTextDocumentAdapter *m_document;
00040 int m_blockPosition;
00041 bool m_contentsChanged;
00042 };
00043
00044
00045
00046
00047
00048 class TextDocumentBridge;
00049
00056 class QTextDocumentAdapter : public QTextDocument
00057 {
00058 Q_OBJECT
00059 protected:
00060 QTextDocumentAdapter(TextDocumentBridge *bridge);
00061 virtual ~QTextDocumentAdapter();
00062 public:
00063 int length();
00064 void clear();
00065 void setDestroying();
00066 void setUseHighlighter(bool useHighlighter);
00067 void setFormat(int start, int length, const QTextCharFormat &format);
00068 void highlightBlock(int blockStart, const QString &blockText);
00069 public:
00070 virtual QString getText() const = 0;
00071 virtual void setText(const QString &text) = 0;
00072 virtual void appendText(const QString &text) = 0;
00073 signals:
00074 void destroying();
00075 void textCleared();
00076 void textSet();
00077 void textAppended();
00078 void selectAllAvailable(bool available);
00079 protected slots:
00080 void contentsChangeSlot(int position, int charsRemoved, int charsAdded);
00081 protected:
00082 int m_length;
00083 bool m_destroying;
00084 TextDocumentBridge *m_bridge;
00085 TextDocumentHighlighter *m_highlighter;
00086 };
00087
00088 #endif // QTEXTDOCUMENTADAPTER_H
00089
00090
00091
00092
00093
00094
00095
00096