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