mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-07 05:58:15 +02:00
implemented installing components in component palette
git-svn-id: trunk@4092 -
This commit is contained in:
parent
a90e7d1689
commit
53ba42a1ef
@ -2874,7 +2874,7 @@ begin
|
||||
DirTempl.AddChild(TDefineTemplate.Create('main path addition',
|
||||
Format(ctsAddsDirToSourcePath,[ctsLazarusMainDirectory]),
|
||||
ExternalMacroStart+'SrcPath',
|
||||
'..;'+SrcPath
|
||||
'..;..'+ds+'packager;'+SrcPath
|
||||
,da_Define));
|
||||
DirTempl.AddChild(TDefineTemplate.Create('components path addition',
|
||||
Format(ctsAddsDirToSourcePath,['synedit']),
|
||||
|
@ -38,7 +38,7 @@ unit ComponentPalette;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Dialogs, Graphics, ExtCtrls, Buttons,
|
||||
Classes, SysUtils, Dialogs, Graphics, ExtCtrls, Buttons, LResources, AVL_Tree,
|
||||
ComponentReg, PackageDefs, LazarusIDEStrConsts;
|
||||
|
||||
const
|
||||
@ -47,38 +47,121 @@ const
|
||||
|
||||
type
|
||||
TComponentPalette = class(TBaseComponentPalette)
|
||||
procedure ActivePageChanged(Sender: TObject);
|
||||
private
|
||||
FNoteBook: TNotebook;
|
||||
fNoteBookNeedsUpdate: boolean;
|
||||
FSelected: TRegisteredComponent;
|
||||
fUpdatingNotebook: boolean;
|
||||
fComponents: TAVLTree; // tree of TRegisteredComponent sorted for componentclass
|
||||
fUnregisteredIcon: TBitmap;
|
||||
procedure SetNoteBook(const AValue: TNotebook);
|
||||
procedure SelectionToolClick(Sender: TObject);
|
||||
procedure ComponentBtnClick(Sender: TObject);
|
||||
procedure SetSelected(const AValue: TRegisteredComponent);
|
||||
protected
|
||||
procedure DoEndUpdate(Changed: boolean); override;
|
||||
procedure OnPageAddedComponent(Component: TRegisteredComponent); override;
|
||||
procedure OnPageRemovedComponent(Page: TBaseComponentPage;
|
||||
Component: TRegisteredComponent); override;
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
function GetUnregisteredIcon: TBitmap;
|
||||
function GetSelectButtonIcon: TBitmap;
|
||||
procedure ClearButtons; override;
|
||||
procedure SelectButton(Button: TComponent);
|
||||
procedure UpdateNoteBookButtons;
|
||||
procedure OnGetNonVisualCompIconCanvas(Sender: TObject;
|
||||
AComponent: TComponent; var IconCanvas: TCanvas;
|
||||
var IconWidth, IconHeight: integer);
|
||||
function FindComponent(const CompClassName: string): TRegisteredComponent; override;
|
||||
property NoteBook: TNotebook read FNoteBook write SetNoteBook;
|
||||
property Selected: TRegisteredComponent read FSelected write SetSelected;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
function CompareRegisteredComponents(Data1, Data2: Pointer): integer;
|
||||
var
|
||||
RegComp1: TRegisteredComponent;
|
||||
RegComp2: TRegisteredComponent;
|
||||
begin
|
||||
RegComp1:=TRegisteredComponent(Data1);
|
||||
RegComp2:=TRegisteredComponent(Data2);
|
||||
Result:=AnsiCompareText(RegComp1.ComponentClass.ClassName,
|
||||
RegComp2.ComponentClass.ClassName);
|
||||
end;
|
||||
|
||||
function CompareClassNameWithRegisteredComponent(Key, Data: Pointer): integer;
|
||||
var
|
||||
AClassName: String;
|
||||
RegComp: TRegisteredComponent;
|
||||
begin
|
||||
AClassName:=String(Key);
|
||||
RegComp:=TRegisteredComponent(Data);
|
||||
Result:=AnsiCompareText(AClassName,RegComp.ComponentClass.ClassName);
|
||||
end;
|
||||
|
||||
{ TComponentPalette }
|
||||
|
||||
procedure TComponentPalette.ActivePageChanged(Sender: TObject);
|
||||
begin
|
||||
if FNoteBook=nil then exit;
|
||||
if (FSelected<>nil)
|
||||
and (FSelected.Page.PageComponent=FNoteBook.ActivePageComponent)
|
||||
then exit;
|
||||
Selected:=nil;
|
||||
end;
|
||||
|
||||
procedure TComponentPalette.SetNoteBook(const AValue: TNotebook);
|
||||
begin
|
||||
if FNoteBook=AValue then exit;
|
||||
ClearButtons;
|
||||
FNoteBook:=AValue;
|
||||
if FNoteBook<>nil then
|
||||
FNoteBook.OnPageChanged:=@ActivePageChanged;
|
||||
UpdateNoteBookButtons;
|
||||
end;
|
||||
|
||||
procedure TComponentPalette.SelectionToolClick(Sender: TObject);
|
||||
begin
|
||||
|
||||
SelectButton(TComponent(Sender));
|
||||
end;
|
||||
|
||||
procedure TComponentPalette.ComponentBtnClick(Sender: TObject);
|
||||
begin
|
||||
SelectButton(TComponent(Sender));
|
||||
end;
|
||||
|
||||
procedure TComponentPalette.SetSelected(const AValue: TRegisteredComponent);
|
||||
var
|
||||
SelectButtonOnPage: TSpeedButton;
|
||||
CurPage: TBaseComponentPage;
|
||||
i: Integer;
|
||||
begin
|
||||
if FSelected=AValue then exit;
|
||||
FSelected:=AValue;
|
||||
if FSelected<>nil then begin
|
||||
if (FSelected.Page=nil) or (FSelected.Page.Palette<>Self)
|
||||
or (not FSelected.Visible)
|
||||
or (not FSelected.CanBeCreatedInDesigner) then
|
||||
FSelected:=nil;
|
||||
end;
|
||||
if FNoteBook=nil then exit;
|
||||
// unselect all other buttons on all other notebook pages
|
||||
for i:=0 to Count-1 do begin
|
||||
CurPage:=Pages[i];
|
||||
if (FSelected=nil) or (FSelected.Page<>CurPage) then begin
|
||||
SelectButtonOnPage:=TSpeedButton(CurPage.SelectButton);
|
||||
if SelectButtonOnPage<>nil then SelectButtonOnPage.Down:=true;
|
||||
end;
|
||||
end;
|
||||
// select button
|
||||
if FSelected<>nil then begin
|
||||
TSpeedButton(FSelected.Button).Down:=true;
|
||||
FNoteBook.ActivePageComponent:=TPage(FSelected.Page.PageComponent);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TComponentPalette.DoEndUpdate(Changed: boolean);
|
||||
@ -87,6 +170,75 @@ begin
|
||||
inherited DoEndUpdate(Changed);
|
||||
end;
|
||||
|
||||
procedure TComponentPalette.OnPageAddedComponent(Component: TRegisteredComponent
|
||||
);
|
||||
begin
|
||||
fComponents.Add(Component);
|
||||
inherited OnPageAddedComponent(Component);
|
||||
end;
|
||||
|
||||
procedure TComponentPalette.OnPageRemovedComponent(Page: TBaseComponentPage;
|
||||
Component: TRegisteredComponent);
|
||||
begin
|
||||
fComponents.Remove(Component);
|
||||
inherited OnPageRemovedComponent(Page, Component);
|
||||
end;
|
||||
|
||||
constructor TComponentPalette.Create;
|
||||
begin
|
||||
inherited Create;
|
||||
fComponents:=TAVLTree.Create(@CompareRegisteredComponents);
|
||||
end;
|
||||
|
||||
destructor TComponentPalette.Destroy;
|
||||
begin
|
||||
NoteBook:=nil;
|
||||
fComponents.Free;
|
||||
fComponents:=nil;
|
||||
if fUnregisteredIcon<>nil then begin
|
||||
fUnregisteredIcon.Free;
|
||||
fUnregisteredIcon:=nil;
|
||||
end;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
function TComponentPalette.GetUnregisteredIcon: TBitMap;
|
||||
var
|
||||
ResName: string;
|
||||
res: TLResource;
|
||||
begin
|
||||
if fUnregisteredIcon=nil then begin
|
||||
fUnregisteredIcon:=TPixmap.Create;
|
||||
fUnregisteredIcon.TransparentColor:=clWhite;
|
||||
ResName:='unregisteredcomponent';
|
||||
res:=LazarusResources.Find(ResName);
|
||||
if (res<>nil) and (res.Value<>'') and (res.ValueType='XPM') then begin
|
||||
fUnregisteredIcon.LoadFromLazarusResource(ResName);
|
||||
end else begin
|
||||
fUnregisteredIcon.LoadFromLazarusResource('default');
|
||||
end;
|
||||
end;
|
||||
Result:=fUnregisteredIcon;
|
||||
end;
|
||||
|
||||
function TComponentPalette.GetSelectButtonIcon: TBitmap;
|
||||
begin
|
||||
Result:=TPixmap.Create;
|
||||
Result.TransparentColor:=clWhite;
|
||||
Result.LoadFromLazarusResource('tmouse');
|
||||
end;
|
||||
|
||||
procedure TComponentPalette.ClearButtons;
|
||||
begin
|
||||
Selected:=nil;
|
||||
inherited ClearButtons;
|
||||
end;
|
||||
|
||||
procedure TComponentPalette.SelectButton(Button: TComponent);
|
||||
begin
|
||||
Selected:=FindButton(Button);
|
||||
end;
|
||||
|
||||
procedure TComponentPalette.UpdateNoteBookButtons;
|
||||
var
|
||||
i: Integer;
|
||||
@ -98,16 +250,19 @@ var
|
||||
ButtonX: Integer;
|
||||
CurPageIndex: Integer;
|
||||
j: Integer;
|
||||
OldActivePage: String;
|
||||
begin
|
||||
if fUpdatingNotebook then exit;
|
||||
if IsUpdating then begin
|
||||
fNoteBookNeedsUpdate:=true;
|
||||
exit;
|
||||
end;
|
||||
fNoteBookNeedsUpdate:=false;
|
||||
if FNoteBook=nil then begin
|
||||
ClearButtons;
|
||||
fNoteBookNeedsUpdate:=false;
|
||||
exit;
|
||||
end;
|
||||
fUpdatingNotebook:=true;
|
||||
OldActivePage:=FNoteBook.ActivePage;
|
||||
// remove every page in the notebook without a visible page
|
||||
for i:=FNoteBook.PageCount-1 downto 0 do begin
|
||||
PageIndex:=IndexOfPageComponent(FNoteBook.Page[i]);
|
||||
@ -124,6 +279,7 @@ begin
|
||||
if Pages[i].PageComponent=nil then begin
|
||||
// insert a new notebook page
|
||||
FNoteBook.Pages.Insert(PageIndex,Pages[i].PageName);
|
||||
Pages[i].PageComponent:=FNoteBook.Page[PageIndex];
|
||||
end else begin
|
||||
// move to the right position
|
||||
CurPageIndex:=TPage(Pages[i].PageComponent).PageIndex;
|
||||
@ -146,7 +302,7 @@ begin
|
||||
Name:='PaletteSelectBtn'+IntToStr(i);
|
||||
Parent:=CurNoteBookPage;
|
||||
OnClick := @SelectionToolClick;
|
||||
Glyph.LoadFromLazarusResource('tmouse');
|
||||
Glyph:=GetSelectButtonIcon;
|
||||
Flat := True;
|
||||
GroupIndex:= 1;
|
||||
Down := True;
|
||||
@ -154,7 +310,7 @@ begin
|
||||
SetBounds(ButtonX,0,ComponentPaletteBtnWidth,ComponentPaletteBtnHeight);
|
||||
end;
|
||||
end;
|
||||
inc(ButtonX,ComponentPaletteBtnWidth+10);
|
||||
inc(ButtonX,((ComponentPaletteBtnWidth*3) div 2)+2);
|
||||
// create component buttons
|
||||
for j:=0 to CurPage.Count-1 do begin
|
||||
CurComponent:=TPkgComponent(CurPage[j]);
|
||||
@ -183,7 +339,56 @@ begin
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
// restore active page
|
||||
if (OldActivePage<>'') and (FNoteBook.Pages.IndexOf(OldActivePage)>=0) then
|
||||
begin
|
||||
FNoteBook.ActivePage:=OldActivePage;
|
||||
end else if FNoteBook.PageCount>0 then begin
|
||||
FNoteBook.PageIndex:=0;
|
||||
end;
|
||||
// unlock
|
||||
fUpdatingNotebook:=false;
|
||||
fNoteBookNeedsUpdate:=false;
|
||||
end;
|
||||
|
||||
procedure TComponentPalette.OnGetNonVisualCompIconCanvas(Sender: TObject;
|
||||
AComponent: TComponent; var IconCanvas: TCanvas; var IconWidth,
|
||||
IconHeight: integer);
|
||||
var
|
||||
ARegComp: TRegisteredComponent;
|
||||
Icon: TBitmap;
|
||||
begin
|
||||
if AComponent<>nil then
|
||||
ARegComp:=FindComponent(AComponent.ClassName)
|
||||
else
|
||||
ARegComp:=nil;
|
||||
if ARegComp<>nil then begin
|
||||
Icon:=TPkgComponent(ARegComp).Icon;
|
||||
end else begin
|
||||
Icon:=GetUnregisteredIcon;
|
||||
end;
|
||||
IconCanvas:=Icon.Canvas;
|
||||
IconWidth:=Icon.Width;
|
||||
IconHeight:=Icon.Height;
|
||||
end;
|
||||
|
||||
function TComponentPalette.FindComponent(const CompClassName: string
|
||||
): TRegisteredComponent;
|
||||
var
|
||||
ANode: TAVLTreeNode;
|
||||
begin
|
||||
ANode:=fComponents.FindKey(Pointer(CompClassName),
|
||||
@CompareClassNameWithRegisteredComponent);
|
||||
if ANode<>nil then
|
||||
Result:=TRegisteredComponent(ANode.Data)
|
||||
else
|
||||
Result:=nil;
|
||||
end;
|
||||
|
||||
|
||||
initialization
|
||||
|
||||
{$I images/components_images.lrs}
|
||||
|
||||
end.
|
||||
|
||||
|
@ -40,7 +40,7 @@ unit IDEComp;
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF EnablePkgs}
|
||||
This unit will be deleted in future
|
||||
{$error This unit will be deleted in future}
|
||||
{$ENDIF}
|
||||
|
||||
interface
|
||||
|
@ -1636,3 +1636,17 @@ LazarusResources.Add('tupdown','XPM',[
|
||||
+'H#####a####xLfE ",'#10'" IxKxxxxxxxxxxRNSE ",'#10'" IGX1..........Cna '
|
||||
+'",'#10'" PzMwwwwwwwwwwwMiU ",'#10'" "};'
|
||||
]);
|
||||
LazarusResources.Add('unregisteredcomponent','XPM',[
|
||||
'/* XPM */'#10'static char * unregisteredcomponent_xpm[] = {'#10'"13 17 18 1"'
|
||||
+','#10'" '#9'c None",'#10'".'#9'c #00385B",'#10'"+'#9'c #000000",'#10'"@'#9
|
||||
+'c #2982C0",'#10'"#'#9'c #00528C",'#10'"$'#9'c #003E66",'#10'"%'#9'c #6BAAD2'
|
||||
+'",'#10'"&'#9'c #004572",'#10'"*'#9'c #4F97CA",'#10'"='#9'c #2A82BF",'#10'"-'
|
||||
+#9'c #418FC6",'#10'";'#9'c #00406A",'#10'">'#9'c #408FC7",'#10'",'#9'c #66A7'
|
||||
+'D1",'#10'"'''#9'c #00538E",'#10'")'#9'c #8BBBDC",'#10'"!'#9'c #005A99",'#10
|
||||
+'"~'#9'c #005896",'#10'" ......+ ",'#10'" .@#+++##++ ",'#10'"$%#+ .@#'
|
||||
+'#+ ",'#10'"&*+ .@#+ ",'#10'".=#+ $-#+ ",'#10'" .##+ ;>#+ ",'#10'" '
|
||||
+' +++ .,''+ ",'#10'" .)!+ ",'#10'" .,~+ ",'#10'" .@#+ '
|
||||
+' ",'#10'" .@#+ ",'#10'" ++ ",'#10'" ",'#10'" '
|
||||
+' .. ",'#10'" .,#+ ",'#10'" ++ ",'#10'" "}'
|
||||
+';'#10
|
||||
]);
|
||||
|
@ -422,6 +422,20 @@ begin
|
||||
Result:='';
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
function TCustomNotebook.GetActivePageComponent: TPage;
|
||||
------------------------------------------------------------------------------}
|
||||
function TCustomNotebook.GetActivePageComponent: TPage;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
i:=PageIndex;
|
||||
if (i>=0) and (i<PageCount) then
|
||||
Result:=Page[i]
|
||||
else
|
||||
Result:=nil;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
TCustomNotebook SetActivePage
|
||||
------------------------------------------------------------------------------}
|
||||
@ -439,6 +453,11 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomNotebook.SetActivePageComponent(const AValue: TPage);
|
||||
begin
|
||||
PageIndex:=fPageList.IndexOf(AValue);
|
||||
end;
|
||||
|
||||
procedure TCustomNotebook.SetImages(const AValue: TImageList);
|
||||
begin
|
||||
if FImages=AValue then exit;
|
||||
@ -732,6 +751,9 @@ end;}
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.30 2003/04/22 13:27:10 mattias
|
||||
implemented installing components in component palette
|
||||
|
||||
Revision 1.29 2002/12/16 09:17:20 mattias
|
||||
notebook pageindex can be set to -1, if interface supports it
|
||||
|
||||
|
@ -46,7 +46,6 @@ uses
|
||||
|
||||
type
|
||||
TComponentPriorityCategory = (
|
||||
cpLCL,
|
||||
cpBase,
|
||||
cpRecommended,
|
||||
cpNormal,
|
||||
@ -86,7 +85,7 @@ type
|
||||
function GetUnitName: string; virtual; abstract;
|
||||
function GetPriority: TComponentPriority; virtual;
|
||||
procedure AddToPalette; virtual;
|
||||
function Createable: boolean; virtual;
|
||||
function CanBeCreatedInDesigner: boolean; virtual;
|
||||
public
|
||||
property ComponentClass: TComponentClass read FComponentClass;
|
||||
property PageName: string read FPageName;
|
||||
@ -110,6 +109,7 @@ type
|
||||
protected
|
||||
FVisible: boolean;
|
||||
procedure SetVisible(const AValue: boolean); virtual;
|
||||
procedure OnComponentVisibleChanged(AComponent: TRegisteredComponent); virtual;
|
||||
public
|
||||
constructor Create(const ThePageName: string);
|
||||
destructor Destroy; override;
|
||||
@ -120,6 +120,7 @@ type
|
||||
procedure Add(NewComponent: TRegisteredComponent);
|
||||
procedure Remove(AComponent: TRegisteredComponent);
|
||||
function FindComponent(const CompClassName: string): TRegisteredComponent;
|
||||
function FindButton(Button: TComponent): TRegisteredComponent;
|
||||
public
|
||||
property Items[Index: integer]: TRegisteredComponent read GetItems; default;
|
||||
property PageName: string read FPageName;
|
||||
@ -145,12 +146,17 @@ type
|
||||
fChanged: boolean;
|
||||
function GetItems(Index: integer): TBaseComponentPage;
|
||||
protected
|
||||
procedure DoChange; virtual;
|
||||
procedure DoEndUpdate(Changed: boolean); virtual;
|
||||
procedure OnPageAddedComponent(Component: TRegisteredComponent); virtual;
|
||||
procedure OnPageRemovedComponent(Page: TBaseComponentPage;
|
||||
Component: TRegisteredComponent); virtual;
|
||||
procedure OnComponentVisibleChanged(AComponent: TRegisteredComponent); virtual;
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
procedure Clear;
|
||||
procedure ClearButtons;
|
||||
procedure ClearButtons; virtual;
|
||||
procedure BeginUpdate(Change: boolean);
|
||||
procedure EndUpdate;
|
||||
function IsUpdating: boolean;
|
||||
@ -162,7 +168,8 @@ type
|
||||
procedure AddComponent(NewComponent: TRegisteredComponent);
|
||||
function CreateNewPage(const NewPageName: string;
|
||||
const Priority: TComponentPriority): TBaseComponentPage;
|
||||
function FindComponent(const CompClassName: string): TRegisteredComponent;
|
||||
function FindComponent(const CompClassName: string): TRegisteredComponent; virtual;
|
||||
function FindButton(Button: TComponent): TRegisteredComponent;
|
||||
function CreateNewClassName(const Prefix: string): string;
|
||||
function IndexOfPageComponent(AComponent: TComponent): integer;
|
||||
public
|
||||
@ -220,6 +227,7 @@ procedure TRegisteredComponent.SetVisible(const AValue: boolean);
|
||||
begin
|
||||
if FVisible=AValue then exit;
|
||||
FVisible:=AValue;
|
||||
if (FPage<>nil) then FPage.OnComponentVisibleChanged(Self);
|
||||
end;
|
||||
|
||||
constructor TRegisteredComponent.Create(TheComponentClass: TComponentClass;
|
||||
@ -255,7 +263,7 @@ begin
|
||||
IDEComponentPalette.AddComponent(Self);
|
||||
end;
|
||||
|
||||
function TRegisteredComponent.Createable: boolean;
|
||||
function TRegisteredComponent.CanBeCreatedInDesigner: boolean;
|
||||
begin
|
||||
Result:=true;
|
||||
end;
|
||||
@ -273,6 +281,12 @@ begin
|
||||
FVisible:=AValue;
|
||||
end;
|
||||
|
||||
procedure TBaseComponentPage.OnComponentVisibleChanged(
|
||||
AComponent: TRegisteredComponent);
|
||||
begin
|
||||
if FPalette<>nil then FPalette.OnComponentVisibleChanged(AComponent);
|
||||
end;
|
||||
|
||||
constructor TBaseComponentPage.Create(const ThePageName: string);
|
||||
begin
|
||||
FPageName:=ThePageName;
|
||||
@ -326,16 +340,18 @@ begin
|
||||
NewPriority:=NewComponent.GetPriority;
|
||||
InsertIndex:=0;
|
||||
while (InsertIndex<Count)
|
||||
and (ComparePriority(Items[InsertIndex].GetPriority,NewPriority)>0) do
|
||||
and (ComparePriority(NewPriority,Items[InsertIndex].GetPriority)<=0) do
|
||||
inc(InsertIndex);
|
||||
FItems.Insert(InsertIndex,NewComponent);
|
||||
NewComponent.Page:=Self;
|
||||
if FPalette<>nil then FPalette.OnPageAddedComponent(NewComponent);
|
||||
end;
|
||||
|
||||
procedure TBaseComponentPage.Remove(AComponent: TRegisteredComponent);
|
||||
begin
|
||||
FItems.Remove(AComponent);
|
||||
AComponent.Page:=nil;
|
||||
if FPalette<>nil then FPalette.OnPageRemovedComponent(Self,AComponent);
|
||||
end;
|
||||
|
||||
function TBaseComponentPage.FindComponent(const CompClassName: string
|
||||
@ -351,6 +367,18 @@ begin
|
||||
Result:=nil;
|
||||
end;
|
||||
|
||||
function TBaseComponentPage.FindButton(Button: TComponent
|
||||
): TRegisteredComponent;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
for i:=0 to Count-1 do begin
|
||||
Result:=Items[i];
|
||||
if Result.Button=Button then exit;
|
||||
end;
|
||||
Result:=nil;
|
||||
end;
|
||||
|
||||
{ TBaseComponentPalette }
|
||||
|
||||
function TBaseComponentPalette.GetItems(Index: integer): TBaseComponentPage;
|
||||
@ -358,11 +386,34 @@ begin
|
||||
Result:=TBaseComponentPage(FItems[Index]);
|
||||
end;
|
||||
|
||||
procedure TBaseComponentPalette.DoChange;
|
||||
begin
|
||||
if FUpdateLock>0 then fChanged:=true;
|
||||
end;
|
||||
|
||||
procedure TBaseComponentPalette.DoEndUpdate(Changed: boolean);
|
||||
begin
|
||||
if Assigned(OnEndUpdate) then OnEndUpdate(Self,Changed);
|
||||
end;
|
||||
|
||||
procedure TBaseComponentPalette.OnPageAddedComponent(
|
||||
Component: TRegisteredComponent);
|
||||
begin
|
||||
DoChange;
|
||||
end;
|
||||
|
||||
procedure TBaseComponentPalette.OnPageRemovedComponent(
|
||||
Page: TBaseComponentPage; Component: TRegisteredComponent);
|
||||
begin
|
||||
DoChange;
|
||||
end;
|
||||
|
||||
procedure TBaseComponentPalette.OnComponentVisibleChanged(
|
||||
AComponent: TRegisteredComponent);
|
||||
begin
|
||||
DoChange;
|
||||
end;
|
||||
|
||||
constructor TBaseComponentPalette.Create;
|
||||
begin
|
||||
FItems:=TList.Create;
|
||||
@ -434,9 +485,12 @@ begin
|
||||
if i>=0 then begin
|
||||
Result:=Pages[i];
|
||||
end else begin
|
||||
if CreateIfNotExists then begin
|
||||
Result:=TBaseComponentPage.Create(APageName);
|
||||
Result.FPalette:=Self;
|
||||
FItems.Add(Result);
|
||||
end else
|
||||
Result:=nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -465,9 +519,10 @@ var
|
||||
InsertIndex: Integer;
|
||||
begin
|
||||
Result:=TBaseComponentPage.Create(NewPageName);
|
||||
Result.Priority:=Priority;
|
||||
InsertIndex:=0;
|
||||
while (InsertIndex<Count)
|
||||
and (ComparePriority(Pages[InsertIndex].Priority,Priority)>0) do
|
||||
and (ComparePriority(Priority,Pages[InsertIndex].Priority)<=0) do
|
||||
inc(InsertIndex);
|
||||
FItems.Insert(InsertIndex,Result);
|
||||
Result.FPalette:=Self;
|
||||
@ -485,6 +540,18 @@ begin
|
||||
Result:=nil;
|
||||
end;
|
||||
|
||||
function TBaseComponentPalette.FindButton(Button: TComponent
|
||||
): TRegisteredComponent;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
for i:=0 to Count-1 do begin
|
||||
Result:=Pages[i].FindButton(Button);
|
||||
if Result<>nil then exit;
|
||||
end;
|
||||
Result:=nil;
|
||||
end;
|
||||
|
||||
function TBaseComponentPalette.CreateNewClassName(const Prefix: string): string;
|
||||
var
|
||||
i: Integer;
|
||||
|
@ -78,9 +78,9 @@ type
|
||||
function GetPriority: TComponentPriority; override;
|
||||
procedure ConsistencyCheck; override;
|
||||
function Icon: TBitmap;
|
||||
function GetIconCopy: TBitMap;
|
||||
function GetIconCopy: TBitmap;
|
||||
function HasIcon: boolean;
|
||||
function Createable: boolean; override;
|
||||
function CanBeCreatedInDesigner: boolean; override;
|
||||
public
|
||||
property PkgFile: TPkgFile read FPkgFile write SetPkgFile;
|
||||
end;
|
||||
@ -2371,9 +2371,9 @@ begin
|
||||
Result:=Page.PageName<>'';
|
||||
end;
|
||||
|
||||
function TPkgComponent.Createable: boolean;
|
||||
function TPkgComponent.CanBeCreatedInDesigner: boolean;
|
||||
begin
|
||||
Result:=not PkgFile.Removed;
|
||||
Result:=(not PkgFile.Removed);
|
||||
end;
|
||||
|
||||
{ TLazPackageID }
|
||||
|
@ -824,6 +824,8 @@ begin
|
||||
end;
|
||||
|
||||
function TLazPackageGraph.CreateLCLPackage: TLazPackage;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
Result:=TLazPackage.Create;
|
||||
with Result do begin
|
||||
@ -841,19 +843,23 @@ begin
|
||||
CompilerOptions.UnitOutputDirectory:='';
|
||||
|
||||
// add registering units
|
||||
AddFile('menus.pp','Menus',pftUnit,[pffHasRegisterProc],cpLCL);
|
||||
AddFile('buttons.pp','Buttons',pftUnit,[pffHasRegisterProc],cpLCL);
|
||||
AddFile('stdctrls.pp','StdCtrls',pftUnit,[pffHasRegisterProc],cpLCL);
|
||||
AddFile('extctrls.pp','ExtCtrls',pftUnit,[pffHasRegisterProc],cpLCL);
|
||||
AddFile('comctrls.pp','ComCtrls',pftUnit,[pffHasRegisterProc],cpLCL);
|
||||
AddFile('maskedit.pp','MaskEdit',pftUnit,[pffHasRegisterProc],cpLCL);
|
||||
AddFile('forms.pp','Forms',pftUnit,[pffHasRegisterProc],cpLCL);
|
||||
AddFile('grids.pas','Grids',pftUnit,[pffHasRegisterProc],cpLCL);
|
||||
AddFile('controls.pp','Controls',pftUnit,[pffHasRegisterProc],cpLCL);
|
||||
AddFile('dialogs.pp','Dialogs',pftUnit,[pffHasRegisterProc],cpLCL);
|
||||
AddFile('spin.pp','Spin',pftUnit,[pffHasRegisterProc],cpLCL);
|
||||
AddFile('arrow.pp','Arrow',pftUnit,[pffHasRegisterProc],cpLCL);
|
||||
AddFile('calendar.pp','Calendar',pftUnit,[pffHasRegisterProc],cpLCL);
|
||||
AddFile('menus.pp','Menus',pftUnit,[pffHasRegisterProc],cpBase);
|
||||
AddFile('buttons.pp','Buttons',pftUnit,[pffHasRegisterProc],cpBase);
|
||||
AddFile('stdctrls.pp','StdCtrls',pftUnit,[pffHasRegisterProc],cpBase);
|
||||
AddFile('extctrls.pp','ExtCtrls',pftUnit,[pffHasRegisterProc],cpBase);
|
||||
AddFile('comctrls.pp','ComCtrls',pftUnit,[pffHasRegisterProc],cpBase);
|
||||
AddFile('maskedit.pp','MaskEdit',pftUnit,[pffHasRegisterProc],cpBase);
|
||||
AddFile('forms.pp','Forms',pftUnit,[pffHasRegisterProc],cpBase);
|
||||
AddFile('grids.pas','Grids',pftUnit,[pffHasRegisterProc],cpBase);
|
||||
AddFile('controls.pp','Controls',pftUnit,[pffHasRegisterProc],cpBase);
|
||||
AddFile('dialogs.pp','Dialogs',pftUnit,[pffHasRegisterProc],cpBase);
|
||||
AddFile('spin.pp','Spin',pftUnit,[pffHasRegisterProc],cpBase);
|
||||
AddFile('arrow.pp','Arrow',pftUnit,[pffHasRegisterProc],cpBase);
|
||||
AddFile('calendar.pp','Calendar',pftUnit,[pffHasRegisterProc],cpBase);
|
||||
// increase priority by one, so that the LCL components are inserted to the
|
||||
// left in the palette
|
||||
for i:=0 to FileCount-1 do
|
||||
inc(Files[i].ComponentPriority.Level);
|
||||
|
||||
// add unit paths
|
||||
UsageOptions.UnitPath:=
|
||||
|
@ -986,7 +986,10 @@ end;
|
||||
|
||||
procedure TPkgManager.UpdateVisibleComponentPalette;
|
||||
begin
|
||||
|
||||
{$IFDEF EnablePkgs}
|
||||
TComponentPalette(IDEComponentPalette).NoteBook:=MainIDE.ComponentNotebook;
|
||||
TComponentPalette(IDEComponentPalette).UpdateNoteBookButtons;
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
function TPkgManager.AddPackageToGraph(APackage: TLazPackage
|
||||
|
Loading…
Reference in New Issue
Block a user