mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-20 17:59:27 +02:00
LCL: Add virtual methods supporting hiding the button in TCustomEditButton. Patch from Stephano.
git-svn-id: trunk@30308 -
This commit is contained in:
parent
dea61d3287
commit
ad2cc72723
@ -48,7 +48,6 @@ type
|
|||||||
function GetButtonWidth: Integer;
|
function GetButtonWidth: Integer;
|
||||||
function GetDirectInput: Boolean;
|
function GetDirectInput: Boolean;
|
||||||
function GetFlat: Boolean;
|
function GetFlat: Boolean;
|
||||||
procedure CheckButtonVisible;
|
|
||||||
procedure SetButtonHint(const AValue: TTranslateString);
|
procedure SetButtonHint(const AValue: TTranslateString);
|
||||||
procedure SetButtonNeedsFocus(const AValue: Boolean);
|
procedure SetButtonNeedsFocus(const AValue: Boolean);
|
||||||
procedure SetButtonWidth(const AValue: Integer);
|
procedure SetButtonWidth(const AValue: Integer);
|
||||||
@ -62,6 +61,9 @@ type
|
|||||||
procedure WMSetFocus(var Message: TLMSetFocus); message LM_SETFOCUS;
|
procedure WMSetFocus(var Message: TLMSetFocus); message LM_SETFOCUS;
|
||||||
procedure WMKillFocus(var Message: TLMKillFocus); message LM_KILLFOCUS;
|
procedure WMKillFocus(var Message: TLMKillFocus); message LM_KILLFOCUS;
|
||||||
protected
|
protected
|
||||||
|
procedure CheckButtonVisible;
|
||||||
|
function CalcButtonVisible: boolean; virtual;
|
||||||
|
function CalcButtonEnabled: Boolean; virtual;
|
||||||
function GetReadOnly: Boolean; override;
|
function GetReadOnly: Boolean; override;
|
||||||
function GetDefaultGlyph: TBitmap; virtual;
|
function GetDefaultGlyph: TBitmap; virtual;
|
||||||
function GetDefaultGlyphName: String; virtual;
|
function GetDefaultGlyphName: String; virtual;
|
||||||
@ -573,11 +575,16 @@ begin
|
|||||||
Result := False;
|
Result := False;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCustomEditButton.CalcButtonVisible: boolean;
|
||||||
|
begin
|
||||||
|
Result := (csdesigning in ComponentState) or
|
||||||
|
(Visible and (Focused or not FButtonNeedsFocus));
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCustomEditButton.CheckButtonVisible;
|
procedure TCustomEditButton.CheckButtonVisible;
|
||||||
begin
|
begin
|
||||||
If Assigned(FButton) then
|
If Assigned(FButton) then
|
||||||
FButton.Visible:=(csdesigning in ComponentState) or
|
FButton.Visible:=CalcButtonVisible;
|
||||||
(Visible and (Focused or not FButtonNeedsFocus));
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomEditButton.SetButtonHint(const AValue: TTranslateString);
|
procedure TCustomEditButton.SetButtonHint(const AValue: TTranslateString);
|
||||||
@ -636,16 +643,14 @@ end;
|
|||||||
procedure TCustomEditButton.CMVisibleChanged(var Msg: TLMessage);
|
procedure TCustomEditButton.CMVisibleChanged(var Msg: TLMessage);
|
||||||
begin
|
begin
|
||||||
inherited CMVisibleChanged(Msg);
|
inherited CMVisibleChanged(Msg);
|
||||||
|
|
||||||
CheckButtonVisible;
|
CheckButtonVisible;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomEditButton.CMEnabledChanged(var Msg: TLMessage);
|
procedure TCustomEditButton.CMEnabledChanged(var Msg: TLMessage);
|
||||||
begin
|
begin
|
||||||
inherited CMEnabledChanged(Msg);
|
inherited CMEnabledChanged(Msg);
|
||||||
|
if (FButton<>nil) then
|
||||||
if (FButton<>nil) and (not ReadOnly) then
|
FButton.Enabled:=CalcButtonEnabled;
|
||||||
FButton.Enabled:=Enabled;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomEditButton.GetMinHeight: Integer;
|
function TCustomEditButton.GetMinHeight: Integer;
|
||||||
@ -663,14 +668,13 @@ end;
|
|||||||
procedure TCustomEditButton.Loaded;
|
procedure TCustomEditButton.Loaded;
|
||||||
begin
|
begin
|
||||||
inherited Loaded;
|
inherited Loaded;
|
||||||
CheckButtonVisible;
|
|
||||||
DoPositionButton;
|
DoPositionButton;
|
||||||
|
CheckButtonVisible;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomEditButton.WMKillFocus(var Message: TLMKillFocus);
|
procedure TCustomEditButton.WMKillFocus(var Message: TLMKillFocus);
|
||||||
begin
|
begin
|
||||||
if FButtonNeedsFocus then
|
CheckButtonVisible;
|
||||||
FButton.Visible:=False;
|
|
||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -689,11 +693,16 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCustomEditButton.CalcButtonEnabled: Boolean;
|
||||||
|
begin
|
||||||
|
Result := not FIsReadOnly and Enabled;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCustomEditButton.SetReadOnly(AValue: Boolean);
|
procedure TCustomEditButton.SetReadOnly(AValue: Boolean);
|
||||||
begin
|
begin
|
||||||
FIsReadOnly := AValue;
|
FIsReadOnly := AValue;
|
||||||
if Assigned(FButton) then
|
if Assigned(FButton) then
|
||||||
FButton.Enabled := not FIsReadOnly and Enabled;
|
FButton.Enabled := CalcButtonEnabled;
|
||||||
inherited SetReadOnly(FIsReadOnly or (not DirectInput));
|
inherited SetReadOnly(FIsReadOnly or (not DirectInput));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -701,13 +710,12 @@ procedure TCustomEditButton.DoPositionButton;
|
|||||||
begin
|
begin
|
||||||
if FButton = nil then exit;
|
if FButton = nil then exit;
|
||||||
FButton.Parent := Parent;
|
FButton.Parent := Parent;
|
||||||
FButton.Visible := Visible;
|
|
||||||
FButton.AnchorToCompanion(akLeft,0,Self);
|
FButton.AnchorToCompanion(akLeft,0,Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomEditButton.WMSetFocus(var Message: TLMSetFocus);
|
procedure TCustomEditButton.WMSetFocus(var Message: TLMSetFocus);
|
||||||
begin
|
begin
|
||||||
FButton.Visible:=True;
|
CheckButtonVisible;
|
||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user