X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/debe6624c1e9d4bf3243381153d1e173c849bcd8..8429bec1e8e3fcb7d071bc3ef7c665c484b5fdc1:/src/msw/listctrl.cpp diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index e595d65996..8f0b1544b9 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -27,6 +27,7 @@ #if defined(__WIN95__) #include "wx/listctrl.h" +#include "wx/log.h" #include "wx/msw/private.h" @@ -54,6 +55,7 @@ wxListCtrl::wxListCtrl(void) m_imageListState = NULL; m_baseStyle = 0; m_colCount = 0; + m_textCtrl = NULL; } bool wxListCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, @@ -62,12 +64,9 @@ bool wxListCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, con m_imageListNormal = NULL; m_imageListSmall = NULL; m_imageListState = NULL; + m_textCtrl = NULL; m_colCount = 0; - wxSystemSettings settings; - SetBackgroundColour(settings.GetSystemColour(wxSYS_COLOUR_WINDOW)); - SetForegroundColour(parent->GetDefaultForegroundColour()); - SetValidator(validator); SetName(name); @@ -109,7 +108,7 @@ bool wxListCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, con wstyle |= ConvertToMSWStyle(oldStyle, m_windowStyle); // Create the ListView control. - HWND hWndListControl = CreateWindowEx(exStyle, + m_hWnd = (WXHWND)CreateWindowEx(exStyle, WC_LISTVIEW, "", wstyle, @@ -117,9 +116,18 @@ bool wxListCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, con (HWND) parent->GetHWND(), (HMENU)m_windowId, wxGetInstance(), - NULL ); + NULL); + + if ( !m_hWnd ) { + wxLogError("Can't create list control window."); + + return FALSE; + } + + wxSystemSettings settings; + SetBackgroundColour(settings.GetSystemColour(wxSYS_COLOUR_WINDOW)); + SetForegroundColour(parent->GetDefaultForegroundColour()); - m_hWnd = (WXHWND) hWndListControl; if (parent) parent->AddChild(this); SubclassWin((WXHWND) m_hWnd); @@ -129,7 +137,13 @@ bool wxListCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, con wxListCtrl::~wxListCtrl(void) { - m_textCtrl.SetHWND((WXHWND) NULL); + if (m_textCtrl) + { + m_textCtrl->UnsubclassWin(); + m_textCtrl->SetHWND(0); + delete m_textCtrl; + m_textCtrl = NULL; + } } // Add or remove a single window style @@ -441,11 +455,9 @@ int wxListCtrl::GetCountPerPage(void) const } // Gets the edit control for editing labels. -wxTextCtrl& wxListCtrl::GetEditControl(void) const +wxTextCtrl* wxListCtrl::GetEditControl(void) const { - HWND hWnd = (HWND) ListView_GetEditControl((HWND) GetHWND()); - ((wxListCtrl *)this)->m_textCtrl.SetHWND((WXHWND) hWnd); - return (wxTextCtrl&)m_textCtrl; + return m_textCtrl; } // Gets information about the item @@ -806,14 +818,49 @@ void wxListCtrl::ClearAll(void) DeleteAllColumns(); } -// Edits a label -wxTextCtrl& wxListCtrl::Edit(long item) +wxTextCtrl* wxListCtrl::EditLabel(long item, wxClassInfo* textControlClass) { - HWND hWnd = (HWND) ListView_EditLabel((HWND) GetHWND(), (int) item); - m_textCtrl.SetHWND((WXHWND) hWnd); - return m_textCtrl; + wxASSERT( (textControlClass->IsKindOf(CLASSINFO(wxTextCtrl))) ); + + HWND hWnd = (HWND) ListView_EditLabel((HWND) GetHWND(), item); + + if (m_textCtrl) + { + m_textCtrl->UnsubclassWin(); + m_textCtrl->SetHWND(0); + delete m_textCtrl; + m_textCtrl = NULL; + } + + m_textCtrl = (wxTextCtrl*) textControlClass->CreateObject(); + m_textCtrl->SetHWND((WXHWND) hWnd); + m_textCtrl->SubclassWin((WXHWND) hWnd); + + return m_textCtrl; +} + +// End label editing, optionally cancelling the edit +bool wxListCtrl::EndEditLabel(bool cancel) +{ + wxASSERT( FALSE); + +/* I don't know how to implement this: there's no such macro as ListView_EndEditLabelNow. + * ??? + bool success = (ListView_EndEditLabelNow((HWND) GetHWND(), cancel) != 0); + + if (m_textCtrl) + { + m_textCtrl->UnsubclassWin(); + m_textCtrl->SetHWND(0); + delete m_textCtrl; + m_textCtrl = NULL; + } + return success; +*/ + return FALSE; } + // Ensures this item is visible bool wxListCtrl::EnsureVisible(long item) {