]> git.lyx.org Git - lyx.git/blobdiff - src/lyx_gui_misc.C
More fixes to insettabular/text (and some missing features added).
[lyx.git] / src / lyx_gui_misc.C
index 53793e89234e04e1932190beb7757cd2594b7a41..bb067c0e02fd9b8a810d876b9fffb673bdd168e3 100644 (file)
@@ -20,6 +20,7 @@
 #include "BufferView.h"
 #include "bibforms.h"
 #include "buffer.h"
+#include "credits_form.h"
 #include "form1.h"
 #include "gettext.h"
 #include "include_form.h"
 #include "LyXView.h"
 #include "bufferview_funcs.h"
 #include "support/filetools.h"
+#include "lyxrc.h"
 
 using std::pair;
 using std::make_pair;
+using std::endl;
 
 extern BufferView * current_view;
 
 extern FD_form_character * fd_form_character;
+extern FD_form_credits * fd_form_credits;
+extern FD_form_figure * fd_form_figure;
 extern FD_form_preamble * fd_form_preamble;
 extern FD_form_sendto * fd_form_sendto;
-extern FD_form_figure * fd_form_figure;
-extern FD_LaTeXLog * fd_latex_log;
 extern FD_form_spell_check * fd_form_spell_check;
+extern FD_form_spell_options * fd_form_spell_options;
+extern FD_LaTeXLog * fd_latex_log;
 extern FD_panel  * fd_panel;
 extern FD_delim  * fd_delim;
 extern FD_deco   * fd_deco;
@@ -62,15 +67,59 @@ extern "C" int CancelCloseBoxCB(FL_FORM *, void *)
 {
        return FL_CANCEL;
 }
-
-
-// Prevents LyX from being killed when the close box is pressed in a popup.
-extern "C" int IgnoreCloseBoxCB(FL_FORM *, void *)
+// Redraw the form (on receipt of a Signal indicating, for example,
+// that the xform colors have been re-mapped).
+void RedrawAllBufferRelatedDialogs()
 {
-       return FL_IGNORE;
+       if (bibitem_form && bibitem_form->bibitem_form->visible) {
+               fl_redraw_form(bibitem_form->bibitem_form);
+       }
+       if (fd_deco && fd_deco->deco->visible) {
+               fl_redraw_form(fd_deco->deco);
+       }
+       if (fd_delim && fd_delim->delim->visible) {
+               fl_redraw_form(fd_delim->delim);
+       }
+       if (fd_form_character->form_character->visible) {
+               fl_redraw_form(fd_form_character->form_character);
+       }
+       if (fd_form_credits && fd_form_credits->form_credits->visible) {
+               fl_redraw_form(fd_form_credits->form_credits);
+       }
+       if (fd_form_figure->form_figure->visible) {
+               fl_redraw_form(fd_form_figure->form_figure);
+       }
+       if (fd_form_preamble->form_preamble->visible) {
+               fl_redraw_form(fd_form_preamble->form_preamble);
+       }
+       if (fd_form_sendto->form_sendto->visible) {
+               fl_redraw_form(fd_form_sendto->form_sendto);
+       }
+       if (fd_form_spell_check &&
+           fd_form_spell_check->form_spell_check->visible) {
+               fl_redraw_form(fd_form_spell_check->form_spell_check);
+       }
+       if (fd_form_spell_options &&
+           fd_form_spell_options->form_spell_options->visible) {
+               fl_redraw_form(fd_form_spell_options->form_spell_options);
+       }
+       if (fd_latex_log->LaTeXLog->visible) {
+               fl_redraw_form(fd_latex_log->LaTeXLog);
+       }
+       if (fd_matrix && fd_matrix->matrix->visible) {
+               fl_redraw_form(fd_matrix->matrix);
+       }
+       if (fd_panel && fd_panel->panel->visible) {
+               fl_redraw_form(fd_panel->panel);
+       }
+       if (fd_space && fd_space->space->visible) {
+               fl_redraw_form(fd_space->space);
+       }
+       if (form && form->include->visible) {
+               fl_redraw_form(form->include);
+       }
 }
 
-
 // Prevents LyX from crashing when no buffers available
 // This is also one of the functions that we _really_ dont want
 // we should try to finds way to help us with that.
