File: sparta_fakecustom.pas

package info (click to toggle)
lazarus 2.0.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 214,460 kB
  • sloc: pascal: 1,862,622; xml: 265,709; cpp: 56,595; sh: 3,008; java: 609; makefile: 535; perl: 297; sql: 222; ansic: 137
file content (749 lines) | stat: -rw-r--r-- 22,165 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
{
 *****************************************************************************
  See the file COPYING.modifiedLGPL.txt, included in this distribution,
  for details about the license.
 *****************************************************************************

  Author: Maciej Izak

  DaThoX 2004-2015
  FreeSparta.com
}

unit sparta_FakeCustom;

{$mode delphi}{$H+}

interface

uses
  Classes, SysUtils,
  {$IFDEF USE_GENERICS_COLLECTIONS}
    Generics.Defaults,
  {$ENDIF}
  // LCL
  Forms, Controls,
  // IdeIntf
  FormEditingIntf, SrcEditorIntf, ObjectInspector,
  // Sparta
  sparta_InterfacesMDI, sparta_DesignedForm, sparta_BasicFakeCustom;

type
  { TDesignedFormImpl }

  TDesignedFormImpl = class(TFormImpl, IDesignedRealForm, IDesignedRealFormHelper, IDesignedForm, IDesignedFormIDE)
  private
    FLastActiveSourceWindow: TSourceEditorWindowInterface;
  protected
    function GetLastActiveSourceWindow: TSourceEditorWindowInterface; virtual;
    procedure SetLastActiveSourceWindow(AValue: TSourceEditorWindowInterface); virtual;
  public
    procedure BeginUpdate; override;
    procedure EndUpdate(AModified: Boolean = False); override;
  end;

  { TFakeCustomForm }

  TFakeCustomForm = class(TForm, IDesignedRealForm, IDesignedForm, IDesignedFormIDE)
  private
    FDesignedForm: TDesignedFormImpl;
    function GetDesignedForm: TDesignedFormImpl;
  protected
    property DesignedForm: TDesignedFormImpl read GetDesignedForm implements IDesignedForm, IDesignedFormIDE;
    function GetLogicalClientRect: TRect; override;
  protected
    function GetRealBounds(AIndex: Integer): Integer; virtual;
    procedure SetRealBounds(AIndex: Integer; AValue: Integer); virtual;
    function GetPublishedBounds(AIndex: Integer): Integer; virtual;
    procedure SetPublishedBounds(AIndex: Integer; AValue: Integer); virtual;

    procedure SetRealBorderStyle(AVal: TFormBorderStyle); virtual;
    procedure SetRealBorderIcons(AVal: TBorderIcons); virtual;
    procedure SetRealFormStyle(AVal: TFormStyle); virtual;
    procedure SetRealPopupMode(AVal: TPopupMode); virtual;
    procedure SetRealPopupParent(AVal: TCustomForm); virtual;

    function GetRealBorderStyle: TFormBorderStyle; virtual;
    function GetRealBorderIcons: TBorderIcons; virtual;
    function GetRealFormStyle: TFormStyle; virtual;
    function GetRealPopupMode: TPopupMode; virtual;
    function GetRealPopupParent: TCustomForm; virtual;
  public
    constructor CreateNew(AOwner: TComponent; Num: Integer = 0); override;
    destructor Destroy; override;
  published
    property Left: Integer index 0 read GetPublishedBounds write SetPublishedBounds;
    property Top: Integer index 1 read GetPublishedBounds write SetPublishedBounds;
    property Width: Integer index 2 read GetPublishedBounds write SetPublishedBounds;
    property Height: Integer index 3 read GetPublishedBounds write SetPublishedBounds;
    property ClientWidth: Integer index 2 read GetPublishedBounds write SetPublishedBounds;
    property ClientHeight: Integer index 3 read GetPublishedBounds write SetPublishedBounds;
  end;

  { TDesignedNonControlFormImpl }

  TDesignedNonControlFormImpl = class(TDesignedFormImpl)
  protected
    function GetPublishedBounds(AIndex: Integer): Integer; override;
    procedure SetPublishedBounds(AIndex: Integer; AValue: Integer); override;
  end;

  { TFakeCustomNonControl }

  TFakeCustomNonControl = class(TNonControlProxyDesignerForm, IDesignedRealForm, IDesignedForm, IDesignedFormIDE)
  private
    FDesignedForm: TDesignedFormImpl;
    function GetDesignedForm: TDesignedFormImpl;
  protected
    property DesignedForm: TDesignedFormImpl read GetDesignedForm implements IDesignedForm, IDesignedFormIDE;
    function GetLogicalClientRect: TRect; override;
  protected
    function GetRealBounds(AIndex: Integer): Integer; virtual;
    procedure SetRealBounds(AIndex: Integer; AValue: Integer); virtual;
    function GetPublishedBounds(AIndex: Integer): Integer; override;
    procedure SetPublishedBounds(AIndex: Integer; AValue: Integer); override;

    procedure SetRealBorderStyle(AVal: TFormBorderStyle); virtual;
    procedure SetRealBorderIcons(AVal: TBorderIcons); virtual;
    procedure SetRealFormStyle(AVal: TFormStyle); virtual;
    procedure SetRealPopupMode(AVal: TPopupMode); virtual;
    procedure SetRealPopupParent(AVal: TCustomForm); virtual;

    function GetRealBorderStyle: TFormBorderStyle; virtual;
    function GetRealBorderIcons: TBorderIcons; virtual;
    function GetRealFormStyle: TFormStyle; virtual;
    function GetRealPopupMode: TPopupMode; virtual;
    function GetRealPopupParent: TCustomForm; virtual;
  protected
    procedure SetLookupRoot(AValue: TComponent); override;
    procedure SetMediator(AValue: TDesignerMediator); override;
  public
    constructor Create(AOwner: TComponent; ANonFormDesigner: INonFormDesigner); override;
    destructor Destroy; override;
    function DockedDesigner: boolean; override;
    procedure SetBounds(ALeft, ATop, AWidth, AHeight: integer); override;
  end;


  { TDesignedFrameFormImpl }

  TDesignedFrameFormImpl = class(TDesignedFormImpl)
  protected
    function GetPublishedBounds(AIndex: Integer): Integer; override;
    procedure SetPublishedBounds(AIndex: Integer; AValue: Integer); override;
  end;

  { TFakeCustomFrame }

  TFakeCustomFrame = class(TFrameProxyDesignerForm, IDesignedRealForm, IDesignedForm, IDesignedFormIDE)
  private
    FDesignedForm: TDesignedFormImpl;
    function GetDesignedForm: TDesignedFormImpl;
  protected
    property DesignedForm: TDesignedFormImpl read GetDesignedForm implements IDesignedForm, IDesignedFormIDE;
    function GetLogicalClientRect: TRect; override;
  protected
    function GetRealBounds(AIndex: Integer): Integer; virtual;
    procedure SetRealBounds(AIndex: Integer; AValue: Integer); virtual;
    function GetPublishedBounds(AIndex: Integer): Integer; override;
    procedure SetPublishedBounds(AIndex: Integer; AValue: Integer); override;

    procedure SetRealBorderStyle(AVal: TFormBorderStyle); virtual;
    procedure SetRealBorderIcons(AVal: TBorderIcons); virtual;
    procedure SetRealFormStyle(AVal: TFormStyle); virtual;
    procedure SetRealPopupMode(AVal: TPopupMode); virtual;
    procedure SetRealPopupParent(AVal: TCustomForm); virtual;

    function GetRealBorderStyle: TFormBorderStyle; virtual;
    function GetRealBorderIcons: TBorderIcons; virtual;
    function GetRealFormStyle: TFormStyle; virtual;
    function GetRealPopupMode: TPopupMode; virtual;
    function GetRealPopupParent: TCustomForm; virtual;
  protected
    procedure SetLookupRoot(AValue: TComponent); override;
  public
    constructor Create(AOwner: TComponent; ANonFormDesigner: INonFormDesigner); override;
    destructor Destroy; override;

    function DockedDesigner: boolean; override;
  end;

