Johann ELSASS před 5 roky
rodič
revize
4b8059a222
7 změnil soubory, kde provedl 44 přidání a 37 odebrání
  1. 12 10
      bgracolortheme.pas
  2. 3 3
      bgraimagetheme.pas
  3. 10 8
      bgrasvgtheme.pas
  4. 13 10
      bgratheme.pas
  5. 2 2
      bgrathemebutton.pas
  6. 2 2
      bgrathemecheckbox.pas
  7. 2 2
      bgrathemeradiobutton.pas

+ 12 - 10
bgracolortheme.pas

@@ -32,11 +32,11 @@ type
 
 
   public
   public
     procedure DrawButton(Caption: string; State: TBGRAThemeButtonState;
     procedure DrawButton(Caption: string; State: TBGRAThemeButtonState;
-      Focused: boolean; ARect: TRect; DestCanvas: TCanvas); override;
+      Focused: boolean; ARect: TRect; DestCanvas: TCanvas; {%H-}CanvasScale: single); override;
     procedure DrawRadioButton(Caption: string; State: TBGRAThemeButtonState;
     procedure DrawRadioButton(Caption: string; State: TBGRAThemeButtonState;
-      {%H-}Focused: boolean; Checked: boolean; ARect: TRect; DestCanvas: TCanvas); override;
+      {%H-}Focused: boolean; Checked: boolean; ARect: TRect; DestCanvas: TCanvas; CanvasScale: single); override;
     procedure DrawCheckBox(Caption: string; State: TBGRAThemeButtonState;
     procedure DrawCheckBox(Caption: string; State: TBGRAThemeButtonState;
-      {%H-}Focused: boolean; Checked: boolean; ARect: TRect; DestCanvas: TCanvas); override;
+      {%H-}Focused: boolean; Checked: boolean; ARect: TRect; DestCanvas: TCanvas; CanvasScale: single); override;
   published
   published
     property ColorNormal: TColor read FColorNormal write SetFColorNormal;
     property ColorNormal: TColor read FColorNormal write SetFColorNormal;
     property ColorHover: TColor read FColorHover write SetFColorHover;
     property ColorHover: TColor read FColorHover write SetFColorHover;
@@ -100,7 +100,7 @@ begin
 end;
 end;
 
 
 procedure TBGRAColorTheme.DrawButton(Caption: string; State: TBGRAThemeButtonState;
 procedure TBGRAColorTheme.DrawButton(Caption: string; State: TBGRAThemeButtonState;
-  Focused: boolean; ARect: TRect; DestCanvas: TCanvas);
+  Focused: boolean; ARect: TRect; DestCanvas: TCanvas; CanvasScale: single);
 var
 var
   Style: TTextStyle;
   Style: TTextStyle;
 begin
 begin
@@ -136,7 +136,7 @@ end;
 
 
 procedure TBGRAColorTheme.DrawRadioButton(Caption: string;
 procedure TBGRAColorTheme.DrawRadioButton(Caption: string;
   State: TBGRAThemeButtonState; Focused: boolean; Checked: boolean;
   State: TBGRAThemeButtonState; Focused: boolean; Checked: boolean;
-  ARect: TRect; DestCanvas: TCanvas);
+  ARect: TRect; DestCanvas: TCanvas; CanvasScale: single);
 var
 var
   Style: TTextStyle;
   Style: TTextStyle;
   Bitmap: TBGRABitmap;
   Bitmap: TBGRABitmap;
@@ -155,7 +155,7 @@ begin
     Color := ColorNormal;
     Color := ColorNormal;
   end;
   end;
 
 
