]> git.lyx.org Git - lyx.git/blobdiff - src/lyx_gui.C
fixes because of SUN CC warnings, bmtable now compiled with C compilator, countChar...
[lyx.git] / src / lyx_gui.C
index 1949740193a681ffec9fef47fe39d2d67f7f8242..9305d9afce1de98e66cf0a6cc5010c3e8ec8d3eb 100644 (file)
@@ -6,7 +6,7 @@
  *         Copyright 1995 Matthias Ettrich
  *          Copyright 1995-1999 The LyX Team.
  *
- * ======================================================*/
+ * ====================================================== */
 
 #include <config.h>
 #include <cstdlib>
@@ -26,7 +26,7 @@
 #include "tex-strings.h"
 #include "lyx_main.h"
 #include "latexoptions.h"
-#include "error.h"
+#include "debug.h"
 #include "version.h"
 #include "LyXView.h"
 #include "buffer.h"
 #include "banner.xpm"
 #endif
 
-FD_form_title *fd_form_title;
-FD_form_paragraph *fd_form_paragraph;
-FD_form_paragraph_extra *fd_form_paragraph_extra;
-FD_form_search *fd_form_search;
-FD_form_character *fd_form_character;
-FD_form_document *fd_form_document;
-FD_form_paper *fd_form_paper;
-FD_form_table_options *fd_form_table_options;
-FD_form_table_extra *fd_form_table_extra;
-FD_form_quotes *fd_form_quotes;
-FD_form_preamble *fd_form_preamble;
-FD_form_table *fd_form_table;
-FD_form_print *fd_form_print;
-FD_form_sendto *fd_form_sendto;
-FD_form_figure *fd_form_figure;
-FD_form_screen *fd_form_screen;
-FD_form_toc *fd_form_toc;
-FD_form_ref *fd_form_ref;
-FD_LaTeXOptions *fd_latex_options; // from latexoptions.h
-FD_LaTeXLog *fd_latex_log; // from latexoptions.h
-Combox *combo_language;
-
-extern LyXServer *lyxserver;
+FD_form_title * fd_form_title;
+FD_form_paragraph * fd_form_paragraph;
+FD_form_paragraph_extra * fd_form_paragraph_extra;
+FD_form_search * fd_form_search;
+FD_form_character * fd_form_character;
+FD_form_document * fd_form_document;
+FD_form_paper * fd_form_paper;
+FD_form_table_options * fd_form_table_options;
+FD_form_table_extra * fd_form_table_extra;
+FD_form_quotes * fd_form_quotes;
+FD_form_preamble * fd_form_preamble;
+FD_form_table * fd_form_table;
+FD_form_print * fd_form_print;
+FD_form_sendto * fd_form_sendto;
+FD_form_figure * fd_form_figure;
+FD_form_screen * fd_form_screen;
+FD_form_toc * fd_form_toc;
+FD_form_ref * fd_form_ref;
+FD_LaTeXOptions * fd_latex_options; // from latexoptions.h
+FD_LaTeXLog * fd_latex_log; // from latexoptions.h
+Combox * combo_language;
+
+extern LyXServer * lyxserver;
 extern bool finished;  // flag, that we are quitting the program
 extern BufferList bufferlist;
 