implementation

uses
  sparta_MainIDE;

type
  TFormAccess = class(TForm);

{ TDesignedNonControlFormImpl }

function TDesignedNonControlFormImpl.GetPublishedBounds(AIndex: Integer
  ): Integer;
var
  LBounds, LClientRect: TRect;
  LMediator: TDesignerMediator;
  LLookupRoot: TComponent;
begin
  LLookupRoot := (FForm as TNonFormProxyDesignerForm).LookupRoot;
  if LLookupRoot is TDataModule then
    with TDataModule(LLookupRoot) do
    case AIndex of
      0: Result := DesignOffset.x;
      1: Result := DesignOffset.y;
      2: Result := DesignSize.x;
      3: Result := DesignSize.y;
    end
  else
  begin
    LMediator := (FForm as TNonControlProxyDesignerForm).Mediator;
    if (LLookupRoot <> nil) and (LMediator <> nil) then
    begin
      LMediator.GetFormBounds(LLookupRoot, LBounds, LClientRect);
      //WriteLn(Format('get Bounds >>> %d %d %d %d',[LBounds.Left,LBounds.Top,LBounds.Right,LBounds.Bottom]));
      //WriteLn(Format('get Client Rect >>> %d %d %d %d',[LClientRect.Left,LClientRect.Top,LClientRect.Right,LClientRect.Bottom]));
      case AIndex of
        0: Result := LBounds.Left;
        1: Result := LBounds.Top;
        2: Result := LClientRect.Right;
        3: Result := LClientRect.Bottom;
      end;
    end
    else
      Result := 0; //inherited GetPublishedBounds(AIndex);
  end
