]> git.lyx.org Git - lyx.git/blob - src/frontends/Application.C
move everything into namespace lyx
[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
33 #include <boost/scoped_ptr.hpp>
34 #include <boost/shared_ptr.hpp>
35
36
37 namespace lyx {
38 namespace frontend {
39
40
41 Application::Application(int &, char **)
42 {
43         // FIXME: please confirm: with unicode, I think initEncoding()
44         // is not needed anymore!
45         
46         // this can't be done before because it needs the Languages object
47         //initEncodings();
48 }
49
50
51 void Application::setBufferView(BufferView * buffer_view)
52 {
53         buffer_view_ = buffer_view;
54 }
55
56
57 LyXView & Application::createView(unsigned int width,
58                                                                   unsigned int height,
59                                                                   int posx, int posy,
60                                                                   bool maximize)
61 {
62         int view_id = gui().newView();
63         LyXView & view = gui().view(view_id);
64
65         theLyXFunc().setLyXView(&view);
66
67         /*int workArea_id_ =*/ gui().newWorkArea(width, height, view_id);
68
69         view.init();
70         view.setGeometry(width, height, posx, posy, maximize);
71
72         return view;
73 }
74
75
76 int Application::start(std::string const & /*batch*/)
77 {
78         return exec();
79 }
80
81
82 } // namespace frontend
83
84
85
86 frontend::FontLoader & theFontLoader()
87 {
88         static frontend::NoGuiFontLoader no_gui_font_loader;
89
90         if (!use_gui)
91                 return no_gui_font_loader;
92
93         BOOST_ASSERT(theApp);
94         return theApp->fontLoader();
95 }
96
97
98 frontend::FontMetrics const & theFontMetrics(LyXFont const & f)
99 {
100         static frontend::NoGuiFontMetrics no_gui_font_metrics;
101
102         if (!use_gui)
103                 return no_gui_font_metrics;
104
105         BOOST_ASSERT(theApp);
106         return theApp->fontLoader().metrics(f);
107 }
108
109
110 frontend::Clipboard & theClipboard()
111 {
112         BOOST_ASSERT(theApp);
113         return theApp->clipboard();
114 }
115
116
117 frontend::Selection & theSelection()
118 {
119         BOOST_ASSERT(theApp);
120         return theApp->selection();
121 }
122
123
124 } // namespace lyx