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