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