+ // Note: a wxPaintDC must be constructed even if no drawing is
+ // done (a Windows requirement).
+ wxPaintDC dc( this );
+
+ if ( IsEmpty() || m_freezeCount )
+ // nothing to draw or not the moment to draw it
+ return;
+
+ if ( m_dirty )
+ // delay the repainting until we calculate all the items positions
+ return;
+
+ PrepareDC( dc );
+
+ int dev_x, dev_y;
+ CalcScrolledPosition( 0, 0, &dev_x, &dev_y );
+
+ dc.SetFont( GetFont() );
+
+ if ( InReportView() )
+ {
+ int lineHeight = GetLineHeight();
+
+ size_t visibleFrom, visibleTo;
+ GetVisibleLinesRange(&visibleFrom, &visibleTo);
+
+ wxRect rectLine;
+ wxCoord xOrig, yOrig;
+ CalcUnscrolledPosition(0, 0, &xOrig, &yOrig);
+
+ // tell the caller cache to cache the data
+ if ( IsVirtual() )
+ {
+ wxListEvent evCache(wxEVT_COMMAND_LIST_CACHE_HINT,
+ GetParent()->GetId());
+ evCache.SetEventObject( GetParent() );
+ evCache.m_oldItemIndex = visibleFrom;
+ evCache.m_itemIndex = visibleTo;
+ GetParent()->GetEventHandler()->ProcessEvent( evCache );
+ }
+
+ for ( size_t line = visibleFrom; line <= visibleTo; line++ )
+ {
+ rectLine = GetLineRect(line);
+
+ if ( !IsExposed(rectLine.x - xOrig, rectLine.y - yOrig,
+ rectLine.width, rectLine.height) )
+ {
+ // don't redraw unaffected lines to avoid flicker
+ continue;
+ }
+
+ GetLine(line)->DrawInReportMode( &dc,
+ rectLine,
+ GetLineHighlightRect(line),
+ IsHighlighted(line) );
+ }
+
+ if ( HasFlag(wxLC_HRULES) )
+ {
+ wxPen pen(GetRuleColour(), 1, wxSOLID);
+ wxSize clientSize = GetClientSize();
+
+ // Don't draw the first one
+ for ( size_t i = visibleFrom + 1; i <= visibleTo; i++ )
+ {
+ dc.SetPen(pen);
+ dc.SetBrush( *wxTRANSPARENT_BRUSH );
+ dc.DrawLine(0 - dev_x, i * lineHeight,
+ clientSize.x - dev_x, i * lineHeight);
+ }
+
+ // Draw last horizontal rule
+ if ( visibleTo == GetItemCount() - 1 )
+ {
+ dc.SetPen( pen );
+ dc.SetBrush( *wxTRANSPARENT_BRUSH );
+ dc.DrawLine(0 - dev_x, (m_lineTo + 1) * lineHeight,
+ clientSize.x - dev_x , (m_lineTo + 1) * lineHeight );
+ }
+ }
+
+ // Draw vertical rules if required
+ if ( HasFlag(wxLC_VRULES) && !IsEmpty() )
+ {
+ wxPen pen(GetRuleColour(), 1, wxSOLID);
+ wxRect firstItemRect, lastItemRect;
+
+ GetItemRect(visibleFrom, firstItemRect);
+ GetItemRect(visibleTo, lastItemRect);
+ int x = firstItemRect.GetX();
+ dc.SetPen(pen);
+ dc.SetBrush(* wxTRANSPARENT_BRUSH);
+
+ for (int col = 0; col < GetColumnCount(); col++)
+ {
+ int colWidth = GetColumnWidth(col);
+ x += colWidth;
+ dc.DrawLine(x - dev_x - 2, firstItemRect.GetY() - 1 - dev_y,
+ x - dev_x - 2, lastItemRect.GetBottom() + 1 - dev_y);
+ }
+ }
+ }
+ else // !report
+ {
+ size_t count = GetItemCount();
+ for ( size_t i = 0; i < count; i++ )
+ {
+ GetLine(i)->Draw( &dc );
+ }
+ }
+
+#ifndef __WXMAC__
+ // Don't draw rect outline under Mac at all.
+ if ( HasCurrent() )
+ {
+ if ( m_hasFocus )
+ {
+ dc.SetPen( *wxBLACK_PEN );
+ dc.SetBrush( *wxTRANSPARENT_BRUSH );
+ dc.DrawRectangle( GetLineHighlightRect( m_current ) );
+ }
+ }
+#endif