1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
| unit decision;
interface
uses Windows, Messages, SysUtils, Classes;
type TEtat = (eCreation,eModification,eVisualisation,eSuppression);
const EtatStr: array[TEtat] of string = (
'Création','Modification','Visualisation','Suppression');
type TGestionGroupe = class(TComponent)
private
Creation,
Modification,
Visualisation,
Suppression: Boolean;
function FLibelle:string;
procedure SetLibelle(const valeur:string);
function FItemIndex:Integer;
procedure SetItemIndex(indice:Integer);
function GetEtat: TEtat;
procedure SetEtat(const valeur:TEtat);
protected
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure SetToCreation;
procedure SetToModification;
procedure SetToVisualisation;
procedure SetToSuppression;
property ItemIndex:Integer read FItemIndex write SetItemIndex default 0;
property Libelle:string read FLibelle write SetLibelle;
published
property Etat:TEtat read GetEtat write SetEtat ;
end;
procedure Register;
implementation
constructor TGestionGroupe.Create(AOwner: TComponent);
begin
inherited;
ItemIndex:=0;
// Etat:=eCreation;
Libelle:='Création'; //EtatStr[Etat];
end;
destructor TGestionGroupe.Destroy;
begin
inherited;
end;
function TGestionGroupe.FLibelle:string;
begin
// Result:=EtatStr[Etat];
end;
procedure TGestionGroupe.SetLibelle(const valeur:string);
begin
// Libelle:=valeur;
end;
function TGestionGroupe.FItemIndex:Integer;
begin
// Result:=ItemIndex;
end;
procedure TGestionGroupe.SetItemIndex(indice:Integer);
begin
ItemIndex:=indice;
// SetEtat(TEtat(indice));
end;
function TGestionGroupe.GetEtat: TEtat;
begin
// Result:=TEtat(ItemIndex);
end;
procedure TGestionGroupe.SetEtat(const valeur:TEtat);
begin
// Etat:=valeur;
// Creation:=False ;
// Modification:=False ;
// Visualisation:=False ;
// Suppression:=False ;
// SetLibelle(EtatStr[valeur]);
// if valeur=eCreation then Creation:=true
// else if valeur=eModification then Modification:=true
// else if valeur=eVisualisation then Visualisation:=true
// else Suppression:=true ;
end;
procedure TGestionGroupe.SetToCreation;
begin
SetItemIndex(0);
end;
procedure TGestionGroupe.SetToModification;
begin
SetItemIndex(1);
end;
procedure TGestionGroupe.SetToVisualisation;
begin
SetItemIndex(2);
end;
procedure TGestionGroupe.SetToSuppression;
begin
SetItemIndex(3);
end;
procedure Register;
begin
RegisterComponents('Exemples', [TGestionGroupe]);
end;
end. |
Partager