]> git.lyx.org Git - lyx.git/blob - src/frontends/gnome/GUIRunTime.C
small patch from Dekel, begin introducing the real boost framework, get rid of the...
[lyx.git] / src / frontends / gnome / 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
18 #include "GUIRunTime.h"
19 #include "debug.h"
20
21 #include <gnome--/main.h>
22 #include "mainapp.h"
23
24 using std::endl;
25
26 // I keep these here so that it will be processed as early in
27 // the compilation process as possible.
28 #if !defined(FL_REVISION) || FL_REVISION < 88 || FL_VERSION != 0
29 #error LyX will not compile with this version of XForms.\
30        Please get version 0.89.\
31        If you want to try to compile anyway, delete this test in src/frontends/gnome/GUIRunTime.C.
32 #endif
33
34 extern bool finished;
35
36 static int const xforms_include_version = FL_INCLUDE_VERSION;
37 GLyxAppWin * mainAppWin;
38
39 int GUIRunTime::initApplication(int, 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         // I belive that this should be done at a later stage, in
67         // lyx_gui, the same place as xforms does the same. (Lgb)
68         static string app_id(PACKAGE);
69         static string app_version(VERSION);
70         static Gnome::Main  a(app_id, app_version, 1, argv);
71         static GLyxAppWin   appWin;
72         mainAppWin = &appWin;
73
74         return 0;
75 }
76
77 void GUIRunTime::processEvents() 
78 {
79         while(Gnome::Main::instance()->events_pending())
80                 Gnome::Main::instance()->iteration(FALSE);
81 }
82
83
84 void GUIRunTime::runTime()
85 {
86         XEvent ev;
87         while (!finished) {
88                 processEvents();
89                 if (fl_check_forms() == FL_EVENT) {
90                         lyxerr << "LyX: This shouldn't happen..." << endl;
91                         fl_XNextEvent(&ev);
92                 }
93         }
94 }
95
96
97 void GUIRunTime::setDefaults()
98 {
99         FL_IOPT cntl;
100         cntl.buttonFontSize = FL_NORMAL_SIZE;
101         cntl.browserFontSize = FL_NORMAL_SIZE;
102         cntl.labelFontSize = FL_NORMAL_SIZE;
103         cntl.choiceFontSize = FL_NORMAL_SIZE;
104         cntl.inputFontSize = FL_NORMAL_SIZE;
105         cntl.menuFontSize  = FL_NORMAL_SIZE;
106         cntl.borderWidth = -1;
107         cntl.vclass = FL_DefaultVisual;
108         fl_set_defaults(FL_PDVisual
109                         | FL_PDButtonFontSize
110                         | FL_PDBrowserFontSize
111                         | FL_PDLabelFontSize
112                         | FL_PDChoiceFontSize
113                         | FL_PDInputFontSize
114                         | FL_PDMenuFontSize
115                         | FL_PDBorderWidth, &cntl);
116 }