home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 September / Chip_2001-09_cd1.bin / zkuste / delphi / kolekce / d123456 / DFS.ZIP / DFSStatusBarReg.pas < prev    next >
Pascal/Delphi Source File  |  2001-06-27  |  3KB  |  116 lines

  1. {$I DFS.INC}
  2.  
  3. unit DFSStatusBarReg;
  4.  
  5. interface
  6.  
  7. uses
  8.   {$IFDEF DFS_NO_DSGNINTF}
  9.   DesignIntf,
  10.   DesignEditors;
  11.   {$ELSE}
  12.   DsgnIntf;
  13.   {$ENDIF}
  14.  
  15. type
  16.   TdfsStatusBarEditor = class(TDefaultEditor)
  17.   protected
  18.     {$IFDEF DFS_IPROPERTY}
  19.     procedure RunPropertyEditor(const Prop: IProperty);
  20.     {$ELSE}
  21.     procedure RunPropertyEditor(Prop: TPropertyEditor);
  22.     {$ENDIF}
  23.   public
  24.     procedure ExecuteVerb(Index : Integer); override;
  25.     function GetVerb(Index : Integer): string; override;
  26.     function GetVerbCount : Integer; override;
  27.     procedure Edit; override;
  28.   end;
  29.  
  30. procedure Register;
  31.  
  32. implementation
  33.  
  34. uses
  35.   Dialogs, Windows, DFSStatusBar, DFSAbout, Classes, SysUtils, TypInfo;
  36.  
  37. procedure Register;
  38. begin
  39.   RegisterComponents('DFS', [TdfsStatusBar]);
  40.   RegisterPropertyEditor(TypeInfo(string), TdfsStatusBar, 'Version',
  41.      TdfsVersionProperty);
  42.   { We have to replace the panels editor that's registered for TStatusBar with
  43.     our own because otherwise it would edit the TStatusBar.Panels property,
  44.     which is of the type TStatusPanels.  We don't want that because it doesn't
  45.     know about our new stuff in TdfsStatusPanel. }
  46.   RegisterComponentEditor(TdfsStatusBar, TdfsStatusBarEditor);
  47. end;
  48.  
  49.  
  50. { TdfsStatusBarEditor }
  51.  
  52. procedure TdfsStatusBarEditor.Edit;
  53. var
  54.   {$IFDEF DFS_DESIGNERSELECTIONS}
  55.   Components: IDesignerSelections;
  56.   {$ELSE}
  57.   {$IFDEF DFS_COMPILER_5_UP}
  58.   Components: TDesignerSelectionList;
  59.   {$ELSE}
  60.   Components: TComponentList;
  61.   {$ENDIF}
  62.   {$ENDIF}
  63. begin
  64.   {$IFDEF DFS_DESIGNERSELECTIONS}
  65.   Components := CreateSelectionList;
  66.   {$ELSE}
  67.   {$IFDEF DFS_COMPILER_5_UP}
  68.   Components := TDesignerSelectionList.Create;
  69.   {$ELSE}
  70.   Components := TComponentList.Create;
  71.   {$ENDIF}
  72.   {$ENDIF}
  73.   try
  74.       Components.Add(Component);
  75.       GetComponentProperties(Components, [tkClass], Designer, RunPropertyEditor);
  76.   finally
  77.     {$IFNDEF DFS_DESIGNERSELECTIONS}
  78.       Components.Free;
  79.     {$ENDIF}
  80.   end;
  81. end;
  82.  
  83. procedure TdfsStatusBarEditor.RunPropertyEditor(
  84. {$IFDEF DFS_IPROPERTY}
  85.   const Prop: IProperty
  86. {$ELSE}
  87.   Prop: TPropertyEditor
  88. {$ENDIF}
  89. );
  90. begin
  91.   if UpperCase(Prop.GetName) = 'PANELS' then
  92.     Prop.Edit;
  93. end;
  94.  
  95. procedure TdfsStatusBarEditor.ExecuteVerb(Index: Integer);
  96. begin
  97.   if Index <> 0 then Exit; { We only have one verb, so exit if this ain't it }
  98.   Edit;  { Invoke the Edit function the same as if double click had happened }
  99. end;
  100.  
  101.  
  102. function TdfsStatusBarEditor.GetVerb(Index: Integer): string;
  103. begin
  104.   Result := '&Panels Editor...';  { Menu item caption for context menu }
  105. end;
  106.  
  107. function TdfsStatusBarEditor.GetVerbCount: Integer;
  108. begin
  109.   Result := 1; // Just add one menu item.
  110. end;
  111.  
  112.  
  113. end.
  114.  
  115.  
  116.