Alert.h
Alert_pimpl.h
Application.h
- Clipboard.h
+ Clipboard.h\r
+ NoGuiFontLoader.h\r
+ NoGuiFontMetrics.h\r
Dialogs.h
FileDialog.h
FontLoader.h
#include "Alert_pimpl.h"
#include "debug.h"
+#include "lyx_main.h" // for lyx::use_gui
using lyx::docstring;
namespace lyx {
-extern bool use_gui;
-
namespace frontend {
int Alert::prompt(docstring const & title, docstring const & question,
#include "frontends/Application.h"
+#include "frontends/NoGuiFontLoader.h"
+#include "frontends/NoGuiFontMetrics.h"
#include "frontends/FontLoader.h"
#include "frontends/FontMetrics.h"
#include "frontends/Gui.h"
#include "bufferlist.h"
#include "funcrequest.h"
#include "FuncStatus.h"
+#include "lyx_main.h"
#include "LyXAction.h"
#include "lyxfont.h"
#include "lyxfunc.h"
lyx::frontend::FontLoader & theFontLoader()
{
+ static lyx::frontend::NoGuiFontLoader no_gui_font_loader;
+
+ if (!lyx::use_gui)
+ return no_gui_font_loader;
+
BOOST_ASSERT(theApp);
return theApp->fontLoader();
}
lyx::frontend::FontMetrics const & theFontMetrics(LyXFont const & f)
{
+ static lyx::frontend::NoGuiFontMetrics no_gui_font_metrics;
+
+ if (!lyx::use_gui)
+ return no_gui_font_metrics;
+
BOOST_ASSERT(theApp);
return theApp->fontLoader().metrics(f);
}
Alert_pimpl.h \
Application.C \
Application.h \
+ NoGuiFontLoader.h \
+ NoGuiFontMetrics.h \
Dialogs.C \
Dialogs.h \
FileDialog.h \
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file NoGuiFontLoader.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_FONTLOADER_H
+#define LYX_NO_GUI_FONTLOADER_H
+
+#include "frontends/FontLoader.h"
+
+#include "frontends/NoGuiFontMetrics.h"
+
+namespace lyx {
+namespace frontend {
+
+/// Dummy FontLoader for command-line output.
+class NoGuiFontLoader: public FontLoader
+{
+public:
+ ///
+ NoGuiFontLoader() {}
+ ///
+ virtual ~NoGuiFontLoader() {}
+
+ /// Update fonts after zoom, dpi, font names, or norm change
+ virtual void update() {};
+
+ /// Is the given font available ?
+ virtual bool available(LyXFont const & f) { return false; };
+
+ /// Get the Font metrics for this LyXFont
+ virtual FontMetrics const & metrics(LyXFont const & f) { return metrics_; }
+
+private:
+ ///
+ NoGuiFontMetrics metrics_;
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // LYX_NO_GUI_FONTLOADER_H
--- /dev/null
+// -*- 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
using std::endl;
using std::string;
-namespace lyx {
-extern bool use_gui;
-}
-
// The global fontLoader
xftFontLoader fontLoader;
bool xftFontLoader::available(LyXFont const & f)
{
- if (!lyx::use_gui)
- return false;
-
static std::vector<bool> cache_set(LyXFont::NUM_FAMILIES, false);
static std::vector<bool> cache(LyXFont::NUM_FAMILIES, false);
namespace lyx {
-
-extern bool use_gui;
-
namespace frontend {
int GuiFontMetrics::maxAscent() const
{
- if (!lyx::use_gui)
- return 1;
return metrics_.ascent();
}
int GuiFontMetrics::maxDescent() const
{
- if (!lyx::use_gui)
- return 1;
// We add 1 as the value returned by QT is different than X
// See http://doc.trolltech.com/2.3/qfontmetrics.html#200b74
return metrics_.descent() + 1;
int GuiFontMetrics::ascent(char_type c) const
{
- if (!lyx::use_gui)
- return 1;
QRect const & r = metrics_.boundingRect(ucs4_to_qchar(c));
// Qt/Win 3.2.1nc (at least) corrects the GetGlyphOutlineA|W y
// value by the height: (x, -y-height, width, height).
int GuiFontMetrics::descent(char_type c) const
{
- if (!lyx::use_gui)
- return 1;
QRect const & r = metrics_.boundingRect(ucs4_to_qchar(c));
// Qt/Win 3.2.1nc (at least) corrects the GetGlyphOutlineA|W y
// value by the height: (x, -y-height, width, height).
int GuiFontMetrics::lbearing(char_type c) const
{
- if (!lyx::use_gui)
- return 1;
return metrics_.leftBearing(ucs4_to_qchar(c));
}
int GuiFontMetrics::rbearing(char_type c) const
{
- if (!lyx::use_gui)
- return 1;
-
// Qt rbearing is from the right edge of the char's width().
QChar sc = ucs4_to_qchar(c);
return metrics_.width(sc) - metrics_.rightBearing(sc);
int GuiFontMetrics::smallcapsWidth(QString const & s) const
{
- if (!lyx::use_gui)
- return 1;
-
int w = 0;
int const ls = s.length();
int GuiFontMetrics::width(char_type const * s, size_t ls) const
{
- if (!lyx::use_gui)
- return ls;
-
QString const ucs2 = toqstr(s, ls);
if (smallcaps_shape_)
using std::vector;
using std::string;
-namespace lyx {
-extern bool use_gui;
-}
-
GuiFontLoader::~GuiFontLoader() {
}
bool GuiFontLoader::available(LyXFont const & f)
{
- if (!lyx::use_gui)
- return false;
-
static vector<int> cache_set(LyXFont::NUM_FAMILIES, false);
static vector<int> cache(LyXFont::NUM_FAMILIES, false);
namespace lyx {
-
-extern bool use_gui;
-
namespace frontend {
GuiFontLoader::~GuiFontLoader() {
bool GuiFontLoader::available(LyXFont const & f)
{
- if (!lyx::use_gui)
- return false;
-
static vector<int> cache_set(LyXFont::NUM_FAMILIES, false);
static vector<int> cache(LyXFont::NUM_FAMILIES, false);
using std::string;
namespace lyx {
-
-extern bool use_gui;
-
namespace frontend {
int GuiFontMetrics::maxAscent() const
{
- if (!lyx::use_gui)
- return 1;
return metrics_.ascent();
}
int GuiFontMetrics::maxDescent() const
{
- if (!lyx::use_gui)
- return 1;
// We add 1 as the value returned by QT is different than X
// See http://doc.trolltech.com/2.3/qfontmetrics.html#200b74
return metrics_.descent() + 1;
int GuiFontMetrics::ascent(char_type c) const
{
- if (!lyx::use_gui)
- return 1;
QRect const & r = metrics_.boundingRect(ucs4_to_qchar(c));
// Qt/Win 3.2.1nc (at least) corrects the GetGlyphOutlineA|W y
// value by the height: (x, -y-height, width, height).
int GuiFontMetrics::descent(char_type c) const
{
- if (!lyx::use_gui)
- return 1;
QRect const & r = metrics_.boundingRect(ucs4_to_qchar(c));
// Qt/Win 3.2.1nc (at least) corrects the GetGlyphOutlineA|W y
// value by the height: (x, -y-height, width, height).
int GuiFontMetrics::lbearing(char_type c) const
{
- if (!lyx::use_gui)
- return 1;
return metrics_.leftBearing(ucs4_to_qchar(c));
}
int GuiFontMetrics::rbearing(char_type c) const
{
- if (!lyx::use_gui)
- return 1;
-
// Qt rbearing is from the right edge of the char's width().
QChar sc = ucs4_to_qchar(c);
return metrics_.width(sc) - metrics_.rightBearing(sc);
int GuiFontMetrics::smallcapsWidth(QString const & s) const
{
- if (!lyx::use_gui)
- return 1;
-
int w = 0;
int const ls = s.size();
int GuiFontMetrics::width(char_type const * s, size_t ls) const
{
- if (!lyx::use_gui)
- return ls;
-
QString ucs2;
ucs4_to_qstring(s, ls, ucs2);
using std::ostringstream;
using std::vector;
-namespace lyx {
-extern bool use_gui;
-}
namespace {
#include "insetgraphicsParams.h"
#include "debug.h"
+#include "lyx_main.h" // for lyx::use_gui
#include "lyxlex.h"
#include "lyxrc.h"
using std::ostream;
-namespace lyx {
-extern bool use_gui;
-}
-
InsetGraphicsParams::InsetGraphicsParams()
{
init();
// this should be static, but I need it in buffer.C
bool quitting; // flag, that we are quitting the program
-namespace lyx {
-extern bool use_gui;
-}
-
//
// Menu callbacks
//
class kb_keymap;
namespace lyx {
+extern bool use_gui;
class Session;
namespace frontend {
class Application;
}
}
-
/// initial startup
class LyX : boost::noncopyable {
public:
// (alkis)
extern tex_accent_struct get_accent(kb_action action);
-namespace lyx {
-extern bool use_gui;
-}
namespace {
bool has_math_fonts;
-namespace lyx {
-extern bool use_gui;
-}
namespace {
bool math_font_available(string & name)
{
- if (!lyx::use_gui)
- return false;
-
LyXFont f;
augmentFont(f, name);