home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 February / Chip_2000-02_cd.bin / zkuste / Delphi / navody / tt / objvm.exe / UNITS / VisualValue.pas < prev   
Pascal/Delphi Source File  |  1998-06-26  |  2KB  |  53 lines

  1. {see TVisualValue}
  2. unit VisualValue;
  3.  
  4. interface
  5. uses LangValue,
  6.      Classes;
  7. type
  8.      {TVisualValue born to be a parent for all VCL ILangValue s }
  9.    TVisualValue=class(ILangValue)
  10.      protected
  11.        fLangOwner:IValueOwner;
  12.        fLangName:string;
  13.        procedure wrLangOwner(a:IValueOwner);
  14.      published
  15.          {Name of TVisualValue in language }
  16.        property    LangName:string read fLangName write fLangName;
  17.        constructor Create(o:TComponent);override;
  18.          {Owner of TVisualValue in language for example VM for }
  19.          {procedure a Class instance for method }
  20.        property LangOwner:IValueOwner read fLangOwner write wrLangOwner;
  21.        function CreateSame(o:TComponent):TVisualValue;virtual;
  22.      end;
  23.  
  24. type TVisualValueClass=class of TVisualValue;
  25. implementation
  26. procedure   TVisualValue.wrLangOwner;
  27.             begin
  28.               if fLangOwner<>nil then
  29.               begin
  30.                 fLangOwner.RemoveValue(Self);
  31.               end;
  32.               fLangOwner:=a;
  33.               if fLangOwner<>nil then
  34.               begin
  35.                 fLangOwner.AddValue(LangName,Self);
  36.               end;
  37.             end;
  38. constructor TVisualValue.Create;
  39.             begin
  40.               Inherited Create(o);
  41.               fLangOwner:=nil;
  42.               LangName:=Name;
  43.             end;
  44. function    TVisualValue.CreateSame;
  45.             Var c:TVisualValueClass; 
  46.             begin
  47.               c:=TVisualValueClass(ClassType);
  48.               Result:=C.Create(o);
  49.               Result.LangName:=Self.LangName;
  50.             end;
  51.  
  52. end.
  53.