[Lazarus] TEditButton alignment

Mattias Gaertner nc-gaertnma at netcologne.de
Tue Mar 19 08:46:03 CET 2013


On Tue, 19 Mar 2013 03:22:51 -0300
Flávio Etrusco <flavio.etrusco at gmail.com> wrote:

Nice idea. This is the important part:

+  { TEditButtonSpacing }
+
+  TEditButtonSpacing = class(TControlBorderSpacing)
+  public
+    constructor Create(OwnerControl: TCustomEditButton);
+    procedure GetSpaceAround(out SpaceAround: TRect); override;
+    function GetSideSpace(Kind: TAnchorKind): Integer; override;
+  end;
+
+function
  TCustomEditButton.CreateControlBorderSpacing:TControlBorderSpacing; 
+begin
+  Result := TEditButtonSpacing.Create(Self);
+end;
+
+{ TEditButtonSpacing }
+
+constructor TEditButtonSpacing.Create(OwnerControl: TCustomEditButton);
+begin
+  inherited Create(OwnerControl);
+end;
+
+procedure TEditButtonSpacing.GetSpaceAround(out SpaceAround: TRect);
+begin
+  inherited GetSpaceAround(SpaceAround);
+  if BiDiMode = bdLeftToRight then
+    Inc(SpaceAround.Right, TCustomEditButton(Control).ButtonWidth)
+  else
+    Inc(SpaceAround.Left, TCustomEditButton(Control).ButtonWidth)
+end;
+
+function TEditButtonSpacing.GetSideSpace(Kind: TAnchorKind): Integer;
+begin
+  Result := inherited GetSideSpace(Kind);
+  if Kind = akRight and then
+  begin
+    if BiDiMode = bdLeftToRight then
+      Inc(Result, TCustomEditButton(Control).ButtonWidth);
+  end
+  else if Kind = akLeft and BiDiMode <> bdLeftToRight then
+    Inc(Result, TCustomEditButton(Control).ButtonWidth);
+end;


Mattias




More information about the Lazarus mailing list