Changeset 585
- Timestamp:
- Jan 13, 2026, 4:12:03 PM (16 hours ago)
- Location:
- DpiControls
- Files:
-
- 13 added
- 1 deleted
- 8 edited
-
Demo (modified) (1 prop)
-
Demo/DpiComponentsDemo.lpi (modified) (3 diffs)
-
Demo/UDpiFormMain.lfm (modified) (2 diffs)
-
Demo/UDpiFormMain.pas (modified) (8 diffs)
-
Demo/UFormMain.lfm (modified) (2 diffs)
-
Demo/UFormMain.pas (modified) (5 diffs)
-
Dpi.ComCtrls.pas (added)
-
Dpi.Common.pas (added)
-
Dpi.Controls.pas (added)
-
Dpi.ExtCtrls.pas (added)
-
Dpi.Forms.pas (added)
-
Dpi.Graphics.pas (added)
-
Dpi.Grids.pas (added)
-
Dpi.Menus.pas (added)
-
Dpi.PixelPointer.pas (added)
-
Dpi.Spin.pas (added)
-
Dpi.StdCtrls.pas (added)
-
DpiControls.lpk (modified) (2 diffs)
-
DpiControls.pas (modified) (1 diff)
-
DpiControlsPackage.pas (added)
-
NativePixelPointer.pas (added)
-
UDpiControls.pas (deleted)
Legend:
- Unmodified
- Added
- Removed
-
DpiControls/Demo
- Property svn:ignore
-
old new 3 3 DpiComponentsDemo.res 4 4 lib 5 heaptrclog.trc
-
- Property svn:ignore
-
DpiControls/Demo/DpiComponentsDemo.lpi
r535 r585 2 2 <CONFIG> 3 3 <ProjectOptions> 4 <Version Value="1 1"/>4 <Version Value="12"/> 5 5 <General> 6 <Flags> 7 <CompatibilityMode Value="True"/> 8 </Flags> 6 9 <SessionStorage Value="InProjectDir"/> 7 <MainUnit Value="0"/>8 10 <Title Value="DpiComponentsDemo"/> 9 11 <Scaled Value="True"/> … … 63 65 <RunParams> 64 66 <FormatVersion Value="2"/> 65 <Modes Count="0"/>66 67 </RunParams> 67 68 <RequiredPackages Count="2"> … … 122 123 <Linking> 123 124 <Debugging> 125 <DebugInfoType Value="dsDwarf3"/> 124 126 <UseHeaptrc Value="True"/> 125 127 </Debugging> -
DpiControls/Demo/UDpiFormMain.lfm
r537 r585 1 1 object DpiFormMain: TDpiFormMain 2 ClientHeight = 1 3 ClientWidth = 1 2 4 Top = 504 3 5 Left = 865 4 6 Width = 1 5 7 Height = 1 6 Visible = True7 8 Enabled = True 8 9 ShowHint = False … … 11 12 Align = alNone 12 13 Color = clDefault 14 HorzScrollBar.Visible = False 15 VertScrollBar.Visible = False 13 16 DesignTimePPI = 96 17 FormStyle = fsNormal 14 18 BorderStyle = Controls 15 19 BorderIcons = [biSystemMenu, biMinimize, biMaximize] 16 20 OnCreate = DpiFormMainCreate 17 21 OnDestroy = DpiFormMainDestroy 18 object DpiPaintBox1: TDpiPaintBox19 Top = 24820 Left = 8821 Width = 10022 Height = 10023 Visible = True24 Enabled = True25 ShowHint = False26 Font.Color = clDefault27 Font.Name = 'jjjdefault'28 Font.PixelsPerInch = 14429 Align = alNone30 Color = clDefault31 end32 22 end -
DpiControls/Demo/UDpiFormMain.pas
r537 r585 6 6 7 7 uses 8 Classes, SysUtils, UDpiControls, Dialogs, Graphics; 8 Classes, SysUtils, Dpi.Controls, Dpi.ExtCtrls, Dialogs, Dpi.Graphics, Dpi.Forms, 9 Types; 9 10 10 11 type … … 12 13 { TDpiFormMain } 13 14 14 TDpiFormMain = class(T DpiForm)15 DpiPaintBox1: T DpiPaintBox;15 TDpiFormMain = class(TForm) 16 DpiPaintBox1: TPaintBox; 16 17 procedure DpiButton1Click(Sender: TObject); 17 18 procedure DpiFormMainCreate(Sender: TObject); … … 19 20 procedure DpiPaintBox1Paint(Sender: TObject); 20 21 private 21 Button: TDpiButton; 22 Image: TDpiImage; 23 ListBox: TDpiListBox; 24 PaintBox: TDpiPaintBox; 22 Button: TButton; 23 ButtonClose: TButton; 24 Image: TImage; 25 ListBox: TListBox; 26 PaintBox: TPaintBox; 27 Bitmap: TBitmap; 28 procedure ButtonCloseClick(Sender: TObject); 25 29 public 26 27 30 end; 28 31 … … 39 42 var 40 43 I: Integer; 44 X, Y: Integer; 41 45 begin 42 46 Button := TDpiButton.Create(DpiFormMain); … … 45 49 Button.Caption := 'Click me'; 46 50 Button.Visible := True; 51 Button.OnClick := @DpiButton1Click; 52 53 ButtonClose := TDpiButton.Create(DpiFormMain); 54 ButtonClose.Parent := Self; 55 ButtonClose.SetBounds(120, 10, 100, 30); 56 ButtonClose.Caption := 'Close'; 57 ButtonClose.Visible := True; 58 ButtonClose.OnClick := @ButtonCloseClick; 47 59 48 60 Image := TDpiImage.Create(DpiFormMain); … … 61 73 ListBox.Visible := True; 62 74 63 DpiPaintBox1.BoundsRect := Rect(0, 0, 100, 100); 64 DpiPaintBox1.VclPaintBox.Parent := VclForm; 65 DpiPaintBox1.Repaint; 75 PaintBox := TDpiPaintBox.Create(DpiFormMain); 76 PaintBox.Parent := Self; 77 PaintBox.BoundsRect := Bounds(0, 100, 200, 200); 78 PaintBox.OnPaint := @DpiPaintBox1Paint; 79 PaintBox.Visible := True; 80 81 Bitmap := TDpiBitmap.Create; 82 Bitmap.PixelFormat := pf24bit; 83 Bitmap.SetSize(120, 50); 84 for Y := 0 to Bitmap.Height - 1 do 85 for X := 0 to Bitmap.Width - 1 do 86 Bitmap.Canvas.Pixels[X, Y] := X mod 255; 87 Bitmap.LoadFromFile('dance.bmp'); 66 88 end; 67 89 … … 74 96 75 97 procedure TDpiFormMain.DpiPaintBox1Paint(Sender: TObject); 98 var 99 X, Y: Integer; 76 100 begin 77 with DpiPaintBox1.Canvas do begin101 with PaintBox.Canvas do begin 78 102 Brush.Color := clWhite; 79 103 Brush.Style := bsSolid; 80 FillRect( Rect(0, 0, 100, 100));104 FillRect(Bounds(0, 0, PaintBox.Width, PaintBox.Height)); 81 105 Caption := IntToStr(Width); 82 106 Pen.Color := clGreen; … … 85 109 LineTo(100, 100); 86 110 Font.Color := clRed; 87 TextOut(40, 10, 'Scaled text'); 111 Font.Size := 20; 112 TextOut(10, 10, 'Scaled text'); 113 114 Brush.Color := clBlue; 115 Rectangle(Bounds(20, 30, 60, 30)); 116 117 Bitmap.Dpi := DpiScreen.Dpi; 118 DpiBitBltCanvas(PaintBox.Canvas, 0, 0, Bitmap.Width, Bitmap.Height, Bitmap.Canvas, 0, 0); 88 119 end; 89 120 end; 90 121 122 procedure TDpiFormMain.ButtonCloseClick(Sender: TObject); 123 begin 124 ModalResult := mrOk; 125 end; 126 91 127 procedure TDpiFormMain.DpiButton1Click(Sender: TObject); 128 var 129 DpiForm: TDpiForm; 92 130 begin 93 ShowMessage('Hello'); 131 //ShowMessage('Hello'); 132 DpiForm := TDpiFormMain.CreateNew(Self); 133 DpiForm.Name := 'Form10'; 134 DpiForm.Caption := 'Modal form'; 135 DpiForm.SetBounds(200, 150, 400, 200); 136 DpiForm.ShowModal; 94 137 end; 95 138 -
DpiControls/Demo/UFormMain.lfm
r537 r585 8 8 ClientWidth = 472 9 9 DesignTimePPI = 144 10 OnActivate = FormActivate 10 11 OnDestroy = FormDestroy 11 12 OnShow = FormShow 12 LCLVersion = ' 2.0.2.0'13 LCLVersion = '3.2.0.0' 13 14 object TrackBar1: TTrackBar 14 15 Left = 13 … … 31 32 end 32 33 object ButtonNewDpiForm: TButton 34 ClientHeight = 38 35 ClientWidth = 193 36 Top = 117 33 37 Left = 19 38 Width = 193 34 39 Height = 38 35 Top = 11736 Width = 19337 40 Caption = 'New DpiForm' 41 Enabled = True 42 ShowHint = False 43 Font.Color = clDefault 44 Font.PixelsPerInch = 96 45 Font.Height = -16 46 Align = alNone 47 Color = clDefault 38 48 OnClick = ButtonNewDpiFormClick 39 TabOrder = 1 49 TabStop = True 50 Visible = True 40 51 end 41 52 object Timer1: TTimer 42 53 Interval = 100 43 54 OnTimer = Timer1Timer 44 left = 25645 top = 4055 Left = 256 56 Top = 40 46 57 end 47 58 end -
DpiControls/Demo/UFormMain.pas
r537 r585 7 7 uses 8 8 Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ComCtrls, StdCtrls, 9 ExtCtrls, UDpiControls, UDpiFormMain;9 ExtCtrls, Dpi.Controls, Dpi.Forms, UDpiFormMain; 10 10 11 11 type … … 19 19 TrackBar1: TTrackBar; 20 20 procedure ButtonNewDpiFormClick(Sender: TObject); 21 procedure FormActivate(Sender: TObject); 21 22 procedure FormDestroy(Sender: TObject); 22 23 procedure FormShow(Sender: TObject); … … 24 25 procedure TrackBar1Change(Sender: TObject); 25 26 private 27 Initialized: Boolean; 26 28 DpiForm: TDpiForm; 27 29 public … … 42 44 DpiScreen.Dpi := 96 * 2; 43 45 TrackBar1.Position := DpiScreen.Dpi; 44 ButtonNewDpiFormClick(nil);45 46 end; 46 47 … … 53 54 procedure TFormMain.ButtonNewDpiFormClick(Sender: TObject); 54 55 begin 55 DpiForm := TDpiFormMain.Create(nil); 56 DpiApplication.CreateForm(TDpiFormMain, DpiForm); 57 //DpiForm := TDpiFormMain.Create(Self); 56 58 DpiForm.Caption := DpiForm.Name; 57 59 DpiForm.SetBounds(100, 100, 400, 200); 58 60 DpiForm.Show; 59 DpiScreen.Forms.Add(DpiForm); 61 end; 62 63 procedure TFormMain.FormActivate(Sender: TObject); 64 begin 65 if not Initialized then begin 66 Initialized := True; 67 ButtonNewDpiFormClick(nil); 68 end; 60 69 end; 61 70 -
DpiControls/DpiControls.lpk
r532 r585 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 2 <CONFIG> 3 <Package Version=" 4">3 <Package Version="5"> 4 4 <Name Value="DpiControls"/> 5 5 <Type Value="RunAndDesignTime"/> … … 10 10 <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)-${BuildMode}"/> 11 11 </SearchPaths> 12 <Parsing> 13 <SyntaxOptions> 14 <SyntaxMode Value="Delphi"/> 15 <CStyleOperator Value="False"/> 16 <AllowLabel Value="False"/> 17 <CPPInline Value="False"/> 18 </SyntaxOptions> 19 </Parsing> 20 <CodeGeneration> 21 <Optimizations> 22 <OptimizationLevel Value="0"/> 23 </Optimizations> 24 </CodeGeneration> 25 <Linking> 26 <Debugging> 27 <GenerateDebugInfo Value="False"/> 28 </Debugging> 29 </Linking> 30 <Other> 31 <CompilerMessages> 32 <IgnoredMessages idx6058="True" idx3123="True"/> 33 </CompilerMessages> 34 </Other> 12 35 </CompilerOptions> 13 36 <Description Value="Controls with dimensions independent to screen DPI setting. The controls use internally VCL controls. All positions and sizes are scaled from DPI independent values."/> 14 37 <License Value="Copyleft, public domain"/> 15 <Version Minor=" 1"/>16 <Files Count="1 ">38 <Version Minor="2"/> 39 <Files Count="14"> 17 40 <Item1> 18 <Filename Value=" UDpiControls.pas"/>41 <Filename Value="DpiControls.pas"/> 19 42 <HasRegisterProc Value="True"/> 20 <UnitName Value=" UDpiControls"/>43 <UnitName Value="DpiControls"/> 21 44 </Item1> 45 <Item2> 46 <Filename Value="Dpi.PixelPointer.pas"/> 47 <UnitName Value="Dpi.PixelPointer"/> 48 </Item2> 49 <Item3> 50 <Filename Value="DpiControlsPackage.pas"/> 51 <Type Value="Main Unit"/> 52 <UnitName Value="DpiControlsPackage"/> 53 </Item3> 54 <Item4> 55 <Filename Value="Dpi.Forms.pas"/> 56 <UnitName Value="Dpi.Forms"/> 57 </Item4> 58 <Item5> 59 <Filename Value="Dpi.Controls.pas"/> 60 <UnitName Value="Dpi.Controls"/> 61 </Item5> 62 <Item6> 63 <Filename Value="Dpi.Graphics.pas"/> 64 <UnitName Value="Dpi.Graphics"/> 65 </Item6> 66 <Item7> 67 <Filename Value="Dpi.Common.pas"/> 68 <UnitName Value="Dpi.Common"/> 69 </Item7> 70 <Item8> 71 <Filename Value="Dpi.Menus.pas"/> 72 <HasRegisterProc Value="True"/> 73 <UnitName Value="Dpi.Menus"/> 74 </Item8> 75 <Item9> 76 <Filename Value="Dpi.ComCtrls.pas"/> 77 <UnitName Value="Dpi.ComCtrls"/> 78 </Item9> 79 <Item10> 80 <Filename Value="Dpi.StdCtrls.pas"/> 81 <HasRegisterProc Value="True"/> 82 <UnitName Value="Dpi.StdCtrls"/> 83 </Item10> 84 <Item11> 85 <Filename Value="Dpi.ExtCtrls.pas"/> 86 <HasRegisterProc Value="True"/> 87 <UnitName Value="Dpi.ExtCtrls"/> 88 </Item11> 89 <Item12> 90 <Filename Value="Dpi.Grids.pas"/> 91 <UnitName Value="Dpi.Grids"/> 92 </Item12> 93 <Item13> 94 <Filename Value="Dpi.Spin.pas"/> 95 <UnitName Value="Dpi.Spin"/> 96 </Item13> 97 <Item14> 98 <Filename Value="NativePixelPointer.pas"/> 99 <UnitName Value="NativePixelPointer"/> 100 </Item14> 22 101 </Files> 102 <CompatibilityMode Value="True"/> 23 103 <RequiredPkgs Count="3"> 24 104 <Item1> -
DpiControls/DpiControls.pas
r532 r585 1 { This file was automatically created by Lazarus. Do not edit!2 This source is only used to compile and install the package.3 }4 5 1 unit DpiControls; 6 2 7 {$warn 5023 off : no warning about unused units}8 3 interface 9 4 10 5 uses 11 UDpiControls, LazarusPackageIntf; 6 {$IFDEF WINDOWS}Windows, {$ENDIF}Classes, SysUtils, LCLProc, LResources, Forms, 7 Generics.Collections, FormEditingIntf, ProjectIntf, Controls, StdCtrls, Graphics, 8 ComCtrls, ExtCtrls, LCLType, GraphType, Types, CustApp, LMessages, LCLIntf, 9 Menus, Math, Dpi.PixelPointer, Grids, Spin, Dpi.Forms, Dpi.Controls, Dpi.Graphics; 10 11 type 12 13 { TDpiFormFileDesc } 14 15 TDpiFormFileDesc = class(TFileDescPascalUnitWithResource) 16 public 17 constructor Create; override; 18 function GetInterfaceUsesSection: string; override; 19 function GetLocalizedName: string; override; 20 function GetLocalizedDescription: string; override; 21 end; 22 23 var 24 DpiFormFileDesc: TDpiFormFileDesc; 25 26 procedure Register; 27 12 28 13 29 implementation 14 30 31 uses 32 LCLStrConsts, Dpi.Common; 33 34 resourcestring 35 SDpiFormTitle = 'DpiForm form'; 36 SDpiFormDescription = 'DPI aware form'; 37 15 38 procedure Register; 16 39 begin 17 RegisterUnit('UDpiControls', @UDpiControls.Register); 40 FormEditingHook.RegisterDesignerBaseClass(TForm); 41 DpiFormFileDesc := TDpiFormFileDesc.Create; 42 RegisterProjectFileDescriptor(DpiFormFileDesc); 43 end; 44 45 { TDpiFormFileDesc } 46 47 constructor TDpiFormFileDesc.Create; 48 begin 49 inherited Create; 50 Name := 'DpiForm form'; 51 ResourceClass := TForm; 52 UseCreateFormStatements := False; 53 end; 54 55 function TDpiFormFileDesc.GetInterfaceUsesSection: string; 56 begin 57 Result := inherited GetInterfaceUsesSection; 58 Result := Result + ', UDpiForm'; 59 end; 60 61 function TDpiFormFileDesc.GetLocalizedName: string; 62 begin 63 Result := SDpiFormTitle; 64 end; 65 66 function TDpiFormFileDesc.GetLocalizedDescription: string; 67 begin 68 Result := SDpiFormDescription; 18 69 end; 19 70 20 71 initialization 21 RegisterPackage('DpiControls', @Register); 72 73 22 74 end. 75
Note:
See TracChangeset
for help on using the changeset viewer.
