Spreg.pas
上传用户:hylc_2004
上传日期:2014-01-23
资源大小:46800k
文件大小:12k
源码类别:

Delphi控件源码

开发平台:

Delphi

  1. {*******************************************************************}
  2. {                                                                   }
  3. {       Almediadev Visual Component Library                         }
  4. {       DynamicSkinForm                                             }
  5. {       Version 4.98                                                }
  6. {                                                                   }
  7. {       Copyright (c) 2000-2002 Almediadev                          }
  8. {       ALL RIGHTS RESERVED                                         }
  9. {                                                                   }
  10. {       Home:  http://www.almdev.com                                }
  11. {       Support: support@almdev.com                                 }
  12. {                                                                   }
  13. {*******************************************************************}
  14. unit spreg;
  15. {$P+,S-,W-,R-}
  16. {$WARNINGS OFF}
  17. {$HINTS OFF}
  18. interface
  19. uses Classes, Menus, Dialogs, Forms,
  20.     {$IFDEF  VER140} DesignEditors, DesignIntf
  21.     {$ELSE} {$IFDEF  VER150} DesignEditors, DesignIntf {$ELSE} DsgnIntf {$ENDIF} {$ENDIF};
  22. type
  23.   TspSkinPageControlEditor = class(TDefaultEditor)
  24.   public
  25.     procedure ExecuteVerb(Index: Integer); override;
  26.     function GetVerb(Index: Integer): string; override;
  27.     function GetVerbCount: Integer; override;
  28.   end;
  29. procedure Register;
  30. implementation
  31. uses
  32.   SPUtils, SPEffBMP, DynamicSkinForm, SkinData, SkinCtrls, SkinHint, SkinGrids,
  33.   SkinTabs, SysUtils, SkinBoxCtrls, SkinMenus, spTrayIcon, spMessages,
  34.   spSkinZip, spSkinUnZip, spFileCtrl, spSkinShellCtrls, spNBPagesEditor,
  35.   spCalendar;
  36.   { TFilenameProperty }
  37. type
  38.   TspFilenameProperty = class(TStringProperty)
  39.   public
  40.     procedure Edit; override;
  41.     function GetAttributes: TPropertyAttributes; override;
  42.   end;
  43.   TspSkinDataNameProperty = class(TStringProperty)
  44.   public
  45.     function GetAttributes: TPropertyAttributes; override;
  46.     procedure GetValueList(List: TStrings); virtual;
  47.     procedure GetValues(Proc: TGetStrProc); override;
  48.   end;
  49.   TspButtonSkinDataNameProperty = class(TspSkinDataNameProperty)
  50.   public
  51.     procedure GetValueList(List: TStrings); override;
  52.   end;
  53.   TspGaugeSkinDataNameProperty = class(TspSkinDataNameProperty)
  54.   public
  55.     procedure GetValueList(List: TStrings); override;
  56.   end;
  57.   TspMenuButtonSkinDataNameProperty = class(TspSkinDataNameProperty)
  58.   public
  59.     procedure GetValueList(List: TStrings); override;
  60.   end;
  61.   TspPanelSkinDataNameProperty = class(TspSkinDataNameProperty)
  62.   public
  63.     procedure GetValueList(List: TStrings); override;
  64.   end;
  65.   TspListBoxSkinDataNameProperty = class(TspSkinDataNameProperty)
  66.   public
  67.     procedure GetValueList(List: TStrings); override;
  68.   end;
  69.   TspCheckListBoxSkinDataNameProperty = class(TspSkinDataNameProperty)
  70.   public
  71.     procedure GetValueList(List: TStrings); override;
  72.   end;
  73.   TspComboBoxSkinDataNameProperty = class(TspSkinDataNameProperty)
  74.   public
  75.     procedure GetValueList(List: TStrings); override;
  76.   end;
  77.   TspSplitterSkinDataNameProperty = class(TspSkinDataNameProperty)
  78.   public
  79.     procedure GetValueList(List: TStrings); override;
  80.   end;
  81.   procedure TspSkinDataNameProperty.GetValueList(List: TStrings);
  82.   begin
  83.   end;
  84.   procedure TspSkinDataNameProperty.GetValues(Proc: TGetStrProc);
  85.   var
  86.     I: Integer;
  87.     Values: TStringList;
  88.   begin
  89.     Values := TStringList.Create;
  90.     try
  91.       GetValueList(Values);
  92.       for I := 0 to Values.Count - 1 do Proc(Values[I]);
  93.     finally
  94.       Values.Free;
  95.     end;
  96.   end;
  97.   function TspSkinDataNameProperty.GetAttributes: TPropertyAttributes;
  98.   begin
  99.     Result := [paValueList];
  100.   end;
  101.   procedure TspButtonSkinDataNameProperty.GetValueList(List: TStrings);
  102.   begin
  103.     List.Add('button');
  104.     List.Add('resizebutton');
  105.     List.Add('toolbutton');
  106.     List.Add('bigtoolbutton');
  107.   end;
  108.   procedure TspGaugeSkinDataNameProperty.GetValueList(List: TStrings);
  109.   begin
  110.     List.Add('gauge');
  111.     List.Add('vgauge');
  112.     List.Add('statusgauge');
  113.   end;
  114.   procedure TspMenuButtonSkinDataNameProperty.GetValueList(List: TStrings);
  115.   begin
  116.     List.Add('toolmenubutton');
  117.     List.Add('bigtoolmenubutton');
  118.     List.Add('toolmenutrackbutton');
  119.     List.Add('bigtoolmenutrackbutton');
  120.   end;
  121.   procedure TspPanelSkinDataNameProperty.GetValueList(List: TStrings);
  122.   begin
  123.     List.Add('panel');
  124.     List.Add('toolpanel');
  125.     List.Add('bigtoolpanel');
  126.     List.Add('statusbar');
  127.     List.Add('groupbox');
  128.   end;
  129.   procedure TspListBoxSkinDataNameProperty.GetValueList(List: TStrings);
  130.   begin
  131.     List.Add('listbox');
  132.     List.Add('captionlistbox');
  133.   end;
  134.   procedure TspCheckListBoxSkinDataNameProperty.GetValueList(List: TStrings);
  135.   begin
  136.     List.Add('checklistbox');
  137.     List.Add('captionchecklistbox');
  138.   end;
  139.   procedure TspComboBoxSkinDataNameProperty.GetValueList(List: TStrings);
  140.   begin
  141.     List.Add('combobox');
  142.     List.Add('captioncombobox');
  143.   end;
  144.   procedure TspSplitterSkinDataNameProperty.GetValueList(List: TStrings);
  145.   begin
  146.     List.Add('vsplitter');
  147.     List.Add('hsplitter');
  148.   end;
  149.   procedure TspFilenameProperty.Edit;
  150.   var
  151.     FileOpen: TOpenDialog;
  152.   begin
  153.     FileOpen := TOpenDialog.Create(Application);
  154.     try
  155.       FileOpen.Filename := '';
  156.       FileOpen.InitialDir := ExtractFilePath(FileOpen.Filename);
  157.       FileOpen.Filter := '*.*|*.*';
  158.       FileOpen.Options := FileOpen.Options + [ofHideReadOnly];
  159.       if FileOpen.Execute then SetValue(FileOpen.Filename);
  160.     finally
  161.       FileOpen.Free;
  162.     end;
  163.   end;
  164.   function TspFilenameProperty.GetAttributes: TPropertyAttributes;
  165.   begin
  166.     Result := [paDialog , paRevertable];
  167.   end;
  168. type
  169.   TspSetPagesProperty = class(TPropertyEditor)
  170.   public
  171.     procedure Edit; override;
  172.     function GetAttributes: TPropertyAttributes; override;
  173.     function GetValue: string; override;
  174.     procedure SetValue(const Value: string); override;
  175.    end;
  176. procedure TspSetPagesProperty.Edit;
  177. var
  178.   NB: TspSkinNoteBook;
  179. begin
  180.   try
  181.     NB := TspSkinNoteBook(GetComponent(0));
  182.     spNBPagesEditor.Execute(NB);
  183.   finally
  184.   end;
  185. end;
  186. function TspSetPagesProperty.GetAttributes: TPropertyAttributes;
  187. begin
  188.   Result := [paDialog];
  189. end;
  190. function TspSetPagesProperty.GetValue: string;
  191. begin
  192.   Result := '(Pages)';
  193. end;
  194. procedure TspSetPagesProperty.SetValue(const Value: string);
  195. begin
  196.   if Value = '' then SetOrdValue(0);
  197. end;
  198. { Registration }
  199. resourcestring
  200.   sTABSHEET_DEFAULT_NAME = 'spSkinTabSheet';
  201.   sNEW_PAGE              = 'New page';
  202.   sDEL_PAGE              = 'Delete page';
  203. procedure Register;
  204. begin
  205.   RegisterComponents('Skin Pack',  [TspDynamicSkinForm,
  206.     TspSkinData, TspStoredSkin, TspCompressedStoredSkin, TspSkinMainMenuBar,
  207.     TspSkinPopupMenu, TspSkinMainMenu, TspTrayIcon,
  208.     TspSkinPanel, TspSkinGroupBox, TspSkinRadioGroup, TspSkinCheckGroup,
  209.     TspSkinButton, TspSkinMenuButton,
  210.     TspSkinSpeedButton, TspSkinMenuSpeedButton,
  211.     TspSkinCheckRadioBox,
  212.     TspSkinGauge, TspSkinTrackBar, TspSkinLabel,
  213.     TspSkinFrameRegulator,
  214.     TspSkinFrameGauge,
  215.     TspSkinXFormButton,
  216.     TspSkinHint, TspSkinDrawGrid, TspSkinStringGrid,
  217.     TspSkinPageControl, TspSkinTabControl,
  218.     TspSkinListBox, TspSkinComboBox, TspSkinEdit, TspSkinMaskEdit,
  219.     TspSkinMemo, TspSkinMemo2,
  220.     TspSkinScrollBar, TspSkinSpinEdit, TspSkinCheckListBox,
  221.     TspSkinStdLabel, TspSkinBitLabel,
  222.     TspSkinAnimate, TspSkinSwitch, TspSkinUpDown,
  223.     TspSkinControlBar, TspSkinSplitter,
  224.     TspSkinScrollBox, TspSkinColorComboBox, TspSkinFontComboBox,
  225.     TspSkinListView, TspSkinTreeView, TspSkinStatusPanel,
  226.     TspSkinRichEdit, TspSkinDateEdit, TspSkinTimeEdit,
  227.     TspSkinMessage, TspSkinZip, TspSkinUnZip, TspSkinTextLabel,
  228.     TspSkinFileListView, TspSkinDirTreeView, TspSkinShellDriveComboBox,
  229.     TspSkinDriveComboBox, TspSkinFilterComboBox,
  230.     TspSkinDirectoryListBox, TspSkinFileListBox,
  231.     TspSkinSelectDirectoryDialog, TspSkinOpenDialog, TspSkinSaveDialog,
  232.     TspSkinOpenPictureDialog, TspSkinSavePictureDialog, TspSkinFontDialog,
  233.     TspSkinInputDialog, TspSkinPasswordDialog, TspSkinProgressDialog, TspSkinTextDialog,
  234.     TspSkinDirectoryEdit, TspSkinFileEdit, TspSkinSaveFileEdit, TspSkinExPanel,
  235.     TspSkinHeaderControl, TspSkinTrackEdit, TspSkinSlider,
  236.     TspSkinLinkLabel, TspSkinLinkImage, TspSkinButtonLabel, TspSkinBevel,
  237.     TspSkinButtonsBar, TspSkinNoteBook, TspSkinMonthCalendar]);
  238.   RegisterClass(TspSkinTabSheet);
  239.   RegisterPropertyEditor(TypeInfo(string), TspStoredSkin, 'FileName', TspFilenameProperty);
  240.   RegisterPropertyEditor(TypeInfo(string), TspCompressedStoredSkin, 'FileName', TspFilenameProperty);
  241.   RegisterPropertyEditor(TypeInfo(string), TspSkinListView, 'HeaderSkinDataName', TspButtonSkinDataNameProperty);
  242.   RegisterPropertyEditor(TypeInfo(string), TspSkinOpenDialog, 'LVHeaderSkinDataName', TspButtonSkinDataNameProperty);
  243.   RegisterPropertyEditor(TypeInfo(string), TspSkinSaveDialog, 'LVHeaderSkinDataName', TspButtonSkinDataNameProperty);
  244.   RegisterPropertyEditor(TypeInfo(string), TspSkinOpenPictureDialog, 'LVHeaderSkinDataName', TspButtonSkinDataNameProperty);
  245.   RegisterPropertyEditor(TypeInfo(string), TspSkinSavePictureDialog, 'LVHeaderSkinDataName', TspButtonSkinDataNameProperty);
  246.   RegisterPropertyEditor(TypeInfo(string), TspSkinButton, 'SkinDataName', TspButtonSkinDataNameProperty);
  247.   RegisterPropertyEditor(TypeInfo(string), TspSkinHeaderControl, 'SkinDataName', TspButtonSkinDataNameProperty);
  248.   RegisterPropertyEditor(TypeInfo(string), TspSkinGauge, 'SkinDataName', TspGaugeSkinDataNameProperty);
  249.   RegisterPropertyEditor(TypeInfo(string), TspSkinMenuButton, 'SkinDataName', TspMenuButtonSkinDataNameProperty);
  250.   RegisterPropertyEditor(TypeInfo(string), TspSkinSpeedButton, 'SkinDataName', TspButtonSkinDataNameProperty);
  251.   RegisterPropertyEditor(TypeInfo(string), TspSkinMenuSpeedButton, 'SkinDataName', TspMenuButtonSkinDataNameProperty);
  252.   RegisterPropertyEditor(TypeInfo(string), TspSkinPanel, 'SkinDataName', TspPanelSkinDataNameProperty);
  253.   RegisterPropertyEditor(TypeInfo(string), TspSkinListBox, 'SkinDataName', TspListBoxSkinDataNameProperty);
  254.   RegisterPropertyEditor(TypeInfo(string), TspSkinCheckListBox, 'SkinDataName', TspCheckListBoxSkinDataNameProperty);
  255.   RegisterPropertyEditor(TypeInfo(string), TspSkinSplitter, 'SkinDataName', TspSplitterSkinDataNameProperty);
  256.   RegisterPropertyEditor(TypeInfo(string), TspSkinComboBox, 'SkinDataName', TspComboBoxSkinDataNameProperty);
  257.   RegisterPropertyEditor(TypeInfo(TStrings),  TspSkinNoteBook, 'Pages', TspSetPagesProperty);
  258.   
  259.   RegisterComponentEditor(TspSkinPageControl, TspSkinPageControlEditor);
  260.   RegisterComponentEditor(TspSkinTabSheet, TspSkinPageControlEditor);
  261.   
  262. end;
  263. function TspSkinPageControlEditor.GetVerb(Index: Integer): string;
  264. begin
  265.   case Index of
  266.     0:  result := sNEW_PAGE;
  267.     1:  result := sDEL_PAGE;
  268.   end;
  269. end;
  270. procedure TspSkinPageControlEditor.ExecuteVerb(Index: Integer);
  271. var
  272.   NewPage: TspSkinCustomTabSheet;
  273.   PControl : TspSkinPageControl;
  274. begin
  275.   if Component is TspSkinPageControl then
  276.     PControl := TspSkinPageControl(Component)
  277.   else PControl := TspSkinPageControl(TspSkinTabSheet(Component).PageControl);
  278.   case Index of
  279.     0:  begin  //  New Page
  280.           NewPage := TspSkinTabSheet.Create(Designer.GetRoot);
  281.           with NewPage do
  282.           begin
  283.             Parent      := PControl;
  284.             PageControl := PControl;
  285.             Caption     := sTABSHEET_DEFAULT_NAME + IntToStr(PControl.PageCount);
  286.             Name        := Caption;
  287.           end;
  288.         end;
  289.     1:  begin  //  Delete Page
  290.           with PControl do
  291.           begin
  292.             NewPage := TspSkinCustomTabSheet(ActivePage);
  293.             NewPage.PageControl := nil;
  294.             NewPage.Free;
  295.           end;
  296.         end;
  297.   end;
  298.   if Designer <> nil then Designer.Modified;
  299. end;
  300. function TspSkinPageControlEditor.GetVerbCount: Integer;
  301. begin
  302.   result := 2;
  303. end;
  304. end.