]> git.lyx.org Git - lyx.git/blobdiff - src/lyx_cb.C
Fix small bug in reading \set_color in lyxrc
[lyx.git] / src / lyx_cb.C
index 12cef90b2bb487dcd01914f22ef31bb17e00463a..021af5c074cea87c5b2effc5715a7648c231bdf4 100644 (file)
@@ -73,7 +73,6 @@ extern FD_form_figure * fd_form_figure;
 extern FD_form_screen * fd_form_screen;
 extern FD_form_toc * fd_form_toc;
 extern FD_form_ref * fd_form_ref;
-extern FD_LaTeXOptions * fd_latex_options;
 extern FD_form_bullet * fd_form_bullet;
 
 extern BufferView * current_view; // called too many times in this file...
@@ -743,7 +742,7 @@ void MenuMakeLinuxDoc(Buffer * buffer)
        ShowMessage(buffer, _("Building LinuxDoc SGML file `"),
                                          MakeDisplayPath(s),"'...");
        
-       buffer->makeLinuxDocFile(s, 65);
+       buffer->makeLinuxDocFile(s, true);
        buffer->redraw();
        ShowMessage(buffer, _("LinuxDoc SGML file save as"),
                                          MakeDisplayPath(s)); 
@@ -770,7 +769,7 @@ void MenuMakeDocBook(Buffer * buffer)
        ShowMessage(buffer, _("Building DocBook SGML file `"),
                                          MakeDisplayPath(s), "'..."); 
        
-       buffer->makeDocBookFile(s, 65);
+       buffer->makeDocBookFile(s, true);
        buffer->redraw();
        ShowMessage(buffer, _("DocBook SGML file save as"),
                                          MakeDisplayPath(s)); 
@@ -1103,10 +1102,19 @@ void InsertAsciiFile(BufferView * bv, string const & f, bool asParagraph)
        ifs.unsetf(ios::skipws);
        istream_iterator<char> ii(ifs);
        istream_iterator<char> end;
+#if !defined(USE_INCLUDED_STRING) && !defined(STD_STRING_IS_GOOD)
+       // We use this until the compilers get better...
+       vector<char> tmp;
+       copy(ii, end, back_inserter(tmp));
+       string tmpstr(tmp.begin(), tmp.end());
+#else
+       // This is what we want to use and what we will use once the
+       // compilers get good enough. 
        //string tmpstr(ii, end); // yet a reason for using std::string
        // alternate approach to get the file into a string:
        string tmpstr;
        copy(ii, end, back_inserter(tmpstr));
+#endif
        // insert the string
        current_view->hideCursor();
        
@@ -1212,7 +1220,7 @@ int RunLinuxDoc(BufferView * bv, int flag, string const & filename)
        
        if (!bv->available())
                return 0;
-       bv->buffer()->makeLinuxDocFile(name, 0);
+       bv->buffer()->makeLinuxDocFile(name, false);
 
        // CHECK remove this once we have a proper geometry class
 
@@ -1273,7 +1281,7 @@ int RunDocBook(int flag, string const & filename)
        if (!current_view->available())
                return 0;
        
-       current_view->buffer()->makeDocBookFile(name, 0);
+       current_view->buffer()->makeDocBookFile(name, false);
 
        // Shall this code go or should it stay? (Lgb)
        // This code is a placeholder for future implementation. (Jose')
@@ -1405,18 +1413,23 @@ bool UpdateLayoutParagraph()
        }
 
        Buffer * buf = current_view->buffer();
+       LyXText * text = 0;
+       if (current_view->the_locking_inset)
+           text = current_view->the_locking_inset->getLyXText(current_view);
+       if (!text)
+           text = current_view->text;
 
        fl_set_input(fd_form_paragraph->input_labelwidth,
-                    current_view->text->cursor.par()->GetLabelWidthString().c_str());
+                    text->cursor.par()->GetLabelWidthString().c_str());
        fl_set_button(fd_form_paragraph->radio_align_right, 0);
        fl_set_button(fd_form_paragraph->radio_align_left, 0);
        fl_set_button(fd_form_paragraph->radio_align_center, 0);
        fl_set_button(fd_form_paragraph->radio_align_block, 0);
 
-       int align = current_view->text->cursor.par()->GetAlign();
+       int align = text->cursor.par()->GetAlign();
        if (align == LYX_ALIGN_LAYOUT)
                align = textclasslist.Style(buf->params.textclass,
-                                           current_view->text->cursor.par()->GetLayout()).align;
+                                           text->cursor.par()->GetLayout()).align;
         
        switch (align) {
        case LYX_ALIGN_RIGHT:
@@ -1432,20 +1445,41 @@ bool UpdateLayoutParagraph()
                fl_set_button(fd_form_paragraph->radio_align_block, 1);
                break;
        }