end;

procedure TDesignedNonControlFormImpl.SetPublishedBounds(AIndex: Integer;
  AValue: Integer);
var
  LBounds, LClientRect: TRect;
  LMediator: TDesignerMediator;
  LLookupRoot: TComponent;
begin
  LLookupRoot := (FForm as TNonFormProxyDesignerForm).LookupRoot;
  if LLookupRoot is TDataModule then
    with TDataModule(LLookupRoot) do
    case AIndex of
      0: DesignOffset := Point(AValue, DesignOffset.y);
      1: DesignOffset := Point(DesignOffset.x, AValue);
      2: DesignSize := Point(AValue, DesignSize.y);
      3: DesignSize := Point(DesignSize.x, AValue);
    end
  else
  begin
    LMediator := (FForm as TNonControlProxyDesignerForm).Mediator;
    if (LLookupRoot <> nil) and (LMediator <> nil) then
    begin
      LMediator.GetFormBounds(LLookupRoot, LBounds, LClientRect);
      //WriteLn(Format('set Bounds >>> %d %d %d %d',[LBounds.Left,LBounds.Top,LBounds.Right,LBounds.Bottom]));
      //WriteLn(Format('set Client Rect >>> %d %d %d %d',[LClientRect.Left,LClientRect.Top,LClientRect.Right,LClientRect.Bottom]));
      case AIndex of
        0: LBounds := Rect(AValue, LBounds.Top, AValue + LClientRect.Right, LBounds.Bottom);
        1: LBounds := Rect(LBounds.Left, AValue, LBounds.Right, AValue + LClientRect.Bottom);
        2: LClientRect := Rect(0, 0, AValue, LClientRect.Bottom);
        3: LClientRect := Rect(0, 0, LClientRect.Right, AValue);
      end;
      if AIndex in [2, 3] then
        LBounds := Rect(LBounds.Left, LBounds.Top, LBounds.Left + LClientRect.Right, LBounds.Top + LClientRect.Bottom);
      LMediator.SetFormBounds(LLookupRoot,LBounds,LClientRect);
    end;
  end;

  // refresh for OI
  inherited SetPublishedBounds(AIndex, AValue);
