procedure TMainForm.ApplyScaling(Resolution: String);
var
Grid: TStringGrid;
i, j: Integer;
CompName, PropName, PropValue: String;
Comp: TComponent;
PropInfo: PPropInfo;
ScreenWidth, ScreenHeight: Integer;
begin
// Set MainForm size based on resolution
case Resolution of
'4K': begin ScreenWidth := 3200; ScreenHeight := 1750; end;
'HiRes': begin ScreenWidth := 2560; ScreenHeight := 1540; end;
'HD': begin ScreenWidth := 1920; ScreenHeight := 1050; end;
'LoRes': begin ScreenWidth := 1366; ScreenHeight := 738; end;
else
Exit; // Invalid resolution
end;
MainForm.Width := ScreenWidth;
MainForm.Height := ScreenHeight;
// Select the correct grid based on OS and resolution
case CurrentOS of
osWindows:
case Resolution of
'4K': Grid := ScalingData.WPanels4k;
'HiRes': Grid := ScalingData.WPanelsHiRes;
'HD': Grid := ScalingData.WPanelsHD;
'LoRes': Grid := ScalingData.WPanelsLoRes;
end;
osMacOS:
case Resolution of
'4K': Grid := ScalingData.MPanels4k;
'HiRes': Grid := ScalingData.MPanelsHiRes;
'HD': Grid := ScalingData.MPanelsHD;
'LoRes': Grid := ScalingData.MPanelsLoRes;
end;
osLinux:
case Resolution of
'4K': Grid := ScalingData.LPanels4k;
'HiRes': Grid := ScalingData.LPanelsHiRes;
'HD': Grid := ScalingData.LPanelsHD;
'LoRes': Grid := ScalingData.LPanelsLoRes;
end;
else
Exit; // Fail-safe
end;
// Loop through each row (components)
for i := 1 to Grid.RowCount - 1 do
begin
CompName := Grid.Cells[0, i]; // Get component name from first column
Comp := MainForm.FindComponent(CompName);
if Assigned(Comp) then
begin
// Loop through each column (properties)
for j := 1 to Grid.ColCount - 1 do
begin
PropName := Grid.Cells[j, 0]; // Property name from header row
PropValue := Grid.Cells[j, i]; // Value from grid
// Skip the dummy "Type" column
if PropName = 'Type' then Continue;
if (Comp is TBGRALabel) and (PropName = 'Font.Size') then
begin
TBGRALabel(Comp).Font.Size := StrToIntDef(PropValue, 0);
end;
if (Comp is TBGRALabelFX) and (PropName = 'Font.Size') then
begin
TBGRALabelFX(Comp).Font.Size := StrToIntDef(PropValue, 0);
end;
if (Comp is TBGRALabel) and (PropName = 'Font.Name') then
begin
TBGRALabel(Comp).Font.Name := PropValue;
end;
if (Comp is TBGRALabelFX) and (PropName = 'Font.Name') then
begin
TBGRALabelFX(Comp).Font.Name := PropValue;
end;
// Skip empty properties
if (PropValue <> '') then
begin
PropInfo := GetPropInfo(Comp.ClassInfo, PropName);
if Assigned(PropInfo) then
begin
// Convert and apply value
case PropInfo^.PropType^.Kind of
tkInteger, tkInt64:
SetPropValue(Comp, PropName, StrToIntDef(PropValue, 0));
tkFloat:
SetPropValue(Comp, PropName, StrToFloatDef(PropValue, 0.0));
tkString, tkLString, tkAString, tkWString, tkUString:
SetPropValue(Comp, PropName, PropValue);
end;
end;
end;
end;
end;
end;
end;