TMSFNCHTMLText with Round Corners

First off, this control has been great for me as I have to render at run time a set of controls in a TVertScrollBox and having the ability to AutoSize with WordWrap has been great.


So here is my issue.

More modern user interfaces seem to make use of Round Corners instead of square, much like the TRectangle control has support for round corners.  But the TRectangle control doesn't clip children at the corner.

It would be great if the TMSFNCHTMLText  and any other control for which it would be appropriate could be updated to have round corners like TRectangle.

If it exists now, I haven't yet figured out how to use it.  

I'm doing Android and iOS development.


Unfortunately round clipping of children is not possible, but you can draw your own background when inheriting from the control and overriding the Drawbackground method. Below is a full sample code snippet on how to apply this to TTMSFNCHTMLText:




unit Unit30;


interface


uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
  FMX.TMSFNCTypes, FMX.TMSFNCUtils, FMX.TMSFNCGraphics, FMX.TMSFNCGraphicsTypes,
  FMX.TMSFNCCustomControl, FMX.TMSFNCHTMLText;


type
  TTMSFNCHTMLTextEx = class(TTMSFNCHTMLText)
  protected
    procedure DrawBackground(AGraphics: TTMSFNCGraphics; {%H-}ARect: TRectF); override;
  end;


  TForm30 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;


var
  Form30: TForm30;


implementation


{$R *.fmx}


procedure TForm30.FormCreate(Sender: TObject);
var
  h: TTMSFNCHTMLTextEx;
begin
  h := TTMSFNCHTMLTextEx.Create(Self);
  h.Parent := Self;
  h.Left := 100;
  h.Top := 100;
  h.Text := 'hello';
  h.EnableBackground;
  h.Stroke.Color := gcGray;
end;


{ TTMSFNCHTMLTextEx }


procedure TTMSFNCHTMLTextEx.DrawBackground(AGraphics: TTMSFNCGraphics;
  ARect: TRectF);
begin
  AGraphics.Fill.Assign(Fill);
  AGraphics.Fill.Color := Color;
  AGraphics.Stroke.Assign(Stroke);
  AGraphics.DrawRoundRectangle(ARect);
end;


end.