lcl: implement TControlScrollBar.Tracking for win32, qt and gtk2 (issue #0007981)

git-svn-id: trunk@23596 -
This commit is contained in:
paul 2010-01-29 17:32:40 +00:00
parent 4f3a4da4f5
commit 3f076b14b9
4 changed files with 37 additions and 3 deletions

View File

@ -92,6 +92,7 @@ type
FPosition: Integer; FPosition: Integer;
FRange: Integer; FRange: Integer;
FSmooth: Boolean; FSmooth: Boolean;
FTracking: Boolean;
FVisible: Boolean; FVisible: Boolean;
FOldScrollInfo: TScrollInfo; FOldScrollInfo: TScrollInfo;
FOldScrollInfoValid: Boolean; FOldScrollInfoValid: Boolean;
@ -119,6 +120,7 @@ type
procedure SetRange(const AValue: Integer); virtual; procedure SetRange(const AValue: Integer); virtual;
procedure SetSize(const AValue: integer); virtual; procedure SetSize(const AValue: integer); virtual;
procedure SetSmooth(const AValue: Boolean); virtual; procedure SetSmooth(const AValue: Boolean); virtual;
procedure SetTracking(const AValue: Boolean);
procedure SetVisible(const AValue: Boolean); virtual; procedure SetVisible(const AValue: Boolean); virtual;
procedure UpdateScrollBar; virtual; procedure UpdateScrollBar; virtual;
procedure InvalidateScrollInfo; procedure InvalidateScrollInfo;
@ -141,6 +143,7 @@ type
property Smooth: Boolean read GetSmooth write SetSmooth default False; property Smooth: Boolean read GetSmooth write SetSmooth default False;
property Position: Integer read GetPosition write SetPosition default 0; property Position: Integer read GetPosition write SetPosition default 0;
property Range: Integer read GetRange write SetRange stored IsRangeStored default 0; property Range: Integer read GetRange write SetRange stored IsRangeStored default 0;
property Tracking: Boolean read FTracking write SetTracking default False;
property Visible: Boolean read GetVisible write SetVisible default True; property Visible: Boolean read GetVisible write SetVisible default True;
end; end;

View File

@ -22,6 +22,12 @@ const
SB_VERT SB_VERT
); );
TrackToPolicyMap: array[Boolean] of integer =
(
SB_POLICY_DISCONTINUOUS,
SB_POLICY_CONTINUOUS
);
procedure TControlScrollBar.SetPosition(const Value: Integer); procedure TControlScrollBar.SetPosition(const Value: Integer);
var var
OldPosition, MaxPos: Integer; OldPosition, MaxPos: Integer;
@ -298,6 +304,10 @@ begin
FOldScrollInfo := ScrollInfo; FOldScrollInfo := ScrollInfo;
FOldScrollInfoValid := True; FOldScrollInfoValid := True;
SetScrollInfo(FControl.Handle, IntfBarKind[Kind], ScrollInfo, FVisible); SetScrollInfo(FControl.Handle, IntfBarKind[Kind], ScrollInfo, FVisible);
// update policy too
ScrollInfo.fMask := SIF_UPDATEPOLICY;
ScrollInfo.nTrackPos := TrackToPolicyMap[FTracking];
SetScrollInfo(ControlHandle, IntfBarKind[Kind], ScrollInfo, FVisible);
end; end;
NewVisible := Visible and (ScrollInfo.nMax - ScrollInfo.nPage > 0); NewVisible := Visible and (ScrollInfo.nMax - ScrollInfo.nPage > 0);
ShowScrollBar(FControl.Handle, IntfBarKind[Kind], NewVisible); ShowScrollBar(FControl.Handle, IntfBarKind[Kind], NewVisible);
@ -355,8 +365,11 @@ begin
Dec(NewPos, FPage); Dec(NewPos, FPage);
SB_PAGEDOWN: SB_PAGEDOWN:
Inc(NewPos, FPage); Inc(NewPos, FPage);
SB_THUMBPOSITION, SB_THUMBTRACK: SB_THUMBPOSITION:
NewPos := Message.Pos; NewPos := Message.Pos;
SB_THUMBTRACK:
if Tracking then
NewPos := Message.Pos;
SB_TOP: SB_TOP:
NewPos := 0; NewPos := 0;
SB_BOTTOM: SB_BOTTOM:
@ -419,6 +432,21 @@ begin
Result := not GetAutoScroll; Result := not GetAutoScroll;
end; end;
procedure TControlScrollBar.SetTracking(const AValue: Boolean);
var
ScrollInfo: TScrollInfo;
begin
if FTracking = AValue then Exit;
FTracking := AValue;
if not HandleAllocated then
Exit;
FillChar(ScrollInfo,SizeOf(ScrollInfo), 0);
ScrollInfo.cbSize := SizeOf(ScrollInfo);
ScrollInfo.fMask := SIF_UPDATEPOLICY;
ScrollInfo.nTrackPos := TrackToPolicyMap[FTracking];
SetScrollInfo(ControlHandle, IntfBarKind[Kind], ScrollInfo, FVisible);
end;
function TControlScrollBar.ControlHandle: HWnd; function TControlScrollBar.ControlHandle: HWnd;
begin begin
Result := FControl.Handle; Result := FControl.Handle;
@ -435,6 +463,7 @@ begin
FPosition := 0; FPosition := 0;
FRange := 0; FRange := 0;
FSmooth := False; FSmooth := False;
FTracking := False;
FVisible := True; FVisible := True;
end; end;

View File

@ -5134,7 +5134,7 @@ begin
LMScroll.Msg := LM_VSCROLL; LMScroll.Msg := LM_VSCROLL;
LMScroll.Pos := p1; LMScroll.Pos := p1;
LMScroll.ScrollCode := SIF_POS; { SIF_TRACKPOS } LMScroll.ScrollCode := SIF_TRACKPOS;
if not InUpdate then if not InUpdate then
DeliverMessage(LMScroll); DeliverMessage(LMScroll);

View File

@ -1499,7 +1499,6 @@ var
Region: QRegionH; Region: QRegionH;
ExRegion: QRegionH; ExRegion: QRegionH;
QtDC: TQtDeviceContext absolute dc; QtDC: TQtDeviceContext absolute dc;
R: TRect;
begin begin
{$ifdef VerboseQtWinAPI} {$ifdef VerboseQtWinAPI}
WriteLn('[WinAPI ExcludeClipRect]'); WriteLn('[WinAPI ExcludeClipRect]');
@ -4946,6 +4945,9 @@ var
end; end;
end; end;
if (ScrollInfo.FMask and SIF_UPDATEPOLICY) <> 0 then
ScrollBar.setTracking(ScrollInfo.nTrackPos <> SB_POLICY_DISCONTINUOUS);
if (ScrollInfo.FMask and SIF_TRACKPOS) <> 0 then if (ScrollInfo.FMask and SIF_TRACKPOS) <> 0 then
begin begin
// from MSDN: the SetScrollInfo function ignores this member // from MSDN: the SetScrollInfo function ignores this member