-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from juliocandrade/main
Correção na aplicação de estilos que não identificava componentes de …
- Loading branch information
Showing
9 changed files
with
392 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
unit Bind4D.Component.CheckListBox; | ||
|
||
interface | ||
|
||
uses | ||
Bind4D.Component.Interfaces, | ||
Bind4D.Attributes, | ||
Vcl.CheckLst; | ||
|
||
Type | ||
TBind4DComponentCheckListBox = class(TInterfacedObject, iBind4DComponent) | ||
private | ||
FComponent : TCheckListBox; | ||
FAttributes : iBind4DComponentAttributes; | ||
public | ||
constructor Create(aValue : TCheckListBox); | ||
destructor Destroy; override; | ||
class function New(aValue : TCheckListBox) : iBind4DComponent; | ||
function Attributes : iBind4DComponentAttributes; | ||
function AdjusteResponsivity : iBind4DComponent; | ||
function ApplyStyles : iBind4DComponent; | ||
function ApplyText : iBind4DComponent; | ||
function ApplyImage : iBind4DComponent; | ||
function ApplyValue : iBind4DComponent; | ||
function ApplyRestData : iBind4DComponent; | ||
function Clear : iBind4DComponent; | ||
function FormatFieldGrid (aAttr : FieldDataSetBind) : iBind4DComponent; | ||
function GetValueString : String; | ||
function GetCaption : String; | ||
end; | ||
|
||
implementation | ||
|
||
uses | ||
System.Classes, | ||
System.Variants, | ||
Vcl.StdCtrls, | ||
Bind4D.Component.Attributes, | ||
System.JSON; | ||
|
||
{ TBind4DComponentCheckListBox } | ||
|
||
function TBind4DComponentCheckListBox.AdjusteResponsivity: iBind4DComponent; | ||
begin | ||
Result := Self; | ||
end; | ||
|
||
function TBind4DComponentCheckListBox.ApplyImage: iBind4DComponent; | ||
begin | ||
Result := Self; | ||
end; | ||
|
||
function TBind4DComponentCheckListBox.ApplyRestData: iBind4DComponent; | ||
begin | ||
Result := Self; | ||
end; | ||
|
||
function TBind4DComponentCheckListBox.ApplyStyles: iBind4DComponent; | ||
begin | ||
Result := Self; | ||
FComponent.StyleElements := FAttributes.StyleSettings; | ||
FComponent.Color := FAttributes.Color; | ||
FComponent.Font.Color := FAttributes.FontColor; | ||
FComponent.Font.Name := FAttributes.FontName; | ||
FComponent.Font.Size := FAttributes.FontSize; | ||
end; | ||
|
||
function TBind4DComponentCheckListBox.ApplyText: iBind4DComponent; | ||
begin | ||
Result := Self; | ||
end; | ||
|
||
function TBind4DComponentCheckListBox.ApplyValue: iBind4DComponent; | ||
var | ||
JsonArray : TJsonArray; | ||
ListIndex : Integer; | ||
begin | ||
if VarIsNull(FAttributes.ValueVariant) then | ||
exit; | ||
|
||
JsonArray := TJSONObject.ParseJSONValue(FAttributes.ValueVariant) as TJSONArray; | ||
if not Assigned(JsonArray) then | ||
exit; | ||
|
||
try | ||
for var JsonItem in JsonArray do | ||
begin | ||
ListIndex := FComponent.Items.IndexOf(JsonItem.Value); | ||
if ListIndex > -1 then | ||
FComponent.Checked[ListIndex] := true; | ||
end; | ||
finally | ||
JsonArray.Free; | ||
end; | ||
end; | ||
|
||
function TBind4DComponentCheckListBox.Attributes: iBind4DComponentAttributes; | ||
begin | ||
Result := FAttributes; | ||
end; | ||
|
||
function TBind4DComponentCheckListBox.Clear: iBind4DComponent; | ||
begin | ||
Result := Self; | ||
FComponent.CheckAll(cbUnchecked, true, true); | ||
end; | ||
|
||
constructor TBind4DComponentCheckListBox.Create(aValue : TCheckListBox); | ||
begin | ||
FAttributes := TBind4DComponentAttributes.Create(Self); | ||
FComponent := aValue; | ||
end; | ||
|
||
destructor TBind4DComponentCheckListBox.Destroy; | ||
begin | ||
|
||
inherited; | ||
end; | ||
|
||
function TBind4DComponentCheckListBox.FormatFieldGrid( | ||
aAttr: FieldDataSetBind): iBind4DComponent; | ||
begin | ||
Result := Self; | ||
end; | ||
|
||
function TBind4DComponentCheckListBox.GetCaption: String; | ||
begin | ||
Result := ''; | ||
end; | ||
|
||
function TBind4DComponentCheckListBox.GetValueString: String; | ||
var | ||
JsonArray : TJsonArray; | ||
I : Integer; | ||
begin | ||
JsonArray := TJsonArray.Create; | ||
try | ||
for I := 0 to Pred(FComponent.Count) do | ||
begin | ||
if FComponent.Checked[I] then | ||
JsonArray.Add(FComponent.Items[I]); | ||
end; | ||
Result := JsonArray.ToString; | ||
finally | ||
JsonArray.Free; | ||
end; | ||
end; | ||
|
||
class function TBind4DComponentCheckListBox.New (aValue : TCheckListBox) : iBind4DComponent; | ||
begin | ||
Result := Self.Create(aValue); | ||
end; | ||
|
||
end. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
unit Bind4D.Component.ListBox; | ||
|
||
interface | ||
uses | ||
Bind4D.Component.Interfaces, | ||
Bind4D.Attributes, | ||
Vcl.StdCtrls; | ||
Type | ||
TBind4DComponentListBox = class(TInterfacedObject, iBind4DComponent) | ||
private | ||
FComponent : TListBox; | ||
FAttributes : iBind4DComponentAttributes; | ||
public | ||
constructor Create(aValue : TListBox); | ||
destructor Destroy; override; | ||
class function New(aValue : TListBox) : iBind4DComponent; | ||
function Attributes : iBind4DComponentAttributes; | ||
function AdjusteResponsivity : iBind4DComponent; | ||
function ApplyStyles : iBind4DComponent; | ||
function ApplyText : iBind4DComponent; | ||
function ApplyImage : iBind4DComponent; | ||
function ApplyValue : iBind4DComponent; | ||
function ApplyRestData : iBind4DComponent; | ||
function Clear : iBind4DComponent; | ||
function FormatFieldGrid (aAttr : FieldDataSetBind) : iBind4DComponent; | ||
function GetValueString : String; | ||
function GetCaption : String; | ||
end; | ||
|
||
implementation | ||
|
||
uses | ||
Bind4D.Component.Attributes; | ||
|
||
{ TBind4DComponentListBox } | ||
|
||
function TBind4DComponentListBox.AdjusteResponsivity: iBind4DComponent; | ||
begin | ||
Result := Self; | ||
end; | ||
|
||
function TBind4DComponentListBox.ApplyImage: iBind4DComponent; | ||
begin | ||
Result := Self; | ||
end; | ||
|
||
function TBind4DComponentListBox.ApplyRestData: iBind4DComponent; | ||
begin | ||
Result := Self; | ||
end; | ||
|
||
function TBind4DComponentListBox.ApplyStyles: iBind4DComponent; | ||
begin | ||
Result := Self; | ||
FComponent.StyleElements := FAttributes.StyleSettings; | ||
FComponent.Color := FAttributes.Color; | ||
FComponent.Font.Color := FAttributes.FontColor; | ||
FComponent.Font.Name := FAttributes.FontName; | ||
FComponent.Font.Size := FAttributes.FontSize; | ||
end; | ||
|
||
function TBind4DComponentListBox.ApplyText: iBind4DComponent; | ||
begin | ||
Result := Self; | ||
FComponent.Items.Text := FAttributes.Text; | ||
end; | ||
|
||
function TBind4DComponentListBox.ApplyValue: iBind4DComponent; | ||
begin | ||
Result := Self; | ||
FComponent.Items.Text := FAttributes.ValueVariant; | ||
end; | ||
|
||
function TBind4DComponentListBox.Attributes: iBind4DComponentAttributes; | ||
begin | ||
Result := FAttributes; | ||
end; | ||
|
||
function TBind4DComponentListBox.Clear: iBind4DComponent; | ||
begin | ||
Result := Self; | ||
FComponent.Items.Clear; | ||
end; | ||
|
||
constructor TBind4DComponentListBox.Create(aValue : TListBox); | ||
begin | ||
FAttributes := TBind4DComponentAttributes.Create(Self); | ||
FComponent := aValue; | ||
end; | ||
|
||
destructor TBind4DComponentListBox.Destroy; | ||
begin | ||
|
||
inherited; | ||
end; | ||
|
||
function TBind4DComponentListBox.FormatFieldGrid( | ||
aAttr: FieldDataSetBind): iBind4DComponent; | ||
begin | ||
Result := Self; | ||
end; | ||
|
||
function TBind4DComponentListBox.GetCaption: String; | ||
begin | ||
Result := FComponent.Items.Text; | ||
end; | ||
|
||
function TBind4DComponentListBox.GetValueString: String; | ||
begin | ||
Result := FComponent.Items.Text; | ||
end; | ||
|
||
class function TBind4DComponentListBox.New (aValue : TListBox) : iBind4DComponent; | ||
begin | ||
Result := Self.Create(aValue); | ||
end; | ||
|
||
end. |
Oops, something went wrong.