end;

{ TDesignedFrameFormImpl }

function TDesignedFrameFormImpl.GetPublishedBounds(AIndex: Integer): Integer;
begin
  if (FForm as TNonFormProxyDesignerForm).LookupRoot <> nil then
    with (TNonFormProxyDesignerForm(FForm).LookupRoot as TFrame) do
    case AIndex of
      0: Result := Left;
      1: Result := Top;
      2: Result := Width;
      3: Result := Height;
    end
  else
    Result:=inherited GetPublishedBounds(AIndex);
end;

procedure TDesignedFrameFormImpl.SetPublishedBounds(AIndex: Integer;
  AValue: Integer);
begin
  if (FForm as TNonFormProxyDesignerForm).LookupRoot <> nil then
    with (TNonFormProxyDesignerForm(FForm).LookupRoot as TControl) do
    case AIndex of
      0: Left := AValue;
      1: Top := AValue;
      2: Width := AValue;
      3: Height := AValue;
    end;

  // refresh for OI
  inherited SetPublishedBounds(AIndex, AValue);
end;

{ TFakeCustomFrame }

function TFakeCustomFrame.GetDesignedForm: TDesignedFormImpl;
begin
  if not Assigned(FDesignedForm) then
    FDesignedForm := TDesignedFrameFormImpl.Create(Self,Self);

  Result := FDesignedForm;
end;

function TFakeCustomFrame.GetLogicalClientRect: TRect;
begin
  Result := DesignedForm.GetLogicalClientRect(inherited GetLogicalClientRect);
end;

function TFakeCustomFrame.GetRealBounds(AIndex: Integer): Integer;
begin
  Result := inherited GetPublishedBounds(AIndex);
end;

procedure TFakeCustomFrame.SetRealBounds(AIndex: Integer; AValue: Integer);
begin
  inherited SetPublishedBounds(AIndex, AValue);
end;

function TFakeCustomFrame.GetPublishedBounds(AIndex: Integer): Integer;
begin
  Result := DesignedForm.GetPublishedBounds(AIndex);
end;

procedure TFakeCustomFrame.SetPublishedBounds(AIndex: Integer; AValue: Integer);
begin
  //DesignedForm.SetPublishedBounds(AIndex, AValue);

  if LookupRoot <> nil then
    with LookupRoot as TControl do
    case AIndex of
      0: Left := AValue;
      1: Top := AValue;
      2: Width := AValue;
      3: Height := AValue;
    end;
end;

constructor TFakeCustomFrame.Create(AOwner: TComponent;
  ANonFormDesigner: INonFormDesigner);
begin
  inherited Create(AOwner, ANonFormDesigner);

  //NonFormDesignerOptions := NonFormDesignerOptions - [nfdokSetBounds];

  Left := inherited Left;
  Top := inherited Top;
  Width := inherited Width;
  Height := inherited Height;
end;

destructor TFakeCustomFrame.Destroy;
begin
  // we need to call "Screen.RemoveForm" to perform
  // references back to nil by IDesignedForm to FDesignedForm
  inherited Destroy;
  if Assigned(FDesignedForm) then
    FDesignedForm.Free;
end;

function TFakeCustomFrame.DockedDesigner: boolean;
begin
  Result := True;
end;

procedure TFakeCustomFrame.SetRealBorderStyle(AVal: TFormBorderStyle);
begin
  inherited BorderStyle := AVal;
end;

procedure TFakeCustomFrame.SetRealBorderIcons(AVal: TBorderIcons);
begin
  inherited BorderIcons := AVal;
end;

procedure TFakeCustomFrame.SetRealFormStyle(AVal: TFormStyle);
begin
  inherited FormStyle := AVal;
