Changeset 248 for branches/highdpi/Packages/DpiControls/UDpiControls.pas
- Timestamp:
- May 22, 2020, 7:08:10 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/highdpi/Packages/DpiControls/UDpiControls.pas
r247 r248 6 6 7 7 uses 8 Windows,Classes, SysUtils, LCLProc, LResources, Forms, FormEditingIntf, ProjectIntf,8 {$IFDEF WINDOWS}Windows, {$ENDIF}Classes, SysUtils, LCLProc, LResources, Forms, FormEditingIntf, ProjectIntf, 9 9 Controls, StdCtrls, fgl, Graphics, ComCtrls, ExtCtrls, LCLType, GraphType, 10 10 Types, CustApp, LMessages, LCLIntf, Menus; … … 59 59 FOnChange: TNotifyEvent; 60 60 FSize: Integer; 61 FHeight: Integer; 62 FPixelsPerInch: Integer; 63 FColor: TColor; 61 64 function GetCharSet: TFontCharSet; 62 65 function GetColor: TColor; … … 64 67 function GetName: string; 65 68 function GetPixelsPerInch: Integer; 69 function GetSize: Integer; 66 70 function GetStyle: TFontStyles; 67 71 function IsNameStored: Boolean; … … 75 79 procedure DoChange; 76 80 procedure SetStyle(AValue: TFontStyles); 81 procedure UpdateFont; 77 82 protected 78 83 procedure ScreenChanged; … … 88 93 property Name: string read GetName write SetName stored IsNameStored; 89 94 property Style: TFontStyles read GetStyle write SetStyle default []; 90 property Size: Integer read FSize write SetSize stored false;95 property Size: Integer read GetSize write SetSize stored false; 91 96 property PixelsPerInch: Integer read GetPixelsPerInch write SetPixelsPerInch; 92 97 property Height: Integer read GetHeight write SetHeight default 0; … … 2275 2280 if FSize = AValue then Exit; 2276 2281 FSize := AValue; 2277 GetNativeFont.Size := AValue; 2282 FHeight := -MulDiv(FSize, FPixelsPerInch, 72); 2283 UpdateFont; 2278 2284 DoChange; 2279 2285 end; … … 2287 2293 begin 2288 2294 GetNativeFont.Style := AValue; 2295 end; 2296 2297 procedure TDpiFont.UpdateFont; 2298 begin 2299 GetNativeFont.PixelsPerInch := FPixelsPerInch; 2300 GetNativeFont.Size := FSize; 2289 2301 end; 2290 2302 … … 2308 2320 procedure TDpiFont.SetPixelsPerInch(AValue: Integer); 2309 2321 begin 2310 GetNativeFont.PixelsPerInch := PixelsPerInch; 2322 FPixelsPerInch := PixelsPerInch; 2323 FHeight := -MulDiv(FSize, FPixelsPerInch, 72); 2324 UpdateFont; 2311 2325 end; 2312 2326 … … 2318 2332 function TDpiFont.GetColor: TColor; 2319 2333 begin 2320 Result := GetNativeFont.Color;2334 Result := FColor; 2321 2335 end; 2322 2336 … … 2333 2347 function TDpiFont.GetPixelsPerInch: Integer; 2334 2348 begin 2335 Result := GetNativeFont.PixelsPerInch; 2349 Result := FPixelsPerInch; 2350 end; 2351 2352 function TDpiFont.GetSize: Integer; 2353 begin 2354 Result := FSize; 2336 2355 end; 2337 2356 … … 2353 2372 procedure TDpiFont.SetColor(AValue: TColor); 2354 2373 begin 2374 if FColor = AValue then Exit; 2375 FColor := AValue; 2355 2376 GetNativeFont.Color := AValue; 2356 2377 end; … … 2358 2379 procedure TDpiFont.SetHeight(AValue: Integer); 2359 2380 begin 2360 GetNativeFont.Height := AValue; 2381 FHeight := AValue; 2382 FSize := MulDiv(-FHeight, 72, FPixelsPerInch); 2383 UpdateFont; 2361 2384 end; 2362 2385 … … 2368 2391 constructor TDpiFont.Create; 2369 2392 begin 2393 FPixelsPerInch := DpiScreen.PixelsPerInch; 2370 2394 Size := 8; 2371 2395 end; … … 2381 2405 GetNativeFont.Assign((Source as TDpiFont).GetNativeFont); 2382 2406 Size := (Source as TDpiFont).Size; 2407 Height := (Source as TDpiFont).Height; 2408 PixelsPerInch := (Source as TDpiFont).PixelsPerInch; 2383 2409 FOnChange := (Source as TDpiFont).FOnChange; 2410 Color := (Source as TDpiFont).Color; 2384 2411 end; 2385 2412 end; … … 2582 2609 procedure TDpiScreen.UpdateScreen; 2583 2610 begin 2584 // Dpi := 96 * 2;2585 2611 Dpi := Screen.PixelsPerInch; 2586 2612 end;
Note:
See TracChangeset
for help on using the changeset viewer.