mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-07 05:18:00 +02:00
lcl: make ScrollBy more delphi compatible:
- invert direction of scroll - add TWinControl.ScrollBy to scroll inner controls - scroll controls in TScrollingWinControl (fixes issue #0016721) git-svn-id: trunk@29944 -
This commit is contained in:
parent
a4d4972a0a
commit
0373c8de84
@ -1930,6 +1930,7 @@ type
|
||||
procedure DisableAlign;
|
||||
procedure EnableAlign;
|
||||
procedure ReAlign; // realign all children
|
||||
procedure ScrollBy(DeltaX, DeltaY: Integer); virtual;
|
||||
procedure WriteLayoutDebugReport(const Prefix: string); override;
|
||||
public
|
||||
constructor Create(TheOwner: TComponent);override;
|
||||
|
@ -184,7 +184,7 @@ type
|
||||
destructor Destroy; override;
|
||||
procedure UpdateScrollbars;
|
||||
class function GetControlClassDefaultSize: TSize; override;
|
||||
procedure ScrollBy(DeltaX, DeltaY: Integer);
|
||||
procedure ScrollBy(DeltaX, DeltaY: Integer); override;
|
||||
published
|
||||
property HorzScrollBar: TControlScrollBar
|
||||
read FHorzScrollBar write SetHorzScrollBar stored StoreScrollBars;
|
||||
|
@ -189,21 +189,31 @@ begin
|
||||
end;
|
||||
|
||||
procedure TScrollingWinControl.ScrollBy(DeltaX, DeltaY: Integer);
|
||||
var
|
||||
i: Integer;
|
||||
Control: TControl;
|
||||
begin
|
||||
if HandleAllocated then
|
||||
if HandleAllocated and IsWindowVisible(Handle) then
|
||||
begin
|
||||
TWSScrollingWinControlClass(WidgetSetClass).ScrollBy(Self, DeltaX, DeltaY);
|
||||
// scroll inner controls
|
||||
for i := 0 to ControlCount - 1 do
|
||||
if not (Controls[i] is TWinControl) then
|
||||
with Controls[i] do
|
||||
SetBounds(Left + DeltaX, Top + DeltaY, Width, Height);
|
||||
Invalidate;
|
||||
end;
|
||||
end
|
||||
else
|
||||
inherited ScrollBy(DeltaX, DeltaY);
|
||||
end;
|
||||
|
||||
procedure TScrollingWinControl.ScrollbarHandler(ScrollKind: TScrollBarKind;
|
||||
OldPosition: Integer);
|
||||
begin
|
||||
if ScrollKind = sbVertical then
|
||||
ScrollBy(0, FVertScrollBar.Position - OldPosition)
|
||||
ScrollBy(0, OldPosition - FVertScrollBar.Position)
|
||||
else
|
||||
ScrollBy(FHorzScrollBar.Position - OldPosition, 0);
|
||||
ScrollBy(OldPosition - FHorzScrollBar.Position, 0);
|
||||
end;
|
||||
|
||||
procedure TScrollingWinControl.Loaded;
|
||||
|
@ -5997,6 +5997,17 @@ begin
|
||||
AdjustSize;
|
||||
end;
|
||||
|
||||
procedure TWinControl.ScrollBy(DeltaX, DeltaY: Integer);
|
||||
var
|
||||
i: Integer;
|
||||
Control: TControl;
|
||||
begin
|
||||
// scroll inner controls
|
||||
for i := 0 to ControlCount - 1 do
|
||||
with Controls[i] do
|
||||
SetBounds(Left + DeltaX, Top + DeltaY, Width, Height);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
TWinControl Remove
|
||||
------------------------------------------------------------------------------}
|
||||
|
@ -952,7 +952,7 @@ const
|
||||
begin
|
||||
OSError(HIViewGetBounds(Content, R),
|
||||
Self, SName, 'HIViewGetBounds');
|
||||
OSError(HIViewSetBoundsOrigin(Content, R.origin.x + DX, R.origin.y + DY),
|
||||
OSError(HIViewSetBoundsOrigin(Content, R.origin.x - DX, R.origin.y - DY),
|
||||
Self, SName, 'HIViewSetBoundsOrigin');
|
||||
end;
|
||||
|
||||
|
@ -426,8 +426,7 @@ begin
|
||||
g_idle_remove_by_data(Data);
|
||||
end;
|
||||
|
||||
class procedure TGtk2WSCustomForm.ScrollBy(
|
||||
const AWinControl: TScrollingWinControl; const DeltaX, DeltaY: integer);
|
||||
class procedure TGtk2WSCustomForm.ScrollBy(const AWinControl: TScrollingWinControl; const DeltaX, DeltaY: integer);
|
||||
var
|
||||
Layout: PGtkLayout;
|
||||
WidgetInfo: PWidgetInfo;
|
||||
@ -443,8 +442,8 @@ begin
|
||||
begin
|
||||
h := gtk_adjustment_get_value(Adjustment);
|
||||
NewPos := Adjustment^.upper - Adjustment^.page_size;
|
||||
if h + DeltaX <= NewPos then
|
||||
NewPos := h + DeltaX;
|
||||
if h - DeltaX <= NewPos then
|
||||
NewPos := h - DeltaX;
|
||||
if gtk_adjustment_get_value(Adjustment) <> NewPos then
|
||||
begin
|
||||
gtk_adjustment_set_value(Adjustment, NewPos);
|
||||
@ -459,8 +458,8 @@ begin
|
||||
begin
|
||||
v := gtk_adjustment_get_value(Adjustment);
|
||||
NewPos := Adjustment^.upper - Adjustment^.page_size;
|
||||
if v + DeltaY <= NewPos then
|
||||
NewPos := v + DeltaY;
|
||||
if v - DeltaY <= NewPos then
|
||||
NewPos := v - DeltaY;
|
||||
if gtk_adjustment_get_value(Adjustment) <> NewPos then
|
||||
begin
|
||||
gtk_adjustment_set_value(Adjustment, NewPos);
|
||||
@ -768,8 +767,8 @@ begin
|
||||
begin
|
||||
h := gtk_adjustment_get_value(Adjustment);
|
||||
NewPos := Adjustment^.upper - Adjustment^.page_size;
|
||||
if h + DeltaX <= NewPos then
|
||||
NewPos := h + DeltaX;
|
||||
if h - DeltaX <= NewPos then
|
||||
NewPos := h - DeltaX;
|
||||
gtk_adjustment_set_value(Adjustment, NewPos);
|
||||
end;
|
||||
Adjustment := gtk_scrolled_window_get_vadjustment(Scrolled);
|
||||
@ -777,8 +776,8 @@ begin
|
||||
begin
|
||||
v := gtk_adjustment_get_value(Adjustment);
|
||||
NewPos := Adjustment^.upper - Adjustment^.page_size;
|
||||
if v + DeltaY <= NewPos then
|
||||
NewPos := v + DeltaY;
|
||||
if v - DeltaY <= NewPos then
|
||||
NewPos := v - DeltaY;
|
||||
gtk_adjustment_set_value(Adjustment, NewPos);
|
||||
end;
|
||||
end;
|
||||
|
@ -616,7 +616,7 @@ begin
|
||||
if not WSCheckHandleAllocated(AWinControl, 'ScrollBy') then
|
||||
Exit;
|
||||
Widget := TQtCustomControl(AWinControl.Handle);
|
||||
Widget.viewport.scroll(-DeltaX, -DeltaY);
|
||||
Widget.viewport.scroll(DeltaX, DeltaY);
|
||||
end;
|
||||
|
||||
{ TQtWSCustomFrame }
|
||||
@ -629,7 +629,7 @@ begin
|
||||
if not WSCheckHandleAllocated(AWinControl, 'ScrollBy') then
|
||||
Exit;
|
||||
Widget := TQtCustomControl(AWinControl.Handle);
|
||||
Widget.viewport.scroll(-DeltaX, -DeltaY);
|
||||
Widget.viewport.scroll(DeltaX, DeltaY);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -224,12 +224,9 @@ function ScrollWindowPtr(hWnd:HWND; XAmount:longint; YAmount:longint; lpRect: po
|
||||
|
||||
class procedure TWin32WSScrollingWinControl.ScrollBy(const AWinControl: TScrollingWinControl;
|
||||
const DeltaX, DeltaY: integer);
|
||||
var
|
||||
lVisible: boolean;
|
||||
begin
|
||||
lVisible := AWinControl.HandleAllocated and Windows.IsWindowVisible(AWinControl.Handle);
|
||||
if lVisible then
|
||||
ScrollWindowPtr(AWinControl.Handle, -DeltaX, -DeltaY, nil, nil);
|
||||
if Windows.IsWindowVisible(AWinControl.Handle) then
|
||||
ScrollWindowPtr(AWinControl.Handle, DeltaX, DeltaY, nil, nil);
|
||||
end;
|
||||
|
||||
{ TWin32WSCustomForm }
|
||||
|
@ -158,21 +158,19 @@ end;
|
||||
class procedure TWinCEWSScrollingWinControl.ScrollBy(const AWinControl: TScrollingWinControl;
|
||||
const DeltaX, DeltaY: integer);
|
||||
var
|
||||
lVisible: boolean;
|
||||
rgn : HRGN;
|
||||
rect : trect;
|
||||
rgn: HRGN;
|
||||
rect: trect;
|
||||
begin
|
||||
lVisible := AWinControl.HandleAllocated and Windows.IsWindowVisible(AWinControl.Handle);
|
||||
rgn := 0; //roozbeh : seems to be ok?
|
||||
// GetClipRgn(AWinControl.Handle,rgn);
|
||||
// roozbeh:which flags really are required?!
|
||||
if lVisible then
|
||||
{$ifdef win32}
|
||||
ScrollWindowPtr(AWinControl.Handle, -DeltaX, -DeltaY, nil, nil);
|
||||
{$else}
|
||||
ScrollWindowPtr(AWinControl.Handle, -DeltaX, -DeltaY, nil, nil,
|
||||
rgn, nil, SW_INVALIDATE or SW_ERASE or SW_SCROLLCHILDREN);
|
||||
{$endif}
|
||||
rgn := 0; //roozbeh : seems to be ok?
|
||||
// GetClipRgn(AWinControl.Handle,rgn);
|
||||
// roozbeh:which flags really are required?!
|
||||
if Windows.IsWindowVisible(AWinControl.Handle) then
|
||||
{$ifdef win32}
|
||||
ScrollWindowPtr(AWinControl.Handle, DeltaX, DeltaY, nil, nil);
|
||||
{$else}
|
||||
ScrollWindowPtr(AWinControl.Handle, DeltaX, DeltaY, nil, nil,
|
||||
rgn, nil, SW_INVALIDATE or SW_ERASE or SW_SCROLLCHILDREN);
|
||||
{$endif}
|
||||
end;
|
||||
|
||||
{ TWinCEWSCustomForm }
|
||||
|
Loading…
Reference in New Issue
Block a user