3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS
15 #pragma implementation
18 #include "support/lyxlib.h"
19 #include "support/os.h"
20 #include "support/filetools.h"
21 #include "support/lstrings.h"
26 #include <boost/bind.hpp>
33 // FIXME: move this stuff out again
34 #include "bufferlist.h"
36 #include "lyxserver.h"
37 #include "BufferView.h"
39 // Dear Lord, deliver us from Evil,
41 #include <boost/shared_ptr.hpp>
42 #include <boost/function/function0.hpp>
43 #include <boost/signals/signal1.hpp>
47 #include "qfont_loader.h"
48 #include "io_callback.h"
50 #include <qapplication.h>
52 #include <qpaintdevicemetrics.h>
54 #ifndef CXX_GLOBAL_CSTD
62 extern BufferList bufferlist;
69 QPaintDeviceMetrics pdm(&w);
70 return pdm.logicalDpiY();
75 // FIXME: wrong place !
76 LyXServer * lyxserver;
78 void lyx_gui::parse_init(int & argc, char * argv[])
80 static QApplication a(argc, argv);
84 Image::newImage = boost::bind(&QLImage::newImage);
85 Image::loadableFormats = boost::bind(&QLImage::loadableFormats);
87 // needs to be done before reading lyxrc
92 void lyx_gui::parse_lyxrc()
97 void lyx_gui::start(string const & batch, vector<string> files)
102 unsigned int width = 690;
103 unsigned int height = 510;
105 QtView view(width, height);
106 view.show(xpos, ypos, "LyX");
111 // FIXME: some code below needs moving
113 lyxserver = new LyXServer(&view.getLyXFunc(), lyxrc.lyxpipes);
115 vector<string>::const_iterator cit = files.begin();
116 vector<string>::const_iterator end = files.end();
117 for (; cit != end; ++cit) {
118 Buffer * b = bufferlist.loadLyXFile(*cit);
124 // switch to the last buffer successfully loaded
126 view.view()->buffer(last);
129 // handle the batch commands the user asked for
130 if (!batch.empty()) {
131 view.getLyXFunc().dispatch(batch);
147 string const lyx_gui::hexname(LColor::color col)
149 QColor color(lcolor.getX11Name(col).c_str());
150 return ltrim(color.name().latin1(), "#");
154 void lyx_gui::update_color(LColor::color)
160 void lyx_gui::update_fonts()
166 bool lyx_gui::font_available(LyXFont const & font)
168 return fontloader.available(font);
173 map<int, io_callback *> io_callbacks;
177 void lyx_gui::set_read_callback(int fd, LyXComm * comm)
179 io_callbacks[fd] = new io_callback(fd, comm);
183 void lyx_gui::remove_read_callback(int fd)
185 map<int, io_callback *>::iterator it = io_callbacks.find(fd);
186 if (it != io_callbacks.end()) {
188 io_callbacks.erase(it);