jvcllaz: Add NAND, NOR and XOR operations to TJvLogic.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6243 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2018-03-13 18:41:49 +00:00
parent 888b7fd2cd
commit 5338638749

View File

@ -53,7 +53,7 @@ type
TJvLogic = class; TJvLogic = class;
TJvGateStyle = (jgsDI, jgsDO); TJvGateStyle = (jgsDI, jgsDO);
TJvLogicFunc = (jlfAND, jlfOR, jlfNOT); TJvLogicFunc = (jlfAND, jlfOR, jlfNOT, jlfNAND, jlfNOR, jlfXOR);
TJvGate = record TJvGate = record
Style: TJvGateStyle; Style: TJvGateStyle;
State: Boolean; State: Boolean;
@ -1482,15 +1482,15 @@ var
I: Integer; I: Integer;
begin begin
inherited Create(AOwner); inherited Create(AOwner);
Width := 65; Width := 75;
Height := 65; Height := 65;
// initialize Gates // initialize Gates
FGates[0].Pos := Point(1, 10); FGates[0].Pos := Point(1, 10);
FGates[1].Pos := Point(1, 28); FGates[1].Pos := Point(1, 28);
FGates[2].Pos := Point(1, 46); FGates[2].Pos := Point(1, 46);
FGates[3].Pos := Point(52, 10); FGates[3].Pos := Point(62, 10);
FGates[4].Pos := Point(52, 28); FGates[4].Pos := Point(62, 28);
FGates[5].Pos := Point(52, 46); FGates[5].Pos := Point(62, 46);
for I := 0 to 5 do for I := 0 to 5 do
FGates[I].State := False; FGates[I].State := False;
for I := 0 to 2 do for I := 0 to 2 do
@ -1617,14 +1617,10 @@ begin
if FDoStyle then if FDoStyle then
begin begin
FDoStyle := False; FDoStyle := False;
case FLogicFunc of if FLogicFunc = High(TJvLogicFunc) then
jlfAND: LogicFunc := Low(TJvLogicFunc)
LogicFunc := jlfOR; else
jlfOR: LogicFunc := succ(FLogicFunc);
LogicFunc := jlfNOT;
jlfNOT:
LogicFunc := jlfAND;
end;
end; end;
BinCheck(Self); BinCheck(Self);
end; end;
@ -1707,6 +1703,7 @@ var
begin begin
with Canvas do with Canvas do
begin begin
Font.Assign(Self.Font);
Brush.Color := clSilver; Brush.Color := clSilver;
R := ClientRect; R := ClientRect;
FillRect(R); FillRect(R);
@ -1716,7 +1713,7 @@ begin
for I := 0 to 5 do for I := 0 to 5 do
PaintLed(I); PaintLed(I);
R := ClientRect; R := ClientRect;
InflateRect(R, -15, -15); InflateRect(R, -14, -14);
if FStyleDown then if FStyleDown then
Frame3D(R, clBtnShadow, clBtnHighlight, 1) Frame3D(R, clBtnShadow, clBtnHighlight, 1)
else else
@ -1729,19 +1726,25 @@ begin
S := 'OR'; // do not localize S := 'OR'; // do not localize
jlfNOT: jlfNOT:
S := 'NOT'; // do not localize S := 'NOT'; // do not localize
jlfNAND:
S := 'NAND';
jlfNOR:
S := 'NOR';
jlfXOR:
S := 'XOR';
end; end;
Brush.Style := bsClear; Brush.Style := bsClear;
ts := TextStyle; ts := TextStyle;
ts.Alignment := taCenter; ts.Alignment := taCenter;
ts.Layout := tlCenter; ts.Layout := tlCenter;
if Font.Size = 0 then Font.Size := 8;
TextRect(R, R.Left, R.Top, S, ts); TextRect(R, R.Left, R.Top, S, ts);
// DrawText(Canvas.handle, PChar(S), -1, R, DT_SINGLELINE or DT_CENTER or DT_VCENTER);
end; end;
end; end;
procedure TJvLogic.Resize; procedure TJvLogic.Resize;
begin begin
Width := 65; Width := 75;
Height := 65; Height := 65;
end; end;
@ -1766,6 +1769,12 @@ begin
Output2 := Input1 or Input3; Output2 := Input1 or Input3;
jlfNOT: jlfNOT:
Output2 := not Input2; Output2 := not Input2;
jlfNAND:
Output2 := not (Input1 and Input3);
jlfNOR:
Output2 := not (Input1 or Input3);
jlfXOR:
Output2 := Input1 xor Input3;
end; end;
end; end;
@ -1833,16 +1842,7 @@ begin
begin begin
FLogicFunc := Value; FLogicFunc := Value;
case FLogicFunc of case FLogicFunc of
jlfAND: jlfAND, jlfOR, jlfNAND, jlfNOR, jlfXOR:
begin
FGates[0].Active := True;
FGates[1].Active := False;
FGates[2].Active := True;
FGates[3].Active := False;
FGates[4].Active := True;
FGates[5].Active := False;
end;
jlfOR:
begin begin
FGates[0].Active := True; FGates[0].Active := True;
FGates[1].Active := False; FGates[1].Active := False;