2002-06-19 05:20:29 +00:00
|
|
|
/**
|
|
|
|
* \file lyx_gui.C
|
|
|
|
* Copyright 2002 the LyX Team
|
|
|
|
* Read the file COPYING
|
|
|
|
*
|
|
|
|
* \author unknown
|
|
|
|
* \author John Levon <moz@compsoc.man.ac.uk>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "support/lyxlib.h"
|
|
|
|
#include "support/os.h"
|
|
|
|
#include "support/filetools.h"
|
|
|
|
#include "debug.h"
|
|
|
|
#include "gettext.h"
|
|
|
|
|
2002-07-12 01:48:53 +00:00
|
|
|
#include <fcntl.h>
|
|
|
|
#include <boost/bind.hpp>
|
|
|
|
|
|
|
|
#include "lyx_gui.h"
|
2002-06-19 05:20:29 +00:00
|
|
|
#include "lyx_main.h"
|
|
|
|
#include "lyxrc.h"
|
2002-07-12 03:05:13 +00:00
|
|
|
#include "lyxfont.h"
|
2002-07-12 01:48:53 +00:00
|
|
|
|
2002-06-19 05:20:29 +00:00
|
|
|
// FIXME: move this stuff out again
|
|
|
|
#include "bufferlist.h"
|
|
|
|
#include "lyxfunc.h"
|
|
|
|
#include "lyxserver.h"
|
|
|
|
#include "BufferView.h"
|
|
|
|
|
2002-07-12 01:48:53 +00:00
|
|
|
// Dear Lord, deliver us from Evil,
|
|
|
|
// aka the Qt headers
|
|
|
|
#include <boost/shared_ptr.hpp>
|
|
|
|
#include <boost/function/function0.hpp>
|
|
|
|
#include <boost/signals/signal1.hpp>
|
|
|
|
|
|
|
|
#include "QtView.h"
|
|
|
|
#include "QLImage.h"
|
2002-07-12 03:05:13 +00:00
|
|
|
#include "qfont_loader.h"
|
2002-06-19 05:20:29 +00:00
|
|
|
|
|
|
|
#include <qapplication.h>
|
|
|
|
|
|
|
|
#ifndef CXX_GLOBAL_CSTD
|
|
|
|
using std::exit;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
using std::vector;
|
|
|
|
using std::hex;
|
|
|
|
using std::endl;
|
|
|
|
|
|
|
|
extern bool finished;
|
|
|
|
extern BufferList bufferlist;
|
|
|
|
|
|
|
|
// FIXME: wrong place !
|
|
|
|
LyXServer * lyxserver;
|
|
|
|
|
|
|
|
void lyx_gui::parse_init(int & argc, char * argv[])
|
|
|
|
{
|
|
|
|
static QApplication a(argc, argv);
|
2002-07-12 16:26:25 +00:00
|
|
|
|
|
|
|
using namespace grfx;
|
|
|
|
|
|
|
|
Image::newImage = boost::bind(&QLImage::newImage);
|
|
|
|
Image::loadableFormats = boost::bind(&QLImage::loadableFormats);
|
2002-06-19 05:20:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void lyx_gui::parse_lyxrc()
|
|
|
|
{
|
|
|
|
// FIXME !!!!
|
|
|
|
lyxrc.dpi = 95;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void lyx_gui::start(string const & batch, vector<string> files)
|
|
|
|
{
|
|
|
|
// initial geometry
|
|
|
|
int xpos = -1;
|
|
|
|
int ypos = -1;
|
|
|
|
unsigned int width = 690;
|
|
|
|
unsigned int height = 510;
|
|
|
|
|
|
|
|
QtView view(width, height);
|
|
|
|
view.show(xpos, ypos, "LyX");
|
|
|
|
view.init();
|
|
|
|
|
|
|
|
Buffer * last = 0;
|
|
|
|
|
|
|
|
// FIXME: some code below needs moving
|
|
|
|
|
|
|
|
lyxserver = new LyXServer(view.getLyXFunc(), lyxrc.lyxpipes);
|
|
|
|
|
|
|
|
vector<string>::const_iterator cit = files.begin();
|
|
|
|
vector<string>::const_iterator end = files.end();
|
|
|
|
for (; cit != end; ++cit) {
|
|
|
|
Buffer * b = bufferlist.loadLyXFile(*cit);
|
|
|
|
if (b) {
|
|
|
|
last = b;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// switch to the last buffer successfully loaded
|
|
|
|
if (last) {
|
|
|
|
view.view()->buffer(last);
|
|
|
|
}
|
|
|
|
|
|
|
|
// handle the batch commands the user asked for
|
|
|
|
if (!batch.empty()) {
|
|
|
|
view.getLyXFunc()->verboseDispatch(batch, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
while (!finished) {
|
|
|
|
qApp->processEvents();
|
|
|
|
}
|
|
|
|
|
|
|
|
// FIXME
|
|
|
|
delete lyxserver;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-11 01:01:38 +00:00
|
|
|
string const lyx_gui::hexname(LColor::color col)
|
|
|
|
{
|
|
|
|
// FIXME
|
|
|
|
return "";
|
|
|
|
}
|
2002-07-12 02:27:42 +00:00
|
|
|
|
|
|
|
|
2002-07-12 03:05:13 +00:00
|
|
|
void lyx_gui::update_color(LColor::color)
|
2002-07-12 02:27:42 +00:00
|
|
|
{
|
|
|
|
// no need
|
|
|
|
}
|
2002-07-12 03:05:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
void lyx_gui::update_fonts()
|
|
|
|
{
|
|
|
|
fontloader.update();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool lyx_gui::font_available(LyXFont const & font)
|
|
|
|
{
|
|
|
|
return fontloader.available(font);
|
|
|
|
}
|