+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() || 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.BeginDrawing();
+
+ 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;
+ wxRect 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
+
+ dc.EndDrawing();
+}
+
+void wxListMainWindow::HighlightAll( bool on )
+{
+ if ( IsSingleSel() )
+ {
+ wxASSERT_MSG( !on, _T("can't do this in a single sel control") );
+
+ // we just have one item to turn off
+ if ( HasCurrent() && IsHighlighted(m_current) )
+ {
+ HighlightLine(m_current, false);
+ RefreshLine(m_current);
+ }
+ }
+ else // multi sel
+ {
+ HighlightLines(0, GetItemCount() - 1, on);
+ }
+}
+
+void wxListMainWindow::SendNotify( size_t line,
+ wxEventType command,
+ const wxPoint& point )
+{
+ wxListEvent le( command, GetParent()->GetId() );
+ le.SetEventObject( GetParent() );
+ le.m_itemIndex = line;
+
+ // set only for events which have position
+ if ( point != wxDefaultPosition )
+ le.m_pointDrag = point;
+
+ // don't try to get the line info for virtual list controls: the main
+ // program has it anyhow and if we did it would result in accessing all
+ // the lines, even those which are not visible now and this is precisely
+ // what we're trying to avoid
+ if ( !IsVirtual() && (command != wxEVT_COMMAND_LIST_DELETE_ITEM) )
+ {
+ if ( line != (size_t)-1 )
+ {
+ GetLine(line)->GetItem( 0, le.m_item );
+ }
+ //else: this happens for wxEVT_COMMAND_LIST_ITEM_FOCUSED event
+ }
+ //else: there may be no more such item
+
+ GetParent()->GetEventHandler()->ProcessEvent( le );
+}
+
+void wxListMainWindow::ChangeCurrent(size_t current)
+{
+ m_current = current;
+
+ SendNotify(current, wxEVT_COMMAND_LIST_ITEM_FOCUSED);
+}