Browse Source

Added DarkTheme property to TBCDPanel

lainz 9 years ago
parent
commit
a2c369c042
1 changed files with 40 additions and 13 deletions
  1. 40 13
      bgracustomdrawn.pas

+ 40 - 13
bgracustomdrawn.pas

@@ -46,8 +46,16 @@ type
   { TBCDPanel }
   { TBCDPanel }
 
 
   TBCDPanel = class(TPanel)
   TBCDPanel = class(TPanel)
+
+  private
+    FDarkTheme: boolean;
+    procedure SetFDartTheme(AValue: boolean);
   protected
   protected
     procedure Paint; override;
     procedure Paint; override;
+  public
+    constructor Create(TheOwner: TComponent); override;
+  published
+    property DarkTheme: boolean read FDarkTheme write SetFDartTheme default True;
   published
   published
     property Align;
     property Align;
     property Alignment;
     property Alignment;
@@ -165,29 +173,48 @@ implementation
 procedure Register;
 procedure Register;
 begin
 begin
   RegisterComponents('BGRA Custom Drawn', [TBCDButton, TBCDEdit,
   RegisterComponents('BGRA Custom Drawn', [TBCDButton, TBCDEdit,
-    TBCDStaticText, TBCDProgressBar, TBCDSpinEdit, TBCDCheckBox, TBCDRadioButton,
-    TBCDPanel]);
+    TBCDStaticText, TBCDProgressBar, TBCDSpinEdit, TBCDCheckBox,
+    TBCDRadioButton, TBCDPanel]);
 end;
 end;
 
 
 { TBCDPanel }
 { TBCDPanel }
 
 
+procedure TBCDPanel.SetFDartTheme(AValue: boolean);
+begin
+  if FDarkTheme = AValue then
+    Exit;
+  FDarkTheme := AValue;
+  Invalidate;
+end;
+
 procedure TBCDPanel.Paint;
 procedure TBCDPanel.Paint;
 begin
 begin
-  if BevelOuter <> bvNone then
+  if DarkTheme then
   begin
   begin
-    Canvas.Pen.Color := RGBToColor(40, 40, 40);
-    Canvas.Brush.Color := RGBToColor(83, 83, 83);
-    Canvas.Rectangle(0, 0, Width, Height);
+    if BevelOuter <> bvNone then
+    begin
+      Canvas.Pen.Color := RGBToColor(40, 40, 40);
+      Canvas.Brush.Color := RGBToColor(83, 83, 83);
+      Canvas.Rectangle(0, 0, Width, Height);
 
 
-    Canvas.Pen.Color := RGBToColor(106, 106, 106);
-    Canvas.Line(1, 1, Width - 1, 1);
+      Canvas.Pen.Color := RGBToColor(106, 106, 106);
+      Canvas.Line(1, 1, Width - 1, 1);
+    end
+    else
+    begin
+      Canvas.Pen.Color := RGBToColor(83, 83, 83);
+      Canvas.Brush.Color := RGBToColor(83, 83, 83);
+      Canvas.Rectangle(0, 0, Width, Height);
+    end;
   end
   end
   else
   else
-  begin
-    Canvas.Pen.Color := RGBToColor(83, 83, 83);
-    Canvas.Brush.Color := RGBToColor(83, 83, 83);
-    Canvas.Rectangle(0, 0, Width, Height);
-  end;
+    inherited Paint;
+end;
+
+constructor TBCDPanel.Create(TheOwner: TComponent);
+begin
+  inherited Create(TheOwner);
+  FDarkTheme := True;
 end;
 end;
 
 
 { TBCDProgressBar }
 { TBCDProgressBar }