mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-23 08:19:41 +02:00
IDE: Move reference of TCustomPage and TScrollBox from ComponentReg interface to ComponentPalette.
git-svn-id: trunk@48304 -
This commit is contained in:
parent
c55e1a9cca
commit
159ba4fccf
@ -24,7 +24,7 @@ unit ComponentReg;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, typinfo, Controls, ComCtrls, Forms,
|
||||
Classes, SysUtils, typinfo, Controls,
|
||||
Laz2_XMLCfg, LCLProc, fgl;
|
||||
|
||||
type
|
||||
@ -132,7 +132,6 @@ type
|
||||
|
||||
TBaseComponentPage = class
|
||||
private
|
||||
FPageComponent: TCustomPage;
|
||||
FPageName: string;
|
||||
FPalette: TBaseComponentPalette;
|
||||
FSelectButton: TComponent;
|
||||
@ -143,11 +142,9 @@ type
|
||||
public
|
||||
constructor Create(const ThePageName: string);
|
||||
destructor Destroy; override;
|
||||
function GetScrollBox: TScrollBox;
|
||||
public
|
||||
property PageName: string read FPageName;
|
||||
property Palette: TBaseComponentPalette read FPalette write FPalette;
|
||||
property PageComponent: TCustomPage read FPageComponent write FPageComponent;
|
||||
property SelectButton: TComponent read FSelectButton write FSelectButton;
|
||||
property Visible: boolean read FVisible write SetVisible;
|
||||
end;
|
||||
@ -230,7 +227,6 @@ type
|
||||
function FindComponent(const CompClassName: string): TRegisteredComponent; virtual;
|
||||
function FindButton(Button: TComponent): TRegisteredComponent;
|
||||
function CreateNewClassName(const Prefix: string): string;
|
||||
function IndexOfPageComponent(AComponent: TComponent): integer;
|
||||
procedure Update(ForceUpdateAll: Boolean); virtual; abstract;
|
||||
procedure IterateRegisteredClasses(Proc: TGetComponentClassEvent);
|
||||
{$IFDEF CustomIDEComps}
|
||||
@ -557,7 +553,6 @@ end;
|
||||
|
||||
destructor TBaseComponentPage.Destroy;
|
||||
begin
|
||||
FreeAndNil(FPageComponent);
|
||||
FreeAndNil(FSelectButton);
|
||||
inherited Destroy;
|
||||
end;
|
||||
@ -576,15 +571,6 @@ begin
|
||||
FPalette.OnComponentVisibleChanged(AComponent);
|
||||
end;
|
||||
|
||||
function TBaseComponentPage.GetScrollBox: TScrollBox;
|
||||
begin
|
||||
if Assigned(PageComponent) and (PageComponent.ComponentCount > 0)
|
||||
and (PageComponent.Components[0] is TScrollBox) then
|
||||
Result := TScrollBox(PageComponent.Components[0])
|
||||
else
|
||||
Result := Nil;
|
||||
end;
|
||||
|
||||
{ TBaseComponentPalette }
|
||||
|
||||
constructor TBaseComponentPalette.Create;
|
||||
@ -854,16 +840,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TBaseComponentPalette.IndexOfPageComponent(AComponent: TComponent): integer;
|
||||
begin
|
||||
if AComponent<>nil then begin
|
||||
Result:=Pages.Count-1;
|
||||
while (Result>=0) and (Pages[Result].PageComponent<>AComponent) do
|
||||
dec(Result);
|
||||
end else
|
||||
Result:=-1;
|
||||
end;
|
||||
|
||||
procedure TBaseComponentPalette.IterateRegisteredClasses(Proc: TGetComponentClassEvent);
|
||||
var
|
||||
i: Integer;
|
||||
|
@ -81,6 +81,7 @@ type
|
||||
|
||||
TComponentPage = class(TBaseComponentPage)
|
||||
private
|
||||
fPageComponent: TCustomPage;
|
||||
fBtnIndex: integer;
|
||||
fIndex: Integer; // Index in the Pages container.
|
||||
fCompNames: TStringList; // Reference to component names.
|
||||
@ -96,6 +97,8 @@ type
|
||||
public
|
||||
constructor Create(const ThePageName: string);
|
||||
destructor Destroy; override;
|
||||
function GetScrollBox: TScrollBox;
|
||||
property PageComponent: TCustomPage read fPageComponent write fPageComponent;
|
||||
end;
|
||||
|
||||
{ TComponentPalette }
|
||||
@ -172,6 +175,7 @@ type
|
||||
procedure DoAfterComponentAdded; override;
|
||||
procedure OnGetNonVisualCompIcon(Sender: TObject;
|
||||
AComponent: TComponent; var Icon: TCustomBitmap);
|
||||
function IndexOfPageComponent(AComponent: TComponent): integer;
|
||||
function FindComponent(const CompClassName: string): TRegisteredComponent; override;
|
||||
{$IFDEF CustomIDEComps}
|
||||
procedure RegisterCustomIDEComponents(
|
||||
@ -301,9 +305,19 @@ end;
|
||||
|
||||
destructor TComponentPage.Destroy;
|
||||
begin
|
||||
FreeAndNil(fPageComponent);
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
function TComponentPage.GetScrollBox: TScrollBox;
|
||||
begin
|
||||
if Assigned(PageComponent) and (PageComponent.ComponentCount > 0)
|
||||
and (PageComponent.Components[0] is TScrollBox) then
|
||||
Result := TScrollBox(PageComponent.Components[0])
|
||||
else
|
||||
Result := Nil;
|
||||
end;
|
||||
|
||||
function IsSelectionToolBtn(aControl: TControl): boolean;
|
||||
begin
|
||||
Result:=(aControl is TSpeedButton)
|
||||
@ -618,7 +632,7 @@ procedure TComponentPalette.ActivePageChanged(Sender: TObject);
|
||||
begin
|
||||
if FPageControl=nil then exit;
|
||||
if (FSelected<>nil)
|
||||
and (FSelected.RealPage.PageComponent=FPageControl.ActivePage) then exit;
|
||||
and ((FSelected.RealPage as TComponentPage).PageComponent=FPageControl.ActivePage) then exit;
|
||||
if fUpdatingPageControl then exit;
|
||||
{$IFDEF VerboseComponentPalette}
|
||||
DebugLn('TComponentPalette.ActivePageChanged: Calling ReAlignButtons, setting Selected:=nil.');
|
||||
@ -832,7 +846,7 @@ begin
|
||||
FSelected.RealPage.PageComponent, ', Index ', FSelected.RealPage.PageComponent.PageIndex]);
|
||||
{$ENDIF}
|
||||
// Switch to the new page
|
||||
FPageControl.ActivePage:=TTabSheet(FSelected.RealPage.PageComponent);
|
||||
FPageControl.ActivePage:=TTabSheet((FSelected.RealPage as TComponentPage).PageComponent);
|
||||
// Build the GUI layout for this page if not done yet.
|
||||
if FSelected.Button=nil then
|
||||
ReAlignButtons(FPageControl.ActivePage);
|
||||
@ -1306,6 +1320,16 @@ begin
|
||||
Icon:=GetUnregisteredIcon;
|
||||
end;
|
||||
|
||||
function TComponentPalette.IndexOfPageComponent(AComponent: TComponent): integer;
|
||||
begin
|
||||
if AComponent<>nil then begin
|
||||
Result:=Pages.Count-1;
|
||||
while (Result>=0) and ((Pages[Result] as TComponentPage).PageComponent<>AComponent) do
|
||||
dec(Result);
|
||||
end else
|
||||
Result:=-1;
|
||||
end;
|
||||
|
||||
function TComponentPalette.FindComponent(const CompClassName: string): TRegisteredComponent;
|
||||
var
|
||||
ANode: TAVLTreeNode;
|
||||
|
Loading…
Reference in New Issue
Block a user