summaryrefslogtreecommitdiff
path: root/docview/components/richtext
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graeme@mastermaths.co.za>2011-08-11 17:12:42 +0200
committerGraeme Geldenhuys <graeme@mastermaths.co.za>2011-08-11 17:12:42 +0200
commit6a5302f54c1a64a45cc72036eef94c7b362f79d1 (patch)
tree951e627b629c1068077e4eaefd782e8673c32bd9 /docview/components/richtext
parentbb8c4f991b4e7e1ca49978c253f8ac729faeb262 (diff)
downloadfpGUI-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.pas21
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;