]> git.lyx.org Git - lyx.git/blob - src/frontends/gtk/GuiApplication.C
make it compile again
[lyx.git] / src / frontends / gtk / GuiApplication.C
1 /**
2  * \file qt4/GuiApplication.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author unknown
7  * \author John Levon
8  * \author Abdelrazak Younes
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #include <config.h>
14
15 #include "GuiApplication.h"
16
17 #include "GView.h"
18 #include "GuiWorkArea.h"
19 #include "GtkmmX.h"
20
21 #include "BufferView.h"
22
23 #include "graphics/LoaderQueue.h"
24
25 #include "support/lstrings.h"
26 #include "support/os.h"
27 #include "support/package.h"
28
29 #include "lyx_main.h"
30 #include "lyxrc.h"
31 #include "debug.h"
32
33 #include <gtkmm.h>
34
35 #include "LyXGdkImage.h"
36
37
38 using lyx::support::subst;
39
40 using std::string;
41 using std::endl;
42
43
44 namespace {
45
46 /// estimate DPI from X server
47 int getDPI()
48 {
49         //TODO use GDK instead
50         Screen * scr = ScreenOfDisplay(getDisplay(), getScreen());
51         return int(((HeightOfScreen(scr) * 25.4 / HeightMMOfScreen(scr)) +
52                 (WidthOfScreen(scr) * 25.4 / WidthMMOfScreen(scr))) / 2);
53 }
54
55 } // namespace anon
56
57
58 namespace lyx {
59 namespace frontend {
60
61 GuiApplication::GuiApplication(int & argc, char ** argv)
62         : Gtk::Main(argc, argv), Application(argc, argv)
63 {
64         using namespace lyx::graphics;
65         Image::newImage = boost::bind(&LyXGdkImage::newImage);
66         Image::loadableFormats = boost::bind(&LyXGdkImage::loadableFormats);
67
68         // needs to be done before reading lyxrc
69         lyxrc.dpi = getDPI();
70
71         LoaderQueue::setPriority(10,100);
72 }
73
74
75 Clipboard& GuiApplication::clipboard()
76 {
77         return clipboard_;
78 }
79
80
81 Selection& GuiApplication::selection()
82 {
83         return selection_;
84 }
85
86
87 int const GuiApplication::exec()
88 {
89         run();
90         return EXIT_SUCCESS;
91 }
92
93
94 void GuiApplication::exit(int /*status*/)
95 {
96         // FIXME: Don't ignore status
97         guiApp->quit();
98 }
99
100
101 // FIXME: this whole method needs to be moved to Application.
102 LyXView & GuiApplication::createView(unsigned int width,
103                                                                           unsigned int height,
104                                                                           int posx, int posy,
105                                                                           bool maximize)
106 {
107         // FIXME: for now we assume that there is only one LyXView with id = 0.
108         /*int workArea_id_ =*/ gui().newWorkArea(width, height, 0);
109         //WorkArea * workArea_ = & theApp->gui().workArea(workArea_id_);
110
111         int view_id = gui().newView(width, height);
112         GView & view = static_cast<GView &>(gui().view(view_id));
113
114         lyxfunc_.reset(new LyXFunc(&view));
115
116         LyX::ref().addLyXView(&view);
117
118         view.show();
119         view.init();
120
121         return view;
122 }
123
124 } // namespace frontend
125 } // namespace lyx