]> git.lyx.org Git - features.git/commitdiff
xforms alert fixes
authorJohn Levon <levon@movementarian.org>
Sat, 29 Mar 2003 08:45:28 +0000 (08:45 +0000)
committerJohn Levon <levon@movementarian.org>
Sat, 29 Mar 2003 08:45:28 +0000 (08:45 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6624 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/xforms/Alert_pimpl.C
src/frontends/xforms/ChangeLog
src/frontends/xforms/xforms_helpers.C
src/frontends/xforms/xforms_helpers.h

index 816c55df29bac08c669b4e4a27cdde3d11f82d1b..eed7b52495c4c5bc6d0779e25f550e372dca6375 100644 (file)
 #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)
 {
@@ -29,20 +32,27 @@ void alert_pimpl(string const & s1, string const & s2, string const & s3)
 }
 
 
-#warning error needs fixing up
-#warning a "&Save" -> "Save|#S" is whats needed
-#warning and a format maybe, and fixup default_button ?
-
-int prompt_pimpl(string const & title, string const & question,
+int prompt_pimpl(string const &, string const & question,
            int default_button,
-          string const & b1, string const & b2, string const & b3);
+          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);
+       lyxerr  << "Parsed " << b1 << " as " << b1label << " and " << b1sc << endl;
+
        if (b3.empty()) {
-               return fl_show_choice(title.c_str(), question.c_str(), "",
-                       2, b1.c_str(), b2.c_str(), 2);
+               fl_set_choices_shortcut(b1sc.c_str(), b2sc.c_str(), "");
+               return fl_show_choices(question.c_str(),
+                       2, b1label.c_str(), b2label.c_str(), "", default_button + 1) - 1;
        } else {
-               return fl_show_choice(title.c_str(), question.c_str(), "",
-                       3, b1.c_str(), b2.c_str(), b3.c_str(), 3);
+               fl_set_choices_shortcut(b1sc.c_str(), b2sc.c_str(), b3sc.c_str());
+               return fl_show_choices(question.c_str(),
+                       3, b1label.c_str(), b2label.c_str(), b3label.c_str(),
+                       default_button + 1) - 1;
        }
 }
 
index b81ba40a26f2be4b8c270ddef19a4227bc924187..0e95aa159174b58093f1eabf535679d6f18105b8 100644 (file)
@@ -1,3 +1,10 @@
+2003-03-29  John Levon  <levon@movementarian.org>
+
+       * xforms_helpers.h:
+       * xforms_helpers.C: add parseShortcut()
+
+       * Alert_pimpl.C: fixes
+
 2003-03-29  John Levon  <levon@movementarian.org>
 
        * Alert_pimpl.C: implement prompt()
index b55ee03351f9799872196fed8e604b3095ee3b10..67055a5c1a5425e78446ff0ce11ee70d4a986a95 100644 (file)
 #include "support/filetools.h"
 #include "support/lstrings.h" // frontStrip, strip
 
-#include <algorithm>
 #include <fstream>
-#include <vector>
 
 #include FORMS_H_LOCATION
 
 using std::ofstream;
 using std::pair;
 using std::vector;
+using std::make_pair;
 
 bool isActive(FL_OBJECT * ob)
 {
        return ob && ob->active > 0;
 }
 
+std::pair<string, string> parse_shortcut(string const & str)
+{
+       string::size_type i = str.find_first_of("&");
+       if (i == string::npos || i == str.length() - 1)
+               return make_pair(str, string());
+
+       // FIXME: handle &&
+
+       string::value_type c = str[i + 1];
+       return make_pair(str.substr(0, i) + str.substr(i + 1),
+               string("#") + c);
+}
+
 
 // A wrapper for the xforms routine, but this one accepts uint args
 unsigned long fl_getmcolor(int i,
index d5f3ba146449cb0c08f7968c8a787c8039c3afcb..bdc4580ea1831b1b3851daf152ed0da7624a141a 100644 (file)
@@ -23,6 +23,9 @@
 
 class LyXLength;
 
+/// parse "&Save" etc. to <"Save", "#S">. Does not handle &&
+std::pair<string, string> parse_shortcut(string const & str);
+
 // A wrapper for the xforms routine, but this one accepts uint args
 unsigned long fl_getmcolor(int i, unsigned int * r, unsigned int * g,
                           unsigned int * b);