Move virtual stub functions to wxListCtrlBase

This commit is contained in:
Maarten Bent
2019-05-05 14:23:44 +02:00
parent d262aa02d1
commit ceaf2aa803
8 changed files with 51 additions and 134 deletions

View File

@@ -213,17 +213,6 @@ protected:
virtual wxSize DoGetBestClientSize() const wxOVERRIDE; virtual wxSize DoGetBestClientSize() const wxOVERRIDE;
// return the text for the given column of the given item
virtual wxString OnGetItemText(long item, long column) const;
// return the icon for the given item. In report view, OnGetItemImage will
// only be called for the first column. See OnGetItemColumnImage for
// details.
virtual int OnGetItemImage(long item) const;
// return the icon for the given item and column.
virtual int OnGetItemColumnImage(long item, long column) const;
// it calls our OnGetXXX() functions // it calls our OnGetXXX() functions
friend class WXDLLIMPEXP_FWD_CORE wxListMainWindow; friend class WXDLLIMPEXP_FWD_CORE wxListMainWindow;

View File

@@ -393,9 +393,6 @@ public:
virtual int GetColumnWidth(int col) const = 0; virtual int GetColumnWidth(int col) const = 0;
virtual bool SetColumnWidth(int col, int width) = 0; virtual bool SetColumnWidth(int col, int width) = 0;
// return the attribute for the item (may return NULL if none)
virtual wxItemAttr *OnGetItemAttr(long item) const;
// Other miscellaneous accessors. // Other miscellaneous accessors.
// ------------------------------ // ------------------------------
@@ -427,6 +424,26 @@ protected:
// Overridden methods of the base class. // Overridden methods of the base class.
virtual wxSize DoGetBestClientSize() const wxOVERRIDE; virtual wxSize DoGetBestClientSize() const wxOVERRIDE;
// these functions are only used for virtual list view controls, i.e. the
// ones with wxLC_VIRTUAL style
// return the attribute for the item (may return NULL if none)
virtual wxItemAttr* OnGetItemAttr(long item) const;
// return the text for the given column of the given item
virtual wxString OnGetItemText(long item, long column) const;
// return the icon for the given item. In report view, OnGetItemImage will
// only be called for the first column. See OnGetItemColumnImage for
// details.
virtual int OnGetItemImage(long item) const;
// return the icon for the given item and column.
virtual int OnGetItemColumnImage(long item, long column) const;
// return the attribute for the given item and column (may return NULL if none)
virtual wxItemAttr* OnGetItemColumnAttr(long item, long column) const;
private: private:
// user defined color to draw row lines, may be invalid // user defined color to draw row lines, may be invalid
wxItemAttr m_alternateRowColour; wxItemAttr m_alternateRowColour;

View File

@@ -421,26 +421,6 @@ protected:
// true if we have any items with custom attributes // true if we have any items with custom attributes
bool m_hasAnyAttr; bool m_hasAnyAttr;
// these functions are only used for virtual list view controls, i.e. the
// ones with wxLC_VIRTUAL style
// return the text for the given column of the given item
virtual wxString OnGetItemText(long item, long column) const;
// return the icon for the given item. In report view, OnGetItemImage will
// only be called for the first column. See OnGetItemColumnImage for
// details.
virtual int OnGetItemImage(long item) const;
// return the icon for the given item and column.
virtual int OnGetItemColumnImage(long item, long column) const;
// return the attribute for the given item and column (may return NULL if none)
virtual wxItemAttr *OnGetItemColumnAttr(long item, long WXUNUSED(column)) const
{
return OnGetItemAttr(item);
}
private: private:
// process NM_CUSTOMDRAW notification message // process NM_CUSTOMDRAW notification message
WXLPARAM OnCustomDraw(WXLPARAM lParam); WXLPARAM OnCustomDraw(WXLPARAM lParam);

View File

@@ -265,27 +265,6 @@ public:
// data is arbitrary data to be passed to the sort function. // data is arbitrary data to be passed to the sort function.
bool SortItems(wxListCtrlCompare fn, wxIntPtr data); bool SortItems(wxListCtrlCompare fn, wxIntPtr data);
// these functions are only used for virtual list view controls, i.e. the
// ones with wxLC_VIRTUAL style (not currently implemented in wxQT)
// return the text for the given column of the given item
virtual wxString OnGetItemText(long item, long column) const;
// return the icon for the given item. In report view, OnGetItemImage will
// only be called for the first column. See OnGetItemColumnImage for
// details.
virtual int OnGetItemImage(long item) const;
// return the icon for the given item and column.
virtual int OnGetItemColumnImage(long item, long column) const;
// return the attribute for the given item and column (may return NULL if none)
virtual wxItemAttr *OnGetItemColumnAttr(long item, long WXUNUSED(column)) const
{
return OnGetItemAttr(item);
}
virtual QWidget *GetHandle() const wxOVERRIDE; virtual QWidget *GetHandle() const wxOVERRIDE;
protected: protected:

View File