end;

procedure TFakeCustomFrame.SetRealPopupMode(AVal: TPopupMode);
begin
  inherited PopupMode := AVal;
end;

procedure TFakeCustomFrame.SetRealPopupParent(AVal: TCustomForm);
begin
  inherited PopupParent := AVal;
end;

function TFakeCustomFrame.GetRealBorderStyle: TFormBorderStyle;
begin
  Result := inherited BorderStyle;
end;

function TFakeCustomFrame.GetRealBorderIcons: TBorderIcons;
begin
  Result := inherited BorderIcons;
end;

function TFakeCustomFrame.GetRealFormStyle: TFormStyle;
begin
  Result := inherited FormStyle;
end;

function TFakeCustomFrame.GetRealPopupMode: TPopupMode;
begin
  Result := inherited PopupMode;
end;

function TFakeCustomFrame.GetRealPopupParent: TCustomForm;
begin
  Result := inherited PopupParent;
end;

procedure TFakeCustomFrame.SetLookupRoot(AValue: TComponent);
begin
  inherited SetLookupRoot(AValue);

  if AValue <> nil then
  begin
    Left   := (LookupRoot as TFrame).Left;
    Top    := (LookupRoot as TFrame).Top;
    Width  := (LookupRoot as TFrame).Width;
    Height := (LookupRoot as TFrame).Height;

    DesignedForm.RealWidth := Width;
    DesignedForm.RealHeight := Height;
  end
  else
    TSpartaMainIDE.TryFreeFormData(Self);
end;

{ TFakeCustomNonControl }

function TFakeCustomNonControl.GetDesignedForm: TDesignedFormImpl;
begin
  if not Assigned(FDesignedForm) then
    FDesignedForm := TDesignedNonControlFormImpl.Create(Self,Self);

  Result := FDesignedForm;
end;

function TFakeCustomNonControl.GetLogicalClientRect: TRect;
begin
  Result := DesignedForm.GetLogicalClientRect(inherited GetLogicalClientRect);
end;

function TFakeCustomNonControl.GetRealBounds(AIndex: Integer): Integer;
begin
  Result := inherited GetPublishedBounds(AIndex);
end;

procedure TFakeCustomNonControl.SetRealBounds(AIndex: Integer; AValue: Integer);
begin
  inherited SetPublishedBounds(AIndex, AValue);
end;

function TFakeCustomNonControl.GetPublishedBounds(AIndex: Integer): Integer;
begin
  Result := DesignedForm.GetPublishedBounds(AIndex);
end;

procedure TFakeCustomNonControl.SetPublishedBounds(AIndex: Integer; AValue: Integer);
begin
  DesignedForm.SetPublishedBounds(AIndex, AValue);
end;

constructor TFakeCustomNonControl.Create(AOwner: TComponent;
  ANonFormDesigner: INonFormDesigner);
begin
  inherited Create(AOwner, ANonFormDesigner);

  //NonFormDesignerOptions := [];

  Left := inherited Left;
  Top := inherited Top;
  Width := inherited Width;
  Height := inherited Height;
end;

destructor TFakeCustomNonControl.Destroy;
begin
  // we need to call "Screen.RemoveForm" to perform
  // references back to nil by IDesignedForm to FDesignedForm
  inherited Destroy;
  if Assigned(FDesignedForm) then
    FDesignedForm.Free;
end;

function TFakeCustomNonControl.DockedDesigner: boolean;
begin
  Result := True;
end;

procedure TFakeCustomNonControl.SetBounds(ALeft, ATop, AWidth, AHeight: integer
  );
begin
  SetDesignerFormBounds(ALeft, ATop, AWidth, AHeight);
end;

procedure TFakeCustomNonControl.SetRealBorderStyle(AVal: TFormBorderStyle);
begin
  inherited BorderStyle := AVal;
end;

