Qt: fixed bug with BeginUpdate EndUpdate pair in SetScrollInfo,also send action when slider is released.issue #19687

LCL: Grids: fixed wrong calculation of bottom/right (max pos) of scrollbars in SB_BOTTOM (diff is always 1 on all ws).

git-svn-id: trunk@31587 -
This commit is contained in:
zeljko 2011-07-07 12:52:00 +00:00
parent b44dd17e8f
commit fd126a05a7
3 changed files with 61 additions and 14 deletions

View File

@ -4116,7 +4116,12 @@ begin
case message.ScrollCode of
// Scrolls to start / end of the text
SB_TOP: C := 0;
SB_BOTTOM: C := TL;
SB_BOTTOM:
begin
if not (goSmoothScroll in Options) then
TL := TL + 1;
C := TL;
end;
// Scrolls one line left / right
SB_LINERIGHT: C := CTL + NextColWidth( FTopLeft.X, 1);
SB_LINELEFT: C := CTL - NextColWidth( FTopLeft.X - 1, -1);
@ -4223,7 +4228,12 @@ begin
case message.ScrollCode of
// Scrolls to start / end of the text
SB_TOP: C := 0;
SB_BOTTOM: C := TL;
SB_BOTTOM:
begin
if not (goSmoothScroll in Options) then
TL := TL + 1;
C := TL;
end;
// Scrolls one line up / down
SB_LINEDOWN: C := CTL + NextRowHeight(FTopleft.Y, 1);
SB_LINEUP: C := CTL - NextRowHeight(FTopleft.Y-1, -1);

View File

@ -368,6 +368,7 @@ type
public
procedure preferredSize(var PreferredWidth, PreferredHeight: integer; WithThemeSpace: Boolean); override;
procedure setFocusPolicy(const APolicy: QtFocusPolicy); override;
procedure SlotSliderReleased; cdecl; override;
function EventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl; override;
procedure AttachEvents; override;
property TrackPos: Integer read FTrackPos write FTrackPos;
@ -6200,7 +6201,7 @@ var
b: Boolean;
begin
{$ifdef VerboseQt}
writeln('TQtAbstractSlider.SlotValueChanged() to value ',p1,' inUpdate ',inUpdate);
writeln('TQtAbstractSlider.SlotValueChanged() to value ',p1,' inUpdate ',inUpdate,' maxIs ',getMax);
{$endif}
FillChar(LMScroll, SizeOf(LMScroll), #0);
@ -6211,11 +6212,11 @@ begin
LMScroll.Msg := LM_HSCROLL
else
LMScroll.Msg := LM_VSCROLL;
LMScroll.Pos := p1;
LMScroll.ScrollCode := SIF_POS;
if not InUpdate and not getTracking then
if not InUpdate then
DeliverMessage(LMScroll);
b := p1 = getMax;
@ -6358,6 +6359,42 @@ begin
inherited setFocusPolicy(APolicy);
end;
procedure TQtScrollBar.SlotSliderReleased; cdecl;
var
AValue: Integer;
LMScroll: TLMScroll;
begin
inherited SlotSliderReleased;
if (ChildOfComplexWidget = ccwAbstractScrollArea) and (FOwner <> nil) and
(FOwner.ChildOfComplexWidget in [ccwCustomControl]) then
begin
AValue := getValue;
if AValue <= getMin then
QAbstractSlider_triggerAction(QAbstractSliderH(Widget), QAbstractSliderSliderToMinimum)
else
if AValue >= getMax then
QAbstractSlider_triggerAction(QAbstractSliderH(Widget), QAbstractSliderSliderToMaximum)
else
begin
FillChar(LMScroll, SizeOf(LMScroll), #0);
LMScroll.ScrollBar := PtrUInt(Self);
if QAbstractSlider_orientation(QAbstractSliderH(Widget)) = QtHorizontal then
LMScroll.Msg := LM_HSCROLL
else
LMScroll.Msg := LM_VSCROLL;
LMScroll.Pos := getSliderPosition;
if not GetTracking then
LMScroll.ScrollCode := SB_THUMBPOSITION
else
LMScroll.ScrollCode := SB_THUMBTRACK;
DeliverMessage(LMScroll);
end;
end;
end;
function TQtScrollBar.EventFilter(Sender: QObjectH; Event: QEventH): Boolean;
cdecl;
begin

View File

@ -3232,8 +3232,8 @@ begin
ScrollInfo.nPos := QtScrollBar.getValue;
// RANGE
if (ScrollInfo.fMask and SIF_RANGE) <> 0
then begin
if (ScrollInfo.fMask and SIF_RANGE) <> 0 then
begin
ScrollInfo.nMin:= QtScrollBar.getMin;
ScrollInfo.nMax:= QtScrollBar.getMax + QtScrollBar.getPageStep;
end;
@ -5710,6 +5710,9 @@ var
end;
end;
if (ScrollInfo.FMask and SIF_UPDATEPOLICY) <> 0 then
ScrollBar.setTracking(ScrollInfo.nTrackPos <> SB_POLICY_DISCONTINUOUS);
if (ScrollInfo.FMask and SIF_POS) <> 0 then
begin
inc(SBUpdatesCount);
@ -5717,11 +5720,11 @@ var
if SBUpdatesCount = 1 then
ScrollBar.BeginUpdate;
try
if (ScrollInfo.FMask and SIF_UPDATEPOLICY) = 0 then
if not (ScrollBar.getTracking and ScrollBar.getSliderDown) then
begin
{do not setValue() if values are equal, since it calls
signalValueChanged() which sends unneeded LM_SCROLL msgs }
if ScrollBar.getValue = ScrollInfo.nPos then
if (ScrollBar.getValue = ScrollInfo.nPos) then
SBUpdatesCount := 0;
if (ScrollInfo.nPos < ScrollBar.getMin) then
@ -5730,18 +5733,15 @@ var
if (ScrollInfo.nPos > ScrollBar.getMax) then
ScrollInfo.nPos := ScrollBar.getMax;
if SBUpdatesCount > 0 then
if (SBUpdatesCount > 0) then
ScrollBar.setValue(ScrollInfo.nPos);
end;
finally
if SBUpdatesCount = 1 then
if ScrollBar.InUpdate then
ScrollBar.EndUpdate;
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
begin
ScrollBar.TrackPos := ScrollInfo.nTrackPos;