hexsha
stringlengths 40
40
| size
int64 3
1.05M
| ext
stringclasses 163
values | lang
stringclasses 53
values | max_stars_repo_path
stringlengths 3
945
| max_stars_repo_name
stringlengths 4
112
| max_stars_repo_head_hexsha
stringlengths 40
78
| max_stars_repo_licenses
listlengths 1
10
| max_stars_count
float64 1
191k
⌀ | max_stars_repo_stars_event_min_datetime
stringlengths 24
24
⌀ | max_stars_repo_stars_event_max_datetime
stringlengths 24
24
⌀ | max_issues_repo_path
stringlengths 3
945
| max_issues_repo_name
stringlengths 4
113
| max_issues_repo_head_hexsha
stringlengths 40
78
| max_issues_repo_licenses
listlengths 1
10
| max_issues_count
float64 1
116k
⌀ | max_issues_repo_issues_event_min_datetime
stringlengths 24
24
⌀ | max_issues_repo_issues_event_max_datetime
stringlengths 24
24
⌀ | max_forks_repo_path
stringlengths 3
945
| max_forks_repo_name
stringlengths 4
113
| max_forks_repo_head_hexsha
stringlengths 40
78
| max_forks_repo_licenses
listlengths 1
10
| max_forks_count
float64 1
105k
⌀ | max_forks_repo_forks_event_min_datetime
stringlengths 24
24
⌀ | max_forks_repo_forks_event_max_datetime
stringlengths 24
24
⌀ | content
stringlengths 3
1.05M
| avg_line_length
float64 1
966k
| max_line_length
int64 1
977k
| alphanum_fraction
float64 0
1
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
83fd45347a58484795a330e258d6639572c7f42e | 1,294 | dpr | Pascal | examples/CLX/QStrmBmp.dpr | ok7-eleven/tpabbrevia | e239ba811f536b90ad8dda2c5d43d9d80e22f592 | [
"BSD-3-Clause"
]
| null | null | null | examples/CLX/QStrmBmp.dpr | ok7-eleven/tpabbrevia | e239ba811f536b90ad8dda2c5d43d9d80e22f592 | [
"BSD-3-Clause"
]
| null | null | null | examples/CLX/QStrmBmp.dpr | ok7-eleven/tpabbrevia | e239ba811f536b90ad8dda2c5d43d9d80e22f592 | [
"BSD-3-Clause"
]
| null | null | null | (* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is TurboPower Abbrevia
*
* The Initial Developer of the Original Code is
* TurboPower Software
*
* Portions created by the Initial Developer are Copyright (C) 1997-2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* ***** END LICENSE BLOCK ***** *)
{*********************************************************}
{* ABBREVIA: QSTRMBMP.DPR *}
{*********************************************************}
{* ABBREVIA Example program file *}
{*********************************************************}
program QStrmBmp;
uses
QForms,
QStrmBmpU in 'QStrmBmpU.pas' {Form1};
begin
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
| 31.560976 | 78 | 0.583462 |
857c809d1a29e64c155e883014b083460ebb20cb | 4,376 | dfm | Pascal | Demos/Demo33/ThSort.dfm | imiara/python4delphi | 2c84d57987f15522f151c4d717911d7f138156b1 | [
"MIT"
]
| 685 | 2015-08-28T02:12:06.000Z | 2022-03-28T19:44:07.000Z | Demos/Demo33/ThSort.dfm | sadanboy/python4delphi | 64f1dd9ea1f9d7a96220a3e6894bc273d6b6e003 | [
"MIT"
]
| 248 | 2015-11-17T16:39:48.000Z | 2022-03-29T18:44:53.000Z | Demos/Demo33/ThSort.dfm | sadanboy/python4delphi | 64f1dd9ea1f9d7a96220a3e6894bc273d6b6e003 | [
"MIT"
]
| 259 | 2015-10-03T04:53:26.000Z | 2022-03-31T18:23:06.000Z | object ThreadSortForm: TThreadSortForm
Left = 171
Top = 19
BorderStyle = bsDialog
Caption = 'Thread Sorting Demo'
ClientHeight = 564
ClientWidth = 566
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = True
Position = poScreenCenter
OnCloseQuery = FormCloseQuery
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object Bevel1: TBevel
Left = 8
Top = 24
Width = 177
Height = 355
end
object Bevel3: TBevel
Left = 376
Top = 24
Width = 177
Height = 355
end
object Bevel2: TBevel
Left = 192
Top = 24
Width = 177
Height = 355
end
object BubbleSortBox: TPaintBox
Left = 8
Top = 24
Width = 177
Height = 355
OnPaint = BubbleSortBoxPaint
end
object SelectionSortBox: TPaintBox
Left = 192
Top = 24
Width = 177
Height = 355
OnPaint = SelectionSortBoxPaint
end
object QuickSortBox: TPaintBox
Left = 376
Top = 24
Width = 177
Height = 355
OnPaint = QuickSortBoxPaint
end
object Label1: TLabel
Left = 8
Top = 8
Width = 49
Height = 13
Caption = 'SortFunc1'
end
object Label2: TLabel
Left = 192
Top = 8
Width = 49
Height = 13
Caption = 'SortFunc2'
end
object Label3: TLabel
Left = 376
Top = 8
Width = 49
Height = 13
Caption = 'SortFunc3'
end
object Start3Btn: TButton
Left = 334
Top = 385
Width = 108
Height = 25
Caption = 'three interpreters'
TabOrder = 0
OnClick = Start3BtnClick
end
object PythonMemo: TMemo
Left = 0
Top = 419
Width = 566
Height = 145
Align = alBottom
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Consolas'
Font.Style = []
Lines.Strings = (
'from SortModule import getvalue,swap'
' '
'def SortFunc1(handle, low, high):'
' for i in range(low, high):'
' for j in range(low+1,high):'
' if getvalue(handle,j-1) > getvalue(handle,j):'
' swap(handle,j-1,j)'
''
'def SortFunc2(handle,low,high):'
' for i in range(low,high-1):'
' for j in range(i+1,high):'
' if getvalue(handle,i) > getvalue(handle,j):'
' swap(handle,i,j)'
''
'def SortFunc3(handle,low,high):'
' Lo = low'
' Hi = high-1'
' Mid = getvalue(handle,(Lo+Hi) // 2)'
' while 1:'
' while getvalue(handle,Lo) < Mid: '
' Lo = Lo + 1'
' while getvalue(handle,Hi) > Mid:'
' Hi = Hi - 1'
' if Lo <= Hi:'
' swap(handle,Lo,Hi)'
' Lo = Lo + 1'
' Hi = Hi - 1'
' if Lo > Hi:'
' break'
' if Hi > low:'
' SortFunc3(handle,low,Hi+1)'
' if Lo < high-1:'
' SortFunc3(handle,Lo,high)')
ParentFont = False
ScrollBars = ssBoth
TabOrder = 1
WordWrap = False
end
object Start1Btn: TButton
Left = 224
Top = 385
Width = 104
Height = 25
Caption = 'one interpreter'
TabOrder = 2
OnClick = Start1BtnClick
end
object LoadBtn: TButton
Left = 8
Top = 384
Width = 97
Height = 25
Caption = 'Load Script'
TabOrder = 3
OnClick = LoadBtnClick
end
object SaveBtn: TButton
Left = 111
Top = 385
Width = 107
Height = 25
Caption = 'Save Script'
TabOrder = 4
OnClick = SaveBtnClick
end
object StopBtn: TButton
Left = 448
Top = 385
Width = 105
Height = 25
Caption = 'stop interpreters'
TabOrder = 5
OnClick = StopBtnClick
end
object PythonEngine1: TPythonEngine
InitThreads = True
PyFlags = [pfDebug, pfInteractive, pfVerbose]
RedirectIO = False
Left = 16
Top = 88
end
object SortModule: TPythonModule
Engine = PythonEngine1
OnInitialization = SortModuleInitialization
ModuleName = 'SortModule'
Errors = <>
Left = 64
Top = 88
end
object PythonDialog: TOpenDialog
DefaultExt = 'py'
Filter = 'Python scripts|*.py|All files|*.*'
Left = 64
Top = 40
end
object SaveDialog: TSaveDialog
DefaultExt = 'py'
Filter = 'Python scripts|*.py|All files|*.*'
Left = 16
Top = 40
end
end
| 21.55665 | 59 | 0.575868 |
fc61e60c4a7774df0f726aa23c81bd2669d0adbd | 4,473 | pas | Pascal | idee/Grafik/GL/Frm_TestGLTex.pas | joecare99/Public | 9eee060fbdd32bab33cf65044602976ac83f4b83 | [
"MIT"
]
| 11 | 2017-06-17T05:13:45.000Z | 2021-07-11T13:18:48.000Z | idee/Grafik/GL/Frm_TestGLTex.pas | joecare99/Public | 9eee060fbdd32bab33cf65044602976ac83f4b83 | [
"MIT"
]
| 2 | 2019-03-05T12:52:40.000Z | 2021-12-03T12:34:26.000Z | idee/Grafik/GL/Frm_TestGLTex.pas | joecare99/Public | 9eee060fbdd32bab33cf65044602976ac83f4b83 | [
"MIT"
]
| 6 | 2017-09-07T09:10:09.000Z | 2022-02-19T20:19:58.000Z | Unit Frm_TestGLTex;
Interface
Uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
opengl, StdCtrls;
Type
TfrmCube = Class(TForm)
Procedure FormCreate(Sender: TObject);
Procedure FormResize(Sender: TObject);
Procedure FormPaint(Sender: TObject);
Procedure FormDestroy(Sender: TObject);
private
hrc: HGLRC;
DC: hdc;
Procedure DrawScene;
public
End;
Const
tex: Array[0..1, 0..7, 0..7] Of GLubyte =
(((0, 0, 0, 0, 0, 0, 0, 0),
(0, 0, 0, 0, 1, 0, 0, 0),
(0, 0, 0, 1, 1, 0, 0, 0),
(0, 0, 0, 0, 1, 0, 0, 0),
(0, 0, 0, 0, 1, 0, 0, 0),
(0, 0, 0, 0, 1, 0, 0, 0),
(0, 0, 0, 1, 1, 1, 0, 0),
(0, 0, 0, 0, 0, 0, 0, 0)),
((0, 0, 0, 0, 0, 0, 0, 0),
(0, 0, 0, 2, 2, 0, 0, 0),
(0, 0, 2, 0, 0, 2, 0, 0),
(0, 0, 0, 0, 0, 2, 0, 0),
(0, 0, 0, 0, 2, 0, 0, 0),
(0, 0, 0, 2, 0, 0, 0, 0),
(0, 0, 2, 2, 2, 2, 0, 0),
(0, 0, 0, 0, 0, 0, 0, 0)));
Type
ttex = Array[0..63, 0..2] Of GLubyte;
Var
t: Array[0..2] Of ttex;
frmCube: TfrmCube;
Distanz: Real;
winkel1: Integer;
winkel2: Integer;
winkel3: Integer;
Implementation
{$R *.DFM}
Procedure Init_Texturen;
Var
p, i, j: Integer;
Const
width = 8;
height = 8;
Begin
For i := 0 To height - 1 Do
Begin
For j := 0 To width - 1 Do
Begin
p := i * width + j;
t[0][p, 0] := $FF;
t[0][p, 1] := 0;
If tex[0][i, j] = 0 Then
t[0][p, 2] := $FF
Else
t[0][p, 2] := 0;
t[1][p, 0] := $FF;
t[1][p, 1] := $FF;
If tex[1][i, j] = 0 Then
t[1][p, 2] := $FF
Else
t[1][p, 2] := 0;
End;
End;
End;
Procedure SetDCPixelFormat(Handle: HDC);
Var
pfd: TPixelFormatDescriptor;
nPixelFormat: Integer;
Begin
FillChar(pfd, SizeOf(pfd), 0);
With pfd Do
Begin
nSize := sizeof(pfd); // Size of this structure
nVersion := 1; // Version number
dwFlags := PFD_DRAW_TO_WINDOW Or PFD_SUPPORT_OPENGL Or PFD_DOUBLEBUFFER;
// Flags
iPixelType := PFD_TYPE_RGBA; // RGBA pixel values
cColorBits := 24; // 24-bit color
cDepthBits := 32; // 32-bit depth buffer
iLayerType := PFD_MAIN_PLANE; // Layer type
End;
nPixelFormat := ChoosePixelFormat(Handle, @pfd);
SetPixelFormat(Handle, nPixelFormat, @pfd);
End;
Procedure TfrmCube.DrawScene;
Begin
glNewList(11, GL_COMPILE);
glBegin(GL_QUADS);
glTexCoord2f(0.0, 0.0);
glVertex2f(-1, 1);
glTexCoord2f(1.0, 0.0);
glVertex2f(1, 1);
glTexCoord2f(1.0, 1.0);
glVertex2f(1, -1);
glTexCoord2f(0.0, 1.0);
glVertex2f(-1, -1);
glEnd;
glEndList;
glEnable(GL_DEPTH_TEST);
glClear(GL_COLOR_BUFFER_BIT Or GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glDepthFunc(GL_LEQUAL);
glLoadIdentity;
glEnable(GL_TEXTURE_2D);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTranslatef(0, 0, Distanz);
glRotatef(winkel1, 1, 0, 0);
glRotatef(winkel2, 0, 1, 0);
glRotatef(winkel3, 0, 0, 1);
glTranslatef(0, 0, 1.0);
glTexImage2D(GL_TEXTURE_2D, 0, 3, 8, 8, 0, GL_RGB, GL_UNSIGNED_BYTE, @t[0]);
glCallList(11);
glTranslatef(0, 0, -2.0);
glTexImage2D(GL_TEXTURE_2D, 0, 3, 8, 8, 0, GL_RGB, GL_UNSIGNED_BYTE, @t[1]);
glCallList(11);
SwapBuffers(DC);
End;
Procedure TfrmCube.FormCreate(Sender: TObject);
Begin
DC := GetDC(Handle);
Randomize;
SetDCPixelFormat(Canvas.Handle);
hrc := wglCreateContext(Canvas.Handle);
Winkel1 := 30;
Winkel2 := 30;
Winkel3 := 30;
Distanz := -10;
Init_Texturen;
End;
Procedure TfrmCube.FormResize(Sender: TObject);
Begin
wglMakeCurrent(DC, hrc);
glMatrixMode(GL_PROJECTION);
glLoadIdentity;
gluPerspective(30.0, Width / Height, 1.0, 50.0);
glViewport(0, 0, Width, Height);
wglMakeCurrent(0, 0);
Invalidate;
End;
Procedure TfrmCube.FormPaint(Sender: TObject);
Begin
wglMakeCurrent(DC, hrc);
DrawScene;
wglMakeCurrent(0, 0);
End;
Procedure TfrmCube.FormDestroy(Sender: TObject);
Begin
wglDeleteContext(hrc);
ReleaseDC(Handle, DC);
End;
End.
| 23.792553 | 79 | 0.579253 |
47bafb0b091ef695de5068e5dcf5f1d32859c089 | 3,953 | pas | Pascal | BaseNcoding.Tests/Delphi.Tests/src/Base128Tests.pas | Xor-el/BaseNcodingPascal | 3621b7f25b5d24be114c0067b269628a5bc0434f | [
"MIT"
]
| 28 | 2017-05-09T18:09:52.000Z | 2022-01-13T18:27:58.000Z | BaseNcoding.Tests/Delphi.Tests/src/Base128Tests.pas | Xor-el/BaseNcodingPascal | 3621b7f25b5d24be114c0067b269628a5bc0434f | [
"MIT"
]
| 3 | 2018-07-05T18:59:28.000Z | 2018-08-14T11:14:40.000Z | BaseNcoding.Tests/Delphi.Tests/src/Base128Tests.pas | Xor-el/BaseNcodingPascal | 3621b7f25b5d24be114c0067b269628a5bc0434f | [
"MIT"
]
| 12 | 2017-09-12T21:26:11.000Z | 2022-03-17T13:00:32.000Z | unit Base128Tests;
{
Delphi DUnit Test Case
----------------------
This unit contains a skeleton test case class generated by the Test Case Wizard.
Modify the generated code to correctly setup and call the methods from the unit
being tested.
}
interface
uses
TestFramework,
SysUtils,
BaseTests,
BcpBase128,
BcpUtils;
type
// Test methods for class TBase128
TBase128Tests = class(TTestCase)
strict private
class var F_btInstance: TBaseNcodingTests;
public
procedure SetUp; override;
procedure TearDown; override;
procedure EncodeDecodeTest(const str: string);
procedure EncodeDecodeTestDefaultTextEncoding(const str: string);
procedure EncodeDecodeTestUnicodeTextEncoding(const str: string);
published
procedure CallEncodeDecodeTest();
procedure CallEncodeDecodeTestDefaultTextEncoding();
procedure CallEncodeDecodeTestUnicodeTextEncoding();
procedure TailTests;
end;
implementation
procedure TBase128Tests.SetUp;
begin
F_btInstance := TBaseNcodingTests.Create();
F_btInstance.FConverter := TBase128.Create();
end;
procedure TBase128Tests.TearDown;
begin
F_btInstance.Free;
end;
procedure TBase128Tests.CallEncodeDecodeTest();
var
i: integer;
begin
for i := 0 to Length(F_btInstance.sArray) - 1 do
begin
EncodeDecodeTest(F_btInstance.sArray[i]);
end;
end;
procedure TBase128Tests.EncodeDecodeTest(const str: string);
var
encoded, decoded: string;
begin
encoded := F_btInstance.FConverter.EncodeString(str);
decoded := F_btInstance.FConverter.DecodeToString(encoded);
CheckEquals(str, decoded);
end;
procedure TBase128Tests.CallEncodeDecodeTestDefaultTextEncoding();
begin
EncodeDecodeTestDefaultTextEncoding(F_btInstance.sArray[0]);
end;
procedure TBase128Tests.EncodeDecodeTestDefaultTextEncoding(const str: string);
var
encoded, decoded: string;
begin
F_btInstance.FConverter.Encoding := TEncoding.Default;
encoded := F_btInstance.FConverter.EncodeString(str);
decoded := F_btInstance.FConverter.DecodeToString(encoded);
CheckEquals(str, decoded);
end;
procedure TBase128Tests.CallEncodeDecodeTestUnicodeTextEncoding();
var
i: integer;
begin
for i := 0 to Length(F_btInstance.sArray) - 1 do
begin
EncodeDecodeTestUnicodeTextEncoding(F_btInstance.sArray[i]);
end;
end;
procedure TBase128Tests.EncodeDecodeTestUnicodeTextEncoding(const str: string);
var
encoded, decoded: string;
begin
F_btInstance.FConverter.Encoding := TEncoding.Unicode;
encoded := F_btInstance.FConverter.EncodeString(str);
decoded := F_btInstance.FConverter.DecodeToString(encoded);
CheckEquals(str, decoded);
end;
procedure TBase128Tests.TailTests;
var
testChar: char;
strBuilder: string;
bitsPerChar, bitsPerByte, charByteBitsLcm, maxTailLength, Count, i: integer;
str, encoded: string;
c: char;
begin
testChar := 'a';
strBuilder := '';
if ((F_btInstance.FConverter.HaveSpecial) and
(Trunc(F_btInstance.FConverter.BitsPerChars) mod 1 = 0) and
(TUtils.IsPowerOf2(UInt32(Trunc(F_btInstance.FConverter.BitsPerChars)))))
then
begin
bitsPerChar := Trunc(F_btInstance.FConverter.BitsPerChars);
bitsPerByte := 8;
charByteBitsLcm := TUtils.LCM(bitsPerByte, bitsPerChar);
maxTailLength := charByteBitsLcm div bitsPerByte - 1;
for i := 0 to (maxTailLength + 2) do
begin
str := strBuilder;
encoded := F_btInstance.FConverter.EncodeString(str);
Count := 0;
for c in encoded do
begin
if c = F_btInstance.FConverter.Special then
Inc(Count);
end;
if i = 0 then
CheckEquals(0, Count)
else
CheckEquals((maxTailLength - (i - 1) mod (maxTailLength + 1)), Count);
CheckEquals(str, F_btInstance.FConverter.DecodeToString(encoded));
strBuilder := strBuilder + (testChar);
end;
end;
end;
initialization
// Register any test cases with the test runner
RegisterTest(TBase128Tests.Suite);
end.
| 24.552795 | 82 | 0.742221 |
83df3b4c3123bc5a5b1e701ec09a326828562373 | 7,268 | pas | Pascal | library/fhir4/fhir4_opbase.pas | danka74/fhirserver | 1fc53b6fba67a54be6bee39159d3db28d42eb8e2 | [
"BSD-3-Clause"
]
| null | null | null | library/fhir4/fhir4_opbase.pas | danka74/fhirserver | 1fc53b6fba67a54be6bee39159d3db28d42eb8e2 | [
"BSD-3-Clause"
]
| null | null | null | library/fhir4/fhir4_opbase.pas | danka74/fhirserver | 1fc53b6fba67a54be6bee39159d3db28d42eb8e2 | [
"BSD-3-Clause"
]
| null | null | null | unit fhir4_opbase;
{
Copyright (c) 2011+, HL7 and Health Intersections Pty Ltd (http://www.healthintersections.com.au)
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
}
{$I fhir.inc}
interface
uses
SysUtils,
fsl_base, fsl_http,
fhir4_types, fhir4_resources;
type
TFHIROpExtension = class (TFslObject)
private
FName : String;
FValue : TFHIRType;
procedure SetValue(const Value: TFHIRType);
public
destructor Destroy; override;
property name : String read FName write FName;
property value : TFHIRType read FValue write SetValue;
end;
TFHIROperationBaseObject = class (TFslObject)
private
FExtensions : TFslList<TFHIROpExtension>;
function GetExtensions: TFslList<TFHIROpExtension>;
protected
function isKnownName(name : String) : boolean; overload; virtual;
procedure loadExtensions(params : TFHIRParameters); overload;
procedure loadExtensions(params : THTTPParameters); overload;
procedure loadExtensions(params : TFhirParametersParameter); overload;
procedure writeExtensions(params : TFHIRParameters); overload;
procedure writeExtensions(params : TFhirParametersParameter); overload;
public
destructor Destroy; override;
property extensions : TFslList<TFHIROpExtension> read GetExtensions;
procedure addExtension(name : String; value : TFHIRType); overload;
procedure addExtension(name : String; value : string); overload;
procedure addExtension(name : String; value : boolean); overload;
end;
TFHIROperationObject = class (TFHIROperationBaseObject)
public
constructor Create(); overload; override;
constructor Create(params : TFhirParametersParameter); overload; virtual;
function asParams(name : String) : TFHIRParametersParameter; virtual;
end;
TFHIROperationRequest = class (TFHIROperationBaseObject)
public
constructor Create(); overload; override;
procedure load(params : TFHIRParameters); overload; virtual; abstract;
procedure load(params : THTTPParameters); overload; virtual; abstract;
function asParams : TFHIRParameters; virtual; abstract;
end;
TFHIROperationResponse = class (TFHIROperationBaseObject)
public
constructor Create(); overload; override;
procedure load(params : TFHIRParameters); overload; virtual; abstract;
procedure load(params : THTTPParameters); overload; virtual; abstract;
function asParams : TFHIRParameters; virtual; abstract;
end;
implementation
{ TFHIROperationRequest }
constructor TFHIROperationRequest.create;
begin
inherited Create;
end;
{ TFHIROperationResponse }
constructor TFHIROperationResponse.create;
begin
inherited Create;
end;
{ TFHIROperationObject }
function TFHIROperationObject.asParams(name : String): TFHIRParametersParameter;
begin
result := nil;
end;
constructor TFHIROperationObject.create;
begin
inherited;
end;
constructor TFHIROperationObject.Create(params: TFhirParametersParameter);
begin
inherited create;
end;
{ TFHIROperationBaseObject }
procedure TFHIROperationBaseObject.addExtension(name: String; value: TFHIRType);
var
ext : TFHIROpExtension;
begin
ext := TFHIROpExtension.Create;
ext.name := name;
ext.value := value;
GetExtensions.Add(ext)
end;
procedure TFHIROperationBaseObject.addExtension(name, value: string);
var
ext : TFHIROpExtension;
begin
ext := TFHIROpExtension.Create;
ext.name := name;
ext.value := TFhirString.Create(value);
GetExtensions.Add(ext)
end;
procedure TFHIROperationBaseObject.addExtension(name: String; value: boolean);
var
ext : TFHIROpExtension;
begin
ext := TFHIROpExtension.Create;
ext.name := name;
ext.value := TFhirBoolean.Create(value);
GetExtensions.Add(ext)
end;
destructor TFHIROperationBaseObject.Destroy;
begin
FExtensions.Free;
inherited;
end;
function TFHIROperationBaseObject.GetExtensions: TFslList<TFHIROpExtension>;
begin
if FExtensions = nil then
FExtensions := TFslList<TFHIROpExtension>.create;
result := FExtensions;
end;
function TFHIROperationBaseObject.IsKnownName(name: String): boolean;
begin
result := false;
end;
procedure TFHIROperationBaseObject.loadExtensions(params: TFhirParametersParameter);
var
p : TFhirParametersParameter;
begin
for p in params.partList do
if not IsKnownName(p.name) then
addExtension(p.name, p.value.Link);
end;
procedure TFHIROperationBaseObject.loadExtensions(params: THTTPParameters);
var
i : integer;
begin
for i := 0 to params.Count - 1 do
if not IsKnownName(params.Name[i]) then
addExtension(params.Name[i], params[params.Name[i]]);
end;
procedure TFHIROperationBaseObject.loadExtensions(params: TFHIRParameters);
var
p : TFhirParametersParameter;
begin
for p in params.parameterList do
if not IsKnownName(p.name) then
addExtension(p.name, p.value.Link);
end;
procedure TFHIROperationBaseObject.writeExtensions(params: TFHIRParameters);
var
p : TFHIROpExtension;
begin
if FExtensions <> nil then
for p in FExtensions do
with params.parameterList.Append do
begin
name := p.name;
value := p.value.Link;
end;
end;
procedure TFHIROperationBaseObject.writeExtensions(params: TFhirParametersParameter);
var
p : TFHIROpExtension;
begin
if FExtensions <> nil then
for p in FExtensions do
with params.partList.Append do
begin
name := p.name;
value := p.value.Link;
end;
end;
{ TFHIROpExtension }
destructor TFHIROpExtension.Destroy;
begin
FValue.Free;
inherited;
end;
procedure TFHIROpExtension.SetValue(const Value: TFHIRType);
begin
FValue.Free;
FValue := Value;
end;
end.
| 29.072 | 98 | 0.739956 |
839e5350f66154bfc5c0f3689a389f44b488ae26 | 1,006 | pas | Pascal | tests/fakeview.pas | fabioxgn/IRC | dcfbaeb863b9feea95313212d5d5b0d7e2785df1 | [
"MIT"
]
| 4 | 2018-10-11T15:33:15.000Z | 2021-08-18T22:13:34.000Z | tests/fakeview.pas | fabioxgn/IRC | dcfbaeb863b9feea95313212d5d5b0d7e2785df1 | [
"MIT"
]
| null | null | null | tests/fakeview.pas | fabioxgn/IRC | dcfbaeb863b9feea95313212d5d5b0d7e2785df1 | [
"MIT"
]
| 1 | 2021-08-18T22:13:36.000Z | 2021-08-18T22:13:36.000Z | unit fakeview;
{$mode objfpc}{$H+}
interface
uses
IRCViewIntf;
type
{ TFakeView }
TFakeView = class(TInterfacedObject, IIRCView)
procedure ServerMessage(const AText: string);
procedure UpdateNodeText(Node: TObject; AText: string);
procedure UpdateTabCaption(Tab: TObject; ACaption: string);
procedure NotifyChanged;
function GetTab(const ACaption: string): TObject;
function GetNode(const ACaption: string; ParentNode: TObject): TObject;
end;
implementation
{ TFakeView }
procedure TFakeView.ServerMessage(const AText: string);
begin
end;
procedure TFakeView.UpdateNodeText(Node: TObject; AText: string);
begin
end;
procedure TFakeView.UpdateTabCaption(Tab: TObject; ACaption: string);
begin
end;
procedure TFakeView.NotifyChanged;
begin
end;
function TFakeView.GetTab(const ACaption: string): TObject;
begin
end;
function TFakeView.GetNode(const ACaption: string; ParentNode: TObject): TObject;
begin
end;
end.
| 17.649123 | 82 | 0.729622 |
fc5083cec3c89c7e115cc58ff59fd1d15ec217b3 | 311 | pas | Pascal | Test/JSONConnectorPass/stringify_keys.pas | synapsea/DW-Script | b36c2e57f0285c217f8f0cae8e4e158d21127163 | [
"Condor-1.1"
]
| 1 | 2022-02-18T22:14:44.000Z | 2022-02-18T22:14:44.000Z | Test/JSONConnectorPass/stringify_keys.pas | synapsea/DW-Script | b36c2e57f0285c217f8f0cae8e4e158d21127163 | [
"Condor-1.1"
]
| null | null | null | Test/JSONConnectorPass/stringify_keys.pas | synapsea/DW-Script | b36c2e57f0285c217f8f0cae8e4e158d21127163 | [
"Condor-1.1"
]
| null | null | null | var a : array[String] of Integer;
a['toto'] := 1;
PrintLn(JSON.Stringify(a.Keys));
a['titi'] := 2;
PrintLn(JSON.Stringify(a.Keys.Sort));
var b : array [Integer] of String;
PrintLn(JSON.Stringify(b.Keys));
b[1] := 'toto';
PrintLn(JSON.Stringify(b.Keys));
b[3] := 'tata';
PrintLn(JSON.Stringify(b.Keys.Sort));
| 22.214286 | 37 | 0.659164 |
fc589e2d2691dfe7425db6e88d1f8c71c184c01f | 4,316 | pas | Pascal | src/execgood.pas | evs38/pntchk | 3a1d1cb0deb1cca41c4ad5ae09d4a1144f3292e2 | [
"MIT"
]
| null | null | null | src/execgood.pas | evs38/pntchk | 3a1d1cb0deb1cca41c4ad5ae09d4a1144f3292e2 | [
"MIT"
]
| null | null | null | src/execgood.pas | evs38/pntchk | 3a1d1cb0deb1cca41c4ad5ae09d4a1144f3292e2 | [
"MIT"
]
| null | null | null | Program execgood;
Uses Dos,Crt;
var segfl: text;
endstr,endstr2: string;
const
(* NameProg = {$IFDEF VIRTUALPASCAL } {$IFDEF EMX} 'EXECGOOD/EMX' {$ELSE} 'EXECGOOD/2' {$ENDIF} {$ELSE} 'EXECGOOD' {$ENDIF};
NameFProg = {$IFDEF VIRTUALPASCAL } 'EXEGOOD' {$ELSE} nameprog {$ENDIF};*)
NameProg = {$IFDEF VIRTUALPASCAL } {$IFDEF WIN32} 'EXECGOOD/W32' {$ELSE} {$IFDEF DOS32} 'EXECGOOD/32' {$ELSE}
{$IFDEF LINUX} {$IFDEF FREEBSD} 'EXECGOOD/BSD' {$ELSE} 'EXECGOOD/LNX' {$ENDIF} {$ELSE} {$IFDEF EMX} 'PNTCHK/EMX'
{$ELSE} 'EXECGOOD/2' {$ENDIF} {$ENDIF} {$ENDIF}
{$ENDIF}
{$ELSE} 'EXECGOOD' {$ENDIF};
{$IFDEF FPC}
{$IFDEF WIN32} namefprog = 'W'; {$ENDIF}
{$IFDEF EMX} namefprog = 'E'; {$ENDIF}
{$IFDEF DOS32} namefprog = 'P'; {$ENDIF}
{$IFDEF LINUX} namefprog = {$IFDEF FREEBSD} 'D.BSD' {$ELSE} 'D.LNX' {$ENDIF}; {$ENDIF}
{$ELSE}
namefprog = 'D';
{$ENDIF}
Version = '0.11.beta';
{dayof: array[1..7] of string[3] = ('Mon','Tue','Wed','Thu','Fri','Sat','Sun');}
monthname: array[1..12] of string[3] = ('Jan','Fer','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
Function XStr(L:LongInt):String;
Var
SS:String;
Begin
Str(L,SS);
XStr:=SS;
End;
Function shortname(fullname: string): string;
var i:integer;
begin
i:=length(fullname)+1;
repeat
dec(i)
until (fullname[i]='\') or (i=0);
if i>0 then delete(fullname,1,i);
shortname:=fullname
end;
function LeadingZero(w : Word) : String;
var
s : String;
begin
Str(w:0,s);
if Length(s) = 1 then
s := '0' + s;
LeadingZero := s;
end;
Function returndatetime: string;
var tplstr: string;
ftime : Longint; { For Get/SetFTime}
dt : DateTime; { For Pack/UnpackTime}
begin
tplstr:='';
GetFTime(segfl,ftime); { Get creation time }
UnpackTime(ftime,dt);
with dt do
begin
tplstr:=tplstr+leadingzero(day);
tplstr:=tplstr+'-';
tplstr:=tplstr+monthname[month];
tplstr:=tplstr+'-';
tplstr:=tplstr+copy(xstr(year),length(xstr(year))-1,2);
tplstr:=tplstr+' ';
tplstr:=tplstr+leadingzero(hour);
tplstr:=tplstr+':';
tplstr:=tplstr+leadingzero(min);
tplstr:=tplstr+':';
tplstr:=tplstr+leadingzero(sec)
end;
returndatetime:=tplstr
end;
begin
TextColor (White);
Write (nameprog);
TextColor(LightCyan);
Writeln ({$IFDEF VIRTUALPASCAL} {$IFDEF EMX} ''+ {$ELSE} ''+ {$ENDIF} {$ELSE} ' '+
{$ENDIF}' An example utility for PNTCHK v'+version);
TextColor(Yellow);
Writeln ('Copyright (c) 1997 Pavel I.Osipov (2:5020/770.0@fidonet)');
WriteLn;
if (paramcount<3) then
begin
textcolor(7);
writeln('A small example utility of EXECGOOD procedure for');
writeln('Professional pointsegment checker, v'+version+' and later');
writeln;
textcolor(15);
write('Usage: EXECGOO'+namefprog+{$IFNDEF LINUX}'.EXE'+
{$ENDIF}' <new_segment_file> <old_segment_file> <outfile>');
textcolor(7); writeln;
halt
end;
endstr:='';
assign(segfl,paramstr(1));
reset(segfl);
if ioresult<>0 then
begin
writeln('Error opening segment file : ',paramstr(1));
halt
end;
endstr:=endstr+returndatetime;
close(segfl);
if (paramstr(2)<>'%o') and (paramstr(2)<>'%O') then
begin
assign(segfl,paramstr(2));
reset(segfl);
if ioresult<>0 then
begin
writeln('Error opening old segment file : ',paramstr(2));
halt
end;
endstr2:=returndatetime;
close(segfl)
end;
assign(segfl,paramstr(3));
rewrite(segfl);
if ioresult<>0 then
begin
writeln('Error creating outfile : ',paramstr(3));
halt
end;
writeln(segfl,'New segment file "'+shortname(paramstr(1))+'" dated '+endstr+' was accepted');
if (paramstr(2)<>'%o') and (paramstr(2)<>'%O') then writeln(segfl,'instead of old segment file "'+
shortname(paramstr(2))+'" dated '+endstr2);
close(segfl);
textcolor(white);
writeln('New segment file "'+shortname(paramstr(1))+'" dated '+endstr+' was accepted');
if (paramstr(2)<>'%o') and (paramstr(2)<>'%O') then writeln('instead of old segment file "'+
shortname(paramstr(2))+'" dated '+endstr2)
end.
| 28.773333 | 126 | 0.596154 |
4794803e46eb0623d0c1d63949fed1f8cd24709b | 2,163 | dfm | Pascal | tools/oldproj.Books/Add.dfm | zhzh2001/Learning-public | c7b0fe6ea64d2890ba2b25ae8a080d61c22f71c9 | [
"MIT"
]
| 1 | 2017-10-05T08:53:04.000Z | 2017-10-05T08:53:04.000Z | tools/oldproj.Books/Add.dfm | zhzh2001/Learning-public | c7b0fe6ea64d2890ba2b25ae8a080d61c22f71c9 | [
"MIT"
]
| null | null | null | tools/oldproj.Books/Add.dfm | zhzh2001/Learning-public | c7b0fe6ea64d2890ba2b25ae8a080d61c22f71c9 | [
"MIT"
]
| null | null | null | object frmAdd: TfrmAdd
Left = 1096
Top = 553
Width = 344
Height = 197
BorderIcons = [biSystemMenu]
Caption = #28155#21152#29992#25143
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
FormStyle = fsMDIChild
OldCreateOrder = False
Position = poMainFormCenter
Visible = True
OnClose = FormClose
PixelsPerInch = 96
TextHeight = 13
object GroupBox1: TGroupBox
Left = 0
Top = 0
Width = 336
Height = 129
Align = alTop
Caption = #29992#25143#20449#24687
TabOrder = 0
object lbUser: TLabel
Left = 16
Top = 32
Width = 49
Height = 13
AutoSize = False
Caption = #29992#25143'(&U):'
end
object lbPassword: TLabel
Left = 16
Top = 64
Width = 49
Height = 13
AutoSize = False
Caption = #23494#30721'(&P):'
FocusControl = edtPassword
end
object Label1: TLabel
Left = 16
Top = 96
Width = 49
Height = 13
AutoSize = False
Caption = #26435#38480'(&T):'
FocusControl = edtPassword
end
object edtPassword: TEdit
Left = 72
Top = 60
Width = 249
Height = 21
PasswordChar = '*'
TabOrder = 1
end
object edtToken: TComboBox
Left = 72
Top = 92
Width = 249
Height = 21
Style = csDropDownList
ItemHeight = 13
ItemIndex = 0
TabOrder = 2
Text = #26222#36890#29992#25143
Items.Strings = (
#26222#36890#29992#25143
#36229#32423#29992#25143
#31649#29702#21592)
end
object edtUser: TEdit
Left = 72
Top = 28
Width = 249
Height = 21
TabOrder = 0
end
end
object btnOK: TBitBtn
Left = 160
Top = 136
Width = 75
Height = 25
Caption = #30830#23450'&O'
TabOrder = 1
OnClick = btnOKClick
Kind = bkOK
end
object btnCancel: TBitBtn
Left = 256
Top = 136
Width = 75
Height = 25
Caption = #21462#28040'&C'
TabOrder = 2
OnClick = btnCancelClick
Kind = bkCancel
end
end
| 20.214953 | 38 | 0.57374 |
f1c0759a61ec11d759cb1b63020cf4bc057faef4 | 8,473 | pas | Pascal | references/mORMot/SQLite3/Samples/29 - SmartMobileStudio Client/SmartTests.pas | zekiguven/alcinoe | e55c5368ee8bfe7cd6d92424c29ab07d8a3e844c | [
"Apache-2.0"
]
| 851 | 2018-02-05T09:54:56.000Z | 2022-03-24T23:13:10.000Z | references/mORMot/SQLite3/Samples/29 - SmartMobileStudio Client/SmartTests.pas | zekiguven/alcinoe | e55c5368ee8bfe7cd6d92424c29ab07d8a3e844c | [
"Apache-2.0"
]
| 200 | 2018-02-06T18:52:39.000Z | 2022-03-24T19:59:14.000Z | references/mORMot/SQLite3/Samples/29 - SmartMobileStudio Client/SmartTests.pas | zekiguven/alcinoe | e55c5368ee8bfe7cd6d92424c29ab07d8a3e844c | [
"Apache-2.0"
]
| 197 | 2018-03-20T20:49:55.000Z | 2022-03-21T17:38:14.000Z | unit SmartTests;
interface
uses
SmartCL.System,
System.Types,
ECMA.Date,
System.Date,
SynCrossPlatformSpecific,
SynCrossPlatformREST,
SynCrossPlatformCrypto;
procedure TestSMS;
procedure ORMTest(client: TSQLRestClientURI);
procedure SOATest(client: TSQLRestClientURI; onSuccess, onError: TSQLRestEvent);
implementation
uses
mORMotClient; // unit generated by the server!
const
MSecsPerDay = 86400000;
OneSecDateTime = 1/SecsPerDay;
procedure TestsIso8601DateTime;
procedure Test(D: TDateTime);
var s: string;
procedure One(D: TDateTime);
var E: TDateTime;
V: TTimeLog;
J: JDate;
begin
J := new JDate;
J.AsDateTime := D;
E := J.AsDateTime;
assert(Abs(D-E)<OneSecDateTime);
s := DateTimeToIso8601(D);
E := Iso8601ToDateTime(s);
assert(Abs(D-E)<OneSecDateTime);
V := DateTimeToTTimeLog(D);
E := TTimeLogToDateTime(V);
assert(Abs(D-E)<OneSecDateTime);
assert(UrlDecode(UrlEncode(s))=s);
end;
begin
One(D);
assert(length(s)=19);
One(Trunc(D));
assert(length(s)=10);
One(Frac(D));
assert(length(s)=9);
end;
var D: TDateTime;
i: integer;
s,x: string;
T: TTimeLog;
begin
s := '2014-06-28T11:50:22';
D := Iso8601ToDateTime(s);
assert(DateTimeToIso8601(D)=s);
assert(Abs(D-41818.40997685185)<OneSecDateTime);
x := TTimeLogToIso8601(135181810838);
assert(x=s);
T := DateTimeToTTimeLog(D);
assert(T=135181810838);
D := Now/20+Random*20; // some starting random date/time
for i := 1 to 2000 do begin
Test(D);
D := D+Random*57; // go further a little bit: change date/time
end;
end;
procedure TestSMS;
var doc: TJSONVariantData;
begin
assert(crc32ascii(0,'abcdefghijklmnop')=$943AC093);
assert(SHA256('abc')='ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad');
assert(VariantType(123)=jvUndefined);
assert(VariantType(null)=jvUndefined);
assert(VariantType(TVariant.CreateObject)=jvObject);
assert(VariantType(new JObject)=jvObject);
assert(VariantType(TVariant.CreateArray)=jvArray);
doc := TJSONVariantData.Create('{"a":1,"b":"B"}');
assert(doc.Kind=jvObject);
assert(doc.Count=2);
assert(doc.Names[0]='a');
assert(doc.Names[1]='b');
assert(doc.Values[0]=1);
assert(doc.Values[1]='B');
doc := TJSONVariantData.Create('["a",2]');
assert(doc.Kind=jvArray);
assert(doc.Count=2);
assert(doc.Names.Count=0);
assert(doc.Values[0]='a');
assert(doc.Values[1]=2);
TestsIso8601DateTime;
end;
procedure ORMTest(client: TSQLRestClientURI);
var people: TSQLRecordPeople;
Call: TSQLRestURIParams;
res: TIntegerDynArray;
i,id: integer;
begin // all this is run in synchronous mode -> only 200 records in the set
client.CallBackGet('DropTable',[],Call,TSQLRecordPeople);
assert(client.InternalState>0);
assert(Call.OutStatus=HTTP_SUCCESS);
client.BatchStart(TSQLRecordPeople);
people := TSQLRecordPeople.Create;
assert(people.InternalState=0);
for i := 1 to 200 do begin
people.FirstName := 'First'+IntToStr(i);
people.LastName := 'Last'+IntToStr(i);
people.YearOfBirth := i+1800;
people.YearOfDeath := i+1825;
assert(client.BatchAdd(people,true)=i-1);
assert(people.InternalState=0);
end;
assert(client.BatchSend(res)=HTTP_SUCCESS);
assert(length(res)=200);
for i := 1 to 200 do
assert(res[i-1]=i);
people := TSQLRecordPeople.CreateAndFillPrepare(client,'','',[]);
assert(people.InternalState=0);
id := 0;
while people.FillOne do begin
assert(people.InternalState=client.InternalState);
inc(id);
assert(people.ID=id);
assert(people.FirstName='First'+IntToStr(id));
assert(people.LastName='Last'+IntToStr(id));
assert(people.YearOfBirth=id+1800);
assert(people.YearOfDeath=id+1825);
end;
assert(id=200);
people.Free; // release all memory used by the request
people := TSQLRecordPeople.CreateAndFillPrepare(client,
'YearOFBIRTH,Yearofdeath,id','',[]);
assert(people.InternalState=0);
id := 0;
while people.FillOne do begin
assert(people.InternalState=client.InternalState);
inc(id);
assert(people.ID=id);
assert(people.FirstName='');
assert(people.LastName='');
assert(people.YearOfBirth=id+1800);
assert(people.YearOfDeath=id+1825);
end;
assert(id=200);
people.Free; // release all memory used by the request
people := TSQLRecordPeople.CreateAndFillPrepare(client,'',
'yearofbirth=?',[1900]);
id := 0;
while people.FillOne do begin
assert(people.InternalState=client.InternalState);
inc(id);
assert(people.ID=100);
assert(people.FirstName='First100');
assert(people.LastName='Last100');
assert(people.YearOfBirth=1900);
assert(people.YearOfDeath=1925);
end;
assert(id=1);
for i := 1 to 200 do
if i and 15=0 then
client.Delete(TSQLRecordPeople,i) else
if i mod 82=0 then begin
people := TSQLRecordPeople.Create;
id := i+1;
people.ID := i;
people.FirstName := 'neversent';
people.LastName := 'neitherthisone';
people.YearOfBirth := id+1800;
people.YearOfDeath := id+1825;
assert(people.InternalState=0);
assert(client.Update(people,'YEarOFBIRTH,YEarOfDeath'));
assert(people.InternalState=client.InternalState);
end;
people := new TSQLRecordPeople;
assert(people.InternalState=0);
for i := 1 to 200 do begin
var read = client.Retrieve(i,people);
if i and 15=0 then
assert(not read) else begin
assert(read);
assert(people.InternalState=client.InternalState);
if i mod 82=0 then
id := i+1 else
id := i;
assert(people.ID=i);
assert(people.FirstName='First'+IntToStr(i));
assert(people.LastName='Last'+IntToStr(i));
assert(people.YearOfBirth=id+1800);
assert(people.YearOfDeath=id+1825);
end;
end;
people.Free;
end;
procedure SOATest(client: TSQLRestClientURI; onSuccess, onError: TSQLRestEvent);
var Calc: TServiceCalculator;
i: integer;
const SEX_TEXT: array[0..1] of string = ('Miss','Mister');
ITERATIONS = 50;
begin
Calc := TServiceCalculator.Create(client); // no need to free instance on SMS
assert(Calc.InstanceImplementation=sicShared);
assert(Calc.ServiceName='Calculator');
// first test synchronous / blocking mode
for i := 1 to ITERATIONS do
assert(calc._Add(i,i+1)=i*2+1);
for i := 1 to ITERATIONS do begin
var sex := TPeopleSexe(i and 1);
var name := 'Smith';
calc._ToText(i,'$',sex,name);
assert(sex=sFemale);
assert(name=format('$ %d for %s Smith',[i,SEX_TEXT[i and 1]]));
end;
var j: integer;
var rec: TTestCustomJSONArraySimpleArray;
for i := 1 to ITERATIONS do begin
var name := calc._RecordToText(rec);
if i=1 then
assert(name='{"F":"","G":[],"H":{"H1":0,"H2":"","H3":{"H3a":false,"H3b":null}},"I":"","J":[]}');
assert(length(Rec.F)=i);
for j := 1 to length(Rec.F) do
assert(Rec.F[j]='!');
assert(length(Rec.G)=i);
for j := 0 to high(Rec.G) do
assert(Rec.G[j]=IntToStr(j+1));
assert(Rec.H.H1=i);
assert(length(Rec.J)=i-1);
for j := 0 to high(Rec.J) do begin
assert(Rec.J[j].J1=j);
assert(Rec.J[j].J2<>'');
assert(Rec.J[j].J3=TRecordEnum(j mod (ord(high(TRecordEnum))+1)));
end;
end;
// code below is asynchronous, so more difficult to follow than synchronous !
i := 1; // need two Calc*Asynch() inlined lambdas to access var i
procedure CalcToTextAsynch(sexe: TPeopleSexe; name: string);
begin
assert(sexe=sFemale);
assert(name=format('$ %d for %s Smith',[i,SEX_TEXT[i and 1]]));
inc(i);
sexe := TPeopleSexe(i and 1);
name := 'Smith';
if i<=ITERATIONS then // recursive for i := 1 to ITERATIONS
Calc.ToText(i,'$',sexe,name,CalcToTextAsynch,onError) else
onSuccess(client);
end;
procedure CalcAddAsynch(res: integer);
begin
assert(res=i*2+1);
inc(i);
if i<=ITERATIONS then // recursive for i := 1 to ITERATIONS
Calc.Add(i,i+1,CalcAddAsynch,onError) else begin
i := 1;
Calc.ToText(i,'$',TPeopleSexe(i and 1),'Smith',CalcToTextAsynch,onError);
end;
end;
Calc.Add(i,i+1,CalcAddAsynch,onError);
end;
end.
| 31.150735 | 103 | 0.646288 |
83d2abd0f9b8c3f45f40d4ce632797d6b67a810f | 68,538 | pas | Pascal | Source/DcefB.Cef3.Interfaces.pas | bccsafe/DcefBrowser | 335a2de83aaab5888ff059f0021d0d965ba02954 | [
"Condor-1.1"
]
| 81 | 2015-01-11T08:38:26.000Z | 2018-06-28T10:00:05.000Z | Source/DcefB.Cef3.Interfaces.pas | TotteKarlsson/bcc_cef | 237bda30a96e5a7d9dc04d436312aecdf37d84b5 | [
"Condor-1.1"
]
| 11 | 2015-05-31T06:42:12.000Z | 2018-06-11T12:11:45.000Z | Source/DcefB.Cef3.Interfaces.pas | TotteKarlsson/bcc_cef | 237bda30a96e5a7d9dc04d436312aecdf37d84b5 | [
"Condor-1.1"
]
| 41 | 2015-01-07T09:17:39.000Z | 2018-06-04T09:43:19.000Z | (*
* Delphi Multi-tab Chromium Browser Frame
*
* Usage allowed under the restrictions of the Lesser GNU General Public License
* or alternatively the restrictions of the Mozilla Public License 1.1
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
*
* Unit owner : BccSafe <bccsafe5988@gmail.com>
* QQ : 1262807955
* Web site : http://www.bccsafe.com
* Repository : https://github.com/bccsafe/DcefBrowser
*
* The code of DcefBrowser is based on DCEF3 by: Henri Gourvest <hgourvest@gmail.com>
* code: https://github.com/hgourvest/dcef3
*
* Embarcadero Technologies, Inc is not permitted to use or redistribute
* this source code without explicit permission.
*
*)
unit DcefB.Cef3.Interfaces;
{$IFDEF FPC}
{$MODE DELPHI}{$H+}
{$ENDIF}
{$I DcefB.Dcef3.cef.inc}
interface
uses
Classes, DcefB.Cef3.Types, DcefB.Cef3.Api;
type
ICefBrowser = interface;
ICefFrame = interface;
ICefRequest = interface;
ICefv8Value = interface;
ICefDomVisitor = interface;
ICefDomDocument = interface;
ICefDomNode = interface;
ICefv8Context = interface;
ICefListValue = interface;
ICefBinaryValue = interface;
ICefDictionaryValue = interface;
ICefClient = interface;
ICefUrlrequestClient = interface;
ICefBrowserHost = interface;
ICefTask = interface;
ICefTaskRunner = interface;
ICefFileDialogCallback = interface;
ICefRequestContext = interface;
ICefDragData = interface;
ICefNavigationEntry = interface;
ICefSslInfo = interface;
ICefBase = interface
['{1F9A7B44-DCDC-4477-9180-3ADD44BDEB7B}']
function Wrap: Pointer;
end;
ICefRunFileDialogCallback = interface(ICefBase)
['{59FCECC6-E897-45BA-873B-F09586C4BE47}']
procedure OnFileDialogDismissed(selectedAcceptFilter: Integer; filePaths: TStrings);
end;
TCefRunFileDialogCallbackProc = {$IFDEF DELPHI12_UP}reference to{$ENDIF}
procedure(selectedAcceptFilter: Integer; filePaths: TStrings);
ICefNavigationEntryVisitor = interface(ICefBase)
['{CC4D6BC9-0168-4C2C-98BA-45E9AA9CD619}']
function visit(const entry: ICefNavigationEntry; current: Boolean;
index, total: Integer): Boolean;
end;
TCefNavigationEntryVisitorProc = {$IFDEF DELPHI12_UP}reference to {$ENDIF}
function(const entry: ICefNavigationEntry; current: Boolean;
index, total: Integer): Boolean;
TOnPdfPrintFinishedProc = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const path: ustring; ok: Boolean);
ICefPdfPrintCallback = interface(ICefBase)
['{F1CC58E9-2C30-4932-91AE-467C8D8EFB8E}']
procedure OnPdfPrintFinished(const path: ustring; ok: Boolean);
end;
ICefBrowserHost = interface(ICefBase)
['{53AE02FF-EF5D-48C3-A43E-069DA9535424}']
function GetBrowser: ICefBrowser;
procedure CloseBrowser(forceClose: Boolean);
procedure SetFocus(focus: Boolean);
procedure SetWindowVisibility(visible: Boolean);
function GetWindowHandle: TCefWindowHandle;
function GetOpenerWindowHandle: TCefWindowHandle;
function GetRequestContext: ICefRequestContext;
function GetZoomLevel: Double;
procedure SetZoomLevel(zoomLevel: Double);
procedure RunFileDialog(mode: TCefFileDialogMode; const title, defaultFilePath: ustring;
acceptFilters: TStrings; selectedAcceptFilter: Integer; const callback: ICefRunFileDialogCallback);
procedure RunFileDialogProc(mode: TCefFileDialogMode; const title, defaultFilePath: ustring;
acceptFilters: TStrings; selectedAcceptFilter: Integer; const callback: TCefRunFileDialogCallbackProc);
procedure StartDownload(const url: ustring);
procedure Print;
procedure PrintToPdf(const path: ustring; settings: PCefPdfPrintSettings; const callback: ICefPdfPrintCallback);
procedure PrintToPdfProc(const path: ustring; settings: PCefPdfPrintSettings; const callback: TOnPdfPrintFinishedProc);
procedure Find(identifier: Integer; const searchText: ustring; forward, matchCase, findNext: Boolean);
procedure StopFinding(clearSelection: Boolean);
procedure ShowDevTools(const windowInfo: PCefWindowInfo; const client: ICefClient;
const settings: PCefBrowserSettings; inspectElementAt: PCefPoint);
procedure CloseDevTools;
procedure GetNavigationEntries(const visitor: ICefNavigationEntryVisitor;
currentOnly: Boolean);
procedure GetNavigationEntriesProc(const proc
: TCefNavigationEntryVisitorProc; currentOnly: Boolean);
procedure SetMouseCursorChangeDisabled(disabled: Boolean);
function IsMouseCursorChangeDisabled: Boolean;
procedure ReplaceMisspelling(const word: ustring);
procedure AddWordToDictionary(const word: ustring);
function IsWindowRenderingDisabled: Boolean;
procedure WasResized;
procedure WasHidden(hidden: Boolean);
procedure NotifyScreenInfoChanged;
procedure invalidate(kind: TCefPaintElementType);
procedure SendKeyEvent(const event: PCefKeyEvent);
procedure SendMouseClickEvent(const event: PCefMouseEvent;
kind: TCefMouseButtonType; mouseUp: Boolean; clickCount: Integer);
procedure SendMouseMoveEvent(const event: PCefMouseEvent;
mouseLeave: Boolean);
procedure SendMouseWheelEvent(const event: PCefMouseEvent;
deltaX, deltaY: Integer);
procedure SendFocusEvent(setFocus: Boolean);
procedure SendCaptureLostEvent;
procedure NotifyMoveOrResizeStarted;
function GetWindowlessFrameRate(): Integer;
procedure SetWindowlessFrameRate(frameRate: Integer);
function GetNsTextInputContext: TCefTextInputContext;
procedure HandleKeyEventBeforeTextInputClient(keyEvent: TCefEventHandle);
procedure HandleKeyEventAfterTextInputClient(keyEvent: TCefEventHandle);
procedure DragTargetDragEnter(const dragData: ICefDragData;
const event: PCefMouseEvent; allowedOps: TCefDragOperations);
procedure DragTargetDragOver(const event: PCefMouseEvent;
allowedOps: TCefDragOperations);
procedure DragTargetDragLeave;
procedure DragTargetDrop(event: PCefMouseEvent);
procedure DragSourceEndedAt(x, y: Integer; op: TCefDragOperation);
procedure DragSourceSystemDragEnded;
property browser: ICefBrowser read GetBrowser;
property WindowHandle: TCefWindowHandle read GetWindowHandle;
property OpenerWindowHandle: TCefWindowHandle read GetOpenerWindowHandle;
property zoomLevel: Double read GetZoomLevel write SetZoomLevel;
property RequestContext: ICefRequestContext read GetRequestContext;
end;
ICefProcessMessage = interface(ICefBase)
['{E0B1001A-8777-425A-869B-29D40B8B93B1}']
function IsValid: Boolean;
function IsReadOnly: Boolean;
function copy: ICefProcessMessage;
function GetName: ustring;
function GetArgumentList: ICefListValue;
property Name: ustring read GetName;
property ArgumentList: ICefListValue read GetArgumentList;
end;
ICefBrowser = interface(ICefBase)
['{BA003C2E-CF15-458F-9D4A-FE3CEFCF3EEF}']
function GetHost: ICefBrowserHost;
function canGoBack: Boolean;
procedure GoBack;
function canGoForward: Boolean;
procedure GoForward;
function isLoading: Boolean;
procedure reload;
procedure ReloadIgnoreCache;
procedure StopLoad;
function GetIdentifier: Integer;
function IsSame(const that: ICefBrowser): Boolean;
function IsPopup: Boolean;
function HasDocument: Boolean;
function GetMainFrame: ICefFrame;
function GetFocusedFrame: ICefFrame;
function GetFrameByident(identifier: Int64): ICefFrame;
function GetFrame(const name: ustring): ICefFrame;
function GetFrameCount: NativeUInt;
procedure GetFrameIdentifiers(count: PNativeUInt; identifiers: PInt64);
procedure GetFrameNames(names: TStrings);
function SendProcessMessage(targetProcess: TCefProcessId;
message: ICefProcessMessage): Boolean;
property MainFrame: ICefFrame read GetMainFrame;
property FocusedFrame: ICefFrame read GetFocusedFrame;
property FrameCount: NativeUInt read GetFrameCount;
property host: ICefBrowserHost read GetHost;
property identifier: Integer read GetIdentifier;
end;
ICefPostDataElement = interface(ICefBase)
['{3353D1B8-0300-4ADC-8D74-4FF31C77D13C}']
function IsReadOnly: Boolean;
procedure SetToEmpty;
procedure SetToFile(const fileName: ustring);
procedure SetToBytes(size: NativeUInt; bytes: Pointer);
function GetType: TCefPostDataElementType;
function GetFile: ustring;
function GetBytesCount: NativeUInt;
function GetBytes(size: NativeUInt; bytes: Pointer): NativeUInt;
end;
ICefPostData = interface(ICefBase)
['{1E677630-9339-4732-BB99-D6FE4DE4AEC0}']
function IsReadOnly: Boolean;
function HasExcludedElements: Boolean;
function GetCount: NativeUInt;
function GetElements(count: NativeUInt): IInterfaceList;
// ICefPostDataElement
function RemoveElement(const element: ICefPostDataElement): Integer;
function AddElement(const element: ICefPostDataElement): Integer;
procedure RemoveElements;
end;
ICefStringMap = interface
['{A33EBC01-B23A-4918-86A4-E24A243B342F}']
function GetHandle: TCefStringMap;
function GetSize: Integer;
function find(const key: ustring): ustring;
function GetKey(index: Integer): ustring;
function GetValue(index: Integer): ustring;
procedure Append(const key, value: ustring);
procedure clear;
property Handle: TCefStringMap read GetHandle;
property size: Integer read GetSize;
property key[index: Integer]: ustring read GetKey;
property value[index: Integer]: ustring read GetValue;
end;
ICefStringMultimap = interface
['{583ED0C2-A9D6-4034-A7C9-20EC7E47F0C7}']
function GetHandle: TCefStringMultimap;
function GetSize: Integer;
function FindCount(const key: ustring): Integer;
function GetEnumerate(const key: ustring; ValueIndex: Integer): ustring;
function GetKey(index: Integer): ustring;
function GetValue(index: Integer): ustring;
procedure Append(const key, value: ustring);
procedure clear;
property Handle: TCefStringMap read GetHandle;
property size: Integer read GetSize;
property key[index: Integer]: ustring read GetKey;
property value[index: Integer]: ustring read GetValue;
property Enumerate[const key: ustring; ValueIndex: Integer]: ustring
read GetEnumerate;
end;
ICefRequest = interface(ICefBase)
['{FB4718D3-7D13-4979-9F4C-D7F6C0EC592A}']
function IsReadOnly: Boolean;
function GetUrl: ustring;
function GetMethod: ustring;
function GetPostData: ICefPostData;
procedure GetHeaderMap(const HeaderMap: ICefStringMultimap);
procedure SetUrl(const value: ustring);
procedure SetMethod(const value: ustring);
procedure SetReferrer(const referrerUrl: string; policy: TCefReferrerPolicy);
function GetReferrerUrl: string;
function GetReferrerPolicy: TCefReferrerPolicy;
procedure SetPostData(const value: ICefPostData);
procedure SetHeaderMap(const HeaderMap: ICefStringMultimap);
function GetFlags: TCefUrlRequestFlags;
procedure SetFlags(flags: TCefUrlRequestFlags);
function GetFirstPartyForCookies: ustring;
procedure SetFirstPartyForCookies(const url: ustring);
procedure Assign(const url, method: ustring;
const postData: ICefPostData; const headerMap: ICefStringMultimap);
function GetResourceType: TCefResourceType;
function GetTransitionType: TCefTransitionType;
function GetIdentifier: UInt64;
property Url: ustring read GetUrl write SetUrl;
property Method: ustring read GetMethod write SetMethod;
property ReferrerUrl: string read GetReferrerUrl;
property ReferrerPolicy: TCefReferrerPolicy read GetReferrerPolicy;
property PostData: ICefPostData read GetPostData write SetPostData;
property Flags: TCefUrlRequestFlags read GetFlags write SetFlags;
property FirstPartyForCookies: ustring read GetFirstPartyForCookies write SetFirstPartyForCookies;
property ResourceType: TCefResourceType read GetResourceType;
property TransitionType: TCefTransitionType read GetTransitionType;
property Identifier: UInt64 read GetIdentifier;
end;
TCefDomVisitorProc = {$IFDEF DELPHI12_UP}reference to
{$ENDIF} procedure(const document: ICefDomDocument);
TCefStringVisitorProc = {$IFDEF DELPHI12_UP}reference to
{$ENDIF} procedure(const str: ustring);
ICefStringVisitor = interface(ICefBase)
['{63ED4D6C-2FC8-4537-964B-B84C008F6158}']
procedure visit(const str: ustring);
end;
ICefFrame = interface(ICefBase)
['{8FD3D3A6-EA3A-4A72-8501-0276BD5C3D1D}']
function IsValid: Boolean;
procedure undo;
procedure redo;
procedure cut;
procedure copy;
procedure paste;
procedure del;
procedure SelectAll;
procedure ViewSource;
procedure GetSource(const visitor: ICefStringVisitor);
procedure GetSourceProc(const proc: TCefStringVisitorProc);
procedure GetText(const visitor: ICefStringVisitor);
procedure GetTextProc(const proc: TCefStringVisitorProc);
procedure LoadRequest(const request: ICefRequest);
procedure LoadUrl(const url: ustring);
procedure LoadString(const str, url: ustring);
procedure ExecuteJavaScript(const code, scriptUrl: ustring;
startLine: Integer);
function IsMain: Boolean;
function IsFocused: Boolean;
function GetName: ustring;
function GetIdentifier: Int64;
function GetParent: ICefFrame;
function GetUrl: ustring;
function GetBrowser: ICefBrowser;
function GetV8Context: ICefv8Context;
procedure VisitDom(const visitor: ICefDomVisitor);
procedure VisitDomProc(const proc: TCefDomVisitorProc);
property Name: ustring read GetName;
property url: ustring read GetUrl;
property browser: ICefBrowser read GetBrowser;
property Parent: ICefFrame read GetParent;
end;
ICefCustomStreamReader = interface(ICefBase)
['{BBCFF23A-6FE7-4C28-B13E-6D2ACA5C83B7}']
function read(ptr: Pointer; size, n: NativeUInt): NativeUInt;
function seek(offset: Int64; whence: Integer): Integer;
function tell: Int64;
function eof: Boolean;
function MayBlock: Boolean;
end;
ICefStreamReader = interface(ICefBase)
['{DD5361CB-E558-49C5-A4BD-D1CE84ADB277}']
function read(ptr: Pointer; size, n: NativeUInt): NativeUInt;
function seek(offset: Int64; whence: Integer): Integer;
function tell: Int64;
function eof: Boolean;
function MayBlock: Boolean;
end;
ICefWriteHandler = interface(ICefBase)
['{F2431888-4EAB-421E-9EC3-320BE695AF30}']
function write(const ptr: Pointer; size, n: NativeUInt): NativeUInt;
function seek(offset: Int64; whence: Integer): Integer;
function tell: Int64;
function flush: Integer;
function MayBlock: Boolean;
end;
ICefStreamWriter = interface(ICefBase)
['{4AA6C477-7D8A-4D5A-A704-67F900A827E7}']
function write(const ptr: Pointer; size, n: NativeUInt): NativeUInt;
function seek(offset: Int64; whence: Integer): Integer;
function tell: Int64;
function flush: Integer;
function MayBlock: Boolean;
end;
ICefResponse = interface(ICefBase)
['{E9C896E4-59A8-4B96-AB5E-6EA3A498B7F1}']
function IsReadOnly: Boolean;
function GetStatus: Integer;
procedure SetStatus(status: Integer);
function GetStatusText: ustring;
procedure SetStatusText(const StatusText: ustring);
function GetMimeType: ustring;
procedure SetMimeType(const mimetype: ustring);
function GetHeader(const name: ustring): ustring;
procedure GetHeaderMap(const headerMap: ICefStringMultimap);
procedure SetHeaderMap(const headerMap: ICefStringMultimap);
property Status: Integer read GetStatus write SetStatus;
property StatusText: ustring read GetStatusText write SetStatusText;
property MimeType: ustring read GetMimeType write SetMimeType;
end;
ICefDownloadItem = interface(ICefBase)
['{B34BD320-A82E-4185-8E84-B98E5EEC803F}']
function IsValid: Boolean;
function IsInProgress: Boolean;
function IsComplete: Boolean;
function IsCanceled: Boolean;
function GetCurrentSpeed: Int64;
function GetPercentComplete: Integer;
function GetTotalBytes: Int64;
function GetReceivedBytes: Int64;
function GetStartTime: TDateTime;
function GetEndTime: TDateTime;
function GetFullPath: ustring;
function GetId: Cardinal;
function GetUrl: ustring;
function GetOriginalUrl: ustring;
function GetSuggestedFileName: ustring;
function GetContentDisposition: ustring;
function GetMimeType: ustring;
property CurrentSpeed: Int64 read GetCurrentSpeed;
property PercentComplete: Integer read GetPercentComplete;
property TotalBytes: Int64 read GetTotalBytes;
property ReceivedBytes: Int64 read GetReceivedBytes;
property StartTime: TDateTime read GetStartTime;
property EndTime: TDateTime read GetEndTime;
property FullPath: ustring read GetFullPath;
property id: Cardinal read GetId;
property url: ustring read GetUrl;
property OriginalUrl: ustring read GetOriginalUrl;
property SuggestedFileName: ustring read GetSuggestedFileName;
property ContentDisposition: ustring read GetContentDisposition;
property mimeType: ustring read GetMimeType;
end;
ICefBeforeDownloadCallback = interface(ICefBase)
['{5A81AF75-CBA2-444D-AD8E-522160F36433}']
procedure cont(const downloadPath: ustring; showDialog: Boolean);
end;
ICefDownloadItemCallback = interface(ICefBase)
['{498F103F-BE64-4D5F-86B7-B37EC69E1735}']
procedure Cancel;
procedure Pause;
procedure Resume;
end;
ICefDownloadHandler = interface(ICefBase)
['{3137F90A-5DC5-43C1-858D-A269F28EF4F1}']
procedure OnBeforeDownload(const browser: ICefBrowser;
const downloadItem: ICefDownloadItem; const suggestedName: ustring;
const callback: ICefBeforeDownloadCallback);
procedure OnDownloadUpdated(const browser: ICefBrowser;
const downloadItem: ICefDownloadItem;
const callback: ICefDownloadItemCallback);
end;
ICefV8Exception = interface(ICefBase)
['{7E422CF0-05AC-4A60-A029-F45105DCE6A4}']
function GetMessage: ustring;
function GetSourceLine: ustring;
function GetScriptResourceName: ustring;
function GetLineNumber: Integer;
function GetStartPosition: Integer;
function GetEndPosition: Integer;
function GetStartColumn: Integer;
function GetEndColumn: Integer;
property Message: ustring read GetMessage;
property SourceLine: ustring read GetSourceLine;
property ScriptResourceName: ustring read GetScriptResourceName;
property LineNumber: Integer read GetLineNumber;
property StartPosition: Integer read GetStartPosition;
property EndPosition: Integer read GetEndPosition;
property StartColumn: Integer read GetStartColumn;
property EndColumn: Integer read GetEndColumn;
end;
ICefv8Context = interface(ICefBase)
['{2295A11A-8773-41F2-AD42-308C215062D9}']
function GetTaskRunner: ICefTaskRunner;
function IsValid: Boolean;
function GetBrowser: ICefBrowser;
function GetFrame: ICefFrame;
function GetGlobal: ICefv8Value;
function enter: Boolean;
function exit: Boolean;
function IsSame(const that: ICefv8Context): Boolean;
function eval(const code: ustring; var retval: ICefv8Value;
var exception: ICefV8Exception): Boolean;
property browser: ICefBrowser read GetBrowser;
property frame: ICefFrame read GetFrame;
property Global: ICefv8Value read GetGlobal;
end;
TCefv8ValueArray = array of ICefv8Value;
ICefv8Handler = interface(ICefBase)
['{F94CDC60-FDCB-422D-96D5-D2A775BD5D73}']
function execute(const name: ustring; const obj: ICefv8Value;
const arguments: TCefv8ValueArray; var retval: ICefv8Value;
var exception: ustring): Boolean;
end;
ICefV8Accessor = interface(ICefBase)
['{DCA6D4A2-726A-4E24-AA64-5E8C731D868A}']
function get(const name: ustring; const obj: ICefv8Value;
out value: ICefv8Value; const exception: ustring): Boolean;
function put(const name: ustring; const obj: ICefv8Value;
const value: ICefv8Value; const exception: ustring): Boolean;
end;
ICefTask = interface(ICefBase)
['{0D965470-4A86-47CE-BD39-A8770021AD7E}']
procedure execute;
end;
ICefTaskRunner = interface(ICefBase)
['{6A500FA3-77B7-4418-8EA8-6337EED1337B}']
function IsSame(const that: ICefTaskRunner): Boolean;
function BelongsToCurrentThread: Boolean;
function BelongsToThread(threadId: TCefThreadId): Boolean;
function PostTask(const task: ICefTask): Boolean; stdcall;
function PostDelayedTask(const task: ICefTask; delayMs: Int64): Boolean;
end;
ICefv8Value = interface(ICefBase)
['{52319B8D-75A8-422C-BD4B-16FA08CC7F42}']
function IsValid: Boolean;
function IsUndefined: Boolean;
function IsNull: Boolean;
function IsBool: Boolean;
function IsInt: Boolean;
function IsUInt: Boolean;
function IsDouble: Boolean;
function IsDate: Boolean;
function IsString: Boolean;
function IsObject: Boolean;
function IsArray: Boolean;
function IsFunction: Boolean;
function IsSame(const that: ICefv8Value): Boolean;
function GetBoolValue: Boolean;
function GetIntValue: Integer;
function GetUIntValue: Cardinal;
function GetDoubleValue: Double;
function GetDateValue: TDateTime;
function GetStringValue: ustring;
function IsUserCreated: Boolean;
function HasException: Boolean;
function GetException: ICefV8Exception;
function ClearException: Boolean;
function WillRethrowExceptions: Boolean;
function SetRethrowExceptions(rethrow: Boolean): Boolean;
function HasValueByKey(const key: ustring): Boolean;
function HasValueByIndex(index: Integer): Boolean;
function DeleteValueByKey(const key: ustring): Boolean;
function DeleteValueByIndex(index: Integer): Boolean;
function GetValueByKey(const key: ustring): ICefv8Value;
function GetValueByIndex(index: Integer): ICefv8Value;
function SetValueByKey(const key: ustring; const value: ICefv8Value;
attribute: TCefV8PropertyAttributes): Boolean;
function SetValueByIndex(index: Integer; const value: ICefv8Value): Boolean;
function SetValueByAccessor(const key: ustring;
settings: TCefV8AccessControls;
attribute: TCefV8PropertyAttributes): Boolean;
function GetKeys(const keys: TStrings): Integer;
function SetUserData(const data: ICefv8Value): Boolean;
function GetUserData: ICefv8Value;
function GetExternallyAllocatedMemory: Integer;
function AdjustExternallyAllocatedMemory(changeInBytes: Integer): Integer;
function GetArrayLength: Integer;
function GetFunctionName: ustring;
function GetFunctionHandler: ICefv8Handler;
function ExecuteFunction(const obj: ICefv8Value;
const arguments: TCefv8ValueArray): ICefv8Value;
function ExecuteFunctionWithContext(const context: ICefv8Context;
const obj: ICefv8Value; const arguments: TCefv8ValueArray): ICefv8Value;
end;
ICefV8StackFrame = interface(ICefBase)
['{BA1FFBF4-E9F2-4842-A827-DC220F324286}']
function IsValid: Boolean;
function GetScriptName: ustring;
function GetScriptNameOrSourceUrl: ustring;
function GetFunctionName: ustring;
function GetLineNumber: Integer;
function GetColumn: Integer;
function IsEval: Boolean;
function IsConstructor: Boolean;
property ScriptName: ustring read GetScriptName;
property ScriptNameOrSourceUrl: ustring read GetScriptNameOrSourceUrl;
property FunctionName: ustring read GetFunctionName;
property LineNumber: Integer read GetLineNumber;
property Column: Integer read GetColumn;
end;
ICefV8StackTrace = interface(ICefBase)
['{32111C84-B7F7-4E3A-92B9-7CA1D0ADB613}']
function IsValid: Boolean;
function GetFrameCount: Integer;
function GetFrame(index: Integer): ICefV8StackFrame;
property FrameCount: Integer read GetFrameCount;
property frame[index: Integer]: ICefV8StackFrame read GetFrame;
end;
ICefXmlReader = interface(ICefBase)
['{0DE686C3-A8D7-45D2-82FD-92F7F4E62A90}']
function MoveToNextNode: Boolean;
function close: Boolean;
function HasError: Boolean;
function GetError: ustring;
function GetType: TCefXmlNodeType;
function GetDepth: Integer;
function GetLocalName: ustring;
function GetPrefix: ustring;
function GetQualifiedName: ustring;
function GetNamespaceUri: ustring;
function GetBaseUri: ustring;
function GetXmlLang: ustring;
function IsEmptyElement: Boolean;
function HasValue: Boolean;
function GetValue: ustring;
function HasAttributes: Boolean;
function GetAttributeCount: NativeUInt;
function GetAttributeByIndex(index: Integer): ustring;
function GetAttributeByQName(const qualifiedName: ustring): ustring;
function GetAttributeByLName(const localName, namespaceURI
: ustring): ustring;
function GetInnerXml: ustring;
function GetOuterXml: ustring;
function GetLineNumber: Integer;
function MoveToAttributeByIndex(index: Integer): Boolean;
function MoveToAttributeByQName(const qualifiedName: ustring): Boolean;
function MoveToAttributeByLName(const localName, namespaceURI
: ustring): Boolean;
function MoveToFirstAttribute: Boolean;
function MoveToNextAttribute: Boolean;
function MoveToCarryingElement: Boolean;
end;
ICefZipReader = interface(ICefBase)
['{3B6C591F-9877-42B3-8892-AA7B27DA34A8}']
function MoveToFirstFile: Boolean;
function MoveToNextFile: Boolean;
function MoveToFile(const fileName: ustring;
caseSensitive: Boolean): Boolean;
function close: Boolean;
function GetFileName: ustring;
function GetFileSize: Int64;
function GetFileLastModified: TCefTime;
function OpenFile(const password: ustring): Boolean;
function CloseFile: Boolean;
function ReadFile(buffer: Pointer; bufferSize: NativeUInt): Integer;
function tell: Int64;
function eof: Boolean;
end;
ICefDomNode = interface(ICefBase)
['{96C03C9E-9C98-491A-8DAD-1947332232D6}']
function GetType: TCefDomNodeType;
function IsText: Boolean;
function IsElement: Boolean;
function IsEditable: Boolean;
function IsFormControlElement: Boolean;
function GetFormControlElementType: ustring;
function IsSame(const that: ICefDomNode): Boolean;
function GetName: ustring;
function GetValue: ustring;
function SetValue(const value: ustring): Boolean;
function GetAsMarkup: ustring;
function GetDocument: ICefDomDocument;
function GetParent: ICefDomNode;
function GetPreviousSibling: ICefDomNode;
function GetNextSibling: ICefDomNode;
function HasChildren: Boolean;
function GetFirstChild: ICefDomNode;
function GetLastChild: ICefDomNode;
function GetElementTagName: ustring;
function HasElementAttributes: Boolean;
function HasElementAttribute(const attrName: ustring): Boolean;
function GetElementAttribute(const attrName: ustring): ustring;
procedure GetElementAttributes(const attrMap: ICefStringMap);
function SetElementAttribute(const attrName, value: ustring): Boolean;
function GetElementInnerText: ustring;
property NodeType: TCefDomNodeType read GetType;
property Name: ustring read GetName;
property AsMarkup: ustring read GetAsMarkup;
property document: ICefDomDocument read GetDocument;
property Parent: ICefDomNode read GetParent;
property PreviousSibling: ICefDomNode read GetPreviousSibling;
property NextSibling: ICefDomNode read GetNextSibling;
property FirstChild: ICefDomNode read GetFirstChild;
property LastChild: ICefDomNode read GetLastChild;
property ElementTagName: ustring read GetElementTagName;
property ElementInnerText: ustring read GetElementInnerText;
end;
ICefDomDocument = interface(ICefBase)
['{08E74052-45AF-4F69-A578-98A5C3959426}']
function GetType: TCefDomDocumentType;
function GetDocument: ICefDomNode;
function GetBody: ICefDomNode;
function GetHead: ICefDomNode;
function GetTitle: ustring;
function GetElementById(const id: ustring): ICefDomNode;
function GetFocusedNode: ICefDomNode;
function HasSelection: Boolean;
function GetSelectionStartOffset: Integer;
function GetSelectionEndOffset: Integer;
function GetSelectionAsMarkup: ustring;
function GetSelectionAsText: ustring;
function GetBaseUrl: ustring;
function GetCompleteUrl(const partialURL: ustring): ustring;
property DocType: TCefDomDocumentType read GetType;
property document: ICefDomNode read GetDocument;
property Body: ICefDomNode read GetBody;
property Head: ICefDomNode read GetHead;
property title: ustring read GetTitle;
property FocusedNode: ICefDomNode read GetFocusedNode;
property SelectionStartOffset: Integer read GetSelectionStartOffset;
property SelectionEndOffset: Integer read GetSelectionEndOffset;
property SelectionAsMarkup: ustring read GetSelectionAsMarkup;
property SelectionAsText: ustring read GetSelectionAsText;
property BaseUrl: ustring read GetBaseUrl;
end;
ICefDomVisitor = interface(ICefBase)
['{30398428-3196-4531-B968-2DDBED36F6B0}']
procedure visit(const document: ICefDomDocument);
end;
ICefCookieVisitor = interface(ICefBase)
['{8378CF1B-84AB-4FDB-9B86-34DDABCCC402}']
function visit(const name, value, domain, path: ustring;
secure, httponly, hasExpires: Boolean; const creation, lastAccess,
expires: TDateTime; count, total: Integer;
out deleteCookie: Boolean): Boolean;
end;
ICefResourceBundleHandler = interface(ICefBase)
['{09C264FD-7E03-41E3-87B3-4234E82B5EA2}']
function GetLocalizedString(stringId: Integer;
out stringVal: ustring): Boolean;
function GetDataResource(resourceId: Integer; out data: Pointer;
out dataSize: NativeUInt): Boolean;
end;
ICefCommandLine = interface(ICefBase)
['{6B43D21B-0F2C-4B94-B4E6-4AF0D7669D8E}']
function IsValid: Boolean;
function IsReadOnly: Boolean;
function copy: ICefCommandLine;
procedure InitFromArgv(argc: Integer; const argv: PPAnsiChar);
procedure InitFromString(const commandLine: ustring);
procedure reset;
function GetCommandLineString: ustring;
procedure GetArgv(args: TStrings);
function GetProgram: ustring;
procedure SetProgram(const prog: ustring);
function HasSwitches: Boolean;
function HasSwitch(const name: ustring): Boolean;
function GetSwitchValue(const name: ustring): ustring;
procedure GetSwitches(switches: TStrings);
procedure AppendSwitch(const name: ustring);
procedure AppendSwitchWithValue(const name, value: ustring);
function HasArguments: Boolean;
procedure GetArguments(arguments: TStrings);
procedure AppendArgument(const argument: ustring);
procedure PrependWrapper(const wrapper: ustring);
property CommandLineString: ustring read GetCommandLineString;
end;
ICefBrowserProcessHandler = interface(ICefBase)
['{27291B7A-C0AE-4EE0-9115-15C810E22F6C}']
procedure OnContextInitialized;
procedure OnBeforeChildProcessLaunch(const commandLine: ICefCommandLine);
procedure OnRenderProcessThreadCreated(const extraInfo: ICefListValue);
end;
ICefSchemeRegistrar = interface(ICefBase)
['{1832FF6E-100B-4E8B-B996-AD633168BEE7}']
function AddCustomScheme(const schemeName: ustring;
IsStandard, IsLocal, IsDisplayIsolated: Boolean): Boolean; stdcall;
end;
ICefRenderProcessHandler = interface(ICefBase)
['{FADEE3BC-BF66-430A-BA5D-1EE3782ECC58}']
procedure OnRenderThreadCreated(const extraInfo: ICefListValue);
procedure OnWebKitInitialized;
procedure OnBrowserCreated(const browser: ICefBrowser);
procedure OnBrowserDestroyed(const browser: ICefBrowser);
procedure OnContextCreated(const browser: ICefBrowser;
const frame: ICefFrame; const context: ICefv8Context);
procedure OnContextReleased(const browser: ICefBrowser;
const frame: ICefFrame; const context: ICefv8Context);
procedure OnUncaughtException(const browser: ICefBrowser;
const frame: ICefFrame; const context: ICefv8Context;
const exception: ICefV8Exception; const stackTrace: ICefV8StackTrace);
procedure OnFocusedNodeChanged(const browser: ICefBrowser;
const frame: ICefFrame; const node: ICefDomNode);
function OnProcessMessageReceived(const browser: ICefBrowser;
sourceProcess: TCefProcessId; const message: ICefProcessMessage): Boolean;
end;
TOnRegisterCustomSchemes = {$IFDEF DELPHI12_UP}reference to
{$ENDIF} procedure(const registrar: ICefSchemeRegistrar);
TOnBeforeCommandLineProcessing = {$IFDEF DELPHI12_UP}reference to
{$ENDIF} procedure(const processType: ustring;
const commandLine: ICefCommandLine);
ICefApp = interface(ICefBase)
['{970CA670-9070-4642-B188-7D8A22DAEED4}']
procedure OnBeforeCommandLineProcessing(const processType: ustring;
const commandLine: ICefCommandLine);
procedure OnRegisterCustomSchemes(const registrar: ICefSchemeRegistrar);
function GetResourceBundleHandler: ICefResourceBundleHandler;
function GetBrowserProcessHandler: ICefBrowserProcessHandler;
function GetRenderProcessHandler: ICefRenderProcessHandler;
end;
TCefCookieVisitorProc = {$IFDEF DELPHI12_UP} reference to
{$ENDIF} function(const name, value, domain, path: ustring;
secure, httponly, hasExpires: Boolean; const creation, lastAccess,
expires: TDateTime; count, total: Integer;
out deleteCookie: Boolean): Boolean;
ICefCompletionCallback = interface(ICefBase)
['{A8ECCFBB-FEE0-446F-AB32-AD69A7478D57}']
procedure OnComplete;
end;
TCefCompletionCallbackProc = {$IFDEF DELPHI12_UP} reference to {$ENDIF} procedure;
ICefSetCookieCallback = interface(ICefBase)
['{16E14B6F-CB0A-4F9D-A008-239E0BC7B892}']
procedure OnComplete(success: Boolean);
end;
TCefSetCookieCallbackProc = {$IFDEF DELPHI12_UP} reference to {$ENDIF} procedure(success: Boolean);
ICefDeleteCookiesCallback = interface(ICefBase)
['{758B79A1-B9E8-4F0D-94A0-DCE5AFADE33D}']
procedure OnComplete(numDeleted: Integer);
end;
TCefDeleteCookiesCallbackProc = {$IFDEF DELPHI12_UP} reference to {$ENDIF} procedure(numDeleted: Integer);
ICefCookieManager = Interface(ICefBase)
['{CC1749E6-9AD3-4283-8430-AF6CBF3E8785}']
procedure SetSupportedSchemes(schemes: TStrings; const callback: ICefCompletionCallback);
procedure SetSupportedSchemesProc(schemes: TStrings; const callback: TCefCompletionCallbackProc);
function VisitAllCookies(const visitor: ICefCookieVisitor): Boolean;
function VisitAllCookiesProc(const visitor: TCefCookieVisitorProc): Boolean;
function VisitUrlCookies(const url: ustring;
includeHttpOnly: Boolean; const visitor: ICefCookieVisitor): Boolean;
function VisitUrlCookiesProc(const url: ustring;
includeHttpOnly: Boolean; const visitor: TCefCookieVisitorProc): Boolean;
function SetCookie(const url: ustring; const name, value, domain, path: ustring; secure, httponly,
hasExpires: Boolean; const creation, lastAccess, expires: TDateTime;
const callback: ICefSetCookieCallback): Boolean;
function SetCookieProc(const url: ustring; const name, value, domain, path: ustring; secure, httponly,
hasExpires: Boolean; const creation, lastAccess, expires: TDateTime;
const callback: TCefSetCookieCallbackProc): Boolean;
function DeleteCookies(const url, cookieName: ustring; const callback: ICefDeleteCookiesCallback): Boolean;
function DeleteCookiesProc(const url, cookieName: ustring; const callback: TCefDeleteCookiesCallbackProc): Boolean;
function SetStoragePath(const path: ustring; persistSessionCookies: Boolean; const callback: ICefCompletionCallback): Boolean;
function SetStoragePathProc(const path: ustring; persistSessionCookies: Boolean; const callback: TCefCompletionCallbackProc): Boolean;
function FlushStore(const handler: ICefCompletionCallback): Boolean;
function FlushStoreProc(const proc: TCefCompletionCallbackProc): Boolean;
end;
ICefWebPluginInfo = interface(ICefBase)
['{AA879E58-F649-44B1-AF9C-655FF5B79A02}']
function GetName: ustring;
function GetPath: ustring;
function GetVersion: ustring;
function GetDescription: ustring;
property Name: ustring read GetName;
property path: ustring read GetPath;
property Version: ustring read GetVersion;
property Description: ustring read GetDescription;
end;
ICefCallback = interface(ICefBase)
['{1B8C449F-E2D6-4B78-9BBA-6F47E8BCDF37}']
procedure cont;
procedure cancel;
end;
ICefResourceHandler = interface(ICefBase)
['{BD3EA208-AAAD-488C-BFF2-76993022F2B5}']
function ProcessRequest(const request: ICefRequest;
const callback: ICefCallback): Boolean;
procedure GetResponseHeaders(const response: ICefResponse;
out responseLength: Int64; out redirectUrl: ustring);
function ReadResponse(const dataOut: Pointer; bytesToRead: Integer;
var bytesRead: Integer; const callback: ICefCallback): Boolean;
function CanGetCookie(const cookie: PCefCookie): Boolean;
function CanSetCookie(const cookie: PCefCookie): Boolean;
procedure cancel;
end;
ICefSchemeHandlerFactory = interface(ICefBase)
['{4D9B7960-B73B-4EBD-9ABE-6C1C43C245EB}']
function New(const browser: ICefBrowser; const frame: ICefFrame;
const schemeName: ustring; const request: ICefRequest)
: ICefResourceHandler;
end;
ICefAuthCallback = interface(ICefBase)
['{500C2023-BF4D-4FF7-9C04-165E5C389131}']
procedure cont(const username, password: ustring);
procedure cancel;
end;
ICefJsDialogCallback = interface(ICefBase)
['{187B2156-9947-4108-87AB-32E559E1B026}']
procedure cont(success: Boolean; const userInput: ustring);
end;
ICefContextMenuParams = interface(ICefBase)
['{E31BFA9E-D4E2-49B7-A05D-20018C8794EB}']
function GetXCoord: Integer;
function GetYCoord: Integer;
function GetTypeFlags: TCefContextMenuTypeFlags;
function GetLinkUrl: ustring;
function GetUnfilteredLinkUrl: ustring;
function GetSourceUrl: ustring;
function HasImageContents: Boolean;
function GetPageUrl: ustring;
function GetFrameUrl: ustring;
function GetFrameCharset: ustring;
function GetMediaType: TCefContextMenuMediaType;
function GetMediaStateFlags: TCefContextMenuMediaStateFlags;
function GetSelectionText: ustring;
function GetMisspelledWord: ustring;
function GetDictionarySuggestions(const suggestions: TStringList): Boolean;
function IsEditable: Boolean;
function IsSpellCheckEnabled: Boolean;
function GetEditStateFlags: TCefContextMenuEditStateFlags;
function IsCustomMenu: Boolean;
function IsPepperMenu: Boolean;
property XCoord: Integer read GetXCoord;
property YCoord: Integer read GetYCoord;
property TypeFlags: TCefContextMenuTypeFlags read GetTypeFlags;
property LinkUrl: ustring read GetLinkUrl;
property UnfilteredLinkUrl: ustring read GetUnfilteredLinkUrl;
property SourceUrl: ustring read GetSourceUrl;
property PageUrl: ustring read GetPageUrl;
property FrameUrl: ustring read GetFrameUrl;
property FrameCharset: ustring read GetFrameCharset;
property MediaType: TCefContextMenuMediaType read GetMediaType;
property MediaStateFlags: TCefContextMenuMediaStateFlags
read GetMediaStateFlags;
property SelectionText: ustring read GetSelectionText;
property EditStateFlags: TCefContextMenuEditStateFlags
read GetEditStateFlags;
end;
ICefMenuModel = interface(ICefBase)
['{40AF19D3-8B4E-44B8-8F89-DEB5907FC495}']
function clear: Boolean;
function GetCount: Integer;
function AddSeparator: Boolean;
function AddItem(commandId: Integer; const text: ustring): Boolean;
function AddCheckItem(commandId: Integer; const text: ustring): Boolean;
function AddRadioItem(commandId: Integer; const text: ustring;
groupId: Integer): Boolean;
function AddSubMenu(commandId: Integer; const text: ustring): ICefMenuModel;
function InsertSeparatorAt(index: Integer): Boolean;
function InsertItemAt(index, commandId: Integer;
const text: ustring): Boolean;
function InsertCheckItemAt(index, commandId: Integer;
const text: ustring): Boolean;
function InsertRadioItemAt(index, commandId: Integer; const text: ustring;
groupId: Integer): Boolean;
function InsertSubMenuAt(index, commandId: Integer; const text: ustring)
: ICefMenuModel;
function remove(commandId: Integer): Boolean;
function RemoveAt(index: Integer): Boolean;
function GetIndexOf(commandId: Integer): Integer;
function GetCommandIdAt(index: Integer): Integer;
function SetCommandIdAt(index, commandId: Integer): Boolean;
function GetLabel(commandId: Integer): ustring;
function GetLabelAt(index: Integer): ustring;
function SetLabel(commandId: Integer; const text: ustring): Boolean;
function SetLabelAt(index: Integer; const text: ustring): Boolean;
function GetType(commandId: Integer): TCefMenuItemType;
function GetTypeAt(index: Integer): TCefMenuItemType;
function GetGroupId(commandId: Integer): Integer;
function GetGroupIdAt(index: Integer): Integer;
function SetGroupId(commandId, groupId: Integer): Boolean;
function SetGroupIdAt(index, groupId: Integer): Boolean;
function GetSubMenu(commandId: Integer): ICefMenuModel;
function GetSubMenuAt(index: Integer): ICefMenuModel;
function IsVisible(commandId: Integer): Boolean;
function isVisibleAt(index: Integer): Boolean;
function SetVisible(commandId: Integer; visible: Boolean): Boolean;
function SetVisibleAt(index: Integer; visible: Boolean): Boolean;
function IsEnabled(commandId: Integer): Boolean;
function IsEnabledAt(index: Integer): Boolean;
function SetEnabled(commandId: Integer; enabled: Boolean): Boolean;
function SetEnabledAt(index: Integer; enabled: Boolean): Boolean;
function IsChecked(commandId: Integer): Boolean;
function IsCheckedAt(index: Integer): Boolean;
function setChecked(commandId: Integer; checked: Boolean): Boolean;
function setCheckedAt(index: Integer; checked: Boolean): Boolean;
function HasAccelerator(commandId: Integer): Boolean;
function HasAcceleratorAt(index: Integer): Boolean;
function SetAccelerator(commandId, keyCode: Integer;
shiftPressed, ctrlPressed, altPressed: Boolean): Boolean;
function SetAcceleratorAt(index, keyCode: Integer;
shiftPressed, ctrlPressed, altPressed: Boolean): Boolean;
function RemoveAccelerator(commandId: Integer): Boolean;
function RemoveAcceleratorAt(index: Integer): Boolean;
function GetAccelerator(commandId: Integer; out keyCode: Integer;
out shiftPressed, ctrlPressed, altPressed: Boolean): Boolean;
function GetAcceleratorAt(index: Integer; out keyCode: Integer;
out shiftPressed, ctrlPressed, altPressed: Boolean): Boolean;
end;
ICefValue = interface(ICefBase)
['{66F9F439-B12B-4EC3-A945-91AE4EF4D4BA}']
function IsValid: Boolean;
function IsOwned: Boolean;
function IsReadOnly: Boolean;
function IsSame(const that: ICefValue): Boolean;
function IsEqual(const that: ICefValue): Boolean;
function Copy: ICefValue;
function GetType: TCefValueType;
function GetBool: Boolean;
function GetInt: Integer;
function GetDouble: Double;
function GetString: ustring;
function GetBinary: ICefBinaryValue;
function GetDictionary: ICefDictionaryValue;
function GetList: ICefListValue;
function SetNull: Boolean;
function SetBool(value: Integer): Boolean;
function SetInt(value: Integer): Boolean;
function SetDouble(value: Double): Boolean;
function SetString(const value: ustring): Boolean;
function SetBinary(const value: ICefBinaryValue): Boolean;
function SetDictionary(const value: ICefDictionaryValue): Boolean;
function SetList(const value: ICefListValue): Boolean;
end;
ICefBinaryValue = interface(ICefBase)
['{974AA40A-9C5C-4726-81F0-9F0D46D7C5B3}']
function IsValid: Boolean;
function IsOwned: Boolean;
function IsSame(const that: ICefBinaryValue): Boolean;
function IsEqual(const that: ICefBinaryValue): Boolean;
function Copy: ICefBinaryValue;
function GetSize: NativeUInt;
function GetData(buffer: Pointer; bufferSize, dataOffset: NativeUInt)
: NativeUInt;
end;
ICefDictionaryValue = interface(ICefBase)
['{B9638559-54DC-498C-8185-233EEF12BC69}']
function IsValid: Boolean;
function IsOwned: Boolean;
function IsReadOnly: Boolean;
function IsSame(const that: ICefDictionaryValue): Boolean;
function IsEqual(const that: ICefDictionaryValue): Boolean;
function Copy(excludeEmptyChildren: Boolean): ICefDictionaryValue;
function GetSize: NativeUInt;
function Clear: Boolean;
function HasKey(const key: ustring): Boolean;
function GetKeys(const keys: TStrings): Boolean;
function remove(const key: ustring): Boolean;
function GetType(const key: ustring): TCefValueType;
function GetValue(const key: ustring): ICefValue;
function GetBool(const key: ustring): Boolean;
function GetInt(const key: ustring): Integer;
function GetDouble(const key: ustring): Double;
function GetString(const key: ustring): ustring;
function GetBinary(const key: ustring): ICefBinaryValue;
function GetDictionary(const key: ustring): ICefDictionaryValue;
function GetList(const key: ustring): ICefListValue;
function SetValue(const key: ustring; const value: ICefValue): Boolean;
function SetNull(const key: ustring): Boolean;
function SetBool(const key: ustring; value: Boolean): Boolean;
function SetInt(const key: ustring; value: Integer): Boolean;
function SetDouble(const key: ustring; value: Double): Boolean;
function SetString(const key, value: ustring): Boolean;
function SetBinary(const key: ustring;
const value: ICefBinaryValue): Boolean;
function SetDictionary(const key: ustring;
const value: ICefDictionaryValue): Boolean;
function SetList(const key: ustring; const value: ICefListValue): Boolean;
end;
ICefListValue = interface(ICefBase)
['{09174B9D-0CC6-4360-BBB0-3CC0117F70F6}']
function IsValid: Boolean;
function IsOwned: Boolean;
function IsReadOnly: Boolean;
function IsSame(const that: ICefListValue): Boolean;
function IsEqual(const that: ICefListValue): Boolean;
function Copy: ICefListValue;
function SetSize(size: NativeUInt): Boolean;
function GetSize: NativeUInt;
function Clear: Boolean;
function Remove(index: Integer): Boolean;
function GetType(index: Integer): TCefValueType;
function GetValue(index: Integer): ICefValue;
function GetBool(index: Integer): Boolean;
function GetInt(index: Integer): Integer;
function GetDouble(index: Integer): Double;
function GetString(index: Integer): ustring;
function GetBinary(index: Integer): ICefBinaryValue;
function GetDictionary(index: Integer): ICefDictionaryValue;
function GetList(index: Integer): ICefListValue;
function SetValue(index: Integer; const value: ICefValue): Boolean;
function SetNull(index: Integer): Boolean;
function SetBool(index: Integer; value: Boolean): Boolean;
function SetInt(index, value: Integer): Boolean;
function SetDouble(index: Integer; value: Double): Boolean;
function SetString(index: Integer; const value: ustring): Boolean;
function SetBinary(index: Integer; const value: ICefBinaryValue): Boolean;
function SetDictionary(index: Integer; const value: ICefDictionaryValue): Boolean;
function SetList(index: Integer; const value: ICefListValue): Boolean;
end;
ICefLifeSpanHandler = interface(ICefBase)
['{0A3EB782-A319-4C35-9B46-09B2834D7169}']
function OnBeforePopup(const browser: ICefBrowser; const frame: ICefFrame;
const targetUrl, targetFrameName: ustring;
targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean;
var popupFeatures: TCefPopupFeatures;
var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings;
var noJavascriptAccess: Boolean): Boolean;
procedure OnAfterCreated(const browser: ICefBrowser);
procedure OnBeforeClose(const browser: ICefBrowser);
function RunModal(const browser: ICefBrowser): Boolean;
function DoClose(const browser: ICefBrowser): Boolean;
end;
ICefLoadHandler = interface(ICefBase)
['{2C63FB82-345D-4A5B-9858-5AE7A85C9F49}']
procedure OnLoadingStateChange(const browser: ICefBrowser;
isLoading, canGoBack, canGoForward: Boolean);
procedure OnLoadStart(const browser: ICefBrowser; const frame: ICefFrame);
procedure OnLoadEnd(const browser: ICefBrowser; const frame: ICefFrame;
httpStatusCode: Integer);
procedure OnLoadError(const browser: ICefBrowser; const frame: ICefFrame;
errorCode: Integer; const errorText, failedUrl: ustring);
end;
ICefRequestCallback = interface(ICefBase)
['{A35B8FD5-226B-41A8-A763-1940787D321C}']
procedure Cont(allow: Boolean);
procedure Cancel;
end;
ICefResponseFilter = interface(ICefBase)
['{5013BC3C-F1AE-407A-A571-A4C6B1D6831E}']
function InitFilter: Boolean;
function Filter(dataIn: Pointer; dataInSize, dataInRead: NativeUInt;
dataOut: Pointer; dataOutSize, dataOutWritten: NativeUInt): TCefResponseFilterStatus;
end;
ICefAllowCertificateErrorCallback = interface(ICefBase)
['{A28E92D1-CF5A-4703-9C2F-C97D88174489}']
procedure cont(allow: Boolean);
end;
ICefRequestHandler = interface(ICefBase)
['{050877A9-D1F8-4EB3-B58E-50DC3E3D39FD}']
function OnBeforeBrowse(const browser: ICefBrowser; const frame: ICefFrame;
const request: ICefRequest; isRedirect: Boolean): Boolean;
function OnOpenUrlFromTab(const browser: ICefBrowser; const frame: ICefFrame;
const targetUrl: ustring; targetDisposition: TCefWindowOpenDisposition;
userGesture: Boolean): Boolean;
function OnBeforeResourceLoad(const browser: ICefBrowser; const frame: ICefFrame;
const request: ICefRequest; const callback: ICefRequestCallback): TCefReturnValue;
function GetResourceHandler(const browser: ICefBrowser; const frame: ICefFrame;
const request: ICefRequest): ICefResourceHandler;
procedure OnResourceRedirect(const browser: ICefBrowser; const frame: ICefFrame;
const request: ICefRequest; var newUrl: ustring);
function OnResourceResponse(const browser: ICefBrowser; const frame: ICefFrame;
const request: ICefRequest; const response: ICefResponse): Boolean;
function GetResourceResponseFilter(const browser: ICefBrowser; const frame: ICefFrame;
const request: ICefRequest; const response: ICefResponse): ICefResponseFilter;
procedure OnResourceLoadComplete(const browser: ICefBrowser; const frame: ICefFrame;
const request: ICefRequest; const response: ICefResponse; status: TCefUrlRequestStatus;
receivedContentLength: Int64);
function GetAuthCredentials(const browser: ICefBrowser; const frame: ICefFrame;
isProxy: Boolean; const host: ustring; port: Integer; const realm, scheme: ustring;
const callback: ICefAuthCallback): Boolean;
function OnQuotaRequest(const browser: ICefBrowser;
const originUrl: ustring; newSize: Int64; const callback: ICefRequestCallback): Boolean;
procedure OnProtocolExecution(const browser: ICefBrowser; const url: ustring; out allowOsExecution: Boolean);
function OnCertificateError(const browser: ICefBrowser; certError: TCefErrorcode;
const requestUrl: ustring; const sslInfo: ICefSslInfo; const callback: ICefRequestCallback): Boolean;
procedure OnPluginCrashed(const browser: ICefBrowser; const pluginPath: ustring);
procedure OnRenderViewReady(const browser: ICefBrowser);
procedure OnRenderProcessTerminated(const browser: ICefBrowser; status: TCefTerminationStatus);
end;
ICefDisplayHandler = interface(ICefBase)
['{1EC7C76D-6969-41D1-B26D-079BCFF054C4}']
procedure OnAddressChange(const browser: ICefBrowser; const frame: ICefFrame; const url: ustring);
procedure OnTitleChange(const browser: ICefBrowser; const title: ustring);
procedure OnFaviconUrlChange(const browser: ICefBrowser; icon_urls: TStrings);
procedure OnFullScreenModeChange(const browser: ICefBrowser; fullscreen: Boolean);
function OnTooltip(const browser: ICefBrowser; var text: ustring): Boolean;
procedure OnStatusMessage(const browser: ICefBrowser; const value: ustring);
function OnConsoleMessage(const browser: ICefBrowser; const message, source: ustring; line: Integer): Boolean;
end;
ICefFocusHandler = interface(ICefBase)
['{BB7FA3FA-7B1A-4ADC-8E50-12A24018DD90}']
procedure OnTakeFocus(const browser: ICefBrowser; next: Boolean);
function OnSetFocus(const browser: ICefBrowser;
source: TCefFocusSource): Boolean;
procedure OnGotFocus(const browser: ICefBrowser);
end;
ICefKeyboardHandler = interface(ICefBase)
['{0512F4EC-ED88-44C9-90D3-5C6D03D3B146}']
function OnPreKeyEvent(const browser: ICefBrowser;
const event: PCefKeyEvent; osEvent: TCefEventHandle;
out isKeyboardShortcut: Boolean): Boolean;
function OnKeyEvent(const browser: ICefBrowser; const event: PCefKeyEvent;
osEvent: TCefEventHandle): Boolean;
end;
ICefJsDialogHandler = interface(ICefBase)
['{64E18F86-DAC5-4ED1-8589-44DE45B9DB56}']
function OnJsdialog(const browser: ICefBrowser;
const originUrl, acceptLang: ustring; dialogType: TCefJsDialogType;
const messageText, defaultPromptText: ustring;
callback: ICefJsDialogCallback; out suppressMessage: Boolean): Boolean;
function OnBeforeUnloadDialog(const browser: ICefBrowser;
const messageText: ustring; isReload: Boolean;
const callback: ICefJsDialogCallback): Boolean;
procedure OnResetDialogState(const browser: ICefBrowser);
procedure OnDialogClosed(const browser: ICefBrowser);
end;
ICefRunContextMenuCallback = interface(ICefBase)
['{44C3C6E3-B64D-4F6E-A318-4A0F3A72EB00}']
procedure Cont(commandId: Integer; eventFlags: TCefEventFlags);
procedure Cancel;
end;
ICefContextMenuHandler = interface(ICefBase)
['{C2951895-4087-49D5-BA18-4D9BA4F5EDD7}']
procedure OnBeforeContextMenu(const browser: ICefBrowser; const frame: ICefFrame;
const params: ICefContextMenuParams; const model: ICefMenuModel);
function RunContextMenu(const browser: ICefBrowser; const frame: ICefFrame;
const params: ICefContextMenuParams; const model: ICefMenuModel;
const callback: ICefRunContextMenuCallback): Boolean;
function OnContextMenuCommand(const browser: ICefBrowser; const frame: ICefFrame;
const params: ICefContextMenuParams; commandId: Integer;
eventFlags: TCefEventFlags): Boolean;
procedure OnContextMenuDismissed(const browser: ICefBrowser; const frame: ICefFrame);
end;
ICefDialogHandler = interface(ICefBase)
['{7763F4B2-8BE1-4E80-AC43-8B825850DC67}']
function OnFileDialog(const browser: ICefBrowser; mode: TCefFileDialogMode;
const title, defaultFilePath: ustring; acceptFilters: TStrings;
selectedAcceptFilter: Integer; const callback: ICefFileDialogCallback): Boolean;
end;
ICefGeolocationCallback = interface(ICefBase)
['{272B8E4F-4AE4-4F14-BC4E-5924FA0C149D}']
procedure cont(allow: Boolean);
end;
ICefGeolocationHandler = interface(ICefBase)
['{1178EE62-BAE7-4E44-932B-EAAC7A18191C}']
function OnRequestGeolocationPermission(const browser: ICefBrowser;
const requestingUrl: ustring; requestId: Integer;
const callback: ICefGeolocationCallback): Boolean;
procedure OnCancelGeolocationPermission(const browser: ICefBrowser; requestId: Integer);
end;
ICefRenderHandler = interface(ICefBase)
['{1FC1C22B-085A-4741-9366-5249B88EC410}']
function GetRootScreenRect(const browser: ICefBrowser;
rect: PCefRect): Boolean;
function GetViewRect(const browser: ICefBrowser; rect: PCefRect): Boolean;
function GetScreenPoint(const browser: ICefBrowser; viewX, viewY: Integer;
screenX, screenY: PInteger): Boolean;
function GetScreenInfo(const browser: ICefBrowser;
screenInfo: PCefScreenInfo): Boolean;
procedure OnPopupShow(const browser: ICefBrowser; show: Boolean);
procedure OnPopupSize(const browser: ICefBrowser; const rect: PCefRect);
procedure OnPaint(const browser: ICefBrowser; kind: TCefPaintElementType;
dirtyRectsCount: NativeUInt; const dirtyRects: PCefRectArray;
const buffer: Pointer; width, height: Integer);
procedure OnCursorChange(const browser: ICefBrowser;
cursor: TCefCursorHandle; CursorType: TCefCursorType;
const customCursorInfo: PCefCursorInfo);
function OnStartDragging(const browser: ICefBrowser;
const dragData: ICefDragData; allowedOps: TCefDragOperations;
x, y: Integer): Boolean;
procedure OnUpdateDragCursor(const browser: ICefBrowser;
operation: TCefDragOperation);
procedure OnScrollOffsetChanged(const browser: ICefBrowser; x, y: Double);
end;
ICefClient = interface(ICefBase)
['{1D502075-2FF0-4E13-A112-9E541CD811F4}']
function GetContextMenuHandler: ICefContextMenuHandler;
function GetDisplayHandler: ICefDisplayHandler;
function GetDownloadHandler: ICefDownloadHandler;
function GetFocusHandler: ICefFocusHandler;
function GetGeolocationHandler: ICefGeolocationHandler;
function GetJsdialogHandler: ICefJsDialogHandler;
function GetKeyboardHandler: ICefKeyboardHandler;
function GetLifeSpanHandler: ICefLifeSpanHandler;
function GetLoadHandler: ICefLoadHandler;
function GetRenderHandler: ICefRenderHandler;
function GetRequestHandler: ICefRequestHandler;
function OnProcessMessageReceived(const browser: ICefBrowser;
sourceProcess: TCefProcessId; const message: ICefProcessMessage): Boolean;
end;
ICefUrlRequest = interface(ICefBase)
['{59226AC1-A0FA-4D59-9DF4-A65C42391A67}']
function GetRequest: ICefRequest;
function GetRequestStatus: TCefUrlRequestStatus;
function GetRequestError: Integer;
function GetResponse: ICefResponse;
procedure cancel;
end;
ICefUrlrequestClient = interface(ICefBase)
['{114155BD-C248-4651-9A4F-26F3F9A4F737}']
procedure OnRequestComplete(const request: ICefUrlRequest);
procedure OnUploadProgress(const request: ICefUrlRequest;
current, total: UInt64);
procedure OnDownloadProgress(const request: ICefUrlRequest;
current, total: UInt64);
procedure OnDownloadData(const request: ICefUrlRequest; data: Pointer;
dataLength: NativeUInt);
function OnGetAuthCredentials(isProxy: Boolean; const host: ustring;
port: Integer; const realm, scheme: ustring;
const callback: ICefAuthCallback): Boolean;
end;
ICefWebPluginInfoVisitor = interface(ICefBase)
['{7523D432-4424-4804-ACAD-E67D2313436E}']
function visit(const info: ICefWebPluginInfo;
count, total: Integer): Boolean;
end;
ICefWebPluginUnstableCallback = interface(ICefBase)
['{67459829-EB47-4B7E-9D69-2EE77DF0E71E}']
procedure IsUnstable(const path: ustring; unstable: Boolean);
end;
ICefEndTracingCallback = interface(ICefBase)
['{79020EBE-9D1D-49A6-9714-8778FE8929F2}']
procedure OnEndTracingComplete(const tracingFile: ustring);
end;
ICefGetGeolocationCallback = interface(ICefBase)
['{ACB82FD9-3FFD-43F9-BF1A-A4849BF5B814}']
procedure OnLocationUpdate(const position: PCefGeoposition);
end;
ICefFileDialogCallback = interface(ICefBase)
['{1AF659AB-4522-4E39-9C52-184000D8E3C7}']
procedure Cont(selectedAcceptFilter: Integer; filePaths: TStrings);
procedure cancel;
end;
ICefDragData = interface(ICefBase)
['{FBB6A487-F633-4055-AB3E-6619EDE75683}']
function clone: ICefDragData;
function IsReadOnly: Boolean;
function IsLink: Boolean;
function IsFragment: Boolean;
function IsFile: Boolean;
function GetLinkUrl: ustring;
function GetLinkTitle: ustring;
function GetLinkMetadata: ustring;
function GetFragmentText: ustring;
function GetFragmentHtml: ustring;
function GetFragmentBaseUrl: ustring;
function GetFileName: ustring;
function GetFileContents(const writer: ICefStreamWriter): NativeUInt;
function GetFileNames(names: TStrings): Integer;
procedure SetLinkUrl(const url: ustring);
procedure SetLinkTitle(const title: ustring);
procedure SetLinkMetadata(const data: ustring);
procedure SetFragmentText(const text: ustring);
procedure SetFragmentHtml(const html: ustring);
procedure SetFragmentBaseUrl(const BaseUrl: ustring);
procedure ResetFileContents;
procedure AddFile(const path, displayName: ustring);
end;
ICefDragHandler = interface(ICefBase)
['{59A89579-5B18-489F-A25C-5CC25FF831FC}']
function OnDragEnter(const browser: ICefBrowser; const dragData: ICefDragData;
mask: TCefDragOperations): Boolean;
procedure OnDraggableRegionsChanged(const browser: ICefBrowser;
regionsCount: NativeUInt; regions: PCefDraggableRegionArray);
end;
ICefFindHandler = interface(ICefBase)
['{F20DF234-BD43-42B3-A80B-D354A9E5B787}']
procedure OnFindResult(const browser: ICefBrowser;
identifier, count: Integer; const selectionRect: PCefRect;
activeMatchOrdinal: Integer; finalUpdate: Boolean);
end;
ICefRequestContextHandler = interface(ICefBase)
['{76EB1FA7-78DF-4FD5-ABB3-1CDD3E73A140}']
function GetCookieManager: ICefCookieManager;
function OnBeforePluginLoad(const mimeType, pluginUrl, topOriginUrl: ustring;
const pluginInfo: ICefWebPluginInfo; pluginPolicy: PCefPluginPolicy): Boolean;
end;
ICefResolveCallback = interface(ICefBase)
['{0C0EA252-7968-4163-A1BE-A1453576DD06}']
procedure OnResolveCompleted(result: TCefErrorCode; resolvedIps: TStrings);
end;
ICefRequestContext = interface(ICefBase)
['{5830847A-2971-4BD5-ABE6-21451F8923F7}']
function IsSame(const other: ICefRequestContext): Boolean;
function IsSharingWith(const other: ICefRequestContext): Boolean;
function IsGlobal: Boolean;
function GetHandler: ICefRequestContextHandler;
function GetCachePath: ustring;
function GetDefaultCookieManager(const callback: ICefCompletionCallback): ICefCookieManager;
function GetDefaultCookieManagerProc(const callback: TCefCompletionCallbackProc): ICefCookieManager;
function RegisterSchemeHandlerFactory(const schemeName, domainName: ustring;
const factory: ICefSchemeHandlerFactory): Boolean;
function ClearSchemeHandlerFactories: Boolean;
procedure PurgePluginListCache(reloadPages: Boolean);
function HasPreference(const name: ustring): Boolean;
function GetPreference(const name: ustring): ICefValue;
function GetAllPreferences(includeDefaults: Boolean): ICefDictionaryValue;
function CanSetPreference(const name: ustring): Boolean;
function SetPreference(const name: ustring; const value: ICefValue; out error: ustring): Boolean;
procedure ClearCertificateExceptions(const callback: ICefCompletionCallback);
procedure CloseAllConnections(const callback: ICefCompletionCallback);
procedure ResolveHost(const origin: ustring; const callback: ICefResolveCallback);
function ResolveHostCached(const origin: ustring; resolvedIps: TStrings): TCefErrorCode;
end;
ICefPrintSettings = Interface(ICefBase)
['{ACBD2395-E9C1-49E5-B7F3-344DAA4A0F12}']
function IsValid: Boolean;
function IsReadOnly: Boolean;
function copy: ICefPrintSettings;
procedure SetOrientation(landscape: Boolean);
function IsLandscape: Boolean;
procedure SetPrinterPrintableArea(const physicalSizeDeviceUnits: PCefSize;
const printableAreaDeviceUnits: PCefRect;
landscapeNeedsFlip: Boolean); stdcall;
procedure SetDeviceName(const name: ustring);
function GetDeviceName: ustring;
procedure SetDpi(dpi: Integer);
function GetDpi: Integer;
procedure SetPageRanges(const ranges: TCefPageRangeArray);
function GetPageRangesCount: NativeUInt;
procedure GetPageRanges(out ranges: TCefPageRangeArray);
procedure SetSelectionOnly(selectionOnly: Boolean);
function IsSelectionOnly: Boolean;
procedure SetCollate(collate: Boolean);
function WillCollate: Boolean;
procedure SetColorModel(model: TCefColorModel);
function GetColorModel: TCefColorModel;
procedure SetCopies(copies: Integer);
function GetCopies: Integer;
procedure SetDuplexMode(mode: TCefDuplexMode);
function GetDuplexMode: TCefDuplexMode;
property landscape: Boolean read IsLandscape write SetOrientation;
property DeviceName: ustring read GetDeviceName write SetDeviceName;
property dpi: Integer read GetDpi write SetDpi;
property selectionOnly: Boolean read IsSelectionOnly write SetSelectionOnly;
property collate: Boolean read WillCollate write SetCollate;
property ColorModel: TCefColorModel read GetColorModel write SetColorModel;
property copies: Integer read GetCopies write SetCopies;
property DuplexMode: TCefDuplexMode read GetDuplexMode write SetDuplexMode;
end;
ICefNavigationEntry = interface(ICefBase)
['{D17B4B37-AA45-42D9-B4E4-AAB6FE2AB297}']
function IsValid: Boolean;
function GetUrl: ustring;
function GetDisplayUrl: ustring;
function GetOriginalUrl: ustring;
function GetTitle: ustring;
function GetTransitionType: TCefTransitionType;
function HasPostData: Boolean;
function GetCompletionTime: TDateTime;
function GetHttpStatusCode: Integer;
property url: ustring read GetUrl;
property DisplayUrl: ustring read GetDisplayUrl;
property OriginalUrl: ustring read GetOriginalUrl;
property title: ustring read GetTitle;
property TransitionType: TCefTransitionType read GetTransitionType;
property CompletionTime: TDateTime read GetCompletionTime;
property httpStatusCode: Integer read GetHttpStatusCode;
end;
ICefSslCertPrincipal = interface(ICefBase)
['{A0B083E1-51D3-4753-9FDD-9ADF75C3E68B}']
function GetDisplayName: ustring;
function GetCommonName: ustring;
function GetLocalityName: ustring;
function GetStateOrProvinceName: ustring;
function GetCountryName: ustring;
procedure GetStreetAddresses(addresses: TStrings);
procedure GetOrganizationNames(names: TStrings);
procedure GetOrganizationUnitNames(names: TStrings);
procedure GetDomainComponents(components: TStrings);
end;
ICefSslInfo = interface(ICefBase)
['{67EC86BD-DE7D-453D-908F-AD15626C514F}']
function GetCertStatus: TCefCertStatus;
function IsCertStatusError: Boolean;
function IsCertStatusMinorError: Boolean;
function GetSubject: ICefSslCertPrincipal;
function GetIssuer: ICefSslCertPrincipal;
function GetSerialNumber: ICefBinaryValue;
function GetValidStart: TCefTime;
function GetValidExpiry: TCefTime;
function GetDerEncoded: ICefBinaryValue;
function GetPemEncoded: ICefBinaryValue;
function GetIssuerChainSize: NativeUInt;
function GetDEREncodedIssuerChain(chainCount: NativeUInt): IInterfaceList;
function GetPEMEencodedIssuerChain(chainCount: NativeUInt): IInterfaceList;
end;
ICefResourceBundle = interface(ICefBase)
['{3213CF97-C854-452B-B615-39192F8D07DC}']
function GetLocalizedString(stringId: Integer): ustring;
function GetDataResource(resourceId: Integer;
out data: Pointer; out dataSize: NativeUInt): Boolean;
function GetDataResourceForScale(resourceId: Integer; scaleFactor: TCefScaleFactor;
out data: Pointer; out dataSize: NativeUInt): Boolean;
end;
ICefMenuModelDelegate = interface(ICefBase)
['{1430D202-2795-433E-9A35-C79A0996F316}']
procedure ExecuteCommand(const menuModel: ICefMenuModel; commandId: Integer;
eventFlags: TCefEventFlags);
procedure MenuWillShow(const menuModel: ICefMenuModel);
end;
implementation
end.
| 43.822251 | 138 | 0.763751 |
f11eaa1e35aee638c8245c7541f0b9a0bd761215 | 6,165 | pas | Pascal | 3rdparty/Indy10/Lib/Core/IdCoreDsnRegister.pas | RazZziel/soldat | 1eae85d007f5e52f34a32c474e5a277a021292f1 | [
"MIT"
]
| 2 | 2020-10-08T16:54:52.000Z | 2021-03-15T21:21:32.000Z | 3rdparty/Indy10/Lib/Core/IdCoreDsnRegister.pas | xyproto/soldat | 2280296ac56883f6a9cad4da48025af8ae7782e7 | [
"MIT"
]
| null | null | null | 3rdparty/Indy10/Lib/Core/IdCoreDsnRegister.pas | xyproto/soldat | 2280296ac56883f6a9cad4da48025af8ae7782e7 | [
"MIT"
]
| 2 | 2021-01-11T17:49:23.000Z | 2021-01-19T19:57:21.000Z | {
$Project$
$Workfile$
$Revision$
$DateUTC$
$Id$
This file is part of the Indy (Internet Direct) project, and is offered
under the dual-licensing agreement described on the Indy website.
(http://www.indyproject.org/)
Copyright:
(c) 1993-2005, Chad Z. Hower and the Indy Pit Crew. All rights reserved.
}
{
$Log$
}
{
Rev 1.4 12/10/2004 15:36:40 HHariri
Fix so it works with D8 too
Rev 1.3 9/5/2004 2:08:14 PM JPMugaas
Should work in D9 NET.
Rev 1.2 2/3/2004 11:42:52 AM JPMugaas
Fixed for new design.
Rev 1.1 2/1/2004 2:44:20 AM JPMugaas
Bindings editor should be fully functional including IPv6 support.
Rev 1.0 11/13/2002 08:41:18 AM JPMugaas
}
unit IdCoreDsnRegister;
interface
{$I IdCompilerDefines.inc}
uses
{$IFDEF DOTNET}
Borland.Vcl.Design.DesignIntF,
Borland.Vcl.Design.DesignEditors
{$ELSE}
{$IFDEF FPC}
PropEdits,
ComponentEditors
{$ELSE}
{$IFDEF VCL_6_OR_ABOVE}
DesignIntf,
DesignEditors
{$ELSE}
Dsgnintf
{$ENDIF}
{$ENDIF}
{$ENDIF}
;
type
{$IFDEF FPC}
TIdBaseComponentEditor = class(TDefaultComponentEditor)
{$ELSE}
TIdBaseComponentEditor = class(TDefaultEditor)
{$ENDIF}
public
procedure ExecuteVerb(Index: Integer); override;
function GetVerb(Index: Integer): string; override;
function GetVerbCount: Integer; override;
end;
{$IFDEF FPC}
TIdPropEdBinding = class(TPropertyEditor)
protected
FValue : String;
property Value : String read FValue write FValue;
{$ELSE}
TIdPropEdBinding = class(TClassProperty)
{$ENDIF}
public
procedure Edit; override;
function GetAttributes: TPropertyAttributes; override;
function GetValue: string; override;
procedure SetValue(const Value: string); override;
end;
// Procs
procedure Register;
implementation
uses
Classes,
{$IFDEF WIDGET_WINFORMS}
IdDsnPropEdBindingNET,
IdAboutDotNET,
{$ELSE}
IdDsnPropEdBindingVCL,
IdAboutVCL,
{$ENDIF}
{$IFDEF DCC}
{$IFDEF VCL_2005_OR_ABOVE}
ToolsAPI,
SysUtils,
{$ENDIF}
{$ENDIF}
IdDsnCoreResourceStrings,
IdBaseComponent,
IdComponent,
IdGlobal,
IdStack,
IdSocketHandle;
{
Design Note: It turns out that in DotNET, there are no services file functions and
IdPorts does not work as expected in DotNET. It is probably possible to read the
services file ourselves but that creates some portability problems as the placement
is different in every operating system.
e.g.
Linux and Unix-like systems - /etc
Windows 95, 98, and ME - c:\windows
Windows NT systems - c:\winnt\system32\drivers\etc
Thus, it will undercut whatever benefit we could get with DotNET.
About the best I could think of is to use an edit control because
we can't offer anything from the services file in DotNET.
TODO: Maybe there might be a way to find the location in a more elegant
manner than what I described.
}
type
{$IFDEF WIDGET_WINFORMS}
TIdPropEdBindingEntry = TIdDsnPropEdBindingNET;
{$ELSE}
TIdPropEdBindingEntry = TIdDsnPropEdBindingVCL;
{$ENDIF}
procedure TIdPropEdBinding.Edit;
var
pSockets: TIdSocketHandles;
pEntry: TIdPropEdBindingEntry;
begin
inherited Edit;
{$IFNDEF DOTNET}
pSockets := TIdSocketHandles(
{$IFDEF CPU64}
GetInt64Value
{$ELSE}
GetOrdValue
{$ENDIF}
);
{$ELSE}
pSockets := GetObjValue as TIdSocketHandles;
{$ENDIF}
pEntry := TIdPropEdBindingEntry.Create;
try
pEntry.Caption := TComponent(GetComponent(0)).Name;
pEntry.DefaultPort := pSockets.DefaultPort;
Value := GetListValues(pSockets);
pEntry.SetList(Value);
if pEntry.Execute then
begin
Value := pEntry.GetList;
FillHandleList(Value, pSockets);
end;
finally
pEntry.Free;
end;
end;
function TIdPropEdBinding.GetAttributes: TPropertyAttributes;
begin
Result := inherited GetAttributes + [paDialog];
end;
function TIdPropEdBinding.GetValue: string;
var
pSockets: TIdSocketHandles;
begin
{$IFNDEF DOTNET}
pSockets := TIdSocketHandles(
{$IFDEF CPU64}
GetInt64Value
{$ELSE}
GetOrdValue
{$ENDIF}
);
{$ELSE}
pSockets := GetObjValue as TIdSocketHandles;
{$ENDIF}
Result := GetListValues(pSockets);
end;
procedure TIdPropEdBinding.SetValue(const Value: string);
var
pSockets: TIdSocketHandles;
begin
inherited SetValue(Value);
{$IFNDEF DOTNET}
pSockets := TIdSocketHandles(
{$IFDEF CPU64}
GetInt64Value
{$ELSE}
GetOrdValue
{$ENDIF}
);
{$ELSE}
pSockets := GetObjValue as TIdSocketHandles;
{$ENDIF}
pSockets.BeginUpdate;
try
FillHandleList(Value, pSockets);
finally
pSockets.EndUpdate;
end;
end;
{ TIdBaseComponentEditor }
procedure TIdBaseComponentEditor.ExecuteVerb(Index: Integer);
begin
case Index of
0 : TfrmAbout.ShowDlg;
end;
end;
function TIdBaseComponentEditor.GetVerb(Index: Integer): string;
begin
case Index of
0: Result := IndyFormat(RSAAboutMenuItemName, [gsIdVersion]);
end;
end;
function TIdBaseComponentEditor.GetVerbCount: Integer;
begin
Result := 1;
end;
procedure Register;
begin
RegisterPropertyEditor(TypeInfo(TIdSocketHandles), nil, '', TIdPropEdBinding); {Do not Localize}
RegisterComponentEditor(TIdBaseComponent, TIdBaseComponentEditor);
end;
{$IFDEF DCC}
{$IFDEF VCL_2005_OR_ABOVE}
var
AboutBoxServices: IOTAAboutBoxServices = nil;
AboutBoxIndex: Integer = -1;
procedure RegisterAboutBox;
begin
if Supports(BorlandIDEServices, IOTAAboutBoxServices, AboutBoxServices) then
begin
AboutBoxIndex := AboutBoxServices.AddPluginInfo(
RSAAboutBoxCompName + ' ' + gsIdVersion,
RSAAboutBoxDescription + sLineBreak + sLineBreak
+ RSAAboutBoxCopyright + sLineBreak + sLineBreak
+ RSAAboutBoxPleaseVisit + sLineBreak + RSAAboutBoxIndyWebsite,
0,
False,
RSAAboutBoxLicences,
'');
end;
end;
procedure UnregisterAboutBox;
begin
if (AboutBoxIndex <> -1) and (AboutBoxServices <> nil) then
begin
AboutBoxServices.RemovePluginInfo(AboutBoxIndex);
end;
end;
initialization
RegisterAboutBox;
finalization
UnregisterAboutBox;
{$ENDIF}
{$ENDIF}
end.
| 21.33218 | 101 | 0.715328 |
83ec426bd243ac12fc1c72ac1694053fcef4c904 | 2,082 | dfm | Pascal | Bat/BatAlgorithm.dfm | leylatulu/Heuristic-Optimization-Algorithms | 1482292d428a9d6d093bf4c36053dd627cb76838 | [
"MIT"
]
| 1 | 2021-07-03T08:58:49.000Z | 2021-07-03T08:58:49.000Z | Bat/BatAlgorithm.dfm | leylatulu/Optimization | 1482292d428a9d6d093bf4c36053dd627cb76838 | [
"MIT"
]
| null | null | null | Bat/BatAlgorithm.dfm | leylatulu/Optimization | 1482292d428a9d6d093bf4c36053dd627cb76838 | [
"MIT"
]
| null | null | null | object Form1: TForm1
Left = 2267
Top = 206
Width = 298
Height = 286
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel
Left = 16
Top = 8
Width = 53
Height = 13
Caption = 'Population '
end
object Label2: TLabel
Left = 16
Top = 32
Width = 38
Height = 13
Caption = 'Iteration'
end
object Label3: TLabel
Left = 16
Top = 56
Width = 28
Height = 13
Caption = 'Gama'
end
object Label4: TLabel
Left = 16
Top = 80
Width = 27
Height = 13
Caption = 'Alpha'
end
object Label5: TLabel
Left = 16
Top = 184
Width = 122
Height = 13
Caption = 'Maximum Target Function'
end
object Label6: TLabel
Left = 16
Top = 208
Width = 49
Height = 13
Caption = 'Optimum x'
end
object Button1: TButton
Left = 16
Top = 112
Width = 249
Height = 49
Caption = 'BAT ALGORITHM'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -19
Font.Name = 'Times New Roman'
Font.Style = []
ParentFont = False
TabOrder = 0
OnClick = Button1Click
end
object Edit1: TEdit
Left = 160
Top = 8
Width = 105
Height = 21
TabOrder = 1
end
object Edit2: TEdit
Left = 160
Top = 32
Width = 105
Height = 21
TabOrder = 2
end
object Edit3: TEdit
Left = 160
Top = 56
Width = 105
Height = 21
TabOrder = 3
end
object Edit4: TEdit
Left = 160
Top = 184
Width = 105
Height = 21
TabOrder = 4
end
object Edit5: TEdit
Left = 160
Top = 208
Width = 105
Height = 21
TabOrder = 5
end
object Edit6: TEdit
Left = 160
Top = 80
Width = 105
Height = 21
TabOrder = 6
end
end
| 17.948276 | 40 | 0.543708 |
47e237da19da4d8607dd9db5f0aac74aefb542da | 379 | pas | Pascal | Test/FailureScripts/reintroduce.pas | skolkman/dwscript | b9f99d4b8187defac3f3713e2ae0f7b83b63d516 | [
"Condor-1.1"
]
| 79 | 2015-03-18T10:46:13.000Z | 2022-03-17T18:05:11.000Z | Test/FailureScripts/reintroduce.pas | skolkman/dwscript | b9f99d4b8187defac3f3713e2ae0f7b83b63d516 | [
"Condor-1.1"
]
| 6 | 2016-03-29T14:39:00.000Z | 2020-09-14T10:04:14.000Z | Test/FailureScripts/reintroduce.pas | skolkman/dwscript | b9f99d4b8187defac3f3713e2ae0f7b83b63d516 | [
"Condor-1.1"
]
| 25 | 2016-05-04T13:11:38.000Z | 2021-09-29T13:34:31.000Z | type
TBase = class
procedure Func; virtual;
end;
type
TChild = class (TBase)
procedure Func; reintroduce;
end;
type
TChild2 = class (TBase)
procedure Func;
end;
type
TSubChild = class (TChild)
procedure Func; override;
end;
type
TSubChild2 = class (TChild)
procedure Func; reintroduce;
end;
| 15.16 | 35 | 0.583113 |
47bf264debf234fef0bd513614e577ba23298543 | 757 | lpr | Pascal | example/multimap/presdatabase_lite.lpr | avk959/LazGenerics | e6ff772baa97e80f5f527a887aebadae51229def | [
"Apache-2.0"
]
| 76 | 2018-06-20T07:36:46.000Z | 2022-03-17T19:19:46.000Z | example/multimap/presdatabase_lite.lpr | avk959/LazGenerics | e6ff772baa97e80f5f527a887aebadae51229def | [
"Apache-2.0"
]
| 6 | 2019-02-04T10:09:49.000Z | 2022-03-10T07:54:41.000Z | example/multimap/presdatabase_lite.lpr | avk959/LazGenerics | e6ff772baa97e80f5f527a887aebadae51229def | [
"Apache-2.0"
]
| 13 | 2019-11-15T10:54:17.000Z | 2022-01-02T15:13:35.000Z | program presdatabase_lite;
{$mode objfpc}{$H+}
uses
SysUtils,
lgMultiMap;
type
TNameList = specialize TGLiteHashMultiMap<string, string, string>;
TName = record
FirstName,
LastName: string;
end;
var
Database: TNameList;
UserInput,
LastName: string;
Name: TName;
Names: array[0..45] of TName = {$I presidents.inc};
{$R *.res}
begin
for Name in Names do
Database.Add(LowerCase(Name.FirstName), Name.LastName);
repeat
Writeln('Enter q to exit');
Writeln('Enter president first name to get list');
Readln(UserInput);
if LowerCase(UserInput) = 'q' then
break;
Writeln('>>>');
for LastName in Database[LowerCase(UserInput)] do
Writeln(LastName);
Writeln;
until False;
end.
| 16.456522 | 68 | 0.661823 |
475898b4ab6a2ee75a62e3078e3f4d0712e4d545 | 36,217 | pas | Pascal | lazarus/synedit/synedittextdoublewidthchars.pas | rarnu/golcl-liblcl | 6f238af742857921062365656a1b13b44b2330ce | [
"Apache-2.0"
]
| null | null | null | lazarus/synedit/synedittextdoublewidthchars.pas | rarnu/golcl-liblcl | 6f238af742857921062365656a1b13b44b2330ce | [
"Apache-2.0"
]
| null | null | null | lazarus/synedit/synedittextdoublewidthchars.pas | rarnu/golcl-liblcl | 6f238af742857921062365656a1b13b44b2330ce | [
"Apache-2.0"
]
| null | null | null | {-------------------------------------------------------------------------------
The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
the specific language governing rights and limitations under the License.
Alternatively, the contents of this file may be used under the terms of the
GNU General Public License Version 2 or later (the "GPL"), in which case
the provisions of the GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms
of the GPL and not to allow others to use your version of this file
under the MPL, indicate your decision by deleting the provisions above and
replace them with the notice and other provisions required by the GPL.
If you do not delete the provisions above, a recipient may use your version
of this file under either the MPL or the GPL.
-------------------------------------------------------------------------------}
(*
visit the following URL for more information
http://www.unicode.org/Public/UNIDATA/EastAsianWidth.txt
http://unicode.org/reports/tr11/
*)
unit SynEditTextDoubleWidthChars;
{$I synedit.inc}
interface
uses
{$ifdef windows}{$IFDEF SynForceDoubeWidthHack} Windows, {$endif}{$endif}
Classes, SysUtils, LazSynEditText;
type
{ SynEditTextDoubleWidthChars }
SynEditStringDoubleWidthChars = class(TSynEditStringsLinked)
protected
procedure DoGetPhysicalCharWidths(Line: PChar; LineLen, Index: Integer; PWidths: PPhysicalCharWidth); override;
end;
implementation
{$IFDEF SynForceDoubeWidthHack}
type
{ For more information, see UAX #11: East Asian Width,
at http://www.unicode.org/reports/tr11/
EastAsianWidth-7.0.0.txt
# Date: 2014-02-28, 23:15:00 GMT [KW, LI]
# This file is an informative contributory data file in the
# Unicode Character Database.
}
TCharWidth = (cwN, cwA, cwH, cwW, cwF, cwNa);
TCharRange = record
l, h : Integer;
l8 : Int64; // utf8 encoding. UTF8 character is no longer that 6-bytes
h8 : Int64; // utf8 encoding
w : TCharWidth;
end;
var
cjkarr : array of TCharRange = nil;
procedure InitCJKWidth;
begin
// Copyright (c) 1991-2014 Unicode, Inc.
// For terms of use, see http://www.unicode.org/terms_of_use.html
// this part is automatically generated based on EastAsianWidth.txt
SetLength(cjkarr,222);
SetLength(cjkarr,222);
with cjkarr[0] do begin l:=32; h:=126; w:=cwNa; l8:=$20; h8:=$7E; end;
with cjkarr[1] do begin l:=161; h:=161; w:=cwA; l8:=$C2A1; h8:=$C2A1; end;
with cjkarr[2] do begin l:=162; h:=163; w:=cwNa; l8:=$C2A2; h8:=$C2A3; end;
with cjkarr[3] do begin l:=164; h:=164; w:=cwA; l8:=$C2A4; h8:=$C2A4; end;
with cjkarr[4] do begin l:=165; h:=166; w:=cwNa; l8:=$C2A5; h8:=$C2A6; end;
with cjkarr[5] do begin l:=167; h:=168; w:=cwA; l8:=$C2A7; h8:=$C2A8; end;
with cjkarr[6] do begin l:=170; h:=170; w:=cwA; l8:=$C2AA; h8:=$C2AA; end;
with cjkarr[7] do begin l:=172; h:=172; w:=cwNa; l8:=$C2AC; h8:=$C2AC; end;
with cjkarr[8] do begin l:=173; h:=174; w:=cwA; l8:=$C2AD; h8:=$C2AE; end;
with cjkarr[9] do begin l:=175; h:=175; w:=cwNa; l8:=$C2AF; h8:=$C2AF; end;
with cjkarr[10] do begin l:=176; h:=180; w:=cwA; l8:=$C2B0; h8:=$C2B4; end;
with cjkarr[11] do begin l:=182; h:=186; w:=cwA; l8:=$C2B6; h8:=$C2BA; end;
with cjkarr[12] do begin l:=188; h:=191; w:=cwA; l8:=$C2BC; h8:=$C2BF; end;
with cjkarr[13] do begin l:=198; h:=198; w:=cwA; l8:=$C386; h8:=$C386; end;
with cjkarr[14] do begin l:=208; h:=208; w:=cwA; l8:=$C390; h8:=$C390; end;
with cjkarr[15] do begin l:=215; h:=216; w:=cwA; l8:=$C397; h8:=$C398; end;
with cjkarr[16] do begin l:=222; h:=225; w:=cwA; l8:=$C39E; h8:=$C3A1; end;
with cjkarr[17] do begin l:=230; h:=230; w:=cwA; l8:=$C3A6; h8:=$C3A6; end;
with cjkarr[18] do begin l:=232; h:=234; w:=cwA; l8:=$C3A8; h8:=$C3AA; end;
with cjkarr[19] do begin l:=236; h:=237; w:=cwA; l8:=$C3AC; h8:=$C3AD; end;
with cjkarr[20] do begin l:=240; h:=240; w:=cwA; l8:=$C3B0; h8:=$C3B0; end;
with cjkarr[21] do begin l:=242; h:=243; w:=cwA; l8:=$C3B2; h8:=$C3B3; end;
with cjkarr[22] do begin l:=247; h:=250; w:=cwA; l8:=$C3B7; h8:=$C3BA; end;
with cjkarr[23] do begin l:=252; h:=252; w:=cwA; l8:=$C3BC; h8:=$C3BC; end;
with cjkarr[24] do begin l:=254; h:=254; w:=cwA; l8:=$C3BE; h8:=$C3BE; end;
with cjkarr[25] do begin l:=257; h:=257; w:=cwA; l8:=$C481; h8:=$C481; end;
with cjkarr[26] do begin l:=273; h:=273; w:=cwA; l8:=$C491; h8:=$C491; end;
with cjkarr[27] do begin l:=275; h:=275; w:=cwA; l8:=$C493; h8:=$C493; end;
with cjkarr[28] do begin l:=283; h:=283; w:=cwA; l8:=$C49B; h8:=$C49B; end;
with cjkarr[29] do begin l:=294; h:=295; w:=cwA; l8:=$C4A6; h8:=$C4A7; end;
with cjkarr[30] do begin l:=299; h:=299; w:=cwA; l8:=$C4AB; h8:=$C4AB; end;
with cjkarr[31] do begin l:=305; h:=307; w:=cwA; l8:=$C4B1; h8:=$C4B3; end;
with cjkarr[32] do begin l:=312; h:=312; w:=cwA; l8:=$C4B8; h8:=$C4B8; end;
with cjkarr[33] do begin l:=319; h:=322; w:=cwA; l8:=$C4BF; h8:=$C582; end;
with cjkarr[34] do begin l:=324; h:=324; w:=cwA; l8:=$C584; h8:=$C584; end;
with cjkarr[35] do begin l:=328; h:=331; w:=cwA; l8:=$C588; h8:=$C58B; end;
with cjkarr[36] do begin l:=333; h:=333; w:=cwA; l8:=$C58D; h8:=$C58D; end;
with cjkarr[37] do begin l:=338; h:=339; w:=cwA; l8:=$C592; h8:=$C593; end;
with cjkarr[38] do begin l:=358; h:=359; w:=cwA; l8:=$C5A6; h8:=$C5A7; end;
with cjkarr[39] do begin l:=363; h:=363; w:=cwA; l8:=$C5AB; h8:=$C5AB; end;
with cjkarr[40] do begin l:=462; h:=462; w:=cwA; l8:=$C78E; h8:=$C78E; end;
with cjkarr[41] do begin l:=464; h:=464; w:=cwA; l8:=$C790; h8:=$C790; end;
with cjkarr[42] do begin l:=466; h:=466; w:=cwA; l8:=$C792; h8:=$C792; end;
with cjkarr[43] do begin l:=468; h:=468; w:=cwA; l8:=$C794; h8:=$C794; end;
with cjkarr[44] do begin l:=470; h:=470; w:=cwA; l8:=$C796; h8:=$C796; end;
with cjkarr[45] do begin l:=472; h:=472; w:=cwA; l8:=$C798; h8:=$C798; end;
with cjkarr[46] do begin l:=474; h:=474; w:=cwA; l8:=$C79A; h8:=$C79A; end;
with cjkarr[47] do begin l:=476; h:=476; w:=cwA; l8:=$C79C; h8:=$C79C; end;
with cjkarr[48] do begin l:=593; h:=593; w:=cwA; l8:=$C991; h8:=$C991; end;
with cjkarr[49] do begin l:=609; h:=609; w:=cwA; l8:=$C9A1; h8:=$C9A1; end;
with cjkarr[50] do begin l:=708; h:=708; w:=cwA; l8:=$CB84; h8:=$CB84; end;
with cjkarr[51] do begin l:=711; h:=711; w:=cwA; l8:=$CB87; h8:=$CB87; end;
with cjkarr[52] do begin l:=713; h:=715; w:=cwA; l8:=$CB89; h8:=$CB8B; end;
with cjkarr[53] do begin l:=717; h:=717; w:=cwA; l8:=$CB8D; h8:=$CB8D; end;
with cjkarr[54] do begin l:=720; h:=720; w:=cwA; l8:=$CB90; h8:=$CB90; end;
with cjkarr[55] do begin l:=728; h:=731; w:=cwA; l8:=$CB98; h8:=$CB9B; end;
with cjkarr[56] do begin l:=733; h:=733; w:=cwA; l8:=$CB9D; h8:=$CB9D; end;
with cjkarr[57] do begin l:=735; h:=735; w:=cwA; l8:=$CB9F; h8:=$CB9F; end;
with cjkarr[58] do begin l:=768; h:=879; w:=cwA; l8:=$CC80; h8:=$CDAF; end;
with cjkarr[59] do begin l:=913; h:=929; w:=cwA; l8:=$CE91; h8:=$CEA1; end;
with cjkarr[60] do begin l:=931; h:=937; w:=cwA; l8:=$CEA3; h8:=$CEA9; end;
with cjkarr[61] do begin l:=945; h:=961; w:=cwA; l8:=$CEB1; h8:=$CF81; end;
with cjkarr[62] do begin l:=963; h:=969; w:=cwA; l8:=$CF83; h8:=$CF89; end;
with cjkarr[63] do begin l:=1025; h:=1025; w:=cwA; l8:=$D081; h8:=$D081; end;
with cjkarr[64] do begin l:=1040; h:=1103; w:=cwA; l8:=$D090; h8:=$D18F; end;
with cjkarr[65] do begin l:=1105; h:=1105; w:=cwA; l8:=$D191; h8:=$D191; end;
with cjkarr[66] do begin l:=4352; h:=4447; w:=cwW; l8:=$E18480; h8:=$E1859F; end;
with cjkarr[67] do begin l:=8208; h:=8208; w:=cwA; l8:=$E28090; h8:=$E28090; end;
with cjkarr[68] do begin l:=8211; h:=8214; w:=cwA; l8:=$E28093; h8:=$E28096; end;
with cjkarr[69] do begin l:=8216; h:=8217; w:=cwA; l8:=$E28098; h8:=$E28099; end;
with cjkarr[70] do begin l:=8220; h:=8221; w:=cwA; l8:=$E2809C; h8:=$E2809D; end;
with cjkarr[71] do begin l:=8224; h:=8226; w:=cwA; l8:=$E280A0; h8:=$E280A2; end;
with cjkarr[72] do begin l:=8228; h:=8231; w:=cwA; l8:=$E280A4; h8:=$E280A7; end;
with cjkarr[73] do begin l:=8240; h:=8240; w:=cwA; l8:=$E280B0; h8:=$E280B0; end;
with cjkarr[74] do begin l:=8242; h:=8243; w:=cwA; l8:=$E280B2; h8:=$E280B3; end;
with cjkarr[75] do begin l:=8245; h:=8245; w:=cwA; l8:=$E280B5; h8:=$E280B5; end;
with cjkarr[76] do begin l:=8251; h:=8251; w:=cwA; l8:=$E280BB; h8:=$E280BB; end;
with cjkarr[77] do begin l:=8254; h:=8254; w:=cwA; l8:=$E280BE; h8:=$E280BE; end;
with cjkarr[78] do begin l:=8308; h:=8308; w:=cwA; l8:=$E281B4; h8:=$E281B4; end;
with cjkarr[79] do begin l:=8319; h:=8319; w:=cwA; l8:=$E281BF; h8:=$E281BF; end;
with cjkarr[80] do begin l:=8321; h:=8324; w:=cwA; l8:=$E28281; h8:=$E28284; end;
with cjkarr[81] do begin l:=8361; h:=8361; w:=cwH; l8:=$E282A9; h8:=$E282A9; end;
with cjkarr[82] do begin l:=8364; h:=8364; w:=cwA; l8:=$E282AC; h8:=$E282AC; end;
with cjkarr[83] do begin l:=8451; h:=8451; w:=cwA; l8:=$E28483; h8:=$E28483; end;
with cjkarr[84] do begin l:=8453; h:=8453; w:=cwA; l8:=$E28485; h8:=$E28485; end;
with cjkarr[85] do begin l:=8457; h:=8457; w:=cwA; l8:=$E28489; h8:=$E28489; end;
with cjkarr[86] do begin l:=8467; h:=8467; w:=cwA; l8:=$E28493; h8:=$E28493; end;
with cjkarr[87] do begin l:=8470; h:=8470; w:=cwA; l8:=$E28496; h8:=$E28496; end;
with cjkarr[88] do begin l:=8481; h:=8482; w:=cwA; l8:=$E284A1; h8:=$E284A2; end;
with cjkarr[89] do begin l:=8486; h:=8486; w:=cwA; l8:=$E284A6; h8:=$E284A6; end;
with cjkarr[90] do begin l:=8491; h:=8491; w:=cwA; l8:=$E284AB; h8:=$E284AB; end;
with cjkarr[91] do begin l:=8531; h:=8532; w:=cwA; l8:=$E28593; h8:=$E28594; end;
with cjkarr[92] do begin l:=8539; h:=8542; w:=cwA; l8:=$E2859B; h8:=$E2859E; end;
with cjkarr[93] do begin l:=8544; h:=8555; w:=cwA; l8:=$E285A0; h8:=$E285AB; end;
with cjkarr[94] do begin l:=8560; h:=8569; w:=cwA; l8:=$E285B0; h8:=$E285B9; end;
with cjkarr[95] do begin l:=8585; h:=8585; w:=cwA; l8:=$E28689; h8:=$E28689; end;
with cjkarr[96] do begin l:=8592; h:=8601; w:=cwA; l8:=$E28690; h8:=$E28699; end;
with cjkarr[97] do begin l:=8632; h:=8633; w:=cwA; l8:=$E286B8; h8:=$E286B9; end;
with cjkarr[98] do begin l:=8658; h:=8658; w:=cwA; l8:=$E28792; h8:=$E28792; end;
with cjkarr[99] do begin l:=8660; h:=8660; w:=cwA; l8:=$E28794; h8:=$E28794; end;
with cjkarr[100] do begin l:=8679; h:=8679; w:=cwA; l8:=$E287A7; h8:=$E287A7; end;
with cjkarr[101] do begin l:=8704; h:=8704; w:=cwA; l8:=$E28880; h8:=$E28880; end;
with cjkarr[102] do begin l:=8706; h:=8707; w:=cwA; l8:=$E28882; h8:=$E28883; end;
with cjkarr[103] do begin l:=8711; h:=8712; w:=cwA; l8:=$E28887; h8:=$E28888; end;
with cjkarr[104] do begin l:=8715; h:=8715; w:=cwA; l8:=$E2888B; h8:=$E2888B; end;
with cjkarr[105] do begin l:=8719; h:=8719; w:=cwA; l8:=$E2888F; h8:=$E2888F; end;
with cjkarr[106] do begin l:=8721; h:=8721; w:=cwA; l8:=$E28891; h8:=$E28891; end;
with cjkarr[107] do begin l:=8725; h:=8725; w:=cwA; l8:=$E28895; h8:=$E28895; end;
with cjkarr[108] do begin l:=8730; h:=8730; w:=cwA; l8:=$E2889A; h8:=$E2889A; end;
with cjkarr[109] do begin l:=8733; h:=8736; w:=cwA; l8:=$E2889D; h8:=$E288A0; end;
with cjkarr[110] do begin l:=8739; h:=8739; w:=cwA; l8:=$E288A3; h8:=$E288A3; end;
with cjkarr[111] do begin l:=8741; h:=8741; w:=cwA; l8:=$E288A5; h8:=$E288A5; end;
with cjkarr[112] do begin l:=8743; h:=8748; w:=cwA; l8:=$E288A7; h8:=$E288AC; end;
with cjkarr[113] do begin l:=8750; h:=8750; w:=cwA; l8:=$E288AE; h8:=$E288AE; end;
with cjkarr[114] do begin l:=8756; h:=8759; w:=cwA; l8:=$E288B4; h8:=$E288B7; end;
with cjkarr[115] do begin l:=8764; h:=8765; w:=cwA; l8:=$E288BC; h8:=$E288BD; end;
with cjkarr[116] do begin l:=8776; h:=8776; w:=cwA; l8:=$E28988; h8:=$E28988; end;
with cjkarr[117] do begin l:=8780; h:=8780; w:=cwA; l8:=$E2898C; h8:=$E2898C; end;
with cjkarr[118] do begin l:=8786; h:=8786; w:=cwA; l8:=$E28992; h8:=$E28992; end;
with cjkarr[119] do begin l:=8800; h:=8801; w:=cwA; l8:=$E289A0; h8:=$E289A1; end;
with cjkarr[120] do begin l:=8804; h:=8807; w:=cwA; l8:=$E289A4; h8:=$E289A7; end;
with cjkarr[121] do begin l:=8810; h:=8811; w:=cwA; l8:=$E289AA; h8:=$E289AB; end;
with cjkarr[122] do begin l:=8814; h:=8815; w:=cwA; l8:=$E289AE; h8:=$E289AF; end;
with cjkarr[123] do begin l:=8834; h:=8835; w:=cwA; l8:=$E28A82; h8:=$E28A83; end;
with cjkarr[124] do begin l:=8838; h:=8839; w:=cwA; l8:=$E28A86; h8:=$E28A87; end;
with cjkarr[125] do begin l:=8853; h:=8853; w:=cwA; l8:=$E28A95; h8:=$E28A95; end;
with cjkarr[126] do begin l:=8857; h:=8857; w:=cwA; l8:=$E28A99; h8:=$E28A99; end;
with cjkarr[127] do begin l:=8869; h:=8869; w:=cwA; l8:=$E28AA5; h8:=$E28AA5; end;
with cjkarr[128] do begin l:=8895; h:=8895; w:=cwA; l8:=$E28ABF; h8:=$E28ABF; end;
with cjkarr[129] do begin l:=8978; h:=8978; w:=cwA; l8:=$E28C92; h8:=$E28C92; end;
with cjkarr[130] do begin l:=9001; h:=9002; w:=cwW; l8:=$E28CA9; h8:=$E28CAA; end;
with cjkarr[131] do begin l:=9312; h:=9449; w:=cwA; l8:=$E291A0; h8:=$E293A9; end;
with cjkarr[132] do begin l:=9451; h:=9547; w:=cwA; l8:=$E293AB; h8:=$E2958B; end;
with cjkarr[133] do begin l:=9552; h:=9587; w:=cwA; l8:=$E29590; h8:=$E295B3; end;
with cjkarr[134] do begin l:=9600; h:=9615; w:=cwA; l8:=$E29680; h8:=$E2968F; end;
with cjkarr[135] do begin l:=9618; h:=9621; w:=cwA; l8:=$E29692; h8:=$E29695; end;
with cjkarr[136] do begin l:=9632; h:=9633; w:=cwA; l8:=$E296A0; h8:=$E296A1; end;
with cjkarr[137] do begin l:=9635; h:=9641; w:=cwA; l8:=$E296A3; h8:=$E296A9; end;
with cjkarr[138] do begin l:=9650; h:=9651; w:=cwA; l8:=$E296B2; h8:=$E296B3; end;
with cjkarr[139] do begin l:=9654; h:=9655; w:=cwA; l8:=$E296B6; h8:=$E296B7; end;
with cjkarr[140] do begin l:=9660; h:=9661; w:=cwA; l8:=$E296BC; h8:=$E296BD; end;
with cjkarr[141] do begin l:=9664; h:=9665; w:=cwA; l8:=$E29780; h8:=$E29781; end;
with cjkarr[142] do begin l:=9670; h:=9672; w:=cwA; l8:=$E29786; h8:=$E29788; end;
with cjkarr[143] do begin l:=9675; h:=9675; w:=cwA; l8:=$E2978B; h8:=$E2978B; end;
with cjkarr[144] do begin l:=9678; h:=9681; w:=cwA; l8:=$E2978E; h8:=$E29791; end;
with cjkarr[145] do begin l:=9698; h:=9701; w:=cwA; l8:=$E297A2; h8:=$E297A5; end;
with cjkarr[146] do begin l:=9711; h:=9711; w:=cwA; l8:=$E297AF; h8:=$E297AF; end;
with cjkarr[147] do begin l:=9733; h:=9734; w:=cwA; l8:=$E29885; h8:=$E29886; end;
with cjkarr[148] do begin l:=9737; h:=9737; w:=cwA; l8:=$E29889; h8:=$E29889; end;
with cjkarr[149] do begin l:=9742; h:=9743; w:=cwA; l8:=$E2988E; h8:=$E2988F; end;
with cjkarr[150] do begin l:=9748; h:=9749; w:=cwA; l8:=$E29894; h8:=$E29895; end;
with cjkarr[151] do begin l:=9756; h:=9756; w:=cwA; l8:=$E2989C; h8:=$E2989C; end;
with cjkarr[152] do begin l:=9758; h:=9758; w:=cwA; l8:=$E2989E; h8:=$E2989E; end;
with cjkarr[153] do begin l:=9792; h:=9792; w:=cwA; l8:=$E29980; h8:=$E29980; end;
with cjkarr[154] do begin l:=9794; h:=9794; w:=cwA; l8:=$E29982; h8:=$E29982; end;
with cjkarr[155] do begin l:=9824; h:=9825; w:=cwA; l8:=$E299A0; h8:=$E299A1; end;
with cjkarr[156] do begin l:=9827; h:=9829; w:=cwA; l8:=$E299A3; h8:=$E299A5; end;
with cjkarr[157] do begin l:=9831; h:=9834; w:=cwA; l8:=$E299A7; h8:=$E299AA; end;
with cjkarr[158] do begin l:=9836; h:=9837; w:=cwA; l8:=$E299AC; h8:=$E299AD; end;
with cjkarr[159] do begin l:=9839; h:=9839; w:=cwA; l8:=$E299AF; h8:=$E299AF; end;
with cjkarr[160] do begin l:=9886; h:=9887; w:=cwA; l8:=$E29A9E; h8:=$E29A9F; end;
with cjkarr[161] do begin l:=9918; h:=9919; w:=cwA; l8:=$E29ABE; h8:=$E29ABF; end;
with cjkarr[162] do begin l:=9924; h:=9933; w:=cwA; l8:=$E29B84; h8:=$E29B8D; end;
with cjkarr[163] do begin l:=9935; h:=9953; w:=cwA; l8:=$E29B8F; h8:=$E29BA1; end;
with cjkarr[164] do begin l:=9955; h:=9955; w:=cwA; l8:=$E29BA3; h8:=$E29BA3; end;
with cjkarr[165] do begin l:=9960; h:=9983; w:=cwA; l8:=$E29BA8; h8:=$E29BBF; end;
with cjkarr[166] do begin l:=10045; h:=10045; w:=cwA; l8:=$E29CBD; h8:=$E29CBD; end;
with cjkarr[167] do begin l:=10071; h:=10071; w:=cwA; l8:=$E29D97; h8:=$E29D97; end;
with cjkarr[168] do begin l:=10102; h:=10111; w:=cwA; l8:=$E29DB6; h8:=$E29DBF; end;
with cjkarr[169] do begin l:=10214; h:=10221; w:=cwNa; l8:=$E29FA6; h8:=$E29FAD; end;
with cjkarr[170] do begin l:=10629; h:=10630; w:=cwNa; l8:=$E2A685; h8:=$E2A686; end;
with cjkarr[171] do begin l:=11093; h:=11097; w:=cwA; l8:=$E2AD95; h8:=$E2AD99; end;
with cjkarr[172] do begin l:=11904; h:=11929; w:=cwW; l8:=$E2BA80; h8:=$E2BA99; end;
with cjkarr[173] do begin l:=11931; h:=12019; w:=cwW; l8:=$E2BA9B; h8:=$E2BBB3; end;
with cjkarr[174] do begin l:=12032; h:=12245; w:=cwW; l8:=$E2BC80; h8:=$E2BF95; end;
with cjkarr[175] do begin l:=12272; h:=12283; w:=cwW; l8:=$E2BFB0; h8:=$E2BFBB; end;
with cjkarr[176] do begin l:=12288; h:=12288; w:=cwF; l8:=$E38080; h8:=$E38080; end;
with cjkarr[177] do begin l:=12289; h:=12350; w:=cwW; l8:=$E38081; h8:=$E380BE; end;
with cjkarr[178] do begin l:=12353; h:=12438; w:=cwW; l8:=$E38181; h8:=$E38296; end;
with cjkarr[179] do begin l:=12441; h:=12543; w:=cwW; l8:=$E38299; h8:=$E383BF; end;
with cjkarr[180] do begin l:=12549; h:=12589; w:=cwW; l8:=$E38485; h8:=$E384AD; end;
with cjkarr[181] do begin l:=12593; h:=12686; w:=cwW; l8:=$E384B1; h8:=$E3868E; end;
with cjkarr[182] do begin l:=12688; h:=12730; w:=cwW; l8:=$E38690; h8:=$E386BA; end;
with cjkarr[183] do begin l:=12736; h:=12771; w:=cwW; l8:=$E38780; h8:=$E387A3; end;
with cjkarr[184] do begin l:=12784; h:=12830; w:=cwW; l8:=$E387B0; h8:=$E3889E; end;
with cjkarr[185] do begin l:=12832; h:=12871; w:=cwW; l8:=$E388A0; h8:=$E38987; end;
with cjkarr[186] do begin l:=12872; h:=12879; w:=cwA; l8:=$E38988; h8:=$E3898F; end;
with cjkarr[187] do begin l:=12880; h:=13054; w:=cwW; l8:=$E38990; h8:=$E38BBE; end;
with cjkarr[188] do begin l:=13056; h:=19903; w:=cwW; l8:=$E38C80; h8:=$E4B6BF; end;
with cjkarr[189] do begin l:=19968; h:=42124; w:=cwW; l8:=$E4B880; h8:=$EA928C; end;
with cjkarr[190] do begin l:=42128; h:=42182; w:=cwW; l8:=$EA9290; h8:=$EA9386; end;
with cjkarr[191] do begin l:=43360; h:=43388; w:=cwW; l8:=$EAA5A0; h8:=$EAA5BC; end;
with cjkarr[192] do begin l:=44032; h:=55203; w:=cwW; l8:=$EAB080; h8:=$ED9EA3; end;
with cjkarr[193] do begin l:=57344; h:=63743; w:=cwA; l8:=$EE8080; h8:=$EFA3BF; end;
with cjkarr[194] do begin l:=63744; h:=64255; w:=cwW; l8:=$EFA480; h8:=$EFABBF; end;
with cjkarr[195] do begin l:=65024; h:=65039; w:=cwA; l8:=$EFB880; h8:=$EFB88F; end;
with cjkarr[196] do begin l:=65040; h:=65049; w:=cwW; l8:=$EFB890; h8:=$EFB899; end;
with cjkarr[197] do begin l:=65072; h:=65106; w:=cwW; l8:=$EFB8B0; h8:=$EFB992; end;
with cjkarr[198] do begin l:=65108; h:=65126; w:=cwW; l8:=$EFB994; h8:=$EFB9A6; end;
with cjkarr[199] do begin l:=65128; h:=65131; w:=cwW; l8:=$EFB9A8; h8:=$EFB9AB; end;
with cjkarr[200] do begin l:=65281; h:=65376; w:=cwF; l8:=$EFBC81; h8:=$EFBDA0; end;
with cjkarr[201] do begin l:=65377; h:=65470; w:=cwH; l8:=$EFBDA1; h8:=$EFBEBE; end;
with cjkarr[202] do begin l:=65474; h:=65479; w:=cwH; l8:=$EFBF82; h8:=$EFBF87; end;
with cjkarr[203] do begin l:=65482; h:=65487; w:=cwH; l8:=$EFBF8A; h8:=$EFBF8F; end;
with cjkarr[204] do begin l:=65490; h:=65495; w:=cwH; l8:=$EFBF92; h8:=$EFBF97; end;
with cjkarr[205] do begin l:=65498; h:=65500; w:=cwH; l8:=$EFBF9A; h8:=$EFBF9C; end;
with cjkarr[206] do begin l:=65504; h:=65510; w:=cwF; l8:=$EFBFA0; h8:=$EFBFA6; end;
with cjkarr[207] do begin l:=65512; h:=65518; w:=cwH; l8:=$EFBFA8; h8:=$EFBFAE; end;
with cjkarr[208] do begin l:=65533; h:=65533; w:=cwA; l8:=$EFBFBD; h8:=$EFBFBD; end;
with cjkarr[209] do begin l:=110592; h:=110593; w:=cwW; l8:=$F09B8080; h8:=$F09B8081; end;
with cjkarr[210] do begin l:=127232; h:=127242; w:=cwA; l8:=$F09F8480; h8:=$F09F848A; end;
with cjkarr[211] do begin l:=127248; h:=127277; w:=cwA; l8:=$F09F8490; h8:=$F09F84AD; end;
with cjkarr[212] do begin l:=127280; h:=127337; w:=cwA; l8:=$F09F84B0; h8:=$F09F85A9; end;
with cjkarr[213] do begin l:=127344; h:=127386; w:=cwA; l8:=$F09F85B0; h8:=$F09F869A; end;
with cjkarr[214] do begin l:=127488; h:=127490; w:=cwW; l8:=$F09F8880; h8:=$F09F8882; end;
with cjkarr[215] do begin l:=127504; h:=127546; w:=cwW; l8:=$F09F8890; h8:=$F09F88BA; end;
with cjkarr[216] do begin l:=127552; h:=127560; w:=cwW; l8:=$F09F8980; h8:=$F09F8988; end;
with cjkarr[217] do begin l:=127568; h:=127569; w:=cwW; l8:=$F09F8990; h8:=$F09F8991; end;
with cjkarr[218] do begin l:=131072; h:=196605; w:=cwW; l8:=$F0A08080; h8:=$F0AFBFBD; end;
with cjkarr[219] do begin l:=196608; h:=262141; w:=cwW; l8:=$F0B08080; h8:=$F0BFBFBD; end;
with cjkarr[220] do begin l:=917760; h:=917999; w:=cwA; l8:=$F3A08480; h8:=$F3A087AF; end;
with cjkarr[221] do begin l:=983040; h:=1048573; w:=cwA; l8:=$F3B08080; h8:=$F3BFBFBD; end;
// end of automatically generated part
end;
function GetCJKWidth(u: Integer; defaultWidth: TCharWidth = cwN): TCharWidth;
var
b: Integer;
e: Integer;
i: Integer;
begin
if length(cjkarr)=0 then InitCJKWidth;
// simple binary search
b := 0;
e := length(cjkarr)-1;
Result := defaultWidth;
while (b <= e) do
begin
i := (b + e) div 2;
if (u>=cjkarr[i].l) and (u<=cjkarr[i].h) then begin
Result := cjkarr[i].w;
Break;
end else if cjkarr[i].l > u then
e := i - 1
else
b := i + 1;
end;
end;
function GetCJKWidth(utf8: PChar; charLen: Integer; defWidth: TCharWidth): TCharWidth; forward;
function GetCJKWidth(utf8: PChar; defWidth: TCharWidth): TCharWidth;
var
l : integer;
const
len1 = $01 shl 7; mask1 = $00;
len2 = $07 shl 5; mask2 = $C0;
len3 = $0F shl 4; mask3 = $E0;
len4 = $1F shl 4; mask4 = $F0;
len5 = $3F shl 4; mask5 = $F8;
len6 = $7F shl 4; mask6 = $FC;
begin
if not AssigneD(utf8) then begin
Result:=defWidth;
Exit;
end;
l:=0;
if byte(utf8^) and len1 = mask1 then l:=1
else if byte(utf8^) and len2 = mask2 then l:=2
else if byte(utf8^) and len3 = mask3 then l:=3
else if byte(utf8^) and len4 = mask4 then l:=4
else if byte(utf8^) and len5 = mask5 then l:=5
else if byte(utf8^) and len6 = mask6 then l:=6;
if l=0 then Result:=defWidth
else Result:=GetCJKWidth(utf8, l, defWidth)
end;
function GetCJKWidth(utf8: PChar; charLen: Integer; defWidth: TCharWidth): TCharWidth;
var
c : Int64;
pb : PByteArray;
b: Integer;
e: Integer;
i: Integer;
begin
{$IFDEF ENDIAN_LITTLE}
case charLen of
1: c:=byte(utf8^);
2: c:=SwapEndian(PWord(utf8)^);
3: begin
pb:=PByteArray(utf8);
c:=(pb^[0] shl 16) or (pb^[1] shl 8) or (pb^[2]);
end;
4: c:=SwapEndian(PLongWord(utf8)^);
5: begin
pb:=PByteArray(utf8);
c:=(pb^[0] shl 32) or (pb^[1] shl 24) or (pb^[2] shl 16) or (pb^[3] shl 8) or (pb^[4]);
end;
6: begin
pb:=PByteArray(utf8);
c:=(pb^[0] shl 40) or (pb^[1] shl 32) or (pb^[2] shl 24) or (pb^[3] shl 16) or (pb^[4] shl 8) or (pb^[5]);
end;
else
Result:=defWidth;
Exit;
end;
{$ELSE}
c:=0;
move(utf8^, c, charLen);
{$ENDIF}
// simple binary search
b := 0;
e := length(cjkarr)-1;
Result := defWidth;
while (b <= e) do
begin
i := (b + e) div 2;
if (c>=cjkarr[i].l8) and (c<=cjkarr[i].h8) then begin
Result := cjkarr[i].w;
Break;
end else if cjkarr[i].l8 > c then
e := i - 1
else
b := i + 1;
end;
end;
{$ENDIF}
{ SynEditTextDoubleWidthChars }
procedure SynEditStringDoubleWidthChars.DoGetPhysicalCharWidths(Line: PChar;
LineLen, Index: Integer; PWidths: PPhysicalCharWidth);
var
i: Integer;
begin
inherited DoGetPhysicalCharWidths(Line, LineLen, Index, PWidths);
if not IsUtf8 then
exit;
dec(Line);
dec(PWidths);
{$IFDEF SynForceDoubeWidthHack}
{$IF FPC_FULLVERSION>=20701}
if (DefaultSystemCodePage = 932) {Japanese}
{$ELSE}
if (GetACP = 932) {Japanese}
{$ENDIF}
then begin
for i := 0 to LineLen - 1 do begin
inc(Line);
inc(PWidths);
if PWidths^ = 0 then continue;
case GetCJKWidth(Line, cwN) of
cwN, cwH, cwNa: PWidths^ := 1;
cwA, cwW, cwF: PWidths^ := 2;
end;
(*
PWidths^:=2;
case Line^ of
#$01..#$7F: PWidths^ := 1;
#$80..#$BF: PWidths^ := 0;
#$EF: begin
if (Line[1] = #$bd) and (Line[2] in [#$A1..#$bf]) then PWidths^ := 1;
if (Line[1] = #$be) and (Line[2] in [#$80..#$9f]) then PWidths^ := 1;
end;
end;
*)
end;
exit;
end;
{$ENDIF}
for i := 0 to LineLen - 1 do begin
inc(Line);
inc(PWidths);
if Line^ < #$e1 then continue;
if PWidths^ = 0 then continue;
case Line^ of
#$e1:
case Line[1] of
#$84:
if (Line[2] >= #$80) then PWidths^ := 2;
#$85:
if (Line[2] <= #$9f) then PWidths^ := 2;
end;
#$e2:
case Line[1] of
#$8c:
if (Line[2] in [#$9a, #$9b, #$a9, #$aa]) then PWidths^ := 2;
#$8f:
if (Line[2] in [#$a9..#$ac, #$b0, #$b3]) then PWidths^ := 2;
#$97:
if (Line[2] in [#$bd..#$be]) then PWidths^ := 2;
#$98:
if (Line[2] in [#$94..#$95]) then PWidths^ := 2;
#$99:
if (Line[2] in [#$88..#$93, #$bf]) then PWidths^ := 2;
#$9a:
if (Line[2] in [#$93, #$a1, #$aa..#$ab, #$bd..#$be]) then PWidths^ := 2;
#$9b:
if (Line[2] in [#$84..#$85, #$8e, #$94, #$aa, #$b2..#$b3, #$b5, #$ba, #$bd]) then PWidths^ := 2;
#$9c:
if (Line[2] in [#$85, #$8a..#$8b, #$a8]) then PWidths^ := 2;
#$9d:
if (Line[2] in [#$8c, #$8e, #$93..#$95, #$97]) then PWidths^ := 2;
#$9e:
if (Line[2] in [#$95..#$97, #$b0, #$bf]) then PWidths^ := 2;
#$ac:
if (Line[2] in [#$9b..#$9c]) then PWidths^ := 2;
#$ad:
if (Line[2] in [#$90, #$95]) then PWidths^ := 2;
#$ba:
if (Line[2] >= #$80) then PWidths^ := 2;
#$bb..#$ff:
PWidths^ := 2;
end;
#$e3:
case Line[1] of
#$80:
if (Line[2] >= #$80) and (Line[2] <= #$be) then PWidths^ := 2;
#$81:
if (Line[2] >= #$81) then PWidths^ := 2;
#$82..#$8e:
PWidths^ := 2;
#$8f:
if (Line[2] <= #$bf) then PWidths^ := 2;
#$90:
if (Line[2] >= #$80) then PWidths^ := 2;
#$91..#$FF:
PWidths^ := 2;
end;
#$e4:
case Line[1] of
#$00..#$b6:
PWidths^ := 2;
#$b8:
if (Line[2] >= #$80) then PWidths^ := 2;
#$b9..#$ff:
PWidths^ := 2;
end;
#$e5..#$e8:
PWidths^ := 2;
#$e9:
//if (Line[1] <= #$bf) or (Line[2] in [#$00..#$bc, #$bd..#$bf]) then
PWidths^ := 2;
#$ea:
case Line[1] of
#$80, #$b0:
if (Line[2] >= #$80) then PWidths^ := 2;
#$81..#$92, #$b1..#$ff:
PWidths^ := 2;
#$93:
if (Line[2] <= #$86) then PWidths^ := 2;
#$A5:
if (Line[2] in [#$A0..#$BC]) then PWidths^ := 2;
end;
#$eb..#$ec:
PWidths^ := 2;
#$ed:
if (Line[1] <= #$9e) or (Line[2] <= #$a3) then PWidths^ := 2;
#$ef:
case Line[1] of
#$a4:
if (Line[2] >= #$80) then PWidths^ := 2;
#$a5..#$ab:
PWidths^ := 2;
#$b8:
if (Line[2] in [#$90..#$99,#$b0..#$ff]) then PWidths^ := 2;
#$b9:
if (Line[2] <= #$ab) then PWidths^ := 2;
#$bc:
if (Line[2] >= #$81) then PWidths^ := 2;
#$bd:
if (Line[2] <= #$a0) then PWidths^ := 2;
#$bf:
if (Line[2] >= #$a0) and (Line[2] <= #$a6) then PWidths^ := 2;
end;
#$f0:
case Line[1] of
#$96:
if (Line[2] = #$bf) and (Line[3] in [#$a0..#$a4, #$b0..#$b1]) then PWidths^ := 2;
#$97:
PWidths^ := 2;
#$98:
case Line[2] of
#$00..#$9e, #$a0..#$b2:
PWidths^ := 2;
#$9f:
if (Line[3] <= #$b7) then PWidths^ := 2;
#$b3:
if (Line[3] <= #$95) then PWidths^ := 2;
#$b4:
if (Line[3] <= #$88) then PWidths^ := 2;
end;
#$9B:
case Line[2] of
#$80..#$83, #$86..#$8a:
PWidths^ := 2;
#$84:
if (Line[3] <= #$9e) then PWidths^ := 2;
#$85:
if (Line[3] in [#$90..#$92, #$a4..#$a7, #$b0..#$ff]) then PWidths^ := 2;
#$8b:
if (Line[3] <= #$bb) then PWidths^ := 2;
end;
#$9F:
case Line[2] of
#$80:
if (Line[3] in [#$84]) then PWidths^ := 2;
#$83:
if (Line[3] in [#$8f]) then PWidths^ := 2;
#$86:
if (Line[3] in [#$8e, #$91..#$9a]) then PWidths^ := 2;
#$88:
if (Line[3] in [#$80..#$82, #$90..#$bb]) then PWidths^ := 2;
#$89:
if (Line[3] in [#$80..#$88, #$90..#$91, #$a0..#$a5]) then PWidths^ := 2;
#$8c:
if (Line[3] in [#$80..#$a0, #$ad..#$b5, #$b7..#$ff]) then PWidths^ := 2;
#$8d:
if (Line[3] in [#$80..#$bc, #$be..#$ff]) then PWidths^ := 2;
#$8e:
if (Line[3] in [#$80..#$93, #$a0..#$ff]) then PWidths^ := 2;
#$8f:
if (Line[3] in [#$80..#$8a, #$8f..#$93, #$a0..#$b0, #$b4, #$b8..#$be]) then PWidths^ := 2;
#$91:
if (Line[3] in [#$80, #$82..#$ff]) then PWidths^ := 2;
#$92:
PWidths^ := 2;
#$93:
if (Line[3] in [#$80..#$bc, #$bf..#$ff]) then PWidths^ := 2;
#$94:
if (Line[3] in [#$80..#$bd]) then PWidths^ := 2;
#$95:
if (Line[3] in [#$8b..#$8e, #$90..#$a7, #$ba]) then PWidths^ := 2;
#$96:
if (Line[3] in [#$95..#$96, #$a4]) then PWidths^ := 2;
#$97:
if (Line[3] in [#$bb..#$ff]) then PWidths^ := 2;
#$98:
PWidths^ := 2;
#$99:
if (Line[3] in [#$80..#$8f]) then PWidths^ := 2;
#$9a:
if (Line[3] in [#$80..#$85]) then PWidths^ := 2;
#$9b:
if (Line[3] in [#$8c, #$90..#$92, #$95..#$97, #$ab..#$ac, #$b4..#$bc]) then PWidths^ := 2;
#$9f:
if (Line[3] in [#$a0..#$ab]) then PWidths^ := 2;
#$a4:
if (Line[3] in [#$8c..#$ba, #$bc..#$ff]) then PWidths^ := 2;
#$a5:
if (Line[3] in [#$80..#$85, #$87..#$b8, #$ba..#$ff]) then PWidths^ := 2;
#$a6:
PWidths^ := 2;
#$a7:
if (Line[3] in [#$80..#$8b, #$8d..#$bf]) then PWidths^ := 2;
#$a9:
if (Line[3] in [#$b0..#$b4, #$b8..#$ba]) then PWidths^ := 2;
#$aa:
if (Line[3] in [#$80..#$86, #$90..#$a8, #$b0..#$b6]) then PWidths^ := 2;
#$ab:
if (Line[3] in [#$80..#$82, #$90..#$96]) then PWidths^ := 2;
end;
#$a0, #$b0:
case Line[2] of
#$80:
if (Line[3] >= #$80) then PWidths^ := 2;
#$81..#$ff:
PWidths^ := 2;
end;
#$a1..#$ae, #$b1..#$be:
PWidths^ := 2;
#$af, #$bf:
case Line[2] of
#$00..#$be:
PWidths^ := 2;
#$bf:
if (Line[3] <= #$bd) then PWidths^ := 2;
end;
end
end;
end
end;
(* Ranges that are FullWidth char
# CJK Unified Ideographs: U+4E00..U+9FFF
# CJK Compatibility Ideographs: U+F900..U+FAFF
# Plane 2: U+20000..U+2FFFD
# Plane 3: U+30000..U+3FFFD
//////////////
1100 e1 84 80 .. 115F e1 85 9f
231A E2 8C 9A .. 231B E2 8C 9B
2329 e2 8c a9 .. 232A e2 8c aa
23E9. E2 8F A9 .. 23EC E2 8F AC
23F0 E2 8F B0
23F3 E2 8F B3
25FD E2 97 BD .. 25FE E2 97 BE
2614 E2 98 94 .. 2615 E2 98 95
2648 E2 99 88 .. 2653 E2 99 93
267F E2 99 BF
2693 E2 9A 93
26A1 E2 9A A1
26AA E2 9A AA .. 26AB E2 9A AB
26BD E2 9A BD .. 26BE E2 9A BE
26C4 E2 9B 84 .. 26C5 E2 9B 85
26CE E2 9B 8E
26D4 E2 9B 94
26EA E2 9B AA
26F2 E2 9B B2 .. 26F3 E2 9B B3
26F5 E2 9B B5
26FA E2 9B BA
26FD E2 9B BD
2705 E2 9C 85
270A E2 9C 8A .. 270B E2 9C 8B
2728 E2 9C A8
274C E2 9D 8C
274E E2 9D 8E
2753 E2 9D 93 .. 2755 E2 9D 95
2757 E2 9D 97
2795 E2 9E 95 .. 2797 E2 9E 97
27B0 E2 9E B0
27BF E2 9E BF
2B1B E2 AC 9B ..2B1C E2 AC 9C
2B50 E2 AD 90
2B55 E2 AD 95
2E80 e2 ba 80 .. 303E e3 80 be
3041 e3 81 81 .. 33FF e3 8f bf
3400 e3 90 80 .. 4DBF E4 B6 BF
4E00 e4 b8 80 .. 9FFC E9 BF BC
9FFD E9 BF BD .. 9FFF E9 BF BF
A000 ea 80 80 .. A4C6 ea 93 86
A960 EA A5 A0 .. A97C EA A5 BC
AC00 ea b0 80 .. D7A3 ed 9e a3
F900 ef a4 80 .. FAFF EF AB BF
FE10 ef b8 90 .. FE19 ef b8 99
FE30 ef b8 b0 .. FE6B ef b9 ab
FF01 ef bc 81 .. FF60 ef bd a0
FFE0 ef bf a0 .. FFE6 ef bf a6
16FE0 F0 96 BF A0 .. 16FE4 F0 96 BF A4
16FF0 F0 96 BF B0 .. 16FF1 F0 96 BF B1
17000 F0 97 80 80 .. 187F7 F0 98 9F B7
18800 F0 98 A0 80 .. 18CD5 F0 98 B3 95
18D00 F0 98 B4 80 .. 18D08 F0 98 B4 88
1B000 F0 9B 80 80 .. 1B11E F0 9B 84 9E
1B150 F0 9B 85 90 .. 1B152 F0 9B 85 92
1B164 F0 9B 85 A4 .. 1B167 F0 9B 85 A7
1B170 F0 9B 85 B0 .. 1B2FB F0 9B 8B BB
1F004 F0 9F 80 84
1F0CF F0 9F 83 8F
1F18E F0 9F 86 8E
1F191 F0 9F 86 91 .. 1F19A F0 9F 86 9A
1F200 F0 9F 88 80 .. 1F202 F0 9F 88 82
1F210 F0 9F 88 90 .. 1F23B F0 9F 88 BB
1F240 F0 9F 89 80 .. 1F248 F0 9F 89 88
1F250 F0 9F 89 90 .. 1F251 F0 9F 89 91
1F260 F0 9F 89 A0 .. 1F265 F0 9F 89 A5
1F300 F0 9F 8C 80 .. 1F320 F0 9F 8C A0
1F32D F0 9F 8C AD .. 1F335 F0 9F 8C B5
1F337 F0 9F 8C B7 .. 1F37C F0 9F 8D BC
1F37E F0 9F 8D BE .. 1F393 F0 9F 8E 93
1F3A0 F0 9F 8E A0 .. 1F3CA F0 9F 8F 8A
1F3CF F0 9F 8F 8F .. 1F3D3 F0 9F 8F 93
1F3E0 F0 9F 8F A0 .. 1F3F0 F0 9F 8F B0
1F3F4 F0 9F 8F B4
1F3F8 F0 9F 8F B8 .. 1F43E F0 9F 90 BE
1F440 F0 9F 91 80
1F442 F0 9F 91 82 .. 1F4FC F0 9F 93 BC
1F4FF F0 9F 93 BF .. 1F53D F0 9F 94 BD
1F54B F0 9F 95 8B .. 1F54E F0 9F 95 8E
1F550 F0 9F 95 90 .. 1F567 F0 9F 95 A7
1F57A F0 9F 95 BA
1F595 F0 9F 96 95 .. 1F596 F0 9F 96 96
1F5A4 F0 9F 96 A4
1F5FB F0 9F 97 BB .. 1F64F F0 9F 99 8F
1F680 F0 9F 9A 80 .. 1F6C5 F0 9F 9B 85
1F6CC F0 9F 9B 8C
1F6D0 F0 9F 9B 90 .. 1F6D2 F0 9F 9B 92
1F6D5 F0 9F 9B 95 .. 1F6D7 F0 9F 9B 97
1F6EB F0 9F 9B AB .. 1F6EC F0 9F 9B AC
1F6F4 F0 9F 9B B4 .. 1F6FC F0 9F 9B BC
1F7E0 F0 9F 9F A0 .. 1F7EB F0 9F 9F AB
1F90C F0 9F A4 8C .. 1F93A F0 9F A4 BA
1F93C F0 9F A4 BC .. 1F945 F0 9F A5 85
1F947 F0 9F A5 87 .. 1F978 F0 9F A5 B8
1F97A F0 9F A5 BA .. 1F9CB F0 9F A7 8B
1F9CD F0 9F A7 8D .. 1F9FF F0 9F A7 BF
1FA70 F0 9F A9 B0 .. 1FA74 F0 9F A9 B4
1FA78 F0 9F A9 B8 .. 1FA7A F0 9F A9 BA
1FA80 F0 9F AA 80 .. 1FA86 F0 9F AA 86
1FA90 F0 9F AA 90 .. 1FAA8 F0 9F AA A8
1FAB0 F0 9F AA B0 .. 1FAB6 F0 9F AA B6
1FAC0 F0 9F AB 80 .. 1FAC2 F0 9F AB 82
1FAD0 F0 9F AB 90 .. 1FAD6 F0 9F AB 96
20000 f0 a0 80 80 .. 2FFFD f0 af bf bd
30000 f0 b0 80 80 .. 3FFFD f0 bf bf bd
*)
{$IFDEF SynForceDoubeWidthHack}
initialization
InitCJKWidth;
{$ENDIF}
end.
| 45.214732 | 115 | 0.557915 |
4768775bd4e02d42c872e9f6b6c738368bb0e389 | 24,481 | pas | Pascal | hedgewars/uStats.pas | hedgewars/hw | 9b8776e6589b2aa77dcda2a6004ca2feaea9faca | [
"Apache-2.0"
]
| 401 | 2015-01-08T05:38:43.000Z | 2022-03-26T10:56:42.000Z | hedgewars/uStats.pas | hedgewars/hw | 9b8776e6589b2aa77dcda2a6004ca2feaea9faca | [
"Apache-2.0"
]
| 31 | 2015-01-05T16:50:02.000Z | 2021-04-05T02:10:38.000Z | hedgewars/uStats.pas | hedgewars/hw | 9b8776e6589b2aa77dcda2a6004ca2feaea9faca | [
"Apache-2.0"
]
| 107 | 2015-01-08T05:38:46.000Z | 2022-02-10T03:49:40.000Z | (*
* Hedgewars, a free turn based strategy game
* Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com>
*
* This program 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; version 2 of the License
*
* 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. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*)
{$INCLUDE "options.inc"}
unit uStats;
interface
uses uConsts, uTypes;
var TotalRoundsPre: LongInt; // Helper variable for calculating start of Sudden Death and more. Starts at -1 and is incremented on the turn BEFORE the turn which marks the start of the next round. Always -1 while in hog placing phase
TotalRoundsReal: LongInt; // Total number of rounds played (-1 if not started or in hog placing phase). Exported to Lua as 'TotalRounds'
FinishedTurnsTotal: LongInt;
// Variables to disable certain portions of game stats (set by Lua)
SendGameResultOn : boolean = true;
SendRankingStatsOn : boolean = true;
SendAchievementsStatsOn : boolean = true;
SendHealthStatsOn : boolean = true;
// Clan death log, used for game stats
ClanDeathLog : PClanDeathLogEntry;
procedure initModule;
procedure freeModule;
procedure AmmoUsed(am: TAmmoType);
procedure HedgehogPoisoned(Gear: PGear; Attacker: PHedgehog);
procedure HedgehogSacrificed(Hedgehog: PHedgehog);
procedure HedgehogDamaged(Gear: PGear; Attacker: PHedgehog; Damage: Longword; killed: boolean);
procedure TargetHit;
procedure Skipped;
function getIsTurnSkipped: boolean;
procedure TurnStats;
procedure TurnReaction;
procedure TurnStatsReset;
procedure SendStats;
procedure hedgehogFlight(Gear: PGear; time: Longword);
procedure declareAchievement(id, teamname, location: shortstring; value: LongInt);
procedure startGhostPoints(n: LongInt);
procedure dumpPoint(x, y: LongInt);
implementation
uses uSound, uLocale, uVariables, uUtils, uIO, uCaptions, uMisc, uConsole, uScript;
var DamageClan : Longword = 0; // Damage of own clan in turn
DamageTeam : Longword = 0; // Damage of own team in turn
DamageTotal : Longword = 0; // Total damage dealt in game
DamageTurn : Longword = 0; // Damage in turn
PoisonTurn : Longword = 0; // Poisoned enemies in turn
PoisonClan : Longword = 0; // Poisoned own clan members in turn
PoisonTeam : Longword = 0; // Poisoned own team members in turn
PoisonTotal : Longword = 0; // Poisoned hogs in whole round
KillsClan : LongWord = 0; // Own clan members killed in turn
KillsTeam : LongWord = 0; // Own team members killed in turn
KillsSD : LongWord = 0; // Killed hedgehogs in turn that died by Sudden Death water rise
Kills : LongWord = 0; // Killed hedgehogs in turn (including those that died by Sudden Death water rise)
KillsTotal : LongWord = 0; // Total killed hedgehogs in game
HitTargets : LongWord = 0; // Target (gtTarget) hits in turn
AmmoUsedCount : Longword = 0; // Number of times an ammo has been used this turn
AmmoDamagingUsed : boolean = false; // true if damaging ammo was used in turn
FirstBlood : boolean = false; // true if the "First blood" taunt has been used in this game
StepFirstBlood : boolean = false; // true if the "First blood" taunt is to be used this turn
LeaveMeAlone : boolean = false; // true if the "Leave me alone" taunt is to be used this turn
SkippedTurns: LongWord = 0; // number of skipped turns in game
isTurnSkipped: boolean = false; // true if this turn was skipped
vpHurtSameClan: PVoicepack = nil; // voicepack of current clan (used for taunts)
vpHurtEnemy: PVoicepack = nil; // voicepack of enemy (used for taunts)
procedure HedgehogPoisoned(Gear: PGear; Attacker: PHedgehog);
begin
if Attacker^.Team^.Clan = Gear^.Hedgehog^.Team^.Clan then
begin
vpHurtSameClan:= Gear^.Hedgehog^.Team^.voicepack;
inc(PoisonClan);
if Attacker^.Team = Gear^.Hedgehog^.Team then
inc(PoisonTeam);
end
else
begin
if not FirstBlood then
StepFirstBlood:= true;
vpHurtEnemy:= Gear^.Hedgehog^.Team^.voicepack;
inc(PoisonTurn)
end;
Gear^.Hedgehog^.stats.StepPoisoned:= true;
inc(PoisonTotal)
end;
procedure HedgehogSacrificed(Hedgehog: PHedgehog);
begin
Hedgehog^.stats.Sacrificed:= true
end;
procedure HedgehogDamaged(Gear: PGear; Attacker: PHedgehog; Damage: Longword; killed: boolean);
var sameClan: Boolean;
begin
sameClan := false;
if Attacker <> nil then
sameClan := Attacker^.Team^.Clan = Gear^.Hedgehog^.Team^.Clan;
if sameClan then
vpHurtSameClan:= Gear^.Hedgehog^.Team^.voicepack
else
begin
if not FirstBlood then
StepFirstBlood:= true;
vpHurtEnemy:= Gear^.Hedgehog^.Team^.voicepack;
if (Attacker <> nil) and (not killed) and (not bDuringWaterRise) then
begin
// Check if victim got attacked by RevengeHog again
if (Gear^.Hedgehog^.RevengeHog <> nil) and (Gear^.Hedgehog^.RevengeHog = Attacker) and (Gear^.Hedgehog^.stats.StepRevenge = false) then
LeaveMeAlone:= true;
// Check if attacker got revenge
if (Attacker^.RevengeHog <> nil) and (Attacker^.RevengeHog = Gear^.Hedgehog) then
begin
Attacker^.stats.GotRevenge:= true;
// Also reset the "in-row" counter to restore LeaveMeAlone/CutItOut taunts
Attacker^.stats.StepDamageRecvInRow:= 0;
Attacker^.RevengeHog:= nil;
end
// If not, victim remembers their attacker to plan *their* revenge
else
begin
Gear^.Hedgehog^.RevengeHog:= Attacker;
// To prevent "LeaveMeAlone" being activated if same hog is hit by attacker
// multiple times in the same turn.
Gear^.Hedgehog^.stats.StepRevenge:= true;
end;
end
end;
//////////////////////////
if (not bDuringWaterRise) then
begin
if Attacker <> nil then
inc(Attacker^.stats.StepDamageGiven, Damage);
inc(Gear^.Hedgehog^.stats.StepDamageRecv, Damage);
end;
if CurrentHedgehog^.Team^.Clan = Gear^.Hedgehog^.Team^.Clan then inc(DamageClan, Damage);
if CurrentHedgehog^.Team = Gear^.Hedgehog^.Team then inc(DamageTeam, Damage);
if killed then
begin
Gear^.Hedgehog^.stats.StepDied:= true;
inc(Kills);
inc(KillsTotal);
if bDuringWaterRise then
inc(KillsSD)
else if Attacker <> nil then
begin
inc(Attacker^.stats.StepKills);
inc(Attacker^.Team^.stats.Kills);
if (Attacker^.Team^.TeamName = Gear^.Hedgehog^.Team^.TeamName) then
begin
inc(Attacker^.Team^.stats.TeamKills);
inc(Attacker^.Team^.stats.TeamDamage, Gear^.Damage);
end;
if Gear = Attacker^.Gear then
inc(Attacker^.Team^.stats.Suicides);
if Attacker^.Team^.Clan = Gear^.Hedgehog^.Team^.Clan then
begin
inc(KillsClan);
if Attacker^.Team = Gear^.Hedgehog^.Team then
inc(KillsTeam);
end;
end;
end;
inc(DamageTotal, Damage);
inc(DamageTurn, Damage)
end;
procedure TargetHit();
begin
inc(HitTargets)
end;
procedure Skipped;
begin
inc(SkippedTurns);
isTurnSkipped:= true
end;
function getIsTurnSkipped: boolean;
begin
getIsTurnSkipped:= isTurnSkipped;
end;
procedure TurnStats;
var i, t: LongInt;
c: Longword;
newEntry: PClanDeathLogEntry;
begin
inc(FinishedTurnsTotal);
for t:= 0 to Pred(TeamsCount) do // send even on zero turn
with TeamsArray[t]^ do
for i:= 0 to cMaxHHIndex do
begin
with Hedgehogs[i].stats do
begin
inc(DamageRecv, StepDamageRecv);
inc(DamageGiven, StepDamageGiven);
if StepDamageRecv > MaxStepDamageRecv then
MaxStepDamageRecv:= StepDamageRecv;
if StepDamageGiven > MaxStepDamageGiven then
MaxStepDamageGiven:= StepDamageGiven;
if StepKills > MaxStepKills then
MaxStepKills:= StepKills;
if (Hedgehogs[i].Team <> nil) and (Hedgehogs[i].Team^.Clan^.ClanIndex <> CurrentHedgehog^.Team^.Clan^.ClanIndex) then
begin
if StepDamageRecv > 0 then
inc(StepDamageRecvInRow)
else
StepDamageRecvInRow:= 0;
if StepDamageRecvInRow >= 3 then
LeaveMeAlone:= true;
end;
end;
end;
// Write into the death log which clans died in this turn,
// important for final rankings.
c:= 0;
newEntry:= nil;
for t:= 0 to Pred(ClansCount) do
with ClansArray[t]^ do
begin
if (ClanHealth = 0) and (ClansArray[t]^.DeathLogged = false) then
begin
if c = 0 then
begin
new(newEntry);
newEntry^.Turn := FinishedTurnsTotal;
newEntry^.NextEntry := nil;
end;
newEntry^.KilledClans[c]:= ClansArray[t];
inc(c);
newEntry^.KilledClansCount := c;
ClansArray[t]^.DeathLogged:= true;
end;
if SendHealthStatsOn then
SendStat(siClanHealth, IntToStr(Color) + ' ' + IntToStr(ClanHealth));
end;
if newEntry <> nil then
begin
if ClanDeathLog <> nil then
begin
newEntry^.NextEntry:= ClanDeathLog;
end;
ClanDeathLog:= newEntry;
end;
end;
procedure TurnReaction;
var killsCheck: LongInt;
s: ansistring;
begin
//TryDo(not bBetweenTurns, 'Engine bug: TurnReaction between turns', true);
if FinishedTurnsTotal <> 0 then
begin
s:= ansistring(CurrentHedgehog^.Name);
inc(CurrentHedgehog^.stats.FinishedTurns);
// killsCheck is used to take deaths into account that were not a traditional "kill"
// Hogs that died during SD water rise do not count as "kills" for taunts
killsCheck:= KillsSD;
// If the hog sacrificed (=kamikaze/piano) itself, this needs to be taken into account for the reactions later
if (CurrentHedgehog^.stats.Sacrificed) then
inc(killsCheck);
// First blood (first damage, poison or kill of enemy)
if (StepFirstBlood) and (not FirstBlood) and (ClansCount > 1) and ((DamageTotal > 0) or (KillsTotal > 0) or (PoisonTotal > 0)) then
begin
FirstBlood:= true;
AddVoice(sndFirstBlood, CurrentTeam^.voicepack);
end
// Hog hurts, poisons or kills itself (except sacrifice)
else if (CurrentHedgehog^.stats.Sacrificed = false) and ((CurrentHedgehog^.stats.StepDamageRecv > 0) or (CurrentHedgehog^.stats.StepPoisoned) or (CurrentHedgehog^.stats.StepDied)) then
// Hurt itself only (without dying)
if (CurrentHedgehog^.stats.StepDamageGiven = CurrentHedgehog^.stats.StepDamageRecv) and (CurrentHedgehog^.stats.StepDamageRecv >= 1) and (not CurrentHedgehog^.stats.StepDied) then
begin
// Announcer message + random taunt
AddCaption(FormatA(GetEventString(eidHurtSelf), s), capcolDefault, capgrpMessage);
if (CurrentHedgehog^.stats.StepDamageGiven <= CurrentHedgehog^.stats.StepDamageRecv) and (CurrentHedgehog^.stats.StepDamageRecv >= 1) then
case random(3) of
0: AddVoice(sndStupid, PreviousTeam^.voicepack);
1: AddVoice(sndBugger, CurrentTeam^.voicepack);
2: AddVoice(sndDrat, CurrentTeam^.voicepack);
end;
end
// Hurt itself and others, or died
else
AddVoice(sndStupid, PreviousTeam^.voicepack)
// Hog hurts, poisons or kills own team/clan member. Sacrifice is taken into account
else if (DamageClan <> 0) or (KillsClan > killsCheck) or (PoisonClan <> 0) then
if (DamageTurn > DamageClan) or ((Kills-KillsSD) > KillsClan) then
if random(2) = 0 then
AddVoice(sndNutter, CurrentTeam^.voicepack)
else
AddVoice(sndWatchIt, vpHurtSameClan)
else
// Attacked same team
if (random(2) = 0) and ((DamageTeam <> 0) or (KillsTeam > killsCheck) or (PoisonTeam <> 0)) then
AddVoice(sndSameTeam, vpHurtSameClan)
// Attacked same team or a clan member
else
AddVoice(sndTraitor, vpHurtSameClan)
// Hog hurts, kills or poisons enemy
else if (CurrentHedgehog^.stats.StepDamageGiven <> 0) or (CurrentHedgehog^.stats.StepKills > killsCheck) or (PoisonTurn <> 0) then
// 3 kills or more
if Kills > killsCheck + 2 then
AddVoice(sndAmazing, CurrentTeam^.voicepack)
// 2 kills
else if Kills = (killsCheck + 2) then
if random(2) = 0 then
AddVoice(sndBrilliant, CurrentTeam^.voicepack)
else
AddVoice(sndExcellent, CurrentTeam^.voicepack)
// 1 kill
else if Kills = (killsCheck + 1) then
AddVoice(sndEnemyDown, CurrentTeam^.voicepack)
// 0 kills, only damage or poison
else
// possible reactions of victim, in the order of preference:
// 1. claiming revenge
// 2. complaining about getting attacked too often
// 3. threatening enemy with retaliation
if CurrentHedgehog^.stats.GotRevenge then
begin
AddVoice(sndRevenge, CurrentHedgehog^.Team^.voicepack);
// If revenge taunt was added, one of the following voices is
// added as fallback (4th param), in case of a missing Revenge sound file.
case random(4) of
0: AddVoice(sndRegret, vpHurtEnemy, false, true);
1: AddVoice(sndGonnaGetYou, vpHurtEnemy, false, true);
2: AddVoice(sndIllGetYou, vpHurtEnemy, false, true);
3: AddVoice(sndJustYouWait, vpHurtEnemy, false, true);
end;
end
else
if LeaveMeAlone then
if random(2) = 0 then
AddVoice(sndCutItOut, vpHurtEnemy)
else
AddVoice(sndLeaveMeAlone, vpHurtEnemy)
else
case random(4) of
0: AddVoice(sndRegret, vpHurtEnemy);
1: AddVoice(sndGonnaGetYou, vpHurtEnemy);
2: AddVoice(sndIllGetYou, vpHurtEnemy);
3: AddVoice(sndJustYouWait, vpHurtEnemy);
end
// Missed shot
// A miss is defined as a shot with a damaging weapon with 0 kills, 0 damage, 0 hogs poisoned and 0 targets hit
else if AmmoDamagingUsed and (Kills <= killsCheck) and (PoisonTurn = 0) and (PoisonClan = 0) and (DamageTurn = 0) and (HitTargets = 0) then
// Chance to call hedgehog stupid or nutter if sacrificed for nothing
if CurrentHedgehog^.stats.Sacrificed then
case random(3) of
0: AddVoice(sndMissed, PreviousTeam^.voicepack);
1: AddVoice(sndStupid, PreviousTeam^.voicepack);
2: AddVoice(sndNutter, PreviousTeam^.voicepack);
end
else
AddVoice(sndMissed, PreviousTeam^.voicepack)
// Timeout
else if (AmmoUsedCount > 0) and (not isTurnSkipped) then
begin end// nothing ?
// Turn skipped
else if isTurnSkipped and (not PlacingHogs) and (not PlacingKings) then
begin
AddVoice(sndCoward, PreviousTeam^.voicepack);
AddCaption(FormatA(GetEventString(eidTurnSkipped), s), capcolDefault, capgrpMessage);
end
end;
end;
procedure TurnStatsReset;
var t, i: LongInt;
begin
for t:= 0 to Pred(TeamsCount) do // send even on zero turn
with TeamsArray[t]^ do
for i:= 0 to cMaxHHIndex do
with Hedgehogs[i].stats do
begin
StepKills:= 0;
StepDamageRecv:= 0;
StepDamageGiven:= 0;
StepPoisoned:= false;
StepDied:= false;
GotRevenge:= false;
StepRevenge:= false;
end;
Kills:= 0;
KillsSD:= 0;
KillsClan:= 0;
KillsTeam:= 0;
DamageClan:= 0;
DamageTeam:= 0;
DamageTurn:= 0;
HitTargets:= 0;
PoisonClan:= 0;
PoisonTeam:= 0;
PoisonTurn:= 0;
AmmoUsedCount:= 0;
LeaveMeAlone:= false;
AmmoDamagingUsed:= false;
isTurnSkipped:= false;
StepFirstBlood:= false;
end;
procedure AmmoUsed(am: TAmmoType);
begin
inc(AmmoUsedCount);
AmmoDamagingUsed:= AmmoDamagingUsed or Ammoz[am].isDamaging
end;
procedure hedgehogFlight(Gear: PGear; time: Longword);
begin
if time > 4000 then
begin
WriteLnToConsole('FLIGHT');
WriteLnToConsole(Gear^.Hedgehog^.Team^.TeamName);
WriteLnToConsole(inttostr(time));
WriteLnToConsole( '');
end
end;
procedure SendStats;
var i, t, c: LongInt;
msd, msk: Longword; msdhh, mskhh: PHedgehog;
mskcnt: Longword;
maxTeamKills : Longword;
maxTeamKillsName : shortstring;
maxTurnSkips : Longword;
maxTurnSkipsName : shortstring;
maxTeamDamage : Longword;
maxTeamDamageName : shortstring;
winnersClan : PClan;
deathEntry : PClanDeathLogEntry;
currentRank: Longword;
begin
if SendHealthStatsOn then
msd:= 0; msdhh:= nil;
msk:= 0; mskhh:= nil;
mskcnt:= 0;
maxTeamKills := 0;
maxTurnSkips := 0;
maxTeamDamage := 0;
winnersClan:= nil;
currentRank:= 0;
for t:= 0 to Pred(TeamsCount) do
with TeamsArray[t]^ do
begin
if (not ExtDriven) and SendRankingStatsOn then
SendStat(siTeamStats, GetTeamStatString(TeamsArray[t]));
for i:= 0 to cMaxHHIndex do
begin
if Hedgehogs[i].stats.MaxStepDamageGiven > msd then
begin
msdhh:= @Hedgehogs[i];
msd:= Hedgehogs[i].stats.MaxStepDamageGiven
end;
if Hedgehogs[i].stats.MaxStepKills >= msk then
if Hedgehogs[i].stats.MaxStepKills = msk then
inc(mskcnt)
else
begin
mskcnt:= 1;
mskhh:= @Hedgehogs[i];
msk:= Hedgehogs[i].stats.MaxStepKills
end;
end;
{ Send player stats for winner clans/teams.
The clan that survived is ranked 1st. }
if (Clan^.ClanHealth > 0) then
begin
winnersClan:= Clan;
if SendRankingStatsOn then
begin
currentRank:= 1;
SendStat(siTeamRank, _S'1');
SendStat(siPlayerKills, IntToStr(Clan^.Color) + ' ' +
IntToStr(stats.Kills) + ' ' + TeamName);
end;
end;
{ determine maximum values of TeamKills, TurnSkips, TeamDamage }
if stats.TeamKills > maxTeamKills then
begin
maxTeamKills := stats.TeamKills;
maxTeamKillsName := TeamName;
end;
if stats.TurnSkips > maxTurnSkips then
begin
maxTurnSkips := stats.TurnSkips;
maxTurnSkipsName := TeamName;
end;
if stats.TeamDamage > maxTeamDamage then
begin
maxTeamDamage := stats.TeamDamage;
maxTeamDamageName := TeamName;
end;
end;
inc(currentRank);
{ Now send player stats for loser teams/clans.
The losing clans are ranked in the reverse order they died.
The clan that died last is ranked 2nd,
the clan that died second to last is ranked 3rd,
and so on.
Clans that died in the same turn share their rank.
If a clan died multiple times in the match
(e.g. due to resurrection), only the *latest* death of
that clan counts (handled in gtResurrector).
}
deathEntry := ClanDeathLog;
i:= 0;
if SendRankingStatsOn then
while (deathEntry <> nil) do
begin
for c:= 0 to Pred(deathEntry^.KilledClansCount) do
if ((deathEntry^.KilledClans[c]^.ClanHealth) = 0) and (not deathEntry^.KilledClans[c]^.StatsHandled) then
begin
for t:= 0 to Pred(TeamsCount) do
if (TeamsArray[t]^.Clan^.ClanIndex = deathEntry^.KilledClans[c]^.ClanIndex) then
begin
SendStat(siTeamRank, IntToStr(currentRank));
SendStat(siPlayerKills, IntToStr(deathEntry^.killedClans[c]^.Color) + ' ' +
IntToStr(TeamsArray[t]^.stats.Kills) + ' ' + TeamsArray[t]^.TeamName);
end;
deathEntry^.KilledClans[c]^.StatsHandled:= true;
inc(i);
end;
if i > 0 then
inc(currentRank, i);
i:= 0;
deathEntry:= deathEntry^.NextEntry;
end;
// "Achievements" / Details part of stats screen
if SendAchievementsStatsOn then
begin
if msdhh <> nil then
SendStat(siMaxStepDamage, IntToStr(msd) + ' ' + msdhh^.Name + ' (' + msdhh^.Team^.TeamName + ')');
if mskcnt = 1 then
SendStat(siMaxStepKills, IntToStr(msk) + ' ' + mskhh^.Name + ' (' + mskhh^.Team^.TeamName + ')');
if maxTeamKills > 1 then
SendStat(siMaxTeamKills, IntToStr(maxTeamKills) + ' ' + maxTeamKillsName);
if maxTurnSkips > 2 then
SendStat(siMaxTurnSkips, IntToStr(maxTurnSkips) + ' ' + maxTurnSkipsName);
if maxTeamDamage > 30 then
SendStat(siMaxTeamDamage, IntToStr(maxTeamDamage) + ' ' + maxTeamDamageName);
if KilledHHs > 0 then
SendStat(siKilledHHs, IntToStr(KilledHHs));
end;
// now to console
if winnersClan <> nil then
begin
ScriptCall('onGameResult', winnersClan^.ClanIndex);
WriteLnToConsole('WINNERS');
WriteLnToConsole(inttostr(winnersClan^.TeamsNumber));
for t:= 0 to winnersClan^.TeamsNumber - 1 do
WriteLnToConsole(winnersClan^.Teams[t]^.TeamName);
end
else
begin
ScriptCall('onGameResult', -1);
WriteLnToConsole('DRAW');
end;
ScriptCall('onAchievementsDeclaration');
end;
procedure declareAchievement(id, teamname, location: shortstring; value: LongInt);
begin
if (length(id) = 0) or (length(teamname) = 0) or (length(location) = 0) then exit;
WriteLnToConsole('ACHIEVEMENT');
WriteLnToConsole(id);
WriteLnToConsole(teamname);
WriteLnToConsole(location);
WriteLnToConsole(inttostr(value));
end;
procedure startGhostPoints(n: LongInt);
begin
WriteLnToConsole('GHOST_POINTS');
WriteLnToConsole(inttostr(n));
end;
procedure dumpPoint(x, y: LongInt);
begin
WriteLnToConsole(inttostr(x));
WriteLnToConsole(inttostr(y));
end;
procedure initModule;
begin
DamageClan := 0;
DamageTeam := 0;
DamageTotal := 0;
DamageTurn := 0;
PoisonClan := 0;
PoisonTeam := 0;
PoisonTurn := 0;
KillsClan := 0;
KillsTeam := 0;
KillsSD := 0;
Kills := 0;
KillsTotal := 0;
HitTargets := 0;
AmmoUsedCount := 0;
AmmoDamagingUsed := false;
FirstBlood:= false;
StepFirstblood:= false;
LeaveMeAlone := false;
SkippedTurns:= 0;
isTurnSkipped:= false;
vpHurtSameClan:= nil;
vpHurtEnemy:= nil;
TotalRoundsPre:= -1;
TotalRoundsReal:= -1;
FinishedTurnsTotal:= -1;
ClanDeathLog:= nil;
end;
procedure freeModule;
begin
end;
end.
| 36.648204 | 233 | 0.610269 |
838601351502edb54a6986fbe2c92767cac259b3 | 2,737 | pas | Pascal | samples/c4plus/plasma.pas | zbyti/Mad-Pascal | 546cae9724828f93047080109488be7d0d07d47e | [
"MIT"
]
| 1 | 2021-12-15T23:47:19.000Z | 2021-12-15T23:47:19.000Z | samples/c4plus/plasma.pas | michalkolodziejski/Mad-Pascal | 0a7a1e2f379e50b0a23878b0d881ff3407269ed6 | [
"MIT"
]
| null | null | null | samples/c4plus/plasma.pas | michalkolodziejski/Mad-Pascal | 0a7a1e2f379e50b0a23878b0d881ff3407269ed6 | [
"MIT"
]
| null | null | null | // 06_plasma.ras, Turbo Rascal example
uses fastmath;
//-----------------------------------------------------------------------------
const
COLOURRAM_ADDR = $0800; SCREEN_ADDR = $0c00;
SCR_W = 40; SCR_H = 25;
DATA_CHAR: array [0..127] of byte = (
$00, $00, $00, $00, $00, $00, $00, $00,
$00, $00, $00, $10, $00, $00, $00, $00,
$00, $00, $18, $18, $00, $00, $00, $00,
$00, $00, $38, $38, $38, $00, $00, $00,
$00, $00, $3c, $3c, $3c, $3c, $00, $00,
$00, $7c, $7c, $7c, $7c, $7c, $00, $00,
$00, $7e, $7e, $7e, $7e, $7e, $7e, $00,
$fe, $fe, $fe, $fe, $fe, $fe, $fe, $00,
$00, $7f, $7f, $7f, $7f, $7f, $7f, $7f,
$00, $7e, $7e, $7e, $7e, $7e, $7e, $00,
$00, $7c, $7c, $7c, $7c, $7c, $00, $00,
$00, $00, $3c, $3c, $3c, $3c, $00, $00,
$00, $00, $38, $38, $38, $00, $00, $00,
$00, $00, $18, $18, $00, $00, $00, $00,
$00, $00, $00, $08, $00, $00, $00, $00,
$00, $00, $00, $00, $00, $00, $00, $00
);
//-----------------------------------------------------------------------------
var
RAMROMSEL : byte absolute $ff12;
CHBAS : byte absolute $ff13;
c1A : byte = 1;
c1B : byte = 5;
scrn : PByte absolute $60;
charset : array [0..0] of byte absolute $3000;
sinusTable : array [0..255] of byte absolute $3100;
lookupDiv16 : array [0..255] of byte absolute $3200;
xbuf : array [0..39] of byte absolute $3300;
//-----------------------------------------------------------------------------
procedure InitDivision16;
var x: byte;
begin
for x:=0 to 255 do lookupDiv16[x] := x shr 4; // Simply store values divided by 16
end;
procedure InitCharset;
begin
Move(DATA_CHAR, charset, SizeOf(DATA_CHAR));
// set bit 2
RAMROMSEL := RAMROMSEL and %11111011;
// 12 = $3000 / $400 on 2-7 bits
CHBAS := (CHBAS and %11) or 12 shl 2;
end;
//-----------------------------------------------------------------------------
procedure doPlasma;
var
_c1a, _c1b : byte;
i, ii, tmp : byte;
begin
scrn := pointer(SCREEN_ADDR);
_c1a := c1A; _c1b := c1B;
for i := (SCR_W - 1) downto 0 do begin
xbuf[i] := sinusTable[_c1a] + sinusTable[_c1b];
Inc(_c1a, 3); Inc(_c1b, 7);
end;
for ii := (SCR_H - 1) downto 0 do begin
tmp := sinusTable[_c1a] + sinusTable[_c1b];
Inc(_c1a, 4); Inc(_c1b, 9);
for i := (SCR_W - 1) downto 0 do
scrn[i] := lookupDiv16[xbuf[i] + tmp];
Inc(scrn, 40);
end;
Inc(c1A, 3); Dec(c1B, 5);
end;
//-----------------------------------------------------------------------------
begin
FillSinHigh(sinusTable); InitDivision16; InitCharset;
repeat
Pause; doPlasma;
until false;
end.
| 25.110092 | 84 | 0.444282 |
47b2f19e7a08d6997f5725ba3dc45b28a4a66aa8 | 5,321 | pas | Pascal | Commands/Commands.GetText.pas | mmarquee/DelphiWebDriver | 312fcb62fdc86af8364af4465c5ecaad1aa2acb4 | [
"Apache-2.0"
]
| 9 | 2017-11-27T06:25:56.000Z | 2021-05-29T01:57:59.000Z | Commands/Commands.GetText.pas | mmarquee/DelphiWebDriver | 312fcb62fdc86af8364af4465c5ecaad1aa2acb4 | [
"Apache-2.0"
]
| 1 | 2017-05-02T15:09:59.000Z | 2017-05-03T18:23:18.000Z | Commands/Commands.GetText.pas | mmarquee/DelphiWebDriver | 312fcb62fdc86af8364af4465c5ecaad1aa2acb4 | [
"Apache-2.0"
]
| 2 | 2017-11-27T06:26:06.000Z | 2021-05-28T05:03:39.000Z | {***************************************************************************}
{ }
{ DelphiWebDriver }
{ }
{ Copyright 2017 inpwtepydjuf@gmail.com }
{ }
{***************************************************************************}
{ }
{ Licensed under the Apache License, Version 2.0 (the "License"); }
{ you may not use this file except in compliance with the License. }
{ You may obtain a copy of the License at }
{ }
{ http://www.apache.org/licenses/LICENSE-2.0 }
{ }
{ Unless required by applicable law or agreed to in writing, software }
{ distributed under the License is distributed on an "AS IS" BASIS, }
{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. }
{ See the License for the specific language governing permissions and }
{ limitations under the License. }
{ }
{***************************************************************************}
unit Commands.GetText;
interface
uses
Vcl.Forms,
CommandRegistry,
HttpServerCommand;
type
/// <summary>
/// Handles 'GET' '/session/(.*)/element/(.*)/text'
/// </summary>
TGetTextCommand = class(TRESTCommand)
private
function OKResponse(const handle, value: String): String;
public
class function GetCommand: String; override;
class function GetRoute: String; override;
procedure Execute(AOwner: TForm); override;
end;
implementation
uses
System.JSON,
System.JSON.Types,
Vcl.Controls,
Vcl.Grids,
System.SysUtils,
System.Classes,
System.StrUtils,
Vcl.ComCtrls,
Vcl.Menus,
Vcl.ExtCtrls,
Vcl.Buttons,
Vcl.StdCtrls,
utils;
procedure TGetTextCommand.Execute(AOwner: TForm);
var
comp: TComponent;
ctrl: TWinControl;
handle: Integer;
parent: TComponent;
values : TStringList;
value: String;
const
Delimiter = '.';
begin
if (isNumber(self.Params[2])) then
begin
handle := StrToInt(self.Params[2]);
ctrl := FindControl(handle);
if (ctrl <> nil) then
begin
if (ctrl is TEdit) then
value := (ctrl as TEdit).Text
else if (ctrl is TStaticText) then
value := (ctrl as TStaticText).Caption
else if (ctrl is TCheckBox) then
value := (ctrl as TCheckBox).Caption
else if (ctrl is TLinkLabel) then
value := (ctrl as TLinkLabel).Caption
else if (ctrl is TRadioButton) then
value := (ctrl as TRadioButton).Caption;
ResponseJSON(OKResponse(self.Params[2], value));
end
else
Error(404);
end
else
begin
// This might be a non-WinControl OR a DataItem for a container
if (ContainsText(self.Params[2], Delimiter)) then
begin
values := TStringList.Create;
try
values.Delimiter := Delimiter;
values.StrictDelimiter := True;
values.DelimitedText := self.Params[2];
// Get parent
parent := AOwner.FindComponent(values[0]);
if (parent is TListBox) then
begin
value := (parent as TListBox).items[StrToInt(values[1])];
end
else if (parent is TStringGrid) then
begin
value := (parent as TStringGrid).Cells[StrToInt(values[1]),StrToInt(values[2])];
end
else if (parent is TPageControl) then
begin
value := (parent as TPageControl).Pages[StrToInt(values[1])].Caption;
end
else if (parent is TCombobox) then
begin
value := (parent as TCombobox).items[StrToInt(values[1])];
end;
// Now send it back please
ResponseJSON(OKResponse(self.Params[2], value));
finally
values.free;
end;
end
else
begin
comp := AOwner.FindComponent(self.Params[2]);
if (comp <> nil) then
begin
if (comp is TSpeedButton) then
Value := (comp as TSpeedButton).Caption
else if (comp is TMenuItem) then
Value := (comp as TMenuItem).Caption
else if (comp is TLabel) then
Value := (comp as TLabel).Caption;
ResponseJSON(OKResponse(self.Params[2], value));
end
else
Error(404);
end;
end;
end;
function TGetTextCommand.OKResponse(const handle, value: String): String;
var
jsonObject: TJSONObject;
begin
jsonObject := TJSONObject.Create;
jsonObject.AddPair(TJSONPair.Create('id', handle));
jsonObject.AddPair(TJSONPair.Create('value', value));
result := jsonObject.ToString;
end;
class function TGetTextCommand.GetCommand: String;
begin
result := 'GET';
end;
class function TGetTextCommand.GetRoute: String;
begin
result := '/session/(.*)/element/(.*)/text';
end;
end.
| 29.561111 | 90 | 0.526029 |
f1a8978b1bfc4dd2ce859f9483cbe409803b08a0 | 597 | pas | Pascal | Libraries/Spring4D/Samples/SpringDemos/Demo.AutoMocking/Interfaces.pas | jomael/Concepts | 82d18029e41d55e897d007f826c021cdf63e53f8 | [
"Apache-2.0"
]
| 62 | 2016-01-20T16:26:25.000Z | 2022-02-28T14:25:52.000Z | Libraries/Spring4D/Samples/SpringDemos/Demo.AutoMocking/Interfaces.pas | jomael/Concepts | 82d18029e41d55e897d007f826c021cdf63e53f8 | [
"Apache-2.0"
]
| null | null | null | Libraries/Spring4D/Samples/SpringDemos/Demo.AutoMocking/Interfaces.pas | jomael/Concepts | 82d18029e41d55e897d007f826c021cdf63e53f8 | [
"Apache-2.0"
]
| 20 | 2016-09-08T00:15:22.000Z | 2022-01-26T13:13:08.000Z | unit Interfaces;
interface
uses
Spring.Collections;
type
ICommandChannel = interface(IInvokable)
['{1C78299A-9963-45B6-BAD5-D31251754625}']
function Send(const item: TObject): Integer;
function Send2(const item: TObject): Integer;
end;
INumberParser = interface(IInvokable)
['{5CDF38F1-B28F-4B61-BA7E-6EAC0B2BDDF9}']
function Parse(const expression: string): IEnumerable<Integer>;
end;
INumberParserFactory = interface(IInvokable)
['{C12B2F4B-11D5-4A8F-872B-FE7437BD1C70}']
function Create(delimiter: Char): INumberParser;
end;
implementation
end.
| 21.321429 | 67 | 0.733668 |
477ec95cbb7554ffb4f63c4b375c478e8f169649 | 1,561 | pas | Pascal | src/bodymovin.CanvasManager.pas | snakeice/lottie-player | 7083fc29c55a6ab70a421c55c396f79f1001a148 | [
"MIT"
]
| 1 | 2019-09-06T13:38:15.000Z | 2019-09-06T13:38:15.000Z | src/bodymovin.CanvasManager.pas | snakeice/lottie-player | 7083fc29c55a6ab70a421c55c396f79f1001a148 | [
"MIT"
]
| null | null | null | src/bodymovin.CanvasManager.pas | snakeice/lottie-player | 7083fc29c55a6ab70a421c55c396f79f1001a148 | [
"MIT"
]
| 1 | 2019-09-06T13:38:17.000Z | 2019-09-06T13:38:17.000Z | unit bodymovin.CanvasManager;
interface
uses
System.Generics.Collections, FMX.Graphics, FMX.Layouts, FMX.Objects, System.Classes;
type
TFrameKey = class
procedure DoRender(ALayer: TCanvas);
end;
TCanvasLayer = class(TLayout)
private
FLayers: array of TRectangle;
function GetLayer(AIndex: Integer): TCanvas;
function CreateLayer: TRectangle;
public
constructor Create(AOwner: TComponent); override;
procedure DrawFrame(AFrameData: TFrameKey; ALayer: Integer);
destructor Destroy; override;
property Layer[Index: Integer]: TCanvas read GetLayer;
end;
implementation
uses
FMX.Types, System.UITypes;
{ TCanvasLayer }
constructor TCanvasLayer.Create(AOwner: TComponent);
begin
inherited;
end;
function TCanvasLayer.CreateLayer: TRectangle;
begin
Result := TRectangle.Create(Self);
Result.Parent := Self;
Result.Fill.Color := TAlphaColorRec.Null;
Result.Stroke.Kind := TBrushKind.None;
Result.Align := TAlignLayout.Contents;
Result.BringToFront;
end;
destructor TCanvasLayer.Destroy;
begin
FLayers := [];
inherited;
end;
procedure TCanvasLayer.DrawFrame(AFrameData: TFrameKey; ALayer: Integer);
begin
AFrameData.DoRender(Layer[ALayer]);
end;
function TCanvasLayer.GetLayer(AIndex: Integer): TCanvas;
begin
if Length(FLayers) - 1 < AIndex then
SetLength(FLayers, AIndex + 1);
if not Assigned(FLayers[AIndex]) then
FLayers[AIndex] := CreateLayer;
Result := FLayers[AIndex].Canvas;
end;
{ TFrameKey }
procedure TFrameKey.DoRender(ALayer: TCanvas);
begin
end;
end.
| 19.271605 | 86 | 0.742473 |
47046cb5be0e2984c978f9a55b129a069da5c399 | 28,084 | pas | Pascal | windows/src/ext/jedi/jcl/jcl/experts/useswizard/JCLUsesWizard.pas | bravogeorge/keyman | c0797e36292de903d7313214d1f765e3d9a2bf4d | [
"MIT"
]
| 219 | 2017-06-21T03:37:03.000Z | 2022-03-27T12:09:28.000Z | windows/src/ext/jedi/jcl/jcl/experts/useswizard/JCLUsesWizard.pas | bravogeorge/keyman | c0797e36292de903d7313214d1f765e3d9a2bf4d | [
"MIT"
]
| 4,451 | 2017-05-29T02:52:06.000Z | 2022-03-31T23:53:23.000Z | windows/src/ext/jedi/jcl/jcl/experts/useswizard/JCLUsesWizard.pas | bravogeorge/keyman | c0797e36292de903d7313214d1f765e3d9a2bf4d | [
"MIT"
]
| 72 | 2017-05-26T04:08:37.000Z | 2022-03-03T10:26:20.000Z | {**************************************************************************************************}
{ }
{ Project JEDI Code Library (JCL) }
{ }
{ The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); }
{ you may not use this file except in compliance with the License. You may obtain a copy of the }
{ License at http://www.mozilla.org/MPL/ }
{ }
{ Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF }
{ ANY KIND, either express or implied. See the License for the specific language governing rights }
{ and limitations under the License. }
{ }
{ The Original Code is JclUsesWizard.pas. }
{ }
{ The Initial Developer of the Original Code is TOndrej (tondrej att t-online dott de). }
{ Portions created by TOndrej are Copyright (C) of TOndrej. }
{ }
{ Contributors: }
{ }
{**************************************************************************************************}
{ }
{ Last modified: $Date:: $ }
{ Revision: $Rev:: $ }
{ Author: $Author:: $ }
{ }
{**************************************************************************************************}
unit JclUsesWizard;
{$I jcl.inc}
interface
uses
SysUtils, Windows, Classes, Messages, Forms, Controls, StdCtrls, ComCtrls,
ExtCtrls,
ToolsAPI,
{$IFDEF UNITVERSIONING}
JclUnitVersioning,
{$ENDIF UNITVERSIONING}
JclOtaUtils, JclOptionsFrame;
type
TWizardAction = (waSkip, waAddToImpl, waAddToIntf, waMoveToIntf);
PErrorInfo = ^TErrorInfo;
TErrorInfo = record
// parsed from compiler message
UnitName: array [0..MAX_PATH - 1] of Char;
LineNumber: Integer;
Identifier: array [0..MAX_PATH - 1] of Char;
// resolved by wizard
UsesName: array [0..MAX_PATH - 1] of Char; // unit name to be added to uses clause
end;
TJCLUsesWizard = class(TJclOTAExpert)
private
FActive: Boolean;
FApplicationIdle: TIdleEvent;
FConfirmChanges: Boolean;
FErrors: TList;
FIdentifierLists: TStrings;
FIniFile: string;
FNotifierIndex: Integer;
FFrameJclOptions: TFrameJclOptions;
procedure AppIdle(Sender: TObject; var Done: Boolean);
procedure ClearErrors;
function DoConfirmChanges(ChangeList: TStrings): TModalResult;
procedure InitializeIdentifierLists;
procedure ProcessCompilerMessages(Messages: TStrings);
procedure ProcessUses;
procedure ResolveUsesName(Error: PErrorInfo);
procedure SetActive(Value: Boolean);
public
Value: Integer;
constructor Create; reintroduce;
destructor Destroy; override;
procedure RegisterCommands; override;
procedure UnregisterCommands; override;
procedure LoadSettings;
procedure SaveSettings;
property Active: Boolean read FActive write SetActive;
property ConfirmChanges: Boolean read FConfirmChanges write FConfirmChanges;
property IniFile: string read FIniFile write FIniFile;
public
function GetPageName: string; override;
function GetFrameClass: TCustomFrameClass; override;
procedure FrameCreated(AFrame: TCustomFrame); override;
procedure DialogClosed(Accepted: Boolean); override;
end;
TJCLUsesWizardNotifier = class(TNotifierObject, IOTANotifier, IOTAIDENotifier, IOTAIDENotifier50)
private
FWizard: TJclUsesWizard;
public
{ IOTAIDENotifier }
procedure AfterCompile(Succeeded: Boolean); overload;
procedure BeforeCompile(const Project: IOTAProject; var Cancel: Boolean); overload;
procedure FileNotification(NotifyCode: TOTAFileNotification; const FileName: string; var Cancel: Boolean);
{ IOTAIDENotifier50 }
procedure AfterCompile(Succeeded: Boolean; IsCodeInsight: Boolean); overload;
procedure BeforeCompile(const Project: IOTAProject; IsCodeInsight: Boolean; var Cancel: Boolean); overload;
public
constructor Create(AWizard: TJclUsesWizard); reintroduce;
property Wizard: TJclUsesWizard read FWizard;
end;
// design package entry point
procedure Register;
// expert DLL entry point
function JCLWizardInit(const BorlandIDEServices: IBorlandIDEServices;
RegisterProc: TWizardRegisterProc;
var TerminateProc: TWizardTerminateProc): Boolean; stdcall;
{$IFDEF UNITVERSIONING}
const
UnitVersioning: TUnitVersionInfo = (
RCSfile: '$URL$';
Revision: '$Revision$';
Date: '$Date$';
LogPath: 'JCL\experts\useswizard';
Extra: '';
Data: nil
);
{$ENDIF UNITVERSIONING}
implementation
uses
IniFiles,
JclFileUtils, JclUsesUtils, JclRegistry, JclStrings, JclStringConversions,
JclUsesDialog,
JclOtaConsts, JclOtaResources;
// create and register wizard instance
procedure Register;
begin
try
RegisterPackageWizard(TJCLUsesWizard.Create);
except
on ExceptionObj: TObject do
begin
JclExpertShowExceptionDialog(ExceptionObj);
raise;
end;
end;
end;
var
JCLWizardIndex: Integer = -1;
procedure JclWizardTerminate;
begin
try
if JCLWizardIndex <> -1 then
TJclOTAExpertBase.GetOTAWizardServices.RemoveWizard(JCLWizardIndex);
except
on ExceptionObj: TObject do
begin
JclExpertShowExceptionDialog(ExceptionObj);
end;
end;
end;
function JCLWizardInit(const BorlandIDEServices: IBorlandIDEServices;
RegisterProc: TWizardRegisterProc;
var TerminateProc: TWizardTerminateProc): Boolean stdcall;
begin
try
TerminateProc := JclWizardTerminate;
JCLWizardIndex := TJclOTAExpertBase.GetOTAWizardServices.AddWizard(TJCLUsesWizard.Create);
Result := True;
except
on ExceptionObj: TObject do
begin
JclExpertShowExceptionDialog(ExceptionObj);
Result := False;
end;
end;
end;
//=== { TLine } ==============================================================
// TLine 'guessed' from coreide60.bpl
type
TLine = class(TObject)
public
constructor Create; virtual;
destructor Destroy; override;
function GetLineText: string; virtual;
end;
{ TLine stubs }
constructor TLine.Create;
begin
end;
destructor TLine.Destroy;
begin
inherited Destroy;
end;
function TLine.GetLineText: string;
begin
Result := '';
end;
function FindClassForm(const AClassName: string): TForm;
var
I: Integer;
begin
Result := nil;
for I := 0 to Screen.FormCount - 1 do
if Screen.Forms[I].ClassNameIs(AClassName) then
begin
Result := Screen.Forms[I];
Break;
end;
end;
function GetLineNumber(S1, S2: PChar): Integer;
var
P: PChar;
begin
if S2 < S1 then
Result := 0
else
begin
Result := 1;
P := StrPos(S1, #13#10);
while (P <> nil) and (P <= S2) do
begin
Inc(Result);
P := StrPos(P + 2, #13#10);
end;
end;
end;
// the message treeview is custom drawn; hence this hack
procedure GetCompilerMessages(List: TStrings);
var
MessageViewForm: TForm;
I: Integer;
TreeView: TTreeView;
Node: TTreeNode;
Line: TLine;
begin
// if TMsgWindow exists all messages are sent to it
MessageViewForm := FindClassForm('TMsgWindow');
if MessageViewForm = nil then // otherwise TMessageViewForm is used
MessageViewForm := FindClassForm('TMessageViewForm');
if Assigned(MessageViewForm) then
begin
TreeView := nil;
with MessageViewForm do
for I := 0 to ControlCount - 1 do
if Controls[I].ClassNameIs('TTreeMessageView') then
begin
TreeView := Controls[I] as TTreeView;
Break;
end;
if Assigned(TreeView) then
begin
with TreeView do
begin
Node := Items.GetFirstNode;
while Node <> nil do
begin
Line := TLine(Node.Data);
if Assigned(Line) then
List.Add(Line.GetLineText);
Node := Node.GetNext;
end;
end;
end;
end;
end;
function ReadEditorBuffer(Buffer: IOTAEditBuffer): string;
const
BufSize = 1024;
var
Reader: IOTAEditReader;
Stream: TStringStream;
ReaderPos, Read: Integer;
Buf: array [0..BufSize] of Char;
begin
Result := '';
if Buffer = nil then
Exit;
Reader := Buffer.CreateReader;
Stream := TStringStream.Create('');
try
ReaderPos := 0;
repeat
Read := Reader.GetText(ReaderPos, @Buf, BufSize);
Inc(ReaderPos, Read);
if (Read < 0) or (Read > BufSize) then
raise EJclExpertException.CreateRes(@RsEErrorReadingBuffer);
Buf[Read] := #0;
Stream.WriteString(Buf);
until Read < BufSize;
Result := Stream.DataString;
finally
Stream.Free;
end;
end;
//=== { TJCLUsesWizardNotifier } =============================================
procedure TJCLUsesWizardNotifier.AfterCompile(Succeeded, IsCodeInsight: Boolean);
var
Messages: TStrings;
begin
try
if IsCodeInsight or Succeeded then
Exit;
Messages := TStringList.Create;
try
GetCompilerMessages(Messages);
if Assigned(Wizard) then
Wizard.ProcessCompilerMessages(Messages);
finally
Messages.Free;
end;
except
on ExceptionObj: TObject do
begin
JclExpertShowExceptionDialog(ExceptionObj);
raise;
end;
end;
end;
procedure TJCLUsesWizardNotifier.AfterCompile(Succeeded: Boolean);
begin
// do nothing
end;
procedure TJCLUsesWizardNotifier.BeforeCompile(const Project: IOTAProject;
IsCodeInsight: Boolean; var Cancel: Boolean);
begin
// do nothing
end;
procedure TJCLUsesWizardNotifier.BeforeCompile(const Project: IOTAProject; var Cancel: Boolean);
begin
// do nothing
end;
constructor TJCLUsesWizardNotifier.Create(AWizard: TJclUsesWizard);
begin
inherited Create;
FWizard := AWizard;
end;
procedure TJCLUsesWizardNotifier.FileNotification(NotifyCode: TOTAFileNotification;
const FileName: string; var Cancel: Boolean);
begin
// do nothing
end;
//=== { TJCLUsesWizard } =====================================================
procedure TJCLUsesWizard.AppIdle(Sender: TObject; var Done: Boolean);
begin
Application.OnIdle := FApplicationIdle;
FApplicationIdle := nil;
if FErrors.Count = 0 then
Exit;
ProcessUses;
end;
procedure TJCLUsesWizard.ClearErrors;
var
I: Integer;
P: PErrorInfo;
begin
for I := 0 to FErrors.Count - 1 do
begin
P := FErrors[I];
FreeMem(P);
end;
FErrors.Clear;
end;
constructor TJCLUsesWizard.Create;
begin
inherited Create(JclUsesExpertName);
FIdentifierLists := TStringList.Create;
FErrors := TList.Create;
FActive := False;
FConfirmChanges := False;
FNotifierIndex := -1;
end;
destructor TJCLUsesWizard.Destroy;
begin
SetActive(False);
ClearErrors;
FErrors.Free;
FIdentifierLists.Free;
inherited Destroy;
end;
procedure TJCLUsesWizard.DialogClosed(Accepted: Boolean);
begin
if Accepted then
begin
Active := FFrameJclOptions.Active;
ConfirmChanges := FFrameJclOptions.ConfirmChanges;
IniFile := FFrameJclOptions.ConfigFileName;
end;
FFrameJclOptions := nil;
end;
function TJCLUsesWizard.DoConfirmChanges(ChangeList: TStrings): TModalResult;
var
Dialog: TFormUsesConfirm;
begin
Dialog := TFormUsesConfirm.Create(nil, ChangeList, FErrors);
try
Result := Dialog.ShowModal;
finally
Dialog.Free;
end;
end;
procedure TJCLUsesWizard.FrameCreated(AFrame: TCustomFrame);
begin
FFrameJclOptions := AFrame as TFrameJclOptions;
FFrameJclOptions.Active := Active;
FFrameJclOptions.ConfirmChanges := ConfirmChanges;
FFrameJclOptions.ConfigFileName := IniFile;
end;
function TJCLUsesWizard.GetFrameClass: TCustomFrameClass;
begin
Result := TFrameJclOptions;
end;
function TJCLUsesWizard.GetPageName: string;
begin
Result := LoadResString(@RsUsesSheet);
end;
// load identifier lists
// each line represents one JCL unit in the following format:
// <unit_name>=<identifier0>,<identifier1>,...
procedure TJCLUsesWizard.InitializeIdentifierLists;
var
IniFile: TIniFile;
I: Integer;
IdentListFileName: string;
IdentList: TStrings;
begin
FIdentifierLists.Clear;
IniFile := TIniFile.Create(FIniFile);
try
IdentList := TStringList.Create;
try
IniFile.ReadSection(SIniIdentifierLists, FIdentifierLists);
for I := 0 to FIdentifierLists.Count - 1 do
begin
IdentListFileName := IniFile.ReadString(SIniIdentifierLists, FIdentifierLists[I],
ChangeFileExt(FIdentifierLists[I], '.txt'));
if ExtractFilePath(IdentListFileName) = '' then
IdentListFileName := ExtractFilePath(FIniFile) + IdentListFileName;
IdentList.LoadFromFile(IdentListFileName);
FIdentifierLists[I] := FIdentifierLists[I] + '=' + IdentList.CommaText;
end;
finally
IdentList.Free;
end;
finally
IniFile.Free;
end;
end;
procedure TJCLUsesWizard.LoadSettings;
var
DefaultIniFile, DefaultRegKey: string;
OTAServices: IOTAServices;
begin
OTAServices := GetOTAServices;
DefaultRegKey := StrEnsureSuffix(NativeBackslash, OTAServices.GetBaseRegistryKey) + RegJclKey;
DefaultIniFile := RegReadStringDef(HKCU, DefaultRegKey, JclRootDirValueName, '');
if DefaultIniFile <> '' then
DefaultIniFile := PathAddSeparator(DefaultIniFile) + JclIniFileLocation;
ConfirmChanges := Settings.LoadBool(SRegWizardConfirm, True);
IniFile := Settings.LoadString(SRegWizardIniFile, DefaultIniFile);
Active := Settings.LoadBool(SRegWizardActive, False);
end;
// load localized strings for the undeclared identifier error
procedure TJCLUsesWizard.ProcessCompilerMessages(Messages: TStrings);
const
SIdentFormatSpec = '%s';
var
I: Integer;
Error: PErrorInfo;
SError: string;
SUndeclaredIdent: string;
procedure LoadDcc32Strings;
const
SErrorID = 4147; // 'Error'
SUndeclaredIdentID = 47; // 'Undeclared identifier: ''%s'''
var
Dcc32FileName: string;
Dcc32: HMODULE;
ResString: TResStringRec;
S: string;
begin
SError := '';
SUndeclaredIdent := '';
Dcc32FileName := 'dcc32.exe';
// try to retrieve and prepend Delphi bin path
S := (BorlandIDEServices as IOTAServices).GetBaseRegistryKey;
if RegKeyExists(HKEY_CURRENT_USER, S) then
Dcc32FileName := PathAddSeparator(RegReadString(HKEY_CURRENT_USER, S, 'RootDir')) + 'Bin\' + Dcc32FileName
else
if RegKeyExists(HKEY_LOCAL_MACHINE, S) then
Dcc32FileName := PathAddSeparator(RegReadString(HKEY_LOCAL_MACHINE, S, 'RootDir')) + 'Bin\' + Dcc32FileName;
// try to load localized resources first
Dcc32 := LoadResourceModule(PChar(Dcc32FileName));
if Dcc32 = 0 then // if not found try the executable
Dcc32 := LoadLibraryEx(PChar(Dcc32FileName), 0, LOAD_LIBRARY_AS_DATAFILE);
if Dcc32 = 0 then
Exit;
try
ResString.Module := @Dcc32;
ResString.Identifier := SErrorID;
SError := LoadResString(@ResString);
ResString.Identifier := SUndeclaredIdentID;
SUndeclaredIdent := LoadResString(@ResString);
finally
FreeLibrary(Dcc32);
end;
end;
// example error message: [Error] Unit1.pas(37): Undeclared identifier: 'GetWindowsFolder'
function ParseMessage(const Msg: string; var Error: PErrorInfo): Boolean;
var
P, P1, P2: PChar;
UnitName: string;
LineNumber: Integer;
Identifier: string;
begin
Result := False;
Error := nil;
P := PChar(Msg);
// check opening bracket
if P^ <> '[' then
Exit;
Inc(P);
// check severity
if StrLComp(P, PChar(SError), Length(SError)) <> 0 then
Exit;
Inc(P, Length(SError));
// check closing bracket
if P^ <> ']' then
Exit;
Inc(P);
// check space
if P^ <> ' ' then
Exit;
Inc(P);
// read unit name
UnitName := '';
while P^ <> '(' do
begin
if P^ = #0 then
Break;
UnitName := UnitName + P^;
Inc(P);
end;
if UnitName = '' then
Exit;
if P^ <> '(' then
Exit;
Inc(P);
// read line number
LineNumber := 0;
while P^ <> ')' do
begin
if P^ = #0 then
Break;
LineNumber := LineNumber * 10 + Ord(P^) - Ord('0');
Inc(P);
end;
if LineNumber = 0 then
Exit;
if P^ <> ')' then
Exit;
Inc(P);
// check colon
if P^ <> ':' then
Exit;
Inc(P);
// check space
if P^ <> ' ' then
Exit;
Inc(P);
// check text
Identifier := '';
P1 := PChar(SUndeclaredIdent);
// check text up to '%s'
P2 := StrPos(P1, SIdentFormatSpec);
if P2 = nil then
Exit;
if StrLComp(P, P1, P2 - P1) <> 0 then
Exit;
P1 := P + (P2 - P1);
// check text after '%s'
Inc(P2, Length(SIdentFormatSpec));
P := StrEnd(P);
Dec(P, StrLen(P2));
if StrComp(P, P2) <> 0 then
Exit;
// copy identifier
while P1 < P do
begin
Identifier := Identifier + P1^;
Inc(P1);
end;
if Identifier = '' then
Exit;
// match
Error := AllocMem(SizeOf(TErrorInfo));
try
StrLCopy(Error^.UnitName, PChar(UnitName), Length(Error^.UnitName));
Error^.LineNumber := LineNumber;
StrLCopy(Error^.Identifier, PChar(Identifier), Length(Error^.Identifier));
Result := True;
except
FreeMem(Error);
raise;
end;
end;
begin
ClearErrors;
if not Assigned(Messages) then
Exit;
LoadDcc32Strings;
for I := 0 to Messages.Count - 1 do
if ParseMessage(Messages[I], Error) then
FErrors.Add(Error);
for I := 0 to FErrors.Count - 1 do
ResolveUsesName(FErrors[I]);
for I := FErrors.Count - 1 downto 0 do
begin
Error := FErrors[I];
if Error^.UsesName = '' then
begin
FreeMem(Error);
FErrors.Delete(I);
end;
end;
Application.ProcessMessages;
FApplicationIdle := Application.OnIdle;
Application.OnIdle := AppIdle;
end;
procedure TJCLUsesWizard.ProcessUses;
var
GoalSource: string;
Goal: TCustomGoal;
I: Integer;
ChangeList: TStrings;
IntfLength, ImplLength: Integer;
Writer: IOTAEditWriter;
ActiveProject: IOTAProject;
begin
GoalSource := '';
with BorlandIDEServices as IOTAEditorServices do
if Assigned(TopBuffer) then
GoalSource := ReadEditorBuffer(TopBuffer)
else
Exit;
Goal := CreateGoal(PChar(GoalSource));
if not Assigned(Goal) then
Exit;
try
if Goal is TProgramGoal then
with TProgramGoal(Goal) do
begin
IntfLength := Length(UsesList.Text);
ChangeList := TStringList.Create;
try
for I := 0 to FErrors.Count - 1 do
with PErrorInfo(FErrors[I])^ do
if (UsesName <> '') and (ChangeList.IndexOf(UsesName) = -1) then
ChangeList.AddObject(UsesName, TObject(waAddToIntf));
if not FConfirmChanges or (DoConfirmChanges(ChangeList) = mrOK) then
begin
for I := ChangeList.Count - 1 downto 0 do
case TWizardAction(ChangeList.Objects[I]) of
waAddToImpl, waAddToIntf:
if UsesList.Count = 0 then
UsesList.Add(ChangeList[I])
else
UsesList.Insert(0, ChangeList[I]);
end;
with BorlandIDEServices as IOTAEditorServices do
if Assigned(TopBuffer) then
begin
Writer := TopBuffer.CreateUndoableWriter;
try
Writer.CopyTo(Length(TextBeforeUses));
Writer.DeleteTo(Length(TextBeforeUses) + IntfLength);
Writer.Insert(PAnsiChar(StringToUTF8(UsesList.Text)));
Writer.CopyTo(Length(GoalSource));
finally
Writer := nil;
end;
end;
// attempt to recompile
ActiveProject := GetActiveProject;
if Assigned(ActiveProject) and Assigned(ActiveProject.ProjectBuilder) then
ActiveProject.ProjectBuilder.BuildProject(cmOTAMake, True, True);
end;
finally
ChangeList.Free;
end;
end
else
if Goal is TLibraryGoal then
with TLibraryGoal(Goal) do
begin
IntfLength := Length(UsesList.Text);
ChangeList := TStringList.Create;
try
for I := 0 to FErrors.Count - 1 do
with PErrorInfo(FErrors[I])^ do
if (UsesName <> '') and (ChangeList.IndexOf(UsesName) = -1) then
ChangeList.AddObject(UsesName, TObject(waAddToIntf));
if not FConfirmChanges or (DoConfirmChanges(ChangeList) = mrOK) then
begin
for I := ChangeList.Count - 1 downto 0 do
case TWizardAction(ChangeList.Objects[I]) of
waAddToImpl, waAddToIntf:
if UsesList.Count = 0 then
UsesList.Add(ChangeList[I])
else
UsesList.Insert(0, ChangeList[I]);
end;
with BorlandIDEServices as IOTAEditorServices do
if Assigned(TopBuffer) then
begin
Writer := TopBuffer.CreateUndoableWriter;
try
Writer.CopyTo(Length(TextBeforeUses));
Writer.DeleteTo(Length(TextBeforeUses) + IntfLength);
Writer.Insert(PAnsiChar(StringToUTF8(UsesList.Text)));
Writer.CopyTo(Length(GoalSource));
finally
Writer := nil;
end;
end;
// attempt to recompile
ActiveProject := GetActiveProject;
if Assigned(ActiveProject) and Assigned(ActiveProject.ProjectBuilder) then
ActiveProject.ProjectBuilder.BuildProject(cmOTAMake, True, True);
end;
finally
ChangeList.Free;
end;
end
else
if Goal is TUnitGoal then
with TUnitGoal(Goal) do
begin
IntfLength := Length(UsesIntf.Text);
ImplLength := Length(UsesImpl.Text);
ChangeList := TStringList.Create;
try
for I := 0 to FErrors.Count - 1 do
with PErrorInfo(FErrors[I])^ do
if (UsesName <> '') and (ChangeList.IndexOf(UsesName) = -1) then
begin
if LineNumber < GetLineNumber(PChar(GoalSource), PChar(GoalSource) + Length(TextBeforeIntf) +
IntfLength + Length(TextAfterIntf)) then // error in interface section
begin
if UsesImpl.IndexOf(UsesName) = -1 then
ChangeList.AddObject(UsesName, TObject(waAddToIntf))
else
ChangeList.AddObject(UsesName, TObject(waMoveToIntf));
end
else // error in implementation section
ChangeList.AddObject(UsesName, TObject(waAddToImpl));
end;
if not FConfirmChanges or (DoConfirmChanges(ChangeList) = mrOK) then
begin
for I := ChangeList.Count - 1 downto 0 do
case TWizardAction(ChangeList.Objects[I]) of
waAddToImpl:
if UsesImpl.Count = 0 then
UsesImpl.Add(ChangeList[I])
else
UsesImpl.Insert(0, ChangeList[I]);
waAddToIntf:
if UsesIntf.Count = 0 then
UsesIntf.Add(ChangeList[I])
else
UsesIntf.Insert(0, ChangeList[I]);
waMoveToIntf:
begin
if UsesIntf.Count = 0 then
UsesIntf.Add(ChangeList[I])
else
UsesIntf.Insert(0, ChangeList[I]);
UsesImpl.Remove(UsesImpl.IndexOf(ChangeList[I]));
end;
else
ChangeList.Delete(I);
end;
if ChangeList.Count = 0 then
Exit;
with BorlandIDEServices as IOTAEditorServices do
if Assigned(TopBuffer) then
begin
Writer := TopBuffer.CreateUndoableWriter;
try
Writer.CopyTo(Length(TextBeforeIntf));
Writer.DeleteTo(Length(TextBeforeIntf) + IntfLength);
Writer.Insert(PAnsiChar(StringToUTF8(UsesIntf.Text)));
Writer.CopyTo(Length(TextBeforeIntf) + IntfLength + Length(TextAfterIntf));
Writer.DeleteTo(Length(TextBeforeIntf) + IntfLength + Length(TextAfterIntf) + ImplLength);
Writer.Insert(PAnsiChar(StringToUTF8(UsesImpl.Text)));
Writer.CopyTo(Length(GoalSource));
finally
Writer := nil;
end;
end;
// attempt to recompile
ActiveProject := GetActiveProject;
if Assigned(ActiveProject) and Assigned(ActiveProject.ProjectBuilder) then
ActiveProject.ProjectBuilder.BuildProject(cmOTAMake, True, True);
end;
finally
ChangeList.Free;
end;
end;
finally
Goal.Free;
end;
end;
procedure TJCLUsesWizard.RegisterCommands;
begin
LoadSettings;
end;
procedure TJCLUsesWizard.ResolveUsesName(Error: PErrorInfo);
var
I: Integer;
Identifiers: TStrings;
IdentifierIndex: Integer;
begin
if FIdentifierLists.Count = 0 then
InitializeIdentifierLists;
Identifiers := TStringList.Create;
try
with FIdentifierLists do
for I := 0 to Count - 1 do
begin
Identifiers.CommaText := Values[Names[I]];
with Error^ do
begin
IdentifierIndex := Identifiers.IndexOf(Identifier);
if IdentifierIndex <> -1 then
begin
StrLCopy(UsesName, PChar(Names[I]), Length(UsesName));
Break;
end;
end;
end;
finally
Identifiers.Free;
end;
end;
procedure TJCLUsesWizard.SaveSettings;
begin
Settings.SaveBool(SRegWizardConfirm, ConfirmChanges);
Settings.SaveString(SRegWizardIniFile, IniFile);
Settings.SaveBool(SRegWizardActive, Active);
end;
procedure TJCLUsesWizard.SetActive(Value: Boolean);
begin
if Value <> FActive then
begin
if Value then
begin
with BorlandIDEServices as IOTAServices do
FNotifierIndex := AddNotifier(TJCLUsesWizardNotifier.Create(Self));
FActive := FNotifierIndex <> -1;
end
else
begin
if FNotifierIndex <> -1 then
with BorlandIDEServices as IOTAServices do
RemoveNotifier(FNotifierIndex);
FNotifierIndex := -1;
FActive := False;
end;
end;
end;
procedure TJCLUsesWizard.UnregisterCommands;
begin
SaveSettings;
end;
{$IFDEF UNITVERSIONING}
initialization
RegisterUnitVersion(HInstance, UnitVersioning);
finalization
UnregisterUnitVersion(HInstance);
{$ENDIF UNITVERSIONING}
end.
| 28.140281 | 114 | 0.603226 |
4794cb98440f0e9a12df69bec4d8fbfe73bb2bd8 | 77,343 | dfm | Pascal | Transparent_ListBox/Unit1.dfm | delphi-pascal-archive/transparent-listbox | fa0a69d787e8d08757fec648335b478e96aa6a2b | [
"Unlicense"
]
| 1 | 2021-11-06T23:17:04.000Z | 2021-11-06T23:17:04.000Z | Transparent_ListBox/Unit1.dfm | delphi-pascal-archive/transparent-listbox | fa0a69d787e8d08757fec648335b478e96aa6a2b | [
"Unlicense"
]
| null | null | null | Transparent_ListBox/Unit1.dfm | delphi-pascal-archive/transparent-listbox | fa0a69d787e8d08757fec648335b478e96aa6a2b | [
"Unlicense"
]
| 1 | 2021-11-06T23:17:06.000Z | 2021-11-06T23:17:06.000Z | object Form1: TForm1
Left = 230
Top = 129
BorderIcons = [biSystemMenu]
BorderStyle = bsSingle
Caption = 'Transparent ListBox'
ClientHeight = 383
ClientWidth = 428
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -14
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
Position = poScreenCenter
Visible = True
OnClose = FormClose
OnCreate = FormCreate
PixelsPerInch = 120
TextHeight = 16
object Image1: TImage
Left = 0
Top = 0
Width = 428
Height = 383
Align = alClient
Picture.Data = {
07544269746D6170EA820000424DEA820000000000003604000028000000C900
00009F0000000100080000000000B47E00000000000000000000000100000001
000000000000FFFFFF006C250000FFFEFF00FEFEFF00FEFDFF00FDFCFE00FDFB
FE00FCFAFE00FCF9FE00FAF6FD00F8F2FC00E8E5F600F8F7FD00F9F8FD00D9D0
F000E1D7F20036215100C4A9E800CFB7EC00F5F0FB00CBAEEA00DFCEF200F1E8
FA00F7F2FC00FBF8FE00F6F4F800F6EFFC00F5EEFB00F2EBF8008136BF00E1C9
F400E7D4F600E9D8F700EBDBF800D6C8E100E3D5EE00E8DDF100F1E6FA00EBE1
F300F0EAF500F9F4FD00F8F3FC00F5F0F9008029BF008C2DD000852BC6007B28
B7007425AC006C23A10066219700611F90003E145C00391356005A1E86003311
4C00541D7C00461867002C0F41004D1B72009033D300260E38008F38CD003D19
5800953DD500401B5B00692D94005D2A83009C48D800442060007336A0008840
BC0052296F00A255DB00A85FDD009958C800AD67DF008852AF00A766D700AE6B
DF00B06EE000B271E100B475E200A56BCF00B376E0009F68C600774F9400B77A
E300B97FE300A874CD00BC84E500805B9B00BF89E600C18EE700AC7ECD00C391
E800C391E700C493E8008B68A400C695E900C594E800C696E900C799EA00C899
EA00C798E900C698E700C99BEA00C79AE900C99CEA00C89BE900CA9DEA00CA9E
EA00B790D300CCA1EB00CBA0EA00CDA3EC009475AA00CDA4EC00CDA3EB00CEA5
EC00CDA4EB00BF99DB00CFA6EC00D0A9ED00CFA8EC00D1AAED00D1ACED00D3AD
EE00D2ADED00D3AEEE00C6A3DF00D3B0EE00D4B0EE00D5B2EF00D6B3EF00D7B6
F000D7B6EF00CBACE200D8B7F000D9B9F000D9BAF000DBBCF100DABBF000DBBE
F100DCBFF200DDC1F200DDC2F200DEC2F200C6AFD700D4BCE600E2CAF400E1C9
F300E3CBF400E2CAF300E3CCF400D9C3E900E4CEF400E5D0F500E6D1F500E7D3
F600E6D2F500E8D5F600DECCEC00E9D7F700E3D1F100EAD8F700C7B8D200ECDC
F800CDC0D700EDDEF800E7D9F100EEE0F800EFE2F900D4C9DC00F1E5FA00F2E7
FA00F1E6F900F4EBFB00F3EAFA00F4ECFA00EEE6F400F7F0FC00FBF7FE00F9F5
FC00F8F4FB00F3EFF600EEEAF1002F0F4500371251004B236700B185D000C899
E900D0A7EC00D2ABED00D3AEED00D4AFEE00A085B300D7B5EF00D8B7EF00DCBD
F100DCBEF100D1B4E500AD95BD00DDC0F100DEC1F200E0C5F300DFC4F200E1C7
F300E2C9F300B7A3C500E4CDF400C0AECC00E9D6F600EBDAF700ECDBF700EDDD
F800ECDCF700EEDFF800F0E3F900F1E5F900DBD1E200F5ECFB00FBF8FD00F6F3
F800F5F2F700F4F1F600F3E8FA00F2E7F900E4DCE900F6EEFB00FAF5FD00F7F2
FA00F4E9FA00E0D7E500F6EDFB00F8F1FC00F7F0FB00E7E0EB00EBE5EE00FCF8
FE00FBF7FD00F2EEF400F8F6F900FDFAFE00FCF9FD00FEFDFE00FCFEFE00F3F8
FA00FBFCFD00F0F4F900EFF2F900C8CCE900EDEEF700FAFAFD00FDFDFE00FFFF
FF00FB0F169C9D9DA0A09D9D9DA0A0A0A4A4A1A3A3A32020A1A1A3A3A3A3A1A1
A1A1A5A5A5A5A5A5A5A5A5A5A5A5D5D5D5D5D5D5D5D5D5D5D5D5D7D5D5A5A5A5
A5D5A1A5A5D7ACACACACA9D7A9A9A9ACACACACACACACACACACACACDBDBDBDBAF
AFE2171717B1B1B1B11C1C1C1C1C1CE5E5E514ECB518181B1B1B1BB5B5B51829
2929292A2A2A2AE6E6E6E60A0A0A0A0A0A0AF0F0F0F0DEDEF409090909080807
08FDFD0707070707070607060606060606060505050505050505050404040404
0403030303030303010101000000127D7B7B7C7DC3817D7DC38485858585C586
8686C5C58AC5C5C5C58A8B8B8B8B8C8C8C8C8C8C8C8C8B8B8B8B8D8D8D8D8D8D
8D8D8D8C8C8DC88C8C8B8A8A8A8A8AC5866A5D718CCECFCDCECFCDCDCDCDCDCE
CFCFCFCF979797D098989A9CA0A12020A322A5D5D5D522222222D7D7A9A9D9D9
ABABACDADADADBDBDBDBDB262626171717B2B2B2B2B2DD1CEAE5E5E51B1B1BB5
B518180B0B0B0B2A2A2A29E60A0A0A0A0A0ADEDEDEDE09090908080808F30707
070707060606060606F5050505050504040404040404040000004E494A4A4A4A
4A4C4C4F50505152525257585758585A5A5C5C5C5C5D5F6161615F6164646568
646468666568666666666668686868686668686868686565645F64685A492D2C
444F5D717A7AC07A7B7A7B7D7B7C7C7B7B7D7D7B7A7F7F7D717181C68F91CC91
91CC909293CECDCF9797D0969696D29A9A9D9D9D9DA09F2020A1A1A1D4A3A5A5
A522A7A7A7A9A9D9ABACACDADBDBDB261717B2B2B2B1B1B1EA1C1CE51B1BB518
EB0B0B2A2929292929E60AF0F0F0191909090808080707070706060606060505
0505050000001E2C2C2E2E2E2E2D2D2D2D2D2D2D2D3C3C3C4040404040404444
44444444444949494949494A4A4A4A4A4C4C4C4C4F4F51515150515151515051
5050505051515152492D2E3B322C2D444F585A5C5C5A5D5C5C5C5C5C5C5C5C5C
5D5C585869585A6D6F7271757A7B777B7D7D80C38485848685858887878E8C8C
8B8E8D909191CB93CECDCFCF97D0969A9A9CD29DA09F20A1A3A1D4A5D5D8D8A7
D7ABACABACDADADADBDBAF17B2B2B1B1B1EAE51B1BB5180B0B0B2A2929E60A0A
0AF0191909090808F30707070606060000004233333333323232313131313131
3130302F2F2F2F2F2C2F2C2C2C2C2C2E2E2E2E2D2D2D2D3C3C3C3C3C3C404040
40404040444040404040404040404040444040402D2E493839312E2C2E40494C
50515050504F5051525151514C576F4F44464458525A5C5C5D5D6060605C5D63
65656168BF6A6F6E6E727172727176777AC07DC1818484858585C5888B8C8B8D
90C8CCCECECECD979797989A9A9DA0A09F20D4A3A5D5D6D7ABD9A9ABACACDADB
DBAFE2B2B1B1DDE51B1BB518EB2A2929290A0A0AF0DE09090908080000001E2F
3030303030303131323132323132323333333636363336363636363636333333
32323232313131313030302F2F2F2F2C2C2E2E2D2D2D2D2D3C3C3C40403C4040
3C4A493BBC39303C2D2E2E3C44494949494A494A4A4949575DBF574648434449
444F4F50505152525251575257585858585C5C5A5A5A5C5C5C5C5D5D5F616464
BF6B6D6F727871757C7D7F7E80C38686C68B8D90919193CECDCF1F99D29A9C9D
A09F2020D522A5A522A7D7A9D9ACACDADB26E2B2B1B1B11C1CE5B5B5182A2A29
29E60AF0F009090000004944444944444944444944494949494A4A4949444440
40404040403C3C3C3C3C2D2D2D2D2E2C2E2E2C2F2F2F2F2F2F2F302F30302F30
302F2F2F2C2C2E2E2E3C3C3C3C443C3134BB3B2F2D3E2C2F2F2E3E3E3E3E3E3E
3E3E3E494A44464843464A4C4C4C4F5150515150504C4F4C4F5252504F4F4F50
4F4F4C4F505151545454545757575858585A5A5C5D5D5F616469696C7175757B
7E8484888B87C58A8D8D8D90CCCCCDCD9799D2D29C9E20A1A1A5D5D6A9D9ABAC
DADA26E2E2B2B1B11C1BB5EC0B2A2929E6F0F000000043363336333333333332
32313131302F2C2C2C2E2E2E2E2D2D2D3C4040444949494A4A4A4A4A4C4C4C51
5152585258585858585857575151515051575752525757524C517D934037BC38
3130314233423242324242424242424246464348424749514C4C4A4A49444949
494B4B4B4B4B4B4B4B4B554B55555553555555555555595959595E5E5E5EBEBE
BEBE70707070797979798282828289898989C9C9C9C995959B9B9B9B9B9BA2A2
A2A2A424242424AA252527272727B4B4B41D1D1D1D2B2B2BE7E7E7B8B80A0A00
0000BD3939343939393939343939393939393939393B3B3B3B393B393B383B3B
3B3B3B383638363836363332333232313130302F2C2C2C2C2C2C2E2C2F2F2C2E
2D4049576586AB18AC2E3D343836363636384343433643384343434342434848
475C5751585D5858524F585A5D5F615A5C615C61616A7A766F73757D72656E6A
686C71736C6E717173767C7A757BC17F8185868B8B8C91CCCBCC91CCCE93CD97
98D29C9D9EA0A09F20A1D4A522A7D7D7D9ABACDADA262617B1B1B11CE51B18EB
0B292929290A0AF0DE090900000045BC35353535343434353434353434343434
3434343434343434343434343534343434343434343434343434353434343435
3535BCBCBCBC353936312E404C5D84CED7DA171B015ABC37393B3B3B483B3B3B
48BD4848BD4848484848BD4865B18D911F8C6F584F4A494A4A4C4A4C4C4C4A4A
4C4A4A4A4E4E4E4E53534E535353595959595E5E5E5E5EBEBE7070BE70707979
79798282828282898989C9C9C9C9C9959595959BA2CEA2A2A2A22424A424AAAA
2525272727ABB4B4B0281DB3B32B2B14E7E72AB8B70A0A00000011373737BCBC
BCBC35BC37BCBCBCBCBCBCBCBC353535BC353434BCBCBCBCBC34353535353535
BC35353535BCBCBC37353434393832303C49527191A517290A09060A070A2909
0197363A3541393939394545454545BDBDBDBDBD48484844A9F01B29AFA3988A
68574A4B4D565656565656565B565B5B5B5B5B5B626262626274747474747474
C4C4C4C4C4C45ECACACACACACAD1D170D179D3D38294949494A6A6A8C9A89523
9523232323DCA2A2E92424E424AA25252727B4B4B4B4282828B9B9B9E1E0DFDF
1AF2F200000011BB3737373737BCBCBC37BCBCBCBCBCBCBCBCBCBC35BCBCBC35
BC3735BCBC3737BC37373737BC353439393632302C40495A768B9AAB29060101
0103060606030303060707090B065135373F3F414141414141414545BDBDBDBD
BD465CAE1BEC0306060808DE29B5AFA79C815D4C4B4D5B56565656565B5B5B5B
5B5B626262626262746274747474C4C4C4C4C4C4CACACACACACACAD1D1D1D1D3
D3D3D3949494A6A6A8A8A8A8ADAD232323DCDCDCDCE9E924E4E4EDEDEDEDEEEE
EEBA282828B9B9B9E1E0DFDF1AF2F2000000113ABBBBBBBB37BB3ABBBBBB3ABB
BBBBBBBBBBBBBBBBBBBBBB37BC353534393B3B3833312F2E444F5A6171C89DD7
1C0A030101060106060709070706060707090607090A0A0607031C4435BC3F3F
3F3F3F41414145BDBD48BD45425C2A2AEC290606DE08080808F30603FE0301FE
E59D8665574E4B4D5B5B5B565B5B5B5B626262626274747474747474C4C4C4C4
C4CACACACACACACAD1D1D1D1D3D1D3D3D3A6A6A6A6A6A8A8A8ADADADAD23DCDC
DCE9E9E9E9E4E4EDEDEDEEEEEEBABABA28F1B9B9E1E0E0DF1AF2F20000004336
3838363638383636333333333332323130302F2E2E2D3C44494A4F575A687C8A
CDA1AC18010101010101010101090A070909090707070A0A0A060607090A0907
06060709030701DA2C3F39413F3F3F3F414545BDBDBD434486A90E0608DE0606
F02A29F0F00ADEDEDEF3DE0606010101FE1BABD0C56B584E5562625B5B5B5B62
62626274747474C4C474C4C4C4C4C4CACACACAD1CAD1D1D1D1D3D3D3D3D3D3A6
A6A6A8A8A8A8ADADADADDCADDCDCE9E9E9E4E4E4EDEDEDEEEEEEBABABAF1F1B9
B9E1E0DF1AF2F2000000157D7166717C717C7D86C890919091CE91CF9FD5D9AF
B20B0A0906030101010101010101010103060603060707090706070709090906
070907090A0A090A0A0A090601010707060307018E32393BBDBD39BDBDBDBDBD
48408E0A012AEC030308DE060608DEF0291BB5B10BDEDE06FEF3DE06FE010101
0101070BDB9D8C7A5D525955746274627474747474C4C4C4C4C4CACACACACACA
CAD1D1D1D1D1D3D3D3D3A6A6A6A6A8A8A8A8ADADADADADDCDCDCE9E9E9E9E4E4
EDEDEDEEEEEEBABABAF1F1F1B9E1E0E01AF2F2000000F70709090A0A07060706
030101010101010301010101010101010303030603060607070709070A090A0A
0706070709090703060607090A290B0B29292909060606060607070701010606
017232BD38364343384838464FDA010A01010ADE010708060603060606DEDE0B
B1B2B2B2B5290AF30303F50303F50301010101010119B2D5988A77645ABE5EC4
C4C4C4C4C4C4C4C4CACACACAD1D1D1D1D1D3D1D3D3D3D3A6A6A6A6A8A8A8A8AD
ADADDCDCDCDCDCE9E9E9E4E4EDEDEDEEEEEEBABABAF1F1F1B9E1E1E01AF2F200
0000F90A0703070709090607090A0909090907090A0A070A0A0A090A0A290909
09090909090906060607090706030607090A2929181CB2DD18290B0A09090606
070307090A060703010307060709802F383836421E49579C0E01090E070608DE
080306DE0803030606030301FEF3291CE3AFDADA17182919F503010103060303
010101010101070829B2ABD4988E847163797070CACACACACACAD1D1D1D1D3D3
D3D3A6D3A6A6A6A8A8A8A8ADADADADADDCDCDCE9E9E9E4E4EDEDEDEEEEEEBABA
BAF1F1F1B9E1E1E01AF2F2000000F90A0A0A0A0A0A0A090A0A0A0A0A0A0A0A0A
0A0A0A0A0A0607070909060606070707070706090709070A291BB2DBAFAFB2DD
DD180A0A0606010101010107291B1B0B0903010101060706060906A35A4A4C5D
D5070601090E06060808070608080308DEF0F00603FEF30603FE010306DE2A1C
AFDAABD7DAB11B0BB609070303F5F5060707010101010101010303060A1BDBD8
D498918A85847E89949494D3D3D3D3A6A6A6A6A8A8A8A8ADADADADDCDCDCDCE9
E9E9E4E4EDEDEDEEEEEEBABABAF1F1F1B9E1E0E01AF2F2000000FA0A09090A0A
0A0A0A090909090706060A09060107070907070606060706070A0A0B1BB217AF
DBACDAAFDDB2180B0A09090603060606060103060A1CDBDB1C09060303070601
010106070309060ADA090609010307070E290E09070706070808DE0606060A18
1B0BDEF3F306F30603FE06030306B6EBE2DAABD522ABDAB218290A0906F5F501
01F503030101F5010101010101010108DEDE291B1CAFACD59FD2CFCDCECB9B9B
232323232323DCDCDCDCE9E9E9E9E4E4EDEDEDEEEEEEBABABAF1F1F1B9E1E1E0
1AF2F2000000FA0A0A0A290A0A0A090909090A09090A290B0B180B181CB2B2B2
AFDADAAFAFACACDADBDBB21C18290A0906070A06070909060306030629DDAFDA
DAAF1B06010303060306060101010301060609099D1701290A090A060707060A
0A060701DE290803DE080306291B1C0BDEDE0606DE06FEFE03FE07F501F5090A
1CB0ACA9A7A9A9A9DAB11B0B0A080807F503F503F50401010101010101010101
010104050506070708F00A0BB51BDDB1B21726B0DADADADADADADBDBAEDB26AF
17B2B1B3B31BB5EC182A2A29E6F0F00000000CDD1C1C1C1B1B1B1B181818181C
DDB2171717AFAFAFAFDBDB17DDB21B0B0B180A0A070706030607070906030906
0101060918AFACD9D7ABAF0B0603010303030606030101030306060301060601
919D01070A09290E06070E070B0A060606072A180608F00601060AB5B1B10B0A
F3F3F3F3FEFE060706F5060303F5F5070A1BB2DBACD9D7D7D7ACDBB21B2A29DE
0707070505050405050404040404040101010101040104040101010101010101
010101010101010101010304040404040403030304030101010101000000FC1B
0B180B181818181818180B0B0B181B18181B181829290B0A0A0A0706090A0709
070706030303070301030929B2ACD59FA1D7ABDD0A0301030307090909070301
030303070706060301010117648D0A01090A290A060E070706E50B06080306B1
B1DE060606DE0603F31CB2B21C180ADE0606F5F50606F5F5F506F5F5F5010101
F519290BE5AFDADAAEDBDAB0B2B11CB5290AF0DE080706050404010101010101
0101040401040101010305050301030301010101010101010101010101010101
01010101010101000000F909090A0A0A0A0A0A0A0A0A0A0A090A290A0A290909
09070707070A0A070707030603010303070A1BB2D79F9C9C9ED4ABDD09030101
03030606030907030607010107090703010306030101AF845A87DA0A030AE509
060A0B090307AF1B070806031BB21BDE06F306FE03FEF318E3AFB11B1829E619
07070706F5030303F5F5F5F5060708F50103F5F508F0E6B51CB1B2B21717B2B1
1CE5B50B29290A0A090808070706050504040101010101010101010101010101
01010101010101010101010101010101010101000000F909090A290A0A0A290A
0A0A0A09090A0A09090A0A09070603060603030101060A291CDA229F98CFCD97
9FD7DB1807030101010103070606060606060101010106070606030603030301
0A2284715C84A3D8070AEAE507060BEC07060EACE507DE03030A26AF2ADEF303
FEF3F303F3B5DDB2171C0B292A2A2909070606F50303F50101F5F5F5F50606F5
F503F50101050507090A0A290BB51818B51B1B1B1B1B1BB518180B2A29E60A0A
0ADE19EF1909080707F3070606060606F5050505050504040404040404040300
0000F90A0A0A0A0A0A090A07070707030303030303060703060A0A0B1C17ABD4
9ACF918C8D93CD9AD7AF1B0A0603010103030306060609090603030303030306
06070707030101010101061BA1846E735D7BA18C09070AAB290706B2E50707DE
DAB1DEDE030108B2ABB10BDE03FEF3DEF303FEDE18B217B2DDE51B0B0A0AB609
090909060303030303F50303F50607F503010404010101010105050506070809
080909DE19F0F0F0F00A0A0A0AF0F0F0F0F01919090909090808070707060606
F505050404040303030301000000F70606070303070907090A0A0B181CB2DBAB
D5D49F9ACEC88B8AC585868B919A9FD9B21B0A06010103070A09090707070907
0703060306060707070709090303010103030301030AAF9AC57A726A5D6CD677
AB0107E3DB0E0629AC0E0808F0A9DAF0DE0603031BDAE21C29DEFE03F30AF303
FEDE2AB1DADBE2B11BB50B2A2929B7F01919F008F5F5F5F5F5F5F5F503040505
0505050501040401010404040104040404040505040505050404050505050404
030304040404040303010303030301010303030303030300000010A5D4A19F9E
9ACDCFCEC88B8B86C3C3807D7D84848A91CF9CD4DADD18090607060101030709
090606070603060909090A070701010307070909070703010103030303010106
1B22CF88786E6D676168DA758A03060EA5E50607B2A307030629D6DA29290806
0129DBABE2B50B29FEFE0306F3F3060309E5DBDAACB0B2DDE51CE5182929290A
0908090807060706F50505050504040101040101040404040404040104040404
0405030304050505050505050404040404040504040404040404040404030303
030303000000138AC5868586C58684868CC89193CF9DD4D7AF1C180906090606
0607090A0A0A0A0A0A09060603070707070906030609030106060607090A0A07
030301010303030301060AB2D5CDC57A71726D676163DB8568B20303E3A02907
08D7D70807032920AC1B29060301061BABB0B2B50BDEF3FEFE060707F503060A
B1B026AEAEB21C1C1B180B290A0A0AF0DE090706070705050504040404050404
0506040404040404040101010104030303030304030303030303030404030403
0101030101010101010101010101010000000C17DDDDB2DD180B1C1B290A0607
07070601060A090A0A2929290A0A0A0A07060307090907090A0A0A0A09070706
06070607090A0A0A0707060603010101010101060A1BDAA1CE867C7172726B65
655CD6CE5A1F0603099DA9070E0E9EA9070806E6A1221BDE08FEFE0329DBABDB
B11B2AE6DE0606F5060607030307E6B1DAABACDADBB2DD1CECEB0B2A2AE60A0A
DE08090909080705050505050505060504040405050505050404010101010101
010303030101010101010101010103010101010101010101010101000000FC29
090A0A290A090A29290B0B29291829290B1829290A0A09070306070706070A0A
290B0A090707060603060603070A0A0A09090606060603030101010306060729
1CAC9F93867C7771726B6B68645CD2A05A7C140606B3CEE50801ECCDAC01DE08
E69FA1B50A0A060603FE1CABABAE1B182ADE0907F50307090603F506081BB1DA
A9ACAE26B2B11CE51B1BB52A290A0A0A0A090909080607070606060604010404
05F5F5F505F50505050505050404040403030303010103040101010101010101
01010101010101000000FC0A0A0A290B0A0729290A090A07090A060709070907
07090606090A090A0B0A290A0A0A090301060603060A29292929090706060706
03030101010101060A0B1CDAD79C93867D76716F726D6B68645DCEAB5D60A301
0706989A0E0306AE90B103E606F09F9DB129F3DEF30603DEE3A9ACB21B182AE6
B606F5F503060707F50607192AB1AEABA9ACDADBE2B1EA1B1C1B180B0B2A2929
0ADEDEDE08080908070706FEF505040404010303030303030303040505050405
05F50505040404040404040303030303030303000000F7060101030603060609
0909292929291818290B0A0A0A290B2929290A090909090A0A03060607090A1B
DD290A09070603060606070301010303030109291817ABA59C90C57D7671716F
6E6B6B68655D8DB16F5A870B03032AC6A90E0701D48D1B060803DE9D9DB21B29
DEF306FE0618DAA9DAB21CEBEBB6070906F501F508070807060719F018AFACAB
ABDB26B217B21C1CE51BB5B50B0B29E60A0A0ADE09090909080807F506F50505
0505050404030103010101010103010101030301010101010101010101010100
0000FC181BDDB2B2AFAFAF17DD1CDD1B0A0A0B0B290A0A0A0A0A290A0A090606
03030703090BDD17B21B1B0B0A070603060707030101010101010106090918DD
AFD99ECFC8C57D7676716F6F6D6B6B68645D7F187B586FA7030703A586B30A06
079893F006DE030820D0DA0B0B0AFEDEDE06F3B1A9AB26DDEB14290A09070807
F5F506081909F5F5F5080A18B126ACABABDA2617B2B2B11C1CE5B518180B2929
E60A0ADE191909090808F3F30707070606060505040404040301030101010101
01010101010101010101010000000CB2DDB21C1B1B18181B290A0A0A0A0A0A0A
0A09090907060606060907090A18B2AFDB17B2180A0707090607090603030103
0101010306060609291BAFD9D59DCF8D867D7A76766F6F6F6D6B6868645D771C
8C5A64CD2907090786CE0ADE08E6C8CFF0080A06DE21CDD729292906F30ADE03
0AAFABABE2DDE50B0A090A0907060806F5080808F5F508F506DE291BB2DAACAC
DAAEAFB2B2B1B11CE51BB5EB2A2A2A29E6E60AF0F0DE19190909090808070707
06060606F5F50505040404040403030303030101010101000000F70907090706
06070A0A0609290A0A0A0A0A0A0A0A09030709291B17ACABD9AC171B09070A07
070A07090301060606060301010306070909291BB2DAD7A19CCE8D867D7A7771
716E6C6C6B68686864606CB2D25C5C84AC030E01AB71A9E6DE061B8596F0DEF0
F0F3A7CDD5B129B529FEDEDEFEFEB617A9DAE21C1B29E619090919191908F5F5
070808070906F5F506F029B5B2AEACACDADBAFB2B2B1B11C1BB5B5B5EB0B2A29
290A0A0A0AF019EF09090908F30707070606060606F505050505040404040304
030303000000F90A0707090A0A0A290B0A290B290A070A07070A18B2ABD522A1
D4AB1718090907090A0A0A090603030101010101010101010101090A291BB2DB
ABA59F98CDC8C5847D7A717171716C6B68656568646163A9D8645C6F9A0B0A0A
068E7AB2070801AFC39FDE06F006FEAB939F170BE52ADE062A0A030614DBDAAF
B2DD1B0B0A19090909090808F503F5070809090806010101050A0B1BB21726AE
DB26E2B2B1DD1C1CE51BB50B2A2A292929E60AF0F0DE190909080808F3070707
0606F5F5F505050505050404040404000000F90A0A090A0A0706060906070A0A
18B2AF229E9FA19FD5DBB20B09070309290B0A0A090603010101010101010101
010101030709291CB2DBACD7A59CCF908C86807D77717171716F6C6B68656568
646161A3B2765C618CDA290A07EC6A912A070806D97A9F0608DEF306DACD9CDB
E52A1B0AFE0AE6090307E5DBACDAE2B11B2A2AB70907080808DE090806F5F506
07070707070501010508DE0B1BB1E2AFAF1717B2DDB11C1BB5B5B5EB0B2A2929
29E60AF0F019190909090808F307060606060606F5050505050404000000F806
06070A290B1CAFDAABD7A19A9A9EA1D7DBB2180A090A06070A0A0A0A0A090303
06060303010101010101010107070A0A181C1C17DAD9D5A19DCF918C8A847D7A
767171716F6E6C6B6865656864615FCF147D5D617E9D0B0E0A01985CD5ECF006
089D7AA908F3F3DE03B1CE96AC1C2A1C18FEF519B6070309B1DBDA17B11C1BB5
290AF0080809DEDEDEDE08F5030105070707070605040501010607EF2918B5DD
B1B1B1B2B11C1BE5B5180B0B2A2929E60A0AF0F0191909090808070707060606
06050505050505000000B2AFDAD922A5A19FA1A1A5D9DBDD290A070306070A0A
0A29090607090301030606060101010101010101010606070A0A0B181CB2AFAC
D7D49E9ACFC88BC5847D7C7A7671716F6F6E6C6B6865656764615D8B2A87605F
78CEDB0E080E08786C2618060603D27AABDEF329DE061C98CEA9B1291CB12906
1929090303B61CACACAEB11CB50B2929F0080907F509DEDEDE07040104050707
08070707070504010104040507190A290BB51BE51B1B1BB5B50B2A2A2929E60A
0AF0DE09090908080707060606060606050505000000ACAFB2AF1717DD181B0B
0A09090707090A09090909070709030603030101010106010101030303030603
070A0A0A0B181CAFAFDAAB22D49E9ACD908BC5C37D7C76767671716F6F6E6C6B
6865656865635D840ACE665F6E8AA52A0E0E01AE5AC8B1290608068D7BDADE06
2929FE29209320AF1B18B21C07F509B60703F50AB1DBDB171CE51B0B290A0AF0
09080608DEF019190807050505060708080809090606060401010104040607F3
DEF0E62929292929292929E6E6E60AF0DE190909080707070706060606050500
0000B21C181B1B0B0A070A0A0A0A0A0A290A0A09090906060606010101010101
010101010101010606060A090A180B18B217DBD9AB22D5A19D97CE908CC5857D
777A76717171716F6F6E6C6B68656568656360752AA3716166C296DA2A080A01
C75CA0AF2ADE0608887EDB29DE0A29F329A7CD9DDAB2E62AB12A03060B0906F5
030A1C26DAAFDD1CEC0B2929F0DEDE08F505080909DEDE090706050607070607
080808080707F504040401010304040305060606060707080808090809090808
0808070707060606060505000000140B0A0A0A0909290A290B0B182909070907
07060303030301010101010101010103060606090A0A29290B1C1B1CDBDAAB22
22D49E9ACF93C88C8A847D7A777771717171716F6F6E6C6B686565686563606A
B2AC7C6161C090A5EC0E0A06F06068DAAF060603188184E2B5F30ADE0AF326CB
9AA917EB2AE51B090609B60AF501060AB1DAAEB2DD1BEB0BE60ADEDEDE090907
07080808DEDEF0F407060606060706FE06080807070807070505050303030301
0101030301010303010303030404030303040303030303000000290B18181C0B
0B1B0B29090907060709070706060101010103030303010101010606090A0A0A
0B1818181CB2B2AFACD9D5D4D49D98CD918D8B8684807A7776767171716F716F
6F6E6C6B6865646564615D68D8E2846B616F889DB22AE6DE03D55885B11C08DE
061B8186DAB5DE0A29DEDEB19696A526142914B10B060808090807F5F5191BAF
26B2DD1BE5B5290ADEF00AF009080706050607F4DE191908070706FEF5F506F5
05F5060706070706050505050404030303040404040403030301010101010101
010101000000B2DD1B1829090709090A0A0B2909030603010303010101010101
0101060606070A0A0A290A29181C1C1CB2AFDAAB2222D49E9D98CD918C8AC584
807D7A7777767171716F716F6F6E6C6B6865646564616064A0E58E7261667FCF
A91B1BF00801885897DA18F02A03B17D8CDBB5DEDEDE29F32A9ECDA1ABB22929
1B1CB6030809090807080808ECAFAFB1B11CB5180B29290A0A09090907070705
0506080808080907060606F506F5050505040405050505040505050404040404
0404030404040404040404040303030000000A09090909090A0A290A06060601
01030101010101010101010101010709090A29291818181BDDB2B2AFDAABD7D5
D4A19DCFCFCE908B8585C3807D77777676717171716F716F6F6E6C6B68656568
64636160CF09CF7261657C8EA0E50BECDE06E66061A5AC29082903E27F8DB2DD
29DEE6E6E629A7979DD5E20B29B5DD1B08F50919F01919F00709EBDD17AFB1B5
1BB50B2A290AF0F0DE0909070607060606060607080907F5F5F5050504050606
050504050404040403040404040403040301010101030101030303000000290A
0A0A090907030303030306030303030303030607060607070707090A0A0A0B0B
181B1C1CB217DBACD922D5D49E9D97CDCD908D8A8584807D7C7A777676717171
716F716F6F6E6C6B686565686865635D8C0920786A6677889AACECE5F008E620
527DB2ACF0DE2A03AC7C91B217E6F3E6E60A072697D2D8DA1C0A0AEAB20B0606
080A29080708F507E6B1AFE2B21CB5B50B0B2A290ADEDE080808F30807070505
05F50706F506050504040404040504050505F505040405040404040504030303
0301010101010100000003030101010101030303030609090706070707070909
09090A0A0A0A29290B181C1C1CB217AFDAACD9D7D5A19F9D9897CD91C88C8B86
C3807D7D7C7A767171717171716F716F6F6E6C6B686565676563615D8418D8C3
6E687186CFA1260BEC0818E68551CEDBACFE2A29FED977CB17AF2ADE2AE6E606
149E9AA3ABB20B09291CDD2AF5F50A0A0908060807070AB5B2E2DD1CE5B5B5EB
290A0A0A0A190909080707060605050404050405070606060505030301030303
0405050505050504040404040404040403030300000006030306070707070707
07060607070907070A0A0A0A292929290B0B1C1CDDDDB217AFDAACD922D5A5D4
9F9C9C98CFCDCE918C8A86C3807D7C7C7A77777676717171716F716F6F6E6B6B
6B6B68686461616076B1AB8A786C6C7E909EAC0BB1ECDE061C5C58A5ABDBF329
2903A771CEAFDAB5DE2AB619070A229620A9B2DD2909B5DDB1190307F0290A09
06080808DE291CB1B2B11BB50B0B2A29E6E60ADE0909080807070706F5F50404
0505050506060606050404030301010304040303030303040303030303030300
0000290907070909090909090909090A0A0A0A0A0A29290B0B180B0B181CDDB2
B217AFDBDAABD922A5D4A19F9C9897CF9391C88D8BC58584807C7C7C7A777776
76717171716F716F6F6E6C6B6B6B6B676561656568B0148B77726A7BC6D0D5B2
EC26DE0808D45768ABD4B1FE292906D57ACFB2D71B062A0BB609B6AF9CA0D817
B21B0AF0EAB21808F5080A29E6090809060707190BEAB1B1E5B50B2A2929E60A
F0F0DEDE09080807070606060505040403030405050505F5F5F5050404030101
01010101010301010101010000000E09090A0A0A0A0A0A0A0A0A0A0A0A0A0A29
290B181B1B1C1B1C1C1C1717AFAFDAACABD722A5A19F9E9D97CDCE91C88D8B8A
868585C37D7A7C7C7A77777676717171716F716F6F6E6F6C6D6D6D6A68656865
64D518CD7C726F7B85CEA1DAE6B11B082ADE8B5185ABA10BDEB518F3A577CFAF
A51C070B0B09B6091BA39AD5AEB21B180A29DDDD2A080607F02AE6DE08070807
0707F00B1CB11B18180B29290A0AF0F019190909090807070707060605050404
030303040404040505F50504040303030101010101010100000009090A292929
29290A0A0A0A0B0B0B0B0B0B18181C1C1CDDB2B21717DADAACACD922D5A5D49F
9D9C9A97CDCE91C88B8AC5858584C3807C777A7A7A7A7776767171716F6F6F6E
6E6A6F6F6D6D6B6765656864649A149C84716F7383CB9CA9B12A26F02A181C68
52CDDA2029DEB5B5FEA3751FB2D51C060A140A290AB6A998A1A9DBB12A29F00B
E51C290803080A2A2A080508DE09080608E60B1BE51BB5EB2A2A290AF00ADE19
0909090808070706060605050505040303030101010103030303030303030303
010101000000290A0A292929292929292929290B0B0B1B1B1C1CDDDDB2B2AFAF
DBDAABD9D722D5A5D49F9D9C9897CFCFCE91C88D8B8AC585C3C3807D7A777A7A
7A7A777676716F6F6F6F6F6E6E6A6F6F6D6D6B6768656561608D0A9F88756F71
818E97A5AE2AB11CF0290AD8585CA0A7A1DEDEB51CDEA97B1F17A517F509E50B
0A0907269EA0D7AC171C2919F0EB1C1BE608F5F509290B0A0809F0F008070708
0A0BB5B5B5B5EB2929E60AF0F0DE090908080707070606F50505050504040403
0301010101010101010101010103030000002A29290B18181818181818181B1B
1B1B1CDDB21717AFAFDBDADAACD922D5D5A5A19F9E9C9A98CFCDCE93918D8D8C
C5C58584807D7D7D7A777A7A7A7A77767671716F6F6F71716F6A6F6F6D6D6D67
686868615D7E29A78A7D73717D8ACE9EA9B1E6AC29F02AF0CF5272D79E2201DE
E5B1DEA981CDDDD4AB0709B10B09E62918D79DD5ACAFDD180A08DE1BDD29DE07
030408292A0A090708DEF007050609290B18180B2A2929E6E60AF01919090908
08070706060606F505050504040403030301010101010101010101000000140B
181B1B1B18181B1B1B1C17B2B2B21717AFAFDBDBDADAACABD9D9D5A5D4D49E9D
9C989897CDCE9391C88D8B8A868584C380807C7C7C7C7A7A7A7A777676717171
717171716F6F6F6F6D6D6D6A676768655D7CB2E3907EC0717A85CBD2D6AE2AB1
DA082AB5187E5285B09CDBFE291CB2DEA97C1FB2D5A729070B1CB607190A1720
D4ABAEB1180A0ADE0AE5B12907050505080A2929F0090808F40806050408DE29
0B0B0B29290A0AF0F0DE19090908080707070606F5F505050504040404030303
03030101010101000000E51B181C1C1CDDDDB2B2B2B217171717DBDBDADAABD9
D9D722D5D5A5A19F9E9D9A9897CDCDCE9190C88D8B8AC5C584848480807D7D7C
7C7C7A7C7A7A77767676767671717171716F6F6F6D6D6D6C67686365607CABEA
97847C7375818B9720AC1BE6DA1B061C29E25C5A93AC9717FE0AB1B2DEACC1D0
EAA3A10B07291B19091919B5D89EA7ABB21CB5F009F029E51B290907040507F0
E629E608070809EF070604FE06190A292A2A29290AF0F0DE1909080807070706
060606F5F50505040404040404030303010101000000B31C1CB2DDDDB21717AF
AFDBAFAFDBDBDADAACABD9D7D9D5A5A5D4A1A19F9C9A9C9A97CFCDCE91C88D8D
8BC586848484C37D7D7D7D7C7A7A7D7D7C7A77777777777776717171716F6F6F
726D6B6A686865BF60BFD5EC9A88C0777A7B8BCDA0A7DA2918AC0A0AB50A9E52
61A1A7CF18032A1BDADEAC7E91DDD59E1C09E6EA0A1909F0B7AFD4A5D826DD0B
E60A08082A1B1C290A07050505080AE62919F3070709DE080504040708DE0A29
29E6F0F0DE090909F3F3070707060606F5F50505050404040403030303010100
0000B3DDDDB2B2171717AFAFDBDBDADAABACABABD9D92222D5D5D4A19F9F9E9C
98989897CDCE9191C88D8C8C8AC5858484C3807D7D7D7D7C7A7A7D7D7C7A7C7C
7C7C777776717171716F716F6E726D6C6A6C686860609AECA38E7F777A7BC591
9CA5AC1BDEACDA061B0B2A885777D7D49A2ADEE6B2DA092684CBB1D89DB20809
1B1B1909F00AE5A9D4D7DAB2EA180AE6090818DD1B0A090907050507F40A0A0A
09070708090908F50405050608DEF0F00AF01909090808070707060606F50505
0504040404040303030101000000B21717AFAFAFDBDBDBDAACACACABD9D9D9D9
D722A5A5D49F9D9E9D9A989897CECECD93C8C8C88CC58B8A868584C3C380807D
7D7D7D7C7A7A7D7D7C7A7C7C7C7C777776717171716F716F7272726C6A6C6365
686091E5A9C8857D7A7A8490D020ACE22A2AA5B50A1C2A1C6A57C5DB9CD2DEDE
0AB2ABB6B2C58DAFD9D2DA08060A180AF009E629B2D522ACAF1CB50B0A0919F0
18EA1B29DE0707050507090AE6E6F00704060808090705030303050708090909
1909080807070706060606F50505050504040404030303000000E3AF17DBDBAF
DADADAACACABD92222D5D5A5A5D4D49F9F9D9D9C9A9897CFCE93CE9391C88C8C
8AC5C5C5858484848080807D7D7D7D7C7C7C7D7D7C7A7C7C7C7C767676717171
716F71717272726F6C6C67BF6A6087B1DACC8A7E7A7A818CCDA0D6261C0826AB
F0B52A0BA75A5A8FDBD29EE6DEE617A90AB1888EABDA9AA92908B7182AF00829
291BDAD6A9DBB21BB5290A090929B51BB5E6DE06050706050609F0E6E6090605
0608080806050503030505F5070809090808070707060606F505050505040404
030303000000DBAFDBDADBDAACACACABD9D9D9D72222A5D4D4A19F9E9D9C9C9A
97CFCFCD91919391908D8B8AC5C58685858484848080807D7D7D7D7D7D7D7C7C
7C7C7A7A7A7A71717171716F6F6E6F6F726E6E6F6C6C676ABF64C3E3B1CF8D7F
7A7B818BCE9EA5ACAF1829D517F3B11CB196526196AED022F329E626A7DDDD91
8BABB29DD418190A18182908F00B29B1A9A9ACAFB11C0B0A0A0908291BB5290A
F406050504060607090AE60A090605060707070706F505040404050606070707
0707060606F5050505040404030303000000ACDADAABABACABD9D9D7222222D5
A5A5A1A19F9F9E9D9A989897CFCECE9391C890C88D8B8AC586C5868484C3C384
8080807D7D7D7D7D7D7D7C7C7C7C7A7A7A7A717171717171716E6F7172726E72
6F6C676C6A6476D9EC2090857D7B7E8A909820D9DA1CF0B2202ADEB1B51C8652
6F2026CED9F32A09DBA7DD1B1F87D8EAA59EDD09B7B5180B0908290A2A26D7AB
DB171C2A2A29F0070829B51B0B2909F306060706F5060719E60AF0F305040306
07070707060503010303040505F506060606050505040404040404000000ACAC
ABD9D9D9D7D7D5A5A5D4D4A19F9F9F9E9E9D9D9A989797CFCE9393918D8DC88D
8C8AC5C586858484C3C3C3848080807D7D7D7D7D7D7D7C7C7C7C7A7A7A7A7777
7777717171717171727272726F726C6C6A666F21EC22CCC6837B7D868DCFA0D7
DAB118DED8AB060BB20B186852C3D6D890AFE6DD0A26A7E50B9A8AA10BA99ADA
090A2929182A0809F00AB5ABD8DA17DDE51829F0F0070729B5B5290A09080605
0506F5040607090A29DE0806040405F506070706060401030104030304050505
05050504040404000000ABD9ABD722D722D5A5D4D4A1A19F9E9E9D9D9C9C9A98
97CFCDCDCE9191908D8C8C8C8BC5C5C585858484C3C38484807D807D7D7D7D7D
7D7D7C7C7C7C7A7A7A7A777777777671717171717272727171726C6C6E656F9C
B1A9CD8C857F7D848BCEA0D5ABAFB1F018D4B2F3B10BDEAB5C5A8ADAA190DD2A
E529DAA9B22920869A1CDB9CD80A0818180B1BDE06F00A29DDDAABDBB21CB50B
0A0ADE0607E6B518290ADE07070606F5F50605050709F0F0DE08060503040506
06070606050403030101010303030304030404000000A9D7D72222D5A5A5A5D4
D4A19F9F9E9E9C9A9A9897CDCFCDCE93939190C88B8B8B8A8AC5868584848484
848484C37D7D7D7D7D7D7D7D7D7D7D7D7C7A7A7A7A7A77777777717171717171
727272726C6C6C6C6A656C93B2DA988D88817F84C592D2A1D7DAB118F0DBD429
0AB129F39A525F93B29F911C14E50ADBA9B01BA786CE17B19F20181918EB2A0B
E6F5080ADE29B1ACDAB2B11B18290ADE0607080AEBB52A0AF0080707F5060706
05030507190A0ADE0806040301040506060606F5050403010101010101010300
0000A722D5D5A5D4D4D4A1A19F9F9E9E9D9C98979797CDCDCDCE93919190C88D
8A8A8AC5C5868584C3C3C3C3C3C3C380807D7D7D7D7D7D7D7D7D7D7D7D7D7C7C
7C7C777777777676767671717172727171726C6C6EBF648CE3B29DCBC6837F84
C590969F22ABAFB1292921ABF3B51C29DEC552729AB21F9314EBE506DAD5AEB1
AE8BCB261BD59DDD09EB1B290BB50906DE292929B2DA26B11CB529E6DE080707
080A18EB290AF009070605050605050505050609F0F00907F504030103040505
F505050505040301010101000000A5A5A5A1A1A19F9E9E9D9D9C9C9A9A98CFCF
CDCDCDCECE93919190C88D8C8AC5C5C586858484C38080808080808080807D7D
7D7D7D808080807D7D7D7D7D7D7D777777777777777778717176767371717272
6F6E64C5A9B2A5CD8E858184868ECFA0A5ACDAB1B5DEB1A31CF31C1C292A7657
7B2017CE97EB1B1B09B0D6ACE2B1938ED818D99EDADE29B1E6291B2908090A0A
091826DA171CB51829F01908070608E62A0B2A0AF00908060505050505F50504
04060819F0090706040403010304040405050505040403000000A5D4A5A1A1A1
9E9E9E9D9D9C9C9A9898CFCFCDCECDCECE93919190C88D8C8AC5C5C585858484
808080808080808080807D7D7D7D7D80808080807D7D7D7D7D7D777777777777
7777787871767673717172726F6E6580A5B2A7CF8E858184858E93D2A1D8DAB2
1C0ADED7A7B50B1CE52A265D5A85D5DA919DEBEC1B07AED5ACAF1BD0C89E1CB2
A1D70B0ADD0B0A18B5190719290AF0EBAF26B11BB50B290ADE09070606F02A0B
2A0A190908070505050506F505050404F5F30909090706050504010101030304
050404000000A5D4A5D49F9D9D9D9D9C9A9A9A989797CFCFCDCE9393919190C8
8D8D8B8B8B8AC5C585858585C3C38484C38080808080808080807D7D7D7D8080
7D7D7A7A7A7A7A7A777677767671787876767271717172726F6F657820B3AC98
908785C3868E939AA1D8D9AFB21BDEB5A3AC29B51CB5B5205A5D8BABE28E9EB6
1BB106AED4ABABE5A38DD2B21B22D4EA071BB1E62A18180A09DEF0F0DEB5B2B2
B1B50B29E6F00908070706080A29290ADE09080606050405050506F504030405
070809080706050503030101010103000000A3D4D4A19E9E9D9C9C9A9A989897
97CFCDCDCECE93919190C8C88D8C8B8A8AC5C5C585858585C3C38484C3808080
8080808080807D7D7D7D80807D7D7C7C7C7C7C7A7A777A777776777876767673
7373717271716C729EB2B29A938B8584868BC81FA022A9DB171C29F3B09FB229
B11C2929CD586590DBAB8DA3B61BDD07B2D5D9A91BB0CECEACEBACA1AF082AE2
1BF018B52908080A0ADEDE1BB1DD1C180B290ADE08070605F508F029290AF008
080706F50504030506060504010305060708080706050504030301000000A3A1
A19F9D9C9C9C9A9A98989797CFCDCECE9393919190908D8D8C8B8A8AC586C5C5
85858585C3C38484C38080808080808080808080808080807D7D7D7D7D7D7C7C
7C7A7C7A77777A77787776757575717171716F6F96ACB29DCE8DC584868B8DCF
9CA322ACDBB12A0ADEA9D5290BB21CE618815771CDB2D88D220918DD08B1D6A9
D8B1E51FCB22B5B2A3A9E609B1B10A29E50BDE0908DEF0080AB5B1B21BB50B0A
F019090806F5040509F02929F00908070605050504040406F504040301040506
07070706F50504000000A19FA19F9D9D9C9A9A98989797CFCFCDCECE93939190
90C88D8D8C8A8AC5C586868685858484C3C38484C38080808080808080808080
80807D7D7D7D7D7D7D7D7D7C7C7A7C7A7A777A77787777757575757176716F6E
CEA7B2A1CDC78A8686C58C931FA122ACDBE21C0A06B521AC29DDDD1C291C7158
7B98B1A08ED809EAE507B222ACD5AE199FC820E5E5D6D51BF5EBDB1B09181B29
0908080A0808DEEBEADD1B0B290A0ADE0807060504040609F0F00ADE08F30706
F5050403040505050504010103040506060606000000209E9F9E9C9C9C9C9A98
979797CFCDCD9393919190C8C88D8C8C8B8A8B8A8AC585858585C3C3C3C3C3C3
C3C3C380808080808080808080807D7D7D7D7D7D7D7D7D7D7D7C7A7A7A7A7A7A
7A7A7675757577777576766FC822B3ABD0CB8E8A86868C93979F22ABDBAFB10B
DEDE17201C2AB2B2180AAB605C7ED2B1D28CAC080BB109B5D5ACA7AC08D79298
172AACD4170829AFB20A0A1B0BF0090808F00907082AB51CB52A290AF0090707
06050301040709F00A1909070706050404040304050405050401010103030500
0000A09E9D9C9A9A9A9A989797CFCFCDCECE9391919090C8C88D8C8C8B8A8B8A
8AC586868686848484848484848484C3C3C3C3C3C3C3C38080807D7D7D7D7D7D
7D7D7D7D7D7C7C7C7C7C7C7CC07A7A777A7A7A7A77777A6A8820B2DB9CCFC88A
C5C58C91CF9DA3A9ABDBB21C290A0AA7A729B1AEAE1BB6A55C5D86A3B198C8AE
092AB5F0B5A9DAA9D80AB297CFA92ADDA5A929081CAC180929B5290808080709
09080829B5180B290AF0190907070505050404F5F319DE090807070605040404
0103030404040404010101000000A09D9D9C989898989797CFCFCDCDCE939191
909090C8C88D8C8C8B8A8B8A8AC5C5C5C5C58585858585858585858484848484
84848080808080808080808080807D7D7D7D7D7D7D7D7D7CC07C7C7A7B7B7B7A
777A776F84A5ABDB9DCFCB8CC5C58C919396A1D8ABDAE2B10B0ADE1CD4AC0AAF
DAAC29E69C5C688BA5B19191DA0A1B1C090AA9A9ACA51C0BA1CF21B5B5D922B1
0829DAB00A080B290A0909080809090707F02AB50B290AF00908070706050504
0304F507090908070706050504030303010303040404030000009D9C9D9A9898
989897CFCFCDCDCE9393919190C890C8C88D8C8C8B8A8B8A8AC5C5C586868585
858585858585858484848484848480808080808080808080808080807D7D7D7D
7D7D7D7D7B7B7B7B7B7B7B7B7A7A7A787ED5A7B22097CB8D8B888B9093969FD8
A9ABAFE21C290ADE17A3B11CAFDADA29EB8D5A7191AB268D93DB0A1CB5F029AB
AC26D5DBDEACCF9E1718DB22DA0A07B2ACE5070A18E61909080809090906070A
292A2A290ADE0909070606F50404030304060708080706060505040403010103
0303030000009D9A9C9898989898CFCFCFCFCFCE93939393919090C8C88D8D8D
8C8B8A8AC586C5C58685858585858484848484848484C3C3C3C3C3C380807D80
8080808080808080808080807D7D7D7DC17E7E7E7D7B7D7E7D7B7D7A7C2022B3
A598CE908D8BC68F93969DA5D7D9DBAFB1B5290ADEACD6B5B2DAA9AC0BE5865C
7ACCDA178DCFAFB7B11CE6F0AED7DBD6ABE6B19D98AB0BDDA7AC0B0529DADB0A
080A290A09DEDE0709090906F509E629290AF019090807060606050403040104
F507070706060505040403030301010000009D9A9C9898989898CFCFCFCFCFCE
93939393919090C8C88D8D8D8C8B8B8A8AC58AC5C58686868686858585858585
85858484848484C38080C3C3C3C3C3C3C3C3C3C3C3C3C380807D7E7E7E808080
7D7D7F7E7D7D7D7DC09DD5DBAC9C9791908E8D9193969DA5D8D9DBAFB1B52929
DE2AA3AC2ADADAD7E22AB17A5C7DCF17DA8ECDDA29B1B529291CA7ACA9D51B0A
2296A3E50BACD8B2DE07DDDAB1190829E6DEF0DE08070719090605070A2929F0
DEDE080707070605040404040101030506060606050504040303030000009D9A
9C9898989898CFCFCFCFCFCE93939393919090C8C88D8D8D8C8B8C8A8A8A8B8A
C586C5C5C5C58686868686868686858585858584C38084848484848484848484
8484848080808080C2C2C2807F7F8181817E80807B97A5ACAFA097CE92908D93
93969DA5D8D9DBB0B11C0B290ADEB1A11718ABABD5EB0BDA6A5D8598B1A9C699
17291C292A0A1BA7AEACA9B208179D9FB229E2D5DA2A0429DBB0B50609290A0A
F0F00807070909060507090AE60A190808080706F50505040404030101040405
06F505050404030000009D9A9C9898989897CFCFCFCFCFCE93939391919090C8
C88D8D8D8C8B8C8B8B8A8B8B8AC5C5C5C5C58686868686868686858585858584
C3C384848484848484848484848484C3C3C38080C2C2C2C28181848481818585
7DCCA5A9B2A39997CE919193CD969CA3D5D7ABB0B2B11C290ADEDEA9A91CB2D7
22D5290B226568889D1CD68C98AF29B1ECEB0B0BAC261722AC080AD5A0A9181B
ACA71C0707DDDAB2F0080AF01919DEF008F506090906050508F00A0909080707
070606050504030301010101030405050504040000009D9A9C989898CFCFCFCF
CFCFCFCE9393909090909090C8C88D8D8C8B8C8C8B8A8A8A8A8AC5C5C5C5C5C5
8685858585858585858585858484C38484848484848484848484848484848484
8484848485868585868686C584CE22220BD79C9797CDCDCD1F9A9D20D5A7ABDB
E2B2DDB5290ADE18D5AB0BABD5D4AB0B0B9F5D6D87A0B5A0C59CAF29B11BB518
E6E2DAB2D8A72907DB9EA51CE6E2D7AF290629DBDAB50907F01908F0F0DE0705
0709080705050608191908F30706060505040404030303010101010104040400
00009D9A9C989898CFCFCFCFCFCFCFCE939391919191919090C8C8C88D8C8C8C
8C8B8B8B8B8B8A8A8A8A8A8AC586868686868686868686858584858585858585
858585858585858585858585868686868687868687878A8B8D90AC20E5A920D2
9A1FCF1F969D9FA3D5A7ABDAB0E2DD1C0B0A0AF317A5B2EB20219FAC0B0B975D
6C8CA1E59C8720DD0A1C1C0B1B29B1ACB2ACD5DD071822D4AE29E5ABAC1B0607
1BDBB229090809090909F0190605060808060504050708090807060606050505
04040301010101010101010000009D9A9C989898CFCFCFCFCFCFCFCE93939393
939391919090C8C88DC8C88D8C8C8C8C8C8C8B8B8B8B8B8AC5C5C5C5C5C5C5C5
C5C5C586858586868686868686868686868686868686C5C5C5C5C58886878787
8B8D8D93CDCDAC9DB3DAA19E9CD2D2D29C9D9FA5D8A7ABDAB0E2B21C18E6DEDE
F3DAA5B1EA9DA998B10B1B905D76C8D8EA968C20B10ADDB10BB529B5ABE226D8
DB0A09DBD4A9B52AAFA9B2DE06F01CB01CE60909080707190ADE060506070806
04030506070807070606050505040403030303010101010000009D9A9C989898
9797979797CFCFCDCECE93939393939191909090C88DC88D8D8C8C8C8C8C8C8C
8A8A8A8B8A8A8A8A8686C5C5C5C5C5C58686C5C5C5C586C5C5C5C5C5C5C5C586
C586888A8B8B8B8B8B8E8D9093CDCE979698DAA3B2E5D5A120A0A0A09D9FA3D8
D7D9ABABDB17B2DDB529E6DE0629A7A70BE29EA5D21C1BDD8A607D93A91CCE8C
D4AFEBDDB1E61B2A2A26AFB1A9AC2A071BA7D5E229E5ACDB2A080929DDE20BF0
DEDEF30608090A19070506070707F5040406060707060606F505040404040303
0101010000009D9A9C9898989898989797CFCFCDCDCD93939393939191909090
C88DC88D8D8C8C8C8C8C8C8C8B8A8A8A8A8A8AC5C586C5C5C5C5C5C5C5C5C5C5
C5C586C5C58A8A8A8A8A8C8B8AC5888A8C8C8ECB93CECD1F969A9D9E9E20DA22
D70BABD5D5D42020A1A1A5D8ABDAABABDAB0B2DDB52A290ADEDE1B22DA2AA5A0
D49D1C1BB18564C3CDAB1C938CA3B229DD1CE618B5F0DDDA1CAEA7B108DE17D5
DA1B2917DAB10A07082AB2DD29F0F009070707190ADE06050607080605040405
F506060606050505040403030303010000009D9A9C9898989898989797CFCFCF
CFCFCECECECE93939391919090C890C8C88D8D8D8D8D8D8C8B8B8B8B8B8B8B8A
C5C58A8A8A8A8A8A8A8A8A8A8A8AC58A8A8B8B8B8B8B8B8B8B8B8A8C8ECB9393
CDD099969C9DA1A52222DAABA10ADAA7D6A5A3A3A1A322A9ABABABABACDBB2B2
E5182AE6DEDE071721B2EB98209C200BE5DAC365C596AEB2CB8DD4DDE6E5B22A
18EB0A1BDB1CB1A9DA2A052AABA9B229EB17AF18F00609B5B11B0ADEDE080706
07DE0A090605F507070605050404050606F50505040404040303030000009D9A
9C9898989898989797CFCFCFCFCFCECECECECE939391919190C890C8C88D8D8D
8D8DC88D8C8B8B8B8B8B8B8A8AC58A8A8A8A8A8A8A8A8A8A8A8AC58A8A8B8B8B
8B8B8C8D8CC890CBCDCFD0999C9DA09FA1A5A5A7D9ABB2DB9DE6B2A9A7D5D5D5
2222D8ABABABDBABACDA17B21CB5B5290ADE0919ABD8E51C91D896A50B1BDB7E
6AC598B2E28E8FA5B2E6EAAF0A291C290B26B21BDAAC1C0608B1D9DA0B0A1C26
1C290806DE1BDD2AF0DE190806F506190A090604050607060605040304050505
050504040303030000009D9A9C9A98989898989797CF97979797CDCDCDCDCECE
CE9393939190919090C8C8C8C8C88D8D8C8C8C8C8C8C8C8C8A8A8B8B8B8B8C8C
8B8B8B8B8B8B8B8B8B8C8C8D8DC89193CDCDCDCF9A9C9C9E20D4A5D8D8D9D8D9
ACACB3B29DB3ECACDAA9D7D7D7D7ABABDBDADBDAACDBB0B21C1B1B18E6DE0909
2AA9AC0BAC90D8D0A7E5B5AC7A728B9DDDAC8E91D4E20A2AAF290A1C290AB217
18B1DAB20A0429DBABB20AE6B1B22A08F5060AE51B2909EF190705040609DEDE
060505F50706F50504030304040505040404030000009D9C9D9C989898989897
97CFCFCFCFCFCDCDCDCD939393939393919090909090C8C8C8C88C8C8C8C8C8C
8C8C8C8C8A8A8B8B8B8B8D8C8B8B8B8B8B8B8C8C8C8C9093CECFCDCD989C9E9E
20A120D4D5D6ABABABDADADBDBDBEAE5A0262ADADAA9ACACACACDADBAFAFDBDA
DB1717B2B11C1BB52AE6190909B2A5DB29D493DA97AB1C18AB77718C9E1CDA8B
CCA3B10A1826B5F0E50B291B26E5B5DAAFEB070618DADAEBF00BB21C0A070607
0AB5EBF009DE090704030609F019060404F50606F50504030303030404040300
00009D9C9D9A9A9A9A9A9A98989797979797CFCFCFCFCECECECECE9393919191
9191909090908D8D8D8D8D8D8D8D8D8C8B8B8C8C8C8C8C8B8A8A8B8B8B8C8D8D
C890CDCDCF989A9A9D9FD4A1A32222D6A9ABDBB0B0E2E2B1B1EAEAECA0D70817
DAACDADADADADADBAFE2DBDBDBB0B017B1DD1CB52AE6E6B61909DBD8B11B93D0
AC97AFB1B5A97A778D201CD98A9321B2E629261C09E518290BE2B12AB2DB1CDE
0609B2DBDD0A0A1BB12A09F30708291829F0080909F30501F508190907050405
06060504040303010303040000009D9C9D9A9A9C9C9C9C9A9A98989898989797
9797CDCDCDCDCECE93939393939391919191C8C8C8C8C8C8C8C8C88D8C8C8D8D
8D8D8B8C8D8D8C8D90909393CDCF97979C9C9D9FA1D4D522D8A9A9ABDADBDBDB
B0E2B1EAE5E5EA0BD5A10EE5AEAEAF26262626AF17B2B2AFB0B0B0B0B1B1DD1C
1829B619B607EBA9AC1CB1889D229817B10BD6787DCCA1EAA78BCEA5B229B5B2
B10A181B0A29B1DD2A1C26B2E60806E6B2AF0BF029E51BF007060609290B2908
F3190906040406070909070504040505050504030101010000009D9C9D9A9A9C
9C9C9C9A9A9898979797CFCFCFCFCDCDCDCDCFCFCDCECECECE9391919191C8C8
C8C8C8C8C8C88D8D8D8D8D8D8DC8C89090919193CECD97989A9D9D9E9FD4D4A5
D7D7ABACDADADAB01717B2B2B1EAEAE5E5E5EA0BAB9D2A0BE2DA26DA262626AF
17E2E2E2B0B0DBB017B11C1B182A29190907061B22DB0BACC3A5A19EDAB20BA5
7A7F92D5B5D58C93A3AF2929B217F02A1B2A291BB21829B217B5090508B517DD
29DE2AB52A09070608090A290A0808DE08060504050608090705040405050504
0403030000009D9C9D9A9A9C9C9C9C9A9A98989797CFCFCFCFCFCDCDCDCDCDCD
CECDCDCE939391919191C8C8C8C8C8C8C8C88DC8909090919193CECECECDCF97
9A9A9D9E9ED4A5D5D5D9D9D9ABACACDADBB0B0B01717B2B11CE5E5E5E5E5E5E5
AED01BE6B2DADA2626AFAFAF17E2E2E2AFB0DBB017B11C1B182A2A29B6090709
B2D8E20B2080DB20A1ACB20AD47B8197A71BD58A97A5AF1829DDAF0A0AE52A29
0BB11B291CAF1C0A06F5F0DDB11819F0B518F008060607080A29F00707090706
050504050708070604030405050404000000A09D9D9C9C9C9C9C9C9A9A989898
9797CFCFCFCFCDCDCDCDCDCE9393CE939191909090909191919190909090C891
9193CECDCFCF979798989C9C9E9FA1D4D4D522D7D9ACACDADADBDBAFAF17B2B2
1C1C1C1C141414E5E5EAEA0BE59A26F0B1E2DA26AFAFAFAF17E2E2E2E217DBB0
17B11C1C18182A29B609B60909ABA9B118CEC5B19FD5AC172AA37B84CDD80BA5
8E1FA5B22A0ADDDA0B081B182929DDB1290BB2B10B0907F529DDE529080A1829
090706080708F00A09060707070605040405060707F50403040404000000209E
9E9D9C9C9C9C9C9A9A989C9A98989898989897979797CFCFCDCECECECE919393
9393CDCDCDCDCFCFCFCFCECECFCF9798989A9A9C9D9D9EA1D4D4D5D7D7D7D9AB
DADBACDBAFAFB2B2DD1C1C1C1C141C1C181814E5E5EAE5EC0BA0D7DEE5B126AF
E2B2B1B1B1B1B2B2B2E2171717E2B11C1B180B2A0AB607070929D8DAE51B8B8E
1BA1D6A9E229217D861FD72A228ECFD8B00BF01BAE1B08181B2929B51C0B0A1C
B2B50A08F5070B1C1BF009290B0A0706F3F306F319F008060607060605040405
F50606F5040303000000A09D9E9D9C9C9C9C9C9A9A9A9C9A9A9A989898989898
989898989797979797CF9797979797979797989898989A9D9D9D9D9E9E9F9FA1
D4D4A5D522D7ABABABACDADAAF17AF17B2B2DD1C1B1BDD1C1C1C1C1C1C1414E5
E5E5ECE50BA7A1E6ECE2E2E2E2B1B1B1B1B1B1B1B2E2171717E2B11C1B18EB2A
0AB6090607061BD5AE1BB27FCF0BD4A9D6B229A57EC596AB2A229097A5172AF0
B5DB1C06291C29E62AE51B0A29B11C29DEF50619181B2909DE292A0906060607
0607090907F5060706050504040404060605050000009D9C9D989A9C9C9C9C9C
9C9C9C9C9C9C9A9A9A9A9A9A9A9A9898989A9C9C9C9C9A9A9A9A9C9C9C9C9C9C
9C9C9EA1A1A1D4A5A5D5D52222D7ABD9ABABDAACDBAF17AFAFB2DDB2DDDD1C1C
1C1C1C1C1C1C1C1C1CE5E5EAE50BECE50ADA98E5F0B1B1B1E2B1B1B1B1B1B1B1
B1B1B2B2B2B2DD1C1818EBEB2A29090707090717A7B218A97B9F18D8A922B229
A184879AAB0AABC81FD6DB2AF00BDAB208F0DD0B0A29B51C290A1C1C0BF0F306
05F0EB0B0A08F0290A0805060706050609080605F50606050504040303050500
0000209F9E9D9E9E9E9E9E9E9E9E9E9E9E9E9D9D9D9D9D9D9D9D9D9D9D9E9F9F
9F9F9E9E9E9EA1A1A1A1A5A5A5A5A5A5A522D7D9D9ABD9ABABABACACDADB1717
B2DDB2DDDD1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1CE5E5EAECECE5E5E62698B2
07B1B1B1B1B11C1C1C1C1CB1B1B1B2B2B1B1DD1C1B1B1BEB2A29B6090909070A
ACABB2B59F7CD918ACD921E518A3848A9DACEBAB9196D5AF0B0A0BAEAF0A07E5
E5E60A2AE5180829DDE5E609070506E60B290908E62919F50506070605060708
07050506F5050404040303000000A3A1A19F9F9F9F9FD4D4D4D4D4D4D4D4A1A1
A1A1A1A1A1A1A1A1A1A1A1A1A1A1A5A5A5A5D5D5D5D5D5D5D5D522D7D9ABD9AB
ABACABACDBDADADADBAFB2DDDD1C17B2DDDDDDDDDDDD1C1C1C1C1C1C1C1C1C1C
1CE5E5EAECECEAE52AE59DAC08B1B11CB11C1B1B1B1B1B1C1CB1DDDDDDDDB11C
1C1C1C140B2A290A090909062AA9DA171BCDC3DA1CACA9D4180B22C58E9DAC0B
AC93D022AEEB0A2AB2DB29F3EBE52A0A291BB5F0DE1B1C2A0A08060508E62A0A
F319290A07F5060606F504060707060404050505040404000000A5D4A5A1A1D4
D4D4A5A5A5A5A5A5A5A5D4D4A5A5A5A5A5A5A5A5A5D522222222D7D7D7D7D7D9
D9D9D9D9D9D9ABACDADBDADADADBDB1717B217B2B2DDB2DDDD1CB2B2B2DDDDDD
DD1C1C1C1C1C1C1C1C1C1C1C1CE5E5EAECECEAE50B0B9EA5F02A1C1CB1B11B1B
1B1B1B1B1CB1DDDDB1B1B1B11C1C1C140B2A290A09090707F5B1D8B21B1B8B86
AFB2AFA720B5B5A98B8D9DAC0BDACED0D526B50A2ADDDA1B070A1C0B190A0BE5
29082AE5180A09060505080A291907F00A190604050606050305060705040405
050404000000D5D5D5A5D5D5D5D5D5D5D5D5D5A5A5A5A5D52222222222222222
D7D722222222D9D9D9D9D7D9ABABABACDADAACACDADBAFAFAFAFAF17AFB2DDDD
DDDDDDDDDDDDDDDDDDDDDD1C1C1B1C1C1C1C1C1C1C1C1C1C1CE5E5EAECECECE5
0B2AD59E2A291BB1B1B11C1C1BB51B1B1CB1DDDDB2B2DD1C1C1C1C140B2A0AB6
B6B6080A060926ABB129AF868EB21CE2D8A3B51BD78E8D9DAB2AAFCF97D5DB1B
0A291BDBDD0908E5B50A0AE61BB51919EB1829EF07F50405080AF00707F0F008
F504050606040304F5060504040404000000A7D7D5D5D7D7D7D7D7D7D7D7D722
222222D7D9D9D9D9D9D9D9D9ABABD9D9D9D9ACACACACABACDADADBDBAFAFAFAF
1717B2B2B2B2B2DDDD1CDDDDDDDDDDDDDDDDDDDDDDDDDD1C1C1B1C1C1C1C1C1C
1C1C1C1C1CE5E5EAECEC0BECEC2AAB991BDE1B1CB1B11C1C1BB5B5B5B51C1C1C
DDB1DD1C1C1C1C1CEB0B290A0A09080909F509ACAB1CB5DA85CDB2E2DDD59FB5
1BAC90C89EAC18B19697A5AC1BE6E60BE2B2E606B51B0A0A0A2AB50A0829EB29
F0080605040608DE090708F00906030405060503030405F5050304000000A9D9
D9D7D9D9D9D9D9D9D9D9ABABABABABACACDADADADADAABACDADADADADADAAFAF
AFAFDBDB1717AFAF17B2B217B2DDB2B2B2B2B2DD1C1CDDDDDDDDDDDDDDDDDDDD
DDDDDD1C1C1B1C1C1C1C1C1C1C1C1C1C1CE5E5EAECECE5E5E5E62697AE081B1B
1C1C1C1C1BB50BB5B5B51C1CDDDDDD1C1C1C1C1C14EB29290A0AB607090A07B7
A9AC1C29D8C39617EAE5A1A018B5ACCE909FAB0BE5D21FA3DAE5E60A29B1E20B
06E6B129F00AE6182A08190B0B0A09070505050609DE070709DE070503040506
05030104050504000000ABD9ABD9ABABABABABABABABACACACACACACDADBDBDB
DBDADBAFAFAFDBDBDBDB17171717AFAFB2B2DBDBAF1717AFB2B21717171717B2
DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD1C1C1B1C1C1C1C1C1C1C1C1C1C1CE5E5EA
ECECE5E5E5E6B3D2A5082A1B1C1B1C1C1BB5B50BB5B51C1CDDDDDD1C1C1C1C1C
14EB2929290A0909080709081BA9AF1C2920819E26B1B5D42018B5AFCF909DA9
2A299F96A5DA1CE60A0ADD17EB07091CEBF0F00A0B2A09070A2A29F007060505
04060808070709090704010405050403010304000000ABACACABABACACACDADA
DADADADADADADADADADADBDBDBDBAFAFAFAFAFAFAFAF1717171717171717AFAF
171717B2B2B2B2B2B2B2B2B2B2B2DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD1C1B1B
1B1B1B1C1C1C1C1C1CE5E5E5E5E5ECECEC0B1BA120DE291C1B1C1B1B1B1B1C1B
B5B51C1CDDDD1C1C1C1C1C1CEBEB0B2929B6B60907F5070908B1ABDD2A0B9C81
A5ACB12A9F9F18E5AFCFC89DABB5E6A598A3AC1C290A0AB5B2E508070BE50A19
DE290BF007092929F00907F50404050608060608090705030304050504030100
0000ACDADAACACDADADADBDBDBDBDBDBDBDBDBDBDBDB17171717AFAFAFAFAFAF
AFAF17171717171717171717171717B2B2B2B2B2B2B2B2B2B2B2DDDDDDDDDDDD
DDDDDDDDDDDDDDDDDDDD1C1C1C1C1C1C1C1C1C1C1CE5E5E5E5E5E5E51B0B0BA9
9E2AF01B1B1CB11B1B1B1BB50BB5B5B51C1C1B1B1C1C1C1CE514EB0B290A0A19
090707070908AEACB10B1BCFC5A9ACB52AA02018E5179AC89EA9B50AD7D2A3DA
1CE60AE6EB171CF0070A1B2909090A2A29F3070A290A09080605050404060706
06F3080604030405050403000000ACDADBDADADBDBDBAFAFAFAFAFAFAFAFAFAF
AFAFAFAFAFAFAFAFAFAFAFAFAFAF17171717171717171717171717B2B2B2B2B2
B2B2B2B2B2B2DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD1C1C1C1C1C1C
1CE5E5E5E5E5EAE5E5EC0BAC9CB1062A1B1CB11B1B1BB50B290B1818E51B1B1B
1C1C1C1CE5E5140B2929E60A090809070807F0ABDAEB1C17CC8CABDAB529A0A1
2AE5B2A0919ED91B0AABD2D4DADD29F0E62AB1DD290608EB0BDE0809292ADE06
090A0A0908060505040405060605060807050303030404000000ACDBDBDADADB
DBDBAFAFAFAFAFAFAFAFAFAFAFAFAFAFAFAFAFAFAFAFAFAFAFAF171717171717
17171717171717B2B2B2B2B2B2B2B2B2B2B2DDDDDDDDDDDDDDDDDDDDDDDDDDDD
DDDDDDDDDDDD1C1C1C1C1C1C1CE5E5E5E5E5EAE5E5B32A269EA7062A1B1C1B1B
1B1BB5B5290B1818B51B1B1B1C1C1C1CE5E5140B0B29E60A0907070806090829
DADB1CEA1790CBDAAB0B299FA1291CDDD493A0D9B1E6269DA3ACB2290A0A29DD
B10B080629B51908090A2A0A0707F00A190807060504030405F5050506070604
030304000000ACDBDBDADADBDBDBDBDBDBDBDBDBDBDBDADADBAFAFAFAFAFAFAF
AFAFAFAFAFAFB2B2B2B2171717171717171717171717B2B2B2B2B2B2B2B2B2B2
B2B21C1C1C1CDDDDDDDDDDDDDDDDDDDDDDDD1C1C1C1C1C1C1C1414E5E5E5E5E5
1B1BE6B2A1A508F01B1B181B1B1B1B1BB50B1818B51B1C1CB1B11C1CE5E5EB0B
0B2AE60A091908070707080718ACAF0BEA26CBCEDBD9B529A0A12AB1B1D897A0
D7DD0AB29F20ACB229F00AF01BB10B190509B529080819E6E60906080AF00808
060505040304050505050606F50403000000ACDBDBDADADBDBDBDBDBDBDBDBDB
DBDBDADADBAFAFAFAFAFAFAFAFAFAFAFAFAF1717171717171717171717171717
1717B2B2B2B2B2B2B2B2B2B2B2B2DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD1C
1C1C1C1C1C1414E5E5E5E5E51B1B2A0BD59EF0F0182A1B1B1B1B1B1BB50B0B0B
B5B51B1C1C1C1C1CE5E5140B0B2A290A19190908080808F5071CACB10BB1AC91
98AEAB2A0A9EA10B1CDDD81F9FA9B20A1BA5A3ACDDEBF00AF00BB1180A070629
0B0907080AE619060619F0080706F5050403030404050505060605000000ACDB
DBDADADBDBDBDBDBDBDBDBDBDBDBDADADBAFAFAFAFAFAFAFAFAFAFAFAFAFAFAF
AFAF171717171717171717171717B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2DDDD
DDDDDDDDDDDDDDDDDDDDDDB2B2B21C1C1C1414E5E5E5E5E51B1B0B2AA99C1C06
18291B1B1B1B1B1BB50B290B1818B51B1C1C1C1CE5E51BEC0B0B290A0A0A1909
090908080808B1DBB218B1AC909D17D9290AD29F2AB1DDAC9CA0D9B22929A7A5
ACB22ADEF0DE29DDE50A0805092A0A0607F0290AF3060709090806F505030303
04040404040506000000ACDBDBDADADBDBDBDBDBDBDBDBDBDBDBDADADBAFAFAF
AFAFAFAFAFAFAFAFAFAFAFAFAFAF171717171717171717171717B2B2B2B2B2B2
B2B2B2B2B2B2B2B2B2B2DDDDDDDDDDDDDDDDDDDDDDDDDDB2B2B21C1C1C1414E5
E5E5E5E51B1B0B2AAC9CDA0618181B1B1B1B1B1BB50B29291818B51B1C1C1C1C
E5E51BECB50B2A0A0A0A19090909070708F509E2AE18B5B2A9919DB0AB0A0A9A
9E2A1C1C17D2A0D7E2E60AABA3ACB118DEDEF00AE51B2908050629290806080A
0A0906F5080908070605040403030304040404000000ACDADAACACDADADADADB
DBAFAFDBDBDBDBDBDBDBDBDBDBDB17171717AFAFAFAFAFAFAFAFAFAFAFAFAFAF
17B2B21717171717171717B2DDDDB2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B21C1C
1C1C1C1C1C1C1C1CEAEAEAEAEAEAE5ECECEC0BE6269EAB060A182AB51BB51B1B
B50B18180B181B1C1C1C1C1CE5E51B0B0B2A2A290A0A19080808F5F508080729
AFB2EBB5B2D993A1DBA9DEDED2D22A1C1CB19F9DA9170BDEAFA5ABB218F0F0F0
DE1BE529DEF504DE29DE0606DEE6DE0605070908070605040404030303030300
0000ACDADAACACDADADADADBDBAFAFDBDBDBDBDBDBDBDBDBDBDBAF171717AFAF
AFAFAFAFAFAFAFAFAFAFAFAF17B2B217171717171717171717B2B2B2B2B2B2B2
B2B2B2B2B2B2B2B2B2B21C1C1C1C1C1C1CEAEAEAEAEAEAEAE5E51BECECECEC2A
B120A306DE182AB51BB5B5B5180B181818181B1C1C1C14E5E51BECB5180B0B2A
290AF0090909F5070606080729ACE229B5AFACCDA726A9F0099D9D2A1BDD1CA5
9EA7AF0B19B122ABB2B51909F009181C2ADE0705070AF006F508F0F007050507
0806060505040403010103000000ACDADADADADADADADAB0B01717B0B0B0B0B0
B0B0B0B0B0B0B0B0B0B0171717171717171717171717171717B2B21717171717
1717B0171717B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B1B1EAEAEAEAEAEA
EAE5E5E5E5E5E5E5E5E5E51818229F2908290BB5B5B5B5B5180B1818180BEBEB
EBEB141B1B1B1B1B18180B2AB7B7F0190908080606F5F50806B517DD291CAFAC
97D7DAABDE07A09E0B1BB10BD89FD9B21808E5A7ABB2B5F009F0092A1C2AF008
0504090A08F5F509DE0806040607070605050404030303000000DADBDBDADBDB
DBDBDBB0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0E2E2E2E2E2E2E2E2E2E2
E2E2E2E2B2B2B1B2B2B2B2B2B2B2E2E2B2B2B1B1B1B1B1B1B1B1B1B1B1B1B1B1
B1B1B1B1B1B1EAEAEAE5E5E5E5E5E5E5E5E5E51B1B1B1C1818AB20B1060A29B5
1CB5B5B5182A1818180B0B0BEBEB141B1B1B1B1B1B18182A0AB70A1919080808
F5F506F506F5B5AE1C0AB126AB96DA26ABF408A19E1818B22ADAD4A91718F029
ACABB2EB0A09F0090AB50B0A08F50307F0090505071909060505060706050504
04030300000026DBE3DBE3E3E3E3DBDBDBDBDBDBDBDBE2E2E2E2E3E3E3E3E3E3
E3E3E3E3E3E3E2E2E2E2B2B2B2B2E2E2E2E2B1B1B1B1B1B1B1B1B1B2B2B2B2B2
B2B2B1B1B1B1EAEAEAEAEAEAEAEAB1B1B3B3B3B3B3B31B1B1B1B1B1B1B1B1B1B
1B1B1B1818DBA3DBFE290B181CB5B5B5182A180B0B0B2A2AEB0BEC1B1B1B1B18
182A2A2AB70A0AF0F0F008080707F5F50607081BDB0B29E217DA9C26DAD90807
A39FB50BB129AFA5ABAFE5DEF026ACB2B5E608F00809180B0A09060305091906
04060909070504F506050505040403000000DADBDBDADBDBDBDBDBDBDBDBDBDB
DBDBE3E3E3E3E3E3E3E3E3E3E3E3E3E3E3E3E3E3E3E3B2B2B2B2B2B2B2B2B2B2
B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B3B3B3B3B3B3B3B3B3B3B3B3B3B3
B1B1E5E5E5E51B1B1B1B1B1B1B1BB51C29B2A3D5F3F30B18B518B518182A0B0B
0B0B29290B0B0B1818181B18182A2A292929E60A0ADEDE080707F5F5F5070707
B1B22A2ADB17AC9EE2DAAC09F3A5201BE6B229DDD6A9171CF008DDDAB21B0A08
190908292AE6090705040619080505060808060304050505040404000000DBAE
AEDA262626262626262626262626AFAFAFAFAFAFAFAFAFAFAFAFAFAFAFAFAFAF
AFAFB2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B3B3
B3B3B3B3B3B3B1B1B1B1B1B11C1C1B1B1B1B1B1B1B1B1B1B1B1BB51C29B5D5A3
0B06292A1818EBEB0B2A0B0B0B0B29290B0B0B181818B518182A292929E60A0A
0A0ADE09080706F50507090709B2B12A2ADBB1ACA1B1ACDBEF07D7A0DDF0B218
1BA9AB17E5E60718DBB2B52908090908E6290A09070504060809060405070706
04030505050404000000DBDAAEDAAEAEAEAE2626262626AE262626262626E2E2
E2E2E2E2E2E2E2E2E2E226262626E2E2E2E2B2B2B2B2B2B2B2B2B2B2B2B2B2B1
B1B1B1B1B1B1B2B2B2B2B1B1B1B1B1B1B1B11C1C1C1C1C1C1C1C1C1C1C1C1C1C
1C1C1BB5B51CB50B0B2AD9A51CF3292A2A2AEBEB0B2A0B0B0B2A29290B0B0B2A
2A2A18180B29290B2929290A0AF0F0DE0808070505050507070AB2E5F02AAC1B
DAA51CDA260906AC9FB119B20B2AACACB21B29082917B2B5E608080907F0290A
0907060505060806040306070605030305050400000017262626AFAFAFAF26DA
DADAE2AFE2E2AFE2E2AF26262626AFAF2626B1B1B1B1B1B1B1B1E2E2E2E2E2E2
E2E2B1B1B1B1B1B1B1B1B1B1B1B11C1C1C1C1C1C1C1CB1B1B1B1B1B1B1B1B1B1
B1B11C1B1B1B1B1B1B1B1B1C1C1C1C1C1C1C1818E6E6DAA5AFFE2A0B292AEBEB
0B0B0B0B0B0B292929B72A2A18180B0B0B0B0B18292929F0F0F0DEDE09070505
0505050506062ADD18DE1BDA0BDB221CDB260801B29FE20ADD18E6DBAC171B29
08F0DDB21B290907090709290A19070604040507070503050606050403040400
000017262626AFAF262626DBDBDB26AF2626AF2626AF2626262626AFAF26B2B2
B1B1B1B1B1B1B2B2B2B2B2B2B2B2B1B1B1B1B1B1B1B1B1B1B1B11C1C1C1C1C1C
1C1CB1B1B1B1B1B1B1B1B1B1B1B11C1B1B1B1BB5B5B5B51C1C1B1B1B1B1B1B1C
18DEB1A5AB06092929290B0B0B0B0B0B0B0BB7B7B7B7292A0B180B0B0B2A2A0B
2929290A0ADEDEDE09080705050507050607050BB10B08E5DA29AED91BDBAF19
01DDA3E2F01B1B0AB1ACE2B52908081BB21B2919070907070A0A09F306050405
0606060301050606050301000000B0DADADADBDBDBDBDBDBDBDBDBDBDBDBDBDB
DBDBAFAFAFAFAFAFAFAFAFAFAFAFAFAFAFE2B2B2B2B2B2B2B2B2B2B2B2B2B1B1
B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B11C1C1C1C1C
1C1C1C1B1B1B1B1B1B1B1B1C14B6E5A7D809F52929290B0B0B0B0B0B2A2A2A2A
2A2929290B182A2A2A2A2A0B29E6E6E60A0A0A19090907070707060605060507
18B1E6F0B2262AAFAC0BDAE219051BA72619181BDEDDDAB21B2A09062AB11B29
DE07080706190A09070605040405F5F50401040506050300000026DBDBDBB0B0
B0B0B0B0B0B0B0B0B0B017171717B0B0B0B0E2E2E2E2E2E2E2E2E2E2E2E2B2E2
E2E2DDDDB2DDDDDDDDDDB2B2B2B2B2DDDDDDDDDDDDDD1C1C1C1CDDDDDDDDDDDD
DDDD1C1C1CE5E51B1B1B1B1B1B1B1B1C1C1C1B1414141C14140B0BAC220B030A
29290B0B0B2A2A2A29292929292929292A2A2A2A2A2A2A0BE6E60A0A0ADE1919
08080808070606060505060607B51C29F01717E6AFDB18DAB2F0F50BD9AF092A
E5DEEBAFB11B2909060AE51B29DE070707F508DE090706050404040505050303
04050500000026AEAF26AFAFAFAFAFAFAFAFAFAFAFAFAF171717AFAFAFAFB2B2
B2B2B2B2B2B2B2B2B2B2171717B2DDDDB1DDDDDDDDDDB1B1B1B1B1DDDDDDDDDD
DDDD1C1C1C1CDDDDDDDDDDDDDDDD1B1B1B1B1B1B1B1B1B1B1B1B141CE5E51414
14140B0B0B0BE626A9E80319B72A2A2A2A2A2929292929292929292929292A2A
2A2929292929E6F0F0F0190909080808070706060505040606F31B1BDEDEE2B2
0AE2172A26B219070AAC2619291BF029B2B1B529DE060918B529DE0707080507
190907060504030405050504010305000000B0AEAFAEAEAFAFAFAFAFAFAFAFAE
AEAFAFAFAFAFAFAFAFAFB2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B1B2B1B1B2
B1B1B1B1B1B1B1B1B1B1B1B1B1B11C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C
1C1C1CE5E5E5E51B1B1B1B1B1B1B1818180B0AB2A7AB06090A0A2A2A290B2929
292929292929292929292A292929292929290A0A0AF0DE090909090808070707
06050404F306091B18DE0A26DDF0B1B22A17B10A08DE26DAF00A1B0A0A1CB11B
2AF00707291829DE07060706060909070605040303050505040301000000DA26
AF26AFAF262626DADADADA2626DAAFAFAFAFAFAFAFAFAFAFAF171717B2B2B2B2
B2B2B2B2B2B2B1B2B1B2B2B1B2B1DDDDDDDDDDDDDDB1B2DDDDDD1C1C1C1C1C1C
1C1C1C1C1C1C1C1CE5E5E5E5E51B1B1B1B1B1B1B1B1B1B1B1B1B1818181B0A1C
D9A919F5F0F02929290B2929292929292929E6E6E6E629292929292929290A0A
0A0ADEDE0909080807070707060605040607040AB529092917E50AB1B129171C
F00908B2DAE619B50ADE1BB11B2A0A08060A0B291907F5060605080807060504
03030405040404000000DBAFAFAFAFDBDBDBDBDBDBDBDBDBDBDBAFAFAFAFAFE2
E2E2E2E2E2E2E2E2B2E2B2B2B2B2B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1
B1B1B1B1B1B1DDDDDDDDE5E5E5E5DDDDE5E5E5E51C1B1B1B1B1B1B1B1B1B1B1B
1B1B1B1BB5B5B5B5B5B5290BDBAB18F519F00A29290B2A2A2A2AE6E6E6E6E6E6
E6E62929292929292929290AF0F0F0F00909090808070606060605060506FEFE
0A1B290829B21BF0B11C29171CF009071CDBE6071829090B1C1829F008F50929
29DE070506060407F30606050403010304040400000017B2B2E2B0B0B0B0E2E2
E2E2B0B0B0B0E2E2E2E2DBE2E2E2B2B2E2B2B2B2B2B2B2B2B1B1B1B1B1B1DDDD
DDDDDDDDDDDDDDDDDDDDDDDDDD1C1C1C1C1C1C1C1B1C1C1C1B1B1B1C1B1B1B1B
EA1B1B1B1BE51B1B1B1BB5B5B5B5B518180B0B0B0B0B0B0A17AB1CF5080A0A29
292A29E6E6E629292929E60A0A0A29292929292929290AF0F0F0F0DE09090808
070606060606050505060606F529B5F0082AAF1819B1B529B2E5DE09060B260B
F32A2A08291B1829F008F507E6E619070505F504060706F50504040301030400
000017AFAFAF262626262626262626262626AF26AF26AEE2E2AFAFAFE2AFE2E2
E2E2B2B2B2B2B2B2B2B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1DDDDDDDDDDDD
DDE5E5E5DDDDDDDDDDDDDDDD1C1C1C1C1C1CE5E5E51BB51BB51BB5B5B5181818
181818291CDA17F507290AE6E62929292929292929290A0A0A0A29292929E629
29290A0A0A0AF0DEF4F40808070706060606060505060605F5F52A0B09F318B1
2A09E51829B21BDE09052917EB06292A08F0180BE6F0080606DE0A1907050506
0505060605050403030103000000B026AFAF26DB262626262626DB26DBDB2626
2626DB171717AFAFAFAF17171717B2B2B2B2B1B1B1B1B1B1B1B1B1B1B1B1B1B1
B1B1B1B1B1B1DDDDDDDDDDDDDDDD1C1C1C1C1CDDDD1C1C1C1C1C1C1C1C1CE5E5
E5E5E5ECECECECECECB5B5EBB5EB1B290B2626DE06DEE60AE6292A2A29292929
292929292929E60A0A0A0A2929E60A0A0A0A0ADEDE19090808070707070606FE
0505F50507F5070B2907081BB12919B50B0AB2EB19F006DEB11806DE2A08092A
2AE6DE08060508F0090705050504040606050504030101000000B0AFE2AFB0B0
E2E2E2E2E2E2AFAFAFAFAFB0AFAFB0E2E2E2E2AFE2B2E2B2B2B1B1B1B1B1B1B1
B1B1B1DDDDDDDDB1B1B1DDDDDDDDDDDDDDDD1C1C1C1CE51CE5E51B1B1B1B1B1B
1BE5E5E5E5E5E5E5E5E5ECECECECB5B5B5B5B5B5B5B518181818B5E62917AF2A
F5090A0A29292929292929292929E6E60A0A0A0A0A0A0AE60A0A0A0A0A0A0A19
1909090808070706060606F505050505F50606092AE608091BDD0A09B529E6DD
0B090906081CB5070929090729290A1908070407190907050405040405050505
04030300000017E2E2AFE2E2B2B2B2E2E2E2B2E2E2AFAFE2AFAFE2E2E2E2E2B2
B2B2B2B2B2B1B1B1B2B1DDDDDDDDDDDDDDDD1CDD1CDDDDDDDDDDDD1C1C1C1C1C
1C1CE5E51B1B1B1B1B1B1B1BECEC1B1B1B1B1B1B1B1BB5B5B518181818181818
1818EBEBEBB50B2A29B2DB1B0408F00A292929292929E60A0A0A0A0A0A0A0A0A
0A0A0A0A0A0A0A0AF0F0F0DEEF090808080706060606F5F5F5F5050505060605
092A0A07DEE51B0A0918290A1C2A08DE070618B507070ADE070AE60A09080605
F5080807050405050305050504040300000017E2B2E2B2B1B2B2B2B2B2B2B2B2
B2B2E2E2E2E2E2E2AFE2B2B1B1B1B1B1B1B1DDDDB1B1DDDD1C1C1C1C1C1C1C1C
1C1C1C1C1C1C1C1C1C1C1C1C1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B
1B1BB5B5B5B5B5B5B5B5B50B0B0B0B0B0BEB29EB0A1BDBB10505DE0AE60A0A0A
0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0AF0DEDEDEDEDE0909080807070706
0606F5F5F5F50404050605050609290907191BB5DE090B0A0A1B2A08F0070529
1809F5F0DE06090AF01908060505070807F504040403040505040400000017B2
B2B2B2B2B2B2B1B2B2B1B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B1B1B1B1B1B1B1
B1B1B1B11CE5E5E5E5E5E51CE5E5E5B1B11CB11C1CE5E5E5E5E51BE5E51B1B1B
B51BE5E5B5B5B5B5B5B5B5B51B1B1B1B1B1B1B1BB518B5181818181818180B2A
292A1717090509F00AF02929E6E6E6E6E6E6E6E60A0A0A0A0A0A0A0A0A0AF0F0
F0F0F0DEDEDE0908080807070707060605050505050505050605DEE60907F0B5
0B0909290A0AB5E608DE07050A18090509190608F019080706050406F3060504
0404030304040400000017B2B2B2B2B2B1B1B2B2B2B2B2B2B2B2B2B2B2B2B2B2
B2B2B2B2B2B2B1B1B1B1B1DD1C1CDDE5E5E5E5E5E5E51B1BE5E5E5E51C1CE5E5
E51B1BB51BB51BB5B5B5B5B5B51BB51BB51B1B1BB518B5B5B5181818B5B5B5B5
B5B5B51818181818180B182A2929B1B2290608DEF0F0292929E60A0A0A0A0A0A
0A0A0A0A0A0A0AF0F0F0F0F0F0F0DEDE09090808080707070706050505050505
05050506050406F00A0806F0182A09F329F0F0182908190704090BDE04071906
06190909070605040506060504030403030404000000B2B1B1B1B1B1B1DDB1B1
B1B1B2B2B2B1B1B2B2B1B1B1B2B2B1B1B1B1DDB1B1B1DDDD1C1C1C1C1C1C1B1B
1B1B1B1B1B1B1B1C1C1C1C1B1BB518B5B51818B518B518B5B5EBB51818181818
1818B5B5EB180BB5B5B5B5181818180B0B0B0B0B2A2A0B2A290A1CB2B50607F0
0A0A0A0AE6E60A0A0A0A0A0A0AF0F0F0F0F0F0DEDEDEDEDEDE19191909090909
0808070706060505050505050505050504050506F00A0806F00B290808E61919
0B0A080908050829F004060906F5080908070605030406060504030403010400
0000B2DDDDB1DDDDDDB1B1B1B1B1B1B1B2B2B2B2B2B2B2B2B2B2B1B1DDB1B1B1
B1DDDDDDDD1C1C1CE5E51B1BB5B51BB51B1BB5B51BB5B5B5B5B518B518181818
180B0B180B180B180B0B0B0B0B1818180BEB0B0B0BEBEB18180B0B0B0B0B0B0B
2A2A2A290BDE0BB11C08061919F00A0A0A0A0A0AF0F0F0F0F0F0DEDEDEDEDEDE
DE0919191919191909090808F308070706060505050505050605050505F50504
06F01906060A0B0A0707E609192A0A07090805060A0A0505080705F3080706F5
F5030305F5050403030301000000B3DDB1B1DDDDDDDDB1B1B1B1B1B1B1B1B1B1
B2B1B1B1B1B1B1B1B1DDB1DDDDDDDD1CEA1CEAEA1B1B1B1B1B1B1B1B1B1B1B1B
1B1B1BB51BB5B5B5EBEB0BEB0BEB0B0B0B0BEB0B0B0B0B0B0BEB2A0B0B0B0B0B
0B0BEBB51818EB0B0B0B0B0B0B182A2A0B0AE61CB119050919F00AF00A0AE6E6
0A0A0A0A0A0AF0F0F0F0F019191919191909DEDE090909090808070707060606
0606060605050504040505050506DE080607E62AF007070A090929DE06080805
05DEF0F50407070506070706F5050403050505040303030000001CDD1CDD1CDD
1C1CDDB1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1DDDDDDDD1CE51CE5E5E5E5
E51B1B1B1BB5B5B5B5B5B5B5B5B5B5EBEBEBB5EBEBB5EBEB0B0B0B0B0B0B0B0B
0B0B2A2A2A292A2A0B2A2A2A2A0B1818EBEB0B0B0B0B0B2A290B290B29290A1B
E5290608DEF0F0F00A0A0A0A0A0AF0F0F0F0DEDEDEDEDE190909090909090909
0909080808080707070606060606F5F5F505050404050505F5F507DE080707E6
29DE0607F00809E60906F307050509DE0604060605050706F505050403040505
0401030000001CE5E51C1CE5E5E51C1C1C1CB1B1B1B1B1B1B1B1B1B1B11C1C1C
1C1C1C1C1CE5E5E5E51B1B1B1B1B1BB5B5B5B5B518B5181818181818180B1818
18180B18180B2A2A2A0B0B0B0B0B0B2A2A0B2A2A2A2A2A2A2A29290B0BEB0B0B
0B0B2A2A2A2A292929290A181B0B0607DEDEDEF00A0A0A0A0AF0F0DEDEDEDEDE
DEDEDE09090909090909090808080808080808070707060606F5050505050404
0404050405050407090806070A0A090607F007080A09F5070705040719060405
0605050606050505040303040504030000001CE5E5E5E51CE51C1C1C1C1C1C1C
1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1CE5E51CE5E51B1B1B1B1B1BB5B518B5
18EBEB18EB0BEB1B180B0B0B0B0B0B0B0B0B0B0B290B0BEB0B0B0B0B0B2A2A2A
292929292A2A2A2A0B2A0B2A2A0B0B29292929292929F029E51807070909DEDE
0AF00A0AF00ADEDEDEDEDEDE1919190909090909090909090808080808080707
07060606060606F505050505040404050505050507090605070AF00906071906
08F009F5070705040608060405060504F50605050403030304040300000014B5
B51B1BB51B1BE5E5E5E5E51C1C1C1C1C1C1C1C1CE51CE5E5E5E5E5E5E51B1B1B
B5B5B5B5B5B5B5B51818EBEBB518EB18EBEB18EBEB0B0B0B0B0B2A2A2A2A0B0B
0B0B0B0B0B2A2A2A0B2A292A2A2A292929292929292A2A2A2A2A2A2A2A2A2929
292A0AF0B5B509060809DEDEF0DEF0F0F0F0F0F0191919191919090909090909
09090908080808080808070707060606060606F5050505050505050405050505
0508090605F3F019080606080607DE0805060605040507070404050504050505
0404040301030400000014B5B5B518B5B5B5B51B1B1B1B1B1B1B1B1B1B1B1B1B
1B1B1B1B1B1B1BB5B5B5B5B5B5B51818181818180B0B0B0B180B0B0B0B0B0B0B
0B2A0B2A292A2929292929292A2A2A292A2A2929292929292929292929292929
2A2929292A2929292929292929290AF00BB5F006F3091919DE19DEDEDEDEDEDE
090909090909090909090908080808080808080808F307070706060606F5F5F5
05050505040404040405050505050708060508DE090805060806071908F50606
0504040706040405050305050504040303010300000014180B180B0B18181818
B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B51818181818181818180B0B0B0B0B
0B0B0B2A0B2A0B0B0B2A0B0B0B2A2A292A292929292929292929292929292929
29292929292929292929E6292929292929292929292929E6E6290A19290BE607
070809DEDE091919190909EF090909090909080808080808080808F3F3F30707
0707070707070606F50505050505050404040404040404050504040707050508
190907F505F30606090705050605040406060403050503040404040403010100
0000180B0B0B0B0B0B0B18181818181818181818181818181818181818181818
181818180B0B0B0B0B0B0B2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2929
292929292A2929292929292929292929292929292929E6E62929292929292929
29E6E6E60A0A0AF00A2A290707080809090909EF090909090909080908080808
080808080808070707070707070707070706060606F505050505050504040404
040404040404040507060505F309F307040507050608060504F5050404050604
0304040303040403030301000000182A2A2A2A2A2A2A2A2A0B0B0B0B0B0B0B0B
0B0B0B0B0B0B0B0B0B0B0B0B0B2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A292A
292929292929292929292929292929292929292929292929E6E6E6E6E6E6E60A
E6E6E6E6E6E6E62929E6E6E6E6E60A0A0A0A0AF0DE2929090607080809090909
09090909090908080808080808080808F3F30707070707070707070606060606
06F5F505050505050404040404040403040404040507060505F3F30706050506
0506070605040505040304050403030403010304030301000000182929292929
2929292929292929292929292929292929292929292929292929292929292929
292929292929292929292929292929292929292929E62929E62929292929E629
2929E6E6E60AE60A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0AF0F0
090A29DE06070808090808090909090908080808F3F3F3F30707070707070707
070707070707070706060606F505050505050404040404040404040404040404
040506F504050707060604050605060706050405050403040504030303030103
030303000000B729292929292929292929292929292929292929292929292929
292929292929292929292929292929292929E62929E62929292929E629E6E6E6
0A0AE6E60A0A0AE60AE60AE60AE60A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A
0A0A0A0AF0F00A0A0A0ADEDE09F00ADE07070708F308080808090808080808F3
0707070707070707070707070706060606060606060606F50505050505050404
040404040404030404040404040405060504F506060605040505040506050403
040403030304040303030301010303000000B70A0A0A0A0A0A0A0A0A0A0A0AE6
E6E6E6E6E6E6E6E6E6E6E6E6E60A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A
0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A
0AF0F0F0F0F0F0DEF0F0F0F0F0F0F0F0F0F0DEDEDEDEDEDE0909F0F007060707
07080808080808F308F307070707070707070707070706060606060606060606
0606F50505050505050504040404040404040403030404040404030506040405
060605050404050405F505040304040303030404010101030101030000000D0A
F0F0F0F0F0F0F0F0F00A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0AF00A0AF0F0F0
F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0
F0F0F0F0F0F0F0F0DEDEDEDEF0DEF0DEDEDEDEDE191919DEDEDEDEDEDEDEDEDE
19190909090819DEF305060707070807F3F3F307070707070707070707060606
0606060606060606060606060606050505050505050404040404040403030303
0404040404040303050504040506060505030405040505050403040403030304
030101010301010000000DF0DEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDE
DEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDE
DEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDE191919091919191909090909
0909090909090909090909090909090808080909080506060706070707070707
070706060606060606060606060606060606060606F50505F5F5050505050505
0404040404040404040403030304030303030304030505040405050505040304
050304050403010303010101030303010101010000000E090909090909090909
0909090909090909090909090909090909090909090909090909090909090909
0909090909090909090909090909090909090909090909090909090909090909
0909090808080808090909080808080808080808080808080808080708070709
0806050606060606060606060606060606060606060606060606F5F5F5050505
0505050505050505050505050404040404040403030303030303030303030303
0303050403030505050404030304030304040301010303030103010101010100
0000FD0808080808080808080808080808080808080808080808080808080808
0808080808080808080808080808080808080808080808080808080808080808
080808080808080808080808080808F30707070707F3F3F30707070707070707
070707070707070707070607070605F5F506060606060606060606F5F5F5F5F5
0505050505050505050505050505050505050404040405040404040404030303
0303030303030301010303010301010404030304040403030103040103040303
0101030301010101010101000000FD0707070707070707070707070707070707
0707070707070707070707070707070707070707070707070707070707070707
0707070707070707070707070707070707070707070707070707070707070707
0707070707070707070707060606060606060606060606060706040505050505
0506F5F5F5F5F5F5F5F5F5050505050505050505050505050505050505040404
0404040404030304030303030303030303030303030101010103030303030103
0404030301010103010303010101010101010101010101000000FD0606060606
0606060606060606060606060606060606060606060606060606060606060606
0606060606060606060606060606060606060606060606060606060606060606
0606060606060606060606060606060606060606060606060606060606F506F5
F5F505F506050404050505050505050505050505050505040404040404040404
0404040404040404040303030303030303030303030303010101010101010101
0101010101010101030401010303030303010103030101010101010101010101
010101000000F601010101010101010101010101010101010101010101010101
0101010101010101010101010101010101010101010101010101010101010101
0101010101010101010101010101010101010101010101010101010101010101
0101010101010101010101010101010101010101010101010101010101010101
0101010101010101010101010101010101010101010101010101010101010101
0101010101010101010101010101010101010101010101010101010101010101
010101010101010101010101010101000000F601010101010101010101010101
0101010101010101010101010101010101010101010101010101010101010101
0101010101010101010101010101010101010101010101010101010101010101
0101010101010101010101010101010101010101010101010101010101010101
0101010101010101010101010101010101010101010101010101010101010101
0101010101010101010101010101010101010101010101010101010101010101
010101010101010101010101010101010101010101010101010101000000F601
0101010101010101010101010101010101010101010101010101010101010101
0101010101010101010101010101010101010101010101010101010101010101
0101010101010101010101010101010101010101010101010101010101010101
0101010101010101010101010101010101010101010101010101010101010101
0101010101010101010101010101010101010101010101010101010101010101
0101010101010101010101010101010101010101010101010101010101010101
01010101010101000000F6010101010101010101010101010101010101010101
0101010101010101010101010101010101010101010101010101010101010101
0101010101010101010101010101010101010101010101010101010101010101
0101010101010101010101010101010101010101010101010101010101010101
0101010101010101010101010101010101010101010101010101010101010101
0101010101010101010101010101010101010101010101010101010101010101
01010101010101010101010101010101010101000000}
Stretch = True
end
object SpeedButton1: TSpeedButton
Left = 357
Top = 352
Width = 68
Height = 27
Caption = 'OK'
Flat = True
Font.Charset = DEFAULT_CHARSET
Font.Color = clPurple
Font.Height = -17
Font.Name = 'MS Sans Serif'
Font.Style = [fsBold]
Glyph.Data = {
76010000424D7601000000000000760000002800000020000000100000000100
04000000000000010000120B0000120B00001000000000000000000000000000
8000008000000080800080000000800080008080000080808000C0C0C0000000
FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00555555555555
555555555555555555555555555555555555555555FF5555555555555A055555
55555555577FF55555555555AAA05555555555557777F55555555555AAA05555
555555557777FF555555555AAAAA05555555555777777F55555555AAAAAA0555
5555557777777FF5555557AA05AAA05555555777757777F555557A05555AA055
55557775555777FF55555555555AAA05555555555557777F555555555555AA05
555555555555777FF555555555555AA05555555555555777FF5555555555557A
05555555555555777FF5555555555557A05555555555555777FF555555555555
5AA0555555555555577755555555555555555555555555555555}
NumGlyphs = 2
ParentFont = False
OnClick = SpeedButton1Click
end
end
| 69.741208 | 71 | 0.885135 |
6a61e426412f289bcb3fdfdeb72f78bad99aaff0 | 20,605 | pas | Pascal | 3rd Party/jcl/source/windows/JclMsdosSys.pas | ajumalp/Launcher | cdf22e6f385503663c4492d018dedb22943b7298 | [
"Apache-2.0"
]
| 1 | 2018-01-08T06:40:02.000Z | 2018-01-08T06:40:02.000Z | Libraries/jcl/JclMsdosSys.pas | novakjf2000/FHIRServer | a47873825e94cd6cdfa1a077f02e0960098bbefa | [
"BSD-3-Clause"
]
| null | null | null | Libraries/jcl/JclMsdosSys.pas | novakjf2000/FHIRServer | a47873825e94cd6cdfa1a077f02e0960098bbefa | [
"BSD-3-Clause"
]
| 1 | 2022-03-04T08:29:13.000Z | 2022-03-04T08:29:13.000Z | {**************************************************************************************************}
{ }
{ Project JEDI Code Library (JCL) }
{ }
{ The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); }
{ you may not use this file except in compliance with the License. You may obtain a copy of the }
{ License at http://www.mozilla.org/MPL/ }
{ }
{ Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF }
{ ANY KIND, either express or implied. See the License for the specific language governing rights }
{ and limitations under the License. }
{ }
{ The Original Code is JclMsdosSys.pas. }
{ }
{ The Initial Developer of the Original Code is Robert Marquardt }
{ Portions created by Robert Marquardt are Copyright (C) 2001 Robert Marquardt }
{ All Rights Reserved. }
{ }
{ Contributor(s): Robert Rossmair (IJclMsdosSys interface) }
{ }
{ You may retrieve the latest version of this file at the Project JEDI's Code Library home page, }
{ located at http://sourceforge.net/projects/jcl/ }
{ }
{ Known Issues: None }
{ }
{**************************************************************************************************}
{ }
{ Last modified: $Date:: $ }
{ Revision: $Rev:: $ }
{ Author: $Author:: $ }
{ }
{**************************************************************************************************}
unit JclMsdosSys;
{$I jcl.inc}
{$I windowsonly.inc}
interface
uses
{$IFDEF UNITVERSIONING}
JclUnitVersioning,
{$ENDIF UNITVERSIONING}
{$IFDEF HAS_UNITSCOPE}
System.Classes, System.SysUtils;
{$ELSE ~HAS_UNITSCOPE}
Classes, SysUtils;
{$ENDIF ~HAS_UNITSCOPE}
type
IJclMsdosSys = interface
['{3E1C7E48-49E5-408B-86D2-9924D223B5C5}']
// Property access methods
function GetAutoScan: Boolean;
function GetBootDelay: Cardinal;
function GetBootGUI: Boolean;
function GetBootKeys: Boolean;
function GetBootMenu: Boolean;
function GetBootMenuDefault: Cardinal;
function GetBootMenuDelay: Cardinal;
function GetBootMulti: Boolean;
function GetBootSafe: Boolean;
function GetBootWarn: Boolean;
function GetBootWin: Boolean;
function GetDBLSpace: Boolean;
function GetDoubleBuffer: Boolean;
function GetDRVSpace: Boolean;
function GetHostWinBootDrv: Char;
function GetLoadTop: Boolean;
function GetLogo: Boolean;
function GetNetwork: Boolean;
function GetUninstallDir: Char;
function GetWinBootDir: string;
function GetWinDir: string;
function GetWinVer: string;
procedure SetUninstallDir(AUninstallDir: Char);
procedure SetWinDir(AWinDir: string);
procedure SetWinBootDir(AWinBootDir: string);
procedure SetHostWinBootDrv(AHostWinBootDrv: Char);
procedure SetAutoScan(AAutoScan: Boolean);
procedure SetBootDelay(ABootDelay: Cardinal);
procedure SetBootGUI(ABootGUI: Boolean);
procedure SetBootKeys(ABootKeys: Boolean);
procedure SetBootMenu(ABootMenu: Boolean);
procedure SetBootMenuDefault(ABootMenuDefault: Cardinal);
procedure SetBootMenuDelay(ABootMenuDelay: Cardinal);
procedure SetBootMulti(ABootMulti: Boolean);
procedure SetBootSafe(ABootSafe: Boolean);
procedure SetBootWarn(ABootWarn: Boolean);
procedure SetBootWin(ABootWin: Boolean);
procedure SetDBLSpace(ADBLSpace: Boolean);
procedure SetDRVSpace(ADRVSpace: Boolean);
procedure SetDoubleBuffer(ADoubleBuffer: Boolean);
procedure SetLoadTop(ALoadTop: Boolean);
procedure SetLogo(ALogo: Boolean);
procedure SetNetwork(ANetwork: Boolean);
procedure SetWinVer(AWinVer: string);
procedure SetBool(var ANew: Boolean; AOld: Boolean);
procedure SetString(var ANew: string; AOld: string);
// Properties
property UninstallDir: Char read GetUninstallDir write SetUninstallDir;
property WinDir: string read GetWinDir write SetWinDir;
property WinBootDir: string read GetWinBootDir write SetWinBootDir;
property HostWinBootDrv: Char read GetHostWinBootDrv write SetHostWinBootDrv;
property AutoScan: Boolean read GetAutoScan write SetAutoScan;
property BootDelay: Cardinal read GetBootDelay write SetBootDelay;
property BootGUI: Boolean read GetBootGUI write SetBootGUI;
property BootKeys: Boolean read GetBootKeys write SetBootKeys;
property BootMenu: Boolean read GetBootMenu write SetBootMenu;
property BootMenuDefault: Cardinal read GetBootMenuDefault write SetBootMenuDefault;
property BootMenuDelay: Cardinal read GetBootMenuDelay write SetBootMenuDelay;
property BootMulti: Boolean read GetBootMulti write SetBootMulti;
property BootSafe: Boolean read GetBootSafe write SetBootSafe;
property BootWarn: Boolean read GetBootWarn write SetBootWarn;
property BootWin: Boolean read GetBootWin write SetBootWin;
property DBLSpace: Boolean read GetDBLSpace write SetDBLSpace;
property DRVSpace: Boolean read GetDRVSpace write SetDRVSpace;
property DoubleBuffer: Boolean read GetDoubleBuffer write SetDoubleBuffer;
property LoadTop: Boolean read GetLoadTop write SetLoadTop;
property Logo: Boolean read GetLogo write SetLogo;
property Network: Boolean read GetNetwork write SetNetwork;
property WinVer: string read GetWinVer write SetWinVer;
end;
type
TJclMsdosSys = class(TInterfacedObject, IJclMsdosSys)
private
FUninstallDir: Char;
FWinDir: string;
FWinBootDir: string;
FHostWinBootDrv: Char;
FAutoScan: Boolean;
FBootDelay: Cardinal;
FBootGUI: Boolean;
FBootKeys: Boolean;
FBootMenu: Boolean;
FBootMenuDefault: Cardinal;
FBootMenuDelay: Cardinal;
FBootMulti: Boolean;
FBootSafe: Boolean;
FBootWarn: Boolean;
FBootWin: Boolean;
FDBLSpace: Boolean;
FDRVSpace: Boolean;
FDoubleBuffer: Boolean;
FLoadTop: Boolean;
FLogo: Boolean;
FNetwork: Boolean;
FWinVer: string;
public
constructor Create;
destructor Destroy; override;
{ IJclMsdosSys }
function GetAutoScan: Boolean;
function GetBootDelay: Cardinal;
function GetBootGUI: Boolean;
function GetBootKeys: Boolean;
function GetBootMenu: Boolean;
function GetBootMenuDefault: Cardinal;
function GetBootMenuDelay: Cardinal;
function GetBootMulti: Boolean;
function GetBootSafe: Boolean;
function GetBootWarn: Boolean;
function GetBootWin: Boolean;
function GetDBLSpace: Boolean;
function GetDoubleBuffer: Boolean;
function GetDRVSpace: Boolean;
function GetHostWinBootDrv: Char;
function GetLoadTop: Boolean;
function GetLogo: Boolean;
function GetNetwork: Boolean;
function GetUninstallDir: Char;
function GetWinBootDir: string;
function GetWinDir: string;
function GetWinVer: string;
procedure SetUninstallDir(AUninstallDir: Char);
procedure SetWinDir(AWinDir: string);
procedure SetWinBootDir(AWinBootDir: string);
procedure SetHostWinBootDrv(AHostWinBootDrv: Char);
procedure SetAutoScan(AAutoScan: Boolean);
procedure SetBootDelay(ABootDelay: Cardinal);
procedure SetBootGUI(ABootGUI: Boolean);
procedure SetBootKeys(ABootKeys: Boolean);
procedure SetBootMenu(ABootMenu: Boolean);
procedure SetBootMenuDefault(ABootMenuDefault: Cardinal);
procedure SetBootMenuDelay(ABootMenuDelay: Cardinal);
procedure SetBootMulti(ABootMulti: Boolean);
procedure SetBootSafe(ABootSafe: Boolean);
procedure SetBootWarn(ABootWarn: Boolean);
procedure SetBootWin(ABootWin: Boolean);
procedure SetDBLSpace(ADBLSpace: Boolean);
procedure SetDRVSpace(ADRVSpace: Boolean);
procedure SetDoubleBuffer(ADoubleBuffer: Boolean);
procedure SetLoadTop(ALoadTop: Boolean);
procedure SetLogo(ALogo: Boolean);
procedure SetNetwork(ANetwork: Boolean);
procedure SetWinVer(AWinVer: string);
procedure SetBool(var ANew: Boolean; AOld: Boolean);
procedure SetString(var ANew: string; AOld: string);
procedure ReadMsdosSys;
procedure WriteMsdosSys;
property UninstallDir: Char read GetUninstallDir write SetUninstallDir;
property WinDir: string read GetWinDir write SetWinDir;
property WinBootDir: string read GetWinBootDir write SetWinBootDir;
property HostWinBootDrv: Char read GetHostWinBootDrv write SetHostWinBootDrv;
property AutoScan: Boolean read GetAutoScan write SetAutoScan;
property BootDelay: Cardinal read GetBootDelay write SetBootDelay;
property BootGUI: Boolean read GetBootGUI write SetBootGUI;
property BootKeys: Boolean read GetBootKeys write SetBootKeys;
property BootMenu: Boolean read GetBootMenu write SetBootMenu;
property BootMenuDefault: Cardinal read GetBootMenuDefault write SetBootMenuDefault;
property BootMenuDelay: Cardinal read GetBootMenuDelay write SetBootMenuDelay;
property BootMulti: Boolean read GetBootMulti write SetBootMulti;
property BootSafe: Boolean read GetBootSafe write SetBootSafe;
property BootWarn: Boolean read GetBootWarn write SetBootWarn;
property BootWin: Boolean read GetBootWin write SetBootWin;
property DBLSpace: Boolean read GetDBLSpace write SetDBLSpace;
property DRVSpace: Boolean read GetDRVSpace write SetDRVSpace;
property DoubleBuffer: Boolean read GetDoubleBuffer write SetDoubleBuffer;
property LoadTop: Boolean read GetLoadTop write SetLoadTop;
property Logo: Boolean read GetLogo write SetLogo;
property Network: Boolean read GetNetwork write SetNetwork;
property WinVer: string read GetWinVer write SetWinVer;
end;
function GetMsdosSys: IJclMsdosSys;
{$IFDEF UNITVERSIONING}
const
UnitVersioning: TUnitVersionInfo = (
RCSfile: '$URL$';
Revision: '$Revision$';
Date: '$Date$';
LogPath: 'JCL\source\windows';
Extra: '';
Data: nil
);
{$ENDIF UNITVERSIONING}
implementation
const
cMsdosSys = 'C:\MSDOS.SYS';
function GetMsdosSys: IJclMsdosSys;
begin
Result := TJclMsdosSys.Create;
end;
//=== { TJclMsdosSys } =======================================================
constructor TJclMsdosSys.Create;
begin
inherited Create;
ReadMsdosSys;
end;
destructor TJclMsdosSys.Destroy;
begin
WriteMsdosSys;
inherited Destroy;
end;
function TJclMsdosSys.GetAutoScan: Boolean;
begin
Result := FAutoScan;
end;
function TJclMsdosSys.GetBootDelay: Cardinal;
begin
Result := FBootDelay;
end;
function TJclMsdosSys.GetBootGUI: Boolean;
begin
Result := FBootGUI;
end;
function TJclMsdosSys.GetBootMenu: Boolean;
begin
Result := FBootMenu;
end;
function TJclMsdosSys.GetBootKeys: Boolean;
begin
Result := FBootKeys;
end;
function TJclMsdosSys.GetBootMenuDefault: Cardinal;
begin
Result := FBootMenuDefault;
end;
function TJclMsdosSys.GetBootMenuDelay: Cardinal;
begin
Result := FBootMenuDelay;
end;
function TJclMsdosSys.GetBootMulti: Boolean;
begin
Result := FBootMulti;
end;
function TJclMsdosSys.GetBootSafe: Boolean;
begin
Result := FBootSafe;
end;
function TJclMsdosSys.GetBootWarn: Boolean;
begin
Result := FBootWarn;
end;
function TJclMsdosSys.GetBootWin: Boolean;
begin
Result := FBootWin;
end;
function TJclMsdosSys.GetDBLSpace: Boolean;
begin
Result := FDBLSpace;
end;
function TJclMsdosSys.GetDoubleBuffer: Boolean;
begin
Result := FDoubleBuffer;
end;
function TJclMsdosSys.GetDRVSpace: Boolean;
begin
Result := FDRVSpace;
end;
function TJclMsdosSys.GetHostWinBootDrv: Char;
begin
Result := FHostWinBootDrv;
end;
function TJclMsdosSys.GetLoadTop: Boolean;
begin
Result := FLoadTop;
end;
function TJclMsdosSys.GetLogo: Boolean;
begin
Result := FLogo;
end;
function TJclMsdosSys.GetNetwork: Boolean;
begin
Result := FNetWork;
end;
function TJclMsdosSys.GetUninstallDir: Char;
begin
Result := FUninstallDir;
end;
function TJclMsdosSys.GetWinBootDir: string;
begin
Result := FWinBootDir;
end;
function TJclMsdosSys.GetWinDir: string;
begin
Result := FWinDir;
end;
function TJclMsdosSys.GetWinVer: string;
begin
Result := FWinVer;
end;
procedure TJclMsdosSys.SetUninstallDir(AUninstallDir: Char);
begin
if UninstallDir <> AUninstallDir then
begin
FUninstallDir := AUninstallDir;
WriteMsdosSys;
end;
end;
procedure TJclMsdosSys.SetWinDir(AWinDir: string);
begin
SetString(FWinDir, AWinDir);
end;
procedure TJclMsdosSys.SetWinBootDir(AWinBootDir: string);
begin
SetString(FWinBootDir, AWinBootDir);
end;
procedure TJclMsdosSys.SetHostWinBootDrv(AHostWinBootDrv: Char);
begin
if HostWinBootDrv <> AHostWinBootDrv then
begin
FHostWinBootDrv := AHostWinBootDrv;
WriteMsdosSys;
end;
end;
procedure TJclMsdosSys.SetAutoScan(AAutoScan: Boolean);
begin
SetBool(FAutoScan, AAutoScan);
end;
procedure TJclMsdosSys.SetBootDelay(ABootDelay: Cardinal);
begin
if BootDelay <> ABootDelay then
begin
FBootDelay := ABootDelay;
WriteMsdosSys;
end;
end;
procedure TJclMsdosSys.SetBootGUI(ABootGUI: Boolean);
begin
SetBool(FBootGUI, ABootGUI);
end;
procedure TJclMsdosSys.SetBootKeys(ABootKeys: Boolean);
begin
SetBool(FBootKeys, ABootKeys);
end;
procedure TJclMsdosSys.SetBootMenu(ABootMenu: Boolean);
begin
SetBool(FBootMenu, ABootMenu);
end;
procedure TJclMsdosSys.SetBootMenuDefault(ABootMenuDefault: Cardinal);
begin
if BootMenuDefault <> ABootMenuDefault then
begin
FBootMenuDefault := ABootMenuDefault;
WriteMsdosSys;
end;
end;
procedure TJclMsdosSys.SetBootMenuDelay(ABootMenuDelay: Cardinal);
begin
if BootMenuDelay <> ABootMenuDelay then
begin
FBootMenuDelay := ABootMenuDelay;
WriteMsdosSys;
end;
end;
procedure TJclMsdosSys.SetBootMulti(ABootMulti: Boolean);
begin
SetBool(FBootMulti, ABootMulti);
end;
procedure TJclMsdosSys.SetBootSafe(ABootSafe: Boolean);
begin
SetBool(FBootSafe, ABootSafe);
end;
procedure TJclMsdosSys.SetBootWarn(ABootWarn: Boolean);
begin
SetBool(FBootWarn, ABootWarn);
end;
procedure TJclMsdosSys.SetBootWin(ABootWin: Boolean);
begin
SetBool(FBootWin, ABootWin);
end;
procedure TJclMsdosSys.SetDBLSpace(ADBLSpace: Boolean);
begin
SetBool(FDBLSpace, ADBLSpace);
end;
procedure TJclMsdosSys.SetDRVSpace(ADRVSpace: Boolean);
begin
SetBool(FDRVSpace, ADRVSpace);
end;
procedure TJclMsdosSys.SetDoubleBuffer(ADoubleBuffer: Boolean);
begin
SetBool(FDoubleBuffer, ADoubleBuffer);
end;
procedure TJclMsdosSys.SetLoadTop(ALoadTop: Boolean);
begin
SetBool(FLoadTop, ALoadTop);
end;
procedure TJclMsdosSys.SetLogo(ALogo: Boolean);
begin
SetBool(FLogo, ALogo);
end;
procedure TJclMsdosSys.SetNetwork(ANetwork: Boolean);
begin
SetBool(FNetwork, ANetwork);
end;
procedure TJclMsdosSys.SetWinVer(AWinVer: string);
begin
SetString(FWinVer, AWinVer);
end;
procedure TJclMsdosSys.SetBool(var ANew: Boolean; AOld: Boolean);
begin
if ANew <> AOld then
begin
ANew := AOld;
WriteMsdosSys;
end;
end;
procedure TJclMsdosSys.SetString(var ANew: string; AOld: string);
begin
if ANew <> AOld then
begin
ANew := AOld;
WriteMsdosSys;
end;
end;
procedure TJclMsdosSys.ReadMsdosSys;
var
List: TStringList;
Value: string;
function BoolVal(const Name: string; const Def: Boolean): Boolean;
var
Val: string;
begin
Result := Def;
Val := Trim(List.Values[Name]);
if Val <> '' then
if Val[1] = '0' then
Result := False
else
if Val[1] = '1' then
Result := True;
end;
begin
FUninstallDir := #0;
FHostWinBootDrv := #0;
List := TStringList.Create;
try
List.LoadFromFile(cMsDosSys);
Value := Trim(List.Values['UninstallDir']);
if Value <> '' then
FUninstallDir := Value[1];
FWinDir := Trim(List.Values['WinDir']);
FWinBootDir := Trim(List.Values['WinBootDir']);
Value := Trim(List.Values['HostWinBootDrv']);
if Value <> '' then
FHostWinBootDrv := Value[1];
FAutoScan := BoolVal('AutoScan', True);
FBootDelay := StrToIntDef(Trim(List.Values['BootDelay']), 2);
FBootGUI := BoolVal('BootGUI', True);
FBootKeys := BoolVal('BootKeys', True);
FBootMenu := BoolVal('BootMenu', False);
FBootMenuDefault := StrToIntDef(Trim(List.Values['BootMenuDefault']), 1);
FBootMenuDelay := StrToIntDef(Trim(List.Values['BootMenuDelay']), 30);
FBootMulti := BoolVal('BootMulti', False);
FBootSafe := BoolVal('BootSafe', False);
FBootWarn := BoolVal('BootWarn', True);
FBootWin := BoolVal('BootWin', True);
FDBLSpace := BoolVal('DBLSpace', True);
FDRVSpace := BoolVal('DRVSpace', True);
FDoubleBuffer := BoolVal('DoubleBuffer', False);
FLoadTop := BoolVal('LoadTop', True);
FLogo := BoolVal('Logo', True);
FNetwork := BoolVal('Network', False);
FWinVer := Trim(List.Values['WinVer']);
finally
List.Free;
end;
end;
procedure TJclMsdosSys.WriteMsdosSys;
var
Attributes: Integer;
I: Char;
Line: string;
begin
if not FileExists(cMsDosSys) then
Exit;
with TStringList.Create do
try
Add('[Paths]');
if UninstallDir <> #0 then
Add('UninstallDir=' + UninstallDir);
if WinDir <> '' then
Add('WinDir=' + WinDir);
if WinBootDir <> '' then
Add('WinBootDir=' + WinBootDir);
if HostWinBootDrv <> #0 then
Add('HostWinBootDrv=' + HostWinBootDrv);
Add('');
Add('[Options]');
if not AutoScan then
Add('AutoScan=0');
if BootDelay <> 2 then
Add('BootDelay=' + IntToStr(BootDelay));
if not BootGUI then
Add('BootGUI=0');
if not BootKeys then
Add('BootKeys=0');
if BootMenu then
Add('BootMenu=1');
if BootMenuDefault <> 1 then
Add('BootMenuDefault=' + IntToStr(BootMenuDefault));
if BootMenuDelay <> 30 then
Add('BootMenuDelay=' + IntToStr(BootMenuDelay));
if BootMulti then
Add('BootMulti=1');
if BootSafe then
Add('BootSafe=1');
if not BootWarn then
Add('BootWarn=0');
if not BootWin then
Add('BootWin=0');
if not DBLSpace then
Add('DBLSpace=0');
if not DRVSpace then
Add('DRVSpace=0');
if DoubleBuffer then
Add('DoubleBuffer=1');
if not LoadTop then
Add('LoadTop=0');
if not Logo then
Add('Logo=0');
if Network then
Add('Network=1');
if WinVer <> '' then
Add('WinVer=' + WinVer);
Add(';');
Add(';The following lines are required for compatibility with other programs.');
Add(';Do not remove them(MSDOS.SYS needs to be >1024 bytes).');
Line := ';' + StringOfChar('x', 69);
for I := 'a' to 's' do
Add(Line+I);
Attributes := FileGetAttr(cMsDosSys) and not faReadOnly;
FileSetAttr(cMsDosSys, Attributes);
SaveToFile(cMsDosSys);
FileSetAttr(cMsDosSys, Attributes or faReadOnly);
finally
Free;
end;
end;
{$IFDEF UNITVERSIONING}
initialization
RegisterUnitVersion(HInstance, UnitVersioning);
finalization
UnregisterUnitVersion(HInstance);
{$ENDIF UNITVERSIONING}
end.
| 31.031627 | 100 | 0.656976 |
47e313fe847b3d89ca5eaba4b6e40f17a3c1b22e | 2,283 | pas | Pascal | Catalogos/PrestamosDM.pas | alexismzt/SOFOM | 57ca73e9f7fbb51521149ea7c0fdc409c22cc6f7 | [
"Apache-2.0"
]
| null | null | null | Catalogos/PrestamosDM.pas | alexismzt/SOFOM | 57ca73e9f7fbb51521149ea7c0fdc409c22cc6f7 | [
"Apache-2.0"
]
| 51 | 2018-07-25T15:39:25.000Z | 2021-04-21T17:40:57.000Z | Catalogos/PrestamosDM.pas | alexismzt/SOFOM | 57ca73e9f7fbb51521149ea7c0fdc409c22cc6f7 | [
"Apache-2.0"
]
| 1 | 2021-02-23T17:27:06.000Z | 2021-02-23T17:27:06.000Z | unit PrestamosDM;
interface
uses
System.SysUtils, System.Classes, _StandarDMod, Data.DB, System.Actions,
Vcl.ActnList, Data.Win.ADODB;
type
TdmPrestamos = class(T_dmStandar)
adodsMasterIdPrestamo: TAutoIncField;
adodsMasterIdPersona: TIntegerField;
adodsMasterImporte: TFMTBCDField;
adodsMasterFecha: TDateTimeField;
adodsMasterPorcentaje: TFMTBCDField;
adodsMasterSaldo: TFMTBCDField;
adodsPersonas: TADODataSet;
adodsMasterPersona: TStringField;
dsMaster: TDataSource;
adodsPrestamosPago: TADODataSet;
adodsPrestamosPagoIdPrestamoPago: TAutoIncField;
adodsPrestamosPagoIdPrestamo: TIntegerField;
adodsPrestamosPagoIdMovimiento: TIntegerField;
adodsPrestamosPagoIdPersona: TIntegerField;
adodsPrestamosPagoIdPeriodo: TIntegerField;
adodsPrestamosPagoIdMovimientoTipo: TIntegerField;
adodsPrestamosPagoImporteCalculo: TFMTBCDField;
adodsPrestamosPagoPorcentaje: TFMTBCDField;
adodsPrestamosPagoImportePeriodo: TFMTBCDField;
adodsPrestamosPagoImportePago: TFMTBCDField;
adodsMovimientoTipo: TADODataSet;
adodsPersonasPago: TADODataSet;
adodsPrestamosPagoMovimientoTipo: TStringField;
adodsPrestamosPagoPersona: TStringField;
adodsPeriodo: TADODataSet;
adodsPrestamosPagoPeriodo: TStringField;
adopUpdPrestamosSaldo: TADOStoredProc;
procedure DataModuleCreate(Sender: TObject);
procedure adodsMasterAfterPost(DataSet: TDataSet);
private
{ Private declarations }
public
{ Public declarations }
end;
implementation
{%CLASSGROUP 'Vcl.Controls.TControl'}
uses PrestamosForm, PrestamosPagoForm;
{$R *.dfm}
procedure TdmPrestamos.adodsMasterAfterPost(DataSet: TDataSet);
begin
inherited;
adopUpdPrestamosSaldo.Parameters.ParamByName('@IdPrestamo').Value:= adodsMasterIdPrestamo.Value;
adopUpdPrestamosSaldo.ExecProc;
adodsMaster.Refresh;
end;
procedure TdmPrestamos.DataModuleCreate(Sender: TObject);
begin
inherited;
adodsPrestamosPago.Open;
gGridForm:= TfrmPrestamos.Create(Self);
gGridForm.DataSet:= adodsMaster;
gFormDeatil1:= TfrmPrestamosPago.Create(Self);
gFormDeatil1.ReadOnlyGrid:= True;
gFormDeatil1.DataSet:= adodsPrestamosPago;
end;
end.
| 30.851351 | 99 | 0.772668 |
fc32c21a8360b4a514aa9ad5a8e4b5bc5bc32f15 | 3,747 | pas | Pascal | source/uWVCoreWebView2CookieManager.pas | e-files/WebView4Delphi | 01dade7a01a1d8b5c1b0ad131e237f18f8e650b5 | [
"MIT"
]
| 99 | 2021-12-03T22:21:56.000Z | 2022-03-26T20:19:23.000Z | source/uWVCoreWebView2CookieManager.pas | flexifi/WebView4Delphi | 6a0169aa0e8c0280f93ec7f874abe95e38dd9e5a | [
"MIT"
]
| 20 | 2021-12-04T10:12:45.000Z | 2022-03-01T09:37:51.000Z | source/uWVCoreWebView2CookieManager.pas | flexifi/WebView4Delphi | 6a0169aa0e8c0280f93ec7f874abe95e38dd9e5a | [
"MIT"
]
| 17 | 2021-12-04T09:32:31.000Z | 2022-03-24T15:15:44.000Z | unit uWVCoreWebView2CookieManager;
{$IFDEF FPC}{$MODE Delphi}{$ENDIF}
interface
uses
uWVTypeLibrary, uWVTypes;
type
TCoreWebView2CookieManager = class
protected
FBaseIntf : ICoreWebView2CookieManager;
function GetInitialized : boolean;
public
constructor Create(const aBaseIntf : ICoreWebView2CookieManager); reintroduce;
destructor Destroy; override;
function CreateCookie(const aName, aValue, aDomain, aPath: wvstring) : ICoreWebView2Cookie;
function CopyCookie(const aCookie : ICoreWebView2Cookie) : ICoreWebView2Cookie;
function GetCookies(const aURI : wvstring; const aHandler: ICoreWebView2GetCookiesCompletedHandler): boolean;
function AddOrUpdateCookie(const aCookie : ICoreWebView2Cookie): boolean;
function DeleteCookie(const aCookie : ICoreWebView2Cookie): boolean;
function DeleteCookies(const aName, aURI : wvstring): boolean;
function DeleteCookiesWithDomainAndPath(const aName, aDomain, aPath : wvstring): boolean;
function DeleteAllCookies : boolean;
property Initialized : boolean read GetInitialized;
property BaseIntf : ICoreWebView2CookieManager read FBaseIntf;
end;
implementation
uses
{$IFDEF FPC}
ActiveX;
{$ELSE}
Winapi.ActiveX;
{$ENDIF}
constructor TCoreWebView2CookieManager.Create(const aBaseIntf: ICoreWebView2CookieManager);
begin
inherited Create;
FBaseIntf := aBaseIntf;
end;
destructor TCoreWebView2CookieManager.Destroy;
begin
FBaseIntf := nil;
inherited Destroy;
end;
function TCoreWebView2CookieManager.GetInitialized : boolean;
begin
Result := assigned(FBaseIntf);
end;
function TCoreWebView2CookieManager.CreateCookie(const aName, aValue, aDomain, aPath: wvstring) : ICoreWebView2Cookie;
var
TempResult : ICoreWebView2Cookie;
begin
Result := nil;
TempResult := nil;
if Initialized and
succeeded(FBaseIntf.CreateCookie(PWideChar(aName), PWideChar(aValue), PWideChar(aDomain), PWideChar(aPath), TempResult)) and
(TempResult <> nil) then
Result := TempResult;
end;
function TCoreWebView2CookieManager.CopyCookie(const aCookie : ICoreWebView2Cookie) : ICoreWebView2Cookie;
var
TempResult : ICoreWebView2Cookie;
begin
Result := nil;
TempResult := nil;
if Initialized and
succeeded(FBaseIntf.CopyCookie(aCookie, TempResult)) and
(TempResult <> nil) then
Result := TempResult;
end;
function TCoreWebView2CookieManager.GetCookies(const aURI : wvstring; const aHandler: ICoreWebView2GetCookiesCompletedHandler) : boolean;
begin
Result := Initialized and
succeeded(FBaseIntf.GetCookies(PWideChar(aURI), aHandler));
end;
function TCoreWebView2CookieManager.AddOrUpdateCookie(const aCookie : ICoreWebView2Cookie): boolean;
begin
Result := Initialized and
succeeded(FBaseIntf.AddOrUpdateCookie(aCookie));
end;
function TCoreWebView2CookieManager.DeleteCookie(const aCookie : ICoreWebView2Cookie): boolean;
begin
Result := Initialized and
succeeded(FBaseIntf.DeleteCookie(aCookie));
end;
function TCoreWebView2CookieManager.DeleteCookies(const aName, aURI : wvstring): boolean;
begin
Result := Initialized and
succeeded(FBaseIntf.DeleteCookies(PWideChar(aName), PWideChar(aURI)));
end;
function TCoreWebView2CookieManager.DeleteCookiesWithDomainAndPath(const aName, aDomain, aPath : wvstring): boolean;
begin
Result := Initialized and
succeeded(FBaseIntf.DeleteCookiesWithDomainAndPath(PWideChar(aName), PWideChar(aDomain), PWideChar(aPath)));
end;
function TCoreWebView2CookieManager.DeleteAllCookies : boolean;
begin
Result := Initialized and
succeeded(FBaseIntf.DeleteAllCookies);
end;
end.
| 29.976 | 137 | 0.756338 |
4757c680f1fe6a4318282cd2be91f0184252a2d5 | 7,978 | pas | Pascal | Neoprogrammer/scripts/read_write_95xxx_example.pas | mamut-tme/UsbAsp-flash_89S52 | 204341688e8f2953579ebaeea4a910c9b2367285 | [
"MIT"
]
| 1 | 2020-09-27T15:53:36.000Z | 2020-09-27T15:53:36.000Z | Neoprogrammer/scripts/read_write_95xxx_example.pas | mamut-tme/UsbAsp-flash_89S52 | 204341688e8f2953579ebaeea4a910c9b2367285 | [
"MIT"
]
| null | null | null | Neoprogrammer/scripts/read_write_95xxx_example.pas | mamut-tme/UsbAsp-flash_89S52 | 204341688e8f2953579ebaeea4a910c9b2367285 | [
"MIT"
]
| null | null | null | // read_write_95xxx_example.pas
// EEPROM 95xxx example of read & write
// useless, working script just for learning purpose
// READ_MEMORY_IN_ARRAY must be done in assocation with uch_95040_test.bin
cvx
{$ READ_MEMORY}
begin
if _IC_Name = '' then
begin
ShowMessage ('Choose a component in list');
exit;
end;
buff:= CreateByteArray(4); // create an array of 4 bytes
if not SPIEnterProgMode(_SPI_SPEED_MAX) then LogPrint('Error setting SPI speed'); // mandatory programmer initialisation
LogPrint ('Start read memory'); // blablabla
//ChipSize := 512; // size of memory in byte (manual)
ChipSize := _IC_Size; // to recover the size of the chip declared in the application.
// addressing for 8, 16, 24 bit mode
SetArrayItem(buff, 0, $03); // $03 read EEprom opcode
SetArrayItem(buff, 1, 0); // equivalent of buff[1]:= Addr in pure pascal
SetArrayItem(buff, 2, 0);
SetArrayItem(buff, 3, 0);
len := 2; // length value depends of addressing mode
// 2 for 8bit mode, 3 for 16 bit, 4 for 24 bit
if (ChipSize > 512) and (ChipSize <= 65536) then len := 3;
if (ChipSize > 65536) then len := 4;
SPIWrite(0, len, buff); // send the read command to the chip, 0 is the state of Chip select (CS) at the end of the command
SPIReadToEditor (1, ChipSize); // then, read the content of memory and put values in the editor, (CS) high and the end
LogPrint ('End read memory');
SPIExitProgMode (); // close programmer
end
{$ READ_MEMORY_IN_ARRAY}
begin
if _IC_Name = '' then
begin
ShowMessage ('Choose a component in list');
exit;
end;
buff:= CreateByteArray(4);
if not SPIEnterProgMode(_SPI_SPEED_MAX) then LogPrint('Error setting SPI speed');
LogPrint ('Start read memory');
//ChipSize := 512; // size of memory in byte (manual)
ChipSize := _IC_Size; // to recover the size of the chip declared in the application.
ReadArray:= CreateByteArray(ChipSize); // create an array of chipsize bytes
ASCIItable:= CreateStringArray(128);
// addressing for 8, 16, 24 bit mode
SetArrayItem(buff, 0, $03); // $03 read EEprom opcode
SetArrayItem(buff, 1, 0); // equivalent of buff[1]:= Addr in pure pascal
SetArrayItem(buff, 2, 0);
SetArrayItem(buff, 3, 0);
len := 2; // length value depends of addressing mode
// 2 for 8bit mode, 3 for 16 bit, 4 for 24 bit
if (ChipSize > 512) and (ChipSize <= 65536) then len := 3;
if (ChipSize > 65536) then len := 4;;
SPIWrite(0, len, buff);
// read the content of memory and put values in an array
SPIRead(1, ChipSize, ReadArray);
// build ASCII table 0..9, A..Z (upcases)
for i:= 0 to 127 do
begin
SetArrayItem(ASCIItable, i, ' '); // initialise the table with spaces
end;
for i:= $30 to $39 do
begin
SetArrayItem(ASCIItable, i, inttostr(i-$30));
end;
i:=$40;
inc (i);SetArrayItem(ASCIItable, i, 'A');
inc (i);SetArrayItem(ASCIItable, i, 'B');
inc (i);SetArrayItem(ASCIItable, i, 'C');
inc (i);SetArrayItem(ASCIItable, i, 'D');
inc (i);SetArrayItem(ASCIItable, i, 'E');
inc (i);SetArrayItem(ASCIItable, i, 'F');
inc (i);SetArrayItem(ASCIItable, i, 'G');
inc (i);SetArrayItem(ASCIItable, i, 'H');
inc (i);SetArrayItem(ASCIItable, i, 'I');
inc (i);SetArrayItem(ASCIItable, i, 'J');
inc (i);SetArrayItem(ASCIItable, i, 'K');
inc (i);SetArrayItem(ASCIItable, i, 'L');
inc (i);SetArrayItem(ASCIItable, i, 'M');
inc (i);SetArrayItem(ASCIItable, i, 'N');
inc (i);SetArrayItem(ASCIItable, i, 'O');
inc (i);SetArrayItem(ASCIItable, i, 'P');
inc (i);SetArrayItem(ASCIItable, i, 'Q');
inc (i);SetArrayItem(ASCIItable, i, 'R');
inc (i);SetArrayItem(ASCIItable, i, 'S');
inc (i);SetArrayItem(ASCIItable, i, 'T');
inc (i);SetArrayItem(ASCIItable, i, 'U');
inc (i);SetArrayItem(ASCIItable, i, 'V');
inc (i);SetArrayItem(ASCIItable, i, 'W');
inc (i);SetArrayItem(ASCIItable, i, 'X');
inc (i);SetArrayItem(ASCIItable, i, 'Y');
inc (i);SetArrayItem(ASCIItable, i, 'Z');
s0:='';
// build VIN number
for i:= $1AD to $1BD do
begin
s0:= s0 + GetArrayItem(ASCIItable, (GetArrayItem(ReadArray, i)));
end;
s0:= 'VIN = ' + s0;
logprint(s0);
s1:='';
// build ISK number
for i:= $13A to $13F do
begin
GetArrayItem(ReadArray, i);
s1:= s1 + inttohex(GetArrayItem(ReadArray, i),2) + ' ';
end;
s1:= 'ISK = ' + s1;
logprint(s1);
// PIN value to be calculated by appropriate algorithm
s2:= 'PIN = ' + 'FF FF FF FF FF FF';
// ShowMessage multiligne workaround
// '\n' string is used as a separator and will be replaced by CR LF at display
ShowMessage(s0+'\n'+s1+'\n'+s2);
LogPrint ('End read memory');
SPIExitProgMode ();
end
{$ WRITE_MEMORY}
begin
if _IC_Name = '' then
begin
ShowMessage ('Choose a component in list');
exit;
end;
buff:= CreateByteArray(4);
if not SPIEnterProgMode(_SPI_SPEED_MAX) then LogPrint('Error setting SPI speed');
LogPrint ('Start write memory');
//ChipSize := 512; // size of memory in byte (manual)
ChipSize := _IC_Size; // to recover the size of the chip declared in the application.
//PageSize := 16; // size of page (see 95040 datasheet)
PageSize := _IC_Page; // to recover the page size of the chip declared in the application.
Addr:= 0;
sreg :=0;
// show progress bar for the fun
ProgressBar(0, (ChipSize / PageSize)-1, 0);
// write (more complex than read)
// writing must be done by chunks equal to page size
// and addressing is depending of the chip particularities (see datasheet)
// beginning of writing loop by chunks equal to pagesize value)
while Addr < ChipSize do
begin
// adapted from spi95.pas in asprogrammer source repository
// https://github.com/nofeletru/UsbAsp-flash/tree/test
// M35080, ST95P08 are excluded
if ChipSize < 512 then
begin
SetArrayItem(buff, 0, $02);
SetArrayItem(buff, 1, Addr);
len := 2;
end;
// For 95040, when A8=1, Bit3 of intruction byte must be set
if ChipSize = 512 then
begin
if Addr < 256 then //A8=0
begin
SetArrayItem(buff, 0, $02); // $02 write EEprom opcode
SetArrayItem(buff, 1, Addr);
end;
if Addr > 255 then //A8=1
begin
SetArrayItem(buff, 0, ($02 or $8)); // set Bit3 of intruction byte
SetArrayItem(buff, 1, Addr-256);
end;
len := 2;
end;
if (ChipSize > 512) and (ChipSize <= 65536) then // 16-bit Address range
begin // 2 bytes
SetArrayItem(buff, 0, $02);
SetArrayItem(buff, 1, (addr shr 8));
SetArrayItem(buff, 2, (addr));
len := 3;
end;
if (ChipSize > 65536) then // 24-bit Address range
begin // 3 bytes
SetArrayItem(buff, 0, $02);
SetArrayItem(buff, 1, (addr shr 16));
SetArrayItem(buff, 2, (addr shr 8));
SetArrayItem(buff, 3, (addr));
len := 4;
end;
// write enable (see datasheet)
SPIWrite (1, 1, $06);
// send the write command to the chip
SPIWrite(0, len, buff);
// then, write the content of the editor at specified address
//SPIWriteFromEditor(cs, size, position)
SPIWriteFromEditor(1, PageSize, Addr);
// wait if busy
//(see datasheet)
repeat
SPIWrite(0, 1, $05);
SPIRead(1, 1, sreg);
until((sreg and 1) <> 1);
Inc(Addr, PageSize); // next chunk
// inc progress bar of 1 step
progressBar(1);
end;
LogPrint('End write memory');
// write disable
SPIWrite (1, 1, $04);
// reset progress bar
ProgressBar(0, 0, 0);
// close programmer
SPIExitProgMode ();
end
| 32.966942 | 125 | 0.609175 |
fc133197694d88dc87cb0dd9581b306b5406fe3a | 403 | pas | Pascal | files/lib/ModbusLib/Archiver/MBArchiverResStrings.pas | krab22/modbusemu | 30bd0b80602a87a26ba521b6160e788143f37c08 | [
"BSD-2-Clause"
]
| 1 | 2021-06-24T13:09:19.000Z | 2021-06-24T13:09:19.000Z | files/lib/ModbusLib/Archiver/MBArchiverResStrings.pas | krab22/modbusemu | 30bd0b80602a87a26ba521b6160e788143f37c08 | [
"BSD-2-Clause"
]
| null | null | null | files/lib/ModbusLib/Archiver/MBArchiverResStrings.pas | krab22/modbusemu | 30bd0b80602a87a26ba521b6160e788143f37c08 | [
"BSD-2-Clause"
]
| 1 | 2020-06-30T09:55:31.000Z | 2020-06-30T09:55:31.000Z | unit MBArchiverResStrings;
{$mode objfpc}{$H+}
interface
resourcestring
rsArchiver = 'Архиватор';
rsArchErrorCreateFile = 'Ошибка создания файла архива: %s';
rsArchErrorOpenFile = 'Ошибка открытия файла архива: %s';
rsArchFileOpen = 'Открыт файл: %s';
rsArchFileClose = 'Закрыт архив. Размер файла: %d';
rsArchTimeCaption = 'Время';
implementation
end.
| 19.190476 | 61 | 0.672457 |
f1925818c0267a18f401362656a872e4efc1625d | 1,403 | dfm | Pascal | Tools/PascalUnitRewriteTool/PascalRewrite_TextEdtFrm.dfm | PassByYou888/ZNet | 8f5439ec275ee4eb5d68e00c33675e6117379fcf | [
"BSD-3-Clause"
]
| 24 | 2022-01-20T13:59:38.000Z | 2022-03-25T01:11:43.000Z | Tools/PascalUnitRewriteTool/PascalRewrite_TextEdtFrm.dfm | lovong/ZNet | ad67382654ea1979c316c2dc9716fd6d8509f028 | [
"BSD-3-Clause"
]
| null | null | null | Tools/PascalUnitRewriteTool/PascalRewrite_TextEdtFrm.dfm | lovong/ZNet | ad67382654ea1979c316c2dc9716fd6d8509f028 | [
"BSD-3-Clause"
]
| 5 | 2022-01-20T14:44:24.000Z | 2022-02-13T10:07:38.000Z | object PascalRewrite_TextEdtForm: TPascalRewrite_TextEdtForm
Left = 0
Top = 0
Caption = 'Text Editor.'
ClientHeight = 426
ClientWidth = 839
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
KeyPreview = True
OldCreateOrder = False
PopupMode = pmExplicit
PopupParent = PascalRewriteModelForm.Owner
Position = poMainFormCenter
OnClose = FormClose
OnKeyUp = FormKeyUp
PixelsPerInch = 96
TextHeight = 13
object _b_Panel: TPanel
Left = 0
Top = 380
Width = 839
Height = 46
Align = alBottom
BevelOuter = bvNone
TabOrder = 0
object DoneButton: TButton
Left = 14
Top = 6
Width = 106
Height = 33
Caption = '&Done'
ModalResult = 1
TabOrder = 0
end
object cancelButton: TButton
Left = 126
Top = 6
Width = 106
Height = 33
Caption = '&Cancel'
ModalResult = 2
TabOrder = 1
end
end
object Memo: TMemo
Left = 0
Top = 0
Width = 839
Height = 380
Align = alClient
DoubleBuffered = True
Font.Charset = ANSI_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Consolas'
Font.Style = []
ParentDoubleBuffered = False
ParentFont = False
ScrollBars = ssBoth
TabOrder = 1
WordWrap = False
end
end
| 20.632353 | 60 | 0.626515 |
f1d4b033266ea0da9200aece25bbc6d3b49f7349 | 1,894 | pas | Pascal | About.pas | tukotech/wrdp | e8f5cd18438aceeeec03a8115a1bd8a962feb4e2 | [
"MIT"
]
| 1 | 2021-11-02T17:13:53.000Z | 2021-11-02T17:13:53.000Z | About.pas | tukotech/wrdp | e8f5cd18438aceeeec03a8115a1bd8a962feb4e2 | [
"MIT"
]
| 19 | 2021-07-23T02:49:13.000Z | 2021-09-05T04:25:59.000Z | About.pas | tukotech/wrdp | e8f5cd18438aceeeec03a8115a1bd8a962feb4e2 | [
"MIT"
]
| 1 | 2021-08-09T16:01:25.000Z | 2021-08-09T16:01:25.000Z | unit About;
interface
uses
inifiles,
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TFormAbout = class(TForm)
Button1: TButton;
Label1: TLabel;
LabelDedication: TLabel;
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
FormAbout: TFormAbout;
implementation
{$R *.dfm}
function GetFileVersion(exeName : string): string;
const
c_StringInfo = 'StringFileInfo\040904E4\FileVersion';
var
n, Len : cardinal;
Buf, Value : PChar;
begin
Result := '';
n := GetFileVersionInfoSize(PChar(exeName),n);
if n > 0 then begin
Buf := AllocMem(n);
try
GetFileVersionInfo(PChar(exeName),0,n,Buf);
if VerQueryValue(Buf,PChar(c_StringInfo),Pointer(Value),Len) then begin
Result := Trim(Value);
end;
finally
FreeMem(Buf,n);
end;
end;
end;
procedure TFormAbout.FormClose(Sender: TObject; var Action: TCloseAction);
var
Ini : TIniFile;
begin
Ini := TIniFile.Create( ChangeFileExt( Application.ExeName, '.INI' ) );
try
Ini.WriteInteger('FormAbout','Top', self.Top);
Ini.WriteInteger('FormAbout','Left', self.Left);
Ini.WriteInteger('FormAbout','Width', self.Width);
finally
Ini.Free;
end;
end;
procedure TFormAbout.FormCreate(Sender: TObject);
var
Ini : TIniFile;
begin
Ini := TIniFile.Create( ChangeFileExt( Application.ExeName, '.INI' ) );
try
self.Top := Ini.ReadInteger( 'FormAbout', 'Top', 0);
self.Left := Ini.ReadInteger( 'FormAbout', 'Left', 0);
self.Width := Ini.ReadInteger( 'FormAbout', 'Width', 300);
finally
Ini.Free;
end;
self.Caption := self.Caption + ' v:' + GetFileVersion(ParamStr(0));
end;
end.
| 22.547619 | 98 | 0.679514 |
fc5fb4ccc6e32fcc4440cf82cb2d4513e02b78cf | 2,115 | pas | Pascal | Source/Services/SimpleEmail/Base/Model/AWS.SES.Model.DeleteIdentityPolicyRequest.pas | herux/aws-sdk-delphi | 4ef36e5bfc536b1d9426f78095d8fda887f390b5 | [
"Apache-2.0"
]
| 67 | 2021-07-28T23:47:09.000Z | 2022-03-15T11:48:35.000Z | Source/Services/SimpleEmail/Base/Model/AWS.SES.Model.DeleteIdentityPolicyRequest.pas | gabrielbaltazar/aws-sdk-delphi | ea1713b227a49cbbc5a2e1bf04cbf2de1f9b611a | [
"Apache-2.0"
]
| 5 | 2021-09-01T09:31:16.000Z | 2022-03-16T18:19:21.000Z | Source/Services/SimpleEmail/Base/Model/AWS.SES.Model.DeleteIdentityPolicyRequest.pas | gabrielbaltazar/aws-sdk-delphi | ea1713b227a49cbbc5a2e1bf04cbf2de1f9b611a | [
"Apache-2.0"
]
| 13 | 2021-07-29T02:41:16.000Z | 2022-03-16T10:22:38.000Z | unit AWS.SES.Model.DeleteIdentityPolicyRequest;
interface
uses
Bcl.Types.Nullable,
AWS.SES.Model.Request;
type
TDeleteIdentityPolicyRequest = class;
IDeleteIdentityPolicyRequest = interface
function GetIdentity: string;
procedure SetIdentity(const Value: string);
function GetPolicyName: string;
procedure SetPolicyName(const Value: string);
function Obj: TDeleteIdentityPolicyRequest;
function IsSetIdentity: Boolean;
function IsSetPolicyName: Boolean;
property Identity: string read GetIdentity write SetIdentity;
property PolicyName: string read GetPolicyName write SetPolicyName;
end;
TDeleteIdentityPolicyRequest = class(TAmazonSimpleEmailServiceRequest, IDeleteIdentityPolicyRequest)
strict private
FIdentity: Nullable<string>;
FPolicyName: Nullable<string>;
function GetIdentity: string;
procedure SetIdentity(const Value: string);
function GetPolicyName: string;
procedure SetPolicyName(const Value: string);
strict protected
function Obj: TDeleteIdentityPolicyRequest;
public
function IsSetIdentity: Boolean;
function IsSetPolicyName: Boolean;
property Identity: string read GetIdentity write SetIdentity;
property PolicyName: string read GetPolicyName write SetPolicyName;
end;
implementation
{ TDeleteIdentityPolicyRequest }
function TDeleteIdentityPolicyRequest.Obj: TDeleteIdentityPolicyRequest;
begin
Result := Self;
end;
function TDeleteIdentityPolicyRequest.GetIdentity: string;
begin
Result := FIdentity.ValueOrDefault;
end;
procedure TDeleteIdentityPolicyRequest.SetIdentity(const Value: string);
begin
FIdentity := Value;
end;
function TDeleteIdentityPolicyRequest.IsSetIdentity: Boolean;
begin
Result := FIdentity.HasValue;
end;
function TDeleteIdentityPolicyRequest.GetPolicyName: string;
begin
Result := FPolicyName.ValueOrDefault;
end;
procedure TDeleteIdentityPolicyRequest.SetPolicyName(const Value: string);
begin
FPolicyName := Value;
end;
function TDeleteIdentityPolicyRequest.IsSetPolicyName: Boolean;
begin
Result := FPolicyName.HasValue;
end;
end.
| 26.111111 | 102 | 0.795272 |
478aaeeb1ec7038e94d5f15cfd0b7289f3e8933b | 4,030 | pas | Pascal | Native/Delphi/Apps/XML/XokumXmlDemo/src/XmlDataBindingFormUnit.pas | jpluimers/bo.codeplex | 787ef3b5a8c6ced0a985361243c48a6c76f5d655 | [
"BSD-3-Clause"
]
| 5 | 2017-05-12T08:03:54.000Z | 2022-02-15T08:23:27.000Z | Native/Delphi/Apps/XML/XokumXmlDemo/src/XmlDataBindingFormUnit.pas | jpluimers/bo.codeplex | 787ef3b5a8c6ced0a985361243c48a6c76f5d655 | [
"BSD-3-Clause"
]
| null | null | null | Native/Delphi/Apps/XML/XokumXmlDemo/src/XmlDataBindingFormUnit.pas | jpluimers/bo.codeplex | 787ef3b5a8c6ced0a985361243c48a6c76f5d655 | [
"BSD-3-Clause"
]
| null | null | null | unit XmlDataBindingFormUnit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, LoggerUnit, ReportersUnit, xokumDataBindingUnit,
ReporterUnit, LoggerInterfaceUnit;
type
TXokumDataBindingForm = class(TForm)
AbonneenummerLabeledEdit: TLabeledEdit;
AchternaamLabeledEdit: TLabeledEdit;
AddSubscriberButton: TButton;
LoadXokumXmlButton: TButton;
LogMemo: TMemo;
NummerLabeledEdit: TLabeledEdit;
Panel1: TPanel;
StraatLabeledEdit: TLabeledEdit;
VoorlettersLabeledEdit: TLabeledEdit;
procedure AddSubscriberButtonClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure LoadXokumXmlButtonClick(Sender: TObject);
strict private
FLogger: ILogger;
FStringsReporter: IReporter;
strict protected
function LoadXokumXml: IXMLXokum; virtual;
procedure LogXokum(xokum: IXMLXokum); virtual;
public
function BuildDataFileName(const BaseFileName: string): string;
property Logger: ILogger read FLogger;
end;
var
XokumDataBindingForm: TXokumDataBindingForm;
implementation
uses
XMLDoc, XMLIntf, ReportingLoggerUnit;
{$R *.dfm}
procedure TXokumDataBindingForm.AddSubscriberButtonClick(Sender: TObject);
var
Netnummer: Integer;
xokum: IXMLXokum;
newXokumRecord: IXMLRecord_;
Plaats: string;
xokumDocument: IXMLDocument;
begin
xokum := LoadXokumXml();
Plaats := xokum[0].Plaats;
Netnummer := xokum[0].Netnummer;
xokum := xokumDataBindingUnit.Newxokum;
newXokumRecord := xokum.Add;
newXokumRecord.Achternaam := AchternaamLabeledEdit.Text;
newXokumRecord.Voorletters := VoorlettersLabeledEdit.Text;
newXokumRecord.Straat := StraatLabeledEdit.Text;
newXokumRecord.Nummer := StrToInt(NummerLabeledEdit.Text);
newXokumRecord.Abonneenummer := StrToInt(AbonneenummerLabeledEdit.Text);
newXokumRecord.Plaats := Plaats;
newXokumRecord.Netnummer := Netnummer;
xokumDocument := xokum.OwnerDocument;
xokumDocument.SaveToFile(BuildDataFileName('xokum.addedrecord.xml'));
LogXokum(xokum);
end;
function TXokumDataBindingForm.BuildDataFileName(const BaseFileName: string): string;
begin
Result := '..\..\..\data\' + BaseFileName;
end;
procedure TXokumDataBindingForm.FormCreate(Sender: TObject);
var
Strings: TStrings;
begin
Strings := LogMemo.Lines;
Strings.Clear();
FStringsReporter := TStringsReporter.Create(Strings);
FLogger := TReportingLogger.Create(FStringsReporter);
end;
procedure TXokumDataBindingForm.FormDestroy(Sender: TObject);
begin
FLogger := nil;
FStringsReporter := nil;
end;
function TXokumDataBindingForm.LoadXokumXml: IXMLXokum;
begin
Result := xokumDataBindingUnit.Loadxokum(BuildDataFileName('xokum.xml'));
end;
procedure TXokumDataBindingForm.LoadXokumXmlButtonClick(Sender: TObject);
var
xokum: IXMLXokum;
begin
xokum := LoadXokumXml();
LogXokum(xokum);
end;
procedure TXokumDataBindingForm.LogXokum(xokum: IXMLXokum);
var
xokumRecord: IXMLRecord_;
xokumCount: Integer;
xokumIndex: Integer;
begin
xokumCount := xokum.Count;
Logger.Log('xokum.Count', xokumCount);
for xokumIndex := 0 to XokumCount - 1 do
begin
xokumRecord := xokum[xokumIndex];
Logger.Log('');
Logger.Log('Achternaam', xokumIndex, xokumRecord.Achternaam);
Logger.Log('Voorletters', xokumIndex, xokumRecord.Voorletters);
Logger.Log('Straat', xokumIndex, xokumRecord.Straat);
if not VarIsNull(xokumRecord.ChildNodes['nummer'].NodeValue) then
Logger.Log('Nummer', xokumIndex, xokumRecord.Nummer);
Logger.Log('Abonneenummer', xokumIndex, xokumRecord.Abonneenummer);
Logger.Log('Plaats', xokumIndex, xokumRecord.Plaats);
if not VarIsNull(xokumRecord.ChildNodes['Netnummer'].NodeValue) then
Logger.Log('Netnummer', xokumIndex, xokumRecord.Netnummer);
end;
Logger.Log('');
end;
end.
| 30.300752 | 86 | 0.740447 |
47c85c75a5cd892f2f501583637a7d379b5c8852 | 13,452 | pas | Pascal | Version7/Source/DDLL/DRegControls.pas | dss-extensions/electricdss-src | fab07b5584090556b003ef037feb25ec2de3b7c9 | [
"BSD-3-Clause"
]
| 1 | 2022-01-23T14:43:30.000Z | 2022-01-23T14:43:30.000Z | Version7/Source/DDLL/DRegControls.pas | PMeira/electricdss-src | fab07b5584090556b003ef037feb25ec2de3b7c9 | [
"BSD-3-Clause"
]
| 7 | 2018-08-15T04:00:26.000Z | 2018-10-25T10:15:59.000Z | Version7/Source/DDLL/DRegControls.pas | PMeira/electricdss-src | fab07b5584090556b003ef037feb25ec2de3b7c9 | [
"BSD-3-Clause"
]
| null | null | null | unit DRegControls;
interface
function RegControlsI(mode: Longint; arg: Longint): Longint; CDECL;
function RegControlsF(mode: Longint; arg: Double): Double; CDECL;
function RegControlsS(mode: Longint; arg: pAnsiChar): pAnsiChar; CDECL;
procedure RegControlsV(mode: Longint; out arg: Variant); CDECL;
implementation
uses
DSSGlobals,
Executive,
ControlElem,
RegControl,
Variants,
SysUtils,
PointerList;
function ActiveRegControl: TRegControlObj;
begin
Result := NIL;
if ActiveCircuit <> NIL then
Result := ActiveCircuit.RegControls.Active;
end;
procedure Set_Parameter(const parm: String; const val: String);
var
cmd: String;
begin
if not Assigned(ActiveCircuit) then
exit;
SolutionAbort := FALSE; // Reset for commands entered from outside
cmd := Format('regcontrol.%s.%s=%s', [ActiveRegControl.Name, parm, val]);
DSSExecutive.Command := cmd;
end;
function RegControlsI(mode: Longint; arg: Longint): Longint; CDECL;
var
elem: TRegControlObj;
lst: TPointerList;
begin
Result := 0; // Default return value
case mode of
0:
begin // RegControls.First
Result := 0;
if ActiveCircuit <> NIL then
begin
lst := ActiveCircuit.RegControls;
elem := lst.First;
if elem <> NIL then
begin
repeat
if elem.Enabled then
begin
ActiveCircuit.ActiveCktElement := elem;
Result := 1;
end
else
elem := lst.Next;
until (Result = 1) or (elem = NIL);
end;
end;
end;
1:
begin // RegControls.Next
Result := 0;
if ActiveCircuit <> NIL then
begin
lst := ActiveCircuit.RegControls;
elem := lst.Next;
if elem <> NIL then
begin
repeat
if elem.Enabled then
begin
ActiveCircuit.ActiveCktElement := elem;
Result := lst.ActiveIndex;
end
else
elem := lst.Next;
until (Result > 0) or (elem = NIL);
end
end;
end;
2:
begin // RegControls.TapWinding read
Result := 0;
elem := ActiveRegControl;
if elem <> NIL then
Result := elem.TrWinding; // has the taps
end;
3:
begin // RegControls.TapWinding write
Set_Parameter('TapWinding', IntToStr(arg));
end;
4:
begin // RegControls.Winding read
Result := 0;
elem := ActiveRegControl;
if elem <> NIL then
Result := elem.ElementTerminal; // monitored winding
end;
5:
begin // RegControls.Winding write
Set_Parameter('Winding', IntToStr(arg));
end;
6:
begin // RegControls.IsReversible read
Result := 0;
elem := ActiveRegControl;
if elem <> NIL then
if elem.UseReverseDrop then
Result := 1;
end;
7:
begin // RegControls.IsReversible write
if arg = 1 then
Set_Parameter('Reversible', 'y')
else
Set_Parameter('Reversible', 'n');
end;
8:
begin // RegControls.IsInverseTime read
Result := 0;
elem := ActiveRegControl;
if elem <> NIL then
if elem.IsInverseTime then
Result := 1;
end;
9:
begin // RegControls.IsInverseTime write
if arg = 1 then
Set_Parameter('InverseTime', 'y')
else
Set_Parameter('InverseTime', 'n');
end;
10:
begin // RegControls.MaxTapChange read
Result := 0;
elem := ActiveRegControl;
if elem <> NIL then
Result := elem.MaxTapChange;
end;
11:
begin // RegControls.MaxTapChange write
Set_Parameter('MaxTapChange', IntToStr(arg));
end;
12:
begin // RegControls.Count
if Assigned(Activecircuit) then
Result := ActiveCircuit.RegControls.ListSize;
end;
13:
begin // RegControls.TapNumber read
Result := 0;
elem := ActiveRegControl;
if elem <> NIL then
Result := elem.TapNum; // tap number on the controlled-winding of the transformer controlled by this regcontrol
end;
14:
begin // RegControls.TapNumber write
Set_Parameter('TapNum', IntToStr(arg));
end
else
Result := -1;
end;
end;
//***********************Floating poitn type properties***************************
function RegControlsF(mode: Longint; arg: Double): Double; CDECL;
var
elem: TRegControlObj;
begin
Result := 0.0; // Default return value
case mode of
0:
begin // RegControls.CTPrimary read
Result := 0.0;
elem := ActiveRegControl;
if elem <> NIL then
Result := elem.CT;
end;
1:
begin // RegControls.CTPrimary write
Set_Parameter('CTprim', FloatToStr(arg));
end;
2:
begin // RegControls.PTRatio read
Result := 0.0;
elem := ActiveRegControl;
if elem <> NIL then
Result := elem.PT;
end;
3:
begin // RegControls.PTRatio write
Set_Parameter('PTratio', FloatToStr(arg));
end;
4:
begin // RegControls.ForwardR read
Result := 0.0;
elem := ActiveRegControl;
if elem <> NIL then
Result := elem.LineDropR;
end;
5:
begin // RegControls.ForwardR write
Set_Parameter('R', FloatToStr(arg));
end;
6:
begin // RegControls.ForwardX read
Result := 0.0;
elem := ActiveRegControl;
if elem <> NIL then
Result := elem.LineDropX;
end;
7:
begin // RegControls.ForwardX write
Set_Parameter('X', FloatToStr(arg));
end;
8:
begin // RegControls.ReverseR read
Result := 0.0;
elem := ActiveRegControl;
if elem <> NIL then
Result := elem.RevLineDropR;
end;
9:
begin // RegControls.ReverseR write
Set_Parameter('RevR', FloatToStr(arg));
end;
10:
begin // RegControls.ReverseX read
Result := 0.0;
elem := ActiveRegControl;
if elem <> NIL then
Result := elem.RevLineDropX;
end;
11:
begin // RegControls.ReverseX write
Set_Parameter('RevX', FloatToStr(arg));
end;
12:
begin // RegControls.Delay read
Result := 0.0;
elem := ActiveRegControl;
if elem <> NIL then
Result := elem.InitialDelay;
end;
13:
begin // RegControls.Delay write
Set_Parameter('Delay', FloatToStr(arg));
end;
14:
begin // RegControls.TapDelay read
Result := 0.0;
elem := ActiveRegControl;
if elem <> NIL then
Result := elem.SubsequentDelay;
end;
15:
begin // RegControls.TapDelay write
Set_Parameter('TapDelay', FloatToStr(arg));
end;
16:
begin // RegControls.VoltageLimit read
Result := 0.0;
elem := ActiveRegControl;
if elem <> NIL then
Result := elem.VoltageLimit;
end;
17:
begin // RegControls.VoltageLimit write
Set_Parameter('Vlimit', FloatToStr(arg));
end;
18:
begin // RegControls.ForwardBand read
Result := 0.0;
elem := ActiveRegControl;
if elem <> NIL then
Result := elem.BandVoltage;
end;
19:
begin // RegControls.ForwardBand write
Set_Parameter('Band', FloatToStr(arg));
end;
20:
begin // RegControls.ForwardVreg read
Result := 0.0;
elem := ActiveRegControl;
if elem <> NIL then
Result := elem.TargetVoltage;
end;
21:
begin // RegControls.ForwardVreg write
Set_Parameter('Vreg', FloatToStr(arg));
end;
22:
begin // RegControls.ReverseBand read
Result := 0.0;
elem := ActiveRegControl;
if elem <> NIL then
Result := elem.RevBandVoltage;
end;
23:
begin // RegControls.ReverseBand Write
Set_Parameter('RevBand', FloatToStr(arg));
end;
24:
begin // RegControls.ReverseVreg read
Result := 0.0;
elem := ActiveRegControl;
if elem <> NIL then
Result := elem.RevTargetVoltage;
end;
25:
begin // RegControls.ReverseVreg write
Set_Parameter('RevVreg', FloatToStr(arg));
end
else
Result := -1.0;
end;
end;
//********************String type properties**************************************
function RegControlsS(mode: Longint; arg: pAnsiChar): pAnsiChar; CDECL;
var
elem: TRegControlObj;
ActiveSave: Integer;
S: String;
Found: Boolean;
lst: TPointerList;
begin
Result := pAnsiChar(Ansistring('')); // Default return value
case mode of
0:
begin // RegControls.Name read
Result := String(Ansistring(''));
elem := ActiveRegControl;
if elem <> NIL then
Result := pAnsiChar(Ansistring(elem.Name));
end;
1:
begin // RegControls.Name write
if ActiveCircuit <> NIL then
begin
lst := ActiveCircuit.RegControls;
S := String(arg); // Convert to Pascal String
Found := FALSE;
ActiveSave := lst.ActiveIndex;
elem := lst.First;
while elem <> NIL do
begin
if (CompareText(elem.Name, S) = 0) then
begin
ActiveCircuit.ActiveCktElement := elem;
Found := TRUE;
Break;
end;
elem := lst.Next;
end;
if not Found then
begin
DoSimpleMsg('RegControl "' + S + '" Not Found in Active Circuit.', 5003);
elem := lst.Get(ActiveSave); // Restore active Load
ActiveCircuit.ActiveCktElement := elem;
end;
end;
end;
2:
begin // RegControls.MonitoredBus read
Result := String(Ansistring(''));
elem := ActiveRegControl;
if elem <> NIL then
Result := pAnsiChar(Ansistring(elem.ControlledBusName));
end;
3:
begin // RegControls.MonitoredBus write
Set_Parameter('Bus', String(arg));
end;
4:
begin // RegControls.Transformer read
Result := String(Ansistring(''));
elem := ActiveRegControl;
if elem <> NIL then
Result := pAnsiChar(Ansistring(elem.Transformer.Name));
end;
5:
begin // RegControls.Transformer write
Set_Parameter('Transformer', String(arg));
end
else
Result := String(Ansistring('Error, parameter not valid'));
end;
end;
//*******************Variant type properties**************************************
procedure RegControlsV(mode: Longint; out arg: Variant); CDECL;
var
elem: TRegControlObj;
lst: TPointerList;
k: Integer;
begin
case mode of
0:
begin // RegControl.AllNames
arg := VarArrayCreate([0, 0], varOleStr);
arg[0] := 'NONE';
if ActiveCircuit <> NIL then
with ActiveCircuit do
begin
lst := RegControls;
if lst.ListSize > 0 then
begin
VarArrayRedim(arg, lst.ListSize - 1);
k := 0;
elem := lst.First;
while elem <> NIL do
begin
arg[k] := elem.Name;
Inc(k);
elem := lst.Next;
end;
end;
end;
end
else
arg[0] := 'Error, parameter not valid';
end;
end;
end.
| 30.365688 | 128 | 0.475022 |
47149c6e923c680e6e741fd817aa03e8223a6779 | 64,037 | pas | Pascal | src/bgrabitmap7.2/bgrafilters.pas | laggyluk/brick_engine | 1fc63d8186b4eb12cbfdb3a8b48a901089d3994c | [
"MIT"
]
| 1 | 2019-05-24T19:20:12.000Z | 2019-05-24T19:20:12.000Z | src/bgrabitmap7.2/bgrafilters.pas | laggyluk/brick_engine | 1fc63d8186b4eb12cbfdb3a8b48a901089d3994c | [
"MIT"
]
| null | null | null | src/bgrabitmap7.2/bgrafilters.pas | laggyluk/brick_engine | 1fc63d8186b4eb12cbfdb3a8b48a901089d3994c | [
"MIT"
]
| null | null | null | unit BGRAFilters;
{$mode objfpc}{$H+}
interface
{ Here are some filters that can be applied to a bitmap. The filters
take a source image as a parameter and gives a filtered image as
a result. }
uses
Classes, BGRABitmapTypes;
type
TCheckShouldStopFunc = function: boolean of object;
{ TFilterTask }
TFilterTask = class
private
FCheckShouldStop: TCheckShouldStopFunc;
procedure SetDestination(AValue: TBGRACustomBitmap);
protected
FDestination: TBGRACustomBitmap;
FSource: TBGRACustomBitmap;
function GetShouldStop: boolean;
procedure DoExecute; virtual; abstract;
public
function Execute: TBGRACustomBitmap;
property Destination: TBGRACustomBitmap read FDestination write SetDestination;
property CheckShouldStop: TCheckShouldStopFunc read FCheckShouldStop write FCheckShouldStop;
end;
{ The median filter consist in calculating the median value of pixels. Here
a square of 9x9 pixel is considered. The median allow to select the most
representative colors. The option parameter allow to choose to smooth the
result or not. }
function FilterMedian(bmp: TBGRACustomBitmap;
Option: TMedianOption): TBGRACustomBitmap;
{ SmartZoom x3 is a filter that upsizes 3 times the picture and add
pixels that could be logically expected (horizontal, vertical, diagonal lines) }
function FilterSmartZoom3(bmp: TBGRACustomBitmap;
Option: TMedianOption): TBGRACustomBitmap;
{ Sharpen filter add more contrast between pixels }
function FilterSharpen(bmp: TBGRACustomBitmap; AAmount: integer = 256): TBGRACustomBitmap;
function FilterSharpen(bmp: TBGRACustomBitmap; ABounds: TRect; AAmount: integer = 256): TBGRACustomBitmap;
{ A radial blur applies a blur with a circular influence, i.e, each pixel
is merged with pixels within the specified radius. There is an exception
with rbFast blur, the optimization entails an hyperbolic shape. }
function FilterBlurRadial(bmp: TBGRACustomBitmap; radius: integer;
blurType: TRadialBlurType): TBGRACustomBitmap;
function CreateRadialBlurTask(ABmp: TBGRACustomBitmap; ABounds: TRect; ARadius: integer;
ABlurType: TRadialBlurType): TFilterTask;
{ The precise blur allow to specify the blur radius with subpixel accuracy }
function FilterBlurRadialPrecise(bmp: TBGRACustomBitmap; radius: single): TBGRACustomBitmap;
function CreateRadialPreciseBlurTask(ABmp: TBGRACustomBitmap; ABounds: TRect; ARadius: single): TFilterTask;
{ Motion blur merge pixels in a direction. The oriented parameter specifies
if the weights of the pixels are the same along the line or not. }
function FilterBlurMotion(bmp: TBGRACustomBitmap; distance: single;
angle: single; oriented: boolean): TBGRACustomBitmap;
function CreateMotionBlurTask(ABmp: TBGRACustomBitmap; ABounds: TRect; ADistance,AAngle: single; AOriented: boolean): TFilterTask;
{ General purpose blur filter, with a blur mask as parameter to describe
how pixels influence each other }
function FilterBlur(bmp: TBGRACustomBitmap; blurMask: TBGRACustomBitmap): TBGRACustomBitmap;
function CreateBlurTask(ABmp: TBGRACustomBitmap; ABounds: TRect; AMask: TBGRACustomBitmap): TFilterTask;
function FilterPixelate(bmp: TBGRACustomBitmap; pixelSize: integer; useResample: boolean; filter: TResampleFilter = rfLinear): TBGRACustomBitmap;
{ Emboss filter compute a color difference in the angle direction }
function FilterEmboss(bmp: TBGRACustomBitmap; angle: single): TBGRACustomBitmap;
function FilterEmboss(bmp: TBGRACustomBitmap; angle: single; ABounds: TRect): TBGRACustomBitmap;
{ Emboss highlight computes a sort of emboss with 45 degrees angle and
with standard selection color (white/black and filled with blue) }
function FilterEmbossHighlight(bmp: TBGRACustomBitmap;
FillSelection: boolean; DefineBorderColor: TBGRAPixel): TBGRACustomBitmap;
function FilterEmbossHighlightOffset(bmp: TBGRACustomBitmap;
FillSelection: boolean; DefineBorderColor: TBGRAPixel; var Offset: TPoint): TBGRACustomBitmap;
{ Normalize use the whole available range of values, making dark colors darkest possible
and light colors lightest possible }
function FilterNormalize(bmp: TBGRACustomBitmap;
eachChannel: boolean = True): TBGRACustomBitmap;
function FilterNormalize(bmp: TBGRACustomBitmap; ABounds: TRect;
eachChannel: boolean = True): TBGRACustomBitmap;
{ Rotate filter rotate the image and clip it in the bounding rectangle }
function FilterRotate(bmp: TBGRACustomBitmap; origin: TPointF;
angle: single): TBGRACustomBitmap;
{ Grayscale converts colored pixel into grayscale with same luminosity }
function FilterGrayscale(bmp: TBGRACustomBitmap): TBGRACustomBitmap;
function FilterGrayscale(bmp: TBGRACustomBitmap; ABounds: TRect): TBGRACustomBitmap;
function CreateGrayscaleTask(bmp: TBGRACustomBitmap; ABounds: TRect): TFilterTask;
{ Compute a contour, as if the image was drawn with a 2 pixels-wide black pencil }
function FilterContour(bmp: TBGRACustomBitmap): TBGRACustomBitmap;
{ Distort the image as if it were on a sphere }
function FilterSphere(bmp: TBGRACustomBitmap): TBGRACustomBitmap;
{ Twirl distortion, i.e. a progressive rotation }
function FilterTwirl(bmp: TBGRACustomBitmap; ACenter: TPoint; ARadius: Single; ATurn: Single=1; AExponent: Single=3): TBGRACustomBitmap;
function FilterTwirl(bmp: TBGRACustomBitmap; ABounds: TRect; ACenter: TPoint; ARadius: Single; ATurn: Single=1; AExponent: Single=3): TBGRACustomBitmap;
{ Distort the image as if it were on a vertical cylinder }
function FilterCylinder(bmp: TBGRACustomBitmap): TBGRACustomBitmap;
{ Compute a plane projection towards infinity (SLOW) }
function FilterPlane(bmp: TBGRACustomBitmap): TBGRACustomBitmap;
implementation
uses Math, GraphType, Dialogs, BGRATransform, Types, SysUtils;
type
{ TGrayscaleTask }
TGrayscaleTask = class(TFilterTask)
private
FBounds: TRect;
public
constructor Create(bmp: TBGRACustomBitmap; ABounds: TRect);
protected
procedure DoExecute; override;
end;
{ TRadialBlurTask }
TRadialBlurTask = class(TFilterTask)
private
FBounds: TRect;
FRadius: integer;
FBlurType: TRadialBlurType;
public
constructor Create(bmp: TBGRACustomBitmap; ABounds: TRect; radius: integer;
blurType: TRadialBlurType);
protected
procedure DoExecute; override;
end;
{ TCustomBlurTask }
TCustomBlurTask = class(TFilterTask)
private
FBounds: TRect;
FMask: TBGRACustomBitmap;
public
constructor Create(bmp: TBGRACustomBitmap; ABounds: TRect; AMask: TBGRACustomBitmap);
protected
procedure DoExecute; override;
end;
{ TRadialPreciseBlurTask }
TRadialPreciseBlurTask = class(TFilterTask)
private
FBounds: TRect;
FRadius: Single;
public
constructor Create(bmp: TBGRACustomBitmap; ABounds: TRect; radius: single);
protected
procedure DoExecute; override;
end;
{ TMotionBlurTask }
TMotionBlurTask = class(TFilterTask)
private
FBounds: TRect;
FDistance,FAngle: single;
FOriented: boolean;
public
constructor Create(ABmp: TBGRACustomBitmap; ABounds: TRect; ADistance, AAngle: single; AOriented: boolean);
protected
procedure DoExecute; override;
end;
procedure FilterBlurRadial(bmp: TBGRACustomBitmap; ABounds: TRect; radius: integer;
blurType: TRadialBlurType; ADestination: TBGRACustomBitmap; ACheckShouldStop: TCheckShouldStopFunc); forward;
procedure FilterBlurRadialPrecise(bmp: TBGRACustomBitmap; ABounds: TRect;
radius: single; ADestination: TBGRACustomBitmap; ACheckShouldStop: TCheckShouldStopFunc); forward;
procedure FilterBlurMotion(bmp: TBGRACustomBitmap; ABounds: TRect; distance: single;
angle: single; oriented: boolean; ADestination: TBGRACustomBitmap; ACheckShouldStop: TCheckShouldStopFunc); forward;
procedure FilterBlur(bmp: TBGRACustomBitmap; ABounds: TRect;
blurMask: TBGRACustomBitmap; ADestination: TBGRACustomBitmap; ACheckShouldStop: TCheckShouldStopFunc); forward;
function FilterSmartZoom3(bmp: TBGRACustomBitmap;
Option: TMedianOption): TBGRACustomBitmap;
type
TSmartDiff = record
d, cd, sd, b, a: single;
end;
var
xb, yb: Int32or64;
diag1, diag2, h1, h2, v1, v2: TSmartDiff;
c,c1,c2: TBGRAPixel;
temp, median: TBGRACustomBitmap;
function ColorDiff(c1, c2: TBGRAPixel): single;
var
max1, max2: Int32or64;
begin
if (c1.alpha = 0) and (c2.alpha = 0) then
begin
Result := 0;
exit;
end
else
if (c1.alpha = 0) or (c2.alpha = 0) then
begin
Result := 1;
exit;
end;
max1 := c1.red;
if c1.green > max1 then
max1 := c1.green;
if c1.blue > max1 then
max1 := c1.blue;
max2 := c2.red;
if c2.green > max2 then
max2 := c2.green;
if c2.blue > max2 then
max2 := c2.blue;
if (max1 = 0) or (max2 = 0) then
begin
Result := 0;
exit;
end;
Result := (abs(c1.red / max1 - c2.red / max2) +
abs(c1.green / max1 - c2.green / max2) + abs(c1.blue / max1 - c2.blue / max2)) / 3;
end;
function RGBDiff(c1, c2: TBGRAPixel): single;
begin
if (c1.alpha = 0) and (c2.alpha = 0) then
begin
Result := 0;
exit;
end
else
if (c1.alpha = 0) or (c2.alpha = 0) then
begin
Result := 1;
exit;
end;
Result := (abs(c1.red - c2.red) + abs(c1.green - c2.green) +
abs(c1.blue - c2.blue)) / 3 / 255;
end;
function smartDiff(x1, y1, x2, y2: Int32or64): TSmartDiff;
var
c1, c2, c1m, c2m: TBGRAPixel;
begin
c1 := bmp.GetPixel(x1, y1);
c2 := bmp.GetPixel(x2, y2);
c1m := median.GetPixel(x1, y1);
c2m := median.GetPixel(x2, y2);
Result.d := RGBDiff(c1, c2);
Result.cd := ColorDiff(c1, c2);
Result.a := c1.alpha / 255 * c2.alpha / 255;
Result.d := Result.d * Result.a + (1 - Result.a) *
(1 + abs(c1.alpha - c2.alpha) / 255) / 5;
Result.b := RGBDiff(c1, c1m) * c1.alpha / 255 * c1m.alpha / 255 +
RGBDiff(c2, c2m) * c2.alpha / 255 * c2m.alpha / 255 +
(abs(c1.alpha - c1m.alpha) + abs(c2.alpha - c2m.alpha)) / 255 / 4;
Result.sd := Result.d + Result.cd * 3;
end;
var
diff: single;
begin
median := FilterMedian(bmp, moNone);
temp := bmp.Resample(bmp.Width * 3, bmp.Height * 3, rmSimpleStretch);
Result := FilterMedian(temp, Option);
temp.Free;
for yb := 0 to bmp.Height - 2 do
for xb := 0 to bmp.Width - 2 do
begin
diag1 := smartDiff(xb, yb, xb + 1, yb + 1);
diag2 := smartDiff(xb, yb + 1, xb + 1, yb);
h1 := smartDiff(xb, yb, xb + 1, yb);
h2 := smartDiff(xb, yb + 1, xb + 1, yb + 1);
v1 := smartDiff(xb, yb, xb, yb + 1);
v2 := smartDiff(xb + 1, yb, xb + 1, yb + 1);
diff := diag1.sd - diag2.sd;
if abs(diff) < 3 then
diff -= (diag1.b - diag2.b) * (3 - abs(diff)) / 2;
//which diagonal to highlight?
if abs(diff) < 0.2 then
diff := 0;
if diff < 0 then
begin
//same color?
if diag1.cd < 0.3 then
begin
c1 := bmp.GetPixel(xb, yb);
c2 := bmp.GetPixel(xb + 1, yb + 1);
c := MergeBGRA(c1, c2);
//restore
Result.SetPixel(xb * 3 + 2, yb * 3 + 2, bmp.GetPixel(xb, yb));
Result.SetPixel(xb * 3 + 3, yb * 3 + 3, bmp.GetPixel(xb + 1, yb + 1));
if (diag1.sd < h1.sd) and (diag1.sd < v2.sd) then
Result.SetPixel(xb * 3 + 3, yb * 3 + 2, c);
if (diag1.sd < h2.sd) and (diag1.sd < v1.sd) then
Result.SetPixel(xb * 3 + 2, yb * 3 + 3, c);
end;
end
else
if diff > 0 then
begin
//same color?
if diag2.cd < 0.3 then
begin
c1 := bmp.GetPixel(xb, yb + 1);
c2 := bmp.GetPixel(xb + 1, yb);
c := MergeBGRA(c1, c2);
//restore
Result.SetPixel(xb * 3 + 3, yb * 3 + 2, bmp.GetPixel(xb + 1, yb));
Result.SetPixel(xb * 3 + 2, yb * 3 + 3, bmp.GetPixel(xb, yb + 1));
if (diag2.sd < h1.sd) and (diag2.sd < v1.sd) then
Result.SetPixel(xb * 3 + 2, yb * 3 + 2, c);
if (diag2.sd < h2.sd) and (diag2.sd < v2.sd) then
Result.SetPixel(xb * 3 + 3, yb * 3 + 3, c);
end;
end;
end;
median.Free;
end;
{ This filter compute for each pixel the mean of the eight surrounding pixels,
then the difference between this average pixel and the pixel at the center
of the square. Finally the difference is added to the new pixel, exagerating
its difference with its neighbours. }
function FilterSharpen(bmp: TBGRACustomBitmap; ABounds: TRect; AAmount: integer = 256): TBGRACustomBitmap;
var
yb, xcount: Int32or64;
dx, dy: Int32or64;
a_pixels: array[-2..1,-2..1] of PBGRAPixel;
sumR, sumG, sumB, sumA, {RGBdiv, }nbA: UInt32or64;
refPixel: TBGRAPixel;
pdest,ptempPixel: PBGRAPixel;
bounds: TRect;
Amount256: boolean;
lastXincluded: boolean;
alpha,rgbDivShr1: uint32or64;
begin
if IsRectEmpty(ABounds) then exit;
Amount256 := AAmount = 256;
Result := bmp.NewBitmap(bmp.Width, bmp.Height);
//determine where pixels are in the bitmap
bounds := bmp.GetImageBounds;
if not IntersectRect(bounds, bounds,ABounds) then exit;
bounds.Left := max(0, bounds.Left - 1);
bounds.Top := max(0, bounds.Top - 1);
bounds.Right := min(bmp.Width, bounds.Right + 1);
bounds.Bottom := min(bmp.Height, bounds.Bottom + 1);
lastXincluded:= bounds.Right < bmp.Width;
//loop through the destination bitmap
for yb := bounds.Top to bounds.Bottom - 1 do
begin
pdest := Result.scanline[yb] + bounds.Left;
fillchar({%H-}a_pixels,sizeof(a_pixels),0);
for dy := -1 to 1 do
if (yb+dy >= bounds.Top) and (yb+dy < bounds.Bottom) then
a_pixels[dy,1] := bmp.ScanLine[yb+dy]+bounds.Left else
a_pixels[dy,1] := nil;
xcount := bounds.right-bounds.left;
while xcount > 0 do
begin
dec(xcount);
//for each pixel, read eight surrounding pixels in the source bitmap
for dy := -1 to 1 do
for dx := -1 to 0 do
a_pixels[dy,dx] := a_pixels[dy,dx+1];
if (xcount > 0) or lastXincluded then
begin
for dy := -1 to 1 do
if a_pixels[dy,0] <> nil then a_pixels[dy,1] := a_pixels[dy,0]+1;
end;
//compute sum
sumR := 0;
sumG := 0;
sumB := 0;
sumA := 0;
//RGBdiv := 0;
nbA := 0;
{$hints off}
for dy := -1 to 1 do
for dx := -1 to 1 do
if (dx<>0) or (dy<>0) then
begin
ptempPixel := a_pixels[dy,dx];
if ptempPixel <> nil then
begin
alpha := ptempPixel^.alpha;
sumR += ptempPixel^.red * alpha;
sumG += ptempPixel^.green * alpha;
sumB += ptempPixel^.blue * alpha;
//RGBdiv += alpha;
sumA += alpha;
Inc(nbA);
end;
end;
{$hints on}
//we finally have an average pixel
if ({RGBdiv}sumA = 0) then
refPixel := BGRAPixelTransparent
else
begin
rgbDivShr1:= {RGBDiv}sumA shr 1;
refPixel.red := (sumR + rgbDivShr1) div {RGBdiv}sumA;
refPixel.green := (sumG + rgbDivShr1) div {RGBdiv}sumA;
refPixel.blue := (sumB + rgbDivShr1) div {RGBdiv}sumA;
refPixel.alpha := (sumA + nbA shr 1) div nbA;
end;
//read the pixel at the center of the square
ptempPixel := a_pixels[0,0];
if refPixel <> BGRAPixelTransparent then
begin
//compute sharpened pixel by adding the difference
if not Amount256 then
pdest^ := BGRA( max(0, min($FFFF, Int32or64(ptempPixel^.red shl 8) +
AAmount*(ptempPixel^.red - refPixel.red))) shr 8,
max(0, min($FFFF, Int32or64(ptempPixel^.green shl 8) +
AAmount*(ptempPixel^.green - refPixel.green))) shr 8,
max(0, min($FFFF, Int32or64(ptempPixel^.blue shl 8) +
AAmount*(ptempPixel^.blue - refPixel.blue))) shr 8,
max(0, min($FFFF, Int32or64(ptempPixel^.alpha shl 8) +
AAmount*(ptempPixel^.alpha - refPixel.alpha))) shr 8 )
else
pdest^ := BGRA( max(0, min(255, (ptempPixel^.red shl 1) - refPixel.red)),
max(0, min(255, (ptempPixel^.green shl 1) - refPixel.green)),
max(0, min(255, (ptempPixel^.blue shl 1) - refPixel.blue)),
max(0, min(255, (ptempPixel^.alpha shl 1) - refPixel.alpha)));
end else
pdest^ := ptempPixel^;
Inc(pdest);
end;
end;
Result.InvalidateBitmap;
end;
function FilterSharpen(bmp: TBGRACustomBitmap; AAmount: integer
): TBGRACustomBitmap;
begin
result := FilterSharpen(bmp,rect(0,0,bmp.Width,bmp.Height),AAmount);
end;
{ Precise blur builds a blur mask with a gradient fill and use
general purpose blur }
procedure FilterBlurRadialPrecise(bmp: TBGRACustomBitmap;
ABounds: TRect; radius: single; ADestination: TBGRACustomBitmap; ACheckShouldStop: TCheckShouldStopFunc);
var
blurShape: TBGRACustomBitmap;
intRadius: integer;
begin
if radius = 0 then
begin
ADestination.PutImagePart(ABounds.Left,ABounds.Top,bmp,ABounds,dmSet);
exit;
end;
intRadius := ceil(radius);
blurShape := bmp.NewBitmap(2 * intRadius + 1, 2 * intRadius + 1);
blurShape.GradientFill(0, 0, blurShape.Width, blurShape.Height, BGRAWhite,
BGRABlack, gtRadial, pointF(intRadius, intRadius), pointF(
intRadius - radius - 1, intRadius), dmSet);
FilterBlur(bmp, ABounds, blurShape, ADestination, ACheckShouldStop);
blurShape.Free;
end;
function FilterBlurRadialPrecise(bmp: TBGRACustomBitmap; radius: single
): TBGRACustomBitmap;
begin
result := bmp.NewBitmap(bmp.Width,bmp.Height);
FilterBlurRadialPrecise(bmp, rect(0,0,bmp.Width,bmp.Height), radius, result, nil);
end;
function CreateRadialPreciseBlurTask(ABmp: TBGRACustomBitmap; ABounds: TRect;
ARadius: single): TFilterTask;
begin
result := TRadialPreciseBlurTask.Create(ABmp,ABounds,ARadius);
end;
{ This is a clever solution for fast computing of the blur
effect : it stores an array of vertical sums forming a square
around the pixel which moves with it. For each new pixel,
the vertical sums are kept except for the last column of
the square }
procedure FilterBlurFast(bmp: TBGRACustomBitmap; ABounds: TRect;
radius: integer; ADestination: TBGRACustomBitmap; ACheckShouldStop: TCheckShouldStopFunc);
type
TRowSum = record
sumR,sumG,sumB,rgbDiv,sumA,aDiv: uint32or64;
end;
function ComputeAverage(sum: TRowSum): TBGRAPixel;
begin
result.alpha:= (sum.sumA+sum.aDiv shr 1) div sum.aDiv;
result.red := (sum.sumR+sum.rgbDiv shr 1) div sum.rgbDiv;
result.green := (sum.sumG+sum.rgbDiv shr 1) div sum.rgbDiv;
result.blue := (sum.sumB+sum.rgbDiv shr 1) div sum.rgbDiv;
end;
{$I blurfast.inc}
{ Normal radial blur compute a blur mask with a GradientFill and
then posterize to optimize general purpose blur }
procedure FilterBlurRadialNormal(bmp: TBGRACustomBitmap;
ABounds: TRect; radius: integer; ADestination: TBGRACustomBitmap; ACheckShouldStop: TCheckShouldStopFunc);
var
blurShape: TBGRACustomBitmap;
n: Int32or64;
p: PBGRAPixel;
begin
if radius = 0 then
begin
ADestination.PutImagePart(ABounds.Left,ABounds.Top,bmp,ABounds,dmSet);
exit;
end;
blurShape := bmp.NewBitmap(2 * radius + 1, 2 * radius + 1);
blurShape.GradientFill(0, 0, blurShape.Width, blurShape.Height, BGRAWhite,
BGRABlack, gtRadial, pointF(radius, radius), pointF(-0.5, radius), dmSet);
p := blurShape.Data;
for n := 0 to blurShape.NbPixels-1 do
begin
p^.red := p^.red and $F0;
p^.green := p^.red;
p^.blue := p^.red;
inc(p);
end;
FilterBlur(bmp, ABounds, blurShape, ADestination, ACheckShouldStop);
blurShape.Free;
end;
{ Blur disk creates a disk mask with a FillEllipse }
procedure FilterBlurDisk(bmp: TBGRACustomBitmap; ABounds: TRect; radius: integer; ADestination: TBGRACustomBitmap; ACheckShouldStop: TCheckShouldStopFunc);
var
blurShape: TBGRACustomBitmap;
begin
if radius = 0 then
begin
ADestination.PutImagePart(ABounds.Left,ABounds.Top,bmp,ABounds,dmSet);
exit;
end;
blurShape := bmp.NewBitmap(2 * radius + 1, 2 * radius + 1);
blurShape.Fill(BGRABlack);
blurShape.FillEllipseAntialias(radius, radius, radius + 0.5, radius + 0.5, BGRAWhite);
FilterBlur(bmp, ABounds, blurShape, ADestination, ACheckShouldStop);
blurShape.Free;
end;
{ Corona blur use a circle as mask }
procedure FilterBlurCorona(bmp: TBGRACustomBitmap; ABounds: TRect; radius: integer; ADestination: TBGRACustomBitmap; ACheckShouldStop: TCheckShouldStopFunc);
var
blurShape: TBGRACustomBitmap;
begin
if radius = 0 then
begin
ADestination.PutImagePart(ABounds.Left,ABounds.Top,bmp,ABounds,dmSet);
exit;
end;
blurShape := bmp.NewBitmap(2 * radius + 1, 2 * radius + 1);
blurShape.Fill(BGRABlack);
blurShape.EllipseAntialias(radius, radius, radius, radius, BGRAWhite, 1);
FilterBlur(bmp, ABounds, blurShape, ADestination, ACheckShouldStop);
blurShape.Free;
end;
procedure FilterBlurRadial(bmp: TBGRACustomBitmap; ABounds: TRect; radius: integer;
blurType: TRadialBlurType; ADestination: TBGRACustomBitmap; ACheckShouldStop: TCheckShouldStopFunc);
begin
if radius = 0 then
begin
ADestination.PutImagePart(ABounds.Left,ABounds.Top,bmp,ABounds,dmSet);
exit;
end;
case blurType of
rbCorona: FilterBlurCorona(bmp, ABounds, radius, ADestination, ACheckShouldStop);
rbDisk: FilterBlurDisk(bmp, ABounds, radius, ADestination, ACheckShouldStop);
rbNormal: FilterBlurRadialNormal(bmp, ABounds, radius, ADestination, ACheckShouldStop);
rbFast: FilterBlurFast(bmp, ABounds, radius, ADestination, ACheckShouldStop);
rbPrecise: FilterBlurRadialPrecise(bmp, ABounds, radius / 10, ADestination, ACheckShouldStop);
end;
end;
function FilterBlurRadial(bmp: TBGRACustomBitmap; radius: integer;
blurType: TRadialBlurType): TBGRACustomBitmap;
begin
result := bmp.NewBitmap(bmp.width,bmp.Height);
FilterBlurRadial(bmp, rect(0,0,bmp.Width,bmp.height), radius, blurType,result,nil);
end;
function CreateRadialBlurTask(ABmp: TBGRACustomBitmap; ABounds: TRect; ARadius: integer;
ABlurType: TRadialBlurType): TFilterTask;
begin
result := TRadialBlurTask.Create(ABmp,ABounds,ARadius,ABlurType);
end;
{ This filter draws an antialiased line to make the mask, and
if the motion blur is oriented, does a GradientFill to orient it }
procedure FilterBlurMotion(bmp: TBGRACustomBitmap; ABounds: TRect; distance: single;
angle: single; oriented: boolean; ADestination: TBGRACustomBitmap; ACheckShouldStop: TCheckShouldStopFunc);
var
blurShape: TBGRACustomBitmap;
intRadius: integer;
dx, dy, d: single;
begin
if distance < 1e-6 then
begin
ADestination.PutImagePart(ABounds.Left,ABounds.Top,bmp,ABounds,dmSet);
exit;
end;
intRadius := ceil(distance / 2);
blurShape := bmp.NewBitmap(2 * intRadius + 1, 2 * intRadius + 1);
d := distance / 2;
dx := cos(angle * Pi / 180);
dy := sin(angle * Pi / 180);
blurShape.Fill(BGRABlack);
blurShape.DrawLineAntialias(intRadius - dx * d, intRadius - dy *
d, intRadius + dx * d, intRadius + dy * d, BGRAWhite, 1, True);
if oriented then
blurShape.GradientFill(0, 0, blurShape.Width, blurShape.Height,
BGRAPixelTransparent, BGRABlack, gtRadial, pointF(intRadius -
dx * d, intRadius - dy * d),
pointF(intRadius + dx * (d + 0.5), intRadius + dy * (d + 0.5)),
dmFastBlend, False);
FilterBlur(bmp, ABounds, blurShape, ADestination, ACheckShouldStop);
blurShape.Free;
end;
function FilterBlurMotion(bmp: TBGRACustomBitmap; distance: single;
angle: single; oriented: boolean): TBGRACustomBitmap;
begin
result := bmp.NewBitmap(bmp.Width,bmp.Height);
FilterBlurMotion(bmp,rect(0,0,bmp.Width,bmp.Height),distance,angle,oriented,result,nil);
end;
function CreateMotionBlurTask(ABmp: TBGRACustomBitmap; ABounds: TRect;
ADistance, AAngle: single; AOriented: boolean): TFilterTask;
begin
result := TMotionBlurTask.Create(ABmp,ABounds,ADistance,AAngle,AOriented);
end;
{ General purpose blur : compute pixel sum according to the mask and then
compute only difference while scanning from the left to the right }
procedure FilterBlurSmallMask(bmp: TBGRACustomBitmap;
blurMask: TBGRACustomBitmap; ABounds: TRect; ADestination: TBGRACustomBitmap; ACheckShouldStop: TCheckShouldStopFunc); forward;
procedure FilterBlurSmallMaskWithShift(bmp: TBGRACustomBitmap;
blurMask: TBGRACustomBitmap; maskShift: integer; ABounds: TRect; ADestination: TBGRACustomBitmap; ACheckShouldStop: TCheckShouldStopFunc); forward;
procedure FilterBlurBigMask(bmp: TBGRACustomBitmap;
blurMask: TBGRACustomBitmap; ABounds: TRect; ADestination: TBGRACustomBitmap; ACheckShouldStop: TCheckShouldStopFunc); forward;
procedure FilterBlurMask64(bmp: TBGRACustomBitmap;
blurMask: TBGRACustomBitmap; ABounds: TRect; ADestination: TBGRACustomBitmap; ACheckShouldStop: TCheckShouldStopFunc); forward;
//make sure value is in the range 0..255
function clampByte(value: Int32or64): byte; inline;
begin
if value < 0 then result := 0 else
if value > 255 then result := 255 else
result := value;
end;
function FilterPixelate(bmp: TBGRACustomBitmap; pixelSize: integer;
useResample: boolean; filter: TResampleFilter): TBGRACustomBitmap;
var yb,xb, xs,ys, tx,ty: Int32or64;
psrc,pdest: PBGRAPixel;
temp,stretched: TBGRACustomBitmap;
oldfilter: TResampleFilter;
begin
if pixelSize < 1 then
begin
result := bmp.Duplicate;
exit;
end;
result := bmp.NewBitmap(bmp.Width,bmp.Height);
tx := (bmp.Width+pixelSize-1) div pixelSize;
ty := (bmp.Height+pixelSize-1) div pixelSize;
if not useResample then
begin
temp := bmp.NewBitmap(tx,ty);
xs := (bmp.Width mod pixelSize) div 2;
ys := (bmp.Height mod pixelSize) div 2;
for yb := 0 to temp.height-1 do
begin
pdest := temp.ScanLine[yb];
psrc := bmp.scanline[ys]+xs;
inc(ys,pixelSize);
for xb := temp.width-1 downto 0 do
begin
pdest^ := psrc^;
inc(pdest);
inc(psrc,pixelSize);
end;
end;
temp.InvalidateBitmap;
end else
begin
oldfilter := bmp.ResampleFilter;
bmp.ResampleFilter := filter;
temp := bmp.Resample(tx,ty,rmFineResample);
bmp.ResampleFilter := oldfilter;
end;
stretched := temp.Resample(temp.Width*pixelSize,temp.Height*pixelSize,rmSimpleStretch);
temp.free;
if bmp.Width mod pixelSize = 0 then
xs := 0
else
xs := (-pixelSize+(bmp.Width mod pixelSize)) div 2;
if bmp.Height mod pixelSize = 0 then
ys := 0
else
ys := (-pixelSize+(bmp.Height mod pixelSize)) div 2;
result.PutImage(xs,ys,stretched,dmSet);
stretched.Free;
end;
function FilterBlur(bmp: TBGRACustomBitmap; blurMask: TBGRACustomBitmap): TBGRACustomBitmap;
begin
result := bmp.NewBitmap(bmp.Width,bmp.Height);
FilterBlur(bmp,rect(0,0,bmp.Width,bmp.Height),blurMask,result,nil);
end;
function CreateBlurTask(ABmp: TBGRACustomBitmap; ABounds: TRect;
AMask: TBGRACustomBitmap): TFilterTask;
begin
result := TCustomBlurTask.Create(ABmp,ABounds,AMask);
end;
procedure FilterBlur(bmp: TBGRACustomBitmap;
ABounds: TRect; blurMask: TBGRACustomBitmap; ADestination: TBGRACustomBitmap; ACheckShouldStop: TCheckShouldStopFunc);
{$IFDEF CPU64}
begin
FilterBlurMask64(bmp,blurMask,ABounds,ADestination,ACheckShouldStop);
end;
{$ELSE}
var
maskSum: int64;
i: Int32or64;
p: PBGRAPixel;
maskShift: integer;
begin
maskSum := 0;
p := blurMask.data;
for i := 0 to blurMask.NbPixels-1 do
begin
inc(maskSum,p^.red);
inc(p);
end;
maskShift := 0;
while maskSum > 32768 do
begin
inc(maskShift);
maskSum := maskSum shr 1;
end;
//check if sum can be stored in a 32-bit signed integer
if maskShift = 0 then
FilterBlurSmallMask(bmp,blurMask,ABounds,ADestination,ACheckShouldStop) else
{$IFDEF CPU32}
if maskShift < 8 then
FilterBlurSmallMaskWithShift(bmp,blurMask,maskShift,ABounds,ADestination,ACheckShouldStop) else
{$ENDIF}
FilterBlurBigMask(bmp,blurMask,ABounds,ADestination,ACheckShouldStop);
end;
{$ENDIF}
//32-bit blur with shift
procedure FilterBlurSmallMaskWithShift(bmp: TBGRACustomBitmap;
blurMask: TBGRACustomBitmap; maskShift: integer; ABounds: TRect; ADestination: TBGRACustomBitmap; ACheckShouldStop: TCheckShouldStopFunc);
var
sumR, sumG, sumB, sumA, Adiv, RGBdiv : integer;
function ComputeAverage: TBGRAPixel; inline;
begin
result.alpha := (sumA + Adiv shr 1) div Adiv;
if result.alpha = 0 then
result := BGRAPixelTransparent
else
begin
result.red := clampByte((sumR + RGBdiv shr 1) div RGBdiv);
result.green := clampByte((sumG + RGBdiv shr 1) div RGBdiv);
result.blue := clampByte((sumB + RGBdiv shr 1) div RGBdiv);
end;
end;
{$define PARAM_MASKSHIFT}
{$I blurnormal.inc}
//32-bit blur
procedure FilterBlurSmallMask(bmp: TBGRACustomBitmap;
blurMask: TBGRACustomBitmap; ABounds: TRect; ADestination: TBGRACustomBitmap; ACheckShouldStop: TCheckShouldStopFunc);
var
sumR, sumG, sumB, sumA, Adiv : integer;
function ComputeAverage: TBGRAPixel; inline;
begin
result.alpha := (sumA + Adiv shr 1) div Adiv;
if result.alpha = 0 then
result := BGRAPixelTransparent
else
begin
result.red := clampByte((sumR + sumA shr 1) div sumA);
result.green := clampByte((sumG + sumA shr 1) div sumA);
result.blue := clampByte((sumB + sumA shr 1) div sumA);
end;
end;
{$I blurnormal.inc}
//64-bit blur
procedure FilterBlurMask64(bmp: TBGRACustomBitmap;
blurMask: TBGRACustomBitmap; ABounds: TRect; ADestination: TBGRACustomBitmap; ACheckShouldStop: TCheckShouldStopFunc);
var
sumR, sumG, sumB, sumA, Adiv : int64;
function ComputeAverage: TBGRAPixel; inline;
begin
result.alpha := (sumA + Adiv shr 1) div Adiv;
if result.alpha = 0 then
result := BGRAPixelTransparent
else
begin
result.red := clampByte((sumR + sumA shr 1) div sumA);
result.green := clampByte((sumG + sumA shr 1) div sumA);
result.blue := clampByte((sumB + sumA shr 1) div sumA);
end;
end;
{$I blurnormal.inc}
//floating point blur
procedure FilterBlurBigMask(bmp: TBGRACustomBitmap;
blurMask: TBGRACustomBitmap; ABounds: TRect; ADestination: TBGRACustomBitmap; ACheckShouldStop: TCheckShouldStopFunc);
var
sumR, sumG, sumB, sumA, Adiv : single;
function ComputeAverage: TBGRAPixel; inline;
begin
result.alpha := round(sumA/Adiv);
if result.alpha = 0 then
result := BGRAPixelTransparent
else
begin
result.red := clampByte(round(sumR/sumA));
result.green := clampByte(round(sumG/sumA));
result.blue := clampByte(round(sumB/sumA));
end;
end;
{$I blurnormal.inc}
function FilterEmboss(bmp: TBGRACustomBitmap; angle: single): TBGRACustomBitmap;
begin
result := FilterEmboss(bmp, angle, rect(0,0,bmp.Width,bmp.Height));
end;
{ Emboss filter computes the difference between each pixel and the surrounding pixels
in the specified direction. }
function FilterEmboss(bmp: TBGRACustomBitmap; angle: single; ABounds: TRect): TBGRACustomBitmap;
var
yb, xb: Int32or64;
dx, dy: single;
idx1, idy1, idx2, idy2, idx3, idy3, idx4, idy4: Int32or64;
w: array[1..4] of single;
iw: uint32or64;
c: array[0..4] of TBGRAPixel;
i: Int32or64;
sumR, sumG, sumB, sumA, RGBdiv, Adiv: UInt32or64;
tempPixel, refPixel: TBGRAPixel;
pdest: PBGRAPixel;
bounds: TRect;
onHorizBorder: boolean;
psrc: array[-1..1] of PBGRAPixel;
begin
if IsRectEmpty(ABounds) then exit;
//compute pixel position and weight
dx := cos(angle * Pi / 180);
dy := sin(angle * Pi / 180);
idx1 := floor(dx);
idy1 := floor(dy);
idx2 := ceil(dx);
idy2 := ceil(dy);
idx3 := idx1;
idy3 := idy2;
idx4 := idx2;
idy4 := idy1;
w[1] := (1 - abs(idx1 - dx)) * (1 - abs(idy1 - dy));
w[2] := (1 - abs(idx2 - dx)) * (1 - abs(idy2 - dy));
w[3] := (1 - abs(idx3 - dx)) * (1 - abs(idy3 - dy));
w[4] := (1 - abs(idx4 - dx)) * (1 - abs(idy4 - dy));
//fill with gray
Result := bmp.NewBitmap(bmp.Width, bmp.Height);
Result.Fill(BGRA(128, 128, 128, 255));
bounds := bmp.GetImageBounds;
if not IntersectRect(bounds, bounds, ABounds) then exit;
bounds.Left := max(0, bounds.Left - 1);
bounds.Top := max(0, bounds.Top - 1);
bounds.Right := min(bmp.Width, bounds.Right + 1);
bounds.Bottom := min(bmp.Height, bounds.Bottom + 1);
//loop through destination
for yb := bounds.Top to bounds.bottom - 1 do
begin
pdest := Result.scanline[yb] + bounds.Left;
onHorizBorder:= (yb=0) or (yb=bmp.Height-1);
psrc[0] := bmp.ScanLine[yb]+bounds.Left;
if (yb>0) then psrc[-1] := bmp.ScanLine[yb-1]+bounds.Left else psrc[-1] := nil;
if (yb<bmp.Height-1) then psrc[1] := bmp.ScanLine[yb+1]+bounds.Left else psrc[1] := nil;
for xb := bounds.Left to bounds.Right - 1 do
begin
c[0] := psrc[0]^;
if onHorizBorder or (xb=0) or (xb=bmp.Width-1) then
begin
c[1] := bmp.getPixel(xb + idx1, yb + idy1);
c[2] := bmp.getPixel(xb + idx2, yb + idy2);
c[3] := bmp.getPixel(xb + idx3, yb + idy3);
c[4] := bmp.getPixel(xb + idx4, yb + idy4);
end else
begin
c[1] := (psrc[idy1]+idx1)^;
c[2] := (psrc[idy2]+idx2)^;
c[3] := (psrc[idy3]+idx3)^;
c[4] := (psrc[idy4]+idx4)^;
end;
sumR := 0;
sumG := 0;
sumB := 0;
sumA := 0;
Adiv := 0;
RGBdiv := 0;
//compute sum
{$hints off}
for i := 1 to 4 do
begin
tempPixel := c[i];
if tempPixel.alpha = 0 then
tempPixel := c[0];
iw := round(w[i] * tempPixel.alpha);
sumR += tempPixel.red * iw;
sumG += tempPixel.green * iw;
sumB += tempPixel.blue * iw;
RGBdiv += iw;
sumA += iw;
Adiv += round(w[i] * 255);
end;
{$hints on}
//average
if (Adiv = 0) or (RGBdiv = 0) then
refPixel := c[0]
else
begin
refPixel.red := (sumR + RGBdiv shr 1) div RGBdiv;
refPixel.green := (sumG + RGBdiv shr 1) div RGBdiv;
refPixel.blue := (sumB + RGBdiv shr 1) div RGBdiv;
refPixel.alpha := (sumA * 255 + Adiv shr 1) div Adiv;
end;
//difference with center pixel
{$hints off}
tempPixel.red := max(0, min(512 * 255, 65536 + refPixel.red *
refPixel.alpha - c[0].red * c[0].alpha)) shr 9;
tempPixel.green := max(0, min(512 * 255, 65536 + refPixel.green *
refPixel.alpha - c[0].green * c[0].alpha)) shr 9;
tempPixel.blue := max(0, min(512 * 255, 65536 + refPixel.blue *
refPixel.alpha - c[0].blue * c[0].alpha)) shr 9;
{$hints on}
tempPixel.alpha := 255;
pdest^ := tempPixel;
Inc(pdest);
inc(psrc[0]);
if psrc[-1] <> nil then inc(psrc[-1]);
if psrc[1] <> nil then inc(psrc[1]);
end;
end;
Result.InvalidateBitmap;
end;
{ Like general emboss, but with fixed direction and automatic color with transparency }
function FilterEmbossHighlight(bmp: TBGRACustomBitmap;
FillSelection: boolean; DefineBorderColor: TBGRAPixel): TBGRACustomBitmap;
var
yb, xb: Int32or64;
c0,c1,c2,c3,c4,c5,c6: Int32or64;
bmpWidth, bmpHeight: Int32or64;
slope, h: byte;
sum: Int32or64;
tempPixel, highlight: TBGRAPixel;
pdest, psrcUp, psrc, psrcDown: PBGRAPixel;
bounds: TRect;
borderColorOverride: boolean;
borderColorLevel: Int32or64;
currentBorderColor: Int32or64;
begin
borderColorOverride := DefineBorderColor.alpha <> 0;
borderColorLevel := DefineBorderColor.red;
bmpWidth := bmp.Width;
bmpHeight := bmp.Height;
Result := bmp.NewBitmap(bmpWidth, bmpHeight);
if borderColorOverride then
bounds := bmp.GetImageBounds(cRed, borderColorLevel)
else
bounds := bmp.GetImageBounds(cRed);
if (bounds.Right <= bounds.Left) or (bounds.Bottom <= Bounds.Top) then
exit;
bounds.Left := max(0, bounds.Left - 1);
bounds.Top := max(0, bounds.Top - 1);
bounds.Right := min(bmpWidth, bounds.Right + 1);
bounds.Bottom := min(bmpHeight, bounds.Bottom + 1);
currentBorderColor := borderColorLevel;
for yb := bounds.Top to bounds.Bottom - 1 do
begin
pdest := Result.scanline[yb] + bounds.Left;
if yb > 0 then
psrcUp := bmp.Scanline[yb - 1] + bounds.Left
else
psrcUp := nil;
psrc := bmp.scanline[yb] + bounds.Left;
if yb < bmpHeight - 1 then
psrcDown := bmp.scanline[yb + 1] + bounds.Left
else
psrcDown := nil;
for xb := bounds.Left to bounds.Right - 1 do
begin
c0 := pbyte(psrc)^;
if not borderColorOverride then currentBorderColor := c0;
if (xb = 0) then
begin
c1 := currentBorderColor;
c2 := currentBorderColor;
end
else
begin
if psrcUp <> nil then
c1 := pbyte(psrcUp - 1)^
else
c1 := currentBorderColor;
c2 := pbyte(psrc - 1)^;
end;
if psrcUp <> nil then
begin
c3 := pbyte(psrcUp)^;
Inc(psrcUp);
end
else
c3 := currentBorderColor;
if (xb = bmpWidth - 1) then
begin
c4 := currentBorderColor;
c5 := currentBorderColor;
end
else
begin
if psrcDown <> nil then
c4 := pbyte(psrcDown + 1)^
else
c4 := currentBorderColor;
c5 := pbyte(psrc + 1)^;
end;
if psrcDown <> nil then
begin
c6 := pbyte(psrcDown)^;
Inc(psrcDown);
end
else
c6 := currentBorderColor;
Inc(psrc);
sum := c4+c5+c6-c1-c2-c3;
sum := 128 + sum div 3;
if sum > 255 then
slope := 255
else
if sum < 1 then
slope := 1
else
slope := sum;
h := c0;
tempPixel.red := slope;
tempPixel.green := slope;
tempPixel.blue := slope;
tempPixel.alpha := abs(slope - 128) * 2;
if fillSelection then
begin
highlight := BGRA(h shr 2, h shr 1, h, h shr 1);
if tempPixel.red < highlight.red then
tempPixel.red := highlight.red;
if tempPixel.green < highlight.green then
tempPixel.green := highlight.green;
if tempPixel.blue < highlight.blue then
tempPixel.blue := highlight.blue;
if tempPixel.alpha < highlight.alpha then
tempPixel.alpha := highlight.alpha;
end;
pdest^ := tempPixel;
Inc(pdest);
end;
end;
Result.InvalidateBitmap;
end;
function FilterEmbossHighlightOffset(bmp: TBGRACustomBitmap;
FillSelection: boolean; DefineBorderColor: TBGRAPixel; var Offset: TPoint): TBGRACustomBitmap;
var
yb, xb: int32or64;
c0,c1,c2,c3,c4,c5,c6: int32or64;
bmpWidth, bmpHeight: int32or64;
slope, h: byte;
sum: int32or64;
tempPixel, highlight: TBGRAPixel;
pdest, psrcUp, psrc, psrcDown: PBGRAPixel;
bounds: TRect;
borderColorOverride: boolean;
borderColorLevel: int32or64;
currentBorderColor: int32or64;
begin
borderColorOverride := DefineBorderColor.alpha <> 0;
borderColorLevel := DefineBorderColor.red;
bmpWidth := bmp.Width;
bmpHeight := bmp.Height;
if borderColorOverride then
bounds := bmp.GetImageBounds(cRed, borderColorLevel)
else
bounds := bmp.GetImageBounds(cRed);
if (bounds.Right <= bounds.Left) or (bounds.Bottom <= Bounds.Top) then
begin
Result := bmp.NewBitmap(0, 0);
exit;
end;
bounds.Left := max(0, bounds.Left - 1);
bounds.Top := max(0, bounds.Top - 1);
bounds.Right := min(bmpWidth, bounds.Right + 1);
bounds.Bottom := min(bmpHeight, bounds.Bottom + 1);
Result := bmp.NewBitmap(bounds.Right-Bounds.Left+1, bounds.Bottom-Bounds.Top+1);
inc(Offset.X, bounds.Left);
inc(Offset.Y, bounds.Top);
currentBorderColor := borderColorLevel;
for yb := bounds.Top to bounds.Bottom - 1 do
begin
pdest := Result.scanline[yb-Bounds.Top];
if yb > 0 then
psrcUp := bmp.Scanline[yb - 1] + bounds.Left
else
psrcUp := nil;
psrc := bmp.scanline[yb] + bounds.Left;
if yb < bmpHeight - 1 then
psrcDown := bmp.scanline[yb + 1] + bounds.Left
else
psrcDown := nil;
for xb := bounds.Left to bounds.Right - 1 do
begin
c0 := pbyte(psrc)^;
if not borderColorOverride then currentBorderColor := c0;
if (xb = 0) then
begin
c1 := currentBorderColor;
c2 := currentBorderColor;
end
else
begin
if psrcUp <> nil then
c1 := pbyte(psrcUp - 1)^
else
c1 := currentBorderColor;
c2 := pbyte(psrc - 1)^;
end;
if psrcUp <> nil then
begin
c3 := pbyte(psrcUp)^;
Inc(psrcUp);
end
else
c3 := currentBorderColor;
if (xb = bmpWidth - 1) then
begin
c4 := currentBorderColor;
c5 := currentBorderColor;
end
else
begin
if psrcDown <> nil then
c4 := pbyte(psrcDown + 1)^
else
c4 := currentBorderColor;
c5 := pbyte(psrc + 1)^;
end;
if psrcDown <> nil then
begin
c6 := pbyte(psrcDown)^;
Inc(psrcDown);
end
else
c6 := currentBorderColor;
Inc(psrc);
sum := c4+c5+c6-c1-c2-c3;
sum := 128 + sum div 3;
if sum > 255 then
slope := 255
else
if sum < 1 then
slope := 1
else
slope := sum;
h := c0;
tempPixel.red := slope;
tempPixel.green := slope;
tempPixel.blue := slope;
tempPixel.alpha := abs(slope - 128) * 2;
if fillSelection then
begin
highlight := BGRA(h shr 2, h shr 1, h, h shr 1);
if tempPixel.red < highlight.red then
tempPixel.red := highlight.red;
if tempPixel.green < highlight.green then
tempPixel.green := highlight.green;
if tempPixel.blue < highlight.blue then
tempPixel.blue := highlight.blue;
if tempPixel.alpha < highlight.alpha then
tempPixel.alpha := highlight.alpha;
end;
pdest^ := tempPixel;
Inc(pdest);
end;
end;
Result.InvalidateBitmap;
end;
function FilterNormalize(bmp: TBGRACustomBitmap; eachChannel: boolean
): TBGRACustomBitmap;
begin
result := FilterNormalize(bmp, rect(0,0,bmp.Width,bmp.Height), eachChannel);
end;
{ Normalize compute min-max of specified channel and apply an affine transformation
to make it use the full range of values }
function FilterNormalize(bmp: TBGRACustomBitmap; ABounds: TRect;
eachChannel: boolean = True): TBGRACustomBitmap;
var
psrc, pdest: PBGRAPixel;
c: TExpandedPixel;
xcount,xb,yb: int32or64;
minValRed, maxValRed, minValGreen, maxValGreen, minValBlue, maxValBlue,
minAlpha, maxAlpha, addValRed, addValGreen, addValBlue, addAlpha: word;
factorValRed, factorValGreen, factorValBlue, factorAlpha: int32or64;
begin
if not IntersectRect(ABounds,ABounds,rect(0,0,bmp.Width,bmp.Height)) then exit;
Result := bmp.NewBitmap(bmp.Width, bmp.Height);
bmp.LoadFromBitmapIfNeeded;
maxValRed := 0;
minValRed := 65535;
maxValGreen := 0;
minValGreen := 65535;
maxValBlue := 0;
minValBlue := 65535;
maxAlpha := 0;
minAlpha := 65535;
xcount := ABounds.Right-ABounds.Left;
for yb := ABounds.Top to ABounds.Bottom-1 do
begin
psrc := bmp.ScanLine[yb]+ABounds.Left;
for xb := xcount-1 downto 0 do
begin
c := GammaExpansion(psrc^);
Inc(psrc);
if c.red > maxValRed then
maxValRed := c.red;
if c.green > maxValGreen then
maxValGreen := c.green;
if c.blue > maxValBlue then
maxValBlue := c.blue;
if c.red < minValRed then
minValRed := c.red;
if c.green < minValGreen then
minValGreen := c.green;
if c.blue < minValBlue then
minValBlue := c.blue;
if c.alpha > maxAlpha then
maxAlpha := c.alpha;
if c.alpha < minAlpha then
minAlpha := c.alpha;
end;
end;
if not eachChannel then
begin
minValRed := min(min(minValRed, minValGreen), minValBlue);
maxValRed := max(max(maxValRed, maxValGreen), maxValBlue);
minValGreen := minValRed;
maxValGreen := maxValRed;
minValBlue := minValBlue;
maxValBlue := maxValBlue;
end;
if maxValRed > minValRed then
begin
factorValRed := 268431360 div (maxValRed - minValRed);
addValRed := 0;
end
else
begin
factorValRed := 0;
if minValRed = 0 then
addValRed := 0
else
addValRed := 65535;
end;
if maxValGreen > minValGreen then
begin
factorValGreen := 268431360 div (maxValGreen - minValGreen);
addValGreen := 0;
end
else
begin
factorValGreen := 0;
if minValGreen = 0 then
addValGreen := 0
else
addValGreen := 65535;
end;
if maxValBlue > minValBlue then
begin
factorValBlue := 268431360 div (maxValBlue - minValBlue);
addValBlue := 0;
end
else
begin
factorValBlue := 0;
if minValBlue = 0 then
addValBlue := 0
else
addValBlue := 65535;
end;
if maxAlpha > minAlpha then
begin
factorAlpha := 268431360 div (maxAlpha - minAlpha);
addAlpha := 0;
end
else
begin
factorAlpha := 0;
if minAlpha = 0 then
addAlpha := 0
else
addAlpha := 65535;
end;
for yb := ABounds.Top to ABounds.Bottom-1 do
begin
psrc := bmp.ScanLine[yb]+ABounds.Left;
pdest := Result.ScanLine[yb]+ABounds.Left;
for xb := xcount-1 downto 0 do
begin
c := GammaExpansion(psrc^);
Inc(psrc);
c.red := ((c.red - minValRed) * factorValRed + 2047) shr 12 + addValRed;
c.green := ((c.green - minValGreen) * factorValGreen + 2047) shr 12 + addValGreen;
c.blue := ((c.blue - minValBlue) * factorValBlue + 2047) shr 12 + addValBlue;
c.alpha := ((c.alpha - minAlpha) * factorAlpha + 2047) shr 12 + addAlpha;
pdest^ := GammaCompression(c);
Inc(pdest);
end;
end;
Result.InvalidateBitmap;
end;
{ Rotates the image. To do this, loop through the destination and
calculates the position in the source bitmap with an affine transformation }
function FilterRotate(bmp: TBGRACustomBitmap; origin: TPointF;
angle: single): TBGRACustomBitmap;
var
bounds: TRect;
pdest: PBGRAPixel;
xsrc, ysrc: single;
savexysrc, pt: TPointF;
dx, dy: single;
xb, yb: int32or64;
minx, miny, maxx, maxy: single;
function RotatePos(x, y: single): TPointF;
var
px, py: single;
begin
px := x - origin.x;
py := y - origin.y;
Result := PointF(origin.x + px * dx + py * dy, origin.y - px * dy + py * dx);
end;
begin
Result := bmp.NewBitmap(bmp.Width, bmp.Height);
bounds := bmp.GetImageBounds;
if (bounds.Right <= bounds.Left) or (bounds.Bottom <= Bounds.Top) then
exit;
//compute new bounding rectangle
dx := cos(angle * Pi / 180);
dy := -sin(angle * Pi / 180);
pt := RotatePos(bounds.left, bounds.top);
minx := pt.x;
miny := pt.y;
maxx := pt.x;
maxy := pt.y;
pt := RotatePos(bounds.Right - 1, bounds.top);
if pt.x < minx then
minx := pt.x
else
if pt.x > maxx then
maxx := pt.x;
if pt.y < miny then
miny := pt.y
else
if pt.y > maxy then
maxy := pt.y;
pt := RotatePos(bounds.Right - 1, bounds.bottom - 1);
if pt.x < minx then
minx := pt.x
else
if pt.x > maxx then
maxx := pt.x;
if pt.y < miny then
miny := pt.y
else
if pt.y > maxy then
maxy := pt.y;
pt := RotatePos(bounds.left, bounds.bottom - 1);
if pt.x < minx then
minx := pt.x
else
if pt.x > maxx then
maxx := pt.x;
if pt.y < miny then
miny := pt.y
else
if pt.y > maxy then
maxy := pt.y;
bounds.left := max(0, floor(minx));
bounds.top := max(0, floor(miny));
bounds.right := min(bmp.Width, ceil(maxx) + 1);
bounds.bottom := min(bmp.Height, ceil(maxy) + 1);
//reciproqual
dy := -dy;
pt := RotatePos(bounds.left, bounds.top);
xsrc := pt.x;
ysrc := pt.y;
for yb := bounds.Top to bounds.bottom - 1 do
begin
pdest := Result.scanline[yb] + bounds.left;
savexysrc := pointf(xsrc, ysrc);
for xb := bounds.left to bounds.right - 1 do
begin
pdest^ := bmp.GetPixel(xsrc, ysrc);
Inc(pdest);
xsrc += dx;
ysrc -= dy;
end;
xsrc := savexysrc.x + dy;
ysrc := savexysrc.y + dx;
end;
Result.InvalidateBitmap;
end;
{ Filter grayscale applies BGRAToGrayscale function to all pixels }
procedure FilterGrayscale(bmp: TBGRACustomBitmap; ABounds: TRect; ADestination: TBGRACustomBitmap; ACheckShouldStop: TCheckShouldStopFunc);
var
pdest, psrc: PBGRAPixel;
xb, yb: int32or64;
begin
if IsRectEmpty(ABounds) then exit;
for yb := ABounds.Top to ABounds.bottom - 1 do
begin
if Assigned(ACheckShouldStop) and ACheckShouldStop() then break;
pdest := ADestination.scanline[yb] + ABounds.left;
psrc := bmp.scanline[yb] + ABounds.left;
for xb := ABounds.left to ABounds.right - 1 do
begin
pdest^ := BGRAToGrayscale(psrc^);
Inc(pdest);
Inc(psrc);
end;
end;
ADestination.InvalidateBitmap;
end;
function FilterGrayscale(bmp: TBGRACustomBitmap): TBGRACustomBitmap;
begin
result := FilterGrayscale(bmp, rect(0,0,bmp.width,bmp.Height));
end;
function FilterGrayscale(bmp: TBGRACustomBitmap; ABounds: TRect): TBGRACustomBitmap;
begin
result := bmp.NewBitmap(bmp.Width,bmp.Height);
FilterGrayscale(bmp,ABounds,result,nil);
end;
function CreateGrayscaleTask(bmp: TBGRACustomBitmap; ABounds: TRect
): TFilterTask;
begin
result := TGrayscaleTask.Create(bmp,ABounds);
end;
{ Filter contour compute a grayscale image, then for each pixel
calculates the difference with surrounding pixels (in intensity and alpha)
and draw black pixels when there is a difference }
function FilterContour(bmp: TBGRACustomBitmap): TBGRACustomBitmap;
var
yb, xb: int32or64;
c: array[0..8] of TBGRAPixel;
i, bmpWidth, bmpHeight: int32or64;
slope: byte;
sum: int32or64;
tempPixel: TBGRAPixel;
pdest, psrcUp, psrc, psrcDown: PBGRAPixel;
bounds: TRect;
gray: TBGRACustomBitmap;
begin
bmpWidth := bmp.Width;
bmpHeight := bmp.Height;
Result := bmp.NewBitmap(bmpWidth, bmpHeight);
gray := bmp.FilterGrayscale;
bounds := rect(0, 0, bmp.Width, bmp.Height);
for yb := bounds.Top to bounds.Bottom - 1 do
begin
pdest := Result.scanline[yb] + bounds.Left;
if yb > 0 then
psrcUp := gray.Scanline[yb - 1] + bounds.Left
else
psrcUp := nil;
psrc := gray.scanline[yb] + bounds.Left;
if yb < bmpHeight - 1 then
psrcDown := gray.scanline[yb + 1] + bounds.Left
else
psrcDown := nil;
for xb := bounds.Left to bounds.Right - 1 do
begin
c[0] := psrc^;
if (xb = 0) then
begin
c[1] := c[0];
c[2] := c[0];
c[4] := c[0];
end
else
begin
if psrcUp <> nil then
c[1] := (psrcUp - 1)^
else
c[1] := c[0];
c[2] := (psrc - 1)^;
if psrcDown <> nil then
c[4] := (psrcDown - 1)^
else
c[4] := c[0];
end;
if psrcUp <> nil then
begin
c[3] := psrcUp^;
Inc(psrcUp);
end
else
c[3] := c[0];
if (xb = bmpWidth - 1) then
begin
c[5] := c[0];
c[6] := c[0];
c[8] := c[0];
end
else
begin
if psrcDown <> nil then
c[5] := (psrcDown + 1)^
else
c[5] := c[0];
c[6] := (psrc + 1)^;
if psrcUp <> nil then
c[8] := psrcUp^
else //+1 before
c[8] := c[0];
end;
if psrcDown <> nil then
begin
c[7] := psrcDown^;
Inc(psrcDown);
end
else
c[7] := c[0];
Inc(psrc);
sum := 0;
for i := 1 to 4 do
sum += abs(c[i].red - c[i + 4].red) + abs(c[i].alpha - c[i + 4].alpha);
if sum > 255 then
slope := 255
else
if sum < 0 then
slope := 0
else
slope := sum;
tempPixel.red := 255 - slope;
tempPixel.green := 255 - slope;
tempPixel.blue := 255 - slope;
tempPixel.alpha := 255;
pdest^ := tempPixel;
Inc(pdest);
end;
end;
Result.InvalidateBitmap;
gray.Free;
end;
{ Compute the distance for each pixel to the center of the bitmap,
calculate the corresponding angle with arcsin, use this angle
to determine a distance from the center in the source bitmap }
function FilterSphere(bmp: TBGRACustomBitmap): TBGRACustomBitmap;
var
cx, cy, x, y, len, fact: single;
xb, yb: int32or64;
mask: TBGRACustomBitmap;
begin
Result := bmp.NewBitmap(bmp.Width, bmp.Height);
cx := bmp.Width / 2 - 0.5;
cy := bmp.Height / 2 - 0.5;
for yb := 0 to Result.Height - 1 do
for xb := 0 to Result.Width - 1 do
begin
x := (xb - cx) / (cx + 0.5);
y := (yb - cy) / (cy + 0.5);
len := sqrt(sqr(x) + sqr(y));
if (len <= 1) then
begin
if (len > 0) then
begin
fact := 1 / len * arcsin(len) / (Pi / 2);
x *= fact;
y *= fact;
end;
Result.setpixel(xb, yb, bmp.Getpixel(x * cx + cx, y * cy + cy));
end;
end;
mask := bmp.NewBitmap(bmp.Width, bmp.Height);
Mask.Fill(BGRABlack);
Mask.FillEllipseAntialias(cx, cy, cx, cy, BGRAWhite);
Result.ApplyMask(mask);
Mask.Free;
end;
{ Applies twirl scanner. See TBGRATwirlScanner }
function FilterTwirl(bmp: TBGRACustomBitmap; ABounds: TRect; ACenter: TPoint; ARadius: Single; ATurn: Single=1; AExponent: Single=3): TBGRACustomBitmap;
var twirl: TBGRATwirlScanner;
begin
twirl := TBGRATwirlScanner.Create(bmp,ACenter,ARadius,ATurn,AExponent);
Result := bmp.NewBitmap(bmp.Width, bmp.Height);
result.FillRect(ABounds, twirl, dmSet);
twirl.free;
end;
function FilterTwirl(bmp: TBGRACustomBitmap; ACenter: TPoint;
ARadius: Single; ATurn: Single; AExponent: Single): TBGRACustomBitmap;
begin
result := FilterTwirl(bmp,rect(0,0,bmp.Width,bmp.Height),ACenter,ARadius,ATurn,AExponent);
end;
{ Compute the distance for each pixel to the vertical axis of the bitmap,
calculate the corresponding angle with arcsin, use this angle
to determine a distance from the vertical axis in the source bitmap }
function FilterCylinder(bmp: TBGRACustomBitmap): TBGRACustomBitmap;
var
cx, cy, x, y, len, fact: single;
xb, yb: int32or64;
begin
Result := bmp.NewBitmap(bmp.Width, bmp.Height);
cx := bmp.Width / 2 - 0.5;
cy := bmp.Height / 2 - 0.5;
for yb := 0 to Result.Height - 1 do
for xb := 0 to Result.Width - 1 do
begin
x := (xb - cx) / (cx + 0.5);
y := (yb - cy) / (cy + 0.5);
len := abs(x);
if (len <= 1) then
begin
if (len > 0) then
begin
fact := 1 / len * arcsin(len) / (Pi / 2);
x *= fact;
end;
Result.setpixel(xb, yb, bmp.Getpixel(x * cx + cx, y * cy + cy));
end;
end;
end;
function FilterPlane(bmp: TBGRACustomBitmap): TBGRACustomBitmap;
const resampleGap=0.6;
var
cy, x1, x2, y1, y2, z1, z2, h: single;
yb: int32or64;
resampledBmp: TBGRACustomBitmap;
resampledBmpWidth: int32or64;
resampledFactor,newResampleFactor: single;
sub,resampledSub: TBGRACustomBitmap;
partRect: TRect;
resampleSizeY : int32or64;
begin
resampledBmp := bmp.Resample(bmp.Width*2,bmp.Height*2,rmSimpleStretch);
resampledBmpWidth := resampledBmp.Width;
resampledFactor := 2;
Result := bmp.NewBitmap(bmp.Width, bmp.Height*2);
cy := result.Height / 2 - 0.5;
h := 1;
for yb := 0 to ((Result.Height-1) div 2) do
begin
y1 := (cy - (yb-0.5)) / (cy+0.5);
y2 := (cy - (yb+0.5)) / (cy+0.5);
if y2 <= 0 then continue;
z1 := h/y1;
z2 := h/y2;
newResampleFactor := 1/(z2-z1)*1.5;
x1 := (z1+1)/2;
x2 := (z2+1)/2;
if newResampleFactor <= resampledFactor*resampleGap then
begin
resampledFactor := newResampleFactor;
if resampledBmp <> bmp then resampledBmp.Free;
if (x2-x1 >= 1) then resampleSizeY := 1 else
resampleSizeY := round(1+((x2-x1)-1)/(1/bmp.Height-1)*(bmp.Height-1));
resampledBmp := bmp.Resample(max(1,round(bmp.Width*resampledFactor)),resampleSizeY,rmSimpleStretch);
resampledBmpWidth := resampledBmp.Width;
end;
partRect := Rect(round(-resampledBmpWidth/2*z1+resampledBmpWidth/2),floor(x1*resampledBmp.Height),
round(resampledBmpWidth/2*z1+resampledBmpWidth/2),floor(x2*resampledBmp.Height)+1);
if x2-x1 > 1 then
begin
partRect.Top := 0;
partRect.Bottom := 1;
end;
sub := resampledBmp.GetPart(partRect);
if sub <> nil then
begin
resampledSub := sub.Resample(bmp.Width,1,rmFineResample);
result.PutImage(0,yb,resampledSub,dmSet);
result.PutImage(0,Result.Height-1-yb,resampledSub,dmSet);
resampledSub.free;
sub.free;
end;
end;
if resampledBmp <> bmp then resampledBmp.Free;
if result.Height <> bmp.Height then
begin
resampledBmp := result.Resample(bmp.Width,bmp.Height,rmSimpleStretch);
result.free;
result := resampledBmp;
end;
end;
{ For each component, sort values to get the median }
function FilterMedian(bmp: TBGRACustomBitmap;
Option: TMedianOption): TBGRACustomBitmap;
function ComparePixLt(p1, p2: TBGRAPixel): boolean;
begin
if (p1.red + p1.green + p1.blue = p2.red + p2.green + p2.blue) then
Result := (int32or64(p1.red) shl 8) + (int32or64(p1.green) shl 16) +
int32or64(p1.blue) < (int32or64(p2.red) shl 8) + (int32or64(p2.green) shl 16) +
int32or64(p2.blue)
else
Result := (p1.red + p1.green + p1.blue) < (p2.red + p2.green + p2.blue);
end;
const
nbpix = 9;
var
yb, xb: int32or64;
dx, dy, n, i, j, k: int32or64;
a_pixels: array[0..nbpix - 1] of TBGRAPixel;
tempPixel, refPixel: TBGRAPixel;
tempValue: byte;
sumR, sumG, sumB, sumA, BGRAdiv, nbA: uint32or64;
tempAlpha: word;
bounds: TRect;
pdest: PBGRAPixel;
begin
Result := bmp.NewBitmap(bmp.Width, bmp.Height);
bounds := bmp.GetImageBounds;
if (bounds.Right <= bounds.Left) or (bounds.Bottom <= Bounds.Top) then
exit;
bounds.Left := max(0, bounds.Left - 1);
bounds.Top := max(0, bounds.Top - 1);
bounds.Right := min(bmp.Width, bounds.Right + 1);
bounds.Bottom := min(bmp.Height, bounds.Bottom + 1);
for yb := bounds.Top to bounds.bottom - 1 do
begin
pdest := Result.scanline[yb] + bounds.left;
for xb := bounds.left to bounds.right - 1 do
begin
n := 0;
for dy := -1 to 1 do
for dx := -1 to 1 do
begin
a_pixels[n] := bmp.GetPixel(xb + dx, yb + dy);
if a_pixels[n].alpha = 0 then
a_pixels[n] := BGRAPixelTransparent;
Inc(n);
end;
for i := 1 to n - 1 do
begin
j := i;
while (j > 1) and (a_pixels[j].alpha < a_pixels[j - 1].alpha) do
begin
tempValue := a_pixels[j].alpha;
a_pixels[j].alpha := a_pixels[j - 1].alpha;
a_pixels[j - 1].alpha := tempValue;
Dec(j);
end;
j := i;
while (j > 1) and (a_pixels[j].red < a_pixels[j - 1].red) do
begin
tempValue := a_pixels[j].red;
a_pixels[j].red := a_pixels[j - 1].red;
a_pixels[j - 1].red := tempValue;
Dec(j);
end;
j := i;
while (j > 1) and (a_pixels[j].green < a_pixels[j - 1].green) do
begin
tempValue := a_pixels[j].green;
a_pixels[j].green := a_pixels[j - 1].green;
a_pixels[j - 1].green := tempValue;
Dec(j);
end;
j := i;
while (j > 1) and (a_pixels[j].blue < a_pixels[j - 1].blue) do
begin
tempValue := a_pixels[j].blue;
a_pixels[j].blue := a_pixels[j - 1].blue;
a_pixels[j - 1].blue := tempValue;
Dec(j);
end;
end;
refPixel := a_pixels[n div 2];
if option in [moLowSmooth, moMediumSmooth, moHighSmooth] then
begin
sumR := 0;
sumG := 0;
sumB := 0;
sumA := 0;
BGRAdiv := 0;
nbA := 0;
case option of
moHighSmooth, moMediumSmooth:
begin
j := 2;
k := 2;
end;
else
begin
j := 1;
k := 1;
end;
end;
{$hints off}
for i := -k to j do
begin
tempPixel := a_pixels[n div 2 + i];
tempAlpha := tempPixel.alpha;
if (option = moMediumSmooth) and ((i = -k) or (i = j)) then
tempAlpha := tempAlpha div 2;
sumR += tempPixel.red * tempAlpha;
sumG += tempPixel.green * tempAlpha;
sumB += tempPixel.blue * tempAlpha;
BGRAdiv += tempAlpha;
sumA += tempAlpha;
Inc(nbA);
end;
{$hints on}
if option = moMediumSmooth then
Dec(nbA);
if (BGRAdiv = 0) then
refPixel := BGRAPixelTransparent
else
begin
refPixel.red := round(sumR / BGRAdiv);
refPixel.green := round(sumG / BGRAdiv);
refPixel.blue := round(sumB / BGRAdiv);
refPixel.alpha := round(sumA / nbA);
end;
end;
pdest^ := refPixel;
Inc(pdest);
end;
end;
end;
constructor TGrayscaleTask.Create(bmp: TBGRACustomBitmap; ABounds: TRect);
begin
FSource := bmp;
FBounds := ABounds;
end;
procedure TGrayscaleTask.DoExecute;
begin
FilterGrayscale(FSource,FBounds,Destination,@GetShouldStop);
end;
{ TCustomBlurTask }
constructor TCustomBlurTask.Create(bmp: TBGRACustomBitmap; ABounds: TRect;
AMask: TBGRACustomBitmap);
begin
FSource := bmp;
FBounds := ABounds;
FMask := AMask;
end;
procedure TCustomBlurTask.DoExecute;
begin
FilterBlur(FSource,FBounds,FMask,Destination,@GetShouldStop);
end;
constructor TMotionBlurTask.Create(ABmp: TBGRACustomBitmap; ABounds: TRect;
ADistance, AAngle: single; AOriented: boolean);
begin
FSource := ABmp;
FBounds := ABounds;
FDistance := ADistance;
FAngle := AAngle;
FOriented:= AOriented;
end;
procedure TMotionBlurTask.DoExecute;
begin
FilterBlurMotion(FSource,FBounds,FDistance,FAngle,FOriented,Destination,@GetShouldStop);
end;
constructor TRadialPreciseBlurTask.Create(bmp: TBGRACustomBitmap;
ABounds: TRect; radius: single);
begin
FSource := bmp;
FBounds := ABounds;
FRadius := radius;
end;
procedure TRadialPreciseBlurTask.DoExecute;
begin
FilterBlurRadialPrecise(FSource,FBounds,FRadius,Destination,@GetShouldStop);
end;
{ TRadialBlurTask }
constructor TRadialBlurTask.Create(bmp: TBGRACustomBitmap; ABounds: TRect;
radius: integer; blurType: TRadialBlurType);
begin
FSource := bmp;
FBounds := ABounds;
FRadius := radius;
FBlurType:= blurType;
end;
procedure TRadialBlurTask.DoExecute;
begin
FilterBlurRadial(FSource,FBounds,FRadius,FBlurType,Destination,@GetShouldStop);
end;
{ TFilterTask }
function TFilterTask.GetShouldStop: boolean;
begin
if Assigned(FCheckShouldStop) then
result := FCheckShouldStop()
else
result := false;
end;
function TFilterTask.Execute: TBGRACustomBitmap;
var DestinationOwned: boolean;
begin
if Destination = nil then
begin
FDestination := FSource.NewBitmap(FSource.Width,FSource.Height);
DestinationOwned:= true;
end else
DestinationOwned:= false;
try
DoExecute;
result := Destination;
FDestination := nil;
except
on ex: exception do
begin
if DestinationOwned then FreeAndNil(FDestination);
raise ex;
end;
end;
end;
procedure TFilterTask.SetDestination(AValue: TBGRACustomBitmap);
begin
if FDestination <> nil then
raise exception.Create('Destination is already defined');
FDestination := AValue;
end;
end.
| 30.610421 | 157 | 0.647048 |
853d23ce2caeb8b426a6ca9e51978fefdebb3d11 | 580 | pas | Pascal | Klassen/Cryptography.pas | pFmuegge/PwMngDelphi | fa0fcf573e667466d7825bb9de1143eca3a31c20 | [
"Unlicense"
]
| null | null | null | Klassen/Cryptography.pas | pFmuegge/PwMngDelphi | fa0fcf573e667466d7825bb9de1143eca3a31c20 | [
"Unlicense"
]
| null | null | null | Klassen/Cryptography.pas | pFmuegge/PwMngDelphi | fa0fcf573e667466d7825bb9de1143eca3a31c20 | [
"Unlicense"
]
| null | null | null | unit Cryptography;
interface
uses
System.Classes, System.SysUtils;
type
TCrypter = class
private
public
constructor Create(AOwner: TComponent);
destructor Destroy; override;
function encrypt(AText: string): string;
function decrypt(AText: string): string;
end;
implementation
{ TCrypter }
{ TCrypter }
constructor TCrypter.Create(AOwner: TComponent);
begin
end;
function TCrypter.decrypt(AText: string): string;
begin
end;
destructor TCrypter.Destroy;
begin
inherited;
end;
function TCrypter.encrypt(AText: string): string;
begin
end;
end.
| 13.488372 | 49 | 0.743103 |
478dd8e043acfcada552acb488a6095a2ef49f90 | 1,861 | pas | Pascal | Source/Services/SimpleEmail/Base/Transform/AWS.SES.Transform.ListVerifiedEmailAddressesRequestMarshaller.pas | herux/aws-sdk-delphi | 4ef36e5bfc536b1d9426f78095d8fda887f390b5 | [
"Apache-2.0"
]
| 67 | 2021-07-28T23:47:09.000Z | 2022-03-15T11:48:35.000Z | Source/Services/SimpleEmail/Base/Transform/AWS.SES.Transform.ListVerifiedEmailAddressesRequestMarshaller.pas | gabrielbaltazar/aws-sdk-delphi | ea1713b227a49cbbc5a2e1bf04cbf2de1f9b611a | [
"Apache-2.0"
]
| 5 | 2021-09-01T09:31:16.000Z | 2022-03-16T18:19:21.000Z | Source/Services/SimpleEmail/Base/Transform/AWS.SES.Transform.ListVerifiedEmailAddressesRequestMarshaller.pas | gabrielbaltazar/aws-sdk-delphi | ea1713b227a49cbbc5a2e1bf04cbf2de1f9b611a | [
"Apache-2.0"
]
| 13 | 2021-07-29T02:41:16.000Z | 2022-03-16T10:22:38.000Z | unit AWS.SES.Transform.ListVerifiedEmailAddressesRequestMarshaller;
interface
uses
AWS.Internal.Request,
AWS.Transform.RequestMarshaller,
AWS.Runtime.Model,
AWS.SES.Model.ListVerifiedEmailAddressesRequest,
AWS.Internal.DefaultRequest;
type
IListVerifiedEmailAddressesRequestMarshaller = IMarshaller<IRequest, TAmazonWebServiceRequest>;
TListVerifiedEmailAddressesRequestMarshaller = class(TInterfacedObject, IMarshaller<IRequest, TListVerifiedEmailAddressesRequest>, IListVerifiedEmailAddressesRequestMarshaller)
strict private
class var FInstance: IListVerifiedEmailAddressesRequestMarshaller;
class constructor Create;
public
function Marshall(AInput: TAmazonWebServiceRequest): IRequest; overload;
function Marshall(PublicRequest: TListVerifiedEmailAddressesRequest): IRequest; overload;
class function Instance: IListVerifiedEmailAddressesRequestMarshaller; static;
end;
implementation
{ TListVerifiedEmailAddressesRequestMarshaller }
function TListVerifiedEmailAddressesRequestMarshaller.Marshall(AInput: TAmazonWebServiceRequest): IRequest;
begin
Result := Marshall(TListVerifiedEmailAddressesRequest(AInput));
end;
function TListVerifiedEmailAddressesRequestMarshaller.Marshall(PublicRequest: TListVerifiedEmailAddressesRequest): IRequest;
var
Request: IRequest;
begin
Request := TDefaultRequest.Create(PublicRequest, 'Amazon.SimpleEmail');
Request.Parameters.Add('Action', 'ListVerifiedEmailAddresses');
Request.Parameters.Add('Version', '2010-12-01');
Result := Request;
end;
class constructor TListVerifiedEmailAddressesRequestMarshaller.Create;
begin
FInstance := TListVerifiedEmailAddressesRequestMarshaller.Create;
end;
class function TListVerifiedEmailAddressesRequestMarshaller.Instance: IListVerifiedEmailAddressesRequestMarshaller;
begin
Result := FInstance;
end;
end.
| 33.836364 | 178 | 0.839334 |
4712908c9b5633fa05668a17c098e2675360c19b | 1,174 | pas | Pascal | Rootkits/vault/admin/ce54releasesvn/frmBreakThreadUnit.pas | dendisuhubdy/grokmachine | 120a21a25c2730ed356739231ec8b99fc0575c8b | [
"BSD-3-Clause"
]
| 46 | 2017-05-15T11:15:08.000Z | 2018-07-02T03:32:52.000Z | Rootkits/vault/admin/ce54releasesvn/frmBreakThreadUnit.pas | dendisuhubdy/grokmachine | 120a21a25c2730ed356739231ec8b99fc0575c8b | [
"BSD-3-Clause"
]
| null | null | null | Rootkits/vault/admin/ce54releasesvn/frmBreakThreadUnit.pas | dendisuhubdy/grokmachine | 120a21a25c2730ed356739231ec8b99fc0575c8b | [
"BSD-3-Clause"
]
| 24 | 2017-05-17T03:26:17.000Z | 2018-07-09T07:00:50.000Z | unit frmBreakThreadUnit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,debugger;
type
Tfrmbreakthread = class(TForm)
Label1: TLabel;
Threadlistbox: TListBox;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
threadhandle: thandle;
end;
var
frmbreakthread: Tfrmbreakthread;
implementation
{$R *.dfm}
procedure Tfrmbreakthread.Button1Click(Sender: TObject);
begin
if threadlistbox.ItemIndex<>-1 then
begin
threadhandle:=debuggerthread.threadlist[threadlistbox.ItemIndex,1];
modalresult:=mrok;
end
else raise exception.Create('Please select a thread before clicking on OK');
end;
procedure Tfrmbreakthread.FormCreate(Sender: TObject);
var i: integer;
begin
threadlistbox.clear;
//fill the threadlistbox
with debuggerthread do
begin
for i:=0 to length(threadlist)-1 do
threadlistbox.Items.Add(inttohex(threadlist[i,0],8));
end;
end;
end.
| 21.740741 | 79 | 0.704429 |
47be596c7865198816646e84cbfb7976517701f7 | 1,362 | pas | Pascal | delphi/0092.pas | nickelsworth/swag | 7c21c0da2291fc249b9dc5cfe121a7672a4ffc08 | [
"BSD-2-Clause"
]
| 11 | 2015-12-12T05:13:15.000Z | 2020-10-14T13:32:08.000Z | delphi/0092.pas | nickelsworth/swag | 7c21c0da2291fc249b9dc5cfe121a7672a4ffc08 | [
"BSD-2-Clause"
]
| null | null | null | delphi/0092.pas | nickelsworth/swag | 7c21c0da2291fc249b9dc5cfe121a7672a4ffc08 | [
"BSD-2-Clause"
]
| 8 | 2017-05-05T05:24:01.000Z | 2021-07-03T20:30:09.000Z |
program ExDelphi;
{executes Delphi, minimizing all apps currently running}
uses
WinProcs, WinTypes, Messages;
var
ExResult: integer;
ExResultSt: string;
function EnumProc (WinHandle: HWnd; Param: LongInt): Boolean;
far;
begin
if (GetParent (WinHandle) = 0) and (not IsIconic (WinHandle))
and
(IsWindowVisible (WinHandle)) then
begin
SendMessage (WinHandle, WM_SYSCOMMAND, SC_MINIMIZE, 0);
end; { if...}
EnumProc := TRUE;
end; { EnumProc }
begin {ExDelphi}
EnumWindows(@EnumProc, 0);
ExResult := WinExec ('DELPHI.EXE', SW_SHOW);
if ExResult < 32 then
begin
Str(ExResult, ExResultSt);
ExResultSt := 'Error Loading Delphi : ' + ExResultSt + #0;
MessageBox (0, @ExResultSt[1], 'EDS ExDelphi Loader',
mb_OK or mb_IconInformation);
end; {if...}
end. {ExDelphi}
------------------------------------------------------------------
not too big of a program but supposed to be cool. will minimize all
windows as it executes delphi.
Well, it compiles and works for me. What you have to do is:
- open a new project;
- close form1 and unit1;
- open the project source;
- paste the whole code above over what is already there;
- save the project as exdelphi.DPR;
- build. {result is an EXE of 4K}
| 29.608696 | 69 | 0.606461 |
fc22899e52aa880b17a943c8aeedf4a2c5133546 | 464 | dpr | Pascal | Samples/Component Demo/DemoReader.dpr | devgijbels/swelio-delphi | 1439de058d103216a0c33759a46a523d450f4302 | [
"MIT"
]
| 2 | 2021-07-01T07:59:44.000Z | 2021-11-16T14:01:14.000Z | Samples/Component Demo/DemoReader.dpr | devgijbels/swelio-delphi | 1439de058d103216a0c33759a46a523d450f4302 | [
"MIT"
]
| 4 | 2021-09-30T10:50:27.000Z | 2022-03-07T19:15:08.000Z | Samples/Component Demo/DemoReader.dpr | devgijbels/swelio-delphi | 1439de058d103216a0c33759a46a523d450f4302 | [
"MIT"
]
| 3 | 2021-11-16T13:58:43.000Z | 2022-03-07T18:42:42.000Z | program DemoReader;
uses
Forms,
frm_main in 'frm_main.pas' {frmMain},
EidFormatter in '..\..\..\Binding\Delphi\EidFormatter.pas',
EidReader in '..\..\..\Binding\Delphi\EidReader.pas',
SwelioEngine in '..\..\..\Binding\Delphi\SwelioEngine.pas',
SwelioTypes in '..\..\..\Binding\Delphi\SwelioTypes.pas';
{$R *.RES}
begin
Application.Initialize;
Application.Title := 'EID Demo';
Application.CreateForm(TfrmMain, frmMain);
Application.Run;
end.
| 24.421053 | 61 | 0.689655 |
fc5f5f5497a1530c99d0af386664fc8b645b75ef | 589 | pas | Pascal | src/Tests/test18.pas | Coopercjc/Haskell-Pascal-Interpreter | 1bf51617d79832e70938d4b8c7810a3fea609b0a | [
"MIT"
]
| 1 | 2020-03-29T13:59:38.000Z | 2020-03-29T13:59:38.000Z | src/Tests/test18.pas | Coopercjc/Haskell-Pascal-Interpreter | 1bf51617d79832e70938d4b8c7810a3fea609b0a | [
"MIT"
]
| null | null | null | src/Tests/test18.pas | Coopercjc/Haskell-Pascal-Interpreter | 1bf51617d79832e70938d4b8c7810a3fea609b0a | [
"MIT"
]
| null | null | null | program mytest;
VAR
c, j : real = 13;
r : real = 6;
q : real = 2;
k, l : boolean = true;
start : real = 18;
function caser(num1, num2: real; condit: boolean): real;
VAR
result : real;
BEGIN
if (condit) then
case (num1) of
6 : writeln('YOU FOUND ME');
else
writeln('Move along.');
END;
result := 6;
else
result := num2
caser := result;
END;
BEGIN
writeln('This is the start of test ', start);
writeln('Q is now ', q);
q := caser(r,j,k);
writeln('Q is now ', q);
END; | 16.361111 | 56 | 0.500849 |
839b10d40ae54842b8ca02604c62976083e708da | 194 | pas | Pascal | PascalCompiler/Tests/Optimizer/UnreachableCode/03.pas | GoldFeniks/PascalCompiler | 4a7325c385c133dd360eaba06bebaedd30b4078d | [
"MIT"
]
| 2 | 2018-07-06T09:50:57.000Z | 2019-10-06T12:57:57.000Z | PascalCompiler/Tests/Optimizer/UnreachableCode/03.pas | GoldFeniks/PascalCompiler | 4a7325c385c133dd360eaba06bebaedd30b4078d | [
"MIT"
]
| null | null | null | PascalCompiler/Tests/Optimizer/UnreachableCode/03.pas | GoldFeniks/PascalCompiler | 4a7325c385c133dd360eaba06bebaedd30b4078d | [
"MIT"
]
| null | null | null | program test;
var
i: integer;
begin
i := 3;
repeat
write('Once');
i := i - 1;
break;
until i = 0;
repeat
write('Twice');
i := i - 1;
until i = 0;
end. | 12.933333 | 19 | 0.453608 |
8590782a3936c8498b928260a61a63bc12911cb9 | 701 | pas | Pascal | references/mORMot/SQLite3/Samples/35 - Practical DDD/03/dom/DomConferenceDepend.pas | zekiguven/alcinoe | e55c5368ee8bfe7cd6d92424c29ab07d8a3e844c | [
"Apache-2.0"
]
| 851 | 2018-02-05T09:54:56.000Z | 2022-03-24T23:13:10.000Z | references/mORMot/SQLite3/Samples/35 - Practical DDD/03/dom/DomConferenceDepend.pas | zekiguven/alcinoe | e55c5368ee8bfe7cd6d92424c29ab07d8a3e844c | [
"Apache-2.0"
]
| 200 | 2018-02-06T18:52:39.000Z | 2022-03-24T19:59:14.000Z | references/mORMot/SQLite3/Samples/35 - Practical DDD/03/dom/DomConferenceDepend.pas | zekiguven/alcinoe | e55c5368ee8bfe7cd6d92424c29ab07d8a3e844c | [
"Apache-2.0"
]
| 197 | 2018-03-20T20:49:55.000Z | 2022-03-21T17:38:14.000Z | /// Conference Domain dependencies interface definition
unit DomConferenceDepend;
interface
uses
SysUtils,
Classes,
SynCommons,
mORMot,
DomConferenceTypes;
type
TBookingRepositoryError = (
brSuccess, brDuplicatedInfo, brWriteFailure);
IBookingRepository = interface(IInvokable)
['{8E121C97-7E53-4208-BE05-1660EAD8AB43}']
function SaveNewRegistration(const Attendee: TAttendee;
out RegistrationNumber: TAttendeeRegistrationNumber): TBookingRepositoryError;
end;
implementation
initialization
TJSONSerializer.RegisterObjArrayForJSON([
]);
TInterfaceFactory.RegisterInterfaces([
TypeInfo(IBookingRepository)
]);
end.
| 21.90625 | 85 | 0.741797 |
83631f2847e0ae2e9471eefd2665fe3a8d4bfbff | 297 | pas | Pascal | 111219/5nedodelka.pas | irasap05/pascal | 9ec73a80cddef094ed56969f003b498f73c9cbb5 | [
"Apache-2.0"
]
| null | null | null | 111219/5nedodelka.pas | irasap05/pascal | 9ec73a80cddef094ed56969f003b498f73c9cbb5 | [
"Apache-2.0"
]
| null | null | null | 111219/5nedodelka.pas | irasap05/pascal | 9ec73a80cddef094ed56969f003b498f73c9cbb5 | [
"Apache-2.0"
]
| null | null | null | var
n: integer;
Begin
read(n);
if n >= 100 then
begin
e := n mod 10;
d := (n div 100) mod 10;
c := (n div 10) mod 10;
t := n div 100;
if e = d = c or e = d = t or d = c = t or c = e = t
then write('есть')
else write('нет');
end
else write('нет');
end. | 17.470588 | 56 | 0.468013 |
4785e415e60a198bd32e8c065b50a5a263231447 | 12,539 | pas | Pascal | oriutils_gui.pas | Chunosov/orion-lazarus | 7b77865f96ed2ac7fb48df473e2c2865ed06db63 | [
"MIT"
]
| null | null | null | oriutils_gui.pas | Chunosov/orion-lazarus | 7b77865f96ed2ac7fb48df473e2c2865ed06db63 | [
"MIT"
]
| null | null | null | oriutils_gui.pas | Chunosov/orion-lazarus | 7b77865f96ed2ac7fb48df473e2c2865ed06db63 | [
"MIT"
]
| null | null | null | {***************************************************************************
*
* Orion-project.org Lazarus Helper Library
* Copyright (C) 2016-2017 by Nikolay Chunosov
*
* This file is part of the Orion-project.org Lazarus Helper Library
* https://github.com/Chunosov/orion-lazarus
*
* This Library is free software: you can redistribute it and/or modify it
* under the terms of the MIT License. See enclosed LICENSE.txt for details.
*
***************************************************************************}
unit OriUtils_Gui;
{$mode objfpc}{$H+}
interface
uses
Classes, Graphics, Controls, ExtCtrls, Forms;
procedure SetDefaultColor(AControl: TWinControl; AColor: TColor = clNone);
procedure ScaleDPI(AControl: TControl; FromDPI: Integer);
{%region Message Dialogs}
procedure MessageDlg(const S: String); overload;
procedure ErrorDlg(const S: String);
procedure ErrorDlg(const S: String; Args: array of const);
function ConfirmDlg(const S: String): Boolean;
function ConfirmDlg(const S: String; Args: array of const): Boolean;
{%endregion}
{%region Form Helpers}
procedure SaveFormPos(AForm: TForm; var ASavedPos: Longword);
procedure SaveFormSize(AForm: TForm; var ASavedSize: Longword);
procedure SaveFormSizePos(AForm: TForm; var ASavedSize, ASavedPos: Longword);
procedure RestoreFormPos(AForm: TForm; ASavedPos: Longword);
procedure RestoreFormSize(AForm: TForm; ASavedSize: Longword);
procedure RestoreFormSizePos(AForm: TForm; ASavedSize, ASavedPos: Longword);
procedure SetPosNoOverlap(AForm: TForm; X, Y: Integer; Position: TPosition = poDesigned); overload;
procedure SetPosNoOverlap(AForm: TForm; X, Y, W, H: Integer; Position: TPosition = poDesigned); overload;
{%endregion}
{%region File Dialogs}
type
TFileDialogParams = record
Title: String;
Filters: String;
FilterIndex: Integer;
FileName: String;
FileNames: TStrings;
InitialDir: String;
MultiSelect: Boolean;
DefaultExt: String;
end;
function OpenFileDialog(var Params: TFileDialogParams): Boolean; overload;
function SaveFileDialog(var Params: TFileDialogParams): Boolean; overload;
function OpenFileDialog(const Title, Filters, Ext: String; var FileName: String): Boolean; overload;
function SaveFileDialog(const Title, Filters, Ext: String; var FileName: String): Boolean; overload;
function FileDlgParams(const Title, Filters, Ext: String): TFileDialogParams;
{%endregion}
function GetMaxTopChild(AParent: TWinControl): Integer;
implementation
uses
{$ifdef WINDOWS}
Windows, CommDlg,
{$endif}
SysUtils, Dialogs, LCLIntf, LazUTF8;
{%region Controls}
// Sets a default theme-aware color for TPanels. On some environments
// (for example on Ubuntu Unity) the default window color is not clBtnFace.
// But TPanel has clBtnFace color when we set clDefault for it.
procedure SetDefaultColor(AControl: TWinControl; AColor: TColor = clNone);
var
I: Integer;
Control: TControl;
begin
if AColor = clNone then
AColor := AControl.GetDefaultColor(dctBrush);
if AControl is TCustomPanel then
AControl.Color := AColor;
for I := 0 to AControl.ControlCount-1 do
begin
Control := AControl.Controls[I];
if Control is TWinControl then
SetDefaultColor(TWinControl(Control), AColor);
end;
end;
// Scales a control and its children according to current screen dpi.
// From here: http://wiki.lazarus.freepascal.org/High_DPI
procedure ScaleDPI(AControl: TControl; FromDPI: Integer);
var
I: Integer;
Control: TWinControl;
begin
if Screen.PixelsPerInch = FromDPI then
Exit;
with AControl do
begin
Left := ScaleX(Left, FromDPI);
Top := ScaleY(Top, FromDPI);
Width := ScaleX(Width, FromDPI);
Height := ScaleY(Height, FromDPI);
end;
if AControl is TWinControl then
begin
Control := TWinControl(AControl);
if Control.ControlCount = 0 then
Exit;
with Control.ChildSizing do
begin
HorizontalSpacing := ScaleX(HorizontalSpacing, FromDPI);
LeftRightSpacing := ScaleX(LeftRightSpacing, FromDPI);
TopBottomSpacing := ScaleY(TopBottomSpacing, FromDPI);
VerticalSpacing := ScaleY(VerticalSpacing, FromDPI);
end;
for I := 0 to Control.ControlCount - 1 do
ScaleDPI(Control.Controls[I], FromDPI);
end;
end;
{%endregion}
{%region Message Dialogs}
procedure MessageDlg(const S: String);
begin
Dialogs.MessageDlg(Application.Title, S, mtInformation, [mbOK], '');
end;
procedure ErrorDlg(const S: String);
begin
Dialogs.MessageDlg(Application.Title, S, mtError, [mbOK], '');
end;
procedure ErrorDlg(const S: String; Args: array of const);
begin
ErrorDlg(Format(S, Args));
end;
function ConfirmDlg(const S: String): Boolean;
begin
Result := Dialogs.MessageDlg(Application.Title, S, mtConfirmation, mbYesNo, '') = mrYes;
end;
function ConfirmDlg(const S: String; Args: array of const): Boolean;
begin
Result := ConfirmDlg(Format(S, Args));
end;
{%endregion}
{%region Form Helpers}
procedure SaveFormPos(AForm: TForm; var ASavedPos: Longword);
begin
with AForm do ASavedPos := MakeLong(Left, Top);
end;
procedure SaveFormSize(AForm: TForm; var ASavedSize: Longword);
begin
with AForm do ASavedSize := MakeLong(Width, Height);
end;
procedure SaveFormSizePos(AForm: TForm; var ASavedSize, ASavedPos: Longword);
begin
SaveFormPos(AForm, ASavedPos);
SaveFormSize(AForm, ASavedSize);
end;
procedure RestoreFormPos(AForm: TForm; ASavedPos: Longword);
begin
with AForm do
if ASavedPos <> 0 then
begin
Position := poDesigned;
Left := Lo(ASavedPos);
Top := Hi(ASavedPos);
end
else Position := poScreenCenter
end;
procedure RestoreFormSize(AForm: TForm; ASavedSize: Longword);
begin
with AForm do
if ASavedSize <> 0 then
begin
Width := Lo(ASavedSize);
Height := Hi(ASavedSize);
end;
end;
procedure RestoreFormSizePos(AForm: TForm; ASavedSize, ASavedPos: Longword);
begin
RestoreFormSize(AForm, ASavedSize);
RestoreFormPos(AForm, ASavedPos);
end;
procedure SetPosNoOverlap(AForm: TForm; X, Y: Integer; Position: TPosition = poDesigned);
begin
SetPosNoOverlap(AForm, X, Y, AForm.Width, AForm.Height, Position)
end;
procedure SetPosNoOverlap(AForm: TForm; X, Y, W, H: Integer; Position: TPosition = poDesigned);
const
SafeCounter = 100;
var
FormClass: TClass;
I, J, DW, DH: Integer;
begin
DW := Screen.DesktopWidth;
DH := Screen.DesktopHeight;
if Position = poDesktopCenter then
begin
X := (DW - W) div 2;
Y := (DH - H) div 2;
end
else if Position = poScreenCenter then
with Screen.WorkAreaRect do
begin
X := (Right - Left - W) div 2;
Y := (Bottom - Top - H) div 2;
end;
I := 0; J := 0;
FormClass := AForm.ClassType;
while (I < Screen.FormCount-1) and (J < SafeCounter) do
begin
if (Screen.Forms[I] is FormClass) and (Screen.Forms[I] <> AForm) then
if (X = Screen.Forms[I].Left) and (Y = Screen.Forms[I].Top) then
begin
Inc(X, 40); if X >= DW then X := 0;
Inc(Y, 40); if Y >= DH then Y := 0;
I := -1;
end;
Inc(I);
Inc(J);
end;
AForm.SetBounds(X, Y, W, H);
end;
{%endregion}
{%region File Dialogs}
function FileDlgParams(const Title, Filters, Ext: String): TFileDialogParams;
begin
Result.Title := Title;
Result.Filters := Filters;
Result.FilterIndex := 1;
Result.DefaultExt := Ext;
Result.MultiSelect := False;
Result.FileNames := nil;
end;
function OpenFileDialog(const Title, Filters, Ext: String; var FileName: String): Boolean;
var Params: TFileDialogParams;
begin
Params := FileDlgParams(Title, Filters, Ext);
Params.FileName := FileName;
Result := OpenFileDialog(Params);
if Result then FileName := Params.FileName;
end;
function SaveFileDialog(const Title, Filters, Ext: String; var FileName: String): Boolean;
var Params: TFileDialogParams;
begin
Params := FileDlgParams(Title, Filters, Ext);
Params.FileName := FileName;
Result := SaveFileDialog(Params);
if Result then FileName := Params.FileName;
end;
{$ifdef WINDOWS}
type TWinApiFileDlgType = (wadtOpen, wadtSave);
function WinApiFileDialog(var Params: TFileDialogParams; DlgType: TWinApiFileDlgType): Boolean;
var
fnStruct: TOpenFileName;
szFile: array[0..MAX_PATH] of Char;
procedure ParseMultipleFileNames;
var
I: Integer;
Index: Integer = 0;
CurDir: String = '';
FileName: String;
begin
for I := 0 to MAX_PATH do
if szFile[I] = #0 then
begin
if (I > 0) and (szFile[I-1] = #0) then // #0#0 ends the string
begin
if (Params.FileNames.Count = 0) and (CurDir <> '') then // single file is selected
if FileExists(CurDir) then
Params.FileNames.Add(SysToUTF8(CurDir));
exit;
end;
if CurDir <> '' then
begin
FileName := PChar(@(szFile[Index]));
FileName := IncludeTrailingPathDelimiter(CurDir) + FileName;
if FileExists(FileName) then
Params.FileNames.Add(SysToUTF8(FileName));
end
else CurDir := szFile;
Index := I+1;
end;
end;
begin
Result := False;
FillChar(fnStruct{%H-}, SizeOf(TOpenFileName), 0);
with fnStruct do
begin
hwndOwner := Application.MainFormHandle;
lStructSize := SizeOf(TOpenFileName);
lpstrFile := {%H-}szFile;
StrPCopy(lpstrFile, UTF8ToSys(Params.FileName));
nMaxFile := Length(szFile);
lpstrFilter := PChar(StringReplace(Params.Filters, '|', #0, [rfReplaceAll]) + #0#0);
nFilterIndex := Params.FilterIndex;
if Params.Title <> '' then
lpstrTitle := PChar(Params.Title);
if Params.InitialDir <> '' then
lpstrInitialDir := PChar(Params.InitialDir);
if Params.DefaultExt <> '' then
lpstrDefExt := PChar(Params.DefaultExt);
if Params.MultiSelect then
Flags := Flags or OFN_ALLOWMULTISELECT;
Flags := Flags or OFN_ENABLESIZING or OFN_EXPLORER;
end;
case DlgType of
wadtOpen:
begin
with fnStruct do
Flags := Flags or OFN_FILEMUSTEXIST or OFN_PATHMUSTEXIST;
Result := GetOpenFileName(@fnStruct);
if Result then
begin
if Params.MultiSelect and Assigned(Params.FileNames) then
begin
ParseMultipleFileNames;
if Params.FileNames.Count > 0 then
Params.FileName := Params.FileNames[0];
end
else Params.FileName := SysToUTF8(StrPas(szFile));
Params.FilterIndex := fnStruct.nFilterIndex;
end;
end;
wadtSave:
begin
with fnStruct do
Flags := Flags or OFN_PATHMUSTEXIST or OFN_OVERWRITEPROMPT;
Result := GetSaveFileName(@fnStruct);
if Result then
begin
Params.FileName := SysToUTF8(StrPas(szFile));
Params.FilterIndex := fnStruct.nFilterIndex;
end;
end;
end;
end;
{$endif}
function OpenFileDialog(var Params: TFileDialogParams): Boolean;
begin
if Assigned(Params.FileNames) then
Params.FileNames.Clear;
{$ifdef WINDOWS}
Result := WinApiFileDialog(Params, wadtOpen);
{$else}
with TOpenDialog.Create(nil) do
try
if Params.Title <> '' then
Title := Params.Title;
Filter := Params.Filters;
FileName := Params.FileName;
if Params.MultiSelect then
Options := Options + [ofAllowMultiSelect];
Options := Options + [ofFileMustExist, ofPathMustExist];
FilterIndex := Params.FilterIndex;
if Params.InitialDir <> '' then
InitialDir := Params.InitialDir;
if Params.DefaultExt <> '' then
DefaultExt := PChar(Params.DefaultExt);
Result := Execute;
if Result then
begin
Params.FilterIndex := FilterIndex;
Params.FileName := FileName;
if Assigned(Params.FileNames) then
begin
if Params.MultiSelect
then Params.FileNames.Assign(Files)
else Params.FileNames.Add(FileName);
end;
end;
finally
Free;
end;
{$endif}
end;
function SaveFileDialog(var Params: TFileDialogParams): Boolean;
begin
{$ifdef WINDOWS}
Result := WinApiFileDialog(Params, wadtSave);
{$else}
Result := False; // TODO
{$endif}
end;
{%endregion}
// Можно использовать при размещении контролов друг под другом. Если добавить
// новый контрол и просто выставить Align = alTop, то он помещается над старыми.
// Нужно выставить ему нужный Top, чтобы он встал в самый низ (обычно еще +1).
function GetMaxTopChild(AParent: TWinControl): Integer;
var i: Integer;
begin
Result := -1;
for I := 0 to AParent.ControlCount-1 do
with AParent.Controls[I] do if Top > Result then Result := Top + Height;
end;
end.
| 29.092807 | 105 | 0.685063 |
fc45b026f802dc3bb2d913604161ca037b5648f0 | 5,184 | pas | Pascal | w/notes.pas | ssg/wolverine | eb300e09ed062127d08703b6f9a2b47473e930cd | [
"BSD-3-Clause"
]
| 23 | 2015-02-16T17:42:19.000Z | 2022-03-28T18:20:01.000Z | w/notes.pas | ssg/wolverine | eb300e09ed062127d08703b6f9a2b47473e930cd | [
"BSD-3-Clause"
]
| null | null | null | w/notes.pas | ssg/wolverine | eb300e09ed062127d08703b6f9a2b47473e930cd | [
"BSD-3-Clause"
]
| 2 | 2015-11-04T11:19:57.000Z | 2020-02-03T23:28:10.000Z | {
wolverine notes
P+All olayi yerine daha esnek bi yontem:
if To=ALL or From=Bi$ii falan
kendime bi$ii ozel paket formati...
Wham! Wolverine packet format
packet structure:
INFO.W information about packet
INDEX.W message index
TEXT.W raw text (optional)
INFO.W format:
~~~~~~~~~~~~~~
Size Description
~~~~ ~~~~~~~~~~~~~~~~~~
DWORD signature $4d414857 = 'WHAM'
WORD Packet type
00 = Standard mail packet
01 = Reply packet
02 = Archive packet
WORD Packet flags
bit 0 - packet is encrypted
WORD Permitted netmail flags
STR39 Origin of packet (i.e. "Dead-Dragon BBS")
STR39 SysOp of system
8BYTES Fido-style address of system
STR39 Name of user who is owner of the packet
STR39 Alias of user
STR39 Creator of packet (i.e. "M-Door")
??? Padding to 512 bytes
after header, there comes area records... format of each area
record is:
Size Description
~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~
STR49 Area name
STR5 Area number
BYTE Area type
0 = local
1 = echo
2 = netmail
3 = internet e-mail
4 = info area (new files etc)
BYTE User status
0 = user doesn't read this area
1 = gets only personal msgs
2 = gets P+All
3 = gets all messages
WORD Area flags
bit 0 - Aliases allowed
1 - User can write messages to this area
68BYTES Null-padded
INDEX.W format
~~~~~~~~~~~~~~
Size Description
~~~~ ~~~~~~~~~~~~~~
STR39 From: field
STR39 To: field
STR79 Subj: field
DWORD Message date (MSDOS format)
ADDR Origin of message
ADDR Destination of message
DWORD Message flags
bit 0 - message has been read
1 - message has been replied
2 - message is personal
3 - message has been deleted
4 - message is marked for reply
5 - message is marked for read
6 - message is marked for save
DWORD Message size
DWORD Message offset (-1 if linked to another file)
STR12 Filename that message is linked
WORD Netmail flags
33BYTES Null padded
XMF (Xtended Message Format)
HTML KEYWORDS LIST (netscape 2.0)
~~~~~~~~~~~~~~~~~~
head,a,tt,p,table,applet,b,select,html,textarea,caption,ul,th,meta,title,
map,input,body,plaintext,option,keygen,param,hype,xmp,font,dt,cite,h5,
div,code,hb,em,image,i,link,dl,kbd,nobr,tr,big,area,h1,pre,noframes,form,
br,blink,blockquote,h2,cell,frame,frameset,embed,noembed,img,center,li,
colormap,menu,h4,ol,base,td,basefont,wbr,small,dd,var,strike,sup,isindex,
listing,sub,strong,script,subdoc,address,hr,dir
head = head of document (unused)
a = symbolic link
tt = teletype mode
p = new paragraph
table = ??? table??
applet = java applet (won't be used)
b = bold
select = ???
html = ??? (no effect)
textarea = ???
caption = ??? (no effect)
ul = ???
th = ??? (table something??)
meta = ???
title = window title
map = symbolic link map
input = user input request
body = body of document (unused)
plaintext = switches to fixed font and ignores any further HTML
directives...
option = ???
keygen = ???
param = ???
hype = hyphenate??
xmp = switches to fixed font and ignores any HTML directives
until an /XMP directive is being encountered...
font = changes font style...
dt = ???
cite = italic
h1,h2,h3,h4,h5 = font size selection...
div = causes a line break??
code = tt, samp, pre, xmp, listing
hb = ???
em = emphasis (italic)
i = italic
dl = ???
kbd = keyboard entry font
nobr = ???
tr = ???
big = big font select
area = ???
pre = fixed size font selection
noframes = ???
form = entry form??
br = line break??
blink = blink
blockquote = quoted text
cell = ???
frame = ???
frameset = ???
embed = ???
noembed = ???
img = embed image
center = center
li = list item
colormap = ???
menu = ???
ol = tabulates text?? what?
base = ???
td = ???
basefont = ???
wbr = ???
small = small font selection
dd = ???
var = ???
strike = strike
sup = superscript
sub = subscript
isindex = ???
strong = bold
script = script-like font selection
subdoc = ???
address = e-mail address like font selection (italic)
script = javascript
hr = tearline creator
dir = tabulation??
}
| 29.622857 | 73 | 0.518711 |
fc0a756b9b4be9a2dc09b1f245d2f576ea1298f1 | 1,234 | dfm | Pascal | TommyGun/Plugins/CodeEditor/fGotoLine.dfm | tonyt73/TommyGun | 2c2ffae3dcd5dc25fd64d68a9f4cc96d99a1cd36 | [
"BSD-3-Clause"
]
| 34 | 2017-05-08T18:39:13.000Z | 2022-02-13T05:05:33.000Z | TommyGun/Plugins/CodeEditor/fGotoLine.dfm | tonyt73/TommyGun | 2c2ffae3dcd5dc25fd64d68a9f4cc96d99a1cd36 | [
"BSD-3-Clause"
]
| null | null | null | TommyGun/Plugins/CodeEditor/fGotoLine.dfm | tonyt73/TommyGun | 2c2ffae3dcd5dc25fd64d68a9f4cc96d99a1cd36 | [
"BSD-3-Clause"
]
| 6 | 2017-05-27T01:14:20.000Z | 2020-01-20T14:54:30.000Z | object frmGotoLine: TfrmGotoLine
Left = 1298
Top = 451
ActiveControl = edtLineNumber
AlphaBlendValue = 200
BorderStyle = bsDialog
Caption = 'Goto Line Number'
ClientHeight = 89
ClientWidth = 257
Color = clWhite
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
FormStyle = fsStayOnTop
OldCreateOrder = False
Position = poMainFormCenter
DesignSize = (
257
89)
PixelsPerInch = 96
TextHeight = 13
object lblEnterNewLineNumber: TLabel
Left = 8
Top = 20
Width = 107
Height = 13
Caption = 'Enter new line number'
end
object cmdOK: TButton
Left = 83
Top = 57
Width = 80
Height = 24
Anchors = [akRight, akBottom]
Caption = 'OK'
Default = True
ModalResult = 1
TabOrder = 0
end
object cmdCancel: TButton
Left = 169
Top = 57
Width = 80
Height = 24
Anchors = [akRight, akBottom]
Cancel = True
Caption = 'Cancel'
ModalResult = 2
TabOrder = 1
end
object edtLineNumber: TEdit
Left = 121
Top = 17
Width = 128
Height = 21
Color = clWhite
TabOrder = 2
Text = '1'
OnChange = edtLineNumberChange
end
end
| 19.28125 | 38 | 0.632091 |
fc11a530d8dd00059ddd0277012d856f59e651de | 3,992 | pas | Pascal | Src/BitmapProgressBar.pas | ryujt/ryulib4delphi | 1269afeb5d55d5d6710cfb1d744d5a1596583a96 | [
"MIT"
]
| 18 | 2015-05-18T01:55:45.000Z | 2019-05-03T03:23:52.000Z | Src/BitmapProgressBar.pas | ryujt/ryulib4delphi | 1269afeb5d55d5d6710cfb1d744d5a1596583a96 | [
"MIT"
]
| 1 | 2019-11-08T08:27:34.000Z | 2019-11-08T08:43:51.000Z | Src/BitmapProgressBar.pas | ryujt/ryulib4delphi | 1269afeb5d55d5d6710cfb1d744d5a1596583a96 | [
"MIT"
]
| 19 | 2015-05-14T01:06:35.000Z | 2019-06-02T05:19:00.000Z | unit BitmapProgressBar;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, ExtCtrls;
type
TBitmapProgressBar = class(TCustomPanel)
private
FBitmapForegroundCopy: TBitmap;
FBitmapBackgroundCopy: TBitmap;
procedure draw_Tile(ASrc,ADst:TBitmap);
protected
procedure Resize; override;
procedure Paint; override;
private
FBitmapForeground: TBitmap;
FBitmapBackground: TBitmap;
FPercent: integer;
procedure SetBitmapBackground(const Value: TBitmap);
procedure SetBitmapForeground(const Value: TBitmap);
procedure SetPercent(const Value: integer);
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property Align;
property Anchors;
property Enabled;
property ShowHint;
property Visible;
published
property Percent : integer read FPercent write SetPercent;
property BitmapForeground : TBitmap read FBitmapForeground write SetBitmapForeground;
property BitmapBackground : TBitmap read FBitmapBackground write SetBitmapBackground;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('RyuLib', [TBitmapProgressBar]);
end;
{ TBitmapProgressBar }
constructor TBitmapProgressBar.Create(AOwner: TComponent);
begin
inherited;
ControlStyle := ControlStyle + [csOpaque];
FBitmapForeground := TBitmap.Create;
FBitmapBackground := TBitmap.Create;
FBitmapForegroundCopy := TBitmap.Create;
FBitmapBackgroundCopy := TBitmap.Create;
end;
destructor TBitmapProgressBar.Destroy;
begin
FreeAndNil(FBitmapForeground);
FreeAndNil(FBitmapBackground);
FreeAndNil(FBitmapForegroundCopy);
FreeAndNil(FBitmapBackgroundCopy);
inherited;
end;
procedure TBitmapProgressBar.draw_Tile(ASrc, ADst: TBitmap);
var
Src, Dst : TRect;
Loop, iPieceSize : Integer;
begin
if (Width * Height) = 0 then Exit;
if (ASrc.Width * ASrc.Height) = 0 then Exit;
iPieceSize := ASrc.Width div 3;
if iPieceSize < 1 then Exit;
ADst.Width := Width;
ADst.Height := Height;
// Repeat middle part.
for Loop := 0 to Width div iPieceSize do begin
Src := Bounds(iPieceSize, 0, iPieceSize, ASrc.Height);
Dst := Bounds(iPieceSize * Loop, 0, iPieceSize, ASrc.Height);
ADst.Canvas.CopyRect(Dst, ASrc.Canvas, Src);
end;
// Draw left part.
Src := Bounds(0, 0, iPieceSize, ASrc.Height);
Dst := Src;
ADst.Canvas.CopyRect(Dst, ASrc.Canvas, Src);
// Draw right part.
Src := Bounds(ASrc.Width-iPieceSize, 0, iPieceSize, ASrc.Height);
Dst := Bounds(Width-iPieceSize, 0, iPieceSize, ASrc.Height);
ADst.Canvas.CopyRect(Dst, ASrc.Canvas, Src);
end;
procedure TBitmapProgressBar.Paint;
var
Src, Dst : TRect;
begin
if (Width * Height) = 0 then Exit;
if csDesigning in ComponentState then
with inherited Canvas do begin
Pen.Style := psDash;
Brush.Style := bsClear;
Rectangle(0, 0, Width, Height);
end;
Canvas.Draw(0, 0, FBitmapBackgroundCopy);
Src := Bounds(0, 0, FBitmapForegroundCopy.Width * FPercent div 100, FBitmapForegroundCopy.Height);
Dst := Src;
Canvas.CopyRect(Dst, FBitmapForegroundCopy.Canvas, Src);
end;
procedure TBitmapProgressBar.Resize;
begin
draw_Tile( FBitmapForeground, FBitmapForegroundCopy );
draw_Tile( FBitmapBackground, FBitmapBackgroundCopy );
end;
procedure TBitmapProgressBar.SetBitmapBackground(const Value: TBitmap);
begin
if Value = nil then begin
FBitmapBackground.Width := 0;
Invalidate;
Exit;
end;
Height := Value.Height;
FBitmapBackground.Assign( Value );
Resize;
Invalidate;
end;
procedure TBitmapProgressBar.SetBitmapForeground(const Value: TBitmap);
begin
if Value = nil then begin
FBitmapForeground.Width := 0;
Invalidate;
Exit;
end;
Height := Value.Height;
FBitmapForeground.Assign( Value );
Resize;
Invalidate;
end;
procedure TBitmapProgressBar.SetPercent(const Value: integer);
begin
FPercent := Value;
Invalidate;
end;
end.
| 23.075145 | 100 | 0.733717 |
f1e97a65f8c555d2795778b4d5b6572add9674cc | 5,004 | pas | Pascal | Common/uPrcData.pas | Sembium/Sembium3 | 0179c38c6a217f71016f18f8a419edd147294b73 | [
"Apache-2.0"
]
| null | null | null | Common/uPrcData.pas | Sembium/Sembium3 | 0179c38c6a217f71016f18f8a419edd147294b73 | [
"Apache-2.0"
]
| null | null | null | Common/uPrcData.pas | Sembium/Sembium3 | 0179c38c6a217f71016f18f8a419edd147294b73 | [
"Apache-2.0"
]
| 3 | 2021-06-30T10:11:17.000Z | 2021-07-01T09:13:29.000Z | unit uPrcData;
interface
uses
uPrcDeclarations, Db, Variants, AbmesClientDataSet, DBClient;
type
TProcessLevelData = class;
TProcessLevelDataArray = array of TProcessLevelData;
TProcessOwnerData = class(TProcessOwner)
private
function GetAsVariant: Variant;
procedure SetAsVariant(const AValue: Variant);
function GetLevelsAsVariant: Variant;
procedure SetLevelsAsVariant(const AValue: Variant);
function GetLevelsSet: TProcessLevelDataArray;
function GetRelevantRollupLevel: TProcessLevelData;
protected
function CreateProcessLevel(AProcessLevel: TProcessLevel): TProcessLevel; override;
procedure FreeProcessLevel(AProcessLevel: TProcessLevel); override;
public
function IsDataEqual(AValue: TProcessOwnerData): Boolean;
function LevelByName(const ALevelName: string): TProcessLevelData;
property LevelsSet: TProcessLevelDataArray read GetLevelsSet;
property AsVariant: Variant read GetAsVariant write SetAsVariant;
property RelevantRollupLevel: TProcessLevelData read GetRelevantRollupLevel;
end;
TProcessLevelData = class(TProcessLevel)
private
FcdsLevelData: TAbmesClientDataSet;
function GetAsVariant: Variant;
procedure SetAsVariant(const AValue: Variant);
function GetOwner: TProcessOwnerData;
protected
procedure DoAfterSetAsVariant; virtual;
public
constructor Create(AProcessLevel: TProcessLevel; AOwner: TProcessOwner);
destructor Destroy; override;
function IsDataEqual(AValue: TProcessLevelData): Boolean;
property cdsLevelData: TAbmesClientDataSet read FcdsLevelData;
property AsVariant: Variant read GetAsVariant write SetAsVariant;
property Owner: TProcessOwnerData read GetOwner;
end;
implementation
uses
uUtils, SysUtils;
{ TProcessOwnerData }
function TProcessOwnerData.GetLevelsSet: TProcessLevelDataArray;
begin
Result:= TProcessLevelDataArray(inherited LevelsSet);
end;
function TProcessOwnerData.GetRelevantRollupLevel: TProcessLevelData;
begin
Result:= inherited RelevantRollupLevel as TProcessLevelData;
end;
function TProcessOwnerData.LevelByName(const ALevelName: string): TProcessLevelData;
begin
Result:= inherited LevelByName(ALevelName) as TProcessLevelData;
end;
function TProcessOwnerData.CreateProcessLevel(AProcessLevel: TProcessLevel): TProcessLevel;
begin
Result:= TProcessLevelData.Create(AProcessLevel, Self);
end;
function TProcessOwnerData.IsDataEqual(AValue: TProcessOwnerData): Boolean;
var
Level: TProcessLevelData;
begin
for Level in LevelsSet do
if not Level.IsDataEqual(AValue.LevelByName(Level.Name)) then
Exit(False);
Result:= True;
end;
procedure TProcessOwnerData.FreeProcessLevel(AProcessLevel: TProcessLevel);
begin
AProcessLevel.Free;
end;
procedure TProcessOwnerData.SetAsVariant(const AValue: Variant);
begin
Assert(VarIsArray(AValue));
Assert(VarArrayLength(AValue) = 2);
Assert(AValue[0] = Name);
SetLevelsAsVariant(AValue[1]);
end;
function TProcessOwnerData.GetAsVariant: Variant;
begin
Result:= VarArrayCreate([0, 1], varVariant);
Result[0]:= Name;
Result[1]:= GetLevelsAsVariant;
end;
function TProcessOwnerData.GetLevelsAsVariant: Variant;
var
i: Integer;
Level: TProcessLevelData;
begin
Result:= VarArrayCreate([0, Length(LevelsSet) - 1], varVariant);
i:= 0;
for Level in LevelsSet do
begin
Result[i]:= Level.AsVariant;
Inc(i);
end; { for }
end;
procedure TProcessOwnerData.SetLevelsAsVariant(const AValue: Variant);
var
Level: TProcessLevelData;
i: Integer;
begin
Assert(VarIsArray(AValue));
Assert(VarArrayLength(AValue) = Length(LevelsSet));
i:= 0;
for Level in LevelsSet do
begin
Level.AsVariant:= AValue[i];
Inc(i);
end; { for }
end;
{ TProcessLevelData }
function TProcessLevelData.GetOwner: TProcessOwnerData;
begin
Result:= inherited Owner as TProcessOwnerData;
end;
function TProcessLevelData.IsDataEqual(AValue: TProcessLevelData): Boolean;
begin
Result:= (Self.cdsLevelData.XMLData = AValue.cdsLevelData.XMLData);
end;
constructor TProcessLevelData.Create(AProcessLevel: TProcessLevel; AOwner: TProcessOwner);
begin
inherited Create(AProcessLevel, AOwner);
FcdsLevelData:= TAbmesClientDataSet.Create(nil);
end;
destructor TProcessLevelData.Destroy;
begin
FreeAndNil(FcdsLevelData);
inherited;
end;
function TProcessLevelData.GetAsVariant: Variant;
begin
Result:= VarArrayCreate([0, 1], varVariant);
Result[0]:= Name;
Result[1]:= cdsLevelData.Data;
end;
procedure TProcessLevelData.SetAsVariant(const AValue: Variant);
begin
Assert(VarIsArray(AValue));
Assert(VarArrayLength(AValue) = 2);
Assert(AValue[0] = Name);
cdsLevelData.Data:= AValue[1];
DoAfterSetAsVariant;
end;
procedure TProcessLevelData.DoAfterSetAsVariant;
begin
// do nothing
end;
end.
| 26.759358 | 92 | 0.7498 |
47d8da4ee063edcda5c62ef697b8416e2b472364 | 53,635 | pas | Pascal | tests/tstreadexif.pas | noomox/dexif | 2c069a1b39db7e835852ad899c2200e604e0c41f | [
"FSFAP"
]
| 13 | 2016-10-21T14:18:48.000Z | 2021-06-27T18:00:50.000Z | tests/tstreadexif.pas | noomox/dexif | 2c069a1b39db7e835852ad899c2200e604e0c41f | [
"FSFAP"
]
| 6 | 2016-12-04T17:55:38.000Z | 2021-01-29T02:08:32.000Z | tests/tstreadexif.pas | noomox/dexif | 2c069a1b39db7e835852ad899c2200e604e0c41f | [
"FSFAP"
]
| 18 | 2016-04-16T00:20:25.000Z | 2022-03-15T19:49:07.000Z | { Important note:
- Never trust a single exif extraction tool. It may just re-use other tags.
}
unit tstreadexif;
{$ifdef FPC}
{$mode objfpc}{$H+}
{$endif FPC}
{$i dExifTest.inc}
interface
uses
Classes, SysUtils
{$ifdef FPC}
, fpcunit, testutils, testregistry
{$else}
, TestFrameWork
{$endif}
, dUtils, dMetadata, dEXIF;
const
// Picture with EXIF data taken from SAMSUNG camera
co_TestPic01 = './testpictures/original/with_exif_large.jpeg';
co_DUTPicName01 = './testpictures/DUTPic01.jpeg';
// Picture with EXIF data taken from CANON camera with GPS
co_TestPic02 = './testpictures/original/img_9438.jpg';
co_DUTPicName02 = './testpictures/DUTPic03.jpeg';
// Picture with EXIF data taken from CANON camera with comment etc.
co_TestPic03 = './testpictures/original/Schilfgebiet.jpg';
co_DUTPicName03 = './testpictures/DUTPic04.jpeg';
type
{ TTsTBasic_dEXIF }
TTstReadFile_dEXIF= class(TTestCase)
{$ifdef FPC}
protected
{$else}
public
{$endif}
procedure SetUp; override;
procedure TearDown; override;
{$ifdef FPC}
protected
{$else}
public
{$endif}
FImgFileName: String;
procedure StdFloatTest(const AFileName, ATestTag: String;
const AExpectedResult: Double; ADecimals: Integer; const AMismatchMsg: String);
procedure StdFloatFromStringTest(const AFilename, ATestTag: String;
const AExpectedResult: String; ADecimals: Integer; const AMismatchMsg: String);
procedure StdIntTest(const AFileName, ATestTag: String;
const AExpectedResult:Integer; const AMismatchMsg: String);
procedure StdStringTest(const AFileName, ATestTag: String;
const AExpectedResult, AMismatchMsg: String);
procedure Test_ByteOrder(const AFilename: String; AExpected: Boolean);
procedure ReadFile_CommentSegment(const AFileName, AExpected: String);
procedure Test_DateTime(const AFileName: String; AKind: Integer;
AExpectedDateTime: TDateTime);
procedure Test_GPSPosition(const AFileName: String; const ATagName: String;
AExpectedDeg, AExpectedMin, AExpectedSec: Double; const AMismatchMsg: String);
procedure Test_ImageSize(const AFileName: String;
AExpectedWidth, AExpectedHeight: Integer);
procedure Test_Resolution(const AFileName: String;
AExpectedXResolution, AExpectedYResolution: Integer; AExpectedUnits: String);
procedure Test_UserComment(const AFilename, AExpected: String);
end;
{ Tests for image DUTPic01, taken by SAMSUNG camera }
{ TTstReadFile_dEXIF_01 }
TTstReadFile_dEXIF_01 = class(TTstReadFile_dEXIF)
{$ifdef FPC}
protected
{$else}
public
{$endif}
procedure SetUp; override;
published
procedure TstReadFile_ApertureValue;
procedure TstReadFile_Artist;
// procedure TstReadFile_BitsPerSample;
procedure TstReadFile_ByteOrder;
procedure TstReadFile_CameraMake;
procedure TstReadFile_CameraModel;
procedure TstReadFile_ColorSpace;
procedure TstReadFile_CommentExif;
procedure TstReadFile_CommentSegment;
procedure TstReadFile_CompressedBitsPerPixel;
// procedure TstReadFile_Compression;
procedure TstReadFile_CustomRendered;
procedure TstReadFile_DateTime;
procedure TstReadFile_DateTime_Original;
procedure TstReadFile_DateTime_Digitized;
procedure TstReadFile_DateTime_Modified;
procedure TstReadFile_DigitalZoomRatio;
procedure TstReadFile_ExifImageLength;
procedure TstReadFile_ExifImageWidth;
procedure TstReadFile_ExifVersion;
procedure TstReadFile_ExposureBiasValue;
procedure TstReadFile_ExposureMode;
procedure TstReadFile_ExposureProgram;
procedure TstReadFile_ExposureTime;
procedure TstReadFile_FileSource;
// procedure TstReadFile_FirmwareVersion;
procedure TstReadFile_Flash;
procedure TstReadFile_FlashPixVersion;
procedure TstReadFile_FNumber;
procedure TstReadFile_FocalLength;
procedure TstReadFile_FocalLengthIn35mmFilm;
procedure TstReadFile_FocalPlaneXResolution;
procedure TstReadFile_FocalPlaneYResolution;
procedure TstReadFile_FocalPlaneResolutionUnit;
procedure TstReadFile_GPSLatitude;
procedure TstReadFile_GPSLatitudeRef;
procedure TstReadFile_GPSLongitude;
procedure TstReadFile_GPSLongitudeRef;
procedure TstReadFile_ImageDescription;
procedure TstReadFile_ImageSize;
// procedure TstReadFile_ImageType;
procedure TstReadFile_ISO;
procedure TstReadFile_MaxApertureValue;
procedure TstReadFile_MeteringMode;
procedure TstReadFile_Orientation;
procedure TstReadFile_RelatedImageHeight;
procedure TstReadFile_RelatedImageWidth;
procedure TstReadFile_Resolution;
procedure TstReadFile_ResolutionUnit;
procedure TstReadFile_SceneCaptureType;
procedure TstReadFile_SensingMethod;
procedure TstReadFile_ShutterSpeedValue;
procedure TstReadFile_WhiteBalance;
procedure TstReadFile_XResolution;
procedure TstReadFile_YCbCrPositioning;
// procedure TstReadFile_YCbCrSubsampling;
procedure TstReadFile_YResolution;
end;
{ Tests for image DUTPic02, taken by CANON camera }
{ TTstReadFile_dEXIF_02 }
TTstReadFile_dEXIF_02 = class(TTstReadFile_dEXIF)
{$ifdef FPC}
protected
{$else}
public
{$endif}
procedure SetUp; override;
published
procedure TstReadFile_Artist;
procedure TstReadFile_ApertureValue;
// procedure TstReadFile_BitsPerSample;
procedure TstReadFile_ByteOrder;
procedure TstReadFile_CameraMake;
procedure TstReadFile_CameraModel;
procedure TstReadFile_ColorSpace;
procedure TstReadFile_CompressedBitsPerPixel;
procedure TstReadFile_CommentExif;
procedure TstReadFile_CommentSegment;
// procedure TstReadFile_Compression;
procedure TstReadFile_CustomRendered;
procedure TstReadFile_DateTime;
procedure TstReadFile_DateTime_Original;
procedure TstReadFile_DateTime_Digitized;
procedure TstReadFile_DateTime_Modified;
procedure TstReadFile_DigitalZoomRatio;
procedure TstReadFile_ExifImageLength;
procedure TstReadFile_ExifImageWidth;
procedure TstReadFile_ExifVersion;
procedure TstReadFile_ExposureBiasValue;
procedure TstReadFile_ExposureMode;
procedure TstReadFile_ExposureProgram;
procedure TstReadFile_ExposureTime;
procedure TstReadFile_FileSource;
// procedure TstReadFile_FirmwareVersion;
procedure TstReadFile_Flash;
procedure TstReadFile_FlashPixVersion;
procedure TstReadFile_FNumber;
procedure TstReadFile_FocalLength;
procedure TstReadFile_FocalLengthIn35mmFilm;
procedure TstReadFile_FocalPlaneXResolution;
procedure TstReadFile_FocalPlaneYResolution;
procedure TstReadFile_FocalPlaneResolutionUnit;
procedure TstReadFile_GPSLatitude;
procedure TstReadFile_GPSLatitudeRef;
procedure TstReadFile_GPSLongitude;
procedure TstReadFile_GPSLongitudeRef;
procedure TstReadFile_ImageDescription;
procedure TstReadFile_ImageSize;
// procedure TstReadFile_ImageType;
procedure TstReadFile_ISO;
procedure TstReadFile_MaxApertureValue;
procedure TstReadFile_MeteringMode;
procedure TstReadFile_Orientation;
procedure TstReadFile_RelatedImageHeight;
procedure TstReadFile_RelatedImageWidth;
procedure TstReadFile_Resolution;
procedure TstReadFile_ResolutionUnit;
procedure TstReadFile_SensingMethod;
procedure TstReadfile_SceneCaptureType;
procedure TstReadFile_ShutterSpeedValue;
procedure TstReadFile_WhiteBalance;
procedure TstReadFile_XResolution;
procedure TstReadFile_YCbCrPositioning;
// procedure TstReadFile_YCbCrSubsampling;
procedure TstReadFile_YResolution;
end;
{ Tests for image DUTPic03, taken by Casio camera, contains comment etc }
{ TTstReadFile_dEXIF_03 }
TTstReadFile_dEXIF_03 = class(TTstReadFile_dEXIF)
{$ifdef FPC}
protected
{$else}
public
{$endif}
procedure SetUp; override;
published
procedure TstReadFile_Artist;
{$IFNDEF DELPHI7}
procedure TstReadFile_CommentExif; // Test must fail in D7 due to unicode characters
{$ENDIF}
procedure TstReadFile_CommentSegment;
procedure TstReadFile_ImageDescription;
end;
implementation
uses
DateUtils, Math
{$ifdef FPC}
, FileUtil
{$else}
, {$ifndef DELPHI7}Winapi.Windows{$else}Windows{$endif}
{$endif}
;
{ Output of ExifTool for DUTPic01.jpeg:
ExifTool Version Number : 10.60
File Name : DUTPic01.jpeg
Directory : .
File Size : 2.9 MB
File Modification Date/Time : 2017:08:05 11:16:56+02:00
File Access Date/Time : 2017:08:05 11:16:56+02:00
File Creation Date/Time : 2017:08:05 11:16:56+02:00
File Permissions : rw-rw-rw-
File Type : JPEG
File Type Extension : jpg
MIME Type : image/jpeg
JFIF Version : 1.01
Resolution Unit : inches
+ X Resolution : 300
+ Y Resolution : 300
+ Exif Byte Order : Big-endian (Motorola, MM)
+ Make : SAMSUNG
+ Camera Model Name : SM-G850F
+ Exposure Time : 1/3376
+ F Number : 2.2
+ ISO : 40, 0 Tag "ISOSpeedRatings"
+ Date/Time Original : 2017:03:15 10:35:11
+ Focal Length : 4.1 mm Tag "FocalLength"
+ Image Width : 4608
+ Image Height : 2592
Encoding Process : Baseline DCT, Huffman coding
Bits Per Sample : 8
Color Components : 3
Y Cb Cr Sub Sampling : YCbCr4:2:0 (2 2)
+ Aperture : 2.2
Image Size : 4608x2592
Megapixels : 11.9
+ Shutter Speed : 1/3376 Tag "ExposureTime"
+ Focal Length : 4.1 mm Tag "FocalLength"
Light Value : 15.3
----------------------
output of ccr-exif Exif Tag List for DUTPic01.jpeg
General
Byte order Big endian
Main IFD
Loaded cleanly Yes
Camera make SAMSUNG
Camera model SM-G850F
Exif sub-IFD
Loaded cleanly Yes
Date/time original Mittwoch, 15. März 2017 at 10:35:11
Exposure time 0,000296208530805687 seconds
F number 2,2
Focal length 4,09
ISO speed rating(s) 40,0
--------------------------------------------------------------------------------
Output of EXIFTool for DUTPic03.jpeg
ExifTool Version Number : 10.60
File Name : DUTPic03.jpeg
Directory : .
File Size : 1478 kB
File Modification Date/Time : 2017:02:15 18:53:32+01:00
File Access Date/Time : 2017:08:07 09:51:19+02:00
File Creation Date/Time : 2017:08:07 09:51:19+02:00
File Permissions : rw-rw-rw-
File Type : JPEG
File Type Extension : jpg
MIME Type : image/jpeg
Exif Byte Order : Little-endian (Intel, II)
Make : Canon
Camera Model Name : Canon PowerShot S5 IS
Orientation : Horizontal (normal)
X Resolution : 180
Y Resolution : 180
Resolution Unit : inches
Modify Date : 2017:02:11 15:09:39
Y Cb Cr Positioning : Centered
Exposure Time : 1/1600
F Number : 2.7
ISO : 160
Exif Version : 0220
Date/Time Original : 2017:02:11 15:09:39
Create Date : 2017:02:11 15:09:39
Components Configuration : Y, Cb, Cr, -
Compressed Bits Per Pixel : 3
Shutter Speed Value : 1/1614
Aperture Value : 2.7
Max Aperture Value : 2.7
Flash : Off, Did not fire
Focal Length : 6.0 mm
Macro Mode : Normal
Self Timer : Off
Quality : Fine
Canon Flash Mode : Off
Continuous Drive : Single
Focus Mode : Single
Record Mode : JPEG
Canon Image Size : Widescreen
Easy Mode : Full auto
Digital Zoom : None
Contrast : Normal
Saturation : Normal
Sharpness : 0
Camera ISO : Auto High
Metering Mode : Evaluative
Focus Range : Auto
AF Point : Manual AF point selection
Canon Exposure Mode : Easy
Lens Type : n/a
Max Focal Length : 72 mm
Min Focal Length : 6 mm
Focal Units : 100/mm
Max Aperture : 2.7
Min Aperture : 8
Flash Activity : 0
Flash Bits : (none)
Focus Continuous : Continuous
AE Setting : Normal AE
Image Stabilization : On
Display Aperture : 2.7
Zoom Source Width : 3264
Zoom Target Width : 3264
Spot Metering Mode : Center
Manual Flash Output : n/a
Focal Type : Zoom
Focal Plane X Size : 5.84 mm
Focal Plane Y Size : 4.39 mm
Auto ISO : 161
Base ISO : 100
Measured EV : 13.38
Target Aperture : 2.7
Target Exposure Time : 1/1614
Exposure Compensation : 0
White Balance : Auto
Slow Shutter : Off
Shot Number In Continuous Burst : 0
Optical Zoom Code : 6
Flash Guide Number : 0
Flash Exposure Compensation : 0
Auto Exposure Bracketing : Off
AEB Bracket Value : 0
Control Mode : Camera Local Control
Focus Distance Upper : 65.53 m
Focus Distance Lower : 0 m
Bulb Duration : 0
Camera Type : Compact
Auto Rotate : None
ND Filter : Off
Self Timer 2 : 0
Flash Output : 0
Canon Image Type : IMG:PowerShot S5 IS JPEG
Canon Firmware Version : Firmware Version 1.01
File Number : 100-9438
Owner Name :
Rotation : 0
Camera Temperature : 16 C
Canon Model ID : PowerShot S5 IS
AF Area Mode : Single-point AF
Num AF Points : 9
Valid AF Points : 1
Canon Image Width : 3264
Canon Image Height : 1832
AF Image Width : 1088
AF Image Height : 245
AF Area Widths : 196 0 0 0 0 0 0 0 0
AF Area Heights : 44 0 0 0 0 0 0 0 0
AF Area X Positions : 0 0 0 0 0 0 0 0 0
AF Area Y Positions : 0 0 0 0 0 0 0 0 0
AF Points In Focus : 0
Primary AF Point : 0
Thumbnail Image Valid Area : 0 159 15 104
Super Macro : Off
Date Stamp Mode : Off
My Color Mode : Off
Firmware Revision : 1.01 rev 2.00
Categories : (none)
Face Detect Frame Size : 0 0
Face Width : 35
Faces Detected : 0
Image Unique ID : 80304b30b8ff9067a4c6cab0bda0c784
User Comment :
Flashpix Version : 0100
Color Space : sRGB
Exif Image Width : 3264
Exif Image Height : 1832
Interoperability Index : R98 - DCF basic file (sRGB)
Interoperability Version : 0100
Related Image Width : 3264
Related Image Height : 1832
Focal Plane X Resolution : 14506.66667
Focal Plane Y Resolution : 10840.23669
Focal Plane Resolution Unit : inches
Sensing Method : One-chip color area
File Source : Digital Camera
Custom Rendered : Normal
Exposure Mode : Auto
Digital Zoom Ratio : 1
Scene Capture Type : Standard
Compression : JPEG (old-style)
Thumbnail Offset : 5120
Thumbnail Length : 4734
Image Width : 3264
Image Height : 1832
Encoding Process : Baseline DCT, Huffman coding
Bits Per Sample : 8
Color Components : 3
Y Cb Cr Sub Sampling : YCbCr4:2:2 (2 1)
Aperture : 2.7
Drive Mode : Single-frame Shooting
Image Size : 3264x1832
Lens : 6.0 - 72.0 mm
Lens ID : Unknown 6-72mm
Megapixels : 6.0
Scale Factor To 35 mm Equivalent: 6.1
Shooting Mode : Full auto
Shutter Speed : 1/1600
Thumbnail Image : (Binary data 4734 bytes, use -b option to extract)
Circle Of Confusion : 0.005 mm
Depth Of Field : inf (2.48 m - inf)
Field Of View : 52.7 deg
Focal Length : 6.0 mm (35 mm equivalent: 36.3 mm)
Hyperfocal Distance : 2.69 m
Lens : 6.0 - 72.0 mm (35 mm equivalent: 36.3 - 435.8 mm)
Light Value : 12.8
--------------------------------------------------------------------------------
Output of CCR-EXIF Tag List demo for DUTPic03.jpeg
General
Byte order Small endian
Main IFD
Loaded cleanly Yes
Camera make Canon
Camera model Canon PowerShot S5 IS
Date/time Samstag, 11. Februar 2017 at 15:09:39
Image description MyZeil Shopping Center
Orientation Normal
Resolution 180 x 180 inches
Exif sub-IFD
Loaded cleanly Yes
Exif version 2,2,0
Aperture value 2,875
Colour space sRGB
Compressed bits per pixel 3
Date/time original Samstag, 11. Februar 2017 at 15:09:39
Date/time digitised Samstag, 11. Februar 2017 at 15:09:39
Digital zoom ratio 1
Exif image width 3264
Exif image height 1832
Exposure time 0,000625 seconds
Exposure bias value 0
File source Digital camera
Flash present Yes
Flash mode Compulsory suppression
Flash fired No
Flash red eye reduction No
Flash strobe light No detection function
F number 2,7
Focal length 6
Focal length in 35mm film 36
Focal plane resolution 14506,6666666667 x 10840,2366863905 inches
ISO speed rating(s) 160
Max aperture value 2,875
Metering mode Pattern
Rendering Normal
Scene capture type Standard
Sensing method One chip
Shutter speed 0,6197 milliseconds
White balance mode Auto
Interoperability sub-IFD
Loaded cleanly Yes
Interoperability type R98
Interoperability version 1,0,0
GPS sub-IFD
Loaded cleanly Yes
GPS version 2,3,0
GPS latitude 50,6,79775/1544N
GPS longitude 8,40,89923/1690E
Thumbnail IFD
Loaded cleanly Yes
Thumbnail resolution 180 x 180 inches
--------------------------------------------------------------------------------
+ <--- test is passed
- <--- test fails, Tag not found by dExif
-------------------------------------------------------------------------------}
function ExtractFloat(s: String): Double;
const
NUMERIC_CHARS = ['0'..'9', '.', ',', '/'];
var
p: PChar;
n, m: Integer;
s1, s2: String;
a, b: Integer;
begin
p := PChar(@s[1]);
n := 0;
while (p^ <> #0) and not (p^ in NUMERIC_CHARS) do begin
inc(p);
inc(n);
end;
Delete(s, 1, n);
if s = '' then begin
Result := 0.0;
exit;
end;
p := PChar(@s[1]);
n := 0;
m := 0;
while (p^ <> #0) and (p^ in NUMERIC_CHARS) do begin
case p^ of
',': p^ := '.';
'/': begin
s1 := Copy(s, 1, n);
m := n+2;
end;
end;
inc(p);
inc(n);
end;
SetLength(s, n);
if m > 0 then begin
s2 := copy(s, m, MaxInt);
a := StrToInt(s1);
b := StrToInt(s2);
Result := a/b;
end else begin
val(s, Result, n);
if n <> 0 then Result := 0.0;
end;
end;
{ Preparation }
procedure TTstReadFile_dEXIF_01.SetUp;
begin
inherited SetUp;
{ Test ...01 will operate on image co_DUTPicName01 }
FImgFileName := co_DUTPicName01;
end;
procedure TTstReadFile_dEXIF_02.SetUp;
begin
inherited SetUp;
{ Test ...02 will operate on image co_DUTPicName02 }
FImgFileName := co_DUTPicName02;
end;
procedure TTstReadFile_dEXIF_03.SetUp;
begin
inherited SetUp;
{ Test ...03 will operate on image co_DUTPicName03 }
FImgFileName := co_DUTPicName03;
end;
{ Test methods }
procedure TTstReadFile_dEXIF.SetUp;
{$ifndef FPC}
function CopyFile(f1,f2:string):boolean;
begin
Result:= {$ifndef DELPHI7}Winapi.{$endif}Windows.CopyFile(PChar(f1),PChar(f2),true);
end;
{$endif}
begin
if not FileExists(co_DUTPicName01) then
if FileExists(co_TestPic01) then
CopyFile(co_TestPic01, co_DUTPicName01);
if not FileExists(co_DUTPicName02) then
if FileExists(co_TestPic02) then
CopyFile(co_TestPic02, co_DUTPicName02);
if not FileExists(co_DUTPicName03) then
if FileExists(co_TestPic03) then
CopyFile(co_TestPic03, co_DUTPicName03);
end;
procedure TTstReadFile_dEXIF.TearDown;
begin
//if FileExists(co_DUTPicName01) then
// DeleteFile(co_DUTPicName01);
end;
{ Generic tests }
procedure TTstReadFile_dEXIF.Test_GPSPosition(const AFileName: String;
const ATagName: String; AExpectedDeg, AExpectedMin, AExpectedSec: Double;
const AMismatchMsg: String);
const
EPS = 1E-2;
var
DUT: TImgData;
currStrValue: String;
currDeg, currMin, currSec: Double;
begin
DUT := TImgData.Create;
try
DUT.ProcessFile(AFileName);
CheckTRUE(DUT.HasEXIF, 'TImgData cannot detect EXIF in file "'+AFileName+'"');
currStrValue := DUT.ExifObj.TagValueAsString[ATagName];
ExtractGPSPosition(currStrValue, currDeg, currMin, currSec);
if IsNaN(AExpectedDeg) and IsNaN(AExpectedMin) and IsNaN(AExpectedSec) then
CheckTRUE(IsNaN(currDeg) and IsNaN(currMin) and IsNaN(currSec), AMismatchMsg)
else
begin
if IsNan(currDeg) then
Fail(AMismatchMsg + ' is NaN (degrees)')
else
CheckEquals(round(AExpectedDeg), round(currDeg), AMismatchMsg + ' (degrees)');
if IsNan(currMin) then
Fail(AMismatchMsg + ' is NaN (minutes)')
else
CheckEquals(round(AExpectedMin), round(currMin), AMismatchMsg + ' (minutes)');
if IsNan(currSec) then
Fail(AMismatchMsg + ' is NaN (seconds)')
else
CheckEquals(round(AExpectedSec), round(currSec), AMismatchMsg + ' (seconds)');
end;
finally
DUT.Free;
end;
end;
{ Use NaN as AExpectedResult if the Tag does not exist in the image }
procedure TTstReadFile_dEXIF.StdFloatTest(const AFileName, ATestTag: String;
const AExpectedResult: Double; ADecimals: Integer;
const AMismatchMsg: String);
var
DUT: TImgData;
currStrValue: String;
currFloatValue: Double;
currVal, expVal: Double;
begin
DUT := TImgData.Create;
try
DUT.ProcessFile(AFileName);
CheckTRUE(DUT.HasEXIF, 'TImgData cannot detect EXIF in file "'+AFileName+'"');
currFloatValue := DUT.ExifObj.GetRawFloat(ATestTag);
if IsNaN(AExpectedResult) then begin
currStrValue := DUT.ExifObj.TagValueAsString[ATestTag];
CheckEquals('', currStrValue, AMismatchMsg);
end else
begin
currVal := RoundTo(currFloatValue, -ADecimals);
expVal := RoundTo(AExpectedResult, -ADecimals);
CheckEquals(expval, currval, AMismatchMsg);
end;
finally
DUT.Free;
end;
end;
{ Compares float values passed as strings. The routine takes care of
different decimal separators, non-numerical characters before or after the
number, and rounds the result to the specified decimal places. }
procedure TTstReadFile_dEXIF.StdFloatFromStringTest(const AFilename, ATestTag: String;
const AExpectedResult: String; ADecimals: Integer; const AMismatchMsg: String);
var
DUT: TImgData;
currStrValue: String;
currval, expVal: Double;
begin
DUT := TImgData.Create;
try
DUT.ProcessFile(AFileName);
CheckTRUE(DUT.HasEXIF, 'TImgData cannot detect EXIF in file "'+AFileName+'"');
currStrValue := DUT.ExifObj.TagValueAsString[ATestTag];
if currStrValue = '' then
currVal := 0.0
else begin
currVal := ExtractFloat(currStrValue);
currVal := RoundTo(currVal, -ADecimals);
end;
if AExpectedResult = '' then
expVal := 0.0
else begin
expVal := ExtractFloat(AExpectedResult);
expVal := RoundTo(expVal, -ADecimals);
end;
CheckEquals(expval, currval, AMismatchMsg);
finally
DUT.Free;
end;
end;
procedure TTstReadFile_dEXIF.StdIntTest(const AFileName, ATestTag: String;
const AExpectedResult: Integer; const AMismatchMsg: String);
var
DUT: TImgData;
currIntValue: Integer;
begin
DUT := TImgData.Create;
try
DUT.ProcessFile(AFilename);
CheckTRUE(DUT.HasEXIF, 'TImgData cannot detect EXIF in file "'+AFileName+'"');
currIntValue := DUT.ExifObj.GetRawInt(ATestTag); //LookupTagInt(ATestTag);
CheckEquals(AExpectedResult, currIntValue, AMismatchMsg);
finally
DUT.Free;
end;
end;
procedure TTstReadFile_dEXIF.StdStringTest(
const AFileName, ATestTag, AExpectedResult, AMismatchMsg: String);
var
DUT: TImgData;
currStrValue: String;
begin
DUT := TImgData.Create;
try
DUT.ProcessFile(AFilename);
CheckTRUE(DUT.HasEXIF, 'TImgData cannot detect EXIF in file "'+AFileName+'"');
currStrValue := DUT.ExifObj.TagValueAsString[ATestTag];
// dEXIF strings sometimes are quoted...
if (currStrValue <> '') and (currStrValue[1] = '"') then
Delete(currStrValue, 1,1);
if (currStrValue <> '') and (currStrValue[Length(currStrValue)] = '"') then
Delete(currStrValue, Length(currStrValue), 1);
CheckEquals(AExpectedResult, currStrValue, AMismatchMsg);
finally
DUT.Free;
end;
end;
{ Artist }
procedure TTstReadFile_dEXIF_01.TstReadFile_Artist;
begin
StdStringTest(FImgFileName, 'Artist', '', 'Artist mismatch');
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_Artist;
begin
StdStringTest(FImgFileName, 'Artist', 'wp', 'Artist mismatch');
end;
procedure TTstReadFile_dEXIF_03.TstReadFile_Artist;
begin
StdStringTest(FImgFileName, 'Artist', 'Mitja Stachowiak', 'Artist mismatch');
end;
{ Aperture value }
procedure TTstReadFile_dEXIF_01.TstReadFile_ApertureValue;
begin
StdFloatTest(FImgFileName, 'ApertureValue', NaN, 1, 'Aperature value mismatch');
// It is listed in EXIFTool output, but not in CCR.EXIF Tag List, and
// is not found by EXIFSpy. --> NaN
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_ApertureValue;
begin
StdFloatTest(FImgFileName, 'ApertureValue', 2.875, 1, 'Aperature value mismatch');
// EXIFTool shows a value 2.7 here, but CCR.EXIF Tag List lists the value 2.875
// that is also seen by Serif PhotoPlus X7 and EXIFSpy.
// I suppose that EXIFTool displays the FNumber value. --> 2.875
end;
(*
{ Bits per sample }
procedure TTstReadFile_dEXIF_01.TstReadFile_BitsPerSample;
begin
StdIntTest(FImgFileName, 'BitsPerSample', 8, 'BitsPerSample usage mismatch');
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_BitsPerSample;
begin
StdIntTest(FImgFileName, 'BitsPerSample', 8, 'BitsPerSample mismatch');
// "Auto" --> 0
end;
*)
{ Byte order }
procedure TTstReadFile_dEXIF.Test_ByteOrder(const AFilename: String;
AExpected: Boolean);
var
DUT: TImgData;
begin
DUT := TImgData.Create;
try
DUT.ProcessFile(AFilename);
CheckTRUE(DUT.HasEXIF, 'TImgData cannot detect EXIF in file "'+AFileName+'"');
CheckEquals(AExpected, DUT.ExifObj.MotorolaOrder, 'ByteOrder mismatch');
finally
DUT.Free;
end;
end;
procedure TTstReadFile_dEXIF_01.TstReadFile_ByteOrder;
begin
Test_ByteOrder(FImgFileName, true);
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_ByteOrder;
begin
Test_ByteOrder(FImgFileName, false);
end;
{ Camera Make }
procedure TTstReadFile_dEXIF_01.TstReadFile_CameraMake;
begin
StdStringTest(FImgFileName, 'Make', 'SAMSUNG', 'Camera Make mismatch');
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_CameraMake;
begin
StdStringTest(FImgFileName, 'Make', 'Canon', 'Camera Make mismatch');
end;
{ Camera model }
procedure TTstReadFile_dEXIF_01.TstReadFile_CameraModel;
begin
StdStringTest(FImgFileName, 'Model', 'SM-G850F', 'Camera model mismatch');
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_CameraModel;
begin
StdStringTest(FImgFileName, 'Model', 'Canon PowerShot S5 IS', 'Camera model mismatch');
end;
{ Color space }
procedure TTstReadFile_dEXIF_01.TstReadFile_ColorSpace;
begin
StdStringTest(FImgFileName, 'ColorSpace', '', 'ColorSpace mismatch');
// Tag not available
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_ColorSpace;
begin
StdStringTest(FImgFileName, 'ColorSpace', 'sRGB', 'ColorSpace mismatch');
end;
{ Comment in Exif Segement: Tag UserComment}
procedure TTstReadFile_dEXIF.Test_UserComment(const AFileName, AExpected: String);
var
DUT: TImgData;
currStrValue: String;
begin
DUT := TImgData.Create;
try
DUT.ProcessFile(AFileName);
currStrValue := DUT.ExifObj.ExifComment;
CheckEquals(AExpected, currStrValue, 'User comment mismatch');
finally
DUT.Free;
end;
end;
procedure TTstReadFile_dEXIF_01.TstReadFile_CommentExif;
begin
Test_UserComment(FImgFileName, '');
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_CommentExif;
const
{$IFDEF FPC}
COMMENT_TEXT = 'This is an EXIF user comment with äöü';
{$ELSE}
COMMENT_TEXT = 'This is an EXIF user comment with ' + #228 + #246 + #252;
{$ENDIF}
begin
Test_UserComment(FImgFileName, COMMENT_TEXT);
end;
{$IFNDEF DELPHI7}
procedure TTstReadFile_dEXIF_03.TstReadFile_CommentExif;
const
{$IFDEF FPC}
CYRILLIC = 'Лев Николаевич Толсто́й';
{$ELSE}
CYRILLIC = #$041B#$0435#$0432#$0020#$041D#$0438#$043A +
#$043E#$043B#$0430#$0435#$0432#$0438#$0447#$0020 +
#$0422#$043E#$043B#$0441#$0442#$043E#$0301#$0439;
{$ENDIF}
begin
Test_UserComment(FImgFileName, 'am Reinheimer Teich - ' + CYRILLIC + ' - End of line.');
end;
{$ENDIF}
{ CommentSegment }
procedure TTstReadFile_dEXIF.ReadFile_CommentSegment(
const AFileName, AExpected: String);
var
DUT: TImgData;
currStrValue: String;
begin
DUT := TImgData.Create;
try
DUT.ProcessFile(AFileName);
CheckEquals(AExpected <> '', DUT.HasComment, 'No comment segment found');
if Dut.HasComment then begin
currStrValue := DUT.Comment;
CheckEquals(AExpected, currStrValue, 'Comment text mismatch');
end;
finally
DUT.Free;
end;
end;
procedure TTstReadFile_dEXIF_01.TstReadFile_CommentSegment;
begin
ReadFile_CommentSegment(FImgFileName, '');
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_CommentSegment;
begin
ReadFile_CommentSegment(FImgFileName, 'This text is in COMMENT section');
end;
procedure TTstReadFile_dEXIF_03.TstReadFile_CommentSegment;
begin
ReadFile_CommentSegment(FImgFileName, '');
end;
{ Compressed Bits per Pixel }
procedure TTstReadFile_dEXIF_01.TstReadFile_CompressedBitsPerPixel;
begin
StdIntTest(FImgFileName, 'CompressedBitsPerPixel', -1, 'Compressed bits per pixel mismatch');
// Tag not specified --> -1
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_CompressedBitsPerPixel;
begin
StdIntTest(FImgFileName, 'CompressedBitsPerPixel', 3, 'Compressed bits per pixel mismatch');
end;
{ wp: not found
{ Compression }
//procedure TTstReadFile_dEXIF_01.TstReadFile_Compression;
//begin
// StdIntTest(FImgFileName, 'Compression', -1, 'Compression mismatch');
// // Tag not specified --> -1
//end;
//
//procedure TTstReadFile_dEXIF_02.TstReadFile_Compression;
//begin
// StdIntTest(FImgFileName, 'Compression', 6, 'Compression mismatch');
// // "JPEG (old style)" --> 6.
// // Other values at https://sno.phy.queensu.ca/~phil/exiftool/TagNames/EXIF.html#Compression
//end;
// }
{ CustomRendered }
procedure TTstReadFile_dEXIF_01.TstReadFile_CustomRendered;
begin
StdIntTest(FImgFileName, 'CustomRendered', -1, 'CustomRendered mismatch');
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_CustomRendered;
begin
StdIntTest(FImgFileName, 'CustomRendered', 0, 'CustomRendered mismatch');
// CCR ExifList: "Normal" --> 0
end;
{ Generic Date/time test }
procedure TTstReadFile_dEXIF.Test_DateTime(const AFileName: String; AKind: Integer;
AExpectedDateTime: TDateTime);
var
DUT: TImgData;
currValue: TDateTime;
begin
DUT := TImgData.Create();
try
DUT.ProcessFile(AFilename);
CheckTRUE(DUT.HasEXIF, 'TImgData cannot detect EXIF in file:'+co_DUTPicName01);
case AKind of
0: currValue := DUT.EXIFObj.GetImgDateTime; // any date/time available
1: currValue := DUT.EXIFObj.DateTimeOriginal; // Tag "DateTimeOriginal"
2: currValue := DUT.EXIFObj.DateTimeDigitized; // Tag "DateTimeDigitized"
3: currValue := Dut.EXIFObj.DateTimeModified; // Tag "DateTimeModified"
end;
CheckEquals(AExpectedDateTime, currValue, 'Date/time mismatch');
finally
DUT.Free;
end;
end;
procedure TTstReadFile_dEXIF_01.TstReadFile_DateTime;
begin
Test_DateTime(FImgFileName, 0, EncodeDateTime(2017,03,15, 10,35,11,0));
// 2017:03:15 10:35:11
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_DateTime;
begin
Test_DateTime(FImgFileName, 0, EncodeDateTime(2017,02,11, 15,09,39,0));
// 2017:02:11 15:09:39
end;
procedure TTstReadFile_dEXIF_01.TstReadFile_DateTime_Original;
begin
Test_DateTime(FImgFileName, 1, EncodeDateTime(2017,03,15, 10,35,11,0));
// 2017:03:15 10:35:11
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_DateTime_Original;
begin
Test_DateTime(FImgFileName, 1, EncodeDateTime(2017,02,11, 15,09,39,0));
// 2017:02:11 15:09:39
end;
procedure TTstReadFile_dEXIF_01.TstReadFile_DateTime_Digitized;
begin
Test_DateTime(FImgFileName, 2, 0.0);
// Tag not available --> 0.0
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_DateTime_Digitized;
begin
Test_DateTime(FImgFileName, 2, EncodeDateTime(2017,02,11, 15,09,39,0));
// 2017:02:11 15:09:39
end;
procedure TTstReadFile_dEXIF_01.TstReadFile_DateTime_Modified;
begin
Test_DateTime(FImgFileName, 3, 0.0);
// Tag not available --> 0.0
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_DateTime_Modified;
begin
Test_DateTime(FImgFileName, 3, EncodeDateTime(2017,02,11, 15,09,39,0));
// 2017:02:11 15:09:39
end;
{ Digital zoom ratio }
procedure TTstReadFile_dEXIF_01.TstReadFile_DigitalZoomRatio;
begin
StdIntTest(FImgFileName, 'DigitalZoomRatio', -1, 'Digital zoom ratio mismatch');
// Tag not available in this image
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_DigitalZoomRatio;
begin
StdIntTest(FImgFileName, 'DigitalZoomRatio', 1, 'Digital zoom ratio mismatch');
end;
{ Exif image length }
procedure TTstReadFile_dEXIF_01.TstReadFile_ExifImageLength;
begin
StdIntTest(FImgFileName, 'ExifImageLength', -1, 'Exif image length mismatch');
// Tag not available in this image
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_ExifImageLength;
begin
StdIntTest(FImgFileName, 'ExifImageLength', 200, 'Exif image length mismatch');
end;
{ Exif image width }
procedure TTstReadFile_dEXIF_01.TstReadFile_ExifImageWidth;
begin
StdIntTest(FImgFileName, 'ExifImageWidth', -1, 'Exif image width mismatch');
// Tag not available in this image
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_ExifImageWidth;
begin
StdIntTest(FImgFileName, 'ExifImageWidth', 356, 'Exif image width mismatch');
end;
{ Exif version }
procedure TTstReadFile_dEXIF_01.TstReadFile_ExifVersion;
begin
StdStringTest(FImgFileName, 'ExifVersion', '', 'Exif version mismatch');
// Tag not available in this image
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_ExifVersion;
begin
StdStringTest(FImgFileName, 'ExifVersion', '0220', 'Exif version mismatch');
end;
{ Exposure bias value }
procedure TTstReadFile_dEXIF_01.TstReadFile_ExposureBiasValue;
begin
StdFloatTest(FImgFileName, 'ExposureBiasValue', NaN, 2, 'Exposure bias value mismatch');
// Tag not available in this image
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_ExposureBiasValue;
begin
StdFloatTest(FImgFileName, 'ExposureBiasValue', 0.0, 2, 'Exposure bias value mismatch');
end;
{ Exposure mode }
procedure TTstReadFile_dEXIF_01.TstReadFile_ExposureMode;
begin
StdIntTest(FImgFileName, 'ExposureMode', -1, 'ExposureMode mismatch');
// Tag not specified --> -1
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_ExposureMode;
begin
StdIntTest(FImgFileName, 'ExposureMode', 0, 'ExposreMode mismatch');
// "Auto" --> 0
end;
{ Exposure program }
procedure TTstReadFile_dEXIF_01.TstReadFile_ExposureProgram;
begin
StdIntTest(FImgFileName, 'ExposureProgram', -1, 'Exposure program mismatch');
// Tag not specified --> -1
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_ExposureProgram;
begin
StdIntTest(FImgFileName, 'ExposureProgram', -1, 'Exposure program mismatch');
// Tag not available --> -1
end;
{ Exposure time }
procedure TTstReadFile_dEXIF_01.TstReadFile_ExposureTime;
begin
StdFloatTest(FImgFilename, 'ExposureTime', 1/3376, 8, 'Exposure time mismatch');
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_ExposureTime;
begin
StdFloatTest(FImgFilename, 'ExposureTime', 1/1600, 8, 'Exposure time mismatch');
end;
{ File source }
procedure TTstReadFile_dEXIF_01.TstReadFile_FileSource;
begin
StdIntTest(FImgFileName, 'FileSource', -1, 'File source mismatch');
// Tag not used --> -1
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_FileSource;
begin
StdIntTest(FImgFileName, 'FileSource', 3, 'File source mismatch');
// "Digital camera" --> 3
end;
(*
{ Firmware version }
procedure TTstReadFile_dEXIF_01.TstReadFile_FirmwareVersion;
begin
StdStringTest(FImgFileName, 'FirmwareVersion', '', 'Firmware version mismatch');
// Tag not used
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_FirmwareVersion;
begin
StdStringTest(FImgFileName, 'FirmwareVersion', 'Firmware Version 1.01', 'Firmware version mismatch');
end;
*)
{ Flash }
procedure TTstReadFile_dEXIF_01.TstReadFile_Flash;
begin
StdIntTest(FImgFileName, 'Flash', -1, 'Flash usage mismatch');
// Tag not used
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_Flash;
begin
StdIntTest(FImgFileName, 'Flash', 16, 'Flash usage mismatch'); // "Off, Did not fire"
// see https://stackoverflow.com/questions/44579889/using-bitwise-to-enumerate-exif-flash-readable-string
// "Off, did not fire" corresponds to Flash value = 16
end;
{ Flash Pix Version}
procedure TTstReadFile_dEXIF_01.TstReadFile_FlashPixVersion;
begin
StdStringTest(FImgFileName, 'FlashPixVersion', '', 'FlashPix version mismatch');
// Tag not used
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_FlashPixVersion;
begin
StdStringTest(FImgFileName, 'FlashPixVersion', '0100', 'FlashPix version mismatch');
end;
{ F Number }
procedure TTstReadFile_dEXIF_01.TstReadFile_FNumber;
begin
StdFloatTest(FImgFileName, 'FNumber', 2.2, 1, 'F number mismatch');
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_FNumber;
begin
StdFloatTest(FImgFileName, 'FNumber', 2.7, 1, 'F number mismatch');
end;
{ Focal length }
procedure TTstReadFile_dEXIF_01.TstReadFile_FocalLength;
begin
StdFloatTest(FImgFileName, 'FocalLength', 4.1, 1, 'Focal length mismatch');
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_FocalLength;
begin
StdFloatTest(FImgFileName, 'FocalLength', 6.0, 1, 'Focal length mismatch');
end;
{ Focal length in 35 mm }
procedure TTstReadFile_dEXIF_01.TstReadFile_FocalLengthIn35mmFilm;
begin
StdFloatFromStringTest(FImgFileName, 'FocalLengthIn35mmFilm', '', 0, 'Focal length in 35mm film mismatch');
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_FocalLengthIn35mmFilm;
begin
StdFloatFromStringTest(FImgFileName, 'FocalLengthIn35mmFilm', '36', 0, 'Focal length in 35mm film mismatch');
end;
{ Focal plane x resolution }
procedure TTstReadFile_dEXIF_01.TstReadFile_FocalPlaneXResolution;
begin
StdFloatTest(FImgFileName, 'FocalPlaneXResolution', NaN, 0, 'Focal plane X resolution mismatch');
// This image does not contain this tag
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_FocalPlaneXResolution;
begin
StdFloatTest(FImgFileName, 'FocalPlaneXResolution', 14506.66667, 3, 'Focal plane X resolution mismatch');
end;
{ Focal plane y resolution }
procedure TTstReadFile_dEXIF_01.TstReadFile_FocalPlaneYResolution;
begin
StdFloatTest(FImgFileName, 'FocalPlaneYResolution', NaN, 0, 'Focal plane Y resolution mismatch');
// This image does not contain this tag
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_FocalPlaneYResolution;
begin
StdFloatTest(FImgFileName, 'FocalPlaneYResolution', 10840.23669, 3, 'Focal plane Y resolution mismatch');
end;
{ Focal plane resolution unit }
procedure TTstReadFile_dEXIF_01.TstReadFile_FocalPlaneResolutionUnit;
begin
StdIntTest(FImgFileName, 'FocalPlaneResolutionUnit', -1, 'Focal plane resolution unit mismatch');
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_FocalPlaneResolutionUnit;
begin
StdIntTest(FImgFileName, 'FocalPlaneResolutionUnit', 2, 'Focal plane resolution unit mismatch');
// 'inches' --> 2
end;
{ GPS latitude }
procedure TTstReadFile_dEXIF_01.TstReadFile_GPSLatitude;
begin
Test_GPSPosition(FImgFileName, 'GPSLatitude', NaN, NaN, NaN,'GPS latitude mismatch');
// No GPS info in this image
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_GPSLatitude;
begin
Test_GPSPosition(FImgFileName, 'GPSLatitude', 50, 6, 51.67, 'GPS latitude mismatch');
// output of EXIFTool: 50 deg 6' 51.67" N
end;
procedure TTstReadFile_dEXIF_01.TstReadFile_GPSLatitudeRef;
begin
StdStringTest(FImgFileName, 'GPSLatitudeRef', '', 'GPS latitude reference mismatch');
// No GPS info in this image
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_GPSLatitudeRef;
begin
StdStringTest(FImgFileName, 'GPSLatitudeRef', 'N', 'GPS latitude reference mismatch');
// output of EXIFTool: 50 deg 6' 51.67" N --> 'N'
end;
{ GPS longitude }
procedure TTstReadFile_dEXIF_01.TstReadFile_GPSLongitude;
begin
Test_GPSPosition(FImgFileName, 'GPSLongitude', NaN, NaN, NaN, 'GPS longitude mismatch');
// No GPS info in this image
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_GPSLongitude;
begin
Test_GPSPosition(FImgFileName, 'GPSLongitude', 8, 40, 53.21, 'GPS longitude mismatch');
// output of EXIFTool: 8 deg 40' 53.21" E
end;
{ GPS latitude reference }
{ GPS longitude reference }
procedure TTstReadFile_dEXIF_01.TstReadFile_GPSLongitudeRef;
begin
StdStringTest(FImgFileName, 'GPSLongitudeRef', '', 'GPS longitude reference mismatch');
// No GPS info in this image
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_GPSLongitudeRef;
begin
StdStringTest(FImgFileName, 'GPSLongitudeRef', 'E', 'GPS longitude reference mismatch');
// output of EXIFTool: 8 deg 40' 53.21" E --> 'E'
end;
{ Image description }
procedure TTstReadFile_dEXIF_01.TstReadFile_ImageDescription;
begin
StdStringTest(FImgFileName, 'ImageDescription', '', 'Image description mismatch');
// Tag not used by this image
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_ImageDescription;
begin
StdStringTest(FImgFileName, 'ImageDescription', 'MyZeil Shopping Center', 'Image description mismatch');
end;
procedure TTstReadFile_dEXIF_03.TstReadFile_ImageDescription;
begin
StdStringTest(FImgFileName, 'ImageDescription', 'Schilfgebiet', 'Image description mismatch');
end;
{ Image width and image height }
procedure TTstReadFile_dEXIF.Test_ImageSize(const AFileName: String;
AExpectedWidth, AExpectedHeight: Integer);
var
DUT: TImgData;
begin
DUT := TImgData.Create;
try
DUT.ProcessFile(AFileName);
CheckTRUE(DUT.HasEXIF, 'TImgData cannot detect EXIF in file "'+AFileName+'"');
CheckEquals(AExpectedWidth, DUT.Width, 'Image width mismatch');
CheckEquals(AExpectedHeight, DUT.Height, 'Image height mismatch');
finally
DUT.Free;
end;
end;
procedure TTstReadFile_dEXIF_01.TstReadFile_ImageSize;
begin
Test_ImageSize(FImgFileName, 4608, 2592);
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_ImageSize;
begin
Test_ImageSize(FImgFileName, 356, 200);
end;
(*
{ Image type }
procedure TTstReadFile_dEXIF_01.TstReadFile_ImageType;
begin
StdStringTest(FImgFileName, 'ImageType', '', 'ImageType mismatch');
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_ImageType;
begin
StdStringTest(FImgFileName, 'ImageType', 'IMG:PowerShot S5 IS JPEG', 'ImageType mismatch');
end;
*)
{ ISO }
procedure TTstReadFile_dEXIF_01.TstReadFile_ISO;
begin
StdStringTest(FImgFileName, 'ISOSpeedRatings', '40, 0', 'ISO mismatch');
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_ISO;
begin
StdStringTest(FImgFileName, 'ISOSpeedRatings', '160', 'ISO mismatch');
end;
{ Max Aperture value }
procedure TTstReadFile_dEXIF_01.TstReadFile_MaxApertureValue;
begin
StdFloatTest(FImgFileName, 'MaxApertureValue', NaN, 1, 'Max aperature value mismatch');
// Tag not used
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_MaxApertureValue;
begin
StdFloatTest(FImgFileName, 'MaxApertureValue', 2.875, 1, 'Max aperature value mismatch');
end;
{ Metering mode }
procedure TTstReadFile_dEXIF_01.TstReadFile_MeteringMode;
begin
StdIntTest(FImgFileName, 'MeteringMode', -1, 'Metering mode mismatch');
// Tag not used
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_MeteringMode;
begin
StdIntTest(FImgFileName, 'MeteringMode', 5, 'Metering mode mismatch');
// ccr Exif List reports it as "Pattern" corresponding to the value 5 in
// the EXIF documentation.
// IrfanView calls it "MultiSegment" which is directly the dEXIF text for 5
// Not idea what the "Evaluative" of ExifTool means...
end;
{ Orientation }
procedure TTstReadFile_dEXIF_01.TstReadFile_Orientation;
begin
StdIntTest(FImgFileName, 'Orientation', -1, 'Orientation mismatch');
// Tag not available --> -1
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_Orientation;
begin
StdIntTest(FImgFileName, 'Orientation', 1, 'Orientation mismatch');
// "Horizontal (normal)" --> 1
end;
{ Related image height }
procedure TTstReadFile_dEXIF_01.TstReadFile_RelatedImageHeight;
begin
StdIntTest(FImgFileName, 'RelatedImageHeight', -1, 'Related image height mismatch');
// Tag not available --> -1
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_RelatedImageHeight;
begin
StdIntTest(FImgFileName, 'RelatedImageHeight', 1832, 'Related image height mismatch');
end;
{ Related image width }
procedure TTstReadFile_dEXIF_01.TstReadFile_RelatedImageWidth;
begin
StdIntTest(FImgFileName, 'RelatedImageWidth', -1, 'Related image width mismatch');
// Tag not available --> -1
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_RelatedImageWidth;
begin
StdIntTest(FImgFileName, 'RelatedImageWidth', 3264, 'Related image width mismatch');
end;
{ Resolution }
procedure TTstReadFile_dEXIF.Test_Resolution(const AFileName: String;
AExpectedXResolution, AExpectedYResolution: Integer; AExpectedUnits: String);
var
DUT: TImgData;
currIntValue: Integer;
currStrValue: String;
begin
DUT := TImgData.Create();
try
DUT.ProcessFile(AFileName);
CheckTRUE(DUT.HasEXIF, 'TImgData cannot detect EXIF in file "'+AFileName+'"');
currIntValue := DUT.XResolution;
CheckEquals(AExpectedXRESOLUTION, currIntValue, 'X resolution mismatch');
currIntValue := DUT.YResolution;
CheckEquals(AExpectedYRESOLUTION, currIntValue, 'Y resolution mismatch');
currStrValue := DUT.ResolutionUnit;
CheckEquals(lowercase(AExpectedUnits), lowercase(currStrValue), 'Resolution unit mismatch');
finally
DUT.Free;
end;
end;
procedure TTstReadFile_dEXIF_01.TstReadFile_Resolution;
begin
Test_Resolution(FImgFileName, 300, 300, 'inches');
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_Resolution;
begin
Test_Resolution(FImgFileName, 180, 180, 'inches');
end;
{ Resolution unit}
procedure TTstReadFile_dEXIF_01.TstReadFile_ResolutionUnit;
begin
StdIntTest(FImgFileName, 'ResolutionUnit', -1, 'Resolution unit mismatch');
// Tag not used in this image file
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_ResolutionUnit;
begin
StdIntTest(FImgFileName, 'ResolutionUnit', 2, 'Resolution unit mismatch');
// "inch" --> 2
end;
{ Scene capture type }
procedure TTstReadFile_dEXIF_01.TstReadFile_SceneCaptureType;
begin
StdIntTest(FImgFileName, 'SceneCaptureType', -1, 'Scene capture type mismatch');
// Tag not available --> -1
end;
procedure TTstReadFile_dEXIF_02.TstReadfile_SceneCaptureType;
begin
StdIntTest(FImgFileName, 'SceneCaptureType', 0, 'Scene capture type mismatch');
// "Standard" --> 0
end;
{ Sensing method }
procedure TTstReadFile_dEXIF_01.TstReadFile_SensingMethod;
begin
StdIntTest(FImgFileName, 'SensingMethod', -1, 'SensingMethod mismatch');
// Tag not available --> -1
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_SensingMethod;
begin
StdIntTest(FImgFileName, 'SensingMethod', 2, 'SensingMethod mismatch');
// "One-chip color area" --> 2
end;
{ Shutter speed value }
procedure TTstReadFile_dEXIF_01.TstReadFile_ShutterSpeedValue;
begin
StdFloatTest(FImgFileName, 'ShutterSpeedValue', NaN, 8, 'Shutter speed value mismatch');
// Tag not available (EXIFTool does list a "Shutter Speed", but the tag is
// not in the file, the value is probably taken from tag "ExposureTime")
// --> NaN
end;
{ BE CAREFUL WITH THIS TEST: IT REQUIRES TRANSFORMATION OF THE EXPECTED VALUE
SHOWN BY THE EXIF REFERENCE PROGRAM. }
procedure TTstReadFile_dEXIF_02.TstReadFile_ShutterSpeedValue;
const
EPS = 0.01; // Allow 1% tolerance for rounding errors etc.
var
expectedExposureTime: Double;
expectedShutterSpeed: Double;
allowedDigits: Integer;
begin
// Note: ShutterSpeedValue is stored as -log2 of exposure time.
// see Annex C in EXIF specification
expectedExposureTime := 1/1614;
expectedShutterSpeed := -log2(expectedExposureTime);
allowedDigits := round(abs(log10(EPS * expectedShutterspeed)));
StdFloatTest(FImgFileName, 'ShutterSpeedValue', expectedShutterSpeed,
allowedDigits, 'Shutter speed value mismatch');
end;
{ White balance }
procedure TTstReadFile_dEXIF_01.TstReadFile_WhiteBalance;
begin
StdIntTest(FImgFileName, 'WhiteBalance', -1, 'WhiteBalance mismatch');
// Tag not available --> -1
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_WhiteBalance;
begin
StdIntTest(FImgFileName, 'WhiteBalance', 0, 'WhiteBalance mismatch');
// "Auto" --> 0
end;
{ X Resolution }
procedure TTstReadFile_dEXIF_01.TstReadFile_XResolution;
begin
StdIntTest(FImgFileName, 'XResolution', -1, 'XResolution mismatch');
// Tag not used in this image file
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_XResolution;
begin
StdIntTest(FImgFileName, 'XResolution', 180, 'XResolution mismatch');
end;
{ YCbCr Positioning }
procedure TTstReadFile_dEXIF_01.TstReadFile_YCbCrPositioning;
begin
StdIntTest(FImgFileName, 'YCbCrPositioning', -1, 'YCbCrPositioning mismatch');
// Tag not specified --> -1
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_YCbCrPositioning;
begin
StdIntTest(FImgFileName, 'YCbCrPositioning', 1, 'YCbCrPositioning mismatch');
// "centered" --> 1
end;
(*
{ YCbCr Subsampling }
procedure TTstReadFile_dEXIF_01.TstReadFile_YCbCrSubsampling;
begin
StdStringTest(FImgFileName, 'YCbCrSubsampling', 'YCbCr4:2:0 (2 2)', 'YCbCrSubsampling mismatch');
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_YCbCrSubsampling;
begin
StdStringTest(FImgFileName, 'YCbCrSubsampling', 'YCbCr4:2:2 (2 1)', 'YCbCrsubsampling mismatch');
end;
*)
{ Y Resolution }
procedure TTstReadFile_dEXIF_01.TstReadFile_YResolution;
begin
StdIntTest(FImgFileName, 'YResolution', -1, 'YResolution mismatch');
// Tag not used in this image file
end;
procedure TTstReadFile_dEXIF_02.TstReadFile_YResolution;
begin
StdIntTest(FImgFileName, 'YResolution', 180, 'YResolution mismatch');
end;
initialization
{$ifndef FPC}TestFramework.{$endif}RegisterTest(TTstReadFile_dEXIF_01{$ifndef FPC}.Suite{$endif});
{$ifndef FPC}TestFramework.{$endif}RegisterTest(TTstReadFile_dEXIF_02{$ifndef FPC}.Suite{$endif});
{$ifndef FPC}TestFramework.{$endif}RegisterTest(TTstReadFile_dEXIF_03{$ifndef FPC}.Suite{$endif});
end.
| 30.405329 | 111 | 0.689494 |
fc65537195dec3c7b99c4a4bfc5acb67be78a430 | 1,495 | pas | Pascal | src/REST4D.Request.pas | AndersondaCampo/REST4D | e13839e4502b0867342b1d4d5a7f059667f222d9 | [
"MIT"
]
| 8 | 2021-05-24T19:43:07.000Z | 2022-02-17T19:38:56.000Z | src/REST4D.Request.pas | AndersondaCampo/REST4D | e13839e4502b0867342b1d4d5a7f059667f222d9 | [
"MIT"
]
| null | null | null | src/REST4D.Request.pas | AndersondaCampo/REST4D | e13839e4502b0867342b1d4d5a7f059667f222d9 | [
"MIT"
]
| null | null | null | unit REST4D.Request;
interface
uses
REST4D.interfaces,
REST.Client;
type
TRequest<T: IInterface> = Class(TInterfacedObject, IRequest<T>)
private
[weak]
FParent : T;
FRequest: TRESTRequest;
public
function SynchronizedEvents(const AValue: Boolean): IRequest<T>;
function AcceptEncoding(const AValue: String): IRequest<T>;
function TimeOut(const AValue: Integer): IRequest<T>;
function &End: T;
class function New(AParent: T; Request: TRESTRequest): IRequest<T>;
constructor Create(AParent: T; Request: TRESTRequest);
destructor Destroy; override;
End;
implementation
{ TRequest<T> }
function TRequest<T>.AcceptEncoding(const AValue: String): IRequest<T>;
begin
Result := Self;
FRequest.AcceptEncoding := AValue;
end;
constructor TRequest<T>.Create(AParent: T; Request: TRESTRequest);
begin
FParent := AParent;
FRequest := Request;
end;
destructor TRequest<T>.Destroy;
begin
inherited;
end;
function TRequest<T>.&End: T;
begin
Result := FParent;
end;
class function TRequest<T>.New(AParent: T; Request: TRESTRequest): IRequest<T>;
begin
Result := TRequest<T>.Create(AParent, Request);
end;
function TRequest<T>.SynchronizedEvents(const AValue: Boolean): IRequest<T>;
begin
Result := Self;
FRequest.SynchronizedEvents := AValue;
end;
function TRequest<T>.TimeOut(const AValue: Integer): IRequest<T>;
begin
Result := Self;
FRequest.Timeout := AValue;
end;
end.
| 21.056338 | 79 | 0.698328 |
47fa2a21ba8f59de4bb37145c425a10f694c4156 | 22,461 | dfm | Pascal | Production7/Banks/EditBank.dfm | kadavris/ok-sklad | f9cd84be7bf984104d9af93d83c0719f2d5668c5 | [
"MIT"
]
| 1 | 2016-04-04T18:11:56.000Z | 2016-04-04T18:11:56.000Z | Production7/Banks/EditBank.dfm | kadavris/ok-sklad | f9cd84be7bf984104d9af93d83c0719f2d5668c5 | [
"MIT"
]
| null | null | null | Production7/Banks/EditBank.dfm | kadavris/ok-sklad | f9cd84be7bf984104d9af93d83c0719f2d5668c5 | [
"MIT"
]
| 5 | 2016-02-15T02:08:05.000Z | 2021-04-05T08:57:58.000Z | inherited frmEditBank: TfrmEditBank
Left = 331
Top = 206
VertScrollBar.Range = 0
ActiveControl = gbContact
BorderStyle = bsDialog
Caption = 'frmEditBank'
ClientHeight = 507
ClientWidth = 832
OnCloseQuery = FormCloseQuery
PixelsPerInch = 96
TextHeight = 16
inherited panMain: TPanel
Width = 832
Height = 425
object tvMain: TcxTreeList
Left = 5
Top = 2
Width = 265
Height = 416
Anchors = [akLeft, akTop, akBottom]
Bands = <
item
Caption.Text = 'Band1'
end>
BufferedPaint = False
Images = dmData.Images
OptionsBehavior.CellHints = True
OptionsData.Deleting = False
OptionsSelection.CellSelect = False
OptionsSelection.HideFocusRect = False
OptionsView.ScrollBars = ssVertical
OptionsView.ColumnAutoWidth = True
OptionsView.Headers = False
PopupMenu = pmTree
TabOrder = 0
OnSelectionChanged = tvMainSelectionChanged
object colNAme: TcxTreeListColumn
DataBinding.ValueType = 'String'
Position.ColIndex = 0
Position.RowIndex = 0
Position.BandIndex = 0
Width = 263
end
end
object pcMain: TcxPageControl
Left = 276
Top = -4
Width = 550
Height = 422
ActivePage = tsContact
Anchors = [akLeft, akTop, akRight, akBottom]
Images = dmData.Images
TabOrder = 1
object tsMain: TcxTabSheet
Caption = 'tsMain'
ImageIndex = 24
TabVisible = False
object gbMain: TssGroupBox
Left = 0
Top = 0
Width = 550
Height = 422
Align = alClient
Alignment = alTopLeft
Caption = 'gbMain'
TabOrder = 0
Edges = [beLeft, beRight, beTop, beBottom]
DesignSize = (
550
422)
object lName: TLabel
Left = 18
Top = 33
Width = 56
Height = 16
Caption = #1053#1072#1079#1074#1072#1085#1080#1077
end
object lMFO: TLabel
Left = 18
Top = 62
Width = 29
Height = 16
Caption = #1052#1060#1054
end
object lAddress: TLabel
Left = 18
Top = 110
Width = 35
Height = 16
Caption = #1040#1076#1088#1077#1089
end
object lWWW: TLabel
Left = 18
Top = 255
Width = 45
Height = 16
Caption = 'Internet'
end
object btnWWW: TssSpeedButton
Left = 504
Top = 251
Width = 20
Height = 20
Alignment = taLeftJustify
AllwaysShowFrame = False
Anchors = [akTop, akRight]
ButtonType = ssbtStandard
Checked = False
Caption = 'aShowTurnIn'
GroupIndex = 0
ImageIndex = 45
Images = dmData.Images
LeftMargin = 1
Style = ssbsUser
ViewStyle = ssvsGlyphOnly
end
object lCorAcc: TLabel
Left = 18
Top = 199
Width = 55
Height = 16
Caption = #1050#1086#1088'. '#1089#1095#1105#1090
end
object edName: TcxTextEdit
Left = 123
Top = 28
Width = 408
Height = 24
Anchors = [akLeft, akTop, akRight]
Properties.MaxLength = 128
Properties.OnChange = DataModified
Style.StyleController = dmData.scMain
TabOrder = 0
ImeName = 'Russian'
OnKeyDown = GoNextKeyDown
OnKeyPress = GoNext
end
object edMFO: TcxTextEdit
Left = 123
Top = 58
Width = 139
Height = 24
Properties.MaxLength = 10
Style.StyleController = dmData.scMain
TabOrder = 1
ImeName = 'Russian'
OnKeyDown = GoNextKeyDown
OnKeyPress = GoNext
end
object memAddr: TcxMemo
Left = 123
Top = 103
Width = 408
Height = 90
Anchors = [akLeft, akTop, akRight]
ImeName = 'Russian'
Properties.MaxLength = 255
Style.StyleController = dmData.scMain
TabOrder = 2
OnKeyDown = GoNextKeyDown
OnKeyPress = GoNext
end
object edWWW: TcxButtonEdit
Left = 123
Top = 249
Width = 365
Height = 24
Anchors = [akLeft, akTop, akRight]
Properties.Buttons = <
item
Default = True
Kind = bkGlyph
Visible = False
end>
Properties.MaxLength = 64
Properties.OnChange = DataModified
Style.StyleController = dmData.scMain
TabOrder = 4
OnKeyDown = GoNextKeyDown
OnKeyPress = GoNext
end
object chbDefault: TcxCheckBox
Left = 122
Top = 278
Width = 420
Height = 24
Anchors = [akLeft, akTop, akRight]
Properties.DisplayUnchecked = 'False'
Properties.OnEditValueChanged = DataModified
Style.StyleController = dmData.scMain
TabOrder = 5
ImeName = 'Russian'
OnKeyDown = GoNextKeyDown
OnKeyPress = GoNext
end
object edCorAcc: TcxTextEdit
Left = 123
Top = 194
Width = 408
Height = 24
Anchors = [akLeft, akTop, akRight]
Properties.MaxLength = 64
Properties.OnChange = DataModified
Style.StyleController = dmData.scMain
TabOrder = 3
ImeName = 'Russian'
OnKeyDown = GoNextKeyDown
OnKeyPress = GoNext
end
end
end
object tsContact: TcxTabSheet
Caption = 'tsContact'
ImageIndex = 18
ParentShowHint = False
ShowHint = False
TabVisible = False
object gbContact: TssGroupBox
Left = 0
Top = 0
Width = 550
Height = 422
Align = alClient
Alignment = alTopLeft
Caption = 'gbContact'
TabOrder = 0
Edges = [beLeft, beRight, beTop, beBottom]
DesignSize = (
550
422)
object panPersonButtons: TPanel
Left = 2
Top = 18
Width = 546
Height = 44
Align = alTop
BevelOuter = bvNone
ParentBackground = False
TabOrder = 0
object btnDelPerson: TssSpeedButton
Left = 238
Top = 10
Width = 113
Height = 31
Action = aCDel
Alignment = taCenter
AllwaysShowFrame = False
ButtonType = ssbtStandard
Checked = False
DisabledImages = dmData.Images18x18dis
GroupIndex = 0
ImageIndex = 2
Images = dmData.Images18x18
LeftMargin = 3
Style = ssbsUser
ViewStyle = ssvsCaptionGlyph
end
object btnPropsPerson: TssSpeedButton
Left = 124
Top = 10
Width = 114
Height = 31
Action = aCUpd
Alignment = taCenter
AllwaysShowFrame = False
ButtonType = ssbtStandard
Checked = False
DisabledImages = dmData.Images18x18dis
GroupIndex = 0
ImageIndex = 1
Images = dmData.Images18x18
LeftMargin = 3
Style = ssbsUser
ViewStyle = ssvsCaptionGlyph
end
object btnAddPerson: TssSpeedButton
Left = 7
Top = 10
Width = 117
Height = 31
Action = aCIns
Alignment = taCenter
AllwaysShowFrame = False
ButtonType = ssbtStandard
Checked = False
DisabledImages = dmData.Images18x18dis
GroupIndex = 0
ImageIndex = 0
Images = dmData.Images18x18
LeftMargin = 3
Style = ssbsUser
ViewStyle = ssvsCaptionGlyph
end
end
object grdPersons: TdxDBGrid
Left = 10
Top = 64
Width = 529
Height = 347
DrawDragFrame = False
Bands = <
item
end>
DefaultLayout = True
HeaderPanelRowCount = 1
KeyField = 'personid'
SummaryGroups = <>
SummarySeparator = ', '
PopupMenu = pmPersons
TabOrder = 1
OnDblClick = grdPersonsDblClick
OnKeyDown = grdPersonsKeyDown
DataSource = srcContact
Filter.Criteria = {00000000}
LookAndFeel = lfUltraFlat
OptionsCustomize = [edgoBandMoving, edgoBandSizing, edgoColumnSizing]
OptionsDB = [edgoCancelOnExit, edgoCanNavigation, edgoConfirmDelete, edgoLoadAllRecords, edgoUseBookmarks]
OptionsView = [edgoAutoWidth, edgoBandHeaderWidth, edgoRowAutoHeight, edgoRowSelect, edgoUseBitmap]
Anchors = [akLeft, akTop, akRight, akBottom]
object colFIO: TdxDBGridColumn
Alignment = taLeftJustify
HeaderAlignment = taCenter
Width = 229
BandIndex = 0
RowIndex = 0
FieldName = 'name'
end
object colJob: TdxDBGridColumn
HeaderAlignment = taCenter
Sorted = csUp
Width = 135
BandIndex = 0
RowIndex = 0
FieldName = 'job'
end
end
end
end
object tsPerson: TcxTabSheet
Caption = 'tsPerson'
ImageIndex = 1
TabVisible = False
object gbPerson: TssGroupBox
Left = 0
Top = 0
Width = 550
Height = 422
Align = alClient
Alignment = alTopLeft
Caption = ' '
TabOrder = 0
Edges = [beLeft, beRight, beTop, beBottom]
OnMouseEnter = gbPersonMouseEnter
OnMouseLeave = gbPersonMouseLeave
DesignSize = (
550
422)
object lFIO: TLabel
Left = 18
Top = 89
Width = 27
Height = 16
Caption = #1060#1048#1054
end
object lJob: TLabel
Left = 18
Top = 118
Width = 66
Height = 16
Caption = #1044#1086#1083#1078#1085#1086#1089#1090#1100
end
object lPhone: TLabel
Left = 18
Top = 165
Width = 53
Height = 16
Caption = #1058#1077#1083#1077#1092#1086#1085
end
object lEMail: TLabel
Left = 18
Top = 196
Width = 35
Height = 16
Caption = 'E-Mail'
end
object lNotes: TLabel
Left = 18
Top = 244
Width = 72
Height = 16
Caption = #1055#1088#1080#1084#1077#1095#1072#1085#1080#1077
end
object btnEMail: TssSpeedButton
Left = 509
Top = 193
Width = 20
Height = 20
Alignment = taLeftJustify
AllwaysShowFrame = False
Anchors = [akTop, akRight]
ButtonType = ssbtStandard
Checked = False
Caption = 'aShowTurnIn'
GroupIndex = 0
ImageIndex = 46
Images = dmData.Images
LeftMargin = 3
Style = ssbsUser
ViewStyle = ssvsGlyphOnly
end
object edFIO: TcxDBTextEdit
Left = 135
Top = 85
Width = 403
Height = 24
Anchors = [akLeft, akTop, akRight]
DataBinding.DataField = 'name'
DataBinding.DataSource = srcContact
ImeName = 'Russian'
Properties.MaxLength = 128
Properties.OnChange = edFIOPropertiesChange
Style.StyleController = dmData.scMain
TabOrder = 0
OnKeyDown = GoNextKeyDown
OnKeyPress = GoNext
end
object edJob: TcxDBTextEdit
Left = 135
Top = 114
Width = 403
Height = 24
Anchors = [akLeft, akTop, akRight]
DataBinding.DataField = 'job'
DataBinding.DataSource = srcContact
ImeName = 'Russian'
Properties.MaxLength = 128
Properties.OnChange = DataModified
Style.StyleController = dmData.scMain
TabOrder = 1
OnKeyDown = GoNextKeyDown
OnKeyPress = GoNext
end
object edPhone: TcxDBTextEdit
Left = 135
Top = 161
Width = 403
Height = 24
Anchors = [akLeft, akTop, akRight]
DataBinding.DataField = 'phone'
DataBinding.DataSource = srcContact
ImeName = 'Russian'
Properties.MaxLength = 64
Properties.OnChange = DataModified
Style.StyleController = dmData.scMain
TabOrder = 2
OnKeyDown = GoNextKeyDown
OnKeyPress = GoNext
end
object edEMail: TcxDBTextEdit
Left = 135
Top = 191
Width = 372
Height = 24
Anchors = [akLeft, akTop, akRight]
DataBinding.DataField = 'email'
DataBinding.DataSource = srcContact
ImeName = 'Russian'
Properties.MaxLength = 64
Properties.OnChange = DataModified
Style.StyleController = dmData.scMain
TabOrder = 3
OnKeyDown = GoNextKeyDown
OnKeyPress = GoNext
end
object memNotes: TcxDBMemo
Left = 135
Top = 239
Width = 403
Height = 101
Anchors = [akLeft, akTop, akRight]
DataBinding.DataField = 'notes'
DataBinding.DataSource = srcContact
ImeName = 'Russian'
Properties.OnChange = DataModified
Style.StyleController = dmData.scMain
TabOrder = 4
OnKeyDown = GoNextKeyDown
OnKeyPress = GoNext
end
object Panel3: TPanel
Left = 2
Top = 18
Width = 546
Height = 49
Align = alTop
BevelOuter = bvNone
ParentBackground = False
TabOrder = 5
DesignSize = (
546
49)
object ssSpeedButton4: TssSpeedButton
Left = 238
Top = 10
Width = 113
Height = 31
Action = aCDel
Alignment = taCenter
AllwaysShowFrame = False
ButtonType = ssbtStandard
Checked = False
DisabledImages = dmData.Images18x18dis
GroupIndex = 0
ImageIndex = 2
Images = dmData.Images18x18
LeftMargin = 3
Style = ssbsUser
ViewStyle = ssvsCaptionGlyph
end
object ssSpeedButton5: TssSpeedButton
Left = 124
Top = 10
Width = 114
Height = 31
Action = aCUpd
Alignment = taCenter
AllwaysShowFrame = False
ButtonType = ssbtStandard
Checked = False
DisabledImages = dmData.Images18x18dis
GroupIndex = 0
ImageIndex = 1
Images = dmData.Images18x18
LeftMargin = 3
Style = ssbsUser
ViewStyle = ssvsCaptionGlyph
end
object ssSpeedButton6: TssSpeedButton
Left = 7
Top = 10
Width = 117
Height = 31
Action = aCIns
Alignment = taCenter
AllwaysShowFrame = False
ButtonType = ssbtStandard
Checked = False
DisabledImages = dmData.Images18x18dis
GroupIndex = 0
ImageIndex = 0
Images = dmData.Images18x18
LeftMargin = 3
Style = ssbsUser
ViewStyle = ssvsCaptionGlyph
end
object bvlPersonSep: TssBevel
Left = 0
Top = 48
Width = 546
Height = 1
Align = alBottom
ColorGrBegin = clBtnFace
ColorGrEnd = clBtnFace
ColorInner = clBtnShadow
ColorOuter = clBtnHighlight
Edges = [beLeft, beRight, beTop, beBottom]
GradientDirection = gdHorizontal
HotTrack = False
ImageIndex = 0
Shape = bsTopLine
UseGradient = False
end
object btnPersonLevelUp: TssSpeedButton
Left = 376
Top = 12
Width = 20
Height = 20
Alignment = taLeftJustify
AllwaysShowFrame = False
Anchors = [akTop, akRight]
ButtonType = ssbtStandard
Checked = False
Caption = 'aShowTurnIn'
GroupIndex = 0
ImageIndex = 21
Images = dmData.Images
LeftMargin = 1
ParentShowHint = False
ShowHint = True
Style = ssbsUser
ViewStyle = ssvsGlyphOnly
end
object btnLevelUp: TssSpeedButton
Left = 505
Top = 12
Width = 20
Height = 20
Alignment = taLeftJustify
AllwaysShowFrame = False
Anchors = [akTop, akRight]
ButtonType = ssbtStandard
Checked = False
Caption = 'aShowTurnIn'
GroupIndex = 0
ImageIndex = 21
Images = dmData.Images
LeftMargin = 1
ParentShowHint = False
ShowHint = True
Style = ssbsUser
ViewStyle = ssvsGlyphOnly
OnClick = btnLevelUpClick
end
end
end
end
end
end
inherited panTitleBar: TssGradientPanel
Width = 832
TabOrder = 3
inherited panTitleButtons: TssPanel
Left = 774
end
end
inherited panButtons: TPanel
Top = 472
Width = 832
inherited btnOK: TxButton
Left = 520
end
inherited btnCancel: TxButton
Left = 623
end
inherited btnApply: TxButton
Left = 726
end
end
inherited panToolBar: TPanel
Width = 832
TabOrder = 2
inherited btnLock: TssSpeedButton
Left = 780
end
inherited btnSendErrMessage: TssSpeedButton
Left = 800
end
inherited btnHelp: TssSpeedButton
Left = 757
end
end
inherited FormStorage: TssFormStorage
Left = 12
Top = 268
end
inherited ActionList: TActionList
Images = dmData.Images18x18
Top = 268
object aCIns: TAction
Category = 'Contact'
Caption = 'aCIns'
ImageIndex = 0
ShortCut = 45
OnExecute = aCInsExecute
end
object aCUpd: TAction
Tag = 1
Category = 'Contact'
Caption = 'aCUpd'
ImageIndex = 1
ShortCut = 16397
OnExecute = aCInsExecute
end
object aCDel: TAction
Category = 'Contact'
Caption = 'aCDel'
ImageIndex = 2
ShortCut = 16430
OnExecute = aCDelExecute
end
end
object mdContact: TssMemoryData
FieldDefs = <>
Left = 136
Top = 89
object mdContactname: TStringField
FieldName = 'name'
Size = 128
end
object mdContactjob: TStringField
FieldName = 'job'
Size = 64
end
object mdContactphone: TStringField
FieldName = 'phone'
Size = 64
end
object mdContactemail: TStringField
FieldName = 'email'
Size = 64
end
object mdContactnotes: TStringField
FieldName = 'notes'
Size = 255
end
object mdContactpersonid: TIntegerField
FieldName = 'personid'
end
object mdContactfnode: TIntegerField
FieldName = 'fnode'
end
end
object srcContact: TDataSource
DataSet = mdContact
Left = 164
Top = 89
end
object pmPersons: TTBPopupMenu
Images = dmData.Images18x18
Left = 68
Top = 268
object TBItem1: TTBItem
Action = aCIns
Images = dmData.Images18x18
end
object TBItem4: TTBItem
Action = aCDel
end
object TBSeparatorItem1: TTBSeparatorItem
end
object TBItem5: TTBItem
Action = aCUpd
end
end
object pmTree: TTBPopupMenu
Images = dmData.Images18x18
Left = 60
Top = 160
object TBItem2: TTBItem
Action = aCIns
Images = dmData.Images18x18
end
object TBItem3: TTBItem
Action = aCDel
end
end
end
| 29.987984 | 119 | 0.485686 |
fc45e99c003edea8352a1e50f94ac7ade611b7b2 | 242 | dpr | Pascal | Demos/Chronometer/ANDChronometer.dpr | JouriM66/DPF.Android.Native.Components | 162948119d62cd7971ed208fe3744bb52e15df1f | [
"Apache-2.0"
]
| 6 | 2016-06-13T09:53:06.000Z | 2021-09-24T09:40:49.000Z | Demos/Chronometer/ANDChronometer.dpr | JouriM66/DPF.Android.Native.Components | 162948119d62cd7971ed208fe3744bb52e15df1f | [
"Apache-2.0"
]
| 3 | 2016-04-17T16:43:33.000Z | 2018-01-20T17:29:39.000Z | Demos/Chronometer/ANDChronometer.dpr | JouriM66/DPF.Android.Native.Components | 162948119d62cd7971ed208fe3744bb52e15df1f | [
"Apache-2.0"
]
| 1 | 2019-04-28T11:59:24.000Z | 2019-04-28T11:59:24.000Z | program ANDChronometer;
uses
System.StartUpCopy,
FMX.Forms,
uMain in 'uMain.pas' {FChronometer};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TFChronometer, FChronometer);
Application.Run;
end.
| 16.133333 | 55 | 0.702479 |
fc4b083bef0805e2d840fc0c84ad7ac1c1b8fadf | 16,418 | pas | Pascal | Libraries/Spring4D/Marshmallow/Test/TestAdaptersFireDAC.pas | jomael/Concepts | 82d18029e41d55e897d007f826c021cdf63e53f8 | [
"Apache-2.0"
]
| 62 | 2016-01-20T16:26:25.000Z | 2022-02-28T14:25:52.000Z | Libraries/Spring4D/Marshmallow/Test/TestAdaptersFireDAC.pas | jomael/Concepts | 82d18029e41d55e897d007f826c021cdf63e53f8 | [
"Apache-2.0"
]
| null | null | null | Libraries/Spring4D/Marshmallow/Test/TestAdaptersFireDAC.pas | jomael/Concepts | 82d18029e41d55e897d007f826c021cdf63e53f8 | [
"Apache-2.0"
]
| 20 | 2016-09-08T00:15:22.000Z | 2022-01-26T13:13:08.000Z | unit TestAdaptersFireDAC;
interface
uses
Classes,
Data.DB,
FireDAC.Comp.Client,
FireDAC.Stan.Error,
Spring,
Spring.Mocking,
Spring.Persistence.Adapters.FireDAC,
Spring.Persistence.Core.Base,
Spring.Persistence.Core.Exceptions,
Spring.Persistence.Core.Interfaces,
Spring.Persistence.Core.Session,
Spring.Persistence.Core.ResourceStrings,
Spring.Persistence.Mapping.Attributes,
Spring.Persistence.SQL.Generators.Ansi,
Spring.Persistence.SQL.Params,
Spring.TestUtils,
SysUtils,
TestEntities,
TestFireDACConnection,
TestFramework
;
type
TFireDACExceptionHandlerAccess = class(TFireDACExceptionHandler);
TFireDACExceptionHandlerTest = class(TTestCase<TFireDACExceptionHandlerAccess>)
private
function CreateException(kind: TFDCommandExceptionKind): EFDDBEngineException;
published
procedure TestGetAdapterException_EFDDBEngineException_ekUKViolated_Returns_EORMConstraintException;
procedure TestGetAdapterException_EFDDBEngineException_ekFKViolated_Returns_EORMConstraintException;
procedure TestGetAdapterException_EFDDBEngineException_Others;
procedure TestGetAdapterException_EDatabaseError;
procedure TestGetAdapterException_Others_Return_Nil;
end;
TBaseFireDACConnectionAdapterTest = class(TTestCase)
strict protected
fConnection: IDBConnection;
fMockConnection: Mock<TTestFDConnection>;
fSqliteConnection: TFDConnection;
procedure CreateSqliteConnection;
protected
procedure SetUp; override;
procedure TearDown; override;
end;
TFireDACConnectionAdapterTest = class(TBaseFireDACConnectionAdapterTest)
protected
procedure SetUp; override;
published
procedure TestIsConnected;
procedure TestConnect;
procedure TestConnectException;
procedure TestDisconnect;
procedure TestCreateStatement;
procedure TestBeginTransaction;
end;
TFireDACTransactionAdapterTest = class(TBaseFireDACConnectionAdapterTest)
private
fTransaction: IDBTransaction;
protected
procedure SetUp; override;
procedure TearDown; override;
published
procedure TestCommit;
procedure TestCommit_Exception;
procedure TestRollback;
procedure TestRollback_Exception;
end;
TFireDACStatementAdapterTest = class(TBaseFireDACConnectionAdapterTest)
private
fStatement: IDBStatement;
protected
procedure SetUp; override;
procedure TearDown; override;
published
procedure TestExecute_Exception;
procedure TestExecuteQuery_Exception;
end;
[Table('CUSTOMERS')]
TFDCustomer = class
private
FId: Integer;
FAge: Integer;
FName: string;
FHeight: Nullable<Double>;
public
[Column('ID', [cpPrimaryKey])] [AutoGenerated] property Id: Integer read FId write FId;
[Column] property Age: Integer read FAge write FAge;
[Column] property Name: string read FName write FName;
[Column] property Height: Nullable<Double> read FHeight write FHeight;
end;
TFireDACSessionTest = class(TTestCase)
private
FConnection: IDBConnection;
FSession: TSession;
FDACConnection: TFDConnection;
protected
procedure CreateTables;
function CreateCustomer(const name: string; const age: Integer): TFDCustomer;
public
procedure SetUp; override;
procedure TearDown; override;
published
procedure Save;
procedure SaveNullable;
procedure WhenSavingInTransaction_RollbackIsSuccessful;
procedure WhenSavingInTransaction_CommitIsSuccessful;
procedure NestedTransaction;
end;
implementation
uses
Spring.Persistence.Core.ConnectionFactory,
FireDAC.Phys.SQLite,
Spring.Persistence.SQL.Interfaces,
Spring.Collections,
TestSession,
Variants;
{$REGION 'TFireDACExceptionHandlerTest'}
function TFireDACExceptionHandlerTest.CreateException(
kind: TFDCommandExceptionKind): EFDDBEngineException;
begin
Result := EFDDBEngineException.Create;
Result.AppendError(0, Ord(kind), '', '', kind, 0, 0);
end;
procedure TFireDACExceptionHandlerTest.TestGetAdapterException_EDatabaseError;
var
exc, result: Shared<Exception>;
begin
exc := EDatabaseError.Create('');
result := SUT.GetAdapterException(exc, 'message');
CheckIs(result, EFireDACAdapterException);
CheckEqualsString('message', result.Value.Message);
CheckFalse(EFireDACAdapterException(result.Value).ErrorCode.HasValue);
end;
procedure TFireDACExceptionHandlerTest.TestGetAdapterException_EFDDBEngineException_ekFKViolated_Returns_EORMConstraintException;
var
exc, result: Shared<Exception>;
begin
exc := CreateException(ekFKViolated);
result := SUT.GetAdapterException(exc, 'message');
CheckIs(result, EORMConstraintException);
CheckEqualsString('message', result.Value.Message);
CheckEquals(Ord(ekFKViolated), EORMConstraintException(result.Value).ErrorCode);
end;
procedure TFireDACExceptionHandlerTest.TestGetAdapterException_EFDDBEngineException_ekUKViolated_Returns_EORMConstraintException;
var
exc, result: Shared<Exception>;
begin
exc := CreateException(ekUKViolated);
result := SUT.GetAdapterException(exc, 'message');
CheckIs(result, EORMConstraintException);
CheckEqualsString('message', result.Value.Message);
CheckEquals(Ord(ekUKViolated), EORMConstraintException(result.Value).ErrorCode);
end;
procedure TFireDACExceptionHandlerTest.TestGetAdapterException_EFDDBEngineException_Others;
var
exc, result: Shared<Exception>;
begin
exc := CreateException(ekInvalidParams);
result := SUT.GetAdapterException(exc, 'message');
CheckIs(result, EFireDACAdapterException);
CheckEqualsString('message', result.Value.Message);
CheckEquals(Ord(ekInvalidParams), EFireDACAdapterException(result.Value).ErrorCode);
end;
procedure TFireDACExceptionHandlerTest.TestGetAdapterException_Others_Return_Nil;
var
exc, result: Shared<Exception>;
begin
exc := Exception.Create('');
result := SUT.GetAdapterException(exc, '');
CheckNull(result);
end;
{$ENDREGION}
{$REGION 'TBaseFireDACConnectionAdapterTest'}
procedure TBaseFireDACConnectionAdapterTest.CreateSqliteConnection;
begin
fSqliteConnection := TFDConnection.Create(nil);
fSqliteConnection.DriverName := 'SQLite';
fConnection := TFireDACConnectionAdapter.Create(fSqliteConnection);
fConnection.AutoFreeConnection := True;
end;
procedure TBaseFireDACConnectionAdapterTest.SetUp;
begin
inherited;
fMockConnection := Mock<TTestFDConnection>.Create(TMockBehavior.Strict);
fConnection := TFireDACConnectionAdapter.Create(fMockConnection);
fConnection.AutoFreeConnection := False;
end;
procedure TBaseFireDACConnectionAdapterTest.TearDown;
begin
fConnection := nil;
fMockConnection.Setup.Executes.When(Args.Any).SetConnected(False);
fMockConnection.Free;
fSqliteConnection := nil;
inherited;
end;
{$ENDREGION}
{$REGION 'TFireDACConnectionAdapterTest'}
procedure TFireDACConnectionAdapterTest.SetUp;
begin
inherited;
end;
procedure TFireDACConnectionAdapterTest.TestBeginTransaction;
var
transaction: IDBTransaction;
begin
// Test connect exception
fMockConnection.Setup.Raises<EFDException>.When.SetConnected(True);
CheckException(EFireDACAdapterException,
procedure begin fConnection.BeginTransaction end);
CreateSqliteConnection;
transaction := fConnection.BeginTransaction;
CheckNotNull(transaction);
// Test InTransaction no nesting exception
fSqliteConnection.TxOptions.EnableNested := False;
CheckException(EFireDACAdapterException,
procedure begin fConnection.BeginTransaction end);
end;
procedure TFireDACConnectionAdapterTest.TestConnect;
begin
fMockConnection.Setup.Executes.When.SetConnected(True);
fConnection.Connect;
fMockConnection.Received(1).SetConnected(True);
Pass;
end;
procedure TFireDACConnectionAdapterTest.TestConnectException;
var
adapter: TFireDACConnectionAdapter;
begin
// Use native connection for this test
adapter := TFireDACConnectionAdapter.Create(TFDConnection.Create(nil));
try
adapter.AutoFreeConnection := True;
ExpectedException := EFireDACAdapterException;
adapter.Connect;
finally
adapter.Free;
end;
end;
procedure TFireDACConnectionAdapterTest.TestCreateStatement;
var
returnValue: IDBStatement;
begin
CreateSqliteConnection;
returnValue := fConnection.CreateStatement;
CheckNotNull(returnValue);
end;
procedure TFireDACConnectionAdapterTest.TestDisconnect;
begin
fMockConnection.Setup.Raises<EFDException>.When.SetConnected(False);
CheckException(EFireDACAdapterException,
procedure begin fConnection.Disconnect end);
fMockConnection.Setup.Executes.When.SetConnected(False);
fConnection.Disconnect;
fMockConnection.Received(2).SetConnected(False);
Pass;
end;
procedure TFireDACConnectionAdapterTest.TestIsConnected;
begin
fMockConnection.Setup.Returns<Boolean>(False).When.GetConnected;
CheckFalse(fConnection.IsConnected);
fMockConnection.Setup.Returns<Boolean>(True).When.GetConnected;
CheckTrue(fConnection.IsConnected);
end;
{$ENDREGION}
{$REGION 'TFireDACTransactionAdapterTest'}
procedure TFireDACTransactionAdapterTest.SetUp;
begin
inherited;
CreateSqliteConnection;
fTransaction := fConnection.BeginTransaction;
end;
procedure TFireDACTransactionAdapterTest.TearDown;
begin
fTransaction := nil;
inherited;
end;
procedure TFireDACTransactionAdapterTest.TestCommit;
begin
fTransaction.Commit;
Pass;
end;
procedure TFireDACTransactionAdapterTest.TestCommit_Exception;
begin
fSqliteConnection.Connected := False;
// ExpectedException := EFireDACAdapterException;
fTransaction.Commit;
Pass;
end;
type
TMockedFireDACTransactionAdapter = class(TFireDACTransactionAdapter)
private
fInTransaction: Boolean;
public
function InTransaction: Boolean; override;
end;
function TMockedFireDACTransactionAdapter.InTransaction: Boolean;
begin
// We need to return true to let the Rollback fail since we closed the
// connection.
Result := fInTransaction;
end;
procedure TFireDACTransactionAdapterTest.TestRollback;
begin
fTransaction.Rollback;
Pass;
end;
procedure TFireDACTransactionAdapterTest.TestRollback_Exception;
begin
fSqliteConnection.Connected := False;
// ExpectedException := EFireDACAdapterException;
fTransaction.Rollback;
Pass;
end;
{$ENDREGION}
{$REGION 'TFireDACStatementAdapterTest'}
procedure TFireDACStatementAdapterTest.SetUp;
begin
inherited;
CreateSqliteConnection;
fStatement := fConnection.CreateStatement;
end;
procedure TFireDACStatementAdapterTest.TearDown;
begin
fStatement := nil;
inherited;
end;
procedure TFireDACStatementAdapterTest.TestExecuteQuery_Exception;
var
resultSet: IDBResultSet;
begin
fSqliteConnection.Connected := False;
try
resultSet := fStatement.ExecuteQuery;
Fail('Exception expected');
except
on E: Exception do
begin
CheckIs(E, EFireDACAdapterException);
CheckNotNull(E.InnerException);
CheckEqualsString(Format(SCannotOpenQuery,
[E.InnerException.Message]), E.Message);
resultSet := nil;
end;
end;
end;
procedure TFireDACStatementAdapterTest.TestExecute_Exception;
begin
fSqliteConnection.Connected := False;
ExpectedException := EFireDACAdapterException;
fStatement.Execute;
end;
{$ENDREGION}
{$REGION 'TFireDACSessionTest'}
function TFireDACSessionTest.CreateCustomer(const name: string;
const age: Integer): TFDCustomer;
begin
Result := TFDCustomer.Create;
Result.Name := name;
Result.Age := age;
end;
procedure TFireDACSessionTest.CreateTables;
begin
FDACConnection.ExecSQL('CREATE TABLE IF NOT EXISTS CUSTOMERS ([ID] INTEGER PRIMARY KEY, [AGE] INTEGER NULL,'+
'[NAME] NVARCHAR (255), [HEIGHT] FLOAT, [PICTURE] BLOB); ');
end;
procedure TFireDACSessionTest.NestedTransaction;
const
__SELECT_COUNT_QUERY = 'select * from CUSTOMERS';
var
LSession: TSession;
LDACConnection: TFDConnection;
LConnection: IDBConnection;
LEntity: TFDCustomer;
LRecordCount: Integer;
LDBTransaction: IDBTransaction;
LDBTransactionNested: IDBTransaction;
begin
LDACConnection := TFDConnection.Create(nil);
LDACConnection.DriverName := 'SQLite';
LDACConnection.Params.Add('Database=file::memory:?cache=shared');
LConnection := TConnectionFactory.GetInstance(dtFireDAC, LDACConnection);
LConnection.AutoFreeConnection := True;
LConnection.QueryLanguage := qlSQLite;
LSession := TSession.Create(LConnection);
try
LRecordCount := LSession.ExecuteScalar<Integer>(__SELECT_COUNT_QUERY, []);
CheckEquals(0, LRecordCount);
LDBTransaction := FSession.BeginTransaction;
try
LDBTransaction.TransactionName := 'TestTransactionName';
LDBTransactionNested := FSession.BeginTransaction;
try
LDBTransactionNested.TransactionName := 'TestNestedTransactionName';
LEntity := TFDCustomer.Create;
try
LEntity.Name := 'TestTransactionComit';
FSession.Insert(LEntity);
// LRecordCount := LSession.ExecuteScalar<Integer>(__SELECT_COUNT_QUERY, []);
CheckEquals(0, LRecordCount);
LDBTransactionNested.Commit;
// LRecordCount := LSession.ExecuteScalar<Integer>(__SELECT_COUNT_QUERY, []);
CheckEquals(0, LRecordCount);
finally
LEntity.Free;
end;
finally
LDBTransactionNested := nil;
end;
LDBTransaction.Commit;
LRecordCount := LSession.ExecuteScalar<Integer>(__SELECT_COUNT_QUERY, []);
CheckEquals(1, LRecordCount);
finally
LDBTransaction := nil;
end;
finally
LSession.Free;
end;
end;
procedure TFireDACSessionTest.Save;
var
customer: TFDCustomer;
begin
customer := CreateCustomer('Foo', 25);
FSession.Save(customer);
CheckEquals('Foo', FSession.FindAll<TFDCustomer>.First.Name);
CheckFalse(FSession.FindAll<TFDCustomer>.First.Height.HasValue);
customer.Free;
end;
procedure TFireDACSessionTest.SaveNullable;
const
OnePointOne: Double = 1.1;
var
customer: TFDCustomer;
begin
customer := CreateCustomer('Foo', 25);
customer.Height := OnePointOne;
FSession.Save(customer);
CheckEquals(OnePointOne, FSession.FindAll<TFDCustomer>.First.Height);
customer.Free;
end;
procedure TFireDACSessionTest.SetUp;
begin
FDACConnection := TFDConnection.Create(nil);
FDACConnection.DriverName := 'SQLite';
FDACConnection.Params.Add('Database=file::memory:?cache=shared');
// FDACConnection.Params.Add('Database=:memory:');
// inherited SetUp;
FConnection := TConnectionFactory.GetInstance(dtFireDAC, FDACConnection);
FConnection.AutoFreeConnection := True;
FConnection.QueryLanguage := qlSQLite;
FConnection.AddExecutionListener(
procedure(const command: string; const params: IEnumerable<TDBParam>)
var
i: Integer;
param: TDBParam;
begin
Status(command);
i := 0;
for param in params do
begin
Status(Format('%2:d %0:s = %1:s. Type: %3:s',
[param.Name,
PrettyPrintVariant(param.ToVariant),
i,
VarTypeAsText(VarType(param.ToVariant))]));
Inc(i);
end;
Status('-----');
end);
FSession := TSession.Create(FConnection);
CreateTables;
end;
procedure TFireDACSessionTest.TearDown;
begin
inherited TearDown;
FSession.Free;
FDACConnection := nil;
FConnection := nil;
end;
procedure TFireDACSessionTest.WhenSavingInTransaction_CommitIsSuccessful;
var
customer: TFDCustomer;
transaction: IDBTransaction;
begin
customer := CreateCustomer('Foo', 25);
transaction := FSession.BeginTransaction;
FSession.Save(customer);
customer.Free;
CheckEquals('Foo', FSession.FindAll<TFDCustomer>.First.Name);
transaction.Commit;
CheckEquals(1, FSession.FindAll<TFDCustomer>.Count);
CheckEquals('Foo', FSession.FindAll<TFDCustomer>.First.Name);
end;
procedure TFireDACSessionTest.WhenSavingInTransaction_RollbackIsSuccessful;
var
customer: TFDCustomer;
transaction: IDBTransaction;
begin
customer := CreateCustomer('Foo', 25);
transaction := FSession.BeginTransaction;
FSession.Save(customer);
customer.Free;
CheckEquals('Foo', FSession.FindAll<TFDCustomer>.First.Name);
transaction.Rollback;
CheckEquals(0, FSession.FindAll<TFDCustomer>.Count);
end;
{$ENDREGION}
initialization
RegisterTests('Spring.Persistence.Adapters', [
TFireDACExceptionHandlerTest.Suite,
TFireDACConnectionAdapterTest.Suite,
TFireDACTransactionAdapterTest.Suite,
TFireDACStatementAdapterTest.Suite,
TFireDACSessionTest.Suite
]);
end.
| 27.047776 | 129 | 0.774699 |
47b4b298581c4e1eb4ff7dcd4a057140e5aae322 | 58,845 | pas | Pascal | Source/cPythonSourceScanner.pas | hadi-f90/pyscripter | 9db397754e77f238b00426234f64e334c9323349 | [
"MIT"
]
| 1 | 2018-09-07T09:35:23.000Z | 2018-09-07T09:35:23.000Z | Source/cPythonSourceScanner.pas | hadi-f90/pyscripter | 9db397754e77f238b00426234f64e334c9323349 | [
"MIT"
]
| null | null | null | Source/cPythonSourceScanner.pas | hadi-f90/pyscripter | 9db397754e77f238b00426234f64e334c9323349 | [
"MIT"
]
| null | null | null | {-----------------------------------------------------------------------------
Unit Name: cPythonSourceScanner
Author: Kiriakos Vlahos
Date: 14-Jun-2005
Purpose: Class for Scanning and analysing Python code
Does not check correctness
Code draws from Bicycle Repair Man and Boa Constructor
History:
-----------------------------------------------------------------------------}
unit cPythonSourceScanner;
interface
uses
System.SysUtils,
System.Classes,
System.Contnrs,
System.RegularExpressions,
System.Threading;
Type
TParsedModule = class;
TCodePos = record
LineNo : integer;
CharOffset : integer;
end;
TBaseCodeElement = class
// abstract base class
private
fParent : TBaseCodeElement;
protected
fIsProxy : boolean;
fCodePos : TCodePos;
function GetCodeHint : string; virtual; abstract;
public
Name : string;
function GetRoot : TBaseCodeElement;
function GetModule : TParsedModule;
function GetDottedName : string;
function GetModuleSource : string;
property CodePos : TCodePos read fCodePos;
property Parent : TBaseCodeElement read fParent write fParent;
property IsProxy : boolean read fIsProxy; // true if derived from live Python object
property CodeHint : string read GetCodeHint;
end;
TCodeBlock = record
StartLine : integer;
EndLine : integer;
end;
TModuleImport = class(TBaseCodeElement)
private
fRealName : string; // used if name is an alias
fPrefixDotCount : integer; // for relative package imports
fCodeBlock : TCodeBlock;
function GetRealName: string;
protected
function GetCodeHint : string; override;
public
ImportAll : Boolean;
ImportedNames : TObjectList;
property RealName : string read GetRealName;
property PrefixDotCount : integer read fPrefixDotCount;
property CodeBlock : TCodeBlock read fCodeBlock;
constructor Create(AName : string; CB : TCodeBlock);
destructor Destroy; override;
end;
TVariableAttribute = (vaBuiltIn, vaClassAttribute, vaCall, vaArgument,
vaStarArgument, vaStarStarArgument, vaArgumentWithDefault,
vaImported);
TVariableAttributes = set of TVariableAttribute;
TVariable = class(TBaseCodeElement)
// The parent can be TParsedModule, TParsedClass, TParsedFunction or TModuleImport
private
// only used if Parent is TModuleImport and Name is an alias
fRealName : string;
function GetRealName: string;
protected
function GetCodeHint : string; override;
public
ObjType : string;
DefaultValue : string;
Attributes : TVariableAttributes;
property RealName : string read GetRealName;
end;
TCodeElement = class(TBaseCodeElement)
private
fCodeBlock : TCodeBlock;
fDocString : string;
fIndent : integer;
fDocStringExtracted : boolean;
function GetChildCount: integer;
function GetChildren(i : integer): TCodeElement;
procedure ExtractDocString;
protected
fChildren : TObjectList;
function GetDocString: string; virtual;
public
constructor Create;
destructor Destroy; override;
procedure AddChild(CE : TCodeElement);
procedure GetSortedClasses(SortedClasses : TObjectList);
procedure GetSortedFunctions(SortedFunctions : TObjectList);
procedure GetNameSpace(SList : TStringList); virtual;
function GetScopeForLine(LineNo : integer) : TCodeElement;
function GetChildByName(ChildName : string): TCodeElement;
property CodeBlock : TCodeBlock read fCodeBlock;
property Indent : integer read fIndent;
property ChildCount : integer read GetChildCount;
property Children[i : integer] : TCodeElement read GetChildren;
property DocString : string read GetDocString;
end;
TParsedModule = class(TCodeElement)
private
fImportedModules : TObjectList;
fSource : string;
fFileName : string;
fMaskedSource : string;
fAllExportsVar : string;
fFileAge : TDateTime;
function GetIsPackage: boolean;
procedure SetFileName(const Value: string);
protected
fGlobals : TObjectList;
function GetAllExportsVar: string; virtual;
function GetCodeHint : string; override;
procedure GetNameSpaceInternal(SList, ImportedModuleCache : TStringList);
public
constructor Create; overload;
constructor Create(const Source : string); overload;
constructor Create(const FName : string; const Source : string); overload;
destructor Destroy; override;
procedure Clear;
procedure GetNameSpace(SList : TStringList); override;
procedure GetSortedImports(ImportsList : TObjectList);
procedure GetUniqueSortedGlobals(GlobalsList : TObjectList);
property ImportedModules : TObjectList read fImportedModules;
property Globals : TObjectList read fGlobals;
property Source : string read fSource write fSource;
property FileName : string read fFileName write SetFileName;
property MaskedSource : string read fMaskedSource;
property IsPackage : boolean read GetIsPackage;
property AllExportsVar : string read GetAllExportsVar;
property FileAge : TDateTime read fFileAge write fFileAge;
end;
TParsedFunction = class(TCodeElement)
private
fArguments : TObjectList;
fLocals : TObjectList;
protected
function GetCodeHint : string; override;
public
ReturnType : string;
ReturnAttributes : TVariableAttributes;
constructor Create;
destructor Destroy; override;
function ArgumentsString : string; virtual;
function HasArgument(Name : string): Boolean;
procedure GetNameSpace(SList : TStringList); override;
property Arguments : TObjectList read fArguments;
property Locals : TObjectList read fLocals;
end;
TParsedClass = class(TCodeElement)
private
fSuperClasses : TStringList;
fAttributes : TObjectList;
procedure GetNameSpaceImpl(SList: TStringList; BaseClassResolver : TStringList);
function GetConstructorImpl(BaseClassResolver : TStringList) : TParsedFunction;
protected
function GetCodeHint : string; override;
public
constructor Create;
destructor Destroy; override;
procedure GetNameSpace(SList : TStringList); override;
procedure GetUniqueSortedAttibutes(AttributesList: TObjectList);
function GetConstructor : TParsedFunction; virtual;
property SuperClasses : TStringList read fSuperClasses;
property Attributes : TObjectList read fAttributes;
end;
TScannerProgressEvent = procedure(CharNo, NoOfChars : integer; var Stop : Boolean) of object;
TPythonScanner = class
private
fOnScannerProgress : TScannerProgressEvent;
fCodeRE : TRegEx;
fBlankLineRE : TRegEx;
//fEscapedQuotesRE : TRegEx;
//fStringsAndCommentsRE : TRegEx;
fLineContinueRE : TRegEx;
fImportRE : TRegEx;
fFromImportRE : TRegEx;
fAssignmentRE : TRegEx;
fForRE : TRegEx;
fReturnRE : TRegEx;
fWithRE : TRegEx;
fGlobalRE : TRegEx;
fAliasRE : TRegEx;
fListRE : TRegEx;
fCommentLineRE : TRegEx;
protected
procedure DoScannerProgress(CharNo, NoOfChars : integer; var Stop : Boolean);
public
property OnScannerProgress : TScannerProgressEvent
read fOnScannerProgress write fOnScannerProgress;
constructor Create;
function ScanModule(Module : TParsedModule) : boolean;
end;
IAsyncSourceScanner = interface
['{B9406B98-FEF9-4D18-AFC6-A6E4DCE37979}']
function GetParsedModule : TParsedModule;
function Finished : Boolean;
procedure StopScanning;
property ParsedModule : TParsedModule read GetParsedModule;
end;
TAsynchSourceScanner = class(TInterfacedObject, IAsyncSourceScanner)
private
fStopped : Boolean;
fParsedModule : TParsedModule;
fPythonScanner : TPythonScanner;
fFuture : IFuture<TParsedModule>;
function FutureTask(Sender : TObject) : TParsedModule;
procedure ScanProgress(CharNo, NoOfChars : integer; var Stop : Boolean);
// IAsyncSourceScanner implementation
function Finished : Boolean;
function GetParsedModule : TParsedModule;
procedure StopScanning;
public
constructor Create(const FileName : string; const Source : string);
destructor Destroy; override;
end;
TAsynchSourceScannerFactory = class
private
fIList : TInterfaceList;
procedure ClearFinished;
public
constructor Create;
destructor Destroy; override;
procedure ReleaseScanner(Scanner : IAsyncSourceScanner);
function CreateAsynchSourceScanner(const FileName : string; const Source : string): IAsyncSourceScanner;
end;
Var
AsynchSourceScannerFactory : TAsynchSourceScannerFactory;
function CodeBlock(StartLine, EndLine : integer) : TCodeBlock;
function GetExpressionBuiltInType(Expr : string; Var IsBuiltIn : boolean) : string;
function GetExpressionType(Expr: string; var VarAtts: TVariableAttributes): string;
implementation
uses
WinApi.Windows,
System.Math,
VarPyth,
JclStrings,
JvGnugettext,
SynCompletionProposal,
StringResources,
uEditAppIntfs,
uCommonFunctions,
cRefactoring,
cPySupportTypes,
cPyBaseDebugger,
cSSHSupport;
Const
MaskChar = WideChar(#96);
Var
DocStringRE : TRegEx;
function HaveImplicitContinuation(S : string; var BracesCount : integer) : Boolean;
var
I: Integer;
begin
for I := 1 to Length(S) do
if (Ord(S[i]) < 128) then begin
if AnsiChar(S[i]) in ['(', '[', '{'] then
Inc(BracesCount)
else if AnsiChar(S[i]) in [')', ']', '}'] then
Dec(BracesCount);
end;
Result := BracesCount > 0;
end;
{ Code Ellement }
constructor TCodeElement.Create;
begin
inherited;
fParent := nil;
fChildren := nil;
end;
destructor TCodeElement.Destroy;
begin
FreeAndNil(fChildren);
inherited;
end;
procedure TCodeElement.AddChild(CE : TCodeElement);
begin
if fChildren = nil then
fChildren := TObjectList.Create(True);
CE.fParent := Self;
fChildren.Add(CE);
end;
function TCodeElement.GetChildCount: integer;
begin
if Assigned(fChildren) then
Result := fChildren.Count
else
Result := 0;
end;
function TCodeElement.GetChildren(i : integer): TCodeElement;
begin
if Assigned(fChildren) then begin
Result := TCodeElement(fChildren[i]);
Assert(Result is TCodeElement);
Assert(Assigned(Result));
end else
Result := nil;
end;
function TCodeElement.GetChildByName(ChildName: string): TCodeElement;
var
i : integer;
CE : TCodeElement;
begin
Result := nil;
if not Assigned(fChildren) then Exit;
for i := 0 to fChildren.Count - 1 do begin
CE := GetChildren(i);
if CE.Name = ChildName then begin
Result := CE;
Exit;
end;
end;
end;
function CompareCodeElements(Item1, Item2: Pointer): Integer;
begin
Result := CompareStr(TCodeElement(Item1).Name, TCodeElement(Item2).Name);
end;
procedure TCodeElement.GetSortedClasses(SortedClasses: TObjectList);
Var
i : integer;
begin
if not Assigned(fChildren) then Exit;
for i := 0 to Self.fChildren.Count - 1 do
if fChildren[i] is TParsedClass then
SortedClasses.Add(fChildren[i]);
SortedClasses.Sort(CompareCodeElements);
end;
procedure TCodeElement.GetSortedFunctions(SortedFunctions: TObjectList);
Var
i : integer;
begin
if not Assigned(fChildren) then Exit;
for i := 0 to Self.fChildren.Count - 1 do
if fChildren[i] is TParsedFunction then
SortedFunctions.Add(fChildren[i]);
SortedFunctions.Sort(CompareCodeElements);
end;
procedure TCodeElement.GetNameSpace(SList: TStringList);
Var
i : integer;
begin
// Add from Children
if Assigned(fChildren) then
for i := 0 to fChildren.Count - 1 do
SList.AddObject(TCodeElement(fChildren[i]).Name, fChildren[i]);
end;
function TCodeElement.GetScopeForLine(LineNo: integer): TCodeElement;
Var
i : integer;
CE : TCodeElement;
begin
if (LineNo >= fCodeBlock.StartLine) and (LineNo <= fCodeBlock.EndLine) then begin
Result := Self;
// try to see whether the line belongs to a child
if not Assigned(fChildren) then Exit;
for i := 0 to fChildren.Count - 1 do begin
CE := Children[i];
if LineNo < CE.CodeBlock.StartLine then
break
else if LineNo > CE.CodeBlock.EndLine then
continue
else begin
// recursive call
Result := CE.GetScopeForLine(LineNo);
break;
end;
end;
end else
Result := nil;
end;
procedure TCodeElement.ExtractDocString;
var
ModuleSource, DocStringSource : string;
CB : TCodeBlock;
begin
if fDocStringExtracted then Exit;
fDocStringExtracted := True;
fDocString := '';
CB := fCodeBlock;
if Assigned(fChildren) and (fChildren.Count > 0) then
CB.EndLine := Pred(Children[0].CodeBlock.StartLine);
if CB.StartLine > CB.EndLine then Exit;
ModuleSource := GetModuleSource;
if ModuleSource = '' then Exit;
DocStringSource := GetLineRange(ModuleSource, CB.StartLine, CB.EndLine);
if DocStringSource = '' then Exit;
if DocStringRE.IsMatch(DocStringSource) then begin
fDocString := DocStringRE.PerlRegEx.Groups[2];
if fDocString = '' then
fDocString := DocStringRE.PerlRegEx.Groups[3];
fDocString := FormatDocString(fDocString);
end;
end;
function TCodeElement.GetDocString: string;
begin
if not fDocStringExtracted then
ExtractDocString;
Result := fDocString;
end;
{ TPythonScanner }
constructor TPythonScanner.Create;
begin
inherited;
fCodeRE := CompiledRegEx(Format('^([ \t]*)(class|def)[ \t]+(%s)[ \t]*(\(([^>]*)\))?[ \t]*(->[ \t]*([^ \t:][^:]*))?:',
[IdentRE]));
fBlankLineRE := CompiledRegEx('^[ \t]*($|\$|\#|\"\"\"|''''''|' + MaskChar +')');
//fEscapedQuotesRE := CompiledRegEx('(\\\\|\\\"|\\\'')');
//fStringsAndCommentsRE :=
// CompiledRegEx('(?sm)(\"\"\".*?\"\"\"|''''''.*?''''''|\"[^\"]*\"|\''[^\'']*\''|#.*?\n)');
fLineContinueRE := CompiledRegEx('\\[ \t]*(#.*)?$');
fImportRE := CompiledRegEx('^[ \t]*import[ \t]+([^#;]+)');
fFromImportRE :=
CompiledRegEx(Format('^[ \t]*from[ \t]+(\.*)(%s)[ \t]+import[ \t]+([^#;]+)', [DottedIdentRE]));
{ TODO : Deal with form . import module as module syntax }
//CompiledRegEx(Format('^[ \t]*from[ \t]+(\.*)(%s)?[ \t]+import[ \t]+([^#;]+)', [DottedIdentRE]));
fAssignmentRE :=
CompiledRegEx(Format('^([ \t]*(self.)?%s[ \t]*(,[ \t]*(self.)?%s[ \t]*)*(=))+(.*)',
[IdentRE, IdentRE]));
fForRE := CompiledRegEx(Format('^\s*for +(%s)( *, *%s)* *(in)', [IdentRe, IdentRe]));
fReturnRE := CompiledRegEx('^[ \t]*return[ \t]+(.*)');
fWithRE :=
CompiledRegEx(Format('^[ \t]*with +(%s) *(\(?).*as +(%s)',
[DottedIdentRE, IdentRE]));
fGlobalRE :=
CompiledRegEx(Format('^[ \t]*global +((%s)( *, *%s)*)',
[IdentRE, IdentRE]));
fAliasRE :=
CompiledRegEx(Format('^[ \t]*(%s)([ \t]+as[ \t]+(%s))?',
[DottedIdentRE, IdentRE]));
fListRE :=
CompiledRegEx('\[(.*)\]');
fCommentLineRE :=
CompiledRegEx('^([ \t]*)#');
end;
procedure TPythonScanner.DoScannerProgress(CharNo, NoOfChars : integer;
var Stop: Boolean);
begin
if Assigned(fOnScannerProgress) then
fOnScannerProgress(CharNo, NoOfChars, Stop);
end;
function TPythonScanner.ScanModule(Module : TParsedModule): boolean;
// Expectes Module Source code in Module.Source
// Parses the Python Source code and adds code elements as children of Module
{ TODO 2 : Optimize out calls to Trim }
Var
UseModifiedSource : boolean;
SourceLines : TFunc<TStringList>;
function GetNthSourceLine(LineNo : integer) : string;
begin
if not Assigned(SourceLines) then begin
SourceLines := TSmartPtr.Make(TStringList.Create);
SourceLines.Text := Module.Source;
end;
if LineNo <= SourceLines.Count then
Result := SourceLines[LineNo-1]
else
Result := '';
end;
procedure GetLine(var P : PWideChar; var Line : string; var LineNo : integer);
Var
Start : PWideChar;
begin
Inc(LineNo);
Start := P;
while not CharInSet(P^, [#0, #10, #13]) do Inc(P);
if UseModifiedSource then
SetString(Line, Start, P - Start)
else
Line := GetNthSourceLine(LineNo);
if P^ = WideChar(#13) then Inc(P);
if P^ = WideChar(#10) then Inc(P);
end;
procedure CharOffsetToCodePos(CharOffset, FirstLine : integer; LineStarts : TList;
var CodePos: TCodePos);
var
i : integer;
begin
CodePos.LineNo := FirstLine;
CodePos.CharOffset := CharOffset;
for i := LineStarts.Count - 1 downto 0 do begin
if Integer(LineStarts[i]) <= CharOffset then begin
CodePos.CharOffset := CharOffset - Integer(LineStarts[i]) + 1;
CodePos.LineNo := FirstLine + i + 1;
break;
end;
end;
end;
procedure RemoveComment(var S : string);
var
Index : Integer;
begin
// Remove comment
Index := CharPos(S, WideChar('#'));
if Index > 0 then
S := Copy(S, 1, Index -1);
end;
function ProcessLineContinuation(var P : PWideChar; var Line : string;
var LineNo: integer; LineStarts : TList): boolean;
// Process continuation lines
var
ExplicitContinuation, ImplicitContinuation : boolean;
NewLine : string;
TrimmedLine : string;
BracesCount : integer;
begin
BracesCount := 0;
LineStarts.Clear;
RemoveComment(Line);
ExplicitContinuation := fLineContinueRE.IsMatch(Line);
ImplicitContinuation := not ExplicitContinuation and
HaveImplicitContinuation(Line, BracesCount);
Result := ExplicitContinuation or ImplicitContinuation;
while (ExplicitContinuation or ImplicitContinuation) and (P^ <> WideChar(#0)) do begin
if ExplicitContinuation then
// Drop the continuation char
Line := Copy(Line, 1, fLineContinueRE.PerlRegEx.GroupOffsets[0] - 1);
LineStarts.Add(Pointer(Length(Line)+2));
GetLine(P, NewLine, LineNo);
RemoveComment(NewLine);
TrimmedLine := Trim(NewLine);
if ExplicitContinuation and (TrimmedLine='') then break;
// issue 212
if StrIsLeft(PWideChar(TrimmedLine), 'class ') or StrIsLeft(PWideChar(TrimmedLine), 'def ') then break;
Line := Line + WideChar(' ') + NewLine;
ExplicitContinuation := fLineContinueRE.IsMatch(Line);
ImplicitContinuation := not ExplicitContinuation and
HaveImplicitContinuation(NewLine, BracesCount);
end;
end;
function GetActiveClass(CodeElement : TBaseCodeElement) : TParsedClass;
begin
while Assigned(CodeElement) and (CodeElement.ClassType <> TParsedClass) do
CodeElement := CodeElement.Parent;
Result := TParsedClass(CodeElement);
end;
procedure ReplaceQuotedChars(var Source : string);
// replace quoted \ ' " with **
Var
pRes, pSource : PWideChar;
begin
if Length(Source) = 0 then Exit;
pRes := PWideChar(Source);
pSource := PWideChar(Source);
while pSource^ <> WideChar(#0) do begin
if (pSource^ = WideChar('\')) then begin
Inc(pSource);
if CharInSet(pSource^, ['\', '''', '"']) then begin
pRes^ := WideChar('*');
Inc(pRes);
pRes^ := WideChar('*');
end else
Inc(pRes);
end;
inc(pSource);
inc(pRes);
end;
end;
procedure MaskStringsAndComments(var Source : string);
// Replace all chars in strings and comments with *
Type
TParseState = (psNormal, psInTripleSingleQuote, psInTripleDoubleQuote,
psInSingleString, psInDoubleString, psInComment);
Var
pRes, pSource : PWideChar;
ParseState : TParseState;
begin
if Length(Source) = 0 then Exit;
pRes := PWideChar(Source);
pSource := PWideChar(Source);
ParseState := psNormal;
while pSource^ <> #0 do begin
case pSource^ of
WideChar('"') :
case ParseState of
psNormal :
if StrIsLeft(psource + 1, '""') then begin
ParseState := psInTripleDoubleQuote;
Inc(pRes,2);
Inc(pSource, 2);
end else
ParseState := psInDoubleString;
psInTripleSingleQuote,
psInSingleString,
psInComment :
pRes^ := MaskChar;
psInTripleDoubleQuote :
if StrIsLeft(psource + 1, '""') then begin
ParseState := psNormal;
Inc(pRes,2);
Inc(pSource, 2);
end else
pRes^ := MaskChar;
psInDoubleString :
ParseState := psNormal;
end;
WideChar(''''):
case ParseState of
psNormal :
if StrIsLeft(psource + 1, '''''') then begin
ParseState := psInTripleSingleQuote;
Inc(pRes, 2);
Inc(pSource, 2);
end else
ParseState := psInSingleString;
psInTripleDoubleQuote,
psInDoubleString,
psInComment :
pRes^ := MaskChar;
psInTripleSingleQuote :
if StrIsLeft(psource + 1, '''''') then begin
ParseState := psNormal;
Inc(pRes, 2);
Inc(pSource, 2);
end else
pRes^ := MaskChar;
psInSingleString :
ParseState := psNormal;
end;
WideChar('#') :
if ParseState = psNormal then
ParseState := psInComment
else
pRes^ := MaskChar;
WideChar(#10), WideChar(#13):
begin
if ParseState in [psInSingleString, psInDoubleString, psInComment] then
ParseState := psNormal;
end;
WideChar(' '),
WideChar(#9) : {do nothing};
else
if ParseState <> psNormal then
pRes^ := MaskChar;
end;
inc(pSource);
inc(pRes);
end;
end;
var
P, CodeStartP : PWideChar;
LineNo, Indent, Index, CharOffset, CharOffset2, LastLength : integer;
CodeStart : integer;
Line, Param, AsgnTargetList, S, SourceLine, LeftS, RightS : string;
Stop : Boolean;
CodeElement, LastCodeElement, Parent : TCodeElement;
ModuleImport : TModuleImport;
Variable : TVariable;
Klass : TParsedClass;
LineStarts: TList;
GlobalList : TStringList;
AsgnTargetCount : integer;
begin
SourceLines := nil;
LineStarts := TSmartPtr.Make(TList.Create)();
GlobalList := TSmartPtr.Make(TStringList.Create)();
GlobalList.CaseSensitive := True;
UseModifiedSource := True;
Module.Clear;
Module.fCodeBlock.StartLine := 1;
Module.fIndent := -1; // so that everything is a child of the module
// Change \" \' and \\ into ** so that text searches
// for " and ' won't hit escaped ones
//Module.fMaskedSource := fEscapedQuotesRE.Replace(Source, '**', False);
Module.fMaskedSource := Copy(Module.fSource, 1, MaxInt);
ReplaceQuotedChars(Module.fMaskedSource);
// Replace all chars in strings and comments with *
// This ensures that text searches don't mistake comments for keywords, and that all
// matches are in the same line/comment as the original
MaskStringsAndComments(Module.fMaskedSource);
P := PWideChar(Module.fMaskedSource);
LineNo := 0;
Stop := False;
LastCodeElement := Module;
while not Stop and (P^ <> #0) do begin
GetLine(P, Line, LineNo);
// skip blank lines and comment lines
if (Length(Line) = 0) or fBlankLineRE.IsMatch(Line) then continue;
// skip comments
if fCommentLineRE.IsMatch(Line) then continue;
CodeStartP := P;
CodeStart := LineNo;
// Process continuation lines
ProcessLineContinuation(P, Line, LineNo, LineStarts);
if fCodeRE.IsMatch(Line) then begin
// found class or function definition
GlobalList.Clear;
S := fCodeRE.PerlRegEx.Groups[5];
if fCodeRE.PerlRegEx.Groups[2] = 'class' then begin
// class definition
CodeElement := TParsedClass.Create;
TParsedClass(CodeElement).fSuperClasses.CommaText := S;
end else begin
// function or method definition
CodeElement := TParsedFunction.Create;
TParsedFunction(CodeElement).ReturnType := fCodeRE.PerlRegEx.Groups[7];
if S <> '' then begin
CharOffset := fCodeRE.PerlRegEx.GroupOffsets[5];
LastLength := Length(S);
Param := GetParameter(S);
CharOffset2 := CalcIndent(Param);
Param := Trim(Param);
Index := 0;
While Param <> '' do begin
Variable := TVariable.Create;
Variable.Parent := CodeElement;
CharOffsetToCodePos(CharOffset + CharOffset2, CodeStart, LineStarts, Variable.fCodePos);
if StrIsLeft(PWideChar(Param), '**') then begin
Variable.Name := Copy(Param, 3, Length(Param) -2);
Include(Variable.Attributes, vaStarStarArgument);
end else if Param[1] = '*' then begin
Variable.Name := Copy(Param, 2, Length(Param) - 1);
Include(Variable.Attributes, vaStarArgument);
end else begin
Index := CharPos(Param, WideChar('='));
if Index > 0 then begin
Variable.Name := Trim(Copy(Param, 1, Index - 1));
Variable.DefaultValue := Copy(Param, Index + 1, Length(Param) - Index);
if Variable.DefaultValue.Length > 0 then begin
// Deal with string arguments (Issue 32)
if CharPos(Variable.DefaultValue, MaskChar) > 0 then begin
SourceLine := GetNthSourceLine(Variable.fCodePos.LineNo);
Variable.DefaultValue :=
Copy(SourceLine, Variable.CodePos.CharOffset + Index, Length(Variable.DefaultValue));
end;
Variable.DefaultValue := Trim(Variable.DefaultValue);
Include(Variable.Attributes, vaArgumentWithDefault);
Variable.ObjType := GetExpressionType(Variable.DefaultValue, Variable.Attributes);
end;
end else begin
Variable.Name := Param;
Include(Variable.Attributes, vaArgument);
end;
end;
// Deal with string annotations (Issue 511)
if CharPos(Variable.Name, MaskChar) > 0 then begin
SourceLine := GetNthSourceLine(Variable.fCodePos.LineNo);
Variable.Name :=
Copy(SourceLine, Variable.CodePos.CharOffset, Length(Variable.Name));
end;
if StrSplit(':', Variable.Name, LeftS, RightS) then begin
Variable.Name := TrimRight(LeftS);
Variable.ObjType := Trim(RightS);
end;
TParsedFunction(CodeElement).fArguments.Add(Variable);
Inc(CharOffset, LastLength - Length(S));
LastLength := Length(S);
Param := GetParameter(S);
CharOffset2 := CalcIndent(Param);
Param := Trim(Param);
end;
end;
end;
CodeElement.Name := fCodeRE.PerlRegEx.Groups[3];
CodeElement.fCodePos.LineNo := CodeStart;
CodeElement.fCodePos.CharOffset := fCodeRe.PerlRegEx.GroupOffsets[3];
CodeElement.fIndent := CalcIndent(fCodeRE.PerlRegEx.Groups[1]);
CodeElement.fCodeBlock.StartLine := CodeStart;
// Decide where to insert CodeElement
if CodeElement.Indent > LastCodeElement.Indent then
LastCodeElement.AddChild(CodeElement)
else begin
LastCodeElement.fCodeBlock.EndLine := Pred(CodeStart);
Parent := LastCodeElement.Parent as TCodeElement;
while Assigned(Parent) do begin
// Note that Module.Indent = -1
if Parent.Indent < CodeElement.Indent then begin
Parent.AddChild(CodeElement);
break;
end else
Parent.fCodeBlock.EndLine := Pred(CodeStart);
Parent := Parent.Parent as TCodeElement;
end;
end;
LastCodeElement := CodeElement;
end else begin
// Close Functions and Classes based on indentation
Indent := CalcIndent(Line);
while Assigned(LastCodeElement) and (LastCodeElement.Indent >= Indent) do begin
// Note that Module.Indent = -1
LastCodeElement.fCodeBlock.EndLine := Pred(LineNo);
LastCodeElement := LastCodeElement.Parent as TCodeElement;
end;
// search for imports
if fImportRE.IsMatch(Line) then begin
// Import statement
S := fImportRE.PerlRegEx.Groups[1];
CharOffset := fImportRE.PerlRegEx.GroupOffsets[1];
LastLength := Length(S);
Param := StrToken(S, ',');
While Param <> '' do begin
if fAliasRE.IsMatch(Param) then begin
if fAliasRE.PerlRegEx.Groups[3] <> '' then begin
Param := fAliasRE.PerlRegEx.Groups[3];
CharOffset2 := fAliasRE.PerlRegEx.GroupOffsets[3] - 1;
end else begin
Param := fAliasRE.PerlRegEx.Groups[1];
CharOffset2 := fAliasRE.PerlRegEx.GroupOffsets[1] - 1;
end;
ModuleImport := TModuleImport.Create(Param, CodeBlock(CodeStart, LineNo));
CharOffsetToCodePos(CharOffset + CharOffset2, CodeStart, LineStarts, ModuleImport.fCodePos);
ModuleImport.Parent := Module;
if fAliasRE.PerlRegEx.Groups[3] <> '' then
ModuleImport.fRealName := fAliasRE.PerlRegEx.Groups[1];
Module.fImportedModules.Add(ModuleImport);
end;
Inc(CharOffset, LastLength - Length(S));
LastLength := Length(S);
Param := StrToken(S, ',');
end;
end else if fFromImportRE.IsMatch(Line) then begin
// From Import statement
ModuleImport := TModuleImport.Create(fFromImportRE.PerlRegEx.Groups[2],
CodeBlock(CodeStart, LineNo));
ModuleImport.fPrefixDotCount := fFromImportRE.PerlRegEx.Groups[1].Length;
ModuleImport.fCodePos.LineNo := CodeStart;
ModuleImport.fCodePos.CharOffset := fFromImportRE.PerlRegEx.GroupOffsets[2];
S := fFromImportRE.PerlRegEx.Groups[3];
if Trim(S) = '*' then
ModuleImport.ImportAll := True
else begin
ModuleImport.ImportedNames := TObjectList.Create(True);
CharOffset := fFromImportRE.PerlRegEx.GroupOffsets[3];
if Pos('(', S) > 0 then begin
Inc(CharOffset);
S := StrRemoveChars(S, ['(',')']); //from module import (a,b,c) form
end;
LastLength := Length(S);
Param := StrToken(S, ',');
While Param <> '' do begin
if fAliasRE.IsMatch(Param) then begin
if fAliasRE.PerlRegEx.Groups[3] <> '' then begin
Param := fAliasRE.PerlRegEx.Groups[3];
CharOffset2 := fAliasRE.PerlRegEx.GroupOffsets[3] - 1;
end else begin
Param := fAliasRE.PerlRegEx.Groups[1];
CharOffset2 := fAliasRE.PerlRegEx.GroupOffsets[1] - 1;
end;
Variable := TVariable.Create;
Variable.Name := Param;
CharOffsetToCodePos(CharOffset + CharOffset2, CodeStart, LineStarts, Variable.fCodePos);
Variable.Parent := ModuleImport;
Include(Variable.Attributes, vaImported);
if fAliasRE.PerlRegEx.Groups[3] <> '' then
Variable.fRealName := fAliasRE.PerlRegEx.Groups[1];
ModuleImport.ImportedNames.Add(Variable);
end;
Inc(CharOffset, LastLength - Length(S));
LastLength := Length(S);
Param := StrToken(S, ',');
end;
end;
ModuleImport.Parent := Module;
Module.fImportedModules.Add(ModuleImport);
end else if fAssignmentRE.IsMatch(Line) then begin
S := Copy(Line, 1, fAssignmentRE.PerlRegEx.GroupOffsets[5]-1);
AsgnTargetList := StrToken(S, '=');
CharOffset2 := 1; // Keeps track of the end of the identifier
while AsgnTargetList <> '' do begin
AsgnTargetCount := 0;
Variable := nil;
while AsgnTargetList <> '' do begin
Param := StrToken(AsgnTargetList, ',');
CharOffset := CharOffset2; // Keeps track of the start of the identifier
Inc(CharOffset, CalcIndent(Param, 1)); // do not expand tabs
Inc(CharOffset2, Succ(Length(Param))); // account for ,
Param := Trim(Param);
if StrIsLeft(PWideChar(Param), 'self.') then begin
// class variable
Param := Copy(Param, 6, Length(Param) - 5);
Inc(CharOffset, 5); // Length of "self."
// search for class attributes
Klass := GetActiveClass(LastCodeElement);
if Assigned(Klass) then begin
Variable := TVariable.Create;
Variable.Name := Param;
Variable.Parent := Klass;
CharOffsetToCodePos(CharOffset, CodeStart, LineStarts, Variable.fCodePos);
Klass.fAttributes.Add(Variable);
Inc(AsgnTargetCount);
end;
end else if (GlobalList.IndexOf(Param) < 0) then begin
// search for local/global variables
Variable := TVariable.Create;
Variable.Name := Param;
Variable.Parent := LastCodeElement;
CharOffsetToCodePos(CharOffset, CodeStart, LineStarts, Variable.fCodePos);
if LastCodeElement.ClassType = TParsedFunction then begin
if TParsedFunction(LastCodeElement).HasArgument(Variable.Name) then
FreeAndNil(Variable)
else
TParsedFunction(LastCodeElement).Locals.Add(Variable);
end else if LastCodeElement.ClassType = TParsedClass then begin
Include(Variable.Attributes, vaClassAttribute);
TParsedClass(LastCodeElement).Attributes.Add(Variable)
end else begin
Module.Globals.Add(Variable);
if Variable.Name = '__all__' then begin
Line := GetNthSourceLine(CodeStart);
UseModifiedSource := False;
ProcessLineContinuation(CodeStartP, Line, CodeStart, LineStarts);
if fListRE.IsMatch(Line) then
Module.fAllExportsVar := fListRE.PerlRegEx.Groups[1];
UseModifiedSource := True;
end;
end;
Inc(AsgnTargetCount);
end;
end;
// Variable Type if the assignment has a single target
if Assigned(Variable) and (AsgnTargetCount = 1) then
Variable.ObjType := GetExpressionType(fAssignmentRE.PerlRegEx.Groups[6],
Variable.Attributes);
AsgnTargetList := StrToken(S, '=');
end;
end else if fForRE.IsMatch(Line) then begin
AsgnTargetList := Copy(Line, fForRE.PerlRegEx.GroupOffsets[1],
fForRE.PerlRegEx.GroupOffsets[3]-fForRE.PerlRegEx.GroupOffsets[1]);
CharOffset2 := fForRE.PerlRegEx.GroupOffsets[1]; // Keeps track of the end of the identifier
while AsgnTargetList <> '' do begin
Param := StrToken(AsgnTargetList, ',');
CharOffset := CharOffset2; // Keeps track of the start of the identifier
Inc(CharOffset, CalcIndent(Param, 1)); // do not expand tabs
Inc(CharOffset2, Succ(Length(Param))); // account for ,
Param := Trim(Param);
if (GlobalList.IndexOf(Param) < 0) then begin
// search for local/global variables
Variable := TVariable.Create;
Variable.Name := Param;
Variable.Parent := LastCodeElement;
CharOffsetToCodePos(CharOffset, CodeStart, LineStarts, Variable.fCodePos);
if LastCodeElement.ClassType = TParsedFunction then
TParsedFunction(LastCodeElement).Locals.Add(Variable)
else if LastCodeElement.ClassType = TParsedClass then begin
// Do not add for variables to class
Variable.Free;
end else begin
Module.Globals.Add(Variable);
end;
end;
end;
end else if fReturnRE.IsMatch(Line) then begin
// only process first return statement
if (LastCodeElement is TParsedFunction) and
(TParsedFunction(LastCodeElement).ReturnType = '')
then
TParsedFunction(LastCodeElement).ReturnType :=
GetExpressionType(fReturnRE.PerlRegEx.Groups[1],
TParsedFunction(LastCodeElement).ReturnAttributes);
end else if fWithRE.IsMatch(Line) then begin
Variable := TVariable.Create;
Variable.Name := fWithRE.PerlRegEx.Groups[3];
Variable.Parent := LastCodeElement;
Variable.fCodePos.LineNo := LineNo;
Variable.fCodePos.CharOffset := fWithRE.PerlRegEx.GroupOffsets[3];
Variable.ObjType := fWithRE.PerlRegEx.Groups[1];
if fWithRE.PerlRegEx.Groups[2] <> '' then
Include(Variable.Attributes, vaCall);
if LastCodeElement.ClassType = TParsedFunction then
TParsedFunction(LastCodeElement).Locals.Add(Variable)
else if LastCodeElement.ClassType = TParsedClass then begin
Include(Variable.Attributes, vaClassAttribute);
TParsedClass(LastCodeElement).Attributes.Add(Variable)
end else
Module.Globals.Add(Variable);
end else if fGlobalRE.IsMatch(Line) then begin
S := fGlobalRE.PerlRegEx.Groups[1];
while S <> '' do
GlobalList.Add(Trim(StrToken(S, ',')));
end;
end;
DoScannerProgress(P - PWideChar(Module.fMaskedSource), Length(Module.fMaskedSource), Stop);
end;
// Account for blank line in the end;
if Length(Module.fMaskedSource) > 0 then begin
Dec(P);
if CharInSet(P^, [#10, #13]) then
Inc(LineNo);
end;
while Assigned(LastCodeElement) do begin
LastCodeElement.fCodeBlock.EndLine := Max(LineNo, LastCodeElement.fCodeBlock.StartLine);
LastCodeElement := LastCodeElement.Parent as TCodeElement;
end;
Result := not Stop;
end;
{ TParsedModule }
constructor TParsedModule.Create;
begin
inherited;
fImportedModules := TObjectList.Create(True);
fGlobals := TObjectList.Create(True);
fCodePos.LineNo := 1;
fCodePos.CharOffset := 1;
end;
procedure TParsedModule.Clear;
begin
//fSource := '';
fMaskedSource := '';
if Assigned(fChildren) then
fChildren.Clear;
fImportedModules.Clear;
fGlobals.Clear;
inherited;
end;
constructor TParsedModule.Create(const Source: string);
begin
Create;
fSource := Source;
end;
constructor TParsedModule.Create(const FName, Source: string);
begin
Create(Source);
FileName := FName;
end;
destructor TParsedModule.Destroy;
begin
fImportedModules.Free;
fGlobals.Free;
inherited;
end;
function CompareVariables(Item1, Item2: Pointer): Integer;
begin
Result := CompareStr(TVariable(Item1).Name, TVariable(Item2).Name);
end;
procedure TParsedModule.GetUniqueSortedGlobals(GlobalsList: TObjectList);
Var
i, j : integer;
HasName : boolean;
begin
for i := 0 to fGlobals.Count - 1 do begin
HasName := False;
for j := 0 to GlobalsList.Count - 1 do
if (TVariable(fGlobals[i]).Name = TVariable(GlobalsList[j]).Name) then begin
HasName := True;
break;
end;
if not HasName then
GlobalsList.Add(fGlobals[i]);
end;
GlobalsList.Sort(CompareVariables);
end;
procedure TParsedModule.SetFileName(const Value: string);
begin
fFileName := Value;
Name := FileNameToModuleName(Value);
end;
function CompareImports(Item1, Item2: Pointer): Integer;
begin
Result := CompareStr(TModuleImport(Item1).Name, TModuleImport(Item2).Name);
end;
procedure TParsedModule.GetSortedImports(ImportsList: TObjectList);
Var
i : integer;
begin
for i := 0 to ImportedModules.Count - 1 do
ImportsList.Add(ImportedModules[i]);
ImportsList.Sort(CompareImports);
end;
procedure TParsedModule.GetNameSpace(SList: TStringList);
{
GetNameSpaceInternal takes care of cyclic imports
}
var
ImportedModuleCache : TStringList;
begin
ImportedModuleCache := TStringList.Create;
try
GetNameSpaceInternal(SList, ImportedModuleCache);
finally
ImportedModuleCache.Free;
end;
end;
procedure TParsedModule.GetNameSpaceInternal(SList, ImportedModuleCache : TStringList);
var
CurrentCount: Integer;
j: Integer;
Index: Integer;
Server, Path: string;
PackageRootName: string;
i: Integer;
PythonPathAdder: IInterface;
ModuleImport: TModuleImport;
ParsedModule: TParsedModule;
begin
if ImportedModuleCache.IndexOf(FileName) >= 0 then
Exit; // Called from a circular input
ImportedModuleCache.Add(FileName);
inherited GetNameSpace(SList);
// Add from Globals
for i := 0 to fGlobals.Count - 1 do
SList.AddObject(TVariable(fGlobals[i]).Name, fGlobals[i]);
// Add the path of the executed file to the Python path
if not TSSHFileName.Parse(Self.FileName, Server, Path) then
Path := ExtractFileDir(Self.fFileName)
else
Path := '';
if Length(Path) > 1 then
PythonPathAdder := GI_PyControl.AddPathToInternalPythonPath(Path);
// Add from imported modules
for i := 0 to fImportedModules.Count - 1 do
begin
ModuleImport := TModuleImport(fImportedModules[i]);
// imported names
if ModuleImport.ImportAll then
begin
// from "module import *" imports
ParsedModule := PyScripterRefactor.GetParsedModule(ModuleImport.Name, None);
// Deal with modules imported themselves (yes it can happen!)
if not Assigned(ParsedModule) or (ParsedModule = Self) then
break;
CurrentCount := SList.Count;
if ParsedModule is TModuleProxy then
TModuleProxy(ParsedModule).Expand;
ParsedModule.GetNameSpaceInternal(SList, ImportedModuleCache);
// Now filter out added names for private and accounting for __all__
if not (ParsedModule is TModuleProxy) then
for j := Slist.Count - 1 downto CurrentCount do
begin
if (StrIsLeft(PWideChar(SList[j]), '__') and not StrIsRight(PWidechar(SList[j]), '__')) or ((ParsedModule.AllExportsVar <> '') and (Pos(SList[j], ParsedModule.AllExportsVar) = 0)) then
SList.Delete(j);
end;
end else if Assigned(ModuleImport.ImportedNames) then begin
for j := 0 to ModuleImport.ImportedNames.Count - 1 do
SList.AddObject(TVariable(ModuleImport.ImportedNames[j]).Name, ModuleImport.ImportedNames[j]);
end else begin
// imported modules
Index := CharPos(ModuleImport.Name, '.');
if Index = 0 then
SList.AddObject(ModuleImport.Name, ModuleImport)
else if Index > 0 then
begin
// we have a package import add implicit import name
PackageRootName := Copy(ModuleImport.Name, 1, Index - 1);
if SList.IndexOf(PackageRootName) < 0 then
begin
ParsedModule := PyScripterRefactor.GetParsedModule(PackageRootName, None);
if Assigned(ParsedModule) then
SList.AddObject(PackageRootName, ParsedModule);
end;
end;
end;
end;
end;
function TParsedModule.GetIsPackage: boolean;
begin
Result := FileIsPythonPackage(fFileName);
end;
function TParsedModule.GetAllExportsVar: string;
begin
Result := fAllExportsVar;
end;
function TParsedModule.GetCodeHint: string;
begin
if IsPackage then
Result := Format(_(SParsedPackageCodeHint), [FileName, Name])
else
Result := Format(_(SParsedModuleCodeHint), [FileName, Name]);
end;
{ TModuleImport }
constructor TModuleImport.Create(AName : string; CB : TCodeBlock);
begin
inherited Create;
Name := AName;
fCodeBlock := CB;
ImportAll := False;
ImportedNames := nil;
end;
destructor TModuleImport.Destroy;
begin
FreeAndNil(ImportedNames);
inherited;
end;
function TModuleImport.GetCodeHint: string;
begin
Result := Format(_(SModuleImportCodeHint), [RealName]);
end;
function TModuleImport.GetRealName: string;
begin
if fRealName <> '' then
Result := fRealName
else
Result := Name;
end;
{ TParsedFunction }
function TParsedFunction.ArgumentsString: string;
function FormatArgument(Variable : TVariable) : string;
begin
if vaStarArgument in Variable.Attributes then
Result := '*' + Variable.Name
else if vaStarStarArgument in Variable.Attributes then
Result := '**' + Variable.Name
else
Result := Variable.Name;
if Variable.ObjType <> '' then
Result := Result + ': ' +Variable.ObjType;
if vaArgumentWithDefault in Variable.Attributes then
Result := Result + '=' + Variable.DefaultValue;
end;
Var
i : integer;
begin
Result:= '';
if fArguments.Count > 0 then begin
Result := FormatArgument(TVariable(fArguments[0]));
for i := 1 to fArguments.Count - 1 do
Result := Result + ', ' + FormatArgument(TVariable(Arguments[i]));
end;
end;
constructor TParsedFunction.Create;
begin
inherited;
fLocals := TObjectList.Create(True);
fArguments := TObjectList.Create(True);
end;
destructor TParsedFunction.Destroy;
begin
FreeAndNil(fLocals);
FreeAndNil(fArguments);
inherited;
end;
function TParsedFunction.GetCodeHint: string;
Var
Module : TParsedModule;
DefinedIn : string;
begin
Module := GetModule;
if Module is TModuleProxy then
DefinedIn := Format(_(SDefinedInModuleCodeHint), [Module.Name])
else
DefinedIn := Format(_(SFilePosInfoCodeHint),
[Module.FileName, fCodePos.LineNo, fCodePos.CharOffset,
Module.Name, fCodePos.LineNo]);
if Parent is TParsedClass then
Result := Format(_(SParsedMethodCodeHint),
[Parent.Name, Name, ArgumentsString, DefinedIn])
else
Result := Format(_(SParsedFunctionCodeHint),
[Name, ArgumentsString, DefinedIn])
end;
procedure TParsedFunction.GetNameSpace(SList: TStringList);
Var
i : integer;
begin
inherited;
// Add Locals
for i := 0 to fLocals.Count - 1 do
SList.AddObject(TVariable(fLocals[i]).Name, fLocals[i]);
// Add arguments
for i := 0 to fArguments.Count - 1 do
SList.AddObject(TVariable(fArguments[i]).Name, fArguments[i]);
end;
function TParsedFunction.HasArgument(Name: string): Boolean;
var
Variable : TObject;
begin
Result := False;
for Variable in fArguments do
if (Variable as TVariable).Name = Name then begin
Result := True;
Exit;
end;
end;
{ TParsedClass }
constructor TParsedClass.Create;
begin
inherited;
fSuperClasses := TStringList.Create;
fSuperClasses.CaseSensitive := True;
fSuperClasses.StrictDelimiter := True;
fAttributes := TObjectList.Create(True);
end;
destructor TParsedClass.Destroy;
begin
FreeAndNil(fSuperClasses);
FreeAndNil(fAttributes);
inherited;
end;
function TParsedClass.GetCodeHint: string;
Var
Module : TParsedModule;
DefinedIn : string;
begin
Module := GetModule;
if Module is TModuleProxy then
DefinedIn := Format(_(SDefinedInModuleCodeHint), [Module.Name])
else
DefinedIn := Format(_(SFilePosInfoCodeHint),
[Module.FileName, fCodePos.LineNo, fCodePos.CharOffset,
Module.Name, fCodePos.LineNo]);
Result := Format(_(SParsedClassCodeHint),
[Name, DefinedIn]);
if fSuperClasses.Count > 0 then
Result := Result + Format(_(SInheritsFromCodeHint), [fSuperClasses.CommaText]);
end;
function TParsedClass.GetConstructor: TParsedFunction;
var
BaseClassResolver : TStringList;
begin
BaseClassResolver := TStringList.Create;
BaseClassResolver.CaseSensitive := True;
try
Result := GetConstructorImpl(BaseClassResolver);
finally
BaseClassResolver.Free;
end;
end;
function TParsedClass.GetConstructorImpl(
BaseClassResolver: TStringList): TParsedFunction;
var
Module : TParsedModule;
S: string;
ErrMsg : string;
CE : TCodeElement;
i : integer;
BaseClass : TBaseCodeElement;
begin
Result := nil;
Module := GetModule;
S := Module.Name + '.' + Parent.Name + '.' + Name;
if BaseClassResolver.IndexOf(S) < 0 then begin
BaseClassResolver.Add(S);
try
for i := 0 to ChildCount - 1 do begin
CE := Children[i];
if (CE.Name = '__init__') and (CE is TParsedFunction) then begin
Result := TParsedFunction(CE);
break;
end;
end;
if not Assigned(Result) then begin
// search superclasses
for i := 0 to fSuperClasses.Count - 1 do begin
BaseClass := PyScripterRefactor.FindDottedDefinition(fSuperClasses[i],
Module, self.Parent as TCodeElement, ErrMsg);
if not (Assigned(BaseClass) and (BaseClass is TParsedClass)) then continue;
// we have found BaseClass
Result := TParsedClass(BaseClass).GetConstructorImpl(BaseClassResolver);
if Assigned(Result) then break;
end;
end;
finally
BaseClassResolver.Delete(BaseClassResolver.IndexOf(S));
end;
end;
end;
procedure TParsedClass.GetNameSpace(SList: TStringList);
var
BaseClassResolver : TStringList;
begin
BaseClassResolver := TStringList.Create;
BaseClassResolver.CaseSensitive := True;
try
GetNameSpaceImpl(SList, BaseClassResolver);
finally
BaseClassResolver.Free;
end;
end;
procedure TParsedClass.GetNameSpaceImpl(SList: TStringList;
BaseClassResolver : TStringList);
Var
i : integer;
Module : TParsedModule;
ErrMsg: string;
BaseClass : TBaseCodeElement;
S : string;
begin
Module := GetModule;
S := Module.Name + '.' + Parent.Name + '.' + Name;
if BaseClassResolver.IndexOf(S) < 0 then begin
BaseClassResolver.Add(S);
try
inherited GetNameSpace(SList);
// Add attributes
for i := 0 to fAttributes.Count - 1 do
SList.AddObject(TVariable(fAttributes[i]).Name, fAttributes[i]);
if fSuperClasses.Count > 0 then begin
for i := 0 to fSuperClasses.Count - 1 do begin
BaseClass := PyScripterRefactor.FindDottedDefinition(fSuperClasses[i],
Module, self.Parent as TCodeElement, ErrMsg);
if not (Assigned(BaseClass) and (BaseClass is TParsedClass)) then continue;
// we have found BaseClass
TParsedClass(BaseClass).GetNameSpaceImpl(SList, BaseClassResolver);
end;
end;
finally
BaseClassResolver.Delete(BaseClassResolver.IndexOf(S));
end;
end;
end;
procedure TParsedClass.GetUniqueSortedAttibutes(AttributesList: TObjectList);
Var
i, j : integer;
HasName : boolean;
begin
for i := 0 to fAttributes.Count - 1 do begin
HasName := False;
for j := 0 to AttributesList.Count - 1 do
if TVariable(fAttributes[i]).Name = TVariable(AttributesList[j]).Name then begin
HasName := True;
break;
end;
if not HasName then
AttributesList.Add(fAttributes[i]);
end;
AttributesList.Sort(CompareVariables);
end;
function CodeBlock(StartLine, EndLine : integer) : TCodeBlock;
begin
Result.StartLine := StartLine;
Result.EndLine := EndLine;
end;
function GetExpressionType(Expr: string; var VarAtts: TVariableAttributes): string;
Var
IsBuiltInType : Boolean;
begin
if Expr.Length = 0 then Exit('');
if TPyRegExpr.FunctionCallRE.IsMatch(Expr) then begin
Result := TPyRegExpr.FunctionCallRE.PerlRegEx.Groups[1];
if TPyRegExpr.FunctionCallRE.PerlRegEx.Groups[2] <> '' then //= '('
Include(VarAtts, vaCall);
end else begin
Result := GetExpressionBuiltInType(Expr, IsBuiltInType);
if IsBuiltInType then
Include(VarAtts, vaBuiltIn);
end;
end;
function GetExpressionBuiltInType(Expr : string; Var IsBuiltIn : boolean) : string;
Var
i : integer;
begin
Result := '';
IsBuiltIn := False;
Expr := Trim(Expr);
if (Expr = '') or (Word(Expr[1]) > $FF) then Exit;
IsBuiltIn := True;
case Expr[1] of
'"','''' : Result := 'str';
'0'..'9', '+', '-' :
begin
Result := 'int';
for i := 2 to Length(Expr) - 1 do begin
if Expr[i] = '.' then begin
Result := 'float';
break;
end else if not CharInSet(Expr[i], ['0'..'9', '+', '-']) then
break;
end;
end;
'{' :
if (CharPos(Expr, ',') = 0) or (CharPos(Expr, ':') <> 0) then
Result := 'dict'
else
Result := 'set';
'[': Result := 'list';
else
if (Expr[1] = '(') and (CharPos(Expr, ',') <> 0) then
Result := 'tuple' // speculative
else
IsBuiltIn := False;
end;
end;
{ TBaseCodeElement }
function TBaseCodeElement.GetDottedName: string;
// Unique name in dotted notation;
begin
if Assigned(Parent) then
Result := Parent.GetDottedName + '.' + Name
else
Result := Name;
end;
function TBaseCodeElement.GetModule: TParsedModule;
begin
Result := GetRoot as TParsedModule;
end;
function TBaseCodeElement.GetModuleSource: string;
var
ParsedModule : TParsedModule;
begin
ParsedModule := GetModule;
if Assigned(ParsedModule) then
Result := ParsedModule.Source
else
Result := '';
end;
function TBaseCodeElement.GetRoot: TBaseCodeElement;
begin
Result := self;
while Assigned(Result.fParent) do
Result := Result.fParent;
end;
{ TVariable }
function TVariable.GetCodeHint: string;
Var
Module : TParsedModule;
Fmt, DefinedIn : string;
ErrMsg : string;
CE : TCodeElement;
begin
Module := GetModule;
if Module is TModuleProxy then
DefinedIn := Format(_(SDefinedInModuleCodeHint), [Module.Name])
else
DefinedIn := Format(_(SFilePosInfoCodeHint),
[Module.FileName, fCodePos.LineNo, fCodePos.CharOffset,
Module.Name, fCodePos.LineNo]);
if Parent is TParsedFunction then begin
if [vaArgument, vaStarArgument, vaStarStarArgument, vaArgumentWithDefault] *
Attributes <> []
then
Fmt := _(SFunctionParameterCodeHint)
else
Fmt := _(SLocalVariableCodeHint);
end else if Parent is TParsedClass then begin
if vaClassAttribute in Attributes then
Fmt := _(SClassVariableCodeHint)
else
Fmt := _(SInstanceVariableCodeHint);
end else if Parent is TParsedModule then begin
Fmt := _(SGlobalVariableCodeHint);
end else if Parent is TModuleImport then begin
Fmt := _(SImportedVariableCodeHint);
end else
Fmt := '';
Result := Format(Fmt,
[Name, Parent.Name, DefinedIn]);
CE := PyScripterRefactor.GetVarType(Self, ErrMsg);
if Assigned(CE) then
Result := Result + Format(_(SVariableTypeCodeHint), [CE.Name]);
end;
function TVariable.GetRealName: string;
begin
if fRealName <> '' then
Result := fRealName
else
Result := Name;
end;
{ TAsynchSourceScanner }
constructor TAsynchSourceScanner.Create(const FileName, Source: string);
begin
inherited Create;
fParsedModule := TParsedModule.Create(FileName, Source);
fPythonScanner := TPythonScanner.Create;
fPythonScanner.OnScannerProgress := ScanProgress;
fFuture := TTask.Future<TParsedModule>(Self, FutureTask);
end;
destructor TAsynchSourceScanner.Destroy;
begin
inherited;
fFuture.Wait;
FreeAndNil(fParsedModule);
FreeAndNil(fPythonScanner);
inherited;
end;
function TAsynchSourceScanner.Finished: Boolean;
begin
Result := fFuture.Status in [TTaskStatus.Completed, TTaskStatus.Exception];
end;
function TAsynchSourceScanner.GetParsedModule: TParsedModule;
begin
Result := fFuture.Value;
end;
procedure TAsynchSourceScanner.ScanProgress(CharNo, NoOfChars: integer;
var Stop: Boolean);
begin
if fStopped then Stop := True;
end;
procedure TAsynchSourceScanner.StopScanning;
begin
fStopped := True;
end;
function TAsynchSourceScanner.FutureTask(Sender : TObject) : TParsedModule;
begin
//StopWatch.Reset;
//StopWatch.Start;
if not fPythonScanner.ScanModule(fParsedModule) then
FreeAndNil(fParsedModule);
Result := fParsedModule;
//StopWatch.Stop;
//OutputDebugString(PWideChar(Format('ScanModule time in ms: %d', [StopWatch.ElapsedMilliseconds])));
end;
{ TAsynchSourceScannerFactory }
procedure TAsynchSourceScannerFactory.ClearFinished;
var
i : integer;
Scanner : IAsyncSourceScanner;
begin
fIList.Lock;
try
for i := fIList.Count - 1 downto 0 do begin
Scanner := IAsyncSourceScanner(fIList[i]);
if Scanner.Finished then
fIList.Delete(i);
end;
finally
fIList.UnLock;
end;
end;
constructor TAsynchSourceScannerFactory.Create;
begin
inherited;
fIList := TInterfaceList.Create;
end;
function TAsynchSourceScannerFactory.CreateAsynchSourceScanner(const FileName,
Source: string): IAsyncSourceScanner;
begin
ClearFinished;
Result := TAsynchSourceScanner.Create(FileName, Source);
fIList.Add(Result);
end;
destructor TAsynchSourceScannerFactory.Destroy;
begin
while fIList.Count > 0 do begin
ClearFinished;
Sleep(10); // wait for threads to finish
end;
fIList.Free;
inherited;
end;
procedure TAsynchSourceScannerFactory.ReleaseScanner(
Scanner: IAsyncSourceScanner);
begin
fIList.Remove(Scanner);
end;
initialization
DocStringRE.Create('(?sm)^[ \t]*[ur]?(\"\"\"(.*?)\"\"\"|''''''(.*?)'''''')');
DocStringRE.Study;
AsynchSourceScannerFactory := TAsynchSourceScannerFactory.Create;
finalization
FreeAndNil(AsynchSourceScannerFactory);
end.
| 32.746244 | 195 | 0.640479 |
471f79f246a95f4a5c27f2eeade0b2058fdab399 | 19,282 | pas | Pascal | Source/BCEditor.Highlighter.pas | EricGrange/TBCEditor | ef037fc3638b9bcf4ecacafcfc30fac745712460 | [
"MIT"
]
| 2 | 2018-01-03T03:48:19.000Z | 2021-12-08T14:54:20.000Z | Source/BCEditor.Highlighter.pas | EricGrange/TBCEditor | ef037fc3638b9bcf4ecacafcfc30fac745712460 | [
"MIT"
]
| null | null | null | Source/BCEditor.Highlighter.pas | EricGrange/TBCEditor | ef037fc3638b9bcf4ecacafcfc30fac745712460 | [
"MIT"
]
| 1 | 2021-04-29T08:09:41.000Z | 2021-04-29T08:09:41.000Z | unit BCEditor.Highlighter;
interface
uses
Classes, SysUtils, Controls, Graphics, BCEditor.Highlighter.Rules, BCEditor.Highlighter.Token,
BCEditor.Consts, BCEditor.Highlighter.Attributes, BCEditor.Highlighter.Info, BCEditor.Editor.SkipRegions,
BCEditor.Highlighter.Colors, BCEditor.Editor.CodeFolding.Regions, BCEditor.Highlighter.Comments, BCEditor.Types;
type
TBCEditorHighlighter = class(TObject)
strict private
FAllDelimiters: TBCEditorCharSet;
FAttributes: TStringList;
FBeginningOfLine: Boolean;
FCodeFoldingRangeCount: Integer;
FCodeFoldingRegions: TBCEditorCodeFoldingRegions;
FColors: TBCEditorHighlighterColors;
FComments: TBCEditorHighlighterComments;
FCompletionProposalSkipRegions: TBCEditorSkipRegions;
FCurrentLine: PChar;
FCurrentRange: TBCEditorRange;
FCurrentToken: TBCEditorToken;
FEditor: TWinControl;
FEndOfLine: Boolean;
FFileName: string;
FFoldCloseKeyChars: TBCEditorCharSet;
FFoldOpenKeyChars: TBCEditorCharSet;
FInfo: TBCEditorHighlighterInfo;
FLoading: Boolean;
FMainRules: TBCEditorRange;
FMatchingPairHighlight: Boolean;
FMatchingPairs: TList;
FMultiHighlighter: Boolean;
FName: string;
FPreviousEndOfLine: Boolean;
FRunPosition: LongInt;
FSkipCloseKeyChars: TBCEditorCharSet;
FSkipOpenKeyChars: TBCEditorCharSet;
FTemporaryCurrentTokens: TList;
FTokenPosition: Integer;
FWordBreakChars: TBCEditorCharSet;
procedure AddAllAttributes(ARange: TBCEditorRange);
procedure UpdateAttributes(ARange: TBCEditorRange; AParentRange: TBCEditorRange);
protected
function GetAttribute(AIndex: Integer): TBCEditorHighlighterAttribute;
procedure AddAttribute(AHighlighterAttribute: TBCEditorHighlighterAttribute);
procedure Prepare;
procedure Reset;
procedure SetAttributesOnChange(AEvent: TNotifyEvent);
procedure SetCodeFoldingRangeCount(AValue: Integer);
procedure SetWordBreakChars(AChars: TBCEditorCharSet);
public
constructor Create(AOwner: TWinControl);
destructor Destroy; override;
function GetCurrentRange: TBCEditorRange;
function GetCurrentRangeAttribute: TBCEditorHighlighterAttribute;
function GetEndOfLine: Boolean;
function GetTokenAttribute: TBCEditorHighlighterAttribute;
function GetTokenKind: TBCEditorRangeType;
function GetTokenLength: Integer;
function GetTokenPosition: Integer;
procedure AddKeyChar(AKeyCharType: TBCEditorKeyCharType; AChar: Char);
procedure AddKeywords(var AStringList: TStringList);
procedure Clear;
procedure GetToken(var AResult: string);
procedure LoadFromFile(const AFileName: string);
procedure LoadFromStream(AStream: TStream);
procedure Next;
procedure NextToEndOfLine;
procedure ResetCurrentRange;
procedure SetCurrentLine(const ANewValue: string);
procedure SetCurrentRange(AValue: Pointer);
procedure UpdateColors;
property Attribute[AIndex: Integer]: TBCEditorHighlighterAttribute read GetAttribute;
property Attributes: TStringList read FAttributes;
property CodeFoldingRangeCount: Integer read FCodeFoldingRangeCount write SetCodeFoldingRangeCount;
property CodeFoldingRegions: TBCEditorCodeFoldingRegions read FCodeFoldingRegions write FCodeFoldingRegions;
property Colors: TBCEditorHighlighterColors read FColors write FColors;
property Comments: TBCEditorHighlighterComments read FComments write FComments;
property CompletionProposalSkipRegions: TBCEditorSkipRegions read FCompletionProposalSkipRegions write FCompletionProposalSkipRegions;
property Editor: TWinControl read FEditor;
property FileName: string read FFileName write FFileName;
property FoldCloseKeyChars: TBCEditorCharSet read FFoldCloseKeyChars write FFoldCloseKeyChars;
property FoldOpenKeyChars: TBCEditorCharSet read FFoldOpenKeyChars write FFoldOpenKeyChars;
property Info: TBCEditorHighlighterInfo read FInfo write FInfo;
property Loading: Boolean read FLoading write FLoading;
property MainRules: TBCEditorRange read FMainRules;
property MatchingPairHighlight: Boolean read FMatchingPairHighlight write FMatchingPairHighlight default True;
property MatchingPairs: TList read FMatchingPairs write FMatchingPairs;
property MultiHighlighter: Boolean read FMultiHighlighter write FMultiHighlighter;
property Name: string read FName write FName;
property SkipCloseKeyChars: TBCEditorCharSet read FSkipCloseKeyChars write FSkipCloseKeyChars;
property SkipOpenKeyChars: TBCEditorCharSet read FSkipOpenKeyChars write FSkipOpenKeyChars;
property WordBreakChars: TBCEditorCharSet read FWordBreakChars write SetWordBreakChars;
end;
implementation
uses
BCEditor.Highlighter.Import.JSON, Types, BCEditor.Editor.Base, IOUtils;
procedure TBCEditorHighlighter.AddKeyChar(AKeyCharType: TBCEditorKeyCharType; AChar: Char);
begin
case AKeyCharType of
ctFoldOpen: FFoldOpenKeyChars := FFoldOpenKeyChars + [AChar];
ctFoldClose: FFoldCloseKeyChars := FFoldCloseKeyChars + [AChar];
ctSkipOpen: FSkipOpenKeyChars := FSkipOpenKeyChars + [AChar];
ctSkipClose: FSkipCloseKeyChars := FSkipCloseKeyChars + [AChar];
end;
end;
constructor TBCEditorHighlighter.Create(AOwner: TWinControl);
begin
inherited Create;
FEditor := AOwner;
FWordBreakChars := BCEDITOR_WORD_BREAK_CHARACTERS;
FAttributes := TStringList.Create;
FAttributes.Duplicates := dupIgnore;
FAttributes.Sorted := False;
FCodeFoldingRangeCount := 0;
FComments := TBCEditorHighlighterComments.Create;
FCompletionProposalSkipRegions := TBCEditorSkipRegions.Create(TBCEditorSkipRegionItem);
Info := TBCEditorHighlighterInfo.Create;
FMainRules := TBCEditorRange.Create;
FMainRules.Parent := FMainRules;
FEndOfLine := False;
FBeginningOfLine := True;
FPreviousEndOfLine := False;
FCurrentRange := MainRules;
FColors := TBCEditorHighlighterColors.Create(Self);
FMatchingPairs := TList.Create;
FMatchingPairHighlight := True;
FTemporaryCurrentTokens := TList.Create;
FAllDelimiters := BCEDITOR_DEFAULT_DELIMITERS + BCEDITOR_ABSOLUTE_DELIMITERS;
FLoading := False;
end;
destructor TBCEditorHighlighter.Destroy;
begin
Clear;
FComments.Free;
FComments := nil;
FMainRules.Free;
FMainRules := nil;
FInfo.Free;
FInfo := nil;
FAttributes.Free;
FAttributes := nil;
FCompletionProposalSkipRegions.Free;
FCompletionProposalSkipRegions := nil;
FMatchingPairs.Free;
FMatchingPairs := nil;
FColors.Free;
FColors := nil;
FTemporaryCurrentTokens.Free;
inherited;
end;
procedure TBCEditorHighlighter.AddAllAttributes(ARange: TBCEditorRange);
var
LIndex: Integer;
begin
AddAttribute(ARange.Attribute);
for LIndex := 0 to ARange.KeyListCount - 1 do
AddAttribute(ARange.KeyList[LIndex].Attribute);
for LIndex := 0 to ARange.SetCount - 1 do
AddAttribute(ARange.Sets[LIndex].Attribute);
for LIndex := 0 to ARange.RangeCount - 1 do
AddAllAttributes(ARange.Ranges[LIndex]);
end;
procedure TBCEditorHighlighter.SetCurrentLine(const ANewValue: string);
begin
if Assigned(FCurrentRange) then
if not FCurrentRange.Prepared then
Prepare;
FCurrentLine := PChar(ANewValue);
FRunPosition := 0;
FTokenPosition := 0;
FEndOfLine := False;
FBeginningOfLine := True;
FPreviousEndOfLine := False;
FCurrentToken := nil;
Next;
end;
procedure TBCEditorHighlighter.Next;
var
LIndex, LPosition: Integer;
LParser: TBCEditorAbstractParser;
LKeyword: PChar;
LCloseParent: Boolean;
LDelimiters: TBCEditorCharSet;
begin
while FTemporaryCurrentTokens.Count > 0 do
begin
FCurrentToken := TBCEditorToken(FTemporaryCurrentTokens[0]);
FCurrentToken.Free;
FCurrentToken := nil;
FTemporaryCurrentTokens.Delete(0);
end;
if FPreviousEndOfLine then
begin
if Assigned(FCurrentRange) then
if FCurrentRange.CloseOnEndOfLine or FCurrentRange.CloseOnTerm then
FCurrentRange := FCurrentRange.Parent;
FEndOfLine := True;
Exit;
end;
if Assigned(FCurrentRange) then
if FCurrentRange.AlternativeCloseArrayCount > 0 then
for LIndex := 0 to FCurrentRange.AlternativeCloseArrayCount - 1 do
begin
LKeyword := PChar(FCurrentRange.AlternativeCloseArray[LIndex]);
LPosition := FRunPosition;
while (FCurrentLine[LPosition] <> BCEDITOR_NONE_CHAR) and (FCurrentLine[LPosition] = LKeyword^) do
begin
Inc(LKeyword);
Inc(LPosition);
end;
if LKeyword^ = BCEDITOR_NONE_CHAR then
begin
FCurrentRange := FCurrentRange.Parent;
Break;
end;
end;
FTokenPosition := FRunPosition;
if Assigned(FCurrentRange) then
begin
LCloseParent := FCurrentRange.CloseParent;
if FCurrentRange.CloseOnTerm and CharInSet(FCurrentLine[FRunPosition], FCurrentRange.Delimiters) and
not (FCurrentRange.SkipWhitespace and CharInSet(FCurrentLine[FRunPosition], BCEDITOR_ABSOLUTE_DELIMITERS)) then
begin
FCurrentRange := FCurrentRange.Parent;
if Assigned(FCurrentRange) then
if LCloseParent then
FCurrentRange := FCurrentRange.Parent;
end;
if Ord(FCurrentLine[FRunPosition]) < 256 then
LParser := FCurrentRange.SymbolList[AnsiChar(FCurrentRange.CaseFunct(FCurrentLine[FRunPosition]))]
else
LParser := FCurrentRange.SymbolList['a'];
if not Assigned(LParser) then
Inc(FRunPosition)
else
if not LParser.GetToken(FCurrentRange, FCurrentLine, FRunPosition, FCurrentToken) then
begin
FCurrentToken := FCurrentRange.DefaultToken;
if FCurrentRange.UseDelimitersForText then
LDelimiters := FCurrentRange.Delimiters
else
LDelimiters := FAllDelimiters;
if Ord(FCurrentLine[FRunPosition - 1]) < 256 then
while (Ord(FCurrentLine[FRunPosition]) < 256) and not CharInSet(FCurrentLine[FRunPosition], LDelimiters) do
Inc(FRunPosition)
else
while (Ord(FCurrentLine[FRunPosition]) > 255) and not CharInSet(FCurrentLine[FRunPosition], LDelimiters) do
Inc(FRunPosition)
end
else
if FCurrentRange.ClosingToken = FCurrentToken then
FCurrentRange := FCurrentRange.Parent
else
if Assigned(FCurrentToken) and Assigned(FCurrentToken.OpenRule) then
if FCurrentToken.OpenRule is TBCEditorRange then
begin
FCurrentRange := TBCEditorRange(FCurrentToken.OpenRule);
FCurrentRange.ClosingToken := FCurrentToken.ClosingToken;
if FCurrentRange.OpenBeginningOfLine and not FBeginningOfLine then
begin
FCurrentRange := FCurrentRange.Parent;
FCurrentToken := FCurrentRange.DefaultToken;
end;
end;
if Assigned(FCurrentToken) then
if FCurrentToken.Temporary then
FTemporaryCurrentTokens.Add(FCurrentToken);
end;
if FBeginningOfLine then
if FRunPosition >= 1 then
if not CharInset(FCurrentLine[FRunPosition - 1], BCEDITOR_ABSOLUTE_DELIMITERS) then
FBeginningOfLine := False;
if FCurrentLine[FRunPosition] = BCEDITOR_NONE_CHAR then
FPreviousEndOfLine := True;
end;
function TBCEditorHighlighter.GetCurrentRangeAttribute: TBCEditorHighlighterAttribute;
begin
Result := nil;
if Assigned(FCurrentRange) then
Result := FCurrentRange.Attribute;
end;
function TBCEditorHighlighter.GetEndOfLine: Boolean;
begin
Result := FEndOfLine;
end;
function TBCEditorHighlighter.GetCurrentRange: TBCEditorRange;
begin
Result := FCurrentRange;
end;
function TBCEditorHighlighter.GetTokenAttribute: TBCEditorHighlighterAttribute;
begin
if Assigned(FCurrentToken) then
Result := FCurrentToken.Attribute
else
Result := nil;
end;
function TBCEditorHighlighter.GetTokenPosition: Integer;
begin
Result := FTokenPosition;
end;
procedure TBCEditorHighlighter.ResetCurrentRange;
begin
FCurrentRange := MainRules;
end;
procedure TBCEditorHighlighter.SetCodeFoldingRangeCount(AValue: Integer);
begin
if FCodeFoldingRangeCount <> AValue then
begin
SetLength(FCodeFoldingRegions, AValue);
FCodeFoldingRangeCount := AValue;
end;
end;
procedure TBCEditorHighlighter.SetCurrentRange(AValue: Pointer);
begin
FCurrentRange := TBCEditorRange(AValue);
end;
procedure TBCEditorHighlighter.AddKeywords(var AStringList: TStringList);
var
LIndex, LIndex2: Integer;
begin
if not Assigned(AStringList) then
Exit;
for LIndex := 0 to FMainRules.KeyListCount - 1 do
for LIndex2 := 0 to FMainRules.KeyList[LIndex].KeyList.Count - 1 do
AStringList.Add(FMainRules.KeyList[LIndex].KeyList[LIndex2]);
end;
procedure TBCEditorHighlighter.GetToken(var AResult: string);
var
LLength: LongInt;
begin
LLength := FRunPosition - FTokenPosition;
SetString(AResult, FCurrentLine + FTokenPosition, LLength);
end;
procedure TBCEditorHighlighter.Reset;
begin
MainRules.Reset;
end;
function TBCEditorHighlighter.GetTokenKind: TBCEditorRangeType;
var
LIndex: Integer;
LToken: string;
LTokenType: TBCEditorRangeType;
LCurrentRangeKeyList: TBCEditorKeyList;
begin
LTokenType := FCurrentRange.TokenType;
if LTokenType <> ttUnspecified then
Result := LTokenType
else
{ keyword token type }
begin
GetToken(LToken);
for LIndex := 0 to FCurrentRange.KeyListCount - 1 do
begin
LCurrentRangeKeyList := FCurrentRange.KeyList[LIndex];
if LCurrentRangeKeyList.KeyList.IndexOf(LToken) <> -1 then
Exit(LCurrentRangeKeyList.TokenType);
end;
Result := ttUnspecified
end;
end;
procedure TBCEditorHighlighter.Clear;
var
LIndex: Integer;
begin
FFoldOpenKeyChars := [];
FFoldCloseKeyChars := [];
FSkipOpenKeyChars := [];
FSkipCloseKeyChars := [];
FAttributes.Clear;
FMainRules.Clear;
FInfo.Clear;
FComments.Clear;
FCompletionProposalSkipRegions.Clear;
for LIndex := FMatchingPairs.Count - 1 downto 0 do
Dispose(PBCEditorMatchingPairToken(FMatchingPairs.Items[LIndex]));
FMatchingPairs.Clear;
for LIndex := 0 to FCodeFoldingRangeCount - 1 do
begin
FCodeFoldingRegions[LIndex].Free;
FCodeFoldingRegions[LIndex] := nil;
end;
CodeFoldingRangeCount := 0;
(Editor as TBCBaseEditor).ClearMatchingPair;
end;
procedure TBCEditorHighlighter.Prepare;
begin
FAttributes.Clear;
AddAllAttributes(MainRules);
FMainRules.Prepare(FMainRules);
end;
procedure TBCEditorHighlighter.UpdateAttributes(ARange: TBCEditorRange; AParentRange: TBCEditorRange);
var
LIndex: Integer;
procedure SetAttributes(AAttribute: TBCEditorHighlighterAttribute; AParentRange: TBCEditorRange);
var
LElement: PBCEditorHighlighterElement;
begin
LElement := FColors.GetElement(AAttribute.Element);
if AAttribute.ParentBackground and Assigned(AParentRange) then
AAttribute.Background := AParentRange.Attribute.Background
else
if Assigned(LElement) then
AAttribute.Background := LElement.Background;
if AAttribute.ParentForeground and Assigned(AParentRange) then
AAttribute.Foreground := AParentRange.Attribute.Foreground
else
if Assigned(LElement) then
AAttribute.Foreground := LElement.Foreground;
if Assigned(LElement) then
AAttribute.FontStyles := LElement.FontStyles;
end;
begin
SetAttributes(ARange.Attribute, AParentRange);
for LIndex := 0 to ARange.KeyListCount - 1 do
SetAttributes(ARange.KeyList[LIndex].Attribute, ARange);
for LIndex := 0 to ARange.SetCount - 1 do
SetAttributes(ARange.Sets[LIndex].Attribute, ARange);
if ARange.RangeCount > 0 then
for LIndex := 0 to ARange.RangeCount - 1 do
UpdateAttributes(ARange.Ranges[LIndex], ARange);
end;
procedure TBCEditorHighlighter.UpdateColors;
var
LEditor: TBCBaseEditor;
LFontDummy: TFont;
begin
UpdateAttributes(MainRules, nil);
LEditor := FEditor as TBCBaseEditor;
if Assigned(LEditor) then
begin
LFontDummy := TFont.Create;
try
LFontDummy.Name := LEditor.Font.Name;
LFontDummy.Size := LEditor.Font.Size;
LEditor.Font.Assign(LFontDummy);
finally
LFontDummy.Free;
end;
end;
end;
procedure TBCEditorHighlighter.LoadFromFile(const AFileName: string);
var
LStream: TStream;
LEditor: TBCBaseEditor;
begin
FFileName := AFileName;
FName := TPath.GetFileNameWithoutExtension(AFileName);
LEditor := FEditor as TBCBaseEditor;
if Assigned(LEditor) then
begin
LStream := LEditor.CreateFileStream(LEditor.GetHighlighterFileName(AFileName));
try
LoadFromStream(LStream);
finally
LStream.Free;
end;
end;
end;
procedure TBCEditorHighlighter.LoadFromStream(AStream: TStream);
var
LEditor: TBCBaseEditor;
LTempLines: TStringList;
LTopLine: Integer;
LCaretPosition: TBCEditorTextPosition;
begin
Clear;
LEditor := FEditor as TBCBaseEditor;
if Assigned(LEditor) then
begin
FLoading := True;
LTempLines := TStringList.Create;
try
if LEditor.Visible then
LCaretPosition := LEditor.TextCaretPosition;
LTopLine := LEditor.TopLine;
LTempLines.AddStrings(LEditor.Lines);
LEditor.Lines.Clear;
with TBCEditorHighlighterImportJSON.Create(Self) do
try
ImportFromStream(AStream);
finally
Free;
end;
LEditor.Lines.LoadFromStrings(LTempLines);
LEditor.TopLine := LTopLine;
if LEditor.Visible then
LEditor.TextCaretPosition := LCaretPosition;
finally
LTempLines.Free;
end;
UpdateColors;
FLoading := False;
end;
end;
function TBCEditorHighlighter.GetAttribute(AIndex: Integer): TBCEditorHighlighterAttribute;
begin
Result := nil;
if (AIndex >= 0) and (AIndex < FAttributes.Count) then
Result := TBCEditorHighlighterAttribute(FAttributes.Objects[AIndex]);
end;
procedure TBCEditorHighlighter.AddAttribute(AHighlighterAttribute: TBCEditorHighlighterAttribute);
begin
FAttributes.AddObject(AHighlighterAttribute.Name, AHighlighterAttribute);
end;
procedure TBCEditorHighlighter.SetWordBreakChars(AChars: TBCEditorCharSet);
begin
FWordBreakChars := AChars;
end;
procedure TBCEditorHighlighter.NextToEndOfLine;
begin
while not GetEndOfLine do
Next;
end;
procedure TBCEditorHighlighter.SetAttributesOnChange(AEvent: TNotifyEvent);
var
LIndex: Integer;
LHighlighterAttribute: TBCEditorHighlighterAttribute;
begin
for LIndex := FAttributes.Count - 1 downto 0 do
begin
LHighlighterAttribute := TBCEditorHighlighterAttribute(FAttributes.Objects[LIndex]);
if Assigned(LHighlighterAttribute) then
begin
LHighlighterAttribute.OnChange := AEvent;
LHighlighterAttribute.InternalSaveDefaultValues;
end;
end;
end;
function TBCEditorHighlighter.GetTokenLength: Integer;
begin
Result := FRunPosition - FTokenPosition;
end;
end.
| 32.083195 | 139 | 0.738253 |
cdc7f0e76417b5111a0a0ea293ef746a5b24b306 | 389 | pas | Pascal | unt_pesq_cliente_c.pas | ewertonjsilva/QTS2 | ae6803ae6a8583955a931f99556734c22ec22ca7 | [
"MIT"
]
| null | null | null | unt_pesq_cliente_c.pas | ewertonjsilva/QTS2 | ae6803ae6a8583955a931f99556734c22ec22ca7 | [
"MIT"
]
| null | null | null | unt_pesq_cliente_c.pas | ewertonjsilva/QTS2 | ae6803ae6a8583955a931f99556734c22ec22ca7 | [
"MIT"
]
| null | null | null | unit unt_pesq_cliente_c;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs;
type
Tfrm_pesq_cliente_c = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
end;
var
frm_pesq_cliente_c: Tfrm_pesq_cliente_c;
implementation
{$R *.dfm}
end.
| 15.56 | 98 | 0.745501 |
fc21a627ce1be7d6713f9945158253e20bfa5328 | 24,435 | pas | Pascal | Demos/AsyncSource with Filestreams/main.pas | magnussandberg/The-Drag-and-Drop-Component-Suite-for-Delphi | 31ce9e0b89a093b140f64ded119b8ea75b9f5eed | [
"MIT"
]
| 98 | 2015-08-24T13:11:14.000Z | 2020-08-19T14:25:40.000Z | Demos/AsyncSource with Filestreams/main.pas | magnussandberg/The-Drag-and-Drop-Component-Suite-for-Delphi | 31ce9e0b89a093b140f64ded119b8ea75b9f5eed | [
"MIT"
]
| 40 | 2015-11-26T22:14:18.000Z | 2020-03-30T12:11:07.000Z | Demos/AsyncSource with Filestreams/main.pas | magnussandberg/The-Drag-and-Drop-Component-Suite-for-Delphi | 31ce9e0b89a093b140f64ded119b8ea75b9f5eed | [
"MIT"
]
| 34 | 2015-12-14T12:39:45.000Z | 2020-08-10T21:12:05.000Z | unit main;
interface
uses
RingbufferStream,
DragDrop, DropSource, DragDropFile,
// Indy 10 required
IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
IdExplicitTLSClientServerBase, IdFTP,
Messages, Dialogs,
ActiveX, Windows, Classes, Controls, Forms, StdCtrls, ComCtrls, ExtCtrls,
Buttons, ImgList, ToolWin, ActnList, Actions, ImageList, Types;
{$include DragDrop.inc}
{$IF CompilerVersion >= 12.0}
// Work around for interface breaking changes between different Indy 10 releases... Pffft!
type
TIndyWorkCountInt = int64;
{$else}
type
TIndyWorkCountInt = integer;
// Hack to make it possible to load new indy FTP component with old indy version
TIPVersion = (Id_IPv4, Id_IPv6);
TIdFTP = class(IdFTP.TIdFTP)
private
FDummyVersion: TIPVersion;
published
property IPVersion: TIPVersion write FDummyVersion;
end;
{$endif}
const
MSG_PROGRESS = WM_USER;
MSG_STATUS = WM_USER+1;
MSG_TRANSFER = WM_USER+2;
MSG_BROWSE = WM_USER+3;
type
TDragDropStage = (dsNone, dsIdle, dsDrag, dsDragAsync, dsDragAsyncFailed, dsDrop, dsGetData, dsGetStream, dsDropComplete);
TBrowseOption = (boBrowse, boUpdateCombo);
TBrowseOptions = set of TBrowseOption;
TFormMain = class(TForm)
DropEmptySource1: TDropEmptySource;
DataFormatAdapterSource: TDataFormatAdapter;
ProgressBar1: TProgressBar;
StatusBar1: TStatusBar;
ListViewFiles: TListView;
CoolBar1: TCoolBar;
ToolBarMain: TToolBar;
AnimateThrobber: TAnimate;
ComboAddress: TComboBox;
ButtonBack: TToolButton;
ButtonForward: TToolButton;
ButtonReload: TToolButton;
ButtonStop: TToolButton;
ImageListNormal: TImageList;
ButtonUp: TToolButton;
ToolButton1: TToolButton;
ImageListDisabled: TImageList;
ImageListHot: TImageList;
ButtonHome: TToolButton;
ToolButton2: TToolButton;
ToolButton3: TToolButton;
ActionList1: TActionList;
ActionBack: TAction;
ActionForward: TAction;
ActionRefresh: TAction;
ActionStop: TAction;
ActionUp: TAction;
ActionHome: TAction;
IdFTP1: TIdFTP;
ImageListExplorer: TImageList;
Timer1: TTimer;
procedure DropEmptySource1Drop(Sender: TObject; DragType: TDragType;
var ContinueDrop: Boolean);
procedure DropEmptySource1AfterDrop(Sender: TObject;
DragResult: TDragResult; Optimized: Boolean);
procedure DropEmptySource1GetData(Sender: TObject;
const FormatEtc: tagFORMATETC; out Medium: tagSTGMEDIUM;
var Handled: Boolean);
procedure OnMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure FormCreate(Sender: TObject);
procedure ComboAddressKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure FormDestroy(Sender: TObject);
procedure ActionBackExecute(Sender: TObject);
procedure ActionForwardExecute(Sender: TObject);
procedure ActionRefreshExecute(Sender: TObject);
procedure ActionStopExecute(Sender: TObject);
procedure ActionUpExecute(Sender: TObject);
procedure ActionHomeExecute(Sender: TObject);
procedure ActionBackUpdate(Sender: TObject);
procedure ActionForwardUpdate(Sender: TObject);
procedure ActionRefreshUpdate(Sender: TObject);
procedure ActionStopUpdate(Sender: TObject);
procedure ActionUpUpdate(Sender: TObject);
procedure ComboAddressCloseUp(Sender: TObject);
procedure ListViewFilesDblClick(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure IdFTP1Work(Sender: TObject; AWorkMode: TWorkMode;
AWorkCount: TIndyWorkCountInt);
procedure IdFTP1WorkBegin(Sender: TObject; AWorkMode: TWorkMode;
AWorkCountMax: TIndyWorkCountInt);
procedure IdFTP1WorkEnd(Sender: TObject; AWorkMode: TWorkMode);
procedure ActionHomeUpdate(Sender: TObject);
private
FHistoryList: TStringList;
FHistoryIndex: Integer;
FTempPath: string;
FAddress: string;
FStatus: TDragDropStage;
FAbort: boolean;
FAborted: boolean;
FWriteStream: TFifoStream;
FTransferCount: integer;
FBusyCount: integer;
FCurrentFileSize: int64;
FIndyFtpAbortWarningShown: boolean;
function GetTransferInProgress: boolean;
function GetBusy: boolean;
procedure SetStatus(const Value: TDragDropStage);
procedure SetProgress(Count, MaxCount: integer);
procedure OnGetStream(Sender: TFileContentsStreamOnDemandClipboardFormat;
Index: integer; out AStream: IStream);
protected
procedure MsgProgress(var Message: TMessage); message MSG_PROGRESS;
procedure MsgStatus(var Message: TMessage); message MSG_STATUS;
procedure MsgTransfer(var Message: TMessage); message MSG_TRANSFER;
procedure MsgBrowse(var Message: TMessage); message MSG_BROWSE;
public
procedure Browse(const Address: string; Options: TBrowseOptions = [boBrowse]);
procedure AddSourceFile(const Filename: string);
procedure BeginBusy;
procedure EndBusy;
procedure BeginTransfer;
procedure EndTransfer;
property Status: TDragDropStage read FStatus write SetStatus;
property Busy: boolean read GetBusy;
property TransferInProgress: boolean read GetTransferInProgress;
end;
var
FormMain: TFormMain;
implementation
{$R *.DFM}
{$R Throbber.res}
uses
DragDropFormats,
IdURI,
IdFTPList,
IdAllFTPListParsers,
ShlObj,
ShellApi,
Graphics,
SysUtils, StrUtils;
const
sAddressHome = 'ftp://ftp.microsoft.com/';
// Another good test site is:
sAddressHomeAlt = 'ftp://gatekeeper.dec.com/';
resourcestring
sIndyFtpAbortWarning =
'Note: Due to a bug in Indy (the TCP/IP library used in this demo), aborting the'+#13+
'FTP transfer will most likely mess up the FTP session, causing various error if'+#13+
'another transfer is initiated.'+#13+#13+
'A work around for this problem is unfortunately beyond the scope of this demo.';
type
TBrowseKind = (bkAddress, bkUp, bkRefresh);
function AddTrailingSlash(const s: string): string;
begin
Result := s;
if (RightStr(Result, 1) <> '/') then
Result := Result+'/';
end;
function SizeToStr(Value: Int64): string;
var
Postfix: string;
begin
if (Value > 1024) then
begin
Value := Value div 1024;
Postfix := ' Kb';
end else
Postfix := '';
Result := Format('%.0n%s', [Int(Integer(Value)), Postfix]);
end;
function DateTimeToFileTime(ADate: TDateTime): TFileTime;
var
tmp: integer;
LocalFileTime: TFileTime;
begin
tmp := DateTimeToFileDate(ADate);
DosDateTimeToFileTime(LongRec(tmp).Hi, LongRec(tmp).Lo, LocalFileTime);
LocalFileTimeToFileTime(LocalFileTime, Result);
end;
procedure TFormMain.FormCreate(Sender: TObject);
var
SHFileInfo: TSHFileInfo;
begin
FHistoryList := TStringList.Create;
FHistoryIndex := -1;
ComboAddress.Items.Add(sAddressHomeAlt);
// Setup event handler to let a drop target request data from our drop source.
(DataFormatAdapterSource.DataFormat as TVirtualFileStreamDataFormat).OnGetStream := OnGetStream;
StatusBar1.ControlStyle := StatusBar1.ControlStyle +[csAcceptsControls];
Status := dsIdle;
ImageListExplorer.Handle := SHGetFileInfo('', 0, SHFileInfo, SizeOf(TSHFileInfo),
SHGFI_SYSICONINDEX or SHGFI_SMALLICON);
ImageListExplorer.ShareImages := True;
ImageListExplorer.BlendColor := clHighlight;
ImageListExplorer.DrawingStyle := dsTransparent;
SetLength(FTempPath, MAX_PATH);
SetLength(FTempPath, GetTempPath(Length(FTempPath), PChar(FTempPath)));
AnimateThrobber.ResName := 'AVI_THROBBER';
// I assign the Indy FTP events manually in order to get them validated at
// compile time. The reason is that Indy has a habit of changing the
// method/event signatures between minor releases.
IdFTP1.OnWorkBegin := IdFTP1WorkBegin;
IdFTP1.OnWork := IdFTP1Work;
IdFTP1.OnWorkEnd := IdFTP1WorkEnd;
end;
procedure TFormMain.FormDestroy(Sender: TObject);
begin
FHistoryList.Free;
end;
procedure TFormMain.AddSourceFile(const Filename: string);
var
ModifiedDate: TDateTime;
FileSize: int64;
i: integer;
begin
FileSize := IdFTP1.Size(Filename);
ModifiedDate := 0;
for i := 0 to IdFTP1.DirectoryListing.Count-1 do
if (IdFTP1.DirectoryListing[i].FileName = Filename) then
begin
ModifiedDate := IdFTP1.DirectoryListing[i].ModifiedDate;
if (FileSize = -1) then
FileSize := IdFTP1.DirectoryListing[i].Size;
break;
end;
if (FileSize = -1) then
exit;
// Transfer the file name to the data format.
// The content will be extracted by the target on-demand.
i := TVirtualFileStreamDataFormat(DataFormatAdapterSource.DataFormat).FileNames.Add(Filename);
// Set the size and timestamp attributes of the filename we just added.
with TVirtualFileStreamDataFormat(DataFormatAdapterSource.DataFormat).FileDescriptors[i]^ do
begin
if (ModifiedDate <> 0) then
ftLastWriteTime := DateTimeToFileTime(ModifiedDate)
else
GetSystemTimeAsFileTime(ftLastWriteTime);
nFileSizeLow := FileSize and $00000000FFFFFFFF;
nFileSizeHigh := (FileSize and $FFFFFFFF00000000) shr 32;
dwFlags := FD_WRITESTIME or FD_FILESIZE or FD_PROGRESSUI;
end;
end;
procedure TFormMain.OnMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
i: integer;
AnyFile: boolean;
begin
if (ListViewFiles.Selected = nil) or (Busy) then
exit;
TVirtualFileStreamDataFormat(DataFormatAdapterSource.DataFormat).FileNames.Clear;
AnyFile := False;
for i := 0 to ListViewFiles.Items.Count-1 do
if (ListViewFiles.Items[i].Selected) and
(TIdDirItemType(ListViewFiles.Items[i].Data) = ditFile) then
begin
AnyFile := True;
break;
end;
if (not AnyFile) then
exit;
Status := dsIdle;
if DragDetectPlus(Handle, Point(X, Y)) then
begin
for i := 0 to ListViewFiles.Items.Count-1 do
begin
if (ListViewFiles.Items[i].Selected) and
(TIdDirItemType(ListViewFiles.Items[i].Data) = ditFile) then
AddSourceFile(ListViewFiles.Items[i].Caption);
end;
if (TVirtualFileStreamDataFormat(DataFormatAdapterSource.DataFormat).FileNames.Count = 0) then
exit;
Status := dsDrag;
// Perform an asynchronous drag (in a separate thread).
if (DropEmptySource1.Execute(True) = drAsync) then
Status := dsDragAsync
else
Status := dsDragAsyncFailed;
end;
end;
procedure TFormMain.DropEmptySource1Drop(Sender: TObject;
DragType: TDragType; var ContinueDrop: Boolean);
begin
// Warning:
// This event will be called in the context of the transfer thread during an
// asynchronous transfer. See TFormMain.OnProgress for a comment on this.
Status := dsDrop;
end;
procedure TFormMain.DropEmptySource1AfterDrop(Sender: TObject;
DragResult: TDragResult; Optimized: Boolean);
begin
// Warning:
// This event will be called in the context of the transfer thread during an
// asynchronous transfer. See TFormMain.OnProgress for a comment on this.
Status := dsDropComplete;
end;
procedure TFormMain.DropEmptySource1GetData(Sender: TObject;
const FormatEtc: tagFORMATETC; out Medium: tagSTGMEDIUM;
var Handled: Boolean);
begin
// Warning:
// This event will be called in the context of the transfer thread during an
// asynchronous transfer. See TFormMain.OnProgress for a comment on this.
Status := dsGetData;
end;
type
TFifoStreamAdapter = class(TFixedStreamAdapter, IStream)
private
public
function Read(pv: Pointer; cb: {$if CompilerVersion < 29}Longint{$else}FixedUInt{$ifend};
pcbRead: {$if CompilerVersion < 29}PLongint{$else}PFixedUInt{$ifend}): HResult; override; stdcall;
end;
function TFifoStreamAdapter.Read(pv: Pointer; cb: {$if CompilerVersion < 29}Longint{$else}FixedUInt{$ifend};
pcbRead: {$if CompilerVersion < 29}PLongint{$else}PFixedUInt{$ifend}): HResult;
begin
Result := inherited Read(pv, cb, pcbRead);
if (TFifoStream(Stream).Aborted) then
Result := E_ABORT;
end;
procedure TFormMain.OnGetStream(Sender: TFileContentsStreamOnDemandClipboardFormat;
Index: integer; out AStream: IStream);
var
RingBuffer: TRingBuffer;
ReadStream: TStream;
FileDescriptor: PFileDescriptorW;
FileSize: int64;
begin
// This event handler is called by TFileContentsStreamOnDemandClipboardFormat
// when the drop target (e.g. Explorer) requests data from the drop source (that's us).
//
// Warning:
// This method will be called in the context of the transfer thread during an
// asynchronous transfer. See TFormMain.OnProgress for a comment on this.
AStream := nil;
FileDescriptor := TVirtualFileStreamDataFormat(DataFormatAdapterSource.DataFormat).FileDescriptors[Index];
FileSize := int64(FileDescriptor.nFileSizeLow) or (int64(FileDescriptor.nFileSizeHigh) shl 32);
Status := dsGetStream;
RingBuffer := TRingBuffer.Create(16, 1024*64);
ReadStream := TFifoStream.CreateForRead(RingBuffer, FileSize);
// Return the stream back to the target as an IStream. Note that the
// target is responsible for deleting the stream (via reference counting).
AStream := TFifoStreamAdapter.Create(ReadStream, soOwned);
PostMessage(Handle, MSG_TRANSFER, Index, integer(RingBuffer));
end;
procedure TFormMain.MsgTransfer(var Message: TMessage);
var
Index: integer;
Filename: string;
FileDescriptor: PFileDescriptorW;
RingBuffer: TRingBuffer;
begin
Index := Message.WParam;
RingBuffer := TRingBuffer(Message.LParam);
if (TransferInProgress) then
begin
PostMessage(Handle, MSG_TRANSFER, Index, integer(RingBuffer));
exit;
end;
BeginTransfer;
try
FileDescriptor := TVirtualFileStreamDataFormat(DataFormatAdapterSource.DataFormat).FileDescriptors[Index];
FCurrentFileSize := int64(FileDescriptor.nFileSizeLow) or (int64(FileDescriptor.nFileSizeHigh) shl 32);
Filename := TVirtualFileStreamDataFormat(DataFormatAdapterSource.DataFormat).FileNames[Index];
// Note: For this demo only lower 32 bits of file size is used for progress bar
ProgressBar1.Max := FCurrentFileSize and $FFFFFFFF;
ProgressBar1.Position := 0;
ProgressBar1.Show;
StatusBar1.Panels[0].Text := 'Reading file from FTP server...';
Update;
FWriteStream := TFifoStream.CreateForWrite(RingBuffer);
try
FWriteStream.FakeWriteDuringAbort := True;
IdFTP1.Get(Filename, FWriteStream);
finally
FreeAndNil(FWriteStream);
end;
finally
ProgressBar1.Hide;
StatusBar1.Panels[0].Text := '';
EndTransfer;
end;
end;
procedure TFormMain.MsgProgress(var Message: TMessage);
begin
SetProgress(Message.WParam, Message.LParam);
end;
procedure TFormMain.SetProgress(Count, MaxCount: integer);
begin
// Make sure GUI updates are performed in the main thread.
if (GetCurrentThreadID <> MainThreadID) then
begin
PostMessage(Handle, MSG_PROGRESS, Count, MaxCount);
exit;
end;
ProgressBar1.Max := MaxCount;
ProgressBar1.Position := Count;
end;
procedure TFormMain.MsgStatus(var Message: TMessage);
begin
SetStatus(TDragDropStage(Message.WParam));
end;
procedure TFormMain.SetStatus(const Value: TDragDropStage);
var
s: string;
begin
// Make sure GUI updates are performed in the main thread.
if (GetCurrentThreadID <> MainThreadID) then
begin
PostMessage(Handle, MSG_STATUS, ord(Value), 0);
exit;
end;
if (FStatus <> Value) then
begin
FStatus := Value;
case FStatus of
dsIdle:
s := 'Ready';
dsDrag:
s := 'Drag in progress';
dsDragAsync:
s := 'Asynchronous drag started';
dsDragAsyncFailed:
s := 'Asynchronous drag failed';
dsDrop:
s := 'Data dropped';
dsGetData:
s := 'Target reading data';
dsGetStream:
s := 'Source writing data';
dsDropComplete:
s := 'Drop completed';
else
s := '';
end;
StatusBar1.Panels[1].Text := s;
Update;
end;
end;
procedure TFormMain.ComboAddressKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (Key = VK_RETURN) then
begin
Browse(ComboAddress.Text, [boBrowse, boUpdateCombo]);
end;
end;
procedure TFormMain.ComboAddressCloseUp(Sender: TObject);
begin
if (FAddress <> ComboAddress.Text) then
Browse(ComboAddress.Text);
end;
procedure TFormMain.Browse(const Address: string; Options: TBrowseOptions);
var
i: Integer;
begin
if (Address = '') then
exit;
if (boUpdateCombo in Options) then
begin
i := ComboAddress.Items.IndexOf(Address);
if i = -1 then
ComboAddress.Items.Insert(0, Address)
else
ComboAddress.Items.Move(i, 0);
end;
FAddress := Address;
ComboAddress.Text := FAddress;
if (boBrowse in Options) then
PostMessage(Handle, MSG_BROWSE, ord(bkAddress), 0);
end;
procedure TFormMain.ActionBackUpdate(Sender: TObject);
begin
TAction(Sender).Enabled := (FHistoryIndex > 0) and (not Busy);
end;
procedure TFormMain.ActionBackExecute(Sender: TObject);
begin
Dec(FHistoryIndex);
ComboAddress.Text := FHistoryList[FHistoryIndex];
Browse(ComboAddress.Text);
end;
procedure TFormMain.ActionForwardUpdate(Sender: TObject);
begin
TAction(Sender).Enabled := (FHistoryIndex < FHistoryList.Count-1) and (not Busy);
end;
procedure TFormMain.ActionForwardExecute(Sender: TObject);
begin
Inc(FHistoryIndex);
ComboAddress.Text := FHistoryList[FHistoryIndex];
Browse(ComboAddress.Text);
end;
procedure TFormMain.ActionRefreshUpdate(Sender: TObject);
begin
TAction(Sender).Enabled := (ComboAddress.Text <> '') and (not Busy);
end;
procedure TFormMain.ActionRefreshExecute(Sender: TObject);
begin
PostMessage(Handle, MSG_BROWSE, Ord(bkRefresh), 0);
end;
procedure TFormMain.ActionStopUpdate(Sender: TObject);
begin
TAction(Sender).Enabled := (not FAbort) and (Busy);
end;
procedure TFormMain.ActionStopExecute(Sender: TObject);
begin
FAbort := True;
if (not FIndyFtpAbortWarningShown) then
begin
FIndyFtpAbortWarningShown := True;
ShowMessage(sIndyFtpAbortWarning);
end;
end;
procedure TFormMain.ActionUpUpdate(Sender: TObject);
begin
TAction(Sender).Enabled := (ComboAddress.Text <> '') and (not Busy);
end;
procedure TFormMain.ActionUpExecute(Sender: TObject);
begin
PostMessage(Handle, MSG_BROWSE, Ord(bkUp), 0);
end;
procedure TFormMain.ActionHomeUpdate(Sender: TObject);
begin
TAction(Sender).Enabled := (not Busy);
end;
procedure TFormMain.ActionHomeExecute(Sender: TObject);
begin
ComboAddress.Text := sAddressHome;
Browse(ComboAddress.Text);
end;
procedure TFormMain.MsgBrowse(var Message: TMessage);
var
URI: TIdURI;
i: integer;
SHFileInfo: TSHFileInfo;
s: string;
BrowseKind: TBrowseKind;
begin
BrowseKind := TBrowseKind(Message.WParam);
FAborted := False;
BeginBusy;
Screen.Cursor := crAppStart;
try
ListViewFiles.Items.Clear;
URI := TIdURI.Create(AddTrailingSlash(FAddress));
try
if (IdFTP1.Host <> URI.Host) and (IdFTP1.Connected) then
begin
StatusBar1.Panels[0].Text := 'Disconnecting from '+IdFTP1.Host+'...';
Update;
IdFTP1.Disconnect;
end;
if (not IdFTP1.Connected) then
begin
StatusBar1.Panels[0].Text := 'Connecting to '+URI.Host+'...';
Update;
IdFTP1.Host := URI.Host;
IdFTP1.Connect;
// Can't go up or refresh when we have lost the connection
BrowseKind := bkAddress;
end;
try
if (FAborted) then
Abort;
case BrowseKind of
bkAddress:
begin
StatusBar1.Panels[0].Text := 'Navigating to '+URI.Path+'...';
Update;
IdFTP1.ChangeDir(URI.Path);
end;
bkUp:
begin
StatusBar1.Panels[0].Text := 'Navigating to parent folder...';
Update;
IdFTP1.ChangeDirUp;
end;
end;
if (FAborted) then
Abort;
URI.Path := IdFTP1.RetrieveCurrentDir;
if (FAborted) then
Abort;
s := URI.URI;
i := FHistoryList.IndexOf(s);
if (i = -1) then
begin
// Remove entries in HistoryList between last address and current address
if (FHistoryIndex >= 0) and (FHistoryIndex < FHistoryList.Count-1) then
while FHistoryList.Count-1 > FHistoryIndex do
FHistoryList.Delete(FHistoryList.Count-1);
FHistoryIndex := FHistoryList.Add(s);
end else
FHistoryIndex := i;
Browse(s, []);
StatusBar1.Panels[0].Text := 'Fetching '+URI.Path+'...';
Update;
IdFTP1.List(nil);
if (FAborted) then
Abort;
ListViewFiles.Items.BeginUpdate;
try
for i := 0 to IdFTP1.DirectoryListing.Count -1 do
with ListViewFiles.Items.Add do
begin
if (FAborted) then
break;
Caption := IdFTP1.DirectoryListing[i].FileName;
SubItems.Add(DateTimeToStr(IdFTP1.DirectoryListing[i].ModifiedDate));
SubItems.Add(SizeToStr(IdFTP1.DirectoryListing[i].Size));
Data := pointer(IdFTP1.DirectoryListing[i].ItemType);
ImageIndex := -1;
case IdFTP1.DirectoryListing[i].ItemType of
ditFile:
if (SHGetFileInfo(PChar(Caption), FILE_ATTRIBUTE_NORMAL, SHFileInfo, SizeOf(TSHFileInfo), SHGFI_USEFILEATTRIBUTES or SHGFI_SYSICONINDEX) <> 0) then
ImageIndex := SHFileInfo.iIcon;
ditDirectory:
if (SHGetFileInfo(PChar(FTempPath), FILE_ATTRIBUTE_DIRECTORY or FILE_ATTRIBUTE_NORMAL, SHFileInfo, SizeOf(TSHFileInfo), SHGFI_USEFILEATTRIBUTES or SHGFI_SYSICONINDEX) <> 0) then
ImageIndex := SHFileInfo.iIcon;
end;
end;
finally
ListViewFiles.Items.EndUpdate;
// Force recalc of auto size
ListViewFiles.Width := ListViewFiles.Width+1;
end;
if (FAborted) then
Abort;
except
IdFTP1.Disconnect;
raise;
end;
finally
URI.Free;
end;
finally
StatusBar1.Panels[0].Text := '';
Screen.Cursor := crDefault;
EndBusy;
end;
end;
procedure TFormMain.ListViewFilesDblClick(Sender: TObject);
begin
if (ListViewFiles.Selected <> nil) then
begin
if (TIdDirItemType(ListViewFiles.Selected.Data) = ditDirectory) then
Browse(AddTrailingSlash(ComboAddress.Text)+ListViewFiles.Selected.Caption);
end;
end;
procedure TFormMain.Timer1Timer(Sender: TObject);
begin
UpdateActions;
end;
procedure TFormMain.IdFTP1Work(Sender: TObject; AWorkMode: TWorkMode;
AWorkCount: TIndyWorkCountInt);
begin
Application.ProcessMessages;
if (FAbort) or ((FWriteStream <> nil) and (FWriteStream.Aborted)) then
begin
try
StatusBar1.Panels[0].Text := 'Aborting...';
Update;
if (TransferInProgress) then
IdFTP1.Abort;
if (FWriteStream <> nil) then
FWriteStream.Abort;
finally
FAbort := False;
FAborted := True;
end;
end else
if (ProgressBar1.Visible) then
begin
ProgressBar1.Position := AWorkCount;
if (FCurrentFileSize > 1024*1024) then
StatusBar1.Panels[0].Text := Format('Reading %.0n Kb of %.0n Kb', [Int(AWorkCount div 1024), Int(integer(FCurrentFileSize div 1024))])
else
StatusBar1.Panels[0].Text := Format('Reading %.0n of %.0n bytes', [Int(AWorkCount), Int(integer(FCurrentFileSize))]);
Update;
UpdateActions;
end;
end;
procedure TFormMain.IdFTP1WorkBegin(Sender: TObject; AWorkMode: TWorkMode;
AWorkCountMax: TIndyWorkCountInt);
begin
BeginTransfer;
UpdateActions;
Update;
end;
procedure TFormMain.IdFTP1WorkEnd(Sender: TObject; AWorkMode: TWorkMode);
begin
EndTransfer;
end;
function TFormMain.GetBusy: boolean;
begin
Result := (FBusyCount > 0) or TransferInProgress;
end;
procedure TFormMain.BeginBusy;
begin
inc(FBusyCount);
if (FBusyCount = 1) then
AnimateThrobber.Active := True;
end;
procedure TFormMain.EndBusy;
begin
dec(FBusyCount);
if (FBusyCount = 0) then
AnimateThrobber.Active := False;
end;
procedure TFormMain.BeginTransfer;
begin
inc(FTransferCount);
if (FTransferCount = 1) then
BeginBusy;
end;
procedure TFormMain.EndTransfer;
begin
dec(FTransferCount);
if (FTransferCount = 0) then
EndBusy;
end;
function TFormMain.GetTransferInProgress: boolean;
begin
Result := (FTransferCount > 0);
end;
end.
| 28.985765 | 195 | 0.708287 |
fc2b0b0c02bd15f543869bc862f3b4ceab062501 | 4,751 | lpr | Pascal | svndecoratedump.lpr | skalogryz/svntools | 2c5ec0796a8f5d4ebb5ead2df6b4bb997752c5ac | [
"MIT"
]
| 3 | 2020-04-13T17:48:08.000Z | 2022-02-16T07:54:52.000Z | svndecoratedump.lpr | skalogryz/svntools | 2c5ec0796a8f5d4ebb5ead2df6b4bb997752c5ac | [
"MIT"
]
| null | null | null | svndecoratedump.lpr | skalogryz/svntools | 2c5ec0796a8f5d4ebb5ead2df6b4bb997752c5ac | [
"MIT"
]
| 2 | 2020-04-13T17:48:15.000Z | 2021-03-21T13:31:06.000Z | program svndecoratedump;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}
cthreads,
{$ENDIF}
Classes, SysUtils, svndumptools
{ you can add units after this };
type
TFileInfo = class(TObject)
fileName : string;
revision : Integer;
end;
type
{ TDecorationTask }
TDecorationTask = class(TObject)
public
remove : TList;
dumpLog: Boolean;
procedure AddToRemove(const fn: string; rev: integer);
procedure AddToRemove(const fn: string);
function CanWriteNode(rev: integer; nodeInfo: TNodeInfo): Boolean;
constructor Create;
destructor Destroy; override;
end;
TInputOut = record
inputFile : string;
outFile : string;
end;
procedure ReadRewrite(const srcFn, dstFn: string; dt: TDecorationTask);
var
rdr : TSVNDumpRead;
fs : TFileStream;
dst : TFileStream;
wr : TSVNDumpWrite;
p : Int64;
r : Int64;
err : Integer;
begin
fs := TFileStream.Create(srcFn, fmOpenRead or fmShareDenyNone);
dst := TFileStream.Create(dstFn, fmCreate);
rdr := TSVNDumpRead.Create(fs);
wr := TSVNDumpWrite.Create(dst);
r:=0;
try
if not rdr.Next then Exit;
wr.WriteHeader(rdr.version, rdr.uuid);
repeat
if rdr.found = dsRevision then begin
Val(rdr.revNum, r, err);
if dt.dumpLog then writeln(rdr.revNum);
wr.WriteRevision(rdr.revNum, rdr.revProp);
end else begin
if not dt.CanWriteNode(r, rdr.nodeInfo) then Continue;
if dt.dumpLog then writeln(' ',rdr.nodeInfo.path);
p:=fs.Position;
wr.WriteNode(
rdr.nodeInfo
,rdr.propOfs, rdr.propLen, fs
,rdr.txtCntOfs, rdr.txtCntLen, fs
);
fs.Position:=p;
end;
until not rdr.Next;
finally
rdr.Free;
fs.Free;
dst.Free;
wr.Free;
end;
end;
{ TDecorationTask }
procedure TDecorationTask.AddToRemove(const fn: string; rev: integer);
var
f : TFileInfo;
begin
f := TFileInfo.Create;
f.fileName := fn;
f.revision := rev;
remove.Add(f);
end;
procedure TDecorationTask.AddToRemove(const fn: string);
var
i : integer;
f : string;
rev : integer;
err : integer;
begin
f:=fn;
i:=Pos('@', f);
rev :=-1;
if i>0 then begin
Val( Trim(Copy(f, i+1, length(f))), rev, err);
if err<>0 then rev:=-1;
f:=Copy(f, 1, i-1);
end else
rev:=1;
AddToRemove(f, rev);
end;
function TDecorationTask.CanWriteNode(rev: integer; nodeInfo: TNodeInfo): Boolean;
var
i : integer;
fi : TFileInfo;
begin
for i:=0 to remove.Count-1 do begin
fi := TFileInfo(remove[i]);
if (nodeInfo.path = fi.fileName) and ((fi.revision<0) or (fi.revision = rev))
then begin
Result := false;
Exit;
end;
end;
Result := true;
end;
constructor TDecorationTask.Create;
begin
inherited Create;
dumpLog:=true;
remove:=Tlist.Create;
end;
destructor TDecorationTask.Destroy;
var
i : integer;
begin
for i:=0 to remove.Count-1 do
TobjecT(remove[i]).Free;
remove.Free;
inherited Destroy;
end;
procedure ParseParams(var inout: TInputOut; dt: TDecorationTask);
var
i : integer;
s : string;
ls : string;
begin
i:=1;
while i<=ParamCount do begin
s := ParamStr(i);
ls := AnsiLowerCase(s);
if ls = '-r' then begin
inc(i);
if i<=ParamCount then
dt.AddToRemove(ParamStr(i));
end else if ((ls = '-q') or (ls = '--quite')) then begin
dt.dumpLog := false;
end else if ((ls = '-o') or (ls = '--out')) then begin
inc(i);
if i<=ParamCount then
inout.outFile := ParamStr(i);
end else
inout.inputFile := s;
inc(i);
end;
if (inout.outFile = '') and (inout.inputFile<>'') then
inout.outFile := inout.inputFile+'.rewrite';
end;
procedure DumpHelp;
begin
writeln('-r filename[@revsion] = remove the file, followed by revision number. If revision number is omitted All entries of the file is exlcuded');
writeln('-q - quite mode, no output');
writeln('-o - the name of the output file path');
end;
var
inout: TInputOut;
dt : TDecorationTask;
begin
try
if ParamCount=0 then begin
writeln('please specify dump file');
DumpHelp;
Exit;
end;
inout.inputFile:='';
inout.outFile := '';
dt := TDecorationTask.Create;
try
ParseParams(inout, dt);
ReadRewrite(inout.inputFile, inout.outFile, dt);
finally
dt.Free;
end;
except
on e: exception do begin
writeln(stderr, 'error: ');
writeln(stderr, e.message);
ExitCode :=1;
end;
end
end.
| 21.894009 | 150 | 0.598611 |
85a333fbaa8ffa6dacb9a25e273d50b5b3f4a70a | 40,484 | pas | Pascal | hedgewars/uStore.pas | RobWatlingSF/hedgewars | 74f633d76bf95674f68f6872472bd21825f1f8c0 | [
"Apache-2.0"
]
| null | null | null | hedgewars/uStore.pas | RobWatlingSF/hedgewars | 74f633d76bf95674f68f6872472bd21825f1f8c0 | [
"Apache-2.0"
]
| null | null | null | hedgewars/uStore.pas | RobWatlingSF/hedgewars | 74f633d76bf95674f68f6872472bd21825f1f8c0 | [
"Apache-2.0"
]
| null | null | null | (*
* Hedgewars, a free turn based strategy game
* Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com>
*
* This program 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; version 2 of the License
*
* 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. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*)
{$INCLUDE "options.inc"}
{$IF GLunit = GL}{$DEFINE GLunit:=GL,GLext}{$ENDIF}
unit uStore;
interface
uses SysUtils, uConsts, SDLh, GLunit, uTypes, uLandTexture, uCaptions, uChat;
procedure initModule;
procedure freeModule;
procedure StoreLoad(reload: boolean);
procedure StoreRelease(reload: boolean);
procedure RenderHealth(var Hedgehog: THedgehog);
function makeHealthBarTexture(w, h, Color: Longword): PTexture;
procedure AddProgress;
procedure FinishProgress;
function LoadImage(const filename: shortstring; imageFlags: LongInt): PSDL_Surface;
// loads an image from the games data files
function LoadDataImage(const path: TPathType; const filename: shortstring; imageFlags: LongInt): PSDL_Surface;
// like LoadDataImage but uses altPath as fallback-path if file not found/loadable in path
function LoadDataImageAltPath(const path, altPath: TPathType; const filename: shortstring; imageFlags: LongInt): PSDL_Surface;
// like LoadDataImage but uses altFile as fallback-filename if file cannot be loaded
function LoadDataImageAltFile(const path: TPathType; const filename, altFile: shortstring; imageFlags: LongInt): PSDL_Surface;
procedure LoadHedgehogHat(var HH: THedgehog; newHat: shortstring);
procedure LoadHedgehogHat2(var HH: THedgehog; newHat: shortstring; allowSurfReuse: boolean);
procedure InitZoom(zoom: real);
procedure SetupOpenGL;
function RenderHelpWindow(caption, subcaption, description, extra: ansistring; extracolor: LongInt; iconsurf: PSDL_Surface; iconrect: PSDL_Rect): PTexture;
procedure RenderWeaponTooltip(atype: TAmmoType);
procedure ShowWeaponTooltip(x, y: LongInt);
procedure MakeCrossHairs;
{$IFDEF USE_VIDEO_RECORDING}
procedure InitOffscreenOpenGL;
{$ENDIF}
{$IFDEF SDL2}
procedure WarpMouse(x, y: Word); inline;
{$ENDIF}
procedure SwapBuffers; {$IFDEF USE_VIDEO_RECORDING}cdecl{$ELSE}inline{$ENDIF};
procedure SetSkyColor(r, g, b: real);
implementation
uses uMisc, uConsole, uVariables, uUtils, uTextures, uRender, uRenderUtils,
uCommands, uPhysFSLayer, uDebug
{$IFDEF USE_CONTEXT_RESTORE}, uWorld{$ENDIF}
{$IF NOT DEFINED(SDL2) AND DEFINED(USE_VIDEO_RECORDING)}, glut {$ENDIF};
var
{$IFDEF SDL2}
SDLwindow: PSDL_Window;
SDLGLcontext: PSDL_GLContext;
{$ELSE}
SDLPrimSurface: PSDL_Surface;
{$ENDIF}
squaresize : LongInt;
numsquares : LongInt;
ProgrTex: PTexture;
prevHat: shortstring;
tmpHatSurf: PSDL_Surface;
const
cHHFileName = 'Hedgehog';
cCHFileName = 'Crosshair';
procedure freeTmpHatSurf();
begin
if tmpHatSurf = nil then exit;
SDL_FreeSurface(tmpHatSurf);
tmpHatSurf:= nil;
prevHat:= 'NoHat';
end;
procedure InitZoom(zoom: real);
begin
SetScale(zoom);
// make sure view limits are updated
// because SetScale() doesn't do it, if zoom=cScaleFactor
updateViewLimits();
end;
function WriteInRect(Surface: PSDL_Surface; X, Y: LongInt; Color: LongWord; Font: THWFont; s: PChar): TSDL_Rect;
var w, h: LongInt;
tmpsurf: PSDL_Surface;
clr: TSDL_Color;
finalRect: TSDL_Rect;
begin
w:= 0; h:= 0; // avoid compiler hints
TTF_SizeUTF8(Fontz[Font].Handle, s, @w, @h);
finalRect.x:= X + cFontBorder + 2;
finalRect.y:= Y + cFontBorder;
finalRect.w:= w + cFontBorder * 2 + 4;
finalRect.h:= h + cFontBorder * 2;
clr.r:= Color shr 16;
clr.g:= (Color shr 8) and $FF;
clr.b:= Color and $FF;
tmpsurf:= TTF_RenderUTF8_Blended(Fontz[Font].Handle, s, clr);
SDLTry(tmpsurf <> nil, true);
tmpsurf:= doSurfaceConversion(tmpsurf);
SDLTry(tmpsurf <> nil, true);
SDL_UpperBlit(tmpsurf, nil, Surface, @finalRect);
SDL_FreeSurface(tmpsurf);
finalRect.x:= X;
finalRect.y:= Y;
finalRect.w:= w + cFontBorder * 2 + 4;
finalRect.h:= h + cFontBorder * 2;
WriteInRect:= finalRect
end;
procedure MakeCrossHairs;
var tmpsurf: PSDL_Surface;
begin
tmpsurf:= LoadDataImage(ptGraphics, cCHFileName, ifAlpha or ifCritical);
CrosshairTexture:= Surface2Tex(tmpsurf, false);
SDL_FreeSurface(tmpsurf)
end;
function makeHealthBarTexture(w, h, Color: Longword): PTexture;
var
rr: TSDL_Rect;
texsurf: PSDL_Surface;
begin
rr.x:= 0;
rr.y:= 0;
rr.w:= w;
rr.h:= h;
texsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32, RMask, GMask, BMask, AMask);
TryDo(texsurf <> nil, errmsgCreateSurface, true);
TryDo(SDL_SetColorKey(texsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true);
DrawRoundRect(@rr, cWhiteColor, cNearBlackColor, texsurf, true);
rr.x:= 2;
rr.y:= 2;
rr.w:= w - 4;
rr.h:= h - 4;
DrawRoundRect(@rr, Color, Color, texsurf, false);
makeHealthBarTexture:= Surface2Tex(texsurf, false);
SDL_FreeSurface(texsurf);
end;
procedure WriteNames(Font: THWFont);
var t: LongInt;
i, maxLevel: LongInt;
r: TSDL_Rect;
drY: LongInt;
texsurf, flagsurf, iconsurf: PSDL_Surface;
foundBot: boolean;
year, month, md : word;
begin
if cOnlyStats then exit;
r.x:= 0;
r.y:= 0;
drY:= - 4;
{$IFNDEF PAS2C}
DecodeDate(Date, year, month, md);
{$ELSE}
year:= 0;
month:= 0;
md:= 0;
{$ENDIF}
for t:= 0 to Pred(TeamsCount) do
with TeamsArray[t]^ do
begin
NameTagTex:= RenderStringTexLim(ansistring(TeamName), Clan^.Color, Font, cTeamHealthWidth);
if length(Owner) > 0 then
OwnerTex:= RenderStringTexLim(ansistring(Owner), Clan^.Color, Font, cTeamHealthWidth);
r.x:= 0;
r.y:= 0;
r.w:= 32;
r.h:= 32;
texsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, r.w, r.h, 32, RMask, GMask, BMask, AMask);
TryDo(texsurf <> nil, errmsgCreateSurface, true);
TryDo(SDL_SetColorKey(texsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true);
r.w:= 26;
r.h:= 19;
DrawRoundRect(@r, cWhiteColor, cNearBlackColor, texsurf, true);
// overwrite flag for cpu teams and keep players from using it
foundBot:= false;
maxLevel:= -1;
for i:= 0 to cMaxHHIndex do
with Hedgehogs[i] do
if (Gear <> nil) and (BotLevel > 0) then
begin
foundBot:= true;
// initially was going to do the highest botlevel of the team, but for now, just apply if entire team has same bot level
if maxLevel = -1 then maxLevel:= BotLevel
else if (maxLevel > 0) and (maxLevel <> BotLevel) then maxLevel:= 0;
//if (maxLevel > 0) and (BotLevel < maxLevel) then maxLevel:= BotLevel
end
else if Gear <> nil then maxLevel:= 0;
if foundBot then
begin
// disabled the plain flag - I think it looks ok even w/ full bars obscuring CPU
//if (maxLevel > 0) and (maxLevel < 3) then Flag:= 'cpu_plain' else
Flag:= 'cpu'
end
else if (Flag = 'cpu') or (Flag = 'cpu_plain') then
Flag:= 'hedgewars';
flagsurf:= LoadDataImageAltFile(ptFlags, Flag, 'hedgewars', ifNone);
TryDo(flagsurf <> nil, 'Failed to load flag "' + Flag + '" as well as the default flag', true);
case maxLevel of
1: copyToXY(SpritesData[sprBotlevels].Surface, flagsurf, 0, 0);
2: copyToXYFromRect(SpritesData[sprBotlevels].Surface, flagsurf, 5, 2, 17, 13, 5, 2);
3: copyToXYFromRect(SpritesData[sprBotlevels].Surface, flagsurf, 9, 5, 13, 10, 9, 5);
4: copyToXYFromRect(SpritesData[sprBotlevels].Surface, flagsurf, 13, 9, 9, 6, 13, 9);
5: copyToXYFromRect(SpritesData[sprBotlevels].Surface, flagsurf, 17, 11, 5, 4, 17, 11)
end;
copyToXY(flagsurf, texsurf, 2, 2);
SDL_FreeSurface(flagsurf);
flagsurf:= nil;
// restore black border pixels inside the flag
PLongwordArray(texsurf^.pixels)^[32 * 2 + 2]:= cNearBlackColor;
PLongwordArray(texsurf^.pixels)^[32 * 2 + 23]:= cNearBlackColor;
PLongwordArray(texsurf^.pixels)^[32 * 16 + 2]:= cNearBlackColor;
PLongwordArray(texsurf^.pixels)^[32 * 16 + 23]:= cNearBlackColor;
FlagTex:= Surface2Tex(texsurf, false);
SDL_FreeSurface(texsurf);
texsurf:= nil;
AIKillsTex := RenderStringTex(ansistring(inttostr(stats.AIKills)), Clan^.Color, fnt16);
dec(drY, r.h + 2);
DrawHealthY:= drY;
for i:= 0 to cMaxHHIndex do
with Hedgehogs[i] do
if Gear <> nil then
begin
NameTagTex:= RenderStringTexLim(ansistring(Name), Clan^.Color, fnt16, cTeamHealthWidth);
if Hat = 'NoHat' then
begin
if (month = 4) and (md = 20) then
Hat := 'eastertop' // Easter
else if (month = 12) and ((md = 24) or (md = 25) or (md = 26)) then
Hat := 'Santa' // Christmas Eve/Christmas/Boxing Day
else if (month = 10) and (md = 31) then
Hat := 'fr_pumpkin'; // Halloween/Hedgewars' birthday
end;
if (month = 4) and (md = 1) then
begin
AprilOne:= true;
Hat := 'fr_tomato'; // avoid promoting violence to hedgehogs. see http://hedgewars.org/node/5818
end;
if Hat <> 'NoHat' then
begin
if (Length(Hat) > 39) and (Copy(Hat,1,8) = 'Reserved') and (Copy(Hat,9,32) = PlayerHash) then
LoadHedgehogHat2(Hedgehogs[i], 'Reserved/' + Copy(Hat,9,Length(Hat)-8), true)
else
LoadHedgehogHat2(Hedgehogs[i], Hat, true);
end
end;
end;
freeTmpHatSurf();
MissionIcons:= LoadDataImage(ptGraphics, 'missions', ifCritical);
iconsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, 28, 28, 32, RMask, GMask, BMask, AMask);
if iconsurf <> nil then
begin
r.x:= 0;
r.y:= 0;
r.w:= 28;
r.h:= 28;
DrawRoundRect(@r, cWhiteColor, cNearBlackColor, iconsurf, true);
ropeIconTex:= Surface2Tex(iconsurf, false);
SDL_FreeSurface(iconsurf);
iconsurf:= nil;
end;
for t:= 0 to Pred(ClansCount) do
with ClansArray[t]^ do
HealthTex:= makeHealthBarTexture(cTeamHealthWidth + 5, Teams[0]^.NameTagTex^.h, Color);
GenericHealthTexture:= makeHealthBarTexture(cTeamHealthWidth + 5, TeamsArray[0]^.NameTagTex^.h, cWhiteColor)
end;
procedure InitHealth;
var i, t: LongInt;
begin
for t:= 0 to Pred(TeamsCount) do
if TeamsArray[t] <> nil then
with TeamsArray[t]^ do
begin
for i:= 0 to cMaxHHIndex do
if Hedgehogs[i].Gear <> nil then
RenderHealth(Hedgehogs[i]);
end
end;
procedure LoadGraves;
var t: LongInt;
texsurf: PSDL_Surface;
begin
for t:= 0 to Pred(TeamsCount) do
if TeamsArray[t] <> nil then
with TeamsArray[t]^ do
begin
if GraveName = '' then
GraveName:= 'Statue';
texsurf:= LoadDataImageAltFile(ptGraves, GraveName, 'Statue', ifCritical or ifTransparent);
GraveTex:= Surface2Tex(texsurf, false);
SDL_FreeSurface(texsurf)
end
end;
procedure StoreLoad(reload: boolean);
var s: shortstring;
ii: TSprite;
fi: THWFont;
ai: TAmmoType;
tmpsurf: PSDL_Surface;
i, imflags: LongInt;
begin
AddFileLog('StoreLoad()');
if (not reload) and (not cOnlyStats) then
for fi:= Low(THWFont) to High(THWFont) do
with Fontz[fi] do
begin
s:= cPathz[ptFonts] + '/' + Name;
WriteToConsole(msgLoading + s + ' (' + inttostr(Height) + 'pt)... ');
Handle:= TTF_OpenFontRW(rwopsOpenRead(s), true, Height);
SDLTry(Handle <> nil, true);
TTF_SetFontStyle(Handle, style);
WriteLnToConsole(msgOK)
end;
if not cOnlyStats then
begin
MakeCrossHairs;
LoadGraves;
tmpHatSurf:= LoadDataImage(ptHats, 'Reserved/chef', ifNone);
ChefHatTexture:= Surface2Tex(tmpHatSurf, true);
freeTmpHatSurf();
end;
if not reload then
AddProgress;
for ii:= Low(TSprite) to High(TSprite) do
with SpritesData[ii] do
// FIXME - add a sprite attribute to match on rq flags?
if (((cReducedQuality and (rqNoBackground or rqLowRes)) = 0) or // why rqLowRes?
(not (ii in [sprSky, sprSkyL, sprSkyR, sprHorizont, sprHorizontL, sprHorizontR])))
and (((cReducedQuality and rqPlainSplash) = 0) or ((not (ii in [sprSplash, sprDroplet, sprSDSplash, sprSDDroplet]))))
and (((cReducedQuality and rqKillFlakes) = 0) or cSnow or ((not (ii in [sprFlake, sprSDFlake]))))
and ((cCloudsNumber > 0) or (ii <> sprCloud))
and ((vobCount > 0) or (ii <> sprFlake))
and (savesurf or (not cOnlyStats)) // in stats-only only load those which are needed later
then
begin
if reload then
tmpsurf:= Surface
else
begin
imflags := (ifAlpha or ifTransparent);
// these sprites are optional
if not (ii in [sprHorizont, sprHorizontL, sprHorizontR, sprSky, sprSkyL, sprSkyR, sprChunk]) then // FIXME: hack
imflags := (imflags or ifCritical);
// load the image
tmpsurf := LoadDataImageAltPath(Path, AltPath, FileName, imflags)
end;
if tmpsurf <> nil then
begin
if getImageDimensions then
begin
imageWidth:= tmpsurf^.w;
imageHeight:= tmpsurf^.h
end;
if getDimensions then
begin
Width:= tmpsurf^.w;
Height:= tmpsurf^.h
end;
if (ii in [sprSky, sprSkyL, sprSkyR, sprHorizont, sprHorizontL, sprHorizontR]) then
begin
Texture:= Surface2Tex(tmpsurf, true);
Texture^.Scale:= 2
end
else
begin
Texture:= Surface2Tex(tmpsurf, false);
// HACK: We should include some sprite attribute to define the texture wrap directions
if ((ii = sprWater) or (ii = sprSDWater)) and ((cReducedQuality and (rq2DWater or rqClampLess)) = 0) then
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
end;
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_PRIORITY, priority);
// This should maybe be flagged. It wastes quite a bit of memory.
if not reload then
begin
{$IFDEF USE_CONTEXT_RESTORE}
Surface:= tmpsurf
{$ELSE}
if saveSurf then
Surface:= tmpsurf
else
SDL_FreeSurface(tmpsurf)
{$ENDIF}
end
end
else
Surface:= nil
end;
if not cOnlyStats then
begin
WriteNames(fnt16);
if not reload then
AddProgress;
tmpsurf:= LoadDataImage(ptGraphics, cHHFileName, ifAlpha or ifCritical or ifTransparent);
HHTexture:= Surface2Tex(tmpsurf, false);
SDL_FreeSurface(tmpsurf);
InitHealth;
PauseTexture:= RenderStringTex(trmsg[sidPaused], cYellowColor, fntBig);
AFKTexture:= RenderStringTex(trmsg[sidAFK], cYellowColor, fntBig);
ConfirmTexture:= RenderStringTex(trmsg[sidConfirm], cYellowColor, fntBig);
SyncTexture:= RenderStringTex(trmsg[sidSync], cYellowColor, fntBig);
if not reload then
AddProgress;
// name of weapons in ammo menu
for ai:= Low(TAmmoType) to High(TAmmoType) do
with Ammoz[ai] do
begin
TryDo(length(trAmmo[NameId]) > 0,'No default text/translation found for ammo type #' + intToStr(ord(ai)) + '!',true);
tmpsurf:= TTF_RenderUTF8_Blended(Fontz[CheckCJKFont(trAmmo[NameId],fnt16)].Handle, PChar(trAmmo[NameId]), cWhiteColorChannels);
TryDo(tmpsurf <> nil,'Name-texture creation for ammo type #' + intToStr(ord(ai)) + ' failed!',true);
tmpsurf:= doSurfaceConversion(tmpsurf);
FreeAndNilTexture(NameTex);
NameTex:= Surface2Tex(tmpsurf, false);
SDL_FreeSurface(tmpsurf)
end;
// number of weapons in ammo menu
for i:= Low(CountTexz) to High(CountTexz) do
begin
tmpsurf:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(IntToStr(i) + 'x'), cWhiteColorChannels);
tmpsurf:= doSurfaceConversion(tmpsurf);
FreeAndNilTexture(CountTexz[i]);
CountTexz[i]:= Surface2Tex(tmpsurf, false);
SDL_FreeSurface(tmpsurf)
end;
if not reload then
AddProgress;
end;
IMG_Quit();
end;
procedure StoreRelease(reload: boolean);
var ii: TSprite;
ai: TAmmoType;
i, t: LongInt;
begin
for ii:= Low(TSprite) to High(TSprite) do
begin
FreeAndNilTexture(SpritesData[ii].Texture);
if (SpritesData[ii].Surface <> nil) and (not reload) then
begin
SDL_FreeSurface(SpritesData[ii].Surface);
SpritesData[ii].Surface:= nil
end
end;
SDL_FreeSurface(MissionIcons);
// free the textures declared in uVariables
FreeAndNilTexture(ChefHatTexture);
FreeAndNilTexture(CrosshairTexture);
FreeAndNilTexture(WeaponTooltipTex);
FreeAndNilTexture(PauseTexture);
FreeAndNilTexture(AFKTexture);
FreeAndNilTexture(SyncTexture);
FreeAndNilTexture(ConfirmTexture);
FreeAndNilTexture(ropeIconTex);
FreeAndNilTexture(HHTexture);
FreeAndNilTexture(GenericHealthTexture);
// free all ammo name textures
for ai:= Low(TAmmoType) to High(TAmmoType) do
FreeAndNilTexture(Ammoz[ai].NameTex);
// free all count textures
for i:= Low(CountTexz) to High(CountTexz) do
begin
FreeAndNilTexture(CountTexz[i]);
CountTexz[i]:= nil
end;
for t:= 0 to Pred(ClansCount) do
begin
if ClansArray[t] <> nil then
FreeAndNilTexture(ClansArray[t]^.HealthTex);
end;
// free all team and hedgehog textures
for t:= 0 to Pred(TeamsCount) do
begin
if TeamsArray[t] <> nil then
begin
FreeAndNilTexture(TeamsArray[t]^.NameTagTex);
FreeAndNilTexture(TeamsArray[t]^.GraveTex);
FreeAndNilTexture(TeamsArray[t]^.AIKillsTex);
FreeAndNilTexture(TeamsArray[t]^.FlagTex);
for i:= 0 to cMaxHHIndex do
begin
FreeAndNilTexture(TeamsArray[t]^.Hedgehogs[i].NameTagTex);
FreeAndNilTexture(TeamsArray[t]^.Hedgehogs[i].HealthTagTex);
FreeAndNilTexture(TeamsArray[t]^.Hedgehogs[i].HatTex);
end;
end;
end;
RendererCleanup();
end;
procedure RenderHealth(var Hedgehog: THedgehog);
var s: shortstring;
begin
str(Hedgehog.Gear^.Health, s);
FreeAndNilTexture(Hedgehog.HealthTagTex);
Hedgehog.HealthTagTex:= RenderStringTex(ansistring(s), Hedgehog.Team^.Clan^.Color, fnt16)
end;
function LoadImage(const filename: shortstring; imageFlags: LongInt): PSDL_Surface;
var tmpsurf: PSDL_Surface;
s: shortstring;
rwops: PSDL_RWops;
begin
LoadImage:= nil;
WriteToConsole(msgLoading + filename + '.png [flags: ' + inttostr(imageFlags) + '] ');
s:= filename + '.png';
rwops:= nil;
tmpsurf:= nil;
if pfsExists(s) then
begin
// get data source
rwops:= rwopsOpenRead(s);
// load image with SDL (with freesrc param set to true)
if rwops <> nil then
tmpsurf:= IMG_Load_RW(rwops, true);
end;
// loading failed
if tmpsurf = nil then
begin
// output sdl error if loading failed when data source was available
if rwops <> nil then
begin
// anounce that loading failed
OutError(msgFailed, false);
SDLTry(false, (imageFlags and ifCritical) <> 0);
// rwops was already freed by IMG_Load_RW
rwops:= nil;
end else
OutError(msgFailed, (imageFlags and ifCritical) <> 0);
exit;
end;
if ((imageFlags and ifIgnoreCaps) = 0) and ((tmpsurf^.w > MaxTextureSize) or (tmpsurf^.h > MaxTextureSize)) then
begin
SDL_FreeSurface(tmpsurf);
OutError(msgFailedSize, ((not cOnlyStats) and ((imageFlags and ifCritical) <> 0)));
// dummy surface to replace non-critical textures that failed to load due to their size
LoadImage:= SDL_CreateRGBSurface(SDL_SWSURFACE, 2, 2, 32, RMask, GMask, BMask, AMask);
exit;
end;
tmpsurf:= doSurfaceConversion(tmpsurf);
if (imageFlags and ifTransparent) <> 0 then
TryDo(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true);
WriteLnToConsole(msgOK + ' (' + inttostr(tmpsurf^.w) + 'x' + inttostr(tmpsurf^.h) + ')');
LoadImage:= tmpsurf //Result
end;
function LoadDataImage(const path: TPathType; const filename: shortstring; imageFlags: LongInt): PSDL_Surface;
var tmpsurf: PSDL_Surface;
begin
// check for file in user dir (never critical)
tmpsurf:= LoadImage(cPathz[path] + '/' + filename, imageFlags);
LoadDataImage:= tmpsurf;
end;
function LoadDataImageAltPath(const path, altPath: TPathType; const filename: shortstring; imageFlags: LongInt): PSDL_Surface;
var tmpsurf: PSDL_Surface;
begin
// if there is no alternative path, just forward and return result
if (altPath = ptNone) then
exit(LoadDataImage(path, filename, imageFlags));
// since we have a fallback path this search isn't critical yet
tmpsurf:= LoadDataImage(path, filename, imageFlags and (not ifCritical));
// if image still not found try alternative path
if (tmpsurf = nil) then
tmpsurf:= LoadDataImage(altPath, filename, imageFlags);
LoadDataImageAltPath:= tmpsurf;
end;
function LoadDataImageAltFile(const path: TPathType; const filename, altFile: shortstring; imageFlags: LongInt): PSDL_Surface;
var tmpsurf: PSDL_Surface;
begin
// if there is no alternative filename, just forward and return result
if (altFile = '') then
exit(LoadDataImage(path, filename, imageFlags));
// since we have a fallback filename this search isn't critical yet
tmpsurf:= LoadDataImage(path, filename, imageFlags and (not ifCritical));
// if image still not found try alternative filename
if (tmpsurf = nil) then
tmpsurf:= LoadDataImage(path, altFile, imageFlags);
LoadDataImageAltFile:= tmpsurf;
end;
procedure LoadHedgehogHat(var HH: THedgehog; newHat: shortstring);
begin
LoadHedgehogHat2(HH, newHat, false);
end;
procedure LoadHedgehogHat2(var HH: THedgehog; newHat: shortstring; allowSurfReuse: boolean);
begin
// free the mem of any previously assigned texture. This was previously only if the new one could be loaded, but, NoHat is usually a better choice
if HH.HatTex <> nil then
FreeAndNilTexture(HH.HatTex);
// load new hat surface if this hat is different than the one already loaded
if newHat <> prevHat then
begin
freeTmpHatSurf();
tmpHatSurf:= LoadDataImage(ptHats, newHat, ifNone);
end;
AddFileLog('Hat => '+newHat);
// only do something if the hat could be loaded
if tmpHatSurf <> nil then
begin
AddFileLog('Got Hat');
// assign new hat to hedgehog
HH.HatTex:= Surface2Tex(tmpHatSurf, true);
// remember that this hat was used last
if allowSurfReuse then
prevHat:= newHat
// cleanup: free temporary surface mem
else
freeTmpHatSurf();
end;
end;
procedure SetupOpenGLAttributes;
begin
{$IFDEF IPHONEOS}
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 0);
SDL_GL_SetAttribute(SDL_GL_RETAINED_BACKING, 1);
{$ELSE}
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
{$ENDIF}
{$IFNDEF SDL2} // vsync is default in SDL2
SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, LongInt((cReducedQuality and rqDesyncVBlank) = 0));
{$ENDIF}
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 6);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0); // no depth buffer
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 0); // no alpha channel
SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 16); // buffer should be 16
SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1); // prefer hw rendering
end;
procedure SetupOpenGL;
var buf: array[byte] of char;
begin
{$IFDEF SDL2}
AddFileLog('Setting up OpenGL (using driver: ' + shortstring(SDL_GetCurrentVideoDriver()) + ')');
{$ELSE}
buf[0]:= char(0); // avoid compiler hint
AddFileLog('Setting up OpenGL (using driver: ' + shortstring(SDL_VideoDriverName(buf, sizeof(buf))) + ')');
{$ENDIF}
RendererSetup();
end;
(*
procedure UpdateProjection;
var
s: GLfloat;
begin
s:=cScaleFactor;
mProjection[0,0]:= s/cScreenWidth; mProjection[0,1]:= 0.0; mProjection[0,2]:=0.0; mProjection[0,3]:= 0.0;
mProjection[1,0]:= 0.0; mProjection[1,1]:= -s/cScreenHeight; mProjection[1,2]:=0.0; mProjection[1,3]:= 0.0;
mProjection[2,0]:= 0.0; mProjection[2,1]:= 0.0; mProjection[2,2]:=1.0; mProjection[2,3]:= 0.0;
mProjection[3,0]:= cStereoDepth; mProjection[3,1]:= s/2; mProjection[3,2]:=0.0; mProjection[3,3]:= 1.0;
{$IFDEF GL2}
UpdateModelviewProjection;
{$ELSE}
glMatrixMode(GL_PROJECTION);
glLoadMatrixf(@mProjection[0, 0]);
glMatrixMode(GL_MODELVIEW);
{$ENDIF}
end;
*)
////////////////////////////////////////////////////////////////////////////////
procedure AddProgress;
var r: TSDL_Rect;
texsurf: PSDL_Surface;
begin
if cOnlyStats then exit;
if Step = 0 then
begin
WriteToConsole(msgLoading + 'progress sprite: ');
texsurf:= LoadDataImage(ptGraphics, 'Progress', ifCritical or ifTransparent);
ProgrTex:= Surface2Tex(texsurf, false);
squaresize:= texsurf^.w shr 1;
numsquares:= texsurf^.h div squaresize;
SDL_FreeSurface(texsurf);
{$IFNDEF PAS2C}
with mobileRecord do
if GameLoading <> nil then
GameLoading();
{$ENDIF}
end;
TryDo(ProgrTex <> nil, 'Error - Progress Texure is nil!', true);
RenderClear();
if Step < numsquares then
r.x:= 0
else
r.x:= squaresize;
r.y:= (Step mod numsquares) * squaresize;
r.w:= squaresize;
r.h:= squaresize;
DrawTextureFromRect( -squaresize div 2, (cScreenHeight - squaresize) shr 1, @r, ProgrTex);
SwapBuffers;
inc(Step);
end;
procedure FinishProgress;
begin
{$IFNDEF PAS2C}
with mobileRecord do
if GameLoaded <> nil then
GameLoaded();
{$ENDIF}
WriteLnToConsole('Freeing progress surface... ');
FreeAndNilTexture(ProgrTex);
Step:= 0
end;
function RenderHelpWindow(caption, subcaption, description, extra: ansistring; extracolor: LongInt; iconsurf: PSDL_Surface; iconrect: PSDL_Rect): PTexture;
var tmpsurf: PSDL_SURFACE;
w, h, i, j: LongInt;
font: THWFont;
r, r2: TSDL_Rect;
wa, ha: LongInt;
tmpline, tmpline2, tmpdesc: ansistring;
begin
// make sure there is a caption as well as a sub caption - description is optional
if length(caption) = 0 then
caption:= ansistring('???');
if length(subcaption) = 0 then
subcaption:= ansistring(_S' ');
font:= CheckCJKFont(caption,fnt16);
font:= CheckCJKFont(subcaption,font);
font:= CheckCJKFont(description,font);
font:= CheckCJKFont(extra,font);
w:= 0;
h:= 0;
wa:= cFontBorder * 2 + 4;
ha:= cFontBorder * 2;
i:= 0; j:= 0; // avoid compiler hints
// TODO: Recheck height/position calculation
// get caption's dimensions
TTF_SizeUTF8(Fontz[font].Handle, PChar(caption), @i, @j);
// width adds 36 px (image + space)
w:= i + 36 + wa;
h:= j + ha;
// get sub caption's dimensions
TTF_SizeUTF8(Fontz[font].Handle, PChar(subcaption), @i, @j);
// width adds 36 px (image + space)
if w < (i + 36 + wa) then
w:= i + 36 + wa;
inc(h, j + ha);
// get description's dimensions
tmpdesc:= description;
while length(tmpdesc) > 0 do
begin
tmpline:= tmpdesc;
SplitByCharA(tmpline, tmpdesc, '|');
if length(tmpline) > 0 then
begin
TTF_SizeUTF8(Fontz[font].Handle, PChar(tmpline), @i, @j);
if w < (i + wa) then
w:= i + wa;
inc(h, j + ha)
end
end;
if length(extra) > 0 then
begin
// get extra label's dimensions
TTF_SizeUTF8(Fontz[font].Handle, PChar(extra), @i, @j);
if w < (i + wa) then
w:= i + wa;
inc(h, j + ha);
end;
// add borders space
inc(w, wa);
inc(h, ha + 8);
tmpsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32, RMask, GMask, BMask, AMask);
TryDo(tmpsurf <> nil, 'RenderHelpWindow: fail to create surface', true);
// render border and background
r.x:= 0;
r.y:= 0;
r.w:= w;
r.h:= h;
DrawRoundRect(@r, cWhiteColor, cNearBlackColor, tmpsurf, true);
// render caption
r:= WriteInRect(tmpsurf, 36 + cFontBorder + 2, ha, $ffffffff, font, PChar(caption));
// render sub caption
r:= WriteInRect(tmpsurf, 36 + cFontBorder + 2, r.y + r.h, $ffc7c7c7, font, PChar(subcaption));
// render all description lines
tmpdesc:= description;
while length(tmpdesc) > 0 do
begin
tmpline:= tmpdesc;
SplitByCharA(tmpline, tmpdesc, '|');
r2:= r;
if length(tmpline) > 0 then
begin
r:= WriteInRect(tmpsurf, cFontBorder + 2, r.y + r.h, $ff707070, font, PChar(tmpline));
// render highlighted caption (if there is a ':')
tmpline2:= _S'';
SplitByCharA(tmpline, tmpline2, ':');
if length(tmpline2) > 0 then
begin
tmpline:= tmpline + ':';
WriteInRect(tmpsurf, cFontBorder + 2, r2.y + r2.h, $ffc7c7c7, font, PChar(tmpline));
end;
end
end;
if length(extra) > 0 then
r:= WriteInRect(tmpsurf, cFontBorder + 2, r.y + r.h, extracolor, font, PChar(extra));
r.x:= cFontBorder + 6;
r.y:= cFontBorder + 4;
r.w:= 32;
r.h:= 32;
SDL_FillRect(tmpsurf, @r, $ffffffff);
SDL_UpperBlit(iconsurf, iconrect, tmpsurf, @r);
RenderHelpWindow:= Surface2Tex(tmpsurf, true);
SDL_FreeSurface(tmpsurf)
end;
procedure RenderWeaponTooltip(atype: TAmmoType);
var r: TSDL_Rect;
i: LongInt;
extra: ansistring;
extracolor: LongInt;
begin
// don't do anything if the window shouldn't be shown
if (cReducedQuality and rqTooltipsOff) <> 0 then
begin
WeaponTooltipTex:= nil;
exit
end;
// free old texture
FreeAndNilTexture(WeaponTooltipTex);
// image region
i:= LongInt(atype) - 1;
r.x:= (i shr 4) * 32;
r.y:= (i mod 16) * 32;
r.w:= 32;
r.h:= 32;
// default (no extra text)
extra:= _S'';
extracolor:= 0;
if (CurrentTeam <> nil) and (Ammoz[atype].SkipTurns >= CurrentTeam^.Clan^.TurnNumber) then // weapon or utility is not yet available
begin
extra:= trmsg[sidNotYetAvailable];
extracolor:= LongInt($ffc77070);
end
else if (Ammoz[atype].Ammo.Propz and ammoprop_NoRoundEnd) <> 0 then // weapon or utility will not end your turn
begin
extra:= trmsg[sidNoEndTurn];
extracolor:= LongInt($ff70c770);
end
else
begin
extra:= _S'';
extracolor:= 0;
end;
// render window and return the texture
WeaponTooltipTex:= RenderHelpWindow(trammo[Ammoz[atype].NameId], trammoc[Ammoz[atype].NameId], trammod[Ammoz[atype].NameId], extra, extracolor, SpritesData[sprAMAmmos].Surface, @r)
end;
procedure ShowWeaponTooltip(x, y: LongInt);
begin
// draw the texture if it exists
if WeaponTooltipTex <> nil then
DrawTexture(x, y, WeaponTooltipTex)
end;
{$IFDEF USE_VIDEO_RECORDING}
{$IFDEF SDL2}
procedure InitOffscreenOpenGL;
begin
// create hidden window
SDLwindow:= SDL_CreateWindow('hedgewars video rendering (SDL2 hidden window)',
SDL_WINDOWPOS_CENTERED_MASK, SDL_WINDOWPOS_CENTERED_MASK,
cScreenWidth, cScreenHeight,
SDL_WINDOW_HIDDEN or SDL_WINDOW_OPENGL);
SDLTry(SDLwindow <> nil, true);
SetupOpenGL();
end;
{$ELSE}
procedure InitOffscreenOpenGL;
var ArgCount: LongInt;
PrgName: pchar;
begin
ArgCount:= 1;
PrgName:= 'hwengine';
glutInit(@ArgCount, @PrgName);
glutInitWindowSize(cScreenWidth, cScreenHeight);
// we do not need a window, but without this call OpenGL will not initialize
glutCreateWindow('hedgewars video rendering (glut hidden window)');
glutHideWindow();
// we do not need to set this callback, but it is required for GLUT3 compat
glutDisplayFunc(@SwapBuffers);
RendererSetup();
end;
{$ENDIF} // SDL2
{$ENDIF} // USE_VIDEO_RECORDING
procedure chFullScr(var s: shortstring);
var flags: Longword = 0;
reinit: boolean = false;
{$IFNDEF DARWIN}ico: PSDL_Surface;{$ENDIF}
{$IFDEF SDL2}x, y: LongInt;{$ENDIF}
begin
if cOnlyStats then
begin
MaxTextureSize:= 1024;
exit
end;
if Length(s) = 0 then
cFullScreen:= (not cFullScreen)
else cFullScreen:= s = '1';
if cFullScreen then
begin
cScreenWidth:= cFullscreenWidth;
cScreenHeight:= cFullscreenHeight;
end
else
begin
cScreenWidth:= cWindowedWidth;
cScreenHeight:= cWindowedHeight;
end;
AddFileLog('Preparing to change video parameters...');
{$IFDEF SDL2}
if SDLwindow = nil then
{$ELSE}
if SDLPrimSurface = nil then
{$ENDIF}
begin
// set window title
{$IFNDEF SDL2}
SDL_WM_SetCaption(_P'Hedgewars', nil);
{$ENDIF}
WriteToConsole('Init SDL_image... ');
SDLTry(IMG_Init(IMG_INIT_PNG) <> 0, true);
WriteLnToConsole(msgOK);
// load engine icon
{$IFNDEF DARWIN}
ico:= LoadDataImage(ptGraphics, 'hwengine', ifIgnoreCaps);
if ico <> nil then
begin
SDL_WM_SetIcon(ico, 0);
SDL_FreeSurface(ico)
end;
{$ENDIF}
end
else
begin
AmmoMenuInvalidated:= true;
{$IFDEF IPHONEOS}
// chFullScr is called when there is a rotation event and needs the SetScale and SetupOpenGL to set up the new resolution
// this 6 gl functions are the relevant ones and are hacked together here for optimisation
glMatrixMode(GL_MODELVIEW);
glPopMatrix;
glLoadIdentity();
glScalef(2.0 / cScreenWidth, -2.0 / cScreenHeight, 1.0);
glTranslatef(0, -cScreenHeight / 2, 0);
glViewport(0, 0, cScreenWidth, cScreenHeight);
exit;
{$ELSE}
SetScale(cDefaultZoomLevel);
{$IFDEF USE_CONTEXT_RESTORE}
reinit:= true;
StoreRelease(true);
ResetLand;
ResetWorldTex;
//uTextures.freeModule; //DEBUG ONLY
{$ENDIF}
AddFileLog('Freeing old primary surface...');
{$IFNDEF SDL2}
SDL_FreeSurface(SDLPrimSurface);
SDLPrimSurface:= nil;
{$ENDIF}
{$ENDIF}
end;
// these attributes must be set up before creating the sdl window
{$IFNDEF WIN32}
(* On a large number of testers machines, SDL default to software rendering
when opengl attributes were set. These attributes were "set" after
CreateWindow in .15, which probably did nothing.
IMO we should rely on the gl_config defaults from SDL, and use
SDL_GL_GetAttribute to possibly post warnings if any bad values are set.
*)
SetupOpenGLAttributes();
{$ENDIF}
{$IFDEF SDL2}
// these values in x and y make the window appear in the center
x:= SDL_WINDOWPOS_CENTERED_MASK;
y:= SDL_WINDOWPOS_CENTERED_MASK;
// SDL_WINDOW_RESIZABLE makes the window resizable and
// respond to rotation events on mobile devices
flags:= SDL_WINDOW_OPENGL or SDL_WINDOW_SHOWN or SDL_WINDOW_RESIZABLE;
{$IFDEF MOBILE}
if isPhone() then
SDL_SetHint('SDL_IOS_ORIENTATIONS','LandscapeLeft LandscapeRight');
// no need for borders on mobile devices
flags:= flags or SDL_WINDOW_BORDERLESS;
{$ENDIF}
if cFullScreen then
flags:= flags or SDL_WINDOW_FULLSCREEN;
if SDLwindow = nil then
SDLwindow:= SDL_CreateWindow('Hedgewars', x, y, cScreenWidth, cScreenHeight, flags);
SDLTry(SDLwindow <> nil, true);
{$ELSE}
flags:= SDL_OPENGL or SDL_RESIZABLE;
if cFullScreen then
flags:= flags or SDL_FULLSCREEN;
if not cOnlyStats then
begin
{$IFDEF WIN32}
s:= SDL_getenv('SDL_VIDEO_CENTERED');
SDL_putenv('SDL_VIDEO_CENTERED=1');
{$ENDIF}
SDLPrimSurface:= SDL_SetVideoMode(cScreenWidth, cScreenHeight, 0, flags);
SDLTry(SDLPrimSurface <> nil, true);
{$IFDEF WIN32}
SDL_putenv(str2pchar('SDL_VIDEO_CENTERED=' + s));
{$ENDIF}
end;
{$ENDIF}
SetupOpenGL();
if reinit then
begin
// clean the window from any previous content
RenderClear();
if SuddenDeathDmg then
SetSkyColor(SDSkyColor.r * (SDTint/255) / 255, SDSkyColor.g * (SDTint/255) / 255, SDSkyColor.b * (SDTint/255) / 255)
else if ((cReducedQuality and rqNoBackground) = 0) then
SetSkyColor(SkyColor.r / 255, SkyColor.g / 255, SkyColor.b / 255)
else
SetSkyColor(RQSkyColor.r / 255, RQSkyColor.g / 255, RQSkyColor.b / 255);
// reload everything we had before
ReloadCaptions(false);
ReloadLines;
StoreLoad(true);
// redraw all land
UpdateLandTexture(0, LAND_WIDTH, 0, LAND_HEIGHT, false);
end;
end;
{$IFDEF SDL2}
// for sdl1.2 we directly call SDL_WarpMouse()
// for sdl2 we provide a SDL_WarpMouse() which just calls this function
// this has the advantage of reducing 'uses' and 'ifdef' statements
// (SDLwindow is a private member of this module)
procedure WarpMouse(x, y: Word); inline;
begin
SDL_WarpMouseInWindow(SDLwindow, x, y);
end;
{$ENDIF}
procedure SwapBuffers; {$IFDEF USE_VIDEO_RECORDING}cdecl{$ELSE}inline{$ENDIF};
begin
if GameType = gmtRecord then
exit;
{$IFDEF SDL2}
SDL_GL_SwapWindow(SDLwindow);
{$ELSE}
SDL_GL_SwapBuffers();
{$ENDIF}
end;
procedure SetSkyColor(r, g, b: real);
begin
RenderSetClearColor(r, g, b, 0.99)
end;
procedure initModule;
var ai: TAmmoType;
i: LongInt;
begin
RegisterVariable('fullscr', @chFullScr, true);
cScaleFactor:= 2.0;
updateViewLimits();
Step:= 0;
ProgrTex:= nil;
SupportNPOTT:= false;
// init all ammo name texture pointers
for ai:= Low(TAmmoType) to High(TAmmoType) do
begin
Ammoz[ai].NameTex := nil;
end;
// init all count texture pointers
for i:= Low(CountTexz) to High(CountTexz) do
CountTexz[i] := nil;
{$IFDEF SDL2}
SDLwindow:= nil;
SDLGLcontext:= nil;
{$ELSE}
SDLPrimSurface:= nil;
{$ENDIF}
prevHat:= 'NoHat';
tmpHatSurf:= nil;
end;
procedure freeModule;
var fi: THWFont;
begin
StoreRelease(false);
// make sure fonts are cleaned up
for fi:= Low(THWFont) to High(THWFont) do
with Fontz[fi] do
begin
if Handle <> nil then
begin
TTF_CloseFont(Handle);
Handle:= nil;
end;
end;
TTF_Quit();
{$IFDEF SDL2}
SDL_GL_DeleteContext(SDLGLcontext);
SDL_DestroyWindow(SDLwindow);
{$ENDIF}
SDL_Quit();
end;
end.
| 32.05384 | 180 | 0.634769 |
479cef76577216f84a3a9d78ac453c7dbccefd09 | 402 | lpr | Pascal | basic/basic.lpr | neurolabusc/Metal-Demos | 5ddd15005f7eb9a48620cf74ebd929dc11f83c73 | [
"BSD-2-Clause"
]
| 26 | 2018-08-23T01:47:13.000Z | 2021-08-19T19:51:42.000Z | basic/basic.lpr | neurolabusc/Metal-Demos | 5ddd15005f7eb9a48620cf74ebd929dc11f83c73 | [
"BSD-2-Clause"
]
| 1 | 2020-03-24T04:28:32.000Z | 2020-03-24T12:10:04.000Z | basic/basic.lpr | neurolabusc/Metal-Demos | 5ddd15005f7eb9a48620cf74ebd929dc11f83c73 | [
"BSD-2-Clause"
]
| 2 | 2020-03-19T20:56:10.000Z | 2021-05-21T07:50:47.000Z | program basic;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, lazopenglcontext, Unit1
{ you can add units after this };
{$R *.res}
begin
RequireDerivedFormResource:=True;
Application.Scaled:=True;
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
| 17.478261 | 48 | 0.711443 |
85190b920060323e28f4be174d17a32ae73567b9 | 223 | pas | Pascal | src/utils/uCommEvents.pas | bidtime/dms-import | 60b97df623d7ec9c96ce5aa853339b92e35a991c | [
"Apache-2.0"
]
| null | null | null | src/utils/uCommEvents.pas | bidtime/dms-import | 60b97df623d7ec9c96ce5aa853339b92e35a991c | [
"Apache-2.0"
]
| null | null | null | src/utils/uCommEvents.pas | bidtime/dms-import | 60b97df623d7ec9c96ce5aa853339b92e35a991c | [
"Apache-2.0"
]
| 1 | 2020-06-09T12:55:41.000Z | 2020-06-09T12:55:41.000Z | unit uCommEvents;
interface
uses
Windows, Classes, DB;
type
TRowNextEvent = procedure(TDataSet: TObject; const batch: boolean; strs: TStrings) of object;
{private
protected
public
end;}
implementation
end.
| 12.388889 | 95 | 0.735426 |
fc24d1ed3c2f496ed568e893eb4349778704e34e | 127 | pas | Pascal | Pascal/Area of a Circle.pas | WeDias/LembreSempre | 0043e4a94bcd029fd89261103e9d4535814a1ca7 | [
"MIT"
]
| 1 | 2020-04-27T01:46:12.000Z | 2020-04-27T01:46:12.000Z | Pascal/Area of a Circle.pas | WeDias/Remember-me | 0043e4a94bcd029fd89261103e9d4535814a1ca7 | [
"MIT"
]
| null | null | null | Pascal/Area of a Circle.pas | WeDias/Remember-me | 0043e4a94bcd029fd89261103e9d4535814a1ca7 | [
"MIT"
]
| null | null | null | Program Area_of_a_Circle;
const
PI = 3.14159;
var
n1: real;
Begin
read(n1);
writeln('A=', (PI * n1 * n1):0:4);
End. | 14.111111 | 36 | 0.590551 |
fc1f5104c789d65f88ad34d448f7bede7beefab6 | 2,224 | pas | Pascal | Demos/Demo.DDuce.ValueList.pas | atkins126/dduce | c52b44344524a180ba4c88cfe3c66e72d9066d4c | [
"Apache-2.0"
]
| null | null | null | Demos/Demo.DDuce.ValueList.pas | atkins126/dduce | c52b44344524a180ba4c88cfe3c66e72d9066d4c | [
"Apache-2.0"
]
| null | null | null | Demos/Demo.DDuce.ValueList.pas | atkins126/dduce | c52b44344524a180ba4c88cfe3c66e72d9066d4c | [
"Apache-2.0"
]
| null | null | null | {
Copyright (C) 2013-2021 Tim Sinaeve tim.sinaeve@gmail.com
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
}
unit Demo.DDuce.ValueList;
interface
{ Form demonstrating the TValueList component. }
uses
Winapi.Windows, Winapi.Messages,
System.SysUtils, System.Variants, System.Classes, System.TypInfo,
Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls,
zObjInspector,
DDuce.DynamicRecord, DDuce.Components.ValueList;
type
TfrmValueListDemo = class(TForm)
{$REGION 'designer controls'}
pnlLeft : TPanel;
pnlRight : TPanel;
splVertical : TSplitter;
{$ENDREGION}
private
FValueList : TValueList;
FObjectInspector : TzObjectInspector;
public
procedure AfterConstruction; override;
end;
implementation
{$R *.dfm}
uses
DDuce.Logger, DDuce.Logger.Channels.WinIPC, DDuce.Factories.zObjInspector;
{$REGION 'construction and destruction'}
procedure TfrmValueListDemo.AfterConstruction;
var
LDR : IDynamicRecord;
begin
inherited AfterConstruction;
FValueList := TValueList.Create(Self);
FValueList.Parent := pnlRight;
FValueList.Align := alClient;
FValueList.ShowHeader := False;
FValueList.ShowHint := True;
FValueList.MultiSelect := True;
FValueList.AlignWithMargins := True;
FValueList.BorderStyle := bsNone;
LDR := DynamicRecord.Create(Self.Font);
Logger.SendObject(Self.Font);
FValueList.Data := LDR;
Logger.SendText(LDR.ToString);
Logger.SendText(FValueList.Data.ToString);
FObjectInspector := TzObjectInspectorFactory.Create(
Self,
pnlLeft,
FValueList
);
FObjectInspector.ObjectVisibility := mvPublished;
end;
{$ENDREGION}
end.
| 26.164706 | 76 | 0.723471 |
4703f3eae5786e605372b0e24e67fafe7cd756a3 | 10,005 | pas | Pascal | Lib/Classes/Common/ZXing.MultiFormatReader.pas | igorbastosib/ZXing.Delphi | c113597d06f493f3715b30e54317af61e7b558c0 | [
"Apache-2.0"
]
| 384 | 2015-05-30T16:32:43.000Z | 2022-03-23T12:07:48.000Z | Lib/Classes/Common/ZXing.MultiFormatReader.pas | kattunga/ZXing.Delphi | 28d32866d4d0871c97bc84130e976366a892586e | [
"Apache-2.0"
]
| 119 | 2015-06-08T14:49:22.000Z | 2022-03-31T16:25:18.000Z | Lib/Classes/Common/ZXing.MultiFormatReader.pas | kattunga/ZXing.Delphi | 28d32866d4d0871c97bc84130e976366a892586e | [
"Apache-2.0"
]
| 182 | 2015-06-01T01:05:29.000Z | 2022-02-22T07:08:05.000Z | {
* Copyright 2007 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Original Authors: Sean Owen and dswitkin@google.com (Daniel Switkin)
* Ported from ZXING Java Source: www.Redivivus.in (suraj.supekar@redivivus.in)
* Delphi Implementation by E. Spelt and K. Gossens
}
unit ZXing.MultiFormatReader;
interface
uses
System.SysUtils,
System.Rtti,
System.Generics.Collections,
System.RegularExpressions,
ZXing.ReadResult,
ZXing.Reader,
ZXing.DecodeHintType,
ZXing.BinaryBitmap,
ZXing.BarcodeFormat,
ZXing.ResultPoint,
// 1D Barcodes
ZXing.OneD.OneDReader,
ZXing.OneD.Code128Reader,
ZXing.OneD.Code93Reader,
ZXing.OneD.ITFReader,
ZXing.OneD.EAN13Reader,
ZXing.OneD.EAN8Reader,
ZXing.OneD.UPCAReader,
ZXing.OneD.UPCEReader,
ZXing.OneD.Code39Reader,
// 2D Codes
ZXing.QrCode.QRCodeReader,
ZXing.Datamatrix.DataMatrixReader;
/// <summary>
/// MultiFormatReader is a convenience class and the main entry point into the library for most uses.
/// By default it attempts to decode all barcode formats that the library supports. Optionally, you
/// can provide a hints object to request different behavior, for example only decoding QR codes.
/// </summary>
/// <author>Sean Owen</author>
/// <author>dswitkin@google.com (Daniel Switkin)</author>
/// <author>www.Redivivus.in (suraj.supekar@redivivus.in) - Ported from ZXING Java Source</author>
type
TMultiFormatReader = class(TInterfacedObject, IReader)
private
FHints: TDictionary<TDecodeHintType, TObject>;
readers: TList<IReader>;
function DecodeInternal(image: TBinaryBitmap): TReadResult;
procedure Set_Hints(const Value: TDictionary<TDecodeHintType, TObject>);
function Get_Hints: TDictionary<TDecodeHintType, TObject>;
/// <summary> This version of decode honors the intent of Reader.decode(BinaryBitmap) in that it
/// passes null as a hint to the decoders. However, that makes it inefficient to call repeatedly.
/// Use setHints() followed by decodeWithState() for continuous scan applications.
///
/// </summary>
/// <param name="image">The pixel data to decode
/// </param>
/// <returns> The contents of the image
/// </returns>
/// <throws> ReaderException Any errors which occurred </throws>
public
function decode(const image: TBinaryBitmap): TReadResult; overload;
function decode(const image: TBinaryBitmap; WithHints: Boolean)
: TReadResult; overload;
/// <summary> Decode an image using the hints provided. Does not honor existing state.
///
/// </summary>
/// <param name="image">The pixel data to decode
/// </param>
/// <param name="hints">The hints to use, clearing the previous state.
/// </param>
/// <returns> The contents of the image
/// </returns>
/// <throws> ReaderException Any errors which occurred </throws>
function decode(const image: TBinaryBitmap;
hints: TDictionary<TDecodeHintType, TObject>): TReadResult; overload;
/// <summary> Decode an image using the state set up by calling setHints() previously. Continuous scan
/// clients will get a <b>large</b> speed increase by using this instead of decode().
///
/// </summary>
/// <param name="image">The pixel data to decode
/// </param>
/// <returns> The contents of the image
/// </returns>
/// <throws> ReaderException Any errors which occurred </throws>
function DecodeWithState(image: TBinaryBitmap): TReadResult;
destructor Destroy; override;
/// <summary> This method adds state to the MultiFormatReader. By setting the hints once, subsequent calls
/// to decodeWithState(image) can reuse the same set of readers without reallocating memory. This
/// is important for performance in continuous scan clients.
///
/// </summary>
/// <param name="hints">The set of hints to use for subsequent calls to decode(image)
/// </param>
property hints: TDictionary<TDecodeHintType, TObject> read Get_Hints
write Set_Hints;
procedure Reset;
procedure FreeReaders();
end;
implementation
function TMultiFormatReader.decode(const image: TBinaryBitmap): TReadResult;
begin
hints := nil;
result := DecodeInternal(image)
end;
function TMultiFormatReader.decode(const image: TBinaryBitmap;
WithHints: Boolean): TReadResult;
begin
result := DecodeInternal(image)
end;
function TMultiFormatReader.decode(const image: TBinaryBitmap;
hints: TDictionary<TDecodeHintType, TObject>): TReadResult;
begin
FHints := hints;
result := DecodeInternal(image)
end;
function TMultiFormatReader.DecodeWithState(image: TBinaryBitmap): TReadResult;
begin
// Make sure to set up the default state so we don't crash
if readers = nil then
begin
hints := nil
end;
result := DecodeInternal(image);
end;
destructor TMultiFormatReader.Destroy;
begin
FreeReaders;
inherited;
end;
procedure TMultiFormatReader.FreeReaders;
begin
if readers <> nil then
readers.Clear();
readers.Free;
readers := nil;
end;
function TMultiFormatReader.Get_Hints: TDictionary<TDecodeHintType, TObject>;
begin
result := FHints;
end;
procedure TMultiFormatReader.Set_Hints(const Value: TDictionary<TDecodeHintType,
TObject>);
var
tryHarder, useCode39CheckDigit, useCode39ExtendedMode: Boolean;
formats: TList<TBarcodeFormat>;
begin
FHints := Value;
// tryHarder := (Value <> nil) and
// (Value.ContainsKey(ZXing.DecodeHintType.TRY_HARDER));
if ((Value = nil) or
(not Value.ContainsKey(ZXing.DecodeHintType.POSSIBLE_FORMATS))) then
begin
formats := nil;
end
else
begin
formats := Value[ZXing.DecodeHintType.POSSIBLE_FORMATS]
as TList<TBarcodeFormat>
end;
// add readers from the hints
readers := TList<IReader>.Create;
if formats <> nil then
begin
// 1D readers
if (formats.Contains(TBarcodeFormat.CODE_128)) then
begin
readers.Add(TCode128Reader.Create())
end;
if (formats.Contains(TBarcodeFormat.CODE_93)) then
begin
readers.Add(TCode93Reader.Create())
end;
if (formats.Contains(TBarcodeFormat.ITF)) then
begin
readers.Add(TITFReader.Create())
end;
// 2D readers
if (formats.Contains(TBarcodeFormat.QR_CODE)) then
begin
readers.Add(TQRCodeReader.Create())
end;
if formats.Contains(TBarcodeFormat.DATA_MATRIX) then
readers.Add(TDataMatrixReader.Create);
if (formats.Contains(TBarcodeFormat.EAN_13)) then
readers.Add(TEAN13Reader.Create());
if (formats.Contains(TBarcodeFormat.EAN_8)) then
readers.Add(TEAN8Reader.Create());
if (formats.Contains(TBarcodeFormat.UPC_A)) then
readers.Add(TUPCAReader.Create());
if (formats.Contains(TBarcodeFormat.UPC_E)) then
readers.Add(TUPCEReader.Create());
if (formats.Contains(TBarcodeFormat.CODE_39)) then
begin
useCode39CheckDigit := hints.ContainsKey
(TDecodeHintType.ASSUME_CODE_39_CHECK_DIGIT) and
hints.ContainsKey(TDecodeHintType.ASSUME_CODE_39_CHECK_DIGIT);
useCode39ExtendedMode := hints.ContainsKey
(TDecodeHintType.USE_CODE_39_EXTENDED_MODE) and
hints.ContainsKey(TDecodeHintType.USE_CODE_39_EXTENDED_MODE);
readers.Add(TCode39Reader.Create(useCode39CheckDigit,
useCode39ExtendedMode));
end;
end;
if (readers.Count = 0) then // must be auto, add them all
begin
// 1D readers
readers.Add(TCode128Reader.Create());
readers.Add(TUPCAReader.Create());
readers.Add(TUPCEReader.Create());
readers.Add(TEAN13Reader.Create());
readers.Add(TEAN8Reader.Create());
readers.Add(TCode93Reader.Create());
readers.Add(TITFReader.Create());
useCode39CheckDigit := hints.ContainsKey
(TDecodeHintType.ASSUME_CODE_39_CHECK_DIGIT) and hints.ContainsKey
(TDecodeHintType.ASSUME_CODE_39_CHECK_DIGIT);
useCode39ExtendedMode := hints.ContainsKey
(TDecodeHintType.USE_CODE_39_EXTENDED_MODE) and hints.ContainsKey
(TDecodeHintType.USE_CODE_39_EXTENDED_MODE);
readers.Add(TCode39Reader.Create(useCode39CheckDigit,
useCode39ExtendedMode));
// 2D readers
readers.Add(TQRCodeReader.Create());
readers.Add(TDataMatrixReader.Create)
end;
end;
procedure TMultiFormatReader.Reset;
var
Reader: IReader;
begin
if readers <> nil then
begin
for Reader in readers do
begin
Reader.Reset();
end
end
end;
function TMultiFormatReader.DecodeInternal(image: TBinaryBitmap): TReadResult;
var
rpCallBack: TResultPointCallback;
i: integer;
Reader: IReader;
begin
result := nil;
if (readers = nil) then
begin
Exit;
end;
rpCallBack := nil;
if ((FHints <> nil) and
(FHints.ContainsKey(ZXing.DecodeHintType.NEED_RESULT_POINT_CALLBACK))) then
begin
// rpCallBack := FHints[DecodeHintType.NEED_RESULT_POINT_CALLBACK]
// as TResultPointCallback(nil);
end;
for i := 0 to readers.Count - 1 do
begin
Reader := readers[i];
Reader.Reset();
result := Reader.decode(image, FHints);
if result <> nil then
begin
// found a barcode, pushing the successful reader up front
// I assume that the same type of barcode is read multiple times
// so the reordering of the readers list should speed up the next reading
// a little bit
readers.Delete(i);
readers.Insert(0, Reader);
Exit;
end;
// if rpCallBack <> nil then
// rpCallBack(nil)
end;
end;
end.
| 28.504274 | 110 | 0.712244 |
83ceb529d554b1687c7db3c680812eb7bd1d6de8 | 343 | pas | Pascal | code/changements.pas | daweido/traverse-game-PASCAL | bea23ce3c76432367f787bf4db156afa0a98c949 | [
"MIT"
]
| null | null | null | code/changements.pas | daweido/traverse-game-PASCAL | bea23ce3c76432367f787bf4db156afa0a98c949 | [
"MIT"
]
| null | null | null | code/changements.pas | daweido/traverse-game-PASCAL | bea23ce3c76432367f787bf4db156afa0a98c949 | [
"MIT"
]
| null | null | null | unit changements;
Interface
uses highlights;
procedure changement(var plato : plateauDyn;i_d,i_a : integer);
Implementation
procedure changement(var plato : plateauDyn;i_d,i_a : integer);
begin
plato[i_a].p.identif := plato[i_d].p.identif;
plato[i_a].p.clr := plato[i_d].p.clr;
plato[i_d].p.identif := 0;
plato[i_d].p.clr := 0;
end;
end.
| 22.866667 | 63 | 0.725948 |
fc7ef1ee8a58747e5f6898e746de2d92c95a692f | 1,933 | pas | Pascal | Core/DW.FMX.Helpers.pas | barlone/Kastri | fb12d9eba242e67efd87eb1cb7acd123601a58ed | [
"MIT"
]
| 259 | 2020-05-27T03:15:19.000Z | 2022-03-24T16:35:02.000Z | Core/DW.FMX.Helpers.pas | barlone/Kastri | fb12d9eba242e67efd87eb1cb7acd123601a58ed | [
"MIT"
]
| 95 | 2020-06-16T09:46:06.000Z | 2022-03-28T00:27:07.000Z | Core/DW.FMX.Helpers.pas | barlone/Kastri | fb12d9eba242e67efd87eb1cb7acd123601a58ed | [
"MIT"
]
| 56 | 2020-06-04T19:32:40.000Z | 2022-03-26T15:32:47.000Z | unit DW.FMX.Helpers;
{*******************************************************}
{ }
{ Kastri }
{ }
{ Delphi Worlds Cross-Platform Library }
{ }
{ Copyright 2020-2021 Dave Nottage under MIT license }
{ which is located in the root folder of this library }
{ }
{*******************************************************}
interface
uses
// RTL
System.SysUtils, System.Messaging;
type
/// <summary>
/// Utility class for deferring execution of methods in FMX apps
/// </summary>
TIdleCaller = class(TObject)
public
/// <summary>
/// Calls the method AProc the next time an idle message is received
/// </summary>
/// <remarks>
/// Can be useful for delaying code that might prevent the debugger from being able to hook the app process if the method causes
/// a crash for example inside the OnCreate event handler of the main form.
/// Example: Move the suspicious code out of the OnCreate event handler into a method called DoSomethingThatMightCrash, and replace with:
/// TIdleCaller.CallOnNextIdle(DoSomethingThatMightCrash);
/// </remarks>
class procedure CallOnNextIdle(const AProc: TProc);
end;
implementation
uses
// FMX
FMX.Types;
{ TIdleCaller }
class procedure TIdleCaller.CallOnNextIdle(const AProc: TProc);
var
LListener: TMessageListener;
begin
LListener := procedure(const Sender: TObject; const M: TMessage)
begin
TMessageManager.DefaultManager.Unsubscribe(TIdleMessage, LListener);
AProc;
end;
TMessageManager.DefaultManager.SubscribeToMessage(TIdleMessage, LListener);
end;
end.
| 32.762712 | 144 | 0.546301 |
47f75d9e5fd01c044113ff64466f1e5174f4e7bc | 150,136 | pas | Pascal | source/ALIosWebRTCApi.pas | zekiguven/alcinoe | e55c5368ee8bfe7cd6d92424c29ab07d8a3e844c | [
"Apache-2.0"
]
| 1 | 2019-09-01T23:03:44.000Z | 2019-09-01T23:03:44.000Z | source/ALIosWebRTCApi.pas | zekiguven/alcinoe | e55c5368ee8bfe7cd6d92424c29ab07d8a3e844c | [
"Apache-2.0"
]
| null | null | null | source/ALIosWebRTCApi.pas | zekiguven/alcinoe | e55c5368ee8bfe7cd6d92424c29ab07d8a3e844c | [
"Apache-2.0"
]
| null | null | null | unit ALIosWebRTCApi;
interface
uses
Macapi.CoreFoundation,
Macapi.CoreServices,
Macapi.Dispatch,
Macapi.Mach,
Macapi.ObjCRuntime,
Macapi.ObjectiveC,
iOSapi.AVFoundation,
iOSapi.CocoaTypes,
iOSapi.CoreGraphics,
iOSapi.CoreVideo,
iOSapi.Foundation,
iOSapi.OpenGLES,
iOSapi.UIKit;
{$M+}
type
//Represents the signaling state of the peer connection.
//typedef NS_ENUM(NSInteger, RTCSignalingState)
RTCSignalingState = NSInteger;
const
RTCSignalingStateStable = 0;
RTCSignalingStateHaveLocalOffer = 1;
RTCSignalingStateHaveLocalPrAnswer = 2;
RTCSignalingStateHaveRemoteOffer = 3;
RTCSignalingStateHaveRemotePrAnswer = 4;
RTCSignalingStateClosed = 5;
type
//Represents the ice connection state of the peer connection.
//typedef NS_ENUM(NSInteger, RTCIceConnectionState)
RTCIceConnectionState = NSInteger;
const
RTCIceConnectionStateNew = 0;
RTCIceConnectionStateChecking = 1;
RTCIceConnectionStateConnected = 2;
RTCIceConnectionStateCompleted = 3;
RTCIceConnectionStateFailed = 4;
RTCIceConnectionStateDisconnected = 5;
RTCIceConnectionStateClosed = 6;
RTCIceConnectionStateCount = 7;
type
//Represents the ice gathering state of the peer connection.
//typedef NS_ENUM(NSInteger, RTCIceGatheringState)
RTCIceGatheringState = NSInteger;
const
RTCIceGatheringStateNew = 0;
RTCIceGatheringStateGathering = 1;
RTCIceGatheringStateComplete = 2;
type
//Represents the stats output level.
//typedef NS_ENUM(NSInteger, RTCStatsOutputLevel)
RTCStatsOutputLevel = NSInteger;
const
RTCStatsOutputLevelStandard = 0;
RTCStatsOutputLevelDebug = 1;
type
//typedef NS_ENUM(NSInteger, RTCSourceState)
RTCSourceState = NSInteger;
const
RTCSourceStateInitializing = 0;
RTCSourceStateLive = 1;
RTCSourceStateEnded = 2;
RTCSourceStateMuted = 3;
type
//Represents the state of the track. This exposes the same states in C++.
//typedef NS_ENUM(NSInteger, RTCMediaStreamTrackState)
RTCMediaStreamTrackState = NSInteger;
const
RTCMediaStreamTrackStateLive = 0;
RTCMediaStreamTrackStateEnded = 1;
type
//typedef NS_ENUM(NSInteger, RTCVideoRotation)
RTCVideoRotation = NSInteger;
const
RTCVideoRotation_0 = 0;
RTCVideoRotation_90 = 90;
RTCVideoRotation_180 = 180;
RTCVideoRotation_270 = 270;
type
//Subset of rtc::LoggingSeverity.
//typedef NS_ENUM(NSInteger, RTCLoggingSeverity)
RTCLoggingSeverity = NSInteger;
const
RTCLoggingSeverityVerbose = 0;
RTCLoggingSeverityInfo = 1;
RTCLoggingSeverityWarning = 2;
RTCLoggingSeverityError = 3;
RTCLoggingSeverityNone = 4;
type
//H264 Profiles and levels.
//NS_ENUM(NSUInteger, RTCH264Profile)
RTCH264Profile = NSUInteger;
const
RTCH264ProfileConstrainedBaseline = 0;
RTCH264ProfileBaseline = 1;
RTCH264ProfileMain = 2;
RTCH264ProfileConstrainedHigh = 3;
RTCH264ProfileHigh = 4;
type
//NS_ENUM(NSUInteger, RTCH264Level)
RTCH264Level = NSUInteger;
const
RTCH264Level1_b = 0;
RTCH264Level1 = 10;
RTCH264Level1_1 = 11;
RTCH264Level1_2 = 12;
RTCH264Level1_3 = 13;
RTCH264Level2 = 20;
RTCH264Level2_1 = 21;
RTCH264Level2_2 = 22;
RTCH264Level3 = 30;
RTCH264Level3_1 = 31;
RTCH264Level3_2 = 32;
RTCH264Level4 = 40;
RTCH264Level4_1 = 41;
RTCH264Level4_2 = 42;
RTCH264Level5 = 50;
RTCH264Level5_1 = 51;
RTCH264Level5_2 = 52;
type
//Represents the chosen SDP semantics for the RTCPeerConnection.
//NS_ENUM(NSInteger, RTCSdpSemantics)
RTCSdpSemantics = NSInteger;
const
RTCSdpSemanticsPlanB = 0;
RTCSdpSemanticsUnifiedPlan = 1;
type
//https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiverdirection
//NS_ENUM(NSInteger, RTCRtpTransceiverDirection)
RTCRtpTransceiverDirection = NSInteger;
const
RTCRtpTransceiverDirectionSendRecv = 0;
RTCRtpTransceiverDirectionSendOnly = 1;
RTCRtpTransceiverDirectionRecvOnly = 2;
RTCRtpTransceiverDirectionInactive = 3;
type
//Represents the media type of the RtpReceiver.
//NS_ENUM(NSInteger, RTCRtpMediaType)
RTCRtpMediaType = NSInteger;
const
RTCRtpMediaTypeAudio = 0;
RTCRtpMediaTypeVideo = 1;
RTCRtpMediaTypeData = 2;
type
//Represents the session description type. This exposes the same types that are
//in C++, which doesn't include the rollback type that is in the W3C spec.
//NS_ENUM(NSInteger, RTCSdpType)
RTCSdpType = NSInteger;
const
RTCSdpTypeOffer = 0;
RTCSdpTypePrAnswer = 1;
RTCSdpTypeAnswer = 2;
//const
//RTCH264PacketizationModeNonInterleaved = 0;
//RTCH264PacketizationModeSingleNalUnit = 1;
//RTCIceTransportPolicyNone = 0;
//RTCIceTransportPolicyRelay = 1;
//RTCIceTransportPolicyNoHost = 2;
//RTCIceTransportPolicyAll = 3;
//RTCBundlePolicyBalanced = 0;
//RTCBundlePolicyMaxCompat = 1;
//RTCBundlePolicyMaxBundle = 2;
//RTCRtcpMuxPolicyNegotiate = 0;
//RTCRtcpMuxPolicyRequire = 1;
//RTCTcpCandidatePolicyEnabled = 0;
//RTCTcpCandidatePolicyDisabled = 1;
//RTCCandidateNetworkPolicyAll = 0;
//RTCCandidateNetworkPolicyLowCost = 1;
//RTCContinualGatheringPolicyGatherOnce = 0;
//RTCContinualGatheringPolicyGatherContinually = 1;
//RTCEncryptionKeyTypeRSA = 0;
//RTCEncryptionKeyTypeECDSA = 1;
//RTCDataChannelStateConnecting = 0;
//RTCDataChannelStateOpen = 1;
//RTCDataChannelStateClosing = 2;
//RTCDataChannelStateClosed = 3;
//RTCFrameTypeEmptyFrame = 0;
//RTCFrameTypeAudioFrameSpeech = 1;
//RTCFrameTypeAudioFrameCN = 2;
//RTCFrameTypeVideoFrameKey = 3;
//RTCFrameTypeVideoFrameDelta = 4;
//RTCVideoContentTypeUnspecified = 0;
//RTCVideoContentTypeScreenshare = 1;
//RTCVideoCodecModeRealtimeVideo = 0;
//RTCVideoCodecModeScreensharing = 1;
//RTCDispatcherTypeMain = 0;
//RTCDispatcherTypeCaptureSession = 1;
//RTCDispatcherTypeAudioSession = 2;
//RTCFileLoggerSeverityVerbose = 0;
//RTCFileLoggerSeverityInfo = 1;
//RTCFileLoggerSeverityWarning = 2;
//RTCFileLoggerSeverityError = 3;
//RTCFileLoggerTypeCall = 0;
//RTCFileLoggerTypeApp = 1;
//RTCTlsCertPolicySecure = 0;
//RTCTlsCertPolicyInsecureNoCheck = 1;
//RTCDeviceTypeUnknown = 0;
//RTCDeviceTypeIPhone1G = 1;
//RTCDeviceTypeIPhone3G = 2;
//RTCDeviceTypeIPhone3GS = 3;
//RTCDeviceTypeIPhone4 = 4;
//RTCDeviceTypeIPhone4Verizon = 5;
//RTCDeviceTypeIPhone4S = 6;
//RTCDeviceTypeIPhone5GSM = 7;
//RTCDeviceTypeIPhone5GSM_CDMA = 8;
//RTCDeviceTypeIPhone5CGSM = 9;
//RTCDeviceTypeIPhone5CGSM_CDMA = 10;
//RTCDeviceTypeIPhone5SGSM = 11;
//RTCDeviceTypeIPhone5SGSM_CDMA = 12;
//RTCDeviceTypeIPhone6Plus = 13;
//RTCDeviceTypeIPhone6 = 14;
//RTCDeviceTypeIPhone6S = 15;
//RTCDeviceTypeIPhone6SPlus = 16;
//RTCDeviceTypeIPhone7 = 17;
//RTCDeviceTypeIPhone7Plus = 18;
//RTCDeviceTypeIPhoneSE = 19;
//RTCDeviceTypeIPhone8 = 20;
//RTCDeviceTypeIPhone8Plus = 21;
//RTCDeviceTypeIPhoneX = 22;
//RTCDeviceTypeIPhoneXS = 23;
//RTCDeviceTypeIPhoneXSMax = 24;
//RTCDeviceTypeIPhoneXR = 25;
//RTCDeviceTypeIPodTouch1G = 26;
//RTCDeviceTypeIPodTouch2G = 27;
//RTCDeviceTypeIPodTouch3G = 28;
//RTCDeviceTypeIPodTouch4G = 29;
//RTCDeviceTypeIPodTouch5G = 30;
//RTCDeviceTypeIPodTouch6G = 31;
//RTCDeviceTypeIPad = 32;
//RTCDeviceTypeIPad2Wifi = 33;
//RTCDeviceTypeIPad2GSM = 34;
//RTCDeviceTypeIPad2CDMA = 35;
//RTCDeviceTypeIPad2Wifi2 = 36;
//RTCDeviceTypeIPadMiniWifi = 37;
//RTCDeviceTypeIPadMiniGSM = 38;
//RTCDeviceTypeIPadMiniGSM_CDMA = 39;
//RTCDeviceTypeIPad3Wifi = 40;
//RTCDeviceTypeIPad3GSM_CDMA = 41;
//RTCDeviceTypeIPad3GSM = 42;
//RTCDeviceTypeIPad4Wifi = 43;
//RTCDeviceTypeIPad4GSM = 44;
//RTCDeviceTypeIPad4GSM_CDMA = 45;
//RTCDeviceTypeIPad5 = 46;
//RTCDeviceTypeIPad6 = 47;
//RTCDeviceTypeIPadAirWifi = 48;
//RTCDeviceTypeIPadAirCellular = 49;
//RTCDeviceTypeIPadAirWifiCellular = 50;
//RTCDeviceTypeIPadAir2 = 51;
//RTCDeviceTypeIPadMini2GWifi = 52;
//RTCDeviceTypeIPadMini2GCellular = 53;
//RTCDeviceTypeIPadMini2GWifiCellular = 54;
//RTCDeviceTypeIPadMini3 = 55;
//RTCDeviceTypeIPadMini4 = 56;
//RTCDeviceTypeIPadPro9Inch = 57;
//RTCDeviceTypeIPadPro12Inch = 58;
//RTCDeviceTypeIPadPro12Inch2 = 59;
//RTCDeviceTypeIPadPro10Inch = 60;
//RTCDeviceTypeSimulatori386 = 61;
//RTCDeviceTypeSimulatorx86_64 = 62;
type
RTCPeerConnection = interface;
RTCVideoSource = interface;
RTCVideoTrack = interface;
RTCCertificate = interface;
RTCSessionDescription = interface;
RTCRtpParameters = interface;
TWebRTCPeerConnectionOfferForConstraintsCompletionHandler = procedure(sdp: RTCSessionDescription; error: NSError) of object;
TWebRTCPeerConnectionAnswerForConstraintsCompletionHandler = procedure(sdp: RTCSessionDescription; error: NSError) of object;
TWebRTCPeerConnectionSetLocalDescriptionCompletionHandler = procedure(error: NSError) of object;
TWebRTCPeerConnectionSetRemoteDescriptionCompletionHandler = procedure(error: NSError) of object;
//NSInteger = Integer;
//PNSInteger = ^NSInteger;
//NSUInteger = Cardinal;
//PNSUInteger = ^NSUInteger;
//AVAudioSessionRouteChangeReason = NSUInteger;
//AVAudioSessionCategoryOptions = NSUInteger;
//NSTimeInterval = Double;
//PNSTimeInterval = ^NSTimeInterval;
//AVAudioSessionPortOverride = NSUInteger;
//TWebRTCCallback = procedure(param1: NSString) of object;
//CVBufferRef = Pointer;
//PCVBufferRef = ^CVBufferRef;
//CVImageBufferRef = CVBufferRef;
//PCVImageBufferRef = ^CVImageBufferRef;
//CVPixelBufferRef = CVImageBufferRef;
//PCVPixelBufferRef = ^CVPixelBufferRef;
//FourCharCode = UInt32;
//PFourCharCode = ^FourCharCode;
//TWebRTCCompletionHandler1 = procedure() of object;
//RTCH264PacketizationMode = NSUInteger;
//RTCIceTransportPolicy = NSInteger;
//RTCBundlePolicy = NSInteger;
//RTCRtcpMuxPolicy = NSInteger;
//RTCTcpCandidatePolicy = NSInteger;
//RTCCandidateNetworkPolicy = NSInteger;
//RTCContinualGatheringPolicy = NSInteger;
//RTCEncryptionKeyType = NSInteger;
//RTCDataChannelState = NSInteger;
//RTCFrameType = NSUInteger;
//RTCVideoContentType = NSUInteger;
//RTCVideoCodecMode = NSUInteger;
//RTCVideoDecoderCallback = procedure(param1: RTCVideoFrame) of object;
//RTCVideoEncoderCallback = function(param1: RTCEncodedImage; param2: Pointer; param3: RTCRtpFragmentationHeader): Boolean; cdecl;
//RTCDispatcherQueueType = NSInteger;
//CGFloat = Single;
//PCGFloat = ^CGFloat;
//CGSize = record
//width: CGFloat;
//height: CGFloat;
//end;
//PCGSize = ^CGSize;
//GLuint = LongWord;
//PGLuint = ^GLuint;
//CGPoint = record
//x: CGFloat;
//y: CGFloat;
//end;
//PCGPoint = ^CGPoint;
//CGRect = record
//origin: CGPoint;
//size: CGSize;
//end;
//PCGRect = ^CGRect;
//__darwin_size_t = LongWord;
//P__darwin_size_t = ^__darwin_size_t;
//RTCFileLoggerSeverity = NSUInteger;
//RTCFileLoggerRotationType = NSUInteger;
//RTCFileVideoCapturerErrorBlock = procedure(param1: NSError) of object;
//RTCTlsCertPolicy = NSUInteger;
//CFTimeInterval = Double;
//PCFTimeInterval = ^CFTimeInterval;
//UIViewContentMode = NSInteger;
//TWebRTCCompletionHandler3 = procedure(param1: NSArray) of object;
//RTCDeviceType = NSInteger;
//{*********************************************}
//RTCAudioSessionClass = interface(NSObjectClass)
//['{A6B6114F-8A68-4D27-B6DC-0D31A79AF1D9}']
//{ class } function sharedInstance: Pointer { instancetype }; cdecl;
//end;
//RTCAudioSession = interface(NSObject)
//['{72EA274E-32EC-4F26-A431-9209D20B8589}']
//function session: AVAudioSession; cdecl;
//function isActive: Boolean; cdecl;
//function isLocked: Boolean; cdecl;
//procedure setUseManualAudio(useManualAudio: Boolean); cdecl;
//function useManualAudio: Boolean; cdecl;
//procedure setIsAudioEnabled(isAudioEnabled: Boolean); cdecl;
//function isAudioEnabled: Boolean; cdecl;
//function category: NSString; cdecl;
//function categoryOptions: AVAudioSessionCategoryOptions; cdecl;
//function mode: NSString; cdecl;
//function secondaryAudioShouldBeSilencedHint: Boolean; cdecl;
//function currentRoute: AVAudioSessionRouteDescription; cdecl;
//function maximumInputNumberOfChannels: NSInteger; cdecl;
//function maximumOutputNumberOfChannels: NSInteger; cdecl;
//function inputGain: Single; cdecl;
//function inputGainSettable: Boolean; cdecl;
//function inputAvailable: Boolean; cdecl;
//function inputDataSources: NSArray; cdecl;
//function inputDataSource: AVAudioSessionDataSourceDescription; cdecl;
//function outputDataSources: NSArray; cdecl;
//function outputDataSource: AVAudioSessionDataSourceDescription; cdecl;
//function sampleRate: Double; cdecl;
//function preferredSampleRate: Double; cdecl;
//function inputNumberOfChannels: NSInteger; cdecl;
//function outputNumberOfChannels: NSInteger; cdecl;
//function outputVolume: Single; cdecl;
//function inputLatency: NSTimeInterval; cdecl;
//function outputLatency: NSTimeInterval; cdecl;
//function IOBufferDuration: NSTimeInterval; cdecl;
//function preferredIOBufferDuration: NSTimeInterval; cdecl;
//procedure addDelegate(delegate: Pointer); cdecl;
//procedure removeDelegate(delegate: Pointer); cdecl;
//procedure lockForConfiguration; cdecl;
//procedure unlockForConfiguration; cdecl;
//function setActive(active: Boolean; error: NSError): Boolean; cdecl;
//function setCategory(category: NSString; withOptions: AVAudioSessionCategoryOptions; error: NSError): Boolean; cdecl;
//function setMode(mode: NSString; error: NSError): Boolean; cdecl;
//function setInputGain(gain: Single; error: NSError): Boolean; cdecl;
//function setPreferredSampleRate(sampleRate: Double; error: NSError): Boolean; cdecl;
//function setPreferredIOBufferDuration(duration: NSTimeInterval; error: NSError): Boolean; cdecl;
//function setPreferredInputNumberOfChannels(count: NSInteger; error: NSError): Boolean; cdecl;
//function setPreferredOutputNumberOfChannels(count: NSInteger; error: NSError): Boolean; cdecl;
//function overrideOutputAudioPort(portOverride: AVAudioSessionPortOverride; error: NSError): Boolean; cdecl;
//function setPreferredInput(inPort: AVAudioSessionPortDescription; error: NSError): Boolean; cdecl;
//function setInputDataSource(dataSource: AVAudioSessionDataSourceDescription; error: NSError): Boolean; cdecl;
//function setOutputDataSource(dataSource: AVAudioSessionDataSourceDescription; error: NSError): Boolean; cdecl;
//[MethodName('setConfiguration:error:')]
//function setConfigurationError(configuration: RTCAudioSessionConfiguration; error: NSError): Boolean; cdecl;
//[MethodName('setConfiguration:active:error:')]
//function setConfigurationActiveError(configuration: RTCAudioSessionConfiguration; active: Boolean; error: NSError): Boolean; cdecl;
//end;
//TRTCAudioSession = class(TOCGenericImport<RTCAudioSessionClass, RTCAudioSession>) end;
//PRTCAudioSession = Pointer;
//{**********************************************************}
//RTCAudioSessionConfigurationClass = interface(NSObjectClass)
//['{F4D9F6EB-B091-43AC-A885-5C43ACF9ED43}']
//{ class } function currentConfiguration: Pointer { instancetype }; cdecl;
//{ class } function webRTCConfiguration: Pointer { instancetype }; cdecl;
//{ class } procedure setWebRTCConfiguration(configuration: RTCAudioSessionConfiguration); cdecl;
//end;
//RTCAudioSessionConfiguration = interface(NSObject)
//['{D4A1E1DE-E80B-4A61-940E-B28B3F0CF007}']
//procedure setCategory(category: NSString); cdecl;
//function category: NSString; cdecl;
//procedure setCategoryOptions(categoryOptions: AVAudioSessionCategoryOptions); cdecl;
//function categoryOptions: AVAudioSessionCategoryOptions; cdecl;
//procedure setMode(mode: NSString); cdecl;
//function mode: NSString; cdecl;
//procedure setSampleRate(sampleRate: Double); cdecl;
//function sampleRate: Double; cdecl;
//procedure setIoBufferDuration(IOBufferDuration: NSTimeInterval); cdecl;
//function IOBufferDuration: NSTimeInterval; cdecl;
//procedure setInputNumberOfChannels(inputNumberOfChannels: NSInteger); cdecl;
//function inputNumberOfChannels: NSInteger; cdecl;
//procedure setOutputNumberOfChannels(outputNumberOfChannels: NSInteger); cdecl;
//function outputNumberOfChannels: NSInteger; cdecl;
//function init: Pointer { instancetype }; cdecl;
//end;
//TRTCAudioSessionConfiguration = class(TOCGenericImport<RTCAudioSessionConfigurationClass, RTCAudioSessionConfiguration>) end;
//PRTCAudioSessionConfiguration = Pointer;
{************************************}
//@interface RTCMediaSource : NSObject
RTCMediaSourceClass = interface(NSObjectClass)
['{BF16BBB0-F9DD-4483-AF2B-4503EC43D476}']
end;
RTCMediaSource = interface(NSObject)
['{77A69BA4-3968-4235-AF7B-7E5A224294B7}']
//The current state of the RTCMediaSource.
//@property(nonatomic, readonly) RTCSourceState state;
function state: RTCSourceState; cdecl;
//- (instancetype)init NS_UNAVAILABLE;
end;
TRTCMediaSource = class(TOCGenericImport<RTCMediaSourceClass, RTCMediaSource>) end;
PRTCMediaSource = Pointer;
{******************************************}
//@interface RTCAudioSource : RTCMediaSource
RTCAudioSourceClass = interface(RTCMediaSourceClass)
['{90AB4822-6838-4B2D-9BC8-A6798E51ADA5}']
end;
RTCAudioSource = interface(RTCMediaSource)
['{7018504B-82F1-4C7F-BAEE-141FEBDC296B}']
//- (instancetype)init NS_UNAVAILABLE;
//Sets the volume for the RTCMediaSource. |volume| is a gain value in the range [0, 10].
//Temporary fix to be able to modify volume of remote audio tracks.
//TODO(kthelgason): Property stays here temporarily until a proper volume-api
//is available on the surface exposed by webrtc.
//@property(nonatomic, assign) double volume;
procedure setVolume(volume: Double); cdecl;
function volume: Double; cdecl;
end;
TRTCAudioSource = class(TOCGenericImport<RTCAudioSourceClass, RTCAudioSource>) end;
PRTCAudioSource = Pointer;
{*****************************************}
//@interface RTCMediaStreamTrack : NSObject
RTCMediaStreamTrackClass = interface(NSObjectClass)
['{C08DFEAA-9074-49DC-B5B9-04A6BFB410C9}']
end;
RTCMediaStreamTrack = interface(NSObject)
['{12C83840-E22E-4DDF-A0C6-EA130FF79708}']
//The kind of track. For example, "audio" if this track represents an audio
//track and "video" if this track represents a video track.
//@property(nonatomic, readonly) NSString *kind;
function kind: NSString; cdecl;
//An identifier string.
//@property(nonatomic, readonly) NSString *trackId;
//function trackId: NSString; cdecl;
//The enabled state of the track.
//@property(nonatomic, assign) BOOL isEnabled;
procedure setIsEnabled(isEnabled: Boolean); cdecl;
function isEnabled: Boolean; cdecl;
//The state of the track.
//@property(nonatomic, readonly) RTCMediaStreamTrackState readyState;
//function readyState: RTCMediaStreamTrackState; cdecl;
//- (instancetype)init NS_UNAVAILABLE;
end;
TRTCMediaStreamTrack = class(TOCGenericImport<RTCMediaStreamTrackClass, RTCMediaStreamTrack>) end;
PRTCMediaStreamTrack = Pointer;
{**********************************************}
//@interface RTCAudioTrack : RTCMediaStreamTrack
RTCAudioTrackClass = interface(RTCMediaStreamTrackClass)
['{4F246275-31AB-41F9-B091-18F051C7A486}']
end;
RTCAudioTrack = interface(RTCMediaStreamTrack)
['{A9828D51-5F7A-4F66-AAFC-EC173651A1DC}']
//The audio source for this audio track.
//@property(nonatomic, readonly) RTCAudioSource *source;
//function source: RTCAudioSource; cdecl;
end;
TRTCAudioTrack = class(TOCGenericImport<RTCAudioTrackClass, RTCAudioTrack>) end;
PRTCAudioTrack = Pointer;
//{***********************************************}
//RTCCallbackLoggerClass = interface(NSObjectClass)
//['{D5096C46-8F94-4AAA-9A8A-06BA8576B3FD}']
//end;
//RTCCallbackLogger = interface(NSObject)
//['{20D563D2-C274-42C1-943C-C0015D9A399A}']
//procedure setSeverity(severity: RTCLoggingSeverity); cdecl;
//function severity: RTCLoggingSeverity; cdecl;
//procedure start(callback: TWebRTCCallback); cdecl;
//procedure stop; cdecl;
//end;
//TRTCCallbackLogger = class(TOCGenericImport<RTCCallbackLoggerClass, RTCCallbackLogger>) end;
//PRTCCallbackLogger = Pointer;
//{************************************************}
//RTCCameraPreviewViewClass = interface(UIViewClass)
//['{F4BABECA-DE65-4237-ADF2-99628993E518}']
//end;
//RTCCameraPreviewView = interface(UIView)
//['{BD3B6360-22DD-438B-877F-1687A37C7813}']
//procedure setCaptureSession(captureSession: AVCaptureSession); cdecl;
//function captureSession: AVCaptureSession; cdecl;
//end;
//TRTCCameraPreviewView = class(TOCGenericImport<RTCCameraPreviewViewClass, RTCCameraPreviewView>) end;
//PRTCCameraPreviewView = Pointer;
{***********************************}
//@interface RTCVideoFrame : NSObject
RTCVideoFrameClass = interface(NSObjectClass)
['{EFA1CAD4-76CA-4029-9AE4-FDF8185B63B8}']
end;
RTCVideoFrame = interface(NSObject)
['{BC992027-8BC1-4AFB-B839-E0F379070055}']
//Width without rotation applied.
//@property(nonatomic, readonly) int width;
function width: Integer; cdecl;
//Height without rotation applied.
//@property(nonatomic, readonly) int height;
function height: Integer; cdecl;
//@property(nonatomic, readonly) RTCVideoRotation rotation;
function rotation: RTCVideoRotation; cdecl;
//Timestamp in nanoseconds.
//@property(nonatomic, readonly) int64_t timeStampNs;
function timeStampNs: Int64; cdecl;
//Timestamp 90 kHz.
//@property(nonatomic, assign) int32_t timeStamp;
//procedure setTimeStamp(timeStamp: Int32); cdecl;
function timeStamp: Int32; cdecl;
//@property(nonatomic, readonly) id<RTCVideoFrameBuffer> buffer;
function buffer: Pointer; cdecl;
//- (instancetype)init NS_UNAVAILABLE;
//- (instancetype) new NS_UNAVAILABLE;
//Initialize an RTCVideoFrame from a pixel buffer, rotation, and timestamp.
//Deprecated - initialize with a RTCCVPixelBuffer instead
//- (instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer
// rotation:(RTCVideoRotation)rotation
// timeStampNs:(int64_t)timeStampNs
// DEPRECATED_MSG_ATTRIBUTE("use initWithBuffer instead");
//[MethodName('initWithPixelBuffer:rotation:timeStampNs:')]
//function initWithPixelBufferRotationTimeStampNs (pixelBuffer: CVPixelBufferRef; rotation: RTCVideoRotation; timeStampNs: Int64): Pointer { instancetype }; cdecl; deprecated;
//Initialize an RTCVideoFrame from a pixel buffer combined with cropping and
//scaling. Cropping will be applied first on the pixel buffer, followed by
//scaling to the final resolution of scaledWidth x scaledHeight.
//- (instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer
// scaledWidth:(int)scaledWidth
// scaledHeight:(int)scaledHeight
// cropWidth:(int)cropWidth
// cropHeight:(int)cropHeight
// cropX:(int)cropX
// cropY:(int)cropY
// rotation:(RTCVideoRotation)rotation
// timeStampNs:(int64_t)timeStampNs
// DEPRECATED_MSG_ATTRIBUTE("use initWithBuffer instead");
//[MethodName ('initWithPixelBuffer:scaledWidth:scaledHeight:cropWidth:cropHeight:cropX:cropY:rotation:timeStampNs:') ]
//function initWithPixelBufferScaledWidthScaledHeightCropWidthCropHeightCropXCropYRotationTimeStampNs (pixelBuffer: CVPixelBufferRef; scaledWidth: Integer; scaledHeight: Integer; cropWidth: Integer; cropHeight: Integer; cropX: Integer; cropY: Integer; rotation: RTCVideoRotation; timeStampNs: Int64): Pointer { instancetype }; cdecl; deprecated;
//Initialize an RTCVideoFrame from a frame buffer, rotation, and timestamp.
//- (instancetype)initWithBuffer:(id<RTCVideoFrameBuffer>)frameBuffer
// rotation:(RTCVideoRotation)rotation
// timeStampNs:(int64_t)timeStampNs;
//function initWithBuffer(frameBuffer: Pointer; rotation: RTCVideoRotation; timeStampNs: Int64): Pointer { instancetype }; cdecl;
//Return a frame that is guaranteed to be I420, i.e. it is possible to access
//the YUV data on it.
//- (RTCVideoFrame *)newI420VideoFrame;
function newI420VideoFrame: RTCVideoFrame; cdecl;
end;
TRTCVideoFrame = class(TOCGenericImport<RTCVideoFrameClass, RTCVideoFrame>) end;
PRTCVideoFrame = Pointer;
{**************************************}
//@interface RTCVideoCapturer : NSObject
RTCVideoCapturerClass = interface(NSObjectClass)
['{A470FB28-9FFF-441E-97BB-C62B958F9C23}']
end;
RTCVideoCapturer = interface(NSObject)
['{C1C314C8-3EE1-4F48-9DCC-15969C3B3C11}']
//@property(nonatomic, weak) id<RTCVideoCapturerDelegate> delegate;
procedure setDelegate(delegate: Pointer); cdecl;
function delegate: Pointer; cdecl;
//- (instancetype)initWithDelegate:(id<RTCVideoCapturerDelegate>)delegate;
function initWithDelegate(delegate: Pointer): Pointer { instancetype }; cdecl;
end;
TRTCVideoCapturer = class(TOCGenericImport<RTCVideoCapturerClass, RTCVideoCapturer>) end;
PRTCVideoCapturer = Pointer;
{****************************************************}
//@interface RTCCameraVideoCapturer : RTCVideoCapturer
RTCCameraVideoCapturerClass = interface(RTCVideoCapturerClass)
['{DCABFA66-0A5D-4881-B490-E31B73C73CD5}']
//Returns list of available capture devices that support video capture.
//+ (NSArray<AVCaptureDevice *> *)captureDevices;
{ class } function captureDevices: NSArray; cdecl;
// Returns list of formats that are supported by this class for this device.
//+ (NSArray<AVCaptureDeviceFormat *> *)supportedFormatsForDevice:(AVCaptureDevice *)device;
{ class } function supportedFormatsForDevice(device: AVCaptureDevice): NSArray; cdecl;
end;
RTCCameraVideoCapturer = interface(RTCVideoCapturer)
['{C8751868-E389-4BEB-AC6A-9F630E73BC58}']
//Capture session that is used for capturing. Valid from initialization to dealloc.
//@property(readonly, nonatomic) AVCaptureSession *captureSession;
//function captureSession: AVCaptureSession; cdecl;
//Returns the most efficient supported output pixel format for this capturer.
//- (FourCharCode)preferredOutputPixelFormat;
function preferredOutputPixelFormat: FourCharCode; cdecl;
//Starts the capture session asynchronously and notifies callback on completion.
//The device will capture video in the format given in the `format` parameter. If the pixel format
//in `format` is supported by the WebRTC pipeline, the same pixel format will be used for the
//output. Otherwise, the format returned by `preferredOutputPixelFormat` will be used.
//- (void)startCaptureWithDevice:(AVCaptureDevice *)device
// format:(AVCaptureDeviceFormat *)format
// fps:(NSInteger)fps
// completionHandler:(nullable void (^)(NSError *))completionHandler;
//[MethodName('startCaptureWithDevice:format:fps:completionHandler:')]
//procedure startCaptureWithDeviceFormatFpsCompletionHandler (device: AVCaptureDevice; format: AVCaptureDeviceFormat; fps: NSInteger; completionHandler: TWebRTCCompletionHandler); cdecl;
//Stops the capture session asynchronously and notifies callback on completion.
//- (void)stopCaptureWithCompletionHandler:(nullable void (^)(void))completionHandler;
//procedure stopCaptureWithCompletionHandler(completionHandler: TWebRTCCompletionHandler1); cdecl;
//Starts the capture session asynchronously.
//- (void)startCaptureWithDevice:(AVCaptureDevice *)device
// format:(AVCaptureDeviceFormat *)format
// fps:(NSInteger)fps;
[MethodName('startCaptureWithDevice:format:fps:')]
procedure startCaptureWithDeviceFormatFps(device: AVCaptureDevice; format: AVCaptureDeviceFormat; fps: NSInteger); cdecl;
//Stops the capture session asynchronously.
//- (void)stopCapture;
procedure stopCapture; cdecl;
end;
TRTCCameraVideoCapturer = class(TOCGenericImport<RTCCameraVideoCapturerClass, RTCCameraVideoCapturer>) end;
PRTCCameraVideoCapturer = Pointer;
{************************************************}
//@interface RTCCertificate : NSObject <NSCopying>
RTCCertificateClass = interface(NSObjectClass)
['{C9AFAF4F-D1EB-4EA3-AE98-B00BF94AB5DC}']
//Generate a new certificate for 're' use.
//Optional dictionary of parameters. Defaults to KeyType ECDSA if none are
//provided.
//- name: "ECDSA" or "RSASSA-PKCS1-v1_5"
//+ (nullable RTCCertificate *)generateCertificateWithParams:(NSDictionary *)params;
{ class } function generateCertificateWithParams(params: NSDictionary): RTCCertificate; cdecl;
end;
RTCCertificate = interface(NSObject)
['{3952697D-06D6-4E0B-BA49-CE026B8C41FD}']
//Private key in PEM.
//@property(nonatomic, readonly, copy) NSString *private_key;
function private_key: NSString; cdecl;
// Public key in an x509 cert encoded in PEM.
//@property(nonatomic, readonly, copy) NSString *certificate;
function certificate: NSString; cdecl;
//Initialize an RTCCertificate with PEM strings for private_key and certificate.
//- (instancetype)initWithPrivateKey:(NSString *)private_key
// certificate:(NSString *)certificate NS_DESIGNATED_INITIALIZER;
function initWithPrivateKey(private_key: NSString; certificate: NSString): Pointer { instancetype }; cdecl;
//- (instancetype)init NS_UNAVAILABLE;
end;
TRTCCertificate = class(TOCGenericImport<RTCCertificateClass, RTCCertificate>) end;
PRTCCertificate = Pointer;
//{******************************************************}
//RTCCodecSpecificInfoH264Class = interface(NSObjectClass)
//['{96F3E93A-D2B8-401E-8016-612FA13D274B}']
//end;
//RTCCodecSpecificInfoH264 = interface(NSObject)
//['{4502F845-EAA2-40B8-89D6-7793DFBEDB62}']
//procedure setPacketizationMode(packetizationMode: RTCH264PacketizationMode); cdecl;
//function packetizationMode: RTCH264PacketizationMode; cdecl;
//end;
//TRTCCodecSpecificInfoH264 = class (TOCGenericImport<RTCCodecSpecificInfoH264Class, RTCCodecSpecificInfoH264>) end;
//PRTCCodecSpecificInfoH264 = Pointer;
{**********************************}
//@interface RTCIceServer : NSObject
RTCIceServerClass = interface(NSObjectClass)
['{D15624FE-A7D9-4EFA-AD79-1251BE9107D3}']
end;
RTCIceServer = interface(NSObject)
['{B6AE16E6-34F2-4F29-A17D-E88F2E0397ED}']
//URI(s) for this server represented as NSStrings.
//@property(nonatomic, readonly) NSArray<NSString *> *urlStrings;
function urlStrings: NSArray; cdecl;
//Username to use if this RTCIceServer object is a TURN server.
//@property(nonatomic, readonly, nullable) NSString *username;
function username: NSString; cdecl;
//Credential to use if this RTCIceServer object is a TURN server.
//@property(nonatomic, readonly, nullable) NSString *credential;
function credential: NSString; cdecl;
//TLS certificate policy to use if this RTCIceServer object is a TURN server.
//@property(nonatomic, readonly) RTCTlsCertPolicy tlsCertPolicy;
//function tlsCertPolicy: RTCTlsCertPolicy; cdecl;
//If the URIs in |urls| only contain IP addresses, this field can be used
//to indicate the hostname, which may be necessary for TLS (using the SNI
//extension). If |urls| itself contains the hostname, this isn't necessary.
//@property(nonatomic, readonly, nullable) NSString *hostname;
function hostname: NSString; cdecl;
//List of protocols to be used in the TLS ALPN extension.
//@property(nonatomic, readonly) NSArray<NSString *> *tlsAlpnProtocols;
//function tlsAlpnProtocols: NSArray; cdecl;
//List elliptic curves to be used in the TLS elliptic curves extension.
//Only curve names supported by OpenSSL should be used (eg. "P-256","X25519").
//@property(nonatomic, readonly) NSArray<NSString *> *tlsEllipticCurves;
//function tlsEllipticCurves: NSArray; cdecl;
//- (nonnull instancetype)init NS_UNAVAILABLE;
//Convenience initializer for a server with no authentication (e.g. STUN).
//- (instancetype)initWithURLStrings:(NSArray<NSString *> *)urlStrings;
[MethodName('initWithURLStrings:')]
function initWithURLStrings(urlStrings: NSArray): Pointer { instancetype }; cdecl;
//Initialize an RTCIceServer with its associated URLs, optional username,
//optional credential, and credentialType.
//- (instancetype)initWithURLStrings:(NSArray<NSString *> *)urlStrings
// username:(nullable NSString *)username
// credential:(nullable NSString *)credential;
[MethodName('initWithURLStrings:username:credential:')]
function initWithURLStringsUsernameCredential(urlStrings: NSArray; username: NSString; credential: NSString): Pointer { instancetype }; cdecl;
//Initialize an RTCIceServer with its associated URLs, optional username,
//optional credential, and TLS cert policy.
//- (instancetype)initWithURLStrings:(NSArray<NSString *> *)urlStrings
// username:(nullable NSString *)username
// credential:(nullable NSString *)credential
// tlsCertPolicy:(RTCTlsCertPolicy)tlsCertPolicy;
//[MethodName('initWithURLStrings:username:credential:tlsCertPolicy:')]
//function initWithURLStringsUsernameCredentialTlsCertPolicy (urlStrings: NSArray; username: NSString; credential: NSString; tlsCertPolicy: RTCTlsCertPolicy): Pointer { instancetype }; cdecl;
//Initialize an RTCIceServer with its associated URLs, optional username,
//optional credential, TLS cert policy and hostname.
//- (instancetype)initWithURLStrings:(NSArray<NSString *> *)urlStrings
// username:(nullable NSString *)username
// credential:(nullable NSString *)credential
// tlsCertPolicy:(RTCTlsCertPolicy)tlsCertPolicy
// hostname:(nullable NSString *)hostname;
//[MethodName ('initWithURLStrings:username:credential:tlsCertPolicy:hostname:')]
//function initWithURLStringsUsernameCredentialTlsCertPolicyHostname (urlStrings: NSArray; username: NSString; credential: NSString; tlsCertPolicy: RTCTlsCertPolicy; hostname: NSString): Pointer { instancetype }; cdecl;
//Initialize an RTCIceServer with its associated URLs, optional username,
//optional credential, TLS cert policy, hostname and ALPN protocols.
//- (instancetype)initWithURLStrings:(NSArray<NSString *> *)urlStrings
// username:(nullable NSString *)username
// credential:(nullable NSString *)credential
// tlsCertPolicy:(RTCTlsCertPolicy)tlsCertPolicy
// hostname:(nullable NSString *)hostname
// tlsAlpnProtocols:(NSArray<NSString *> *)tlsAlpnProtocols;
//[MethodName ('initWithURLStrings:username:credential:tlsCertPolicy:hostname:tlsAlpnProtocols:') ]
//function initWithURLStringsUsernameCredentialTlsCertPolicyHostnameTlsAlpnProtocols (urlStrings: NSArray; username: NSString; credential: NSString; tlsCertPolicy: RTCTlsCertPolicy; hostname: NSString; tlsAlpnProtocols: NSArray): Pointer { instancetype }; cdecl;
//Initialize an RTCIceServer with its associated URLs, optional username,
//optional credential, TLS cert policy, hostname, ALPN protocols and
//elliptic curves.
//- (instancetype)initWithURLStrings:(NSArray<NSString *> *)urlStrings
// username:(nullable NSString *)username
// credential:(nullable NSString *)credential
// tlsCertPolicy:(RTCTlsCertPolicy)tlsCertPolicy
// hostname:(nullable NSString *)hostname
// tlsAlpnProtocols:(nullable NSArray<NSString *> *)tlsAlpnProtocols
// tlsEllipticCurves:(nullable NSArray<NSString *> *)tlsEllipticCurves
// NS_DESIGNATED_INITIALIZER;
//[MethodName ('initWithURLStrings:username:credential:tlsCertPolicy:hostname:tlsAlpnProtocols:tlsEllipticCurves:') ]
//function initWithURLStringsUsernameCredentialTlsCertPolicyHostnameTlsAlpnProtocolsTlsEllipticCurves (urlStrings: NSArray; username: NSString; credential: NSString; tlsCertPolicy: RTCTlsCertPolicy; hostname: NSString; tlsAlpnProtocols: NSArray; tlsEllipticCurves: NSArray): Pointer { instancetype }; cdecl;
end;
TRTCIceServer = class(TOCGenericImport<RTCIceServerClass, RTCIceServer>) end;
PRTCIceServer = Pointer;
//{**********************************************}
//RTCIntervalRangeClass = interface(NSObjectClass)
//['{D9929EBD-D3EA-461A-B3D8-C6B564E7FAEB}']
//end;
//RTCIntervalRange = interface(NSObject)
//['{68C6B303-BB26-43BB-89D0-1F0696FD94D2}']
//function min: NSInteger; cdecl;
//function max: NSInteger; cdecl;
//function init: Pointer { instancetype }; cdecl;
//function initWithMin(min: NSInteger; max: NSInteger): Pointer { instancetype }; cdecl;
//end;
//TRTCIntervalRange = class(TOCGenericImport<RTCIntervalRangeClass, RTCIntervalRange>) end;
//PRTCIntervalRange = Pointer;
{**************************************}
//@interface RTCConfiguration : NSObject
RTCConfigurationClass = interface(NSObjectClass)
['{B6FBFCDC-7338-4389-8449-F4F5107582BA}']
end;
RTCConfiguration = interface(NSObject)
['{D3B3564D-780E-497C-8E9C-FAEE23376E5C}']
//An array of Ice Servers available to be used by ICE.
//@property(nonatomic, copy) NSArray<RTCIceServer *> *iceServers;
procedure setIceServers(iceServers: NSArray); cdecl;
function iceServers: NSArray; cdecl;
//An RTCCertificate for 're' use.
//@property(nonatomic, nullable) RTCCertificate *certificate;
procedure setCertificate(certificate: RTCCertificate); cdecl;
function certificate: RTCCertificate; cdecl;
//Which candidates the ICE agent is allowed to use. The W3C calls it
//|iceTransportPolicy|, while in C++ it is called |type|.
//@property(nonatomic, assign) RTCIceTransportPolicy iceTransportPolicy;
//procedure setIceTransportPolicy(iceTransportPolicy: RTCIceTransportPolicy); cdecl;
//function iceTransportPolicy: RTCIceTransportPolicy; cdecl;
//The media-bundling policy to use when gathering ICE candidates.
//@property(nonatomic, assign) RTCBundlePolicy bundlePolicy;
//procedure setBundlePolicy(bundlePolicy: RTCBundlePolicy); cdecl;
//function bundlePolicy: RTCBundlePolicy; cdecl;
//The rtcp-mux policy to use when gathering ICE candidates.
//@property(nonatomic, assign) RTCRtcpMuxPolicy rtcpMuxPolicy;
//procedure setRtcpMuxPolicy(rtcpMuxPolicy: RTCRtcpMuxPolicy); cdecl;
//function rtcpMuxPolicy: RTCRtcpMuxPolicy; cdecl;
//@property(nonatomic, assign) RTCTcpCandidatePolicy tcpCandidatePolicy;
//procedure setTcpCandidatePolicy(tcpCandidatePolicy: RTCTcpCandidatePolicy); cdecl;
//function tcpCandidatePolicy: RTCTcpCandidatePolicy; cdecl;
//@property(nonatomic, assign) RTCCandidateNetworkPolicy candidateNetworkPolicy;
//procedure setCandidateNetworkPolicy(candidateNetworkPolicy: RTCCandidateNetworkPolicy); cdecl;
//function candidateNetworkPolicy: RTCCandidateNetworkPolicy; cdecl;
//@property(nonatomic, assign) RTCContinualGatheringPolicy continualGatheringPolicy;
//procedure setContinualGatheringPolicy(continualGatheringPolicy: RTCContinualGatheringPolicy); cdecl;
//function continualGatheringPolicy: RTCContinualGatheringPolicy; cdecl;
//By default, the PeerConnection will use a limited number of IPv6 network
//interfaces, in order to avoid too many ICE candidate pairs being created
//and delaying ICE completion.
//Can be set to INT_MAX to effectively disable the limit.
//@property(nonatomic, assign) int maxIPv6Networks;
//procedure setMaxIPv6Networks(maxIPv6Networks: Integer); cdecl;
//function maxIPv6Networks: Integer; cdecl;
//Exclude link-local network interfaces
//from considertaion for gathering ICE candidates.
//Defaults to NO.
//@property(nonatomic, assign) BOOL disableLinkLocalNetworks;
//procedure setDisableLinkLocalNetworks(disableLinkLocalNetworks: Boolean); cdecl;
//function disableLinkLocalNetworks: Boolean; cdecl;
//@property(nonatomic, assign) int audioJitterBufferMaxPackets;
//procedure setAudioJitterBufferMaxPackets(audioJitterBufferMaxPackets: Integer); cdecl;
//function audioJitterBufferMaxPackets: Integer; cdecl;
//@property(nonatomic, assign) BOOL audioJitterBufferFastAccelerate;
//procedure setAudioJitterBufferFastAccelerate(audioJitterBufferFastAccelerate: Boolean); cdecl;
//function audioJitterBufferFastAccelerate: Boolean; cdecl;
//@property(nonatomic, assign) int iceConnectionReceivingTimeout;
//procedure setIceConnectionReceivingTimeout(iceConnectionReceivingTimeout: Integer); cdecl;
//function iceConnectionReceivingTimeout: Integer; cdecl;
//@property(nonatomic, assign) int iceBackupCandidatePairPingInterval;
//procedure setIceBackupCandidatePairPingInterval (iceBackupCandidatePairPingInterval: Integer); cdecl;
//function iceBackupCandidatePairPingInterval: Integer; cdecl;
//Key type used to generate SSL identity. Default is ECDSA.
//@property(nonatomic, assign) RTCEncryptionKeyType keyType;
//procedure setKeyType(keyType: RTCEncryptionKeyType); cdecl;
//function keyType: RTCEncryptionKeyType; cdecl;
//ICE candidate pool size as defined in JSEP. Default is 0.
//@property(nonatomic, assign) int iceCandidatePoolSize;
//procedure setIceCandidatePoolSize(iceCandidatePoolSize: Integer); cdecl;
//function iceCandidatePoolSize: Integer; cdecl;
//Prune turn ports on the same network to the same turn server.
//Default is NO.
//@property(nonatomic, assign) BOOL shouldPruneTurnPorts;
//procedure setShouldPruneTurnPorts(shouldPruneTurnPorts: Boolean); cdecl;
//function shouldPruneTurnPorts: Boolean; cdecl;
//If set to YES, this means the ICE transport should presume TURN-to-TURN
//candidate pairs will succeed, even before a binding response is received.
//@property(nonatomic, assign) BOOL shouldPresumeWritableWhenFullyRelayed;
//procedure setShouldPresumeWritableWhenFullyRelayed (shouldPresumeWritableWhenFullyRelayed: Boolean); cdecl;
//function shouldPresumeWritableWhenFullyRelayed: Boolean; cdecl;
//If set to non-nil, controls the minimal interval between consecutive ICE
//check packets.
//@property(nonatomic, copy, nullable) NSNumber *iceCheckMinInterval;
//procedure setIceCheckMinInterval(iceCheckMinInterval: NSNumber); cdecl;
//function iceCheckMinInterval: NSNumber; cdecl;
//ICE Periodic Regathering
//If set, WebRTC will periodically create and propose candidates without
//starting a new ICE generation. The regathering happens continuously with
//interval specified in milliseconds by the uniform distribution [a, b].
//@property(nonatomic, strong, nullable) RTCIntervalRange *iceRegatherIntervalRange;
//procedure setIceRegatherIntervalRange(iceRegatherIntervalRange: RTCIntervalRange); cdecl;
//function iceRegatherIntervalRange: RTCIntervalRange; cdecl;
//Configure the SDP semantics used by this PeerConnection. Note that the
//WebRTC 1.0 specification requires UnifiedPlan semantics. The
//RTCRtpTransceiver API is only available with UnifiedPlan semantics.
//
//PlanB will cause RTCPeerConnection to create offers and answers with at
//most one audio and one video m= section with multiple RTCRtpSenders and
//RTCRtpReceivers specified as multiple a=ssrc lines within the section. This
//will also cause RTCPeerConnection to ignore all but the first m= section of
//the same media type.
//
//UnifiedPlan will cause RTCPeerConnection to create offers and answers with
//multiple m= sections where each m= section maps to one RTCRtpSender and one
//RTCRtpReceiver (an RTCRtpTransceiver), either both audio or both video. This
//will also cause RTCPeerConnection to ignore all but the first a=ssrc lines
//that form a Plan B stream.
//
//For users who wish to send multiple audio/video streams and need to stay
//interoperable with legacy WebRTC implementations or use legacy APIs,
//specify PlanB.
//
//For all other users, specify UnifiedPlan.
//@property(nonatomic, assign) RTCSdpSemantics sdpSemantics;
procedure setSdpSemantics(sdpSemantics: RTCSdpSemantics); cdecl;
function sdpSemantics: RTCSdpSemantics; cdecl;
//Actively reset the SRTP parameters when the DTLS transports underneath are
//changed after offer/answer negotiation. This is only intended to be a
//workaround for crbug.com/835958
//@property(nonatomic, assign) BOOL activeResetSrtpParams;
//procedure setActiveResetSrtpParams(activeResetSrtpParams: Boolean); cdecl;
//function activeResetSrtpParams: Boolean; cdecl;
//If MediaTransportFactory is provided in PeerConnectionFactory, this flag informs PeerConnection
//that it should use the MediaTransportInterface.
//@property(nonatomic, assign) BOOL useMediaTransport;
//procedure setUseMediaTransport(useMediaTransport: Boolean); cdecl;
//function useMediaTransport: Boolean; cdecl;
//- (instancetype)init;
//function init: Pointer { instancetype }; cdecl;
end;
TRTCConfiguration = class(TOCGenericImport<RTCConfigurationClass, RTCConfiguration>) end;
PRTCConfiguration = Pointer;
{************************************************************}
//@interface RTCCVPixelBuffer : NSObject <RTCVideoFrameBuffer>
RTCCVPixelBufferClass = interface(NSObjectClass)
['{AF44B741-EAD5-44A8-BB93-53A6303E5E7A}']
//+ (NSSet<NSNumber *> *)supportedPixelFormats;
{ class } function supportedPixelFormats: NSSet; cdecl;
end;
RTCCVPixelBuffer = interface(NSObject)
['{82775AF1-460D-46D2-90D4-8FC2B1412A50}']
//@property(nonatomic, readonly) CVPixelBufferRef pixelBuffer;
function pixelBuffer: CVPixelBufferRef; cdecl;
//@property(nonatomic, readonly) int cropX;
function cropX: Integer; cdecl;
//@property(nonatomic, readonly) int cropY;
function cropY: Integer; cdecl;
//@property(nonatomic, readonly) int cropWidth;
function cropWidth: Integer; cdecl;
//@property(nonatomic, readonly) int cropHeight;
function cropHeight: Integer; cdecl;
//- (instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer;
//[MethodName('initWithPixelBuffer:')]
//function initWithPixelBuffer(pixelBuffer: CVPixelBufferRef): Pointer { instancetype }; cdecl;
//- (instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer
// adaptedWidth:(int)adaptedWidth
// adaptedHeight:(int)adaptedHeight
// cropWidth:(int)cropWidth
// cropHeight:(int)cropHeight
// cropX:(int)cropX
// cropY:(int)cropY;
//[MethodName ('initWithPixelBuffer:adaptedWidth:adaptedHeight:cropWidth:cropHeight:cropX:cropY:') ]
//function initWithPixelBufferAdaptedWidthAdaptedHeightCropWidthCropHeightCropXCropY (pixelBuffer: CVPixelBufferRef; adaptedWidth: Integer; adaptedHeight: Integer; cropWidth: Integer; cropHeight: Integer; cropX: Integer; cropY: Integer): Pointer { instancetype }; cdecl;
//- (BOOL)requiresCropping;
//function requiresCropping: Boolean; cdecl;
//- (BOOL)requiresScalingToWidth:(int)width height:(int)height;
//function requiresScalingToWidth(width: Integer; height: Integer): Boolean; cdecl;
//- (int)bufferSizeForCroppingAndScalingToWidth:(int)width height:(int)height;
//function bufferSizeForCroppingAndScalingToWidth(width: Integer; height: Integer): Integer; cdecl;
//The minimum size of the |tmpBuffer| must be the number of bytes returned from the
//bufferSizeForCroppingAndScalingToWidth:height: method.
//If that size is 0, the |tmpBuffer| may be nil.
//- (BOOL)cropAndScaleTo:(CVPixelBufferRef)outputPixelBuffer
// withTempBuffer:(nullable uint8_t *)tmpBuffer;
//function cropAndScaleTo(outputPixelBuffer: CVPixelBufferRef; withTempBuffer: PByte): Boolean; cdecl;
end;
TRTCCVPixelBuffer = class(TOCGenericImport<RTCCVPixelBufferClass, RTCCVPixelBuffer>) end;
PRTCCVPixelBuffer = Pointer;
//{*******************************************}
//RTCDataBufferClass = interface(NSObjectClass)
//['{8B28D4C3-41A6-437C-92DE-68FC37CCF93F}']
//end;
//RTCDataBuffer = interface(NSObject)
//['{94218B3E-1882-45BA-897A-BD136219374E}']
//function data: NSData; cdecl;
//function isBinary: Boolean; cdecl;
//function initWithData(data: NSData; isBinary: Boolean): Pointer { instancetype }; cdecl;
//end;
//TRTCDataBuffer = class(TOCGenericImport<RTCDataBufferClass, RTCDataBuffer>) end;
//PRTCDataBuffer = Pointer;
{************************************}
//@interface RTCDataChannel : NSObject
RTCDataChannelClass = interface(NSObjectClass)
['{025C6769-3D1F-4FA4-90C2-CD10AD41AD33}']
end;
RTCDataChannel = interface(NSObject)
['{2FDBC0D3-56B7-4A43-A2CE-DAD670FB2940}']
//A label that can be used to distinguish this data channel from other data
//channel objects.
//@property(nonatomic, readonly) NSString *label;
function &label: NSString; cdecl;
//Whether the data channel can send messages in unreliable mode.
//@property(nonatomic, readonly) BOOL isReliable DEPRECATED_ATTRIBUTE;
//function isReliable: Boolean; cdecl;
//Returns whether this data channel is ordered or not.
//@property(nonatomic, readonly) BOOL isOrdered;
//function isOrdered: Boolean; cdecl;
//Deprecated. Use maxPacketLifeTime.
//@property(nonatomic, readonly) NSUInteger maxRetransmitTime DEPRECATED_ATTRIBUTE;
//function maxRetransmitTime: NSUInteger; cdecl; deprecated;
//The length of the time window (in milliseconds) during which transmissions
//and retransmissions may occur in unreliable mode.
//@property(nonatomic, readonly) uint16_t maxPacketLifeTime;
//function maxPacketLifeTime: Word; cdecl;
//The maximum number of retransmissions that are attempted in unreliable mode.
//@property(nonatomic, readonly) uint16_t maxRetransmits;
//function maxRetransmits: Word; cdecl;
//The name of the sub-protocol used with this data channel, if any. Otherwise
//this returns an empty string.
//@property(nonatomic, readonly) NSString *protocol;
//function protocol: NSString; cdecl;
//Returns whether this data channel was negotiated by the application or not.
//@property(nonatomic, readonly) BOOL isNegotiated;
//function isNegotiated: Boolean; cdecl;
//Deprecated. Use channelId.
//@property(nonatomic, readonly) NSInteger streamId DEPRECATED_ATTRIBUTE;
//function streamId: NSInteger; cdecl; deprecated;
//The identifier for this data channel.
//@property(nonatomic, readonly) int channelId;
function channelId: Integer; cdecl;
//The state of the data channel.
//@property(nonatomic, readonly) RTCDataChannelState readyState;
//function readyState: RTCDataChannelState; cdecl;
//The number of bytes of application data that have been queued using
//|sendData:| but that have not yet been transmitted to the network.
//@property(nonatomic, readonly) uint64_t bufferedAmount;
//function bufferedAmount: UInt64; cdecl;
//The delegate for this data channel.
//@property(nonatomic, weak) id<RTCDataChannelDelegate> delegate;
//procedure setDelegate(delegate: Pointer); cdecl;
//function delegate: Pointer; cdecl;
//- (instancetype)init NS_UNAVAILABLE;
//Closes the data channel.
//- (void)close;
//procedure close; cdecl;
//Attempt to send |data| on this data channel's underlying data transport.
//- (BOOL)sendData:(RTCDataBuffer *)data;
//function sendData(data: RTCDataBuffer): Boolean; cdecl;
end;
TRTCDataChannel = class(TOCGenericImport<RTCDataChannelClass, RTCDataChannel>) end;
PRTCDataChannel = Pointer;
//{*********************************************************}
//RTCDataChannelConfigurationClass = interface(NSObjectClass)
//['{135B2907-3AF7-4050-ABEB-B3C05595693C}']
//end;
//RTCDataChannelConfiguration = interface(NSObject)
//['{1F85DF5C-6E32-4B77-8959-9057060BE601}']
//procedure setIsOrdered(isOrdered: Boolean); cdecl;
//function isOrdered: Boolean; cdecl;
//procedure setMaxRetransmitTimeMs(maxRetransmitTimeMs: NSInteger); cdecl;
//function maxRetransmitTimeMs: NSInteger; cdecl;
//procedure setMaxPacketLifeTime(maxPacketLifeTime: Integer); cdecl;
//function maxPacketLifeTime: Integer; cdecl;
//procedure setMaxRetransmits(maxRetransmits: Integer); cdecl;
//function maxRetransmits: Integer; cdecl;
//procedure setIsNegotiated(isNegotiated: Boolean); cdecl;
//function isNegotiated: Boolean; cdecl;
//procedure setStreamId(streamId: Integer); cdecl;
//function streamId: Integer; cdecl;
//procedure setChannelId(channelId: Integer); cdecl;
//function channelId: Integer; cdecl;
//procedure setProtocol(protocol: NSString); cdecl;
//function protocol: NSString; cdecl;
//end;
//TRTCDataChannelConfiguration = class(TOCGenericImport<RTCDataChannelConfigurationClass, RTCDataChannelConfiguration>) end;
//PRTCDataChannelConfiguration = Pointer;
{*****************************************************************************}
//Holds information to identify a codec. Corresponds to webrtc::SdpVideoFormat.
//@interface RTCVideoCodecInfo : NSObject <NSCoding>
RTCVideoCodecInfoClass = interface(NSObjectClass)
['{E9946732-49E4-43BE-B3B3-64FBA9779070}']
end;
RTCVideoCodecInfo = interface(NSObject)
['{1475B502-6FB2-4868-9624-CDC139211A85}']
//- (instancetype)init NS_UNAVAILABLE;
//- (instancetype)initWithName:(NSString *)name;
[MethodName('initWithName:')]
function initWithName(name: NSString): Pointer { instancetype }; cdecl;
//- (instancetype)initWithName:(NSString *)name
// parameters:(nullable NSDictionary<NSString *, NSString *> *)parameters
//NS_DESIGNATED_INITIALIZER;
[MethodName('initWithName:parameters:')]
function initWithNameParameters(name: NSString; parameters: NSDictionary): Pointer { instancetype }; cdecl;
//- (BOOL)isEqualToCodecInfo:(RTCVideoCodecInfo *)info;
function isEqualToCodecInfo(info: RTCVideoCodecInfo): Boolean; cdecl;
//@property(nonatomic, readonly) NSString *name;
function name: NSString; cdecl;
//@property(nonatomic, readonly) NSDictionary<NSString *, NSString *> *parameters;
function parameters: NSDictionary; cdecl;
end;
TRTCVideoCodecInfo = class(TOCGenericImport<RTCVideoCodecInfoClass, RTCVideoCodecInfo>) end;
PRTCVideoCodecInfo = Pointer;
//{*********************************************}
//RTCEncodedImageClass = interface(NSObjectClass)
//['{D03D5F46-4AEA-4638-9C0C-D1F150622A8F}']
//end;
//RTCEncodedImage = interface(NSObject)
//['{923A43FD-EFC0-4DD9-B200-3A4ACACA8E69}']
//procedure setBuffer(buffer: NSData); cdecl;
//function buffer: NSData; cdecl;
//procedure setEncodedWidth(encodedWidth: Int32); cdecl;
//function encodedWidth: Int32; cdecl;
//procedure setEncodedHeight(encodedHeight: Int32); cdecl;
//function encodedHeight: Int32; cdecl;
//procedure setTimeStamp(timeStamp: LongWord); cdecl;
//function timeStamp: LongWord; cdecl;
//procedure setCaptureTimeMs(captureTimeMs: Int64); cdecl;
//function captureTimeMs: Int64; cdecl;
//procedure setNtpTimeMs(ntpTimeMs: Int64); cdecl;
//function ntpTimeMs: Int64; cdecl;
//procedure setFlags(flags: Byte); cdecl;
//function flags: Byte; cdecl;
//procedure setEncodeStartMs(encodeStartMs: Int64); cdecl;
//function encodeStartMs: Int64; cdecl;
//procedure setEncodeFinishMs(encodeFinishMs: Int64); cdecl;
//function encodeFinishMs: Int64; cdecl;
//procedure setFrameType(frameType: RTCFrameType); cdecl;
//function frameType: RTCFrameType; cdecl;
//procedure setRotation(rotation: RTCVideoRotation); cdecl;
//function rotation: RTCVideoRotation; cdecl;
//procedure setCompleteFrame(completeFrame: Boolean); cdecl;
//function completeFrame: Boolean; cdecl;
//procedure setQp(qp: NSNumber); cdecl;
//function qp: NSNumber; cdecl;
//procedure setContentType(contentType: RTCVideoContentType); cdecl;
//function contentType: RTCVideoContentType; cdecl;
//end;
//TRTCEncodedImage = class(TOCGenericImport<RTCEncodedImageClass, RTCEncodedImage>) end;
//PRTCEncodedImage = Pointer;
//{*****************************************************}
//RTCVideoEncoderSettingsClass = interface(NSObjectClass)
//['{0CE09797-07F1-4609-A56B-2A0C412037CD}']
//end;
//RTCVideoEncoderSettings = interface(NSObject)
//['{2BA97AC8-2DAB-4E0F-86D4-8FDF1166F156}']
//procedure setName(name: NSString); cdecl;
//function name: NSString; cdecl;
//procedure setWidth(width: Word); cdecl;
//function width: Word; cdecl;
//procedure setHeight(height: Word); cdecl;
//function height: Word; cdecl;
//procedure setStartBitrate(startBitrate: Cardinal); cdecl;
//function startBitrate: Cardinal; cdecl;
//procedure setMaxBitrate(maxBitrate: Cardinal); cdecl;
//function maxBitrate: Cardinal; cdecl;
//procedure setMinBitrate(minBitrate: Cardinal); cdecl;
//function minBitrate: Cardinal; cdecl;
//procedure setTargetBitrate(targetBitrate: Cardinal); cdecl;
//function targetBitrate: Cardinal; cdecl;
//procedure setMaxFramerate(maxFramerate: LongWord); cdecl;
//function maxFramerate: LongWord; cdecl;
//procedure setQpMax(qpMax: Cardinal); cdecl;
//function qpMax: Cardinal; cdecl;
//procedure setMode(mode: RTCVideoCodecMode); cdecl;
//function mode: RTCVideoCodecMode; cdecl;
//end;
//TRTCVideoEncoderSettings = class(TOCGenericImport<RTCVideoEncoderSettingsClass, RTCVideoEncoderSettings>) end;
//PRTCVideoEncoderSettings = Pointer;
{****************************************************************************************}
//This decoder factory include support for all codecs bundled with WebRTC. If using custom
//codecs, create custom implementations of RTCVideoEncoderFactory and RTCVideoDecoderFactory.
//@interface RTCDefaultVideoDecoderFactory : NSObject <RTCVideoDecoderFactory>
RTCDefaultVideoDecoderFactoryClass = interface(NSObjectClass)
['{F72D68FF-8EC7-47AE-B260-37CF79B19418}']
end;
RTCDefaultVideoDecoderFactory = interface(NSObject)
['{6BD5BA9E-A505-460C-BBEF-2841DF55C7D3}']
end;
TRTCDefaultVideoDecoderFactory = class(TOCGenericImport<RTCDefaultVideoDecoderFactoryClass, RTCDefaultVideoDecoderFactory>) end;
PRTCDefaultVideoDecoderFactory = Pointer;
//{*******************************************************}
//RTCRtpFragmentationHeaderClass = interface(NSObjectClass)
//['{1DB1DFAD-ACBE-4F4C-95AE-D592774CB766}']
//end;
//RTCRtpFragmentationHeader = interface(NSObject)
//['{72DC1468-0712-4DED-8CB0-955DA0E21CD8}']
//procedure setFragmentationOffset(fragmentationOffset: NSArray); cdecl;
//function fragmentationOffset: NSArray; cdecl;
//procedure setFragmentationLength(fragmentationLength: NSArray); cdecl;
//function fragmentationLength: NSArray; cdecl;
//procedure setFragmentationTimeDiff(fragmentationTimeDiff: NSArray); cdecl;
//function fragmentationTimeDiff: NSArray; cdecl;
//procedure setFragmentationPlType(fragmentationPlType: NSArray); cdecl;
//function fragmentationPlType: NSArray; cdecl;
//end;
//TRTCRtpFragmentationHeader = class(TOCGenericImport<RTCRtpFragmentationHeaderClass, RTCRtpFragmentationHeader>) end;
//PRTCRtpFragmentationHeader = Pointer;
//{*********************************************************}
//RTCVideoEncoderQpThresholdsClass = interface(NSObjectClass)
//['{0B602B2D-CAD2-47BC-BDD6-90686D731BF1}']
//end;
//RTCVideoEncoderQpThresholds = interface(NSObject)
//['{A5687575-ABC5-44F9-9808-DA92EA96C774}']
//function initWithThresholdsLow(low: NSInteger; high: NSInteger): Pointer { instancetype }; cdecl;
//function low: NSInteger; cdecl;
//function high: NSInteger; cdecl;
//end;
//TRTCVideoEncoderQpThresholds = class(TOCGenericImport<RTCVideoEncoderQpThresholdsClass, RTCVideoEncoderQpThresholds>) end;
//PRTCVideoEncoderQpThresholds = Pointer;
{****************************************************************************************}
//This encoder factory include support for all codecs bundled with WebRTC. If using custom
//codecs, create custom implementations of RTCVideoEncoderFactory and RTCVideoDecoderFactory.
//@interface RTCDefaultVideoEncoderFactory : NSObject <RTCVideoEncoderFactory>
RTCDefaultVideoEncoderFactoryClass = interface(NSObjectClass)
['{06A55D95-5B90-4E2B-98F6-E03F35C746C3}']
//+ (NSArray<RTCVideoCodecInfo *> *)supportedCodecs;
{ class } function supportedCodecs: NSArray; cdecl;
end;
RTCDefaultVideoEncoderFactory = interface(NSObject)
['{1205BC8D-3182-42AD-BB6A-02E06E17A866}']
//@property(nonatomic, retain) RTCVideoCodecInfo *preferredCodec;
procedure setPreferredCodec(preferredCodec: RTCVideoCodecInfo); cdecl;
function preferredCodec: RTCVideoCodecInfo; cdecl;
end;
TRTCDefaultVideoEncoderFactory = class(TOCGenericImport<RTCDefaultVideoEncoderFactoryClass, RTCDefaultVideoEncoderFactory>) end;
PRTCDefaultVideoEncoderFactory = Pointer;
//{*******************************************}
//RTCDispatcherClass = interface(NSObjectClass)
//['{BE18E651-39AE-49CC-B161-0F83CE99E90E}']
//{ class } procedure dispatchAsyncOnType(dispatchType: RTCDispatcherQueueType; block: Pointer { dispatch_block_t } ); cdecl;
//{ class } function isOnQueueForType(dispatchType: RTCDispatcherQueueType): Boolean; cdecl;
//end;
//RTCDispatcher = interface(NSObject)
//['{53C8DE2D-B117-4265-92F4-5FE9BCE7FA76}']
//end;
//TRTCDispatcher = class(TOCGenericImport<RTCDispatcherClass, RTCDispatcher>) end;
//PRTCDispatcher = Pointer;
//{********************************************}
//RTCEAGLVideoViewClass = interface(UIViewClass)
//['{F498FC75-6552-49DD-8E8A-1F98B77DA8B7}']
//end;
//RTCEAGLVideoView = interface(UIView)
//['{CE927B4A-A238-4CCB-B371-A88236D87761}']
//procedure setDelegate(delegate: Pointer); cdecl;
//function delegate: Pointer; cdecl;
//function initWithFrame(frame: CGRect; shader: Pointer): Pointer { instancetype }; cdecl;
//function initWithCoder(aDecoder: NSCoder; shader: Pointer): Pointer { instancetype }; cdecl;
//end;
//TRTCEAGLVideoView = class(TOCGenericImport<RTCEAGLVideoViewClass, RTCEAGLVideoView>) end;
//PRTCEAGLVideoView = Pointer;
//{*******************************************}
//RTCFileLoggerClass = interface(NSObjectClass)
//['{8CFD272C-B1A1-4595-AE58-F2CCFA45DEA0}']
//end;
//RTCFileLogger = interface(NSObject)
//['{D5706349-63B1-4055-B178-25D937340C7E}']
//procedure setSeverity(severity: RTCFileLoggerSeverity); cdecl;
//function severity: RTCFileLoggerSeverity; cdecl;
//function rotationType: RTCFileLoggerRotationType; cdecl;
//procedure setShouldDisableBuffering(shouldDisableBuffering: Boolean); cdecl;
//function shouldDisableBuffering: Boolean; cdecl;
//function init: Pointer { instancetype }; cdecl;
//[MethodName('initWithDirPath:maxFileSize:')]
//function initWithDirPathMaxFileSize(dirPath: NSString; maxFileSize: NSUInteger): Pointer { instancetype }; cdecl;
//[MethodName('initWithDirPath:maxFileSize:rotationType:')]
//function initWithDirPathMaxFileSizeRotationType(dirPath: NSString; maxFileSize: NSUInteger; rotationType: RTCFileLoggerRotationType): Pointer { instancetype }; cdecl;
//procedure start; cdecl;
//procedure stop; cdecl;
//function logData: NSData; cdecl;
//end;
//TRTCFileLogger = class(TOCGenericImport<RTCFileLoggerClass, RTCFileLogger>) end;
//PRTCFileLogger = Pointer;
//{**********************************************************}
//RTCFileVideoCapturerClass = interface(RTCVideoCapturerClass)
//['{B039F9AD-EB1C-45C0-97DD-9F25828B6420}']
//end;
//RTCFileVideoCapturer = interface(RTCVideoCapturer)
//['{61A9BD01-16F2-4244-B1A0-0D7894DA5E95}']
//procedure startCapturingFromFileNamed(nameOfFile: NSString; onError: RTCFileVideoCapturerErrorBlock); cdecl;
//procedure stopCapture; cdecl;
//end;
//TRTCFileVideoCapturer = class(TOCGenericImport<RTCFileVideoCapturerClass, RTCFileVideoCapturer>) end;
//PRTCFileVideoCapturer = Pointer;
{*******************************************}
//@interface RTCH264ProfileLevelId : NSObject
RTCH264ProfileLevelIdClass = interface(NSObjectClass)
['{4967D0E3-E801-4551-9529-D81B051D4075}']
end;
RTCH264ProfileLevelId = interface(NSObject)
['{4961CCA6-548C-44A1-BC10-3D9884820149}']
//@property(nonatomic, readonly) RTCH264Profile profile;
function profile: RTCH264Profile; cdecl;
//@property(nonatomic, readonly) RTCH264Level level;
function level: RTCH264Level; cdecl;
//@property(nonatomic, readonly) NSString *hexString;
function hexString: NSString; cdecl;
//- (instancetype)initWithHexString:(NSString *)hexString;
function initWithHexString(hexString: NSString): Pointer { instancetype }; cdecl;
//- (instancetype)initWithProfile:(RTCH264Profile)profile level:(RTCH264Level)level;
function initWithProfile(profile: RTCH264Profile; level: RTCH264Level): Pointer { instancetype }; cdecl;
end;
TRTCH264ProfileLevelId = class(TOCGenericImport<RTCH264ProfileLevelIdClass, RTCH264ProfileLevelId>) end;
PRTCH264ProfileLevelId = Pointer;
{*************************************}
//@interface RTCIceCandidate : NSObject
RTCIceCandidateClass = interface(NSObjectClass)
['{A096C28C-D525-4E4C-8875-5235481CDAB9}']
end;
RTCIceCandidate = interface(NSObject)
['{029E5282-6864-4B38-B93A-9449CDF82EF7}']
//If present, the identifier of the "media stream identification" for the media
//component this candidate is associated with.
//@property(nonatomic, readonly, nullable) NSString *sdpMid;
function sdpMid: NSString; cdecl;
//The index (starting at zero) of the media description this candidate is
//associated with in the SDP.
//@property(nonatomic, readonly) int sdpMLineIndex;
function sdpMLineIndex: Integer; cdecl;
//The SDP string for this candidate.
//@property(nonatomic, readonly) NSString *sdp;
function sdp: NSString; cdecl;
//The URL of the ICE server which this candidate is gathered from.
//@property(nonatomic, readonly, nullable) NSString *serverUrl;
function serverUrl: NSString; cdecl;
//- (instancetype)init NS_UNAVAILABLE;
//Initialize an RTCIceCandidate from SDP.
//- (instancetype)initWithSdp:(NSString *)sdp
// sdpMLineIndex:(int)sdpMLineIndex
// sdpMid:(nullable NSString *)sdpMid NS_DESIGNATED_INITIALIZER;
function initWithSdp(sdp: NSString; sdpMLineIndex: Integer; sdpMid: NSString): Pointer { instancetype }; cdecl;
end;
TRTCIceCandidate = class(TOCGenericImport<RTCIceCandidateClass, RTCIceCandidate>) end;
PRTCIceCandidate = Pointer;
//{**************************************************}
//RTCLegacyStatsReportClass = interface(NSObjectClass)
//['{6CDFB5E6-6BBC-410E-B34E-7AE4030A3BD7}']
//end;
//RTCLegacyStatsReport = interface(NSObject)
//['{173B5644-F310-4338-A0A3-13779F046F24}']
//function timeStamp: CFTimeInterval; cdecl;
//function &type: NSString; cdecl;
//function reportId: NSString; cdecl;
//function values: NSDictionary; cdecl;
//end;
//TRTCLegacyStatsReport = class(TOCGenericImport<RTCLegacyStatsReportClass, RTCLegacyStatsReport>) end;
//PRTCLegacyStatsReport = Pointer;
{*****************************************}
//@interface RTCMediaConstraints : NSObject
RTCMediaConstraintsClass = interface(NSObjectClass)
['{8235D2CB-7359-4F52-9F78-7BF285C1BE26}']
end;
RTCMediaConstraints = interface(NSObject)
['{99D7E0CC-E384-4C0E-9B41-B6E3411568D8}']
//- (instancetype)init NS_UNAVAILABLE;
//Initialize with mandatory and/or optional constraints.
//- (instancetype)
// initWithMandatoryConstraints:(nullable NSDictionary<NSString *, NSString *> *)mandatory
// optionalConstraints:(nullable NSDictionary<NSString *, NSString *> *)optional
// NS_DESIGNATED_INITIALIZER;
function initWithMandatoryConstraints(mandatory: NSDictionary; optionalConstraints: NSDictionary): Pointer { instancetype }; cdecl;
end;
TRTCMediaConstraints = class(TOCGenericImport<RTCMediaConstraintsClass, RTCMediaConstraints>) end;
PRTCMediaConstraints = Pointer;
{**********************************************}
//@interface RTCPeerConnectionFactory : NSObject
RTCPeerConnectionFactoryClass = interface(NSObjectClass)
['{60AF5637-A719-4C21-A04A-FE89DA61E82B}']
end;
RTCPeerConnectionFactory = interface(NSObject)
['{AC489494-5259-4C88-81A9-6AA20A16E36A}']
//Initialize object with default H264 video encoder/decoder factories
//- (instancetype)init;
function init: Pointer { instancetype }; cdecl;
//Initialize object with injectable video encoder/decoder factories
//- (instancetype)initWithEncoderFactory:(nullable id<RTCVideoEncoderFactory>)encoderFactory
// decoderFactory:(nullable id<RTCVideoDecoderFactory>)decoderFactory;
function initWithEncoderFactory(encoderFactory: Pointer; decoderFactory: Pointer): Pointer { instancetype }; cdecl;
//Initialize an RTCAudioSource with constraints.
//- (RTCAudioSource *)audioSourceWithConstraints:(nullable RTCMediaConstraints *)constraints;
function audioSourceWithConstraints(constraints: RTCMediaConstraints): RTCAudioSource; cdecl;
//Initialize an RTCAudioTrack with an id. Convenience ctor to use an audio source with no constraints.
//- (RTCAudioTrack *)audioTrackWithTrackId:(NSString *)trackId;
//function audioTrackWithTrackId(trackId: NSString): RTCAudioTrack; cdecl;
//Initialize an RTCAudioTrack with a source and an id.
//- (RTCAudioTrack *)audioTrackWithSource:(RTCAudioSource *)source trackId:(NSString *)trackId;
function audioTrackWithSource(source: RTCAudioSource; trackId: NSString): RTCAudioTrack; cdecl;
//Initialize a generic RTCVideoSource. The RTCVideoSource should be passed to a RTCVideoCapturer
//implementation, e.g. RTCCameraVideoCapturer, in order to produce frames.
//- (RTCVideoSource *)videoSource;
function videoSource: RTCVideoSource; cdecl;
//Initialize an RTCVideoTrack with a source and an id.
//- (RTCVideoTrack *)videoTrackWithSource:(RTCVideoSource *)source trackId:(NSString *)trackId;
function videoTrackWithSource(source: RTCVideoSource; trackId: NSString): RTCVideoTrack; cdecl;
//Initialize an RTCMediaStream with an id.
//- (RTCMediaStream *)mediaStreamWithStreamId:(NSString *)streamId;
//function mediaStreamWithStreamId(streamId: NSString): RTCMediaStream; cdecl;
//Initialize an RTCPeerConnection with a configuration, constraints, and delegate.
//- (RTCPeerConnection *)peerConnectionWithConfiguration:(RTCConfiguration *)configuration
// constraints:(RTCMediaConstraints *)constraints
// delegate:(nullable id<RTCPeerConnectionDelegate>)delegate;
function peerConnectionWithConfiguration(configuration: RTCConfiguration; constraints: RTCMediaConstraints; delegate: Pointer): RTCPeerConnection; cdecl;
//Set the options to be used for subsequently created RTCPeerConnections
//- (void)setOptions:(nonnull RTCPeerConnectionFactoryOptions *)options;
//procedure setOptions(options: RTCPeerConnectionFactoryOptions); cdecl;
//Start an AecDump recording. This API call will likely change in the future.
//- (BOOL)startAecDumpWithFilePath:(NSString *)filePath maxSizeInBytes:(int64_t)maxSizeInBytes;
//function startAecDumpWithFilePath(filePath: NSString; maxSizeInBytes: Int64): Boolean; cdecl;
//Stop an active AecDump recording
//- (void)stopAecDump;
//procedure stopAecDump; cdecl;
end;
TRTCPeerConnectionFactory = class(TOCGenericImport<RTCPeerConnectionFactoryClass, RTCPeerConnectionFactory>) end;
PRTCPeerConnectionFactory = Pointer;
{**********************************************}
//@interface RTCVideoTrack : RTCMediaStreamTrack
RTCVideoTrackClass = interface(RTCMediaStreamTrackClass)
['{42239C62-26A1-46EA-87EC-B897743D22A4}']
end;
RTCVideoTrack = interface(RTCMediaStreamTrack)
['{E87017EA-5159-4770-BC33-BFBE9BD5AE86}']
//The video source for this video track.
//@property(nonatomic, readonly) RTCVideoSource *source;
function source: RTCVideoSource; cdecl;
//- (instancetype)init NS_UNAVAILABLE;
//Register a renderer that will render all frames received on this track.
//- (void)addRenderer:(id<RTCVideoRenderer>)renderer;
procedure addRenderer(renderer: Pointer); cdecl;
//Deregister a renderer.
//- (void)removeRenderer:(id<RTCVideoRenderer>)renderer;
procedure removeRenderer(renderer: Pointer); cdecl;
end;
TRTCVideoTrack = class(TOCGenericImport<RTCVideoTrackClass, RTCVideoTrack>) end;
PRTCVideoTrack = Pointer;
{************************************}
//@interface RTCMediaStream : NSObject
RTCMediaStreamClass = interface(NSObjectClass)
['{DD661051-CD33-460C-A285-BDE3C672670D}']
end;
RTCMediaStream = interface(NSObject)
['{89DE6B02-4016-4CF2-9164-59C006DF9B4A}']
//The audio tracks in this stream.
//@property(nonatomic, strong, readonly) NSArray<RTCAudioTrack *> *audioTracks;
//function audioTracks: NSArray; cdecl;
//The video tracks in this stream.
//@property(nonatomic, strong, readonly) NSArray<RTCVideoTrack *> *videoTracks;
//function videoTracks: NSArray; cdecl;
//An identifier for this media stream.
//@property(nonatomic, readonly) NSString *streamId;
function streamId: NSString; cdecl;
//- (instancetype)init NS_UNAVAILABLE;
//Adds the given audio track to this media stream.
//- (void)addAudioTrack:(RTCAudioTrack *)audioTrack;
//procedure addAudioTrack(audioTrack: RTCAudioTrack); cdecl;
//Adds the given video track to this media stream.
//- (void)addVideoTrack:(RTCVideoTrack *)videoTrack;
//procedure addVideoTrack(videoTrack: RTCVideoTrack); cdecl;
//Removes the given audio track to this media stream.
//- (void)removeAudioTrack:(RTCAudioTrack *)audioTrack;
//procedure removeAudioTrack(audioTrack: RTCAudioTrack); cdecl;
//Removes the given video track to this media stream.
//- (void)removeVideoTrack:(RTCVideoTrack *)videoTrack;
//procedure removeVideoTrack(videoTrack: RTCVideoTrack); cdecl;
end;
TRTCMediaStream = class(TOCGenericImport<RTCMediaStreamClass, RTCMediaStream>) end;
PRTCMediaStream = Pointer;
//{**************************************************}
//RTCMetricsSampleInfoClass = interface(NSObjectClass)
//['{3299719D-AFF9-4EC0-B86F-9DB3CB1334C1}']
//end;
//RTCMetricsSampleInfo = interface(NSObject)
//['{A909A86F-F4C3-42DF-8B46-E7479A6A674D}']
//function name: NSString; cdecl;
//function min: Integer; cdecl;
//function max: Integer; cdecl;
//function bucketCount: Integer; cdecl;
//function samples: NSDictionary; cdecl;
//end;
//TRTCMetricsSampleInfo = class(TOCGenericImport<RTCMetricsSampleInfoClass, RTCMetricsSampleInfo>) end;
//PRTCMetricsSampleInfo = Pointer;
//{*******************************************}
//RTCMTLVideoViewClass = interface(UIViewClass)
//['{BA32C167-DB82-4A95-87AD-14D09A9D54AC}']
//end;
//RTCMTLVideoView = interface(UIView)
//['{5FA2C7EE-0A9E-470F-B434-9C8530CD29C0}']
//procedure setDelegate(delegate: Pointer); cdecl;
//function delegate: Pointer; cdecl;
//procedure setVideoContentMode(videoContentMode: UIViewContentMode); cdecl;
//function videoContentMode: UIViewContentMode; cdecl;
//procedure setEnabled(enabled: Boolean); cdecl;
//function isEnabled: Boolean; cdecl;
//procedure setRotationOverride(rotationOverride: NSValue); cdecl;
//function rotationOverride: NSValue; cdecl;
//end;
//TRTCMTLVideoView = class(TOCGenericImport<RTCMTLVideoViewClass, RTCMTLVideoView>) end;
//PRTCMTLVideoView = Pointer;
{*******************************************}
RTCI420BufferClass = interface(NSObjectClass)
['{CD148B90-CE83-4B88-BE05-4248C65A57B3}']
end;
RTCI420Buffer = interface(NSObject)
['{EBB60134-F56C-441D-8407-4C628BD81CE4}']
//@property(nonatomic, readonly) int width;
function width: Integer; cdecl;
//@property(nonatomic, readonly) int height;
function height: Integer; cdecl;
//- (id<RTCI420Buffer>)toI420;
//function toI420: Pointer; cdecl;
//@property(nonatomic, readonly) int chromaWidth;
function chromaWidth: Integer; cdecl;
//@property(nonatomic, readonly) int chromaHeight;
function chromaHeight: Integer; cdecl;
//@property(nonatomic, readonly) const uint8_t *dataY;
function dataY: PByte; cdecl;
//@property(nonatomic, readonly) const uint8_t *dataU;
function dataU: PByte; cdecl;
//@property(nonatomic, readonly) const uint8_t *dataV;
function dataV: PByte; cdecl;
//@property(nonatomic, readonly) int strideY;
function strideY: Integer; cdecl;
//@property(nonatomic, readonly) int strideU;
function strideU: Integer; cdecl;
//@property(nonatomic, readonly) int strideV;
function strideV: Integer; cdecl;
//- (instancetype)initWithWidth:(int)width
// height:(int)height
// dataY:(const uint8_t *)dataY
// dataU:(const uint8_t *)dataU
// dataV:(const uint8_t *)dataV;
//[MethodName('initWithWidth:height:dataY:dataU:dataV:')]
//function initWithWidthHeightDataYDataUDataV(width: Integer; height: Integer; dataY: PByte; dataU: PByte; dataV: PByte): Pointer { instancetype }; cdecl;
//- (instancetype)initWithWidth:(int)width height:(int)height;
//[MethodName('initWithWidth:height:')]
//function initWithWidthHeight(width: Integer; height: Integer): Pointer { instancetype }; cdecl;
//- (instancetype)initWithWidth:(int)width
// height:(int)height
// strideY:(int)strideY
// strideU:(int)strideU
// strideV:(int)strideV;
//[MethodName('initWithWidth:height:strideY:strideU:strideV:')]
//function initWithWidthHeightStrideYStrideUStrideV(width: Integer; height: Integer; strideY: Integer; strideU: Integer; strideV: Integer): Pointer { instancetype }; cdecl;
end;
TRTCI420Buffer = class(TOCGenericImport<RTCI420BufferClass, RTCI420Buffer>) end;
PRTCI420Buffer = Pointer;
//{*******************************************}
//RTCMutableI420Buffer = interface(IObjectiveC)
//['{EEB18C16-8EBF-462A-8FA0-EDEC2F03E588}']
//end;
{***********************************}
//@protocol RTCRtpReceiver <NSObject>
//@interface RTCRtpReceiver : NSObject <RTCRtpReceiver>
RTCRtpReceiverClass = interface(NSObjectClass)
['{1AAB73CC-2B5B-41B4-8771-CBFCF003223F}']
end;
RTCRtpReceiver = interface(NSObject)
['{C24EB32B-1630-457B-A0F8-F495370ADF57}']
//A unique identifier for this receiver.
//@property(nonatomic, readonly) NSString *receiverId;
//function receiverId: NSString; cdecl;
//The currently active RTCRtpParameters, as defined in
//https://www.w3.org/TR/webrtc/#idl-def-RTCRtpParameters.
//The WebRTC specification only defines RTCRtpParameters in terms of senders,
//but this API also applies them to receivers, similar to ORTC:
//http://ortc.org/wp-content/uploads/2016/03/ortc.html#rtcrtpparameters*.
//@property(nonatomic, readonly) RTCRtpParameters *parameters;
//function parameters: RTCRtpParameters; cdecl;
//The RTCMediaStreamTrack associated with the receiver.
//Note: reading this property returns a new instance of
//RTCMediaStreamTrack. Use isEqual: instead of == to compare
//RTCMediaStreamTrack instances.
//@property(nonatomic, readonly, nullable) RTCMediaStreamTrack *track;
function track: RTCMediaStreamTrack; cdecl;
//The delegate for this RtpReceiver.
//@property(nonatomic, weak) id<RTCRtpReceiverDelegate> delegate;
//procedure setDelegate(delegate: Pointer); cdecl;
//function delegate: Pointer; cdecl;
end;
TRTCRtpReceiver = class(TOCGenericImport<RTCRtpReceiverClass, RTCRtpReceiver>) end;
PRTCRtpReceiver = Pointer;
{*********************************}
//@protocol RTCRtpSender <NSObject>
RTCRtpSenderClass = interface(NSObjectClass)
['{0AE0ED18-0EB7-485A-B6AF-0730F5608655}']
end;
RTCRtpSender = interface(NSObject)
['{F51462D8-AC7F-45DB-9B4C-6D8237AD14AB}']
//A unique identifier for this sender.
//@property(nonatomic, readonly) NSString *senderId;
//function senderId: NSString; cdecl;
//The currently active RTCRtpParameters, as defined in
//https://www.w3.org/TR/webrtc/#idl-def-RTCRtpParameters.
//@property(nonatomic, copy) RTCRtpParameters *parameters;
procedure setParameters(parameters: RTCRtpParameters); cdecl;
function parameters: RTCRtpParameters; cdecl;
//The RTCMediaStreamTrack associated with the sender.
//Note: reading this property returns a new instance of
//RTCMediaStreamTrack. Use isEqual: instead of == to compare
//RTCMediaStreamTrack instances.
//@property(nonatomic, copy, nullable) RTCMediaStreamTrack *track;
procedure setTrack(track: RTCMediaStreamTrack); cdecl;
function track: RTCMediaStreamTrack; cdecl;
//The RTCDtmfSender accociated with the RTP sender.
//@property(nonatomic, readonly, nullable) id<RTCDtmfSender> dtmfSender;
//function dtmfSender: Pointer; cdecl;
end;
TRTCRtpSender = class(TOCGenericImport<RTCRtpSenderClass, RTCRtpSender>) end;
PRTCRtpSender = Pointer;
{*************************}
//The RTCRtpTransceiver maps to the RTCRtpTransceiver defined by the WebRTC
//specification. A transceiver represents a combination of an RTCRtpSender
//and an RTCRtpReceiver that share a common mid. As defined in JSEP, an
//RTCRtpTransceiver is said to be associated with a media description if its
//mid property is non-nil; otherwise, it is said to be disassociated.
//JSEP: https://tools.ietf.org/html/draft-ietf-rtcweb-jsep-24
//Note that RTCRtpTransceivers are only supported when using
//RTCPeerConnection with Unified Plan SDP.
//WebRTC specification for RTCRtpTransceiver, the JavaScript analog:
//https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver
//@protocol RTCRtpTransceiver <NSObject>
//@interface RTCRtpTransceiver : NSObject <RTCRtpTransceiver>
RTCRtpTransceiverClass = interface(NSObjectClass)
['{86DACB46-DC39-493E-9B6F-CC1A998D351A}']
end;
RTCRtpTransceiver = interface(NSObject)
['{3322A9ED-3447-4596-BEE6-B7F3E9A71B4A}']
//Media type of the transceiver. The sender and receiver will also have this
//type.
//@property(nonatomic, readonly) RTCRtpMediaType mediaType;
function mediaType: RTCRtpMediaType; cdecl;
//The mid attribute is the mid negotiated and present in the local and
//remote descriptions. Before negotiation is complete, the mid value may be
//nil. After rollbacks, the value may change from a non-nil value to nil.
//https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-mid
//@property(nonatomic, readonly) NSString *mid;
//function mid: NSString; cdecl;
//The sender attribute exposes the RTCRtpSender corresponding to the RTP
//media that may be sent with the transceiver's mid. The sender is always
//present, regardless of the direction of media.
//https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-sender
//@property(nonatomic, readonly) RTCRtpSender *sender;
//function sender: RTCRtpSender; cdecl;
//The receiver attribute exposes the RTCRtpReceiver corresponding to the RTP
//media that may be received with the transceiver's mid. The receiver is
//always present, regardless of the direction of media.
//https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-receiver
//@property(nonatomic, readonly) RTCRtpReceiver *receiver;
function receiver: RTCRtpReceiver; cdecl;
//The isStopped attribute indicates that the sender of this transceiver will
//no longer send, and that the receiver will no longer receive. It is true if
//either stop has been called or if setting the local or remote description
//has caused the RTCRtpTransceiver to be stopped.
//https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-stopped
//@property(nonatomic, readonly) BOOL isStopped;
//function isStopped: Boolean; cdecl;
//The direction attribute indicates the preferred direction of this
//transceiver, which will be used in calls to createOffer and createAnswer.
//An update of directionality does not take effect immediately. Instead,
//future calls to createOffer and createAnswer mark the corresponding media
//descriptions as sendrecv, sendonly, recvonly, or inactive.
//https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-direction
//@property(nonatomic) RTCRtpTransceiverDirection direction;
//procedure setDirection(direction: RTCRtpTransceiverDirection); cdecl;
//function direction: RTCRtpTransceiverDirection; cdecl;
//The currentDirection attribute indicates the current direction negotiated
//for this transceiver. If this transceiver has never been represented in an
//offer/answer exchange, or if the transceiver is stopped, the value is not
//present and this method returns NO.
//https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-currentdirection
//- (BOOL)currentDirection:(RTCRtpTransceiverDirection *)currentDirectionOut;
//function currentDirection(currentDirectionOut: PRTCRtpTransceiverDirection): Boolean; cdecl;
//The stop method irreversibly stops the RTCRtpTransceiver. The sender of
//this transceiver will no longer send, the receiver will no longer receive.
//https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-stop
//- (void)stop;
//procedure stop; cdecl;
end;
TRTCRtpTransceiver = class(TOCGenericImport<RTCRtpTransceiverClass, RTCRtpTransceiver>) end;
PRTCRtpTransceiver = Pointer;
//{***************************************************}
//RTCRtpTransceiverInitClass = interface(NSObjectClass)
//['{2A8922EB-41E8-41E6-966F-26C914045A32}']
//end;
//RTCRtpTransceiverInit = interface(NSObject)
//['{49DD4612-4E85-40E0-8FF4-A53B35217CE9}']
//procedure setDirection(direction: RTCRtpTransceiverDirection); cdecl;
//function direction: RTCRtpTransceiverDirection; cdecl;
//procedure setStreamIds(streamIds: NSArray); cdecl;
//function streamIds: NSArray; cdecl;
//procedure setSendEncodings(sendEncodings: NSArray); cdecl;
//function sendEncodings: NSArray; cdecl;
//end;
//TRTCRtpTransceiverInit = class(TOCGenericImport<RTCRtpTransceiverInitClass, RTCRtpTransceiverInit>) end;
//PRTCRtpTransceiverInit = Pointer;
{***************************************************}
RTCSessionDescriptionClass = interface(NSObjectClass)
['{A5B3B5A3-5F03-4ED0-B9CC-3A8B0E894050}']
//+ (NSString *)stringForType:(RTCSdpType)type;
{ class } function stringForType(&type: RTCSdpType): NSString; cdecl;
//+ (RTCSdpType)typeForString:(NSString *)string;
{ class } function typeForString(&string: NSString): RTCSdpType; cdecl;
end;
RTCSessionDescription = interface(NSObject)
['{E3C8A270-2141-4F67-BDC5-36F42368E506}']
//The type of session description.
//@property(nonatomic, readonly) RTCSdpType type;
function &type: RTCSdpType; cdecl;
//The SDP string representation of this session description.
//@property(nonatomic, readonly) NSString *sdp;
function sdp: NSString; cdecl;
//- (instancetype)init NS_UNAVAILABLE;
//Initialize a session description with a type and SDP string.
//- (instancetype)initWithType:(RTCSdpType)type sdp:(NSString *)sdp NS_DESIGNATED_INITIALIZER;
function initWithType(&type: RTCSdpType; sdp: NSString): Pointer { instancetype }; cdecl;
end;
TRTCSessionDescription = class(TOCGenericImport<RTCSessionDescriptionClass, RTCSessionDescription>) end;
PRTCSessionDescription = Pointer;
{***********************************************}
//@interface RTCPeerConnection : NSObject
RTCPeerConnectionClass = interface(NSObjectClass)
['{72035A56-D3E9-42F0-BA42-986BC2E10196}']
end;
RTCPeerConnection = interface(NSObject)
['{F5473616-4DB0-4E75-B869-555761CA6794}']
//The object that will be notifed about events such as state changes and
//streams being added or removed.
//@property(nonatomic, weak, nullable) id<RTCPeerConnectionDelegate> delegate;
procedure setDelegate(delegate: Pointer); cdecl;
function delegate: Pointer; cdecl;
//This property is not available with RTCSdpSemanticsUnifiedPlan. Please use
//|senders| instead.
//@property(nonatomic, readonly) NSArray<RTCMediaStream *> *localStreams;
//function localStreams: NSArray; cdecl;
//@property(nonatomic, readonly, nullable) RTCSessionDescription *localDescription;
function localDescription: RTCSessionDescription; cdecl;
//@property(nonatomic, readonly, nullable) RTCSessionDescription *remoteDescription;
function remoteDescription: RTCSessionDescription; cdecl;
//@property(nonatomic, readonly) RTCSignalingState signalingState;
function signalingState: RTCSignalingState; cdecl;
//@property(nonatomic, readonly) RTCIceConnectionState iceConnectionState;
function iceConnectionState: RTCIceConnectionState; cdecl;
//@property(nonatomic, readonly) RTCIceGatheringState iceGatheringState;
function iceGatheringState: RTCIceGatheringState; cdecl;
//@property(nonatomic, readonly, copy) RTCConfiguration *configuration;
//function configuration: RTCConfiguration; cdecl;
//Gets all RTCRtpSenders associated with this peer connection.
//Note: reading this property returns different instances of RTCRtpSender.
//Use isEqual: instead of == to compare RTCRtpSender instances.
//@property(nonatomic, readonly) NSArray<RTCRtpSender *> *senders;
function senders: NSArray; cdecl;
//Gets all RTCRtpReceivers associated with this peer connection.
//Note: reading this property returns different instances of RTCRtpReceiver.
//Use isEqual: instead of == to compare RTCRtpReceiver instances.
//@property(nonatomic, readonly) NSArray<RTCRtpReceiver *> *receivers;
//function receivers: NSArray; cdecl;
//Gets all RTCRtpTransceivers associated with this peer connection.
//Note: reading this property returns different instances of
//RTCRtpTransceiver. Use isEqual: instead of == to compare RTCRtpTransceiver
//instances.
//This is only available with RTCSdpSemanticsUnifiedPlan specified.
//@property(nonatomic, readonly) NSArray<RTCRtpTransceiver *> *transceivers;
function transceivers: NSArray; cdecl;
//- (instancetype)init NS_UNAVAILABLE;
//Sets the PeerConnection's global configuration to |configuration|.
//Any changes to STUN/TURN servers or ICE candidate policy will affect the
//next gathering phase, and cause the next call to createOffer to generate
//new ICE credentials. Note that the BUNDLE and RTCP-multiplexing policies
//cannot be changed with this method.
//- (BOOL)setConfiguration:(RTCConfiguration *)configuration;
//function setConfiguration(configuration: RTCConfiguration): Boolean; cdecl;
//Terminate all media and close the transport.
//- (void)close;
procedure close; cdecl;
//Provide a remote candidate to the ICE Agent.
//- (void)addIceCandidate:(RTCIceCandidate *)candidate;
procedure addIceCandidate(candidate: RTCIceCandidate); cdecl;
//Remove a group of remote candidates from the ICE Agent.
//- (void)removeIceCandidates:(NSArray<RTCIceCandidate *> *)candidates;
procedure removeIceCandidates(candidates: NSArray); cdecl;
//Add a new media stream to be sent on this peer connection.
//This method is not supported with RTCSdpSemanticsUnifiedPlan. Please use
//addTrack instead.
//- (void)addStream:(RTCMediaStream *)stream;
//procedure addStream(stream: RTCMediaStream); cdecl;
//Remove the given media stream from this peer connection.
//This method is not supported with RTCSdpSemanticsUnifiedPlan. Please use
//removeTrack instead.
//- (void)removeStream:(RTCMediaStream *)stream;
//procedure removeStream(stream: RTCMediaStream); cdecl;
//Add a new media stream track to be sent on this peer connection, and return
//the newly created RTCRtpSender. The RTCRtpSender will be associated with
//the streams specified in the |streamIds| list.
//
//Errors: If an error occurs, returns nil. An error can occur if:
//- A sender already exists for the track.
//- The peer connection is closed.
//- (RTCRtpSender *)addTrack:(RTCMediaStreamTrack *)track streamIds:(NSArray<NSString *> *)streamIds;
function addTrack(track: RTCMediaStreamTrack; streamIds: NSArray): RTCRtpSender; cdecl;
//With PlanB semantics, removes an RTCRtpSender from this peer connection.
//
//With UnifiedPlan semantics, sets sender's track to null and removes the
//send component from the associated RTCRtpTransceiver's direction.
//
//Returns YES on success.
//- (BOOL)removeTrack:(RTCRtpSender *)sender;
function removeTrack(sender: RTCRtpSender): Boolean; cdecl;
//addTransceiver creates a new RTCRtpTransceiver and adds it to the set of
//transceivers. Adding a transceiver will cause future calls to CreateOffer
//to add a media description for the corresponding transceiver.
//
//The initial value of |mid| in the returned transceiver is nil. Setting a
//new session description may change it to a non-nil value.
//
//https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-addtransceiver
//
//Optionally, an RtpTransceiverInit structure can be specified to configure
//the transceiver from construction. If not specified, the transceiver will
//default to having a direction of kSendRecv and not be part of any streams.
//
//These methods are only available when Unified Plan is enabled (see
//RTCConfiguration).
//
//Adds a transceiver with a sender set to transmit the given track. The kind
//of the transceiver (and sender/receiver) will be derived from the kind of
//the track.
//- (RTCRtpTransceiver *)addTransceiverWithTrack:(RTCMediaStreamTrack *)track;
//[MethodName('addTransceiverWithTrack:')]
//function addTransceiverWithTrack(track: RTCMediaStreamTrack): RTCRtpTransceiver; cdecl;
//- (RTCRtpTransceiver *)addTransceiverWithTrack:(RTCMediaStreamTrack *)track
// init:(RTCRtpTransceiverInit *)init;
//[MethodName('addTransceiverWithTrack:init:')]
//function addTransceiverWithTrackInit(track: RTCMediaStreamTrack; init: RTCRtpTransceiverInit): RTCRtpTransceiver; cdecl;
//Adds a transceiver with the given kind. Can either be RTCRtpMediaTypeAudio
//or RTCRtpMediaTypeVideo.
//- (RTCRtpTransceiver *)addTransceiverOfType:(RTCRtpMediaType)mediaType;
//[MethodName('addTransceiverOfType:')]
//function addTransceiverOfType(mediaType: RTCRtpMediaType): RTCRtpTransceiver; cdecl;
//- (RTCRtpTransceiver *)addTransceiverOfType:(RTCRtpMediaType)mediaType
// init:(RTCRtpTransceiverInit *)init;
//[MethodName('addTransceiverOfType:init:')]
//function addTransceiverOfTypeInit(mediaType: RTCRtpMediaType; init: RTCRtpTransceiverInit): RTCRtpTransceiver; cdecl;
//Generate an SDP offer.
//- (void)offerForConstraints:(RTCMediaConstraints *)constraints
// completionHandler:(nullable void (^)(RTCSessionDescription *_Nullable sdp,
// NSError *_Nullable error))completionHandler;
procedure offerForConstraints(constraints: RTCMediaConstraints; completionHandler: TWebRTCPeerConnectionOfferForConstraintsCompletionHandler); cdecl;
//Generate an SDP answer.
//- (void)answerForConstraints:(RTCMediaConstraints *)constraints
// completionHandler:(nullable void (^)(RTCSessionDescription *_Nullable sdp,
// NSError *_Nullable error))completionHandler;
procedure answerForConstraints(constraints: RTCMediaConstraints; completionHandler: TWebRTCPeerConnectionAnswerForConstraintsCompletionHandler); cdecl;
//Apply the supplied RTCSessionDescription as the local description.
//- (void)setLocalDescription:(RTCSessionDescription *)sdp
// completionHandler:(nullable void (^)(NSError *_Nullable error))completionHandler;
procedure setLocalDescription(sdp: RTCSessionDescription; completionHandler: TWebRTCPeerConnectionSetLocalDescriptionCompletionHandler); cdecl;
//Apply the supplied RTCSessionDescription as the remote description.
//- (void)setRemoteDescription:(RTCSessionDescription *)sdp
// completionHandler:(nullable void (^)(NSError *_Nullable error))completionHandler;
procedure setRemoteDescription(sdp: RTCSessionDescription; completionHandler: TWebRTCPeerConnectionSetRemoteDescriptionCompletionHandler); cdecl;
//Limits the bandwidth allocated for all RTP streams sent by this
//PeerConnection. Nil parameters will be unchanged. Setting
//|currentBitrateBps| will force the available bitrate estimate to the given
//value. Returns YES if the parameters were successfully updated.
//- (BOOL)setBweMinBitrateBps:(nullable NSNumber *)minBitrateBps
// currentBitrateBps:(nullable NSNumber *)currentBitrateBps
// maxBitrateBps:(nullable NSNumber *)maxBitrateBps;
//function setBweMinBitrateBps(minBitrateBps: NSNumber; currentBitrateBps: NSNumber; maxBitrateBps: NSNumber): Boolean; cdecl;
//Start or stop recording an Rtc EventLog.
//- (BOOL)startRtcEventLogWithFilePath:(NSString *)filePath maxSizeInBytes:(int64_t)maxSizeInBytes;
function startRtcEventLogWithFilePath(filePath: NSString; maxSizeInBytes: Int64): Boolean; cdecl;
//- (void)stopRtcEventLog;
procedure stopRtcEventLog; cdecl;
//Create an RTCRtpSender with the specified kind and media stream ID.
//See RTCMediaStreamTrack.h for available kinds.
//This method is not supported with RTCSdpSemanticsUnifiedPlan. Please use
//addTransceiver instead.
//- (RTCRtpSender *)senderWithKind:(NSString *)kind streamId:(NSString *)streamId;
//function senderWithKind(kind: NSString; streamId: NSString): RTCRtpSender; cdecl;
//Create a new data channel with the given label and configuration.
//- (nullable RTCDataChannel *)dataChannelForLabel:(NSString *)label
// configuration:(RTCDataChannelConfiguration *)configuration;
//function dataChannelForLabel(&label: NSString; configuration: RTCDataChannelConfiguration): RTCDataChannel; cdecl;
//Gather stats for the given RTCMediaStreamTrack. If |mediaStreamTrack| is nil
//statistics are gathered for all tracks.
//- (void)statsForTrack:(nullable RTCMediaStreamTrack *)mediaStreamTrack
// statsOutputLevel:(RTCStatsOutputLevel)statsOutputLevel
// completionHandler:(nullable void (^)(NSArray<RTCLegacyStatsReport *> *stats))completionHandler;
//procedure statsForTrack(mediaStreamTrack: RTCMediaStreamTrack; statsOutputLevel: RTCStatsOutputLevel; completionHandler: TWebRTCCompletionHandler3); cdecl;
end;
TRTCPeerConnection = class(TOCGenericImport<RTCPeerConnectionClass, RTCPeerConnection>) end;
PRTCPeerConnection = Pointer;
{*********************************************************************}
//@interface RTCVideoSource : RTCMediaSource <RTCVideoCapturerDelegate>
RTCVideoSourceClass = interface(RTCMediaSourceClass)
['{81E090DA-C21F-4034-A60C-311FF5E99DE2}']
end;
RTCVideoSource = interface(RTCMediaSource)
['{889191B4-4AB0-4AF3-B527-2ACB2759FFE3}']
//- (instancetype)init NS_UNAVAILABLE;
//Calling this function will cause frames to be scaled down to the
//requested resolution. Also, frames will be cropped to match the
//requested aspect ratio, and frames will be dropped to match the
//requested fps. The requested aspect ratio is orientation agnostic and
//will be adjusted to maintain the input orientation, so it doesn't
//matter if e.g. 1280x720 or 720x1280 is requested.
//- (void)adaptOutputFormatToWidth:(int)width height:(int)height fps:(int)fps;
procedure adaptOutputFormatToWidth(width: Integer; height: Integer; fps: Integer); cdecl;
end;
TRTCVideoSource = class(TOCGenericImport<RTCVideoSourceClass, RTCVideoSource>) end;
PRTCVideoSource = Pointer;
//{*************************************************************}
//RTCPeerConnectionFactoryOptionsClass = interface(NSObjectClass)
//['{8E5529AB-311A-4C3C-A854-2C0EA00230FD}']
//end;
//RTCPeerConnectionFactoryOptions = interface(NSObject)
//['{C67B18A4-5472-42D5-8C92-CF89C3AC3566}']
//procedure setDisableEncryption(disableEncryption: Boolean); cdecl;
//function disableEncryption: Boolean; cdecl;
//procedure setDisableNetworkMonitor(disableNetworkMonitor: Boolean); cdecl;
//function disableNetworkMonitor: Boolean; cdecl;
//procedure setIgnoreLoopbackNetworkAdapter(ignoreLoopbackNetworkAdapter: Boolean); cdecl;
//function ignoreLoopbackNetworkAdapter: Boolean; cdecl;
//procedure setIgnoreVPNNetworkAdapter(ignoreVPNNetworkAdapter: Boolean); cdecl;
//function ignoreVPNNetworkAdapter: Boolean; cdecl;
//procedure setIgnoreCellularNetworkAdapter(ignoreCellularNetworkAdapter: Boolean); cdecl;
//function ignoreCellularNetworkAdapter: Boolean; cdecl;
//procedure setIgnoreWiFiNetworkAdapter(ignoreWiFiNetworkAdapter: Boolean); cdecl;
//function ignoreWiFiNetworkAdapter: Boolean; cdecl;
//procedure setIgnoreEthernetNetworkAdapter(ignoreEthernetNetworkAdapter: Boolean); cdecl;
//function ignoreEthernetNetworkAdapter: Boolean; cdecl;
//procedure setEnableAes128Sha1_32CryptoCipher(enableAes128Sha1_32CryptoCipher: Boolean); cdecl;
//function enableAes128Sha1_32CryptoCipher: Boolean; cdecl;
//procedure setEnableGcmCryptoSuites(enableGcmCryptoSuites: Boolean); cdecl;
//function enableGcmCryptoSuites: Boolean; cdecl;
//procedure setRequireFrameEncryption(requireFrameEncryption: Boolean); cdecl;
//function requireFrameEncryption: Boolean; cdecl;
//function init: Pointer { instancetype }; cdecl;
//end;
//TRTCPeerConnectionFactoryOptions = class(TOCGenericImport<RTCPeerConnectionFactoryOptionsClass, RTCPeerConnectionFactoryOptions>) end;
//PRTCPeerConnectionFactoryOptions = Pointer;
//{***********************************************}
//RTCRtcpParametersClass = interface(NSObjectClass)
//['{E8094EC1-7A9B-4487-9FC9-F8C92D8F6DDD}']
//end;
//RTCRtcpParameters = interface(NSObject)
//['{0D8FD227-2A68-4018-85CC-5A3499E57C53}']
//function cname: NSString; cdecl;
//procedure setIsReducedSize(isReducedSize: Boolean); cdecl;
//function isReducedSize: Boolean; cdecl;
//function init: Pointer { instancetype }; cdecl;
//end;
//TRTCRtcpParameters = class(TOCGenericImport<RTCRtcpParametersClass, RTCRtcpParameters>) end;
//PRTCRtcpParameters = Pointer;
//{***************************************************}
//RTCRtpCodecParametersClass = interface(NSObjectClass)
//['{37FE9BA9-2F15-4E8C-9128-49475017F625}']
//end;
//RTCRtpCodecParameters = interface(NSObject)
//['{1BEBD056-C52B-4D12-8443-165BEA74E193}']
//procedure setPayloadType(payloadType: Integer); cdecl;
//function payloadType: Integer; cdecl;
//function name: NSString; cdecl;
//function kind: NSString; cdecl;
//function clockRate: NSNumber; cdecl;
//function numChannels: NSNumber; cdecl;
//function parameters: NSDictionary; cdecl;
//function init: Pointer { instancetype }; cdecl;
//end;
//TRTCRtpCodecParameters = class(TOCGenericImport<RTCRtpCodecParametersClass, RTCRtpCodecParameters>) end;
//PRTCRtpCodecParameters = Pointer;
{**********************************************}
//@interface RTCRtpEncodingParameters : NSObject
RTCRtpEncodingParametersClass = interface(NSObjectClass)
['{B4DA3F62-1BF3-48BB-8F95-1BE788B12E73}']
end;
RTCRtpEncodingParameters = interface(NSObject)
['{6B905749-0D33-4DF7-9121-B18EB2E8E071}']
//Controls whether the encoding is currently transmitted.
//@property(nonatomic, assign) BOOL isActive;
//procedure setIsActive(isActive: Boolean); cdecl;
//function isActive: Boolean; cdecl;
//The maximum bitrate to use for the encoding, or nil if there is no
//limit.
//@property(nonatomic, copy, nullable) NSNumber *maxBitrateBps;
procedure setMaxBitrateBps(maxBitrateBps: NSNumber); cdecl;
function maxBitrateBps: NSNumber; cdecl;
//The minimum bitrate to use for the encoding, or nil if there is no
//limit.
//@property(nonatomic, copy, nullable) NSNumber *minBitrateBps;
//procedure setMinBitrateBps(minBitrateBps: NSNumber); cdecl;
//function minBitrateBps: NSNumber; cdecl;
//The maximum framerate to use for the encoding, or nil if there is no
//limit.
//@property(nonatomic, copy, nullable) NSNumber *maxFramerate;
//procedure setMaxFramerate(maxFramerate: NSNumber); cdecl;
//function maxFramerate: NSNumber; cdecl;
//The requested number of temporal layers to use for the encoding, or nil
//if the default should be used.
//@property(nonatomic, copy, nullable) NSNumber *numTemporalLayers;
//procedure setNumTemporalLayers(numTemporalLayers: NSNumber); cdecl;
//function numTemporalLayers: NSNumber; cdecl;
//The SSRC being used by this encoding. */
//@property(nonatomic, readonly, nullable) NSNumber *ssrc;
//function ssrc: NSNumber; cdecl;
//- (instancetype)init NS_DESIGNATED_INITIALIZER;
//function init: Pointer { instancetype }; cdecl;
end;
TRTCRtpEncodingParameters = class(TOCGenericImport<RTCRtpEncodingParametersClass, RTCRtpEncodingParameters>) end;
PRTCRtpEncodingParameters = Pointer;
//{***************************************************}
//RTCRtpHeaderExtensionClass = interface(NSObjectClass)
//['{F8164A6A-F3AD-4347-BF90-B41A004FF44E}']
//end;
//RTCRtpHeaderExtension = interface(NSObject)
//['{7D06813C-1545-463D-A4FA-FB3D4FB4915A}']
//function uri: NSString; cdecl;
//function id: Integer; cdecl;
//function isEncrypted: Boolean; cdecl;
//function init: Pointer { instancetype }; cdecl;
//end;
//TRTCRtpHeaderExtension = class(TOCGenericImport<RTCRtpHeaderExtensionClass, RTCRtpHeaderExtension>) end;
//PRTCRtpHeaderExtension = Pointer;
{**************************************}
//@interface RTCRtpParameters : NSObject
RTCRtpParametersClass = interface(NSObjectClass)
['{9FD0BAE1-C448-4A1E-A244-78B31E04AAB1}']
end;
RTCRtpParameters = interface(NSObject)
['{41D43D16-F1A1-419F-A356-BFC8FEE7A66F}']
//A unique identifier for the last set of parameters applied.
//@property(nonatomic, copy) NSString *transactionId;
procedure setTransactionId(transactionId: NSString); cdecl;
function transactionId: NSString; cdecl;
//Parameters used for RTCP.
//@property(nonatomic, readonly, copy) RTCRtcpParameters *rtcp;
//function rtcp: RTCRtcpParameters; cdecl;
//An array containing parameters for RTP header extensions.
//@property(nonatomic, readonly, copy) NSArray<RTCRtpHeaderExtension *> *headerExtensions;
function headerExtensions: NSArray; cdecl;
//The currently active encodings in the order of preference.
//@property(nonatomic, copy) NSArray<RTCRtpEncodingParameters *> *encodings;
procedure setEncodings(encodings: NSArray); cdecl;
function encodings: NSArray; cdecl;
//The negotiated set of send codecs in order of preference.
//@property(nonatomic, copy) NSArray<RTCRtpCodecParameters *> *codecs;
procedure setCodecs(codecs: NSArray); cdecl;
function codecs: NSArray; cdecl;
//- (instancetype)init NS_DESIGNATED_INITIALIZER;
function init: Pointer { instancetype }; cdecl;
end;
TRTCRtpParameters = class(TOCGenericImport<RTCRtpParametersClass, RTCRtpParameters>) end;
PRTCRtpParameters = Pointer;
//{********************************************************}
//RTCVideoDecoderFactoryH264Class = interface(NSObjectClass)
//['{AB6A5448-09E3-40F4-8BA4-C98EF63768D9}']
//end;
//RTCVideoDecoderFactoryH264 = interface(NSObject)
//['{CC95BD22-56FA-4B33-BE77-0EC5F85B49B6}']
//end;
//TRTCVideoDecoderFactoryH264 = class(TOCGenericImport<RTCVideoDecoderFactoryH264Class, RTCVideoDecoderFactoryH264>) end;
//PRTCVideoDecoderFactoryH264 = Pointer;
//{*************************************************}
//RTCVideoDecoderH264Class = interface(NSObjectClass)
//['{4AE2C9E4-82F9-4FE6-8DA5-ECD9A275EAC0}']
//end;
//RTCVideoDecoderH264 = interface(NSObject)
//['{3536063B-C468-4A52-86EC-6950E6980EF7}']
//end;
//TRTCVideoDecoderH264 = class(TOCGenericImport<RTCVideoDecoderH264Class, RTCVideoDecoderH264>) end;
//PRTCVideoDecoderH264 = Pointer;
//{************************************************}
//RTCVideoDecoderVP8Class = interface(NSObjectClass)
//['{E0189880-17DA-445F-AE7F-87945B87AC14}']
//{ class } function vp8Decoder: Pointer; cdecl;
//end;
//RTCVideoDecoderVP8 = interface(NSObject)
//['{A81E1B58-629B-4CD3-9374-8571A0306EE2}']
//end;
//TRTCVideoDecoderVP8 = class(TOCGenericImport<RTCVideoDecoderVP8Class, RTCVideoDecoderVP8>) end;
//PRTCVideoDecoderVP8 = Pointer;
//{************************************************}
//RTCVideoDecoderVP9Class = interface(NSObjectClass)
//['{49ADA230-1A6D-4470-B9D0-47C6161B4CAC}']
//{ class } function vp9Decoder: Pointer; cdecl;
//end;
//RTCVideoDecoderVP9 = interface(NSObject)
//['{1DF313DA-FCEB-4C7B-90FB-414906295340}']
//end;
//TRTCVideoDecoderVP9 = class(TOCGenericImport<RTCVideoDecoderVP9Class, RTCVideoDecoderVP9>) end;
//PRTCVideoDecoderVP9 = Pointer;
//{********************************************************}
//RTCVideoEncoderFactoryH264Class = interface(NSObjectClass)
//['{17D653AF-6374-415F-9464-FB3E2CF10EC4}']
//end;
//RTCVideoEncoderFactoryH264 = interface(NSObject)
//['{3544F254-E238-4514-8358-AD68F66231DD}']
//end;
//TRTCVideoEncoderFactoryH264 = class(TOCGenericImport<RTCVideoEncoderFactoryH264Class, RTCVideoEncoderFactoryH264>) end;
//PRTCVideoEncoderFactoryH264 = Pointer;
//{*************************************************}
//RTCVideoEncoderH264Class = interface(NSObjectClass)
//['{7E87C686-5E63-4474-B292-F675A02852F5}']
//end;
//RTCVideoEncoderH264 = interface(NSObject)
//['{DCB7D623-99E1-4D50-B8BA-DC7CDA4A443C}']
//function initWithCodecInfo(codecInfo: RTCVideoCodecInfo): Pointer { instancetype }; cdecl;
//end;
//TRTCVideoEncoderH264 = class(TOCGenericImport<RTCVideoEncoderH264Class, RTCVideoEncoderH264>) end;
//PRTCVideoEncoderH264 = Pointer;
//{************************************************}
//RTCVideoEncoderVP8Class = interface(NSObjectClass)
//['{50C9BCEF-C572-43CB-8B45-2D41F47EC199}']
//{ class } function vp8Encoder: Pointer; cdecl;
//end;
//RTCVideoEncoderVP8 = interface(NSObject)
//['{9C42EE69-7803-4ED1-9490-5363AA9CE379}']
//end;
//TRTCVideoEncoderVP8 = class(TOCGenericImport<RTCVideoEncoderVP8Class, RTCVideoEncoderVP8>) end;
//PRTCVideoEncoderVP8 = Pointer;
//{************************************************}
//RTCVideoEncoderVP9Class = interface(NSObjectClass)
//['{F85718EE-23DC-4D16-BB84-CD6C44879F01}']
//{ class } function vp9Encoder: Pointer; cdecl;
//end;
//RTCVideoEncoderVP9 = interface(NSObject)
//['{70A9750A-F8E2-4ABC-B41A-B9749F56B43F}']
//end;
//TRTCVideoEncoderVP9 = class(TOCGenericImport<RTCVideoEncoderVP9Class, RTCVideoEncoderVP9>) end;
//PRTCVideoEncoderVP9 = Pointer;
//{********************************}
//RTCDevice = interface(IObjectiveC)
//['{3F119A2E-EC1F-4C58-A3BB-01F225062DA5}']
//function deviceType: RTCDeviceType; cdecl;
//function isIOS11OrLater: Boolean; cdecl;
//end;
//{**********************************************}
//RTCAudioSessionDelegate = interface(IObjectiveC)
//['{D688ED74-51FA-4722-96A8-F6D4B9F480A9}']
//procedure audioSessionDidBeginInterruption(session: RTCAudioSession); cdecl;
//procedure audioSessionDidEndInterruption(session: RTCAudioSession; shouldResumeSession: Boolean); cdecl;
//procedure audioSessionDidChangeRoute(session: RTCAudioSession; reason: AVAudioSessionRouteChangeReason; previousRoute: AVAudioSessionRouteDescription); cdecl;
//procedure audioSessionMediaServerTerminated (session: RTCAudioSession); cdecl;
//procedure audioSessionMediaServerReset(session: RTCAudioSession); cdecl;
//[MethodName('audioSession:didChangeCanPlayOrRecord:')]
//procedure audioSessionDidChangeCanPlayOrRecord(session: RTCAudioSession; didChangeCanPlayOrRecord: Boolean); cdecl;
//procedure audioSessionDidStartPlayOrRecord(session: RTCAudioSession); cdecl;
//procedure audioSessionDidStopPlayOrRecord(session: RTCAudioSession); cdecl;
//[MethodName('audioSession:didChangeOutputVolume:')]
//procedure audioSessionDidChangeOutputVolume(audioSession: RTCAudioSession; didChangeOutputVolume: Single); cdecl;
//[MethodName('audioSession:didDetectPlayoutGlitch:')]
//procedure audioSessionDidDetectPlayoutGlitch(audioSession: RTCAudioSession; didDetectPlayoutGlitch: Int64); cdecl;
//[MethodName('audioSession:willSetActive:')]
//procedure audioSessionWillSetActive(audioSession: RTCAudioSession; willSetActive: Boolean); cdecl;
//[MethodName('audioSession:didSetActive:')]
//procedure audioSessionDidSetActive(audioSession: RTCAudioSession; didSetActive: Boolean); cdecl;
//[MethodName('audioSession:failedToSetActive:error:')]
//procedure audioSessionFailedToSetActiveError(audioSession: RTCAudioSession; failedToSetActive: Boolean; error: NSError); cdecl;
//end;
//{********************************************************}
//RTCAudioSessionActivationDelegate = interface(IObjectiveC)
//['{15161B43-B6A7-4D66-AA08-586FEC66D10B}']
//procedure audioSessionDidActivate(session: AVAudioSession); cdecl;
//procedure audioSessionDidDeactivate(session: AVAudioSession); cdecl;
//end;
{****************************************}
//@protocol RTCVideoFrameBuffer <NSObject>
//RTCVideoFrameBuffer = interface(IObjectiveC)
//['{EAEE9751-BBF7-44DC-918D-80D87B1A1BC9}']
//@property(nonatomic, readonly) int width;
//function width: Integer; cdecl;
//@property(nonatomic, readonly) int height;
//function height: Integer; cdecl;
//- (id<RTCI420Buffer>)toI420;
//function toI420: Pointer; cdecl;
//end;
{*********************************************}
//@protocol RTCVideoCapturerDelegate <NSObject>
RTCVideoCapturerDelegate = interface(IObjectiveC)
['{128218E8-24D4-4AE6-B4E2-998C3B7AB6E9}']
//- (void)capturer:(RTCVideoCapturer *)capturer didCaptureVideoFrame:(RTCVideoFrame *)frame;
procedure capturer(capturer: RTCVideoCapturer; didCaptureVideoFrame: RTCVideoFrame); cdecl;
end;
//{*******************************************}
//RTCCodecSpecificInfo = interface(IObjectiveC)
//['{A4E42988-D478-4D4C-ACA7-C173335E0D85}']
//end;
//{*********************************************}
//RTCDataChannelDelegate = interface(IObjectiveC)
//['{FE3BF9F7-BEF6-42A2-BBA2-BF923C87446B}']
//procedure dataChannelDidChangeState(dataChannel: RTCDataChannel); cdecl;
//[MethodName('dataChannel:didReceiveMessageWithBuffer:')]
//procedure dataChannelDidReceiveMessageWithBuffer (dataChannel: RTCDataChannel; didReceiveMessageWithBuffer: RTCDataBuffer); cdecl;
//[MethodName('dataChannel:didChangeBufferedAmount:')]
//procedure dataChannelDidChangeBufferedAmount(dataChannel: RTCDataChannel; didChangeBufferedAmount: UInt64); cdecl;
//end;
//{**************************************}
//RTCVideoDecoder = interface(IObjectiveC)
//['{CA3AC1F9-7545-466E-8832-0FA2E44D413F}']
//procedure setCallback(callback: RTCVideoDecoderCallback); cdecl;
//function startDecodeWithSettings(settings: RTCVideoEncoderSettings; numberOfCores: Integer): NSInteger; cdecl;
//function releaseDecoder: NSInteger; cdecl;
//function decode(encodedImage: RTCEncodedImage; missingFrames: Boolean; codecSpecificInfo: Pointer; renderTimeMs: Int64): NSInteger; cdecl;
//function implementationName: NSString; cdecl;
//function startDecodeWithNumberOfCores(numberOfCores: Integer): NSInteger; cdecl;
//end;
//{*********************************************}
//RTCVideoDecoderFactory = interface(IObjectiveC)
//['{78896CE3-4543-41A4-8451-0BF665F321ED}']
//function createDecoder(info: RTCVideoCodecInfo): Pointer; cdecl;
//function supportedCodecs: NSArray; cdecl;
//end;
//{**************************************}
//RTCVideoEncoder = interface(IObjectiveC)
//['{7310F706-7913-4B4C-AE9F-924BBB273649}']
//procedure setCallback(callback: RTCVideoEncoderCallback); cdecl;
//function startEncodeWithSettings(settings: RTCVideoEncoderSettings; numberOfCores: Integer): NSInteger; cdecl;
//function releaseEncoder: NSInteger; cdecl;
//function encode(frame: RTCVideoFrame; codecSpecificInfo: Pointer; frameTypes: NSArray): NSInteger; cdecl;
//function setBitrate(bitrateKbit: LongWord; framerate: LongWord): Integer; cdecl;
//function implementationName: NSString; cdecl;
//function scalingSettings: RTCVideoEncoderQpThresholds; cdecl;
//end;
//{*********************************************}
//RTCVideoEncoderFactory = interface(IObjectiveC)
//['{2440D44B-5404-4460-B60C-C1BBF5AB8BCA}']
//function createEncoder(info: RTCVideoCodecInfo): Pointer; cdecl;
//function supportedCodecs: NSArray; cdecl;
//end;
//{************************************}
//RTCDtmfSender = interface(IObjectiveC)
//['{32F586AC-065E-45E4-A704-D04BF78739A0}']
//function canInsertDtmf: Boolean; cdecl;
//function insertDtmf(tones: NSString; duration: NSTimeInterval; interToneGap: NSTimeInterval): Boolean; cdecl;
//function remainingTones: NSString; cdecl;
//function duration: NSTimeInterval; cdecl;
//function interToneGap: NSTimeInterval; cdecl;
//end;
{*************************************}
//@protocol RTCVideoRenderer <NSObject>
RTCVideoRenderer = interface(IObjectiveC)
['{161733F8-4379-4F41-B7F7-1985FAAF9A11}']
//The size of the frame.
//- (void)setSize:(CGSize)size;
procedure setSize(size: CGSize); cdecl;
//The frame to be displayed.
//- (void)renderFrame:(nullable RTCVideoFrame *)frame;
procedure renderFrame(frame: RTCVideoFrame); cdecl;
end;
//{*******************************************}
//RTCVideoViewDelegate = interface(IObjectiveC)
//['{62563606-CFC0-47FC-B147-FD8881C8A6CE}']
//procedure videoView(videoView: Pointer; didChangeVideoSize: CGSize); cdecl;
//end;
//{******************************************}
//RTCVideoViewShading = interface(IObjectiveC)
//['{88021F97-F59B-408E-AA7E-FD0BA1D15E0A}']
//[MethodName ('applyShadingForFrameWithWidth:height:rotation:yPlane:uPlane:vPlane:')]
//procedure applyShadingForFrameWithWidthHeightRotationYPlaneUPlaneVPlane (width: Integer; height: Integer; rotation: RTCVideoRotation; yPlane: GLuint; uPlane: GLuint; vPlane: GLuint); cdecl;
//[MethodName ('applyShadingForFrameWithWidth:height:rotation:yPlane:uvPlane:')]
//procedure applyShadingForFrameWithWidthHeightRotationYPlaneUvPlane (width: Integer; height: Integer; rotation: RTCVideoRotation; yPlane: GLuint; uvPlane: GLuint); cdecl;
//end;
//{*****************************************}
//RTCYUVPlanarBuffer = interface(IObjectiveC)
//['{B2C25DC6-5976-4911-B710-67E03A53F16D}']
//function chromaWidth: Integer; cdecl;
//function chromaHeight: Integer; cdecl;
//function dataY: PByte; cdecl;
//function dataU: PByte; cdecl;
//function dataV: PByte; cdecl;
//function strideY: Integer; cdecl;
//function strideU: Integer; cdecl;
//function strideV: Integer; cdecl;
//[MethodName('initWithWidth:height:dataY:dataU:dataV:')]
//function initWithWidthHeightDataYDataUDataV(width: Integer; height: Integer; dataY: PByte; dataU: PByte; dataV: PByte): Pointer { instancetype }; cdecl;
//[MethodName('initWithWidth:height:')]
//function initWithWidthHeight(width: Integer; height: Integer): Pointer { instancetype }; cdecl;
//[MethodName('initWithWidth:height:strideY:strideU:strideV:')]
//function initWithWidthHeightStrideYStrideUStrideV(width: Integer; height: Integer; strideY: Integer; strideU: Integer; strideV: Integer): Pointer { instancetype }; cdecl;
//end;
//{************************************************}
//RTCMutableYUVPlanarBuffer = interface(IObjectiveC)
//['{BCF71D8A-E4BD-4506-ACE6-3CE0EE691EE5}']
//function mutableDataY: PByte; cdecl;
//function mutableDataU: PByte; cdecl;
//function mutableDataV: PByte; cdecl;
//end;
{**********************************************}
//@protocol RTCPeerConnectionDelegate <NSObject>
RTCPeerConnectionDelegate = interface(IObjectiveC)
['{511BE845-750C-4A21-9125-C996A51BEF2C}']
//Called when the SignalingState changed.
//- (void)peerConnection:(RTCPeerConnection *)peerConnection
// didChangeSignalingState:(RTCSignalingState)stateChanged;
[MethodName('peerConnection:didChangeSignalingState:')]
procedure peerConnectionDidChangeSignalingState(peerConnection: RTCPeerConnection; didChangeSignalingState: RTCSignalingState); cdecl;
//Called when media is received on a new stream from remote peer.
//- (void)peerConnection:(RTCPeerConnection *)peerConnection didAddStream:(RTCMediaStream *)stream;
[MethodName('peerConnection:didAddStream:')]
procedure peerConnectionDidAddStream(peerConnection: RTCPeerConnection; didAddStream: RTCMediaStream); cdecl;
//Called when a remote peer closes a stream.
//This is not called when RTCSdpSemanticsUnifiedPlan is specified.
//- (void)peerConnection:(RTCPeerConnection *)peerConnection didRemoveStream:(RTCMediaStream *)stream;
[MethodName('peerConnection:didRemoveStream:')]
procedure peerConnectionDidRemoveStream(peerConnection: RTCPeerConnection; didRemoveStream: RTCMediaStream); cdecl;
//Called when negotiation is needed, for example ICE has restarted.
//- (void)peerConnectionShouldNegotiate:(RTCPeerConnection *)peerConnection;
procedure peerConnectionShouldNegotiate(peerConnection: RTCPeerConnection); cdecl;
//Called any time the IceConnectionState changes.
//- (void)peerConnection:(RTCPeerConnection *)peerConnection
// didChangeIceConnectionState:(RTCIceConnectionState)newState;
[MethodName('peerConnection:didChangeIceConnectionState:')]
procedure peerConnectionDidChangeIceConnectionState(peerConnection: RTCPeerConnection; didChangeIceConnectionState: RTCIceConnectionState); cdecl;
//Called any time the IceGatheringState changes.
//- (void)peerConnection:(RTCPeerConnection *)peerConnection
// didChangeIceGatheringState:(RTCIceGatheringState)newState;
[MethodName('peerConnection:didChangeIceGatheringState:')]
procedure peerConnectionDidChangeIceGatheringState(peerConnection: RTCPeerConnection; didChangeIceGatheringState: RTCIceGatheringState); cdecl;
//New ice candidate has been found.
//- (void)peerConnection:(RTCPeerConnection *)peerConnection
// didGenerateIceCandidate:(RTCIceCandidate *)candidate;
[MethodName('peerConnection:didGenerateIceCandidate:')]
procedure peerConnectionDidGenerateIceCandidate(peerConnection: RTCPeerConnection; didGenerateIceCandidate: RTCIceCandidate); cdecl;
//Called when a group of local Ice candidates have been removed.
//- (void)peerConnection:(RTCPeerConnection *)peerConnection
// didRemoveIceCandidates:(NSArray<RTCIceCandidate *> *)candidates;
[MethodName('peerConnection:didRemoveIceCandidates:')]
procedure peerConnectionDidRemoveIceCandidates(peerConnection: RTCPeerConnection; didRemoveIceCandidates: NSArray); cdecl;
//New data channel has been opened.
//- (void)peerConnection:(RTCPeerConnection *)peerConnection
// didOpenDataChannel:(RTCDataChannel *)dataChannel;
[MethodName('peerConnection:didOpenDataChannel:')]
procedure peerConnectionDidOpenDataChannel(peerConnection: RTCPeerConnection; didOpenDataChannel: RTCDataChannel); cdecl;
//Called when signaling indicates a transceiver will be receiving media from
//the remote endpoint.
//This is only called with RTCSdpSemanticsUnifiedPlan specified.
//@optional
//- (void)peerConnection:(RTCPeerConnection *)peerConnection
// didStartReceivingOnTransceiver:(RTCRtpTransceiver *)transceiver;
[MethodName('peerConnection:didStartReceivingOnTransceiver:')]
procedure peerConnectionDidStartReceivingOnTransceiver(peerConnection: RTCPeerConnection; didStartReceivingOnTransceiver: RTCRtpTransceiver); cdecl;
//Called when a receiver and its track are created.
//@optional
//- (void)peerConnection:(RTCPeerConnection *)peerConnection
// didAddReceiver:(RTCRtpReceiver *)rtpReceiver
// streams:(NSArray<RTCMediaStream *> *)mediaStreams;
[MethodName('peerConnection:didAddReceiver:streams:')]
procedure peerConnectionDidAddReceiverStreams(peerConnection: RTCPeerConnection; didAddReceiver: RTCRtpReceiver; streams: NSArray); cdecl;
//Called when the receiver and its track are removed.
//- (void)peerConnection:(RTCPeerConnection *)peerConnection
// didRemoveReceiver:(RTCRtpReceiver *)rtpReceiver;
[MethodName('peerConnection:didRemoveReceiver:')]
procedure peerConnectionDidRemoveReceiver(peerConnection: RTCPeerConnection; didRemoveReceiver: RTCRtpReceiver); cdecl;
end;
//{*********************************************}
//RTCRtpReceiverDelegate = interface(IObjectiveC)
//['{8E81C44C-673D-4CBB-86C8-E19CBEFED21C}']
//procedure rtpReceiver(rtpReceiver: RTCRtpReceiver; didReceiveFirstPacketForMediaType: RTCRtpMediaType); cdecl;
//end;
//{*********************************************}
//function kRTCAudioSessionErrorDomain: NSString;
//function kRTCAudioSessionErrorLockRequired: Pointer;
//function kRTCAudioSessionErrorConfiguration: Pointer;
//function kRTCAudioSessionPreferredNumberOfChannels: Pointer;
//function kRTCAudioSessionHighPerformanceSampleRate: Pointer;
//function kRTCAudioSessionLowComplexitySampleRate: Pointer;
//function kRTCAudioSessionHighPerformanceIOBufferDuration: Pointer;
//function kRTCAudioSessionLowComplexityIOBufferDuration: Pointer;
//function kRTCMediaStreamTrackKindAudio: NSString;
//function kRTCMediaStreamTrackKindVideo: NSString;
//function kRTCFieldTrialAudioSendSideBweKey: NSString;
//function kRTCFieldTrialAudioSendSideBweForVideoKey: NSString;
//function kRTCFieldTrialAudioForceNoTWCCKey: NSString;
//function kRTCFieldTrialAudioForceABWENoTWCCKey: NSString;
//function kRTCFieldTrialSendSideBweWithOverheadKey: NSString;
//function kRTCFieldTrialFlexFec03AdvertisedKey: NSString;
//function kRTCFieldTrialFlexFec03Key: NSString;
//function kRTCFieldTrialImprovedBitrateEstimateKey: NSString;
//function kRTCFieldTrialH264HighProfileKey: NSString;
//function kRTCFieldTrialMinimizeResamplingOnMobileKey: NSString;
//function kRTCFieldTrialEnabledValue: NSString;
//function kRTCFieldTrialMedianSlopeFilterKey: NSString;
//function kRTCFieldTrialTrendlineFilterKey: NSString;
//function kRTCVideoCodecH264Name: NSString;
//function kRTCLevel31ConstrainedHigh: NSString;
//function kRTCLevel31ConstrainedBaseline: NSString;
//function kRTCMaxSupportedH264ProfileLevelConstrainedHigh: NSString;
//function kRTCMaxSupportedH264ProfileLevelConstrainedBaseline: NSString;
//function kRTCMediaConstraintsMinAspectRatio: NSString;
//function kRTCMediaConstraintsMaxAspectRatio: NSString;
//function kRTCMediaConstraintsMaxWidth: NSString;
//function kRTCMediaConstraintsMinWidth: NSString;
//function kRTCMediaConstraintsMaxHeight: NSString;
//function kRTCMediaConstraintsMinHeight: NSString;
//function kRTCMediaConstraintsMaxFrameRate: NSString;
//function kRTCMediaConstraintsMinFrameRate: NSString;
//function kRTCMediaConstraintsAudioNetworkAdaptorConfig: NSString;
//function kRTCMediaConstraintsIceRestart: NSString;
//function kRTCMediaConstraintsOfferToReceiveAudio: NSString;
//function kRTCMediaConstraintsOfferToReceiveVideo: NSString;
//function kRTCMediaConstraintsVoiceActivityDetection: NSString;
//function kRTCMediaConstraintsValueTrue: NSString;
//function kRTCMediaConstraintsValueFalse: NSString;
//function kRTCPeerConnectionErrorDomain: NSString;
//function kRTCSessionDescriptionErrorCode: Pointer;
//function kRTCRtxCodecName: NSString;
//function kRTCRedCodecName: NSString;
//function kRTCUlpfecCodecName: NSString;
//function kRTCFlexfecCodecName: NSString;
//function kRTCOpusCodecName: NSString;
//function kRTCIsacCodecName: NSString;
//function kRTCL16CodecName: NSString;
//function kRTCG722CodecName: NSString;
//function kRTCIlbcCodecName: NSString;
//function kRTCPcmuCodecName: NSString;
//function kRTCPcmaCodecName: NSString;
//function kRTCDtmfCodecName: NSString;
//function kRTCComfortNoiseCodecName: NSString;
//function kRTCVp8CodecName: NSString;
//function kRTCVp9CodecName: NSString;
//function kRTCH264CodecName: NSString;
//function kRTCVideoCodecVp8Name: NSString;
//function kRTCVideoCodecVp9Name: NSString;
//RTC_EXTERN void RTCSetupInternalTracer(void);
procedure RTCSetupInternalTracer; cdecl; external 'WebRTC' name _PU + 'RTCSetupInternalTracer';
//Starts capture to specified file. Must be a valid writable path.
//Returns YES if capture starts.
//RTC_EXTERN BOOL RTCStartInternalCapture(NSString* filePath);
function RTCStartInternalCapture(filePath: Pointer { NSString }): Boolean; cdecl; external 'WebRTC' name _PU + 'RTCStartInternalCapture';
//RTC_EXTERN void RTCStopInternalCapture(void);
procedure RTCStopInternalCapture; cdecl; external 'WebRTC' name _PU + 'RTCStopInternalCapture';
//RTC_EXTERN void RTCShutdownInternalTracer(void);
procedure RTCShutdownInternalTracer; cdecl; external 'WebRTC' name _PU + 'RTCShutdownInternalTracer';
//Initialize field trials using a dictionary mapping field trial keys to their
//values. See above for valid keys and values. Must be called before any other
//call into WebRTC. See: webrtc/system_wrappers/include/field_trial.h
//RTC_EXTERN void RTCInitFieldTrialDictionary(NSDictionary<NSString *, NSString *> *fieldTrials);
procedure RTCInitFieldTrialDictionary(fieldTrials: Pointer { NSDictionary } ); cdecl; external 'WebRTC' name _PU + 'RTCInitFieldTrialDictionary';
//Initialize and clean up the SSL library. Failure is fatal. These call the
//corresponding functions in webrtc/rtc_base/ssladapter.h.
//RTC_EXTERN BOOL RTCInitializeSSL(void);
function RTCInitializeSSL: Boolean; cdecl; external 'WebRTC' name _PU + 'RTCInitializeSSL';
//RTC_EXTERN BOOL RTCCleanupSSL(void);
function RTCCleanupSSL: Boolean; cdecl; external 'WebRTC' name _PU + 'RTCCleanupSSL';
//Wrapper for rtc::LogMessage::LogToDebug.
//Sets the minimum severity to be logged to console.
//RTC_EXTERN void RTCSetMinDebugLogLevel(RTCLoggingSeverity severity);
procedure RTCSetMinDebugLogLevel(severity: RTCLoggingSeverity); cdecl; external 'WebRTC' name _PU + 'RTCSetMinDebugLogLevel';
//procedure RTCLogEx(severity: RTCLoggingSeverity; log_string: Pointer { NSString } ); cdecl; external libWebRTC name _PU + 'RTCLogEx';
//function RTCFileName(filePath: MarshaledAString): Pointer { NSString }; cdecl; external libWebRTC name _PU + 'RTCFileName';
//function RTCFieldTrialMedianSlopeFilterValue(windowSize: LongWord; thresholdGain: Double): Pointer { NSString }; cdecl; external libWebRTC name _PU + 'RTCFieldTrialMedianSlopeFilterValue';
//function RTCFieldTrialTrendlineFilterValue(windowSize: LongWord; smoothingCoeff: Double; thresholdGain: Double): Pointer { NSString }; cdecl; external libWebRTC name _PU + 'RTCFieldTrialTrendlineFilterValue';
//procedure RTCEnableMetrics; cdecl; external libWebRTC name _PU + 'RTCEnableMetrics';
//function RTCGetAndResetMetrics: Pointer { NSArray }; cdecl; external libWebRTC name _PU + 'RTCGetAndResetMetrics';
implementation
//{*********************************************}
//function kRTCAudioSessionErrorDomain: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCAudioSessionErrorDomain');
//end;
//{***********************************************}
//function kRTCMediaStreamTrackKindAudio: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCMediaStreamTrackKindAudio');
//end;
//{***********************************************}
//function kRTCMediaStreamTrackKindVideo: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCMediaStreamTrackKindVideo');
//end;
//{***************************************************}
//function kRTCFieldTrialAudioSendSideBweKey: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCFieldTrialAudioSendSideBweKey');
//end;
//{***********************************************************}
//function kRTCFieldTrialAudioSendSideBweForVideoKey: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCFieldTrialAudioSendSideBweForVideoKey');
//end;
//{***************************************************}
//function kRTCFieldTrialAudioForceNoTWCCKey: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCFieldTrialAudioForceNoTWCCKey');
//end;
//{*******************************************************}
//function kRTCFieldTrialAudioForceABWENoTWCCKey: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCFieldTrialAudioForceABWENoTWCCKey');
//end;
//{**********************************************************}
//function kRTCFieldTrialSendSideBweWithOverheadKey: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCFieldTrialSendSideBweWithOverheadKey');
//end;
//{******************************************************}
//function kRTCFieldTrialFlexFec03AdvertisedKey: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCFieldTrialFlexFec03AdvertisedKey');
//end;
//{********************************************}
//function kRTCFieldTrialFlexFec03Key: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCFieldTrialFlexFec03Key');
//end;
//{**********************************************************}
//function kRTCFieldTrialImprovedBitrateEstimateKey: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCFieldTrialImprovedBitrateEstimateKey');
//end;
//{**************************************************}
//function kRTCFieldTrialH264HighProfileKey: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCFieldTrialH264HighProfileKey');
//end;
//{*************************************************************}
//function kRTCFieldTrialMinimizeResamplingOnMobileKey: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCFieldTrialMinimizeResamplingOnMobileKey');
//end;
//{********************************************}
//function kRTCFieldTrialEnabledValue: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCFieldTrialEnabledValue');
//end;
//{****************************************************}
//function kRTCFieldTrialMedianSlopeFilterKey: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCFieldTrialMedianSlopeFilterKey');
//end;
//{**************************************************}
//function kRTCFieldTrialTrendlineFilterKey: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCFieldTrialTrendlineFilterKey');
//end;
//{****************************************}
//function kRTCVideoCodecH264Name: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCVideoCodecH264Name');
//end;
//{********************************************}
//function kRTCLevel31ConstrainedHigh: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCLevel31ConstrainedHigh');
//end;
//{************************************************}
//function kRTCLevel31ConstrainedBaseline: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCLevel31ConstrainedBaseline');
//end;
//{*****************************************************************}
//function kRTCMaxSupportedH264ProfileLevelConstrainedHigh: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCMaxSupportedH264ProfileLevelConstrainedHigh');
//end;
//{*********************************************************************}
//function kRTCMaxSupportedH264ProfileLevelConstrainedBaseline: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCMaxSupportedH264ProfileLevelConstrainedBaseline');
//end;
//{****************************************************}
//function kRTCMediaConstraintsMinAspectRatio: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCMediaConstraintsMinAspectRatio');
//end;
//{****************************************************}
//function kRTCMediaConstraintsMaxAspectRatio: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCMediaConstraintsMaxAspectRatio');
//end;
//{**********************************************}
//function kRTCMediaConstraintsMaxWidth: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCMediaConstraintsMaxWidth');
//end;
//{**********************************************}
//function kRTCMediaConstraintsMinWidth: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCMediaConstraintsMinWidth');
//end;
//{***********************************************}
//function kRTCMediaConstraintsMaxHeight: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCMediaConstraintsMaxHeight');
//end;
//{***********************************************}
//function kRTCMediaConstraintsMinHeight: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCMediaConstraintsMinHeight');
//end;
//{**************************************************}
//function kRTCMediaConstraintsMaxFrameRate: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCMediaConstraintsMaxFrameRate');
//end;
//{**************************************************}
//function kRTCMediaConstraintsMinFrameRate: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCMediaConstraintsMinFrameRate');
//end;
//{***************************************************************}
//function kRTCMediaConstraintsAudioNetworkAdaptorConfig: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCMediaConstraintsAudioNetworkAdaptorConfig');
//end;
//{************************************************}
//function kRTCMediaConstraintsIceRestart: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCMediaConstraintsIceRestart');
//end;
//{*********************************************************}
//function kRTCMediaConstraintsOfferToReceiveAudio: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCMediaConstraintsOfferToReceiveAudio');
//end;
//{*********************************************************}
//function kRTCMediaConstraintsOfferToReceiveVideo: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCMediaConstraintsOfferToReceiveVideo');
//end;
//{************************************************************}
//function kRTCMediaConstraintsVoiceActivityDetection: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCMediaConstraintsVoiceActivityDetection');
//end;
//{***********************************************}
//function kRTCMediaConstraintsValueTrue: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCMediaConstraintsValueTrue');
//end;
//{************************************************}
//function kRTCMediaConstraintsValueFalse: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCMediaConstraintsValueFalse');
//end;
//{***********************************************}
//function kRTCPeerConnectionErrorDomain: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCPeerConnectionErrorDomain');
//end;
//{**********************************}
//function kRTCRtxCodecName: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCRtxCodecName');
//end;
//{**********************************}
//function kRTCRedCodecName: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCRedCodecName');
//end;
//{*************************************}
//function kRTCUlpfecCodecName: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCUlpfecCodecName');
//end;
//{**************************************}
//function kRTCFlexfecCodecName: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCFlexfecCodecName');
//end;
//{***********************************}
//function kRTCOpusCodecName: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCOpusCodecName');
//end;
//{***********************************}
//function kRTCIsacCodecName: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCIsacCodecName');
//end;
//{**********************************}
//function kRTCL16CodecName: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCL16CodecName');
//end;
//{***********************************}
//function kRTCG722CodecName: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCG722CodecName');
//end;
//{***********************************}
//function kRTCIlbcCodecName: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCIlbcCodecName');
//end;
//{***********************************}
//function kRTCPcmuCodecName: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCPcmuCodecName');
//end;
//{***********************************}
//function kRTCPcmaCodecName: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCPcmaCodecName');
//end;
//{***********************************}
//function kRTCDtmfCodecName: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCDtmfCodecName');
//end;
//{*******************************************}
//function kRTCComfortNoiseCodecName: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCComfortNoiseCodecName');
//end;
//{**********************************}
//function kRTCVp8CodecName: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCVp8CodecName');
//end;
//{**********************************}
//function kRTCVp9CodecName: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCVp9CodecName');
//end;
//{***********************************}
//function kRTCH264CodecName: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCH264CodecName');
//end;
//{***************************************}
//function kRTCVideoCodecVp8Name: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCVideoCodecVp8Name');
//end;
//{***************************************}
//function kRTCVideoCodecVp9Name: NSString;
//begin
//Result := CocoaNSStringConst(libWebRTC, 'kRTCVideoCodecVp9Name');
//end;
//{**************************************************}
//function kRTCAudioSessionErrorLockRequired: Pointer;
//begin
//Result := CocoaPointerConst(libWebRTC, 'kRTCAudioSessionErrorLockRequired');
//end;
//{***************************************************}
//function kRTCAudioSessionErrorConfiguration: Pointer;
//begin
//Result := CocoaPointerConst(libWebRTC, 'kRTCAudioSessionErrorConfiguration');
//end;
//{**********************************************************}
//function kRTCAudioSessionPreferredNumberOfChannels: Pointer;
//begin
//Result := CocoaPointerConst(libWebRTC, 'kRTCAudioSessionPreferredNumberOfChannels');
//end;
//{**********************************************************}
//function kRTCAudioSessionHighPerformanceSampleRate: Pointer;
//begin
//Result := CocoaPointerConst(libWebRTC, 'kRTCAudioSessionHighPerformanceSampleRate');
//end;
//{********************************************************}
//function kRTCAudioSessionLowComplexitySampleRate: Pointer;
//begin
//Result := CocoaPointerConst(libWebRTC, 'kRTCAudioSessionLowComplexitySampleRate');
//end;
//{****************************************************************}
//function kRTCAudioSessionHighPerformanceIOBufferDuration: Pointer;
//begin
//Result := CocoaPointerConst(libWebRTC, 'kRTCAudioSessionHighPerformanceIOBufferDuration');
//end;
//{**************************************************************}
//function kRTCAudioSessionLowComplexityIOBufferDuration: Pointer;
//begin
//Result := CocoaPointerConst(libWebRTC, 'kRTCAudioSessionLowComplexityIOBufferDuration');
//end;
//{************************************************}
//function kRTCSessionDescriptionErrorCode: Pointer;
//begin
//Result := CocoaPointerConst(libWebRTC, 'kRTCSessionDescriptionErrorCode');
//end;
{$IF defined(CPUARM)}
procedure StubProc1; cdecl; external 'WebRTC' name 'OBJC_CLASS_$_RTCPeerConnectionFactory';
{$ELSE}
// i don't know how to do under ios simulator :(
{$ENDIF}
end.
| 45.82906 | 350 | 0.698207 |
4741ffc93c5072923b296bd8b480086184368a2d | 298 | pas | Pascal | src/RssParser.pas | dimsa/delphi-tdd-example | 346cc7a1500cf1b64d4980f195f384910fe15e8a | [
"MIT"
]
| 1 | 2021-03-19T05:57:18.000Z | 2021-03-19T05:57:18.000Z | src/RssParser.pas | JSinx/delphi-tdd-example | 4630e7d848c8d6aa83e7de309670c62ae5cb286f | [
"MIT"
]
| null | null | null | src/RssParser.pas | JSinx/delphi-tdd-example | 4630e7d848c8d6aa83e7de309670c62ae5cb286f | [
"MIT"
]
| 1 | 2018-03-13T21:09:46.000Z | 2018-03-13T21:09:46.000Z | unit RssParser;
interface
uses
RssModel, SysUtils;
type
ERSSParserException = class(Exception);
IRSSParser = interface
['{263159EC-F94D-4BA6-9D34-5D93277D4DDC}']
function ParseRSSFeed(XML: string): TRSSFeed;
end;
var
DefaultRSSParser: IRSSParser = nil;
implementation
end.
| 13.545455 | 49 | 0.734899 |
fc369b5615205aed8f7a056ea1f6c44dfd7c65a7 | 1,592 | dfm | Pascal | TipaLife/uEditProgram.dfm | delphi-pascal-archive/tipa-life | 07cea361a414dd3bfa2f5ea6a79ad3a5eb319903 | [
"Unlicense"
]
| 1 | 2021-11-06T23:50:18.000Z | 2021-11-06T23:50:18.000Z | TipaLife/uEditProgram.dfm | delphi-pascal-archive/tipa-life | 07cea361a414dd3bfa2f5ea6a79ad3a5eb319903 | [
"Unlicense"
]
| null | null | null | TipaLife/uEditProgram.dfm | delphi-pascal-archive/tipa-life | 07cea361a414dd3bfa2f5ea6a79ad3a5eb319903 | [
"Unlicense"
]
| 1 | 2021-11-06T23:50:20.000Z | 2021-11-06T23:50:20.000Z | object frmEditProgram: TfrmEditProgram
Left = 334
Top = 173
Width = 468
Height = 301
Caption = 'frmEditProgram'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -14
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
PixelsPerInch = 120
TextHeight = 16
object Memo1: TMemo
Left = 122
Top = 0
Width = 338
Height = 273
Align = alClient
Lines.Strings = (
'// '#1055#1088#1086#1075#1088#1072#1084#1084#1072' '#1087#1086' '#1091#1084#1086#1083#1095#1072#1085#1080#1102
''
' ACT:=0;'
' DX:=RND;'
' DY:=RND;'
' HLP:=0;'
'')
ScrollBars = ssBoth
TabOrder = 0
end
object Panel1: TPanel
Left = 0
Top = 0
Width = 122
Height = 273
Align = alLeft
TabOrder = 1
object Button1: TButton
Left = 15
Top = 10
Width = 92
Height = 31
Caption = 'SetProgram'
TabOrder = 0
OnClick = Button1Click
end
object Button2: TButton
Left = 17
Top = 103
Width = 93
Height = 31
Caption = 'Close'
TabOrder = 1
OnClick = Button2Click
end
object Button3: TButton
Left = 17
Top = 54
Width = 93
Height = 31
Caption = 'open'
TabOrder = 2
OnClick = Button3Click
end
end
object OpenDialog1: TOpenDialog
DefaultExt = '*.vpg'
Filter = '*.vpg|*.vpg'
Left = 64
Top = 44
end
end
| 20.947368 | 118 | 0.537688 |
4715c2b8eca6abbb5eb62149a9be3e2093586b5a | 8,839 | pas | Pascal | Source/DcefB.Handler.Request.pas | bccsafe/DcefBrowser | 335a2de83aaab5888ff059f0021d0d965ba02954 | [
"Condor-1.1"
]
| 81 | 2015-01-11T08:38:26.000Z | 2018-06-28T10:00:05.000Z | Source/DcefB.Handler.Request.pas | TotteKarlsson/bcc_cef | 237bda30a96e5a7d9dc04d436312aecdf37d84b5 | [
"Condor-1.1"
]
| 11 | 2015-05-31T06:42:12.000Z | 2018-06-11T12:11:45.000Z | Source/DcefB.Handler.Request.pas | TotteKarlsson/bcc_cef | 237bda30a96e5a7d9dc04d436312aecdf37d84b5 | [
"Condor-1.1"
]
| 41 | 2015-01-07T09:17:39.000Z | 2018-06-04T09:43:19.000Z | (*
* Delphi Multi-tab Chromium Browser Frame
*
* Usage allowed under the restrictions of the Lesser GNU General Public License
* or alternatively the restrictions of the Mozilla Public License 1.1
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
*
* Unit owner : BccSafe <bccsafe5988@gmail.com>
* QQ : 1262807955
* Web site : http://www.bccsafe.com
* Repository : https://github.com/bccsafe/DcefBrowser
*
* The code of DcefBrowser is based on DCEF3 by: Henri Gourvest <hgourvest@gmail.com>
* code: https://github.com/hgourvest/dcef3
*
* Embarcadero Technologies, Inc is not permitted to use or redistribute
* this source code without explicit permission.
*
*)
unit DcefB.Handler.Request;
interface
uses
Windows, Classes,
DcefB.Cef3.Interfaces, DcefB.Cef3.Classes, DcefB.Cef3.Types, DcefB.Events,
DcefB.res, DcefB.Utils, DcefB.BaseObject;
type
TDcefBRequestHandler = class(TCefRequestHandlerOwn)
private
FEvents: IDcefBrowser;
protected
function OnBeforeBrowse(const browser: ICefBrowser; const frame: ICefFrame;
const request: ICefRequest; isRedirect: Boolean): Boolean; override;
function OnOpenUrlFromTab(const browser: ICefBrowser; const frame: ICefFrame;
const targetUrl: ustring; targetDisposition: TCefWindowOpenDisposition;
userGesture: Boolean): Boolean; override;
function OnBeforeResourceLoad(const browser: ICefBrowser; const frame: ICefFrame;
const request: ICefRequest; const callback: ICefRequestCallback): TCefReturnValue; override;
function GetResourceHandler(const browser: ICefBrowser; const frame: ICefFrame;
const request: ICefRequest): ICefResourceHandler; override;
procedure OnResourceRedirect(const browser: ICefBrowser; const frame: ICefFrame;
const request: ICefRequest; var newUrl: ustring); override;
function OnResourceResponse(const browser: ICefBrowser; const frame: ICefFrame;
const request: ICefRequest; const response: ICefResponse): Boolean; override;
function GetResourceResponseFilter(const browser: ICefBrowser; const frame: ICefFrame;
const request: ICefRequest; const response: ICefResponse): ICefResponseFilter; override;
procedure OnResourceLoadComplete(const browser: ICefBrowser; const frame: ICefFrame;
const request: ICefRequest; const response: ICefResponse; status: TCefUrlRequestStatus;
receivedContentLength: Int64); override;
function GetAuthCredentials(const browser: ICefBrowser; const frame: ICefFrame;
isProxy: Boolean; const host: ustring; port: Integer; const realm, scheme: ustring;
const callback: ICefAuthCallback): Boolean; override;
function OnQuotaRequest(const browser: ICefBrowser; const originUrl: ustring;
newSize: Int64; const callback: ICefRequestCallback): Boolean; override;
procedure OnProtocolExecution(const browser: ICefBrowser; const url: ustring; out allowOsExecution: Boolean); override;
function OnCertificateError(const browser: ICefBrowser; certError: TCefErrorcode;
const requestUrl: ustring; const sslInfo: ICefSslInfo; const callback: ICefRequestCallback): Boolean; override;
procedure OnPluginCrashed(const browser: ICefBrowser; const pluginPath: ustring); override;
procedure OnRenderViewReady(const browser: ICefBrowser); override;
procedure OnRenderProcessTerminated(const browser: ICefBrowser; status: TCefTerminationStatus); override;
public
constructor Create(aDcefBrowser: IDcefBrowser); reintroduce;
destructor Destroy; override;
end;
implementation
{ TCustomRequestHandler }
constructor TDcefBRequestHandler.Create(aDcefBrowser: IDcefBrowser);
begin
inherited Create;
FEvents := aDcefBrowser;
end;
destructor TDcefBRequestHandler.Destroy;
begin
FEvents := nil;
inherited;
end;
// Called on the IO thread
function TDcefBRequestHandler.GetAuthCredentials(const browser: ICefBrowser;
const frame: ICefFrame; isProxy: Boolean; const host: ustring; port: Integer;
const realm, scheme: ustring; const callback: ICefAuthCallback): Boolean;
var
PArgs: PAuthCredentialsArgs;
begin
inherited;
result := true;
New(PArgs);
PArgs.frame := @frame;
PArgs.isProxy := @isProxy;
PArgs.host := @host;
PArgs.port := @port;
PArgs.realm := @realm;
PArgs.scheme := @scheme;
PArgs.callback := @callback;
PArgs.CancelDefaultEvent := False;
PArgs.Result := @Result;
TDcefBUtils.SendMsg(browser, WM_GetAuthCredentials, LParam(PArgs));
Dispose(PArgs);
end;
// Called on the IO thread
function TDcefBRequestHandler.GetResourceHandler(const browser: ICefBrowser;
const frame: ICefFrame; const Request: ICefRequest): ICefResourceHandler;
begin
FEvents.doOnGetResourceHandler(browser, frame, Request, Result);
end;
// Called on the IO thread
function TDcefBRequestHandler.GetResourceResponseFilter(
const browser: ICefBrowser; const frame: ICefFrame;
const request: ICefRequest; const response: ICefResponse): ICefResponseFilter;
begin
FEvents.doOnGetResourceResponseFilter(browser, frame, request, response, Result);
end;
// Called on the UI thread
function TDcefBRequestHandler.OnBeforeBrowse(const browser: ICefBrowser;
const frame: ICefFrame; const Request: ICefRequest;
isRedirect: Boolean): Boolean;
begin
Result := False;
FEvents.doOnBeforeBrowse(browser, frame, Request, isRedirect, Result);
end;
// Called on the IO thread
function TDcefBRequestHandler.OnBeforeResourceLoad(const browser: ICefBrowser; const frame: ICefFrame;
const request: ICefRequest; const callback: ICefRequestCallback): TCefReturnValue;
begin
Result := TCefReturnValue.RV_CONTINUE;
FEvents.doOnBeforeResourceLoad(browser, frame, request, callback, Result);
end;
// Called on the UI thread
function TDcefBRequestHandler.OnCertificateError(const browser: ICefBrowser; certError: TCefErrorcode;
const requestUrl: ustring; const sslInfo: ICefSslInfo; const callback: ICefRequestCallback): Boolean;
begin
Result := False;
FEvents.doOnCertificateError(browser, certError, requestUrl, sslInfo, callback, Result);
end;
// Called on the UI thread
function TDcefBRequestHandler.OnOpenUrlFromTab(const browser: ICefBrowser;
const frame: ICefFrame; const targetUrl: ustring;
targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean): Boolean;
begin
inherited;
Result := False;
FEvents.doOnOpenUrlFromTab(browser, frame, targetUrl, targetDisposition, userGesture, Result);
end;
// Called on the browser process UI thread
procedure TDcefBRequestHandler.OnPluginCrashed(const browser: ICefBrowser;
const pluginPath: ustring);
begin
inherited;
FEvents.doOnPluginCrashed(browser, pluginPath);
end;
// Called on the UI thread
procedure TDcefBRequestHandler.OnProtocolExecution(const browser: ICefBrowser;
const url: ustring; out allowOsExecution: Boolean);
begin
inherited;
FEvents.doOnProtocolExecution(browser, url, allowOsExecution);
end;
// Called on the IO thread
function TDcefBRequestHandler.OnQuotaRequest(const browser: ICefBrowser; const originUrl: ustring;
newSize: Int64; const callback: ICefRequestCallback): Boolean;
begin
Result := False;
FEvents.doOnQuotaRequest(browser, originUrl, newSize, callback, Result);
end;
// Called on the browser process UI thread
procedure TDcefBRequestHandler.OnRenderProcessTerminated(const browser
: ICefBrowser; status: TCefTerminationStatus);
begin
inherited;
FEvents.doOnRenderProcessTerminated(browser, status);
end;
// Called on the browser process UI thread
procedure TDcefBRequestHandler.OnRenderViewReady(const browser: ICefBrowser);
begin
inherited;
//FEvents.doOnRenderViewReady(browser);
end;
// Called on the IO thread
procedure TDcefBRequestHandler.OnResourceLoadComplete(
const browser: ICefBrowser; const frame: ICefFrame;
const request: ICefRequest; const response: ICefResponse;
status: TCefUrlRequestStatus; receivedContentLength: Int64);
begin
inherited;
FEvents.doOnResourceLoadComplete(browser, frame, request, response, status, receivedContentLength);
end;
// Called on the IO thread
procedure TDcefBRequestHandler.OnResourceRedirect(const browser: ICefBrowser; const frame: ICefFrame;
const request: ICefRequest; var newUrl: ustring);
begin
inherited;
FEvents.doOnResourceRedirect(browser, frame, request, newUrl);
end;
// Called on the IO thread
function TDcefBRequestHandler.OnResourceResponse(const browser: ICefBrowser;
const frame: ICefFrame; const request: ICefRequest;
const response: ICefResponse): Boolean;
begin
inherited;
Result := False;
FEvents.doOnResourceResponse(browser, frame, request, response, Result);
end;
end.
| 38.598253 | 123 | 0.780066 |
8529e423eb5e7c5034483755267f1bdecf922c97 | 361,169 | pas | Pascal | Delphi/LibUser/GIFImage.pas | tdebaets/common | d94411a3cc1902f4bb3c788ca9ee66a2d9664708 | [
"Apache-2.0"
]
| 4 | 2017-03-30T19:52:29.000Z | 2022-02-10T04:20:52.000Z | Delphi/LibUser/GIFImage.pas | tdebaets/common | d94411a3cc1902f4bb3c788ca9ee66a2d9664708 | [
"Apache-2.0"
]
| null | null | null | Delphi/LibUser/GIFImage.pas | tdebaets/common | d94411a3cc1902f4bb3c788ca9ee66a2d9664708 | [
"Apache-2.0"
]
| 3 | 2016-07-25T13:33:39.000Z | 2018-12-27T05:17:50.000Z | unit GIFImage;
////////////////////////////////////////////////////////////////////////////////
// //
// Project: GIF Graphics Object //
// Module: gifimage //
// Description: TGraphic implementation of the GIF89a graphics format //
// Version: 2.2 //
// Release: 5 //
// Date: 23-MAY-1999 //
// Target: Win32, Delphi 2, 3, 4 & 5, C++ Builder 3 & 4 //
// Author(s): anme: Anders Melander, anders@melander.dk //
// fila: Filip Larsen //
// rps: Reinier Sterkenburg //
// Copyright: (c) 1997-99 Anders Melander. //
// All rights reserved. //
// Formatting: 2 space indent, 8 space tabs, 80 columns. //
// //
////////////////////////////////////////////////////////////////////////////////
// Changed 2001.07.23 by Finn Tolderlund //
// Changed according to e-mail from "Rolf Frei" <rolf@eicom.ch> //
// on 2001.07.23 so that it works in Delphi 6. //
// //
// Changed 2002.07.07 by Finn Tolderlund //
// Incorporated additional modifications by Alexey Barkovoy (clootie@reactor.ru)
// found in his Delphi 6 GifImage.pas (from 22-Dec-2001). //
// Alexey Barkovoy's Delphi 6 gifimage.pas can be downloaded from //
// http://clootie.narod.ru/delphi/download_vcl.html //
// These changes made showing of animated gif files more stable. The code //
// from 2001.07.23 could crash sometimes with an Execption EAccessViolation. //
// //
////////////////////////////////////////////////////////////////////////////////
// //
// Please read the "Conditions of use" in the release notes. //
// //
////////////////////////////////////////////////////////////////////////////////
// Known problems:
//
// * The combination of buffered, tiled and transparent draw will display the
// background incorrectly (scaled).
// If this is a problem for you, use non-buffered (goDirectDraw) drawing
// instead.
//
// * The combination of non-buffered, transparent and stretched draw is
// sometimes distorted with a pattern effect when the image is displayed
// smaller than the real size (shrinked).
//
// * Buffered display flickers when TGIFImage is used by a transparent TImage
// component.
// This is a problem with TImage caused by the fact that TImage was designed
// with static images in mind. Not much I can do about it.
//
////////////////////////////////////////////////////////////////////////////////
// To do (in rough order of priority):
// { TODO -oanme -cFeature : TImage hook for destroy notification. }
// { TODO -oanme -cFeature : TBitmap pool to limit resource consumption on Win95/98. }
// { TODO -oanme -cImprovement : Make BitsPerPixel property writable. }
// { TODO -oanme -cFeature : Visual GIF component. }
// { TODO -oanme -cImprovement : Easier method to determine DrawPainter status. }
// { TODO -oanme -cFeature : Import to 256+ color GIF. }
// { TODO -oanme -cFeature : Make some of TGIFImage's properties persistent (DrawOptions etc). }
// { TODO -oanme -cFeature : Add TGIFImage.Persistent property. Should save published properties in application extension when this options is set. }
// { TODO -oanme -cBugFix : Solution for background buffering in scrollbox. }
//
//////////////////////////////////////////////////////////////////////////////////
{$ifdef BCB}
{$ObjExportAll On}
{$endif}
interface
////////////////////////////////////////////////////////////////////////////////
//
// Conditional Compiler Symbols
//
////////////////////////////////////////////////////////////////////////////////
(*
DEBUG Must be defined if any of the DEBUG_xxx
symbols are defined.
If the symbol is defined the source will not be
optimized and overflow- and range checks will be
enabled.
DEBUG_HASHPERFORMANCE Calculates hash table performance data.
DEBUG_HASHFILLFACTOR Calculates fill factor of hash table -
Interferes with DEBUG_HASHPERFORMANCE.
DEBUG_COMPRESSPERFORMANCE Calculates LZW compressor performance data.
DEBUG_DECOMPRESSPERFORMANCE Calculates LZW decompressor performance data.
DEBUG_DITHERPERFORMANCE Calculates color reduction performance data.
DEBUG_DRAWPERFORMANCE Calculates low level drawing performance data.
The performance data for DEBUG_DRAWPERFORMANCE
will be displayed when you press the Ctrl key.
DEBUG_RENDERPERFORMANCE Calculates performance data for the GIF to
bitmap converter.
The performance data for DEBUG_DRAWPERFORMANCE
will be displayed when you press the Ctrl key.
GIF_NOSAFETY Define this symbol to disable overflow- and
range checks.
Ignored if the DEBUG symbol is defined.
STRICT_MOZILLA Define to mimic Mozilla as closely as possible.
If not defined, a slightly more "optimal"
implementation is used (IMHO).
FAST_AS_HELL Define this symbol to use strictly GIF compliant
(but too fast) animation timing.
Since our paint routines are much faster and
more precise timed than Mozilla's, the standard
GIF and Mozilla values causes animations to loop
faster than they would in Mozilla.
If the symbol is _not_ defined, an alternative
set of tweaked timing values will be used.
The tweaked values are not optimal but are based
on tests performed on my reference system:
- Windows 95
- 133 MHz Pentium
- 64Mb RAM
- Diamond Stealth64/V3000
- 1600*1200 in 256 colors
The alternate values can be modified if you are
not satisfied with my defaults (they can be
found a few pages down).
REGISTER_TGIFIMAGE Define this symbol to register TGIFImage with
the TPicture class and integrate with TImage.
This is required to be able to display GIFs in
the TImage component.
The symbol is defined by default.
Undefine if you use another GIF library to
provide GIF support for TImage.
PIXELFORMAT_TOO_SLOW When this symbol is defined, the internal
PixelFormat routines are used in some places
instead of TBitmap.PixelFormat.
The current implementation (Delphi4, Builder 3)
of TBitmap.PixelFormat can in some situation
degrade performance.
The symbol is defined by default.
CREATEDIBSECTION_SLOW If this symbol is defined, TDIBWriter will
use global memory as scanline storage, instead
of a DIB section.
Benchmarks have shown that a DIB section is
twice as slow as global memory.
The symbol is defined by default.
The symbol requires that PIXELFORMAT_TOO_SLOW
is defined.
SERIALIZE_RENDER Define this symbol to serialize threaded
GIF to bitmap rendering.
When a GIF is displayed with the goAsync option
(the default), the GIF to bitmap rendering is
executed in the context of the draw thread.
If more than one thread is drawing the same GIF
or the GIF is being modified while it is
animating, the GIF to bitmap rendering should be
serialized to guarantee that the bitmap isn't
modified by more than one thread at a time. If
SERIALIZE_RENDER is defined, the draw threads
uses TThread.Synchronize to serialize GIF to
bitmap rendering.
*)
{$DEFINE REGISTER_TGIFIMAGE}
{$DEFINE PIXELFORMAT_TOO_SLOW}
{$DEFINE CREATEDIBSECTION_SLOW}
////////////////////////////////////////////////////////////////////////////////
//
// Determine Delphi and C++ Builder version
//
////////////////////////////////////////////////////////////////////////////////
// Delphi 1.x
{$IFDEF VER80}
'Error: TGIFImage does not support Delphi 1.x'
{$ENDIF}
// Delphi 2.x
{$IFDEF VER90}
{$DEFINE VER9x}
{$ENDIF}
// C++ Builder 1.x
{$IFDEF VER93}
// Good luck...
{$DEFINE VER9x}
{$ENDIF}
// Delphi 3.x
{$IFDEF VER100}
{$DEFINE VER10_PLUS}
{$DEFINE D3_BCB3}
{$ENDIF}
// C++ Builder 3.x
{$IFDEF VER110}
{$DEFINE VER10_PLUS}
{$DEFINE VER11_PLUS}
{$DEFINE D3_BCB3}
{$DEFINE BAD_STACK_ALIGNMENT}
{$ENDIF}
// Delphi 4.x
{$IFDEF VER120}
{$DEFINE VER10_PLUS}
{$DEFINE VER11_PLUS}
{$DEFINE VER12_PLUS}
{$DEFINE BAD_STACK_ALIGNMENT}
{$ENDIF}
// C++ Builder 4.x
{$IFDEF VER125}
{$DEFINE VER10_PLUS}
{$DEFINE VER11_PLUS}
{$DEFINE VER12_PLUS}
{$DEFINE VER125_PLUS}
{$DEFINE BAD_STACK_ALIGNMENT}
{$ENDIF}
// Delphi 5.x
{$IFDEF VER130}
{$DEFINE VER10_PLUS}
{$DEFINE VER11_PLUS}
{$DEFINE VER12_PLUS}
{$DEFINE VER125_PLUS}
{$DEFINE VER13_PLUS}
{$DEFINE BAD_STACK_ALIGNMENT}
{$ENDIF}
// Delphi 6.x
{$IFDEF VER140}
{$WARN SYMBOL_PLATFORM OFF}
{$DEFINE VER10_PLUS}
{$DEFINE VER11_PLUS}
{$DEFINE VER12_PLUS}
{$DEFINE VER125_PLUS}
{$DEFINE VER13_PLUS}
{$DEFINE VER14_PLUS}
{$DEFINE BAD_STACK_ALIGNMENT}
{$ENDIF}
// Unknown compiler version - assume D4 compatible
{$IFNDEF VER9x}
{$IFNDEF VER10_PLUS}
{$DEFINE VER10_PLUS}
{$DEFINE VER11_PLUS}
{$DEFINE VER12_PLUS}
{$DEFINE BAD_STACK_ALIGNMENT}
{$ENDIF}
{$ENDIF}
////////////////////////////////////////////////////////////////////////////////
//
// Compiler Options required to compile this library
//
////////////////////////////////////////////////////////////////////////////////
{$A+,B-,H+,J+,K-,M-,T-,X+}
// Debug control - You can safely change these settings
{$IFDEF DEBUG}
{$C+} // ASSERTIONS
{$O-} // OPTIMIZATION
{$Q+} // OVERFLOWCHECKS
{$R+} // RANGECHECKS
{$ELSE}
{$C-} // ASSERTIONS
{$IFDEF GIF_NOSAFETY}
{$Q-}// OVERFLOWCHECKS
{$R-}// RANGECHECKS
{$ENDIF}
{$ENDIF}
// Special options for Time2Help parser
{$ifdef TIME2HELP}
{$UNDEF PIXELFORMAT_TOO_SLOW}
{$endif}
////////////////////////////////////////////////////////////////////////////////
//
// External dependecies
//
////////////////////////////////////////////////////////////////////////////////
uses
sysutils,
Windows,
Graphics,
Classes;
////////////////////////////////////////////////////////////////////////////////
//
// TGIFImage library version
//
////////////////////////////////////////////////////////////////////////////////
const
GIFVersion = $0202;
GIFVersionMajor = 2;
GIFVersionMinor = 2;
GIFVersionRelease = 5;
////////////////////////////////////////////////////////////////////////////////
//
// Misc constants and support types
//
////////////////////////////////////////////////////////////////////////////////
const
GIFMaxColors = 256; // Max number of colors supported by GIF
// Don't bother changing this value!
BitmapAllocationThreshold = 500000; // Bitmap pixel count limit at which
// a newly allocated bitmap will be
// converted to 1 bit format before
// being resized and converted to 8 bit.
var
{$IFDEF FAST_AS_HELL}
GIFDelayExp: integer = 10; // Delay multiplier in mS.
{$ELSE}
GIFDelayExp: integer = 12; // Delay multiplier in mS. Tweaked.
{$ENDIF}
// * GIFDelayExp:
// The following delay values should all
// be multiplied by this value to
// calculate the effective time (in mS).
// According to the GIF specs, this
// value should be 10.
// Since our paint routines are much
// faster than Mozilla's, you might need
// to increase this value if your
// animations loops too fast. The
// optimal value is impossible to
// determine since it depends on the
// speed of the CPU, the viceo card,
// memory and many other factors.
GIFDefaultDelay: integer = 10; // * GIFDefaultDelay:
// Default animation delay.
// This value is used if no GCE is
// defined.
// (10 = 100 mS)
{$IFDEF FAST_AS_HELL}
GIFMinimumDelay: integer = 1; // Minimum delay (from Mozilla source).
// (1 = 10 mS)
{$ELSE}
GIFMinimumDelay: integer = 3; // Minimum delay - Tweaked.
{$ENDIF}
// * GIFMinimumDelay:
// The minumum delay used in the Mozilla
// source is 10mS. This corresponds to a
// value of 1. However, since our paint
// routines are much faster than
// Mozilla's, a value of 3 or 4 gives
// better results.
GIFMaximumDelay: integer = 1000; // * GIFMaximumDelay:
// Maximum delay when painter is running
// in main thread (goAsync is not set).
// This value guarantees that a very
// long and slow GIF does not hang the
// system.
// (1000 = 10000 mS = 10 Seconds)
type
TGIFVersion = (gvUnknown, gv87a, gv89a);
TGIFVersionRec = array[0..2] of char;
const
GIFVersions : array[gv87a..gv89a] of TGIFVersionRec = ('87a', '89a');
type
// TGIFImage mostly throws exceptions of type GIFException
GIFException = class(EInvalidGraphic);
// Severity level as indicated in the Warning methods and the OnWarning event
TGIFSeverity = (gsInfo, gsWarning, gsError);
////////////////////////////////////////////////////////////////////////////////
//
// Delphi 2.x support
//
////////////////////////////////////////////////////////////////////////////////
{$IFDEF VER9x}
// Delphi 2 doesn't support TBitmap.PixelFormat
{$DEFINE PIXELFORMAT_TOO_SLOW}
type
// TThreadList from Delphi 3 classes.pas
TThreadList = class
private
FList: TList;
FLock: TRTLCriticalSection;
public
constructor Create;
destructor Destroy; override;
procedure Add(Item: Pointer);
procedure Clear;
function LockList: TList;
procedure Remove(Item: Pointer);
procedure UnlockList;
end;
// From Delphi 3 sysutils.pas
EOutOfMemory = class(Exception);
// From Delphi 3 classes.pas
EOutOfResources = class(EOutOfMemory);
// From Delphi 3 windows.pas
PMaxLogPalette = ^TMaxLogPalette;
TMaxLogPalette = packed record
palVersion: Word;
palNumEntries: Word;
palPalEntry: array [Byte] of TPaletteEntry;
end; { TMaxLogPalette }
// From Delphi 3 graphics.pas. Used by the D3 TGraphic class.
TProgressStage = (psStarting, psRunning, psEnding);
TProgressEvent = procedure (Sender: TObject; Stage: TProgressStage;
PercentDone: Byte; RedrawNow: Boolean; const R: TRect; const Msg: string) of object;
// From Delphi 3 windows.pas
PRGBTriple = ^TRGBTriple;
{$ENDIF}
////////////////////////////////////////////////////////////////////////////////
//
// Forward declarations
//
////////////////////////////////////////////////////////////////////////////////
type
TGIFImage = class;
TGIFSubImage = class;
////////////////////////////////////////////////////////////////////////////////
//
// TGIFItem
//
////////////////////////////////////////////////////////////////////////////////
TGIFItem = class(TPersistent)
private
FGIFImage: TGIFImage;
protected
function GetVersion: TGIFVersion; virtual;
procedure Warning(Severity: TGIFSeverity; Message: string); virtual;
public
constructor Create(GIFImage: TGIFImage); virtual;
procedure SaveToStream(Stream: TStream); virtual; abstract;
procedure LoadFromStream(Stream: TStream); virtual; abstract;
procedure SaveToFile(const Filename: string); virtual;
procedure LoadFromFile(const Filename: string); virtual;
property Version: TGIFVersion read GetVersion;
property Image: TGIFImage read FGIFImage;
end;
////////////////////////////////////////////////////////////////////////////////
//
// TGIFList
//
////////////////////////////////////////////////////////////////////////////////
TGIFList = class(TPersistent)
private
FItems: TList;
FImage: TGIFImage;
protected
function GetItem(Index: Integer): TGIFItem;
procedure SetItem(Index: Integer; Item: TGIFItem);
function GetCount: Integer;
procedure Warning(Severity: TGIFSeverity; Message: string); virtual;
public
constructor Create(Image: TGIFImage);
destructor Destroy; override;
function Add(Item: TGIFItem): Integer;
procedure Clear;
procedure Delete(Index: Integer);
procedure Exchange(Index1, Index2: Integer);
function First: TGIFItem;
function IndexOf(Item: TGIFItem): Integer;
procedure Insert(Index: Integer; Item: TGIFItem);
function Last: TGIFItem;
procedure Move(CurIndex, NewIndex: Integer);
function Remove(Item: TGIFItem): Integer;
procedure SaveToStream(Stream: TStream); virtual;
procedure LoadFromStream(Stream: TStream; Parent: TObject); virtual; abstract;
property Items[Index: Integer]: TGIFItem read GetItem write SetItem; default;
property Count: Integer read GetCount;
property List: TList read FItems;
property Image: TGIFImage read FImage;
end;
////////////////////////////////////////////////////////////////////////////////
//
// TGIFColorMap
//
////////////////////////////////////////////////////////////////////////////////
// One way to do it:
// TBaseColor = (bcRed, bcGreen, bcBlue);
// TGIFColor = array[bcRed..bcBlue] of BYTE;
// Another way:
TGIFColor = packed record
Red: byte;
Green: byte;
Blue: byte;
end;
TColorMap = packed array[0..GIFMaxColors-1] of TGIFColor;
PColorMap = ^TColorMap;
TUsageCount = record
Count : integer; // # of pixels using color index
Index : integer; // Color index
end;
TColormapHistogram = array[0..255] of TUsageCount;
TColormapReverse = array[0..255] of byte;
TGIFColorMap = class(TPersistent)
private
FColorMap : PColorMap;
FCount : integer;
FCapacity : integer;
FOptimized : boolean;
protected
function GetColor(Index: integer): TColor;
procedure SetColor(Index: integer; Value: TColor);
function GetBitsPerPixel: integer;
function DoOptimize: boolean;
procedure SetCapacity(Size: integer);
procedure Warning(Severity: TGIFSeverity; Message: string); virtual; abstract;
procedure BuildHistogram(var Histogram: TColormapHistogram); virtual; abstract;
procedure MapImages(var Map: TColormapReverse); virtual; abstract;
public
constructor Create;
destructor Destroy; override;
class function Color2RGB(Color: TColor): TGIFColor;
class function RGB2Color(Color: TGIFColor): TColor;
procedure SaveToStream(Stream: TStream);
procedure LoadFromStream(Stream: TStream; Count: integer);
procedure Assign(Source: TPersistent); override;
function IndexOf(Color: TColor): integer;
function Add(Color: TColor): integer;
function AddUnique(Color: TColor): integer;
procedure Delete(Index: integer);
procedure Clear;
function Optimize: boolean; virtual; abstract;
procedure Changed; virtual; abstract;
procedure ImportPalette(Palette: HPalette);
procedure ImportColorTable(Pal: pointer; Count: integer);
procedure ImportDIBColors(Handle: HDC);
procedure ImportColorMap(Map: TColorMap; Count: integer);
function ExportPalette: HPalette;
property Colors[Index: integer]: TColor read GetColor write SetColor; default;
property Data: PColorMap read FColorMap;
property Count: integer read FCount;
property Optimized: boolean read FOptimized write FOptimized;
property BitsPerPixel: integer read GetBitsPerPixel;
end;
////////////////////////////////////////////////////////////////////////////////
//
// TGIFHeader
//
////////////////////////////////////////////////////////////////////////////////
TLogicalScreenDescriptor = packed record
ScreenWidth: word; { logical screen width }
ScreenHeight: word; { logical screen height }
PackedFields: byte; { packed fields }
BackgroundColorIndex: byte; { index to global color table }
AspectRatio: byte; { actual ratio = (AspectRatio + 15) / 64 }
end;
TGIFHeader = class(TGIFItem)
private
FLogicalScreenDescriptor: TLogicalScreenDescriptor;
FColorMap : TGIFColorMap;
procedure Prepare;
protected
function GetVersion: TGIFVersion; override;
function GetBackgroundColor: TColor;
procedure SetBackgroundColor(Color: TColor);
procedure SetBackgroundColorIndex(Index: BYTE);
function GetBitsPerPixel: integer;
function GetColorResolution: integer;
public
constructor Create(GIFImage: TGIFImage); override;
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
procedure SaveToStream(Stream: TStream); override;
procedure LoadFromStream(Stream: TStream); override;
procedure Clear;
property Version: TGIFVersion read GetVersion;
property Width: WORD read FLogicalScreenDescriptor.ScreenWidth
write FLogicalScreenDescriptor.ScreenWidth;
property Height: WORD read FLogicalScreenDescriptor.ScreenHeight
write FLogicalScreenDescriptor.Screenheight;
property BackgroundColorIndex: BYTE read FLogicalScreenDescriptor.BackgroundColorIndex
write SetBackgroundColorIndex;
property BackgroundColor: TColor read GetBackgroundColor
write SetBackgroundColor;
property AspectRatio: BYTE read FLogicalScreenDescriptor.AspectRatio
write FLogicalScreenDescriptor.AspectRatio;
property ColorMap: TGIFColorMap read FColorMap;
property BitsPerPixel: integer read GetBitsPerPixel;
property ColorResolution: integer read GetColorResolution;
end;
////////////////////////////////////////////////////////////////////////////////
//
// TGIFExtension
//
////////////////////////////////////////////////////////////////////////////////
TGIFExtensionType = BYTE;
TGIFExtension = class;
TGIFExtensionClass = class of TGIFExtension;
TGIFGraphicControlExtension = class;
TGIFExtension = class(TGIFItem)
private
FSubImage: TGIFSubImage;
protected
function GetExtensionType: TGIFExtensionType; virtual; abstract;
function GetVersion: TGIFVersion; override;
function DoReadFromStream(Stream: TStream): TGIFExtensionType;
class procedure RegisterExtension(elabel: BYTE; eClass: TGIFExtensionClass);
class function FindExtension(Stream: TStream): TGIFExtensionClass;
class function FindSubExtension(Stream: TStream): TGIFExtensionClass; virtual;
public
// Ignore compiler warning about hiding base class constructor
constructor Create(ASubImage: TGIFSubImage); {$IFDEF VER12_PLUS} reintroduce; {$ENDIF} virtual;
destructor Destroy; override;
procedure SaveToStream(Stream: TStream); override;
procedure LoadFromStream(Stream: TStream); override;
property ExtensionType: TGIFExtensionType read GetExtensionType;
property SubImage: TGIFSubImage read FSubImage;
end;
////////////////////////////////////////////////////////////////////////////////
//
// TGIFSubImage
//
////////////////////////////////////////////////////////////////////////////////
TGIFExtensionList = class(TGIFList)
protected
function GetExtension(Index: Integer): TGIFExtension;
procedure SetExtension(Index: Integer; Extension: TGIFExtension);
public
procedure LoadFromStream(Stream: TStream; Parent: TObject); override;
property Extensions[Index: Integer]: TGIFExtension read GetExtension write SetExtension; default;
end;
TImageDescriptor = packed record
Separator: byte; { fixed value of ImageSeparator }
Left: word; { Column in pixels in respect to left edge of logical screen }
Top: word; { row in pixels in respect to top of logical screen }
Width: word; { width of image in pixels }
Height: word; { height of image in pixels }
PackedFields: byte; { Bit fields }
end;
TGIFSubImage = class(TGIFItem)
private
FBitmap : TBitmap;
FMask : HBitmap;
FNeedMask : boolean;
FLocalPalette : HPalette;
FData : PChar;
FDataSize : integer;
FColorMap : TGIFColorMap;
FImageDescriptor : TImageDescriptor;
FExtensions : TGIFExtensionList;
FTransparent : boolean;
FGCE : TGIFGraphicControlExtension;
procedure Prepare;
procedure Compress(Stream: TStream);
procedure Decompress(Stream: TStream);
protected
function GetVersion: TGIFVersion; override;
function GetInterlaced: boolean;
procedure SetInterlaced(Value: boolean);
function GetColorResolution: integer;
function GetBitsPerPixel: integer;
procedure AssignTo(Dest: TPersistent); override;
function DoGetBitmap: TBitmap;
function DoGetDitherBitmap: TBitmap;
function GetBitmap: TBitmap;
procedure SetBitmap(Value: TBitmap);
procedure FreeMask;
function GetEmpty: Boolean;
function GetPalette: HPALETTE;
procedure SetPalette(Value: HPalette);
function GetActiveColorMap: TGIFColorMap;
function GetBoundsRect: TRect;
procedure SetBoundsRect(const Value: TRect);
procedure DoSetBounds(ALeft, ATop, AWidth, AHeight: integer);
function GetClientRect: TRect;
function GetPixel(x, y: integer): BYTE;
function GetScanline(y: integer): pointer;
procedure NewBitmap;
procedure FreeBitmap;
procedure NewImage;
procedure FreeImage;
procedure NeedImage;
function ScaleRect(DestRect: TRect): TRect;
function HasMask: boolean;
function GetBounds(Index: integer): WORD;
procedure SetBounds(Index: integer; Value: WORD);
function GetHasBitmap: boolean;
procedure SetHasBitmap(Value: boolean);
public
constructor Create(GIFImage: TGIFImage); override;
destructor Destroy; override;
procedure Clear;
procedure SaveToStream(Stream: TStream); override;
procedure LoadFromStream(Stream: TStream); override;
procedure Assign(Source: TPersistent); override;
procedure Draw(ACanvas: TCanvas; const Rect: TRect;
DoTransparent, DoTile: boolean);
procedure StretchDraw(ACanvas: TCanvas; const Rect: TRect;
DoTransparent, DoTile: boolean);
procedure Crop;
procedure Merge(Previous: TGIFSubImage);
property HasBitmap: boolean read GetHasBitmap write SetHasBitmap;
property Left: WORD index 1 read GetBounds write SetBounds;
property Top: WORD index 2 read GetBounds write SetBounds;
property Width: WORD index 3 read GetBounds write SetBounds;
property Height: WORD index 4 read GetBounds write SetBounds;
property BoundsRect: TRect read GetBoundsRect write SetBoundsRect;
property ClientRect: TRect read GetClientRect;
property Interlaced: boolean read GetInterlaced write SetInterlaced;
property ColorMap: TGIFColorMap read FColorMap;
property ActiveColorMap: TGIFColorMap read GetActiveColorMap;
property Data: PChar read FData;
property DataSize: integer read FDataSize;
property Extensions: TGIFExtensionList read FExtensions;
property Version: TGIFVersion read GetVersion;
property ColorResolution: integer read GetColorResolution;
property BitsPerPixel: integer read GetBitsPerPixel;
property Bitmap: TBitmap read GetBitmap write SetBitmap;
property Mask: HBitmap read FMask;
property Palette: HPALETTE read GetPalette write SetPalette;
property Empty: boolean read GetEmpty;
property Transparent: boolean read FTransparent;
property GraphicControlExtension: TGIFGraphicControlExtension read FGCE;
property Pixels[x, y: integer]: BYTE read GetPixel;
property Scanline[y: integer]: pointer read GetScanline;
end;
////////////////////////////////////////////////////////////////////////////////
//
// TGIFTrailer
//
////////////////////////////////////////////////////////////////////////////////
TGIFTrailer = class(TGIFItem)
procedure SaveToStream(Stream: TStream); override;
procedure LoadFromStream(Stream: TStream); override;
end;
////////////////////////////////////////////////////////////////////////////////
//
// TGIFGraphicControlExtension
//
////////////////////////////////////////////////////////////////////////////////
// Graphic Control Extension block a.k.a GCE
TGIFGCERec = packed record
BlockSize: byte; { should be 4 }
PackedFields: Byte;
DelayTime: Word; { in centiseconds }
TransparentColorIndex: Byte;
Terminator: Byte;
end;
TDisposalMethod = (dmNone, dmNoDisposal, dmBackground, dmPrevious);
TGIFGraphicControlExtension = class(TGIFExtension)
private
FGCExtension: TGIFGCERec;
protected
function GetExtensionType: TGIFExtensionType; override;
function GetTransparent: boolean;
procedure SetTransparent(Value: boolean);
function GetTransparentColor: TColor;
procedure SetTransparentColor(Color: TColor);
function GetTransparentColorIndex: BYTE;
procedure SetTransparentColorIndex(Value: BYTE);
function GetDelay: WORD;
procedure SetDelay(Value: WORD);
function GetUserInput: boolean;
procedure SetUserInput(Value: boolean);
function GetDisposal: TDisposalMethod;
procedure SetDisposal(Value: TDisposalMethod);
public
constructor Create(ASubImage: TGIFSubImage); override;
destructor Destroy; override;
procedure SaveToStream(Stream: TStream); override;
procedure LoadFromStream(Stream: TStream); override;
property Delay: WORD read GetDelay write SetDelay;
property Transparent: boolean read GetTransparent write SetTransparent;
property TransparentColorIndex: BYTE read GetTransparentColorIndex
write SetTransparentColorIndex;
property TransparentColor: TColor read GetTransparentColor write SetTransparentColor;
property UserInput: boolean read GetUserInput write SetUserInput;
property Disposal: TDisposalMethod read GetDisposal write SetDisposal;
end;
////////////////////////////////////////////////////////////////////////////////
//
// TGIFTextExtension
//
////////////////////////////////////////////////////////////////////////////////
TGIFPlainTextExtensionRec = packed record
BlockSize: byte; { should be 12 }
Left, Top, Width, Height: Word;
CellWidth, CellHeight: Byte;
TextFGColorIndex,
TextBGColorIndex: Byte;
end;
TGIFTextExtension = class(TGIFExtension)
private
FText : TStrings;
FPlainTextExtension : TGIFPlainTextExtensionRec;
protected
function GetExtensionType: TGIFExtensionType; override;
function GetForegroundColor: TColor;
procedure SetForegroundColor(Color: TColor);
function GetBackgroundColor: TColor;
procedure SetBackgroundColor(Color: TColor);
function GetBounds(Index: integer): WORD;
procedure SetBounds(Index: integer; Value: WORD);
function GetCharWidthHeight(Index: integer): BYTE;
procedure SetCharWidthHeight(Index: integer; Value: BYTE);
function GetColorIndex(Index: integer): BYTE;
procedure SetColorIndex(Index: integer; Value: BYTE);
public
constructor Create(ASubImage: TGIFSubImage); override;
destructor Destroy; override;
procedure SaveToStream(Stream: TStream); override;
procedure LoadFromStream(Stream: TStream); override;
property Left: WORD index 1 read GetBounds write SetBounds;
property Top: WORD index 2 read GetBounds write SetBounds;
property GridWidth: WORD index 3 read GetBounds write SetBounds;
property GridHeight: WORD index 4 read GetBounds write SetBounds;
property CharWidth: BYTE index 1 read GetCharWidthHeight write SetCharWidthHeight;
property CharHeight: BYTE index 2 read GetCharWidthHeight write SetCharWidthHeight;
property ForegroundColorIndex: BYTE index 1 read GetColorIndex write SetColorIndex;
property ForegroundColor: TColor read GetForegroundColor;
property BackgroundColorIndex: BYTE index 2 read GetColorIndex write SetColorIndex;
property BackgroundColor: TColor read GetBackgroundColor;
property Text: TStrings read FText write FText;
end;
////////////////////////////////////////////////////////////////////////////////
//
// TGIFCommentExtension
//
////////////////////////////////////////////////////////////////////////////////
TGIFCommentExtension = class(TGIFExtension)
private
FText : TStrings;
protected
function GetExtensionType: TGIFExtensionType; override;
public
constructor Create(ASubImage: TGIFSubImage); override;
destructor Destroy; override;
procedure SaveToStream(Stream: TStream); override;
procedure LoadFromStream(Stream: TStream); override;
property Text: TStrings read FText;
end;
////////////////////////////////////////////////////////////////////////////////
//
// TGIFApplicationExtension
//
////////////////////////////////////////////////////////////////////////////////
TGIFIdentifierCode = array[0..7] of char;
TGIFAuthenticationCode = array[0..2] of char;
TGIFApplicationRec = packed record
Identifier : TGIFIdentifierCode;
Authentication : TGIFAuthenticationCode;
end;
TGIFApplicationExtension = class;
TGIFAppExtensionClass = class of TGIFApplicationExtension;
TGIFApplicationExtension = class(TGIFExtension)
private
FIdent : TGIFApplicationRec;
function GetAuthentication: string;
function GetIdentifier: string;
protected
function GetExtensionType: TGIFExtensionType; override;
procedure SetAuthentication(const Value: string);
procedure SetIdentifier(const Value: string);
procedure SaveData(Stream: TStream); virtual; abstract;
procedure LoadData(Stream: TStream); virtual; abstract;
public
constructor Create(ASubImage: TGIFSubImage); override;
destructor Destroy; override;
procedure SaveToStream(Stream: TStream); override;
procedure LoadFromStream(Stream: TStream); override;
class procedure RegisterExtension(eIdent: TGIFApplicationRec; eClass: TGIFAppExtensionClass);
class function FindSubExtension(Stream: TStream): TGIFExtensionClass; override;
property Identifier: string read GetIdentifier write SetIdentifier;
property Authentication: string read GetAuthentication write SetAuthentication;
end;
////////////////////////////////////////////////////////////////////////////////
//
// TGIFUnknownAppExtension
//
////////////////////////////////////////////////////////////////////////////////
TGIFBlock = class(TObject)
private
FSize : BYTE;
FData : pointer;
public
constructor Create(ASize: integer);
destructor Destroy; override;
procedure SaveToStream(Stream: TStream);
procedure LoadFromStream(Stream: TStream);
property Size: BYTE read FSize;
property Data: pointer read FData;
end;
TGIFUnknownAppExtension = class(TGIFApplicationExtension)
private
FBlocks : TList;
protected
procedure SaveData(Stream: TStream); override;
procedure LoadData(Stream: TStream); override;
public
constructor Create(ASubImage: TGIFSubImage); override;
destructor Destroy; override;
property Blocks: TList read FBlocks;
end;
////////////////////////////////////////////////////////////////////////////////
//
// TGIFAppExtNSLoop
//
////////////////////////////////////////////////////////////////////////////////
TGIFAppExtNSLoop = class(TGIFApplicationExtension)
private
FLoops : WORD;
FBufferSize : DWORD;
protected
procedure SaveData(Stream: TStream); override;
procedure LoadData(Stream: TStream); override;
public
constructor Create(ASubImage: TGIFSubImage); override;
property Loops: WORD read FLoops write FLoops;
property BufferSize: DWORD read FBufferSize write FBufferSize;
end;
////////////////////////////////////////////////////////////////////////////////
//
// TGIFImage
//
////////////////////////////////////////////////////////////////////////////////
TGIFImageList = class(TGIFList)
protected
function GetImage(Index: Integer): TGIFSubImage;
procedure SetImage(Index: Integer; SubImage: TGIFSubImage);
public
procedure LoadFromStream(Stream: TStream; Parent: TObject); override;
procedure SaveToStream(Stream: TStream); override;
property SubImages[Index: Integer]: TGIFSubImage read GetImage write SetImage; default;
end;
// Compression algorithms
TGIFCompression =
(gcLZW, // Normal LZW compression
gcRLE // GIF compatible RLE compression
);
// Color reduction methods
TColorReduction =
(rmNone, // Do not perform color reduction
rmWindows20, // Reduce to the Windows 20 color system palette
rmWindows256, // Reduce to the Windows 256 color halftone palette (Only works in 256 color display mode)
rmWindowsGray, // Reduce to the Windows 4 grayscale colors
rmMonochrome, // Reduce to a black/white monochrome palette
rmGrayScale, // Reduce to a uniform 256 shade grayscale palette
rmNetscape, // Reduce to the Netscape 216 color palette
rmQuantize, // Reduce to optimal 2^n color palette
rmQuantizeWindows, // Reduce to optimal 256 color windows palette
rmPalette // Reduce to custom palette
);
TDitherMode =
(dmNearest, // Nearest color matching w/o error correction
dmFloydSteinberg, // Floyd Steinberg Error Diffusion dithering
dmStucki, // Stucki Error Diffusion dithering
dmSierra, // Sierra Error Diffusion dithering
dmJaJuNI, // Jarvis, Judice & Ninke Error Diffusion dithering
dmSteveArche, // Stevenson & Arche Error Diffusion dithering
dmBurkes // Burkes Error Diffusion dithering
// dmOrdered, // Ordered dither
);
// Optimization options
TGIFOptimizeOption =
(ooCrop, // Crop animated GIF frames
ooMerge, // Merge pixels of same color
ooCleanup, // Remove comments and application extensions
ooColorMap, // Sort color map by usage and remove unused entries
ooReduceColors // Reduce color depth ***NOT IMPLEMENTED***
);
TGIFOptimizeOptions = set of TGIFOptimizeOption;
TGIFDrawOption =
(goAsync, // Asyncronous draws (paint in thread)
goTransparent, // Transparent draws
goAnimate, // Animate draws
goLoop, // Loop animations
goLoopContinously, // Ignore loop count and loop forever
goValidateCanvas, // Validate canvas in threaded paint ***NOT IMPLEMENTED***
goDirectDraw, // Draw() directly on canvas
goClearOnLoop, // Clear animation on loop
goTile, // Tiled display
goDither, // Dither to Netscape palette
goAutoDither // Only dither on 256 color systems
);
TGIFDrawOptions = set of TGIFDrawOption;
// Note: if goAsync is not set then goDirectDraw should be set. Otherwise
// the image will not be displayed.
PGIFPainter = ^TGIFPainter;
TGIFPainter = class(TThread)
private
FImage : TGIFImage; // The TGIFImage that owns this painter
FCanvas : TCanvas; // Destination canvas
FRect : TRect; // Destination rect
FDrawOptions : TGIFDrawOptions;// Paint options
FAnimationSpeed : integer; // Animation speed %
FActiveImage : integer; // Current frame
Disposal , // Used by synchronized paint
OldDisposal : TDisposalMethod;// Used by synchronized paint
BackupBuffer : TBitmap; // Used by synchronized paint
FrameBuffer : TBitmap; // Used by synchronized paint
Background : TBitmap; // Used by synchronized paint
ValidateDC : HDC;
DoRestart : boolean; // Flag used to restart animation
FStarted : boolean; // Flag used to signal start of paint
PainterRef : PGIFPainter; // Pointer to var referencing painter
FEventHandle : THandle; // Animation delay event
ExceptObject : Exception; // Eaten exception
ExceptAddress : pointer; // Eaten exceptions address
FEvent : TNotifyEvent; // Used by synchronized events
FOnStartPaint : TNotifyEvent;
FOnPaint : TNotifyEvent;
FOnAfterPaint : TNotifyEvent;
FOnLoop : TNotifyEvent;
FOnEndPaint : TNotifyEvent;
procedure DoOnTerminate(Sender: TObject);// Sync. shutdown procedure
procedure DoSynchronize(Method: TThreadMethod);// Conditional sync stub
{$ifdef SERIALIZE_RENDER}
procedure PrefetchBitmap; // Sync. bitmap prefetch
{$endif}
procedure DoPaintFrame; // Sync. buffered paint procedure
procedure DoPaint; // Sync. paint procedure
procedure DoEvent;
procedure SetActiveImage(const Value: integer);// Sync. event procedure
protected
procedure Execute; override;
procedure SetAnimationSpeed(Value: integer);
public
constructor Create(AImage: TGIFImage; ACanvas: TCanvas; ARect: TRect;
Options: TGIFDrawOptions);
constructor CreateRef(Painter: PGIFPainter; AImage: TGIFImage; ACanvas: TCanvas; ARect: TRect;
Options: TGIFDrawOptions);
destructor Destroy; override;
procedure Start;
procedure Stop;
procedure Restart;
property Image: TGIFImage read FImage;
property Canvas: TCanvas read FCanvas;
property Rect: TRect read FRect write FRect;
property DrawOptions: TGIFDrawOptions read FDrawOptions write FDrawOptions;
property AnimationSpeed: integer read FAnimationSpeed write SetAnimationSpeed;
property Started: boolean read FStarted;
property ActiveImage: integer read FActiveImage write SetActiveImage;
property OnStartPaint: TNotifyEvent read FOnStartPaint write FOnStartPaint;
property OnPaint: TNotifyEvent read FOnPaint write FOnPaint;
property OnAfterPaint: TNotifyEvent read FOnAfterPaint write FOnAfterPaint;
property OnLoop: TNotifyEvent read FOnLoop write FOnLoop;
property OnEndPaint : TNotifyEvent read FOnEndPaint write FOnEndPaint ;
property EventHandle: THandle read FEventHandle;
end;
TGIFWarning = procedure(Sender: TObject; Severity: TGIFSeverity; Message: string) of object;
TGIFImage = class(TGraphic)
private
IsDrawing : Boolean;
IsInsideGetPalette : boolean;
FImages : TGIFImageList;
FHeader : TGIFHeader;
FGlobalPalette : HPalette;
FPainters : TThreadList;
FDrawOptions : TGIFDrawOptions;
FColorReduction : TColorReduction;
FReductionBits : integer;
FDitherMode : TDitherMode;
FCompression : TGIFCompression;
FOnWarning : TGIFWarning;
FBitmap : TBitmap;
FDrawPainter : TGIFPainter;
FThreadPriority : TThreadPriority;
FAnimationSpeed : integer;
FDrawBackgroundColor: TColor;
FOnStartPaint : TNotifyEvent;
FOnPaint : TNotifyEvent;
FOnAfterPaint : TNotifyEvent;
FOnLoop : TNotifyEvent;
FOnEndPaint : TNotifyEvent;
{$IFDEF VER9x}
FPaletteModified : Boolean;
FOnProgress : TProgressEvent;
{$ENDIF}
function GetAnimate: Boolean; // 2002.07.07
procedure SetAnimate(const Value: Boolean); // 2002.07.07
protected
// Obsolete: procedure Changed(Sender: TObject); {$IFDEF VER9x} virtual; {$ELSE} override; {$ENDIF}
function GetHeight: Integer; override;
procedure SetHeight(Value: Integer); override;
function GetWidth: Integer; override;
procedure SetWidth(Value: Integer); override;
procedure AssignTo(Dest: TPersistent); override;
function InternalPaint(Painter: PGIFPainter; ACanvas: TCanvas; const Rect: TRect; Options: TGIFDrawOptions): TGIFPainter;
procedure Draw(ACanvas: TCanvas; const Rect: TRect); override;
function Equals(Graphic: TGraphic): Boolean; override;
function GetPalette: HPALETTE; {$IFDEF VER9x} virtual; {$ELSE} override; {$ENDIF}
procedure SetPalette(Value: HPalette); {$IFDEF VER9x} virtual; {$ELSE} override; {$ENDIF}
function GetEmpty: Boolean; override;
procedure WriteData(Stream: TStream); override;
function GetIsTransparent: Boolean;
function GetVersion: TGIFVersion;
function GetColorResolution: integer;
function GetBitsPerPixel: integer;
function GetBackgroundColorIndex: BYTE;
procedure SetBackgroundColorIndex(const Value: BYTE);
function GetBackgroundColor: TColor;
procedure SetBackgroundColor(const Value: TColor);
function GetAspectRatio: BYTE;
procedure SetAspectRatio(const Value: BYTE);
procedure SetDrawOptions(Value: TGIFDrawOptions);
procedure SetAnimationSpeed(Value: integer);
procedure SetReductionBits(Value: integer);
procedure NewImage;
function GetBitmap: TBitmap;
function NewBitmap: TBitmap;
procedure FreeBitmap;
function GetColorMap: TGIFColorMap;
function GetDoDither: boolean;
property DrawPainter: TGIFPainter read FDrawPainter; // Extremely volatile
property DoDither: boolean read GetDoDither;
{$IFDEF VER9x}
procedure Progress(Sender: TObject; Stage: TProgressStage;
PercentDone: Byte; RedrawNow: Boolean; const R: TRect; const Msg: string); dynamic;
{$ENDIF}
public
constructor Create; override;
destructor Destroy; override;
procedure SaveToStream(Stream: TStream); override;
procedure LoadFromStream(Stream: TStream); override;
procedure LoadFromResourceName(Instance: THandle; const ResName: String); // 2002.07.07
function Add(Source: TPersistent): integer;
procedure Pack;
procedure OptimizeColorMap;
procedure Optimize(Options: TGIFOptimizeOptions;
ColorReduction: TColorReduction; DitherMode: TDitherMode;
ReductionBits: integer);
procedure Clear;
procedure StopDraw;
function Paint(ACanvas: TCanvas; const Rect: TRect; Options: TGIFDrawOptions): TGIFPainter;
procedure PaintStart;
procedure PaintPause;
procedure PaintStop;
procedure PaintResume;
procedure PaintRestart;
procedure Warning(Sender: TObject; Severity: TGIFSeverity; Message: string); virtual;
procedure Assign(Source: TPersistent); override;
procedure LoadFromClipboardFormat(AFormat: Word; AData: THandle;
APalette: HPALETTE); override;
procedure SaveToClipboardFormat(var AFormat: Word; var AData: THandle;
var APalette: HPALETTE); override;
property GlobalColorMap: TGIFColorMap read GetColorMap;
property Version: TGIFVersion read GetVersion;
property Images: TGIFImageList read FImages;
property ColorResolution: integer read GetColorResolution;
property BitsPerPixel: integer read GetBitsPerPixel;
property BackgroundColorIndex: BYTE read GetBackgroundColorIndex write SetBackgroundColorIndex;
property BackgroundColor: TColor read GetBackgroundColor write SetBackgroundColor;
property AspectRatio: BYTE read GetAspectRatio write SetAspectRatio;
property Header: TGIFHeader read FHeader; // ***OBSOLETE***
property IsTransparent: boolean read GetIsTransparent;
property DrawOptions: TGIFDrawOptions read FDrawOptions write SetDrawOptions;
property DrawBackgroundColor: TColor read FDrawBackgroundColor write FDrawBackgroundColor;
property ColorReduction: TColorReduction read FColorReduction write FColorReduction;
property ReductionBits: integer read FReductionBits write SetReductionBits;
property DitherMode: TDitherMode read FDitherMode write FDitherMode;
property Compression: TGIFCompression read FCompression write FCompression;
property AnimationSpeed: integer read FAnimationSpeed write SetAnimationSpeed;
property Animate: Boolean read GetAnimate write SetAnimate; // 2002.07.07
property Painters: TThreadList read FPainters;
property ThreadPriority: TThreadPriority read FThreadPriority write FThreadPriority;
property Bitmap: TBitmap read GetBitmap; // Volatile - beware!
property OnWarning: TGIFWarning read FOnWarning write FOnWarning;
property OnStartPaint: TNotifyEvent read FOnStartPaint write FOnStartPaint;
property OnPaint: TNotifyEvent read FOnPaint write FOnPaint;
property OnAfterPaint: TNotifyEvent read FOnAfterPaint write FOnAfterPaint;
property OnLoop: TNotifyEvent read FOnLoop write FOnLoop;
property OnEndPaint : TNotifyEvent read FOnEndPaint write FOnEndPaint ;
{$IFDEF VER9x}
property Palette: HPALETTE read GetPalette write SetPalette;
property PaletteModified: Boolean read FPaletteModified write FPaletteModified;
property OnProgress: TProgressEvent read FOnProgress write FOnProgress;
{$ENDIF}
end;
////////////////////////////////////////////////////////////////////////////////
//
// Utility routines
//
////////////////////////////////////////////////////////////////////////////////
// WebPalette creates a 216 color uniform palette a.k.a. the Netscape Palette
function WebPalette: HPalette;
// ReduceColors
// Map colors in a bitmap to their nearest representation in a palette using
// the methods specified by the ColorReduction and DitherMode parameters.
// The ReductionBits parameter specifies the desired number of colors (bits
// per pixel) when the reduction method is rmQuantize. The CustomPalette
// specifies the palette when the rmPalette reduction method is used.
function ReduceColors(Bitmap: TBitmap; ColorReduction: TColorReduction;
DitherMode: TDitherMode; ReductionBits: integer; CustomPalette: hPalette): TBitmap;
// CreateOptimizedPaletteFromManyBitmaps
//: Performs Color Quantization on multiple bitmaps.
// The Bitmaps parameter is a list of bitmaps. Returns an optimized palette.
function CreateOptimizedPaletteFromManyBitmaps(Bitmaps: TList; Colors, ColorBits: integer;
Windows: boolean): hPalette;
{$IFDEF VER9x}
// From Delphi 3 graphics.pas
type
TPixelFormat = (pfDevice, pf1bit, pf4bit, pf8bit, pf15bit, pf16bit, pf24bit, pf32bit, pfCustom);
{$ENDIF}
procedure InternalGetDIBSizes(Bitmap: HBITMAP; var InfoHeaderSize: Integer;
var ImageSize: longInt; PixelFormat: TPixelFormat);
function InternalGetDIB(Bitmap: HBITMAP; Palette: HPALETTE;
var BitmapInfo; var Bits; PixelFormat: TPixelFormat): Boolean;
////////////////////////////////////////////////////////////////////////////////
//
// Global variables
//
////////////////////////////////////////////////////////////////////////////////
// GIF Clipboard format identifier for use by LoadFromClipboardFormat and
// SaveToClipboardFormat.
// Set in Initialization section.
var
CF_GIF: WORD;
////////////////////////////////////////////////////////////////////////////////
//
// Library defaults
//
////////////////////////////////////////////////////////////////////////////////
var
//: Default options for TGIFImage.DrawOptions.
GIFImageDefaultDrawOptions : TGIFDrawOptions =
[goAsync, goLoop, goTransparent, goAnimate, goDither, goAutoDither
{$IFDEF STRICT_MOZILLA}
,goClearOnLoop
{$ENDIF}
];
// WARNING! Do not use goAsync and goDirectDraw unless you have absolute
// control of the destination canvas.
// TGIFPainter will continue to write on the canvas even after the canvas has
// been deleted, unless *you* prevent it.
// The goValidateCanvas option will fix this problem if it is ever implemented.
//: Default color reduction methods for bitmap import.
// These are the fastest settings, but also the ones that gives the
// worst result (in most cases).
GIFImageDefaultColorReduction: TColorReduction = rmNetscape;
GIFImageDefaultColorReductionBits: integer = 8; // Range 3 - 8
GIFImageDefaultDitherMode: TDitherMode = dmNearest;
//: Default encoder compression method.
GIFImageDefaultCompression: TGIFCompression = gcLZW;
//: Default painter thread priority
GIFImageDefaultThreadPriority: TThreadPriority = tpNormal;
//: Default animation speed in % of normal speed (range 0 - 1000)
GIFImageDefaultAnimationSpeed: integer = 100;
// DoAutoDither is set to True in the initializaion section if the desktop DC
// supports 256 colors or less.
// It can be modified in your application to disable/enable Auto Dithering
DoAutoDither: boolean = False;
// Palette is set to True in the initialization section if the desktop DC
// supports 256 colors or less.
// You should NOT modify it.
PaletteDevice: boolean = False;
// Set GIFImageRenderOnLoad to True to render (convert to bitmap) the
// GIF frames as they are loaded instead of rendering them on-demand.
// This might increase resource consumption and will increase load time,
// but will cause animated GIFs to display more smoothly.
GIFImageRenderOnLoad: boolean = False;
// If GIFImageOptimizeOnStream is true, the GIF will be optimized
// before it is streamed to the DFM file.
// This will not affect TGIFImage.SaveToStream or SaveToFile.
GIFImageOptimizeOnStream: boolean = False;
////////////////////////////////////////////////////////////////////////////////
//
// Design Time support
//
////////////////////////////////////////////////////////////////////////////////
// Dummy component registration for design time support of GIFs in TImage
procedure Register;
////////////////////////////////////////////////////////////////////////////////
//
// Error messages
//
////////////////////////////////////////////////////////////////////////////////
{$ifndef VER9x}
resourcestring
{$else}
const
{$endif}
// GIF Error messages
sOutOfData = 'Premature end of data';
sTooManyColors = 'Color table overflow';
sBadColorIndex = 'Invalid color index';
sBadVersion = 'Unsupported GIF version';
sBadSignature = 'Invalid GIF signature';
sScreenBadColorSize = 'Invalid number of colors specified in Screen Descriptor';
sImageBadColorSize = 'Invalid number of colors specified in Image Descriptor';
sUnknownExtension = 'Unknown extension type';
sBadExtensionLabel = 'Invalid extension introducer';
sOutOfMemDIB = 'Failed to allocate memory for GIF DIB';
sDIBCreate = 'Failed to create DIB from Bitmap';
sDecodeTooFewBits = 'Decoder bit buffer under-run';
sDecodeCircular = 'Circular decoder table entry';
sBadTrailer = 'Invalid Image trailer';
sBadExtensionInstance = 'Internal error: Extension Instance does not match Extension Label';
sBadBlockSize = 'Unsupported Application Extension block size';
sBadBlock = 'Unknown GIF block type';
sUnsupportedClass = 'Object type not supported for operation';
sInvalidData = 'Invalid GIF data';
sBadHeight = 'Image height too small for contained frames';
sBadWidth = 'Image width too small for contained frames';
{$IFNDEF REGISTER_TGIFIMAGE}
sGIFToClipboard = 'Clipboard operations not supported for GIF objects';
{$ELSE}
sFailedPaste = 'Failed to store GIF on clipboard';
{$IFDEF VER9x}
sUnknownClipboardFormat= 'Unsupported clipboard format';
{$ENDIF}
{$ENDIF}
sScreenSizeExceeded = 'Image exceeds Logical Screen size';
sNoColorTable = 'No global or local color table defined';
sBadPixelCoordinates = 'Invalid pixel coordinates';
sUnsupportedBitmap = 'Unsupported bitmap format';
sInvalidPixelFormat = 'Unsupported PixelFormat';
sBadDimension = 'Invalid image dimensions';
sNoDIB = 'Image has no DIB';
sInvalidStream = 'Invalid stream operation';
sInvalidColor = 'Color not in color table';
sInvalidBitSize = 'Invalid Bits Per Pixel value';
sEmptyColorMap = 'Color table is empty';
sEmptyImage = 'Image is empty';
sInvalidBitmapList = 'Invalid bitmap list';
sInvalidReduction = 'Invalid reduction method';
{$IFDEF VER9x}
// From Delphi 3 consts.pas
SOutOfResources = 'Out of system resources';
SInvalidBitmap = 'Bitmap image is not valid';
SScanLine = 'Scan line index out of range';
{$ENDIF}
////////////////////////////////////////////////////////////////////////////////
//
// Misc texts
//
////////////////////////////////////////////////////////////////////////////////
// File filter name
sGIFImageFile = 'GIF Image';
// Progress messages
sProgressLoading = 'Loading...';
sProgressSaving = 'Saving...';
sProgressConverting = 'Converting...';
sProgressRendering = 'Rendering...';
sProgressCopying = 'Copying...';
sProgressOptimizing = 'Optimizing...';
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//
// Implementation
//
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
implementation
{ This makes me long for the C preprocessor... }
{$ifdef DEBUG}
{$ifdef DEBUG_COMPRESSPERFORMANCE}
{$define DEBUG_PERFORMANCE}
{$else}
{$ifdef DEBUG_DECOMPRESSPERFORMANCE}
{$define DEBUG_PERFORMANCE}
{$else}
{$ifdef DEBUG_DITHERPERFORMANCE}
{$define DEBUG_PERFORMANCE}
{$else}
{$ifdef DEBUG_DITHERPERFORMANCE}
{$define DEBUG_PERFORMANCE}
{$else}
{$ifdef DEBUG_DRAWPERFORMANCE}
{$define DEBUG_PERFORMANCE}
{$else}
{$ifdef DEBUG_RENDERPERFORMANCE}
{$define DEBUG_PERFORMANCE}
{$endif}
{$endif}
{$endif}
{$endif}
{$endif}
{$endif}
{$endif}
uses
{$ifdef DEBUG}
dialogs,
{$endif}
mmsystem, // timeGetTime()
messages,
Consts;
////////////////////////////////////////////////////////////////////////////////
//
// Misc consts
//
////////////////////////////////////////////////////////////////////////////////
const
{ Extension/block label values }
bsPlainTextExtension = $01;
bsGraphicControlExtension = $F9;
bsCommentExtension = $FE;
bsApplicationExtension = $FF;
bsImageDescriptor = Ord(',');
bsExtensionIntroducer = Ord('!');
bsTrailer = ord(';');
// Thread messages - Used by TThread.Synchronize()
CM_DESTROYWINDOW = $8FFE; // Defined in classes.pas
CM_EXECPROC = $8FFF; // Defined in classes.pas
////////////////////////////////////////////////////////////////////////////////
//
// Design Time support
//
////////////////////////////////////////////////////////////////////////////////
//: Dummy component registration to add design-time support of GIFs to TImage.
// Since TGIFImage isn't a component there's nothing to register here, but
// since Register is only called at design time we can set the design time
// GIF paint options here (modify as you please):
procedure Register;
begin
// Don't loop animations at design-time. Animated GIFs will animate once and
// then stop thus not using CPU resources and distracting the developer.
Exclude(GIFImageDefaultDrawOptions, goLoop);
end;
////////////////////////////////////////////////////////////////////////////////
//
// Utilities
//
////////////////////////////////////////////////////////////////////////////////
//: Creates a 216 color uniform non-dithering Netscape palette.
function WebPalette: HPalette;
type
TLogWebPalette = packed record
palVersion : word;
palNumEntries : word;
PalEntries : array[0..5,0..5,0..5] of TPaletteEntry;
end;
var
r, g, b : byte;
LogWebPalette : TLogWebPalette;
LogPalette : TLogpalette absolute LogWebPalette; // Stupid typecast
begin
with LogWebPalette do
begin
palVersion:= $0300;
palNumEntries:= 216;
for r:=0 to 5 do
for g:=0 to 5 do
for b:=0 to 5 do
begin
with PalEntries[r,g,b] do
begin
peRed := 51 * r;
peGreen := 51 * g;
peBlue := 51 * b;
peFlags := 0;
end;
end;
end;
Result := CreatePalette(Logpalette);
end;
(*
** GDI Error handling
** Adapted from graphics.pas
*)
{$IFOPT R+}
{$DEFINE R_PLUS}
{$RANGECHECKS OFF}
{$ENDIF}
{$ifdef D3_BCB3}
function GDICheck(Value: Integer): Integer;
{$else}
function GDICheck(Value: Cardinal): Cardinal;
{$endif}
var
ErrorCode : integer;
Buf : array [byte] of char;
function ReturnAddr: Pointer;
// From classes.pas
asm
MOV EAX,[EBP+4] // sysutils.pas says [EBP-4], but this works !
end;
begin
if (Value = 0) then
begin
ErrorCode := GetLastError;
if (ErrorCode <> 0) and (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, nil,
ErrorCode, LOCALE_USER_DEFAULT, Buf, sizeof(Buf), nil) <> 0) then
raise EOutOfResources.Create(Buf) at ReturnAddr
else
raise EOutOfResources.Create(SOutOfResources) at ReturnAddr;
end;
Result := Value;
end;
{$IFDEF R_PLUS}
{$RANGECHECKS ON}
{$UNDEF R_PLUS}
{$ENDIF}
(*
** Raise error condition
*)
procedure Error(msg: string);
function ReturnAddr: Pointer;
// From classes.pas
asm
MOV EAX,[EBP+4] // sysutils.pas says [EBP-4] !
end;
begin
raise GIFException.Create(msg) at ReturnAddr;
end;
(*
** Return number bytes required to
** hold a given number of bits.
*)
function ByteAlignBit(Bits: Cardinal): Cardinal;
begin
Result := (Bits+7) SHR 3;
end;
// Rounded up to nearest 2
function WordAlignBit(Bits: Cardinal): Cardinal;
begin
Result := ((Bits+15) SHR 4) SHL 1;
end;
// Rounded up to nearest 4
function DWordAlignBit(Bits: Cardinal): Cardinal;
begin
Result := ((Bits+31) SHR 5) SHL 2;
end;
// Round to arbitrary number of bits
function AlignBit(Bits, BitsPerPixel, Alignment: Cardinal): Cardinal;
begin
Dec(Alignment);
Result := ((Bits * BitsPerPixel) + Alignment) and not Alignment;
Result := Result SHR 3;
end;
(*
** Compute Bits per Pixel from Number of Colors
** (Return the ceiling log of n)
*)
function Colors2bpp(Colors: integer): integer;
var
MaxColor : integer;
begin
(*
** This might be faster computed by multiple if then else statements
*)
if (Colors = 0) then
Result := 0
else
begin
Result := 1;
MaxColor := 2;
while (Colors > MaxColor) do
begin
inc(Result);
MaxColor := MaxColor SHL 1;
end;
end;
end;
(*
** Write an ordinal byte value to a stream
*)
procedure WriteByte(Stream: TStream; b: BYTE);
begin
Stream.Write(b, 1);
end;
(*
** Read an ordinal byte value from a stream
*)
function ReadByte(Stream: TStream): BYTE;
begin
Stream.Read(Result, 1);
end;
(*
** Read data from stream and raise exception of EOF
*)
procedure ReadCheck(Stream: TStream; var Buffer; Size: LongInt);
var
ReadSize : integer;
begin
ReadSize := Stream.Read(Buffer, Size);
if (ReadSize <> Size) then
Error(sOutOfData);
end;
(*
** Write a string list to a stream as multiple blocks
** of max 255 characters in each.
*)
procedure WriteStrings(Stream: TStream; Text: TStrings);
var
i : integer;
b : BYTE;
size : integer;
s : string;
begin
for i := 0 to Text.Count-1 do
begin
s := Text[i];
size := length(s);
if (size > 255) then
b := 255
else
b := size;
while (size > 0) do
begin
dec(size, b);
WriteByte(Stream, b);
Stream.Write(PChar(s)^, b);
delete(s, 1, b);
if (b > size) then
b := size;
end;
end;
// Terminating zero (length = 0)
WriteByte(Stream, 0);
end;
(*
** Read a string list from a stream as multiple blocks
** of max 255 characters in each.
*)
{ TODO -oanme -cImprovement : Replace ReadStrings with TGIFReader. }
procedure ReadStrings(Stream: TStream; Text: TStrings);
var
size : BYTE;
buf : array[0..255] of char;
begin
Text.Clear;
if (Stream.Read(size, 1) <> 1) then
exit;
while (size > 0) do
begin
ReadCheck(Stream, buf, size);
buf[size] := #0;
Text.Add(Buf);
if (Stream.Read(size, 1) <> 1) then
exit;
end;
end;
////////////////////////////////////////////////////////////////////////////////
//
// Delphi 2.x / C++ Builder 1.x support
//
////////////////////////////////////////////////////////////////////////////////
{$IFDEF VER9x}
var
// From Delphi 3 graphics.pas
SystemPalette16: HPalette; // 16 color palette that maps to the system palette
type
TPixelFormats = set of TPixelFormat;
const
// Only pf1bit, pf4bit and pf8bit is supported since they are the only ones
// with palettes
SupportedPixelformats: TPixelFormats = [pf1bit, pf4bit, pf8bit];
{$ENDIF}
// --------------------------
// InitializeBitmapInfoHeader
// --------------------------
// Fills a TBitmapInfoHeader with the values of a bitmap when converted to a
// DIB of a specified PixelFormat.
//
// Parameters:
// Bitmap The handle of the source bitmap.
// Info The TBitmapInfoHeader buffer that will receive the values.
// PixelFormat The pixel format of the destination DIB.
//
{$IFDEF BAD_STACK_ALIGNMENT}
// Disable optimization to circumvent optimizer bug...
{$IFOPT O+}
{$DEFINE O_PLUS}
{$O-}
{$ENDIF}
{$ENDIF}
procedure InitializeBitmapInfoHeader(Bitmap: HBITMAP; var Info: TBitmapInfoHeader;
PixelFormat: TPixelFormat);
// From graphics.pas, "optimized" for our use
var
DIB : TDIBSection;
Bytes : Integer;
begin
DIB.dsbmih.biSize := 0;
Bytes := GetObject(Bitmap, SizeOf(DIB), @DIB);
if (Bytes = 0) then
Error(sInvalidBitmap);
if (Bytes >= (sizeof(DIB.dsbm) + sizeof(DIB.dsbmih))) and
(DIB.dsbmih.biSize >= sizeof(DIB.dsbmih)) then
Info := DIB.dsbmih
else
begin
FillChar(Info, sizeof(Info), 0);
with Info, DIB.dsbm do
begin
biSize := SizeOf(Info);
biWidth := bmWidth;
biHeight := bmHeight;
end;
end;
case PixelFormat of
pf1bit: Info.biBitCount := 1;
pf4bit: Info.biBitCount := 4;
pf8bit: Info.biBitCount := 8;
pf24bit: Info.biBitCount := 24;
else
Error(sInvalidPixelFormat);
// Info.biBitCount := DIB.dsbm.bmBitsPixel * DIB.dsbm.bmPlanes;
end;
Info.biPlanes := 1;
Info.biCompression := BI_RGB; // Always return data in RGB format
Info.biSizeImage := AlignBit(Info.biWidth, Info.biBitCount, 32) * Cardinal(abs(Info.biHeight));
end;
{$IFDEF O_PLUS}
{$O+}
{$UNDEF O_PLUS}
{$ENDIF}
// -------------------
// InternalGetDIBSizes
// -------------------
// Calculates the buffer sizes nescessary for convertion of a bitmap to a DIB
// of a specified PixelFormat.
// See the GetDIBSizes API function for more info.
//
// Parameters:
// Bitmap The handle of the source bitmap.
// InfoHeaderSize
// The returned size of a buffer that will receive the DIB's
// TBitmapInfo structure.
// ImageSize The returned size of a buffer that will receive the DIB's
// pixel data.
// PixelFormat The pixel format of the destination DIB.
//
procedure InternalGetDIBSizes(Bitmap: HBITMAP; var InfoHeaderSize: Integer;
var ImageSize: longInt; PixelFormat: TPixelFormat);
// From graphics.pas, "optimized" for our use
var
Info : TBitmapInfoHeader;
begin
InitializeBitmapInfoHeader(Bitmap, Info, PixelFormat);
// Check for palette device format
if (Info.biBitCount > 8) then
begin
// Header but no palette
InfoHeaderSize := SizeOf(TBitmapInfoHeader);
if ((Info.biCompression and BI_BITFIELDS) <> 0) then
Inc(InfoHeaderSize, 12);
end else
// Header and palette
InfoHeaderSize := SizeOf(TBitmapInfoHeader) + SizeOf(TRGBQuad) * (1 shl Info.biBitCount);
ImageSize := Info.biSizeImage;
end;
// --------------
// InternalGetDIB
// --------------
// Converts a bitmap to a DIB of a specified PixelFormat.
//
// Parameters:
// Bitmap The handle of the source bitmap.
// Pal The handle of the source palette.
// BitmapInfo The buffer that will receive the DIB's TBitmapInfo structure.
// A buffer of sufficient size must have been allocated prior to
// calling this function.
// Bits The buffer that will receive the DIB's pixel data.
// A buffer of sufficient size must have been allocated prior to
// calling this function.
// PixelFormat The pixel format of the destination DIB.
//
// Returns:
// True on success, False on failure.
//
// Note: The InternalGetDIBSizes function can be used to calculate the
// nescessary sizes of the BitmapInfo and Bits buffers.
//
function InternalGetDIB(Bitmap: HBITMAP; Palette: HPALETTE;
var BitmapInfo; var Bits; PixelFormat: TPixelFormat): Boolean;
// From graphics.pas, "optimized" for our use
var
OldPal : HPALETTE;
DC : HDC;
begin
InitializeBitmapInfoHeader(Bitmap, TBitmapInfoHeader(BitmapInfo), PixelFormat);
OldPal := 0;
DC := CreateCompatibleDC(0);
try
if (Palette <> 0) then
begin
OldPal := SelectPalette(DC, Palette, False);
RealizePalette(DC);
end;
Result := (GetDIBits(DC, Bitmap, 0, abs(TBitmapInfoHeader(BitmapInfo).biHeight),
@Bits, TBitmapInfo(BitmapInfo), DIB_RGB_COLORS) <> 0);
finally
if (OldPal <> 0) then
SelectPalette(DC, OldPal, False);
DeleteDC(DC);
end;
end;
// ----------
// DIBFromBit
// ----------
// Converts a bitmap to a DIB of a specified PixelFormat.
// The DIB is returned in a TMemoryStream ready for streaming to a BMP file.
//
// Note: As opposed to D2's DIBFromBit function, the returned stream also
// contains a TBitmapFileHeader at offset 0.
//
// Parameters:
// Stream The TMemoryStream used to store the bitmap data.
// The stream must be allocated and freed by the caller prior to
// calling this function.
// Src The handle of the source bitmap.
// Pal The handle of the source palette.
// PixelFormat The pixel format of the destination DIB.
// DIBHeader A pointer to the DIB's TBitmapInfo (or TBitmapInfoHeader)
// structure in the memory stream.
// The size of the structure can either be deduced from the
// pixel format (i.e. number of colors) or calculated by
// subtracting the DIBHeader pointer from the DIBBits pointer.
// DIBBits A pointer to the DIB's pixel data in the memory stream.
//
procedure DIBFromBit(Stream: TMemoryStream; Src: HBITMAP;
Pal: HPALETTE; PixelFormat: TPixelFormat; var DIBHeader, DIBBits: Pointer);
// (From D2 graphics.pas, "optimized" for our use)
var
HeaderSize : integer;
FileSize : longInt;
ImageSize : longInt;
BitmapFileHeader : PBitmapFileHeader;
begin
if (Src = 0) then
Error(sInvalidBitmap);
// Get header- and pixel data size for new pixel format
InternalGetDIBSizes(Src, HeaderSize, ImageSize, PixelFormat);
// Make room in stream for a TBitmapInfo and pixel data
FileSize := sizeof(TBitmapFileHeader) + HeaderSize + ImageSize;
Stream.SetSize(FileSize);
// Get pointer to TBitmapFileHeader
BitmapFileHeader := Stream.Memory;
// Get pointer to TBitmapInfo
DIBHeader := Pointer(Longint(BitmapFileHeader) + sizeof(TBitmapFileHeader));
// Get pointer to pixel data
DIBBits := Pointer(Longint(DIBHeader) + HeaderSize);
// Initialize file header
FillChar(BitmapFileHeader^, sizeof(TBitmapFileHeader), 0);
with BitmapFileHeader^ do
begin
bfType := $4D42; // 'BM' = Windows BMP signature
bfSize := FileSize; // File size (not needed)
bfOffBits := sizeof(TBitmapFileHeader) + HeaderSize; // Offset of pixel data
end;
// Get pixel data in new pixel format
InternalGetDIB(Src, Pal, DIBHeader^, DIBBits^, PixelFormat);
end;
// --------------
// GetPixelFormat
// --------------
// Returns the current pixel format of a bitmap.
//
// Replacement for delphi 3 TBitmap.PixelFormat getter.
//
// Parameters:
// Bitmap The bitmap which pixel format is returned.
//
// Returns:
// The PixelFormat of the bitmap
//
function GetPixelFormat(Bitmap: TBitmap): TPixelFormat;
{$IFDEF VER9x}
// From graphics.pas, "optimized" for our use
var
DIBSection : TDIBSection;
Bytes : Integer;
Handle : HBitmap;
begin
Result := pfCustom; // This value is never returned
// BAD_STACK_ALIGNMENT
// Note: To work around an optimizer bug, we do not use Bitmap.Handle
// directly. Instead we store the value and use it indirectly. Unless we do
// this, the register containing Bitmap.Handle will be overwritten!
Handle := Bitmap.Handle;
if (Handle <> 0) then
begin
Bytes := GetObject(Handle, SizeOf(DIBSection), @DIBSection);
if (Bytes = 0) then
Error(sInvalidBitmap);
with (DIBSection) do
begin
// Check for NT bitmap
if (Bytes < (SizeOf(dsbm) + SizeOf(dsbmih))) or (dsbmih.biSize < SizeOf(dsbmih)) then
DIBSection.dsBmih.biBitCount := dsbm.bmBitsPixel * dsbm.bmPlanes;
case (dsBmih.biBitCount) of
0: Result := pfDevice;
1: Result := pf1bit;
4: Result := pf4bit;
8: Result := pf8bit;
16: case (dsBmih.biCompression) of
BI_RGB:
Result := pf15Bit;
BI_BITFIELDS:
if (dsBitFields[1] = $07E0) then
Result := pf16Bit;
end;
24: Result := pf24Bit;
32: if (dsBmih.biCompression = BI_RGB) then
Result := pf32Bit;
else
Error(sUnsupportedBitmap);
end;
end;
end else
// Result := pfDevice;
Error(sUnsupportedBitmap);
end;
{$ELSE}
begin
Result := Bitmap.PixelFormat;
end;
{$ENDIF}
// --------------
// SetPixelFormat
// --------------
// Changes the pixel format of a TBitmap.
//
// Replacement for delphi 3 TBitmap.PixelFormat setter.
// The returned TBitmap will always be a DIB.
//
// Note: Under Delphi 3.x this function will leak a palette handle each time it
// converts a TBitmap to pf8bit format!
// If possible, use SafeSetPixelFormat instead to avoid this.
//
// Parameters:
// Bitmap The bitmap to modify.
// PixelFormat The pixel format to convert to.
//
procedure SetPixelFormat(Bitmap: TBitmap; PixelFormat: TPixelFormat);
{$IFDEF VER9x}
var
Stream : TMemoryStream;
Header ,
Bits : Pointer;
begin
// Can't change anything without a handle
if (Bitmap.Handle = 0) then
Error(sInvalidBitmap);
// Only convert to supported formats
if not(PixelFormat in SupportedPixelformats) then
Error(sInvalidPixelFormat);
// No need to convert to same format
if (GetPixelFormat(Bitmap) = PixelFormat) then
exit;
Stream := TMemoryStream.Create;
try
// Convert to DIB file in memory stream
DIBFromBit(Stream, Bitmap.Handle, Bitmap.Palette, PixelFormat, Header, Bits);
// Load DIB from stream
Stream.Position := 0;
Bitmap.LoadFromStream(Stream);
finally
Stream.Free;
end;
end;
{$ELSE}
begin
Bitmap.PixelFormat := PixelFormat;
end;
{$ENDIF}
{$IFDEF VER100}
var
pf8BitBitmap: TBitmap = nil;
{$ENDIF}
// ------------------
// SafeSetPixelFormat
// ------------------
// Changes the pixel format of a TBitmap but doesn't preserve the contents.
//
// Replacement for Delphi 3 TBitmap.PixelFormat setter.
// The returned TBitmap will always be an empty DIB of the same size as the
// original bitmap.
//
// This function is used to avoid the palette handle leak that Delphi 3's
// SetPixelFormat and TBitmap.PixelFormat suffers from.
//
// Parameters:
// Bitmap The bitmap to modify.
// PixelFormat The pixel format to convert to.
//
procedure SafeSetPixelFormat(Bitmap: TBitmap; PixelFormat: TPixelFormat);
{$IFDEF VER9x}
begin
SetPixelFormat(Bitmap, PixelFormat);
end;
{$ELSE}
{$IFNDEF VER100}
var
Palette : hPalette;
begin
Bitmap.PixelFormat := PixelFormat;
// Work around a bug in TBitmap:
// When converting to pf8bit format, the palette assigned to TBitmap.Palette
// will be a half tone palette (which only contains the 20 system colors).
// Unfortunately this is not the palette used to render the bitmap and it
// is also not the palette saved with the bitmap.
if (PixelFormat = pf8bit) then
begin
// Disassociate the wrong palette from the bitmap (without affecting
// the DIB color table)
Palette := Bitmap.ReleasePalette;
if (Palette <> 0) then
DeleteObject(Palette);
// Recreate the palette from the DIB color table
Bitmap.Palette;
end;
end;
{$ELSE}
var
Width ,
Height : integer;
begin
if (PixelFormat = pf8bit) then
begin
// Partial solution to "TBitmap.PixelFormat := pf8bit" leak
// by Greg Chapman <glc@well.com>
if (pf8BitBitmap = nil) then
begin
// Create a "template" bitmap
// The bitmap is deleted in the finalization section of the unit.
pf8BitBitmap:= TBitmap.Create;
// Convert template to pf8bit format
// This will leak 1 palette handle, but only once
pf8BitBitmap.PixelFormat:= pf8Bit;
end;
// Store the size of the original bitmap
Width := Bitmap.Width;
Height := Bitmap.Height;
// Convert to pf8bit format by copying template
Bitmap.Assign(pf8BitBitmap);
// Restore the original size
Bitmap.Width := Width;
Bitmap.Height := Height;
end else
// This is safe since only pf8bit leaks
Bitmap.PixelFormat := PixelFormat;
end;
{$ENDIF}
{$ENDIF}
{$IFDEF VER9x}
// -----------
// CopyPalette
// -----------
// Copies a HPALETTE.
//
// Copied from D3 graphics.pas.
// This is declared private in some old versions of Delphi 2 so we have to
// implement it here to support those old versions.
//
// Parameters:
// Palette The palette to copy.
//
// Returns:
// The handle to a new palette.
//
function CopyPalette(Palette: HPALETTE): HPALETTE;
var
PaletteSize: Integer;
LogPal: TMaxLogPalette;
begin
Result := 0;
if Palette = 0 then Exit;
PaletteSize := 0;
if GetObject(Palette, SizeOf(PaletteSize), @PaletteSize) = 0 then Exit;
if PaletteSize = 0 then Exit;
with LogPal do
begin
palVersion := $0300;
palNumEntries := PaletteSize;
GetPaletteEntries(Palette, 0, PaletteSize, palPalEntry);
end;
Result := CreatePalette(PLogPalette(@LogPal)^);
end;
// TThreadList implementation from Delphi 3 classes.pas
constructor TThreadList.Create;
begin
inherited Create;
InitializeCriticalSection(FLock);
FList := TList.Create;
end;
destructor TThreadList.Destroy;
begin
LockList; // Make sure nobody else is inside the list.
try
FList.Free;
inherited Destroy;
finally
UnlockList;
DeleteCriticalSection(FLock);
end;
end;
procedure TThreadList.Add(Item: Pointer);
begin
LockList;
try
if FList.IndexOf(Item) = -1 then
FList.Add(Item);
finally
UnlockList;
end;
end;
procedure TThreadList.Clear;
begin
LockList;
try
FList.Clear;
finally
UnlockList;
end;
end;
function TThreadList.LockList: TList;
begin
EnterCriticalSection(FLock);
Result := FList;
end;
procedure TThreadList.Remove(Item: Pointer);
begin
LockList;
try
FList.Remove(Item);
finally
UnlockList;
end;
end;
procedure TThreadList.UnlockList;
begin
LeaveCriticalSection(FLock);
end;
// End of TThreadList implementation
// From Delphi 3 sysutils.pas
{ CompareMem performs a binary compare of Length bytes of memory referenced
by P1 to that of P2. CompareMem returns True if the memory referenced by
P1 is identical to that of P2. }
function CompareMem(P1, P2: Pointer; Length: Integer): Boolean; assembler;
asm
PUSH ESI
PUSH EDI
MOV ESI,P1
MOV EDI,P2
MOV EDX,ECX
XOR EAX,EAX
AND EDX,3
SHR ECX,1
SHR ECX,1
REPE CMPSD
JNE @@2
MOV ECX,EDX
REPE CMPSB
JNE @@2
@@1: INC EAX
@@2: POP EDI
POP ESI
end;
// Dummy ASSERT procedure since ASSERT does not exist in Delphi 2.x
procedure ASSERT(Condition: boolean; Message: string);
begin
end;
{$ENDIF} // Delphi 2.x stuff
////////////////////////////////////////////////////////////////////////////////
//
// TDIB Classes
//
// These classes gives read and write access to TBitmap's pixel data
// independently of the Delphi version used.
//
////////////////////////////////////////////////////////////////////////////////
type
TDIB = class(TObject)
private
FBitmap : TBitmap;
FPixelFormat : TPixelFormat;
protected
function GetScanline(Row: integer): pointer; virtual; abstract;
constructor Create(ABitmap: TBitmap; APixelFormat: TPixelFormat);
public
property Scanline[Row: integer]: pointer read GetScanline;
property Bitmap: TBitmap read FBitmap;
property PixelFormat: TPixelFormat read FPixelFormat;
end;
TDIBReader = class(TDIB)
private
{$ifdef VER9x}
FDIB : TDIBSection;
FDC : HDC;
FScanLine : pointer;
FLastRow : integer;
FInfo : PBitmapInfo;
FBytes : integer;
{$endif}
protected
function GetScanline(Row: integer): pointer; override;
public
constructor Create(ABitmap: TBitmap; APixelFormat: TPixelFormat);
destructor Destroy; override;
end;
TDIBWriter = class(TDIB)
private
{$ifdef PIXELFORMAT_TOO_SLOW}
FDIBInfo : PBitmapInfo;
FDIBBits : pointer;
FDIBInfoSize : integer;
FDIBBitsSize : longInt;
{$ifndef CREATEDIBSECTION_SLOW}
FDIB : HBITMAP;
{$endif}
{$endif}
FPalette : HPalette;
FHeight : integer;
FWidth : integer;
protected
procedure CreateDIB;
procedure FreeDIB;
procedure NeedDIB;
function GetScanline(Row: integer): pointer; override;
public
constructor Create(ABitmap: TBitmap; APixelFormat: TPixelFormat;
AWidth, AHeight: integer; APalette: HPalette);
destructor Destroy; override;
procedure UpdateBitmap;
property Width: integer read FWidth;
property Height: integer read FHeight;
property Palette: HPalette read FPalette;
end;
////////////////////////////////////////////////////////////////////////////////
constructor TDIB.Create(ABitmap: TBitmap; APixelFormat: TPixelFormat);
begin
inherited Create;
FBitmap := ABitmap;
FPixelFormat := APixelFormat;
end;
////////////////////////////////////////////////////////////////////////////////
constructor TDIBReader.Create(ABitmap: TBitmap; APixelFormat: TPixelFormat);
{$ifdef VER9x}
var
InfoHeaderSize : integer;
ImageSize : longInt;
{$endif}
begin
inherited Create(ABitmap, APixelFormat);
{$ifndef VER9x}
SetPixelFormat(FBitmap, FPixelFormat);
{$else}
FDC := CreateCompatibleDC(0);
SelectPalette(FDC, FBitmap.Palette, False);
// Allocate DIB info structure
InternalGetDIBSizes(ABitmap.Handle, InfoHeaderSize, ImageSize, APixelFormat);
GetMem(FInfo, InfoHeaderSize);
// Get DIB info
InitializeBitmapInfoHeader(ABitmap.Handle, FInfo^.bmiHeader, APixelFormat);
// Allocate scan line buffer
GetMem(FScanLine, ImageSize DIV abs(FInfo^.bmiHeader.biHeight));
FLastRow := -1;
{$endif}
end;
destructor TDIBReader.Destroy;
begin
{$ifdef VER9x}
DeleteDC(FDC);
FreeMem(FScanLine);
FreeMem(FInfo);
{$endif}
inherited Destroy;
end;
function TDIBReader.GetScanline(Row: integer): pointer;
begin
{$ifdef VER9x}
if (Row < 0) or (Row >= FBitmap.Height) then
raise EInvalidGraphicOperation.Create(SScanLine);
GDIFlush;
Result := FScanLine;
if (Row = FLastRow) then
exit;
FLastRow := Row;
if (FInfo^.bmiHeader.biHeight > 0) then // bottom-up DIB
Row := FInfo^.bmiHeader.biHeight - Row - 1;
GetDIBits(FDC, FBitmap.Handle, Row, 1, FScanLine, FInfo^, DIB_RGB_COLORS);
{$else}
Result := FBitmap.ScanLine[Row];
{$endif}
end;
////////////////////////////////////////////////////////////////////////////////
constructor TDIBWriter.Create(ABitmap: TBitmap; APixelFormat: TPixelFormat;
AWidth, AHeight: integer; APalette: HPalette);
begin
inherited Create(ABitmap, APixelFormat);
// DIB writer only supports 8 or 24 bit bitmaps
if not(APixelFormat in [pf8bit, pf24bit]) then
Error(sInvalidPixelFormat);
if (AWidth = 0) or (AHeight = 0) then
Error(sBadDimension);
FHeight := AHeight;
FWidth := AWidth;
{$ifndef PIXELFORMAT_TOO_SLOW}
FBitmap.Palette := 0;
FBitmap.Height := FHeight;
FBitmap.Width := FWidth;
SafeSetPixelFormat(FBitmap, FPixelFormat);
FPalette := CopyPalette(APalette);
FBitmap.Palette := FPalette;
{$else}
FPalette := APalette;
FDIBInfo := nil;
FDIBBits := nil;
{$ifndef CREATEDIBSECTION_SLOW}
FDIB := 0;
{$endif}
{$endif}
end;
destructor TDIBWriter.Destroy;
begin
UpdateBitmap;
FreeDIB;
inherited Destroy;
end;
function TDIBWriter.GetScanline(Row: integer): pointer;
begin
{$ifdef PIXELFORMAT_TOO_SLOW}
NeedDIB;
if (FDIBBits = nil) then
Error(sNoDIB);
with FDIBInfo^.bmiHeader do
begin
if (Row < 0) or (Row >= Height) then
raise EInvalidGraphicOperation.Create(SScanLine);
GDIFlush;
if biHeight > 0 then // bottom-up DIB
Row := biHeight - Row - 1;
Result := PChar(Cardinal(FDIBBits) + Cardinal(Row) * AlignBit(biWidth, biBitCount, 32));
end;
{$else}
Result := FBitmap.ScanLine[Row];
{$endif}
end;
procedure TDIBWriter.CreateDIB;
{$IFDEF PIXELFORMAT_TOO_SLOW}
var
SrcColors : WORD;
// ScreenDC : HDC;
// From Delphi 3.02 graphics.pas
// There is a bug in the ByteSwapColors from Delphi 3.0!
procedure ByteSwapColors(var Colors; Count: Integer);
var // convert RGB to BGR and vice-versa. TRGBQuad <-> TPaletteEntry
SysInfo: TSystemInfo;
begin
GetSystemInfo(SysInfo);
asm
MOV EDX, Colors
MOV ECX, Count
DEC ECX
JS @@END
LEA EAX, SysInfo
CMP [EAX].TSystemInfo.wProcessorLevel, 3
JE @@386
@@1: MOV EAX, [EDX+ECX*4]
BSWAP EAX
SHR EAX,8
MOV [EDX+ECX*4],EAX
DEC ECX
JNS @@1
JMP @@END
@@386:
PUSH EBX
@@2: XOR EBX,EBX
MOV EAX, [EDX+ECX*4]
MOV BH, AL
MOV BL, AH
SHR EAX,16
SHL EBX,8
MOV BL, AL
MOV [EDX+ECX*4],EBX
DEC ECX
JNS @@2
POP EBX
@@END:
end;
end;
{$ENDIF}
begin
{$ifdef PIXELFORMAT_TOO_SLOW}
FreeDIB;
if (PixelFormat = pf8bit) then
// 8 bit: Header and palette
FDIBInfoSize := SizeOf(TBitmapInfoHeader) + SizeOf(TRGBQuad) * (1 shl 8)
else
// 24 bit: Header but no palette
FDIBInfoSize := SizeOf(TBitmapInfoHeader);
// Allocate TBitmapInfo structure
GetMem(FDIBInfo, FDIBInfoSize);
try
FDIBInfo^.bmiHeader.biSize := SizeOf(FDIBInfo^.bmiHeader);
FDIBInfo^.bmiHeader.biWidth := Width;
FDIBInfo^.bmiHeader.biHeight := Height;
FDIBInfo^.bmiHeader.biPlanes := 1;
FDIBInfo^.bmiHeader.biSizeImage := 0;
FDIBInfo^.bmiHeader.biCompression := BI_RGB;
if (PixelFormat = pf8bit) then
begin
FDIBInfo^.bmiHeader.biBitCount := 8;
// Find number of colors defined by palette
if (Palette <> 0) and
(GetObject(Palette, sizeof(SrcColors), @SrcColors) <> 0) and
(SrcColors <> 0) then
begin
// Copy all colors...
GetPaletteEntries(Palette, 0, SrcColors, FDIBInfo^.bmiColors[0]);
// ...and convert BGR to RGB
ByteSwapColors(FDIBInfo^.bmiColors[0], SrcColors);
end else
SrcColors := 0;
// Finally zero any unused entried
if (SrcColors < 256) then
FillChar(pointer(LongInt(@FDIBInfo^.bmiColors)+SizeOf(TRGBQuad)*SrcColors)^,
256 - SrcColors, 0);
FDIBInfo^.bmiHeader.biClrUsed := 256;
FDIBInfo^.bmiHeader.biClrImportant := SrcColors;
end else
begin
FDIBInfo^.bmiHeader.biBitCount := 24;
FDIBInfo^.bmiHeader.biClrUsed := 0;
FDIBInfo^.bmiHeader.biClrImportant := 0;
end;
FDIBBitsSize := AlignBit(Width, FDIBInfo^.bmiHeader.biBitCount, 32) * Cardinal(abs(Height));
{$ifdef CREATEDIBSECTION_SLOW}
FDIBBits := GlobalAllocPtr(GMEM_MOVEABLE, FDIBBitsSize);
if (FDIBBits = nil) then
raise EOutOfMemory.Create(sOutOfMemDIB);
{$else}
// ScreenDC := GDICheck(GetDC(0));
try
// Allocate DIB section
// Note: You can ignore warnings about the HDC parameter being 0. The
// parameter is not used for 24 bit bitmaps
FDIB := GDICheck(CreateDIBSection(0 {ScreenDC}, FDIBInfo^, DIB_RGB_COLORS,
FDIBBits,
{$IFDEF VER9x} nil, {$ELSE} 0, {$ENDIF}
0));
finally
// ReleaseDC(0, ScreenDC);
end;
{$endif}
except
FreeDIB;
raise;
end;
{$endif}
end;
procedure TDIBWriter.FreeDIB;
begin
{$ifdef PIXELFORMAT_TOO_SLOW}
if (FDIBInfo <> nil) then
FreeMem(FDIBInfo);
{$ifdef CREATEDIBSECTION_SLOW}
if (FDIBBits <> nil) then
GlobalFreePtr(FDIBBits);
{$else}
if (FDIB <> 0) then
DeleteObject(FDIB);
FDIB := 0;
{$endif}
FDIBInfo := nil;
FDIBBits := nil;
{$endif}
end;
procedure TDIBWriter.NeedDIB;
begin
{$ifdef PIXELFORMAT_TOO_SLOW}
{$ifdef CREATEDIBSECTION_SLOW}
if (FDIBBits = nil) then
{$else}
if (FDIB = 0) then
{$endif}
CreateDIB;
{$endif}
end;
// Convert the DIB created by CreateDIB back to a TBitmap
procedure TDIBWriter.UpdateBitmap;
{$ifdef PIXELFORMAT_TOO_SLOW}
var
Stream : TMemoryStream;
FileSize : longInt;
BitmapFileHeader : TBitmapFileHeader;
{$endif}
begin
{$ifdef PIXELFORMAT_TOO_SLOW}
{$ifdef CREATEDIBSECTION_SLOW}
if (FDIBBits = nil) then
{$else}
if (FDIB = 0) then
{$endif}
exit;
// Win95 and NT differs in what solution performs best
{$ifndef CREATEDIBSECTION_SLOW}
{$ifdef VER10_PLUS}
if (Win32Platform = VER_PLATFORM_WIN32_NT) then
begin
// Assign DIB to bitmap
FBitmap.Handle := FDIB;
FDIB := 0;
FBitmap.Palette := CopyPalette(Palette);
end else
{$endif}
{$endif}
begin
// Write DIB to a stream in the BMP file format
Stream := TMemoryStream.Create;
try
// Make room in stream for a TBitmapInfo and pixel data
FileSize := sizeof(TBitmapFileHeader) + FDIBInfoSize + FDIBBitsSize;
Stream.SetSize(FileSize);
// Initialize file header
FillChar(BitmapFileHeader, sizeof(TBitmapFileHeader), 0);
with BitmapFileHeader do
begin
bfType := $4D42; // 'BM' = Windows BMP signature
bfSize := FileSize; // File size (not needed)
bfOffBits := sizeof(TBitmapFileHeader) + FDIBInfoSize; // Offset of pixel data
end;
// Save file header
Stream.Write(BitmapFileHeader, sizeof(TBitmapFileHeader));
// Save TBitmapInfo structure
Stream.Write(FDIBInfo^, FDIBInfoSize);
// Save pixel data
Stream.Write(FDIBBits^, FDIBBitsSize);
// Rewind and load bitmap from stream
Stream.Position := 0;
FBitmap.LoadFromStream(Stream);
finally
Stream.Free;
end;
end;
{$endif}
end;
////////////////////////////////////////////////////////////////////////////////
//
// Color Mapping
//
////////////////////////////////////////////////////////////////////////////////
type
TColorLookup = class(TObject)
private
FColors : integer;
public
constructor Create(Palette: hPalette); virtual;
function Lookup(Red, Green, Blue: BYTE; var R, G, B: BYTE): char; virtual; abstract;
property Colors: integer read FColors;
end;
PRGBQuadArray = ^TRGBQuadArray; // From Delphi 3 graphics.pas
TRGBQuadArray = array[Byte] of TRGBQuad; // From Delphi 3 graphics.pas
BGRArray = array[0..0] of TRGBTriple;
PBGRArray = ^BGRArray;
PalArray = array[byte] of TPaletteEntry;
PPalArray = ^PalArray;
// TFastColorLookup implements a simple but reasonably fast generic color
// mapper. It trades precision for speed by reducing the size of the color
// space.
// Using a class instead of inline code results in a speed penalty of
// approx. 15% but reduces the complexity of the color reduction routines that
// uses it. If bitmap to GIF conversion speed is really important to you, the
// implementation can easily be inlined again.
TInverseLookup = array[0..1 SHL 15-1] of SmallInt;
PInverseLookup = ^TInverseLookup;
TFastColorLookup = class(TColorLookup)
private
FPaletteEntries : PPalArray;
FInverseLookup : PInverseLookup;
public
constructor Create(Palette: hPalette); override;
destructor Destroy; override;
function Lookup(Red, Green, Blue: BYTE; var R, G, B: BYTE): char; override;
end;
// TSlowColorLookup implements a precise but very slow generic color mapper.
// It uses the GetNearestPaletteIndex GDI function.
// Note: Tests has shown TFastColorLookup to be more precise than
// TSlowColorLookup in many cases. I can't explain why...
TSlowColorLookup = class(TColorLookup)
private
FPaletteEntries : PPalArray;
FPalette : hPalette;
public
constructor Create(Palette: hPalette); override;
destructor Destroy; override;
function Lookup(Red, Green, Blue: BYTE; var R, G, B: BYTE): char; override;
end;
// TNetscapeColorLookup maps colors to the netscape 6*6*6 color cube.
TNetscapeColorLookup = class(TColorLookup)
public
constructor Create(Palette: hPalette); override;
function Lookup(Red, Green, Blue: BYTE; var R, G, B: BYTE): char; override;
end;
// TGrayWindowsLookup maps colors to 4 shade palette.
TGrayWindowsLookup = class(TSlowColorLookup)
public
constructor Create(Palette: hPalette); override;
function Lookup(Red, Green, Blue: BYTE; var R, G, B: BYTE): char; override;
end;
// TGrayScaleLookup maps colors to a uniform 256 shade palette.
TGrayScaleLookup = class(TColorLookup)
public
constructor Create(Palette: hPalette); override;
function Lookup(Red, Green, Blue: BYTE; var R, G, B: BYTE): char; override;
end;
// TMonochromeLookup maps colors to a black/white palette.
TMonochromeLookup = class(TColorLookup)
public
constructor Create(Palette: hPalette); override;
function Lookup(Red, Green, Blue: BYTE; var R, G, B: BYTE): char; override;
end;
constructor TColorLookup.Create(Palette: hPalette);
begin
inherited Create;
end;
constructor TFastColorLookup.Create(Palette: hPalette);
var
i : integer;
InverseIndex : integer;
begin
inherited Create(Palette);
GetMem(FPaletteEntries, sizeof(TPaletteEntry) * 256);
FColors := GetPaletteEntries(Palette, 0, 256, FPaletteEntries^);
New(FInverseLookup);
for i := low(TInverseLookup) to high(TInverseLookup) do
FInverseLookup^[i] := -1;
// Premap palette colors
if (FColors > 0) then
for i := 0 to FColors-1 do
with FPaletteEntries^[i] do
begin
InverseIndex := (peRed SHR 3) OR ((peGreen AND $F8) SHL 2) OR ((peBlue AND $F8) SHL 7);
if (FInverseLookup^[InverseIndex] = -1) then
FInverseLookup^[InverseIndex] := i;
end;
end;
destructor TFastColorLookup.Destroy;
begin
if (FPaletteEntries <> nil) then
FreeMem(FPaletteEntries);
if (FInverseLookup <> nil) then
Dispose(FInverseLookup);
inherited Destroy;
end;
// Map color to arbitrary palette
function TFastColorLookup.Lookup(Red, Green, Blue: BYTE; var R, G, B: BYTE): char;
var
i : integer;
InverseIndex : integer;
Delta ,
MinDelta ,
MinColor : integer;
begin
// Reduce color space with 3 bits in each dimension
InverseIndex := (Red SHR 3) OR ((Green AND $F8) SHL 2) OR ((Blue AND $F8) SHL 7);
if (FInverseLookup^[InverseIndex] <> -1) then
Result := char(FInverseLookup^[InverseIndex])
else
begin
// Sequential scan for nearest color to minimize euclidian distance
MinDelta := 3 * (256 * 256);
MinColor := 0;
for i := 0 to FColors-1 do
with FPaletteEntries[i] do
begin
Delta := ABS(peRed - Red) + ABS(peGreen - Green) + ABS(peBlue - Blue);
if (Delta < MinDelta) then
begin
MinDelta := Delta;
MinColor := i;
end;
end;
Result := char(MinColor);
FInverseLookup^[InverseIndex] := MinColor;
end;
with FPaletteEntries^[ord(Result)] do
begin
R := peRed;
G := peGreen;
B := peBlue;
end;
end;
constructor TSlowColorLookup.Create(Palette: hPalette);
begin
inherited Create(Palette);
FPalette := Palette;
FColors := GetPaletteEntries(Palette, 0, 256, nil^);
if (FColors > 0) then
begin
GetMem(FPaletteEntries, sizeof(TPaletteEntry) * FColors);
FColors := GetPaletteEntries(Palette, 0, 256, FPaletteEntries^);
end;
end;
destructor TSlowColorLookup.Destroy;
begin
if (FPaletteEntries <> nil) then
FreeMem(FPaletteEntries);
inherited Destroy;
end;
// Map color to arbitrary palette
function TSlowColorLookup.Lookup(Red, Green, Blue: BYTE; var R, G, B: BYTE): char;
begin
Result := char(GetNearestPaletteIndex(FPalette, Red OR (Green SHL 8) OR (Blue SHL 16)));
if (FPaletteEntries <> nil) then
with FPaletteEntries^[ord(Result)] do
begin
R := peRed;
G := peGreen;
B := peBlue;
end;
end;
constructor TNetscapeColorLookup.Create(Palette: hPalette);
begin
inherited Create(Palette);
FColors := 6*6*6; // This better be true or something is wrong
end;
// Map color to netscape 6*6*6 color cube
function TNetscapeColorLookup.Lookup(Red, Green, Blue: BYTE; var R, G, B: BYTE): char;
begin
R := (Red+3) DIV 51;
G := (Green+3) DIV 51;
B := (Blue+3) DIV 51;
Result := char(B + 6*G + 36*R);
R := R * 51;
G := G * 51;
B := B * 51;
end;
constructor TGrayWindowsLookup.Create(Palette: hPalette);
begin
inherited Create(Palette);
FColors := 4;
end;
// Convert color to windows grays
function TGrayWindowsLookup.Lookup(Red, Green, Blue: BYTE; var R, G, B: BYTE): char;
begin
Result := inherited Lookup(MulDiv(Red, 77, 256),
MulDiv(Green, 150, 256), MulDiv(Blue, 29, 256), R, G, B);
end;
constructor TGrayScaleLookup.Create(Palette: hPalette);
begin
inherited Create(Palette);
FColors := 256;
end;
// Convert color to grayscale
function TGrayScaleLookup.Lookup(Red, Green, Blue: BYTE; var R, G, B: BYTE): char;
begin
Result := char((Blue*29 + Green*150 + Red*77) DIV 256);
R := ord(Result);
G := ord(Result);
B := ord(Result);
end;
constructor TMonochromeLookup.Create(Palette: hPalette);
begin
inherited Create(Palette);
FColors := 2;
end;
// Convert color to black/white
function TMonochromeLookup.Lookup(Red, Green, Blue: BYTE; var R, G, B: BYTE): char;
begin
if ((Blue*29 + Green*150 + Red*77) > 32512) then
begin
Result := #1;
R := 255;
G := 255;
B := 255;
end else
begin
Result := #0;
R := 0;
G := 0;
B := 0;
end;
end;
////////////////////////////////////////////////////////////////////////////////
//
// Dithering engine
//
////////////////////////////////////////////////////////////////////////////////
type
TDitherEngine = class
private
protected
FDirection : integer;
FColumn : integer;
FLookup : TColorLookup;
Width : integer;
public
constructor Create(AWidth: integer; Lookup: TColorLookup); virtual;
function Dither(Red, Green, Blue: BYTE; var R, G, B: BYTE): char; virtual;
procedure NextLine; virtual;
procedure NextColumn;
property Direction: integer read FDirection;
property Column: integer read FColumn;
end;
// Note: TErrorTerm does only *need* to be 16 bits wide, but since
// it is *much* faster to use native machine words (32 bit), we sacrifice
// some bytes (a lot actually) to improve performance.
TErrorTerm = Integer;
TErrors = array[0..0] of TErrorTerm;
PErrors = ^TErrors;
TFloydSteinbergDitherer = class(TDitherEngine)
private
ErrorsR ,
ErrorsG ,
ErrorsB : PErrors;
ErrorR ,
ErrorG ,
ErrorB : PErrors;
CurrentErrorR , // Current error or pixel value
CurrentErrorG ,
CurrentErrorB ,
BelowErrorR , // Error for pixel below current
BelowErrorG ,
BelowErrorB ,
BelowPrevErrorR , // Error for pixel below previous pixel
BelowPrevErrorG ,
BelowPrevErrorB : TErrorTerm;
public
constructor Create(AWidth: integer; Lookup: TColorLookup); override;
destructor Destroy; override;
function Dither(Red, Green, Blue: BYTE; var R, G, B: BYTE): char; override;
procedure NextLine; override;
end;
T5by3Ditherer = class(TDitherEngine)
private
ErrorsR0 ,
ErrorsG0 ,
ErrorsB0 ,
ErrorsR1 ,
ErrorsG1 ,
ErrorsB1 ,
ErrorsR2 ,
ErrorsG2 ,
ErrorsB2 : PErrors;
ErrorR0 ,
ErrorG0 ,
ErrorB0 ,
ErrorR1 ,
ErrorG1 ,
ErrorB1 ,
ErrorR2 ,
ErrorG2 ,
ErrorB2 : PErrors;
FDirection2 : integer;
protected
FDivisor : integer;
procedure Propagate(Errors0, Errors1, Errors2: PErrors; Error: integer); virtual; abstract;
public
constructor Create(AWidth: integer; Lookup: TColorLookup); override;
destructor Destroy; override;
function Dither(Red, Green, Blue: BYTE; var R, G, B: BYTE): char; override;
procedure NextLine; override;
end;
TStuckiDitherer = class(T5by3Ditherer)
protected
procedure Propagate(Errors0, Errors1, Errors2: PErrors; Error: integer); override;
public
constructor Create(AWidth: integer; Lookup: TColorLookup); override;
end;
TSierraDitherer = class(T5by3Ditherer)
protected
procedure Propagate(Errors0, Errors1, Errors2: PErrors; Error: integer); override;
public
constructor Create(AWidth: integer; Lookup: TColorLookup); override;
end;
TJaJuNiDitherer = class(T5by3Ditherer)
protected
procedure Propagate(Errors0, Errors1, Errors2: PErrors; Error: integer); override;
public
constructor Create(AWidth: integer; Lookup: TColorLookup); override;
end;
TSteveArcheDitherer = class(TDitherEngine)
private
ErrorsR0 ,
ErrorsG0 ,
ErrorsB0 ,
ErrorsR1 ,
ErrorsG1 ,
ErrorsB1 ,
ErrorsR2 ,
ErrorsG2 ,
ErrorsB2 ,
ErrorsR3 ,
ErrorsG3 ,
ErrorsB3 : PErrors;
ErrorR0 ,
ErrorG0 ,
ErrorB0 ,
ErrorR1 ,
ErrorG1 ,
ErrorB1 ,
ErrorR2 ,
ErrorG2 ,
ErrorB2 ,
ErrorR3 ,
ErrorG3 ,
ErrorB3 : PErrors;
FDirection2 ,
FDirection3 : integer;
public
constructor Create(AWidth: integer; Lookup: TColorLookup); override;
destructor Destroy; override;
function Dither(Red, Green, Blue: BYTE; var R, G, B: BYTE): char; override;
procedure NextLine; override;
end;
TBurkesDitherer = class(TDitherEngine)
private
ErrorsR0 ,
ErrorsG0 ,
ErrorsB0 ,
ErrorsR1 ,
ErrorsG1 ,
ErrorsB1 : PErrors;
ErrorR0 ,
ErrorG0 ,
ErrorB0 ,
ErrorR1 ,
ErrorG1 ,
ErrorB1 : PErrors;
FDirection2 : integer;
public
constructor Create(AWidth: integer; Lookup: TColorLookup); override;
destructor Destroy; override;
function Dither(Red, Green, Blue: BYTE; var R, G, B: BYTE): char; override;
procedure NextLine; override;
end;
////////////////////////////////////////////////////////////////////////////////
// TDitherEngine
constructor TDitherEngine.Create(AWidth: integer; Lookup: TColorLookup);
begin
inherited Create;
FLookup := Lookup;
Width := AWidth;
FDirection := 1;
FColumn := 0;
end;
function TDitherEngine.Dither(Red, Green, Blue: BYTE; var R, G, B: BYTE): char;
begin
// Map color to palette
Result := FLookup.Lookup(Red, Green, Blue, R, G, B);
NextColumn;
end;
procedure TDitherEngine.NextLine;
begin
FDirection := -FDirection;
if (FDirection = 1) then
FColumn := 0
else
FColumn := Width-1;
end;
procedure TDitherEngine.NextColumn;
begin
inc(FColumn, FDirection);
end;
////////////////////////////////////////////////////////////////////////////////
// TFloydSteinbergDitherer
constructor TFloydSteinbergDitherer.Create(AWidth: integer; Lookup: TColorLookup);
begin
inherited Create(AWidth, Lookup);
// The Error arrays has (columns + 2) entries; the extra entry at
// each end saves us from special-casing the first and last pixels.
// We can get away with a single array (holding one row's worth of errors)
// by using it to store the current row's errors at pixel columns not yet
// processed, but the next row's errors at columns already processed. We
// need only a few extra variables to hold the errors immediately around the
// current column. (If we are lucky, those variables are in registers, but
// even if not, they're probably cheaper to access than array elements are.)
GetMem(ErrorsR, sizeof(TErrorTerm)*(Width+2));
GetMem(ErrorsG, sizeof(TErrorTerm)*(Width+2));
GetMem(ErrorsB, sizeof(TErrorTerm)*(Width+2));
FillChar(ErrorsR^, sizeof(TErrorTerm)*(Width+2), 0);
FillChar(ErrorsG^, sizeof(TErrorTerm)*(Width+2), 0);
FillChar(ErrorsB^, sizeof(TErrorTerm)*(Width+2), 0);
ErrorR := ErrorsR;
ErrorG := ErrorsG;
ErrorB := ErrorsB;
CurrentErrorR := 0;
CurrentErrorG := CurrentErrorR;
CurrentErrorB := CurrentErrorR;
BelowErrorR := CurrentErrorR;
BelowErrorG := CurrentErrorR;
BelowErrorB := CurrentErrorR;
BelowPrevErrorR := CurrentErrorR;
BelowPrevErrorG := CurrentErrorR;
BelowPrevErrorB := CurrentErrorR;
end;
destructor TFloydSteinbergDitherer.Destroy;
begin
FreeMem(ErrorsR);
FreeMem(ErrorsG);
FreeMem(ErrorsB);
inherited Destroy;
end;
{$IFOPT R+}
{$DEFINE R_PLUS}
{$RANGECHECKS OFF}
{$ENDIF}
function TFloydSteinbergDitherer.Dither(Red, Green, Blue: BYTE; var R, G, B: BYTE): char;
var
BelowNextError : TErrorTerm;
Delta : TErrorTerm;
begin
CurrentErrorR := Red + (CurrentErrorR + ErrorR[0] + 8) DIV 16;
// CurrentErrorR := Red + (CurrentErrorR + ErrorR[Direction] + 8) DIV 16;
if (CurrentErrorR < 0) then
CurrentErrorR := 0
else if (CurrentErrorR > 255) then
CurrentErrorR := 255;
CurrentErrorG := Green + (CurrentErrorG + ErrorG[0] + 8) DIV 16;
// CurrentErrorG := Green + (CurrentErrorG + ErrorG[Direction] + 8) DIV 16;
if (CurrentErrorG < 0) then
CurrentErrorG := 0
else if (CurrentErrorG > 255) then
CurrentErrorG := 255;
CurrentErrorB := Blue + (CurrentErrorB + ErrorB[0] + 8) DIV 16;
// CurrentErrorB := Blue + (CurrentErrorB + ErrorB[Direction] + 8) DIV 16;
if (CurrentErrorB < 0) then
CurrentErrorB := 0
else if (CurrentErrorB > 255) then
CurrentErrorB := 255;
// Map color to palette
Result := inherited Dither(CurrentErrorR, CurrentErrorG, CurrentErrorB, R, G, B);
// Propagate Floyd-Steinberg error terms.
// Errors are accumulated into the error arrays, at a resolution of
// 1/16th of a pixel count. The error at a given pixel is propagated
// to its not-yet-processed neighbors using the standard F-S fractions,
// ... (here) 7/16
// 3/16 5/16 1/16
// We work left-to-right on even rows, right-to-left on odd rows.
// Red component
CurrentErrorR := CurrentErrorR - R;
if (CurrentErrorR <> 0) then
begin
BelowNextError := CurrentErrorR; // Error * 1
Delta := CurrentErrorR * 2;
inc(CurrentErrorR, Delta);
ErrorR[0] := BelowPrevErrorR + CurrentErrorR; // Error * 3
inc(CurrentErrorR, Delta);
BelowPrevErrorR := BelowErrorR + CurrentErrorR; // Error * 5
BelowErrorR := BelowNextError; // Error * 1
inc(CurrentErrorR, Delta); // Error * 7
end;
// Green component
CurrentErrorG := CurrentErrorG - G;
if (CurrentErrorG <> 0) then
begin
BelowNextError := CurrentErrorG; // Error * 1
Delta := CurrentErrorG * 2;
inc(CurrentErrorG, Delta);
ErrorG[0] := BelowPrevErrorG + CurrentErrorG; // Error * 3
inc(CurrentErrorG, Delta);
BelowPrevErrorG := BelowErrorG + CurrentErrorG; // Error * 5
BelowErrorG := BelowNextError; // Error * 1
inc(CurrentErrorG, Delta); // Error * 7
end;
// Blue component
CurrentErrorB := CurrentErrorB - B;
if (CurrentErrorB <> 0) then
begin
BelowNextError := CurrentErrorB; // Error * 1
Delta := CurrentErrorB * 2;
inc(CurrentErrorB, Delta);
ErrorB[0] := BelowPrevErrorB + CurrentErrorB; // Error * 3
inc(CurrentErrorB, Delta);
BelowPrevErrorB := BelowErrorB + CurrentErrorB; // Error * 5
BelowErrorB := BelowNextError; // Error * 1
inc(CurrentErrorB, Delta); // Error * 7
end;
// Move on to next column
if (Direction = 1) then
begin
inc(longInt(ErrorR), sizeof(TErrorTerm));
inc(longInt(ErrorG), sizeof(TErrorTerm));
inc(longInt(ErrorB), sizeof(TErrorTerm));
end else
begin
dec(longInt(ErrorR), sizeof(TErrorTerm));
dec(longInt(ErrorG), sizeof(TErrorTerm));
dec(longInt(ErrorB), sizeof(TErrorTerm));
end;
end;
{$IFDEF R_PLUS}
{$RANGECHECKS ON}
{$UNDEF R_PLUS}
{$ENDIF}
{$IFOPT R+}
{$DEFINE R_PLUS}
{$RANGECHECKS OFF}
{$ENDIF}
procedure TFloydSteinbergDitherer.NextLine;
begin
ErrorR[0] := BelowPrevErrorR;
ErrorG[0] := BelowPrevErrorG;
ErrorB[0] := BelowPrevErrorB;
// Note: The optimizer produces better code for this construct:
// a := 0; b := a; c := a;
// compared to this construct:
// a := 0; b := 0; c := 0;
CurrentErrorR := 0;
CurrentErrorG := CurrentErrorR;
CurrentErrorB := CurrentErrorG;
BelowErrorR := CurrentErrorG;
BelowErrorG := CurrentErrorG;
BelowErrorB := CurrentErrorG;
BelowPrevErrorR := CurrentErrorG;
BelowPrevErrorG := CurrentErrorG;
BelowPrevErrorB := CurrentErrorG;
inherited NextLine;
if (Direction = 1) then
begin
ErrorR := ErrorsR;
ErrorG := ErrorsG;
ErrorB := ErrorsB;
end else
begin
ErrorR := @ErrorsR[Width+1];
ErrorG := @ErrorsG[Width+1];
ErrorB := @ErrorsB[Width+1];
end;
end;
{$IFDEF R_PLUS}
{$RANGECHECKS ON}
{$UNDEF R_PLUS}
{$ENDIF}
////////////////////////////////////////////////////////////////////////////////
// T5by3Ditherer
constructor T5by3Ditherer.Create(AWidth: integer; Lookup: TColorLookup);
begin
inherited Create(AWidth, Lookup);
GetMem(ErrorsR0, sizeof(TErrorTerm)*(Width+4));
GetMem(ErrorsG0, sizeof(TErrorTerm)*(Width+4));
GetMem(ErrorsB0, sizeof(TErrorTerm)*(Width+4));
GetMem(ErrorsR1, sizeof(TErrorTerm)*(Width+4));
GetMem(ErrorsG1, sizeof(TErrorTerm)*(Width+4));
GetMem(ErrorsB1, sizeof(TErrorTerm)*(Width+4));
GetMem(ErrorsR2, sizeof(TErrorTerm)*(Width+4));
GetMem(ErrorsG2, sizeof(TErrorTerm)*(Width+4));
GetMem(ErrorsB2, sizeof(TErrorTerm)*(Width+4));
FillChar(ErrorsR0^, sizeof(TErrorTerm)*(Width+4), 0);
FillChar(ErrorsG0^, sizeof(TErrorTerm)*(Width+4), 0);
FillChar(ErrorsB0^, sizeof(TErrorTerm)*(Width+4), 0);
FillChar(ErrorsR1^, sizeof(TErrorTerm)*(Width+4), 0);
FillChar(ErrorsG1^, sizeof(TErrorTerm)*(Width+4), 0);
FillChar(ErrorsB1^, sizeof(TErrorTerm)*(Width+4), 0);
FillChar(ErrorsR2^, sizeof(TErrorTerm)*(Width+4), 0);
FillChar(ErrorsG2^, sizeof(TErrorTerm)*(Width+4), 0);
FillChar(ErrorsB2^, sizeof(TErrorTerm)*(Width+4), 0);
FDivisor := 1;
FDirection2 := 2 * Direction;
ErrorR0 := PErrors(longInt(ErrorsR0)+2*sizeof(TErrorTerm));
ErrorG0 := PErrors(longInt(ErrorsG0)+2*sizeof(TErrorTerm));
ErrorB0 := PErrors(longInt(ErrorsB0)+2*sizeof(TErrorTerm));
ErrorR1 := PErrors(longInt(ErrorsR1)+2*sizeof(TErrorTerm));
ErrorG1 := PErrors(longInt(ErrorsG1)+2*sizeof(TErrorTerm));
ErrorB1 := PErrors(longInt(ErrorsB1)+2*sizeof(TErrorTerm));
ErrorR2 := PErrors(longInt(ErrorsR2)+2*sizeof(TErrorTerm));
ErrorG2 := PErrors(longInt(ErrorsG2)+2*sizeof(TErrorTerm));
ErrorB2 := PErrors(longInt(ErrorsB2)+2*sizeof(TErrorTerm));
end;
destructor T5by3Ditherer.Destroy;
begin
FreeMem(ErrorsR0);
FreeMem(ErrorsG0);
FreeMem(ErrorsB0);
FreeMem(ErrorsR1);
FreeMem(ErrorsG1);
FreeMem(ErrorsB1);
FreeMem(ErrorsR2);
FreeMem(ErrorsG2);
FreeMem(ErrorsB2);
inherited Destroy;
end;
{$IFOPT R+}
{$DEFINE R_PLUS}
{$RANGECHECKS OFF}
{$ENDIF}
function T5by3Ditherer.Dither(Red, Green, Blue: BYTE; var R, G, B: BYTE): char;
var
ColorR ,
ColorG ,
ColorB : integer; // Error for current pixel
begin
// Apply red component error correction
ColorR := Red + (ErrorR0[0] + FDivisor DIV 2) DIV FDivisor;
if (ColorR < 0) then
ColorR := 0
else if (ColorR > 255) then
ColorR := 255;
// Apply green component error correction
ColorG := Green + (ErrorG0[0] + FDivisor DIV 2) DIV FDivisor;
if (ColorG < 0) then
ColorG := 0
else if (ColorG > 255) then
ColorG := 255;
// Apply blue component error correction
ColorB := Blue + (ErrorB0[0] + FDivisor DIV 2) DIV FDivisor;
if (ColorB < 0) then
ColorB := 0
else if (ColorB > 255) then
ColorB := 255;
// Map color to palette
Result := inherited Dither(ColorR, ColorG, ColorB, R, G, B);
// Propagate red component error
Propagate(ErrorR0, ErrorR1, ErrorR2, ColorR - R);
// Propagate green component error
Propagate(ErrorG0, ErrorG1, ErrorG2, ColorG - G);
// Propagate blue component error
Propagate(ErrorB0, ErrorB1, ErrorB2, ColorB - B);
// Move on to next column
if (Direction = 1) then
begin
inc(longInt(ErrorR0), sizeof(TErrorTerm));
inc(longInt(ErrorG0), sizeof(TErrorTerm));
inc(longInt(ErrorB0), sizeof(TErrorTerm));
inc(longInt(ErrorR1), sizeof(TErrorTerm));
inc(longInt(ErrorG1), sizeof(TErrorTerm));
inc(longInt(ErrorB1), sizeof(TErrorTerm));
inc(longInt(ErrorR2), sizeof(TErrorTerm));
inc(longInt(ErrorG2), sizeof(TErrorTerm));
inc(longInt(ErrorB2), sizeof(TErrorTerm));
end else
begin
dec(longInt(ErrorR0), sizeof(TErrorTerm));
dec(longInt(ErrorG0), sizeof(TErrorTerm));
dec(longInt(ErrorB0), sizeof(TErrorTerm));
dec(longInt(ErrorR1), sizeof(TErrorTerm));
dec(longInt(ErrorG1), sizeof(TErrorTerm));
dec(longInt(ErrorB1), sizeof(TErrorTerm));
dec(longInt(ErrorR2), sizeof(TErrorTerm));
dec(longInt(ErrorG2), sizeof(TErrorTerm));
dec(longInt(ErrorB2), sizeof(TErrorTerm));
end;
end;
{$IFDEF R_PLUS}
{$RANGECHECKS ON}
{$UNDEF R_PLUS}
{$ENDIF}
{$IFOPT R+}
{$DEFINE R_PLUS}
{$RANGECHECKS OFF}
{$ENDIF}
procedure T5by3Ditherer.NextLine;
var
TempErrors : PErrors;
begin
FillChar(ErrorsR0^, sizeof(TErrorTerm)*(Width+4), 0);
FillChar(ErrorsG0^, sizeof(TErrorTerm)*(Width+4), 0);
FillChar(ErrorsB0^, sizeof(TErrorTerm)*(Width+4), 0);
// Swap lines
TempErrors := ErrorsR0;
ErrorsR0 := ErrorsR1;
ErrorsR1 := ErrorsR2;
ErrorsR2 := TempErrors;
TempErrors := ErrorsG0;
ErrorsG0 := ErrorsG1;
ErrorsG1 := ErrorsG2;
ErrorsG2 := TempErrors;
TempErrors := ErrorsB0;
ErrorsB0 := ErrorsB1;
ErrorsB1 := ErrorsB2;
ErrorsB2 := TempErrors;
inherited NextLine;
FDirection2 := 2 * Direction;
if (Direction = 1) then
begin
// ErrorsR0[1] gives compiler error, so we
// use PErrors(longInt(ErrorsR0)+sizeof(TErrorTerm)) instead...
ErrorR0 := PErrors(longInt(ErrorsR0)+2*sizeof(TErrorTerm));
ErrorG0 := PErrors(longInt(ErrorsG0)+2*sizeof(TErrorTerm));
ErrorB0 := PErrors(longInt(ErrorsB0)+2*sizeof(TErrorTerm));
ErrorR1 := PErrors(longInt(ErrorsR1)+2*sizeof(TErrorTerm));
ErrorG1 := PErrors(longInt(ErrorsG1)+2*sizeof(TErrorTerm));
ErrorB1 := PErrors(longInt(ErrorsB1)+2*sizeof(TErrorTerm));
ErrorR2 := PErrors(longInt(ErrorsR2)+2*sizeof(TErrorTerm));
ErrorG2 := PErrors(longInt(ErrorsG2)+2*sizeof(TErrorTerm));
ErrorB2 := PErrors(longInt(ErrorsB2)+2*sizeof(TErrorTerm));
end else
begin
ErrorR0 := @ErrorsR0[Width+1];
ErrorG0 := @ErrorsG0[Width+1];
ErrorB0 := @ErrorsB0[Width+1];
ErrorR1 := @ErrorsR1[Width+1];
ErrorG1 := @ErrorsG1[Width+1];
ErrorB1 := @ErrorsB1[Width+1];
ErrorR2 := @ErrorsR2[Width+1];
ErrorG2 := @ErrorsG2[Width+1];
ErrorB2 := @ErrorsB2[Width+1];
end;
end;
{$IFDEF R_PLUS}
{$RANGECHECKS ON}
{$UNDEF R_PLUS}
{$ENDIF}
////////////////////////////////////////////////////////////////////////////////
// TStuckiDitherer
constructor TStuckiDitherer.Create(AWidth: integer; Lookup: TColorLookup);
begin
inherited Create(AWidth, Lookup);
FDivisor := 42;
end;
{$IFOPT R+}
{$DEFINE R_PLUS}
{$RANGECHECKS OFF}
{$ENDIF}
procedure TStuckiDitherer.Propagate(Errors0, Errors1, Errors2: PErrors; Error: integer);
begin
if (Error = 0) then
exit;
// Propagate Stucki error terms:
// ... ... (here) 8/42 4/42
// 2/42 4/42 8/42 4/42 2/42
// 1/42 2/42 4/42 2/42 1/42
inc(Errors2[FDirection2], Error); // Error * 1
inc(Errors2[-FDirection2], Error); // Error * 1
Error := Error + Error;
inc(Errors1[FDirection2], Error); // Error * 2
inc(Errors1[-FDirection2], Error); // Error * 2
inc(Errors2[Direction], Error); // Error * 2
inc(Errors2[-Direction], Error); // Error * 2
Error := Error + Error;
inc(Errors0[FDirection2], Error); // Error * 4
inc(Errors1[-Direction], Error); // Error * 4
inc(Errors1[Direction], Error); // Error * 4
inc(Errors2[0], Error); // Error * 4
Error := Error + Error;
inc(Errors0[Direction], Error); // Error * 8
inc(Errors1[0], Error); // Error * 8
end;
{$IFDEF R_PLUS}
{$RANGECHECKS ON}
{$UNDEF R_PLUS}
{$ENDIF}
////////////////////////////////////////////////////////////////////////////////
// TSierraDitherer
constructor TSierraDitherer.Create(AWidth: integer; Lookup: TColorLookup);
begin
inherited Create(AWidth, Lookup);
FDivisor := 32;
end;
{$IFOPT R+}
{$DEFINE R_PLUS}
{$RANGECHECKS OFF}
{$ENDIF}
procedure TSierraDitherer.Propagate(Errors0, Errors1, Errors2: PErrors; Error: integer);
var
TempError : integer;
begin
if (Error = 0) then
exit;
// Propagate Sierra error terms:
// ... ... (here) 5/32 3/32
// 2/32 4/32 5/32 4/32 2/32
// ... 2/32 3/32 2/32 ...
TempError := Error + Error;
inc(Errors1[FDirection2], TempError); // Error * 2
inc(Errors1[-FDirection2], TempError);// Error * 2
inc(Errors2[Direction], TempError); // Error * 2
inc(Errors2[-Direction], TempError); // Error * 2
inc(TempError, Error);
inc(Errors0[FDirection2], TempError); // Error * 3
inc(Errors2[0], TempError); // Error * 3
inc(TempError, Error);
inc(Errors1[-Direction], TempError); // Error * 4
inc(Errors1[Direction], TempError); // Error * 4
inc(TempError, Error);
inc(Errors0[Direction], TempError); // Error * 5
inc(Errors1[0], TempError); // Error * 5
end;
{$IFDEF R_PLUS}
{$RANGECHECKS ON}
{$UNDEF R_PLUS}
{$ENDIF}
////////////////////////////////////////////////////////////////////////////////
// TJaJuNiDitherer
constructor TJaJuNiDitherer.Create(AWidth: integer; Lookup: TColorLookup);
begin
inherited Create(AWidth, Lookup);
FDivisor := 38;
end;
{$IFOPT R+}
{$DEFINE R_PLUS}
{$RANGECHECKS OFF}
{$ENDIF}
procedure TJaJuNiDitherer.Propagate(Errors0, Errors1, Errors2: PErrors; Error: integer);
var
TempError : integer;
begin
if (Error = 0) then
exit;
// Propagate Jarvis, Judice and Ninke error terms:
// ... ... (here) 8/38 4/38
// 2/38 4/38 8/38 4/38 2/38
// 1/38 2/38 4/38 2/38 1/38
inc(Errors2[FDirection2], Error); // Error * 1
inc(Errors2[-FDirection2], Error); // Error * 1
TempError := Error + Error;
inc(Error, TempError);
inc(Errors1[FDirection2], Error); // Error * 3
inc(Errors1[-FDirection2], Error); // Error * 3
inc(Errors2[Direction], Error); // Error * 3
inc(Errors2[-Direction], Error); // Error * 3
inc(Error, TempError);
inc(Errors0[FDirection2], Error); // Error * 5
inc(Errors1[-Direction], Error); // Error * 5
inc(Errors1[Direction], Error); // Error * 5
inc(Errors2[0], Error); // Error * 5
inc(Error, TempError);
inc(Errors0[Direction], Error); // Error * 7
inc(Errors1[0], Error); // Error * 7
end;
{$IFDEF R_PLUS}
{$RANGECHECKS ON}
{$UNDEF R_PLUS}
{$ENDIF}
////////////////////////////////////////////////////////////////////////////////
// TSteveArcheDitherer
constructor TSteveArcheDitherer.Create(AWidth: integer; Lookup: TColorLookup);
begin
inherited Create(AWidth, Lookup);
GetMem(ErrorsR0, sizeof(TErrorTerm)*(Width+6));
GetMem(ErrorsG0, sizeof(TErrorTerm)*(Width+6));
GetMem(ErrorsB0, sizeof(TErrorTerm)*(Width+6));
GetMem(ErrorsR1, sizeof(TErrorTerm)*(Width+6));
GetMem(ErrorsG1, sizeof(TErrorTerm)*(Width+6));
GetMem(ErrorsB1, sizeof(TErrorTerm)*(Width+6));
GetMem(ErrorsR2, sizeof(TErrorTerm)*(Width+6));
GetMem(ErrorsG2, sizeof(TErrorTerm)*(Width+6));
GetMem(ErrorsB2, sizeof(TErrorTerm)*(Width+6));
GetMem(ErrorsR3, sizeof(TErrorTerm)*(Width+6));
GetMem(ErrorsG3, sizeof(TErrorTerm)*(Width+6));
GetMem(ErrorsB3, sizeof(TErrorTerm)*(Width+6));
FillChar(ErrorsR0^, sizeof(TErrorTerm)*(Width+6), 0);
FillChar(ErrorsG0^, sizeof(TErrorTerm)*(Width+6), 0);
FillChar(ErrorsB0^, sizeof(TErrorTerm)*(Width+6), 0);
FillChar(ErrorsR1^, sizeof(TErrorTerm)*(Width+6), 0);
FillChar(ErrorsG1^, sizeof(TErrorTerm)*(Width+6), 0);
FillChar(ErrorsB1^, sizeof(TErrorTerm)*(Width+6), 0);
FillChar(ErrorsR2^, sizeof(TErrorTerm)*(Width+6), 0);
FillChar(ErrorsG2^, sizeof(TErrorTerm)*(Width+6), 0);
FillChar(ErrorsB2^, sizeof(TErrorTerm)*(Width+6), 0);
FillChar(ErrorsR3^, sizeof(TErrorTerm)*(Width+6), 0);
FillChar(ErrorsG3^, sizeof(TErrorTerm)*(Width+6), 0);
FillChar(ErrorsB3^, sizeof(TErrorTerm)*(Width+6), 0);
FDirection2 := 2 * Direction;
FDirection3 := 3 * Direction;
ErrorR0 := PErrors(longInt(ErrorsR0)+3*sizeof(TErrorTerm));
ErrorG0 := PErrors(longInt(ErrorsG0)+3*sizeof(TErrorTerm));
ErrorB0 := PErrors(longInt(ErrorsB0)+3*sizeof(TErrorTerm));
ErrorR1 := PErrors(longInt(ErrorsR1)+3*sizeof(TErrorTerm));
ErrorG1 := PErrors(longInt(ErrorsG1)+3*sizeof(TErrorTerm));
ErrorB1 := PErrors(longInt(ErrorsB1)+3*sizeof(TErrorTerm));
ErrorR2 := PErrors(longInt(ErrorsR2)+3*sizeof(TErrorTerm));
ErrorG2 := PErrors(longInt(ErrorsG2)+3*sizeof(TErrorTerm));
ErrorB2 := PErrors(longInt(ErrorsB2)+3*sizeof(TErrorTerm));
ErrorR3 := PErrors(longInt(ErrorsR3)+3*sizeof(TErrorTerm));
ErrorG3 := PErrors(longInt(ErrorsG3)+3*sizeof(TErrorTerm));
ErrorB3 := PErrors(longInt(ErrorsB3)+3*sizeof(TErrorTerm));
end;
destructor TSteveArcheDitherer.Destroy;
begin
FreeMem(ErrorsR0);
FreeMem(ErrorsG0);
FreeMem(ErrorsB0);
FreeMem(ErrorsR1);
FreeMem(ErrorsG1);
FreeMem(ErrorsB1);
FreeMem(ErrorsR2);
FreeMem(ErrorsG2);
FreeMem(ErrorsB2);
FreeMem(ErrorsR3);
FreeMem(ErrorsG3);
FreeMem(ErrorsB3);
inherited Destroy;
end;
{$IFOPT R+}
{$DEFINE R_PLUS}
{$RANGECHECKS OFF}
{$ENDIF}
function TSteveArcheDitherer.Dither(Red, Green, Blue: BYTE; var R, G, B: BYTE): char;
var
ColorR ,
ColorG ,
ColorB : integer; // Error for current pixel
// Propagate Stevenson & Arche error terms:
// ... ... ... (here) ... 32/200 ...
// 12/200 ... 26/200 ... 30/200 ... 16/200
// ... 12/200 ... 26/200 ... 12/200 ...
// 5/200 ... 12/200 ... 12/200 ... 5/200
procedure Propagate(Errors0, Errors1, Errors2, Errors3: PErrors; Error: integer);
var
TempError : integer;
begin
if (Error = 0) then
exit;
TempError := 5 * Error;
inc(Errors3[FDirection3], TempError); // Error * 5
inc(Errors3[-FDirection3], TempError); // Error * 5
TempError := 12 * Error;
inc(Errors1[-FDirection3], TempError); // Error * 12
inc(Errors2[-FDirection2], TempError); // Error * 12
inc(Errors2[FDirection2], TempError); // Error * 12
inc(Errors3[-Direction], TempError); // Error * 12
inc(Errors3[Direction], TempError); // Error * 12
inc(Errors1[FDirection3], 16 * TempError); // Error * 16
TempError := 26 * Error;
inc(Errors1[-Direction], TempError); // Error * 26
inc(Errors2[0], TempError); // Error * 26
inc(Errors1[Direction], 30 * Error); // Error * 30
inc(Errors0[FDirection2], 32 * Error); // Error * 32
end;
begin
// Apply red component error correction
ColorR := Red + (ErrorR0[0] + 100) DIV 200;
if (ColorR < 0) then
ColorR := 0
else if (ColorR > 255) then
ColorR := 255;
// Apply green component error correction
ColorG := Green + (ErrorG0[0] + 100) DIV 200;
if (ColorG < 0) then
ColorG := 0
else if (ColorG > 255) then
ColorG := 255;
// Apply blue component error correction
ColorB := Blue + (ErrorB0[0] + 100) DIV 200;
if (ColorB < 0) then
ColorB := 0
else if (ColorB > 255) then
ColorB := 255;
// Map color to palette
Result := inherited Dither(ColorR, ColorG, ColorB, R, G, B);
// Propagate red component error
Propagate(ErrorR0, ErrorR1, ErrorR2, ErrorR3, ColorR - R);
// Propagate green component error
Propagate(ErrorG0, ErrorG1, ErrorG2, ErrorG3, ColorG - G);
// Propagate blue component error
Propagate(ErrorB0, ErrorB1, ErrorB2, ErrorB3, ColorB - B);
// Move on to next column
if (Direction = 1) then
begin
inc(longInt(ErrorR0), sizeof(TErrorTerm));
inc(longInt(ErrorG0), sizeof(TErrorTerm));
inc(longInt(ErrorB0), sizeof(TErrorTerm));
inc(longInt(ErrorR1), sizeof(TErrorTerm));
inc(longInt(ErrorG1), sizeof(TErrorTerm));
inc(longInt(ErrorB1), sizeof(TErrorTerm));
inc(longInt(ErrorR2), sizeof(TErrorTerm));
inc(longInt(ErrorG2), sizeof(TErrorTerm));
inc(longInt(ErrorB2), sizeof(TErrorTerm));
inc(longInt(ErrorR3), sizeof(TErrorTerm));
inc(longInt(ErrorG3), sizeof(TErrorTerm));
inc(longInt(ErrorB3), sizeof(TErrorTerm));
end else
begin
dec(longInt(ErrorR0), sizeof(TErrorTerm));
dec(longInt(ErrorG0), sizeof(TErrorTerm));
dec(longInt(ErrorB0), sizeof(TErrorTerm));
dec(longInt(ErrorR1), sizeof(TErrorTerm));
dec(longInt(ErrorG1), sizeof(TErrorTerm));
dec(longInt(ErrorB1), sizeof(TErrorTerm));
dec(longInt(ErrorR2), sizeof(TErrorTerm));
dec(longInt(ErrorG2), sizeof(TErrorTerm));
dec(longInt(ErrorB2), sizeof(TErrorTerm));
dec(longInt(ErrorR3), sizeof(TErrorTerm));
dec(longInt(ErrorG3), sizeof(TErrorTerm));
dec(longInt(ErrorB3), sizeof(TErrorTerm));
end;
end;
{$IFDEF R_PLUS}
{$RANGECHECKS ON}
{$UNDEF R_PLUS}
{$ENDIF}
{$IFOPT R+}
{$DEFINE R_PLUS}
{$RANGECHECKS OFF}
{$ENDIF}
procedure TSteveArcheDitherer.NextLine;
var
TempErrors : PErrors;
begin
FillChar(ErrorsR0^, sizeof(TErrorTerm)*(Width+6), 0);
FillChar(ErrorsG0^, sizeof(TErrorTerm)*(Width+6), 0);
FillChar(ErrorsB0^, sizeof(TErrorTerm)*(Width+6), 0);
// Swap lines
TempErrors := ErrorsR0;
ErrorsR0 := ErrorsR1;
ErrorsR1 := ErrorsR2;
ErrorsR2 := ErrorsR3;
ErrorsR3 := TempErrors;
TempErrors := ErrorsG0;
ErrorsG0 := ErrorsG1;
ErrorsG1 := ErrorsG2;
ErrorsG2 := ErrorsG3;
ErrorsG3 := TempErrors;
TempErrors := ErrorsB0;
ErrorsB0 := ErrorsB1;
ErrorsB1 := ErrorsB2;
ErrorsB2 := ErrorsB3;
ErrorsB3 := TempErrors;
inherited NextLine;
FDirection2 := 2 * Direction;
FDirection3 := 3 * Direction;
if (Direction = 1) then
begin
// ErrorsR0[1] gives compiler error, so we
// use PErrors(longInt(ErrorsR0)+sizeof(TErrorTerm)) instead...
ErrorR0 := PErrors(longInt(ErrorsR0)+3*sizeof(TErrorTerm));
ErrorG0 := PErrors(longInt(ErrorsG0)+3*sizeof(TErrorTerm));
ErrorB0 := PErrors(longInt(ErrorsB0)+3*sizeof(TErrorTerm));
ErrorR1 := PErrors(longInt(ErrorsR1)+3*sizeof(TErrorTerm));
ErrorG1 := PErrors(longInt(ErrorsG1)+3*sizeof(TErrorTerm));
ErrorB1 := PErrors(longInt(ErrorsB1)+3*sizeof(TErrorTerm));
ErrorR2 := PErrors(longInt(ErrorsR2)+3*sizeof(TErrorTerm));
ErrorG2 := PErrors(longInt(ErrorsG2)+3*sizeof(TErrorTerm));
ErrorB2 := PErrors(longInt(ErrorsB2)+3*sizeof(TErrorTerm));
ErrorR3 := PErrors(longInt(ErrorsR3)+3*sizeof(TErrorTerm));
ErrorG3 := PErrors(longInt(ErrorsG3)+3*sizeof(TErrorTerm));
ErrorB3 := PErrors(longInt(ErrorsB3)+3*sizeof(TErrorTerm));
end else
begin
ErrorR0 := @ErrorsR0[Width+2];
ErrorG0 := @ErrorsG0[Width+2];
ErrorB0 := @ErrorsB0[Width+2];
ErrorR1 := @ErrorsR1[Width+2];
ErrorG1 := @ErrorsG1[Width+2];
ErrorB1 := @ErrorsB1[Width+2];
ErrorR2 := @ErrorsR2[Width+2];
ErrorG2 := @ErrorsG2[Width+2];
ErrorB2 := @ErrorsB2[Width+2];
ErrorR3 := @ErrorsR2[Width+2];
ErrorG3 := @ErrorsG2[Width+2];
ErrorB3 := @ErrorsB2[Width+2];
end;
end;
{$IFDEF R_PLUS}
{$RANGECHECKS ON}
{$UNDEF R_PLUS}
{$ENDIF}
////////////////////////////////////////////////////////////////////////////////
// TBurkesDitherer
constructor TBurkesDitherer.Create(AWidth: integer; Lookup: TColorLookup);
begin
inherited Create(AWidth, Lookup);
GetMem(ErrorsR0, sizeof(TErrorTerm)*(Width+4));
GetMem(ErrorsG0, sizeof(TErrorTerm)*(Width+4));
GetMem(ErrorsB0, sizeof(TErrorTerm)*(Width+4));
GetMem(ErrorsR1, sizeof(TErrorTerm)*(Width+4));
GetMem(ErrorsG1, sizeof(TErrorTerm)*(Width+4));
GetMem(ErrorsB1, sizeof(TErrorTerm)*(Width+4));
FillChar(ErrorsR0^, sizeof(TErrorTerm)*(Width+4), 0);
FillChar(ErrorsG0^, sizeof(TErrorTerm)*(Width+4), 0);
FillChar(ErrorsB0^, sizeof(TErrorTerm)*(Width+4), 0);
FillChar(ErrorsR1^, sizeof(TErrorTerm)*(Width+4), 0);
FillChar(ErrorsG1^, sizeof(TErrorTerm)*(Width+4), 0);
FillChar(ErrorsB1^, sizeof(TErrorTerm)*(Width+4), 0);
FDirection2 := 2 * Direction;
ErrorR0 := PErrors(longInt(ErrorsR0)+2*sizeof(TErrorTerm));
ErrorG0 := PErrors(longInt(ErrorsG0)+2*sizeof(TErrorTerm));
ErrorB0 := PErrors(longInt(ErrorsB0)+2*sizeof(TErrorTerm));
ErrorR1 := PErrors(longInt(ErrorsR1)+2*sizeof(TErrorTerm));
ErrorG1 := PErrors(longInt(ErrorsG1)+2*sizeof(TErrorTerm));
ErrorB1 := PErrors(longInt(ErrorsB1)+2*sizeof(TErrorTerm));
end;
destructor TBurkesDitherer.Destroy;
begin
FreeMem(ErrorsR0);
FreeMem(ErrorsG0);
FreeMem(ErrorsB0);
FreeMem(ErrorsR1);
FreeMem(ErrorsG1);
FreeMem(ErrorsB1);
inherited Destroy;
end;
{$IFOPT R+}
{$DEFINE R_PLUS}
{$RANGECHECKS OFF}
{$ENDIF}
function TBurkesDitherer.Dither(Red, Green, Blue: BYTE; var R, G, B: BYTE): char;
var
ErrorR ,
ErrorG ,
ErrorB : integer; // Error for current pixel
// Propagate Burkes error terms:
// ... ... (here) 8/32 4/32
// 2/32 4/32 8/32 4/32 2/32
procedure Propagate(Errors0, Errors1: PErrors; Error: integer);
begin
if (Error = 0) then
exit;
inc(Error, Error);
inc(Errors1[FDirection2], Error); // Error * 2
inc(Errors1[-FDirection2], Error); // Error * 2
inc(Error, Error);
inc(Errors0[FDirection2], Error); // Error * 4
inc(Errors1[-Direction], Error); // Error * 4
inc(Errors1[Direction], Error); // Error * 4
inc(Error, Error);
inc(Errors0[Direction], Error); // Error * 8
inc(Errors1[0], Error); // Error * 8
end;
begin
// Apply red component error correction
ErrorR := Red + (ErrorR0[0] + 16) DIV 32;
if (ErrorR < 0) then
ErrorR := 0
else if (ErrorR > 255) then
ErrorR := 255;
// Apply green component error correction
ErrorG := Green + (ErrorG0[0] + 16) DIV 32;
if (ErrorG < 0) then
ErrorG := 0
else if (ErrorG > 255) then
ErrorG := 255;
// Apply blue component error correction
ErrorB := Blue + (ErrorB0[0] + 16) DIV 32;
if (ErrorB < 0) then
ErrorB := 0
else if (ErrorB > 255) then
ErrorB := 255;
// Map color to palette
Result := inherited Dither(ErrorR, ErrorG, ErrorB, R, G, B);
// Propagate red component error
Propagate(ErrorR0, ErrorR1, ErrorR - R);
// Propagate green component error
Propagate(ErrorG0, ErrorG1, ErrorG - G);
// Propagate blue component error
Propagate(ErrorB0, ErrorB1, ErrorB - B);
// Move on to next column
if (Direction = 1) then
begin
inc(longInt(ErrorR0), sizeof(TErrorTerm));
inc(longInt(ErrorG0), sizeof(TErrorTerm));
inc(longInt(ErrorB0), sizeof(TErrorTerm));
inc(longInt(ErrorR1), sizeof(TErrorTerm));
inc(longInt(ErrorG1), sizeof(TErrorTerm));
inc(longInt(ErrorB1), sizeof(TErrorTerm));
end else
begin
dec(longInt(ErrorR0), sizeof(TErrorTerm));
dec(longInt(ErrorG0), sizeof(TErrorTerm));
dec(longInt(ErrorB0), sizeof(TErrorTerm));
dec(longInt(ErrorR1), sizeof(TErrorTerm));
dec(longInt(ErrorG1), sizeof(TErrorTerm));
dec(longInt(ErrorB1), sizeof(TErrorTerm));
end;
end;
{$IFDEF R_PLUS}
{$RANGECHECKS ON}
{$UNDEF R_PLUS}
{$ENDIF}
{$IFOPT R+}
{$DEFINE R_PLUS}
{$RANGECHECKS OFF}
{$ENDIF}
procedure TBurkesDitherer.NextLine;
var
TempErrors : PErrors;
begin
FillChar(ErrorsR0^, sizeof(TErrorTerm)*(Width+4), 0);
FillChar(ErrorsG0^, sizeof(TErrorTerm)*(Width+4), 0);
FillChar(ErrorsB0^, sizeof(TErrorTerm)*(Width+4), 0);
// Swap lines
TempErrors := ErrorsR0;
ErrorsR0 := ErrorsR1;
ErrorsR1 := TempErrors;
TempErrors := ErrorsG0;
ErrorsG0 := ErrorsG1;
ErrorsG1 := TempErrors;
TempErrors := ErrorsB0;
ErrorsB0 := ErrorsB1;
ErrorsB1 := TempErrors;
inherited NextLine;
FDirection2 := 2 * Direction;
if (Direction = 1) then
begin
// ErrorsR0[1] gives compiler error, so we
// use PErrors(longInt(ErrorsR0)+sizeof(TErrorTerm)) instead...
ErrorR0 := PErrors(longInt(ErrorsR0)+2*sizeof(TErrorTerm));
ErrorG0 := PErrors(longInt(ErrorsG0)+2*sizeof(TErrorTerm));
ErrorB0 := PErrors(longInt(ErrorsB0)+2*sizeof(TErrorTerm));
ErrorR1 := PErrors(longInt(ErrorsR1)+2*sizeof(TErrorTerm));
ErrorG1 := PErrors(longInt(ErrorsG1)+2*sizeof(TErrorTerm));
ErrorB1 := PErrors(longInt(ErrorsB1)+2*sizeof(TErrorTerm));
end else
begin
ErrorR0 := @ErrorsR0[Width+1];
ErrorG0 := @ErrorsG0[Width+1];
ErrorB0 := @ErrorsB0[Width+1];
ErrorR1 := @ErrorsR1[Width+1];
ErrorG1 := @ErrorsG1[Width+1];
ErrorB1 := @ErrorsB1[Width+1];
end;
end;
{$IFDEF R_PLUS}
{$RANGECHECKS ON}
{$UNDEF R_PLUS}
{$ENDIF}
////////////////////////////////////////////////////////////////////////////////
//
// Octree Color Quantization Engine
//
////////////////////////////////////////////////////////////////////////////////
// Adapted from Earl F. Glynn's ColorQuantizationLibrary, March 1998
////////////////////////////////////////////////////////////////////////////////
type
TOctreeNode = class; // Forward definition so TReducibleNodes can be declared
TReducibleNodes = array[0..7] of TOctreeNode;
TOctreeNode = Class(TObject)
public
IsLeaf : Boolean;
PixelCount : integer;
RedSum : integer;
GreenSum : integer;
BlueSum : integer;
Next : TOctreeNode;
Child : TReducibleNodes;
constructor Create(Level: integer; ColorBits: integer; var LeafCount: integer;
var ReducibleNodes: TReducibleNodes);
destructor Destroy; override;
end;
TColorQuantizer = class(TObject)
private
FTree : TOctreeNode;
FLeafCount : integer;
FReducibleNodes : TReducibleNodes;
FMaxColors : integer;
FColorBits : integer;
protected
procedure AddColor(var Node: TOctreeNode; r, g, b: byte; ColorBits: integer;
Level: integer; var LeafCount: integer; var ReducibleNodes: TReducibleNodes);
procedure DeleteTree(var Node: TOctreeNode);
procedure GetPaletteColors(const Node: TOctreeNode;
var RGBQuadArray: TRGBQuadArray; var Index: integer);
procedure ReduceTree(ColorBits: integer; var LeafCount: integer;
var ReducibleNodes: TReducibleNodes);
public
constructor Create(MaxColors: integer; ColorBits: integer);
destructor Destroy; override;
procedure GetColorTable(var RGBQuadArray: TRGBQuadArray);
function ProcessImage(const DIB: TDIBReader): boolean;
property ColorCount: integer read FLeafCount;
end;
constructor TOctreeNode.Create(Level: integer; ColorBits: integer;
var LeafCount: integer; var ReducibleNodes: TReducibleNodes);
var
i : integer;
begin
PixelCount := 0;
RedSum := 0;
GreenSum := 0;
BlueSum := 0;
for i := Low(Child) to High(Child) do
Child[i] := nil;
IsLeaf := (Level = ColorBits);
if (IsLeaf) then
begin
Next := nil;
inc(LeafCount);
end else
begin
Next := ReducibleNodes[Level];
ReducibleNodes[Level] := self;
end;
end;
destructor TOctreeNode.Destroy;
var
i : integer;
begin
for i := High(Child) downto Low(Child) do
Child[i].Free;
end;
constructor TColorQuantizer.Create(MaxColors: integer; ColorBits: integer);
var
i : integer;
begin
ASSERT(ColorBits <= 8, 'ColorBits must be 8 or less');
FTree := nil;
FLeafCount := 0;
// Initialize all nodes even though only ColorBits+1 of them are needed
for i := Low(FReducibleNodes) to High(FReducibleNodes) do
FReducibleNodes[i] := nil;
FMaxColors := MaxColors;
FColorBits := ColorBits;
end;
destructor TColorQuantizer.Destroy;
begin
if (FTree <> nil) then
DeleteTree(FTree);
end;
procedure TColorQuantizer.GetColorTable(var RGBQuadArray: TRGBQuadArray);
var
Index : integer;
begin
Index := 0;
GetPaletteColors(FTree, RGBQuadArray, Index);
end;
// Handles passed to ProcessImage should refer to DIB sections, not DDBs.
// In certain cases, specifically when it's called upon to process 1, 4, or
// 8-bit per pixel images on systems with palettized display adapters,
// ProcessImage can produce incorrect results if it's passed a handle to a
// DDB.
function TColorQuantizer.ProcessImage(const DIB: TDIBReader): boolean;
var
i ,
j : integer;
ScanLine : pointer;
Pixel : PRGBTriple;
begin
Result := True;
for j := 0 to DIB.Bitmap.Height-1 do
begin
Scanline := DIB.Scanline[j];
Pixel := ScanLine;
for i := 0 to DIB.Bitmap.Width-1 do
begin
with Pixel^ do
AddColor(FTree, rgbtRed, rgbtGreen, rgbtBlue,
FColorBits, 0, FLeafCount, FReducibleNodes);
while FLeafCount > FMaxColors do
ReduceTree(FColorbits, FLeafCount, FReducibleNodes);
inc(Pixel);
end;
end;
end;
procedure TColorQuantizer.AddColor(var Node: TOctreeNode; r,g,b: byte;
ColorBits: integer; Level: integer; var LeafCount: integer;
var ReducibleNodes: TReducibleNodes);
const
Mask: array[0..7] of BYTE = ($80, $40, $20, $10, $08, $04, $02, $01);
var
Index : integer;
Shift : integer;
begin
// If the node doesn't exist, create it.
if (Node = nil) then
Node := TOctreeNode.Create(Level, ColorBits, LeafCount, ReducibleNodes);
if (Node.IsLeaf) then
begin
inc(Node.PixelCount);
inc(Node.RedSum, r);
inc(Node.GreenSum, g);
inc(Node.BlueSum, b);
end else
begin
// Recurse a level deeper if the node is not a leaf.
Shift := 7 - Level;
Index := (((r and mask[Level]) SHR Shift) SHL 2) or
(((g and mask[Level]) SHR Shift) SHL 1) or
((b and mask[Level]) SHR Shift);
AddColor(Node.Child[Index], r, g, b, ColorBits, Level+1, LeafCount, ReducibleNodes);
end;
end;
procedure TColorQuantizer.DeleteTree(var Node: TOctreeNode);
var
i : integer;
begin
for i := High(TReducibleNodes) downto Low(TReducibleNodes) do
if (Node.Child[i] <> nil) then
DeleteTree(Node.Child[i]);
Node.Free;
Node := nil;
end;
procedure TColorQuantizer.GetPaletteColors(const Node: TOctreeNode;
var RGBQuadArray: TRGBQuadArray; var Index: integer);
var
i : integer;
begin
if (Node.IsLeaf) then
begin
with RGBQuadArray[Index] do
begin
if (Node.PixelCount <> 0) then
begin
rgbRed := BYTE(Node.RedSum DIV Node.PixelCount);
rgbGreen := BYTE(Node.GreenSum DIV Node.PixelCount);
rgbBlue := BYTE(Node.BlueSum DIV Node.PixelCount);
end else
begin
rgbRed := 0;
rgbGreen := 0;
rgbBlue := 0;
end;
rgbReserved := 0;
end;
inc(Index);
end else
begin
for i := Low(Node.Child) to High(Node.Child) do
if (Node.Child[i] <> nil) then
GetPaletteColors(Node.Child[i], RGBQuadArray, Index);
end;
end;
procedure TColorQuantizer.ReduceTree(ColorBits: integer; var LeafCount: integer;
var ReducibleNodes: TReducibleNodes);
var
RedSum ,
GreenSum ,
BlueSum : integer;
Children : integer;
i : integer;
Node : TOctreeNode;
begin
// Find the deepest level containing at least one reducible node
i := Colorbits - 1;
while (i > 0) and (ReducibleNodes[i] = nil) do
dec(i);
// Reduce the node most recently added to the list at level i.
Node := ReducibleNodes[i];
ReducibleNodes[i] := Node.Next;
RedSum := 0;
GreenSum := 0;
BlueSum := 0;
Children := 0;
for i := Low(ReducibleNodes) to High(ReducibleNodes) do
if (Node.Child[i] <> nil) then
begin
inc(RedSum, Node.Child[i].RedSum);
inc(GreenSum, Node.Child[i].GreenSum);
inc(BlueSum, Node.Child[i].BlueSum);
inc(Node.PixelCount, Node.Child[i].PixelCount);
Node.Child[i].Free;
Node.Child[i] := nil;
inc(Children);
end;
Node.IsLeaf := TRUE;
Node.RedSum := RedSum;
Node.GreenSum := GreenSum;
Node.BlueSum := BlueSum;
dec(LeafCount, Children-1);
end;
////////////////////////////////////////////////////////////////////////////////
//
// Octree Color Quantization Wrapper
//
////////////////////////////////////////////////////////////////////////////////
// Adapted from Earl F. Glynn's PaletteLibrary, March 1998
////////////////////////////////////////////////////////////////////////////////
// Wrapper for internal use - uses TDIBReader for bitmap access
function doCreateOptimizedPaletteFromSingleBitmap(const DIB: TDIBReader;
Colors, ColorBits: integer; Windows: boolean): hPalette;
var
SystemPalette : HPalette;
ColorQuantizer : TColorQuantizer;
i : integer;
LogicalPalette : TMaxLogPalette;
RGBQuadArray : TRGBQuadArray;
Offset : integer;
begin
LogicalPalette.palVersion := $0300;
LogicalPalette.palNumEntries := Colors;
if (Windows) then
begin
// Get the windows 20 color system palette
SystemPalette := GetStockObject(DEFAULT_PALETTE);
GetPaletteEntries(SystemPalette, 0, 10, LogicalPalette.palPalEntry[0]);
GetPaletteEntries(SystemPalette, 10, 10, LogicalPalette.palPalEntry[245]);
Colors := 236;
Offset := 10;
LogicalPalette.palNumEntries := 256;
end else
Offset := 0;
// Normally for 24-bit images, use ColorBits of 5 or 6. For 8-bit images
// use ColorBits = 8.
ColorQuantizer := TColorQuantizer.Create(Colors, ColorBits);
try
ColorQuantizer.ProcessImage(DIB);
ColorQuantizer.GetColorTable(RGBQuadArray);
finally
ColorQuantizer.Free;
end;
for i := 0 to Colors-1 do
with LogicalPalette.palPalEntry[i+Offset] do
begin
peRed := RGBQuadArray[i].rgbRed;
peGreen := RGBQuadArray[i].rgbGreen;
peBlue := RGBQuadArray[i].rgbBlue;
peFlags := RGBQuadArray[i].rgbReserved;
end;
Result := CreatePalette(pLogPalette(@LogicalPalette)^);
end;
function CreateOptimizedPaletteFromSingleBitmap(const Bitmap: TBitmap;
Colors, ColorBits: integer; Windows: boolean): hPalette;
var
DIB : TDIBReader;
begin
DIB := TDIBReader.Create(Bitmap, pf24bit);
try
Result := doCreateOptimizedPaletteFromSingleBitmap(DIB, Colors, ColorBits, Windows);
finally
DIB.Free;
end;
end;
function CreateOptimizedPaletteFromManyBitmaps(Bitmaps: TList; Colors, ColorBits: integer;
Windows: boolean): hPalette;
var
SystemPalette : HPalette;
ColorQuantizer : TColorQuantizer;
i : integer;
LogicalPalette : TMaxLogPalette;
RGBQuadArray : TRGBQuadArray;
Offset : integer;
DIB : TDIBReader;
begin
if (Bitmaps = nil) or (Bitmaps.Count = 0) then
Error(sInvalidBitmapList);
LogicalPalette.palVersion := $0300;
LogicalPalette.palNumEntries := Colors;
if (Windows) then
begin
// Get the windows 20 color system palette
SystemPalette := GetStockObject(DEFAULT_PALETTE);
GetPaletteEntries(SystemPalette, 0, 10, LogicalPalette.palPalEntry[0]);
GetPaletteEntries(SystemPalette, 10, 10, LogicalPalette.palPalEntry[245]);
Colors := 236;
Offset := 10;
LogicalPalette.palNumEntries := 256;
end else
Offset := 0;
// Normally for 24-bit images, use ColorBits of 5 or 6. For 8-bit images
// use ColorBits = 8.
ColorQuantizer := TColorQuantizer.Create(Colors, ColorBits);
try
for i := 0 to Bitmaps.Count-1 do
begin
DIB := TDIBReader.Create(TBitmap(Bitmaps[i]), pf24bit);
try
ColorQuantizer.ProcessImage(DIB);
finally
DIB.Free;
end;
end;
ColorQuantizer.GetColorTable(RGBQuadArray);
finally
ColorQuantizer.Free;
end;
for i := 0 to Colors-1 do
with LogicalPalette.palPalEntry[i+Offset] do
begin
peRed := RGBQuadArray[i].rgbRed;
peGreen := RGBQuadArray[i].rgbGreen;
peBlue := RGBQuadArray[i].rgbBlue;
peFlags := RGBQuadArray[i].rgbReserved;
end;
Result := CreatePalette(pLogPalette(@LogicalPalette)^);
end;
////////////////////////////////////////////////////////////////////////////////
//
// Color reduction
//
////////////////////////////////////////////////////////////////////////////////
{$IFOPT R+}
{$DEFINE R_PLUS}
{$RANGECHECKS OFF}
{$ENDIF}
//: Reduces the color depth of a bitmap using color quantization and dithering.
function ReduceColors(Bitmap: TBitmap; ColorReduction: TColorReduction;
DitherMode: TDitherMode; ReductionBits: integer; CustomPalette: hPalette): TBitmap;
var
Palette : hPalette;
ColorLookup : TColorLookup;
Ditherer : TDitherEngine;
Row : Integer;
DIBResult : TDIBWriter;
DIBSource : TDIBReader;
SrcScanLine ,
Src : PRGBTriple;
DstScanLine ,
Dst : PChar;
BGR : TRGBTriple;
{$ifdef DEBUG_DITHERPERFORMANCE}
TimeStart ,
TimeStop : DWORD;
{$endif}
function GrayScalePalette: hPalette;
var
i : integer;
Pal : TMaxLogPalette;
begin
Pal.palVersion := $0300;
Pal.palNumEntries := 256;
for i := 0 to 255 do
begin
with (Pal.palPalEntry[i]) do
begin
peRed := i;
peGreen := i;
peBlue := i;
peFlags := PC_NOCOLLAPSE;
end;
end;
Result := CreatePalette(pLogPalette(@Pal)^);
end;
function MonochromePalette: hPalette;
var
i : integer;
Pal : TMaxLogPalette;
const
Values : array[0..1] of byte
= (0, 255);
begin
Pal.palVersion := $0300;
Pal.palNumEntries := 2;
for i := 0 to 1 do
begin
with (Pal.palPalEntry[i]) do
begin
peRed := Values[i];
peGreen := Values[i];
peBlue := Values[i];
peFlags := PC_NOCOLLAPSE;
end;
end;
Result := CreatePalette(pLogPalette(@Pal)^);
end;
function WindowsGrayScalePalette: hPalette;
var
i : integer;
Pal : TMaxLogPalette;
const
Values : array[0..3] of byte
= (0, 128, 192, 255);
begin
Pal.palVersion := $0300;
Pal.palNumEntries := 4;
for i := 0 to 3 do
begin
with (Pal.palPalEntry[i]) do
begin
peRed := Values[i];
peGreen := Values[i];
peBlue := Values[i];
peFlags := PC_NOCOLLAPSE;
end;
end;
Result := CreatePalette(pLogPalette(@Pal)^);
end;
function WindowsHalftonePalette: hPalette;
var
DC : HDC;
begin
DC := GDICheck(GetDC(0));
try
Result := CreateHalfTonePalette(DC);
finally
ReleaseDC(0, DC);
end;
end;
begin
{$ifdef DEBUG_DITHERPERFORMANCE}
timeBeginPeriod(5);
TimeStart := timeGetTime;
{$endif}
Result := TBitmap.Create;
try
if (ColorReduction = rmNone) then
begin
Result.Assign(Bitmap);
{$ifndef VER9x}
SetPixelFormat(Result, pf24bit);
{$endif}
exit;
end;
{$IFNDEF VER9x}
if (Bitmap.Width*Bitmap.Height > BitmapAllocationThreshold) then
SetPixelFormat(Result, pf1bit); // To reduce resource consumption of resize
{$ENDIF}
ColorLookup := nil;
Ditherer := nil;
DIBResult := nil;
DIBSource := nil;
Palette := 0;
try // Protect above resources
// Dithering and color mapper only supports 24 bit bitmaps,
// so we have convert the source bitmap to the appropiate format.
DIBSource := TDIBReader.Create(Bitmap, pf24bit);
// Create a palette based on current options
case (ColorReduction) of
rmQuantize:
Palette := doCreateOptimizedPaletteFromSingleBitmap(DIBSource, 1 SHL ReductionBits, 8, False);
rmQuantizeWindows:
Palette := CreateOptimizedPaletteFromSingleBitmap(Bitmap, 256, 8, True);
rmNetscape:
Palette := WebPalette;
rmGrayScale:
Palette := GrayScalePalette;
rmMonochrome:
Palette := MonochromePalette;
rmWindowsGray:
Palette := WindowsGrayScalePalette;
rmWindows20:
Palette := GetStockObject(DEFAULT_PALETTE);
rmWindows256:
Palette := WindowsHalftonePalette;
rmPalette:
Palette := CopyPalette(CustomPalette);
else
exit;
end;
{ TODO -oanme -cImprovement : Gray scale conversion should be done prior to dithering/mapping. Otherwise corrected values will be converted multiple times. }
// Create a color mapper based on current options
case (ColorReduction) of
// For some strange reason my fast and dirty color lookup
// is more precise that Windows GetNearestPaletteIndex...
// rmWindows20:
// ColorLookup := TSlowColorLookup.Create(Palette);
// rmWindowsGray:
// ColorLookup := TGrayWindowsLookup.Create(Palette);
rmQuantize:
ColorLookup := TFastColorLookup.Create(Palette);
rmNetscape:
ColorLookup := TNetscapeColorLookup.Create(Palette);
rmGrayScale:
ColorLookup := TGrayScaleLookup.Create(Palette);
rmMonochrome:
ColorLookup := TMonochromeLookup.Create(Palette);
else
ColorLookup := TFastColorLookup.Create(Palette);
end;
// Nothing to do if palette doesn't contain any colors
if (ColorLookup.Colors = 0) then
exit;
// Create a ditherer based on current options
case (DitherMode) of
dmNearest:
Ditherer := TDitherEngine.Create(Bitmap.Width, ColorLookup);
dmFloydSteinberg:
Ditherer := TFloydSteinbergDitherer.Create(Bitmap.Width, ColorLookup);
dmStucki:
Ditherer := TStuckiDitherer.Create(Bitmap.Width, ColorLookup);
dmSierra:
Ditherer := TSierraDitherer.Create(Bitmap.Width, ColorLookup);
dmJaJuNI:
Ditherer := TJaJuNIDitherer.Create(Bitmap.Width, ColorLookup);
dmSteveArche:
Ditherer := TSteveArcheDitherer.Create(Bitmap.Width, ColorLookup);
dmBurkes:
Ditherer := TBurkesDitherer.Create(Bitmap.Width, ColorLookup);
else
exit;
end;
// The processed bitmap is returned in pf8bit format
DIBResult := TDIBWriter.Create(Result, pf8bit, Bitmap.Width, Bitmap.Height,
Palette);
// Process the image
Row := 0;
while (Row < Bitmap.Height) do
begin
SrcScanline := DIBSource.ScanLine[Row];
DstScanline := DIBResult.ScanLine[Row];
Src := pointer(longInt(SrcScanLine) + Ditherer.Column*sizeof(TRGBTriple));
Dst := pointer(longInt(DstScanLine) + Ditherer.Column);
while (Ditherer.Column < Ditherer.Width) and (Ditherer.Column >= 0) do
begin
BGR := Src^;
// Dither and map a single pixel
Dst^ := Ditherer.Dither(BGR.rgbtRed, BGR.rgbtGreen, BGR.rgbtBlue,
BGR.rgbtRed, BGR.rgbtGreen, BGR.rgbtBlue);
inc(Src, Ditherer.Direction);
inc(Dst, Ditherer.Direction);
end;
Inc(Row);
Ditherer.NextLine;
end;
finally
if (ColorLookup <> nil) then
ColorLookup.Free;
if (Ditherer <> nil) then
Ditherer.Free;
if (DIBResult <> nil) then
DIBResult.Free;
if (DIBSource <> nil) then
DIBSource.Free;
// Must delete palette after TDIBWriter since TDIBWriter uses palette
if (Palette <> 0) then
DeleteObject(Palette);
end;
except
Result.Free;
raise;
end;
{$ifdef DEBUG_DITHERPERFORMANCE}
TimeStop := timeGetTime;
ShowMessage(format('Dithered %d pixels in %d mS, Rate %d pixels/mS (%d pixels/S)',
[Bitmap.Height*Bitmap.Width, TimeStop-TimeStart,
MulDiv(Bitmap.Height, Bitmap.Width, TimeStop-TimeStart+1),
MulDiv(Bitmap.Height, Bitmap.Width * 1000, TimeStop-TimeStart+1)]));
timeEndPeriod(5);
{$endif}
end;
{$IFDEF R_PLUS}
{$RANGECHECKS ON}
{$UNDEF R_PLUS}
{$ENDIF}
////////////////////////////////////////////////////////////////////////////////
//
// TGIFColorMap
//
////////////////////////////////////////////////////////////////////////////////
const
InitColorMapSize = 16;
DeltaColorMapSize = 32;
//: Creates an instance of a TGIFColorMap object.
constructor TGIFColorMap.Create;
begin
inherited Create;
FColorMap := nil;
FCapacity := 0;
FCount := 0;
FOptimized := False;
end;
//: Destroys an instance of a TGIFColorMap object.
destructor TGIFColorMap.Destroy;
begin
Clear;
Changed;
inherited Destroy;
end;
//: Empties the color map.
procedure TGIFColorMap.Clear;
begin
if (FColorMap <> nil) then
FreeMem(FColorMap);
FColorMap := nil;
FCapacity := 0;
FCount := 0;
FOptimized := False;
end;
//: Converts a Windows color value to a RGB value.
class function TGIFColorMap.Color2RGB(Color: TColor): TGIFColor;
begin
Result.Blue := (Color shr 16) and $FF;
Result.Green := (Color shr 8) and $FF;
Result.Red := Color and $FF;
end;
//: Converts a RGB value to a Windows color value.
class function TGIFColorMap.RGB2Color(Color: TGIFColor): TColor;
begin
Result := (Color.Blue SHL 16) OR (Color.Green SHL 8) OR Color.Red;
end;
//: Saves the color map to a stream.
procedure TGIFColorMap.SaveToStream(Stream: TStream);
var
Dummies : integer;
Dummy : TGIFColor;
begin
if (FCount = 0) then
exit;
Stream.WriteBuffer(FColorMap^, FCount*sizeof(TGIFColor));
Dummies := (1 SHL BitsPerPixel)-FCount;
Dummy.Red := 0;
Dummy.Green := 0;
Dummy.Blue := 0;
while (Dummies > 0) do
begin
Stream.WriteBuffer(Dummy, sizeof(TGIFColor));
dec(Dummies);
end;
end;
//: Loads the color map from a stream.
procedure TGIFColorMap.LoadFromStream(Stream: TStream; Count: integer);
begin
Clear;
SetCapacity(Count);
ReadCheck(Stream, FColorMap^, Count*sizeof(TGIFColor));
FCount := Count;
end;
//: Returns the position of a color in the color map.
function TGIFColorMap.IndexOf(Color: TColor): integer;
var
RGB : TGIFColor;
begin
RGB := Color2RGB(Color);
if (FOptimized) then
begin
// Optimized palette has most frequently occuring entries first
Result := 0;
// Reverse search to (hopefully) check latest colors first
while (Result < FCount) do
with (FColorMap^[Result]) do
begin
if (RGB.Red = Red) and (RGB.Green = Green) and (RGB.Blue = Blue) then
exit;
Inc(Result);
end;
Result := -1;
end else
begin
Result := FCount-1;
// Reverse search to (hopefully) check latest colors first
while (Result >= 0) do
with (FColorMap^[Result]) do
begin
if (RGB.Red = Red) and (RGB.Green = Green) and (RGB.Blue = Blue) then
exit;
Dec(Result);
end;
end;
end;
procedure TGIFColorMap.SetCapacity(Size: integer);
begin
if (Size >= FCapacity) then
begin
if (Size <= InitColorMapSize) then
FCapacity := InitColorMapSize
else
FCapacity := (Size + DeltaColorMapSize - 1) DIV DeltaColorMapSize * DeltaColorMapSize;
if (FCapacity > GIFMaxColors) then
FCapacity := GIFMaxColors;
ReallocMem(FColorMap, FCapacity * sizeof(TGIFColor));
end;
end;
//: Imports a Windows palette into the color map.
procedure TGIFColorMap.ImportPalette(Palette: HPalette);
type
PalArray = array[byte] of TPaletteEntry;
var
Pal : PalArray;
NewCount : integer;
i : integer;
begin
Clear;
NewCount := GetPaletteEntries(Palette, 0, 256, pal);
if (NewCount = 0) then
exit;
SetCapacity(NewCount);
for i := 0 to NewCount-1 do
with FColorMap[i], Pal[i] do
begin
Red := peRed;
Green := peGreen;
Blue := peBlue;
end;
FCount := NewCount;
Changed;
end;
//: Imports a color map structure into the color map.
procedure TGIFColorMap.ImportColorMap(Map: TColorMap; Count: integer);
begin
Clear;
if (Count = 0) then
exit;
SetCapacity(Count);
FCount := Count;
System.Move(Map, FColorMap^, FCount * sizeof(TGIFColor));
Changed;
end;
//: Imports a Windows palette structure into the color map.
procedure TGIFColorMap.ImportColorTable(Pal: pointer; Count: integer);
var
i : integer;
begin
Clear;
if (Count = 0) then
exit;
SetCapacity(Count);
for i := 0 to Count-1 do
with FColorMap[i], PRGBQuadArray(Pal)[i] do
begin
Red := rgbRed;
Green := rgbGreen;
Blue := rgbBlue;
end;
FCount := Count;
Changed;
end;
//: Imports the color table of a DIB into the color map.
procedure TGIFColorMap.ImportDIBColors(Handle: HDC);
var
Pal : Pointer;
NewCount : integer;
begin
Clear;
GetMem(Pal, sizeof(TRGBQuad) * 256);
try
NewCount := GetDIBColorTable(Handle, 0, 256, Pal^);
ImportColorTable(Pal, NewCount);
finally
FreeMem(Pal);
end;
Changed;
end;
//: Creates a Windows palette from the color map.
function TGIFColorMap.ExportPalette: HPalette;
var
Pal : TMaxLogPalette;
i : Integer;
begin
if (Count = 0) then
begin
Result := 0;
exit;
end;
Pal.palVersion := $300;
Pal.palNumEntries := Count;
for i := 0 to Count-1 do
with FColorMap[i], Pal.palPalEntry[i] do
begin
peRed := Red;
peGreen := Green;
peBlue := Blue;
peFlags := PC_NOCOLLAPSE; { TODO -oanme -cImprovement : Verify that PC_NOCOLLAPSE is the correct value to use. }
end;
Result := CreatePalette(PLogPalette(@Pal)^);
end;
//: Adds a color to the color map.
function TGIFColorMap.Add(Color: TColor): integer;
begin
if (FCount >= GIFMaxColors) then
// Color map full
Error(sTooManyColors);
Result := FCount;
if (Result >= FCapacity) then
SetCapacity(FCount+1);
FColorMap^[FCount] := Color2RGB(Color);
inc(FCount);
FOptimized := False;
Changed;
end;
function TGIFColorMap.AddUnique(Color: TColor): integer;
begin
// Look up color before add (same as IndexOf)
Result := IndexOf(Color);
if (Result >= 0) then
// Color already in map
exit;
Result := Add(Color);
end;
//: Removes a color from the color map.
procedure TGIFColorMap.Delete(Index: integer);
begin
if (Index < 0) or (Index >= FCount) then
// Color index out of range
Error(sBadColorIndex);
dec(FCount);
if (Index < FCount) then
System.Move(FColorMap^[Index + 1], FColorMap^[Index], (FCount - Index)* sizeof(TGIFColor));
FOptimized := False;
Changed;
end;
function TGIFColorMap.GetColor(Index: integer): TColor;
begin
if (Index < 0) or (Index >= FCount) then
begin
// Color index out of range
Warning(gsWarning, sBadColorIndex);
// Raise an exception if the color map is empty
if (FCount = 0) then
Error(sEmptyColorMap);
// Default to color index 0
Index := 0;
end;
Result := RGB2Color(FColorMap^[Index]);
end;
procedure TGIFColorMap.SetColor(Index: integer; Value: TColor);
begin
if (Index < 0) or (Index >= FCount) then
// Color index out of range
Error(sBadColorIndex);
FColorMap^[Index] := Color2RGB(Value);
Changed;
end;
function TGIFColorMap.DoOptimize: boolean;
var
Usage : TColormapHistogram;
TempMap : array[0..255] of TGIFColor;
ReverseMap : TColormapReverse;
i : integer;
LastFound : boolean;
NewCount : integer;
T : TUsageCount;
Pivot : integer;
procedure QuickSort(iLo, iHi: Integer);
var
Lo, Hi: Integer;
begin
repeat
Lo := iLo;
Hi := iHi;
Pivot := Usage[(iLo + iHi) SHR 1].Count;
repeat
while (Usage[Lo].Count - Pivot > 0) do inc(Lo);
while (Usage[Hi].Count - Pivot < 0) do dec(Hi);
if (Lo <= Hi) then
begin
T := Usage[Lo];
Usage[Lo] := Usage[Hi];
Usage[Hi] := T;
inc(Lo);
dec(Hi);
end;
until (Lo > Hi);
if (iLo < Hi) then
QuickSort(iLo, Hi);
iLo := Lo;
until (Lo >= iHi);
end;
begin
if (FCount <= 1) then
begin
Result := False;
exit;
end;
FOptimized := True;
Result := True;
BuildHistogram(Usage);
(*
** Sort according to usage count
*)
QuickSort(0, FCount-1);
(*
** Test for table already sorted
*)
for i := 0 to FCount-1 do
if (Usage[i].Index <> i) then
break;
if (i = FCount) then
exit;
(*
** Build old to new map
*)
for i := 0 to FCount-1 do
ReverseMap[Usage[i].Index] := i;
MapImages(ReverseMap);
(*
** Reorder colormap
*)
LastFound := False;
NewCount := FCount;
Move(FColorMap^, TempMap, FCount * sizeof(TGIFColor));
for i := 0 to FCount-1 do
begin
FColorMap^[ReverseMap[i]] := TempMap[i];
// Find last used color index
if (Usage[i].Count = 0) and not(LastFound) then
begin
LastFound := True;
NewCount := i;
end;
end;
FCount := NewCount;
Changed;
end;
function TGIFColorMap.GetBitsPerPixel: integer;
begin
Result := Colors2bpp(FCount);
end;
//: Copies one color map to another.
procedure TGIFColorMap.Assign(Source: TPersistent);
begin
if (Source is TGIFColorMap) then
begin
Clear;
FCapacity := TGIFColorMap(Source).FCapacity;
FCount := TGIFColorMap(Source).FCount;
FOptimized := TGIFColorMap(Source).FOptimized;
FColorMap := AllocMem(FCapacity * sizeof(TGIFColor));
System.Move(TGIFColorMap(Source).FColorMap^, FColorMap^, FCount * sizeof(TGIFColor));
Changed;
end else
inherited Assign(Source);
end;
////////////////////////////////////////////////////////////////////////////////
//
// TGIFItem
//
////////////////////////////////////////////////////////////////////////////////
constructor TGIFItem.Create(GIFImage: TGIFImage);
begin
inherited Create;
FGIFImage := GIFImage;
end;
procedure TGIFItem.Warning(Severity: TGIFSeverity; Message: string);
begin
FGIFImage.Warning(self, Severity, Message);
end;
function TGIFItem.GetVersion: TGIFVersion;
begin
Result := gv87a;
end;
procedure TGIFItem.LoadFromFile(const Filename: string);
var
Stream: TStream;
begin
Stream := TFileStream.Create(Filename, fmOpenRead OR fmShareDenyWrite);
try
LoadFromStream(Stream);
finally
Stream.Free;
end;
end;
procedure TGIFItem.SaveToFile(const Filename: string);
var
Stream: TStream;
begin
Stream := TFileStream.Create(Filename, fmCreate);
try
SaveToStream(Stream);
finally
Stream.Free;
end;
end;
////////////////////////////////////////////////////////////////////////////////
//
// TGIFList
//
////////////////////////////////////////////////////////////////////////////////
constructor TGIFList.Create(Image: TGIFImage);
begin
inherited Create;
FImage := Image;
FItems := TList.Create;
end;
destructor TGIFList.Destroy;
begin
Clear;
FItems.Free;
inherited Destroy;
end;
function TGIFList.GetItem(Index: Integer): TGIFItem;
begin
Result := TGIFItem(FItems[Index]);
end;
procedure TGIFList.SetItem(Index: Integer; Item: TGIFItem);
begin
FItems[Index] := Item;
end;
function TGIFList.GetCount: Integer;
begin
Result := FItems.Count;
end;
function TGIFList.Add(Item: TGIFItem): Integer;
begin
Result := FItems.Add(Item);
end;
procedure TGIFList.Clear;
begin
while (FItems.Count > 0) do
Delete(0);
end;
procedure TGIFList.Delete(Index: Integer);
var
Item : TGIFItem;
begin
Item := TGIFItem(FItems[Index]);
// Delete before item is destroyed to avoid recursion
FItems.Delete(Index);
Item.Free;
end;
procedure TGIFList.Exchange(Index1, Index2: Integer);
begin
FItems.Exchange(Index1, Index2);
end;
function TGIFList.First: TGIFItem;
begin
Result := TGIFItem(FItems.First);
end;
function TGIFList.IndexOf(Item: TGIFItem): Integer;
begin
Result := FItems.IndexOf(Item);
end;
procedure TGIFList.Insert(Index: Integer; Item: TGIFItem);
begin
FItems.Insert(Index, Item);
end;
function TGIFList.Last: TGIFItem;
begin
Result := TGIFItem(FItems.Last);
end;
procedure TGIFList.Move(CurIndex, NewIndex: Integer);
begin
FItems.Move(CurIndex, NewIndex);
end;
function TGIFList.Remove(Item: TGIFItem): Integer;
begin
// Note: TGIFList.Remove must not destroy item
Result := FItems.Remove(Item);
end;
procedure TGIFList.SaveToStream(Stream: TStream);
var
i : integer;
begin
for i := 0 to FItems.Count-1 do
TGIFItem(FItems[i]).SaveToStream(Stream);
end;
procedure TGIFList.Warning(Severity: TGIFSeverity; Message: string);
begin
Image.Warning(self, Severity, Message);
end;
////////////////////////////////////////////////////////////////////////////////
//
// TGIFGlobalColorMap
//
////////////////////////////////////////////////////////////////////////////////
type
TGIFGlobalColorMap = class(TGIFColorMap)
private
FHeader : TGIFHeader;
protected
procedure Warning(Severity: TGIFSeverity; Message: string); override;
procedure BuildHistogram(var Histogram: TColormapHistogram); override;
procedure MapImages(var Map: TColormapReverse); override;
public
constructor Create(HeaderItem: TGIFHeader);
function Optimize: boolean; override;
procedure Changed; override;
end;
constructor TGIFGlobalColorMap.Create(HeaderItem: TGIFHeader);
begin
Inherited Create;
FHeader := HeaderItem;
end;
procedure TGIFGlobalColorMap.Warning(Severity: TGIFSeverity; Message: string);
begin
FHeader.Image.Warning(self, Severity, Message);
end;
procedure TGIFGlobalColorMap.BuildHistogram(var Histogram: TColormapHistogram);
var
Pixel ,
LastPixel : PChar;
i : integer;
begin
(*
** Init histogram
*)
for i := 0 to Count-1 do
begin
Histogram[i].Index := i;
Histogram[i].Count := 0;
end;
for i := 0 to FHeader.Image.Images.Count-1 do
if (FHeader.Image.Images[i].ActiveColorMap = self) then
begin
Pixel := FHeader.Image.Images[i].Data;
LastPixel := Pixel + FHeader.Image.Images[i].Width * FHeader.Image.Images[i].Height;
(*
** Sum up usage count for each color
*)
while (Pixel < LastPixel) do
begin
inc(Histogram[ord(Pixel^)].Count);
inc(Pixel);
end;
end;
end;
procedure TGIFGlobalColorMap.MapImages(var Map: TColormapReverse);
var
Pixel ,
LastPixel : PChar;
i : integer;
begin
for i := 0 to FHeader.Image.Images.Count-1 do
if (FHeader.Image.Images[i].ActiveColorMap = self) then
begin
Pixel := FHeader.Image.Images[i].Data;
LastPixel := Pixel + FHeader.Image.Images[i].Width * FHeader.Image.Images[i].Height;
(*
** Reorder all pixel to new map
*)
while (Pixel < LastPixel) do
begin
Pixel^ := chr(Map[ord(Pixel^)]);
inc(Pixel);
end;
(*
** Reorder transparent colors
*)
if (FHeader.Image.Images[i].Transparent) then
FHeader.Image.Images[i].GraphicControlExtension.TransparentColorIndex :=
Map[FHeader.Image.Images[i].GraphicControlExtension.TransparentColorIndex];
end;
end;
function TGIFGlobalColorMap.Optimize: boolean;
begin
{ Optimize with first image, Remove unused colors if only one image }
if (FHeader.Image.Images.Count > 0) then
Result := DoOptimize
else
Result := False;
end;
procedure TGIFGlobalColorMap.Changed;
begin
FHeader.Image.Palette := 0;
end;
////////////////////////////////////////////////////////////////////////////////
//
// TGIFHeader
//
////////////////////////////////////////////////////////////////////////////////
constructor TGIFHeader.Create(GIFImage: TGIFImage);
begin
inherited Create(GIFImage);
FColorMap := TGIFGlobalColorMap.Create(self);
Clear;
end;
destructor TGIFHeader.Destroy;
begin
FColorMap.Free;
inherited Destroy;
end;
procedure TGIFHeader.Clear;
begin
FColorMap.Clear;
FLogicalScreenDescriptor.ScreenWidth := 0;
FLogicalScreenDescriptor.ScreenHeight := 0;
FLogicalScreenDescriptor.PackedFields := 0;
FLogicalScreenDescriptor.BackgroundColorIndex := 0;
FLogicalScreenDescriptor.AspectRatio := 0;
end;
procedure TGIFHeader.Assign(Source: TPersistent);
begin
if (Source is TGIFHeader) then
begin
ColorMap.Assign(TGIFHeader(Source).ColorMap);
FLogicalScreenDescriptor := TGIFHeader(Source).FLogicalScreenDescriptor;
end else
if (Source is TGIFColorMap) then
begin
Clear;
ColorMap.Assign(TGIFColorMap(Source));
end else
inherited Assign(Source);
end;
type
TGIFHeaderRec = packed record
Signature: array[0..2] of char; { contains 'GIF' }
Version: TGIFVersionRec; { '87a' or '89a' }
end;
const
{ logical screen descriptor packed field masks }
lsdGlobalColorTable = $80; { set if global color table follows L.S.D. }
lsdColorResolution = $70; { Color resolution - 3 bits }
lsdSort = $08; { set if global color table is sorted - 1 bit }
lsdColorTableSize = $07; { size of global color table - 3 bits }
{ Actual size = 2^value+1 - value is 3 bits }
procedure TGIFHeader.Prepare;
var
pack : BYTE;
begin
Pack := $00;
if (ColorMap.Count > 0) then
begin
Pack := lsdGlobalColorTable;
if (ColorMap.Optimized) then
Pack := Pack OR lsdSort;
end;
// Note: The SHL below was SHL 5 in the original source, but that looks wrong
Pack := Pack OR ((Image.ColorResolution SHL 4) AND lsdColorResolution);
Pack := Pack OR ((Image.BitsPerPixel-1) AND lsdColorTableSize);
FLogicalScreenDescriptor.PackedFields := Pack;
end;
procedure TGIFHeader.SaveToStream(Stream: TStream);
var
GifHeader : TGIFHeaderRec;
v : TGIFVersion;
begin
v := Image.Version;
if (v = gvUnknown) then
Error(sBadVersion);
GifHeader.Signature := 'GIF';
GifHeader.Version := GIFVersions[v];
Prepare;
Stream.Write(GifHeader, sizeof(GifHeader));
Stream.Write(FLogicalScreenDescriptor, sizeof(FLogicalScreenDescriptor));
if (FLogicalScreenDescriptor.PackedFields AND lsdGlobalColorTable = lsdGlobalColorTable) then
ColorMap.SaveToStream(Stream);
end;
procedure TGIFHeader.LoadFromStream(Stream: TStream);
var
GifHeader : TGIFHeaderRec;
ColorCount : integer;
Position : integer;
begin
Position := Stream.Position;
ReadCheck(Stream, GifHeader, sizeof(GifHeader));
if (uppercase(GifHeader.Signature) <> 'GIF') then
begin
// Attempt recovery in case we are reading a GIF stored in a form by rxLib
Stream.Position := Position;
// Seek past size stored in stream
Stream.Seek(sizeof(longInt), soFromCurrent);
// Attempt to read signature again
ReadCheck(Stream, GifHeader, sizeof(GifHeader));
if (uppercase(GifHeader.Signature) <> 'GIF') then
Error(sBadSignature);
end;
ReadCheck(Stream, FLogicalScreenDescriptor, sizeof(FLogicalScreenDescriptor));
if (FLogicalScreenDescriptor.PackedFields AND lsdGlobalColorTable = lsdGlobalColorTable) then
begin
ColorCount := 2 SHL (FLogicalScreenDescriptor.PackedFields AND lsdColorTableSize);
if (ColorCount < 2) or (ColorCount > 256) then
Error(sScreenBadColorSize);
ColorMap.LoadFromStream(Stream, ColorCount)
end else
ColorMap.Clear;
end;
function TGIFHeader.GetVersion: TGIFVersion;
begin
if (FColorMap.Optimized) or (AspectRatio <> 0) then
Result := gv89a
else
Result := inherited GetVersion;
end;
function TGIFHeader.GetBackgroundColor: TColor;
begin
Result := FColorMap[BackgroundColorIndex];
end;
procedure TGIFHeader.SetBackgroundColor(Color: TColor);
begin
BackgroundColorIndex := FColorMap.AddUnique(Color);
end;
procedure TGIFHeader.SetBackgroundColorIndex(Index: BYTE);
begin
if ((Index >= FColorMap.Count) and (FColorMap.Count > 0)) then
begin
Warning(gsWarning, sBadColorIndex);
Index := 0;
end;
FLogicalScreenDescriptor.BackgroundColorIndex := Index;
end;
function TGIFHeader.GetBitsPerPixel: integer;
begin
Result := FColorMap.BitsPerPixel;
end;
function TGIFHeader.GetColorResolution: integer;
begin
Result := FColorMap.BitsPerPixel-1;
end;
////////////////////////////////////////////////////////////////////////////////
//
// TGIFLocalColorMap
//
////////////////////////////////////////////////////////////////////////////////
type
TGIFLocalColorMap = class(TGIFColorMap)
private
FSubImage : TGIFSubImage;
protected
procedure Warning(Severity: TGIFSeverity; Message: string); override;
procedure BuildHistogram(var Histogram: TColormapHistogram); override;
procedure MapImages(var Map: TColormapReverse); override;
public
constructor Create(SubImage: TGIFSubImage);
function Optimize: boolean; override;
procedure Changed; override;
end;
constructor TGIFLocalColorMap.Create(SubImage: TGIFSubImage);
begin
Inherited Create;
FSubImage := SubImage;
end;
procedure TGIFLocalColorMap.Warning(Severity: TGIFSeverity; Message: string);
begin
FSubImage.Image.Warning(self, Severity, Message);
end;
procedure TGIFLocalColorMap.BuildHistogram(var Histogram: TColormapHistogram);
var
Pixel ,
LastPixel : PChar;
i : integer;
begin
Pixel := FSubImage.Data;
LastPixel := Pixel + FSubImage.Width * FSubImage.Height;
(*
** Init histogram
*)
for i := 0 to Count-1 do
begin
Histogram[i].Index := i;
Histogram[i].Count := 0;
end;
(*
** Sum up usage count for each color
*)
while (Pixel < LastPixel) do
begin
inc(Histogram[ord(Pixel^)].Count);
inc(Pixel);
end;
end;
procedure TGIFLocalColorMap.MapImages(var Map: TColormapReverse);
var
Pixel ,
LastPixel : PChar;
begin
Pixel := FSubImage.Data;
LastPixel := Pixel + FSubImage.Width * FSubImage.Height;
(*
** Reorder all pixel to new map
*)
while (Pixel < LastPixel) do
begin
Pixel^ := chr(Map[ord(Pixel^)]);
inc(Pixel);
end;
(*
** Reorder transparent colors
*)
if (FSubImage.Transparent) then
FSubImage.GraphicControlExtension.TransparentColorIndex :=
Map[FSubImage.GraphicControlExtension.TransparentColorIndex];
end;
function TGIFLocalColorMap.Optimize: boolean;
begin
Result := DoOptimize;
end;
procedure TGIFLocalColorMap.Changed;
begin
FSubImage.Palette := 0;
end;
////////////////////////////////////////////////////////////////////////////////
//
// LZW Decoder
//
////////////////////////////////////////////////////////////////////////////////
const
GIFCodeBits = 12; // Max number of bits per GIF token code
GIFCodeMax = (1 SHL GIFCodeBits)-1;// Max GIF token code
// 12 bits = 4095
StackSize = (2 SHL GIFCodeBits); // Size of decompression stack
TableSize = (1 SHL GIFCodeBits); // Size of decompression table
procedure TGIFSubImage.Decompress(Stream: TStream);
var
table0 : array[0..TableSize-1] of integer;
table1 : array[0..TableSize-1] of integer;
firstcode, oldcode : integer;
buf : array[0..257] of BYTE;
Dest : PChar;
v ,
xpos, ypos, pass : integer;
stack : array[0..StackSize-1] of integer;
Source : ^integer;
BitsPerCode : integer; // number of CodeTableBits/code
InitialBitsPerCode : BYTE;
MaxCode : integer; // maximum code, given BitsPerCode
MaxCodeSize : integer;
ClearCode : integer; // Special code to signal "Clear table"
EOFCode : integer; // Special code to signal EOF
step : integer;
i : integer;
StartBit , // Index of bit buffer start
LastBit , // Index of last bit in buffer
LastByte : integer; // Index of last byte in buffer
get_done ,
return_clear ,
ZeroBlock : boolean;
ClearValue : BYTE;
{$ifdef DEBUG_DECOMPRESSPERFORMANCE}
TimeStartDecompress ,
TimeStopDecompress : DWORD;
{$endif}
function nextCode(BitsPerCode: integer): integer;
const
masks: array[0..15] of integer =
($0000, $0001, $0003, $0007,
$000f, $001f, $003f, $007f,
$00ff, $01ff, $03ff, $07ff,
$0fff, $1fff, $3fff, $7fff);
var
StartIndex, EndIndex : integer;
ret : integer;
EndBit : integer;
count : BYTE;
begin
if (return_clear) then
begin
return_clear := False;
Result := ClearCode;
exit;
end;
EndBit := StartBit + BitsPerCode;
if (EndBit >= LastBit) then
begin
if (get_done) then
begin
if (StartBit >= LastBit) then
Warning(gsWarning, sDecodeTooFewBits);
Result := -1;
exit;
end;
buf[0] := buf[LastByte-2];
buf[1] := buf[LastByte-1];
if (Stream.Read(count, 1) <> 1) then
begin
Result := -1;
exit;
end;
if (count = 0) then
begin
ZeroBlock := True;
get_done := TRUE;
end else
begin
// Handle premature end of file
if (Stream.Size - Stream.Position < Count) then
begin
Warning(gsWarning, sOutOfData);
// Not enough data left - Just read as much as we can get
Count := Stream.Size - Stream.Position;
end;
if (Count <> 0) then
ReadCheck(Stream, Buf[2], Count);
end;
LastByte := 2 + count;
StartBit := (StartBit - LastBit) + 16;
LastBit := LastByte * 8;
EndBit := StartBit + BitsPerCode;
end;
EndIndex := EndBit DIV 8;
StartIndex := StartBit DIV 8;
ASSERT(StartIndex <= high(buf), 'StartIndex too large');
if (StartIndex = EndIndex) then
ret := buf[StartIndex]
else
if (StartIndex + 1 = EndIndex) then
ret := buf[StartIndex] OR (buf[StartIndex+1] SHL 8)
else
ret := buf[StartIndex] OR (buf[StartIndex+1] SHL 8) OR (buf[StartIndex+2] SHL 16);
ret := (ret SHR (StartBit AND $0007)) AND masks[BitsPerCode];
Inc(StartBit, BitsPerCode);
Result := ret;
end;
function NextLZW: integer;
var
code, incode : integer;
i : integer;
b : BYTE;
begin
code := nextCode(BitsPerCode);
while (code >= 0) do
begin
if (code = ClearCode) then
begin
ASSERT(ClearCode < TableSize, 'ClearCode too large');
for i := 0 to ClearCode-1 do
begin
table0[i] := 0;
table1[i] := i;
end;
for i := ClearCode to TableSize-1 do
begin
table0[i] := 0;
table1[i] := 0;
end;
BitsPerCode := InitialBitsPerCode+1;
MaxCodeSize := 2 * ClearCode;
MaxCode := ClearCode + 2;
Source := @stack;
repeat
firstcode := nextCode(BitsPerCode);
oldcode := firstcode;
until (firstcode <> ClearCode);
Result := firstcode;
exit;
end;
if (code = EOFCode) then
begin
Result := -2;
if (ZeroBlock) then
exit;
// Eat rest of data blocks
if (Stream.Read(b, 1) <> 1) then
exit;
while (b <> 0) do
begin
Stream.Seek(b, soFromCurrent);
if (Stream.Read(b, 1) <> 1) then
exit;
end;
exit;
end;
incode := code;
if (code >= MaxCode) then
begin
Source^ := firstcode;
Inc(Source);
code := oldcode;
end;
ASSERT(Code < TableSize, 'Code too large');
while (code >= ClearCode) do
begin
Source^ := table1[code];
Inc(Source);
if (code = table0[code]) then
Error(sDecodeCircular);
code := table0[code];
ASSERT(Code < TableSize, 'Code too large');
end;
firstcode := table1[code];
Source^ := firstcode;
Inc(Source);
code := MaxCode;
if (code <= GIFCodeMax) then
begin
table0[code] := oldcode;
table1[code] := firstcode;
Inc(MaxCode);
if ((MaxCode >= MaxCodeSize) and (MaxCodeSize <= GIFCodeMax)) then
begin
MaxCodeSize := MaxCodeSize * 2;
Inc(BitsPerCode);
end;
end;
oldcode := incode;
if (longInt(Source) > longInt(@stack)) then
begin
Dec(Source);
Result := Source^;
exit;
end
end;
Result := code;
end;
function readLZW: integer;
begin
if (longInt(Source) > longInt(@stack)) then
begin
Dec(Source);
Result := Source^;
end else
Result := NextLZW;
end;
begin
NewImage;
// Clear image data in case decompress doesn't complete
if (Transparent) then
// Clear to transparent color
ClearValue := GraphicControlExtension.GetTransparentColorIndex
else
// Clear to first color
ClearValue := 0;
FillChar(FData^, FDataSize, ClearValue);
{$ifdef DEBUG_DECOMPRESSPERFORMANCE}
TimeStartDecompress := timeGetTime;
{$endif}
(*
** Read initial code size in bits from stream
*)
if (Stream.Read(InitialBitsPerCode, 1) <> 1) then
exit;
(*
** Initialize the Compression routines
*)
BitsPerCode := InitialBitsPerCode + 1;
ClearCode := 1 SHL InitialBitsPerCode;
EOFCode := ClearCode + 1;
MaxCodeSize := 2 * ClearCode;
MaxCode := ClearCode + 2;
StartBit := 0;
LastBit := 0;
LastByte := 2;
ZeroBlock := False;
get_done := False;
return_clear := TRUE;
Source := @stack;
try
if (Interlaced) then
begin
ypos := 0;
pass := 0;
step := 8;
for i := 0 to Height-1 do
begin
Dest := FData + Width * ypos;
for xpos := 0 to width-1 do
begin
v := readLZW;
if (v < 0) then
exit;
Dest^ := char(v);
Inc(Dest);
end;
Inc(ypos, step);
if (ypos >= height) then
repeat
if (pass > 0) then
step := step DIV 2;
Inc(pass);
ypos := step DIV 2;
until (ypos < height);
end;
end else
begin
Dest := FData;
for ypos := 0 to (height * width)-1 do
begin
v := readLZW;
if (v < 0) then
exit;
Dest^ := char(v);
Inc(Dest);
end;
end;
finally
if (readLZW >= 0) then
;
// raise GIFException.Create('Too much input data, ignoring extra...');
end;
{$ifdef DEBUG_DECOMPRESSPERFORMANCE}
TimeStopDecompress := timeGetTime;
ShowMessage(format('Decompressed %d pixels in %d mS, Rate %d pixels/mS',
[Height*Width, TimeStopDecompress-TimeStartDecompress,
(Height*Width) DIV (TimeStopDecompress-TimeStartDecompress+1)]));
{$endif}
end;
////////////////////////////////////////////////////////////////////////////////
//
// LZW Encoder stuff
//
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// LZW Encoder THashTable
////////////////////////////////////////////////////////////////////////////////
const
HashKeyBits = 13; // Max number of bits per Hash Key
HashSize = 8009; // Size of hash table
// Must be prime
// Must be > than HashMaxCode
// Must be < than HashMaxKey
HashKeyMax = (1 SHL HashKeyBits)-1;// Max hash key value
// 13 bits = 8191
HashKeyMask = HashKeyMax; // $1FFF
GIFCodeMask = GIFCodeMax; // $0FFF
HashEmpty = $000FFFFF; // 20 bits
type
// A Hash Key is 20 bits wide.
// - The lower 8 bits are the postfix character (the new pixel).
// - The upper 12 bits are the prefix code (the GIF token).
// A KeyInt must be able to represent the integer values -1..(2^20)-1
KeyInt = longInt; // 32 bits
CodeInt = SmallInt; // 16 bits
THashArray = array[0..HashSize-1] of KeyInt;
PHashArray = ^THashArray;
THashTable = class
{$ifdef DEBUG_HASHPERFORMANCE}
CountLookupFound : longInt;
CountMissFound : longInt;
CountLookupNotFound : longInt;
CountMissNotFound : longInt;
{$endif}
HashTable: PHashArray;
public
constructor Create;
destructor Destroy; override;
procedure Clear;
procedure Insert(Key: KeyInt; Code: CodeInt);
function Lookup(Key: KeyInt): CodeInt;
end;
function HashKey(Key: KeyInt): CodeInt;
begin
Result := ((Key SHR (GIFCodeBits-8)) XOR Key) MOD HashSize;
end;
function NextHashKey(HKey: CodeInt): CodeInt;
var
disp : CodeInt;
begin
(*
** secondary hash (after G. Knott)
*)
disp := HashSize - HKey;
if (HKey = 0) then
disp := 1;
// disp := 13; // disp should be prime relative to HashSize, but
// it doesn't seem to matter here...
dec(HKey, disp);
if (HKey < 0) then
inc(HKey, HashSize);
Result := HKey;
end;
constructor THashTable.Create;
begin
ASSERT(longInt($FFFFFFFF) = -1, 'TGIFImage implementation assumes $FFFFFFFF = -1');
inherited Create;
GetMem(HashTable, sizeof(THashArray));
Clear;
{$ifdef DEBUG_HASHPERFORMANCE}
CountLookupFound := 0;
CountMissFound := 0;
CountLookupNotFound := 0;
CountMissNotFound := 0;
{$endif}
end;
destructor THashTable.Destroy;
begin
{$ifdef DEBUG_HASHPERFORMANCE}
ShowMessage(
Format('Found: %d HitRate: %.2f',
[CountLookupFound, (CountLookupFound+1)/(CountMissFound+1)])+#13+
Format('Not found: %d HitRate: %.2f',
[CountLookupNotFound, (CountLookupNotFound+1)/(CountMissNotFound+1)]));
{$endif}
FreeMem(HashTable);
inherited Destroy;
end;
// Clear hash table and fill with empty slots (doh!)
procedure THashTable.Clear;
{$ifdef DEBUG_HASHFILLFACTOR}
var
i ,
Count : longInt;
{$endif}
begin
{$ifdef DEBUG_HASHFILLFACTOR}
Count := 0;
for i := 0 to HashSize-1 do
if (HashTable[i] SHR GIFCodeBits <> HashEmpty) then
inc(Count);
ShowMessage(format('Size: %d, Filled: %d, Rate %.4f',
[HashSize, Count, Count/HashSize]));
{$endif}
FillChar(HashTable^, sizeof(THashArray), $FF);
end;
// Insert new key/value pair into hash table
procedure THashTable.Insert(Key: KeyInt; Code: CodeInt);
var
HKey : CodeInt;
begin
// Create hash key from prefix string
HKey := HashKey(Key);
// Scan for empty slot
// while (HashTable[HKey] SHR GIFCodeBits <> HashEmpty) do { Unoptimized }
while (HashTable[HKey] AND (HashEmpty SHL GIFCodeBits) <> (HashEmpty SHL GIFCodeBits)) do { Optimized }
HKey := NextHashKey(HKey);
// Fill slot with key/value pair
HashTable[HKey] := (Key SHL GIFCodeBits) OR (Code AND GIFCodeMask);
end;
// Search for key in hash table.
// Returns value if found or -1 if not
function THashTable.Lookup(Key: KeyInt): CodeInt;
var
HKey : CodeInt;
HTKey : KeyInt;
{$ifdef DEBUG_HASHPERFORMANCE}
n : LongInt;
{$endif}
begin
// Create hash key from prefix string
HKey := HashKey(Key);
{$ifdef DEBUG_HASHPERFORMANCE}
n := 0;
{$endif}
// Scan table for key
// HTKey := HashTable[HKey] SHR GIFCodeBits; { Unoptimized }
Key := Key SHL GIFCodeBits; { Optimized }
HTKey := HashTable[HKey] AND (HashEmpty SHL GIFCodeBits); { Optimized }
// while (HTKey <> HashEmpty) do { Unoptimized }
while (HTKey <> HashEmpty SHL GIFCodeBits) do { Optimized }
begin
if (Key = HTKey) then
begin
// Extract and return value
Result := HashTable[HKey] AND GIFCodeMask;
{$ifdef DEBUG_HASHPERFORMANCE}
inc(CountLookupFound);
inc(CountMissFound, n);
{$endif}
exit;
end;
{$ifdef DEBUG_HASHPERFORMANCE}
inc(n);
{$endif}
// Try next slot
HKey := NextHashKey(HKey);
// HTKey := HashTable[HKey] SHR GIFCodeBits; { Unoptimized }
HTKey := HashTable[HKey] AND (HashEmpty SHL GIFCodeBits); { Optimized }
end;
// Found empty slot - key doesn't exist
Result := -1;
{$ifdef DEBUG_HASHPERFORMANCE}
inc(CountLookupNotFound);
inc(CountMissNotFound, n);
{$endif}
end;
////////////////////////////////////////////////////////////////////////////////
// TGIFStream - Abstract GIF block stream
//
// Descendants from TGIFStream either reads or writes data in blocks
// of up to 255 bytes. These blocks are organized as a leading byte
// containing the number of bytes in the block (exclusing the count
// byte itself), followed by the data (up to 254 bytes of data).
////////////////////////////////////////////////////////////////////////////////
type
TGIFStream = class(TStream)
private
FOnWarning : TGIFWarning;
FStream : TStream;
FOnProgress : TNotifyEvent;
FBuffer : array [BYTE] of Char;
FBufferCount : integer;
protected
constructor Create(Stream: TStream);
function Read(var Buffer; Count: Longint): Longint; override;
function Write(const Buffer; Count: Longint): Longint; override;
function Seek(Offset: Longint; Origin: Word): Longint; override;
procedure Progress(Sender: TObject); dynamic;
property OnProgress: TNotifyEvent read FOnProgress write FOnProgress;
public
property Warning: TGIFWarning read FOnWarning write FOnWarning;
end;
constructor TGIFStream.Create(Stream: TStream);
begin
inherited Create;
FStream := Stream;
FBufferCount := 1; // Reserve first byte of buffer for length
end;
procedure TGIFStream.Progress(Sender: TObject);
begin
if Assigned(FOnProgress) then
FOnProgress(Sender);
end;
function TGIFStream.Write(const Buffer; Count: Longint): Longint;
begin
raise Exception.Create(sInvalidStream);
end;
function TGIFStream.Read(var Buffer; Count: Longint): Longint;
begin
raise Exception.Create(sInvalidStream);
end;
function TGIFStream.Seek(Offset: Longint; Origin: Word): Longint;
begin
raise Exception.Create(sInvalidStream);
end;
////////////////////////////////////////////////////////////////////////////////
// TGIFReader - GIF block reader
////////////////////////////////////////////////////////////////////////////////
type
TGIFReader = class(TGIFStream)
public
constructor Create(Stream: TStream);
function Read(var Buffer; Count: Longint): Longint; override;
end;
constructor TGIFReader.Create(Stream: TStream);
begin
inherited Create(Stream);
FBufferCount := 0;
end;
function TGIFReader.Read(var Buffer; Count: Longint): Longint;
var
n : integer;
Dst : PChar;
size : BYTE;
begin
Dst := @Buffer;
Result := 0;
while (Count > 0) do
begin
// Get data from buffer
while (FBufferCount > 0) and (Count > 0) do
begin
if (FBufferCount > Count) then
n := Count
else
n := FBufferCount;
Move(FBuffer, Dst^, n);
dec(FBufferCount, n);
dec(Count, n);
inc(Result, n);
inc(Dst, n);
end;
// Refill buffer when it becomes empty
if (FBufferCount <= 0) then
begin
FStream.Read(size, 1);
{ TODO -oanme -cImprovement : Should be handled as a warning instead of an error. }
if (size >= 255) then
Error('GIF block too large');
FBufferCount := size;
if (FBufferCount > 0) then
begin
n := FStream.Read(FBuffer, size);
if (n = FBufferCount) then
begin
Warning(self, gsWarning, sOutOfData);
break;
end;
end else
break;
end;
end;
end;
////////////////////////////////////////////////////////////////////////////////
// TGIFWriter - GIF block writer
////////////////////////////////////////////////////////////////////////////////
type
TGIFWriter = class(TGIFStream)
private
FOutputDirty : boolean;
protected
procedure FlushBuffer;
public
constructor Create(Stream: TStream);
destructor Destroy; override;
function Write(const Buffer; Count: Longint): Longint; override;
function WriteByte(Value: BYTE): Longint;
end;
constructor TGIFWriter.Create(Stream: TStream);
begin
inherited Create(Stream);
FBufferCount := 1; // Reserve first byte of buffer for length
FOutputDirty := False;
end;
destructor TGIFWriter.Destroy;
begin
inherited Destroy;
if (FOutputDirty) then
FlushBuffer;
end;
procedure TGIFWriter.FlushBuffer;
begin
if (FBufferCount <= 0) then
exit;
FBuffer[0] := char(FBufferCount-1); // Block size excluding the count
FStream.WriteBuffer(FBuffer, FBufferCount);
FBufferCount := 1; // Reserve first byte of buffer for length
FOutputDirty := False;
end;
function TGIFWriter.Write(const Buffer; Count: Longint): Longint;
var
n : integer;
Src : PChar;
begin
Result := Count;
FOutputDirty := True;
Src := @Buffer;
while (Count > 0) do
begin
// Move data to the internal buffer in 255 byte chunks
while (FBufferCount < sizeof(FBuffer)) and (Count > 0) do
begin
n := sizeof(FBuffer) - FBufferCount;
if (n > Count) then
n := Count;
Move(Src^, FBuffer[FBufferCount], n);
inc(Src, n);
inc(FBufferCount, n);
dec(Count, n);
end;
// Flush the buffer when it is full
if (FBufferCount >= sizeof(FBuffer)) then
FlushBuffer;
end;
end;
function TGIFWriter.WriteByte(Value: BYTE): Longint;
begin
Result := Write(Value, 1);
end;
////////////////////////////////////////////////////////////////////////////////
// TGIFEncoder - Abstract encoder
////////////////////////////////////////////////////////////////////////////////
type
TGIFEncoder = class(TObject)
protected
FOnWarning : TGIFWarning;
MaxColor : integer;
BitsPerPixel : BYTE; // Bits per pixel of image
Stream : TStream; // Output stream
Width , // Width of image in pixels
Height : integer; // height of image in pixels
Interlace : boolean; // Interlace flag (True = interlaced image)
Data : PChar; // Pointer to pixel data
GIFStream : TGIFWriter; // Output buffer
OutputBucket : longInt; // Output bit bucket
OutputBits : integer; // Current # of bits in bucket
ClearFlag : Boolean; // True if dictionary has just been cleared
BitsPerCode , // Current # of bits per code
InitialBitsPerCode : integer; // Initial # of bits per code after
// dictionary has been cleared
MaxCode : CodeInt; // maximum code, given BitsPerCode
ClearCode : CodeInt; // Special output code to signal "Clear table"
EOFCode : CodeInt; // Special output code to signal EOF
BaseCode : CodeInt; // ...
Pixel : PChar; // Pointer to current pixel
cX , // Current X counter (Width - X)
Y : integer; // Current Y
Pass : integer; // Interlace pass
function MaxCodesFromBits(Bits: integer): CodeInt;
procedure Output(Value: integer); virtual;
procedure Clear; virtual;
function BumpPixel: boolean;
procedure DoCompress; virtual; abstract;
public
procedure Compress(AStream: TStream; ABitsPerPixel: integer;
AWidth, AHeight: integer; AInterlace: boolean; AData: PChar; AMaxColor: integer);
property Warning: TGIFWarning read FOnWarning write FOnWarning;
end;
// Calculate the maximum number of codes that a given number of bits can represent
// MaxCodes := (1^bits)-1
function TGIFEncoder.MaxCodesFromBits(Bits: integer): CodeInt;
begin
Result := (CodeInt(1) SHL Bits) - 1;
end;
// Stuff bits (variable sized codes) into a buffer and output them
// a byte at a time
procedure TGIFEncoder.Output(Value: integer);
const
BitBucketMask: array[0..16] of longInt =
($0000,
$0001, $0003, $0007, $000F,
$001F, $003F, $007F, $00FF,
$01FF, $03FF, $07FF, $0FFF,
$1FFF, $3FFF, $7FFF, $FFFF);
begin
if (OutputBits > 0) then
OutputBucket :=
(OutputBucket AND BitBucketMask[OutputBits]) OR (longInt(Value) SHL OutputBits)
else
OutputBucket := Value;
inc(OutputBits, BitsPerCode);
while (OutputBits >= 8) do
begin
GIFStream.WriteByte(OutputBucket AND $FF);
OutputBucket := OutputBucket SHR 8;
dec(OutputBits, 8);
end;
if (Value = EOFCode) then
begin
// At EOF, write the rest of the buffer.
while (OutputBits > 0) do
begin
GIFStream.WriteByte(OutputBucket AND $FF);
OutputBucket := OutputBucket SHR 8;
dec(OutputBits, 8);
end;
end;
end;
procedure TGIFEncoder.Clear;
begin
// just_cleared = 1;
ClearFlag := TRUE;
Output(ClearCode);
end;
// Bump (X,Y) and data pointer to point to the next pixel
function TGIFEncoder.BumpPixel: boolean;
begin
// Bump the current X position
dec(cX);
// If we are at the end of a scan line, set cX back to the beginning
// If we are interlaced, bump Y to the appropriate spot, otherwise,
// just increment it.
if (cX <= 0) then
begin
if not(Interlace) then
begin
// Done - no more data
Result := False;
exit;
end;
cX := Width;
case (Pass) of
0:
begin
inc(Y, 8);
if (Y >= Height) then
begin
inc(Pass);
Y := 4;
end;
end;
1:
begin
inc(Y, 8);
if (Y >= Height) then
begin
inc(Pass);
Y := 2;
end;
end;
2:
begin
inc(Y, 4);
if (Y >= Height) then
begin
inc(Pass);
Y := 1;
end;
end;
3:
inc(Y, 2);
end;
if (Y >= height) then
begin
// Done - No more data
Result := False;
exit;
end;
Pixel := Data + (Y * Width);
end;
Result := True;
end;
procedure TGIFEncoder.Compress(AStream: TStream; ABitsPerPixel: integer;
AWidth, AHeight: integer; AInterlace: boolean; AData: PChar; AMaxColor: integer);
const
EndBlockByte = $00; // End of block marker
{$ifdef DEBUG_COMPRESSPERFORMANCE}
var
TimeStartCompress ,
TimeStopCompress : DWORD;
{$endif}
begin
MaxColor := AMaxColor;
Stream := AStream;
BitsPerPixel := ABitsPerPixel;
Width := AWidth;
Height := AHeight;
Interlace := AInterlace;
Data := AData;
if (BitsPerPixel <= 1) then
BitsPerPixel := 2;
InitialBitsPerCode := BitsPerPixel + 1;
Stream.Write(BitsPerPixel, 1);
// out_bits_init = init_bits;
BitsPerCode := InitialBitsPerCode;
MaxCode := MaxCodesFromBits(BitsPerCode);
ClearCode := (1 SHL (InitialBitsPerCode - 1));
EOFCode := ClearCode + 1;
BaseCode := EOFCode + 1;
// Clear bit bucket
OutputBucket := 0;
OutputBits := 0;
// Reset pixel counter
if (Interlace) then
cX := Width
else
cX := Width*Height;
// Reset row counter
Y := 0;
Pass := 0;
GIFStream := TGIFWriter.Create(AStream);
try
GIFStream.Warning := Warning;
if (Data <> nil) and (Height > 0) and (Width > 0) then
begin
{$ifdef DEBUG_COMPRESSPERFORMANCE}
TimeStartCompress := timeGetTime;
{$endif}
// Call compress implementation
DoCompress;
{$ifdef DEBUG_COMPRESSPERFORMANCE}
TimeStopCompress := timeGetTime;
ShowMessage(format('Compressed %d pixels in %d mS, Rate %d pixels/mS',
[Height*Width, TimeStopCompress-TimeStartCompress,
DWORD(Height*Width) DIV (TimeStopCompress-TimeStartCompress+1)]));
{$endif}
// Output the final code.
Output(EOFCode);
end else
// Output the final code (and nothing else).
TGIFEncoder(self).Output(EOFCode);
finally
GIFStream.Free;
end;
WriteByte(Stream, EndBlockByte);
end;
////////////////////////////////////////////////////////////////////////////////
// TRLEEncoder - RLE encoder
////////////////////////////////////////////////////////////////////////////////
type
TRLEEncoder = class(TGIFEncoder)
private
MaxCodes : integer;
OutBumpInit ,
OutClearInit : integer;
Prefix : integer; // Current run color
RunLengthTableMax ,
RunLengthTablePixel ,
OutCount ,
OutClear ,
OutBump : integer;
protected
function ComputeTriangleCount(count: integer; nrepcodes: integer): integer;
procedure MaxOutClear;
procedure ResetOutClear;
procedure FlushFromClear(Count: integer);
procedure FlushClearOrRepeat(Count: integer);
procedure FlushWithTable(Count: integer);
procedure Flush(RunLengthCount: integer);
procedure OutputPlain(Value: integer);
procedure Clear; override;
procedure DoCompress; override;
end;
procedure TRLEEncoder.Clear;
begin
OutBump := OutBumpInit;
OutClear := OutClearInit;
OutCount := 0;
RunLengthTableMax := 0;
inherited Clear;
BitsPerCode := InitialBitsPerCode;
end;
procedure TRLEEncoder.OutputPlain(Value: integer);
begin
ClearFlag := False;
Output(Value);
inc(OutCount);
if (OutCount >= OutBump) then
begin
inc(BitsPerCode);
inc(OutBump, 1 SHL (BitsPerCode - 1));
end;
if (OutCount >= OutClear) then
Clear;
end;
function TRLEEncoder.ComputeTriangleCount(count: integer; nrepcodes: integer): integer;
var
PerRepeat : integer;
n : integer;
function iSqrt(x: integer): integer;
var
r, v : integer;
begin
if (x < 2) then
begin
Result := x;
exit;
end else
begin
v := x;
r := 1;
while (v > 0) do
begin
v := v DIV 4;
r := r * 2;
end;
end;
while (True) do
begin
v := ((x DIV r) + r) DIV 2;
if ((v = r) or (v = r+1)) then
begin
Result := r;
exit;
end;
r := v;
end;
end;
begin
Result := 0;
PerRepeat := (nrepcodes * (nrepcodes+1)) DIV 2;
while (Count >= PerRepeat) do
begin
inc(Result, nrepcodes);
dec(Count, PerRepeat);
end;
if (Count > 0) then
begin
n := iSqrt(Count);
while ((n * (n+1)) >= 2*Count) do
dec(n);
while ((n * (n+1)) < 2*Count) do
inc(n);
inc(Result, n);
end;
end;
procedure TRLEEncoder.MaxOutClear;
begin
OutClear := MaxCodes;
end;
procedure TRLEEncoder.ResetOutClear;
begin
OutClear := OutClearInit;
if (OutCount >= OutClear) then
Clear;
end;
procedure TRLEEncoder.FlushFromClear(Count: integer);
var
n : integer;
begin
MaxOutClear;
RunLengthTablePixel := Prefix;
n := 1;
while (Count > 0) do
begin
if (n = 1) then
begin
RunLengthTableMax := 1;
OutputPlain(Prefix);
dec(Count);
end else
if (Count >= n) then
begin
RunLengthTableMax := n;
OutputPlain(BaseCode + n - 2);
dec(Count, n);
end else
if (Count = 1) then
begin
inc(RunLengthTableMax);
OutputPlain(Prefix);
break;
end else
begin
inc(RunLengthTableMax);
OutputPlain(BaseCode + Count - 2);
break;
end;
if (OutCount = 0) then
n := 1
else
inc(n);
end;
ResetOutClear;
end;
procedure TRLEEncoder.FlushClearOrRepeat(Count: integer);
var
WithClear : integer;
begin
WithClear := 1 + ComputeTriangleCount(Count, MaxCodes);
if (WithClear < Count) then
begin
Clear;
FlushFromClear(Count);
end else
while (Count > 0) do
begin
OutputPlain(Prefix);
dec(Count);
end;
end;
procedure TRLEEncoder.FlushWithTable(Count: integer);
var
RepeatMax ,
RepeatLeft ,
LeftOver : integer;
begin
RepeatMax := Count DIV RunLengthTableMax;
LeftOver := Count MOD RunLengthTableMax;
if (LeftOver <> 0) then
RepeatLeft := 1
else
RepeatLeft := 0;
if (OutCount + RepeatMax + RepeatLeft > MaxCodes) then
begin
RepeatMax := MaxCodes - OutCount;
LeftOver := Count - (RepeatMax * RunLengthTableMax);
RepeatLeft := 1 + ComputeTriangleCount(LeftOver, MaxCodes);
end;
if (1 + ComputeTriangleCount(Count, MaxCodes) < RepeatMax + RepeatLeft) then
begin
Clear;
FlushFromClear(Count);
exit;
end;
MaxOutClear;
while (RepeatMax > 0) do
begin
OutputPlain(BaseCode + RunLengthTableMax-2);
dec(RepeatMax);
end;
if (LeftOver > 0) then
begin
if (ClearFlag) then
FlushFromClear(LeftOver)
else if (LeftOver = 1) then
OutputPlain(Prefix)
else
OutputPlain(BaseCode + LeftOver - 2);
end;
ResetOutClear;
end;
procedure TRLEEncoder.Flush(RunLengthCount: integer);
begin
if (RunLengthCount = 1) then
begin
OutputPlain(Prefix);
exit;
end;
if (ClearFlag) then
FlushFromClear(RunLengthCount)
else if ((RunLengthTableMax < 2) or (RunLengthTablePixel <> Prefix)) then
FlushClearOrRepeat(RunLengthCount)
else
FlushWithTable(RunLengthCount);
end;
procedure TRLEEncoder.DoCompress;
var
Color : CodeInt;
RunLengthCount : integer;
begin
OutBumpInit := ClearCode - 1;
// For images with a lot of runs, making OutClearInit larger will
// give better compression.
if (BitsPerPixel <= 3) then
OutClearInit := 9
else
OutClearInit := OutBumpInit - 1;
// max_ocodes = (1 << GIFBITS) - ((1 << (out_bits_init - 1)) + 3);
// <=> MaxCodes := (1 SHL GIFCodeBits) - ((1 SHL (BitsPerCode - 1)) + 3);
// <=> MaxCodes := (1 SHL GIFCodeBits) - ((1 SHL (InitialBitsPerCode - 1)) + 3);
// <=> MaxCodes := (1 SHL GIFCodeBits) - (ClearCode + 3);
// <=> MaxCodes := (1 SHL GIFCodeBits) - (EOFCode + 2);
// <=> MaxCodes := (1 SHL GIFCodeBits) - (BaseCode + 1);
// <=> MaxCodes := MaxCodesFromBits(GIFCodeBits) - BaseCode;
MaxCodes := MaxCodesFromBits(GIFCodeBits) - BaseCode;
Clear;
RunLengthCount := 0;
Pixel := Data;
Prefix := -1; // Dummy value to make Color <> Prefix
repeat
// Fetch the next pixel
Color := CodeInt(Pixel^);
inc(Pixel);
if (Color >= MaxColor) then
Error(sInvalidColor);
if (RunLengthCount > 0) and (Color <> Prefix) then
begin
// End of current run
Flush(RunLengthCount);
RunLengthCount := 0;
end;
if (Color = Prefix) then
// Increment run length
inc(RunLengthCount)
else
begin
// Start new run
Prefix := Color;
RunLengthCount := 1;
end;
until not(BumpPixel);
Flush(RunLengthCount);
end;
////////////////////////////////////////////////////////////////////////////////
// TLZWEncoder - LZW encoder
////////////////////////////////////////////////////////////////////////////////
const
TableMaxMaxCode = (1 SHL GIFCodeBits); //
TableMaxFill = TableMaxMaxCode-1; // Clear table when it fills to
// this point.
// Note: Must be <= GIFCodeMax
type
TLZWEncoder = class(TGIFEncoder)
private
Prefix : CodeInt; // Current run color
FreeEntry : CodeInt; // next unused code in table
HashTable : THashTable;
protected
procedure Output(Value: integer); override;
procedure Clear; override;
procedure DoCompress; override;
end;
procedure TLZWEncoder.Output(Value: integer);
begin
inherited Output(Value);
// If the next entry is going to be too big for the code size,
// then increase it, if possible.
if (FreeEntry > MaxCode) or (ClearFlag) then
begin
if (ClearFlag) then
begin
BitsPerCode := InitialBitsPerCode;
MaxCode := MaxCodesFromBits(BitsPerCode);
ClearFlag := False;
end else
begin
inc(BitsPerCode);
if (BitsPerCode = GIFCodeBits) then
MaxCode := TableMaxMaxCode
else
MaxCode := MaxCodesFromBits(BitsPerCode);
end;
end;
end;
procedure TLZWEncoder.Clear;
begin
inherited Clear;
HashTable.Clear;
FreeEntry := ClearCode + 2;
end;
procedure TLZWEncoder.DoCompress;
var
Color : char;
NewKey : KeyInt;
NewCode : CodeInt;
begin
HashTable := THashTable.Create;
try
// clear hash table and sync decoder
Clear;
Pixel := Data;
Prefix := CodeInt(Pixel^);
inc(Pixel);
if (Prefix >= MaxColor) then
Error(sInvalidColor);
while (BumpPixel) do
begin
// Fetch the next pixel
Color := Pixel^;
inc(Pixel);
if (ord(Color) >= MaxColor) then
Error(sInvalidColor);
// Append Postfix to Prefix and lookup in table...
NewKey := (KeyInt(Prefix) SHL 8) OR ord(Color);
NewCode := HashTable.Lookup(NewKey);
if (NewCode >= 0) then
begin
// ...if found, get next pixel
Prefix := NewCode;
continue;
end;
// ...if not found, output and start over
Output(Prefix);
Prefix := CodeInt(Color);
if (FreeEntry < TableMaxFill) then
begin
HashTable.Insert(NewKey, FreeEntry);
inc(FreeEntry);
end else
Clear;
end;
Output(Prefix);
finally
HashTable.Free;
end;
end;
////////////////////////////////////////////////////////////////////////////////
//
// TGIFSubImage
//
////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
// TGIFSubImage.Compress
/////////////////////////////////////////////////////////////////////////
procedure TGIFSubImage.Compress(Stream: TStream);
var
Encoder : TGIFEncoder;
BitsPerPixel : BYTE;
MaxColors : integer;
begin
if (ColorMap.Count > 0) then
begin
MaxColors := ColorMap.Count;
BitsPerPixel := ColorMap.BitsPerPixel
end else
begin
BitsPerPixel := Image.BitsPerPixel;
MaxColors := 1 SHL BitsPerPixel;
end;
// Create a RLE or LZW GIF encoder
if (Image.Compression = gcRLE) then
Encoder := TRLEEncoder.Create
else
Encoder := TLZWEncoder.Create;
try
Encoder.Warning := Image.Warning;
Encoder.Compress(Stream, BitsPerPixel, Width, Height, Interlaced, FData, MaxColors);
finally
Encoder.Free;
end;
end;
function TGIFExtensionList.GetExtension(Index: Integer): TGIFExtension;
begin
Result := TGIFExtension(Items[Index]);
end;
procedure TGIFExtensionList.SetExtension(Index: Integer; Extension: TGIFExtension);
begin
Items[Index] := Extension;
end;
procedure TGIFExtensionList.LoadFromStream(Stream: TStream; Parent: TObject);
var
b : BYTE;
Extension : TGIFExtension;
ExtensionClass : TGIFExtensionClass;
begin
// Peek ahead to determine block type
if (Stream.Read(b, 1) <> 1) then
exit;
while not(b in [bsTrailer, bsImageDescriptor]) do
begin
if (b = bsExtensionIntroducer) then
begin
ExtensionClass := TGIFExtension.FindExtension(Stream);
if (ExtensionClass = nil) then
Error(sUnknownExtension);
Stream.Seek(-1, soFromCurrent);
Extension := ExtensionClass.Create(Parent as TGIFSubImage);
try
Extension.LoadFromStream(Stream);
Add(Extension);
except
Extension.Free;
raise;
end;
end else
begin
Warning(gsWarning, sBadExtensionLabel);
break;
end;
if (Stream.Read(b, 1) <> 1) then
exit;
end;
Stream.Seek(-1, soFromCurrent);
end;
const
{ image descriptor bit masks }
idLocalColorTable = $80; { set if a local color table follows }
idInterlaced = $40; { set if image is interlaced }
idSort = $20; { set if color table is sorted }
idReserved = $0C; { reserved - must be set to $00 }
idColorTableSize = $07; { size of color table as above }
constructor TGIFSubImage.Create(GIFImage: TGIFImage);
begin
inherited Create(GIFImage);
FExtensions := TGIFExtensionList.Create(GIFImage);
FColorMap := TGIFLocalColorMap.Create(self);
FImageDescriptor.Separator := bsImageDescriptor;
FImageDescriptor.Left := 0;
FImageDescriptor.Top := 0;
FImageDescriptor.Width := 0;
FImageDescriptor.Height := 0;
FImageDescriptor.PackedFields := 0;
FBitmap := nil;
FMask := 0;
FNeedMask := True;
FData := nil;
FDataSize := 0;
FTransparent := False;
FGCE := nil;
// Remember to synchronize with TGIFSubImage.Clear
end;
destructor TGIFSubImage.Destroy;
begin
if (FGIFImage <> nil) then
FGIFImage.Images.Remove(self);
Clear;
FExtensions.Free;
FColorMap.Free;
if (FLocalPalette <> 0) then
DeleteObject(FLocalPalette);
inherited Destroy;
end;
procedure TGIFSubImage.Clear;
begin
FExtensions.Clear;
FColorMap.Clear;
FreeImage;
Height := 0;
Width := 0;
FTransparent := False;
FGCE := nil;
FreeBitmap;
FreeMask;
// Remember to synchronize with TGIFSubImage.Create
end;
function TGIFSubImage.GetEmpty: Boolean;
begin
Result := ((FData = nil) or (FDataSize = 0) or (Height = 0) or (Width = 0));
end;
function TGIFSubImage.GetPalette: HPALETTE;
begin
if (FBitmap <> nil) and (FBitmap.Palette <> 0) then
// Use bitmaps own palette if possible
Result := FBitmap.Palette
else if (FLocalPalette <> 0) then
// Or a previously exported local palette
Result := FLocalPalette
else if (Image.DoDither) then
begin
// or create a new dither palette
FLocalPalette := WebPalette;
Result := FLocalPalette;
end
else if (ColorMap.Count > 0) then
begin
// or create a new if first time
FLocalPalette := ColorMap.ExportPalette;
Result := FLocalPalette;
end else
// Use global palette if everything else fails
Result := Image.Palette;
end;
procedure TGIFSubImage.SetPalette(Value: HPalette);
var
NeedNewBitmap : boolean;
begin
if (Value <> FLocalPalette) then
begin
// Zap old palette
if (FLocalPalette <> 0) then
DeleteObject(FLocalPalette);
// Zap bitmap unless new palette is same as bitmaps own
NeedNewBitmap := (FBitmap <> nil) and (Value <> FBitmap.Palette);
// Use new palette
FLocalPalette := Value;
if (NeedNewBitmap) then
begin
// Need to create new bitmap and repaint
FreeBitmap;
Image.PaletteModified := True;
Image.Changed(Self);
end;
end;
end;
procedure TGIFSubImage.NeedImage;
begin
if (FData = nil) then
NewImage;
if (FDataSize = 0) then
Error(sEmptyImage);
end;
procedure TGIFSubImage.NewImage;
var
NewSize : longInt;
begin
FreeImage;
NewSize := Height * Width;
if (NewSize <> 0) then
begin
GetMem(FData, NewSize);
FillChar(FData^, NewSize, 0);
end else
FData := nil;
FDataSize := NewSize;
end;
procedure TGIFSubImage.FreeImage;
begin
if (FData <> nil) then
FreeMem(FData);
FDataSize := 0;
FData := nil;
end;
function TGIFSubImage.GetHasBitmap: boolean;
begin
Result := (FBitmap <> nil);
end;
procedure TGIFSubImage.SetHasBitmap(Value: boolean);
begin
if (Value <> (FBitmap <> nil)) then
begin
if (Value) then
Bitmap // Referencing Bitmap will automatically create it
else
FreeBitmap;
end;
end;
procedure TGIFSubImage.NewBitmap;
begin
FreeBitmap;
FBitmap := TBitmap.Create;
end;
procedure TGIFSubImage.FreeBitmap;
begin
if (FBitmap <> nil) then
begin
FBitmap.Free;
FBitmap := nil;
end;
end;
procedure TGIFSubImage.FreeMask;
begin
if (FMask <> 0) then
begin
DeleteObject(FMask);
FMask := 0;
end;
FNeedMask := True;
end;
function TGIFSubImage.HasMask: boolean;
begin
if (FNeedMask) and (Transparent) then
begin
// Zap old bitmap
FreeBitmap;
// Create new bitmap and mask
GetBitmap;
end;
Result := (FMask <> 0);
end;
function TGIFSubImage.GetBounds(Index: integer): WORD;
begin
case (Index) of
1: Result := FImageDescriptor.Left;
2: Result := FImageDescriptor.Top;
3: Result := FImageDescriptor.Width;
4: Result := FImageDescriptor.Height;
else
Result := 0; // To avoid compiler warnings
end;
end;
procedure TGIFSubImage.SetBounds(Index: integer; Value: WORD);
begin
case (Index) of
1: DoSetBounds(Value, FImageDescriptor.Top, FImageDescriptor.Width, FImageDescriptor.Height);
2: DoSetBounds(FImageDescriptor.Left, Value, FImageDescriptor.Width, FImageDescriptor.Height);
3: DoSetBounds(FImageDescriptor.Left, FImageDescriptor.Top, Value, FImageDescriptor.Height);
4: DoSetBounds(FImageDescriptor.Left, FImageDescriptor.Top, FImageDescriptor.Width, Value);
end;
end;
{$IFOPT R+}
{$DEFINE R_PLUS}
{$RANGECHECKS OFF}
{$ENDIF}
function TGIFSubImage.DoGetDitherBitmap: TBitmap;
var
ColorLookup : TColorLookup;
Ditherer : TDitherEngine;
DIBResult : TDIB;
Src : PChar;
Dst : PChar;
Row : integer;
Color : TGIFColor;
ColMap : PColorMap;
Index : byte;
TransparentIndex : byte;
IsTransparent : boolean;
WasTransparent : boolean;
MappedTransparentIndex: char;
MaskBits : PChar;
MaskDest : PChar;
MaskRow : PChar;
MaskRowWidth ,
MaskRowBitWidth : integer;
Bit ,
RightBit : BYTE;
begin
Result := TBitmap.Create;
try
{$IFNDEF VER9x}
if (Width*Height > BitmapAllocationThreshold) then
SetPixelFormat(Result, pf1bit); // To reduce resource consumption of resize
{$ENDIF}
if (Empty) then
begin
// Set bitmap width and height
Result.Width := Width;
Result.Height := Height;
// Build and copy palette to bitmap
Result.Palette := CopyPalette(Palette);
exit;
end;
ColorLookup := nil;
Ditherer := nil;
DIBResult := nil;
try // Protect above resources
ColorLookup := TNetscapeColorLookup.Create(Palette);
Ditherer := TFloydSteinbergDitherer.Create(Width, ColorLookup);
// Get DIB buffer for scanline operations
// It is assumed that the source palette is the 216 color Netscape palette
DIBResult := TDIBWriter.Create(Result, pf8bit, Width, Height, Palette);
// Determine if this image is transparent
ColMap := ActiveColorMap.Data;
IsTransparent := FNeedMask and Transparent;
WasTransparent := False;
FNeedMask := False;
TransparentIndex := 0;
MappedTransparentIndex := #0;
if (FMask = 0) and (IsTransparent) then
begin
IsTransparent := True;
TransparentIndex := GraphicControlExtension.TransparentColorIndex;
Color := ColMap[ord(TransparentIndex)];
MappedTransparentIndex := char(Color.Blue DIV 51 +
MulDiv(6, Color.Green, 51) + MulDiv(36, Color.Red, 51)+1);
end;
// Allocate bit buffer for transparency mask
MaskDest := nil;
Bit := $00;
if (IsTransparent) then
begin
MaskRowWidth := ((Width+15) DIV 16) * 2;
MaskRowBitWidth := (Width+7) DIV 8;
RightBit := $01 SHL ((8 - (Width AND $0007)) AND $0007);
GetMem(MaskBits, MaskRowWidth * Height);
FillChar(MaskBits^, MaskRowWidth * Height, 0);
end else
begin
MaskBits := nil;
MaskRowWidth := 0;
MaskRowBitWidth := 0;
RightBit := $00;
end;
try
// Process the image
Row := 0;
MaskRow := MaskBits;
Src := FData;
while (Row < Height) do
begin
if ((Row AND $1F) = 0) then
Image.Progress(Self, psRunning, MulDiv(Row, 100, Height),
False, Rect(0,0,0,0), sProgressRendering);
Dst := DIBResult.ScanLine[Row];
if (IsTransparent) then
begin
// Preset all pixels to transparent
FillChar(Dst^, Width, ord(MappedTransparentIndex));
if (Ditherer.Direction = 1) then
begin
MaskDest := MaskRow;
Bit := $80;
end else
begin
MaskDest := MaskRow + MaskRowBitWidth-1;
Bit := RightBit;
end;
end;
inc(Dst, Ditherer.Column);
while (Ditherer.Column < Ditherer.Width) and (Ditherer.Column >= 0) do
begin
Index := ord(Src^);
Color := ColMap[ord(Index)];
if (IsTransparent) and (Index = TransparentIndex) then
begin
MaskDest^ := char(byte(MaskDest^) OR Bit);
WasTransparent := True;
Ditherer.NextColumn;
end else
begin
// Dither and map a single pixel
Dst^ := Ditherer.Dither(Color.Red, Color.Green, Color.Blue,
Color.Red, Color.Green, Color.Blue);
end;
if (IsTransparent) then
begin
if (Ditherer.Direction = 1) then
begin
Bit := Bit SHR 1;
if (Bit = $00) then
begin
Bit := $80;
inc(MaskDest, 1);
end;
end else
begin
Bit := Bit SHL 1;
if (Bit = $00) then
begin
Bit := $01;
dec(MaskDest, 1);
end;
end;
end;
inc(Src, Ditherer.Direction);
inc(Dst, Ditherer.Direction);
end;
if (IsTransparent) then
Inc(MaskRow, MaskRowWidth);
Inc(Row);
inc(Src, Width-Ditherer.Direction);
Ditherer.NextLine;
end;
// Transparent paint needs a mask bitmap
if (IsTransparent) and (WasTransparent) then
FMask := CreateBitmap(Width, Height, 1, 1, MaskBits);
finally
if (MaskBits <> nil) then
FreeMem(MaskBits);
end;
finally
if (ColorLookup <> nil) then
ColorLookup.Free;
if (Ditherer <> nil) then
Ditherer.Free;
if (DIBResult <> nil) then
DIBResult.Free;
end;
except
Result.Free;
raise;
end;
end;
{$IFDEF R_PLUS}
{$RANGECHECKS ON}
{$UNDEF R_PLUS}
{$ENDIF}
function TGIFSubImage.DoGetBitmap: TBitmap;
var
ScanLineRow : Integer;
DIBResult : TDIB;
DestScanLine ,
Src : PChar;
TransparentIndex : byte;
IsTransparent : boolean;
WasTransparent : boolean;
MaskBits : PChar;
MaskDest : PChar;
MaskRow : PChar;
MaskRowWidth : integer;
Col : integer;
MaskByte : byte;
Bit : byte;
begin
Result := TBitmap.Create;
try
{$IFNDEF VER9x}
if (Width*Height > BitmapAllocationThreshold) then
SetPixelFormat(Result, pf1bit); // To reduce resource consumption of resize
{$ENDIF}
if (Empty) then
begin
// Set bitmap width and height
Result.Width := Width;
Result.Height := Height;
// Build and copy palette to bitmap
Result.Palette := CopyPalette(Palette);
exit;
end;
// Get DIB buffer for scanline operations
DIBResult := TDIBWriter.Create(Result, pf8bit, Width, Height, Palette);
try
// Determine if this image is transparent
IsTransparent := FNeedMask and Transparent;
WasTransparent := False;
FNeedMask := False;
TransparentIndex := 0;
if (FMask = 0) and (IsTransparent) then
begin
IsTransparent := True;
TransparentIndex := GraphicControlExtension.TransparentColorIndex;
end;
// Allocate bit buffer for transparency mask
if (IsTransparent) then
begin
MaskRowWidth := ((Width+15) DIV 16) * 2;
GetMem(MaskBits, MaskRowWidth * Height);
FillChar(MaskBits^, MaskRowWidth * Height, 0);
IsTransparent := (MaskBits <> nil);
end else
begin
MaskBits := nil;
MaskRowWidth := 0;
end;
try
ScanLineRow := 0;
Src := FData;
MaskRow := MaskBits;
while (ScanLineRow < Height) do
begin
DestScanline := DIBResult.ScanLine[ScanLineRow];
if ((ScanLineRow AND $1F) = 0) then
Image.Progress(Self, psRunning, MulDiv(ScanLineRow, 100, Height),
False, Rect(0,0,0,0), sProgressRendering);
Move(Src^, DestScanline^, Width);
Inc(ScanLineRow);
if (IsTransparent) then
begin
Bit := $80;
MaskDest := MaskRow;
MaskByte := 0;
for Col := 0 to Width-1 do
begin
// Set a bit in the mask if the pixel is transparent
if (Src^ = char(TransparentIndex)) then
MaskByte := MaskByte OR Bit;
Bit := Bit SHR 1;
if (Bit = $00) then
begin
// Store a mask byte for each 8 pixels
Bit := $80;
WasTransparent := WasTransparent or (MaskByte <> 0);
MaskDest^ := char(MaskByte);
inc(MaskDest);
MaskByte := 0;
end;
Inc(Src);
end;
// Save the last mask byte in case the width isn't divisable by 8
if (MaskByte <> 0) then
begin
WasTransparent := True;
MaskDest^ := char(MaskByte);
end;
Inc(MaskRow, MaskRowWidth);
end else
Inc(Src, Width);
end;
// Transparent paint needs a mask bitmap
if (IsTransparent) and (WasTransparent) then
FMask := CreateBitmap(Width, Height, 1, 1, MaskBits);
finally
if (MaskBits <> nil) then
FreeMem(MaskBits);
end;
finally
// Free DIB buffer used for scanline operations
DIBResult.Free;
end;
except
Result.Free;
raise;
end;
end;
{$ifdef DEBUG_RENDERPERFORMANCE}
var
ImageCount : DWORD = 0;
RenderTime : DWORD = 0;
{$endif}
function TGIFSubImage.GetBitmap: TBitmap;
var
n : integer;
{$ifdef DEBUG_RENDERPERFORMANCE}
RenderStartTime : DWORD;
{$endif}
begin
{$ifdef DEBUG_RENDERPERFORMANCE}
if (GetAsyncKeyState(VK_CONTROL) <> 0) then
begin
ShowMessage(format('Render %d images in %d mS, Rate %d mS/image (%d images/S)',
[ImageCount, RenderTime,
RenderTime DIV (ImageCount+1),
MulDiv(ImageCount, 1000, RenderTime+1)]));
end;
{$endif}
Result := FBitmap;
if (Result <> nil) or (Empty) then
Exit;
{$ifdef DEBUG_RENDERPERFORMANCE}
inc(ImageCount);
RenderStartTime := timeGetTime;
{$endif}
try
Image.Progress(Self, psStarting, 0, False, Rect(0,0,0,0), sProgressRendering);
try
if (Image.DoDither) then
// Create dithered bitmap
FBitmap := DoGetDitherBitmap
else
// Create "regular" bitmap
FBitmap := DoGetBitmap;
Result := FBitmap;
finally
if ExceptObject = nil then
n := 100
else
n := 0;
Image.Progress(Self, psEnding, n, Image.PaletteModified, Rect(0,0,0,0),
sProgressRendering);
// Make sure new palette gets realized, in case OnProgress event didn't.
if Image.PaletteModified then
Image.Changed(Self);
end;
except
on EAbort do ; // OnProgress can raise EAbort to cancel image load
end;
{$ifdef DEBUG_RENDERPERFORMANCE}
inc(RenderTime, timeGetTime-RenderStartTime);
{$endif}
end;
procedure TGIFSubImage.SetBitmap(Value: TBitmap);
begin
FreeBitmap;
if (Value <> nil) then
Assign(Value);
end;
function TGIFSubImage.GetActiveColorMap: TGIFColorMap;
begin
if (ColorMap.Count > 0) or (Image.GlobalColorMap.Count = 0) then
Result := ColorMap
else
Result := Image.GlobalColorMap;
end;
function TGIFSubImage.GetInterlaced: boolean;
begin
Result := (FImageDescriptor.PackedFields AND idInterlaced) <> 0;
end;
procedure TGIFSubImage.SetInterlaced(Value: boolean);
begin
if (Value) then
FImageDescriptor.PackedFields := FImageDescriptor.PackedFields OR idInterlaced
else
FImageDescriptor.PackedFields := FImageDescriptor.PackedFields AND NOT(idInterlaced);
end;
function TGIFSubImage.GetVersion: TGIFVersion;
var
v : TGIFVersion;
i : integer;
begin
if (ColorMap.Optimized) then
Result := gv89a
else
Result := inherited GetVersion;
i := 0;
while (Result < high(TGIFVersion)) and (i < FExtensions.Count) do
begin
v := FExtensions[i].Version;
if (v > Result) then
Result := v;
end;
end;
function TGIFSubImage.GetColorResolution: integer;
begin
Result := ColorMap.BitsPerPixel-1;
end;
function TGIFSubImage.GetBitsPerPixel: integer;
begin
Result := ColorMap.BitsPerPixel;
end;
function TGIFSubImage.GetBoundsRect: TRect;
begin
Result := Rect(FImageDescriptor.Left,
FImageDescriptor.Top,
FImageDescriptor.Left+FImageDescriptor.Width,
FImageDescriptor.Top+FImageDescriptor.Height);
end;
procedure TGIFSubImage.DoSetBounds(ALeft, ATop, AWidth, AHeight: integer);
var
TooLarge : boolean;
Zap : boolean;
begin
Zap := (FImageDescriptor.Width <> Width) or (FImageDescriptor.Height <> AHeight);
FImageDescriptor.Left := ALeft;
FImageDescriptor.Top := ATop;
FImageDescriptor.Width := AWidth;
FImageDescriptor.Height := AHeight;
// Delete existing image and bitmaps if size has changed
if (Zap) then
begin
FreeBitmap;
FreeMask;
FreeImage;
// ...and allocate a new image
NewImage;
end;
TooLarge := False;
// Set width & height if added image is larger than existing images
{$IFDEF STRICT_MOZILLA}
// From Mozilla source:
// Work around broken GIF files where the logical screen
// size has weird width or height. [...]
if (Image.Width < AWidth) or (Image.Height < AHeight) then
begin
TooLarge := True;
Image.Width := AWidth;
Image.Height := AHeight;
Left := 0;
Top := 0;
end;
{$ELSE}
if (Image.Width < ALeft+AWidth) then
begin
if (Image.Width > 0) then
begin
TooLarge := True;
Warning(gsWarning, sBadWidth)
end;
Image.Width := ALeft+AWidth;
end;
if (Image.Height < ATop+AHeight) then
begin
if (Image.Height > 0) then
begin
TooLarge := True;
Warning(gsWarning, sBadHeight)
end;
Image.Height := ATop+AHeight;
end;
{$ENDIF}
if (TooLarge) then
Warning(gsWarning, sScreenSizeExceeded);
end;
procedure TGIFSubImage.SetBoundsRect(const Value: TRect);
begin
DoSetBounds(Value.Left, Value.Top, Value.Right-Value.Left+1, Value.Bottom-Value.Top+1);
end;
function TGIFSubImage.GetClientRect: TRect;
begin
Result := Rect(0, 0, FImageDescriptor.Width, FImageDescriptor.Height);
end;
function TGIFSubImage.GetPixel(x, y: integer): BYTE;
begin
if (x < 0) or (x > Width-1) then
Error(sBadPixelCoordinates);
Result := BYTE(PChar(longInt(Scanline[y]) + x)^);
end;
function TGIFSubImage.GetScanline(y: integer): pointer;
begin
if (y < 0) or (y > Height-1) then
Error(sBadPixelCoordinates);
NeedImage;
Result := pointer(longInt(FData) + y * Width);
end;
procedure TGIFSubImage.Prepare;
var
Pack : BYTE;
begin
Pack := FImageDescriptor.PackedFields;
if (ColorMap.Count > 0) then
begin
Pack := idLocalColorTable;
if (ColorMap.Optimized) then
Pack := Pack OR idSort;
Pack := (Pack AND NOT(idColorTableSize)) OR (ColorResolution AND idColorTableSize);
end else
Pack := Pack AND NOT(idLocalColorTable OR idSort OR idColorTableSize);
FImageDescriptor.PackedFields := Pack;
end;
procedure TGIFSubImage.SaveToStream(Stream: TStream);
begin
FExtensions.SaveToStream(Stream);
if (Empty) then
exit;
Prepare;
Stream.Write(FImageDescriptor, sizeof(TImageDescriptor));
ColorMap.SaveToStream(Stream);
Compress(Stream);
end;
procedure TGIFSubImage.LoadFromStream(Stream: TStream);
var
ColorCount : integer;
b : BYTE;
begin
Clear;
FExtensions.LoadFromStream(Stream, self);
// Check for extension without image
if (Stream.Read(b, 1) <> 1) then
exit;
Stream.Seek(-1, soFromCurrent);
if (b = bsTrailer) or (b = 0) then
exit;
ReadCheck(Stream, FImageDescriptor, sizeof(TImageDescriptor));
// From Mozilla source:
// Work around more broken GIF files that have zero image
// width or height
if (FImageDescriptor.Height = 0) or (FImageDescriptor.Width = 0) then
begin
FImageDescriptor.Height := Image.Height;
FImageDescriptor.Width := Image.Width;
Warning(gsWarning, sScreenSizeExceeded);
end;
if (FImageDescriptor.PackedFields AND idLocalColorTable = idLocalColorTable) then
begin
ColorCount := 2 SHL (FImageDescriptor.PackedFields AND idColorTableSize);
if (ColorCount < 2) or (ColorCount > 256) then
Error(sImageBadColorSize);
ColorMap.LoadFromStream(Stream, ColorCount);
end;
Decompress(Stream);
// On-load rendering
if (GIFImageRenderOnLoad) then
// Touch bitmap to force frame to be rendered
Bitmap;
end;
procedure TGIFSubImage.AssignTo(Dest: TPersistent);
begin
if (Dest is TBitmap) then
Dest.Assign(Bitmap)
else
inherited AssignTo(Dest);
end;
procedure TGIFSubImage.Assign(Source: TPersistent);
var
MemoryStream : TMemoryStream;
i : integer;
PixelFormat : TPixelFormat;
DIBSource : TDIB;
ABitmap : TBitmap;
procedure Import8Bit(Dest: PChar);
var
y : integer;
begin
// Copy colormap
{$ifdef VER10_PLUS}
if (FBitmap.HandleType = bmDIB) then
FColorMap.ImportDIBColors(FBitmap.Canvas.Handle)
else
{$ENDIF}
FColorMap.ImportPalette(FBitmap.Palette);
// Copy pixels
for y := 0 to Height-1 do
begin
if ((y AND $1F) = 0) then
Image.Progress(Self, psRunning, MulDiv(y, 100, Height), False, Rect(0,0,0,0), sProgressConverting);
Move(DIBSource.Scanline[y]^, Dest^, Width);
inc(Dest, Width);
end;
end;
procedure Import4Bit(Dest: PChar);
var
x, y : integer;
Scanline : PChar;
begin
// Copy colormap
FColorMap.ImportPalette(FBitmap.Palette);
// Copy pixels
for y := 0 to Height-1 do
begin
if ((y AND $1F) = 0) then
Image.Progress(Self, psRunning, MulDiv(y, 100, Height), False, Rect(0,0,0,0), sProgressConverting);
ScanLine := DIBSource.Scanline[y];
for x := 0 to Width-1 do
begin
if (x AND $01 = 0) then
Dest^ := chr(ord(ScanLine^) SHR 4)
else
begin
Dest^ := chr(ord(ScanLine^) AND $0F);
inc(ScanLine);
end;
inc(Dest);
end;
end;
end;
procedure Import1Bit(Dest: PChar);
var
x, y : integer;
Scanline : PChar;
Bit : integer;
Byte : integer;
begin
// Copy colormap
FColorMap.ImportPalette(FBitmap.Palette);
// Copy pixels
for y := 0 to Height-1 do
begin
if ((y AND $1F) = 0) then
Image.Progress(Self, psRunning, MulDiv(y, 100, Height), False, Rect(0,0,0,0), sProgressConverting);
ScanLine := DIBSource.Scanline[y];
x := Width;
Bit := 0;
Byte := 0; // To avoid compiler warning
while (x > 0) do
begin
if (Bit = 0) then
begin
Bit := 8;
Byte := ord(ScanLine^);
inc(Scanline);
end;
Dest^ := chr((Byte AND $80) SHR 7);
Byte := Byte SHL 1;
inc(Dest);
dec(Bit);
dec(x);
end;
end;
end;
procedure Import24Bit(Dest: PChar);
type
TCacheEntry = record
Color : TColor;
Index : integer;
end;
const
// Size of palette cache. Must be 2^n.
// The cache holds the palette index of the last "CacheSize" colors
// processed. Hopefully the cache can speed things up a bit... Initial
// testing shows that this is indeed the case at least for non-dithered
// bitmaps.
// All the same, a small hash table would probably be much better.
CacheSize = 8;
var
i : integer;
Cache : array[0..CacheSize-1] of TCacheEntry;
LastEntry : integer;
Scanline : PRGBTriple;
Pixel : TColor;
RGBTriple : TRGBTriple absolute Pixel;
x, y : integer;
ColorMap : PColorMap;
t : byte;
label
NextPixel;
begin
for i := 0 to CacheSize-1 do
Cache[i].Index := -1;
LastEntry := 0;
// Copy all pixels and build colormap
for y := 0 to Height-1 do
begin
if ((y AND $1F) = 0) then
Image.Progress(Self, psRunning, MulDiv(y, 100, Height), False, Rect(0,0,0,0), sProgressConverting);
ScanLine := DIBSource.Scanline[y];
for x := 0 to Width-1 do
begin
Pixel := 0;
RGBTriple := Scanline^;
// Scan cache for color from most recently processed color to last
// recently processed. This is done because TColorMap.AddUnique is very slow.
i := LastEntry;
repeat
if (Cache[i].Index = -1) then
break;
if (Cache[i].Color = Pixel) then
begin
Dest^ := chr(Cache[i].Index);
LastEntry := i;
goto NextPixel;
end;
if (i = 0) then
i := CacheSize-1
else
dec(i);
until (i = LastEntry);
// Color not found in cache, do it the slow way instead
Dest^ := chr(FColorMap.AddUnique(Pixel));
// Add color and index to cache
LastEntry := (LastEntry + 1) AND (CacheSize-1);
Cache[LastEntry].Color := Pixel;
Cache[LastEntry].Index := ord(Dest^);
NextPixel:
Inc(Dest);
Inc(Scanline);
end;
end;
// Convert colors in colormap from BGR to RGB
ColorMap := FColorMap.Data;
i := FColorMap.Count;
while (i > 0) do
begin
t := ColorMap^[0].Red;
ColorMap^[0].Red := ColorMap^[0].Blue;
ColorMap^[0].Blue := t;
inc(integer(ColorMap), sizeof(TGIFColor));
dec(i);
end;
end;
procedure ImportViaDraw(ABitmap: TBitmap; Graphic: TGraphic);
begin
ABitmap.Height := Graphic.Height;
ABitmap.Width := Graphic.Width;
// Note: Disable the call to SafeSetPixelFormat below to import
// in max number of colors with the risk of having to use
// TCanvas.Pixels to do it (very slow).
// Make things a little easier for TGIFSubImage.Assign by converting
// pfDevice to a more import friendly format
{$ifdef SLOW_BUT_SAFE}
SafeSetPixelFormat(ABitmap, pf8bit);
{$else}
{$ifndef VER9x}
SetPixelFormat(ABitmap, pf24bit);
{$endif}
{$endif}
ABitmap.Canvas.Draw(0, 0, Graphic);
end;
procedure AddMask(Mask: TBitmap);
var
DIBReader : TDIBReader;
TransparentIndex : integer;
i ,
j : integer;
GIFPixel ,
MaskPixel : PChar;
WasTransparent : boolean;
GCE : TGIFGraphicControlExtension;
begin
// Optimize colormap to make room for transparent color
ColorMap.Optimize;
// Can't make transparent if no color or colormap full
if (ColorMap.Count = 0) or (ColorMap.Count = 256) then
exit;
// Add the transparent color to the color map
TransparentIndex := ColorMap.Add(TColor(0));
WasTransparent := False;
DIBReader := TDIBReader.Create(Mask, pf8bit);
try
for i := 0 to Height-1 do
begin
MaskPixel := DIBReader.Scanline[i];
GIFPixel := Scanline[i];
for j := 0 to Width-1 do
begin
// Change all unmasked pixels to transparent
if (MaskPixel^ <> #0) then
begin
GIFPixel^ := chr(TransparentIndex);
WasTransparent := True;
end;
inc(MaskPixel);
inc(GIFPixel);
end;
end;
finally
DIBReader.Free;
end;
// Add a Graphic Control Extension if any part of the mask was transparent
if (WasTransparent) then
begin
GCE := TGIFGraphicControlExtension.Create(self);
GCE.Transparent := True;
GCE.TransparentColorIndex := TransparentIndex;
Extensions.Add(GCE);
end else
// Otherwise removed the transparency color since it wasn't used
ColorMap.Delete(TransparentIndex);
end;
procedure AddMaskOnly(hMask: hBitmap);
var
Mask : TBitmap;
begin
if (hMask = 0) then
exit;
// Encapsulate the mask
Mask := TBitmap.Create;
try
Mask.Handle := hMask;
AddMask(Mask);
finally
Mask.ReleaseHandle;
Mask.Free;
end;
end;
procedure AddIconMask(Icon: TIcon);
var
IconInfo : TIconInfo;
begin
if (not GetIconInfo(Icon.Handle, IconInfo)) then
exit;
// Extract the icon mask
AddMaskOnly(IconInfo.hbmMask);
end;
procedure AddMetafileMask(Metafile: TMetaFile);
var
Mask1 ,
Mask2 : TBitmap;
procedure DrawMetafile(ABitmap: TBitmap; Background: TColor);
begin
ABitmap.Width := Metafile.Width;
ABitmap.Height := Metafile.Height;
{$ifndef VER9x}
SetPixelFormat(ABitmap, pf24bit);
{$endif}
ABitmap.Canvas.Brush.Color := Background;
ABitmap.Canvas.Brush.Style := bsSolid;
ABitmap.Canvas.FillRect(ABitmap.Canvas.ClipRect);
ABitmap.Canvas.Draw(0,0, Metafile);
end;
begin
// Create the metafile mask
Mask1 := TBitmap.Create;
try
Mask2 := TBitmap.Create;
try
DrawMetafile(Mask1, clWhite);
DrawMetafile(Mask2, clBlack);
Mask1.Canvas.CopyMode := cmSrcInvert;
Mask1.Canvas.Draw(0,0, Mask2);
AddMask(Mask1);
finally
Mask2.Free;
end;
finally
Mask1.Free;
end;
end;
begin
if (Source = self) then
exit;
if (Source = nil) then
begin
Clear;
end else
//
// TGIFSubImage import
//
if (Source is TGIFSubImage) then
begin
// Zap existing colormap, extensions and bitmap
Clear;
if (TGIFSubImage(Source).Empty) then
exit;
// Copy source data
FImageDescriptor := TGIFSubImage(Source).FImageDescriptor;
FTransparent := TGIFSubImage(Source).Transparent;
// Copy image data
NewImage;
if (FData <> nil) and (TGIFSubImage(Source).Data <> nil) then
Move(TGIFSubImage(Source).Data^, FData^, FDataSize);
// Copy palette
FColorMap.Assign(TGIFSubImage(Source).ColorMap);
// Copy extensions
if (TGIFSubImage(Source).Extensions.Count > 0) then
begin
MemoryStream := TMemoryStream.Create;
try
TGIFSubImage(Source).Extensions.SaveToStream(MemoryStream);
MemoryStream.Seek(0, soFromBeginning);
Extensions.LoadFromStream(MemoryStream, Self);
finally
MemoryStream.Free;
end;
end;
// Copy bitmap representation
// (Not really nescessary but improves performance if the bitmap is needed
// later on)
if (TGIFSubImage(Source).HasBitmap) then
begin
NewBitmap;
FBitmap.Assign(TGIFSubImage(Source).Bitmap);
end;
end else
//
// Bitmap import
//
if (Source is TBitmap) then
begin
// Zap existing colormap, extensions and bitmap
Clear;
if (TBitmap(Source).Empty) then
exit;
Width := TBitmap(Source).Width;
Height := TBitmap(Source).Height;
PixelFormat := GetPixelFormat(TBitmap(Source));
{$ifdef VER9x}
// Delphi 2 TBitmaps are always DDBs. This means that if a 24 bit
// bitmap is loaded in 8 bit device mode, TBitmap.PixelFormat will
// be pf8bit, but TBitmap.Palette will be 0!
if (TBitmap(Source).Palette = 0) then
PixelFormat := pfDevice;
{$endif}
if (PixelFormat > pf8bit) or (PixelFormat = pfDevice) then
begin
// Convert image to 8 bits/pixel or less
FBitmap := ReduceColors(TBitmap(Source), Image.ColorReduction,
Image.DitherMode, Image.ReductionBits, 0);
PixelFormat := GetPixelFormat(FBitmap);
end else
begin
// Create new bitmap and copy
NewBitmap;
FBitmap.Assign(TBitmap(Source));
end;
// Allocate new buffer
NewImage;
Image.Progress(Self, psStarting, 0, False, Rect(0,0,0,0), sProgressConverting);
try
{$ifdef VER9x}
// This shouldn't happen, but better safe...
if (FBitmap.Palette = 0) then
PixelFormat := pf24bit;
{$endif}
if (not(PixelFormat in [pf1bit, pf4bit, pf8bit, pf24bit])) then
PixelFormat := pf24bit;
DIBSource := TDIBReader.Create(FBitmap, PixelFormat);
try
// Copy pixels
case (PixelFormat) of
pf8bit: Import8Bit(Fdata);
pf4bit: Import4Bit(Fdata);
pf1bit: Import1Bit(Fdata);
else
// Error(sUnsupportedBitmap);
Import24Bit(Fdata);
end;
finally
DIBSource.Free;
end;
{$ifdef VER10_PLUS}
// Add mask for transparent bitmaps
if (TBitmap(Source).Transparent) then
AddMaskOnly(TBitmap(Source).MaskHandle);
{$endif}
finally
if ExceptObject = nil then
i := 100
else
i := 0;
Image.Progress(Self, psEnding, i, Image.PaletteModified, Rect(0,0,0,0), sProgressConverting);
end;
end else
//
// TGraphic import
//
if (Source is TGraphic) then
begin
// Zap existing colormap, extensions and bitmap
Clear;
if (TGraphic(Source).Empty) then
exit;
ABitmap := TBitmap.Create;
try
// Import TIcon and TMetafile by drawing them onto a bitmap...
// ...and then importing the bitmap recursively
if (Source is TIcon) or (Source is TMetafile) then
begin
try
ImportViaDraw(ABitmap, TGraphic(Source))
except
// If import via TCanvas.Draw fails (which it shouldn't), we try the
// Assign mechanism instead
ABitmap.Assign(Source);
end;
end else
try
ABitmap.Assign(Source);
except
// If automatic conversion to bitmap fails, we try and draw the
// graphic on the bitmap instead
ImportViaDraw(ABitmap, TGraphic(Source));
end;
// Convert the bitmap to a GIF frame recursively
Assign(ABitmap);
finally
ABitmap.Free;
end;
// Import transparency mask
if (Source is TIcon) then
AddIconMask(TIcon(Source));
if (Source is TMetaFile) then
AddMetafileMask(TMetaFile(Source));
end else
//
// TPicture import
//
if (Source is TPicture) then
begin
// Recursively import TGraphic
Assign(TPicture(Source).Graphic);
end else
// Unsupported format - fall back to Source.AssignTo
inherited Assign(Source);
end;
// Copied from D3 graphics.pas
// Fixed by Brian Lowe of Acro Technology Inc. 30Jan98
function TransparentStretchBlt(DstDC: HDC; DstX, DstY, DstW, DstH: Integer;
SrcDC: HDC; SrcX, SrcY, SrcW, SrcH: Integer; MaskDC: HDC; MaskX,
MaskY: Integer): Boolean;
const
ROP_DstCopy = $00AA0029;
var
MemDC ,
OrMaskDC : HDC;
MemBmp ,
OrMaskBmp : HBITMAP;
Save ,
OrMaskSave : THandle;
crText, crBack : TColorRef;
SavePal : HPALETTE;
begin
Result := True;
if (Win32Platform = VER_PLATFORM_WIN32_NT) and (SrcW = DstW) and (SrcH = DstH) then
begin
MemBmp := GDICheck(CreateCompatibleBitmap(SrcDC, 1, 1));
MemBmp := SelectObject(MaskDC, MemBmp);
try
MaskBlt(DstDC, DstX, DstY, DstW, DstH, SrcDC, SrcX, SrcY, MemBmp, MaskX,
MaskY, MakeRop4(ROP_DstCopy, SrcCopy));
finally
MemBmp := SelectObject(MaskDC, MemBmp);
DeleteObject(MemBmp);
end;
Exit;
end;
SavePal := 0;
MemDC := GDICheck(CreateCompatibleDC(DstDC));
try
{ Color bitmap for combining OR mask with source bitmap }
MemBmp := GDICheck(CreateCompatibleBitmap(DstDC, SrcW, SrcH));
try
Save := SelectObject(MemDC, MemBmp);
try
{ This bitmap needs the size of the source but DC of the dest }
OrMaskDC := GDICheck(CreateCompatibleDC(DstDC));
try
{ Need a monochrome bitmap for OR mask!! }
OrMaskBmp := GDICheck(CreateBitmap(SrcW, SrcH, 1, 1, nil));
try
OrMaskSave := SelectObject(OrMaskDC, OrMaskBmp);
try
// OrMask := 1
// Original: BitBlt(OrMaskDC, SrcX, SrcY, SrcW, SrcH, OrMaskDC, SrcX, SrcY, WHITENESS);
// Replacement, but not needed: PatBlt(OrMaskDC, SrcX, SrcY, SrcW, SrcH, WHITENESS);
// OrMask := OrMask XOR Mask
// Not needed: BitBlt(OrMaskDC, SrcX, SrcY, SrcW, SrcH, MaskDC, SrcX, SrcY, SrcInvert);
// OrMask := NOT Mask
BitBlt(OrMaskDC, SrcX, SrcY, SrcW, SrcH, MaskDC, SrcX, SrcY, NotSrcCopy);
// Retrieve source palette (with dummy select)
SavePal := SelectPalette(SrcDC, SystemPalette16, False);
// Restore source palette
SelectPalette(SrcDC, SavePal, False);
// Select source palette into memory buffer
if SavePal <> 0 then
SavePal := SelectPalette(MemDC, SavePal, True)
else
SavePal := SelectPalette(MemDC, SystemPalette16, True);
RealizePalette(MemDC);
// Mem := OrMask
BitBlt(MemDC, SrcX, SrcY, SrcW, SrcH, OrMaskDC, SrcX, SrcY, SrcCopy);
// Mem := Mem AND Src
{$IFNDEF GIF_TESTMASK} // Define GIF_TESTMASK if you want to know what it does...
BitBlt(MemDC, SrcX, SrcY, SrcW, SrcH, SrcDC, SrcX, SrcY, SrcAnd);
{$ELSE}
StretchBlt(DstDC, DstX, DstY, DstW DIV 2, DstH, MemDC, SrcX, SrcY, SrcW, SrcH, SrcCopy);
StretchBlt(DstDC, DstX+DstW DIV 2, DstY, DstW DIV 2, DstH, SrcDC, SrcX, SrcY, SrcW, SrcH, SrcCopy);
exit;
{$ENDIF}
finally
if (OrMaskSave <> 0) then
SelectObject(OrMaskDC, OrMaskSave);
end;
finally
DeleteObject(OrMaskBmp);
end;
finally
DeleteDC(OrMaskDC);
end;
crText := SetTextColor(DstDC, $00000000);
crBack := SetBkColor(DstDC, $00FFFFFF);
{ All color rendering is done at 1X (no stretching),
then final 2 masks are stretched to dest DC }
// Neat trick!
// Dst := Dst AND Mask
StretchBlt(DstDC, DstX, DstY, DstW, DstH, MaskDC, SrcX, SrcY, SrcW, SrcH, SrcAnd);
// Dst := Dst OR Mem
StretchBlt(DstDC, DstX, DstY, DstW, DstH, MemDC, SrcX, SrcY, SrcW, SrcH, SrcPaint);
SetTextColor(DstDC, crText);
SetTextColor(DstDC, crBack);
finally
if (Save <> 0) then
SelectObject(MemDC, Save);
end;
finally
DeleteObject(MemBmp);
end;
finally
if (SavePal <> 0) then
SelectPalette(MemDC, SavePal, False);
DeleteDC(MemDC);
end;
end;
procedure TGIFSubImage.Draw(ACanvas: TCanvas; const Rect: TRect;
DoTransparent, DoTile: boolean);
begin
if (DoTile) then
StretchDraw(ACanvas, Rect, DoTransparent, DoTile)
else
StretchDraw(ACanvas, ScaleRect(Rect), DoTransparent, DoTile);
end;
type
// Dummy class used to gain access to protected method TCanvas.Changed
TChangableCanvas = class(TCanvas)
end;
procedure TGIFSubImage.StretchDraw(ACanvas: TCanvas; const Rect: TRect;
DoTransparent, DoTile: boolean);
var
MaskDC : HDC;
Save : THandle;
Tile : TRect;
{$ifdef DEBUG_DRAWPERFORMANCE}
ImageCount ,
TimeStart ,
TimeStop : DWORD;
{$endif}
begin
{$ifdef DEBUG_DRAWPERFORMANCE}
TimeStart := timeGetTime;
ImageCount := 0;
{$endif}
if (DoTransparent) and (Transparent) and (HasMask) then
begin
// Draw transparent using mask
Save := 0;
MaskDC := 0;
try
MaskDC := GDICheck(CreateCompatibleDC(0));
Save := SelectObject(MaskDC, FMask);
if (DoTile) then
begin
Tile.Left := Rect.Left+Left;
Tile.Right := Tile.Left + Width;
while (Tile.Left < Rect.Right) do
begin
Tile.Top := Rect.Top+Top;
Tile.Bottom := Tile.Top + Height;
while (Tile.Top < Rect.Bottom) do
begin
TransparentStretchBlt(ACanvas.Handle, Tile.Left, Tile.Top, Width, Height,
Bitmap.Canvas.Handle, 0, 0, Width, Height, MaskDC, 0, 0);
Tile.Top := Tile.Top + Image.Height;
Tile.Bottom := Tile.Bottom + Image.Height;
{$ifdef DEBUG_DRAWPERFORMANCE}
inc(ImageCount);
{$endif}
end;
Tile.Left := Tile.Left + Image.Width;
Tile.Right := Tile.Right + Image.Width;
end;
end else
TransparentStretchBlt(ACanvas.Handle, Rect.Left, Rect.Top,
Rect.Right - Rect.Left, Rect.Bottom - Rect.Top,
Bitmap.Canvas.Handle, 0, 0, Width, Height, MaskDC, 0, 0);
// Since we are not using any of the TCanvas functions (only handle)
// we need to fire the TCanvas.Changed method "manually".
TChangableCanvas(ACanvas).Changed;
finally
if (Save <> 0) then
SelectObject(MaskDC, Save);
if (MaskDC <> 0) then
DeleteDC(MaskDC);
end;
end else
begin
if (DoTile) then
begin
Tile.Left := Rect.Left+Left;
Tile.Right := Tile.Left + Width;
while (Tile.Left < Rect.Right) do
begin
Tile.Top := Rect.Top+Top;
Tile.Bottom := Tile.Top + Height;
while (Tile.Top < Rect.Bottom) do
begin
ACanvas.StretchDraw(Tile, Bitmap);
Tile.Top := Tile.Top + Image.Height;
Tile.Bottom := Tile.Bottom + Image.Height;
{$ifdef DEBUG_DRAWPERFORMANCE}
inc(ImageCount);
{$endif}
end;
Tile.Left := Tile.Left + Image.Width;
Tile.Right := Tile.Right + Image.Width;
end;
end else
ACanvas.StretchDraw(Rect, Bitmap);
end;
{$ifdef DEBUG_DRAWPERFORMANCE}
if (GetAsyncKeyState(VK_CONTROL) <> 0) then
begin
TimeStop := timeGetTime;
ShowMessage(format('Draw %d images in %d mS, Rate %d images/mS (%d images/S)',
[ImageCount, TimeStop-TimeStart,
ImageCount DIV (TimeStop-TimeStart+1),
MulDiv(ImageCount, 1000, TimeStop-TimeStart+1)]));
end;
{$endif}
end;
// Given a destination rect (DestRect) calculates the
// area covered by this sub image
function TGIFSubImage.ScaleRect(DestRect: TRect): TRect;
var
HeightMul ,
HeightDiv : integer;
WidthMul ,
WidthDiv : integer;
begin
HeightDiv := Image.Height;
HeightMul := DestRect.Bottom-DestRect.Top;
WidthDiv := Image.Width;
WidthMul := DestRect.Right-DestRect.Left;
Result.Left := DestRect.Left + muldiv(Left, WidthMul, WidthDiv);
Result.Top := DestRect.Top + muldiv(Top, HeightMul, HeightDiv);
Result.Right := DestRect.Left + muldiv(Left+Width, WidthMul, WidthDiv);
Result.Bottom := DestRect.Top + muldiv(Top+Height, HeightMul, HeightDiv);
end;
procedure TGIFSubImage.Crop;
var
TransparentColorIndex : byte;
CropLeft ,
CropTop ,
CropRight ,
CropBottom : integer;
WasTransparent : boolean;
i : integer;
NewSize : integer;
NewData : PChar;
NewWidth ,
NewHeight : integer;
pSource ,
pDest : PChar;
begin
if (Empty) or (not Transparent) then
exit;
TransparentColorIndex := GraphicControlExtension.TransparentColorIndex;
CropLeft := 0;
CropRight := Width - 1;
CropTop := 0;
CropBottom := Height - 1;
// Find left edge
WasTransparent := True;
while (CropLeft <= CropRight) and (WasTransparent) do
begin
for i := CropTop to CropBottom do
if (Pixels[CropLeft, i] <> TransparentColorIndex) then
begin
WasTransparent := False;
break;
end;
if (WasTransparent) then
inc(CropLeft);
end;
// Find right edge
WasTransparent := True;
while (CropLeft <= CropRight) and (WasTransparent) do
begin
for i := CropTop to CropBottom do
if (pixels[CropRight, i] <> TransparentColorIndex) then
begin
WasTransparent := False;
break;
end;
if (WasTransparent) then
dec(CropRight);
end;
if (CropLeft <= CropRight) then
begin
// Find top edge
WasTransparent := True;
while (CropTop <= CropBottom) and (WasTransparent) do
begin
for i := CropLeft to CropRight do
if (pixels[i, CropTop] <> TransparentColorIndex) then
begin
WasTransparent := False;
break;
end;
if (WasTransparent) then
inc(CropTop);
end;
// Find bottom edge
WasTransparent := True;
while (CropTop <= CropBottom) and (WasTransparent) do
begin
for i := CropLeft to CropRight do
if (pixels[i, CropBottom] <> TransparentColorIndex) then
begin
WasTransparent := False;
break;
end;
if (WasTransparent) then
dec(CropBottom);
end;
end;
if (CropLeft > CropRight) or (CropTop > CropBottom) then
begin
// Cropped to nothing - frame is invisible
Clear;
end else
begin
// Crop frame - move data
NewWidth := CropRight - CropLeft + 1;
Newheight := CropBottom - CropTop + 1;
NewSize := NewWidth * NewHeight;
GetMem(NewData, NewSize);
pSource := PChar(integer(FData) + CropTop * Width + CropLeft);
pDest := NewData;
for i := 0 to NewHeight-1 do
begin
Move(pSource^, pDest^, NewWidth);
inc(pSource, Width);
inc(pDest, NewWidth);
end;
FreeImage;
FData := NewData;
FDataSize := NewSize;
inc(FImageDescriptor.Left, CropLeft);
inc(FImageDescriptor.Top, CropTop);
FImageDescriptor.Width := NewWidth;
FImageDescriptor.Height := NewHeight;
FreeBitmap;
FreeMask
end;
end;
procedure TGIFSubImage.Merge(Previous: TGIFSubImage);
var
SourceIndex ,
DestIndex : byte;
SourceTransparent : boolean;
NeedTransparentColorIndex: boolean;
PreviousRect ,
ThisRect ,
MergeRect : TRect;
PreviousY ,
X ,
Y : integer;
pSource ,
pDest : PChar;
pSourceMap ,
pDestMap : PColorMap;
GCE : TGIFGraphicControlExtension;
function CanMakeTransparent: boolean;
begin
// Is there a local color map...
if (ColorMap.Count > 0) then
// ...and is there room in it?
Result := (ColorMap.Count < 256)
// Is there a global color map...
else if (Image.GlobalColorMap.Count > 0) then
// ...and is there room in it?
Result := (Image.GlobalColorMap.Count < 256)
else
Result := False;
end;
function GetTransparentColorIndex: byte;
var
i : integer;
begin
if (ColorMap.Count > 0) then
begin
// Get the transparent color from the local color map
Result := ColorMap.Add(TColor(0));
end else
begin
// Are any other frames using the global color map for transparency
for i := 0 to Image.Images.Count-1 do
if (Image.Images[i] <> self) and (Image.Images[i].Transparent) and
(Image.Images[i].ColorMap.Count = 0) then
begin
// Use the same transparency color as the other frame
Result := Image.Images[i].GraphicControlExtension.TransparentColorIndex;
exit;
end;
// Get the transparent color from the global color map
Result := Image.GlobalColorMap.Add(TColor(0));
end;
end;
begin
// Determine if it is possible to merge this frame
if (Empty) or (Previous = nil) or (Previous.Empty) or
((Previous.GraphicControlExtension <> nil) and
(Previous.GraphicControlExtension.Disposal in [dmBackground, dmPrevious])) then
exit;
PreviousRect := Previous.BoundsRect;
ThisRect := BoundsRect;
// Cannot merge unless the frames intersect
if (not IntersectRect(MergeRect, PreviousRect, ThisRect)) then
exit;
// If the frame isn't already transparent, determine
// if it is possible to make it so
if (Transparent) then
begin
DestIndex := GraphicControlExtension.TransparentColorIndex;
NeedTransparentColorIndex := False;
end else
begin
if (not CanMakeTransparent) then
exit;
DestIndex := 0; // To avoid compiler warning
NeedTransparentColorIndex := True;
end;
SourceTransparent := Previous.Transparent;
if (SourceTransparent) then
SourceIndex := Previous.GraphicControlExtension.TransparentColorIndex
else
SourceIndex := 0; // To avoid compiler warning
PreviousY := MergeRect.Top - Previous.Top;
pSourceMap := Previous.ActiveColorMap.Data;
pDestMap := ActiveColorMap.Data;
for Y := MergeRect.Top - Top to MergeRect.Bottom - Top-1 do
begin
pSource := PChar(integer(Previous.Scanline[PreviousY]) + MergeRect.Left - Previous.Left);
pDest := PChar(integer(Scanline[Y]) + MergeRect.Left - Left);
for X := MergeRect.Left to MergeRect.Right-1 do
begin
// Ignore pixels if either this frame's or the previous frame's pixel is transparent
if (
not(
((not NeedTransparentColorIndex) and (pDest^ = char(DestIndex))) or
((SourceTransparent) and (pSource^ = char(SourceIndex)))
)
) and (
// Replace same colored pixels with transparency
((pDestMap = pSourceMap) and (pDest^ = pSource^)) or
(CompareMem(@(pDestMap^[ord(pDest^)]), @(pSourceMap^[ord(pSource^)]), sizeof(TGIFColor)))
) then
begin
if (NeedTransparentColorIndex) then
begin
NeedTransparentColorIndex := False;
DestIndex := GetTransparentColorIndex;
end;
pDest^ := char(DestIndex);
end;
inc(pDest);
inc(pSource);
end;
inc(PreviousY);
end;
(*
** Create a GCE if the frame wasn't already transparent and any
** pixels were made transparent
*)
if (not Transparent) and (not NeedTransparentColorIndex) then
begin
if (GraphicControlExtension = nil) then
begin
GCE := TGIFGraphicControlExtension.Create(self);
Extensions.Add(GCE);
end else
GCE := GraphicControlExtension;
GCE.Transparent := True;
GCE.TransparentColorIndex := DestIndex;
end;
FreeBitmap;
FreeMask
end;
////////////////////////////////////////////////////////////////////////////////
//
// TGIFTrailer
//
////////////////////////////////////////////////////////////////////////////////
procedure TGIFTrailer.SaveToStream(Stream: TStream);
begin
WriteByte(Stream, bsTrailer);
end;
procedure TGIFTrailer.LoadFromStream(Stream: TStream);
var
b : BYTE;
begin
if (Stream.Read(b, 1) <> 1) then
exit;
if (b <> bsTrailer) then
Warning(gsWarning, sBadTrailer);
end;
////////////////////////////////////////////////////////////////////////////////
//
// TGIFExtension registration database
//
////////////////////////////////////////////////////////////////////////////////
type
TExtensionLeadIn = packed record
Introducer: byte; { always $21 }
ExtensionLabel: byte;
end;
PExtRec = ^TExtRec;
TExtRec = record
ExtClass: TGIFExtensionClass;
ExtLabel: BYTE;
end;
TExtensionList = class(TList)
public
constructor Create;
destructor Destroy; override;
procedure Add(eLabel: BYTE; eClass: TGIFExtensionClass);
function FindExt(eLabel: BYTE): TGIFExtensionClass;
procedure Remove(eClass: TGIFExtensionClass);
end;
constructor TExtensionList.Create;
begin
inherited Create;
Add(bsPlainTextExtension, TGIFTextExtension);
Add(bsGraphicControlExtension, TGIFGraphicControlExtension);
Add(bsCommentExtension, TGIFCommentExtension);
Add(bsApplicationExtension, TGIFApplicationExtension);
end;
destructor TExtensionList.Destroy;
var
I: Integer;
begin
for I := 0 to Count-1 do
Dispose(PExtRec(Items[I]));
inherited Destroy;
end;
procedure TExtensionList.Add(eLabel: BYTE; eClass: TGIFExtensionClass);
var
NewRec: PExtRec;
begin
New(NewRec);
with NewRec^ do
begin
ExtLabel := eLabel;
ExtClass := eClass;
end;
inherited Add(NewRec);
end;
function TExtensionList.FindExt(eLabel: BYTE): TGIFExtensionClass;
var
I: Integer;
begin
for I := Count-1 downto 0 do
with PExtRec(Items[I])^ do
if ExtLabel = eLabel then
begin
Result := ExtClass;
Exit;
end;
Result := nil;
end;
procedure TExtensionList.Remove(eClass: TGIFExtensionClass);
var
I: Integer;
P: PExtRec;
begin
for I := Count-1 downto 0 do
begin
P := PExtRec(Items[I]);
if P^.ExtClass.InheritsFrom(eClass) then
begin
Dispose(P);
Delete(I);
end;
end;
end;
var
ExtensionList: TExtensionList = nil;
function GetExtensionList: TExtensionList;
begin
if (ExtensionList = nil) then
ExtensionList := TExtensionList.Create;
Result := ExtensionList;
end;
////////////////////////////////////////////////////////////////////////////////
//
// TGIFExtension
//
////////////////////////////////////////////////////////////////////////////////
function TGIFExtension.GetVersion: TGIFVersion;
begin
Result := gv89a;
end;
class procedure TGIFExtension.RegisterExtension(eLabel: BYTE; eClass: TGIFExtensionClass);
begin
GetExtensionList.Add(eLabel, eClass);
end;
class function TGIFExtension.FindExtension(Stream: TStream): TGIFExtensionClass;
var
eLabel : BYTE;
SubClass : TGIFExtensionClass;
Pos : LongInt;
begin
Pos := Stream.Position;
if (Stream.Read(eLabel, 1) <> 1) then
begin
Result := nil;
exit;
end;
Result := GetExtensionList.FindExt(eLabel);
while (Result <> nil) do
begin
SubClass := Result.FindSubExtension(Stream);
if (SubClass = Result) then
break;
Result := SubClass;
end;
Stream.Position := Pos;
end;
class function TGIFExtension.FindSubExtension(Stream: TStream): TGIFExtensionClass;
begin
Result := self;
end;
constructor TGIFExtension.Create(ASubImage: TGIFSubImage);
begin
inherited Create(ASubImage.Image);
FSubImage := ASubImage;
end;
destructor TGIFExtension.Destroy;
begin
if (FSubImage <> nil) then
FSubImage.Extensions.Remove(self);
inherited Destroy;
end;
procedure TGIFExtension.SaveToStream(Stream: TStream);
var
ExtensionLeadIn : TExtensionLeadIn;
begin
ExtensionLeadIn.Introducer := bsExtensionIntroducer;
ExtensionLeadIn.ExtensionLabel := ExtensionType;
Stream.Write(ExtensionLeadIn, sizeof(ExtensionLeadIn));
end;
function TGIFExtension.DoReadFromStream(Stream: TStream): TGIFExtensionType;
var
ExtensionLeadIn : TExtensionLeadIn;
begin
ReadCheck(Stream, ExtensionLeadIn, sizeof(ExtensionLeadIn));
if (ExtensionLeadIn.Introducer <> bsExtensionIntroducer) then
Error(sBadExtensionLabel);
Result := ExtensionLeadIn.ExtensionLabel;
end;
procedure TGIFExtension.LoadFromStream(Stream: TStream);
begin
// Seek past lead-in
// Stream.Seek(sizeof(TExtensionLeadIn), soFromCurrent);
if (DoReadFromStream(Stream) <> ExtensionType) then
Error(sBadExtensionInstance);
end;
////////////////////////////////////////////////////////////////////////////////
//
// TGIFGraphicControlExtension
//
////////////////////////////////////////////////////////////////////////////////
const
{ Extension flag bit masks }
efInputFlag = $02; { 00000010 }
efDisposal = $1C; { 00011100 }
efTransparent = $01; { 00000001 }
efReserved = $E0; { 11100000 }
constructor TGIFGraphicControlExtension.Create(ASubImage: TGIFSubImage);
begin
inherited Create(ASubImage);
FGCExtension.BlockSize := 4;
FGCExtension.PackedFields := $00;
FGCExtension.DelayTime := 0;
FGCExtension.TransparentColorIndex := 0;
FGCExtension.Terminator := 0;
if (ASubImage.FGCE = nil) then
ASubImage.FGCE := self;
end;
destructor TGIFGraphicControlExtension.Destroy;
begin
// Clear transparent flag in sub image
if (Transparent) then
SubImage.FTransparent := False;
if (SubImage.FGCE = self) then
SubImage.FGCE := nil;
inherited Destroy;
end;
function TGIFGraphicControlExtension.GetExtensionType: TGIFExtensionType;
begin
Result := bsGraphicControlExtension;
end;
function TGIFGraphicControlExtension.GetTransparent: boolean;
begin
Result := (FGCExtension.PackedFields AND efTransparent) <> 0;
end;
procedure TGIFGraphicControlExtension.SetTransparent(Value: boolean);
begin
// Set transparent flag in sub image
SubImage.FTransparent := Value;
if (Value) then
FGCExtension.PackedFields := FGCExtension.PackedFields OR efTransparent
else
FGCExtension.PackedFields := FGCExtension.PackedFields AND NOT(efTransparent);
end;
function TGIFGraphicControlExtension.GetTransparentColor: TColor;
begin
Result := SubImage.ActiveColorMap[TransparentColorIndex];
end;
procedure TGIFGraphicControlExtension.SetTransparentColor(Color: TColor);
begin
FGCExtension.TransparentColorIndex := Subimage.ActiveColorMap.AddUnique(Color);
end;
function TGIFGraphicControlExtension.GetTransparentColorIndex: BYTE;
begin
Result := FGCExtension.TransparentColorIndex;
end;
procedure TGIFGraphicControlExtension.SetTransparentColorIndex(Value: BYTE);
begin
if ((Value >= SubImage.ActiveColorMap.Count) and (SubImage.ActiveColorMap.Count > 0)) then
begin
Warning(gsWarning, sBadColorIndex);
Value := 0;
end;
FGCExtension.TransparentColorIndex := Value;
end;
function TGIFGraphicControlExtension.GetDelay: WORD;
begin
Result := FGCExtension.DelayTime;
end;
procedure TGIFGraphicControlExtension.SetDelay(Value: WORD);
begin
FGCExtension.DelayTime := Value;
end;
function TGIFGraphicControlExtension.GetUserInput: boolean;
begin
Result := (FGCExtension.PackedFields AND efInputFlag) <> 0;
end;
procedure TGIFGraphicControlExtension.SetUserInput(Value: boolean);
begin
if (Value) then
FGCExtension.PackedFields := FGCExtension.PackedFields OR efInputFlag
else
FGCExtension.PackedFields := FGCExtension.PackedFields AND NOT(efInputFlag);
end;
function TGIFGraphicControlExtension.GetDisposal: TDisposalMethod;
begin
Result := TDisposalMethod((FGCExtension.PackedFields AND efDisposal) SHR 2);
end;
procedure TGIFGraphicControlExtension.SetDisposal(Value: TDisposalMethod);
begin
FGCExtension.PackedFields := FGCExtension.PackedFields AND NOT(efDisposal)
OR ((ord(Value) SHL 2) AND efDisposal);
end;
procedure TGIFGraphicControlExtension.SaveToStream(Stream: TStream);
begin
inherited SaveToStream(Stream);
Stream.Write(FGCExtension, sizeof(FGCExtension));
end;
procedure TGIFGraphicControlExtension.LoadFromStream(Stream: TStream);
begin
inherited LoadFromStream(Stream);
if (Stream.Read(FGCExtension, sizeof(FGCExtension)) <> sizeof(FGCExtension)) then
begin
Warning(gsWarning, sOutOfData);
exit;
end;
// Set transparent flag in sub image
if (Transparent) then
SubImage.FTransparent := True;
end;
////////////////////////////////////////////////////////////////////////////////
//
// TGIFTextExtension
//
////////////////////////////////////////////////////////////////////////////////
constructor TGIFTextExtension.Create(ASubImage: TGIFSubImage);
begin
inherited Create(ASubImage);
FText := TStringList.Create;
FPlainTextExtension.BlockSize := 12;
FPlainTextExtension.Left := 0;
FPlainTextExtension.Top := 0;
FPlainTextExtension.Width := 0;
FPlainTextExtension.Height := 0;
FPlainTextExtension.CellWidth := 0;
FPlainTextExtension.CellHeight := 0;
FPlainTextExtension.TextFGColorIndex := 0;
FPlainTextExtension.TextBGColorIndex := 0;
end;
destructor TGIFTextExtension.Destroy;
begin
FText.Free;
inherited Destroy;
end;
function TGIFTextExtension.GetExtensionType: TGIFExtensionType;
begin
Result := bsPlainTextExtension;
end;
function TGIFTextExtension.GetForegroundColor: TColor;
begin
Result := SubImage.ColorMap[ForegroundColorIndex];
end;
procedure TGIFTextExtension.SetForegroundColor(Color: TColor);
begin
ForegroundColorIndex := SubImage.ActiveColorMap.AddUnique(Color);
end;
function TGIFTextExtension.GetBackgroundColor: TColor;
begin
Result := SubImage.ActiveColorMap[BackgroundColorIndex];
end;
procedure TGIFTextExtension.SetBackgroundColor(Color: TColor);
begin
BackgroundColorIndex := SubImage.ColorMap.AddUnique(Color);
end;
function TGIFTextExtension.GetBounds(Index: integer): WORD;
begin
case (Index) of
1: Result := FPlainTextExtension.Left;
2: Result := FPlainTextExtension.Top;
3: Result := FPlainTextExtension.Width;
4: Result := FPlainTextExtension.Height;
else
Result := 0; // To avoid compiler warnings
end;
end;
procedure TGIFTextExtension.SetBounds(Index: integer; Value: WORD);
begin
case (Index) of
1: FPlainTextExtension.Left := Value;
2: FPlainTextExtension.Top := Value;
3: FPlainTextExtension.Width := Value;
4: FPlainTextExtension.Height := Value;
end;
end;
function TGIFTextExtension.GetCharWidthHeight(Index: integer): BYTE;
begin
case (Index) of
1: Result := FPlainTextExtension.CellWidth;
2: Result := FPlainTextExtension.CellHeight;
else
Result := 0; // To avoid compiler warnings
end;
end;
procedure TGIFTextExtension.SetCharWidthHeight(Index: integer; Value: BYTE);
begin
case (Index) of
1: FPlainTextExtension.CellWidth := Value;
2: FPlainTextExtension.CellHeight := Value;
end;
end;
function TGIFTextExtension.GetColorIndex(Index: integer): BYTE;
begin
case (Index) of
1: Result := FPlainTextExtension.TextFGColorIndex;
2: Result := FPlainTextExtension.TextBGColorIndex;
else
Result := 0; // To avoid compiler warnings
end;
end;
procedure TGIFTextExtension.SetColorIndex(Index: integer; Value: BYTE);
begin
case (Index) of
1: FPlainTextExtension.TextFGColorIndex := Value;
2: FPlainTextExtension.TextBGColorIndex := Value;
end;
end;
procedure TGIFTextExtension.SaveToStream(Stream: TStream);
begin
inherited SaveToStream(Stream);
Stream.Write(FPlainTextExtension, sizeof(FPlainTextExtension));
WriteStrings(Stream, FText);
end;
procedure TGIFTextExtension.LoadFromStream(Stream: TStream);
begin
inherited LoadFromStream(Stream);
ReadCheck(Stream, FPlainTextExtension, sizeof(FPlainTextExtension));
ReadStrings(Stream, FText);
end;
////////////////////////////////////////////////////////////////////////////////
//
// TGIFCommentExtension
//
////////////////////////////////////////////////////////////////////////////////
constructor TGIFCommentExtension.Create(ASubImage: TGIFSubImage);
begin
inherited Create(ASubImage);
FText := TStringList.Create;
end;
destructor TGIFCommentExtension.Destroy;
begin
FText.Free;
inherited Destroy;
end;
function TGIFCommentExtension.GetExtensionType: TGIFExtensionType;
begin
Result := bsCommentExtension;
end;
procedure TGIFCommentExtension.SaveToStream(Stream: TStream);
begin
inherited SaveToStream(Stream);
WriteStrings(Stream, FText);
end;
procedure TGIFCommentExtension.LoadFromStream(Stream: TStream);
begin
inherited LoadFromStream(Stream);
ReadStrings(Stream, FText);
end;
////////////////////////////////////////////////////////////////////////////////
//
// TGIFApplicationExtension registration database
//
////////////////////////////////////////////////////////////////////////////////
type
PAppExtRec = ^TAppExtRec;
TAppExtRec = record
AppClass: TGIFAppExtensionClass;
Ident: TGIFApplicationRec;
end;
TAppExtensionList = class(TList)
public
constructor Create;
destructor Destroy; override;
procedure Add(eIdent: TGIFApplicationRec; eClass: TGIFAppExtensionClass);
function FindExt(eIdent: TGIFApplicationRec): TGIFAppExtensionClass;
procedure Remove(eClass: TGIFAppExtensionClass);
end;
constructor TAppExtensionList.Create;
const
NSLoopIdent: array[0..1] of TGIFApplicationRec =
((Identifier: 'NETSCAPE'; Authentication: '2.0'),
(Identifier: 'ANIMEXTS'; Authentication: '1.0'));
begin
inherited Create;
Add(NSLoopIdent[0], TGIFAppExtNSLoop);
Add(NSLoopIdent[1], TGIFAppExtNSLoop);
end;
destructor TAppExtensionList.Destroy;
var
I: Integer;
begin
for I := 0 to Count-1 do
Dispose(PAppExtRec(Items[I]));
inherited Destroy;
end;
procedure TAppExtensionList.Add(eIdent: TGIFApplicationRec; eClass: TGIFAppExtensionClass);
var
NewRec: PAppExtRec;
begin
New(NewRec);
NewRec^.Ident := eIdent;
NewRec^.AppClass := eClass;
inherited Add(NewRec);
end;
function TAppExtensionList.FindExt(eIdent: TGIFApplicationRec): TGIFAppExtensionClass;
var
I: Integer;
begin
for I := Count-1 downto 0 do
with PAppExtRec(Items[I])^ do
if CompareMem(@Ident, @eIdent, sizeof(TGIFApplicationRec)) then
begin
Result := AppClass;
Exit;
end;
Result := nil;
end;
procedure TAppExtensionList.Remove(eClass: TGIFAppExtensionClass);
var
I: Integer;
P: PAppExtRec;
begin
for I := Count-1 downto 0 do
begin
P := PAppExtRec(Items[I]);
if P^.AppClass.InheritsFrom(eClass) then
begin
Dispose(P);
Delete(I);
end;
end;
end;
var
AppExtensionList: TAppExtensionList = nil;
function GetAppExtensionList: TAppExtensionList;
begin
if (AppExtensionList = nil) then
AppExtensionList := TAppExtensionList.Create;
Result := AppExtensionList;
end;
class procedure TGIFApplicationExtension.RegisterExtension(eIdent: TGIFApplicationRec;
eClass: TGIFAppExtensionClass);
begin
GetAppExtensionList.Add(eIdent, eClass);
end;
class function TGIFApplicationExtension.FindSubExtension(Stream: TStream): TGIFExtensionClass;
var
eIdent : TGIFApplicationRec;
OldPos : longInt;
Size : BYTE;
begin
OldPos := Stream.Position;
Result := nil;
if (Stream.Read(Size, 1) <> 1) then
exit;
// Some old Adobe export filters mistakenly uses a value of 10
if (Size = 10) then
begin
{ TODO -oanme -cImprovement : replace with seek or read and check contents = 'Adobe' }
if (Stream.Read(eIdent, 10) <> 10) then
exit;
Result := TGIFUnknownAppExtension;
exit;
end else
if (Size <> sizeof(TGIFApplicationRec)) or
(Stream.Read(eIdent, sizeof(eIdent)) <> sizeof(eIdent)) then
begin
Stream.Position := OldPos;
Result := inherited FindSubExtension(Stream);
end else
begin
Result := GetAppExtensionList.FindExt(eIdent);
if (Result = nil) then
Result := TGIFUnknownAppExtension;
end;
end;
////////////////////////////////////////////////////////////////////////////////
//
// TGIFApplicationExtension
//
////////////////////////////////////////////////////////////////////////////////
constructor TGIFApplicationExtension.Create(ASubImage: TGIFSubImage);
begin
inherited Create(ASubImage);
FillChar(FIdent, sizeof(FIdent), 0);
end;
destructor TGIFApplicationExtension.Destroy;
begin
inherited Destroy;
end;
function TGIFApplicationExtension.GetExtensionType: TGIFExtensionType;
begin
Result := bsApplicationExtension;
end;
function TGIFApplicationExtension.GetAuthentication: string;
begin
Result := FIdent.Authentication;
end;
procedure TGIFApplicationExtension.SetAuthentication(const Value: string);
begin
if (Length(Value) < sizeof(TGIFAuthenticationCode)) then
FillChar(FIdent.Authentication, sizeof(TGIFAuthenticationCode), 32);
StrLCopy(@(FIdent.Authentication[0]), PChar(Value), sizeof(TGIFAuthenticationCode));
end;
function TGIFApplicationExtension.GetIdentifier: string;
begin
Result := FIdent.Identifier;
end;
procedure TGIFApplicationExtension.SetIdentifier(const Value: string);
begin
if (Length(Value) < sizeof(TGIFIdentifierCode)) then
FillChar(FIdent.Identifier, sizeof(TGIFIdentifierCode), 32);
StrLCopy(@(FIdent.Identifier[0]), PChar(Value), sizeof(TGIFIdentifierCode));
end;
procedure TGIFApplicationExtension.SaveToStream(Stream: TStream);
begin
inherited SaveToStream(Stream);
WriteByte(Stream, sizeof(FIdent)); // Block size
Stream.Write(FIdent, sizeof(FIdent));
SaveData(Stream);
end;
procedure TGIFApplicationExtension.LoadFromStream(Stream: TStream);
var
i : integer;
begin
inherited LoadFromStream(Stream);
i := ReadByte(Stream);
// Some old Adobe export filters mistakenly uses a value of 10
if (i = 10) then
FillChar(FIdent, sizeOf(FIdent), 0)
else
if (i < 11) then
Error(sBadBlockSize);
ReadCheck(Stream, FIdent, sizeof(FIdent));
Dec(i, sizeof(FIdent));
// Ignore extra data
Stream.Seek(i, soFromCurrent);
// ***FIXME***
// If self class is TGIFApplicationExtension, this will cause an "abstract
// error".
// TGIFApplicationExtension.LoadData should read and ignore rest of block.
LoadData(Stream);
end;
////////////////////////////////////////////////////////////////////////////////
//
// TGIFUnknownAppExtension
//
////////////////////////////////////////////////////////////////////////////////
constructor TGIFBlock.Create(ASize: integer);
begin
inherited Create;
FSize := ASize;
GetMem(FData, FSize);
FillChar(FData^, FSize, 0);
end;
destructor TGIFBlock.Destroy;
begin
FreeMem(FData);
inherited Destroy;
end;
procedure TGIFBlock.SaveToStream(Stream: TStream);
begin
Stream.Write(FSize, 1);
Stream.Write(FData^, FSize);
end;
procedure TGIFBlock.LoadFromStream(Stream: TStream);
begin
ReadCheck(Stream, FData^, FSize);
end;
constructor TGIFUnknownAppExtension.Create(ASubImage: TGIFSubImage);
begin
inherited Create(ASubImage);
FBlocks := TList.Create;
end;
destructor TGIFUnknownAppExtension.Destroy;
var
i : integer;
begin
for i := 0 to FBlocks.Count-1 do
TGIFBlock(FBlocks[i]).Free;
FBlocks.Free;
inherited Destroy;
end;
procedure TGIFUnknownAppExtension.SaveData(Stream: TStream);
var
i : integer;
begin
for i := 0 to FBlocks.Count-1 do
TGIFBlock(FBlocks[i]).SaveToStream(Stream);
// Terminating zero
WriteByte(Stream, 0);
end;
procedure TGIFUnknownAppExtension.LoadData(Stream: TStream);
var
b : BYTE;
Block : TGIFBlock;
i : integer;
begin
// Zap old blocks
for i := 0 to FBlocks.Count-1 do
TGIFBlock(FBlocks[i]).Free;
FBlocks.Clear;
// Read blocks
if (Stream.Read(b, 1) <> 1) then
exit;
while (b <> 0) do
begin
Block := TGIFBlock.Create(b);
try
Block.LoadFromStream(Stream);
except
Block.Free;
raise;
end;
FBlocks.Add(Block);
if (Stream.Read(b, 1) <> 1) then
exit;
end;
end;
////////////////////////////////////////////////////////////////////////////////
//
// TGIFAppExtNSLoop
//
////////////////////////////////////////////////////////////////////////////////
const
// Netscape sub block types
nbLoopExtension = 1;
nbBufferExtension = 2;
constructor TGIFAppExtNSLoop.Create(ASubImage: TGIFSubImage);
const
NSLoopIdent: TGIFApplicationRec = (Identifier: 'NETSCAPE'; Authentication: '2.0');
begin
inherited Create(ASubImage);
FIdent := NSLoopIdent;
end;
procedure TGIFAppExtNSLoop.SaveData(Stream: TStream);
begin
// Write loop count
WriteByte(Stream, 1 + sizeof(FLoops)); // Size of block
WriteByte(Stream, nbLoopExtension); // Identify sub block as looping extension data
Stream.Write(FLoops, sizeof(FLoops)); // Loop count
// Write buffer size if specified
if (FBufferSize > 0) then
begin
WriteByte(Stream, 1 + sizeof(FBufferSize)); // Size of block
WriteByte(Stream, nbBufferExtension); // Identify sub block as buffer size data
Stream.Write(FBufferSize, sizeof(FBufferSize)); // Buffer size
end;
WriteByte(Stream, 0); // Terminating zero
end;
procedure TGIFAppExtNSLoop.LoadData(Stream: TStream);
var
BlockSize : integer;
BlockType : integer;
begin
// Read size of first block or terminating zero
BlockSize := ReadByte(Stream);
while (BlockSize <> 0) do
begin
BlockType := ReadByte(Stream);
dec(BlockSize);
case (BlockType AND $07) of
nbLoopExtension:
begin
if (BlockSize < sizeof(FLoops)) then
Error(sInvalidData);
// Read loop count
ReadCheck(Stream, FLoops, sizeof(FLoops));
dec(BlockSize, sizeof(FLoops));
end;
nbBufferExtension:
begin
if (BlockSize < sizeof(FBufferSize)) then
Error(sInvalidData);
// Read buffer size
ReadCheck(Stream, FBufferSize, sizeof(FBufferSize));
dec(BlockSize, sizeof(FBufferSize));
end;
end;
// Skip/ignore unread data
if (BlockSize > 0) then
Stream.Seek(BlockSize, soFromCurrent);
// Read size of next block or terminating zero
BlockSize := ReadByte(Stream);
end;
end;
////////////////////////////////////////////////////////////////////////////////
//
// TGIFImageList
//
////////////////////////////////////////////////////////////////////////////////
function TGIFImageList.GetImage(Index: Integer): TGIFSubImage;
begin
Result := TGIFSubImage(Items[Index]);
end;
procedure TGIFImageList.SetImage(Index: Integer; SubImage: TGIFSubImage);
begin
Items[Index] := SubImage;
end;
procedure TGIFImageList.LoadFromStream(Stream: TStream; Parent: TObject);
var
b : BYTE;
SubImage : TGIFSubImage;
begin
// Peek ahead to determine block type
repeat
if (Stream.Read(b, 1) <> 1) then
exit;
until (b <> 0); // Ignore 0 padding (non-compliant)
while (b <> bsTrailer) do
begin
Stream.Seek(-1, soFromCurrent);
if (b in [bsExtensionIntroducer, bsImageDescriptor]) then
begin
SubImage := TGIFSubImage.Create(Parent as TGIFImage);
try
SubImage.LoadFromStream(Stream);
Add(SubImage);
Image.Progress(Self, psRunning, MulDiv(Stream.Position, 100, Stream.Size),
GIFImageRenderOnLoad, Rect(0,0,0,0), sProgressLoading);
except
SubImage.Free;
raise;
end;
end else
begin
Warning(gsWarning, sBadBlock);
break;
end;
repeat
if (Stream.Read(b, 1) <> 1) then
exit;
until (b <> 0); // Ignore 0 padding (non-compliant)
end;
Stream.Seek(-1, soFromCurrent);
end;
procedure TGIFImageList.SaveToStream(Stream: TStream);
var
i : integer;
begin
for i := 0 to Count-1 do
begin
TGIFItem(Items[i]).SaveToStream(Stream);
Image.Progress(Self, psRunning, MulDiv((i+1), 100, Count), False, Rect(0,0,0,0), sProgressSaving);
end;
end;
////////////////////////////////////////////////////////////////////////////////
//
// TGIFPainter
//
////////////////////////////////////////////////////////////////////////////////
constructor TGIFPainter.CreateRef(Painter: PGIFPainter; AImage: TGIFImage;
ACanvas: TCanvas; ARect: TRect; Options: TGIFDrawOptions);
begin
Create(AImage, ACanvas, ARect, Options);
PainterRef := Painter;
if (PainterRef <> nil) then
PainterRef^ := self;
end;
constructor TGIFPainter.Create(AImage: TGIFImage; ACanvas: TCanvas; ARect: TRect;
Options: TGIFDrawOptions);
var
i : integer;
BackgroundColor : TColor;
Disposals : set of TDisposalMethod;
begin
inherited Create(True);
FreeOnTerminate := True;
Onterminate := DoOnTerminate;
FImage := AImage;
FCanvas := ACanvas;
FRect := ARect;
FActiveImage := -1;
FDrawOptions := Options;
FStarted := False;
BackupBuffer := nil;
FrameBuffer := nil;
Background := nil;
FEventHandle := 0;
// This should be a parameter, but I think I've got enough of them already...
FAnimationSpeed := FImage.AnimationSpeed;
// An event handle is used for animation delays
if (FDrawOptions >= [goAnimate, goAsync]) and (FImage.Images.Count > 1) and
(FAnimationSpeed >= 0) then
FEventHandle := CreateEvent(nil, False, False, nil);
// Preprocessing of extensions to determine if we need frame buffers
Disposals := [];
if (FImage.DrawBackgroundColor = clNone) then
begin
if (FImage.GlobalColorMap.Count > 0) then
BackgroundColor := FImage.BackgroundColor
else
BackgroundColor := ColorToRGB(clWindow);
end else
BackgroundColor := ColorToRGB(FImage.DrawBackgroundColor);
// Need background buffer to clear on loop
if (goClearOnLoop in FDrawOptions) then
Include(Disposals, dmBackground);
for i := 0 to FImage.Images.Count-1 do
if (FImage.Images[i].GraphicControlExtension <> nil) then
with (FImage.Images[i].GraphicControlExtension) do
Include(Disposals, Disposal);
// Need background buffer to draw transparent on background
if (dmBackground in Disposals) and (goTransparent in FDrawOptions) then
begin
Background := TBitmap.Create;
Background.Height := FRect.Bottom-FRect.Top;
Background.Width := FRect.Right-FRect.Left;
// Copy background immediately
Background.Canvas.CopyMode := cmSrcCopy;
Background.Canvas.CopyRect(Background.Canvas.ClipRect, FCanvas, FRect);
end;
// Need frame- and backup buffer to restore to previous and background
if ((Disposals * [dmPrevious, dmBackground]) <> []) then
begin
BackupBuffer := TBitmap.Create;
BackupBuffer.Height := FRect.Bottom-FRect.Top;
BackupBuffer.Width := FRect.Right-FRect.Left;
BackupBuffer.Canvas.CopyMode := cmSrcCopy;
BackupBuffer.Canvas.Brush.Color := BackgroundColor;
BackupBuffer.Canvas.Brush.Style := bsSolid;
{$IFDEF DEBUG}
BackupBuffer.Canvas.Brush.Color := clBlack;
BackupBuffer.Canvas.Brush.Style := bsDiagCross;
{$ENDIF}
// Step 1: Copy destination to backup buffer
// Always executed before first frame and only once.
BackupBuffer.Canvas.CopyRect(BackupBuffer.Canvas.ClipRect, FCanvas, FRect);
FrameBuffer := TBitmap.Create;
FrameBuffer.Height := FRect.Bottom-FRect.Top;
FrameBuffer.Width := FRect.Right-FRect.Left;
FrameBuffer.Canvas.CopyMode := cmSrcCopy;
FrameBuffer.Canvas.Brush.Color := BackgroundColor;
FrameBuffer.Canvas.Brush.Style := bsSolid;
{$IFDEF DEBUG}
FrameBuffer.Canvas.Brush.Color := clBlack;
FrameBuffer.Canvas.Brush.Style := bsDiagCross;
{$ENDIF}
end;
end;
destructor TGIFPainter.Destroy;
begin
// OnTerminate isn't called if we are running in main thread, so we must call
// it manually
if not(goAsync in DrawOptions) then
DoOnTerminate(self);
// Reraise any exptions that were eaten in the Execute method
if (ExceptObject <> nil) then
raise ExceptObject at ExceptAddress;
inherited Destroy;
end;
procedure TGIFPainter.SetAnimationSpeed(Value: integer);
begin
if (Value < 0) then
Value := 0
else if (Value > 1000) then
Value := 1000;
if (Value <> FAnimationSpeed) then
begin
FAnimationSpeed := Value;
// Signal WaitForSingleObject delay to abort
if (FEventHandle <> 0) then
SetEvent(FEventHandle)
else
DoRestart := True;
end;
end;
procedure TGIFPainter.SetActiveImage(const Value: integer);
begin
if (Value >= 0) and (Value < FImage.Images.Count) then
FActiveImage := Value;
end;
// Conditional Synchronize
procedure TGIFPainter.DoSynchronize(Method: TThreadMethod);
begin
if (Terminated) then
exit;
if (goAsync in FDrawOptions) then
// Execute Synchronized if requested...
Synchronize(Method)
else
// ...Otherwise just execute in current thread (probably main thread)
Method;
end;
// Delete frame buffers - Executed in main thread
procedure TGIFPainter.DoOnTerminate(Sender: TObject);
begin
// It shouldn't really be nescessary to protect PainterRef in this manner
// since we are running in the main thread at this point, but I'm a little
// paranoid about the way PainterRef is being used...
if Image <> nil then // 2001.02.23
begin // 2001.02.23
with Image.Painters.LockList do
try
// Zap pointer to self and remove from painter list
if (PainterRef <> nil) and (PainterRef^ = self) then
PainterRef^ := nil;
finally
Image.Painters.UnLockList;
end;
Image.Painters.Remove(self);
FImage := nil;
end; // 2001.02.23
// Free buffers
if (BackupBuffer <> nil) then
BackupBuffer.Free;
if (FrameBuffer <> nil) then
FrameBuffer.Free;
if (Background <> nil) then
Background.Free;
// Delete event handle
if (FEventHandle <> 0) then
CloseHandle(FEventHandle);
end;
// Event "dispatcher" - Executed in main thread
procedure TGIFPainter.DoEvent;
begin
if (Assigned(FEvent)) then
FEvent(self);
end;
// Non-buffered paint - Executed in main thread
procedure TGIFPainter.DoPaint;
begin
FImage.Images[ActiveImage].Draw(FCanvas, FRect, (goTransparent in FDrawOptions),
(goTile in FDrawOptions));
FStarted := True;
end;
// Buffered paint - Executed in main thread
procedure TGIFPainter.DoPaintFrame;
var
DrawDestination : TCanvas;
DrawRect : TRect;
DoStep2 ,
DoStep3 ,
DoStep5 ,
DoStep6 : boolean;
SavePal ,
SourcePal : HPALETTE;
procedure ClearBackup;
var
r ,
Tile : TRect;
FrameTop ,
FrameHeight : integer;
ImageWidth ,
ImageHeight : integer;
begin
if (goTransparent in FDrawOptions) then
begin
// If the frame is transparent, we must remove it by copying the
// background buffer over it
if (goTile in FDrawOptions) then
begin
FrameTop := FImage.Images[ActiveImage].Top;
FrameHeight := FImage.Images[ActiveImage].Height;
ImageWidth := FImage.Width;
ImageHeight := FImage.Height;
Tile.Left := FRect.Left + FImage.Images[ActiveImage].Left;
Tile.Right := Tile.Left + FImage.Images[ActiveImage].Width;
while (Tile.Left < FRect.Right) do
begin
Tile.Top := FRect.Top + FrameTop;
Tile.Bottom := Tile.Top + FrameHeight;
while (Tile.Top < FRect.Bottom) do
begin
BackupBuffer.Canvas.CopyRect(Tile, Background.Canvas, Tile);
Tile.Top := Tile.Top + ImageHeight;
Tile.Bottom := Tile.Bottom + ImageHeight;
end;
Tile.Left := Tile.Left + ImageWidth;
Tile.Right := Tile.Right + ImageWidth;
end;
end else
begin
r := FImage.Images[ActiveImage].ScaleRect(BackupBuffer.Canvas.ClipRect);
BackupBuffer.Canvas.CopyRect(r, Background.Canvas, r)
end;
end else
begin
// If the frame isn't transparent, we just clear the area covered by
// it to the background color.
// Tile the background unless the frame covers all of the image
if (goTile in FDrawOptions) and
((FImage.Width <> FImage.Images[ActiveImage].Width) and
(FImage.height <> FImage.Images[ActiveImage].Height)) then
begin
FrameTop := FImage.Images[ActiveImage].Top;
FrameHeight := FImage.Images[ActiveImage].Height;
ImageWidth := FImage.Width;
ImageHeight := FImage.Height;
// ***FIXME*** I don't think this does any difference
BackupBuffer.Canvas.Brush.Color := FImage.DrawBackgroundColor;
Tile.Left := FRect.Left + FImage.Images[ActiveImage].Left;
Tile.Right := Tile.Left + FImage.Images[ActiveImage].Width;
while (Tile.Left < FRect.Right) do
begin
Tile.Top := FRect.Top + FrameTop;
Tile.Bottom := Tile.Top + FrameHeight;
while (Tile.Top < FRect.Bottom) do
begin
BackupBuffer.Canvas.FillRect(Tile);
Tile.Top := Tile.Top + ImageHeight;
Tile.Bottom := Tile.Bottom + ImageHeight;
end;
Tile.Left := Tile.Left + ImageWidth;
Tile.Right := Tile.Right + ImageWidth;
end;
end else
BackupBuffer.Canvas.FillRect(FImage.Images[ActiveImage].ScaleRect(FRect));
end;
end;
begin
if (goValidateCanvas in FDrawOptions) then
if (GetObjectType(ValidateDC) <> OBJ_DC) then
begin
Terminate;
exit;
end;
DrawDestination := nil;
DoStep2 := (goClearOnLoop in FDrawOptions) and (FActiveImage = 0);
DoStep3 := False;
DoStep5 := False;
DoStep6 := False;
{
Disposal mode algorithm:
Step 1: Copy destination to backup buffer
Always executed before first frame and only once.
Done in constructor.
Step 2: Clear previous frame (implementation is same as step 6)
Done implicitly by implementation.
Only done explicitly on first frame if goClearOnLoop option is set.
Step 3: Copy backup buffer to frame buffer
Step 4: Draw frame
Step 5: Copy buffer to destination
Step 6: Clear frame from backup buffer
+------------+------------------+---------------------+------------------------+
|New \ Old | dmNone | dmBackground | dmPrevious |
+------------+------------------+---------------------+------------------------+
|dmNone | | | |
| |4. Paint on backup|4. Paint on backup |4. Paint on backup |
| |5. Restore |5. Restore |5. Restore |
+------------+------------------+---------------------+------------------------+
|dmBackground| | | |
| |4. Paint on backup|4. Paint on backup |4. Paint on backup |
| |5. Restore |5. Restore |5. Restore |
| |6. Clear backup |6. Clear backup |6. Clear backup |
+------------+------------------+---------------------+------------------------+
|dmPrevious | | | |
| | |3. Copy backup to buf|3. Copy backup to buf |
| |4. Paint on dest |4. Paint on buf |4. Paint on buf |
| | |5. Copy buf to dest |5. Copy buf to dest |
+------------+------------------+---------------------+------------------------+
}
case (Disposal) of
dmNone, dmNoDisposal:
begin
DrawDestination := BackupBuffer.Canvas;
DrawRect := BackupBuffer.Canvas.ClipRect;
DoStep5 := True;
end;
dmBackground:
begin
DrawDestination := BackupBuffer.Canvas;
DrawRect := BackupBuffer.Canvas.ClipRect;
DoStep5 := True;
DoStep6 := True;
end;
dmPrevious:
case (OldDisposal) of
dmNone, dmNoDisposal:
begin
DrawDestination := FCanvas;
DrawRect := FRect;
end;
dmBackground, dmPrevious:
begin
DrawDestination := FrameBuffer.Canvas;
DrawRect := FrameBuffer.Canvas.ClipRect;
DoStep3 := True;
DoStep5 := True;
end;
end;
end;
// Find source palette
SourcePal := FImage.Images[ActiveImage].Palette;
if (SourcePal = 0) then
SourcePal := SystemPalette16; // This should never happen
SavePal := SelectPalette(DrawDestination.Handle, SourcePal, False);
RealizePalette(DrawDestination.Handle);
// Step 2: Clear previous frame
if (DoStep2) then
ClearBackup;
// Step 3: Copy backup buffer to frame buffer
if (DoStep3) then
FrameBuffer.Canvas.CopyRect(FrameBuffer.Canvas.ClipRect,
BackupBuffer.Canvas, BackupBuffer.Canvas.ClipRect);
// Step 4: Draw frame
if (DrawDestination <> nil) then
FImage.Images[ActiveImage].Draw(DrawDestination, DrawRect,
(goTransparent in FDrawOptions), (goTile in FDrawOptions));
// Step 5: Copy buffer to destination
if (DoStep5) then
begin
FCanvas.CopyMode := cmSrcCopy;
FCanvas.CopyRect(FRect, DrawDestination, DrawRect);
end;
if (SavePal <> 0) then
SelectPalette(DrawDestination.Handle, SavePal, False);
// Step 6: Clear frame from backup buffer
if (DoStep6) then
ClearBackup;
FStarted := True;
end;
// Prefetch bitmap
// Used to force the GIF image to be rendered as a bitmap
{$ifdef SERIALIZE_RENDER}
procedure TGIFPainter.PrefetchBitmap;
begin
// Touch current bitmap to force bitmap to be rendered
if not((FImage.Images[ActiveImage].Empty) or (FImage.Images[ActiveImage].HasBitmap)) then
FImage.Images[ActiveImage].Bitmap;
end;
{$endif}
// Main thread execution loop - This is where it all happens...
procedure TGIFPainter.Execute;
var
i : integer;
LoopCount ,
LoopPoint : integer;
Looping : boolean;
Ext : TGIFExtension;
Msg : TMsg;
Delay ,
OldDelay ,
DelayUsed : longInt;
DelayStart ,
NewDelayStart : DWORD;
procedure FireEvent(Event: TNotifyEvent);
begin
if not(Assigned(Event)) then
exit;
FEvent := Event;
try
DoSynchronize(DoEvent);
finally
FEvent := nil;
end;
end;
begin
{
Disposal:
dmNone: Same as dmNodisposal
dmNoDisposal: Do not dispose
dmBackground: Clear with background color *)
dmPrevious: Previous image
*) Note: Background color should either be a BROWSER SPECIFIED Background
color (DrawBackgroundColor) or the background image if any frames are
transparent.
}
try
try
if (goValidateCanvas in FDrawOptions) then
ValidateDC := FCanvas.Handle;
DoRestart := True;
// Loop to restart paint
while (DoRestart) and not(Terminated) do
begin
FActiveImage := 0;
// Fire OnStartPaint event
// Note: ActiveImage may be altered by the event handler
FireEvent(FOnStartPaint);
FStarted := False;
DoRestart := False;
LoopCount := 1;
LoopPoint := FActiveImage;
Looping := False;
if (goAsync in DrawOptions) then
Delay := 0
else
Delay := 1; // Dummy to process messages
OldDisposal := dmNoDisposal;
// Fetch delay start time
DelayStart := timeGetTime;
OldDelay := 0;
// Loop to loop - duh!
while ((LoopCount <> 0) or (goLoopContinously in DrawOptions)) and
not(Terminated or DoRestart) do
begin
FActiveImage := LoopPoint;
// Fire OnLoopPaint event
// Note: ActiveImage may be altered by the event handler
if (FStarted) then
FireEvent(FOnLoop);
// Loop to animate
while (ActiveImage < FImage.Images.Count) and not(Terminated or DoRestart) do
begin
// Ignore empty images
if (FImage.Images[ActiveImage].Empty) then
break;
// Delay from previous image
if (Delay > 0) then
begin
// Prefetch frame bitmap
{$ifdef SERIALIZE_RENDER}
DoSynchronize(PrefetchBitmap);
{$else}
FImage.Images[ActiveImage].Bitmap;
{$endif}
// Calculate inter frame delay
NewDelayStart := timeGetTime;
if (FAnimationSpeed > 0) then
begin
// Calculate number of mS used in prefetch and display
try
DelayUsed := integer(NewDelayStart-DelayStart)-OldDelay;
// Prevent feedback oscillations caused by over/undercompensation.
DelayUsed := DelayUsed DIV 2;
// Convert delay value to mS and...
// ...Adjust for time already spent converting GIF to bitmap and...
// ...Adjust for Animation Speed factor.
Delay := MulDiv(Delay * GIFDelayExp - DelayUsed, 100, FAnimationSpeed);
OldDelay := Delay;
except
Delay := GIFMaximumDelay * GIFDelayExp;
OldDelay := 0;
end;
end else
begin
if (goAsync in DrawOptions) then
Delay := longInt(INFINITE)
else
Delay := GIFMaximumDelay * GIFDelayExp;
end;
// Fetch delay start time
DelayStart := NewDelayStart;
// Sleep in one chunk if we are running in a thread
if (goAsync in DrawOptions) then
begin
// Use of WaitForSingleObject allows TGIFPainter.Stop to wake us up
if (Delay > 0) or (FAnimationSpeed = 0) then
begin
if (WaitForSingleObject(FEventHandle, DWORD(Delay)) <> WAIT_TIMEOUT) then
begin
// Don't use interframe delay feedback adjustment if delay
// were prematurely aborted (e.g. because the animation
// speed were changed)
OldDelay := 0;
DelayStart := longInt(timeGetTime);
end;
end;
end else
begin
if (Delay <= 0) then
Delay := 1;
// Fetch start time
NewDelayStart := timeGetTime;
// If we are not running in a thread we Sleep in small chunks
// and give the user a chance to abort
while (Delay > 0) and not(Terminated or DoRestart) do
begin
if (Delay < 100) then
Sleep(Delay)
else
Sleep(100);
// Calculate number of mS delayed in this chunk
DelayUsed := integer(timeGetTime - NewDelayStart);
dec(Delay, DelayUsed);
// Reset start time for chunk
NewDelaySTart := timeGetTime;
// Application.ProcessMessages wannabe
while (not(Terminated or DoRestart)) and
(PeekMessage(Msg, 0, 0, 0, PM_REMOVE)) do
begin
if (Msg.Message <> WM_QUIT) then
begin
TranslateMessage(Msg);
DispatchMessage(Msg);
end else
begin
// Put WM_QUIT back in queue and get out of here fast
PostQuitMessage(Msg.WParam);
Terminate;
end;
end;
end;
end;
end else
Sleep(0); // Yield
if (Terminated) then
break;
// Fire OnPaint event
// Note: ActiveImage may be altered by the event handler
FireEvent(FOnPaint);
if (Terminated) then
break;
// Pre-draw processing of extensions
Disposal := dmNoDisposal;
for i := 0 to FImage.Images[ActiveImage].Extensions.Count-1 do
begin
Ext := FImage.Images[ActiveImage].Extensions[i];
if (Ext is TGIFAppExtNSLoop) then
begin
// Recursive loops not supported (or defined)
if (Looping) then
continue;
Looping := True;
LoopCount := TGIFAppExtNSLoop(Ext).Loops;
if ((LoopCount = 0) or (goLoopContinously in DrawOptions)) and
(goAsync in DrawOptions) then
LoopCount := -1; // Infinite if running in separate thread
{$IFNDEF STRICT_MOZILLA}
// Loop from this image and on
// Note: This is not standard behavior
LoopPoint := ActiveImage;
{$ENDIF}
end else
if (Ext is TGIFGraphicControlExtension) then
Disposal := TGIFGraphicControlExtension(Ext).Disposal;
end;
// Paint the image
if (BackupBuffer <> nil) then
DoSynchronize(DoPaintFrame)
else
DoSynchronize(DoPaint);
OldDisposal := Disposal;
if (Terminated) then
break;
Delay := GIFDefaultDelay; // Default delay
// Post-draw processing of extensions
if (FImage.Images[ActiveImage].GraphicControlExtension <> nil) then
if (FImage.Images[ActiveImage].GraphicControlExtension.Delay > 0) then
begin
Delay := FImage.Images[ActiveImage].GraphicControlExtension.Delay;
// Enforce minimum animation delay in compliance with Mozilla
if (Delay < GIFMinimumDelay) then
Delay := GIFMinimumDelay;
// Do not delay more than 10 seconds if running in main thread
if (Delay > GIFMaximumDelay) and not(goAsync in DrawOptions) then
Delay := GIFMaximumDelay; // Max 10 seconds
end;
// Fire OnAfterPaint event
// Note: ActiveImage may be altered by the event handler
i := FActiveImage;
FireEvent(FOnAfterPaint);
if (Terminated) then
break;
// Don't increment frame counter if event handler modified
// current frame
if (FActiveImage = i) then
Inc(FActiveImage);
// Nothing more to do unless we are animating
if not(goAnimate in DrawOptions) then
break;
end;
if (LoopCount > 0) then
Dec(LoopCount);
if ([goAnimate, goLoop] * DrawOptions <> [goAnimate, goLoop]) then
break;
end;
if (Terminated) then // 2001.07.23
break; // 2001.07.23
end;
FActiveImage := -1;
// Fire OnEndPaint event
FireEvent(FOnEndPaint);
finally
// If we are running in the main thread we will have to zap our self
if not(goAsync in DrawOptions) then
Free;
end;
except
on E: Exception do
begin
// Eat exception and terminate thread...
// If we allow the exception to abort the thread at this point, the
// application will hang since the thread destructor will never be called
// and the application will wait forever for the thread to die!
Terminate;
// Clone exception
ExceptObject := E.Create(E.Message);
ExceptAddress := ExceptAddr;
end;
end;
end;
procedure TGIFPainter.Start;
begin
if (goAsync in FDrawOptions) then
Resume;
end;
procedure TGIFPainter.Stop;
begin
Terminate;
if (goAsync in FDrawOptions) then
begin
// Signal WaitForSingleObject delay to abort
if (FEventHandle <> 0) then
SetEvent(FEventHandle);
Priority := tpNormal;
if (Suspended) then
Resume; // Must be running before we can terminate
end;
end;
procedure TGIFPainter.Restart;
begin
DoRestart := True;
if (Suspended) and (goAsync in FDrawOptions) then
Resume; // Must be running before we can terminate
end;
////////////////////////////////////////////////////////////////////////////////
//
// TColorMapOptimizer
//
////////////////////////////////////////////////////////////////////////////////
// Used by TGIFImage to optimize local color maps to a single global color map.
// The following algorithm is used:
// 1) Build a histogram for each image
// 2) Merge histograms
// 3) Sum equal colors and adjust max # of colors
// 4) Map entries > max to entries <= 256
// 5) Build new color map
// 6) Map images to new color map
////////////////////////////////////////////////////////////////////////////////
type
POptimizeEntry = ^TOptimizeEntry;
TColorRec = record
case byte of
0: (Value: integer);
1: (Color: TGIFColor);
2: (SameAs: POptimizeEntry); // Used if TOptimizeEntry.Count = 0
end;
TOptimizeEntry = record
Count : integer; // Usage count
OldIndex : integer; // Color OldIndex
NewIndex : integer; // NewIndex color OldIndex
Color : TColorRec; // Color value
end;
TOptimizeEntries = array[0..255] of TOptimizeEntry;
POptimizeEntries = ^TOptimizeEntries;
THistogram = class(TObject)
private
PHistogram : POptimizeEntries;
FCount : integer;
FColorMap : TGIFColorMap;
FList : TList;
FImages : TList;
public
constructor Create(AColorMap: TGIFColorMap);
destructor Destroy; override;
function ProcessSubImage(Image: TGIFSubImage): boolean;
function Prune: integer;
procedure MapImages(UseTransparency: boolean; NewTransparentColorIndex: byte);
property Count: integer read FCount;
property ColorMap: TGIFColorMap read FColorMap;
property List: TList read FList;
end;
TColorMapOptimizer = class(TObject)
private
FImage : TGIFImage;
FHistogramList : TList;
FHistogram : TList;
FColorMap : TColorMap;
FFinalCount : integer;
FUseTransparency : boolean;
FNewTransparentColorIndex: byte;
protected
procedure ProcessImage;
procedure MergeColors;
procedure MapColors;
procedure ReplaceColorMaps;
public
constructor Create(AImage: TGIFImage);
destructor Destroy; override;
procedure Optimize;
end;
function CompareColor(Item1, Item2: Pointer): integer;
begin
Result := POptimizeEntry(Item2)^.Color.Value - POptimizeEntry(Item1)^.Color.Value;
end;
function CompareCount(Item1, Item2: Pointer): integer;
begin
Result := POptimizeEntry(Item2)^.Count - POptimizeEntry(Item1)^.Count;
end;
constructor THistogram.Create(AColorMap: TGIFColorMap);
var
i : integer;
begin
inherited Create;
FCount := AColorMap.Count;
FColorMap := AColorMap;
FImages := TList.Create;
// Allocate memory for histogram
GetMem(PHistogram, FCount * sizeof(TOptimizeEntry));
FList := TList.Create;
FList.Capacity := FCount;
// Move data to histogram and initialize
for i := 0 to FCount-1 do
with PHistogram^[i] do
begin
FList.Add(@PHistogram^[i]);
OldIndex := i;
Count := 0;
Color.Value := 0;
Color.Color := AColorMap.Data^[i];
NewIndex := 256; // Used to signal unmapped
end;
end;
destructor THistogram.Destroy;
begin
FImages.Free;
FList.Free;
FreeMem(PHistogram);
inherited Destroy;
end;
//: Build a color histogram
function THistogram.ProcessSubImage(Image: TGIFSubImage): boolean;
var
Size : integer;
Pixel : PChar;
IsTransparent ,
WasTransparent : boolean;
OldTransparentColorIndex: byte;
begin
Result := False;
if (Image.Empty) then
exit;
FImages.Add(Image);
Pixel := Image.data;
Size := Image.Width * Image.Height;
IsTransparent := Image.Transparent;
if (IsTransparent) then
OldTransparentColorIndex := Image.GraphicControlExtension.TransparentColorIndex
else
OldTransparentColorIndex := 0; // To avoid compiler warning
WasTransparent := False;
(*
** Sum up usage count for each color
*)
while (Size > 0) do
begin
// Ignore transparent pixels
if (not IsTransparent) or (ord(Pixel^) <> OldTransparentColorIndex) then
begin
// Check for invalid color index
if (ord(Pixel^) >= FCount) then
begin
Pixel^ := #0; // ***FIXME*** Isn't this an error condition?
Image.Warning(gsWarning, sInvalidColor);
end;
with PHistogram^[ord(Pixel^)] do
begin
// Stop if any color reaches the max count
if (Count = high(integer)) then
break;
inc(Count);
end;
end else
WasTransparent := WasTransparent or IsTransparent;
inc(Pixel);
dec(Size);
end;
(*
** Clear frames transparency flag if the frame claimed to
** be transparent, but wasn't
*)
if (IsTransparent and not WasTransparent) then
begin
Image.GraphicControlExtension.TransparentColorIndex := 0;
Image.GraphicControlExtension.Transparent := False;
end;
Result := WasTransparent;
end;
//: Removed unused color entries from the histogram
function THistogram.Prune: integer;
var
i, j : integer;
begin
(*
** Sort by usage count
*)
FList.Sort(CompareCount);
(*
** Determine number of used colors
*)
for i := 0 to FCount-1 do
// Find first unused color entry
if (POptimizeEntry(FList[i])^.Count = 0) then
begin
// Zap unused colors
for j := i to FCount-1 do
POptimizeEntry(FList[j])^.Count := -1; // Use -1 to signal unused entry
// Remove unused entries
FCount := i;
FList.Count := FCount;
break;
end;
Result := FCount;
end;
//: Convert images from old color map to new color map
procedure THistogram.MapImages(UseTransparency: boolean; NewTransparentColorIndex: byte);
var
i : integer;
Size : integer;
Pixel : PChar;
ReverseMap : array[byte] of byte;
IsTransparent : boolean;
OldTransparentColorIndex: byte;
begin
(*
** Build NewIndex map
*)
for i := 0 to List.Count-1 do
ReverseMap[POptimizeEntry(List[i])^.OldIndex] := POptimizeEntry(List[i])^.NewIndex;
(*
** Reorder all images using this color map
*)
for i := 0 to FImages.Count-1 do
with TGIFSubImage(FImages[i]) do
begin
Pixel := Data;
Size := Width * Height;
// Determine frame transparency
IsTransparent := (Transparent) and (UseTransparency);
if (IsTransparent) then
begin
OldTransparentColorIndex := GraphicControlExtension.TransparentColorIndex;
// Map transparent color
GraphicControlExtension.TransparentColorIndex := NewTransparentColorIndex;
end else
OldTransparentColorIndex := 0; // To avoid compiler warning
// Map all pixels to new color map
while (Size > 0) do
begin
// Map transparent pixels to the new transparent color index and...
if (IsTransparent) and (ord(Pixel^) = OldTransparentColorIndex) then
Pixel^ := char(NewTransparentColorIndex)
else
// ... all other pixels to their new color index
Pixel^ := char(ReverseMap[ord(Pixel^)]);
dec(size);
inc(Pixel);
end;
end;
end;
constructor TColorMapOptimizer.Create(AImage: TGIFImage);
begin
inherited Create;
FImage := AImage;
FHistogramList := TList.Create;
FHistogram := TList.Create;
end;
destructor TColorMapOptimizer.Destroy;
var
i : integer;
begin
FHistogram.Free;
for i := FHistogramList.Count-1 downto 0 do
THistogram(FHistogramList[i]).Free;
FHistogramList.Free;
inherited Destroy;
end;
procedure TColorMapOptimizer.ProcessImage;
var
Hist : THistogram;
i : integer;
ProcessedImage : boolean;
begin
FUseTransparency := False;
(*
** First process images using global color map
*)
if (FImage.GlobalColorMap.Count > 0) then
begin
Hist := THistogram.Create(FImage.GlobalColorMap);
ProcessedImage := False;
// Process all images that are using the global color map
for i := 0 to FImage.Images.Count-1 do
if (FImage.Images[i].ColorMap.Count = 0) and (not FImage.Images[i].Empty) then
begin
ProcessedImage := True;
// Note: Do not change order of statements. Shortcircuit evaluation not desired!
FUseTransparency := Hist.ProcessSubImage(FImage.Images[i]) or FUseTransparency;
end;
// Keep the histogram if any images used the global color map...
if (ProcessedImage) then
FHistogramList.Add(Hist)
else // ... otherwise delete it
Hist.Free;
end;
(*
** Next process images that have a local color map
*)
for i := 0 to FImage.Images.Count-1 do
if (FImage.Images[i].ColorMap.Count > 0) and (not FImage.Images[i].Empty) then
begin
Hist := THistogram.Create(FImage.Images[i].ColorMap);
FHistogramList.Add(Hist);
// Note: Do not change order of statements. Shortcircuit evaluation not desired!
FUseTransparency := Hist.ProcessSubImage(FImage.Images[i]) or FUseTransparency;
end;
end;
procedure TColorMapOptimizer.MergeColors;
var
Entry, SameEntry : POptimizeEntry;
i : integer;
begin
(*
** Sort by color value
*)
FHistogram.Sort(CompareColor);
(*
** Merge same colors
*)
SameEntry := POptimizeEntry(FHistogram[0]);
for i := 1 to FHistogram.Count-1 do
begin
Entry := POptimizeEntry(FHistogram[i]);
ASSERT(Entry^.Count > 0, 'Unused entry exported from THistogram');
if (Entry^.Color.Value = SameEntry^.Color.Value) then
begin
// Transfer usage count to first entry
inc(SameEntry^.Count, Entry^.Count);
Entry^.Count := 0; // Use 0 to signal merged entry
Entry^.Color.SameAs := SameEntry; // Point to master
end else
SameEntry := Entry;
end;
end;
procedure TColorMapOptimizer.MapColors;
var
i, j : integer;
Delta, BestDelta : integer;
BestIndex : integer;
MaxColors : integer;
begin
(*
** Sort by usage count
*)
FHistogram.Sort(CompareCount);
(*
** Handle transparency
*)
if (FUseTransparency) then
MaxColors := 255
else
MaxColors := 256;
(*
** Determine number of colors used (max 256)
*)
FFinalCount := FHistogram.Count;
for i := 0 to FFinalCount-1 do
if (i >= MaxColors) or (POptimizeEntry(FHistogram[i])^.Count = 0) then
begin
FFinalCount := i;
break;
end;
(*
** Build color map and reverse map for final entries
*)
for i := 0 to FFinalCount-1 do
begin
POptimizeEntry(FHistogram[i])^.NewIndex := i;
FColorMap[i] := POptimizeEntry(FHistogram[i])^.Color.Color;
end;
(*
** Map colors > 256 to colors <= 256 and build NewIndex color map
*)
for i := FFinalCount to FHistogram.Count-1 do
with POptimizeEntry(FHistogram[i])^ do
begin
// Entries with a usage count of -1 is unused
ASSERT(Count <> -1, 'Internal error: Unused entry exported');
// Entries with a usage count of 0 has been merged with another entry
if (Count = 0) then
begin
// Use mapping of master entry
ASSERT(Color.SameAs.NewIndex < 256, 'Internal error: Mapping to unmapped color');
NewIndex := Color.SameAs.NewIndex;
end else
begin
// Search for entry with nearest color value
BestIndex := 0;
BestDelta := 255*3;
for j := 0 to FFinalCount-1 do
begin
Delta := ABS((POptimizeEntry(FHistogram[j])^.Color.Color.Red - Color.Color.Red) +
(POptimizeEntry(FHistogram[j])^.Color.Color.Green - Color.Color.Green) +
(POptimizeEntry(FHistogram[j])^.Color.Color.Blue - Color.Color.Blue));
if (Delta < BestDelta) then
begin
BestDelta := Delta;
BestIndex := j;
end;
end;
NewIndex := POptimizeEntry(FHistogram[BestIndex])^.NewIndex;;
end;
end;
(*
** Add transparency color to new color map
*)
if (FUseTransparency) then
begin
FNewTransparentColorIndex := FFinalCount;
FColorMap[FFinalCount].Red := 0;
FColorMap[FFinalCount].Green := 0;
FColorMap[FFinalCount].Blue := 0;
inc(FFinalCount);
end;
end;
procedure TColorMapOptimizer.ReplaceColorMaps;
var
i : integer;
begin
// Zap all local color maps
for i := 0 to FImage.Images.Count-1 do
if (FImage.Images[i].ColorMap <> nil) then
FImage.Images[i].ColorMap.Clear;
// Store optimized global color map
FImage.GlobalColorMap.ImportColorMap(FColorMap, FFinalCount);
FImage.GlobalColorMap.Optimized := True;
end;
procedure TColorMapOptimizer.Optimize;
var
Total : integer;
i, j : integer;
begin
// Stop all painters during optimize...
FImage.PaintStop;
// ...and prevent any new from starting while we are doing our thing
FImage.Painters.LockList;
try
(*
** Process all sub images
*)
ProcessImage;
// Prune histograms and calculate total number of colors
Total := 0;
for i := 0 to FHistogramList.Count-1 do
inc(Total, THistogram(FHistogramList[i]).Prune);
// Allocate global histogram
FHistogram.Clear;
FHistogram.Capacity := Total;
// Move data pointers from local histograms to global histogram
for i := 0 to FHistogramList.Count-1 do
with THistogram(FHistogramList[i]) do
for j := 0 to Count-1 do
begin
ASSERT(POptimizeEntry(List[j])^.Count > 0, 'Unused entry exported from THistogram');
FHistogram.Add(List[j]);
end;
(*
** Merge same colors
*)
MergeColors;
(*
** Build color map and NewIndex map for final entries
*)
MapColors;
(*
** Replace local colormaps with global color map
*)
ReplaceColorMaps;
(*
** Process images for each color map
*)
for i := 0 to FHistogramList.Count-1 do
THistogram(FHistogramList[i]).MapImages(FUseTransparency, FNewTransparentColorIndex);
(*
** Delete the frame's old bitmaps and palettes
*)
for i := 0 to FImage.Images.Count-1 do
begin
FImage.Images[i].HasBitmap := False;
FImage.Images[i].Palette := 0;
end;
finally
FImage.Painters.UnlockList;
end;
end;
////////////////////////////////////////////////////////////////////////////////
//
// TGIFImage
//
////////////////////////////////////////////////////////////////////////////////
constructor TGIFImage.Create;
begin
inherited Create;
FImages := TGIFImageList.Create(self);
FHeader := TGIFHeader.Create(self);
FPainters := TThreadList.Create;
FGlobalPalette := 0;
// Load defaults
FDrawOptions := GIFImageDefaultDrawOptions;
ColorReduction := GIFImageDefaultColorReduction;
FReductionBits := GIFImageDefaultColorReductionBits;
FDitherMode := GIFImageDefaultDitherMode;
FCompression := GIFImageDefaultCompression;
FThreadPriority := GIFImageDefaultThreadPriority;
FAnimationSpeed := GIFImageDefaultAnimationSpeed;
FDrawBackgroundColor := clNone;
IsDrawing := False;
IsInsideGetPalette := False;
NewImage;
end;
destructor TGIFImage.Destroy;
var
i : integer;
begin
PaintStop;
with FPainters.LockList do
try
for i := Count-1 downto 0 do
TGIFPainter(Items[i]).FImage := nil;
finally
FPainters.UnLockList;
end;
Clear;
FPainters.Free;
FImages.Free;
FHeader.Free;
inherited Destroy;
end;
procedure TGIFImage.Clear;
begin
PaintStop;
FreeBitmap;
FImages.Clear;
FHeader.ColorMap.Clear;
FHeader.Height := 0;
FHeader.Width := 0;
FHeader.Prepare;
Palette := 0;
end;
procedure TGIFImage.NewImage;
begin
Clear;
end;
function TGIFImage.GetVersion: TGIFVersion;
var
v : TGIFVersion;
i : integer;
begin
Result := gvUnknown;
for i := 0 to FImages.Count-1 do
begin
v := FImages[i].Version;
if (v > Result) then
Result := v;
if (v >= high(TGIFVersion)) then
break;
end;
end;
function TGIFImage.GetColorResolution: integer;
var
i : integer;
begin
Result := FHeader.ColorResolution;
for i := 0 to FImages.Count-1 do
if (FImages[i].ColorResolution > Result) then
Result := FImages[i].ColorResolution;
end;
function TGIFImage.GetBitsPerPixel: integer;
var
i : integer;
begin
Result := FHeader.BitsPerPixel;
for i := 0 to FImages.Count-1 do
if (FImages[i].BitsPerPixel > Result) then
Result := FImages[i].BitsPerPixel;
end;
function TGIFImage.GetBackgroundColorIndex: BYTE;
begin
Result := FHeader.BackgroundColorIndex;
end;
procedure TGIFImage.SetBackgroundColorIndex(const Value: BYTE);
begin
FHeader.BackgroundColorIndex := Value;
end;
function TGIFImage.GetBackgroundColor: TColor;
begin
Result := FHeader.BackgroundColor;
end;
procedure TGIFImage.SetBackgroundColor(const Value: TColor);
begin
FHeader.BackgroundColor := Value;
end;
function TGIFImage.GetAspectRatio: BYTE;
begin
Result := FHeader.AspectRatio;
end;
procedure TGIFImage.SetAspectRatio(const Value: BYTE);
begin
FHeader.AspectRatio := Value;
end;
procedure TGIFImage.SetDrawOptions(Value: TGIFDrawOptions);
begin
if (FDrawOptions = Value) then
exit;
if (DrawPainter <> nil) then
DrawPainter.Stop;
FDrawOptions := Value;
// Zap all bitmaps
Pack;
Changed(self);
end;
function TGIFImage.GetAnimate: Boolean;
begin // 2002.07.07
Result:= goAnimate in DrawOptions;
end;
procedure TGIFImage.SetAnimate(const Value: Boolean);
begin // 2002.07.07
if Value then
DrawOptions:= DrawOptions + [goAnimate]
else
DrawOptions:= DrawOptions - [goAnimate];
end;
procedure TGIFImage.SetAnimationSpeed(Value: integer);
begin
if (Value < 0) then
Value := 0
else if (Value > 1000) then
Value := 1000;
if (Value <> FAnimationSpeed) then
begin
FAnimationSpeed := Value;
// Use the FPainters threadlist to protect FDrawPainter from being modified
// by the thread while we mess with it
with FPainters.LockList do
try
if (FDrawPainter <> nil) then
FDrawPainter.AnimationSpeed := FAnimationSpeed;
finally
// Release the lock on FPainters to let paint thread kill itself
FPainters.UnLockList;
end;
end;
end;
procedure TGIFImage.SetReductionBits(Value: integer);
begin
if (Value < 3) or (Value > 8) then
Error(sInvalidBitSize);
FReductionBits := Value;
end;
procedure TGIFImage.OptimizeColorMap;
var
ColorMapOptimizer : TColorMapOptimizer;
begin
ColorMapOptimizer := TColorMapOptimizer.Create(self);
try
ColorMapOptimizer.Optimize;
finally
ColorMapOptimizer.Free;
end;
end;
procedure TGIFImage.Optimize(Options: TGIFOptimizeOptions;
ColorReduction: TColorReduction; DitherMode: TDitherMode;
ReductionBits: integer);
var
i ,
j : integer;
Delay : integer;
GCE : TGIFGraphicControlExtension;
ThisRect ,
NextRect ,
MergeRect : TRect;
Prog ,
MaxProg : integer;
function Scan(Buf: PChar; Value: Byte; Count: integer): boolean; assembler;
asm
PUSH EDI
MOV EDI, Buf
MOV ECX, Count
MOV AL, Value
REPNE SCASB
MOV EAX, False
JNE @@1
MOV EAX, True
@@1:POP EDI
end;
begin
if (Empty) then
exit;
// Stop all painters during optimize...
PaintStop;
// ...and prevent any new from starting while we are doing our thing
FPainters.LockList;
try
Progress(Self, psStarting, 0, False, Rect(0,0,0,0), sProgressOptimizing);
try
Prog := 0;
MaxProg := Images.Count*6;
// Sort color map by usage and remove unused entries
if (ooColorMap in Options) then
begin
// Optimize global color map
if (GlobalColorMap.Count > 0) then
GlobalColorMap.Optimize;
// Optimize local color maps
for i := 0 to Images.Count-1 do
begin
inc(Prog);
if (Images[i].ColorMap.Count > 0) then
begin
Images[i].ColorMap.Optimize;
Progress(Self, psRunning, MulDiv(Prog, 100, MaxProg), False,
Rect(0,0,0,0), sProgressOptimizing);
end;
end;
end;
// Remove passive elements, pass 1
if (ooCleanup in Options) then
begin
// Check for transparency flag without any transparent pixels
for i := 0 to Images.Count-1 do
begin
inc(Prog);
if (Images[i].Transparent) then
begin
if not(Scan(Images[i].Data,
Images[i].GraphicControlExtension.TransparentColorIndex,
Images[i].DataSize)) then
begin
Images[i].GraphicControlExtension.Transparent := False;
Progress(Self, psRunning, MulDiv(Prog, 100, MaxProg), False,
Rect(0,0,0,0), sProgressOptimizing);
end;
end;
end;
// Change redundant disposal modes
for i := 0 to Images.Count-2 do
begin
inc(Prog);
if (Images[i].GraphicControlExtension <> nil) and
(Images[i].GraphicControlExtension.Disposal in [dmPrevious, dmBackground]) and
(not Images[i+1].Transparent) then
begin
ThisRect := Images[i].BoundsRect;
NextRect := Images[i+1].BoundsRect;
if (not IntersectRect(MergeRect, ThisRect, NextRect)) then
continue;
// If the next frame completely covers the current frame,
// change the disposal mode to dmNone
if (EqualRect(MergeRect, NextRect)) then
Images[i].GraphicControlExtension.Disposal := dmNone;
Progress(Self, psRunning, MulDiv(Prog, 100, MaxProg), False,
Rect(0,0,0,0), sProgressOptimizing);
end;
end;
end else
inc(Prog, 2*Images.Count);
// Merge layers of equal pixels (remove redundant pixels)
if (ooMerge in Options) then
begin
// Merge from last to first to avoid intefering with merge
for i := Images.Count-1 downto 1 do
begin
inc(Prog);
j := i-1;
// If the "previous" frames uses dmPrevious disposal mode, we must
// instead merge with the frame before the previous
while (j > 0) and
((Images[j].GraphicControlExtension <> nil) and
(Images[j].GraphicControlExtension.Disposal = dmPrevious)) do
dec(j);
// Merge
Images[i].Merge(Images[j]);
Progress(Self, psRunning, MulDiv(Prog, 100, MaxProg), False,
Rect(0,0,0,0), sProgressOptimizing);
end;
end else
inc(Prog, Images.Count);
// Crop transparent areas
if (ooCrop in Options) then
begin
for i := Images.Count-1 downto 0 do
begin
inc(Prog);
if (not Images[i].Empty) and (Images[i].Transparent) then
begin
// Remember frames delay in case frame is deleted
Delay := Images[i].GraphicControlExtension.Delay;
// Crop
Images[i].Crop;
// If the frame was completely transparent we remove it
if (Images[i].Empty) then
begin
// Transfer delay to previous frame in case frame was deleted
if (i > 0) and (Images[i-1].Transparent) then
Images[i-1].GraphicControlExtension.Delay :=
Images[i-1].GraphicControlExtension.Delay + Delay;
Images.Delete(i);
end;
Progress(Self, psRunning, MulDiv(Prog, 100, MaxProg), False,
Rect(0,0,0,0), sProgressOptimizing);
end;
end;
end else
inc(Prog, Images.Count);
// Remove passive elements, pass 2
inc(Prog, Images.Count);
if (ooCleanup in Options) then
begin
for i := Images.Count-1 downto 0 do
begin
// Remove comments and application extensions
for j := Images[i].Extensions.Count-1 downto 0 do
if (Images[i].Extensions[j] is TGIFCommentExtension) or
(Images[i].Extensions[j] is TGIFTextExtension) or
(Images[i].Extensions[j] is TGIFUnknownAppExtension) or
((Images[i].Extensions[j] is TGIFAppExtNSLoop) and
((i > 0) or (Images.Count = 1))) then
Images[i].Extensions.Delete(j);
if (Images[i].GraphicControlExtension <> nil) then
begin
GCE := Images[i].GraphicControlExtension;
// Zap GCE if all of the following are true:
// * No delay or only one image
// * Not transparent
// * No prompt
// * No disposal or only one image
if ((GCE.Delay = 0) or (Images.Count = 1)) and
(not GCE.Transparent) and
(not GCE.UserInput) and
((GCE.Disposal in [dmNone, dmNoDisposal]) or (Images.Count = 1)) then
begin
GCE.Free;
end;
end;
// Zap frame if it has become empty
if (Images[i].Empty) and (Images[i].Extensions.Count = 0) then
Images[i].Free;
end;
Progress(Self, psRunning, MulDiv(Prog, 100, MaxProg), False,
Rect(0,0,0,0), sProgressOptimizing);
end else
// Reduce color depth
if (ooReduceColors in Options) then
begin
if (ColorReduction = rmPalette) then
Error(sInvalidReduction);
{ TODO -oanme -cFeature : Implement ooReduceColors option. }
// Not implemented!
end;
finally
if ExceptObject = nil then
i := 100
else
i := 0;
Progress(Self, psEnding, i, False, Rect(0,0,0,0), sProgressOptimizing);
end;
finally
FPainters.UnlockList;
end;
end;
procedure TGIFImage.Pack;
var
i : integer;
begin
// Zap bitmaps and palettes
FreeBitmap;
Palette := 0;
for i := 0 to FImages.Count-1 do
begin
FImages[i].Bitmap := nil;
FImages[i].Palette := 0;
end;
// Only pack if no global colormap and a single image
if (FHeader.ColorMap.Count > 0) or (FImages.Count <> 1) then
exit;
// Copy local colormap to global
FHeader.ColorMap.Assign(FImages[0].ColorMap);
// Zap local colormap
FImages[0].ColorMap.Clear;
end;
procedure TGIFImage.SaveToStream(Stream: TStream);
var
n : Integer;
begin
Progress(Self, psStarting, 0, False, Rect(0,0,0,0), sProgressSaving);
try
// Write header
FHeader.SaveToStream(Stream);
// Write images
FImages.SaveToStream(Stream);
// Write trailer
with TGIFTrailer.Create(self) do
try
SaveToStream(Stream);
finally
Free;
end;
finally
if ExceptObject = nil then
n := 100
else
n := 0;
Progress(Self, psEnding, n, True, Rect(0,0,0,0), sProgressSaving);
end;
end;
procedure TGIFImage.LoadFromStream(Stream: TStream);
var
n : Integer;
Position : integer;
begin
Progress(Self, psStarting, 0, False, Rect(0,0,0,0), sProgressLoading);
try
// Zap old image
Clear;
Position := Stream.Position;
try
// Read header
FHeader.LoadFromStream(Stream);
// Read images
FImages.LoadFromStream(Stream, self);
// Read trailer
with TGIFTrailer.Create(self) do
try
LoadFromStream(Stream);
finally
Free;
end;
except
// Restore stream position in case of error.
// Not required, but "a nice thing to do"
Stream.Position := Position;
raise;
end;
finally
if ExceptObject = nil then
n := 100
else
n := 0;
Progress(Self, psEnding, n, True, Rect(0,0,0,0), sProgressLoading);
end;
end;
procedure TGIFImage.LoadFromResourceName(Instance: THandle; const ResName: String);
// 2002.07.07
var
Stream: TCustomMemoryStream;
begin
Stream := TResourceStream.Create(Instance, ResName, RT_RCDATA);
try
LoadFromStream(Stream);
finally
Stream.Free;
end;
end;
function TGIFImage.GetBitmap: TBitmap;
begin
if not(Empty) then
begin
Result := FBitmap;
if (Result <> nil) then
exit;
FBitmap := TBitmap.Create;
Result := FBitmap;
FBitmap.OnChange := Changed;
// Use first image as default
if (Images.Count > 0) then
begin
if (Images[0].Width = Width) and (Images[0].Height = Height) then
begin
// Use first image as it has same dimensions
FBitmap.Assign(Images[0].Bitmap);
end else
begin
// Draw first image on bitmap
FBitmap.Palette := CopyPalette(Palette);
FBitmap.Height := Height;
FBitmap.Width := Width;
Images[0].Draw(FBitmap.Canvas, FBitmap.Canvas.ClipRect, False, False);
end;
end;
end else
Result := nil
end;
// Create a new (empty) bitmap
function TGIFImage.NewBitmap: TBitmap;
begin
Result := FBitmap;
if (Result <> nil) then
exit;
FBitmap := TBitmap.Create;
Result := FBitmap;
FBitmap.OnChange := Changed;
// Draw first image on bitmap
FBitmap.Palette := CopyPalette(Palette);
FBitmap.Height := Height;
FBitmap.Width := Width;
end;
procedure TGIFImage.FreeBitmap;
begin
if (DrawPainter <> nil) then
DrawPainter.Stop;
if (FBitmap <> nil) then
begin
FBitmap.Free;
FBitmap := nil;
end;
end;
function TGIFImage.Add(Source: TPersistent): integer;
var
Image : TGIFSubImage;
begin
Image := nil; // To avoid compiler warning - not needed.
if (Source is TGraphic) then
begin
Image := TGIFSubImage.Create(self);
try
Image.Assign(Source);
// ***FIXME*** Documentation should explain the inconsistency here:
// TGIFimage does not take ownership of Source after TGIFImage.Add() and
// therefore does not delete Source.
except
Image.Free;
raise;
end;
end else
if (Source is TGIFSubImage) then
Image := TGIFSubImage(Source)
else
Error(sUnsupportedClass);
Result := FImages.Add(Image);
FreeBitmap;
Changed(self);
end;
function TGIFImage.GetEmpty: Boolean;
begin
Result := (FImages.Count = 0);
end;
function TGIFImage.GetHeight: Integer;
begin
Result := FHeader.Height;
end;
function TGIFImage.GetWidth: Integer;
begin
Result := FHeader.Width;
end;
function TGIFImage.GetIsTransparent: Boolean;
var
i : integer;
begin
Result := False;
for i := 0 to Images.Count-1 do
if (Images[i].GraphicControlExtension <> nil) and
(Images[i].GraphicControlExtension.Transparent) then
begin
Result := True;
exit;
end;
end;
function TGIFImage.Equals(Graphic: TGraphic): Boolean;
begin
Result := (Graphic = self);
end;
function TGIFImage.GetPalette: HPALETTE;
begin
// Check for recursion
// (TGIFImage.GetPalette->TGIFSubImage.GetPalette->TGIFImage.GetPalette etc...)
if (IsInsideGetPalette) then
Error(sNoColorTable);
IsInsideGetPalette := True;
try
Result := 0;
if (FBitmap <> nil) and (FBitmap.Palette <> 0) then
// Use bitmaps own palette if possible
Result := FBitmap.Palette
else if (FGlobalPalette <> 0) then
// Or a previously exported global palette
Result := FGlobalPalette
else if (DoDither) then
begin
// or create a new dither palette
FGlobalPalette := WebPalette;
Result := FGlobalPalette;
end else
if (FHeader.ColorMap.Count > 0) then
begin
// or create a new if first time
FGlobalPalette := FHeader.ColorMap.ExportPalette;
Result := FGlobalPalette;
end else
if (FImages.Count > 0) then
// This can cause a recursion if no global palette exist and image[0]
// hasn't got one either. Checked by the IsInsideGetPalette semaphor.
Result := FImages[0].Palette;
finally
IsInsideGetPalette := False;
end;
end;
procedure TGIFImage.SetPalette(Value: HPalette);
var
NeedNewBitmap : boolean;
begin
if (Value <> FGlobalPalette) then
begin
// Zap old palette
if (FGlobalPalette <> 0) then
DeleteObject(FGlobalPalette);
// Zap bitmap unless new palette is same as bitmaps own
NeedNewBitmap := (FBitmap <> nil) and (Value <> FBitmap.Palette);
// Use new palette
FGlobalPalette := Value;
if (NeedNewBitmap) then
begin
// Need to create new bitmap and repaint
FreeBitmap;
PaletteModified := True;
Changed(Self);
end;
end;
end;
// Obsolete
// procedure TGIFImage.Changed(Sender: TObject);
// begin
// inherited Changed(Sender);
// end;
procedure TGIFImage.SetHeight(Value: Integer);
var
i : integer;
begin
for i := 0 to Images.Count-1 do
if (Images[i].Top + Images[i].Height > Value) then
Error(sBadHeight);
if (Value <> Header.Height) then
begin
Header.Height := Value;
FreeBitmap;
Changed(self);
end;
end;
procedure TGIFImage.SetWidth(Value: Integer);
var
i : integer;
begin
for i := 0 to Images.Count-1 do
if (Images[i].Left + Images[i].Width > Value) then
Error(sBadWidth);
if (Value <> Header.Width) then
begin
Header.Width := Value;
FreeBitmap;
Changed(self);
end;
end;
procedure TGIFImage.WriteData(Stream: TStream);
begin
if (GIFImageOptimizeOnStream) then
Optimize([ooCrop, ooMerge, ooCleanup, ooColorMap, ooReduceColors], rmNone, dmNearest, 8);
inherited WriteData(Stream);
end;
procedure TGIFImage.AssignTo(Dest: TPersistent);
begin
if (Dest is TBitmap) then
Dest.Assign(Bitmap)
else
inherited AssignTo(Dest);
end;
{ TODO 1 -oanme -cImprovement : Better handling of TGIFImage.Assign(Empty TBitmap). }
procedure TGIFImage.Assign(Source: TPersistent);
var
i : integer;
Image : TGIFSubImage;
begin
if (Source = self) then
exit;
if (Source = nil) then
begin
Clear;
end else
//
// TGIFImage import
//
if (Source is TGIFImage) then
begin
Clear;
// Temporarily copy event handlers to be able to generate progress events
// during the copy and handle copy errors
OnProgress := TGIFImage(Source).OnProgress;
try
FOnWarning := TGIFImage(Source).OnWarning;
Progress(Self, psStarting, 0, False, Rect(0,0,0,0), sProgressCopying);
try
FHeader.Assign(TGIFImage(Source).Header);
FThreadPriority := TGIFImage(Source).ThreadPriority;
FDrawBackgroundColor := TGIFImage(Source).DrawBackgroundColor;
FDrawOptions := TGIFImage(Source).DrawOptions;
FColorReduction := TGIFImage(Source).ColorReduction;
FDitherMode := TGIFImage(Source).DitherMode;
// 2002.07.07 ->
FOnWarning:= TGIFImage(Source).FOnWarning;
FOnStartPaint:= TGIFImage(Source).FOnStartPaint;
FOnPaint:= TGIFImage(Source).FOnPaint;
FOnEndPaint:= TGIFImage(Source).FOnEndPaint;
FOnAfterPaint:= TGIFImage(Source).FOnAfterPaint;
FOnLoop:= TGIFImage(Source).FOnLoop;
// 2002.07.07 <-
for i := 0 to TGIFImage(Source).Images.Count-1 do
begin
Image := TGIFSubImage.Create(self);
Image.Assign(TGIFImage(Source).Images[i]);
Add(Image);
Progress(Self, psRunning, MulDiv((i+1), 100, TGIFImage(Source).Images.Count),
False, Rect(0,0,0,0), sProgressCopying);
end;
finally
if ExceptObject = nil then
i := 100
else
i := 0;
Progress(Self, psEnding, i, False, Rect(0,0,0,0), sProgressCopying);
end;
finally
// Reset event handlers
FOnWarning := nil;
OnProgress := nil;
end;
end else
//
// Import via TGIFSubImage.Assign
//
begin
Clear;
Image := TGIFSubImage.Create(self);
try
Image.Assign(Source);
Add(Image);
except
on E: EConvertError do
begin
Image.Free;
// Unsupported format - fall back to Source.AssignTo
inherited Assign(Source);
end;
else
// Unknown conversion error
Image.Free;
raise;
end;
end;
end;
procedure TGIFImage.LoadFromClipboardFormat(AFormat: Word; AData: THandle;
APalette: HPALETTE);
{$IFDEF REGISTER_TGIFIMAGE}
var
Size : Longint;
Buffer : Pointer;
Stream : TMemoryStream;
Bmp : TBitmap;
{$ENDIF} // 2002.07.07
begin // 2002.07.07
{$IFDEF REGISTER_TGIFIMAGE} // 2002.07.07
if (AData = 0) then
AData := GetClipboardData(AFormat);
if (AData <> 0) and (AFormat = CF_GIF) then
begin
// Get size and pointer to data
Size := GlobalSize(AData);
Buffer := GlobalLock(AData);
try
Stream := TMemoryStream.Create;
try
// Copy data to a stream
Stream.SetSize(Size);
Move(Buffer^, Stream.Memory^, Size);
// Load GIF from stream
LoadFromStream(Stream);
finally
Stream.Free;
end;
finally
GlobalUnlock(AData);
end;
end else
if (AData <> 0) and (AFormat = CF_BITMAP) then
begin
// No GIF on clipboard - try loading a bitmap instead
Bmp := TBitmap.Create;
try
Bmp.LoadFromClipboardFormat(AFormat, AData, APalette);
Assign(Bmp);
finally
Bmp.Free;
end;
end else
Error(sUnknownClipboardFormat);
{$ELSE} // 2002.07.07
Error(sGIFToClipboard); // 2002.07.07
{$ENDIF} // 2002.07.07
end;
procedure TGIFImage.SaveToClipboardFormat(var AFormat: Word; var AData: THandle;
var APalette: HPALETTE);
{$IFDEF REGISTER_TGIFIMAGE}
var
Stream : TMemoryStream;
Data : THandle;
Buffer : Pointer;
{$ENDIF} // 2002.07.07
begin // 2002.07.07
{$IFDEF REGISTER_TGIFIMAGE} // 2002.07.07
if (Empty) then
exit;
// First store a bitmap version on the clipboard...
Bitmap.SaveToClipboardFormat(AFormat, AData, APalette);
// ...then store a GIF
Stream := TMemoryStream.Create;
try
// Save the GIF to a memory stream
SaveToStream(Stream);
Stream.Position := 0;
// Allocate some memory for the GIF data
Data := GlobalAlloc(HeapAllocFlags, Stream.Size);
try
if (Data <> 0) then
begin
Buffer := GlobalLock(Data);
try
// Copy GIF data from stream memory to clipboard memory
Move(Stream.Memory^, Buffer^, Stream.Size);
finally
GlobalUnlock(Data);
end;
// Transfer data to clipboard
if (SetClipboardData(CF_GIF, Data) = 0) then
Error(sFailedPaste);
end;
except
GlobalFree(Data);
raise;
end;
finally
Stream.Free;
end;
{$ELSE} // 2002.07.07
Error(sGIFToClipboard); // 2002.07.07
{$ENDIF} // 2002.07.07
end;
function TGIFImage.GetColorMap: TGIFColorMap;
begin
Result := FHeader.ColorMap;
end;
function TGIFImage.GetDoDither: boolean;
begin
Result := (goDither in DrawOptions) and
(((goAutoDither in DrawOptions) and DoAutoDither) or
not(goAutoDither in DrawOptions));
end;
{$IFDEF VER9x}
procedure TGIFImage.Progress(Sender: TObject; Stage: TProgressStage;
PercentDone: Byte; RedrawNow: Boolean; const R: TRect; const Msg: string);
begin
if Assigned(FOnProgress) then
FOnProgress(Sender, Stage, PercentDone, RedrawNow, R, Msg);
end;
{$ENDIF}
procedure TGIFImage.StopDraw;
{$IFNDEF VER14_PLUS} // 2001.07.23
var
Msg : TMsg;
ThreadWindow : HWND;
{$ENDIF} // 2001.07.23
begin
repeat
// Use the FPainters threadlist to protect FDrawPainter from being modified
// by the thread while we mess with it
with FPainters.LockList do
try
if (FDrawPainter = nil) then
break;
// Tell thread to terminate
FDrawPainter.Stop;
// No need to wait for "thread" to terminate if running in main thread
if not(goAsync in FDrawPainter.DrawOptions) then
break;
finally
// Release the lock on FPainters to let paint thread kill itself
FPainters.UnLockList;
end;
{$IFDEF VER14_PLUS}
// 2002.07.07
if (GetCurrentThreadID = MainThreadID) then
while CheckSynchronize do {loop};
{$ELSE}
// Process Messages to make Synchronize work
// (Instead of Application.ProcessMessages)
//{$IFDEF VER14_PLUS} // 2001.07.23
// Break; // 2001.07.23
// Sleep(0); // Yield // 2001.07.23
//{$ELSE} // 2001.07.23
ThreadWindow := FindWindow('TThreadWindow', nil);
while PeekMessage(Msg, ThreadWindow, CM_DESTROYWINDOW, CM_EXECPROC, PM_REMOVE) do
begin
if (Msg.Message <> WM_QUIT) then
begin
TranslateMessage(Msg);
DispatchMessage(Msg);
end else
begin
PostQuitMessage(Msg.WParam);
exit;
end;
end;
{$ENDIF} // 2001.07.23
Sleep(0); // Yield
until (False);
FreeBitmap;
end;
procedure TGIFImage.Draw(ACanvas: TCanvas; const Rect: TRect);
var
Canvas : TCanvas;
DestRect : TRect;
{$IFNDEF VER14_PLUS} // 2001.07.23
Msg : TMsg;
ThreadWindow : HWND;
{$ENDIF} // 2001.07.23
procedure DrawTile(Rect: TRect; Bitmap: TBitmap);
var
Tile : TRect;
begin
if (goTile in FDrawOptions) then
begin
// Note: This design does not handle transparency correctly!
Tile.Left := Rect.Left;
Tile.Right := Tile.Left + Width;
while (Tile.Left < Rect.Right) do
begin
Tile.Top := Rect.Top;
Tile.Bottom := Tile.Top + Height;
while (Tile.Top < Rect.Bottom) do
begin
ACanvas.StretchDraw(Tile, Bitmap);
Tile.Top := Tile.Top + Height;
Tile.Bottom := Tile.Top + Height;
end;
Tile.Left := Tile.Left + Width;
Tile.Right := Tile.Left + Width;
end;
end else
ACanvas.StretchDraw(Rect, Bitmap);
end;
begin
// Prevent recursion(s(s(s)))
if (IsDrawing) or (FImages.Count = 0) then
exit;
IsDrawing := True;
try
// Copy bitmap to canvas if we are already drawing
// (or have drawn but are finished)
if (FImages.Count = 1) or // Only one image
(not (goAnimate in FDrawOptions)) then // Don't animate
begin
FImages[0].Draw(ACanvas, Rect, (goTransparent in FDrawOptions),
(goTile in FDrawOptions));
exit;
end else
if (FBitmap <> nil) and not(goDirectDraw in FDrawOptions) then
begin
DrawTile(Rect, Bitmap);
exit;
end;
// Use the FPainters threadlist to protect FDrawPainter from being modified
// by the thread while we mess with it
with FPainters.LockList do
try
// If we are already painting on the canvas in goDirectDraw mode
// and at the same location, just exit and let the painter do
// its thing when it's ready
if (FDrawPainter <> nil) and (FDrawPainter.Canvas = ACanvas) and
EqualRect(FDrawPainter.Rect, Rect) then
exit;
// Kill the current paint thread
StopDraw;
if not(goDirectDraw in FDrawOptions) then
begin
// Create a bitmap to draw on
NewBitmap;
Canvas := FBitmap.Canvas;
DestRect := Canvas.ClipRect;
// Initialize bitmap canvas with background image
Canvas.CopyRect(DestRect, ACanvas, Rect);
end else
begin
Canvas := ACanvas;
DestRect := Rect;
end;
// Create new paint thread
InternalPaint(@FDrawPainter, Canvas, DestRect, FDrawOptions);
if (FDrawPainter <> nil) then
begin
// Launch thread
FDrawPainter.Start;
if not(goDirectDraw in FDrawOptions) then
begin
{$IFDEF VER14_PLUS}
// 2002.07.07
while (FDrawPainter <> nil) and (not FDrawPainter.Terminated) and
(not FDrawPainter.Started) do
begin
if not CheckSynchronize then
Sleep(0); // Yield
end;
{$ELSE}
//{$IFNDEF VER14_PLUS} // 2001.07.23
ThreadWindow := FindWindow('TThreadWindow', nil);
// Wait for thread to render first frame
while (FDrawPainter <> nil) and (not FDrawPainter.Terminated) and
(not FDrawPainter.Started) do
// Process Messages to make Synchronize work
// (Instead of Application.ProcessMessages)
if PeekMessage(Msg, ThreadWindow, CM_DESTROYWINDOW, CM_EXECPROC, PM_REMOVE) then
begin
if (Msg.Message <> WM_QUIT) then
begin
TranslateMessage(Msg);
DispatchMessage(Msg);
end else
begin
PostQuitMessage(Msg.WParam);
exit;
end;
end else
Sleep(0); // Yield
{$ENDIF} // 2001.07.23
// Draw frame to destination
DrawTile(Rect, Bitmap);
end;
end;
finally
FPainters.UnLockList;
end;
finally
IsDrawing := False;
end;
end;
// Internal pain(t) routine used by Draw()
function TGIFImage.InternalPaint(Painter: PGifPainter; ACanvas: TCanvas;
const Rect: TRect; Options: TGIFDrawOptions): TGIFPainter;
begin
if (Empty) or (Rect.Left >= Rect.Right) or (Rect.Top >= Rect.Bottom) then
begin
Result := nil;
if (Painter <> nil) then
Painter^ := Result;
exit;
end;
// Draw in main thread if only one image
if (Images.Count = 1) then
Options := Options - [goAsync, goAnimate];
Result := TGIFPainter.CreateRef(Painter, self, ACanvas, Rect, Options);
FPainters.Add(Result);
Result.OnStartPaint := FOnStartPaint;
Result.OnPaint := FOnPaint;
Result.OnAfterPaint := FOnAfterPaint;
Result.OnLoop := FOnLoop;
Result.OnEndPaint := FOnEndPaint;
if not(goAsync in Options) then
begin
// Run in main thread
Result.Execute;
// Note: Painter threads executing in the main thread are freed upon exit
// from the Execute method, so no need to do it here.
Result := nil;
if (Painter <> nil) then
Painter^ := Result;
end else
Result.Priority := FThreadPriority;
end;
function TGIFImage.Paint(ACanvas: TCanvas; const Rect: TRect;
Options: TGIFDrawOptions): TGIFPainter;
begin
Result := InternalPaint(nil, ACanvas, Rect, Options);
if (Result <> nil) then
// Run in separate thread
Result.Start;
end;
procedure TGIFImage.PaintStart;
var
i : integer;
begin
with FPainters.LockList do
try
for i := 0 to Count-1 do
TGIFPainter(Items[i]).Start;
finally
FPainters.UnLockList;
end;
end;
procedure TGIFImage.PaintStop;
var
Ghosts : integer;
i : integer;
{$IFNDEF VER14_PLUS} // 2001.07.23
Msg : TMsg;
ThreadWindow : HWND;
{$ENDIF} // 2001.07.23
{$IFNDEF VER14_PLUS} // 2001.07.23
procedure KillThreads;
var
i : integer;
begin
with FPainters.LockList do
try
for i := Count-1 downto 0 do
if (goAsync in TGIFPainter(Items[i]).DrawOptions) then
begin
TerminateThread(TGIFPainter(Items[i]).Handle, 0);
Delete(i);
end;
finally
FPainters.UnLockList;
end;
end;
{$ENDIF} // 2001.07.23
begin
try
// Loop until all have died
repeat
with FPainters.LockList do
try
if (Count = 0) then
exit;
// Signal painters to terminate
// Painters will attempt to remove them self from the
// painter list when they die
Ghosts := Count;
for i := Ghosts-1 downto 0 do
begin
if not(goAsync in TGIFPainter(Items[i]).DrawOptions) then
dec(Ghosts);
TGIFPainter(Items[i]).Stop;
end;
finally
FPainters.UnLockList;
end;
// If all painters were synchronous, there's no purpose waiting for them
// to terminate, because they are running in the main thread.
if (Ghosts = 0) then
exit;
{$IFDEF VER14_PLUS}
// 2002.07.07
if (GetCurrentThreadID = MainThreadID) then
while CheckSynchronize do {loop};
{$ELSE}
// Process Messages to make TThread.Synchronize work
// (Instead of Application.ProcessMessages)
//{$IFDEF VER14_PLUS} // 2001.07.23
// Exit; // 2001.07.23
//{$ELSE} // 2001.07.23
ThreadWindow := FindWindow('TThreadWindow', nil);
if (ThreadWindow = 0) then
begin
KillThreads;
Exit;
end;
while PeekMessage(Msg, ThreadWindow, CM_DESTROYWINDOW, CM_EXECPROC, PM_REMOVE) do
begin
if (Msg.Message <> WM_QUIT) then
begin
TranslateMessage(Msg);
DispatchMessage(Msg);
end else
begin
KillThreads;
Exit;
end;
end;
{$ENDIF} // 2001.07.23
Sleep(0);
until (False);
finally
FreeBitmap;
end;
end;
procedure TGIFImage.PaintPause;
var
i : integer;
begin
with FPainters.LockList do
try
for i := 0 to Count-1 do
TGIFPainter(Items[i]).Suspend;
finally
FPainters.UnLockList;
end;
end;
procedure TGIFImage.PaintResume;
var
i : integer;
begin
// Implementation is currently same as PaintStart, but don't call PaintStart
// in case its implementation changes
with FPainters.LockList do
try
for i := 0 to Count-1 do
TGIFPainter(Items[i]).Start;
finally
FPainters.UnLockList;
end;
end;
procedure TGIFImage.PaintRestart;
var
i : integer;
begin
with FPainters.LockList do
try
for i := 0 to Count-1 do
TGIFPainter(Items[i]).Restart;
finally
FPainters.UnLockList;
end;
end;
procedure TGIFImage.Warning(Sender: TObject; Severity: TGIFSeverity; Message: string);
begin
if (Assigned(FOnWarning)) then
FOnWarning(Sender, Severity, Message);
end;
{$IFDEF VER12_PLUS}
{$IFNDEF VER14_PLUS} // not anymore need for Delphi 6 and up // 2001.07.23
type
TDummyThread = class(TThread)
protected
procedure Execute; override;
end;
procedure TDummyThread.Execute;
begin
end;
{$ENDIF} // 2001.07.23
{$ENDIF}
var
DesktopDC: HDC;
{$IFDEF VER12_PLUS}
{$IFNDEF VER14_PLUS} // not anymore need for Delphi 6 and up // 2001.07.23
DummyThread: TThread;
{$ENDIF} // 2001.07.23
{$ENDIF}
////////////////////////////////////////////////////////////////////////////////
//
// Initialization
//
////////////////////////////////////////////////////////////////////////////////
initialization
{$IFDEF REGISTER_TGIFIMAGE}
TPicture.RegisterFileFormat('GIF', sGIFImageFile, TGIFImage);
CF_GIF := RegisterClipboardFormat(PChar(sGIFImageFile));
TPicture.RegisterClipboardFormat(CF_GIF, TGIFImage);
{$ENDIF}
DesktopDC := GetDC(0);
try
PaletteDevice := (GetDeviceCaps(DesktopDC, BITSPIXEL) * GetDeviceCaps(DesktopDC, PLANES) <= 8);
DoAutoDither := PaletteDevice;
finally
ReleaseDC(0, DesktopDC);
end;
{$IFDEF VER9x}
// Note: This doesn't return the same palette as the Delphi 3 system palette
// since the true system palette contains 20 entries and the Delphi 3 system
// palette only contains 16.
// For our purpose this doesn't matter since we do not care about the actual
// colors (or their number) in the palette.
// Stock objects doesn't have to be deleted.
SystemPalette16 := GetStockObject(DEFAULT_PALETTE);
{$ENDIF}
{$IFDEF VER12_PLUS}
// Make sure that at least one thread always exist.
// This is done to circumvent a race condition bug in Delphi 4.x and later:
// When threads are deleted and created in rapid succesion, a situation might
// arise where the thread window is deleted *after* the threads it controls
// has been created. See the Delphi Bug Lists for more information.
{$IFNDEF VER14_PLUS} // not anymore need for Delphi 6 and up // 2001.07.23
DummyThread := TDummyThread.Create(True);
{$ENDIF} // 2001.07.23
{$ENDIF}
////////////////////////////////////////////////////////////////////////////////
//
// Finalization
//
////////////////////////////////////////////////////////////////////////////////
finalization
ExtensionList.Free;
AppExtensionList.Free;
{$IFNDEF VER9x}
{$IFDEF REGISTER_TGIFIMAGE}
TPicture.UnregisterGraphicClass(TGIFImage);
{$ENDIF}
{$IFDEF VER100}
if (pf8BitBitmap <> nil) then
pf8BitBitmap.Free;
{$ENDIF}
{$ENDIF}
{$IFDEF VER12_PLUS}
{$IFNDEF VER14_PLUS} // not anymore need for Delphi 6 and up // 2001.07.23
if (DummyThread <> nil) then
DummyThread.Free;
{$ENDIF} // 2001.07.23
{$ENDIF}
end.
| 28.753204 | 163 | 0.632147 |
fc434e7bde55590b917ac5d54fca2263e82abc30 | 188 | pas | Pascal | MiscInterfaces.pas | randydom/commonx | 2315f1acf41167bd77ba4d040b3f5b15a5c5b81a | [
"MIT"
]
| 48 | 2018-11-19T22:13:00.000Z | 2021-11-02T17:25:41.000Z | MiscInterfaces.pas | jpluimers/commonx | c49e51b4edcc61b2b51e78590a5168d574b66282 | [
"MIT"
]
| 6 | 2018-11-24T17:15:29.000Z | 2019-05-15T14:59:56.000Z | MiscInterfaces.pas | jpluimers/commonx | c49e51b4edcc61b2b51e78590a5168d574b66282 | [
"MIT"
]
| 12 | 2018-11-20T15:15:44.000Z | 2021-09-14T10:12:43.000Z | unit MiscInterfaces;
interface
type
ICheckSum = interface(IUnknown)
function GetCheckSum: integer;
property CheckSum: integer read GetCheckSum;
end;
implementation
end.
| 11.058824 | 48 | 0.75 |
f1d82632f80640d20fd55a77e0a7e076053471e7 | 3,352 | pas | Pascal | Kide/Source/KIDE.FormControllerButtonDesignerFrameUnit.pas | gz818/kitto3 | e76eea45028d732730a66c2d6238d13cd2e65392 | [
"Apache-2.0"
]
| 1 | 2021-11-18T05:41:19.000Z | 2021-11-18T05:41:19.000Z | Kide/Source/KIDE.FormControllerButtonDesignerFrameUnit.pas | gz818/kitto3 | e76eea45028d732730a66c2d6238d13cd2e65392 | [
"Apache-2.0"
]
| null | null | null | Kide/Source/KIDE.FormControllerButtonDesignerFrameUnit.pas | gz818/kitto3 | e76eea45028d732730a66c2d6238d13cd2e65392 | [
"Apache-2.0"
]
| null | null | null | {-------------------------------------------------------------------------------
Copyright 2012-2018 Ethea S.r.l.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-------------------------------------------------------------------------------}
unit KIDE.FormControllerButtonDesignerFrameUnit;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, KIDE.EditNodeBaseFrameUnit,
Vcl.ExtCtrls, Vcl.Tabs,
System.Actions, Vcl.ActnList, Vcl.ComCtrls, Vcl.ToolWin, Vcl.StdCtrls, Vcl.Buttons,
KIDE.BaseFrameUnit, KIDE.CodeEditorFrameUnit,
EF.Tree, Vcl.Samples.Spin, Vcl.StdActns,
KIDE.MainDataModuleUnit;
type
TFormControllerButtonDesignerFrame = class(TEditNodeBaseFrame)
_Caption: TLabeledEdit;
_Tooltip: TLabeledEdit;
private
function IsCloneButton: boolean;
protected
class function SuitsNode(const ANode: TEFNode): Boolean; override;
procedure CleanupDefaultsToEditNode; override;
procedure DesignPanelToEditNode; override;
public
procedure UpdateDesignPanel(const AForce: Boolean = False); override;
constructor Create(AOwner: TComponent); override;
end;
implementation
{$R *.dfm}
uses
StrUtils,
EF.Macros,
Kitto.Ext.Base,
Kitto.Ext.Form,
KIDE.Project, KIDE.Config, KIDE.ViewTableFormControllerDesignerFrameUnit;
{ TViewTableFormControllerDesignerFrame }
procedure TFormControllerButtonDesignerFrame.CleanupDefaultsToEditNode;
begin
inherited;
CleanupTextNode('Caption');
CleanupTextNode('ToolTip');
end;
constructor TFormControllerButtonDesignerFrame.Create(AOwner: TComponent);
begin
inherited;
end;
procedure TFormControllerButtonDesignerFrame.DesignPanelToEditNode;
begin
inherited;
;
end;function TFormControllerButtonDesignerFrame.IsCloneButton: boolean;
begin
Result := SameText(TEFNode(EditNode).Name, 'CloneButton');
end;
class function TFormControllerButtonDesignerFrame.SuitsNode(
const ANode: TEFNode): Boolean;
begin
Assert(Assigned(ANode));
Result := MatchText(ANode.Name, ['CloneButton', 'ConfirmButton', 'CancelButton', 'CloseButton'])
and (ANode.Parent is TEFNode) and
TViewTableFormControllerDesignerFrame.IsViewTableFormControllerNode(TEFNode(ANode.Parent));
end;
procedure TFormControllerButtonDesignerFrame.UpdateDesignPanel(
const AForce: Boolean);
begin
inherited;
Assert(Assigned(EditNode));
end;
initialization
TEditNodeFrameRegistry.Instance.RegisterClass(TFormControllerButtonDesignerFrame.GetClassId, TFormControllerButtonDesignerFrame);
finalization
if Assigned(TEditNodeFrameRegistry.Instance) then
TEditNodeFrameRegistry.Instance.UnregisterClass(TFormControllerButtonDesignerFrame.GetClassId);
end.
| 32.862745 | 132 | 0.732399 |
fc8a7264829c43af988bc9d1f231e6ef26068802 | 43,155 | pas | Pascal | references/sqlite3delphi/Source/SQLite3.pas | zekiguven/alcinoe | e55c5368ee8bfe7cd6d92424c29ab07d8a3e844c | [
"Apache-2.0"
]
| 851 | 2018-02-05T09:54:56.000Z | 2022-03-24T23:13:10.000Z | references/sqlite3delphi/Source/SQLite3.pas | zekiguven/alcinoe | e55c5368ee8bfe7cd6d92424c29ab07d8a3e844c | [
"Apache-2.0"
]
| 200 | 2018-02-06T18:52:39.000Z | 2022-03-24T19:59:14.000Z | references/sqlite3delphi/Source/SQLite3.pas | zekiguven/alcinoe | e55c5368ee8bfe7cd6d92424c29ab07d8a3e844c | [
"Apache-2.0"
]
| 197 | 2018-03-20T20:49:55.000Z | 2022-03-21T17:38:14.000Z | {*
* SQLite for Delphi and FreePascal/Lazarus
*
* This unit contains complete SQLite3 API translation
* Version of SQLite: 3.6.22
*
* Copyright 2010-2013 Yury Plashenkov
* http://plashenkov.github.io/sqlite/
*
* The MIT License (MIT)
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*}
unit SQLite3;
{$IFDEF FPC}
{$MODE DELPHI}
{$ENDIF}
{ $DEFINE SQLITE_DEPRECATED} // Enable deprecated functions
{ $DEFINE SQLITE_EXPERIMENTAL} // Enable experimental functions
{$DEFINE SQLITE_ENABLE_COLUMN_METADATA} // Enable functions to work with
// column metadata:
// table name, DB name, etc.
{$DEFINE SQLITE_ENABLE_UNLOCK_NOTIFY} // Enable sqlite3_unlock_notify()
// function to receive DB unlock
// notification
{ $DEFINE SQLITE_DEBUG} // Enable sqlite3_mutex_held() and
// sqlite3_mutex_notheld() functions
interface
type
PPAnsiCharArray = ^TPAnsiCharArray;
TPAnsiCharArray = array[0..MaxInt div SizeOf(PAnsiChar) - 1] of PAnsiChar;
const
{$IFDEF MSWINDOWS}
sqlite3_lib = 'sqlite3.dll';
{$ENDIF}
{$IFDEF UNIX}
sqlite3_lib = 'sqlite3.so';
{$ENDIF}
{$IFDEF DARWIN}
sqlite3_lib = 'libsqlite3.dylib';
{$ENDIF}
//var sqlite3_version: PAnsiChar;
function sqlite3_libversion: PAnsiChar; cdecl; external sqlite3_lib;
function sqlite3_sourceid: PAnsiChar; cdecl; external sqlite3_lib;
function sqlite3_libversion_number: Integer; cdecl; external sqlite3_lib;
function sqlite3_threadsafe: Integer; cdecl; external sqlite3_lib;
type
PSQLite3 = type Pointer;
function sqlite3_close(db: PSQLite3): Integer; cdecl; external sqlite3_lib;
type
TSQLite3Callback = function(pArg: Pointer; nCol: Integer; argv: PPAnsiCharArray; colv: PPAnsiCharArray): Integer; cdecl;
function sqlite3_exec(db: PSQLite3; const sql: PAnsiChar; callback: TSQLite3Callback; pArg: Pointer; errmsg: PPAnsiChar): Integer; cdecl; external sqlite3_lib;
const
SQLITE_OK = 0;
SQLITE_ERROR = 1;
SQLITE_INTERNAL = 2;
SQLITE_PERM = 3;
SQLITE_ABORT = 4;
SQLITE_BUSY = 5;
SQLITE_LOCKED = 6;
SQLITE_NOMEM = 7;
SQLITE_READONLY = 8;
SQLITE_INTERRUPT = 9;
SQLITE_IOERR = 10;
SQLITE_CORRUPT = 11;
SQLITE_NOTFOUND = 12;
SQLITE_FULL = 13;
SQLITE_CANTOPEN = 14;
SQLITE_PROTOCOL = 15;
SQLITE_EMPTY = 16;
SQLITE_SCHEMA = 17;
SQLITE_TOOBIG = 18;
SQLITE_CONSTRAINT = 19;
SQLITE_MISMATCH = 20;
SQLITE_MISUSE = 21;
SQLITE_NOLFS = 22;
SQLITE_AUTH = 23;
SQLITE_FORMAT = 24;
SQLITE_RANGE = 25;
SQLITE_NOTADB = 26;
SQLITE_ROW = 100;
SQLITE_DONE = 101;
const
SQLITE_IOERR_READ = SQLITE_IOERR or (1 shl 8);
SQLITE_IOERR_SHORT_READ = SQLITE_IOERR or (2 shl 8);
SQLITE_IOERR_WRITE = SQLITE_IOERR or (3 shl 8);
SQLITE_IOERR_FSYNC = SQLITE_IOERR or (4 shl 8);
SQLITE_IOERR_DIR_FSYNC = SQLITE_IOERR or (5 shl 8);
SQLITE_IOERR_TRUNCATE = SQLITE_IOERR or (6 shl 8);
SQLITE_IOERR_FSTAT = SQLITE_IOERR or (7 shl 8);
SQLITE_IOERR_UNLOCK = SQLITE_IOERR or (8 shl 8);
SQLITE_IOERR_RDLOCK = SQLITE_IOERR or (9 shl 8);
SQLITE_IOERR_DELETE = SQLITE_IOERR or (10 shl 8);
SQLITE_IOERR_BLOCKED = SQLITE_IOERR or (11 shl 8);
SQLITE_IOERR_NOMEM = SQLITE_IOERR or (12 shl 8);
SQLITE_IOERR_ACCESS = SQLITE_IOERR or (13 shl 8);
SQLITE_IOERR_CHECKRESERVEDLOCK = SQLITE_IOERR or (14 shl 8);
SQLITE_IOERR_LOCK = SQLITE_IOERR or (15 shl 8);
SQLITE_IOERR_CLOSE = SQLITE_IOERR or (16 shl 8);
SQLITE_IOERR_DIR_CLOSE = SQLITE_IOERR or (17 shl 8);
SQLITE_LOCKED_SHAREDCACHE = SQLITE_LOCKED or (1 shl 8);
const
SQLITE_OPEN_READONLY = $00000001;
SQLITE_OPEN_READWRITE = $00000002;
SQLITE_OPEN_CREATE = $00000004;
SQLITE_OPEN_DELETEONCLOSE = $00000008;
SQLITE_OPEN_EXCLUSIVE = $00000010;
SQLITE_OPEN_MAIN_DB = $00000100;
SQLITE_OPEN_TEMP_DB = $00000200;
SQLITE_OPEN_TRANSIENT_DB = $00000400;
SQLITE_OPEN_MAIN_JOURNAL = $00000800;
SQLITE_OPEN_TEMP_JOURNAL = $00001000;
SQLITE_OPEN_SUBJOURNAL = $00002000;
SQLITE_OPEN_MASTER_JOURNAL = $00004000;
SQLITE_OPEN_NOMUTEX = $00008000;
SQLITE_OPEN_FULLMUTEX = $00010000;
SQLITE_OPEN_SHAREDCACHE = $00020000;
SQLITE_OPEN_PRIVATECACHE = $00040000;
const
SQLITE_IOCAP_ATOMIC = $00000001;
SQLITE_IOCAP_ATOMIC512 = $00000002;
SQLITE_IOCAP_ATOMIC1K = $00000004;
SQLITE_IOCAP_ATOMIC2K = $00000008;
SQLITE_IOCAP_ATOMIC4K = $00000010;
SQLITE_IOCAP_ATOMIC8K = $00000020;
SQLITE_IOCAP_ATOMIC16K = $00000040;
SQLITE_IOCAP_ATOMIC32K = $00000080;
SQLITE_IOCAP_ATOMIC64K = $00000100;
SQLITE_IOCAP_SAFE_APPEND = $00000200;
SQLITE_IOCAP_SEQUENTIAL = $00000400;
const
SQLITE_LOCK_NONE = 0;
SQLITE_LOCK_SHARED = 1;
SQLITE_LOCK_RESERVED = 2;
SQLITE_LOCK_PENDING = 3;
SQLITE_LOCK_EXCLUSIVE = 4;
const
SQLITE_SYNC_NORMAL = $00002;
SQLITE_SYNC_FULL = $00003;
SQLITE_SYNC_DATAONLY = $00010;
type
PSQLite3File = ^TSQLite3File;
PSQLite3IOMethods = ^TSQLite3IOMethods;
sqlite3_file = record
pMethods: PSQLite3IOMethods;
end;
TSQLite3File = sqlite3_file;
sqlite3_io_methods = record
iVersion: Integer;
xClose: function(id: PSQLite3File): Integer; cdecl;
xRead: function(id: PSQLite3File; pBuf: Pointer; iAmt: Integer; iOfst: Int64): Integer; cdecl;
xWrite: function(id: PSQLite3File; const pBuf: Pointer; iAmt: Integer; iOfst: Int64): Integer; cdecl;
xTruncate: function(id: PSQLite3File; size: Int64): Integer; cdecl;
xSync: function(id: PSQLite3File; flags: Integer): Integer; cdecl;
xFileSize: function(id: PSQLite3File; var pSize: Int64): Integer; cdecl;
xLock: function(id: PSQLite3File; locktype: Integer): Integer; cdecl;
xUnlock: function(id: PSQLite3File; locktype: Integer): Integer; cdecl;
xCheckReservedLock: function(f: PSQLite3File; var pResOut: Integer): Integer; cdecl;
xFileControl: function(id: PSQLite3File; op: Integer; pArg: Pointer): Integer; cdecl;
xSectorSize: function(id: PSQLite3File): Integer; cdecl;
xDeviceCharacteristics: function(id: PSQLite3File): Integer; cdecl;
end;
TSQLite3IOMethods = sqlite3_io_methods;
const
SQLITE_FCNTL_LOCKSTATE = 1;
SQLITE_GET_LOCKPROXYFILE = 2;
SQLITE_SET_LOCKPROXYFILE = 3;
SQLITE_LAST_ERRNO = 4;
type
PSQLite3Mutex = type Pointer;
type
PSQLite3VFS = ^TSQLite3VFS;
sqlite3_vfs = record
iVersion: Integer;
szOsFile: Integer;
mxPathname: Integer;
pNext: PSQLite3VFS;
zName: PAnsiChar;
pAppData: Pointer;
xOpen: function(pVfs: PSQLite3VFS; const zName: PAnsiChar; id: PSQLite3File; flags: Integer; pOutFlags: PInteger): Integer; cdecl;
xDelete: function(pVfs: PSQLite3VFS; const zName: PAnsiChar; syncDir: Integer): Integer; cdecl;
xAccess: function(pVfs: PSQLite3VFS; const zName: PAnsiChar; flags: Integer; var pResOut: Integer): Integer; cdecl;
xFullPathname: function(pVfs: PSQLite3VFS; const zName: PAnsiChar; nOut: Integer; zOut: PAnsiChar): Integer; cdecl;
xDlOpen: function(pVfs: PSQLite3VFS; const zFilename: PAnsiChar): Pointer; cdecl;
xDlError: procedure(pVfs: PSQLite3VFS; nByte: Integer; zErrMsg: PAnsiChar); cdecl;
xDlSym: function(pVfs: PSQLite3VFS; pHandle: Pointer; const zSymbol: PAnsiChar): Pointer; cdecl;
xDlClose: procedure(pVfs: PSQLite3VFS; pHandle: Pointer); cdecl;
xRandomness: function(pVfs: PSQLite3VFS; nByte: Integer; zOut: PAnsiChar): Integer; cdecl;
xSleep: function(pVfs: PSQLite3VFS; microseconds: Integer): Integer; cdecl;
xCurrentTime: function(pVfs: PSQLite3VFS; var prNow: Double): Integer; cdecl;
xGetLastError: function(pVfs: PSQLite3VFS; nBuf: Integer; zBuf: PAnsiChar): Integer; cdecl;
end;
TSQLite3VFS = sqlite3_vfs;
const
SQLITE_ACCESS_EXISTS = 0;
SQLITE_ACCESS_READWRITE = 1;
SQLITE_ACCESS_READ = 2;
function sqlite3_initialize: Integer; cdecl; external sqlite3_lib;
function sqlite3_shutdown: Integer; cdecl; external sqlite3_lib;
function sqlite3_os_init: Integer; cdecl; external sqlite3_lib;
function sqlite3_os_end: Integer; cdecl; external sqlite3_lib;
{$IFDEF SQLITE_EXPERIMENTAL}
function sqlite3_config(op: Integer{; ...}): Integer; cdecl; external sqlite3_lib;
function sqlite3_db_config(db: PSQLite3; op: Integer{; ...}): Integer; cdecl; external sqlite3_lib;
type
sqlite3_mem_methods = record
xMalloc: function(nByte: Integer): Pointer; cdecl;
xFree: procedure(pPrior: Pointer); cdecl;
xRealloc: function(pPrior: Pointer; nByte: Integer): Pointer; cdecl;
xSize: function(pPrior: Pointer): Integer; cdecl;
xRoundup: function(n: Integer): Integer; cdecl;
xInit: function(NotUsed: Pointer): Integer; cdecl;
xShutdown: procedure(NotUsed: Pointer); cdecl;
pAppData: Pointer;
end;
TSQLite3MemMethods = sqlite3_mem_methods;
const
SQLITE_CONFIG_SINGLETHREAD = 1;
SQLITE_CONFIG_MULTITHREAD = 2;
SQLITE_CONFIG_SERIALIZED = 3;
SQLITE_CONFIG_MALLOC = 4;
SQLITE_CONFIG_GETMALLOC = 5;
SQLITE_CONFIG_SCRATCH = 6;
SQLITE_CONFIG_PAGECACHE = 7;
SQLITE_CONFIG_HEAP = 8;
SQLITE_CONFIG_MEMSTATUS = 9;
SQLITE_CONFIG_MUTEX = 10;
SQLITE_CONFIG_GETMUTEX = 11;
//SQLITE_CONFIG_CHUNKALLOC = 12;
SQLITE_CONFIG_LOOKASIDE = 13;
SQLITE_CONFIG_PCACHE = 14;
SQLITE_CONFIG_GETPCACHE = 15;
const
SQLITE_DBCONFIG_LOOKASIDE = 1001;
{$ENDIF}
function sqlite3_extended_result_codes(db: PSQLite3; onoff: Integer): Integer; cdecl; external sqlite3_lib;
function sqlite3_last_insert_rowid(db: PSQLite3): Int64; cdecl; external sqlite3_lib;
function sqlite3_changes(db: PSQLite3): Integer; cdecl; external sqlite3_lib;
function sqlite3_total_changes(db: PSQLite3): Integer; cdecl; external sqlite3_lib;
procedure sqlite3_interrupt(db: PSQLite3); cdecl; external sqlite3_lib;
function sqlite3_complete(const sql: PAnsiChar): Integer; cdecl; external sqlite3_lib;
function sqlite3_complete16(const sql: PWideChar): Integer; cdecl; external sqlite3_lib;
type
TSQLite3BusyCallback = function(ptr: Pointer; count: Integer): Integer; cdecl;
function sqlite3_busy_handler(db: PSQLite3; xBusy: TSQLite3BusyCallback; pArg: Pointer): Integer; cdecl; external sqlite3_lib;
function sqlite3_busy_timeout(db: PSQLite3; ms: Integer): Integer; cdecl; external sqlite3_lib;
function sqlite3_get_table(db: PSQLite3; const zSql: PAnsiChar; var pazResult: PPAnsiCharArray; pnRow: PInteger; pnColumn: PInteger; pzErrmsg: PPAnsiChar): Integer; cdecl; external sqlite3_lib;
procedure sqlite3_free_table(result: PPAnsiCharArray); cdecl; external sqlite3_lib;
function sqlite3_mprintf(const zFormat: PAnsiChar{; ...}): PAnsiChar; cdecl; external sqlite3_lib;
function sqlite3_vmprintf(const zFormat: PAnsiChar; ap: Pointer{va_list}): PAnsiChar; cdecl; external sqlite3_lib;
function sqlite3_snprintf(n: Integer; zBuf: PAnsiChar; const zFormat: PAnsiChar{; ...}): PAnsiChar; cdecl; external sqlite3_lib;
function sqlite3_malloc(n: Integer): Pointer; cdecl; external sqlite3_lib;
function sqlite3_realloc(pOld: Pointer; n: Integer): Pointer; cdecl; external sqlite3_lib;
procedure sqlite3_free(p: Pointer); cdecl; external sqlite3_lib;
function sqlite3_memory_used: Int64; cdecl; external sqlite3_lib;
function sqlite3_memory_highwater(resetFlag: Integer): Int64; cdecl; external sqlite3_lib;
procedure sqlite3_randomness(N: Integer; P: Pointer); cdecl; external sqlite3_lib;
type
TSQLite3AuthorizerCallback = function(pAuthArg: Pointer; code: Integer; const zTab: PAnsiChar; const zCol: PAnsiChar; const zDb: PAnsiChar; const zAuthContext: PAnsiChar): Integer; cdecl;
function sqlite3_set_authorizer(db: PSQLite3; xAuth: TSQLite3AuthorizerCallback; pUserData: Pointer): Integer; cdecl; external sqlite3_lib;
const
SQLITE_DENY = 1;
SQLITE_IGNORE = 2;
const
SQLITE_CREATE_INDEX = 1;
SQLITE_CREATE_TABLE = 2;
SQLITE_CREATE_TEMP_INDEX = 3;
SQLITE_CREATE_TEMP_TABLE = 4;
SQLITE_CREATE_TEMP_TRIGGER = 5;
SQLITE_CREATE_TEMP_VIEW = 6;
SQLITE_CREATE_TRIGGER = 7;
SQLITE_CREATE_VIEW = 8;
SQLITE_DELETE = 9;
SQLITE_DROP_INDEX = 10;
SQLITE_DROP_TABLE = 11;
SQLITE_DROP_TEMP_INDEX = 12;
SQLITE_DROP_TEMP_TABLE = 13;
SQLITE_DROP_TEMP_TRIGGER = 14;
SQLITE_DROP_TEMP_VIEW = 15;
SQLITE_DROP_TRIGGER = 16;
SQLITE_DROP_VIEW = 17;
SQLITE_INSERT = 18;
SQLITE_PRAGMA = 19;
SQLITE_READ = 20;
SQLITE_SELECT = 21;
SQLITE_TRANSACTION = 22;
SQLITE_UPDATE = 23;
SQLITE_ATTACH = 24;
SQLITE_DETACH = 25;
SQLITE_ALTER_TABLE = 26;
SQLITE_REINDEX = 27;
SQLITE_ANALYZE = 28;
SQLITE_CREATE_VTABLE = 29;
SQLITE_DROP_VTABLE = 30;
SQLITE_FUNCTION = 31;
SQLITE_SAVEPOINT = 32;
SQLITE_COPY = 0;
{$IFDEF SQLITE_EXPERIMENTAL}
type
TSQLite3TraceCallback = procedure(pTraceArg: Pointer; const zTrace: PAnsiChar); cdecl;
TSQLite3ProfileCallback = procedure(pProfileArg: Pointer; const zSql: PAnsiChar; elapseTime: UInt64); cdecl;
function sqlite3_trace(db: PSQLite3; xTrace: TSQLite3TraceCallback; pArg: Pointer): Pointer; cdecl; external sqlite3_lib;
function sqlite3_profile(db: PSQLite3; xProfile: TSQLite3ProfileCallback; pArg: Pointer): Pointer; cdecl; external sqlite3_lib;
{$ENDIF}
type
TSQLite3ProgressCallback = function(pProgressArg: Pointer): Integer; cdecl;
procedure sqlite3_progress_handler(db: PSQLite3; nOps: Integer; xProgress: TSQLite3ProgressCallback; pArg: Pointer); cdecl; external sqlite3_lib;
function sqlite3_open(const filename: PAnsiChar; var ppDb: PSQLite3): Integer; cdecl; external sqlite3_lib;
function sqlite3_open16(const filename: PWideChar; var ppDb: PSQLite3): Integer; cdecl; external sqlite3_lib;
function sqlite3_open_v2(const filename: PAnsiChar; var ppDb: PSQLite3; flags: Integer; const zVfs: PAnsiChar): Integer; cdecl; external sqlite3_lib;
function sqlite3_errcode(db: PSQLite3): Integer; cdecl; external sqlite3_lib;
function sqlite3_extended_errcode(db: PSQLite3): Integer; cdecl; external sqlite3_lib;
function sqlite3_errmsg(db: PSQLite3): PAnsiChar; cdecl; external sqlite3_lib;
function sqlite3_errmsg16(db: PSQLite3): PWideChar; cdecl; external sqlite3_lib;
type
PSQLite3Stmt = type Pointer;
function sqlite3_limit(db: PSQLite3; limitId: Integer; newLimit: Integer): Integer; cdecl; external sqlite3_lib;
const
SQLITE_LIMIT_LENGTH = 0;
SQLITE_LIMIT_SQL_LENGTH = 1;
SQLITE_LIMIT_COLUMN = 2;
SQLITE_LIMIT_EXPR_DEPTH = 3;
SQLITE_LIMIT_COMPOUND_SELECT = 4;
SQLITE_LIMIT_VDBE_OP = 5;
SQLITE_LIMIT_FUNCTION_ARG = 6;
SQLITE_LIMIT_ATTACHED = 7;
SQLITE_LIMIT_LIKE_PATTERN_LENGTH = 8;
SQLITE_LIMIT_VARIABLE_NUMBER = 9;
SQLITE_LIMIT_TRIGGER_DEPTH = 10;
function sqlite3_prepare(db: PSQLite3; const zSql: PAnsiChar; nByte: Integer; var ppStmt: PSQLite3Stmt; const pzTail: PPAnsiChar): Integer; cdecl; external sqlite3_lib;
function sqlite3_prepare_v2(db: PSQLite3; const zSql: PAnsiChar; nByte: Integer; var ppStmt: PSQLite3Stmt; const pzTail: PPAnsiChar): Integer; cdecl; external sqlite3_lib;
function sqlite3_prepare16(db: PSQLite3; const zSql: PWideChar; nByte: Integer; var ppStmt: PSQLite3Stmt; const pzTail: PPWideChar): Integer; cdecl; external sqlite3_lib;
function sqlite3_prepare16_v2(db: PSQLite3; const zSql: PWideChar; nByte: Integer; var ppStmt: PSQLite3Stmt; const pzTail: PPWideChar): Integer; cdecl; external sqlite3_lib;
function sqlite3_sql(pStmt: PSQLite3Stmt): PAnsiChar; cdecl; external sqlite3_lib;
type
PSQLite3Value = ^TSQLite3Value;
sqlite3_value = type Pointer;
TSQLite3Value = sqlite3_value;
PPSQLite3ValueArray = ^TPSQLite3ValueArray;
TPSQLite3ValueArray = array[0..MaxInt div SizeOf(PSQLite3Value) - 1] of PSQLite3Value;
type
PSQLite3Context = type Pointer;
type
TSQLite3DestructorType = procedure(p: Pointer); cdecl;
const
SQLITE_STATIC = Pointer(0);
SQLITE_TRANSIENT = Pointer(-1);
function sqlite3_bind_blob(pStmt: PSQLite3Stmt; i: Integer; const zData: Pointer; n: Integer; xDel: TSQLite3DestructorType): Integer; cdecl; external sqlite3_lib;
function sqlite3_bind_double(pStmt: PSQLite3Stmt; i: Integer; rValue: Double): Integer; cdecl; external sqlite3_lib;
function sqlite3_bind_int(p: PSQLite3Stmt; i: Integer; iValue: Integer): Integer; cdecl; external sqlite3_lib;
function sqlite3_bind_int64(pStmt: PSQLite3Stmt; i: Integer; iValue: Int64): Integer; cdecl; external sqlite3_lib;
function sqlite3_bind_null(pStmt: PSQLite3Stmt; i: Integer): Integer; cdecl; external sqlite3_lib;
function sqlite3_bind_text(pStmt: PSQLite3Stmt; i: Integer; const zData: PAnsiChar; n: Integer; xDel: TSQLite3DestructorType): Integer; cdecl; external sqlite3_lib;
function sqlite3_bind_text16(pStmt: PSQLite3Stmt; i: Integer; const zData: PWideChar; nData: Integer; xDel: TSQLite3DestructorType): Integer; cdecl; external sqlite3_lib;
function sqlite3_bind_value(pStmt: PSQLite3Stmt; i: Integer; const pValue: PSQLite3Value): Integer; cdecl; external sqlite3_lib;
function sqlite3_bind_zeroblob(pStmt: PSQLite3Stmt; i: Integer; n: Integer): Integer; cdecl; external sqlite3_lib;
function sqlite3_bind_parameter_count(pStmt: PSQLite3Stmt): Integer; cdecl; external sqlite3_lib;
function sqlite3_bind_parameter_name(pStmt: PSQLite3Stmt; i: Integer): PAnsiChar; cdecl; external sqlite3_lib;
function sqlite3_bind_parameter_index(pStmt: PSQLite3Stmt; const zName: PAnsiChar): Integer; cdecl; external sqlite3_lib;
function sqlite3_clear_bindings(pStmt: PSQLite3Stmt): Integer; cdecl; external sqlite3_lib;
function sqlite3_column_count(pStmt: PSQLite3Stmt): Integer; cdecl; external sqlite3_lib;
function sqlite3_column_name(pStmt: PSQLite3Stmt; N: Integer): PAnsiChar; cdecl; external sqlite3_lib;
function sqlite3_column_name16(pStmt: PSQLite3Stmt; N: Integer): PWideChar; cdecl; external sqlite3_lib;
{$IFDEF SQLITE_ENABLE_COLUMN_METADATA}
function sqlite3_column_database_name(pStmt: PSQLite3Stmt; N: Integer): PAnsiChar; cdecl; external sqlite3_lib;
function sqlite3_column_database_name16(pStmt: PSQLite3Stmt; N: Integer): PWideChar; cdecl; external sqlite3_lib;
function sqlite3_column_table_name(pStmt: PSQLite3Stmt; N: Integer): PAnsiChar; cdecl; external sqlite3_lib;
function sqlite3_column_table_name16(pStmt: PSQLite3Stmt; N: Integer): PWideChar; cdecl; external sqlite3_lib;
function sqlite3_column_origin_name(pStmt: PSQLite3Stmt; N: Integer): PAnsiChar; cdecl; external sqlite3_lib;
function sqlite3_column_origin_name16(pStmt: PSQLite3Stmt; N: Integer): PWideChar; cdecl; external sqlite3_lib;
{$ENDIF}
function sqlite3_column_decltype(pStmt: PSQLite3Stmt; N: Integer): PAnsiChar; cdecl; external sqlite3_lib;
function sqlite3_column_decltype16(pStmt: PSQLite3Stmt; N: Integer): PWideChar; cdecl; external sqlite3_lib;
function sqlite3_step(pStmt: PSQLite3Stmt): Integer; cdecl; external sqlite3_lib;
function sqlite3_data_count(pStmt: PSQLite3Stmt): Integer; cdecl; external sqlite3_lib;
const
SQLITE_INTEGER = 1;
SQLITE_FLOAT = 2;
SQLITE_BLOB = 4;
SQLITE_NULL = 5;
SQLITE_TEXT = 3;
SQLITE3_TEXT = 3;
function sqlite3_column_blob(pStmt: PSQLite3Stmt; iCol: Integer): Pointer; cdecl; external sqlite3_lib;
function sqlite3_column_bytes(pStmt: PSQLite3Stmt; iCol: Integer): Integer; cdecl; external sqlite3_lib;
function sqlite3_column_bytes16(pStmt: PSQLite3Stmt; iCol: Integer): Integer; cdecl; external sqlite3_lib;
function sqlite3_column_double(pStmt: PSQLite3Stmt; iCol: Integer): Double; cdecl; external sqlite3_lib;
function sqlite3_column_int(pStmt: PSQLite3Stmt; iCol: Integer): Integer; cdecl; external sqlite3_lib;
function sqlite3_column_int64(pStmt: PSQLite3Stmt; iCol: Integer): Int64; cdecl; external sqlite3_lib;
function sqlite3_column_text(pStmt: PSQLite3Stmt; iCol: Integer): PAnsiChar; cdecl; external sqlite3_lib;
function sqlite3_column_text16(pStmt: PSQLite3Stmt; iCol: Integer): PWideChar; cdecl; external sqlite3_lib;
function sqlite3_column_type(pStmt: PSQLite3Stmt; iCol: Integer): Integer; cdecl; external sqlite3_lib;
function sqlite3_column_value(pStmt: PSQLite3Stmt; iCol: Integer): PSQLite3Value; cdecl; external sqlite3_lib;
function sqlite3_finalize(pStmt: PSQLite3Stmt): Integer; cdecl; external sqlite3_lib;
function sqlite3_reset(pStmt: PSQLite3Stmt): Integer; cdecl; external sqlite3_lib;
type
TSQLite3RegularFunction = procedure(ctx: PSQLite3Context; n: Integer; apVal: PPSQLite3ValueArray); cdecl;
TSQLite3AggregateStep = procedure(ctx: PSQLite3Context; n: Integer; apVal: PPSQLite3ValueArray); cdecl;
TSQLite3AggregateFinalize = procedure(ctx: PSQLite3Context); cdecl;
function sqlite3_create_function(db: PSQLite3; const zFunctionName: PAnsiChar; nArg: Integer; eTextRep: Integer; pApp: Pointer; xFunc: TSQLite3RegularFunction; xStep: TSQLite3AggregateStep; xFinal: TSQLite3AggregateFinalize): Integer; cdecl; external sqlite3_lib;
function sqlite3_create_function16(db: PSQLite3; const zFunctionName: PWideChar; nArg: Integer; eTextRep: Integer; pApp: Pointer; xFunc: TSQLite3RegularFunction; xStep: TSQLite3AggregateStep; xFinal: TSQLite3AggregateFinalize): Integer; cdecl; external sqlite3_lib;
const
SQLITE_UTF8 = 1;
SQLITE_UTF16LE = 2;
SQLITE_UTF16BE = 3;
SQLITE_UTF16 = 4;
SQLITE_ANY = 5;
SQLITE_UTF16_ALIGNED = 8;
{$IFDEF SQLITE_DEPRECATED}
type
TSQLite3MemoryAlarmCallback = procedure(pArg: Pointer; used: Int64; N: Integer); cdecl;
function sqlite3_aggregate_count(p: PSQLite3Context): Integer; cdecl; external sqlite3_lib;
function sqlite3_expired(pStmt: PSQLite3Stmt): Integer; cdecl; external sqlite3_lib;
function sqlite3_transfer_bindings(pFromStmt: PSQLite3Stmt; pToStmt: PSQLite3Stmt): Integer; cdecl; external sqlite3_lib;
function sqlite3_global_recover: Integer; cdecl; external sqlite3_lib;
procedure sqlite3_thread_cleanup; cdecl; external sqlite3_lib;
function sqlite3_memory_alarm(xCallback: TSQLite3MemoryAlarmCallback; pArg: Pointer; iThreshold: Int64): Integer; cdecl; external sqlite3_lib;
{$ENDIF}
function sqlite3_value_blob(pVal: PSQLite3Value): Pointer; cdecl; external sqlite3_lib;
function sqlite3_value_bytes(pVal: PSQLite3Value): Integer; cdecl; external sqlite3_lib;
function sqlite3_value_bytes16(pVal: PSQLite3Value): Integer; cdecl; external sqlite3_lib;
function sqlite3_value_double(pVal: PSQLite3Value): Double; cdecl; external sqlite3_lib;
function sqlite3_value_int(pVal: PSQLite3Value): Integer; cdecl; external sqlite3_lib;
function sqlite3_value_int64(pVal: PSQLite3Value): Int64; cdecl; external sqlite3_lib;
function sqlite3_value_text(pVal: PSQLite3Value): PAnsiChar; cdecl; external sqlite3_lib;
function sqlite3_value_text16(pVal: PSQLite3Value): PWideChar; cdecl; external sqlite3_lib;
function sqlite3_value_text16le(pVal: PSQLite3Value): Pointer; cdecl; external sqlite3_lib;
function sqlite3_value_text16be(pVal: PSQLite3Value): Pointer; cdecl; external sqlite3_lib;
function sqlite3_value_type(pVal: PSQLite3Value): Integer; cdecl; external sqlite3_lib;
function sqlite3_value_numeric_type(pVal: PSQLite3Value): Integer; cdecl; external sqlite3_lib;
function sqlite3_aggregate_context(p: PSQLite3Context; nBytes: Integer): Pointer; cdecl; external sqlite3_lib;
function sqlite3_user_data(p: PSQLite3Context): Pointer; cdecl; external sqlite3_lib;
function sqlite3_context_db_handle(p: PSQLite3Context): PSQLite3; cdecl; external sqlite3_lib;
type
TSQLite3AuxDataDestructor = procedure(pAux: Pointer); cdecl;
function sqlite3_get_auxdata(pCtx: PSQLite3Context; N: Integer): Pointer; cdecl; external sqlite3_lib;
procedure sqlite3_set_auxdata(pCtx: PSQLite3Context; N: Integer; pAux: Pointer; xDelete: TSQLite3AuxDataDestructor); cdecl; external sqlite3_lib;
procedure sqlite3_result_blob(pCtx: PSQLite3Context; const z: Pointer; n: Integer; xDel: TSQLite3DestructorType); cdecl; external sqlite3_lib;
procedure sqlite3_result_double(pCtx: PSQLite3Context; rVal: Double); cdecl; external sqlite3_lib;
procedure sqlite3_result_error(pCtx: PSQLite3Context; const z: PAnsiChar; n: Integer); cdecl; external sqlite3_lib;
procedure sqlite3_result_error16(pCtx: PSQLite3Context; const z: PWideChar; n: Integer); cdecl; external sqlite3_lib;
procedure sqlite3_result_error_toobig(pCtx: PSQLite3Context); cdecl; external sqlite3_lib;
procedure sqlite3_result_error_nomem(pCtx: PSQLite3Context); cdecl; external sqlite3_lib;
procedure sqlite3_result_error_code(pCtx: PSQLite3Context; errCode: Integer); cdecl; external sqlite3_lib;
procedure sqlite3_result_int(pCtx: PSQLite3Context; iVal: Integer); cdecl; external sqlite3_lib;
procedure sqlite3_result_int64(pCtx: PSQLite3Context; iVal: Int64); cdecl; external sqlite3_lib;
procedure sqlite3_result_null(pCtx: PSQLite3Context); cdecl; external sqlite3_lib;
procedure sqlite3_result_text(pCtx: PSQLite3Context; const z: PAnsiChar; n: Integer; xDel: TSQLite3DestructorType); cdecl; external sqlite3_lib;
procedure sqlite3_result_text16(pCtx: PSQLite3Context; const z: PWideChar; n: Integer; xDel: TSQLite3DestructorType); cdecl; external sqlite3_lib;
procedure sqlite3_result_text16le(pCtx: PSQLite3Context; const z: Pointer; n: Integer; xDel: TSQLite3DestructorType); cdecl; external sqlite3_lib;
procedure sqlite3_result_text16be(pCtx: PSQLite3Context; const z: Pointer; n: Integer; xDel: TSQLite3DestructorType); cdecl; external sqlite3_lib;
procedure sqlite3_result_value(pCtx: PSQLite3Context; pValue: PSQLite3Value); cdecl; external sqlite3_lib;
procedure sqlite3_result_zeroblob(pCtx: PSQLite3Context; n: Integer); cdecl; external sqlite3_lib;
type
TSQLite3CollationCompare = function(pUser: Pointer; n1: Integer; const z1: Pointer; n2: Integer; const z2: Pointer): Integer; cdecl;
TSQLite3CollationDestructor = procedure(pUser: Pointer); cdecl;
function sqlite3_create_collation(db: PSQLite3; const zName: PAnsiChar; eTextRep: Integer; pUser: Pointer; xCompare: TSQLite3CollationCompare): Integer; cdecl; external sqlite3_lib;
function sqlite3_create_collation_v2(db: PSQLite3; const zName: PAnsiChar; eTextRep: Integer; pUser: Pointer; xCompare: TSQLite3CollationCompare; xDestroy: TSQLite3CollationDestructor): Integer; cdecl; external sqlite3_lib;
function sqlite3_create_collation16(db: PSQLite3; const zName: PWideChar; eTextRep: Integer; pUser: Pointer; xCompare: TSQLite3CollationCompare): Integer; cdecl; external sqlite3_lib;
type
TSQLite3CollationNeededCallback = procedure(pCollNeededArg: Pointer; db: PSQLite3; eTextRep: Integer; const zExternal: PAnsiChar); cdecl;
TSQLite3CollationNeededCallback16 = procedure(pCollNeededArg: Pointer; db: PSQLite3; eTextRep: Integer; const zExternal: PWideChar); cdecl;
function sqlite3_collation_needed(db: PSQLite3; pCollNeededArg: Pointer; xCollNeeded: TSQLite3CollationNeededCallback): Integer; cdecl; external sqlite3_lib;
function sqlite3_collation_needed16(db: PSQLite3; pCollNeededArg: Pointer; xCollNeeded16: TSQLite3CollationNeededCallback16): Integer; cdecl; external sqlite3_lib;
//function sqlite3_key(db: PSQLite3; const pKey: Pointer; nKey: Integer): Integer; cdecl; external sqlite3_lib;
//function sqlite3_rekey(db: PSQLite3; const pKey: Pointer; nKey: Integer): Integer; cdecl; external sqlite3_lib;
function sqlite3_sleep(ms: Integer): Integer; cdecl; external sqlite3_lib;
//var sqlite3_temp_directory: PAnsiChar;
function sqlite3_get_autocommit(db: PSQLite3): Integer; cdecl; external sqlite3_lib;
function sqlite3_db_handle(pStmt: PSQLite3Stmt): PSQLite3; cdecl; external sqlite3_lib;
function sqlite3_next_stmt(pDb: PSQLite3; pStmt: PSQLite3Stmt): PSQLite3Stmt; cdecl; external sqlite3_lib;
type
TSQLite3CommitCallback = function(pCommitArg: Pointer): Integer; cdecl;
TSQLite3RollbackCallback = procedure(pRollbackArg: Pointer); cdecl;
function sqlite3_commit_hook(db: PSQLite3; xCallback: TSQLite3CommitCallback; pArg: Pointer): Pointer; cdecl; external sqlite3_lib;
function sqlite3_rollback_hook(db: PSQLite3; xCallback: TSQLite3RollbackCallback; pArg: Pointer): Pointer; cdecl; external sqlite3_lib;
type
TSQLite3UpdateCallback = procedure(pUpdateArg: Pointer; op: Integer; const zDb: PAnsiChar; const zTbl: PAnsiChar; iKey: Int64); cdecl;
function sqlite3_update_hook(db: PSQLite3; xCallback: TSQLite3UpdateCallback; pArg: Pointer): Pointer; cdecl; external sqlite3_lib;
function sqlite3_enable_shared_cache(enable: Integer): Integer; cdecl; external sqlite3_lib;
function sqlite3_release_memory(n: Integer): Integer; cdecl; external sqlite3_lib;
procedure sqlite3_soft_heap_limit(n: Integer); cdecl; external sqlite3_lib;
{$IFDEF SQLITE_ENABLE_COLUMN_METADATA}
function sqlite3_table_column_metadata(db: PSQLite3; const zDbName: PAnsiChar; const zTableName: PAnsiChar; const zColumnName: PAnsiChar; const pzDataType: PPAnsiChar; const pzCollSeq: PPAnsiChar; pNotNull: PInteger; pPrimaryKey: PInteger; pAutoinc: PInteger): Integer; cdecl; external sqlite3_lib;
{$ENDIF}
function sqlite3_load_extension(db: PSQLite3; const zFile: PAnsiChar; const zProc: PAnsiChar; pzErrMsg: PPAnsiChar): Integer; cdecl; external sqlite3_lib;
function sqlite3_enable_load_extension(db: PSQLite3; onoff: Integer): Integer; cdecl; external sqlite3_lib;
type
TSQLiteAutoExtensionEntryPoint = procedure; cdecl;
function sqlite3_auto_extension(xEntryPoint: TSQLiteAutoExtensionEntryPoint): Integer; cdecl; external sqlite3_lib;
procedure sqlite3_reset_auto_extension; cdecl; external sqlite3_lib;
{$IFDEF SQLITE_EXPERIMENTAL}
type
TSQLite3FTS3Func = procedure(pContext: PSQLite3Context; argc: Integer; argv: PPSQLite3ValueArray); cdecl;
type
PSQLite3VTab = ^TSQLite3VTab;
PSQLite3IndexInfo = ^TSQLite3IndexInfo;
PSQLite3VTabCursor = ^TSQLite3VTabCursor;
PSQLite3Module = ^TSQLite3Module;
sqlite3_module = record
iVersion: Integer;
xCreate: function(db: PSQLite3; pAux: Pointer; argc: Integer; const argv: PPAnsiCharArray; var ppVTab: PSQLite3VTab; var pzErr: PAnsiChar): Integer; cdecl;
xConnect: function(db: PSQLite3; pAux: Pointer; argc: Integer; const argv: PPAnsiCharArray; var ppVTab: PSQLite3VTab; var pzErr: PAnsiChar): Integer; cdecl;
xBestIndex: function(pVTab: PSQLite3VTab; pInfo: PSQLite3IndexInfo): Integer; cdecl;
xDisconnect: function(pVTab: PSQLite3VTab): Integer; cdecl;
xDestroy: function(pVTab: PSQLite3VTab): Integer; cdecl;
xOpen: function(pVTab: PSQLite3VTab; var ppCursor: PSQLite3VTabCursor): Integer; cdecl;
xClose: function(pVtabCursor: PSQLite3VTabCursor): Integer; cdecl;
xFilter: function(pVtabCursor: PSQLite3VTabCursor; idxNum: Integer; const idxStr: PAnsiChar; argc: Integer; argv: PPSQLite3ValueArray): Integer; cdecl;
xNext: function(pVtabCursor: PSQLite3VTabCursor): Integer; cdecl;
xEof: function(pVtabCursor: PSQLite3VTabCursor): Integer; cdecl;
xColumn: function(pVtabCursor: PSQLite3VTabCursor; sContext: PSQLite3Context; p2: Integer): Integer; cdecl;
xRowid: function(pVtabCursor: PSQLite3VTabCursor; var pRowid: Int64): Integer; cdecl;
xUpdate: function(pVtab: PSQLite3VTab; nArg: Integer; ppArg: PPSQLite3ValueArray; var pRowid: Int64): Integer; cdecl;
xBegin: function(pVTab: PSQLite3VTab): Integer; cdecl;
xSync: function(pVTab: PSQLite3VTab): Integer; cdecl;
xCommit: function(pVTab: PSQLite3VTab): Integer; cdecl;
xRollback: function(pVTab: PSQLite3VTab): Integer; cdecl;
xFindFunction: function(pVtab: PSQLite3VTab; nArg: Integer; const zName: PAnsiChar; var pxFunc: TSQLite3FTS3Func; var ppArg: Pointer): Integer; cdecl;
xRename: function(pVtab: PSQLite3VTab; const zNew: PAnsiChar): Integer; cdecl;
end;
TSQLite3Module = sqlite3_module;
sqlite3_index_constraint = record
iColumn: Integer;
op: Byte;
usable: Byte;
iTermOffset: Integer;
end;
TSQLite3IndexConstraint = sqlite3_index_constraint;
PSQLite3IndexConstraintArray = ^TSQLite3IndexConstraintArray;
TSQLite3IndexConstraintArray = array[0..MaxInt div SizeOf(TSQLite3IndexConstraint) - 1] of TSQLite3IndexConstraint;
sqlite3_index_orderby = record
iColumn: Integer;
desc: Byte;
end;
TSQLite3IndexOrderBy = sqlite3_index_orderby;
PSQLite3IndexOrderByArray = ^TSQLite3IndexOrderByArray;
TSQLite3IndexOrderByArray = array[0..MaxInt div SizeOf(TSQLite3IndexOrderBy) - 1] of TSQLite3IndexOrderBy;
sqlite3_index_constraint_usage = record
argvIndex: Integer;
omit: Byte;
end;
TSQLite3IndexConstraintUsage = sqlite3_index_constraint_usage;
PSQLite3IndexConstraintUsageArray = ^TSQLite3IndexConstraintUsageArray;
TSQLite3IndexConstraintUsageArray = array[0..MaxInt div SizeOf(TSQLite3IndexConstraintUsage) - 1] of TSQLite3IndexConstraintUsage;
sqlite3_index_info = record
nConstraint: Integer;
aConstraint: PSQLite3IndexConstraintArray;
nOrderBy: Integer;
aOrderBy: PSQLite3IndexOrderByArray;
aConstraintUsage: PSQLite3IndexConstraintUsageArray;
idxNum: Integer;
idxStr: PAnsiChar;
needToFreeIdxStr: Integer;
orderByConsumed: Integer;
estimatedCost: Double;
end;
TSQLite3IndexInfo = sqlite3_index_info;
sqlite3_vtab = record
pModule: PSQLite3Module;
nRef: Integer;
zErrMsg: PAnsiChar;
end;
TSQLite3VTab = sqlite3_vtab;
sqlite3_vtab_cursor = record
pVtab: PSQLite3VTab;
end;
TSQLite3VTabCursor = sqlite3_vtab_cursor;
const
SQLITE_INDEX_CONSTRAINT_EQ = 2;
SQLITE_INDEX_CONSTRAINT_GT = 4;
SQLITE_INDEX_CONSTRAINT_LE = 8;
SQLITE_INDEX_CONSTRAINT_LT = 16;
SQLITE_INDEX_CONSTRAINT_GE = 32;
SQLITE_INDEX_CONSTRAINT_MATCH = 64;
function sqlite3_create_module(db: PSQLite3; const zName: PAnsiChar; const p: PSQLite3Module; pClientData: Pointer): Integer; cdecl; external sqlite3_lib;
type
TSQLite3ModuleDestructor = procedure(pAux: Pointer); cdecl;
function sqlite3_create_module_v2(db: PSQLite3; const zName: PAnsiChar; const p: PSQLite3Module; pClientData: Pointer; xDestroy: TSQLite3ModuleDestructor): Integer; cdecl; external sqlite3_lib;
function sqlite3_declare_vtab(db: PSQLite3; const zSQL: PAnsiChar): Integer; cdecl; external sqlite3_lib;
function sqlite3_overload_function(db: PSQLite3; const zFuncName: PAnsiChar; nArg: Integer): Integer; cdecl; external sqlite3_lib;
{$ENDIF}
type
PSQLite3Blob = type Pointer;
function sqlite3_blob_open(db: PSQLite3; const zDb: PAnsiChar; const zTable: PAnsiChar; const zColumn: PAnsiChar; iRow: Int64; flags: Integer; var ppBlob: PSQLite3Blob): Integer; cdecl; external sqlite3_lib;
function sqlite3_blob_close(pBlob: PSQLite3Blob): Integer; cdecl; external sqlite3_lib;
function sqlite3_blob_bytes(pBlob: PSQLite3Blob): Integer; cdecl; external sqlite3_lib;
function sqlite3_blob_read(pBlob: PSQLite3Blob; Z: Pointer; N: Integer; iOffset: Integer): Integer; cdecl; external sqlite3_lib;
function sqlite3_blob_write(pBlob: PSQLite3Blob; const z: Pointer; n: Integer; iOffset: Integer): Integer; cdecl; external sqlite3_lib;
function sqlite3_vfs_find(const zVfsName: PAnsiChar): PSQLite3VFS; cdecl; external sqlite3_lib;
function sqlite3_vfs_register(pVfs: PSQLite3VFS; makeDflt: Integer): Integer; cdecl; external sqlite3_lib;
function sqlite3_vfs_unregister(pVfs: PSQLite3VFS): Integer; cdecl; external sqlite3_lib;
function sqlite3_mutex_alloc(id: Integer): PSQLite3Mutex; cdecl; external sqlite3_lib;
procedure sqlite3_mutex_free(p: PSQLite3Mutex); cdecl; external sqlite3_lib;
procedure sqlite3_mutex_enter(p: PSQLite3Mutex); cdecl; external sqlite3_lib;
function sqlite3_mutex_try(p: PSQLite3Mutex): Integer; cdecl; external sqlite3_lib;
procedure sqlite3_mutex_leave(p: PSQLite3Mutex); cdecl; external sqlite3_lib;
{$IFDEF SQLITE_EXPERIMENTAL}
type
sqlite3_mutex_methods = record
xMutexInit: function: Integer; cdecl;
xMutexEnd: function: Integer; cdecl;
xMutexAlloc: function(id: Integer): PSQLite3Mutex; cdecl;
xMutexFree: procedure(p: PSQLite3Mutex); cdecl;
xMutexEnter: procedure(p: PSQLite3Mutex); cdecl;
xMutexTry: function(p: PSQLite3Mutex): Integer; cdecl;
xMutexLeave: procedure(p: PSQLite3Mutex); cdecl;
xMutexHeld: function(p: PSQLite3Mutex): Integer; cdecl;
xMutexNotheld: function(p: PSQLite3Mutex): Integer; cdecl;
end;
TSQLite3MutexMethods = sqlite3_mutex_methods;
{$ENDIF}
{$IFDEF SQLITE_DEBUG}
function sqlite3_mutex_held(p: PSQLite3Mutex): Integer; cdecl; external sqlite3_lib;
function sqlite3_mutex_notheld(p: PSQLite3Mutex): Integer; cdecl; external sqlite3_lib;
{$ENDIF}
const
SQLITE_MUTEX_FAST = 0;
SQLITE_MUTEX_RECURSIVE = 1;
SQLITE_MUTEX_STATIC_MASTER = 2;
SQLITE_MUTEX_STATIC_MEM = 3;
SQLITE_MUTEX_STATIC_MEM2 = 4;
SQLITE_MUTEX_STATIC_OPEN = 4;
SQLITE_MUTEX_STATIC_PRNG = 5;
SQLITE_MUTEX_STATIC_LRU = 6;
SQLITE_MUTEX_STATIC_LRU2 = 7;
function sqlite3_db_mutex(db: PSQLite3): PSQLite3Mutex; cdecl; external sqlite3_lib;
function sqlite3_file_control(db: PSQLite3; const zDbName: PAnsiChar; op: Integer; pArg: Pointer): Integer; cdecl; external sqlite3_lib;
function sqlite3_test_control(op: Integer{; ...}): Integer; cdecl; external sqlite3_lib;
const
SQLITE_TESTCTRL_FIRST = 5;
SQLITE_TESTCTRL_PRNG_SAVE = 5;
SQLITE_TESTCTRL_PRNG_RESTORE = 6;
SQLITE_TESTCTRL_PRNG_RESET = 7;
SQLITE_TESTCTRL_BITVEC_TEST = 8;
SQLITE_TESTCTRL_FAULT_INSTALL = 9;
SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS = 10;
SQLITE_TESTCTRL_PENDING_BYTE = 11;
SQLITE_TESTCTRL_ASSERT = 12;
SQLITE_TESTCTRL_ALWAYS = 13;
SQLITE_TESTCTRL_RESERVE = 14;
SQLITE_TESTCTRL_OPTIMIZATIONS = 15;
SQLITE_TESTCTRL_ISKEYWORD = 16;
SQLITE_TESTCTRL_LAST = 16;
{$IFDEF SQLITE_EXPERIMENTAL}
function sqlite3_status(op: Integer; var pCurrent: Integer; var pHighwater: Integer; resetFlag: Integer): Integer; cdecl; external sqlite3_lib;
const
SQLITE_STATUS_MEMORY_USED = 0;
SQLITE_STATUS_PAGECACHE_USED = 1;
SQLITE_STATUS_PAGECACHE_OVERFLOW = 2;
SQLITE_STATUS_SCRATCH_USED = 3;
SQLITE_STATUS_SCRATCH_OVERFLOW = 4;
SQLITE_STATUS_MALLOC_SIZE = 5;
SQLITE_STATUS_PARSER_STACK = 6;
SQLITE_STATUS_PAGECACHE_SIZE = 7;
SQLITE_STATUS_SCRATCH_SIZE = 8;
function sqlite3_db_status(db: PSQLite3; op: Integer; var pCur: Integer; var pHiwtr: Integer; resetFlg: Integer): Integer; cdecl; external sqlite3_lib;
const
SQLITE_DBSTATUS_LOOKASIDE_USED = 0;
function sqlite3_stmt_status(pStmt: PSQLite3Stmt; op: Integer; resetFlg: Integer): Integer; cdecl; external sqlite3_lib;
const
SQLITE_STMTSTATUS_FULLSCAN_STEP = 1;
SQLITE_STMTSTATUS_SORT = 2;
type
PSQLite3PCache = type Pointer;
type
sqlite3_pcache_methods = record
pArg: Pointer;
xInit: function(pArg: Pointer): Integer; cdecl;
xShutdown: procedure(pArg: Pointer); cdecl;
xCreate: function(szPage: Integer; bPurgeable: Integer): PSQLite3PCache; cdecl;
xCachesize: procedure(pCache: PSQLite3PCache; nCachesize: Integer); cdecl;
xPagecount: function(pCache: PSQLite3PCache): Integer; cdecl;
xFetch: function(pCache: PSQLite3PCache; key: Cardinal; createFlag: Integer): Pointer; cdecl;
xUnpin: procedure(pCache: PSQLite3PCache; pPg: Pointer; discard: Integer); cdecl;
xRekey: procedure(pCache: PSQLite3PCache; pPg: Pointer; oldKey: Cardinal; newKey: Cardinal); cdecl;
xTruncate: procedure(pCache: PSQLite3PCache; iLimit: Cardinal); cdecl;
xDestroy: procedure(pCache: PSQLite3PCache); cdecl;
end;
TSQLite3PCacheMethods = sqlite3_pcache_methods;
type
PSQLite3Backup = type Pointer;
function sqlite3_backup_init(pDest: PSQLite3; const zDestName: PAnsiChar; pSource: PSQLite3; const zSourceName: PAnsiChar): PSQLite3Backup; cdecl; external sqlite3_lib;
function sqlite3_backup_step(p: PSQLite3Backup; nPage: Integer): Integer; cdecl; external sqlite3_lib;
function sqlite3_backup_finish(p: PSQLite3Backup): Integer; cdecl; external sqlite3_lib;
function sqlite3_backup_remaining(p: PSQLite3Backup): Integer; cdecl; external sqlite3_lib;
function sqlite3_backup_pagecount(p: PSQLite3Backup): Integer; cdecl; external sqlite3_lib;
{$IFDEF SQLITE_ENABLE_UNLOCK_NOTIFY}
type
TSQLite3UnlockNotifyCallback = procedure(apArg: PPointerArray; nArg: Integer); cdecl;
function sqlite3_unlock_notify(pBlocked: PSQLite3; xNotify: TSQLite3UnlockNotifyCallback; pNotifyArg: Pointer): Integer; cdecl; external sqlite3_lib;
{$ENDIF}
function sqlite3_strnicmp(const zLeft: PAnsiChar; const zRight: PAnsiChar; N: Integer): Integer; cdecl; external sqlite3_lib;
{$ENDIF}
//function sqlite3_win32_mbcs_to_utf8(const S: PAnsiChar): PAnsiChar; cdecl; external sqlite3_lib;
implementation
end.
| 48.984109 | 299 | 0.750226 |
fc67af4ed9f6fe1f4ed8af5609004b2aa490c65f | 1,404 | pas | Pascal | files/0059.pas | nickelsworth/swag | 7c21c0da2291fc249b9dc5cfe121a7672a4ffc08 | [
"BSD-2-Clause"
]
| 11 | 2015-12-12T05:13:15.000Z | 2020-10-14T13:32:08.000Z | files/0059.pas | nickelsworth/swag | 7c21c0da2291fc249b9dc5cfe121a7672a4ffc08 | [
"BSD-2-Clause"
]
| null | null | null | files/0059.pas | nickelsworth/swag | 7c21c0da2291fc249b9dc5cfe121a7672a4ffc08 | [
"BSD-2-Clause"
]
| 8 | 2017-05-05T05:24:01.000Z | 2021-07-03T20:30:09.000Z | {
You included one of my subroutines in the SWAG-library. Unfortunately
it was buggy. Below you will find the, hopefully, bugfree code.
}
function GetRelativeFileName (F: FNameStr): FNameStr;
var
D: DirStr;
N: NameStr;
E: ExtStr;
i: integer;
rd: string;
begin
F := FExpand(F);
FSplit(F, D, N, E);
if GetCurDrive = D[1] then begin
{ Same Drive - remove Driveinformation from D }
Delete (D,1,2);
F := GetCurDir;
Delete (F,1,2);
{ Maybe it is a file in a directory higher than the actual directory }
i := Pos(F,d);
if i > 0 then begin
if length(f) = 1 then Delete (d,1,length(F))
else Delete (d,1,length(F)+1);
end
else begin
rd := '';
if Pos(d,F) = 0 then begin
repeat
repeat
rd := d[Ord(d[0])]+rd;
dec(d[0]);
until d[Ord(d[0])] = '\';
until Pos(d,F) > 0;
end;
{ Maybe it is a file in a directory lower than the actual directory }
if length(d)=1 then
d:= '\'+rd
else if Pos(d,F) > 0 then begin
repeat
rd := '..\'+rd;
dec (F[0]);
while F[Ord(F[0])] <> '\' do dec(F[0]);
until (Pos(F,D) > 0) and not((d='\') and (F<>'\'));
d := rd;
end
end;
end;
GetRelativeFileName := lower(D+N+E);
end;
| 26.490566 | 77 | 0.496439 |
471e30b1b3ae8de4697806471a57b2bf1b345b4f | 1,938 | dpr | Pascal | Tests.dpr | codingbott/DelphiFizzBuzzDecorator | caf99eeafcdaa0455d9ff61cc6c2d4f78e3adcba | [
"CC0-1.0"
]
| 1 | 2022-02-27T13:07:56.000Z | 2022-02-27T13:07:56.000Z | Tests.dpr | codingbott/DelphiFizzBuzzDecorator | caf99eeafcdaa0455d9ff61cc6c2d4f78e3adcba | [
"CC0-1.0"
]
| null | null | null | Tests.dpr | codingbott/DelphiFizzBuzzDecorator | caf99eeafcdaa0455d9ff61cc6c2d4f78e3adcba | [
"CC0-1.0"
]
| 1 | 2022-02-27T13:07:45.000Z | 2022-02-27T13:07:45.000Z | program Tests;
{$IFNDEF TESTINSIGHT}
{$APPTYPE CONSOLE}
{$ENDIF}
{$STRONGLINKTYPES ON}
uses
System.SysUtils,
{$IFDEF TESTINSIGHT}
TestInsight.DUnitX,
{$ELSE}
DUnitX.Loggers.Console,
{$ENDIF }
DUnitX.TestFramework,
uFizzBuzzTest in 'uFizzBuzzTest.pas',
FizzBuzzer in 'FizzBuzzer.pas',
uZahl in 'uZahl.pas',
uZahlTest in 'uZahlTest.pas',
uBuzzTest in 'uBuzzTest.pas',
uFizzTest in 'uFizzTest.pas',
uDummy in 'uDummy.pas';
{$IFNDEF TESTINSIGHT}
var
runner: ITestRunner;
results: IRunResults;
logger: ITestLogger;
nunitLogger : ITestLogger;
{$ENDIF}
begin
{$IFDEF TESTINSIGHT}
TestInsight.DUnitX.RunRegisteredTests;
{$ELSE}
try
//Check command line options, will exit if invalid
TDUnitX.CheckCommandLine;
//Create the test runner
runner := TDUnitX.CreateRunner;
//Tell the runner to use RTTI to find Fixtures
runner.UseRTTI := True;
//When true, Assertions must be made during tests;
runner.FailsOnNoAsserts := False;
//tell the runner how we will log things
//Log to the console window if desired
if TDUnitX.Options.ConsoleMode <> TDunitXConsoleMode.Off then
begin
logger := TDUnitXConsoleLogger.Create(TDUnitX.Options.ConsoleMode = TDunitXConsoleMode.Quiet);
runner.AddLogger(logger);
end;
//Generate an NUnit compatible XML File
nunitLogger := TDUnitXXMLNUnitFileLogger.Create(TDUnitX.Options.XMLOutputFile);
runner.AddLogger(nunitLogger);
//Run tests
results := runner.Execute;
if not results.AllPassed then
System.ExitCode := EXIT_ERRORS;
{$IFNDEF CI}
//We don't want this happening when running under CI.
if TDUnitX.Options.ExitBehavior = TDUnitXExitBehavior.Pause then
begin
System.Write('Done.. press <Enter> key to quit.');
System.Readln;
end;
{$ENDIF}
except
on E: Exception do
System.Writeln(E.ClassName, ': ', E.Message);
end;
{$ENDIF}
end.
| 26.189189 | 100 | 0.702786 |
83fcdaef4d6c2e7913fb8037b146e7657fe6c8d7 | 383 | pas | Pascal | Test/BuildScripts/Sections.pas | skolkman/dwscript | b9f99d4b8187defac3f3713e2ae0f7b83b63d516 | [
"Condor-1.1"
]
| 79 | 2015-03-18T10:46:13.000Z | 2022-03-17T18:05:11.000Z | Test/BuildScripts/Sections.pas | skolkman/dwscript | b9f99d4b8187defac3f3713e2ae0f7b83b63d516 | [
"Condor-1.1"
]
| 6 | 2016-03-29T14:39:00.000Z | 2020-09-14T10:04:14.000Z | Test/BuildScripts/Sections.pas | skolkman/dwscript | b9f99d4b8187defac3f3713e2ae0f7b83b63d516 | [
"Condor-1.1"
]
| 25 | 2016-05-04T13:11:38.000Z | 2021-09-29T13:34:31.000Z | unit Sections;
interface
type THello = class
method Dummy;
end;
PrintLn('Hello');
begin
PrintLn('Hello');
end;
procedure Stuff;
procedure Dummy;
implementation
method THello.Dummy;
begin
end;
PrintLn('Hello');
begin
PrintLn('Hello');
end;
procedure Dummy;
begin
end;
implementation
end.
this should be ignored
| 9.341463 | 23 | 0.624021 |
4741736e94d3bb6f8faf4be3a6bbf16ab3c01969 | 6,382 | pas | Pascal | mergevertices.pas | crom777/crom777 | b4e8a62995eb0793ad5d246cdc24e87f3397754b | [
"MIT"
]
| 48 | 2016-05-05T00:00:09.000Z | 2022-02-16T10:03:49.000Z | mergevertices.pas | crom777/crom777 | b4e8a62995eb0793ad5d246cdc24e87f3397754b | [
"MIT"
]
| 2 | 2016-08-29T11:47:31.000Z | 2020-04-08T12:29:19.000Z | mergevertices.pas | crom777/crom777 | b4e8a62995eb0793ad5d246cdc24e87f3397754b | [
"MIT"
]
| 13 | 2016-08-24T02:37:34.000Z | 2021-06-22T01:46:52.000Z | unit mergevertices;
//this function merges nearby vertices as a single vertex
// due to rouding errors, meshes can exhibit gaps and tears creating non-manifold meshes
// this code merges vertices that are within a given radius (the tolerance)
// if the tolerance is zero, only identical vertices are merged
// if the tolerance is 0.0001 than vertices within 0.001 are merged
{$IFDEF FPC}{$mode objfpc}{$H+}{$ENDIF}
interface
uses
Classes, sysutils, meshify_simplify_quadric;
//procedure UnifyVertices(var faces: TFaces; var vertices: TVertices; Radius: single);
procedure UnifyVertices(var faces: TFaces; var vertices: TVertices; Radius: single);
implementation
type
TSortType = single; //can be integer, single, double, etc
TSort = record
index: integer;
value: TSortType;
end;
TSortArray = array of TSort;
TInts = array of integer;
//http://stackoverflow.com/questions/24335585/quicksort-drama
procedure QuickSort(left, right: integer; var s: TSortArray);
// left: Index des 1. Elements, right: Index des letzten Elements
var
l, r, lswap: integer;
pivot: TSortType;
begin
if (right > left) then begin
l := left;
r := right;
pivot := s[s[(right + left) div 2].index].value;
while (l < r) do begin
while s[s[l].index].value < pivot do
l := l + 1;
while s[s[r].index].value > pivot do
r := r - 1;
if (l <= r) then begin
lswap := s[r].index;
s[r].index := s[l].index;
s[l].index := lswap;
l := l + 1;
r := r - 1;
end;
end;
if (left < r) then
QuickSort(left, r, s);
if (right > l) then
QuickSort(l, right, s);
end;
end;
procedure SortArrayIndices(var s: TSortArray); //sorts indices, not values!
var
i : integer;
begin
if length(s) < 1 then exit;
for i := 0 to (length(s)-1) do //set indices
s[i].index := i;
quicksort(low(s), high(s), s);
end;
procedure vectorAdd (var A: TPoint3f; B: TPoint3f); inline;
//sum two vectors
begin
A.X := A.X + B.X;
A.Y := A.Y + B.Y;
A.Z := A.Z + B.Z;
end; // vectorAdd()
function vectorScale(A: TPoint3f; Scale: single): TPoint3f;// overload;
begin
result.X := A.X * Scale;
result.Y := A.Y * Scale;
result.Z := A.Z * Scale;
end;
procedure ClusterVertex( var faces: TFaces; var vertices: TVertices; Radius: single);
var
s: TSortArray;
j,i, nv,nc,nvPost: integer;
z, dz, dx: TSortType;
pt,sum: TPoint3f;
face: TPoint3i;
newVert: TVertices;
oldFaces: TFaces;
radiusSqr: single;
cluster, remap: TInts;
begin
nv := length(vertices);
if (nv < 3) or (Radius < 0) then exit;
setlength(s,nv);
setlength(remap,nv);
setlength(cluster,nv);
for i := 0 to (nv -1) do begin
s[i].value := vertices[i].Z;
cluster[i] := i;
remap[i] := -1;
end;
SortArrayIndices(s);
nvPost := 0;
setLength(newVert, nv);
if Radius <= 0 then begin
for i := 0 to (nv - 1) do begin
if cluster[i] = i then begin //not part of previous cluster
pt := vertices[s[i].index];
j := i + 1;
while (j < nv) and (vertices[s[j].index].Z = pt.Z) do begin //i.Z==j.Z
if (vertices[s[j].index].X = pt.X) and (vertices[s[j].index].Y = pt.Y) then begin//i.X==j.X, i.Y==j.Y
cluster[j] := nvPost;
remap[s[j].index] := nvPost;
end;
j := j + 1;
end;
newVert[nvPost] := pt;
cluster[i] := nvPost;
remap[s[i].index] := nvPost;
nvPost := nvPost + 1; //no neighbors
end; //not yet clustered
end; //for each vertex
end else begin //Radius > 0
radiusSqr := sqr(Radius); //avoids calculating square-root for each comparison
for i := 0 to (nv - 1) do begin
if cluster[i] = i then begin //not part of previous cluster
z := s[s[i].index].value;
pt := vertices[s[i].index];
sum := pt;
dz := 0;
j := i + 1;
nc := 1;
while (dz <= Radius) and (j < nv) do begin
dz := abs(s[s[j].index].value - z);
//dx := vectorDistance(pt, vertices[s[j].index]);
dx := sqr(pt.X-vertices[s[j].index].X)+ sqr(pt.Y-vertices[s[j].index].Y) + sqr(pt.Z-vertices[s[j].index].Z);
if dx <= radiusSqr then begin
vectorAdd(sum, vertices[s[j].index]);
cluster[j] := nvPost;
remap[s[j].index] := nvPost;
nc := nc + 1;
end;
j := j + 1;
end;
newVert[nvPost] := vectorScale(sum, 1/nc);
cluster[i] := nvPost;
remap[s[i].index] := nvPost;
nvPost := nvPost + 1; //no neighbors
end; //not yet clustered
end; //for each vertex
end;
if nvPost = nv then exit; //no clusters - no change!
vertices := Copy(newVert, Low(newVert), nvPost);
//remap faces to new vertices
oldFaces := Copy(faces, Low(faces), Length(faces));
setlength(faces,0);
for i := 0 to (length(oldFaces) - 1) do begin
face.X := remap[oldFaces[i].X];
face.Y := remap[oldFaces[i].Y];
face.Z := remap[oldFaces[i].Z];
if (face.X <> face.Y) and (face.X <> face.Z) and (face.Y <> face.Z) then begin //exclude degenerate faces
setlength(Faces,length(Faces)+1);
Faces[High(Faces)].X := face.X;
Faces[High(Faces)].Y := face.Y;
Faces[High(Faces)].Z := face.Z;
end;
end;
end;
procedure UnifyVertices(var faces: TFaces; var vertices: TVertices; Radius: single);
//STL format saves raw vertices, this uses a lot of RAM and makes estimating vertex normals impossible...
// http://www.mathworks.com/matlabcentral/fileexchange/29986-patch-slim--patchslim-m-
var vStart, vEnd: integer;
begin
if (Radius < 0) then exit;
vStart := length(vertices);
ClusterVertex(faces, vertices, Radius);
vEnd := length(vertices);
if vStart = vEnd then exit;
if (Radius = 0) then
writeln(format(' removed identical vertices, reducing number from %d to %d', [vStart, vEnd ]))
else
writeln(format(' removed identical(ish) vertices, reducing number from %d to %d', [vStart, vEnd ]));
end;
end.
| 32.561224 | 126 | 0.569101 |
fc8b731b863304a5a9d926a6295df2d21eac6d7a | 310 | pas | Pascal | tests/t5.pas | jputh/Pascal-interpreter-haskell | 5d4744c241c83ed1c686c21064e02d8d8ffb6f1d | [
"MIT"
]
| null | null | null | tests/t5.pas | jputh/Pascal-interpreter-haskell | 5d4744c241c83ed1c686c21064e02d8d8ffb6f1d | [
"MIT"
]
| null | null | null | tests/t5.pas | jputh/Pascal-interpreter-haskell | 5d4744c241c83ed1c686c21064e02d8d8ffb6f1d | [
"MIT"
]
| null | null | null | // Tests if-elseif-else statements
//output: "The values are equal"
program test5;
var
a : boolean = True;
x : real = 9.0;
y : real = 9.0;
begin
if(x > y) then
writeln('The condition is true');
else if (x = y) then
writeln('The values are equal');
else
writeln('The condition is false');
end. | 15.5 | 38 | 0.63871 |
837af7b1ce3411d3575f26f34b0864464273fd50 | 42,726 | pas | Pascal | Libraries/BigIntegersLib/dwsBigIntegerFunctions.GMP.pas | skolkman/dwscript | b9f99d4b8187defac3f3713e2ae0f7b83b63d516 | [
"Condor-1.1"
]
| null | null | null | Libraries/BigIntegersLib/dwsBigIntegerFunctions.GMP.pas | skolkman/dwscript | b9f99d4b8187defac3f3713e2ae0f7b83b63d516 | [
"Condor-1.1"
]
| null | null | null | Libraries/BigIntegersLib/dwsBigIntegerFunctions.GMP.pas | skolkman/dwscript | b9f99d4b8187defac3f3713e2ae0f7b83b63d516 | [
"Condor-1.1"
]
| null | null | null | {**********************************************************************}
{ }
{ "The contents of this file are subject to the Mozilla Public }
{ License Version 1.1 (the "License"); you may not use this }
{ file except in compliance with the License. You may obtain }
{ a copy of the License at http://www.mozilla.org/MPL/ }
{ }
{ Software distributed under the License is distributed on an }
{ "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express }
{ or implied. See the License for the specific language }
{ governing rights and limitations under the License. }
{ }
{ Copyright Creative IT. }
{ Current maintainer: Eric Grange }
{ }
{**********************************************************************}
unit dwsBigIntegerFunctions.GMP;
{$I dws.inc}
interface
uses
Classes, SysUtils,
dwsXPlatform, dwsUtils, dwsStrings,
dwsFunctions, dwsSymbols, dwsExprs, dwsCoreExprs, dwsExprList, dwsUnitSymbols,
dwsConstExprs, dwsMagicExprs, dwsDataContext, dwsErrors, dwsRelExprs,
dwsOperators, dwsTokenizer, dwsCryptoXPlatform,
dwsMPIR;
const
SYS_BIGINTEGER = 'BigInteger';
type
TBaseBigIntegerSymbol = class (TBaseSymbol)
public
constructor Create;
function IsCompatible(typSym : TTypeSymbol) : Boolean; override;
procedure InitData(const data : TData; offset : Integer); override;
end;
IdwsBigInteger = interface
['{93A7FA32-DE99-44AB-A5B4-861FD50E9AAB}']
function GetValue : pmpz_t;
procedure SetValue(const v : pmpz_t);
property Value : pmpz_t read GetValue write SetValue;
function BitLength : Integer;
function ToStringBase(base : Integer) : String;
function ToHexString : String;
function ToInt64 : Int64;
end;
TBigIntegerWrapper = class (TInterfacedObject, IdwsBigInteger, IGetSelf)
protected
function GetValue : pmpz_t; inline;
procedure SetValue(const v : pmpz_t); inline;
function GetSelf : TObject;
public
Value : mpz_t;
constructor CreateZero;
constructor CreateInt64(const i : Int64);
constructor CreateString(const s : String; base : Integer);
constructor Wrap(const v : mpz_t);
destructor Destroy; override;
function BitLength : Integer;
function ToStringBase(base : Integer) : String;
function ToHexString : String;
function ToString : String; override;
function ToInt64 : Int64;
end;
TBigIntegerOpExpr = class(TBinaryOpExpr)
constructor Create(Prog: TdwsProgram; const aScriptPos : TScriptPos; aLeft, aRight : TTypedExpr); override;
end;
TBigIntegerAddOpExpr = class(TBigIntegerOpExpr)
procedure EvalAsVariant(exec : TdwsExecution; var result : Variant); override;
end;
TBigIntegerSubOpExpr = class(TBigIntegerOpExpr)
procedure EvalAsVariant(exec : TdwsExecution; var result : Variant); override;
end;
TBigIntegerMultOpExpr = class(TBigIntegerOpExpr)
procedure EvalAsVariant(exec : TdwsExecution; var result : Variant); override;
end;
TBigIntegerDivOpExpr = class(TBigIntegerOpExpr)
procedure EvalAsVariant(exec : TdwsExecution; var result : Variant); override;
end;
TBigIntegerModOpExpr = class(TBigIntegerOpExpr)
procedure EvalAsVariant(exec : TdwsExecution; var result : Variant); override;
end;
TBigIntegerAndOpExpr = class(TBigIntegerOpExpr)
procedure EvalAsVariant(exec : TdwsExecution; var result : Variant); override;
end;
TBigIntegerOrOpExpr = class(TBigIntegerOpExpr)
procedure EvalAsVariant(exec : TdwsExecution; var result : Variant); override;
end;
TBigIntegerXorOpExpr = class(TBigIntegerOpExpr)
procedure EvalAsVariant(exec : TdwsExecution; var result : Variant); override;
end;
TBigIntegerShiftLeftExpr = class(TBigIntegerOpExpr)
procedure EvalAsVariant(exec : TdwsExecution; var result : Variant); override;
end;
TBigIntegerShiftRightExpr = class(TBigIntegerOpExpr)
procedure EvalAsVariant(exec : TdwsExecution; var result : Variant); override;
end;
TBigIntegerOpAssignExpr = class(TOpAssignExpr)
procedure TypeCheckAssign(prog : TdwsProgram; exec : TdwsExecution); override;
end;
TBigIntegerPlusAssignExpr = class(TBigIntegerOpAssignExpr)
procedure EvalNoResult(exec : TdwsExecution); override;
end;
TBigIntegerMinusAssignExpr = class(TBigIntegerOpAssignExpr)
procedure EvalNoResult(exec : TdwsExecution); override;
end;
TBigIntegerMultAssignExpr = class(TBigIntegerOpAssignExpr)
procedure EvalNoResult(exec : TdwsExecution); override;
end;
TBigIntegerRelOpExpr = class(TBoolRelOpExpr)
protected
function InternalCompare(exec : TdwsExecution) : Integer;
end;
TBigIntegerRelOpExprClass = class of TBigIntegerRelOpExpr;
TBigIntegerEqualOpExpr = class(TBigIntegerRelOpExpr)
function EvalAsBoolean(exec : TdwsExecution) : Boolean; override;
end;
TBigIntegerNotEqualOpExpr = class(TBigIntegerRelOpExpr)
function EvalAsBoolean(exec : TdwsExecution) : Boolean; override;
end;
TBigIntegerGreaterOpExpr = class(TBigIntegerRelOpExpr)
function EvalAsBoolean(exec : TdwsExecution) : Boolean; override;
end;
TBigIntegerGreaterEqualOpExpr = class(TBigIntegerRelOpExpr)
function EvalAsBoolean(exec : TdwsExecution) : Boolean; override;
end;
TBigIntegerLessOpExpr = class(TBigIntegerRelOpExpr)
function EvalAsBoolean(exec : TdwsExecution) : Boolean; override;
end;
TBigIntegerLessEqualOpExpr = class(TBigIntegerRelOpExpr)
function EvalAsBoolean(exec : TdwsExecution) : Boolean; override;
end;
TBigIntegerUnaryOpExpr = class (TUnaryOpExpr)
public
constructor Create(prog : TdwsProgram; expr : TTypedExpr); override;
end;
TConvIntegerToBigIntegerExpr = class(TBigIntegerUnaryOpExpr)
procedure EvalAsVariant(exec : TdwsExecution; var result : Variant); override;
end;
TConvStringToBigIntegerExpr = class(TBigIntegerUnaryOpExpr)
procedure EvalAsVariant(exec : TdwsExecution; var result : Variant); override;
end;
TConvBigIntegerToIntegerExpr = class(TUnaryOpIntExpr)
function EvalAsInteger(exec : TdwsExecution) : Int64; override;
end;
TConvBigIntegerToFloatExpr = class(TUnaryOpFloatExpr)
function EvalAsFloat(exec : TdwsExecution) : Double; override;
end;
TBigIntegerToStringFunc = class(TInternalMagicStringFunction)
procedure DoEvalAsString(const args : TExprBaseListExec; var Result : UnicodeString); override;
end;
TStringToBigIntegerFunc = class(TInternalMagicVariantFunction)
procedure DoEvalAsVariant(const args : TExprBaseListExec; var result : Variant); override;
end;
TBigIntegerToHexFunc = class(TInternalMagicStringFunction)
procedure DoEvalAsString(const args : TExprBaseListExec; var Result : UnicodeString); override;
end;
THexToBigIntegerFunc = class(TInternalMagicVariantFunction)
procedure DoEvalAsVariant(const args : TExprBaseListExec; var result : Variant); override;
end;
TBigIntegerToBlobFunc = class(TInternalMagicVariantFunction)
procedure DoEvalAsVariant(const args : TExprBaseListExec; var result : Variant); override;
end;
TBlobToBigIntegerFunc = class(TInternalMagicVariantFunction)
procedure DoEvalAsVariant(const args : TExprBaseListExec; var result : Variant); override;
end;
TBigIntegerToFloatFunc = class(TInternalMagicFloatFunction)
procedure DoEvalAsFloat(const args : TExprBaseListExec; var Result : Double); override;
end;
TBigIntegerToIntegerFunc = class(TInternalMagicIntFunction)
function DoEvalAsInteger(const args : TExprBaseListExec) : Int64; override;
end;
TBigIntegerOddFunc = class(TInternalMagicBoolFunction)
function DoEvalAsBoolean(const args : TExprBaseListExec) : Boolean; override;
end;
TBigIntegerEvenFunc = class(TInternalMagicBoolFunction)
function DoEvalAsBoolean(const args : TExprBaseListExec) : Boolean; override;
end;
TBigIntegerSignFunc = class(TInternalMagicIntFunction)
function DoEvalAsInteger(const args : TExprBaseListExec) : Int64; override;
end;
TBigIntegerBitLengthFunc = class(TInternalMagicIntFunction)
function DoEvalAsInteger(const args : TExprBaseListExec) : Int64; override;
end;
TBigIntegerAbsExpr = class(TBigIntegerUnaryOpExpr)
public
procedure EvalAsVariant(exec : TdwsExecution; var result : Variant); override;
end;
TBigIntegerGcdFunc = class(TInternalMagicVariantFunction)
procedure DoEvalAsVariant(const args : TExprBaseListExec; var result : Variant); override;
end;
TBigIntegerLcmFunc = class(TInternalMagicVariantFunction)
procedure DoEvalAsVariant(const args : TExprBaseListExec; var result : Variant); override;
end;
TBigIntegerIsPrimeFunc = class(TInternalMagicBoolFunction)
function DoEvalAsBoolean(const args : TExprBaseListExec) : Boolean; override;
end;
TBigIntegerPowerFunc = class(TInternalMagicVariantFunction)
procedure DoEvalAsVariant(const args : TExprBaseListExec; var result : Variant); override;
end;
TBigIntegerSqrFunc = class(TInternalMagicVariantFunction)
procedure DoEvalAsVariant(const args : TExprBaseListExec; var result : Variant); override;
end;
TBigIntegerModPowFunc = class(TInternalMagicVariantFunction)
procedure DoEvalAsVariant(const args : TExprBaseListExec; var result : Variant); override;
end;
TBigIntegerDivModFunc = class(TInternalMagicProcedure)
procedure DoEvalProc(const args : TExprBaseListExec); override;
end;
TBigIntegerFactorialFunc = class(TInternalMagicVariantFunction)
procedure DoEvalAsVariant(const args : TExprBaseListExec; var result : Variant); override;
end;
TBigIntegerRandomFunc = class(TInternalMagicVariantFunction)
procedure DoEvalAsVariant(const args : TExprBaseListExec; var result : Variant); override;
end;
// ------------------------------------------------------------------
// ------------------------------------------------------------------
// ------------------------------------------------------------------
implementation
// ------------------------------------------------------------------
// ------------------------------------------------------------------
// ------------------------------------------------------------------
// RegisterBigIntegerType
//
procedure RegisterBigIntegerType(systemTable : TSystemSymbolTable; unitSyms : TUnitMainSymbols;
unitTable : TSymbolTable);
var
typBigInteger : TBaseBigIntegerSymbol;
begin
if systemTable.FindLocal(SYS_BIGINTEGER)<>nil then exit;
typBigInteger:=TBaseBigIntegerSymbol.Create;
systemTable.AddSymbol(typBigInteger);
end;
// RegisterBigIntegerOperators
//
procedure RegisterBigIntegerOperators(systemTable : TSystemSymbolTable;
unitTable : TSymbolTable; operators : TOperators);
var
typBigInteger : TBaseBigIntegerSymbol;
procedure RegisterOperators(token : TTokenType; exprClass : TBinaryOpExprClass);
begin
operators.RegisterOperator(token, exprClass, typBigInteger, typBigInteger);
operators.RegisterOperator(token, exprClass, systemTable.TypInteger, typBigInteger);
operators.RegisterOperator(token, exprClass, typBigInteger, systemTable.TypInteger);
end;
begin
typBigInteger:=systemTable.FindTypeSymbol(SYS_BIGINTEGER, cvMagic) as TBaseBigIntegerSymbol;
if operators.FindCaster(typBigInteger, systemTable.TypInteger) <> nil then Exit;
RegisterOperators(ttPLUS, TBigIntegerAddOpExpr);
RegisterOperators(ttMINUS, TBigIntegerSubOpExpr);
RegisterOperators(ttTIMES, TBigIntegerMultOpExpr);
RegisterOperators(ttDIV, TBigIntegerDivOpExpr);
RegisterOperators(ttMOD, TBigIntegerModOpExpr);
RegisterOperators(ttAND, TBigIntegerAndOpExpr);
RegisterOperators(ttOR, TBigIntegerOrOpExpr);
RegisterOperators(ttXOR, TBigIntegerXorOpExpr);
operators.RegisterOperator(ttSHL, TBigIntegerShiftLeftExpr, typBigInteger, systemTable.TypInteger);
operators.RegisterOperator(ttSAR, TBigIntegerShiftRightExpr, typBigInteger, systemTable.TypInteger);
operators.RegisterOperator(ttPLUS_ASSIGN, TBigIntegerPlusAssignExpr, typBigInteger, typBigInteger);
operators.RegisterOperator(ttPLUS_ASSIGN, TBigIntegerPlusAssignExpr, typBigInteger, systemTable.TypInteger);
operators.RegisterOperator(ttMINUS_ASSIGN, TBigIntegerMinusAssignExpr, typBigInteger, typBigInteger);
operators.RegisterOperator(ttMINUS_ASSIGN, TBigIntegerMinusAssignExpr, typBigInteger, systemTable.TypInteger);
operators.RegisterOperator(ttTIMES_ASSIGN, TBigIntegerMultAssignExpr, typBigInteger, typBigInteger);
operators.RegisterOperator(ttTIMES_ASSIGN, TBigIntegerMultAssignExpr, typBigInteger, systemTable.TypInteger);
RegisterOperators(ttEQ, TBigIntegerEqualOpExpr);
RegisterOperators(ttNOTEQ, TBigIntegerNotEqualOpExpr);
RegisterOperators(ttGTR, TBigIntegerGreaterOpExpr);
RegisterOperators(ttGTREQ, TBigIntegerGreaterEqualOpExpr);
RegisterOperators(ttLESS, TBigIntegerLessOpExpr);
RegisterOperators(ttLESSEQ, TBigIntegerLessEqualOpExpr);
operators.RegisterCaster(typBigInteger, systemTable.TypInteger, TConvIntegerToBigIntegerExpr);
operators.RegisterCaster(typBigInteger, systemTable.TypString, TConvStringToBigIntegerExpr);
operators.RegisterCaster(systemTable.TypInteger, typBigInteger, TConvBigIntegerToIntegerExpr);
operators.RegisterCaster(systemTable.TypFloat, typBigInteger, TConvBigIntegerToFloatExpr);
end;
// HandleBigIntegerAbs
//
function HandleBigIntegerAbs(prog : TdwsProgram; argExpr : TTypedExpr) : TTypedExpr;
begin
if argExpr.Typ.UnAliasedTypeIs(TBaseBigIntegerSymbol) then
Result:=TBigIntegerAbsExpr.Create(prog, argExpr)
else Result:=nil;
end;
type
TTypedExprBigIntegerHelper = class helper for TTypedExpr
function EvalAsBigInteger(exec : TdwsExecution) : IdwsBigInteger;
end;
function TTypedExprBigIntegerHelper.EvalAsBigInteger(exec : TdwsExecution) : IdwsBigInteger;
var
v : Variant;
begin
if Typ.UnAliasedType.ClassType = TBaseBigIntegerSymbol then begin
EvalAsVariant(exec, v);
Assert(TVarData(v).VType=varUnknown);
if TVarData(v).VUnknown<>nil then
Result := IdwsBigInteger(TVarData(v).VUnknown)
else Result := TBigIntegerWrapper.CreateZero;
end else Result := TBigIntegerWrapper.CreateInt64( EvalAsInteger(exec) );
end;
// ArgBigInteger
//
function ArgBigInteger(const args : TExprBaseListExec; index : Integer) : IdwsBigInteger;
begin
Result := (args.ExprBase[index] as TTypedExpr).EvalAsBigInteger(args.Exec);
end;
// BigIntegerWrap
//
function BigIntegerWrap(const bi : mpz_t) : IInterface;
begin
Result := TBigIntegerWrapper.Wrap(bi) as IdwsBigInteger;
end;
// ------------------
// ------------------ TBaseBigIntegerSymbol ------------------
// ------------------
// Create
//
constructor TBaseBigIntegerSymbol.Create;
begin
inherited Create(SYS_BIGINTEGER);
end;
// IsCompatible
//
function TBaseBigIntegerSymbol.IsCompatible(typSym : TTypeSymbol) : Boolean;
begin
Result:=(typSym<>nil) and (typSym.UnAliasedType.ClassType=TBaseBigIntegerSymbol);
end;
// InitData
//
procedure TBaseBigIntegerSymbol.InitData(const data : TData; offset : Integer);
begin
data[offset] := IUnknown(nil);
end;
// ------------------
// ------------------ TBigIntegerWrapper ------------------
// ------------------
// CreateZero
//
constructor TBigIntegerWrapper.CreateZero;
begin
inherited Create;
if not Bind_MPIR_DLL then
raise Exception.Create('mpir.dll is required for BigInteger');
mpz_init(Value);
end;
// CreateInt64
//
constructor TBigIntegerWrapper.CreateInt64(const i : Int64);
begin
CreateZero;
mpz_set_int64(Value, i);
end;
// CreateString
//
constructor TBigIntegerWrapper.CreateString(const s : String; base : Integer);
var
buf : RawByteString;
begin
CreateZero;
if s <> '' then begin
ScriptStringToRawByteString(s, buf);
mpz_set_str(Value, Pointer(buf), base);
end;
end;
// Wrap
//
constructor TBigIntegerWrapper.Wrap(const v : mpz_t);
begin
CreateZero;
mpz_set(Value, v);
end;
// Destroy
//
destructor TBigIntegerWrapper.Destroy;
begin
if Value.mp_alloc <> 0 then
mpz_clear(Value);
inherited;
end;
// GetValue
//
function TBigIntegerWrapper.GetValue : pmpz_t;
begin
Result := @Value;
end;
// SetValue
//
procedure TBigIntegerWrapper.SetValue(const v : pmpz_t);
begin
mpz_set(Value, v^);
end;
// GetSelf
//
function TBigIntegerWrapper.GetSelf : TObject;
begin
Result := Self;
end;
// BitLength
//
function TBigIntegerWrapper.BitLength : Integer;
begin
if Value.mp_size = 0 then
Result := 0
else Result := mpz_sizeinbase(Value, 2);
end;
// ToStringBase
//
function TBigIntegerWrapper.ToStringBase(base : Integer) : String;
var
size : Integer;
buf : RawByteString;
begin
Assert(base in [2..62]);
if Value.mp_size = 0 then Exit('0');
size := mpz_sizeinbase(Value, base);
Assert(size > 0);
if Value.mp_size < 0 then
Inc(size);
SetLength(buf, size);
mpz_get_str(Pointer(buf), base, Value);
if (size > 1) and (buf[size] = #0) then
SetLength(buf, size-1); // clear occasional trailing #0
Result := RawByteStringToScriptString(buf);
end;
// ToHexString
//
function TBigIntegerWrapper.ToHexString : String;
begin
Result := ToStringBase(16);
end;
// ToString
//
function TBigIntegerWrapper.ToString : String;
begin
Result := ToStringBase(10);
end;
// ToInt64
//
function TBigIntegerWrapper.ToInt64 : Int64;
var
n : Integer;
begin
Result := 0;
n := Abs(Value.mp_size);
if n > 2 then n := 3;
System.Move(Value.mp_d^, Result, n*4);
if Value.mp_size < 0 then begin
Result := -Result;
end;
end;
// ------------------
// ------------------ TBigIntegerOpExpr ------------------
// ------------------
// Create
//
constructor TBigIntegerOpExpr.Create(Prog: TdwsProgram; const aScriptPos : TScriptPos; aLeft, aRight : TTypedExpr);
begin
inherited;
Bind_MPIR_DLL;
if aLeft.Typ.UnAliasedTypeIs(TBaseIntegerSymbol) then
Typ := aRight.Typ
else Typ := aLeft.Typ;
end;
// ------------------
// ------------------ TBigIntegerAddOpExpr ------------------
// ------------------
procedure TBigIntegerAddOpExpr.EvalAsVariant(exec : TdwsExecution; var result : Variant);
var
bi : TBigIntegerWrapper;
begin
bi := TBigIntegerWrapper.CreateZero;
mpz_add(bi.Value, Left.EvalAsBigInteger(exec).Value^, Right.EvalAsBigInteger(exec).Value^);
result := bi as IdwsBigInteger;
end;
// ------------------
// ------------------ TBigIntegerSubOpExpr ------------------
// ------------------
procedure TBigIntegerSubOpExpr.EvalAsVariant(exec : TdwsExecution; var result : Variant);
var
bi : TBigIntegerWrapper;
begin
bi := TBigIntegerWrapper.CreateZero;
mpz_sub(bi.Value, Left.EvalAsBigInteger(exec).Value^, Right.EvalAsBigInteger(exec).Value^);
result := bi as IdwsBigInteger;
end;
// ------------------
// ------------------ TBigIntegerMultOpExpr ------------------
// ------------------
procedure TBigIntegerMultOpExpr.EvalAsVariant(exec : TdwsExecution; var result : Variant);
var
bi : TBigIntegerWrapper;
begin
bi := TBigIntegerWrapper.CreateZero;
mpz_mul(bi.Value, Left.EvalAsBigInteger(exec).Value^, Right.EvalAsBigInteger(exec).Value^);
result := bi as IdwsBigInteger;
end;
// ------------------
// ------------------ TBigIntegerDivOpExpr ------------------
// ------------------
procedure TBigIntegerDivOpExpr.EvalAsVariant(exec : TdwsExecution; var result : Variant);
var
bi : TBigIntegerWrapper;
begin
bi := TBigIntegerWrapper.CreateZero;
mpz_divexact(bi.Value, Left.EvalAsBigInteger(exec).Value^, Right.EvalAsBigInteger(exec).Value^);
result := bi as IdwsBigInteger;
end;
// ------------------
// ------------------ TBigIntegerModOpExpr ------------------
// ------------------
procedure TBigIntegerModOpExpr.EvalAsVariant(exec : TdwsExecution; var result : Variant);
var
bi : TBigIntegerWrapper;
begin
bi := TBigIntegerWrapper.CreateZero;
mpz_mod(bi.Value, Left.EvalAsBigInteger(exec).Value^, Right.EvalAsBigInteger(exec).Value^);
result := bi as IdwsBigInteger;
end;
// ------------------
// ------------------ TBigIntegerAndOpExpr ------------------
// ------------------
procedure TBigIntegerAndOpExpr.EvalAsVariant(exec : TdwsExecution; var result : Variant);
var
bi : TBigIntegerWrapper;
begin
bi := TBigIntegerWrapper.CreateZero;
mpz_and(bi.Value, Left.EvalAsBigInteger(exec).Value^, Right.EvalAsBigInteger(exec).Value^);
result := bi as IdwsBigInteger;
end;
// ------------------
// ------------------ TBigIntegerOrOpExpr ------------------
// ------------------
procedure TBigIntegerOrOpExpr.EvalAsVariant(exec : TdwsExecution; var result : Variant);
var
bi : TBigIntegerWrapper;
begin
bi := TBigIntegerWrapper.CreateZero;
mpz_ior(bi.Value, Left.EvalAsBigInteger(exec).Value^, Right.EvalAsBigInteger(exec).Value^);
result := bi as IdwsBigInteger;
end;
// ------------------
// ------------------ TBigIntegerXorOpExpr ------------------
// ------------------
procedure TBigIntegerXorOpExpr.EvalAsVariant(exec : TdwsExecution; var result : Variant);
var
bi : TBigIntegerWrapper;
begin
bi := TBigIntegerWrapper.CreateZero;
mpz_xor(bi.Value, Left.EvalAsBigInteger(exec).Value^, Right.EvalAsBigInteger(exec).Value^);
result := bi as IdwsBigInteger;
end;
// ------------------
// ------------------ TBigIntegerRelOpExpr ------------------
// ------------------
// InternalCompare
//
function TBigIntegerRelOpExpr.InternalCompare(exec : TdwsExecution) : Integer;
begin
Result := mpz_cmp(Left.EvalAsBigInteger(exec).Value^, Right.EvalAsBigInteger(exec).Value^);
end;
// ------------------
// ------------------ TBigIntegerEqualOpExpr ------------------
// ------------------
function TBigIntegerEqualOpExpr.EvalAsBoolean(exec : TdwsExecution) : Boolean;
begin
Result := InternalCompare(exec) = 0;
end;
// ------------------
// ------------------ TBigIntegerNotEqualOpExpr ------------------
// ------------------
function TBigIntegerNotEqualOpExpr.EvalAsBoolean(exec : TdwsExecution) : Boolean;
begin
Result := InternalCompare(exec) <> 0;
end;
// ------------------
// ------------------ TBigIntegerGreaterOpExpr ------------------
// ------------------
function TBigIntegerGreaterOpExpr.EvalAsBoolean(exec : TdwsExecution) : Boolean;
begin
Result := InternalCompare(exec) > 0;
end;
// ------------------
// ------------------ TBigIntegerGreaterEqualOpExpr ------------------
// ------------------
function TBigIntegerGreaterEqualOpExpr.EvalAsBoolean(exec : TdwsExecution) : Boolean;
begin
Result := InternalCompare(exec) >= 0;
end;
// ------------------
// ------------------ TBigIntegerLessOpExpr ------------------
// ------------------
function TBigIntegerLessOpExpr.EvalAsBoolean(exec : TdwsExecution) : Boolean;
begin
Result := InternalCompare(exec) < 0;
end;
// ------------------
// ------------------ TBigIntegerLessEqualOpExpr ------------------
// ------------------
function TBigIntegerLessEqualOpExpr.EvalAsBoolean(exec : TdwsExecution) : Boolean;
begin
Result := InternalCompare(exec) <= 0;
end;
// ------------------
// ------------------ TBigIntegerUnaryOpExpr ------------------
// ------------------
constructor TBigIntegerUnaryOpExpr.Create(prog : TdwsProgram; expr : TTypedExpr);
begin
inherited Create(prog, expr);
Typ := prog.Root.SystemTable.SymbolTable.FindTypeSymbol(SYS_BIGINTEGER, cvMagic);
end;
// ------------------
// ------------------ TConvIntegerToBigIntegerExpr ------------------
// ------------------
procedure TConvIntegerToBigIntegerExpr.EvalAsVariant(exec : TdwsExecution; var result : Variant);
begin
result := TBigIntegerWrapper.CreateInt64( Expr.EvalAsInteger(exec) ) as IdwsBigInteger;
end;
// ------------------
// ------------------ TConvStringToBigIntegerExpr ------------------
// ------------------
procedure TConvStringToBigIntegerExpr.EvalAsVariant(exec : TdwsExecution; var result : Variant);
var
s : String;
begin
Expr.EvalAsString(exec, s);
result := TBigIntegerWrapper.CreateString( s, 10 ) as IdwsBigInteger;
end;
// ------------------
// ------------------ TConvBigIntegerToIntegerExpr ------------------
// ------------------
function TConvBigIntegerToIntegerExpr.EvalAsInteger(exec : TdwsExecution) : Int64;
begin
Result := Expr.EvalAsBigInteger(exec).ToInt64;
end;
// ------------------
// ------------------ TConvBigIntegerToFloatExpr ------------------
// ------------------
function TConvBigIntegerToFloatExpr.EvalAsFloat(exec : TdwsExecution) : Double;
begin
Result := mpz_get_d(Expr.EvalAsBigInteger(exec).Value^);
end;
// ------------------
// ------------------ TBigIntegerToStringFunc ------------------
// ------------------
// DoEvalAsString
//
procedure TBigIntegerToStringFunc.DoEvalAsString(const args : TExprBaseListExec; var Result : UnicodeString);
begin
Result := ArgBigInteger(args, 0).ToStringBase(args.AsInteger[1]);
end;
// ------------------
// ------------------ TStringToBigIntegerFunc ------------------
// ------------------
// DoEvalAsVariant
//
procedure TStringToBigIntegerFunc.DoEvalAsVariant(const args : TExprBaseListExec; var result : Variant);
begin
result := TBigIntegerWrapper.CreateString( args.AsString[0], args.AsInteger[1] ) as IdwsBigInteger;
end;
// ------------------
// ------------------ TBigIntegerToHexFunc ------------------
// ------------------
// DoEvalAsString
//
procedure TBigIntegerToHexFunc.DoEvalAsString(const args : TExprBaseListExec; var Result : UnicodeString);
begin
Result := ArgBigInteger(args, 0).ToStringBase(16);
end;
// ------------------
// ------------------ THexToBigIntegerFunc ------------------
// ------------------
// DoEvalAsVariant
//
procedure THexToBigIntegerFunc.DoEvalAsVariant(const args : TExprBaseListExec; var result : Variant);
begin
result := TBigIntegerWrapper.CreateString( args.AsString[0], 16 ) as IdwsBigInteger;
end;
// ------------------
// ------------------ TBigIntegerToFloatFunc ------------------
// ------------------
procedure TBigIntegerToFloatFunc.DoEvalAsFloat(const args : TExprBaseListExec; var result : Double);
begin
result := mpz_get_d(ArgBigInteger(args, 0).Value^);
end;
// ------------------
// ------------------ TBigIntegerToIntegerFunc ------------------
// ------------------
function TBigIntegerToIntegerFunc.DoEvalAsInteger(const args : TExprBaseListExec) : Int64;
begin
Result := ArgBigInteger(args, 0).ToInt64;
end;
// ------------------
// ------------------ TBigIntegerOddFunc ------------------
// ------------------
function TBigIntegerOddFunc.DoEvalAsBoolean(const args : TExprBaseListExec) : Boolean;
begin
Result := mpz_odd_p(ArgBigInteger(args, 0).Value^);
end;
// ------------------
// ------------------ TBigIntegerEvenFunc ------------------
// ------------------
function TBigIntegerEvenFunc.DoEvalAsBoolean(const args : TExprBaseListExec) : Boolean;
begin
Result := mpz_even_p(ArgBigInteger(args, 0).Value^);
end;
// ------------------
// ------------------ TBigIntegerSignFunc ------------------
// ------------------
function TBigIntegerSignFunc.DoEvalAsInteger(const args : TExprBaseListExec) : Int64;
begin
Result := mpz_sgn(ArgBigInteger(args, 0).Value^);
end;
// ------------------
// ------------------ TBigIntegerAbsExpr ------------------
// ------------------
// EvalAsVariant
//
procedure TBigIntegerAbsExpr.EvalAsVariant(exec : TdwsExecution; var result : Variant);
var
bi : TBigIntegerWrapper;
begin
bi := TBigIntegerWrapper.CreateZero;
bi.SetValue(Expr.EvalAsBigInteger(exec).Value);
bi.Value.mp_size := Abs(bi.Value.mp_size);
result := bi as IdwsBigInteger;
end;
// ------------------
// ------------------ TBigIntegerGcdFunc ------------------
// ------------------
procedure TBigIntegerGcdFunc.DoEvalAsVariant(const args : TExprBaseListExec; var result : Variant);
var
bi : TBigIntegerWrapper;
begin
bi := TBigIntegerWrapper.CreateZero;
mpz_gcd(bi.Value, ArgBigInteger(args, 0).Value^, ArgBigInteger(args, 1).Value^);
result := bi as IdwsBigInteger;
end;
// ------------------
// ------------------ TBigIntegerLcmFunc ------------------
// ------------------
procedure TBigIntegerLcmFunc.DoEvalAsVariant(const args : TExprBaseListExec; var result : Variant);
var
bi : TBigIntegerWrapper;
begin
bi := TBigIntegerWrapper.CreateZero;
mpz_lcm(bi.Value, ArgBigInteger(args, 0).Value^, ArgBigInteger(args, 1).Value^);
result := bi as IdwsBigInteger;
end;
// ------------------
// ------------------ TBigIntegerIsPrimeFunc ------------------
// ------------------
// DoEvalAsBoolean
//
function TBigIntegerIsPrimeFunc.DoEvalAsBoolean(const args : TExprBaseListExec) : Boolean;
var
state : gmp_randstate_t;
begin
gmp_randinit_mt(state);
Result := mpz_probable_prime_p(ArgBigInteger(args, 0).Value^, state, args.AsInteger[1], 0) > 0;
gmp_randclear(state);
end;
// ------------------
// ------------------ TBigIntegerPowerFunc ------------------
// ------------------
procedure TBigIntegerPowerFunc.DoEvalAsVariant(const args : TExprBaseListExec; var result : Variant);
var
bi : TBigIntegerWrapper;
begin
bi := TBigIntegerWrapper.CreateZero;
mpz_pow_ui(bi.Value, ArgBigInteger(args, 0).Value^, args.AsInteger[1]);
result := bi as IdwsBigInteger;
end;
// ------------------
// ------------------ TBigIntegerSqrFunc ------------------
// ------------------
procedure TBigIntegerSqrFunc.DoEvalAsVariant(const args : TExprBaseListExec; var result : Variant);
var
bi : TBigIntegerWrapper;
begin
bi := TBigIntegerWrapper.CreateZero;
mpz_pow_ui(bi.Value, ArgBigInteger(args, 0).Value^, 2);
result := bi as IdwsBigInteger;
end;
// ------------------
// ------------------ TBigIntegerDivModFunc ------------------
// ------------------
procedure TBigIntegerDivModFunc.DoEvalProc(const args : TExprBaseListExec);
var
biQ, biR : TBigIntegerWrapper;
begin
biQ := TBigIntegerWrapper.CreateZero;
biR := TBigIntegerWrapper.CreateZero;
mpz_tdiv_qr(biQ.Value, biR.Value, ArgBigInteger(args, 0).Value^, ArgBigInteger(args, 1).Value^);
args.ExprBase[2].AssignValue(args.Exec, biQ as IdwsBigInteger);
args.ExprBase[3].AssignValue(args.Exec, biR as IdwsBigInteger);
end;
// ------------------
// ------------------ TBigIntegerToBlobFunc ------------------
// ------------------
procedure TBigIntegerToBlobFunc.DoEvalAsVariant(const args : TExprBaseListExec; var result : Variant);
var
bufString : RawByteString;
pDest : PInteger;
n : Integer;
gmp : pmpz_t;
begin
gmp := ArgBigInteger(args, 0).Value;
n := Abs(gmp.mp_size);
if n = 0 then
bufString := ''
else begin
SetLength(bufString, n*4+4);
pDest := Pointer(bufString);
pDest^ := n;
if n > 0 then begin
Inc(pDest);
System.Move(gmp.mp_d^, pDest^, n*4);
end;
end;
Result := bufString;
end;
// ------------------
// ------------------ TBlobToBigIntegerFunc ------------------
// ------------------
procedure TBlobToBigIntegerFunc.DoEvalAsVariant(const args : TExprBaseListExec; var result : Variant);
var
bufString : RawByteString;
pSrc : PInteger;
n : Integer;
bi : TBigIntegerWrapper;
begin
bi := TBigIntegerWrapper.CreateZero;
bufString := args.AsDataString[0];
if bufString <> '' then begin
Assert( (Length(bufString) and 3) = 0 );
pSrc := Pointer(bufString);
if pSrc^ <> 0 then begin
n := Abs(pSrc^);
mpz_realloc(bi.Value, n);
bi.Value.mp_size := pSrc^;
Inc(pSrc);
System.Move( bi.Value.mp_d^, pSrc^, n*4);
end;
end;
Result := bi as IdwsBigInteger;
end;
// ------------------
// ------------------ TBigIntegerShiftLeftExpr ------------------
// ------------------
procedure TBigIntegerShiftLeftExpr.EvalAsVariant(exec : TdwsExecution; var result : Variant);
var
bi : TBigIntegerWrapper;
begin
bi := TBigIntegerWrapper.CreateZero;
mpz_mul_2exp(bi.Value, Left.EvalAsBigInteger(exec).Value^, Right.EvalAsInteger(exec));
result := bi as IdwsBigInteger;
end;
// ------------------
// ------------------ TBigIntegerShiftRightExpr ------------------
// ------------------
procedure TBigIntegerShiftRightExpr.EvalAsVariant(exec : TdwsExecution; var result : Variant);
var
bi : TBigIntegerWrapper;
begin
bi := TBigIntegerWrapper.CreateZero;
mpz_tdiv_q_2exp(bi.Value, Left.EvalAsBigInteger(exec).Value^, Right.EvalAsInteger(exec));
result := bi as IdwsBigInteger;
end;
// ------------------
// ------------------ TBigIntegerOpAssignExpr ------------------
// ------------------
procedure TBigIntegerOpAssignExpr.TypeCheckAssign(prog : TdwsProgram; exec : TdwsExecution);
begin
// nothing here
end;
// ------------------
// ------------------ TBigIntegerPlusAssignExpr ------------------
// ------------------
procedure TBigIntegerPlusAssignExpr.EvalNoResult(exec : TdwsExecution);
var
bi : TBigIntegerWrapper;
begin
bi := TBigIntegerWrapper.CreateZero;
mpz_add(bi.Value, Left.EvalAsBigInteger(exec).Value^, Right.EvalAsBigInteger(exec).Value^);
FLeft.AssignValue(exec, bi as IdwsBigInteger);
end;
// ------------------
// ------------------ TBigIntegerMinusAssignExpr ------------------
// ------------------
procedure TBigIntegerMinusAssignExpr.EvalNoResult(exec : TdwsExecution);
var
bi : TBigIntegerWrapper;
begin
bi := TBigIntegerWrapper.CreateZero;
mpz_sub(bi.Value, Left.EvalAsBigInteger(exec).Value^, Right.EvalAsBigInteger(exec).Value^);
FLeft.AssignValue(exec, bi as IdwsBigInteger);
end;
// ------------------
// ------------------ TBigIntegerMultAssignExpr ------------------
// ------------------
procedure TBigIntegerMultAssignExpr.EvalNoResult(exec : TdwsExecution);
var
bi : TBigIntegerWrapper;
begin
bi := TBigIntegerWrapper.CreateZero;
mpz_mul(bi.Value, Left.EvalAsBigInteger(exec).Value^, Right.EvalAsBigInteger(exec).Value^);
FLeft.AssignValue(exec, bi as IdwsBigInteger);
end;
// ------------------
// ------------------ TBigIntegerRandomFunc ------------------
// ------------------
// DoEvalAsVariant
//
procedure TBigIntegerRandomFunc.DoEvalAsVariant(const args : TExprBaseListExec; var result : Variant);
function RandomBigIntegerOfBitLength(nb : Integer) : IdwsBigInteger;
var
mask : Integer;
bytes : TBytes;
rnd : RawByteString;
bi : TBigIntegerWrapper;
begin
// adapted from BigInteger.Create(NumBits: Integer; const Random: IRandom)
// uses cryptographic random
rnd := CryptographicRandom( (nb + 7) div 8 + 1 );
Setlength(bytes, Length(rnd));
System.Move(rnd[1], bytes[0], Length(rnd));
// One byte too many was allocated, to get a top byte of 0, i.e. always positive.
bytes[High(bytes)] := 0;
// Set bits above required bit length to 0.
mask := $7F shr (7 - (nb and 7));
bytes[High(bytes)-1] := bytes[High(bytes)-1] and mask;
bi := TBigIntegerWrapper.CreateZero;
mpz_realloc(bi.Value, (nb div (8*4))+1);
FillChar(bi.Value.mp_d^, bi.Value.mp_alloc*4, 0);
bi.Value.mp_size := bi.Value.mp_alloc;
System.Move(bytes[0], bi.Value.mp_d^, Length(bytes));
Result := bi as IdwsBigInteger;
end;
var
bi, limit : IdwsBigInteger;
bits : Integer;
begin
limit := ArgBigInteger(args, 0);
if mpz_cmp_ui(limit.Value^, 1) <= 0 then begin
result := TBigIntegerWrapper.CreateZero as IdwsBigInteger;
end else begin
bits := limit.BitLength;
repeat
bi := RandomBigIntegerOfBitLength(bits);
until mpz_cmp(bi.Value^, limit.Value^) < 0;
end;
result := bi;
end;
// ------------------
// ------------------ TBigIntegerBitLengthFunc ------------------
// ------------------
function TBigIntegerBitLengthFunc.DoEvalAsInteger(const args : TExprBaseListExec) : Int64;
begin
Result := ArgBigInteger(args, 0).BitLength;
end;
// ------------------
// ------------------ TBigIntegerModPowFunc ------------------
// ------------------
procedure TBigIntegerModPowFunc.DoEvalAsVariant(const args : TExprBaseListExec; var result : Variant);
var
bi : TBigIntegerWrapper;
begin
bi := TBigIntegerWrapper.CreateZero;
mpz_powm(bi.Value,
ArgBigInteger(args, 0).Value^,
ArgBigInteger(args, 1).Value^,
ArgBigInteger(args, 2).Value^);
Result := bi as IdwsBigInteger;
end;
// ------------------
// ------------------ TBigIntegerFactorialFunc ------------------
// ------------------
procedure TBigIntegerFactorialFunc.DoEvalAsVariant(const args : TExprBaseListExec; var result : Variant);
var
bi : TBigIntegerWrapper;
i : Int64;
begin
bi := TBigIntegerWrapper.CreateZero;
i:=args.AsInteger[0];
if i <= 1 then
mpz_set_uint64(bi.Value, 1)
else mpz_fac_ui(bi.Value, i);
Result := bi as IdwsBigInteger;
end;
// ------------------------------------------------------------------
// ------------------------------------------------------------------
// ------------------------------------------------------------------
initialization
// ------------------------------------------------------------------
// ------------------------------------------------------------------
// ------------------------------------------------------------------
dwsInternalUnit.AddSymbolsRegistrationProc(RegisterBigIntegerType);
dwsInternalUnit.AddOperatorsRegistrationProc(RegisterBigIntegerOperators);
dwsInternalUnit.AddAbsHandler(HandleBigIntegerAbs);
RegisterInternalStringFunction(TBigIntegerToStringFunc, 'BigIntegerToHex', ['v', SYS_BIGINTEGER, 'base=10', SYS_INTEGER], [iffStateLess], 'ToString');
RegisterInternalFunction(TStringToBigIntegerFunc, 'StringToBigInteger', ['s', SYS_STRING, 'base=10', SYS_INTEGER], SYS_BIGINTEGER, [iffStateLess], 'ToBigInteger');
RegisterInternalStringFunction(TBigIntegerToHexFunc, 'BigIntegerToHex', ['v', SYS_BIGINTEGER], [iffStateLess], 'ToHex');
RegisterInternalFunction(THexToBigIntegerFunc, 'HexToBigInteger', ['h', SYS_STRING], SYS_BIGINTEGER, [iffStateLess], 'HexToBigInteger');
RegisterInternalFunction(TBigIntegerToBlobFunc, 'BigIntegerToBlobParameter', ['v', SYS_BIGINTEGER], SYS_VARIANT, [iffStateLess], 'ToBlobParameter');
RegisterInternalFunction(TBlobToBigIntegerFunc, 'BlobFieldToBigInteger', ['b', SYS_STRING], SYS_BIGINTEGER, [iffStateLess]);
RegisterInternalFloatFunction(TBigIntegerToFloatFunc, '', ['v', SYS_BIGINTEGER], [iffStateLess], 'ToFloat');
RegisterInternalIntFunction(TBigIntegerToIntegerFunc, '', ['v', SYS_BIGINTEGER], [iffStateLess], 'ToInteger');
RegisterInternalBoolFunction(TBigIntegerOddFunc, 'Odd', ['i', SYS_BIGINTEGER], [iffStateLess, iffOverloaded], 'IsOdd');
RegisterInternalBoolFunction(TBigIntegerEvenFunc, 'Even', ['i', SYS_BIGINTEGER], [iffStateLess, iffOverloaded], 'IsEven');
RegisterInternalIntFunction(TBigIntegerSignFunc, 'Sign', ['v', SYS_BIGINTEGER], [iffStateLess, iffOverloaded], 'Sign');
RegisterInternalIntFunction(TBigIntegerBitLengthFunc, '', ['v', SYS_BIGINTEGER], [iffStateLess], 'BitLength');
RegisterInternalFunction(TBigIntegerGcdFunc, 'Gcd', ['a', SYS_BIGINTEGER, 'b', SYS_BIGINTEGER], SYS_BIGINTEGER, [iffStateLess, iffOverloaded]);
RegisterInternalFunction(TBigIntegerLcmFunc, 'Gcd', ['a', SYS_BIGINTEGER, 'b', SYS_BIGINTEGER], SYS_BIGINTEGER, [iffStateLess, iffOverloaded]);
RegisterInternalBoolFunction(TBigIntegerIsPrimeFunc, 'IsPrime',['n', SYS_BIGINTEGER, 'prob=25', SYS_INTEGER], [iffStateLess, iffOverloaded], 'IsPrime');
RegisterInternalFunction(TBigIntegerPowerFunc, 'IntPower', ['base', SYS_BIGINTEGER, 'exponent', SYS_INTEGER], SYS_BIGINTEGER, [iffStateLess, iffOverloaded], 'Power');
RegisterInternalFunction(TBigIntegerSqrFunc, 'Sqr', ['v', SYS_BIGINTEGER], SYS_BIGINTEGER, [iffStateLess, iffOverloaded], 'Sqr');
RegisterInternalProcedure(TBigIntegerDivModFunc, 'DivMod',
['dividend', SYS_BIGINTEGER, 'divisor', SYS_BIGINTEGER,
'@result', SYS_BIGINTEGER, '@remainder', SYS_BIGINTEGER], '', [iffOverloaded]);
RegisterInternalFunction(TBigIntegerModPowFunc, 'ModPow', ['base', SYS_BIGINTEGER, 'exponent', SYS_BIGINTEGER, 'modulus', SYS_BIGINTEGER],
SYS_BIGINTEGER, [iffStateLess, iffOverloaded], 'ModPow');
RegisterInternalFunction(TBigIntegerModPowFunc, 'ModPow', ['base', SYS_BIGINTEGER, 'exponent', SYS_INTEGER, 'modulus', SYS_BIGINTEGER],
SYS_BIGINTEGER, [iffStateLess, iffOverloaded], 'ModPow');
RegisterInternalFunction(TBigIntegerFactorialFunc, 'BigFactorial', ['n', SYS_INTEGER], SYS_VARIANT, [iffStateLess]);
RegisterInternalFunction(TBigIntegerRandomFunc, 'RandomBigInteger', ['limitPlusOne', SYS_BIGINTEGER], SYS_BIGINTEGER);
end.
| 34.79316 | 173 | 0.628446 |
fc0821a8728be89133ab0ec015dc4df0d9e5fda7 | 190 | dpr | Pascal | Grafika Komputer/Modul10/ProjectRotasi.dpr | r2itech/Project-Delphi7 | 293fa9579cd896e3a03b1669ca323b0af5a16717 | [
"Apache-2.0"
]
| null | null | null | Grafika Komputer/Modul10/ProjectRotasi.dpr | r2itech/Project-Delphi7 | 293fa9579cd896e3a03b1669ca323b0af5a16717 | [
"Apache-2.0"
]
| null | null | null | Grafika Komputer/Modul10/ProjectRotasi.dpr | r2itech/Project-Delphi7 | 293fa9579cd896e3a03b1669ca323b0af5a16717 | [
"Apache-2.0"
]
| null | null | null | program ProjectRotasi;
uses
Forms,
UnitRotasi in 'UnitRotasi.pas' {Form1};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
| 13.571429 | 41 | 0.726316 |
47b7dbfb36d63ae284d367792c3c4f6bb1f261a0 | 6,586 | pas | Pascal | Quake_Delphi_Sources/src/cvar.pas | delphi-pascal-archive/quake-delphi-sources | d7b90ca29ea43f9f7f11bb3646bee5050b100509 | [
"Unlicense"
]
| null | null | null | Quake_Delphi_Sources/src/cvar.pas | delphi-pascal-archive/quake-delphi-sources | d7b90ca29ea43f9f7f11bb3646bee5050b100509 | [
"Unlicense"
]
| null | null | null | Quake_Delphi_Sources/src/cvar.pas | delphi-pascal-archive/quake-delphi-sources | d7b90ca29ea43f9f7f11bb3646bee5050b100509 | [
"Unlicense"
]
| null | null | null | // ------------------------------------------------------------------------------
//
// Copyright (C) 1996-1997 Id Software, Inc.
//
// This program 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 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.
//
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// ------------------------------------------------------------------------------
// Roman Vereshagin
//
//
{$Z4}
unit cvar;
// cvar.c -- dynamic variable tracking
interface
uses
Unit_SysTools;
type
Pcvar_t = ^cvar_t;
cvar_t = record
name: PChar;
text: PChar;
archive: qboolean; // set to true to cause it to be saved to vars.rc
server: qboolean; // notifies players when changed
value: single;
next: Pcvar_t;
end;
type
TConsoleVars = class
cvar_vars: Pcvar_t;
constructor Create;
destructor Destroy; override;
function FindVar(var_name: PChar): Pcvar_t;
function VariableValue(var_name: PChar): single;
function VariableString(var_name: PChar): PChar;
function CompleteVariable(partial: PChar): PChar;
procedure SetValue(const var_name: PChar; const value: PChar); overload;
procedure SetValue(const var_name: PChar; const value: single); overload;
procedure SetValue(const var_name: PChar; const value: qboolean); overload;
procedure SetValue(const var_name: string; const value: single); overload;
procedure SetValue(const var_name: string; const value: qboolean); overload;
procedure RegisterVariable(variable: Pcvar_t);
function Command: qboolean;
procedure WriteVariables(var f: text);
end;
var
ConsoleVars: TConsoleVars;
implementation
uses
common,
console,
zone,
sv_main,
host,
cmd;
{ TConsoleVars }
function TConsoleVars.Command: qboolean;
var
v: Pcvar_t;
begin
// check variables
v := FindVar(Cmd_Argv_f(0));
if v = nil then
begin
result := false;
exit;
end;
// perform a variable print or set
if Cmd_Argc_f = 1 then
begin
Con_Printf('"%s" is "%s"'#10, [v.name, v.text]);
result := true;
exit;
end;
SetValue(v.name, Cmd_Argv_f(1));
result := true;
end;
function TConsoleVars.CompleteVariable(partial: PChar): PChar;
var
Item: Pcvar_t;
len: integer;
begin
len := Q_strlen(partial);
if len = 0 then
begin
result := nil;
exit;
end;
// check functions
Item := cvar_vars;
while Item <> nil do
begin
if Q_strncmp(partial, Item.name, len) = 0 then
begin
result := Item.name;
exit;
end;
Item := Item.next;
end;
result := nil;
end;
constructor TConsoleVars.Create;
begin
inherited;
end;
destructor TConsoleVars.Destroy;
begin
inherited;
end;
function TConsoleVars.FindVar(var_name: PChar): Pcvar_t;
var
Item: Pcvar_t;
begin
Item := cvar_vars;
while Item <> nil do
begin
if Q_strcmp(var_name, Item.name) = 0 then
begin
result := Item;
exit;
end;
Item := Item.next;
end;
result := nil;
end;
procedure TConsoleVars.RegisterVariable(variable: Pcvar_t);
var
oldstr: PChar;
begin
// first check to see if it has allready been defined
if FindVar(variable.name) <> nil then
begin
Con_Printf('Can''t register variable %s, allready defined'#10, [variable.name]);
exit;
end;
// check for overlap with a command
if Cmd_Exists(variable.name) then
begin
Con_Printf('Cvar_RegisterVariable: %s is a command'#10, [variable.name]);
exit;
end;
// copy the value off, because future sets will Z_Free it
oldstr := variable.text;
variable.text := Z_Malloc(Q_strlen(variable.text) + 1);
Q_strcpy(variable.text, oldstr);
variable.value := Q_atof(variable.text);
// link the variable in
variable.next := cvar_vars;
cvar_vars := variable;
end;
procedure TConsoleVars.SetValue(const var_name: PChar; const value: qboolean);
var
f: single;
begin
if value then f := 1.0
else f := 0.0;
SetValue(var_name, f);
end;
procedure TConsoleVars.SetValue(const var_name: PChar; const value: single);
var
val: array[0..31] of char;
begin
sprintf(val, '%f', [value]);
SetValue(var_name, val);
end;
procedure TConsoleVars.SetValue(const var_name: PChar; const value: PChar);
var
Item: Pcvar_t;
changed: qboolean;
begin
Item := FindVar(var_name);
if Item = nil then
begin // there is an error in C code if this happens
Con_Printf('Cvar_Set: variable %s not found'#10, [var_name]);
exit;
end;
changed := Q_strcmp(Item.text, value) = 0;
Z_Free(Item.text); // free the old value string
Item.text := Z_Malloc(Q_strlen(value) + 1);
Q_strcpy(Item.text, value);
Item.value := Q_atof(Item.text);
if Item.server and changed then
begin
if sv.active then
SV_BroadcastPrintf('"%s" changed to "%s"'#10, [Item.name, Item.text]);
end;
end;
procedure TConsoleVars.SetValue(const var_name: string; const value: qboolean);
begin
SetValue(PChar(var_name), value);
end;
procedure TConsoleVars.SetValue(const var_name: string; const value: single);
begin
SetValue(PChar(var_name), value);
end;
function TConsoleVars.VariableString(var_name: PChar): PChar;
var
Item: Pcvar_t;
begin
Item := FindVar(var_name);
if Item = nil then result := ''
else result := Item.text;
end;
function TConsoleVars.VariableValue(var_name: PChar): single;
var
Item: Pcvar_t;
begin
Item := FindVar(var_name);
if Item = nil then result := 0
else result := Q_atof(Item.text);
end;
procedure TConsoleVars.WriteVariables(var f: text);
var
Item: Pcvar_t;
begin
Item := cvar_vars;
while Item <> nil do
begin
if Item.archive then
fprintf(f, '%s "%s"'#10, [Item.name, Item.text]);
Item := Item.next;
end;
end;
initialization
ConsoleVars := TConsoleVars.Create;
finalization
ConsoleVars.Free;
end.
| 23.272085 | 85 | 0.646523 |
47e3a2daf358bd052d2ca94bc2eaa95db6caf1a8 | 1,641 | pas | Pascal | theme/AMegaDemo/UnitTsShellControls.pas | AbdelliNasredine/gestion_budjet | ada33c945092d0036ef75a13f34b15cb2ad367e4 | [
"MIT"
]
| null | null | null | theme/AMegaDemo/UnitTsShellControls.pas | AbdelliNasredine/gestion_budjet | ada33c945092d0036ef75a13f34b15cb2ad367e4 | [
"MIT"
]
| null | null | null | theme/AMegaDemo/UnitTsShellControls.pas | AbdelliNasredine/gestion_budjet | ada33c945092d0036ef75a13f34b15cb2ad367e4 | [
"MIT"
]
| null | null | null | unit UnitTsShellControls;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, StdCtrls, ComCtrls,
Controls, Forms, Dialogs, Buttons, ImgList, UnitBaseMenu,
sGroupBox, sCheckBox, sListView, acShellCtrls, sComboBoxes, sTreeView, sFrameAdapter;
type
TFrameTsShellControls = class(TFrameBaseMenu)
sShellTreeView1: TsShellTreeView;
sShellComboBox1: TsShellComboBox;
sShellListView1: TsShellListView;
sCheckBox1: TsCheckBox;
sCheckBox2: TsCheckBox;
sCheckBox3: TsCheckBox;
sRadioGroup1: TsRadioGroup;
sRadioGroup2: TsRadioGroup;
procedure sCheckBox2Click(Sender: TObject);
procedure sCheckBox1Click(Sender: TObject);
procedure sRadioGroup1Change(Sender: TObject);
procedure sRadioGroup2Change(Sender: TObject);
procedure sCheckBox3Click(Sender: TObject);
public
end;
var
FrameTsShellControls: TFrameTsShellControls;
implementation
{$R *.dfm}
procedure TFrameTsShellControls.sCheckBox1Click(Sender: TObject);
begin
sShellListView1.AutoContextMenus := sCheckBox1.Checked;
end;
procedure TFrameTsShellControls.sCheckBox2Click(Sender: TObject);
begin
sShellListView1.AutoRefresh := sCheckBox2.Checked;
end;
procedure TFrameTsShellControls.sCheckBox3Click(Sender: TObject);
begin
sShellListView1.AutoNavigate := sCheckBox3.Checked;
end;
procedure TFrameTsShellControls.sRadioGroup1Change(Sender: TObject);
begin
sShellListView1.ShowExt := TacShowExtension(sRadioGroup1.ItemIndex);
end;
procedure TFrameTsShellControls.sRadioGroup2Change(Sender: TObject);
begin
sShellListView1.ViewStyle := TViewStyle(sRadioGroup2.ItemIndex);
end;
end.
| 24.132353 | 87 | 0.797075 |
47f5c86ec624ed1b4be8ea9d60b2159102298d8d | 253 | dpr | Pascal | abp/Sound/BASSlib/BASS_CD/ORIGINAL/delphi/cdtest/cdtest.dpr | pyrroman/au3-boilerplate | 596a3aa68d4d6b48dd79ed737d1e11604ac9e92f | [
"BSD-3-Clause"
]
| 8 | 2019-07-02T15:59:30.000Z | 2021-07-13T05:13:43.000Z | abp/Sound/BASSlib/BASS_CD/ORIGINAL/delphi/cdtest/cdtest.dpr | pyrroman/au3-boilerplate | 596a3aa68d4d6b48dd79ed737d1e11604ac9e92f | [
"BSD-3-Clause"
]
| null | null | null | abp/Sound/BASSlib/BASS_CD/ORIGINAL/delphi/cdtest/cdtest.dpr | pyrroman/au3-boilerplate | 596a3aa68d4d6b48dd79ed737d1e11604ac9e92f | [
"BSD-3-Clause"
]
| 1 | 2019-07-02T15:59:31.000Z | 2019-07-02T15:59:31.000Z | program cdtest;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1},
BASSCD in '..\basscd.pas',
Bass in '..\Bass.pas';
begin
Application.Initialize;
Application.Title := 'BASSCD test';
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
| 16.866667 | 40 | 0.683794 |
47767ba7afa10f0b5472b622359d25690163e2df | 1,467 | pas | Pascal | 00_Common/U_Producers.pas | jrgdre/Tread_POC | 6db9ffc25870708e92f42f648159c70d94a808b6 | [
"MIT"
]
| null | null | null | 00_Common/U_Producers.pas | jrgdre/Tread_POC | 6db9ffc25870708e92f42f648159c70d94a808b6 | [
"MIT"
]
| null | null | null | 00_Common/U_Producers.pas | jrgdre/Tread_POC | 6db9ffc25870708e92f42f648159c70d94a808b6 | [
"MIT"
]
| null | null | null | {! Common data structures, Producers.
@copyright
(c)2021 J.Drechsler
@license
MIT:
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
@author
jrgdre: J.Drechsler
@version
1.0.0 2021-07-19 jrgdre, initial release
}
unit U_Producers;
{$mode Delphi}
interface
uses
U_Beverages;
type
{! Not multi-threading enabled coffee maker.
}
TCoffeeMaker = class
public
procedure MakeCoffee(const typeOfCoffee: TCoffee);
end;
implementation
uses
classes,
sysutils;
{ TCoffeeMaker }
{! Make a coffee.
Plain old object. Nothing to see here.
It takes the coffee maker between 10..21ms to make a coffe,
depending on the type of coffee and some random factor.
}
procedure TCoffeeMaker.MakeCoffee(
const typeOfCoffee: TCoffee
);
var
ran: Integer;
begin
ran := Random(10);
case typeOfCoffee of
cAmericano : Sleep(10+ran);
cCappuccino: Sleep(11+ran);
cEspresso : Sleep(12+ran);
end;
end;
end.
| 20.957143 | 71 | 0.73756 |
473accd72ba0ef7cc592460ddcfc6bb50100c675 | 9,514 | pas | Pascal | Components/JVCL/examples/JvErrorIndicator/JvErrorIndicatorMainDemoForm.pas | sabatex/Delphi | 0efbe6eb38bf8aa2bf269d1866741266e90b9cbf | [
"MIT"
]
| null | null | null | Components/JVCL/examples/JvErrorIndicator/JvErrorIndicatorMainDemoForm.pas | sabatex/Delphi | 0efbe6eb38bf8aa2bf269d1866741266e90b9cbf | [
"MIT"
]
| null | null | null | Components/JVCL/examples/JvErrorIndicator/JvErrorIndicatorMainDemoForm.pas | sabatex/Delphi | 0efbe6eb38bf8aa2bf269d1866741266e90b9cbf | [
"MIT"
]
| 1 | 2019-12-24T08:39:18.000Z | 2019-12-24T08:39:18.000Z | {******************************************************************
JEDI-VCL Demo
Copyright (C) 2002 Project JEDI
Original author:
Contributor(s):
You may retrieve the latest version of this file at the JEDI-JVCL
home page, located at http://jvcl.sourceforge.net
The contents of this file are used with permission, subject to
the Mozilla Public License Version 1.1 (the "License"); you may
not use this file except in compliance with the License. You may
obtain a copy of the License at
http://www.mozilla.org/MPL/MPL-1_1Final.html
Software distributed under the License is distributed on an
"AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
implied. See the License for the specific language governing
rights and limitations under the License.
******************************************************************}
{$I jvcl.inc}
unit JvErrorIndicatorMainDemoForm;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, ImgList, ComCtrls,
JvComponent, JvErrorIndicator, JvExControls, JvImageSquare;
type
// Example of a control that implements the IJvErrorIndicatorClient interface
TJvErrorClientEdit = class(TEdit, IUnknown, IJvErrorIndicatorClient)
private
FErrorMessage: WideString;
FErrorIndicator: IJvErrorIndicator;
{$IFNDEF COMPILER6_UP}
// D5 and below doesn't support interface properties, so we fake out with a TComponent property
// and instead check the supported interfaces in the setErrorIndicatorComp
FErrorIndicatorComp: TComponent;
procedure setErrorIndicatorComp(const Value: TComponent);
{$ENDIF}
{ IJvErrorIndicatorClient}
procedure UpdateProvider;
procedure ClearProvider;
protected
procedure setErrorIndicator(const Value: IJvErrorIndicator); virtual;
function getErrorIndicator: IJvErrorIndicator; virtual;
function getControl: TControl; virtual;
procedure setErrorMessage(const Value: WideString); virtual;
function getErrorMessage: WideString; virtual;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
public
procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); override;
published
{$IFDEF COMPILER6_UP}
property ErrorIndicator: IJvErrorIndicator read getErrorIndicator write setErrorIndicator;
{$ELSE}
property ErrorIndicator: TComponent read FErrorIndicatorComp write setErrorIndicatorComp;
{$ENDIF}
property ErrorMessage: WideString read getErrorMessage write setErrorMessage;
end;
TJvErrorIndicatorMainDemoFrm = class(TForm)
btnClearErrors: TButton;
memDescription: TMemo;
il16: TImageList;
btnShowErrors: TButton;
gbOptions: TGroupBox;
Label1: TLabel;
cbImageAlignment: TComboBox;
Label2: TLabel;
edImagePadding: TEdit;
udImagePadding: TUpDown;
Label3: TLabel;
cbBlinkStyle: TComboBox;
Label4: TLabel;
edBlinkRate: TEdit;
udBlinkRate: TUpDown;
btnUpdate: TButton;
Label5: TLabel;
edImageIndex: TEdit;
udImageIndex: TUpDown;
isPreview: TJvImageSquare;
chkAutoScroll: TCheckBox;
il32: TImageList;
chkLarge: TCheckBox;
lblClient: TLabel;
procedure FormCreate(Sender: TObject);
procedure btnClearErrorsClick(Sender: TObject);
procedure btnShowErrorsClick(Sender: TObject);
procedure btnUpdateClick(Sender: TObject);
procedure udImageIndexClick(Sender: TObject; Button: TUDBtnType);
procedure chkAutoScrollClick(Sender: TObject);
procedure chkLargeClick(Sender: TObject);
private
jep: TJvErrorIndicator;
edClient: TJvErrorClientEdit;
procedure DoClientKey(Sender: TObject; var Key: Word; Shift: TShiftState);
public
end;
var
JvErrorIndicatorMainDemoFrm: TJvErrorIndicatorMainDemoFrm;
implementation
uses
JvEdit;
{$R *.dfm}
procedure TJvErrorIndicatorMainDemoFrm .FormCreate(Sender: TObject);
begin
cbImageAlignment.ItemIndex := 3;
cbBlinkStyle.ItemIndex := 1;
jep := TJvErrorIndicator.Create(Self);
jep.Images := il16;
isPreview.Images := TImageList(jep.Images);
jep.ImageIndex := udImageIndex.Position;
isPreview.ImageIndex := udImageIndex.Position;
udImageIndex.Max := jep.Images.Count - 1;
// Create an edit dynamically that implements the IJvErrorIndicatorClient interface
// For this demo, hitting RETURN will display it's Text as an error message
edClient := TJvErrorClientEdit.Create(Self);
edClient.Parent := Self;
edClient.SetBounds(lblClient.Left, lblClient.Top + lblClient.Height + 4,
edClient.Width, edClient.Height);
edClient.Name := 'JvErrorClientEdit1';
edClient.ErrorIndicator := jep;
edClient.TabOrder := 2;
edClient.Text := 'Type and hit RETURN to show this text as an error message';
edClient.OnKeyUp := DoClientKey;
memDescription.WordWrap := true;
end;
procedure TJvErrorIndicatorMainDemoFrm .DoClientKey(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if Key = VK_RETURN then
begin
// you must set both ErrorIndicator <> nil and ErrorMessage <> '' to trigger the ErrorIndicator:
if edClient.Text = '' then
edClient.ErrorMessage := 'Please supply a value!'
else
edClient.ErrorMessage := 'You typed: "' + edClient.Text + '"';
end;
end;
procedure TJvErrorIndicatorMainDemoFrm .btnClearErrorsClick(Sender: TObject);
begin
jep.ClearErrors;
end;
procedure TJvErrorIndicatorMainDemoFrm .btnShowErrorsClick(Sender: TObject);
var
i: integer;
begin
jep.BeginUpdate; // suspend blinking until all controls have been updated
// update any previous controls
btnUpdate.Click;
// only show error icons for wincontrols since the form gets crowded anyway...
for i := 0 to ComponentCount - 1 do
if (Components[i] is TWinControl)
// avoid duplicate icons for the edit/updown combos:
and (not (Components[i] is TEdit) or (Components[i] is TJvErrorClientEdit)) then
jep.Error[TWinControl(Components[i])] := Format('Example error message for %s',
[TWinControl(Components[i]).Name]);
// update any option changes
btnUpdate.Click;
jep.EndUpdate; // restart blinking
end;
procedure TJvErrorIndicatorMainDemoFrm .btnUpdateClick(Sender: TObject);
begin
jep.ImageAlignment[nil] := TJvErrorImageAlignment(cbImageAlignment.ItemIndex);
jep.ImagePadding[nil] := udImagePadding.Position;
jep.BlinkStyle := TJvErrorBlinkStyle(cbBlinkStyle.ItemIndex);
jep.BlinkRate := udBlinkRate.Position;
jep.ImageIndex := udImageIndex.Position;
end;
procedure TJvErrorIndicatorMainDemoFrm .udImageIndexClick(Sender: TObject; Button: TUDBtnType);
begin
isPreview.ImageIndex := udImageIndex.Position;
end;
procedure TJvErrorIndicatorMainDemoFrm .chkAutoScrollClick(Sender: TObject);
begin
AutoScroll := chkAutoScroll.Checked;
end;
procedure TJvErrorIndicatorMainDemoFrm .chkLargeClick(Sender: TObject);
begin
if chkLarge.Checked then
jep.Images := il32
else
jep.Images := il16;
isPreview.Images := TImageList(jep.Images);
udImageIndex.Max := jep.Images.Count - 1;
end;
{ TJvErrorClientEdit }
procedure TJvErrorClientEdit.ClearProvider;
var
tmp: string;
begin
if (FErrorIndicator <> nil) and not (csFreeNotification in ComponentState) then
begin
tmp := FErrorMessage;
FErrorMessage := '';
FErrorIndicator.SetClientError(Self);
FErrorMessage := tmp;
end;
end;
function TJvErrorClientEdit.getControl: TControl;
begin
Result := Self;
end;
function TJvErrorClientEdit.getErrorMessage: WideString;
begin
Result := FErrorMessage;
end;
function TJvErrorClientEdit.getErrorIndicator: IJvErrorIndicator;
begin
Result := FErrorIndicator;
end;
procedure TJvErrorClientEdit.Notification(AComponent: TComponent;
Operation: TOperation);
begin
inherited;
if Operation = opRemove then
begin
{$IFDEF COMPILER6_UP}
if (Assigned(ErrorIndicator)) and (AComponent.IsImplementorOf(ErrorIndicator)) then
ErrorIndicator := nil;
{$ELSE}
if AComponent = ErrorIndicator then
ErrorIndicator := nil;
{$ENDIF}
end;
end;
procedure TJvErrorClientEdit.SetBounds(ALeft, ATop, AWidth, AHeight: Integer);
begin
inherited;
ClearProvider;
UpdateProvider;
end;
procedure TJvErrorClientEdit.setErrorMessage(const Value: WideString);
begin
FErrorMessage := Value;
UpdateProvider;
end;
procedure TJvErrorClientEdit.setErrorIndicator(const Value: IJvErrorIndicator);
begin
ClearProvider;
{$IFDEF COMPILER6_UP}
ReferenceInterface(FErrorIndicator, opRemove);
FErrorIndicator := Value;
ReferenceInterface(FErrorIndicator, opInsert);
{$ELSE}
FErrorIndicator := Value;
{$ENDIF}
UpdateProvider;
end;
{$IFNDEF COMPILER6_UP}
procedure TJvErrorClientEdit.setErrorIndicatorComp(const Value: TComponent);
var
obj: IJvErrorIndicator;
begin
if FErrorIndicatorComp <> Value then
begin
if FErrorIndicatorComp <> nil then
FErrorIndicatorComp.RemoveFreeNotification(Self);
if Value = nil then
begin
FErrorIndicatorComp := nil;
setErrorIndicator(nil);
Exit;
end;
if not Supports(Value, IJvErrorIndicator, obj) then
Exception.CreateFmt('%s does not support the IJvErrorIndicator interface', [Value.Name]);
FErrorIndicatorComp := Value;
setErrorIndicator(obj);
if FErrorIndicatorComp <> nil then
FErrorIndicatorComp.FreeNotification(Self);
end;
end;
{$ENDIF}
procedure TJvErrorClientEdit.UpdateProvider;
begin
if (FErrorIndicator <> nil) then
FErrorIndicator.SetClientError(Self);
end;
end.
| 30.012618 | 104 | 0.742064 |
f1f0546e2749bb86f13a3014cc7531a4a6f4de9a | 5,316 | pas | Pascal | windows/src/ext/jedi/jvcl/tests/archive/jvcl/source/JvDropDownForm.pas | bravogeorge/keyman | c0797e36292de903d7313214d1f765e3d9a2bf4d | [
"MIT"
]
| 219 | 2017-06-21T03:37:03.000Z | 2022-03-27T12:09:28.000Z | windows/src/ext/jedi/jvcl/tests/archive/jvcl/source/JvDropDownForm.pas | bravogeorge/keyman | c0797e36292de903d7313214d1f765e3d9a2bf4d | [
"MIT"
]
| 4,451 | 2017-05-29T02:52:06.000Z | 2022-03-31T23:53:23.000Z | windows/src/ext/jedi/jvcl/tests/archive/jvcl/source/JvDropDownForm.pas | bravogeorge/keyman | c0797e36292de903d7313214d1f765e3d9a2bf4d | [
"MIT"
]
| 72 | 2017-05-26T04:08:37.000Z | 2022-03-03T10:26:20.000Z | {-----------------------------------------------------------------------------
The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/MPL-1.1.html
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the License for
the specific language governing rights and limitations under the License.
The Original Code is: JvDropDownForm, released on 2002-10-04.
The Initial Developer of the Original Code is Oliver Giesen [giesen@lucatec.com]
Portions created by Oliver Giesen are Copyright (C) 2002 Lucatec GmbH.
All Rights Reserved.
Contributor(s): ______________________________________.
Last Modified: 2002-12-09
You may retrieve the latest version of this file at the Project JEDI's JVCL home page,
located at http://jvcl.sourceforge.net
Known Issues:
-----------------------------------------------------------------------------}
{$I JVCL.INC}
{ A generic container form to be displayed as dropdown below a TCustomEdit
descendant.
There's still plenty of room for improvement here.
}
unit JvDropDownForm;
interface
uses
Classes, Windows, Messages, Controls, StdCtrls, Forms,
JvTypes;
type
TJvCustomDropDownForm = class(TCustomForm)
private
FEntering: Boolean;
FCloseOnLeave: Boolean;
FLeaving: Boolean;
FOnKillFocus: TJvFocusChangeEvent;
FOnSetFocus: TJvFocusChangeEvent;
procedure WMKillFocus(var AMessage: TMessage); message WM_KILLFOCUS;
procedure WMSetFocus(var AMessage: TMessage); message WM_SETFOCUS;
protected
function GetEdit: TCustomEdit;
procedure DoSetFocus(const APreviousControl: TWinControl); dynamic;
procedure DoKillFocus(const ANextControl: TWinControl); virtual;
procedure DoClose(var AAction: TCloseAction); override;
procedure DoShow; override;
procedure CreateParams(var AParams: TCreateParams); override;
property Edit: TCustomEdit read GetEdit;
public
constructor Create(AOwner: TComponent); override;
property CloseOnLeave: Boolean read FCloseOnLeave write FCloseOnLeave;
property Entering: Boolean read FEntering;
property Leaving: Boolean read FLeaving;
property OnSetFocus: TJvFocusChangeEvent read FOnSetFocus write FOnSetFocus;
property OnKillFocus: TJvFocusChangeEvent read FOnKillFocus write FOnKillFocus;
end;
{TODO : IsChildOf should probably better be moved somewhere into the JCL}
function IsChildOf(const AChild, AParent: HWND): Boolean;
implementation
uses
SysUtils;
function IsChildOf(const AChild, AParent: HWND): Boolean;
var
LParent: HWND;
begin
{determines whether one control is the child (or grand^x-child) of another}
LParent := AChild;
repeat
LParent := GetParent(LParent);
until (LParent = AParent) or (LParent = 0);
Result := LParent = AParent;
end;
type
TCustomEditHack = class(TCustomEdit);
constructor TJvCustomDropDownForm.Create(AOwner: TComponent);
begin
if not (AOwner is TCustomEdit) then
raise EJVCLException.Create('TJvCustomDropDownForm.Create: Owner must be a TCustomEdit');
inherited CreateNew(AOwner);
BorderIcons := [];
BorderStyle := bsNone;
Font := TCustomEditHack(AOwner).Font;
FEntering := True;
FLeaving := False;
FCloseOnLeave := True;
with TWinControl(AOwner) do
begin
Self.Left := ClientOrigin.X;
Self.Top := ClientOrigin.Y + Height;
end;
end;
procedure TJvCustomDropDownForm.CreateParams(var AParams: TCreateParams);
begin
inherited CreateParams(AParams);
AParams.Style := AParams.Style or WS_BORDER;
end;
procedure TJvCustomDropDownForm.DoClose(var AAction: TCloseAction);
begin
AAction := caFree;
inherited;
end;
procedure TJvCustomDropDownForm.DoShow;
var
LScreenRect: TRect;
begin
inherited DoShow;
if (not SystemParametersInfo(SPI_GETWORKAREA, 0, @lScreenRect, 0)) then
LScreenRect := Rect(0, 0, Screen.Width, Screen.Height);
if (Left + Width > LScreenRect.Right) then
Left := LScreenRect.Right - Width;
if (Top + Height > LScreenRect.Bottom) then
Top := Self.Edit.ClientOrigin.y - Height;
end;
function TJvCustomDropDownForm.GetEdit: TCustomEdit;
begin
Result := TCustomEdit(Owner);
end;
procedure TJvCustomDropDownForm.WMKillFocus(var AMessage: TMessage);
begin
if IsChildOf(AMessage.WParam, Self.Handle) then
inherited
else
begin
FLeaving := True;
try
inherited;
DoKillFocus(FindControl(AMessage.WParam));
finally
FLeaving := False;
end;
end;
end;
procedure TJvCustomDropDownForm.DoKillFocus(const ANextControl: TWinControl);
begin
if Assigned(OnKillFocus) then
OnKillFocus(Self, ANextControl);
if CloseOnLeave then
Close;
end;
procedure TJvCustomDropDownForm.WMSetFocus(var AMessage: TMessage);
begin
if IsChildOf(AMessage.WParam, Self.Handle) then
inherited
else
begin
FEntering := True;
try
inherited;
DoSetFocus(FindControl(AMessage.WParam));
finally
FEntering := False;
end;
end;
end;
procedure TJvCustomDropDownForm.DoSetFocus(
const APreviousControl: TWinControl);
begin
if Assigned(OnSetFocus) then
OnSetFocus(Self, APreviousControl);
end;
end.
| 27.402062 | 93 | 0.733634 |
fc8fa7751b4c93f786cde145719619beda79b7c0 | 3,536 | pas | Pascal | code/DatabaseEngine.pas | gzwplato/ooDataBaseEngine | a6702fce3bfe2fb075f8071f730f7a4ef80d7b29 | [
"BSD-3-Clause"
]
| 3 | 2019-11-19T16:17:45.000Z | 2022-01-04T02:16:36.000Z | code/DatabaseEngine.pas | VencejoSoftware/ooDataBaseEngine | a6702fce3bfe2fb075f8071f730f7a4ef80d7b29 | [
"BSD-3-Clause"
]
| null | null | null | code/DatabaseEngine.pas | VencejoSoftware/ooDataBaseEngine | a6702fce3bfe2fb075f8071f730f7a4ef80d7b29 | [
"BSD-3-Clause"
]
| 3 | 2019-11-21T02:01:20.000Z | 2021-07-26T09:14:07.000Z | {$REGION 'documentation'}
{
Copyright (c) 2020, Vencejo Software
Distributed under the terms of the Modified BSD License
The full license is distributed with this software
}
{
Database engine object
@created(18/09/2018)
@author Vencejo Software <www.vencejosoft.com>
}
{$ENDREGION}
unit DatabaseEngine;
interface
uses
DatabaseLogin,
ExecutionResult;
const
{$REGION 'documentation'}
{
@abstract(NULL text value for SQL)
}
{$ENDREGION}
NULL = 'NULL';
type
{$REGION 'documentation'}
{
@abstract(Database engine object)
Object to encapsulate basic methods to acces, alter and get data from SQL based databases
@member(
InTransaction Checks for an active global transaction
@return(@true if exists an active global transaction, @false if not)
)
@member(
BeginTransaction Start the global transaction
@return(@true if can start a new transaction, @false if fail)
)
@member(
CommitTransaction Commits all chnages of the global transaction
@return(@true if committing data is done, @false if fail)
)
@member(
RollbackTransaction Rollback all chnages of the global transaction
@return(@true if rollbacking data is done, @false if fail)
)
@member(
Connect Try to login into database
@param(Login @link(ILogin Login object))
@return(@true if connection is done, @false if fail)
)
@member(
Disconnect Try to disconnect from the database
@return(@true if disconnection is done, @false if fail)
)
@member(
IsConnected Checks if is currently connected to database
@return(@true if is connected, @false if not)
)
@member(
OpenDataset Open and return a new dataset based in a query
@param(Statement Statement query to run)
@return(link(@IExecutionResult Execution result object))
)
@member(
Execute Run a statement to alter data or database struct
@param(Statement Statement query to run)
@param(UseGlobalTransaction Defines is the execution run into the global transaction or create an isolate one)
@return(link(@IExecutionResult Execution result object))
)
@member(
ExecuteReturning Run a statement to alter data or database struct and wait for data returning
@param(Statement Statement query to run)
@param(UseGlobalTransaction Defines is the execution run into the global transaction or create an isolate one)
@return(link(@IExecutionResult Execution result object))
)
@member(
ExecuteScript Execute a script directly to the database
@param(StatementList Lines of statements to run)
@return(link(@IExecutionResult Execution result object))
)
}
{$ENDREGION}
IDatabaseEngine = interface
['{911CC81E-2051-4531-B758-6BDB7E04F55E}']
function InTransaction: Boolean;
function BeginTransaction: Boolean;
function CommitTransaction: Boolean;
function RollbackTransaction: Boolean;
function Connect(const Login: IDatabaseLogin): Boolean;
function Disconnect: Boolean;
function IsConnected: Boolean;
function OpenDataset(const Statement: WideString): IExecutionResult;
function Execute(const Statement: WideString; const UseGlobalTransaction: Boolean = False): IExecutionResult;
function ExecuteReturning(const Statement: WideString; const UseGlobalTransaction: Boolean = False)
: IExecutionResult;
function ExecuteScript(const StatementList: array of WideString): IExecutionResult;
end;
implementation
end.
| 33.358491 | 115 | 0.722851 |
fc2349547c97528c7c10d54a03179752b1a453f0 | 2,074 | pas | Pascal | Oxygene/All/Calculator/Calculator.WPF/MainWindow.xaml.pas | remobjects/ElementsSamples | 744647f59424c18ccb06c0c776b2dcafdabb0513 | [
"MIT"
]
| 19 | 2016-04-09T12:40:27.000Z | 2022-02-22T12:15:03.000Z | Oxygene/All/Calculator/Calculator.WPF/MainWindow.xaml.pas | remobjects/ElementsSamples | 744647f59424c18ccb06c0c776b2dcafdabb0513 | [
"MIT"
]
| 3 | 2017-09-05T09:31:29.000Z | 2019-09-11T04:49:27.000Z | Oxygene/All/Calculator/Calculator.WPF/MainWindow.xaml.pas | remobjects/ElementsSamples | 744647f59424c18ccb06c0c776b2dcafdabb0513 | [
"MIT"
]
| 11 | 2016-12-29T19:30:39.000Z | 2021-08-31T12:20:27.000Z | namespace Calculator.WPF;
interface
uses
System,
System.Collections.Generic,
System.Linq,
System.Text,
System.Threading.Tasks,
System.Windows,
System.Windows.Controls,
System.Windows.Data,
System.Windows.Documents,
System.Windows.Input,
System.Windows.Media,
System.Windows.Media.Imaging,
System.Windows.Navigation,
System.Windows.Shapes,
Calculator.Engine;
type
MainWindow = public partial class(Window)
public
constructor;
private
method Exit_Clicked(sender: System.Object; e: System.Windows.RoutedEventArgs);
method Backspace_Clicked(sender: System.Object; e: System.Windows.RoutedEventArgs);
public
method Refocus;
private
method Evaluate_Clicked(sender: System.Object; e: System.Windows.RoutedEventArgs);
method Text_Clicked(sender: System.Object; e: System.Windows.RoutedEventArgs);
end;
implementation
constructor MainWindow;
begin
InitializeComponent();
end;
method MainWindow.Exit_Clicked(sender: System.Object; e: System.Windows.RoutedEventArgs);
begin
Close();
end;
method MainWindow.Backspace_Clicked(sender: System.Object; e: System.Windows.RoutedEventArgs);
begin
var s: String := tbValue.Text;
if s.Length > 0 then
s := s.Substring(0, s.Length - 1);
tbValue.Text := s;
Refocus();
end;
method MainWindow.Refocus;
begin
tbValue.Focus();
tbValue.SelectionStart := tbValue.Text.Length;
end;
method MainWindow.Evaluate_Clicked(sender: System.Object; e: System.Windows.RoutedEventArgs);
begin
try
var eval := new Evaluator();
var res := eval.Evaluate(tbValue.Text);
tbValue.Text := res.ToString(System.Globalization.CultureInfo.InvariantCulture);
except
on ex: Exception do
begin
MessageBox.Show('Error evaluating: ' + ex.Message);
end;
end;
Refocus();
end;
method MainWindow.Text_Clicked(sender: System.Object; e: System.Windows.RoutedEventArgs);
begin
tbValue.Text := tbValue.Text + (Button(sender)).Content.ToString();
Refocus();
end;
end. | 24.690476 | 95 | 0.711186 |
47c40efb39802e26eb594e2fafc41f577178c860 | 1,506 | dfm | Pascal | Lib/Win32/Debug/DDuce.Editor.Sortstrings.Toolview.dfm | beNative/dduce | cedbe2e847cc49fe8bcd5ba12b76327eee43d639 | [
"Apache-2.0"
]
| 52 | 2015-03-17T16:34:08.000Z | 2022-03-16T12:06:09.000Z | Lib/Win64/Debug/DDuce.Editor.Sortstrings.Toolview.dfm | beNative/dduce | cedbe2e847cc49fe8bcd5ba12b76327eee43d639 | [
"Apache-2.0"
]
| 2 | 2016-06-04T11:26:16.000Z | 2018-07-11T04:14:16.000Z | Lib/Win32/Release/DDuce.Editor.Sortstrings.Toolview.dfm | beNative/dduce | cedbe2e847cc49fe8bcd5ba12b76327eee43d639 | [
"Apache-2.0"
]
| 10 | 2015-03-25T06:12:24.000Z | 2019-11-13T13:20:27.000Z | inherited frmSortStrings: TfrmSortStrings
Caption = 'Sort strings'
ClientHeight = 394
ClientWidth = 282
OnResize = FormResize
ExplicitWidth = 298
ExplicitHeight = 433
PixelsPerInch = 96
TextHeight = 13
object rgpSortDirection: TRadioGroup
AlignWithMargins = True
Left = 3
Top = 3
Width = 276
Height = 54
Align = alTop
Caption = 'Sort direction:'
Columns = 2
ItemIndex = 0
Items.Strings = (
'Ascending'
'Descending')
TabOrder = 0
OnClick = rgpSortDirectionClick
end
object pnlBottom: TPanel
Left = 0
Top = 369
Width = 282
Height = 25
Align = alBottom
AutoSize = True
BevelOuter = bvNone
TabOrder = 2
DesignSize = (
282
25)
object btnOK: TButton
Left = 161
Top = 0
Width = 120
Height = 25
Action = actExecute
Anchors = [akRight, akBottom]
Caption = 'Sort selection'
Default = True
ModalResult = 1
TabOrder = 0
end
end
object rgpSortScope: TRadioGroup
AlignWithMargins = True
Left = 3
Top = 63
Width = 276
Height = 66
Align = alTop
Caption = 'Scope'
Columns = 3
ItemIndex = 0
Items.Strings = (
'Words'
'Lines'
'Paragraphs')
TabOrder = 1
OnClick = rgpSortScopeClick
end
object aclMain: TActionList
Left = 296
Top = 280
object actExecute: TAction
Caption = 'Execute'
OnExecute = actExecuteExecute
end
end
end
| 19.558442 | 41 | 0.601594 |
47a4e476c1b49c2fc89f9466d72233ba80b115ee | 106,497 | dfm | Pascal | Client/fXModels.dfm | Sembium/Sembium3 | 0179c38c6a217f71016f18f8a419edd147294b73 | [
"Apache-2.0"
]
| null | null | null | Client/fXModels.dfm | Sembium/Sembium3 | 0179c38c6a217f71016f18f8a419edd147294b73 | [
"Apache-2.0"
]
| null | null | null | Client/fXModels.dfm | Sembium/Sembium3 | 0179c38c6a217f71016f18f8a419edd147294b73 | [
"Apache-2.0"
]
| 3 | 2021-06-30T10:11:17.000Z | 2021-07-01T09:13:29.000Z | inherited fmXModels: TfmXModels
Left = 243
Top = 162
Caption = #1056#1077#1075#1080#1089#1090#1098#1088' '#1085#1072' '#1056#1077#1072#1083#1080#1079#1072#1094#1080#1086#1085#1085#1080' '#1048#1085#1078#1077#1085#1077#1088#1085#1080' '#1056#1072#1079#1088#1072#1073#1086#1090#1082#1080' '#1087#1086' '#1054#1055#1042' %s'
ClientHeight = 583
ClientWidth = 1017
PixelsPerInch = 96
TextHeight = 13
inherited pnlBottomButtons: TPanel
Top = 549
Width = 1017
Height = 34
inherited pnlClose: TPanel [0]
Left = 660
Height = 34
TabOrder = 2
Visible = True
end
inherited pnlApply: TPanel [1]
Left = 928
Height = 34
TabOrder = 4
Visible = False
end
inherited pnlOKCancel: TPanel [2]
Left = 749
Height = 34
TabOrder = 3
Visible = False
end
object pnlClientButtons: TPanel [3]
Left = 698
Top = 0
Width = 80
Height = 34
Align = alClient
BevelOuter = bvNone
TabOrder = 1
end
inherited pnlDataButtons: TPanel
Width = 698
Height = 34
inherited btnAddData: TBitBtn
Width = 97
Caption = #1057#1098#1079#1076#1072#1074#1072#1085#1077'...'
end
inherited btnDeleteData: TBitBtn
Left = 112
Width = 89
end
inherited btnEditData: TBitBtn
Left = 208
end
object btnMakeChanges: TBitBtn
Left = 321
Top = 2
Width = 89
Height = 25
Action = actMakeChanges
Caption = #1047#1072#1084#1077#1085#1080'...'
Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
2000000000000004000000000000000000000000000000000000FF00FF00FF00
FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00
FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00
FF0000000000FFFF000000000000FF00FF00FF00FF0000000000FFFFFF00FFFF
FF00FFFFFF00FF000000FF000000FFFFFF00FF000000FF000000FF00FF000000
0000FFFF0000FFFF0000FFFF000000000000FF00FF0000000000FFFFFF00FFFF
FF00FFFFFF00FF000000FF000000FFFFFF00FF000000FF00000000000000FFFF
0000FFFF0000FFFF000000000000000000000000000000000000FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FF000000FF000000FFFFFF00FFFF0000FFFF
0000FFFF00000000000000FFFF00FFFFFF0000FFFF00FFFFFF0000000000FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FF000000FF000000FFFFFF0000000000FFFF
00000000000000FFFF00FFFFFF0000FFFF00FFFFFF0000FFFF00FFFFFF000000
0000FFFFFF00FFFFFF00FF000000FF000000FFFFFF00FFFFFF00FF00FF000000
000000FFFF00FFFFFF0000FFFF00FFFFFF0000FFFF00FFFFFF0000FFFF00FFFF
FF0000000000FFFFFF00FF000000FF000000FFFFFF00FFFFFF00FF00FF000000
0000FFFFFF0000FFFF00FFFFFF0000FFFF00FFFFFF0000FFFF000000000000FF
FF0000000000FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FF00FF000000
000000FFFF000000000000FFFF00FFFFFF0000000000FFFFFF0000FFFF000000
0000000000000000000000000000000000000000000000000000FF00FF000000
0000FFFFFF0000FFFF000000000000FFFF00FFFFFF0000000000FFFFFF0000FF
FF0000000000FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FF00FF00FF00
FF000000000000000000FF00FF000000000000FFFF00FFFFFF0000000000FFFF
FF0000000000FFFFFF00FFFFFF00FFFFFF000000FF000000FF00FF000000FF00
0000FF00FF00FF00FF00FF00FF00FF00FF000000000000FFFF00FFFFFF000000
000000000000FFFFFF00FFFFFF00FFFFFF000000FF000000FF00FF000000FF00
00000000FF000000FF00FF00FF00FF00FF00FF00FF0000000000000000000000
00000000FF00FFFFFF000000FF000000FF00FFFFFF00FFFFFF00FF00FF00FF00
FF000000FF000000FF00FF00FF00FF00FF00FF00FF0000000000FFFFFF000000
FF000000FF00FFFFFF000000FF000000FF00FFFFFF00FFFFFF000000FF000000
FF00FF00FF00FF000000FF000000FF00FF00FF00FF0000000000FFFFFF00FFFF
FF00FFFFFF000000FF000000FF00FFFFFF000000FF000000FF000000FF000000
FF00FF00FF00FF000000FF000000FF00FF00FF00FF0000000000FFFFFF00FFFF
FF00FFFFFF000000FF000000FF00FFFFFF000000FF000000FF00}
Spacing = -1
TabOrder = 3
end
object btnEditSale: TBitBtn
Left = 616
Top = 2
Width = 78
Height = 25
Action = actEditSale
Caption = #1054#1055#1042'...'
Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
2000000000000004000000000000000000000000000000000000FF00FF00FF00
FF00FF00FF00FF00FF00FF00FF00FF00FF000000000000000000000000000000
0000000000000000000000000000000000000000000000000000FF00FF00FF00
FF00FF00FF00FF00FF00FF00FF00FF00FF0000000000FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF0000000000000000000000
0000FF00FF000000000000000000000000000000000000000000FFFFFF00FFFF
FF0000000000FFFFFF000000000000000000FFFFFF0000000000FFFF00000000
00000000000000FFFF00FFFFFF0000FFFF00FFFFFF0000FFFF0000000000FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF0000000000FFFF00000000
000000FFFF00FFFFFF0000FFFF00FFFFFF00000000000000000000000000FFFF
FF00FFFFFF00FFFFFF00FFFFFF0000000000FFFFFF0000000000FFFF00000000
0000FFFFFF0000FFFF00FFFFFF0000FFFF00FFFFFF0000FFFF00FFFFFF000000
0000FFFFFF000000000000000000FFFFFF00FFFFFF0000000000FFFF00000000
000000FFFF00FFFFFF0000FFFF00FFFFFF000000000000000000000000000000
00000000000000FFFF0000000000FFFFFF00FFFFFF0000000000FFFF00000000
0000FFFFFF0000FFFF00FFFFFF0000FFFF00FFFFFF0000FFFF00FFFFFF0000FF
FF00FFFFFF0000000000FFFFFF00FFFFFF00FFFFFF0000000000FFFF00000000
000000FFFF00FFFFFF0000000000000000000000000000000000000000000000
000000000000FFFFFF00FFFFFF00FFFFFF00FFFFFF0000000000000000000000
00000000000000FFFF00FFFFFF0000FFFF00000000000000000000FFFF000000
0000FFFFFF00FFFFFF000000000000000000FFFFFF0000000000FF00FF00FF00
FF00FF00FF000000000000000000000000000000000000FFFF0000000000FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF0000000000FF00FF00FF00
FF00FF00FF00FF00FF00FF00FF000000000000FFFF0000000000FFFFFF00FFFF
FF00FFFFFF00FFFFFF0000000000000000000000000000000000FF00FF00FF00
FF00FF00FF00FF00FF000000000000FFFF0000000000FFFFFF00FFFFFF000000
000000000000FFFFFF0000000000FFFFFF00FFFFFF0000000000FF00FF00FF00
FF00FF00FF000000000000FFFF000000000000000000FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF0000000000FFFFFF0000000000FF00FF00FF00FF00FF00
FF00000000000000FF0000000000FF00FF0000000000FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF000000000000000000FF00FF00FF00FF00FF00FF00FF00
FF00FF00FF0000000000FF00FF00FF00FF000000000000000000000000000000
0000000000000000000000000000FF00FF00FF00FF00FF00FF00}
Spacing = -1
TabOrder = 6
end
object btnModelCapacityStatus: TBitBtn
Left = 512
Top = 2
Width = 97
Height = 25
Action = actModelCapacityStatus
Caption = #1050#1072#1087#1072#1094#1080#1090#1077#1090'...'
Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
2000000000000004000000000000000000000000000000000000FF00FF00FF00
FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00
FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF000000
0000FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00
FF00FF00FF00000000000000FF0000000000FF00FF00FF00FF00FF00FF00FF00
FF0000000000FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00
FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00
FF00FF00FF0000000000FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00
FF00000000000000FF000000FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00
FF00FF00FF00FF00FF0000000000FF00FF00FF00FF00FF00FF00FF00FF00FF00
FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00
FF00FF00FF00FF00FF00FF00FF0000000000FF00FF00FF00FF00FF00FF00FF00
FF00FF00FF00FF00FF00000000000000FF000000FF00FF00FF00FF00FF00FF00
FF00FF00FF00FF00FF00FF00FF00FF00FF0000000000FF00FF00FF00FF00FF00
FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00
FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF0000000000FF00FF00FF00
FF00FF00FF000000FF000000FF000000000000000000FF00FF00000000008484
84000000FF000000FF000000FF0084848400FF00FF00FF00FF0000000000FF00
FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00
FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF000000
0000FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00000000000000
FF00000000000000FF008484840084848400FF00FF00FF00FF00FF00FF00FF00
FF0000000000FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00
FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00
FF00FF00FF0000000000FF00FF00FF00FF00FF00FF00FF00FF00000000008484
8400000000000000FF00000000000000FF00FF00FF00FF00FF00FF00FF00FF00
FF00FF00FF00FF00FF0000000000FF00FF00FF00FF00FF00FF00FF00FF00FF00
FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00
FF00FF00FF00FF00FF00FF00FF0000000000FF00FF00FF00FF00000000008484
8400000000000000FF00000000000000FF00FF00FF00FF00FF00FF00FF00FF00
FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00
FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00
FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00}
ParentShowHint = False
ShowHint = True
Spacing = -1
TabOrder = 5
end
object btnModelStatus: TBitBtn
Left = 416
Top = 2
Width = 89
Height = 25
Action = actModelStatus
Caption = #1057#1083#1077#1076#1077#1085#1077'...'
Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
2000000000000004000000000000000000000000000000000000FF00FF00FF00
FF00FF00FF00FF00FF0000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000FF00FF00FF00
FF00FF00FF00FF00FF0000000000FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF0000000000FF00FF00FF00
FF00FF00FF00FF00FF0000000000FFFFFF00000000000000000000000000FFFF
FF0000000000FFFFFF000000000000000000FFFFFF0000000000FF00FF00FF00
FF00FF00FF00FF00FF0000000000FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF0000000000FF00FF00FF00
FF00FF00FF00FF00FF0000000000FFFFFF000000000000000000FFFFFF000000
000000000000FFFFFF000000000000000000FFFFFF0000000000FF00FF00FF00
FF00FF00FF00FF00FF0000000000FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF0000000000FF00FF00FF00
FF00FF00FF00FF00FF000000000000000000FFFFFF00FFFFFF00FFFFFF00FFFF
FF000000000000000000FFFFFF0000000000FFFFFF0000000000FF00FF00FF00
FF00FF00FF0000000000FFFFFF0000FFFF000000000000000000FFFFFF000000
0000FFFFFF0000000000FFFFFF00FFFFFF00FFFFFF0000000000FF00FF00FF00
FF0000000000FFFFFF0000FFFF000000000000FFFF00FFFFFF0000000000FFFF
FF0000FFFF0000000000FFFFFF0000000000FFFFFF0000000000FF00FF000000
0000FFFFFF0000FFFF00FFFFFF0000FFFF00FFFFFF0000000000FFFFFF0000FF
FF0000000000FFFFFF00FFFFFF00FFFFFF00FFFFFF0000000000FF00FF000000
000000FFFF00FFFFFF0000FFFF00FFFFFF0000000000FFFFFF0000FFFF000000
0000FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF0000000000000000000000
0000FFFFFF0000FFFF00FFFFFF0000FFFF00FFFFFF0000FFFF0000000000FFFF
FF00FFFFFF00FFFFFF0000000000000000000000000000000000FFFF00000000
000000FFFF00FFFFFF0000FFFF00FFFFFF0000FFFF0000000000000000000000
0000FFFFFF00FFFFFF0000000000FFFFFF00FFFFFF0000000000FFFF0000FFFF
00000000000000FFFF00FFFFFF0000FFFF000000000000FFFF00FFFFFF0000FF
FF0000000000FFFFFF0000000000FFFFFF0000000000FF00FF00FFFF0000FFFF
0000FFFF00000000000000FFFF00FFFFFF0000FFFF00FFFFFF00000000000000
0000FFFFFF00FFFFFF000000000000000000FF00FF00FF00FF00FFFF0000FFFF
0000FFFF0000FFFF000000000000000000000000000000000000000000000000
0000000000000000000000000000FF00FF00FF00FF00FF00FF00}
ParentShowHint = False
ShowHint = True
Spacing = -1
TabOrder = 4
end
end
end
inherited pnlMain: TPanel
Width = 1017
Height = 549
inherited pnlGrid: TPanel
Width = 1001
Height = 533
inherited pnlNavigator: TPanel
Width = 1001
inherited pnlFilterButton: TPanel
Left = 120
end
inherited navData: TDBColorNavigator
Width = 96
VisibleButtons = [nbFirst, nbPrior, nbNext, nbLast]
Hints.Strings = ()
end
inherited tlbTopGridButtons: TToolBar
Left = 144
Width = 64
object sepBeforeCopyButton: TToolButton
Left = 56
Top = 0
Width = 8
Caption = 'sepBeforeCopyButton'
ImageIndex = 3
Style = tbsSeparator
end
end
object tlbTopButtons: TToolBar
Left = 208
Top = 0
Width = 337
Height = 24
Align = alLeft
ButtonHeight = 24
ButtonWidth = 24
Caption = 'tlbTopButtons'
EdgeInner = esNone
Images = dmMain.ilActions
TabOrder = 3
object btnCopy: TToolButton
Left = 0
Top = 0
Action = actCopyToClipboard
DropdownMenu = pmCopy
Style = tbsDropDown
end
object sepDocumentation: TToolButton
Left = 39
Top = 0
Width = 8
Caption = 'sepDocumentation'
ImageIndex = 16
Style = tbsSeparator
end
object pnlProductDocsCaption: TPanel
Left = 47
Top = 0
Width = 31
Height = 24
Align = alLeft
BevelOuter = bvNone
Caption = #1059#1054#1073
TabOrder = 0
end
object btnDocumentation: TSpeedButton
Left = 78
Top = 0
Width = 37
Height = 24
Hint = #1055#1086#1082#1072#1079#1074#1072' '#1048#1048#1054' '#1085#1072' '#1059#1087#1088#1072#1074#1083#1103#1077#1084#1080#1103' '#1054#1073#1077#1082#1090' '#1085#1072' '#1080#1079#1073#1088#1072#1085#1080#1103' '#1054#1055#1042
Flat = True
Glyph.Data = {
36060000424D360600000000000036040000280000001D000000100000000100
0800000000000002000000000000000000000001000000000000000000000000
80000080000000808000800000008000800080800000C0C0C000C0DCC000F0CA
A6000020400000206000002080000020A0000020C0000020E000004000000040
20000040400000406000004080000040A0000040C0000040E000006000000060
20000060400000606000006080000060A0000060C0000060E000008000000080
20000080400000806000008080000080A0000080C0000080E00000A0000000A0
200000A0400000A0600000A0800000A0A00000A0C00000A0E00000C0000000C0
200000C0400000C0600000C0800000C0A00000C0C00000C0E00000E0000000E0
200000E0400000E0600000E0800000E0A00000E0C00000E0E000400000004000
20004000400040006000400080004000A0004000C0004000E000402000004020
20004020400040206000402080004020A0004020C0004020E000404000004040
20004040400040406000404080004040A0004040C0004040E000406000004060
20004060400040606000406080004060A0004060C0004060E000408000004080
20004080400040806000408080004080A0004080C0004080E00040A0000040A0
200040A0400040A0600040A0800040A0A00040A0C00040A0E00040C0000040C0
200040C0400040C0600040C0800040C0A00040C0C00040C0E00040E0000040E0
200040E0400040E0600040E0800040E0A00040E0C00040E0E000800000008000
20008000400080006000800080008000A0008000C0008000E000802000008020
20008020400080206000802080008020A0008020C0008020E000804000008040
20008040400080406000804080008040A0008040C0008040E000806000008060
20008060400080606000806080008060A0008060C0008060E000808000008080
20008080400080806000808080008080A0008080C0008080E00080A0000080A0
200080A0400080A0600080A0800080A0A00080A0C00080A0E00080C0000080C0
200080C0400080C0600080C0800080C0A00080C0C00080C0E00080E0000080E0
200080E0400080E0600080E0800080E0A00080E0C00080E0E000C0000000C000
2000C0004000C0006000C0008000C000A000C000C000C000E000C0200000C020
2000C0204000C0206000C0208000C020A000C020C000C020E000C0400000C040
2000C0404000C0406000C0408000C040A000C040C000C040E000C0600000C060
2000C0604000C0606000C0608000C060A000C060C000C060E000C0800000C080
2000C0804000C0806000C0808000C080A000C080C000C080E000C0A00000C0A0
2000C0A04000C0A06000C0A08000C0A0A000C0A0C000C0A0E000C0C00000C0C0
2000C0C04000C0C06000C0C08000C0C0A000F0FBFF00A4A0A000808080000000
FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00FDFDFDFDFD1D
1D1D1D1DFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFD000000FDFDFDFB0000
0000000000FDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFD000000FDFDFBFB1D1D
0000001D1D1DFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFD000000FDFBFB1D1DFB
000000FBFB1D1DFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFD000000FBFB1D1DFBFB
0000001DFBFB1D1DFDFDFDFDFDFDFDFDFDFDFDFDFDFDFD000000FBFB1D1DFB1D
0000001D1DFBFB1D1DFDFDFDFDFDFDFDFDFDFDFDFDFDFD000000FBFB1DFBFB1D
000000FB1D1DFBFB1DFDFDFDFDFDFDFDFDFDFDFD00FDFD000000FBFB1DFBFB1D
000000FBFB1DFBFB1D1DFDFDFDFDFDFDFDFDFD000000FD000000FBFB1D1D0000
0000001DFB1DFBFB1D1DFDFDFDFDFDFDFDFD0000000000000000FBFBFB1DFBFB
1D1D1DFBFB1DFBFB1D1DFDFDFDFDFDFDFDFDFDFDFDFDFD000000FDFBFB1D1DFB
FBFBFBFB1D1DFBFB1DFDFDFDFDFDFDFDFDFDFDFDFDFDFD000000FDFBFBFB1D1D
0000001D1DFBFB1D1DFDFDFDFDFDFDFDFDFDFDFDFDFDFD000000FDFDFBFBFB1D
0000001D1DFBFB1DFDFDFDFDFDFDFDFDFDFDFDFDFDFDFD000000FDFDFDFBFBFB
1D001DFBFBFB1D1DFDFDFDFDFDFDFDFDFDFDFDFDFDFDFD000000FDFDFDFDFDFB
FBFBFBFBFB1D1DFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFD000000FDFDFDFDFDFD
FD1D1D1D1DFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFD000000}
Transparent = False
OnClick = btnDocumentationClick
end
object sepBeforeXModelDocStatus: TToolButton
Left = 115
Top = 0
Width = 8
Caption = 'sepBeforeXModelDocStatus'
ImageIndex = 15
Style = tbsSeparator
end
object btnXModelDocStatus: TSpeedButton
Left = 123
Top = 0
Width = 128
Height = 24
Action = actXModelDocStatus
Flat = True
Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
2000000000000004000000000000000000000000000000000000FF00FF00FF00
FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00
FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00
FF00FF00FF00FF00FF00FF00FF00FF00FF000000000000000000000000000000
00000000000000000000FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00
FF00FF00FF00FF00FF00FF00FF00FF00FF0000000000FFFFFF00FFFFFF00FFFF
FF00FFFFFF0000000000FF00FF00FF00FF00FF00FF00FF00FF00FF00FF000000
00000000000000000000000000000000000000000000FFFFFF00FFFFFF00FFFF
FF00000000000000000000000000000000000000000000000000FF00FF000000
0000FFFFFF00FFFFFF00FFFFFF00FFFFFF0000000000FFFFFF00FFFFFF00FFFF
FF0000000000FFFFFF00FFFFFF00FFFFFF00FFFFFF0000000000FF00FF000000
0000FFFFFF008080800080808000808080008000000080000000800000008000
000000000000FFFFFF00FFFFFF00FFFFFF00FFFFFF0000000000FF00FF000000
0000FFFFFF00FFFFFF00FFFFFF00FFFFFF008000000080000000800000008000
000000000000FFFFFF00FFFFFF00FFFFFF00FFFFFF0000000000FF00FF000000
0000FFFFFF008080800080808000808080008080800000000000FFFFFF00FFFF
FF00800000008000000080000000800000008000000080000000FF00FF000000
0000FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF0000000000FFFFFF00FFFF
FF00800000008000000080000000800000008000000080000000FF00FF000000
0000FFFFFF008080800080808000808080008080800000000000FFFFFF00FFFF
FF00FFFFFF00FFFFFF0000000000FF00FF00FF00FF00FF00FF00FF00FF000000
0000FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF0080000000800000008000
0000800000008000000080000000FF00FF00FF00FF00FF00FF00FF00FF000000
0000FFFFFF008080800080808000808080008080800080000000800000008000
0000800000008000000080000000FF00FF00FF00FF00FF00FF00FF00FF000000
0000FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF0000000000FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF000000
00000000000000000000FFFFFF0080808000808080008080800080808000FFFF
FF0000000000FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00
FF000000000000000000FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF0000000000FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00
FF00FF00FF000000000000000000000000000000000000000000000000000000
000000000000FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00}
Spacing = -1
Transparent = False
end
object sepSaleDocs: TToolButton
Left = 251
Top = 0
Width = 8
Caption = 'sepSaleDocs'
ImageIndex = 16
Style = tbsSeparator
end
object pnlSaleDocs: TPanel
Left = 259
Top = 0
Width = 31
Height = 24
Align = alLeft
BevelOuter = bvNone
Caption = #1054#1055#1042
TabOrder = 1
end
object btnSaleDocs: TSpeedButton
Left = 290
Top = 0
Width = 37
Height = 24
Hint = #1055#1086#1082#1072#1079#1074#1072' '#1048#1048#1054' '#1085#1072' '#1059#1087#1088#1072#1074#1083#1103#1077#1084#1080#1103' '#1054#1073#1077#1082#1090' '#1085#1072' '#1080#1079#1073#1088#1072#1085#1080#1103' '#1054#1055#1042
Flat = True
Glyph.Data = {
36060000424D360600000000000036040000280000001D000000100000000100
0800000000000002000000000000000000000001000000000000000000000000
80000080000000808000800000008000800080800000C0C0C000C0DCC000F0CA
A6000020400000206000002080000020A0000020C0000020E000004000000040
20000040400000406000004080000040A0000040C0000040E000006000000060
20000060400000606000006080000060A0000060C0000060E000008000000080
20000080400000806000008080000080A0000080C0000080E00000A0000000A0
200000A0400000A0600000A0800000A0A00000A0C00000A0E00000C0000000C0
200000C0400000C0600000C0800000C0A00000C0C00000C0E00000E0000000E0
200000E0400000E0600000E0800000E0A00000E0C00000E0E000400000004000
20004000400040006000400080004000A0004000C0004000E000402000004020
20004020400040206000402080004020A0004020C0004020E000404000004040
20004040400040406000404080004040A0004040C0004040E000406000004060
20004060400040606000406080004060A0004060C0004060E000408000004080
20004080400040806000408080004080A0004080C0004080E00040A0000040A0
200040A0400040A0600040A0800040A0A00040A0C00040A0E00040C0000040C0
200040C0400040C0600040C0800040C0A00040C0C00040C0E00040E0000040E0
200040E0400040E0600040E0800040E0A00040E0C00040E0E000800000008000
20008000400080006000800080008000A0008000C0008000E000802000008020
20008020400080206000802080008020A0008020C0008020E000804000008040
20008040400080406000804080008040A0008040C0008040E000806000008060
20008060400080606000806080008060A0008060C0008060E000808000008080
20008080400080806000808080008080A0008080C0008080E00080A0000080A0
200080A0400080A0600080A0800080A0A00080A0C00080A0E00080C0000080C0
200080C0400080C0600080C0800080C0A00080C0C00080C0E00080E0000080E0
200080E0400080E0600080E0800080E0A00080E0C00080E0E000C0000000C000
2000C0004000C0006000C0008000C000A000C000C000C000E000C0200000C020
2000C0204000C0206000C0208000C020A000C020C000C020E000C0400000C040
2000C0404000C0406000C0408000C040A000C040C000C040E000C0600000C060
2000C0604000C0606000C0608000C060A000C060C000C060E000C0800000C080
2000C0804000C0806000C0808000C080A000C080C000C080E000C0A00000C0A0
2000C0A04000C0A06000C0A08000C0A0A000C0A0C000C0A0E000C0C00000C0C0
2000C0C04000C0C06000C0C08000C0C0A000F0FBFF00A4A0A000808080000000
FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00FDFDFDFDFD1D
1D1D1D1DFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFD000000FDFDFDFB0000
0000000000FDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFD000000FDFDFBFB1D1D
0000001D1D1DFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFD000000FDFBFB1D1DFB
000000FBFB1D1DFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFD000000FBFB1D1DFBFB
0000001DFBFB1D1DFDFDFDFDFDFDFDFDFDFDFDFDFDFDFD000000FBFB1D1DFB1D
0000001D1DFBFB1D1DFDFDFDFDFDFDFDFDFDFDFDFDFDFD000000FBFB1DFBFB1D
000000FB1D1DFBFB1DFDFDFDFDFDFDFDFDFDFDFD00FDFD000000FBFB1DFBFB1D
000000FBFB1DFBFB1D1DFDFDFDFDFDFDFDFDFD000000FD000000FBFB1D1D0000
0000001DFB1DFBFB1D1DFDFDFDFDFDFDFDFD0000000000000000FBFBFB1DFBFB
1D1D1DFBFB1DFBFB1D1DFDFDFDFDFDFDFDFDFDFDFDFDFD000000FDFBFB1D1DFB
FBFBFBFB1D1DFBFB1DFDFDFDFDFDFDFDFDFDFDFDFDFDFD000000FDFBFBFB1D1D
0000001D1DFBFB1D1DFDFDFDFDFDFDFDFDFDFDFDFDFDFD000000FDFDFBFBFB1D
0000001D1DFBFB1DFDFDFDFDFDFDFDFDFDFDFDFDFDFDFD000000FDFDFDFBFBFB
1D001DFBFBFB1D1DFDFDFDFDFDFDFDFDFDFDFDFDFDFDFD000000FDFDFDFDFDFB
FBFBFBFBFB1D1DFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFD000000FDFDFDFDFDFD
FD1D1D1D1DFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFD000000}
Transparent = False
OnClick = btnSaleDocsClick
end
end
object tlbToggleButtons: TToolBar
Left = 809
Top = 0
Width = 192
Height = 24
Align = alRight
AutoSize = True
ButtonHeight = 24
ButtonWidth = 24
Caption = 'tlbToggleButtons'
Images = dmMain.ilActions
ParentShowHint = False
ShowHint = True
TabOrder = 4
object btnToggleTreeView: TSpeedButton
Left = 0
Top = 0
Width = 113
Height = 24
Action = actToggleTreeView
AllowAllUp = True
GroupIndex = 6
Flat = True
Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
2000000000000004000000000000000000000000000000000000FF00FF000000
0000FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00
FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF000000
0000FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00
FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF000000
0000FF00FF00FF00FF000000000000000000000000000000000000000000FF00
FF000000000000000000FF00FF000000000000000000FF00FF00FF00FF000000
000000000000000000000000000000FFFF0000FFFF0000FFFF0000000000FF00
FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF000000
0000FF00FF00FF00FF000000000000FFFF0000FFFF000000000000000000FF00
FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF000000
0000FF00FF00FF00FF00FF00FF000000000000000000FF00FF00FF00FF00FF00
FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF000000
0000FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00
FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF000000
0000FF00FF00FF00FF000000000000000000000000000000000000000000FF00
FF000000000000000000FF00FF000000000000000000FF00FF00FF00FF000000
000000000000000000000000000000FFFF0000FFFF0000FFFF0000000000FF00
FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF000000
0000FF00FF00FF00FF000000000000FFFF0000FFFF000000000000000000FF00
FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF000000
0000FF00FF00FF00FF00FF00FF000000000000000000FF00FF00FF00FF00FF00
FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF000000
0000FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00
FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00000000000000
0000000000000000000000000000FF00FF000000000000000000FF00FF000000
00000000000000000000FF00FF00FF00FF00FF00FF00FF00FF000000000000FF
FF0000FFFF0000FFFF0000000000FF00FF00FF00FF00FF00FF00FF00FF00FF00
FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF000000000000FF
FF0000FFFF000000000000000000FF00FF00FF00FF00FF00FF00FF00FF00FF00
FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF000000
000000000000FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00
FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00}
Transparent = False
end
object btnShowInactive: TToolButton
Left = 113
Top = 0
Action = actShowInactive
end
object sepToggleTreeView: TToolButton
Left = 137
Top = 0
Width = 8
Caption = 'sepToggleTreeView'
Style = tbsSeparator
end
object btnToggleOwnerConsumer: TSpeedButton
Tag = 2
Left = 145
Top = 0
Width = 23
Height = 24
Hint = #1055#1088#1077#1074#1082#1083#1102#1095#1074#1072' '#1055#1086#1088#1098#1095#1080#1090#1077#1083' / '#1058#1055' '#1055#1086#1083#1079#1074#1072#1090#1077#1083
AllowAllUp = True
GroupIndex = 4
Flat = True
Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
2000000000000004000000000000000000000000000000000000FF00FF00FF00
FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00
FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00
FF0000000000FF00FF00FF00FF00000000000000000000000000FF00FF000000
0000FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00
FF00FF00FF000000000000000000FFFFFF00FFFFFF000000000000000000FF00
FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00
FF00FF00FF00FF00FF0000000000FFFFFF00000000000000000000000000FF00
FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00000000000000
0000000000000000000000000000FFFFFF00FFFFFF00FFFFFF00FFFFFF000000
00000000000000000000000000000000000000000000FF00FF0000000000FFFF
FF00FFFFFF00000000000000000000000000FFFFFF00FFFFFF00FFFFFF000000
0000FFFFFF00FFFFFF00FFFFFF000000000000000000FF00FF0000000000FFFF
FF00000000000000000000000000FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF000000000000000000000000000000000000000000FF00FF0000000000FFFF
FF00000000000000000000000000FFFFFF00FFFFFF00FFFFFF00000000000000
00000000000000000000000000000000000000000000FF00FF0084848400FFFF
FF000000000000000000000000000000000000000000FFFFFF00000000000000
00000000000000000000000000000000000000000000FF00FF0084848400FFFF
FF00000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000FF00FF0084848400FFFF
FF00848484000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000FF00FF0000000000FFFF
FF0084848400FFFFFF0000000000000000000000000000000000000000000000
0000000000000000000000000000FF00FF0000000000FF00FF0084848400FFFF
FF0084848400FFFFFF00FFFFFF00FFFFFF008484840000000000FFFFFF008484
840084848400FFFFFF00000000000000000000000000FF00FF0084848400FFFF
FF0084848400FFFFFF008484840084848400FFFFFF0000000000FFFFFF00FFFF
FF0000000000FFFFFF0000000000FF00FF0000000000FF00FF00848484008484
840084848400FFFFFF00FFFFFF00FFFFFF0000000000FF00FF0000000000FFFF
FF00FFFFFF00FFFFFF00000000000000000000000000FF00FF00FF00FF00FF00
FF0084848400848484008484840084848400FF00FF00FF00FF00FF00FF008484
8400848484008484840084848400FF00FF00FF00FF00FF00FF00}
Transparent = False
end
object btnToggleProductDisplay: TSpeedButton
Tag = 4
Left = 168
Top = 0
Width = 24
Height = 24
Hint = #1055#1088#1077#1074#1082#1083#1102#1095#1074#1072' '#1059#1087#1088#1072#1074#1083#1103#1077#1084' '#1054#1073#1077#1082#1090'/'#1054#1079#1085#1072#1095#1077#1085#1080#1103' '#1086#1090' '#1082#1083#1080#1077#1085#1090#1072
AllowAllUp = True
GroupIndex = 2
Flat = True
Glyph.Data = {
36030000424D3603000000000000360000002800000010000000100000000100
1800000000000003000000000000000000000000000000000000FF00FFFF00FF
FF00FFFF00FFFF00FFFF00FFFF00FFFF00FFFF00FFFF00FFFF00FFFF00FFFF00
FFFF00FFFF00FFFF00FFFF00FFFF00FFFF00FFFF00FFFF00FFFF00FFFF00FFFF
00FFFF00FFFF00FFFF00FFFF00FFFF00FFFF00FFFF00FFFF00FFFF00FFFF00FF
FF00FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF00FF
FFFF00FFFF00FFFF00FFFF00FFFF00FFFF00FF0000FF0000000000FF0000FF00
00FF0000FF0000FF0000000000FF00FFFF00FFFFFF00FFFF00FFFF00FFFF00FF
FF00FF0000FF0000000000FF0000FF0000FF0000FF0000FF0000000000FF00FF
FF80808000FFFFFF00FFFF00FFFF00FFFF00FF0000FF00000000000000000000
00000000000000000000000000FF00FFFF80808080808000FFFFFF00FFFF00FF
FF00FF0000FF0000FF0000000000FF0000FF0000FF0000000000FF0000FF00FF
FF80808080808000FFFFFF00FFFF00FFFF00FF0000FF0000FF00000000000000
00FF0000000000000000FF0000FF00FFFF80808080808000FFFFFF00FFFF00FF
FF00FF0000FF0000FF0000FF0000000000000000000000FF0000FF0000FF00FF
FF80808000FFFF00FFFFFF00FFFF00FFFF00FF0000FF0000FF0000FF0000FF00
00000000FF0000FF0000FF0000FF00FFFF80808080808000FFFFFF00FFFF00FF
FF00FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF00FF
FF00FFFF80808000FFFFFF00FFFF00FFFF00FFFF00FFFF0000FF0000FF0000FF
0000FF0000FF0000FF0000FF0000FF000000FFFF00FFFF00FFFFFF00FFFF00FF
FF00FFFF00FFFF00FFFF0000FF0000FF0000FF0000FF0000FF0000FF0000FF00
00FF000000FFFF00FFFFFF00FFFF00FFFF00FFFF00FFFF00FFFF00FFFF0000FF
0000FF0000FF0000FF0000FF0000FF0000FF0000FF000000FFFFFF00FFFF00FF
FF00FFFF00FFFF00FFFF00FFFF00FFFF00FFFF00FFFF00FFFF00FFFF00FFFF00
FFFF00FFFF00FFFF00FFFF00FFFF00FFFF00FFFF00FFFF00FFFF00FFFF00FFFF
00FFFF00FFFF00FFFF00FFFF00FFFF00FFFF00FFFF00FFFF00FF}
Transparent = False
end
end
object navDataRefresh: TDBColorNavigator
Left = 96
Top = 0
Width = 24
Height = 24
DataSource = dsGridData
VisibleButtons = [nbRefresh]
Align = alLeft
Flat = True
TabOrder = 5
BeforeAction = navDataBeforeAction
end
end
inherited grdData: TAbmesDBGrid
Width = 1001
Height = 509
FooterRowCount = 1
FooterParams.Color = 15258325
HorzScrollBar.VisibleMode = sbNeverShowEh
TitleParams.MultiTitle = True
OnGetCellParams = grdDataGetCellParams
Columns = <
item
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'SPEC_STATE_CODE'
Footers = <>
Title.Caption = #1057#1090#1072#1090#1091#1089#1080'|'#1055#1048#1056
Width = 35
end
item
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'ML_STATE_CODE'
Footers = <>
Title.Caption = #1057#1090#1072#1090#1091#1089#1080'|'#1054#1055#1042
Width = 26
end
item
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'CURRENT_TO_LIMITING_DATE_DIFF'
Footers = <>
Title.Caption = #1044#1085#1080' '#1076#1086' '#1072#1082#1090'.'
Width = 25
end
item
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'IS_SALE'
Footers = <>
Title.Caption = #1054#1073#1074'. '#1089' '#1054#1055#1055
Title.Hint = #1054#1073#1074#1098#1088#1079#1072#1085#1086#1089#1090' '#1089' '#1087#1088#1086#1076#1072#1078#1073#1080
Title.Orientation = tohVertical
Width = 13
end
item
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = '_PRODUCTION_ORDER_POSITION'
Footers = <>
Title.Caption = #1055#1086#1079'. '#1085#1072' '#1054#1055#1042
Title.Orientation = tohVertical
Width = 19
end
item
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'SALE_IDENTIFICATION'
Footers = <>
Title.Caption = 'ID '#1054#1055#1042
Width = 152
end
item
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'PRIORITY_FULL_NAME'
Footers = <>
Title.Caption = #1054#1089#1085'. '#1055#1088'.'
Title.Orientation = tohVertical
Width = 16
end
item
CellButtons = <>
Color = clBtnFace
DynProps = <>
EditButtons = <>
FieldName = 'WORK_PRIORITY_NO'
Footers = <>
Title.Caption = #1054#1087'. '#1055#1088'.'
Title.Orientation = tohVertical
Width = 24
end
item
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'OWNER_NAME'
Footers = <>
Tag = 2
Title.Caption = #1055#1086#1088#1098#1095#1080#1090#1077#1083
Width = 93
end
item
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'CONSUMER_DEPT_IDENTIFIER'
Footers = <>
Tag = 3
Title.Caption = #1058#1055' '#1055#1086#1083#1079#1074#1072#1090#1077#1083
Visible = False
Width = 93
end
item
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'PRODUCT_NAME'
Footers = <>
Tag = 4
Title.Caption = #1059#1087#1088#1072#1074#1083#1103#1077#1084' '#1054#1073#1077#1082#1090
Width = 186
end
item
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'PRODUCT_NO'
Footers = <>
Title.Caption = #1059#1087#1088#1072#1074#1083#1103#1077#1084' '#1054#1073#1077#1082#1090' No'
Visible = False
end
item
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'CLIENT_REQUEST_NO'
Footers = <>
Tag = 5
Title.Caption = #1054#1079#1085#1072#1095#1077#1085#1080#1103' '#1086#1090' '#1082#1083#1080#1077#1085#1090#1072'|'#1055#1086#1088#1098#1095#1082#1072
Visible = False
Width = 73
end
item
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'CLIENT_PRODUCT_NAME'
Footers = <>
Tag = 5
Title.Caption = #1054#1079#1085#1072#1095#1077#1085#1080#1103' '#1086#1090' '#1082#1083#1080#1077#1085#1090#1072'|'#1059#1087#1088#1072#1074#1083#1103#1077#1084' '#1054#1073#1077#1082#1090
Visible = False
Width = 112
end
item
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'MANUFACTURE_QUANTITY'
Footer.FieldName = '_SUM_MANUFACTURE_QUANTITY'
Footer.Font.Charset = DEFAULT_CHARSET
Footer.Font.Color = clWindowText
Footer.Font.Height = -9
Footer.Font.Name = 'Microsoft Sans Serif'
Footer.Font.Style = []
Footer.ValueType = fvtFieldValue
Footers = <>
Title.Caption = #1050'-'#1074#1086
Width = 48
end
item
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'MEASURE_ABBREV'
Footer.FieldName = '_AGG_MEASURE_ABBREV'
Footer.Font.Charset = DEFAULT_CHARSET
Footer.Font.Color = clWindowText
Footer.Font.Height = -9
Footer.Font.Name = 'Microsoft Sans Serif'
Footer.Font.Style = []
Footer.ValueType = fvtFieldValue
Footers = <>
Title.Caption = #1052'.'#1077#1076'.'
Width = 29
end
item
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'MAIN_DEPT_IDENTIFIER'
Footers = <>
Title.Caption = #1058#1055' '#1056#1077#1072#1083#1080' '#1079#1072#1090#1086#1088
Width = 53
end
item
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'ENGINEER_EMPLOYEE_ABBREV'
Footers = <>
Title.Caption = #1052#1054#1044#1045#1083'-'#1080#1077#1088
Title.Orientation = tohVertical
Width = 27
end
item
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'MIN_PRODUCT_NEED_BEGIN_DATE'
Footers = <>
Title.Caption = #1042#1088#1077#1084#1077#1074#1080' '#1080#1085#1090#1077#1088#1074#1072#1083' '#1079#1072' '#1080#1079#1087#1098#1083#1085#1077#1085#1080#1077'|'#1057
Title.Hint = #1057#1090#1072#1088#1090
Width = 31
end
item
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'ENTER_RESULT_STORE_END_DATE'
Footers = <>
Title.Caption = #1042#1088#1077#1084#1077#1074#1080' '#1080#1085#1090#1077#1088#1074#1072#1083' '#1079#1072' '#1080#1079#1087#1098#1083#1085#1077#1085#1080#1077'|'#1060
Title.Hint = #1060#1080#1085#1072#1083
Width = 31
end
item
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'MANUFACTURE_DAYS'
Footers = <>
Title.Caption = #1042#1088#1077#1084#1077#1074#1080' '#1080#1085#1090#1077#1088#1074#1072#1083' '#1079#1072' '#1080#1079#1087#1098#1083#1085#1077#1085#1080#1077'|'#1088'.'#1076'.'
Title.Hint = #1056#1072#1073#1086#1090#1085#1080' '#1076#1085#1080
Width = 24
end
item
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'REQUESTED_CHANGE_COUNT'
Footers = <>
Title.Caption = #1047#1072#1084#1077#1085#1080'|'#1055#1088#1077#1076#1083'.|'#1054
Title.Hint = #1054#1073#1097#1086
Title.ToolTips = True
Width = 18
end
item
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'REQUESTED_MY_CHANGE_COUNT'
Footers = <>
Title.Caption = #1047#1072#1084#1077#1085#1080'|'#1055#1088#1077#1076#1083'.|'#1052
Title.Hint = #1052#1086#1080' ('#1055#1088#1077#1076#1083#1086#1078#1077#1085#1080' '#1086#1090' '#1084#1077#1085')'
Title.ToolTips = True
Width = 18
end
item
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'REJECTED_CHANGE_COUNT'
Footers = <>
Title.Caption = #1047#1072#1084#1077#1085#1080'|'#1054#1090#1082#1072#1079'.|'#1054
Title.Hint = #1054#1073#1097#1086
Title.ToolTips = True
Width = 19
end
item
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'REJECTED_MY_CHANGE_COUNT'
Footers = <>
Title.Caption = #1047#1072#1084#1077#1085#1080'|'#1054#1090#1082#1072#1079'.|'#1052
Title.Hint = #1052#1086#1080' ('#1055#1088#1077#1076#1083#1086#1078#1077#1085#1080' '#1086#1090' '#1084#1077#1085')'
Title.ToolTips = True
Width = 18
end
item
Alignment = taCenter
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'MODEL_DEVELOPMENT_TYPE_ABBREV'
Footers = <>
Title.Caption = #1054#1073#1077#1084' '#1088#1072#1079#1088'.'
Title.Orientation = tohVertical
Width = 28
end
item
Alignment = taCenter
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'MODEL_OPERATIONS_STATUS_CODE'
Footers = <>
Title.Caption = #1042#1080#1076' '#1052#1054#1044#1045#1083
Title.Hint = #1042#1080#1076' '#1052#1054#1044#1045#1083
Title.Orientation = tohVertical
Width = 13
end
item
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'WASTING_ORDER_IDENTIFIER'
Footers = <>
Title.Caption = #1054#1055#1042' '#1054#1089#1085#1086#1074#1077#1085'|ID '#1054#1055#1042
Visible = False
end>
end
object pnlTreeView: TPanel
Left = 0
Top = 24
Width = 1001
Height = 509
Align = alClient
BevelOuter = bvNone
TabOrder = 2
object grdModelsTree: TAbmesDBGrid
Left = 0
Top = 0
Width = 1001
Height = 509
Align = alClient
DataSource = dsGridData
DynProps = <>
FooterParams.Color = 15258325
GridLineParams.VertEmptySpaceStyle = dessNonEh
HorzScrollBar.VisibleMode = sbNeverShowEh
Options = [dgTitles, dgIndicator, dgColLines, dgRowLines, dgConfirmDelete, dgCancelOnExit]
OptionsEh = [dghFixed3D, dghHighlightFocus, dghClearSelection, dghAutoSortMarking, dghMultiSortMarking, dghIncSearch, dghPreferIncSearch]
ReadOnly = True
TabOrder = 0
TitleParams.MultiTitle = True
TitleParams.VTitleMargin = 12
OnDblClick = grdDataDblClick
OnDrawColumnCell = grdModelsTreeDrawColumnCell
OnGetCellParams = grdDataGetCellParams
OnSortMarkingChanged = grdDataSortMarkingChanged
Columns = <
item
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'SALE_IDENTIFICATION'
Footers = <>
Title.Caption = 'ID '#1054#1055#1042
Width = 171
end
item
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'SPEC_STATE_CODE'
Footers = <>
Title.Caption = #1057#1090#1072#1090#1091#1089#1080'|'#1055#1048#1056
Width = 35
end
item
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'ML_STATE_CODE'
Footers = <>
Title.Caption = #1057#1090#1072#1090#1091#1089#1080'|'#1054#1055#1042
Width = 27
end
item
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'CURRENT_TO_LIMITING_DATE_DIFF'
Footers = <>
Title.Caption = #1044#1085#1080' '#1076#1086' '#1072#1082#1090'.'
Width = 25
end
item
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'IS_SALE'
Footers = <>
Title.Caption = #1054#1073#1074'. '#1089' '#1054#1055#1055
Title.Hint = #1054#1073#1074#1098#1088#1079#1072#1085#1086#1089#1090' '#1089' '#1087#1088#1086#1076#1072#1078#1073#1080
Title.Orientation = tohVertical
Width = 13
end
item
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'PRIORITY_FULL_NAME'
Footers = <>
Title.Caption = #1054#1089#1085'. '#1055#1088'.'
Title.Orientation = tohVertical
Width = 16
end
item
CellButtons = <>
Color = 15461355
DynProps = <>
EditButtons = <>
FieldName = 'WORK_PRIORITY_NO'
Footers = <>
Title.Caption = #1054#1087'. '#1055#1088'.'
Title.Orientation = tohVertical
Width = 24
end
item
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'OWNER_NAME'
Footers = <>
Tag = 2
Title.Caption = #1055#1086#1088#1098#1095#1080#1090#1077#1083
Width = 93
end
item
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'CONSUMER_DEPT_IDENTIFIER'
Footers = <>
Tag = 3
Title.Caption = #1058#1055' '#1055#1086#1083#1079#1074#1072#1090#1077#1083
Visible = False
Width = 93
end
item
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'PRODUCT_NAME'
Footers = <>
Tag = 4
Title.Caption = #1059#1087#1088#1072#1074#1083#1103#1077#1084' '#1054#1073#1077#1082#1090
Width = 186
end
item
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'CLIENT_REQUEST_NO'
Footers = <>
Tag = 5
Title.Caption = #1054#1079#1085#1072#1095#1077#1085#1080#1103' '#1086#1090' '#1082#1083#1080#1077#1085#1090#1072'|'#1055#1086#1088#1098#1095#1082#1072
Visible = False
Width = 73
end
item
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'CLIENT_PRODUCT_NAME'
Footers = <>
Tag = 5
Title.Caption = #1054#1079#1085#1072#1095#1077#1085#1080#1103' '#1086#1090' '#1082#1083#1080#1077#1085#1090#1072'|'#1059#1087#1088#1072#1074#1083#1103#1077#1084' '#1054#1073#1077#1082#1090
Visible = False
Width = 112
end
item
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'MANUFACTURE_QUANTITY'
Footer.FieldName = '_SUM_MANUFACTURE_QUANTITY'
Footer.Font.Charset = DEFAULT_CHARSET
Footer.Font.Color = clWindowText
Footer.Font.Height = -9
Footer.Font.Name = 'Microsoft Sans Serif'
Footer.Font.Style = []
Footer.ValueType = fvtFieldValue
Footers = <>
Title.Caption = #1050'-'#1074#1086
Width = 48
end
item
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'MEASURE_ABBREV'
Footer.FieldName = '_AGG_MEASURE_ABBREV'
Footer.Font.Charset = DEFAULT_CHARSET
Footer.Font.Color = clWindowText
Footer.Font.Height = -9
Footer.Font.Name = 'Microsoft Sans Serif'
Footer.Font.Style = []
Footer.ValueType = fvtFieldValue
Footers = <>
Title.Caption = #1052'.'#1077#1076'.'
Width = 29
end
item
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'MAIN_DEPT_IDENTIFIER'
Footers = <>
Title.Caption = #1058#1055' '#1056#1077#1072#1083#1080' '#1079#1072#1090#1086#1088
Width = 53
end
item
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'ENGINEER_EMPLOYEE_ABBREV'
Footers = <>
Title.Caption = #1052#1054#1044#1045#1083'-'#1080#1077#1088
Title.Orientation = tohVertical
Width = 27
end
item
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'MIN_PRODUCT_NEED_BEGIN_DATE'
Footers = <>
Title.Caption = #1042#1088#1077#1084#1077#1074#1080' '#1080#1085#1090#1077#1088#1074#1072#1083' '#1079#1072' '#1080#1079#1087#1098#1083#1085#1077#1085#1080#1077'|'#1057
Title.Hint = #1057#1090#1072#1088#1090
Width = 31
end
item
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'ENTER_RESULT_STORE_END_DATE'
Footers = <>
Title.Caption = #1042#1088#1077#1084#1077#1074#1080' '#1080#1085#1090#1077#1088#1074#1072#1083' '#1079#1072' '#1080#1079#1087#1098#1083#1085#1077#1085#1080#1077'|'#1060
Title.Hint = #1060#1080#1085#1072#1083
Width = 31
end
item
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'MANUFACTURE_DAYS'
Footers = <>
Title.Caption = #1042#1088#1077#1084#1077#1074#1080' '#1080#1085#1090#1077#1088#1074#1072#1083' '#1079#1072' '#1080#1079#1087#1098#1083#1085#1077#1085#1080#1077'|'#1088'.'#1076'.'
Title.Hint = #1056#1072#1073#1086#1090#1085#1080' '#1076#1085#1080
Width = 24
end
item
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'REQUESTED_CHANGE_COUNT'
Footers = <>
Title.Caption = #1047#1072#1084#1077#1085#1080'|'#1055#1088#1077#1076#1083'.|'#1054
Title.Hint = #1054#1073#1097#1086
Title.ToolTips = True
Width = 18
end
item
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'REQUESTED_MY_CHANGE_COUNT'
Footers = <>
Title.Caption = #1047#1072#1084#1077#1085#1080'|'#1055#1088#1077#1076#1083'.|'#1052
Title.Hint = #1052#1086#1080' ('#1055#1088#1077#1076#1083#1086#1078#1077#1085#1080' '#1086#1090' '#1084#1077#1085')'
Title.ToolTips = True
Width = 18
end
item
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'REJECTED_CHANGE_COUNT'
Footers = <>
Title.Caption = #1047#1072#1084#1077#1085#1080'|'#1054#1090#1082#1072#1079'.|'#1054
Title.Hint = #1054#1073#1097#1086
Title.ToolTips = True
Width = 19
end
item
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'REJECTED_MY_CHANGE_COUNT'
Footers = <>
Title.Caption = #1047#1072#1084#1077#1085#1080'|'#1054#1090#1082#1072#1079'.|'#1052
Title.Hint = #1052#1086#1080' ('#1055#1088#1077#1076#1083#1086#1078#1077#1085#1080' '#1086#1090' '#1084#1077#1085')'
Title.ToolTips = True
Width = 18
end
item
Alignment = taCenter
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'MODEL_DEVELOPMENT_TYPE_ABBREV'
Footers = <>
Title.Caption = #1054#1073#1077#1084' '#1088#1072#1079#1088'.'
Title.Orientation = tohVertical
Width = 28
end
item
Alignment = taCenter
CellButtons = <>
DynProps = <>
EditButtons = <>
FieldName = 'MODEL_OPERATIONS_STATUS_CODE'
Footers = <>
Title.Caption = #1042#1080#1076' '#1052#1054#1044#1045#1083
Title.Hint = #1042#1080#1076' '#1052#1054#1044#1045#1083
Title.Orientation = tohVertical
Width = 13
end>
object RowDetailData: TRowDetailPanelControlEh
end
end
end
end
end
inherited dsGridData: TDataSource
Left = 64
Top = 200
end
inherited cdsGridData: TAbmesClientDataSet
AggregatesActive = True
ConnectionBroker = dmMain.conModelReports
Filtered = True
FieldDefs = <
item
Name = 'PROCESS_OBJECT_BRANCH_CODE'
DataType = ftFloat
end
item
Name = 'PROCESS_OBJECT_CODE'
DataType = ftFloat
end
item
Name = 'SALE_OBJECT_BRANCH_CODE'
DataType = ftFloat
end
item
Name = 'SALE_OBJECT_CODE'
DataType = ftFloat
end
item
Name = 'SALE_ORDER_TYPE_CODE'
DataType = ftFloat
end
item
Name = 'IS_SALE'
DataType = ftFloat
end
item
Name = 'PRODUCT_CODE'
DataType = ftFloat
end
item
Name = 'PRODUCT_NAME'
DataType = ftWideString
Size = 100
end
item
Name = 'PRODUCT_NO'
DataType = ftFloat
end
item
Name = 'CLIENT_REQUEST_NO'
DataType = ftWideString
Size = 50
end
item
Name = 'CLIENT_PRODUCT_NAME'
DataType = ftWideString
Size = 1
end
item
Name = 'MANUFACTURE_QUANTITY'
DataType = ftFloat
end
item
Name = 'ENGINEER_EMPLOYEE_CODE'
DataType = ftFloat
end
item
Name = 'ENGINEER_EMPLOYEE_ABBREV'
DataType = ftWideString
Size = 49
end
item
Name = 'IS_ANNULED'
DataType = ftFloat
end
item
Name = 'IS_FINISHED'
DataType = ftFloat
end
item
Name = 'ML_OBJECT_BRANCH_CODE'
DataType = ftFloat
end
item
Name = 'ML_OBJECT_CODE'
DataType = ftFloat
end
item
Name = 'MAIN_DEPT_CODE'
DataType = ftFloat
end
item
Name = 'MAIN_DEPT_IDENTIFIER'
DataType = ftWideString
Size = 46
end
item
Name = 'IS_LIMITING'
DataType = ftFloat
end
item
Name = 'ENTER_RESULT_STORE_END_DATE'
DataType = ftTimeStamp
end
item
Name = 'MIN_PRODUCT_NEED_BEGIN_DATE'
DataType = ftTimeStamp
end
item
Name = 'MANUFACTURE_DAYS'
DataType = ftFloat
end
item
Name = 'IS_ARCHIVED'
DataType = ftFloat
end
item
Name = 'REQUESTED_CHANGE_COUNT'
DataType = ftFloat
end
item
Name = 'REQUESTED_MY_CHANGE_COUNT'
DataType = ftFloat
end
item
Name = 'REJECTED_CHANGE_COUNT'
DataType = ftFloat
end
item
Name = 'REJECTED_MY_CHANGE_COUNT'
DataType = ftFloat
end
item
Name = 'CURRENT_TO_LIMITING_DATE_DIFF'
DataType = ftFloat
end
item
Name = 'ML_STATE_CODE'
DataType = ftFloat
end
item
Name = 'SPEC_STATE_CODE'
DataType = ftFloat
end
item
Name = 'DEL_RECORD'
DataType = ftFloat
end
item
Name = 'MEASURE_ABBREV'
DataType = ftWideString
Size = 5
end
item
Name = 'ACCOUNT_MEASURE_ABBREV'
DataType = ftWideString
Size = 5
end
item
Name = 'MEASURE_CODE'
DataType = ftFloat
end
item
Name = 'ACCOUNT_MEASURE_CODE'
DataType = ftFloat
end
item
Name = 'PRIORITY_CODE'
DataType = ftFloat
end
item
Name = 'PRIORITY_NO'
DataType = ftFloat
end
item
Name = 'PRIORITY_FULL_NAME'
DataType = ftWideString
Size = 93
end
item
Name = 'WORK_PRIORITY_NO'
DataType = ftFloat
end
item
Name = 'WORK_PRIORITY_FULL_NAME'
DataType = ftWideString
Size = 93
end
item
Name = 'SALE_IDENTIFICATION'
DataType = ftWideString
Size = 93
end
item
Name = 'WASTING_ORDER_IDENTIFIER'
DataType = ftWideString
Size = 188
end
item
Name = 'IS_WASTE_COMPENSATOR'
DataType = ftFloat
end
item
Name = 'HAS_WASTE'
DataType = ftFloat
end
item
Name = 'OWNER_NAME'
DataType = ftWideString
Size = 41
end
item
Name = 'CONSUMER_DEPT_IDENTIFIER'
DataType = ftWideString
Size = 46
end
item
Name = 'DOC_BRANCH_CODE'
DataType = ftFloat
end
item
Name = 'DOC_CODE'
DataType = ftFloat
end
item
Name = 'HAS_DOC_ITEMS'
DataType = ftFloat
end
item
Name = 'PRODUCT_HAS_DOC_ITEMS'
DataType = ftFloat
end
item
Name = 'MODEL_OPERATIONS_STATUS_CODE'
DataType = ftFloat
end
item
Name = 'HAS_WASTE_COMPENSATORS'
DataType = ftFloat
end
item
Name = 'MODEL_DEVELOPMENT_TYPE_CODE'
Attributes = [faRequired]
DataType = ftFloat
end
item
Name = 'MODEL_DEVELOPMENT_TYPE_ABBREV'
DataType = ftWideString
Size = 100
end
item
Name = 'SALE_OBJECT_PK'
DataType = ftWideString
Size = 81
end
item
Name = 'WASTING_SALE_OBJ_PK'
DataType = ftWideString
Size = 81
end
item
Name = 'WORK_PRIORITY_CODE'
DataType = ftFloat
end>
IndexDefs = <
item
Name = 'idxDefault'
Fields =
'PRIORITY_NO;WORK_PRIORITY_NO;ENTER_RESULT_STORE_END_DATE;SALE_OR' +
'DER_TYPE_CODE;SALE_IDENTIFICATION'
end>
Params = <
item
DataType = ftFloat
Name = 'TREE_SALE_OBJECT_BRANCH_CODE'
ParamType = ptInput
end
item
DataType = ftFloat
Name = 'TREE_SALE_OBJECT_CODE'
ParamType = ptInput
end
item
DataType = ftFloat
Name = 'USER_CODE'
ParamType = ptInput
end
item
DataType = ftFloat
Name = 'USER_CODE'
ParamType = ptInput
end
item
DataType = ftFloat
Name = 'PRODUCTION_ORDER_BASE_TYPE_CODE'
ParamType = ptInput
end
item
DataType = ftFloat
Name = 'PRODUCTION_ORDER_TYPE_CODE'
ParamType = ptInput
end
item
DataType = ftFloat
Name = 'PRODUCTION_ORDER_TYPE_CODE'
ParamType = ptInput
end
item
DataType = ftFloat
Name = 'PRODUCTION_ORDER_TYPE_CODE'
ParamType = ptInput
end
item
DataType = ftFloat
Name = 'ALL_FILTERED_PRODUCTS'
ParamType = ptInput
end
item
DataType = ftFloat
Name = 'MAIN_DEPT_CODE'
ParamType = ptInput
end
item
DataType = ftFloat
Name = 'MAIN_DEPT_CODE'
ParamType = ptInput
end
item
DataType = ftFloat
Name = 'INCLUDE_DEPT_CODE'
ParamType = ptInput
end
item
DataType = ftFloat
Name = 'INCLUDE_DEPT_CODE'
ParamType = ptInput
end
item
DataType = ftFloat
Name = 'INCLUDE_DETAIL_CODE'
ParamType = ptInput
end
item
DataType = ftFloat
Name = 'INCLUDE_DETAIL_CODE'
ParamType = ptInput
end
item
DataType = ftFloat
Name = 'INCLUDE_PRODUCT_CODE'
ParamType = ptInput
end
item
DataType = ftFloat
Name = 'INCLUDE_PRODUCT_CODE'
ParamType = ptInput
end
item
DataType = ftFloat
Name = 'ENGINEER_EMPLOYEE_CODE'
ParamType = ptInput
end
item
DataType = ftFloat
Name = 'ENGINEER_EMPLOYEE_CODE'
ParamType = ptInput
end
item
DataType = ftTimeStamp
Name = 'ENTER_RESULT_STORE_END_BEGIN_DATE'
ParamType = ptInput
end
item
DataType = ftTimeStamp
Name = 'ENTER_RESULT_STORE_END_END_DATE'
ParamType = ptInput
end
item
DataType = ftFloat
Name = 'SALE_BRANCH_CODE'
ParamType = ptInput
end
item
DataType = ftFloat
Name = 'SALE_BRANCH_CODE'
ParamType = ptInput
end
item
DataType = ftFloat
Name = 'SALE_TYPE_CODE'
ParamType = ptInput
end
item
DataType = ftFloat
Name = 'SALE_TYPE_CODE'
ParamType = ptInput
end
item
DataType = ftFloat
Name = 'SALE_NO'
ParamType = ptInput
end
item
DataType = ftFloat
Name = 'SALE_NO'
ParamType = ptInput
end
item
DataType = ftTimeStamp
Name = 'MIN_PRODUCT_NEED_BEGIN_BEGIN_DATE'
ParamType = ptInput
end
item
DataType = ftTimeStamp
Name = 'MIN_PRODUCT_NEED_BEGIN_END_DATE'
ParamType = ptInput
end
item
DataType = ftTimeStamp
Name = 'MIN_PRODUCT_NEED_BEGIN_BEGIN_DATE'
ParamType = ptInput
end
item
DataType = ftTimeStamp
Name = 'MIN_PRODUCT_NEED_BEGIN_END_DATE'
ParamType = ptInput
end
item
DataType = ftFloat
Name = 'MIN_ML_STATE_CODE'
ParamType = ptInput
Value = '1'
end
item
DataType = ftFloat
Name = 'MAX_ML_STATE_CODE'
ParamType = ptInput
Value = '7'
end
item
DataType = ftFloat
Name = 'HAS_REQUESTED_CHANGES'
ParamType = ptInput
Value = '1'
end
item
DataType = ftFloat
Name = 'HAS_NOT_REQUESTED_CHANGES'
ParamType = ptInput
Value = '1'
end
item
DataType = ftFloat
Name = 'HAS_REQUESTED_CHANGES'
ParamType = ptInput
Value = '1'
end
item
DataType = ftFloat
Name = 'HAS_NOT_REQUESTED_CHANGES'
ParamType = ptInput
Value = '1'
end
item
DataType = ftFloat
Name = 'HAS_REQUESTED_MY_CHANGES'
ParamType = ptInput
Value = '1'
end
item
DataType = ftFloat
Name = 'HAS_NOT_REQUESTED_MY_CHANGES'
ParamType = ptInput
Value = '1'
end
item
DataType = ftFloat
Name = 'HAS_REQUESTED_MY_CHANGES'
ParamType = ptInput
Value = '1'
end
item
DataType = ftFloat
Name = 'USER_CODE'
ParamType = ptInput
end
item
DataType = ftFloat
Name = 'HAS_NOT_REQUESTED_MY_CHANGES'
ParamType = ptInput
Value = '1'
end
item
DataType = ftFloat
Name = 'USER_CODE'
ParamType = ptInput
end
item
DataType = ftFloat
Name = 'HAS_REJECTED_CHANGES'
ParamType = ptInput
Value = '1'
end
item
DataType = ftFloat
Name = 'HAS_NOT_REJECTED_CHANGES'
ParamType = ptInput
Value = '1'
end
item
DataType = ftFloat
Name = 'HAS_REJECTED_CHANGES'
ParamType = ptInput
Value = '1'
end
item
DataType = ftFloat
Name = 'HAS_NOT_REJECTED_CHANGES'
ParamType = ptInput
Value = '1'
end
item
DataType = ftFloat
Name = 'HAS_REJECTED_MY_CHANGES'
ParamType = ptInput
Value = '1'
end
item
DataType = ftFloat
Name = 'HAS_NOT_REJECTED_MY_CHANGES'
ParamType = ptInput
Value = '1'
end
item
DataType = ftFloat
Name = 'HAS_REJECTED_MY_CHANGES'
ParamType = ptInput
Value = '1'
end
item
DataType = ftFloat
Name = 'USER_CODE'
ParamType = ptInput
end
item
DataType = ftFloat
Name = 'HAS_NOT_REJECTED_MY_CHANGES'
ParamType = ptInput
Value = '1'
end
item
DataType = ftFloat
Name = 'USER_CODE'
ParamType = ptInput
end
item
DataType = ftFloat
Name = 'BEGIN_PRIORITY_CODE'
ParamType = ptInput
end
item
DataType = ftFloat
Name = 'END_PRIORITY_CODE'
ParamType = ptInput
end
item
DataType = ftFloat
Name = 'IS_WASTE_COMPENSATOR_STATUS'
ParamType = ptInput
Value = '1'
end
item
DataType = ftFloat
Name = 'IS_WASTE_COMPENSATOR_STATUS'
ParamType = ptInput
Value = '1'
end
item
DataType = ftFloat
Name = 'IS_WASTE_COMPENSATOR_STATUS'
ParamType = ptInput
Value = '1'
end
item
DataType = ftFloat
Name = 'HAS_WASTE_STATUS'
ParamType = ptInput
Value = '1'
end
item
DataType = ftFloat
Name = 'HAS_WASTE_STATUS'
ParamType = ptInput
Value = '1'
end
item
DataType = ftFloat
Name = 'IS_SALE_STATE'
ParamType = ptInput
Value = '0'
end
item
DataType = ftFloat
Name = 'IS_SALE_STATE'
ParamType = ptInput
Value = '0'
end
item
DataType = ftFloat
Name = 'OWNER_COMPANY_CODE'
ParamType = ptInput
end
item
DataType = ftFloat
Name = 'OWNER_COMPANY_CODE'
ParamType = ptInput
end
item
DataType = ftTimeStamp
Name = 'SALE_SHIPMENT_BEGIN_DATE'
ParamType = ptInput
end
item
DataType = ftTimeStamp
Name = 'SALE_SHIPMENT_BEGIN_DATE'
ParamType = ptInput
end
item
DataType = ftTimeStamp
Name = 'SALE_SHIPMENT_END_DATE'
ParamType = ptInput
end
item
DataType = ftTimeStamp
Name = 'SALE_SHIPMENT_END_DATE'
ParamType = ptInput
end
item
DataType = ftFloat
Name = 'IS_SALE_STATE'
ParamType = ptInput
Value = '0'
end
item
DataType = ftFloat
Name = 'OWNER_EMPLOYEE_CODE'
ParamType = ptInput
end
item
DataType = ftFloat
Name = 'OWNER_EMPLOYEE_CODE'
ParamType = ptInput
end
item
DataType = ftFloat
Name = 'MODEL_DEVELOPMENT_TYPE_CODE'
ParamType = ptInput
end
item
DataType = ftFloat
Name = 'MODEL_DEVELOPMENT_TYPE_CODE'
ParamType = ptInput
end
item
DataType = ftFloat
Name = 'MIN_LIMITING_DATE_DIFF'
ParamType = ptInput
end
item
DataType = ftFloat
Name = 'MIN_LIMITING_DATE_DIFF'
ParamType = ptInput
end
item
DataType = ftFloat
Name = 'MAX_LIMITING_DATE_DIFF'
ParamType = ptInput
end
item
DataType = ftFloat
Name = 'MAX_LIMITING_DATE_DIFF'
ParamType = ptInput
end
item
DataType = ftFloat
Name = 'TOOL_DETAIL_CODE'
ParamType = ptInput
end
item
DataType = ftFloat
Name = 'TOOL_DETAIL_CODE'
ParamType = ptInput
end
item
DataType = ftFloat
Name = 'TOOL_DETAIL_CODE'
ParamType = ptInput
end
item
DataType = ftFloat
Name = 'MIN_SPEC_STATE_CODE'
ParamType = ptInput
Value = '0'
end
item
DataType = ftFloat
Name = 'MAX_SPEC_STATE_CODE'
ParamType = ptInput
Value = '6'
end
item
DataType = ftWideString
Name = 'CHOSEN_PRODUCTS'
ParamType = ptInput
end
item
DataType = ftFloat
Name = 'GET_SALE_OBJECT_TREE'
ParamType = ptUnknown
end>
ProviderName = 'prvModels'
OnCalcFields = cdsGridDataCalcFields
OnFilterRecord = cdsGridDataFilterRecord
Left = 32
Top = 200
object cdsGridDataPROCESS_OBJECT_BRANCH_CODE: TAbmesFloatField
FieldName = 'PROCESS_OBJECT_BRANCH_CODE'
end
object cdsGridDataPROCESS_OBJECT_CODE: TAbmesFloatField
FieldName = 'PROCESS_OBJECT_CODE'
end
object cdsGridDataSALE_OBJECT_BRANCH_CODE: TAbmesFloatField
FieldName = 'SALE_OBJECT_BRANCH_CODE'
end
object cdsGridDataSALE_OBJECT_CODE: TAbmesFloatField
FieldName = 'SALE_OBJECT_CODE'
end
object cdsGridDataSALE_ORDER_TYPE_CODE: TAbmesFloatField
FieldName = 'SALE_ORDER_TYPE_CODE'
end
object cdsGridDataIS_SALE: TAbmesFloatField
Alignment = taCenter
FieldName = 'IS_SALE'
DisplayFormat = '#'
DisplayBoolValues = #1051';'#1057
FieldValueType = fvtBoolean
end
object cdsGridDataPRODUCT_CODE: TAbmesFloatField
FieldName = 'PRODUCT_CODE'
end
object cdsGridDataPRODUCT_NAME: TAbmesWideStringField
FieldName = 'PRODUCT_NAME'
Size = 100
end
object cdsGridDataPRODUCT_NO: TAbmesFloatField
FieldName = 'PRODUCT_NO'
end
object cdsGridDataCLIENT_PRODUCT_NAME: TAbmesWideStringField
FieldName = 'CLIENT_PRODUCT_NAME'
Size = 250
end
object cdsGridDataCLIENT_REQUEST_NO: TAbmesWideStringField
FieldName = 'CLIENT_REQUEST_NO'
Size = 50
end
object cdsGridDataMANUFACTURE_QUANTITY: TAbmesFloatField
FieldName = 'MANUFACTURE_QUANTITY'
DisplayFormat = ',0.###'
end
object cdsGridDataENGINEER_EMPLOYEE_CODE: TAbmesFloatField
FieldName = 'ENGINEER_EMPLOYEE_CODE'
end
object cdsGridDataENGINEER_EMPLOYEE_ABBREV: TAbmesWideStringField
FieldName = 'ENGINEER_EMPLOYEE_ABBREV'
Size = 49
end
object cdsGridDataIS_ANNULED: TAbmesFloatField
FieldName = 'IS_ANNULED'
FieldValueType = fvtBoolean
end
object cdsGridDataIS_FINISHED: TAbmesFloatField
FieldName = 'IS_FINISHED'
FieldValueType = fvtBoolean
end
object cdsGridDataML_OBJECT_BRANCH_CODE: TAbmesFloatField
FieldName = 'ML_OBJECT_BRANCH_CODE'
end
object cdsGridDataML_OBJECT_CODE: TAbmesFloatField
FieldName = 'ML_OBJECT_CODE'
end
object cdsGridDataMAIN_DEPT_CODE: TAbmesFloatField
FieldName = 'MAIN_DEPT_CODE'
end
object cdsGridDataMAIN_DEPT_IDENTIFIER: TAbmesWideStringField
FieldName = 'MAIN_DEPT_IDENTIFIER'
Size = 46
end
object cdsGridDataENTER_RESULT_STORE_END_DATE: TAbmesSQLTimeStampField
FieldName = 'ENTER_RESULT_STORE_END_DATE'
end
object cdsGridDataMIN_PRODUCT_NEED_BEGIN_DATE: TAbmesSQLTimeStampField
FieldName = 'MIN_PRODUCT_NEED_BEGIN_DATE'
end
object cdsGridDataMANUFACTURE_DAYS: TAbmesFloatField
DisplayLabel = #1076#1085#1080
FieldName = 'MANUFACTURE_DAYS'
DisplayFormat = '#'
end
object cdsGridDataIS_LIMITING: TAbmesFloatField
FieldName = 'IS_LIMITING'
FieldValueType = fvtBoolean
end
object cdsGridDataIS_ARCHIVED: TAbmesFloatField
FieldName = 'IS_ARCHIVED'
FieldValueType = fvtBoolean
end
object cdsGridDataREQUESTED_CHANGE_COUNT: TAbmesFloatField
FieldName = 'REQUESTED_CHANGE_COUNT'
OnGetText = EmptyZeroGetText
end
object cdsGridDataREQUESTED_MY_CHANGE_COUNT: TAbmesFloatField
FieldName = 'REQUESTED_MY_CHANGE_COUNT'
OnGetText = EmptyZeroGetText
end
object cdsGridDataREJECTED_CHANGE_COUNT: TAbmesFloatField
FieldName = 'REJECTED_CHANGE_COUNT'
OnGetText = EmptyZeroGetText
end
object cdsGridDataREJECTED_MY_CHANGE_COUNT: TAbmesFloatField
FieldName = 'REJECTED_MY_CHANGE_COUNT'
OnGetText = EmptyZeroGetText
end
object cdsGridDataCURRENT_TO_LIMITING_DATE_DIFF: TAbmesFloatField
FieldName = 'CURRENT_TO_LIMITING_DATE_DIFF'
end
object cdsGridDataDEL_RECORD: TAbmesFloatField
FieldName = 'DEL_RECORD'
FieldValueType = fvtBoolean
end
object cdsGridDataML_STATE_CODE: TAbmesFloatField
Alignment = taLeftJustify
FieldName = 'ML_STATE_CODE'
OnGetText = cdsGridDataML_STATE_CODEGetText
end
object cdsGridDataSPEC_STATE_CODE: TAbmesFloatField
Alignment = taLeftJustify
FieldName = 'SPEC_STATE_CODE'
OnGetText = cdsGridDataSPEC_STATE_CODEGetText
end
object cdsGridDataMEASURE_ABBREV: TAbmesWideStringField
DisplayLabel = #1084
FieldName = 'MEASURE_ABBREV'
Size = 5
end
object cdsGridDataACCOUNT_MEASURE_ABBREV: TAbmesWideStringField
DisplayLabel = #1084
FieldName = 'ACCOUNT_MEASURE_ABBREV'
Size = 5
end
object cdsGridData_SUM_MANUFACTURE_QUANTITY: TAbmesFloatField
FieldKind = fkCalculated
FieldName = '_SUM_MANUFACTURE_QUANTITY'
DisplayFormat = ',##'
Calculated = True
end
object cdsGridData_AGG_MEASURE_ABBREV: TAbmesWideStringField
FieldKind = fkCalculated
FieldName = '_AGG_MEASURE_ABBREV'
Size = 10
Calculated = True
end
object cdsGridDataMEASURE_CODE: TAbmesFloatField
FieldName = 'MEASURE_CODE'
end
object cdsGridDataACCOUNT_MEASURE_CODE: TAbmesFloatField
FieldName = 'ACCOUNT_MEASURE_CODE'
end
object cdsGridDataPRIORITY_CODE: TAbmesFloatField
FieldName = 'PRIORITY_CODE'
end
object cdsGridDataPRIORITY_NO: TAbmesFloatField
FieldName = 'PRIORITY_NO'
end
object cdsGridDataPRIORITY_FULL_NAME: TAbmesWideStringField
FieldName = 'PRIORITY_FULL_NAME'
Size = 93
end
object cdsGridDataWORK_PRIORITY_NO: TAbmesFloatField
FieldName = 'WORK_PRIORITY_NO'
end
object cdsGridDataWORK_PRIORITY_FULL_NAME: TAbmesWideStringField
FieldName = 'WORK_PRIORITY_FULL_NAME'
Size = 93
end
object cdsGridDataSALE_IDENTIFICATION: TAbmesWideStringField
FieldName = 'SALE_IDENTIFICATION'
Size = 188
end
object cdsGridDataWASTING_ORDER_IDENTIFIER: TAbmesWideStringField
FieldName = 'WASTING_ORDER_IDENTIFIER'
Size = 188
end
object cdsGridDataIS_WASTE_COMPENSATOR: TAbmesFloatField
FieldName = 'IS_WASTE_COMPENSATOR'
FieldValueType = fvtBoolean
end
object cdsGridDataHAS_WASTE: TAbmesFloatField
FieldName = 'HAS_WASTE'
FieldValueType = fvtBoolean
end
object cdsGridDataOWNER_NAME: TAbmesWideStringField
FieldName = 'OWNER_NAME'
Size = 41
end
object cdsGridDataCONSUMER_DEPT_IDENTIFIER: TAbmesWideStringField
FieldName = 'CONSUMER_DEPT_IDENTIFIER'
Size = 46
end
object cdsGridDataDOC_BRANCH_CODE: TAbmesFloatField
FieldName = 'DOC_BRANCH_CODE'
end
object cdsGridDataDOC_CODE: TAbmesFloatField
FieldName = 'DOC_CODE'
end
object cdsGridDataHAS_DOC_ITEMS: TAbmesFloatField
FieldName = 'HAS_DOC_ITEMS'
FieldValueType = fvtBoolean
end
object cdsGridDataPRODUCT_DOC_BRANCH_CODE: TAbmesFloatField
FieldName = 'PRODUCT_DOC_BRANCH_CODE'
end
object cdsGridDataPRODUCT_DOC_CODE: TAbmesFloatField
FieldName = 'PRODUCT_DOC_CODE'
end
object cdsGridDataPRODUCT_HAS_DOC_ITEMS: TAbmesFloatField
FieldName = 'PRODUCT_HAS_DOC_ITEMS'
FieldValueType = fvtBoolean
end
object cdsGridDataMODEL_OPERATIONS_STATUS_CODE: TAbmesFloatField
FieldName = 'MODEL_OPERATIONS_STATUS_CODE'
OnGetText = cdsGridDataMODEL_OPERATIONS_STATUS_CODEGetText
end
object cdsGridData_PRIORITY_BACKGROUND_COLOR: TAbmesFloatField
FieldKind = fkLookup
FieldName = '_PRIORITY_BACKGROUND_COLOR'
LookupDataSet = cdsPriorities
LookupKeyFields = 'PRIORITY_CODE'
LookupResultField = 'PRIORITY_BACKGROUND_COLOR'
KeyFields = 'PRIORITY_CODE'
Lookup = True
end
object cdsGridData_PRIORITY_COLOR: TAbmesFloatField
FieldKind = fkLookup
FieldName = '_PRIORITY_COLOR'
LookupDataSet = cdsPriorities
LookupKeyFields = 'PRIORITY_CODE'
LookupResultField = 'PRIORITY_COLOR'
KeyFields = 'PRIORITY_CODE'
Lookup = True
end
object cdsGridData_REPORT_TITLE: TAbmesWideStringField
FieldKind = fkCalculated
FieldName = '_REPORT_TITLE'
Size = 100
Calculated = True
end
object cdsGridDataHAS_WASTE_COMPENSATORS: TAbmesFloatField
FieldName = 'HAS_WASTE_COMPENSATORS'
FieldValueType = fvtBoolean
end
object cdsGridData_PRODUCTION_ORDER_POSITION: TAbmesWideStringField
FieldKind = fkCalculated
FieldName = '_PRODUCTION_ORDER_POSITION'
Size = 50
Calculated = True
end
object cdsGridDataMODEL_DEVELOPMENT_TYPE_CODE: TAbmesFloatField
FieldName = 'MODEL_DEVELOPMENT_TYPE_CODE'
Required = True
end
object cdsGridDataMODEL_DEVELOPMENT_TYPE_ABBREV: TAbmesWideStringField
FieldName = 'MODEL_DEVELOPMENT_TYPE_ABBREV'
Size = 100
end
object cdsGridDataSALE_OBJECT_PK: TAbmesWideStringField
FieldName = 'SALE_OBJECT_PK'
Size = 81
end
object cdsGridDataWASTING_SALE_OBJ_PK: TAbmesWideStringField
FieldName = 'WASTING_SALE_OBJ_PK'
Size = 81
end
object cdsGridDataSUM_MANUFACTURE_QUANTITY: TAggregateField
FieldName = 'SUM_MANUFACTURE_QUANTITY'
Active = True
DisplayName = ''
Expression = 'Sum(MANUFACTURE_QUANTITY)'
end
object cdsGridDataAGG_MEASURE_CODE: TAggregateField
FieldName = 'AGG_MEASURE_CODE'
Active = True
DisplayName = ''
Expression = 'Max(MEASURE_CODE) - Min(MEASURE_CODE)'
end
end
inherited alActions: TActionList
inherited actForm: TAction
Caption = #1056#1077#1075#1080#1089#1090#1098#1088' '#1085#1072' '#1056#1077#1072#1083#1080#1079#1072#1094#1080#1086#1085#1085#1080' '#1048#1085#1078#1077#1085#1077#1088#1085#1080' '#1056#1072#1079#1088#1072#1073#1086#1090#1082#1080' '#1087#1086' '#1054#1055#1042' %s'
end
inherited actFilter: TAction
Visible = True
end
inherited actInsertRecord: TAction
Caption = #1057#1098#1079#1076#1072#1074#1072#1085#1077'...'
Hint = #1057#1098#1079#1076#1072#1074#1072#1085#1077' '#1085#1072' '#1056'-'#1052#1054#1044#1045#1083
end
inherited actDelRecord: TAction
Hint = #1048#1079#1090#1088#1080#1074#1072#1085#1077' '#1085#1072' '#1056'-'#1052#1054#1044#1045#1083
end
inherited actEditRecord: TAction
Hint = #1056#1077#1076#1072#1082#1090#1080#1088#1072#1085#1077' '#1085#1072' '#1056'-'#1052#1054#1044#1045#1083
end
object actMakeChanges: TAction
Caption = #1047#1072#1084#1077#1085#1080'...'
Hint =
#1054#1090#1074#1072#1088#1103' '#1080#1079#1073#1088#1072#1085#1080#1103' '#1056'-'#1052#1054#1044#1045#1083' '#1074' '#1088#1077#1078#1080#1084' '#1085#1072' '#1089#1098#1079#1076#1072#1074#1072#1085#1077' '#1080' '#1086#1073#1088#1072#1073#1086#1090#1082#1072' '#1085#1072' '#1079#1072#1084#1077 +
#1085#1080
ImageIndex = 33
OnExecute = actMakeChangesExecute
OnUpdate = actMakeChangesUpdate
end
object actEditSale: TAction
Caption = #1054#1055#1042'...'
ImageIndex = 6
OnExecute = actEditSaleExecute
OnUpdate = actEditSaleUpdate
end
object actCopyToClipboard: TAction
Hint = #1050#1086#1087#1080#1088#1072#1085#1077' '#1085#1086#1084#1077#1088#1072' '#1085#1072' '#1059#1087#1088#1072#1074#1083#1103#1077#1084' '#1054#1073#1077#1082#1090#1072' '#1074' '#1073#1091#1092#1077#1088#1072
ImageIndex = 14
ShortCut = 16451
OnExecute = actCopyToClipboardExecute
OnUpdate = actCopyToClipboardUpdate
end
object actCopyNameToClipboard: TAction
Caption = #1050#1086#1087#1080#1088#1072#1085#1077' '#1085#1072#1080#1084#1077#1085#1086#1074#1072#1085#1080#1077#1090#1086' '#1085#1072' '#1059#1087#1088#1072#1074#1083#1103#1077#1084' '#1054#1073#1077#1082#1090#1072' '#1074' '#1073#1091#1092#1077#1088#1072
Hint = #1050#1086#1087#1080#1088#1072#1085#1077' '#1085#1072#1080#1084#1077#1085#1086#1074#1072#1085#1080#1077#1090#1086' '#1085#1072' '#1059#1087#1088#1072#1074#1083#1103#1077#1084' '#1054#1073#1077#1082#1090#1072' '#1074' '#1073#1091#1092#1077#1088#1072
OnExecute = actCopyNameToClipboardExecute
end
object actCopyNoToClipboard: TAction
Caption = #1050#1086#1087#1080#1088#1072#1085#1077' '#1085#1086#1084#1077#1088#1072' '#1085#1072' '#1059#1087#1088#1072#1074#1083#1103#1077#1084' '#1054#1073#1077#1082#1090#1072' '#1074' '#1073#1091#1092#1077#1088#1072
Hint = #1050#1086#1087#1080#1088#1072#1085#1077' '#1085#1086#1084#1077#1088#1072' '#1085#1072' '#1059#1087#1088#1072#1074#1083#1103#1077#1084' '#1054#1073#1077#1082#1090#1072' '#1074' '#1073#1091#1092#1077#1088#1072
OnExecute = actCopyNoToClipboardExecute
end
object actToggleClientData: TAction
GroupIndex = 9
Hint = #1053#1072#1080#1084#1077#1085#1086#1074#1072#1085#1080#1077' '#1085#1072' '#1059#1087#1088#1072#1074#1083#1103#1077#1084' '#1054#1073#1077#1082#1090#1072' / '#1054#1079#1085#1072#1095#1077#1085#1080#1103' '#1086#1090' '#1082#1083#1080#1077#1085#1090#1072
ImageIndex = 24
end
object actModelCapacityStatus: TAction
Caption = #1050#1072#1087#1072#1094#1080#1090#1077#1090'...'
ImageIndex = 51
OnExecute = actModelCapacityStatusExecute
OnUpdate = actModelCapacityStatusUpdate
end
object actModelStatus: TAction
Caption = #1057#1083#1077#1076#1077#1085#1077'...'
ImageIndex = 18
OnExecute = actModelStatusExecute
OnUpdate = actModelStatusUpdate
end
object actXModelDocStatus: TAction
Caption = #1057#1080#1052' '#1052#1048#1048#1054' '#1085#1072' '#1059#1054#1073
Hint = #1057#1090#1088#1091#1082#1090#1091#1088#1085#1080' '#1080' '#1052#1072#1088#1096#1088#1091#1090#1085#1080' '#1052#1048#1048#1054' '#1085#1072' '#1059#1054#1073
ImageIndex = 113
OnExecute = actXModelDocStatusExecute
OnUpdate = actXModelDocStatusUpdate
end
object actToggleTreeView: TAction
Caption = #1057#1090#1088#1091#1082#1090#1091#1088#1080#1088#1072#1085#1080
GroupIndex = 6
Hint = #1055#1088#1077#1074#1082#1083#1102#1095#1074#1072' '#1057#1090#1088#1091#1082#1090#1091#1088#1080#1088#1072#1085#1080'/'#1045#1076#1080#1085#1080#1095#1085#1080
ImageIndex = 8
OnExecute = actToggleTreeViewExecute
OnUpdate = actToggleTreeViewUpdate
end
object actShowInactive: TAction
GroupIndex = 7
Hint = #1055#1086#1082#1072#1079#1074#1072' '#1055#1088#1080#1082#1083#1102#1095#1077#1085#1080'/'#1040#1085#1091#1083#1080#1088#1072#1085#1080
ImageIndex = 16
OnExecute = actShowInactiveExecute
OnUpdate = actShowInactiveUpdate
end
end
inherited pdsGridDataParams: TParamDataSet
BeforeOpen = pdsGridDataParamsBeforeOpen
AfterOpen = pdsGridDataParamsAfterOpen
AfterClose = pdsGridDataParamsAfterClose
Left = 32
Top = 232
object pdsGridDataParamsMIN_SPEC_STATE_CODE: TAbmesFloatField
DisplayLabel = #1057#1090#1072#1090#1091#1089' '#1085#1072' '#1055#1088#1080#1085#1094#1080#1087#1085#1072#1090#1072' '#1048#1056' - '#1054#1090
FieldName = 'MIN_SPEC_STATE_CODE'
end
object pdsGridDataParamsMAX_SPEC_STATE_CODE: TAbmesFloatField
DisplayLabel = #1057#1090#1072#1090#1091#1089' '#1085#1072' '#1055#1088#1080#1085#1094#1080#1087#1085#1072#1090#1072' '#1048#1056' - '#1044#1086
FieldName = 'MAX_SPEC_STATE_CODE'
end
object pdsGridDataParamsMIN_ML_STATE_CODE: TAbmesFloatField
DisplayLabel = #1057#1090#1072#1090#1091#1089' '#1085#1072' ID '#1054#1055#1042' - '#1054#1090
FieldName = 'MIN_ML_STATE_CODE'
end
object pdsGridDataParamsMAX_ML_STATE_CODE: TAbmesFloatField
DisplayLabel = #1057#1090#1072#1090#1091#1089' '#1085#1072' ID '#1054#1055#1042' - '#1044#1086
FieldName = 'MAX_ML_STATE_CODE'
end
object pdsGridDataParamsPRODUCTION_ORDER_TYPE_CODE: TAbmesFloatField
DisplayLabel = #1055#1088#1086#1094#1077#1089
FieldName = 'PRODUCTION_ORDER_TYPE_CODE'
end
object pdsGridDataParamsSALE_BRANCH_CODE: TAbmesFloatField
DisplayLabel = #1058#1055' '#1043#1083'.'
FieldName = 'SALE_BRANCH_CODE'
end
object pdsGridDataParamsSALE_NO: TAbmesFloatField
DisplayLabel = #8470
FieldName = 'SALE_NO'
end
object pdsGridDataParamsSALE_TYPE_CODE: TAbmesFloatField
DisplayLabel = #1042#1080#1076
FieldName = 'SALE_TYPE_CODE'
end
object pdsGridDataParamsBEGIN_PRIORITY_CODE: TAbmesFloatField
DisplayLabel = #1054#1089#1085'. '#1055#1088#1080#1086#1088#1080#1090#1077#1090' - '#1054#1090
FieldName = 'BEGIN_PRIORITY_CODE'
end
object pdsGridDataParamsEND_PRIORITY_CODE: TAbmesFloatField
DisplayLabel = #1054#1089#1085'. '#1055#1088#1080#1086#1088#1080#1090#1077#1090' - '#1044#1086
FieldName = 'END_PRIORITY_CODE'
end
object pdsGridDataParamsMODEL_DEVELOPMENT_TYPE_CODE: TAbmesFloatField
DisplayLabel = #1054#1073#1077#1084' '#1056#1072#1079#1088'.'
FieldName = 'MODEL_DEVELOPMENT_TYPE_CODE'
end
object pdsGridDataParamsENGINEER_EMPLOYEE_CODE: TAbmesFloatField
DisplayLabel = #1048#1085#1078#1077#1085#1077#1088' '#1052#1054#1044#1045#1083'-'#1080#1077#1088
FieldName = 'ENGINEER_EMPLOYEE_CODE'
end
object pdsGridDataParamsCHOSEN_PRODUCTS: TAbmesWideStringField
DisplayLabel = #1059#1087#1088#1072#1074#1083#1103#1077#1084' '#1054#1073#1077#1082#1090
FieldName = 'CHOSEN_PRODUCTS'
Size = 4000
end
object pdsGridDataParamsIS_SALE_STATE: TAbmesFloatField
DisplayLabel = #1054#1073#1074#1098#1088#1079#1072#1085#1086#1089#1090' '#1089' '#1055#1088#1086#1076#1072#1078#1073#1080
FieldName = 'IS_SALE_STATE'
end
object pdsGridDataParamsOWNER_COMPANY_CODE: TAbmesFloatField
DisplayLabel = #1050#1083#1080#1077#1085#1090
FieldName = 'OWNER_COMPANY_CODE'
end
object pdsGridDataParamsSALE_SHIPMENT_BEGIN_DATE: TAbmesSQLTimeStampField
DisplayLabel = #1042#1088#1084#1048#1085#1090' '#1085#1072' '#1045#1082#1089#1087#1077#1076#1080#1094#1080#1080' - '#1053#1072#1095#1072#1083#1086
FieldName = 'SALE_SHIPMENT_BEGIN_DATE'
end
object pdsGridDataParamsSALE_SHIPMENT_END_DATE: TAbmesSQLTimeStampField
DisplayLabel = #1042#1088#1084#1048#1085#1090' '#1085#1072' '#1045#1082#1089#1087#1077#1076#1080#1094#1080#1080' - '#1050#1088#1072#1081
FieldName = 'SALE_SHIPMENT_END_DATE'
end
object pdsGridDataParamsOWNER_EMPLOYEE_CODE: TAbmesFloatField
DisplayLabel = #1055#1086#1088#1098#1095#1080#1090#1077#1083
FieldName = 'OWNER_EMPLOYEE_CODE'
end
object pdsGridDataParamsIS_WASTE_COMPENSATOR_STATUS: TAbmesFloatField
DisplayLabel = #1055#1086#1079#1080#1094#1080#1103' '#1085#1072' ID '#1054#1055#1042
FieldName = 'IS_WASTE_COMPENSATOR_STATUS'
end
object pdsGridDataParamsHAS_WASTE_STATUS: TAbmesFloatField
DisplayLabel = #1053#1072#1083#1080#1095#1080#1077' '#1085#1072' '#1073#1083#1086#1082'.'
FieldName = 'HAS_WASTE_STATUS'
end
object pdsGridDataParamsMAIN_DEPT_CODE: TAbmesFloatField
DisplayLabel = #1058#1055' '#1056#1077#1072#1083#1080#1079#1072#1090#1086#1088
FieldName = 'MAIN_DEPT_CODE'
end
object pdsGridDataParamsINCLUDE_DEPT_CODE: TAbmesFloatField
DisplayLabel = #1058#1055' '#1055#1088#1080#1077#1084#1085#1080#1082
FieldName = 'INCLUDE_DEPT_CODE'
end
object pdsGridDataParamsINCLUDE_DETAIL_CODE: TAbmesFloatField
DisplayLabel = #1057#1098#1076#1098#1088#1078#1072#1097' '#1050#1057#1063
FieldName = 'INCLUDE_DETAIL_CODE'
end
object pdsGridDataParamsMIN_PRODUCT_NEED_BEGIN_BEGIN_DATE: TAbmesSQLTimeStampField
DisplayLabel = #1042#1088#1084#1048#1085#1090' '#1085#1072' '#1057#1090#1072#1088#1090' '#1085#1072' '#1056'-'#1052#1054#1044#1045#1083' - '#1053#1072#1095#1072#1083#1086
FieldName = 'MIN_PRODUCT_NEED_BEGIN_BEGIN_DATE'
DisplayFormat = 'ww\e\iiii'
AbmesEditFormat = 'ww\e\iiii'
end
object pdsGridDataParamsMIN_PRODUCT_NEED_BEGIN_END_DATE: TAbmesSQLTimeStampField
DisplayLabel = #1042#1088#1084#1048#1085#1090' '#1085#1072' '#1057#1090#1072#1088#1090' '#1085#1072' '#1056'-'#1052#1054#1044#1045#1083' - '#1050#1088#1072#1081
FieldName = 'MIN_PRODUCT_NEED_BEGIN_END_DATE'
DisplayFormat = 'ww\e\iiii'
AbmesEditFormat = 'ww\e\iiii'
end
object pdsGridDataParamsENTER_RESULT_STORE_END_BEGIN_DATE: TAbmesSQLTimeStampField
DisplayLabel = #1042#1088#1084#1048#1085#1090' '#1085#1072' '#1053#1072#1095#1072#1083#1086' '#1085#1072' '#1055#1088#1080#1077#1084#1072#1085#1077' - '#1053#1072#1095#1072#1083#1086
FieldName = 'ENTER_RESULT_STORE_END_BEGIN_DATE'
DisplayFormat = 'ww\e\iiii'
AbmesEditFormat = 'ww\e\iiii'
end
object pdsGridDataParamsENTER_RESULT_STORE_END_END_DATE: TAbmesSQLTimeStampField
DisplayLabel = #1042#1088#1084#1048#1085#1090' '#1085#1072' '#1053#1072#1095#1072#1083#1086' '#1085#1072' '#1055#1088#1080#1077#1084#1072#1085#1077' - '#1050#1088#1072#1081
FieldName = 'ENTER_RESULT_STORE_END_END_DATE'
DisplayFormat = 'ww\e\iiii'
AbmesEditFormat = 'ww\e\iiii'
end
object pdsGridDataParamsINCLUDE_PRODUCT_CODE: TAbmesFloatField
DisplayLabel = #1057#1098#1076#1098#1088#1078#1072#1097' '#1053#1057#1063
FieldName = 'INCLUDE_PRODUCT_CODE'
end
object pdsGridDataParamsMIN_LIMITING_DATE_DIFF: TAbmesFloatField
DisplayLabel = #1044#1085#1080' '#1076#1086' '#1072#1082#1090#1080#1074#1080#1088#1072#1085#1077' - '#1054#1090
FieldName = 'MIN_LIMITING_DATE_DIFF'
end
object pdsGridDataParamsMAX_LIMITING_DATE_DIFF: TAbmesFloatField
DisplayLabel = #1044#1085#1080' '#1076#1086' '#1072#1082#1090#1080#1074#1080#1088#1072#1085#1077' - '#1044#1086
FieldName = 'MAX_LIMITING_DATE_DIFF'
end
object pdsGridDataParamsHAS_REQUESTED_CHANGES: TAbmesFloatField
DisplayLabel = #1055#1088#1077#1076#1083#1086#1078#1077#1085#1080' '#1047#1072#1084#1077#1085#1080' - '#1048#1084#1072' '#1054#1073#1097#1086
FieldName = 'HAS_REQUESTED_CHANGES'
FieldValueType = fvtBoolean
end
object pdsGridDataParamsHAS_NOT_REQUESTED_CHANGES: TAbmesFloatField
DisplayLabel = #1055#1088#1077#1076#1083#1086#1078#1077#1085#1080' '#1047#1072#1084#1077#1085#1080' - '#1053#1103#1084#1072' '#1054#1073#1097#1086
FieldName = 'HAS_NOT_REQUESTED_CHANGES'
FieldValueType = fvtBoolean
end
object pdsGridDataParamsHAS_REQUESTED_MY_CHANGES: TAbmesFloatField
DisplayLabel = #1055#1088#1077#1076#1083#1086#1078#1077#1085#1080' '#1047#1072#1084#1077#1085#1080' - '#1048#1084#1072' '#1052#1086#1080
FieldName = 'HAS_REQUESTED_MY_CHANGES'
FieldValueType = fvtBoolean
end
object pdsGridDataParamsHAS_NOT_REQUESTED_MY_CHANGES: TAbmesFloatField
DisplayLabel = #1055#1088#1077#1076#1083#1086#1078#1077#1085#1080' '#1047#1072#1084#1077#1085#1080' - '#1053#1103#1084#1072' '#1052#1086#1080
FieldName = 'HAS_NOT_REQUESTED_MY_CHANGES'
FieldValueType = fvtBoolean
end
object pdsGridDataParamsHAS_REJECTED_CHANGES: TAbmesFloatField
DisplayLabel = #1054#1090#1082#1072#1079#1072#1085#1080' '#1047#1072#1084#1077#1085#1080' - '#1048#1084#1072' '#1054#1073#1097#1086
FieldName = 'HAS_REJECTED_CHANGES'
FieldValueType = fvtBoolean
end
object pdsGridDataParamsHAS_NOT_REJECTED_CHANGES: TAbmesFloatField
DisplayLabel = #1054#1090#1082#1072#1079#1072#1085#1080' '#1047#1072#1084#1077#1085#1080' - '#1053#1103#1084#1072' '#1054#1073#1097#1086
FieldName = 'HAS_NOT_REJECTED_CHANGES'
FieldValueType = fvtBoolean
end
object pdsGridDataParamsHAS_REJECTED_MY_CHANGES: TAbmesFloatField
DisplayLabel = #1054#1090#1082#1072#1079#1072#1085#1080' '#1047#1072#1084#1077#1085#1080' - '#1048#1084#1072' '#1052#1086#1080
FieldName = 'HAS_REJECTED_MY_CHANGES'
FieldValueType = fvtBoolean
end
object pdsGridDataParamsHAS_NOT_REJECTED_MY_CHANGES: TAbmesFloatField
DisplayLabel = #1054#1090#1082#1072#1079#1072#1085#1080' '#1047#1072#1084#1077#1085#1080' - '#1053#1103#1084#1072' '#1052#1086#1080
FieldName = 'HAS_NOT_REJECTED_MY_CHANGES'
FieldValueType = fvtBoolean
end
object pdsGridDataParamsUSER_CODE: TAbmesFloatField
FieldName = 'USER_CODE'
ProviderFlags = []
end
object pdsGridDataParamsPRODUCT_CODE: TAbmesFloatField
FieldName = 'PRODUCT_CODE'
ProviderFlags = []
end
object pdsGridDataParamsPRODUCTION_ORDER_BASE_TYPE_CODE: TAbmesFloatField
FieldName = 'PRODUCTION_ORDER_BASE_TYPE_CODE'
ProviderFlags = []
end
object pdsGridDataParams_SALE_BRANCH_IDENTIFIER: TAbmesWideStringField
FieldKind = fkLookup
FieldName = '_SALE_BRANCH_IDENTIFIER'
LookupDataSet = cdsBranches
LookupKeyFields = 'BRANCH_CODE'
LookupResultField = 'BRANCH_IDENTIFIER'
KeyFields = 'SALE_BRANCH_CODE'
LookupCache = True
ProviderFlags = []
OnGetText = pdsGridDataParamsGetText
Size = 255
Lookup = True
end
object pdsGridDataParams_MODEL_DEVELOPMENT_TYPE_ABBREV: TAbmesWideStringField
FieldKind = fkLookup
FieldName = '_MODEL_DEVELOPMENT_TYPE_ABBREV'
LookupDataSet = cdsModelDevelopmentTypes
LookupKeyFields = 'MODEL_DEVELOPMENT_TYPE_CODE'
LookupResultField = 'MODEL_DEVELOPMENT_TYPE_ABBREV'
KeyFields = 'MODEL_DEVELOPMENT_TYPE_CODE'
Size = 100
Lookup = True
end
object pdsGridDataParamsTOOL_DETAIL_CODE: TAbmesFloatField
DisplayLabel = #1050#1086#1084#1087#1083#1077#1082#1090#1086#1074#1072#1097' '#1088#1077#1089#1091#1088#1089
FieldName = 'TOOL_DETAIL_CODE'
end
end
inherited dsGridDataParams: TDataSource
Left = 64
Top = 232
end
inherited dsData: TDataSource
Left = 64
Top = 168
end
inherited cdsData: TAbmesClientDataSet
Left = 32
Top = 168
end
object cdsBranches: TAbmesClientDataSet
Aggregates = <>
ConnectionBroker = dmMain.conCompany
Params = <>
ProviderName = 'prvBranches'
Left = 112
Top = 200
object cdsBranchesBRANCH_CODE: TAbmesFloatField
FieldName = 'BRANCH_CODE'
end
object cdsBranchesBRANCH_IDENTIFIER: TAbmesWideStringField
FieldName = 'BRANCH_IDENTIFIER'
Size = 255
end
end
object pmCopy: TPopupMenu
Left = 619
Top = 65530
object miCopyNoToClipboard: TMenuItem
Action = actCopyNoToClipboard
Default = True
end
object miCopyNameToClipboard: TMenuItem
Action = actCopyNameToClipboard
end
end
object pmProductDocumentation: TPopupMenu
Left = 224
Top = 32
end
object cdsPriorities: TAbmesClientDataSet
Aggregates = <>
ConnectionBroker = dmMain.conCommon
Params = <>
ProviderName = 'prvPriorities'
Left = 144
Top = 200
object cdsPrioritiesPRIORITY_CODE: TAbmesFloatField
FieldName = 'PRIORITY_CODE'
end
object cdsPrioritiesPRIORITY_NAME: TAbmesWideStringField
FieldName = 'PRIORITY_NAME'
Size = 50
end
object cdsPrioritiesPRIORITY_COLOR: TAbmesFloatField
FieldName = 'PRIORITY_COLOR'
end
object cdsPrioritiesPRIORITY_BACKGROUND_COLOR: TAbmesFloatField
FieldName = 'PRIORITY_BACKGROUND_COLOR'
end
end
object cdsModelDevelopmentTypes: TAbmesClientDataSet
Aggregates = <>
ConnectionBroker = dmMain.conSales
Params = <>
ProviderName = 'prvModelDevelopmentTypes'
Left = 176
Top = 200
object prvModelDevelopmentTypesMODEL_DEVELOPMENT_TYPE_CODE: TAbmesFloatField
FieldName = 'MODEL_DEVELOPMENT_TYPE_CODE'
Required = True
end
object prvModelDevelopmentTypesMODEL_DEVELOPMENT_TYPE_ABBREV: TAbmesWideStringField
FieldName = 'MODEL_DEVELOPMENT_TYPE_ABBREV'
Size = 100
end
object prvModelDevelopmentTypesMODEL_DEVELOPMENT_TYPE_NAME: TAbmesWideStringField
FieldName = 'MODEL_DEVELOPMENT_TYPE_NAME'
Size = 100
end
end
end
| 39.826851 | 309 | 0.635661 |
fc7e213582c09d43a5e71068e71d67d91e03d303 | 3,463 | pas | Pascal | samples/jsonwebtoken_livevaliditywindow/vclclient/MainClientFormU.pas | lukaszsegiet/delphimvcframework | f78156a9618694ae32fb5d1e70dd545418587475 | [
"Apache-2.0"
]
| 1 | 2018-01-02T09:13:27.000Z | 2018-01-02T09:13:27.000Z | samples/jsonwebtoken_livevaliditywindow/vclclient/MainClientFormU.pas | lukaszsegiet/delphimvcframework | f78156a9618694ae32fb5d1e70dd545418587475 | [
"Apache-2.0"
]
| null | null | null | samples/jsonwebtoken_livevaliditywindow/vclclient/MainClientFormU.pas | lukaszsegiet/delphimvcframework | f78156a9618694ae32fb5d1e70dd545418587475 | [
"Apache-2.0"
]
| null | null | null | unit MainClientFormU;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls;
type
TMainForm = class(TForm)
Memo1: TMemo;
Memo2: TMemo;
Panel1: TPanel;
btnGet: TButton;
btnLOGIN: TButton;
Splitter1: TSplitter;
Label1: TLabel;
btnLoginWithHeaderBasic: TButton;
Button1: TButton;
procedure btnGetClick(Sender: TObject);
procedure btnLOGINClick(Sender: TObject);
procedure btnLoginWithHeaderBasicClick(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
FJWT: string;
procedure SetJWT(const Value: string);
property JWT: string read FJWT write SetJWT;
public
{ Public declarations }
end;
var
MainForm: TMainForm;
implementation
{$R *.dfm}
uses
MVCFramework.RESTClient,
MVCFramework.RESTClient.Intf,
MVCFramework.Middleware.JWT,
MVCFramework.Commons,
MVCFramework.SystemJSONUtils,
System.NetEncoding,
JSONDataObjects;
procedure TMainForm.btnGetClick(Sender: TObject);
var
lClient: IMVCRESTClient;
lResp: IMVCRESTResponse;
tokenOld, tokenNew: string; // NEW CODE
begin
tokenOld := FJWT; // NEW CODE
lClient := TMVCRESTClient.New
.BaseURL('localhost', 8080)
.ReadTimeOut(0);
if not FJWT.IsEmpty then
begin
lClient.SetBearerAuthorization(FJWT);
end;
lResp := lClient
.AddQueryStringParam('firstname', 'Daniele')
.AddQueryStringParam('lastname', 'Teti')
.Get('/admin/role1');
if not lResp.Success then
ShowMessage(lResp.StatusCode.ToString + sLineBreak + lResp.Content);
Memo2.Lines.Text := lResp.Content;
// NEW CODE
tokenNew := lResp.HeaderValue(TMVCJWTDefaults.AUTHORIZATION_HEADER);
if tokenNew.StartsWith('Bearer', True) then
begin
tokenNew := tokenNew.Remove(0, 'Bearer'.Length).Trim;
tokenNew := TNetEncoding.URL.URLDecode(tokenNew).Trim;
JWT := tokenNew;
end; // END NEW CODE
end;
procedure TMainForm.btnLOGINClick(Sender: TObject);
var
lClient: IMVCRESTClient;
lRest: IMVCRESTResponse;
lJSON: TJSONObject;
begin
lClient := TMVCRESTClient.New
.BaseURL('localhost', 8080)
.ReadTimeOut(0)
.AddHeader(TMVCJWTDefaults.USERNAME_HEADER, 'user1')
.AddHeader(TMVCJWTDefaults.PASSWORD_HEADER, 'user1');
lRest := lClient.Get('/login');
lJSON := StrToJSONObject(lRest.Content);
try
JWT := lJSON.S['token'];
finally
lJSON.Free;
end;
end;
procedure TMainForm.btnLoginWithHeaderBasicClick(Sender: TObject);
var
lClient: IMVCRESTClient;
lRest: IMVCRESTResponse;
lJSON: TJSONObject;
begin
lClient := TMVCRESTClient.New
.BaseURL('localhost', 8080)
.ReadTimeOut(0)
.SetBasicAuthorization('user1', 'user1');
lRest := lClient.Post('/login');
lJSON := StrToJSONObject(lRest.Content);
try
JWT := lJSON.S['token'];
finally
lJSON.Free;
end;
end;
procedure TMainForm.Button1Click(Sender: TObject);
var
lClient: IMVCRESTClient;
lRest: IMVCRESTResponse;
lJSON: TJSONObject;
begin
lClient := TMVCRESTClient.New
.BaseURL('localhost', 8080)
.ReadTimeOut(0);
lRest := lClient.Post('/login', '{"jwtusername":"user1","jwtpassword":"user1"}');
lJSON := StrToJSONObject(lRest.Content);
try
JWT := lJSON.S['token'];
finally
lJSON.Free;
end;
end;
procedure TMainForm.SetJWT(const Value: string);
begin
FJWT := Value;
Memo1.Lines.Text := Value;
end;
end.
| 22.782895 | 83 | 0.709789 |
f1c4927d9a74f5de851eb1f988281c756a6b102d | 33,251 | dfm | Pascal | Delphi/Delphi Projeto 2/Forms/U_Pesquisa_Padrao.dfm | lacerdence/Projetos-completos | 18df4a568ff1a1ff7ddbb23d27b75ae7c75eedf1 | [
"MIT"
]
| null | null | null | Delphi/Delphi Projeto 2/Forms/U_Pesquisa_Padrao.dfm | lacerdence/Projetos-completos | 18df4a568ff1a1ff7ddbb23d27b75ae7c75eedf1 | [
"MIT"
]
| null | null | null | Delphi/Delphi Projeto 2/Forms/U_Pesquisa_Padrao.dfm | lacerdence/Projetos-completos | 18df4a568ff1a1ff7ddbb23d27b75ae7c75eedf1 | [
"MIT"
]
| null | null | null | object frm_pesquisa_padrao: Tfrm_pesquisa_padrao
Left = 0
Top = 0
Caption = 'Formul'#225'rio de pesquisa padr'#227'o'
ClientHeight = 739
ClientWidth = 1109
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
KeyPreview = True
OldCreateOrder = False
WindowState = wsMaximized
OnClose = FormClose
OnKeyPress = FormKeyPress
PixelsPerInch = 96
TextHeight = 13
object Panel1: TPanel
Left = 0
Top = 0
Width = 1109
Height = 105
Align = alTop
Color = clSkyBlue
ParentBackground = False
TabOrder = 0
object Label1: TLabel
Left = 8
Top = 18
Width = 140
Height = 19
Caption = 'Op'#231#245'es de pesquisa'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Tahoma'
Font.Style = []
ParentFont = False
end
object lb_nome: TLabel
Left = 240
Top = 18
Width = 48
Height = 19
Caption = 'Nome:'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Tahoma'
Font.Style = []
ParentFont = False
end
object lb_inicio: TLabel
Left = 480
Top = 18
Width = 39
Height = 19
Caption = 'In'#237'cio'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Tahoma'
Font.Style = []
ParentFont = False
end
object lb_fim: TLabel
Left = 632
Top = 18
Width = 26
Height = 19
Caption = 'Fim'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Tahoma'
Font.Style = []
ParentFont = False
end
object cb_chave_pesquisa: TComboBox
Left = 8
Top = 43
Width = 209
Height = 21
TabOrder = 0
OnChange = cb_chave_pesquisaChange
Items.Strings = (
'C'#211'DIGO'
'NOME'
'CADASTRO'
'PER'#205'ODO'
'TODOS')
end
object Ed_nome: TEdit
Left = 240
Top = 43
Width = 193
Height = 21
TabOrder = 1
end
object mk_inicio: TMaskEdit
Left = 480
Top = 43
Width = 120
Height = 21
EditMask = '!99/99/0000;0;_'
MaxLength = 10
TabOrder = 2
Text = ''
end
object mk_fim: TMaskEdit
Left = 632
Top = 43
Width = 120
Height = 21
EditMask = '!99/99/0000;0;_'
MaxLength = 10
TabOrder = 3
Text = ''
end
object bt_pesquisa: TBitBtn
Left = 768
Top = 31
Width = 92
Height = 45
Caption = '&Pesquisar'
Glyph.Data = {
36100000424D3610000000000000360000002800000020000000200000000100
20000000000000100000C40E0000C40E00000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000009E9E9E25939496E4757678E061616922000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000009E9E9E25A7A8AAE4808183FF44464AFF6B6C6FE1000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00009E9E9E25ABACADE4838586FF46484CFF666769FF808082E2000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000009E9E
9E25B0B0B1E48D8E8FFF494C4FFF666869FF88898AE2A0A0A023000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000009E9E9E25B0B0
B1E48D8E8FFF494C4FFF656769FF89898AE1A5A5A52200000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000A5A5A525B6B7B7E49395
96FF4A4D50FF656768FF88898AE0A2A2A2210000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000A5A5A525B8B9BAE49A9B9CFF4F51
54FF646668FF888989E0A2A2A221000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000A1A1A126B8B9BAE49A9B9CFF4F5154FF6466
68FF88898ADF9FA7A72000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000A1A1A126BFC0C0E5A3A4A6FF515457FF646667FF8889
8ADEA4A4A41F0000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000ACACAC1FBFC0C1E5A6A7A8FF535659FF636567FF88898ADDAAAA
AA1E000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000FFFFFF02BABBBCC8A6A7A9FF535659FF636567FF88898ADDA1A1AA1E0000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000FFFFFF017F7F8436888B8D6EA4A4
A68DAAAAAC949696988178787B579D9D9D150000000000000000000000000000
0000AAAAAC69B2B3B4FF57595CFF626466FF878889DCA7A7A71D000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000CCCCCC059395986DC2C2C3DFD2D3D4FFDBDCDCFFDDDD
DEFFDEDFDFFFE2E2E3FFE3E4E4FFCCCCCDFAA9A9ACAD79797F2E000000009C9C
9C27979899EA57595CFF626466FF898A8AC3AAAAAA1800000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000008C8C8C26BABABBD1D3D3D4FFC8C9C9FFD7D8D9FFE0E1E1FFDDDD
DEFFDCDDDDFFDEDFDFFFE0E1E2FFDDDEDEFFE5E6E6FFD4D4D5FB919294B1A3A4
A5FE4F5255FF606264E490909063FFFFFF020000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00008C8C8C31CBCBCCECBFC0C1FFD6D7D7FFD8D9D9FFD1D1D2FFD1D1D2FFD1D1
D2FFD1D1D2FFD1D1D2FFD0D0D1FFD3D4D4FFDDDEDEFFE0E1E1FFE6E7E7FF7374
77FF616365FEA1A1A12900000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000009B9B
9B17C7C7C8E6BABABBFFDBDBDCFFD2D2D3FFD2D3D3FFD3D4D4FFD4D4D5FFD5D5
D6FFD5D5D6FFD4D5D5FFD4D4D5FFD3D3D4FFD1D2D2FFD6D6D7FFDFE0E0FFE6E6
E6FF8D8D90B40000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000B4B5
B7AAC3C3C4FFD7D8D8FFD3D3D4FFD4D5D5FFD6D6D7FFD7D8D8FFD8D8D9FFD8D9
D9FFD8D9D9FFD8D9D9FFD7D8D8FFD6D7D7FFD5D5D6FFD3D3D4FFD5D5D6FFDDDE
DEFFD4D5D6FC7A7A7F3200000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000009C9C9C31D0D0
D1FEC0C1C2FFD4D4D5FFD6D6D7FFD8D8D9FFD9DADAFFDADBDBFFDBDCDCFFDCDD
DDFFDCDDDDFFDCDDDDFFDBDCDCFFDADBDBFFD8D9D9FFD6D7D7FFD4D4D5FFD8D9
D9FFE1E2E2FFAEAEAFB400000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000BCBCBD95BEBF
C0FFD8D9D9FFD6D7D7FFD9D9DAFFDBDCDCFFDDDEDEFFDEDFDFFFDFE0E0FFE0E1
E1FFE0E1E1FFE0E1E1FFDFE0E0FFDDDEDEFFDBDCDCFFD9DADAFFD7D8D8FFD4D5
D5FFD5D6D6FFCDCECFFC848D8D1B000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000D8D9D9DBB5B5
B6FFD6D7D7FFD9DADAFFDCDDDDFFDEDFDFFFE0E1E1FFE2E3E3FFE3E4E4FFE4E5
E5FFE4E5E5FFE4E4E5FFE2E3E3FFE1E2E2FFDFE0E0FFDCDDDDFFDADBDBFFD7D8
D8FFD8D9D9FFE2E2E3FF7C7C7F60000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000D9D9DAFDBABA
BBFFDADADBFFDBDCDCFFDEDFDFFFE1E2E2FFE4E5E5FFE6E6E7FFE7E8E8FFE8E9
E9FFE8E9E9FFE7E8E8FFE6E7E7FFE4E5E5FFE2E3E3FFDFE0E0FFDCDDDDFFD9DA
DAFFDBDBDBFFDEDFDFFF9EA0A28C000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000D6D6D7FFC3C3
C4FFE5E5E5FFE3E4E4FFE2E3E3FFE4E5E5FFE7E8E8FFE9EAEAFFEAEBEBFFEBEC
ECFFEBECECFFEAEBEBFFE9EAEAFFE7E8E8FFE5E6E6FFE2E3E3FFE1E2E2FFE4E4
E4FFE3E4E4FFD7D8D8FFB2B2B39F000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000D9DADAFFC5C5
C6FFE8E9E9FFEBEBEBFFEDEDEDFFEDEDEDFFEDEDEDFFECEDEDFFEDEDEDFFEDED
EDFFEDEEEEFFEDEDEDFFECEDEDFFECEDEDFFECEDEDFFECEDEDFFEBECECFFE9EA
EAFFE7E7E7FFD7D7D8FFAFAFB099000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000E5E6E6F4BCBD
BEFFEBECECFFEEEEEEFFF0F0F0FFF2F2F2FFF3F4F4FFF4F5F5FFF5F5F5FFF6F6
F6FFF6F6F6FFF5F5F5FFF4F5F5FFF3F4F4FFF2F3F3FFF0F1F1FFEEEFEFFFECEC
ECFFECEDEDFFD8D8D8FF9191937B000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000E4E5E5BDBFC0
C1FFEFEFEFFFF0F0F0FFF2F3F3FFF4F4F4FFF5F5F5FFF6F6F6FFF7F7F7FFF7F8
F8FFF7F8F8FFF7F7F7FFF6F7F7FFF5F6F6FFF4F5F5FFF3F3F3FFF1F1F1FFEEEF
EFFFE6E6E6FFD1D2D2FF7B7B7F42000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000D3D5D569C7C7
C8FFEBEBEBFFF2F2F2FFF4F4F4FFF5F6F6FFF6F7F7FFF7F8F8FFF8F8F8FFF9F9
F9FFF9F9F9FFF8F9F9FFF8F8F8FFF7F7F7FFF6F6F6FFF4F5F5FFF2F3F3FFF1F2
F2FFCCCCCDFFC4C4C5E8BFBFBF04000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000E7E7E70BE9E9
E9E9BCBCBDFFF6F6F6FFF5F5F5FFF6F7F7FFF7F7F7FFF8F8F8FFF9F9F9FFFAFA
FAFFFAFAFAFFF9F9F9FFF8F8F8FFF7F8F8FFF6F7F7FFF5F6F6FFF4F4F4FFEDED
EDFFCFCFCFFF96989A7A00000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000DBDB
DE5ED7D7D8FFD2D2D3FFF8F8F8FFF7F8F8FFF8F8F8FFF9F9F9FFF9F9F9FFFAFA
FAFFFAFAFAFFFAFAFAFFF9F9F9FFF8F8F8FFF8F8F8FFF6F7F7FFF8F8F8FFC2C2
C3FFBEBEBFD9BFBFBF0800000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000E1E3E39BD0D0D1FFD3D3D4FFFBFBFBFFF9F9F9FFF9F9F9FFFAFAFAFFFAFA
FAFFFAFAFAFFFAFAFAFFF9FAFAFFF9F9F9FFF9F9F9FFF7F7F7FFC1C1C2FFCDCD
CEF085858A2E0000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000FFFFFF03E2E2E29AD6D7D7FFBDBDBFFFF2F2F3FFFCFCFCFFFBFBFBFFFBFB
FBFFFBFBFBFFFBFBFBFFFBFCFCFFFDFDFDFFD9D9DAFFC5C5C6FFC8C8C9EA8F8F
8F37000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000DBDBDB5DE8E8E8E9C8C8C9FFC2C3C4FFC7C7C8FFD6D6
D7FFD7D7D8FFD3D3D4FFC6C6C7FFC4C4C5FFCFCFD0FEB5B6B8B09797971B0000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000D0D0D00BD2D2D568E2E2E2BDE5E5E6F3D8D8
D9FFD3D3D4FFD5D5D6FED6D6D7DDB8B8BA989595993500000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000}
TabOrder = 4
end
object bt_transferir: TBitBtn
Left = 888
Top = 31
Width = 92
Height = 45
Caption = '&Transferir'
Glyph.Data = {
36100000424D3610000000000000360000002800000020000000200000000100
20000000000000100000C40E0000C40E00000000000000000000000000000000
0000A5A5A500A5A5A504A5A5A506A5A5A50AA5A5A50EA5A5A510A5A5A516A5A5
A516A5A5A518A5A5A51EA5A5A524A5A5A524A5A5A524A5A5A524A5A5A524A5A5
A524A5A5A524A5A5A524A5A5A520A5A5A518A5A5A516A5A5A516A5A5A512A5A5
A50EA5A5A50AA5A5A506A5A5A504A5A5A500000000000000000000000000A5A5
A506A5A5A540A5A5A576A5A5A591A5A5A5A5A5A5A5B1A5A5A5B9A5A5A5C7A5A5
A5C7A5A5A5C7A5A5A5D1A5A5A5D9A5A5A5DBA5A5A5DBA5A5A5DBA5A5A5DBA5A5
A5DBA5A5A5DBA5A5A5D9A5A5A5D3A5A5A5C9A5A5A5C7A5A5A5C7A5A5A5BBA5A5
A5B1A5A5A5A5A5A5A593A5A5A578A5A5A540A5A5A5060000000000000000A5A5
A504A5A5A530A5A5A55CA5A5A574A5A5A587A5A5A597A5A5A59BA5A5A5ADA5A5
A5B3A5A5A5B3A5A5A5B3A5A5A5B7A5A5A5C5A5A5A5C9A5A5A5C9A5A5A5C9A5A5
A5C9A5A5A5C5A5A5A5B7A5A5A5B3A5A5A5B3A5A5A5B3A5A5A5ADA5A5A59BA5A5
A597A5A5A587A5A5A576A5A5A55CA5A5A530A5A5A50400000000000000000000
0000A5A5A500A5A5A500A5A5A502A5A5A504A5A5A506A5A5A508A5A5A50CA5A5
A50CA5A5A50CA5A5A50CA5A5A510A5A5A516A5A5A516A5A5A516A5A5A516A5A5
A516A5A5A516A5A5A510A5A5A50CA5A5A50CA5A5A50CA5A5A50CA5A5A508A5A5
A506A5A5A504A5A5A502A5A5A500A5A5A5000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000A07C2A040000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000A27D2B4EA17D2BE9A17D
2B42000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000A5812F0EA5802E9FA47F2EFFA47F2EFFAB88
3850000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000A8833142A78230E1A78230FFA78230FFA78230FFAF8C
3C50000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000AC86350AAB853491AA8533FDAA8533FFAA8533FFAA8533FFAA8533FFB18D
3E6AAC863528AC863528AC863528AC863528AC863528AC863528AC863528AC86
3528AC863528AC863528AC863528AC8635140000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000AE88
3736AD8836D7AD8836FFAD8836FFAD8836FFAD8836FFAD8836FFAD8836FFAD88
36FFAD8836FFAD8836FFAD8836FFAD8836FFAD8836FFAD8836FFAD8836FFAD88
36FFAD8836FFAD8836FFAD8836FFAD8836F1AE88371200000000000000000000
00000000000000000000000000000000000000000000B28C3B06B18B3A83B18A
39FBB18A39FFB18A39FFB18A39FFB18A39FFB18A39FFB18A39FFB18A39FFB18A
39FFB18A39FFB18A39FFB18A39FFB18A39FFB18A39FFB18A39FFB18A39FFB18A
39FFB18A39FFB18A39FFB18A39FFB18A39FFB18A393000000000000000000000
000000000000000000000000000000000000B48E3D2CB48D3CCDB48D3CFFB48D
3CFFB48D3CFFB48D3CFFB48D3CFFB48D3CFFB48D3CFFB48D3CFFB48D3CFFB48D
3CFFB48D3CFFB48D3CFFB48D3CFFB48D3CFFB48D3CFFB48D3CFFB48D3CFFB48D
3CFFB48D3CFFB48D3CFFB48D3CFFB48D3CFFB48D3C3000000000000000000000
00000000000000000000B8914002B7903F74B7903FF7B7903FFFB7903FFFB790
3FFFB7903FFFB7903FFFB7903FFFB7903FFFB7903FFFB7903FFFB7903FFFB790
3FFFB7903FFFB7903FFFB7903FFFB7903FFFB7903FFFB7903FFFB7903FFFB790
3FFFB7903FFFB7903FFFB7903FFFB7903FFFB7903F3000000000000000000000
000000000000BB934222BA9242C3BA9242FFBA9242FFBA9242FFBA9242FFBA92
42FFBA9242FFBA9242FFBA9242FFBA9242FFBA9242FFBA9242FFBA9242FFBA92
42FFBA9242FFBA9242FFBA9242FFBA9242FFBA9242FFBA9242FFBA9242FFBA92
42FFBA9242FFBA9242FFBA9242FFBA9242FFBA92423000000000000000000000
0000BE964566BD9544F3BD9544FFBD9544FFBD9544FFBD9544FFBD9544FFBD95
44FFBD9544FFBD9544FFBD9544FFBD9544FFBD9544FFBD9544FFBD9544FFBD95
44FFBD9544FFBD9544FFBD9544FFBD9544FFBD9544FFBD9544FFBD9544FFBD95
44FFBD9544FFBD9544FFBD9544FFBD9544FFBD9544300000000000000000C097
4716CDAA5EFDC09847FFC09847FFC09847FFC09847FFC09847FFC09847FFC098
47FFC09847FFC09847FFC09847FFC09847FFC09847FFC09847FFC09847FFC098
47FFC09847FFC09847FFC09847FFC09847FFC09847FFC09847FFC09847FFC098
47FFC09847FFC09847FFC09847FFC09847FFC098473000000000000000000000
0000D6B66F40DABB74E1C8A153FFC39A4AFFC39A4AFFC39A4AFFC39A4AFFC39A
4AFFC39A4AFFC39A4AFFC39A4AFFC39A4AFFC39A4AFFC39A4AFFC39A4AFFC39A
4AFFC39A4AFFC39A4AFFC39A4AFFC39A4AFFC39A4AFFC39A4AFFC39A4AFFC39A
4AFFC39A4AFFC39A4AFFC39A4AFFC39A4AFFC39A4A3000000000000000000000
000000000000C69D4D0EDDBF79A1D4B167FFC69D4DFFC69D4DFFC69D4DFFC69D
4DFFC69D4DFFC69D4DFFC69D4DFFC69D4DFFC69D4DFFC69D4DFFC69D4DFFC69D
4DFFC69D4DFFC69D4DFFC69D4DFFC69D4DFFC69D4DFFC69D4DFFC69D4DFFC69D
4DFFC69D4DFFC69D4DFFC69D4DFFC69D4DFFC69D4D3000000000000000000000
0000000000000000000000000000D8B76E50DCBC76EBCDA557FFC9A050FFC9A0
50FFC9A050FFC9A050FFC9A050FFC9A050FFC9A050FFC9A050FFC9A050FFC9A0
50FFC9A050FFC9A050FFC9A050FFC9A050FFC9A050FFC9A050FFC9A050FFC9A0
50FFC9A050FFC9A050FFC9A050FFC9A050FFC9A0503000000000000000000000
000000000000000000000000000000000000CCA35316DFBF79B1D7B46AFFCCA2
53FFCCA253FFCCA253FFCCA253FFCCA253FFCCA253FFCCA253FFCCA253FFCCA2
53FFCCA253FFCCA253FFCCA253FFCCA253FFCCA253FFCCA253FFCCA253FFCCA2
53FFCCA253FFCCA253FFCCA253FFCCA353FFCCA2533000000000000000000000
00000000000000000000000000000000000000000000CEA45500DBB86F62DFBF
78F1D2AA5CFFCFA555FFCFA555FFCFA555FFCFA555FFCFA555FFCFA555FFCFA5
55FFCFA555FFCFA555FFCFA555FFCFA555FFCFA555FFCFA555FFCFA555FFCFA5
55FFCFA555FFCFA555FFCFA555FFD7B267FFCFA5552800000000000000000000
000000000000000000000000000000000000000000000000000000000000D2A8
5A20E1C17AC1DBB76DFFD2A858FFD2A858FFD2A858FFD2A858FFD2A858FFE1C0
79C1E7CA87A7E7CA87A7E7CA87A7E7CA87A7E7CA87A7E7CA87A7E7CA87A7E7CA
87A7E7CA87A7E7CA87A7E7CA87A7DDB97083D1A7570000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000D5AA5A02DEBA7174E2C17AF7D8AE60FFD5AA5BFFD5AA5BFFD5AA5BFFD9B0
6348000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000D8AE602CE4C37CCFE0BB71FFD8AD5EFFD8AD5EFFDCB3
6648000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000DAAF6006E2BD7487E6C47DFBDDB365FFE1BB
7148000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000DEB3653AE7C57ED3E6C2
7B34000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000}
ModalResult = 1
TabOrder = 5
end
object bt_imprimir: TBitBtn
Left = 1008
Top = 31
Width = 92
Height = 45
Caption = '&Imprimir'
Glyph.Data = {
36100000424D3610000000000000360000002800000020000000200000000100
20000000000000100000C40E0000C40E00000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000002000000100000001C0000001E0000
001E000000200000002200000022000000220000002400000022000000220000
0022000000240000002A0000002A0000002A0000002A0000002C000000220000
0010000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000E14100EA1221D1AC9221D1AC9221D
1AC9221D1AC9201C19CD1E1B19CD221C19CD1E1A18CD1D1918CD1D1A18D11E1B
19D1211B19D1211B18D1211B19D1211B19D1211B19D1211B19D1211C1ACF0B0A
097E000000040000000000000000000000000000000000000000000000000000
00000000000000000000000000000000001637302BFD756053FF8D6F5EFF9074
62FF8C7160FF8F7262FF917363FF927463FF8D7260FF8B6F5FFF8A6D5BFF8C6F
5DFF8E7160FF8D705FFF8C6F5FFF886D5CFF866B5AFF816859FF60524AFF221D
1AB7000000020000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000C65544AF1735C50FF8B6E5DFF7860
54FF7A6054FF846859FF86695BFF886C5BFF8A6C5AFF8C6E5BFF95735EFF9674
5EFF8F6F5DFF846859FF826757FF7F6658FF7F6557FF8B6F5FFF766055FF201B
179D000000000000000000000000000000000000000000000000000000000000
00020000000600000008000000080000000E5B4B41D3705C50FF908982FF8997
96FF8D9998FF919B9AFF919C9BFF949F9EFF929E9CFF939F9DFF909E9DFF8F9B
9AFF8C9998FF8F9B99FF8F9C9AFF889493FFA9B2B2FF816C5FFF7B675AFF0807
077A000000140000001200000012000000100000000600000000000000020000
001E0B0B0B520B0B0A5A0808085E07070762362B24C77B6456FF9C918BFF6075
72FF627673FF637A77FF667C7AFF687E7CFF6A807EFF6B817FFF6B807FFF697F
7DFF677D7AFF647A78FF627875FF617471FF9DACAAFF7C6657FF5A4B42FF0707
07970606067206060678060606720404045E0000002600000002000000041818
18585F5F5FFF707070FF757676FF777777FF393735FF826A5AFF887D75FF6E85
82FF657B79FF6A7F7DFF6D8582FF6F8885FF708A87FF728D89FF718C88FF6E83
81FF6B807EFF6C8280FF677D7BFF637A77FF95A3A3FF6C5648FF40342EFF4D4F
4FFF6A6A69FF686869FF676767FF4A4A4AFD1717175800000004000000022928
2770A6A7A8FFB4B5B5FFB4B5B5FFB5B6B6FF3E3E3EFF735D50FF756A62FF8195
94FF6B827FFF6E8885FF738E8BFF779290FF799592FF7B9794FF728A88FF5C70
8CFF5B6F97FF6C8686FF6D8582FF687D7BFF939D9CFF614F43FF3E3530FF7172
72FFACACACFFADADADFFACACACFF8D8D8CFF232323640000000400000000403F
3F99B4B5B5FFB4B5B5FFB4B5B5FFB5B6B6FF40403FFF59473DFF665A51FF889E
9EFF6F8986FF76918EFF809090FF768E92FF859C9BFF6F8397FF5F6C84FF7081
9EFF617892FF718A88FF6B827FFF647876FF828381FF5F4E42FF3A3735FF7171
72FFADADADFFADADADFFADADADFFA4A5A5FF3737377E00000000000000005858
58C5B4B5B5FFB4B5B5FFB4B5B5FFAFB0B0FF464647FF4A3B32FF53463EFF707A
7AFF5E6D6BFF627471FF5E6E6DFF787E7FFF6B6E70FF465A79FF44577DFF6869
6AFF5A696CFF5D6B69FF596664FF57605FFF6A625DFF544841FF3A3A3AFF6F6F
70FFABABABFFADADADFFADADADFFABABABFF434444AB000000004F5151046666
66F5B1B2B4FFB4B5B5FFB2B3B4FF9A9C9CFF373839FF403731FF34302EFF4E4F
4EFF505150FF505453FF505655FF4A4C4CFF515151FF4F4E4DFF4E4F51FF4D50
54FF494D50FF4C4F4EFF4B4E4EFF4E5254FF4E4844FF413A36FF343535FF6061
63FFA7A7A6FFADADADFFADADADFFADADADFF535454D3000000003A3A3A1C7373
73FFAEB0B2FFB2B5B5FFACAFB3FFA5A7A9FF78797BFF7C7D7EFF818385FF7F80
80FF7D7E7FFF7E7E7FFF7C7C7CFF7C7C7CFF7C7C7CFF7B7B7AFF7B7C7AFF7E7F
7DFF818180FF81807FFF7F7F7EFF7D7E7CFF7A7D7CFF78797BFF7A7A7BFF9090
90FFA6A6A5FFACACABFFACACACFFACACACFF636362F56E727604363636388383
84FFACADADFFB0B2B3FFACAEB1FFACADADFFADADADFFACACACFFABACA8FFAAAB
A7FFA6A6A5FFA5A5A5FFA5A5A5FFA5A5A5FFA6A6A5FFA7A8A6FFABACA8FFABAC
A8FFABACA8FFABACA8FFABACA8FFABACA8FFABACA8FFAAABA8FFAAABA8FFA5A5
A5FFA7A7A7FFAEAFAFFFAAAAAAFFABACA9FF70706FFF41424320363636568A8B
8AFFA3A4A3FFA7A9AAFFAAACAEFFA9ACB0FFAAAAABFFA9AAA9FFA8A8A6FFA7A8
A5FFA6A7A5FFA6A7A4FFA1A1A1FFA0A1A1FFA0A1A1FFA3A3A4FFA5A5A5FFA5A6
A5FFA6A7A6FFA7A8A6FFA7A9A7FFA8AAA8FFA9AAA7FFA9AAA7FFA8A9A6FFA3A4
A3FF9FA3A3FFB1C4BFFFA4A7A7FFA1A3A2FF777878FF3939394836363640B3B4
B5FFF1F2F3FFEBEEF0FFE7EAEDFFE8EBEBFFE9EDEDFFE7E9EAFFE4E7E9FFDCE0
E3FFD2D5D9FFD2D6D9FFDBDFE2FFD8DBDFFFDADEE0FFD3D9DCFFDBDFE0FFD8DE
E0FFD8DEE2FFD8DDE2FFD5DBDEFFDDE3E4FFE3E7E9FFE5E7E8FFE7E9E9FFE7E8
E9FFB7BABAFFA8ACADFFA1A3A4FFECECECFF9C9C9CFF3A3B3B22424243068E8E
8EEBE4E7ECFFDEE2E7FFDEE1E7FFE2E6ECFFE6EBEEFFE8EDEFFFE7EBEEFFE5EA
EDFFDCE2E7FFDCE4E7FFDEE4E7FFDFE3E7FFDFE2E6FFDFE1E7FFDFE2E6FFE0E3
E7FFE5E6E8FFE3E6EAFFE4E6EBFFEBEFF0FFEFF0F1FFEEF1F3FFEBEFF2FFE9ED
F0FFB4B5B7FFA5A8AAFFAFB3B4FFFBFBFCFF808181D700000000000000005050
509FDCE2E6FFD9DEE4FFDCDFE5FFDDE3E7FFE3E6ECFFE4E7EDFFE4E7EDFFE4E7
EDFFD7DFE2FFD5DDDFFFD7DCDEFFDADDDEFFDBDFE2FFDBDFE4FFDCDEE5FFDEE0
E6FFE1E4E6FFE4E6E8FFE4E8EDFFEAEFF0FFEFF0F1FFE7EEEFFFE2E6EBFFDEE4
E8FFD9DFE2FFDADFE3FFE1E7ECFFE5E7EAFF4242429700000000000000003737
3746B3B7B9FFD4DBDDFFD6DCE0FFDADFE4FFE0E4E8FFE1E4E9FFE2E4EAFFE1E4
EBFFDEE3E9FFDCE1E5FFDDE0E5FFDEE0E5FFDDE1E3FFDEE3E7FFDFE6E9FFE2E6
EAFFE5E7E9FFE3E8EAFFE2E8EBFFE6E9ECFFE8ECEEFFE4E9ECFFE0E5EBFFDDE0
E6FFDDE2E6FFDDE3E7FFDFE5ECFFAAACAEFF4242434C00000000000000004242
4204838587DDCED4DBFFD0D5DCFFD0D6DCFFCBD2D7FF858686FF757270FFA5AD
AEFFA7ADAEFF9DA4A7FF9DA3A7FF9CA3A7FF99A1A4FF989FA2FF969EA0FF7071
71FF6F6F70FF727272FF797979FFA7ADB0FF808181FF707170FFA7ABADFFDAE1
E5FFDDDFE6FFDDE0E6FFE0E5E9FF717170EB686C6C0800000000000000000000
00005454557CC8CDD3FFCCD2D9FFCCD1D9FFC8CDD4FF5B5D5EFF69584EFFD4E2
E6FFCEDCDFFFCEDBDEFFCCDADDFFCCD7DBFFCAD5DAFFCDD9DDFFCCD8DBFF5C5E
5DFF4F4F4FFF4E4E4EFF505050FFC9D5D9FF817E7AFF584E47FFA8ABAFFFD4DC
E1FFD8DEE4FFD7DEE4FFCBD0D2FF3E3D3D8F0000000000000000000000000000
00003C3C3D1A9A9EA1F9C8CFD5FFC8CED4FFC4CACEFF5F6061FF685951FFE5F2
F5FFD9E7EAFFD6E4E6FFD6E3E6FFD8E8EBFFD9E9EBFFD8E7EBFFD7E7EBFF9FA7
A9FF9DA4A5FFA3A9AAFFABB3B4FFCCDBDDFF8C8883FF5C5048FFB1B7BAFFD3D9
DDFFD5DEDFFFD5DEDFFF8D8F8FFD4C4D4E200000000000000000000000000000
000000000000727474AFC1C8CCFFC1C9CDFFBDC3C7FF626365FF6C625BFFE0F0
F2FFDAEAECFFDAEAEDFFE0EFF2FFE3F0F3FFE2F0F2FFDDEFF0FFDDEEEFFFD9E9
EDFFDAEBEEFFD8E7EBFFD5E4E8FFD3E1E5FF8D8A87FF5B4E45FFB1B9BDFFC8CF
D5FFCFD5DBFFD2D9DCFF4F5050A7000000000000000000000000000000000000
0000000000005456563075787AD5797D7FDB7A7B7BE5484746F3736962FFDBEC
EEFFDDEEEFFFE1EFF2FFE6F4F6FFE6F5F7FFE6F4F6FFE1F0F4FFDDEFF2FFDDEE
F0FFDDEEEFFFDCEDEFFFD8E8EDFFD7E6E9FF92928FFF50453EFB767A7CE56C6F
72E36D7072DD5D5F60D93A3A3A30000000000000000000000000000000000000
0000000000000000000000000000000000000000000027211D85776F6AFFDEEE
EFFFE3F0F3FFE6F3F5FFE8F7F9FFECF8FCFFE9F7FAFFE6F5F7FFE4F1F4FFDEEF
F3FFDDEFF1FFDEEFF0FFDBEBEEFFD7E5E9FF8E908EFF50463FEB000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000352E2A998A8985FFDEEF
F0FFE6F2F5FFE9F7FAFFEFFCFEFFEFFEFFFFEFFBFEFFE9F7FAFFE6F4F7FFE4F1
F4FFDFEFF3FFDDEFF2FFDBECEFFFD8E8EDFF909393FF51463FFB737682060000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000003D3530AB8B8E8CFFDEEF
F0FFE5F1F4FFEAF7FAFFEFFDFEFFEFFEFFFFEFFCFEFFEAF8FBFFE6F3F6FFE6F2
F5FFE1F0F3FFDDEFF3FFDBEDF0FFD7E7ECFFA0A3A2FF53463DFF4040440C0000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000423B37BD8A8C8CFFDDEF
F0FFDFEFF0FFE7F4F7FFEBF8FBFFECF9FCFFEFFAFEFFEDF9FCFFE6F6F8FFE5F1
F4FFDFEFF0FFDDEFF0FFD9EAEDFFD7E6E9FFA5A9A8FF5D4B41FF1C1C1C1E0000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000473E38CD92918DFFD7DD
DEFFD6DCDEFFD2DADBFFD8DDDEFFDAE0E1FFD9E0E1FFDAE0E3FFD9DFE0FFD6DD
DEFFD3DBDCFFD2DADCFFD0D7D9FFCBD4D6FF999793FF665348FF1414142C0000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000054473FD98F7666FF9177
67FF947868FF937767FF957867FF967866FF977866FF997966FF997A67FF9A7D
6BFF987B69FF967A68FF957766FF937666FF977969FF6D594EFF1412122E0000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000544944EF988071FF997E
6EFF987D6DFF998071FF9B8172FFA18574FFA38573FFA58673FFA28370FFA282
6EFF9E7F6BFFA1826EFFA88A77FFA68A7AFFA18777FF736156FF0F0E0D300000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000A090846050404520505
0552050404520807065206050552040403520505055205050552050404520403
0352040403520907045203030352040303520303035208070660131313120000
0000000000000000000000000000000000000000000000000000}
TabOrder = 6
end
end
object DBGrid1: TDBGrid
Left = 0
Top = 105
Width = 1109
Height = 576
Align = alClient
DataSource = ds_pesq_padrao
TabOrder = 1
TitleFont.Charset = DEFAULT_CHARSET
TitleFont.Color = clWindowText
TitleFont.Height = -11
TitleFont.Name = 'Tahoma'
TitleFont.Style = []
OnDblClick = DBGrid1DblClick
end
object Panel2: TPanel
Left = 0
Top = 681
Width = 1109
Height = 58
Align = alBottom
Color = clSkyBlue
ParentBackground = False
TabOrder = 2
end
object Q_pesq_padrao: TFDQuery
Connection = DM.conexao
Left = 912
Top = 152
end
object ds_pesq_padrao: TDataSource
DataSet = Q_pesq_padrao
Left = 912
Top = 216
end
object Rel_pesq_padrao: TfrxReport
Version = '6.2.1'
DotMatrixReport = False
IniFile = '\Software\Fast Reports'
PreviewOptions.Buttons = [pbPrint, pbLoad, pbSave, pbExport, pbZoom, pbFind, pbOutline, pbPageSetup, pbTools, pbEdit, pbNavigator, pbExportQuick, pbCopy, pbSelection]
PreviewOptions.Zoom = 1.000000000000000000
PrintOptions.Printer = 'Default'
PrintOptions.PrintOnSheet = 0
ReportOptions.CreateDate = 44361.375195057870000000
ReportOptions.LastChange = 44361.375195057870000000
ScriptLanguage = 'PascalScript'
ScriptText.Strings = (
'begin'
''
'end.')
Left = 912
Top = 344
Datasets = <>
Variables = <>
Style = <>
end
object Dataset_pesq_padrao: TfrxDBDataset
UserName = 'frxDBDataset1'
CloseDataSource = False
BCDToCurrency = False
Left = 912
Top = 280
end
end
| 54.960331 | 170 | 0.834712 |
fc72cfc950c4764569cf01b1aeb5d5f8f5a4d8db | 999 | pas | Pascal | src/Horse.ISAPI.pas | josiasmaceda/horse | 895281ef4db9f4568e2df413772a6e55e07ce950 | [
"MIT"
]
| null | null | null | src/Horse.ISAPI.pas | josiasmaceda/horse | 895281ef4db9f4568e2df413772a6e55e07ce950 | [
"MIT"
]
| null | null | null | src/Horse.ISAPI.pas | josiasmaceda/horse | 895281ef4db9f4568e2df413772a6e55e07ce950 | [
"MIT"
]
| null | null | null | unit Horse.ISAPI;
interface
uses Horse.Core, Horse.HTTP, System.SysUtils, Horse.Router, Horse.Exception;
type
EHorseException = Horse.Exception.EHorseException;
EHorseCallbackInterrupted = Horse.Exception.EHorseCallbackInterrupted;
TProc = System.SysUtils.TProc;
THorseList = Horse.HTTP.THorseList;
THorseRequest = Horse.HTTP.THorseRequest;
THorseHackRequest = Horse.HTTP.THorseHackRequest;
THorseResponse = Horse.HTTP.THorseResponse;
THorseHackResponse = Horse.HTTP.THorseHackResponse;
THorseCallback = Horse.Router.THorseCallback;
THorse = class(THorseCore)
public
procedure Start; override;
procedure Stop; override;
end;
implementation
{ THorse }
uses Web.WebBroker, System.Win.ComObj, Winapi.ActiveX, Horse.WebModule;
procedure THorse.Start;
begin
inherited;
CoInitFlags := COINIT_MULTITHREADED;
Application.Initialize;
Application.WebModuleClass := WebModuleClass;
Application.Run;
end;
procedure THorse.Stop;
begin
inherited;
end;
end.
| 22.2 | 76 | 0.780781 |
fc4925e5b8d4656315d0da2eb015093a820cf01d | 587 | pas | Pascal | Pascal-Source/hiEventFromData.pas | QuestYouCraft/Microsoft-Store-UnInstaller | 8634793a92b0043020a495f932144f98d2cce7d9 | [
"MIT"
]
| 18 | 2020-09-22T17:54:37.000Z | 2022-02-22T08:17:36.000Z | Pascal-Source/hiEventFromData.pas | QuestYouCraft/Microsoft-Store-Installer | 8634793a92b0043020a495f932144f98d2cce7d9 | [
"MIT"
]
| 3 | 2020-11-30T22:01:07.000Z | 2022-01-11T19:15:10.000Z | Pascal-Source/hiEventFromData.pas | QuestYouCraft/Microsoft-Store-Installer | 8634793a92b0043020a495f932144f98d2cce7d9 | [
"MIT"
]
| 4 | 2021-09-23T15:26:42.000Z | 2022-01-10T06:28:39.000Z | unit hiEventFromData;
interface
uses Kol,Share,Debug;
type
THIEventFromData = class(TDebug)
private
dt:TData;
public
_data_Data:THI_Event;
_event_onEvent:THI_Event;
procedure _work_doData(var _Data:TData; Index:word);
procedure _var_GetData(var _Data:TData; Index:word);
end;
implementation
procedure THIEventFromData._work_doData;
var ldt:TData;
begin
ldt := ReadMTData(_Data,_data_Data);
FreeData(@dt);
CopyData(@dt,@ldt);
end;
procedure THIEventFromData._var_GetData;
begin
_hi_OnEvent(_event_onEvent,_Data);
_data := dt;
end;
end.
| 16.305556 | 56 | 0.737649 |
47a97d84206a11f03f9638c84f33e5b365aedaf4 | 2,156 | pas | Pascal | CryptoLib.Tests/src/Asn1/ParseTests.pas | stlcours/CryptoLib4Pascal | 82344d4a4b74422559fa693466ca04652e42cf8b | [
"MIT"
]
| 2 | 2019-07-09T10:06:53.000Z | 2021-08-15T18:19:31.000Z | CryptoLib.Tests/src/Asn1/ParseTests.pas | stlcours/CryptoLib4Pascal | 82344d4a4b74422559fa693466ca04652e42cf8b | [
"MIT"
]
| null | null | null | CryptoLib.Tests/src/Asn1/ParseTests.pas | stlcours/CryptoLib4Pascal | 82344d4a4b74422559fa693466ca04652e42cf8b | [
"MIT"
]
| null | null | null | { *********************************************************************************** }
{ * CryptoLib Library * }
{ * Copyright (c) 2018 - 20XX Ugochukwu Mmaduekwe * }
{ * Github Repository <https://github.com/Xor-el> * }
{ * Distributed under the MIT software license, see the accompanying file LICENSE * }
{ * or visit http://www.opensource.org/licenses/mit-license.php. * }
{ * Acknowledgements: * }
{ * * }
{ * Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring * }
{ * development of this library * }
{ * ******************************************************************************* * }
(* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *)
unit ParseTests;
interface
{$IFDEF FPC}
{$MODE DELPHI}
{$ENDIF FPC}
uses
SysUtils,
{$IFDEF FPC}
fpcunit,
testregistry,
{$ELSE}
TestFramework,
{$ENDIF FPC}
ClpAsn1Objects,
ClpIAsn1Objects,
ClpEncoders;
type
TCryptoLibTestCase = class abstract(TTestCase)
end;
type
TTestParse = class(TCryptoLibTestCase)
var
private
FlongTagged: TBytes;
protected
procedure SetUp; override;
procedure TearDown; override;
published
procedure TestParse;
end;
implementation
{ TTestParse }
procedure TTestParse.SetUp;
begin
inherited;
FlongTagged := THex.Decode('9f1f023330');
end;
procedure TTestParse.TearDown;
begin
inherited;
end;
procedure TTestParse.TestParse;
var
aIn: IAsn1StreamParser;
tagged: IAsn1TaggedObjectParser;
begin
aIn := TAsn1StreamParser.Create(FlongTagged);
tagged := aIn.ReadObject() as IAsn1TaggedObjectParser;
CheckEquals(31, tagged.TagNo);
end;
initialization
// Register any test cases with the test runner
{$IFDEF FPC}
RegisterTest(TTestParse);
{$ELSE}
RegisterTest(TTestParse.Suite);
{$ENDIF FPC}
end.
| 22.458333 | 87 | 0.511132 |
f1f6a4d2620fc96e25e436a30728cd6902204ee3 | 1,867 | dfm | Pascal | U_ListaFornecedores.dfm | marcalderdelma/curso-delphi-sistema-financeiro | db4ed2f3beba1580341faef9c1fc03dfb6df0375 | [
"MIT"
]
| null | null | null | U_ListaFornecedores.dfm | marcalderdelma/curso-delphi-sistema-financeiro | db4ed2f3beba1580341faef9c1fc03dfb6df0375 | [
"MIT"
]
| null | null | null | U_ListaFornecedores.dfm | marcalderdelma/curso-delphi-sistema-financeiro | db4ed2f3beba1580341faef9c1fc03dfb6df0375 | [
"MIT"
]
| null | null | null | object frmListafornecedores: TfrmListafornecedores
Left = 0
Top = 0
BorderStyle = bsToolWindow
Caption = 'Lista de Fornecedores'
ClientHeight = 302
ClientWidth = 536
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
Position = poDesktopCenter
OnShow = FormShow
PixelsPerInch = 96
TextHeight = 13
object StatusBar1: TStatusBar
Left = 0
Top = 283
Width = 536
Height = 19
Panels = <
item
Width = 50
end>
end
object Panel1: TPanel
Left = 0
Top = 0
Width = 536
Height = 283
Align = alClient
TabOrder = 1
ExplicitLeft = 8
ExplicitTop = -6
object DBGrid1: TDBGrid
Left = 1
Top = 56
Width = 534
Height = 226
Align = alBottom
DataSource = DSListafornecedores
TabOrder = 0
TitleFont.Charset = DEFAULT_CHARSET
TitleFont.Color = clWindowText
TitleFont.Height = -11
TitleFont.Name = 'Tahoma'
TitleFont.Style = []
OnCellClick = DBGrid1CellClick
Columns = <
item
Expanded = False
FieldName = 'idempresa'
Visible = False
end
item
Expanded = False
FieldName = 'nome'
Title.Caption = 'Nome'
Visible = True
end
item
Expanded = False
FieldName = 'telefone'
Title.Caption = 'Telefone'
Width = 100
Visible = True
end
item
Expanded = False
FieldName = 'tipo'
Title.Caption = 'Tipo'
Width = 60
Visible = True
end>
end
end
object DSListafornecedores: TDataSource
DataSet = DMConexao.CDSListafornecedores
Left = 320
Top = 192
end
end
| 21.709302 | 50 | 0.572576 |
f101ad62fe00d5546e0fcb6e34f15f6b7c79ac7f | 10,937 | pas | Pascal | DDCS/Dialogs/frmPregHistPreg.pas | Veratics/Maternity-Tracker | bc28178d832960ca2f543b0667c075e33f45a93e | [
"Apache-2.0"
]
| 2 | 2016-05-20T22:11:42.000Z | 2021-02-21T17:31:05.000Z | DDCS/Dialogs/frmPregHistPreg.pas | Veratics/Maternity-Tracker | bc28178d832960ca2f543b0667c075e33f45a93e | [
"Apache-2.0"
]
| 43 | 2015-05-15T22:21:21.000Z | 2017-01-06T17:39:09.000Z | DDCS/Dialogs/frmPregHistPreg.pas | VHAINNOVATIONS/Maternity-Tracker | fca505195c458ca1e5f08fbfe40f7303cd1c25bb | [
"Apache-2.0"
]
| 11 | 2015-05-20T15:15:40.000Z | 2017-09-05T13:43:15.000Z | unit frmPregHistPreg;
{
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Developer: Theodore Fontana
VA Contract: TAC-13-06464
v2.0.0.0
}
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, System.StrUtils, Vcl.Graphics, Vcl.Controls, Vcl.Forms,
Vcl.Dialogs, Vcl.StdCtrls, Vcl.ComCtrls, Vcl.Buttons, ORCtrls, ORDtTm,
uDialog, frmPregHistPregInfo, frmPregHistChild;
type
TPregType = (ptN, ptAI, ptAS, ptE);
TfPreg = class(TFrame)
btnDelete: TBitBtn;
pgPreg: TPageControl;
procedure btnDeleteClick(Sender: TObject);
procedure pgPregChange(Sender: TObject);
private
FPregType: TPregType;
FPregIEN: Integer;
FAdded: Boolean;
procedure SetPregType(Value: TPregType);
function GetIndex: Integer;
function GetChildrenV: string;
function GetAdded: Boolean;
public
constructor Create(AOwner: TComponent); override;
procedure DeleteChild(Value: TTabSheet);
procedure GetSaveChildComments(PregID: string);
procedure GetText(var oText: TStringList);
procedure GetSavePregComments(PregID: string; var oText: TStringList);
function GetPregInfo: TfPregInfo;
function GetChild(Value: Integer): TfChild;
function GetSavePregInfo(PregID: string): string;
property PregnancyType: TPregType read FPregType write SetPregType default ptN;
property PregnancyIEN: Integer read FPregIEN write FPregIEN default 0;
property Added: Boolean read GetAdded write FAdded default False;
end;
implementation
{$R *.dfm}
uses
udlgPregHist, uCommon, DDCSUtils, uReportItems;
procedure TfPreg.btnDeleteClick(Sender: TObject);
begin
if ShowMsg('Are you sure you wish to delete this pregnancy record?' +
' All associated child information will also be deleted.' +
' This action cannot be undone.', smiWarning, smbYesNo) = smrYes then
dlgPregHist.DeletePregnancy(GetIndex);
end;
procedure TfPreg.pgPregChange(Sender: TObject);
begin
// if pgPreg.ActivePageIndex <> 0 then
// btnDelete.Visible := False
// else
// btnDelete.Visible := True;
end;
// Private ---------------------------------------------------------------------
procedure TfPreg.SetPregType(Value: TPregType);
var
vPregInfo: TfPregInfo;
begin
FPregType := Value;
vPregInfo := GetPregInfo;
if vPregInfo <> nil then
begin
case Value of
ptN: vPregInfo.lbStatus.Visible := False;
ptAI: vPregInfo.lbStatus.Caption := 'Induced Abortion';
ptAS: vPregInfo.lbStatus.Caption := 'Spontaneous Abortion';
ptE: vPregInfo.lbStatus.Caption := 'Ectopic';
end;
end;
end;
function TfPreg.GetIndex: Integer;
begin
Result := -1;
if Owner is TTabSheet then
Result := TTabSheet(Owner).TabIndex;
end;
function TfPreg.GetChildrenV: string;
var
I: Integer;
begin
Result := '';
if pgPreg.PageCount > 1 then
for I := 1 to pgPreg.PageCount - 1 do
if pgPreg.Pages[I].ControlCount > 0 then
if pgPreg.Pages[I].Controls[0] is TfChild then
Result := Result + TfChild(pgPreg.Pages[I].Controls[0]).GetV;
end;
function TfPreg.GetAdded: Boolean;
begin
Result := FAdded;
if Self.PregnancyIEN < 1 then
Result := True;
end;
// Public ----------------------------------------------------------------------
constructor TfPreg.Create(AOwner: TComponent);
var
nItem: TDDCSNoteItem;
begin
inherited;
nItem := dlgPregHist.ReportCollection.GetNoteItemAddifNil(btnDelete);
if nItem <> nil then
nItem.SayOnFocus := 'Click to delete current pregnancy and associated child records.';
end;
procedure TfPreg.DeleteChild(Value: TTabSheet);
var
I: Integer;
vPregInfo: TfPregInfo;
begin
pgPreg.Pages[Value.TabIndex].Free;
vPregInfo := GetPregInfo;
if vPregInfo <> nil then
begin
vPregInfo.spnBirthCount.OnChange := nil;
vPregInfo.spnBirthCount.Value := vPregInfo.spnBirthCount.Value - 1;
vPregInfo.spnBirthCount.OnChange := vPregInfo.spnBabyCountChange;
vPregInfo.ChildCount := vPregInfo.spnBirthCount.Value;
end;
if pgPreg.PageCount > 1 then
for I := 1 to pgPreg.PageCount - 1 do
pgPreg.Pages[I].Caption := 'Baby # ' + IntToStr(I);
pgPregChange(pgPreg);
end;
procedure TfPreg.GetSaveChildComments(PregID: string);
var
I,J: Integer;
vChild: TfChild;
BabyID: string;
cItem: TConfigItem;
begin
if PregID = '' then
begin
if Added then
PregID := '+' + IntToStr(PregnancyIEN)
else
PregID := IntToStr(PregnancyIEN);
end;
// B^IEN|BABY|#^COMMENT
if pgPreg.PageCount > 1 then
for I := 1 to pgPreg.PageCount - 1 do
if pgPreg.Pages[I].ControlCount > 0 then
if pgPreg.Pages[I].Controls[0] is TfChild then
begin
vChild := TfChild(pgPreg.Pages[I].Controls[0]);
BabyID := PregID + '|' + vChild.BabyIEN + '|' + vChild.BabyNumber;
cItem := dlgPregHist.Configuration.LookUp('B', BabyID, '');
if cItem = nil then
begin
cItem := TConfigItem.Create(dlgPregHist.Configuration);
cItem.ID[1] := 'B';
cItem.ID[2] := BabyID;
end;
cItem.Data.Clear;
for J := 0 to vChild.meComplications.Lines.Count - 1 do
cItem.Data.Add('B^' + BabyID + U + vChild.meComplications.Lines[J]);
end;
end;
procedure TfPreg.GetText(var oText: TStringList);
var
sl: TStringList;
I: Integer;
begin
oText.Clear;
sl := TStringList.Create;
try
if GetPregInfo <> nil then
begin
GetPregInfo.GetText(sl);
if sl.Count > 0 then
oText.AddStrings(sl);
end;
sl.Clear;
if pgPreg.PageCount > 1 then
for I := 1 to pgPreg.PageCount - 1 do
if pgPreg.Pages[I].ControlCount > 0 then
if pgPreg.Pages[I].Controls[0] is TfChild then
begin
TfChild(pgPreg.Pages[I].Controls[0]).GetText(sl);
if sl.Count > 0 then
oText.AddStrings(sl);
sl.Clear;
end;
finally
sl.Free;
end;
end;
procedure TfPreg.GetSavePregComments(PregID: string; var oText: TStringList);
var
vPregInfo: TfPregInfo;
I: Integer;
begin
oText.Clear;
vPregInfo := GetPregInfo;
if vPregInfo = nil then
Exit;
if PregID = '' then
begin
if Added then
PregID := '+' + IntToStr(PregnancyIEN)
else
PregID := IntToStr(PregnancyIEN);
end;
// C^IEN^COMMENT
for I := 0 to vPregInfo.meDeliveryNotes.Lines.Count - 1 do
oText.Add('C^' + PregID + U + vPregInfo.meDeliveryNotes.Lines[I])
end;
function TfPreg.GetPregInfo: TfPregInfo;
begin
Result := nil;
if pgPreg.PageCount > 0 then
if pgPreg.Pages[0].ControlCount > 0 then
if pgPreg.Pages[0].Controls[0] is TfPregInfo then
Result := TfPregInfo(pgPreg.Pages[0].Controls[0]);
end;
function TfPreg.GetChild(Value: Integer): TfChild;
var
I: Integer;
sValue: string;
begin
Result := nil;
sValue := IntToStr(Value);
if pgPreg.PageCount > 1 then
for I := 1 to pgPreg.PageCount - 1 do
if pgPreg.Pages[I].ControlCount > 0 then
if pgPreg.Pages[I].Controls[0] is TfChild then
if TfChild(pgPreg.Pages[I].Controls[0]).BabyIEN = sValue then
begin
Result := TfChild(pgPreg.Pages[I].Controls[0]);
Break;
end;
end;
function TfPreg.GetSavePregInfo(PregID: string): string;
var
vPregInfo: TfPregInfo;
begin
Result := '';
vPregInfo := GetPregInfo;
if vPregInfo = nil then
Exit;
if PregID = '' then
PregID := IntToStr(PregnancyIEN);
// 1) L
// 2) IEN
// 3) DATE RECORDED
// 4) EDC
// 5) DFN|PATIENT
// 6) STATUS
// 7) FOF|(IEN OR IDENTIFIER)
// 8) EDD
// 9) PREGNANCY END
// 10) OB IEN|OB
// 11) FACILITY IEN|FACILITY
// 12) UPDATED BY IEN|UPDATED BY
// 13) GESTATIONAL AGE
// 14) LENGTH OF LABOR
// 15) TYPE OF DELIVERY
// 16) ANESTHESIA
// 17) PRETERM DELIVERY
// 18) BIRTH TYPE
// 19) IEN;NUMBER;NAME;GENDER;BIRTH WEIGHT;STILLBORN;APGAR1;APGAR2;STATUS;NICU|
// 20) OUTCOME
// 21) HIGH RISK FLAG
// 22) DAYS IN HOSPITAL
Result := 'L^'; // ID (L)
Result := Result + PregID + U; // IEN (Replaced upstream if 0)
Result := Result + U; // DATE RECORDED
Result := Result + U; // EDC
Result := Result + U; // DFN| PATIENT (handled by routine)
// STATUS (this is Historical or Current and is handled by routine)
if (vPregInfo.lbStatus.Caption = 'CURRENT') or
(AnsiContainsText(vPregInfo.lbStatus.Caption, '(C)')) then
Result := Result + 'CURRENT^'
else
Result := Result + 'HISTORICAL^';
Result := Result + U; // FOF|(IEN OR IDENTIFIER)
Result := Result + U; // EDD
Result := Result + vPregInfo.dtDelivery.Text + U; // PREGNANCY END
Result := Result + U; // OB IEN|OB
Result := Result + '|' + vPregInfo.cbDeliveryPlace.Text + U; // FACILITY IEN|FACILITY
Result := Result + U; // UPDATED BY IEN|UPDATED BY
Result := Result + vPregInfo.spnGAWeeks.Text + 'W' + vPregInfo.spnGADays.Text + 'D^'; // GESTATIONAL AGE
Result := Result + vPregInfo.spnLaborLength.Text + U; // LENGTH OF LABOR
// TYPE OF DELIVERY
if vPregInfo.rgTypeDelivery.ItemIndex = 0 then
Result := Result + 'V^'
else if vPregInfo.rgTypeDelivery.ItemIndex = 1 then
Result := Result + 'C^'
else
Result := Result + U;
Result := Result + vPregInfo.cbAnesthesia.Text + U; // ANESTHESIA
Result := Result + IntToStr(vPregInfo.rgPretermDelivery.ItemIndex) + U; // PRETERM DELIVERY
Result := Result + U; // BIRTH TYPE
Result := Result + GetChildrenV + U; // IEN;NUMBER;NAME;GENDER;BIRTH WEIGHT;STILLBORN;APGAR1;APGAR2;STATUS;NICU|
Result := Result + vPregInfo.cbOutcome.Text + U; // OUTCOME
Result := Result + U; // HIGH RISK FLAG
Result := Result + vPregInfo.edtDeliveryAt.Text; // DAYS IN HOSPITAL
end;
end.
| 29.720109 | 144 | 0.621194 |
832d008947d06156db1838343ac568b151c446fc | 4,787 | pas | Pascal | tests/CountryCodeTest.pas | marvotron-lab/iban4pas | fc87b140078441dde2dc06adea704131870040a9 | [
"Apache-2.0"
]
| 2 | 2020-05-23T14:28:37.000Z | 2020-05-24T00:15:22.000Z | tests/CountryCodeTest.pas | bravesoftdz/iban4pas | fc87b140078441dde2dc06adea704131870040a9 | [
"Apache-2.0"
]
| null | null | null | tests/CountryCodeTest.pas | bravesoftdz/iban4pas | fc87b140078441dde2dc06adea704131870040a9 | [
"Apache-2.0"
]
| 2 | 2020-05-23T22:49:25.000Z | 2020-05-24T00:15:22.000Z | {*
* Copyright 2013 Artur Mkrtchyan
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
Pascal port Copyright 2020 yonojoy@gmail.com
}
unit CountryCodeTest;
interface
uses
System.SysUtils,
TestFrameWork,
BaseTestCase,
Iban4Pas.CountryCode;
type
TCountryCodeTest = class(TBaseTestCase)
published
procedure getAlpha2WithDECodeShouldReturnGermany;
procedure getAlpha3WithDECodeShouldReturnGermany;
procedure getByCodeWith4DigitCodeShouldReturnUnknown;
procedure getByCodeWithAlpha2CodeShouldReturnCountry;
procedure getByCodeWithAlpha3CodeShouldReturnCountryCode;
procedure getByCodeWithLowerCaseAlpha2CodeShouldReturnCountry;
procedure getByCodeWithLowerCaseAlpha3CodeShouldReturnCountry;
procedure getByCodeWithNullCodeShouldReturnUnknown;
procedure getByCodeWithUpperCaseAlpha2CodeShouldReturnCountry;
procedure getByCodeWithUpperCaseAlpha3CodeShouldReturnCountry;
procedure getByCodeWithWrongAlpha2CodeShouldReturnUnknown;
procedure getByCodeWithWrongAlpha3CodeShouldReturnUnknown;
procedure getNameWithDECodeShouldReturnGermany;
end;
implementation
procedure TCountryCodeTest.getByCodeWithAlpha2CodeShouldReturnCountry();
var
code: TCountryCode;
newCode: TCountryCode;
begin
for code in TCountryCode.values() do
begin
newCode := TCountryCode.getByCode(code.getAlpha2());
Check(newCode = code);
end;
end;
procedure TCountryCodeTest.getByCodeWithLowerCaseAlpha2CodeShouldReturnCountry();
var
code: TCountryCode;
newCode: TCountryCode;
begin
for code in TCountryCode.values() do
begin
newCode := TCountryCode.getByCode(code.getAlpha2().toLower());
Check(newCode = code);
end;
end;
procedure TCountryCodeTest.getByCodeWithUpperCaseAlpha2CodeShouldReturnCountry();
var
code: TCountryCode;
newCode: TCountryCode;
begin
for code in TCountryCode.values() do
begin
newCode := TCountryCode.getByCode(code.getAlpha2().toUpper());
Check(newCode = code);
end;
end;
procedure TCountryCodeTest.getByCodeWithAlpha3CodeShouldReturnCountryCode();
var
code: TCountryCode;
newCode: TCountryCode;
begin
for code in TCountryCode.values() do
begin
newCode := TCountryCode.getByCode(code.getAlpha3());
Check(newCode = code);
end;
end;
procedure TCountryCodeTest.getByCodeWithLowerCaseAlpha3CodeShouldReturnCountry();
var
code: TCountryCode;
newCode: TCountryCode;
begin
for code in TCountryCode.values() do
begin
newCode := TCountryCode.getByCode(code.getAlpha3().toLower());
Check(newCode = code);
end;
end;
procedure TCountryCodeTest.getByCodeWithUpperCaseAlpha3CodeShouldReturnCountry();
var
code: TCountryCode;
newCode: TCountryCode;
begin
for code in TCountryCode.values() do
begin
newCode := TCountryCode.getByCode(code.getAlpha3().toUpper());
Check(newCode = code);
end;
end;
procedure TCountryCodeTest.getByCodeWithNullCodeShouldReturnUnknown();
var
code: TCountryCode;
begin
code := TCountryCode.getByCode('');
Check(code = TCountryCode.UNKNOWN);
end;
procedure TCountryCodeTest.getByCodeWith4DigitCodeShouldReturnUnknown();
var
code: TCountryCode;
begin
code := TCountryCode.getByCode('XXXX');
Check(code = TCountryCode.UNKNOWN);
end;
procedure TCountryCodeTest.getByCodeWithWrongAlpha2CodeShouldReturnUnknown();
var
code: TCountryCode;
begin
code := TCountryCode.getByCode('XX');
Check(code = TCountryCode.UNKNOWN);
end;
procedure TCountryCodeTest.getByCodeWithWrongAlpha3CodeShouldReturnUnknown();
var
code: TCountryCode;
begin
code := TCountryCode.getByCode('XXX');
Check(code = TCountryCode.UNKNOWN);
end;
procedure TCountryCodeTest.getNameWithDECodeShouldReturnGermany();
begin
Check(TCountryCode.DE.getName() = 'Germany');
end;
procedure TCountryCodeTest.getAlpha2WithDECodeShouldReturnGermany();
begin
Check(TCountryCode.DE.getAlpha2() = 'DE');
end;
procedure TCountryCodeTest.getAlpha3WithDECodeShouldReturnGermany();
begin
Check(TCountryCode.DE.getAlpha3() = 'DEU');
end;
initialization
RegisterTest(TCountryCodeTest.Suite);
end. | 26.016304 | 81 | 0.752455 |
47c72fc0c07a6646a211f813eb18b15b5d362097 | 109,895 | pas | Pascal | 10.2.2/FMX.Platform.Android.pas | jfhyn/fmxfixes | 65c04a92d39991ad55fdd2878f40a7f1def8ee84 | [
"MIT"
]
| null | null | null | 10.2.2/FMX.Platform.Android.pas | jfhyn/fmxfixes | 65c04a92d39991ad55fdd2878f40a7f1def8ee84 | [
"MIT"
]
| null | null | null | 10.2.2/FMX.Platform.Android.pas | jfhyn/fmxfixes | 65c04a92d39991ad55fdd2878f40a7f1def8ee84 | [
"MIT"
]
| 1 | 2019-05-19T11:53:50.000Z | 2019-05-19T11:53:50.000Z | {*******************************************************}
{ }
{ Delphi FireMonkey Platform }
{ }
{ Copyright(c) 2011-2017 Embarcadero Technologies, Inc. }
{ All rights reserved }
{ }
{*******************************************************}
unit FMX.Platform.Android;
interface
{$SCOPEDENUMS ON}
uses
System.Types, System.UITypes, System.Messaging, Androidapi.JNI.Embarcadero, FMX.Forms, FMX.Types, FMX.Types3D;
type
TAndroidWindowHandle = class(TWindowHandle)
strict private
FTexture: TTexture;
FBounds: TRectF;
[Weak] FForm: TCommonCustomForm;
FNeedsUpdate: Boolean;
private
procedure SetBounds(const Value: TRectF);
procedure SetNeedsUpdate(const Value: Boolean);
function GetIsPopup: Boolean;
function GetBounds: TRectF;
protected
function GetScale: Single; override;
public
constructor Create(const AForm: TCommonCustomForm);
procedure CreateTexture;
procedure DestroyTexture;
function RequiresComposition: Boolean;
property Bounds: TRectF read GetBounds write SetBounds;
property Form: TCommonCustomForm read FForm;
property Texture: TTexture read FTexture;
property NeedsUpdate: Boolean read FNeedsUpdate write SetNeedsUpdate;
property IsPopup: Boolean read GetIsPopup;
end;
{ Broadcast messages: Taking images }
TMessageCancelReceivingImage = class(TMessage<Integer>);
TMessageReceivedImagePath = class(TMessage<string>)
public
RequestCode: Integer;
end;
function WindowHandleToPlatform(const AHandle: TWindowHandle): TAndroidWindowHandle;
function MainActivity: JFMXNativeActivity;
function ConvertPixelToPoint(const P: TPointF): TPointF;
function ConvertPointToPixel(const P: TPointF): TPointF;
procedure RegisterCorePlatformServices;
procedure UnregisterCorePlatformServices;
implementation
uses
System.Classes, System.SysUtils, System.Math, System.Math.Vectors, System.Generics.Collections, System.Character,
System.RTLConsts, System.Devices, System.Rtti, System.UIConsts,
Androidapi.Input, Androidapi.Jni.JavaTypes, Androidapi.Egl, Androidapi.Gles2, Androidapi.JNI.Widget, Androidapi.Keycodes,
Androidapi.NativeWindow, Androidapi.NativeActivity, Androidapi.AppGlue, Androidapi.JNIBridge, Androidapi.Helpers,
Androidapi.JNI.GraphicsContentViewText, Androidapi.JNI.App, Androidapi.JNI.Os,
FMX.KeyMapping, FMX.Helpers.Android, FMX.Canvas.GPU, FMX.Controls, FMX.Controls.Android, FMX.Materials.Canvas,
FMX.Gestures, FMX.VirtualKeyboard, FMX.Consts, FMX.Text, FMX.Graphics, FMX.TextLayout, FMX.Maps, FMX.Platform,
FMX.Presentation.Style, FMX.Ani, FMX.Context.GLES.Android, FMX.Graphics.Android,
FMX.MultiTouch.Android, FMX.VirtualKeyboard.Android, FMX.Gestures.Android, FMX.Dialogs.Android,
FMX.Platform.Timer.Android, FMX.Platform.Device.Android, FMX.Platform.Logger.Android, FMX.Platform.SaveState.Android,
FMX.Platform.Screen.Android, FMX.Platform.Metrics.Android;
type
TFMXNativeActivityListener = class (TJavaLocal, JOnActivityListener)
public
procedure onCancelReceiveImage(ARequestCode: Integer); cdecl;
procedure onReceiveImagePath(ARequestCode: Integer; AFileName: JString); cdecl;
procedure onReceiveNotification(P1: JIntent); cdecl;
procedure onReceiveResult(ARequestCode, AResultCode: Integer; AResultObject: JIntent); cdecl;
end;
TCopyButtonClickListener = class(TJavaLocal, JView_OnClickListener)
public
procedure onClick(P1: JView); cdecl;
end;
TCutButtonClickListener = class(TJavaLocal, JView_OnClickListener)
public
procedure onClick(P1: JView); cdecl;
end;
TPasteButtonClickListener = class(TJavaLocal, JView_OnClickListener)
public
procedure onClick(P1: JView); cdecl;
end;
TTextServiceAndroid = class;
TWindowManager = class(TInterfacedObject, IFreeNotification, IFMXWindowService)
public const
HidePasteMenuDelay = 2500;
public type
TContextMenuItem = (Copy, Cut, Paste);
TContextMenuItems = set of TContextMenuItem;
public const
AllContextMenuItems = [TContextMenuItem.Copy, TContextMenuItem.Cut, TContextMenuItem.Paste];
private type
TRenderRunnable = class(TJavaLocal, JRunnable)
private class var
[weak] FManager: TWindowManager;
FMainHandler: JHandler;
private
class function GetMainHandler: JHandler; static;
public
constructor Create(const AManager: TWindowManager);
procedure run; cdecl;
class property MainHandler: JHandler read GetMainHandler;
end;
private class var
FRenderRunnable: TRenderRunnable;
private
class var FInstance: TWindowManager;
class function GetInstance: TWindowManager; static;
private
FRenderLock: TObject;
FTimerService: IFMXTimerService;
FVirtualKeyboard: IFMXVirtualKeyboardService;
FWindows: TList<TAndroidWindowHandle>;
FVisibleStack: TStack<TAndroidWindowHandle>;
[Weak] FGestureControl: TComponent;
[Weak] FMouseDownControl: TControl;
FNeedsRender: Boolean;
FPause: Boolean;
FScale: Single;
FContentRect: TRect;
FStatusBarHeight: Integer;
//Text editing
FFocusedControl: IControl;
FContextMenuPopup: JPopupWindow;
FContextMenuPopupSize: TSize;
FContextMenuLayout: JLinearLayout;
FContextButtonsLayout: JLinearLayout;
FCopyButton: JButton;
FCopyClickListener: TCopyButtonClickListener;
FCutButton: JButton;
FCutClickListener: TCutButtonClickListener;
FPasteButton: JButton;
FPasteClickListener: TPasteButtonClickListener;
FContextMenuVisible: Boolean;
[Weak] FCapturedWindow: TAndroidWindowHandle;
FSelectionInProgress: Boolean;
FPasteMenuTimer: TFmxHandle;
FMultiTouchManager: TMultiTouchManagerAndroid;
FContext: TContext3D;
FIsFirstSingleTap: Boolean;
procedure SetContentRect(const Value: TRect);
procedure SetPause(const Value: Boolean);
function GetMultiTouchManager: TMultiTouchManagerAndroid;
procedure UpdateFormSizes;
procedure ShowContextMenu(const ItemsToShow: TContextMenuItems = AllContextMenuItems);
procedure DoShowContextMenu;
procedure VKStateHandler(const Sender: TObject; const M: TMessage);
procedure HideContextMenu;
{ Context Menu }
procedure CreatePasteMenuTimer;
procedure DestroyPasteMenuTimer;
procedure PasteMenuTimerCall;
{ Popup }
procedure PrepareClosePopups(const SaveForm: TAndroidWindowHandle);
procedure ClosePopups;
{ Rendering }
procedure PostRenderRunnable;
procedure ReleaseRenderRunnable;
{ IFreeNotification }
procedure FreeNotification(AObject: TObject);
public
constructor Create;
destructor Destroy; override;
function IsPopupForm(const AForm: TCommonCustomForm): Boolean;
procedure InitWindow;
procedure TermWindow;
procedure GainedFocus;
{ IFMXWindowService }
function FindForm(const AHandle: TWindowHandle): TCommonCustomForm;
function CreateWindow(const AForm: TCommonCustomForm): TWindowHandle;
procedure DestroyWindow(const AForm: TCommonCustomForm);
procedure ReleaseWindow(const AForm: TCommonCustomForm);
procedure ShowWindow(const AForm: TCommonCustomForm);
procedure HideWindow(const AForm: TCommonCustomForm);
procedure BringToFront(const AForm: TCommonCustomForm); overload;
procedure SendToBack(const AForm: TCommonCustomForm); overload;
procedure Activate(const AForm: TCommonCustomForm);
function ShowWindowModal(const AForm: TCommonCustomForm): TModalResult;
function CanShowModal: Boolean;
procedure InvalidateWindowRect(const AForm: TCommonCustomForm; R: TRectF);
procedure InvalidateImmediately(const AForm: TCommonCustomForm);
procedure SetWindowRect(const AForm: TCommonCustomForm; ARect: TRectF);
function GetWindowRect(const AForm: TCommonCustomForm): TRectF;
function GetClientSize(const AForm: TCommonCustomForm): TPointF;
procedure SetClientSize(const AForm: TCommonCustomForm; const ASize: TPointF);
procedure SetWindowCaption(const AForm: TCommonCustomForm; const ACaption: string);
procedure SetCapture(const AForm: TCommonCustomForm);
procedure SetWindowState(const AForm: TCommonCustomForm; const AState: TWindowState);
procedure ReleaseCapture(const AForm: TCommonCustomForm);
function ClientToScreen(const AForm: TCommonCustomForm; const Point: TPointF): TPointF;
function ScreenToClient(const AForm: TCommonCustomForm; const Point: TPointF): TPointF; overload;
function GetWindowScale(const AForm: TCommonCustomForm): Single;
procedure BeginSelection;
procedure EndSelection;
procedure SetNeedsRender;
function RenderIfNeeds: Boolean;
procedure RenderImmediately;
procedure Render;
procedure BringToFront(const AHandle: TAndroidWindowHandle); overload;
procedure SendToBack(const AHandle: TAndroidWindowHandle); overload;
procedure AddWindow(const AHandle: TAndroidWindowHandle);
procedure RemoveWindow(const AHandle: TAndroidWindowHandle);
function AlignToPixel(const Value: Single): Single; inline;
function FindWindowByPoint(X, Y: Single): TAndroidWindowHandle;
function FindTopWindow: TAndroidWindowHandle;
function FindTopWindowForTextInput: TAndroidWindowHandle;
function SendCMGestureMessage(AEventInfo: TGestureEventInfo): Boolean;
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Single);
procedure MouseMove(Shift: TShiftState; X, Y: Single);
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Single; DoCLick: Boolean = True);
procedure KeyDown(var Key: Word; var KeyChar: System.WideChar; Shift: TShiftState);
procedure KeyUp(var Key: Word; var KeyChar: System.WideChar; Shift: TShiftState; KeyDownHandled: Boolean);
procedure MultiTouch(const Touches: TTouches; const Action: TTouchAction; const AEnabledGestures: TInteractiveGestures = []);
function PixelToPoint(const P: TPointF): TPointF;
function PointToPixel(const P: TPointF): TPointF;
function ScreenToClient(const Handle: TAndroidWindowHandle; const Point: TPointF): TPointF; overload;
procedure SingleTap;
function TextGetService: TTextServiceAndroid;
function TextGetActions: ITextActions;
procedure TextResetSelection;
function TextReadOnly: Boolean;
procedure SetFocusedControl(const Control: IControl);
public
property ContentRect: TRect read FContentRect write SetContentRect;
property Windows: TList<TAndroidWindowHandle> read FWindows;
property Pause: Boolean read FPause write SetPause;
property Scale: Single read FScale;
property StatusBarHeight: Integer read FStatusBarHeight;
property MultiTouchManager: TMultiTouchManagerAndroid read GetMultiTouchManager;
class property Current: TWindowManager read GetInstance;
end;
TAndroidMotionManager = class(TInterfacedObject, IFMXGestureRecognizersService, IFMXMouseService)
private const
DblTapDelay = 300; //delay between the 2 taps
SingleTapDelay = 150;
LongTapDuration = 500;
LongTapMovement = 10; //10 pixels - use scale to transform to points to use on each device
private type
TMotionEvent = record
Position: TPointF;
EventAction: Int32;
Shift: TShiftState;
end;
TMotionEvents = TList<TMotionEvent>;
private
{ Gestures }
FActiveInteractiveGestures: TInteractiveGestures;
FEnabledInteractiveGestures: TInteractiveGestures;
FMotionEvents: TMotionEvents;
FDoubleTapTimer: TFmxHandle;
FLongTapTimer: TFmxHandle;
FSingleTapTimer: TFmxHandle;
FDblClickFirstMouseUp: Boolean;
FSingleTap: Boolean;
FOldPoint1, FOldPoint2: TPointF;
FRotationAngle: Single;
FGestureEnded: Boolean;
{ Mouse }
FMouseCoord: TPointF;
FMouseDownCoordinates: TPointF;
{ Single Tap }
procedure SingleTap;
procedure CreateSingleTapTimer;
procedure DestroySingleTapTimer;
procedure SingleTapTimerCall;
{ Double Tap }
procedure CreateDoubleTapTimer;
procedure DestroyDoubleTapTimer;
procedure DoubleTapTimerCall;
{ Long Tap }
procedure CreateLongTapTimer;
procedure DestroyLongTapTimer;
procedure LongTapTimerCall;
function GetLongTapAllowedMovement: Single;
procedure HandleMultiTouch;
protected
function HandleAndroidMotionEvent(AEvent: PAInputEvent): Int32;
function CreateGestureEventInfo(ASecondPointer: TPointF; const AGesture: TInteractiveGesture; const AGestureEnded: Boolean = False): TGestureEventInfo;
public
constructor Create;
destructor Destroy; override;
procedure ProcessAndroidGestureEvents;
procedure ProcessAndroidMouseEvents;
{ IFMXGestureRecognizersService }
procedure AddRecognizer(const AGesture: TInteractiveGesture; const AForm: TCommonCustomForm);
procedure RemoveRecognizer(const AGesture: TInteractiveGesture; const AForm: TCommonCustomForm);
{ IFMXMouseService }
function GetMousePos: TPointF;
end;
TAndroidTextInputManager = class(TInterfacedObject, IFMXKeyMappingService, IFMXTextService)
private
FVirtualKeyboard: IFMXVirtualKeyboardService;
FKeyMapping: TKeyMapping;
FSkipEventQueue: TQueue<JKeyEvent>;
FKeyCharacterMap: JKeyCharacterMap;
FDownKey: Word;
FDownKeyChar: System.WideChar;
FKeyDownHandled: Boolean;
FTextEditorProxy: JFMXTextEditorProxy;
procedure SetKeyboardEventToSkip(event: JKeyEvent);
function ObtainKeyCharacterMap(DeviceId: Integer): JKeyCharacterMap;
function ShiftStateFromMetaState(const AMetaState: Integer): TShiftState;
protected
function HandleAndroidKeyEvent(AEvent: PAInputEvent): Int32;
public
constructor Create;
destructor Destroy; override;
{ Android view for IME }
function GetTextEditorProxy: JFmxTextEditorProxy;
{ IFMXTextService }
function GetTextServiceClass: TTextServiceClass;
{ IFMXKeyMappingService }
/// <summary>Registers a platform key as the given virtual key.</summary>
function RegisterKeyMapping(const PlatformKey, VirtualKey: Word; const KeyKind: TKeyKind): Boolean;
/// <summary>Unegisters a platform key as the given virtual key.</summary>
function UnregisterKeyMapping(const PlatformKey: Word): Boolean;
/// <summary>Obtains the virtual key from a given platform key.</summary>
function PlatformKeyToVirtualKey(const PlatformKey: Word; var KeyKind: TKeyKind): Word;
/// <summary>Obtains the platform key from a given virtual key.</summary>
function VirtualKeyToPlatformKey(const VirtualKey: Word): Word;
end;
{ TPlatformAndroid }
TWakeMainThreadRunnable = class(TJavaLocal, JRunnable)
public
{ JRunnable }
procedure run; cdecl;
end;
TPlatformAndroid = class(TInterfacedObject, IFMXApplicationEventService, IFMXApplicationService)
private const
UndefinedOrientation = TScreenOrientation(-1);
private type
TMessageQueueIdleHandler = class(TJavaLocal, JMessageQueue_IdleHandler)
private
[Weak] FPlatform: TPlatformAndroid;
public
constructor Create(APlatform: TPlatformAndroid);
function queueIdle: Boolean; cdecl;
end;
private
{ Core services }
FTimerService: TAndroidTimerService;
FDeviceServices: TAndroidDeviceServices;
FLoggerService: TAndroidLoggerService;
FSaveStateService: TAndroidSaveStateService;
FScreenServices: TAndroidScreenServices;
FGraphicServices: TAndroidGraphicsServices;
FMetricsServices: TAndroidMetricsServices;
FVirtualKeyboardService: TVirtualKeyboardAndroid;
FWindowManager: TWindowManager;
FMotionManager: TAndroidMotionManager;
FTextInputManager: TAndroidTextInputManager;
{ Internal }
FIdleHandler: TMessageQueueIdleHandler;
FWakeMainThreadRunnable: TWakeMainThreadRunnable;
FOnApplicationEvent: TApplicationEventHandler;
FActivityListener: TFMXNativeActivityListener;
FFirstRun: Boolean;
FLastOrientation: TScreenOrientation;
FRunning: Boolean;
FTerminating: Boolean;
FPreviousActivityCommands: TAndroidApplicationCommands;
FTitle: string;
procedure InternalProcessMessages;
procedure CheckOrientationChange;
procedure RegisterWakeMainThread;
procedure UnregisterWakeMainThread;
procedure WakeMainThread(Sender: TObject);
procedure RegisterServices;
procedure UnregisterServices;
procedure BindAppGlueEvents;
procedure UnbindAppGlueEvents;
protected
function HandleAndroidInputEvent(const App: TAndroidApplicationGlue; const AEvent: PAInputEvent): Int32;
procedure HandleApplicationCommandEvent(const App: TAndroidApplicationGlue; const ACommand: TAndroidApplicationCommand);
procedure HandleContentRectChanged(const App: TAndroidApplicationGlue; const ARect: TRect);
public
constructor Create;
destructor Destroy; override;
{ IFMXApplicationService }
procedure Run;
function HandleMessage: Boolean;
procedure WaitMessage;
function GetDefaultTitle: string;
function GetTitle: string;
procedure SetTitle(const Value: string);
function GetVersionString: string;
function Running: Boolean;
function Terminating: Boolean;
procedure Terminate;
{ IFMXApplicationEventService }
procedure SetApplicationEventHandler(AEventHandler: TApplicationEventHandler);
function HandleApplicationEvent(AEvent: TApplicationEvent): Boolean;
public
property DeviceManager: TAndroidDeviceServices read FDeviceServices;
property Logger: TAndroidLoggerService read FLoggerService;
property Metrics: TAndroidMetricsServices read FMetricsServices;
property MotionManager: TAndroidMotionManager read FMotionManager;
property SaveStateManager: TAndroidSaveStateService read FSaveStateService;
property ScreenManager: TAndroidScreenServices read FScreenServices;
property TextInputManager: TAndroidTextInputManager read FTextInputManager;
property TimerManager: TAndroidTimerService read FTimerService;
property VirtualKeyboard: TVirtualKeyboardAndroid read FVirtualKeyboardService;
property WindowManager: TWindowManager read FWindowManager;
end;
TFMXTextListener = class(TJavaLocal, JFMXTextListener)
strict private
[Weak] FTextService: TTextServiceAndroid;
public
constructor Create(const TextService: TTextServiceAndroid); overload;
{ JFMXTextListener }
procedure onTextUpdated(text: JCharSequence; position: Integer); cdecl;
procedure onComposingText(beginPosition: Integer; endPosition: Integer); cdecl;
procedure onSkipKeyEvent(event: JKeyEvent); cdecl;
end;
TTextServiceAndroid = class(TTextService)
private
FCaretPosition: TPoint;
FText : string;
FImeMode: TImeMode;
FTextView: JFmxTextEditorProxy;
FTextListener: TFMXTextListener;
FComposingBegin: Integer;
FComposingEnd: Integer;
FLines: TStrings;
FInternalUpdate: Boolean;
procedure UnpackText;
procedure CalculateSelectionBounds(out SelectionStart, SelectionEnd: Integer);
procedure HandleVK(const Sender: TObject; const M: TMessage);
function IsFocused: Boolean;
protected
function GetText: string; override;
procedure SetText(const Value: string); override;
function GetCaretPostion: TPoint; override;
procedure SetCaretPosition(const Value: TPoint); override;
procedure SetMaxLength(const Value: Integer); override;
procedure SetCharCase(const Value: TEditCharCase); override;
procedure SetFilterChar(const Value: string); override;
public
procedure InternalUpdate;
procedure InternalUpdateSelection;
function CombinedText: string; override;
function TargetClausePosition: TPoint; override;
procedure EnterControl(const FormHandle: TWindowHandle); override;
procedure ExitControl(const FormHandle: TWindowHandle); override;
procedure DrawSingleLine(const Canvas: TCanvas;
const ARect: TRectF; const FirstVisibleChar: integer; const Font: TFont;
const AOpacity: Single; const Flags: TFillTextFlags; const ATextAlign: TTextAlign;
const AVTextAlign: TTextAlign = TTextAlign.Center;
const AWordWrap: Boolean = False); overload; override;
procedure DrawSingleLine(const Canvas: TCanvas;
const S: string;
const ARect: TRectF;
const Font: TFont;
const AOpacity: Single; const Flags: TFillTextFlags; const ATextAlign: TTextAlign;
const AVTextAlign: TTextAlign = TTextAlign.Center;
const AWordWrap: Boolean = False); overload; override;
function HasMarkedText: Boolean; override;
function GetImeMode: TImeMode; override;
procedure SetImeMode(const Value: TImeMode); override;
{ Selection }
procedure BeginSelection; override;
procedure EndSelection; override;
procedure ProcessUpdate(const APos: Integer; AText: string);
procedure PostProcessUpdate;
public
constructor Create(const Owner: IControl; SupportMultiLine: Boolean); override;
destructor Destroy; override;
procedure CutSelectedText;
procedure CopySelectedText;
procedure PasteText;
end;
var
PlatformAndroid: TPlatformAndroid;
function WindowHandleToPlatform(const AHandle: TWindowHandle): TAndroidWindowHandle;
begin
Result := TAndroidWindowHandle(AHandle);
end;
function MainActivity: JFMXNativeActivity;
begin
if TAndroidApplicationGlue.Current <> nil then
Result := TJFMXNativeActivity.Wrap(TAndroidApplicationGlue.Current.NativeActivity.clazz)
else
Result := nil;
end;
procedure RegisterCorePlatformServices;
begin
PlatformAndroid := TPlatformAndroid.Create;
end;
procedure UnregisterCorePlatformServices;
begin
FreeAndNil(PlatformAndroid);
end;
{ TCopyButtonClickListener }
procedure TCopyButtonClickListener.onClick(P1: JView);
var
TextService: TTextServiceAndroid;
begin
TextService := TWindowManager.Current.TextGetService;
if TextService <> nil then
TextService.CopySelectedText;
TWindowManager.Current.TextResetSelection;
TWindowManager.Current.HideContextMenu;
end;
{ TCutButtonClickListener }
procedure TCutButtonClickListener.onClick(P1: JView);
var
TextService: TTextServiceAndroid;
begin
TextService := TWindowManager.Current.TextGetService;
if (TextService <> nil) and not TWindowManager.Current.TextReadOnly then
TextService.CutSelectedText;
TWindowManager.Current.TextResetSelection;
TWindowManager.Current.HideContextMenu;
end;
{ TPasteButtonClickListener }
procedure TPasteButtonClickListener.onClick(P1: JView);
var
TextService: TTextServiceAndroid;
begin
TextService := TWindowManager.Current.TextGetService;
if (TextService <> nil) and not TWindowManager.Current.TextReadOnly then
TextService.PasteText;
TWindowManager.Current.TextResetSelection;
TWindowManager.Current.HideContextMenu;
end;
{ TWindowManager.TRenderRunnable }
constructor TWindowManager.TRenderRunnable.Create;
begin
inherited Create;
FManager := AManager;
MainHandler.post(Self);
end;
class function TWindowManager.TRenderRunnable.GetMainHandler: JHandler;
begin
if FMainHandler = nil then
FMainHandler := TJHandler.JavaClass.init(TJLooper.JavaClass.getMainLooper);
Result := FMainHandler;
end;
procedure TWindowManager.TRenderRunnable.run;
begin
FManager.RenderIfNeeds;
FManager.ReleaseRenderRunnable;
end;
{ TWindowManager }
constructor TWindowManager.Create;
var
ScreenService: IFMXScreenService;
begin
inherited Create;
FRenderLock := TObject.Create;
FWindows := TList<TAndroidWindowHandle>.Create;
FVisibleStack := TStack<TAndroidWindowHandle>.Create;
if TPlatformServices.Current.SupportsPlatformService(IFMXScreenService, ScreenService) then
FScale := ScreenService.GetScreenScale
else
raise Exception.Create('Correct working of window manager requires IFMXScreenService.');
TMessageManager.DefaultManager.SubscribeToMessage(TVKStateChangeMessage, VKStateHandler);
if not TPlatformServices.Current.SupportsPlatformService(IFMXTimerService, FTimerService) then
raise Exception.Create('Correct working of window manager requires IFMXTimerService.');
TPlatformServices.Current.SupportsPlatformService(IFMXVirtualKeyboardService, FVirtualKeyboard);
end;
procedure TWindowManager.CreatePasteMenuTimer;
begin
if FPasteMenuTimer = 0 then
FPasteMenuTimer := FTimerService.CreateTimer(HidePasteMenuDelay, PasteMenuTimerCall);
end;
function TWindowManager.CreateWindow(const AForm: TCommonCustomForm): TWindowHandle;
begin
Result := nil;
if (AForm.Handle <> nil) and Windows.Contains(TAndroidWindowHandle(AForm.Handle)) then
raise Exception.Create('Window already exists.');
Result := TAndroidWindowHandle.Create(AForm);
AddWindow(TAndroidWindowHandle(Result));
if not IsPopupForm(AForm) then
TAndroidWindowHandle(Result).Bounds := TRectF.Create(ContentRect);
end;
destructor TWindowManager.Destroy;
begin
TMessageManager.DefaultManager.Unsubscribe(TVKStateChangeMessage, VKStateHandler);
FVirtualKeyboard := nil;
FVisibleStack.DisposeOf;
FWindows.DisposeOf;
SetFocusedControl(nil);
FContextMenuPopup := nil;
FContextMenuLayout := nil;
FContextButtonsLayout := nil;
FCopyButton := nil;
FCopyClickListener := nil;
FCutButton := nil;
FCutClickListener := nil;
FPasteButton := nil;
FPasteClickListener := nil;
FMouseDownControl := nil;
FreeAndNil(FMultiTouchManager);
inherited;
end;
procedure TWindowManager.DestroyPasteMenuTimer;
begin
if FPasteMenuTimer <> 0 then
begin
FTimerService.DestroyTimer(FPasteMenuTimer);
FPasteMenuTimer := 0;
end;
end;
procedure TWindowManager.DestroyWindow(const AForm: TCommonCustomForm);
begin
if (AForm.Handle <> nil) and Windows.Contains(TAndroidWindowHandle(AForm.Handle)) then
Windows.Remove(TAndroidWindowHandle(AForm.Handle));
end;
procedure TWindowManager.EndSelection;
begin
FSelectionInProgress := False;
end;
procedure TWindowManager.BeginSelection;
begin
FSelectionInProgress := True;
end;
procedure TWindowManager.Activate(const AForm: TCommonCustomForm);
var
MapManager: IFMXMapService;
begin
if TPlatformServices.Current.SupportsPlatformService(IFMXMapService, MapManager) then
MapManager.RealignMapViews;
end;
procedure TWindowManager.BringToFront(const AForm: TCommonCustomForm);
begin
if AForm.Handle <> nil then
BringToFront(TAndroidWindowHandle(AForm.Handle));
end;
procedure TWindowManager.AddWindow(const AHandle: TAndroidWindowHandle);
begin
FWindows.Add(AHandle);
end;
procedure TWindowManager.BringToFront(const AHandle: TAndroidWindowHandle);
begin
if FWindows.Contains(AHandle) then
begin
FWindows.Remove(AHandle);
FWindows.Add(AHandle);
if (FVisibleStack.Count = 0) or (FVisibleStack.Peek <> AHandle) then
FVisibleStack.Push(AHandle);
SetNeedsRender;
end;
end;
function TWindowManager.ScreenToClient(const Handle: TAndroidWindowHandle; const Point: TPointF): TPointF;
begin
if Handle <> nil then
Result := Point - Handle.Bounds.TopLeft
else
Result := Point;
end;
function TWindowManager.ScreenToClient(const AForm: TCommonCustomForm; const Point: TPointF): TPointF;
begin
Result := ScreenToClient(TAndroidWindowHandle(AForm.Handle), Point);
end;
function TWindowManager.SendCMGestureMessage(AEventInfo: TGestureEventInfo): Boolean;
var
Window: TAndroidWindowHandle;
Obj, LFocusedControl: IControl;
OldGestureControl: TComponent;
TmpControl: TFmxObject;
GObj: IGestureControl;
ClientEventInfo: TGestureEventInfo;
TextInput: ITextInput;
TextActions: ITextActions;
const
LGestureMap: array [igiZoom .. igiDoubleTap] of TInteractiveGesture =
(TInteractiveGesture.Zoom, TInteractiveGesture.Pan,
TInteractiveGesture.Rotate, TInteractiveGesture.TwoFingerTap,
TInteractiveGesture.PressAndtap, TInteractiveGesture.LongTap,
TInteractiveGesture.DoubleTap);
begin
Result := False;
OldGestureControl := nil;
Window := FindWindowByPoint(AEventInfo.Location.X, AEventInfo.Location.Y);
if Window <> nil then
begin
if TInteractiveGestureFlag.gfBegin in AEventInfo.Flags then
begin
// find the control from under the gesture
Obj := Window.Form.ObjectAtPoint(AEventInfo.Location);
if FGestureControl <> nil then
OldGestureControl := FGestureControl;
if Obj <> nil then
FGestureControl := Obj.GetObject
else
FGestureControl := Window.Form;
if Supports(FGestureControl, IGestureControl, GObj) then
FGestureControl := GObj.GetFirstControlWithGesture(LGestureMap[AEventInfo.GestureID])
else
FGestureControl := nil;
end;
if not FSelectionInProgress then
if Window.Form.Focused <> nil then
begin
LFocusedControl := Window.Form.Focused;
if LFocusedControl is TStyledPresentation then
LFocusedControl := TStyledPresentation(LFocusedControl).PresentedControl;
if Window.Form.Focused <> LFocusedControl then
SetFocusedControl(LFocusedControl);
end
else if FFocusedControl <> nil then
SetFocusedControl(nil);
if FGestureControl <> nil then
begin
if Supports(FGestureControl, IGestureControl, GObj) then
try
ClientEventInfo := AEventInfo;
ClientEventInfo.Location := Window.Form.ScreenToClient(ClientEventInfo.Location);
GObj.CMGesture(ClientEventInfo);
except
Application.HandleException(FGestureControl);
end;
if not FSelectionInProgress then
begin
Obj := Window.Form.ObjectAtPoint(AEventInfo.Location);
if Obj <> nil then
TmpControl := Obj.GetObject
else
TmpControl := Window.Form;
if TmpControl is TStyledPresentation then
TmpControl := TStyledPresentation(TmpControl).PresentedControl;
if (AEventInfo.GestureID = igiLongTap) and Supports(TmpControl, ITextInput, TextInput) and
Supports(TmpControl, ITextActions, TextActions) then
begin
TextActions.SelectWord;
TTextServiceAndroid(TextInput.GetTextService).InternalUpdateSelection;
ShowContextMenu;
end;
if AEventInfo.GestureID = igiDoubleTap then
begin
while (TmpControl <> nil) and
not (Supports(TmpControl, ITextInput, TextInput) and Supports(TmpControl, ITextActions, TextActions)) do
TmpControl := TmpControl.Parent;
if (TextInput <> nil) and (TextActions <> nil) then
begin
TTextServiceAndroid(TextInput.GetTextService).InternalUpdateSelection;
if not TextInput.GetSelection.IsEmpty then
ShowContextMenu;
end;
end;
end;
Result := True;
end
else
FGestureControl := OldGestureControl;
end;
if TInteractiveGestureFlag.gfEnd in AEventInfo.Flags then
FGestureControl := nil;
end;
procedure TWindowManager.SendToBack(const AForm: TCommonCustomForm);
begin
if AForm.Handle <> nil then
SendToBack(TAndroidWindowHandle(AForm.Handle));
end;
procedure TWindowManager.SendToBack(const AHandle: TAndroidWindowHandle);
begin
if FWindows.Contains(AHandle) then
begin
FWindows.Remove(AHandle);
FWindows.Insert(0, AHandle);
SetNeedsRender;
end;
end;
function TWindowManager.FindForm(const AHandle: TWindowHandle): TCommonCustomForm;
begin
Result := nil;
if FWindows.Contains(TAndroidWindowHandle(AHandle)) then
Result := FWindows[FWindows.IndexOf(TAndroidWindowHandle(AHandle))].Form;
end;
function TWindowManager.FindTopWindow: TAndroidWindowHandle;
var
I: Integer;
begin
for I := FWindows.Count - 1 downto 0 do
if FWindows[I].Form.Visible then
Exit(FWindows[I]);
Result := nil;
end;
function TWindowManager.FindTopWindowForTextInput: TAndroidWindowHandle;
var
I: Integer;
begin
for I := FWindows.Count - 1 downto 0 do
if FWindows[I].Form.Visible and not (FWindows[I].Form is TCustomPopupForm) then
Exit(FWindows[I]);
Result := nil;
end;
function TWindowManager.FindWindowByPoint(X, Y: Single): TAndroidWindowHandle;
var
I: Integer;
begin
for I := FWindows.Count - 1 downto 0 do
if FWindows[I].Form.Visible and FWindows[I].Bounds.Contains(PointF(X, Y)) then
Exit(FWindows[I]);
Result := nil;
end;
procedure TWindowManager.FreeNotification(AObject: TObject);
begin
FFocusedControl := nil;
end;
function TWindowManager.GetClientSize(const AForm: TCommonCustomForm): TPointF;
begin
if not IsPopupForm(AForm) then
Result := TPointF.Create(ContentRect.Width, ContentRect.Height)
else
Result := TAndroidWindowHandle(AForm.Handle).Bounds.Size;
end;
class function TWindowManager.GetInstance: TWindowManager;
begin
if FInstance = nil then
FInstance := TWindowManager.Create;
Result := FInstance;
end;
function TWindowManager.GetMultiTouchManager: TMultiTouchManagerAndroid;
var
Window: TAndroidWindowHandle;
begin
Window := FindTopWindow;
if Window <> nil then
if FMultiTouchManager = nil then
FMultiTouchManager := TMultiTouchManagerAndroid.Create(Window.Form)
else
if FMultiTouchManager.Parent <> Window.Form then
FMultiTouchManager.Parent := Window.Form;
Result := FMultiTouchManager;
end;
function TWindowManager.GetWindowRect(const AForm: TCommonCustomForm): TRectF;
begin
if IsPopupForm(AForm) then
Result := TAndroidWindowHandle(AForm.Handle).Bounds
else
Result := ContentRect;
end;
function TWindowManager.GetWindowScale(const AForm: TCommonCustomForm): Single;
begin
Result := Scale;
end;
function TWindowManager.TextGetService: TTextServiceAndroid;
var
TextInput: ITextInput;
begin
Result := nil;
if Supports(FFocusedControl, ITextInput, TextInput) then
Result := TTextServiceAndroid(TextInput.GetTextService);
end;
function TWindowManager.TextGetActions: ITextActions;
begin
Supports(FFocusedControl, ITextActions, Result);
end;
function TWindowManager.TextReadOnly: Boolean;
var
ReadOnly: IReadOnly;
begin
Result := True;
if Supports(FFocusedControl, IReadOnly, ReadOnly) then
Result := ReadOnly.ReadOnly;
end;
procedure TWindowManager.TextResetSelection;
var
TextActions: ITextActions;
begin
if Supports(FFocusedControl, ITextActions, TextActions) then
TextActions.ResetSelection;
end;
procedure TWindowManager.KeyDown(var Key: Word; var KeyChar: System.WideChar; Shift: TShiftState);
var
Window: TAndroidWindowHandle;
begin
HideContextMenu;
Window := FindTopWindowForTextInput;
if Window <> nil then
try
Window.Form.KeyDown(Key, KeyChar, Shift);
except
Application.HandleException(Window.Form);
end;
end;
procedure TWindowManager.KeyUp(var Key: Word; var KeyChar: System.WideChar; Shift: TShiftState; KeyDownHandled: Boolean);
var
Window: TAndroidWindowHandle;
function HideVKB: Boolean;
begin
if FVirtualKeyboard <> nil then
begin
Result := FVirtualKeyboard.GetVirtualKeyboardState * [TVirtualKeyboardState.Visible] <> [];
if Result then
begin
Key := 0;
KeyChar := #0;
Screen.ActiveForm.Focused := nil;
FVirtualKeyboard.HideVirtualKeyboard
end;
end
else
Result := True;
end;
begin
Window := FindTopWindowForTextInput;
if Window <> nil then
try
Window.Form.KeyUp(Key, KeyChar, Shift);
except
Application.HandleException(Window.Form);
end;
// some actions by default
if KeyDownHandled and (Key = vkHardwareBack) then // If you press of key was processed
HideVKB
else // If you press of key wasn't processed
case Key of
vkHardwareBack:
begin
if not HideVKB and (Window <> nil) then
begin
try
Key := 0;
KeyChar := #0;
Window.Form.Close;
except
Application.HandleException(Window.Form);
end;
if Application.MainForm <> Window.Form then
begin
if (FVisibleStack.Count > 0) and (FVisibleStack.Peek = Window) then
FVisibleStack.Pop;
if (FVisibleStack.Count > 0) and (FVisibleStack.Peek <> nil) then
BringToFront(FVisibleStack.Peek);
end
else
Application.Terminate; //we have close the main form
end;
end
end
end;
procedure TWindowManager.PrepareClosePopups(const SaveForm: TAndroidWindowHandle);
begin
if Screen <> nil then
if SaveForm <> nil then
Screen.PrepareClosePopups(SaveForm.Form)
else
Screen.PrepareClosePopups(nil);
end;
function TWindowManager.ClientToScreen(const AForm: TCommonCustomForm; const Point: TPointF): TPointF;
begin
if AForm <> nil then
Result := Point + TAndroidWindowHandle(AForm.Handle).Bounds.TopLeft
else
Result := Point;
end;
procedure TWindowManager.ClosePopups;
begin
if Screen <> nil then
Screen.ClosePopupForms;
end;
procedure TWindowManager.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Single);
var
Window: TAndroidWindowHandle;
ClientPoint: TPointF;
Obj: IControl;
GObj: IGestureControl;
begin
Window := FindWindowByPoint(X, Y);
if Window <> nil then
begin
PrepareClosePopups(Window);
ClientPoint := ScreenToClient(Window, TPointF.Create(X, Y));
try
Window.Form.MouseMove([ssTouch], ClientPoint.X, ClientPoint.Y);
Window.Form.MouseMove([], ClientPoint.X, ClientPoint.Y); // Required for correct IsMouseOver handling
Window.Form.MouseDown(TMouseButton.mbLeft, Shift, ClientPoint.X, ClientPoint.Y);
except
Application.HandleException(Window.Form);
end;
// find the control from under the gesture
Obj := Window.Form.ObjectAtPoint(Window.Form.ClientToScreen(ClientPoint));
if Obj <> nil then
FGestureControl := Obj.GetObject
else
FGestureControl := Window.Form;
if FGestureControl is TControl then
FMouseDownControl := TControl(FGestureControl);
if FMouseDownControl is TStyledPresentation then
FMouseDownControl := TStyledPresentation(FMouseDownControl).PresentedControl;
HideContextMenu;
if Supports(FGestureControl, IGestureControl, GObj) then
FGestureControl := GObj.GetFirstControlWithGestureEngine;
if Supports(FGestureControl, IGestureControl, GObj) then
begin
TPlatformGestureEngine(GObj.TouchManager.GestureEngine).InitialPoint := ClientPoint;
// Retain the points/touches.
TPlatformGestureEngine(GObj.TouchManager.GestureEngine).ClearPoints;
TPlatformGestureEngine(GObj.TouchManager.GestureEngine).AddPoint(ClientPoint.X, ClientPoint.Y);
end;
end;
end;
procedure TWindowManager.MouseMove(Shift: TShiftState; X, Y: Single);
var
Window: TAndroidWindowHandle;
ClientPoint: TPointF;
GObj: IGestureControl;
begin
if FCapturedWindow <> nil then
Window := FCapturedWindow
else
Window := FindWindowByPoint(X, Y);
if Window <> nil then
begin
ClientPoint := ScreenToClient(Window, TPointF.Create(X, Y));
try
Window.Form.MouseMove(Shift, ClientPoint.X, ClientPoint.Y);
except
Application.HandleException(Window.Form);
end;
if Supports(FGestureControl, IGestureControl, GObj) and (GObj.TouchManager.GestureEngine <> nil) then
TPlatformGestureEngine(GObj.TouchManager.GestureEngine).AddPoint(ClientPoint.X, ClientPoint.Y);
end;
end;
procedure TWindowManager.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Single; DoCLick: Boolean);
const
LGestureTypes: TGestureTypes = [TGestureType.Standard, TGestureType.Recorded, TGestureType.Registered];
var
Window: TAndroidWindowHandle;
ClientPoint: TPointF;
EventInfo: TGestureEventInfo;
GObj: IGestureControl;
begin
if FCapturedWindow <> nil then
Window := FCapturedWindow
else
Window := FindWindowByPoint(X, Y);
if Window <> nil then
begin
ClientPoint := ScreenToClient(Window, TPointF.Create(X, Y));
try
Window.Form.MouseUp(TMouseButton.mbLeft, Shift, ClientPoint.X, ClientPoint.Y, DoClick);
if Window.Form <> nil then
Window.Form.MouseLeave; // Require for correct IsMouseOver handle
ClosePopups;
except
Application.HandleException(Window.Form);
end;
if Supports(FGestureControl, IGestureControl, GObj) then
if GObj.TouchManager.GestureEngine <> nil then
begin
if TPlatformGestureEngine(GObj.TouchManager.GestureEngine).PointCount > 1 then
begin
FillChar(EventInfo, Sizeof(EventInfo), 0);
if TPlatformGestureEngine.IsGesture
(TPlatformGestureEngine(GObj.TouchManager.GestureEngine).Points,
TPlatformGestureEngine(GObj.TouchManager.GestureEngine).GestureList, LGestureTypes, EventInfo) then
TPlatformGestureEngine(GObj.TouchManager.GestureEngine).BroadcastGesture(FGestureControl, EventInfo);
end;
end;
end;
end;
procedure TWindowManager.MultiTouch(const Touches: TTouches; const Action: TTouchAction; const AEnabledGestures: TInteractiveGestures);
var
Window: TAndroidWindowHandle;
Control: IControl;
I: Integer;
begin
if FCapturedWindow <> nil then
Window := FCapturedWindow
else
Window := FindWindowByPoint(Touches[0].Location.X, Touches[0].Location.Y);
if Window <> nil then
begin
if Length(Touches) = 1 then
Control := Window.Form.ObjectAtPoint(Touches[0].Location)
else if Length(Touches) = 2 then
Control := Window.Form.ObjectAtPoint(Touches[0].Location.MidPoint(Touches[1].Location))
else
Control := nil;
for I := 0 to Length(Touches) - 1 do
Touches[I].Location := Window.Form.ScreenToClient(Touches[I].Location);
MultiTouchManager.SetEnabledGestures(AEnabledGestures);
MultiTouchManager.HandleTouches(Touches, Action, Control);
end;
end;
procedure TWindowManager.PasteMenuTimerCall;
begin
DestroyPasteMenuTimer;
//
HideContextMenu;
end;
function TWindowManager.PixelToPoint(const P: TPointF): TPointF;
begin
Result := TPointF.Create(P.X / FScale, P.Y / FScale);
end;
function TWindowManager.PointToPixel(const P: TPointF): TPointF;
begin
Result := TPointF.Create(P.X * FScale, P.Y * FScale);
end;
procedure TWindowManager.ReleaseCapture(const AForm: TCommonCustomForm);
begin
FCapturedWindow := nil;
end;
procedure TWindowManager.ReleaseWindow(const AForm: TCommonCustomForm);
begin
if (AForm.Handle <> nil) and Windows.Contains(TAndroidWindowHandle(AForm.Handle)) then
RemoveWindow(TAndroidWindowHandle(AForm.Handle));
end;
procedure TWindowManager.RemoveWindow(const AHandle: TAndroidWindowHandle);
begin
if FVisibleStack.Peek = AHandle then
FVisibleStack.Pop;
FWindows.Remove(AHandle);
FMouseDownControl := nil;
SetFocusedControl(nil);
FGestureControl := nil;
SetNeedsRender;
end;
function TWindowManager.AlignToPixel(const Value: Single): Single;
begin
Result := Round(Value * Scale) / Scale;
end;
procedure TWindowManager.InitWindow;
begin
TContext3D.ResetStates;
FContext := TCustomAndroidContext.CreateContextFromActivity(Round(FContentRect.Width * FScale),
Round(FContentRect.Height * FScale), TMultisample.None, False);
end;
procedure TWindowManager.TermWindow;
begin
FContext.DisposeOf;
FContext := nil;
end;
procedure TWindowManager.GainedFocus;
begin
TContext3D.ResetStates;
end;
procedure TWindowManager.PostRenderRunnable;
begin
if (not Pause) and (FRenderRunnable = nil) then
begin
TMonitor.Enter(FRenderLock);
try
FRenderRunnable := TRenderRunnable.Create(Self)
finally
TMonitor.Exit(FRenderLock);
end;
end;
end;
procedure TWindowManager.ReleaseRenderRunnable;
begin
TMonitor.Enter(FRenderLock);
try
FRenderRunnable := nil;
finally
TMonitor.Exit(FRenderLock);
end;
end;
procedure TWindowManager.Render;
function HaveAnyCompositionedWindows: Boolean;
var
I: Integer;
begin
for I := 0 to FWindows.Count - 1 do
if FWindows[I].Form.Visible and FWindows[I].RequiresComposition then
Exit(True);
Result := False;
end;
procedure RenderNormalWindows;
var
I: Integer;
PaintControl: IPaintControl;
begin
for I := FWindows.Count - 1 downto 0 do
if FWindows[I].Form.Visible and not FWindows[I].RequiresComposition and Supports(FWindows[I].Form,
IPaintControl, PaintControl) then
begin
PaintControl.PaintRects([TRectF.Create(0, 0, FContentRect.Width, FContentRect.Height)]);
Break;
end;
end;
procedure RenderBuffers;
var
I: Integer;
CurrentForm: TAndroidWindowHandle;
FormBounds: TRectF;
begin
for I := FWindows.Count - 1 downto 0 do
begin
CurrentForm := FWindows[I];
if CurrentForm.RequiresComposition and (CurrentForm.Texture <> nil) and CurrentForm.Form.Visible then
begin
FormBounds := CurrentForm.Bounds;
if CurrentForm.NeedsUpdate then
begin
IPaintControl(CurrentForm.Form).PaintRects([RectF(0, 0, FormBounds.Width, FormBounds.Height)]);
CurrentForm.NeedsUpdate := False;
end;
end;
end;
end;
procedure RenderCompositionedWindows;
var
I: Integer;
Mat: TCanvasTextureMaterial;
Ver: TVertexBuffer;
Ind: TIndexBuffer;
CurrentForm: TAndroidWindowHandle;
FormBounds: TRectF;
begin
Ver := TVertexBuffer.Create([TVertexFormat.Vertex, TVertexFormat.TexCoord0, TVertexFormat.Color0], 4);
Ver.Color0[0] := $FFFFFFFF;
Ver.Color0[1] := $FFFFFFFF;
Ver.Color0[2] := $FFFFFFFF;
Ver.Color0[3] := $FFFFFFFF;
Ver.TexCoord0[0] := PointF(0.0, 1.0);
Ver.TexCoord0[1] := PointF(1.0, 1.0);
Ver.TexCoord0[2] := PointF(1.0, 0.0);
Ver.TexCoord0[3] := PointF(0.0, 0.0);
Ind := TIndexBuffer.Create(6);
Ind[0] := 0;
Ind[1] := 1;
Ind[2] := 3;
Ind[3] := 3;
Ind[4] := 1;
Ind[5] := 2;
Mat := TCanvasTextureMaterial.Create;
for I := FWindows.Count - 1 downto 0 do
begin
CurrentForm := FWindows[I];
if CurrentForm.RequiresComposition and (CurrentForm.Texture <> nil) and CurrentForm.Form.Visible then
begin
FormBounds := CurrentForm.Bounds;
FormBounds.Offset(-FContentRect.Left, -FContentRect.Top);
FormBounds.Left := Round(FormBounds.Left * Scale);
FormBounds.Top := Round(FormBounds.Top * Scale);
FormBounds.Right := FormBounds.Left + CurrentForm.Texture.Width;
FormBounds.Bottom := FormBounds.Top + CurrentForm.Texture.Height;
Ver.Vertices[0] := TPoint3D.Create(FormBounds.Left, FormBounds.Top, 0);
Ver.Vertices[1] := TPoint3D.Create(FormBounds.Right, FormBounds.Top, 0);
Ver.Vertices[2] := TPoint3D.Create(FormBounds.Right, FormBounds.Bottom, 0);
Ver.Vertices[3] := TPoint3D.Create(FormBounds.Left, FormBounds.Bottom, 0);
Mat.Texture := CurrentForm.Texture;
FContext.SetMatrix(TMatrix3D.Identity);
FContext.SetContextState(TContextState.cs2DScene);
FContext.SetContextState(TContextState.csZWriteOff);
FContext.SetContextState(TContextState.csZTestOff);
FContext.SetContextState(TContextState.csAllFace);
FContext.SetContextState(TContextState.csScissorOff);
if CurrentForm.Form.Transparency then
FContext.SetContextState(TContextState.csAlphaBlendOn)
else
FContext.SetContextState(TContextState.csAlphaBlendOff);
FContext.DrawTriangles(Ver, Ind, Mat, 1);
end;
Mat.Free;
Ind.Free;
Ver.Free;
end;
end;
begin
if (FContext <> nil) and not FPause then
begin
if HaveAnyCompositionedWindows then
RenderBuffers;
if FContext.BeginScene then
try
// Render normal opaque windows that are occupying entire client space.
RenderNormalWindows;
// If there are any visible popups or transparent windows, render them using buffered texture.
if HaveAnyCompositionedWindows then
RenderCompositionedWindows;
finally
FContext.EndScene;
end;
end;
FNeedsRender := False;
end;
function TWindowManager.RenderIfNeeds: Boolean;
begin
Result := FNeedsRender;
if FNeedsRender then
Render;
end;
procedure TWindowManager.RenderImmediately;
begin
SetNeedsRender;
RenderIfNeeds;
end;
procedure TWindowManager.SetCapture(const AForm: TCommonCustomForm);
begin
FCapturedWindow := TAndroidWindowHandle(AForm.Handle);
end;
procedure TWindowManager.SetClientSize(const AForm: TCommonCustomForm; const ASize: TPointF);
var
Bounds: TRectF;
begin
if IsPopupForm(AForm) then
begin
Bounds := TAndroidWindowHandle(AForm.Handle).Bounds;
TAndroidWindowHandle(AForm.Handle).Bounds := TRectF.Create(Bounds.TopLeft, ASize.X, ASize.Y);
end;
end;
procedure TWindowManager.SetContentRect(const Value: TRect);
var
DecorView: JView;
NativeWin: JWindow;
ContentRect: JRect;
begin
if FContentRect <> Value then
begin
FContentRect := TRect.Create(Round(Value.left / FScale), Round(Value.top / FScale), Round(Value.right / FScale), Round(Value.bottom / FScale));;
NativeWin := TAndroidHelper.Activity.getWindow;
if NativeWin <> nil then
begin
ContentRect := TJRect.Create;
DecorView := NativeWin.getDecorView;
DecorView.getDrawingRect(ContentRect);
FContentRect.Bottom := Round(ContentRect.bottom / FScale);
FContentRect.Right := Round(ContentRect.right / FScale);
end;
FStatusBarHeight := Value.Top;
UpdateFormSizes;
PlatformAndroid.ScreenManager.UpdateDisplayInformation;
if FContext <> nil then
FContext.SetSize(Round(FContentRect.Width * FScale), Round(FContentRect.Height * FScale));
SetNeedsRender;
Render;
end;
end;
procedure TWindowManager.SetFocusedControl(const Control: IControl);
begin
if FFocusedControl <> Control then
begin
if FFocusedControl <> nil then
FFocusedControl.RemoveFreeNotify(Self);
FFocusedControl := Control;
if FFocusedControl <> nil then
FFocusedControl.AddFreeNotify(Self);
end;
end;
procedure TWindowManager.SetNeedsRender;
begin
if not FNeedsRender then
begin
FNeedsRender := True;
PostRenderRunnable;
end;
end;
procedure TWindowManager.SetPause(const Value: Boolean);
begin
FPause := Value;
end;
procedure TWindowManager.SetWindowCaption(const AForm: TCommonCustomForm; const ACaption: string);
begin
// NOP on Android
end;
procedure TWindowManager.SetWindowRect(const AForm: TCommonCustomForm; ARect: TRectF);
begin
if IsPopupForm(AForm) then
TAndroidWindowHandle(AForm.Handle).Bounds := ARect;
end;
procedure TWindowManager.SetWindowState(const AForm: TCommonCustomForm; const AState: TWindowState);
begin
if AForm.Visible and (AState = TWindowState.wsMinimized) then
AForm.Visible := False;
if AForm.Visible then
if IsPopupForm(AForm) then
AForm.WindowState := TWindowState.wsNormal
else
AForm.WindowState := TWindowState.wsMaximized
else
AForm.WindowState := TWindowState.wsMinimized;
end;
procedure TWindowManager.ShowContextMenu(const ItemsToShow: TContextMenuItems);
var
LA: TTextLayout;
P: TPoint;
HasSelection, HasClipboard: Boolean;
ApproxWidth: Integer;
ApproxHeight: Integer;
ClipboardValue: TValue;
ResID: Integer;
TextInput: ITextInput;
VirtualKeyboard: IVirtualKeyboardControl;
ClipboardSvc: IFMXClipboardService;
begin
DestroyPasteMenuTimer;
ApproxWidth := FContextMenuPopupSize.cx;
ApproxHeight := FContextMenuPopupSize.cy;
if not FContextMenuVisible and Supports(FFocusedControl, ITextInput, TextInput) and not FSelectionInProgress then
begin
FContextMenuVisible := True;
HasSelection := not TextInput.GetSelection.IsEmpty;
TPlatformServices.Current.SupportsPlatformService(IFMXClipboardService, ClipboardSvc);
ClipboardValue := ClipboardSvc.GetClipboard;
HasClipboard := not ClipboardValue.IsEmpty and not ClipboardValue.ToString.IsEmpty;
if FContextMenuPopup = nil then
begin
FContextMenuLayout := TJLinearLayout.JavaClass.init(TAndroidHelper.Activity);
FContextButtonsLayout := TJLinearLayout.JavaClass.init(TAndroidHelper.Activity);
LA := TTextLayoutManager.DefaultTextLayout.Create;
LA.Font.Style := LA.Font.Style + [TFontStyle.fsBold];
P := Point(0, 0);
Supports(FFocusedControl, IVirtualKeyboardControl, VirtualKeyboard);
if HasSelection then
begin
//Copy button
if (TContextMenuItem.Copy in ItemsToShow) and ((VirtualKeyboard = nil) or not VirtualKeyboard.IsPassword) then
begin
ResID := TAndroidHelper.GetResourceID('android:string/copy');
if ResID <> 0 then
LA.Text := TAndroidHelper.GetResourceString(ResID)
else
LA.Text := SEditCopy.ToUpper;
FCopyButton := TJButton.JavaClass.init(TAndroidHelper.Activity);
if ResID <> 0 then
FCopyButton.setText(ResID)
else
FCopyButton.setText(StrToJCharSequence(LA.Text));
FCopyButton.setTypeface(TJTypeface.JavaClass.DEFAULT_BOLD);
FCopyClickListener := TCopyButtonClickListener.Create;
FCopyButton.setOnClickListener(FCopyClickListener);
LA.Font.Size := FCopyButton.getTextSize;
P.X := P.X + Ceil((LA.TextWidth + 2) * FScale);
P.Y := Max(P.Y, Ceil((LA.TextHeight + 2) * FScale));
ApproxHeight := P.Y + FCopyButton.getPaddingTop + FCopyButton.getPaddingBottom;
end;
//Cut button
if (TContextMenuItem.Cut in ItemsToShow) and not TextReadOnly and ((VirtualKeyboard = nil) or not VirtualKeyboard.IsPassword) then
begin
ResID := TAndroidHelper.GetResourceID('android:string/cut');
if ResID <> 0 then
LA.Text := TAndroidHelper.GetResourceString(ResID)
else
LA.Text := SEditCut.ToUpper;
FCutButton := TJButton.JavaClass.init(TAndroidHelper.Activity);
if ResID <> 0 then
FCutButton.setText(ResID)
else
FCutButton.setText(StrToJCharSequence(LA.Text));
FCutButton.setTypeface(TJTypeface.JavaClass.DEFAULT_BOLD);
FCutClickListener := TCutButtonClickListener.Create;
FCutButton.setOnClickListener(FCutClickListener);
LA.Font.Size := FCopyButton.getTextSize;
P.X := P.X + Ceil((LA.TextWidth + 2) * FScale);
P.Y := Max(P.Y, Ceil((LA.TextHeight + 2) * FScale));
end;
end;
if HasClipboard and (TContextMenuItem.Paste in ItemsToShow) and not TextReadOnly then
begin
//Paste button
ResID := TAndroidHelper.GetResourceID('android:string/paste');
if ResID <> 0 then
LA.Text := TAndroidHelper.GetResourceString(ResID)
else
LA.Text := SEditPaste.ToUpper;
FPasteButton := TJButton.JavaClass.init(TAndroidHelper.Activity);
if ResID <> 0 then
FPasteButton.setText(ResID)
else
FPasteButton.setText(StrToJCharSequence(LA.Text));
FPasteButton.setTypeface(TJTypeface.JavaClass.DEFAULT_BOLD);
FPasteClickListener := TPasteButtonClickListener.Create;
FPasteButton.setOnClickListener(FPasteClickListener);
LA.Font.Size := FPasteButton.getTextSize;
P.X := P.X + Ceil((LA.TextWidth + 2) * FScale);
P.Y := Max(P.Y, Ceil((LA.TextHeight + 2) * FScale));
if ApproxHeight = 0 then
ApproxHeight := P.Y + FPasteButton.getPaddingTop + FPasteButton.getPaddingBottom;
end;
ApproxWidth := P.X;
FContextMenuPopup := TJPopupWindow.JavaClass.init(TAndroidHelper.Activity);
FContextMenuPopup.setBackgroundDrawable(TJColorDrawable.JavaClass.init(0));
FContextMenuPopup.setContentView(FContextButtonsLayout);
FContextMenuPopup.setWidth(TJViewGroup_LayoutParams.JavaClass.WRAP_CONTENT);
FContextMenuPopup.setHeight(TJViewGroup_LayoutParams.JavaClass.WRAP_CONTENT);
end;
FContextMenuPopupSize.cx := ApproxWidth;
if FContextMenuPopupSize.cy <= 0 then
begin
FContextMenuPopupSize.cy := ApproxHeight;
end;
if FCopyButton <> nil then
FContextButtonsLayout.addView(FCopyButton);
if FCutButton <> nil then
FContextButtonsLayout.addView(FCutButton);
if FPasteButton <> nil then
FContextButtonsLayout.addView(FPasteButton);
if (FVirtualKeyboard <> nil) and (TVirtualKeyboardState.Visible in FVirtualKeyboard.VirtualKeyboardState) then
DoShowContextMenu;
end;
end;
procedure TWindowManager.ShowWindow(const AForm: TCommonCustomForm);
var
NativeWin: JWindow;
begin
if AForm.Handle <> nil then
begin
if not IsPopupForm(AForm) then
begin
NativeWin := TAndroidHelper.Activity.getWindow;
if AForm.BorderStyle = TFmxFormBorderStyle.None then
MainActivity.setStatusBarVisibility(False)
else
MainActivity.setStatusBarVisibility(True);
try
AForm.SetBounds(ContentRect.Left, ContentRect.Top, ContentRect.Width, ContentRect.Height);
except
Application.HandleException(AForm);
end;
end
else
SetNeedsRender;
BringToFront(TAndroidWindowHandle(AForm.Handle));
if IsPopupForm(AForm) then
AForm.WindowState := TWindowState.wsNormal
else
AForm.WindowState := TWindowState.wsMaximized;
end;
end;
function TWindowManager.ShowWindowModal(const AForm: TCommonCustomForm): TModalResult;
begin
raise ENotImplemented.CreateFmt(SNotImplementedOnPlatform, ['ShowModal']);
Result := mrCancel;
end;
function TWindowManager.CanShowModal: Boolean;
begin
Result := False;
end;
procedure TWindowManager.DoShowContextMenu;
const
LocTopOffset = 10.0;
LocBottomOffset = 3 * LocTopOffset;
var
SelRect: TRectF;
PopupLoc: TPoint;
TempPointF: TPointF;
TextInput: ITextInput;
LocY: Single;
begin
if Supports(FFocusedControl, ITextInput, TextInput) and (FContextMenuLayout <> nil) and (FContextMenuPopup <> nil) and
(FContextButtonsLayout.getChildCount > 0) then
begin
SelRect := TextInput.GetSelectionRect;
TempPointF := FFocusedControl.LocalToScreen(TPointF.Create(SelRect.Left, SelRect.Top)) * FScale;
TempPointF.X := TempPointF.X + SelRect.Width / 2 - FContextMenuPopupSize.cx / 2;
LocY := TempPointF.Y - LocTopOffset * FScale - FContextMenuPopupSize.cy;
if LocY < 0 then
LocY := TempPointF.Y + (SelRect.Height + LocBottomOffset) * FScale;
TempPointF.Y := LocY;
PopupLoc := TempPointF.Round;
FContextMenuPopup.showAtLocation(FContextMenuLayout, 0, PopupLoc.X, PopupLoc.Y);
end
else
HideContextMenu;
end;
procedure TWindowManager.VKStateHandler(const Sender: TObject; const M: TMessage);
begin
if TVKStateChangeMessage(M).KeyboardVisible and Supports(FFocusedControl, ITextInput) and (FContextMenuLayout <> nil) and
(FContextMenuPopup <> nil) and (FContextButtonsLayout.getChildCount > 0) then
DoShowContextMenu;
end;
procedure TWindowManager.SingleTap;
begin
if FMouseDownControl <> nil then
try
if not FSelectionInProgress then
begin
if Supports(FMouseDownControl, ITextInput) and Supports(FMouseDownControl, ITextActions) then
begin
if not FIsFirstSingleTap then
begin
ShowContextMenu([TContextMenuItem.Paste]);
CreatePasteMenuTimer;
end;
FIsFirstSingleTap := False;
end
else
HideContextMenu;
end;
except
Application.HandleException(Self);
FMouseDownControl := nil;
end;
end;
procedure TWindowManager.HideContextMenu;
begin
DestroyPasteMenuTimer;
if FContextMenuVisible and (FContextMenuPopup <> nil) and (FContextButtonsLayout <> nil) then
begin
FContextMenuPopupSize.cx := FContextButtonsLayout.getWidth;
FContextMenuPopupSize.cy := FContextButtonsLayout.getHeight;
FContextMenuPopup.dismiss;
FContextMenuPopup := nil;
FCopyButton := nil;
FCopyClickListener := nil;
FPasteButton := nil;
FPasteClickListener := nil;
FCutButton := nil;
FCutClickListener := nil;
FContextMenuLayout := nil;
FContextButtonsLayout := nil;
end;
FContextMenuVisible := False;
end;
procedure TWindowManager.HideWindow(const AForm: TCommonCustomForm);
begin
if FVisibleStack.Peek = AForm.Handle then
FVisibleStack.Pop;
if AForm.Handle <> nil then
SetNeedsRender;
AForm.WindowState := TWindowState.wsMinimized;
end;
procedure TWindowManager.InvalidateImmediately(const AForm: TCommonCustomForm);
begin
TAndroidWindowHandle(AForm.Handle).NeedsUpdate := True;
SetNeedsRender;
end;
procedure TWindowManager.InvalidateWindowRect(const AForm: TCommonCustomForm; R: TRectF);
begin
TAndroidWindowHandle(AForm.Handle).NeedsUpdate := True;
SetNeedsRender;
end;
function TWindowManager.IsPopupForm(const AForm: TCommonCustomForm): Boolean;
begin
Result := (AForm <> nil) and ((AForm.FormStyle = TFormStyle.Popup) or (AForm.Owner is TPopup));
end;
procedure TWindowManager.UpdateFormSizes;
var
I: Integer;
begin
for I := FWindows.Count - 1 downto 0 do
if not FWindows[I].IsPopup then
try
FWindows[I].SetBounds(FContentRect);
except
Application.HandleException(FWindows[I].Form);
end;
end;
{ TPlatformAndroid }
constructor TPlatformAndroid.Create;
begin
inherited;
BindAppGlueEvents;
{ Creates core services }
FLoggerService := TAndroidLoggerService.Create;
FTimerService := TAndroidTimerService.Create;
FSaveStateService := TAndroidSaveStateService.Create;
FScreenServices := TAndroidScreenServices.Create;
FMetricsServices := TAndroidMetricsServices.Create;
FDeviceServices := TAndroidDeviceServices.Create;
if DeviceManager.GetDeviceClass <> TDeviceInfo.TDeviceClass.Watch then
FVirtualKeyboardService := TVirtualKeyboardAndroid.Create;
FGraphicServices := TAndroidGraphicsServices.Create;
FWindowManager := TWindowManager.Current;
FMotionManager := TAndroidMotionManager.Create;
FTextInputManager := TAndroidTextInputManager.Create;
Application := TApplication.Create(nil);
FFirstRun := True;
FRunning := False;
FActivityListener := TFMXNativeActivityListener.Create;
MainActivity.setListener(FActivityListener);
FWakeMainThreadRunnable := TWakeMainThreadRunnable.Create;
FLastOrientation := UndefinedOrientation;
if DeviceManager.GetModel = 'Glass 1' then
TPlatformServices.Current.GlobalFlags.Add(EnableGlassFPSWorkaround, True);
RegisterServices;
RegisterWakeMainThread;
FIdleHandler := TMessageQueueIdleHandler.Create(Self);
TJLooper.JavaClass.getMainLooper.getQueue.addIdleHandler(FIdleHandler);
end;
destructor TPlatformAndroid.Destroy;
begin
TJLooper.JavaClass.getMainLooper.getQueue.removeIdleHandler(FIdleHandler);
FIdleHandler.Free;
FTextInputManager.Free;
FMotionManager.Free;
FWindowManager.Free;
FGraphicServices.Free;
FVirtualKeyboardService.Free;
FDeviceServices.Free;
FMetricsServices.Free;
FScreenServices.Free;
FSaveStateService.Free;
FTimerService.Free;
FLoggerService.Free;
UnregisterServices;
UnbindAppGlueEvents;
FWakeMainThreadRunnable := nil;
FActivityListener.DisposeOf;
UnregisterWakeMainThread;
inherited;
end;
procedure TPlatformAndroid.Run;
begin
FRunning := True;
{ Although calling this routine is not really necessary, but it is a way to ensure that "Androidapi.AppGlue.pas" is
kept in uses list, in order to export ANativeActivity_onCreate callback. }
app_dummy;
InternalProcessMessages;
end;
function TPlatformAndroid.Running: Boolean;
begin
Result := FRunning;
end;
function TPlatformAndroid.Terminating: Boolean;
begin
Result := FTerminating;
end;
procedure TPlatformAndroid.Terminate;
begin
FRunning := False;
FTerminating := True;
TMessageManager.DefaultManager.SendMessage(nil, TApplicationTerminatingMessage.Create);
// When we manually finish our activity, Android will not generate OnSaveInstanceState event, because it is generated
// only in cases when the system is going to kill our activity to reclaim resources. In this particular case we
// initiate correct termination of the application, so we have to invoke OnSaveInstanceState manually to make sure
// that TForm.OnSaveState is invoked before the application is closed
HandleApplicationCommandEvent(TAndroidApplicationGlue.Current, TAndroidApplicationCommand.SaveState);
ANativeActivity_finish(System.DelphiActivity);
end;
function TPlatformAndroid.HandleAndroidInputEvent(const App: TAndroidApplicationGlue; const AEvent: PAInputEvent): Int32;
var
EventType: Int64;
begin
EventType := AInputEvent_getType(AEvent);
if EventType = AINPUT_EVENT_TYPE_KEY then
// Keyboard input
Result := TextInputManager.HandleAndroidKeyEvent(AEvent)
else if EventType = AINPUT_EVENT_TYPE_MOTION then
// Motion Event
Result := MotionManager.HandleAndroidMotionEvent(AEvent)
else
Result := 0;
end;
function TPlatformAndroid.HandleMessage: Boolean;
begin
InternalProcessMessages;
Result := False;
end;
procedure TPlatformAndroid.BindAppGlueEvents;
var
AndroidAppGlue: TAndroidApplicationGlue;
begin
AndroidAppGlue := PANativeActivity(System.DelphiActivity)^.instance;
AndroidAppGlue.OnApplicationCommandEvent := HandleApplicationCommandEvent;
AndroidAppGlue.OnContentRectEvent := HandleContentRectChanged;
AndroidAppGlue.OnInputEvent := HandleAndroidInputEvent;
end;
procedure TPlatformAndroid.CheckOrientationChange;
var
LOrientation: TScreenOrientation;
begin
LOrientation := ScreenManager.GetScreenOrientation;
if FLastOrientation <> LOrientation then
begin
FLastOrientation := LOrientation;
TMessageManager.DefaultManager.SendMessage(Self, TOrientationChangedMessage.Create, True);
end;
end;
procedure TPlatformAndroid.WaitMessage;
begin
InternalProcessMessages;
end;
procedure TPlatformAndroid.RegisterWakeMainThread;
begin
System.Classes.WakeMainThread := WakeMainThread;
end;
procedure TPlatformAndroid.UnregisterWakeMainThread;
begin
System.Classes.WakeMainThread := nil;
end;
{ TWakeMainThreadRunnable }
procedure TWakeMainThreadRunnable.run;
begin
PlatformAndroid.InternalProcessMessages;
end;
procedure TPlatformAndroid.WakeMainThread(Sender: TObject);
begin
TAndroidHelper.Activity.runOnUiThread(FWakeMainThreadRunnable);
end;
procedure TPlatformAndroid.InternalProcessMessages;
var
LDone: Boolean;
procedure ProcessAndroidMessage;
begin
FTimerService.ProcessQueueTimers;
end;
begin
CheckSynchronize;
ProcessAndroidMessage;
WindowManager.RenderIfNeeds;
if not Terminating then
try
LDone := False;
Application.DoIdle(LDone);
except
Application.HandleException(Application);
end;
end;
function TPlatformAndroid.GetDefaultTitle: string;
begin
Result := TAndroidHelper.ApplicationTitle;
end;
function TPlatformAndroid.GetTitle: string;
begin
Result := FTitle;
end;
function TPlatformAndroid.GetVersionString: string;
var
PackageInfo: JPackageInfo;
PackageManager: JPackageManager;
AppContext: JContext;
begin
AppContext := TAndroidHelper.Context;
if AppContext <> nil then
begin
PackageManager := AppContext.getPackageManager;
if PackageManager <> nil then
begin
PackageInfo := AppContext.getPackageManager.getPackageInfo(AppContext.getPackageName, 0);
if PackageInfo <> nil then
Exit(JStringToString(PackageInfo.versionName));
end;
end;
Result := string.Empty;
end;
procedure TPlatformAndroid.SetTitle(const Value: string);
begin
FTitle := Value;
end;
procedure TPlatformAndroid.SetApplicationEventHandler(AEventHandler: TApplicationEventHandler);
begin
FOnApplicationEvent := AEventHandler;
end;
function TPlatformAndroid.HandleApplicationEvent(AEvent: TApplicationEvent): Boolean;
var
ApplicationEventMessage: TApplicationEventMessage;
begin
Result := False;
{ Send broadcast message }
ApplicationEventMessage := TApplicationEventMessage.Create(TApplicationEventData.Create(AEvent, nil));
TMessageManager.DefaultManager.SendMessage(nil, ApplicationEventMessage);
{ Invoke application event}
if Assigned(FOnApplicationEvent) then
try
Result := FOnApplicationEvent(AEvent, nil);
except
Application.HandleException(Self);
end;
end;
procedure TPlatformAndroid.HandleContentRectChanged(const App: TAndroidApplicationGlue; const ARect: TRect);
begin
TWindowManager.Current.ContentRect := ARect;
end;
procedure TPlatformAndroid.HandleApplicationCommandEvent(const App: TAndroidApplicationGlue; const ACommand: TAndroidApplicationCommand);
begin
case ACommand of
TAndroidApplicationCommand.Start:
begin
FRunning := True;
FTerminating := False;
end;
TAndroidApplicationCommand.Resume:
begin
TWindowManager.Current.Pause := False;
HandleApplicationEvent(TApplicationEvent.WillBecomeForeground);
end;
TAndroidApplicationCommand.Pause:
begin
TWindowManager.Current.Pause := True;
HandleApplicationEvent(TApplicationEvent.EnteredBackground);
end;
TAndroidApplicationCommand.InitWindow:
begin
if FFirstRun then
begin
Application.RealCreateForms;
FFirstRun := False;
HandleApplicationEvent(TApplicationEvent.FinishedLaunching);
end
else
Include(FPreviousActivityCommands, TAndroidApplicationCommand.InitWindow);
TWindowManager.Current.InitWindow;
end;
TAndroidApplicationCommand.TermWindow:
TWindowManager.Current.TermWindow;
TAndroidApplicationCommand.WindowRedrawNeeded:
TWindowManager.Current.SetNeedsRender;
TAndroidApplicationCommand.GainedFocus:
begin
Exclude(FPreviousActivityCommands, TAndroidApplicationCommand.LostFocus);
TWindowManager.Current.RenderImmediately;
HandleApplicationEvent(TApplicationEvent.BecameActive);
TWindowManager.Current.GainedFocus;
end;
TAndroidApplicationCommand.LostFocus:
begin
HandleApplicationEvent(TApplicationEvent.WillBecomeInactive);
FPreviousActivityCommands := [TAndroidApplicationCommand.LostFocus];
end;
TAndroidApplicationCommand.SaveState:
TMessageManager.DefaultManager.SendMessage(Self, TSaveStateMessage.Create);
TAndroidApplicationCommand.ConfigChanged:
begin
Include(FPreviousActivityCommands, TAndroidApplicationCommand.ConfigChanged);
CheckOrientationChange;
end;
TAndroidApplicationCommand.LowMemory:
PlatformAndroid.HandleApplicationEvent(TApplicationEvent.LowMemory);
TAndroidApplicationCommand.Destroy:
HandleApplicationEvent(TApplicationEvent.WillTerminate);
end;
end;
procedure TPlatformAndroid.RegisterServices;
begin
if not TPlatformServices.Current.SupportsPlatformService(IFMXApplicationService) then
TPlatformServices.Current.AddPlatformService(IFMXApplicationService, Self);
if not TPlatformServices.Current.SupportsPlatformService(IFMXApplicationEventService) then
TPlatformServices.Current.AddPlatformService(IFMXApplicationEventService, Self);
if not TPlatformServices.Current.SupportsPlatformService(IFMXWindowService) then
TPlatformServices.Current.AddPlatformService(IFMXWindowService, WindowManager);
if not TPlatformServices.Current.SupportsPlatformService(IFMXMouseService) then
TPlatformServices.Current.AddPlatformService(IFMXMouseService, MotionManager);
if not TPlatformServices.Current.SupportsPlatformService(IFMXGestureRecognizersService) then
TPlatformServices.Current.AddPlatformService(IFMXGestureRecognizersService, MotionManager);
if not TPlatformServices.Current.SupportsPlatformService(IFMXTextService) then
TPlatformServices.Current.AddPlatformService(IFMXTextService, FTextInputManager);
if (FVirtualKeyboardService <> nil) and not TPlatformServices.Current.SupportsPlatformService(IFMXKeyMappingService) then
TPlatformServices.Current.AddPlatformService(IFMXKeyMappingService, FTextInputManager);
end;
procedure TPlatformAndroid.UnbindAppGlueEvents;
var
AndroidAppGlue: TAndroidApplicationGlue;
begin
AndroidAppGlue := PANativeActivity(System.DelphiActivity)^.instance;
if AndroidAppGlue <> nil then
begin
AndroidAppGlue.OnApplicationCommandEvent := nil;
AndroidAppGlue.OnContentRectEvent := nil;
AndroidAppGlue.OnInputEvent := nil;
end;
end;
procedure TPlatformAndroid.UnregisterServices;
begin
TPlatformServices.Current.RemovePlatformService(IFMXApplicationService);
TPlatformServices.Current.RemovePlatformService(IFMXApplicationEventService);
TPlatformServices.Current.RemovePlatformService(IFMXWindowService);
TPlatformServices.Current.RemovePlatformService(IFMXMouseService);
TPlatformServices.Current.RemovePlatformService(IFMXGestureRecognizersService);
TPlatformServices.Current.RemovePlatformService(IFMXTextService);
TPlatformServices.Current.RemovePlatformService(IFMXKeyMappingService);
end;
{ TAndroidWindowHandle }
constructor TAndroidWindowHandle.Create(const AForm: TCommonCustomForm);
begin
inherited Create;
FNeedsUpdate := True;
FForm := AForm;
FBounds := TRectF.Create(AForm.Left, AForm.Top, AForm.Left + AForm.Width, AForm.Top + AForm.Height);
end;
procedure TAndroidWindowHandle.CreateTexture;
var
ScaledSize: TSize;
begin
if FTexture = nil then
begin
ScaledSize := TSize.Create(Round(Bounds.Width * TWindowManager.Current.Scale),
Round(Bounds.Height * TWindowManager.Current.Scale));
FTexture := TTexture.Create;
FTexture.Style := [TTextureStyle.RenderTarget];
FTexture.SetSize(ScaledSize.Width, ScaledSize.Height);
FTexture.Initialize;
end;
end;
procedure TAndroidWindowHandle.DestroyTexture;
begin
if FTexture <> nil then
begin
FTexture.DisposeOf;
FTexture := nil;
end;
end;
procedure TAndroidWindowHandle.SetBounds(const Value: TRectF);
begin
if FBounds <> Value then
begin
FBounds := Value;
if FForm <> nil then
FForm.SetBounds(Trunc(Value.Left), Trunc(Value.Top), Trunc(Value.Width), Trunc(Value.Height));
TWindowManager.Current.SetNeedsRender;
end;
end;
function TAndroidWindowHandle.GetBounds: TRectF;
begin
Result := FBounds;
end;
function TAndroidWindowHandle.GetIsPopup: Boolean;
begin
Result := PlatformAndroid.WindowManager.IsPopupForm(FForm);
end;
function TAndroidWindowHandle.GetScale: Single;
begin
Result := TWindowManager.Current.Scale;
end;
function TAndroidWindowHandle.RequiresComposition: Boolean;
begin
Result := PlatformAndroid.WindowManager.IsPopupForm(FForm) or (FForm.Transparency and (Application.MainForm <> FForm));
end;
procedure TAndroidWindowHandle.SetNeedsUpdate(const Value: Boolean);
begin
FNeedsUpdate := Value;
if FNeedsUpdate then
TWindowManager.Current.SetNeedsRender;
end;
{ TTextServiceAndroid }
constructor TTextServiceAndroid.Create(const Owner: IControl; SupportMultiLine: Boolean);
begin
FLines := TStringList.Create;
FComposingBegin := -1;
FComposingEnd := -1;
inherited Create(Owner, SupportMultiLine);
end;
destructor TTextServiceAndroid.Destroy;
begin
inherited;
end;
procedure TTextServiceAndroid.BeginSelection;
begin
TWindowManager.Current.BeginSelection;
TWindowManager.Current.HideContextMenu;
end;
procedure TTextServiceAndroid.EndSelection;
begin
TWindowManager.Current.EndSelection;
InternalUpdateSelection;
TWindowManager.Current.ShowContextMenu;
end;
function TTextServiceAndroid.CombinedText: string;
var
I, TextLength: Integer;
Builder: TStringBuilder;
begin
TextLength := 0;
for I := 0 to FLines.Count - 1 do
begin
if I > 0 then
Inc(TextLength);
Inc(TextLength, FLines[I].Length);
end;
Builder := TStringBuilder.Create(TextLength);
for I := 0 to FLines.Count - 1 do
begin
if I > 0 then
Builder.Append(FLines.LineBreak);
Builder.Append(FLines[I]);
end;
Result := Builder.ToString;
end;
procedure TTextServiceAndroid.CopySelectedText;
begin
if FTextView <> nil then
FTextView.copySelectedText;
end;
procedure TTextServiceAndroid.CutSelectedText;
begin
if FTextView <> nil then
FTextView.cutSelectedText;
end;
procedure TTextServiceAndroid.PasteText;
begin
if FTextView <> nil then
FTextView.pasteText;
end;
procedure TTextServiceAndroid.DrawSingleLine(const Canvas: TCanvas; const ARect: TRectF; const FirstVisibleChar: integer;
const Font: TFont; const AOpacity: Single; const Flags: TFillTextFlags; const ATextAlign: TTextAlign;
const AVTextAlign: TTextAlign = TTextAlign.Center; const AWordWrap: Boolean = False);
var
I, Shift: Integer;
S: string;
Layout: TTextLayout;
Region: TRegion;
begin
Layout := TTextLayoutManager.TextLayoutByCanvas(Canvas.ClassType).Create;
try
Layout.BeginUpdate;
Layout.TopLeft := ARect.TopLeft;
Layout.MaxSize := PointF(ARect.Width, ARect.Height);
Layout.WordWrap := AWordWrap;
Layout.HorizontalAlign := ATextAlign;
Layout.VerticalAlign := AVTextAlign;
Layout.Font := Font;
Layout.Color := Canvas.Fill.Color;
Layout.Opacity := AOpacity;
Layout.RightToLeft := TFillTextFlag.RightToLeft in Flags;
if FLines.Count > 0 then
S := FLines[FCaretPosition.Y]
else
S := '';
Layout.Text := S.Substring(FirstVisibleChar - 1, S.Length - FirstVisibleChar + 1);
Layout.EndUpdate;
Layout.RenderLayout(Canvas);
if (FComposingBegin >= 0) and (FComposingEnd >= 0) and (FComposingBegin < FComposingEnd) and IsFocused then
try
Shift := 0;
if FLines.Count > 0 then
for I := 0 to FCaretPosition.Y - 1 do
Inc(Shift, FLines[I].Length + FLines.LineBreak.Length);
Canvas.Stroke.Assign(Canvas.Fill);
Canvas.Stroke.Thickness := 1;
Canvas.Stroke.Dash := TStrokeDash.Solid;
Region := Layout.RegionForRange(TTextRange.Create(FComposingBegin - Shift - (FirstVisibleChar - 1), FComposingEnd - FComposingBegin));
for I := Low(Region) to High(Region) do
Canvas.DrawLine(
PointF(Region[I].Left, Region[I].Bottom),
PointF(Region[I].Right, Region[I].Bottom),
AOpacity, Canvas.Stroke);
finally
end;
finally
FreeAndNil(Layout);
end;
end;
procedure TTextServiceAndroid.DrawSingleLine(const Canvas: TCanvas; const S: string; const ARect: TRectF; const Font: TFont;
const AOpacity: Single; const Flags: TFillTextFlags; const ATextAlign: TTextAlign;
const AVTextAlign: TTextAlign = TTextAlign.Center; const AWordWrap: Boolean = False);
var
I: Integer;
Layout: TTextLayout;
Region: TRegion;
begin
Layout := TTextLayoutManager.TextLayoutByCanvas(Canvas.ClassType).Create;
try
Layout.BeginUpdate;
Layout.TopLeft := ARect.TopLeft;
Layout.MaxSize := PointF(ARect.Width, ARect.Height);
Layout.WordWrap := AWordWrap;
Layout.HorizontalAlign := ATextAlign;
Layout.VerticalAlign := AVTextAlign;
Layout.Font := Font;
Layout.Color := Canvas.Fill.Color;
Layout.Opacity := AOpacity;
Layout.RightToLeft := TFillTextFlag.RightToLeft in Flags;
Layout.Text := S;
Layout.EndUpdate;
Layout.RenderLayout(Canvas);
if (FComposingBegin >= 0) and (FComposingEnd >= 0) and (FComposingBegin < FComposingEnd) then
try
Canvas.Stroke.Assign(Canvas.Fill);
Canvas.Stroke.Thickness := 1;
Canvas.Stroke.Dash := TStrokeDash.Solid;
Region := Layout.RegionForRange(TTextRange.Create(FComposingBegin, FComposingEnd - FComposingBegin));
for I := Low(Region) to High(Region) do
Canvas.DrawLine(
PointF(Region[I].Left, Region[I].Bottom),
PointF(Region[I].Right, Region[I].Bottom),
AOpacity, Canvas.Stroke);
finally
end;
finally
FreeAndNil(Layout);
end;
end;
{ TFMXTextListener }
constructor TFMXTextListener.Create(const TextService: TTextServiceAndroid);
begin
inherited Create;
FTextService := TextService;
end;
procedure TFMXTextListener.onTextUpdated(text: JCharSequence; position: Integer);
begin
TWindowManager.Current.HideContextMenu;
FTextService.ProcessUpdate(position, JCharSequenceToStr(text));
PlatformAndroid.InternalProcessMessages;
end;
procedure TFMXTextListener.onComposingText(beginPosition: Integer; endPosition: Integer);
begin
TWindowManager.Current.HideContextMenu;
FTextService.FComposingBegin := beginPosition;
FTextService.FComposingEnd := endPosition;
end;
procedure TFMXTextListener.onSkipKeyEvent(event: JKeyEvent);
begin
PlatformAndroid.TextInputManager.SetKeyboardEventToSkip(event);
end;
procedure TTextServiceAndroid.EnterControl(const FormHandle: TWindowHandle);
var
VirtKBControl: IVirtualKeyboardControl;
KbType: Integer;
RKType: Integer;
SelStart, SelEnd: Integer;
ReadOnly, Password: Boolean;
LReadOnly: IReadOnly;
begin
if (FormHandle is TAndroidWindowHandle) and (TAndroidWindowHandle(FormHandle).Form.Focused <> nil) then
begin
if Supports(TAndroidWindowHandle(FormHandle).Form.Focused, IVirtualKeyboardControl, VirtKBControl) then
begin
TWindowManager.Current.FIsFirstSingleTap := True;
TWindowManager.Current.SetFocusedControl(TAndroidWindowHandle(FormHandle).Form.Focused);
case VirtKBControl.ReturnKeyType of
TReturnKeyType.Default:
RKType := TJFMXTextEditorProxy.JavaClass.ACTION_ENTER;
TReturnKeyType.Done:
RKType := TJFMXTextEditorProxy.JavaClass.ACTION_DONE;
TReturnKeyType.Go:
RKType := TJFMXTextEditorProxy.JavaClass.ACTION_GO;
TReturnKeyType.Next:
RKType := TJFMXTextEditorProxy.JavaClass.ACTION_NEXT;
TReturnKeyType.Search:
RKType := TJFMXTextEditorProxy.JavaClass.ACTION_SEARCH;
TReturnKeyType.Send:
RKType := TJFMXTextEditorProxy.JavaClass.ACTION_SEND;
else
RKType := TJFMXTextEditorProxy.JavaClass.ACTION_ENTER;
end;
case VirtKBControl.KeyboardType of
TVirtualKeyboardType.Default:
KbType := TJFMXTextEditorProxy.JavaClass.INPUT_TEXT;
TVirtualKeyboardType.NumbersAndPunctuation:
KbType := TJFMXTextEditorProxy.JavaClass.INPUT_NUMBER_AND_PUNCTUATION;
TVirtualKeyboardType.NumberPad:
KbType := TJFMXTextEditorProxy.JavaClass.INPUT_NUMBER;
TVirtualKeyboardType.PhonePad:
KbType := TJFMXTextEditorProxy.JavaClass.INPUT_PHONE;
TVirtualKeyboardType.Alphabet:
KbType := TJFMXTextEditorProxy.JavaClass.INPUT_ALPHABET;
TVirtualKeyboardType.URL:
KbType := TJFMXTextEditorProxy.JavaClass.INPUT_URL;
TVirtualKeyboardType.NamePhonePad:
KbType := TJFMXTextEditorProxy.JavaClass.INPUT_NAME_PHONE_PAD;
TVirtualKeyboardType.EmailAddress:
KbType := TJFMXTextEditorProxy.JavaClass.INPUT_EMAIL_ADDRESS;
TVirtualKeyboardType.DecimalNumberPad:
KbType := TJFMXTextEditorProxy.JavaClass.INPUT_NUMBER_DECIMAL;
else
KbType := TJFMXTextEditorProxy.JavaClass.INPUT_TEXT;
end;
Password := VirtKBControl.IsPassword;
end
else
begin
KbType := TJFMXTextEditorProxy.JavaClass.INPUT_TEXT;
RKType := TJFMXTextEditorProxy.JavaClass.ACTION_ENTER;
Password := False;
end;
if Supports(TAndroidWindowHandle(FormHandle).Form.Focused, IReadOnly, LReadOnly) then
try
ReadOnly := LReadOnly.ReadOnly;
finally
LReadOnly := nil;
end
else
ReadOnly := True;
if FTextView = nil then
FTextView := PlatformAndroid.TextInputManager.GetTextEditorProxy;
if FTextView <> nil then
begin
if FTextListener = nil then
FTextListener := TFMXTextListener.Create(Self);
CalculateSelectionBounds(SelStart, SelEnd);
FTextView.setMaxLength(MaxLength);
case CharCase of
TEditCharCase.ecUpperCase:
FTextView.setCharCase(TJFMXTextEditorProxy.JavaClass.CHARCASE_UPPER);
TEditCharCase.ecLowerCase:
FTextView.setCharCase(TJFMXTextEditorProxy.JavaClass.CHARCASE_LOWER);
else
FTextView.setCharCase(TJFMXTextEditorProxy.JavaClass.CHARCASE_NORMAL);
end;
FTextView.setFilterChar(StrToJCharSequence(FilterChar));
FTextView.setMultiline(MultiLine);
FTextView.setReadOnly(ReadOnly);
FTextView.setInputType(KbType);
FTextView.setIsPassword(Password);
FTextView.setText(StrToJCharSequence(FText));
FTextView.setEnterAction(RKType);
if SelEnd - SelStart > 0 then
FTextView.setSelection(SelStart, SelEnd)
else
FTextView.setCursorPosition(CaretPosition.X);
FTextView.addTextListener(FTextListener);
MainActivity.getViewStack.addView(nil);
FTextView.setFocusableInTouchMode(true);
FTextView.requestFocus;
FTextView.showSoftInput(True);
end;
TMessageManager.DefaultManager.SubscribeToMessage(TVKStateChangeMessage, HandleVK);
end;
end;
procedure TTextServiceAndroid.ExitControl(const FormHandle: TWindowHandle);
begin
TMessageManager.DefaultManager.Unsubscribe(TVKStateChangeMessage, HandleVK);
if (FTextView <> nil) and (FTextListener <> nil) then
begin
FComposingBegin := -1;
FComposingEnd := -1;
FTextView.setCursorPosition(FCaretPosition.X);
FTextView.removeTextListener(FTextListener);
FTextView.clearFocus;
FTextView := nil;
TWindowManager.Current.HideContextMenu;
FTextListener := nil;
end;
end;
function TTextServiceAndroid.GetCaretPostion: TPoint;
begin
Result := FCaretPosition;
end;
procedure TTextServiceAndroid.SetCaretPosition(const Value: TPoint);
var
SelStart, SelEnd: Integer;
begin
FCaretPosition := Value;
CalculateSelectionBounds(SelStart, SelEnd);
if (FTextView <> nil) and not FInternalUpdate then
if (SelEnd - SelStart) > 0 then
FTextView.setSelection(SelStart, SelEnd)
else
FTextView.setCursorPosition(CaretPosition.X);
end;
procedure TTextServiceAndroid.SetMaxLength(const Value: Integer);
begin
inherited;
if FTextView <> nil then
FTextView.setMaxLength(Value);
end;
procedure TTextServiceAndroid.SetCharCase(const Value: TEditCharCase);
begin
inherited;
if FTextView <> nil then
case Value of
TEditCharCase.ecUpperCase:
FTextView.setCharCase(TJFMXTextEditorProxy.JavaClass.CHARCASE_UPPER);
TEditCharCase.ecLowerCase:
FTextView.setCharCase(TJFMXTextEditorProxy.JavaClass.CHARCASE_LOWER);
else
FTextView.setCharCase(TJFMXTextEditorProxy.JavaClass.CHARCASE_NORMAL);
end;
end;
procedure TTextServiceAndroid.SetFilterChar(const Value: string);
begin
inherited;
if FTextView <> nil then
FTextView.setFilterChar(StrToJCharSequence(Value));
end;
function TTextServiceAndroid.GetText: string;
begin
Result := FText;
end;
procedure TTextServiceAndroid.SetText(const Value: string);
begin
if not SameStr(FText, Value) then
begin
FText := Value;
UnpackText;
if FTextView <> nil then
FTextView.setText(StrToJCharSequence(Value));
end;
end;
procedure TTextServiceAndroid.HandleVK(const Sender: TObject; const M: TMessage);
var
VirtKBControl: IVirtualKeyboardControl;
KbType: Integer;
RKType: Integer;
LReadOnly: IReadOnly;
ReadOnly, Password: Boolean;
begin
if (FTextView <> nil) and (Screen.ActiveForm <> nil) and (Screen.ActiveForm.Focused <> nil) and
TVKStateChangeMessage(M).KeyboardVisible then
begin
if Supports(Screen.ActiveForm.Focused, IVirtualKeyboardControl, VirtKBControl) then
begin
case VirtKBControl.ReturnKeyType of
TReturnKeyType.Default:
RKType := TJFMXTextEditorProxy.JavaClass.ACTION_ENTER;
TReturnKeyType.Done:
RKType := TJFMXTextEditorProxy.JavaClass.ACTION_DONE;
TReturnKeyType.Go:
RKType := TJFMXTextEditorProxy.JavaClass.ACTION_GO;
TReturnKeyType.Next:
RKType := TJFMXTextEditorProxy.JavaClass.ACTION_NEXT;
TReturnKeyType.Search:
RKType := TJFMXTextEditorProxy.JavaClass.ACTION_SEARCH;
TReturnKeyType.Send:
RKType := TJFMXTextEditorProxy.JavaClass.ACTION_SEND;
else
RKType := TJFMXTextEditorProxy.JavaClass.ACTION_ENTER;
end;
case VirtKBControl.KeyboardType of
TVirtualKeyboardType.Default:
KbType := TJFMXTextEditorProxy.JavaClass.INPUT_TEXT;
TVirtualKeyboardType.NumbersAndPunctuation:
KbType := TJFMXTextEditorProxy.JavaClass.INPUT_NUMBER_AND_PUNCTUATION;
TVirtualKeyboardType.NumberPad:
KbType := TJFMXTextEditorProxy.JavaClass.INPUT_NUMBER;
TVirtualKeyboardType.PhonePad:
KbType := TJFMXTextEditorProxy.JavaClass.INPUT_PHONE;
TVirtualKeyboardType.Alphabet:
KbType := TJFMXTextEditorProxy.JavaClass.INPUT_ALPHABET;
TVirtualKeyboardType.URL:
KbType := TJFMXTextEditorProxy.JavaClass.INPUT_URL;
TVirtualKeyboardType.NamePhonePad:
KbType := TJFMXTextEditorProxy.JavaClass.INPUT_NAME_PHONE_PAD;
TVirtualKeyboardType.EmailAddress:
KbType := TJFMXTextEditorProxy.JavaClass.INPUT_EMAIL_ADDRESS;
TVirtualKeyboardType.DecimalNumberPad:
KbType := TJFMXTextEditorProxy.JavaClass.INPUT_NUMBER_DECIMAL;
else
KbType := TJFMXTextEditorProxy.JavaClass.INPUT_TEXT;
end;
Password := VirtKBControl.IsPassword;
end
else
begin
KbType := TJFMXTextEditorProxy.JavaClass.INPUT_TEXT;
RKType := TJFMXTextEditorProxy.JavaClass.ACTION_ENTER;
Password := False;
end;
if Supports(Screen.ActiveForm.Focused, IReadOnly, LReadOnly) then
try
ReadOnly := LReadOnly.ReadOnly;
finally
LReadOnly := nil;
end
else
ReadOnly := False;
FTextView.setReadOnly(ReadOnly);
FTextView.setInputType(KbType);
FTextView.setIsPassword(Password);
FTextView.setEnterAction(RKType);
end;
end;
function TTextServiceAndroid.HasMarkedText: Boolean;
begin
Result := (FComposingBegin >= 0) and (FComposingEnd >= 0) and (FComposingBegin < FComposingEnd);
end;
function TTextServiceAndroid.GetImeMode: TImeMode;
begin
Result := FImeMode;
end;
procedure TTextServiceAndroid.CalculateSelectionBounds(out SelectionStart, SelectionEnd: Integer);
var
TextInput: ITextInput;
I: Integer;
SelBounds: TRect;
TopLeft, BottomRight: TPoint;
begin
if (FLines <> nil) and Supports(Owner, ITextInput, TextInput) then
begin
if FLines.Count > 0 then
begin
SelBounds := TextInput.GetSelectionBounds;
if (SelBounds.Top > SelBounds.Bottom) or ((SelBounds.Height = 0) and (SelBounds.Left > SelBounds.Right)) then
begin
TopLeft := SelBounds.BottomRight;
BottomRight := SelBounds.TopLeft;
end
else
begin
TopLeft := SelBounds.TopLeft;
BottomRight := SelBounds.BottomRight;
end;
SelectionStart := TopLeft.X;
for I := 0 to Min(TopLeft.Y - 1, FLines.Count - 1) do
Inc(SelectionStart, FLines[I].Length + FLines.LineBreak.Length);
SelectionEnd := SelBounds.Right + (SelectionStart - SelBounds.Left);
for I := Min(TopLeft.Y, FLines.Count - 1) to Min(BottomRight.Y - 1, FLines.Count - 1) do
Inc(SelectionEnd, FLines[I].Length + FLines.LineBreak.Length);
end
else
begin
SelectionStart := Min(SelBounds.Left, SelBounds.Right);
SelectionEnd := Max(SelBounds.Left, SelBounds.Right);
end
end
else
begin
SelectionStart := FCaretPosition.X;
SelectionEnd := FCaretPosition.X;
end;
end;
procedure TTextServiceAndroid.SetImeMode(const Value: TImeMode);
begin
FImeMode := Value;
end;
procedure TTextServiceAndroid.InternalUpdate;
begin
FInternalUpdate := True;
try
(Owner as ITextInput).IMEStateUpdated;
finally
FInternalUpdate := False;
end;
end;
procedure TTextServiceAndroid.InternalUpdateSelection;
var
SelStart, SelEnd: Integer;
begin
CalculateSelectionBounds(SelStart, SelEnd);
if FTextView <> nil then
FTextView.setSelection(SelStart, SelEnd);
end;
function TTextServiceAndroid.IsFocused: Boolean;
begin
Result := False;
if FTextView <> nil then
Result := FTextView.isFocused;
end;
procedure TTextServiceAndroid.ProcessUpdate(const APos: Integer; AText: string);
begin
FText := AText;
UnpackText;
FCaretPosition.X := APos;
PostProcessUpdate;
end;
procedure TTextServiceAndroid.PostProcessUpdate;
begin
InternalUpdate;
end;
function TTextServiceAndroid.TargetClausePosition: TPoint;
begin
Result := CaretPosition;
end;
procedure TTextServiceAndroid.UnpackText;
var
HeaderBegin, HeaderEnd: Integer;
LinesLength: TArray<string>;
I, LineLength, LengthBefore: Integer;
begin
FLines.Clear;
HeaderBegin := FText.IndexOf('[');
HeaderEnd := FText.IndexOf(']');
if not FText.IsEmpty and (HeaderBegin >= 0) and (HeaderEnd > 0) then
begin
LinesLength := FText.Substring(HeaderBegin + 1, HeaderEnd - HeaderBegin - 1).Split([',']);
LengthBefore := 0;
for I := 0 to Length(LinesLength) - 1 do
begin
LineLength := StrToInt(LinesLength[I]);
if LineLength > 0 then
FLines.Add(FText.Substring(HeaderEnd + 1 + LengthBefore, LineLength))
else
FLines.Add(string.Empty);
Inc(LengthBefore, LineLength);
end;
end;
end;
{ TFMXNativeActivityListener }
procedure TFMXNativeActivityListener.onCancelReceiveImage(ARequestCode: Integer);
begin
TThread.Queue(nil, procedure
begin
TMessageManager.DefaultManager.SendMessage(nil, TMessageCancelReceivingImage.Create(ARequestCode));
end);
end;
procedure TFMXNativeActivityListener.onReceiveImagePath(ARequestCode: Integer; AFileName: JString);
var
Message: TMessageReceivedImagePath;
begin
TThread.Queue(nil, procedure
var
ImageFileName: string;
begin
ImageFileName := JStringToString(AFileName);
Message := TMessageReceivedImagePath.Create(ImageFileName);
Message.RequestCode := ARequestCode;
TMessageManager.DefaultManager.SendMessage(nil, Message);
end);
end;
procedure TFMXNativeActivityListener.onReceiveNotification(P1: JIntent);
begin
TMessageManager.DefaultManager.SendMessage(nil, TMessageReceivedNotification.Create(P1));
end;
procedure TFMXNativeActivityListener.onReceiveResult(ARequestCode, AResultCode: Integer; AResultObject: JIntent);
var
Msg: TMessageResultNotification;
begin
Msg := TMessageResultNotification.Create(AResultObject);
Msg.RequestCode := ARequestCode;
Msg.ResultCode := AResultCode;
TMessageManager.DefaultManager.SendMessage(nil, Msg);
end;
function ConvertPixelToPoint(const P: TPointF): TPointF;
begin
Result := TWindowManager.Current.PixelToPoint(P);
end;
function ConvertPointToPixel(const P: TPointF): TPointF;
begin
Result := TWindowManager.Current.PointToPixel(P);
end;
{ TAndroidMotionManager }
procedure TAndroidMotionManager.AddRecognizer(const AGesture: TInteractiveGesture; const AForm: TCommonCustomForm);
begin
Include(FEnabledInteractiveGestures, AGesture);
end;
constructor TAndroidMotionManager.Create;
begin
inherited;
FMotionEvents := TMotionEvents.Create;
end;
procedure TAndroidMotionManager.CreateDoubleTapTimer;
begin
if FDoubleTapTimer = 0 then
FDoubleTapTimer := PlatformAndroid.TimerManager.CreateTimer(DblTapDelay, DoubleTapTimerCall);
end;
function TAndroidMotionManager.CreateGestureEventInfo(ASecondPointer: TPointF; const AGesture: TInteractiveGesture;
const AGestureEnded: Boolean): TGestureEventInfo;
begin
FillChar(Result, Sizeof(Result), 0);
Result.Location := FMouseCoord;
Result.GestureID := igiZoom + Ord(AGesture);
if not(AGesture in FActiveInteractiveGestures) then
Result.Flags := [TInteractiveGestureFlag.gfBegin];
if AGestureEnded then
Result.Flags := [TInteractiveGestureFlag.gfEnd];
if AGesture = TInteractiveGesture.LongTap then
Result.Location := FMouseDownCoordinates;
end;
procedure TAndroidMotionManager.CreateLongTapTimer;
begin
if FLongTapTimer = 0 then
FLongTapTimer := PlatformAndroid.TimerManager.CreateTimer(LongTapDuration, LongTapTimerCall);
end;
procedure TAndroidMotionManager.CreateSingleTapTimer;
begin
if FSingleTapTimer = 0 then
FSingleTapTimer := PlatformAndroid.TimerManager.CreateTimer(SingleTapDelay, SingleTapTimerCall);
end;
destructor TAndroidMotionManager.Destroy;
begin
DestroyDoubleTapTimer;
DestroyLongTapTimer;
DestroySingleTapTimer;
FMotionEvents.Free;
inherited;
end;
procedure TAndroidMotionManager.DestroyDoubleTapTimer;
begin
if FDoubleTapTimer <> 0 then
PlatformAndroid.TimerManager.DestroyTimer(FDoubleTapTimer);
FDoubleTapTimer := 0;
FDblClickFirstMouseUp := False;
end;
procedure TAndroidMotionManager.DestroyLongTapTimer;
begin
if FLongTapTimer <> 0 then
PlatformAndroid.TimerManager.DestroyTimer(FLongTapTimer);
FLongTapTimer := 0;
end;
procedure TAndroidMotionManager.DestroySingleTapTimer;
begin
if FSingleTapTimer <> 0 then
PlatformAndroid.TimerManager.DestroyTimer(FSingleTapTimer);
FSingleTapTimer := 0;
FSingletap := False;
end;
procedure TAndroidMotionManager.DoubleTapTimerCall;
begin
//no double tap was made
DestroyDoubleTapTimer;
end;
function TAndroidMotionManager.GetLongTapAllowedMovement: Single;
begin
Result := LongTapMovement / TWindowManager.Current.Scale;
end;
function TAndroidMotionManager.GetMousePos: TPointF;
begin
Result := FMouseCoord;
end;
function TAndroidMotionManager.HandleAndroidMotionEvent(AEvent: PAInputEvent): Int32;
var
I: Integer;
MotionEvent: TMotionEvent;
begin
Result := 0;
FMotionEvents.Clear;
for I := 0 to AMotionEvent_getPointerCount(AEvent) - 1 do
begin
MotionEvent.EventAction := AKeyEvent_getAction(AEvent) and AMOTION_EVENT_ACTION_MASK;
MotionEvent.Position := TWindowManager.Current.PixelToPoint(TPointF.Create(AMotionEvent_getX(AEvent, I),
AMotionEvent_getY(AEvent, I)));
MotionEvent.Shift := [ssLeft];
if AInputEvent_getType(AEvent) <> AINPUT_SOURCE_MOUSE then
Include(MotionEvent.Shift, ssTouch);
FMotionEvents.Add(MotionEvent);
end;
HandleMultiTouch;
if (FActiveInteractiveGestures = []) or (FActiveInteractiveGestures = [TInteractiveGesture.Pan]) then
ProcessAndroidMouseEvents;
ProcessAndroidGestureEvents;
end;
procedure TAndroidMotionManager.HandleMultiTouch;
var
Touches: TTouches;
TouchAction: TTouchAction;
I: Integer;
begin
if FMotionEvents.Count > 0 then
begin
SetLength(Touches, FMotionEvents.Count);
for I := 0 to FMotionEvents.Count - 1 do
Touches[I].Location := FMotionEvents[I].Position;
case FMotionEvents[0].EventAction of
AMOTION_EVENT_ACTION_DOWN:
TouchAction := TTouchAction.Down;
AMOTION_EVENT_ACTION_UP:
TouchAction := TTouchAction.Up;
AMOTION_EVENT_ACTION_MOVE:
TouchAction := TTouchAction.Move;
AMOTION_EVENT_ACTION_CANCEL:
TouchAction := TTouchAction.Cancel;
AMOTION_EVENT_ACTION_POINTER_DOWN:
TouchAction := TTouchAction.Down;
AMOTION_EVENT_ACTION_POINTER_UP:
TouchAction := TTouchAction.Up;
else
begin
TouchAction := TTouchAction.None;
end;
end;
TWindowManager.Current.MultiTouch(Touches, TouchAction, FEnabledInteractiveGestures);
end;
end;
procedure TAndroidMotionManager.LongTapTimerCall;
begin
//a long press was recognized
DestroyLongTapTimer;
DestroySingleTapTimer;
TWindowManager.Current.SendCMGestureMessage(CreateGestureEventInfo(PointF(0, 0), TInteractiveGesture.LongTap));
end;
procedure TAndroidMotionManager.ProcessAndroidGestureEvents;
var
SecondPointer: TPointF;
begin
if FMotionEvents.Count < 1 then
Exit;
FMouseCoord := FMotionEvents[0].Position;
if FMotionEvents.Count > 1 then
SecondPointer := FMotionEvents[1].Position
else
SecondPointer := TPointF.Zero;
case (FMotionEvents[0].EventAction and AMOTION_EVENT_ACTION_MASK) of
AMOTION_EVENT_ACTION_DOWN:
begin
if FSingleTapTimer <> 0 then
DestroySingleTapTimer
else
FSingleTap := True;
if FDoubleTapTimer = 0 then
if (TInteractiveGesture.DoubleTap in FEnabledInteractiveGestures) and (FMotionEvents.Count = 1) then
CreateDoubleTapTimer;
if (TInteractiveGesture.LongTap in FEnabledInteractiveGestures) and (FMotionEvents.Count = 1) then
CreateLongTapTimer;
end;
AMOTION_EVENT_ACTION_UP:
begin
if FSingleTap then
CreateSingleTapTimer;
if FDoubleTapTimer <> 0 then
if not FDblClickFirstMouseUp then
FDblClickFirstMouseUp := True
else
begin
DestroyDoubleTapTimer;
FDblClickFirstMouseUp := False;
TWindowManager.Current.SendCMGestureMessage(CreateGestureEventInfo(TPointF.Zero,
TInteractiveGesture.DoubleTap));
end;
//stop longtap timer
DestroyLongTapTimer;
end;
AMOTION_EVENT_ACTION_MOVE:
begin
// Stop longtap and double tap timers only if the coordinates did not change (much) since the last event.
// Allow for some slight finger movement.
if FMotionEvents.Count = 1 then
begin
if FMouseCoord.Distance(FMouseDownCoordinates) > GetLongTapAllowedMovement then
begin
DestroySingleTapTimer;
end;
if FMouseCoord.Distance(FOldPoint1) > GetLongTapAllowedMovement then
begin
DestroyLongTapTimer;
DestroyDoubleTapTimer;
end;
FOldPoint2 := TPointF.Zero;
end;
end;
AMOTION_EVENT_ACTION_CANCEL:
begin
DestroyLongTapTimer;
DestroyDoubleTapTimer;
DestroySingleTapTimer;
FActiveInteractiveGestures := [];
FRotationAngle := 0;
FOldPoint1 := TPointF.Zero;
FOldPoint2 := TPointF.Zero;
FMouseDownCoordinates := TPointF.Zero;
end;
AMOTION_EVENT_ACTION_POINTER_DOWN:
begin
//stop timers
DestroyLongTapTimer;
DestroyDoubleTapTimer;
DestroySingleTapTimer;
if FMotionEvents.Count = 2 then
FOldPoint2 := SecondPointer;
end;
AMOTION_EVENT_ACTION_POINTER_UP:
begin
//from 2 pointers now, there will be only 1 pointer
if FMotionEvents.Count = 2 then
FOldPoint2 := TPointF.Zero;
end;
end;
FOldPoint1 := FMotionEvents[0].Position;
FOldPoint2 := SecondPointer;
end;
procedure TAndroidMotionManager.ProcessAndroidMouseEvents;
var
MotionEvent: TMotionEvent;
begin
if FMotionEvents.Count > 0 then
begin
MotionEvent := FMotionEvents[0];
case MotionEvent.EventAction of
AMOTION_EVENT_ACTION_DOWN:
begin
TWindowManager.Current.MouseDown(TMouseButton.mbLeft, MotionEvent.Shift, MotionEvent.Position.X, MotionEvent.Position.Y);
FMouseDownCoordinates := MotionEvent.Position;
end;
AMOTION_EVENT_ACTION_UP:
begin
TWindowManager.Current.MouseUp(TMouseButton.mbLeft, MotionEvent.Shift, MotionEvent.Position.X, MotionEvent.Position.Y, not FGestureEnded);
FGestureEnded := False;
end;
AMOTION_EVENT_ACTION_MOVE:
TWindowManager.Current.MouseMove(MotionEvent.Shift, MotionEvent.Position.X, MotionEvent.Position.Y);
end;
FMouseCoord := MotionEvent.Position;
end;
end;
procedure TAndroidMotionManager.RemoveRecognizer(const AGesture: TInteractiveGesture; const AForm: TCommonCustomForm);
begin
Exclude(FEnabledInteractiveGestures, AGesture);
end;
procedure TAndroidMotionManager.SingleTap;
begin
TWindowManager.Current.SingleTap;
end;
procedure TAndroidMotionManager.SingleTapTimerCall;
begin
DestroySingleTapTimer;
SingleTap;
end;
{ TAndroidTextInputManager }
constructor TAndroidTextInputManager.Create;
var
InputDeviceID: Integer;
begin
inherited;
TPlatformServices.Current.SupportsPlatformService(IFMXVirtualKeyboardService, FVirtualKeyboard);
FKeyMapping := TKeyMapping.Create;
FSkipEventQueue := TQueue<JKeyEvent>.Create;
if TOSVersion.Check(3, 0) then
InputDeviceID := TJKeyCharacterMap.JavaClass.VIRTUAL_KEYBOARD
else
InputDeviceID := TJKeyCharacterMap.JavaClass.BUILT_IN_KEYBOARD;
FKeyCharacterMap := TJKeyCharacterMap.JavaClass.load(InputDeviceID);
end;
destructor TAndroidTextInputManager.Destroy;
begin
FSkipEventQueue.Free;
FKeyMapping.Free;
inherited;
end;
function TAndroidTextInputManager.GetTextEditorProxy: JFmxTextEditorProxy;
begin
if FTextEditorProxy = nil then
FTextEditorProxy := MainActivity.getTextEditorProxy;
Result := FTextEditorProxy;
end;
function TAndroidTextInputManager.GetTextServiceClass: TTextServiceClass;
begin
Result := TTextServiceAndroid;
end;
function TAndroidTextInputManager.HandleAndroidKeyEvent(AEvent: PAInputEvent): Int32;
var
KeyCode, vkKeyCode: Word;
Action, MetaState: Integer;
KeyChar: Char;
KeyEvent: JKeyEvent;
KeyEventChars: string;
C: WideChar;
SkipEvent: JKeyEvent;
LKeyDownHandled: Boolean;
KeyKind: TKeyKind;
EventTime, DownTime: Int64;
DeviceId: Integer;
begin
Result := 0;
Action := AKeyEvent_getAction(AEvent);
KeyCode := AKeyEvent_getKeyCode(AEvent);
MetaState := AKeyEvent_getMetaState(AEvent);
EventTime := AKeyEvent_getEventTime(AEvent) div 1000000;
DownTime := AKeyEvent_getDownTime(AEvent) div 1000000;
DeviceId := AInputEvent_getDeviceId(AEvent);
if FSkipEventQueue.Count > 0 then
SkipEvent := FSkipEventQueue.Peek
else
SkipEvent := nil;
if (SkipEvent <> nil) and ((SkipEvent.getEventTime < EventTime) or (SkipEvent.getDownTime < DownTime)) then
begin
SkipEvent := nil;
FSkipEventQueue.Dequeue;
end;
if (SkipEvent = nil) or (SkipEvent.getAction <> Action) or (SkipEvent.getFlags <> AKeyEvent_getFlags(AEvent)) or
(SkipEvent.getKeyCode <> KeyCode) or (SkipEvent.getMetaState <> MetaState) or (SkipEvent.getEventTime <> EventTime) or
(SkipEvent.getDownTime <> DownTime) then
begin
KeyChar := #0;
vkKeyCode := PlatformKeyToVirtualKey(KeyCode, KeyKind);
if (vkKeyCode <> 0) and (KeyKind <> TKeyKind.Usual) then
begin
KeyCode := vkKeyCode;
if KeyCode in [vkEscape] then
KeyChar := Char(KeyCode);
end
else
begin
if FKeyCharacterMap <> nil then
begin
KeyChar := Char(ObtainKeyCharacterMap(DeviceId).get(KeyCode, MetaState));
if KeyChar <> #0 then
KeyCode := 0
else
KeyCode := vkKeyCode;
end;
end;
case AKeyEvent_getAction(AEvent) of
AKEY_EVENT_ACTION_DOWN:
begin
if (KeyCode = vkHardwareBack) and (KeyChar = #0) and (FVirtualKeyboard <> nil) and
(FVirtualKeyboard.VirtualKeyboardState * [TVirtualKeyboardState.Visible] <> []) then
begin
FDownKey := 0;
FDownKeyChar := #0;
end
else
begin
FDownKey := KeyCode;
FDownKeyChar := KeyChar;
TWindowManager.Current.KeyDown(KeyCode, KeyChar, ShiftStateFromMetaState(MetaState));
end;
FKeyDownHandled := (KeyCode = 0) and (KeyChar = #0);
if FKeyDownHandled then
Result := 1;
end;
AKEY_EVENT_ACTION_UP:
begin
LKeyDownHandled := (FDownKey = KeyCode) and (FDownKeyChar = KeyChar) and FKeyDownHandled;
TWindowManager.Current.KeyUp(KeyCode, KeyChar, ShiftStateFromMetaState(MetaState), LKeyDownHandled);
if (KeyCode = 0) and (KeyChar = #0) then
Result := 1; // indicate that we have handled the event
end;
AKEY_EVENT_ACTION_MULTIPLE:
begin
KeyEvent := JFMXNativeActivity(MainActivity).getLastEvent;
if KeyEvent <> nil then
begin
KeyEventChars := JStringToString(KeyEvent.getCharacters);
KeyCode := 0;
for C in KeyEventChars do
begin
FDownKey := KeyCode;
FDownKeyChar := C;
TWindowManager.Current.KeyDown(KeyCode, FDownKeyChar, ShiftStateFromMetaState(MetaState));
FKeyDownHandled := (KeyCode = 0) and (FDownKeyChar = #0);
end;
Result := 1;
end;
end;
end;
end
else
FSkipEventQueue.Dequeue;
end;
function TAndroidTextInputManager.ObtainKeyCharacterMap(DeviceId: Integer): JKeyCharacterMap;
begin
Result := TJKeyCharacterMap.JavaClass.load(DeviceId)
end;
function TAndroidTextInputManager.PlatformKeyToVirtualKey(const PlatformKey: Word; var KeyKind: TKeyKind): Word;
begin
Result := FKeyMapping.PlatformKeyToVirtualKey(PlatformKey, KeyKind);
end;
function TAndroidTextInputManager.RegisterKeyMapping(const PlatformKey, VirtualKey: Word;
const KeyKind: TKeyKind): Boolean;
begin
Result := FKeyMapping.RegisterKeyMapping(PlatformKey, VirtualKey, KeyKind);
end;
procedure TAndroidTextInputManager.SetKeyboardEventToSkip(event: JKeyEvent);
begin
FSkipEventQueue.Enqueue(event);
end;
function TAndroidTextInputManager.ShiftStateFromMetaState(const AMetaState: Integer): TShiftState;
begin
Result := [];
if (AMetaState and AMETA_SHIFT_ON) > 0 then
Result := Result + [ssShift];
if (AMetaState and AMETA_ALT_ON) > 0 then
Result := Result + [ssAlt];
end;
function TAndroidTextInputManager.UnregisterKeyMapping(const PlatformKey: Word): Boolean;
begin
Result := FKeyMapping.UnregisterKeyMapping(PlatformKey);
end;
function TAndroidTextInputManager.VirtualKeyToPlatformKey(const VirtualKey: Word): Word;
begin
Result := FKeyMapping.VirtualKeyToPlatformKey(VirtualKey);
end;
{ TPlatformAndroid.TMessageQueueIdleHandler }
constructor TPlatformAndroid.TMessageQueueIdleHandler.Create(APlatform: TPlatformAndroid);
begin
inherited Create;
FPlatform := APlatform;
end;
function TPlatformAndroid.TMessageQueueIdleHandler.queueIdle: Boolean;
begin
Result := True;
if not FPlatform.Terminating then
FPlatform.InternalProcessMessages;
end;
end.
| 32.388742 | 155 | 0.742955 |
Subsets and Splits
HTML Code Excluding Scripts
The query retrieves a limited set of HTML content entries that are longer than 8 characters and do not contain script tags, offering only basic filtering with minimal analytical value.