mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 06:56:10 +02:00
* Fixed setting layoutrange
git-svn-id: trunk@7843 -
This commit is contained in:
parent
74443943d2
commit
c943976da2
@ -202,18 +202,21 @@ procedure TControlScrollBar.AutoCalcRange;
|
|||||||
|
|
||||||
procedure AutoCalcHRange;
|
procedure AutoCalcHRange;
|
||||||
var
|
var
|
||||||
I : Integer;
|
i: Integer;
|
||||||
TmpRange : Longint;
|
TmpRange : Longint;
|
||||||
IncludeControl : Boolean;
|
c: TControl;
|
||||||
begin
|
begin
|
||||||
TmpRange := 0;
|
TmpRange := 0;
|
||||||
For I := 0 to FControl.ControlCount - 1 do
|
for i := 0 to FControl.ControlCount - 1 do
|
||||||
With FControl.Controls[I] do
|
begin
|
||||||
if Visible then begin
|
c := FControl.Controls[I];
|
||||||
IncludeControl := (Align = alLeft) or (Align = alNone);
|
if not C.Visible then Continue;
|
||||||
If IncludeControl then
|
if (c.Align <> alLeft) and (c.Align <> alNone) then Continue;
|
||||||
TmpRange := Max(TmpRange, Left + Width);
|
|
||||||
end;
|
TmpRange := Max(TmpRange, c.Left + c.Width);
|
||||||
|
if c.Left < 0
|
||||||
|
then DebugLn('Child.Left = %d, Control.Left = %d', [c.Left, FControl.Left]);
|
||||||
|
end;
|
||||||
Range := TmpRange;
|
Range := TmpRange;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -4949,83 +4949,105 @@ function TGtkWidgetSet.GetScrollInfo(Handle: HWND; SBStyle: Integer;
|
|||||||
var
|
var
|
||||||
Adjustment: PGtkAdjustment;
|
Adjustment: PGtkAdjustment;
|
||||||
Scroll : PGTKWidget;
|
Scroll : PGTKWidget;
|
||||||
|
IsScrollWindow: Boolean;
|
||||||
begin
|
begin
|
||||||
Result := false;
|
Result := false;
|
||||||
if (Handle = 0) then exit;
|
if (Handle = 0) then exit;
|
||||||
|
|
||||||
Adjustment := nil;
|
|
||||||
Scroll := GTK_Object_Get_Data(PGTKObject(Handle), odnScrollArea);
|
Scroll := gtk_object_get_data(PGTKObject(Handle), odnScrollArea);
|
||||||
If not GtkWidgetIsA(PGtkWidget(Scroll),gtk_scrolled_window_get_type) then
|
if GtkWidgetIsA(Scroll, gtk_scrolled_window_get_type)
|
||||||
|
then begin
|
||||||
|
IsScrollWindow := True;
|
||||||
|
end
|
||||||
|
else begin
|
||||||
Scroll := PGTKWidget(Handle);
|
Scroll := PGTKWidget(Handle);
|
||||||
|
IsScrollWindow := GtkWidgetIsA(Scroll, gtk_scrolled_window_get_type);
|
||||||
|
end;
|
||||||
|
|
||||||
|
Adjustment := nil;
|
||||||
|
|
||||||
case SBStyle of
|
case SBStyle of
|
||||||
SB_HORZ:
|
SB_HORZ:
|
||||||
If GtkWidgetIsA(PGtkWidget(Scroll),gtk_scrolled_window_get_type) then
|
if IsScrollWindow
|
||||||
|
then begin
|
||||||
Adjustment := gtk_scrolled_window_get_hadjustment(
|
Adjustment := gtk_scrolled_window_get_hadjustment(
|
||||||
PGTKScrolledWindow(Scroll))
|
PGTKScrolledWindow(Scroll));
|
||||||
|
end
|
||||||
|
else if GtkWidgetIsA(PGtkWidget(Scroll),gtk_clist_get_type)
|
||||||
|
then begin
|
||||||
|
//clist
|
||||||
|
//TODO: check is this is needed for listviews
|
||||||
|
DebugLn('[SetScrollInfo] Possible obsolete get use of CList (Listview ?)');
|
||||||
|
Adjustment := gtk_clist_get_hadjustment(PgtkCList(Scroll));
|
||||||
|
end
|
||||||
|
// obsolete stuff
|
||||||
|
else if GtkWidgetIsA(PGtkWidget(Scroll),gtk_hscrollbar_get_type)
|
||||||
|
then begin
|
||||||
|
// this one shouldn't be possible, scrolbar messages are sent to the CTL
|
||||||
|
DebugLN('!!! direct SB_HORZ get call to scrollbar');
|
||||||
|
Adjustment := PgtkhScrollBar(Scroll)^.Scrollbar.Range.Adjustment;
|
||||||
|
end;
|
||||||
|
|
||||||
|
SB_VERT:
|
||||||
|
if GtkWidgetIsA(PGtkWidget(Scroll),gtk_scrolled_window_get_type)
|
||||||
|
then begin
|
||||||
|
Adjustment := gtk_scrolled_window_get_vadjustment(
|
||||||
|
PGTKScrolledWindow(Scroll));
|
||||||
|
end
|
||||||
|
else if GtkWidgetIsA(PGtkWidget(Scroll), gtk_clist_get_type)
|
||||||
|
then begin
|
||||||
|
//clist
|
||||||
|
//TODO: check is this is needed for listviews
|
||||||
|
DebugLn('[SetScrollInfo] Possible obsolete get use of CList (Listview ?)');
|
||||||
|
Adjustment := gtk_clist_get_vadjustment(PgtkCList(Scroll));
|
||||||
|
end
|
||||||
|
// obsolete stuff
|
||||||
|
else if GtkWidgetIsA(PGtkWidget(Scroll),gtk_vscrollbar_get_type)
|
||||||
|
then begin
|
||||||
|
// this one shouldn't be possible, scrolbar messages are sent to the CTL
|
||||||
|
DebugLN('!!! direct SB_HORZ get call to scrollbar');
|
||||||
|
Adjustment := PgtkvScrollBar(Scroll)^.Scrollbar.Range.Adjustment;
|
||||||
|
end;
|
||||||
|
|
||||||
|
SB_CTL:
|
||||||
|
if GtkWidgetIsA(PGtkWidget(Scroll),gtk_vscrollbar_get_type) then
|
||||||
|
Adjustment := PgtkvScrollBar(Scroll)^.Scrollbar.Range.Adjustment
|
||||||
else
|
else
|
||||||
if GtkWidgetIsA(PGtkWidget(Scroll),gtk_hscrollbar_get_type) then
|
if GtkWidgetIsA(PGtkWidget(Scroll),gtk_hscrollbar_get_type) then
|
||||||
Adjustment := PgtkhScrollBar(Scroll)^.Scrollbar.Range.Adjustment
|
Adjustment := PgtkhScrollBar(Scroll)^.Scrollbar.Range.Adjustment
|
||||||
else //clist
|
|
||||||
if GtkWidgetIsA(PGtkWidget(Scroll),gtk_clist_get_type) then
|
|
||||||
Adjustment := gtk_clist_get_hadjustment(PgtkCList(Scroll));
|
|
||||||
|
|
||||||
SB_VERT:
|
|
||||||
If GtkWidgetIsA(PGtkWidget(Scroll),gtk_scrolled_window_get_type) then
|
|
||||||
Adjustment := gtk_scrolled_window_get_vadjustment(
|
|
||||||
PGTKScrolledWindow(Scroll))
|
|
||||||
else
|
else
|
||||||
if GtkWidgetIsA(PGtkWidget(Scroll),gtk_vscrollbar_get_type) then
|
|
||||||
Adjustment := PgtkvScrollBar(Scroll)^.Scrollbar.Range.Adjustment
|
|
||||||
else //clist
|
|
||||||
if GtkWidgetIsA(PGtkWidget(Scroll), gtk_clist_get_type) then
|
|
||||||
Adjustment := gtk_clist_get_vadjustment(PgtkCList(Scroll));
|
|
||||||
|
|
||||||
SB_CTL:
|
|
||||||
if GtkWidgetIsA(PGtkWidget(Scroll), gtk_range_get_type) then
|
if GtkWidgetIsA(PGtkWidget(Scroll), gtk_range_get_type) then
|
||||||
Adjustment := gtk_range_get_adjustment(PGTKRange(Scroll));
|
Adjustment := gtk_range_get_adjustment(PGTKRange(Scroll));
|
||||||
|
SB_BOTH:
|
||||||
|
DebugLn('[SetScrollInfo] Got SB_BOTH ???');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if Adjustment<>nil then begin
|
if Adjustment = nil then Exit;
|
||||||
with ScrollInfo, Adjustment^ do begin
|
|
||||||
// POS
|
// POS
|
||||||
if (fMask and SIF_POS) <> 0 then
|
if (ScrollInfo.fMask and SIF_POS) <> 0
|
||||||
nPos := RoundToInt(Value);
|
then begin
|
||||||
// RANGE
|
ScrollInfo.nPos := Round(Adjustment^.Value);
|
||||||
if (fMask and SIF_RANGE) <> 0
|
|
||||||
then begin
|
|
||||||
nMin:= RoundToInt(Lower);
|
|
||||||
nMax:= RoundToInt(Upper);
|
|
||||||
end;
|
|
||||||
// PAGE
|
|
||||||
if (fMask and SIF_PAGE) <> 0 then
|
|
||||||
nPage := RoundToCardinal(Page_Size);
|
|
||||||
// TRACKPOS
|
|
||||||
if (fMask and SIF_TRACKPOS)<>0 then
|
|
||||||
nTrackPos := RoundToInt(Value);
|
|
||||||
end;
|
|
||||||
Result := true;
|
|
||||||
end else begin
|
|
||||||
with ScrollInfo, Adjustment^ do begin
|
|
||||||
// POS
|
|
||||||
if (fMask and SIF_POS) <> 0 then
|
|
||||||
nPos := 0;
|
|
||||||
// RANGE
|
|
||||||
if (fMask and SIF_RANGE) <> 0
|
|
||||||
then begin
|
|
||||||
nMin:= 0;
|
|
||||||
nMax:= 0;
|
|
||||||
end;
|
|
||||||
// PAGE
|
|
||||||
if (fMask and SIF_PAGE) <> 0 then
|
|
||||||
nPage := 0;
|
|
||||||
// TRACKPOS
|
|
||||||
if (fMask and SIF_TRACKPOS)<>0 then
|
|
||||||
nTrackPos := 0;
|
|
||||||
end;
|
|
||||||
Result := false;
|
|
||||||
end;
|
end;
|
||||||
|
// RANGE
|
||||||
|
if (ScrollInfo.fMask and SIF_RANGE) <> 0
|
||||||
|
then begin
|
||||||
|
ScrollInfo.nMin:= Round(Adjustment^.Lower);
|
||||||
|
ScrollInfo.nMax:= Round(Adjustment^.Upper);
|
||||||
|
end;
|
||||||
|
// PAGE
|
||||||
|
if (ScrollInfo.fMask and SIF_PAGE) <> 0
|
||||||
|
then begin
|
||||||
|
ScrollInfo.nPage := Round(Adjustment^.Page_Size);
|
||||||
|
end;
|
||||||
|
// TRACKPOS
|
||||||
|
if (ScrollInfo.fMask and SIF_TRACKPOS) <> 0
|
||||||
|
then begin
|
||||||
|
ScrollInfo.nTrackPos := Round(Adjustment^.Value);
|
||||||
|
end;
|
||||||
|
|
||||||
|
Result := true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -8216,29 +8238,37 @@ begin
|
|||||||
then begin
|
then begin
|
||||||
Adjustment := gtk_scrolled_window_get_hadjustment(PGTKScrolledWindow(Scroll));
|
Adjustment := gtk_scrolled_window_get_hadjustment(PGTKScrolledWindow(Scroll));
|
||||||
if Layout <> nil
|
if Layout <> nil
|
||||||
then gtk_layout_set_size(Layout, ScrollInfo.nMax - ScrollInfo.nMin, Layout^.height);
|
then begin
|
||||||
|
if (ScrollInfo.fMask and SIF_RANGE) <> 0
|
||||||
|
then gtk_layout_set_size(Layout, ScrollInfo.nMax - ScrollInfo.nMin, Layout^.height);
|
||||||
|
Result := Layout^.xoffset;
|
||||||
|
end;
|
||||||
end
|
end
|
||||||
// obsolete stuff
|
// obsolete stuff
|
||||||
else if GtkWidgetIsA(PGtkWidget(Scroll),gtk_hscrollbar_get_type)
|
else if GtkWidgetIsA(PGtkWidget(Scroll),gtk_hscrollbar_get_type)
|
||||||
then begin
|
then begin
|
||||||
// this one shouldn't be possible, scrolbar messages are sent to the CTL
|
// this one shouldn't be possible, scrolbar messages are sent to the CTL
|
||||||
DebugLN('!!! direct SB_HORZ call to scrollbar');
|
DebugLN('!!! direct SB_HORZ set call to scrollbar');
|
||||||
Adjustment := PgtkhScrollBar(Scroll)^.Scrollbar.Range.Adjustment
|
Adjustment := PgtkhScrollBar(Scroll)^.Scrollbar.Range.Adjustment
|
||||||
end
|
end
|
||||||
else
|
else if GtkWidgetIsA(PGtkWidget(Scroll),gtk_clist_get_type)
|
||||||
if GtkWidgetIsA(PGtkWidget(Scroll),gtk_clist_get_type)
|
|
||||||
then begin
|
then begin
|
||||||
//clist
|
//clist
|
||||||
DebugLn('[SetScrollInfo] Obsolete use of CList ???');
|
//TODO: check is this is needed for listviews
|
||||||
|
DebugLn('[SetScrollInfo] Possible obsolete set use of CList (Listview ?)');
|
||||||
Adjustment := gtk_clist_get_hadjustment(PgtkCList(Scroll));
|
Adjustment := gtk_clist_get_hadjustment(PgtkCList(Scroll));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
SB_VERT:
|
SB_VERT:
|
||||||
If IsScrollWindow
|
if IsScrollWindow
|
||||||
then begin
|
then begin
|
||||||
Adjustment := gtk_scrolled_window_get_vadjustment(PGTKScrolledWindow(Scroll));
|
Adjustment := gtk_scrolled_window_get_vadjustment(PGTKScrolledWindow(Scroll));
|
||||||
if Layout <> nil
|
if Layout <> nil
|
||||||
then gtk_layout_set_size(Layout, Layout^.Width, ScrollInfo.nMax - ScrollInfo.nMin);
|
then begin
|
||||||
|
if (ScrollInfo.fMask and SIF_RANGE) <> 0
|
||||||
|
then gtk_layout_set_size(Layout, Layout^.Width, ScrollInfo.nMax - ScrollInfo.nMin);
|
||||||
|
Result := Layout^.yoffset;
|
||||||
|
end;
|
||||||
end
|
end
|
||||||
// obsolete stuff
|
// obsolete stuff
|
||||||
else if GtkWidgetIsA(PGtkWidget(Scroll),gtk_vscrollbar_get_type)
|
else if GtkWidgetIsA(PGtkWidget(Scroll),gtk_vscrollbar_get_type)
|
||||||
@ -8249,8 +8279,8 @@ begin
|
|||||||
end
|
end
|
||||||
else if GtkWidgetIsA(PGtkWidget(Scroll), gtk_clist_get_type)
|
else if GtkWidgetIsA(PGtkWidget(Scroll), gtk_clist_get_type)
|
||||||
then begin
|
then begin
|
||||||
//clist
|
//TODO: check is this is needed for listviews
|
||||||
DebugLn('[SetScrollInfo] Obsolete use of CList ???');
|
DebugLn('[SetScrollInfo] Possible obsolete set use of CList (Listview ?)');
|
||||||
Adjustment := gtk_clist_get_vadjustment(PgtkCList(Scroll));
|
Adjustment := gtk_clist_get_vadjustment(PgtkCList(Scroll));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -8266,64 +8296,65 @@ begin
|
|||||||
SB_BOTH:
|
SB_BOTH:
|
||||||
DebugLn('[SetScrollInfo] Got SB_BOTH ???');
|
DebugLn('[SetScrollInfo] Got SB_BOTH ???');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
if Adjustment = nil then exit;
|
if Adjustment = nil then exit;
|
||||||
|
|
||||||
with ScrollInfo, Adjustment^ do begin
|
Result := Round(Adjustment^.Value);
|
||||||
Result := Round(Value);
|
|
||||||
|
|
||||||
if (fMask and SIF_POS) <> 0
|
if (ScrollInfo.fMask and SIF_POS) <> 0
|
||||||
then Value := nPos;
|
then begin
|
||||||
if (fMask and SIF_RANGE) <> 0
|
Adjustment^.Value := ScrollInfo.nPos;
|
||||||
|
end;
|
||||||
|
if (ScrollInfo.fMask and SIF_RANGE) <> 0
|
||||||
|
then begin
|
||||||
|
Adjustment^.Lower := ScrollInfo.nMin;
|
||||||
|
Adjustment^.Upper := ScrollInfo.nMax;
|
||||||
|
end;
|
||||||
|
if (ScrollInfo.fMask and SIF_PAGE) <> 0
|
||||||
|
then begin
|
||||||
|
Adjustment^.Page_Size := ScrollInfo.nPage;
|
||||||
|
Adjustment^.Page_Increment := ScrollInfo.nPage;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{DebugLn('');
|
||||||
|
DebugLn('[TGtkWidgetSet.SetScrollInfo] Result=',Result,
|
||||||
|
' Lower=',RoundToInt(Lower),
|
||||||
|
' Upper=',RoundToInt(Upper),
|
||||||
|
' Page_Size=',RoundToInt(Page_Size),
|
||||||
|
' Page_Increment=',RoundToInt(Page_Increment),
|
||||||
|
' bRedraw=',bRedraw,
|
||||||
|
' Handle=',DbgS(Handle));}
|
||||||
|
|
||||||
|
// do we have to set this always ?
|
||||||
|
// ??? what is this for code ????
|
||||||
|
// why not change adjustment if we don't do a redraw ???
|
||||||
|
if bRedraw then
|
||||||
|
begin
|
||||||
|
if IsScrollWindow
|
||||||
then begin
|
then begin
|
||||||
Lower := nMin;
|
case SBStyle of
|
||||||
Upper := nMax;
|
SB_HORZ: gtk_object_set(PGTKObject(Scroll),'hscrollbar_policy',[POLICY[bRedraw],nil]);
|
||||||
end;
|
SB_VERT: gtk_object_set(PGTKObject(Scroll),'vscrollbar_policy',[POLICY[bRedraw],nil]);
|
||||||
if (fMask and SIF_PAGE) <> 0
|
|
||||||
then begin
|
|
||||||
Page_Size := nPage;
|
|
||||||
Page_Increment := nPage;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{DebugLn('');
|
|
||||||
DebugLn('[TGtkWidgetSet.SetScrollInfo] Result=',Result,
|
|
||||||
' Lower=',RoundToInt(Lower),
|
|
||||||
' Upper=',RoundToInt(Upper),
|
|
||||||
' Page_Size=',RoundToInt(Page_Size),
|
|
||||||
' Page_Increment=',RoundToInt(Page_Increment),
|
|
||||||
' bRedraw=',bRedraw,
|
|
||||||
' Handle=',DbgS(Handle));}
|
|
||||||
|
|
||||||
// do we have to set this always ?
|
|
||||||
// ??? what is this for code ????
|
|
||||||
// why not change adjustment if we don't do a redraw ???
|
|
||||||
if bRedraw then
|
|
||||||
begin
|
|
||||||
if IsScrollWindow
|
|
||||||
then begin
|
|
||||||
case SBStyle of
|
|
||||||
SB_HORZ: gtk_object_set(PGTKObject(Scroll),'hscrollbar_policy',[POLICY[bRedraw],nil]);
|
|
||||||
SB_VERT: gtk_object_set(PGTKObject(Scroll),'vscrollbar_policy',[POLICY[bRedraw],nil]);
|
|
||||||
end;
|
|
||||||
end
|
|
||||||
else begin
|
|
||||||
if (SBSTYLE = SB_CTL)
|
|
||||||
and GtkWidgetIsA(PGtkWidget(Scroll),gtk_widget_get_type) then
|
|
||||||
gtk_widget_show(PGTKWidget(Scroll))
|
|
||||||
else
|
|
||||||
gtk_widget_hide(PGTKWidget(Scroll))
|
|
||||||
end;
|
end;
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
if (SBSTYLE = SB_CTL)
|
||||||
|
and GtkWidgetIsA(PGtkWidget(Scroll),gtk_widget_get_type) then
|
||||||
|
gtk_widget_show(PGTKWidget(Scroll))
|
||||||
|
else
|
||||||
|
gtk_widget_hide(PGTKWidget(Scroll))
|
||||||
|
end;
|
||||||
|
|
||||||
(*
|
(*
|
||||||
DebugLn('TGtkWidgetSet.SetScrollInfo:' +
|
DebugLn('TGtkWidgetSet.SetScrollInfo:' +
|
||||||
' lower=%d/%d upper=%d/%d value=%d/%d' +
|
' lower=%d/%d upper=%d/%d value=%d/%d' +
|
||||||
' step_increment=%d/1 page_increment=%d/%d page_size=%d/%d', [
|
' step_increment=%d/1 page_increment=%d/%d page_size=%d/%d', [
|
||||||
Round(lower),nMin, Round(upper),nMax, Round(value),nPos,
|
Round(lower),nMin, Round(upper),nMax, Round(value),nPos,
|
||||||
Round(step_increment), Round(page_increment),nPage, Round(page_size),nPage]
|
Round(step_increment), Round(page_increment),nPage, Round(page_size),nPage]
|
||||||
);
|
);
|
||||||
*)
|
*)
|
||||||
gtk_adjustment_changed(Adjustment);
|
gtk_adjustment_changed(Adjustment);
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user