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"
24 #include "io_callback.h"
28 #include "BufferView.h"
31 #include "graphics/LoaderQueue.h"
33 #include "support/lstrings.h"
34 #include "support/os.h"
35 #include "support/package.h"
43 #include "LyXGdkImage.h"
48 using lyx::support::subst;
56 std::map<int, boost::shared_ptr<io_callback> > callbacks;
58 /// estimate DPI from X server
61 //TODO use GDK instead
62 Screen * scr = ScreenOfDisplay(getDisplay(), getScreen());
63 return int(((HeightOfScreen(scr) * 25.4 / HeightMMOfScreen(scr)) +
64 (WidthOfScreen(scr) * 25.4 / WidthMMOfScreen(scr))) / 2);
72 frontend::Application * createApplication(int & argc, char * argv[])
74 return new frontend::GuiApplication(argc, argv);
79 GuiApplication::GuiApplication(int & argc, char ** argv)
80 : Gtk::Main(argc, argv), Application(argc, argv)
82 using namespace lyx::graphics;
83 Image::newImage = boost::bind(&LyXGdkImage::newImage);
84 Image::loadableFormats = boost::bind(&LyXGdkImage::loadableFormats);
86 // needs to be done before reading lyxrc
89 LoaderQueue::setPriority(10,100);
93 Clipboard& GuiApplication::clipboard()
99 Selection& GuiApplication::selection()
105 int const GuiApplication::exec()
112 void GuiApplication::exit(int /*status*/)
114 // FIXME: Don't ignore status
119 string const GuiApplication::romanFontName()
125 string const GuiApplication::sansFontName()
131 string const GuiApplication::typewriterFontName()
137 void GuiApplication::syncEvents()
143 bool GuiApplication::getRgbColor(LColor_color col,
144 lyx::RGBColor & rgbcol)
147 Gdk::Color * gclr = colorCache.getColor(col);
150 if(!gclr->parse(lcolor.getX11Name(col))) {
158 // Note that X stores the RGB values in the range 0 - 65535
159 // whilst we require them in the range 0 - 255.
160 rgbcol.r = gclr->get_red() / 256;
161 rgbcol.g = gclr->get_green() / 256;
162 rgbcol.b = gclr->get_blue() / 256;
167 string const GuiApplication::hexName(LColor_color col)
169 lyx::RGBColor rgbcol;
170 if (!getRgbColor(col, rgbcol)) {
171 lyxerr << "X can't find color for \"" << lcolor.getLyXName(col)
176 std::ostringstream os;
178 os << std::setbase(16) << std::setfill('0')
179 << std::setw(2) << rgbcol.r
180 << std::setw(2) << rgbcol.g
181 << std::setw(2) << rgbcol.b;
187 void GuiApplication::updateColor(LColor_color)
193 void GuiApplication::registerSocketCallback(int fd, boost::function<void()> func)
195 callbacks[fd] = boost::shared_ptr<io_callback>(new io_callback(fd, func));
199 void GuiApplication::unregisterSocketCallback(int fd)
204 } // namespace frontend