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