- Timestamp:
- Dec 4, 2014, 5:19:20 PM (10 years ago)
- Location:
- Common
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
Common/Common.lpk
r463 r467 12 12 <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> 13 13 </SearchPaths> 14 <Other>15 <CompilerMessages>16 <UseMsgFile Value="True"/>17 </CompilerMessages>18 <CompilerPath Value="$(CompPath)"/>19 </Other>20 14 </CompilerOptions> 21 15 <Description Value="Various libraries"/> 22 16 <License Value="GNU/GPL"/> 23 17 <Version Minor="7"/> 24 <Files Count=" 19">18 <Files Count="20"> 25 19 <Item1> 26 20 <Filename Value="StopWatch.pas"/> … … 106 100 <UnitName Value="UFindFile"/> 107 101 </Item19> 102 <Item20> 103 <Filename Value="UScaleDPI.pas"/> 104 <HasRegisterProc Value="True"/> 105 <UnitName Value="UScaleDPI"/> 106 </Item20> 108 107 </Files> 109 108 <i18n> -
Common/Common.pas
r463 r467 11 11 UMemory, UResetableThread, UPool, ULastOpenedList, URegistry, 12 12 UJobProgressView, UXMLUtils, UApplicationInfo, USyncCounter, UListViewSort, 13 UPersistentForm, UFindFile, LazarusPackageIntf;13 UPersistentForm, UFindFile, UScaleDPI, LazarusPackageIntf; 14 14 15 15 implementation -
Common/UScaleDPI.pas
r466 r467 14 14 { TScaleDPI } 15 15 16 TScaleDPI = class 16 TScaleDPI = class(TComponent) 17 17 private 18 18 FAutoDetect: Boolean; … … 27 27 function ScaleX(Size: Integer; FromDPI: Integer): Integer; 28 28 function ScaleY(Size: Integer; FromDPI: Integer): Integer; 29 constructor Create; 29 constructor Create(AOwner: TComponent); 30 published 30 31 property AutoDetect: Boolean read FAutoDetect write SetAutoDetect; 31 32 end; 32 33 34 procedure Register; 33 35 34 36 implementation 37 38 procedure Register; 39 begin 40 RegisterComponents('Common', [TScaleDPI]); 41 end; 35 42 36 43 procedure TScaleDPI.SetAutoDetect(AValue: Boolean); … … 59 66 I: Integer; 60 67 begin 61 if (DPI.X <= FromDPI.X * 1.1) or (DPI.Y <= FromDPI.Y * 1.1) then Exit;62 63 68 NewWidth := ScaleX(ImgList.Width, FromDPI.X); 64 69 NewHeight := ScaleY(ImgList.Height, FromDPI.Y); … … 97 102 function TScaleDPI.ScaleX(Size: Integer; FromDPI: Integer): Integer; 98 103 begin 99 if DPI.X <= FromDPI then 100 Result := Size 101 else 102 Result := MulDiv(Size, DPI.X, FromDPI); 104 Result := MulDiv(Size, DPI.X, FromDPI); 103 105 end; 104 106 105 107 function TScaleDPI.ScaleY(Size: Integer; FromDPI: Integer): Integer; 106 108 begin 107 if Screen.PixelsPerInch <= FromDPI then 108 Result := Size 109 else 110 Result := MulDiv(Size, DPI.Y, FromDPI); 109 Result := MulDiv(Size, DPI.Y, FromDPI); 111 110 end; 112 111 … … 117 116 end; 118 117 119 constructor TScaleDPI.Create ;118 constructor TScaleDPI.Create(AOwner: TComponent); 120 119 begin 120 inherited; 121 121 DPI := Point(96, 96); 122 122 DesignDPI := Point(96, 96); … … 129 129 ToolBarControl: TToolBar; 130 130 begin 131 if (DPI.X <= FromDPI.X) or (DPI.Y <= FromDPI.Y) then Exit;132 133 131 with Control do begin 134 132 Left := ScaleX(Left, FromDPI.X);
Note:
See TracChangeset
for help on using the changeset viewer.