diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..8231e5a --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Renato Trevisan + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Samples/Samples.Principal.pas b/Samples/Samples.Principal.pas index 12bde35..c4ff7ae 100644 --- a/Samples/Samples.Principal.pas +++ b/Samples/Samples.Principal.pas @@ -3,11 +3,22 @@ interface uses - System.SysUtils, System.Types, System.UITypes, System.Classes, - System.Variants, - FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, + FMX.Controls, FMX.Controls.Presentation, - FMX.StdCtrls, FMX.Memo.Types, FMX.ScrollBox, FMX.Memo; + FMX.Dialogs, + FMX.Forms, + FMX.Graphics, + FMX.Memo, + FMX.Memo.Types, + FMX.ScrollBox, + FMX.StdCtrls, + FMX.Types, + + System.Classes, + System.SysUtils, + System.Types, + System.UITypes, + System.Variants; type TForm1 = class(TForm) @@ -34,11 +45,11 @@ TForm1 = class(TForm) implementation -{$R *.fmx} - uses HDMessageDlg, HDMessageDlg.Interfaces; +{$R *.fmx} + procedure TForm1.BtnAttentionClick(Sender: TObject); var diff --git a/src/FMX/HDMessageDlg.View.FMX.fmx b/src/FMX/HDMessageDlg.View.FMX.fmx index 9762055..997794f 100644 --- a/src/FMX/HDMessageDlg.View.FMX.fmx +++ b/src/FMX/HDMessageDlg.View.FMX.fmx @@ -34,7 +34,7 @@ object HDMessageDlgFMX: THDMessageDlgFMX Size.Height = 40.000000000000000000 Size.PlatformDefault = False TabOrder = 0 - object ReclblTitle: TRectangle + object RecLblTitle: TRectangle Align = Client Fill.Color = xFF086FFB Size.Width = 580.000000000000000000 diff --git a/src/FMX/HDMessageDlg.View.FMX.pas b/src/FMX/HDMessageDlg.View.FMX.pas index d2b138b..619ac8c 100644 --- a/src/FMX/HDMessageDlg.View.FMX.pas +++ b/src/FMX/HDMessageDlg.View.FMX.pas @@ -14,14 +14,11 @@ interface FMX.StdCtrls, FMX.Types, - HDMessageDlg.Consts, HDMessageDlg.Interfaces, System.Classes, System.SysUtils, - System.Types, System.UITypes, - System.Variants, Winapi.Windows; @@ -30,7 +27,7 @@ THDMessageDlgFMX = class(TForm) RecBackGround : TRectangle; LayoutContainer : TLayout; LayoutTop : TLayout; - ReclblTitle : TRectangle; + RecLblTitle: TRectangle; lbl_Title : TLabel; LayoutContainerMessage: TLayout; LayoutIMG : TLayout; @@ -56,12 +53,14 @@ THDMessageDlgFMX = class(TForm) procedure btnYesClick(Sender: TObject); procedure FormCreate(Sender: TObject); private - FMsgTitle : string; - FMsgQuestion: string; - FMsgBody : string; - FMsgType : TType; - FMsgIcon : string; - FColorSvgIcon: TAlphaColor; + FMsgTitle : string; + FMsgQuestion : string; + FMsgBody : string; + FMsgType : TType; + FMsgIcon : string; + FColorSvgIcon : TAlphaColor; + FMsgResponse : Boolean; + FColorBackuground : TAlphaColor; procedure SetMsgIcon(const Value: string); procedure SetMsgBody(const Value: string); procedure SetMsgQuestion(const Value: string); @@ -72,18 +71,22 @@ THDMessageDlgFMX = class(TForm) procedure SetNo; procedure SetYes; public - MsgResponse : Boolean; published - property MsgTitle : string read FMsgTitle write SetMsgTitle; - property MsgQuestion : string read FMsgQuestion write SetMsgQuestion; - property MsgBody : string read FMsgBody write SetMsgBody; - property MsgIcon : string read FMsgIcon write SetMsgIcon; - property MsgType : TType read FMsgType write SetMsgType; - property ColorSvgIcon: TAlphaColor read FColorSvgIcon write FColorSvgIcon; + property MsgTitle : string read FMsgTitle write SetMsgTitle; + property MsgQuestion : string read FMsgQuestion write SetMsgQuestion; + property MsgBody : string read FMsgBody write SetMsgBody; + property MsgIcon : string read FMsgIcon write SetMsgIcon; + property MsgResponse : Boolean read FMsgResponse write FMsgResponse; + property MsgType : TType read FMsgType write SetMsgType; + property ColorSvgIcon : TAlphaColor read FColorSvgIcon write FColorSvgIcon; + property ColorBackuground : TAlphaColor read FColorBackuground write FColorBackuground; end; implementation +uses + HDMessageDlg.Consts; + {$R *.fmx} procedure THDMessageDlgFMX.btnNoClick(Sender: TObject); @@ -99,8 +102,6 @@ procedure THDMessageDlgFMX.btnYesClick(Sender: TObject); procedure THDMessageDlgFMX.FormCreate(Sender: TObject); begin // Set Color - ReclblTitle.Fill.Color := TAlphaColor(FMXColorTop); - RecBackGround.Fill.Color := TAlphaColor(FMXColorBackuground); BackbtnNo.Fill.Color := TAlphaColor(FMXColorButtonNo); BackbtnYes.Fill.Color := TAlphaColor(FMXColorButtonYes); lbl_Title.FontColor := TAlphaColor(FMXLabelTitle); @@ -114,30 +115,31 @@ procedure THDMessageDlgFMX.FormKeyDown(Sender: TObject; var Key: Word; var KeyChar: Char; Shift: TShiftState); begin if LayoutYes.Visible then - if key = VK_RETURN then + if Key = VK_RETURN then SetYes; if LayoutNo.Visible then - if key = VK_ESCAPE then + if Key = VK_ESCAPE then SetNo; end; procedure THDMessageDlgFMX.FormShow(Sender: TObject); begin - MsgResponse := False; - btnNo.Text := TextButtonNo; - lbl_Title.Text := FMsgTitle; - lbl_Question.Text := FMsgQuestion; - lbl_BodyMessage.Text := FMsgBody; + FMsgResponse := False; + btnNo.Text := TextButtonNo; + lbl_Title.Text := FMsgTitle; + lbl_Question.Text := FMsgQuestion; + lbl_BodyMessage.Text := FMsgBody; + RecBackGround.Fill.Color := TAlphaColor(FColorBackuground); + RecLblTitle.Fill.Color := TAlphaColor(FColorSvgIcon); + PathIconSVG.Fill.Color := FColorSvgIcon; + PathIconSVG.WrapMode := TPathWrapMode.Fit; + PathIconSVG.Data.Data := FMsgIcon; case FMsgType of TyOK : TypeOk; TyQuestion: TypeQuestion; end; - PathIconSVG.Fill.Color := FColorSvgIcon; - PathIconSVG.WrapMode := TPathWrapMode.Fit; - PathIconSVG.Data.Data := FMsgIcon; -// imgMenssage.Bitmap := imgMenssage.MultiResBitmap.Items[FMsgIcon.ToInteger].Bitmap; end; procedure THDMessageDlgFMX.SetMsgIcon(const Value: string); @@ -152,7 +154,7 @@ procedure THDMessageDlgFMX.SetMsgBody(const Value: string); procedure THDMessageDlgFMX.SetNo; begin - MsgResponse := False; + FMsgResponse := False; Close; end; @@ -163,7 +165,7 @@ procedure THDMessageDlgFMX.SetMsgQuestion(const Value: string); procedure THDMessageDlgFMX.SetYes; begin - MsgResponse := True; + FMsgResponse := True; Close; end; @@ -187,7 +189,8 @@ procedure THDMessageDlgFMX.TypeQuestion; begin LayoutNo.Visible := True; btnYes.Text := TextButtonYes; - BackbtnYes.Fill.Color := TAlphaColor(FMXColorButtonYes);//($FFEF553B); + btnNo.Text := TextButtonNo; + BackbtnYes.Fill.Color := TAlphaColor(FMXColorButtonYes); end; end. diff --git a/src/HDMessageDlg.Consts.pas b/src/HDMessageDlg.Consts.pas index 53677e1..edcc409 100644 --- a/src/HDMessageDlg.Consts.pas +++ b/src/HDMessageDlg.Consts.pas @@ -23,7 +23,6 @@ interface FMXColorTop = $FF086FFB; FMXColorButtonNo = $FF086FFB; FMXColorButtonYes = $FF0CA950; - FMXColorBackuground = $FFD7D8DB; FMXLabelTitle = $FFFFFFFF; FMXLabelQuestion = $FF086FFB; FMXLabelBodyMessage = $FF555962; diff --git a/src/HDMessageDlg.IconsSVG.pas b/src/HDMessageDlg.IconsSVG.pas index a3cb32a..0a50179 100644 --- a/src/HDMessageDlg.IconsSVG.pas +++ b/src/HDMessageDlg.IconsSVG.pas @@ -17,6 +17,7 @@ THDMessageDlgIconsSVG = class public class function Icon(ATipo : TIcon) : string; class function ColorSvgIcon(ATipo : TIcon) : TAlphaColor; + class function ColorBackuground(ATipo : TIcon) : TAlphaColor; end; const @@ -49,15 +50,35 @@ THDMessageDlgIconsSVG = class '1.26,0,0,1,4.22,15l1.61-2.42A1,1,0,0,0,6,12V9a6,6,0,0,1,6-6,6.07,6.07,0,0,1,2.31.47A3.91,'+ '3.91,0,0,0,14,5a4,4,0,0,0,4,4v3a1,1,0,0,0,.17.55L19.78,15a1.2,1.2,0,0,1,.22.72A1.3,1.3,0,0,1,18.7,17Z'; //Colors SVG - CColorSvgError = $FFD54309; - CColorSvgAttention = $FFFFBE2E; - CColorSvgLike = $FF00BDE3; - CColorSvgQuestion = $FF9C3D10; - CColorSvgMessage = $FF00BDE3; - CColorSvgDefault = $FF086FFB; + CColorSvgError = $FFD54309; + CColorSvgAttention = $FFFFBE2E; + CColorSvgLike = $FF00BDE3; + CColorSvgQuestion = $FF9C3D10; + CColorSvgMessage = $FF00BDE3; + CColorSvgDefault = $FF086FFB; + + CColorBackugroundAttention = $FFFAF3D1; + CColorBackugroundError = $FFF4E3DB; + CColorBackugroundLike = $FFE7F6F8; + CColorBackugroundMessage = $FFE7F6F8; + CColorBackugroundQuestion = $FFF4E3DB; + CColorBackugroundDefault = $FFD7D8DB; + implementation +class function THDMessageDlgIconsSVG.ColorBackuground(ATipo: TIcon): TAlphaColor; +begin + Result := CColorBackugroundDefault; + case ATipo of + TiAttention : Result := CColorBackugroundAttention; + TiError : Result := CColorBackugroundError; + TiLike : Result := CColorBackugroundLike; + TiMessage : Result := CColorBackugroundMessage; + TiQuestion : Result := CColorBackugroundQuestion; + end; +end; + class function THDMessageDlgIconsSVG.ColorSvgIcon(ATipo: TIcon): TAlphaColor; begin Result := CColorSvgDefault; diff --git a/src/HDMessageDlg.Interfaces.pas b/src/HDMessageDlg.Interfaces.pas index daddb25..eab30fc 100644 --- a/src/HDMessageDlg.Interfaces.pas +++ b/src/HDMessageDlg.Interfaces.pas @@ -8,13 +8,13 @@ interface iHDMessageDlg = interface ['{206A0343-2168-418C-9AB6-8A6412F91916}'] - function MsgTitle(aValue: String): iHDMessageDlg; + function MsgTitle(aValue: String) : iHDMessageDlg; function MsgQuestion(aValue: String): iHDMessageDlg; - function MsgBody(aValue: String): iHDMessageDlg; - function MsgIcon(aValue: TIcon): iHDMessageDlg; - function MsgType(aValue: TType): iHDMessageDlg; - function DisplayMessage: iHDMessageDlg; - function DisplayQuestion: Boolean; + function MsgBody(aValue: String) : iHDMessageDlg; + function MsgIcon(aValue: TIcon) : iHDMessageDlg; + function MsgType(aValue: TType) : iHDMessageDlg; + function DisplayMessage : iHDMessageDlg; + function DisplayQuestion : Boolean; end; implementation diff --git a/src/HDMessageDlg.pas b/src/HDMessageDlg.pas index 498f2eb..ad76f51 100644 --- a/src/HDMessageDlg.pas +++ b/src/HDMessageDlg.pas @@ -16,12 +16,13 @@ interface type THDMessageDlg = class(TInterfacedObject, iHDMessageDlg) private - FMsgTitle : String; - FMsgQuestion : String; - FMsgBody : String; - FMsgIcon : string; - FMsgType : TType; - FColorSvgIcon : TAlphaColor; + FMsgTitle : String; + FMsgQuestion : String; + FMsgBody : String; + FMsgIcon : string; + FMsgType : TType; + FColorSvgIcon : TAlphaColor; + FColorBackuground : TAlphaColor; public constructor Create; destructor Destroy; override; @@ -53,17 +54,17 @@ function THDMessageDlg.DisplayMessage: iHDMessageDlg; Result := Self; HDMessageDlgFMX := THDMessageDlgFMX.Create(nil); try - HDMessageDlgFMX.MsgTitle := FMsgTitle; - HDMessageDlgFMX.MsgQuestion := FMsgQuestion; - HDMessageDlgFMX.MsgBody := FMsgBody; - HDMessageDlgFMX.MsgIcon := FMsgIcon; - HDMessageDlgFMX.MsgType := FMsgType; - HDMessageDlgFMX.ColorSvgIcon:= FColorSvgIcon; + HDMessageDlgFMX.MsgTitle := FMsgTitle; + HDMessageDlgFMX.MsgQuestion := FMsgQuestion; + HDMessageDlgFMX.MsgBody := FMsgBody; + HDMessageDlgFMX.MsgIcon := FMsgIcon; + HDMessageDlgFMX.MsgType := FMsgType; + HDMessageDlgFMX.ColorSvgIcon := FColorSvgIcon; + HDMessageDlgFMX.ColorBackuground := FColorBackuground; HDMessageDlgFMX.ShowModal; finally FreeAndNil(HDMessageDlgFMX); end; - end; function THDMessageDlg.DisplayQuestion: Boolean; @@ -72,22 +73,23 @@ function THDMessageDlg.DisplayQuestion: Boolean; begin HDMessageDlgFMX := THDMessageDlgFMX.Create(nil); try - HDMessageDlgFMX.MsgTitle := FMsgTitle; - HDMessageDlgFMX.MsgQuestion := FMsgQuestion; - HDMessageDlgFMX.MsgBody := FMsgBody; - HDMessageDlgFMX.MsgIcon := FMsgIcon; - HDMessageDlgFMX.MsgType := FMsgType; - HDMessageDlgFMX.ColorSvgIcon:= FColorSvgIcon; + HDMessageDlgFMX.MsgTitle := FMsgTitle; + HDMessageDlgFMX.MsgQuestion := FMsgQuestion; + HDMessageDlgFMX.MsgBody := FMsgBody; + HDMessageDlgFMX.MsgIcon := FMsgIcon; + HDMessageDlgFMX.MsgType := FMsgType; + HDMessageDlgFMX.ColorSvgIcon := FColorSvgIcon; + HDMessageDlgFMX.ColorBackuground := FColorBackuground; HDMessageDlgFMX.ShowModal; - Result := HDMessageDlgFMX.MsgResponse; + Result := HDMessageDlgFMX.MsgResponse; finally - FreeAndNil(HDMessageDlgFMX); + FreeAndNil(HDMessageDlgFMX); end; end; function THDMessageDlg.MsgBody(aValue: String): iHDMessageDlg; begin - Result := Self; + Result := Self; FMsgBody := aValue; end; @@ -97,47 +99,52 @@ function THDMessageDlg.MsgIcon(aValue: TIcon): iHDMessageDlg; case aValue of TiAttention: begin - FMsgIcon := THDMessageDlgIconsSVG.Icon(aValue); - FColorSvgIcon := THDMessageDlgIconsSVG.ColorSvgIcon(aValue); + FMsgIcon := THDMessageDlgIconsSVG.Icon(aValue); + FColorSvgIcon := THDMessageDlgIconsSVG.ColorSvgIcon(aValue); + FColorBackuground := THDMessageDlgIconsSVG.ColorBackuground(aValue); end; TiError: begin - FMsgIcon := THDMessageDlgIconsSVG.Icon(aValue); - FColorSvgIcon := THDMessageDlgIconsSVG.ColorSvgIcon(aValue); + FMsgIcon := THDMessageDlgIconsSVG.Icon(aValue); + FColorSvgIcon := THDMessageDlgIconsSVG.ColorSvgIcon(aValue); + FColorBackuground := THDMessageDlgIconsSVG.ColorBackuground(aValue); end; TiLike: begin - FMsgIcon := THDMessageDlgIconsSVG.Icon(aValue); - FColorSvgIcon := THDMessageDlgIconsSVG.ColorSvgIcon(aValue); + FMsgIcon := THDMessageDlgIconsSVG.Icon(aValue); + FColorSvgIcon := THDMessageDlgIconsSVG.ColorSvgIcon(aValue); + FColorBackuground := THDMessageDlgIconsSVG.ColorBackuground(aValue); end; TiMessage: begin - FMsgIcon := THDMessageDlgIconsSVG.Icon(aValue); - FColorSvgIcon := THDMessageDlgIconsSVG.ColorSvgIcon(aValue); + FMsgIcon := THDMessageDlgIconsSVG.Icon(aValue); + FColorSvgIcon := THDMessageDlgIconsSVG.ColorSvgIcon(aValue); + FColorBackuground := THDMessageDlgIconsSVG.ColorBackuground(aValue); end; TiQuestion: begin - FMsgIcon := THDMessageDlgIconsSVG.Icon(aValue); - FColorSvgIcon := THDMessageDlgIconsSVG.ColorSvgIcon(aValue); + FMsgIcon := THDMessageDlgIconsSVG.Icon(aValue); + FColorSvgIcon := THDMessageDlgIconsSVG.ColorSvgIcon(aValue); + FColorBackuground := THDMessageDlgIconsSVG.ColorBackuground(aValue); end; end; end; function THDMessageDlg.MsgQuestion(aValue: String): iHDMessageDlg; begin - Result := Self; + Result := Self; FMsgQuestion := aValue; end; function THDMessageDlg.MsgTitle(aValue: String): iHDMessageDlg; begin - Result := Self; + Result := Self; FMsgTitle := aValue; end; function THDMessageDlg.MsgType(aValue: TType): iHDMessageDlg; begin - Result := Self; + Result := Self; FMsgType := aValue; end;