#if defined(__WIN95__)
#include "wx/listctrl.h"
+#include "wx/log.h"
#include "wx/msw/private.h"
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,
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);
wstyle |= ConvertToMSWStyle(oldStyle, m_windowStyle);
// Create the ListView control.
- HWND hWndListControl = CreateWindowEx(exStyle,
+ m_hWnd = (WXHWND)CreateWindowEx(exStyle,
WC_LISTVIEW,
"",
wstyle,
(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);
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
}
// 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
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)
{