customdrawn: Many small fixes

git-svn-id: trunk@33302 -
This commit is contained in:
sekelsenmat 2011-11-04 16:50:37 +00:00
parent e2ab4a0218
commit 3e420731a5
4 changed files with 38 additions and 53 deletions

View File

@ -35,6 +35,8 @@ type
AState: TCDControlState; AStateEx: TCDControlStateEx): TRect; override;
procedure DrawControl(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
AControl: TCDControlID; AState: TCDControlState; AStateEx: TCDControlStateEx); override;
// General drawing routines
procedure DrawFocusRect(ADest: TCanvas; ADestPos: TPoint; ASize: TSize); override;
// ===================================
// Standard Tab
// ===================================
@ -193,6 +195,18 @@ begin
end;
end;
procedure TCDDrawerCommon.DrawFocusRect(ADest: TCanvas; ADestPos: TPoint;
ASize: TSize);
begin
ADest.Pen.Color := clWhite;
ADest.Pen.Style := psSolid;
ADest.Brush.Style := bsClear;
ADest.Rectangle(ADestPos.X, ADestPos.Y, ADestPos.X + ASize.CX, ADestPos.Y + ASize.CY);
ADest.Pen.Color := clBlack;
ADest.Pen.Style := psDot;
ADest.Rectangle(ADestPos.X, ADestPos.Y, ADestPos.X + ASize.CX, ADestPos.Y + ASize.CY);
end;
procedure TCDDrawerCommon.DrawButton(ADest: TCanvas; ADestPos: TPoint;
ASize: TSize; AState: TCDControlState; AStateEx: TCDControlStateEx);
var
@ -592,17 +606,8 @@ begin
if IsSelected then
begin
// If it is selected, add a selection frame
ADest.Pen.Color := clWhite;
ADest.Pen.Style := psSolid;
ADest.Brush.Style := bsClear;
ADest.Rectangle(
AStateEx.CurStartLeftPos+3, lTabTopPos+3,
AStateEx.CurStartLeftPos+lTabWidth-5, lTabTopPos+lTabHeight-3);
ADest.Pen.Color := clBlack;
ADest.Pen.Style := psDot;
ADest.Rectangle(
AStateEx.CurStartLeftPos+3, lTabTopPos+3,
AStateEx.CurStartLeftPos+lTabWidth-5, lTabTopPos+lTabHeight-3);
DrawFocusRect(ADest, Point(AStateEx.CurStartLeftPos+3, lTabTopPos+3),
Size(lTabWidth-8, lTabHeight-6));
// and Clear the bottom area if selected
ADest.Pen.Color := AStateEx.RGBColor;

View File

