mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-23 04:39:36 +02:00
IDE: Simplify component palette code, ComponentPage.Priority is not used. Rename a method.
git-svn-id: trunk@47004 -
This commit is contained in:
parent
75c4a0f8df
commit
c7486b1bf9
@ -138,7 +138,6 @@ type
|
||||
FPageComponent: TCustomPage;
|
||||
FPageName: string;
|
||||
FPalette: TBaseComponentPalette;
|
||||
FPriority: TComponentPriority;
|
||||
FSelectButton: TComponent;
|
||||
FVisible: boolean;
|
||||
protected
|
||||
@ -152,7 +151,6 @@ type
|
||||
public
|
||||
property PageName: string read FPageName;
|
||||
property Palette: TBaseComponentPalette read FPalette write FPalette;
|
||||
property Priority: TComponentPriority read FPriority write FPriority;
|
||||
property PageComponent: TCustomPage read FPageComponent write FPageComponent;
|
||||
property SelectButton: TComponent read FSelectButton write FSelectButton;
|
||||
property Visible: boolean read FVisible write SetVisible;
|
||||
@ -208,7 +206,7 @@ type
|
||||
procedure OnComponentVisibleChanged({%H-}AComponent: TRegisteredComponent); virtual;
|
||||
procedure OnPageVisibleChanged({%H-}APage: TBaseComponentPage); virtual;
|
||||
procedure Update; virtual;
|
||||
function UpdateVisible(AComponent: TRegisteredComponent): Boolean; virtual;
|
||||
function VoteCompVisibility(AComponent: TRegisteredComponent): Boolean; virtual;
|
||||
function GetSelected: TRegisteredComponent; virtual;
|
||||
procedure SetBaseComponentPageClass(const AValue: TBaseComponentPageClass); virtual;
|
||||
procedure SetRegisteredComponentClass(const AValue: TRegisteredComponentClass); virtual;
|
||||
@ -597,7 +595,7 @@ begin
|
||||
HasVisibleComponents:=false;
|
||||
for i:=0 to Palette.Comps.Count-1 do
|
||||
if (Palette.Comps[i].RealPage = Self) then
|
||||
if Palette.UpdateVisible(Palette.Comps[i]) then
|
||||
if Palette.VoteCompVisibility(Palette.Comps[i]) then
|
||||
HasVisibleComponents:=true;
|
||||
Visible:=HasVisibleComponents and (PageName<>'');
|
||||
end;
|
||||
@ -716,7 +714,7 @@ begin
|
||||
|
||||
end;
|
||||
|
||||
function TBaseComponentPalette.UpdateVisible(AComponent: TRegisteredComponent): Boolean;
|
||||
function TBaseComponentPalette.VoteCompVisibility(AComponent: TRegisteredComponent): Boolean;
|
||||
var
|
||||
i, Vote: Integer;
|
||||
begin
|
||||
|
@ -132,8 +132,6 @@ type
|
||||
destructor Destroy; override;
|
||||
procedure Clear;
|
||||
procedure ClearButtons;
|
||||
function CreateNewPage(const NewPageName: string;
|
||||
const Priority: TComponentPriority): TBaseComponentPage;
|
||||
function CreatePagesFromUserOrder: Boolean;
|
||||
procedure DoAfterComponentAdded; override;
|
||||
function GetUnregisteredIcon: TCustomBitmap;
|
||||
@ -668,23 +666,6 @@ begin
|
||||
FPageControl.EnableAlign;
|
||||
end;
|
||||
|
||||
function TComponentPalette.CreateNewPage(const NewPageName: string;
|
||||
const Priority: TComponentPriority): TBaseComponentPage;
|
||||
var
|
||||
InsertIndex: Integer;
|
||||
begin
|
||||
Result:=TBaseComponentPage.Create(NewPageName);
|
||||
Result.Priority:=Priority;
|
||||
InsertIndex:=0;
|
||||
while (InsertIndex<Pages.Count)
|
||||
and (ComparePriority(Priority,Pages[InsertIndex].Priority)<=0) do
|
||||
inc(InsertIndex);
|
||||
fPages.Insert(InsertIndex,Result);
|
||||
Result.Palette:=Self;
|
||||
if CompareText(NewPageName,'Hidden')=0 then
|
||||
Result.Visible:=false;
|
||||
end;
|
||||
|
||||
function TComponentPalette.CreatePagesFromUserOrder: Boolean;
|
||||
var
|
||||
i, j: Integer;
|
||||
@ -700,7 +681,13 @@ begin
|
||||
for i := 0 to fUserOrder.ComponentPages.Count-1 do
|
||||
begin
|
||||
PgName := fUserOrder.ComponentPages[i];
|
||||
Pg:=CreateNewPage(PgName, ComponentPriorityNormal);
|
||||
// Create a new page
|
||||
Pg:=TBaseComponentPage.Create(PgName);
|
||||
fPages.Add(Pg);
|
||||
Pg.Palette:=Self;
|
||||
if CompareText(PgName,'Hidden')=0 then
|
||||
Pg.Visible:=false;
|
||||
// Assign components belonging to this page
|
||||
CompNames := TStringList(fUserOrder.ComponentPages.Objects[i]);
|
||||
for j := 0 to CompNames.Count-1 do
|
||||
begin
|
||||
|
Loading…
Reference in New Issue
Block a user