lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] (no subject)


From: Greg Chicares
Subject: [lmi-commits] (no subject)
Date: Fri, 3 Jun 2016 23:13:49 +0000 (UTC)

branch: master
commit 8b34a2f830a4124759f9b7e5a6fba972eeaeaece
Author: Gregory W. Chicares <address@hidden>
Date:   Fri Jun 3 23:13:07 2016 +0000

    Avoid using inverted wxSpinCtrl range in InputSequenceEditor (VZ)
    
    Disable wxSpinCtrl instead as inversed ranges behave counterintuitively
    in wxMSW and are not supported at all under other platforms.
---
 input_sequence_entry.cpp |   24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/input_sequence_entry.cpp b/input_sequence_entry.cpp
index 728f3e9..cbf1815 100644
--- a/input_sequence_entry.cpp
+++ b/input_sequence_entry.cpp
@@ -1066,21 +1066,27 @@ void InputSequenceEditor::adjust_duration_num_range(int 
row)
     int const prev_duration = (row > 0) ? duration_scalars_[row - 1] : 0;
     wxSpinCtrl& duration = duration_num_field(row);
 
+    int range_min = 0;
+    int range_max = 0;
+
     switch(duration_mode_field(row).value())
         {
         case e_attained_age:
             {
-            duration.SetRange(input_.issue_age() + 1 + prev_duration, 
input_.maturity_age() - 1);
+            range_min = input_.issue_age() + 1 + prev_duration;
+            range_max = input_.maturity_age() - 1;
             break;
             }
         case e_duration:
             {
-            duration.SetRange(1 + prev_duration, input_.years_to_maturity() - 
1);
+            range_min = 1 + prev_duration;
+            range_max = input_.years_to_maturity() - 1;
             break;
             }
         case e_number_of_years:
             {
-            duration.SetRange(1, input_.years_to_maturity() - prev_duration - 
1);
+            range_min = 1;
+            range_max = input_.years_to_maturity() - prev_duration - 1;
             break;
             }
         case e_maturity:
@@ -1093,6 +1099,18 @@ void InputSequenceEditor::adjust_duration_num_range(int 
row)
             break;
             }
         }
+
+    // See:
+    //   http://lists.nongnu.org/archive/html/lmi/2015-05/msg00006.html
+    if(range_min <= range_max)
+        {
+        duration.Enable();
+        duration.SetRange(range_min, range_max);
+        }
+    else
+        {
+        duration.Disable();
+        }
 }
 
 void InputSequenceEditor::adjust_duration_num(int row)



reply via email to

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