procedure TFakeCustomNonControl.SetRealBorderIcons(AVal: TBorderIcons);
begin
  inherited BorderIcons := AVal;
end;

procedure TFakeCustomNonControl.SetRealFormStyle(AVal: TFormStyle);
begin
  inherited FormStyle := AVal;
end;

procedure TFakeCustomNonControl.SetRealPopupMode(AVal: TPopupMode);
begin
  inherited PopupMode := AVal;
end;

procedure TFakeCustomNonControl.SetRealPopupParent(AVal: TCustomForm);
begin
  inherited PopupParent := AVal;
end;

function TFakeCustomNonControl.GetRealBorderStyle: TFormBorderStyle;
begin
  Result := inherited BorderStyle;
end;

function TFakeCustomNonControl.GetRealBorderIcons: TBorderIcons;
begin
  Result := inherited BorderIcons;
end;

function TFakeCustomNonControl.GetRealFormStyle: TFormStyle;
begin
  Result := inherited FormStyle;
end;

function TFakeCustomNonControl.GetRealPopupMode: TPopupMode;
begin
  Result := inherited PopupMode;
end;

function TFakeCustomNonControl.GetRealPopupParent: TCustomForm;
begin
  Result := inherited PopupParent;
end;

procedure TFakeCustomNonControl.SetLookupRoot(AValue: TComponent);
var
  LBounds, LClientRect: TRect;
begin
  inherited SetLookupRoot(AValue);

  if AValue <> nil then
  begin
    if LookupRoot is TDataModule then
    begin
      Width  := (LookupRoot as TDataModule).DesignSize.x;
      Height := (LookupRoot as TDataModule).DesignSize.y;
    end
    else if (LookupRoot <> nil) and (Mediator <> nil) then
    begin
      Mediator.GetFormBounds(LookupRoot,LBounds,LClientRect);
      //WriteLn(Format('Bounds >>> %d %d %d %d',[LBounds.Left,LBounds.Top,LBounds.Right,LBounds.Bottom]));
      //WriteLn(Format('Client Rect >>> %d %d %d %d',[LClientRect.Left,LClientRect.Top,LClientRect.Right,LClientRect.Bottom]));
      Width := LClientRect.Right;
      Height := LClientRect.Bottom;
    end else
      Width := 1;

    DesignedForm.RealWidth := Width;
    DesignedForm.RealHeight := Height;
  end
  else
    TSpartaMainIDE.TryFreeFormData(Self);
end;

procedure TFakeCustomNonControl.SetMediator(AValue: TDesignerMediator);
var
  LBounds, LClientRect: TRect;
begin
  inherited SetMediator(AValue);

  if (LookupRoot <> nil) and (Mediator <> nil) then
  begin
    Mediator.GetFormBounds(LookupRoot,LBounds,LClientRect);
    //WriteLn(Format('Bounds >>> %d %d %d %d',[LBounds.Left,LBounds.Top,LBounds.Right,LBounds.Bottom]));
    //WriteLn(Format('Client Rect >>> %d %d %d %d',[LClientRect.Left,LClientRect.Top,LClientRect.Right,LClientRect.Bottom]));
    Width := LClientRect.Right;
    Height := LClientRect.Bottom;
  end else
    ;//WriteLn('o kurwa eh');
end;

{ TFakeCustomForm }

function TFakeCustomForm.GetDesignedForm: TDesignedFormImpl;
begin
  if not Assigned(FDesignedForm) then
    FDesignedForm := TDesignedFormImpl.Create(Self,Self);

  Result := FDesignedForm;
end;

function TFakeCustomForm.GetLogicalClientRect: TRect;
begin
  Result := DesignedForm.GetLogicalClientRect(inherited GetLogicalClientRect);
end;

function TFakeCustomForm.GetRealBounds(AIndex: Integer): Integer;
begin
  case AIndex of
    0: Result := inherited Left;
    1: Result := inherited Top;
    2: Result := inherited Width;
    3: Result := inherited Height;
  end;
