]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/Application.C
* src/frontends/qt4/GuiSelection.C
[lyx.git] / src / frontends / Application.C
index 22417f7ed605b2f9f19b56e6cb3c5fe5dc5f8a6d..35eeaa9418dcf26bedfec3180d63a32eed2263d0 100644 (file)
 
 #include <config.h>
 
-#include "Application.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 "LyXAction.h"
+#include "FuncStatus.h"
+#include "lyx_main.h"  // for lyx::use_gui
+#include "lyxfont.h"
+#include "lyxfunc.h"
 #include "lyxrc.h"
-#include "LyXView.h"
 
 #include "support/lstrings.h"
 #include "support/os.h"
-#include "support/package.h"
 
 #include <boost/scoped_ptr.hpp>
+#include <boost/shared_ptr.hpp>
 
-using lyx::support::package;
 
 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();
 }
 
 
-LyXFunc & Application::lyxFunc()
+LyXView & Application::createView(unsigned int width,
+                                 unsigned int height,
+                                 int posx, int posy,
+                                 bool maximize,
+                                 unsigned int iconSizeXY,
+                                 const std::string & geometryArg)
 {
-       return *lyxfunc_.get(); 
-}
+       LyXView & view = gui().createRegisteredView();
+       int view_id = view.id();
+       
+       theLyXFunc().setLyXView(&view);
 
+       /*int workArea_id_ =*/ gui().newWorkArea(width, height, view_id);
 
-LyXFunc const & Application::lyxFunc() const
-{
-       return *lyxfunc_.get(); 
-}
+       view.init();
+       view.setGeometry(width, height, posx, posy, maximize, iconSizeXY, geometryArg);
+       view.setFocus();
 
+       setCurrentView(view);
 
-LyXServer & Application::server()
-{
-       return *lyx_server_.get(); 
+       return view;
 }
 
 
-LyXServer const & Application::server() const 
+LyXView const * Application::currentView() const
 {
-       return *lyx_server_.get(); 
+       return current_view_;
 }
 
 
-LyXServerSocket & Application::socket()
+LyXView * Application::currentView()
 {
-       return *lyx_socket_.get();
+       return current_view_;
 }
 
 
-LyXServerSocket const & Application::socket() const
+void Application::setCurrentView(LyXView & current_view)
 {
-       return *lyx_socket_.get();
+       current_view_ = &current_view;
 }
 
+} // namespace frontend
 
-BufferList & Application::bufferList()
-{
-       return buffer_list_;
-}
 
 
-BufferList const & Application::bufferList() const
+frontend::FontLoader & theFontLoader()
 {
-       return buffer_list_;
+       static frontend::NoGuiFontLoader no_gui_font_loader;
+
+       if (!use_gui)
+               return no_gui_font_loader;
+
+       BOOST_ASSERT(theApp());
+       return theApp()->fontLoader();
 }
 
 
-void Application::setBufferView(BufferView * buffer_view)
+frontend::FontMetrics const & theFontMetrics(LyXFont const & f)
 {
-       buffer_view_ = buffer_view;
+       static frontend::NoGuiFontMetrics no_gui_font_metrics;
+
+       if (!use_gui)
+               return no_gui_font_metrics;
+
+       BOOST_ASSERT(theApp());
+       return theApp()->fontLoader().metrics(f);
 }
 
 
-int Application::start(std::string const & batch)
+frontend::Clipboard & theClipboard()
 {
-       lyx_server_.reset(new LyXServer(lyxfunc_.get(), lyxrc.lyxpipes));
-       lyx_socket_.reset(new LyXServerSocket(lyxfunc_.get(), 
-               lyx::support::os::internal_path(package().temp_dir() + "/lyxsocket")));
+       BOOST_ASSERT(theApp());
+       return theApp()->clipboard();
+}
 
-       // handle the batch commands the user asked for
-       if (!batch.empty()) {
-               lyxfunc_->dispatch(lyxaction.lookupFunc(batch));
-       }
 
-       return exec();
+frontend::Selection & theSelection()
+{
+       BOOST_ASSERT(theApp());
+       return theApp()->selection();
 }
 
 
-} // namespace frontend
 } // namespace lyx