@@ -25,6 +25,7 @@
#if wxUSE_LISTCTRL #if wxUSE_LISTCTRL
#include "wx/listctrl.h" #include "wx/listctrl.h"
#include "wx/imaglist.h"
#ifndef WX_PRECOMP #ifndef WX_PRECOMP
#include "wx/dcclient.h" #include "wx/dcclient.h"
@@ -251,4 +252,34 @@ wxItemAttr *wxListCtrlBase::OnGetItemAttr(long item) const
: NULL; // no attributes by default : NULL; // no attributes by default
} }
wxString wxListCtrlBase::OnGetItemText(long WXUNUSED(item), long WXUNUSED(col)) const
{
// this is a pure virtual function, in fact - which is not really pure
// because the controls which are not virtual don't need to implement it
wxFAIL_MSG("wxListCtrl::OnGetItemText not supposed to be called");
return wxEmptyString;
}
int wxListCtrlBase::OnGetItemImage(long WXUNUSED(item)) const
{
wxCHECK_MSG(!GetImageList(wxIMAGE_LIST_SMALL),
-1,
"List control has an image list, OnGetItemImage or OnGetItemColumnImage should be overridden.");
return -1;
}
int wxListCtrlBase::OnGetItemColumnImage(long item, long column) const
{
if ( !column )
return OnGetItemImage(item);
return -1;
}
wxItemAttr* wxListCtrlBase::OnGetItemColumnAttr(long item, long WXUNUSED(column)) const
{
return OnGetItemAttr(item);
}
#endif // wxUSE_LISTCTRL #endif // wxUSE_LISTCTRL

View File

@@ -5533,31 +5533,6 @@ wxSize wxGenericListCtrl::DoGetBestClientSize() const
// virtual list control support // virtual list control support
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
wxString wxGenericListCtrl::OnGetItemText(long WXUNUSED(item), long WXUNUSED(col)) const
{
// this is a pure virtual function, in fact - which is not really pure
// because the controls which are not virtual don't need to implement it
wxFAIL_MSG( wxT("wxGenericListCtrl::OnGetItemText not supposed to be called") );
return wxEmptyString;
}
int wxGenericListCtrl::OnGetItemImage(long WXUNUSED(item)) const
{
wxCHECK_MSG(!GetImageList(wxIMAGE_LIST_SMALL),
-1,
wxT("List control has an image list, OnGetItemImage or OnGetItemColumnImage should be overridden."));
return -1;
}
int wxGenericListCtrl::OnGetItemColumnImage(long item, long column) const
{
if (!column)
return OnGetItemImage(item);
return -1;
}
void wxGenericListCtrl::SetItemCount(long count) void wxGenericListCtrl::SetItemCount(long count)
{ {
wxASSERT_MSG( IsVirtual(), wxT("this is for virtual controls only") ); wxASSERT_MSG( IsVirtual(), wxT("this is for virtual controls only") );

View File

@@ -3240,31 +3240,6 @@ wxListCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
// virtual list controls // virtual list controls
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
wxString wxListCtrl::OnGetItemText(long WXUNUSED(item), long WXUNUSED(col)) const
{
// this is a pure virtual function, in fact - which is not really pure
// because the controls which are not virtual don't need to implement it
wxFAIL_MSG( wxT("wxListCtrl::OnGetItemText not supposed to be called") );
return wxEmptyString;
}
int wxListCtrl::OnGetItemImage(long WXUNUSED(item)) const
{
wxCHECK_MSG(!GetImageList(wxIMAGE_LIST_SMALL),
-1,
wxT("List control has an image list, OnGetItemImage or OnGetItemColumnImage should be overridden."));
return -1;
}
int wxListCtrl::OnGetItemColumnImage(long item, long column) const
{
if (!column)
return OnGetItemImage(item);
return -1;
}
wxItemAttr *wxListCtrl::DoGetItemColumnAttr(long item, long column) const wxItemAttr *wxListCtrl::DoGetItemColumnAttr(long item, long column) const
{ {
if ( IsVirtual() ) if ( IsVirtual() )

View File

@@ -1010,35 +1010,6 @@ bool wxListCtrl::SortItems(wxListCtrlCompare WXUNUSED(fn), wxIntPtr WXUNUSED(dat
return false; return false;
} }
// ----------------------------------------------------------------------------
// virtual list controls (not currently implemented in wxQT)
// ----------------------------------------------------------------------------
wxString wxListCtrl::OnGetItemText(long WXUNUSED(item), long WXUNUSED(col)) const
{
// this is a pure virtual function, in fact - which is not really pure
// because the controls which are not virtual don't need to implement it
wxFAIL_MSG( wxT("wxListCtrl::OnGetItemText not supposed to be called") );
return wxEmptyString;
}
int wxListCtrl::OnGetItemImage(long WXUNUSED(item)) const
{
wxCHECK_MSG(!GetImageList(wxIMAGE_LIST_SMALL),
-1,
wxT("List control has an image list, OnGetItemImage or OnGetItemColumnImage should be overridden."));
return -1;
}
int wxListCtrl::OnGetItemColumnImage(long item, long column) const
{
if (!column)
return OnGetItemImage(item);
return -1;
}
QWidget *wxListCtrl::GetHandle() const QWidget *wxListCtrl::GetHandle() const
{ {
return m_qtTreeWidget; return m_qtTreeWidget;