- wxPoint max = m_llist->GetSize();
- wxSize size = GetClientSize();
-
- WXLO_DEBUG(("ResizeScrollbars: max size = (%ld, %ld)",
- (long int)max.x, (long int) max.y));
-
- // in the absence of scrollbars we should compare with the client size
- if ( !m_hasHScrollbar )
- m_maxx = size.x - WXLO_ROFFSET;
- if ( !m_hasVScrollbar )
- m_maxy = size.y - WXLO_BOFFSET;
-
- // check if the text hasn't become too big
- // TODO why do we set both at once? they're independent...
- if( max.x > m_maxx - WXLO_ROFFSET || max.y > m_maxy - WXLO_BOFFSET || exact )
- {
- // text became too large
- if ( !exact )
- {
- // add an extra bit to the sizes to avoid future updates
- max.x += WXLO_ROFFSET;
- max.y += WXLO_BOFFSET;
- }
-
- ViewStart(&m_ViewStartX, &m_ViewStartY);
- SetScrollbars(X_SCROLL_PAGE, Y_SCROLL_PAGE,
- max.x / X_SCROLL_PAGE + 1, max.y / Y_SCROLL_PAGE + 1,
- m_ViewStartX, m_ViewStartY,
- true);
-
- m_hasHScrollbar =
- m_hasVScrollbar = true;
-
- m_maxx = max.x + X_SCROLL_PAGE;
- m_maxy = max.y + Y_SCROLL_PAGE;
- }
-#if 0
- else
- {
- // check if the window hasn't become too big, thus making the scrollbars
- // unnecessary
- if ( m_hasHScrollbar && (max.x < size.x) )
- {
- // remove the horizontal scrollbar
- SetScrollbars(0, -1, 0, -1, 0, -1, true);
- m_hasHScrollbar = false;
- }
-
- if ( m_hasVScrollbar && (max.y < size.y) )
- {
- // remove the vertical scrollbar
- SetScrollbars(-1, 0, -1, 0, -1, 0, true);
- m_hasVScrollbar = false;
- }
- }
-#endif
+ wxClientDC dc( this );
+ PrepareDC( dc );
+// m_llist->ForceTotalLayout();
+
+ if(! IsDirty())
+ {
+ // we are laying out just the minimum, but always up to the
+ // cursor line, so the cursor position is updated.
+ m_llist->Layout(dc, 0);
+ return;
+ }
+
+ WXLO_TIMER_START(LayoutTimer);
+ m_llist->Layout(dc, -1);
+ WXLO_TIMER_STOP(LayoutTimer);
+ ResetDirty();
+
+ wxPoint max = m_llist->GetSize();
+ wxSize size = GetClientSize();
+
+ WXLO_DEBUG(("ResizeScrollbars: max size = (%ld, %ld)",
+ (long int)max.x, (long int) max.y));
+
+ // in the absence of scrollbars we should compare with the client size
+ if ( !m_hasHScrollbar )
+ m_maxx = size.x;// - WXLO_ROFFSET;
+
+ if ( !m_hasVScrollbar )
+ m_maxy = size.y;// - WXLO_BOFFSET;
+
+ // check if the text hasn't become too big
+ // TODO why do we set both at once? they're independent...
+ if( max.x > m_maxx - WXLO_ROFFSET
+ || max.y > m_maxy - WXLO_BOFFSET
+ || (max.x < m_maxx - X_SCROLL_PAGE)
+ || (max.y < m_maxy - Y_SCROLL_PAGE)
+ || exact )
+ {
+ // text became too large
+ if ( !exact )
+ {
+ // add an extra bit to the sizes to avoid future updates
+ max.x += WXLO_ROFFSET;
+ max.y += WXLO_BOFFSET;
+ }
+
+ bool done = false;
+
+ if(max.x < X_SCROLL_PAGE && m_hasHScrollbar)
+ {
+ SetScrollbars(0,-1,0,-1,0,-1,true);
+ m_hasHScrollbar = false;
+ done = true;
+ }
+
+ if(max.y < Y_SCROLL_PAGE && m_hasVScrollbar)
+ {
+ SetScrollbars(-1,0,-1,0,-1,0,true);
+ m_hasVScrollbar = false;
+ done = true;
+ }
+
+ if (! done &&
+// (max.x > X_SCROLL_PAGE || max.y > Y_SCROLL_PAGE)
+ (max.x > size.x - X_SCROLL_PAGE|| max.y > size.y - Y_SCROLL_PAGE) )
+ {
+ GetViewStart(&m_ViewStartX, &m_ViewStartY);
+
+ SetScrollbars(X_SCROLL_PAGE,
+ Y_SCROLL_PAGE,
+ max.x / X_SCROLL_PAGE + 2,
+ max.y / Y_SCROLL_PAGE + 2,
+ m_ViewStartX,
+ m_ViewStartY,
+ true);
+
+ m_hasHScrollbar =
+ m_hasVScrollbar = true;
+// ScrollToCursor();
+ }
+
+ m_maxx = max.x + X_SCROLL_PAGE;
+ m_maxy = max.y + Y_SCROLL_PAGE;
+ }