WorkArea.h
guiapi.h
key_state.h
- lyx_gui.h
mouse_state.h
nullpainter.h
''')
Toolbars.C
WorkArea.C
guiapi.C
- lyx_gui.C
nullpainter.C
''')
iconpalette.C
lcolorcache.C
lengthcombo.C
- lyx_gui.C
panelstack.C
qcoloritem.C
qfont_loader.C
FloatPlacement.C
iconpalette.C
lengthcombo.C
- lyx_gui.C
panelstack.C
qfontexample.C
qsetborder.C
#include "BranchList.h"
#include "LColor.h"
-#include "frontends/lyx_gui.h"
+
+#include "frontends/Application.h"
+
#include <algorithm>
using std::string;
Branch::Branch()
{
- lyx_gui::getRGBColor(LColor::background, color_);
+ theApp->getRgbColor(LColor::background, color_);
}
color_ = lyx::RGBColor(c);
else
// no color set or invalid color - use normal background
- lyx_gui::getRGBColor(LColor::background, color_);
+ theApp->getRgbColor(LColor::background, color_);
}
#include "Alert_pimpl.h"
#include "debug.h"
-#include "lyx_gui.h"
using lyx::docstring;
namespace lyx {
+
+extern bool use_gui;
+
namespace frontend {
int Alert::prompt(docstring const & title, docstring const & question,
int default_button, int escape_button,
docstring const & b1, docstring const & b2, docstring const & b3)
{
- if (!lyx_gui::use_gui || lyxerr.debugging()) {
+ if (!lyx::use_gui || lyxerr.debugging()) {
lyxerr << lyx::to_utf8(title) << '\n'
<< "----------------------------------------\n"
<< lyx::to_utf8(question) << endl;
case 1: lyxerr << lyx::to_utf8(b2) << endl;
case 2: lyxerr << lyx::to_utf8(b3) << endl;
}
- if (!lyx_gui::use_gui)
+ if (!lyx::use_gui)
return default_button;
}
void Alert::warning(docstring const & title, docstring const & message)
{
- if (!lyx_gui::use_gui || lyxerr.debugging())
+ if (!lyx::use_gui || lyxerr.debugging())
lyxerr << "Warning: " << lyx::to_utf8(title) << '\n'
<< "----------------------------------------\n"
<< lyx::to_utf8(message) << endl;
- if (lyx_gui::use_gui)
+ if (lyx::use_gui)
warning_pimpl(title, message);
}
void Alert::error(docstring const & title, docstring const & message)
{
- if (!lyx_gui::use_gui || lyxerr.debugging())
+ if (!lyx::use_gui || lyxerr.debugging())
lyxerr << "Error: " << lyx::to_utf8(title) << '\n'
<< "----------------------------------------\n"
<< lyx::to_utf8(message) << endl;
- if (lyx_gui::use_gui)
+ if (lyx::use_gui)
error_pimpl(title, message);
}
void Alert::information(docstring const & title, docstring const & message)
{
- if (!lyx_gui::use_gui || lyxerr.debugging())
+ if (!lyx::use_gui || lyxerr.debugging())
lyxerr << lyx::to_utf8(title) << '\n'
<< "----------------------------------------\n"
<< lyx::to_utf8(message) << endl;
- if (lyx_gui::use_gui)
+ if (lyx::use_gui)
information_pimpl(title, message);
}
pair<bool, docstring> const Alert::askForText(docstring const & msg,
docstring const & dflt)
{
- if (!lyx_gui::use_gui || lyxerr.debugging()) {
+ if (!lyx::use_gui || lyxerr.debugging()) {
lyxerr << "----------------------------------------\n"
<< lyx::to_utf8(msg) << '\n'
<< "Assuming answer is " << lyx::to_utf8(dflt) << '\n'
<< "----------------------------------------" << endl;
- if (!lyx_gui::use_gui)
+ if (!lyx::use_gui)
return make_pair<bool, docstring>(true, dflt);
}
#include "support/os.h"
#include "support/package.h"
+#include <boost/scoped_ptr.hpp>
+#include <boost/shared_ptr.hpp>
using lyx::support::package;
return exec();
}
-
} // namespace frontend
{
return theApp->selection();
}
+
#ifndef LYX_APPLICATION_H
#define LYX_APPLICATION_H
-#include <boost/scoped_ptr.hpp>
+#include <boost/function.hpp>
#include <string>
class LyXServer;
class LyXServerSocket;
class LyXView;
+class LColor_color;
namespace lyx {
+
+struct RGBColor;
+
namespace frontend {
struct Application_pimpl;
*/
virtual void exit(int status) = 0;
+ /**
+ * Synchronise all pending events.
+ */
+ virtual void syncEvents() = 0;
///
virtual Clipboard & clipboard() = 0;
///
/// return a suitable monospaced font name.
virtual std::string const typewriterFontName() = 0;
+ /**
+ * Given col, fills r, g, b in the range 0-255.
+ * The function returns true if successful.
+ * It returns false on failure and sets r, g, b to 0.
+ */
+ virtual bool getRgbColor(LColor_color col, lyx::RGBColor & rgbcol) = 0;
+
+ /** Eg, passing LColor::black returns "000000",
+ * passing LColor::white returns "ffffff".
+ */
+ virtual std::string const hexName(LColor_color col) = 0;
+
+ /**
+ * update an altered GUI color
+ */
+ virtual void updateColor(LColor_color col) = 0;
+
+ /**
+ * add a callback for socket read notification
+ * @param fd socket descriptor (file/socket/etc)
+ */
+ virtual void registerSocketCallback(
+ int fd, boost::function<void()> func) = 0;
+
+ /**
+ * remove a I/O read callback
+ * @param fd socket descriptor (file/socket/etc)
+ */
+ virtual void unregisterSocketCallback(int fd) = 0;
+
///
LyXFunc & lyxFunc();
LyXFunc const & lyxFunc() const;
}; // Application
} // namespace frontend
+
+lyx::frontend::Application * createApplication(int & argc, char * argv[]);
+
} // namespace lyx
extern lyx::frontend::Application * theApp;
guiapi.h \
guiapi.C \
key_state.h \
- lyx_gui.C \
- lyx_gui.h \
mouse_state.h \
nullpainter.C \
nullpainter.h
#include "frontends/FontMetrics.h"
#include "funcrequest.h"
-#include "lyx_gui.h"
#include "lyxfunc.h"
#include "Painter.h"
namespace {
+std::map<int, boost::shared_ptr<io_callback> > callbacks;
+
/// estimate DPI from X server
int getDPI()
{
namespace lyx {
+
+lyx::frontend::Application * createApplication(int & argc, char * argv[])
+{
+ return new GuiApplication(argc, argv);
+}
+
namespace frontend {
GuiApplication::GuiApplication(int & argc, char ** argv)
}
+void GuiApplication::syncEvents()
+{
+ // FIXME
+}
+
+
+bool GuiApplication::getRgbColor(LColor_color col,
+ lyx::RGBColor & rgbcol)
+{
+ Gdk::Color gdkColor;
+ Gdk::Color * gclr = colorCache.getColor(col);
+ if (!gclr) {
+ gclr = &gdkColor;
+ if(!gclr->parse(lcolor.getX11Name(col))) {
+ rgbcol.r = 0;
+ rgbcol.g = 0;
+ rgbcol.b = 0;
+ return false;
+ }
+ }
+
+ // Note that X stores the RGB values in the range 0 - 65535
+ // whilst we require them in the range 0 - 255.
+ rgbcol.r = gclr->get_red() / 256;
+ rgbcol.g = gclr->get_green() / 256;
+ rgbcol.b = gclr->get_blue() / 256;
+ return true;
+}
+
+
+string const GuiApplication::hexName(LColor_color col)
+{
+ lyx::RGBColor rgbcol;
+ if (!getRGBColor(col, rgbcol)) {
+ lyxerr << "X can't find color for \"" << lcolor.getLyXName(col)
+ << '"' << std::endl;
+ return string();
+ }
+
+ std::ostringstream os;
+
+ os << std::setbase(16) << std::setfill('0')
+ << std::setw(2) << rgbcol.r
+ << std::setw(2) << rgbcol.g
+ << std::setw(2) << rgbcol.b;
+
+ return os.str();
+}
+
+
+void GuiApplication::updateColor(LColor_color)
+{
+ colorCache.clear();
+}
+
+
+void GuiApplication::registerSocketCallback(int fd, boost::function<void()> func)
+{
+ callbacks[fd] = boost::shared_ptr<io_callback>(new io_callback(fd, func));
+}
+
+
+void GuiApplication::unregisterSocketCallback(int fd)
+{
+ callbacks.erase(fd);
+}
+
} // namespace frontend
} // namespace lyx
virtual std::string const romanFontName();
virtual std::string const sansFontName();
virtual std::string const typewriterFontName();
+ virtual bool getRgbColor(LColor_color col, lyx::RGBColor & rgbcol);
+ virtual std::string const hexName(LColor_color col);
+ virtual void updateColor(LColor_color col);
+ virtual void registerSocketCallback(
+ int fd, boost::function<void()> func);
+ virtual void unregisterSocketCallback(int fd);
//@}
///
GuiImplementation.C \
io_callback.C \
io_callback.h \
- lyx_gui.C \
xftFontLoader.C \
xftFontLoader.h \
xftFontMetrics.C
#include "GtkmmX.h"
#include "frontends/LyXView.h"
-#include "frontends/lyx_gui.h"
#include "support/convert.h"
#include "support/lstrings.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_gui::use_gui)
+ if (!lyx::use_gui)
return false;
static std::vector<bool> cache_set(LyXFont::NUM_FAMILIES, false);
+++ /dev/null
-/**
- * \file frontends/lyx_gui.C
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- * \author Abdelrazak Younes
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "lyx_gui.h"
-
-#include "Application.h"
-
-using std::string;
-
-lyx::frontend::Application * theApp;
-
-
-namespace lyx_gui {
-
-bool use_gui = true;
-
-}; // namespace lyx_gui
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file lyx_gui.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef LYX_GUI_H
-#define LYX_GUI_H
-
-
-#include "FuncStatus.h"
-
-#include <boost/function.hpp>
-
-#include <string>
-#include <vector>
-
-class Dialogs;
-class LColor_color;
-class LyXFont;
-class LyXComm;
-class FuncRequest;
-class LyXView;
-namespace lyx {
-struct RGBColor;
-}
-
-/// GUI interaction
-namespace lyx_gui {
-
-/// are we using the GUI at all
-extern bool use_gui;
-
-/**
- * Enter the main event loop (\sa LyX::exec2)
- */
-int exec(int & argc, char * argv[]);
-
-/**
- * Synchronise all pending events.
- */
-void sync_events();
-
-/**
- * Given col, fills r, g, b in the range 0-255.
- * The function returns true if successful.
- * It returns false on failure and sets r, g, b to 0.
- */
-bool getRGBColor(LColor_color col, lyx::RGBColor & rgbcol);
-
-/** Eg, passing LColor::black returns "000000",
- * passing LColor::white returns "ffffff".
- */
-std::string const hexname(LColor_color col);
-
-/**
- * update an altered GUI color
- */
-void update_color(LColor_color col);
-
-/**
- * add a callback for socket read notification
- * @param fd socket descriptor (file/socket/etc)
- */
-void register_socket_callback(int fd, boost::function<void()> func);
-
-/**
- * remove a I/O read callback
- * @param fd socket descriptor (file/socket/etc)
- */
-void unregister_socket_callback(int fd);
-
-} // namespace lyx_gui
-
-#endif // LYX_GUI_H
#include "qt_helpers.h"
#include "QLImage.h"
+#include "socket_callback.h"
#include "graphics/LoaderQueue.h"
namespace {
+map<int, shared_ptr<socket_callback> > socket_callbacks;
+
int getDPI()
{
QWidget w;
namespace lyx {
+
+lyx::frontend::Application * createApplication(int & argc, char * argv[])
+{
+ GuiApplication app(argc, argv);
+
+ return &app;
+}
+
namespace frontend {
GuiApplication::GuiApplication(int & argc, char ** argv)
}
+void GuiApplication::syncEvents()
+{
+ // This is the ONLY place where processEvents may be called.
+ // During screen update/ redraw, this method is disabled to
+ // prevent keyboard events being handed to the LyX core, where
+ // they could cause re-entrant calls to screen update.
+#if QT_VERSION >= 0x030100
+ qApp->eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
+#endif
+}
+
+
+bool GuiApplication::getRgbColor(LColor_color col,
+ lyx::RGBColor & rgbcol)
+{
+ QColor const & qcol = lcolorcache.get(col);
+ if (!qcol.isValid()) {
+ rgbcol.r = 0;
+ rgbcol.g = 0;
+ rgbcol.b = 0;
+ return false;
+ }
+ rgbcol.r = qcol.red();
+ rgbcol.g = qcol.green();
+ rgbcol.b = qcol.blue();
+ return true;
+}
+
+
+string const GuiApplication::hexName(LColor_color col)
+{
+ return ltrim(fromqstr(lcolorcache.get(col).name()), "#");
+}
+
+
+void GuiApplication::updateColor(LColor_color)
+{
+ // FIXME: Bleh, can't we just clear them all at once ?
+ lcolorcache.clear();
+}
+
+
+void GuiApplication::registerSocketCallback(int fd, boost::function<void()> func)
+{
+ socket_callbacks[fd] = shared_ptr<socket_callback>(new socket_callback(fd, func));
+}
+
+
+void GuiApplication::unregisterSocketCallback(int fd)
+{
+ socket_callbacks.erase(fd);
+}
+
+
////////////////////////////////////////////////////////////////////////
// X11 specific stuff goes here...
#ifdef Q_WS_X11
virtual std::string const romanFontName();
virtual std::string const sansFontName();
virtual std::string const typewriterFontName();
+ virtual bool getRgbColor(LColor_color col, lyx::RGBColor & rgbcol);
+ virtual std::string const hexName(LColor_color col);
+ virtual void updateColor(LColor_color col);
+ virtual void registerSocketCallback(
+ int fd, boost::function<void()> func);
+ virtual void unregisterSocketCallback(int fd);
//@}
///
#include "language.h"
-#include "frontends/lyx_gui.h"
-
#include "support/unicode.h"
using lyx::char_type;
namespace lyx {
+
+extern bool use_gui;
+
namespace frontend {
int GuiFontMetrics::maxAscent() const
{
- if (!lyx_gui::use_gui)
+ if (!lyx::use_gui)
return 1;
return metrics_.ascent();
}
int GuiFontMetrics::maxDescent() const
{
- if (!lyx_gui::use_gui)
+ 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
int GuiFontMetrics::ascent(char_type c) const
{
- if (!lyx_gui::use_gui)
+ 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
int GuiFontMetrics::descent(char_type c) const
{
- if (!lyx_gui::use_gui)
+ 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
int GuiFontMetrics::lbearing(char_type c) const
{
- if (!lyx_gui::use_gui)
+ if (!lyx::use_gui)
return 1;
return metrics_.leftBearing(ucs4_to_qchar(c));
}
int GuiFontMetrics::rbearing(char_type c) const
{
- if (!lyx_gui::use_gui)
+ if (!lyx::use_gui)
return 1;
// Qt rbearing is from the right edge of the char's width().
int GuiFontMetrics::smallcapsWidth(QString const & s) const
{
- if (!lyx_gui::use_gui)
+ if (!lyx::use_gui)
return 1;
int w = 0;
int GuiFontMetrics::width(char_type const * s, size_t ls) const
{
- if (!lyx_gui::use_gui)
+ if (!lyx::use_gui)
return ls;
QString const ucs2 = toqstr(s, ls);
Qt2BC.C Qt2BC.h \
QtLyXView.h \
checkedwidgets.C checkedwidgets.h \
- lyx_gui.C \
lcolorcache.h lcolorcache.C \
panelstack.h panelstack.C \
qcoloritem.h qcoloritem.C \
#include "MenuBackend.h"
-#include "frontends/lyx_gui.h"
+#include "frontends/Application.h"
#include "support/lstrings.h"
{
// make sure the interface is repainted correctly (in case the
// action needs a long time, like File>Open).
- lyx_gui::sync_events();
+ theApp->syncEvents();
#ifdef Q_WS_MACX
if (index >= indexOffset) {
MenuItem mi = owner_->backend().getMenu("LyX")[index - indexOffset];
#include "controllers/ControlMath.h"
-#include "frontends/lyx_gui.h"
+#include "frontends/Application.h"
#include <qwidgetstack.h>
#include <qcombobox.h>
w_->resize(viewport()->width(), w_->height());
// force the resize to get accurate scrollbar
- lyx_gui::sync_events();
+ theApp->syncEvents();
resizeContents(w_->width(), w_->height());
}
private:
#include "controllers/helper_funcs.h"
#include "frontends/Application.h"
-#include "frontends/lyx_gui.h"
#include <qcheckbox.h>
#include "qcoloritem.h"
#include "QViewSource.h"
#include "QViewSourceDialog.h"
#include "qt_helpers.h"
-#include "lyx_gui.h"
#include "frontends/Application.h"
#include "debug.h"
#include "lyxrc.h"
-#include "frontends/lyx_gui.h"
-
#include "support/convert.h"
#include "support/filetools.h"
#include "support/lstrings.h"
using std::vector;
using std::string;
+namespace lyx {
+extern bool use_gui;
+}
+
GuiFontLoader::~GuiFontLoader() {
}
bool GuiFontLoader::available(LyXFont const & f)
{
- if (!lyx_gui::use_gui)
+ if (!lyx::use_gui)
return false;
static vector<int> cache_set(LyXFont::NUM_FAMILIES, false);
#include "qt_helpers.h"
#include "QLImage.h"
+#include "socket_callback.h"
#include "graphics/LoaderQueue.h"
#include "support/package.h"
#include "BufferView.h"
+#include "Color.h"
+#include "debug.h"
#include "lyx_main.h"
#include "lyxrc.h"
-#include "debug.h"
#include <QApplication>
#include <QClipboard>
} // namespace anon
+lyx::frontend::GuiApplication * guiApp;
+
namespace lyx {
+
+lyx::frontend::Application * createApplication(int & argc, char * argv[])
+{
+ // FIXME: it would be great if we could just do:
+ //return new lyx::frontend::GuiApplication(argc, argv);
+
+#if defined(Q_WS_WIN) && !defined(Q_CYGWIN_WIN)
+ static lyx::frontend::GuiApplication app(argc, argv);
+#else
+ lyx::frontend::GuiApplication app(argc, argv);
+#endif
+
+ return &app;
+}
+
+
namespace frontend {
GuiApplication::GuiApplication(int & argc, char ** argv)
lyxrc.dpi = getDPI();
LoaderQueue::setPriority(10,100);
+
+ guiApp = this;
}
}
+void GuiApplication::syncEvents()
+{
+ // This is the ONLY place where processEvents may be called.
+ // During screen update/ redraw, this method is disabled to
+ // prevent keyboard events being handed to the LyX core, where
+ // they could cause re-entrant calls to screen update.
+ processEvents(QEventLoop::ExcludeUserInputEvents);
+}
+
+
+bool GuiApplication::getRgbColor(LColor_color col,
+ lyx::RGBColor & rgbcol)
+{
+ QColor const & qcol = color_cache_.get(col);
+ if (!qcol.isValid()) {
+ rgbcol.r = 0;
+ rgbcol.g = 0;
+ rgbcol.b = 0;
+ return false;
+ }
+ rgbcol.r = qcol.red();
+ rgbcol.g = qcol.green();
+ rgbcol.b = qcol.blue();
+ return true;
+}
+
+
+string const GuiApplication::hexName(LColor_color col)
+{
+ return lyx::support::ltrim(fromqstr(color_cache_.get(col).name()), "#");
+}
+
+
+void GuiApplication::updateColor(LColor_color)
+{
+ // FIXME: Bleh, can't we just clear them all at once ?
+ color_cache_.clear();
+}
+
+
+void GuiApplication::registerSocketCallback(int fd, boost::function<void()> func)
+{
+ socket_callbacks_[fd] =
+ boost::shared_ptr<socket_callback>(new socket_callback(fd, func));
+}
+
+
+void GuiApplication::unregisterSocketCallback(int fd)
+{
+ socket_callbacks_.erase(fd);
+}
+
////////////////////////////////////////////////////////////////////////
// X11 specific stuff goes here...
#ifdef Q_WS_X11
///////////////////////////////////////////////////////////////
class BufferView;
+class socket_callback;
namespace lyx {
namespace frontend {
virtual int const exec();
virtual Gui & gui() { return gui_; }
virtual void exit(int status);
+ void syncEvents();
virtual std::string const romanFontName();
virtual std::string const sansFontName();
virtual std::string const typewriterFontName();
+ virtual bool getRgbColor(LColor_color col, lyx::RGBColor & rgbcol);
+ virtual std::string const hexName(LColor_color col);
+ virtual void updateColor(LColor_color col);
+ virtual void registerSocketCallback(
+ int fd, boost::function<void()> func);
+ virtual void unregisterSocketCallback(int fd);
//@}
///
GuiFontLoader font_loader_;
///
ColorCache color_cache_;
+ ///
+ std::map<int, boost::shared_ptr<socket_callback> > socket_callbacks_;
#ifdef Q_WS_X11
public:
#include "debug.h"
#include "lyxrc.h"
-#include "frontends/lyx_gui.h"
-
#include "support/convert.h"
#include "support/filetools.h"
#include "support/lstrings.h"
namespace lyx {
+
+extern bool use_gui;
+
namespace frontend {
GuiFontLoader::~GuiFontLoader() {
bool GuiFontLoader::available(LyXFont const & f)
{
- if (!lyx_gui::use_gui)
+ if (!lyx::use_gui)
return false;
static vector<int> cache_set(LyXFont::NUM_FAMILIES, false);
#include "language.h"
-#include "frontends/lyx_gui.h"
-
#include "support/unicode.h"
using lyx::char_type;
using std::string;
-
namespace lyx {
+
+extern bool use_gui;
+
namespace frontend {
int GuiFontMetrics::maxAscent() const
{
- if (!lyx_gui::use_gui)
+ if (!lyx::use_gui)
return 1;
return metrics_.ascent();
}
int GuiFontMetrics::maxDescent() const
{
- if (!lyx_gui::use_gui)
+ 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
int GuiFontMetrics::ascent(char_type c) const
{
- if (!lyx_gui::use_gui)
+ 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
int GuiFontMetrics::descent(char_type c) const
{
- if (!lyx_gui::use_gui)
+ 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
int GuiFontMetrics::lbearing(char_type c) const
{
- if (!lyx_gui::use_gui)
+ if (!lyx::use_gui)
return 1;
return metrics_.leftBearing(ucs4_to_qchar(c));
}
int GuiFontMetrics::rbearing(char_type c) const
{
- if (!lyx_gui::use_gui)
+ if (!lyx::use_gui)
return 1;
// Qt rbearing is from the right edge of the char's width().
int GuiFontMetrics::smallcapsWidth(QString const & s) const
{
- if (!lyx_gui::use_gui)
+ if (!lyx::use_gui)
return 1;
int w = 0;
int GuiFontMetrics::width(char_type const * s, size_t ls) const
{
- if (!lyx_gui::use_gui)
+ if (!lyx::use_gui)
return ls;
QString ucs2;
QWrap.C QWrap.h \
Qt2BC.C Qt2BC.h \
checkedwidgets.C checkedwidgets.h \
- lyx_gui.C \
panelstack.h panelstack.C \
qfontexample.h qfontexample.C \
qlkey.h \
#include "qt_helpers.h"
#include "MenuBackend.h"
-#include "frontends/lyx_gui.h"
#include "support/lstrings.h"
#include "debug.h"
#include "iconpalette.h"
#include "qt_helpers.h"
#include "controllers/ControlMath.h"
-#include "frontends/lyx_gui.h"
+
#include "support/filetools.h"
using std::string;
#include "controllers/frnt_lang.h"
#include "controllers/helper_funcs.h"
-#include "frontends/lyx_gui.h"
-
using namespace Ui;
namespace lyx {
#include "controllers/helper_funcs.h"
#include "frontends/Alert.h"
-#include "frontends/lyx_gui.h"
+#include "frontends/Application.h"
#include "QPrefsDialog.h"
#include "QPrefs.h"
+++ /dev/null
-/**
- * \file qt4/lyx_gui.C
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author unknown
- * \author John Levon
- * \author Abdelrazak Younes
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "lyx_gui.h"
-
-// FIXME: move this stuff out again
-#include "Color.h"
-#include "funcrequest.h"
-#include "LColor.h"
-#include "lyx_main.h"
-#include "LyXAction.h"
-#include "lyxfunc.h"
-#include "lyxrc.h"
-
-
-#include "support/lstrings.h"
-
-#include "GuiView.h"
-#include "QLImage.h"
-#include "qt_helpers.h"
-#include "socket_callback.h"
-#include "GuiApplication.h"
-
-#include <QApplication>
-#include <QEventLoop>
-#include <QTranslator>
-#include <QTextCodec>
-#include <QLocale>
-#include <QLibraryInfo>
-
-#include <boost/bind.hpp>
-#include <boost/shared_ptr.hpp>
-
-
-using lyx::support::ltrim;
-
-using lyx::frontend::GuiImplementation;
-using lyx::frontend::GuiView;
-using lyx::frontend::GuiApplication;
-
-using boost::shared_ptr;
-
-using std::map;
-using std::vector;
-using std::string;
-
-lyx::frontend::GuiApplication * guiApp;
-
-namespace {
-
-map<int, shared_ptr<socket_callback> > socket_callbacks;
-
-} // namespace anon
-
-namespace lyx_gui {
-
-int exec(int & argc, char * argv[])
-{
- /*
- FIXME : Abdel 29/05/2006 (younes.a@free.fr)
- reorganize this code. In particular make sure that this
- advice from Qt documentation is respected:
-
- Since the QApplication object does so much initialization, it
- must be created before any other objects related to the user
- interface are created.
-
- Right now this is not the case, I suspect that a number of global variables
- contains Qt object that are initialized before the passage through
- parse_init(). This might also explain the message displayed by Qt
- that caused the hanging:
-
- QObject::killTimer: timers cannot be stopped from another thread
-
- I hope that the problem will disappear automagically when we get rid of
- lyx_gui entirely, thus using theApp directly throughout the code for LyXFunc,
- Clipboard and Selection access.
- */
-
-#if defined(Q_WS_WIN) && !defined(Q_CYGWIN_WIN)
- static GuiApplication app(argc, argv);
-#else
- GuiApplication app(argc, argv);
-#endif
-
- guiApp = &app;
- theApp = guiApp;
-
- return LyX::ref().exec2(argc, argv);
-}
-
-
-void sync_events()
-{
- // This is the ONLY place where processEvents may be called.
- // During screen update/ redraw, this method is disabled to
- // prevent keyboard events being handed to the LyX core, where
- // they could cause re-entrant calls to screen update.
- guiApp->processEvents(QEventLoop::ExcludeUserInputEvents);
-}
-
-
-bool getRGBColor(LColor_color col, lyx::RGBColor & rgbcol)
-{
- QColor const & qcol = guiApp->colorCache().get(col);
- if (!qcol.isValid()) {
- rgbcol.r = 0;
- rgbcol.g = 0;
- rgbcol.b = 0;
- return false;
- }
- rgbcol.r = qcol.red();
- rgbcol.g = qcol.green();
- rgbcol.b = qcol.blue();
- return true;
-}
-
-
-string const hexname(LColor_color col)
-{
- return ltrim(fromqstr(guiApp->colorCache().get(col).name()), "#");
-}
-
-
-void update_color(LColor_color)
-{
- // FIXME: Bleh, can't we just clear them all at once ?
- guiApp->colorCache().clear();
-}
-
-
-void register_socket_callback(int fd, boost::function<void()> func)
-{
- socket_callbacks[fd] = shared_ptr<socket_callback>(new socket_callback(fd, func));
-}
-
-
-void unregister_socket_callback(int fd)
-{
- socket_callbacks.erase(fd);
-}
-
-}; // namespace lyx_gui
#include "outputparams.h"
#include "paragraph.h"
-#include "frontends/lyx_gui.h" // hexname
+#include "frontends/Application.h" // hexName
#include "insets/inset.h"
cs << pconverter_->command << ' ' << pconverter_->to << ' '
<< support::quoteName(latexfile) << ' '
<< int(font_scaling_factor_) << ' '
- << lyx_gui::hexname(LColor::preview) << ' '
- << lyx_gui::hexname(LColor::background);
+ << theApp->hexName(LColor::preview) << ' '
+ << theApp->hexName(LColor::background);
string const command = support::libScriptSearch(cs.str());
#include "debug.h"
#include "dispatchresult.h"
#include "exporter.h"
+#include "FuncStatus.h"
#include "funcrequest.h"
#include "gettext.h"
#include "LaTeXFeatures.h"
#include "metricsinfo.h"
#include "outputparams.h"
-#include "frontends/lyx_gui.h"
-
#include "graphics/PreviewLoader.h"
#include "support/filetools.h"
using std::ostringstream;
using std::vector;
+namespace lyx {
+extern bool use_gui;
+}
namespace {
if (gparams.display == graphics::DefaultDisplay)
gparams.display = lyxrc.display_graphics;
// Override the above if we're not using a gui
- if (!lyx_gui::use_gui)
+ if (!lyx::use_gui)
gparams.display = graphics::NoDisplay;
return gparams;
#include "lyxlex.h"
#include "lyxrc.h"
-#include "frontends/lyx_gui.h"
-
#include "graphics/GraphicsParams.h"
#include "support/convert.h"
using std::ostream;
+namespace lyx {
+extern bool use_gui;
+}
+
InsetGraphicsParams::InsetGraphicsParams()
{
init();
}
// Override the above if we're not using a gui
- if (!lyx_gui::use_gui) {
+ if (!lyx::use_gui) {
pars.display = lyx::graphics::NoDisplay;
}
#include "frontends/Alert.h"
#include "frontends/Application.h"
#include "frontends/FileDialog.h"
-#include "frontends/lyx_gui.h"
#include "support/filefilterlist.h"
#include "support/filetools.h"
// 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
{
lyxerr[Debug::INFO] << "Running QuitLyX." << endl;
- if (lyx_gui::use_gui) {
+ if (lyx::use_gui) {
if (!noask && !theBufferList().quitWriteAll())
return;
Alert::warning(_("Unable to remove temporary directory"), msg);
}
- if (lyx_gui::use_gui)
+ if (lyx::use_gui) {
theApp->exit(0);
- // Restore original font resources after Application is destroyed.
- lyx::support::restoreFontResources();
+ // Restore original font resources after Application is destroyed.
+ lyx::support::restoreFontResources();
+ }
}
#include "frontends/Alert.h"
#include "frontends/Application.h"
-#include "frontends/lyx_gui.h"
#include "frontends/LyXView.h"
#include "support/environment.h"
#endif
-// convenient to have it here.
+/// convenient to have it here.
boost::scoped_ptr<kb_keymap> toplevel_keymap;
+///
+lyx::frontend::Application * theApp;
+
+namespace lyx {
+
+/// are we using the GUI at all?
+/**
+* We default to true and this is changed to false when the export feature is used.
+*/
+bool use_gui = true;
+
+}
+
namespace {
// Filled with the command line arguments "foo" of "-sysdir foo" or
// FIXME: We should not directly call exit(), since it only
// guarantees a return to the system, no application cleanup.
// This may cause troubles with not executed destructors.
- if (lyx_gui::use_gui) {
+ if (lyx::use_gui) {
theApp->exit(status);
// Restore original font resources after Application is destroyed.
lyx::support::restoreFontResources();
{
// Here we need to parse the command line. At least
// we need to parse for "-dbg" and "-help"
- lyx_gui::use_gui = easyParse(argc, argv);
+ easyParse(argc, argv);
lyx::support::init_package(argv[0], cl_system_support, cl_user_support,
lyx::support::top_build_dir_is_one_level_up);
// Start the real execution loop.
- if (lyx_gui::use_gui) {
+ if (lyx::use_gui) {
// Force adding of font path _before_ Application is initialized
lyx::support::addFontResources();
- return lyx_gui::exec(argc, argv);
+ theApp = lyx::createApplication(argc, argv);
}
- else
- return exec2(argc, argv);
+ else {
+ // FIXME: create a ConsoleApplication
+ theApp = 0;
+ }
+
+ return exec2(argc, argv);
}
files.clear(); // the files are already loaded
}
- if (lyx_gui::use_gui) {
+ if (lyx::use_gui) {
// determine windows size and position, from lyxrc and/or session
// initial geometry
unsigned int width = 690;
if (lyxrc.roman_font_name.empty())
lyxrc.roman_font_name =
- lyx_gui::use_gui? theApp->romanFontName(): "serif";
+ lyx::use_gui? theApp->romanFontName(): "serif";
if (lyxrc.sans_font_name.empty())
lyxrc.sans_font_name =
- lyx_gui::use_gui? theApp->sansFontName(): "sans";
+ lyx::use_gui? theApp->sansFontName(): "sans";
if (lyxrc.typewriter_font_name.empty())
lyxrc.typewriter_font_name =
- lyx_gui::use_gui? theApp->typewriterFontName(): "monospace";
+ lyx::use_gui? theApp->typewriterFontName(): "monospace";
//
// Read configuration files
reconfigureUserLyXDir();
// no need for a splash when there is no GUI
- if (!lyx_gui::use_gui) {
+ if (!lyx::use_gui) {
first_start = false;
}
if (!LyXSetStyle())
return false;
- if (lyx_gui::use_gui) {
+ if (lyx::use_gui) {
// Set up bindings
toplevel_keymap.reset(new kb_keymap);
defaultKeyBindings(toplevel_keymap.get());
namespace {
-bool is_gui = true;
string batch;
/// return the the number of arguments consumed
exit(1);
}
batch = "buffer-export " + type;
- is_gui = false;
+ lyx::use_gui = true;
return 1;
}
} // namespace anon
-bool LyX::easyParse(int & argc, char * argv[])
+void LyX::easyParse(int & argc, char * argv[])
{
std::map<string, cmd_helper> cmdmap;
}
batch_command = batch;
-
- return is_gui;
}
* Execute LyX. The startup sequence is as follows:
* -# LyX::exec()
* -# LyX::priv_exec()
- * -# lyx_gui::exec()
+ * -# lyx::createApplication()
* -# LyX::exec2()
- * Step 3 is omitted if no gui is wanted. We need lyx_gui::exec()
+ * Step 3 is omitted if no gui is wanted. We need lyx::createApplication()
* only to create the QApplication object in the qt frontend. All
* attempts with static and dynamically allocated QApplication
* objects lead either to harmless error messages on exit
bool readLanguagesFile(std::string const & name);
/// read the given encodings file
bool readEncodingsFile(std::string const & name);
- /// parsing of non-gui LyX options. Returns true if gui
- bool easyParse(int & argc, char * argv[]);
+ /// parsing of non-gui LyX options.
+ void easyParse(int & argc, char * argv[]);
/// shows up a parsing error on screen
void printError(ErrorItem const &);
#include "exporter.h"
#include "format.h"
#include "funcrequest.h"
+#include "FuncStatus.h"
#include "gettext.h"
#include "importer.h"
#include "insetiterator.h"
#include "frontends/Dialogs.h"
#include "frontends/FileDialog.h"
#include "frontends/FontLoader.h"
-#include "frontends/lyx_gui.h"
#include "frontends/LyXKeySym.h"
#include "frontends/LyXView.h"
#include "frontends/Menubar.h"
// (alkis)
extern tex_accent_struct get_accent(kb_action action);
+namespace lyx {
+extern bool use_gui;
+}
namespace {
boost::tie(view()->cursor().pit(), view()->cursor().pos()) );
// save bookmarks to .lyx/session
view()->saveSavedPositions();
- }
+ }
quitLyX(argument == "force");
break;
break;
}
- lyx_gui::update_color(lcolor.getFromLyXName(lyx_name));
+ theApp->updateColor(lcolor.getFromLyXName(lyx_name));
if (graphicsbg_changed) {
#ifdef WITH_WARNINGS
string const lyxfile = changeExtension(filename, ".lyx");
// Check if the document already is open
- if (lyx_gui::use_gui && theBufferList().exists(lyxfile)) {
+ if (lyx::use_gui && theBufferList().exists(lyxfile)) {
if (!theBufferList().close(theBufferList().getBuffer(lyxfile), true)) {
owner->message(_("Canceled."));
return;
#include "funcrequest.h"
#include "LyXAction.h"
#include "lyxfunc.h"
-#include "frontends/lyx_gui.h"
+#include "frontends/Application.h"
#include "support/lstrings.h"
#include "support/lyxlib.h"
}
if (!write) {
- lyx_gui::register_socket_callback(fd, boost::bind(&LyXComm::read_ready, this));
+ theApp->registerSocketCallback(fd,
+ boost::bind(&LyXComm::read_ready, this));
}
return fd;
return;
if (!write) {
- lyx_gui::unregister_socket_callback(fd);
+ theApp->unregisterSocketCallback(fd);
}
if (::close(fd) < 0) {
#include "LyXAction.h"
#include "lyxfunc.h"
-#include "frontends/lyx_gui.h"
+#include "frontends/Application.h"
#include "support/environment.h"
#include "support/lyxlib.h"
// Needed by lyxclient
lyx::support::setEnv("LYXSOCKET", address_);
- lyx_gui::register_socket_callback(
+ theApp->registerSocketCallback(
fd_,
boost::bind(&LyXServerSocket::serverCallback, this)
);
LyXServerSocket::~LyXServerSocket()
{
if (fd_ != -1) {
- lyx_gui::unregister_socket_callback(fd_);
+ theApp->unregisterSocketCallback(fd_);
if (::close(fd_) != 0)
lyxerr << "lyx: Server socket " << fd_
<< " IO error on closing: " << strerror(errno);
// Register the new client.
clients[client_fd] =
shared_ptr<LyXDataSocket>(new LyXDataSocket(client_fd));
- lyx_gui::register_socket_callback(
+ theApp->registerSocketCallback(
client_fd,
boost::bind(&LyXServerSocket::dataCallback,
this, client_fd)
lyxerr << "lyx: Data socket " << fd_
<< " IO error on closing: " << strerror(errno);
- lyx_gui::unregister_socket_callback(fd_);
+ theApp->unregisterSocketCallback(fd_);
lyxerr[Debug::LYXSERVER] << "lyx: Data socket " << fd_ << " quitting."
<< endl;
}