-  Bitmap := TBGRABitmap.Create(ARect.Height, ARect.Height);
+  Bitmap := TBGRABitmap.Create(round(ARect.Height*CanvasScale), round(ARect.Height*CanvasScale));
   Bitmap.FillEllipseAntialias(Bitmap.Height / 2, Bitmap.Height / 2,
   Bitmap.FillEllipseAntialias(Bitmap.Height / 2, Bitmap.Height / 2,
     Bitmap.Height / 2 - 2, Bitmap.Height / 2 - 2, BGRAWhite);
     Bitmap.Height / 2 - 2, Bitmap.Height / 2 - 2, BGRAWhite);
   Bitmap.EllipseAntialias(Bitmap.Height / 2, Bitmap.Height / 2,
   Bitmap.EllipseAntialias(Bitmap.Height / 2, Bitmap.Height / 2,
@@ -163,7 +163,8 @@ begin
   if Checked then
   if Checked then
     Bitmap.FillEllipseAntialias(Bitmap.Height / 2, Bitmap.Height /
     Bitmap.FillEllipseAntialias(Bitmap.Height / 2, Bitmap.Height /
       2, Bitmap.Height / 4, Bitmap.Height / 4, Color);
       2, Bitmap.Height / 4, Bitmap.Height / 4, Color);
-  Bitmap.Draw(DestCanvas, Arect.Left, Arect.Top, False);
+  Bitmap.Draw(DestCanvas, RectWithSize(Arect.Left, Arect.Top,
+    round(Bitmap.Width/CanvasScale), round(Bitmap.Height/CanvasScale)), False);
   Bitmap.Free;
   Bitmap.Free;
 
 
   if Caption <> '' then
   if Caption <> '' then
@@ -181,7 +182,7 @@ end;
 
 
 procedure TBGRAColorTheme.DrawCheckBox(Caption: string;
 procedure TBGRAColorTheme.DrawCheckBox(Caption: string;
   State: TBGRAThemeButtonState; Focused: boolean; Checked: boolean;
   State: TBGRAThemeButtonState; Focused: boolean; Checked: boolean;
-  ARect: TRect; DestCanvas: TCanvas);
+  ARect: TRect; DestCanvas: TCanvas; CanvasScale: single);
 var
 var
   Style: TTextStyle;
   Style: TTextStyle;
   Bitmap: TBGRABitmap;
   Bitmap: TBGRABitmap;
@@ -201,7 +202,7 @@ begin
     Color := ColorNormal;
     Color := ColorNormal;
   end;
   end;
 
 
-  Bitmap := TBGRABitmap.Create(ARect.Height, ARect.Height);
+  Bitmap := TBGRABitmap.Create(round(ARect.Height*CanvasScale), round(ARect.Height*CanvasScale));
   Bitmap.Rectangle(0, 0, Bitmap.Height, Bitmap.Height, Color, BGRAWhite);
   Bitmap.Rectangle(0, 0, Bitmap.Height, Bitmap.Height, Color, BGRAWhite);
   aleft := 0;
   aleft := 0;
   aright := Bitmap.Height;
   aright := Bitmap.Height;
@@ -213,7 +214,8 @@ begin
       BezierCurve(PointF((aleft + aright - 1) / 2, abottom - 3), PointF(
       BezierCurve(PointF((aleft + aright - 1) / 2, abottom - 3), PointF(
       (aleft + aright - 1) / 2, (atop * 2 + abottom - 1) / 3), PointF(aright - 2, atop - 2))]),
       (aleft + aright - 1) / 2, (atop * 2 + abottom - 1) / 3), PointF(aright - 2, atop - 2))]),
       Color, 1.5);
       Color, 1.5);
-  Bitmap.Draw(DestCanvas, Arect.Left, Arect.Top, False);
+  Bitmap.Draw(DestCanvas, RectWithSize(Arect.Left, Arect.Top,
+    round(Bitmap.Width/CanvasScale), round(Bitmap.Height/CanvasScale)), False);
   Bitmap.Free;
   Bitmap.Free;
 
 
   if Caption <> '' then
   if Caption <> '' then

+ 3 - 3
bgraimagetheme.pas

@@ -25,7 +25,7 @@ type
     destructor Destroy; override;
     destructor Destroy; override;
     procedure LoadResources(AFileName: string);
     procedure LoadResources(AFileName: string);
     procedure DrawButton(Caption: string; State: TBGRAThemeButtonState;
     procedure DrawButton(Caption: string; State: TBGRAThemeButtonState;
-      {%H-}Focused: boolean; ARect: TRect; DestCanvas: TCanvas); override;
+      {%H-}Focused: boolean; ARect: TRect; DestCanvas: TCanvas; CanvasScale: single); override;
   published
   published
     property BackgroundColor: TColor read FBackgroundColor
     property BackgroundColor: TColor read FBackgroundColor
       write SetFBackgroundColor default clForm;
       write SetFBackgroundColor default clForm;
