LCL: TPanel: fixed AdjustClientRect

git-svn-id: trunk@23915 -
This commit is contained in:
mattias 2010-03-10 12:04:34 +00:00
parent 51501edffa
commit a146e3b1e7
2 changed files with 21 additions and 12 deletions

View File

@ -1069,7 +1069,7 @@ type
procedure SetBevelWidth(const Value: TBevelWidth); procedure SetBevelWidth(const Value: TBevelWidth);
protected protected
class procedure WSRegisterClass; override; class procedure WSRegisterClass; override;
procedure AdjustClientRect(var Rect: TRect); override; procedure AdjustClientRect(var aRect: TRect); override;
class function GetControlClassDefaultSize: TPoint; override; class function GetControlClassDefaultSize: TPoint; override;
procedure CMParentColorChanged(var Message: TLMessage); message CM_PARENTCOLORCHANGED; procedure CMParentColorChanged(var Message: TLMessage); message CM_PARENTCOLORCHANGED;
function GetDefaultDockCaption: String; override; function GetDefaultDockCaption: String; override;

View File

@ -94,14 +94,16 @@ var
TS : TTextStyle; TS : TTextStyle;
begin begin
ARect := GetClientRect; ARect := GetClientRect;
if BevelOuter <> bvNone then // if BevelOuter is set then draw a frame with BevelWidth
Canvas.Frame3d(ARect, BevelWidth, BevelOuter); if (BevelOuter <> bvNone) and (BevelWidth>0) then
Canvas.Frame3d(ARect, BevelWidth, BevelOuter); // Note: Frame3D inflates ARect
if BevelInner <> bvNone then // if BevelInner is set then skip the BorderWidth and draw a frame with BevelWidth
if (BevelInner <> bvNone) and (BevelWidth>0) then
begin begin
if BorderWidth > 0 then if BorderWidth > 0 then
InflateRect(ARect, -BorderWidth, -BorderWidth); InflateRect(ARect, -BorderWidth, -BorderWidth);
Canvas.Frame3d(ARect, BevelWidth, BevelInner); Canvas.Frame3d(ARect, BevelWidth, BevelInner); // Note: Frame3D inflates ARect
end; end;
if Caption <> '' then if Caption <> '' then
@ -129,17 +131,24 @@ begin
inherited Paint; inherited Paint;
end; end;
procedure TCustomPanel.AdjustClientRect(var Rect: TRect); procedure TCustomPanel.AdjustClientRect(var aRect: TRect);
var var
BevelSize: Integer; BevelSize: Integer;
begin begin
inherited AdjustClientRect(Rect); inherited AdjustClientRect(aRect);
BevelSize := BorderWidth; BevelSize:=0;
if BevelOuter <> bvNone then // if BevelOuter is set then draw a frame with BevelWidth
if (BevelOuter <> bvNone) and (BevelWidth > 0) then
inc(BevelSize, BevelWidth);
// if BevelInner is set then skip the BorderWidth and draw a frame with BevelWidth
if (BevelInner <> bvNone) and (BevelWidth > 0) then
begin
if BorderWidth > 0 then
Inc(BevelSize, BorderWidth);
Inc(BevelSize, BevelWidth); Inc(BevelSize, BevelWidth);
if BevelInner <> bvNone then end;
Inc(BevelSize, BevelWidth); InflateRect(aRect, -BevelSize, -BevelSize);
InflateRect(Rect, -BevelSize, -BevelSize);
end; end;
class function TCustomPanel.GetControlClassDefaultSize: TPoint; class function TCustomPanel.GetControlClassDefaultSize: TPoint;