Extract main status bar component

This commit is contained in:
2026-05-21 21:27:43 +03:00
parent 36fa914e2f
commit 3bf8c1c162
2 changed files with 193 additions and 70 deletions
+6 -70
View File
@@ -31,6 +31,7 @@ uses
WebServer,
CATEngine, CATSerial, CATTcp,
SpectrumView,
StatusBar,
WinFirewall;
const
@@ -435,9 +436,7 @@ type
PbWaterfall: TPaintBox;
// ---- Status bar ----
StatusPanel: TPanel;
StatusCells: array[0..7] of TPanel;
StatusLabels: array[0..7] of TLabel;
StatusPanel: TMainStatusBar;
// ---- Helpers ----
procedure BuildUI;
@@ -1529,30 +1528,6 @@ var
L.Font.Size := 7;
end;
procedure MakeStatusCell(Index, CellWidth: Integer; const Cap: string);
begin
StatusCells[Index] := TPanel.Create(Self);
StatusCells[Index].Parent := StatusPanel;
StatusCells[Index].BevelOuter := bvNone;
StatusCells[Index].Align := alLeft;
StatusCells[Index].Width := CellWidth;
StatusCells[Index].BorderSpacing.Left := 1;
StatusCells[Index].BorderSpacing.Top := 1;
StatusCells[Index].BorderSpacing.Bottom := 1;
StatusLabels[Index] := TLabel.Create(Self);
StatusLabels[Index].Parent := StatusCells[Index];
StatusLabels[Index].AutoSize := False;
StatusLabels[Index].Align := alClient;
StatusLabels[Index].BorderSpacing.Left := 8;
StatusLabels[Index].BorderSpacing.Right := 8;
StatusLabels[Index].Alignment := taLeftJustify;
StatusLabels[Index].Layout := tlCenter;
StatusLabels[Index].Caption := Cap;
StatusLabels[Index].Font.Name := 'Courier New';
StatusLabels[Index].Font.Size := 8;
end;
begin
// ---- Toolbar ----
PanelToolbar := TPanel.Create(Self);
@@ -1583,23 +1558,8 @@ begin
// ---- Separator line ----
// ---- Status bar ----
StatusPanel := TPanel.Create(Self);
StatusPanel := TMainStatusBar.Create(Self);
StatusPanel.Parent := Self;
StatusPanel.Align := alBottom;
StatusPanel.Height := 26;
StatusPanel.BevelOuter := bvNone;
// alLeft controls are arranged by Z-order in LCL; create them in reverse
// visual order so the final bar reads left-to-right as intended.
MakeStatusCell(6, 130, 'SEQ --');
MakeStatusCell(5, 180, 'TX idle');
MakeStatusCell(4, 190, 'RX idle');
MakeStatusCell(7, 90, 'PLL --');
MakeStatusCell(3, 150, 'Supply --');
MakeStatusCell(1, 120, 'IP --');
MakeStatusCell(0, 220, 'Board --');
MakeStatusCell(2, 170, 'Disconnected');
StatusCells[6].Align := alClient;
// ---- Left panel ----
PanelLeft := TPanel.Create(Self);
@@ -2608,10 +2568,8 @@ end;
procedure TMainForm.SetStatusText(Index: Integer; const Text: string);
begin
if (Index < Low(StatusLabels)) or (Index > High(StatusLabels)) then Exit;
if StatusLabels[Index] = nil then Exit;
if StatusLabels[Index].Caption <> Text then
StatusLabels[Index].Caption := Text;
if StatusPanel = nil then Exit;
StatusPanel.SetStatusText(Index, Text);
end;
procedure TMainForm.SetRadioOfflineStatus(const ConnText: string; ClearDevice: Boolean);
@@ -2639,31 +2597,9 @@ begin
end;
procedure TMainForm.ApplyStatusTheme(const T: TAppTheme);
var
I: Integer;
begin
if StatusPanel = nil then Exit;
StatusPanel.Color := T.Border;
for I := Low(StatusCells) to High(StatusCells) do
begin
if StatusCells[I] <> nil then
begin
StatusCells[I].Color := T.Panel;
StatusCells[I].Font.Color := T.Text;
end;
if StatusLabels[I] <> nil then
begin
if I in [4, 5] then
StatusLabels[I].Font.Color := T.TextDim
else if I = 6 then
StatusLabels[I].Font.Color := T.Amber
else if I = 2 then
StatusLabels[I].Font.Color := T.TbStartText
else
StatusLabels[I].Font.Color := T.Text;
StatusLabels[I].Color := T.Panel;
end;
end;
StatusPanel.ApplyTheme(T);
end;
procedure TMainForm.SetLightTheme(V: Boolean);