1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 2000 The LyX Team.
8 *======================================================*/
13 #pragma implementation
16 #include FORMS_H_LOCATION
18 #include "GUIRunTime.h"
21 #include <gnome--/main.h>
22 #include <glade/glade.h>
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.
38 int const xforms_include_version = FL_INCLUDE_VERSION;
43 int GUIRunTime::initApplication(int &, char * argv[])
45 // Check the XForms version in the forms.h header against
46 // the one in the libforms. If they don't match quit the
47 // execution of LyX. Better with a clean fast exit than
48 // a strange segfault later.
49 // I realize that this check have to be moved when we
50 // support several toolkits, but IMO all the toolkits
51 // should try to have the same kind of check. This could
52 // be done by having a CheckHeaderAndLib function in
53 // all the toolkit implementations, this function is
54 // responsible for notifing the user.
55 // if (!CheckHeaderAndLib()) {
56 // // header vs. lib version failed
59 int xforms_lib_version = fl_library_version(0, 0);
60 if (xforms_include_version != xforms_lib_version) {
61 cerr << "You are either running LyX with wrong "
62 "version of a dynamic XForms library\n"
63 "or you have build LyX with conflicting header "
64 "and library (different\n"
65 "versions of XForms. Sorry but there is no point "
66 "in continuing executing LyX!" << endl;
70 // I belive that this should be done at a later stage, in
71 // lyx_gui, the same place as xforms does the same. (Lgb)
72 string app_id(PACKAGE);
73 string app_version(VERSION);
74 static Gnome::Main a(app_id, app_version, 1, argv);
75 glade_gnome_init(); // Initialize the glade library.
80 void GUIRunTime::processEvents()
82 while (Gnome::Main::instance()->events_pending())
83 Gnome::Main::instance()->iteration(FALSE);
87 void GUIRunTime::runTime()
92 if (fl_check_forms() == FL_EVENT) {
94 lyxerr << "Received unhandled X11 event" << endl;
95 lyxerr << "Type: 0x" << hex << ev.xany.type <<
96 "Target: 0x" << hex << ev.xany.window << endl;
102 void GUIRunTime::setDefaults()
105 cntl.buttonFontSize = FL_NORMAL_SIZE;
106 cntl.browserFontSize = FL_NORMAL_SIZE;
107 cntl.labelFontSize = FL_NORMAL_SIZE;
108 cntl.choiceFontSize = FL_NORMAL_SIZE;
109 cntl.inputFontSize = FL_NORMAL_SIZE;
110 cntl.menuFontSize = FL_NORMAL_SIZE;
111 cntl.borderWidth = -1;
112 cntl.vclass = FL_DefaultVisual;
113 fl_set_defaults(FL_PDVisual
114 | FL_PDButtonFontSize
115 | FL_PDBrowserFontSize
117 | FL_PDChoiceFontSize
120 | FL_PDBorderWidth, &cntl);
124 #include "XFormsView.h"
125 LyXView * GUIRunTime::createMainView(int w, int h)
127 return new XFormsView(w, h);
131 Display * GUIRunTime::x11Display()
133 return fl_get_display();
137 int GUIRunTime::x11Screen()
143 Colormap GUIRunTime::x11Colormap()
145 return fl_state[fl_get_vclass()].colormap;
149 int GUIRunTime::x11VisualDepth()
151 return fl_get_visual_depth();
154 float GUIRunTime::getScreenDPI()
156 Screen * scr = ScreenOfDisplay(fl_get_display(), fl_screen);
157 return ((HeightOfScreen(scr) * 25.4 / HeightMMOfScreen(scr)) +
158 (WidthOfScreen(scr) * 25.4 / WidthMMOfScreen(scr))) / 2;