#endif
#include "wx/msw/private.h"
+#include "wx/msw/dc.h"
#include <windowsx.h>
wxListBox::wxListBox()
{
m_noItems = 0;
- m_selected = 0;
+ m_updateHorizontalExtent = false;
}
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) )
wxListBox::~wxListBox()
{
- Free();
+ Clear();
}
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
// ----------------------------------------------------------------------------
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
ListBox_ResetContent(GetHwnd());
m_noItems = 0;
- SetHorizontalExtent();
+ m_updateHorizontalExtent = true;
+
+ UpdateOldSelections();
}
void wxListBox::Free()
{
SendMessage(GetHwnd(), LB_SETCURSEL, select ? N : -1, 0);
}
+
+ UpdateOldSelections();
}
bool wxListBox::IsSelected(int N) const
AssignNewItemClientData(n, clientData, i, type);
}
- SetHorizontalExtent();
+ m_updateHorizontalExtent = true;
+
+ UpdateOldSelections();
return n;
}
void *oldData = NULL;
wxClientData *oldObjData = NULL;
- if ( m_clientDataItemsType == wxClientData_Void )
+ if ( HasClientUntypedData() )
oldData = GetClientData(n);
- else if ( m_clientDataItemsType == wxClientData_Object )
+ else if ( HasClientObjectData() )
oldObjData = GetClientObject(n);
// delete and recreate it
if ( wasSelected )
Select(n);
- SetHorizontalExtent();
+ m_updateHorizontalExtent = true;
}
unsigned int wxListBox::GetCount() const
bool wxListBox::MSWCommand(WXUINT param, WXWORD WXUNUSED(id))
{
+ if ((param == LBN_SELCHANGE) && HasMultipleSelection())
+ {
+ CalcAndSendEvent();
+ return true;
+ }
+
wxEventType evtType;
if ( param == LBN_SELCHANGE )
{
event.SetClientData( GetClientData(n) );
event.SetString(GetString(n));
- event.SetExtraLong( HasMultipleSelection() ? IsSelected(n) : true );
+ }
+ else
+ {
+ return false;
}
event.SetInt(n);
- return GetEventHandler()->ProcessEvent(event);
+ return HandleWindowEvent(event);
}
// ----------------------------------------------------------------------------