]> git.lyx.org Git - lyx.git/blob - src/frontends/NoGuiFontMetrics.h
Fix memory leaks with multiple windows and crash when deleteOnClose is set.
[lyx.git] / src / frontends / NoGuiFontMetrics.h
1 // -*- C++ -*-
2 /**
3  * \file NoGuiFontMetrics.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Abdelrazak Younes
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef LYX_NO_GUI_FONT_METRICS_H
13 #define LYX_NO_GUI_FONT_METRICS_H
14
15 #include "frontends/FontMetrics.h"
16
17 #include "support/docstring.h"
18
19 namespace lyx {
20 namespace frontend {
21
22 class NoGuiFontMetrics : public FontMetrics
23 {
24 public:
25
26         NoGuiFontMetrics() {}
27
28         virtual ~NoGuiFontMetrics() {}
29
30         virtual int maxAscent() const { return 1; }
31
32         virtual int maxDescent() const { return 1; }
33         
34         virtual int width(char_type) const { return 1; }
35
36         virtual int ascent(char_type) const { return 1; }
37         
38         int descent(char_type) const { return 1; }
39         
40         virtual int lbearing(char_type) const { return 1; }
41         
42         virtual int rbearing(char_type) const { return 1; }
43         
44         virtual int width(char_type const *, size_t n) const { return n; }
45         
46         virtual int signedWidth(docstring const & s) const
47         {
48                 if (s.size() && s[0] == '-')
49                         return -FontMetrics::width(s.substr(1, s.length() - 1));
50                 return FontMetrics::width(s);
51         }
52         
53         virtual void rectText(docstring const &,
54                 int & /*width*/, int & /*ascent*/, int & /*descent*/) const {}
55         
56         virtual void buttonText(docstring const &,
57                 int & /*width*/, int & /*ascent*/, int & /*descent*/) const {}
58 };
59
60 } // namespace frontend
61 } // namespace lyx
62
63 #endif // LYX_NO_GUI_FONT_METRICS_H