@@ -121,13 +121,13 @@ char         selection_color[32];
 
 FL_resource res[] =
 {
-       {"width", "widthClass", FL_INT, &width, "690"},
-       {"height", "heightClass", FL_INT, &height, "510"},
-       {"xpos", "xposClass", FL_INT, &xpos, "-1"},
-       {"ypos", "yposClass", FL_INT, &ypos, "-1"},
-       {"Reverse", "reverseClass", FL_INT, &reverse_video, "0"},
-       {"Mono", "monoClass", FL_INT, &mono_video, "0"},
-       {"FastSelection", "selectionClass", FL_INT, &fast_selection, "0"},
+       {"width", "widthClass", FL_INT, &width, "690", 0},
+       {"height", "heightClass", FL_INT, &height, "510", 0},
+       {"xpos", "xposClass", FL_INT, &xpos, "-1", 0},
+       {"ypos", "yposClass", FL_INT, &ypos, "-1", 0},
+       {"Reverse", "reverseClass", FL_INT, &reverse_video, "0", 0},
+       {"Mono", "monoClass", FL_INT, &mono_video, "0", 0},
+       {"FastSelection", "selectionClass", FL_INT, &fast_selection, "0", 0},
        {"MathColor", "colorClass", FL_STRING, math_color, "blue", 31},
        {"MathFrameColor", "colorClass", FL_STRING, math_frame_color, "magenta", 31},
        {"FootColor", "colorClass", FL_STRING, foot_color, "red", 31},
@@ -144,25 +144,25 @@ FL_resource res[] =
 };
 
 
-static int LyX_XErrHandler(Display *display, XErrorEvent *xeev)
+extern "C" int LyX_XErrHandler(Display * display, XErrorEvent * xeev)
 {
 //#warning Please see if you can trigger this!
        // emergency save
-       if (!bufferlist.isEmpty())
+       if (!bufferlist.empty())
                bufferlist.emergencyWriteAll();
 
        // Get the reason for the crash.
        char etxt[513];
        XGetErrorText(display, xeev->error_code, etxt, 512);
-       lyxerr.print(etxt);
+       lyxerr << etxt << endl;
        // By doing an abort we get a nice backtrace. (hopefully)
        abort();
        return 0; // Solaris CC wants us to return something
 }
 
 
-LyXGUI::LyXGUI(LyX *owner, int *argc, char *argv[], bool GUI)
-       :_owner(owner)
+LyXGUI::LyXGUI(LyX * owner, int * argc, char * argv[], bool GUI)
+       : _owner(owner)
 {
        gui = GUI;
        if (!gui)
@@ -173,9 +173,9 @@ LyXGUI::LyXGUI(LyX *owner, int *argc, char *argv[], bool GUI)
        static const int num_res = sizeof(res)/sizeof(FL_resource);
        fl_initialize(argc, argv, "LyX", cmdopt, num_res);
        fl_get_app_resources(res, num_res);
-       Display *display = fl_get_display();
+       Display * display = fl_get_display();
        if (!display) {
-               lyxerr.print("LyX: unable to access X display, exiting");
+               lyxerr << "LyX: unable to access X display, exiting" << endl;
                exit(1);
        }
        fcntl(ConnectionNumber(display), F_SETFD, FD_CLOEXEC);
@@ -186,18 +186,19 @@ LyXGUI::LyXGUI(LyX *owner, int *argc, char *argv[], bool GUI)
        
        // Make sure default screen is not larger than monitor
        if (width == 690 && height == 510) {
-               Screen * scr=(DefaultScreenOfDisplay(fl_get_display()));
-               if (HeightOfScreen(scr)-24<height)
-                       height = HeightOfScreen(scr)-24;
-               if (WidthOfScreen(scr)-8<width)
-                       width = WidthOfScreen(scr)-8;
+               Screen * scr = DefaultScreenOfDisplay(fl_get_display());
+               if (HeightOfScreen(scr) - 24 < height)
+                       height = HeightOfScreen(scr) - 24;
+               if (WidthOfScreen(scr) - 8 < width)
+                       width = WidthOfScreen(scr) - 8;
        }
 
 }
 
 
 // A destructor is always necessary  (asierra-970604)
