]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/GUIRunTime.C
13dd471b58444c1a1d3d75e16dee4ed4ef99de3e
[lyx.git] / src / frontends / xforms / GUIRunTime.C
1 /* This file is part of
2  * ======================================================
3  * 
4  *           LyX, The Document Processor
5  *       
6  *           Copyright 2000-2001 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 "XFormsView.h"
20 #include "debug.h"
21
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.
28 #endif
29
30 using std::endl;
31
32 extern bool finished;
33
34 namespace {
35
36 int const xforms_include_version = FL_INCLUDE_VERSION;
37
38 } // namespace anon
39
40
41 int GUIRunTime::initApplication(int , char **)
42 {
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
55         //         return 1;
56         // }
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;
65                 return 1;
66         }
67         return 0;
68 }
69
70
71 void GUIRunTime::processEvents() 
72 {
73         XEvent ev;
74
75         if (fl_do_forms() == FL_EVENT) {
76                 lyxerr << "LyX: This shouldn't happen..." << endl;
77                 fl_XNextEvent(&ev);
78         }
79 }
80
81
82 void GUIRunTime::runTime()
83 {
84         XEvent ev;
85         while (!finished) {
86                 if (fl_check_forms() == FL_EVENT) {
87                         lyxerr << "LyX: This shouldn't happen..." << endl;
88                         fl_XNextEvent(&ev);
89                 }
90         }
91 }
92
93
94 void GUIRunTime::setDefaults()
95 {
96         FL_IOPT cntl;
97         cntl.buttonFontSize = FL_NORMAL_SIZE;
98         cntl.browserFontSize = FL_NORMAL_SIZE;
99         cntl.labelFontSize = FL_NORMAL_SIZE;
100         cntl.choiceFontSize = FL_NORMAL_SIZE;
101         cntl.inputFontSize = FL_NORMAL_SIZE;
102         cntl.menuFontSize  = FL_NORMAL_SIZE;
103         cntl.borderWidth = -1;
104         cntl.vclass = FL_DefaultVisual;
105         fl_set_defaults(FL_PDVisual
106                         | FL_PDButtonFontSize
107                         | FL_PDBrowserFontSize
108                         | FL_PDLabelFontSize
109                         | FL_PDChoiceFontSize
110                         | FL_PDInputFontSize
111                         | FL_PDMenuFontSize
112                         | FL_PDBorderWidth, &cntl);
113 }
114
115
116 LyXView * GUIRunTime::createMainView(int w, int h)
117 {
118         return new XFormsView(w, h);
119 }