+ wxRect region = GetUpdateRegion().GetBox();
+ InternalPaint(& region);
+}
+
+void
+wxLayoutWindow::DoPaint(const wxRect *updateRect)
+{
+#ifdef __WXGTK__
+ InternalPaint(updateRect);
+#else
+ Refresh(FALSE, updateRect); // Causes bad flicker under wxGTK!!!
+#endif
+}
+
+void
+wxLayoutWindow::InternalPaint(const wxRect *updateRect)
+{
+ 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;
+
+ WXLO_DEBUG(("Update rect: %ld,%ld / %ld,%ld",
+ updateRect->x, updateRect->y,
+ updateRect->x+updateRect->width,
+ updateRect->y+updateRect->height));
+
+ if(IsDirty())
+ {
+//FIXME m_llist->Layout(dc);
+ ResizeScrollbars();
+ }
+ /* 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);
+ }
+
+ m_memDC->SetDeviceOrigin(0,0);
+ m_memDC->SetBrush(wxBrush(*m_llist->GetDefaults()->GetBGColour(),wxSOLID));
+ m_memDC->SetPen(wxPen(*m_llist->GetDefaults()->GetBGColour(),
+ 0,wxTRANSPARENT));
+ m_memDC->SetLogicalFunction(wxCOPY);
+
+ /* Either fill the background with the background bitmap, or clear
+ it. */
+ 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);
+ m_memDC->SetBackgroundMode(wxTRANSPARENT);
+ }
+ else
+ {
+ // clear the background: (must not be done if we use the update rectangle!)
+ m_memDC->SetBackgroundMode(wxSOLID);
+ m_memDC->DrawRectangle(0,0,x1, y1);
+ }
+
+
+ /* This is the important bit: we tell the list to draw itself: */
+#if WXLO_DEBUG_URECT
+ WXLO_DEBUG(("Update rect: %ld,%ld / %ld,%ld",
+ updateRect->x, updateRect->y,
+ updateRect->x+updateRect->width,
+ updateRect->y+updateRect->height));
+#endif
+
+ // Device origins on the memDC are suspect, we translate manually
+ // with the translate parameter of Draw().
+ wxPoint offset(-x0+WXLO_XOFFSET,-y0+WXLO_YOFFSET);
+ m_llist->Draw(*m_memDC,offset, y0, y0+y1);
+
+ // We start calculating a new update rect before drawing the
+ // cursor, so that the cursor coordinates get included in the next
+ // update rectangle (although they are drawn on the memDC, this is
+ // needed to erase it):
+ m_llist->InvalidateUpdateRect();
+ m_llist->DrawCursor(*m_memDC,
+ m_HaveFocus && IsEditable(), // draw a thick
+ // cursor for editable windows with focus
+ offset);