mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-10 21:58:22 +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',
|
DirTempl.AddChild(TDefineTemplate.Create('main path addition',
|
||||||
Format(ctsAddsDirToSourcePath,[ctsLazarusMainDirectory]),
|
Format(ctsAddsDirToSourcePath,[ctsLazarusMainDirectory]),
|
||||||
ExternalMacroStart+'SrcPath',
|
ExternalMacroStart+'SrcPath',
|
||||||
'..;'+SrcPath
|
'..;..'+ds+'packager;'+SrcPath
|
||||||
,da_Define));
|
,da_Define));
|
||||||
DirTempl.AddChild(TDefineTemplate.Create('components path addition',
|
DirTempl.AddChild(TDefineTemplate.Create('components path addition',
|
||||||
Format(ctsAddsDirToSourcePath,['synedit']),
|
Format(ctsAddsDirToSourcePath,['synedit']),
|
||||||
|
@ -38,7 +38,7 @@ unit ComponentPalette;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, Dialogs, Graphics, ExtCtrls, Buttons,
|
Classes, SysUtils, Dialogs, Graphics, ExtCtrls, Buttons, LResources, AVL_Tree,
|
||||||
ComponentReg, PackageDefs, LazarusIDEStrConsts;
|
ComponentReg, PackageDefs, LazarusIDEStrConsts;
|
||||||
|
|
||||||
const
|
const
|
||||||
@ -47,38 +47,121 @@ const
|
|||||||
|
|
||||||
type
|
type
|
||||||
TComponentPalette = class(TBaseComponentPalette)
|
TComponentPalette = class(TBaseComponentPalette)
|
||||||
|
procedure ActivePageChanged(Sender: TObject);
|
||||||
private
|
private
|
||||||
FNoteBook: TNotebook;
|
FNoteBook: TNotebook;
|
||||||
fNoteBookNeedsUpdate: boolean;
|
fNoteBookNeedsUpdate: boolean;
|
||||||
|
FSelected: TRegisteredComponent;
|
||||||
|
fUpdatingNotebook: boolean;
|
||||||
|
fComponents: TAVLTree; // tree of TRegisteredComponent sorted for componentclass
|
||||||
|
fUnregisteredIcon: TBitmap;
|
||||||
procedure SetNoteBook(const AValue: TNotebook);
|
procedure SetNoteBook(const AValue: TNotebook);
|
||||||
procedure SelectionToolClick(Sender: TObject);
|
procedure SelectionToolClick(Sender: TObject);
|
||||||
procedure ComponentBtnClick(Sender: TObject);
|
procedure ComponentBtnClick(Sender: TObject);
|
||||||
|
procedure SetSelected(const AValue: TRegisteredComponent);
|
||||||
protected
|
protected
|
||||||
procedure DoEndUpdate(Changed: boolean); override;
|
procedure DoEndUpdate(Changed: boolean); override;
|
||||||
|
procedure OnPageAddedComponent(Component: TRegisteredComponent); override;
|
||||||
|
procedure OnPageRemovedComponent(Page: TBaseComponentPage;
|
||||||
|
Component: TRegisteredComponent); override;
|
||||||
public
|
public
|
||||||
|
constructor Create;
|
||||||
|
destructor Destroy; override;
|
||||||
|
function GetUnregisteredIcon: TBitmap;
|
||||||
|
function GetSelectButtonIcon: TBitmap;
|
||||||
|
procedure ClearButtons; override;
|
||||||
|
procedure SelectButton(Button: TComponent);
|
||||||
procedure UpdateNoteBookButtons;
|
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 NoteBook: TNotebook read FNoteBook write SetNoteBook;
|
||||||
|
property Selected: TRegisteredComponent read FSelected write SetSelected;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
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 }
|
{ 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);
|
procedure TComponentPalette.SetNoteBook(const AValue: TNotebook);
|
||||||
begin
|
begin
|
||||||
if FNoteBook=AValue then exit;
|
if FNoteBook=AValue then exit;
|
||||||
|
ClearButtons;
|
||||||
FNoteBook:=AValue;
|
FNoteBook:=AValue;
|
||||||
|
if FNoteBook<>nil then
|
||||||
|
FNoteBook.OnPageChanged:=@ActivePageChanged;
|
||||||
UpdateNoteBookButtons;
|
UpdateNoteBookButtons;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TComponentPalette.SelectionToolClick(Sender: TObject);
|
procedure TComponentPalette.SelectionToolClick(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
|
SelectButton(TComponent(Sender));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TComponentPalette.ComponentBtnClick(Sender: TObject);
|
procedure TComponentPalette.ComponentBtnClick(Sender: TObject);
|
||||||
begin
|
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;
|
end;
|
||||||
|
|
||||||
procedure TComponentPalette.DoEndUpdate(Changed: boolean);
|
procedure TComponentPalette.DoEndUpdate(Changed: boolean);
|
||||||
@ -87,6 +170,75 @@ begin
|
|||||||
inherited DoEndUpdate(Changed);
|
inherited DoEndUpdate(Changed);
|
||||||
end;
|
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;
|
procedure TComponentPalette.UpdateNoteBookButtons;
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
@ -98,16 +250,19 @@ var
|
|||||||
ButtonX: Integer;
|
ButtonX: Integer;
|
||||||
CurPageIndex: Integer;
|
CurPageIndex: Integer;
|
||||||
j: Integer;
|
j: Integer;
|
||||||
|
OldActivePage: String;
|
||||||
begin
|
begin
|
||||||
|
if fUpdatingNotebook then exit;
|
||||||
if IsUpdating then begin
|
if IsUpdating then begin
|
||||||
fNoteBookNeedsUpdate:=true;
|
fNoteBookNeedsUpdate:=true;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
fNoteBookNeedsUpdate:=false;
|
|
||||||
if FNoteBook=nil then begin
|
if FNoteBook=nil then begin
|
||||||
ClearButtons;
|
fNoteBookNeedsUpdate:=false;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
fUpdatingNotebook:=true;
|
||||||
|
OldActivePage:=FNoteBook.ActivePage;
|
||||||
// remove every page in the notebook without a visible page
|
// remove every page in the notebook without a visible page
|
||||||
for i:=FNoteBook.PageCount-1 downto 0 do begin
|
for i:=FNoteBook.PageCount-1 downto 0 do begin
|
||||||
PageIndex:=IndexOfPageComponent(FNoteBook.Page[i]);
|
PageIndex:=IndexOfPageComponent(FNoteBook.Page[i]);
|
||||||
@ -124,6 +279,7 @@ begin
|
|||||||
if Pages[i].PageComponent=nil then begin
|
if Pages[i].PageComponent=nil then begin
|
||||||
// insert a new notebook page
|
// insert a new notebook page
|
||||||
FNoteBook.Pages.Insert(PageIndex,Pages[i].PageName);
|
FNoteBook.Pages.Insert(PageIndex,Pages[i].PageName);
|
||||||
|
Pages[i].PageComponent:=FNoteBook.Page[PageIndex];
|
||||||
end else begin
|
end else begin
|
||||||
// move to the right position
|
// move to the right position
|
||||||
CurPageIndex:=TPage(Pages[i].PageComponent).PageIndex;
|
CurPageIndex:=TPage(Pages[i].PageComponent).PageIndex;
|
||||||
@ -146,7 +302,7 @@ begin
|
|||||||
Name:='PaletteSelectBtn'+IntToStr(i);
|
Name:='PaletteSelectBtn'+IntToStr(i);
|
||||||
Parent:=CurNoteBookPage;
|
Parent:=CurNoteBookPage;
|
||||||
OnClick := @SelectionToolClick;
|
OnClick := @SelectionToolClick;
|
||||||
Glyph.LoadFromLazarusResource('tmouse');
|
Glyph:=GetSelectButtonIcon;
|
||||||
Flat := True;
|
Flat := True;
|
||||||
GroupIndex:= 1;
|
GroupIndex:= 1;
|
||||||
Down := True;
|
Down := True;
|
||||||
@ -154,7 +310,7 @@ begin
|
|||||||
SetBounds(ButtonX,0,ComponentPaletteBtnWidth,ComponentPaletteBtnHeight);
|
SetBounds(ButtonX,0,ComponentPaletteBtnWidth,ComponentPaletteBtnHeight);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
inc(ButtonX,ComponentPaletteBtnWidth+10);
|
inc(ButtonX,((ComponentPaletteBtnWidth*3) div 2)+2);
|
||||||
// create component buttons
|
// create component buttons
|
||||||
for j:=0 to CurPage.Count-1 do begin
|
for j:=0 to CurPage.Count-1 do begin
|
||||||
CurComponent:=TPkgComponent(CurPage[j]);
|
CurComponent:=TPkgComponent(CurPage[j]);
|
||||||
@ -183,7 +339,56 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
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;
|
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.
|
end.
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ unit IDEComp;
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
{$IFDEF EnablePkgs}
|
{$IFDEF EnablePkgs}
|
||||||
This unit will be deleted in future
|
{$error This unit will be deleted in future}
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
interface
|
interface
|
||||||
|
@ -1636,3 +1636,17 @@ LazarusResources.Add('tupdown','XPM',[
|
|||||||
+'H#####a####xLfE ",'#10'" IxKxxxxxxxxxxRNSE ",'#10'" IGX1..........Cna '
|
+'H#####a####xLfE ",'#10'" IxKxxxxxxxxxxRNSE ",'#10'" IGX1..........Cna '
|
||||||
+'",'#10'" PzMwwwwwwwwwwwMiU ",'#10'" "};'
|
+'",'#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:='';
|
Result:='';
|
||||||
end;
|
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
|
TCustomNotebook SetActivePage
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
@ -439,6 +453,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomNotebook.SetActivePageComponent(const AValue: TPage);
|
||||||
|
begin
|
||||||
|
PageIndex:=fPageList.IndexOf(AValue);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCustomNotebook.SetImages(const AValue: TImageList);
|
procedure TCustomNotebook.SetImages(const AValue: TImageList);
|
||||||
begin
|
begin
|
||||||
if FImages=AValue then exit;
|
if FImages=AValue then exit;
|
||||||
@ -732,6 +751,9 @@ end;}
|
|||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
|
|
||||||
$Log$
|
$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
|
Revision 1.29 2002/12/16 09:17:20 mattias
|
||||||
notebook pageindex can be set to -1, if interface supports it
|
notebook pageindex can be set to -1, if interface supports it
|
||||||
|
|
||||||
|
@ -46,7 +46,6 @@ uses
|
|||||||
|
|
||||||
type
|
type
|
||||||
TComponentPriorityCategory = (
|
TComponentPriorityCategory = (
|
||||||
cpLCL,
|
|
||||||
cpBase,
|
cpBase,
|
||||||
cpRecommended,
|
cpRecommended,
|
||||||
cpNormal,
|
cpNormal,
|
||||||
@ -86,7 +85,7 @@ type
|
|||||||
function GetUnitName: string; virtual; abstract;
|
function GetUnitName: string; virtual; abstract;
|
||||||
function GetPriority: TComponentPriority; virtual;
|
function GetPriority: TComponentPriority; virtual;
|
||||||
procedure AddToPalette; virtual;
|
procedure AddToPalette; virtual;
|
||||||
function Createable: boolean; virtual;
|
function CanBeCreatedInDesigner: boolean; virtual;
|
||||||
public
|
public
|
||||||
property ComponentClass: TComponentClass read FComponentClass;
|
property ComponentClass: TComponentClass read FComponentClass;
|
||||||
property PageName: string read FPageName;
|
property PageName: string read FPageName;
|
||||||
@ -110,6 +109,7 @@ type
|
|||||||
protected
|
protected
|
||||||
FVisible: boolean;
|
FVisible: boolean;
|
||||||
procedure SetVisible(const AValue: boolean); virtual;
|
procedure SetVisible(const AValue: boolean); virtual;
|
||||||
|
procedure OnComponentVisibleChanged(AComponent: TRegisteredComponent); virtual;
|
||||||
public
|
public
|
||||||
constructor Create(const ThePageName: string);
|
constructor Create(const ThePageName: string);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
@ -120,6 +120,7 @@ type
|
|||||||
procedure Add(NewComponent: TRegisteredComponent);
|
procedure Add(NewComponent: TRegisteredComponent);
|
||||||
procedure Remove(AComponent: TRegisteredComponent);
|
procedure Remove(AComponent: TRegisteredComponent);
|
||||||
function FindComponent(const CompClassName: string): TRegisteredComponent;
|
function FindComponent(const CompClassName: string): TRegisteredComponent;
|
||||||
|
function FindButton(Button: TComponent): TRegisteredComponent;
|
||||||
public
|
public
|
||||||
property Items[Index: integer]: TRegisteredComponent read GetItems; default;
|
property Items[Index: integer]: TRegisteredComponent read GetItems; default;
|
||||||
property PageName: string read FPageName;
|
property PageName: string read FPageName;
|
||||||
@ -145,12 +146,17 @@ type
|
|||||||
fChanged: boolean;
|
fChanged: boolean;
|
||||||
function GetItems(Index: integer): TBaseComponentPage;
|
function GetItems(Index: integer): TBaseComponentPage;
|
||||||
protected
|
protected
|
||||||
|
procedure DoChange; virtual;
|
||||||
procedure DoEndUpdate(Changed: boolean); virtual;
|
procedure DoEndUpdate(Changed: boolean); virtual;
|
||||||
|
procedure OnPageAddedComponent(Component: TRegisteredComponent); virtual;
|
||||||
|
procedure OnPageRemovedComponent(Page: TBaseComponentPage;
|
||||||
|
Component: TRegisteredComponent); virtual;
|
||||||
|
procedure OnComponentVisibleChanged(AComponent: TRegisteredComponent); virtual;
|
||||||
public
|
public
|
||||||
constructor Create;
|
constructor Create;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
procedure Clear;
|
procedure Clear;
|
||||||
procedure ClearButtons;
|
procedure ClearButtons; virtual;
|
||||||
procedure BeginUpdate(Change: boolean);
|
procedure BeginUpdate(Change: boolean);
|
||||||
procedure EndUpdate;
|
procedure EndUpdate;
|
||||||
function IsUpdating: boolean;
|
function IsUpdating: boolean;
|
||||||
@ -162,7 +168,8 @@ type
|
|||||||
procedure AddComponent(NewComponent: TRegisteredComponent);
|
procedure AddComponent(NewComponent: TRegisteredComponent);
|
||||||
function CreateNewPage(const NewPageName: string;
|
function CreateNewPage(const NewPageName: string;
|
||||||
const Priority: TComponentPriority): TBaseComponentPage;
|
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 CreateNewClassName(const Prefix: string): string;
|
||||||
function IndexOfPageComponent(AComponent: TComponent): integer;
|
function IndexOfPageComponent(AComponent: TComponent): integer;
|
||||||
public
|
public
|
||||||
@ -220,6 +227,7 @@ procedure TRegisteredComponent.SetVisible(const AValue: boolean);
|
|||||||
begin
|
begin
|
||||||
if FVisible=AValue then exit;
|
if FVisible=AValue then exit;
|
||||||
FVisible:=AValue;
|
FVisible:=AValue;
|
||||||
|
if (FPage<>nil) then FPage.OnComponentVisibleChanged(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TRegisteredComponent.Create(TheComponentClass: TComponentClass;
|
constructor TRegisteredComponent.Create(TheComponentClass: TComponentClass;
|
||||||
@ -255,7 +263,7 @@ begin
|
|||||||
IDEComponentPalette.AddComponent(Self);
|
IDEComponentPalette.AddComponent(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TRegisteredComponent.Createable: boolean;
|
function TRegisteredComponent.CanBeCreatedInDesigner: boolean;
|
||||||
begin
|
begin
|
||||||
Result:=true;
|
Result:=true;
|
||||||
end;
|
end;
|
||||||
@ -273,6 +281,12 @@ begin
|
|||||||
FVisible:=AValue;
|
FVisible:=AValue;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TBaseComponentPage.OnComponentVisibleChanged(
|
||||||
|
AComponent: TRegisteredComponent);
|
||||||
|
begin
|
||||||
|
if FPalette<>nil then FPalette.OnComponentVisibleChanged(AComponent);
|
||||||
|
end;
|
||||||
|
|
||||||
constructor TBaseComponentPage.Create(const ThePageName: string);
|
constructor TBaseComponentPage.Create(const ThePageName: string);
|
||||||
begin
|
begin
|
||||||
FPageName:=ThePageName;
|
FPageName:=ThePageName;
|
||||||
@ -326,16 +340,18 @@ begin
|
|||||||
NewPriority:=NewComponent.GetPriority;
|
NewPriority:=NewComponent.GetPriority;
|
||||||
InsertIndex:=0;
|
InsertIndex:=0;
|
||||||
while (InsertIndex<Count)
|
while (InsertIndex<Count)
|
||||||
and (ComparePriority(Items[InsertIndex].GetPriority,NewPriority)>0) do
|
and (ComparePriority(NewPriority,Items[InsertIndex].GetPriority)<=0) do
|
||||||
inc(InsertIndex);
|
inc(InsertIndex);
|
||||||
FItems.Insert(InsertIndex,NewComponent);
|
FItems.Insert(InsertIndex,NewComponent);
|
||||||
NewComponent.Page:=Self;
|
NewComponent.Page:=Self;
|
||||||
|
if FPalette<>nil then FPalette.OnPageAddedComponent(NewComponent);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TBaseComponentPage.Remove(AComponent: TRegisteredComponent);
|
procedure TBaseComponentPage.Remove(AComponent: TRegisteredComponent);
|
||||||
begin
|
begin
|
||||||
FItems.Remove(AComponent);
|
FItems.Remove(AComponent);
|
||||||
AComponent.Page:=nil;
|
AComponent.Page:=nil;
|
||||||
|
if FPalette<>nil then FPalette.OnPageRemovedComponent(Self,AComponent);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TBaseComponentPage.FindComponent(const CompClassName: string
|
function TBaseComponentPage.FindComponent(const CompClassName: string
|
||||||
@ -351,6 +367,18 @@ begin
|
|||||||
Result:=nil;
|
Result:=nil;
|
||||||
end;
|
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 }
|
{ TBaseComponentPalette }
|
||||||
|
|
||||||
function TBaseComponentPalette.GetItems(Index: integer): TBaseComponentPage;
|
function TBaseComponentPalette.GetItems(Index: integer): TBaseComponentPage;
|
||||||
@ -358,11 +386,34 @@ begin
|
|||||||
Result:=TBaseComponentPage(FItems[Index]);
|
Result:=TBaseComponentPage(FItems[Index]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TBaseComponentPalette.DoChange;
|
||||||
|
begin
|
||||||
|
if FUpdateLock>0 then fChanged:=true;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TBaseComponentPalette.DoEndUpdate(Changed: boolean);
|
procedure TBaseComponentPalette.DoEndUpdate(Changed: boolean);
|
||||||
begin
|
begin
|
||||||
if Assigned(OnEndUpdate) then OnEndUpdate(Self,Changed);
|
if Assigned(OnEndUpdate) then OnEndUpdate(Self,Changed);
|
||||||
end;
|
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;
|
constructor TBaseComponentPalette.Create;
|
||||||
begin
|
begin
|
||||||
FItems:=TList.Create;
|
FItems:=TList.Create;
|
||||||
@ -434,9 +485,12 @@ begin
|
|||||||
if i>=0 then begin
|
if i>=0 then begin
|
||||||
Result:=Pages[i];
|
Result:=Pages[i];
|
||||||
end else begin
|
end else begin
|
||||||
|
if CreateIfNotExists then begin
|
||||||
Result:=TBaseComponentPage.Create(APageName);
|
Result:=TBaseComponentPage.Create(APageName);
|
||||||
Result.FPalette:=Self;
|
Result.FPalette:=Self;
|
||||||
FItems.Add(Result);
|
FItems.Add(Result);
|
||||||
|
end else
|
||||||
|
Result:=nil;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -465,9 +519,10 @@ var
|
|||||||
InsertIndex: Integer;
|
InsertIndex: Integer;
|
||||||
begin
|
begin
|
||||||
Result:=TBaseComponentPage.Create(NewPageName);
|
Result:=TBaseComponentPage.Create(NewPageName);
|
||||||
|
Result.Priority:=Priority;
|
||||||
InsertIndex:=0;
|
InsertIndex:=0;
|
||||||
while (InsertIndex<Count)
|
while (InsertIndex<Count)
|
||||||
and (ComparePriority(Pages[InsertIndex].Priority,Priority)>0) do
|
and (ComparePriority(Priority,Pages[InsertIndex].Priority)<=0) do
|
||||||
inc(InsertIndex);
|
inc(InsertIndex);
|
||||||
FItems.Insert(InsertIndex,Result);
|
FItems.Insert(InsertIndex,Result);
|
||||||
Result.FPalette:=Self;
|
Result.FPalette:=Self;
|
||||||
@ -485,6 +540,18 @@ begin
|
|||||||
Result:=nil;
|
Result:=nil;
|
||||||
end;
|
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;
|
function TBaseComponentPalette.CreateNewClassName(const Prefix: string): string;
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
|
@ -78,9 +78,9 @@ type
|
|||||||
function GetPriority: TComponentPriority; override;
|
function GetPriority: TComponentPriority; override;
|
||||||
procedure ConsistencyCheck; override;
|
procedure ConsistencyCheck; override;
|
||||||
function Icon: TBitmap;
|
function Icon: TBitmap;
|
||||||
function GetIconCopy: TBitMap;
|
function GetIconCopy: TBitmap;
|
||||||
function HasIcon: boolean;
|
function HasIcon: boolean;
|
||||||
function Createable: boolean; override;
|
function CanBeCreatedInDesigner: boolean; override;
|
||||||
public
|
public
|
||||||
property PkgFile: TPkgFile read FPkgFile write SetPkgFile;
|
property PkgFile: TPkgFile read FPkgFile write SetPkgFile;
|
||||||
end;
|
end;
|
||||||
@ -2371,9 +2371,9 @@ begin
|
|||||||
Result:=Page.PageName<>'';
|
Result:=Page.PageName<>'';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TPkgComponent.Createable: boolean;
|
function TPkgComponent.CanBeCreatedInDesigner: boolean;
|
||||||
begin
|
begin
|
||||||
Result:=not PkgFile.Removed;
|
Result:=(not PkgFile.Removed);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TLazPackageID }
|
{ TLazPackageID }
|
||||||
|
@ -824,6 +824,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TLazPackageGraph.CreateLCLPackage: TLazPackage;
|
function TLazPackageGraph.CreateLCLPackage: TLazPackage;
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
Result:=TLazPackage.Create;
|
Result:=TLazPackage.Create;
|
||||||
with Result do begin
|
with Result do begin
|
||||||
@ -841,19 +843,23 @@ begin
|
|||||||
CompilerOptions.UnitOutputDirectory:='';
|
CompilerOptions.UnitOutputDirectory:='';
|
||||||
|
|
||||||
// add registering units
|
// add registering units
|
||||||
AddFile('menus.pp','Menus',pftUnit,[pffHasRegisterProc],cpLCL);
|
AddFile('menus.pp','Menus',pftUnit,[pffHasRegisterProc],cpBase);
|
||||||
AddFile('buttons.pp','Buttons',pftUnit,[pffHasRegisterProc],cpLCL);
|
AddFile('buttons.pp','Buttons',pftUnit,[pffHasRegisterProc],cpBase);
|
||||||
AddFile('stdctrls.pp','StdCtrls',pftUnit,[pffHasRegisterProc],cpLCL);
|
AddFile('stdctrls.pp','StdCtrls',pftUnit,[pffHasRegisterProc],cpBase);
|
||||||
AddFile('extctrls.pp','ExtCtrls',pftUnit,[pffHasRegisterProc],cpLCL);
|
AddFile('extctrls.pp','ExtCtrls',pftUnit,[pffHasRegisterProc],cpBase);
|
||||||
AddFile('comctrls.pp','ComCtrls',pftUnit,[pffHasRegisterProc],cpLCL);
|
AddFile('comctrls.pp','ComCtrls',pftUnit,[pffHasRegisterProc],cpBase);
|
||||||
AddFile('maskedit.pp','MaskEdit',pftUnit,[pffHasRegisterProc],cpLCL);
|
AddFile('maskedit.pp','MaskEdit',pftUnit,[pffHasRegisterProc],cpBase);
|
||||||
AddFile('forms.pp','Forms',pftUnit,[pffHasRegisterProc],cpLCL);
|
AddFile('forms.pp','Forms',pftUnit,[pffHasRegisterProc],cpBase);
|
||||||
AddFile('grids.pas','Grids',pftUnit,[pffHasRegisterProc],cpLCL);
|
AddFile('grids.pas','Grids',pftUnit,[pffHasRegisterProc],cpBase);
|
||||||
AddFile('controls.pp','Controls',pftUnit,[pffHasRegisterProc],cpLCL);
|
AddFile('controls.pp','Controls',pftUnit,[pffHasRegisterProc],cpBase);
|
||||||
AddFile('dialogs.pp','Dialogs',pftUnit,[pffHasRegisterProc],cpLCL);
|
AddFile('dialogs.pp','Dialogs',pftUnit,[pffHasRegisterProc],cpBase);
|
||||||
AddFile('spin.pp','Spin',pftUnit,[pffHasRegisterProc],cpLCL);
|
AddFile('spin.pp','Spin',pftUnit,[pffHasRegisterProc],cpBase);
|
||||||
AddFile('arrow.pp','Arrow',pftUnit,[pffHasRegisterProc],cpLCL);
|
AddFile('arrow.pp','Arrow',pftUnit,[pffHasRegisterProc],cpBase);
|
||||||
AddFile('calendar.pp','Calendar',pftUnit,[pffHasRegisterProc],cpLCL);
|
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
|
// add unit paths
|
||||||
UsageOptions.UnitPath:=
|
UsageOptions.UnitPath:=
|
||||||
|
@ -986,7 +986,10 @@ end;
|
|||||||
|
|
||||||
procedure TPkgManager.UpdateVisibleComponentPalette;
|
procedure TPkgManager.UpdateVisibleComponentPalette;
|
||||||
begin
|
begin
|
||||||
|
{$IFDEF EnablePkgs}
|
||||||
|
TComponentPalette(IDEComponentPalette).NoteBook:=MainIDE.ComponentNotebook;
|
||||||
|
TComponentPalette(IDEComponentPalette).UpdateNoteBookButtons;
|
||||||
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TPkgManager.AddPackageToGraph(APackage: TLazPackage
|
function TPkgManager.AddPackageToGraph(APackage: TLazPackage
|
||||||
|
Loading…
Reference in New Issue
Block a user