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"
19 #include <boost/bind.hpp>
26 // FIXME: move this stuff out again
27 #include "bufferlist.h"
29 #include "lyxserver.h"
30 #include "BufferView.h"
32 // Dear Lord, deliver us from Evil,
34 #include <boost/shared_ptr.hpp>
35 #include <boost/function/function0.hpp>
36 #include <boost/signals/signal1.hpp>
40 #include "qfont_loader.h"
41 #include "io_callback.h"
43 #include <qapplication.h>
45 #ifndef CXX_GLOBAL_CSTD
54 extern BufferList bufferlist;
56 // FIXME: wrong place !
57 LyXServer * lyxserver;
59 void lyx_gui::parse_init(int & argc, char * argv[])
61 static QApplication a(argc, argv);
65 Image::newImage = boost::bind(&QLImage::newImage);
66 Image::loadableFormats = boost::bind(&QLImage::loadableFormats);
70 void lyx_gui::parse_lyxrc()
77 void lyx_gui::start(string const & batch, vector<string> files)
82 unsigned int width = 690;
83 unsigned int height = 510;
85 QtView view(width, height);
86 view.show(xpos, ypos, "LyX");
91 // FIXME: some code below needs moving
93 lyxserver = new LyXServer(view.getLyXFunc(), lyxrc.lyxpipes);
95 vector<string>::const_iterator cit = files.begin();
96 vector<string>::const_iterator end = files.end();
97 for (; cit != end; ++cit) {
98 Buffer * b = bufferlist.loadLyXFile(*cit);
104 // switch to the last buffer successfully loaded
106 view.view()->buffer(last);
109 // handle the batch commands the user asked for
110 if (!batch.empty()) {
111 view.getLyXFunc()->dispatch(batch);
114 // FIXME: something somewhere is EATING CPU
116 qApp->processEvents();
124 string const lyx_gui::hexname(LColor::color col)
126 QColor color(lcolor.getX11Name(col).c_str());
127 return color.name().latin1();
131 void lyx_gui::update_color(LColor::color)
137 void lyx_gui::update_fonts()
143 bool lyx_gui::font_available(LyXFont const & font)
145 return fontloader.available(font);
149 void lyx_gui::set_read_callback(int fd, LyXComm * comm)
152 new io_callback(fd, comm);