]> git.lyx.org Git - lyx.git/blob - src/frontends/gtk/GuiApplication.C
enable Font cache only for MacOSX and inline width() for other platform.
[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 // Too hard to make concept checks work with this file
16 #ifdef _GLIBCXX_CONCEPT_CHECKS
17 #undef _GLIBCXX_CONCEPT_CHECKS
18 #endif
19 #ifdef _GLIBCPP_CONCEPT_CHECKS
20 #undef _GLIBCPP_CONCEPT_CHECKS
21 #endif
22
23 #include "GuiApplication.h"
24
25 #include "GtkmmX.h"
26
27 #include "BufferView.h"
28
29 #include "graphics/LoaderQueue.h"
30
31 #include "support/lstrings.h"
32 #include "support/os.h"
33 #include "support/package.h"
34
35 #include "lyx_main.h"
36 #include "lyxrc.h"
37 #include "debug.h"
38
39 #include <gtkmm.h>
40
41 #include "LyXGdkImage.h"
42
43
44 using lyx::support::subst;
45
46 using std::string;
47 using std::endl;
48
49
50 namespace {
51
52 /// estimate DPI from X server
53 int getDPI()
54 {
55         //TODO use GDK instead
56         Screen * scr = ScreenOfDisplay(getDisplay(), getScreen());
57         return int(((HeightOfScreen(scr) * 25.4 / HeightMMOfScreen(scr)) +
58                 (WidthOfScreen(scr) * 25.4 / WidthMMOfScreen(scr))) / 2);
59 }
60
61 } // namespace anon
62
63
64 namespace lyx {
65 namespace frontend {
66
67 GuiApplication::GuiApplication(int & argc, char ** argv)
68         : Gtk::Main(argc, argv), Application(argc, argv)
69 {
70         using namespace lyx::graphics;
71         Image::newImage = boost::bind(&LyXGdkImage::newImage);
72         Image::loadableFormats = boost::bind(&LyXGdkImage::loadableFormats);
73
74         // needs to be done before reading lyxrc
75         lyxrc.dpi = getDPI();
76
77         LoaderQueue::setPriority(10,100);
78 }
79
80
81 Clipboard& GuiApplication::clipboard()
82 {
83         return clipboard_;
84 }
85
86
87 Selection& GuiApplication::selection()
88 {
89         return selection_;
90 }
91
92
93 int const GuiApplication::exec()
94 {
95         run();
96         return EXIT_SUCCESS;
97 }
98
99
100 void GuiApplication::exit(int /*status*/)
101 {
102         // FIXME: Don't ignore status
103         guiApp->quit();
104 }
105
106
107 string const GuiApplication::romanFontName()
108 {
109         return "times";
110 }
111
112
113 string const GuiApplication::sansFontName()
114 {
115         return "helvetica";
116 }
117
118
119 string const GuiApplication::typewriterFontName()
120 {
121         return "courier";
122 }
123
124
125 } // namespace frontend
126 } // namespace lyx