]> git.lyx.org Git - features.git/blob - src/frontends/NoGuiFontMetrics.h
This commit saves the need to check for lyx::use_gui in a number of places.
[features.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 ascent(lyx::char_type c) const { return 1; }
35         
36         int descent(lyx::char_type c) const { return 1; }
37         
38         virtual int lbearing(lyx::char_type c) const { return 1; }
39         
40         virtual int rbearing(lyx::char_type c) const { return 1; }
41         
42         virtual int width(lyx::char_type const * s, size_t n) const { return n; }
43         
44         virtual int signedWidth(lyx::docstring const & s) const
45         {
46                 if (s[0] == '-')
47                         return -FontMetrics::width(s.substr(1, s.length() - 1));
48                 else
49                         return FontMetrics::width(s);
50         }
51         
52         virtual void rectText(lyx::docstring const & str,
53                 int & width,
54                 int & ascent,
55                 int & descent) const {};         
56         
57         virtual void buttonText(lyx::docstring const & str,
58                 int & width,
59                 int & ascent,
60                 int & descent) const {};
61 };
62
63 } // namespace frontend
64 } // namespace lyx
65
66 #endif // LYX_NO_GUI_FONT_METRICS_H