mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-11 10:20:53 +01:00
MG: added custom components trick
git-svn-id: trunk@3620 -
This commit is contained in:
parent
193e9e1936
commit
9d7444f027
18
Makefile
18
Makefile
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Don't edit, this file is generated by FPCMake Version 1.1 [2002/09/20]
|
||||
# Don't edit, this file is generated by FPCMake Version 1.1 [2002/11/05]
|
||||
#
|
||||
default: all
|
||||
MAKEFILETARGETS=linux go32v2 win32 os2 freebsd beos netbsd amiga atari sunos qnx netware openbsd wdosx
|
||||
@ -58,6 +58,9 @@ ifdef inUnix
|
||||
PATHSEP=/
|
||||
else
|
||||
PATHSEP:=$(subst /,\,/)
|
||||
ifneq ($(findstring sh.exe,$(SHELL)),)
|
||||
PATHSEP=/
|
||||
endif
|
||||
endif
|
||||
ifdef PWD
|
||||
BASEDIR:=$(subst \,/,$(shell $(PWD)))
|
||||
@ -139,6 +142,16 @@ ifndef OS_TARGET
|
||||
OS_TARGET:=$(shell $(FPC) -iTO)
|
||||
endif
|
||||
endif
|
||||
ifndef CPU_TARGET
|
||||
ifdef CPU_TARGET_DEFAULT
|
||||
CPU_TARGET=$(CPU_TARGET_DEFAULT)
|
||||
endif
|
||||
endif
|
||||
ifndef OS_TARGET
|
||||
ifdef OS_TARGET_DEFAULT
|
||||
OS_TARGET=$(OS_TARGET_DEFAULT)
|
||||
endif
|
||||
endif
|
||||
FULL_TARGET=$(CPU_TARGET)-$(OS_TARGET)
|
||||
FULL_SOURCE=$(CPU_SOURCE)-$(OS_SOURCE)
|
||||
ifneq ($(FULL_TARGET),$(FULL_SOURCE))
|
||||
@ -217,7 +230,7 @@ override INSTALL_BASEDIR=lib/lazarus
|
||||
override DIST_DESTDIR=$(BASEDIR)/dist
|
||||
override COMPILER_OPTIONS+=-gl
|
||||
override COMPILER_INCLUDEDIR+=include include/$(OS_TARGET)
|
||||
override COMPILER_UNITDIR+=lcl/units lcl/units/$(LCL_PLATFORM) designer designer/units debugger components/units .
|
||||
override COMPILER_UNITDIR+=components/custom lcl/units lcl/units/$(LCL_PLATFORM) designer designer/units debugger components/units .
|
||||
override COMPILER_TARGETDIR+=.
|
||||
ifdef REQUIRE_UNITSDIR
|
||||
override UNITSDIR+=$(REQUIRE_UNITSDIR)
|
||||
@ -1476,6 +1489,7 @@ fpc_baseinfo:
|
||||
@$(ECHO) Rm........ $(RMPROG)
|
||||
@$(ECHO) GInstall.. $(GINSTALL)
|
||||
@$(ECHO) Echo...... $(ECHO)
|
||||
@$(ECHO) Shell..... $(SHELL)
|
||||
@$(ECHO) Date...... $(DATE)
|
||||
@$(ECHO) FPCMake... $(FPCMAKE)
|
||||
@$(ECHO) PPUMove... $(PPUMOVE)
|
||||
|
||||
@ -16,7 +16,8 @@ exampledirs=examples
|
||||
|
||||
[compiler]
|
||||
options=-gl
|
||||
unitdir=lcl/units lcl/units/$(LCL_PLATFORM) designer designer/units debugger \
|
||||
unitdir=components/custom \
|
||||
lcl/units lcl/units/$(LCL_PLATFORM) designer designer/units debugger \
|
||||
components/units .
|
||||
includedir=include include/$(OS_TARGET)
|
||||
targetdir=.
|
||||
@ -75,3 +76,5 @@ ifeq ($(OS_TARGET), win32)
|
||||
endif
|
||||
|
||||
clean: cleanall cleanide
|
||||
# end.
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Don't edit, this file is generated by FPCMake Version 1.1 [2002/09/20]
|
||||
# Don't edit, this file is generated by FPCMake Version 1.1 [2002/11/05]
|
||||
#
|
||||
default: all
|
||||
MAKEFILETARGETS=linux go32v2 win32 os2 freebsd beos netbsd amiga atari sunos qnx netware openbsd wdosx
|
||||
@ -58,6 +58,9 @@ ifdef inUnix
|
||||
PATHSEP=/
|
||||
else
|
||||
PATHSEP:=$(subst /,\,/)
|
||||
ifneq ($(findstring sh.exe,$(SHELL)),)
|
||||
PATHSEP=/
|
||||
endif
|
||||
endif
|
||||
ifdef PWD
|
||||
BASEDIR:=$(subst \,/,$(shell $(PWD)))
|
||||
@ -139,6 +142,16 @@ ifndef OS_TARGET
|
||||
OS_TARGET:=$(shell $(FPC) -iTO)
|
||||
endif
|
||||
endif
|
||||
ifndef CPU_TARGET
|
||||
ifdef CPU_TARGET_DEFAULT
|
||||
CPU_TARGET=$(CPU_TARGET_DEFAULT)
|
||||
endif
|
||||
endif
|
||||
ifndef OS_TARGET
|
||||
ifdef OS_TARGET_DEFAULT
|
||||
OS_TARGET=$(OS_TARGET_DEFAULT)
|
||||
endif
|
||||
endif
|
||||
FULL_TARGET=$(CPU_TARGET)-$(OS_TARGET)
|
||||
FULL_SOURCE=$(CPU_SOURCE)-$(OS_SOURCE)
|
||||
ifneq ($(FULL_TARGET),$(FULL_SOURCE))
|
||||
@ -199,7 +212,7 @@ UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
|
||||
endif
|
||||
PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages/base $(FPCDIR)/packages/extra)
|
||||
override TARGET_DIRS+=synedit codetools
|
||||
override CLEAN_FILES+=$(wildcard ./units/*$(OEXT)) $(wildcard ./units/*$(PPUEXT)) $(wildcard ./units/*$(RSTEXT))
|
||||
override CLEAN_FILES+=$(wildcard ./units/*$(OEXT)) $(wildcard ./units/*$(PPUEXT)) $(wildcard ./units/*$(RSTEXT)) $(wildcard ./custom/*$(OEXT)) $(wildcard ./custom/*$(PPUEXT)) $(wildcard ./custom/*$(RSTEXT))
|
||||
ifdef REQUIRE_UNITSDIR
|
||||
override UNITSDIR+=$(REQUIRE_UNITSDIR)
|
||||
endif
|
||||
@ -956,6 +969,7 @@ fpc_baseinfo:
|
||||
@$(ECHO) Rm........ $(RMPROG)
|
||||
@$(ECHO) GInstall.. $(GINSTALL)
|
||||
@$(ECHO) Echo...... $(ECHO)
|
||||
@$(ECHO) Shell..... $(SHELL)
|
||||
@$(ECHO) Date...... $(DATE)
|
||||
@$(ECHO) FPCMake... $(FPCMAKE)
|
||||
@$(ECHO) PPUMove... $(PPUMOVE)
|
||||
|
||||
@ -7,7 +7,12 @@
|
||||
dirs=synedit codetools
|
||||
|
||||
[clean]
|
||||
files=$(wildcard ./units/*$(OEXT)) $(wildcard ./units/*$(PPUEXT)) $(wildcard ./units/*$(RSTEXT))
|
||||
files=$(wildcard ./units/*$(OEXT)) \
|
||||
$(wildcard ./units/*$(PPUEXT)) \
|
||||
$(wildcard ./units/*$(RSTEXT)) \
|
||||
$(wildcard ./custom/*$(OEXT)) \
|
||||
$(wildcard ./custom/*$(PPUEXT)) \
|
||||
$(wildcard ./custom/*$(RSTEXT))
|
||||
|
||||
[rules]
|
||||
|
||||
|
||||
@ -170,6 +170,7 @@ ResourceString
|
||||
ctsAbstractWidgetPath = 'abstract widget path';
|
||||
ctsWidgetDirectory = 'Widget Directory';
|
||||
ctsComponentsDirectory = 'Components Directory';
|
||||
ctsCustomComponentsDirectory = 'Custom Components Directory';
|
||||
ctsToolsDirectory = 'Tools Directory';
|
||||
ctsDesignerDirectory = 'Designer Directory';
|
||||
ctsLazarusMainDirectory = 'lazarus main directory';
|
||||
|
||||
@ -2293,13 +2293,14 @@ begin
|
||||
,da_Define));
|
||||
MainDir.AddChild(TDefineTemplate.Create(
|
||||
'Component path addition',
|
||||
Format(ctsAddsDirToSourcePath,['designer, jitform, debugger, synedit, codetools']),
|
||||
Format(ctsAddsDirToSourcePath,['designer, debugger, components']),
|
||||
ExternalMacroStart+'SrcPath',
|
||||
'designer;'
|
||||
+'designer'+ds+'jitform;'
|
||||
+'debugger;'
|
||||
+'components'+ds+'synedit;'
|
||||
+'components'+ds+'codetools;'
|
||||
+'components'+ds+'custom;'
|
||||
+SrcPath
|
||||
,da_Define));
|
||||
MainDir.AddChild(TDefineTemplate.Create('includepath addition',
|
||||
@ -2341,6 +2342,7 @@ begin
|
||||
LazarusSrcDir+ds+'lcl;'+SrcPath,da_DefineRecurse));
|
||||
DirTempl.AddChild(SubDirTempl);
|
||||
|
||||
|
||||
// components
|
||||
DirTempl:=TDefineTemplate.Create('Components',ctsComponentsDirectory,
|
||||
'','components',da_Directory);
|
||||
@ -2352,6 +2354,19 @@ begin
|
||||
+';'+SrcPath
|
||||
,da_DefineRecurse));
|
||||
MainDir.AddChild(DirTempl);
|
||||
|
||||
// components/custom
|
||||
SubDirTempl:=TDefineTemplate.Create('Custom Components',
|
||||
ctsCustomComponentsDirectory,
|
||||
'','custom',da_Directory);
|
||||
SubDirTempl.AddChild(TDefineTemplate.Create('lazarus standard components',
|
||||
Format(ctsAddsDirToSourcePath,['synedit']),
|
||||
ExternalMacroStart+'SrcPath',
|
||||
'..'+ds+'synedit'
|
||||
+';'+SrcPath
|
||||
,da_DefineRecurse));
|
||||
DirTempl.AddChild(SubDirTempl);
|
||||
|
||||
|
||||
// tools
|
||||
DirTempl:=TDefineTemplate.Create('Tools',
|
||||
@ -2364,6 +2379,7 @@ begin
|
||||
,da_Define));
|
||||
MainDir.AddChild(DirTempl);
|
||||
|
||||
|
||||
// include
|
||||
|
||||
// designer
|
||||
@ -2384,7 +2400,9 @@ begin
|
||||
DirTempl.AddChild(TDefineTemplate.Create('components path addition',
|
||||
Format(ctsAddsDirToSourcePath,['synedit']),
|
||||
ExternalMacroStart+'SrcPath',
|
||||
'..'+ds+'components'+ds+'synedit;'+'..'+ds+'components'+ds+'codetools;'
|
||||
'..'+ds+'components'+ds+'synedit;'
|
||||
+'..'+ds+'components'+ds+'codetools;'
|
||||
+'..'+ds+'components'+ds+'custom;'
|
||||
+'jitform;'
|
||||
+SrcPath
|
||||
,da_Define));
|
||||
|
||||
@ -3685,7 +3685,7 @@ var
|
||||
end;
|
||||
if (ExprType.Context.Node=nil) then begin
|
||||
MoveCursorToCleanPos(CurAtom.StartPos);
|
||||
RaiseExceptionFmt(ctsStrExpectedButAtomFound,[ctsIllegalQualifier,'.']);
|
||||
RaiseIllegalQualifierFound;
|
||||
end;
|
||||
if (ExprType.Context.Node.Desc in AllUsableSourceTypes) then begin
|
||||
// identifier in front of the point is a unit name
|
||||
|
||||
5
components/custom/README
Normal file
5
components/custom/README
Normal file
@ -0,0 +1,5 @@
|
||||
How to add extra components to the lazarus IDE
|
||||
==============================================
|
||||
|
||||
Use the customidecomps.pas.template file and read the instructions carefully.
|
||||
|
||||
73
components/custom/customidecomps.pas.template
Normal file
73
components/custom/customidecomps.pas.template
Normal file
@ -0,0 +1,73 @@
|
||||
{
|
||||
***************************************************************************
|
||||
* *
|
||||
* This source is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This code is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* General Public License for more details. *
|
||||
* *
|
||||
* A copy of the GNU General Public License is available on the World *
|
||||
* Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
|
||||
* obtain it by writing to the Free Software Foundation, *
|
||||
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
Author: Mattias Gaertner
|
||||
|
||||
|
||||
Use this unit to add components to the lazarus IDE.
|
||||
|
||||
For example:
|
||||
To add TCheckBook from checkbook.pas to the IDE do the following:
|
||||
1. If not already done, copy or rename this file to
|
||||
components/custom/customidecomps.pas.
|
||||
2. Copy checkbook.pas into the same directory.
|
||||
3. Add checkbook to the uses section of the customidecomps.pas (*1).
|
||||
4. Add the line following line to RegisterCustomComponents (*2):
|
||||
RegisterComponents('Extra','CheckBook',[TCheckBook]);
|
||||
5. Add -dUseIDEComps to Tools-> Configure "Build Lazarus" -> Options.
|
||||
This flag will tell the compiler to use customidecomps.pas.
|
||||
6. Rebuild lazarus.
|
||||
}
|
||||
unit CustomIDEComps;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes
|
||||
{ *1 Add your units here }
|
||||
;
|
||||
|
||||
|
||||
type
|
||||
TRegisterComponentProc = procedure(const Page, UnitName:ShortString;
|
||||
ComponentClass: TComponentClass);
|
||||
|
||||
// this procedure is called by the IDE on startup
|
||||
procedure RegisterCustomComponents(RegisterComponent: TRegisterComponentProc);
|
||||
|
||||
implementation
|
||||
|
||||
procedure RegisterCustomComponents(RegisterComponent: TRegisterComponentProc);
|
||||
begin
|
||||
{ *2 Add your component registrations here }
|
||||
|
||||
{ Example:
|
||||
|
||||
RegisterComponent('PageName','UnitName',TCustomComp1);
|
||||
RegisterComponent('Extra','CheckBook',TCheckBook);
|
||||
|
||||
For further examples see idecomp.pp -> RegisterStandardComponents
|
||||
}
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
@ -98,10 +98,15 @@ type
|
||||
end;
|
||||
|
||||
|
||||
const
|
||||
RegisterComponentsProc: procedure(const Page,UnitName:ShortString;
|
||||
ComponentClasses: array of TComponentClass) = nil;
|
||||
type
|
||||
TRegisterComponentsProc = procedure(const Page,UnitName:ShortString;
|
||||
ComponentClasses: array of TComponentClass);
|
||||
|
||||
var
|
||||
RegisterComponentsProc: TRegisterComponentsProc;
|
||||
|
||||
procedure RegisterComponent(const Page,UnitName:ShortString;
|
||||
ComponentClass: TComponentClass);
|
||||
procedure RegisterComponents(const Page,UnitName:ShortString;
|
||||
ComponentClasses: array of TComponentClass);
|
||||
function FindRegsiteredComponentClass(
|
||||
@ -110,11 +115,20 @@ function FindRegsiteredComponentClass(
|
||||
var
|
||||
RegCompList:TRegisteredComponentList;
|
||||
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
|
||||
procedure RegisterComponent(const Page, UnitName: ShortString;
|
||||
ComponentClass: TComponentClass);
|
||||
begin
|
||||
if RegCompList<>nil then
|
||||
RegCompList.RegisterComponents(Page,UnitName,[ComponentClass])
|
||||
else
|
||||
raise EComponentError.Create(
|
||||
'RegisterComponentsInGlobalList RegCompList=nil');
|
||||
end;
|
||||
|
||||
procedure RegisterComponents(const Page,UnitName:ShortString;
|
||||
ComponentClasses: array of TComponentClass);
|
||||
begin
|
||||
@ -136,6 +150,16 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure RegisterComponentsInGlobalList(const Page,UnitName:ShortString;
|
||||
ComponentClasses: array of TComponentClass);
|
||||
begin
|
||||
if RegCompList<>nil then
|
||||
RegCompList.RegisterComponents(Page,UnitName,ComponentClasses)
|
||||
else
|
||||
raise EComponentError.Create(
|
||||
'RegisterComponentsInGlobalList RegCompList=nil');
|
||||
end;
|
||||
|
||||
{ TRegisteredComponent }
|
||||
|
||||
constructor TRegisteredComponent.Create(APage:TRegisteredComponentPage;
|
||||
@ -231,7 +255,12 @@ var NewPage:TRegisteredComponentPage;
|
||||
a:integer;
|
||||
NewComp:TRegisteredComponent;
|
||||
begin
|
||||
|
||||
if (High(ComponentClasses)-Low(ComponentClasses)<0)
|
||||
or (Page='') or (UnitName='') then exit;
|
||||
if not IsValidIdent(UnitName) then begin
|
||||
raise EComponentError.Create(
|
||||
'RegisterComponents: Invalid unitname "'+UnitName+'"');
|
||||
end;
|
||||
NewPage:=FindPageByName(Page);
|
||||
if (NewPage=nil) then begin
|
||||
NewPage:=TRegisteredComponentPage.Create(Self,FPages.Count,Page);
|
||||
@ -270,11 +299,13 @@ begin
|
||||
end;
|
||||
|
||||
initialization
|
||||
RegisterComponentsProc:=nil;
|
||||
RegCompList := TRegisteredComponentList.Create;
|
||||
RegisterComponentsProc := @RegisterComponentsInGlobalList;
|
||||
|
||||
finalization
|
||||
RegCompList.Destroy;
|
||||
|
||||
RegCompList.Free;
|
||||
RegCompList:=nil;
|
||||
|
||||
end.
|
||||
|
||||
|
||||
@ -48,6 +48,9 @@ uses
|
||||
{$IFDEF INTERBASE}
|
||||
,interbase
|
||||
{$ENDIF}
|
||||
{$IFDEF CustomIDEComps}
|
||||
,CustomIDEComps
|
||||
{$ENDIF}
|
||||
;
|
||||
|
||||
const
|
||||
@ -269,7 +272,7 @@ end;
|
||||
|
||||
function TIDEComponent.LoadImageIntoPixmap: TPixmap;
|
||||
|
||||
function LoadResource(ResourceName:string; PixMap:TPixMap):boolean;
|
||||
function LoadResource(const ResourceName:string; PixMap:TPixMap):boolean;
|
||||
var
|
||||
ms:TMemoryStream;
|
||||
res:TLResource;
|
||||
@ -303,18 +306,16 @@ end;
|
||||
|
||||
{--------------------------------------------------}
|
||||
|
||||
procedure RegisterStandardComponents(
|
||||
ARegisteredComponentList:TRegisteredComponentList);
|
||||
|
||||
procedure RegisterComponents(const Page,UnitName:ShortString;
|
||||
ComponentClasses: array of TComponentClass);
|
||||
begin
|
||||
ARegisteredComponentList.RegisterComponents(
|
||||
Page,UnitName,ComponentClasses);
|
||||
end;
|
||||
|
||||
{procedure RegisterComponents(const Page,UnitName:ShortString;
|
||||
ComponentClasses: array of TComponentClass);
|
||||
begin
|
||||
RegisterComponentsProc:=@RegisterComponents;
|
||||
CurRegisteredComponentList.RegisterComponents(
|
||||
Page,UnitName,ComponentClasses);
|
||||
end;}
|
||||
|
||||
procedure RegisterStandardComponents;
|
||||
begin
|
||||
//RegisterComponentsProc:=@RegisterComponents;
|
||||
|
||||
RegisterComponents('Standard','Menus',[TMainMenu,TPopupMenu]);
|
||||
RegisterComponents('Standard','StdCtrls',[TLabel,TEdit,TMemo]);
|
||||
@ -339,14 +340,14 @@ begin
|
||||
|
||||
RegisterComponents('Samples','Spin',[TSpinEdit]);
|
||||
|
||||
{$IFDEF DATABASE}
|
||||
{$IFDEF DATABASE}
|
||||
RegisterComponents('Data Access','Db',[TDatasource,TDatabase]);
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF INTERBASE}
|
||||
{$IFDEF INTERBASE}
|
||||
RegisterComponents('Interbase Data Access','Interbase',[TIBStoredProc,
|
||||
TIBQuery,TIBDatabase]);
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
|
||||
// unselectable components
|
||||
// components that are streamed but not selectable in the IDE
|
||||
@ -354,12 +355,16 @@ begin
|
||||
RegisterComponents('','ComCtrls',[TToolbutton]);
|
||||
RegisterComponents('','menus', [TMenuItem]);
|
||||
|
||||
RegisterComponentsProc:=nil;
|
||||
{$IFDEF CustomIDEComps}
|
||||
CustomIDEComps.RegisterCustomComponents(@RegisterComponent);
|
||||
{$ENDIF}
|
||||
|
||||
//RegisterComponentsProc:=nil;
|
||||
end;
|
||||
|
||||
procedure InitIDEComponents;
|
||||
begin
|
||||
RegisterStandardComponents(RegCompList);
|
||||
RegisterStandardComponents;
|
||||
IdeCompList := TIDECompList.Create;
|
||||
end;
|
||||
|
||||
|
||||
@ -651,6 +651,10 @@ function InitResourceComponent(Instance: TComponent;
|
||||
function GetShortHint(const Hint: string): string;
|
||||
function GetLongHint(const Hint: string): string;
|
||||
|
||||
procedure RegisterComponents(const Page:ShortString; UnitName:ShortString;
|
||||
ComponentClasses: array of TComponentClass);
|
||||
|
||||
|
||||
var
|
||||
Application : TApplication;
|
||||
Screen : TScreen;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user