}
// now we can compute our best size correctly, so do it again
- InvalidateBestSize();
SetInitialSize(size);
return true;
}
}
+void wxListBox::MSWOnItemsChanged()
+{
+ // we need to do two things when items change: update their max horizontal
+ // extent so that horizontal scrollbar could be shown or hidden as
+ // appropriate and also invlaidate the best size
+ //
+ // updating the max extent is slow (it's an O(N) operation) and so we defer
+ // it until the idle time but the best size should be invalidated
+ // immediately doing it in idle time is too late -- layout using incorrect
+ // old best size will have been already done by then
+
+ m_updateHorizontalExtent = true;
+
+ InvalidateBestSize();
+}
+
// ----------------------------------------------------------------------------
// implementation of wxListBoxBase methods
// ----------------------------------------------------------------------------
SendMessage(GetHwnd(), LB_DELETESTRING, n, 0);
m_noItems--;
- // SetHorizontalExtent(wxEmptyString); can be slow
- m_updateHorizontalExtent = true;
+ MSWOnItemsChanged();
UpdateOldSelections();
}
ListBox_ResetContent(GetHwnd());
m_noItems = 0;
- m_updateHorizontalExtent = true;
+ MSWOnItemsChanged();
UpdateOldSelections();
}
AssignNewItemClientData(n, clientData, i, type);
}
- m_updateHorizontalExtent = true;
+ MSWOnItemsChanged();
UpdateOldSelections();
if ( wasSelected )
Select(n);
- m_updateHorizontalExtent = true;
+ MSWOnItemsChanged();
}
unsigned int wxListBox::GetCount() const
void wxListBox::SetHorizontalExtent(const wxString& s)
{
- // in any case, our best size could have changed
- InvalidateBestSize();
-
// the rest is only necessary if we want a horizontal scrollbar
if ( !HasFlag(wxHSCROLL) )
return;