/**
* \file lyx_gui.C
- * Copyright 2002 the LyX Team
- * Read the file COPYING
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
*
* \author unknown
- * \author John Levon <moz@compsoc.man.ac.uk>
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS
*/
#include <config.h>
/// quit lyx
bool finished = false;
+/// estimate DPI from X server
+float getDPI()
+{
+ Screen * scr = ScreenOfDisplay(fl_get_display(), fl_screen);
+ return ((HeightOfScreen(scr) * 25.4 / HeightMMOfScreen(scr)) +
+ (WidthOfScreen(scr) * 25.4 / WidthMMOfScreen(scr))) / 2;
+}
+
+
/// set default GUI configuration
void setDefaults()
{
XSetErrorHandler(LyX_XErrHandler);
lyxColorHandler.reset(new LyXColorHandler());
-
+
using namespace grfx;
#ifdef USE_XFORMS_IMAGE_LOADER
Image::newImage = boost::bind(&ImageXPM::newImage);
Image::loadableFormats = boost::bind(&ImageXPM::loadableFormats);
#endif
+
+ // must do this /before/ lyxrc gets read
+ lyxrc.dpi = getDPI();
}
void lyx_gui::parse_lyxrc()
{
- // FIXME !!!!
- lyxrc.dpi = 95;
-
XformsColor::read(AddName(user_lyxdir, "preferences.xform"));
if (lyxrc.popup_font_encoding.empty())
// FIXME: some code below needs moving
- lyxserver = new LyXServer(view.getLyXFunc(), lyxrc.lyxpipes);
+ lyxserver = new LyXServer(&view.getLyXFunc(), lyxrc.lyxpipes);
vector<string>::const_iterator cit = files.begin();
vector<string>::const_iterator end = files.end();
// handle the batch commands the user asked for
if (!batch.empty()) {
- view.getLyXFunc()->dispatch(batch);
+ view.getLyXFunc().dispatch(batch);
}
// enter the event loop
finished = true;
}
-
+
string const lyx_gui::hexname(LColor::color col)
{
string const name = lcolor.getX11Name(col);
extern "C"
void C_read_callback(int, void * data)
{
- LyXComm * comm = static_cast<LyXComm *>(data);
+ LyXComm * comm = static_cast<LyXComm *>(data);
comm->read_ready();
}
{
fl_add_io_callback(fd, FL_READ, C_read_callback, comm);
}
+
+
+void lyx_gui::remove_read_callback(int fd)
+{
+ fl_remove_io_callback(fd, FL_READ, C_read_callback);
+}