]> git.lyx.org Git - features.git/commitdiff
This commit creates a new "frontends/lyx_gui.C" that contains all functions that...
authorAbdelrazak Younes <younes@lyx.org>
Tue, 3 Oct 2006 10:34:10 +0000 (10:34 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Tue, 3 Oct 2006 10:34:10 +0000 (10:34 +0000)
virtual std::string const romanFontName() = 0;
virtual std::string const sansFontName() = 0;
virtual std::string const typewriterFontName() = 0;

My goal is to transfer all of "frontends/*/lyx_gui.C" to "frontends/lyx_gui.C". When this is done, "frontends/lyx_gui.C" can go altogether as its functions will then be replaced with direct calls to theApp->XXX().

* frontends/lyx_gui.C: new file with code transfered from [qt3,qt4,gtk]/lyx_gui.C

* frontends/Application: 3 new font related pure virtual methods

* [qt3,qt4,gtk]/GuiApplication: implement the above method with code transfered from lyx_gui.C

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15208 a592a061-630c-0410-9148-cb99ea01b6c8

13 files changed:
development/scons/scons_manifest.py
src/frontends/Application.h
src/frontends/Makefile.am
src/frontends/gtk/GuiApplication.C
src/frontends/gtk/GuiApplication.h
src/frontends/gtk/lyx_gui.C
src/frontends/lyx_gui.C [new file with mode: 0644]
src/frontends/qt3/GuiApplication.C
src/frontends/qt3/GuiApplication.h
src/frontends/qt3/lyx_gui.C
src/frontends/qt4/GuiApplication.C
src/frontends/qt4/GuiApplication.h
src/frontends/qt4/lyx_gui.C

index e7aaf9671f5190f3607bb231a2c881186bbbfc09..f4af24b58179bc594a347cb31d18ff9afb9f13e7 100644 (file)
@@ -461,6 +461,7 @@ src_frontends_files = Split('''
     Toolbars.C
     WorkArea.C
     guiapi.C
+    lyx_gui.C
     nullpainter.C
 ''')
 
index 50dd994a0b016abd29c8f50b6ad29f488bbe41e6..a141bf54d45e6d99e2949ae5b5c2da5fe7fb86e0 100644 (file)
@@ -59,6 +59,15 @@ public:
        ///
        virtual Selection & selection() = 0;
 
+       /// return a suitable serif font name.
+       virtual std::string const romanFontName() = 0;
+
+       /// return a suitable sans serif font name.
+       virtual std::string const sansFontName() = 0;
+
+       /// return a suitable monospaced font name.
+       virtual std::string const typewriterFontName() = 0;
+
        ///
        LyXFunc & lyxFunc();
        LyXFunc const & lyxFunc() const;
index fd9d691e931ab2c7003feb448efc6fa971639143..4ca77284f3eaf28059241e69171ff820e0e8a86d 100644 (file)
@@ -41,6 +41,7 @@ libfrontends_la_SOURCES = \
        guiapi.h \
        guiapi.C \
        key_state.h \
+       lyx_gui.C \
        lyx_gui.h \
        mouse_state.h \
        nullpainter.C \
index 5877d15ef39f5d65883874eeddcb08c536789062..431fec949138551b1cc01183e83be43b244a5ff5 100644 (file)
@@ -104,5 +104,23 @@ void GuiApplication::exit(int /*status*/)
 }
 
 
+string const GuiApplication::romanFontName()
+{
+       return "times";
+}
+
+
+string const GuiApplication::sansFontName()
+{
+       return "helvetica";
+}
+
+
+string const GuiApplication::typewriterFontName()
+{
+       return "courier";
+}
+
+
 } // namespace frontend
 } // namespace lyx
