#include "wx/mac/private.h"
#endif
+#include <math.h>
+
+
// NOTE: If using the wxListBox visual attributes works everywhere then this can
// be removed, as well as the #else case below.
#define _USE_VISATTR 0
void EnsureVisible( long index );
long FindItem( long start, const wxString& str, bool partial = false );
long FindItem( long start, long data);
+ long FindItem( const wxPoint& pt );
long HitTest( int x, int y, int &flags );
void InsertItem( wxListItem &item );
void InsertColumn( long col, wxListItem &item );
switch ( event.m_keyCode )
{
case WXK_RETURN:
- if ( !AcceptChanges() )
+ if ( AcceptChanges() )
{
- // vetoed by the user code
- break;
+ // Close the text control, changes were accepted
+ Finish();
}
- //else: fall through
+ // else do nothing, do not accept and do not close
+
+ break;
case WXK_ESCAPE:
Finish();
{
if ( !m_finished )
{
- // We must finish regardless of success, otherwise we'll get focus problems
+ // We must finish regardless of success, otherwise we'll get
+ // focus problems:
Finish();
if ( !AcceptChanges() )
m_owner->OnRenameCancelled( m_itemEdited );
}
+ // We must let the native text control handle focus, too, otherwise
+ // it could have problems with the cursor (e.g., in wxGTK):
event.Skip();
}
return wxNOT_FOUND;
}
+long wxListMainWindow::FindItem( const wxPoint& pt )
+{
+ size_t topItem;
+ GetVisibleLinesRange(&topItem, NULL);
+
+ wxPoint p;
+ GetItemPosition( GetItemCount()-1, p );
+ if( p.y == 0 )
+ return topItem;
+ long id = (long) floor( pt.y*(GetItemCount()-topItem-1)/p.y+topItem );
+ if( id >= 0 && id < (long)GetItemCount() )
+ return id;
+
+ return wxNOT_FOUND;
+}
+
long wxListMainWindow::HitTest( int x, int y, int &flags )
{
CalcUnscrolledPosition( x, y, &x, &y );
return m_mainWin->FindItem( start, data );
}
-long wxGenericListCtrl::FindItem( long WXUNUSED(start), const wxPoint& WXUNUSED(pt),
+long wxGenericListCtrl::FindItem( long WXUNUSED(start), const wxPoint& pt,
int WXUNUSED(direction))
{
- return 0;
+ return m_mainWin->FindItem( pt );
}
long wxGenericListCtrl::HitTest( const wxPoint &point, int &flags )