-LyXGUI::~LyXGUI() {
+LyXGUI::~LyXGUI()
+{
         // Lyxserver was created in this class so should be destroyed
         // here.  asierra-970604
         if (lyxserver) {
@@ -259,7 +260,8 @@ void LyXGUI::init()
                 fl_set_font_name(FL_BOLD_STYLE, menufontname.c_str());
         else
 #endif
-                lyxerr.print("Could not set menu font to " + menufontname);
+                lyxerr << "Could not set menu font to "
+                      << menufontname << endl;
 
 #if FL_REVISION > 85
         if (fl_set_font_name(FL_NORMAL_STYLE, popupfontname.c_str()) < 0)
@@ -271,7 +273,8 @@ void LyXGUI::init()
                 fl_set_font_name(FL_NORMAL_STYLE, popupfontname.c_str());
         else
 #endif
-                lyxerr.print("Could not set popup font to " + popupfontname);
+                lyxerr << "Could not set popup font to "
+                      << popupfontname << endl;
 
        // put here (after fl_initialize) to avoid segfault. Cannot be done
        // in setDefaults() (Matthias 140496)
@@ -279,7 +282,7 @@ void LyXGUI::init()
        // (petr 120997).
        fl_setpup_fontstyle(FL_NORMAL_STYLE);
        fl_setpup_fontsize(FL_NORMAL_SIZE);
-       fl_setpup_color(FL_MCOL,FL_BLACK);
+       fl_setpup_color(FL_MCOL, FL_BLACK);
        fl_set_goodies_font(FL_NORMAL_STYLE, FL_NORMAL_SIZE);
 
         // all lyxrc settings has to be done here as lyxrc has not yet
@@ -323,9 +326,9 @@ void LyXGUI::init()
 
 void LyXGUI::create_forms()
 {
-       lyxerr.debug("Initializing LyXView...");
+       lyxerr[Debug::INIT] << "Initializing LyXView..." << endl;
        lyxViews = new LyXView(width, height);
-       lyxerr.debug("Initializing LyXView...done");
+       lyxerr[Debug::INIT] << "Initializing LyXView...done" << endl;
 
        // From here down should be done by somebody else. (Lgb)
 
@@ -339,36 +342,36 @@ void LyXGUI::create_forms()
        fl_set_form_atclose(fd_form_title->form_title, CancelCloseBoxCB, 0);
        fl_addto_form(fd_form_title->form_title);
 #ifdef TWO_COLOR_ICONS
-       FL_OBJECT *obj = fl_add_bitmapbutton(FL_NORMAL_BUTTON,0,0,425,290,"");
-         fl_set_bitmapbutton_data(obj,banner_bw_width,
+       FL_OBJECT *obj = fl_add_bitmapbutton(FL_NORMAL_BUTTON, 0, 0, 425, 290, "");
+         fl_set_bitmapbutton_data(obj, banner_bw_width,
                                   banner_bw_height, banner_bw_bits);
-         fl_set_object_color(obj,FL_WHITE,FL_BLACK);
+         fl_set_object_color(obj, FL_WHITE, FL_BLACK);
 #else
-       FL_OBJECT *obj = fl_add_pixmapbutton(FL_NORMAL_BUTTON,0,0,425,290,"");
-         fl_set_pixmapbutton_data(obj, (char**)banner);
+       FL_OBJECT *obj = fl_add_pixmapbutton(FL_NORMAL_BUTTON, 0, 0, 425, 290, "");
+         fl_set_pixmapbutton_data(obj, const_cast<char **>(banner));
 #if FL_REVISION > 85
-         fl_set_pixmapbutton_focus_outline(obj,3);
+         fl_set_pixmapbutton_focus_outline(obj, 3);
 #endif
 #endif
-         fl_set_button_shortcut(obj,"^M ^[",1);
-         fl_set_object_boxtype(obj,FL_NO_BOX);
-         fl_set_object_callback(obj,TimerCB,0);
+         fl_set_button_shortcut(obj, "^M ^[", 1);
+         fl_set_object_boxtype(obj, FL_NO_BOX);
+         fl_set_object_callback(obj, TimerCB, 0);
 
-       obj = fl_add_text(FL_NORMAL_TEXT,248,265,170,16, LYX_VERSION);
-         fl_set_object_lsize(obj,FL_NORMAL_SIZE);
+       obj = fl_add_text(FL_NORMAL_TEXT, 248, 265, 170, 16, LYX_VERSION);
+         fl_set_object_lsize(obj, FL_NORMAL_SIZE);
 #ifdef TWO_COLOR_ICONS
-         fl_set_object_color(obj,FL_WHITE,FL_WHITE);
-         fl_set_object_lcol(obj,FL_BLACK);
+         fl_set_object_color(obj, FL_WHITE, FL_WHITE);
+         fl_set_object_lcol(obj, FL_BLACK);
 #else
-//       fl_set_object_color(obj,FL_WHITE, FL_WHITE);
-//       fl_set_object_lcol(obj,FL_BLACK);
+//       fl_set_object_color(obj, FL_WHITE, FL_WHITE);
+//       fl_set_object_lcol(obj, FL_BLACK);
           fl_mapcolor(FL_FREE_COL2, 0x05, 0x2e, 0x4c);
           fl_mapcolor(FL_FREE_COL3, 0xe1, 0xd2, 0x9b);
-         fl_set_object_color(obj,FL_FREE_COL2, FL_FREE_COL2);
-         fl_set_object_lcol(obj,FL_FREE_COL3);
+         fl_set_object_color(obj, FL_FREE_COL2, FL_FREE_COL2);
+         fl_set_object_lcol(obj, FL_FREE_COL3);
 #endif
-         fl_set_object_lalign(obj,FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
-         fl_set_object_lstyle(obj,FL_BOLD_STYLE);
+         fl_set_object_lalign(obj, FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
+         fl_set_object_lstyle(obj, FL_BOLD_STYLE);
        fl_end_form();
 
        // the paragraph form
@@ -420,6 +423,9 @@ void LyXGUI::create_forms()
        fl_addto_choice(fd_form_character->choice_color, 
                        _(" No change %l| No color | Black | White | Red | Green "
                        "| Blue | Cyan | Magenta | Yellow %l| Reset "));
+       fl_set_form_minsize(fd_form_character->form_character,
+                           fd_form_character->form_character->w,
+                           fd_form_character->form_character->h);
 
        // the document form
        fd_form_document = create_form_form_document();
@@ -428,36 +434,36 @@ void LyXGUI::create_forms()
        fl_addto_choice(fd_form_document->choice_spacing,
                        _(" Single | OneHalf | Double | Other "));
 
-       fl_set_counter_bounds(fd_form_document->slider_secnumdepth,-1,5);
-       fl_set_counter_bounds(fd_form_document->slider_tocdepth,-1,5);
-       fl_set_counter_step(fd_form_document->slider_secnumdepth,1,1);
-       fl_set_counter_step(fd_form_document->slider_tocdepth,1,1);
+       fl_set_counter_bounds(fd_form_document->slider_secnumdepth,-1, 5);
+       fl_set_counter_bounds(fd_form_document->slider_tocdepth,-1, 5);
+       fl_set_counter_step(fd_form_document->slider_secnumdepth, 1, 1);
+       fl_set_counter_step(fd_form_document->slider_tocdepth, 1, 1);
        fl_set_counter_precision(fd_form_document->slider_secnumdepth, 0);
        fl_set_counter_precision(fd_form_document->slider_tocdepth, 0);
        fl_addto_form(fd_form_document->form_document);
        combo_language = new Combox(FL_COMBOX_DROPLIST);
-       FL_OBJECT *ob = fd_form_document->choice_language;
+       FL_OBJECT * ob = fd_form_document->choice_language;
        combo_language->add(ob->x, ob->y, ob->w, ob->h, 200);
-       combo_language->shortcut("#G",1);
+       combo_language->shortcut("#G", 1);
        fl_end_form();
        int n; // declared here because DEC cxx does not like multiple
               // declarations of variables in for() loops (JMarc)
-        for (n=0; tex_babel[n][0]; n++) {
+        for (n = 0; tex_babel[n][0]; ++n) {
            combo_language->addto(tex_babel[n]);
        }
 
        // not really necessary, but we can do it anyway.
        fl_addto_choice(fd_form_document->choice_fontsize, "default|10|11|12");
        
-        for (n=0; tex_fonts[n][0]; n++) {
-           fl_addto_choice(fd_form_document->choice_fonts,tex_fonts[n]);
+        for (n = 0; tex_fonts[n][0]; ++n) {
+           fl_addto_choice(fd_form_document->choice_fonts, tex_fonts[n]);
        }
 
        fl_addto_choice(fd_form_document->choice_inputenc,
                        "default|latin1|latin2|latin5"
                        "|koi8-r|koi8-u|cp866|cp1251");
 
-        for (n=0; tex_graphics[n][0]; n++) {
+        for (n = 0; tex_graphics[n][0]; ++n) {
            fl_addto_choice(fd_form_document->choice_postscript_driver,
                                        tex_graphics[n]);
        }
@@ -468,6 +474,9 @@ void LyXGUI::create_forms()
                        _(" Smallskip | Medskip | Bigskip | Length "));
        fl_set_input_return(fd_form_document->input_default_skip,
                            FL_RETURN_ALWAYS);
+       fl_set_form_minsize(fd_form_document->form_document,
+                           fd_form_document->form_document->w,
+                           fd_form_document->form_document->h);
 
         // the paper form
        fd_form_paper = create_form_form_paper();
@@ -533,8 +542,8 @@ void LyXGUI::create_forms()
        // the table form
        fd_form_table = create_form_form_table();
        fl_set_form_atclose(fd_form_table->form_table, CancelCloseBoxCB, 0);
-       fl_set_slider_bounds(fd_form_table->slider_rows,1,50);
-       fl_set_slider_bounds(fd_form_table->slider_columns,1,50);
+       fl_set_slider_bounds(fd_form_table->slider_rows, 1, 50);
+       fl_set_slider_bounds(fd_form_table->slider_columns, 1, 50);
        fl_set_slider_value(fd_form_table->slider_rows, 5);
        fl_set_slider_value(fd_form_table->slider_columns, 5);
        fl_set_slider_precision(fd_form_table->slider_rows, 0);
@@ -553,7 +562,7 @@ void LyXGUI::create_forms()
 
        // the sendto form
        fd_form_sendto = create_form_form_sendto();
-       fl_set_form_atclose(fd_form_sendto->form_sendto,CancelCloseBoxCB,0);
+       fl_set_form_atclose(fd_form_sendto->form_sendto, CancelCloseBoxCB, 0);
 
        // the figure form
        fd_form_figure = create_form_form_figure();
@@ -573,6 +582,8 @@ void LyXGUI::create_forms()
        // the ref form
        fd_form_ref = create_form_form_ref();
        fl_set_form_atclose(fd_form_ref->form_ref, CancelCloseBoxCB, 0);
+       fl_set_form_minsize(fd_form_ref->form_ref, fd_form_ref->form_ref->w,
+                           fd_form_ref->form_ref->h);
 
        // the latex options form
        fd_latex_options = create_form_LaTeXOptions();
@@ -588,7 +599,7 @@ void LyXGUI::create_forms()
        int main_placement = FL_PLACE_CENTER | FL_FREE_SIZE;
        int title_placement = FL_PLACE_CENTER;
        // Did we get a valid position?
-       if (xpos>=0 && ypos>=0) {
+       if (xpos>= 0 && ypos>= 0) {
                lyxViews->setPosition(xpos, ypos);
                // show the title form in the middle of the main form
                fl_set_form_position(fd_form_title->form_title,
@@ -622,14 +633,14 @@ void LyXGUI::runTime()
 
        while (!finished) {
                if (fl_check_forms() == FL_EVENT) {
-                       lyxerr.print("LyX: This shouldn't happen...");
+                       lyxerr << "LyX: This shouldn't happen..." << endl;
                        fl_XNextEvent(&ev);
                }
        }
 }
 
 
-void LyXGUI::regBuf(Buffer *b)
+void LyXGUI::regBuf(Buffer * b)
 {
-       lyxViews->currentView()->setBuffer(b);
+       lyxViews->view()->buffer(b);
 }