]> git.lyx.org Git - lyx.git/blob - src/frontends/Application.C
* src/frontends/qt4/GuiSelection.C
[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"  // for lyx::use_gui
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         : current_view_(0)
43 {
44         // FIXME: please confirm: with unicode, I think initEncoding()
45         // is not needed anymore!
46         
47         // this can't be done before because it needs the Languages object
48         //initEncodings();
49 }
50
51
52 LyXView & Application::createView(unsigned int width,
53                                   unsigned int height,
54                                   int posx, int posy,
55                                   bool maximize,
56                                   unsigned int iconSizeXY,
57                                   const std::string & geometryArg)
58 {
59         LyXView & view = gui().createRegisteredView();
60         int view_id = view.id();
61         
62         theLyXFunc().setLyXView(&view);
63
64         /*int workArea_id_ =*/ gui().newWorkArea(width, height, view_id);
65
66         view.init();
67         view.setGeometry(width, height, posx, posy, maximize, iconSizeXY, geometryArg);
68         view.setFocus();
69
70         setCurrentView(view);
71
72         return view;
73 }
74
75
76 LyXView const * Application::currentView() const
77 {
78         return current_view_;
79 }
80
81
82 LyXView * Application::currentView()
83 {
84         return current_view_;
85 }
86
87
88 void Application::setCurrentView(LyXView & current_view)
89 {
90         current_view_ = &current_view;
91 }
92
93 } // namespace frontend
94
95
96
97 frontend::FontLoader & theFontLoader()
98 {
99         static frontend::NoGuiFontLoader no_gui_font_loader;
100
101         if (!use_gui)
102                 return no_gui_font_loader;
103
104         BOOST_ASSERT(theApp());
105         return theApp()->fontLoader();
106 }
107
108
109 frontend::FontMetrics const & theFontMetrics(LyXFont const & f)
110 {
111         static frontend::NoGuiFontMetrics no_gui_font_metrics;
112
113         if (!use_gui)
114                 return no_gui_font_metrics;
115
116         BOOST_ASSERT(theApp());
117         return theApp()->fontLoader().metrics(f);
118 }
119
120
121 frontend::Clipboard & theClipboard()
122 {
123         BOOST_ASSERT(theApp());
124         return theApp()->clipboard();
125 }
126
127
128 frontend::Selection & theSelection()
129 {
130         BOOST_ASSERT(theApp());
131         return theApp()->selection();
132 }
133
134
135 } // namespace lyx