-        
+
+#ifndef NEW_INSETS
+       fl_set_button(fd_form_paragraph->check_lines_top,
+                     text->cursor.par()->FirstPhysicalPar()->line_top);
+
+       fl_set_button(fd_form_paragraph->check_lines_bottom,
+                     text->cursor.par()->FirstPhysicalPar()->line_bottom);
+
+       fl_set_button(fd_form_paragraph->check_pagebreaks_top,
+                     text->cursor.par()->FirstPhysicalPar()->pagebreak_top);
+
+       fl_set_button(fd_form_paragraph->check_pagebreaks_bottom,
+                     text->cursor.par()->FirstPhysicalPar()->pagebreak_bottom);
+       fl_set_button(fd_form_paragraph->check_noindent,
+                     text->cursor.par()->FirstPhysicalPar()->noindent);
+#else
        fl_set_button(fd_form_paragraph->check_lines_top,
-                     current_view->text->cursor.par()->FirstPhysicalPar()->line_top);
+                     text->cursor.par()->line_top);
        fl_set_button(fd_form_paragraph->check_lines_bottom,
-                     current_view->text->cursor.par()->FirstPhysicalPar()->line_bottom);
+                     text->cursor.par()->line_bottom);
        fl_set_button(fd_form_paragraph->check_pagebreaks_top,
-                     current_view->text->cursor.par()->FirstPhysicalPar()->pagebreak_top);
+                     text->cursor.par()->pagebreak_top);
        fl_set_button(fd_form_paragraph->check_pagebreaks_bottom,
-                     current_view->text->cursor.par()->FirstPhysicalPar()->pagebreak_bottom);
+                     text->cursor.par()->pagebreak_bottom);
        fl_set_button(fd_form_paragraph->check_noindent,
-                     current_view->text->cursor.par()->FirstPhysicalPar()->noindent);
+                     text->cursor.par()->noindent);
+#endif
        fl_set_input (fd_form_paragraph->input_space_above, "");
-       
-       switch (current_view->text->cursor.par()->FirstPhysicalPar()->added_space_top.kind()) {
+
+#ifndef NEW_INSETS
+       switch (text->cursor.par()->FirstPhysicalPar()->added_space_top.kind()) {
+#else
+       switch (text->cursor.par()->added_space_top.kind()) {
+#endif
+
        case VSpace::NONE:
                fl_set_choice (fd_form_paragraph->choice_space_above, 1);
                break;
@@ -1465,15 +1499,27 @@ bool UpdateLayoutParagraph()
                fl_set_choice (fd_form_paragraph->choice_space_above, 6);
                break;
        case VSpace::LENGTH:
-               fl_set_choice (fd_form_paragraph->choice_space_above, 7); 
+               fl_set_choice (fd_form_paragraph->choice_space_above, 7);
+#ifndef NEW_INSETS
+               fl_set_input  (fd_form_paragraph->input_space_above, 
+                              text->cursor.par()->FirstPhysicalPar()->added_space_top.length().asString().c_str());
+#else
                fl_set_input  (fd_form_paragraph->input_space_above, 
-                              current_view->text->cursor.par()->FirstPhysicalPar()->added_space_top.length().asString().c_str());
+                              text->cursor.par()->added_space_top.length().asString().c_str());
+#endif
                break;
        }
+#ifndef NEW_INSETS
        fl_set_button (fd_form_paragraph->check_space_above,
-                      current_view->text->cursor.par()->FirstPhysicalPar()->added_space_top.keep());
+                      text->cursor.par()->FirstPhysicalPar()->added_space_top.keep());
        fl_set_input (fd_form_paragraph->input_space_below, "");
