home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 October / Chip_2001-10_cd1.bin / zkuste / delphi / nastroje / d3456 / KBMWABD.ZIP / WABD_PropEditors.pas < prev    next >
Pascal/Delphi Source File  |  1999-05-06  |  10KB  |  399 lines

  1. unit WABD_PropEditors;
  2.  
  3. interface
  4.  
  5. uses SysUtils, Windows, Dialogs, Classes;
  6.  
  7.    procedure Register;
  8.  
  9. implementation
  10.  
  11. uses WABD_About, WABD_Objects, WABD_FormEditor, WABD_FramesetEditor, WABD_TableStrEditor, WABD_TreeEditor,
  12.       WABD_HotSpotEditor, DsgnIntf, WABD_StrListEditor;
  13.  
  14. var
  15.    FormEditor : TWABDFormEditor;
  16.    FramesetEditor : TWABDFramesetEditor;
  17.    HotSpotEditor : THSEditForm;
  18.    TreeEditor : TWABDTreeEditor;
  19.  
  20. type
  21.    TWABD_Form_Comp_Editor = class(TComponentEditor)
  22.       procedure   ExecuteVerb(Index: Integer); override;
  23.       function    GetVerb(Index: Integer): string; override;
  24.       function    GetVerbCount: Integer; override;
  25.    public
  26.       procedure   DesignForm;
  27.    end;
  28.  
  29.    TTable_Strings_Editor = class(TPropertyEditor)
  30.       procedure   Edit; override;
  31.       function    GetAttributes: TPropertyAttributes; override;
  32.       function    GetValue: string; override;
  33.    end;
  34.  
  35.    TString_List_Editor = class(TPropertyEditor)
  36.       procedure   Edit; override;
  37.       function    GetAttributes: TPropertyAttributes; override;
  38.       function    GetValue: string; override;
  39.    end;
  40.  
  41.    TWABDEditFormProperty = class(TPropertyEditor)
  42.    public
  43.       procedure Edit; override;
  44.       function  GetAttributes: TPropertyAttributes; override;
  45.       function  GetValue: string; override;
  46.       function  GetName: string; override;
  47.    end;
  48.  
  49.    TWABDEditFramesetProperty = class(TPropertyEditor)
  50.    public
  51.       procedure Edit; override;
  52.       function  GetAttributes: TPropertyAttributes; override;
  53.       function  GetValue: string; override;
  54.       function  GetName: string; override;
  55.    end;
  56.  
  57.    TWABDEditTreeNodes = class(TComponentEditor)
  58.       procedure   ExecuteVerb(Index: Integer); override;
  59.       function    GetVerb(Index: Integer): string; override;
  60.       function    GetVerbCount: Integer; override;
  61.    public
  62.       procedure   DesignForm;
  63.    end;
  64.  
  65.    TWABDEditTreeProperty = class(TPropertyEditor)
  66.    public
  67.       procedure Edit; override;
  68.       function  GetAttributes: TPropertyAttributes; override;
  69.       function  GetValue: string; override;
  70.       function  GetName: string; override;
  71.    end;
  72.  
  73.    TWABDHotSpotProperty = class(TPropertyEditor)
  74.    public
  75.       procedure Edit; override;
  76.       function  GetAttributes: TPropertyAttributes; override;
  77.       function  GetValue: string; override;
  78.    end;
  79.  
  80.    TWABDFileNameProperty = class(TStringProperty)
  81.    public
  82.       procedure Edit; override;
  83.       function  GetAttributes: TPropertyAttributes; override;
  84.       function  GetValue: string; override;
  85.    end;
  86.  
  87.    TWABDJSFunctionProperty = class(TClassProperty)
  88.    public
  89.       function GetAttributes: TPropertyAttributes; override;
  90.       function GetValue: string; override;
  91.    end;
  92.  
  93.  
  94. // ************************************************************************
  95.  
  96. procedure TWABD_Form_Comp_Editor.DesignForm;
  97. begin
  98.    if FormEditor=nil then FormEditor := TWABDFormEditor.Create(nil);
  99.    FormEditor.WABDForm := Component as TWABD_Form;
  100.    FormEditor.Designer := Designer;
  101.  
  102.    FormEditor.Initialize;
  103.    FormEditor.Show;
  104. end;
  105.  
  106. procedure TWABD_Form_Comp_Editor.ExecuteVerb(Index: Integer);
  107. begin
  108.    case Index of
  109.       0: DesignForm;
  110.    end;
  111. end;
  112.  
  113. function TWABD_Form_Comp_Editor.GetVerb(Index: Integer): string;
  114. begin
  115.    case Index of
  116.       0: Result := '&Design WABD Form...';
  117.    end;
  118. end;
  119.  
  120. function TWABD_Form_Comp_Editor.GetVerbCount: Integer;
  121. begin
  122.    Result := 1;
  123. end;
  124.  
  125.  
  126. // ************************************************************************
  127.  
  128. procedure TTable_Strings_Editor.Edit;
  129. var
  130.    d : TTableStrings_Editor;
  131. begin
  132.    d := TTableStrings_Editor.Create(nil);
  133.    try
  134.       d.EditStrings(TWABD_Table_Strings(GetOrdValue));
  135.       SetOrdValue(GetOrdValue);
  136.    finally
  137.       d.Free;
  138.    end;
  139. end;
  140.  
  141. function TTable_Strings_Editor.GetAttributes: TPropertyAttributes;
  142. begin
  143.    Result := [paDialog];
  144. end;
  145.  
  146. function TTable_Strings_Editor.GetValue: string;
  147. begin
  148.    Result := '(Table Strings)';
  149. end;
  150.  
  151. // ************************************************************************
  152.  
  153. procedure TString_List_Editor.Edit;
  154. var
  155.    d : TStringList_Editor;
  156.    S: TStrings;
  157.    n: Integer;
  158. begin
  159.      d := TStringList_Editor.Create(nil);
  160.      try
  161.         S := TStrings(Pointer(GetOrdValue));
  162.         D.Caption := 'Edit - '+ GetName;
  163.         D.Memo.Lines.Text := S.Text;
  164.         D.ShowModal;
  165.         for n := 0 to PropCount-1 do begin
  166.           S := TStrings(Pointer(GetOrdValueAt(n)));
  167.           S.Text := D.Memo.Lines.Text;
  168.         end;
  169.         try
  170.           Modified;
  171.         except
  172.         end;
  173.      finally
  174.         d.Free;
  175.      end;
  176. end;
  177.  
  178. function TString_List_Editor.GetAttributes: TPropertyAttributes;
  179. begin
  180.    Result := [paDialog];
  181. end;
  182.  
  183. function TString_List_Editor.GetValue: string;
  184. begin
  185.    Result := '(Strings)';
  186. end;
  187.  
  188. // ************************************************************************
  189.  
  190. function TWABDEditFormProperty.GetAttributes: TPropertyAttributes;
  191. begin
  192.    Result := [paDialog];
  193. end;
  194.  
  195. function TWABDEditFormProperty.GetValue: string;
  196. begin
  197.    Result := '(Click_Me)';
  198. end;
  199.  
  200. function TWABDEditFormProperty.GetName: string;
  201. begin
  202.    Result := 'Edit Form';
  203. end;
  204.  
  205. procedure TWABDEditFormProperty.Edit;
  206. begin
  207.    if FormEditor=nil then FormEditor := TWABDFormEditor.Create(nil);
  208.    FormEditor.WABDForm := TWABDEditForm(GetOrdValue).ParForm;
  209.    FormEditor.Designer := Designer;
  210.  
  211.    FormEditor.Initialize;
  212.    FormEditor.Show;
  213. end;
  214.  
  215. // ************************************************************************
  216.  
  217. function TWABDEditFramesetProperty.GetAttributes: TPropertyAttributes;
  218. begin
  219.    Result := [paDialog];
  220. end;
  221.  
  222. function TWABDEditFramesetProperty.GetValue: string;
  223. begin
  224.    Result := '(Click_Me)';
  225. end;
  226.  
  227. function TWABDEditFramesetProperty.GetName: string;
  228. begin
  229.    Result := 'Edit Frameset';
  230. end;
  231.  
  232. procedure TWABDEditFramesetProperty.Edit;
  233. begin
  234.    if FramesetEditor=nil then FramesetEditor := TWABDFramesetEditor.Create(nil);
  235.    FramesetEditor.WABDFrameset := TWABDEditFrameset(GetOrdValue).ParFrameset;
  236.    FramesetEditor.Designer := Designer;
  237.  
  238.    FramesetEditor.Initialize;
  239.    FramesetEditor.Show;
  240. end;
  241.  
  242. // ************************************************************************
  243.  
  244. procedure TWABDEditTreeNodes.DesignForm;
  245. begin
  246.    if TreeEditor=nil then TreeEditor := TWABDTreeEditor.Create(nil);
  247.    TreeEditor.ParTree := Component as TWABD_Tree;
  248.    TreeEditor.Designer := Designer;
  249.  
  250.    TreeEditor.Init;
  251.    TreeEditor.Show;
  252. end;
  253.  
  254. procedure TWABDEditTreeNodes.ExecuteVerb(Index: Integer);
  255. begin
  256.    case Index of
  257.       0: DesignForm;
  258.    end;
  259. end;
  260.  
  261. function TWABDEditTreeNodes.GetVerb(Index: Integer): string;
  262. begin
  263.    case Index of
  264.       0: Result := '&Design WABD Tree structure...';
  265.    end;
  266. end;
  267.  
  268. function TWABDEditTreeNodes.GetVerbCount: Integer;
  269. begin
  270.    Result := 1;
  271. end;
  272.  
  273. // ************************************************************************
  274.  
  275. function TWABDEditTreeProperty.GetAttributes: TPropertyAttributes;
  276. begin
  277.    Result := [paDialog];
  278. end;
  279.  
  280. function TWABDEditTreeProperty.GetValue: string;
  281. begin
  282.    Result := '(Click_Me)';
  283. end;
  284.  
  285. function TWABDEditTreeProperty.GetName: string;
  286. begin
  287.    Result := 'Edit Tree';
  288. end;
  289.  
  290. procedure TWABDEditTreeProperty.Edit;
  291. begin
  292.    if TreeEditor=nil then TreeEditor := TWABDTreeEditor.Create(nil);
  293.    TreeEditor.Designer := Designer;
  294.    TreeEditor.ParTree := TWABDEditTree(GetOrdValue).ParTree;
  295.  
  296.    TreeEditor.Init;
  297.    TreeEditor.Show;
  298. end;
  299.  
  300. // ************************************************************************
  301.  
  302. procedure TWABDHotSpotProperty.Edit;
  303. begin
  304.    if HotSpotEditor=nil then HotSpotEditor := THSEditForm.Create(nil);
  305.    HotSpotEditor.Designer := Designer;
  306.    HotSpotEditor.ParImage := TWABD_HotSpots(GetOrdValue).ParImage;
  307.  
  308.    HotSpotEditor.Init;
  309.    HotSpotEditor.Show;
  310. end;
  311.  
  312. function  TWABDHotSpotProperty.GetAttributes: TPropertyAttributes;
  313. begin
  314.    Result := [paDialog];
  315. end;
  316.  
  317. function  TWABDHotSpotProperty.GetValue: string;
  318. begin
  319.    Result := '(Click_Me)';
  320. end;
  321.  
  322.  
  323. // ************************************************************************
  324.  
  325. function  TWABDJSFunctionProperty.GetAttributes: TPropertyAttributes;
  326. begin
  327.    Result := [paSubProperties,paReadOnly];
  328. end;
  329.  
  330. function TWABDJSFunctionProperty.GetValue: string;
  331. var
  332.    p:pointer;
  333.    f:TWABD_JS_Function;
  334. begin
  335.      p:=Pointer(GetOrdValue);
  336.      if (p = nil) then Result:=''
  337.      else begin
  338.         f:=TWABD_JS_Function(p);
  339.         Result:=f.Script;
  340.      end;
  341. end;
  342.  
  343. // ************************************************************************
  344.  
  345. procedure TWABDFileNameProperty.Edit;
  346. var
  347.   fo: TOpenDialog;
  348. begin
  349.   fo := TOpenDialog.Create(nil);
  350.   fo.Filename := GetValue;
  351.   fo.Options := [ofPathMustExist,ofFileMustExist];
  352.   try
  353.     if fo.Execute then SetValue(fo.Filename);
  354.   finally
  355.     fo.Free;
  356.   end;
  357. end;
  358.  
  359. function  TWABDFileNameProperty.GetAttributes: TPropertyAttributes;
  360. begin
  361.    Result := [paDialog];
  362. end;
  363.  
  364. function  TWABDFileNameProperty.GetValue: string;
  365. begin
  366.    Result := GetStrValue;
  367. end;
  368.  
  369.  
  370. // ************************************************************************
  371.  
  372. procedure Register;
  373. begin
  374.    RegisterComponentEditor(TWABD_Form, TWABD_Form_Comp_Editor);
  375.    RegisterPropertyEditor(TypeInfo(TWABD_Table_Strings), nil, '', TTable_Strings_Editor);
  376.    RegisterPropertyEditor(TypeInfo(TStrings), nil, '', TString_List_Editor);
  377.    RegisterPropertyEditor(TypeInfo(TWABDAbout), NIL, '', TWABDAboutProperty);
  378.    RegisterPropertyEditor(TypeInfo(TWABDEditForm), NIL, '', TWABDEditFormProperty);
  379.    RegisterPropertyEditor(TypeInfo(TWABDEditFrameset), NIL, '', TWABDEditFramesetProperty);
  380.    RegisterPropertyEditor(TypeInfo(TWABD_HotSpots), NIL, '', TWABDHotSpotProperty);
  381.    RegisterPropertyEditor(TypeInfo(TFileName), TWABD_Base_Image, '', TWABDFileNameProperty);
  382.    RegisterPropertyEditor(TypeInfo(TWABD_JS_Function), nil, '', TWABDJSFunctionProperty);
  383.  
  384.    RegisterComponentEditor(TWABD_Tree, TWABDEditTreeNodes);
  385.    RegisterPropertyEditor(TypeInfo(TWABDEditTree), NIL, '', TWABDEditTreeProperty);
  386. end;
  387.  
  388. initialization
  389.    FormEditor := nil;
  390.    FramesetEditor := nil;
  391.    HotSpotEditor := nil;
  392.    TreeEditor := nil;
  393. finalization
  394.    FormEditor.Free;
  395.    FramesetEditor.Free;
  396.    HotSpotEditor.Free;
  397.    TreeEditor.Free;
  398. end.
  399.