Changes done in ownerdraw-refactor branch have broken non-ownerdrawn list
boxes as the code was now using m_aItems array even for them but it's not used
in this case.
Also remove unnecessarily overridden Delete() method which didn't add anything
to the base class implementation but just deleted the same m_aItems pointer
twice.
Also use HasFlag(wxLB_OWNERDRAW) everywhere consistently instead of testing
for it manually.
Closes #11729.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63551
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
// ownerdrawn wxListBox and wxCheckListBox support
#if wxUSE_OWNER_DRAWN
// override base class virtuals
// ownerdrawn wxListBox and wxCheckListBox support
#if wxUSE_OWNER_DRAWN
// override base class virtuals
- virtual void Delete(unsigned int n);
virtual bool SetFont(const wxFont &font);
bool MSWOnMeasure(WXMEASUREITEMSTRUCT *item);
virtual bool SetFont(const wxFont &font);
bool MSWOnMeasure(WXMEASUREITEMSTRUCT *item);
wxT("invalid index in wxListBox::Delete") );
#if wxUSE_OWNER_DRAWN
wxT("invalid index in wxListBox::Delete") );
#if wxUSE_OWNER_DRAWN
- delete m_aItems[n];
- m_aItems.RemoveAt(n);
+ if ( HasFlag(wxLB_OWNERDRAW) )
+ {
+ delete m_aItems[n];
+ m_aItems.RemoveAt(n);
+ }
#endif // wxUSE_OWNER_DRAWN
SendMessage(GetHwnd(), LB_DELETESTRING, n, 0);
#endif // wxUSE_OWNER_DRAWN
SendMessage(GetHwnd(), LB_DELETESTRING, n, 0);
void wxListBox::DoClear()
{
#if wxUSE_OWNER_DRAWN
void wxListBox::DoClear()
{
#if wxUSE_OWNER_DRAWN
- if ( m_windowStyle & wxLB_OWNERDRAW )
+ if ( HasFlag(wxLB_OWNERDRAW) )
{
WX_CLEAR_ARRAY(m_aItems);
}
{
WX_CLEAR_ARRAY(m_aItems);
}
}
// ----------------------------------------------------------------------------
}
// ----------------------------------------------------------------------------
-// wxCheckListBox support
+// owner-drawn list boxes support
// ----------------------------------------------------------------------------
#if wxUSE_OWNER_DRAWN
// ----------------------------------------------------------------------------
#if wxUSE_OWNER_DRAWN
// misc overloaded methods
// -----------------------
// misc overloaded methods
// -----------------------
-void wxListBox::Delete(unsigned int n)
-{
- wxCHECK_RET( IsValid(n),
- wxT("invalid index in wxListBox::Delete") );
-
- wxListBoxBase::Delete(n);
-
- // free memory
- delete m_aItems[n];
- m_aItems.RemoveAt(n);
-}
-
bool wxListBox::SetFont(const wxFont &font)
{
bool wxListBox::SetFont(const wxFont &font)
{
- unsigned int i;
- for ( i = 0; i < m_aItems.GetCount(); i++ )
- m_aItems[i]->SetFont(font);
+ if ( HasFlag(wxLB_OWNERDRAW) )
+ {
+ const unsigned count = m_aItems.GetCount();
+ for ( unsigned i = 0; i < count; i++ )
+ m_aItems[i]->SetFont(font);
+ }
wxListBoxBase::SetFont(font);
wxListBoxBase::SetFont(font);
bool wxListBox::MSWOnMeasure(WXMEASUREITEMSTRUCT *item)
{
// only owner-drawn control should receive this message
bool wxListBox::MSWOnMeasure(WXMEASUREITEMSTRUCT *item)
{
// only owner-drawn control should receive this message
- wxCHECK( ((m_windowStyle & wxLB_OWNERDRAW) == wxLB_OWNERDRAW), false );
+ wxCHECK( HasFlag(wxLB_OWNERDRAW), false );
MEASUREITEMSTRUCT *pStruct = (MEASUREITEMSTRUCT *)item;
MEASUREITEMSTRUCT *pStruct = (MEASUREITEMSTRUCT *)item;
bool wxListBox::MSWOnDraw(WXDRAWITEMSTRUCT *item)
{
// only owner-drawn control should receive this message
bool wxListBox::MSWOnDraw(WXDRAWITEMSTRUCT *item)
{
// only owner-drawn control should receive this message
- wxCHECK( ((m_windowStyle & wxLB_OWNERDRAW) == wxLB_OWNERDRAW), false );
+ wxCHECK( HasFlag(wxLB_OWNERDRAW), false );
DRAWITEMSTRUCT *pStruct = (DRAWITEMSTRUCT *)item;
DRAWITEMSTRUCT *pStruct = (DRAWITEMSTRUCT *)item;