anchor.diff:  end;
   
   
  +{ TKMScrollPanel }
  +constructor TKMScrollPanel.Create(aParent: TKMPanel; aLeft, aTop, aWidth, aHeight: Integer; aScrollAxisSet: TKMScrollAxisSet;
  +                                  aStyle: TKMButtonStyle; aScrollStyle: TKMScrollStyle);
  +begin
  +  inherited Create(aParent, aLeft, aTop, aWidth - 20*Byte(sa_Vertical in aScrollAxisSet), aHeight - 20*Byte(sa_Horizontal in aScrollAxisSet));
  +
  +  fScrollAxisSet := aScrollAxisSet;
  +
  +  fScrollBarH := TKMScrollBar.Create(aParent, aLeft, aTop + aHeight - 20, aWidth, 20, sa_Horizontal, aStyle, aScrollStyle);
  +  fScrollBarH.Hide;
  +  fScrollBarH.OnChange := ScrollChanged;
  +
  +  fScrollBarV := TKMScrollBar.Create(aParent, aLeft + aWidth - 20, aTop, 20, aHeight, sa_Vertical, aStyle, aScrollStyle);
  +  fScrollBarV.Hide;
  +  fScrollBarV.OnChange := ScrollChanged;
  +
  +  fClipRect := KMRect(Left, Top, Left + Width, Top + Height);
  +end;
  +
  +
  +function TKMScrollPanel.AddChild(aChild: TKMControl): Integer;
  +begin
  +  inherited AddChild(aChild);
  +
  +  aChild.fOnSizeSet := UpdateScrolls;
  +  aChild.fOnPositionSet := UpdateScrolls;
  +  aChild.fOnChangeVisibility := UpdateScrolls;
  +  aChild.fOnChangeEnableStatus := UpdateScrolls;
  +end;
  +
  +
  +procedure TKMScrollPanel.ScrollChanged(Sender: TObject);
  +var
  +  OldValue: Integer;
  +begin
  +  if Sender = fScrollBarH then
  +  begin
  +    OldValue := Left;
  +    Left := fClipRect.Left - fScrollBarH.Position;
  +    //To compensate changes in SetLeft
  +    Inc(fClipRect.Left, OldValue - Left);
  +    Inc(fClipRect.Right, OldValue - Left);
  +  end else
  +  if Sender = fScrollBarV then
  +  begin
  +    OldValue := Top;
  +    Top := fClipRect.Top - fScrollBarV.Position;
  +    //To compensate changes in SetTop
  +    Inc(fClipRect.Top, OldValue - Top);
  +    Inc(fClipRect.Bottom, OldValue - Top);
  +  end;
  +end;
  +
  +
  +procedure TKMScrollPanel.UpdateScrolls(Sender: TObject; aValue: Boolean);
  +begin
  +  if (Sender <> fScrollBarH) and (Sender <> fScrollBarV) then
  +    UpdateScrolls(nil);
  +end;
  +
  +
  +procedure TKMScrollPanel.UpdateScrolls(Sender: TObject);
  +var
  +  ChildsRect: TKMRect;
  +  NewPos: Integer;
  +begin
  +  ChildsRect := GetChildsRect;
  +  fScrollBarH.Hide;
  +  fScrollBarV.Hide;
  +
  +  if (sa_Horizontal in fScrollAxisSet) then
  +  begin
  +    if KMRectWidth(ChildsRect) > KMRectWidth(fClipRect) then
  +    begin
  +      fScrollBarH.MaxValue := KMRectWidth(ChildsRect) - KMRectWidth(fClipRect);
  +      NewPos := fClipRect.Left - Left;
  +      fScrollBarH.Position := NewPos;
  +
  +      if NewPos > fScrollBarH.MaxValue then
  +        fLeft := Left + NewPos - fScrollBarH.MaxValue; //Slightly move panel to the top, when resize near maxvalue position
  +      fScrollBarH.DoSetVisible;
  +    end else begin
  +      fScrollBarH.Position := 0;
  +      if Left <> fClipRect.Left then
  +        fLeft := fClipRect.Left; //Set directrly to avoid SetLeft call
  +    end;
  +  end;
  +
  +  if (sa_Vertical in fScrollAxisSet) then
  +  begin
  +    if KMRectHeight(ChildsRect) > KMRectHeight(fClipRect) then
  +    begin
  +      fScrollBarV.MaxValue := KMRectHeight(ChildsRect) - KMRectHeight(fClipRect);
  +      NewPos := fClipRect.Top - Top;
  +      fScrollBarV.Position := NewPos;
  +
  +      if NewPos > fScrollBarV.MaxValue then
  +        fTop := Top + NewPos - fScrollBarV.MaxValue; //Slightly move panel to the top, when resize near maxvalue position
  +      fScrollBarV.DoSetVisible;
  +    end else begin
  +      fScrollBarV.Position := 0;
  +      if Top <> fClipRect.Top then
  +        fTop := fClipRect.Top; //Set directrly to avoid SetTop call
  +    end;
  +  end;
  +
  +  fScrollBarH.Width := Width;
  +  fScrollBarV.Height := Height;
  +end;
  +
  +
  +procedure TKMScrollPanel.SetLeft(aValue: Integer);
  +var
  +  OldValue: Integer;
  +begin
  +  OldValue := Left;
  +  inherited;
  +
  +  Inc(fClipRect.Left, Left - OldValue);
  +  Inc(fClipRect.Right, Left - OldValue);
  +
  +  UpdateScrolls(nil);
  +end;
  +
  +
  +procedure TKMScrollPanel.SetTop(aValue: Integer);
  +var
  +  OldValue: Integer;
  +begin
  +  OldValue := Top;
  +  inherited;
  +
  +  Inc(fClipRect.Top, Top - OldValue);
  +  Inc(fClipRect.Bottom, Top - OldValue);
  +
  +  UpdateScrolls(nil);
  +end;
  +
  +
  +procedure TKMScrollPanel.SetWidth(aValue: Integer);
  +var
  +  OldValue: Integer;
  +begin
  +  OldValue := Width;
  +  inherited;
  +
  +  Inc(fClipRect.Right, Width - OldValue);
  +
  +  fScrollBarV.Left := fClipRect.Left + Width;
  +
  +  UpdateScrolls(nil);
  +end;
  +
  +
  +procedure TKMScrollPanel.SetHeight(aValue: Integer);
  +var
  +  OldValue: Integer;
  +begin
  +  OldValue := Height;
  +  inherited;
  +
  +  Inc(fClipRect.Bottom, Height - OldValue);
  +
  +  fScrollBarH.Top := fClipRect.Top + Height;
  +
  +  UpdateScrolls(nil);
  +end;
  +
  +
  +function TKMScrollPanel.GetChildsRect: TKMRect;
  +var
  +  I: Integer;
  +begin
  +  Result.Left := 0; //Its fine to have 0 here
  +  Result.Top := 0;
  +  Result.Right := Width;
  +  Result.Bottom := Height;
  +  for I := 0 to ChildCount - 1 do
  +  begin
  +    if not Childs[I].IsPainted then
  +      Continue;
  +
  +    if Childs[I].Left < Result.Left then
  +      Result.Left := Childs[I].Left;
  +
  +    if Childs[I].Top < Result.Top then
  +      Result.Top := Childs[I].Top;
  +
  +    if Childs[I].Right > Result.Right then
  +      Result.Right := Childs[I].Right;
  +
  +    if Childs[I].Bottom > Result.Bottom then
  +      Result.Bottom := Childs[I].Bottom;
  +  end;
  +end;
  +
  +
  +function TKMScrollPanel.AllowScrollV: Boolean;
  +begin
  +  Result := sa_Vertical in fScrollAxisSet;
  +end;
  +
  +
  +function TKMScrollPanel.AllowScrollH: Boolean;
  +begin
  +  Result := sa_Horizontal in fScrollAxisSet;
  +end;
  +
  +
  +procedure TKMScrollPanel.Paint;
  +begin
  +  TKMRenderUI.SetupClipX(Parent.AbsLeft + fClipRect.Left, Parent.AbsLeft + fClipRect.Right + 20*Byte(AllowScrollV and not fScrollBarV.Visible));
  +  TKMRenderUI.SetupClipY(Parent.AbsTop + fClipRect.Top, Parent.AbsTop + fClipRect.Bottom + 20*Byte(AllowScrollH and not fScrollBarH.Visible));
  +
  +  inherited Paint;
  +
  +  TKMRenderUI.ReleaseClipY;
  +  TKMRenderUI.ReleaseClipX;
  +end;
  +
  +
   { TKMMemo }
   constructor TKMMemo.Create(aParent: TKMPanel; aLeft, aTop, aWidth, aHeight: Integer; aFont: TKMFont; aStyle: TKMButtonStyle; aSelectable: Boolean = True);
   begin
  
positive.code:   Highlight := False;
    HighlightOnMouseOver := False;
    HighlightCoef := 0.4;
  end;
  
  
  
negative.code: procedure TKMControl.SetLeft(aValue: Integer);
  begin
    fLeft := aValue;
  
    if Assigned(fOnPositionSet) then
      fOnPositionSet(Self);
  end;
  
  procedure TKMControl.SetTop(aValue: Integer);
  begin
    fTop := aValue;
  
    if Assigned(fOnPositionSet) then
      fOnPositionSet(Self);
  end;
  
  function TKMControl.GetHeight: Integer;
  