]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/listctrl.cpp
Changed BidEndianOrdered to BigEndianOrdered in datstrm.h
[wxWidgets.git] / src / generic / listctrl.cpp
index f9b74282d597175c0a421fb2dd8c5ea4463812c9..65f568eb3ba43c0b5570ef1a92ed962538f33ada 100644 (file)
@@ -20,7 +20,7 @@
 
 #include "wx/dcscreen.h"
 #include "wx/app.h"
-#include "wx/generic/listctrl.h"
+#include "wx/listctrl.h"
 #include "wx/generic/imaglist.h"
 
 //-----------------------------------------------------------------------------
@@ -899,6 +899,9 @@ wxListTextCtrl::wxListTextCtrl( wxWindow *parent, const wxWindowID id,
     m_res = res;
     m_accept = accept;
     m_owner = owner;
+    (*m_accept) = FALSE;
+    (*m_res) = "";
+    m_startValue = value;
 }
 
 void wxListTextCtrl::OnChar( wxKeyEvent &event )
@@ -907,15 +910,14 @@ void wxListTextCtrl::OnChar( wxKeyEvent &event )
     {
         (*m_accept) = TRUE;
         (*m_res) = GetValue();
-        m_owner->OnRenameAccept();
-        if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this);
+       m_owner->SetFocus();
         return;
     }
     if (event.m_keyCode == WXK_ESCAPE)
     {
         (*m_accept) = FALSE;
         (*m_res) = "";
-        if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this);
+       m_owner->SetFocus();
         return;
     }
     event.Skip();
@@ -923,10 +925,12 @@ void wxListTextCtrl::OnChar( wxKeyEvent &event )
 
 void wxListTextCtrl::OnKillFocus( wxFocusEvent &WXUNUSED(event) )
 {
-    (*m_accept) = FALSE;
-    (*m_res) = "";
-    if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this);
-    return;
+    if (wxPendingDelete.Member(this)) return;
+
+    wxPendingDelete.Append(this);
+    
+    if ((*m_accept) && ((*m_res) != m_startValue))
+        m_owner->OnRenameAccept();
 }
 
 //-----------------------------------------------------------------------------
@@ -1139,10 +1143,10 @@ void wxListMainWindow::DeleteLine( wxListLineData *line )
 
 /* *** */
 
-void wxListMainWindow::Edit( long item )
+void wxListMainWindow::EditLabel( long item )
 {
     wxNode *node = m_lines.Nth( item );
-    wxCHECK_RET( node, "wrong index in wxListCtrl::Edit() ");
+    wxCHECK_RET( node, _T("wrong index in wxListCtrl::Edit()") );
     
     m_currentEdit = (wxListLineData*) node->Data();
 
@@ -1152,7 +1156,8 @@ void wxListMainWindow::Edit( long item )
     m_currentEdit->GetItem( 0, le.m_item );
     GetParent()->GetEventHandler()->ProcessEvent( le );
     
-    if (!le.IsAllowed()) return;
+    if (!le.IsAllowed())
+        return;
     
     wxString s;
     m_currentEdit->GetText( 0, s );
@@ -1174,7 +1179,7 @@ void wxListMainWindow::Edit( long item )
 
 void wxListMainWindow::OnRenameTimer()
 {
-    wxCHECK_RET( m_current, "invalid m_current" );
+    wxCHECK_RET( m_current, _T("invalid m_current") );
     
     Edit( m_lines.IndexOf( m_current ) );
 }
@@ -1190,7 +1195,11 @@ void wxListMainWindow::OnRenameAccept()
     
     if (!le.IsAllowed()) return;
     
-    /* DO CHANGE LABEL */
+    wxListItem info;
+    info.m_mask = wxLIST_MASK_TEXT;
+    info.m_itemId = le.m_itemIndex;
+    info.m_text = m_renameRes;
+    SetItem( info );
 }
 
 void wxListMainWindow::OnMouse( wxMouseEvent &event )