home *** CD-ROM | disk | FTP | other *** search
/ Dream 52 / Amiga_Dream_52.iso / Linux / Divers / lyx-0.13.2.tar.gz / lyx-0.13.2.tar / lyx-0.13.2 / src / lyx_gui.C < prev    next >
C/C++ Source or Header  |  1998-04-23  |  19KB  |  568 lines

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