Changeset 465 for branches/highdpi/Packages/DpiControls/UDpiControls.pas
- Timestamp:
- Nov 30, 2023, 10:16:14 PM (12 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/highdpi/Packages/DpiControls/UDpiControls.pas
r463 r465 1 1 unit UDpiControls; 2 3 {$mode objfpc}{$H+}4 2 5 3 interface … … 7 5 uses 8 6 {$IFDEF WINDOWS}Windows, {$ENDIF}Classes, SysUtils, LCLProc, LResources, Forms, 9 FormEditingIntf, ProjectIntf, Controls, StdCtrls, fgl, Graphics, ComCtrls,10 ExtCtrls, LCLType, GraphType, Types, CustApp, LMessages, LCLIntf, Menus, Math,11 UPixelPointer2, Grids, Spin;7 Generics.Collections, FormEditingIntf, ProjectIntf, Controls, StdCtrls, Graphics, 8 ComCtrls, ExtCtrls, LCLType, GraphType, Types, CustApp, LMessages, LCLIntf, 9 Menus, Math, UPixelPointer2, Grids, Spin; 12 10 13 11 const 14 FixedDpi = -1;12 FixedDpi = 192; 15 13 16 14 type … … 89 87 procedure SetName(AValue: string); 90 88 procedure SetNativeFont(AValue: TFont); 91 procedure SetOnChange(AValue: TNotifyEvent);92 89 procedure SetPixelsPerInch(AValue: Integer); 93 90 procedure SetSize(AValue: Integer); … … 114 111 property PixelsPerInch: Integer read GetPixelsPerInch write SetPixelsPerInch; 115 112 property Height: Integer read GetHeight write SetHeight default 0; 116 property OnChange: TNotifyEvent read FOnChange write SetOnChange;113 property OnChange: TNotifyEvent read FOnChange write FOnChange; 117 114 end; 118 115 … … 189 186 procedure SetFont(AValue: TDpiFont); 190 187 procedure SetHint(AValue: string); 191 procedure SetOnChangeBounds(AValue: TNotifyEvent);192 188 procedure SetOnClick(AValue: TNotifyEvent); 193 189 procedure SetOnDblClick(AValue: TNotifyEvent); 194 procedure SetOnResize(AValue: TNotifyEvent);195 190 procedure SetParentFont(AValue: Boolean); 196 191 procedure SetShowHint(AValue: Boolean); … … 275 270 property Constraints: TDpiSizeConstraints read FConstraints write FConstraints; 276 271 property Cursor: TCursor read GetCursor write SetCursor default crDefault; 277 property OnResize: TNotifyEvent read FOnResize write SetOnResize;278 property OnChangeBounds: TNotifyEvent read FOnChangeBounds write SetOnChangeBounds;272 property OnResize: TNotifyEvent read FOnResize write FOnResize; 273 property OnChangeBounds: TNotifyEvent read FOnChangeBounds write FOnChangeBounds; 279 274 property OnClick: TNotifyEvent read GetOnClick write SetOnClick; 280 275 property OnDblClick: TNotifyEvent read GetOnDblClick write SetOnDblClick; … … 285 280 end; 286 281 287 TDpiControls = specialize TFPGObjectList<TDpiControl>;282 TDpiControls = TObjectList<TDpiControl>; 288 283 289 284 { TDpiControlBorderSpacing } … … 446 441 public 447 442 property NativeCanvas: TCanvas read FNativeCanvas write SetNativeCanvas; 448 procedure RoundRect(const Rect: TRect; RX, RY: Integer); 443 procedure RoundRect(const Rect: TRect; RX, RY: Integer); overload; 449 444 procedure RoundRect(X1, Y1, X2, Y2: Integer; RX,RY: Integer); overload; virtual; 450 445 procedure Polygon(const Points: array of TPoint; Winding: Boolean; 451 StartIndex: Integer = 0; NumPts: Integer = -1); 452 procedure Polygon(Points: PPoint; NumPts: Integer; Winding: Boolean = False); virtual; 453 procedure Polygon(const Points: array of TPoint); 446 StartIndex: Integer = 0; NumPts: Integer = -1); overload; 447 procedure Polygon(Points: PPoint; NumPts: Integer; Winding: Boolean = False); virtual; overload; 448 procedure Polygon(const Points: array of TPoint); overload; 454 449 procedure PolyBezier(const Points: array of TPoint; 455 Filled: Boolean = False; Continuous: boolean = True); 450 Filled: Boolean = False; Continuous: boolean = True); overload; 456 451 procedure PolyBezier(Points: PPoint; NumPts: Integer; 457 Filled: Boolean = False; Continuous: Boolean = True); virtual; 458 procedure Polyline(const Points: array of TPoint); 459 procedure Polyline(Points: PPoint; NumPts: Integer); virtual; 460 procedure Ellipse(x1, y1, x2, y2: Integer); virtual; 461 procedure Ellipse(const ARect: TRect); virtual; 462 procedure StretchDraw(const DestRect: TRect; SrcGraphic: TGraphic); virtual; 452 Filled: Boolean = False; Continuous: Boolean = True); virtual; overload; 453 procedure Polyline(const Points: array of TPoint); overload; 454 procedure Polyline(Points: PPoint; NumPts: Integer); virtual; overload; 455 procedure Ellipse(x1, y1, x2, y2: Integer); virtual; overload; 456 procedure Ellipse(const ARect: TRect); virtual; overload; 457 procedure StretchDraw(const DestRect: TRect; SrcGraphic: TGraphic); virtual; overload; 458 procedure StretchDraw(const DestRect: TRect; SrcGraphic: TDpiGraphic); virtual; overload; 463 459 procedure Pie(EllipseX1, EllipseY1, EllipseX2, EllipseY2, 464 460 StartX, StartY, EndX, EndY: Integer); virtual; 465 procedure StretchDraw(const DestRect: TRect; SrcGraphic: TDpiGraphic); virtual;466 461 procedure FrameRect(Rect: TRect); 467 462 procedure Rectangle(X1, Y1, X2, Y2: Integer); overload; … … 475 470 procedure LineTo(X, Y: Integer); 476 471 procedure Line(const p1, p2: TPoint); 477 procedure FillRect(const ARect: TRect); virtual; 478 procedure FillRect(X1, Y1, X2, Y2: Integer); 472 procedure FillRect(const ARect: TRect); virtual; overload; 473 procedure FillRect(X1, Y1, X2, Y2: Integer); overload; 479 474 procedure Draw(X, Y: Integer; Source: TDpiGraphic); 480 475 procedure CopyRect(Dest: TRect; SrcCanvas: TDpiCanvas; Source: TRect); … … 708 703 end; 709 704 710 TDpiForms = specialize TFPGObjectList<TDpiForm>;705 TDpiForms = TObjectList<TDpiForm>; 711 706 712 707 { TDpiEdit } … … 1242 1237 procedure UpdateScreen; 1243 1238 procedure UpdateActiveFormFromNativeScreen; 1244 function DisableForms(SkipForm: TDpiForm; DisabledList: TList = nil):TList;1245 procedure EnableForms(var AFormList: TList);1239 function DisableForms(SkipForm: TDpiForm; DisabledList: Classes.TList = nil): Classes.TList; 1240 procedure EnableForms(var AFormList: Classes.TList); 1246 1241 property FormCount: Integer read GetFormCount; 1247 1242 property Forms[Index: Integer]: TDpiForm read GetForms; … … 1419 1414 public 1420 1415 NativePopupMenu: TPopupMenu; 1421 procedure PopUp; 1422 procedure PopUp(X, Y: Integer); virtual; 1416 procedure PopUp; overload; 1417 procedure PopUp(X, Y: Integer); virtual; overload; 1423 1418 constructor Create(AOwner: TComponent); override; 1424 1419 destructor Destroy; override; … … 2310 2305 if not Assigned(NativeListView) then begin 2311 2306 NativeListView := TListView.Create(nil); 2312 NativeListView.OnCustomDrawItem := @DoCustomDrawItem;2307 NativeListView.OnCustomDrawItem := DoCustomDrawItem; 2313 2308 end; 2314 2309 Result := NativeListView; … … 2781 2776 NativeMenuItem := TMenuItem.Create(nil); 2782 2777 NativeMenuItem.Name := 'Native' + Name; 2783 NativeMenuItem.OnClick := @OnClickHandler;2778 NativeMenuItem.OnClick := OnClickHandler; 2784 2779 end; 2785 2780 Result := NativeMenuItem; … … 3084 3079 begin 3085 3080 if (FMainForm = nil) 3086 and (FCreatingForm =AForm)3081 and (FCreatingForm = AForm) 3087 3082 //and (not (AppDestroying in FFlags)) 3088 3083 and not (AForm.FormStyle in [fsMDIChild, fsSplash]) … … 3096 3091 var 3097 3092 Instance: TComponent; 3098 ok: Boolean;3093 Ok: Boolean; 3099 3094 AForm: TDpiForm; 3100 3095 begin … … 3105 3100 TComponent(Reference) := Instance; 3106 3101 3107 ok := False;3102 Ok := False; 3108 3103 try 3109 3104 if (FCreatingForm = nil) and (Instance is TDpiForm) then 3110 3105 FCreatingForm := TDpiForm(Instance); 3111 3106 Instance.Create(Self); 3112 ok := true;3107 Ok := true; 3113 3108 finally 3114 if not ok then begin3109 if not Ok then begin 3115 3110 TComponent(Reference) := nil; 3116 3111 if FCreatingForm = Instance then … … 4103 4098 begin 4104 4099 inherited; 4105 TGraphicControlEx(GetNativeGraphicControl).OnPaint := @PaintHandler;4100 TGraphicControlEx(GetNativeGraphicControl).OnPaint := PaintHandler; 4106 4101 end; 4107 4102 … … 4196 4191 begin 4197 4192 Result := NativeFont; 4198 end;4199 4200 procedure TDpiFont.SetOnChange(AValue: TNotifyEvent);4201 begin4202 if FOnChange = AValue then Exit;4203 FOnChange := AValue;4204 4193 end; 4205 4194 … … 4409 4398 begin 4410 4399 inherited; 4411 GetNativeWinControl.OnKeyDown := @KeyDownHandler;4400 GetNativeWinControl.OnKeyDown := KeyDownHandler; 4412 4401 end; 4413 4402 … … 4448 4437 begin 4449 4438 Controls := TDpiControls.Create; 4450 Controls. FreeObjects := False;4439 Controls.OwnsObjects := False; 4451 4440 inherited; 4452 4441 end; … … 4557 4546 end; 4558 4547 4559 function TDpiScreen.DisableForms(SkipForm: TDpiForm; DisabledList: TList4560 ): TList;4548 function TDpiScreen.DisableForms(SkipForm: TDpiForm; DisabledList: Classes.TList 4549 ): Classes.TList; 4561 4550 begin 4562 4551 Result := Screen.DisableForms(SkipForm.GetNativeForm, DisabledList); 4563 4552 end; 4564 4553 4565 procedure TDpiScreen.EnableForms(var AFormList: TList);4554 procedure TDpiScreen.EnableForms(var AFormList: Classes.TList); 4566 4555 begin 4567 4556 Screen.EnableForms(AFormList); … … 4571 4560 begin 4572 4561 FForms := TDpiForms.Create; 4573 FForms. FreeObjects := False;4562 FForms.OwnsObjects := False; 4574 4563 FPrevActiveForms := TDpiForms.Create; 4575 FPrevActiveForms. FreeObjects := False;4564 FPrevActiveForms.OwnsObjects := False; 4576 4565 // Screen.PixelsPerInch is not initialized at this point 4577 4566 Dpi := 96; … … 4651 4640 begin 4652 4641 Font.NativeFont := GetNativeControl.Font; 4653 GetNativeControl.OnResize := @NativeFormResize;4654 GetNativeControl.OnChangeBounds := @NativeChangeBounds;4655 TControlEx(GetNativeControl).OnMouseDown := @MouseDownHandler;4656 TControlEx(GetNativeControl).OnMouseUp := @MouseUpHandler;4657 TControlEx(GetNativeControl).OnMouseMove := @MouseMoveHandler;4658 TControlEx(GetNativeControl).OnMouseEnter := @MouseEnterHandler;4659 TControlEx(GetNativeControl).OnMouseLeave := @MouseLeaveHandler;4660 TControlEx(GetNativeControl).OnMouseWheel := @MouseWheelHandler;4642 GetNativeControl.OnResize := NativeFormResize; 4643 GetNativeControl.OnChangeBounds := NativeChangeBounds; 4644 TControlEx(GetNativeControl).OnMouseDown := MouseDownHandler; 4645 TControlEx(GetNativeControl).OnMouseUp := MouseUpHandler; 4646 TControlEx(GetNativeControl).OnMouseMove := MouseMoveHandler; 4647 TControlEx(GetNativeControl).OnMouseEnter := MouseEnterHandler; 4648 TControlEx(GetNativeControl).OnMouseLeave := MouseLeaveHandler; 4649 TControlEx(GetNativeControl).OnMouseWheel := MouseWheelHandler; 4661 4650 end; 4662 4651 … … 4830 4819 inherited; 4831 4820 FFont := TDpiFont.Create; 4832 FFont.OnChange := @FontChanged;4821 FFont.OnChange := FontChanged; 4833 4822 FConstraints := TDpiSizeConstraints.Create; 4834 4823 if Assigned(TheOwner) and (TheOwner is TDpiWinControl) then … … 5031 5020 end; 5032 5021 5033 procedure TDpiControl.SetOnChangeBounds(AValue: TNotifyEvent);5034 begin5035 if FOnChangeBounds = AValue then Exit;5036 FOnChangeBounds := AValue;5037 end;5038 5039 5022 procedure TDpiControl.SetOnClick(AValue: TNotifyEvent); 5040 5023 begin … … 5045 5028 begin 5046 5029 TControlEx(GetNativeControl).OnDblClick := AValue; 5047 end;5048 5049 procedure TDpiControl.SetOnResize(AValue: TNotifyEvent);5050 begin5051 if FOnResize = AValue then Exit;5052 FOnResize := AValue;5053 5030 end; 5054 5031 … … 5411 5388 if not Assigned(NativeForm) then begin 5412 5389 NativeForm := TFormEx.CreateNew(nil); 5413 (NativeForm as TFormEx).OnMessage := @FormMessageHandler;5390 (NativeForm as TFormEx).OnMessage := FormMessageHandler; 5414 5391 //NativeForm := TForm.Create(nil); 5415 5392 end; … … 5420 5397 begin 5421 5398 inherited; 5422 GetNativeForm.OnActivate := @ActivateHandler;5423 GetNativeForm.OnDeactivate := @DeactivateHandler;5424 GetNativeForm.OnClose := @CloseHandler;5425 GetNativeForm.OnCloseQuery := @CloseQueryHandler;5399 GetNativeForm.OnActivate := ActivateHandler; 5400 GetNativeForm.OnDeactivate := DeactivateHandler; 5401 GetNativeForm.OnClose := CloseHandler; 5402 GetNativeForm.OnCloseQuery := CloseQueryHandler; 5426 5403 GetNativeForm.Name := Name + 'Native'; 5427 5404 end;
Note:
See TracChangeset
for help on using the changeset viewer.