mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-15 23:19:50 +02:00
customdrawn: The common button is now win2k
git-svn-id: trunk@33265 -
This commit is contained in:
parent
30fd618333
commit
78da9b52f1
@ -151,62 +151,74 @@ end;
|
|||||||
procedure TCDDrawerCommon.DrawButton(ADest: TCanvas; ADestPos: TPoint;
|
procedure TCDDrawerCommon.DrawButton(ADest: TCanvas; ADestPos: TPoint;
|
||||||
ASize: TSize; AState: TCDControlState; AStateEx: TCDControlStateEx);
|
ASize: TSize; AState: TCDControlState; AStateEx: TCDControlStateEx);
|
||||||
var
|
var
|
||||||
TmpB: TBitmap;
|
|
||||||
Str: string;
|
Str: string;
|
||||||
begin
|
begin
|
||||||
// Button shape -> This crashes in Gtk2
|
// Button shape -> This crashes in Gtk2
|
||||||
TmpB := TBitmap.Create;
|
ADest.Brush.Color := AStateEx.RGBColor;
|
||||||
TmpB.Width := ASize.cx;
|
ADest.Brush.Style := bsSolid;
|
||||||
TmpB.Height := ASize.cy;
|
ADest.RoundRect(0, 0, ASize.cx, ASize.cy, 8, 8);
|
||||||
TmpB.Canvas.Brush.Color := AStateEx.RGBColor;
|
|
||||||
TmpB.Canvas.Brush.Style := bsSolid;
|
ADest.Brush.Style := bsSolid;
|
||||||
TmpB.Canvas.RoundRect(0, 0, TmpB.Width, TmpB.Height, 8, 8);
|
ADest.Brush.Color := AStateEx.RGBColor;
|
||||||
// CDButton.SetShape(TmpB);
|
ADest.Pen.Color := clWhite;
|
||||||
|
ADest.Pen.Style := psSolid;
|
||||||
|
ADest.Rectangle(0, 0, ASize.cx - 1, ASize.cy - 1);
|
||||||
|
ADest.Pen.Color := clWhite;
|
||||||
|
ADest.Line(0, 0, ASize.cx - 1, 0);
|
||||||
|
ADest.Line(0, 0, 0, ASize.cy - 1);
|
||||||
|
ADest.Pen.Color := clGray;
|
||||||
|
ADest.Line(0, ASize.cy - 1, ASize.cx - 1, ASize.cy - 1);
|
||||||
|
ADest.Line(ASize.cx - 1, ASize.cy - 1, ASize.cx - 1, -1);
|
||||||
|
ADest.Pen.Color := $0099A8AC;
|
||||||
|
ADest.Line(1, ASize.cy - 2, ASize.cx - 2, ASize.cy - 2);
|
||||||
|
ADest.Line(ASize.cx - 2, ASize.cx - 2, ASize.cx - 2, 0);
|
||||||
|
ADest.Pen.Color := $00E2EFF1;
|
||||||
|
ADest.Line(1, 1, ASize.cx - 2, 1);
|
||||||
|
ADest.Line(1, 1, 1, ASize.cy - 2);
|
||||||
|
|
||||||
// Button image
|
// Button image
|
||||||
if csfSunken in AState then
|
if csfSunken in AState then
|
||||||
begin
|
begin
|
||||||
TmpB.Canvas.Brush.Style := bsSolid;
|
ADest.Brush.Style := bsSolid;
|
||||||
TmpB.Canvas.Brush.Color := RGBToColor(230, 230, 230);
|
ADest.Brush.Color := AStateEx.RGBColor;
|
||||||
TmpB.Canvas.Pen.Color := clBlack;
|
ADest.Pen.Color := clWhite;
|
||||||
TmpB.Canvas.Pen.Style := psSolid;
|
ADest.Pen.Style := psSolid;
|
||||||
TmpB.Canvas.Rectangle(0, 0, TmpB.Canvas.Width, TmpB.Canvas.Height);
|
ADest.Rectangle(0, 0, ASize.cx - 1, ASize.cy - 1);
|
||||||
|
ADest.Pen.Color := clGray;
|
||||||
|
ADest.Line(0, 0, ASize.cx - 1, 0);
|
||||||
|
ADest.Line(0, 0, 0, ASize.cy - 1);
|
||||||
|
ADest.Pen.Color := clWhite;
|
||||||
|
ADest.Line(0, ASize.cy - 1, ASize.cx - 1, ASize.cy - 1);
|
||||||
|
ADest.Line(ASize.cx - 1, ASize.cy - 1, ASize.cx - 1, -1);
|
||||||
|
ADest.Pen.Color := $00E2EFF1;
|
||||||
|
ADest.Line(1, ASize.cy - 2, ASize.cx - 2, ASize.cy - 2);
|
||||||
|
ADest.Line(ASize.cx - 2, ASize.cy - 2, ASize.cx - 2, 0);
|
||||||
|
ADest.Pen.Color := $0099A8AC;
|
||||||
|
ADest.Line(1, 1, ASize.cx - 2, 1);
|
||||||
|
ADest.Line(1, 1, 1, ASize.cy - 2);
|
||||||
end
|
end
|
||||||
else if csfHasFocus in AState then
|
else if csfHasFocus in AState then
|
||||||
begin
|
begin
|
||||||
with TmpB.Canvas do
|
ADest.Brush.Style := bsClear;
|
||||||
begin
|
ADest.Pen.Color := clWhite;
|
||||||
Brush.Style := bsSolid;
|
ADest.Pen.Style := psSolid;
|
||||||
Brush.Color := RGBToColor($FD, $FD, $FD);
|
ADest.Rectangle(3, 3, ASize.cx - 4, ASize.cy - 4);
|
||||||
Pen.Color := clBlack;
|
ADest.Pen.Color := clBlack;
|
||||||
Pen.Style := psSolid;
|
ADest.Pen.Style := psDot;
|
||||||
Rectangle(0, 0, Width, Height);
|
ADest.Rectangle(3, 3, ASize.cx - 4, ASize.cy - 4);
|
||||||
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 := AStateEx.RGBColor;
|
|
||||||
Pen.Color := clBlack;
|
|
||||||
Pen.Style := psSolid;
|
|
||||||
Rectangle(0, 0, Width, Height);
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
ADest.Draw(0, 0, TmpB);
|
|
||||||
|
|
||||||
TmpB.Free;
|
|
||||||
|
|
||||||
// Button text
|
// Button text
|
||||||
ADest.Font.Assign(AStateEx.Font);
|
ADest.Font.Assign(AStateEx.Font);
|
||||||
ADest.Brush.Style := bsClear;
|
ADest.Brush.Style := bsClear;
|
||||||
ADest.Pen.Style := psSolid;
|
ADest.Pen.Style := psSolid;
|
||||||
Str := AStateEx.Caption;
|
Str := AStateEx.Caption;
|
||||||
ADest.TextOut((ASize.cx - ADest.TextWidth(Str)) div 2,
|
if csfSunken in AState then
|
||||||
(ASize.cy - ADest.TextHeight(Str)) div 2, Str);
|
ADest.TextOut((ASize.cx - ADest.TextWidth(Str)) div 2 + 1,
|
||||||
|
(ASize.cy - ADest.TextHeight(Str)) div 2 + 1, Str)
|
||||||
|
else
|
||||||
|
ADest.TextOut((ASize.cx - ADest.TextWidth(Str)) div 2,
|
||||||
|
(ASize.cy - ADest.TextHeight(Str)) div 2, Str);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCDDrawerCommon.DrawEditBackground(ADest: TCanvas;
|
procedure TCDDrawerCommon.DrawEditBackground(ADest: TCanvas;
|
||||||
|
@ -15,99 +15,15 @@ uses
|
|||||||
customdrawndrawers, customdrawn_common;
|
customdrawndrawers, customdrawn_common;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
|
{ TCDDrawerWin2k }
|
||||||
|
|
||||||
TCDDrawerWin2k = class(TCDDrawerCommon)
|
TCDDrawerWin2k = class(TCDDrawerCommon)
|
||||||
public
|
public
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
{procedure TCDButtonDrawerWin2k.DrawToIntfImage(ADest: TFPImageCanvas;
|
|
||||||
CDButton: TCDButton);
|
|
||||||
begin
|
|
||||||
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TCDButtonDrawerWin2k.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);
|
|
||||||
|
|
||||||
with TmpB.Canvas do
|
|
||||||
begin
|
|
||||||
Brush.Style := bsSolid;
|
|
||||||
Brush.Color := CDButton.Color;
|
|
||||||
Pen.Color := clWhite;
|
|
||||||
Pen.Style := psSolid;
|
|
||||||
Rectangle(0, 0, Width - 1, Height - 1);
|
|
||||||
Pen.Color := clWhite;
|
|
||||||
Line(0, 0, Width - 1, 0);
|
|
||||||
Line(0, 0, 0, Height - 1);
|
|
||||||
Pen.Color := clGray;
|
|
||||||
Line(0, Height - 1, Width - 1, Height - 1);
|
|
||||||
Line(Width - 1, Height - 1, Width - 1, -1);
|
|
||||||
Pen.Color := $0099A8AC;
|
|
||||||
Line(1, Height - 2, Width - 2, Height - 2);
|
|
||||||
Line(Width - 2, Height - 2, Width - 2, 0);
|
|
||||||
Pen.Color := $00E2EFF1;
|
|
||||||
Line(1, 1, Width - 2, 1);
|
|
||||||
Line(1, 1, 1, Height - 2);
|
|
||||||
end;
|
|
||||||
|
|
||||||
// Button image
|
|
||||||
if CDButton.IsDown then
|
|
||||||
begin
|
|
||||||
with TmpB.Canvas do
|
|
||||||
begin
|
|
||||||
Brush.Style := bsSolid;
|
|
||||||
Brush.Color := CDButton.Color;
|
|
||||||
Pen.Color := clWhite;
|
|
||||||
Pen.Style := psSolid;
|
|
||||||
Rectangle(0, 0, Width - 1, Height - 1);
|
|
||||||
Pen.Color := clGray;
|
|
||||||
Line(0, 0, Width - 1, 0);
|
|
||||||
Line(0, 0, 0, Height - 1);
|
|
||||||
Pen.Color := clWhite;
|
|
||||||
Line(0, Height - 1, Width - 1, Height - 1);
|
|
||||||
Line(Width - 1, Height - 1, Width - 1, -1);
|
|
||||||
Pen.Color := $00E2EFF1;
|
|
||||||
Line(1, Height - 2, Width - 2, Height - 2);
|
|
||||||
Line(Width - 2, Height - 2, Width - 2, 0);
|
|
||||||
Pen.Color := $0099A8AC;
|
|
||||||
Line(1, 1, Width - 2, 1);
|
|
||||||
Line(1, 1, 1, Height - 2);
|
|
||||||
end;
|
|
||||||
end
|
|
||||||
else if CDButton.Focused then
|
|
||||||
begin
|
|
||||||
with TmpB.Canvas do
|
|
||||||
DrawFocusRect(Rect(3, 3, Width - 4, Height - 4))
|
|
||||||
end;
|
|
||||||
|
|
||||||
ADest.Draw(0, 0, TmpB);
|
|
||||||
|
|
||||||
TmpB.Free;
|
|
||||||
|
|
||||||
// Button text
|
|
||||||
ADest.Font.Assign(CDButton.Font);
|
|
||||||
ADest.Brush.Style := bsClear;
|
|
||||||
ADest.Pen.Style := psSolid;
|
|
||||||
Str := CDButton.Caption;
|
|
||||||
if CDButton.IsDown then
|
|
||||||
ADest.TextOut((CDButton.Width - ADest.TextWidth(Str)) div 2 + 1,
|
|
||||||
(CDButton.Height - ADest.TextHeight(Str)) div 2 + 1, Str)
|
|
||||||
else
|
|
||||||
ADest.TextOut((CDButton.Width - ADest.TextWidth(Str)) div 2,
|
|
||||||
(CDButton.Height - ADest.TextHeight(Str)) div 2, Str);
|
|
||||||
end;}
|
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
RegisterDrawer(TCDDrawerWin2k.Create, dsWin2000);
|
RegisterDrawer(TCDDrawerWin2k.Create, dsWin2000);
|
||||||
end.
|
end.
|
||||||
|
@ -6,7 +6,7 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
// RTL
|
// RTL
|
||||||
Classes, SysUtils,
|
Classes, SysUtils, Types,
|
||||||
// LCL -> Use only TForm, TWinControl, TCanvas and TLazIntfImage
|
// LCL -> Use only TForm, TWinControl, TCanvas and TLazIntfImage
|
||||||
Graphics, Controls, LCLType,
|
Graphics, Controls, LCLType,
|
||||||
// Others only for types
|
// Others only for types
|
||||||
@ -17,10 +17,77 @@ uses
|
|||||||
type
|
type
|
||||||
TCDDrawerWinCE = class(TCDDrawerCommon)
|
TCDDrawerWinCE = class(TCDDrawerCommon)
|
||||||
public
|
public
|
||||||
|
// ===================================
|
||||||
|
// Standard Tab
|
||||||
|
// ===================================
|
||||||
|
// TCDButton
|
||||||
|
procedure DrawButton(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
||||||
|
AState: TCDControlState; AStateEx: TCDControlStateEx); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
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
|
||||||
|
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;
|
||||||
|
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;
|
||||||
|
end;
|
||||||
|
|
||||||
|
ADest.Draw(0, 0, TmpB);
|
||||||
|
|
||||||
|
TmpB.Free;
|
||||||
|
|
||||||
|
// Button text
|
||||||
|
ADest.Font.Assign(AStateEx.Font);
|
||||||
|
ADest.Brush.Style := bsClear;
|
||||||
|
ADest.Pen.Style := psSolid;
|
||||||
|
Str := AStateEx.Caption;
|
||||||
|
ADest.TextOut((ASize.cx - ADest.TextWidth(Str)) div 2,
|
||||||
|
(ASize.cy - ADest.TextHeight(Str)) div 2, Str);
|
||||||
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
RegisterDrawer(TCDDrawerWinCE.Create, dsWinCE);
|
RegisterDrawer(TCDDrawerWinCE.Create, dsWinCE);
|
||||||
end.
|
end.
|
||||||
|
Loading…
Reference in New Issue
Block a user