]> git.lyx.org Git - features.git/blob - src/lyx_gui.C
1a731b82c87d5cbaebaa632264439d3f3d529d5a
[features.git] / src / lyx_gui.C
1 /* This file is part of
2  * ======================================================
3  * 
4  *           LyX, The Document Processor
5  *       
6  *          Copyright 1995 Matthias Ettrich
7  *          Copyright 1995-2000 The LyX Team.
8  *
9  * ====================================================== */
10
11 #include <config.h>
12 #include <cstdlib>
13
14 #ifdef __GNUG__
15 #pragma implementation
16 #endif
17
18 #ifdef KDEGUI
19 #    include <kapp.h>
20 #endif
21
22 #ifdef GTKGUI
23 #    include <gnome--/main.h>
24 #endif
25
26 #include <fcntl.h>
27 #include "lyx_gui.h"
28 #include FORMS_H_LOCATION
29 #include "support/filetools.h"
30 #include "combox.h"
31 #include "lyx.h"
32 #include "form1.h"
33 #include "layout_forms.h"
34 #include "print_form.h"
35 #include "tex-strings.h"
36 #include "lyx_main.h"
37 #include "log_form.h"
38 #include "debug.h"
39 #include "version.h"
40 #include "LyXView.h"
41 #include "buffer.h"
42 #include "lyxserver.h"
43 #include "lyxrc.h"
44 #include "gettext.h"
45 #include "lyx_gui_misc.h"
46 #include "lyxlookup.h"
47 #include "bufferlist.h"
48 #include "language.h"
49 #include "ColorHandler.h"
50
51 using std::endl;
52
53 FD_form_title * fd_form_title;
54 FD_form_paragraph * fd_form_paragraph;
55 FD_form_paragraph_extra * fd_form_paragraph_extra;
56 FD_form_character * fd_form_character;
57 FD_form_document * fd_form_document;
58 FD_form_paper * fd_form_paper;
59 FD_form_table_options * fd_form_table_options;
60 FD_form_table_extra * fd_form_table_extra;
61 FD_form_quotes * fd_form_quotes;
62 FD_form_preamble * fd_form_preamble;
63 FD_form_table * fd_form_table;
64 FD_form_sendto * fd_form_sendto;
65 FD_form_figure * fd_form_figure;
66 FD_form_screen * fd_form_screen;
67 FD_LaTeXLog * fd_latex_log; // from log_form.h
68 Combox * combo_language;
69 Combox * combo_language2;
70
71 extern LyXServer * lyxserver;
72 extern bool finished;   // flag, that we are quitting the program
73 extern BufferList bufferlist;
74
75 FL_CMD_OPT cmdopt[] =
76 {
77         {"-geometry", "*.geometry", XrmoptionSepArg, "690x510"}
78 };
79
80 static int width  = 690;
81 static int height = 510;
82 static int xpos   = -1;
83 static int ypos   = -1;
84 static char geometry[40];
85 bool       cursor_follows_scrollbar;
86
87
88 FL_resource res[] =
89 {
90         {"geometry", "geometryClass", FL_STRING, geometry, "", 40}
91 };
92
93
94 extern "C" int LyX_XErrHandler(Display * display, XErrorEvent * xeev)
95 {
96 //#warning Please see if you can trigger this!
97         // emergency save
98         if (!bufferlist.empty())
99                 bufferlist.emergencyWriteAll();
100
101         // Get the reason for the crash.
102         char etxt[513];
103         XGetErrorText(display, xeev->error_code, etxt, 512);
104         lyxerr << etxt << endl;
105         // By doing an abort we get a nice backtrace. (hopefully)
106         lyx::abort();
107         return 0; // Solaris CC wants us to return something
108 }
109
110
111 LyXGUI::LyXGUI(LyX * owner, int * argc, char * argv[], bool GUI)
112   : _owner(owner), lyxViews(0)
113 {
114         gui = GUI;
115         if (!gui)
116                 return;
117
118         setDefaults();
119         
120         static const int num_res = sizeof(res)/sizeof(FL_resource);
121         fl_initialize(argc, argv, "LyX", cmdopt, num_res);
122         fl_get_app_resources(res, num_res);
123
124         static const int geometryBitmask = XParseGeometry( geometry,
125                                                            &xpos,
126                                                            &ypos,
127                                                            (unsigned int *) &width,
128                                                            (unsigned int *) &height
129                                                          );
130
131         Display * display = fl_get_display();
132         if (!display) {
133                 lyxerr << "LyX: unable to access X display, exiting" << endl;
134                 exit(1);
135         }
136         fcntl(ConnectionNumber(display), F_SETFD, FD_CLOEXEC);
137         // X Error handler install goes here
138         XSetErrorHandler(LyX_XErrHandler);
139
140         // A width less than 590 pops up an awkward main window
141         // The minimal values of width/height (590/400) are defined in
142         // src/lyx.C  
143         if (width < 590) width = 590;
144         if (height < 400) height = 400;
145         
146         // If width is not set by geometry, check it against monitor width
147         if ( !(geometryBitmask & 4) ) {
148                 Screen * scr = DefaultScreenOfDisplay(fl_get_display());
149                 if (WidthOfScreen(scr) - 8 < width)
150                         width = WidthOfScreen(scr) - 8;
151         }
152
153         // If height is not set by geometry, check it against monitor height
154         if ( !(geometryBitmask & 8) ) {
155                 Screen * scr = DefaultScreenOfDisplay(fl_get_display());
156                 if (HeightOfScreen(scr) - 24 < height)
157                         height = HeightOfScreen(scr) - 24;
158         }
159
160         // Recalculate xpos if it's negative
161         if (geometryBitmask & 16)
162                 xpos += WidthOfScreen(DefaultScreenOfDisplay(fl_get_display())) - width;
163
164         // Recalculate ypos if it's negative
165         if (geometryBitmask & 32)
166                 ypos += HeightOfScreen(DefaultScreenOfDisplay(fl_get_display())) - height;
167
168         // Initialize the LyXColorHandler
169         lyxColorHandler = new LyXColorHandler;
170 }
171
172
173 // A destructor is always necessary  (asierra-970604)
174 LyXGUI::~LyXGUI()
175 {
176         // Lyxserver was created in this class so should be destroyed
177         // here.  asierra-970604
178         delete lyxserver;
179         lyxserver = 0;
180         delete lyxViews;
181         lyxViews = 0;
182
183         CloseLyXLookup();
184 }
185
186
187 void LyXGUI::setDefaults()
188 {
189         FL_IOPT cntl;
190         cntl.buttonFontSize = FL_NORMAL_SIZE;
191         cntl.browserFontSize = FL_NORMAL_SIZE;
192         cntl.labelFontSize = FL_NORMAL_SIZE;
193         cntl.choiceFontSize = FL_NORMAL_SIZE;
194         cntl.inputFontSize = FL_NORMAL_SIZE;
195         cntl.menuFontSize  = FL_NORMAL_SIZE;
196         cntl.borderWidth = -1;
197         cntl.vclass = FL_DefaultVisual;
198         fl_set_defaults(FL_PDVisual
199                         | FL_PDButtonFontSize
200                         | FL_PDBrowserFontSize
201                         | FL_PDLabelFontSize
202                         | FL_PDChoiceFontSize
203                         | FL_PDInputFontSize
204                         | FL_PDMenuFontSize
205                         | FL_PDBorderWidth, &cntl);
206 }
207
208
209 // This is called after we have parsed lyxrc
210 void LyXGUI::init()
211 {
212         if (!gui)
213                 return;
214
215         create_forms();
216
217         if (lyxrc.font_norm_menu.empty())
218                 lyxrc.font_norm_menu = lyxrc.font_norm;
219         // Set the font name for popups and menus
220         string menufontname = lyxrc.menu_font_name 
221                                + "-*-*-*-?-*-*-*-*-"  
222                                + lyxrc.font_norm_menu;
223                 // "?" means "scale that font"
224         string popupfontname = lyxrc.popup_font_name 
225                                + "-*-*-*-?-*-*-*-*-"  
226                                + lyxrc.font_norm_menu;
227
228         int bold = fl_set_font_name(FL_BOLD_STYLE, menufontname.c_str());
229         int normal = fl_set_font_name(FL_NORMAL_STYLE, popupfontname.c_str());
230         if (bold < 0)
231                 lyxerr << "Could not set menu font to "
232                        << menufontname << endl;
233
234         if (normal < 0)
235                 lyxerr << "Could not set popup font to "
236                        << popupfontname << endl;
237
238         if (bold < 0 && normal < 0) {
239                 lyxerr << "Using 'helvetica' font for menus" << endl;
240                 bold = fl_set_font_name(FL_BOLD_STYLE,
241                                         "-*-helvetica-bold-r-*-*-*-?-*-*-*-*-iso8859-1");
242                 normal = fl_set_font_name(FL_NORMAL_STYLE,
243                                           "-*-helvetica-medium-r-*-*-*-?-*-*-*-*-iso8859-1");
244                 if (bold < 0 && normal < 0) {
245                         lyxerr << "Could not find helvetica font. Using 'fixed'." << endl;
246                         normal = fl_set_font_name(FL_NORMAL_STYLE, "fixed");
247                 }
248         }
249
250         // put here (after fl_initialize) to avoid segfault. Cannot be done
251         // in setDefaults() (Matthias 140496)
252         // Moved from ::LyXGUI to ::init to allow popup font customization 
253         // (petr 120997).
254         fl_setpup_fontstyle(FL_NORMAL_STYLE);
255         fl_setpup_fontsize(FL_NORMAL_SIZE);
256         fl_setpup_color(FL_MCOL, FL_BLACK);
257         fl_set_goodies_font(FL_NORMAL_STYLE, FL_NORMAL_SIZE);
258
259         // all lyxrc settings has to be done here as lyxrc has not yet
260         // been read when the GUI is created (Jug)
261
262         // the sendto form
263         if (!lyxrc.custom_export_command.empty())
264                 fl_set_input(fd_form_sendto->input_cmd,
265                              lyxrc.custom_export_command.c_str());
266         if (lyxrc.custom_export_format == "lyx")
267                 fl_set_button(fd_form_sendto->radio_ftype_lyx, 1);
268         else if (lyxrc.custom_export_format == "tex")
269                 fl_set_button(fd_form_sendto->radio_ftype_latex, 1);
270         else if (lyxrc.custom_export_format == "dvi")
271                 fl_set_button(fd_form_sendto->radio_ftype_dvi, 1);
272         else if (lyxrc.custom_export_format == "ps")
273                 fl_set_button(fd_form_sendto->radio_ftype_ps, 1);
274         else if (lyxrc.custom_export_format == "ascii")
275                 fl_set_button(fd_form_sendto->radio_ftype_ascii, 1);
276
277         // Update parameters.
278         lyxViews->redraw();
279
280         // Initialize the views.
281         lyxViews->init();
282
283         // in 0.12 the initialisation of the LyXServer must be done here
284         // 0.13 it should be moved again...
285         lyxserver = new LyXServer(lyxViews->getLyXFunc(), lyxrc.lyxpipes);
286 }
287
288
289 void LyXGUI::create_forms()
290 {
291         lyxerr[Debug::INIT] << "Initializing LyXView..." << endl;
292         lyxViews = new LyXView(width, height);
293         lyxerr[Debug::INIT] << "Initializing LyXView...done" << endl;
294
295         // From here down should be done by somebody else. (Lgb)
296
297         //
298         // Create forms
299         //
300
301         // the title form
302         string banner_file = LibFileSearch("images", "banner", "xpm");
303         if (lyxrc.show_banner && !banner_file.empty()) {
304                 fd_form_title = create_form_form_title();
305                 fl_set_form_dblbuffer(fd_form_title->form_title, 1); // use dbl buffer
306                 fl_set_form_atclose(fd_form_title->form_title, CancelCloseBoxCB, 0);
307                 fl_addto_form(fd_form_title->form_title);
308                 FL_OBJECT *obj = fl_add_pixmapbutton(FL_NORMAL_BUTTON, 0, 0, 425, 290, "");
309                 fl_set_pixmapbutton_file(obj, banner_file.c_str());
310                 
311                 fl_set_pixmapbutton_focus_outline(obj, 3);
312                 fl_set_button_shortcut(obj, "^M ^[", 1);
313                 fl_set_object_boxtype(obj, FL_NO_BOX);
314                 fl_set_object_callback(obj, TimerCB, 0);
315                 
316                 obj = fl_add_text(FL_NORMAL_TEXT, 248, 265, 170, 16, LYX_VERSION);
317                 fl_set_object_lsize(obj, FL_NORMAL_SIZE);
318                 fl_mapcolor(FL_FREE_COL2, 0x05, 0x2e, 0x4c);
319                 fl_mapcolor(FL_FREE_COL3, 0xe1, 0xd2, 0x9b);
320                 fl_set_object_color(obj, FL_FREE_COL2, FL_FREE_COL2);
321                 fl_set_object_lcol(obj, FL_FREE_COL3);
322                 fl_set_object_lalign(obj, FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
323                 fl_set_object_lstyle(obj, FL_BOLD_STYLE);
324                 fl_end_form();
325         }
326         
327         // the paragraph form
328         fd_form_paragraph = create_form_form_paragraph();
329         fl_set_form_atclose(fd_form_paragraph->form_paragraph,
330                             CancelCloseBoxCB, 0);
331         fl_addto_choice(fd_form_paragraph->choice_space_above,
332                         _(" None | Defskip | Smallskip "
333                         "| Medskip | Bigskip | VFill | Length "));
334         fl_addto_choice(fd_form_paragraph->choice_space_below,
335                         _(" None | Defskip | Smallskip "
336                         "| Medskip | Bigskip | VFill | Length ")); 
337         fl_set_input_return(fd_form_paragraph->input_space_above,
338                             FL_RETURN_ALWAYS);
339         fl_set_input_return(fd_form_paragraph->input_space_below,
340                             FL_RETURN_ALWAYS);
341
342         // the paragraph extra form
343         fd_form_paragraph_extra = create_form_form_paragraph_extra();
344         fl_set_form_atclose(fd_form_paragraph_extra->form_paragraph_extra,
345                             CancelCloseBoxCB, 0);
346         fl_set_input_return(fd_form_paragraph_extra->input_pextra_width,
347                             FL_RETURN_ALWAYS);
348         fl_set_input_return(fd_form_paragraph_extra->input_pextra_widthp,
349                             FL_RETURN_ALWAYS);
350         lyxerr[Debug::INIT] << "Initializing form_paragraph...done" << endl;
351
352         // the character form
353         fd_form_character = create_form_form_character();
354         fl_set_form_atclose(fd_form_character->form_character,
355                             CancelCloseBoxCB, 0);
356         fl_addto_choice(fd_form_character->choice_family, 
357                         _(" No change %l| Roman | Sans Serif | Typewriter %l| Reset "));
358         fl_addto_choice(fd_form_character->choice_series, 
359                         _(" No change %l| Medium | Bold %l| Reset "));
360         fl_addto_choice(fd_form_character->choice_shape,
361                         _(" No change %l| Upright | Italic | Slanted | Small Caps "
362                         "%l| Reset "));
363         fl_addto_choice(fd_form_character->choice_size, 
364                         _(" No change %l| Tiny | Smallest | Smaller | Small "
365                         "| Normal | Large | Larger | Largest | Huge | Huger "
366                         "%l| Increase | Decrease | Reset "));
367         fl_addto_choice(fd_form_character->choice_bar, 
368                         _(" No change %l| Emph | Underbar | Noun | LaTeX mode %l| Reset "));
369         fl_addto_choice(fd_form_character->choice_color, 
370                         _(" No change %l| No color | Black | White | Red | Green "
371                         "| Blue | Cyan | Magenta | Yellow %l| Reset "));
372         fl_set_form_minsize(fd_form_character->form_character,
373                             fd_form_character->form_character->w,
374                             fd_form_character->form_character->h);
375         lyxerr[Debug::INIT] << "Initializing form_character::combox..." << endl;
376         fl_addto_form(fd_form_character->form_character);
377         combo_language2 = new Combox(FL_COMBOX_DROPLIST);
378         FL_OBJECT * ob = fd_form_character->choice_language;
379         combo_language2->add(ob->x, ob->y, ob->w, ob->h, 250);
380         combo_language2->shortcut("#L", 1);
381         fl_end_form();
382         lyxerr[Debug::INIT] << "Initializing form_character...done" << endl;
383
384         // the document form
385         fd_form_document = create_form_form_document();
386         fl_set_form_atclose(fd_form_document->form_document,
387                             CancelCloseBoxCB, 0);
388         fl_addto_choice(fd_form_document->choice_spacing,
389                         _(" Single | OneHalf | Double | Other "));
390
391         fl_set_counter_bounds(fd_form_document->slider_secnumdepth,-2, 5);
392         fl_set_counter_bounds(fd_form_document->slider_tocdepth,-1, 5);
393         fl_set_counter_step(fd_form_document->slider_secnumdepth, 1, 1);
394         fl_set_counter_step(fd_form_document->slider_tocdepth, 1, 1);
395         fl_set_counter_precision(fd_form_document->slider_secnumdepth, 0);
396         fl_set_counter_precision(fd_form_document->slider_tocdepth, 0);
397         fl_addto_form(fd_form_document->form_document);
398         combo_language = new Combox(FL_COMBOX_DROPLIST);
399         ob = fd_form_document->choice_language;
400         combo_language->add(ob->x, ob->y, ob->w, ob->h, 250);
401         combo_language->shortcut("#G", 1);
402         fl_end_form();
403
404         // "default" is not part of the languages array any more.
405         combo_language->addto("default");
406         combo_language2->addto(_("No change"));
407         combo_language2->addto(_("Reset"));
408         for(Languages::const_iterator cit = languages.begin();
409             cit != languages.end(); ++cit) {
410                 combo_language->addto((*cit).second.lang().c_str());
411                 combo_language2->addto((*cit).second.lang().c_str());
412         }
413         combo_language2->select_text("No change");
414
415         // not really necessary, but we can do it anyway.
416         fl_addto_choice(fd_form_document->choice_fontsize, "default|10|11|12");
417         int n;
418         for (n = 0; tex_fonts[n][0]; ++n) {
419             fl_addto_choice(fd_form_document->choice_fonts, tex_fonts[n]);
420         }
421
422         fl_addto_choice(fd_form_document->choice_inputenc,
423                         "default|auto|latin1|latin2|latin5"
424                         "|koi8-r|koi8-u|cp866|cp1251|iso88595");
425
426         for (n = 0; tex_graphics[n][0]; ++n) {
427             fl_addto_choice(fd_form_document->choice_postscript_driver,
428                                         tex_graphics[n]);
429         }
430         // not really necessary, but we can do it anyway.
431         fl_addto_choice(fd_form_document->choice_pagestyle,
432                         "default|empty|plain|headings|fancy");
433         fl_addto_choice(fd_form_document->choice_default_skip,
434                         _(" Smallskip | Medskip | Bigskip | Length "));
435         fl_set_input_return(fd_form_document->input_default_skip,
436                             FL_RETURN_ALWAYS);
437         fl_set_form_minsize(fd_form_document->form_document,
438                             fd_form_document->form_document->w,
439                             fd_form_document->form_document->h);
440         lyxerr[Debug::INIT] << "Initializing form_document...done" << endl;
441
442         // the paper form
443         fd_form_paper = create_form_form_paper();
444         fl_set_form_atclose(fd_form_paper->form_paper,
445                             CancelCloseBoxCB, 0);
446         fl_addto_choice(fd_form_paper->choice_papersize2,
447                         _(" Default | Custom | USletter | USlegal "
448                         "| USexecutive | A3 | A4 | A5 | B3 | B4 | B5 "));
449         fl_addto_choice(fd_form_paper->choice_paperpackage,
450                         _(" None "
451                         "| A4 small Margins (only portrait) "
452                         "| A4 very small Margins (only portrait) "
453                         "| A4 very wide margins (only portrait) "));
454         fl_set_input_return(fd_form_paper->input_custom_width,
455                             FL_RETURN_ALWAYS);
456         fl_set_input_return(fd_form_paper->input_custom_height,
457                             FL_RETURN_ALWAYS);
458         fl_set_input_return(fd_form_paper->input_top_margin,
459                             FL_RETURN_ALWAYS);
460         fl_set_input_return(fd_form_paper->input_bottom_margin,
461                             FL_RETURN_ALWAYS);
462         fl_set_input_return(fd_form_paper->input_left_margin,
463                             FL_RETURN_ALWAYS);
464         fl_set_input_return(fd_form_paper->input_right_margin,
465                             FL_RETURN_ALWAYS);
466         fl_set_input_return(fd_form_paper->input_head_height,
467                             FL_RETURN_ALWAYS);
468         fl_set_input_return(fd_form_paper->input_head_sep,
469                             FL_RETURN_ALWAYS);
470         fl_set_input_return(fd_form_paper->input_foot_skip,
471                             FL_RETURN_ALWAYS);
472         lyxerr[Debug::INIT] << "Initializing form_paper...done" << endl;
473
474         // the table_options form
475         fd_form_table_options = create_form_form_table_options();
476         fl_set_form_atclose(fd_form_table_options->form_table_options,
477                             CancelCloseBoxCB, 0);
478         fl_set_input_return(fd_form_table_options->input_column_width,
479                             FL_RETURN_ALWAYS);
480
481         // the table_extra form
482         fd_form_table_extra = create_form_form_table_extra();
483         fl_set_form_atclose(fd_form_table_extra->form_table_extra,
484                             CancelCloseBoxCB, 0);
485         fl_set_input_return(fd_form_table_extra->input_special_alignment,
486                             FL_RETURN_ALWAYS);
487         fl_set_input_return(fd_form_table_extra->input_special_multialign,
488                             FL_RETURN_ALWAYS);
489         lyxerr[Debug::INIT] << "Initializing form_table_extra...done" << endl;
490
491         // the quotes form
492         fd_form_quotes = create_form_form_quotes();
493         fl_set_form_atclose(fd_form_quotes->form_quotes,
494                             CancelCloseBoxCB, 0);
495         // Is it wrong of me to use « » instead of << >> ? (Lgb)
496         // Maybe if people use a font other than latin1... (JMarc)
497         fl_addto_choice(fd_form_quotes->choice_quotes_language,
498                         _(" ``text'' | ''text'' | ,,text`` | ,,text'' | «text» | »text« "));
499
500         // the preamble form
501         fd_form_preamble = create_form_form_preamble();
502         fl_set_form_atclose(fd_form_preamble->form_preamble,
503                             CancelCloseBoxCB, 0);
504
505 #ifndef NEW_TABULAR
506         // the table form
507         fd_form_table = create_form_form_table();
508         fl_set_form_atclose(fd_form_table->form_table, CancelCloseBoxCB, 0);
509         fl_set_slider_bounds(fd_form_table->slider_rows, 1, 50);
510         fl_set_slider_bounds(fd_form_table->slider_columns, 1, 50);
511         fl_set_slider_value(fd_form_table->slider_rows, 5);
512         fl_set_slider_value(fd_form_table->slider_columns, 5);
513         fl_set_slider_precision(fd_form_table->slider_rows, 0);
514         fl_set_slider_precision(fd_form_table->slider_columns, 0);
515         lyxerr[Debug::INIT] << "Initializing form_table...done" << endl;
516 #endif
517
518         // the sendto form
519         fd_form_sendto = create_form_form_sendto();
520         fl_set_form_atclose(fd_form_sendto->form_sendto, CancelCloseBoxCB, 0);
521
522         // the figure form
523         fd_form_figure = create_form_form_figure();
524         fl_set_form_atclose(fd_form_figure->form_figure,
525                             CancelCloseBoxCB, 0);
526         fl_set_button(fd_form_figure->radio_postscript, 1);
527
528         // the screen form
529         fd_form_screen = create_form_form_screen();
530         fl_set_form_atclose(fd_form_screen->form_screen,
531                             CancelCloseBoxCB, 0);
532
533         // the latex log form
534         fd_latex_log = create_form_LaTeXLog();
535         fl_set_form_atclose(fd_latex_log->LaTeXLog,
536                             CancelCloseBoxCB, 0);
537
538         // Show the main & title form
539         int main_placement = FL_PLACE_CENTER | FL_FREE_SIZE;
540         int title_placement = FL_PLACE_CENTER;
541         // Did we get a valid position?
542         if (xpos>= 0 && ypos>= 0) {
543                 lyxViews->setPosition(xpos, ypos);
544                 if (lyxrc.show_banner) {
545                         // show the title form in the middle of the main form
546                         fl_set_form_position(fd_form_title->form_title,
547                                              abs(xpos + (width/2) - (370 / 2)),
548                                              abs(ypos + (height/2) - (290 / 2)));
549                         title_placement = FL_PLACE_GEOMETRY;
550                         // The use of abs() above is a trick to ensure
551                         // valid positions
552                 }
553                         main_placement = FL_PLACE_POSITION;
554         }
555         lyxViews->show(main_placement, FL_FULLBORDER, "LyX");
556         if (lyxrc.show_banner) {
557                 fl_show_form(fd_form_title->form_title, 
558                              title_placement, FL_NOBORDER, 
559                              _("LyX Banner"));
560                 fl_redraw_form(fd_form_title->form_title);
561                 fl_raise_form(fd_form_title->form_title);
562
563                 // Show the title form at most 7 secs (lowered from 10 secs)
564                 fl_set_timer(fd_form_title->timer_title, 7);
565         }
566 }
567
568
569 void LyXGUI::runTime()
570         /* This will usually be toolkit (GUI) specific. This is
571          * also usually the XEvent dispatcher of the GUI. */
572 {
573         if (!gui)
574                 return;
575
576         // XForms specific
577         XEvent ev;
578
579         while (!finished) {
580 #ifdef KDEGUI
581                 kapp->processEvents();
582 #endif
583 #ifdef GTKGUI
584                 Gnome::Main::instance()->iteration(FALSE);
585 #endif
586                 
587                 if (fl_check_forms() == FL_EVENT) {
588                         lyxerr << "LyX: This shouldn't happen..." << endl;
589                         fl_XNextEvent(&ev);
590                 }
591         }
592 }
593
594
595 void LyXGUI::regBuf(Buffer * b)
596 {
597         lyxViews->view()->buffer(b);
598 }
599
600 LyXView * LyXGUI::getLyXView() const
601 {
602         return lyxViews;
603 }