]> git.lyx.org Git - lyx.git/blob - src/lyx_gui.C
Fix the line-delete-forward bug?
[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         int bold = fl_set_font_name(FL_BOLD_STYLE, menufontname.c_str());
251         int normal = fl_set_font_name(FL_NORMAL_STYLE, popupfontname.c_str());
252         if (bold < 0)
253                 lyxerr << "Could not set menu font to "
254                        << menufontname << endl;
255
256         if (normal < 0)
257                 lyxerr << "Could not set popup font to "
258                        << popupfontname << endl;
259
260         if (bold < 0 && normal < 0) {
261                 lyxerr << "Using 'helvetica' font for menus" << endl;
262                 bold = fl_set_font_name(FL_BOLD_STYLE,
263                                         "-*-helvetica-bold-r-*-*-*-?-*-*-*-*-iso8859-1");
264                 normal = fl_set_font_name(FL_NORMAL_STYLE,
265                                           "-*-helvetica-medium-r-*-*-*-?-*-*-*-*-iso8859-1");
266                 if (bold < 0 && normal < 0) {
267                         lyxerr << "Could not find helvetica font. Using 'fixed'." << endl;
268                         normal = fl_set_font_name(FL_NORMAL_STYLE, "fixed");
269                 }
270         }
271
272         // put here (after fl_initialize) to avoid segfault. Cannot be done
273         // in setDefaults() (Matthias 140496)
274         // Moved from ::LyXGUI to ::init to allow popup font customization 
275         // (petr 120997).
276         fl_setpup_fontstyle(FL_NORMAL_STYLE);
277         fl_setpup_fontsize(FL_NORMAL_SIZE);
278         fl_setpup_color(FL_MCOL, FL_BLACK);
279         fl_set_goodies_font(FL_NORMAL_STYLE, FL_NORMAL_SIZE);
280
281         // all lyxrc settings has to be done here as lyxrc has not yet
282         // been read when the GUI is created (Jug)
283
284         // the print form
285         fl_set_input(fd_form_print->input_printer, 
286                      lyxrc.printer.c_str());    
287         
288         // the sendto form
289         if (!lyxrc.custom_export_command.empty())
290                 fl_set_input(fd_form_sendto->input_cmd,
291                              lyxrc.custom_export_command.c_str());
292         if (lyxrc.custom_export_format == "lyx")
293                 fl_set_button(fd_form_sendto->radio_ftype_lyx, 1);
294         else if (lyxrc.custom_export_format == "tex")
295                 fl_set_button(fd_form_sendto->radio_ftype_latex, 1);
296         else if (lyxrc.custom_export_format == "dvi")
297                 fl_set_button(fd_form_sendto->radio_ftype_dvi, 1);
298         else if (lyxrc.custom_export_format == "ps")
299                 fl_set_button(fd_form_sendto->radio_ftype_ps, 1);
300         else if (lyxrc.custom_export_format == "ascii")
301                 fl_set_button(fd_form_sendto->radio_ftype_ascii, 1);
302
303         // Update parameters.
304         lyxViews->redraw();
305
306         // Initialize the views.
307         lyxViews->init();
308
309         // in 0.12 the initialisation of the LyXServer must be done here
310         // 0.13 it should be moved again...
311         lyxserver = new LyXServer(lyxViews->getLyXFunc(), lyxrc.lyxpipes);
312 }
313
314
315 void LyXGUI::create_forms()
316 {
317         lyxerr[Debug::INIT] << "Initializing LyXView..." << endl;
318         lyxViews = new LyXView(width, height);
319         lyxerr[Debug::INIT] << "Initializing LyXView...done" << endl;
320
321         // From here down should be done by somebody else. (Lgb)
322
323         //
324         // Create forms
325         //
326
327         // the title form
328         if (lyxrc.show_banner) {
329                 fd_form_title = create_form_form_title();
330                 fl_set_form_dblbuffer(fd_form_title->form_title, 1); // use dbl buffer
331                 fl_set_form_atclose(fd_form_title->form_title, CancelCloseBoxCB, 0);
332                 fl_addto_form(fd_form_title->form_title);
333 #ifdef TWO_COLOR_ICONS
334                 FL_OBJECT *obj = fl_add_bitmapbutton(FL_NORMAL_BUTTON, 0, 0, 425, 290, "");
335                 fl_set_bitmapbutton_data(obj, banner_bw_width,
336                                          banner_bw_height, banner_bw_bits);
337                 fl_set_object_color(obj, FL_WHITE, FL_BLACK);
338 #else
339                 FL_OBJECT *obj = fl_add_pixmapbutton(FL_NORMAL_BUTTON, 0, 0, 425, 290, "");
340                 fl_set_pixmapbutton_data(obj, const_cast<char **>(banner));
341                 
342                 fl_set_pixmapbutton_focus_outline(obj, 3);
343 #endif
344                 fl_set_button_shortcut(obj, "^M ^[", 1);
345                 fl_set_object_boxtype(obj, FL_NO_BOX);
346                 fl_set_object_callback(obj, TimerCB, 0);
347                 
348                 obj = fl_add_text(FL_NORMAL_TEXT, 248, 265, 170, 16, LYX_VERSION);
349                 fl_set_object_lsize(obj, FL_NORMAL_SIZE);
350 #ifdef TWO_COLOR_ICONS
351                 fl_set_object_color(obj, FL_WHITE, FL_WHITE);
352                 fl_set_object_lcol(obj, FL_BLACK);
353 #else
354 //        fl_set_object_color(obj, FL_WHITE, FL_WHITE);
355 //        fl_set_object_lcol(obj, FL_BLACK);
356                 fl_mapcolor(FL_FREE_COL2, 0x05, 0x2e, 0x4c);
357                 fl_mapcolor(FL_FREE_COL3, 0xe1, 0xd2, 0x9b);
358                 fl_set_object_color(obj, FL_FREE_COL2, FL_FREE_COL2);
359                 fl_set_object_lcol(obj, FL_FREE_COL3);
360 #endif
361                 fl_set_object_lalign(obj, FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
362                 fl_set_object_lstyle(obj, FL_BOLD_STYLE);
363                 fl_end_form();
364         }
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 character form
391         fd_form_character = create_form_form_character();
392         fl_set_form_atclose(fd_form_character->form_character,
393                             CancelCloseBoxCB, 0);
394         fl_addto_choice(fd_form_character->choice_family, 
395                         _(" No change %l| Roman | Sans Serif | Typewriter %l| Reset "));
396         fl_addto_choice(fd_form_character->choice_series, 
397                         _(" No change %l| Medium | Bold %l| Reset "));
398         fl_addto_choice(fd_form_character->choice_shape,
399                         _(" No change %l| Upright | Italic | Slanted | Small Caps "
400                         "%l| Reset "));
401         fl_addto_choice(fd_form_character->choice_size, 
402                         _(" No change %l| Tiny | Smallest | Smaller | Small "
403                         "| Normal | Large | Larger | Largest | Huge | Huger "
404                         "%l| Increase | Decrease | Reset "));
405         fl_addto_choice(fd_form_character->choice_bar, 
406                         _(" No change %l| Emph | Underbar | Noun | LaTeX mode %l| Reset "));
407         fl_addto_choice(fd_form_character->choice_color, 
408                         _(" No change %l| No color | Black | White | Red | Green "
409                         "| Blue | Cyan | Magenta | Yellow %l| Reset "));
410         fl_set_form_minsize(fd_form_character->form_character,
411                             fd_form_character->form_character->w,
412                             fd_form_character->form_character->h);
413         fl_addto_form(fd_form_character->form_character);
414         combo_language2 = new Combox(FL_COMBOX_DROPLIST);
415         FL_OBJECT * ob = fd_form_character->choice_language;
416         combo_language2->add(ob->x, ob->y, ob->w, ob->h, 250);
417         combo_language2->shortcut("#L", 1);
418         fl_end_form();
419
420         // the document form
421         fd_form_document = create_form_form_document();
422         fl_set_form_atclose(fd_form_document->form_document,
423                             CancelCloseBoxCB, 0);
424         fl_addto_choice(fd_form_document->choice_spacing,
425                         _(" Single | OneHalf | Double | Other "));
426
427         fl_set_counter_bounds(fd_form_document->slider_secnumdepth,-2, 5);
428         fl_set_counter_bounds(fd_form_document->slider_tocdepth,-1, 5);
429         fl_set_counter_step(fd_form_document->slider_secnumdepth, 1, 1);
430         fl_set_counter_step(fd_form_document->slider_tocdepth, 1, 1);
431         fl_set_counter_precision(fd_form_document->slider_secnumdepth, 0);
432         fl_set_counter_precision(fd_form_document->slider_tocdepth, 0);
433         fl_addto_form(fd_form_document->form_document);
434         combo_language = new Combox(FL_COMBOX_DROPLIST);
435         ob = fd_form_document->choice_language;
436         combo_language->add(ob->x, ob->y, ob->w, ob->h, 250);
437         combo_language->shortcut("#G", 1);
438         fl_end_form();
439
440         // "default" is not part of the languages array any more.
441         combo_language->addto("default");
442         combo_language2->addto("No change");
443         for(Languages::const_iterator cit = languages.begin();
444             cit != languages.end(); ++cit) {
445                 combo_language->addto((*cit).second.lang.c_str());
446                 combo_language2->addto((*cit).second.lang.c_str());
447         }
448         combo_language2->select_text("No change");
449
450         // not really necessary, but we can do it anyway.
451         fl_addto_choice(fd_form_document->choice_fontsize, "default|10|11|12");
452         int n;
453         for (n = 0; tex_fonts[n][0]; ++n) {
454             fl_addto_choice(fd_form_document->choice_fonts, tex_fonts[n]);
455         }
456
457         fl_addto_choice(fd_form_document->choice_inputenc,
458                         "default|latin1|latin2|latin5"
459                         "|koi8-r|koi8-u|cp866|cp1251|iso88595");
460
461         for (n = 0; tex_graphics[n][0]; ++n) {
462             fl_addto_choice(fd_form_document->choice_postscript_driver,
463                                         tex_graphics[n]);
464         }
465         // not really necessary, but we can do it anyway.
466         fl_addto_choice(fd_form_document->choice_pagestyle,
467                         "default|empty|plain|headings|fancy");
468         fl_addto_choice(fd_form_document->choice_default_skip,
469                         _(" Smallskip | Medskip | Bigskip | Length "));
470         fl_set_input_return(fd_form_document->input_default_skip,
471                             FL_RETURN_ALWAYS);
472         fl_set_form_minsize(fd_form_document->form_document,
473                             fd_form_document->form_document->w,
474                             fd_form_document->form_document->h);
475
476         // the paper form
477         fd_form_paper = create_form_form_paper();
478         fl_set_form_atclose(fd_form_paper->form_paper,
479                             CancelCloseBoxCB, 0);
480         fl_addto_choice(fd_form_paper->choice_papersize2,
481                         _(" Default | Custom | USletter | USlegal "
482                         "| USexecutive | A3 | A4 | A5 | B3 | B4 | B5 "));
483         fl_addto_choice(fd_form_paper->choice_paperpackage,
484                         _(" None "
485                         "| A4 small Margins (only portrait) "
486                         "| A4 very small Margins (only portrait) "
487                         "| A4 very wide margins (only portrait) "));
488         fl_set_input_return(fd_form_paper->input_custom_width,
489                             FL_RETURN_ALWAYS);
490         fl_set_input_return(fd_form_paper->input_custom_height,
491                             FL_RETURN_ALWAYS);
492         fl_set_input_return(fd_form_paper->input_top_margin,
493                             FL_RETURN_ALWAYS);
494         fl_set_input_return(fd_form_paper->input_bottom_margin,
495                             FL_RETURN_ALWAYS);
496         fl_set_input_return(fd_form_paper->input_left_margin,
497                             FL_RETURN_ALWAYS);
498         fl_set_input_return(fd_form_paper->input_right_margin,
499                             FL_RETURN_ALWAYS);
500         fl_set_input_return(fd_form_paper->input_head_height,
501                             FL_RETURN_ALWAYS);
502         fl_set_input_return(fd_form_paper->input_head_sep,
503                             FL_RETURN_ALWAYS);
504         fl_set_input_return(fd_form_paper->input_foot_skip,
505                             FL_RETURN_ALWAYS);
506
507         // the table_options form
508         fd_form_table_options = create_form_form_table_options();
509         fl_set_form_atclose(fd_form_table_options->form_table_options,
510                             CancelCloseBoxCB, 0);
511         fl_set_input_return(fd_form_table_options->input_column_width,
512                             FL_RETURN_ALWAYS);
513
514         // the table_extra form
515         fd_form_table_extra = create_form_form_table_extra();
516         fl_set_form_atclose(fd_form_table_extra->form_table_extra,
517                             CancelCloseBoxCB, 0);
518         fl_set_input_return(fd_form_table_extra->input_special_alignment,
519                             FL_RETURN_ALWAYS);
520         fl_set_input_return(fd_form_table_extra->input_special_multialign,
521                             FL_RETURN_ALWAYS);
522
523         // the quotes form
524         fd_form_quotes = create_form_form_quotes();
525         fl_set_form_atclose(fd_form_quotes->form_quotes,
526                             CancelCloseBoxCB, 0);
527         // Is it wrong of me to use « » instead of << >> ? (Lgb)
528         // Maybe if people use a font other than latin1... (JMarc)
529         fl_addto_choice(fd_form_quotes->choice_quotes_language,
530                         _(" ``text'' | ''text'' | ,,text`` | ,,text'' | «text» | »text« "));
531
532         // the preamble form
533         fd_form_preamble = create_form_form_preamble();
534         fl_set_form_atclose(fd_form_preamble->form_preamble,
535                             CancelCloseBoxCB, 0);
536
537         // the table form
538         fd_form_table = create_form_form_table();
539         fl_set_form_atclose(fd_form_table->form_table, CancelCloseBoxCB, 0);
540         fl_set_slider_bounds(fd_form_table->slider_rows, 1, 50);
541         fl_set_slider_bounds(fd_form_table->slider_columns, 1, 50);
542         fl_set_slider_value(fd_form_table->slider_rows, 5);
543         fl_set_slider_value(fd_form_table->slider_columns, 5);
544         fl_set_slider_precision(fd_form_table->slider_rows, 0);
545         fl_set_slider_precision(fd_form_table->slider_columns, 0);
546
547         // the print form
548         fd_form_print = create_form_form_print();
549         fl_set_form_atclose(fd_form_print->form_print, CancelCloseBoxCB, 0);
550         fl_set_button(fd_form_print->radio_printer, 1);
551         fl_set_button(fd_form_print->radio_file, 0);
552         fl_set_button(fd_form_print->radio_order_normal, 1);
553         fl_set_button(fd_form_print->radio_order_reverse, 0);
554         fl_set_button(fd_form_print->radio_all_pages, 1);
555         fl_set_button(fd_form_print->radio_odd_pages, 0);
556         fl_set_button(fd_form_print->radio_even_pages, 0);
557
558         // the sendto form
559         fd_form_sendto = create_form_form_sendto();
560         fl_set_form_atclose(fd_form_sendto->form_sendto, CancelCloseBoxCB, 0);
561
562         // the figure form
563         fd_form_figure = create_form_form_figure();
564         fl_set_form_atclose(fd_form_figure->form_figure,
565                             CancelCloseBoxCB, 0);
566         fl_set_button(fd_form_figure->radio_postscript, 1);
567
568         // the screen form
569         fd_form_screen = create_form_form_screen();
570         fl_set_form_atclose(fd_form_screen->form_screen,
571                             CancelCloseBoxCB, 0);
572
573         // the toc form
574         fd_form_toc = create_form_form_toc();
575         fl_addto_choice(fd_form_toc->toctype,
576                         _(" TOC | LOF | LOT | LOA "));
577         fl_set_form_atclose(fd_form_toc->form_toc, CancelCloseBoxCB, 0);
578
579         // the ref form
580         fd_form_ref = create_form_form_ref();
581         fl_set_form_atclose(fd_form_ref->form_ref, CancelCloseBoxCB, 0);
582         fl_set_form_minsize(fd_form_ref->form_ref, fd_form_ref->form_ref->w,
583                             fd_form_ref->form_ref->h);
584
585         // the latex options form
586         fd_latex_options = create_form_LaTeXOptions();
587         fl_set_form_atclose(fd_latex_options->LaTeXOptions,
588                             CancelCloseBoxCB, 0);
589
590         // the latex log form
591         fd_latex_log = create_form_LaTeXLog();
592         fl_set_form_atclose(fd_latex_log->LaTeXLog,
593                             CancelCloseBoxCB, 0);
594
595         // Show the main & title form
596         int main_placement = FL_PLACE_CENTER | FL_FREE_SIZE;
597         int title_placement = FL_PLACE_CENTER;
598         // Did we get a valid position?
599         if (xpos>= 0 && ypos>= 0) {
600                 lyxViews->setPosition(xpos, ypos);
601                 if (lyxrc.show_banner) {
602                         // show the title form in the middle of the main form
603                         fl_set_form_position(fd_form_title->form_title,
604                                              abs(xpos + (width/2) - (370 / 2)),
605                                              abs(ypos + (height/2) - (290 / 2)));
606                         title_placement = FL_PLACE_GEOMETRY;
607                         // The use of abs() above is a trick to ensure
608                         // valid positions
609                 }
610                         main_placement = FL_PLACE_POSITION;
611         }
612         lyxViews->show(main_placement, FL_FULLBORDER, "LyX");
613         if (lyxrc.show_banner) {
614                 fl_show_form(fd_form_title->form_title, 
615                              title_placement, FL_NOBORDER, 
616                              _("LyX Banner"));
617                 fl_redraw_form(fd_form_title->form_title);
618                 fl_raise_form(fd_form_title->form_title);
619
620                 // Show the title form at most 7 secs (lowered from 10 secs)
621                 fl_set_timer(fd_form_title->timer_title, 7);
622         }
623 }
624
625
626 void LyXGUI::runTime()
627         /* This will usually be toolkit (GUI) specific. This is
628          * also usually the XEvent dispatcher of the GUI. */
629 {
630         if (!gui)
631                 return;
632
633         // XForms specific
634         XEvent ev;
635
636         while (!finished) {
637                 if (fl_check_forms() == FL_EVENT) {
638                         lyxerr << "LyX: This shouldn't happen..." << endl;
639                         fl_XNextEvent(&ev);
640                 }
641         }
642 }
643
644
645 void LyXGUI::regBuf(Buffer * b)
646 {
647         lyxViews->view()->buffer(b);
648 }
649
650 LyXView * LyXGUI::getLyXView() const
651 {
652         return lyxViews;
653 }