@@ -68,7 +68,7 @@ begin
 end;
 end;
 
 
 procedure TBGRAImageTheme.DrawButton(Caption: string; State: TBGRAThemeButtonState;
 procedure TBGRAImageTheme.DrawButton(Caption: string; State: TBGRAThemeButtonState;
-  Focused: boolean; ARect: TRect; DestCanvas: TCanvas);
+  Focused: boolean; ARect: TRect; DestCanvas: TCanvas; CanvasScale: single);
 var
 var
   Style: TTextStyle;
   Style: TTextStyle;
   ImageIndex: integer;
   ImageIndex: integer;
@@ -82,7 +82,7 @@ begin
     ImageIndex := 0;
     ImageIndex := 0;
   end;
   end;
 
 
-  bmp := TBGRABitmap.Create(ARect.Width, ARect.Height, BackgroundColor);
+  bmp := TBGRABitmap.Create(round(ARect.Width*CanvasScale), round(ARect.Height*CanvasScale), BackgroundColor);
 
 
   if Assigned(FSliceScalingButton) then
   if Assigned(FSliceScalingButton) then
     FSliceScalingButton.Draw(ImageIndex, bmp, 0, 0, bmp.Width, bmp.Height);
     FSliceScalingButton.Draw(ImageIndex, bmp, 0, 0, bmp.Width, bmp.Height);

+ 10 - 8
bgrasvgtheme.pas

@@ -38,10 +38,10 @@ type
     destructor Destroy; override;
     destructor Destroy; override;
     procedure DrawRadioButton(Caption: string; State: TBGRAThemeButtonState;
     procedure DrawRadioButton(Caption: string; State: TBGRAThemeButtonState;
     {%H-}Focused: boolean; Checked: boolean; ARect: TRect;
     {%H-}Focused: boolean; Checked: boolean; ARect: TRect;
-      DestCanvas: TCanvas); override;
+      DestCanvas: TCanvas; CanvasScale: single); override;
     procedure DrawCheckBox(Caption: string; State: TBGRAThemeButtonState;
     procedure DrawCheckBox(Caption: string; State: TBGRAThemeButtonState;
     {%H-}Focused: boolean; Checked: boolean; ARect: TRect;
     {%H-}Focused: boolean; Checked: boolean; ARect: TRect;
-      DestCanvas: TCanvas); override;
+      DestCanvas: TCanvas; CanvasScale: single); override;
   public
   public
     property ColorizeNormal: TBGRAPixel read FColorizeNormal write SetColorizeNormal;
     property ColorizeNormal: TBGRAPixel read FColorizeNormal write SetColorizeNormal;
     property ColorizeHover: TBGRAPixel read FColorizeHover write SetColorizeHover;
     property ColorizeHover: TBGRAPixel read FColorizeHover write SetColorizeHover;
@@ -144,7 +144,7 @@ end;
 
 
 procedure TBGRASVGTheme.DrawRadioButton(Caption: string;
 procedure TBGRASVGTheme.DrawRadioButton(Caption: string;
   State: TBGRAThemeButtonState; Focused: boolean; Checked: boolean;
   State: TBGRAThemeButtonState; Focused: boolean; Checked: boolean;
-  ARect: TRect; DestCanvas: TCanvas);
+  ARect: TRect; DestCanvas: TCanvas; CanvasScale: single);
 var
 var
   Style: TTextStyle;
   Style: TTextStyle;
   Bitmap: TBGRABitmap;
   Bitmap: TBGRABitmap;
@@ -156,7 +156,7 @@ begin
     svg := TBGRASVG.CreateFromString(FRadioButtonChecked)
     svg := TBGRASVG.CreateFromString(FRadioButtonChecked)
   else
   else
     svg := TBGRASVG.CreateFromString(FRadioButtonUnchecked);
     svg := TBGRASVG.CreateFromString(FRadioButtonUnchecked);
-  Bitmap := TBGRABitmap.Create(ARect.Height, ARect.Height);
+  Bitmap := TBGRABitmap.Create(round(ARect.Height*CanvasScale), round(ARect.Height*CanvasScale));
   aleft := 0;
   aleft := 0;
   aright := Bitmap.Height;
   aright := Bitmap.Height;
   atop := 0;
   atop := 0;
