customdrawn: Many fixes for dsCommon support for CTabControl

git-svn-id: trunk@33329 -
This commit is contained in:
sekelsenmat 2011-11-05 10:03:57 +00:00
parent e586e7c43d
commit 328db6815a
3 changed files with 94 additions and 116 deletions

View File

@ -70,6 +70,8 @@ type
// TCDCustomTabControl // TCDCustomTabControl
procedure DrawCTabControl(ADest: TCanvas; ADestPos: TPoint; ASize: TSize; procedure DrawCTabControl(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
AState: TCDControlState; AStateEx: TCDCTabControlStateEx); override; AState: TCDControlState; AStateEx: TCDCTabControlStateEx); override;
procedure DrawCTabControlFrame(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
AState: TCDControlState; AStateEx: TCDCTabControlStateEx); override;
procedure DrawTabSheet(ADest: TCanvas; ADestPos: TPoint; ASize: TSize; procedure DrawTabSheet(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
AState: TCDControlState; AStateEx: TCDCTabControlStateEx); override; AState: TCDControlState; AStateEx: TCDCTabControlStateEx); override;
procedure DrawTabs(ADest: TCanvas; ADestPos: TPoint; ASize: TSize; procedure DrawTabs(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
@ -218,7 +220,28 @@ end;
procedure TCDDrawerCommon.DrawRaisedFrame(ADest: TCanvas; ADestPos: TPoint; procedure TCDDrawerCommon.DrawRaisedFrame(ADest: TCanvas; ADestPos: TPoint;
ASize: TSize); ASize: TSize);
begin begin
// white lines in the left and top
ADest.Pen.Style := psSolid;
ADest.Brush.Style := bsClear;
ADest.Pen.Color := WIN2000_FRAME_WHITE;
ADest.MoveTo(ADestPos.X, ADestPos.Y+ASize.cy-1);
ADest.LineTo(ADestPos.X, ADestPos.Y);
ADest.LineTo(ADestPos.X+ASize.cy-1, ADestPos.Y);
// Grey line on the inside left and top
ADest.Pen.Color := WIN2000_FRAME_LIGHT_GRAY;
ADest.MoveTo(ADestPos.X+1, ADestPos.Y+ASize.cy-2);
ADest.LineTo(ADestPos.X+1, ADestPos.Y+1);
ADest.LineTo(ADestPos.X+ASize.cx-1, ADestPos.Y+1);
// Dark grey line on the right and bottom
ADest.Pen.Color := WIN2000_FRAME_DARK_GRAY;
ADest.MoveTo(ADestPos.X, ADestPos.Y+ASize.cy-1);
ADest.LineTo(ADestPos.X+ASize.cx-1, ADestPos.Y+ASize.cy-1);
ADest.LineTo(ADestPos.X+ASize.cx-1, ADestPos.Y);
// Grey line on the inside right and bottom
ADest.Pen.Color := WIN2000_FRAME_GRAY;
ADest.MoveTo(ADestPos.X+1, ADestPos.Y+ASize.cy-2);
ADest.LineTo(ADestPos.X+ASize.cx-2, ADestPos.Y+ASize.cy-2);
ADest.LineTo(ADestPos.X+ASize.cx-2, ADestPos.Y-1);
end; end;
procedure TCDDrawerCommon.DrawSunkenFrame(ADest: TCanvas; ADestPos: TPoint; procedure TCDDrawerCommon.DrawSunkenFrame(ADest: TCanvas; ADestPos: TPoint;
@ -551,8 +574,6 @@ end;
procedure TCDDrawerCommon.DrawCTabControl(ADest: TCanvas; ADestPos: TPoint; procedure TCDDrawerCommon.DrawCTabControl(ADest: TCanvas; ADestPos: TPoint;
ASize: TSize; AState: TCDControlState; AStateEx: TCDCTabControlStateEx); ASize: TSize; AState: TCDControlState; AStateEx: TCDCTabControlStateEx);
var
CaptionHeight: Integer;
begin begin
// Background // Background
ADest.Pen.Style := psSolid; ADest.Pen.Style := psSolid;
@ -562,34 +583,25 @@ begin
ADest.Rectangle(ADestPos.X, ADestPos.Y, ADestPos.X+ASize.cx, ADestPos.Y+ASize.cy); ADest.Rectangle(ADestPos.X, ADestPos.Y, ADestPos.X+ASize.cx, ADestPos.Y+ASize.cy);
// frame // frame
if AStateEx.TabCount = 0 then CaptionHeight := 0 DrawCTabControlFrame(ADest, ADestPos, ASize, AState, AStateEx);
else CaptionHeight := GetMeasuresEx(ADest, TCDCTABCONTROL_TAB_HEIGHT, AState, AStateEx);
// white lines in the left and top
ADest.Pen.Style := psSolid;
ADest.Brush.Style := bsClear;
ADest.Pen.Color := WIN2000_FRAME_WHITE;
ADest.Line(0, CaptionHeight, 0, ASize.cy-1);
ADest.Pixels[1,1] := clWhite;
ADest.Line(2, CaptionHeight, ASize.cx-1, CaptionHeight);
// Grey line on the inside left and top
ADest.Pen.Color := WIN2000_FRAME_LIGHT_GRAY;
ADest.Line(1, CaptionHeight, 1, ASize.cy-2);
ADest.Line(2, CaptionHeight+1, ASize.cx-2, CaptionHeight+1);
// Dark grey line on the right and bottom
ADest.Pen.Color := WIN2000_FRAME_DARK_GRAY;
ADest.Line(0, ASize.cy, ASize.cx, ASize.cy);
ADest.Line(ASize.cx, ASize.cy, ASize.cx, CaptionHeight);
// Grey line on the inside right and bottom
ADest.Pen.Color := WIN2000_FRAME_GRAY;
ADest.Line(1, ASize.cy-1, ASize.cx-1, ASize.cy-1);
ADest.Line(ASize.cx-1, ASize.cy-1, ASize.cx-1, CaptionHeight);
// Tabs // Tabs
ADest.Font.Assign(AStateEx.Font); ADest.Font.Assign(AStateEx.Font);
DrawTabs(ADest, ADestPos, ASize, AState, AStateEx); DrawTabs(ADest, ADestPos, ASize, AState, AStateEx);
end; end;
procedure TCDDrawerCommon.DrawCTabControlFrame(ADest: TCanvas;
ADestPos: TPoint; ASize: TSize; AState: TCDControlState;
AStateEx: TCDCTabControlStateEx);
var
CaptionHeight: Integer;
begin
if AStateEx.TabCount = 0 then CaptionHeight := 0
else CaptionHeight := GetMeasuresEx(ADest, TCDCTABCONTROL_TAB_HEIGHT, AState, AStateEx);
DrawRaisedFrame(ADest, Point(0, CaptionHeight), Size(ASize.cx, ASize.cy-CaptionHeight));
end;
procedure TCDDrawerCommon.DrawTabSheet(ADest: TCanvas; ADestPos: TPoint; procedure TCDDrawerCommon.DrawTabSheet(ADest: TCanvas; ADestPos: TPoint;
ASize: TSize; AState: TCDControlState; AStateEx: TCDCTabControlStateEx); ASize: TSize; AState: TCDControlState; AStateEx: TCDCTabControlStateEx);
begin begin
@ -629,35 +641,50 @@ var
Points: array of TPoint; Points: array of TPoint;
lCaption: String; lCaption: String;
lTabHeightCorrection: Integer = 0; lTabHeightCorrection: Integer = 0;
lTabRightBorderExtraHeight: Integer = 0;
begin begin
IsSelected := AStateEx.TabIndex = AStateEx.CurTabIndex; IsSelected := AStateEx.TabIndex = AStateEx.CurTabIndex;
if not IsSelected then lTabHeightCorrection := 3; if not IsSelected then lTabHeightCorrection := 3;
if IsSelected then lTabRightBorderExtraHeight := 1;
lTabTopPos := lTabHeightCorrection; lTabTopPos := lTabHeightCorrection;
lTabHeight := GetMeasuresEx(ADest, TCDCTABCONTROL_TAB_HEIGHT, AState, AStateEx)-lTabHeightCorrection; lTabHeight := GetMeasuresEx(ADest, TCDCTABCONTROL_TAB_HEIGHT, AState, AStateEx)-lTabHeightCorrection;
lTabWidth := GetMeasuresEx(ADest, TCDCTABCONTROL_TAB_WIDTH, AState, AStateEx); lTabWidth := GetMeasuresEx(ADest, TCDCTABCONTROL_TAB_WIDTH, AState, AStateEx);
// Fill the area inside the outer border // Fill the area inside the outer border
ADest.Pen.Style := psClear; // And at the same time fill the white border (part of it will be erased later)
ADest.Pen.Style := psSolid;
ADest.Pen.Color := WIN2000_FRAME_WHITE;
ADest.Brush.Style := bsSolid; ADest.Brush.Style := bsSolid;
ADest.Brush.Color := clWhite; ADest.Brush.Color := AStateEx.RGBColor;
SetLength(Points, 5); SetLength(Points, 6);
Points[0] := Point(AStateEx.CurStartLeftPos, lTabTopPos); Points[0] := Point(AStateEx.CurStartLeftPos, lTabTopPos+lTabHeight);
Points[1] := Point(AStateEx.CurStartLeftPos+lTabWidth-2, lTabTopPos); Points[1] := Point(AStateEx.CurStartLeftPos, lTabTopPos+2);
Points[2] := Point(AStateEx.CurStartLeftPos+lTabWidth, lTabTopPos+2); Points[2] := Point(AStateEx.CurStartLeftPos+2, lTabTopPos);
Points[3] := Point(AStateEx.CurStartLeftPos+lTabWidth, lTabTopPos+lTabHeight); Points[3] := Point(AStateEx.CurStartLeftPos+lTabWidth-3, lTabTopPos);
Points[4] := Point(AStateEx.CurStartLeftPos, lTabTopPos+lTabHeight); Points[4] := Point(AStateEx.CurStartLeftPos+lTabWidth-1, lTabTopPos+2);
Points[5] := Point(AStateEx.CurStartLeftPos+lTabWidth-1, lTabTopPos+lTabHeight);
ADest.Polygon(Points); ADest.Polygon(Points);
// Draw the outer border only in the top and right sides, // Draw the inner border of the top and right sides,
ADest.Pen.Style := psSolid; ADest.Pen.Style := psSolid;
ADest.Brush.Style := bsClear; ADest.Brush.Style := bsClear;
ADest.Pen.Color := ColorToRGB($009C9B91); ADest.Pen.Color := WIN2000_FRAME_LIGHT_GRAY;
ADest.MoveTo(AStateEx.CurStartLeftPos, lTabTopPos); ADest.MoveTo(AStateEx.CurStartLeftPos+1, lTabTopPos+lTabHeight-1);
ADest.LineTo(AStateEx.CurStartLeftPos+lTabWidth-2, lTabTopPos); ADest.LineTo(AStateEx.CurStartLeftPos+1, lTabTopPos+2);
ADest.LineTo(AStateEx.CurStartLeftPos+lTabWidth, lTabTopPos+2); ADest.LineTo(AStateEx.CurStartLeftPos+2, lTabTopPos+1);
ADest.LineTo(AStateEx.CurStartLeftPos+lTabWidth, lTabTopPos+lTabHeight); ADest.LineTo(AStateEx.CurStartLeftPos+lTabWidth-3, lTabTopPos+1);
// Draw the inner border of the right side
ADest.Pen.Color := WIN2000_FRAME_GRAY;
ADest.MoveTo(AStateEx.CurStartLeftPos+lTabWidth-2, lTabTopPos+2);
ADest.LineTo(AStateEx.CurStartLeftPos+lTabWidth-2, lTabTopPos+lTabHeight+lTabRightBorderExtraHeight);
// Draw the outter border of the right side
ADest.Pen.Color := WIN2000_FRAME_DARK_GRAY;
ADest.MoveTo(AStateEx.CurStartLeftPos+lTabWidth-1, lTabTopPos+2);
ADest.LineTo(AStateEx.CurStartLeftPos+lTabWidth-1, lTabTopPos+lTabHeight+lTabRightBorderExtraHeight);
ADest.Pixels[AStateEx.CurStartLeftPos+lTabWidth-2, lTabTopPos+1] := WIN2000_FRAME_DARK_GRAY;
if IsSelected then if IsSelected then
begin begin
@ -666,11 +693,12 @@ begin
Size(lTabWidth-8, lTabHeight-6)); Size(lTabWidth-8, lTabHeight-6));
// and Clear the bottom area if selected // and Clear the bottom area if selected
ADest.Pen.Style := psSolid;
ADest.Pen.Color := AStateEx.RGBColor; ADest.Pen.Color := AStateEx.RGBColor;
ADest.Line(AStateEx.CurStartLeftPos, lTabTopPos+lTabHeight, ADest.Line(AStateEx.CurStartLeftPos+1, lTabTopPos+lTabHeight,
AStateEx.CurStartLeftPos+lTabWidth, lTabTopPos+lTabHeight); AStateEx.CurStartLeftPos+lTabWidth-2, lTabTopPos+lTabHeight);
ADest.Line(AStateEx.CurStartLeftPos, lTabTopPos+lTabHeight-1, ADest.Line(AStateEx.CurStartLeftPos+1, lTabTopPos+lTabHeight+1,
AStateEx.CurStartLeftPos+lTabWidth-2, lTabTopPos+lTabHeight-1); AStateEx.CurStartLeftPos+lTabWidth-2, lTabTopPos+lTabHeight+1);
end; end;
// Now the text // Now the text

View File

@ -24,6 +24,9 @@ type
public public
procedure LoadFallbackPaletteColors; override; procedure LoadFallbackPaletteColors; override;
function GetDrawStyle: TCDDrawStyle; override; function GetDrawStyle: TCDDrawStyle; override;
// General drawing routines
procedure DrawRaisedFrame(ADest: TCanvas; ADestPos: TPoint; ASize: TSize); override;
procedure DrawSunkenFrame(ADest: TCanvas; ADestPos: TPoint; ASize: TSize); override;
// =================================== // ===================================
// Standard Tab // Standard Tab
// =================================== // ===================================
@ -42,12 +45,6 @@ type
// Common Controls Tab // Common Controls Tab
// =================================== // ===================================
// TCDCustomTabControl // TCDCustomTabControl
procedure DrawCTabControl(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
AState: TCDControlState; AStateEx: TCDCTabControlStateEx); override;
procedure DrawTabSheet(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
AState: TCDControlState; AStateEx: TCDCTabControlStateEx); override;
procedure DrawTabs(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
AState: TCDControlState; AStateEx: TCDCTabControlStateEx); override;
procedure DrawTab(ADest: TCanvas; ADestPos: TPoint; ASize: TSize; procedure DrawTab(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
AState: TCDControlState; AStateEx: TCDCTabControlStateEx); override; AState: TCDControlState; AStateEx: TCDCTabControlStateEx); override;
end; end;
@ -66,6 +63,24 @@ begin
Result := dsWinCE; Result := dsWinCE;
end; end;
procedure TCDDrawerWinCE.DrawRaisedFrame(ADest: TCanvas; ADestPos: TPoint;
ASize: TSize);
begin
ADest.Pen.Style := psSolid;
ADest.Brush.Style := bsClear;
ADest.Pen.Color := clBlack;
ADest.Rectangle(Bounds(ADestPos.X, ADestPos.Y, ASize.cx, ASize.cy));
end;
procedure TCDDrawerWinCE.DrawSunkenFrame(ADest: TCanvas; ADestPos: TPoint;
ASize: TSize);
begin
ADest.Pen.Style := psSolid;
ADest.Brush.Style := bsClear;
ADest.Pen.Color := clBlack;
ADest.Rectangle(Bounds(ADestPos.X, ADestPos.Y, ASize.cx, ASize.cy));
end;
procedure TCDDrawerWinCE.DrawButton(ADest: TCanvas; ADestPos: TPoint; procedure TCDDrawerWinCE.DrawButton(ADest: TCanvas; ADestPos: TPoint;
ASize: TSize; AState: TCDControlState; AStateEx: TCDControlStateEx); ASize: TSize; AState: TCDControlState; AStateEx: TCDControlStateEx);
var var
@ -169,73 +184,6 @@ begin
end; end;
end; end;
procedure TCDDrawerWinCE.DrawCTabControl(ADest: TCanvas; ADestPos: TPoint;
ASize: TSize; AState: TCDControlState; AStateEx: TCDCTabControlStateEx);
var
CaptionHeight: Integer;
begin
// Background
ADest.Pen.Style := psSolid;
ADest.Pen.Color := AStateEx.ParentRGBColor;
ADest.Brush.Style := bsSolid;
ADest.Brush.Color := AStateEx.ParentRGBColor;
ADest.Rectangle(ADestPos.X, ADestPos.Y, ADestPos.X+ASize.cx, ADestPos.Y+ASize.cy);
CaptionHeight := GetMeasuresEx(ADest, TCDCTABCONTROL_TAB_HEIGHT, AState, AStateEx);
// frame
ADest.Pen.Style := psSolid;
ADest.Brush.Style := bsClear;
ADest.Pen.Color := ColorToRGB($009C9B91);
if AStateEx.TabCount = 0 then
ADest.Rectangle(0, 0, ASize.cx - 2, ASize.cy - 2)
else
ADest.Rectangle(0, CaptionHeight, ASize.cx - 2, ASize.cy - 2);
ADest.Pen.Color := ColorToRGB($00BFCED0);
ADest.Line(ASize.cx - 1, CaptionHeight + 1,
ASize.cx - 1, ASize.cy - 1);
ADest.Line(ASize.cx - 1, ASize.cy - 1, 1,
ASize.cy - 1);
// Tabs
ADest.Font.Name := AStateEx.Font.Name;
ADest.Font.Size := AStateEx.Font.Size;
DrawTabs(ADest, ADestPos, ASize, AState, AStateEx);
end;
procedure TCDDrawerWinCE.DrawTabSheet(ADest: TCanvas; ADestPos: TPoint;
ASize: TSize; AState: TCDControlState; AStateEx: TCDCTabControlStateEx);
begin
ADest.Brush.Color := AStateEx.RGBColor;
ADest.Brush.Style := bsSolid;
ADest.Pen.Style := psSolid;
ADest.Pen.Color := AStateEx.RGBColor;
ADest.Rectangle(0, 0, ASize.cx, ASize.cy);
end;
procedure TCDDrawerWinCE.DrawTabs(ADest: TCanvas; ADestPos: TPoint;
ASize: TSize; AState: TCDControlState; AStateEx: TCDCTabControlStateEx);
var
IsPainting: Boolean = False;
i: Integer;
begin
AStateEx.CurStartLeftPos := 0;
for i := 0 to AStateEx.Tabs.Count - 1 do
begin
if i = AStateEx.LeftmostTabVisibleIndex then
IsPainting := True;
if IsPainting then
begin
AStateEx.CurTabIndex := i;
DrawTab(ADest, ADestPos, ASize, AState, AStateEx);
AStateEx.CurStartLeftPos := AStateEx.CurStartLeftPos + GetMeasuresEx(ADest, TCDCTABCONTROL_TAB_WIDTH, AState, AStateEx);
end;
end;
end;
procedure TCDDrawerWinCE.DrawTab(ADest: TCanvas; ADestPos: TPoint; procedure TCDDrawerWinCE.DrawTab(ADest: TCanvas; ADestPos: TPoint;
ASize: TSize; AState: TCDControlState; AStateEx: TCDCTabControlStateEx); ASize: TSize; AState: TCDControlState; AStateEx: TCDCTabControlStateEx);
var var

View File

@ -226,6 +226,8 @@ type
// TCDCustomTabControl // TCDCustomTabControl
procedure DrawCTabControl(ADest: TCanvas; ADestPos: TPoint; ASize: TSize; procedure DrawCTabControl(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
AState: TCDControlState; AStateEx: TCDCTabControlStateEx); virtual; abstract; AState: TCDControlState; AStateEx: TCDCTabControlStateEx); virtual; abstract;
procedure DrawCTabControlFrame(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
AState: TCDControlState; AStateEx: TCDCTabControlStateEx); virtual; abstract;
procedure DrawTabSheet(ADest: TCanvas; ADestPos: TPoint; ASize: TSize; procedure DrawTabSheet(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
AState: TCDControlState; AStateEx: TCDCTabControlStateEx); virtual; abstract; AState: TCDControlState; AStateEx: TCDCTabControlStateEx); virtual; abstract;
procedure DrawTabs(ADest: TCanvas; ADestPos: TPoint; ASize: TSize; procedure DrawTabs(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;