]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/Application.C
This commit saves the need to check for lyx::use_gui in a number of places.
[lyx.git] / src / frontends / Application.C
index 66fcbfbd7c280bda1f329a85594253b5a8fb29ba..741099670b38a284884e315cceacbc43f05cd395 100644 (file)
 
 #include <config.h>
 
-#include "Application.h"
+#include "frontends/Application.h"
 
-#include "Gui.h"
-#include "LyXView.h"
-#include "WorkArea.h"
+#include "frontends/NoGuiFontLoader.h"
+#include "frontends/NoGuiFontMetrics.h"
+#include "frontends/FontLoader.h"
+#include "frontends/FontMetrics.h"
+#include "frontends/Gui.h"
+#include "frontends/LyXView.h"
+#include "frontends/WorkArea.h"
 
 #include "bufferlist.h"
 #include "funcrequest.h"
+#include "FuncStatus.h"
+#include "lyx_main.h"
 #include "LyXAction.h"
+#include "lyxfont.h"
 #include "lyxfunc.h"
 #include "lyxrc.h"
 #include "lyxserver.h"
@@ -28,6 +35,8 @@
 #include "support/os.h"
 #include "support/package.h"
 
+#include <boost/scoped_ptr.hpp>
+#include <boost/shared_ptr.hpp>
 
 using lyx::support::package;
 
@@ -37,8 +46,6 @@ namespace frontend {
 /// The main application class private implementation.
 struct Application_pimpl 
 {
-       ///
-       BufferList buffer_list_;
        /// our function handler
        boost::scoped_ptr<LyXFunc> lyxfunc_;
        ///
@@ -90,18 +97,6 @@ LyXServerSocket const & Application::socket() const
 }
 
 
-BufferList & Application::bufferList()
-{
-       return pimpl_->buffer_list_;
-}
-
-
-BufferList const & Application::bufferList() const
-{
-       return pimpl_->buffer_list_;
-}
-
-
 void Application::setBufferView(BufferView * buffer_view)
 {
        buffer_view_ = buffer_view;
@@ -119,7 +114,7 @@ LyXView & Application::createView(unsigned int width,
        // this can't be done before because it needs the Languages object
        //initEncodings();
 
-       int view_id = gui().newView(width, height);
+       int view_id = gui().newView();
        LyXView & view = gui().view(view_id);
 
        pimpl_->lyxfunc_.reset(new LyXFunc(&view));
@@ -149,6 +144,64 @@ int Application::start(std::string const & batch)
        return exec();
 }
 
-
 } // namespace frontend
+
+
+FuncStatus getStatus(FuncRequest const & action)
+{
+       return theApp->lyxFunc().getStatus(action);
+}
+
+
+void dispatch(FuncRequest const & action)
+{
+       theApp->lyxFunc().dispatch(action);
+}
+
 } // namespace lyx
+
+
+LyXFunc & theLyXFunc()
+{
+       BOOST_ASSERT(theApp);
+       return theApp->lyxFunc();
+}
+
+
+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);
+}
+
+
+lyx::frontend::Clipboard & theClipboard()
+{
+       BOOST_ASSERT(theApp);
+       return theApp->clipboard();
+}
+
+
+lyx::frontend::Selection & theSelection()
+{
+       BOOST_ASSERT(theApp);
+       return theApp->selection();
+}
+