3 * Copyright 2002 the LyX Team
4 * Read the file COPYING
7 * \author John Levon <moz@compsoc.man.ac.uk>
12 #include "support/lyxlib.h"
13 #include "support/os.h"
14 #include "support/filetools.h"
15 #include "support/lstrings.h"
20 #include <boost/bind.hpp>
27 // FIXME: move this stuff out again
28 #include "bufferlist.h"
30 #include "lyxserver.h"
31 #include "BufferView.h"
33 // Dear Lord, deliver us from Evil,
35 #include <boost/shared_ptr.hpp>
36 #include <boost/function/function0.hpp>
37 #include <boost/signals/signal1.hpp>
41 #include "qfont_loader.h"
42 #include "io_callback.h"
44 #include <qapplication.h>
46 #ifndef CXX_GLOBAL_CSTD
54 extern BufferList bufferlist;
57 /// good ol' "easy to use" Qt again
58 float getDPI() { return 95; }
61 // FIXME: wrong place !
62 LyXServer * lyxserver;
64 void lyx_gui::parse_init(int & argc, char * argv[])
66 static QApplication a(argc, argv);
70 Image::newImage = boost::bind(&QLImage::newImage);
71 Image::loadableFormats = boost::bind(&QLImage::loadableFormats);
73 // needs to be done before reading lyxrc
78 void lyx_gui::parse_lyxrc()
83 void lyx_gui::start(string const & batch, vector<string> files)
88 unsigned int width = 690;
89 unsigned int height = 510;
91 QtView view(width, height);
92 view.show(xpos, ypos, "LyX");
97 // FIXME: some code below needs moving
99 lyxserver = new LyXServer(&view.getLyXFunc(), lyxrc.lyxpipes);
101 vector<string>::const_iterator cit = files.begin();
102 vector<string>::const_iterator end = files.end();
103 for (; cit != end; ++cit) {
104 Buffer * b = bufferlist.loadLyXFile(*cit);
110 // switch to the last buffer successfully loaded
112 view.view()->buffer(last);
115 // handle the batch commands the user asked for
116 if (!batch.empty()) {
117 view.getLyXFunc().dispatch(batch);
133 string const lyx_gui::hexname(LColor::color col)
135 QColor color(lcolor.getX11Name(col).c_str());
136 return ltrim(color.name().latin1(), "#");
140 void lyx_gui::update_color(LColor::color)
146 void lyx_gui::update_fonts()
152 bool lyx_gui::font_available(LyXFont const & font)
154 return fontloader.available(font);
159 map<int, io_callback *> io_callbacks;
163 void lyx_gui::set_read_callback(int fd, LyXComm * comm)
165 io_callbacks[fd] = new io_callback(fd, comm);
169 void lyx_gui::remove_read_callback(int fd)
171 map<int, io_callback *>::iterator it = io_callbacks.find(fd);
172 if (it != io_callbacks.end()) {
174 io_callbacks.erase(it);