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 #ifndef CXX_GLOBAL_CSTD
60 extern BufferList bufferlist;
63 /// good ol' "easy to use" Qt again
64 float getDPI() { return 95; }
67 // FIXME: wrong place !
68 LyXServer * lyxserver;
70 void lyx_gui::parse_init(int & argc, char * argv[])
72 static QApplication a(argc, argv);
76 Image::newImage = boost::bind(&QLImage::newImage);
77 Image::loadableFormats = boost::bind(&QLImage::loadableFormats);
79 // needs to be done before reading lyxrc
84 void lyx_gui::parse_lyxrc()
89 void lyx_gui::start(string const & batch, vector<string> files)
94 unsigned int width = 690;
95 unsigned int height = 510;
97 QtView view(width, height);
98 view.show(xpos, ypos, "LyX");
103 // FIXME: some code below needs moving
105 lyxserver = new LyXServer(&view.getLyXFunc(), lyxrc.lyxpipes);
107 vector<string>::const_iterator cit = files.begin();
108 vector<string>::const_iterator end = files.end();
109 for (; cit != end; ++cit) {
110 Buffer * b = bufferlist.loadLyXFile(*cit);
116 // switch to the last buffer successfully loaded
118 view.view()->buffer(last);
121 // handle the batch commands the user asked for
122 if (!batch.empty()) {
123 view.getLyXFunc().dispatch(batch);
139 string const lyx_gui::hexname(LColor::color col)
141 QColor color(lcolor.getX11Name(col).c_str());
142 return ltrim(color.name().latin1(), "#");
146 void lyx_gui::update_color(LColor::color)
152 void lyx_gui::update_fonts()
158 bool lyx_gui::font_available(LyXFont const & font)
160 return fontloader.available(font);
165 map<int, io_callback *> io_callbacks;
169 void lyx_gui::set_read_callback(int fd, LyXComm * comm)
171 io_callbacks[fd] = new io_callback(fd, comm);
175 void lyx_gui::remove_read_callback(int fd)
177 map<int, io_callback *>::iterator it = io_callbacks.find(fd);
178 if (it != io_callbacks.end()) {
180 io_callbacks.erase(it);