Source-highlight Qt Library
TextFormatterFactory.h
1 /*
2  * Copyright (C) 2008-2010 Lorenzo Bettini, http://www.lorenzobettini.it
3  * License: See COPYING file that comes with this distribution
4  */
5 
6 #ifndef TEXTFORMATTERFACTORY_H_
7 #define TEXTFORMATTERFACTORY_H_
8 
9 #include <map>
10 
11 #include "srchilite/formatterfactory.h"
12 
13 #include "TextFormatter.h"
14 #include "QtColorMap.h"
15 
16 namespace srchiliteqt {
17 
18 using std::string;
19 
20 typedef std::map<string, TextFormatterPtr> TextFormatterMap;
21 
26 class TextFormatterFactory: public srchilite::FormatterFactory {
27 protected:
28  TextFormatterMap textFormatterMap;
29 
32 
33 public:
36 
38  virtual ~TextFormatterFactory();
39 
46  bool hasFormatter(const string &key) const;
47 
53  TextFormatterPtr getFormatter(const string &key) const;
54 
60  void addFormatter(const string &key, TextFormatterPtr formatter);
61 
65  const TextFormatterMap &getTextFormatterMap() const {
66  return textFormatterMap;
67  }
68 
69  bool isDefaultToMonospace() const {
70  return defaultToMonospace;
71  }
72 
79  void setDefaultToMonospace(bool d) {
80  defaultToMonospace = d;
81  }
82 };
83 
84 }
85 
86 #endif /* TEXTFORMATTERFACTORY_H_ */
void addFormatter(const string &key, TextFormatterPtr formatter)
Adds the formatter for the given key.
Definition: TextFormatterFactory.cpp:32
Definition: ColorDialog.cpp:12
void setDefaultToMonospace(bool d)
Whether the created formatters should use monospace font by default if nothing is specified about the...
Definition: TextFormatterFactory.h:79
static QtColorMap colorMap
the color map for source-highlight colors into RGB #RRGGBB values
Definition: TextFormatterFactory.h:35
bool hasFormatter(const string &key) const
Checks whether a formatter for the given key is already present.
Definition: TextFormatterFactory.cpp:19
TextFormatterPtr getFormatter(const string &key) const
Returns the formatter for the given key.
Definition: TextFormatterFactory.cpp:23
Specialization of FormatterFactory to create TextFormatter objects to format text in a TextEdit...
Definition: TextFormatterFactory.h:26
Map for source-highlight colors into qt colors (actually, into the format #RRGGBB) ...
Definition: QtColorMap.h:18
const TextFormatterMap & getTextFormatterMap() const
Definition: TextFormatterFactory.h:65
bool defaultToMonospace
whether to default font to monospace (default true)
Definition: TextFormatterFactory.h:31