end;

procedure TFakeCustomForm.SetRealBounds(AIndex: Integer; AValue: Integer);
begin
  case AIndex of
    0: inherited Left := AValue;
    1: inherited Top := AValue;
    2: inherited Width := AValue;
    3: inherited Height := AValue;
  end;
end;

function TFakeCustomForm.GetPublishedBounds(AIndex: Integer): Integer;
begin
  Result := DesignedForm.GetPublishedBounds(AIndex);
end;

procedure TFakeCustomForm.SetPublishedBounds(AIndex: Integer; AValue: Integer);
begin
  case AIndex of
    0, 1: DesignedForm.SetPublishedBounds(AIndex, AValue);
    2, 3:
      begin
        DesignedForm.SetPublishedBounds(AIndex, AValue);
        SetRealBounds(AIndex, DesignedForm.GetPublishedBounds(AIndex));
      end;
  end;
end;

constructor TFakeCustomForm.CreateNew(AOwner: TComponent; Num: Integer);
begin
  inherited CreateNew(AOwner, Num);

  Left := inherited Left;
  Top := inherited Top;
  Width := inherited Width;
  Height := inherited Height;
end;

destructor TFakeCustomForm.Destroy;
begin
  // we need to call "Screen.RemoveForm" to perform
  // references back to nil by IDesignedForm to FDesignedForm
  inherited Destroy;
  if Assigned(FDesignedForm) then
    FreeAndNil(FDesignedForm);
end;

procedure TFakeCustomForm.SetRealBorderStyle(AVal: TFormBorderStyle);
begin
  inherited BorderStyle := AVal;
end;

procedure TFakeCustomForm.SetRealBorderIcons(AVal: TBorderIcons);
begin
  inherited BorderIcons := AVal;
end;

procedure TFakeCustomForm.SetRealFormStyle(AVal: TFormStyle);
begin
  inherited FormStyle := AVal;
end;

procedure TFakeCustomForm.SetRealPopupMode(AVal: TPopupMode);
begin
  inherited PopupMode := AVal;
end;

procedure TFakeCustomForm.SetRealPopupParent(AVal: TCustomForm);
begin
  inherited PopupParent := AVal;
end;

function TFakeCustomForm.GetRealBorderStyle: TFormBorderStyle;
begin
  Result := inherited BorderStyle;
end;

function TFakeCustomForm.GetRealBorderIcons: TBorderIcons;
begin
  Result := inherited BorderIcons;
end;

function TFakeCustomForm.GetRealFormStyle: TFormStyle;
begin
  Result := inherited FormStyle;
end;

function TFakeCustomForm.GetRealPopupMode: TPopupMode;
begin
  Result := inherited PopupMode;
end;

function TFakeCustomForm.GetRealPopupParent: TCustomForm;
begin
  Result := inherited PopupParent;
end;

{ TDesignedFormImpl }

function TDesignedFormImpl.GetLastActiveSourceWindow: TSourceEditorWindowInterface;
begin
  Result := FLastActiveSourceWindow;
end;

procedure TDesignedFormImpl.SetLastActiveSourceWindow(
  AValue: TSourceEditorWindowInterface);
begin
  FLastActiveSourceWindow := AValue;
end;

procedure TDesignedFormImpl.BeginUpdate;
begin
  TFormAccess(FForm).SetDesigning(False, False);
  inherited BeginUpdate;
end;

procedure TDesignedFormImpl.EndUpdate(AModified: Boolean);
var
  OI: TObjectInspectorDlg;
begin
  TFormAccess(FForm).SetDesigning(True, False);
  inherited EndUpdate(AModified);
  if AModified and (FormEditingHook <> nil)
  and (FormEditingHook.GetCurrentDesigner = FForm.Designer) then
  begin
    OI := FormEditingHook.GetCurrentObjectInspector;
    if Assigned(OI) then
      OI.RefreshPropertyValues;
  end;
end;

end.