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