X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/bde9072f68db1fed276e2ca376a1d95b4b8998d2..d728116a27b358e5b002337d96268fb51be128eb:/src/generic/listctrl.cpp diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index b3680c13d5..16ec1bbabc 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -611,7 +611,13 @@ public: // bring the current item into view void MoveToFocus() { MoveToItem(m_current); } + // start editing the label of the given item void EditLabel( long item ); + + // suspend/resume redrawing the control + void Freeze(); + void Thaw(); + void OnRenameTimer(); void OnRenameAccept(); @@ -843,6 +849,9 @@ private: wxBrush *m_highlightBrush, *m_highlightUnfocusedBrush; + // if this is > 0, the control is frozen and doesn't redraw itself + size_t m_freezeCount; + DECLARE_DYNAMIC_CLASS(wxListMainWindow); DECLARE_EVENT_TABLE() }; @@ -1879,7 +1888,7 @@ void wxListHeaderWindow::OnPaint( wxPaintEvent &WXUNUSED(event) ) int numColumns = m_owner->GetColumnCount(); wxListItem item; - for (int i = 0; i < numColumns; i++) + for ( int i = 0; i < numColumns && x < w; i++ ) { m_owner->GetColumn( i, item ); int wCol = item.m_width; @@ -1923,11 +1932,9 @@ void wxListHeaderWindow::OnPaint( wxPaintEvent &WXUNUSED(event) ) dc.DrawText( item.GetText(), x + EXTRA_WIDTH, HEADER_OFFSET_Y + EXTRA_HEIGHT ); - if ( x > w - wCol + 5 ) - break; - x += wCol; } + dc.EndDrawing(); } @@ -2229,6 +2236,8 @@ void wxListMainWindow::Init() m_currentEdit = m_lineLastClicked = m_lineBeforeLastClicked = (size_t)-1; + + m_freezeCount = 0; } void wxListMainWindow::InitScrolling() @@ -2648,7 +2657,7 @@ void wxListMainWindow::RefreshSelected() for ( size_t line = from; line <= to; line++ ) { - if ( IsHighlighted(line) ) + if ( IsHighlighted(line) || (line == m_current) ) { if ( line < selMin ) selMin = line; @@ -2664,15 +2673,30 @@ void wxListMainWindow::RefreshSelected() #endif // !__WXGTK__/__WXGTK__ } +void wxListMainWindow::Freeze() +{ + m_freezeCount++; +} + +void wxListMainWindow::Thaw() +{ + wxCHECK_RET( m_freezeCount > 0, _T("thawing unfrozen list control?") ); + + if ( !--m_freezeCount ) + { + Refresh(); + } +} + void wxListMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) ) { // Note: a wxPaintDC must be constructed even if no drawing is // done (a Windows requirement). wxPaintDC dc( this ); - if ( IsEmpty() ) + if ( IsEmpty() || m_freezeCount ) { - // empty control. nothing to draw + // nothing to draw or not the moment to draw it return; } @@ -3244,7 +3268,8 @@ void wxListMainWindow::OnChar( wxKeyEvent &event ) nevent.SetDirection( !event.ShiftDown() ); nevent.SetEventObject( GetParent()->GetParent() ); nevent.SetCurrentFocus( m_parent ); - if (GetParent()->GetParent()->GetEventHandler()->ProcessEvent( nevent )) return; + if (GetParent()->GetParent()->GetEventHandler()->ProcessEvent( nevent )) + return; } /* no item -> nothing to do */ @@ -3344,12 +3369,7 @@ void wxListMainWindow::OnChar( wxKeyEvent &event ) case WXK_SPACE: if ( IsSingleSel() ) { - wxListEvent le( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, - GetParent()->GetId() ); - le.SetEventObject( GetParent() ); - le.m_itemIndex = m_current; - GetLine(m_current)->GetItem( 0, le.m_item ); - GetParent()->GetEventHandler()->ProcessEvent( le ); + SendNotify( m_current, wxEVT_COMMAND_LIST_ITEM_ACTIVATED ); if ( IsHighlighted(m_current) ) { @@ -3364,14 +3384,7 @@ void wxListMainWindow::OnChar( wxKeyEvent &event ) case WXK_RETURN: case WXK_EXECUTE: - { - wxListEvent le( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, - GetParent()->GetId() ); - le.SetEventObject( GetParent() ); - le.m_itemIndex = m_current; - GetLine(m_current)->GetItem( 0, le.m_item ); - GetParent()->GetEventHandler()->ProcessEvent( le ); - } + SendNotify( m_current, wxEVT_COMMAND_LIST_ITEM_ACTIVATED ); break; default: @@ -3393,16 +3406,16 @@ void wxListMainWindow::OnSetFocus( wxFocusEvent &WXUNUSED(event) ) // EVT_KILL_FOCUS before which means that we finish by redrawing the items // which are already drawn correctly resulting in horrible flicker - avoid // it - if ( m_hasFocus ) - return; + if ( !m_hasFocus ) + { + m_hasFocus = TRUE; - m_hasFocus = TRUE; + RefreshSelected(); + } - if (!GetParent()) + if ( !GetParent() ) return; - RefreshSelected(); - #ifdef __WXGTK__ g_focusWindow = GetParent(); #endif @@ -4904,7 +4917,7 @@ bool wxListCtrl::DeleteAllColumns() { size_t count = m_mainWin->m_columns.GetCount(); for ( size_t n = 0; n < count; n++ ) - DeleteColumn(n); + DeleteColumn(0); return TRUE; } @@ -5223,4 +5236,14 @@ void wxListCtrl::RefreshItems(long itemFrom, long itemTo) m_mainWin->RefreshLines(itemFrom, itemTo); } +void wxListCtrl::Freeze() +{ + m_mainWin->Freeze(); +} + +void wxListCtrl::Thaw() +{ + m_mainWin->Thaw(); +} + #endif // wxUSE_LISTCTRL