index 606ed23324ebd864ca8b36203efec43efe2f34b2..6526729786666b0591ce502af42f406a186ee9a7 100644 (file)
@@ -43,6 +43,8 @@ class GuiApplication : public Gtk::Main, public Application
 {
 public:
        GuiApplication(int & argc, char ** argv);
+       ///
+       virtual ~GuiApplication() {}
 
        /// Method inherited from \c Application class
        //@{
@@ -51,6 +53,9 @@ public:
        virtual int const exec();
        virtual Gui & gui() { return gui_; }
        virtual void exit(int status);
+       virtual std::string const romanFontName();
+       virtual std::string const sansFontName();
+       virtual std::string const typewriterFontName();
        //@}
 
        ///
index 23d3de2c878fbbf317217222d57df5192350571b..3de8d1872a4ca0e7567c51da4d9d6adfe2fcdcae 100644 (file)
@@ -79,8 +79,6 @@ using lyx::frontend::GuiImplementation;
 using lyx::frontend::GView;
 
 
-bool lyx_gui::use_gui = true;
-
 namespace {
 
 /// estimate DPI from X server
@@ -94,7 +92,6 @@ int getDPI()
 
 } // namespace anon
 
-lyx::frontend::Application * theApp;
 GuiApplication * guiApp;
 
 int lyx_gui::exec(int & argc, char * argv[])
@@ -106,45 +103,12 @@ int lyx_gui::exec(int & argc, char * argv[])
 }
 
 
-void lyx_gui::parse_lyxrc()
-{
-}
-
-
-LyXView * lyx_gui::create_view(unsigned int width, unsigned int height,
-               int posx, int posy, bool maximize)
-{
-       return &guiApp->createView(width, height, posx, posy, maximize);
-}
-
-
-int lyx_gui::start(LyXView *, string const & batch)
-{
-       return guiApp->start(batch);
-}
-
-
 void lyx_gui::exit(int status)
 {
        guiApp->exit(status);
 }
 
 
-FuncStatus lyx_gui::getStatus(FuncRequest const & ev)
-{
-       FuncStatus flag;
-       switch (ev.action) {
-       case LFUN_TOOLTIPS_TOGGLE:
-               flag.unknown(true);
-               break;
-       default:
-               break;
-       }
-
-       return flag;
-}
-
-
 bool lyx_gui::getRGBColor(LColor_color col, lyx::RGBColor & rgbcol)
 {
        Gdk::Color gdkColor;
@@ -226,24 +190,6 @@ void lyx_gui::unregister_socket_callback(int fd)
 }
 
 
