From 637b578aab8d8642e6e8183b1da1efa30af466b6 Mon Sep 17 00:00:00 2001 From: mattias Date: Mon, 1 Aug 2005 10:11:31 +0000 Subject: [PATCH] increased scroll position for gtk from 15bit to 31bit from Colin Western git-svn-id: trunk@7470 - --- lcl/grids.pas | 21 +++++++++++++++++---- lcl/include/controlscrollbar.inc | 2 +- lcl/interfaces/gtk/gtkcallback.inc | 20 ++++++++++++++++---- 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/lcl/grids.pas b/lcl/grids.pas index b9af069182..e7698d97d2 100644 --- a/lcl/grids.pas +++ b/lcl/grids.pas @@ -698,6 +698,7 @@ type function GetDefaultColumnReadOnly(Column: Integer): boolean; virtual; function GetDefaultColumnTitle(Column: Integer): string; virtual; function GetDefaultEditor(Column: Integer): TWinControl; + function GetScrollBarPosition(Which: integer): Integer; function GetEditMask(ACol, ARow: Longint): string; dynamic; function GetEditText(ACol, ARow: Longint): string; dynamic; function GetFixedcolor: TColor; virtual; @@ -2919,10 +2920,10 @@ begin SB_PAGEUP: C := CTL - FGCache.ClientWidth; // Scrolls to the current scroll bar position SB_THUMBPOSITION: - C := Message.Pos; + C := GetScrollBarPosition(SBS_HORZ); SB_THUMBTRACK: if goThumbTracking in Options then - C := message.Pos + C := GetScrollBarPosition(SBS_HORZ) else Exit; // Ends scrolling @@ -2997,10 +2998,10 @@ begin SB_PAGEUP: C := CTL - FGCache.ClientHeight; // Scrolls to the current scroll bar position SB_THUMBPOSITION: - C := message.Pos; + C := GetScrollBarPosition(SBS_VERT); SB_THUMBTRACK: if goThumbTracking in Options then - C := message.Pos + C := GetScrollBarPosition(SBS_VERT) else Exit; // Ends scrolling @@ -5258,6 +5259,18 @@ begin end; end; +function TCustomGrid.GetScrollBarPosition(Which: integer): Integer; +var + ScrollInfo: TScrollInfo; +begin + if HandleAllocated then begin + ScrollInfo.cbSize := SizeOf(ScrollInfo); + ScrollInfo.fMask := SIF_POS; + GetScrollInfo(Handle, Which, ScrollInfo); + Result:=ScrollInfo.nPos; + end; +end; + function TCustomGrid.GetDefaultColumnWidth(Column: Integer): Integer; begin result := FDefColWidth; diff --git a/lcl/include/controlscrollbar.inc b/lcl/include/controlscrollbar.inc index 857a589aff..4e9cacdfc5 100644 --- a/lcl/include/controlscrollbar.inc +++ b/lcl/include/controlscrollbar.inc @@ -322,7 +322,7 @@ begin SB_PAGEDOWN: Inc(NewPos, FPage); SB_THUMBPOSITION, SB_THUMBTRACK: - NewPos := Pos; + NewPos := GetPosition; { Read scroll bar as TLMScroll message does not provide full range } SB_TOP: NewPos := 0; SB_BOTTOM: diff --git a/lcl/interfaces/gtk/gtkcallback.inc b/lcl/interfaces/gtk/gtkcallback.inc index 22e9c39bfa..4c3509abba 100644 --- a/lcl/interfaces/gtk/gtkcallback.inc +++ b/lcl/interfaces/gtk/gtkcallback.inc @@ -2535,7 +2535,10 @@ begin Result := CallBackDefaultReturn; Msg.Msg := LM_HSCROLL; with Msg do begin - pos := Round(Range^.Adjustment^.Value); + if Range^.Adjustment^.value <= High(pos) then + pos := Round(Range^.Adjustment^.Value) + else + pos := High(pos); { Out of simple range } ScrollBar := HWND(Range); ScrollCode := ScrollTypeToSbCode(False, Scroll, gtk_range_get_update_policy(Range)); @@ -2551,7 +2554,10 @@ begin Result := CallBackDefaultReturn; Msg.Msg := LM_VSCROLL; with Msg do begin - pos := Round(Range^.Adjustment^.Value); + if Range^.Adjustment^.value <= High(pos) then + pos := Round(Range^.Adjustment^.Value) + else + pos := High(pos); { Out of simple range } ScrollBar := HWND(Range); ScrollCode := ScrollTypeToSbCode(True, Scroll, gtk_range_get_update_policy(Range)); @@ -2571,7 +2577,10 @@ begin if Scroll<>nil then begin Msg.Msg := LM_HSCROLL; with Msg do begin - pos := Round(Adjustment^.Value); + if Adjustment^.value <= High(pos) then + pos := Round(Adjustment^.Value) + else + pos := High(pos); { Out of simple range } ScrollBar := HWND(Scroll); ScrollType := get_gtk_scroll_type(Scroll); ScrollCode := ScrollTypeToSbCode(False, ScrollType, @@ -2593,7 +2602,10 @@ begin if Scroll<>nil then begin Msg.Msg := LM_VSCROLL; with Msg do begin - pos := Round(Adjustment^.Value); + if Adjustment^.value <= High(pos) then + pos := Round(Adjustment^.Value) + else + pos := High(pos); { Out of simple range } ScrollBar := HWND(Scroll); ScrollType := get_gtk_scroll_type(Scroll); ScrollCode := ScrollTypeToSbCode(True, ScrollType,