@@ -141,15 +190,15 @@ void CloseAllBufferRelatedDialogs()
 
 // This is another function we really don't want.
 // Again the Signal/Slot mechanism is tailor made for this task.
-void updateAllVisibleBufferRelatedDialogs()
+void updateAllVisibleBufferRelatedDialogs(bool)
 {
        if (fd_form_preamble->form_preamble->visible) {
-               UpdateLayoutPreamble();
+               UpdateLayoutPreamble(current_view);
        }
        if (fd_latex_log->LaTeXLog->visible) {
                LatexLogUpdate(0,0);
        }
-       if (current_view->buffer()->isReadonly()) {
+       if (current_view->buffer() &&  current_view->buffer()->isReadonly()) {
                // a little crude perhaps but it works. ARRae
                if (fd_form_character->form_character->visible) {
                        fl_hide_form(fd_form_character->form_character);
@@ -304,8 +353,23 @@ void WriteFSAlert(string const & s1, string const & s2)
 }
 
 
-bool AskQuestion(string const & s1, string const & s2, string const & s3)
+bool AskQuestion(string const & s1, string const & s2, string const & s3,
+                bool default_value)
 {
+       if (!lyxrc.use_gui) {
+               lyxerr << "----------------------------------------" << endl
+                      << s1 << endl;
+               if (!s2.empty())
+                       lyxerr << s2 << endl;
+               if (!s3.empty())
+                       lyxerr << s3 << endl;
+               lyxerr << "Assuming answer is "
+                      << (default_value ? "yes" : "no")
+                      << endl
+                      << "----------------------------------------" << endl;
+               return default_value;
+       }
+
        fl_set_resource("flQuestion.yes.label", idex(_("Yes|Yy#y")));
        fl_set_resource("flQuestion.no.label", idex(_("No|Nn#n")));
        return fl_show_question((s1 + "\n" + s2 + "\n" + s3).c_str(), 0);
@@ -313,8 +377,28 @@ bool AskQuestion(string const & s1, string const & s2, string const & s3)
 
 
 // Returns 1 for yes, 2 for no, 3 for cancel.
-int AskConfirmation(string const & s1, string const & s2, string const & s3)
+int AskConfirmation(string const & s1, string const & s2, string const & s3,
+                   int default_value)
 {
+       if (!lyxrc.use_gui) {
+               lyxerr << "----------------------------------------" << endl
+                      << s1 << endl;
+               if (!s2.empty())
+                       lyxerr << s2 << endl;
+               if (!s3.empty())
+                       lyxerr << s3 << endl;
+               lyxerr << "Assuming answer is ";
+               if (default_value == 1)
+                       lyxerr << "yes";
+               else if (default_value == 2)
+                       lyxerr << "no";
+               else
+                       lyxerr << "cancel";
+               lyxerr << endl
+                      << "----------------------------------------" << endl;
+               return default_value;
+       }
+
        fl_set_choices_shortcut(scex(_("Yes|Yy#y")),
                                scex(_("No|Nn#n")),
                                scex(_("Cancel|^[")));
@@ -329,6 +413,14 @@ int AskConfirmation(string const & s1, string const & s2, string const & s3)
 pair<bool, string> const
 askForText(string const & msg, string const & dflt)
 {
+       if (!lyxrc.use_gui) {
+               lyxerr << "----------------------------------------" << endl
+                      << msg << endl
+                      << "Assuming answer is " << dflt
+                      << "----------------------------------------" << endl;
+               return make_pair<bool, string>(true, dflt);
+       }
+
        fl_set_resource("flInput.cancel.label", idex(_("Cancel|^[")));
        fl_set_resource("flInput.ok.label", idex(_("OK|#O")));
        fl_set_resource("flInput.clear.label", idex(_("Clear|#e")));
@@ -352,7 +444,7 @@ void WarnReadonly(string const & file)
 /// Get the dpi setting of the current screen
 float getScreenDPI()
 {
-       Screen * scr = DefaultScreenOfDisplay(fl_get_display());
+       Screen * scr = ScreenOfDisplay(fl_get_display(), fl_screen); //DefaultScreen(fl_get_display());
        return ((HeightOfScreen(scr) * 25.4 / HeightMMOfScreen(scr)) +
                (WidthOfScreen(scr) * 25.4 / WidthMMOfScreen(scr))) / 2;
 }