]> git.lyx.org Git - features.git/blob - src/frontends/xforms/GUIRunTime.C
to much stuff for my liking...
[features.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
31 using std::endl;
32 using std::hex;
33
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 &, char **)
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         return 0;
71 }
72
73
74 void GUIRunTime::processEvents() 
75 {
76         if (fl_do_forms() == FL_EVENT) {
77                 XEvent ev;
78                 fl_XNextEvent(&ev);
79                 lyxerr << "Received unhandled X11 event" << endl;
80                 lyxerr << "Type: 0x" << hex << ev.xany.type <<
81                         "Target: 0x" << hex << ev.xany.window << endl;
82         }
83 }
84
85
86 void GUIRunTime::runTime()
87 {
88         while (!finished) {
89                 if (fl_check_forms() == FL_EVENT) {
90                         XEvent ev;
91                         fl_XNextEvent(&ev);
92                         lyxerr << "Received unhandled X11 event" << endl;
93                         lyxerr << "Type: 0x" << hex << ev.xany.type <<
94                                 "Target: 0x" << hex << ev.xany.window << endl;
95                 }
96         }
97 }
98
99
100 void GUIRunTime::setDefaults()
101 {
102         FL_IOPT cntl;
103         cntl.buttonFontSize = FL_NORMAL_SIZE;
104         cntl.browserFontSize = FL_NORMAL_SIZE;
105         cntl.labelFontSize = FL_NORMAL_SIZE;
106         cntl.choiceFontSize = FL_NORMAL_SIZE;
107         cntl.inputFontSize = FL_NORMAL_SIZE;
108         cntl.menuFontSize  = FL_NORMAL_SIZE;
109         cntl.borderWidth = -1;
110         cntl.vclass = FL_DefaultVisual;
111         fl_set_defaults(FL_PDVisual
112                         | FL_PDButtonFontSize
113                         | FL_PDBrowserFontSize
114                         | FL_PDLabelFontSize
115                         | FL_PDChoiceFontSize
116                         | FL_PDInputFontSize
117                         | FL_PDMenuFontSize
118                         | FL_PDBorderWidth, &cntl);
119 }
120
121
122 LyXView * GUIRunTime::createMainView(int w, int h)
123 {
124         return new XFormsView(w, h);
125 }
126
127
128 Display * GUIRunTime::x11Display()
129 {
130         return fl_get_display();
131 }
132
133
134 int GUIRunTime::x11Screen()
135 {
136         return fl_screen;
137 }
138
139
140 Colormap GUIRunTime::x11Colormap()
141 {
142         return fl_state[fl_get_vclass()].colormap;
143 }
144
145
146 int GUIRunTime::x11VisualDepth()
147 {
148         return fl_get_visual_depth();
149 }
150
151 float GUIRunTime::getScreenDPI()
152 {
153         Screen * scr = ScreenOfDisplay(fl_get_display(), fl_screen);
154         return ((HeightOfScreen(scr) * 25.4 / HeightMMOfScreen(scr)) +
155                 (WidthOfScreen(scr) * 25.4 / WidthMMOfScreen(scr))) / 2;
156 }