3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Lars Gullik Bjnes
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
26 #include "funcrequest.h"
31 #include "LyXAction.h"
35 #include "graphics/LoaderQueue.h"
37 #include "io_callback.h"
39 // FIXME: move this stuff out again
41 #include "lyxserver.h"
42 #include "lyxsocket.h"
43 #include "BufferView.h"
45 #include "GuiApplication.h"
46 #include "GuiImplementation.h"
50 #include "GWorkArea.h"
52 #include "support/lyxlib.h"
53 #include "support/os.h"
54 #include "support/filetools.h"
55 #include "support/package.h"
59 #include <boost/bind.hpp>
60 #include <boost/function.hpp>
61 #include <boost/shared_ptr.hpp>
68 namespace os = lyx::support::os;
70 using std::ostringstream;
73 using lyx::support::package;
75 using lyx::frontend::colorCache;
76 using lyx::frontend::Gui;
77 using lyx::frontend::GuiApplication;
78 using lyx::frontend::GuiImplementation;
79 using lyx::frontend::GView;
84 /// estimate DPI from X server
87 //TODO use GDK instead
88 Screen * scr = ScreenOfDisplay(getDisplay(), getScreen());
89 return int(((HeightOfScreen(scr) * 25.4 / HeightMMOfScreen(scr)) +
90 (WidthOfScreen(scr) * 25.4 / WidthMMOfScreen(scr))) / 2);
95 GuiApplication * guiApp;
97 int lyx_gui::exec(int & argc, char * argv[])
99 guiApp = new GuiApplication(argc, argv);
102 return LyX::ref().exec2(argc, argv);
106 bool lyx_gui::getRGBColor(LColor_color col, lyx::RGBColor & rgbcol)
109 Gdk::Color * gclr = colorCache.getColor(col);
112 if(!gclr->parse(lcolor.getX11Name(col))) {
120 // Note that X stores the RGB values in the range 0 - 65535
121 // whilst we require them in the range 0 - 255.
122 rgbcol.r = gclr->get_red() / 256;
123 rgbcol.g = gclr->get_green() / 256;
124 rgbcol.b = gclr->get_blue() / 256;
129 string const lyx_gui::hexname(LColor_color col)
131 lyx::RGBColor rgbcol;
132 if (!getRGBColor(col, rgbcol)) {
133 lyxerr << "X can't find color for \"" << lcolor.getLyXName(col)
138 std::ostringstream os;
140 os << std::setbase(16) << std::setfill('0')
141 << std::setw(2) << rgbcol.r
142 << std::setw(2) << rgbcol.g
143 << std::setw(2) << rgbcol.b;
149 void lyx_gui::update_color(LColor_color /*col*/)
157 std::map<int, boost::shared_ptr<io_callback> > callbacks;
162 void lyx_gui::register_socket_callback(int fd,
163 boost::function<void()> func)
165 callbacks[fd] = boost::shared_ptr<io_callback>(new io_callback(fd, func));
169 void lyx_gui::unregister_socket_callback(int fd)
175 void lyx_gui::sync_events()