]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/Application.C
* src/frontends/qt4/GuiSelection.C
[lyx.git] / src / frontends / Application.C
index d590e9d67883e33e1cb2d921511559813f228dd7..35eeaa9418dcf26bedfec3180d63a32eed2263d0 100644 (file)
-/**\r
- * \file frontend/Application.C\r
- * This file is part of LyX, the document processor.\r
- * Licence details can be found in the file COPYING.\r
- *\r
- * \author Abdelrazak Younes\r
- *\r
- * Full author contact details are available in file CREDITS.\r
- */\r
-\r
-#include <config.h>\r
-\r
-#include "Application.h"\r
-\r
-#include "funcrequest.h"\r
-#include "LyXAction.h"\r
-#include "lyxrc.h"\r
-#include "LyXView.h"\r
-\r
-#include "support/lstrings.h"\r
-#include "support/os.h"\r
-#include "support/package.h"\r
-\r
-#include <boost/scoped_ptr.hpp>\r
-\r
-using lyx::support::package;\r
-\r
-// FIXME: replace all occurence of lyxserver with theApp->server().\r
-LyXServer * lyxserver;\r
-// FIXME: replace all occurence of lyxsocket with theApp->socket().\r
-LyXServerSocket * lyxsocket;\r
-\r
-namespace lyx {\r
-namespace frontend {\r
-\r
-\r
-Application::Application(int & argc, char ** argv)\r
-{\r
-}\r
-\r
-\r
-LyXFunc & Application::lyxFunc()\r
-{\r
-       return *lyxfunc_.get(); \r
-}\r
-\r
-\r
-LyXFunc const & Application::lyxFunc() const\r
-{\r
-       return *lyxfunc_.get(); \r
-}\r
-\r
-\r
-LyXServer & Application::server()\r
-{\r
-       return *lyx_server_.get(); \r
-}\r
-\r
-\r
-LyXServer const & Application::server() const \r
-{\r
-       return *lyx_server_.get(); \r
-}\r
-\r
-\r
-LyXServerSocket & Application::socket()\r
-{\r
-       return *lyx_socket_.get();\r
-}\r
-\r
-\r
-LyXServerSocket const & Application::socket() const\r
-{\r
-       return *lyx_socket_.get();\r
-}\r
-\r
-\r
-void Application::setBufferView(BufferView * buffer_view)\r
-{\r
-       buffer_view_ = buffer_view;\r
-}\r
-\r
-\r
-int Application::start(std::string const & batch)\r
-{\r
-       lyx_server_.reset(new LyXServer(lyxfunc_.get(), lyxrc.lyxpipes));\r
-       lyx_socket_.reset(new LyXServerSocket(lyxfunc_.get(), \r
-               lyx::support::os::internal_path(package().temp_dir() + "/lyxsocket")));\r
-\r
-       // FIXME: these two lines should disappear soon (Abdel 20/09/71)\r
-       lyxserver = lyx_server_.get();\r
-       lyxsocket = lyx_socket_.get();\r
-\r
-       // handle the batch commands the user asked for\r
-       if (!batch.empty()) {\r
-               lyxfunc_->dispatch(lyxaction.lookupFunc(batch));\r
-       }\r
-\r
-       return exec();\r
-}\r
-\r
-\r
-} // namespace frontend\r
-} // namespace lyx\r
+/**
+ * \file frontend/Application.C
+ * 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/Gui.h"
+#include "frontends/LyXView.h"
+#include "frontends/WorkArea.h"
+
+#include "funcrequest.h"
+#include "FuncStatus.h"
+#include "lyx_main.h"  // for lyx::use_gui
+#include "lyxfont.h"
+#include "lyxfunc.h"
+#include "lyxrc.h"
+
+#include "support/lstrings.h"
+#include "support/os.h"
+
+#include <boost/scoped_ptr.hpp>
+#include <boost/shared_ptr.hpp>
+
+
+namespace lyx {
+namespace frontend {
+
+
+Application::Application(int &, char **)
+       : current_view_(0)
+{
+       // FIXME: please confirm: with unicode, I think initEncoding()
+       // is not needed anymore!
+       
+       // this can't be done before because it needs the Languages object
+       //initEncodings();
+}
+
+
+LyXView & Application::createView(unsigned int width,
+                                 unsigned int height,
+                                 int posx, int posy,
+                                 bool maximize,
+                                 unsigned int iconSizeXY,
+                                 const std::string & geometryArg)
+{
+       LyXView & view = gui().createRegisteredView();
+       int view_id = view.id();
+       
+       theLyXFunc().setLyXView(&view);
+
+       /*int workArea_id_ =*/ gui().newWorkArea(width, height, view_id);
+
+       view.init();
+       view.setGeometry(width, height, posx, posy, maximize, iconSizeXY, geometryArg);
+       view.setFocus();
+
+       setCurrentView(view);
+
+       return view;
+}
+
+
+LyXView const * Application::currentView() const
+{
+       return current_view_;
+}
+
+
+LyXView * Application::currentView()
+{
+       return current_view_;
+}
+
+
+void Application::setCurrentView(LyXView & current_view)
+{
+       current_view_ = &current_view;
+}
+
+} // namespace frontend
+
+
+
+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(LyXFont 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