#include "wx/dcscreen.h"
#include "wx/app.h"
-#include "wx/generic/listctrl.h"
+#include "wx/listctrl.h"
#include "wx/generic/imaglist.h"
//-----------------------------------------------------------------------------
m_res = res;
m_accept = accept;
m_owner = owner;
+ (*m_accept) = FALSE;
+ (*m_res) = "";
+ m_startValue = value;
}
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();
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();
}
//-----------------------------------------------------------------------------
/* *** */
-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();
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 );
void wxListMainWindow::OnRenameTimer()
{
- wxCHECK_RET( m_current, "invalid m_current" );
+ wxCHECK_RET( m_current, _T("invalid m_current") );
Edit( m_lines.IndexOf( m_current ) );
}
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 )