Source-highlight Qt Library
|
00001 /* 00002 * Copyright (C) 2008-2010 Lorenzo Bettini, http://www.lorenzobettini.it 00003 * License: See COPYING file that comes with this distribution 00004 */ 00005 00006 #ifndef TEXTFORMATTERFACTORY_H_ 00007 #define TEXTFORMATTERFACTORY_H_ 00008 00009 #include <map> 00010 00011 #include "srchilite/formatterfactory.h" 00012 00013 #include "TextFormatter.h" 00014 #include "QtColorMap.h" 00015 00016 namespace srchiliteqt { 00017 00018 using std::string; 00019 00020 typedef std::map<string, TextFormatterPtr> TextFormatterMap; 00021 00026 class TextFormatterFactory: public srchilite::FormatterFactory { 00027 protected: 00028 TextFormatterMap textFormatterMap; 00029 00031 bool defaultToMonospace; 00032 00033 public: 00035 static QtColorMap colorMap; 00036 00037 TextFormatterFactory(); 00038 virtual ~TextFormatterFactory(); 00039 00046 bool hasFormatter(const string &key) const; 00047 00053 TextFormatterPtr getFormatter(const string &key) const; 00054 00060 void addFormatter(const string &key, TextFormatterPtr formatter); 00061 00065 const TextFormatterMap &getTextFormatterMap() const { 00066 return textFormatterMap; 00067 } 00068 00069 bool isDefaultToMonospace() const { 00070 return defaultToMonospace; 00071 } 00072 00079 void setDefaultToMonospace(bool d) { 00080 defaultToMonospace = d; 00081 } 00082 }; 00083 00084 } 00085 00086 #endif /* TEXTFORMATTERFACTORY_H_ */