home *** CD-ROM | disk | FTP | other *** search
/ Chip 1999 January / Chip_1999-01_cd.bin / zkuste / delphi / D4 / COOLFORM.ZIP / MaskEditor.pas < prev    next >
Pascal/Delphi Source File  |  1998-09-15  |  2KB  |  91 lines

  1. unit MaskEditor;
  2.  
  3. interface
  4. uses
  5.     Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  6.     ExtCtrls, maskgenerator, dsgnintf;
  7.  
  8.  
  9. type
  10.     TCoolMaskEditor = class(TPropertyEditor)
  11.         private
  12.             FValue:string;
  13.         public
  14.             destructor destroy;override;
  15.             procedure Edit;override;
  16.             function GetAttributes: TPropertyAttributes;override;
  17.             function getname:string; override;
  18.             function getValue:string; override;
  19.         published
  20.             property Value:string read FValue write FValue;
  21.     end;
  22.  
  23. var
  24.     FormCreated:boolean=false;
  25.  
  26. implementation
  27.  
  28. uses
  29.     CoolForm;
  30.  
  31. function TCoolMaskEditor.getname:string;
  32. begin
  33.     result:='Mask';
  34. end;
  35.  
  36.  
  37. function TCoolMaskEditor.getValue:string;
  38. begin
  39.     result:='Mask';
  40. end;
  41.  
  42.  
  43.  
  44. destructor TCoolMaskEditor.Destroy;
  45. begin
  46.     if Formmaskgenerator<>nil then
  47.   begin
  48.       FormMaskGenerator.Free;
  49.      FormMaskGenerator:=nil;
  50.      FormCreated:=false;
  51.     end;
  52.     inherited;
  53. end;
  54.  
  55. function TCoolMaskEditor.GetAttributes: TPropertyAttributes;
  56. begin
  57.     // Make Delphi display the (...) button in the objectinspector
  58.     Result := [paDialog];
  59. end;
  60.  
  61.  
  62. procedure TCoolMaskEditor.Edit;
  63. //******************* Unknown *************************
  64. begin
  65.     // Create the maskeditorform if it doesn`t exist yet
  66.     if not assigned(FormMaskGenerator) then
  67.     begin
  68.         formMaskGenerator:=TFormMaskGenerator.Create(nil);
  69.         formMaskGenerator.OriginalRegionData:=nil;
  70.         formMaskGenerator.SaveOriginalRegionData;
  71.         FormCreated:=true;
  72.     end;
  73.     with formMaskGenerator do
  74.     begin
  75.         // Set the existing mask in the editor
  76.         formMaskGenerator.Rgn1:=hrgn(TRegionType(GetOrdValue).Fregion);
  77.         // copy the bitmap into the editor
  78.         Image1.picture.bitmap.Assign(TRegionType(GetOrdValue).owner.picture.bitmap);
  79.         opendialog1.filename:='';
  80.         Showmodal;
  81.         // get the new region from the editor
  82.         hrgn(TRegionType(GetOrdValue).Fregion):=formMaskGenerator.Rgn1;
  83.         // note: the editorform must not be freed here
  84.         // if done, delphi eats lines of the sourcecode of the form in which coolform is used
  85.         // (every line where a visible component is defined) ... rather strange
  86.     end;
  87. end;
  88.  
  89.  
  90. end.
  91.