Changeset 104


Ignore:
Timestamp:
Oct 11, 2016, 9:49:16 AM (8 years ago)
Author:
chronos
Message:
  • Added: DPI scaling for icons and toolbars.
Location:
trunk
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormAcronyms.lfm

    r100 r104  
    1212  LCLVersion = '1.6.0.4'
    1313  object ListViewAcronyms: TListView
    14     Left = 8
    15     Height = 456
    16     Top = 40
    17     Width = 725
    18     Anchors = [akTop, akLeft, akRight, akBottom]
     14    Left = 4
     15    Height = 466
     16    Top = 34
     17    Width = 732
     18    Align = alClient
     19    BorderSpacing.Left = 4
     20    BorderSpacing.Right = 4
     21    BorderSpacing.Bottom = 4
    1922    Columns = <   
    2023      item
     
    4447  end
    4548  object ListViewFilter1: TListViewFilter
    46     Left = 8
     49    Left = 4
    4750    Height = 30
    48     Top = 8
    49     Width = 725
     51    Top = 4
     52    Width = 732
    5053    OnChange = ListViewFilter1Change
    51     Anchors = [akTop, akLeft, akRight]
     54    Align = alTop
     55    BorderSpacing.Left = 4
     56    BorderSpacing.Top = 4
     57    BorderSpacing.Right = 4
    5258  end
    5359  object StatusBar1: TStatusBar
    5460    Left = 0
    55     Height = 24
    56     Top = 534
     61    Height = 28
     62    Top = 530
    5763    Width = 740
    5864    Panels = <   
     
    6874    Left = 0
    6975    Height = 26
    70     Top = 508
     76    Top = 504
    7177    Width = 740
    7278    Align = alBottom
  • trunk/Forms/UFormAcronyms.pas

    r100 r104  
    112112  ListViewFilter1.UpdateFromListView(ListViewAcronyms);
    113113  UpdateAcronymsList;
     114  Core.ScaleDPI1.ScaleControl(ToolBar1, Core.ScaleDPI1.DesignDPI);
    114115end;
    115116
  • trunk/Forms/UFormCategories.lfm

    r97 r104  
    1212  LCLVersion = '1.6.0.4'
    1313  object ListViewCategories: TListView
    14     Left = 9
    15     Height = 374
    16     Top = 8
    17     Width = 767
    18     Anchors = [akTop, akLeft, akRight, akBottom]
     14    Left = 4
     15    Height = 395
     16    Top = 4
     17    Width = 776
     18    Align = alClient
     19    BorderSpacing.Around = 4
    1920    Columns = <   
    2021      item
  • trunk/Forms/UFormCategories.pas

    r97 r104  
    7070begin
    7171  UpdateList;
     72  Core.ScaleDPI1.ScaleControl(ToolBar1, Core.ScaleDPI1.DesignDPI);
    7273end;
    7374
  • trunk/Forms/UFormCategorySelect.lfm

    r96 r104  
    11object FormCategorySelect: TFormCategorySelect
    22  Left = 500
    3   Height = 602
     3  Height = 584
    44  Top = 253
    5   Width = 794
     5  Width = 791
    66  Caption = 'Select categories'
    7   ClientHeight = 602
    8   ClientWidth = 794
     7  ClientHeight = 584
     8  ClientWidth = 791
    99  OnCreate = FormCreate
    1010  OnShow = FormShow
     
    1313  object ListBox1: TListBox
    1414    Left = 16
    15     Height = 536
     15    Height = 518
    1616    Top = 8
    17     Width = 764
     17    Width = 761
    1818    Anchors = [akTop, akLeft, akRight, akBottom]
    1919    ItemHeight = 0
     
    2525  end
    2626  object ButtonOk: TButton
    27     Left = 704
     27    Left = 701
    2828    Height = 25
    29     Top = 559
     29    Top = 541
    3030    Width = 75
    3131    Anchors = [akRight, akBottom]
     
    3535  end
    3636  object ButtonCancel: TButton
    37     Left = 608
     37    Left = 605
    3838    Height = 25
    39     Top = 560
     39    Top = 542
    4040    Width = 75
    4141    Anchors = [akRight, akBottom]
  • trunk/Forms/UFormImportFormat.lfm

    r96 r104  
    11object FormImportFormat: TFormImportFormat
    22  Left = 462
    3   Height = 433
     3  Height = 439
    44  Top = 322
    5   Width = 664
     5  Width = 629
    66  Caption = 'Import format'
    7   ClientHeight = 433
    8   ClientWidth = 664
     7  ClientHeight = 439
     8  ClientWidth = 629
    99  OnCreate = FormCreate
    1010  OnShow = FormShow
     
    1212  LCLVersion = '1.6.0.4'
    1313  object ButtonOk: TButton
    14     Left = 560
     14    Left = 525
    1515    Height = 25
    16     Top = 384
     16    Top = 390
    1717    Width = 75
    1818    Anchors = [akRight, akBottom]
     
    2222  end
    2323  object ButtonCancel: TButton
    24     Left = 464
     24    Left = 429
    2525    Height = 25
    26     Top = 384
     26    Top = 390
    2727    Width = 75
    2828    Anchors = [akRight, akBottom]
     
    4343    Height = 28
    4444    Top = 48
    45     Width = 461
     45    Width = 426
    4646    Anchors = [akTop, akLeft, akRight]
    4747    TabOrder = 1
     
    5959    Height = 28
    6060    Top = 85
    61     Width = 461
     61    Width = 426
    6262    Anchors = [akTop, akLeft, akRight]
    6363    TabOrder = 2
     
    7575    Height = 28
    7676    Top = 125
    77     Width = 461
     77    Width = 426
    7878    Anchors = [akTop, akLeft, akRight]
    7979    TabOrder = 3
     
    8181  object ListViewItemRules: TListView
    8282    Left = 20
    83     Height = 192
     83    Height = 198
    8484    Top = 181
    85     Width = 620
     85    Width = 585
    8686    Anchors = [akTop, akLeft, akRight, akBottom]
    8787    Columns = <   
  • trunk/Forms/UFormImportFormats.lfm

    r85 r104  
    1212  LCLVersion = '1.6.0.4'
    1313  object ListView1: TListView
    14     Left = 8
    15     Height = 368
    16     Top = 8
    17     Width = 577
    18     Anchors = [akTop, akLeft, akRight, akBottom]
     14    Left = 4
     15    Height = 380
     16    Top = 4
     17    Width = 583
     18    Align = alClient
     19    BorderSpacing.Around = 4
    1920    Columns = <   
    2021      item
  • trunk/Forms/UFormImportFormats.pas

    r96 r104  
    104104begin
    105105  UpdateList;
     106  Core.ScaleDPI1.ScaleControl(ToolBar1, Core.ScaleDPI1.DesignDPI);
    106107end;
    107108
  • trunk/Forms/UFormImportSource.lfm

    r96 r104  
    11object FormImportSource: TFormImportSource
    22  Left = 493
    3   Height = 444
     3  Height = 459
    44  Top = 315
    5   Width = 630
     5  Width = 620
    66  Caption = 'Import source'
    7   ClientHeight = 444
    8   ClientWidth = 630
     7  ClientHeight = 459
     8  ClientWidth = 620
    99  OnCreate = FormCreate
    1010  OnShow = FormShow
     
    1515    Height = 28
    1616    Top = 10
    17     Width = 481
     17    Width = 471
    1818    Anchors = [akTop, akLeft, akRight]
    1919    TabOrder = 0
     
    3939    Height = 28
    4040    Top = 49
    41     Width = 360
     41    Width = 350
    4242    Anchors = [akTop, akLeft, akRight]
    4343    TabOrder = 1
    4444  end
    4545  object ButtonOk: TButton
    46     Left = 541
    47     Height = 25
    48     Top = 406
     46    Left = 531
     47    Height = 25
     48    Top = 421
    4949    Width = 75
    5050    Anchors = [akRight, akBottom]
     
    5454  end
    5555  object ButtonCancel: TButton
    56     Left = 439
    57     Height = 25
    58     Top = 406
     56    Left = 429
     57    Height = 25
     58    Top = 421
    5959    Width = 75
    6060    Anchors = [akRight, akBottom]
     
    7575    Height = 28
    7676    Top = 91
    77     Width = 360
     77    Width = 350
    7878    Anchors = [akTop, akLeft, akRight]
    7979    ItemHeight = 20
     
    8282  end
    8383  object ButtonShowFormat: TButton
    84     Left = 503
     84    Left = 493
    8585    Height = 25
    8686    Top = 91
     
    111111    Height = 141
    112112    Top = 160
    113     Width = 481
     113    Width = 471
    114114    Anchors = [akTop, akLeft, akRight]
    115115    ItemHeight = 0
     
    138138    Left = 10
    139139    Height = 2
    140     Top = 393
    141     Width = 580
    142     Anchors = [akLeft, akBottom]
     140    Top = 408
     141    Width = 597
     142    Anchors = [akLeft, akRight, akBottom]
    143143  end
    144144  object Label5: TLabel
     
    175175  end
    176176  object ButtonOpenURL: TButton
    177     Left = 503
     177    Left = 493
    178178    Height = 25
    179179    Top = 52
  • trunk/Forms/UFormImportSources.lfm

    r100 r104  
    4444  end
    4545  object ListView1: TListView
    46     Left = 8
    47     Height = 340
    48     Top = 44
    49     Width = 798
    50     Anchors = [akTop, akLeft, akRight, akBottom]
     46    Left = 4
     47    Height = 351
     48    Top = 33
     49    Width = 804
     50    Align = alClient
     51    BorderSpacing.Left = 4
     52    BorderSpacing.Right = 4
     53    BorderSpacing.Bottom = 4
    5154    Checkboxes = True
    5255    Columns = <   
     
    8689  end
    8790  object ListViewFilter1: TListViewFilter
    88     Left = 8
     91    Left = 4
    8992    Height = 29
    90     Top = 11
    91     Width = 798
     93    Top = 4
     94    Width = 804
    9295    OnChange = ListViewFilter1Change
    93     Anchors = [akTop, akLeft, akRight]
     96    Align = alTop
     97    BorderSpacing.Left = 4
     98    BorderSpacing.Top = 4
     99    BorderSpacing.Right = 4
    94100  end
    95101  object ActionList1: TActionList
  • trunk/Forms/UFormImportSources.pas

    r100 r104  
    172172begin
    173173  UpdateList;
     174  Core.ScaleDPI1.ScaleControl(ToolBar1, Core.ScaleDPI1.DesignDPI);
    174175end;
    175176
  • trunk/Forms/UFormMain.lfm

    r102 r104  
    710710    object MenuItem28: TMenuItem
    711711      Action = AProcessImports
     712      Bitmap.Data = {
     713        36040000424D3604000000000000360000002800000010000000100000000100
     714        2000000000000004000064000000640000000000000000000000000000000000
     715        0000000000000000000000000000000000000000000000000000000000000000
     716        0000000000000000000000000000000000000000000000000000000000000000
     717        000000000000303030FF303030FF303030FF303030FF00000000000000000000
     718        0000000000000000000000000000000000000000000000000000000000000000
     719        0000000000000000000000000000303030FF303030FF00000000000000000000
     720        0000000000000000000000000000303030FF0000000000000000000000000000
     721        0000000000000000000000000000303030FF303030FF00000000000000000000
     722        0000000000000000000000000000303030FF0000000000000000000000000000
     723        0000000000000000000000000000303030FF303030FF00000000000000003030
     724        30FF303030FF303030FF303030FF303030FF0000000000000000000000000000
     725        0000000000000000000000000000303030FF303030FF303030FF303030FF3030
     726        30FF303030FF303030FF303030FF303030FF0000000000000000000000000000
     727        000000000000000000000000000000000000303030FF303030FF303030FF3030
     728        30FF000000000000000000000000000000000000000000000000000000000000
     729        00000000000000000000000000000000000000000000303030FF303030FF0000
     730        0000000000000000000000000000000000000000000000000000000000000000
     731        00000000000000000000303030FF0000000000000000303030FF303030FF0000
     732        000000000000303030FF00000000000000000000000000000000000000000000
     733        000000000000303030FF303030FF303030FF303030FF303030FF303030FF0000
     734        000000000000303030FF00000000000000000000000000000000000000000000
     735        0000303030FF303030FF00000000303030FF303030FF303030FF303030FF0000
     736        000000000000303030FF00000000000000000000000000000000000000000000
     737        0000303030FF00000000000000000000000000000000303030FF303030FF3030
     738        30FF303030FF303030FF00000000000000000000000000000000000000000000
     739        000000000000000000000000000000000000303030FF303030FF000000000000
     740        0000000000000000000000000000000000000000000000000000000000000000
     741        0000000000000000000000000000303030FF303030FF303030FF303030FF0000
     742        0000000000000000000000000000000000000000000000000000000000000000
     743        0000000000000000000000000000303030FF303030FF303030FF303030FF0000
     744        0000000000000000000000000000000000000000000000000000000000000000
     745        000000000000000000000000000000000000303030FF303030FF000000000000
     746        0000000000000000000000000000000000000000000000000000
     747      }
    712748    end
    713749    object MenuItem19: TMenuItem
  • trunk/Forms/UFormMain.pas

    r102 r104  
    166166  ProjectExt = '.adp';
    167167  DefaultFileName = 'Acronyms' + ProjectExt;
    168   DefaultRegKey = '\Software\Chronosoft\Acronym Decoder';
    169168  RegistryRunKey = '\Software\Microsoft\Windows\CurrentVersion\Run';
    170169
     
    431430    ListViewFilter1.StringGrid.SetFocus;
    432431  end;
     432  Core.ScaleDPI1.ScaleImageList(ImageList1, Core.ScaleDPI1.DesignDPI);
     433  Core.ScaleDPI1.ScaleControl(ToolBar1, Core.ScaleDPI1.DesignDPI);
    433434end;
    434435
  • trunk/Packages/Common/UListViewSort.pas

    r103 r104  
    9595    property Align;
    9696    property Anchors;
     97    property BorderSpacing;
    9798  end;
    9899
  • trunk/Packages/Common/UScaleDPI.pas

    r3 r104  
    190190    Temp[I] := TBitmap.Create;
    191191    Temp[I].SetSize(NewWidth, NewHeight);
    192     Temp[I].TransparentColor := TempBmp.TransparentColor;
     192    Temp[I].TransparentColor := clFuchsia;// TempBmp.TransparentColor;
    193193    //Temp[I].TransparentMode := TempBmp.TransparentMode;
    194194    Temp[I].Transparent := True;
     
    247247  WinControl: TWinControl;
    248248  ToolBarControl: TToolBar;
    249   OldAnchors: TAnchors;
    250   OldAutoSize: Boolean;
    251 begin
    252   //if Control is TMemo then Exit;
    253   //if Control is TForm then
    254   //  Control.DisableAutoSizing;
    255   with Control do begin
    256     //OldAutoSize := AutoSize;
    257     //AutoSize := False;
    258     //Anchors := [];
    259     Left := ScaleX(Left, FromDPI.X);
    260     Top := ScaleY(Top, FromDPI.Y);
    261     //if not (akRight in Anchors) then
    262     Width := ScaleX(Width, FromDPI.X);
    263     //if not (akBottom in Anchors) then
    264     Height := ScaleY(Height, FromDPI.Y);
    265     {$IFDEF LCL Qt}
    266       Font.Size := 0;
    267     {$ELSE}
    268       Font.Height := ScaleY(Font.GetTextHeight('Hg'), FromDPI.Y);
    269     {$ENDIF}
    270     //Anchors := OldAnchors;
    271     //AutoSize := OldAutoSize;
    272   end;
    273 
    274 
     249begin
     250  Control.BoundsRect := ScaleRect(Control.BoundsRect, DesignDPI);
     251  Control.Font.Height := ScaleY(Control.Font.Height, DesignDPI.Y);
    275252
    276253  if Control is TToolBar then begin
  • trunk/UCore.lfm

    r97 r104  
    2626    top = 272
    2727  end
     28  object ScaleDPI1: TScaleDPI
     29    AutoDetect = False
     30    left = 156
     31    top = 272
     32  end
    2833end
  • trunk/UCore.pas

    r99 r104  
    77uses
    88  Classes, SysUtils, FileUtil, UAcronym, UCoolTranslator, UPersistentForm,
    9   UJobProgressView, Forms, Controls, LazFileUtils;
     9  UJobProgressView, UScaleDPI, Forms, Controls, LazFileUtils, URegistry,
     10  Registry;
    1011
    1112type
     
    1718    JobProgressView1: TJobProgressView;
    1819    PersistentForm1: TPersistentForm;
     20    ScaleDPI1: TScaleDPI;
    1921    procedure CoolTranslator1Translate(Sender: TObject);
    2022    procedure DataModuleCreate(Sender: TObject);
     
    2224  private
    2325    FAlwaysOnTop: Boolean;
     26    StoredDimension: TControlDimension;
    2427    procedure SetAlwaysOnTop(AValue: Boolean);
    2528    function FindFirstNonOption: string;
     
    3336    procedure LoadConfig;
    3437    procedure SaveConfig;
     38    procedure ScaleDPI;
    3539    property AlwaysOnTop: Boolean read FAlwaysOnTop write SetAlwaysOnTop;
    3640  end;
     
    3842var
    3943  Core: TCore;
     44
     45const
     46  DefaultRegKey = '\Software\Chronosoft\Acronym Decoder';
     47
    4048
    4149implementation
     
    5563  InitializeStarted := False;
    5664  InitializeFinished := False;
     65  StoredDimension := TControlDimension.Create;
    5766end;
    5867
    5968procedure TCore.DataModuleDestroy(Sender: TObject);
    6069begin
     70  FreeAndNil(StoredDimension);
    6171  FreeAndNil(AcronymDb);
    6272end;
     
    116126      FormMain.ProjectOpen(FileNameOption);
    117127    end;
     128    ScaleDPI;
    118129    FormMain.UpdateAcronymsList;
    119130    FormMain.ListViewFilter1.UpdateFromListView(FormMain.ListViewAcronyms);
     
    125136begin
    126137  FormMain.LoadConfig;
     138
     139  with TRegistryEx.Create do
     140  try
     141    RootKey := HKEY_CURRENT_USER;
     142    OpenKey(DefaultRegKey, True);
     143    ScaleDPI1.DPI := Point(ReadIntegerWithDefault('DPIX', 96), ReadIntegerWithDefault('DPIY', 96));
     144    ScaleDPI1.AutoDetect := ReadBoolWithDefault('DPIAuto', True);
     145  finally
     146    Free;
     147  end;
    127148end;
    128149
     
    130151begin
    131152  FormMain.SaveConfig;
     153
     154  with TRegistryEx.Create do
     155  try
     156    RootKey := HKEY_CURRENT_USER;
     157    OpenKey(DefaultRegKey, True);
     158    WriteInteger('DPIX', ScaleDPI1.DPI.X);
     159    WriteInteger('DPIY', ScaleDPI1.DPI.Y);
     160    WriteBool('DPIAuto', ScaleDPI1.AutoDetect);
     161  finally
     162    Free;
     163  end;
     164end;
     165
     166procedure TCore.ScaleDPI;
     167var
     168  I: Integer;
     169begin
     170  //ScaleDPI1.DPI := Point(150, 150);
     171  with ScaleDPI1 do
     172  if (DesignDPI.X <> DPI.X) or (DesignDPI.Y <> DPI.Y) then begin
     173    for I := 0 to Screen.FormCount - 1 do begin
     174      //StoreDimensions(Screen.Forms[I], StoredDimension);
     175      //ScaleDimensions(Screen.Forms[I], StoredDimension);
     176    end;
     177  end;
    132178end;
    133179
Note: See TracChangeset for help on using the changeset viewer.