@@ -170,7 +170,8 @@ begin
   end;
   end;
   if color{%H-} <> BGRAPixelTransparent then
   if color{%H-} <> BGRAPixelTransparent then
     Colorize(Bitmap, Bitmap, color);
     Colorize(Bitmap, Bitmap, color);
-  Bitmap.Draw(DestCanvas, Arect.Left, Arect.Top, False);
+  Bitmap.Draw(DestCanvas, RectWithSize(Arect.Left, Arect.Top,
+    round(Bitmap.Width/CanvasScale), round(Bitmap.Height/CanvasScale)), False);
   Bitmap.Free;
   Bitmap.Free;
   svg.Free;
   svg.Free;
 
 
@@ -195,7 +196,7 @@ begin
 end;
 end;
 
 
 procedure TBGRASVGTheme.DrawCheckBox(Caption: string; State: TBGRAThemeButtonState;
 procedure TBGRASVGTheme.DrawCheckBox(Caption: string; State: TBGRAThemeButtonState;
-  Focused: boolean; Checked: boolean; ARect: TRect; DestCanvas: TCanvas);
+  Focused: boolean; Checked: boolean; ARect: TRect; DestCanvas: TCanvas; CanvasScale: single);
 var
 var
   Style: TTextStyle;
   Style: TTextStyle;
   Bitmap: TBGRABitmap;
   Bitmap: TBGRABitmap;
@@ -207,7 +208,7 @@ begin
     svg := TBGRASVG.CreateFromString(FCheckBoxChecked)
     svg := TBGRASVG.CreateFromString(FCheckBoxChecked)
   else
   else
     svg := TBGRASVG.CreateFromString(FCheckBoxUnchecked);
     svg := TBGRASVG.CreateFromString(FCheckBoxUnchecked);
-  Bitmap := TBGRABitmap.Create(ARect.Height, ARect.Height);
+  Bitmap := TBGRABitmap.Create(round(ARect.Height*CanvasScale), round(ARect.Height*CanvasScale));
   aleft := 0;
   aleft := 0;
   aright := Bitmap.Height;
   aright := Bitmap.Height;
   atop := 0;
   atop := 0;
@@ -221,7 +222,8 @@ begin
   end;
   end;
   if color{%H-} <> BGRAPixelTransparent then
   if color{%H-} <> BGRAPixelTransparent then
     Colorize(Bitmap, Bitmap, color);
     Colorize(Bitmap, Bitmap, color);
-  Bitmap.Draw(DestCanvas, Arect.Left, Arect.Top, False);
+  Bitmap.Draw(DestCanvas, RectWithSize(Arect.Left, Arect.Top,
+    round(Bitmap.Width/CanvasScale), round(Bitmap.Height/CanvasScale)), False);
   Bitmap.Free;
   Bitmap.Free;
   svg.Free;
   svg.Free;
 
 

+ 13 - 10
bgratheme.pas

@@ -21,13 +21,13 @@ type
 
 
   public
   public
     procedure DrawButton(Caption: string; State: TBGRAThemeButtonState;
     procedure DrawButton(Caption: string; State: TBGRAThemeButtonState;
-      Focused: boolean; ARect: TRect; DestCanvas: TCanvas); virtual;
+      Focused: boolean; ARect: TRect; DestCanvas: TCanvas; CanvasScale: single); virtual;
     procedure DrawRadioButton(Caption: string; State: TBGRAThemeButtonState;
     procedure DrawRadioButton(Caption: string; State: TBGRAThemeButtonState;
     {%H-}Focused: boolean; Checked: boolean; ARect: TRect;
     {%H-}Focused: boolean; Checked: boolean; ARect: TRect;
-      DestCanvas: TCanvas); virtual;
+      DestCanvas: TCanvas; CanvasScale: single); virtual;
     procedure DrawCheckBox(Caption: string; State: TBGRAThemeButtonState;
     procedure DrawCheckBox(Caption: string; State: TBGRAThemeButtonState;
     {%H-}Focused: boolean; Checked: boolean; ARect: TRect;
     {%H-}Focused: boolean; Checked: boolean; ARect: TRect;
-      DestCanvas: TCanvas); virtual;
+      DestCanvas: TCanvas; CanvasScale: single); virtual;
   public
   public
     procedure Colorize(Source, Dest: TBGRABitmap; c: TBGRAPixel);
     procedure Colorize(Source, Dest: TBGRABitmap; c: TBGRAPixel);
   published
   published
