mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-05-29 06:22:44 +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 -
164 lines
4.6 KiB
ObjectPascal
164 lines
4.6 KiB
ObjectPascal
unit sparta_BasicResizer;
|
|
|
|
{$mode delphi}{$H+}
|
|
|
|
interface
|
|
|
|
uses
|
|
Classes, SysUtils, Controls, ExtCtrls, sparta_BasicResizeFrame, Forms, Math, StdCtrls,
|
|
LCLType, Buttons, Dialogs,
|
|
sparta_InterfacesMDI, sparta_MDI_StrConsts, sparta_AbstractResizer;
|
|
|
|
type
|
|
|
|
{ TBasicResizer }
|
|
|
|
TBasicResizer = class(TAbstractResizer)
|
|
private
|
|
FDesignedForm: IDesignedForm;
|
|
FResizerFrame: TBasicResizeFrame;
|
|
protected
|
|
function GetActiveResizeFrame: IResizeFrame; override;
|
|
function GetActiveDesignedForm: IDesignedForm; override;
|
|
procedure SetDesignedForm(const AValue: IDesignedForm); virtual;
|
|
public
|
|
constructor Create(AParent: TWinControl; AResizerFrameClass: TResizerFrameClass); override;
|
|
destructor Destroy; override;
|
|
|
|
property DesignedForm: IDesignedForm read FDesignedForm write SetDesignedForm;
|
|
|
|
//procedure TryBoundSizerToDesignedForm(Sender: TObject); override;
|
|
end;
|
|
|
|
implementation
|
|
|
|
{ TBasicResizer }
|
|
|
|
procedure TBasicResizer.SetDesignedForm(const AValue: IDesignedForm);
|
|
|
|
function FindFirstFormParent: TCustomForm;
|
|
begin
|
|
Result := TCustomForm(FResizerFrame.Parent);
|
|
while not (Result is TCustomForm) do
|
|
Result := TCustomForm(Result.Parent);
|
|
end;
|
|
|
|
begin
|
|
if FDesignedForm <> nil then
|
|
begin
|
|
FDesignedForm.OnChangeHackedBounds := nil;
|
|
end;
|
|
|
|
FDesignedForm := AValue;
|
|
|
|
if FDesignedForm <> nil then
|
|
begin
|
|
FDesignedForm.BeginUpdate;
|
|
|
|
FDesignedForm.Form.Parent := FResizerFrame.pClient;
|
|
{$IFNDEF WINDOWS}
|
|
FDesignedForm.Form.BorderStyle := bsNone;
|
|
{$ENDIF}
|
|
// for big forms (bigger than screen resolution) we need to refresh Real* values
|
|
DesignedForm.RealWidth := DesignedForm.Width;
|
|
DesignedForm.RealHeight := DesignedForm.Height;
|
|
|
|
FDesignedForm.EndUpdate;
|
|
FDesignedForm.OnChangeHackedBounds := TryBoundSizerToDesignedForm;
|
|
end;
|
|
|
|
FResizerFrame.DesignedForm := AValue;
|
|
end;
|
|
|
|
constructor TBasicResizer.Create(AParent: TWinControl;
|
|
AResizerFrameClass: TResizerFrameClass);
|
|
begin
|
|
inherited Create(AParent, AResizerFrameClass);
|
|
|
|
FResizerFrame := CreateResizeFrame;
|
|
end;
|
|
|
|
destructor TBasicResizer.Destroy;
|
|
begin
|
|
Pointer(FDesignedForm) := nil;
|
|
inherited Destroy;
|
|
end;
|
|
|
|
(*procedure TBasicResizer.TryBoundSizerToDesignedForm(Sender: TObject);
|
|
var
|
|
LWidth, LHeight: Integer;
|
|
LScrollPos: Integer;
|
|
begin
|
|
if DesignedForm = nil then
|
|
Exit;
|
|
|
|
FResizerFrame.Constraints.MaxWidth := pMain.Width;
|
|
FResizerFrame.Constraints.MaxHeight := pMain.Height;
|
|
|
|
LWidth := DesignedForm.Width + FResizerFrame.BgLeftMargin + FResizerFrame.BgRightMargin + 2*FResizerFrame.SIZER_RECT_SIZE;
|
|
LHeight := DesignedForm.Height + FResizerFrame.BgTopMargin + FResizerFrame.BgBottomMargin + 2*FResizerFrame.SIZER_RECT_SIZE;
|
|
if not FResizerFrame.NodePositioning then
|
|
begin
|
|
FResizerFrame.Width := LWidth;
|
|
FResizerFrame.Height := LHeight;
|
|
// after enlargement and after reducing constrait not work for frame (LCL bug)
|
|
if FResizerFrame.Width > FResizerFrame.Constraints.MaxWidth then
|
|
FResizerFrame.Width := FResizerFrame.Constraints.MaxWidth;
|
|
if FResizerFrame.Height > FResizerFrame.Constraints.MaxHeight then
|
|
FResizerFrame.Height := FResizerFrame.Constraints.MaxHeight;
|
|
end;
|
|
|
|
FResizerFrame.PositionNodes(FResizerFrame);
|
|
|
|
DesignScrollBottom := FResizerFrame.Width < LWidth;
|
|
sbH.Max := LWidth;
|
|
FRealMaxH := LWidth - FResizerFrame.Width;
|
|
sbH.PageSize := FResizerFrame.Width;
|
|
if FResizerFrame.HorizontalScrollPos > FRealMaxH then
|
|
begin
|
|
FResizerFrame.HorizontalScrollPos := FRealMaxH;
|
|
LScrollPos := FResizerFrame.HorizontalScrollPos;
|
|
sbScroll(sbH, scEndScroll, LScrollPos);
|
|
end;
|
|
|
|
DesignScrollRight := FResizerFrame.Height < LHeight;
|
|
sbV.Max := LHeight;
|
|
FRealMaxV := LHeight - FResizerFrame.Height;
|
|
sbV.PageSize := FResizerFrame.Height;
|
|
if FResizerFrame.VerticalScrollPos > FRealMaxV then
|
|
begin
|
|
FResizerFrame.VerticalScrollPos := FRealMaxV;
|
|
LScrollPos := FResizerFrame.VerticalScrollPos;
|
|
sbScroll(sbV, scEndScroll, LScrollPos);
|
|
end;
|
|
|
|
{!}
|
|
FResizerFrame.ClientChangeBounds(nil);
|
|
|
|
// each editor can have scrolls in different positions.
|
|
// this is our place where we can call event to set scroll positions.
|
|
LScrollPos := FResizerFrame.VerticalScrollPos;
|
|
sbScroll(sbV, scEndScroll, LScrollPos);
|
|
LScrollPos := FResizerFrame.HorizontalScrollPos;
|
|
sbScroll(sbH, scEndScroll, LScrollPos);
|
|
|
|
if Supports(FDesignedForm, IDesignedFormBackground) then
|
|
(FDesignedForm as IDesignedFormBackground).RefreshValues;
|
|
|
|
FResizerFrame.DesignerSetFocus;
|
|
end;*)
|
|
|
|
function TBasicResizer.GetActiveResizeFrame: IResizeFrame;
|
|
begin
|
|
Result := FResizerFrame;
|
|
end;
|
|
|
|
function TBasicResizer.GetActiveDesignedForm: IDesignedForm;
|
|
begin
|
|
Result := FDesignedForm;
|
|
end;
|
|
|
|
|
|
end.
|
|
|