diff options
author | Graeme Geldenhuys <graeme@mastermaths.co.za> | 2011-08-11 17:12:42 +0200 |
---|---|---|
committer | Graeme Geldenhuys <graeme@mastermaths.co.za> | 2011-08-11 17:12:42 +0200 |
commit | 6a5302f54c1a64a45cc72036eef94c7b362f79d1 (patch) | |
tree | 951e627b629c1068077e4eaefd782e8673c32bd9 /docview/components/richtext | |
parent | bb8c4f991b4e7e1ca49978c253f8ac729faeb262 (diff) | |
download | fpGUI-6a5302f54c1a64a45cc72036eef94c7b362f79d1.tar.xz |
richview: improved the scrollbar textwidth and SB max value calculations.
This helps those odd borderline cases, so now the scrollbar always seems
appropriate when it is visible.
Diffstat (limited to 'docview/components/richtext')
-rw-r--r-- | docview/components/richtext/RichTextView.pas | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/docview/components/richtext/RichTextView.pas b/docview/components/richtext/RichTextView.pas index 0cce5705..ed774366 100644 --- a/docview/components/richtext/RichTextView.pas +++ b/docview/components/richtext/RichTextView.pas @@ -1235,14 +1235,29 @@ begin AvailableWidth := GetTextAreaWidth; MaxDisplayWidth := FLayout.Width; + { This might seem redundant, but the HScrollBar and VScrollBar are a bit + of "chicken vs egg" situation. This checked and the same check done a bit + later just makes the scrollbar calculation a bit more accurate } + AvailableHeight := GetTextAreaHeight; // this includes borders and scrollbars and small margin + if FLayout.Height > AvailableHeight then + FNeedVScroll := true; + // Horizontal scroll setup - if MaxDisplayWidth > AvailableWidth then - FNeedHScroll := true; + if FNeedVScroll then + begin + if MaxDisplayWidth > (AvailableWidth - FScrollbarWidth) then + FNeedHScroll := true; + end + else + begin + if MaxDisplayWidth > AvailableWidth then + FNeedHScroll := true; + end; // FHScrollbar.SliderSize := AvailableWidth div 2; FHScrollbar.Min := 0; if FNeedHScroll then - FHScrollbar.Max := (MaxDisplayWidth - AvailableWidth) + FScrollbarWidth + FHScrollbar.Max := (MaxDisplayWidth - AvailableWidth) + FScrollbarWidth + FRichTextSettings.Margins.Right else begin FHScrollBar.Position := 0; |