home *** CD-ROM | disk | FTP | other *** search
- unit StdReg;
-
- interface
-
- uses DsgnIntf, Classes;
-
- procedure Register;
-
- implementation
-
- uses SysUtils, Graphics, Menus, Forms, Controls, Dialogs, Buttons, StdCtrls,
- ExtCtrls, PageEdit, Grids, MnuBuild, Mask, MaskText, MaskProp, PicEdit,
- SBarEdit, ColEdit, ItemEdit, ImgList, NodeEdit, HCtlEdit, LibConst, ComCtrls;
-
- { TActivePageProperty }
-
- type
- TActivePageProperty = class(TComponentProperty)
- public
- function GetAttributes: TPropertyAttributes; override;
- procedure GetValues(Proc: TGetStrProc); override;
- end;
-
- function TActivePageProperty.GetAttributes: TPropertyAttributes;
- begin
- Result := [paValueList];
- end;
-
- procedure TActivePageProperty.GetValues(Proc: TGetStrProc);
- var
- I: Integer;
- Component: TComponent;
- begin
- for I := 0 to Designer.Form.ComponentCount - 1 do
- begin
- Component := Designer.Form.Components[I];
- if (Component.Name <> '') and (Component is TTabSheet) and
- (TTabSheet(Component).PageControl = GetComponent(0)) then
- Proc(Component.Name);
- end;
- end;
-
- { TPageControlEditor }
-
- type
- TPageControlEditor = class(TDefaultEditor)
- procedure ExecuteVerb(Index: Integer); override;
- function GetVerb(Index: Integer): string; override;
- function GetVerbCount: Integer; override;
- end;
-
- const
- PageControlVerbs: array[0..2] of Word = (SNewPage, SNextPage, SPrevPage);
-
- procedure TPageControlEditor.ExecuteVerb(Index: Integer);
- var
- PageControl: TPageControl;
- Page: TTabSheet;
- Designer: TFormDesigner;
- begin
- if Component is TTabSheet then
- PageControl := TTabSheet(Component).PageControl else
- PageControl := TPageControl(Component);
- if PageControl <> nil then
- begin
- Designer := Self.Designer;
- if Index = 0 then
- begin
- Page := TTabSheet.Create(Designer.Form);
- try
- Page.Name := Designer.UniqueName(TTabSheet.ClassName);
- Page.Parent := PageControl;
- Page.PageControl := PageControl;
- except
- Page.Free;
- raise;
- end;
- PageControl.ActivePage := Page;
- Designer.SelectComponent(Page);
- Designer.Modified;
- end else
- begin
- Page := PageControl.FindNextPage(PageControl.ActivePage,
- Index = 1, False);
- if (Page <> nil) and (Page <> PageControl.ActivePage) then
- begin
- PageControl.ActivePage := Page;
- if Component is TTabSheet then Designer.SelectComponent(Page);
- Designer.Modified;
- end;
- end;
- end;
- end;
-
- function TPageControlEditor.GetVerb(Index: Integer): string;
- begin
- Result := LoadStr(PageControlVerbs[Index]);
- end;
-
- function TPageControlEditor.GetVerbCount: Integer;
- begin
- Result := High(PageControlVerbs) + 1;
- end;
-
- { TStatusPanelsProperty }
-
- type
- TStatusPanelsProperty = class(TClassProperty)
- public
- procedure Edit; override;
- function GetAttributes: TPropertyAttributes; override;
- end;
-
- procedure TStatusPanelsProperty.Edit;
- begin
- if EditStatusPanels(TStatusPanels(GetOrdValue)) then Modified;
- end;
-
- function TStatusPanelsProperty.GetAttributes: TPropertyAttributes;
- begin
- Result := [paDialog, paReadOnly];
- end;
-
- { THeaderSectionsProperty }
-
- type
- THeaderSectionsProperty = class(TClassProperty)
- public
- procedure Edit; override;
- function GetAttributes: TPropertyAttributes; override;
- end;
-
- procedure THeaderSectionsProperty.Edit;
- begin
- if EditHeaderSections(THeaderSections(GetOrdValue)) then Modified;
- end;
-
- function THeaderSectionsProperty.GetAttributes: TPropertyAttributes;
- begin
- Result := [paDialog, paReadOnly];
- end;
-
- { TListColumnsProperty }
-
- type
- TListColumnsProperty = class(TClassProperty)
- public
- procedure Edit; override;
- function GetAttributes: TPropertyAttributes; override;
- end;
-
- procedure TListColumnsProperty.Edit;
- begin
- if EditListViewColumns(TListColumns(GetOrdValue)) then Modified;
- end;
-
- function TListColumnsProperty.GetAttributes: TPropertyAttributes;
- begin
- Result := [paDialog, paReadOnly];
- end;
-
- { TListItemsProperty }
-
- type
- TListItemsProperty = class(TClassProperty)
- public
- procedure Edit; override;
- function GetAttributes: TPropertyAttributes; override;
- end;
-
- procedure TListItemsProperty.Edit;
- begin
- if EditListViewItems(TListItems(GetOrdValue)) then Modified;
- end;
-
- function TListItemsProperty.GetAttributes: TPropertyAttributes;
- begin
- Result := [paDialog, paReadOnly];
- end;
-
- { TTreeNodesProperty }
-
- type
- TTreeNodesProperty = class(TClassProperty)
- public
- procedure Edit; override;
- function GetAttributes: TPropertyAttributes; override;
- end;
-
- procedure TTreeNodesProperty.Edit;
- begin
- if EditTreeViewItems(TTreeNodes(GetOrdValue)) then Modified;
- end;
-
- function TTreeNodesProperty.GetAttributes: TPropertyAttributes;
- begin
- Result := [paDialog, paReadOnly];
- end;
-
- type
- TImageListEditor = class(TComponentEditor)
- private
- procedure ExecuteVerb(Index: Integer); override;
- function GetVerb(Index: Integer): string; override;
- function GetVerbCount: Integer; override;
- end;
-
- procedure TImageListEditor.ExecuteVerb(Index: Integer);
- begin
- case Index of
- 0:
- if EditImageList(Component as TImageList) and (Designer <> nil) then
- Designer.Modified;
- end;
- end;
-
- function TImageListEditor.GetVerb(Index: Integer): string;
- begin
- if Index = 0 then
- Result := LoadStr(SImageEditor);
- end;
-
- function TImageListEditor.GetVerbCount: Integer;
- begin
- Result := 1;
- end;
-
- { Registration }
-
- procedure Register;
- begin
- RegisterComponents(LoadStr(srStandard), [TMainMenu, TPopupMenu, TLabel,
- TEdit, TMemo, TButton, TCheckBox, TRadioButton, TListBox, TComboBox,
- TScrollBar, TGroupBox, TRadioGroup, TPanel]);
-
- RegisterComponents(LoadStr(srAdditional), [TBitBtn, TSpeedButton,
- TMaskEdit, TStringGrid, TDrawGrid, TImage, TShape, TBevel,
- TScrollBox]);
-
- RegisterComponents(LoadStr(srWin95), [TTabControl, TPageControl,
- TTreeView, TListView, TImageList, THeaderControl, TRichEdit,
- TStatusBar, TTrackBar, TProgressBar, TUpDown, THotKey]);
-
- RegisterClasses([TTabSheet]);
-
- RegisterNoIcon([TMenuItem]);
-
- RegisterComponentEditor(TMenu, TMenuEditor);
- RegisterComponentEditor(TImage, TGraphicEditor);
-
- RegisterComponentEditor(TPageControl, TPageControlEditor);
- RegisterComponentEditor(TTabSheet, TPageControlEditor);
- RegisterComponentEditor(TImageList, TImageListEditor);
-
- RegisterPropertyEditor(TypeInfo(string), TCustomMaskEdit, 'EditMask', TMaskProperty);
- RegisterPropertyEditor(TypeInfo(string), TCustomMaskEdit, 'Text', TMaskTextProperty);
-
- RegisterPropertyEditor(TypeInfo(TTabSheet), TPageControl, 'ActivePage', TActivePageProperty);
- RegisterPropertyEditor(TypeInfo(TStatusPanels), nil, '', TStatusPanelsProperty);
- RegisterPropertyEditor(TypeInfo(THeaderSections), nil, '', THeaderSectionsProperty);
- RegisterPropertyEditor(TypeInfo(TListColumns), nil, '', TListColumnsProperty);
- RegisterPropertyEditor(TypeInfo(TListItems), nil, '', TListItemsProperty);
- RegisterPropertyEditor(TypeInfo(TTreeNodes), nil, '', TTreeNodesProperty);
- end;
-
- end.
-