]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/listctrl.cpp
set more event object fields for lbox dbl click events
[wxWidgets.git] / src / generic / listctrl.cpp
index b546c685a7517ce1e6a0d5215ed289123a305b3c..6b0861d9b0a61db69447308ecc0da1b08cd34947 100644 (file)
@@ -264,6 +264,7 @@ public:
                     const wxValidator& validator = wxDefaultValidator,
                     const wxString &name = "listctrltextctrl" );
     void OnChar( wxKeyEvent &event );
+    void OnKeyUp( wxKeyEvent &event );
     void OnKillFocus( wxFocusEvent &event );
 
 private:
@@ -768,6 +769,8 @@ void wxListLineData::CalculateSize( wxDC *dc, int spacing )
                 m_bound_all.height = lh;
                 node = node->Next();
             }
+            m_bound_label.width = m_bound_all.width;
+            m_bound_label.height = m_bound_all.height;
             break;
         }
     }
@@ -1467,6 +1470,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxListTextCtrl,wxTextCtrl);
 
 BEGIN_EVENT_TABLE(wxListTextCtrl,wxTextCtrl)
     EVT_CHAR           (wxListTextCtrl::OnChar)
+    EVT_KEY_UP         (wxListTextCtrl::OnKeyUp)    
     EVT_KILL_FOCUS     (wxListTextCtrl::OnKillFocus)
 END_EVENT_TABLE()
 
@@ -1520,6 +1524,21 @@ void wxListTextCtrl::OnChar( wxKeyEvent &event )
     event.Skip();
 }
 
+void wxListTextCtrl::OnKeyUp( wxKeyEvent &event )
+{
+    // auto-grow the textctrl:
+    wxSize parentSize = m_owner->GetSize();
+    wxPoint myPos = GetPosition();
+    wxSize mySize = GetSize();
+    int sx, sy;
+    GetTextExtent(GetValue() + _T("MM"), &sx, &sy);
+    if (myPos.x + sx > parentSize.x) sx = parentSize.x - myPos.x;
+    if (mySize.x > sx) sx = mySize.x;
+    SetSize(sx, -1);
+    
+    event.Skip();
+}
+
 void wxListTextCtrl::OnKillFocus( wxFocusEvent &WXUNUSED(event) )
 {
     if (!wxPendingDelete.Member(this))