]> git.lyx.org Git - lyx.git/blob - src/frontends/Application.C
Updates from Bennett and myself.
[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 LyXView & Application::createView(unsigned int width,
52                                                                   unsigned int height,
53                                                                   int posx, int posy,
54                                                                   bool maximize,
55                                                                   unsigned int iconSizeXY)
56 {
57         int view_id = gui().newView();
58         LyXView & view = gui().view(view_id);
59
60         theLyXFunc().setLyXView(&view);
61
62         /*int workArea_id_ =*/ gui().newWorkArea(width, height, view_id);
63
64         view.init();
65         view.setGeometry(width, height, posx, posy, maximize, iconSizeXY);
66
67         setCurrentView(view);
68
69         return view;
70 }
71
72
73 LyXView const & Application::currentView() const
74 {
75         return *current_view_;
76 }
77
78
79 LyXView & Application::currentView()
80 {
81         return *current_view_;
82 }
83
84
85 void Application::setCurrentView(LyXView & current_view)
86 {
87         current_view_ = &current_view;
88 }
89
90 } // namespace frontend
91
92
93
94 frontend::FontLoader & theFontLoader()
95 {
96         static frontend::NoGuiFontLoader no_gui_font_loader;
97
98         if (!use_gui)
99                 return no_gui_font_loader;
100
101         BOOST_ASSERT(theApp);
102         return theApp->fontLoader();
103 }
104
105
106 frontend::FontMetrics const & theFontMetrics(LyXFont const & f)
107 {
108         static frontend::NoGuiFontMetrics no_gui_font_metrics;
109
110         if (!use_gui)
111                 return no_gui_font_metrics;
112
113         BOOST_ASSERT(theApp);
114         return theApp->fontLoader().metrics(f);
115 }
116
117
118 frontend::Clipboard & theClipboard()
119 {
120         BOOST_ASSERT(theApp);
121         return theApp->clipboard();
122 }
123
124
125 frontend::Selection & theSelection()
126 {
127         BOOST_ASSERT(theApp);
128         return theApp->selection();
129 }
130
131
132 } // namespace lyx