-       switch (current_view->text->cursor.par()->FirstPhysicalPar()->added_space_bottom.kind()) {
+       switch (text->cursor.par()->FirstPhysicalPar()->added_space_bottom.kind()) {
+#else
+       fl_set_button (fd_form_paragraph->check_space_above,
+                      text->cursor.par()->added_space_top.keep());
+       fl_set_input (fd_form_paragraph->input_space_below, "");
+       switch (text->cursor.par()->added_space_bottom.kind()) {
+#endif
        case VSpace::NONE:
                fl_set_choice (fd_form_paragraph->choice_space_below,
                               1);
@@ -1500,17 +1546,28 @@ bool UpdateLayoutParagraph()
                break;
        case VSpace::LENGTH:
                fl_set_choice (fd_form_paragraph->choice_space_below,
-                              7); 
+                              7);
+#ifndef NEW_INSETS
                fl_set_input  (fd_form_paragraph->input_space_below, 
-                              current_view->text->cursor.par()->FirstPhysicalPar()->added_space_bottom.length().asString().c_str());
+                              text->cursor.par()->FirstPhysicalPar()->added_space_bottom.length().asString().c_str());
                break;
        }
        fl_set_button (fd_form_paragraph->check_space_below,
-                      current_view->text->cursor.par()->FirstPhysicalPar()->added_space_bottom.keep());
+                      text->cursor.par()->FirstPhysicalPar()->added_space_bottom.keep());
 
        fl_set_button(fd_form_paragraph->check_noindent,
-                     current_view->text->cursor.par()->FirstPhysicalPar()->noindent);
+                     text->cursor.par()->FirstPhysicalPar()->noindent);
+#else
+               fl_set_input  (fd_form_paragraph->input_space_below, 
+                              text->cursor.par()->added_space_bottom.length().asString().c_str());
+               break;
+       }
+       fl_set_button (fd_form_paragraph->check_space_below,
+                      text->cursor.par()->added_space_bottom.keep());
 
+       fl_set_button(fd_form_paragraph->check_noindent,
+                     text->cursor.par()->noindent);
+#endif
        if (current_view->buffer()->isReadonly()) {
                DisableParagraphLayout();
        } else {
@@ -2131,16 +2188,21 @@ extern "C" void ParagraphApplyCB(FL_OBJECT *, long)
        labelwidthstring = fl_get_input(fd_form_paragraph->input_labelwidth);
        noindent = fl_get_button(fd_form_paragraph->check_noindent);
 
-       current_view->text->SetParagraph(current_view,
-                                        line_top,
-                                        line_bottom,
-                                        pagebreak_top,
-                                        pagebreak_bottom,
-                                        space_top,
-                                        space_bottom,
-                                        align, 
-                                        labelwidthstring,
-                                        noindent);
+       LyXText * text = 0;
+       if (current_view->the_locking_inset)
+           text = current_view->the_locking_inset->getLyXText(current_view);
+       if (!text)
+           text = current_view->text;
+       text->SetParagraph(current_view,
+                          line_top,
+                          line_bottom,
+                          pagebreak_top,
+                          pagebreak_bottom,
+                          space_top,
+                          space_bottom,
+                          align, 
+                          labelwidthstring,
+                          noindent);
        current_view->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
        current_view->owner()->getMiniBuffer()->Set(_("Paragraph layout set"));
 }
@@ -2571,11 +2633,13 @@ extern "C" void PreambleOKCB(FL_OBJECT * ob, long data)
 
 /* callbacks for form form_table */
 
-extern "C" void TableApplyCB(FL_OBJECT *, long)
+extern "C"
+void TableApplyCB(FL_OBJECT *, long)
 {
        if (!current_view->available())
                return;
-   
+
+#ifndef NEW_TABULAR
        // check for tables in tables
        if (current_view->text->cursor.par()->table){
                WriteAlert(_("Impossible Operation!"),
@@ -2583,7 +2647,7 @@ extern "C" void TableApplyCB(FL_OBJECT *, long)
                           _("Sorry."));
                return;
        }
+#endif
        current_view->owner()->getMiniBuffer()->Set(_("Inserting table..."));
 
        int ysize = int(fl_get_slider_value(fd_form_table->slider_columns) + 0.5);
@@ -2611,8 +2675,10 @@ extern "C" void TableApplyCB(FL_OBJECT *, long)
        //if (!fl_get_button(fd_form_table->check_latex)){
        // insert the new wysiwy table
        current_view->text->SetLayout(current_view, 0); // standard layout
+#ifndef NEW_INSETS
        if (current_view->text->cursor.par()->footnoteflag == 
            LyXParagraph::NO_FOOTNOTE) {
+#endif
                current_view->text
                        ->SetParagraph(current_view, 0, 0,
                                       0, 0,
@@ -2625,6 +2691,7 @@ extern "C" void TableApplyCB(FL_OBJECT *, long)
                                       LYX_ALIGN_CENTER,
                                       string(),
                                       0);
+#ifndef NEW_INSETS
        } else {
                current_view->text
                        ->SetParagraph(current_view, 0, 0,
@@ -2635,16 +2702,17 @@ extern "C" void TableApplyCB(FL_OBJECT *, long)
                                       string(),
                                       0);
        }
-       
+#endif
+#ifndef NEW_TABULAR
        current_view->text->cursor.par()->table =
                new LyXTable(xsize, ysize);
-
+#endif
        Language const * lang = 
                current_view->text->cursor.par()->getParLanguage(current_view->buffer()->params);
        LyXFont font(LyXFont::ALL_INHERIT, lang);
        for (int i = 0; i < xsize * ysize - 1; ++i) {
-               current_view->text->cursor.par()->InsertChar(0, LyXParagraph::META_NEWLINE);
-               current_view->text->cursor.par()->SetFont(0, font);
+               current_view->text->cursor.par()
+                       ->InsertChar(0, LyXParagraph::META_NEWLINE, font);
        }
        current_view->text->RedoParagraph(current_view);
    
@@ -2656,13 +2724,15 @@ extern "C" void TableApplyCB(FL_OBJECT *, long)
 }
 
 
