From 705a1b547d293df6add3886b9c7d4a7022297ebc Mon Sep 17 00:00:00 2001 From: Tim Kosse Date: Sun, 6 Jul 2014 10:32:42 +0000 Subject: [PATCH] Implement wxGenericListCtrl::EndEditLabel. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76856 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + include/wx/generic/listctrl.h | 4 ++++ include/wx/generic/private/listctrl.h | 3 +++ src/generic/listctrl.cpp | 16 ++++++++++++++++ 4 files changed, 24 insertions(+) diff --git a/docs/changes.txt b/docs/changes.txt index a1a75ab8ce..407e3002ad 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -59,6 +59,7 @@ All (GUI): - Fix handling of rectangular selections in wxStyledTextCtrl (roberto). - Fix characters outside of the BMP in wxStyledTextCtrl (Thomas Goyne). - Allow access to the currently shown wxInfoBar buttons (Hanmac). +- Add wxGenericListCtrl::EndEditLabel() (Tim Kosse). wxGTK: diff --git a/include/wx/generic/listctrl.h b/include/wx/generic/listctrl.h index eed280969e..0245424d77 100644 --- a/include/wx/generic/listctrl.h +++ b/include/wx/generic/listctrl.h @@ -120,6 +120,10 @@ public: wxTextCtrl *EditLabel(long item, wxClassInfo* textControlClass = wxCLASSINFO(wxTextCtrl)); + + // End label editing, optionally cancelling the edit + bool EndEditLabel(bool cancel); + wxTextCtrl* GetEditControl() const; void Edit( long item ) { EditLabel(item); } diff --git a/include/wx/generic/private/listctrl.h b/include/wx/generic/private/listctrl.h index 32afaada6f..5cd210f486 100644 --- a/include/wx/generic/private/listctrl.h +++ b/include/wx/generic/private/listctrl.h @@ -564,6 +564,9 @@ public: // start editing the label of the given item wxTextCtrl *EditLabel(long item, wxClassInfo* textControlClass = wxCLASSINFO(wxTextCtrl)); + + bool EndEditLabel(bool cancel); + wxTextCtrl *GetEditControl() const { return m_textctrlWrapper ? m_textctrlWrapper->GetText() : NULL; diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index 2545541523..d7ba8dc88e 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -2260,6 +2260,17 @@ wxTextCtrl *wxListMainWindow::EditLabel(long item, wxClassInfo* textControlClass return m_textctrlWrapper->GetText(); } +bool wxListMainWindow::EndEditLabel(bool cancel) +{ + if (!m_textctrlWrapper) + { + return false; + } + + m_textctrlWrapper->EndEdit(cancel ? wxListTextCtrlWrapper::End_Discard : wxListTextCtrlWrapper::End_Accept); + return true; +} + void wxListMainWindow::OnRenameTimer() { wxCHECK_RET( HasCurrent(), wxT("unexpected rename timer") ); @@ -5063,6 +5074,11 @@ wxTextCtrl *wxGenericListCtrl::EditLabel(long item, return m_mainWin->EditLabel( item, textControlClass ); } +bool wxGenericListCtrl::EndEditLabel(bool cancel) +{ + return m_mainWin->EndEditLabel(cancel); +} + wxTextCtrl *wxGenericListCtrl::GetEditControl() const { return m_mainWin->GetEditControl();