|
@@ -23,6 +23,7 @@ Type
|
|
|
class constructor Init;
|
|
|
class function IsSpecialChar(aUnicodeChar: string): boolean;
|
|
|
private
|
|
|
+ FSelectionElement : TPseudoElSelection;
|
|
|
FEnabled: Boolean;
|
|
|
FMaxLength: Integer;
|
|
|
FReadOnly: Boolean;
|
|
@@ -94,6 +95,7 @@ Type
|
|
|
procedure SetValue(const aValue: TFresnelCaption); virtual;
|
|
|
procedure SetName(const aNewName: TComponentName); override;
|
|
|
procedure DoRender(aRenderer: IFresnelRenderer); override;
|
|
|
+ procedure SetParent(const AValue: TFresnelElement); override;
|
|
|
Public
|
|
|
class function HandleFocus: Boolean; override;
|
|
|
class function CSSTypeID: TCSSNumericalID; override;
|
|
@@ -101,14 +103,22 @@ Type
|
|
|
class function GetCSSTypeStyle: TCSSString; override;
|
|
|
public
|
|
|
constructor Create(aOwner : TComponent); override;
|
|
|
+ destructor destroy; override;
|
|
|
function GetIntrinsicContentSize(aMode: TFresnelLayoutMode;
|
|
|
aMaxWidth: TFresnelLength; aMaxHeight: TFresnelLength): TFreIntrinsicContentSize; override;
|
|
|
+ // Can the control be focused ?
|
|
|
function CanFocus: Boolean; override;
|
|
|
+ // Delete the current selection
|
|
|
procedure DeleteSelection;
|
|
|
+ // Set the selection. Start and end are zero-based
|
|
|
procedure SetSelection(const aStart,aEnd : Integer);
|
|
|
+ // The value shown in the edit
|
|
|
property Value: TFresnelCaption read FValue write SetValue;
|
|
|
+ // Is the content editable ?
|
|
|
property ReadOnly : Boolean Read FReadOnly Write SetReadOnly;
|
|
|
+ // Is the control enabled ?
|
|
|
property Enabled : Boolean Read FEnabled Write SetEnabled;
|
|
|
+ // Placeholder text, shown if no value is present
|
|
|
property PlaceHolder : TFresnelCaption Read FPlaceHolder Write SetPlaceHolder;
|
|
|
// Cursor position, 0 based, in characters (codepoints)
|
|
|
Property Curs : Integer Read FSelectionStart Write SetSelectionStart;
|
|
@@ -116,9 +126,9 @@ Type
|
|
|
Property SelectionStart : Integer Read FSelectionStart Write SetSelectionStart;
|
|
|
// SelectionEnd, 0 based, in characters (codepoints)
|
|
|
Property SelectionEnd : Integer Read FSelectionEnd Write SetSelectionEnd;
|
|
|
- // Max length
|
|
|
+ // Max length of the text
|
|
|
Property MaxLength : Integer Read FMaxLength Write SetMaxLength;
|
|
|
- // Get selection
|
|
|
+ // Get current selection text
|
|
|
Property SelectionText : String Read GetSelectionText write SetSelectionText;
|
|
|
end;
|
|
|
|
|
@@ -865,7 +875,7 @@ procedure TEdit.DoRender(aRenderer: IFresnelRenderer);
|
|
|
|
|
|
var
|
|
|
lCaption : string;
|
|
|
- lBackColor, lColorFP, lShadowColor: TFPColor;
|
|
|
+ lSelColor,lBackColor, lColorFP, lShadowColor: TFPColor;
|
|
|
lTopSideMargin, lLeftSideMargin, lRadius, lOffsetX, lOffsetY : TFresnelLength;
|
|
|
lHaveShadow : Boolean;
|
|
|
R,RSel : TFresnelRect;
|
|
@@ -905,8 +915,9 @@ begin
|
|
|
begin
|
|
|
RSel.Left:=RSel.Left+{lLeftSideMargin+}FSelectionStartX;
|
|
|
RSel.Right:=RSel.Left+SelWidth;
|
|
|
- lBackColor:=fpimage.colDkBlue; // GetComputedColor(fcaSelectionBackGroundColor,colTransparent);
|
|
|
- aRenderer.FillRect(fpimage.colDkBlue,RSel);
|
|
|
+ lBackColor:=FSelectionElement.GetComputedColor(fcaBackgroundColor,fpimage.colDkBlue);
|
|
|
+ lSelColor:=FSelectionElement.GetComputedColor(fcaColor,fpimage.colWhite);
|
|
|
+ aRenderer.FillRect(lBackColor,RSel);
|
|
|
end;
|
|
|
lHaveShadow:=GetComputedTextShadow(lOffsetX, lOffsetY, lRadius, lShadowColor);
|
|
|
if lHaveShadow then
|
|
@@ -917,7 +928,7 @@ begin
|
|
|
begin
|
|
|
if FSelectionStart>0 then
|
|
|
aRenderer.TextOut(R.Left+lLeftSideMargin,R.Top+lTopSideMargin,Font,lColorFP,Copy(lCaption,1,1+FSelectionStart));
|
|
|
- aRenderer.TextOut(RSel.Left,RSel.Top+lTopSideMargin,Font,colWhite,Copy(lCaption,1+FSelectionStart,FSelectionEnd-FSelectionStart));
|
|
|
+ aRenderer.TextOut(RSel.Left,RSel.Top+lTopSideMargin,Font,lSelColor,Copy(lCaption,1+FSelectionStart,FSelectionEnd-FSelectionStart));
|
|
|
if FSelectionEnd<Length(lCaption) then
|
|
|
aRenderer.TextOut(RSel.Right,Rsel.Top+lTopSideMargin,Font,lColorFP,Copy(lCaption,1+FSelectionEnd));
|
|
|
end
|
|
@@ -931,6 +942,11 @@ begin
|
|
|
DrawCursor;
|
|
|
end;
|
|
|
|
|
|
+procedure TEdit.SetParent(const AValue: TFresnelElement);
|
|
|
+begin
|
|
|
+ inherited SetParent(AValue);
|
|
|
+end;
|
|
|
+
|
|
|
procedure TEdit.SetSelection(const aStart, aEnd: Integer);
|
|
|
var
|
|
|
lLen : Integer;
|
|
@@ -969,23 +985,32 @@ end;
|
|
|
|
|
|
class function TEdit.CSSTypeName: TCSSString;
|
|
|
begin
|
|
|
- Result:='edit';
|
|
|
+ Result:='input';
|
|
|
end;
|
|
|
|
|
|
class function TEdit.GetCSSTypeStyle: TCSSString;
|
|
|
begin
|
|
|
// needs checking. Normally you cannot have controls inside an edit.
|
|
|
- Result:='edit { padding: 3px; ' +
|
|
|
+ Result:='input { padding: 3px; ' +
|
|
|
' border: 1px solid black; ' +
|
|
|
' display: inline flow; }';
|
|
|
+
|
|
|
end;
|
|
|
|
|
|
constructor TEdit.Create(aOwner: TComponent);
|
|
|
begin
|
|
|
inherited Create(aOwner);
|
|
|
+ FSelectionElement:=TPseudoElSelection.Create(Self);
|
|
|
+ FSelectionElement.Parent:=Self;
|
|
|
FEnabled:=True;
|
|
|
end;
|
|
|
|
|
|
+destructor TEdit.destroy;
|
|
|
+begin
|
|
|
+ FreeAndNil(FSelectionElement);
|
|
|
+ inherited destroy;
|
|
|
+end;
|
|
|
+
|
|
|
|
|
|
end.
|
|
|
|