<commit_before>unit proc_scrollbars;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, Controls, Graphics, StdCtrls, ComCtrls, Forms,
  ATScrollBar, ATListbox;

type
  { TTreeViewMy }

  TTreeViewMy = class(TTreeView)
  private
    FScroll: TATScroll;
    procedure ScrollChange(Sender: TObject);
    procedure UpdScroll;
  protected
    procedure DoSelectionChanged; override;
    procedure Resize; override;
    procedure Changed; override;
    procedure Collapse(Node: TTreeNode); override;
    procedure Expand(Node: TTreeNode); override;
  public
    constructor Create(AOwner: TComponent); override;
  end;

type
  { TATListboxMy }

  TATListboxMy = class(TATListbox)
  private
    FScroll: TATScroll;
    procedure ScrollChange(Sender: TObject);
    procedure UpdScroll;
  protected
    procedure Resize; override;
    procedure DoScrolled; override;
  public
    constructor Create(AOwner: TComponent); override;
    function ClientWidth: integer;
  end;

const
  cATScrollWidth = 16;
  cATScrollBorderSize = 0;


implementation

{ TATListboxMy }

procedure TATListboxMy.ScrollChange(Sender: TObject);
begin
  ItemTop:= FScroll.Position;
end;

procedure TATListboxMy.UpdScroll;
begin
  if not Assigned(FScroll) then exit;
  FScroll.Min:= 0;
  FScroll.Max:= ItemCount;
  FScroll.PageSize:= VisibleItems;
  FScroll.Position:= ItemTop;
end;

procedure TATListboxMy.Resize;
begin
  inherited;
  UpdScroll;
end;

procedure TATListboxMy.DoScrolled;
begin
  inherited;
  UpdScroll;
end;

constructor TATListboxMy.Create(AOwner: TComponent);
begin
  inherited;
  ShowScrollbar:= false;
  FScroll:= TATScroll.Create(Self);
  FScroll.Parent:= Self;
  FScroll.Kind:= sbVertical;
  FScroll.Align:= alRight;
  FScroll.Width:= cATScrollWidth;
  FScroll.IndentBorder:= cATScrollBorderSize;
  FScroll.OnChange:= @ScrollChange;
  UpdScroll;
end;

function TATListboxMy.ClientWidth: integer;
begin
  Result:= inherited ClientWidth - FScroll.Width;
end;

{ TTreeViewMy }

constructor TTreeViewMy.Create(AOwner: TComponent);
begin
  inherited;
  ScrollBars:= ssNone;
  FScroll:= TATScroll.Create(Self);
  FScroll.Parent:= Self;
  FScroll.Kind:= sbVertical;
  FScroll.Align:= alRight;
  FScroll.Width:= cATScrollWidth;
  FScroll.IndentBorder:= cATScrollBorderSize;
  FScroll.OnChange:= @ScrollChange;
  UpdScroll;
end;

procedure TTreeViewMy.ScrollChange(Sender: TObject);<commit_msg>rename id<commit_after>unit proc_scrollbars;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, Controls, Graphics, StdCtrls, ComCtrls, Forms,
  ATScrollBar, ATListbox;

type
  { TTreeViewMy }

  TTreeViewMy = class(TTreeView)
  private
    FScroll: TATScroll;
    procedure ScrollChange(Sender: TObject);
    procedure UpdScroll;
  protected
    procedure DoSelectionChanged; override;
    procedure Resize; override;
    procedure Changed; override;
    procedure Collapse(Node: TTreeNode); override;
    procedure Expand(Node: TTreeNode); override;
  public
    constructor Create(AOwner: TComponent); override;
  end;

type
  { TATListboxMy }

  TATListboxMy = class(TATListbox)
  private
    FScroll: TATScroll;
    procedure ScrollChange(Sender: TObject);
    procedure UpdScroll;
  protected
    procedure Resize; override;
    procedure DoScrolled; override;
  public
    constructor Create(AOwner: TComponent); override;
    function ClientWidth: integer;
  end;

const
  UiOps_ScrollbarWidth: integer = 14;
  UiOps_ScrollbarBorderSize: integer = 0;


implementation

{ TATListboxMy }

procedure TATListboxMy.ScrollChange(Sender: TObject);
begin
  ItemTop:= FScroll.Position;
end;

procedure TATListboxMy.UpdScroll;
begin
  if not Assigned(FScroll) then exit;
  FScroll.Min:= 0;
  FScroll.Max:= ItemCount;
  FScroll.PageSize:= VisibleItems;
  FScroll.Position:= ItemTop;
end;

procedure TATListboxMy.Resize;
begin
  inherited;
  UpdScroll;
end;

procedure TATListboxMy.DoScrolled;
begin
  inherited;
  UpdScroll;
end;

constructor TATListboxMy.Create(AOwner: TComponent);
begin
  inherited;
  ShowScrollbar:= false;
  FScroll:= TATScroll.Create(Self);
  FScroll.Parent:= Self;
  FScroll.Kind:= sbVertical;
  FScroll.Align:= alRight;
  FScroll.Width:= UiOps_ScrollbarWidth;
  FScroll.IndentBorder:= UiOps_ScrollbarBorderSize;
  FScroll.OnChange:= @ScrollChange;
  UpdScroll;
end;

function TATListboxMy.ClientWidth: integer;
begin
  Result:= inherited ClientWidth - FScroll.Width;
end;

{ TTreeViewMy }

constructor TTreeViewMy.Create(AOwner: TComponent);
begin
  inherited;
  ScrollBars:= ssNone;
  FScroll:= TATScroll.Create(Self);
  FScroll.Parent:= Self;
  FScroll.Kind:= sbVertical;
  FScroll.Align:= alRight;
  FScroll.Width:= UiOps_ScrollbarWidth;
  FScroll.IndentBorder:= UiOps_ScrollbarBorderSize;
  FScroll.OnChange:= @ScrollChange;
  UpdScroll;
end;

procedure TTreeViewMy.ScrollChange(Sender: TObject);
{'fraction_non_alphanumeric': 0.09438669438669439, 'fraction_numerical': 0.0016632016632016633, 'mean_word_length': 4.983830845771144, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2323006', 'n_tokens_mistral': 1692, 'n_tokens_neox': 1612, 'n_words': 364}