]> git.lyx.org Git - lyx.git/blobdiff - src/lyx_gui_misc.C
fix the smallcaps drawing, move xfont metrics functions out from LyXFont, move non...
[lyx.git] / src / lyx_gui_misc.C
index 802d3b7d789e9c14552715272e8a2195554ef8b5..96959eb131b77010bd5e319a122a645ddcb5f32c 100644 (file)
@@ -5,7 +5,7 @@
  *           LyX, The Document Processor
  *        
  *           Copyright 1995 Matthias Ettrich
- *           Copyright 1995-1999 The LyX Team.
+ *           Copyright 1995-2000 The LyX Team.
  *
  * ====================================================== */
 
 #include "print_form.h"
 #include "sp_form.h"
 #include "insets/insetindex.h"
+#include "LyXView.h"
 
-extern MiniBuffer *minibuffer;
-extern BufferView *current_view;
+using std::pair;
+using std::make_pair;
+
+extern BufferView * current_view;
 
 extern FD_form_paragraph * fd_form_paragraph;
 extern FD_form_paragraph_extra * fd_form_paragraph_extra;
-extern FD_form_search * fd_form_search;
 extern FD_form_character * fd_form_character;
 extern FD_form_document * fd_form_document;
 extern FD_form_paper * fd_form_paper;
@@ -96,9 +98,6 @@ void CloseAllBufferRelatedPopups()
        if (fd_form_paragraph_extra->form_paragraph_extra->visible) {
                fl_hide_form(fd_form_paragraph_extra->form_paragraph_extra);
        }
-       if (fd_form_search->form_search->visible) {
-               fl_hide_form(fd_form_search->form_search);
-       }
        if (fd_form_character->form_character->visible) {
                fl_hide_form(fd_form_character->form_character);
        }
@@ -305,42 +304,47 @@ void updateAllVisibleBufferRelatedPopups()
 }
 
 // Extract shortcut from <ident>|<shortcut> string
-const char* flyx_shortcut_extract(const char*sc)
+char const * flyx_shortcut_extract(char const * sc)
 {
        // Find '|' in the sc and return the string after that.
-       register char const *sd = sc;
-       while(sd[0]!= 0 && sd[0] != '|') sd++;
+       register char const * sd = sc;
+       while(sd[0]!= 0 && sd[0] != '|') ++sd;
 
        if (sd[0] == '|') {
-               sd++;
+               ++sd;
                //lyxerr << sd << endl;
                return sd;
        }
        return "";
 }
 
+
 // Extract identifier from <ident>|<shortcut> string
-const char* flyx_ident_extract(char const *sc)
+char const * flyx_ident_extract(char const * sc)
 {
-       register char const *se = sc;
-       while(se[0]!= 0 && se[0] != '|') se++;
+       register char const * se = sc;
+       while(se[0]!= 0 && se[0] != '|') ++se;
 
        if (se[0] == 0) return sc;
        
-       char * sb = new char[se-sc + 1];
+       char * sb = new char[se - sc + 1];
        int index = 0;
-       register char const *sd = sc;
+       register char const * sd = sc;
        while (sd != se) {
                sb[index] = sd[0];
-               index++; sd++;
+               ++index; ++sd;
        }
        sb[index] = 0;
        return sb;
 }
 
+
 //
 void WriteAlert(string const & s1, string const & s2, string const & s3)
 {
+       MiniBuffer * minibuffer = 0;
+       if (current_view && current_view->owner())
+               minibuffer = current_view->owner()->getMiniBuffer();
        if (minibuffer) {
                ProhibitInput();
                minibuffer->Set(s1, s2, s3);
@@ -365,54 +369,43 @@ bool AskQuestion(string const & s1, string const & s2, string const & s3)
 {
        fl_set_resource("flQuestion.yes.label", idex(_("Yes|Yy#y")));
        fl_set_resource("flQuestion.no.label", idex(_("No|Nn#n")));
-#if FL_REVISION > 85
        return fl_show_question((s1 + "\n" + s2 + "\n" + s3).c_str(), 0);
-#else
-       return fl_show_question(s1.c_str(), s2.c_str(), s3.c_str());
-#endif
 }
 
+
 // Returns 1 for yes, 2 for no, 3 for cancel.
 int AskConfirmation(string const & s1, string const & s2, string const & s3)
 {
        fl_set_choices_shortcut(scex(_("Yes|Yy#y")),
                                scex(_("No|Nn#n")),
                                scex(_("Cancel|^[")));
-#if FL_REVISION < 86
-        return fl_show_choice(s1.c_str(), s2.c_str(), s3.c_str(), 
-                             3, idex(_("Yes|Yy#y")),
-                             idex(_("No|Nn#n")),
-                             idex(_("Cancel|^[")));
-#endif
-#if FL_REVISION > 85
         return fl_show_choice(s1.c_str(), s2.c_str(), s3.c_str(), 
                              3, idex(_("Yes|Yy#y")),
                              idex(_("No|Nn#n")),
                               idex(_("Cancel|^[")), 3);
-#endif
 }
 
 
 // Asks for a text
-string askForText(string const & msg, string const & dflt)
+pair<bool, string> askForText(string const & msg, string const & dflt)
 {
-       const char * tmp;
+       char const * tmp;
        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")));
        tmp = fl_show_input(msg.c_str(), dflt.c_str());
        if (tmp != 0)
-         return tmp;
+         return make_pair<bool, string>(true, tmp);
        else
-         return string();
+         return make_pair<bool, string>(false, string());
 }
 
+
 // Inform the user that the buffer is read-only, and that changes in the
 // dialog box that is to appear will be ignored.
-void WarnReadonly()
+void WarnReadonly(string const & file)
 {
        WriteAlert(_("Any changes will be ignored"),
                   _("The document is read-only:"),
-                  current_view->buffer()->getFileName());
+                  file);
 }
-