X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/937013e0fd914d4c42f9f5ec98da665986b93dfa..c585ccef9cc010d0557a17998f3d5a4c286de537:/src/msw/listbox.cpp?ds=sidebyside diff --git a/src/msw/listbox.cpp b/src/msw/listbox.cpp index fd421c8467..9252783bed 100644 --- a/src/msw/listbox.cpp +++ b/src/msw/listbox.cpp @@ -32,6 +32,7 @@ #endif #include "wx/msw/private.h" +#include "wx/msw/dc.h" #include @@ -144,7 +145,7 @@ wxOwnerDrawn *wxListBox::CreateLboxItem(size_t WXUNUSED(n)) wxListBox::wxListBox() { m_noItems = 0; - m_selected = 0; + m_updateHorizontalExtent = false; } bool wxListBox::Create(wxWindow *parent, @@ -157,7 +158,7 @@ bool wxListBox::Create(wxWindow *parent, const wxString& name) { m_noItems = 0; - m_selected = 0; + m_updateHorizontalExtent = false; // initialize base class fields if ( !CreateControl(parent, id, pos, size, style, validator, name) ) @@ -198,7 +199,7 @@ bool wxListBox::Create(wxWindow *parent, wxListBox::~wxListBox() { - Free(); + Clear(); } WXDWORD wxListBox::MSWGetStyle(long style, WXDWORD *exstyle) const @@ -244,6 +245,17 @@ WXDWORD wxListBox::MSWGetStyle(long style, WXDWORD *exstyle) const return msStyle; } +void wxListBox::OnInternalIdle() +{ + wxWindow::OnInternalIdle(); + + if (m_updateHorizontalExtent) + { + SetHorizontalExtent(wxEmptyString); + m_updateHorizontalExtent = false; + } +} + // ---------------------------------------------------------------------------- // implementation of wxListBoxBase methods // ---------------------------------------------------------------------------- @@ -264,7 +276,10 @@ void wxListBox::DoDeleteOneItem(unsigned int n) SendMessage(GetHwnd(), LB_DELETESTRING, n, 0); m_noItems--; - SetHorizontalExtent(wxEmptyString); + // SetHorizontalExtent(wxEmptyString); can be slow + m_updateHorizontalExtent = true; + + UpdateOldSelections(); } int wxListBox::FindString(const wxString& s, bool bCase) const @@ -287,7 +302,9 @@ void wxListBox::DoClear() ListBox_ResetContent(GetHwnd()); m_noItems = 0; - SetHorizontalExtent(); + m_updateHorizontalExtent = true; + + UpdateOldSelections(); } void wxListBox::Free() @@ -313,6 +330,8 @@ void wxListBox::DoSetSelection(int N, bool select) { SendMessage(GetHwnd(), LB_SETCURSEL, select ? N : -1, 0); } + + UpdateOldSelections(); } bool wxListBox::IsSelected(int N) const @@ -461,7 +480,9 @@ int wxListBox::DoInsertItems(const wxArrayStringsAdapter & items, AssignNewItemClientData(n, clientData, i, type); } - SetHorizontalExtent(); + m_updateHorizontalExtent = true; + + UpdateOldSelections(); return n; } @@ -521,7 +542,7 @@ void wxListBox::SetString(unsigned int n, const wxString& s) if ( wasSelected ) Select(n); - SetHorizontalExtent(); + m_updateHorizontalExtent = true; } unsigned int wxListBox::GetCount() const @@ -625,6 +646,12 @@ wxSize wxListBox::DoGetBestSize() const bool wxListBox::MSWCommand(WXUINT param, WXWORD WXUNUSED(id)) { + if ((param == LBN_SELCHANGE) && HasMultipleSelection()) + { + CalcAndSendEvent(); + return true; + } + wxEventType evtType; if ( param == LBN_SELCHANGE ) { @@ -653,7 +680,10 @@ bool wxListBox::MSWCommand(WXUINT param, WXWORD WXUNUSED(id)) event.SetClientData( GetClientData(n) ); event.SetString(GetString(n)); - event.SetExtraLong( HasMultipleSelection() ? IsSelected(n) : true ); + } + else + { + return false; } event.SetInt(n);