- Timestamp:
- May 7, 2020, 7:05:57 PM (5 years ago)
- Location:
- branches/highdpi
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/highdpi/Back.pas
r179 r193 65 65 begin 66 66 if Assigned(Img) then 67 DpiBitBlt(Canvas.Handle, Screen.Width - Img.Width - (Screen.Width - 800) *68 3 div 8, ( Screen.Height - 600) div 3, Img.Width, Img.Height,67 DpiBitBlt(Canvas.Handle, DpiScreen.Width - Img.Width - (DpiScreen.Width - 800) * 68 3 div 8, (DpiScreen.Height - 600) div 3, Img.Width, Img.Height, 69 69 Img.Canvas.Handle, 0, 0, SRCCOPY); 70 70 end; -
branches/highdpi/Inp.pas
r111 r193 7 7 ScreenTools, Messg, 8 8 LCLIntf, LCLType, SysUtils, Classes, Graphics, Controls, Forms, DrawDlg, 9 ButtonA, StdCtrls ;9 ButtonA, StdCtrls, UDpiControls; 10 10 11 11 type … … 88 88 EInput.SelLength := Length(EInput.Text); 89 89 if Center then 90 CenterToRect(Rect(0, 0, Screen.Width,Screen.Height));90 CenterToRect(Rect(0, 0, DpiScreen.Width, DpiScreen.Height)); 91 91 end; 92 92 -
branches/highdpi/Integrated.lpi
r180 r193 16 16 <ResourceType Value="res"/> 17 17 <UseXPManifest Value="True"/> 18 <XPManifest> 19 <DpiAware Value="True"/> 20 </XPManifest> 18 21 <Icon Value="0"/> 19 22 <Resources Count="2"> … … 133 136 <ComponentName Value="DirectDlg"/> 134 137 <HasResources Value="True"/> 138 <ResourceBaseClass Value="Form"/> 135 139 </Unit7> 136 140 <Unit8> -
branches/highdpi/LocalPlayer/Battle.pas
r179 r193 212 212 OKBtn.Visible := true; 213 213 CancelBtn.Visible := true; 214 Left := ( Screen.Width - ClientWidth) div 2; // center on screen215 Top := ( Screen.Height - ClientHeight) div 2;214 Left := (DpiScreen.Width - ClientWidth) div 2; // center on screen 215 Top := (DpiScreen.Height - ClientHeight) div 2; 216 216 end 217 217 else -
branches/highdpi/LocalPlayer/CityScreen.pas
r179 r193 1106 1106 if WindowMode = wmModal then 1107 1107 begin { center on screen } 1108 Left := ( Screen.Width - Width) div 2;1109 Top := ( Screen.Height - Height) div 2;1108 Left := (DpiScreen.Width - Width) div 2; 1109 Top := (DpiScreen.Height - Height) div 2; 1110 1110 end; 1111 1111 -
branches/highdpi/LocalPlayer/Diagram.pas
r178 r193 293 293 if WindowMode = wmModal then 294 294 begin { center on screen } 295 Left := ( Screen.Width - Width) div 2;296 Top := ( Screen.Height - Height) div 2;295 Left := (DpiScreen.Width - Width) div 2; 296 Top := (DpiScreen.Height - Height) div 2; 297 297 end; 298 298 OffscreenPaint; -
branches/highdpi/LocalPlayer/Draft.pas
r179 r193 488 488 if WindowMode = wmModal then 489 489 begin { center on screen } 490 Left := ( Screen.Width - Template.Width) div 2;491 Top := ( Screen.Height - (Template.Height - Cut)) div 2;490 Left := (DpiScreen.Width - Template.Width) div 2; 491 Top := (DpiScreen.Height - (Template.Height - Cut)) div 2; 492 492 end; 493 493 -
branches/highdpi/LocalPlayer/Help.lfm
r69 r193 1 1 object HelpDlg: THelpDlg 2 2 Left = 394 3 Height = 718 3 4 Top = 180 5 Width = 840 4 6 BorderIcons = [] 5 7 BorderStyle = bsNone 6 ClientHeight = 4797 ClientWidth = 5608 ClientHeight = 718 9 ClientWidth = 840 8 10 Color = clBtnFace 9 Font.Charset = DEFAULT_CHARSET11 DesignTimePPI = 144 10 12 Font.Color = clWindowText 11 Font.Height = - 1313 Font.Height = -20 12 14 Font.Name = 'MS Sans Serif' 13 Font.Style = []14 15 FormStyle = fsStayOnTop 15 16 OnClose = FormClose … … 17 18 OnDestroy = FormDestroy 18 19 OnKeyDown = FormKeyDown 19 OnMouseWheel = FormMouseWheel20 20 OnMouseDown = PaintBox1MouseDown 21 21 OnMouseMove = PaintBox1MouseMove 22 OnMouseWheel = FormMouseWheel 22 23 OnPaint = FormPaint 23 PixelsPerInch = 9624 LCLVersion = '2.0.8.0' 24 25 object CloseBtn: TButtonB 25 Left = 52226 Top = 627 Width = 2528 Height = 2526 Left = 783 27 Height = 38 28 Top = 9 29 Width = 38 29 30 Down = False 30 31 Permanent = False … … 33 34 end 34 35 object BackBtn: TButtonB 35 Left = 4236 Top = 637 Width = 2538 Height = 2536 Left = 63 37 Height = 38 38 Top = 9 39 Width = 38 39 40 Down = False 40 41 Permanent = False … … 43 44 end 44 45 object TopBtn: TButtonB 45 Left = 1346 Top = 647 Width = 2548 Height = 2546 Left = 20 47 Height = 38 48 Top = 9 49 Width = 38 49 50 Down = False 50 51 Permanent = False … … 53 54 end 54 55 object SearchBtn: TButtonB 55 Left = 49356 Top = 657 Width = 2558 Height = 2556 Left = 740 57 Height = 38 58 Top = 9 59 Width = 38 59 60 Down = False 60 61 Permanent = False -
branches/highdpi/LocalPlayer/Help.pas
r179 r193 367 367 ImpPtr: array [-1 .. 1] of TPixelPointer; 368 368 begin 369 { TODO 369 370 // assume eiffel tower has free common heaven 370 371 for dy := 0 to nHeaven - 1 do … … 376 377 xSrc := iix mod 7 * xSizeBig; 377 378 ySrc := (iix div 7 + 1) * ySizeBig; 378 for y := 0 to ySizeBig * 2- 1 do379 for y := 0 to ScaleToVcl(ySizeBig * 2) - 1 do 379 380 if ((y0 + y) >= 0) and ((y0 + y) < InnerHeight) then begin 380 PaintPtr.Init(OffScreen, 0, y0 + y);381 CoalPtr.Init(Templates, 0, yCoal + y);381 PaintPtr.Init(OffScreen, 0, ScaleToVcl(y0 + y)); 382 CoalPtr.Init(Templates, 0, ScaleToVcl(yCoal + y)); 382 383 for dy := -1 to 1 do 383 384 if ((Max(y + dy, 0) shr 1) >= 0) and ((Max(y + dy, 0) shr 1) < ySizeBig) then 384 ImpPtr[dy].Init(BigImp, 0, ySrc + (Max(y + dy, 0) shr 1));385 for x := 0 to xSizeBig * 2- 1 do begin385 ImpPtr[dy].Init(BigImp, 0, ScaleToVcl(ySrc + (Max(y + dy, 0) shr 1))); 386 for x := 0 to ScaleToVcl(xSizeBig * 2) - 1 do begin 386 387 sum := 0; 387 388 for dx := -1 to 1 do begin … … 412 413 Offscreen.EndUpdate; 413 414 BigImp.EndUpdate; 415 } 414 416 end; 415 417 -
branches/highdpi/LocalPlayer/MessgEx.pas
r179 r193 177 177 0: 178 178 begin 179 Left := ( Screen.Width - ClientWidth) div 2;180 Top := ( Screen.Height - ClientHeight) div 2 - MapCenterUp;179 Left := (DpiScreen.Width - ClientWidth) div 2; 180 Top := (DpiScreen.Height - ClientHeight) div 2 - MapCenterUp; 181 181 end; 182 182 1: 183 183 begin 184 Left := ( Screen.Width - ClientWidth) div 4;185 Top := ( Screen.Height - ClientHeight) * 2 div 3 - MapCenterUp;184 Left := (DpiScreen.Width - ClientWidth) div 4; 185 Top := (DpiScreen.Height - ClientHeight) * 2 div 3 - MapCenterUp; 186 186 end; 187 187 -1: 188 188 begin 189 Left := ( Screen.Width - ClientWidth) div 4;190 Top := ( Screen.Height - ClientHeight) div 3 - MapCenterUp;189 Left := (DpiScreen.Width - ClientWidth) div 4; 190 Top := (DpiScreen.Height - ClientHeight) div 3 - MapCenterUp; 191 191 end; 192 192 end; -
branches/highdpi/LocalPlayer/Rates.pas
r179 r193 42 42 procedure TRatesDlg.FormCreate(Sender: TObject); 43 43 begin 44 TitleHeight := Screen.Height;44 TitleHeight := DpiScreen.Height; 45 45 InitButtons(); 46 46 end; -
branches/highdpi/LocalPlayer/Select.pas
r179 r193 1609 1609 begin { center on screen } 1610 1610 if Kind = kTribe then 1611 Left := ( Screen.Width - 800) * 3 div 8 + 1301611 Left := (DpiScreen.Width - 800) * 3 div 8 + 130 1612 1612 else 1613 Left := ( Screen.Width - Width) div 2;1614 Top := ( Screen.Height - Height) div 2;1613 Left := (DpiScreen.Width - Width) div 2; 1614 Top := (DpiScreen.Height - Height) div 2; 1615 1615 if Kind = kProject then 1616 1616 Top := Top + 48; -
branches/highdpi/LocalPlayer/TechTree.pas
r179 r193 183 183 184 184 // fit window to image, center image in window, center window to screen 185 width := min( Screen.width - 40, Image.width + LeftBorder + RightBorder + 2 *185 width := min(DpiScreen.width - 40, Image.width + LeftBorder + RightBorder + 2 * 186 186 BlackBorder); 187 height := min( Screen.height - 40, Image.height + TopBorder + BottomBorder + 2187 height := min(DpiScreen.height - 40, Image.height + TopBorder + BottomBorder + 2 188 188 * BlackBorder); 189 Left := ( Screen.width - width) div 2;190 Top := ( Screen.height - height) div 2;189 Left := (DpiScreen.width - width) div 2; 190 Top := (DpiScreen.height - height) div 2; 191 191 CloseBtn.Left := width - CloseBtn.width - BlackBorder - 8; 192 192 CloseBtn.Top := BlackBorder + 8; -
branches/highdpi/LocalPlayer/Term.pas
r179 r193 2503 2503 SetMainTextureByAge(-1); 2504 2504 Tribes.Init; 2505 HelpDlg.UserLeft := ( Screen.width - HelpDlg.width) div 2;2506 HelpDlg.UserTop := ( Screen.height - HelpDlg.height) div 2;2505 HelpDlg.UserLeft := (DpiScreen.width - HelpDlg.width) div 2; 2506 HelpDlg.UserTop := (DpiScreen.height - HelpDlg.height) div 2; 2507 2507 HelpDlg.Difficulty := 0; 2508 2508 if Command = cStartCredits then … … 2566 2566 ListDlg.UserLeft := 8; 2567 2567 ListDlg.UserTop := TopBarHeight + 8; 2568 HelpDlg.UserLeft := Screen.width - HelpDlg.width - 8;2568 HelpDlg.UserLeft := DpiScreen.width - HelpDlg.width - 8; 2569 2569 HelpDlg.UserTop := TopBarHeight + 8; 2570 2570 UnitStatDlg.UserLeft := 397; 2571 2571 UnitStatDlg.UserTop := TopBarHeight + 64; 2572 DiaDlg.UserLeft := ( Screen.width - DiaDlg.width) div 2;2573 DiaDlg.UserTop := ( Screen.height - DiaDlg.height) div 2;2574 NatStatDlg.UserLeft := Screen.width - NatStatDlg.width - 8;2575 NatStatDlg.UserTop := Screen.height - PanelHeight -2572 DiaDlg.UserLeft := (DpiScreen.width - DiaDlg.width) div 2; 2573 DiaDlg.UserTop := (DpiScreen.height - DiaDlg.height) div 2; 2574 NatStatDlg.UserLeft := DpiScreen.width - NatStatDlg.width - 8; 2575 NatStatDlg.UserTop := DpiScreen.height - PanelHeight - 2576 2576 NatStatDlg.height - 8; 2577 2577 if NatStatDlg.UserTop < 8 then … … 3908 3908 UnitStatDlg.Close; 3909 3909 end; 3910 for i := 0 to Screen.FormCount - 1 do3910 for i := 0 to DpiScreen.FormCount - 1 do 3911 3911 if DpiScreen.Forms[i].Visible and (DpiScreen.Forms[i] is TBufferedDrawDlg) then 3912 3912 DpiScreen.Forms[i].Enabled := false; … … 5102 5102 dx := 0; 5103 5103 dy := 0; 5104 if Mouse.CursorPos.y < Screen.height - PanelHeight then5104 if Mouse.CursorPos.y < DpiScreen.height - PanelHeight then 5105 5105 if Mouse.CursorPos.x = 0 then 5106 5106 dx := -speed // scroll left 5107 else if Mouse.CursorPos.x = Screen.width - 1 then5107 else if Mouse.CursorPos.x = DpiScreen.width - 1 then 5108 5108 dx := speed; // scroll right 5109 5109 if Mouse.CursorPos.y = 0 then 5110 5110 dy := -speed // scroll up 5111 else if (Mouse.CursorPos.y = Screen.height - 1) and5111 else if (Mouse.CursorPos.y = DpiScreen.height - 1) and 5112 5112 (Mouse.CursorPos.x >= TerrainBtn.Left + TerrainBtn.width) and 5113 5113 (Mouse.CursorPos.x < xRightPanel + 10 - 8) then … … 5469 5469 if BattleDlg.Left < 0 then 5470 5470 BattleDlg.Left := 0 5471 else if BattleDlg.Left + BattleDlg.width > Screen.width then5472 BattleDlg.Left := Screen.width - BattleDlg.width;5471 else if BattleDlg.Left + BattleDlg.width > DpiScreen.width then 5472 BattleDlg.Left := DpiScreen.width - BattleDlg.width; 5473 5473 BattleDlg.Top := y - BattleDlg.height div 2; 5474 5474 if BattleDlg.Top < 0 then 5475 5475 BattleDlg.Top := 0 5476 else if BattleDlg.Top + BattleDlg.height > Screen.height then5477 BattleDlg.Top := Screen.height - BattleDlg.height;5476 else if BattleDlg.Top + BattleDlg.height > DpiScreen.height then 5477 BattleDlg.Top := DpiScreen.height - BattleDlg.height; 5478 5478 BattleDlg.IsSuicideQuery := false; 5479 5479 BattleDlg.Show; -
branches/highdpi/LocalPlayer/UnitStat.pas
r179 r193 74 74 inherited; 75 75 AgePrepared := -2; 76 TitleHeight := Screen.Height;76 TitleHeight := DpiScreen.Height; 77 77 InitButtons(); 78 78 … … 171 171 else 172 172 begin 173 Left := ( Screen.Width - Width) div 2;174 Top := ( Screen.Height - Height) div 2;173 Left := (DpiScreen.Width - Width) div 2; 174 Top := (DpiScreen.Height - Height) div 2; 175 175 end; 176 176 -
branches/highdpi/Locale.lfm
r178 r193 6 6 Width = 483 7 7 Height = 456 8 Visible = False9 8 Caption = 'LocaleDlg' 10 9 Enabled = True -
branches/highdpi/NoTerm.pas
r179 r193 73 73 procedure TNoTermDlg.FormCreate(Sender: TObject); 74 74 begin 75 Left := Screen.Width - Width - 8;75 Left := DpiScreen.Width - Width - 8; 76 76 Top := 8; 77 77 Caption := Phrases.Lookup('AIT'); -
branches/highdpi/Packages/CevoComponents/BaseWin.pas
r180 r193 500 500 Offscreen := TDpiBitmap.Create; 501 501 Offscreen.PixelFormat := pf24bit; 502 if Screen.Height - yUnused < 480 then503 Offscreen.SetSize( Screen.Width, 480)502 if DpiScreen.Height - yUnused < 480 then 503 Offscreen.SetSize(DpiScreen.Width, 480) 504 504 else 505 Offscreen.SetSize( Screen.Width,Screen.Height - yUnused);505 Offscreen.SetSize(DpiScreen.Width, DpiScreen.Height - yUnused); 506 506 Offscreen.Canvas.FillRect(0, 0, Offscreen.Width, OffScreen.Height); 507 507 Offscreen.Canvas.Brush.Style := bsClear; -
branches/highdpi/Packages/CevoComponents/ScreenTools.pas
r180 r193 410 410 Bitmap.BeginUpdate; 411 411 PixelPtr.Init(Bitmap); 412 for Y := 0 to Bitmap.Height- 1 do begin413 for X := 0 to Bitmap.Width- 1 do begin412 for Y := 0 to ScaleToVcl(Bitmap.Height) - 1 do begin 413 for X := 0 to ScaleToVcl(Bitmap.Width) - 1 do begin 414 414 PixelPtr.Pixel^ := ApplyGammaToPixel(PixelPtr.Pixel^); 415 415 PixelPtr.NextPixel; … … 428 428 SrcPtr.Init(Src); 429 429 DstPtr.Init(Dst); 430 for Y := 0 to S rc.Height- 1 do begin431 for X := 0 to S rc.Width- 1 do begin430 for Y := 0 to ScaleToVcl(Src.Height) - 1 do begin 431 for X := 0 to ScaleToVcl(Src.Width) - 1 do begin 432 432 DstPtr.Pixel^.B := SrcPtr.Pixel^.B; 433 433 DstPtr.Pixel^.G := SrcPtr.Pixel^.B; … … 607 607 PixelPtr: TPixelPointer; 608 608 begin 609 X := ScaleToVcl(X); 610 Y := ScaleToVcl(Y); 611 W := ScaleToVcl(W); 612 H := ScaleToVcl(H); 609 613 Dst.BeginUpdate; 610 614 PixelPtr.Init(Dst, X, Y); … … 630 634 PixelDst: TPixelPointer; 631 635 begin 636 xDst := ScaleToVcl(xDst); 637 yDst := ScaleToVcl(yDst); 638 xSrc := ScaleToVcl(xSrc); 639 ySrc := ScaleToVcl(ySrc); 640 w := ScaleToVcl(w); 641 h := ScaleToVcl(h); 632 642 //Assert(Src.PixelFormat = pf8bit); 633 643 Assert(dst.PixelFormat = pf24bit); … … 642 652 yDst := 0; 643 653 end; 644 if xDst + w > dst.Widththen645 w := dst.Width- xDst;646 if yDst + h > dst.Heightthen647 h := dst.Height- yDst;654 if xDst + w > ScaleToVcl(dst.Width) then 655 w := ScaleToVcl(dst.Width) - xDst; 656 if yDst + h > ScaleToVcl(dst.Height) then 657 h := ScaleToVcl(dst.Height) - yDst; 648 658 if (w < 0) or (h < 0) then 649 659 exit; … … 691 701 SrcPixel, DstPixel: TPixelPointer; 692 702 begin 703 xDst := ScaleToVcl(xDst); 704 yDst := ScaleToVcl(yDst); 705 xSrc := ScaleToVcl(xSrc); 706 ySrc := ScaleToVcl(ySrc); 707 w := ScaleToVcl(w); 708 h := ScaleToVcl(h); 693 709 if xDst < 0 then begin 694 710 w := w + xDst; … … 701 717 yDst := 0; 702 718 end; 703 if xDst + w > dst.Widththen704 w := dst.Width- xDst;705 if yDst + h > dst.Heightthen706 h := dst.Height- yDst;719 if xDst + w > ScaleToVcl(dst.Width) then 720 w := ScaleToVcl(dst.Width) - xDst; 721 if yDst + h > ScaleToVcl(dst.Height) then 722 h := ScaleToVcl(dst.Height) - yDst; 707 723 if (w < 0) or (h < 0) then 708 724 exit; … … 756 772 PixelPtr: TPixelPointer; 757 773 begin 774 X := ScaleToVcl(X); 775 Y := ScaleToVcl(Y); 776 W := ScaleToVcl(W); 777 H := ScaleToVcl(H); 758 778 bmp.BeginUpdate; 759 779 assert(bmp.PixelFormat = pf24bit); … … 892 912 x, y, ch, r: Integer; 893 913 DstPtr: TPixelPointer; 894 begin 914 DpiGlowRange: Integer; 915 begin 916 DpiGlowRange := ScaleToVcl(GlowRange); 917 X0 := ScaleToVcl(X0); 918 Y0 := ScaleToVcl(Y0); 919 Width := ScaleToVcl(Width); 920 Height := ScaleToVcl(Height); 895 921 dst.BeginUpdate; 896 922 DstPtr.Init(dst, x0, y0); 897 for y := - GlowRange + 1 to Height - 1 +GlowRange - 1 do begin898 for x := - GlowRange + 1 to Width - 1 +GlowRange - 1 do begin923 for y := -DpiGlowRange + 1 to Height - 1 + DpiGlowRange - 1 do begin 924 for x := -DpiGlowRange + 1 to Width - 1 + DpiGlowRange - 1 do begin 899 925 DstPtr.SetXY(x, y); 900 926 if x < 0 then … … 924 950 DstPtr.Pixel^.Planes[2 - ch] := 925 951 (DstPtr.Pixel^.Planes[2 - ch] * (r - 1) + (cl shr (8 * ch) and $FF) * 926 ( GlowRange - r)) div (GlowRange - 1);952 (DpiGlowRange - r)) div (DpiGlowRange - 1); 927 953 end; 928 954 end; … … 1559 1585 // 0.8 constant is compensation for Lazarus as size of fonts against Delphi differs 1560 1586 UniFont[section].Size := 1561 Round(Size * Screen.PixelsPerInch / UniFont[section].PixelsPerInch * 0.8);1587 Round(Size * Screen.PixelsPerInch / UniFont[section].PixelsPerInch); 1562 1588 end; 1563 1589 end; -
branches/highdpi/Packages/DpiControls/UDpiControls.pas
r179 r193 28 28 public 29 29 property OnPaint; 30 procedure Paint; override; 31 end; 32 33 { TControlEx } 34 35 TControlEx = class(TControl) 36 public 30 37 property OnMouseDown; 31 38 property OnMouseUp; 32 39 property OnMouseMove; 33 procedure Paint; override;34 40 end; 35 41 … … 189 195 property Parent: TDpiWinControl read FParent write SetParent; 190 196 property BoundsRect: TRect read GetBoundsRect write SetBoundsRect; 197 property Visible: Boolean read GetVisible write SetVisible; 191 198 published 192 199 property ClientHeight: Integer read GetClientHeight write SetClientHeight; … … 197 204 property Width: Integer read FWidth write SetWidth; 198 205 property Height: Integer read FHeight write SetHeight; 199 property Visible: Boolean read GetVisible write SetVisible;200 206 property Caption: string read GetCaption write SetCaption; 201 207 property Enabled: Boolean read GetEnabled write SetEnabled; … … 221 227 TDpiGraphic = class(TPersistent) 222 228 protected 229 FDpi: Integer; 223 230 function GetVclGraphic: TGraphic; virtual; 231 function GetWidth: Integer; virtual; abstract; 232 function GetHeight: Integer; virtual; abstract; 233 procedure SetWidth(Value: Integer); virtual; abstract; 234 procedure SetHeight(Value: Integer); virtual; abstract; 235 procedure ScreenChanged; virtual; 236 procedure SetDpi(AValue: Integer); virtual; 237 function GetDpi: Integer; virtual; 224 238 public 225 procedure LoadFromFile(const Filename: string); 239 constructor Create; 240 procedure LoadFromFile(const Filename: string); virtual; 241 property Width: Integer read GetWidth write SetWidth; 242 property Height: Integer read GetHeight write SetHeight; 243 property Dpi: Integer read GetDpi write SetDpi; 226 244 end; 227 245 … … 260 278 procedure StretchDraw(const DestRect: TRect; SrcGraphic: TDpiGraphic); virtual; 261 279 procedure FrameRect(Rect: TRect); 262 procedure Rectangle(X1, Y1, X2, Y2: Integer); 280 procedure Rectangle(X1, Y1, X2, Y2: Integer); overload; 281 procedure Rectangle(const ARect: TRect); overload; 263 282 function TextWidth(Text: string): Integer; 264 283 function TextHeight(Text: string): Integer; … … 291 310 VclGraphicControl: TGraphicControl; 292 311 FCanvas: TDpiCanvas; 312 function GetOnPaint: TNotifyEvent; 293 313 procedure SetCanvas(AValue: TDpiCanvas); 294 314 procedure PaintHandler(Sender: TObject); 315 procedure SetOnPaint(AValue: TNotifyEvent); 295 316 protected 296 317 procedure Paint; virtual; … … 298 319 function GetVclGraphicControl: TGraphicControl; virtual; 299 320 procedure UpdateVclControl; override; 300 property OnPaint: TNotifyEvent read FOnPaint write FOnPaint; 321 procedure UpdateVclControlPrivate; virtual; 322 property OnPaint: TNotifyEvent read GetOnPaint write SetOnPaint; 301 323 public 302 324 constructor Create(TheOwner: TComponent); override; … … 481 503 destructor Destroy; override; 482 504 published 505 property Visible; 483 506 end; 484 507 … … 523 546 property ExtendedSelect: Boolean read GetExtendedSelect write SetExtendedSelect default true; 524 547 property BorderStyle: TBorderStyle read GetBorderStyle write SetBorderStyle default bsNone; 548 property Visible; 525 549 end; 526 550 … … 556 580 property Kind: TScrollBarKind read GetKind write SetKind; 557 581 property OnChange: TNotifyEvent read GetOnChange write SetOnChange; 582 property Visible; 558 583 end; 559 584 … … 563 588 private 564 589 FCanvas: TDpiCanvas; 590 FWidth: Integer; 591 FHeight: Integer; 565 592 function GetCanvas: TDpiCanvas; 566 function GetHeight: Integer;567 593 function GetPixelFormat: TPixelFormat; 568 594 function GetScanLine(Row: Integer): Pointer; 569 function GetWidth: Integer;570 procedure SetHeight(AValue: Integer);571 595 procedure SetPixelFormat(AValue: TPixelFormat); 572 procedure SetWidth(AValue: Integer);573 596 protected 597 function GetHeight: Integer; override; 598 function GetWidth: Integer; override; 574 599 function GetVclBitmap: TCustomBitmap; virtual; 575 600 function GetVclRasterImage: TRasterImage; override; 601 procedure SetHeight(AValue: Integer); override; 602 procedure SetWidth(AValue: Integer); override; 603 procedure ScreenChanged; override; 576 604 public 577 605 VclBitmap: TBitmap; 578 606 procedure BeginUpdate; 579 607 procedure EndUpdate; 580 procedure SetSize( Width,Height: Integer);608 procedure SetSize(AWidth, AHeight: Integer); 581 609 constructor Create; 582 610 destructor Destroy; override; … … 617 645 property Stretch: Boolean read FStretch write SetStretch; 618 646 property Picture: TDpiPicture read FDpiPicture write SetPicture; 647 property Visible; 619 648 end; 620 649 … … 623 652 TDpiPaintBox = class(TDpiGraphicControl) 624 653 private 625 function GetOnPaint: TNotifyEvent; 626 procedure SetOnPaint(AValue: TNotifyEvent); 654 procedure UpdateVclControlPrivate; override; 627 655 public 628 656 VclPaintBox: TPaintBox; … … 631 659 destructor Destroy; override; 632 660 published 661 property OnPaint; 662 property Visible; 633 663 end; 634 664 … … 666 696 public 667 697 VclJpeg: TJPEGImage; 698 procedure LoadFromFile(const Filename: string); override; 668 699 end; 669 700 … … 676 707 public 677 708 VclPng: TPortableNetworkGraphic; 709 procedure LoadFromFile(const Filename: string); override; 678 710 end; 679 711 … … 709 741 710 742 procedure Register; 711 function DpiBitBlt(DestDC: HDC; X, Y, Width, Height: Integer; SrcDC: HDC; XSrc, YSrc: Integer; Rop: DWORD): Boolean; 743 function DpiBitBlt(DestDC: HDC; X, Y, Width, Height: Integer; SrcDC: HDC; XSrc, YSrc: Integer; Rop: DWORD = SRCCOPY): Boolean; 744 function DpiBitBltCanvas(Dest: TDpiCanvas; X, Y, Width, Height: Integer; Src: TDpiCanvas; XSrc, YSrc: Integer; Rop: DWORD = SRCCOPY): Boolean; 712 745 function DpiCreateRectRgn(X1, Y1, X2, Y2: Integer): HRGN; 713 746 function ScaleToVcl(Value: Integer): Integer; … … 735 768 end; 736 769 770 function DpiBitBltCanvas(Dest: TDpiCanvas; X, Y, Width, Height: Integer; 771 Src: TDpiCanvas; XSrc, YSrc: Integer; Rop: DWORD = SRCCOPY): Boolean; 772 begin 773 Result := DpiBitBlt(Dest.Handle, X, Y, Width, Height, Src.Handle, XSrc, YSrc, Rop); 774 end; 775 737 776 function DpiCreateRectRgn(X1, Y1, X2, Y2: Integer): HRGN; 738 777 begin … … 792 831 793 832 function DpiBitBlt(DestDC: HDC; X, Y, Width, Height: Integer; SrcDC: HDC; XSrc, 794 YSrc: Integer; Rop: DWORD ): Boolean;833 YSrc: Integer; Rop: DWORD = SRCCOPY): Boolean; 795 834 begin 796 835 Result := BitBlt(DestDC, ScaleToVcl(X), ScaleToVcl(Y), ScaleToVcl(Width), … … 995 1034 end; 996 1035 1036 procedure TDpiJpegImage.LoadFromFile(const Filename: string); 1037 var 1038 Bitmap: TJPEGImage; 1039 begin 1040 Bitmap := TJPEGImage.Create; 1041 Bitmap.LoadFromFile(FileName); 1042 Width := ScaleFromVcl(Bitmap.Width); 1043 Height := ScaleFromVcl(Bitmap.Height); 1044 if Self is TDpiBitmap then 1045 TBitmap(GetVclGraphic).Canvas.StretchDraw(Bounds(0, 0, Bitmap.Width, Bitmap.Height), Bitmap) 1046 else raise Exception.Create('Unsupported class ' + Self.ClassName); 1047 Bitmap.Free; 1048 end; 1049 997 1050 { TDpiPortableNetworkGraphic } 998 1051 … … 1006 1059 if not Assigned(VclPng) then VclPng := TPortableNetworkGraphic.Create; 1007 1060 Result := VclPng; 1061 end; 1062 1063 procedure TDpiPortableNetworkGraphic.LoadFromFile(const Filename: string); 1064 var 1065 Bitmap: TPortableNetworkGraphic; 1066 begin 1067 Bitmap := TPortableNetworkGraphic.Create; 1068 Bitmap.LoadFromFile(FileName); 1069 Width := ScaleFromVcl(Bitmap.Width); 1070 Height := ScaleFromVcl(Bitmap.Height); 1071 if Self is TDpiBitmap then 1072 TBitmap(GetVclGraphic).Canvas.StretchDraw(Bounds(0, 0, Bitmap.Width, Bitmap.Height), Bitmap) 1073 else raise Exception.Create('Unsupported class ' + Self.ClassName); 1074 Bitmap.Free; 1008 1075 end; 1009 1076 … … 1157 1224 end; 1158 1225 1226 procedure TDpiGraphic.ScreenChanged; 1227 begin 1228 end; 1229 1230 procedure TDpiGraphic.SetDpi(AValue: Integer); 1231 begin 1232 FDpi := AValue; 1233 ScreenChanged; 1234 end; 1235 1236 function TDpiGraphic.GetDpi: Integer; 1237 begin 1238 Result := FDpi; 1239 end; 1240 1241 constructor TDpiGraphic.Create; 1242 begin 1243 Dpi := DpiScreen.Dpi; 1244 end; 1245 1159 1246 procedure TDpiGraphic.LoadFromFile(const Filename: string); 1160 begin 1161 GetVclGraphic.LoadFromFile(FileName); 1247 var 1248 Bitmap: TBitmap; 1249 begin 1250 Bitmap := TBitmap.Create; 1251 Bitmap.LoadFromFile(FileName); 1252 Width := ScaleFromVcl(Bitmap.Width); 1253 Height := ScaleFromVcl(Bitmap.Height); 1254 if Self is TDpiBitmap then 1255 TBitmap(GetVclGraphic).Canvas.StretchDraw(Bounds(0, 0, Bitmap.Width, Bitmap.Height), Bitmap) 1256 else raise Exception.Create('Unsupported class ' + Self.ClassName); 1257 Bitmap.Free; 1162 1258 end; 1163 1259 … … 1166 1262 function TDpiBitmap.GetHeight: Integer; 1167 1263 begin 1168 Result := ScaleFromVcl(GetVclBitmap.Height);1264 Result := FHeight; 1169 1265 end; 1170 1266 … … 1190 1286 function TDpiBitmap.GetWidth: Integer; 1191 1287 begin 1192 Result := ScaleFromVcl(GetVclBitmap.Width);1288 Result := FWidth; 1193 1289 end; 1194 1290 1195 1291 procedure TDpiBitmap.SetHeight(AValue: Integer); 1196 1292 begin 1293 FHeight := AValue; 1197 1294 GetVclBitmap.Height := ScaleToVcl(AValue); 1198 1295 end; … … 1205 1302 procedure TDpiBitmap.SetWidth(AValue: Integer); 1206 1303 begin 1304 FWidth := AValue; 1207 1305 GetVclBitmap.Width := ScaleToVcl(AValue); 1306 end; 1307 1308 procedure TDpiBitmap.ScreenChanged; 1309 var 1310 Bitmap: TBitmap; 1311 NewWidth: Integer; 1312 NewHeight: Integer; 1313 begin 1314 NewWidth := ScaleToVcl(Width); 1315 NewHeight := ScaleToVcl(Height); 1316 if Assigned(VclBitmap) and ((NewWidth <> VclBitmap.Width) or (NewHeight <> VclBitmap.Height)) then begin 1317 // Rescale bitmap to new size 1318 Bitmap := TBitmap.Create; 1319 Bitmap.SetSize(NewWidth, NewHeight); 1320 Bitmap.PixelFormat := VclBitmap.PixelFormat; 1321 Bitmap.Canvas.StretchDraw(Bounds(0, 0, NewWidth, NewHeight), VclBitmap); 1322 VclBitmap.Free; 1323 VclBitmap := Bitmap; 1324 Canvas.VclCanvas := VclBitmap.Canvas; 1325 end; 1208 1326 end; 1209 1327 … … 1227 1345 end; 1228 1346 1229 procedure TDpiBitmap.SetSize(Width, Height: Integer); 1230 begin 1231 GetVclBitmap.SetSize(ScaleToVcl(Width), ScaleToVcl(Height)); 1347 procedure TDpiBitmap.SetSize(AWidth, AHeight: Integer); 1348 begin 1349 FWidth := AWidth; 1350 FHeight := AHeight; 1351 GetVclBitmap.SetSize(ScaleToVcl(AWidth), ScaleToVcl(AHeight)); 1232 1352 end; 1233 1353 … … 1372 1492 { TDpiPaintBox } 1373 1493 1374 function TDpiPaintBox.GetOnPaint: TNotifyEvent; 1375 begin 1376 Result := VclPaintBox.OnPaint; 1377 end; 1378 1379 procedure TDpiPaintBox.SetOnPaint(AValue: TNotifyEvent); 1380 begin 1381 VclPaintBox.OnPaint := AValue; 1494 procedure TDpiPaintBox.UpdateVclControlPrivate; 1495 begin 1496 VclPaintBox.OnPaint := @PaintHandler; 1497 VclPaintBox.OnMouseDown := @MouseDownHandler; 1498 VclPaintBox.OnMouseUp := @MouseUpHandler; 1499 VclPaintBox.OnMouseMove := @MouseMoveHandler; 1382 1500 end; 1383 1501 … … 1416 1534 end; 1417 1535 1418 1419 1536 { TDpiCanvas } 1420 1537 … … 1471 1588 1472 1589 procedure TDpiCanvas.SetPixel(X, Y: Integer; AValue: TColor); 1473 begin 1590 var 1591 BrushStyle: TBrushStyle; 1592 BrushColor: TColor; 1593 begin 1594 { BrushStyle := GetVclCanvas.Brush.Style; 1595 BrushColor := GetVclCanvas.Brush.Color; 1596 GetVclCanvas.Brush.Color := AValue; 1597 GetVclCanvas.Brush.Style := bsClear; 1598 GetVclCanvas.FillRect(ScaleToVcl(X), ScaleToVcl(Y), ScaleToVcl(X + 1) - 1, ScaleToVcl(Y + 1) - 1); 1599 GetVclCanvas.Brush.Style := BrushStyle; 1600 GetVclCanvas.Brush.Color := BrushColor; 1601 } 1474 1602 GetVclCanvas.Pixels[ScaleToVcl(X), ScaleToVcl(Y)] := AValue; 1475 1603 end; … … 1497 1625 end; 1498 1626 1627 procedure TDpiCanvas.Rectangle(const ARect: TRect); 1628 begin 1629 Rectangle(ARect.Left, ARect.Top, ARect.Right, ARect.Bottom); 1630 end; 1631 1499 1632 function TDpiCanvas.TextWidth(Text: string): Integer; 1500 1633 begin … … 1550 1683 Source: TRect); 1551 1684 begin 1552 GetVclCanvas.CopyRect(Dest, SrcCanvas.VclCanvas, S ource);1685 GetVclCanvas.CopyRect(Dest, SrcCanvas.VclCanvas, ScaleRectToVcl(Source)); 1553 1686 end; 1554 1687 … … 1591 1724 begin 1592 1725 if not Assigned(VclGraphicControl) then begin 1593 VclGraphicControl := TGraphicControlEx.Create(nil); 1594 (VclGraphicControl as TGraphicControlEx).OnPaint := @PaintHandler; 1726 VclGraphicControl := TGraphicControl.Create(nil); 1595 1727 end; 1596 1728 Result := VclGraphicControl; … … 1600 1732 begin 1601 1733 inherited; 1602 (GetVclGraphicControl as TGraphicControlEx).OnMouseDown := @MouseDownHandler; 1603 (GetVclGraphicControl as TGraphicControlEx).OnMouseUp := @MouseUpHandler; 1604 (GetVclGraphicControl as TGraphicControlEx).OnMouseMove := @MouseMoveHandler; 1734 UpdateVclControlPrivate; 1735 end; 1736 1737 procedure TDpiGraphicControl.UpdateVclControlPrivate; 1738 begin 1739 TGraphicControlEx(GetVclGraphicControl).OnPaint := @PaintHandler; 1740 TControlEx(GetVclControl).OnMouseDown := @MouseDownHandler; 1741 TControlEx(GetVclControl).OnMouseUp := @MouseUpHandler; 1742 TControlEx(GetVclControl).OnMouseMove := @MouseMoveHandler; 1743 // Some VCL component event are not accessible on TGraphicControl level. 1744 // Delegate this responsibility up 1745 { 1746 GetVclGraphicControl.OnPaint := @PaintHandler; 1747 GetVclControl.OnMouseDown := @MouseDownHandler; 1748 GetVclControl.OnMouseUp := @MouseUpHandler; 1749 GetVclControl.OnMouseMove := @MouseMoveHandler; 1750 } 1751 // raise Exception.Create('Missing inicialization of private fields for ' + ClassName); 1752 end; 1753 1754 function TDpiGraphicControl.GetOnPaint: TNotifyEvent; 1755 begin 1756 Result := FOnPaint; 1757 end; 1758 1759 procedure TDpiGraphicControl.SetOnPaint(AValue: TNotifyEvent); 1760 begin 1761 FOnPaint := AValue; 1605 1762 end; 1606 1763 … … 1906 2063 Forms := TDpiForms.Create; 1907 2064 Forms.FreeObjects := False; 1908 Dpi := 1 44;2065 Dpi := 150; 1909 2066 end; 1910 2067 … … 1914 2071 inherited Destroy; 1915 2072 end; 1916 1917 { TDpiWinControl }1918 1919 2073 1920 2074 { TDpiButton } … … 2513 2667 begin 2514 2668 if not Assigned(VclForm) then begin 2515 VclForm := TFormEx.Create (nil);2669 VclForm := TFormEx.CreateNew(nil); 2516 2670 (VclForm as TFormEx).OnMessage := @FormMessageHandler; 2517 2671 //VclForm := TForm.Create(nil); -
branches/highdpi/Start.lfm
r179 r193 6 6 Width = 556 7 7 Height = 326 8 Visible = False9 8 Caption = 'C-evo' 10 9 Enabled = True -
branches/highdpi/Start.pas
r179 r193 256 256 end; // default AI not found, use any 257 257 258 DirectDlg.Left := ( Screen.Width - DirectDlg.Width) div 2;259 DirectDlg.Top := ( Screen.Height - DirectDlg.Height) div 2;258 DirectDlg.Left := (DpiScreen.Width - DirectDlg.Width) div 2; 259 DirectDlg.Top := (DpiScreen.Height - DirectDlg.Height) div 2; 260 260 261 261 if FullScreen then 262 262 begin 263 Location := Point(( Screen.Width - 800) * 3 div 8,264 Screen.Height - Height - (Screen.Height - 600) div 3);263 Location := Point((DpiScreen.Width - 800) * 3 div 8, 264 DpiScreen.Height - Height - (DpiScreen.Height - 600) div 3); 265 265 Left := Location.X; 266 266 Top := Location.Y; … … 279 279 else 280 280 begin 281 Left := ( Screen.Width - Width) div 2;282 Top := ( Screen.Height - Height) div 2;281 Left := (DpiScreen.Width - Width) div 2; 282 Top := (DpiScreen.Height - Height) div 2; 283 283 end; 284 284 … … 611 611 h := ClientHeight - ActionBottomBorder - 612 612 (yAction + SelectedAction * ActionPitch - 8); 613 BitBltCanvas(LogoBuffer.Canvas, 0, 0, w, h, Canvas, 613 //BitBltCanvas(LogoBuffer.Canvas, 0, 0, w, h, Canvas, 614 // ActionSideBorder + i * wBuffer, yAction + SelectedAction * ActionPitch 615 // - 8, SRCCOPY); 616 BitBlt(LogoBuffer.Canvas.Handle, 0, 0, w, h, Canvas.Handle, 614 617 ActionSideBorder + i * wBuffer, yAction + SelectedAction * ActionPitch 615 618 - 8, SRCCOPY); … … 879 882 EmptyPicture.BeginUpdate; 880 883 PicturePixel.Init(EmptyPicture); 881 for y := 0 to 63do begin882 for x := 0 to 64- 1 do begin884 for y := 0 to ScaleToVcl(64) - 1 do begin 885 for x := 0 to ScaleToVcl(64) - 1 do begin 883 886 PicturePixel.Pixel^.B := Max(PicturePixel.Pixel^.B - 28, 0); 884 887 PicturePixel.Pixel^.G := Max(PicturePixel.Pixel^.G - 28, 0); … … 1049 1052 Mini.BeginUpdate; 1050 1053 MiniPixel.Init(Mini); 1051 for y := 0 to MiniHeight- 1 do begin1052 for x := 0 to MiniWidth- 1 do begin1054 for y := 0 to ScaleToVcl(MiniHeight) - 1 do begin 1055 for x := 0 to ScaleToVcl(MiniWidth) - 1 do begin 1053 1056 for i := 0 to 1 do begin 1054 xm := (x * 2 + i + y and 1) mod ( MiniWidth* 2);1057 xm := (x * 2 + i + y and 1) mod (ScaleToVcl(MiniWidth) * 2); 1055 1058 MiniPixel.SetX(xm); 1056 1059 cm := MiniColors
Note:
See TracChangeset
for help on using the changeset viewer.