mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
New lyx_gui namespace. Some working out to be done still ..
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4377 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
279eed6806
commit
9699643848
@ -1,3 +1,13 @@
|
||||
2002-06-12 John Levon <moz@compsoc.man.ac.uk>
|
||||
|
||||
* Makefile.am:
|
||||
* lyx_gui.h:
|
||||
* lyx_gui.C: move to frontends/
|
||||
|
||||
* main.C:
|
||||
* lyx_main.h:
|
||||
* lyx_main.C: changes from above
|
||||
|
||||
2002-06-12 John Levon <moz@compsoc.man.ac.uk>
|
||||
|
||||
* intl.C:
|
||||
|
@ -136,8 +136,6 @@ lyx_SOURCES = \
|
||||
lengthcommon.h \
|
||||
lyx_cb.C \
|
||||
lyx_cb.h \
|
||||
lyx_gui.C \
|
||||
lyx_gui.h \
|
||||
lyx_main.C \
|
||||
lyx_main.h \
|
||||
lyx_sty.C \
|
||||
@ -214,15 +212,14 @@ lyx_SOURCES = \
|
||||
vspace.C \
|
||||
vspace.h
|
||||
|
||||
lyx_main.o: lyx_main.C lyx_main.h config.h version.h lyx_gui.h \
|
||||
lyx_main.o: lyx_main.C lyx_main.h config.h version.h \
|
||||
lyxrc.h support/path.h support/filetools.h \
|
||||
bufferlist.h debug.h support/FileInfo.h lastfiles.h intl.h \
|
||||
lyxserver.h layout.h gettext.h kbmap.h commandtags.h language.h
|
||||
$(CXXCOMPILE) -DLYX_DIR=\"$(pkgdatadir)\" \
|
||||
-DTOP_SRCDIR=\"$(top_srcdir)\" -c $(top_srcdir)/src/lyx_main.C
|
||||
|
||||
main.o: main.C config.h lyx_main.h gettext.h LString.h support/filetools.h \
|
||||
support/os.h frontends/GUIRunTime.h
|
||||
main.o: main.C config.h lyx_main.h gettext.h LString.h support/filetools.h support/os.h
|
||||
$(CXXCOMPILE) -DLOCALEDIR=\"$(localedir)\" -c $(top_srcdir)/src/main.C
|
||||
|
||||
dist-hook:
|
||||
|
@ -3,6 +3,15 @@
|
||||
* font_metrics.h: remove trailing semi-colon after the brace closing
|
||||
the namespace.
|
||||
|
||||
2002-06-12 John Levon <moz@compsoc.man.ac.uk>
|
||||
|
||||
* GUIRunTime.h: remove in favour of ...
|
||||
|
||||
* Makefile.am:
|
||||
* lyx_gui.h: ... namespace for GUI start up
|
||||
|
||||
* LyXView.h: remove init(),show(),setPosition()
|
||||
|
||||
2002-06-12 John Levon <moz@compsoc.man.ac.uk>
|
||||
|
||||
* Menubar.C:
|
||||
|
@ -1,64 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/* This file is part of
|
||||
* ======================================================
|
||||
*
|
||||
* LyX, The Document Processor
|
||||
*
|
||||
* Copyright 2000-2001 The LyX Team.
|
||||
*
|
||||
* ====================================================== */
|
||||
|
||||
#ifndef GUIRUNTIME_H
|
||||
#define GUIRUNTIME_H
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
class LyXView;
|
||||
|
||||
/** The LyX GUI independent guiruntime class
|
||||
The GUI interface is implemented in the corresponding
|
||||
frontends GUIRunTime.C file.
|
||||
*/
|
||||
class GUIRunTime {
|
||||
public:
|
||||
/// initialise the toolkit
|
||||
static
|
||||
int initApplication(int & argc, char * argv[]);
|
||||
/// process pending events
|
||||
static
|
||||
void processEvents();
|
||||
/// enter the permanent event loop until "finished" becomes false
|
||||
static
|
||||
void runTime();
|
||||
/// This is run first in the LyXGUI constructor.
|
||||
static
|
||||
void setDefaults();
|
||||
///
|
||||
static
|
||||
LyXView * createMainView(int w, int h);
|
||||
/** Called bu the graphics cache to connect the approriate frontend
|
||||
* image loading routines to the LyX kernel.
|
||||
*/
|
||||
static void initialiseGraphics();
|
||||
|
||||
/* the following entries are X11 specific and should eventually go away */
|
||||
/// The display on which LyX is running
|
||||
static
|
||||
Display * x11Display();
|
||||
/// The screen on which LyX is running
|
||||
static
|
||||
int x11Screen();
|
||||
/// The current colormap
|
||||
static
|
||||
Colormap x11Colormap();
|
||||
/// The current visual depth
|
||||
static
|
||||
int x11VisualDepth();
|
||||
/// the server's DPI estimate
|
||||
static
|
||||
float getScreenDPI();
|
||||
};
|
||||
#endif
|
@ -54,12 +54,6 @@ public:
|
||||
LyXView();
|
||||
///
|
||||
virtual ~LyXView();
|
||||
///
|
||||
virtual void init() = 0;
|
||||
///
|
||||
virtual void setPosition(int, int) = 0;
|
||||
///
|
||||
virtual void show(int, int, string const &) = 0;
|
||||
/// Redraw the main form.
|
||||
virtual void redraw() = 0;
|
||||
|
||||
|
@ -21,7 +21,6 @@ libfrontends_la_SOURCES = \
|
||||
Dialogs.h \
|
||||
DialogBase.h \
|
||||
FileDialog.h \
|
||||
GUIRunTime.h \
|
||||
Liason.C \
|
||||
Liason.h \
|
||||
Menubar.C \
|
||||
@ -38,6 +37,7 @@ libfrontends_la_SOURCES = \
|
||||
font_loader.h \
|
||||
font_metrics.h \
|
||||
key_state.h \
|
||||
lyx_gui.h \
|
||||
mouse_state.h \
|
||||
screen.C \
|
||||
screen.h
|
||||
|
40
src/frontends/lyx_gui.h
Normal file
40
src/frontends/lyx_gui.h
Normal file
@ -0,0 +1,40 @@
|
||||
/**
|
||||
* \file lyx_gui.h
|
||||
* Copyright 2002 the LyX Team
|
||||
* Read the file COPYING
|
||||
*
|
||||
* \author John Levon <moz@compsoc.man.ac.uk>
|
||||
*/
|
||||
|
||||
#ifndef LYX_GUI_H
|
||||
#define LYX_GUI_H
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "LString.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
/// GUI interaction
|
||||
namespace lyx_gui {
|
||||
|
||||
/// parse command line and do basic initialisation
|
||||
void parse_init(int & argc, char * argv[]);
|
||||
|
||||
/**
|
||||
* set up GUI parameters. At this point lyxrc may
|
||||
* be used.
|
||||
*/
|
||||
void parse_lyxrc();
|
||||
|
||||
/**
|
||||
* Start the main event loop, after executing the given
|
||||
* batch commands, and loading the given documents
|
||||
*/
|
||||
void start(string const & batch, std::vector<std::string> files);
|
||||
|
||||
/// initialise graphics
|
||||
void init_graphics();
|
||||
};
|
||||
|
||||
#endif // LYX_GUI_H
|
@ -1,3 +1,16 @@
|
||||
2002-06-12 John Levon <moz@compsoc.man.ac.uk>
|
||||
|
||||
* GUIRunTime.C: remove in favour of ...
|
||||
|
||||
* Makefile.am:
|
||||
* lyx_gui.C: ... GUI startup namespace
|
||||
|
||||
* XFormsView.h:
|
||||
* XFormsView.C: change show() prototype
|
||||
|
||||
* XPainter.C:
|
||||
* xfont_loader.C: don't use GUIRunTime any more
|
||||
|
||||
2002-06-12 John Levon <moz@compsoc.man.ac.uk>
|
||||
|
||||
* ColorHandler.C:
|
||||
|
@ -1,173 +0,0 @@
|
||||
/**
|
||||
* \file xforms/GUIRunTime.C
|
||||
* Copyright 2000-2001 The LyX Team.
|
||||
* See the file COPYING.
|
||||
*
|
||||
* \author unknown
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include FORMS_H_LOCATION
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
||||
#include "GUIRunTime.h"
|
||||
#include "XFormsView.h"
|
||||
#include "debug.h"
|
||||
|
||||
#ifdef USE_XFORMS_IMAGE_LOADER
|
||||
#include "xformsGImage.h"
|
||||
#else
|
||||
#include "graphics/GraphicsImageXPM.h"
|
||||
#endif
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
using std::endl;
|
||||
using std::hex;
|
||||
|
||||
|
||||
extern bool finished;
|
||||
|
||||
namespace {
|
||||
|
||||
int const xforms_include_version = FL_INCLUDE_VERSION;
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
||||
int GUIRunTime::initApplication(int &, char * [])
|
||||
{
|
||||
// Check the XForms version in the forms.h header against
|
||||
// the one in the libforms. If they don't match quit the
|
||||
// execution of LyX. Better with a clean fast exit than
|
||||
// a strange segfault later.
|
||||
// I realize that this check have to be moved when we
|
||||
// support several toolkits, but IMO all the toolkits
|
||||
// should try to have the same kind of check. This could
|
||||
// be done by having a CheckHeaderAndLib function in
|
||||
// all the toolkit implementations, this function is
|
||||
// responsible for notifing the user.
|
||||
// if (!CheckHeaderAndLib()) {
|
||||
// // header vs. lib version failed
|
||||
// return 1;
|
||||
// }
|
||||
int xforms_lib_version = fl_library_version(0, 0);
|
||||
if (xforms_include_version != xforms_lib_version) {
|
||||
lyxerr << "You are either running LyX with wrong "
|
||||
"version of a dynamic XForms library\n"
|
||||
"or you have build LyX with conflicting header "
|
||||
"and library (different\n"
|
||||
"versions of XForms). Sorry but there is no point "
|
||||
"in continuing executing LyX!" << endl;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void GUIRunTime::processEvents()
|
||||
{
|
||||
if (fl_do_forms() == FL_EVENT) {
|
||||
XEvent ev;
|
||||
fl_XNextEvent(&ev);
|
||||
lyxerr << "Received unhandled X11 event" << endl;
|
||||
lyxerr << "Type: 0x" << hex << ev.xany.type <<
|
||||
" Target: 0x" << hex << ev.xany.window << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GUIRunTime::runTime()
|
||||
{
|
||||
while (!finished) {
|
||||
if (fl_check_forms() == FL_EVENT) {
|
||||
XEvent ev;
|
||||
fl_XNextEvent(&ev);
|
||||
lyxerr << "Received unhandled X11 event" << endl;
|
||||
lyxerr << "Type: 0x" << hex << ev.xany.type <<
|
||||
" Target: 0x" << hex << ev.xany.window << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GUIRunTime::setDefaults()
|
||||
{
|
||||
FL_IOPT cntl;
|
||||
cntl.buttonFontSize = FL_NORMAL_SIZE;
|
||||
cntl.browserFontSize = FL_NORMAL_SIZE;
|
||||
cntl.labelFontSize = FL_NORMAL_SIZE;
|
||||
cntl.choiceFontSize = FL_NORMAL_SIZE;
|
||||
cntl.inputFontSize = FL_NORMAL_SIZE;
|
||||
cntl.menuFontSize = FL_NORMAL_SIZE;
|
||||
cntl.borderWidth = -1;
|
||||
cntl.vclass = FL_DefaultVisual;
|
||||
fl_set_defaults(FL_PDVisual
|
||||
| FL_PDButtonFontSize
|
||||
| FL_PDBrowserFontSize
|
||||
| FL_PDLabelFontSize
|
||||
| FL_PDChoiceFontSize
|
||||
| FL_PDInputFontSize
|
||||
| FL_PDMenuFontSize
|
||||
| FL_PDBorderWidth, &cntl);
|
||||
}
|
||||
|
||||
|
||||
LyXView * GUIRunTime::createMainView(int w, int h)
|
||||
{
|
||||
return new XFormsView(w, h);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Called by the graphics cache to connect the appropriate frontend
|
||||
// image loading routines to the LyX kernel.
|
||||
void GUIRunTime::initialiseGraphics()
|
||||
{
|
||||
using namespace grfx;
|
||||
|
||||
#ifdef USE_XFORMS_IMAGE_LOADER
|
||||
// connect the image loader based on the xforms library
|
||||
GImage::newImage.connect(boost::bind(&xformsGImage::newImage));
|
||||
GImage::loadableFormats.connect(boost::bind(&xformsGImage::loadableFormats));
|
||||
#else
|
||||
// connect the image loader based on the XPM library
|
||||
GImage::newImage.connect(boost::bind(&GImageXPM::newImage));
|
||||
GImage::loadableFormats.connect(boost::bind(&GImageXPM::loadableFormats));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Display * GUIRunTime::x11Display()
|
||||
{
|
||||
return fl_get_display();
|
||||
}
|
||||
|
||||
|
||||
int GUIRunTime::x11Screen()
|
||||
{
|
||||
return fl_screen;
|
||||
}
|
||||
|
||||
|
||||
Colormap GUIRunTime::x11Colormap()
|
||||
{
|
||||
return fl_state[fl_get_vclass()].colormap;
|
||||
}
|
||||
|
||||
|
||||
int GUIRunTime::x11VisualDepth()
|
||||
{
|
||||
return fl_get_visual_depth();
|
||||
}
|
||||
|
||||
float GUIRunTime::getScreenDPI()
|
||||
{
|
||||
Screen * scr = ScreenOfDisplay(fl_get_display(), fl_screen);
|
||||
return ((HeightOfScreen(scr) * 25.4 / HeightMMOfScreen(scr)) +
|
||||
(WidthOfScreen(scr) * 25.4 / WidthMMOfScreen(scr))) / 2;
|
||||
}
|
@ -197,9 +197,9 @@ libxforms_la_SOURCES = \
|
||||
form_url.h \
|
||||
FormVCLog.C \
|
||||
FormVCLog.h \
|
||||
GUIRunTime.C \
|
||||
input_validators.C \
|
||||
input_validators.h \
|
||||
lyx_gui.C \
|
||||
lyxlookup.C \
|
||||
lyxlookup.h \
|
||||
MathsSymbols.C \
|
||||
@ -231,13 +231,6 @@ libxforms_la_SOURCES = \
|
||||
$(XFORMSGIMAGE) xformsBC.C \
|
||||
xformsBC.h
|
||||
|
||||
# These still have to be added. Sooner or later. ARRae-20000411
|
||||
# GUI_defaults.C \
|
||||
# GUI_initialize.C \
|
||||
# GUI_postlyxrc.C \
|
||||
# GUI_runtime.C \
|
||||
# GUI_applymenu.C
|
||||
|
||||
libxforms.la: $(libxforms_la_OBJECTS) $(libxforms_la_DEPENDENCIES)
|
||||
|
||||
# for convenience only
|
||||
|
@ -93,20 +93,26 @@ int XFormsView::atCloseMainFormCB(FL_FORM *, void *)
|
||||
}
|
||||
|
||||
|
||||
void XFormsView::setPosition(int x, int y)
|
||||
void XFormsView::show(int x, int y, string const & title)
|
||||
{
|
||||
fl_set_form_position(getForm(), x, y);
|
||||
}
|
||||
|
||||
|
||||
void XFormsView::show(int place, int border, string const & title)
|
||||
{
|
||||
fl_set_form_minsize(getForm(), getForm()->w, getForm()->h);
|
||||
fl_show_form(getForm(), place, border, title.c_str());
|
||||
FL_FORM * form = getForm();
|
||||
|
||||
fl_set_form_minsize(form, form->w, form->h);
|
||||
|
||||
int placement = FL_PLACE_CENTER | FL_FREE_SIZE;
|
||||
|
||||
// Did we get a valid geometry position ?
|
||||
if (x >= 0 && y >= 0) {
|
||||
fl_set_form_position(form, x, y);
|
||||
placement = FL_PLACE_POSITION;
|
||||
}
|
||||
|
||||
fl_show_form(form, placement, FL_FULLBORDER, title.c_str());
|
||||
|
||||
getLyXFunc()->initMiniBuffer();
|
||||
#if FL_VERSION < 1 && (FL_REVISION < 89 || (FL_REVISION == 89 && FL_FIXLEVEL < 5))
|
||||
InitLyXLookup(fl_get_display(), getForm()->window);
|
||||
#endif
|
||||
InitLyXLookup(fl_get_display(), form_->window);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -31,10 +31,15 @@ public:
|
||||
XFormsView(int w, int h);
|
||||
|
||||
~XFormsView();
|
||||
/// Where to place the form.
|
||||
virtual void setPosition(int, int);
|
||||
/// Show the main form.
|
||||
virtual void show(int, int, string const & t = string("LyX"));
|
||||
|
||||
/**
|
||||
* show - display the top-level window
|
||||
* @param xpos requested x position (or 0)
|
||||
* @param xpos requested y position (or 0)
|
||||
* @param title window title
|
||||
*/
|
||||
void show(int xpos, int ypos, string const & t = string("LyX"));
|
||||
|
||||
/// init (should probably be removed later) (Lgb)
|
||||
virtual void init();
|
||||
/// get the xforms main form
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include "encoding.h"
|
||||
#include "language.h"
|
||||
|
||||
#include "frontends/GUIRunTime.h"
|
||||
#include "graphics/GraphicsImage.h"
|
||||
|
||||
#include "support/LAssert.h"
|
||||
@ -43,7 +42,7 @@ namespace {
|
||||
inline
|
||||
Display * display()
|
||||
{
|
||||
return GUIRunTime::x11Display();
|
||||
return fl_get_display();
|
||||
}
|
||||
|
||||
}
|
||||
|
306
src/frontends/xforms/lyx_gui.C
Normal file
306
src/frontends/xforms/lyx_gui.C
Normal file
@ -0,0 +1,306 @@
|
||||
/**
|
||||
* \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 "lyx_gui.h"
|
||||
|
||||
#include "support/lyxlib.h"
|
||||
#include "support/os.h"
|
||||
#include "support/filetools.h"
|
||||
|
||||
#include "debug.h"
|
||||
#include "gettext.h"
|
||||
|
||||
#include "lyx_main.h"
|
||||
#include "lyxrc.h"
|
||||
|
||||
// FIXME: move this stuff out again
|
||||
#include "bufferlist.h"
|
||||
#include "lyxfunc.h"
|
||||
#include "lyxserver.h"
|
||||
#include "BufferView.h"
|
||||
#include "XFormsView.h"
|
||||
|
||||
#include FORMS_H_LOCATION
|
||||
#include "ColorHandler.h"
|
||||
#include "xforms_helpers.h"
|
||||
#ifdef USE_XFORMS_IMAGE_LOADER
|
||||
#include "xformsGImage.h"
|
||||
#else
|
||||
#include "graphics/GraphicsImageXPM.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
using std::vector;
|
||||
using std::hex;
|
||||
using std::endl;
|
||||
|
||||
extern bool finished;
|
||||
extern BufferList bufferlist;
|
||||
|
||||
// FIXME: wrong place !
|
||||
LyXServer * lyxserver;
|
||||
|
||||
namespace {
|
||||
|
||||
/// set default GUI configuration
|
||||
void setDefaults()
|
||||
{
|
||||
FL_IOPT cntl;
|
||||
cntl.buttonFontSize = FL_NORMAL_SIZE;
|
||||
cntl.browserFontSize = FL_NORMAL_SIZE;
|
||||
cntl.labelFontSize = FL_NORMAL_SIZE;
|
||||
cntl.choiceFontSize = FL_NORMAL_SIZE;
|
||||
cntl.inputFontSize = FL_NORMAL_SIZE;
|
||||
cntl.menuFontSize = FL_NORMAL_SIZE;
|
||||
cntl.borderWidth = -1;
|
||||
cntl.vclass = FL_DefaultVisual;
|
||||
fl_set_defaults(FL_PDVisual
|
||||
| FL_PDButtonFontSize
|
||||
| FL_PDBrowserFontSize
|
||||
| FL_PDLabelFontSize
|
||||
| FL_PDChoiceFontSize
|
||||
| FL_PDInputFontSize
|
||||
| FL_PDMenuFontSize
|
||||
| FL_PDBorderWidth, &cntl);
|
||||
}
|
||||
|
||||
|
||||
extern "C" {
|
||||
|
||||
int LyX_XErrHandler(Display * display, XErrorEvent * xeev) {
|
||||
// We don't abort on BadWindow
|
||||
if (xeev->error_code == BadWindow) {
|
||||
lyxerr << "BadWindow received !" << endl;
|
||||
lyxerr << "If you're using xforms 1.0 or greater, "
|
||||
<< " please report this to lyx-devel@lists.lyx.org" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// emergency cleanup
|
||||
LyX::emergencyCleanup();
|
||||
|
||||
// Get the reason for the crash.
|
||||
char etxt[513];
|
||||
XGetErrorText(display, xeev->error_code, etxt, 512);
|
||||
lyxerr << etxt << " id: " << xeev->resourceid << endl;
|
||||
// By doing an abort we get a nice backtrace. (hopefully)
|
||||
lyx::abort();
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// read in geometry specification
|
||||
char geometry[40];
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
||||
void lyx_gui::parse_init(int & argc, char * argv[])
|
||||
{
|
||||
setDefaults();
|
||||
|
||||
FL_CMD_OPT cmdopt[] = {
|
||||
{"-geometry", "*.geometry", XrmoptionSepArg, "690x510"}
|
||||
};
|
||||
|
||||
FL_resource res[] = {
|
||||
{"geometry", "geometryClass", FL_STRING, geometry, "", 40}
|
||||
};
|
||||
|
||||
const int num_res = sizeof(res)/sizeof(FL_resource);
|
||||
|
||||
fl_initialize(&argc, argv, "LyX", cmdopt, num_res);
|
||||
|
||||
// It appears that, in xforms >=0.89.5, fl_initialize()
|
||||
// calls setlocale() and ruins our LC_NUMERIC setting.
|
||||
locale_init();
|
||||
|
||||
fl_get_app_resources(res, num_res);
|
||||
|
||||
Display * display = fl_get_display();
|
||||
|
||||
if (!display) {
|
||||
lyxerr << "LyX: unable to access X display, exiting" << endl;
|
||||
os::warn("Unable to access X display, exiting");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
fcntl(ConnectionNumber(display), F_SETFD, FD_CLOEXEC);
|
||||
|
||||
XSetErrorHandler(LyX_XErrHandler);
|
||||
|
||||
lyxColorHandler.reset(new LyXColorHandler());
|
||||
}
|
||||
|
||||
|
||||
void lyx_gui::parse_lyxrc()
|
||||
{
|
||||
// FIXME !!!!
|
||||
lyxrc.dpi = 95;
|
||||
|
||||
XformsColor::read(AddName(user_lyxdir, "preferences.xform"));
|
||||
|
||||
if (lyxrc.popup_font_encoding.empty())
|
||||
lyxrc.popup_font_encoding = lyxrc.font_norm;
|
||||
// Set the font name for popups and menus
|
||||
string boldfontname = lyxrc.popup_bold_font
|
||||
+ "-*-*-*-?-*-*-*-*-"
|
||||
+ lyxrc.popup_font_encoding;
|
||||
// "?" means "scale that font"
|
||||
string fontname = lyxrc.popup_normal_font
|
||||
+ "-*-*-*-?-*-*-*-*-"
|
||||
+ lyxrc.popup_font_encoding;
|
||||
|
||||
int bold = fl_set_font_name(FL_BOLD_STYLE, boldfontname.c_str());
|
||||
int normal = fl_set_font_name(FL_NORMAL_STYLE, fontname.c_str());
|
||||
if (bold < 0)
|
||||
lyxerr << "Could not set menu font to "
|
||||
<< boldfontname << endl;
|
||||
|
||||
if (normal < 0)
|
||||
lyxerr << "Could not set popup font to "
|
||||
<< fontname << endl;
|
||||
|
||||
if (bold < 0 && normal < 0) {
|
||||
lyxerr << "Using 'helvetica' font for menus" << endl;
|
||||
boldfontname = "-*-helvetica-bold-r-*-*-*-?-*-*-*-*-iso8859-1";
|
||||
fontname = "-*-helvetica-medium-r-*-*-*-?-*-*-*-*-iso8859-1";
|
||||
bold = fl_set_font_name(FL_BOLD_STYLE, boldfontname.c_str());
|
||||
normal = fl_set_font_name(FL_NORMAL_STYLE, fontname.c_str());
|
||||
|
||||
if (bold < 0 && normal < 0) {
|
||||
lyxerr << "Could not find helvetica font. Using 'fixed'." << endl;
|
||||
fl_set_font_name(FL_NORMAL_STYLE, "fixed");
|
||||
normal = bold = 0;
|
||||
}
|
||||
}
|
||||
if (bold < 0)
|
||||
fl_set_font_name(FL_BOLD_STYLE, fontname.c_str());
|
||||
else if (normal < 0)
|
||||
fl_set_font_name(FL_NORMAL_STYLE, boldfontname.c_str());
|
||||
|
||||
fl_setpup_fontstyle(FL_NORMAL_STYLE);
|
||||
fl_setpup_fontsize(FL_NORMAL_SIZE);
|
||||
fl_setpup_color(FL_MCOL, FL_BLACK);
|
||||
fl_set_goodies_font(FL_NORMAL_STYLE, FL_NORMAL_SIZE);
|
||||
#if FL_REVISION < 89
|
||||
fl_set_oneliner_font(FL_NORMAL_STYLE, FL_NORMAL_SIZE);
|
||||
#else
|
||||
fl_set_tooltip_font(FL_NORMAL_STYLE, FL_NORMAL_SIZE);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
|
||||
static const int geometryBitmask =
|
||||
XParseGeometry(geometry,
|
||||
&xpos, &ypos, &width, &height);
|
||||
|
||||
// if width is not set by geometry, check it against monitor width
|
||||
if (!(geometryBitmask & 4)) {
|
||||
Screen * scr = ScreenOfDisplay(fl_get_display(), fl_screen);
|
||||
if (WidthOfScreen(scr) - 8 < int(width))
|
||||
width = WidthOfScreen(scr) - 8;
|
||||
}
|
||||
|
||||
// if height is not set by geometry, check it against monitor height
|
||||
if (!(geometryBitmask & 8)) {
|
||||
Screen * scr = ScreenOfDisplay(fl_get_display(), fl_screen);
|
||||
if (HeightOfScreen(scr) - 24 < int(height))
|
||||
height = HeightOfScreen(scr) - 24;
|
||||
}
|
||||
|
||||
Screen * s = ScreenOfDisplay(fl_get_display(), fl_screen);
|
||||
|
||||
// recalculate xpos if it's not set
|
||||
if (xpos == -1)
|
||||
xpos = (WidthOfScreen(s) - width) / 2;
|
||||
|
||||
// recalculate ypos if it's not set
|
||||
if (ypos == -1)
|
||||
ypos = (HeightOfScreen(s) - height) / 2;
|
||||
|
||||
lyxerr[Debug::GUI] << "Creating view: " << width << "x" << height
|
||||
<< "+" << xpos << "+" << ypos << endl;
|
||||
|
||||
XFormsView 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);
|
||||
}
|
||||
|
||||
// enter the event loop
|
||||
while (!finished) {
|
||||
if (fl_check_forms() == FL_EVENT) {
|
||||
XEvent ev;
|
||||
fl_XNextEvent(&ev);
|
||||
lyxerr << "Received unhandled X11 event" << endl;
|
||||
lyxerr << "Type: 0x" << hex << ev.xany.type <<
|
||||
" Target: 0x" << hex << ev.xany.window << endl;
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME
|
||||
delete lyxserver;
|
||||
}
|
||||
|
||||
|
||||
// Called by the graphics cache to connect the appropriate frontend
|
||||
// image loading routines to the LyX kernel.
|
||||
void lyx_gui::init_graphics()
|
||||
{
|
||||
using namespace grfx;
|
||||
|
||||
#ifdef USE_XFORMS_IMAGE_LOADER
|
||||
// connect the image loader based on the xforms library
|
||||
GImage::newImage.connect(boost::bind(&xformsGImage::newImage));
|
||||
GImage::loadableFormats.connect(boost::bind(&xformsGImage::loadableFormats));
|
||||
#else
|
||||
// connect the image loader based on the XPM library
|
||||
GImage::newImage.connect(boost::bind(&GImageXPM::newImage));
|
||||
GImage::loadableFormats.connect(boost::bind(&GImageXPM::loadableFormats));
|
||||
#endif
|
||||
}
|
@ -22,7 +22,8 @@
|
||||
#include "lyxrc.h" // lyxrc.font_*
|
||||
#include "BufferView.h"
|
||||
#include "frontends/LyXView.h"
|
||||
#include "frontends/GUIRunTime.h"
|
||||
|
||||
#include FORMS_H_LOCATION
|
||||
|
||||
using std::endl;
|
||||
|
||||
@ -84,7 +85,7 @@ void xfont_loader::unload()
|
||||
}
|
||||
for (int i4 = 0; i4 < 10; ++i4) {
|
||||
if (fontstruct[i1][i2][i3][i4]) {
|
||||
XFreeFont(GUIRunTime::x11Display(), fontstruct[i1][i2][i3][i4]);
|
||||
XFreeFont(fl_get_display(), fontstruct[i1][i2][i3][i4]);
|
||||
fontstruct[i1][i2][i3][i4] = 0;
|
||||
}
|
||||
}
|
||||
@ -294,14 +295,14 @@ XFontStruct * xfont_loader::doLoad(LyXFont::FONT_FAMILY family,
|
||||
|
||||
current_view->owner()->messagePush(_("Loading font into X-Server..."));
|
||||
|
||||
fs = XLoadQueryFont(GUIRunTime::x11Display(), font.c_str());
|
||||
fs = XLoadQueryFont(fl_get_display(), font.c_str());
|
||||
|
||||
if (fs == 0) {
|
||||
if (font == "fixed") {
|
||||
lyxerr << "We're doomed. Can't get 'fixed' font." << endl;
|
||||
} else {
|
||||
lyxerr << "Could not get font. Using 'fixed'." << endl;
|
||||
fs = XLoadQueryFont(GUIRunTime::x11Display(), "fixed");
|
||||
fs = XLoadQueryFont(fl_get_display(), "fixed");
|
||||
}
|
||||
} else if (lyxerr.debugging(Debug::FONT)) {
|
||||
// Tell user the font matching
|
||||
|
@ -1,3 +1,10 @@
|
||||
2002-06-12 John Levon <moz@compsoc.man.ac.uk>
|
||||
|
||||
* GraphicsCache.C: use lyx_gui namespace
|
||||
|
||||
* GraphicsImageXPM.C: back down to using xforms
|
||||
directly again
|
||||
|
||||
2002-06-07 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
Fixes needed to compile with Compaq cxx 6.5.
|
||||
|
@ -18,8 +18,7 @@
|
||||
#include "GraphicsImage.h"
|
||||
#include "GraphicsParams.h"
|
||||
#include "insets/insetgraphics.h"
|
||||
#include "frontends/GUIRunTime.h"
|
||||
|
||||
#include "frontends/lyx_gui.h"
|
||||
|
||||
namespace grfx {
|
||||
|
||||
@ -28,7 +27,7 @@ GCache & GCache::get()
|
||||
static bool start = true;
|
||||
if (start) {
|
||||
start = false;
|
||||
GUIRunTime::initialiseGraphics();
|
||||
lyx_gui::init_graphics();
|
||||
}
|
||||
|
||||
// Now return the cache
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include "GraphicsParams.h"
|
||||
#include "frontends/xforms/ColorHandler.h"
|
||||
#include "debug.h"
|
||||
#include "frontends/GUIRunTime.h" // x11Display, x11Screen
|
||||
#include "support/filetools.h" // IsFileReadable
|
||||
#include "support/lstrings.h"
|
||||
#include "Lsstream.h"
|
||||
@ -25,6 +24,8 @@
|
||||
#include <cmath> // cos, sin
|
||||
#include <cstdlib> // malloc, free
|
||||
|
||||
#include FORMS_H_LOCATION
|
||||
|
||||
#ifndef CXX_GLOBAL_CSTD
|
||||
using std::cos;
|
||||
using std::sin;
|
||||
@ -70,7 +71,7 @@ GImageXPM::GImageXPM(GImageXPM const & other)
|
||||
GImageXPM::~GImageXPM()
|
||||
{
|
||||
if (pixmap_)
|
||||
XFreePixmap(GUIRunTime::x11Display(), pixmap_);
|
||||
XFreePixmap(fl_get_display(), pixmap_);
|
||||
}
|
||||
|
||||
|
||||
@ -160,14 +161,14 @@ bool GImageXPM::setPixmap(GParams const & params)
|
||||
return false;
|
||||
}
|
||||
|
||||
Display * display = GUIRunTime::x11Display();
|
||||
Display * display = fl_get_display();
|
||||
|
||||
if (pixmap_ && pixmap_status_ == PIXMAP_SUCCESS)
|
||||
XFreePixmap(display, pixmap_);
|
||||
|
||||
//(BE 2000-08-05)
|
||||
// This might be a dirty thing, but I dont know any other solution.
|
||||
Screen * screen = ScreenOfDisplay(display, GUIRunTime::x11Screen());
|
||||
Screen * screen = ScreenOfDisplay(display, fl_screen);
|
||||
|
||||
Pixmap pixmap;
|
||||
Pixmap mask;
|
||||
@ -611,8 +612,8 @@ void mapcolor(char const * c_color, char ** g_color_ptr, char ** m_color_ptr)
|
||||
// Already filled.
|
||||
return;
|
||||
|
||||
Display * display = GUIRunTime::x11Display();
|
||||
Colormap cmap = GUIRunTime::x11Colormap();
|
||||
Display * display = fl_get_display();
|
||||
Colormap cmap = fl_colormap;
|
||||
XColor xcol;
|
||||
XColor ccol;
|
||||
if (XLookupColor(display, cmap, c_color, &xcol, &ccol) == 0)
|
||||
|
312
src/lyx_gui.C
312
src/lyx_gui.C
@ -1,312 +0,0 @@
|
||||
/* This file is part of
|
||||
* ======================================================
|
||||
*
|
||||
* LyX, The Document Processor
|
||||
*
|
||||
* Copyright 1995 Matthias Ettrich
|
||||
* Copyright 1995-2001 The LyX Team.
|
||||
*
|
||||
* ====================================================== */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
||||
#include "lyx_gui.h"
|
||||
#include FORMS_H_LOCATION
|
||||
#include "tex-strings.h"
|
||||
#include "lyx_main.h"
|
||||
#include "debug.h"
|
||||
#include "version.h"
|
||||
#include "frontends/LyXView.h"
|
||||
#include "buffer.h"
|
||||
#include "BufferView.h"
|
||||
#include "lyxserver.h"
|
||||
#include "lyxrc.h"
|
||||
#include "gettext.h"
|
||||
#if FL_VERSION < 1 && (FL_REVISION < 89 || (FL_REVISION == 89 && FL_FIXLEVEL < 5))
|
||||
#include "frontends/xforms/lyxlookup.h"
|
||||
#endif
|
||||
#include "bufferlist.h"
|
||||
#include "frontends/xforms/ColorHandler.h"
|
||||
|
||||
#include "frontends/GUIRunTime.h"
|
||||
#include "frontends/xforms/xforms_helpers.h" // for XformColor
|
||||
|
||||
#include "support/filetools.h"
|
||||
#include "support/os.h"
|
||||
#include "support/lyxlib.h"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <fcntl.h>
|
||||
|
||||
#ifndef CXX_GLOBAL_CSTD
|
||||
using std::exit;
|
||||
#endif
|
||||
|
||||
using std::endl;
|
||||
|
||||
extern LyXServer * lyxserver;
|
||||
extern bool finished; // flag, that we are quitting the program
|
||||
extern BufferList bufferlist;
|
||||
extern string user_lyxdir;
|
||||
|
||||
FL_CMD_OPT cmdopt[] =
|
||||
{
|
||||
{"-geometry", "*.geometry", XrmoptionSepArg, "690x510"}
|
||||
};
|
||||
|
||||
namespace {
|
||||
|
||||
int width = 690;
|
||||
int height = 510;
|
||||
int xpos = -1;
|
||||
int ypos = -1;
|
||||
char geometry[40];
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
||||
FL_resource res[] =
|
||||
{
|
||||
{"geometry", "geometryClass", FL_STRING, geometry, "", 40}
|
||||
};
|
||||
|
||||
|
||||
extern "C" {
|
||||
|
||||
static
|
||||
int LyX_XErrHandler(Display * display, XErrorEvent * xeev)
|
||||
{
|
||||
// We don't abort on BadWindow
|
||||
if (xeev->error_code == BadWindow) {
|
||||
lyxerr << "BadWindow received !" << endl;
|
||||
lyxerr << "If you're using xforms 1.0 or greater, "
|
||||
<< " please report this to lyx-devel@lists.lyx.org" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// emergency cleanup
|
||||
LyX::emergencyCleanup();
|
||||
|
||||
// Get the reason for the crash.
|
||||
char etxt[513];
|
||||
XGetErrorText(display, xeev->error_code, etxt, 512);
|
||||
lyxerr << etxt << " id: " << xeev->resourceid << endl;
|
||||
// By doing an abort we get a nice backtrace. (hopefully)
|
||||
lyx::abort();
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
LyXGUI::LyXGUI(LyX * owner, int * argc, char * argv[], bool GUI)
|
||||
: _owner(owner), lyxViews(0)
|
||||
{
|
||||
gui = GUI;
|
||||
if (!gui)
|
||||
return;
|
||||
|
||||
//
|
||||
setDefaults();
|
||||
|
||||
static const int num_res = sizeof(res)/sizeof(FL_resource);
|
||||
fl_initialize(argc, argv, "LyX", cmdopt, num_res);
|
||||
// It appears that, in xforms >=0.89.5, fl_initialize()
|
||||
// calls setlocale() and ruins our LC_NUMERIC setting.
|
||||
locale_init();
|
||||
fl_get_app_resources(res, num_res);
|
||||
|
||||
static const int geometryBitmask =
|
||||
XParseGeometry(geometry,
|
||||
&xpos,
|
||||
&ypos,
|
||||
reinterpret_cast<unsigned int *>(&width),
|
||||
reinterpret_cast<unsigned int *>(&height));
|
||||
|
||||
Display * display = fl_get_display();
|
||||
if (!display) {
|
||||
lyxerr << "LyX: unable to access X display, exiting" << endl;
|
||||
os::warn("Unable to access X display, exiting");
|
||||
exit(1);
|
||||
}
|
||||
fcntl(ConnectionNumber(display), F_SETFD, FD_CLOEXEC);
|
||||
// X Error handler install goes here
|
||||
XSetErrorHandler(LyX_XErrHandler);
|
||||
|
||||
// A width less than 590 pops up an awkward main window
|
||||
// The minimal values of width/height (590/400) are defined in
|
||||
// src/lyx.C
|
||||
if (width < 590) width = 590;
|
||||
if (height < 400) height = 400;
|
||||
|
||||
// If width is not set by geometry, check it against monitor width
|
||||
if (!(geometryBitmask & 4)) {
|
||||
Screen * scr = ScreenOfDisplay(fl_get_display(), fl_screen);
|
||||
if (WidthOfScreen(scr) - 8 < width)
|
||||
width = WidthOfScreen(scr) - 8;
|
||||
}
|
||||
|
||||
// If height is not set by geometry, check it against monitor height
|
||||
if (!(geometryBitmask & 8)) {
|
||||
Screen * scr = ScreenOfDisplay(fl_get_display(), fl_screen);
|
||||
if (HeightOfScreen(scr) - 24 < height)
|
||||
height = HeightOfScreen(scr) - 24;
|
||||
}
|
||||
|
||||
// Recalculate xpos if it's negative
|
||||
if (geometryBitmask & 16)
|
||||
xpos += WidthOfScreen(ScreenOfDisplay(fl_get_display(),
|
||||
fl_screen)) - width;
|
||||
|
||||
// Recalculate ypos if it's negative
|
||||
if (geometryBitmask & 32)
|
||||
ypos += HeightOfScreen(ScreenOfDisplay(fl_get_display(),
|
||||
fl_screen)) - height;
|
||||
|
||||
// Initialize the LyXColorHandler
|
||||
lyxColorHandler.reset(new LyXColorHandler);
|
||||
}
|
||||
|
||||
|
||||
// A destructor is always necessary (asierra-970604)
|
||||
LyXGUI::~LyXGUI()
|
||||
{
|
||||
// Lyxserver was created in this class so should be destroyed
|
||||
// here. asierra-970604
|
||||
delete lyxserver;
|
||||
lyxserver = 0;
|
||||
delete lyxViews;
|
||||
#if FL_VERSION < 1 && (FL_REVISION < 89 || (FL_REVISION == 89 && FL_FIXLEVEL < 5))
|
||||
CloseLyXLookup();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void LyXGUI::setDefaults()
|
||||
{
|
||||
GUIRunTime::setDefaults();
|
||||
}
|
||||
|
||||
|
||||
// This is called after we have parsed lyxrc
|
||||
void LyXGUI::init()
|
||||
{
|
||||
if (!gui)
|
||||
return;
|
||||
|
||||
create_forms();
|
||||
|
||||
if (lyxrc.popup_font_encoding.empty())
|
||||
lyxrc.popup_font_encoding = lyxrc.font_norm;
|
||||
// Set the font name for popups and menus
|
||||
string boldfontname = lyxrc.popup_bold_font
|
||||
+ "-*-*-*-?-*-*-*-*-"
|
||||
+ lyxrc.popup_font_encoding;
|
||||
// "?" means "scale that font"
|
||||
string fontname = lyxrc.popup_normal_font
|
||||
+ "-*-*-*-?-*-*-*-*-"
|
||||
+ lyxrc.popup_font_encoding;
|
||||
|
||||
int bold = fl_set_font_name(FL_BOLD_STYLE, boldfontname.c_str());
|
||||
int normal = fl_set_font_name(FL_NORMAL_STYLE, fontname.c_str());
|
||||
if (bold < 0)
|
||||
lyxerr << "Could not set menu font to "
|
||||
<< boldfontname << endl;
|
||||
|
||||
if (normal < 0)
|
||||
lyxerr << "Could not set popup font to "
|
||||
<< fontname << endl;
|
||||
|
||||
if (bold < 0 && normal < 0) {
|
||||
lyxerr << "Using 'helvetica' font for menus" << endl;
|
||||
boldfontname = "-*-helvetica-bold-r-*-*-*-?-*-*-*-*-iso8859-1";
|
||||
fontname = "-*-helvetica-medium-r-*-*-*-?-*-*-*-*-iso8859-1";
|
||||
bold = fl_set_font_name(FL_BOLD_STYLE, boldfontname.c_str());
|
||||
normal = fl_set_font_name(FL_NORMAL_STYLE, fontname.c_str());
|
||||
|
||||
if (bold < 0 && normal < 0) {
|
||||
lyxerr << "Could not find helvetica font. Using 'fixed'." << endl;
|
||||
fl_set_font_name(FL_NORMAL_STYLE, "fixed");
|
||||
normal = bold = 0;
|
||||
}
|
||||
}
|
||||
if (bold < 0)
|
||||
fl_set_font_name(FL_BOLD_STYLE, fontname.c_str());
|
||||
else if (normal < 0)
|
||||
fl_set_font_name(FL_NORMAL_STYLE, boldfontname.c_str());
|
||||
|
||||
// put here (after fl_initialize) to avoid segfault. Cannot be done
|
||||
// in setDefaults() (Matthias 140496)
|
||||
// Moved from ::LyXGUI to ::init to allow popup font customization
|
||||
// (petr 120997).
|
||||
fl_setpup_fontstyle(FL_NORMAL_STYLE);
|
||||
fl_setpup_fontsize(FL_NORMAL_SIZE);
|
||||
fl_setpup_color(FL_MCOL, FL_BLACK);
|
||||
fl_set_goodies_font(FL_NORMAL_STYLE, FL_NORMAL_SIZE);
|
||||
#if FL_VERSION < 1 && FL_REVISION < 89
|
||||
fl_set_oneliner_font(FL_NORMAL_STYLE, FL_NORMAL_SIZE);
|
||||
#else
|
||||
fl_set_tooltip_font(FL_NORMAL_STYLE, FL_NORMAL_SIZE);
|
||||
#endif
|
||||
|
||||
// all lyxrc settings has to be done here as lyxrc has not yet
|
||||
// been read when the GUI is created (Jug)
|
||||
|
||||
// Update parameters.
|
||||
lyxViews->redraw();
|
||||
|
||||
// Initialize the views.
|
||||
lyxViews->init();
|
||||
|
||||
// this should be moved ...
|
||||
lyxserver = new LyXServer(lyxViews->getLyXFunc(), lyxrc.lyxpipes);
|
||||
}
|
||||
|
||||
|
||||
void LyXGUI::create_forms()
|
||||
{
|
||||
lyxerr[Debug::INIT] << "Initializing LyXView..." << endl;
|
||||
lyxViews = GUIRunTime::createMainView(width, height);
|
||||
lyxerr[Debug::INIT] << "Initializing LyXView...done" << endl;
|
||||
|
||||
// From here down should be done by somebody else. (Lgb)
|
||||
|
||||
// This is probably as good a time as any to map the xform colours,
|
||||
// should a mapping exist.
|
||||
string const filename = AddName(user_lyxdir, "preferences.xform");
|
||||
XformsColor::read(filename);
|
||||
|
||||
// Show the main & title form
|
||||
int main_placement = FL_PLACE_CENTER | FL_FREE_SIZE;
|
||||
// Did we get a valid position?
|
||||
if (xpos >= 0 && ypos >= 0) {
|
||||
lyxViews->setPosition(xpos, ypos);
|
||||
main_placement = FL_PLACE_POSITION;
|
||||
}
|
||||
|
||||
lyxViews->show(main_placement, FL_FULLBORDER, "LyX");
|
||||
}
|
||||
|
||||
|
||||
void LyXGUI::runTime()
|
||||
{
|
||||
if (!gui) return;
|
||||
|
||||
GUIRunTime::runTime();
|
||||
}
|
||||
|
||||
|
||||
void LyXGUI::regBuf(Buffer * b)
|
||||
{
|
||||
lyxViews->view()->buffer(b);
|
||||
}
|
||||
|
||||
|
||||
LyXView * LyXGUI::getLyXView() const
|
||||
{
|
||||
return lyxViews;
|
||||
}
|
@ -1,71 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/* This file is part of
|
||||
* ======================================================
|
||||
*
|
||||
* LyX, The Document Processor
|
||||
*
|
||||
* Copyright 1995 Matthias Ettrich
|
||||
* Copyright 1995-2001 The LyX Team.
|
||||
*
|
||||
* ====================================================== */
|
||||
|
||||
#ifndef LYX_GUI_H
|
||||
#define LYX_GUI_H
|
||||
|
||||
#include <boost/utility.hpp>
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
class LyXView;
|
||||
class LyX;
|
||||
class Buffer;
|
||||
|
||||
/**
|
||||
This class is going to be the entry point to {\em all} GUI funcionality.
|
||||
From this object will all the things going on be initiated. However I
|
||||
have not clearly figured out how this class is going to be, suggestions
|
||||
are welcome. (Lgb)
|
||||
*/
|
||||
class LyXGUI : boost::noncopyable {
|
||||
public:
|
||||
/** The only constructor allowed.
|
||||
If gui is false, LyX will operate in non-X mode
|
||||
*/
|
||||
LyXGUI(LyX * owner, int * argc, char * argv[], bool gui);
|
||||
///
|
||||
~LyXGUI();
|
||||
|
||||
/**
|
||||
This functions starts the ball. For XForms it runs a loop of
|
||||
fl_check_forms(). For QT this will probably be .exec().
|
||||
*/
|
||||
void runTime();
|
||||
/** This will take care of the initializaton done after the
|
||||
main initialization.
|
||||
*/
|
||||
void init();
|
||||
|
||||
/// Register the buffer with the first found LyXView in lyxViews
|
||||
void regBuf(Buffer *);
|
||||
|
||||
/// Access to (first?) LyXView
|
||||
LyXView * getLyXView() const;
|
||||
|
||||
private:
|
||||
///
|
||||
void setDefaults();
|
||||
///
|
||||
void create_forms();
|
||||
|
||||
/// The LyX that owns this GUI.
|
||||
LyX * _owner;
|
||||
///
|
||||
LyXView * lyxViews; // or something so that several views
|
||||
// on the same time can be allowed.
|
||||
/// Do we have a gui?
|
||||
bool gui;
|
||||
};
|
||||
|
||||
#endif
|
153
src/lyx_main.C
153
src/lyx_main.C
@ -14,38 +14,35 @@
|
||||
#endif
|
||||
|
||||
#include "lyx_main.h"
|
||||
#include "lyx_gui.h"
|
||||
#include "frontends/LyXView.h"
|
||||
#include "lyxfunc.h"
|
||||
#include "lyxrc.h"
|
||||
#include "buffer.h"
|
||||
#include "bufferlist.h"
|
||||
|
||||
#include "support/filetools.h"
|
||||
#include "support/lyxlib.h"
|
||||
#include "support/os.h"
|
||||
#include "support/FileInfo.h"
|
||||
#include "support/path.h"
|
||||
#include "debug.h"
|
||||
#include "lastfiles.h"
|
||||
#include "intl.h"
|
||||
#include "lyxserver.h"
|
||||
//#include "layout.h"
|
||||
#include "lyxtextclasslist.h"
|
||||
#include "gettext.h"
|
||||
#include "kbmap.h"
|
||||
#include "MenuBackend.h"
|
||||
#include "ToolbarDefaults.h"
|
||||
#include "lyxlex.h"
|
||||
|
||||
#include "bufferlist.h"
|
||||
#include "lyxtextclasslist.h"
|
||||
#include "lyxserver.h"
|
||||
#include "kbmap.h"
|
||||
#include "lyxfunc.h"
|
||||
#include "ToolbarDefaults.h"
|
||||
#include "MenuBackend.h"
|
||||
#include "language.h"
|
||||
#include "lastfiles.h"
|
||||
#include "encoding.h"
|
||||
#include "converter.h"
|
||||
#include "language.h"
|
||||
|
||||
#include "frontends/Alert.h"
|
||||
#include "frontends/GUIRunTime.h"
|
||||
|
||||
#include "support/path.h"
|
||||
#include "support/filetools.h"
|
||||
#include "support/FileInfo.h"
|
||||
#include "support/os.h"
|
||||
#include "frontends/lyx_gui.h"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <csignal>
|
||||
|
||||
using std::vector;
|
||||
using std::endl;
|
||||
|
||||
#ifndef CXX_GLOBAL_CSTD
|
||||
@ -57,6 +54,8 @@ using std::system;
|
||||
extern void LoadLyXFile(string const &);
|
||||
extern void QuitLyX();
|
||||
|
||||
extern LyXServer * lyxserver;
|
||||
|
||||
string system_lyxdir;
|
||||
string build_lyxdir;
|
||||
string system_tempdir;
|
||||
@ -69,7 +68,6 @@ boost::scoped_ptr<LastFiles> lastfiles;
|
||||
// This is the global bufferlist object
|
||||
BufferList bufferlist;
|
||||
|
||||
LyXServer * lyxserver = 0;
|
||||
// this should be static, but I need it in buffer.C
|
||||
bool finished = false; // flag, that we are quitting the program
|
||||
|
||||
@ -77,26 +75,23 @@ bool finished = false; // flag, that we are quitting the program
|
||||
boost::scoped_ptr<kb_keymap> toplevel_keymap;
|
||||
|
||||
|
||||
LyX::LyX(int * argc, char * argv[])
|
||||
LyX::LyX(int & argc, char * argv[])
|
||||
{
|
||||
// Here we need to parse the command line. At least
|
||||
// we need to parse for "-dbg" and "-help"
|
||||
bool gui = easyParse(argc, argv);
|
||||
bool const want_gui = easyParse(argc, argv);
|
||||
|
||||
// Global bindings (this must be done as early as possible.) (Lgb)
|
||||
toplevel_keymap.reset(new kb_keymap);
|
||||
defaultKeyBindings(toplevel_keymap.get());
|
||||
|
||||
// Make the GUI object, and let it take care of the
|
||||
// command line arguments that concerns it.
|
||||
lyxerr[Debug::INIT] << "Initializing LyXGUI..." << endl;
|
||||
lyxGUI.reset(new LyXGUI(this, argc, argv, gui));
|
||||
lyxerr[Debug::INIT] << "Initializing LyXGUI...done" << endl;
|
||||
if (want_gui) {
|
||||
lyx_gui::parse_init(argc, argv);
|
||||
}
|
||||
|
||||
// Now the GUI and LyX have taken care of their arguments, so
|
||||
// the only thing left on the command line should be
|
||||
// filenames. Let's check anyway.
|
||||
for (int argi = 1; argi < *argc ; ++argi) {
|
||||
// check for any spurious extra arguments
|
||||
// other than documents
|
||||
for (int argi = 1; argi < argc ; ++argi) {
|
||||
if (argv[argi][0] == '-') {
|
||||
lyxerr << _("Wrong command line option `")
|
||||
<< argv[argi]
|
||||
@ -107,46 +102,27 @@ LyX::LyX(int * argc, char * argv[])
|
||||
|
||||
// Initialization of LyX (reads lyxrc and more)
|
||||
lyxerr[Debug::INIT] << "Initializing LyX::init..." << endl;
|
||||
init(gui);
|
||||
init(want_gui);
|
||||
lyxerr[Debug::INIT] << "Initializing LyX::init...done" << endl;
|
||||
|
||||
lyxGUI->init();
|
||||
if (want_gui) {
|
||||
lyx_gui::parse_lyxrc();
|
||||
}
|
||||
|
||||
// Load the files specified in the command line.
|
||||
if ((*argc) == 2)
|
||||
lyxerr[Debug::INFO] << "Opening document..." << endl;
|
||||
else if ((*argc) > 2)
|
||||
lyxerr[Debug::INFO] << "Opening documents..." << endl;
|
||||
vector<string> files;
|
||||
|
||||
Buffer * last_loaded = 0;
|
||||
|
||||
for (int argi = (*argc) - 1; argi >= 1; --argi) {
|
||||
Buffer * loadb = bufferlist.loadLyXFile(argv[argi]);
|
||||
if (loadb != 0) {
|
||||
last_loaded = loadb;
|
||||
}
|
||||
for (int argi = argc - 1; argi >= 1; --argi) {
|
||||
files.push_back(argv[argi]);
|
||||
}
|
||||
|
||||
if (first_start) {
|
||||
string const splash =
|
||||
i18nLibFileSearch("examples", "splash.lyx");
|
||||
lyxerr[Debug::INIT] << "Opening splash document "
|
||||
<< splash << "..." << endl;
|
||||
Buffer * loadb = bufferlist.loadLyXFile(splash);
|
||||
if (loadb != 0) {
|
||||
last_loaded = loadb;
|
||||
}
|
||||
files.push_back(i18nLibFileSearch("examples", "splash.lyx"));
|
||||
}
|
||||
|
||||
if (last_loaded != 0) {
|
||||
lyxerr[Debug::INIT] << "Yes we loaded some files." << endl;
|
||||
if (lyxrc.use_gui)
|
||||
lyxGUI->regBuf(last_loaded);
|
||||
}
|
||||
|
||||
|
||||
#if 0 // FIXME: GUII
|
||||
// Execute batch commands if available
|
||||
if (!batch_command.empty()) {
|
||||
lyxerr << "About to handle -x '"
|
||||
lyxerr[Debug::INIT] << "About to handle -x '"
|
||||
<< batch_command << "'" << endl;
|
||||
|
||||
// no buffer loaded, create one
|
||||
@ -156,27 +132,20 @@ LyX::LyX(int * argc, char * argv[])
|
||||
bool success = false;
|
||||
|
||||
// try to dispatch to last loaded buffer first
|
||||
bool dispatched = last_loaded->dispatch(batch_command, &success);
|
||||
bool const dispatched = last_loaded->dispatch(batch_command, &success);
|
||||
|
||||
// if this was successful, return.
|
||||
// Maybe we could do something more clever than aborting...
|
||||
// if this was successful, finish
|
||||
if (dispatched) {
|
||||
QuitLyX();
|
||||
exit(!success);
|
||||
}
|
||||
|
||||
// otherwise, let the GUI handle the batch command
|
||||
lyxGUI->regBuf(last_loaded);
|
||||
lyxGUI->getLyXView()->getLyXFunc()->verboseDispatch(batch_command, false);
|
||||
|
||||
// fall through...
|
||||
}
|
||||
#endif
|
||||
|
||||
// Let the ball begin...
|
||||
lyxGUI->runTime();
|
||||
lyx_gui::start(batch_command, files);
|
||||
}
|
||||
|
||||
|
||||
|
||||
extern "C" {
|
||||
|
||||
static
|
||||
@ -441,15 +410,6 @@ void LyX::init(bool gui)
|
||||
if (!gui)
|
||||
lyxrc.use_gui = false;
|
||||
|
||||
// Calculate screen dpi as average of x-DPI and y-DPI:
|
||||
if (lyxrc.use_gui) {
|
||||
lyxrc.dpi = GUIRunTime::getScreenDPI();
|
||||
lyxerr[Debug::INIT] << "DPI setting detected to be "
|
||||
<< lyxrc.dpi + 0.5 << endl;
|
||||
} else {
|
||||
lyxrc.dpi = 1; // I hope this is safe
|
||||
}
|
||||
|
||||
//
|
||||
// Read configuration files
|
||||
//
|
||||
@ -503,11 +463,6 @@ void LyX::init(bool gui)
|
||||
lastfiles.reset(new LastFiles(lyxrc.lastfiles,
|
||||
lyxrc.check_lastfiles,
|
||||
lyxrc.num_lastfiles));
|
||||
|
||||
// start up the lyxserver. (is this a bit early?) (Lgb)
|
||||
// 0.12 this will be way to early, we need the GUI to be initialized
|
||||
// first, so move it for now.
|
||||
// lyxserver = new LyXServer;
|
||||
}
|
||||
|
||||
|
||||
@ -813,16 +768,16 @@ void commandLineVersionInfo()
|
||||
} // namespace anon
|
||||
|
||||
|
||||
bool LyX::easyParse(int * argc, char * argv[])
|
||||
bool LyX::easyParse(int & argc, char * argv[])
|
||||
{
|
||||
bool gui = true;
|
||||
int removeargs = 0; // used when options are read
|
||||
for (int i = 1; i < *argc; ++i) {
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
string arg = argv[i];
|
||||
|
||||
// Check for -dbg int
|
||||
if (arg == "-dbg") {
|
||||
if (i + 1 < *argc) {
|
||||
if (i + 1 < argc) {
|
||||
setDebuggingLevel(argv[i + 1]);
|
||||
removeargs = 2;
|
||||
} else {
|
||||
@ -834,7 +789,7 @@ bool LyX::easyParse(int * argc, char * argv[])
|
||||
}
|
||||
// Check for "-sysdir"
|
||||
else if (arg == "-sysdir") {
|
||||
if (i + 1 < *argc) {
|
||||
if (i + 1 < argc) {
|
||||
system_lyxdir = argv[i + 1];
|
||||
removeargs = 2;
|
||||
} else {
|
||||
@ -845,7 +800,7 @@ bool LyX::easyParse(int * argc, char * argv[])
|
||||
}
|
||||
// Check for "-userdir"
|
||||
else if (arg == "-userdir") {
|
||||
if (i + 1 < *argc) {
|
||||
if (i + 1 < argc) {
|
||||
user_lyxdir = argv[i + 1];
|
||||
removeargs = 2;
|
||||
} else {
|
||||
@ -873,7 +828,7 @@ bool LyX::easyParse(int * argc, char * argv[])
|
||||
|
||||
// Check for "-x": Execute commands
|
||||
else if (arg == "-x" || arg == "--execute") {
|
||||
if (i + 1 < *argc) {
|
||||
if (i + 1 < argc) {
|
||||
batch_command = string(argv[i + 1]);
|
||||
removeargs = 2;
|
||||
}
|
||||
@ -886,7 +841,7 @@ bool LyX::easyParse(int * argc, char * argv[])
|
||||
}
|
||||
|
||||
else if (arg == "-e" || arg == "--export") {
|
||||
if (i + 1 < *argc) {
|
||||
if (i + 1 < argc) {
|
||||
string type(argv[i+1]);
|
||||
removeargs = 2;
|
||||
batch_command = "buffer-export " + type;
|
||||
@ -899,7 +854,7 @@ bool LyX::easyParse(int * argc, char * argv[])
|
||||
}
|
||||
}
|
||||
else if (arg == "-i" || arg == "--import") {
|
||||
if (i + 1 < *argc) {
|
||||
if (i + 1 < argc) {
|
||||
if (!argv[i+2]) {
|
||||
lyxerr << _("Missing filename for --import") << endl;
|
||||
exit(1);
|
||||
@ -924,8 +879,8 @@ bool LyX::easyParse(int * argc, char * argv[])
|
||||
if (removeargs > 0) {
|
||||
// Now, remove used arguments by shifting
|
||||
// the following ones removeargs places down.
|
||||
(*argc) -= removeargs;
|
||||
for (int j = i; j < (*argc); ++j)
|
||||
argc -= removeargs;
|
||||
for (int j = i; j < argc; ++j)
|
||||
argv[j] = argv[j + removeargs];
|
||||
--i; // After shift, check this number again.
|
||||
removeargs = 0;
|
||||
|
@ -21,13 +21,12 @@
|
||||
|
||||
#include <csignal>
|
||||
|
||||
class LyXGUI;
|
||||
class LyXRC;
|
||||
class LastFiles;
|
||||
class Buffer;
|
||||
class kb_keymap;
|
||||
|
||||
|
||||
|
||||
///
|
||||
extern string user_lyxdir;
|
||||
///
|
||||
@ -36,18 +35,16 @@ extern string system_lyxdir;
|
||||
extern string system_tempdir;
|
||||
///
|
||||
extern boost::scoped_ptr<LastFiles> lastfiles;
|
||||
|
||||
|
||||
|
||||
class LyX : boost::noncopyable {
|
||||
public:
|
||||
LyX(int * argc, char * argv[]);
|
||||
LyX(int & argc, char * argv[]);
|
||||
|
||||
/// in the case of failure
|
||||
static void emergencyCleanup();
|
||||
|
||||
private:
|
||||
/// Should be a maximum of 1 LyXGUI.
|
||||
boost::scoped_ptr<LyXGUI> lyxGUI;
|
||||
/// does this user start lyx for the first time?
|
||||
bool first_start;
|
||||
///
|
||||
@ -73,7 +70,7 @@ private:
|
||||
/// Read the encodings file `name'
|
||||
void readEncodingsFile(string const & name);
|
||||
///
|
||||
bool easyParse(int * argc, char * argv[]);
|
||||
bool easyParse(int & argc, char * argv[]);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
26
src/main.C
26
src/main.C
@ -1,30 +1,22 @@
|
||||
/* This file is part of
|
||||
* ======================================================
|
||||
/**
|
||||
* \file main.C
|
||||
* Copyright 2002 the LyX Team
|
||||
* Read the file COPYING
|
||||
*
|
||||
* LyX, The Document Processor
|
||||
*
|
||||
* Copyright 1995 Matthias Ettrich
|
||||
* Copyright 1995-2001 The LyX Team.
|
||||
*
|
||||
* ====================================================== */
|
||||
* \author unknown
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "lyx_main.h"
|
||||
#include "gettext.h"
|
||||
#include "LString.h"
|
||||
#include "lyx_gui.h"
|
||||
#include "support/filetools.h"
|
||||
#include "support/os.h"
|
||||
#include "frontends/GUIRunTime.h"
|
||||
|
||||
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
os::init(&argc, &argv);
|
||||
int const val = GUIRunTime::initApplication(argc, argv);
|
||||
if (val)
|
||||
return val;
|
||||
|
||||
// lyx_localedir is used by gettext_init() is we have
|
||||
// i18n support built-in
|
||||
@ -36,6 +28,6 @@ int main(int argc, char * argv[])
|
||||
locale_init();
|
||||
gettext_init(lyx_localedir);
|
||||
|
||||
LyX lyx(&argc, argv);
|
||||
return 0; // SUCCESS
|
||||
LyX lyx(argc, argv);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user