customdrawn: Many small fixes, mostly for design time and controls impacted by the rewrite

git-svn-id: trunk@33262 -
This commit is contained in:
sekelsenmat 2011-11-03 13:26:50 +00:00
parent 574de4ecfd
commit 0abff19f7a
5 changed files with 80 additions and 706 deletions

View File

@ -7,10 +7,8 @@ interface
uses
// RTL
Classes, SysUtils, Types,
// fpimage
fpcanvas, fpimgcanv, fpimage,
// LCL -> Use only TForm, TWinControl, TCanvas and TLazIntfImage
Graphics, Controls, LCLType, LCLIntf, //IntfGraphics,
Graphics, Controls, LCLType,
// Others only for types
StdCtrls,
//
@ -372,7 +370,7 @@ begin
ADest.Rectangle(0, 0, ASize.cx, ASize.cy);
// frame
ADest.Pen.FPColor := colBlack;
ADest.Pen.Color := clBlack;
ADest.Pen.Style := psSolid;
ADest.Brush.Style := bsClear;
ADest.Rectangle(0, FCaptionMiddle, ASize.cx - 1, ASize.cy - 1);
@ -395,6 +393,13 @@ procedure TCDDrawerCommon.DrawCTabControl(ADest: TCanvas; ADestPos: TPoint;
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

View File

@ -145,12 +145,13 @@ begin
ADest.Brush.Color := AStateEx.ParentRGBColor;
ADest.Brush.Style := bsSolid;
ADest.Pen.Style := psClear;
ADest.Pen.Style := psSolid;
ADest.Pen.Color := AStateEx.ParentRGBColor;
ADest.Rectangle(0, 0, ASize.cx, ASize.cy);
ADest.Brush.Color := ColorToRGB($006BB6E6);
// Draws the double-sided arrow in the center of the slider
ADest.Brush.Color := ColorToRGB($006BB6E6);
ADest.Pen.Style := psSolid;
ADest.Pen.Color := ColorToRGB($006BB6E6);
ADest.Line(0, lDrawingBottom, ASize.cx, lDrawingBottom);
@ -194,29 +195,29 @@ begin
ADest.Brush.FPColor := TColorToFPColor(ColorToRGB($006BB6E6));
ADest.Brush.Style := bsSolid;
ADest.Rectangle(pStart, lDrawingBottom + 1, pStart + 10, lDrawingBottom + 6);
ADest.Pen.FPColor := TColorToFPColor(ColorToRGB($005BA6C6));
ADest.Pen.Color := ColorToRGB($005BA6C6);
ADest.RecTangle(pStart, lDrawingBottom + 2, pStart + 10, lDrawingBottom + 7);
ADest.Pen.FPColor := TColorToFPColor(ColorToRGB($006BB6E6));
ADest.Pen.Color := ColorToRGB($006BB6E6);
ADest.RecTangle(pStart, lDrawingBottom, pStart + 10, lDrawingBottom + 2);
end;
pStart := pStart + pStepWidth;
end;
ADest.Pen.FPColor := TColorToFPColor(ColorToRGB($007BC6F6));
ADest.Pen.Color := ColorToRGB($007BC6F6);
ADest.Line(7, lDrawingBottom - 1, ASize.cx - 8, lDrawingBottom - 1);
ADest.Line(7, lDrawingBottom + 1, ASize.cx - 8, lDrawingBottom + 1);
ADest.Colors[2, lDrawingBottom - 1] := ADest.Pen.FPColor;
ADest.Colors[4, lDrawingBottom - 2] := ADest.Pen.FPColor;
ADest.Colors[2, lDrawingBottom + 1] := ADest.Pen.FPColor;
ADest.Colors[4, lDrawingBottom + 2] := ADest.Pen.FPColor;
ADest.Colors[6, lDrawingBottom - 3] := ADest.Pen.FPColor;
ADest.Colors[6, lDrawingBottom + 3] := ADest.Pen.FPColor;
ADest.Colors[ASize.cx - 1 - 2, lDrawingBottom - 1] := ADest.Pen.FPColor;
ADest.Colors[ASize.cx - 1 - 4, lDrawingBottom - 2] := ADest.Pen.FPColor;
ADest.Colors[ASize.cx - 1 - 2, lDrawingBottom + 1] := ADest.Pen.FPColor;
ADest.Colors[ASize.cx - 1 - 4, lDrawingBottom + 2] := ADest.Pen.FPColor;
ADest.Colors[ASize.cx - 1 - 6, lDrawingBottom - 3] := ADest.Pen.FPColor;
ADest.Colors[ASize.cx - 1 - 6, lDrawingBottom + 3] := ADest.Pen.FPColor;
ADest.Pixels[2, lDrawingBottom - 1] := ADest.Pen.Color;
ADest.Pixels[4, lDrawingBottom - 2] := ADest.Pen.Color;
ADest.Pixels[2, lDrawingBottom + 1] := ADest.Pen.Color;
ADest.Pixels[4, lDrawingBottom + 2] := ADest.Pen.Color;
ADest.Pixels[6, lDrawingBottom - 3] := ADest.Pen.Color;
ADest.Pixels[6, lDrawingBottom + 3] := ADest.Pen.Color;
ADest.Pixels[ASize.cx - 1 - 2, lDrawingBottom - 1] := ADest.Pen.Color;
ADest.Pixels[ASize.cx - 1 - 4, lDrawingBottom - 2] := ADest.Pen.Color;
ADest.Pixels[ASize.cx - 1 - 2, lDrawingBottom + 1] := ADest.Pen.Color;
ADest.Pixels[ASize.cx - 1 - 4, lDrawingBottom + 2] := ADest.Pen.Color;
ADest.Pixels[ASize.cx - 1 - 6, lDrawingBottom - 3] := ADest.Pen.Color;
ADest.Pixels[ASize.cx - 1 - 6, lDrawingBottom + 3] := ADest.Pen.Color;
end;
initialization

View File

@ -7,10 +7,8 @@ interface
uses
// RTL
Classes, SysUtils,
// fpimage
fpcanvas, fpimgcanv, fpimage,
// LCL -> Use only TForm, TWinControl, TCanvas and TLazIntfImage
Graphics, Controls, LCLType, LCLIntf, IntfGraphics,
Graphics, Controls, LCLType,
// Others only for types
StdCtrls,
//
@ -23,619 +21,6 @@ type
implementation
(*{ TCDListViewDrawerWinCE }
procedure TCDListViewDrawerWinCE.DrawToIntfImage(ADest: TFPImageCanvas;
CDListView: TCDListView);
begin
end;
procedure TCDListViewDrawerWinCE.DrawToCanvas(ADest: TCanvas;
CDListView: TCDListView);
begin
end;
{ TCDEditDrawerWinCE }
function TCDEditDrawerWinCE.GetMeasures(AMeasureID: Integer): Integer;
begin
case AMeasureID of
TCDEDIT_LEFT_TEXT_SPACING: Result := 4;
TCDEDIT_RIGHT_TEXT_SPACING: Result := 3;
else
Result := inherited GetMeasures(AMeasureID);
end;
end;
procedure TCDEditDrawerWinCE.DrawBackground(ADest: TCanvas;
CDControl: TCDControl);
begin
// The background
ADest.Brush.Color := clWhite;
ADest.Brush.Style := bsSolid;
ADest.Pen.Color := clBlack;
ADest.Pen.Style := psSolid;
ADest.Rectangle(0, 0, CDControl.Width, CDControl.Height);
end;
{ TCDCheckBoxDrawerWinCE }
function TCDCheckBoxDrawerWinCE.GetCaptionWidth(CDCheckBox: TCDCheckBox
): Integer;
begin
CDCheckBox.Canvas.Font.Assign(CDCheckBox.Font);
Result := CDCheckBox.Canvas.TextWidth(CDCheckBox.Caption);
end;
function TCDCheckBoxDrawerWinCE.GetCaptionHeight(CDCheckBox: TCDCheckBox
): Integer;
begin
CDCheckBox.Canvas.Font.Assign(CDCheckBox.Font);
Result := CDCheckBox.Canvas.TextHeight('ŹÇ')+3;
end;
procedure TCDCheckBoxDrawerWinCE.CalculatePreferredSize(
CDCheckBox: TCDCheckBox; var PreferredWidth, PreferredHeight: integer;
WithThemeSpace: Boolean);
begin
PreferredWidth := 0;
if CDCheckBox.AutoSize then
PreferredWidth := 21 + GetCaptionWidth(CDCheckBox);
PreferredHeight := GetCaptionHeight(CDCheckBox);
end;
procedure TCDCheckBoxDrawerWinCE.DrawToIntfImage(ADest: TFPImageCanvas;
CDCheckBox: TCDCheckBox);
begin
end;
procedure TCDCheckBoxDrawerWinCE.DrawToCanvas(ADest: TCanvas;
CDCheckBox: TCDCheckBox);
const
CDCheckBoxWinCE_Half_Height = 7;
CDCheckBoxWinCE_Height = 15;
var
lHalf: Integer;
lColor: TColor;
i: Integer;
begin
lHalf := CDCheckBox.Height div 2;
// Background
lColor := CDCheckBox.GetRGBBackgroundColor();
ADest.Brush.Color := lColor;
ADest.Brush.Style := bsSolid;
ADest.Pen.Style := psClear;
ADest.FillRect(0, 0, CDCheckBox.Width, CDCheckBox.Height);
// The checkbox item itself
ADest.Brush.Color := clWhite;
ADest.Pen.Style := psSolid;
if CDCheckBox.IsDown then ADest.Pen.Color := clGray
else ADest.Pen.Color := clBlack;
ADest.Rectangle(
1,
lHalf - CDCheckBoxWinCE_Half_Height,
CDCheckBoxWinCE_Height+1,
lHalf + CDCheckBoxWinCE_Half_Height);
// The Tickmark
if CDCheckBox.State = cbChecked then
begin
// 4 lines going down and to the right
for i := 0 to 3 do
ADest.Line(5+i, lHalf - CDCheckBoxWinCE_Half_Height+5+i, 5+i, lHalf - CDCheckBoxWinCE_Half_Height+8+i);
// Now 5 lines going up and to the right
for i := 4 to 8 do
ADest.Line(5+i, lHalf - CDCheckBoxWinCE_Half_Height+5+6-i, 5+i, lHalf - CDCheckBoxWinCE_Half_Height+8+6-i);
end;
// The selection
ADest.Brush.Style := bsClear;
ADest.Pen.Color := RGBToColor($31, $C6, $D6);
ADest.Pen.Style := psSolid;
if CDCheckBox.Focused then
begin
// The selection inside the square
ADest.Rectangle(
2,
lHalf - CDCheckBoxWinCE_Half_Height+1,
CDCheckBoxWinCE_Height,
lHalf + CDCheckBoxWinCE_Half_Height-1);
// Selection around the text
ADest.Rectangle(
CDCheckBoxWinCE_Height+4, 0,
CDCheckBox.Width, CDCheckBox.Height);
end;
// Now the text
ADest.Font.Assign(CDCheckBox.Font);
ADest.TextOut(CDCheckBoxWinCE_Height+5, 0, CDCheckBox.Caption);
end;
{ TCDButtonDrawerWinCE }
procedure TCDButtonDrawerWinCE.DrawToIntfImage(ADest: TFPImageCanvas;
CDButton: TCDButton);
begin
end;
procedure TCDButtonDrawerWinCE.DrawToCanvas(ADest: TCanvas; CDButton: TCDButton);
var
TmpB: TBitmap;
Str: string;
begin
// Button shape -> This crashes in Gtk2
TmpB := TBitmap.Create;
TmpB.Width := CDButton.Width;
TmpB.Height := CDButton.Height;
TmpB.Canvas.Brush.Color := CDButton.Color;
TmpB.Canvas.Brush.Style := bsSolid;
TmpB.Canvas.RoundRect(0, 0, TmpB.Width, TmpB.Height, 8, 8);
// CDButton.SetShape(TmpB);
// Button image
if CDButton.IsDown then
begin
TmpB.Canvas.Brush.Style := bsSolid;
TmpB.Canvas.Brush.Color := GetAColor(CDButton.Color, 90);
TmpB.Canvas.Pen.Color := clBlack;
TmpB.Canvas.Pen.Style := psSolid;
TmpB.Canvas.Rectangle(0, 0, TmpB.Canvas.Width, TmpB.Canvas.Height);
end
else if CDButton.Focused then
begin
with TmpB.Canvas do
begin
Brush.Style := bsSolid;
Brush.Color := GetAColor(CDButton.Color, 99);
Pen.Color := clBlack;
Pen.Style := psSolid;
Rectangle(0, 0, Width, Height);
Rectangle(1, 1, Width - 1, Height - 1); // The border is thicken when focused
end;
end
else
begin
with TmpB.Canvas do
begin
Brush.Style := bsSolid;
Brush.Color := CDButton.Color;
Pen.Color := clBlack;
Pen.Style := psSolid;
Rectangle(0, 0, Width, Height);
end;
end;
ADest.Draw(0, 0, TmpB);
TmpB.Free;
// Button text
{$ifndef CUSTOMDRAWN_USE_FREETYPE}
ADest.Font.Assign(CDButton.Font);
ADest.Brush.Style := bsClear;
ADest.Pen.Style := psSolid;
Str := CDButton.Caption;
ADest.TextOut((CDButton.Width - ADest.TextWidth(Str)) div 2,
(CDButton.Height - ADest.TextHeight(Str)) div 2, Str);
{$endif}
end;
{ TCDCustomTabControlDrawerWinCE }
procedure TCDCustomTabControlDrawerWinCE.DrawCaptionBar(ADest: TCanvas;
lRect: TRect; CL: TColor);
begin
{ CaptionHeight := GetTabHeight(CDPageControl.PageIndex, CDPageControl) - 4;
RButtHeight := GetTabHeight(CDPageControl.PageIndex, CDPageControl);
aRect := lRect;
ADest.Pen.Style := psSolid;
ADest.Brush.Style := bsSolid;
ADest.Pen.FPColor := TColorToFPColor(ColorToRGB(CL));
//TColorToFPColor(ColorToRGB($009C9B91));
ADest.Brush.FPColor := TColorToFPColor(ColorToRGB(CL));
aRect.Left := lRect.Left;
aRect.Top := lRect.Top;
aRect.Bottom := lRect.Bottom;
aRect.Right := lRect.Right;
ADest.RecTangle(lRect);
if CDPageControl.FPages.Count = 0 then
begin
ADest.Brush.Color := clWhite;
ADest.Pen.Color := $009C9B91;
ADest.RecTangle(Rect(aRect.Left, aRect.Top, aRect.Right + 1, aRect.Bottom + 2));
ADest.Pen.Color := clWhite;
ADest.Line(aRect.Left + 1, aRect.Bottom + 1, aRect.Right, aRect.Bottom + 1);
Exit;
end;
aRect.Left := lRect.Left + 2;
aRect.Top := lRect.Top + 3;
//ADest.TextStyle.Opaque :=false;
//SetBkMode(ADest.Handle, TRANSPARENT);
if ADest.Brush.Style = bsSolid then
SetBkMode(ADest.Handle, OPAQUE)
else
SetBkMode(ADest.Handle, TRANSPARENT);
for i := StartIndex to CDPageControl.FPages.Count - 1 do
begin
aText := CDPageControl.FPages[i].TabPage.Caption;
rWidth := (CaptionHeight - ADest.TextHeight(aText)) + ADest.TextWidth(aText);
CDPageControl.FPages[i].Width := rWidth;
if aRect.Left + rWidth > lRect.Right - 6 then
Break
else
aRect.Right := aRect.Left + rWidth;
if CDPageControl.PageIndex = i then
begin
cRect := aRect;
if i = StartIndex then
cRect.Left := aRect.Left - 2
else
cRect.Left := aRect.Left - 4;
cRect.Right := aRect.Right + 4;
cRect.Top := cRect.Top - 2;
bText := CDPageControl.FPages[i].TabPage.Caption;
end
else
DrawTabHead(aDest, aRect, CDPageControl.Color, False);
MaskColor := MaskBaseColor + i - StartIndex;
//DrawTabHeadMask(MaskHeadBmp.Canvas, aRect, MaskColor, False);
ADest.TextOut(aRect.Left + (aRect.Right - aRect.Left - ADest.TextWidth(aText)) div 2,
aRect.Top + (aRect.Bottom - aRect.Top - ADest.TextHeight(aText)) div 2, aText);
aRect.Left := aRect.Right + 3;
end;
ADest.Line(lRect.Left, lRect.Bottom - 1, cRect.Left, lRect.Bottom - 1);
ADest.Line(cRect.Right, lRect.Bottom - 1, lRect.Right, lRect.Bottom - 1);
DrawTabHead(aDest, cRect, clWhite, True);
ADest.TextOut(cRect.Left + (cRect.Right - cRect.Left - ADest.TextWidth(bText)) div 2,
cRect.Top + (cRect.Bottom - cRect.Top - ADest.TextHeight(bText)) div 2, bText);
if not CheckTabButton(lRect.Right - lRect.Left, CDPageControl.FPages) then
Exit;
aRect.Left := lRect.Right - RButtHeight * 2 - 3;
aRect.Top := 1;
aRect.Bottom := RButtHeight + 1;
aRect.Right := lRect.Right - RButtHeight;
//if FMDownL then
// GradFill(ADest, aRect, $00F1A079, $00EFAF9B)
//else
GradFill(ADest, aRect, $00FDD9CB, $00F2C9B8);
aRect.Left := lRect.Right - RButtHeight - 1;
aRect.Top := 1;
aRect.Bottom := RButtHeight + 1;
aRect.Right := lRect.Right;
GradFill(ADest, aRect, $00FDD9CB, $00F2C9B8);
ADest.Pen.FPColor := TColorToFPColor(ColorToRGB($0085614D));
bRect.Top := 1;
bRect.Left := lRect.Right - RButtHeight * 2 - 3;
bRect.Right := lRect.Right;
bRect.Bottom := RButtHeight + 1;
DrawArrow(ADest, bRect, True);
DrawArrow(ADest, bRect, False);
ADest.Pen.FPColor := TColorToFPColor(ColorToRGB(clWhite));
ADest.Line(lRect.Right - RButtHeight * 2 - 3, 1, lRect.Right, 1);
ADest.Line(lRect.Right, 1, lRect.Right, RButtHeight + 1);
ADest.Line(lRect.Right, RButtHeight + 1, lRect.Right - RButtHeight *
2 - 3, RButtHeight + 1);
ADest.Line(lRect.Right - RButtHeight * 2 - 3, RButtHeight + 1,
lRect.Right - RButtHeight * 2 - 3, 1);
ADest.Pen.FPColor := TColorToFPColor(ColorToRGB($00E5BAA7));
ADest.Brush.Style := bsClear;
ADest.Rectangle(lRect.Right - RButtHeight * 2 - 2, 2, lRect.Right -
1, RButtHeight + 1);
CornerColor := TColorToFPColor(ColorToRGB($00F6E3D9));
ADest.Colors[lRect.Right - RButtHeight * 2 - 2, 2] := CornerColor;
ADest.Colors[lRect.Right - RButtHeight * 2 - 2, RButtHeight] := CornerColor;
ADest.Colors[lRect.Right - 1, 2] := CornerColor;
ADest.Colors[lRect.Right - 1, RButtHeight] := CornerColor;
ADest.Pen.FPColor := TColorToFPColor(ColorToRGB(clWhite));
ADest.Line(lRect.Right - 51, 1, lRect.Right, 1);
ADest.Line(lRect.Right, 1, lRect.Right, 25);
ADest.Line(lRect.Right, 25, lRect.Right - 51, 25);
ADest.Line(lRect.Right - 51, 25, lRect.Right - 51, 1);
ADest.Pen.FPColor := TColorToFPColor(ColorToRGB($00FFFFFF));}
end;
procedure TCDCustomTabControlDrawerWinCE.DrawTabs(ADest: TCanvas; CDTabControl: TCDCustomTabControl);
var
IsPainting: Boolean = False;
CurStartLeftPos: Integer = 0;
i: Integer;
begin
for i := 0 to CDTabControl.Tabs.Count - 1 do
begin
if i = LeftmostTabVisibleIndex then
IsPainting := True;
if IsPainting then
begin
DrawTab(ADest, i, CurStartLeftPos, CDTabControl);
CurStartLeftPos := CurStartLeftPos + GetTabWidth(ADest, i, CDTabControl);
end;
end;
end;
procedure TCDCustomTabControlDrawerWinCE.DrawTab(ADest: TCanvas;
AIndex: Integer; ACurStartLeftPos: Integer; CDTabControl: TCDCustomTabControl);
var
IsSelected: Boolean;
lTabWidth, lTabHeight, lTabTopPos: Integer;
Points: array of TPoint;
lCaption: String;
begin
IsSelected := CDTabControl.TabIndex = AIndex;
if IsSelected then
begin
lTabTopPos := 0;
lTabHeight := GetTabHeight(AIndex, CDTabControl);
end
else
begin
lTabTopPos := 5;
lTabHeight := GetTabHeight(AIndex, CDTabControl)-5;
end;
lTabWidth := GetTabWidth(ADest, AIndex, CDTabControl);
// Fill the area inside the outer border
ADest.Pen.Style := psClear;
ADest.Brush.Style := bsSolid;
ADest.Brush.Color := clWhite;
SetLength(Points, 5);
Points[0] := Point(ACurStartLeftPos, lTabTopPos);
Points[1] := Point(ACurStartLeftPos+lTabWidth-5, lTabTopPos);
Points[2] := Point(ACurStartLeftPos+lTabWidth, lTabTopPos+5);
Points[3] := Point(ACurStartLeftPos+lTabWidth, lTabTopPos+lTabHeight);
Points[4] := Point(ACurStartLeftPos, lTabTopPos+lTabHeight);
ADest.Polygon(Points);
// Draw the outer border only in the top and right sides,
// and bottom if unselected
ADest.Pen.Style := psSolid;
ADest.Brush.Style := bsClear;
ADest.Pen.Color := ColorToRGB($009C9B91);
ADest.MoveTo(ACurStartLeftPos+1, lTabTopPos);
ADest.LineTo(ACurStartLeftPos+lTabWidth-5, lTabTopPos);
ADest.LineTo(ACurStartLeftPos+lTabWidth, lTabTopPos+5);
ADest.LineTo(ACurStartLeftPos+lTabWidth, lTabTopPos+lTabHeight);
// If it is selected, add a selection frame
if IsSelected then
begin
ADest.Pen.Color := ColorToRGB($00D6C731);
ADest.Pen.Style := psSolid;
ADest.Brush.Style := bsClear;
ADest.Rectangle(
ACurStartLeftPos+3, lTabTopPos+3,
ACurStartLeftPos+lTabWidth-5, lTabTopPos+lTabHeight-5
);
end;
// Now the text
lCaption := CDTabControl.Tabs.Strings[AIndex];
ADest.TextOut(ACurStartLeftPos+5, lTabTopPos+5, lCaption);
end;
function TCDCustomTabControlDrawerWinCE.GetPageIndexFromXY(x, y: integer
): integer;
begin
Result := 1;
end;
function TCDCustomTabControlDrawerWinCE.GetTabHeight(AIndex: Integer; CDTabControl: TCDCustomTabControl): Integer;
begin
if CDTabControl.Font.Size = 0 then
Result := 32
else
Result := CDTabControl.Font.Size + 22;
end;
function TCDCustomTabControlDrawerWinCE.GetTabWidth(ADest: TCanvas;
AIndex: Integer; CDTabControl: TCDCustomTabControl): Integer;
const
TCDTabControl_WinCE_TabCaptionExtraWidth = 20;
var
lCaption: string;
begin
lCaption := CDTabControl.Tabs.Strings[AIndex];
Result := ADest.TextWidth(lCaption) + TCDTabControl_WinCE_TabCaptionExtraWidth;
end;
{function TCDCustomTabControlDrawerWinCE.GetClientRect(AControl: TCDControl
): TRect;
var
lCaptionHeight: Integer;
begin
lCaptionHeight := GetTabHeight(CDTabControl.FTabIndex) - 4;
Result := Rect(5, lCaptionHeight + 1, CDTabControl.Width - 10,
CDTabControl.Height - lCaptionHeight - 5);
end;}
procedure TCDCustomTabControlDrawerWinCE.DrawToIntfImage(ADest: TFPImageCanvas;
FPImg: TLazIntfImage; CDTabControl: TCDCustomTabControl);
var
lColor: TColor;
lFPColor: TFPColor;
x, y: Integer;
begin
lColor := CDTabControl.GetRGBBackgroundColor();
// Background
lFPColor := TColorToFPColor(lColor);
FPImg.FillPixels(lFPColor);
end;
procedure TCDCustomTabControlDrawerWinCE.DrawToCanvas(ADest: TCanvas; CDTabControl: TCDCustomTabControl);
var
CaptionHeight: Integer;
begin
CaptionHeight := GetTabHeight(CDTabControl.TabIndex, CDTabControl);
// frame
ADest.Pen.Style := psSolid;
ADest.Brush.Style := bsClear;
ADest.Pen.Color := ColorToRGB($009C9B91);
if CDTabControl.GetTabCount = 0 then
ADest.Rectangle(0, 0, CDTabControl.Width - 2, CDTabControl.Height - 2)
else
ADest.Rectangle(0, CaptionHeight, CDTabControl.Width - 2, CDTabControl.Height - 2);
ADest.Pen.Color := ColorToRGB($00BFCED0);
ADest.Line(CDTabControl.Width - 1, CaptionHeight + 1,
CDTabControl.Width - 1, CDTabControl.Height - 1);
ADest.Line(CDTabControl.Width - 1, CDTabControl.Height - 1, 1,
CDTabControl.Height - 1);
// Tabs
ADest.Font.Name := CDTabControl.Font.Name;
ADest.Font.Size := CDTabControl.Font.Size;
// DrawCaptionBar(ADest, Rect(0, 0, CDPageControl.Width -
// 2, CaptionHeight + 1), CDPageControl.Color, CDPageControl);
DrawTabs(ADest, CDTabControl);
end;
procedure TCDCustomTabControlDrawerWinCE.DrawTabSheet(ADest: TCanvas; CDTabControl: TCDCustomTabControl);
begin
ADest.Brush.Color := CDTabControl.Color;
ADest.Brush.Style := bsSolid;
ADest.Pen.Style := psClear;
ADest.Rectangle(0, 0, CDTabControl.Width, CDTabControl.Height);
end;
procedure TCDCustomTabControlDrawerWinCE.MouseDown(Button: TMouseButton;
Shift: TShiftState; X, Y: integer; CDTabControl: TCDCustomTabControl);
var
i: Integer;
CurPage: TCDTabSheet;
CurStartLeftPos: Integer = 0;
VisiblePagesStarted: Boolean = False;
lTabWidth: Integer;
begin
for i := 0 to CDTabControl.Tabs.Count - 1 do
begin
if i = LeftmostTabVisibleIndex then
VisiblePagesStarted := True;
if VisiblePagesStarted then
begin
lTabWidth := GetTabWidth(CDTabControl.Canvas, i, CDTabControl);
if (X > CurStartLeftPos) and
(X < CurStartLeftPos + lTabWidth) and
(Y < GetTabHeight(i, CDTabControl)) then
begin
if CDTabControl is TCDPageControl then
(CDTabControl as TCDPageControl).PageIndex := i
else
CDTabControl.TabIndex := i;
Exit;
end;
CurStartLeftPos := CurStartLeftPos + lTabWidth;
end;
end;
end;
procedure TCDCustomTabControlDrawerWinCE.MouseUp(Button: TMouseButton;
Shift: TShiftState; X, Y: integer; CDTabControl: TCDCustomTabControl);
begin
end;
procedure TCDGroupBoxDrawerWinCE.SetClientRectPos(CDGroupBox: TCDGroupBox);
var
lRect: TRect;
lCaptionHeight: integer;
begin
lCaptionHeight := 10;
lRect := Rect(1, lCaptionHeight, CDGroupBox.Width - 1, CDGroupBox.Height - 1);
//CDGroupBox.AdjustClientRect(lRect);
end;
procedure TCDGroupBoxDrawerWinCE.DrawToIntfImage(ADest: TFPImageCanvas;
CDGroupBox: TCDGroupBox);
{$ifdef CUSTOMDRAWN_USE_FREETYPE}
var
AFont: TFreeTypeFont = nil;
{$endif}
begin
FCaptionMiddle := CDGroupBox.Canvas.TextHeight('Ź') div 2;
if FCaptionMiddle = 0 then FCaptionMiddle := CDGroupBox.Canvas.Font.Size div 2;
if FCaptionMiddle = 0 then FCaptionMiddle := 5;
// Background
if CDGroupBox.Parent = nil then
ADest.Brush.FPColor := colLtGray
else if CDGroupBox.Parent.Color = clDefault then
ADest.Brush.FPColor := TColorToFPColor(ColorToRGB(clForm))
else
ADest.Brush.FPColor := TColorToFPColor(ColorToRGB(CDGroupBox.Parent.Color));
ADest.Brush.Style := bsSolid;
ADest.Pen.Style := psClear;
ADest.Rectangle(0, 0, CDGroupBox.Width, CDGroupBox.Height);
// frame
ADest.Pen.FPColor := colBlack;
ADest.Pen.Style := psSolid;
ADest.Brush.Style := bsClear;
ADest.Rectangle(0, FCaptionMiddle, CDGroupBox.Width - 1, CDGroupBox.Height - 1);
{$ifdef CUSTOMDRAWN_USE_FREETYPE}
// Caption background and caption
// initialize free type font manager
opcftfont.InitEngine;
// FontMgr.SearchPath:='/usr/share/fonts/truetype/';
AFont := TFreeTypeFont.Create;
try
// Text background
ADest.Pen.Style := psClear;
ADest.Brush.Style := bsSolid;
// The brush color was already set previously and is already correct
// ADest.Rectangle(5, 0, AFont.GetTextWidth(CDGroupBox.Caption) + 5, 10);
// paint text
ADest.Pen.Style := psSolid;
ADest.Brush.Style := bsClear;
ADest.Font := AFont;
ADest.Font.Name := 'Arial';
ADest.Font.Size := 10;
ADest.TextOut(5, 10, CDGroupBox.Caption);
finally
AFont.Free;
end;
{$endif}
end;
procedure TCDGroupBoxDrawerWinCE.DrawToCanvas(ADest: TCanvas; CDGroupBox: TCDGroupBox);
begin
if CDGroupBox.Parent = nil then
ADest.Brush.Color := clLtGray
else if CDGroupBox.Parent.Color = clDefault then
ADest.Brush.Color := ColorToRGB(clForm)
else
ADest.Brush.Color := ColorToRGB(CDGroupBox.Parent.Color);
// paint text
ADest.Pen.Style := psSolid;
ADest.Brush.Style := bsSolid; // This will fill the text background
ADest.Font.Size := 10;
ADest.TextOut(FCaptionMiddle, 0, CDGroupBox.Caption);
end;*)
initialization
RegisterDrawer(TCDDrawerWinCE.Create, dsWinCE);
end.

View File

@ -299,14 +299,23 @@ type
{ TCDCustomTabSheet }
TCDCustomTabSheet = class(TCustomControl)
{ TCDTabSheet }
TCDTabSheet = class(TCustomControl)
private
CDTabControl: TCDCustomTabControl;
FTabVisible: Boolean;
protected
procedure RealSetText(const Value: TCaption); override; // to update on caption changes
public
procedure SetParent(NewParent: TWinControl); override; // For being created by the LCL resource reader
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure EraseBackground(DC: HDC); override;
procedure Paint; override;
published
property Caption;
property Color;
property Font;
property TabVisible: Boolean read FTabVisible write FTabVisible;
end;
@ -353,23 +362,6 @@ type
property OnChange;
end;
{ TCDTabSheet }
TCDPageControl = class;
TCDTabSheet = class(TCDCustomTabSheet)
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure EraseBackground(DC: HDC); override;
procedure Paint; override;
published
property Caption;
property Color;
property Font;
property TabVisible: Boolean;
end;
{ TCDPageControl }
TCDPageControl = class(TCDCustomTabControl)
@ -691,7 +683,6 @@ begin
csDoubleClicks, csReplicatable];
AutoSize := True;
DrawStyle := dsWinXP;
PrepareCurrentDrawer();
end;
@ -700,39 +691,6 @@ begin
inherited Destroy;
end;
{ TCDCustomTabSheet }
procedure TCDCustomTabSheet.RealSetText(const Value: TCaption);
var
lIndex: Integer;
begin
inherited RealSetText(Value);
lIndex := CDTabControl.Tabs.IndexOfObject(Self);
if lIndex >= 0 then
CDTabControl.Tabs.Strings[lIndex] := Value;
CDTabControl.Invalidate;
end;
destructor TCDCustomTabSheet.Destroy;
var
lIndex: Integer;
begin
// We should support deleting the tabsheet directly too,
// and then it should update the tabcontrol
// This is important mostly for the designer
if CDTabControl <> nil then
begin
lIndex := CDTabControl.FTabs.IndexOfObject(Self);
if lIndex >= 0 then
begin
CDTabControl.FTabs.Delete(lIndex);
CDTabControl.CorrectTabIndex();
end;
end;
inherited Destroy;
end;
{ TCDCustomTabControl }
procedure TCDCustomTabControl.MouseDown(Button: TMouseButton;
@ -1259,7 +1217,6 @@ begin
DrawStyle := dsExtra1;
PrepareCurrentDrawer();
Color := clBtnFace;
FMax := 10;
FMin := 0;
TabStop := True;
@ -1297,6 +1254,23 @@ end;}
{ TCDTabSheet }
procedure TCDTabSheet.RealSetText(const Value: TCaption);
var
lIndex: Integer;
begin
inherited RealSetText(Value);
lIndex := CDTabControl.Tabs.IndexOfObject(Self);
if lIndex >= 0 then
CDTabControl.Tabs.Strings[lIndex] := Value;
CDTabControl.Invalidate;
end;
procedure TCDTabSheet.SetParent(NewParent: TWinControl);
begin
inherited SetParent(NewParent);
CDTabControl := NewParent as TCDCustomTabControl;
end;
constructor TCDTabSheet.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
@ -1311,7 +1285,22 @@ begin
end;
destructor TCDTabSheet.Destroy;
var
lIndex: Integer;
begin
// We should support deleting the tabsheet directly too,
// and then it should update the tabcontrol
// This is important mostly for the designer
if CDTabControl <> nil then
begin
lIndex := CDTabControl.FTabs.IndexOfObject(Self);
if lIndex >= 0 then
begin
CDTabControl.FTabs.Delete(lIndex);
CDTabControl.CorrectTabIndex();
end;
end;
inherited Destroy;
end;
@ -1342,12 +1331,7 @@ begin
NewPage := TCDTabSheet.Create(Owner);
NewPage.Parent := Self;
NewPage.CDTabControl := Self;
//Name := Designer.CreateUniqueComponentName(ClassName);
{ NewPage.Name := GetUniqueName(sTABSHEET_DEFAULT_NAME, Self.Owner);
if S = '' then
NewPage.Caption := NewPage.Name
else}
NewPage.Caption := S;
NewPage.Caption := S;
PositionTabSheet(NewPage);
@ -1372,12 +1356,8 @@ var
begin
NewPage := TCDTabSheet.Create(Owner);
NewPage.Parent := Self;
//Name := Designer.CreateUniqueComponentName(ClassName);
{ NewPage.Name := GetUniqueName(sTABSHEET_DEFAULT_NAME, Self.Owner);
if S = '' then
NewPage.Caption := NewPage.Name
else}
NewPage.Caption := S;
NewPage.CDTabControl := Self;
NewPage.Caption := S;
PositionTabSheet(NewPage);

View File

@ -184,7 +184,7 @@ procedure Register;
begin
RegisterComponents('Custom Drawn', [
// Standard tab
TCDButton, TCDEdit, TCDGroupBox,
TCDButton, TCDEdit, TCDCheckBox, TCDGroupBox,
// Common Controls
TCDTrackBar, TCDPageControl, TCDTabControl]);
RegisterComponentEditor(TCDPageControl, TCDPageControlEditor);
@ -427,18 +427,21 @@ var
Hook: TPropertyEditorHook;
PageComponent: TPersistent;
OldPage: longint;
lPageName: String;
begin
if not GetHook(Hook) then exit;
case Index of
0:
begin // New Page
NewPage := PControl.AddPage('');
lPageName := Designer.CreateUniqueComponentName(TCDTabSheet.ClassName);
NewPage := PControl.AddPage(lPageName);
Hook.PersistentAdded(NewPage, True);
end;
1:
begin // Insert Page
NewPage := PControl.InsertPage(PControl.PageIndex, '');
lPageName := Designer.CreateUniqueComponentName(TCDTabSheet.ClassName);
NewPage := PControl.InsertPage(PControl.PageIndex, lPageName);
Hook.PersistentAdded(NewPage, True);
end;
2: