make frontend::Application a bit slimmer

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21657 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2007-11-17 22:11:11 +00:00
parent 1005c166c2
commit d837643c95
5 changed files with 57 additions and 87 deletions

View File

@ -1,79 +0,0 @@
/**
* \file frontend/Application.cpp
* 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.
*/
#include <config.h>
#include "frontends/Application.h"
#include "frontends/NoGuiFontLoader.h"
#include "frontends/NoGuiFontMetrics.h"
#include "frontends/FontLoader.h"
#include "frontends/FontMetrics.h"
#include "frontends/LyXView.h"
#include "FuncRequest.h"
#include "FuncStatus.h"
#include "LyX.h" // for lyx::use_gui
#include "Font.h"
#include "LyXFunc.h"
#include "LyXRC.h"
#include "support/lstrings.h"
#include "support/os.h"
namespace lyx {
frontend::FontLoader & theFontLoader()
{
static frontend::NoGuiFontLoader no_gui_font_loader;
if (!use_gui)
return no_gui_font_loader;
BOOST_ASSERT(theApp());
return theApp()->fontLoader();
}
frontend::FontMetrics const & theFontMetrics(Font const & f)
{
return theFontMetrics(f.fontInfo());
}
frontend::FontMetrics const & theFontMetrics(FontInfo const & f)
{
static frontend::NoGuiFontMetrics no_gui_font_metrics;
if (!use_gui)
return no_gui_font_metrics;
BOOST_ASSERT(theApp());
return theApp()->fontLoader().metrics(f);
}
frontend::Clipboard & theClipboard()
{
BOOST_ASSERT(theApp());
return theApp()->clipboard();
}
frontend::Selection & theSelection()
{
BOOST_ASSERT(theApp());
return theApp()->selection();
}
} // namespace lyx

View File

@ -187,10 +187,6 @@ public:
*/
virtual void syncEvents() = 0;
///
virtual Clipboard & clipboard() = 0;
///
virtual Selection & selection() = 0;
///
virtual FontLoader & fontLoader() = 0;
/// return a suitable serif font name.

View File

@ -10,7 +10,6 @@ AM_CPPFLAGS += -I$(srcdir)/.. $(BOOST_INCLUDES)
liblyxfrontends_la_SOURCES = \
alert.h \
Application.cpp \
Application.h \
NoGuiFontLoader.h \
NoGuiFontMetrics.h \

View File

@ -20,6 +20,11 @@
#include "Dialogs.h"
#include "frontends/alert.h"
#include "frontends/Application.h"
#include "frontends/NoGuiFontLoader.h"
#include "frontends/NoGuiFontMetrics.h"
#include "frontends/FontLoader.h"
#include "frontends/FontMetrics.h"
#include "graphics/LoaderQueue.h"
@ -32,6 +37,7 @@
#include "BufferList.h"
#include "BufferView.h"
#include "debug.h"
#include "Font.h"
#include "FuncRequest.h"
#include "gettext.h"
#include "LyX.h"
@ -563,6 +569,57 @@ bool GuiApplication::x11EventFilter(XEvent * xev)
#endif
} // namespace frontend
////////////////////////////////////////////////////////////////////
//
// Font stuff
//
////////////////////////////////////////////////////////////////////
frontend::FontLoader & theFontLoader()
{
static frontend::NoGuiFontLoader no_gui_font_loader;
if (!use_gui)
return no_gui_font_loader;
BOOST_ASSERT(theApp());
return theApp()->fontLoader();
}
frontend::FontMetrics const & theFontMetrics(Font const & f)
{
return theFontMetrics(f.fontInfo());
}
frontend::FontMetrics const & theFontMetrics(FontInfo const & f)
{
static frontend::NoGuiFontMetrics no_gui_font_metrics;
if (!use_gui)
return no_gui_font_metrics;
BOOST_ASSERT(theApp());
return theApp()->fontLoader().metrics(f);
}
frontend::Clipboard & theClipboard()
{
BOOST_ASSERT(frontend::guiApp);
return frontend::guiApp->clipboard();
}
frontend::Selection & theSelection()
{
BOOST_ASSERT(frontend::guiApp);
return frontend::guiApp->selection();
}
} // namespace lyx
#include "GuiApplication_moc.cpp"

View File

@ -43,9 +43,6 @@ class SocketNotifier;
/**
There should be only one instance of this class. No Qt object
initialisation should be done before the instanciation of this class.
\todo The work areas handling could be moved to a base virtual class
comon to all frontends.
*/
class GuiApplication : public QApplication, public Application
{