Changeset 352 for trunk/Packages/CevoComponents/ScreenTools.pas
- Timestamp:
- Apr 6, 2021, 10:16:55 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/CevoComponents/ScreenTools.pas
r347 r352 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: TBitmap; 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: TCanvas; p: TRect; constT: TTexture);38 procedure EditFrame(ca: TCanvas; p: TRect; constT: TTexture);53 procedure BtnFrame(ca: TCanvas; p: TRect; T: TTexture); 54 procedure EditFrame(ca: TCanvas; p: TRect; T: TTexture); 39 55 function HexStringToColor(S: string): integer; 40 56 function LoadGraphicFile(Bmp: TBitmap; FileName: string; Options: TLoadGraphicFileOptions = []): boolean; … … 74 90 procedure GlowFrame(Dst: TBitmap; 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: TCanvas; Left, Top, Width, Height, xOffset, yOffset: integer); overload; 78 94 procedure Fill(Canvas: TCanvas; Rect: TRect; Offset: TPoint); overload; … … 83 99 const Texture: TBitmap); 84 100 procedure PaintBackground(Form: TForm; Left, Top, Width, Height: integer); 85 procedure Corner(ca: TCanvas; x, y, Kind: integer; constT: TTexture);101 procedure Corner(ca: TCanvas; x, y, Kind: integer; T: TTexture); 86 102 procedure BiColorTextOut(ca: TCanvas; clMain, clBack: TColor; x, y: integer; s: string); 87 procedure LoweredTextOut(ca: TCanvas; cl: TColor; constT: TTexture;103 procedure LoweredTextOut(ca: TCanvas; cl: TColor; T: TTexture; 88 104 x, y: integer; s: string); 89 105 function BiColorTextWidth(ca: TCanvas; s: string): integer; … … 95 111 procedure UnderlinedTitleValue(Canvas: TCanvas; Title, Value: string; X, Y, Width: Integer); 96 112 procedure NumberBar(dst: TBitmap; x, y: integer; Cap: string; val: integer; 97 constT: TTexture);113 T: TTexture); 98 114 procedure CountBar(dst: TBitmap; 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: TCanvas; Kind, x, y, pos, Growth, max: integer; 101 constT: TTexture);117 T: TTexture); 102 118 procedure PaintRelativeProgressBar(ca: TCanvas; 103 119 Kind, x, y, size, pos, Growth, max: integer; IndicateComplete: boolean; 104 constT: TTexture);120 T: TTexture); 105 121 procedure PaintLogo(Canvas: TCanvas; X, Y, LightColor, ShadeColor: integer); 106 function SetMainTextureByAge(Age: integer): boolean;107 122 procedure LoadPhrases; 108 123 procedure Texturize(Dest, Texture: TBitmap; TransparentColor: Cardinal); … … 115 130 TransparentColor1 = $FF00FF; 116 131 TransparentColor2 = $7F007F; 117 118 wMainTexture = 640;119 hMainTexture = 480;120 132 121 133 // template positions in Templates.png … … 167 179 HGrSystem2: TGraphicSet; 168 180 ClickFrameColor: Integer; 169 MainTextureAge: Integer;170 181 MainTexture: TTexture; 171 182 Templates: TGraphicSet; … … 327 338 end; 328 339 329 procedure BtnFrame(ca: TCanvas; p: TRect; constT: TTexture);330 begin 331 RFrame(ca, p.Left - 1, p.Top - 1, p.Right, p.Bottom, T. clBevelShade,332 T. clBevelLight);333 end; 334 335 procedure EditFrame(ca: TCanvas; p: TRect; constT: TTexture);340 procedure BtnFrame(ca: TCanvas; p: TRect; T: TTexture); 341 begin 342 RFrame(ca, p.Left - 1, p.Top - 1, p.Right, p.Bottom, T.ColorBevelShade, 343 T.ColorBevelLight); 344 end; 345 346 procedure EditFrame(ca: TCanvas; p: TRect; T: TTexture); 336 347 begin 337 348 Frame(ca, p.Left - 1, p.Top - 1, p.Right, p.Bottom, $000000, $000000); 338 349 Frame(ca, p.Left - 2, p.Top - 2, p.Right + 1, p.Bottom + 1, $000000, $000000); 339 350 Frame(ca, p.Left - 3, p.Top - 3, p.Right + 2, p.Bottom + 1, $000000, $000000); 340 RFrame(ca, p.Left - 4, p.Top - 4, p.Right + 3, p.Bottom + 2, T. clBevelShade,341 T. clBevelLight);351 RFrame(ca, p.Left - 4, p.Top - 4, p.Right + 3, p.Bottom + 2, T.ColorBevelShade, 352 T.ColorBevelLight); 342 353 end; 343 354 … … 1041 1052 begin 1042 1053 if InitOrnamentDone then Exit; 1043 Light := ColorToColor32(MainTexture. clBevelLight);1044 // and $FCFCFC shr 2*3+MainTexture. clBevelShade and $FCFCFC shr 2;1045 Shade := ColorToColor32(MainTexture. clBevelShade and $FCFCFC shr 2 * 3 +1046 MainTexture. clBevelLight and $FCFCFC shr 2);1054 Light := ColorToColor32(MainTexture.ColorBevelLight); 1055 // and $FCFCFC shr 2*3+MainTexture.ColorBevelShade and $FCFCFC shr 2; 1056 Shade := ColorToColor32(MainTexture.ColorBevelShade and $FCFCFC shr 2 * 3 + 1057 MainTexture.ColorBevelLight and $FCFCFC shr 2); 1047 1058 HGrSystem2.Data.BeginUpdate; 1048 1059 PixelPtr := PixelPointer(HGrSystem2.Data, ScaleToNative(Ornament.Left), ScaleToNative(Ornament.Top)); … … 1072 1083 end; 1073 1084 1074 procedure InitCityMark( constT: TTexture);1085 procedure InitCityMark(T: TTexture); 1075 1086 var 1076 1087 x: Integer; … … 1085 1096 x, CityMark1.Top + y] and $FF; 1086 1097 HGrSystem.Data.Canvas.Pixels[CityMark2.Left + x, CityMark2.Top + y] := 1087 T. clMark and $FF * Intensity div $FF + T.clMark shr 8 and1088 $FF * Intensity div $FF shl 8 + T. clMark shr 16 and1098 T.ColorMark and $FF * Intensity div $FF + T.ColorMark shr 8 and 1099 $FF * Intensity div $FF shl 8 + T.ColorMark shr 16 and 1089 1100 $FF * Intensity div $FF shl 16; 1090 1101 end; … … 1097 1108 procedure Fill(ca: TCanvas; Left, Top, Width, Height, xOffset, yOffset: Integer); 1098 1109 begin 1099 Assert((Left + xOffset >= 0) and (Left + xOffset + Width <= wMainTexture) and1100 (Top + yOffset >= 0) and (Top + yOffset + Height <= hMainTexture));1110 Assert((Left + xOffset >= 0) and (Left + xOffset + Width <= MainTexture.Width) and 1111 (Top + yOffset >= 0) and (Top + yOffset + Height <= MainTexture.Height)); 1101 1112 BitBltCanvas(ca, Left, Top, Width, Height, MainTexture.Image.Canvas, 1102 1113 Left + xOffset, Top + yOffset); … … 1114 1125 n: integer; 1115 1126 begin 1116 n := (( hMainTexturediv 2) div (y1 - y0)) * 2;1117 while hMainTexture div 2 + (I + 1) * (y1 - y0) > hMainTexturedo1127 n := ((MainTexture.Height div 2) div (y1 - y0)) * 2; 1128 while MainTexture.Height div 2 + (I + 1) * (y1 - y0) > MainTexture.Height do 1118 1129 Dec(I, n); 1119 while hMainTexturediv 2 + I * (y1 - y0) < 0 do1130 while MainTexture.Height div 2 + I * (y1 - y0) < 0 do 1120 1131 Inc(I, n); 1121 1132 Result := I; … … 1125 1136 I: Integer; 1126 1137 begin 1127 for I := 0 to (x1 - xm) div wMainTexture- 1 do1128 BitBltCanvas(ca, xm + I * wMainTexture, y0, wMainTexture, y1 - y0,1129 MainTexture.Image.Canvas, 0, hMainTexturediv 2 + Band(I) *1138 for I := 0 to (x1 - xm) div MainTexture.Width - 1 do 1139 BitBltCanvas(ca, xm + I * MainTexture.Width, y0, MainTexture.Width, y1 - y0, 1140 MainTexture.Image.Canvas, 0, MainTexture.Height div 2 + Band(I) * 1130 1141 (y1 - y0)); 1131 BitBltCanvas(ca, xm + ((x1 - xm) div wMainTexture) * wMainTexture, y0,1132 x1 - (xm + ((x1 - xm) div wMainTexture) * wMainTexture), y1 - y0,1133 MainTexture.Image.Canvas, 0, hMainTexturediv 2 + Band(1134 (x1 - xm) div wMainTexture) * (y1 - y0));1135 for I := 0 to (xm - x0) div wMainTexture- 1 do1136 BitBltCanvas(ca, xm - (I + 1) * wMainTexture, y0, wMainTexture, y1 - y0,1137 MainTexture.Image.Canvas, 0, hMainTexturediv 2 +1142 BitBltCanvas(ca, xm + ((x1 - xm) div MainTexture.Width) * MainTexture.Width, y0, 1143 x1 - (xm + ((x1 - xm) div MainTexture.Width) * MainTexture.Width), y1 - y0, 1144 MainTexture.Image.Canvas, 0, MainTexture.Height div 2 + Band( 1145 (x1 - xm) div MainTexture.Width) * (y1 - y0)); 1146 for I := 0 to (xm - x0) div MainTexture.Width - 1 do 1147 BitBltCanvas(ca, xm - (I + 1) * MainTexture.Width, y0, MainTexture.Width, y1 - y0, 1148 MainTexture.Image.Canvas, 0, MainTexture.Height div 2 + 1138 1149 Band(-I - 1) * (y1 - y0)); 1139 BitBltCanvas(ca, x0, y0, xm - ((xm - x0) div wMainTexture) *1140 wMainTexture- x0, y1 - y0, MainTexture.Image.Canvas,1141 ((xm - x0) div wMainTexture + 1) * wMainTexture- (xm - x0),1142 hMainTexture div 2 + Band(-(xm - x0) div wMainTexture- 1) * (y1 - y0));1150 BitBltCanvas(ca, x0, y0, xm - ((xm - x0) div MainTexture.Width) * 1151 MainTexture.Width - x0, y1 - y0, MainTexture.Image.Canvas, 1152 ((xm - x0) div MainTexture.Width + 1) * MainTexture.Width - (xm - x0), 1153 MainTexture.Height div 2 + Band(-(xm - x0) div MainTexture.Width - 1) * (y1 - y0)); 1143 1154 end; 1144 1155 … … 1185 1196 procedure PaintBackground(Form: TForm; Left, Top, Width, Height: Integer); 1186 1197 begin 1187 Fill(Form.Canvas, Left, Top, Width, Height, ( wMainTexture- Form.ClientWidth) div1188 2, ( hMainTexture- Form.ClientHeight) div 2);1189 end; 1190 1191 procedure Corner(ca: TCanvas; x, y, Kind: Integer; constT: TTexture);1198 Fill(Form.Canvas, Left, Top, Width, Height, (MainTexture.Width - Form.ClientWidth) div 1199 2, (MainTexture.Height - Form.ClientHeight) div 2); 1200 end; 1201 1202 procedure Corner(ca: TCanvas; x, y, Kind: Integer; T: TTexture); 1192 1203 begin 1193 1204 { BitBltCanvas(ca,x,y,8,8,T.HGr.Mask.Canvas, … … 1284 1295 end; 1285 1296 1286 procedure LoweredTextOut(ca: TCanvas; cl: TColor; constT: TTexture;1297 procedure LoweredTextOut(ca: TCanvas; cl: TColor; T: TTexture; 1287 1298 x, y: Integer; s: string); 1288 1299 begin 1289 1300 if cl = -2 then 1290 BiColorTextOut(ca, (T. clBevelShade and $FEFEFE) shr 1,1291 T. clBevelLight, x, y, s)1301 BiColorTextOut(ca, (T.ColorBevelShade and $FEFEFE) shr 1, 1302 T.ColorBevelLight, x, y, s) 1292 1303 else if cl < 0 then 1293 BiColorTextOut(ca, T. clTextShade, T.clTextLight, x, y, s)1304 BiColorTextOut(ca, T.ColorTextShade, T.ColorTextLight, x, y, s) 1294 1305 else 1295 BiColorTextOut(ca, cl, T. clTextLight, x, y, s);1306 BiColorTextOut(ca, cl, T.ColorTextLight, x, y, s); 1296 1307 end; 1297 1308 … … 1368 1379 procedure UnderlinedTitleValue(Canvas: TCanvas; Title, Value: string; X, Y, Width: Integer); 1369 1380 begin 1370 DLine(Canvas, X, X + Width, Y + 19, MainTexture. clBevelLight, MainTexture.clBevelShade);1381 DLine(Canvas, X, X + Width, Y + 19, MainTexture.ColorBevelLight, MainTexture.ColorBevelShade); 1371 1382 RisedTextOut(Canvas, X, Y, Title); 1372 1383 RisedTextOut(Canvas, X + Width - BiColorTextWidth(Canvas, Value), Y, Value); … … 1374 1385 1375 1386 procedure NumberBar(dst: TBitmap; x, y: integer; Cap: string; 1376 val: Integer; constT: TTexture);1387 val: Integer; T: TTexture); 1377 1388 var 1378 1389 s: string; … … 1380 1391 if val > 0 then 1381 1392 begin 1382 DLine(dst.Canvas, x - 2, x + 170, y + 16, T. clBevelShade,1383 T. clBevelLight);1393 DLine(dst.Canvas, x - 2, x + 170, y + 16, T.ColorBevelShade, 1394 T.ColorBevelLight); 1384 1395 LoweredTextOut(dst.Canvas, -1, T, x - 2, y, Cap); 1385 1396 s := IntToStr(val); … … 1390 1401 1391 1402 procedure CountBar(dst: TBitmap; x, y, w: Integer; Kind: Integer; 1392 Cap: string; val: Integer; constT: TTexture);1403 Cap: string; val: Integer; T: TTexture); 1393 1404 var 1394 1405 i, sd, ld, cl, xIcon, yIcon: Integer; … … 1403 1414 // xIcon:=x+100; 1404 1415 // yIcon:=y; 1405 // DLine(dst.Canvas,x-2,x+170+32,y+16,T. clBevelShade,T.clBevelLight);1416 // DLine(dst.Canvas,x-2,x+170+32,y+16,T.ColorBevelShade,T.ColorBevelLight); 1406 1417 1407 1418 xIcon := x - 5; 1408 1419 yIcon := y + 15; 1409 DLine(dst.Canvas, x - 2, xIcon + w + 2, yIcon + 16, T. clBevelShade,1410 T. clBevelLight);1420 DLine(dst.Canvas, x - 2, xIcon + w + 2, yIcon + 16, T.ColorBevelShade, 1421 T.ColorBevelLight); 1411 1422 1412 1423 s := IntToStr(val); … … 1486 1497 1487 1498 procedure PaintProgressBar(ca: TCanvas; Kind, x, y, pos, Growth, max: Integer; 1488 constT: TTexture);1499 T: TTexture); 1489 1500 var 1490 1501 i: Integer; … … 1504 1515 Growth := max - pos; 1505 1516 Frame(ca, x - 1, y - 1, x + max, y + 7, $000000, $000000); 1506 RFrame(ca, x - 2, y - 2, x + max + 1, y + 8, T. clBevelShade,1507 T. clBevelLight);1517 RFrame(ca, x - 2, y - 2, x + max + 1, y + 8, T.ColorBevelShade, 1518 T.ColorBevelLight); 1508 1519 with ca do 1509 1520 begin … … 1540 1551 procedure PaintRelativeProgressBar(ca: TCanvas; 1541 1552 Kind, x, y, size, pos, Growth, max: Integer; IndicateComplete: Boolean; 1542 constT: TTexture);1553 T: TTexture); 1543 1554 begin 1544 1555 if Growth > 0 then … … 1559 1570 LightColor, ShadeColor); 1560 1571 BitBltCanvas(Canvas, X, Y, Logo.Width, Logo.Height, LogoBuffer.Canvas, 0, 0); 1561 end;1562 1563 function SetMainTextureByAge(Age: Integer): Boolean;1564 begin1565 if Age <> MainTextureAge then1566 with MainTexture do begin1567 MainTextureAge := Age;1568 LoadGraphicFile(Image, GetGraphicsDir + DirectorySeparator +1569 'Texture' + IntToStr(Age + 1) + '.jpg');1570 clBevelLight := Colors.Canvas.Pixels[clkAge0 + Age, cliBevelLight];1571 clBevelShade := Colors.Canvas.Pixels[clkAge0 + Age, cliBevelShade];1572 clTextLight := Colors.Canvas.Pixels[clkAge0 + Age, cliTextLight];1573 clTextShade := Colors.Canvas.Pixels[clkAge0 + Age, cliTextShade];1574 clLitText := Colors.Canvas.Pixels[clkAge0 + Age, cliLitText];1575 clMark := Colors.Canvas.Pixels[clkAge0 + Age, cliMark];1576 clPage := Colors.Canvas.Pixels[clkAge0 + Age, cliPage];1577 clCover := Colors.Canvas.Pixels[clkAge0 + Age, cliCover];1578 Result := True;1579 end1580 else1581 Result := False;1582 1572 end; 1583 1573 … … 1795 1785 BigImp := TBitmap.Create; 1796 1786 BigImp.PixelFormat := pf24bit; 1797 MainTexture.Image := TBitmap.Create; 1798 MainTextureAge := -2; 1787 MainTexture := TTexture.Create; 1799 1788 ClickFrameColor := HGrSystem.Data.Canvas.Pixels[187, 175]; 1800 1789 InitOrnamentDone := False; … … 1819 1808 FreeAndNil(Paper); 1820 1809 FreeAndNil(Colors); 1821 FreeAndNil(MainTexture.Image); 1810 FreeAndNil(MainTexture); 1811 end; 1812 1813 { TTexture } 1814 1815 procedure TTexture.SetAge(AValue: Integer); 1816 begin 1817 if FAge = AValue then Exit; 1818 FAge := AValue; 1819 LoadGraphicFile(Image, GetGraphicsDir + DirectorySeparator + 1820 'Texture' + IntToStr(Age + 1) + '.jpg'); 1821 ColorBevelLight := Colors.Canvas.Pixels[clkAge0 + Age, cliBevelLight]; 1822 ColorBevelShade := Colors.Canvas.Pixels[clkAge0 + Age, cliBevelShade]; 1823 ColorTextLight := Colors.Canvas.Pixels[clkAge0 + Age, cliTextLight]; 1824 ColorTextShade := Colors.Canvas.Pixels[clkAge0 + Age, cliTextShade]; 1825 ColorLitText := Colors.Canvas.Pixels[clkAge0 + Age, cliLitText]; 1826 ColorMark := Colors.Canvas.Pixels[clkAge0 + Age, cliMark]; 1827 ColorPage := Colors.Canvas.Pixels[clkAge0 + Age, cliPage]; 1828 ColorCover := Colors.Canvas.Pixels[clkAge0 + Age, cliCover]; 1829 end; 1830 1831 function TTexture.GetHeight: Integer; 1832 begin 1833 Result := Image.Height; 1834 end; 1835 1836 function TTexture.GetWidth: Integer; 1837 begin 1838 Result := Image.Width; 1839 end; 1840 1841 constructor TTexture.Create; 1842 begin 1843 Image := TBitmap.Create; 1844 FAge := -2; 1845 end; 1846 1847 destructor TTexture.Destroy; 1848 begin 1849 FreeAndNil(Image); 1850 inherited; 1851 end; 1852 1853 procedure TTexture.Assign(Source: TTexture); 1854 begin 1855 FAge := Source.FAge; 1856 Image.Assign(Image); 1857 ColorBevelLight := Source.ColorBevelLight; 1858 ColorBevelShade := Source.ColorBevelShade; 1859 ColorTextLight := Source.ColorTextLight; 1860 ColorTextShade := Source.ColorTextShade; 1861 ColorLitText := Source.ColorLitText; 1862 ColorMark := Source.ColorMark; 1863 ColorPage := Source.ColorPage; 1864 ColorCover := Source.ColorCover; 1822 1865 end; 1823 1866
Note:
See TracChangeset
for help on using the changeset viewer.