home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1996 August / VPR9608A.BIN / del20try / install / data.z / STDREG.PAS < prev    next >
Pascal/Delphi Source File  |  1996-05-08  |  7KB  |  267 lines

  1. unit StdReg;
  2.  
  3. interface
  4.  
  5. uses DsgnIntf, Classes;
  6.  
  7. procedure Register;
  8.  
  9. implementation
  10.  
  11. uses SysUtils, Graphics, Menus, Forms, Controls, Dialogs, Buttons, StdCtrls,
  12.   ExtCtrls, PageEdit, Grids, MnuBuild, Mask, MaskText, MaskProp, PicEdit,
  13.   SBarEdit, ColEdit, ItemEdit, ImgList, NodeEdit, HCtlEdit, LibConst, ComCtrls;
  14.  
  15. { TActivePageProperty }
  16.  
  17. type
  18.   TActivePageProperty = class(TComponentProperty)
  19.   public
  20.     function GetAttributes: TPropertyAttributes; override;
  21.     procedure GetValues(Proc: TGetStrProc); override;
  22.   end;
  23.  
  24. function TActivePageProperty.GetAttributes: TPropertyAttributes;
  25. begin
  26.   Result := [paValueList];
  27. end;
  28.  
  29. procedure TActivePageProperty.GetValues(Proc: TGetStrProc);
  30. var
  31.   I: Integer;
  32.   Component: TComponent;
  33. begin
  34.   for I := 0 to Designer.Form.ComponentCount - 1 do
  35.   begin
  36.     Component := Designer.Form.Components[I];
  37.     if (Component.Name <> '') and (Component is TTabSheet) and
  38.       (TTabSheet(Component).PageControl = GetComponent(0)) then
  39.       Proc(Component.Name);
  40.   end;
  41. end;
  42.  
  43. { TPageControlEditor }
  44.  
  45. type
  46.   TPageControlEditor = class(TDefaultEditor)
  47.     procedure ExecuteVerb(Index: Integer); override;
  48.     function GetVerb(Index: Integer): string; override;
  49.     function GetVerbCount: Integer; override;
  50.   end;
  51.  
  52. const
  53.   PageControlVerbs: array[0..2] of Word = (SNewPage, SNextPage, SPrevPage);
  54.  
  55. procedure TPageControlEditor.ExecuteVerb(Index: Integer);
  56. var
  57.   PageControl: TPageControl;
  58.   Page: TTabSheet;
  59.   Designer: TFormDesigner;
  60. begin
  61.   if Component is TTabSheet then
  62.     PageControl := TTabSheet(Component).PageControl else
  63.     PageControl := TPageControl(Component);
  64.   if PageControl <> nil then
  65.   begin
  66.     Designer := Self.Designer;
  67.     if Index = 0 then
  68.     begin
  69.       Page := TTabSheet.Create(Designer.Form);
  70.       try
  71.         Page.Name := Designer.UniqueName(TTabSheet.ClassName);
  72.         Page.Parent := PageControl;
  73.         Page.PageControl := PageControl;
  74.       except
  75.         Page.Free;
  76.         raise;
  77.       end;
  78.       PageControl.ActivePage := Page;
  79.       Designer.SelectComponent(Page);
  80.       Designer.Modified;
  81.     end else
  82.     begin
  83.       Page := PageControl.FindNextPage(PageControl.ActivePage,
  84.         Index = 1, False);
  85.       if (Page <> nil) and (Page <> PageControl.ActivePage) then
  86.       begin
  87.         PageControl.ActivePage := Page;
  88.         if Component is TTabSheet then Designer.SelectComponent(Page);
  89.         Designer.Modified;
  90.       end;
  91.     end;
  92.   end;
  93. end;
  94.  
  95. function TPageControlEditor.GetVerb(Index: Integer): string;
  96. begin
  97.   Result := LoadStr(PageControlVerbs[Index]);
  98. end;
  99.  
  100. function TPageControlEditor.GetVerbCount: Integer;
  101. begin
  102.   Result := High(PageControlVerbs) + 1;
  103. end;
  104.  
  105. { TStatusPanelsProperty }
  106.  
  107. type
  108.   TStatusPanelsProperty = class(TClassProperty)
  109.   public
  110.     procedure Edit; override;
  111.     function GetAttributes: TPropertyAttributes; override;
  112.   end;
  113.  
  114. procedure TStatusPanelsProperty.Edit;
  115. begin
  116.   if EditStatusPanels(TStatusPanels(GetOrdValue)) then Modified;
  117. end;
  118.  
  119. function TStatusPanelsProperty.GetAttributes: TPropertyAttributes;
  120. begin
  121.   Result := [paDialog, paReadOnly];
  122. end;
  123.  
  124. { THeaderSectionsProperty }
  125.  
  126. type
  127.   THeaderSectionsProperty = class(TClassProperty)
  128.   public
  129.     procedure Edit; override;
  130.     function GetAttributes: TPropertyAttributes; override;
  131.   end;
  132.  
  133. procedure THeaderSectionsProperty.Edit;
  134. begin
  135.   if EditHeaderSections(THeaderSections(GetOrdValue)) then Modified;
  136. end;
  137.  
  138. function THeaderSectionsProperty.GetAttributes: TPropertyAttributes;
  139. begin
  140.   Result := [paDialog, paReadOnly];
  141. end;
  142.  
  143. { TListColumnsProperty }
  144.  
  145. type
  146.   TListColumnsProperty = class(TClassProperty)
  147.   public
  148.     procedure Edit; override;
  149.     function GetAttributes: TPropertyAttributes; override;
  150.   end;
  151.  
  152. procedure TListColumnsProperty.Edit;
  153. begin
  154.   if EditListViewColumns(TListColumns(GetOrdValue)) then Modified;
  155. end;
  156.  
  157. function TListColumnsProperty.GetAttributes: TPropertyAttributes;
  158. begin
  159.   Result := [paDialog, paReadOnly];
  160. end;
  161.  
  162. { TListItemsProperty }
  163.  
  164. type
  165.   TListItemsProperty = class(TClassProperty)
  166.   public
  167.     procedure Edit; override;
  168.     function GetAttributes: TPropertyAttributes; override;
  169.   end;
  170.  
  171. procedure TListItemsProperty.Edit;
  172. begin
  173.   if EditListViewItems(TListItems(GetOrdValue)) then Modified;
  174. end;
  175.  
  176. function TListItemsProperty.GetAttributes: TPropertyAttributes;
  177. begin
  178.   Result := [paDialog, paReadOnly];
  179. end;
  180.  
  181. { TTreeNodesProperty }
  182.  
  183. type
  184.   TTreeNodesProperty = class(TClassProperty)
  185.   public
  186.     procedure Edit; override;
  187.     function GetAttributes: TPropertyAttributes; override;
  188.   end;
  189.  
  190. procedure TTreeNodesProperty.Edit;
  191. begin
  192.   if EditTreeViewItems(TTreeNodes(GetOrdValue)) then Modified;
  193. end;
  194.  
  195. function TTreeNodesProperty.GetAttributes: TPropertyAttributes;
  196. begin
  197.   Result := [paDialog, paReadOnly];
  198. end;
  199.  
  200. type
  201.   TImageListEditor = class(TComponentEditor)
  202.   private
  203.     procedure ExecuteVerb(Index: Integer); override;
  204.     function GetVerb(Index: Integer): string; override;
  205.     function GetVerbCount: Integer; override;
  206.   end;
  207.  
  208. procedure TImageListEditor.ExecuteVerb(Index: Integer);
  209. begin
  210.   case Index of
  211.     0:
  212.       if EditImageList(Component as TImageList) and (Designer <> nil) then
  213.         Designer.Modified;
  214.   end;
  215. end;
  216.  
  217. function TImageListEditor.GetVerb(Index: Integer): string;
  218. begin
  219.   if Index = 0 then
  220.     Result := LoadStr(SImageEditor);
  221. end;
  222.  
  223. function TImageListEditor.GetVerbCount: Integer;
  224. begin
  225.   Result := 1;
  226. end;
  227.  
  228. { Registration }
  229.  
  230. procedure Register;
  231. begin
  232.   RegisterComponents(LoadStr(srStandard), [TMainMenu, TPopupMenu, TLabel,
  233.     TEdit, TMemo, TButton, TCheckBox, TRadioButton, TListBox, TComboBox,
  234.     TScrollBar, TGroupBox, TRadioGroup, TPanel]);
  235.  
  236.   RegisterComponents(LoadStr(srAdditional), [TBitBtn, TSpeedButton,
  237.     TMaskEdit, TStringGrid, TDrawGrid, TImage, TShape, TBevel,
  238.     TScrollBox]);
  239.  
  240.   RegisterComponents(LoadStr(srWin95), [TTabControl, TPageControl,
  241.     TTreeView, TListView, TImageList, THeaderControl, TRichEdit, 
  242.     TStatusBar, TTrackBar, TProgressBar, TUpDown, THotKey]);
  243.  
  244.   RegisterClasses([TTabSheet]);
  245.  
  246.   RegisterNoIcon([TMenuItem]);
  247.  
  248.   RegisterComponentEditor(TMenu, TMenuEditor);
  249.   RegisterComponentEditor(TImage, TGraphicEditor);
  250.  
  251.   RegisterComponentEditor(TPageControl, TPageControlEditor);
  252.   RegisterComponentEditor(TTabSheet, TPageControlEditor);
  253.   RegisterComponentEditor(TImageList, TImageListEditor);
  254.  
  255.   RegisterPropertyEditor(TypeInfo(string), TCustomMaskEdit, 'EditMask', TMaskProperty);
  256.   RegisterPropertyEditor(TypeInfo(string), TCustomMaskEdit, 'Text', TMaskTextProperty);
  257.  
  258.   RegisterPropertyEditor(TypeInfo(TTabSheet), TPageControl, 'ActivePage', TActivePageProperty);
  259.   RegisterPropertyEditor(TypeInfo(TStatusPanels), nil, '', TStatusPanelsProperty);
  260.   RegisterPropertyEditor(TypeInfo(THeaderSections), nil, '', THeaderSectionsProperty);
  261.   RegisterPropertyEditor(TypeInfo(TListColumns), nil, '', TListColumnsProperty);
  262.   RegisterPropertyEditor(TypeInfo(TListItems), nil, '', TListItemsProperty);
  263.   RegisterPropertyEditor(TypeInfo(TTreeNodes), nil, '', TTreeNodesProperty);
  264. end;
  265.  
  266. end.
  267.