]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/GUIRunTime.C
More pref work from Angus
[lyx.git] / src / frontends / xforms / GUIRunTime.C
1 /* This file is part of
2  * ======================================================
3  * 
4  *           LyX, The Document Processor
5  *       
6  *           Copyright 2000 The LyX Team.
7  *
8  *======================================================*/
9
10 #include <config.h>
11
12 #ifdef __GNUG__
13 #pragma implementation
14 #endif
15
16 #include FORMS_H_LOCATION
17 #include "GUIRunTime.h"
18 #include "debug.h"
19
20 // I keep these here so that it will be processed as early in
21 // the compilation process as possible.
22 #if !defined(FL_REVISION) || FL_REVISION < 88 || FL_VERSION != 0
23 #error LyX will not compile with this version of XForms.\
24        Please get version 0.89.\
25        If you want to try to compile anyway, delete this test in src/frontends/xforms/GUIRunTime.C.
26 #endif
27
28 using std::endl;
29
30 extern bool finished;
31
32 static int const xforms_include_version = FL_INCLUDE_VERSION;
33
34 int GUIRunTime::initApplication(int , char **)
35 {
36         // Check the XForms version in the forms.h header against
37         // the one in the libforms. If they don't match quit the
38         // execution of LyX. Better with a clean fast exit than
39         // a strange segfault later.
40         // I realize that this check have to be moved when we
41         // support several toolkits, but IMO all the toolkits
42         // should try to have the same kind of check. This could
43         // be done by having a CheckHeaderAndLib function in
44         // all the toolkit implementations, this function is
45         // responsible for notifing the user.
46         // if (!CheckHeaderAndLib()) {
47         //         // header vs. lib version failed
48         //         return 1;
49         // }
50         int xforms_lib_version = fl_library_version(0, 0);
51         if (xforms_include_version != xforms_lib_version) {
52                 lyxerr << "You are either running LyX with wrong "
53                         "version of a dynamic XForms library\n"
54                         "or you have build LyX with conflicting header "
55                         "and library (different\n"
56                         "versions of XForms. Sorry but there is no point "
57                         "in continuing executing LyX!" << endl;
58                 return 1;
59         }
60         return 0;
61 }
62
63
64 void GUIRunTime::processEvents() 
65 {
66         XEvent ev;
67
68         if (fl_do_forms() == FL_EVENT) {
69                 lyxerr << "LyX: This shouldn't happen..." << endl;
70                 fl_XNextEvent(&ev);
71         }
72 }
73
74
75 void GUIRunTime::runTime()
76 {
77         XEvent ev;
78         while (!finished) {
79                 if (fl_check_forms() == FL_EVENT) {
80                         lyxerr << "LyX: This shouldn't happen..." << endl;
81                         fl_XNextEvent(&ev);
82                 }
83         }
84 }
85
86
87 void GUIRunTime::setDefaults()
88 {
89         FL_IOPT cntl;
90         cntl.buttonFontSize = FL_NORMAL_SIZE;
91         cntl.browserFontSize = FL_NORMAL_SIZE;
92         cntl.labelFontSize = FL_NORMAL_SIZE;
93         cntl.choiceFontSize = FL_NORMAL_SIZE;
94         cntl.inputFontSize = FL_NORMAL_SIZE;
95         cntl.menuFontSize  = FL_NORMAL_SIZE;
96         cntl.borderWidth = -1;
97         cntl.vclass = FL_DefaultVisual;
98         fl_set_defaults(FL_PDVisual
99                         | FL_PDButtonFontSize
100                         | FL_PDBrowserFontSize
101                         | FL_PDLabelFontSize
102                         | FL_PDChoiceFontSize
103                         | FL_PDInputFontSize
104                         | FL_PDMenuFontSize
105                         | FL_PDBorderWidth, &cntl);
106 }