]> git.lyx.org Git - lyx.git/blob - src/frontends/Application.C
This commit transfers the singletons defined in the Application class to the private...
[lyx.git] / src / frontends / Application.C
1 /**
2  * \file frontend/Application.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Abdelrazak Younes
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "frontends/Application.h"
14
15 #include "frontends/NoGuiFontLoader.h"
16 #include "frontends/NoGuiFontMetrics.h"
17 #include "frontends/FontLoader.h"
18 #include "frontends/FontMetrics.h"
19 #include "frontends/Gui.h"
20 #include "frontends/LyXView.h"
21 #include "frontends/WorkArea.h"
22
23 #include "funcrequest.h"
24 #include "FuncStatus.h"
25 #include "lyx_main.h"
26 #include "lyxfont.h"
27 #include "lyxfunc.h"
28 #include "lyxrc.h"
29
30 #include "support/lstrings.h"
31 #include "support/os.h"
32 #include "support/package.h"
33
34 #include <boost/scoped_ptr.hpp>
35 #include <boost/shared_ptr.hpp>
36
37 using lyx::support::package;
38
39 namespace lyx {
40 namespace frontend {
41
42
43 Application::Application(int &, char **)
44 {
45 }
46
47
48 void Application::setBufferView(BufferView * buffer_view)
49 {
50         buffer_view_ = buffer_view;
51 }
52
53
54 LyXView & Application::createView(unsigned int width,
55                                                                   unsigned int height,
56                                                                   int posx, int posy,
57                                                                   bool maximize)
58 {
59         // FIXME: please confirm: with unicode, I think initEncoding()
60         // is not needed anymore!
61         
62         // this can't be done before because it needs the Languages object
63         //initEncodings();
64
65         int view_id = gui().newView();
66         LyXView & view = gui().view(view_id);
67
68         theLyXFunc().setLyXView(&view);
69
70         // FIXME: for now we assume that there is only one LyXView with id = 0.
71         /*int workArea_id_ =*/ gui().newWorkArea(width, height, 0);
72         //WorkArea * workArea_ = & theApp->gui().workArea(workArea_id_);
73
74         view.init();
75         view.setGeometry(width, height, posx, posy, maximize);
76
77         return view;
78 }
79
80
81 int Application::start(std::string const & batch)
82 {
83         return exec();
84 }
85
86 } // namespace frontend
87 } // namespace lyx
88
89
90 lyx::frontend::FontLoader & theFontLoader()
91 {
92         static lyx::frontend::NoGuiFontLoader no_gui_font_loader;
93
94         if (!lyx::use_gui)
95                 return no_gui_font_loader;
96
97         BOOST_ASSERT(theApp);
98         return theApp->fontLoader();
99 }
100
101
102 lyx::frontend::FontMetrics const & theFontMetrics(LyXFont const & f)
103 {
104         static lyx::frontend::NoGuiFontMetrics no_gui_font_metrics;
105
106         if (!lyx::use_gui)
107                 return no_gui_font_metrics;
108
109         BOOST_ASSERT(theApp);
110         return theApp->fontLoader().metrics(f);
111 }
112
113
114 lyx::frontend::Clipboard & theClipboard()
115 {
116         BOOST_ASSERT(theApp);
117         return theApp->clipboard();
118 }
119
120
121 lyx::frontend::Selection & theSelection()
122 {
123         BOOST_ASSERT(theApp);
124         return theApp->selection();
125 }
126