mirror of
https://git.vladimir.cc/vladimir/ewsdr.git
synced 2026-08-25 18:43:51 +00:00
Refactor VFO-B top panel layout
This commit is contained in:
+24
-2
@@ -15,7 +15,7 @@ unit FreqDisplay;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Controls, Graphics, LCLType, Math;
|
||||
Classes, SysUtils, Controls, Graphics, LCLType;
|
||||
|
||||
type
|
||||
TFreqChangeEvent = procedure(Sender: TObject; NewFreq: Int64) of object;
|
||||
@@ -30,6 +30,8 @@ type
|
||||
FColorNormal: TColor;
|
||||
FColorHover: TColor;
|
||||
FColorDim: TColor;
|
||||
FMinMhzDigits: Integer;
|
||||
FDimLeadingZeros: Boolean;
|
||||
FOnChange: TFreqChangeEvent;
|
||||
|
||||
FHoverDigit: Integer; // 0=единицы .. 8=100МГц, -1=нет
|
||||
@@ -65,6 +67,8 @@ type
|
||||
property ColorNormal: TColor read FColorNormal write FColorNormal;
|
||||
property ColorHover: TColor read FColorHover write FColorHover;
|
||||
property ColorDim: TColor read FColorDim write FColorDim;
|
||||
property MinMhzDigits: Integer read FMinMhzDigits write FMinMhzDigits;
|
||||
property DimLeadingZeros: Boolean read FDimLeadingZeros write FDimLeadingZeros;
|
||||
property OnChange: TFreqChangeEvent read FOnChange write FOnChange;
|
||||
end;
|
||||
|
||||
@@ -81,6 +85,8 @@ begin
|
||||
FColorNormal := TColor($00E8F0FF);
|
||||
FColorHover := TColor($0040DDFF);
|
||||
FColorDim := TColor($00607080);
|
||||
FMinMhzDigits := 1;
|
||||
FDimLeadingZeros := False;
|
||||
FHoverDigit := -1;
|
||||
FDigitW := 14;
|
||||
FCharH := 24;
|
||||
@@ -162,6 +168,9 @@ var
|
||||
Mhz: Integer;
|
||||
KHz: Integer;
|
||||
Ones: Integer;
|
||||
MhzFmt: string;
|
||||
MhzText: string;
|
||||
LeadingMhzZeros: Integer;
|
||||
TotalW: Integer;
|
||||
StartX: Integer;
|
||||
ChW, ChH: Integer;
|
||||
@@ -194,7 +203,18 @@ begin
|
||||
Mhz := Hz div 1000000;
|
||||
KHz := (Hz div 1000) mod 1000;
|
||||
Ones := Hz mod 1000;
|
||||
S := Format('%d.%3.3d.%3.3d', [Mhz, KHz, Ones]);
|
||||
if FMinMhzDigits > 1 then
|
||||
MhzFmt := '%.' + IntToStr(FMinMhzDigits) + 'd'
|
||||
else
|
||||
MhzFmt := '%d';
|
||||
MhzText := Format(MhzFmt, [Mhz]);
|
||||
S := MhzText + Format('.%3.3d.%3.3d', [KHz, Ones]);
|
||||
|
||||
LeadingMhzZeros := 0;
|
||||
while FDimLeadingZeros and
|
||||
(LeadingMhzZeros < Length(MhzText) - 1) and
|
||||
(MhzText[LeadingMhzZeros + 1] = '0') do
|
||||
Inc(LeadingMhzZeros);
|
||||
|
||||
TotalW := C.TextWidth(S);
|
||||
StartX := (Width - TotalW) div 2;
|
||||
@@ -227,6 +247,8 @@ begin
|
||||
|
||||
if ch = '.' then
|
||||
col := FColorDim
|
||||
else if FDimLeadingZeros and (ci < LeadingMhzZeros) then
|
||||
col := FColorDim
|
||||
else if dIdx = FHoverDigit then
|
||||
col := FColorHover
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user