lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [5031] Fix defect introduced 20100704T1645Z


From: Greg Chicares
Subject: [lmi-commits] [5031] Fix defect introduced 20100704T1645Z
Date: Sun, 11 Jul 2010 14:22:50 +0000

Revision: 5031
          http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=5031
Author:   chicares
Date:     2010-07-11 14:22:49 +0000 (Sun, 11 Jul 2010)
Log Message:
-----------
Fix defect introduced 20100704T1645Z

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

Modified: lmi/trunk/ChangeLog
===================================================================
--- lmi/trunk/ChangeLog 2010-07-11 14:21:50 UTC (rev 5030)
+++ lmi/trunk/ChangeLog 2010-07-11 14:22:49 UTC (rev 5031)
@@ -26305,3 +26305,21 @@
   database.cpp
 Optionally reverse the meaning of 'DB_PremTaxState', for testing.
 
+20100711T1420Z <address@hidden> [693]
+
+  input_sequence_entry.cpp
+Fix defect introduced 20100704T1645Z. See:
+  http://lists.nongnu.org/archive/html/lmi/2010-07/msg00015.html
+
+20100711T1421Z <address@hidden> [693]
+
+  input_sequence_entry.cpp
+Fix defect introduced 20100704T1645Z. See:
+  http://lists.nongnu.org/archive/html/lmi/2010-07/msg00016.html
+
+20100711T1422Z <address@hidden> [693]
+
+  input_sequence_entry.cpp
+Fix defect introduced 20100704T1645Z. See:
+  http://lists.nongnu.org/archive/html/lmi/2010-07/msg00017.html
+

Modified: lmi/trunk/input_sequence_entry.cpp
===================================================================
--- lmi/trunk/input_sequence_entry.cpp  2010-07-11 14:21:50 UTC (rev 5030)
+++ lmi/trunk/input_sequence_entry.cpp  2010-07-11 14:22:49 UTC (rev 5031)
@@ -194,6 +194,7 @@
     void remove_row(int row);
     void update_row(int row);
     void redo_layout();
+    void set_tab_order();
     wxString format_from_text(int row);
 
     enum Col
@@ -250,6 +251,7 @@
 
     template<typename T>
     T& get_field(int col, int row);
+    wxWindow* get_field_win(int col, int row);
 
     int compute_duration_scalar(int row);
     void adjust_duration_num(int row);
@@ -265,7 +267,8 @@
 
     int rows_count_;
     wxFlexGridSizer* sizer_;
-    wxButton* last_button_;
+    wxButton* ok_button_;
+    wxButton* cancel_button_;
     typedef std::map<wxWindowID, int> id_to_row_map;
     id_to_row_map id_to_row_;
 
@@ -293,8 +296,8 @@
     top->Add(sizer_, wxSizerFlags(1).Expand().DoubleBorder());
 
     wxStdDialogButtonSizer* buttons = new(wx) wxStdDialogButtonSizer();
-    buttons->AddButton(new(wx) wxButton(this, wxID_OK));
-    buttons->AddButton(last_button_ = new(wx) wxButton(this, wxID_CANCEL));
+    buttons->AddButton(ok_button_ = new(wx) wxButton(this, wxID_OK));
+    buttons->AddButton(cancel_button_ = new(wx) wxButton(this, wxID_CANCEL));
     buttons->Realize();
 
     top->Add(buttons, wxSizerFlags().Expand().Border());
@@ -542,7 +545,6 @@
 #endif
 
     remove->SetToolTip("Remove this row");
-    remove->MoveBeforeInTabOrder(last_button_);
     remove->Connect
         (wxEVT_COMMAND_BUTTON_CLICKED
         ,wxCommandEventHandler(InputSequenceEditor::UponRemoveRow)
@@ -565,7 +567,6 @@
 #endif
 
     add->SetToolTip("Insert a new row after this one");
-    add->MoveBeforeInTabOrder(last_button_);
     add->Connect
         (wxEVT_COMMAND_BUTTON_CLICKED
         ,wxCommandEventHandler(InputSequenceEditor::UponAddRow)
@@ -587,7 +588,7 @@
     // belong to which row
     for(int i = 0; i < Col_Max; ++i)
         {
-        id_to_row_[get_field<wxWindow>(i, new_row).GetId()] = new_row;
+        id_to_row_[get_field_win(i, new_row)->GetId()] = new_row;
         }
 
     if(0 == rows_count_)
@@ -598,6 +599,8 @@
     rows_count_++;
     duration_scalars_.insert(duration_scalars_.begin() + new_row, -1);
 
+    set_tab_order();
+
     // update state of controls on the two rows affected by addition of
     // a new row
     if(prev_row != -1)
@@ -609,6 +612,44 @@
     redo_layout();
 }
 
+void InputSequenceEditor::set_tab_order()
+{
+    // The desired tab order is as follows:
+    // 1. data entry fields from left to right, top to bottom:
+    //      Col_Value
+    //      Col_From
+    //      Col_DurationMode
+    //      Col_DurationNum
+    //      Col_Then
+    // 2. dialog's OK button
+    // 3. then Remove and Add buttons, top to bottom
+    //      Col_Remove
+    //      Col_Add
+    // 4. dialog's Cancel button
+
+    if(0 == rows_count_)
+        return;
+
+    std::vector<wxWindow*> order;
+    for(int row = 0; row < rows_count_; ++row)
+        {
+        for (int col = Col_Value; col <= Col_Then; ++col)
+            order.push_back(get_field_win(col, row));
+        }
+    order.push_back(ok_button_);
+    for(int row = 0; row < rows_count_; ++row)
+        {
+        order.push_back(get_field_win(Col_Remove, row));
+        order.push_back(get_field_win(Col_Add, row));
+        }
+    order.push_back(cancel_button_);
+
+    for(size_t i = 1; i < order.size(); ++i)
+        {
+        order[i]->MoveAfterInTabOrder(order[i - 1]);
+        }
+}
+
 void InputSequenceEditor::remove_row(int row)
 {
     duration_scalars_.erase(duration_scalars_.begin() + row);
@@ -771,8 +812,7 @@
     throw "Unreachable--silences a compiler diagnostic.";
 }
 
-template<typename T>
-T& InputSequenceEditor::get_field(int col, int row)
+wxWindow* InputSequenceEditor::get_field_win(int col, int row)
 {
     wxSizerItem* i = sizer_->GetItem(col + Col_Max * row);
     LMI_ASSERT(i);
@@ -780,7 +820,13 @@
     wxWindow* w = i->GetWindow();
     LMI_ASSERT(w);
 
-    T* t = dynamic_cast<T*>(w);
+    return w;
+}
+
+template<typename T>
+T& InputSequenceEditor::get_field(int col, int row)
+{
+    T* t = dynamic_cast<T*>(get_field_win(col, row));
     LMI_ASSERT(t);
 
     return *t;




reply via email to

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