From d837643c95740c4169ebe3185f1f69c540311928 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Sat, 17 Nov 2007 22:11:11 +0000 Subject: [PATCH] make frontend::Application a bit slimmer git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21657 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/Application.cpp | 79 ---------------------------- src/frontends/Application.h | 4 -- src/frontends/Makefile.am | 1 - src/frontends/qt4/GuiApplication.cpp | 57 ++++++++++++++++++++ src/frontends/qt4/GuiApplication.h | 3 -- 5 files changed, 57 insertions(+), 87 deletions(-) delete mode 100644 src/frontends/Application.cpp diff --git a/src/frontends/Application.cpp b/src/frontends/Application.cpp deleted file mode 100644 index c62bf8d584..0000000000 --- a/src/frontends/Application.cpp +++ /dev/null @@ -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 - -#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 diff --git a/src/frontends/Application.h b/src/frontends/Application.h index 28e74f10c8..858bf3e77d 100644 --- a/src/frontends/Application.h +++ b/src/frontends/Application.h @@ -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. diff --git a/src/frontends/Makefile.am b/src/frontends/Makefile.am index 5c6cf8e727..baeaedf1bb 100644 --- a/src/frontends/Makefile.am +++ b/src/frontends/Makefile.am @@ -10,7 +10,6 @@ AM_CPPFLAGS += -I$(srcdir)/.. $(BOOST_INCLUDES) liblyxfrontends_la_SOURCES = \ alert.h \ - Application.cpp \ Application.h \ NoGuiFontLoader.h \ NoGuiFontMetrics.h \ diff --git a/src/frontends/qt4/GuiApplication.cpp b/src/frontends/qt4/GuiApplication.cpp index 6edfdd7c88..08817607a7 100644 --- a/src/frontends/qt4/GuiApplication.cpp +++ b/src/frontends/qt4/GuiApplication.cpp @@ -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" diff --git a/src/frontends/qt4/GuiApplication.h b/src/frontends/qt4/GuiApplication.h index 702051d380..c7e8f4f5a9 100644 --- a/src/frontends/qt4/GuiApplication.h +++ b/src/frontends/qt4/GuiApplication.h @@ -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 { -- 2.39.5