]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/Alert_pimpl.C
remove defaults stuff, let Qt handle no toolbar
[lyx.git] / src / frontends / xforms / Alert_pimpl.C
index 33436e32334caa0d296845038ee752c5e01ee67f..79d5b28a15b2064d166cab003dc80f4fe05b5ba8 100644 (file)
@@ -1,61 +1,80 @@
 /**
- * \file Alert_pimpl.C
- * Copyright 2001 the LyX Team
- * Read the file COPYING
+ * \file xforms/Alert_pimpl.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- * \author John Levon <moz@compsoc.man.ac.uk>
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS
  */
 
 #include <config.h>
 
-#include FORMS_H_LOCATION
-#include <algorithm>
-#include <gettext.h>
-#include "xforms_helpers.h"
+
 #include "Alert.h"
-#include "Alert_pimpl.h" 
+#include "Alert_pimpl.h"
+#include "forms_gettext.h"
+#include "gettext.h"
+#include "xforms_helpers.h"
+
+#include <algorithm>
+#include <boost/tuple/tuple.hpp>
+#include FORMS_H_LOCATION
+
 using std::pair;
 using std::make_pair;
+using std::endl;
 
-void alert_pimpl(string const & s1, string const & s2, string const & s3)
+void warning_pimpl(string const &, string const & message)
 {
-       fl_set_resource("flAlert.dismiss.label", _("Dismiss"));
-       fl_show_alert(s1.c_str(), s2.c_str(), s3.c_str(), 0);
+       fl_show_messages(formatted(message, 300).c_str());
 }
 
 
-bool askQuestion_pimpl(string const & s1, string const & s2, string const & s3)
+void error_pimpl(string const &, string const & message)
 {
-       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);
+       fl_show_messages(formatted(message, 300).c_str());
 }
 
 
-int askConfirmation_pimpl(string const & s1, string const & s2, string const & s3)
+void information_pimpl(string const &, string const & message)
 {
-       fl_set_choices_shortcut(scex(_("Yes|Yy#y")),
-                               scex(_("No|Nn#n")),
-                               scex(_("Cancel|^[")));
-        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);
+       fl_show_messages(formatted(message, 300).c_str());
+}
+
+
+int prompt_pimpl(string const &, string const & question,
+           int default_button,
+          string const & b1, string const & b2, string const & b3)
+{
+       string b1label, b1sc;
+       string b2label, b2sc;
+       string b3label, b3sc;
+       boost::tie(b1label, b1sc) = parse_shortcut(b1);
+       boost::tie(b2label, b2sc) = parse_shortcut(b2);
+       boost::tie(b3label, b3sc) = parse_shortcut(b3);
+
+       if (b3.empty()) {
+               fl_set_choices_shortcut(b1sc.c_str(), b2sc.c_str(), "");
+               return fl_show_choices(formatted(question, 300).c_str(),
+                       2, b1label.c_str(), b2label.c_str(), "", default_button + 1) - 1;
+       } else {
+               fl_set_choices_shortcut(b1sc.c_str(), b2sc.c_str(), b3sc.c_str());
+               return fl_show_choices(formatted(question, 300).c_str(),
+                       3, b1label.c_str(), b2label.c_str(), b3label.c_str(),
+                       default_button + 1) - 1;
+       }
 }
 
 
 pair<bool, string> const askForText_pimpl(string const & msg, string const & 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")));
+       fl_set_resource("flInput.cancel.label", idex(_("Cancel|^[")).c_str());
+       fl_set_resource("flInput.ok.label", idex(_("OK|^M")).c_str());
+       fl_set_resource("flInput.clear.label", idex(_("Clear|#C")).c_str());
        char const * tmp = fl_show_input(msg.c_str(), dflt.c_str());
        if (tmp != 0)
-         return make_pair<bool, string>(true, string(tmp));
+               return make_pair<bool, string>(true, string(tmp));
        else
-         return make_pair<bool, string>(false, string());
+               return make_pair<bool, string>(false, string());
 }