From fd126a05a7a4c78aa8ead55f2ef1d6980bf1d1f8 Mon Sep 17 00:00:00 2001 From: zeljko Date: Thu, 7 Jul 2011 12:52:00 +0000 Subject: [PATCH] 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 - --- lcl/grids.pas | 14 +++++++++-- lcl/interfaces/qt/qtwidgets.pas | 43 ++++++++++++++++++++++++++++++--- lcl/interfaces/qt/qtwinapi.inc | 18 +++++++------- 3 files changed, 61 insertions(+), 14 deletions(-) diff --git a/lcl/grids.pas b/lcl/grids.pas index a37ae30ccb..e5112ee424 100644 --- a/lcl/grids.pas +++ b/lcl/grids.pas @@ -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); diff --git a/lcl/interfaces/qt/qtwidgets.pas b/lcl/interfaces/qt/qtwidgets.pas index a1147f8be4..dbd9301a31 100644 --- a/lcl/interfaces/qt/qtwidgets.pas +++ b/lcl/interfaces/qt/qtwidgets.pas @@ -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 diff --git a/lcl/interfaces/qt/qtwinapi.inc b/lcl/interfaces/qt/qtwinapi.inc index 77efdff803..178b745bd8 100644 --- a/lcl/interfaces/qt/qtwinapi.inc +++ b/lcl/interfaces/qt/qtwinapi.inc @@ -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;