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