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