@@ -73,7 +73,7 @@ begin
 end;
 end;
 
 
 procedure TBGRATheme.DrawButton(Caption: string; State: TBGRAThemeButtonState;
 procedure TBGRATheme.DrawButton(Caption: string; State: TBGRAThemeButtonState;
-  Focused: boolean; ARect: TRect; DestCanvas: TCanvas);
+  Focused: boolean; ARect: TRect; DestCanvas: TCanvas; CanvasScale: single);
 var
 var
   Style: TTextStyle;
   Style: TTextStyle;
 begin
 begin
@@ -107,7 +107,7 @@ begin
 end;
 end;
 
 
 procedure TBGRATheme.DrawRadioButton(Caption: string; State: TBGRAThemeButtonState;
 procedure TBGRATheme.DrawRadioButton(Caption: string; State: TBGRAThemeButtonState;
-  Focused: boolean; Checked: boolean; ARect: TRect; DestCanvas: TCanvas);
+  Focused: boolean; Checked: boolean; ARect: TRect; DestCanvas: TCanvas; CanvasScale: single);
 var
 var
   Style: TTextStyle;
   Style: TTextStyle;
   Bitmap: TBGRABitmap;
   Bitmap: TBGRABitmap;
@@ -126,7 +126,8 @@ begin
       Color := BGRABlack;
       Color := BGRABlack;
   end;
   end;
 
 
-  Bitmap := TBGRABitmap.Create(ARect.Height, ARect.Height);
+  Bitmap := TBGRABitmap.Create(round(ARect.Height*CanvasScale),
+            round(ARect.Height));
   Bitmap.FillEllipseAntialias(Bitmap.Height / 2, Bitmap.Height / 2,
   Bitmap.FillEllipseAntialias(Bitmap.Height / 2, Bitmap.Height / 2,
     Bitmap.Height / 2 - 2, Bitmap.Height / 2 - 2, BGRAWhite);
     Bitmap.Height / 2 - 2, Bitmap.Height / 2 - 2, BGRAWhite);
   Bitmap.EllipseAntialias(Bitmap.Height / 2, Bitmap.Height / 2,
   Bitmap.EllipseAntialias(Bitmap.Height / 2, Bitmap.Height / 2,
@@ -134,7 +135,8 @@ begin
   if Checked then
   if Checked then
     Bitmap.FillEllipseAntialias(Bitmap.Height / 2, Bitmap.Height /
     Bitmap.FillEllipseAntialias(Bitmap.Height / 2, Bitmap.Height /
       2, Bitmap.Height / 4, Bitmap.Height / 4, Color);
       2, Bitmap.Height / 4, Bitmap.Height / 4, Color);
-  Bitmap.Draw(DestCanvas, Arect.Left, Arect.Top, False);
+  Bitmap.Draw(DestCanvas, RectWithSize(Arect.Left, Arect.Top,
+    round(Bitmap.Width/CanvasScale), round(Bitmap.Height/CanvasScale)), False);
   Bitmap.Free;
   Bitmap.Free;
 
 
   if Caption <> '' then
   if Caption <> '' then
@@ -151,7 +153,7 @@ begin
 end;
 end;
 
 
 procedure TBGRATheme.DrawCheckBox(Caption: string; State: TBGRAThemeButtonState;
 procedure TBGRATheme.DrawCheckBox(Caption: string; State: TBGRAThemeButtonState;
-  Focused: boolean; Checked: boolean; ARect: TRect; DestCanvas: TCanvas);
+  Focused: boolean; Checked: boolean; ARect: TRect; DestCanvas: TCanvas; CanvasScale: single);
 var
 var
   Style: TTextStyle;
   Style: TTextStyle;
   Bitmap: TBGRABitmap;
   Bitmap: TBGRABitmap;
@@ -171,7 +173,7 @@ begin
       Color := BGRABlack;
       Color := BGRABlack;
   end;
   end;
 
 
-  Bitmap := TBGRABitmap.Create(ARect.Height, ARect.Height);
+  Bitmap := TBGRABitmap.Create(round(ARect.Height*CanvasScale), round(ARect.Height*CanvasScale));
   Bitmap.Rectangle(0, 0, Bitmap.Height, Bitmap.Height, Color, BGRAWhite);
   Bitmap.Rectangle(0, 0, Bitmap.Height, Bitmap.Height, Color, BGRAWhite);
   aleft := 0;
   aleft := 0;
   aright := Bitmap.Height;
   aright := Bitmap.Height;
@@ -183,7 +185,8 @@ begin
       BezierCurve(PointF((aleft + aright - 1) / 2, abottom - 3), PointF(
       BezierCurve(PointF((aleft + aright - 1) / 2, abottom - 3), PointF(
       (aleft + aright - 1) / 2, (atop * 2 + abottom - 1) / 3), PointF(aright - 2, atop - 2))]),
       (aleft + aright - 1) / 2, (atop * 2 + abottom - 1) / 3), PointF(aright - 2, atop - 2))]),
       Color, 1.5);
       Color, 1.5);
