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   // LCL
22   Forms, Controls,
23   // IdeIntf
24   FormEditingIntf, SrcEditorIntf, ObjectInspector,
25   // Sparta
26   sparta_InterfacesMDI, sparta_DesignedForm, sparta_BasicFakeCustom;
27 
28 type
29   { TDesignedFormImpl }
30 
31   TDesignedFormImpl = class(TFormImpl, IDesignedRealForm, IDesignedRealFormHelper, IDesignedForm, IDesignedFormIDE)
32   private
33     FLastActiveSourceWindow: TSourceEditorWindowInterface;
34   protected
GetLastActiveSourceWindownull35     function GetLastActiveSourceWindow: TSourceEditorWindowInterface; virtual;
36     procedure SetLastActiveSourceWindow(AValue: TSourceEditorWindowInterface); virtual;
37   public
38     procedure BeginUpdate; override;
39     procedure EndUpdate(AModified: Boolean = False); override;
40   end;
41 
42   { TFakeCustomForm }
43 
44   TFakeCustomForm = class(TForm, IDesignedRealForm, IDesignedForm, IDesignedFormIDE)
45   private
46     FDesignedForm: TDesignedFormImpl;
GetDesignedFormnull47     function GetDesignedForm: TDesignedFormImpl;
48   protected
49     property DesignedForm: TDesignedFormImpl read GetDesignedForm implements IDesignedForm, IDesignedFormIDE;
GetLogicalClientRectnull50     function GetLogicalClientRect: TRect; override;
51   protected
GetRealBoundsnull52     function GetRealBounds(AIndex: Integer): Integer; virtual;
53     procedure SetRealBounds(AIndex: Integer; AValue: Integer); virtual;
GetPublishedBoundsnull54     function GetPublishedBounds(AIndex: Integer): Integer; virtual;
55     procedure SetPublishedBounds(AIndex: Integer; AValue: Integer); virtual;
56 
57     procedure SetRealBorderStyle(AVal: TFormBorderStyle); virtual;
58     procedure SetRealBorderIcons(AVal: TBorderIcons); virtual;
59     procedure SetRealFormStyle(AVal: TFormStyle); virtual;
60     procedure SetRealPopupMode(AVal: TPopupMode); virtual;
61     procedure SetRealPopupParent(AVal: TCustomForm); virtual;
62 
GetRealBorderStylenull63     function GetRealBorderStyle: TFormBorderStyle; virtual;
GetRealBorderIconsnull64     function GetRealBorderIcons: TBorderIcons; virtual;
GetRealFormStylenull65     function GetRealFormStyle: TFormStyle; virtual;
GetRealPopupModenull66     function GetRealPopupMode: TPopupMode; virtual;
GetRealPopupParentnull67     function GetRealPopupParent: TCustomForm; virtual;
68   public
69     constructor CreateNew(AOwner: TComponent; Num: Integer = 0); override;
70     destructor Destroy; override;
71   published
72     property Left: Integer index 0 read GetPublishedBounds write SetPublishedBounds;
73     property Top: Integer index 1 read GetPublishedBounds write SetPublishedBounds;
74     property Width: Integer index 2 read GetPublishedBounds write SetPublishedBounds;
75     property Height: Integer index 3 read GetPublishedBounds write SetPublishedBounds;
76     property ClientWidth: Integer index 2 read GetPublishedBounds write SetPublishedBounds;
77     property ClientHeight: Integer index 3 read GetPublishedBounds write SetPublishedBounds;
78   end;
79 
80   { TDesignedNonControlFormImpl }
81 
82   TDesignedNonControlFormImpl = class(TDesignedFormImpl)
83   protected
GetPublishedBoundsnull84     function GetPublishedBounds(AIndex: Integer): Integer; override;
85     procedure SetPublishedBounds(AIndex: Integer; AValue: Integer); override;
86   end;
87 
88   { TFakeCustomNonControl }
89 
90   TFakeCustomNonControl = class(TNonControlProxyDesignerForm, IDesignedRealForm, IDesignedForm, IDesignedFormIDE)
91   private
92     FDesignedForm: TDesignedFormImpl;
GetDesignedFormnull93     function GetDesignedForm: TDesignedFormImpl;
94   protected
95     property DesignedForm: TDesignedFormImpl read GetDesignedForm implements IDesignedForm, IDesignedFormIDE;
GetLogicalClientRectnull96     function GetLogicalClientRect: TRect; override;
97   protected
GetRealBoundsnull98     function GetRealBounds(AIndex: Integer): Integer; virtual;
99     procedure SetRealBounds(AIndex: Integer; AValue: Integer); virtual;
GetPublishedBoundsnull100     function GetPublishedBounds(AIndex: Integer): Integer; override;
101     procedure SetPublishedBounds(AIndex: Integer; AValue: Integer); override;
102 
103     procedure SetRealBorderStyle(AVal: TFormBorderStyle); virtual;
104     procedure SetRealBorderIcons(AVal: TBorderIcons); virtual;
105     procedure SetRealFormStyle(AVal: TFormStyle); virtual;
106     procedure SetRealPopupMode(AVal: TPopupMode); virtual;
107     procedure SetRealPopupParent(AVal: TCustomForm); virtual;
108 
GetRealBorderStylenull109     function GetRealBorderStyle: TFormBorderStyle; virtual;
GetRealBorderIconsnull110     function GetRealBorderIcons: TBorderIcons; virtual;
GetRealFormStylenull111     function GetRealFormStyle: TFormStyle; virtual;
GetRealPopupModenull112     function GetRealPopupMode: TPopupMode; virtual;
GetRealPopupParentnull113     function GetRealPopupParent: TCustomForm; virtual;
114   protected
115     procedure SetLookupRoot(AValue: TComponent); override;
116     procedure SetMediator(AValue: TDesignerMediator); override;
117   public
118     constructor Create(AOwner: TComponent; ANonFormDesigner: INonFormDesigner); override;
119     destructor Destroy; override;
DockedDesignernull120     function DockedDesigner: boolean; override;
121     procedure SetBounds(ALeft, ATop, AWidth, AHeight: integer); override;
122   end;
123 
124 
125   { TDesignedFrameFormImpl }
126 
127   TDesignedFrameFormImpl = class(TDesignedFormImpl)
128   protected
GetPublishedBoundsnull129     function GetPublishedBounds(AIndex: Integer): Integer; override;
130     procedure SetPublishedBounds(AIndex: Integer; AValue: Integer); override;
131   end;
132 
133   { TFakeCustomFrame }
134 
135   TFakeCustomFrame = class(TFrameProxyDesignerForm, IDesignedRealForm, IDesignedForm, IDesignedFormIDE)
136   private
137     FDesignedForm: TDesignedFormImpl;
GetDesignedFormnull138     function GetDesignedForm: TDesignedFormImpl;
139   protected
140     property DesignedForm: TDesignedFormImpl read GetDesignedForm implements IDesignedForm, IDesignedFormIDE;
GetLogicalClientRectnull141     function GetLogicalClientRect: TRect; override;
142   protected
GetRealBoundsnull143     function GetRealBounds(AIndex: Integer): Integer; virtual;
144     procedure SetRealBounds(AIndex: Integer; AValue: Integer); virtual;
GetPublishedBoundsnull145     function GetPublishedBounds(AIndex: Integer): Integer; override;
146     procedure SetPublishedBounds(AIndex: Integer; AValue: Integer); override;
147 
148     procedure SetRealBorderStyle(AVal: TFormBorderStyle); virtual;
149     procedure SetRealBorderIcons(AVal: TBorderIcons); virtual;
150     procedure SetRealFormStyle(AVal: TFormStyle); virtual;
151     procedure SetRealPopupMode(AVal: TPopupMode); virtual;
152     procedure SetRealPopupParent(AVal: TCustomForm); virtual;
153 
GetRealBorderStylenull154     function GetRealBorderStyle: TFormBorderStyle; virtual;
GetRealBorderIconsnull155     function GetRealBorderIcons: TBorderIcons; virtual;
GetRealFormStylenull156     function GetRealFormStyle: TFormStyle; virtual;
GetRealPopupModenull157     function GetRealPopupMode: TPopupMode; virtual;
GetRealPopupParentnull158     function GetRealPopupParent: TCustomForm; virtual;
159   protected
160     procedure SetLookupRoot(AValue: TComponent); override;
161   public
162     constructor Create(AOwner: TComponent; ANonFormDesigner: INonFormDesigner); override;
163     destructor Destroy; override;
164 
DockedDesignernull165     function DockedDesigner: boolean; override;
166   end;
167 
168 implementation
169 
170 uses
171   sparta_MainIDE;
172 
173 type
174   TFormAccess = class(TForm);
175 
176 { TDesignedNonControlFormImpl }
177 
GetPublishedBoundsnull178 function TDesignedNonControlFormImpl.GetPublishedBounds(AIndex: Integer): Integer;
179 var
180   LBounds, LClientRect: TRect;
181   LMediator: TDesignerMediator;
182   LLookupRoot: TComponent;
183 begin
184   LLookupRoot := (FForm as TNonFormProxyDesignerForm).LookupRoot;
185   if LLookupRoot is TDataModule then
186     with TDataModule(LLookupRoot) do
187     case AIndex of
188       0: Result := DesignOffset.x;
189       1: Result := DesignOffset.y;
190       2: Result := DesignSize.x;
191       3: Result := DesignSize.y;
192     end
193   else
194   begin
195     LMediator := (FForm as TNonControlProxyDesignerForm).Mediator;
196     if (LLookupRoot <> nil) and (LMediator <> nil) then
197     begin
198       LMediator.GetFormBounds(LLookupRoot, LBounds, LClientRect);
199       //WriteLn(Format('get Bounds >>> %d %d %d %d',[LBounds.Left,LBounds.Top,LBounds.Right,LBounds.Bottom]));
200       //WriteLn(Format('get Client Rect >>> %d %d %d %d',[LClientRect.Left,LClientRect.Top,LClientRect.Right,LClientRect.Bottom]));
201       case AIndex of
202         0: Result := LBounds.Left;
203         1: Result := LBounds.Top;
204         2: Result := LClientRect.Right;
205         3: Result := LClientRect.Bottom;
206       end;
207     end
208     else
209       Result := 0; //inherited GetPublishedBounds(AIndex);
210   end
211 end;
212 
213 procedure TDesignedNonControlFormImpl.SetPublishedBounds(AIndex: Integer;
214   AValue: Integer);
215 var
216   LBounds, LClientRect: TRect;
217   LMediator: TDesignerMediator;
218   LLookupRoot: TComponent;
219 begin
220   LLookupRoot := (FForm as TNonFormProxyDesignerForm).LookupRoot;
221   if LLookupRoot is TDataModule then
222     with TDataModule(LLookupRoot) do
223     case AIndex of
224       0: DesignOffset := Point(AValue, DesignOffset.y);
225       1: DesignOffset := Point(DesignOffset.x, AValue);
226       2: DesignSize := Point(AValue, DesignSize.y);
227       3: DesignSize := Point(DesignSize.x, AValue);
228     end
229   else
230   begin
231     LMediator := (FForm as TNonControlProxyDesignerForm).Mediator;
232     if (LLookupRoot <> nil) and (LMediator <> nil) then
233     begin
234       LMediator.GetFormBounds(LLookupRoot, LBounds, LClientRect);
235       //WriteLn(Format('set Bounds >>> %d %d %d %d',[LBounds.Left,LBounds.Top,LBounds.Right,LBounds.Bottom]));
236       //WriteLn(Format('set Client Rect >>> %d %d %d %d',[LClientRect.Left,LClientRect.Top,LClientRect.Right,LClientRect.Bottom]));
237       case AIndex of
238         0: LBounds := Rect(AValue, LBounds.Top, AValue + LClientRect.Right, LBounds.Bottom);
239         1: LBounds := Rect(LBounds.Left, AValue, LBounds.Right, AValue + LClientRect.Bottom);
240         2: LClientRect := Rect(0, 0, AValue, LClientRect.Bottom);
241         3: LClientRect := Rect(0, 0, LClientRect.Right, AValue);
242       end;
243       if AIndex in [2, 3] then
244         LBounds := Rect(LBounds.Left, LBounds.Top, LBounds.Left + LClientRect.Right, LBounds.Top + LClientRect.Bottom);
245       LMediator.SetFormBounds(LLookupRoot,LBounds,LClientRect);
246     end;
247   end;
248 
249   // refresh for OI
250   inherited SetPublishedBounds(AIndex, AValue);
251 end;
252 
253 { TDesignedFrameFormImpl }
254 
GetPublishedBoundsnull255 function TDesignedFrameFormImpl.GetPublishedBounds(AIndex: Integer): Integer;
256 begin
257   if (FForm as TNonFormProxyDesignerForm).LookupRoot <> nil then
258     with (TNonFormProxyDesignerForm(FForm).LookupRoot as TFrame) do
259     case AIndex of
260       0: Result := Left;
261       1: Result := Top;
262       2: Result := Width;
263       3: Result := Height;
264     end
265   else
266     Result:=inherited GetPublishedBounds(AIndex);
267 end;
268 
269 procedure TDesignedFrameFormImpl.SetPublishedBounds(AIndex: Integer;
270   AValue: Integer);
271 begin
272   if (FForm as TNonFormProxyDesignerForm).LookupRoot <> nil then
273     with (TNonFormProxyDesignerForm(FForm).LookupRoot as TControl) do
274     case AIndex of
275       0: Left := AValue;
276       1: Top := AValue;
277       2: Width := AValue;
278       3: Height := AValue;
279     end;
280 
281   // refresh for OI
282   inherited SetPublishedBounds(AIndex, AValue);
283 end;
284 
285 { TFakeCustomFrame }
286 
GetDesignedFormnull287 function TFakeCustomFrame.GetDesignedForm: TDesignedFormImpl;
288 begin
289   if not Assigned(FDesignedForm) then
290     FDesignedForm := TDesignedFrameFormImpl.Create(Self,Self);
291 
292   Result := FDesignedForm;
293 end;
294 
TFakeCustomFrame.GetLogicalClientRectnull295 function TFakeCustomFrame.GetLogicalClientRect: TRect;
296 begin
297   Result := DesignedForm.GetLogicalClientRect(inherited GetLogicalClientRect);
298 end;
299 
GetRealBoundsnull300 function TFakeCustomFrame.GetRealBounds(AIndex: Integer): Integer;
301 begin
302   Result := inherited GetPublishedBounds(AIndex);
303 end;
304 
305 procedure TFakeCustomFrame.SetRealBounds(AIndex: Integer; AValue: Integer);
306 begin
307   inherited SetPublishedBounds(AIndex, AValue);
308 end;
309 
GetPublishedBoundsnull310 function TFakeCustomFrame.GetPublishedBounds(AIndex: Integer): Integer;
311 begin
312   Result := DesignedForm.GetPublishedBounds(AIndex);
313 end;
314 
315 procedure TFakeCustomFrame.SetPublishedBounds(AIndex: Integer; AValue: Integer);
316 begin
317   //DesignedForm.SetPublishedBounds(AIndex, AValue);
318 
319   if LookupRoot <> nil then
320     with LookupRoot as TControl do
321     case AIndex of
322       0: Left := AValue;
323       1: Top := AValue;
324       2: Width := AValue;
325       3: Height := AValue;
326     end;
327 end;
328 
329 constructor TFakeCustomFrame.Create(AOwner: TComponent;
330   ANonFormDesigner: INonFormDesigner);
331 begin
332   inherited Create(AOwner, ANonFormDesigner);
333 
334   //NonFormDesignerOptions := NonFormDesignerOptions - [nfdokSetBounds];
335 
336   Left := inherited Left;
337   Top := inherited Top;
338   Width := inherited Width;
339   Height := inherited Height;
340 end;
341 
342 destructor TFakeCustomFrame.Destroy;
343 begin
344   // we need to call "Screen.RemoveForm" to perform
345   // references back to nil by IDesignedForm to FDesignedForm
346   inherited Destroy;
347   if Assigned(FDesignedForm) then
348     FDesignedForm.Free;
349 end;
350 
TFakeCustomFrame.DockedDesignernull351 function TFakeCustomFrame.DockedDesigner: boolean;
352 begin
353   Result := True;
354 end;
355 
356 procedure TFakeCustomFrame.SetRealBorderStyle(AVal: TFormBorderStyle);
357 begin
358   inherited BorderStyle := AVal;
359 end;
360 
361 procedure TFakeCustomFrame.SetRealBorderIcons(AVal: TBorderIcons);
362 begin
363   inherited BorderIcons := AVal;
364 end;
365 
366 procedure TFakeCustomFrame.SetRealFormStyle(AVal: TFormStyle);
367 begin
368   inherited FormStyle := AVal;
369 end;
370 
371 procedure TFakeCustomFrame.SetRealPopupMode(AVal: TPopupMode);
372 begin
373   inherited PopupMode := AVal;
374 end;
375 
376 procedure TFakeCustomFrame.SetRealPopupParent(AVal: TCustomForm);
377 begin
378   inherited PopupParent := AVal;
379 end;
380 
TFakeCustomFrame.GetRealBorderStylenull381 function TFakeCustomFrame.GetRealBorderStyle: TFormBorderStyle;
382 begin
383   Result := inherited BorderStyle;
384 end;
385 
GetRealBorderIconsnull386 function TFakeCustomFrame.GetRealBorderIcons: TBorderIcons;
387 begin
388   Result := inherited BorderIcons;
389 end;
390 
GetRealFormStylenull391 function TFakeCustomFrame.GetRealFormStyle: TFormStyle;
392 begin
393   Result := inherited FormStyle;
394 end;
395 
GetRealPopupModenull396 function TFakeCustomFrame.GetRealPopupMode: TPopupMode;
397 begin
398   Result := inherited PopupMode;
399 end;
400 
TFakeCustomFrame.GetRealPopupParentnull401 function TFakeCustomFrame.GetRealPopupParent: TCustomForm;
402 begin
403   Result := inherited PopupParent;
404 end;
405 
406 procedure TFakeCustomFrame.SetLookupRoot(AValue: TComponent);
407 begin
408   inherited SetLookupRoot(AValue);
409 
410   if AValue <> nil then
411   begin
412     Left   := (LookupRoot as TFrame).Left;
413     Top    := (LookupRoot as TFrame).Top;
414     Width  := (LookupRoot as TFrame).Width;
415     Height := (LookupRoot as TFrame).Height;
416 
417     DesignedForm.RealWidth := Width;
418     DesignedForm.RealHeight := Height;
419   end
420   else
421     TSpartaMainIDE.TryFreeFormData(Self);
422 end;
423 
424 { TFakeCustomNonControl }
425 
GetDesignedFormnull426 function TFakeCustomNonControl.GetDesignedForm: TDesignedFormImpl;
427 begin
428   if not Assigned(FDesignedForm) then
429     FDesignedForm := TDesignedNonControlFormImpl.Create(Self,Self);
430 
431   Result := FDesignedForm;
432 end;
433 
GetLogicalClientRectnull434 function TFakeCustomNonControl.GetLogicalClientRect: TRect;
435 begin
436   Result := DesignedForm.GetLogicalClientRect(inherited GetLogicalClientRect);
437 end;
438 
GetRealBoundsnull439 function TFakeCustomNonControl.GetRealBounds(AIndex: Integer): Integer;
440 begin
441   Result := inherited GetPublishedBounds(AIndex);
442 end;
443 
444 procedure TFakeCustomNonControl.SetRealBounds(AIndex: Integer; AValue: Integer);
445 begin
446   inherited SetPublishedBounds(AIndex, AValue);
447 end;
448 
GetPublishedBoundsnull449 function TFakeCustomNonControl.GetPublishedBounds(AIndex: Integer): Integer;
450 begin
451   Result := DesignedForm.GetPublishedBounds(AIndex);
452 end;
453 
454 procedure TFakeCustomNonControl.SetPublishedBounds(AIndex: Integer; AValue: Integer);
455 begin
456   DesignedForm.SetPublishedBounds(AIndex, AValue);
457 end;
458 
459 constructor TFakeCustomNonControl.Create(AOwner: TComponent;
460   ANonFormDesigner: INonFormDesigner);
461 begin
462   inherited Create(AOwner, ANonFormDesigner);
463 
464   //NonFormDesignerOptions := [];
465 
466   Left := inherited Left;
467   Top := inherited Top;
468   Width := inherited Width;
469   Height := inherited Height;
470 end;
471 
472 destructor TFakeCustomNonControl.Destroy;
473 begin
474   // we need to call "Screen.RemoveForm" to perform
475   // references back to nil by IDesignedForm to FDesignedForm
476   inherited Destroy;
477   if Assigned(FDesignedForm) then
478     FDesignedForm.Free;
479 end;
480 
TFakeCustomNonControl.DockedDesignernull481 function TFakeCustomNonControl.DockedDesigner: boolean;
482 begin
483   Result := True;
484 end;
485 
486 procedure TFakeCustomNonControl.SetBounds(ALeft, ATop, AWidth, AHeight: integer);
487 begin
488   SetDesignerFormBounds(ALeft, ATop, AWidth, AHeight);
489 end;
490 
491 procedure TFakeCustomNonControl.SetRealBorderStyle(AVal: TFormBorderStyle);
492 begin
493   inherited BorderStyle := AVal;
494 end;
495 
496 procedure TFakeCustomNonControl.SetRealBorderIcons(AVal: TBorderIcons);
497 begin
498   inherited BorderIcons := AVal;
499 end;
500 
501 procedure TFakeCustomNonControl.SetRealFormStyle(AVal: TFormStyle);
502 begin
503   inherited FormStyle := AVal;
504 end;
505 
506 procedure TFakeCustomNonControl.SetRealPopupMode(AVal: TPopupMode);
507 begin
508   inherited PopupMode := AVal;
509 end;
510 
511 procedure TFakeCustomNonControl.SetRealPopupParent(AVal: TCustomForm);
512 begin
513   inherited PopupParent := AVal;
514 end;
515 
GetRealBorderStylenull516 function TFakeCustomNonControl.GetRealBorderStyle: TFormBorderStyle;
517 begin
518   Result := inherited BorderStyle;
519 end;
520 
TFakeCustomNonControl.GetRealBorderIconsnull521 function TFakeCustomNonControl.GetRealBorderIcons: TBorderIcons;
522 begin
523   Result := inherited BorderIcons;
524 end;
525 
TFakeCustomNonControl.GetRealFormStylenull526 function TFakeCustomNonControl.GetRealFormStyle: TFormStyle;
527 begin
528   Result := inherited FormStyle;
529 end;
530 
GetRealPopupModenull531 function TFakeCustomNonControl.GetRealPopupMode: TPopupMode;
532 begin
533   Result := inherited PopupMode;
534 end;
535 
GetRealPopupParentnull536 function TFakeCustomNonControl.GetRealPopupParent: TCustomForm;
537 begin
538   Result := inherited PopupParent;
539 end;
540 
541 procedure TFakeCustomNonControl.SetLookupRoot(AValue: TComponent);
542 var
543   LBounds, LClientRect: TRect;
544 begin
545   inherited SetLookupRoot(AValue);
546 
547   if AValue <> nil then
548   begin
549     if LookupRoot is TDataModule then
550     begin
551       Width  := (LookupRoot as TDataModule).DesignSize.x;
552       Height := (LookupRoot as TDataModule).DesignSize.y;
553     end
554     else if (LookupRoot <> nil) and (Mediator <> nil) then
555     begin
556       Mediator.GetFormBounds(LookupRoot,LBounds,LClientRect);
557       //WriteLn(Format('Bounds >>> %d %d %d %d',[LBounds.Left,LBounds.Top,LBounds.Right,LBounds.Bottom]));
558       //WriteLn(Format('Client Rect >>> %d %d %d %d',[LClientRect.Left,LClientRect.Top,LClientRect.Right,LClientRect.Bottom]));
559       Width := LClientRect.Right;
560       Height := LClientRect.Bottom;
561     end else
562       Width := 1;
563 
564     DesignedForm.RealWidth := Width;
565     DesignedForm.RealHeight := Height;
566   end
567   else
568     TSpartaMainIDE.TryFreeFormData(Self);
569 end;
570 
571 procedure TFakeCustomNonControl.SetMediator(AValue: TDesignerMediator);
572 var
573   LBounds, LClientRect: TRect;
574 begin
575   inherited SetMediator(AValue);
576 
577   if (LookupRoot <> nil) and (Mediator <> nil) then
578   begin
579     Mediator.GetFormBounds(LookupRoot,LBounds,LClientRect);
580     //WriteLn(Format('Bounds >>> %d %d %d %d',[LBounds.Left,LBounds.Top,LBounds.Right,LBounds.Bottom]));
581     //WriteLn(Format('Client Rect >>> %d %d %d %d',[LClientRect.Left,LClientRect.Top,LClientRect.Right,LClientRect.Bottom]));
582     Width := LClientRect.Right;
583     Height := LClientRect.Bottom;
584   end else
585     ;//WriteLn('o kurwa eh');
586 end;
587 
588 { TFakeCustomForm }
589 
GetDesignedFormnull590 function TFakeCustomForm.GetDesignedForm: TDesignedFormImpl;
591 begin
592   if not Assigned(FDesignedForm) then
593     FDesignedForm := TDesignedFormImpl.Create(Self,Self);
594 
595   Result := FDesignedForm;
596 end;
597 
TFakeCustomForm.GetLogicalClientRectnull598 function TFakeCustomForm.GetLogicalClientRect: TRect;
599 begin
600   Result := DesignedForm.GetLogicalClientRect(inherited GetLogicalClientRect);
601 end;
602 
GetRealBoundsnull603 function TFakeCustomForm.GetRealBounds(AIndex: Integer): Integer;
604 begin
605   case AIndex of
606     0: Result := inherited Left;
607     1: Result := inherited Top;
608     2: Result := inherited Width;
609     3: Result := inherited Height;
610   end;
611 end;
612 
613 procedure TFakeCustomForm.SetRealBounds(AIndex: Integer; AValue: Integer);
614 begin
615   case AIndex of
616     0: inherited Left := AValue;
617     1: inherited Top := AValue;
618     2: inherited Width := AValue;
619     3: inherited Height := AValue;
620   end;
621 end;
622 
GetPublishedBoundsnull623 function TFakeCustomForm.GetPublishedBounds(AIndex: Integer): Integer;
624 begin
625   Result := DesignedForm.GetPublishedBounds(AIndex);
626 end;
627 
628 procedure TFakeCustomForm.SetPublishedBounds(AIndex: Integer; AValue: Integer);
629 begin
630   case AIndex of
631     0, 1: DesignedForm.SetPublishedBounds(AIndex, AValue);
632     2, 3:
633       begin
634         DesignedForm.SetPublishedBounds(AIndex, AValue);
635         SetRealBounds(AIndex, DesignedForm.GetPublishedBounds(AIndex));
636       end;
637   end;
638 end;
639 
640 constructor TFakeCustomForm.CreateNew(AOwner: TComponent; Num: Integer);
641 begin
642   inherited CreateNew(AOwner, Num);
643 
644   Left := inherited Left;
645   Top := inherited Top;
646   Width := inherited Width;
647   Height := inherited Height;
648 end;
649 
650 destructor TFakeCustomForm.Destroy;
651 begin
652   // we need to call "Screen.RemoveForm" to perform
653   // references back to nil by IDesignedForm to FDesignedForm
654   inherited Destroy;
655   if Assigned(FDesignedForm) then
656     FreeAndNil(FDesignedForm);
657 end;
658 
659 procedure TFakeCustomForm.SetRealBorderStyle(AVal: TFormBorderStyle);
660 begin
661   inherited BorderStyle := AVal;
662 end;
663 
664 procedure TFakeCustomForm.SetRealBorderIcons(AVal: TBorderIcons);
665 begin
666   inherited BorderIcons := AVal;
667 end;
668 
669 procedure TFakeCustomForm.SetRealFormStyle(AVal: TFormStyle);
670 begin
671   inherited FormStyle := AVal;
672 end;
673 
674 procedure TFakeCustomForm.SetRealPopupMode(AVal: TPopupMode);
675 begin
676   inherited PopupMode := AVal;
677 end;
678 
679 procedure TFakeCustomForm.SetRealPopupParent(AVal: TCustomForm);
680 begin
681   inherited PopupParent := AVal;
682 end;
683 
TFakeCustomForm.GetRealBorderStylenull684 function TFakeCustomForm.GetRealBorderStyle: TFormBorderStyle;
685 begin
686   Result := inherited BorderStyle;
687 end;
688 
TFakeCustomForm.GetRealBorderIconsnull689 function TFakeCustomForm.GetRealBorderIcons: TBorderIcons;
690 begin
691   Result := inherited BorderIcons;
692 end;
693 
TFakeCustomForm.GetRealFormStylenull694 function TFakeCustomForm.GetRealFormStyle: TFormStyle;
695 begin
696   Result := inherited FormStyle;
697 end;
698 
GetRealPopupModenull699 function TFakeCustomForm.GetRealPopupMode: TPopupMode;
700 begin
701   Result := inherited PopupMode;
702 end;
703 
TFakeCustomForm.GetRealPopupParentnull704 function TFakeCustomForm.GetRealPopupParent: TCustomForm;
705 begin
706   Result := inherited PopupParent;
707 end;
708 
709 { TDesignedFormImpl }
710 
TDesignedFormImpl.GetLastActiveSourceWindownull711 function TDesignedFormImpl.GetLastActiveSourceWindow: TSourceEditorWindowInterface;
712 begin
713   Result := FLastActiveSourceWindow;
714 end;
715 
716 procedure TDesignedFormImpl.SetLastActiveSourceWindow(
717   AValue: TSourceEditorWindowInterface);
718 begin
719   FLastActiveSourceWindow := AValue;
720 end;
721 
722 procedure TDesignedFormImpl.BeginUpdate;
723 begin
724   TFormAccess(FForm).SetDesigning(False, False);
725   inherited BeginUpdate;
726 end;
727 
728 procedure TDesignedFormImpl.EndUpdate(AModified: Boolean);
729 var
730   OI: TObjectInspectorDlg;
731 begin
732   TFormAccess(FForm).SetDesigning(True, False);
733   inherited EndUpdate(AModified);
734   if AModified and (FormEditingHook <> nil)
735   and (FormEditingHook.GetCurrentDesigner = FForm.Designer) then
736   begin
737     OI := FormEditingHook.GetCurrentObjectInspector;
738     if Assigned(OI) then
739       OI.RefreshPropertyValues;
740   end;
741 end;
742 
743 end.
744 
745