home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 October / Chip_2001-10_cd1.bin / zkuste / delphi / kolekce / d456 / DCSLIB25.ZIP / DCPageColEdit.pas < prev    next >
Pascal/Delphi Source File  |  2001-06-20  |  7KB  |  305 lines

  1. {
  2.  BUSINESS CONSULTING
  3.  s a i n t - p e t e r s b u r g
  4.  
  5.          Components Library for Borland Delphi 4.x, 5.x
  6.          Copyright (c) 1998-2000 Alex'EM
  7.  
  8. }
  9. unit DCPageColEdit;
  10.  
  11. interface
  12. {$I DCConst.inc}
  13.  
  14. uses
  15.   Classes, Sysutils, 
  16.   {$IFDEF DELPHI_V6} 
  17.     DesignIntf, DesignEditors, DesignWindows, 
  18.   {$ELSE} 
  19.     Dsgnintf, DsgnWnds, 
  20.   {$ENDIF} 
  21.   DCStdCtrls, Dialogs, TypInfo;
  22.  
  23. type
  24.  
  25.   TPageControlEditor = class(TComponentEditor)
  26.   public
  27.     function GetVerbCount: integer; override;
  28.     function GetVerb(Index: integer): string; override;
  29.     procedure ExecuteVerb(Index: integer); override;
  30.     procedure Edit; override;
  31.   end;
  32.  
  33.   TOutBarEditor = class(TComponentEditor)
  34.   public
  35.     function GetVerbCount: integer; override;
  36.     function GetVerb(Index: integer): string; override;
  37.     procedure ExecuteVerb(Index: integer); override;
  38.     procedure Edit; override;
  39.   end;
  40.  
  41.   TPaleteBarEditor = class(TComponentEditor)
  42.   public
  43.     function GetVerbCount: integer; override;
  44.     function GetVerb(Index: integer): string; override;
  45.     procedure ExecuteVerb(Index: integer); override;
  46.     procedure Edit; override;
  47.   end;
  48.  
  49.   TActivePageField = class(TClassProperty)
  50.   private
  51.     procedure GetValueList(List: TStrings);
  52.   public
  53.     function GetAttributes: TPropertyAttributes; override;
  54.     function GetValue: string; override;
  55.     procedure GetValues(Proc: TGetStrProc); override;
  56.     procedure SetValue(const Value: string); override;
  57.   end;
  58.  
  59. implementation
  60.  
  61. { TPageControlEditor }
  62.  
  63. procedure TPageControlEditor.Edit;
  64. begin
  65.   inherited;
  66. end;
  67.  
  68. procedure TPageControlEditor.ExecuteVerb(Index: integer);
  69.  var
  70.   APage: TDCCustomPage;
  71.   APageControl: TDCCustomPageControl;
  72. begin
  73.   if (Component is TDCCustomPageControl) then
  74.     APageControl := TDCCustomPageControl(Component)
  75.   else
  76.     APageControl := TDCCustomPage(Component).PageControl;
  77.  
  78.   case Index of
  79.     0:
  80.       begin
  81.         APage := TDCPage.Create(Designer.GetRoot);
  82.         with APage do
  83.         begin
  84.           Name    := Designer.UniqueName(ClassName);
  85.           Caption := Name;
  86.           PageControl := APageControl;
  87.           if Assigned(APageControl.Images) then ImageIndex := PageIndex;
  88.       end;
  89.       end;
  90.     1:;
  91.     2: APageControl.SelectNextPage(True);
  92.     3: APageControl.SelectNextPage(False);
  93.   end;
  94.   APage := APageControl.ActivePage;
  95.   Designer.SelectComponent(APage);
  96.   Designer.Modified;
  97. end;
  98.  
  99. function TPageControlEditor.GetVerb(Index: integer): string;
  100. begin
  101.   case Index of
  102.    0: Result := 'Ne&w Page';
  103.    1: Result := '-';
  104.    2: Result := '&Next Page';
  105.    3: Result := '&Previous Page';
  106.   end;
  107. end;
  108.  
  109. function TPageControlEditor.GetVerbCount: integer;
  110. begin
  111.   Result :=  4;
  112. end;
  113.  
  114. { TOutBarEditor }
  115.  
  116. procedure TOutBarEditor.Edit;
  117. begin
  118.   inherited;
  119. end;
  120.  
  121. procedure TOutBarEditor.ExecuteVerb(Index: integer);
  122.  var
  123.   APage: TDCCustomPage;
  124.   APageControl: TDCCustomPageControl;
  125. begin
  126.   if (Component is TDCCustomPageControl) then
  127.     APageControl := TDCCustomPageControl(Component)
  128.   else
  129.     APageControl := TDCCustomPage(Component).PageControl;
  130.  
  131.   case Index of
  132.     0:
  133.       begin
  134.         APage := TDCOutBarPanel.Create(Designer.GetRoot);
  135.         with APage do
  136.         begin
  137.           Name    := Designer.UniqueName(ClassName);
  138.           Caption := Name;
  139.           PageControl := APageControl;
  140.           if Assigned(APageControl.Images) then ImageIndex := PageIndex;
  141.         end;
  142.       end;
  143.     1:;
  144.     2: APageControl.SelectNextPage(True);
  145.     3: APageControl.SelectNextPage(False);
  146.     5:
  147.       begin
  148.         APage := TDCPage.Create(Designer.GetRoot);
  149.         with APage do
  150.         begin
  151.           Name    := Designer.UniqueName(ClassName);
  152.           Caption := Name;
  153.           PageControl := APageControl;
  154.           if Assigned(APageControl.Images) then ImageIndex := PageIndex;
  155.         end;
  156.       end;
  157.   end;
  158.   APage := APageControl.ActivePage;
  159.   Designer.SelectComponent(APage);
  160.   Designer.Modified;
  161. end;
  162.  
  163. function TOutBarEditor.GetVerb(Index: integer): string;
  164. begin
  165.   case Index of
  166.    0: Result := 'Ne&w Page';
  167.    1: Result := '-';
  168.    2: Result := '&Next Page';
  169.    3: Result := '&Previous Page';
  170.    4: Result := '-';
  171.    5: Result := 'Ne&w Standard Page';
  172.   end;
  173. end;
  174.  
  175. function TOutBarEditor.GetVerbCount: integer;
  176. begin
  177.   Result :=  6;
  178. end;
  179.  
  180. { TGetCustomPageField }
  181.  
  182. function TActivePageField.GetAttributes: TPropertyAttributes;
  183. begin
  184.   Result := [paValueList, paSortList];
  185. end;
  186.  
  187. function TActivePageField.GetValue: string;
  188.  var
  189.   APageControl: TDCCustomPageControl;
  190. begin
  191.   APageControl := GetComponent(0) as TDCCustomPageControl;
  192.   if (APageControl <> nil) and (APageControl.ActivePage <> nil) then
  193.     Result := APageControl.ActivePage.Name
  194.   else
  195.     Result := '';
  196. end;
  197.  
  198. procedure TActivePageField.GetValueList(List: TStrings);
  199.  var
  200.   I: Integer;
  201.   APageControl: TDCCustomPageControl;
  202.   APage: TDCCustomPage;
  203. begin
  204.   APageControl := GetComponent(0) as TDCCustomPageControl;
  205.   try
  206.     for I := 0 to Designer.GetRoot.ComponentCount - 1 do
  207.     begin
  208.       if Designer.GetRoot.Components[I] is TDCCustomPage then
  209.       begin
  210.         APage := Designer.GetRoot.Components[I] as TDCCustomPage;
  211.         if (APage.PageControl = nil) or (APage.PageControl = APageControl) then
  212.           List.Add(APage.Name);
  213.       end;
  214.     end;
  215.   finally
  216.   end;
  217. end;
  218.  
  219. procedure TActivePageField.GetValues(Proc: TGetStrProc);
  220.  var
  221.   Values: TStringList;
  222.   I: integer;
  223. begin
  224.   Values := TStringList.Create;
  225.   try
  226.     GetValueList(Values);
  227.     for I := 0 to Values.Count - 1 do Proc(Values[I]);
  228.   finally
  229.     Values.Free;
  230.   end;
  231. end;
  232.  
  233. procedure TActivePageField.SetValue(const Value: string);
  234.  var
  235.   APageControl: TDCCustomPageControl;
  236.   i: integer;
  237. begin
  238.   APageControl := GetComponent(0) as TDCCustomPageControl;
  239.   if (APageControl <> nil) then
  240.   with APageControl do
  241.   begin
  242.     for i := 0 to PageCount-1 do
  243.       if AnsiCompareText(Pages[i].Name, Value) = 0 then
  244.       begin
  245.         ActivePage := Pages[i];
  246.         Exit;
  247.       end;
  248.   end;
  249. end;
  250.  
  251. { TPaleteBarEditor }
  252.  
  253. procedure TPaleteBarEditor.Edit;
  254. begin
  255.   inherited;
  256. end;
  257.  
  258. procedure TPaleteBarEditor.ExecuteVerb(Index: integer);
  259.  var
  260.   APage: TDCCustomPage;
  261.   APageControl: TDCCustomPageControl;
  262. begin
  263.   if (Component is TDCCustomPageControl) then
  264.     APageControl := TDCCustomPageControl(Component)
  265.   else
  266.     APageControl := TDCCustomPage(Component).PageControl;
  267.  
  268.   case Index of
  269.     0:
  270.       begin
  271.         APage := TDCPaleteBarPanel.Create(Designer.GetRoot);
  272.         with APage do
  273.         begin
  274.           Name    := Designer.UniqueName(ClassName);
  275.           Caption := Name;
  276.           PageControl := APageControl;
  277.           if Assigned(APageControl.Images) then ImageIndex := PageIndex;
  278.         end;
  279.       end;
  280.     1:;
  281.     2: APageControl.SelectNextPage(True);
  282.     3: APageControl.SelectNextPage(False);
  283.   end;
  284.   APage := APageControl.ActivePage;
  285.   Designer.SelectComponent(APage);
  286.   Designer.Modified;
  287. end;
  288.  
  289. function TPaleteBarEditor.GetVerb(Index: integer): string;
  290. begin
  291.   case Index of
  292.    0: Result := 'Ne&w Page';
  293.    1: Result := '-';
  294.    2: Result := '&Next Page';
  295.    3: Result := '&Previous Page';
  296.   end;
  297. end;
  298.  
  299. function TPaleteBarEditor.GetVerbCount: integer;
  300. begin
  301.   Result :=  4;
  302. end;
  303.  
  304. end.
  305.