mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-25 00:19:10 +02:00
added new package lazthread from Carlos German Tejero
git-svn-id: trunk@12345 -
This commit is contained in:
parent
f20081a879
commit
dc9ea5da5c
7
.gitattributes
vendored
7
.gitattributes
vendored
@ -502,6 +502,12 @@ components/lazreport/source/lr_view.lrs svneol=native#text/plain
|
||||
components/lazreport/source/lr_view.pas svneol=native#text/pascal
|
||||
components/lazreport/source/sysutilsadds.pas svneol=native#text/pascal
|
||||
components/lazreport/tools/localize.sh svneol=native#text/plain
|
||||
components/lazthread/lazthread.lpk svneol=native#text/plain
|
||||
components/lazthread/lazthread.pas svneol=native#text/plain
|
||||
components/lazthread/reglazthread.pas svneol=native#text/plain
|
||||
components/lazthread/threadoptionsdialog.lfm svneol=native#text/plain
|
||||
components/lazthread/threadoptionsdialog.lrs svneol=native#text/plain
|
||||
components/lazthread/threadoptionsdialog.pas svneol=native#text/plain
|
||||
components/macfiles/Makefile svneol=native#text/plain
|
||||
components/macfiles/Makefile.fpc svneol=native#text/plain
|
||||
components/macfiles/examples/Readme.txt svneol=native#text/plain
|
||||
@ -3150,6 +3156,7 @@ packager/globallinks/lazcustomform-0.lpl svneol=native#text/plain
|
||||
packager/globallinks/lazdaemon-0.lpl svneol=native#text/plain
|
||||
packager/globallinks/lazopenglcontext-0.lpl svneol=native#text/plain
|
||||
packager/globallinks/lazreport-0.9.5.lpl svneol=native#text/plain
|
||||
packager/globallinks/lazthread-0.lpl svneol=native#text/plain
|
||||
packager/globallinks/macosfiles-0.lpl svneol=native#text/plain
|
||||
packager/globallinks/popupnotifierlaz-0.lpl svneol=native#text/plain
|
||||
packager/globallinks/prettyformat-0.lpl svneol=native#text/plain
|
||||
|
54
components/lazthread/lazthread.lpk
Normal file
54
components/lazthread/lazthread.lpk
Normal file
@ -0,0 +1,54 @@
|
||||
<?xml version="1.0"?>
|
||||
<CONFIG>
|
||||
<Package Version="3">
|
||||
<Name Value="lazthread"/>
|
||||
<Author Value="Carlos German Tejero"/>
|
||||
<CompilerOptions>
|
||||
<Version Value="5"/>
|
||||
<SearchPaths>
|
||||
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<CodeGeneration>
|
||||
<Generate Value="Faster"/>
|
||||
</CodeGeneration>
|
||||
<Other>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
<Description Value="Extends IDE with a new unit type.
|
||||
"/>
|
||||
<License Value="modified LGPL. See the file COPYING.modifiedLGPL for details.
|
||||
"/>
|
||||
<Files Count="2">
|
||||
<Item1>
|
||||
<Filename Value="reglazthread.pas"/>
|
||||
<HasRegisterProc Value="True"/>
|
||||
<UnitName Value="RegLazThread"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Filename Value="threadoptionsdialog.pas"/>
|
||||
<UnitName Value="ThreadOptionsDialog"/>
|
||||
</Item2>
|
||||
</Files>
|
||||
<Type Value="RunAndDesignTime"/>
|
||||
<RequiredPkgs Count="3">
|
||||
<Item1>
|
||||
<PackageName Value="IDEIntf"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<PackageName Value="FCL"/>
|
||||
<MinVersion Major="1" Valid="True"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item3>
|
||||
</RequiredPkgs>
|
||||
<UsageOptions>
|
||||
<UnitPath Value="$(PkgOutDir)/"/>
|
||||
</UsageOptions>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<IgnoreBinaries Value="False"/>
|
||||
</PublishOptions>
|
||||
</Package>
|
||||
</CONFIG>
|
21
components/lazthread/lazthread.pas
Normal file
21
components/lazthread/lazthread.pas
Normal file
@ -0,0 +1,21 @@
|
||||
{ This file was automatically created by Lazarus. Do not edit!
|
||||
This source is only used to compile and install the package.
|
||||
}
|
||||
|
||||
unit lazthread;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
RegLazThread, ThreadOptionsDialog, LazarusPackageIntf;
|
||||
|
||||
implementation
|
||||
|
||||
procedure Register;
|
||||
begin
|
||||
RegisterUnit('RegLazThread', @RegLazThread.Register);
|
||||
end;
|
||||
|
||||
initialization
|
||||
RegisterPackage('lazthread', @Register);
|
||||
end.
|
146
components/lazthread/reglazthread.pas
Normal file
146
components/lazthread/reglazthread.pas
Normal file
@ -0,0 +1,146 @@
|
||||
{
|
||||
*****************************************************************************
|
||||
* *
|
||||
* See the file COPYING.modifiedLGPL, included in this distribution, *
|
||||
* for details about the copyright. *
|
||||
* *
|
||||
* This program 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. *
|
||||
* *
|
||||
*****************************************************************************
|
||||
}
|
||||
|
||||
unit RegLazThread;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, ProjectIntf, LazIdeIntf;
|
||||
|
||||
type
|
||||
{ TThreadFileDescriptor }
|
||||
TThreadFileDescriptor = class(TFileDescPascalUnit)
|
||||
private
|
||||
FThreadCount:integer;
|
||||
FThreadName :string;
|
||||
function GetNextThreadName:string;
|
||||
function GetCurrentThreadName:string;
|
||||
public
|
||||
constructor Create; override;
|
||||
function GetLocalizedName : string; override;
|
||||
function GetLocalizedDescription : string; override;
|
||||
function GetInterfaceSource(const Filename, SourceName, ResourceName: string): string; override;
|
||||
function GetImplementationSource(const Filename, SourceName, ResourceName: string): string; override;
|
||||
end;
|
||||
|
||||
procedure register;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
Controls, ThreadOptionsDialog;
|
||||
|
||||
resourcestring
|
||||
SThreadName = 'Thread Object';
|
||||
SThreadDescription = 'A Pascal unit with a subclass of TThread class';
|
||||
|
||||
//---------------//
|
||||
procedure register;
|
||||
begin
|
||||
RegisterProjectFileDescriptor(TThreadFileDescriptor.Create, FileDescGroupName);
|
||||
end;
|
||||
|
||||
{ TThreadFileDescriptor }
|
||||
|
||||
//-------------------------------------//
|
||||
constructor TThreadFileDescriptor.Create;
|
||||
begin
|
||||
inherited Create;
|
||||
Name := SThreadName;
|
||||
FThreadCount := 1;
|
||||
FThreadName := TThread.ClassName;
|
||||
end;
|
||||
|
||||
//-----------------------------------------------------//
|
||||
function TThreadFileDescriptor.GetNextThreadName: string;
|
||||
var
|
||||
ThreadOptionsDialog:TThreadOptionsDialog;
|
||||
begin
|
||||
//Create Default Thread Class Name
|
||||
FThreadName := TThread.ClassName + IntToStr(FThreadCount);
|
||||
FThreadCount := (FThreadCount mod MaxInt) + 1;
|
||||
|
||||
//Show Thread Options Dialog
|
||||
with(TThreadOptionsDialog.Create(nil))do
|
||||
begin
|
||||
ThreadNameEdit.Text := FThreadName;
|
||||
if((ShowModal = mrOK)and(ThreadNameEdit.Text <> ''))then
|
||||
begin
|
||||
FThreadName := ThreadNameEdit.Text;
|
||||
end;
|
||||
Free;
|
||||
end;
|
||||
|
||||
//Return Thread Class Name
|
||||
Result := FThreadName;
|
||||
end;
|
||||
|
||||
//--------------------------------------------------------//
|
||||
function TThreadFileDescriptor.GetCurrentThreadName: string;
|
||||
begin
|
||||
Result := FThreadName;
|
||||
end;
|
||||
|
||||
//----------------------------------------------------//
|
||||
function TThreadFileDescriptor.GetLocalizedName: string;
|
||||
begin
|
||||
Result := SThreadName;
|
||||
end;
|
||||
|
||||
//-----------------------------------------------------------//
|
||||
function TThreadFileDescriptor.GetLocalizedDescription: string;
|
||||
begin
|
||||
Result := SThreadDescription;
|
||||
end;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------//
|
||||
function TThreadFileDescriptor.GetInterfaceSource(const Filename, SourceName, ResourceName: string): string;
|
||||
begin
|
||||
with(TStringList.Create)do
|
||||
begin
|
||||
Add('type');
|
||||
Add(' ' + GetNextThreadName + ' = class(TThread)');
|
||||
Add(' private');
|
||||
Add(' { Private declarations }');
|
||||
Add(' protected');
|
||||
Add(' { Protected declarations }');
|
||||
Add(' procedure Execute; override;');
|
||||
Add(' end;');
|
||||
Add('');
|
||||
Result := Text;
|
||||
Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------//
|
||||
function TThreadFileDescriptor.GetImplementationSource(const Filename, SourceName, ResourceName: string): string;
|
||||
begin
|
||||
with(TStringList.Create)do
|
||||
begin
|
||||
Add('{ ' + GetCurrentThreadName + ' }');
|
||||
Add('');
|
||||
Add('procedure ' + GetCurrentThreadName + '.Execute;');
|
||||
Add('begin');
|
||||
Add(' { Write your thread code here }');
|
||||
Add('end;');
|
||||
Add('');
|
||||
Result := Text;
|
||||
Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
48
components/lazthread/threadoptionsdialog.lfm
Normal file
48
components/lazthread/threadoptionsdialog.lfm
Normal file
@ -0,0 +1,48 @@
|
||||
object ThreadOptionsDialog: TThreadOptionsDialog
|
||||
Left = 282
|
||||
Height = 106
|
||||
Top = 183
|
||||
Width = 283
|
||||
HorzScrollBar.Page = 282
|
||||
VertScrollBar.Page = 105
|
||||
ActiveControl = ThreadNameEdit
|
||||
BorderIcons = []
|
||||
Caption = 'ThreadOptionsDialog'
|
||||
ClientHeight = 106
|
||||
ClientWidth = 283
|
||||
Position = poDesktopCenter
|
||||
object OptionsGroupBox: TGroupBox
|
||||
Height = 65
|
||||
Width = 283
|
||||
Align = alTop
|
||||
ClientHeight = 47
|
||||
ClientWidth = 279
|
||||
TabOrder = 1
|
||||
object ThreadNameLabel: TLabel
|
||||
Left = 22
|
||||
Height = 17
|
||||
Top = 2
|
||||
Width = 90
|
||||
ParentColor = False
|
||||
end
|
||||
object ThreadNameEdit: TEdit
|
||||
Left = 22
|
||||
Height = 22
|
||||
Top = 16
|
||||
Width = 232
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
TabOrder = 0
|
||||
end
|
||||
end
|
||||
object CreateUnitButton: TButton
|
||||
Left = 40
|
||||
Height = 25
|
||||
Top = 73
|
||||
Width = 200
|
||||
Anchors = [akLeft, akRight, akBottom]
|
||||
BorderSpacing.InnerBorder = 4
|
||||
Default = True
|
||||
ModalResult = 1
|
||||
TabOrder = 0
|
||||
end
|
||||
end
|
17
components/lazthread/threadoptionsdialog.lrs
Normal file
17
components/lazthread/threadoptionsdialog.lrs
Normal file
@ -0,0 +1,17 @@
|
||||
{ Este es un archivo de recurso de Lazarus generado automáticamente }
|
||||
|
||||
LazarusResources.Add('TThreadOptionsDialog','FORMDATA',[
|
||||
'TPF0'#20'TThreadOptionsDialog'#19'ThreadOptionsDialog'#4'Left'#3#26#1#6'Heig'
|
||||
+'ht'#2'j'#3'Top'#3#183#0#5'Width'#3#27#1#18'HorzScrollBar.Page'#3#26#1#18'Ve'
|
||||
+'rtScrollBar.Page'#2'i'#13'ActiveControl'#7#14'ThreadNameEdit'#11'BorderIcon'
|
||||
+'s'#11#0#7'Caption'#6#19'ThreadOptionsDialog'#12'ClientHeight'#2'j'#11'Clien'
|
||||
+'tWidth'#3#27#1#8'Position'#7#15'poDesktopCenter'#0#9'TGroupBox'#15'OptionsG'
|
||||
+'roupBox'#6'Height'#2'A'#5'Width'#3#27#1#5'Align'#7#5'alTop'#12'ClientHeight'
|
||||
+#2'/'#11'ClientWidth'#3#23#1#8'TabOrder'#2#1#0#6'TLabel'#15'ThreadNameLabel'
|
||||
+#4'Left'#2#22#6'Height'#2#17#3'Top'#2#2#5'Width'#2'Z'#11'ParentColor'#8#0#0#5
|
||||
+'TEdit'#14'ThreadNameEdit'#4'Left'#2#22#6'Height'#2#22#3'Top'#2#16#5'Width'#3
|
||||
+#232#0#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#0#8'TabOrder'#2#0#0#0#0#7
|
||||
+'TButton'#16'CreateUnitButton'#4'Left'#2'('#6'Height'#2#25#3'Top'#2'I'#5'Wid'
|
||||
+'th'#3#200#0#7'Anchors'#11#6'akLeft'#7'akRight'#8'akBottom'#0#25'BorderSpaci'
|
||||
+'ng.InnerBorder'#2#4#7'Default'#9#11'ModalResult'#2#1#8'TabOrder'#2#0#0#0#0
|
||||
]);
|
63
components/lazthread/threadoptionsdialog.pas
Normal file
63
components/lazthread/threadoptionsdialog.pas
Normal file
@ -0,0 +1,63 @@
|
||||
{
|
||||
*****************************************************************************
|
||||
* *
|
||||
* See the file COPYING.modifiedLGPL, included in this distribution, *
|
||||
* for details about the copyright. *
|
||||
* *
|
||||
* This program 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. *
|
||||
* *
|
||||
*****************************************************************************
|
||||
}
|
||||
|
||||
unit ThreadOptionsDialog;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, StdCtrls;
|
||||
|
||||
type
|
||||
|
||||
{ TThreadOptionsDialog }
|
||||
|
||||
TThreadOptionsDialog = class(TForm)
|
||||
CreateUnitButton: TButton;
|
||||
ThreadNameLabel: TLabel;
|
||||
ThreadNameEdit: TEdit;
|
||||
OptionsGroupBox: TGroupBox;
|
||||
private
|
||||
{ private declarations }
|
||||
public
|
||||
{ public declarations }
|
||||
constructor Create(AOwner: TComponent);override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
resourcestring
|
||||
SThreadDialogTitle = 'Thread Class Options';
|
||||
SOptionsGroupBoxCaption = 'Options';
|
||||
SThreadNameLabelCaption = 'Thread Class Name';
|
||||
SCreateUnitButtonCaption = 'Create Unit';
|
||||
|
||||
{ TThreadOptionsDialog }
|
||||
|
||||
//--------------------------------------------------------//
|
||||
constructor TThreadOptionsDialog.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
Caption := SThreadDialogTitle;
|
||||
OptionsGroupBox.Caption := SOptionsGroupBoxCaption;
|
||||
ThreadNameLabel.Caption := SThreadNameLabelCaption;
|
||||
CreateUnitButton.Caption := SCreateUnitButtonCaption;
|
||||
end;
|
||||
|
||||
initialization
|
||||
{$I threadoptionsdialog.lrs}
|
||||
|
||||
end.
|
||||
|
1
packager/globallinks/lazthread-0.lpl
Normal file
1
packager/globallinks/lazthread-0.lpl
Normal file
@ -0,0 +1 @@
|
||||
$(LazarusDir)/components/lazthread/lazthread.lpk
|
Loading…
Reference in New Issue
Block a user