X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/75ae9acfa815c7d8b70d2d38153bd110b6731495..15f0ad701496612df8c145e8e46d4b38515c0bbf:/src/generic/listctrl.cpp diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index fb4924f17e..3a901214d5 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: generic/listctrl.cpp +// Name: src/generic/listctrl.cpp // Purpose: generic implementation of wxListCtrl // Author: Robert Roebling // Vadim Zeitlin (virtual list control support) @@ -1583,7 +1583,7 @@ void wxListLineData::DrawTextFormatted(wxDC *dc, // 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) { @@ -1596,9 +1596,9 @@ void wxListLineData::DrawTextFormatted(wxDC *dc, } // 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); } @@ -2033,6 +2033,8 @@ wxListTextCtrlWrapper::wxListTextCtrlWrapper(wxListMainWindow *owner, 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); } @@ -2045,7 +2047,7 @@ void wxListTextCtrlWrapper::Finish() m_text->RemoveEventHandler(this); m_owner->FinishEditing(m_text); - delete this; + wxPendingDelete.Append( this ); } } @@ -2087,8 +2089,8 @@ void wxListTextCtrlWrapper::OnChar( wxKeyEvent &event ) break; case WXK_ESCAPE: - Finish(); m_owner->OnRenameCancelled( m_itemEdited ); + Finish(); break; default: @@ -2123,16 +2125,13 @@ void wxListTextCtrlWrapper::OnKillFocus( wxFocusEvent &event ) { 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(); } @@ -2858,6 +2857,7 @@ void wxListMainWindow::OnRenameCancelled(size_t itemEdit) 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 @@ -2879,7 +2879,15 @@ void wxListMainWindow::OnMouse( wxMouseEvent &event ) } 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; @@ -2950,6 +2958,18 @@ void wxListMainWindow::OnMouse( wxMouseEvent &event ) if ( !hitResult ) { // 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; } @@ -3261,8 +3281,12 @@ void wxListMainWindow::OnChar( wxKeyEvent &event ) OnArrowChar( 0, event ); break; - case WXK_PRIOR: + 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 index = m_current - steps; @@ -3273,8 +3297,12 @@ void wxListMainWindow::OnChar( wxKeyEvent &event ) } break; - case WXK_NEXT: + 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; @@ -4587,7 +4615,13 @@ void wxListMainWindow::SortItems( wxListCtrlCompare fn, long data ) void wxListMainWindow::OnScroll(wxScrollWinEvent& event) { - // update our idea of which lines are shown when we redraw the window the + 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 // next time ResetVisibleLinesRange(); @@ -4934,11 +4968,18 @@ bool wxGenericListCtrl::SetItemState( long item, long state, long stateMask ) bool wxGenericListCtrl::SetItemImage( long item, int image, int WXUNUSED(selImage) ) +{ + return SetItemColumnImage(item, 0, image); +} + +bool +wxGenericListCtrl::SetItemColumnImage( long item, long column, int image ) { wxListItem info; info.m_image = image; info.m_mask = wxLIST_MASK_IMAGE; info.m_itemId = item; + info.m_col = column; m_mainWin->SetItem( info ); return true; } @@ -5018,10 +5059,12 @@ wxSize wxGenericListCtrl::GetItemSpacing() const 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 ) { @@ -5336,10 +5379,10 @@ void wxGenericListCtrl::ResizeReportView(bool showHeader) { 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 @@ -5478,12 +5521,12 @@ bool wxGenericListCtrl::DoPopupMenu( wxMenu *menu, int x, int y ) 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() @@ -5618,4 +5661,3 @@ void wxGenericListCtrl::Thaw() } #endif // wxUSE_LISTCTRL -