-extern "C" void TableCancelCB(FL_OBJECT *, long)
+extern "C"
+void TableCancelCB(FL_OBJECT *, long)
 {
        fl_hide_form(fd_form_table->form_table);
 }
 
 
-extern "C" void TableOKCB(FL_OBJECT * ob, long data)
+extern "C"
+void TableOKCB(FL_OBJECT * ob, long data)
 {
        TableApplyCB(ob, data);
        TableCancelCB(ob, data);
@@ -2694,7 +2764,8 @@ void Table()
 
 
 /* callbacks for form form_figure */
-extern "C" void FigureApplyCB(FL_OBJECT *, long)
+extern "C"
+void FigureApplyCB(FL_OBJECT *, long)
 {
        if (!current_view->available())
                return;
@@ -2705,7 +2776,10 @@ extern "C" void FigureApplyCB(FL_OBJECT *, long)
        
        current_view->owner()->getMiniBuffer()->Set(_("Inserting figure..."));
        if (fl_get_button(fd_form_figure->radio_inline)
-           || current_view->text->cursor.par()->table) {
+#ifndef NEW_TABULAR
+           || current_view->text->cursor.par()->table
+#endif
+               ) {
                InsetFig * new_inset = new InsetFig(100, 20, buffer);
                current_view->insertInset(new_inset);
                current_view->owner()->getMiniBuffer()->Set(_("Figure inserted"));
@@ -2732,9 +2806,11 @@ extern "C" void FigureApplyCB(FL_OBJECT *, long)
 
        // The standard layout should always be numer 0;
        current_view->text->SetLayout(current_view, 0);
-       
+
+#ifndef NEW_INSETS
        if (current_view->text->cursor.par()->footnoteflag == 
            LyXParagraph::NO_FOOTNOTE) {
+#endif
                current_view->text->
                        SetParagraph(current_view, 0, 0,
                                     0, 0,
@@ -2744,6 +2820,7 @@ extern "C" void FigureApplyCB(FL_OBJECT *, long)
                                             buffer->params.spacing.getValue(),
                                             LyXLength::CM),
                                     LYX_ALIGN_CENTER, string(), 0);
+#ifndef NEW_INSETS
        } else {
                current_view->text->SetParagraph(current_view, 0, 0,
                                                 0, 0,
@@ -2753,6 +2830,7 @@ extern "C" void FigureApplyCB(FL_OBJECT *, long)
                                                 string(),
                                                 0);
        }
+#endif
        
        current_view->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
       
@@ -2785,6 +2863,7 @@ extern "C" void ScreenApplyCB(FL_OBJECT *, long)
        lyxrc.sans_font_name = fl_get_input(fd_form_screen->input_sans);
        lyxrc.typewriter_font_name = fl_get_input(fd_form_screen->input_typewriter);
        lyxrc.font_norm = fl_get_input(fd_form_screen->input_font_norm);
+       lyxrc.set_font_norm_type();
        lyxrc.zoom = atoi(fl_get_input(fd_form_screen->intinput_size));
        fontloader.update();
 
@@ -2815,24 +2894,6 @@ extern "C" void ScreenOKCB(FL_OBJECT * ob, long data)
 }
 
 
-void LaTeXOptions(BufferView * bv)
-{
-       if (!bv->available())
-               return;
-
-       fl_set_button(fd_latex_options->accents,
-                     int(bv->buffer()->params.allowAccents));
-       
-       if (fd_latex_options->LaTeXOptions->visible) {
-               fl_raise_form(fd_latex_options->LaTeXOptions);
-       } else {
-               fl_show_form(fd_latex_options->LaTeXOptions,
-                            FL_PLACE_MOUSE, FL_FULLBORDER,
-                            _("LaTeX Options"));
-       }
-}
-
-
 // This function runs "configure" and then rereads lyx.defaults to
 // reconfigure the automatic settings.
 void Reconfigure(BufferView * bv)