1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 2000-2001 The LyX Team.
8 *======================================================*/
12 #include FORMS_H_LOCATION
15 #pragma implementation
18 #include "GUIRunTime.h"
19 #include "XFormsView.h"
22 // I keep these here so that it will be processed as early in
23 // the compilation process as possible.
24 #if !defined(FL_REVISION) || FL_REVISION < 88 || FL_VERSION != 0
25 #error LyX will not compile with this version of XForms.\
26 Please get version 0.89.\
27 If you want to try to compile anyway, delete this test in src/frontends/xforms/GUIRunTime.C.
36 int const xforms_include_version = FL_INCLUDE_VERSION;
41 int GUIRunTime::initApplication(int &, char **)
43 // Check the XForms version in the forms.h header against
44 // the one in the libforms. If they don't match quit the
45 // execution of LyX. Better with a clean fast exit than
46 // a strange segfault later.
47 // I realize that this check have to be moved when we
48 // support several toolkits, but IMO all the toolkits
49 // should try to have the same kind of check. This could
50 // be done by having a CheckHeaderAndLib function in
51 // all the toolkit implementations, this function is
52 // responsible for notifing the user.
53 // if (!CheckHeaderAndLib()) {
54 // // header vs. lib version failed
57 int xforms_lib_version = fl_library_version(0, 0);
58 if (xforms_include_version != xforms_lib_version) {
59 lyxerr << "You are either running LyX with wrong "
60 "version of a dynamic XForms library\n"
61 "or you have build LyX with conflicting header "
62 "and library (different\n"
63 "versions of XForms. Sorry but there is no point "
64 "in continuing executing LyX!" << endl;
71 void GUIRunTime::processEvents()
73 if (fl_do_forms() == FL_EVENT) {
76 lyxerr << "Received unhandled X11 event" << endl;
77 lyxerr << "Type: 0x" << std::hex << ev.xany.type <<
78 "Target: 0x" << std::hex << ev.xany.window << endl;
83 void GUIRunTime::runTime()
86 if (fl_check_forms() == FL_EVENT) {
89 lyxerr << "Received unhandled X11 event" << endl;
90 lyxerr << "Type: 0x" << std::hex << ev.xany.type <<
91 "Target: 0x" << std::hex << ev.xany.window << endl;
97 void GUIRunTime::setDefaults()
100 cntl.buttonFontSize = FL_NORMAL_SIZE;
101 cntl.browserFontSize = FL_NORMAL_SIZE;
102 cntl.labelFontSize = FL_NORMAL_SIZE;
103 cntl.choiceFontSize = FL_NORMAL_SIZE;
104 cntl.inputFontSize = FL_NORMAL_SIZE;
105 cntl.menuFontSize = FL_NORMAL_SIZE;
106 cntl.borderWidth = -1;
107 cntl.vclass = FL_DefaultVisual;
108 fl_set_defaults(FL_PDVisual
109 | FL_PDButtonFontSize
110 | FL_PDBrowserFontSize
112 | FL_PDChoiceFontSize
115 | FL_PDBorderWidth, &cntl);
119 LyXView * GUIRunTime::createMainView(int w, int h)
121 return new XFormsView(w, h);
125 Display * GUIRunTime::x11Display()
127 return fl_get_display();
131 int GUIRunTime::x11Screen()
137 Colormap GUIRunTime::x11Colormap()
139 return fl_state[fl_get_vclass()].colormap;
143 int GUIRunTime::x11VisualDepth()
145 return fl_get_visual_depth();