home *** CD-ROM | disk | FTP | other *** search
/ Inter.Net 55-1 / Inter.Net 55-1.iso / CBuilder / Setup / BCB / data.z / dsgnintf.int < prev    next >
Encoding:
Text File  |  1998-02-09  |  33.8 KB  |  801 lines

  1.  
  2. {*******************************************************}
  3. {                                                       }
  4. {       Delphi Visual Component Library                 }
  5. {                                                       }
  6. {       Copyright (c) 1995,98 Borland International     }
  7. {                                                       }
  8. {*******************************************************}
  9.  
  10. unit DsgnIntf;
  11.  
  12. interface
  13.  
  14. {$N+,S-,R-}
  15.  
  16. uses SysUtils, Classes, Graphics, Controls, Forms, TypInfo;
  17.  
  18. type
  19.  
  20. { TComponentList }
  21.  
  22.   TComponentList = class(TObject)
  23.   public
  24.     constructor Create;
  25.     destructor Destroy; override;
  26.     function Add(Item: TPersistent): Integer;
  27.     function Equals(List: TComponentList): Boolean;
  28.     property Count: Integer;
  29.     property Items[Index: Integer]: TPersistent; default;
  30.   end;
  31.  
  32. { Forward declaration }
  33.  
  34.   TComponentEditor = class;
  35.  
  36. { TFormDesigner }
  37.  
  38.   TFormDesigner = class(TDesigner)
  39.   public
  40.     function CreateMethod(const Name: string; TypeData: PTypeData): TMethod; virtual; abstract;
  41.     function GetMethodName(const Method: TMethod): string; virtual; abstract;
  42.     procedure GetMethods(TypeData: PTypeData; Proc: TGetStrProc); virtual; abstract;
  43.     function GetPrivateDirectory: string; virtual; abstract;
  44.     procedure GetSelections(List: TComponentList); virtual; abstract;
  45.     function MethodExists(const Name: string): Boolean; virtual; abstract;
  46.     procedure RenameMethod(const CurName, NewName: string); virtual; abstract;
  47.     procedure SelectComponent(Instance: TPersistent); virtual; abstract;
  48.     procedure SetSelections(List: TComponentList); virtual; abstract;
  49.     procedure ShowMethod(const Name: string); virtual; abstract;
  50.     function UniqueName(const BaseName: string): string; virtual; abstract;
  51.     procedure GetComponentNames(TypeData: PTypeData; Proc: TGetStrProc); virtual; abstract;
  52.     function GetComponent(const Name: string): TComponent; virtual; abstract;
  53.     function GetComponentName(Component: TComponent): string; virtual; abstract;
  54.     function GetObject(const Name: string): TPersistent; virtual; abstract;
  55.     function GetObjectName(Instance: TPersistent): string; virtual; abstract;
  56.     procedure GetObjectNames(TypeData: PTypeData; Proc: TGetStrProc); virtual; abstract;
  57.     function MethodFromAncestor(const Method: TMethod): Boolean; virtual; abstract;
  58.     function CreateComponent(ComponentClass: TComponentClass; Parent: TComponent;
  59.       Left, Top, Width, Height: Integer): TComponent; virtual; abstract;
  60.     function IsComponentLinkable(Component: TComponent): Boolean; virtual; abstract;
  61.     procedure MakeComponentLinkable(Component: TComponent); virtual; abstract;
  62.     function GetRoot: TComponent; virtual; abstract;
  63.     procedure Revert(Instance: TPersistent; PropInfo: PPropInfo); virtual; abstract;
  64.     function GetIsDormant: Boolean; virtual; abstract;
  65.     function HasInterface: Boolean; virtual; abstract;
  66.     function HasInterfaceMember(const Name: string): Boolean; virtual; abstract;
  67.     procedure AddToInterface(InvKind: Integer; const Name: string; VT: Word;
  68.       const TypeInfo: string); virtual; abstract;
  69.     procedure GetProjectModules(Proc: TGetModuleProc); virtual; abstract;
  70.     property IsDormant: Boolean;
  71.   end;
  72.  
  73. { TPropertyEditor
  74.   Edits a property of a component, or list of components, selected into the
  75.   Object Inspector.  The property editor is created based on the type of the
  76.   property being edited as determined by the types registered by
  77.   RegisterPropertyEditor.  The Object Inspector uses the a TPropertyEditor
  78.   for all modification to a property. GetName and GetValue are called to display
  79.   the name and value of the property.  SetValue is called whenever the user
  80.   requests to change the value.  Edit is called when the user double-clicks the
  81.   property in the Object Inspector. GetValues is called when the drop-down
  82.   list of a property is displayed.  GetProperties is called when the property
  83.   is expanded to show sub-properties.  AllEqual is called to decide whether or
  84.   not to display the value of the property when more than one component is
  85.   selected.
  86.  
  87.   The following are methods that can be overriden to change the behavior of
  88.   the property editor:
  89.  
  90.     Activate
  91.       Called whenever the property becomes selected in the object inspector.
  92.       This is potientially useful to allow certian property attributes to
  93.       to only be determined whenever the property is selected in the object
  94.       inspector. Only paSubProperties and paMultiSelect, returned from
  95.       GetAttributes, need to be accurate before this method is called.
  96.     AllEqual
  97.       Called whenever there are more than one components selected.  If this
  98.       method returns true, GetValue is called, otherwise blank is displayed
  99.       in the Object Inspector.  This is called only when GetAttributes
  100.       returns paMultiSelect.
  101.     Edit
  102.       Called when the '...' button is pressed or the property is double-clicked.
  103.       This can, for example, bring up a dialog to allow the editing the
  104.       component in some more meaningful fashion than by text (e.g. the Font
  105.       property).
  106.     GetAttributes
  107.       Returns the information for use in the Object Inspector to be able to
  108.       show the approprate tools.  GetAttributes return a set of type
  109.       TPropertyAttributes:
  110.         paValueList:     The property editor can return an enumerated list of
  111.                          values for the property.  If GetValues calls Proc
  112.                          with values then this attribute should be set.  This
  113.                          will cause the drop-down button to appear to the right
  114.                          of the property in the Object Inspector.
  115.         paSortList:      Object Inspector to sort the list returned by
  116.                          GetValues.
  117.         paSubProperties: The property editor has sub-properties that will be
  118.                          displayed indented and below the current property in
  119.                          standard outline format. If GetProperties will
  120.                          generate property objects then this attribute should
  121.                          be set.
  122.         paDialog:        Indicates that the Edit method will bring up a
  123.                          dialog.  This will cause the '...' button to be
  124.                          displayed to the right of the property in the Object
  125.                          Inspector.
  126.         paMultiSelect:   Allows the property to be displayed when more than
  127.                          one component is selected.  Some properties are not
  128.                          approprate for multi-selection (e.g. the Name
  129.                          property).
  130.         paAutoUpdate:    Causes the SetValue method to be called on each
  131.                          change made to the editor instead of after the change
  132.                          has been approved (e.g. the Caption property).
  133.         paReadOnly:      Value is not allowed to change.
  134.         paRevertable:    Allows the property to be reverted to the original
  135.                          value.  Things that shouldn't be reverted are nested
  136.                          properties (e.g. Fonts) and elements of a composite
  137.                          property such as set element values.
  138.     GetComponent
  139.       Returns the Index'th component being edited by this property editor.  This
  140.       is used to retieve the components.  A property editor can only refer to
  141.       multiple components when paMultiSelect is returned from GetAttributes.
  142.     GetEditLimit
  143.       Returns the number of character the user is allowed to enter for the
  144.       value.  The inplace editor of the object inspector will be have its
  145.       text limited set to the return value.  By default this limit is 255.
  146.     GetName
  147.       Returns a the name of the property.  By default the value is retrieved
  148.       from the type information with all underbars replaced by spaces.  This
  149.       should only be overriden if the name of the property is not the name
  150.       that should appear in the Object Inspector.
  151.     GetProperties
  152.       Should be overriden to call PropertyProc for every sub-property (or nested
  153.       property) of the property begin edited and passing a new TPropertyEdtior
  154.       for each sub-property.  By default, PropertyProc is not called and no
  155.       sub-properties are assumed.  TClassProperty will pass a new property
  156.       editor for each published property in a class.  TSetProperty passes a
  157.       new editor for each element in the set.
  158.     GetPropType
  159.       Returns the type information pointer for the propertie(s) being edited.
  160.     GetValue
  161.       Returns the string value of the property. By default this returns
  162.       '(unknown)'.  This should be overriden to return the appropriate value.
  163.     GetValues
  164.       Called when paValueList is returned in GetAttributes.  Should call Proc
  165.       for every value that is acceptable for this property.  TEnumProperty
  166.       will pass every element in the enumeration.
  167.     Initialize
  168.       Called after the property editor has been created but before it is used.
  169.       Many times property editors are created and because they are not a common
  170.       property across the entire selection they are thrown away.  Initialize is
  171.       called after it is determined the property editor is going to be used by
  172.       the object inspector and not just thrown away.
  173.     SetValue(Value)
  174.       Called to set the value of the property.  The property editor should be
  175.       able to translate the string and call one of the SetXxxValue methods. If
  176.       the string is not in the correct format or not an allowed value, the
  177.       property editor should generate an exception describing the problem. Set
  178.       value can ignore all changes and allow all editing of the property be
  179.       accomplished through the Edit method (e.g. the Picture property).
  180.  
  181.   Properties and methods useful in creating a new TPropertyEditor classes:
  182.  
  183.     Name property
  184.       Returns the name of the property returned by GetName
  185.     PrivateDirectory property
  186.       It is either the .EXE or the "working directory" as specified in
  187.       the registry under the key:
  188.         "HKEY_CURRENT_USER\Software\Borland\Delphi\3.0\Globals\PrivateDir"
  189.       If the property editor needs auxilury or state files (templates, examples,
  190.       etc) they should be stored in this directory.
  191.     Value property
  192.       The current value, as a string, of the property as returned by GetValue.
  193.     Modified
  194.       Called to indicate the value of the property has been modified.  Called
  195.       automatically by the SetXxxValue methods.  If you call a TProperty
  196.       SetXxxValue method directly, you *must* call Modified as well.
  197.     GetXxxValue
  198.       Gets the value of the first property in the Properties property.  Calls
  199.       the appropriate TProperty GetXxxValue method to retrieve the value.
  200.     SetXxxValue
  201.       Sets the value of all the properties in the Properties property.  Calls
  202.       the approprate TProperty SetXxxxValue methods to set the value. }
  203.  
  204.   TPropertyAttribute = (paValueList, paSubProperties, paDialog,
  205.     paMultiSelect, paAutoUpdate, paSortList, paReadOnly, paRevertable);
  206.   TPropertyAttributes = set of TPropertyAttribute;
  207.  
  208.   TPropertyEditor = class;
  209.  
  210.   TInstProp = record
  211.     Instance: TPersistent;
  212.     PropInfo: PPropInfo;
  213.   end;
  214.  
  215.   PInstPropList = ^TInstPropList;
  216.   TInstPropList = array[0..1023] of TInstProp;
  217.  
  218.   TGetPropEditProc = procedure(Prop: TPropertyEditor) of object;
  219.  
  220.   TPropertyEditor = class
  221.   protected
  222.     function GetPropInfo: PPropInfo;
  223.     function GetFloatValue: Extended;
  224.     function GetFloatValueAt(Index: Integer): Extended;
  225.     function GetMethodValue: TMethod;
  226.     function GetMethodValueAt(Index: Integer): TMethod;
  227.     function GetOrdValue: Longint;
  228.     function GetOrdValueAt(Index: Integer): Longint;
  229.     function GetStrValue: string;
  230.     function GetStrValueAt(Index: Integer): string;
  231.     function GetVarValue: Variant;
  232.     function GetVarValueAt(Index: Integer): Variant;
  233.     procedure Modified;
  234.     procedure SetFloatValue(Value: Extended);
  235.     procedure SetMethodValue(const Value: TMethod);
  236.     procedure SetOrdValue(Value: Longint);
  237.     procedure SetStrValue(const Value: string);
  238.     procedure SetVarValue(const Value: Variant);
  239.   public
  240.     destructor Destroy; override;
  241.     procedure Activate; virtual;
  242.     function AllEqual: Boolean; virtual;
  243.     procedure Edit; virtual;
  244.     function GetAttributes: TPropertyAttributes; virtual;
  245.     function GetComponent(Index: Integer): TPersistent;
  246.     function GetEditLimit: Integer; virtual;
  247.     function GetName: string; virtual;
  248.     procedure GetProperties(Proc: TGetPropEditProc); virtual;
  249.     function GetPropType: PTypeInfo;
  250.     function GetValue: string; virtual;
  251.     procedure GetValues(Proc: TGetStrProc); virtual;
  252.     procedure Initialize; virtual;
  253.     procedure Revert;
  254.     procedure SetValue(const Value: string); virtual;
  255.     function ValueAvailable: Boolean;
  256.     property Designer: TFormDesigner;
  257.     property PrivateDirectory: string;
  258.     property PropCount: Integer;
  259.     property Value: string;
  260.   end;
  261.  
  262.   TPropertyEditorClass = class of TPropertyEditor;
  263.  
  264. { TOrdinalProperty
  265.   The base class of all ordinal property editors.  It established that ordinal
  266.   properties are all equal if the GetOrdValue all return the same value. }
  267.  
  268.   TOrdinalProperty = class(TPropertyEditor)
  269.     function AllEqual: Boolean; override;
  270.     function GetEditLimit: Integer; override;
  271.   end;
  272.  
  273. { TIntegerProperty
  274.   Default editor for all Longint properties and all subtypes of the Longint
  275.   type (i.e. Integer, Word, 1..10, etc.).  Retricts the value entrered into
  276.   the property to the range of the sub-type. }
  277.  
  278.   TIntegerProperty = class(TOrdinalProperty)
  279.   public
  280.     function GetValue: string; override;
  281.     procedure SetValue(const Value: string); override;
  282.   end;
  283.  
  284. { TCharProperty
  285.   Default editor for all Char properties and sub-types of Char (i.e. Char,
  286.   'A'..'Z', etc.). }
  287.  
  288.   TCharProperty = class(TOrdinalProperty)
  289.   public
  290.     function GetValue: string; override;
  291.     procedure SetValue(const Value: string); override;
  292.   end;
  293.  
  294. { TEnumProperty
  295.   The default property editor for all enumerated properties (e.g. TShape =
  296.   (sCircle, sTriangle, sSquare), etc.). }
  297.  
  298.   TEnumProperty = class(TOrdinalProperty)
  299.   public
  300.     function GetAttributes: TPropertyAttributes; override;
  301.     function GetValue: string; override;
  302.     procedure GetValues(Proc: TGetStrProc); override;
  303.     procedure SetValue(const Value: string); override;
  304.   end;
  305.  
  306.   TBoolProperty = class(TEnumProperty)
  307.     function GetValue: string; override;
  308.     procedure GetValues(Proc: TGetStrProc); override;
  309.     procedure SetValue(const Value: string); override;
  310.   end;
  311.  
  312. { TFloatProperty
  313.   The default property editor for all floating point types (e.g. Float,
  314.   Single, Double, etc.) }
  315.  
  316.   TFloatProperty = class(TPropertyEditor)
  317.   public
  318.     function AllEqual: Boolean; override;
  319.     function GetValue: string; override;
  320.     procedure SetValue(const Value: string); override;
  321.   end;
  322.  
  323. { TStringProperty
  324.   The default property editor for all strings and sub types (e.g. string,
  325.   string[20], etc.). }
  326.  
  327.   TStringProperty = class(TPropertyEditor)
  328.   public
  329.     function AllEqual: Boolean; override;
  330.     function GetEditLimit: Integer; override;
  331.     function GetValue: string; override;
  332.     procedure SetValue(const Value: string); override;
  333.   end;
  334.  
  335. { TSetElementProperty
  336.   A property editor that edits an individual set element.  GetName is
  337.   changed to display the set element name instead of the property name and
  338.   Get/SetValue is changed to reflect the individual element state.  This
  339.   editor is created by the TSetProperty editor. }
  340.  
  341.   TSetElementProperty = class(TPropertyEditor)
  342.   public
  343.     destructor Destroy; override;
  344.     function AllEqual: Boolean; override;
  345.     function GetAttributes: TPropertyAttributes; override;
  346.     function GetName: string; override;
  347.     function GetValue: string; override;
  348.     procedure GetValues(Proc: TGetStrProc); override;
  349.     procedure SetValue(const Value: string); override;
  350.    end;
  351.  
  352. { TSetProperty
  353.   Default property editor for all set properties. This editor does not edit
  354.   the set directly but will display sub-properties for each element of the
  355.   set. GetValue displays the value of the set in standard set syntax. }
  356.  
  357.   TSetProperty = class(TOrdinalProperty)
  358.   public
  359.     function GetAttributes: TPropertyAttributes; override;
  360.     procedure GetProperties(Proc: TGetPropEditProc); override;
  361.     function GetValue: string; override;
  362.   end;
  363.  
  364. { TClassProperty
  365.   Default property editor for all objects.  Does not allow modifing the
  366.   property but does display the class name of the object and will allow the
  367.   editing of the object's properties as sub-properties of the property. }
  368.  
  369.   TClassProperty = class(TPropertyEditor)
  370.   public
  371.     function GetAttributes: TPropertyAttributes; override;
  372.     procedure GetProperties(Proc: TGetPropEditProc); override;
  373.     function GetValue: string; override;
  374.   end;
  375.  
  376. { TMethodProperty
  377.   Property editor for all method properties. }
  378.  
  379.   TMethodProperty = class(TPropertyEditor)
  380.   public
  381.     function AllEqual: Boolean; override;
  382.     procedure Edit; override;
  383.     function GetAttributes: TPropertyAttributes; override;
  384.     function GetEditLimit: Integer; override;
  385.     function GetValue: string; override;
  386.     procedure GetValues(Proc: TGetStrProc); override;
  387.     procedure SetValue(const AValue: string); override;
  388.     function GetFormMethodName: string; virtual;
  389.     function GetTrimmedEventName: string;
  390.   end;
  391.  
  392. { TComponentProperty
  393.   The default editor for TComponents.  It does not allow editing of the
  394.   properties of the component.  It allow the user to set the value of this
  395.   property to point to a component in the same form that is type compatible
  396.   with the property being edited (e.g. the ActiveControl property). }
  397.  
  398.   TComponentProperty = class(TPropertyEditor)
  399.   public
  400.     function GetAttributes: TPropertyAttributes; override;
  401.     function GetEditLimit: Integer; override;
  402.     function GetValue: string; override;
  403.     procedure GetValues(Proc: TGetStrProc); override;
  404.     procedure SetValue(const Value: string); override;
  405.   end;
  406.  
  407. { TComponentNameProperty
  408.   Property editor for the Name property.  It restricts the name property
  409.   from being displayed when more than one component is selected. }
  410.  
  411.   TComponentNameProperty = class(TStringProperty)
  412.   public
  413.     function GetAttributes: TPropertyAttributes; override;
  414.     function GetEditLimit: Integer; override;
  415.   end;
  416.  
  417. { TFontNameProperty
  418.   Editor for the TFont.FontName property.  Displays a drop-down list of all
  419.   the fonts known by Windows.}
  420.  
  421.   TFontNameProperty = class(TStringProperty)
  422.   public
  423.     function GetAttributes: TPropertyAttributes; override;
  424.     procedure GetValues(Proc: TGetStrProc); override;
  425.   end;
  426.  
  427. { TFontCharsetProperty
  428.   Editor for the TFont.Charset property.  Displays a drop-down list of the
  429.   character-set by Windows.}
  430.  
  431.   TFontCharsetProperty = class(TIntegerProperty)
  432.   public
  433.     function GetAttributes: TPropertyAttributes; override;
  434.     function GetValue: string; override;
  435.     procedure GetValues(Proc: TGetStrProc); override;
  436.     procedure SetValue(const Value: string); override;
  437.   end;
  438.  
  439. { TImeNameProperty
  440.   Editor for the TImeName property.  Displays a drop-down list of all
  441.   the IME names known by Windows.}
  442.  
  443.   TImeNameProperty = class(TStringProperty)
  444.   public
  445.     function GetAttributes: TPropertyAttributes; override;
  446.     procedure GetValues(Proc: TGetStrProc); override;
  447.   end;
  448.  
  449. { TColorProperty
  450.   Property editor for the TColor type.  Displays the color as a clXXX value
  451.   if one exists, otherwise displays the value as hex.  Also allows the
  452.   clXXX value to be picked from a list. }
  453.  
  454.   TColorProperty = class(TIntegerProperty)
  455.   public
  456.     procedure Edit; override;
  457.     function GetAttributes: TPropertyAttributes; override;
  458.     function GetValue: string; override;
  459.     procedure GetValues(Proc: TGetStrProc); override;
  460.     procedure SetValue(const Value: string); override;
  461.   end;
  462.  
  463. { TCursorProperty
  464.   Property editor for the TCursor type.  Displays the color as a crXXX value
  465.   if one exists, otherwise displays the value as hex.  Also allows the
  466.   clXXX value to be picked from a list. }
  467.  
  468.   TCursorProperty = class(TIntegerProperty)
  469.   public
  470.     function GetAttributes: TPropertyAttributes; override;
  471.     function GetValue: string; override;
  472.     procedure GetValues(Proc: TGetStrProc); override;
  473.     procedure SetValue(const Value: string); override;
  474.   end;
  475.  
  476. { TFontProperty
  477.   Property editor the Font property.  Brings up the font dialog as well as
  478.   allowing the properties of the object to be edited. }
  479.  
  480.   TFontProperty = class(TClassProperty)
  481.   public
  482.     procedure Edit; override;
  483.     function GetAttributes: TPropertyAttributes; override;
  484.   end;
  485.  
  486. { TModalResultProperty }
  487.  
  488.   TModalResultProperty = class(TIntegerProperty)
  489.   public
  490.     function GetAttributes: TPropertyAttributes; override;
  491.     function GetValue: string; override;
  492.     procedure GetValues(Proc: TGetStrProc); override;
  493.     procedure SetValue(const Value: string); override;
  494.   end;
  495.  
  496. { TShortCutProperty
  497.   Property editor the the ShortCut property.  Allows both typing in a short
  498.   cut value or picking a short-cut value from a list. }
  499.  
  500.   TShortCutProperty = class(TOrdinalProperty)
  501.   public
  502.     function GetAttributes: TPropertyAttributes; override;
  503.     function GetValue: string; override;
  504.     procedure GetValues(Proc: TGetStrProc); override;
  505.     procedure SetValue(const Value: string); override;
  506.   end;
  507.  
  508. { TMPFilenameProperty
  509.   Property editor for the TMediaPlayer.  Displays an File Open Dialog
  510.   for the name of the media file.}
  511.  
  512.   TMPFilenameProperty = class(TStringProperty)
  513.   public
  514.     procedure Edit; override;
  515.     function GetAttributes: TPropertyAttributes; override;
  516.   end;
  517.  
  518. { TTabOrderProperty
  519.   Property editor for the TabOrder property.  Prevents the property from being
  520.   displayed when more than one component is selected. }
  521.  
  522.   TTabOrderProperty = class(TIntegerProperty)
  523.   public
  524.     function GetAttributes: TPropertyAttributes; override;
  525.   end;
  526.  
  527. { TCaptionProperty
  528.   Property editor for the Caption and Text properties.  Updates the value of
  529.   the property for each change instead on when the property is approved. }
  530.  
  531.   TCaptionProperty = class(TStringProperty)
  532.   public
  533.     function GetAttributes: TPropertyAttributes; override;
  534.   end;
  535.  
  536. { TDateProperty
  537.   Property editor for date portion of TDateTime type. }
  538.  
  539.   TDateProperty = class(TPropertyEditor)
  540.     function GetAttributes: TPropertyAttributes; override;
  541.     function GetValue: string; override;
  542.     procedure SetValue(const Value: string); override;
  543.   end;
  544.  
  545. { TTimeProperty
  546.   Property editor for time portion of TDateTime type. }
  547.  
  548.   TTimeProperty = class(TPropertyEditor)
  549.     function GetAttributes: TPropertyAttributes; override;
  550.     function GetValue: string; override;
  551.     procedure SetValue(const Value: string); override;
  552.   end;
  553.  
  554. { TDateTimeProperty
  555.   Edits both date and time data... simultaneously!  }
  556.  
  557.   TDateTimeProperty = class(TPropertyEditor)
  558.     function GetAttributes: TPropertyAttributes; override;
  559.     function GetValue: string; override;
  560.     procedure SetValue(const Value: string); override;
  561.   end;
  562.  
  563.   EPropertyError = class(Exception);
  564.  
  565. { TComponentEditor
  566.   A component editor is created for each component that is selected in the
  567.   form designer based on the component's type (see GetComponentEditor and
  568.   RegisterComponentEditor).  When the component is double-clicked the Edit
  569.   method is called.  When the context menu for the component is invoked the
  570.   GetVerbCount and GetVerb methods are called to build the menu.  If one
  571.   of the verbs are selected ExecuteVerb is called.  Paste is called whenever
  572.   the component is pasted to the clipboard.  You only need to create a
  573.   component editor if you wish to add verbs to the context menu, change
  574.   the default double-click behavior, or paste an additional clipboard format.
  575.   The default component editor (TDefaultEditor) implements Edit to searchs the
  576.   properties of the component and generates (or navigates to) the OnCreate,
  577.   OnChanged, or OnClick event (whichever it finds first).  Whenever the
  578.   component modifies the component is *must* call Designer.Modified to inform
  579.   the designer that the form has been modified.
  580.  
  581.     Create(AComponent, ADesigner)
  582.       Called to create the component editor.  AComponent is the component to
  583.       be edited by the editor.  ADesigner is an interface to the designer to
  584.       find controls and create methods (this is not use often).
  585.     Edit
  586.       Called when the user double-clicks the component. The component editor can
  587.       bring up a dialog in responce to this method, for example, or some kind
  588.       of design expert.  If GetVerbCount is greater than zero, edit will execute
  589.       the first verb in the list (ExecuteVerb(0)).
  590.     ExecuteVerb(Index)
  591.       The Index'ed verb was selected by the use off the context menu.  The
  592.       meaning of this is determined by component editor.
  593.     GetVerb
  594.       The component editor should return a string that will be displayed in the
  595.       context menu.  It is the responsibility of the component editor to place
  596.       the & character and the '...' characters as appropriate.
  597.     GetVerbCount
  598.       The number of valid indexs to GetVerb and Execute verb.  The index assumed
  599.       to be zero based (i.e. 0..GetVerbCount - 1).
  600.     Copy
  601.       Called when the component is being copyied to the clipboard.  The
  602.       component's filed image is already on the clipboard.  This gives the
  603.       component editor a chance to paste a different type of format which is
  604.       ignored by the designer but might be recoginized by another application. }
  605.  
  606.   TComponentEditor = class
  607.   public
  608.     constructor Create(AComponent: TComponent; ADesigner: TFormDesigner); virtual;
  609.     procedure Edit; virtual;
  610.     procedure ExecuteVerb(Index: Integer); virtual;
  611.     function GetVerb(Index: Integer): string; virtual;
  612.     function GetVerbCount: Integer; virtual;
  613.     procedure Copy; virtual;
  614.     property Component: TComponent;
  615.     property Designer: TFormDesigner;
  616.   end;
  617.  
  618.   TComponentEditorClass = class of TComponentEditor;
  619.  
  620.   TDefaultEditor = class(TComponentEditor)
  621.   protected
  622.     procedure EditProperty(PropertyEditor: TPropertyEditor;
  623.       var Continue, FreeEditor: Boolean); virtual;
  624.   public
  625.     procedure Edit; override;
  626.   end;
  627.  
  628. { Global variables initialized internally by the form designer }
  629.  
  630. type
  631.   TFreeCustomModulesProc = procedure (Group: Integer);
  632.  
  633. var
  634.   FreeCustomModulesProc: TFreeCustomModulesProc;
  635.  
  636. { RegisterPropertyEditor
  637.   Registers a new property editor for the given type.  When a component is
  638.   selected the Object Inspector will create a property editor for each
  639.   of the component's properties.  The property editor is created based on
  640.   the type of the property.  If, for example, the property type is an
  641.   Integer, the property editor for Integer will be created (by default
  642.   that would be TIntegerProperty). Most properties do not need specialized
  643.   property editors.  For example, if the property is an ordinal type the
  644.   default property editor will restrict the range to the ordinal subtype
  645.   range (e.g. a property of type TMyRange = 1..10 will only allow values
  646.   between 1 and 10 to be entered into the property).  Enumerated types will
  647.   display a drop-down list of all the enumerated values (e.g. TShapes =
  648.   (sCircle, sSquare, sTriangle) will be edited by a drop-down list containing
  649.   only sCircle, sSquare and sTriangle).  A property editor need only be
  650.   created if default property editor or none of the existing property editors
  651.   are sufficient to edit the property.  This is typically because the
  652.   property is an object.  The properties are looked up newest to oldest.
  653.   This allows and existing property editor replaced by a custom property
  654.   editor.
  655.  
  656.     PropertyType
  657.       The type information pointer returned by the TypeInfo built-in function
  658.       (e.g. TypeInfo(TMyRange) or TypeInfo(TShapes)).
  659.  
  660.     ComponentClass
  661.       Type type of the component to which to restrict this type editor.  This
  662.       parameter can be left nil which will mean this type editor applies to all
  663.       properties of PropertyType.
  664.  
  665.     PropertyName
  666.       The name of the property to which to restrict this type editor.  This
  667.       parameter is ignored if ComponentClass is nil.  This paramter can be
  668.       an empty string ('') which will mean that this editor applies to all
  669.       properties of PropertyType in ComponentClass.
  670.  
  671.     EditorClass
  672.       The class of the editor to be created whenever a property of the type
  673.       passed in PropertyTypeInfo is displayed in the Object Inspector.  The
  674.       class will be created by calling EditorClass.Create. }
  675.  
  676. procedure RegisterPropertyEditor(PropertyType: PTypeInfo; ComponentClass: TClass;
  677.   const PropertyName: string; EditorClass: TPropertyEditorClass);
  678.  
  679. type
  680.   TPropertyMapperFunc = function(Obj: TPersistent;
  681.     PropInfo: PPropInfo): TPropertyEditorClass;
  682.     
  683. procedure RegisterPropertyMapper(Mapper: TPropertyMapperFunc);
  684.  
  685. procedure GetComponentProperties(Components: TComponentList;
  686.   Filter: TTypeKinds; Designer: TFormDesigner; Proc: TGetPropEditProc);
  687.  
  688. procedure RegisterComponentEditor(ComponentClass: TComponentClass;
  689.   ComponentEditor: TComponentEditorClass);
  690.  
  691. function GetComponentEditor(Component: TComponent;
  692.   Designer: TFormDesigner): TComponentEditor;
  693.  
  694. { Custom modules }
  695. { A custom module allows containers that descend from classes other than TForm
  696.   to be created and edited by the form designer. This is useful for other form
  697.   like containers (e.g. a report designer) or for specialized forms (e.g. an
  698.   ActiveForm) or for generic component containers (e.g. a TDataModule). It is
  699.   assumed that the base class registered will call InitInheritedComponent in its
  700.   constructor which will initialize the component from the associated DFM file
  701.   stored in the programs resources. See the constructors of TDataModule and
  702.   TForm for examples of how to write such a constructor.
  703.  
  704.   The following designer assumptions are made, depending on the base components
  705.   ancestor,
  706.  
  707.     If ComponentBaseClass descends from TForm,
  708.  
  709.        it is designed by creating an instance of the component as the form.
  710.        Allows designing TForm descendents and modifying their properties as
  711.        well as the form properties
  712.  
  713.     If ComponentBaseClass descends from TWinControl (but not TForm),
  714.  
  715.        it is designed by creating an instance of the control, placing it into a
  716.        design-time form.  The form's client size is in the default size of the
  717.        control.
  718.  
  719.     If ComponentBaseClass descends from TDataModule,
  720.  
  721.        it is designed by creating and instance of the class and creating a
  722.        special non-visual container designer to edit the components and display
  723.        the icons of the contained components.
  724.  
  725.   The module will appear in the project file with a colon and the base class
  726.   name appended after the component name (e.g. MyDataModle: TDataModule).
  727.  
  728.   Note it is not legal to register anything that does not desend from one of
  729.   the above.
  730.  
  731.   TCustomModule class
  732.     This an instance of this class is created for each custom module that is
  733.     loaded. This class is also destroyed whenever the module is unloaded.
  734.     The Saving method is called prior to the file being saved. When the context
  735.     menu for the module is invoked the GetVerbCount and GetVerb methods are
  736.     called to build the menu.  If one of the verbs are selected ExecuteVerb is
  737.     called.
  738.  
  739.     ExecuteVerb(Index)
  740.       The Index'ed verb was selected by the use off the context menu.  The
  741.       meaning of this is determined by custom module.
  742.     GetAttributes
  743.       Only used for TWinControl object to determine if the control is "client
  744.       aligned" in the designer or if the object should sized independently
  745.       from the designer.  This is a set for future expansion.
  746.     GetVerb(Index)
  747.       The custom module should return a string that will be displayed in the
  748.       context menu.  It is the responsibility of the custom module to place
  749.       the & character and the '...' characters as appropriate.
  750.     GetVerbCount
  751.       The number of valid indexs to GetVerb and Execute verb.  The index assumed
  752.       to be zero based (i.e. 0..GetVerbCount - 1).
  753.     Saving
  754.       Called prior to the module being saved.
  755.     ValidateComponent(Component)
  756.       ValidateCompoennt is called whenever a component is created by the
  757.       user for the designer to contain.  The intent is for this procedure to
  758.       raise an exception with a descriptive message if the component is not
  759.       applicable for the container. For example, a TComponent module should
  760.       throw an exception if the component descends from TControl.
  761.     Root
  762.       This is the instance being designed.}
  763.  
  764. type
  765.   TCustomModuleAttribute = (cmaVirtualSize);
  766.   TCustomModuleAttributes = set of TCustomModuleAttribute;
  767.  
  768.   TCustomModule = class
  769.   public
  770.     constructor Create(ARoot: TComponent); virtual;
  771.     procedure ExecuteVerb(Index: Integer); virtual;
  772.     function GetAttributes: TCustomModuleAttributes; virtual;
  773.     function GetVerb(Index: Integer): string; virtual;
  774.     function GetVerbCount: Integer; virtual;
  775.     procedure Saving; virtual;
  776.     procedure ValidateComponent(Component: TComponent); virtual;
  777.     property Root: TComponent;
  778.   end;
  779.  
  780.   TCustomModuleClass = class of TCustomModule;
  781.  
  782.   TRegisterCustomModuleProc = procedure (Group: Integer;
  783.     ComponentBaseClass: TComponentClass;
  784.     CustomModuleClass: TCustomModuleClass);
  785.  
  786. procedure RegisterCustomModule(ComponentBaseClass: TComponentClass;
  787.   CustomModuleClass: TCustomModuleClass);
  788.  
  789. var
  790.   RegisterCustomModuleProc: TRegisterCustomModuleProc;
  791.  
  792. { Routines used by the form designer for package management }
  793.  
  794. function NewEditorGroup: Integer;
  795. procedure FreeEditorGroup(Group: Integer);
  796.  
  797. var  // number of significant characters in identifiers
  798.   MaxIdentLength: Byte = 63;
  799.  
  800. implementation
  801.