unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls;
type
ta_type = (ta_none,
ta_naked_singles, ta_hidden_singles, ta_naked_pairs, ta_hidden_pairs,
ta_naked_triples, ta_hidden_triples, ta_pair_projection,
ta_triple_projection, ta_naked_quads, ta_hidden_quads,
ta_x_wing, ta_y_wing, ta_single_chains, ta_swordfish, ta_jellyfish,
ta_squirmbag, ta_medusa, ta_xyz_wing, ta_unique_rectangles,
ta_alt_inf_chains, ta_forcing_chains,
ta_finish);
{ TForm1 }
TForm1 = class(TForm)
Memo1: TMemo;
Panel1: TPanel;
rb_naked_singles: TRadioButton;
rb_hidden_singles: TRadioButton;
rb_naked_pairs: TRadioButton;
rb_pair_projection: TRadioButton;
rb_x_wing: TRadioButton;
rb_hidden_pairs: TRadioButton;
rb_naked_triples: TRadioButton;
rb_hidden_triples: TRadioButton;
rb_triple_projection: TRadioButton;
rb_naked_quads: TRadioButton;
rb_hidden_quads: TRadioButton;
Panel2: TPanel;
rb_single_chains: TRadioButton;
rb_y_wing: TRadioButton;
rb_swordfish: TRadioButton;
rb_jellyfish: TRadioButton;
rb_squirmbag: TRadioButton;
rb_medusa: TRadioButton;
rb_xyz_wing: TRadioButton;
rb_unique_rectangles: TRadioButton;
rb_alt_inf_chains: TRadioButton;
rb_forcing_chains: TRadioButton;
procedure FormCreate(Sender: TObject);
procedure rbclick(Sender: TObject);
private
public
focus_techs : array [ta_naked_singles..ta_finish] of tradiobutton;
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
begin
memo1.append('form create start');
focus_techs[ta_naked_singles] := rb_naked_singles;
focus_techs[ta_hidden_singles] := rb_hidden_singles;
focus_techs[ta_naked_pairs] := rb_naked_pairs;
focus_techs[ta_pair_projection] := rb_pair_projection;
focus_techs[ta_x_wing] := rb_x_wing;
focus_techs[ta_hidden_pairs] := rb_hidden_pairs;
focus_techs[ta_naked_triples] := rb_naked_triples;
focus_techs[ta_hidden_triples] := rb_hidden_triples;
focus_techs[ta_triple_projection] := rb_triple_projection;
focus_techs[ta_naked_quads] := rb_naked_quads;
focus_techs[ta_hidden_quads] := rb_hidden_quads;
focus_techs[ta_single_chains] := rb_single_chains;
focus_techs[ta_y_wing] := rb_y_wing;
focus_techs[ta_swordfish] := rb_swordfish;
focus_techs[ta_jellyfish] := rb_jellyfish;
focus_techs[ta_squirmbag] := rb_squirmbag;
focus_techs[ta_medusa] := rb_medusa;
focus_techs[ta_xyz_wing] := rb_xyz_wing;
focus_techs[ta_unique_rectangles] := rb_unique_rectangles;
focus_techs[ta_alt_inf_chains] := rb_alt_inf_chains;
focus_techs[ta_forcing_chains] := rb_forcing_chains;
focus_techs[ta_finish] := rb_naked_singles; // not used
memo1.append('form create end');
end;
procedure TForm1.rbclick(Sender: TObject);
var
ok : boolean;
a : ta_type;
begin
memo1.append('rbclick start');
ok := true;
for a := ta_naked_singles to ta_finish do
if focus_techs[a] = nil then
begin
memo1.append('focus_techs['+ord(a).tostring+'] = nil');
ok := false;
end;
if ok then
memo1.append('focus_techs[] all OK');
for a := ta_naked_singles to ta_finish do
if focus_techs[a] <> nil then
if focus_techs[a].checked then
focus_techs[a].checked := false;
a := ta_type(tradiobutton(sender).tag);
if focus_techs[a] <> nil then
begin
focus_techs[a].checked := true;
memo1.append('setting rb['+ord(a).tostring+']');
end;
memo1.append('rbclick end');
end;
end.