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