2
0
mattias 2 жил өмнө
parent
commit
63e3877211

+ 13 - 15
design/fresnelregister.pas

@@ -48,12 +48,11 @@ type
     procedure InvalidateRect(Sender: TObject; ARect: TRect; Erase: boolean);
     property DsgnForm: TFresnelForm read FDsgnForm;
   public
-    procedure GetObjInspNodeImageIndex(APersistent: TPersistent; var AIndex: integer); override;
   end;
 
-  { TFileDescPascalUnitWithMyForm }
+  { TFileDescPascalUnitWithFresnelForm }
 
-  TFileDescPascalUnitWithMyForm = class(TFileDescPascalUnitWithResource)
+  TFileDescPascalUnitWithFresnelForm = class(TFileDescPascalUnitWithResource)
   public
     constructor Create; override;
     function GetInterfaceUsesSection: string; override;
@@ -67,7 +66,10 @@ implementation
 
 procedure Register;
 begin
-
+  FormEditingHook.RegisterDesignerMediator(TFresnelFormMediator);
+  RegisterComponents('Fresnel',[TFresnelDiv,TFresnelSpan,TFresnelLabel]);
+  RegisterProjectFileDescriptor(TFileDescPascalUnitWithFresnelForm.Create,
+                                FileDescGroupName);
 end;
 
 { TFresnelFormMediator }
@@ -167,6 +169,8 @@ end;
 
 destructor TFresnelFormMediator.Destroy;
 begin
+  if FDsgnForm<>nil then FDsgnForm.Designer:=nil;
+  FDsgnForm:=nil;
   inherited Destroy;
 end;
 
@@ -177,15 +181,9 @@ begin
   LCLIntf.InvalidateRect(LCLForm.Handle,@ARect,Erase);
 end;
 
-procedure TFresnelFormMediator.GetObjInspNodeImageIndex(
-  APersistent: TPersistent; var AIndex: integer);
-begin
-  inherited GetObjInspNodeImageIndex(APersistent, AIndex);
-end;
-
-{ TFileDescPascalUnitWithMyForm }
+{ TFileDescPascalUnitWithFresnelForm }
 
-constructor TFileDescPascalUnitWithMyForm.Create;
+constructor TFileDescPascalUnitWithFresnelForm.Create;
 begin
   inherited Create;
   Name:='FresnelForm';
@@ -193,17 +191,17 @@ begin
   UseCreateFormStatements:=true;
 end;
 
-function TFileDescPascalUnitWithMyForm.GetInterfaceUsesSection: string;
+function TFileDescPascalUnitWithFresnelForm.GetInterfaceUsesSection: string;
 begin
   Result:='Classes, SysUtils, FresnelLCLControls, FresnelDOM, FresnelControls';
 end;
 
-function TFileDescPascalUnitWithMyForm.GetLocalizedName: string;
+function TFileDescPascalUnitWithFresnelForm.GetLocalizedName: string;
 begin
   Result:='FresnelForm';
 end;
 
-function TFileDescPascalUnitWithMyForm.GetLocalizedDescription: string;
+function TFileDescPascalUnitWithFresnelForm.GetLocalizedDescription: string;
 begin
   Result:='Create a new Fresnel form';
 end;

+ 4 - 3
src/fresnellclcontrols.pas

@@ -188,7 +188,8 @@ procedure TFresnelLCLRenderer.FillRect(const aColor: TFPColor;
 begin
   Canvas.Brush.FPColor:=aColor;
   Canvas.Brush.Style:=bsSolid;
-  Canvas.FillRect(Rect(floor(aRect.Left),floor(aRect.Top),ceil(aRect.Right),ceil(aRect.Bottom)));
+  Canvas.FillRect(Rect(floor(FOrigin.X+aRect.Left),floor(FOrigin.Y+aRect.Top),
+                       ceil(FOrigin.X+aRect.Right),ceil(FOrigin.Y+aRect.Bottom)));
 end;
 
 procedure TFresnelLCLRenderer.Line(const aColor: TFPColor; const x1, y1, x2,
@@ -196,7 +197,7 @@ procedure TFresnelLCLRenderer.Line(const aColor: TFPColor; const x1, y1, x2,
 begin
   Canvas.Pen.FPColor:=aColor;
   Canvas.Pen.Style:=psSolid;
-  Canvas.Line(round(x1),round(y1),round(x2),round(y2));
+  Canvas.Line(round(FOrigin.X+x1),round(FOrigin.Y+y1),round(FOrigin.X+x2),round(FOrigin.Y+y2));
 end;
 
 procedure TFresnelLCLRenderer.TextOut(const aLeft, aTop: TFresnelLength;
@@ -212,7 +213,7 @@ begin
   ts:=Canvas.TextStyle;
   ts.Opaque:=false;
   Canvas.TextStyle:=ts;
-  Canvas.TextOut(round(aLeft),round(aTop),aText);
+  Canvas.TextOut(round(FOrigin.X+aLeft),round(FOrigin.Y+aTop),aText);
 end;
 
 constructor TFresnelLCLRenderer.Create(AOwner: TComponent);

+ 1 - 1
src/fresnelrenderer.pas

@@ -14,9 +14,9 @@ type
 
   TFresnelRenderer = class(TComponent)
   private
-    FOrigin: TFresnelPoint;
     FSubPixel: boolean;
   protected
+    FOrigin: TFresnelPoint;
     procedure FillRect(const aColor: TFPColor; const aRect: TFresnelRect); virtual; abstract;
     procedure Line(const aColor: TFPColor; const x1, y1, x2, y2: TFresnelLength); virtual; abstract;
     procedure TextOut(const aLeft, aTop: TFresnelLength; const aFont: IFresnelFont; const aColor: TFPColor; const aText: string); virtual; abstract;