-  Bitmap.Draw(DestCanvas, Arect.Left, Arect.Top, False);
+  Bitmap.Draw(DestCanvas, RectWithSize(Arect.Left, Arect.Top,
+    round(Bitmap.Width/CanvasScale), round(Bitmap.Height/CanvasScale)), False);
   Bitmap.Free;
   Bitmap.Free;
 
 
   if Caption <> '' then
   if Caption <> '' then

+ 2 - 2
bgrathemebutton.pas

@@ -122,9 +122,9 @@ end;
 procedure TBGRAThemeButton.Paint;
 procedure TBGRAThemeButton.Paint;
 begin
 begin
   if Assigned(Theme) then
   if Assigned(Theme) then
-    Theme.DrawButton(Caption, FState, Focused, ClientRect, Canvas)
+    Theme.DrawButton(Caption, FState, Focused, ClientRect, Canvas, GetCanvasScaleFactor)
   else
   else
-    BGRADefaultTheme.DrawButton(Caption, FState, Focused, ClientRect, Canvas);
+    BGRADefaultTheme.DrawButton(Caption, FState, Focused, ClientRect, Canvas, GetCanvasScaleFactor);
 end;
 end;
 
 
 constructor TBGRAThemeButton.Create(AOwner: TComponent);
 constructor TBGRAThemeButton.Create(AOwner: TComponent);

+ 2 - 2
bgrathemecheckbox.pas

@@ -139,10 +139,10 @@ end;
 procedure TBGRAThemeCheckBox.Paint;
 procedure TBGRAThemeCheckBox.Paint;
 begin
 begin
   if Assigned(Theme) then
   if Assigned(Theme) then
-    Theme.DrawCheckBox(Caption, FState, Focused, Checked, ClientRect, Canvas)
+    Theme.DrawCheckBox(Caption, FState, Focused, Checked, ClientRect, Canvas, GetCanvasScaleFactor)
   else
   else
     BGRADefaultTheme.DrawCheckBox(Caption, FState, Focused, Checked,
     BGRADefaultTheme.DrawCheckBox(Caption, FState, Focused, Checked,
-      ClientRect, Canvas);
+      ClientRect, Canvas, GetCanvasScaleFactor);
 end;
 end;
 
 
 constructor TBGRAThemeCheckBox.Create(AOwner: TComponent);
 constructor TBGRAThemeCheckBox.Create(AOwner: TComponent);

+ 2 - 2
bgrathemeradiobutton.pas

@@ -139,10 +139,10 @@ end;
 procedure TBGRAThemeRadioButton.Paint;
 procedure TBGRAThemeRadioButton.Paint;
 begin
 begin
   if Assigned(Theme) then
   if Assigned(Theme) then
-    Theme.DrawRadioButton(Caption, FState, Focused, Checked, ClientRect, Canvas)
+    Theme.DrawRadioButton(Caption, FState, Focused, Checked, ClientRect, Canvas, GetCanvasScaleFactor)
   else
   else
     BGRADefaultTheme.DrawRadioButton(Caption, FState, Focused, Checked,
     BGRADefaultTheme.DrawRadioButton(Caption, FState, Focused, Checked,
-      ClientRect, Canvas);
+      ClientRect, Canvas, GetCanvasScaleFactor);
 end;
 end;
 
 
 procedure TBGRAThemeRadioButton.UncheckOthers;
 procedure TBGRAThemeRadioButton.UncheckOthers;