1 {
2  *****************************************************************************
3   See the file COPYING.modifiedLGPL.txt, included in this distribution,
4   for details about the license.
5  *****************************************************************************
6 
7   Author: Maciej Izak
8 
9   DaThoX 2004-2015
10   FreeSparta.com
11 }
12 
13 unit sparta_FakeCustom;
14 
15 {$mode delphi}{$H+}
16 
17 interface
18 
19 uses
20   Classes, SysUtils,
21   {$IFDEF USE_GENERICS_COLLECTIONS}
22     Generics.Defaults,
23   {$ENDIF}
24   // LCL
25   Forms, Controls,
26   // IdeIntf
27   FormEditingIntf, SrcEditorIntf, ObjectInspector,
28   // Sparta
29   sparta_InterfacesMDI, sparta_DesignedForm, sparta_BasicFakeCustom;
30 
31 type
32   { TDesignedFormImpl }
33 
34   TDesignedFormImpl = class(TFormImpl, IDesignedRealForm, IDesignedRealFormHelper, IDesignedForm, IDesignedFormIDE)
35   private
36     FLastActiveSourceWindow: TSourceEditorWindowInterface;
37   protected
GetLastActiveSourceWindownull38     function GetLastActiveSourceWindow: TSourceEditorWindowInterface; virtual;
39     procedure SetLastActiveSourceWindow(AValue: TSourceEditorWindowInterface); virtual;
40   public
41     procedure BeginUpdate; override;
42     procedure EndUpdate(AModified: Boolean = False); override;
43   end;
44 
45   { TFakeCustomForm }
46 
47   TFakeCustomForm = class(TForm, IDesignedRealForm, IDesignedForm, IDesignedFormIDE)
48   private
49     FDesignedForm: TDesignedFormImpl;
GetDesignedFormnull50     function GetDesignedForm: TDesignedFormImpl;
51   protected
52     property DesignedForm: TDesignedFormImpl read GetDesignedForm implements IDesignedForm, IDesignedFormIDE;
GetLogicalClientRectnull53     function GetLogicalClientRect: TRect; override;
54   protected
GetRealBoundsnull55     function GetRealBounds(AIndex: Integer): Integer; virtual;
56     procedure SetRealBounds(AIndex: Integer; AValue: Integer); virtual;
GetPublishedBoundsnull57     function GetPublishedBounds(AIndex: Integer): Integer; virtual;
58     procedure SetPublishedBounds(AIndex: Integer; AValue: Integer); virtual;
59 
60     procedure SetRealBorderStyle(AVal: TFormBorderStyle); virtual;
61     procedure SetRealBorderIcons(AVal: TBorderIcons); virtual;
62     procedure SetRealFormStyle(AVal: TFormStyle); virtual;
63     procedure SetRealPopupMode(AVal: TPopupMode); virtual;
64     procedure SetRealPopupParent(AVal: TCustomForm); virtual;
65 
GetRealBorderStylenull66     function GetRealBorderStyle: TFormBorderStyle; virtual;
GetRealBorderIconsnull67     function GetRealBorderIcons: TBorderIcons; virtual;
GetRealFormStylenull68     function GetRealFormStyle: TFormStyle; virtual;
GetRealPopupModenull69     function GetRealPopupMode: TPopupMode; virtual;
GetRealPopupParentnull70     function GetRealPopupParent: TCustomForm; virtual;
71   public
72     constructor CreateNew(AOwner: TComponent; Num: Integer = 0); override;
73     destructor Destroy; override;
74   published
75     property Left: Integer index 0 read GetPublishedBounds write SetPublishedBounds;
76     property Top: Integer index 1 read GetPublishedBounds write SetPublishedBounds;
77     property Width: Integer index 2 read GetPublishedBounds write SetPublishedBounds;
78     property Height: Integer index 3 read GetPublishedBounds write SetPublishedBounds;
79     property ClientWidth: Integer index 2 read GetPublishedBounds write SetPublishedBounds;
80     property ClientHeight: Integer index 3 read GetPublishedBounds write SetPublishedBounds;
81   end;
82 
83   { TDesignedNonControlFormImpl }
84 
85   TDesignedNonControlFormImpl = class(TDesignedFormImpl)
86   protected
GetPublishedBoundsnull87     function GetPublishedBounds(AIndex: Integer): Integer; override;
88     procedure SetPublishedBounds(AIndex: Integer; AValue: Integer); override;
89   end;
90 
91   { TFakeCustomNonControl }
92 
93   TFakeCustomNonControl = class(TNonControlProxyDesignerForm, IDesignedRealForm, IDesignedForm, IDesignedFormIDE)
94   private
95     FDesignedForm: TDesignedFormImpl;
GetDesignedFormnull96     function GetDesignedForm: TDesignedFormImpl;
97   protected
98     property DesignedForm: TDesignedFormImpl read GetDesignedForm implements IDesignedForm, IDesignedFormIDE;
GetLogicalClientRectnull99     function GetLogicalClientRect: TRect; override;
100   protected
GetRealBoundsnull101     function GetRealBounds(AIndex: Integer): Integer; virtual;
102     procedure SetRealBounds(AIndex: Integer; AValue: Integer); virtual;
GetPublishedBoundsnull103     function GetPublishedBounds(AIndex: Integer): Integer; override;
104     procedure SetPublishedBounds(AIndex: Integer; AValue: Integer); override;
105 
106     procedure SetRealBorderStyle(AVal: TFormBorderStyle); virtual;
107     procedure SetRealBorderIcons(AVal: TBorderIcons); virtual;
108     procedure SetRealFormStyle(AVal: TFormStyle); virtual;
109     procedure SetRealPopupMode(AVal: TPopupMode); virtual;
110     procedure SetRealPopupParent(AVal: TCustomForm); virtual;
111 
GetRealBorderStylenull112     function GetRealBorderStyle: TFormBorderStyle; virtual;
GetRealBorderIconsnull113     function GetRealBorderIcons: TBorderIcons; virtual;
GetRealFormStylenull114     function GetRealFormStyle: TFormStyle; virtual;
GetRealPopupModenull115     function GetRealPopupMode: TPopupMode; virtual;
GetRealPopupParentnull116     function GetRealPopupParent: TCustomForm; virtual;
117   protected
118     procedure SetLookupRoot(AValue: TComponent); override;
119     procedure SetMediator(AValue: TDesignerMediator); override;
120   public
121     constructor Create(AOwner: TComponent; ANonFormDesigner: INonFormDesigner); override;
122     destructor Destroy; override;
DockedDesignernull123     function DockedDesigner: boolean; override;
124     procedure SetBounds(ALeft, ATop, AWidth, AHeight: integer); override;
125   end;
126 
127 
128   { TDesignedFrameFormImpl }
129 
130   TDesignedFrameFormImpl = class(TDesignedFormImpl)
131   protected
GetPublishedBoundsnull132     function GetPublishedBounds(AIndex: Integer): Integer; override;
133     procedure SetPublishedBounds(AIndex: Integer; AValue: Integer); override;
134   end;
135 
136   { TFakeCustomFrame }
137 
138   TFakeCustomFrame = class(TFrameProxyDesignerForm, IDesignedRealForm, IDesignedForm, IDesignedFormIDE)
139   private
140     FDesignedForm: TDesignedFormImpl;
GetDesignedFormnull141     function GetDesignedForm: TDesignedFormImpl;
142   protected
143     property DesignedForm: TDesignedFormImpl read GetDesignedForm implements IDesignedForm, IDesignedFormIDE;
GetLogicalClientRectnull144     function GetLogicalClientRect: TRect; override;
145   protected
GetRealBoundsnull146     function GetRealBounds(AIndex: Integer): Integer; virtual;
147     procedure SetRealBounds(AIndex: Integer; AValue: Integer); virtual;
GetPublishedBoundsnull148     function GetPublishedBounds(AIndex: Integer): Integer; override;
149     procedure SetPublishedBounds(AIndex: Integer; AValue: Integer); override;
150 
151     procedure SetRealBorderStyle(AVal: TFormBorderStyle); virtual;
152     procedure SetRealBorderIcons(AVal: TBorderIcons); virtual;
153     procedure SetRealFormStyle(AVal: TFormStyle); virtual;
154     procedure SetRealPopupMode(AVal: TPopupMode); virtual;
155     procedure SetRealPopupParent(AVal: TCustomForm); virtual;
156 
GetRealBorderStylenull157     function GetRealBorderStyle: TFormBorderStyle; virtual;
GetRealBorderIconsnull158     function GetRealBorderIcons: TBorderIcons; virtual;
GetRealFormStylenull159     function GetRealFormStyle: TFormStyle; virtual;
GetRealPopupModenull160     function GetRealPopupMode: TPopupMode; virtual;
GetRealPopupParentnull161     function GetRealPopupParent: TCustomForm; virtual;
162   protected
163     procedure SetLookupRoot(AValue: TComponent); override;
164   public
165     constructor Create(AOwner: TComponent; ANonFormDesigner: INonFormDesigner); override;
166     destructor Destroy; override;
167 
DockedDesignernull168     function DockedDesigner: boolean; override;
169   end;
170 
171 implementation
172 
173 uses
174   sparta_MainIDE;
175 
176 type
177   TFormAccess = class(TForm);
178 
179 { TDesignedNonControlFormImpl }
180 
GetPublishedBoundsnull181 function TDesignedNonControlFormImpl.GetPublishedBounds(AIndex: Integer
182   ): Integer;
183 var
184   LBounds, LClientRect: TRect;
185   LMediator: TDesignerMediator;
186   LLookupRoot: TComponent;
187 begin
188   LLookupRoot := (FForm as TNonFormProxyDesignerForm).LookupRoot;
189   if LLookupRoot is TDataModule then
190     with TDataModule(LLookupRoot) do
191     case AIndex of
192       0: Result := DesignOffset.x;
193       1: Result := DesignOffset.y;
194       2: Result := DesignSize.x;
195       3: Result := DesignSize.y;
196     end
197   else
198   begin
199     LMediator := (FForm as TNonControlProxyDesignerForm).Mediator;
200     if (LLookupRoot <> nil) and (LMediator <> nil) then
201     begin
202       LMediator.GetFormBounds(LLookupRoot, LBounds, LClientRect);
203       //WriteLn(Format('get Bounds >>> %d %d %d %d',[LBounds.Left,LBounds.Top,LBounds.Right,LBounds.Bottom]));
204       //WriteLn(Format('get Client Rect >>> %d %d %d %d',[LClientRect.Left,LClientRect.Top,LClientRect.Right,LClientRect.Bottom]));
205       case AIndex of
206         0: Result := LBounds.Left;
207         1: Result := LBounds.Top;
208         2: Result := LClientRect.Right;
209         3: Result := LClientRect.Bottom;
210       end;
211     end
212     else
213       Result := 0; //inherited GetPublishedBounds(AIndex);
214   end
215 end;
216 
217 procedure TDesignedNonControlFormImpl.SetPublishedBounds(AIndex: Integer;
218   AValue: Integer);
219 var
220   LBounds, LClientRect: TRect;
221   LMediator: TDesignerMediator;
222   LLookupRoot: TComponent;
223 begin
224   LLookupRoot := (FForm as TNonFormProxyDesignerForm).LookupRoot;
225   if LLookupRoot is TDataModule then
226     with TDataModule(LLookupRoot) do
227     case AIndex of
228       0: DesignOffset := Point(AValue, DesignOffset.y);
229       1: DesignOffset := Point(DesignOffset.x, AValue);
230       2: DesignSize := Point(AValue, DesignSize.y);
231       3: DesignSize := Point(DesignSize.x, AValue);
232     end
233   else
234   begin
235     LMediator := (FForm as TNonControlProxyDesignerForm).Mediator;
236     if (LLookupRoot <> nil) and (LMediator <> nil) then
237     begin
238       LMediator.GetFormBounds(LLookupRoot, LBounds, LClientRect);
239       //WriteLn(Format('set Bounds >>> %d %d %d %d',[LBounds.Left,LBounds.Top,LBounds.Right,LBounds.Bottom]));
240       //WriteLn(Format('set Client Rect >>> %d %d %d %d',[LClientRect.Left,LClientRect.Top,LClientRect.Right,LClientRect.Bottom]));
241       case AIndex of
242         0: LBounds := Rect(AValue, LBounds.Top, AValue + LClientRect.Right, LBounds.Bottom);
243         1: LBounds := Rect(LBounds.Left, AValue, LBounds.Right, AValue + LClientRect.Bottom);
244         2: LClientRect := Rect(0, 0, AValue, LClientRect.Bottom);
245         3: LClientRect := Rect(0, 0, LClientRect.Right, AValue);
246       end;
247       if AIndex in [2, 3] then
248         LBounds := Rect(LBounds.Left, LBounds.Top, LBounds.Left + LClientRect.Right, LBounds.Top + LClientRect.Bottom);
249       LMediator.SetFormBounds(LLookupRoot,LBounds,LClientRect);
250     end;
251   end;
252 
253   // refresh for OI
254   inherited SetPublishedBounds(AIndex, AValue);
255 end;
256 
257 { TDesignedFrameFormImpl }
258 
GetPublishedBoundsnull259 function TDesignedFrameFormImpl.GetPublishedBounds(AIndex: Integer): Integer;
260 begin
261   if (FForm as TNonFormProxyDesignerForm).LookupRoot <> nil then
262     with (TNonFormProxyDesignerForm(FForm).LookupRoot as TFrame) do
263     case AIndex of
264       0: Result := Left;
265       1: Result := Top;
266       2: Result := Width;
267       3: Result := Height;
268     end
269   else
270     Result:=inherited GetPublishedBounds(AIndex);
271 end;
272 
273 procedure TDesignedFrameFormImpl.SetPublishedBounds(AIndex: Integer;
274   AValue: Integer);
275 begin
276   if (FForm as TNonFormProxyDesignerForm).LookupRoot <> nil then
277     with (TNonFormProxyDesignerForm(FForm).LookupRoot as TControl) do
278     case AIndex of
279       0: Left := AValue;
280       1: Top := AValue;
281       2: Width := AValue;
282       3: Height := AValue;
283     end;
284 
285   // refresh for OI
286   inherited SetPublishedBounds(AIndex, AValue);
287 end;
288 
289 { TFakeCustomFrame }
290 
GetDesignedFormnull291 function TFakeCustomFrame.GetDesignedForm: TDesignedFormImpl;
292 begin
293   if not Assigned(FDesignedForm) then
294     FDesignedForm := TDesignedFrameFormImpl.Create(Self,Self);
295 
296   Result := FDesignedForm;
297 end;
298 
TFakeCustomFrame.GetLogicalClientRectnull299 function TFakeCustomFrame.GetLogicalClientRect: TRect;
300 begin
301   Result := DesignedForm.GetLogicalClientRect(inherited GetLogicalClientRect);
302 end;
303 
GetRealBoundsnull304 function TFakeCustomFrame.GetRealBounds(AIndex: Integer): Integer;
305 begin
306   Result := inherited GetPublishedBounds(AIndex);
307 end;
308 
309 procedure TFakeCustomFrame.SetRealBounds(AIndex: Integer; AValue: Integer);
310 begin
311   inherited SetPublishedBounds(AIndex, AValue);
312 end;
313 
GetPublishedBoundsnull314 function TFakeCustomFrame.GetPublishedBounds(AIndex: Integer): Integer;
315 begin
316   Result := DesignedForm.GetPublishedBounds(AIndex);
317 end;
318 
319 procedure TFakeCustomFrame.SetPublishedBounds(AIndex: Integer; AValue: Integer);
320 begin
321   //DesignedForm.SetPublishedBounds(AIndex, AValue);
322 
323   if LookupRoot <> nil then
324     with LookupRoot as TControl do
325     case AIndex of
326       0: Left := AValue;
327       1: Top := AValue;
328       2: Width := AValue;
329       3: Height := AValue;
330     end;
331 end;
332 
333 constructor TFakeCustomFrame.Create(AOwner: TComponent;
334   ANonFormDesigner: INonFormDesigner);
335 begin
336   inherited Create(AOwner, ANonFormDesigner);
337 
338   //NonFormDesignerOptions := NonFormDesignerOptions - [nfdokSetBounds];
339 
340   Left := inherited Left;
341   Top := inherited Top;
342   Width := inherited Width;
343   Height := inherited Height;
344 end;
345 
346 destructor TFakeCustomFrame.Destroy;
347 begin
348   // we need to call "Screen.RemoveForm" to perform
349   // references back to nil by IDesignedForm to FDesignedForm
350   inherited Destroy;
351   if Assigned(FDesignedForm) then
352     FDesignedForm.Free;
353 end;
354 
TFakeCustomFrame.DockedDesignernull355 function TFakeCustomFrame.DockedDesigner: boolean;
356 begin
357   Result := True;
358 end;
359 
360 procedure TFakeCustomFrame.SetRealBorderStyle(AVal: TFormBorderStyle);
361 begin
362   inherited BorderStyle := AVal;
363 end;
364 
365 procedure TFakeCustomFrame.SetRealBorderIcons(AVal: TBorderIcons);
366 begin
367   inherited BorderIcons := AVal;
368 end;
369 
370 procedure TFakeCustomFrame.SetRealFormStyle(AVal: TFormStyle);
371 begin
372   inherited FormStyle := AVal;
373 end;
374 
375 procedure TFakeCustomFrame.SetRealPopupMode(AVal: TPopupMode);
376 begin
377   inherited PopupMode := AVal;
378 end;
379 
380 procedure TFakeCustomFrame.SetRealPopupParent(AVal: TCustomForm);
381 begin
382   inherited PopupParent := AVal;
383 end;
384 
TFakeCustomFrame.GetRealBorderStylenull385 function TFakeCustomFrame.GetRealBorderStyle: TFormBorderStyle;
386 begin
387   Result := inherited BorderStyle;
388 end;
389 
GetRealBorderIconsnull390 function TFakeCustomFrame.GetRealBorderIcons: TBorderIcons;
391 begin
392   Result := inherited BorderIcons;
393 end;
394 
GetRealFormStylenull395 function TFakeCustomFrame.GetRealFormStyle: TFormStyle;
396 begin
397   Result := inherited FormStyle;
398 end;
399 
GetRealPopupModenull400 function TFakeCustomFrame.GetRealPopupMode: TPopupMode;
401 begin
402   Result := inherited PopupMode;
403 end;
404 
TFakeCustomFrame.GetRealPopupParentnull405 function TFakeCustomFrame.GetRealPopupParent: TCustomForm;
406 begin
407   Result := inherited PopupParent;
408 end;
409 
410 procedure TFakeCustomFrame.SetLookupRoot(AValue: TComponent);
411 begin
412   inherited SetLookupRoot(AValue);
413 
414   if AValue <> nil then
415   begin
416     Left   := (LookupRoot as TFrame).Left;
417     Top    := (LookupRoot as TFrame).Top;
418     Width  := (LookupRoot as TFrame).Width;
419     Height := (LookupRoot as TFrame).Height;
420 
421     DesignedForm.RealWidth := Width;
422     DesignedForm.RealHeight := Height;
423   end
424   else
425     TSpartaMainIDE.TryFreeFormData(Self);
426 end;
427 
428 { TFakeCustomNonControl }
429 
GetDesignedFormnull430 function TFakeCustomNonControl.GetDesignedForm: TDesignedFormImpl;
431 begin
432   if not Assigned(FDesignedForm) then
433     FDesignedForm := TDesignedNonControlFormImpl.Create(Self,Self);
434 
435   Result := FDesignedForm;
436 end;
437 
GetLogicalClientRectnull438 function TFakeCustomNonControl.GetLogicalClientRect: TRect;
439 begin
440   Result := DesignedForm.GetLogicalClientRect(inherited GetLogicalClientRect);
441 end;
442 
GetRealBoundsnull443 function TFakeCustomNonControl.GetRealBounds(AIndex: Integer): Integer;
444 begin
445   Result := inherited GetPublishedBounds(AIndex);
446 end;
447 
448 procedure TFakeCustomNonControl.SetRealBounds(AIndex: Integer; AValue: Integer);
449 begin
450   inherited SetPublishedBounds(AIndex, AValue);
451 end;
452 
GetPublishedBoundsnull453 function TFakeCustomNonControl.GetPublishedBounds(AIndex: Integer): Integer;
454 begin
455   Result := DesignedForm.GetPublishedBounds(AIndex);
456 end;
457 
458 procedure TFakeCustomNonControl.SetPublishedBounds(AIndex: Integer; AValue: Integer);
459 begin
460   DesignedForm.SetPublishedBounds(AIndex, AValue);
461 end;
462 
463 constructor TFakeCustomNonControl.Create(AOwner: TComponent;
464   ANonFormDesigner: INonFormDesigner);
465 begin
466   inherited Create(AOwner, ANonFormDesigner);
467 
468   //NonFormDesignerOptions := [];
469 
470   Left := inherited Left;
471   Top := inherited Top;
472   Width := inherited Width;
473   Height := inherited Height;
474 end;
475 
476 destructor TFakeCustomNonControl.Destroy;
477 begin
478   // we need to call "Screen.RemoveForm" to perform
479   // references back to nil by IDesignedForm to FDesignedForm
480   inherited Destroy;
481   if Assigned(FDesignedForm) then
482     FDesignedForm.Free;
483 end;
484 
TFakeCustomNonControl.DockedDesignernull485 function TFakeCustomNonControl.DockedDesigner: boolean;
486 begin
487   Result := True;
488 end;
489 
490 procedure TFakeCustomNonControl.SetBounds(ALeft, ATop, AWidth, AHeight: integer
491   );
492 begin
493   SetDesignerFormBounds(ALeft, ATop, AWidth, AHeight);
494 end;
495 
496 procedure TFakeCustomNonControl.SetRealBorderStyle(AVal: TFormBorderStyle);
497 begin
498   inherited BorderStyle := AVal;
499 end;
500 
501 procedure TFakeCustomNonControl.SetRealBorderIcons(AVal: TBorderIcons);
502 begin
503   inherited BorderIcons := AVal;
504 end;
505 
506 procedure TFakeCustomNonControl.SetRealFormStyle(AVal: TFormStyle);
507 begin
508   inherited FormStyle := AVal;
509 end;
510 
511 procedure TFakeCustomNonControl.SetRealPopupMode(AVal: TPopupMode);
512 begin
513   inherited PopupMode := AVal;
514 end;
515 
516 procedure TFakeCustomNonControl.SetRealPopupParent(AVal: TCustomForm);
517 begin
518   inherited PopupParent := AVal;
519 end;
520 
GetRealBorderStylenull521 function TFakeCustomNonControl.GetRealBorderStyle: TFormBorderStyle;
522 begin
523   Result := inherited BorderStyle;
524 end;
525 
TFakeCustomNonControl.GetRealBorderIconsnull526 function TFakeCustomNonControl.GetRealBorderIcons: TBorderIcons;
527 begin
528   Result := inherited BorderIcons;
529 end;
530 
TFakeCustomNonControl.GetRealFormStylenull531 function TFakeCustomNonControl.GetRealFormStyle: TFormStyle;
532 begin
533   Result := inherited FormStyle;
534 end;
535 
GetRealPopupModenull536 function TFakeCustomNonControl.GetRealPopupMode: TPopupMode;
537 begin
538   Result := inherited PopupMode;
539 end;
540 
GetRealPopupParentnull541 function TFakeCustomNonControl.GetRealPopupParent: TCustomForm;
542 begin
543   Result := inherited PopupParent;
544 end;
545 
546 procedure TFakeCustomNonControl.SetLookupRoot(AValue: TComponent);
547 var
548   LBounds, LClientRect: TRect;
549 begin
550   inherited SetLookupRoot(AValue);
551 
552   if AValue <> nil then
553   begin
554     if LookupRoot is TDataModule then
555     begin
556       Width  := (LookupRoot as TDataModule).DesignSize.x;
557       Height := (LookupRoot as TDataModule).DesignSize.y;
558     end
559     else if (LookupRoot <> nil) and (Mediator <> nil) then
560     begin
561       Mediator.GetFormBounds(LookupRoot,LBounds,LClientRect);
562       //WriteLn(Format('Bounds >>> %d %d %d %d',[LBounds.Left,LBounds.Top,LBounds.Right,LBounds.Bottom]));
563       //WriteLn(Format('Client Rect >>> %d %d %d %d',[LClientRect.Left,LClientRect.Top,LClientRect.Right,LClientRect.Bottom]));
564       Width := LClientRect.Right;
565       Height := LClientRect.Bottom;
566     end else
567       Width := 1;
568 
569     DesignedForm.RealWidth := Width;
570     DesignedForm.RealHeight := Height;
571   end
572   else
573     TSpartaMainIDE.TryFreeFormData(Self);
574 end;
575 
576 procedure TFakeCustomNonControl.SetMediator(AValue: TDesignerMediator);
577 var
578   LBounds, LClientRect: TRect;
579 begin
580   inherited SetMediator(AValue);
581 
582   if (LookupRoot <> nil) and (Mediator <> nil) then
583   begin
584     Mediator.GetFormBounds(LookupRoot,LBounds,LClientRect);
585     //WriteLn(Format('Bounds >>> %d %d %d %d',[LBounds.Left,LBounds.Top,LBounds.Right,LBounds.Bottom]));
586     //WriteLn(Format('Client Rect >>> %d %d %d %d',[LClientRect.Left,LClientRect.Top,LClientRect.Right,LClientRect.Bottom]));
587     Width := LClientRect.Right;
588     Height := LClientRect.Bottom;
589   end else
590     ;//WriteLn('o kurwa eh');
591 end;
592 
593 { TFakeCustomForm }
594 
GetDesignedFormnull595 function TFakeCustomForm.GetDesignedForm: TDesignedFormImpl;
596 begin
597   if not Assigned(FDesignedForm) then
598     FDesignedForm := TDesignedFormImpl.Create(Self,Self);
599 
600   Result := FDesignedForm;
601 end;
602 
TFakeCustomForm.GetLogicalClientRectnull603 function TFakeCustomForm.GetLogicalClientRect: TRect;
604 begin
605   Result := DesignedForm.GetLogicalClientRect(inherited GetLogicalClientRect);
606 end;
607 
GetRealBoundsnull608 function TFakeCustomForm.GetRealBounds(AIndex: Integer): Integer;
609 begin
610   case AIndex of
611     0: Result := inherited Left;
612     1: Result := inherited Top;
613     2: Result := inherited Width;
614     3: Result := inherited Height;
615   end;
616 end;
617 
618 procedure TFakeCustomForm.SetRealBounds(AIndex: Integer; AValue: Integer);
619 begin
620   case AIndex of
621     0: inherited Left := AValue;
622     1: inherited Top := AValue;
623     2: inherited Width := AValue;
624     3: inherited Height := AValue;
625   end;
626 end;
627 
GetPublishedBoundsnull628 function TFakeCustomForm.GetPublishedBounds(AIndex: Integer): Integer;
629 begin
630   Result := DesignedForm.GetPublishedBounds(AIndex);
631 end;
632 
633 procedure TFakeCustomForm.SetPublishedBounds(AIndex: Integer; AValue: Integer);
634 begin
635   case AIndex of
636     0, 1: DesignedForm.SetPublishedBounds(AIndex, AValue);
637     2, 3:
638       begin
639         DesignedForm.SetPublishedBounds(AIndex, AValue);
640         SetRealBounds(AIndex, DesignedForm.GetPublishedBounds(AIndex));
641       end;
642   end;
643 end;
644 
645 constructor TFakeCustomForm.CreateNew(AOwner: TComponent; Num: Integer);
646 begin
647   inherited CreateNew(AOwner, Num);
648 
649   Left := inherited Left;
650   Top := inherited Top;
651   Width := inherited Width;
652   Height := inherited Height;
653 end;
654 
655 destructor TFakeCustomForm.Destroy;
656 begin
657   // we need to call "Screen.RemoveForm" to perform
658   // references back to nil by IDesignedForm to FDesignedForm
659   inherited Destroy;
660   if Assigned(FDesignedForm) then
661     FreeAndNil(FDesignedForm);
662 end;
663 
664 procedure TFakeCustomForm.SetRealBorderStyle(AVal: TFormBorderStyle);
665 begin
666   inherited BorderStyle := AVal;
667 end;
668 
669 procedure TFakeCustomForm.SetRealBorderIcons(AVal: TBorderIcons);
670 begin
671   inherited BorderIcons := AVal;
672 end;
673 
674 procedure TFakeCustomForm.SetRealFormStyle(AVal: TFormStyle);
675 begin
676   inherited FormStyle := AVal;
677 end;
678 
679 procedure TFakeCustomForm.SetRealPopupMode(AVal: TPopupMode);
680 begin
681   inherited PopupMode := AVal;
682 end;
683 
684 procedure TFakeCustomForm.SetRealPopupParent(AVal: TCustomForm);
685 begin
686   inherited PopupParent := AVal;
687 end;
688 
TFakeCustomForm.GetRealBorderStylenull689 function TFakeCustomForm.GetRealBorderStyle: TFormBorderStyle;
690 begin
691   Result := inherited BorderStyle;
692 end;
693 
TFakeCustomForm.GetRealBorderIconsnull694 function TFakeCustomForm.GetRealBorderIcons: TBorderIcons;
695 begin
696   Result := inherited BorderIcons;
697 end;
698 
TFakeCustomForm.GetRealFormStylenull699 function TFakeCustomForm.GetRealFormStyle: TFormStyle;
700 begin
701   Result := inherited FormStyle;
702 end;
703 
GetRealPopupModenull704 function TFakeCustomForm.GetRealPopupMode: TPopupMode;
705 begin
706   Result := inherited PopupMode;
707 end;
708 
TFakeCustomForm.GetRealPopupParentnull709 function TFakeCustomForm.GetRealPopupParent: TCustomForm;
710 begin
711   Result := inherited PopupParent;
712 end;
713 
714 { TDesignedFormImpl }
715 
TDesignedFormImpl.GetLastActiveSourceWindownull716 function TDesignedFormImpl.GetLastActiveSourceWindow: TSourceEditorWindowInterface;
717 begin
718   Result := FLastActiveSourceWindow;
719 end;
720 
721 procedure TDesignedFormImpl.SetLastActiveSourceWindow(
722   AValue: TSourceEditorWindowInterface);
723 begin
724   FLastActiveSourceWindow := AValue;
725 end;
726 
727 procedure TDesignedFormImpl.BeginUpdate;
728 begin
729   TFormAccess(FForm).SetDesigning(False, False);
730   inherited BeginUpdate;
731 end;
732 
733 procedure TDesignedFormImpl.EndUpdate(AModified: Boolean);
734 var
735   OI: TObjectInspectorDlg;
736 begin
737   TFormAccess(FForm).SetDesigning(True, False);
738   inherited EndUpdate(AModified);
739   if AModified and (FormEditingHook <> nil)
740   and (FormEditingHook.GetCurrentDesigner = FForm.Designer) then
741   begin
742     OI := FormEditingHook.GetCurrentObjectInspector;
743     if Assigned(OI) then
744       OI.RefreshPropertyValues;
745   end;
746 end;
747 
748 end.
749 
750