@ -55,6 +55,7 @@ procedure TCDDrawerWinCE.LoadFallbackPaletteColors;
begin
Palette.Form := $EFDFCE;
Palette.BtnFace := $EFDFCE;
Palette.BtnShadow := clBlack;
end;
function TCDDrawerWinCE.GetDrawStyle: TCDDrawStyle;
@ -65,59 +66,35 @@ end;
procedure TCDDrawerWinCE.DrawButton(ADest: TCanvas; ADestPos: TPoint;
ASize: TSize; AState: TCDControlState; AStateEx: TCDControlStateEx);
var
TmpB: TBitmap;
Str: string;
begin
// Button shape -> This crashes in Gtk2
TmpB := TBitmap.Create;
TmpB.Width := ASize.cx;
TmpB.Height := ASize.cy;
TmpB.Canvas.Brush.Color := AStateEx.RGBColor;
TmpB.Canvas.Brush.Style := bsSolid;
TmpB.Canvas.RoundRect(0, 0, TmpB.Width, TmpB.Height, 8, 8);
// CDButton.SetShape(TmpB);
// Button image
// Button background
if csfSunken in AState then
begin
TmpB.Canvas.Brush.Style := bsSolid;
TmpB.Canvas.Brush.Color := RGBToColor(230, 230, 230);
TmpB.Canvas.Pen.Color := clBlack;
TmpB.Canvas.Pen.Style := psSolid;
TmpB.Canvas.Rectangle(0, 0, TmpB.Canvas.Width, TmpB.Canvas.Height);
end
else if csfHasFocus in AState then
begin
with TmpB.Canvas do
begin
Brush.Style := bsSolid;
Brush.Color := RGBToColor($FD, $FD, $FD);
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;
ADest.Brush.Style := bsSolid;
ADest.Brush.Color := Palette.BtnShadow;
ADest.Pen.Color := clBlack;
ADest.Pen.Style := psSolid;
ADest.Rectangle(0, 0, ASize.cx, ASize.cy);
end
else
begin
with TmpB.Canvas do
begin
Brush.Style := bsSolid;
Brush.Color := AStateEx.RGBColor;
Pen.Color := clBlack;
Pen.Style := psSolid;
Rectangle(0, 0, Width, Height);
end;
ADest.Brush.Style := bsSolid;
ADest.Brush.Color := AStateEx.RGBColor;
ADest.Pen.Color := clBlack;
ADest.Pen.Style := psSolid;
ADest.Rectangle(0, 0, ASize.cx, ASize.cy);
end;
ADest.Draw(0, 0, TmpB);
TmpB.Free;
// Focus
if (csfHasFocus in AState) and not (csfSunken in AState) then
DrawFocusRect(ADest, Point(4, 4), Size(ASize.cx-8, ASize.cy-8));
// Button text
ADest.Font.Assign(AStateEx.Font);
ADest.Brush.Style := bsClear;
ADest.Pen.Style := psSolid;
if csfSunken in AState then ADest.Font.Color := clWhite;
Str := AStateEx.Caption;
ADest.TextOut((ASize.cx - ADest.TextWidth(Str)) div 2,
(ASize.cy - ADest.TextHeight(Str)) div 2, Str);

View File

@ -893,7 +893,7 @@ begin
if Parent <> nil then FStateEx.ParentRGBColor := Parent.GetRGBColorResolvingParent
else FStateEx.ParentRGBColor := clSilver;
if Color = clDefault then FStateEx.RGBColor := FDrawer.GetControlColor(GetControlId())
if Color = clDefault then FStateEx.RGBColor := FDrawer.GetControlDefaultColor(GetControlId())
else FStateEx.RGBColor := GetRGBColorResolvingParent;
FStateEx.Caption := Caption;

View File

@ -173,7 +173,8 @@ type
procedure LoadNativePaletteColors;
procedure LoadFallbackPaletteColors; virtual;
function GetDrawStyle: TCDDrawStyle; virtual;
function GetControlColor(AControlId: TCDControlID): TColor;
// GetControlDefaultColor is used by customdrawncontrols to resolve clDefault
function GetControlDefaultColor(AControlId: TCDControlID): TColor;
// General
function GetMeasures(AMeasureID: Integer): Integer; virtual; abstract;
function GetMeasuresEx(ADest: TCanvas; AMeasureID: Integer;
@ -186,6 +187,8 @@ type
AState: TCDControlState; AStateEx: TCDControlStateEx): TRect; virtual; abstract;
procedure DrawControl(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
AControl: TCDControlID; AState: TCDControlState; AStateEx: TCDControlStateEx); virtual; abstract;
// General drawing routines
procedure DrawFocusRect(ADest: TCanvas; ADestPos: TPoint; ASize: TSize); virtual; abstract;
// TCDButton
procedure DrawButton(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
AState: TCDControlState; AStateEx: TCDControlStateEx); virtual; abstract;
@ -344,7 +347,7 @@ begin
Result := dsCommon;
end;
function TCDDrawer.GetControlColor(AControlId: TCDControlID): TColor;
function TCDDrawer.GetControlDefaultColor(AControlId: TCDControlID): TColor;
begin
case AControlId of
cidControl: Result := Palette.Form;