#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, const wxWindowID id, const wxPoint& pos, const wxSize& size,
- const long style, const wxValidator& validator, const wxString& name)
+bool wxListCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
+ long style, const wxValidator& validator, const wxString& name)
{
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
-void wxListCtrl::SetSingleStyle(const long style, const bool add)
+void wxListCtrl::SetSingleStyle(long style, bool add)
{
long flag = GetWindowStyleFlag();
}
// Set the whole window style
-void wxListCtrl::SetWindowStyleFlag(const long flag)
+void wxListCtrl::SetWindowStyleFlag(long flag)
{
m_windowStyle = flag;
}
// Can be just a single style, or a bitlist
-long wxListCtrl::ConvertToMSWStyle(long& oldStyle, const long style) const
+long wxListCtrl::ConvertToMSWStyle(long& oldStyle, long style) const
{
long wstyle = 0;
if ( style & wxLC_ICON )
}
// Gets information about this column
-bool wxListCtrl::GetColumn(const int col, wxListItem& item) const
+bool wxListCtrl::GetColumn(int col, wxListItem& item) const
{
LV_COLUMN lvCol;
lvCol.mask = 0;
}
// Sets information about this column
-bool wxListCtrl::SetColumn(const int col, wxListItem& item)
+bool wxListCtrl::SetColumn(int col, wxListItem& item)
{
LV_COLUMN lvCol;
lvCol.mask = 0;
}
// Gets the column width
-int wxListCtrl::GetColumnWidth(const int col) const
+int wxListCtrl::GetColumnWidth(int col) const
{
return ListView_GetColumnWidth((HWND) GetHWND(), col);
}
// Sets the column width
-bool wxListCtrl::SetColumnWidth(const int col, const int width)
+bool wxListCtrl::SetColumnWidth(int col, int width)
{
int col2 = col;
if ( m_windowStyle & wxLC_LIST )
}
// 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
return (ListView_SetItem((HWND) GetHWND(), &item) != 0);
}
-long wxListCtrl::SetItem(const long index, const int col, const wxString& label, const int imageId)
+long wxListCtrl::SetItem(long index, int col, const wxString& label, int imageId)
{
wxListItem info;
info.m_text = label;
// Gets the item state
-int wxListCtrl::GetItemState(const long item, const long stateMask) const
+int wxListCtrl::GetItemState(long item, long stateMask) const
{
wxListItem info;
}
// Sets the item state
-bool wxListCtrl::SetItemState(const long item, const long state, const long stateMask)
+bool wxListCtrl::SetItemState(long item, long state, long stateMask)
{
wxListItem info;
}
// Sets the item image
-bool wxListCtrl::SetItemImage(const long item, const int image, const int selImage)
+bool wxListCtrl::SetItemImage(long item, int image, int selImage)
{
wxListItem info;
}
// Gets the item text
-wxString wxListCtrl::GetItemText(const long item) const
+wxString wxListCtrl::GetItemText(long item) const
{
wxListItem info;
}
// Sets the item text
-void wxListCtrl::SetItemText(const long item, const wxString& str)
+void wxListCtrl::SetItemText(long item, const wxString& str)
{
wxListItem info;
}
// Gets the item data
-long wxListCtrl::GetItemData(const long item) const
+long wxListCtrl::GetItemData(long item) const
{
wxListItem info;
}
// Sets the item data
-bool wxListCtrl::SetItemData(const long item, long data)
+bool wxListCtrl::SetItemData(long item, long data)
{
wxListItem info;
}
// Gets the item rectangle
-bool wxListCtrl::GetItemRect(const long item, wxRectangle& rect, const int code) const
+bool wxListCtrl::GetItemRect(long item, wxRectangle& rect, int code) const
{
RECT rect2;
}
// Gets the item position
-bool wxListCtrl::GetItemPosition(const long item, wxPoint& pos) const
+bool wxListCtrl::GetItemPosition(long item, wxPoint& pos) const
{
POINT pt;
}
// Sets the item position.
-bool wxListCtrl::SetItemPosition(const long item, const wxPoint& pos)
+bool wxListCtrl::SetItemPosition(long item, const wxPoint& pos)
{
return (ListView_SetItemPosition((HWND) GetHWND(), (int) item, pos.x, pos.y) != 0);
}
// item can be -1 to find the first item that matches the
// specified flags.
// Returns the item or -1 if unsuccessful.
-long wxListCtrl::GetNextItem(const long item, int geom, int state) const
+long wxListCtrl::GetNextItem(long item, int geom, int state) const
{
long flags = 0;
}
-wxImageList *wxListCtrl::GetImageList(const int which) const
+wxImageList *wxListCtrl::GetImageList(int which) const
{
if ( which == wxIMAGE_LIST_NORMAL )
{
return NULL;
}
-void wxListCtrl::SetImageList(wxImageList *imageList, const int which)
+void wxListCtrl::SetImageList(wxImageList *imageList, int which)
{
int flags = 0;
if ( which == wxIMAGE_LIST_NORMAL )
////////////////////////////////////////////////////////////////////////////
// Arranges the items
-bool wxListCtrl::Arrange(const int flag)
+bool wxListCtrl::Arrange(int flag)
{
UINT code = 0;
if ( flag == wxLIST_ALIGN_LEFT )
}
// Deletes an item
-bool wxListCtrl::DeleteItem(const long item)
+bool wxListCtrl::DeleteItem(long item)
{
return (ListView_DeleteItem((HWND) GetHWND(), (int) item) != 0);
}
}
// Deletes a column
-bool wxListCtrl::DeleteColumn(const int col)
+bool wxListCtrl::DeleteColumn(int col)
{
bool success = (ListView_DeleteColumn((HWND) GetHWND(), col) != 0);
DeleteAllColumns();
}
-// Edits a label
-wxTextCtrl& wxListCtrl::Edit(const 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(const long item)
+bool wxListCtrl::EnsureVisible(long item)
{
return (ListView_EnsureVisible((HWND) GetHWND(), (int) item, FALSE) != 0);
}
// Find an item whose label matches this string, starting from the item after 'start'
// or the beginning if 'start' is -1.
-long wxListCtrl::FindItem(const long start, const wxString& str, const bool partial)
+long wxListCtrl::FindItem(long start, const wxString& str, bool partial)
{
LV_FINDINFO findInfo;
// Find an item whose data matches this data, starting from the item after 'start'
// or the beginning if 'start' is -1.
-long wxListCtrl::FindItem(const long start, const long data)
+long wxListCtrl::FindItem(long start, long data)
{
LV_FINDINFO findInfo;
// Find an item nearest this position in the specified direction, starting from
// the item after 'start' or the beginning if 'start' is -1.
-long wxListCtrl::FindItem(const long start, const wxPoint& pt, const int direction)
+long wxListCtrl::FindItem(long start, const wxPoint& pt, int direction)
{
LV_FINDINFO findInfo;
return (long) ListView_InsertItem((HWND) GetHWND(), & item);
}
-long wxListCtrl::InsertItem(const long index, const wxString& label)
+long wxListCtrl::InsertItem(long index, const wxString& label)
{
wxListItem info;
info.m_text = label;
}
// Inserts an image item
-long wxListCtrl::InsertItem(const long index, const int imageIndex)
+long wxListCtrl::InsertItem(long index, int imageIndex)
{
wxListItem info;
info.m_image = imageIndex;
}
// Inserts an image/string item
-long wxListCtrl::InsertItem(const long index, const wxString& label, const int imageIndex)
+long wxListCtrl::InsertItem(long index, const wxString& label, int imageIndex)
{
wxListItem info;
info.m_image = imageIndex;
}
// For list view mode (only), inserts a column.
-long wxListCtrl::InsertColumn(const long col, wxListItem& item)
+long wxListCtrl::InsertColumn(long col, wxListItem& item)
{
LV_COLUMN lvCol;
lvCol.mask = 0;
return success;
}
-long wxListCtrl::InsertColumn(const long col, const wxString& heading, const int format,
- const int width)
+long wxListCtrl::InsertColumn(long col, const wxString& heading, int format,
+ int width)
{
wxListItem item;
item.m_mask = wxLIST_MASK_TEXT | wxLIST_MASK_FORMAT;
// specifies the number of columns to scroll.
// If in icon, small icon or list view mode, y specifies the number of pixels
// to scroll. If in report view mode, y specifies the number of lines to scroll.
-bool wxListCtrl::ScrollList(const int dx, const int dy)
+bool wxListCtrl::ScrollList(int dx, int dy)
{
return (ListView_Scroll((HWND) GetHWND(), dx, dy) != 0);
}
return (ListView_SortItems((HWND) GetHWND(), (PFNLVCOMPARE) fn, data) != 0);
}
-bool wxListCtrl::MSWCommand(const WXUINT cmd, const WXWORD id)
+bool wxListCtrl::MSWCommand(WXUINT cmd, WXWORD id)
{
if (cmd == EN_UPDATE)
{
else return FALSE;
}
-bool wxListCtrl::MSWNotify(const WXWPARAM wParam, const WXLPARAM lParam)
+bool wxListCtrl::MSWNotify(WXWPARAM wParam, WXLPARAM lParam)
{
wxListEvent event(wxEVT_NULL, m_windowId);
wxEventType eventType = wxEVT_NULL;