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

  1. unit WABD_Reg;
  2.  
  3. {$include kbmWABD.inc}
  4.  
  5. interface
  6.  
  7. uses
  8.     Classes,
  9.     WABD_Objects,
  10. {$ifdef LEVEL6}
  11.     PropertyCategories,
  12.     DesignEditors,
  13.     DesignIntf
  14. {$else}
  15.     DsgnIntf
  16. {$endif}
  17. ;
  18.  
  19. type
  20.    TWABDAboutProperty = class(TClassProperty)
  21.    public
  22.       procedure Edit; override;
  23.       function  GetAttributes: TPropertyAttributes; override;
  24.       function  GetValue: string; override;
  25.    end;
  26.  
  27.    TWABD_Form_Comp_Editor = class(TComponentEditor)
  28.       procedure   ExecuteVerb(Index: Integer); override;
  29.       function    GetVerb(Index: Integer): string; override;
  30.       function    GetVerbCount: Integer; override;
  31.    public
  32.       procedure   DesignForm;
  33.    end;
  34.  
  35.    TTable_Strings_Editor = class(TPropertyEditor)
  36.       procedure   Edit; override;
  37.       function    GetAttributes: TPropertyAttributes; override;
  38.       function    GetValue: string; override;
  39.    end;
  40.  
  41.    TString_List_Editor = class(TPropertyEditor)
  42.       procedure   Edit; override;
  43.       function    GetAttributes: TPropertyAttributes; override;
  44.       function    GetValue: string; override;
  45.    end;
  46.  
  47.    TWABDEditFormProperty = class(TPropertyEditor)
  48.    public
  49.       procedure Edit; override;
  50.       function  GetAttributes: TPropertyAttributes; override;
  51.       function  GetValue: string; override;
  52.       function  GetName: string; override;
  53.    end;
  54.  
  55.    TWABDEditFramesetProperty = class(TPropertyEditor)
  56.    public
  57.       procedure Edit; override;
  58.       function  GetAttributes: TPropertyAttributes; override;
  59.       function  GetValue: string; override;
  60.       function  GetName: string; override;
  61.    end;
  62.  
  63.    TWABDEditTreeNodes = class(TComponentEditor)
  64.       procedure   ExecuteVerb(Index: Integer); override;
  65.       function    GetVerb(Index: Integer): string; override;
  66.       function    GetVerbCount: Integer; override;
  67.    public
  68.       procedure   DesignForm;
  69.    end;
  70.  
  71.    TWABDEditTreeProperty = class(TPropertyEditor)
  72.    public
  73.       procedure Edit; override;
  74.       function  GetAttributes: TPropertyAttributes; override;
  75.       function  GetValue: string; override;
  76.       function  GetName: string; override;
  77.    end;
  78.  
  79.    TWABDHotSpotProperty = class(TPropertyEditor)
  80.    public
  81.       procedure Edit; override;
  82.       function  GetAttributes: TPropertyAttributes; override;
  83.       function  GetValue: string; override;
  84.    end;
  85.  
  86.    TWABDFileNameProperty = class(TStringProperty)
  87.    public
  88.       procedure Edit; override;
  89.       function  GetAttributes: TPropertyAttributes; override;
  90.       function  GetValue: string; override;
  91.    end;
  92.  
  93.    TWABDJSFunctionProperty = class(TClassProperty)
  94.    public
  95.       function GetAttributes: TPropertyAttributes; override;
  96.       function GetValue: string; override;
  97.    end;
  98.  
  99.    procedure Register;
  100.  
  101.    procedure RegisterWABDComponent(WABDClass: TWABD_ObjectClass);
  102.    procedure RegisterWABDComponents(WABDClasses: array of TWABD_ObjectClass);
  103.    function  GetWABDClassListCount: integer;
  104.    function  GetWABDClassListItem(i: integer): TWABD_ObjectClass;
  105.  
  106.  
  107. var
  108.    WABDClassList         : TList;
  109.  
  110. implementation
  111.  
  112. uses
  113.      Dialogs,
  114.      Forms,
  115.      SysUtils,
  116.      WABD_About,
  117.      WABD_FormEditor,
  118.      WABD_FormSecEditor,
  119.      WABD_FramesetEditor,
  120.      WABD_HotspotEditor,
  121.      WABD_StrListEditor,
  122.      WABD_TableStrEditor,
  123.      WABD_TreeEditor,
  124.      WABD_EditTable;
  125.  
  126. var
  127.    FormEditor            : TWABDFormEditor;
  128.    FramesetEditor        : TWABDFramesetEditor;
  129.    HotSpotEditor         : THSEditForm;
  130.    TreeEditor            : TWABDTreeEditor;
  131.  
  132. // ************************************************************************
  133. // About box property editor.
  134. // ************************************************************************
  135.  
  136. procedure TWABDAboutProperty.Edit;
  137. var
  138.    f : TWABDAboutForm;
  139. begin
  140.    f := TWABDAboutForm.Create(Application);
  141.    try
  142.       f.ShowModal;
  143.       Modified;
  144.    finally
  145.       f.Free;
  146.    end;
  147. end;
  148.  
  149. function TWABDAboutProperty.GetValue: string;
  150. begin
  151.    Result := '(Click Me)';
  152. end;
  153.  
  154. function TWABDAboutProperty.GetAttributes: TPropertyAttributes;
  155. begin
  156.    Result := [paDialog];
  157. end;
  158.  
  159. // ************************************************************************
  160. // Form property editor.
  161. // ************************************************************************
  162.  
  163. procedure TWABD_Form_Comp_Editor.DesignForm;
  164. begin
  165.    if FormEditor=nil then FormEditor := TWABDFormEditor.Create(nil);
  166.    FormEditor.WABDForm := Component as TWABD_Form;
  167.    FormEditor.MyDesigner := Designer;
  168.  
  169.    FormEditor.Initialize;
  170.    FormEditor.Show;
  171. end;
  172.  
  173. procedure TWABD_Form_Comp_Editor.ExecuteVerb(Index: Integer);
  174. begin
  175.    case Index of
  176.       0: DesignForm;
  177.    end;
  178. end;
  179.  
  180. function TWABD_Form_Comp_Editor.GetVerb(Index: Integer): string;
  181. begin
  182.    case Index of
  183.       0: Result := '&Design WABD Form...';
  184.    end;
  185. end;
  186.  
  187. function TWABD_Form_Comp_Editor.GetVerbCount: Integer;
  188. begin
  189.    Result := 1;
  190. end;
  191.  
  192. // ************************************************************************
  193. // Table strings property editor.
  194. // ************************************************************************
  195.  
  196. procedure TTable_Strings_Editor.Edit;
  197. var
  198.    d : TTableStrings_Editor;
  199. begin
  200.    d := TTableStrings_Editor.Create(nil);
  201.    try
  202.       d.EditStrings(TWABD_Table_Strings(GetOrdValue));
  203.       SetOrdValue(GetOrdValue);
  204.    finally
  205.       d.Free;
  206.    end;
  207. end;
  208.  
  209. function TTable_Strings_Editor.GetAttributes: TPropertyAttributes;
  210. begin
  211.    Result := [paDialog];
  212. end;
  213.  
  214. function TTable_Strings_Editor.GetValue: string;
  215. begin
  216.    Result := '(Table Strings)';
  217. end;
  218.  
  219. // ************************************************************************
  220. // TStrings property editor.
  221. // ************************************************************************
  222.  
  223. procedure TString_List_Editor.Edit;
  224. var
  225.    d : TStringList_Editor;
  226.    S: TStrings;
  227.    n: Integer;
  228. begin
  229.      d := TStringList_Editor.Create(nil);
  230.      try
  231.         S := TStrings(Pointer(GetOrdValue));
  232.         D.Caption := 'Edit - '+ GetName;
  233.         D.Memo.Lines.Text := S.Text;
  234.         D.ShowModal;
  235.         for n := 0 to PropCount-1 do begin
  236.           S := TStrings(Pointer(GetOrdValueAt(n)));
  237.           S.Text := D.Memo.Lines.Text;
  238.         end;
  239.         try
  240.           Modified;
  241.         except
  242.         end;
  243.      finally
  244.         d.Free;
  245.      end;
  246. end;
  247.  
  248. function TString_List_Editor.GetAttributes: TPropertyAttributes;
  249. begin
  250.    Result := [paDialog];
  251. end;
  252.  
  253. function TString_List_Editor.GetValue: string;
  254. begin
  255.    Result := '(Strings)';
  256. end;
  257.  
  258. // ************************************************************************
  259. // Form property editor.
  260. // ************************************************************************
  261.  
  262. function TWABDEditFormProperty.GetAttributes: TPropertyAttributes;
  263. begin
  264.    Result := [paDialog];
  265. end;
  266.  
  267. function TWABDEditFormProperty.GetValue: string;
  268. begin
  269.    Result := '(Click_Me)';
  270. end;
  271.  
  272. function TWABDEditFormProperty.GetName: string;
  273. begin
  274.    Result := 'Edit Form';
  275. end;
  276.  
  277. procedure TWABDEditFormProperty.Edit;
  278. begin
  279.    if FormEditor=nil then FormEditor := TWABDFormEditor.Create(nil);
  280.    FormEditor.WABDForm := TWABDEditForm(GetOrdValue).ParForm;
  281.    FormEditor.MyDesigner := Designer;
  282.  
  283.    FormEditor.Initialize;
  284.    FormEditor.Show;
  285. end;
  286.  
  287. // ************************************************************************
  288. // Frameset property editor.
  289. // ************************************************************************
  290.  
  291. function TWABDEditFramesetProperty.GetAttributes: TPropertyAttributes;
  292. begin
  293.    Result := [paDialog];
  294. end;
  295.  
  296. function TWABDEditFramesetProperty.GetValue: string;
  297. begin
  298.    Result := '(Click_Me)';
  299. end;
  300.  
  301. function TWABDEditFramesetProperty.GetName: string;
  302. begin
  303.    Result := 'Edit Frameset';
  304. end;
  305.  
  306. procedure TWABDEditFramesetProperty.Edit;
  307. begin
  308.    if FramesetEditor=nil then FramesetEditor := TWABDFramesetEditor.Create(nil);
  309.    FramesetEditor.WABDFrameset := TWABDEditFrameset(GetOrdValue).ParFrameset;
  310.    FramesetEditor.MyDesigner := Designer;
  311.  
  312.    FramesetEditor.Initialize;
  313.    FramesetEditor.Show;
  314. end;
  315.  
  316. // ************************************************************************
  317. // Tree nodes property editor.
  318. // ************************************************************************
  319.  
  320. procedure TWABDEditTreeNodes.DesignForm;
  321. begin
  322.    if TreeEditor=nil then TreeEditor := TWABDTreeEditor.Create(nil);
  323.    TreeEditor.ParTree := Component as TWABD_Tree;
  324.    TreeEditor.MyDesigner := Designer;
  325.  
  326.    TreeEditor.Init;
  327.    TreeEditor.Show;
  328. end;
  329.  
  330. procedure TWABDEditTreeNodes.ExecuteVerb(Index: Integer);
  331. begin
  332.    case Index of
  333.       0: DesignForm;
  334.    end;
  335. end;
  336.  
  337. function TWABDEditTreeNodes.GetVerb(Index: Integer): string;
  338. begin
  339.    case Index of
  340.       0: Result := '&Design WABD Tree structure...';
  341.    end;
  342. end;
  343.  
  344. function TWABDEditTreeNodes.GetVerbCount: Integer;
  345. begin
  346.    Result := 1;
  347. end;
  348.  
  349. // ************************************************************************
  350. // Tree property editor.
  351. // ************************************************************************
  352.  
  353. function TWABDEditTreeProperty.GetAttributes: TPropertyAttributes;
  354. begin
  355.    Result := [paDialog];
  356. end;
  357.  
  358. function TWABDEditTreeProperty.GetValue: string;
  359. begin
  360.    Result := '(Click_Me)';
  361. end;
  362.  
  363. function TWABDEditTreeProperty.GetName: string;
  364. begin
  365.    Result := 'Edit Tree';
  366. end;
  367.  
  368. procedure TWABDEditTreeProperty.Edit;
  369. begin
  370.    if TreeEditor=nil then TreeEditor := TWABDTreeEditor.Create(nil);
  371.    TreeEditor.MyDesigner := Designer;
  372.    TreeEditor.ParTree := TWABDEditTree(GetOrdValue).ParTree;
  373.  
  374.    TreeEditor.Init;
  375.    TreeEditor.Show;
  376. end;
  377.  
  378. // ************************************************************************
  379. // Hotspot property editor.
  380. // ************************************************************************
  381.  
  382. procedure TWABDHotSpotProperty.Edit;
  383. begin
  384.    if HotSpotEditor=nil then HotSpotEditor := THSEditForm.Create(nil);
  385.    HotSpotEditor.MyDesigner := Designer;
  386.    HotSpotEditor.ParImage := TWABD_HotSpots(GetOrdValue).ParImage;
  387.  
  388.    HotSpotEditor.Init;
  389.    HotSpotEditor.Show;
  390. end;
  391.  
  392. function  TWABDHotSpotProperty.GetAttributes: TPropertyAttributes;
  393. begin
  394.    Result := [paDialog];
  395. end;
  396.  
  397. function  TWABDHotSpotProperty.GetValue: string;
  398. begin
  399.    Result := '(Click_Me)';
  400. end;
  401.  
  402. // ************************************************************************
  403. // JSFunction property editor.
  404. // ************************************************************************
  405.  
  406. function  TWABDJSFunctionProperty.GetAttributes: TPropertyAttributes;
  407. begin
  408.    Result := [paSubProperties,paReadOnly];
  409. end;
  410.  
  411. function TWABDJSFunctionProperty.GetValue: string;
  412. var
  413.    p:pointer;
  414.    f:TWABD_JS_Function;
  415. begin
  416.      p:=Pointer(GetOrdValue);
  417.      if (p = nil) then Result:=''
  418.      else begin
  419.         f:=TWABD_JS_Function(p);
  420.         Result:=f.Script;
  421.      end;
  422. end;
  423.  
  424. // ************************************************************************
  425. // Filename property editor.
  426. // ************************************************************************
  427.  
  428. procedure TWABDFileNameProperty.Edit;
  429. var
  430.   fo: TOpenDialog;
  431. begin
  432.   fo := TOpenDialog.Create(nil);
  433.   fo.Filename := GetValue;
  434.   fo.Options := [ofPathMustExist,ofFileMustExist];
  435.   try
  436.     if fo.Execute then SetValue(fo.Filename);
  437.   finally
  438.     fo.Free;
  439.   end;
  440. end;
  441.  
  442. function  TWABDFileNameProperty.GetAttributes: TPropertyAttributes;
  443. begin
  444.    Result := [paDialog];
  445. end;
  446.  
  447. function  TWABDFileNameProperty.GetValue: string;
  448. begin
  449.    Result := GetStrValue;
  450. end;
  451.  
  452. // ************************************************************************
  453. // RegisterWABDComponent - so you can create your own HTML components!
  454. // ************************************************************************
  455.  
  456. procedure RegisterWABDComponents(WABDClasses: array of TWABD_ObjectClass);
  457. var
  458.    i : integer;
  459. begin
  460.    for i := Low(WABDClasses) to High(WABDClasses) do begin
  461.       RegisterWABDComponent(WABDClasses[i]);
  462.    end;
  463. end;
  464.  
  465. procedure RegisterWABDComponent(WABDClass: TWABD_ObjectClass);
  466. begin
  467.    if WABDClassList.IndexOf(WABDClass) = -1 then
  468.       WABDClassList.Add(WABDClass);
  469.    RegisterClasses([WABDClass]);
  470. end;
  471.  
  472. function GetWABDClassListCount: integer;
  473. begin
  474.    Result := WABDClassList.Count;
  475. end;
  476.  
  477. function GetWABDClassListItem(i: integer): TWABD_ObjectClass;
  478. begin
  479.    if (i < 0) or (i >= GetWABDClassListCount) then
  480.       Result := nil
  481.    else
  482.       Result := WABDClassList.Items[i];
  483. end;
  484.  
  485.  
  486. // ************************************************************************
  487. // Registration
  488. // ************************************************************************
  489.  
  490. procedure Register;
  491. begin
  492.    RegisterComponentEditor(TWABD_Form, TWABD_Form_Comp_Editor);
  493.    RegisterPropertyEditor(TypeInfo(TWABD_Table_Strings), nil, '', TTable_Strings_Editor);
  494.    RegisterPropertyEditor(TypeInfo(TStrings), nil, '', TString_List_Editor);
  495.    RegisterPropertyEditor(TypeInfo(TWABDAbout), NIL, '', TWABDAboutProperty);
  496.    RegisterPropertyEditor(TypeInfo(TWABDEditForm), NIL, '', TWABDEditFormProperty);
  497.    RegisterPropertyEditor(TypeInfo(TWABDEditFrameset), NIL, '', TWABDEditFramesetProperty);
  498.    RegisterPropertyEditor(TypeInfo(TWABD_HotSpots), NIL, '', TWABDHotSpotProperty);
  499.    RegisterPropertyEditor(TypeInfo(TFileName), TWABD_Base_Image, '', TWABDFileNameProperty);
  500.    RegisterPropertyEditor(TypeInfo(TWABD_JS_Function), nil, '', TWABDJSFunctionProperty);
  501.  
  502.    RegisterComponentEditor(TWABD_Tree, TWABDEditTreeNodes);
  503.    RegisterPropertyEditor(TypeInfo(TWABDEditTree), NIL, '', TWABDEditTreeProperty);
  504.  
  505.    RegisterComponents('kbmWABD', [
  506.       TWABD_SessionMgr,
  507.       TWABD_Session,
  508.       TWABD_Admin,
  509.       TWABD_Setup,
  510.       TWABD_Frameset,
  511.       TWABD_Frame,
  512.       TWABD_ExternalFrame,
  513.       TWABD_MenuTree,
  514.       TWABD_Form,
  515.       TWABD_HTML,
  516.       TWABD_HTMLFile,
  517.       TWABD_Javascript]);
  518.  
  519.    RegisterNoIcon([
  520.       TWABD_FormSection,
  521.       TWABD_Header,
  522.       TWABD_HTMLSection,
  523.       TWABD_HTMLFileSection,
  524.       TWABD_Expires,
  525.       TWABD_Autorefresh,
  526.       TWABD_Autoload,
  527.       TWABD_Table,
  528.       TWABD_DataTable,
  529.       TWABD_EditTable,
  530.       TWABD_DBEditTable,
  531.       TWABD_Hidden,
  532.       TWABD_BlankLines,
  533.  
  534.       TWABD_Anchor,
  535.       TWABD_Image,
  536.       TWABD_LiveImage,
  537.       TWABD_HotSpot,
  538.       TWABD_TreeNode,
  539.       TWABD_Label,
  540.       TWABD_HTMLEmbed,
  541.       TWABD_HTMLFileEmbed,
  542.       TWABD_Memo,
  543.       TWABD_Button,
  544.       TWABD_Edit,
  545.       TWABD_ComboBox,
  546.       TWABD_RadioButton,
  547.       TWABD_ListBox,
  548.       TWABD_CheckBox,
  549.       TWABD_Chart,
  550. {      TWABD_DBNavigator, }
  551.       TWABD_UploadFile]);
  552. end;
  553.  
  554. initialization
  555.    Randomize;
  556.    WABDClassList := TList.Create;
  557.    IsMultiThread := true;
  558.  
  559.    FormEditor := nil;
  560.    FramesetEditor := nil;
  561.    HotSpotEditor := nil;
  562.    TreeEditor := nil;
  563.  
  564.    RegisterWABDComponents([
  565.       TWABD_FormSection,
  566.       TWABD_Header,
  567.       TWABD_HTMLSection,
  568.       TWABD_HTMLFileSection,
  569.       TWABD_Autoload,
  570.       TWABD_Expires,
  571.       TWABD_AutoRefresh,
  572.       TWABD_Table,
  573.       TWABD_DataTable,
  574.       TWABD_Hidden,
  575.       TWABD_BlankLines,
  576.       TWABD_EditTable,
  577. {      TWABD_DBNavigator, }
  578.       TWABD_DBEditTable]);
  579.  
  580.    RegisterClasses([
  581.       TWABD_Admin,
  582.       TWABD_Setup,
  583.       TWABD_Frameset,
  584.       TWABD_Frame,
  585.       TWABD_ExternalFrame,
  586.       TWABD_FormSection,
  587.       TWABD_Header,
  588.       TWABD_HTMLSection,
  589.       TWABD_HTMLFileSection,
  590.       TWABD_JS_Function,
  591.       TWABD_Autoload,
  592.       TWABD_Expires,
  593.       TWABD_AutoRefresh,
  594.       TWABD_Table,
  595.       TWABD_DataTable,
  596.       TWABD_Hidden,
  597.       TWABD_BlankLines,
  598.  
  599.       TWABD_Anchor,
  600.       TWABD_Image,
  601.       TWABD_LiveImage,
  602.       TWABD_HotSpot,
  603.       TWABD_TreeNode,
  604.       TWABD_Label,
  605.       TWABD_HTMLEmbed,
  606.       TWABD_HTMLFileEmbed,
  607.       TWABD_Memo,
  608.       TWABD_Button,
  609.       TWABD_Edit,
  610.       TWABD_ComboBox,
  611.       TWABD_RadioButton,
  612.       TWABD_ListBox,
  613.       TWABD_CheckBox,
  614.       TWABD_UploadFile,
  615.  
  616.       TWABD_Table_Strings,
  617.       TWABD_HotSpots,
  618.       TWABD_Chart,
  619.       TWABD_MenuTree,
  620.       TWABD_EditTable,
  621.       TWABD_DBEditTable]);
  622.  
  623. finalization
  624.    WABDClassList.Free;
  625.    FormEditor.Free;
  626.    FramesetEditor.Free;
  627.    HotSpotEditor.Free;
  628.    TreeEditor.Free;
  629.  
  630. end.
  631.