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_ResizerFrame;
14 
15 {$mode delphi}{$H+}
16 
17 interface
18 
19 uses
20   SysUtils,
21   // IdeIntf
22   FormEditingIntf, PropEdits, ObjectInspector,
23   // Sparta
24   sparta_BasicResizeFrame;
25 
26 type
27 
28   { TResizerFrame }
29 
30   TResizerFrame = class(TBasicResizeFrame)
31   private
32     FActivePropertyGridItemIndex: Integer;
33   protected
34     procedure TryBoundDesignedForm; override;
35     procedure BeginFormSizeUpdate(Sender: TObject); override;
36     procedure EndFormSizeUpdate(Sender: TObject); override;
37   end;
38 
39 implementation
40 
41 {$R *.lfm}
42 
43 { TResizerFrame }
44 
45 procedure TResizerFrame.TryBoundDesignedForm;
46 begin
47   if DesignedForm = nil then
48     Exit;
49 
50   // special for frames
51   {DesignedForm.BeginUpdate;
52   DesignedForm.RealWidth := DesignedForm.RealWidth + 1;
53   DesignedForm.RealWidth := DesignedForm.RealWidth - 1;
54   DesignedForm.EndUpdate;}
55 
56   inherited TryBoundDesignedForm;
57 end;
58 
59 procedure TResizerFrame.BeginFormSizeUpdate(Sender: TObject);
60 var
61   OI: TObjectInspectorDlg;
62 begin
63   inherited;
64 
65   // when was active ActivePropertyGrid.ItemIndex for height or width during scaling
66   // there was problem with values :<
67   OI := FormEditingHook.GetCurrentObjectInspector;
68   if ((Sender = pR) or (Sender = pB) or (FNodes.IndexOf(Sender) in [3,4,5])) and Assigned(OI) then
69   begin
70     FActivePropertyGridItemIndex := OI.GetActivePropertyGrid.ItemIndex;
71     OI.GetActivePropertyGrid.ItemIndex := -1;
72   end
73   else
74     FActivePropertyGridItemIndex := -1;
75 end;
76 
77 procedure TResizerFrame.EndFormSizeUpdate(Sender: TObject);
78 var
79   OI: TObjectInspectorDlg;
80 begin
81   inherited;
82 
83   // restore last selected item in OI.
84   if FActivePropertyGridItemIndex <> -1 then
85   begin
86     OI := FormEditingHook.GetCurrentObjectInspector;
87     if OI <> nil then
88       OI.GetActivePropertyGrid.ItemIndex := FActivePropertyGridItemIndex;
89     FActivePropertyGridItemIndex := -1;
90   end;
91 
92   GlobalDesignHook.RefreshPropertyValues;
93 end;
94 
95 end.
96 
97