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