mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-30 17:50:19 +02:00
Qt: Completely rewritten SetScrollInfo() & GetScrollInfo(), now scrollbars works ok and faster since invalidating of scrollbar is out of this routines now. Fixed EnableWindow() bug by reimplementation of SetScrollInfo() & GetScrollInfo().
git-svn-id: trunk@12241 -
This commit is contained in:
parent
fcf28f8985
commit
c565a39dde
@ -1232,18 +1232,17 @@ function TQtWidgetSet.EnableScrollBar(Wnd: HWND; wSBflags, wArrows: Cardinal): B
|
|||||||
begin
|
begin
|
||||||
{maybe we can put creating of scrollbar here instead of SetScrollInfo() }
|
{maybe we can put creating of scrollbar here instead of SetScrollInfo() }
|
||||||
Result := False;
|
Result := False;
|
||||||
{$ifdef VerboseQtWinAPI_MISSING_IMPLEMENTATION}
|
// {$ifdef VerboseQtWinAPI_MISSING_IMPLEMENTATION}
|
||||||
WriteLn('***** [WinAPI TQtWidgetSet.EnableScrollbar] missing implementation ');
|
WriteLn('***** [WinAPI TQtWidgetSet.EnableScrollbar] missing implementation ');
|
||||||
{$endif}
|
// {$endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TQtWidgetSet.EnableWindow(hWnd: HWND; bEnable: Boolean): Boolean;
|
function TQtWidgetSet.EnableWindow(hWnd: HWND; bEnable: Boolean): Boolean;
|
||||||
begin
|
begin
|
||||||
Result := True;
|
{$ifdef VerboseQtWinAPI}
|
||||||
{$ifdef VerboseQtWinAPI_MISSING_IMPLEMENTATION}
|
WriteLn('[WinAPI EnableWindow] ');
|
||||||
WriteLn('***** [WinAPI TQtWidgetSet.EnableWindow] possible wrong implementation');
|
|
||||||
{$endif}
|
{$endif}
|
||||||
if not (TQtWidget(hWnd).LCLObject is TScrollBar) then
|
Result := QWidget_isEnabled(TQtWidget(hWnd).Widget);
|
||||||
TQtWidget(hWnd).setEnabled(bEnable);
|
TQtWidget(hWnd).setEnabled(bEnable);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -2400,9 +2399,12 @@ end;
|
|||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Function: GetScrollInfo
|
Function: GetScrollInfo
|
||||||
Params: BarFlag
|
Params: BarFlag
|
||||||
SB_CTL Retrieves the parameters for a scroll bar control. The hwnd parameter must be the handle to the scroll bar control.
|
SB_CTL Retrieves the parameters for a scroll bar control. The hwnd
|
||||||
SB_HORZ Retrieves the parameters for the window's standard horizontal scroll bar.
|
parameter must be the handle to the scroll bar control.
|
||||||
SB_VERT Retrieves the parameters for the window's standard vertical scroll bar.
|
SB_HORZ Retrieves the parameters for the window's standard horizontal
|
||||||
|
scroll bar.
|
||||||
|
SB_VERT Retrieves the parameters for the window's standard vertical
|
||||||
|
scroll bar.
|
||||||
|
|
||||||
ScrollInfo returns TScrollInfo structure.
|
ScrollInfo returns TScrollInfo structure.
|
||||||
|
|
||||||
@ -2418,14 +2420,6 @@ begin
|
|||||||
|
|
||||||
if Handle = 0 then exit;
|
if Handle = 0 then exit;
|
||||||
|
|
||||||
ScrollInfo.nTrackPos := 0;
|
|
||||||
ScrollInfo.nPage := 0;
|
|
||||||
ScrollInfo.nMax := 0;
|
|
||||||
ScrollInfo.nMin := 0;
|
|
||||||
ScrollInfo.nPos := 0;
|
|
||||||
ScrollInfo.fMask := SIF_UPDATEPOLICY;
|
|
||||||
ScrollInfo.cbSize := SizeOf(ScrollInfo);
|
|
||||||
|
|
||||||
if (csDestroying in TQtWidget(Handle).LCLObject.ComponentState) or
|
if (csDestroying in TQtWidget(Handle).LCLObject.ComponentState) or
|
||||||
(csFreeNotification in TQtWidget(Handle).LCLObject.ComponentState) then
|
(csFreeNotification in TQtWidget(Handle).LCLObject.ComponentState) then
|
||||||
exit;
|
exit;
|
||||||
@ -2442,17 +2436,9 @@ begin
|
|||||||
SB_VERT: QtScrollBar := TQtAbstractScrollArea(Handle).verticalScrollBar;
|
SB_VERT: QtScrollBar := TQtAbstractScrollArea(Handle).verticalScrollBar;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if QtScrollBar = nil then exit;
|
if QtScrollBar = nil then exit
|
||||||
|
else FScrollBar := TScrollBar(QtScrollBar.LCLObject);
|
||||||
|
|
||||||
ScrollInfo.nTrackPos := 0;
|
|
||||||
|
|
||||||
ScrollInfo.nMax := QtScrollBar.getMax;
|
|
||||||
ScrollInfo.nMin := QtScrollBar.getMin;
|
|
||||||
ScrollInfo.nPage := QtScrollBar.getPageStep;
|
|
||||||
ScrollInfo.nPos := QtScrollBar.getValue;
|
|
||||||
ScrollInfo.fMask := SIF_ALL;
|
|
||||||
ScrollInfo.cbSize := SizeOf(ScrollInfo);
|
|
||||||
Result := True;
|
|
||||||
end else
|
end else
|
||||||
Result := False;
|
Result := False;
|
||||||
end
|
end
|
||||||
@ -2464,12 +2450,23 @@ begin
|
|||||||
|
|
||||||
if (csDestroying in FScrollBar.ComponentState) then exit;
|
if (csDestroying in FScrollBar.ComponentState) then exit;
|
||||||
|
|
||||||
ScrollInfo.nTrackPos := 0; {TODO: according to msdn this is ignored in SetScrollInfo()}
|
// POS
|
||||||
ScrollInfo.nPage := FScrollBar.PageSize;
|
if (ScrollInfo.fMask and SIF_POS) <> 0 then
|
||||||
ScrollInfo.nMax := FScrollBar.Max;
|
|
||||||
ScrollInfo.nMin := FScrollBar.Min;
|
|
||||||
ScrollInfo.nPos := FScrollBar.Position;
|
ScrollInfo.nPos := FScrollBar.Position;
|
||||||
ScrollInfo.cbSize := SizeOf(ScrollInfo);
|
|
||||||
|
// RANGE
|
||||||
|
if (ScrollInfo.fMask and SIF_RANGE) <> 0
|
||||||
|
then begin
|
||||||
|
ScrollInfo.nMin:= FScrollBar.Min;
|
||||||
|
ScrollInfo.nMax:= FScrollBar.Max;
|
||||||
|
end;
|
||||||
|
// PAGE
|
||||||
|
if (ScrollInfo.fMask and SIF_PAGE) <> 0 then
|
||||||
|
ScrollInfo.nPage := FScrollBar.PageSize;
|
||||||
|
|
||||||
|
// TRACKPOS TrackPos is setted up as in gtk implementation
|
||||||
|
if (ScrollInfo.fMask and SIF_TRACKPOS) <> 0 then
|
||||||
|
ScrollInfo.nTrackPos := FScrollBar.Position;
|
||||||
|
|
||||||
Result := True;
|
Result := True;
|
||||||
end;
|
end;
|
||||||
@ -4023,7 +4020,6 @@ var
|
|||||||
ScrollBar: TScrollBar;
|
ScrollBar: TScrollBar;
|
||||||
FScrollInfo: TScrollInfo;
|
FScrollInfo: TScrollInfo;
|
||||||
R: TRect;
|
R: TRect;
|
||||||
FRepaint: Boolean;
|
|
||||||
|
|
||||||
function PrepareScrollInfo: Integer;
|
function PrepareScrollInfo: Integer;
|
||||||
var
|
var
|
||||||
@ -4041,11 +4037,10 @@ begin
|
|||||||
if GetScrollInfo(Handle, SBStyle, FScrollInfo) then
|
if GetScrollInfo(Handle, SBStyle, FScrollInfo) then
|
||||||
begin
|
begin
|
||||||
{impossible cases}
|
{impossible cases}
|
||||||
if (ScrollInfo.nMax < 0)
|
if (ScrollInfo.nMax < 0) or
|
||||||
or (Integer(ScrollInfo.nPage) > ScrollInfo.nMax) then
|
(Integer(ScrollInfo.nPage) > ScrollInfo.nMax) then exit;
|
||||||
exit;
|
|
||||||
|
|
||||||
if (ScrollInfo.FMask or SIF_RANGE) = ScrollInfo.FMask then
|
if (ScrollInfo.FMask and SIF_RANGE) <> 0 then
|
||||||
begin
|
begin
|
||||||
FScrollInfo.nMin := ScrollInfo.nMin;
|
FScrollInfo.nMin := ScrollInfo.nMin;
|
||||||
FScrollInfo.nMax := ScrollInfo.nMax;
|
FScrollInfo.nMax := ScrollInfo.nMax;
|
||||||
@ -4060,23 +4055,18 @@ begin
|
|||||||
{ - (ScrollInfo.nMax div 4 PageStep property)); }
|
{ - (ScrollInfo.nMax div 4 PageStep property)); }
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if (ScrollInfo.FMask or SIF_PAGE) = ScrollInfo.FMask then
|
if (ScrollInfo.FMask and SIF_PAGE) <> 0 then
|
||||||
begin
|
begin
|
||||||
FScrollInfo.nPage := ScrollInfo.nPage;
|
FScrollInfo.nPage := ScrollInfo.nPage;
|
||||||
{segfaults if we don't check Enabled property !}
|
{segfaults if we don't check Enabled property !}
|
||||||
if ScrollBar.Enabled then
|
if ScrollBar.Enabled then
|
||||||
begin
|
|
||||||
{default Qt minimum size}
|
|
||||||
if ScrollInfo.nPage < 10 then
|
|
||||||
ScrollBar.PageSize := ScrollBar.Max
|
|
||||||
else
|
|
||||||
ScrollBar.PageSize := ScrollInfo.nPage;
|
ScrollBar.PageSize := ScrollInfo.nPage;
|
||||||
end;
|
end;
|
||||||
end;
|
|
||||||
|
|
||||||
if (ScrollInfo.FMask or SIF_POS) = ScrollInfo.FMask then
|
if (ScrollInfo.FMask and SIF_POS) <> 0 then
|
||||||
begin
|
begin
|
||||||
FScrollInfo.nPos := ScrollInfo.nPos;
|
FScrollInfo.nPos := ScrollInfo.nPos;
|
||||||
|
FScrollInfo.nTrackPos := ScrollInfo.nPos;
|
||||||
|
|
||||||
if (FScrollInfo.nPos < ScrollBar.Min) then
|
if (FScrollInfo.nPos < ScrollBar.Min) then
|
||||||
FScrollInfo.nPos := ScrollBar.Min
|
FScrollInfo.nPos := ScrollBar.Min
|
||||||
@ -4088,56 +4078,12 @@ begin
|
|||||||
ScrollBar.Position := FScrollInfo.nPos;
|
ScrollBar.Position := FScrollInfo.nPos;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if (ScrollInfo.FMask or SIF_TRACKPOS) = ScrollInfo.FMask then
|
if (ScrollInfo.FMask and SIF_TRACKPOS) <> 0 then
|
||||||
begin
|
begin
|
||||||
FScrollInfo.nTrackPos := ScrollInfo.nTrackPos;
|
FScrollInfo.nTrackPos := ScrollInfo.nTrackPos;
|
||||||
{TODO: TQtScrollBar(ScrollBar.Handle).setTracking(True); via SB_THUMBTRACK }
|
{TODO: TQtScrollBar(ScrollBar.Handle).setTracking(True); via SB_THUMBTRACK }
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if (ScrollInfo.FMask or SIF_ALL) = ScrollInfo.FMask then
|
|
||||||
begin
|
|
||||||
|
|
||||||
FScrollInfo.nPage := ScrollInfo.nPage;
|
|
||||||
FScrollInfo.nPos := ScrollInfo.nPos;
|
|
||||||
|
|
||||||
if (FScrollInfo.nPos < ScrollBar.Min) then
|
|
||||||
FScrollInfo.nPos := ScrollBar.Min
|
|
||||||
else
|
|
||||||
if (FScrollInfo.nPos > ScrollBar.Max) then
|
|
||||||
FScrollInfo.nPos := ScrollBar.Max;
|
|
||||||
|
|
||||||
FScrollInfo.nMin := ScrollInfo.nMin;
|
|
||||||
FScrollInfo.nMax := ScrollInfo.nMax;
|
|
||||||
ScrollBar.Min := ScrollInfo.nMin;
|
|
||||||
ScrollBar.Max := ScrollInfo.nMax;
|
|
||||||
{segfaults if we don't check Enabled property !}
|
|
||||||
if ScrollBar.Enabled then
|
|
||||||
begin
|
|
||||||
{default Qt minimum size}
|
|
||||||
if ScrollInfo.nPage < 10 then
|
|
||||||
ScrollBar.PageSize := ScrollBar.Max
|
|
||||||
else
|
|
||||||
ScrollBar.PageSize := ScrollInfo.nPage;
|
|
||||||
end;
|
|
||||||
if (ScrollBar.Position <> FScrollInfo.nPos) then
|
|
||||||
ScrollBar.Position := FScrollInfo.nPos;
|
|
||||||
end;
|
|
||||||
|
|
||||||
if (ScrollInfo.FMask or SIF_DISABLENOSCROLL) = ScrollInfo.FMask then
|
|
||||||
begin
|
|
||||||
{This value is used only when setting a scroll bar''s parameters.
|
|
||||||
If the scroll bar's new parameters make the scroll bar unnecessary,
|
|
||||||
disable the scroll bar instead of removing it.}
|
|
||||||
ScrollBar.Enabled := False;
|
|
||||||
end else
|
|
||||||
begin
|
|
||||||
if not ScrollBar.Enabled then
|
|
||||||
begin
|
|
||||||
ScrollBar.Enabled := True;
|
|
||||||
ScrollBar.Invalidate;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
ScrollInfo := FScrollInfo;
|
ScrollInfo := FScrollInfo;
|
||||||
Result := FScrollInfo.nPos;
|
Result := FScrollInfo.nPos;
|
||||||
end;
|
end;
|
||||||
@ -4148,7 +4094,6 @@ begin
|
|||||||
|
|
||||||
if (Handle = 0) then exit;
|
if (Handle = 0) then exit;
|
||||||
|
|
||||||
FRepaint := False;
|
|
||||||
ScrollBar := NiL;
|
ScrollBar := NiL;
|
||||||
case SBStyle of
|
case SBStyle of
|
||||||
|
|
||||||
@ -4161,10 +4106,8 @@ begin
|
|||||||
SB_CTL:
|
SB_CTL:
|
||||||
begin
|
begin
|
||||||
{HWND is always TScrollBar, but seem that Create ScrollBar should be called here }
|
{HWND is always TScrollBar, but seem that Create ScrollBar should be called here }
|
||||||
if (csReading in TQtWidget(Handle).LCLObject.ComponentState)
|
if (csReading in TQtWidget(Handle).LCLObject.ComponentState) or
|
||||||
or (csDestroying in TQtWidget(Handle).LCLObject.ComponentState)
|
(csDestroying in TQtWidget(Handle).LCLObject.ComponentState) then exit;
|
||||||
then
|
|
||||||
exit;
|
|
||||||
|
|
||||||
ScrollBar := TScrollBar(TQtWidget(Handle).LCLObject);
|
ScrollBar := TScrollBar(TQtWidget(Handle).LCLObject);
|
||||||
|
|
||||||
@ -4176,8 +4119,6 @@ begin
|
|||||||
exit; {still creating ... set it to Nil because of PrepareScrollInfo() }
|
exit; {still creating ... set it to Nil because of PrepareScrollInfo() }
|
||||||
end;
|
end;
|
||||||
|
|
||||||
FRepaint := bRedraw and not ScrollBar.Visible;
|
|
||||||
|
|
||||||
ScrollBar.Visible := bRedraw;
|
ScrollBar.Visible := bRedraw;
|
||||||
end; {SB_CTL}
|
end; {SB_CTL}
|
||||||
|
|
||||||
@ -4213,11 +4154,9 @@ begin
|
|||||||
TQtAbstractScrollArea(Handle).horizontalScrollBar.Show;
|
TQtAbstractScrollArea(Handle).horizontalScrollBar.Show;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if Assigned(ScrollBar) then
|
if Assigned(ScrollBar) then
|
||||||
begin
|
|
||||||
FRepaint := bRedraw and not ScrollBar.Visible;
|
|
||||||
ScrollBar.Visible := bRedraw;
|
ScrollBar.Visible := bRedraw;
|
||||||
end;
|
|
||||||
|
|
||||||
end; {SB_HORZ}
|
end; {SB_HORZ}
|
||||||
|
|
||||||
@ -4255,24 +4194,16 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if Assigned(ScrollBar) then
|
if Assigned(ScrollBar) then
|
||||||
begin
|
|
||||||
FRepaint := bRedraw and not ScrollBar.Visible;
|
|
||||||
ScrollBar.Visible := bRedraw;
|
ScrollBar.Visible := bRedraw;
|
||||||
end;
|
|
||||||
|
|
||||||
end; {SB_VERT}
|
end; {SB_VERT}
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if Assigned(ScrollBar) then
|
if Assigned(ScrollBar) and bRedraw then
|
||||||
begin
|
|
||||||
if FRepaint then ScrollBar.Invalidate;
|
|
||||||
|
|
||||||
if bRedraw
|
|
||||||
then
|
|
||||||
Result := PrepareScrollInfo;
|
Result := PrepareScrollInfo;
|
||||||
end;
|
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -361,7 +361,10 @@ begin
|
|||||||
QtScrollBar := TQtScrollBar(AScrollBar.Handle);
|
QtScrollBar := TQtScrollBar(AScrollBar.Handle);
|
||||||
|
|
||||||
{feels much better with *2 pagesize}
|
{feels much better with *2 pagesize}
|
||||||
QtScrollBar.setPageStep(AScrollBar.PageSize * 2);
|
|
||||||
|
QtScrollBar.setPageStep(AScrollBar.PageSize);
|
||||||
|
QtScrollBar.setSingleStep((AScrollBar.PageSize div 6) + 1);
|
||||||
|
|
||||||
QtScrollBar.setRange(AScrollBar.Min, AScrollBar.Max);
|
QtScrollBar.setRange(AScrollBar.Min, AScrollBar.Max);
|
||||||
|
|
||||||
QtScrollBar.setValue(AScrollBar.Position);
|
QtScrollBar.setValue(AScrollBar.Position);
|
||||||
@ -369,6 +372,7 @@ begin
|
|||||||
RA := QtScrollBar.LCLObject.ClientRect;
|
RA := QtScrollBar.LCLObject.ClientRect;
|
||||||
RB := AScrollBar.ClientRect;
|
RB := AScrollBar.ClientRect;
|
||||||
|
|
||||||
|
|
||||||
if not EqualRect(RA, RB) then
|
if not EqualRect(RA, RB) then
|
||||||
QWidget_setGeometry(QtScrollbar.Widget,AScrollBar.Left,AScrollBar.Top,AScrollBar.Width,AScrollBar.Height);
|
QWidget_setGeometry(QtScrollbar.Widget,AScrollBar.Left,AScrollBar.Top,AScrollBar.Width,AScrollBar.Height);
|
||||||
{don't update geometry each time}
|
{don't update geometry each time}
|
||||||
|
Loading…
Reference in New Issue
Block a user