LCL: Added TGraphicControl.VisuallyEnabled to track if control is really visually enabled (eg Enabled=True but Parent is disabled) during checking Enabled property inside paint and mouse methods.fixes issue #20247

git-svn-id: trunk@32393 -
This commit is contained in:
zeljko 2011-09-17 19:42:30 +00:00
parent 1cb835eb35
commit b21be873d3
4 changed files with 25 additions and 8 deletions

View File

@ -2017,6 +2017,7 @@ type
procedure WMPaint(var Message: TLMPaint); message LM_PAINT;
protected
class procedure WSRegisterClass; override;
function VisuallyEnabled: Boolean;
procedure FontChanged(Sender: TObject); override;
procedure Paint; virtual;
procedure DoOnChangeBounds; override;

View File

@ -412,7 +412,7 @@ begin
R := Rect(0,0,Width,Height);
with Canvas do
begin
if Enabled then
if VisuallyEnabled then
Brush.Color := Self.Color
else
Brush.Color := clNone;
@ -463,7 +463,7 @@ begin
//debugln('TCustomLabel.Paint ',dbgs(Alignment=tacenter),' ',dbgs(Layout=tlCenter),' ',dbgs(TextLeft),' TextTop=',dbgs(TextTop),' ',dbgs(R));
LabelText := GetLabelText;
OldFontColor := Font.Color;
if not Enabled then
if not VisuallyEnabled then
begin
Font.Color := clBtnHighlight;
TextRect(R, TextLeft + 1, TextTop + 1, LabelText, TR);

View File

@ -77,6 +77,22 @@ begin
RegisterGraphicControl;
end;
{------------------------------------------------------------------------------
Method: TGraphicControl.VisuallyEnabled
Params: none
Returns: Boolean
Returns True only if both TGraphicControl and it's parent are enabled.
Used internally by TGraphicControls for painting and various states during
runtime.
------------------------------------------------------------------------------}
function TGraphicControl.VisuallyEnabled: Boolean;
begin
Result := Enabled;
if Result and Assigned(Parent) then
Result := Result and Parent.Enabled;
end;
procedure TGraphicControl.FontChanged(Sender: TObject);
begin
Canvas.Font:=Font;

View File

@ -291,7 +291,7 @@ var
OldState: TButtonState;
begin
OldState := FState;
if not Enabled then
if not VisuallyEnabled then
begin
FState := bsDisabled;
FDragging := False;
@ -339,7 +339,7 @@ function TCustomSpeedButton.GetDrawDetails: TThemedElementDetails;
// no check states available
Result := tbPushButtonNormal;
if not Enabled then
if not VisuallyEnabled then
Result := tbPushButtonDisabled
else
if FState in [bsDown, bsExclusive] then
@ -355,7 +355,7 @@ function TCustomSpeedButton.GetDrawDetails: TThemedElementDetails;
begin
// ttbButtonNormal, ttbButtonHot, ttbButtonPressed, ttbButtonDisabled
// ttbButtonChecked, ttbButtonCheckedHot
if not Enabled then
if not VisuallyEnabled then
Result := ttbButtonDisabled
else
begin
@ -738,7 +738,7 @@ begin
inherited MouseDown(Button, Shift, X, Y);
if csDesigning in ComponentState then exit;
if (Button = mbLeft) and Enabled then
if (Button = mbLeft) and VisuallyEnabled then
begin
if not FDown then
begin
@ -1053,7 +1053,7 @@ end;
procedure TCustomSpeedButton.MouseEnter;
begin
if csDesigning in ComponentState then exit;
if not FMouseInControl and Enabled and (GetCapture = 0) then
if not FMouseInControl and VisuallyEnabled and (GetCapture = 0) then
begin
FMouseInControl := True;
UpdateState(true);
@ -1074,7 +1074,7 @@ begin
if FMouseInControl then
begin
FMouseInControl := False;
if Enabled then
if VisuallyEnabled then
begin
if FDragging and (not MouseCapture) then
begin