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.
8 * \author Abdelrazak Younes
10 * Full author contact details are available in file CREDITS.
15 // Too hard to make concept checks work with this file
16 #ifdef _GLIBCXX_CONCEPT_CHECKS
17 #undef _GLIBCXX_CONCEPT_CHECKS
19 #ifdef _GLIBCPP_CONCEPT_CHECKS
20 #undef _GLIBCPP_CONCEPT_CHECKS
23 #include "GuiApplication.h"
27 #include "BufferView.h"
29 #include "graphics/LoaderQueue.h"
31 #include "support/lstrings.h"
32 #include "support/os.h"
33 #include "support/package.h"
41 #include "LyXGdkImage.h"
44 using lyx::support::subst;
52 std::map<int, boost::shared_ptr<io_callback> > callbacks;
54 /// estimate DPI from X server
57 //TODO use GDK instead
58 Screen * scr = ScreenOfDisplay(getDisplay(), getScreen());
59 return int(((HeightOfScreen(scr) * 25.4 / HeightMMOfScreen(scr)) +
60 (WidthOfScreen(scr) * 25.4 / WidthMMOfScreen(scr))) / 2);
68 lyx::frontend::Application * createApplication(int & argc, char * argv[])
70 return new GuiApplication(argc, argv);
75 GuiApplication::GuiApplication(int & argc, char ** argv)
76 : Gtk::Main(argc, argv), Application(argc, argv)
78 using namespace lyx::graphics;
79 Image::newImage = boost::bind(&LyXGdkImage::newImage);
80 Image::loadableFormats = boost::bind(&LyXGdkImage::loadableFormats);
82 // needs to be done before reading lyxrc
85 LoaderQueue::setPriority(10,100);
89 Clipboard& GuiApplication::clipboard()
95 Selection& GuiApplication::selection()
101 int const GuiApplication::exec()
108 void GuiApplication::exit(int /*status*/)
110 // FIXME: Don't ignore status
115 string const GuiApplication::romanFontName()
121 string const GuiApplication::sansFontName()
127 string const GuiApplication::typewriterFontName()
133 void GuiApplication::syncEvents()
139 bool GuiApplication::getRgbColor(LColor_color col,
140 lyx::RGBColor & rgbcol)
143 Gdk::Color * gclr = colorCache.getColor(col);
146 if(!gclr->parse(lcolor.getX11Name(col))) {
154 // Note that X stores the RGB values in the range 0 - 65535
155 // whilst we require them in the range 0 - 255.
156 rgbcol.r = gclr->get_red() / 256;
157 rgbcol.g = gclr->get_green() / 256;
158 rgbcol.b = gclr->get_blue() / 256;
163 string const GuiApplication::hexName(LColor_color col)
165 lyx::RGBColor rgbcol;
166 if (!getRGBColor(col, rgbcol)) {
167 lyxerr << "X can't find color for \"" << lcolor.getLyXName(col)
172 std::ostringstream os;
174 os << std::setbase(16) << std::setfill('0')
175 << std::setw(2) << rgbcol.r
176 << std::setw(2) << rgbcol.g
177 << std::setw(2) << rgbcol.b;
183 void GuiApplication::updateColor(LColor_color)
189 void GuiApplication::registerSocketCallback(int fd, boost::function<void()> func)
191 callbacks[fd] = boost::shared_ptr<io_callback>(new io_callback(fd, func));
195 void GuiApplication::unregisterSocketCallback(int fd)
200 } // namespace frontend