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;
82 bool lyx_gui::use_gui = true;
86 /// estimate DPI from X server
89 //TODO use GDK instead
90 Screen * scr = ScreenOfDisplay(getDisplay(), getScreen());
91 return int(((HeightOfScreen(scr) * 25.4 / HeightMMOfScreen(scr)) +
92 (WidthOfScreen(scr) * 25.4 / WidthMMOfScreen(scr))) / 2);
97 lyx::frontend::Application * theApp;
98 GuiApplication * guiApp;
100 int lyx_gui::exec(int & argc, char * argv[])
102 guiApp = new GuiApplication(argc, argv);
105 return LyX::ref().exec2(argc, argv);
109 void lyx_gui::parse_lyxrc()
114 LyXView * lyx_gui::create_view(unsigned int width, unsigned int height,
115 int posx, int posy, bool maximize)
117 return &guiApp->createView(width, height, posx, posy, maximize);
121 int lyx_gui::start(LyXView *, string const & batch)
123 return guiApp->start(batch);
127 void lyx_gui::exit(int status)
129 guiApp->exit(status);
133 FuncStatus lyx_gui::getStatus(FuncRequest const & ev)
137 case LFUN_TOOLTIPS_TOGGLE:
148 bool lyx_gui::getRGBColor(LColor_color col, lyx::RGBColor & rgbcol)
151 Gdk::Color * gclr = colorCache.getColor(col);
154 if(!gclr->parse(lcolor.getX11Name(col))) {
162 // Note that X stores the RGB values in the range 0 - 65535
163 // whilst we require them in the range 0 - 255.
164 rgbcol.r = gclr->get_red() / 256;
165 rgbcol.g = gclr->get_green() / 256;
166 rgbcol.b = gclr->get_blue() / 256;
171 string const lyx_gui::hexname(LColor_color col)
173 lyx::RGBColor rgbcol;
174 if (!getRGBColor(col, rgbcol)) {
175 lyxerr << "X can't find color for \"" << lcolor.getLyXName(col)
180 std::ostringstream os;
182 os << std::setbase(16) << std::setfill('0')
183 << std::setw(2) << rgbcol.r
184 << std::setw(2) << rgbcol.g
185 << std::setw(2) << rgbcol.b;
191 void lyx_gui::update_color(LColor_color /*col*/)
197 void lyx_gui::update_fonts()
203 bool lyx_gui::font_available(LyXFont const & font)
205 return fontLoader.available(font);
211 std::map<int, boost::shared_ptr<io_callback> > callbacks;
216 void lyx_gui::register_socket_callback(int fd,
217 boost::function<void()> func)
219 callbacks[fd] = boost::shared_ptr<io_callback>(new io_callback(fd, func));
223 void lyx_gui::unregister_socket_callback(int fd)
229 string const lyx_gui::roman_font_name()
235 string const lyx_gui::sans_font_name()
241 string const lyx_gui::typewriter_font_name()
247 void lyx_gui::sync_events()