-string const lyx_gui::roman_font_name()
-{
-       return "times";
-}
-
-
-string const lyx_gui::sans_font_name()
-{
-       return "helvetica";
-}
-
-
-string const lyx_gui::typewriter_font_name()
-{
-       return "courier";
-}
-
-
 void lyx_gui::sync_events()
 {
        // FIXME
diff --git a/src/frontends/lyx_gui.C b/src/frontends/lyx_gui.C
new file mode 100644 (file)
index 0000000..9dd95c0
--- /dev/null
@@ -0,0 +1,88 @@
+/**
+ * \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 "LyXView.h"
+#include "Application.h"
+
+#include "funcrequest.h"
+
+using std::string;
+
+lyx::frontend::Application * theApp;
+
+
+namespace lyx_gui {
+
+bool use_gui = true;
+
+void parse_lyxrc()
+{}
+
+
+LyXView * create_view(unsigned int width, unsigned int height, int posx, int posy,
+          bool maximize)
+{
+       return &theApp->createView(width, height, posx, posy, maximize);
+}
+
+
+int start(LyXView * view, string const & batch)
+{
+       return theApp->start(batch);
+}
+
+
+FuncStatus getStatus(FuncRequest const & ev)
+{
+       FuncStatus flag;
+       switch (ev.action) {
+       case LFUN_TOOLTIPS_TOGGLE:
+               flag.unknown(true);
+               break;
+       default:
+               break;
+       }
+
+       return flag;
+}
+
+
+string const roman_font_name()
+{
+       if (!use_gui)
+               return "serif";
+
+       return theApp->romanFontName();
+}
+
+
+string const sans_font_name()
+{
+       if (!use_gui)
+               return "sans";
+
+       return theApp->sansFontName();
+}
+
+
+string const typewriter_font_name()
+{
+       if (!use_gui)
+               return "monospace";
+
+       return theApp->typewriterFontName();
+}
+
+}; // namespace lyx_gui
index 0c99d689309e97ed863cb77976303b11e75c7f33..0b4e13fc470212176b7a438a4c25b499a598d859 100644 (file)
@@ -161,6 +161,36 @@ void GuiApplication::exit(int status)
 }
 
 
+string const GuiApplication::romanFontName()
+{
+       QFont font;
+       font.setStyleHint(QFont::Serif);
+       font.setFamily("serif");
+
+       return fromqstr(QFontInfo(font).family());
+}
+
+
+string const GuiApplication::sansFontName()
+{
+       QFont font;
+       font.setStyleHint(QFont::SansSerif);
+       font.setFamily("sans");
+
+       return fromqstr(QFontInfo(font).family());
+}
+
+
+string const GuiApplication::typewriterFontName()
+{
+       QFont font;
+       font.setStyleHint(QFont::TypeWriter);
+       font.setFamily("monospace");
+
+       return fromqstr(QFontInfo(font).family());
+}
+
+
 ////////////////////////////////////////////////////////////////////////
 // X11 specific stuff goes here...
 #ifdef Q_WS_X11
index 066d45c2c93c4950918afd82cf9c7d9c578195db..d56e057c5d14f7d7955fa5d107c0ece2517a5137 100644 (file)
@@ -49,6 +49,8 @@ class GuiApplication : public QApplication, public Application
 {
 public:
        GuiApplication(int & argc, char ** argv);
+       ///
+       virtual ~GuiApplication() {}
 
        /// Method inherited from \c Application class
        //@{
@@ -57,6 +59,9 @@ public:
        virtual int const exec();
        virtual Gui & gui() { return gui_; }
        virtual void exit(int status);
+       virtual std::string const romanFontName();
+       virtual std::string const sansFontName();
+       virtual std::string const typewriterFontName();
        //@}
 
        ///
index 4be85e78e36777a600f8dbd4124dc7444ba6e0aa..0bf68e8be5ff883b1e2011b7ae88cd272197fde1 100644 (file)
@@ -85,14 +85,10 @@ map<int, shared_ptr<socket_callback> > socket_callbacks;
 } // namespace anon
 
 
-lyx::frontend::Application * theApp;
 GuiApplication * guiApp;
 
 namespace lyx_gui {
 
-bool use_gui = true;
-
-
 int exec(int & argc, char * argv[])
 {
        GuiApplication app(argc, argv);
@@ -104,23 +100,6 @@ int exec(int & argc, char * argv[])
 }
 
 
-void parse_lyxrc()
-{}
-
-
-LyXView* create_view(unsigned int width, unsigned int height, int posx, int posy,
-             bool maximize)
-{
-       return &guiApp->createView(width, height, posx, posy, maximize);
-}
-
-
-int start(LyXView *, string const & batch)
-{
-       return theApp->start(batch);
-}
-
-
 void sync_events()
 {
        // This is the ONLY place where processEvents may be called.
@@ -139,21 +118,6 @@ void exit(int status)
 }
 
 
-FuncStatus getStatus(FuncRequest const & ev)
-{
-       FuncStatus flag;
-       switch (ev.action) {
-       case LFUN_TOOLTIPS_TOGGLE:
-               flag.unknown(true);
-               break;
-       default:
-               break;
-       }
-
-       return flag;
-}
-
-
 bool getRGBColor(LColor_color col, lyx::RGBColor & rgbcol)
 {
        QColor const & qcol = lcolorcache.get(col);
@@ -206,43 +170,4 @@ void unregister_socket_callback(int fd)
        socket_callbacks.erase(fd);
 }
 
-
-string const roman_font_name()
-{
-       if (!use_gui)
-               return "serif";
-
-       QFont font;
-       font.setStyleHint(QFont::Serif);
-       font.setFamily("serif");
-
-       return fromqstr(QFontInfo(font).family());
-}
-
-
-string const sans_font_name()
-{
-       if (!use_gui)
-               return "sans";
-
-       QFont font;
-       font.setStyleHint(QFont::SansSerif);
-       font.setFamily("sans");
-
-       return fromqstr(QFontInfo(font).family());
-}
-
-
-string const typewriter_font_name()
-{
-       if (!use_gui)
-               return "monospace";
-
-       QFont font;
-       font.setStyleHint(QFont::TypeWriter);
-       font.setFamily("monospace");
-
-       return fromqstr(QFontInfo(font).family());
-}
-
 }; // namespace lyx_gui
index f9da2648fd72060c6931f042707880514856acdd..147238249f889ce5e5e6eb04884588bd38847f43 100644 (file)
@@ -159,6 +159,34 @@ void GuiApplication::exit(int status)
 }
 
 
+string const GuiApplication::romanFontName()
+{
+       QFont font;
+       font.setStyleHint(QFont::Serif);
+       font.setFamily("serif");
+
+       return fromqstr(QFontInfo(font).family());
+}
+
+
+string const GuiApplication::sansFontName()
+{
+       QFont font;
+       font.setStyleHint(QFont::SansSerif);
+       font.setFamily("sans");
+
+       return fromqstr(QFontInfo(font).family());
+}
+
+
+string const GuiApplication::typewriterFontName()
+{
+       QFont font;
+       font.setStyleHint(QFont::TypeWriter);
+       font.setFamily("monospace");
+
+       return fromqstr(QFontInfo(font).family());
+}
 
 
 ////////////////////////////////////////////////////////////////////////
index 8bc3b978157c413ab75985761dc00f46452b70af..82334a8d130fcd7c85392db96fb1ccf928a2d264 100644 (file)
@@ -50,6 +50,8 @@ class GuiApplication : public QApplication, public Application
 {
 public:
        GuiApplication(int & argc, char ** argv);
+       ///
+       virtual ~GuiApplication() {}
 
        /// Method inherited from \c Application class
        //@{
@@ -58,6 +60,9 @@ public:
        virtual int const exec();
        virtual Gui & gui() { return gui_; }
        virtual void exit(int status);
+       virtual std::string const romanFontName();
+       virtual std::string const sansFontName();
+       virtual std::string const typewriterFontName();
        //@}
 
        ///
index 8192332dd35b2b70b86f1382802d25eea42c4383..838bea46f13186fc1208a5b1676440cb2c4ad57d 100644 (file)
@@ -26,7 +26,6 @@
 
 #include "support/lstrings.h"
 
-
 #include "GuiView.h"
 #include "QLImage.h"
 #include "qt_helpers.h"
@@ -61,8 +60,6 @@ using std::vector;
 using std::string;
 
 lyx::frontend::GuiApplication * guiApp;
-lyx::frontend::Application * theApp;
-
 
 namespace {
 
@@ -72,8 +69,6 @@ map<int, shared_ptr<socket_callback> > socket_callbacks;
 
 namespace lyx_gui {
 
-bool use_gui = true;
-
 int exec(int & argc, char * argv[])
 {
        /*
@@ -110,23 +105,6 @@ int exec(int & argc, char * argv[])
 }
 
 
-void parse_lyxrc()
-{}
-
-
-LyXView * create_view(unsigned int width, unsigned int height, int posx, int posy,
-          bool maximize)
-{
-       return &guiApp->createView(width, height, posx, posy, maximize);
-}
-
-
-int start(LyXView * view, string const & batch)
-{
-       return theApp->start(batch);
-}
-
-
 void sync_events()
 {
        // This is the ONLY place where processEvents may be called.
@@ -143,21 +121,6 @@ void exit(int status)
 }
 
 
-FuncStatus getStatus(FuncRequest const & ev)
-{
-       FuncStatus flag;
-       switch (ev.action) {
-       case LFUN_TOOLTIPS_TOGGLE:
-               flag.unknown(true);
-               break;
-       default:
-               break;
-       }
-
-       return flag;
-}
-
-
 bool getRGBColor(LColor_color col, lyx::RGBColor & rgbcol)
 {
        QColor const & qcol = guiApp->colorCache().get(col);
@@ -210,43 +173,4 @@ void unregister_socket_callback(int fd)
        socket_callbacks.erase(fd);
 }
 
-
-string const roman_font_name()
-{
-       if (!use_gui)
-               return "serif";
-
-       QFont font;
-       font.setStyleHint(QFont::Serif);
-       font.setFamily("serif");
-
-       return fromqstr(QFontInfo(font).family());
-}
-
-
-string const sans_font_name()
-{
-       if (!use_gui)
-               return "sans";
-
-       QFont font;
-       font.setStyleHint(QFont::SansSerif);
-       font.setFamily("sans");
-
-       return fromqstr(QFontInfo(font).family());
-}
-
-
-string const typewriter_font_name()
-{
-       if (!use_gui)
-               return "monospace";
-
-       QFont font;
-       font.setStyleHint(QFont::TypeWriter);
-       font.setFamily("monospace");
-
-       return fromqstr(QFontInfo(font).family());
-}
-
 }; // namespace lyx_gui