Changeset 248


Ignore:
Timestamp:
May 22, 2020, 7:08:10 PM (4 years ago)
Author:
chronos
Message:
  • Fixed: Wrong font size in Help form.
Location:
branches/highdpi
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/highdpi/Packages/DpiControls/UDpiControls.pas

    r247 r248  
    66
    77uses
    8   Windows, Classes, SysUtils, LCLProc, LResources, Forms, FormEditingIntf, ProjectIntf,
     8  {$IFDEF WINDOWS}Windows, {$ENDIF}Classes, SysUtils, LCLProc, LResources, Forms, FormEditingIntf, ProjectIntf,
    99  Controls, StdCtrls, fgl, Graphics, ComCtrls, ExtCtrls, LCLType, GraphType,
    1010  Types, CustApp, LMessages, LCLIntf, Menus;
     
    5959    FOnChange: TNotifyEvent;
    6060    FSize: Integer;
     61    FHeight: Integer;
     62    FPixelsPerInch: Integer;
     63    FColor: TColor;
    6164    function GetCharSet: TFontCharSet;
    6265    function GetColor: TColor;
     
    6467    function GetName: string;
    6568    function GetPixelsPerInch: Integer;
     69    function GetSize: Integer;
    6670    function GetStyle: TFontStyles;
    6771    function IsNameStored: Boolean;
     
    7579    procedure DoChange;
    7680    procedure SetStyle(AValue: TFontStyles);
     81    procedure UpdateFont;
    7782  protected
    7883    procedure ScreenChanged;
     
    8893    property Name: string read GetName write SetName stored IsNameStored;
    8994    property Style: TFontStyles read GetStyle write SetStyle default [];
    90     property Size: Integer read FSize write SetSize stored false;
     95    property Size: Integer read GetSize write SetSize stored false;
    9196    property PixelsPerInch: Integer read GetPixelsPerInch write SetPixelsPerInch;
    9297    property Height: Integer read GetHeight write SetHeight default 0;
     
    22752280  if FSize = AValue then Exit;
    22762281  FSize := AValue;
    2277   GetNativeFont.Size := AValue;
     2282  FHeight := -MulDiv(FSize, FPixelsPerInch, 72);
     2283  UpdateFont;
    22782284  DoChange;
    22792285end;
     
    22872293begin
    22882294  GetNativeFont.Style := AValue;
     2295end;
     2296
     2297procedure TDpiFont.UpdateFont;
     2298begin
     2299  GetNativeFont.PixelsPerInch := FPixelsPerInch;
     2300  GetNativeFont.Size := FSize;
    22892301end;
    22902302
     
    23082320procedure TDpiFont.SetPixelsPerInch(AValue: Integer);
    23092321begin
    2310   GetNativeFont.PixelsPerInch := PixelsPerInch;
     2322  FPixelsPerInch := PixelsPerInch;
     2323  FHeight := -MulDiv(FSize, FPixelsPerInch, 72);
     2324  UpdateFont;
    23112325end;
    23122326
     
    23182332function TDpiFont.GetColor: TColor;
    23192333begin
    2320   Result := GetNativeFont.Color;
     2334  Result := FColor;
    23212335end;
    23222336
     
    23332347function TDpiFont.GetPixelsPerInch: Integer;
    23342348begin
    2335   Result := GetNativeFont.PixelsPerInch;
     2349  Result := FPixelsPerInch;
     2350end;
     2351
     2352function TDpiFont.GetSize: Integer;
     2353begin
     2354  Result := FSize;
    23362355end;
    23372356
     
    23532372procedure TDpiFont.SetColor(AValue: TColor);
    23542373begin
     2374  if FColor = AValue then Exit;
     2375  FColor := AValue;
    23552376  GetNativeFont.Color := AValue;
    23562377end;
     
    23582379procedure TDpiFont.SetHeight(AValue: Integer);
    23592380begin
    2360   GetNativeFont.Height := AValue;
     2381  FHeight := AValue;
     2382  FSize := MulDiv(-FHeight, 72, FPixelsPerInch);
     2383  UpdateFont;
    23612384end;
    23622385
     
    23682391constructor TDpiFont.Create;
    23692392begin
     2393  FPixelsPerInch := DpiScreen.PixelsPerInch;
    23702394  Size := 8;
    23712395end;
     
    23812405    GetNativeFont.Assign((Source as TDpiFont).GetNativeFont);
    23822406    Size := (Source as TDpiFont).Size;
     2407    Height := (Source as TDpiFont).Height;
     2408    PixelsPerInch := (Source as TDpiFont).PixelsPerInch;
    23832409    FOnChange := (Source as TDpiFont).FOnChange;
     2410    Color := (Source as TDpiFont).Color;
    23842411  end;
    23852412end;
     
    25822609procedure TDpiScreen.UpdateScreen;
    25832610begin
    2584 //  Dpi := 96 * 2;
    25852611  Dpi := Screen.PixelsPerInch;
    25862612end;
  • branches/highdpi/Start.pas

    r246 r248  
    4848    Bitmap: TDpiBitmap; { game world sample preview }
    4949    Size: TPoint;
    50     Colors: array [0 .. 11, 0 .. 1] of TColor;
     50    Colors: array [0 .. $1f, 0 .. 1] of TColor;
    5151    Mode: TMiniMode;
    5252    procedure LoadFromLogFile(FileName: string; var LastTurn: Integer);
Note: See TracChangeset for help on using the changeset viewer.