diff --git a/.gitattributes b/.gitattributes
index a2695e75f5..fe9128f6f6 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -638,6 +638,11 @@ components/compilers/javascript/examples/jsclassxmlread.pas svneol=native#text/p
components/custom/README.txt svneol=native#text/plain
components/customdrawn/customdrawn.lpk svneol=native#text/plain
components/customdrawn/customdrawn.pas svneol=native#text/pascal
+components/customdrawn/customdrawn_android.pas svneol=native#text/plain
+components/customdrawn/customdrawn_extra1.pas svneol=native#text/plain
+components/customdrawn/customdrawn_win2000.pas svneol=native#text/plain
+components/customdrawn/customdrawn_wince.pas svneol=native#text/plain
+components/customdrawn/customdrawn_winxp.pas svneol=native#text/plain
components/customdrawn/customdrawncontrols.pas svneol=native#text/pascal
components/customdrawn/customdrawnextras.pas svneol=native#text/plain
components/customdrawn/customdrawnutils.pas svneol=native#text/pascal
diff --git a/components/customdrawn/customdrawn.lpk b/components/customdrawn/customdrawn.lpk
index 32387af516..8672036e46 100644
--- a/components/customdrawn/customdrawn.lpk
+++ b/components/customdrawn/customdrawn.lpk
@@ -23,7 +23,7 @@
-
+
@@ -37,6 +37,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/components/customdrawn/customdrawn.pas b/components/customdrawn/customdrawn.pas
index c9e4d065ee..669fc88312 100644
--- a/components/customdrawn/customdrawn.pas
+++ b/components/customdrawn/customdrawn.pas
@@ -7,7 +7,9 @@ unit customdrawn;
interface
uses
- customdrawnextras, customdrawnutils, customdrawncontrols, LazarusPackageIntf;
+ customdrawnextras, customdrawnutils, customdrawncontrols, customdrawn_wince,
+ customdrawn_win2000, customdrawn_winxp, customdrawn_android,
+ customdrawn_extra1, LazarusPackageIntf;
implementation
diff --git a/components/customdrawn/customdrawn_android.pas b/components/customdrawn/customdrawn_android.pas
new file mode 100644
index 0000000000..f937a14946
--- /dev/null
+++ b/components/customdrawn/customdrawn_android.pas
@@ -0,0 +1,79 @@
+unit customdrawn_android;
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+ // RTL
+ Classes, SysUtils,
+ // fpimage
+ fpcanvas, fpimgcanv, fpimage,
+ // LCL -> Use only TForm, TWinControl, TCanvas and TLazIntfImage
+ Graphics, Controls, LCLType, LCLIntf, IntfGraphics,
+ //
+ customdrawncontrols, customdrawnutils;
+
+type
+ TCDButtonDrawerAndroid = class(TCDButtonDrawer)
+ public
+ procedure DrawToIntfImage(ADest: TFPImageCanvas; CDButton: TCDButton); override;
+ procedure DrawToCanvas(ADest: TCanvas; CDButton: TCDButton;
+ FState: TCDButtonState); override;
+ end;
+
+implementation
+
+procedure TCDButtonDrawerAndroid.DrawToIntfImage(ADest: TFPImageCanvas;
+ CDButton: TCDButton);
+begin
+
+end;
+
+procedure TCDButtonDrawerAndroid.DrawToCanvas(ADest: TCanvas;
+ CDButton: TCDButton; FState: TCDButtonState);
+var
+ //TmpB: TBitmap;
+ Str: string;
+begin
+ // Button shape -> This crashes in Gtk2
+{ 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);
+ ADest.Draw(0, 0, TmpB);
+ TmpB.Free;
+ }
+
+ ADest.Brush.Color := CDButton.Parent.Color;
+ ADest.Brush.Style := bsSolid;
+ ADest.Pen.Color := ADest.Brush.Color;
+ ADest.RecTangle(0, 0, CDButton.Width, CDButton.Height);
+
+ // Button image
+ case FState of
+ bbsDown:
+ begin
+ DrawCDButtonDown(ADest, CDButton.GetRGBBackgroundColor);
+ end;
+ bbsFocused:
+ begin
+ DrawAndroidButton(ADest, GetAColor(CDButton.Color, 98));
+ end;
+ else
+ DrawAndroidButton(ADest, GetAColor(CDButton.Color, 96));
+ end;
+
+ // Button text
+ 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);
+end;
+
+initialization
+ RegisterButtonDrawer(TCDButtonDrawerAndroid.Create, dsAndroid);
+end.
+
diff --git a/components/customdrawn/customdrawn_extra1.pas b/components/customdrawn/customdrawn_extra1.pas
new file mode 100644
index 0000000000..37828fcd97
--- /dev/null
+++ b/components/customdrawn/customdrawn_extra1.pas
@@ -0,0 +1,208 @@
+unit customdrawn_extra1;
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+ // RTL
+ Classes, SysUtils,
+ // fpimage
+ fpcanvas, fpimgcanv, fpimage,
+ // LCL -> Use only TForm, TWinControl, TCanvas and TLazIntfImage
+ Graphics, Controls, LCLType, LCLIntf, IntfGraphics,
+ //
+ customdrawncontrols, customdrawnutils;
+
+type
+ TCDButtonDrawerGrad = class(TCDButtonDrawer)
+ public
+ procedure DrawToIntfImage(ADest: TFPImageCanvas; CDButton: TCDButton); override;
+ procedure DrawToCanvas(ADest: TCanvas; CDButton: TCDButton;
+ FState: TCDButtonState); override;
+ end;
+
+ TCDTrackBarDrawerGraph = class(TCDTrackBarDrawer)
+ public
+ procedure DrawToIntfImage(ADest: TFPImageCanvas; FPImg: TLazIntfImage;
+ CDTrackBar: TCDTrackBar); override;
+ procedure GetGeometry(var ALeftBorder, ARightBorder: Integer); override;
+ end;
+
+implementation
+
+procedure TCDButtonDrawerGrad.DrawToIntfImage(ADest: TFPImageCanvas;
+ CDButton: TCDButton);
+begin
+
+end;
+
+procedure TCDButtonDrawerGrad.DrawToCanvas(ADest: TCanvas; CDButton: TCDButton;
+ FState: TCDButtonState);
+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);
+
+ with TmpB.Canvas do
+ begin
+ Brush.Style := bsSolid;
+ Brush.Color := CDButton.Parent.Color;
+ Pen.Color := Brush.Color;
+ Rectangle(0, 0, Width, Height);
+ FillRect(0, 0, Width, Height);
+ Brush.Color := GetAColor(CDButton.Color, 90);
+ end;
+
+ // Button image
+ case FState of
+ bbsDown:
+ begin
+ DrawCDButtonDown(TmpB.Canvas, CDButton.GetRGBBackgroundColor);
+ end;
+ bbsFocused:
+ //GradientFill(GetUColor(CDButton.Color, 50), GetAColor(CDButton.Color, 60), TmpB.Canvas);
+ GradientFill(clWhite, GetAColor(CDButton.Color, 96), TmpB.Canvas);
+ else
+ //GradientFill(GetUColor(CDButton.Color, 10), GetAColor(CDButton.Color, 20), TmpB.Canvas);
+ GradientFill(clWhite, CDButton.Color, TmpB.Canvas);
+ 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;
+ ADest.TextOut((CDButton.Width - ADest.TextWidth(Str)) div 2,
+ (CDButton.Height - ADest.TextHeight(Str)) div 2, Str);
+end;
+
+{ TCDTrackBarDrawer }
+
+procedure TCDTrackBarDrawerGraph.DrawToIntfImage(ADest: TFPImageCanvas;
+ FPImg: TLazIntfImage; CDTrackBar: TCDTrackBar);
+const
+ CDBarEdge = 18;
+var
+ lDrawingBottom, StepsCount, i: Integer;
+ pStart, pEnd: integer; // for drawing the decorative bars
+ dRect: TRect;
+ pStepWidth, pHalfStepWidth: Integer;
+begin
+ // Sanity check
+ if CDTrackBar.Max - CDTrackBar.Min <= 0 then
+ raise Exception.Create('[TCDTrackBarDrawerGraph.DrawToIntfImage] Max-Min must be at least 1');
+
+ // Preparations
+ StepsCount := CDTrackBar.Max - CDTrackBar.Min + 1;
+ pStepWidth := (CDTrackBar.Width - CDBarEdge) div StepsCount;
+ pHalfStepWidth := (CDTrackBar.Width - CDBarEdge) div (StepsCount * 2);
+
+ // The bottom part of the drawing
+ lDrawingBottom := CDTrackBar.Height - 10;
+
+ // Background
+
+ if CDTrackBar.Parent = nil then
+ ADest.Brush.FPColor := colLtGray
+ else
+ ADest.Brush.FPColor := TColorToFPColor(ColorToRGB(CDTrackBar.Color));
+ ADest.Brush.Style := bsSolid;
+ ADest.Pen.Style := psClear;
+ ADest.Rectangle(0, 0, CDTrackBar.Width, CDTrackBar.Height);
+ ADest.Brush.FPColor := TColorToFPColor(ColorToRGB($006BB6E6));
+
+ // Draws the double-sided arrow in the center of the slider
+
+ ADest.Pen.Style := psSolid;
+ ADest.Pen.FPColor := TColorToFPColor(ColorToRGB($006BB6E6));
+ ADest.Line(0, lDrawingBottom, CDTrackBar.Width, lDrawingBottom);
+ ADest.Line(3, lDrawingBottom - 1, 6, lDrawingBottom - 1);
+ ADest.Line(5, lDrawingBottom - 2, 6, lDrawingBottom - 2);
+ ADest.Line(3, lDrawingBottom + 1, 6, lDrawingBottom + 1);
+ ADest.Line(5, lDrawingBottom + 2, 6, lDrawingBottom + 2);
+ ADest.Line(CDTrackBar.Width - 1 - 3, lDrawingBottom - 1, CDTrackBar.Width - 1 - 6, lDrawingBottom - 1);
+ ADest.Line(CDTrackBar.Width - 1 - 5, lDrawingBottom - 2, CDTrackBar.Width - 1 - 6, lDrawingBottom - 2);
+ ADest.Line(CDTrackBar.Width - 1 - 3, lDrawingBottom + 1, CDTrackBar.Width - 1 - 6, lDrawingBottom + 1);
+ ADest.Line(CDTrackBar.Width - 1 - 5, lDrawingBottom + 2, CDTrackBar.Width - 1 - 6, lDrawingBottom + 2);
+ ADest.Pen.FPColor := TColorToFPColor(ColorToRGB(clGray));
+ ADest.Brush.FPColor := TColorToFPColor(ColorToRGB($00F0F0F0));
+
+ // Draws the decorative bars and also the slider button
+
+ pStart := 10 - 1;
+ for i := 0 to StepsCount - 1 do
+ begin
+ // Draw the decorative bars
+ dRect := Bounds(
+ pStart + pHalfStepWidth,
+ lDrawingBottom - 5 - i,
+ Round(pStepWidth)-3,
+ 4 + i);
+
+ ADest.Brush.Style := bsSolid;
+ ADest.Pen.Style := psSolid;
+ ADest.Pen.FPColor := colBlack;
+ if i + CDTrackBar.Min <= CDTrackBar.Position then
+ ADest.Brush.FPColor := colDkGray
+ else
+ ADest.Brush.FPColor := colWhite;
+
+ ADest.Rectangle(dRect);
+
+ // Draw the slider
+
+ if i + CDTrackBar.Min = CDTrackBar.Position then
+ 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.RecTangle(pStart, lDrawingBottom + 2, pStart + 10, lDrawingBottom + 7);
+ ADest.Pen.FPColor := TColorToFPColor(ColorToRGB($006BB6E6));
+ ADest.RecTangle(pStart, lDrawingBottom, pStart + 10, lDrawingBottom + 2);
+ end;
+ pStart := pStart + pStepWidth;
+ end;
+
+ ADest.Pen.FPColor := TColorToFPColor(ColorToRGB($007BC6F6));
+ ADest.Line(7, lDrawingBottom - 1, CDTrackBar.Width - 8, lDrawingBottom - 1);
+ ADest.Line(7, lDrawingBottom + 1, CDTrackBar.Width - 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[CDTrackBar.Width - 1 - 2, lDrawingBottom - 1] := ADest.Pen.FPColor;
+ ADest.Colors[CDTrackBar.Width - 1 - 4, lDrawingBottom - 2] := ADest.Pen.FPColor;
+ ADest.Colors[CDTrackBar.Width - 1 - 2, lDrawingBottom + 1] := ADest.Pen.FPColor;
+ ADest.Colors[CDTrackBar.Width - 1 - 4, lDrawingBottom + 2] := ADest.Pen.FPColor;
+ ADest.Colors[CDTrackBar.Width - 1 - 6, lDrawingBottom - 3] := ADest.Pen.FPColor;
+ ADest.Colors[CDTrackBar.Width - 1 - 6, lDrawingBottom + 3] := ADest.Pen.FPColor;
+end;
+
+procedure TCDTrackBarDrawerGraph.GetGeometry(var ALeftBorder,
+ ARightBorder: Integer);
+begin
+ ALeftBorder := 9;
+ ARightBorder := 9;
+end;
+
+initialization
+ RegisterButtonDrawer(TCDButtonDrawerGrad.Create, dsExtra1);
+ RegisterTrackBarDrawer(TCDTrackBarDrawerGraph.Create, dsExtra1);
+end.
+
diff --git a/components/customdrawn/customdrawn_win2000.pas b/components/customdrawn/customdrawn_win2000.pas
new file mode 100644
index 0000000000..9fc5df8761
--- /dev/null
+++ b/components/customdrawn/customdrawn_win2000.pas
@@ -0,0 +1,121 @@
+unit customdrawn_win2000;
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+ // RTL
+ Classes, SysUtils,
+ // fpimage
+ fpcanvas, fpimgcanv, fpimage,
+ // LCL -> Use only TForm, TWinControl, TCanvas and TLazIntfImage
+ Graphics, Controls, LCLType, LCLIntf, IntfGraphics,
+ //
+ customdrawncontrols, customdrawnutils;
+
+type
+ TCDButtonDrawerWin2k = class(TCDButtonDrawer)
+ public
+ procedure DrawToIntfImage(ADest: TFPImageCanvas; CDButton: TCDButton); override;
+ procedure DrawToCanvas(ADest: TCanvas; CDButton: TCDButton;
+ FState: TCDButtonState); override;
+ end;
+
+implementation
+
+procedure TCDButtonDrawerWin2k.DrawToIntfImage(ADest: TFPImageCanvas;
+ CDButton: TCDButton);
+begin
+
+end;
+
+procedure TCDButtonDrawerWin2k.DrawToCanvas(ADest: TCanvas; CDButton: TCDButton;
+ FState: TCDButtonState);
+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
+ case FState of
+ bbsDown:
+ 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;
+ bbsFocused:
+ with TmpB.Canvas do
+ DrawFocusRect(Rect(3, 3, Width - 4, Height - 4))
+ else
+ begin
+ end;
+ 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 FState = bbsDown 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
+ RegisterButtonDrawer(TCDButtonDrawerWin2k.Create, dsWin2000);
+end.
+
diff --git a/components/customdrawn/customdrawn_wince.pas b/components/customdrawn/customdrawn_wince.pas
new file mode 100644
index 0000000000..5fefaa8907
--- /dev/null
+++ b/components/customdrawn/customdrawn_wince.pas
@@ -0,0 +1,534 @@
+unit customdrawn_wince;
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+ // RTL
+ Classes, SysUtils,
+ // fpimage
+ fpcanvas, fpimgcanv, fpimage,
+ // LCL -> Use only TForm, TWinControl, TCanvas and TLazIntfImage
+ Graphics, Controls, LCLType, LCLIntf, IntfGraphics,
+ //
+ customdrawncontrols, customdrawnutils;
+
+type
+ TCDButtonDrawerWinCE = class(TCDButtonDrawer)
+ public
+ procedure DrawToIntfImage(ADest: TFPImageCanvas; CDButton: TCDButton); override;
+ procedure DrawToCanvas(ADest: TCanvas; CDButton: TCDButton;
+ FState: TCDButtonState); override;
+ end;
+
+ TCDGroupBoxDrawerWinCE = class(TCDGroupBoxDrawer)
+ public
+ FCaptionMiddle: integer;
+ procedure SetClientRectPos(CDGroupBox: TCDGroupBox); override;
+ procedure DrawToIntfImage(ADest: TFPImageCanvas; CDGroupBox: TCDGroupBox); override;
+ procedure DrawToCanvas(ADest: TCanvas; CDGroupBox: TCDGroupBox); override;
+ end;
+
+ TCDCustomTabControlDrawerWinCE = class(TCDCustomTabControlDrawer)
+ private
+ StartIndex: integer; //FEndIndex
+ LeftmostTabVisibleIndex: Integer;
+ procedure DrawCaptionBar(ADest: TCanvas; lRect: TRect; CL: TColor);
+ procedure DrawTabs(ADest: TCanvas; CDTabControl: TCDCustomTabControl);
+ procedure DrawTab(ADest: TCanvas; AIndex: Integer; ACurStartLeftPos: Integer;
+ CDTabControl: TCDCustomTabControl);
+ public
+ function GetPageIndexFromXY(x, y: integer): integer; override;
+ function GetTabHeight(AIndex: Integer; CDTabControl: TCDCustomTabControl): Integer; override;
+ function GetTabWidth(ADest: TCanvas; AIndex: Integer; CDTabControl: TCDCustomTabControl): Integer; override;
+ //function GetClientRect(AControl: TCDControl): TRect; override;
+ procedure DrawToIntfImage(ADest: TFPImageCanvas; FPImg: TLazIntfImage;
+ CDTabControl: TCDCustomTabControl); override;
+ procedure DrawToCanvas(ADest: TCanvas; CDTabControl: TCDCustomTabControl); override;
+ procedure DrawTabSheet(ADest: TCanvas; CDTabControl: TCDCustomTabControl); override;
+ procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
+ X, Y: integer; CDTabControl: TCDCustomTabControl); override;
+ end;
+
+implementation
+
+{ TCDButtonDrawerWinCE }
+
+procedure TCDButtonDrawerWinCE.DrawToIntfImage(ADest: TFPImageCanvas;
+ CDButton: TCDButton);
+begin
+
+end;
+
+procedure TCDButtonDrawerWinCE.DrawToCanvas(ADest: TCanvas; CDButton: TCDButton;
+ FState: TCDButtonState);
+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
+ case FState of
+ bbsDown:
+ begin
+ with TmpB.Canvas do
+ begin
+ Brush.Style := bsSolid;
+ Brush.Color := GetAColor(CDButton.Color, 90);
+ Pen.Color := clBlack;
+ Pen.Style := psSolid;
+ Rectangle(0, 0, Width, Height);
+ end;
+ end;
+ bbsFocused:
+ 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;
+ else
+ 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 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
+ RegisterButtonDrawer(TCDButtonDrawerWinCE.Create, dsWinCE);
+ RegisterGroupBoxDrawer(TCDGroupBoxDrawerWinCE.Create, dsWinCE);
+ RegisterCustomTabControlDrawer(TCDCustomTabControlDrawerWinCE.Create, dsWinCE);
+end.
+
diff --git a/components/customdrawn/customdrawn_winxp.pas b/components/customdrawn/customdrawn_winxp.pas
new file mode 100644
index 0000000000..a2e06b5773
--- /dev/null
+++ b/components/customdrawn/customdrawn_winxp.pas
@@ -0,0 +1,63 @@
+unit customdrawn_winxp;
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+ // RTL
+ Classes, SysUtils,
+ // fpimage
+ fpcanvas, fpimgcanv, fpimage,
+ // LCL -> Use only TForm, TWinControl, TCanvas and TLazIntfImage
+ Graphics, Controls, LCLType, LCLIntf, IntfGraphics,
+ //
+ customdrawncontrols, customdrawnutils;
+
+type
+ TCDButtonDrawerXPTB = class(TCDButtonDrawer)
+ public
+ procedure DrawToIntfImage(ADest: TFPImageCanvas; CDButton: TCDButton); override;
+ procedure DrawToCanvas(ADest: TCanvas; CDButton: TCDButton;
+ FState: TCDButtonState); override;
+ end;
+
+implementation
+
+procedure TCDButtonDrawerXPTB.DrawToIntfImage(ADest: TFPImageCanvas;
+ CDButton: TCDButton);
+begin
+
+end;
+
+procedure TCDButtonDrawerXPTB.DrawToCanvas(ADest: TCanvas; CDButton: TCDButton;
+ FState: TCDButtonState);
+var
+ Str: string;
+begin
+ case FState of
+ bbsDown:
+ begin
+ DrawCDButtonDown(ADest, CDButton.GetRGBBackgroundColor);
+ end;
+ bbsFocused:
+ begin
+ DrawXPTaskbarButton(ADest, GetAColor(CDButton.Color, 98));
+ end;
+ else
+ DrawXPTaskbarButton(ADest, CDButton.Color);
+ end;
+
+ // Button text
+ 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);
+end;
+
+initialization
+ RegisterButtonDrawer(TCDButtonDrawerXPTB.Create, dsWinXP);
+end.
+
diff --git a/components/customdrawn/customdrawncontrols.pas b/components/customdrawn/customdrawncontrols.pas
index 35e29a1bdb..b07cb86cde 100644
--- a/components/customdrawn/customdrawncontrols.pas
+++ b/components/customdrawn/customdrawncontrols.pas
@@ -16,26 +16,24 @@ interface
uses
// FPC
Classes, SysUtils, contnrs, Math, types,
+ // fpimage
+ fpcanvas, fpimgcanv, fpimage,
// LCL
Graphics, Controls, LCLType, LCLIntf, IntfGraphics,
- customdrawnutils, LMessages, Messages,
- LCLProc, PropEdits, ExtCtrls, ImgList, Forms, Menus,
- // fpimage
- fpcanvas, fpimgcanv, fpimage
- {$ifdef CUSTOMDRAWN_USE_FREETYPE}
- // font support
- , ftfont
- {$endif} ;
+ LMessages, Messages, LCLProc, Forms,
+ //
+ customdrawnutils;
type
TCDDrawStyle = (
// Operating system styles
- dsWinCE, dsWin2000, dsAndroid, dsXPTaskBar,
- // Other special styles
- dsGrad,
- // Defined by the user
- dsCustom);
+ dsWinCE, dsWin2000, dsWinXP,
+ dsKDE, dsGNOME, dsMacOSX,
+ dsAndroid,
+ // Other special styles for the user
+ dsExtra1, dsExtra2, dsExtra3, dsExtra4
+ );
// commented items are not yet supported
TCDButtonState = (bbsNormal, bbsDown, bbsMouseOver, bbsFocused
@@ -52,12 +50,13 @@ type
//constructor Create(AOwner: TComponent); override;
//destructor Destroy; override;
procedure PrepareCurrentDrawer(); virtual;
- procedure SetDrawStyle(const AValue: TCDDrawStyle);
+ procedure SetDrawStyle(const AValue: TCDDrawStyle); virtual;
function GetClientRect: TRect; override;
procedure EraseBackground(DC: HDC); override;
property DrawStyle: TCDDrawStyle read FDrawStyle write SetDrawStyle;
public
end;
+ TCDControlClass = class of TCDControl;
TCDControlDrawer = class
public
@@ -68,22 +67,11 @@ type
end;
TCDButtonDrawer = class;
- TCDButtonDrawerWinCE = class;
- TCDButtonDrawerAndroid = class;
- TCDButtonDrawerXPTB = class;
- TCDButtonDrawerGrad = class;
- TCDButtonDrawerWin2k = class;
{ TCDButton }
TCDButton = class(TCDControl)
private
- //FCurrentDrawer: TCDButtonDrawer;
- FDrawerWinCE: TCDButtonDrawerWinCE;
- FDrawerAndroid: TCDButtonDrawerAndroid;
- FDrawerXPTB: TCDButtonDrawerXPTB;
- FDrawerGrad: TCDButtonDrawerGrad;
- FDrawerWin2k: TCDButtonDrawerWin2k;
procedure PrepareCurrentDrawer(); override;
protected
FState: TCDButtonState;
@@ -103,7 +91,6 @@ type
procedure DoButtonUp();
procedure RealSetText(const Value: TCaption); override;
public
- CustomDrawer: TCDButtonDrawer;
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Paint; override;
@@ -113,7 +100,7 @@ type
property Caption;
property Color;
property Constraints;
- property DrawStyle: TCDDrawStyle read FDrawStyle write SetDrawStyle;
+ property DrawStyle;
property Enabled;
property Font;
property OnChangeBounds;
@@ -155,77 +142,34 @@ type
FState: TCDButtonState); virtual; abstract;
end;
- { TCDButtonDrawerWinCE }
-
- TCDButtonDrawerWinCE = class(TCDButtonDrawer)
- public
- procedure DrawToIntfImage(ADest: TFPImageCanvas; CDButton: TCDButton); override;
- procedure DrawToCanvas(ADest: TCanvas; CDButton: TCDButton;
- FState: TCDButtonState); override;
- end;
-
- { TCDButtonDrawerAndroid }
- TCDButtonDrawerAndroid = class(TCDButtonDrawer)
- public
- procedure DrawToIntfImage(ADest: TFPImageCanvas; CDButton: TCDButton); override;
- procedure DrawToCanvas(ADest: TCanvas; CDButton: TCDButton;
- FState: TCDButtonState); override;
- end;
-
- TCDButtonDrawerXPTB = class(TCDButtonDrawer)
- public
- procedure DrawToIntfImage(ADest: TFPImageCanvas; CDButton: TCDButton); override;
- procedure DrawToCanvas(ADest: TCanvas; CDButton: TCDButton;
- FState: TCDButtonState); override;
- end;
-
- TCDButtonDrawerGrad = class(TCDButtonDrawer)
- public
- procedure DrawToIntfImage(ADest: TFPImageCanvas; CDButton: TCDButton); override;
- procedure DrawToCanvas(ADest: TCanvas; CDButton: TCDButton;
- FState: TCDButtonState); override;
- end;
-
- TCDButtonDrawerWin2k = class(TCDButtonDrawer)
- public
- procedure DrawToIntfImage(ADest: TFPImageCanvas; CDButton: TCDButton); override;
- procedure DrawToCanvas(ADest: TCanvas; CDButton: TCDButton;
- FState: TCDButtonState); override;
- end;
-
{@@
TCDGroupBox is a custom-drawn group box control
}
TCDGroupBoxDrawer = class;
- TCDGroupBoxDrawerWinCE = class;
{ TCDGroupBox }
- TCDGroupBox = class(TCustomControl)
+ TCDGroupBox = class(TCDControl)
private
- FDrawStyle: TCDDrawStyle;
- FCurrentDrawer: TCDGroupBoxDrawer;
- FDrawerWinCE: TCDGroupBoxDrawerWinCE;
- procedure PrepareCurrentDrawer();
- procedure SetDrawStyle(const AValue: TCDDrawStyle);
+ procedure PrepareCurrentDrawer(); override;
+ procedure SetDrawStyle(const AValue: TCDDrawStyle); override;
protected
procedure RealSetText(const Value: TCaption); override; // to update on caption changes
public
- CustomDrawer: TCDGroupBoxDrawer; // Fill the field to use the dsCustom draw mode
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure EraseBackground(DC: HDC); override;
procedure Paint; override;
published
- property DrawStyle: TCDDrawStyle read FDrawStyle write SetDrawStyle;
+ property DrawStyle;
property Caption;
property TabStop default False;
end;
{ TCDGroupBoxDrawer }
- TCDGroupBoxDrawer = class
+ TCDGroupBoxDrawer = class(TCDControlDrawer)
public
procedure SetClientRectPos(CDGroupBox: TCDGroupBox); virtual; abstract;
procedure DrawToIntfImage(ADest: TFPImageCanvas; CDGroupBox: TCDGroupBox);
@@ -233,16 +177,6 @@ type
procedure DrawToCanvas(ADest: TCanvas; CDGroupBox: TCDGroupBox); virtual; abstract;
end;
- { TCDGroupBoxDrawerWinCE }
-
- TCDGroupBoxDrawerWinCE = class(TCDGroupBoxDrawer)
- public
- FCaptionMiddle: integer;
- procedure SetClientRectPos(CDGroupBox: TCDGroupBox); override;
- procedure DrawToIntfImage(ADest: TFPImageCanvas; CDGroupBox: TCDGroupBox); override;
- procedure DrawToCanvas(ADest: TCanvas; CDGroupBox: TCDGroupBox); override;
- end;
-
{@@
TCDTrackBar is a custom-drawn trackbar control
}
@@ -251,7 +185,7 @@ type
{ TCDTrackBar }
- TCDTrackBar = class(TCustomControl)
+ TCDTrackBar = class(TCDControl)
private
DragDropStarted: boolean;
// fields
@@ -259,7 +193,7 @@ type
FMax: integer;
FPosition: integer;
FOnChange: TNotifyEvent;
- FCurrentDrawer: TCDTrackBarDrawer;
+ procedure PrepareCurrentDrawer(); override;
procedure SetMax(Value: integer);
procedure SetMin(Value: integer);
procedure SetPosition(Value: integer);
@@ -295,29 +229,18 @@ type
{ TCDTrackBarDrawer }
- TCDTrackBarDrawer = class
+ TCDTrackBarDrawer = class(TCDControlDrawer)
public
procedure DrawToIntfImage(ADest: TFPImageCanvas; FPImg: TLazIntfImage;
CDTrackBar: TCDTrackBar); virtual; abstract;
procedure GetGeometry(var ALeftBorder, ARightBorder: Integer); virtual; abstract;
end;
- { TCDTrackBarDrawerGraph }
-
- TCDTrackBarDrawerGraph = class(TCDTrackBarDrawer)
- public
- procedure DrawToIntfImage(ADest: TFPImageCanvas; FPImg: TLazIntfImage;
- CDTrackBar: TCDTrackBar); override;
- procedure GetGeometry(var ALeftBorder, ARightBorder: Integer); override;
- end;
-
{TCDTabControl}
{ TCDCustomTabControl }
TCDCustomTabControl = class;
- TCDCustomTabControlDrawer = class;
- TCDCustomTabControlDrawerWinCE = class;
{ TCDCustomTabSheet }
@@ -336,7 +259,6 @@ type
private
FTabIndex: Integer;
FTabs: TStringList;
- FDrawerWinCE: TCDCustomTabControlDrawerWinCE;
FOnChanging: TNotifyEvent;
FOnChange: TNotifyEvent;
procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
@@ -352,10 +274,9 @@ type
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Paint; override;
- function GetTabCount: Integer;
procedure CorrectTabIndex();
public
- CustomDrawer: TCDCustomTabControlDrawer; // Fill the field to use the dsCustom draw mode
+ function GetTabCount: Integer;
property Tabs: TStringList read FTabs write SetTabs;
property OnChanging: TNotifyEvent read FOnChanging write FOnChanging;
property OnChange: TNotifyEvent read FOnChange write FOnChange;
@@ -366,36 +287,15 @@ type
TCDCustomTabControlDrawer = class(TCDControlDrawer)
public
- CDTabControl: TCDCustomTabControl;
function GetPageIndexFromXY(x, y: integer): integer; virtual; abstract;
- function GetTabHeight(AIndex: Integer): Integer; virtual; abstract;
- function GetTabWidth(ADest: TCanvas; AIndex: Integer): Integer; virtual; abstract;
- procedure DrawToIntfImage(ADest: TFPImageCanvas; FPImg: TLazIntfImage); virtual; abstract;
- procedure DrawToCanvas(ADest: TCanvas); virtual; abstract;
- procedure DrawTabSheet(ADest: TCanvas); virtual; abstract;
+ function GetTabHeight(AIndex: Integer; CDTabControl: TCDCustomTabControl): Integer; virtual; abstract;
+ function GetTabWidth(ADest: TCanvas; AIndex: Integer; CDTabControl: TCDCustomTabControl): Integer; virtual; abstract;
+ procedure DrawToIntfImage(ADest: TFPImageCanvas; FPImg: TLazIntfImage;
+ CDTabControl: TCDCustomTabControl); virtual; abstract;
+ procedure DrawToCanvas(ADest: TCanvas; CDTabControl: TCDCustomTabControl); virtual; abstract;
+ procedure DrawTabSheet(ADest: TCanvas; CDTabControl: TCDCustomTabControl); virtual; abstract;
procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
- X, Y: integer); virtual; abstract;
- end;
-
- { TCDCustomTabControlDrawerWinCE }
-
- TCDCustomTabControlDrawerWinCE = class(TCDCustomTabControlDrawer)
- private
- StartIndex: integer; //FEndIndex
- LeftmostTabVisibleIndex: Integer;
- procedure DrawCaptionBar(ADest: TCanvas; lRect: TRect; CL: TColor);
- procedure DrawTabs(ADest: TCanvas);
- procedure DrawTab(ADest: TCanvas; AIndex: Integer; ACurStartLeftPos: Integer);
- public
- function GetPageIndexFromXY(x, y: integer): integer; override;
- function GetTabHeight(AIndex: Integer): Integer; override;
- function GetTabWidth(ADest: TCanvas; AIndex: Integer): Integer; override;
- //function GetClientRect(AControl: TCDControl): TRect; override;
- procedure DrawToIntfImage(ADest: TFPImageCanvas; FPImg: TLazIntfImage); override;
- procedure DrawToCanvas(ADest: TCanvas); override;
- procedure DrawTabSheet(ADest: TCanvas); override;
- procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
- X, Y: integer); override;
+ X, Y: integer; CDTabControl: TCDCustomTabControl); virtual; abstract;
end;
// TTabSelectedEvent = procedure(Sender: TObject; ATab: TTabItem;
@@ -468,11 +368,50 @@ type
property OnChange;
end;
+procedure RegisterButtonDrawer(ADrawer: TCDButtonDrawer; AStyle: TCDDrawStyle);
+procedure RegisterGroupBoxDrawer(ADrawer: TCDGroupBoxDrawer; AStyle: TCDDrawStyle);
+procedure RegisterTrackBarDrawer(ADrawer: TCDTrackBarDrawer; AStyle: TCDDrawStyle);
+procedure RegisterCustomTabControlDrawer(ADrawer: TCDCustomTabControlDrawer; AStyle: TCDDrawStyle);
+
implementation
resourcestring
sTABSHEET_DEFAULT_NAME = 'CTabSheet';
+var
+ RegisteredButtonDrawers: array[TCDDrawStyle] of TCDButtonDrawer
+ = (nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil);
+ RegisteredGroupBoxDrawers: array[TCDDrawStyle] of TCDGroupBoxDrawer
+ = (nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil);
+ RegisteredTrackBarDrawers: array[TCDDrawStyle] of TCDTrackBarDrawer
+ = (nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil);
+ RegisteredCustomTabControlDrawers: array[TCDDrawStyle] of TCDCustomTabControlDrawer
+ = (nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil);
+
+procedure RegisterButtonDrawer(ADrawer: TCDButtonDrawer; AStyle: TCDDrawStyle);
+begin
+ if RegisteredButtonDrawers[AStyle] <> nil then RegisteredButtonDrawers[AStyle].Free;
+ RegisteredButtonDrawers[AStyle] := ADrawer;
+end;
+
+procedure RegisterGroupBoxDrawer(ADrawer: TCDGroupBoxDrawer; AStyle: TCDDrawStyle);
+begin
+ if RegisteredGroupBoxDrawers[AStyle] <> nil then RegisteredGroupBoxDrawers[AStyle].Free;
+ RegisteredGroupBoxDrawers[AStyle] := ADrawer;
+end;
+
+procedure RegisterTrackBarDrawer(ADrawer: TCDTrackBarDrawer; AStyle: TCDDrawStyle);
+begin
+ if RegisteredTrackBarDrawers[AStyle] <> nil then RegisteredTrackBarDrawers[AStyle].Free;
+ RegisteredTrackBarDrawers[AStyle] := ADrawer;
+end;
+
+procedure RegisterCustomTabControlDrawer(ADrawer: TCDCustomTabControlDrawer; AStyle: TCDDrawStyle);
+begin
+ if RegisteredCustomTabControlDrawers[AStyle] <> nil then RegisteredCustomTabControlDrawers[AStyle].Free;
+ RegisteredCustomTabControlDrawers[AStyle] := ADrawer;
+end;
+
{ TCDCustomTabSheet }
procedure TCDCustomTabSheet.RealSetText(const Value: TCaption);
@@ -506,341 +445,20 @@ begin
inherited Destroy;
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);
-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);
- CurStartLeftPos := CurStartLeftPos + GetTabWidth(ADest, i);
- end;
- end;
-end;
-
-procedure TCDCustomTabControlDrawerWinCE.DrawTab(ADest: TCanvas;
- AIndex: Integer; ACurStartLeftPos: Integer);
-var
- IsSelected: Boolean;
- lTabWidth, lTabHeight, lTabTopPos: Integer;
- Points: array of TPoint;
- lCaption: String;
-begin
- IsSelected := CDTabControl.FTabIndex = AIndex;
-
- if IsSelected then
- begin
- lTabTopPos := 0;
- lTabHeight := GetTabHeight(AIndex);
- end
- else
- begin
- lTabTopPos := 5;
- lTabHeight := GetTabHeight(AIndex)-5;
- end;
-
- lTabWidth := GetTabWidth(ADest, AIndex);
-
- // 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): Integer;
-begin
- if CDTabControl.Font.Size = 0 then
- Result := 32
- else
- Result := CDTabControl.Font.Size + 22;
-end;
-
-function TCDCustomTabControlDrawerWinCE.GetTabWidth(ADest: TCanvas;
- AIndex: Integer): 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);
-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);
-var
- CaptionHeight: Integer;
-begin
- CaptionHeight := GetTabHeight(CDTabControl.FTabIndex);
-
- // 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);
-end;
-
-procedure TCDCustomTabControlDrawerWinCE.DrawTabSheet(ADest: TCanvas);
-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);
-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);
- if (X > CurStartLeftPos) and
- (X < CurStartLeftPos + lTabWidth) and
- (Y < GetTabHeight(i)) then
- begin
- if CDTabControl is TCDPageControl then
- (CDTabControl as TCDPageControl).SetPageIndex(i)
- else
- CDTabControl.SetTabIndex(i);
-
- Exit;
- end;
- CurStartLeftPos := CurStartLeftPos + lTabWidth;
- end;
- end;
-end;
-
{ TCDCustomTabControl }
procedure TCDCustomTabControl.MouseDown(Button: TMouseButton;
Shift: TShiftState; X, Y: integer);
begin
- TCDCustomTabControlDrawer(FCurrentDrawer).MouseDown(Button, Shift, X, Y);
+ TCDCustomTabControlDrawer(FCurrentDrawer).MouseDown(Button, Shift, X, Y, Self);
inherited MouseDown(Button, Shift, X, Y);
end;
procedure TCDCustomTabControl.PrepareCurrentDrawer;
begin
- case FDrawStyle of
- dsWince: FCurrentDrawer := FDrawerWinCE;
- dsCustom: FCurrentDrawer := CustomDrawer;
- end;
+ FCurrentDrawer := RegisteredCustomTabControlDrawers[DrawStyle];
+ if FCurrentDrawer = nil then FCurrentDrawer := RegisteredCustomTabControlDrawers[dsWince];
+ if FCurrentDrawer = nil then raise Exception.Create('No registered custom tab control drawers were found');
end;
procedure TCDCustomTabControl.SetTabIndex(AValue: Integer);
@@ -868,11 +486,8 @@ begin
Height := 184;
TabStop := True;
- FDrawerWinCE := TCDCustomTabControlDrawerWinCE.Create;
- TCDCustomTabControlDrawerWinCE(FDrawerWinCE).CDTabControl := Self;
- CustomDrawer := FDrawerWinCE; // Dummy to avoid designer crashes
- FCurrentDrawer := FDrawerWinCE;
FDrawStyle := dsWinCE;
+ PrepareCurrentDrawer();
ParentColor := True;
ParentFont := True;
@@ -901,10 +516,10 @@ begin
ABmp.Height := Height;
AImage := ABmp.CreateIntfImage;
lCanvas := TFPImageCanvas.Create(AImage);
- TCDCustomTabControlDrawer(FCurrentDrawer).DrawToIntfImage(lCanvas, AImage);
+ TCDCustomTabControlDrawer(FCurrentDrawer).DrawToIntfImage(lCanvas, AImage, Self);
ABmp.LoadFromIntfImage(AImage);
ABmp.Canvas.Font.Assign(Font);
- TCDCustomTabControlDrawer(FCurrentDrawer).DrawToCanvas(ABmp.Canvas);
+ TCDCustomTabControlDrawer(FCurrentDrawer).DrawToCanvas(ABmp.Canvas, Self);
Canvas.Draw(0, 0, ABmp);
finally
if lCanvas <> nil then
@@ -1056,14 +671,9 @@ end;
procedure TCDButton.PrepareCurrentDrawer;
begin
- case DrawStyle of
- dsWince: FCurrentDrawer := FDrawerWinCE;
- dsCustom: FCurrentDrawer := CustomDrawer;
- dsAndroid: FCurrentDrawer := FDrawerAndroid;
- dsXPTaskbar: FCurrentDrawer := FDrawerXPTB;
- dsGrad: FCurrentDrawer := FDrawerGrad;
- dsWin2000: FCurrentDrawer := FDrawerWin2k;
- end;
+ FCurrentDrawer := RegisteredButtonDrawers[DrawStyle];
+ if FCurrentDrawer = nil then FCurrentDrawer := RegisteredButtonDrawers[dsWince];
+ if FCurrentDrawer = nil then raise Exception.Create('No registered button drawers were found');
end;
procedure TCDButton.RealSetText(const Value: TCaption);
@@ -1076,18 +686,14 @@ constructor TCDButton.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
TabStop := True;
- FDrawerWinCE := TCDButtonDrawerWinCE.Create;
- CustomDrawer := FDrawerWinCE; // Dummy to avoid designer crashes
- FDrawerAndroid := TCDButtonDrawerAndroid.Create;
- FDrawerXPTB := TCDButtonDrawerXPTB.Create;
- FDrawerGrad := TCDButtonDrawerGrad.Create;
- FDrawerWin2k := TCDButtonDrawerWin2k.Create;
Width := 120;
Height := 43;
//Color := clTeal;
ParentFont := True;
- FDrawStyle := dsAndroid;
Color := $00F1F5F5;
+
+ FDrawStyle := dsAndroid;
+ PrepareCurrentDrawer();
end;
destructor TCDButton.Destroy;
@@ -1095,21 +701,6 @@ begin
inherited Destroy;
end;
-procedure DrawCDButtonDown(Canvas: TCanvas; CDButton: TCDButton);
-begin
- with Canvas do
- begin
- Brush.Style := bsSolid;
- Brush.Color := CDButton.Color;
- Pen.Color := Brush.Color;
- Rectangle(0, 0, Width, Height);
- FillRect(0, 0, Width, Height);
- Brush.Color := GetAColor(CDButton.Color, 93);
- Pen.Color := GetAColor(Brush.Color, 76);
- RoundRect(0, 0, Width, Height, 8, 8);
- end;
-end;
-
procedure TCDButton.Paint;
var
AImage: TLazIntfImage = nil;
@@ -1143,327 +734,14 @@ begin
end;
end;
-{ TCDButtonDrawerGrad }
-
-procedure TCDButtonDrawerGrad.DrawToIntfImage(ADest: TFPImageCanvas;
- CDButton: TCDButton);
-begin
-
-end;
-
-procedure TCDButtonDrawerGrad.DrawToCanvas(ADest: TCanvas; CDButton: TCDButton;
- FState: TCDButtonState);
-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);
-
- with TmpB.Canvas do
- begin
- Brush.Style := bsSolid;
- Brush.Color := CDButton.Parent.Color;
- Pen.Color := Brush.Color;
- Rectangle(0, 0, Width, Height);
- FillRect(0, 0, Width, Height);
- Brush.Color := GetAColor(CDButton.Color, 90);
- end;
-
- // Button image
- case FState of
- bbsDown:
- begin
- DrawCDButtonDown(TmpB.Canvas, CDButton);
- end;
- bbsFocused:
- //GradientFill(GetUColor(CDButton.Color, 50), GetAColor(CDButton.Color, 60), TmpB.Canvas);
- GradientFill(clWhite, GetAColor(CDButton.Color, 96), TmpB.Canvas);
- else
- //GradientFill(GetUColor(CDButton.Color, 10), GetAColor(CDButton.Color, 20), TmpB.Canvas);
- GradientFill(clWhite, CDButton.Color, TmpB.Canvas);
- 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;
-
-{ TCDButtonDrawerWinCE }
-
-procedure TCDButtonDrawerWinCE.DrawToIntfImage(ADest: TFPImageCanvas;
- CDButton: TCDButton);
-begin
-
-end;
-
-procedure TCDButtonDrawerWinCE.DrawToCanvas(ADest: TCanvas; CDButton: TCDButton;
- FState: TCDButtonState);
-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
- case FState of
- bbsDown:
- begin
- with TmpB.Canvas do
- begin
- Brush.Style := bsSolid;
- Brush.Color := GetAColor(CDButton.Color, 90);
- Pen.Color := clBlack;
- Pen.Style := psSolid;
- Rectangle(0, 0, Width, Height);
- end;
- end;
- bbsFocused:
- 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;
- else
- 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;
-
-procedure TCDButtonDrawerWin2k.DrawToIntfImage(ADest: TFPImageCanvas;
- CDButton: TCDButton);
-begin
-
-end;
-
-procedure TCDButtonDrawerWin2k.DrawToCanvas(ADest: TCanvas; CDButton: TCDButton;
- FState: TCDButtonState);
-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
- case FState of
- bbsDown:
- 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;
- bbsFocused:
- with TmpB.Canvas do
- DrawFocusRect(Rect(3, 3, Width - 4, Height - 4))
- else
- begin
- 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;
- if FState = bbsDown 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);
- {$endif}
-end;
-
-procedure TCDButtonDrawerAndroid.DrawToIntfImage(ADest: TFPImageCanvas;
- CDButton: TCDButton);
-begin
-
-end;
-
-procedure TCDButtonDrawerAndroid.DrawToCanvas(ADest: TCanvas;
- CDButton: TCDButton; FState: TCDButtonState);
-var
- //TmpB: TBitmap;
- Str: string;
-begin
- // Button shape -> This crashes in Gtk2
-{ 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);
- ADest.Draw(0, 0, TmpB);
- TmpB.Free;
- }
-
- ADest.Brush.Color := CDButton.Parent.Color;
- ADest.Brush.Style := bsSolid;
- ADest.Pen.Color := ADest.Brush.Color;
- ADest.RecTangle(0, 0, CDButton.Width, CDButton.Height);
-
- // Button image
- case FState of
- bbsDown:
- begin
- DrawCDButtonDown(ADest, CDButton);
- end;
- bbsFocused:
- begin
- DrawAndroidButton(ADest, GetAColor(CDButton.Color, 98));
- end;
- else
- DrawAndroidButton(ADest, GetAColor(CDButton.Color, 96));
- end;
-
- // 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;
-
-procedure TCDButtonDrawerXPTB.DrawToIntfImage(ADest: TFPImageCanvas;
- CDButton: TCDButton);
-begin
-
-end;
-
-procedure TCDButtonDrawerXPTB.DrawToCanvas(ADest: TCanvas; CDButton: TCDButton;
- FState: TCDButtonState);
-var
- Str: string;
-begin
- case FState of
- bbsDown:
- begin
- DrawCDButtonDown(ADest, CDButton);
- end;
- bbsFocused:
- begin
- DrawXPTaskbarButton(ADest, GetAColor(CDButton.Color, 98));
- end;
- else
- DrawXPTaskbarButton(ADest, CDButton.Color);
- end;
-
- // 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;
{ TCDGroupBox }
procedure TCDGroupBox.PrepareCurrentDrawer();
begin
- case DrawStyle of
- dsWince: FCurrentDrawer := FDrawerWinCE;
- dsCustom: FCurrentDrawer := CustomDrawer;
- end;
+ FCurrentDrawer := RegisteredGroupBoxDrawers[DrawStyle];
+ if FCurrentDrawer = nil then FCurrentDrawer := RegisteredGroupBoxDrawers[dsWince];
+ if FCurrentDrawer = nil then raise Exception.Create('No registered group box drawers were found');
end;
procedure TCDGroupBox.SetDrawStyle(const AValue: TCDDrawStyle);
@@ -1475,7 +753,7 @@ begin
Invalidate;
PrepareCurrentDrawer();
- FCurrentDrawer.SetClientRectPos(Self);
+ TCDGroupBoxDrawer(FCurrentDrawer).SetClientRectPos(Self);
end;
procedure TCDGroupBox.RealSetText(const Value: TCaption);
@@ -1490,10 +768,11 @@ begin
Width := 100;
Height := 100;
TabStop := False;
- FDrawerWinCE := TCDGroupBoxDrawerWinCE.Create;
- CustomDrawer := FDrawerWinCE; // Dummy to avoid designer crashes
ControlStyle := [csAcceptsControls, csCaptureMouse, csClickEvents,
csDoubleClicks, csReplicatable];
+
+ DrawStyle := dsWinCE;
+ PrepareCurrentDrawer();
end;
destructor TCDGroupBox.Destroy;
@@ -1523,10 +802,10 @@ begin
AImage := ABmp.CreateIntfImage;
lCanvas := TFPImageCanvas.Create(AImage);
// First step of the drawing: FCL TFPCustomCanvas for fast pixel access
- FCurrentDrawer.DrawToIntfImage(lCanvas, Self);
+ TCDGroupBoxDrawer(FCurrentDrawer).DrawToIntfImage(lCanvas, Self);
ABmp.LoadFromIntfImage(AImage);
// Second step of the drawing: LCL TCustomCanvas for easy font access
- FCurrentDrawer.DrawToCanvas(ABmp.Canvas, Self);
+ TCDGroupBoxDrawer(FCurrentDrawer).DrawToCanvas(ABmp.Canvas, Self);
Canvas.Draw(0, 0, ABmp);
finally
if lCanvas <> nil then
@@ -1537,93 +816,15 @@ begin
end;
end;
-{ TCDGroupBoxDrawerWinCE }
-
-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
- {$ifndef CUSTOMDRAWN_USE_FREETYPE}
- 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);
- {$endif}
-end;
-
{ TCDTrackBar }
+procedure TCDTrackBar.PrepareCurrentDrawer;
+begin
+ FCurrentDrawer := RegisteredTrackBarDrawers[DrawStyle];
+ if FCurrentDrawer = nil then FCurrentDrawer := RegisteredTrackBarDrawers[dsWince];
+ if FCurrentDrawer = nil then raise Exception.Create('No registered track bar drawers were found');
+end;
+
procedure TCDTrackBar.SetMax(Value: integer);
begin
if Value = FMax then
@@ -1651,7 +852,7 @@ function TCDTrackBar.GetPositionFromMousePos(X, Y: integer): integer;
var
lLeftBorder, lRightBorder: Integer;
begin
- FCurrentDrawer.GetGeometry(lLeftBorder, lRightBorder);
+ TCDTrackBarDrawer(FCurrentDrawer).GetGeometry(lLeftBorder, lRightBorder);
if X > Width - lRightBorder then Result := FMax
else if X < lLeftBorder then Result := FMin
else Result := FMin + (X - lLeftBorder) * (FMax - FMin + 1) div (Width - lRightBorder - lLeftBorder);
@@ -1747,7 +948,10 @@ begin
inherited Create(AOwner);
Height := 25;
Width := 100;
- FCurrentDrawer := TCDTrackBarDrawerGraph.Create;
+
+ DrawStyle := dsExtra1;
+ PrepareCurrentDrawer();
+
Color := clBtnFace;
FMax := 10;
FMin := 0;
@@ -1779,7 +983,7 @@ begin
AImage := ABmp.CreateIntfImage;
lCanvas := TFPImageCanvas.Create(AImage);
// First step of the drawing: FCL TFPCustomCanvas for fast pixel access
- FCurrentDrawer.DrawToIntfImage(lCanvas, AImage, Self);
+ TCDTrackBarDrawer(FCurrentDrawer).DrawToIntfImage(lCanvas, AImage, Self);
ABmp.LoadFromIntfImage(AImage);
Canvas.Draw(0, 0, ABmp);
finally
@@ -1791,118 +995,6 @@ begin
end;
end;
-{ TCDTrackBarDrawer }
-
-procedure TCDTrackBarDrawerGraph.DrawToIntfImage(ADest: TFPImageCanvas;
- FPImg: TLazIntfImage; CDTrackBar: TCDTrackBar);
-const
- CDBarEdge = 18;
-var
- lDrawingBottom, StepsCount, i: Integer;
- pStart, pEnd: integer; // for drawing the decorative bars
- dRect: TRect;
- pStepWidth, pHalfStepWidth: Integer;
-begin
- // Sanity check
- if CDTrackBar.Max - CDTrackBar.Min <= 0 then
- raise Exception.Create('[TCDTrackBarDrawerGraph.DrawToIntfImage] Max-Min must be at least 1');
-
- // Preparations
- StepsCount := CDTrackBar.Max - CDTrackBar.Min + 1;
- pStepWidth := (CDTrackBar.Width - CDBarEdge) div StepsCount;
- pHalfStepWidth := (CDTrackBar.Width - CDBarEdge) div (StepsCount * 2);
-
- // The bottom part of the drawing
- lDrawingBottom := CDTrackBar.Height - 10;
-
- // Background
-
- if CDTrackBar.Parent = nil then
- ADest.Brush.FPColor := colLtGray
- else
- ADest.Brush.FPColor := TColorToFPColor(ColorToRGB(CDTrackBar.Color));
- ADest.Brush.Style := bsSolid;
- ADest.Pen.Style := psClear;
- ADest.Rectangle(0, 0, CDTrackBar.Width, CDTrackBar.Height);
- ADest.Brush.FPColor := TColorToFPColor(ColorToRGB($006BB6E6));
-
- // Draws the double-sided arrow in the center of the slider
-
- ADest.Pen.Style := psSolid;
- ADest.Pen.FPColor := TColorToFPColor(ColorToRGB($006BB6E6));
- ADest.Line(0, lDrawingBottom, CDTrackBar.Width, lDrawingBottom);
- ADest.Line(3, lDrawingBottom - 1, 6, lDrawingBottom - 1);
- ADest.Line(5, lDrawingBottom - 2, 6, lDrawingBottom - 2);
- ADest.Line(3, lDrawingBottom + 1, 6, lDrawingBottom + 1);
- ADest.Line(5, lDrawingBottom + 2, 6, lDrawingBottom + 2);
- ADest.Line(CDTrackBar.Width - 1 - 3, lDrawingBottom - 1, CDTrackBar.Width - 1 - 6, lDrawingBottom - 1);
- ADest.Line(CDTrackBar.Width - 1 - 5, lDrawingBottom - 2, CDTrackBar.Width - 1 - 6, lDrawingBottom - 2);
- ADest.Line(CDTrackBar.Width - 1 - 3, lDrawingBottom + 1, CDTrackBar.Width - 1 - 6, lDrawingBottom + 1);
- ADest.Line(CDTrackBar.Width - 1 - 5, lDrawingBottom + 2, CDTrackBar.Width - 1 - 6, lDrawingBottom + 2);
- ADest.Pen.FPColor := TColorToFPColor(ColorToRGB(clGray));
- ADest.Brush.FPColor := TColorToFPColor(ColorToRGB($00F0F0F0));
-
- // Draws the decorative bars and also the slider button
-
- pStart := 10 - 1;
- for i := 0 to StepsCount - 1 do
- begin
- // Draw the decorative bars
- dRect := Bounds(
- pStart + pHalfStepWidth,
- lDrawingBottom - 5 - i,
- Round(pStepWidth)-3,
- 4 + i);
-
- ADest.Brush.Style := bsSolid;
- ADest.Pen.Style := psSolid;
- ADest.Pen.FPColor := colBlack;
- if i + CDTrackBar.Min <= CDTrackBar.Position then
- ADest.Brush.FPColor := colDkGray
- else
- ADest.Brush.FPColor := colWhite;
-
- ADest.Rectangle(dRect);
-
- // Draw the slider
-
- if i + CDTrackBar.Min = CDTrackBar.Position then
- 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.RecTangle(pStart, lDrawingBottom + 2, pStart + 10, lDrawingBottom + 7);
- ADest.Pen.FPColor := TColorToFPColor(ColorToRGB($006BB6E6));
- ADest.RecTangle(pStart, lDrawingBottom, pStart + 10, lDrawingBottom + 2);
- end;
- pStart := pStart + pStepWidth;
- end;
-
- ADest.Pen.FPColor := TColorToFPColor(ColorToRGB($007BC6F6));
- ADest.Line(7, lDrawingBottom - 1, CDTrackBar.Width - 8, lDrawingBottom - 1);
- ADest.Line(7, lDrawingBottom + 1, CDTrackBar.Width - 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[CDTrackBar.Width - 1 - 2, lDrawingBottom - 1] := ADest.Pen.FPColor;
- ADest.Colors[CDTrackBar.Width - 1 - 4, lDrawingBottom - 2] := ADest.Pen.FPColor;
- ADest.Colors[CDTrackBar.Width - 1 - 2, lDrawingBottom + 1] := ADest.Pen.FPColor;
- ADest.Colors[CDTrackBar.Width - 1 - 4, lDrawingBottom + 2] := ADest.Pen.FPColor;
- ADest.Colors[CDTrackBar.Width - 1 - 6, lDrawingBottom - 3] := ADest.Pen.FPColor;
- ADest.Colors[CDTrackBar.Width - 1 - 6, lDrawingBottom + 3] := ADest.Pen.FPColor;
-end;
-
-procedure TCDTrackBarDrawerGraph.GetGeometry(var ALeftBorder,
- ARightBorder: Integer);
-begin
- ALeftBorder := 9;
- ARightBorder := 9;
-end;
-
{ TCDTabSheet }
constructor TCDTabSheet.Create(AOwner: TComponent);
@@ -1932,7 +1024,7 @@ procedure TCDTabSheet.Paint;
begin
if CDTabControl <> nil then
begin
- TCDCustomTabControlDrawer(CDTabControl.FCurrentDrawer).DrawTabSheet(Canvas);
+ TCDCustomTabControlDrawer(CDTabControl.FCurrentDrawer).DrawTabSheet(Canvas, CDTabControl);
end;
end;
@@ -2122,8 +1214,8 @@ var
lTabHeight, lIndex: Integer;
begin
// ATabSheet.SetBounds(1, 32 + 1, Width - 3, Height - 32 - 4);
- lIndex := FTabs.IndexOfObject(ATabSheet);;
- lTabHeight := TCDCustomTabControlDrawer(FCurrentDrawer).GetTabHeight(lIndex);
+ lIndex := FTabs.IndexOfObject(ATabSheet);
+ lTabHeight := TCDCustomTabControlDrawer(FCurrentDrawer).GetTabHeight(lIndex, Self);
ATabSheet.BorderSpacing.Top := lTabHeight;
ATabSheet.BorderSpacing.Left := 2;
ATabSheet.BorderSpacing.Right := 3;
diff --git a/components/customdrawn/customdrawnutils.pas b/components/customdrawn/customdrawnutils.pas
index d4bf0ee186..958945185a 100644
--- a/components/customdrawn/customdrawnutils.pas
+++ b/components/customdrawn/customdrawnutils.pas
@@ -31,6 +31,7 @@ procedure DrawTabHead(aDest: TFPCustomCanvas; aRect: TRect; HeadColor: TColor;
procedure DrawTabHeadMask(aDest: TFPCustomCanvas; aRect: TRect;
HeadColor: TColor; IsActive: boolean);
procedure DrawArrow(aDest: TFPCustomCanvas; aRect: TRect; R: boolean);
+procedure DrawCDButtonDown(Canvas: TCanvas; ABackgroundColor: TColor);
type
PRGBTripleArray = ^TRGBTripleArray;
@@ -549,5 +550,20 @@ begin
TmpBmp.Free;
end;
+procedure DrawCDButtonDown(Canvas: TCanvas; ABackgroundColor: TColor);
+begin
+ with Canvas do
+ begin
+ Brush.Style := bsSolid;
+ Brush.Color := ABackgroundColor;
+ Pen.Color := Brush.Color;
+ Rectangle(0, 0, Width, Height);
+ FillRect(0, 0, Width, Height);
+ Brush.Color := GetAColor(ABackgroundColor, 93);
+ Pen.Color := GetAColor(Brush.Color, 76);
+ RoundRect(0, 0, Width, Height, 8, 8);
+ end;
+end;
+
end.