mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-08 10:39:15 +02:00
LCL: Implement TCustomEdit.NumbersOnly property.
Currently only effective on Windows. git-svn-id: trunk@43678 -
This commit is contained in:
parent
cffb111e37
commit
409cedc9c4
@ -32,6 +32,8 @@ begin
|
||||
Params.Style := Params.Style or ES_AUTOHSCROLL or AlignmentStyle[Alignment];
|
||||
if ReadOnly then
|
||||
Params.Style := Params.Style or ES_READONLY;
|
||||
if NumbersOnly then
|
||||
Params.Style := Params.Style or ES_NUMBER;
|
||||
if not HideSelection then
|
||||
Params.Style := Params.Style or ES_NOHIDESEL;
|
||||
end;
|
||||
@ -283,6 +285,11 @@ begin
|
||||
Result := False;
|
||||
end;
|
||||
|
||||
function TCustomEdit.GetNumbersOnly: Boolean;
|
||||
begin
|
||||
Result := FNumbersOnly;
|
||||
end;
|
||||
|
||||
function TCustomEdit.GetReadOnly: Boolean;
|
||||
begin
|
||||
Result := FReadOnly;
|
||||
@ -345,6 +352,7 @@ begin
|
||||
FModified := Value;
|
||||
end;
|
||||
|
||||
|
||||
procedure TCustomEdit.SetPasswordChar(const AValue: Char);
|
||||
begin
|
||||
if FPasswordChar=AValue then exit;
|
||||
@ -393,6 +401,22 @@ begin
|
||||
TWSCustomEditClass(WidgetSetClass).SetEchoMode(Self, Val);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: TCustomEdit.SetNumbersOnly
|
||||
Params: Value to set FNumbersOnly to
|
||||
Returns: Nothing
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TCustomEdit.SetNumbersOnly(Value: Boolean);
|
||||
begin
|
||||
if FNumbersOnly <> Value then
|
||||
begin
|
||||
FNumbersOnly := Value;
|
||||
if HandleAllocated then
|
||||
TWSCustomEditClass(WidgetSetClass).SetNumbersOnly(Self, Value);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: TCustomEdit.SetReadOnly
|
||||
Params: Value to set FReadOnly to
|
||||
@ -571,4 +595,5 @@ end;
|
||||
|
||||
|
||||
|
||||
|
||||
// included by stdctrls.pp
|
||||
|
@ -165,6 +165,7 @@ type
|
||||
class procedure SetEchoMode(const ACustomEdit: TCustomEdit; NewMode: TEchoMode); override;
|
||||
class procedure SetHideSelection(const ACustomEdit: TCustomEdit; NewHideSelection: Boolean); override;
|
||||
class procedure SetMaxLength(const ACustomEdit: TCustomEdit; NewLength: integer); override;
|
||||
class procedure SetNumbersOnly(const ACustomEdit: TCustomEdit; NewNumbersOnly: Boolean); override;
|
||||
class procedure SetPasswordChar(const ACustomEdit: TCustomEdit; NewChar: char); override;
|
||||
class procedure SetReadOnly(const ACustomEdit: TCustomEdit; NewReadOnly: boolean); override;
|
||||
class procedure SetSelStart(const ACustomEdit: TCustomEdit; NewStart: integer); override;
|
||||
@ -1203,6 +1204,14 @@ begin
|
||||
GetWin32WindowInfo(winhandle)^.MaxLength := NewLength;
|
||||
end;
|
||||
|
||||
class procedure TWin32WSCustomEdit.SetNumbersOnly(const ACustomEdit: TCustomEdit; NewNumbersOnly: Boolean);
|
||||
const
|
||||
EditStyles: array[Boolean] of integer = (0, ES_NUMBER);
|
||||
EditStyleMask = ES_NUMBER;
|
||||
begin
|
||||
UpdateWindowStyle(ACustomEdit.Handle, EditStyles[NewNumbersOnly], EditStyleMask);
|
||||
end;
|
||||
|
||||
class procedure TWin32WSCustomEdit.SetPasswordChar(const ACustomEdit: TCustomEdit; NewChar: char);
|
||||
begin
|
||||
SendMessage(ACustomEdit.Handle, EM_SETPASSWORDCHAR, WParam(NewChar), 0);
|
||||
|
@ -153,6 +153,7 @@ type
|
||||
class procedure SetEchoMode(const ACustomEdit: TCustomEdit; NewMode: TEchoMode); override;
|
||||
class procedure SetHideSelection(const ACustomEdit: TCustomEdit; NewHideSelection: Boolean); override;
|
||||
class procedure SetMaxLength(const ACustomEdit: TCustomEdit; NewLength: integer); override;
|
||||
class procedure SetNumbersOnly(const ACustomEdit: TCustomEdit; NewNumbersOnly: Boolean); override;
|
||||
class procedure SetPasswordChar(const ACustomEdit: TCustomEdit; NewChar: char); override;
|
||||
class procedure SetReadOnly(const ACustomEdit: TCustomEdit; NewReadOnly: boolean); override;
|
||||
class procedure SetSelStart(const ACustomEdit: TCustomEdit; NewStart: integer); override;
|
||||
@ -976,6 +977,14 @@ begin
|
||||
GetWindowInfo(winhandle)^.MaxLength := NewLength;
|
||||
end;
|
||||
|
||||
class procedure TWin32WSCustomEdit.SetNumbersOnly(const ACustomEdit: TCustomEdit; NewNumbersOnly: Boolean);
|
||||
const
|
||||
EditStyles: array[Boolean] of integer = (0, ES_NUMBER);
|
||||
EditStyleMask = ES_NUMBER;
|
||||
begin
|
||||
UpdateWindowStyle(ACustomEdit.Handle, EditStyles[NewNumbersOnly], EditStyleMask);
|
||||
end;
|
||||
|
||||
class procedure TWinCEWSCustomEdit.SetPasswordChar(const ACustomEdit: TCustomEdit; NewChar: char);
|
||||
begin
|
||||
SendMessage(ACustomEdit.Handle, EM_SETPASSWORDCHAR, WParam(NewChar), 0);
|
||||
|
@ -963,6 +963,7 @@ const
|
||||
ES_AUTOVSCROLL = $0040;
|
||||
ES_AUTOHSCROLL = $0080;
|
||||
ES_NOHIDESEL = $0100;
|
||||
ES_NUMBER = $2000;
|
||||
ES_READONLY = $0800;
|
||||
ES_WANTRETURN = $1000;
|
||||
|
||||
|
@ -48,7 +48,7 @@ Different behaviour than Delphi, but by design (October 2009, BB)
|
||||
- Restore all MaskLiterals in the text
|
||||
}
|
||||
|
||||
unit maskedit;
|
||||
unit MaskEdit;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
@ -230,7 +230,7 @@ const
|
||||
function GetCharCase: TEditCharCase;
|
||||
procedure SetMaxLength(Value: Integer);
|
||||
function GetMaxLength: Integer;
|
||||
|
||||
procedure SetNumbersOnly(Value: Boolean); override;
|
||||
procedure Loaded; override;
|
||||
|
||||
procedure LMPasteFromClip(var Message: TLMessage); message LM_PASTE;
|
||||
@ -639,7 +639,11 @@ begin
|
||||
FFirstFreePos := 1;
|
||||
//Determine first position where text can be entered (needed for DeleteChars()
|
||||
while (FFirstFreePos <= FMaskLength) and IsLiteral(FMask[FFirstFreePos]) do Inc(FFirstFreePos);
|
||||
if (FMaskLength > 0) then SetCharCase(ecNormal);
|
||||
if (FMaskLength > 0) then
|
||||
begin
|
||||
SetCharCase(ecNormal);
|
||||
SetNumbersOnly(False);
|
||||
end;
|
||||
//SetMaxLegth must be before Clear, otherwise Clear uses old MaxLength value!
|
||||
SetMaxLength(FMaskLength);
|
||||
Clear;
|
||||
@ -1520,6 +1524,15 @@ begin
|
||||
Result := inherited Maxlength;
|
||||
end;
|
||||
|
||||
procedure TCustomMaskEdit.SetNumbersOnly(Value: Boolean);
|
||||
begin
|
||||
if not IsMasked then
|
||||
inherited SetNumbersOnly(Value)
|
||||
else
|
||||
//NumersOnly interferes with masking
|
||||
inherited SetNumbersOnly(False);
|
||||
end;
|
||||
|
||||
procedure TCustomMaskEdit.Loaded;
|
||||
begin
|
||||
inherited Loaded;
|
||||
|
@ -697,6 +697,7 @@ type
|
||||
FModified: Boolean;
|
||||
FPasswordChar: Char;
|
||||
FReadOnly: Boolean;
|
||||
FNumbersOnly: Boolean;
|
||||
FOnChange: TNotifyEvent;
|
||||
FSelLength: integer;
|
||||
FSelStart: integer;
|
||||
@ -719,12 +720,14 @@ type
|
||||
procedure DoEnter; override;
|
||||
procedure DoExit; override;
|
||||
function GetCaretPos: TPoint; virtual;
|
||||
function GetNumbersOnly: Boolean; virtual;
|
||||
function GetReadOnly: Boolean; virtual;
|
||||
function GetSelLength: integer; virtual;
|
||||
function GetSelStart: integer; virtual;
|
||||
function GetSelText: string; virtual;
|
||||
procedure SetCaretPos(const Value: TPoint); virtual;
|
||||
procedure SetEchoMode(Val: TEchoMode); virtual;
|
||||
procedure SetNumbersOnly(Value: Boolean); virtual;
|
||||
procedure SetReadOnly(Value: Boolean); virtual;
|
||||
procedure SetSelLength(Val: integer); virtual;
|
||||
procedure SetSelStart(Val: integer); virtual;
|
||||
@ -760,6 +763,7 @@ type
|
||||
property HideSelection: Boolean read FHideSelection write SetHideSelection default True;
|
||||
property MaxLength: Integer read FMaxLength write SetMaxLength default 0;
|
||||
property Modified: Boolean read GetModified write SetModified;
|
||||
property NumbersOnly: Boolean read GetNumbersOnly write SetNumbersOnly default false;
|
||||
property OnChange: TNotifyEvent read FOnChange write FOnChange;
|
||||
property PasswordChar: Char read FPasswordChar write SetPasswordChar default #0;
|
||||
property PopupMenu;
|
||||
@ -865,6 +869,7 @@ type
|
||||
property Font;
|
||||
property HideSelection;
|
||||
property MaxLength;
|
||||
property NumbersOnly;
|
||||
property ParentBidiMode;
|
||||
property OnChange;
|
||||
property OnChangeBounds;
|
||||
|
@ -152,6 +152,7 @@ type
|
||||
class procedure SetEchoMode(const ACustomEdit: TCustomEdit; NewMode: TEchoMode); virtual;
|
||||
class procedure SetHideSelection(const ACustomEdit: TCustomEdit; NewHideSelection: Boolean); virtual;
|
||||
class procedure SetMaxLength(const ACustomEdit: TCustomEdit; NewLength: integer); virtual;
|
||||
class procedure SetNumbersOnly(const ACustomEdit: TCustomEdit; NewNumbersOnly: Boolean); virtual;
|
||||
class procedure SetPasswordChar(const ACustomEdit: TCustomEdit; NewChar: char); virtual;
|
||||
class procedure SetReadOnly(const ACustomEdit: TCustomEdit; NewReadOnly: boolean); virtual;
|
||||
class procedure SetSelStart(const ACustomEdit: TCustomEdit; NewStart: integer); virtual;
|
||||
@ -533,6 +534,11 @@ class procedure TWSCustomEdit.SetMaxLength(const ACustomEdit: TCustomEdit; NewLe
|
||||
begin
|
||||
end;
|
||||
|
||||
class procedure TWSCustomEdit.SetNumbersOnly(const ACustomEdit: TCustomEdit;
|
||||
NewNumbersOnly: Boolean);
|
||||
begin
|
||||
end;
|
||||
|
||||
class procedure TWSCustomEdit.SetPasswordChar(const ACustomEdit: TCustomEdit; NewChar: char);
|
||||
begin
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user