]> git.lyx.org Git - lyx.git/blob - src/frontends/Application.cpp
Get rid of a few warnings.
[lyx.git] / src / frontends / Application.cpp
1 /**
2  * \file frontend/Application.cpp
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.h"  // for lyx::use_gui
26 #include "Font.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 }
45
46
47 LyXView & Application::createView(unsigned int width,
48                                   unsigned int height,
49                                   int posx, int posy,
50                                   int maximized,
51                                   unsigned int iconSizeXY,
52                                   const std::string & geometryArg)
53 {
54         LyXView & view = gui().createRegisteredView();
55         int view_id = view.id();
56
57         theLyXFunc().setLyXView(&view);
58
59         /*int workArea_id_ =*/ gui().newWorkArea(width, height, view_id);
60
61         view.init();
62         view.setGeometry(width, height, posx, posy, maximized, iconSizeXY, geometryArg);
63         view.setFocus();
64
65         setCurrentView(view);
66
67         return view;
68 }
69
70
71 LyXView const * Application::currentView() const
72 {
73         return current_view_;
74 }
75
76
77 LyXView * Application::currentView()
78 {
79         return current_view_;
80 }
81
82
83 void Application::setCurrentView(LyXView & current_view)
84 {
85         current_view_ = &current_view;
86 }
87
88 } // namespace frontend
89
90
91
92 frontend::FontLoader & theFontLoader()
93 {
94         static frontend::NoGuiFontLoader no_gui_font_loader;
95
96         if (!use_gui)
97                 return no_gui_font_loader;
98
99         BOOST_ASSERT(theApp());
100         return theApp()->fontLoader();
101 }
102
103
104 frontend::FontMetrics const & theFontMetrics(Font const & f)
105 {
106         static frontend::NoGuiFontMetrics no_gui_font_metrics;
107
108         if (!use_gui)
109                 return no_gui_font_metrics;
110
111         BOOST_ASSERT(theApp());
112         return theApp()->fontLoader().metrics(f);
113 }
114
115
116 frontend::Clipboard & theClipboard()
117 {
118         BOOST_ASSERT(theApp());
119         return theApp()->clipboard();
120 }
121
122
123 frontend::Selection & theSelection()
124 {
125         BOOST_ASSERT(theApp());
126         return theApp()->selection();
127 }
128
129
130 } // namespace lyx