+ 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
+}
+
+void wxListMainWindow::HighlightAll( bool on )
+{
+ if ( IsSingleSel() )
+ {
+ wxASSERT_MSG( !on, _T("can't do this in a single selection 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);
+}
+
+wxTextCtrl *wxListMainWindow::EditLabel(long item, wxClassInfo* textControlClass)
+{
+ wxCHECK_MSG( (item >= 0) && ((size_t)item < GetItemCount()), NULL,
+ wxT("wrong index in wxGenericListCtrl::EditLabel()") );
+
+ wxASSERT_MSG( textControlClass->IsKindOf(CLASSINFO(wxTextCtrl)),
+ wxT("EditLabel() needs a text control") );
+
+ size_t itemEdit = (size_t)item;
+
+ wxListEvent le( wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT, GetParent()->GetId() );
+ le.SetEventObject( GetParent() );
+ le.m_itemIndex = item;
+ wxListLineData *data = GetLine(itemEdit);
+ wxCHECK_MSG( data, NULL, _T("invalid index in EditLabel()") );
+ data->GetItem( 0, le.m_item );
+
+ if ( GetParent()->GetEventHandler()->ProcessEvent( le ) && !le.IsAllowed() )
+ {
+ // vetoed by user code
+ return NULL;
+ }
+
+ // We have to call this here because the label in question might just have
+ // been added and no screen update taken place.
+ if ( m_dirty )
+ wxSafeYield();
+
+ wxTextCtrl * const text = (wxTextCtrl *)textControlClass->CreateObject();
+ m_textctrlWrapper = new wxListTextCtrlWrapper(this, text, item);
+ return m_textctrlWrapper->GetText();