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.cxx46
1 files changed, 42 insertions, 4 deletions
diff --git a/basctl/source/basicide/linenumberwindow.cxx b/basctl/source/basicide/linenumberwindow.cxx
index be9fe3752045..80fff0872f10 100644
--- a/basctl/source/basicide/linenumberwindow.cxx
+++ b/basctl/source/basicide/linenumberwindow.cxx
@@ -21,7 +21,14 @@ LineNumberWindow::LineNumberWindow(vcl::Window* pParent, ModulWindow* pModulWind
, m_pModulWindow(pModulWindow)
, m_nCurYOffset(0)
{
- SetBackground(Wallpaper(GetSettings().GetStyleSettings().GetFieldColor()));
+ // tdf#153853 The line number window does not need to be affected by RTL
+ EnableRTL(false);
+
+ const Wallpaper aBackground(GetSettings().GetStyleSettings().GetWindowColor());
+ SetBackground(aBackground);
+ GetWindow(GetWindowType::Border)->SetBackground(aBackground);
+ m_FontColor = GetSettings().GetStyleSettings().GetWindowTextColor();
+ m_HighlightColor = GetSettings().GetStyleSettings().GetFaceColor();
m_nBaseWidth = GetTextWidth("8");
m_nWidth = m_nBaseWidth * 3 + m_nBaseWidth / 2;
}
@@ -47,9 +54,8 @@ void LineNumberWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Re
if (!txtView)
return;
- GetParent()->Resize();
-
int windowHeight = rRenderContext.GetOutputSize().Height();
+ int windowWidth = rRenderContext.GetOutputSize().Width();
int nLineHeight = rRenderContext.GetTextHeight();
if (!nLineHeight)
{
@@ -77,9 +83,41 @@ void LineNumberWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Re
m_nWidth += m_nBaseWidth;
}
+ vcl::Font aNormalFont = rRenderContext.GetFont();
+ vcl::Font aBoldFont(aNormalFont);
+ aBoldFont.SetWeight(FontWeight::WEIGHT_BOLD);
+
+ sal_uInt32 nParaEnd = txtView->GetSelection().GetEnd().GetPara() + 1;
sal_Int64 y = (nStartLine - 1) * static_cast<sal_Int64>(nLineHeight);
+
for (sal_uInt32 n = nStartLine; n <= nEndLine; ++n, y += nLineHeight)
- rRenderContext.DrawText(Point(0, y - m_nCurYOffset), OUString::number(n));
+ {
+ // Font weight for the selected lines is bold
+ if (n == nParaEnd)
+ {
+ tools::Rectangle aRect(Point(0, y - m_nCurYOffset),
+ Point(windowWidth, y - m_nCurYOffset + nLineHeight));
+ rRenderContext.SetFillColor(m_HighlightColor);
+ rRenderContext.DrawRect(aRect);
+ rRenderContext.SetFont(aBoldFont);
+ }
+ else
+ {
+ rRenderContext.SetFont(aNormalFont);
+ }
+
+ rRenderContext.SetTextColor(m_FontColor);
+ const OUString aLineNumber = OUString::number(n);
+ // tdf#153798 - align line numbers to the right
+ rRenderContext.DrawText(
+ Point(m_nWidth - GetTextWidth(aLineNumber) - m_nBaseWidth / 2, y - m_nCurYOffset),
+ aLineNumber);
+ }
+ // Restore the original font
+ rRenderContext.SetFont(aNormalFont);
+
+ // Resize the parent after calculating the new width and height values
+ GetParent()->Resize();
}
void LineNumberWindow::DataChanged(DataChangedEvent const& rDCEvt)