]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/GUIRunTime.C
implement getLabelList
[lyx.git] / src / frontends / qt2 / GUIRunTime.C
1 /* This file is part of
2  * ======================================================
3  * 
4  *           LyX, The Document Processor
5  *       
6  *           Copyright 2001 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 <qapplication.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/qt2/GUIRunTime.C.
33 #endif
34
35 extern bool finished;
36
37 namespace {
38
39 int const xforms_include_version = FL_INCLUDE_VERSION;
40
41 } // namespace anon
42
43
44 int GUIRunTime::initApplication(int argc, char * argv[])
45 {
46         // Check the XForms version in the forms.h header against
47         // the one in the libforms. If they don't match quit the
48         // execution of LyX. Better with a clean fast exit than
49         // a strange segfault later.
50         // I realize that this check have to be moved when we
51         // support several toolkits, but IMO all the toolkits
52         // should try to have the same kind of check. This could
53         // be done by having a CheckHeaderAndLib function in
54         // all the toolkit implementations, this function is
55         // responsible for notifing the user.
56         // if (!CheckHeaderAndLib()) {
57         //         // header vs. lib version failed
58         //         return 1;
59         // }
60         int xforms_lib_version = fl_library_version(0, 0);
61         if (xforms_include_version != xforms_lib_version) {
62                 lyxerr << "You are either running LyX with wrong "
63                         "version of a dynamic XForms library\n"
64                         "or you have build LyX with conflicting header "
65                         "and library (different\n"
66                         "versions of XForms. Sorry but there is no point "
67                         "in continuing executing LyX!" << endl;
68                 return 1;
69         }
70
71         // I belive this is done in the wrong place, imo this should
72         // be done in lyx_gui.C similar to how/where xforms does it (Lgb)
73         static QApplication a(argc, argv);
74
75         return 0;
76 }
77
78 void GUIRunTime::processEvents() 
79 {
80         qApp->processEvents();
81 }
82
83
84 void GUIRunTime::runTime()
85 {
86         // We still use xforms event handler as the main one...
87         XEvent ev;
88         while (!finished) {
89                 processEvents();
90                 if (fl_check_forms() == FL_EVENT) {
91                         lyxerr << "LyX: This shouldn't happen..." << endl;
92                         fl_XNextEvent(&ev);
93                 }
94         }
95 }
96
97
98 void GUIRunTime::setDefaults() 
99 {
100         FL_IOPT cntl;
101         cntl.buttonFontSize = FL_NORMAL_SIZE;
102         cntl.browserFontSize = FL_NORMAL_SIZE;
103         cntl.labelFontSize = FL_NORMAL_SIZE;
104         cntl.choiceFontSize = FL_NORMAL_SIZE;
105         cntl.inputFontSize = FL_NORMAL_SIZE;
106         cntl.menuFontSize  = FL_NORMAL_SIZE;
107         cntl.borderWidth = -1;
108         cntl.vclass = FL_DefaultVisual;
109         fl_set_defaults(FL_PDVisual
110                         | FL_PDButtonFontSize
111                         | FL_PDBrowserFontSize
112                         | FL_PDLabelFontSize
113                         | FL_PDChoiceFontSize
114                         | FL_PDInputFontSize
115                         | FL_PDMenuFontSize
116                         | FL_PDBorderWidth, &cntl);
117 }
118