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