#if wxUSE_LISTCTRL
-#include "wx/dcscreen.h"
-#include "wx/app.h"
-#include "wx/listctrl.h"
+#ifndef WX_PRECOMP
+ #include "wx/app.h"
+
+ #include "wx/dynarray.h"
+
+ #include "wx/dcscreen.h"
+
+ #include "wx/textctrl.h"
+#endif
+
#include "wx/imaglist.h"
-#include "wx/dynarray.h"
+#include "wx/listctrl.h"
#ifdef __WXGTK__
-#include <gtk/gtk.h>
-#include "wx/gtk/win_gtk.h"
+ #include <gtk/gtk.h>
+ #include "wx/gtk/win_gtk.h"
#endif
// ----------------------------------------------------------------------------
wxString *m_res;
wxListMainWindow *m_owner;
wxString m_startValue;
+ bool m_finished;
public:
wxListTextCtrl() {}
// stop counting (see comment below)
itemsChanged = NULL;
}
-
- itemsChanged->Add(m_itemsSel[i]);
+ else
+ {
+ itemsChanged->Add(m_itemsSel[i]);
+ }
}
m_itemsSel.RemoveAt(i);
(*m_accept) = FALSE;
(*m_res) = "";
m_startValue = value;
+ m_finished = FALSE;
}
void wxListTextCtrl::OnChar( wxKeyEvent &event )
if (!wxPendingDelete.Member(this))
wxPendingDelete.Append(this);
- if ((*m_accept) && ((*m_res) != m_startValue))
+ if ((*m_res) != m_startValue)
m_owner->OnRenameAccept();
+ m_finished = TRUE;
+ m_owner->SetFocus(); // This doesn't work. TODO.
+
return;
}
if (event.m_keyCode == WXK_ESCAPE)
if (!wxPendingDelete.Member(this))
wxPendingDelete.Append(this);
+ m_finished = TRUE;
+ m_owner->SetFocus(); // This doesn't work. TODO.
+
return;
}
void wxListTextCtrl::OnKeyUp( wxKeyEvent &event )
{
+ if (m_finished)
+ {
+ event.Skip();
+ return;
+ }
+
// auto-grow the textctrl:
wxSize parentSize = m_owner->GetSize();
wxPoint myPos = GetPosition();
wxSize mySize = GetSize();
int sx, sy;
- GetTextExtent(GetValue() + _T("MM"), &sx, &sy); // FIXME: MM??
+ GetTextExtent(GetValue() + _T("M"), &sx, &sy); // FIXME: MM??
if (myPos.x + sx > parentSize.x)
sx = parentSize.x - myPos.x;
if (mySize.x > sx)
event.Skip();
}
-void wxListTextCtrl::OnKillFocus( wxFocusEvent &WXUNUSED(event) )
+void wxListTextCtrl::OnKillFocus( wxFocusEvent &event )
{
+ if (m_finished)
+ {
+ event.Skip();
+ return;
+ }
+
if (!wxPendingDelete.Member(this))
wxPendingDelete.Append(this);
- if ((*m_accept) && ((*m_res) != m_startValue))
+ (*m_accept) = TRUE;
+ (*m_res) = GetValue();
+
+ if ((*m_res) != m_startValue)
m_owner->OnRenameAccept();
}
}
}
-// -------------------------------------------------------------------------------------
-// wxListEvent
-// -------------------------------------------------------------------------------------
-
-IMPLEMENT_DYNAMIC_CLASS(wxListEvent, wxNotifyEvent)
-
-wxListEvent::wxListEvent( wxEventType commandType, int id )
- : wxNotifyEvent( commandType, id )
-{
- m_code = 0;
- m_itemIndex = 0;
- m_oldItemIndex = 0;
- m_col = 0;
- m_cancelled = FALSE;
- m_pointDrag.x = 0;
- m_pointDrag.y = 0;
-}
-
-void wxListEvent::CopyObject(wxObject& object_dest) const
-{
- wxListEvent *obj = (wxListEvent *)&object_dest;
-
- wxNotifyEvent::CopyObject(object_dest);
-
- obj->m_code = m_code;
- obj->m_itemIndex = m_itemIndex;
- obj->m_oldItemIndex = m_oldItemIndex;
- obj->m_col = m_col;
- obj->m_cancelled = m_cancelled;
- obj->m_pointDrag = m_pointDrag;
- obj->m_item.m_mask = m_item.m_mask;
- obj->m_item.m_itemId = m_item.m_itemId;
- obj->m_item.m_col = m_item.m_col;
- obj->m_item.m_state = m_item.m_state;
- obj->m_item.m_stateMask = m_item.m_stateMask;
- obj->m_item.m_text = m_item.m_text;
- obj->m_item.m_image = m_item.m_image;
- obj->m_item.m_data = m_item.m_data;
- obj->m_item.m_format = m_item.m_format;
- obj->m_item.m_width = m_item.m_width;
-
- if ( m_item.HasAttributes() )
- {
- obj->m_item.SetTextColour(m_item.GetTextColour());
- }
-}
-
// -------------------------------------------------------------------------------------
// wxListCtrl
// -------------------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxListCtrl, wxControl)
IMPLEMENT_DYNAMIC_CLASS(wxListView, wxListCtrl)
+IMPLEMENT_DYNAMIC_CLASS(wxListEvent, wxNotifyEvent)
+
BEGIN_EVENT_TABLE(wxListCtrl,wxControl)
EVT_SIZE(wxListCtrl::OnSize)
EVT_IDLE(wxListCtrl::OnIdle)