+ wxPaintDC dc( this );
+ PrepareDC( dc );
+
+ int x0,y0,x1,y1, dx, dy;
+
+ // Calculate where the top of the visible area is:
+ ViewStart(&x0,&y0);
+ GetScrollPixelsPerUnit(&dx, &dy);
+ x0 *= dx; y0 *= dy;
+
+ // Get the size of the visible window:
+ GetClientSize(&x1,&y1);
+ wxASSERT(x1 > 0);
+ wxASSERT(y1 > 0);
+ // As we have the values anyway, use them to avoid unnecessary
+ // scrollbar updates.
+ if(x1 > m_maxx) m_maxx = x1;
+ if(y1 > m_maxy) m_maxy = y1;
+
+
+ //m_llist->InvalidateUpdateRect();
+ //const wxRect *r = m_llist->GetUpdateRect();
+ wxLogDebug("Update rect: %ld,%ld / %ld,%ld",
+ updateRect->x, updateRect->y, updateRect->x+updateRect->width, updateRect->y+updateRect->height);
+
+#if 0
+ //FIXME: we should never need to call Layout at all because the
+ // list does it automatically.
+// Maybe we need to change the scrollbar sizes or positions,
+ // so layout the list and check:
+ if(IsDirty())
+ m_llist->Layout(dc);
+ wxLogDebug("Update rect after calling Layout: %ld,%ld / %ld,%ld",
+ r->x, r->y, r->x+r->width, r->y+r->height);
+ // this is needed even when only the cursor moved
+ m_llist->Layout(dc,y0+y1);
+ wxLogDebug("Update rect after calling Layout again: %ld,%ld / %ld,%ld",
+ r->x, r->y, r->x+r->width, r->y+r->height);
+#endif
+
+ if(IsDirty())
+ ResizeScrollbars();
+
+ /* Make sure that the scrollbars are at a position so that the
+ cursor is visible if we are editing. */
+ /** Scroll so that cursor is visible! */
+ wxLogDebug("m_ScrollToCursor = %d", (int) m_ScrollToCursor);
+ if(IsEditable() && m_ScrollToCursor)
+ {
+ wxPoint cc = m_llist->GetCursorScreenPos(*m_memDC);
+ if(cc.x < x0 || cc.y < y0
+ || cc.x >= x0+(9*x1)/10 || cc.y >= y0+(9*y1/10)) // (9*x)/10 == 90%
+ {
+ int nx, ny;
+ nx = cc.x - x1/2; if(nx < 0) nx = 0;
+ ny = cc.y - y1/2; if(ny < 0) ny = 0;
+ Scroll(nx/dx,ny/dy); // new view start
+ x0 = nx; y0 = ny;
+ }
+ }
+
+ /* Check whether the window has grown, if so, we need to reallocate
+ the bitmap to be larger. */
+ if(x1 > m_bitmapSize.x || y1 > m_bitmapSize.y)
+ {
+ wxASSERT(m_bitmapSize.x > 0);
+ wxASSERT(m_bitmapSize.y > 0);
+
+ m_memDC->SelectObject(wxNullBitmap);
+ delete m_bitmap;
+ m_bitmapSize = wxPoint(x1,y1);
+ m_bitmap = new wxBitmap(x1,y1);
+ m_memDC->SelectObject(*m_bitmap);
+ }
+
+ // Device origins on the memDC are suspect, we translate manually
+ // with the translate parameter of Draw().
+ m_memDC->SetDeviceOrigin(0,0);
+ m_memDC->SetBackgroundMode(wxTRANSPARENT);
+ m_memDC->SetBrush(wxBrush(m_llist->GetDefaults()->GetBGColour(), wxSOLID));
+ m_memDC->SetPen(wxPen(m_llist->GetDefaults()->GetBGColour(),0,wxTRANSPARENT));
+ m_memDC->SetLogicalFunction(wxCOPY);
+ if(m_BGbitmap)
+ {
+ CoordType
+ y, x,
+ w = m_BGbitmap->GetWidth(),
+ h = m_BGbitmap->GetHeight();
+ for(y = 0; y < y1; y+=h)
+ for(x = 0; x < x1; x+=w)
+ m_memDC->DrawBitmap(*m_BGbitmap, x, y);
+ }
+ else
+ m_memDC->DrawRectangle(0,0,x1, y1);
+
+
+
+ /* This is the important bit: we tell the list to draw itself: */
+ wxLogDebug("Update rect: %ld,%ld / %ld,%ld",
+ updateRect->x, updateRect->y, updateRect->x+updateRect->width, updateRect->y+updateRect->height);
+
+ wxPoint offset(-x0+WXLO_XOFFSET,-y0+WXLO_YOFFSET);
+ m_llist->Draw(*m_memDC,offset, y0, y0+y1);