Changeset 253
- Timestamp:
- May 23, 2020, 12:47:45 AM (4 years ago)
- Location:
- branches/highdpi
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/highdpi/Inp.lfm
r246 r253 28 28 Caption = '' 29 29 end 30 object EInput: T Edit30 object EInput: TDpiEdit 31 31 Left = 16 32 32 Top = 40 -
branches/highdpi/Inp.pas
r210 r253 12 12 TInputDlg = class(TDrawDlg) 13 13 OKBtn: TButtonA; 14 EInput: T Edit;14 EInput: TDpiEdit; 15 15 procedure OKBtnClick(Sender: TObject); 16 16 procedure FormPaint(Sender: TObject); -
branches/highdpi/LocalPlayer/MessgEx.lfm
r246 r253 61 61 ButtonIndex = 0 62 62 end 63 object EInput: T Edit63 object EInput: TDpiEdit 64 64 Left = 125 65 65 Top = 64 -
branches/highdpi/LocalPlayer/MessgEx.pas
r246 r253 15 15 Button3: TButtonA; 16 16 RemoveBtn: TButtonB; 17 EInput: T Edit;17 EInput: TDpiEdit; 18 18 procedure FormCreate(Sender: TObject); 19 19 procedure FormPaint(Sender: TObject); -
branches/highdpi/Packages/DpiControls/UDpiControls.pas
r252 r253 41 41 property OnMouseLeave; 42 42 property OnMouseEnter; 43 property ParentFont; 44 end; 45 46 TWinControlEx = class(TWinControl) 47 public 48 property BorderStyle; 43 49 end; 44 50 … … 150 156 function GetHint: string; 151 157 function GetOnClick: TNotifyEvent; 158 function GetParentFont: Boolean; 152 159 function GetShowHint: Boolean; 153 160 function GetVisible: Boolean; … … 166 173 procedure SetOnClick(AValue: TNotifyEvent); 167 174 procedure SetOnResize(AValue: TNotifyEvent); 175 procedure SetParentFont(AValue: Boolean); 168 176 procedure SetShowHint(AValue: Boolean); 169 177 procedure NativeFormResize(Sender: TObject); … … 181 189 procedure MouseEnterHandler(Sender: TObject); virtual; 182 190 protected 191 function GetText: TCaption; virtual; 192 procedure SetText(AValue: TCaption); virtual; 183 193 procedure UpdateBounds; virtual; 184 194 procedure FontChanged(Sender: TObject); virtual; … … 200 210 procedure MouseLeave; virtual; 201 211 procedure MouseEnter; virtual; 212 property Text: TCaption read GetText write SetText; 213 property ParentFont: Boolean read GetParentFont write SetParentFont default True; 202 214 public 203 215 function ScreenToClient(const APoint: TPoint): TPoint; virtual; … … 359 371 TDpiWinControl = class(TDpiControl) 360 372 private 373 function GetBorderStyle: TBorderStyle; 361 374 function GetHandle: HWND; 362 375 function GetOnKeyDown: TKeyEvent; … … 365 378 function GetTabOrder: TTabOrder; 366 379 function GetTabStop: Boolean; 380 procedure SetBorderStyle(AValue: TBorderStyle); 367 381 procedure SetHandle(AValue: HWND); 368 382 procedure SetOnKeyDown(AValue: TKeyEvent); … … 374 388 function GetNativeControl: TControl; override; 375 389 function GetNativeWinControl: TWinControl; virtual; 390 property BorderStyle: TBorderStyle read GetBorderStyle write SetBorderStyle default bsNone; 376 391 public 377 392 Controls: TDpiControls; … … 527 542 TDpiForms = specialize TFPGObjectList<TDpiForm>; 528 543 544 { TDpiEdit } 545 546 TDpiEdit = class(TDpiWinControl) 547 private 548 FText: string; 549 function GetSelLength: Integer; 550 function GetSelStart: Integer; 551 procedure SetSelLength(AValue: Integer); 552 procedure SetSelStart(AValue: Integer); 553 protected 554 function GetNativeWinControl: TWinControl; override; 555 function GetNativeEdit: TEdit; virtual; 556 function GetText: TCaption; override; 557 procedure SetText(AValue: TCaption); override; 558 public 559 NativeEdit: TEdit; 560 property SelLength: Integer read GetSelLength write SetSelLength; 561 property SelStart: Integer read GetSelStart write SetSelStart; 562 published 563 property Text; 564 property BorderStyle default bsSingle; 565 property ParentFont; 566 end; 567 529 568 { TDpiButton } 530 569 … … 911 950 function ScaleRectToNative(Value: TRect): TRect; 912 951 function ScaleRectFromNative(Value: TRect): TRect; 952 function ScaleFloatToNative(Value: Double): Double; 953 function ScaleFloatFromNative(Value: Double): Double; 913 954 914 955 … … 928 969 RegisterProjectFileDescriptor(DpiFormFileDesc); 929 970 RegisterComponents('DpiControls', [TDpiButton, TDpiImage, TDpiPaintBox, 930 TDpiListBox, TDpiPopupMenu ]);971 TDpiListBox, TDpiPopupMenu, TDpiEdit]); 931 972 end; 932 973 … … 1015 1056 end; 1016 1057 1058 function ScaleFloatToNative(Value: Double): Double; 1059 begin 1060 Result := Value * DpiScreen.Dpi / 96; 1061 end; 1062 1063 function ScaleFloatFromNative(Value: Double): Double; 1064 begin 1065 Result := Value * 96 / DpiScreen.Dpi; 1066 end; 1067 1017 1068 function DpiBitBlt(DestDC: HDC; X, Y, Width, Height: Integer; SrcDC: HDC; XSrc, 1018 1069 YSrc: Integer; Rop: DWORD = SRCCOPY): Boolean; … … 1028 1079 ScaleToNative(XSrc), ScaleToNative(YSrc), Rop); 1029 1080 {$ENDIF} 1081 end; 1082 1083 { TDpiEdit } 1084 1085 function TDpiEdit.GetText: TCaption; 1086 begin 1087 Result := FText; 1088 end; 1089 1090 procedure TDpiEdit.SetText(AValue: TCaption); 1091 begin 1092 FText := AValue; 1093 GetNativeEdit.Text := AValue; 1094 end; 1095 1096 function TDpiEdit.GetSelLength: Integer; 1097 begin 1098 Result := GetNativeEdit.SelLength; 1099 end; 1100 1101 function TDpiEdit.GetSelStart: Integer; 1102 begin 1103 Result := GetNativeEdit.SelStart; 1104 end; 1105 1106 procedure TDpiEdit.SetSelLength(AValue: Integer); 1107 begin 1108 GetNativeEdit.SelLength := AValue; 1109 end; 1110 1111 procedure TDpiEdit.SetSelStart(AValue: Integer); 1112 begin 1113 GetNativeEdit.SelStart := AValue; 1114 end; 1115 1116 function TDpiEdit.GetNativeWinControl: TWinControl; 1117 begin 1118 Result := GetNativeEdit; 1119 end; 1120 1121 function TDpiEdit.GetNativeEdit: TEdit; 1122 begin 1123 if not Assigned(NativeEdit) then NativeEdit := TEdit.Create(nil); 1124 Result := NativeEdit; 1030 1125 end; 1031 1126 … … 2437 2532 { TDpiWinControl } 2438 2533 2534 function TDpiWinControl.GetBorderStyle: TBorderStyle; 2535 begin 2536 Result := TWinControlEx(GetNativeWinControl).BorderStyle; 2537 end; 2538 2439 2539 function TDpiWinControl.GetHandle: HWND; 2440 2540 begin … … 2465 2565 begin 2466 2566 Result := GetNativeWinControl.TabStop; 2567 end; 2568 2569 procedure TDpiWinControl.SetBorderStyle(AValue: TBorderStyle); 2570 begin 2571 TWinControlEx(GetNativeWinControl).BorderStyle := AValue; 2467 2572 end; 2468 2573 … … 2632 2737 procedure TDpiScreen.UpdateScreen; 2633 2738 begin 2739 //Dpi := 96 * 2; //Screen.PixelsPerInch; 2634 2740 Dpi := Screen.PixelsPerInch; 2635 2741 end; … … 2745 2851 end; 2746 2852 2853 procedure TDpiControl.SetText(AValue: TCaption); 2854 begin 2855 2856 end; 2857 2747 2858 procedure TDpiControl.MouseDown(Button: TMouseButton; Shift: TShiftState; X, 2748 2859 Y: Integer); … … 2952 3063 end; 2953 3064 3065 function TDpiControl.GetParentFont: Boolean; 3066 begin 3067 Result := TControlEx(GetNativeControl).ParentFont; 3068 end; 3069 2954 3070 function TDpiControl.GetShowHint: Boolean; 2955 3071 begin 2956 3072 Result := GetNativeControl.ShowHint; 3073 end; 3074 3075 function TDpiControl.GetText: TCaption; 3076 begin 3077 Result := ''; 2957 3078 end; 2958 3079 … … 3022 3143 if FOnResize = AValue then Exit; 3023 3144 FOnResize := AValue; 3145 end; 3146 3147 procedure TDpiControl.SetParentFont(AValue: Boolean); 3148 begin 3149 TControlEx(GetNativeControl).ParentFont := AValue; 3024 3150 end; 3025 3151
Note:
See TracChangeset
for help on using the changeset viewer.