///////////////////////////////////////////////////////////////////////////////
-// Name: src/osx/carbon/listbox.cpp
+// Name: src/osx/listbox_osx.cpp
// Purpose: wxListBox
// Author: Stefan Csomor
// Modified by:
// Created: 1998-01-01
-// RCS-ID: $Id: listbox.cpp 54820 2008-07-29 20:04:11Z SC $
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#include "wx/dcclient.h"
#endif
-IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControlWithItems)
-
BEGIN_EVENT_TABLE(wxListBox, wxControl)
END_EVENT_TABLE()
const wxValidator& validator,
const wxString& name )
{
+ DontCreatePeer();
m_blockEvents = false;
- m_macIsUserPane = false;
+
+ if ( ! (style & wxNO_BORDER) )
+ style = (style & ~wxBORDER_MASK) | wxSUNKEN_BORDER ;
wxASSERT_MSG( !(style & wxLB_MULTIPLE) || !(style & wxLB_EXTENDED),
wxT("only a single listbox selection mode can be specified") );
else
m_strings.unsorted = new wxArrayString;
- m_peer = wxWidgetImpl::CreateListBox( this, parent, id, pos, size, style, GetExtraStyle() );
+ SetPeer(wxWidgetImpl::CreateListBox( this, parent, id, pos, size, style, GetExtraStyle() ));
MacPostControlCreate( pos, size );
m_blockEvents = false;
// make sure no native events get sent to a object in destruction
- delete m_peer;
- m_peer = NULL;
+ SetPeer(NULL);
if ( IsSorted() )
delete m_strings.sorted;
void wxListBox::DoSetFirstItem(int n)
{
+ // osx actually only has an implementation for ensuring the visibility of a row, it does so
+ // by scrolling the minimal amount necessary from the current scrolling position.
+ // in order to get the same behaviour I'd have to make sure first that the last line is visible,
+ // followed by a scrollRowToVisible for the desired line
+ GetListPeer()->ListScrollTo( GetCount()-1 );
GetListPeer()->ListScrollTo( n );
}
return GetListPeer()->ListGetSelection();
}
+int wxListBox::DoListHitTest(const wxPoint& inpoint) const
+{
+ return GetListPeer()->DoListHitTest( inpoint );
+}
+
// ----------------------------------------------------------------------------
// display
// ----------------------------------------------------------------------------
void wxListBox::OnItemInserted(unsigned int WXUNUSED(pos))
{
-
}
int wxListBox::DoInsertItems(const wxArrayStringsAdapter& items,
GetListPeer()->UpdateLineToEnd(startpos);
+ // Inserting the items may scroll the listbox down to show the last
+ // selected one but we don't want to do it as it could result in e.g. the
+ // first items of a listbox be hidden immediately after its creation so
+ // show the first selected item instead. Ideal would probably be to
+ // preserve the old selection unchanged, in fact, but I don't know how to
+ // get the first visible item so for now do at least this.
+ SetFirstItem(startpos);
+
UpdateOldSelections();
return idx;
void wxListBox::HandleLineEvent( unsigned int n, bool doubleClick )
{
- wxCommandEvent event( doubleClick ? wxEVT_COMMAND_LISTBOX_DOUBLECLICKED :
- wxEVT_COMMAND_LISTBOX_SELECTED, GetId() );
+ wxCommandEvent event( doubleClick ? wxEVT_LISTBOX_DCLICK :
+ wxEVT_LISTBOX, GetId() );
event.SetEventObject( this );
if ( HasClientObjectData() )
event.SetClientObject( GetClientObject(n) );