lyx_mirror/src/frontends/NoGuiFontMetrics.h
Abdelrazak Younes c7e365365e This commit saves the need to check for lyx::use_gui in a number of places.
* lyx_main.h: define "extern bool lyx::use_gui" here.

* NoGuiFontMetrics.h: new class for command-line LyX

* NoGuiFontLoader.h: new class for command-line LyX

* Application.C:
  - theFontMetrics(): returns the above dummy FontMetrics when use_gui is false.
  - theFontLoader(): returns the above dummy FontLoader when use_gui is false.



git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15339 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-15 21:47:29 +00:00

67 lines
1.4 KiB
C++

// -*- C++ -*-
/**
* \file NoGuiFontMetrics.h
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Abdelrazak Younes
*
* Full author contact details are available in file CREDITS.
*/
#ifndef LYX_NO_GUI_FONT_METRICS_H
#define LYX_NO_GUI_FONT_METRICS_H
#include "frontends/FontMetrics.h"
#include "support/docstring.h"
namespace lyx {
namespace frontend {
class NoGuiFontMetrics: public FontMetrics
{
public:
NoGuiFontMetrics() {}
virtual ~NoGuiFontMetrics() {}
virtual int maxAscent() const { return 1; }
virtual int maxDescent() const { return 1; }
virtual int ascent(lyx::char_type c) const { return 1; }
int descent(lyx::char_type c) const { return 1; }
virtual int lbearing(lyx::char_type c) const { return 1; }
virtual int rbearing(lyx::char_type c) const { return 1; }
virtual int width(lyx::char_type const * s, size_t n) const { return n; }
virtual int signedWidth(lyx::docstring const & s) const
{
if (s[0] == '-')
return -FontMetrics::width(s.substr(1, s.length() - 1));
else
return FontMetrics::width(s);
}
virtual void rectText(lyx::docstring const & str,
int & width,
int & ascent,
int & descent) const {};
virtual void buttonText(lyx::docstring const & str,
int & width,
int & ascent,
int & descent) const {};
};
} // namespace frontend
} // namespace lyx
#endif // LYX_NO_GUI_FONT_METRICS_H