Sparta docked form designer prevents use of inherited forms
Original Reporter info from Mantis: sysrpl
-
Reporter name: Anthony Walter
Original Reporter info from Mantis: sysrpl
- Reporter name: Anthony Walter
Description:
When using the Sparta docked form designer forms which inherit from TForm or TCustomForm cannot be designed. For example, in my projects I sometimes need a form with a banner area up top and a footer area at the bottom. I have a custom form class registered to provide me with this often needed functionality and visual style:
http://cache.getlazarus.org/images/makedeb-small.png
When using the normal form designer I am able to install a package that registers custom form descriptors and I can set custom properties and events on an inherited form objects. These inherited forms also display new visual elements defined by my inherited form.
The Sparta docked form designer does not correctly handle any inherited form. When you attempt to create a new form using an inherited form as the base class Sparta shows NO form designer at all. This effectively makes it impossible to use inherited forms when the Sparta docked form designer is installed.
Steps to reproduce:
Make sure the Sparta docked form designer is installed.
Create a new package.
Define a form inside the package and place some controls on your form.
Optionally add some new published properties and events.
Add a new unit to the package to register custom forms like so:
unit RegisterYourCustomForms;
{$mode delphi}
interface
uses
Classes, SysUtils, Forms, ProjectIntf, NewItemIntf;
type
TCustomFormClass = class of TCustomForm;
procedure RegisterForm(FormClass: TCustomFormClass; const Caption, Description, UnitName: string);
implementation
{ TCustomFormDescriptor }
type
TCustomFormDescriptor = class(TFileDescPascalUnitWithResource)
private
FCaption: string;
FDescription: string;
FUnitName: string;
public
constructor Create(FormClass: TCustomFormClass; const Caption, Description, UnitName: string);
function GetResourceType: TResourceType; override;
function GetLocalizedName: string; override;
function GetLocalizedDescription: string; override;
function GetInterfaceUsesSection: string; override;
end;
var
Created: Boolean;
procedure RegisterForm(FormClass: TCustomFormClass; const Caption, Description, UnitName: string);
const
YourForms = 'Your Forms';
begin
RegisterNoIcon([FormClass]);
if not Created then
RegisterNewItemCategory(TNewIDEItemCategory.Create(YourForms));
Created := True;
RegisterProjectFileDescriptor(TCustomFormDescriptor.Create(FormClass, Caption,
Description, UnitName), YourForms);
end;
constructor TCustomFormDescriptor.Create(FormClass: TCustomFormClass;
const Caption, Description, UnitName: string);
begin
inherited Create;
FCaption := Caption;
FDescription := Description;
FUnitName := UnitName;
ResourceClass := FormClass;
Name := Caption;
RequiredPackages := 'LCL;YourPackageName';
UseCreateFormStatements := True;
end;
function TCustomFormDescriptor.GetResourceType: TResourceType;
begin
Result := rtRes;
end;
function TCustomFormDescriptor.GetLocalizedName: string;
begin
Result := FCaption;
end;
function TCustomFormDescriptor.GetLocalizedDescription: string;
begin
Result:= FDescription;
end;
function TCustomFormDescriptor.GetInterfaceUsesSection: string;
begin
Result := inherited GetInterfaceUsesSection;
Result := Result + ', Forms, '#13#10 +
' YourFormUnitName,'#13#10 +
' ' + FUnitName;
end;
end.
Call RegisterForm() in the register procedure with your inherited form class.
Install the new package.
Create a new project.
Select "File | New..." from the Lazarus main menu.
Select your custom form from the tree view in the "New.." dialog.
Result: You now have a new form unit added to the project, but there is NO form designer.
Expected: You should see your inherited form. It should have the controls you added already on it and if you added new properties or events they should be visible in the object inspector.