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