00001
00007 #ifndef HSYNTAXHIGHLIGHTERSETTINGS_H_
00008 #define HSYNTAXHIGHLIGHTERSETTINGS_H_
00009 #include <QtCore/QString>
00010 #include <QtCore/QVector>
00011 #include <QtGui/QTextCharFormat>
00012 #include <QtCore/QCoreApplication>
00013
00014 #include "HighlightBlock.h"
00020 enum slHighlightType {
00021 Keyword,
00022 TextConstant,
00023 NumberConstant,
00024 PreprocessorDirective,
00025 SingleLineCommment
00026 };
00032 enum mlHighlightType {
00033 MultiLinesComment
00034 };
00039 struct slFormatingRule
00040 {
00041 QRegExp exp;
00042 QTextCharFormat format;
00043 };
00049 struct mlFormatingRule
00050 {
00051 QRegExp beginingExp;
00052 QRegExp endingExp;
00053 QTextCharFormat format;
00054 };
00055
00064 class HSyntaxHighlighterSettings
00065 {
00071 friend class HSyntaxHighlighterDialog;
00072 private:
00073 QVector<SingleLineHighlightBlock> singleLine;
00074 QVector<MultiLinesHighlightBlock> multiLines;
00075
00084 void setupHighlightBlocks();
00089 bool modified;
00090
00091 public:
00096 bool changed() const
00097 {
00098 return modified;
00099 }
00100
00105 void cached()
00106 {
00107 modified=false;
00108 }
00115 void saveConfig(QString fileName=QCoreApplication::applicationDirPath()+"/default.ini") const;
00116
00123 void loadConfig(QString fileName=QCoreApplication::applicationDirPath()+"/default.ini");
00124
00129 HSyntaxHighlighterSettings();
00134 ~HSyntaxHighlighterSettings(){};
00140 QVector<slFormatingRule> getSingleLineRules() const;
00141
00147 QVector<mlFormatingRule> getMultiLinesRules() const;
00148
00154 void setFont(slHighlightType _type,const QFont& _font)
00155 {
00156 singleLine[_type].setFont(_font);
00157 }
00158
00164 void setFont(mlHighlightType _type,const QFont& _font)
00165 {
00166 multiLines[_type].setFont(_font);
00167 }
00168
00174 void setForegroundColor(slHighlightType _type,const QColor& _color)
00175 {
00176 singleLine[_type].setForegroundColor(_color);
00177 }
00178
00184 void setForegroundColor(mlHighlightType _type,const QColor& _color)
00185 {
00186 multiLines[_type].setForegroundColor(_color);
00187 }
00188
00194 void setBackgroundColor(slHighlightType _type,const QColor& _color)
00195 {
00196 singleLine[_type].setBackgroundColor(_color);
00197 }
00198
00204 void setBackgroundColor(mlHighlightType _type,const QColor& _color)
00205 {
00206 multiLines[_type].setBackgroundColor(_color);
00207 }
00208 };
00209
00210 #endif