/////////////////////////////////////////////////////////////////////////////
-// Name: generic/listctrl.cpp
+// Name: src/generic/listctrl.cpp
// Purpose: generic implementation of wxListCtrl
// Author: Robert Roebling
// Vadim Zeitlin (virtual list control support)
#include "wx/wxprec.h"
#ifdef __BORLANDC__
-#pragma hdrstop
+ #pragma hdrstop
#endif
#if wxUSE_LISTCTRL
#ifndef WX_PRECOMP
- #include "wx/app.h"
#include "wx/dynarray.h"
+ #include "wx/app.h"
#include "wx/dcscreen.h"
#include "wx/textctrl.h"
#endif
{
protected:
wxListMainWindow *m_owner;
- wxCursor *m_currentCursor;
+ const wxCursor *m_currentCursor;
wxCursor *m_resizeCursor;
bool m_isDragging;
// continue until we have enough space or only one character left
wxCoord w_c, h_c;
- size_t len = text.Length();
+ size_t len = text.length();
wxString drawntext = text.Left(len);
while (len > 1)
{
}
// if still not enough space, remove ellipsis characters
- while (ellipsis.Length() > 0 && w + base_w > width)
+ while (ellipsis.length() > 0 && w + base_w > width)
{
- ellipsis = ellipsis.Left(ellipsis.Length() - 1);
+ ellipsis = ellipsis.Left(ellipsis.length() - 1);
dc->GetTextExtent(ellipsis, &base_w, &h);
}
m_text->Create(owner, wxID_ANY, m_startValue,
wxPoint(rectLabel.x-4,rectLabel.y-4),
wxSize(rectLabel.width+11,rectLabel.height+8));
+ m_text->SetFocus();
+
m_text->PushEventHandler(this);
}
m_text->RemoveEventHandler(this);
m_owner->FinishEditing(m_text);
- delete this;
+ wxPendingDelete.Append( this );
}
}
break;
case WXK_ESCAPE:
- Finish();
m_owner->OnRenameCancelled( m_itemEdited );
+ Finish();
break;
default:
{
if ( !m_finished && !m_aboutToFinish )
{
- // We must finish regardless of success, otherwise we'll get
- // focus problems:
- Finish();
-
if ( !AcceptChanges() )
m_owner->OnRenameCancelled( m_itemEdited );
+
+ Finish();
}
- // We must let the native text control handle focus, too, otherwise
- // it could have problems with the cursor (e.g., in wxGTK).
+ // We must let the native text control handle focus
event.Skip();
}
void wxListMainWindow::OnMouse( wxMouseEvent &event )
{
+
#ifdef __WXMAC__
// On wxMac we can't depend on the EVT_KILL_FOCUS event to properly
// shutdown the edit control when the mouse is clicked elsewhere on the
}
if ( !HasCurrent() || IsEmpty() )
+ {
+ if (event.RightDown())
+ {
+ SendNotify( (size_t)-1, wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK, event.GetPosition() );
+ // Allow generation of context menu event
+ event.Skip();
+ }
return;
+ }
if (m_dirty)
return;
if ( !hitResult )
{
- // outside of any item, reset the selection and bail out
- HighlightAll(false);
+ // outside of any item
+ if (event.RightDown())
+ {
+ SendNotify( (size_t) -1, wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK, event.GetPosition() );
+ // Allow generation of context menu event
+ event.Skip();
+ }
+ else
+ {
+ // reset the selection and bail out
+ HighlightAll(false);
+ }
+
return;
}
return;
}
- switch (event.GetKeyCode())
+ // don't use m_linesPerPage directly as it might not be computed yet
+ const int pageSize = GetCountPerPage();
+ wxCHECK_RET( pageSize, _T("should have non zero page size") );
+
+ switch ( event.GetKeyCode() )
{
case WXK_UP:
if ( m_current > 0 )
OnArrowChar( 0, event );
break;
- case WXK_PRIOR:
+ case WXK_PAGEUP:
{
- int steps = InReportView() ? m_linesPerPage - 1 : m_current % m_linesPerPage;
+ int steps = InReportView() ? pageSize - 1
+ : m_current % pageSize;
int index = m_current - steps;
if (index < 0)
}
break;
- case WXK_NEXT:
+ case WXK_PAGEDOWN:
{
int steps = InReportView()
- ? m_linesPerPage - 1
- : m_linesPerPage - (m_current % m_linesPerPage) - 1;
+ ? pageSize - 1
+ : pageSize - (m_current % pageSize) - 1;
size_t index = m_current + steps;
size_t count = GetItemCount();
case WXK_LEFT:
if ( !InReportView() )
{
- int index = m_current - m_linesPerPage;
+ int index = m_current - pageSize;
if (index < 0)
index = 0;
case WXK_RIGHT:
if ( !InReportView() )
{
- size_t index = m_current + m_linesPerPage;
+ size_t index = m_current + pageSize;
size_t count = GetItemCount();
if ( index >= count )
return wxSize(spacing, spacing);
}
+#if WXWIN_COMPATIBILITY_2_6
int wxGenericListCtrl::GetItemSpacing( bool isSmall ) const
{
return m_mainWin->GetItemSpacing( isSmall );
}
+#endif // WXWIN_COMPATIBILITY_2_6
void wxGenericListCtrl::SetItemTextColour( long item, const wxColour &col )
{
return m_mainWin->FindItem( pt );
}
-long wxGenericListCtrl::HitTest( const wxPoint &point, int &flags )
+// TODO: sub item hit testing
+long wxGenericListCtrl::HitTest(const wxPoint& point, int& flags, long *)
{
return m_mainWin->HitTest( (int)point.x, (int)point.y, flags );
}
{
m_headerWin->SetSize( 0, 0, cw, m_headerHeight );
if(ch > m_headerHeight)
- m_mainWin->SetSize( 0, m_headerHeight + 1,
+ m_mainWin->SetSize( 0, m_headerHeight + 1,
cw, ch - m_headerHeight - 1 );
else
- m_mainWin->SetSize( 0, m_headerHeight + 1,
+ m_mainWin->SetSize( 0, m_headerHeight + 1,
cw, 0);
}
else // no header window
void wxGenericListCtrl::DoClientToScreen( int *x, int *y ) const
{
- return m_mainWin->DoClientToScreen(x, y);
+ m_mainWin->DoClientToScreen(x, y);
}
void wxGenericListCtrl::DoScreenToClient( int *x, int *y ) const
{
- return m_mainWin->DoScreenToClient(x, y);
+ m_mainWin->DoScreenToClient(x, y);
}
void wxGenericListCtrl::SetFocus()
}
#endif // wxUSE_LISTCTRL
-