]> git.lyx.org Git - lyx.git/blob - src/frontends/kde/GUIRunTime.C
main.C now GUII.
[lyx.git] / src / frontends / kde / 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 "GUIRunTime.h"
17 #include "debug.h"
18
19 #include <kapp.h>
20
21 #include FORMS_H_LOCATION
22
23 using std::endl;
24
25 // For now we need this here as long as we use xforms components!
26
27 // I keep these here so that it will be processed as early in
28 // the compilation process as possible.
29 #if !defined(FL_REVISION) || FL_REVISION < 88 || FL_VERSION != 0
30 #error LyX will not compile with this version of XForms.\
31        Please get version 0.89.\
32        If you want to try to compile anyway, delete this test in src/frontends/kde/GUIRunTime.C.
33 #endif
34
35 extern bool finished;
36
37 static int const xforms_include_version = FL_INCLUDE_VERSION;
38
39 int GUIRunTime::initApplication(int argc, char * argv[])
40 {
41         // Check the XForms version in the forms.h header against
42         // the one in the libforms. If they don't match quit the
43         // execution of LyX. Better with a clean fast exit than
44         // a strange segfault later.
45         // I realize that this check have to be moved when we
46         // support several toolkits, but IMO all the toolkits
47         // should try to have the same kind of check. This could
48         // be done by having a CheckHeaderAndLib function in
49         // all the toolkit implementations, this function is
50         // responsible for notifing the user.
51         // if (!CheckHeaderAndLib()) {
52         //         // header vs. lib version failed
53         //         return 1;
54         // }
55         int xforms_lib_version = fl_library_version(0, 0);
56         if (xforms_include_version != xforms_lib_version) {
57                 cerr << "You are either running LyX with wrong "
58                         "version of a dynamic XForms library\n"
59                         "or you have build LyX with conflicting header "
60                         "and library (different\n"
61                         "versions of XForms. Sorry but there is no point "
62                         "in continuing executing LyX!" << endl;
63                 return 1;
64         }
65
66         static KApplication a(argc, argv);
67
68         return 0;
69 }
70
71 void GUIRunTime::processEvents() 
72 {
73         kapp->processEvents();
74 }
75
76
77 void GUIRunTime::runTime()
78 {
79         // We still use xforms event handler as the main one...
80         XEvent ev;
81         while (!finished) {
82                 processEvents();
83                 if (fl_check_forms() == FL_EVENT) {
84                         lyxerr << "LyX: This shouldn't happen..." << endl;
85                         fl_XNextEvent(&ev);
86                 }
87         }
88 }