Changeset 581


Ignore:
Timestamp:
Dec 10, 2024, 4:50:34 PM (11 days ago)
Author:
chronos
Message:
  • Modified: Improved Common package.
Location:
Common
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • Common/MetaCanvas.pas

    r563 r581  
    150150    procedure SetWidth(AValue: Integer); override;
    151151    function GetWidth: Integer; override;
    152     procedure DoLine (x1,y1,x2,y2:integer); override;
     152    procedure DoLine(X1, Y1, X2, Y2: Integer); override;
    153153    procedure DoTextOut(X, Y: Integer; Text: string); override;
    154154    procedure DoRectangle(const Bounds: TRect); override;
     
    563563end;
    564564
    565 procedure TMetaCanvas.DoLine(x1, y1, x2, y2: integer);
     565procedure TMetaCanvas.DoLine(X1, Y1, X2, Y2: integer);
    566566var
    567567  NewObj: TCanvasLine;
  • Common/RegistryEx.pas

    r571 r581  
    3636    function ReadFloatWithDefault(const Name: string;
    3737      DefaultValue: Double): Double;
     38    function ReadDateTimeWithDefault(const Name: string; DefaultValue: TDateTime): TDateTime;
    3839    function DeleteKeyRecursive(const Key: string): Boolean;
    3940    function OpenKey(const Key: string; CanCreate: Boolean): Boolean;
     
    110111end;
    111112
     113function TRegistryEx.ReadDateTimeWithDefault(const Name: string;
     114  DefaultValue: TDateTime): TDateTime;
     115begin
     116  if ValueExists(Name) then Result := ReadDateTime(Name)
     117    else begin
     118      WriteDateTime(Name, DefaultValue);
     119      Result := DefaultValue;
     120    end;
     121end;
     122
    112123function TRegistryEx.DeleteKeyRecursive(const Key: string): Boolean;
    113124var
  • Common/Theme.pas

    r563 r581  
    3030  private
    3131    FTheme: TTheme;
     32    function Gray(C: TColor): Byte;
    3233    procedure SetTheme(AValue: TTheme);
    3334    procedure SetThemeName(AValue: TTheme);
     
    3536    Used: Boolean;
    3637    Themes: TThemes;
     38    function IsDarkTheme: Boolean;
    3739    procedure ApplyTheme(Component: TComponent);
    3840    constructor Create(AOwner: TComponent); override;
     
    9395    Strings.EndUpdate;
    9496  end;
     97end;
     98
     99{ TThemeManager }
     100
     101function TThemeManager.Gray(C: TColor): Byte;
     102begin
     103  Result := Trunc(Red(C) * 0.3 + Green(C) * 0.59 + Blue(C) * 0.11);
     104end;
     105
     106function TThemeManager.IsDarkTheme: Boolean;
     107begin
     108  Result := Gray(ColorToRGB(clWindow)) < Gray(ColorToRGB(clWindowText));
    95109end;
    96110
Note: See TracChangeset for help on using the changeset viewer.