summaryrefslogtreecommitdiff
path: root/basctl/source/basicide/linenumberwindow.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'basctl/source/basicide/linenumberwindow.cxx')
-rw-r--r--basctl/source/basicide/linenumberwindow.cxx44
1 files changed, 40 insertions, 4 deletions
diff --git a/basctl/source/basicide/linenumberwindow.cxx b/basctl/source/basicide/linenumberwindow.cxx
index 5168da1b092a..deba85df526c 100644
--- a/basctl/source/basicide/linenumberwindow.cxx
+++ b/basctl/source/basicide/linenumberwindow.cxx
@@ -7,7 +7,8 @@
LineNumberWindow::LineNumberWindow( Window* pParent, ModulWindow* pModulWin ) :
Window( pParent, WB_BORDER ),
pModulWindow(pModulWin),
- nWidth(1)
+ nWidth(1),
+ nCurYOffset(0)
{
SetBackground(Wallpaper(GetSettings().GetStyleSettings().GetFieldColor()));
}
@@ -16,6 +17,9 @@ LineNumberWindow::~LineNumberWindow() { }
void LineNumberWindow::Paint( const Rectangle& )
{
+ if(SyncYOffset())
+ return;
+
ExtTextEngine* txtEngine = pModulWindow->GetEditEngine();
if(!txtEngine)
return;
@@ -27,9 +31,9 @@ void LineNumberWindow::Paint( const Rectangle& )
GetParent()->Resize();
ulong windowHeight = GetOutputSize().Height();
- ulong startY = txtView->GetStartDocPos().Y();
ulong nLineHeight = GetTextHeight();
+ ulong startY = txtView->GetStartDocPos().Y();
ulong nStartLine = startY / nLineHeight + 1;
ulong nEndLine = (startY + windowHeight) / nLineHeight + 1;
@@ -38,8 +42,9 @@ void LineNumberWindow::Paint( const Rectangle& )
nWidth = String::CreateFromInt64(nEndLine).Len() * 10;
- for(ulong i = nStartLine, y = 0; i < nEndLine; ++i, y += nLineHeight)
- DrawText(Point(0, y), String::CreateFromInt64(i));
+ sal_Int64 y = (nStartLine - 1) * nLineHeight;
+ for(ulong i = nStartLine; i <= nEndLine; ++i, y += nLineHeight)
+ DrawText(Point(0, y - nCurYOffset), String::CreateFromInt64(i));
}
void LineNumberWindow::DataChanged(DataChangedEvent const & rDCEvt)
@@ -56,3 +61,34 @@ void LineNumberWindow::DataChanged(DataChangedEvent const & rDCEvt)
}
}
}
+
+void LineNumberWindow::DoScroll(long nHorzScroll, long nVertScroll)
+{
+ nCurYOffset -= nVertScroll;
+ Window::Scroll(nHorzScroll, nVertScroll);
+}
+
+long& LineNumberWindow::GetCurYOffset()
+{
+ return nCurYOffset;
+}
+
+bool LineNumberWindow::SyncYOffset()
+{
+ TextView* pView = pModulWindow->GetEditView();
+ if (!pView)
+ return false;
+
+ long nViewYOffset = pView->GetStartDocPos().Y();
+ if (nCurYOffset == nViewYOffset)
+ return false;
+
+ nCurYOffset = nViewYOffset;
+ Invalidate();
+ return true;
+}
+
+ulong LineNumberWindow::GetWidth()
+{
+ return (nWidth < 20 ? 20 : nWidth);
+}