Gtk2: fixed TScrollBar.ScrollBy_WS error. Patch by Andrew Haines

This commit is contained in:
Željan Rikalo 2023-02-01 15:06:28 +01:00
parent f823854588
commit 2ffedf7545

View File

@ -71,6 +71,7 @@ type
class procedure SetKind(const AScrollBar: TCustomScrollBar; const {%H-}AIsHorizontal: Boolean); override;
class procedure SetParams(const AScrollBar: TCustomScrollBar); override;
class procedure ShowHide(const AWinControl: TWinControl); override;
class procedure ScrollBy(const AWinControl: TWinControl; DeltaX, DeltaY: integer); override;
end;
{ TGtk2WSCustomGroupBox }
@ -2777,6 +2778,37 @@ begin
AWinControl.HandleObjectShouldBeVisible);
end;
class procedure TGtk2WSScrollBar.ScrollBy(const AWinControl: TWinControl;
DeltaX, DeltaY: integer);
var
Scrolled: PGtkRange;
Adjustment: PGtkAdjustment;
NewPos, v: gdouble;
Delta: Integer;
begin
if not AWinControl.HandleAllocated then exit;
Scrolled := GTK_RANGE({%H-}Pointer(AWinControl.Handle));
if not GTK_IS_SCROLLBAR(Scrolled) then
exit;
if GTK_IS_HSCROLLBAR(Scrolled) then
Delta := DeltaX
else
Delta := DeltaY;
Adjustment := gtk_range_get_adjustment(Scrolled);
if (Adjustment <> nil) then
begin
v := gtk_adjustment_get_value(Adjustment);
NewPos := Adjustment^.upper - Adjustment^.page_size;
if v - Delta <= NewPos then
NewPos := v - Delta;
gtk_adjustment_set_value(Adjustment, NewPos);
end;
// gtk doesn't emit a signal when we change the value manually
Gtk2RangeScrollCB(Scrolled, GTK_SCROLL_JUMP, NewPos, GetWidgetInfo(Scrolled));
end;
{ TGtk2WSRadioButton }
class function TGtk2WSRadioButton.CreateHandle(const AWinControl: TWinControl;