home *** CD-ROM | disk | FTP | other *** search
/ Chip 2003 February / Chip_2003-02_cd1.bin / zkuste / delphi / kompon / d3456 / PICSHOW.ZIP / PSReg.pas < prev    next >
Pascal/Delphi Source File  |  2002-10-25  |  7KB  |  247 lines

  1. {------------------------------------------------------------------------------}
  2. {                                                                              }
  3. {  TCustomPicShow v2.812                                                       }
  4. {  by Kambiz R. Khojasteh                                                      }
  5. {                                                                              }
  6. {  kambiz@delphiarea.com                                                       }
  7. {  http://www.delphiarea.com                                                   }
  8. {                                                                              }
  9. {  Special thanks to:                                                          }
  10. {  :: <k3nx@hotmail.com> for help on D5 support.                               }
  11. {  :: Douglass Titjan <support@delphipages.com> for help on D5 support.        }
  12. {  :: Jerry McLain <jkmclain@srcaccess.net> for manual control idea.           }
  13. {  :: M. R. Zamani <M_R_Zamani@yahoo.com> for adding 8 effects (110..117).     }
  14. {  :: Elliott Shevin <ShevinE@aol.com> for adding 4 effects (123..126).        }
  15. {  :: Ken Otto <ken.otto@enviros.com> for adding native JPG support to         }
  16. {     TDBPicShow and fixing a memory leak bug.                                 }
  17. {  :: Gary Bond <gary.bond@tesco.net> for name of the transitions.             }
  18. {                                                                              }
  19. {------------------------------------------------------------------------------}
  20.  
  21. {$I DELPHIAREA.INC}
  22.  
  23. unit PSReg;
  24.  
  25. interface
  26.  
  27. uses
  28.   Windows, Classes, {$IFDEF DELPHI6_UP} DesignIntf, DesignEditors {$ELSE} DsgnIntf {$ENDIF};
  29.  
  30. type
  31.  
  32.   {$IFDEF DELPHI6_UP}
  33.   TGetPropEditProc = procedure(const Prop: IProperty) of object;
  34.   {$ENDIF}
  35.  
  36. { TPicShowComponentEditor }
  37.  
  38.   TPicShowComponentEditor = class(TComponentEditor)
  39.   protected
  40.     procedure CallPropertyEditor(Proc: TGetPropEditProc);
  41.     {$IFDEF DELPHI6_UP}
  42.     procedure PictureEditor(const Prop: IProperty);
  43.     procedure BackgroundEditor(const Prop: IProperty);
  44.     {$ELSE}
  45.     procedure PictureEditor(Prop: TPropertyEditor);
  46.     procedure BackgroundEditor(Prop: TPropertyEditor);
  47.     {$ENDIF}
  48.   public
  49.     function GetVerbCount: Integer; override;
  50.     function GetVerb(Index: Integer): string; override;
  51.     procedure ExecuteVerb(Index: Integer); override;
  52.     procedure Edit; override;
  53.   end;
  54.  
  55. { TStyleNamePropertyEditor }
  56.  
  57.   TStyleNamePropertyEditor = class(TEnumProperty)
  58.   public
  59.     function GetAttributes: TPropertyAttributes; override;
  60.     procedure GetValues(Proc: TGetStrProc); override;
  61.     function GetValue: string; override;
  62.     procedure SetValue(const Value: string); override;
  63.   end;
  64.  
  65. { TAboutPropertyEditor }
  66.  
  67.   TAboutPropertyEditor = class(TStringProperty)
  68.   public
  69.     procedure Edit; override;
  70.     function GetValue: string; override;
  71.     function GetAttributes: TPropertyAttributes; override;
  72.   end;
  73.  
  74. procedure Register;
  75.  
  76. implementation
  77.  
  78. uses
  79.   PicShow, TypInfo, Dialogs;
  80.  
  81. procedure ShowAboutBox(const ClassName: String);
  82. const
  83.   AboutStr = ' v2.812'                                     + #10#13
  84.            + 'Copyright(C) 1999-2002 Kambiz R. Khojasteh'  + #10#13
  85.            + 'All rights reserved.'                        + #10#13
  86.            +                                                 #10#13
  87.            + 'kambiz@delphiarea.com'                       + #10#13
  88.            + 'http://www.delphiarea.com';
  89. begin
  90.   MessageDlg(ClassName + AboutStr, mtInformation, [mbOK], 0);
  91. end;
  92.  
  93. { TPicShowComponentEditor }
  94.  
  95. function TPicShowComponentEditor.GetVerbCount: Integer;
  96. begin
  97.   Result := 7;
  98. end;
  99.  
  100. function TPicShowComponentEditor.GetVerb(Index: Integer): string;
  101. begin
  102.   case Index of
  103.     0: Result := 'About ' + Component.ClassName + '...';
  104.     1: Result := '-';
  105.     2: Result := 'Picture Editor...';
  106.     3: Result := 'Background Editor...';
  107.     4: Result := '-';
  108.     5: if TCustomPicShow(Component).Busy then
  109.          Result := 'Stop Transition'
  110.        else
  111.          Result := 'Start Transition';
  112.     6: if TCustomPicShow(Component).Busy then
  113.          Result := 'Can''t Clear Screen'
  114.        else
  115.          Result := 'Clear Screen';
  116.   else
  117.     Result := '';
  118.   end;
  119. end;
  120.  
  121. procedure TPicShowComponentEditor.ExecuteVerb(Index: Integer);
  122. begin
  123.   case Index of
  124.     0: ShowAboutBox(Component.ClassName);
  125.     1: {Nothing to do};
  126.     2: CallPropertyEditor(PictureEditor);
  127.     3: CallPropertyEditor(BackgroundEditor);
  128.     4: {Nothing to do};
  129.     5: if TCustomPicShow(Component).Busy then
  130.          TCustomPicShow(Component).Stop
  131.        else
  132.          TCustomPicShow(Component).Execute;
  133.     6: if not TCustomPicShow(Component).Busy then
  134.          TCustomPicShow(Component).Clear;
  135.   else
  136.     inherited ExecuteVerb(Index);
  137.   end;
  138. end;
  139.  
  140. procedure TPicShowComponentEditor.Edit;
  141. begin
  142.   ExecuteVerb(2);
  143. end;
  144.  
  145. procedure TPicShowComponentEditor.CallPropertyEditor(Proc: TGetPropEditProc);
  146. var
  147.   {$IFDEF DELPHI6_UP}
  148.   List: IDesignerSelections;
  149.   {$ELSE}
  150.   {$IFDEF DELPHI5_UP}
  151.   List: TDesignerSelectionList;
  152.   {$ELSE}
  153.   List: TComponentList;
  154.   {$ENDIF}
  155.   {$ENDIF}
  156. begin
  157.   {$IFDEF DELPHI6_UP}
  158.   List := TDesignerSelections.Create;
  159.   {$ELSE}
  160.   {$IFDEF DELPHI5_UP}
  161.   List := TDesignerSelectionList.Create;
  162.   {$ELSE}
  163.   List := TComponentList.Create;
  164.   {$ENDIF}
  165.   {$ENDIF}
  166.   try
  167.     List.Add(Component);
  168.     GetComponentProperties(List, [tkClass], Designer, Proc);
  169.   finally
  170.     {$IFNDEF DELPHI6_UP}
  171.     List.Free;
  172.     {$ENDIF}
  173.   end;
  174. end;
  175.  
  176. {$IFDEF DELPHI6_UP}
  177. procedure TPicShowComponentEditor.PictureEditor(const Prop: IProperty);
  178. {$ELSE}
  179. procedure TPicShowComponentEditor.PictureEditor(Prop: TPropertyEditor);
  180. {$ENDIF}
  181. begin
  182.   if Prop.GetName = 'Picture' then
  183.     Prop.Edit;
  184. end;
  185.  
  186. {$IFDEF DELPHI6_UP}
  187. procedure TPicShowComponentEditor.BackgroundEditor(const Prop: IProperty);
  188. {$ELSE}
  189. procedure TPicShowComponentEditor.BackgroundEditor(Prop: TPropertyEditor);
  190. {$ENDIF}
  191. begin
  192.   if Prop.GetName = 'BgPicture' then
  193.     Prop.Edit;
  194. end;
  195.  
  196. { TStyleNamePropertyEditor }
  197.  
  198. function TStyleNamePropertyEditor.GetAttributes: TPropertyAttributes;
  199. begin
  200.   Result := [paMultiSelect, paValueList, paSortList, paRevertable];
  201. end;
  202.  
  203. procedure TStyleNamePropertyEditor.GetValues(Proc: TGetStrProc);
  204. var
  205.   Style: TShowStyle;
  206. begin
  207.   for Style := Low(TShowStyle) to High(TShowStyle) do
  208.     Proc(PSTransitionNames[Style]);
  209. end;
  210.  
  211. function TStyleNamePropertyEditor.GetValue: string;
  212. begin
  213.   Result := GetStrValue;
  214. end;
  215.  
  216. procedure TStyleNamePropertyEditor.SetValue(const Value: string);
  217. begin
  218.   SetStrValue(Value);
  219. end;
  220.  
  221. { TAboutPropertyEditor }
  222.  
  223. function TAboutPropertyEditor.GetAttributes: TPropertyAttributes;
  224. begin
  225.   Result := [paDialog, paReadOnly, paMultiSelect];
  226. end;
  227.  
  228. function TAboutPropertyEditor.GetValue: string;
  229. begin
  230.   Result := '(About)'
  231. end;
  232.  
  233. procedure TAboutPropertyEditor.Edit;
  234. begin
  235.   ShowAboutBox(GetComponent(0).ClassName);
  236. end;
  237.  
  238. procedure Register;
  239. begin
  240.   RegisterComponents('Delphi Area', [TPicShow, TDBPicShow]);
  241.   RegisterComponentEditor(TPicShow, TPicShowComponentEditor);
  242.   RegisterPropertyEditor(TypeInfo(String), TCustomPicShow, 'StyleName', TStyleNamePropertyEditor);
  243.   RegisterPropertyEditor(TypeInfo(TAbout), TCustomPicShow, 'About', TAboutPropertyEditor);
  244. end;
  245.  
  246. end.
  247.