X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/82d492f14504c4c9f29dc8c54ffce1dd2c2f5deb..6d7b547184bfdcdf67790755deb0122050b1d728:/src/generic/listctrl.cpp diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index 3a901214d5..93b28ecb70 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -18,18 +18,11 @@ #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/dcscreen.h" - #include "wx/textctrl.h" -#endif - // under Win32 we always use the native version and also may use the generic // one, however some things should be done only if we use only the generic // version @@ -51,9 +44,17 @@ IMPLEMENT_DYNAMIC_CLASS(wxListCtrl, wxGenericListCtrl) #endif // HAVE_NATIVE_LISTCTRL/!HAVE_NATIVE_LISTCTRL +#ifndef WX_PRECOMP + #include "wx/dynarray.h" + #include "wx/app.h" + #include "wx/dcscreen.h" + #include "wx/textctrl.h" + #include "wx/listbox.h" + #include "wx/math.h" +#endif + #include "wx/selstore.h" #include "wx/renderer.h" -#include "wx/math.h" #ifdef __WXMAC__ #include "wx/mac/private.h" @@ -412,7 +413,7 @@ class WXDLLEXPORT wxListHeaderWindow : public wxWindow { protected: wxListMainWindow *m_owner; - wxCursor *m_currentCursor; + const wxCursor *m_currentCursor; wxCursor *m_resizeCursor; bool m_isDragging; @@ -706,7 +707,7 @@ public: long FindItem( long start, const wxString& str, bool partial = false ); long FindItem( long start, wxUIntPtr data); long FindItem( const wxPoint& pt ); - long HitTest( int x, int y, int &flags ); + long HitTest( int x, int y, int &flags ) const; void InsertItem( wxListItem &item ); void InsertColumn( long col, wxListItem &item ); int GetItemWidthWithImage(wxListItem * item); @@ -2034,7 +2035,7 @@ wxListTextCtrlWrapper::wxListTextCtrlWrapper(wxListMainWindow *owner, wxPoint(rectLabel.x-4,rectLabel.y-4), wxSize(rectLabel.width+11,rectLabel.height+8)); m_text->SetFocus(); - + m_text->PushEventHandler(this); } @@ -2127,7 +2128,7 @@ void wxListTextCtrlWrapper::OnKillFocus( wxFocusEvent &event ) { if ( !AcceptChanges() ) m_owner->OnRenameCancelled( m_itemEdited ); - + Finish(); } @@ -2969,7 +2970,7 @@ void wxListMainWindow::OnMouse( wxMouseEvent &event ) // reset the selection and bail out HighlightAll(false); } - + return; } @@ -3259,7 +3260,11 @@ void wxListMainWindow::OnChar( wxKeyEvent &event ) 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 ) @@ -3283,11 +3288,8 @@ void wxListMainWindow::OnChar( wxKeyEvent &event ) case WXK_PAGEUP: { - // we get a floating point exception without this - if (m_linesPerPage == 0) - m_linesPerPage = 1; - - 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) @@ -3299,13 +3301,9 @@ void wxListMainWindow::OnChar( wxKeyEvent &event ) case WXK_PAGEDOWN: { - // we get a floating point exception without this - if (m_linesPerPage == 0) - m_linesPerPage = 1; - 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(); @@ -3319,7 +3317,7 @@ void wxListMainWindow::OnChar( wxKeyEvent &event ) case WXK_LEFT: if ( !InReportView() ) { - int index = m_current - m_linesPerPage; + int index = m_current - pageSize; if (index < 0) index = 0; @@ -3330,7 +3328,7 @@ void wxListMainWindow::OnChar( wxKeyEvent &event ) 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 ) @@ -4434,7 +4432,7 @@ long wxListMainWindow::FindItem( const wxPoint& pt ) return wxNOT_FOUND; } -long wxListMainWindow::HitTest( int x, int y, int &flags ) +long wxListMainWindow::HitTest( int x, int y, int &flags ) const { CalcUnscrolledPosition( x, y, &x, &y ); @@ -4615,13 +4613,7 @@ void wxListMainWindow::SortItems( wxListCtrlCompare fn, long data ) void wxListMainWindow::OnScroll(wxScrollWinEvent& event) { - int cw, ch, vw, vh; - GetVirtualSize(&vw, &vh); - GetClientSize(&cw, &ch); - - if( event.GetOrientation() == wxVERTICAL && ch >= vh) - return; - // update our idea of which lines are shown when we redraw the window the + // update our idea of which lines are shown when we redraw the window the // next time ResetVisibleLinesRange(); @@ -5264,7 +5256,8 @@ long wxGenericListCtrl::FindItem( long WXUNUSED(start), const wxPoint& pt, 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 *) const { return m_mainWin->HitTest( (int)point.x, (int)point.y, flags ); } @@ -5456,10 +5449,6 @@ bool wxGenericListCtrl::SetFont( const wxFont &font ) return true; } -#if _USE_VISATTR -#include "wx/listbox.h" -#endif - // static wxVisualAttributes wxGenericListCtrl::GetClassDefaultAttributes(wxWindowVariant variant)