mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-18 17:48:14 +02:00

sparta: initial commit of "compilable" new sparta package - smart form editor. !NOTE: not for daily usage. ........ sparta: Initial conception for package for MDI: sparta_MDI. Base for sparta_DockedFormEditor package. ........ sparta: Generics.Collections library ( sync with https://github.com/dathox/generics.collections SHA fda586932bd80ef58c08f8ebf5a24316ca4ccca5) ........ sparta: smart form editor adjustment for new sparta_MDI ........ sparta: new class "TFormImpl" for MDI solution (created from TDesignedFormImpl). ........ sparta: -MDI form container "TFormContainer" -New IResizeFrame interface to handle MDI form moving -New frame TfrFormBackgroundForMDI ........ sparta: sparta_MDI package modifications: -new class TMultiplyResizer to menage MDI desktop -more generic resizer: TAbstractResizer. Base for IDE resizer and TMultiplyResizer -more advanced IResizeFrame interface ........ sparta: -DockedFormEditor adjustment for latest changes in mdi package -small changes in mdi (visibility of methods). -OnModified method for IResizeFrame ........ sparta: MDI -simulate MDI forms order for TMultiplyResizer -property DesignedForm: IDesignedForm for IResizeFrame ........ sparta: -IMPORTANT! pixel perfect form resizing (fix for problems for controls with align alLeft, alRight etc on design form). -Fix problem for windows: wrong design design window width (a little bigger than designed size) TFormImpl.SetRealBounds -> AdjustSize ........ sparta: mdi bug fix for AV in TMultiplyResizer ........ Fix compilation for FPC 3.0 (TRect changes in FPC 3.1 trunk) ........ sparta: Cannot resize the docked form designer, issue #29380 patch from Anthony Walter. Thanks! ........ sparta ToolsAPI: Delphi compatible ToolsAPI/DesignIDE interface at XE2 level (proxy for IDEIntf). Initial commit (no functionality yet), just interfaces and classes without implementation: designeditors.pas: -TComponentEditor designintf.pas: -Interfaces: IEventInfo, IClass, IActivatable, IDesignObject, IDesignPersistent, IDesignerSelections, IDesigner60, IDesigner70, IDesigner80, IDesigner100, IDesigner, IComponentEditor -TBaseComponentEditor -RegisterComponentEditor designmenus.pas: -Interfaces: IMenuItems, IMenu, IMainMenu, IPopupMenu, IMenuItem ........ when form is removed we need to remove all handlers located in collections FFormsStack and FForms. Necessary to avoid AV. ........ sparta: more correct and simpler calculation of form border for Windows ........ sparta: * Fix for loop error for resize. Highly visible problem for docked forms/frames with Align=alClient. * New THookFrame class as new meta class for Frames. ........ updated lpl ........ git-svn-id: trunk@52728 -
276 lines
6.9 KiB
ObjectPascal
276 lines
6.9 KiB
ObjectPascal
{
|
|
*****************************************************************************
|
|
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_EDTU_Main;
|
|
|
|
{$mode delphi}{$H+}
|
|
|
|
interface
|
|
|
|
uses
|
|
Classes, SysUtils, FileUtil, Forms, Controls, ExtCtrls, Buttons, ComCtrls,
|
|
StdCtrls, Menus, EditBtn, ComponentReg, FormEditingIntf,
|
|
LazIDEIntf, SpartaAPI, Math, PropEdits, sparta_ComponentPalette, sparta_FakeForm;
|
|
|
|
type
|
|
|
|
{ TedtuMain }
|
|
|
|
TedtuMain = class(TFrame, ISTADesignTimeUtil, ISTAMainDesignTimeUtil)
|
|
eFilter: TEditButton;
|
|
pInfo: TPanel;
|
|
pComponents: TPanel;
|
|
pSearch: TPanel;
|
|
pEDTU: TPanel;
|
|
sbShowPalette: TSpeedButton;
|
|
procedure eFilterButtonClick(Sender: TObject);
|
|
procedure eFilterChange(Sender: TObject);
|
|
procedure sbShowPaletteClick(Sender: TObject);
|
|
private
|
|
FRoot: TPersistent;
|
|
FEDTU: TList;
|
|
FNonVisualComponentsEDTU: Pointer;
|
|
FComponentsPalette: TComponentsPalette;
|
|
|
|
procedure CreateEDTUButtons;
|
|
procedure SetRoot(AValue: TPersistent);
|
|
function GetRoot: TPersistent;
|
|
|
|
function GetShowNonVisualComponents: Boolean;
|
|
|
|
procedure OnShowEditorClick(Sender: TObject);
|
|
|
|
procedure OnDesignRefreshPropertyValues;
|
|
procedure OnPersistentDeleted;
|
|
procedure OnPersistentAdded(APersistent: TPersistent; Select: boolean);
|
|
public
|
|
{ public declarations }
|
|
pAddons: TWinControl;
|
|
|
|
constructor Create(AOwner: TComponent); override;
|
|
destructor Destroy; override;
|
|
property Root: TPersistent read GetRoot write SetRoot;
|
|
end;
|
|
|
|
implementation
|
|
|
|
{$R *.lfm}
|
|
|
|
{ TedtuMain }
|
|
|
|
procedure TedtuMain.eFilterChange(Sender: TObject);
|
|
begin
|
|
if Assigned(FComponentsPalette) then
|
|
FComponentsPalette.Filter := eFilter.Text;
|
|
end;
|
|
|
|
procedure TedtuMain.eFilterButtonClick(Sender: TObject);
|
|
begin
|
|
eFilter.Text := '';
|
|
end;
|
|
|
|
procedure TedtuMain.sbShowPaletteClick(Sender: TObject);
|
|
begin
|
|
if pComponents.Visible = False then
|
|
begin
|
|
Parent.Height:=55;
|
|
Height:=55;
|
|
pComponents.Visible := True;
|
|
eFilter.SetFocus;
|
|
pInfo.Visible := False;
|
|
end
|
|
else
|
|
begin
|
|
Parent.Height:=22;
|
|
Height:=22;
|
|
pComponents.Visible := False;
|
|
pInfo.Visible := True;
|
|
end;
|
|
|
|
if not Assigned(FComponentsPalette) then
|
|
begin
|
|
FComponentsPalette := TComponentsPalette.Create(pComponents, pComponents);
|
|
FComponentsPalette.Root := FRoot;
|
|
end;
|
|
end;
|
|
|
|
procedure TedtuMain.CreateEDTUButtons;
|
|
var
|
|
i: Integer;
|
|
LLeft: TControl;
|
|
LButton: TSpeedButton;
|
|
LASR: TAnchorSideReference;
|
|
begin
|
|
FEDTU := TList.Create;
|
|
|
|
LLeft := pEDTU;
|
|
LASR := asrLeft;
|
|
for i := 0 to DTUManager.EDTUCount - 1 do
|
|
if DTUManager.EDTU[i].AvailableForRoot(FRoot) then
|
|
begin
|
|
LButton := TSpeedButton.Create(pEDTU);
|
|
with LButton do
|
|
begin
|
|
Parent := pEDTU;
|
|
AnchorSideLeft.Control := LLeft;
|
|
AnchorSideLeft.Side := LASR;
|
|
AnchorSideBottom.Control := pEDTU;
|
|
AnchorSideBottom.Side := asrBottom;
|
|
Anchors := [akLeft, akBottom];
|
|
LLeft := LButton;
|
|
Tag := -Succ(i);
|
|
LoadGlyphFromResourceName(HINSTANCE, DTUManager.EDTU[i].GlyphName);
|
|
GroupIndex := 1;
|
|
AllowAllUp := True;
|
|
OnClick:=OnShowEditorClick;
|
|
end;
|
|
LASR := asrRight;
|
|
end;
|
|
end;
|
|
|
|
procedure TedtuMain.SetRoot(AValue: TPersistent);
|
|
var
|
|
i: Integer;
|
|
begin
|
|
if FRoot = AValue then
|
|
Exit;
|
|
FRoot := AValue;
|
|
|
|
// skoro tu jestesmy pierwszy raz to ARoot <> nil (FRoot domyslnie ma nil)
|
|
if FEDTU = nil then
|
|
CreateEDTUButtons
|
|
else
|
|
for i := 0 to FEDTU.Count - 1 do
|
|
ISTAExtendedDesignTimeUtil(FEDTU[i]).Root := FRoot;
|
|
|
|
if Assigned(FComponentsPalette) then
|
|
FComponentsPalette.Root := FRoot;
|
|
|
|
OnDesignRefreshPropertyValues;
|
|
end;
|
|
|
|
function TedtuMain.GetRoot: TPersistent;
|
|
begin
|
|
Result := FRoot;
|
|
end;
|
|
|
|
function TedtuMain.GetShowNonVisualComponents: Boolean;
|
|
begin
|
|
if FNonVisualComponentsEDTU <> nil then
|
|
Result := ISTANonVisualComponentsUtil(FNonVisualComponentsEDTU).ShowNonVisualComponents
|
|
else
|
|
Result := True;
|
|
end;
|
|
|
|
procedure TedtuMain.OnShowEditorClick(Sender: TObject);
|
|
var
|
|
LCtrl: TControl;
|
|
i: Integer;
|
|
LButton: TSpeedButton absolute Sender;
|
|
LEDTU: ISTAExtendedDesignTimeUtil;
|
|
begin
|
|
if FRoot = nil then
|
|
Exit;
|
|
|
|
if LButton.Tag < 0 then
|
|
begin
|
|
LEDTU := DTUManager.EDTU[Pred(-LButton.Tag)].CreateEDTUForRoot(pAddons, FRoot);
|
|
LEDTU.Parent := pAddons;
|
|
LEDTU.RefreshValues;
|
|
LButton.Tag := FEDTU.Add(LEDTU);
|
|
|
|
if Supports(LEDTU, ISTANonVisualComponentsUtil) then
|
|
FNonVisualComponentsEDTU := LEDTU as ISTANonVisualComponentsUtil;
|
|
end;
|
|
|
|
for i := 0 to pEDTU.ControlCount - 1 do
|
|
begin
|
|
LCtrl := pEDTU.Controls[i];
|
|
if LButton = LCtrl then
|
|
Continue;
|
|
|
|
if LCtrl.Tag >= 0 then
|
|
ISTAExtendedDesignTimeUtil(FEDTU[LCtrl.Tag]).Visible := False;
|
|
end;
|
|
|
|
ISTAExtendedDesignTimeUtil(FEDTU[LButton.Tag]).Visible := LButton.Down;
|
|
pAddons.Width := ifthen(not LButton.Down, 0, 256);
|
|
end;
|
|
|
|
procedure TedtuMain.OnDesignRefreshPropertyValues;
|
|
var
|
|
i: Integer;
|
|
f: TFakeForm;
|
|
LCtrlCount: Integer = 0;
|
|
LCompCount: Integer = 0;
|
|
LNonVisualCount: Integer = 0;
|
|
|
|
procedure GetCompAndCtrlCount(AComp: TComponent);
|
|
var
|
|
i: Integer;
|
|
LComp: TComponent;
|
|
begin
|
|
Inc(LCompCount, AComp.ComponentCount);
|
|
if AComp is TWinControl then
|
|
Inc(LCtrlCount, TWinControl(AComp).ControlCount);
|
|
for i := 0 to AComp.ComponentCount - 1 do
|
|
GetCompAndCtrlCount(AComp.Components[i]);
|
|
end;
|
|
|
|
begin
|
|
if FRoot <> GlobalDesignHook.LookupRoot then
|
|
Exit;
|
|
|
|
if FRoot is TForm then
|
|
begin
|
|
f := TFakeForm(FRoot);
|
|
//pInfo.Caption := Format('%s (X: %d Y: %d W: %d H: %d) ComponentCount = %d ControlCount = %d NonVisualCount = %d',
|
|
// [f.Name, f.Left, f.Top, f.Width, f.Height, LCompCount, LCtrlCount, LCompCount - LCtrlCount]);
|
|
pInfo.Caption := Format('%s (X: %d Y: %d W: %d H: %d)',
|
|
[f.Name, f.Left, f.Top, f.Width, f.Height]);
|
|
end;
|
|
end;
|
|
|
|
procedure TedtuMain.OnPersistentDeleted;
|
|
begin
|
|
OnDesignRefreshPropertyValues
|
|
end;
|
|
|
|
procedure TedtuMain.OnPersistentAdded(APersistent: TPersistent; Select: boolean
|
|
);
|
|
begin
|
|
OnDesignRefreshPropertyValues
|
|
end;
|
|
|
|
constructor TedtuMain.Create(AOwner: TComponent);
|
|
begin
|
|
inherited Create(AOwner);
|
|
|
|
sbShowPalette.LoadGlyphFromResourceName(HINSTANCE, 'SHOW_PALETTE_UP');
|
|
eFilter.Button.LoadGlyphFromResourceName(HINSTANCE, 'MENU_CLOSE');
|
|
GlobalDesignHook.AddHandlerRefreshPropertyValues(OnDesignRefreshPropertyValues);
|
|
GlobalDesignHook.AddHandlerPersistentDeleted(OnPersistentDeleted);
|
|
GlobalDesignHook.AddHandlerPersistentAdded(OnPersistentAdded);
|
|
end;
|
|
|
|
destructor TedtuMain.Destroy;
|
|
begin
|
|
GlobalDesignHook.RemoveHandlerRefreshPropertyValues(OnDesignRefreshPropertyValues);
|
|
GlobalDesignHook.RemoveHandlerPersistentDeleted(OnPersistentDeleted);
|
|
GlobalDesignHook.RemoveHandlerPersistentAdded(OnPersistentAdded);
|
|
FEDTU.Free;
|
|
inherited Destroy;
|
|
end;
|
|
|
|
end.
|
|
|