// Author: Stefan Csomor
// Modified by:
// Created: 1998-01-01
-// RCS-ID: $Id: listbox.cpp 54820 2008-07-29 20:04:11Z SC $
+// RCS-ID: $Id$
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
m_strings.unsorted = new wxArrayString;
m_peer = wxWidgetImpl::CreateListBox( this, parent, id, pos, size, style, GetExtraStyle() );
-
+
MacPostControlCreate( pos, size );
m_textColumn = GetListPeer()->InsertTextColumn(0,wxEmptyString);
m_blockEvents = false;
// make sure no native events get sent to a object in destruction
- delete m_peer;
- m_peer = NULL;
+ wxDELETE(m_peer);
if ( IsSorted() )
delete m_strings.sorted;
GetListPeer()->ListDelete( n );
m_blockEvents = false;
-
+
UpdateOldSelections();
}
m_blockEvents = true;
FreeData();
m_blockEvents = false;
-
+
UpdateOldSelections();
}
wxT("invalid index in wxListBox::SetSelection") );
m_blockEvents = true;
-
+
if ( n == wxNOT_FOUND )
GetListPeer()->ListDeselectAll();
else
GetListPeer()->ListSetSelection( n, select, HasMultipleSelection() );
-
+
m_blockEvents = false;
-
+
UpdateOldSelections();
}
return GetListPeer()->ListGetSelection();
}
+int wxListBox::DoListHitTest(const wxPoint& inpoint) const
+{
+ return GetListPeer()->DoListHitTest( inpoint );
+}
+
// ----------------------------------------------------------------------------
// display
// ----------------------------------------------------------------------------
wxSize wxListBox::DoGetBestSize() const
{
int lbWidth = 100; // some defaults
- int lbHeight = 110;
+ int lbHeight;
int wLine;
{
attr.colFg = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT );
attr.colBg = wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOX );
- attr.font.CreateSystemFont(wxOSX_SYSTEM_FONT_VIEWS);
+ static wxFont font = wxFont(wxOSX_SYSTEM_FONT_VIEWS);
+ attr.font = font;
return attr;
}
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::SetString(unsigned int n, const wxString& s)
{
- wxCHECK_RET( !IsSorted(), _T("can't set string in sorted listbox") );
+ wxCHECK_RET( !IsSorted(), wxT("can't set string in sorted listbox") );
if ( IsSorted() )
(*m_strings.sorted)[n] = s;
void wxListBox::HandleLineEvent( unsigned int n, bool doubleClick )
{
- wxCommandEvent event( doubleClick ? wxEVT_COMMAND_LISTBOX_DOUBLECLICKED :
+ wxCommandEvent event( doubleClick ? wxEVT_COMMAND_LISTBOX_DOUBLECLICKED :
wxEVT_COMMAND_LISTBOX_SELECTED, GetId() );
event.SetEventObject( this );
if ( HasClientObjectData() )
HandleWindowEvent(event);
}
+//
+// common list cell value operations
+//
+
+void wxListWidgetCellValue::Check( bool check )
+{
+ Set( check ? 1 : 0 );
+}
+
+bool wxListWidgetCellValue::IsChecked() const
+{
+ return GetIntValue() != 0;
+}
+
+
+
#endif // wxUSE_LISTBOX