mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-25 13:59:12 +02:00
LCL: Added DirectInput property for TCustomEditButton
patch by: Gerard Visent (modified) mantis: 10861 git-svn-id: trunk@15118 -
This commit is contained in:
parent
8668edd623
commit
27cf27363d
lcl
@ -41,6 +41,8 @@ type
|
||||
private
|
||||
FButton: TSpeedButton;
|
||||
FButtonNeedsFocus: Boolean;
|
||||
FDirectInput: Boolean;
|
||||
FIsReadOnly: boolean;
|
||||
FOnButtonClick : TNotifyEvent;
|
||||
function GetButtonHint: TTranslateString;
|
||||
function GetButtonWidth: Integer;
|
||||
@ -60,10 +62,11 @@ type
|
||||
procedure WMSetFocus(var Message: TLMSetFocus); message LM_SETFOCUS;
|
||||
procedure WMKillFocus(var Message: TLMKillFocus); message LM_KILLFOCUS;
|
||||
protected
|
||||
function GetReadOnly: Boolean; override;
|
||||
function GetDefaultGlyph: TBitmap; virtual;
|
||||
function GetDefaultGlyphName: String; virtual;
|
||||
procedure SetParent(AParent: TWinControl); override;
|
||||
procedure SetReadOnly(Value: Boolean); override;
|
||||
procedure SetReadOnly(AValue: Boolean); override;
|
||||
procedure DoPositionButton; virtual;
|
||||
procedure DoButtonClick (Sender: TObject); virtual;
|
||||
procedure Loaded; override;
|
||||
@ -72,7 +75,7 @@ type
|
||||
procedure CMEnabledChanged(var Msg: TLMessage); message CM_ENABLEDCHANGED;
|
||||
// New properties.
|
||||
property ButtonWidth : Integer read GetButtonWidth write SetButtonWidth;
|
||||
property DirectInput : Boolean read GetDirectInput write SetDirectInput stored False Default True;
|
||||
property DirectInput : Boolean read GetDirectInput write SetDirectInput default true;
|
||||
property Glyph : TBitmap read GetGlyph write SetGlyph;
|
||||
property NumGlyphs : Integer read GetNumGlyphs write SetNumGlyphs;
|
||||
property OnButtonClick : TNotifyEvent read FOnButtonClick write FOnButtonClick;
|
||||
@ -80,7 +83,7 @@ type
|
||||
property ButtonHint: TTranslateString read GetButtonHint write SetButtonHint;
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
destructor Destroy; override;
|
||||
property Flat : Boolean read GetFlat write SetFlat;
|
||||
property ButtonOnlyWhenFocused : Boolean read FButtonNeedsFocus write SetButtonNeedsFocus;
|
||||
end;
|
||||
@ -347,10 +350,8 @@ type
|
||||
property OnCustomDate : TCustomDateEvent read FOnCustomDate write FOnCustomDate;
|
||||
property OKCaption:TCaption read FOKCaption write FOKCaption;
|
||||
property CancelCaption:TCaption read FCancelCaption write FCancelCaption;
|
||||
property ReadOnly default true;
|
||||
property DefaultToday: Boolean read FDefaultToday write FDefaultToday
|
||||
default False;
|
||||
|
||||
property ReadOnly;
|
||||
property DefaultToday: Boolean read FDefaultToday write FDefaultToday;
|
||||
property ButtonOnlyWhenFocused;
|
||||
property ButtonWidth;
|
||||
property Action;
|
||||
@ -362,6 +363,7 @@ type
|
||||
property Color;
|
||||
property Constraints;
|
||||
property CharCase;
|
||||
property DirectInput;
|
||||
property Glyph;
|
||||
property NumGlyphs;
|
||||
property DragMode;
|
||||
@ -493,6 +495,7 @@ var
|
||||
B: TBitmap;
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
FDirectInput:=true;
|
||||
FButton := TSpeedButton.Create(Self);
|
||||
FButton.Width := Self.Height;
|
||||
FButton.Height := Self.Height;
|
||||
@ -541,7 +544,7 @@ end;
|
||||
|
||||
function TCustomEditButton.GetDirectInput: Boolean;
|
||||
begin
|
||||
Result := not ReadOnly;
|
||||
Result := FDirectInput;
|
||||
end;
|
||||
|
||||
function TCustomEditButton.GetFlat: Boolean;
|
||||
@ -580,7 +583,8 @@ end;
|
||||
|
||||
procedure TCustomEditButton.SetDirectInput(const AValue: Boolean);
|
||||
begin
|
||||
ReadOnly := not AValue;
|
||||
FDirectInput := AValue;
|
||||
Inherited SetReadOnly((not FDirectInput) or (FIsReadOnly))
|
||||
end;
|
||||
|
||||
procedure TCustomEditButton.SetFlat(const AValue: Boolean);
|
||||
@ -622,7 +626,7 @@ procedure TCustomEditButton.CMEnabledChanged(var Msg: TLMessage);
|
||||
begin
|
||||
inherited CMEnabledChanged(Msg);
|
||||
|
||||
if FButton<>nil then
|
||||
if (FButton<>nil) and (not ReadOnly) then
|
||||
FButton.Enabled:=Enabled;
|
||||
end;
|
||||
|
||||
@ -652,6 +656,11 @@ begin
|
||||
inherited;
|
||||
end;
|
||||
|
||||
function TCustomEditButton.GetReadOnly: Boolean;
|
||||
begin
|
||||
Result := FIsReadOnly;
|
||||
end;
|
||||
|
||||
procedure TCustomEditButton.SetParent(AParent: TWinControl);
|
||||
begin
|
||||
inherited SetParent(AParent);
|
||||
@ -662,12 +671,12 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomEditButton.SetReadOnly(Value: Boolean);
|
||||
procedure TCustomEditButton.SetReadOnly(AValue: Boolean);
|
||||
begin
|
||||
inherited SetReadOnly(Value);
|
||||
// Paul: ReadOnly should affect only editbox to prevent editing it by hands
|
||||
|
||||
//FButton.Enabled := not Value;
|
||||
FIsReadOnly := AValue;
|
||||
if Assigned(FButton) then
|
||||
FButton.Enabled := not FIsReadOnly and Enabled;
|
||||
inherited SetReadOnly(FIsReadOnly or (not DirectInput));
|
||||
end;
|
||||
|
||||
procedure TCustomEditButton.DoPositionButton;
|
||||
@ -885,7 +894,6 @@ constructor TDateEdit.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
FDisplaySettings:=[dsShowHeadings, dsShowDayNames];
|
||||
ReadOnly:=true;
|
||||
DialogTitle:=rsPickDate;
|
||||
OKCaption:='OK';
|
||||
CancelCaption:='Cancel';
|
||||
|
@ -260,6 +260,11 @@ begin
|
||||
Result := False;
|
||||
end;
|
||||
|
||||
function TCustomEdit.GetReadOnly: Boolean;
|
||||
begin
|
||||
Result := FReadOnly;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: TCustomEdit.SetCharCase
|
||||
Params: Value to set FCharCase to
|
||||
|
@ -673,6 +673,7 @@ type
|
||||
procedure DoEnter; override;
|
||||
procedure DoExit; override;
|
||||
function GetCaretPos: TPoint; virtual;
|
||||
function GetReadOnly: Boolean; virtual;
|
||||
function GetSelLength: integer; virtual;
|
||||
function GetSelStart: integer; virtual;
|
||||
function GetSelText: string; virtual;
|
||||
@ -710,7 +711,7 @@ type
|
||||
property OnChange: TNotifyEvent read FOnChange write FOnChange;
|
||||
property PasswordChar: Char read FPasswordChar write SetPasswordChar default #0;
|
||||
property PopupMenu;
|
||||
property ReadOnly: Boolean read FReadOnly write SetReadOnly default false;
|
||||
property ReadOnly: Boolean read GetReadOnly write SetReadOnly default false;
|
||||
property SelLength: integer read GetSelLength write SetSelLength;
|
||||
property SelStart: integer read GetSelStart write SetSelStart;
|
||||
property SelText: String read GetSelText write SetSelText;
|
||||
|
Loading…
Reference in New Issue
Block a user