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