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

Delphi控件源码

开发平台:

Delphi

  1. {*******************************************************************}
  2. {                                                                   }
  3. {       Almediadev Visual Component Library                         }
  4. {       BusinessSkinForm                                            }
  5. {       Version 1.98                                                }
  6. {                                                                   }
  7. {       Copyright (c) 2000-2003 Almediadev                          }
  8. {       ALL RIGHTS RESERVED                                         }
  9. {                                                                   }
  10. {       Home:  http://www.almdev.com                                }
  11. {       Support: support@almdev.com                                 }
  12. {                                                                   }
  13. {*******************************************************************}
  14. unit bsreg;
  15. {$P+,S-,W-,R-}
  16. {$WARNINGS OFF}
  17. {$HINTS OFF}
  18. interface
  19. uses Classes, Menus, Dialogs, Forms,
  20.     {$IFDEF  VER140} DesignEditors, DesignIntf {$ELSE}
  21.     {$IFDEF  VER150} DesignEditors, DesignIntf {$ELSE} DsgnIntf {$ENDIF}{$ENDIF};
  22. type
  23.   TbsSkinPageControlEditor = 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.   bsUtils, BusinessSkinForm, bsSkinData, bsSkinCtrls, bsSkinHint, bsSkinGrids,
  33.   bsSkinTabs, SysUtils, bsSkinBoxCtrls, bsSkinMenus, bsTrayIcon,
  34.   bsDBGrids, bsDBCtrls, DB, bsCalc, bsMessages, bsSkinZip, bsSkinUnZip,
  35.   bsFileCtrl, bsSkinShellCtrls, NBPagesEditor, bsCalendar;
  36. { TColumnDataFieldEditor }
  37. type
  38.   { TFilenameProperty }
  39.   TbsFilenameProperty = class(TStringProperty)
  40.   public
  41.     procedure Edit; override;
  42.     function GetAttributes: TPropertyAttributes; override;
  43.   end;
  44.   TbsDBStringProperty = class(TStringProperty)
  45.   public
  46.     function GetAttributes: TPropertyAttributes; override;
  47.     procedure GetValueList(List: TStrings); virtual;
  48.     procedure GetValues(Proc: TGetStrProc); override;
  49.   end;
  50.   TbsSkinDataNameProperty = class(TStringProperty)
  51.   public
  52.     function GetAttributes: TPropertyAttributes; override;
  53.     procedure GetValueList(List: TStrings); virtual;
  54.     procedure GetValues(Proc: TGetStrProc); override;
  55.   end;
  56.   TbsButtonSkinDataNameProperty = class(TbsSkinDataNameProperty)
  57.   public
  58.     procedure GetValueList(List: TStrings); override;
  59.   end;
  60.   TbsGaugeSkinDataNameProperty = class(TbsSkinDataNameProperty)
  61.   public
  62.     procedure GetValueList(List: TStrings); override;
  63.   end;
  64.   TbsMenuButtonSkinDataNameProperty = class(TbsSkinDataNameProperty)
  65.   public
  66.     procedure GetValueList(List: TStrings); override;
  67.   end;
  68.   TbsPanelSkinDataNameProperty = class(TbsSkinDataNameProperty)
  69.   public
  70.     procedure GetValueList(List: TStrings); override;
  71.   end;
  72.   TbsListBoxSkinDataNameProperty = class(TbsSkinDataNameProperty)
  73.   public
  74.     procedure GetValueList(List: TStrings); override;
  75.   end;
  76.   TbsComboBoxSkinDataNameProperty = class(TbsSkinDataNameProperty)
  77.   public
  78.     procedure GetValueList(List: TStrings); override;
  79.   end;
  80.    TbsCheckListBoxSkinDataNameProperty = class(TbsSkinDataNameProperty)
  81.   public
  82.     procedure GetValueList(List: TStrings); override;
  83.   end;
  84.   TbsSplitterSkinDataNameProperty = class(TbsSkinDataNameProperty)
  85.   public
  86.     procedure GetValueList(List: TStrings); override;
  87.   end;
  88.   procedure TbsSkinDataNameProperty.GetValueList(List: TStrings);
  89.   begin
  90.   end;
  91.   procedure TbsSkinDataNameProperty.GetValues(Proc: TGetStrProc);
  92.   var
  93.     I: Integer;
  94.     Values: TStringList;
  95.   begin
  96.     Values := TStringList.Create;
  97.     try
  98.       GetValueList(Values);
  99.       for I := 0 to Values.Count - 1 do Proc(Values[I]);
  100.     finally
  101.       Values.Free;
  102.     end;
  103.   end;
  104.   function TbsSkinDataNameProperty.GetAttributes: TPropertyAttributes;
  105.   begin
  106.     Result := [paValueList];
  107.   end;
  108.   procedure TbsButtonSkinDataNameProperty.GetValueList(List: TStrings);
  109.   begin
  110.     List.Add('button');
  111.     List.Add('resizebutton');
  112.     List.Add('toolbutton');
  113.     List.Add('bigtoolbutton');
  114.   end;
  115.   procedure TbsGaugeSkinDataNameProperty.GetValueList(List: TStrings);
  116.   begin
  117.     List.Add('gauge');
  118.     List.Add('vgauge');
  119.     List.Add('statusgauge');
  120.   end;
  121.   procedure TbsMenuButtonSkinDataNameProperty.GetValueList(List: TStrings);
  122.   begin
  123.     List.Add('toolmenubutton');
  124.     List.Add('bigtoolmenubutton');
  125.     List.Add('toolmenutrackbutton');
  126.     List.Add('bigtoolmenutrackbutton');
  127.   end;
  128.   procedure TbsPanelSkinDataNameProperty.GetValueList(List: TStrings);
  129.   begin
  130.     List.Add('panel');
  131.     List.Add('toolpanel');
  132.     List.Add('bigtoolpanel');
  133.     List.Add('statusbar');
  134.     List.Add('groupbox');
  135.   end;
  136.   procedure TbsListBoxSkinDataNameProperty.GetValueList(List: TStrings);
  137.   begin
  138.     List.Add('listbox');
  139.     List.Add('captionlistbox');
  140.   end;
  141.   procedure TbsComboBoxSkinDataNameProperty.GetValueList(List: TStrings);
  142.   begin
  143.     List.Add('combobox');
  144.     List.Add('captioncombobox');
  145.   end;
  146.   procedure TbsCheckListBoxSkinDataNameProperty.GetValueList(List: TStrings);
  147.   begin
  148.     List.Add('checklistbox');
  149.     List.Add('captionchecklistbox');
  150.   end;
  151.   procedure TbsSplitterSkinDataNameProperty.GetValueList(List: TStrings);
  152.   begin
  153.     List.Add('vsplitter');
  154.     List.Add('hsplitter');
  155.   end;
  156.   procedure TbsFilenameProperty.Edit;
  157.   var
  158.     FileOpen: TOpenDialog;
  159.   begin
  160.     FileOpen := TOpenDialog.Create(Application);
  161.     try
  162.       FileOpen.Filename := '';
  163.       FileOpen.InitialDir := ExtractFilePath(FileOpen.Filename);
  164.       FileOpen.Filter := '*.*|*.*';
  165.       FileOpen.Options := FileOpen.Options + [ofHideReadOnly];
  166.       if FileOpen.Execute then SetValue(FileOpen.Filename);
  167.     finally
  168.       FileOpen.Free;
  169.     end;
  170.   end;
  171.   function TbsFilenameProperty.GetAttributes: TPropertyAttributes;
  172.   begin
  173.     Result := [paDialog , paRevertable];
  174.   end;
  175.   function TbsDBStringProperty.GetAttributes: TPropertyAttributes;
  176.   begin
  177.     Result := [paValueList, paSortList, paMultiSelect];
  178.   end;
  179.   procedure TbsDBStringProperty.GetValueList(List: TStrings);
  180.   begin
  181.   end;
  182. procedure TbsDBStringProperty.GetValues(Proc: TGetStrProc);
  183. var
  184.   I: Integer;
  185.   Values: TStringList;
  186. begin
  187.   Values := TStringList.Create;
  188.   try
  189.     GetValueList(Values);
  190.     for I := 0 to Values.Count - 1 do Proc(Values[I]);
  191.   finally
  192.     Values.Free;
  193.   end;
  194. end;
  195. type
  196.   TbsColumnDataFieldProperty = class(TbsDBStringProperty)
  197.     procedure GetValueList(List: TStrings); override;
  198.   end;
  199. procedure TbsColumnDataFieldProperty.GetValueList(List: TStrings);
  200. var
  201.   Grid: TbsSkinCustomDBGrid;
  202.   DataSource: TDataSource;
  203. begin
  204.   Grid := (GetComponent(0) as TbsColumn).Grid;
  205.   if (Grid = nil) then Exit;
  206.   DataSource := Grid.DataSource;
  207.   if (DataSource <> nil) and (DataSource.DataSet <> nil) then
  208.     DataSource.DataSet.GetFieldNames(List);
  209. end;
  210. type
  211.   TbsSkinDBLookUpListBoxFieldProperty = class(TbsDBStringProperty)
  212.     procedure GetValueList(List: TStrings); override;
  213.   end;
  214. procedure TbsSkinDBLookUpListBoxFieldProperty.GetValueList(List: TStrings);
  215. var
  216.   DataSource: TDataSource;
  217.   LookUpControl: TbsDBLookUpControl;
  218. begin
  219.   DataSource := (GetComponent(0) as TbsSkinDBLookUpListBox).ListSource;
  220.   if (DataSource <> nil) and (DataSource.DataSet <> nil) then
  221.     DataSource.DataSet.GetFieldNames(List);
  222. end;
  223. type
  224.   TbsSkinDBLookUpComboBoxFieldProperty = class(TbsDBStringProperty)
  225.     procedure GetValueList(List: TStrings); override;
  226.   end;
  227. procedure TbsSkinDBLookUpComboBoxFieldProperty.GetValueList(List: TStrings);
  228. var
  229.   DataSource: TDataSource;
  230.   LookUpControl: TbsDBLookUpControl;
  231. begin
  232.   DataSource := (GetComponent(0) as TbsSkinDBLookUpComboBox).ListSource;
  233.   if (DataSource <> nil) and (DataSource.DataSet <> nil) then
  234.     DataSource.DataSet.GetFieldNames(List);
  235. end;
  236. type
  237.   TbsSetPagesProperty = class(TPropertyEditor)
  238.   public
  239.     procedure Edit; override;
  240.     function GetAttributes: TPropertyAttributes; override;
  241.     function GetValue: string; override;
  242.     procedure SetValue(const Value: string); override;
  243.    end;
  244. procedure TbsSetPagesProperty.Edit;
  245. var
  246.   NB: TbsSkinNoteBook;
  247. begin
  248.   try
  249.     NB := TbsSkinNoteBook(GetComponent(0));
  250.     NBPagesEditor.Execute(NB);
  251.   finally
  252.   end;
  253. end;
  254. function TbsSetPagesProperty.GetAttributes: TPropertyAttributes;
  255. begin
  256.   Result := [paDialog];
  257. end;
  258. function TbsSetPagesProperty.GetValue: string;
  259. begin
  260.   Result := '(Pages)';
  261. end;
  262. procedure TbsSetPagesProperty.SetValue(const Value: string);
  263. begin
  264.   if Value = '' then SetOrdValue(0);
  265. end;
  266. { Registration }
  267. resourcestring
  268.   sTABSHEET_DEFAULT_NAME = 'bsSkinTabSheet';
  269.   sNEW_PAGE              = 'New page';
  270.   sDEL_PAGE              = 'Delete page';
  271. procedure Register;
  272. begin
  273.   RegisterComponents('BusinessSkinForm VCL',  [TbsBusinessSkinForm,
  274.     TbsSkinData, TbsCompressedStoredSkin, TbsStoredSkin, TbsSkinMainMenuBar,
  275.     TbsSkinPopupMenu, TbsSkinMainMenu, TbsTrayIcon,
  276.     TbsSkinPanel, TbsSkinGroupBox, TbsSkinRadioGroup, TbsSkinCheckGroup,
  277.     TbsSkinSpeedButton, TbsSkinMenuSpeedButton,
  278.     TbsSkinButton, TbsSkinCheckRadioBox,
  279.     TbsSkinGauge, TbsSkinTrackBar, TbsSkinLabel,
  280.     TbsSkinHint, TbsSkinDrawGrid, TbsSkinStringGrid,
  281.     TbsSkinPageControl, TbsSkinTabControl,
  282.     TbsSkinListBox, TbsSkinComboBox, TbsSkinEdit, TbsSkinMaskEdit,
  283.     TbsSkinMemo, TbsSkinMemo2,
  284.     TbsSkinScrollBar, TbsSkinSpinEdit, TbsSkinCheckListBox,
  285.     TbsSkinStdLabel, TbsSkinUpDown,
  286.     TbsSkinControlBar, TbsSkinSplitter, TbsSkinMenuButton,
  287.     TbsSkinScrollBox, TbsSkinColorComboBox, TbsSkinFontComboBox,
  288.     TbsSkinTreeView, TbsSkinListView, TbsSkinStatusPanel,
  289.     TbsSkinRichEdit, TbsSkinDateEdit, TbsSkinCalculator, TbsSkinCalcEdit,
  290.     TbsSkinMessage, TbsSkinZip, TbsSkinUnZip, TbsSkinTextLabel,
  291.     TbsSkinFileListBox, TbsSkinDirectoryListBox, TbsSkinDriveComboBox,
  292.     TbsSkinFilterComboBox, TbsSkinFileListView, TbsSkinDirTreeView,
  293.     TbsSkinShellDriveComboBox,
  294.     TbsSkinSelectDirectoryDialog, TbsSkinOpenDialog, TbsSkinSaveDialog,
  295.     TbsSkinOpenPictureDialog, TbsSkinSavePictureDialog,
  296.     TbsSkinInputDialog, TbsSkinPasswordDialog, TbsSkinTextDialog,
  297.     TbsSkinDirectoryEdit, TbsSkinFileEdit, TbsSkinSaveFileEdit,
  298.     TbsSkinExPanel, TbsSkinFontDialog, TbsSkinProgressDialog,
  299.     TbsSkinTrackEdit, TbsSkinHeaderControl, TbsSkinLinkLabel, TbsSkinLinkImage,
  300.     TbsSkinButtonLabel,  TbsSkinSlider, TbsSkinTimeEdit,
  301.     TbsSkinBevel, TbsSkinButtonsBar, TbsSkinNoteBook, TbsSkinMonthCalendar,
  302.     TbsSkinXFormButton]);
  303.   RegisterComponents('BusinessSkinForm DB VCL',
  304.     [TbsSkinDBGrid, TbsSkinDBText,
  305.      TbsSkinDBEdit, TbsSkinDBMemo, TbsSkinDBMemo2,
  306.      TbsSkinDBCheckRadioBox, TbsSkinDBListBox, TbsSkinDBComboBox,
  307.      TbsSkinDBNavigator, TbsSkinDBImage, TbsSkinDBRadioGroup,
  308.      TbsSkinDBSpinEdit, TbsSkinDBRichEdit,
  309.      TbsSkinDBLookUpListBox, TbsSkinDBLookUpComboBox,
  310.      TbsSkinDBCalcEdit, TbsSkinDBDateEdit, TbsSkinDBTimeEdit]);
  311.   RegisterClass(TbsSkinTabSheet);
  312.   RegisterComponentEditor(TbsSkinPageControl, TbsSkinPageControlEditor);
  313.   RegisterComponentEditor(TbsSkinTabSheet, TbsSkinPageControlEditor);
  314.   RegisterPropertyEditor(TypeInfo(string), TbsColumn, 'FieldName', TbsColumnDataFieldProperty);
  315.   RegisterPropertyEditor(TypeInfo(string), TbsStoredSkin, 'FileName', TbsFilenameProperty);
  316.   RegisterPropertyEditor(TypeInfo(string), TbsCompressedStoredSkin, 'FileName', TbsFilenameProperty);
  317.   RegisterPropertyEditor(TypeInfo(string), TbsSkinDBLookUpListBox, 'KeyField', TbsSkinDBLookUpListBoxFieldProperty);
  318.   RegisterPropertyEditor(TypeInfo(string), TbsSkinDBLookUpListBox, 'ListField', TbsSkinDBLookUpListBoxFieldProperty);
  319.   RegisterPropertyEditor(TypeInfo(string), TbsSkinDBLookUpComboBox, 'KeyField', TbsSkinDBLookUpComboBoxFieldProperty);
  320.   RegisterPropertyEditor(TypeInfo(string), TbsSkinDBLookUpComboBox, 'ListField', TbsSkinDBLookUpComboBoxFieldProperty);
  321.   RegisterPropertyEditor(TypeInfo(string), TbsSkinButton, 'SkinDataName', TbsButtonSkinDataNameProperty);
  322.   RegisterPropertyEditor(TypeInfo(string), TbsSkinHeaderControl, 'SkinDataName', TbsButtonSkinDataNameProperty);
  323.   RegisterPropertyEditor(TypeInfo(string), TbsSkinListView, 'HeaderSkinDataName', TbsButtonSkinDataNameProperty);
  324.   RegisterPropertyEditor(TypeInfo(string), TbsSkinFileEdit, 'LVHeaderSkinDataName', TbsButtonSkinDataNameProperty);
  325.   RegisterPropertyEditor(TypeInfo(string), TbsSkinSaveFileEdit, 'LVHeaderSkinDataName', TbsButtonSkinDataNameProperty);
  326.   RegisterPropertyEditor(TypeInfo(string), TbsSkinOpenDialog, 'LVHeaderSkinDataName', TbsButtonSkinDataNameProperty);
  327.   RegisterPropertyEditor(TypeInfo(string), TbsSkinOpenPictureDialog, 'LVHeaderSkinDataName', TbsButtonSkinDataNameProperty);
  328.   RegisterPropertyEditor(TypeInfo(string), TbsSkinSaveDialog, 'LVHeaderSkinDataName', TbsButtonSkinDataNameProperty);
  329.   RegisterPropertyEditor(TypeInfo(string), TbsSkinSavePictureDialog, 'LVHeaderSkinDataName', TbsButtonSkinDataNameProperty);
  330.   RegisterPropertyEditor(TypeInfo(string), TbsSkinGauge, 'SkinDataName', TbsGaugeSkinDataNameProperty);
  331.   RegisterPropertyEditor(TypeInfo(string), TbsSkinMenuButton, 'SkinDataName', TbsMenuButtonSkinDataNameProperty);
  332.   RegisterPropertyEditor(TypeInfo(string), TbsSkinSpeedButton, 'SkinDataName', TbsButtonSkinDataNameProperty);
  333.   RegisterPropertyEditor(TypeInfo(string), TbsSkinMenuSpeedButton, 'SkinDataName', TbsMenuButtonSkinDataNameProperty);
  334.   RegisterPropertyEditor(TypeInfo(string), TbsSkinPanel, 'SkinDataName', TbsPanelSkinDataNameProperty);
  335.   RegisterPropertyEditor(TypeInfo(string), TbsSkinComboBox, 'SkinDataName', TbsComboBoxSkinDataNameProperty);
  336.   RegisterPropertyEditor(TypeInfo(string), TbsSkinListBox, 'SkinDataName', TbsListBoxSkinDataNameProperty);
  337.   RegisterPropertyEditor(TypeInfo(string), TbsSkinCheckListBox, 'SkinDataName', TbsCheckListBoxSkinDataNameProperty);
  338.   RegisterPropertyEditor(TypeInfo(string), TbsSkinSplitter, 'SkinDataName', TbsSplitterSkinDataNameProperty);
  339.   RegisterPropertyEditor(TypeInfo(TStrings),  TbsSkinNoteBook, 'Pages', TbsSetPagesProperty);
  340. end;
  341. function TbsSkinPageControlEditor.GetVerb(Index: Integer): string;
  342. begin
  343.   case Index of
  344.     0:  result := sNEW_PAGE;
  345.     1:  result := sDEL_PAGE;
  346.   end;
  347. end;
  348. procedure TbsSkinPageControlEditor.ExecuteVerb(Index: Integer);
  349. var
  350.   NewPage: TbsSkinCustomTabSheet;
  351.   PControl : TbsSkinPageControl;
  352. begin
  353.   if Component is TbsSkinPageControl then
  354.     PControl := TbsSkinPageControl(Component)
  355.   else PControl := TbsSkinPageControl(TbsSkinTabSheet(Component).PageControl);
  356.   case Index of
  357.     0:  begin  //  New Page
  358.           NewPage := TbsSkinTabSheet.Create(Designer.GetRoot);
  359.           with NewPage do
  360.           begin
  361.             Parent      := PControl;
  362.             PageControl := PControl;
  363.             Caption     := sTABSHEET_DEFAULT_NAME + IntToStr(PControl.PageCount);
  364.             Name        := Caption;
  365.           end;
  366.         end;
  367.     1:  begin  //  Delete Page
  368.           with PControl do
  369.           begin
  370.             NewPage := TbsSkinCustomTabSheet(ActivePage);
  371.             NewPage.PageControl := nil;
  372.             NewPage.Free;
  373.           end;
  374.         end;
  375.   end;
  376.   if Designer <> nil then Designer.Modified;
  377. end;
  378. function TbsSkinPageControlEditor.GetVerbCount: Integer;
  379. begin
  380.   result := 4;
  381. end;
  382. end.