home *** CD-ROM | disk | FTP | other *** search
/ PC Format Collection 48 / SENT14D.ISO / tech / delphi / disk12 / lib.pak / STDREG.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-08-24  |  4.1 KB  |  150 lines

  1. unit StdReg;
  2.  
  3. interface
  4.  
  5. uses DsgnIntf, Classes;
  6.  
  7. type
  8.   TTabPageNameProperty = class(TPropertyEditor)
  9.     function GetAttributes: TPropertyAttributes; override;
  10.     procedure GetValues(Proc: TGetStrProc); override;
  11.     function GetValue: string; override;
  12.     procedure SetValue(const AValue: string); override;
  13.   end;
  14.  
  15.   TTabPageListProperty = class(TPropertyEditor)
  16.     function GetAttributes: TPropertyAttributes; override;
  17.     function GetValue: string; override;
  18.     procedure Edit; override;
  19.   end;
  20.  
  21.   TTabbedNotebookEditor = class(TDefaultEditor)
  22.     procedure ExecuteVerb(Index: Integer); override;
  23.     function GetVerb(Index: Integer): string; override;
  24.     function GetVerbCount: Integer; override;
  25.   end;
  26.  
  27. procedure Register;
  28.  
  29. implementation
  30.  
  31. uses SysUtils, Graphics, Menus, Forms, Controls, Dialogs, Tabs,
  32.   Buttons, StdCtrls, ExtCtrls, NoteBReg, TabNotBk, PageEdit, Grids,
  33.   MnuBuild, Outline, Mask, MaskText, MaskProp, PicEdit, LibConst;
  34.  
  35. { TTabPageNameProperty }
  36. function TTabPageNameProperty.GetAttributes: TPropertyAttributes;
  37. begin
  38.   Result := [paValueList];
  39. end;
  40.  
  41. procedure TTabPageNameProperty.GetValues(Proc: TGetStrProc);
  42. var
  43.   I: Integer;
  44.   Notebook: TTabbedNotebook;
  45.   Page: TTabPage;
  46. begin
  47.   Notebook := GetComponent(0) as TTabbedNotebook;
  48.   for I := 0 to Notebook.Pages.Count - 1 do
  49.   begin
  50.     Page := Notebook.Pages.Objects[I] as TTabPage;
  51.     Proc(Page.Caption);
  52.   end;
  53. end;
  54.  
  55. function TTabPageNameProperty.GetValue: string;
  56. begin
  57.   Result := GetStrValue;
  58. end;
  59.  
  60. procedure TTabPageNameProperty.SetValue(const AValue: string);
  61. begin
  62.   SetStrValue(AValue);
  63. end;
  64.  
  65. { TTabPageListProperty }
  66. function TTabPageListProperty.GetAttributes: TPropertyAttributes;
  67. begin
  68.   Result := [paDialog];
  69. end;
  70.  
  71. function TTabPageListProperty.GetValue: string;
  72. begin
  73.   FmtStr(Result, '(%s)', [GetPropType^.Name]);
  74. end;
  75.  
  76. procedure TTabPageListProperty.Edit;
  77. var
  78.   D: TNotebookEditDlg;
  79. begin
  80.   D := TNotebookEditDlg.Create(Application);
  81.   try
  82.     D.SetPageList(TStringList(GetOrdValue));
  83.     D.ShowModal;
  84.     if D.Modified then Designer.Modified;
  85.   finally
  86.     D.Free;
  87.   end;
  88. end;
  89.  
  90. { TNotebookEditor }
  91.  
  92. const
  93.   Verbs: array[0..1] of Word = (SNextPage, SPrevPage);
  94.  
  95. procedure TTabbedNotebookEditor.ExecuteVerb(Index: Integer);
  96. var
  97.   NewPage: Integer;
  98. begin
  99.   with TTabbedNotebook(Component) do
  100.   begin
  101.     NewPage := PageIndex;
  102.     if Index = 0 then
  103.       Inc(NewPage) else
  104.       Dec(NewPage);
  105.     if NewPage < 0 then NewPage := Pages.Count
  106.     else if NewPage >= Pages.Count then NewPage := 0;
  107.     if NewPage <> PageIndex then
  108.     begin
  109.       PageIndex := NewPage;
  110.       Designer.Modified;
  111.     end;
  112.   end;
  113. end;
  114.  
  115. function TTabbedNotebookEditor.GetVerb(Index: Integer): string;
  116. begin
  117.   Result := LoadStr(Verbs[Index]);
  118. end;
  119.  
  120. function TTabbedNotebookEditor.GetVerbCount: Integer;
  121. begin
  122.   Result := High(Verbs) + 1;
  123. end;
  124.  
  125. procedure Register;
  126. begin
  127.   RegisterComponents(LoadStr(srStandard), [TMainMenu, TPopupMenu, TLabel,
  128.     TEdit, TMemo, TButton, TCheckBox, TRadioButton, TListBox, TComboBox,
  129.     TScrollBar, TGroupBox, TRadioGroup, TPanel]);
  130.   RegisterComponents(LoadStr(srAdditional), [TBitBtn, TSpeedButton, TTabSet,
  131.     TNotebook, TTabbedNotebook, TMaskEdit, TOutline, TStringGrid, TDrawGrid, 
  132.     TImage, TShape, TBevel, THeader, TScrollBox]);
  133.  
  134.   RegisterNoIcon([TMenuItem]);
  135.  
  136.   RegisterComponentEditor(TMenu, TMenuEditor);
  137.   RegisterComponentEditor(TImage, TGraphicEditor);
  138.   RegisterComponentEditor(TNotebook, TNotebookEditor);
  139.   RegisterComponentEditor(TTabbedNotebook, TTabbedNotebookEditor);
  140.  
  141.   RegisterPropertyEditor(TypeInfo(string), TNotebook, 'ActivePage', TPageNameProperty);
  142.   RegisterPropertyEditor(TypeInfo(TStrings), TNotebook, 'Pages', TPageListProperty);
  143.   RegisterPropertyEditor(TypeInfo(string), TCustomMaskEdit, 'EditMask', TMaskProperty);
  144.   RegisterPropertyEditor(TypeInfo(string), TCustomMaskEdit, 'Text', TMaskTextProperty);
  145.   RegisterPropertyEditor(TypeInfo(string), TTabbedNotebook, 'ActivePage', TTabPageNameProperty);
  146.   RegisterPropertyEditor(TypeInfo(TStrings), TTabbedNotebook, 'Pages',    TTabPageListProperty);
  147. end;
  148.  
  149. end.
  150.