Changeset 361 for branches/highdpi/Packages/CevoComponents/ScreenTools.pas
- Timestamp:
- Apr 9, 2021, 5:56:50 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/highdpi/Packages/CevoComponents/ScreenTools.pas
r349 r361 11 11 12 12 type 13 TTexture = record 13 14 { TTexture } 15 16 TTexture = class 17 private 18 FAge: Integer; 19 function GetHeight: Integer; 20 function GetWidth: Integer; 21 procedure SetAge(AValue: Integer); 22 public 14 23 Image: TDpiBitmap; 15 clBevelLight: TColor; 16 clBevelShade: TColor; 17 clTextLight: TColor; 18 clTextShade: TColor; 19 clLitText: TColor; 20 clMark: TColor; 21 clPage: TColor; 22 clCover: TColor; 23 end; 24 ColorBevelLight: TColor; 25 ColorBevelShade: TColor; 26 ColorTextLight: TColor; 27 ColorTextShade: TColor; 28 ColorLitText: TColor; 29 ColorMark: TColor; 30 ColorPage: TColor; 31 ColorCover: TColor; 32 constructor Create; 33 destructor Destroy; override; 34 procedure Assign(Source: TTexture); 35 property Age: Integer read FAge write SetAge; 36 property Width: Integer read GetWidth; 37 property Height: Integer read GetHeight; 38 end; 39 24 40 TLoadGraphicFileOption = (gfNoError, gfNoGamma); 25 41 TLoadGraphicFileOptions = set of TLoadGraphicFileOption; … … 35 51 function TurnToString(Turn: integer): string; 36 52 function MovementToString(Movement: integer): string; 37 procedure BtnFrame(ca: TDpiCanvas; p: TRect; constT: TTexture);38 procedure EditFrame(ca: TDpiCanvas; p: TRect; constT: TTexture);53 procedure BtnFrame(ca: TDpiCanvas; p: TRect; T: TTexture); 54 procedure EditFrame(ca: TDpiCanvas; p: TRect; T: TTexture); 39 55 function HexStringToColor(S: string): integer; 40 56 function LoadGraphicFile(Bmp: TDpiBitmap; FileName: string; Options: TLoadGraphicFileOptions = []): boolean; … … 74 90 procedure GlowFrame(Dst: TDpiBitmap; x0, y0, Width, Height: integer; cl: TColor); 75 91 procedure InitOrnament; 76 procedure InitCityMark( constT: TTexture);92 procedure InitCityMark(T: TTexture); 77 93 procedure Fill(ca: TDpiCanvas; Left, Top, Width, Height, xOffset, yOffset: integer); overload; 78 94 procedure Fill(Canvas: TDpiCanvas; Rect: TRect; Offset: TPoint); overload; … … 83 99 const Texture: TDpiBitmap); 84 100 procedure PaintBackground(Form: TDpiForm; Left, Top, Width, Height: integer); 85 procedure Corner(ca: TDpiCanvas; x, y, Kind: integer; constT: TTexture);101 procedure Corner(ca: TDpiCanvas; x, y, Kind: integer; T: TTexture); 86 102 procedure BiColorTextOut(ca: TDpiCanvas; clMain, clBack: TColor; x, y: integer; s: string); 87 procedure LoweredTextOut(ca: TDpiCanvas; cl: TColor; constT: TTexture;103 procedure LoweredTextOut(ca: TDpiCanvas; cl: TColor; T: TTexture; 88 104 x, y: integer; s: string); 89 105 function BiColorTextWidth(ca: TDpiCanvas; s: string): integer; … … 95 111 procedure UnderlinedTitleValue(Canvas: TDpiCanvas; Title, Value: string; X, Y, Width: Integer); 96 112 procedure NumberBar(dst: TDpiBitmap; x, y: integer; Cap: string; val: integer; 97 constT: TTexture);113 T: TTexture); 98 114 procedure CountBar(dst: TDpiBitmap; x, y, w: integer; Kind: integer; 99 Cap: string; val: integer; constT: TTexture);115 Cap: string; val: integer; T: TTexture); 100 116 procedure PaintProgressBar(ca: TDpiCanvas; Kind, x, y, pos, Growth, max: integer; 101 constT: TTexture);117 T: TTexture); 102 118 procedure PaintRelativeProgressBar(ca: TDpiCanvas; 103 119 Kind, x, y, size, pos, Growth, max: integer; IndicateComplete: boolean; 104 constT: TTexture);120 T: TTexture); 105 121 procedure PaintLogo(Canvas: TDpiCanvas; X, Y, LightColor, ShadeColor: integer); 106 function SetMainTextureByAge(Age: integer): boolean;107 122 procedure LoadPhrases; 108 123 procedure Texturize(Dest, Texture: TDpiBitmap; TransparentColor: Cardinal); … … 113 128 TransparentColor1 = $FF00FF; 114 129 TransparentColor2 = $7F007F; 115 116 wMainTexture = 640;117 hMainTexture = 480;118 130 119 131 // template positions in Templates.png … … 165 177 HGrSystem2: TGraphicSet; 166 178 ClickFrameColor: Integer; 167 MainTextureAge: Integer;168 179 MainTexture: TTexture; 169 180 Templates: TGraphicSet; … … 325 336 end; 326 337 327 procedure BtnFrame(ca: TDpiCanvas; p: TRect; constT: TTexture);328 begin 329 RFrame(ca, p.Left - 1, p.Top - 1, p.Right, p.Bottom, T. clBevelShade,330 T. clBevelLight);331 end; 332 333 procedure EditFrame(ca: TDpiCanvas; p: TRect; constT: TTexture);338 procedure BtnFrame(ca: TDpiCanvas; p: TRect; T: TTexture); 339 begin 340 RFrame(ca, p.Left - 1, p.Top - 1, p.Right, p.Bottom, T.ColorBevelShade, 341 T.ColorBevelLight); 342 end; 343 344 procedure EditFrame(ca: TDpiCanvas; p: TRect; T: TTexture); 334 345 begin 335 346 Frame(ca, p.Left - 1, p.Top - 1, p.Right, p.Bottom, $000000, $000000); 336 347 Frame(ca, p.Left - 2, p.Top - 2, p.Right + 1, p.Bottom + 1, $000000, $000000); 337 348 Frame(ca, p.Left - 3, p.Top - 3, p.Right + 2, p.Bottom + 1, $000000, $000000); 338 RFrame(ca, p.Left - 4, p.Top - 4, p.Right + 3, p.Bottom + 2, T. clBevelShade,339 T. clBevelLight);349 RFrame(ca, p.Left - 4, p.Top - 4, p.Right + 3, p.Bottom + 2, T.ColorBevelShade, 350 T.ColorBevelLight); 340 351 end; 341 352 … … 1039 1050 begin 1040 1051 if InitOrnamentDone then Exit; 1041 Light := ColorToColor32(MainTexture. clBevelLight);1042 // and $FCFCFC shr 2*3+MainTexture. clBevelShade and $FCFCFC shr 2;1043 Shade := ColorToColor32(MainTexture. clBevelShade and $FCFCFC shr 2 * 3 +1044 MainTexture. clBevelLight and $FCFCFC shr 2);1052 Light := ColorToColor32(MainTexture.ColorBevelLight); 1053 // and $FCFCFC shr 2*3+MainTexture.ColorBevelShade and $FCFCFC shr 2; 1054 Shade := ColorToColor32(MainTexture.ColorBevelShade and $FCFCFC shr 2 * 3 + 1055 MainTexture.ColorBevelLight and $FCFCFC shr 2); 1045 1056 HGrSystem2.Data.BeginUpdate; 1046 1057 PixelPtr := PixelPointer(HGrSystem2.Data, ScaleToNative(Ornament.Left), ScaleToNative(Ornament.Top)); … … 1070 1081 end; 1071 1082 1072 procedure InitCityMark( constT: TTexture);1083 procedure InitCityMark(T: TTexture); 1073 1084 var 1074 1085 x: Integer; … … 1083 1094 x, CityMark1.Top + y] and $FF; 1084 1095 HGrSystem.Data.Canvas.Pixels[CityMark2.Left + x, CityMark2.Top + y] := 1085 T. clMark and $FF * Intensity div $FF + T.clMark shr 8 and1086 $FF * Intensity div $FF shl 8 + T. clMark shr 16 and1096 T.ColorMark and $FF * Intensity div $FF + T.ColorMark shr 8 and 1097 $FF * Intensity div $FF shl 8 + T.ColorMark shr 16 and 1087 1098 $FF * Intensity div $FF shl 16; 1088 1099 end; … … 1095 1106 procedure Fill(ca: TDpiCanvas; Left, Top, Width, Height, xOffset, yOffset: Integer); 1096 1107 begin 1097 Assert((Left + xOffset >= 0) and (Left + xOffset + Width <= wMainTexture) and1098 (Top + yOffset >= 0) and (Top + yOffset + Height <= hMainTexture));1108 Assert((Left + xOffset >= 0) and (Left + xOffset + Width <= MainTexture.Width) and 1109 (Top + yOffset >= 0) and (Top + yOffset + Height <= MainTexture.Height)); 1099 1110 DpiBitCanvas(ca, Left, Top, Width, Height, MainTexture.Image.Canvas, 1100 1111 Left + xOffset, Top + yOffset); … … 1112 1123 n: integer; 1113 1124 begin 1114 n := (( hMainTexturediv 2) div (y1 - y0)) * 2;1115 while hMainTexture div 2 + (I + 1) * (y1 - y0) > hMainTexturedo1125 n := ((MainTexture.Height div 2) div (y1 - y0)) * 2; 1126 while MainTexture.Height div 2 + (I + 1) * (y1 - y0) > MainTexture.Height do 1116 1127 Dec(I, n); 1117 while hMainTexturediv 2 + I * (y1 - y0) < 0 do1128 while MainTexture.Height div 2 + I * (y1 - y0) < 0 do 1118 1129 Inc(I, n); 1119 1130 Result := I; … … 1123 1134 I: Integer; 1124 1135 begin 1125 for I := 0 to (x1 - xm) div wMainTexture- 1 do1126 DpiBitCanvas(ca, xm + I * wMainTexture, y0, wMainTexture, y1 - y0,1127 MainTexture.Image.Canvas, 0, hMainTexturediv 2 + Band(I) *1136 for I := 0 to (x1 - xm) div MainTexture.Width - 1 do 1137 DpiBitCanvas(ca, xm + I * MainTexture.Width, y0, MainTexture.Width, y1 - y0, 1138 MainTexture.Image.Canvas, 0, MainTexture.Height div 2 + Band(I) * 1128 1139 (y1 - y0)); 1129 DpiBitCanvas(ca, xm + ((x1 - xm) div wMainTexture) * wMainTexture, y0,1130 x1 - (xm + ((x1 - xm) div wMainTexture) * wMainTexture), y1 - y0,1131 MainTexture.Image.Canvas, 0, hMainTexturediv 2 + Band(1132 (x1 - xm) div wMainTexture) * (y1 - y0));1133 for I := 0 to (xm - x0) div wMainTexture- 1 do1134 DpiBitCanvas(ca, xm - (I + 1) * wMainTexture, y0, wMainTexture, y1 - y0,1135 MainTexture.Image.Canvas, 0, hMainTexturediv 2 +1140 DpiBitCanvas(ca, xm + ((x1 - xm) div MainTexture.Width) * MainTexture.Width, y0, 1141 x1 - (xm + ((x1 - xm) div MainTexture.Width) * MainTexture.Width), y1 - y0, 1142 MainTexture.Image.Canvas, 0, MainTexture.Height div 2 + Band( 1143 (x1 - xm) div MainTexture.Width) * (y1 - y0)); 1144 for I := 0 to (xm - x0) div MainTexture.Width - 1 do 1145 DpiBitCanvas(ca, xm - (I + 1) * MainTexture.Width, y0, MainTexture.Width, y1 - y0, 1146 MainTexture.Image.Canvas, 0, MainTexture.Height div 2 + 1136 1147 Band(-I - 1) * (y1 - y0)); 1137 DpiBitCanvas(ca, x0, y0, xm - ((xm - x0) div wMainTexture) *1138 wMainTexture- x0, y1 - y0, MainTexture.Image.Canvas,1139 ((xm - x0) div wMainTexture + 1) * wMainTexture- (xm - x0),1140 hMainTexture div 2 + Band(-(xm - x0) div wMainTexture- 1) * (y1 - y0));1148 DpiBitCanvas(ca, x0, y0, xm - ((xm - x0) div MainTexture.Width) * 1149 MainTexture.Width - x0, y1 - y0, MainTexture.Image.Canvas, 1150 ((xm - x0) div MainTexture.Width + 1) * MainTexture.Width - (xm - x0), 1151 MainTexture.Height div 2 + Band(-(xm - x0) div MainTexture.Width - 1) * (y1 - y0)); 1141 1152 end; 1142 1153 … … 1183 1194 procedure PaintBackground(Form: TDpiForm; Left, Top, Width, Height: Integer); 1184 1195 begin 1185 Fill(Form.Canvas, Left, Top, Width, Height, ( wMainTexture- Form.ClientWidth) div1186 2, ( hMainTexture- Form.ClientHeight) div 2);1187 end; 1188 1189 procedure Corner(ca: TDpiCanvas; x, y, Kind: Integer; constT: TTexture);1196 Fill(Form.Canvas, Left, Top, Width, Height, (MainTexture.Width - Form.ClientWidth) div 1197 2, (MainTexture.Height - Form.ClientHeight) div 2); 1198 end; 1199 1200 procedure Corner(ca: TDpiCanvas; x, y, Kind: Integer; T: TTexture); 1190 1201 begin 1191 1202 { DpiBitCanvas(ca,x,y,8,8,T.HGr.Mask.Canvas, … … 1282 1293 end; 1283 1294 1284 procedure LoweredTextOut(ca: TDpiCanvas; cl: TColor; constT: TTexture;1295 procedure LoweredTextOut(ca: TDpiCanvas; cl: TColor; T: TTexture; 1285 1296 x, y: Integer; s: string); 1286 1297 begin 1287 1298 if cl = -2 then 1288 BiColorTextOut(ca, (T. clBevelShade and $FEFEFE) shr 1,1289 T. clBevelLight, x, y, s)1299 BiColorTextOut(ca, (T.ColorBevelShade and $FEFEFE) shr 1, 1300 T.ColorBevelLight, x, y, s) 1290 1301 else if cl < 0 then 1291 BiColorTextOut(ca, T. clTextShade, T.clTextLight, x, y, s)1302 BiColorTextOut(ca, T.ColorTextShade, T.ColorTextLight, x, y, s) 1292 1303 else 1293 BiColorTextOut(ca, cl, T. clTextLight, x, y, s);1304 BiColorTextOut(ca, cl, T.ColorTextLight, x, y, s); 1294 1305 end; 1295 1306 … … 1366 1377 procedure UnderlinedTitleValue(Canvas: TDpiCanvas; Title, Value: string; X, Y, Width: Integer); 1367 1378 begin 1368 DLine(Canvas, X, X + Width, Y + 19, MainTexture. clBevelLight, MainTexture.clBevelShade);1379 DLine(Canvas, X, X + Width, Y + 19, MainTexture.ColorBevelLight, MainTexture.ColorBevelShade); 1369 1380 RisedTextOut(Canvas, X, Y, Title); 1370 1381 RisedTextOut(Canvas, X + Width - BiColorTextWidth(Canvas, Value), Y, Value); … … 1372 1383 1373 1384 procedure NumberBar(dst: TDpiBitmap; x, y: integer; Cap: string; 1374 val: Integer; constT: TTexture);1385 val: Integer; T: TTexture); 1375 1386 var 1376 1387 s: string; … … 1378 1389 if val > 0 then 1379 1390 begin 1380 DLine(dst.Canvas, x - 2, x + 170, y + 16, T. clBevelShade,1381 T. clBevelLight);1391 DLine(dst.Canvas, x - 2, x + 170, y + 16, T.ColorBevelShade, 1392 T.ColorBevelLight); 1382 1393 LoweredTextOut(dst.Canvas, -1, T, x - 2, y, Cap); 1383 1394 s := IntToStr(val); … … 1388 1399 1389 1400 procedure CountBar(dst: TDpiBitmap; x, y, w: Integer; Kind: Integer; 1390 Cap: string; val: Integer; constT: TTexture);1401 Cap: string; val: Integer; T: TTexture); 1391 1402 var 1392 1403 i, sd, ld, cl, xIcon, yIcon: Integer; … … 1401 1412 // xIcon:=x+100; 1402 1413 // yIcon:=y; 1403 // DLine(dst.Canvas,x-2,x+170+32,y+16,T. clBevelShade,T.clBevelLight);1414 // DLine(dst.Canvas,x-2,x+170+32,y+16,T.ColorBevelShade,T.ColorBevelLight); 1404 1415 1405 1416 xIcon := x - 5; 1406 1417 yIcon := y + 15; 1407 DLine(dst.Canvas, x - 2, xIcon + w + 2, yIcon + 16, T. clBevelShade,1408 T. clBevelLight);1418 DLine(dst.Canvas, x - 2, xIcon + w + 2, yIcon + 16, T.ColorBevelShade, 1419 T.ColorBevelLight); 1409 1420 1410 1421 s := IntToStr(val); … … 1484 1495 1485 1496 procedure PaintProgressBar(ca: TDpiCanvas; Kind, x, y, pos, Growth, max: Integer; 1486 constT: TTexture);1497 T: TTexture); 1487 1498 var 1488 1499 i: Integer; … … 1502 1513 Growth := max - pos; 1503 1514 Frame(ca, x - 1, y - 1, x + max, y + 7, $000000, $000000); 1504 RFrame(ca, x - 2, y - 2, x + max + 1, y + 8, T. clBevelShade,1505 T. clBevelLight);1515 RFrame(ca, x - 2, y - 2, x + max + 1, y + 8, T.ColorBevelShade, 1516 T.ColorBevelLight); 1506 1517 with ca do 1507 1518 begin … … 1538 1549 procedure PaintRelativeProgressBar(ca: TDpiCanvas; 1539 1550 Kind, x, y, size, pos, Growth, max: Integer; IndicateComplete: Boolean; 1540 constT: TTexture);1551 T: TTexture); 1541 1552 begin 1542 1553 if Growth > 0 then … … 1557 1568 LightColor, ShadeColor); 1558 1569 DpiBitCanvas(Canvas, X, Y, Logo.Width, Logo.Height, LogoBuffer.Canvas, 0, 0); 1559 end;1560 1561 function SetMainTextureByAge(Age: Integer): Boolean;1562 begin1563 if Age <> MainTextureAge then1564 with MainTexture do begin1565 MainTextureAge := Age;1566 LoadGraphicFile(Image, GetGraphicsDir + DirectorySeparator +1567 'Texture' + IntToStr(Age + 1) + '.jpg');1568 clBevelLight := Colors.Canvas.Pixels[clkAge0 + Age, cliBevelLight];1569 clBevelShade := Colors.Canvas.Pixels[clkAge0 + Age, cliBevelShade];1570 clTextLight := Colors.Canvas.Pixels[clkAge0 + Age, cliTextLight];1571 clTextShade := Colors.Canvas.Pixels[clkAge0 + Age, cliTextShade];1572 clLitText := Colors.Canvas.Pixels[clkAge0 + Age, cliLitText];1573 clMark := Colors.Canvas.Pixels[clkAge0 + Age, cliMark];1574 clPage := Colors.Canvas.Pixels[clkAge0 + Age, cliPage];1575 clCover := Colors.Canvas.Pixels[clkAge0 + Age, cliCover];1576 Result := True;1577 end1578 else1579 Result := False;1580 1570 end; 1581 1571 … … 1786 1776 BigImp := TDpiBitmap.Create; 1787 1777 BigImp.PixelFormat := pf24bit; 1788 MainTexture.Image := TDpiBitmap.Create; 1789 MainTextureAge := -2; 1778 MainTexture := TTexture.Create; 1790 1779 ClickFrameColor := HGrSystem.Data.Canvas.Pixels[187, 175]; 1791 1780 InitOrnamentDone := False; … … 1810 1799 FreeAndNil(Paper); 1811 1800 FreeAndNil(Colors); 1812 FreeAndNil(MainTexture.Image); 1801 FreeAndNil(MainTexture); 1802 end; 1803 1804 { TTexture } 1805 1806 procedure TTexture.SetAge(AValue: Integer); 1807 begin 1808 if FAge = AValue then Exit; 1809 FAge := AValue; 1810 LoadGraphicFile(Image, GetGraphicsDir + DirectorySeparator + 1811 'Texture' + IntToStr(Age + 1) + '.jpg'); 1812 ColorBevelLight := Colors.Canvas.Pixels[clkAge0 + Age, cliBevelLight]; 1813 ColorBevelShade := Colors.Canvas.Pixels[clkAge0 + Age, cliBevelShade]; 1814 ColorTextLight := Colors.Canvas.Pixels[clkAge0 + Age, cliTextLight]; 1815 ColorTextShade := Colors.Canvas.Pixels[clkAge0 + Age, cliTextShade]; 1816 ColorLitText := Colors.Canvas.Pixels[clkAge0 + Age, cliLitText]; 1817 ColorMark := Colors.Canvas.Pixels[clkAge0 + Age, cliMark]; 1818 ColorPage := Colors.Canvas.Pixels[clkAge0 + Age, cliPage]; 1819 ColorCover := Colors.Canvas.Pixels[clkAge0 + Age, cliCover]; 1820 end; 1821 1822 function TTexture.GetHeight: Integer; 1823 begin 1824 Result := Image.Height; 1825 end; 1826 1827 function TTexture.GetWidth: Integer; 1828 begin 1829 Result := Image.Width; 1830 end; 1831 1832 constructor TTexture.Create; 1833 begin 1834 Image := TDpiBitmap.Create; 1835 FAge := -2; 1836 end; 1837 1838 destructor TTexture.Destroy; 1839 begin 1840 FreeAndNil(Image); 1841 inherited; 1842 end; 1843 1844 procedure TTexture.Assign(Source: TTexture); 1845 begin 1846 FAge := Source.FAge; 1847 Image.Assign(Image); 1848 ColorBevelLight := Source.ColorBevelLight; 1849 ColorBevelShade := Source.ColorBevelShade; 1850 ColorTextLight := Source.ColorTextLight; 1851 ColorTextShade := Source.ColorTextShade; 1852 ColorLitText := Source.ColorLitText; 1853 ColorMark := Source.ColorMark; 1854 ColorPage := Source.ColorPage; 1855 ColorCover := Source.ColorCover; 1813 1856 end; 1814 1857
Note:
See TracChangeset
for help on using the changeset viewer.