From 936b420ba87bcd23806e5f1d09a8ded90110b1bc Mon Sep 17 00:00:00 2001 From: sekelsenmat Date: Thu, 3 Nov 2011 21:00:52 +0000 Subject: [PATCH] customdrawn: Adds a client area getter git-svn-id: trunk@33271 - --- components/customdrawn/customdrawn_common.pas | 31 +++++++++++++++---- .../customdrawn/customdrawncontrols.pas | 12 ++++--- components/customdrawn/customdrawndrawers.pas | 2 ++ 3 files changed, 34 insertions(+), 11 deletions(-) diff --git a/components/customdrawn/customdrawn_common.pas b/components/customdrawn/customdrawn_common.pas index cb1af57d1e..1071aa0fd1 100644 --- a/components/customdrawn/customdrawn_common.pas +++ b/components/customdrawn/customdrawn_common.pas @@ -28,6 +28,8 @@ type AState: TCDControlState; AStateEx: TCDControlStateEx; var PreferredWidth, PreferredHeight: integer; WithThemeSpace: Boolean); override; function GetColor(AColorID: Integer): TColor; override; + function GetClientArea(ADest: TCanvas; ASize: TSize; AControlId: TCDControlID; + AState: TCDControlState; AStateEx: TCDControlStateEx): TRect; override; procedure DrawControl(ADest: TCanvas; ADestPos: TPoint; ASize: TSize; AControl: TCDControlID; AState: TCDControlState; AStateEx: TCDControlStateEx); override; // =================================== @@ -91,7 +93,7 @@ begin TCDCONTROL_CAPTION_HEIGHT: Result := ADest.TextHeight('ŹÇ')+3; TCDCTABCONTROL_TAB_HEIGHT: begin - if AStateEx.Font.Size = 0 then Result := 22 + if AStateEx.Font.Size = 0 then Result := ADest.TextHeight('Z')+14 else Result := AStateEx.Font.Size + 14; end; TCDCTABCONTROL_TAB_WIDTH: @@ -135,6 +137,23 @@ begin end; end; +function TCDDrawerCommon.GetClientArea(ADest: TCanvas; ASize: TSize; + AControlId: TCDControlID; AState: TCDControlState; AStateEx: TCDControlStateEx + ): TRect; +begin + Result := Bounds(0, 0, ASize.cx, ASize.cy); + + case AControlId of + cidCTabControl: + begin + Result.Top := GetMeasuresEx(ADest, TCDCTABCONTROL_TAB_HEIGHT, AState, AStateEx) + 2; + Result.Left := 2; + Result.Right := Result.Right - 2; + Result.Bottom := Result.Bottom - 2; + end; + end; +end; + procedure TCDDrawerCommon.DrawControl(ADest: TCanvas; ADestPos: TPoint; ASize: TSize; AControl: TCDControlID; AState: TCDControlState; AStateEx: TCDControlStateEx); @@ -495,8 +514,8 @@ begin ADest.Brush.Color := clWhite; SetLength(Points, 5); Points[0] := Point(AStateEx.CurStartLeftPos, lTabTopPos); - Points[1] := Point(AStateEx.CurStartLeftPos+lTabWidth-5, lTabTopPos); - Points[2] := Point(AStateEx.CurStartLeftPos+lTabWidth, lTabTopPos+5); + Points[1] := Point(AStateEx.CurStartLeftPos+lTabWidth-2, lTabTopPos); + Points[2] := Point(AStateEx.CurStartLeftPos+lTabWidth, lTabTopPos+2); Points[3] := Point(AStateEx.CurStartLeftPos+lTabWidth, lTabTopPos+lTabHeight); Points[4] := Point(AStateEx.CurStartLeftPos, lTabTopPos+lTabHeight); ADest.Polygon(Points); @@ -505,9 +524,9 @@ begin ADest.Pen.Style := psSolid; ADest.Brush.Style := bsClear; ADest.Pen.Color := ColorToRGB($009C9B91); - ADest.MoveTo(AStateEx.CurStartLeftPos+1, lTabTopPos); - ADest.LineTo(AStateEx.CurStartLeftPos+lTabWidth-5, lTabTopPos); - ADest.LineTo(AStateEx.CurStartLeftPos+lTabWidth, lTabTopPos+5); + ADest.MoveTo(AStateEx.CurStartLeftPos, lTabTopPos); + ADest.LineTo(AStateEx.CurStartLeftPos+lTabWidth-2, lTabTopPos); + ADest.LineTo(AStateEx.CurStartLeftPos+lTabWidth, lTabTopPos+2); ADest.LineTo(AStateEx.CurStartLeftPos+lTabWidth, lTabTopPos+lTabHeight); if IsSelected then diff --git a/components/customdrawn/customdrawncontrols.pas b/components/customdrawn/customdrawncontrols.pas index 440fbf8ec9..c5b910999d 100644 --- a/components/customdrawn/customdrawncontrols.pas +++ b/components/customdrawn/customdrawncontrols.pas @@ -1518,16 +1518,18 @@ end; procedure TCDPageControl.PositionTabSheet(ATabSheet: TCDTabSheet); var lTabHeight, lIndex: Integer; + lClientArea: TRect; begin lIndex := FTabs.IndexOfObject(ATabSheet); FTabCState.TabIndex := lIndex; PrepareControlState; PrepareControlStateEx; - lTabHeight := FDrawer.GetMeasuresEx(Canvas, TCDCTABCONTROL_TAB_HEIGHT, FState, FStateEx); - ATabSheet.BorderSpacing.Top := lTabHeight; - ATabSheet.BorderSpacing.Left := 2; - ATabSheet.BorderSpacing.Right := 3; - ATabSheet.BorderSpacing.Bottom := 3; + lClientArea := FDrawer.GetClientArea(Canvas, Size(Width, Height), GetControlId, FState, FStateEx); + + ATabSheet.BorderSpacing.Top := lClientArea.Top; + ATabSheet.BorderSpacing.Left := lClientArea.Left; + ATabSheet.BorderSpacing.Right := Width - lClientArea.Right; + ATabSheet.BorderSpacing.Bottom := Height - lClientArea.Bottom; ATabSheet.Align := alClient; end; diff --git a/components/customdrawn/customdrawndrawers.pas b/components/customdrawn/customdrawndrawers.pas index 7b1fecd30f..ac24b29697 100644 --- a/components/customdrawn/customdrawndrawers.pas +++ b/components/customdrawn/customdrawndrawers.pas @@ -151,6 +151,8 @@ type AState: TCDControlState; AStateEx: TCDControlStateEx; var PreferredWidth, PreferredHeight: integer; WithThemeSpace: Boolean); virtual; abstract; function GetColor(AColorID: Integer): TColor; virtual; abstract; + function GetClientArea(ADest: TCanvas; ASize: TSize; AControlId: TCDControlID; + AState: TCDControlState; AStateEx: TCDControlStateEx): TRect; virtual; abstract; procedure DrawControl(ADest: TCanvas; ADestPos: TPoint; ASize: TSize; AControl: TCDControlID; AState: TCDControlState; AStateEx: TCDControlStateEx); virtual; abstract; // TCDButton