lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [5261] Permit floating-point numbers in input-sequence edi


From: Greg Chicares
Subject: [lmi-commits] [5261] Permit floating-point numbers in input-sequence editor
Date: Fri, 19 Aug 2011 11:31:17 +0000

Revision: 5261
          http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=5261
Author:   chicares
Date:     2011-08-19 11:31:17 +0000 (Fri, 19 Aug 2011)
Log Message:
-----------
Permit floating-point numbers in input-sequence editor

Modified Paths:
--------------
    lmi/trunk/ChangeLog
    lmi/trunk/input_sequence_entry.cpp

Modified: lmi/trunk/ChangeLog
===================================================================
--- lmi/trunk/ChangeLog 2011-08-19 00:29:16 UTC (rev 5260)
+++ lmi/trunk/ChangeLog 2011-08-19 11:31:17 UTC (rev 5261)
@@ -28331,3 +28331,14 @@
   skin.xrc
 Use the input-sequence benefit types added 20110817T2009Z.
 
+20110819T0029Z <address@hidden> [622]
+
+  datum_sequence.hpp
+  input.hpp
+Make class datum_sequence abstract.
+
+20110819T1131Z <address@hidden> [622]
+
+  input_sequence_entry.cpp
+Permit floating-point numbers in input-sequence editor.
+

Modified: lmi/trunk/input_sequence_entry.cpp
===================================================================
--- lmi/trunk/input_sequence_entry.cpp  2011-08-19 00:29:16 UTC (rev 5260)
+++ lmi/trunk/input_sequence_entry.cpp  2011-08-19 11:31:17 UTC (rev 5261)
@@ -30,10 +30,12 @@
 
 #include "alert.hpp"
 #include "assert_lmi.hpp"
+#include "contains.hpp"
 #include "input.hpp"
 #include "input_seq_helpers.hpp"
 #include "input_sequence.hpp"
 #include "mvc_controller.hpp"
+#include "numeric_io_cast.hpp"
 #include "value_cast.hpp"
 #include "wx_new.hpp"
 #include "wx_utility.hpp"
@@ -272,7 +274,7 @@
     void adjust_duration_num_range(int row);
 
     void update_diagnostics();
-    bool is_valid_value(wxString const& s);
+    bool is_valid_value(wxString const&);
     wxString get_diagnostics_message();
 
     void UponValueChange(wxCommandEvent& event);
@@ -1033,20 +1035,29 @@
     ok_button_->Enable(msg.empty());
 }
 
-bool InputSequenceEditor::is_valid_value(wxString const& s)
+bool InputSequenceEditor::is_valid_value(wxString const& w)
 {
-    for(std::vector<std::string>::const_iterator k = keywords_.begin()
-       ;k != keywords_.end()
-       ;++k)
+    std::string const s(w.c_str());
+
+    if(contains(keywords_, s))
         {
-        if(s == *k)
-            return true;
+        return true;
         }
 
-    if(!keywords_only_)
-        return s.IsNumber();
+    if(keywords_only_)
+        {
+        return false;
+        }
 
-    return false;
+    try
+        {
+        numeric_io_cast<double>(s);
+        return true;
+        }
+    catch(...)
+        {
+        return false;
+        }
 }
 
 wxString InputSequenceEditor::get_diagnostics_message()




reply via email to

[Prev in Thread] Current Thread [Next in Thread]