text stringlengths 14 6.51M |
|---|
unit evdTextStyle_Const;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Библиотека "EVD"
// Автор: Люлин А.В.
// Модуль: "w:/common/components/rtl/Garant/EVD/evdTextStyle_Const.pas"
// Начат: 07.06.2008 19:47
// Родные Delphi интерфейсы (.pas)
// Generated from UML model, root element: <<Tag::Class>> Shared Delphi::EVD::Standard::evdNative::TextStyle
//
// Стиль оформления текста
//
//
// Все права принадлежат ООО НПП "Гарант-Сервис".
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Константы для значений тега TextStyle - "Стиль оформления текста".
// ! Полностью генерируется с модели. Править руками - нельзя. !
{$Include ..\EVD\evdDefine.inc}
interface
uses
k2Base {a},
evdStyles
;
const
k2_idTextStyle = 39;
var k2_idTextStyle_Header : Integer = -1;
var k2_idTextStyle_Footer : Integer = -1;
function k2_typTextStyle: Tk2Type;
const
evd_saTxtNormalANSI = -1;
{ Нормальный }
evd_saObject = -35;
{ псевдо-стиль, для объектных сегментов }
evd_saMistake = -36;
{ Слово с опечаткой }
evd_saColorSelection = -10;
{ Цветовое выделение }
evd_saHyperLink = -8;
{ Гипертекстовая ссылка }
evd_saInterface = -38;
{ Стиль для интерфейсных элементов }
evd_saActiveHyperLink = -39;
{ Активная гиперссылка }
evd_saNormalTable = -17;
{ Нормальный для таблиц }
evd_saCenteredTable = -40;
{ Центрированный в таблице }
evd_saColorSelectionForBaseSearch = -51;
{ Выделение для Базового Поиска }
evd_saItalicColorSelectionForBaseSearch = evdStyles.ev_saItalicColorSelectionForBaseSearch;
{ Выделение для Базового Поиска (курсив) }
evd_saDialogs = evdStyles.ev_saDialogs;
{ Текст диалогов }
evd_saTOC = evdStyles.ev_saTOC;
{ }
evd_saAttention = evdStyles.ev_saAttention;
{ Внимание }
evd_saWriteToUs = evdStyles.ev_saWriteToUs;
{ Напишите нам }
//#UC START# *484D2CBA0213const_intf*
const
evd_saGUI =
{$IfDef Archi}
evd_saInterface
{$Else Archi}
//evd_saTxtNormalANSI
evd_saInterface
// http://mdp.garant.ru/pages/viewpage.action?pageId=96475831
{$EndIf Archi};
//#UC END# *484D2CBA0213const_intf*
implementation
uses
evdNative_Schema,
k2Facade {a}
;
var
g_TextStyle : Tk2Type = nil;
// start class TextStyleTag
function k2_typTextStyle: Tk2Type;
begin
if (g_TextStyle = nil) then
begin
Assert(Tk2TypeTable.GetInstance Is TevdNativeSchema);
g_TextStyle := TevdNativeSchema(Tk2TypeTable.GetInstance).t_TextStyle;
end;//g_TextStyle = nil
Result := g_TextStyle;
end;
end. |
unit uTestePai;
interface
uses
System.SysUtils, IBX.IBquery;
type
TTestePai = class
private
nome : String;
data_nascimento : TDate;
data_cadastro : TDate;
protected
{ protected declarations }
public
{ public declarations }
function Getnome : String;
function Getdata_nascimento : TDate;
function Getdata_cadastro : TDate;
procedure Setnome(const Value: String);
procedure Setdata_nascimento(const Value: TDate);
procedure Setdata_cadastro(const Value: TDate);
published
{ published declarations }
end;
TUsuario = class(TTestePai)
private
email : String;
telefone : String;
protected
{ protected declarations }
public
{ public declarations }
function Getemail : String;
function Gettelefone : String;
procedure Setemail(const Value: String);
procedure Settelefone(const Value: String);
procedure procCopiaUsuario;
published
{ published declarations }
constructor Create(nome : String; dtNascimento : Tdate);
end;
implementation
{ TTestePai }
uses Udm000;
procedure TTestePai.Setnome(const Value: String);
begin
nome := Value;
end;
procedure TTestePai.Setdata_nascimento(const Value: TDate);
begin
data_nascimento := Value;
end;
function TTestePai.Getdata_cadastro: TDate;
begin
Result := data_cadastro;
end;
function TTestePai.Getdata_nascimento: TDate;
begin
Result := data_nascimento;
end;
function TTestePai.Getnome: String;
begin
Result := nome;
end;
procedure TTestePai.Setdata_cadastro(const Value: Tdate);
begin
data_cadastro := Value;
end;
{ TUsuario }
{ TUsuario }
constructor TUsuario.Create(nome: String; dtNascimento: Tdate);
begin
Self.Setnome(nome);
Self.Setdata_nascimento(dtNascimento);
Self.Setdata_cadastro(dmBanco.funcDataServidor);
end;
function TUsuario.Getemail: String;
begin
Result := email;
end;
function TUsuario.Gettelefone: String;
begin
Result := telefone;
end;
procedure TUsuario.procCopiaUsuario;
var
usuario : TUsuario;
QryUpdate : TIBQuery;
begin
QryUpdate := TIBQuery.Create(nil);
QryUpdate.Transaction := dmBanco.TBanco;
try
try
QryUpdate.Close;
QryUpdate.SQL.Text := ' INSERT INTO USUARIO VALUES (GEN_ID(SEQ_USUARIO,1), :NOME, :DT_NASCIMENTO, '+
' :DT_CADASTRO, :EMAIL, :TELEFONE); ';
QryUpdate.ParamByName('NOME').AsString := Self.Getnome;
QryUpdate.ParamByName('DT_NASCIMENTO').AsDate := Self.Getdata_nascimento;
QryUpdate.ParamByName('DT_CADASTRO').AsDate := Self.Getdata_cadastro;
QryUpdate.ParamByName('EMAIL').AsString := Self.Getemail;
QryUpdate.ParamByName('TELEFONE').AsString := Self.Gettelefone;
QryUpdate.ExecSQL;
if dmBanco.TBanco.InTransaction then
dmBanco.TBanco.Commit;
except
on E: Exception do
begin
if dmBanco.TBanco.InTransaction then
dmBanco.TBanco.Rollback;
Raise;
end;
end;
finally
QryUpdate.Free
end;
end;
procedure TUsuario.Setemail(const Value: String);
begin
email := Value;
end;
procedure TUsuario.Settelefone(const Value: String);
begin
telefone := Value;
end;
end.
|
unit nsBaseSearchModel;
// Модуль: "w:\garant6x\implementation\Garant\GbaNemesis\Search\nsBaseSearchModel.pas"
// Стереотип: "SimpleClass"
// Элемент модели: "TnsBaseSearchModel" MUID: (56F12BAB0086)
{$Include w:\garant6x\implementation\Garant\nsDefine.inc}
interface
{$If NOT Defined(Admin) AND NOT Defined(Monitorings)}
uses
l3IntfUses
, l3ProtoObject
, BaseSearchInterfaces
, l3Interfaces
, l3LongintList
, PrimBaseSearchInterfaces
;
type
TnsBaseSearchModel = class(Tl3ProtoObject, InsBaseSearchModel)
private
f_Context: Il3CString;
f_FindEnabled: Boolean;
f_IsLocalSearchArea: Boolean;
f_Listeners: Tl3LongintList;
public
f_ActiveClass: InsBaseSearchClass;
f_Area: TnsSearchArea;
f_AvailableAreas: TnsSearchAreas;
f_FindBackSupported: Boolean;
f_FindBackEnabled: Boolean;
private
procedure Changed;
protected
function pm_GetActiveClass: InsBaseSearchClass;
procedure pm_SetActiveClass(const aValue: InsBaseSearchClass);
function pm_GetContext: Il3CString;
procedure pm_SetContext(const aValue: Il3CString);
function pm_GetArea: TnsSearchArea;
procedure pm_SetArea(aValue: TnsSearchArea);
function pm_GetAvailableAreas: TnsSearchAreas;
function Find(const aProcessor: InsBaseSearchResultProcessor): Boolean;
function FindBack(const aProcessor: InsBaseSearchResultProcessor): Boolean;
function pm_GetFindBackSupported: Boolean;
function pm_GetFindBackEnabled: Boolean;
procedure AddView(const aVie: InsBaseSearchView);
procedure RemoveView(const aView: InsBaseSearchView);
function pm_GetFindEnabled: Boolean;
procedure SubscribeListener(const aListener: InsBaseSearchModelListener);
procedure UnsubscribeListener(const aListener: InsBaseSearchModelListener);
function pm_GetIsLocalSearchArea: Boolean;
function pm_GetExampleText: Il3CString;
procedure Cleanup; override;
{* Функция очистки полей объекта. }
public
constructor Create; reintroduce;
class function Make: InsBaseSearchModel; reintroduce;
end;//TnsBaseSearchModel
{$IfEnd} // NOT Defined(Admin) AND NOT Defined(Monitorings)
implementation
{$If NOT Defined(Admin) AND NOT Defined(Monitorings)}
uses
l3ImplUses
//#UC START# *56F12BAB0086impl_uses*
//#UC END# *56F12BAB0086impl_uses*
;
constructor TnsBaseSearchModel.Create;
//#UC START# *56F12C01028A_56F12BAB0086_var*
//#UC END# *56F12C01028A_56F12BAB0086_var*
begin
//#UC START# *56F12C01028A_56F12BAB0086_impl*
!!! Needs to be implemented !!!
//#UC END# *56F12C01028A_56F12BAB0086_impl*
end;//TnsBaseSearchModel.Create
class function TnsBaseSearchModel.Make: InsBaseSearchModel;
var
l_Inst : TnsBaseSearchModel;
begin
l_Inst := Create;
try
Result := l_Inst;
finally
l_Inst.Free;
end;//try..finally
end;//TnsBaseSearchModel.Make
procedure TnsBaseSearchModel.Changed;
//#UC START# *56F13824018B_56F12BAB0086_var*
//#UC END# *56F13824018B_56F12BAB0086_var*
begin
//#UC START# *56F13824018B_56F12BAB0086_impl*
!!! Needs to be implemented !!!
//#UC END# *56F13824018B_56F12BAB0086_impl*
end;//TnsBaseSearchModel.Changed
function TnsBaseSearchModel.pm_GetActiveClass: InsBaseSearchClass;
//#UC START# *56D42F43033E_56F12BAB0086get_var*
//#UC END# *56D42F43033E_56F12BAB0086get_var*
begin
//#UC START# *56D42F43033E_56F12BAB0086get_impl*
!!! Needs to be implemented !!!
//#UC END# *56D42F43033E_56F12BAB0086get_impl*
end;//TnsBaseSearchModel.pm_GetActiveClass
procedure TnsBaseSearchModel.pm_SetActiveClass(const aValue: InsBaseSearchClass);
//#UC START# *56D42F43033E_56F12BAB0086set_var*
//#UC END# *56D42F43033E_56F12BAB0086set_var*
begin
//#UC START# *56D42F43033E_56F12BAB0086set_impl*
!!! Needs to be implemented !!!
//#UC END# *56D42F43033E_56F12BAB0086set_impl*
end;//TnsBaseSearchModel.pm_SetActiveClass
function TnsBaseSearchModel.pm_GetContext: Il3CString;
//#UC START# *56D42F4C032F_56F12BAB0086get_var*
//#UC END# *56D42F4C032F_56F12BAB0086get_var*
begin
//#UC START# *56D42F4C032F_56F12BAB0086get_impl*
!!! Needs to be implemented !!!
//#UC END# *56D42F4C032F_56F12BAB0086get_impl*
end;//TnsBaseSearchModel.pm_GetContext
procedure TnsBaseSearchModel.pm_SetContext(const aValue: Il3CString);
//#UC START# *56D42F4C032F_56F12BAB0086set_var*
//#UC END# *56D42F4C032F_56F12BAB0086set_var*
begin
//#UC START# *56D42F4C032F_56F12BAB0086set_impl*
!!! Needs to be implemented !!!
//#UC END# *56D42F4C032F_56F12BAB0086set_impl*
end;//TnsBaseSearchModel.pm_SetContext
function TnsBaseSearchModel.pm_GetArea: TnsSearchArea;
//#UC START# *56D42F5801B5_56F12BAB0086get_var*
//#UC END# *56D42F5801B5_56F12BAB0086get_var*
begin
//#UC START# *56D42F5801B5_56F12BAB0086get_impl*
!!! Needs to be implemented !!!
//#UC END# *56D42F5801B5_56F12BAB0086get_impl*
end;//TnsBaseSearchModel.pm_GetArea
procedure TnsBaseSearchModel.pm_SetArea(aValue: TnsSearchArea);
//#UC START# *56D42F5801B5_56F12BAB0086set_var*
//#UC END# *56D42F5801B5_56F12BAB0086set_var*
begin
//#UC START# *56D42F5801B5_56F12BAB0086set_impl*
!!! Needs to be implemented !!!
//#UC END# *56D42F5801B5_56F12BAB0086set_impl*
end;//TnsBaseSearchModel.pm_SetArea
function TnsBaseSearchModel.pm_GetAvailableAreas: TnsSearchAreas;
//#UC START# *56D42FB300D9_56F12BAB0086get_var*
//#UC END# *56D42FB300D9_56F12BAB0086get_var*
begin
//#UC START# *56D42FB300D9_56F12BAB0086get_impl*
!!! Needs to be implemented !!!
//#UC END# *56D42FB300D9_56F12BAB0086get_impl*
end;//TnsBaseSearchModel.pm_GetAvailableAreas
function TnsBaseSearchModel.Find(const aProcessor: InsBaseSearchResultProcessor): Boolean;
//#UC START# *56D42FE5023F_56F12BAB0086_var*
//#UC END# *56D42FE5023F_56F12BAB0086_var*
begin
//#UC START# *56D42FE5023F_56F12BAB0086_impl*
!!! Needs to be implemented !!!
//#UC END# *56D42FE5023F_56F12BAB0086_impl*
end;//TnsBaseSearchModel.Find
function TnsBaseSearchModel.FindBack(const aProcessor: InsBaseSearchResultProcessor): Boolean;
//#UC START# *56D42FFF0321_56F12BAB0086_var*
//#UC END# *56D42FFF0321_56F12BAB0086_var*
begin
//#UC START# *56D42FFF0321_56F12BAB0086_impl*
!!! Needs to be implemented !!!
//#UC END# *56D42FFF0321_56F12BAB0086_impl*
end;//TnsBaseSearchModel.FindBack
function TnsBaseSearchModel.pm_GetFindBackSupported: Boolean;
//#UC START# *56D4300D027E_56F12BAB0086get_var*
//#UC END# *56D4300D027E_56F12BAB0086get_var*
begin
//#UC START# *56D4300D027E_56F12BAB0086get_impl*
!!! Needs to be implemented !!!
//#UC END# *56D4300D027E_56F12BAB0086get_impl*
end;//TnsBaseSearchModel.pm_GetFindBackSupported
function TnsBaseSearchModel.pm_GetFindBackEnabled: Boolean;
//#UC START# *56D4301A00C4_56F12BAB0086get_var*
//#UC END# *56D4301A00C4_56F12BAB0086get_var*
begin
//#UC START# *56D4301A00C4_56F12BAB0086get_impl*
!!! Needs to be implemented !!!
//#UC END# *56D4301A00C4_56F12BAB0086get_impl*
end;//TnsBaseSearchModel.pm_GetFindBackEnabled
procedure TnsBaseSearchModel.AddView(const aVie: InsBaseSearchView);
//#UC START# *56D4309E031C_56F12BAB0086_var*
//#UC END# *56D4309E031C_56F12BAB0086_var*
begin
//#UC START# *56D4309E031C_56F12BAB0086_impl*
!!! Needs to be implemented !!!
//#UC END# *56D4309E031C_56F12BAB0086_impl*
end;//TnsBaseSearchModel.AddView
procedure TnsBaseSearchModel.RemoveView(const aView: InsBaseSearchView);
//#UC START# *56D430AD02C7_56F12BAB0086_var*
//#UC END# *56D430AD02C7_56F12BAB0086_var*
begin
//#UC START# *56D430AD02C7_56F12BAB0086_impl*
!!! Needs to be implemented !!!
//#UC END# *56D430AD02C7_56F12BAB0086_impl*
end;//TnsBaseSearchModel.RemoveView
function TnsBaseSearchModel.pm_GetFindEnabled: Boolean;
//#UC START# *56EF9DE2023E_56F12BAB0086get_var*
//#UC END# *56EF9DE2023E_56F12BAB0086get_var*
begin
//#UC START# *56EF9DE2023E_56F12BAB0086get_impl*
!!! Needs to be implemented !!!
//#UC END# *56EF9DE2023E_56F12BAB0086get_impl*
end;//TnsBaseSearchModel.pm_GetFindEnabled
procedure TnsBaseSearchModel.SubscribeListener(const aListener: InsBaseSearchModelListener);
//#UC START# *56EFAA430205_56F12BAB0086_var*
//#UC END# *56EFAA430205_56F12BAB0086_var*
begin
//#UC START# *56EFAA430205_56F12BAB0086_impl*
!!! Needs to be implemented !!!
//#UC END# *56EFAA430205_56F12BAB0086_impl*
end;//TnsBaseSearchModel.SubscribeListener
procedure TnsBaseSearchModel.UnsubscribeListener(const aListener: InsBaseSearchModelListener);
//#UC START# *56EFAA520307_56F12BAB0086_var*
//#UC END# *56EFAA520307_56F12BAB0086_var*
begin
//#UC START# *56EFAA520307_56F12BAB0086_impl*
!!! Needs to be implemented !!!
//#UC END# *56EFAA520307_56F12BAB0086_impl*
end;//TnsBaseSearchModel.UnsubscribeListener
function TnsBaseSearchModel.pm_GetIsLocalSearchArea: Boolean;
//#UC START# *56F122950394_56F12BAB0086get_var*
//#UC END# *56F122950394_56F12BAB0086get_var*
begin
//#UC START# *56F122950394_56F12BAB0086get_impl*
!!! Needs to be implemented !!!
//#UC END# *56F122950394_56F12BAB0086get_impl*
end;//TnsBaseSearchModel.pm_GetIsLocalSearchArea
function TnsBaseSearchModel.pm_GetExampleText: Il3CString;
//#UC START# *56F2592D029E_56F12BAB0086get_var*
//#UC END# *56F2592D029E_56F12BAB0086get_var*
begin
//#UC START# *56F2592D029E_56F12BAB0086get_impl*
!!! Needs to be implemented !!!
//#UC END# *56F2592D029E_56F12BAB0086get_impl*
end;//TnsBaseSearchModel.pm_GetExampleText
procedure TnsBaseSearchModel.Cleanup;
{* Функция очистки полей объекта. }
//#UC START# *479731C50290_56F12BAB0086_var*
//#UC END# *479731C50290_56F12BAB0086_var*
begin
//#UC START# *479731C50290_56F12BAB0086_impl*
!!! Needs to be implemented !!!
//#UC END# *479731C50290_56F12BAB0086_impl*
end;//TnsBaseSearchModel.Cleanup
{$IfEnd} // NOT Defined(Admin) AND NOT Defined(Monitorings)
end.
|
unit EventType;
interface
type
TEventStatus = (ENABLED, DEPRECATED);
TEventType = class
private
Fname: String;
Flabel: String;
Fstatus: TEventStatus;
function GetStatus: TEventStatus;
public
property name : String read Fname write Fname;
property &label : String read Flabel write Flabel;
property status : TEventStatus read GetStatus write Fstatus;
end;
implementation
{ TEventType }
function TEventType.GetStatus: TEventStatus;
begin
Result := Fstatus;
end;
end.
|
Unit example;
{ This file illustrates how to use the IJG code as a subroutine library
to read or write JPEG image files. You should look at this code in
conjunction with the documentation file libjpeg.doc.
This code will not do anything useful as-is, but it may be helpful as a
skeleton for constructing routines that call the JPEG library. }
{ Original: example.c }
Interface
{ Include file for users of JPEG library.
You will need to have included system headers that define at least
the typedefs FILE and size_t before you can include jpeglib.h.
(stdio.h is sufficient on ANSI-conforming systems.)
You may also wish to include "jerror.h". }
uses
jmorecfg, jerror, jpeglib,
jdatadst, jcparam, jcapimin, jcapistd, jdapimin, jdatasrc, jdapistd,
test;
{ Sample routine for JPEG compression. We assume that the target file name
and a compression quality factor are passed in. }
{GLOBAL}
procedure write_JPEG_file (filename : string; quality : int);
{ Sample routine for JPEG decompression. We assume that the source file name
is passed in. We want to return TRUE on success, FALSE on error. }
{GLOBAL}
function read_JPEG_file (filename : string) : boolean;
implementation
{$IFOPT I+} {$DEFINE IoCheck} {$ENDIF}
{ <setjmp.h> is used for the optional error recovery mechanism shown in
the second part of the example. }
{******************* JPEG COMPRESSION SAMPLE INTERFACE ******************}
{ This half of the example shows how to feed data into the JPEG compressor.
We present a minimal version that does not worry about refinements such
as error recovery (the JPEG code will just exit() if it gets an error). }
{ IMAGE DATA FORMATS:
The standard input image format is a rectangular array of pixels, with
each pixel having the same number of "component" values (color channels).
Each pixel row is an array of JSAMPLEs (which typically are unsigned chars).
If you are working with color data, then the color values for each pixel
must be adjacent in the row; for example, R,G,B,R,G,B,R,G,B,... for 24-bit
RGB color.
For this example, we'll assume that this data structure matches the way
our application has stored the image in memory, so we can just pass a
pointer to our image buffer. In particular, let's say that the image is
RGB color and is described by: }
{$IFDEF TEST}
{extern}
var
image_buffer : JSAMPROW; { Points to large array of R,G,B-order data }
image_height : int; { Number of rows in image }
image_width : int; { Number of columns in image }
{$ENDIF}
{ Sample routine for JPEG compression. We assume that the target file name
and a compression quality factor are passed in. }
{GLOBAL}
procedure write_JPEG_file (filename : string; quality : int);
var
{ This struct contains the JPEG compression parameters and pointers to
working space (which is allocated as needed by the JPEG library).
It is possible to have several such structures, representing multiple
compression/decompression processes, in existence at once. We refer
to any one struct (and its associated working data) as a "JPEG object". }
cinfo : jpeg_compress_struct;
{ This struct represents a JPEG error handler. It is declared separately
because applications often want to supply a specialized error handler
(see the second half of this file for an example). But here we just
take the easy way out and use the standard error handler, which will
print a message on stderr and call exit() if compression fails.
Note that this struct must live as long as the main JPEG parameter
struct, to avoid dangling-pointer problems. }
jerr : jpeg_error_mgr;
{ More stuff }
outfile : FILE; { target file }
row_pointer : array[0..0] of JSAMPROW ; { pointer to JSAMPLE row[s] }
row_stride : int; { physical row width in image buffer }
begin
{ Step 1: allocate and initialize JPEG compression object }
{ We have to set up the error handler first, in case the initialization
step fails. (Unlikely, but it could happen if you are out of memory.)
This routine fills in the contents of struct jerr, and returns jerr's
address which we place into the link field in cinfo. }
cinfo.err := jpeg_std_error(jerr);
{ msg_level that will be displayed. (Nomssi) }
jerr.trace_level := 3;
{ Now we can initialize the JPEG compression object. }
jpeg_create_compress(@cinfo);
{ Step 2: specify data destination (eg, a file) }
{ Note: steps 2 and 3 can be done in either order. }
{ Here we use the library-supplied code to send compressed data to a
stdio stream. You can also write your own code to do something else.
VERY IMPORTANT: use "b" option to fopen() if you are on a machine that
requires it in order to write binary files. }
Assign(outfile, filename);
{$I-}
ReWrite(outfile, 1);
{$IFDEF IoCheck} {$I+} {$ENDIF}
if (IOresult <> 0) then
begin
WriteLn(output, 'can''t open ', filename);
Halt(1);
end;
jpeg_stdio_dest(@cinfo, @outfile);
{ Step 3: set parameters for compression }
{ First we supply a description of the input image.
Four fields of the cinfo struct must be filled in: }
cinfo.image_width := image_width; { image width and height, in pixels }
cinfo.image_height := image_height;
cinfo.input_components := 3; { # of color components per pixel }
cinfo.in_color_space := JCS_RGB; { colorspace of input image }
{ Now use the library's routine to set default compression parameters.
(You must set at least cinfo.in_color_space before calling this,
since the defaults depend on the source color space.) }
jpeg_set_defaults(@cinfo);
{ Now you can set any non-default parameters you wish to.
Here we just illustrate the use of quality (quantization table) scaling: }
jpeg_set_quality(@cinfo, quality, TRUE { limit to baseline-JPEG values });
{ Step 4: Start compressor }
{ TRUE ensures that we will write a complete interchange-JPEG file.
Pass TRUE unless you are very sure of what you're doing. }
jpeg_start_compress(@cinfo, TRUE);
{ Step 5: while (scan lines remain to be written) }
{ jpeg_write_scanlines(...); }
{ Here we use the library's state variable cinfo.next_scanline as the
loop counter, so that we don't have to keep track ourselves.
To keep things simple, we pass one scanline per call; you can pass
more if you wish, though. }
row_stride := image_width * 3; { JSAMPLEs per row in image_buffer }
while (cinfo.next_scanline < cinfo.image_height) do
begin
{ jpeg_write_scanlines expects an array of pointers to scanlines.
Here the array is only one element long, but you could pass
more than one scanline at a time if that's more convenient. }
row_pointer[0] := JSAMPROW(@image_buffer^[cinfo.next_scanline * row_stride]);
{void} jpeg_write_scanlines(@cinfo, JSAMPARRAY(@row_pointer), 1);
end;
{ Step 6: Finish compression }
jpeg_finish_compress(@cinfo);
{ After finish_compress, we can close the output file. }
system.close(outfile);
{ Step 7: release JPEG compression object }
{ This is an important step since it will release a good deal of memory. }
jpeg_destroy_compress(@cinfo);
{ And we're done! }
end;
{ SOME FINE POINTS:
In the above loop, we ignored the return value of jpeg_write_scanlines,
which is the number of scanlines actually written. We could get away
with this because we were only relying on the value of cinfo.next_scanline,
which will be incremented correctly. If you maintain additional loop
variables then you should be careful to increment them properly.
Actually, for output to a stdio stream you needn't worry, because
then jpeg_write_scanlines will write all the lines passed (or else exit
with a fatal error). Partial writes can only occur if you use a data
destination module that can demand suspension of the compressor.
(If you don't know what that's for, you don't need it.)
If the compressor requires full-image buffers (for entropy-coding
optimization or a multi-scan JPEG file), it will create temporary
files for anything that doesn't fit within the maximum-memory setting.
(Note that temp files are NOT needed if you use the default parameters.)
On some systems you may need to set up a signal handler to ensure that
temporary files are deleted if the program is interrupted. See libjpeg.doc.
Scanlines MUST be supplied in top-to-bottom order if you want your JPEG
files to be compatible with everyone else's. If you cannot readily read
your data in that order, you'll need an intermediate array to hold the
image. See rdtarga.c or rdbmp.c for examples of handling bottom-to-top
source data using the JPEG code's internal virtual-array mechanisms. }
{******************* JPEG DECOMPRESSION SAMPLE INTERFACE ******************}
{ This half of the example shows how to read data from the JPEG decompressor.
It's a bit more refined than the above, in that we show:
(a) how to modify the JPEG library's standard error-reporting behavior;
(b) how to allocate workspace using the library's memory manager.
Just to make this example a little different from the first one, we'll
assume that we do not intend to put the whole image into an in-memory
buffer, but to send it line-by-line someplace else. We need a one-
scanline-high JSAMPLE array as a work buffer, and we will let the JPEG
memory manager allocate it for us. This approach is actually quite useful
because we don't need to remember to deallocate the buffer separately: it
will go away automatically when the JPEG object is cleaned up. }
{ ERROR HANDLING:
The JPEG library's standard error handler (jerror.c) is divided into
several "methods" which you can override individually. This lets you
adjust the behavior without duplicating a lot of code, which you might
have to update with each future release.
Our example here shows how to override the "error_exit" method so that
control is returned to the library's caller when a fatal error occurs,
rather than calling exit() as the standard error_exit method does.
We use C's setjmp/longjmp facility to return control. This means that the
routine which calls the JPEG library must first execute a setjmp() call to
establish the return point. We want the replacement error_exit to do a
longjmp(). But we need to make the setjmp buffer accessible to the
error_exit routine. To do this, we make a private extension of the
standard JPEG error handler object. (If we were using C++, we'd say we
were making a subclass of the regular error handler.) }
{$IFDEF TEST ---------------------------------------------------------------}
{extern}
type
jmp_buf = pointer;
{ This routine does the output }
procedure put_scanline_someplace(buffer : JSAMPROW; row_stride : int);
forward;
{ define an error recovery point. Return 0 when OK }
function setjmp(setjmp_buffer : jmp_buf) : int;
forward;
{ Return control to the setjmp point }
procedure longjmp(setjmp_buffer : jmp_buf; flag : int);
forward;
{$ENDIF --------------------------------------------------------------------}
{ Here's the extended error handler struct: }
type
my_error_ptr = ^my_error_mgr;
my_error_mgr = record
pub : jpeg_error_mgr; { "public" fields }
setjmp_buffer : jmp_buf; { for return to caller }
end;
{ Here's the routine that will replace the standard error_exit method: }
{METHODDEF}
procedure my_error_exit (cinfo : j_common_ptr); far;
var
myerr : my_error_ptr;
begin
{ cinfo^.err really points to a my_error_mgr struct, so coerce pointer }
myerr := my_error_ptr (cinfo^.err);
{ Always display the message. }
{ We could postpone this until after returning, if we chose. }
cinfo^.err^.output_message (cinfo);
{ Return control to the setjmp point }
longjmp(myerr^.setjmp_buffer, 1);
end;
{ Sample routine for JPEG decompression. We assume that the source file name
is passed in. We want to return 1 on success, 0 on error. }
{GLOBAL}
function read_JPEG_file (filename : string) : boolean;
var
{ This struct contains the JPEG decompression parameters and pointers to
working space (which is allocated as needed by the JPEG library). }
cinfo : jpeg_decompress_struct;
{ We use our private extension JPEG error handler.
Note that this struct must live as long as the main JPEG parameter
struct, to avoid dangling-pointer problems. }
jerr : my_error_mgr;
{ More stuff }
infile : FILE; { source file }
buffer : JSAMPARRAY; { Output row buffer }
row_stride : int; { physical row width in output buffer }
begin
{ In this example we want to open the input file before doing anything else,
so that the setjmp() error recovery below can assume the file is open.
VERY IMPORTANT: use "b" option to fopen() if you are on a machine that
requires it in order to read binary files. }
Assign(infile, filename);
{$I-}
Reset(infile, 1);
{$IFDEF IoCheck} {$I+} {$ENDIF}
if (IOresult <> 0) then
begin
WriteLn(output, 'can''t open ', filename);
read_JPEG_file := FALSE;
exit;
end;
{ Step 1: allocate and initialize JPEG decompression object }
{ We set up the normal JPEG error routines, then override error_exit. }
cinfo.err := jpeg_std_error(jerr.pub);
jerr.pub.error_exit := my_error_exit;
jerr.pub.trace_level := 3; { I'm debbuging a lot (Nomssi) }
{ Establish the setjmp return context for my_error_exit to use. }
if (setjmp(jerr.setjmp_buffer)<>0) then
begin
{ If we get here, the JPEG code has signaled an error.
We need to clean up the JPEG object, close the input file, and return. }
{ Nomssi: if we get here, we are in trouble, because e.g. cinfo.mem
is not guaranted to be NIL }
jpeg_destroy_decompress(@cinfo);
system.close(infile);
read_JPEG_file := FALSE;
exit;
end;
{ Now we can initialize the JPEG decompression object. }
jpeg_create_decompress(@cinfo);
{ Step 2: specify data source (eg, a file) }
jpeg_stdio_src(@cinfo, @infile);
{ Step 3: read file parameters with jpeg_read_header() }
jpeg_read_header(@cinfo, TRUE);
{ We can ignore the return value from jpeg_read_header since
(a) suspension is not possible with the stdio data source, and
(b) we passed TRUE to reject a tables-only JPEG file as an error.
See libjpeg.doc for more info. }
{ Step 4: set parameters for decompression }
{ the defaults are set by jpeg_read_header(),
we could choose to do nothing here. }
cinfo.scale_num := 1;
cinfo.scale_denom := 1; { 1:1 scaling }
cinfo.dct_method := JDCT_IFAST;
cinfo.quantize_colors := TRUE;
cinfo.two_pass_quantize := TRUE;
cinfo.dither_mode := JDITHER_FS; { Floyd-Steinberg error diffusion dither }
{ Step 5: Start decompressor }
jpeg_start_decompress(@cinfo);
{ We can ignore the return value since suspension is not possible
with the stdio data source. }
{ We may need to do some setup of our own at this point before reading
the data. After jpeg_start_decompress() we have the correct scaled
output image dimensions available, as well as the output colormap
if we asked for color quantization.
In this example, we need to make an output work buffer of the right size. }
{ JSAMPLEs per row in output buffer }
row_stride := cinfo.output_width * cinfo.output_components;
{ Make a one-row-high sample array that will go away when done with image }
buffer := cinfo.mem^.alloc_sarray
(j_common_ptr(@cinfo), JPOOL_IMAGE, row_stride, 1);
{ Step 6: while (scan lines remain to be read) }
{ jpeg_read_scanlines(...); }
{ Here we use the library's state variable cinfo.output_scanline as the
loop counter, so that we don't have to keep track ourselves. }
while (cinfo.output_scanline < cinfo.output_height) do
begin
{ jpeg_read_scanlines expects an array of pointers to scanlines.
Here the array is only one element long, but you could ask for
more than one scanline at a time if that's more convenient. }
jpeg_read_scanlines(@cinfo, buffer, 1);
{ Assume put_scanline_someplace wants a pointer and sample count. }
put_scanline_someplace(buffer^[0], row_stride);
end;
{ Nomssi }
save_color_map(@cinfo);
{ Step 7: Finish decompression }
jpeg_finish_decompress(@cinfo);
{ We can ignore the return value since suspension is not possible
with the stdio data source. }
{ Step 8: Release JPEG decompression object }
{ This is an important step since it will release a good deal of memory. }
jpeg_destroy_decompress(@cinfo);
{ After finish_decompress, we can close the input file.
Here we postpone it until after no more JPEG errors are possible,
so as to simplify the setjmp error logic above. (Actually, I don't
think that jpeg_destroy can do an error exit, but why assume anything...) }
system.close(infile);
{ At this point you may want to check to see whether any corrupt-data
warnings occurred (test whether jerr.pub.num_warnings is nonzero). }
{ And we're done! }
read_JPEG_file := TRUE;
end;
{ SOME FINE POINTS:
In the above code, we ignored the return value of jpeg_read_scanlines,
which is the number of scanlines actually read. We could get away with
this because we asked for only one line at a time and we weren't using
a suspending data source. See libjpeg.doc for more info.
We cheated a bit by calling alloc_sarray() after jpeg_start_decompress();
we should have done it beforehand to ensure that the space would be
counted against the JPEG max_memory setting. In some systems the above
code would risk an out-of-memory error. However, in general we don't
know the output image dimensions before jpeg_start_decompress(), unless we
call jpeg_calc_output_dimensions(). See libjpeg.doc for more about this.
Scanlines are returned in the same order as they appear in the JPEG file,
which is standardly top-to-bottom. If you must emit data bottom-to-top,
you can use one of the virtual arrays provided by the JPEG memory manager
to invert the data. See wrbmp.c for an example.
As with compression, some operating modes may require temporary files.
On some systems you may need to set up a signal handler to ensure that
temporary files are deleted if the program is interrupted. See libjpeg.doc. }
end.
|
unit Errors;
interface
const
ER_SYNTAX = 'Ошибка синтаксиса';
ER_FUNC_ARGS = 'Ошибка чтения аргументов %s: ';
ER_FUNC_ARGS_OPEN = ER_FUNC_ARGS + 'ожидается символ (';
ER_FUNC_ARGS_CLOSE = ER_FUNC_ARGS + 'ожидается символ )';
ER_FUNC_ARGS_INVALID = ER_FUNC_ARGS + 'ожидается переменная или выражение';
ER_FUNC_ARGS_SYNTAX = ER_FUNC_ARGS + 'синтаксическая ошибка';
ER_FUNC_ARGS_COUNT = ER_FUNC_ARGS + 'неверное количество. Ожидается аргументов: %d';
ER_FOR = 'Ошибка оператора for: ';
ER_FOR_EXP_EXISTS = ER_FOR + 'ожидается выражение';
ER_FOR_VAR_LOC = ER_FOR + 'ожидается имя локальной переменной';
ER_LEX_NOT_FOUND = 'Лексема %s не найдена';
ER_SYMBOL_EXISTS = 'Ожидается символ %s';
ER_OBJ_FIELD_ACCESS = 'Ошибка доступа к полям объекта %s: ожидается оператор .';
ER_OBJ_METHOD_BAD = 'Метод %s для объекта %s не поддерживается';
ER_VAR_EXISTS = 'Переменная с именем %s уже существует';
ER_VAR_NOT_FOUND = 'Переменная с именем %s не найдена';
ER_TOK_DNT_SUP = 'Символ с кодом 0x%s в позиции %d не поддерживается';
implementation
end.
|
{
$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.5 10/26/2004 9:36:26 PM JPMugaas
Updated ref.
Rev 1.4 4/19/2004 5:05:28 PM JPMugaas
Class rework Kudzu wanted.
Rev 1.3 2004.02.03 5:45:22 PM czhower
Name changes
Rev 1.2 10/19/2003 2:08:48 PM DSiders
Added localization comments.
Rev 1.1 4/7/2003 04:03:02 PM JPMugaas
User can now descover what output a parser may give.
Rev 1.0 2/19/2003 04:18:10 AM JPMugaas
More things restructured for the new list framework.
}
unit IdFTPListParseAS400;
interface
{$i IdCompilerDefines.inc}
uses
Classes,
IdFTPList, IdFTPListParseBase, IdFTPListTypes;
type
TIdAS400FTPListItem = class(TIdOwnerFTPListItem);
TIdFTPLPAS400 = class(TIdFTPLineOwnedList)
protected
class function MakeNewItem(AOwner : TIdFTPListItems) : TIdFTPListItem; override;
class function ParseLine(const AItem : TIdFTPListItem; const APath : String=''): Boolean; override;
public
class function GetIdent : String; override;
class function CheckListing(AListing : TStrings; const ASysDescript : String =''; const ADetails : Boolean = True): boolean; override;
end;
// RLebeau 2/14/09: this forces C++Builder to link to this unit so
// RegisterFTPListParser can be called correctly at program startup...
(*$HPPEMIT '#pragma link "IdFTPListParseAS400"'*)
implementation
uses
IdGlobal, IdFTPCommon, IdGlobalProtocols, SysUtils;
const
DIR_TYPES : array [0..3] of string = ('*DIR','*DDIR','*LIB','*FLR');
{ TIdFTPLPAS400 }
class function TIdFTPLPAS400.CheckListing(AListing: TStrings;
const ASysDescript: String; const ADetails: Boolean): boolean;
var
s : TStrings;
begin
Result := False;
if AListing.Count > 0 then begin
s := TStringList.Create;
try
SplitColumns(AListing[0], s);
if s.Count > 4 then begin
Result := (s[4][1]='*') or (s[4]='DIR'); {Do not translate}
end;
finally
FreeAndNil(s);
end;
end;
end;
class function TIdFTPLPAS400.GetIdent: String;
begin
Result := 'AS400'; {do not localize}
end;
class function TIdFTPLPAS400.MakeNewItem(AOwner: TIdFTPListItems): TIdFTPListItem;
begin
Result := TIdAS400FTPListItem.Create(AOwner);
end;
class function TIdFTPLPAS400.ParseLine(const AItem: TIdFTPListItem;
const APath: String): Boolean;
var
LBuffer : String;
LDate : String;
LTime : String;
LObjType : String;
LI : TIdOwnerFTPListItem;
begin
try
{ From:
http://groups.google.com/groups?q=AS400+LISTFMT+%3D+0&hl=en&lr=&ie=UTF-8&oe=utf-8&selm=9onmpt%24dhe%2402%241%40news.t-online.com&rnum=1
ftp> dir qtemp/timestamp
200 PORT subcommand request successful.
125 List started.
drwx---rwx 1 QPGMR 0 20480 Sep 24 18:16 TIMESTAMP
-rwx---rwx 1 QPGMR 0 0 Sep 24 18:16 TIMESTAMP.TIMESTAMP
250 List completed.
FTP: 140 Bytes empfangen in 0.06Sekunden 2.33KB/s
or
ftp> dir qtemp/timestamp
200 PORT subcommand request successful.
125 List started.
1 2 3 4 5
123456789012345678901234567890123456789012345678901234567890
QPGMR 20480 24.09.01 18:16:20 *FILE QTEMP/TIMESTAMP
QPGMR *MEM QTEMP/TIMESTAMP.TIMESTAMP
250 List completed.
FTP: 146 Bytes empfangen in 0.00Sekunden 146000.00KB/s
It depends qether the SITE param LISTFMT is set to "1" (1st example, *nix-
like) or "0" (2nd example, OS/400-like). I have choosen the 2nd format (I
think it's easier to parse). To get it, submit "QUOTE SITE LISTFMT 0" just
before submitting the DIR command.
From IBM Manual at:
http://publib.boulder.ibm.com/iseries/v5r2/ic2924/index.htm
Here is the original iSeries style format for the LIST subcommand
(when LISTFMT=0):
owner size date time type name
A blank space separates each field.
This is a description of each field:
owner
The 10 character string that represents the user profile which owns the subject.
This string is left justified, and includes blanks. This field is blank for
anonymous FTP sessions.
size
The 10 character number that represents the size of the object. This number is
right justified, and it includes blanks. This field is blank when an object has
no size associated with it.
date
The 8 character modification date in the format that is defined for the server
job. It uses date separators that are defined for the server job. This
modification date is left justified, and it includes blanks.
time
The 8 character modification time that uses the time separator, which the
server job defines.
type
The 10 character OS/400 object type.
name
The variable length name of the object that follows a CRLF (carriage return,
line feed pair). This name may include blanks.
Here is an example of the original iSeries style format:
1 2 3 4 5
123456789012345678901234567890123456789012345678901234567890
BAILEYSE 5263360 06/11/97 12:27:39 *FILE BPTFSAVF
Note on name format from (
http://groups.google.com/groups?q=AS400+FTP+LIST+format&hl=
en&lr=&ie=UTF-8&oe=utf-8&selm=3264740F.B52%40mother.com&rnum=4):
Starting in v3r1 you can access the shared folders area or libraries with FTP by using the
"NAMEFMT 1" command. For example:
SYST
215 OS/400 is the remote operating system. The TCP/IP version is "V3R1M0".
SITE NAMEFMT 1
250 Now using naming format "1".
LIST /QDLS
/QDLS/ARM 0 11/09/95 07:19:30 DIR
/QDLS/ARM-VOL1 0 06/23/95 16:39:43 DIR
/QDLS/ARMM 0 08/04/95 14:32:03 DIR
or
SYST
215 OS/400 is the remote operating system. The TCP/IP version is "V3R1M0".
SITE NAMEFMT 1
250 Now using naming format "1".
LIST /QSYS.LIB
QSYS 3584 11/15/95 16:15:33 *FILE /QSYS.LIB/QSYS.LIB/QPRTRPYL.PRTF
QSYS 18432 11/15/95 16:15:33 *FILE /QSYS.LIB/QSYS.LIB/QPRTSBSD.PRTF
QSYS 5632 11/15/95 16:15:33 *FILE /QSYS.LIB/QSYS.LIB/QPRTSPLF.PRTF
QSYS 8704 11/15/95 16:15:33 *FILE /QSYS.LIB/QSYS.LIB/QPRTSPLQ.PRTF
}
{Notes from Angus Robertson, Magenta Systems Ltd,
MORE TYPES OF SHIT ON THE AS/400 FILE SYSTEM
Object types that are commonly used or that you are likely to see on
this display include the following:
AUTL Authorization list
BLKSF Block special file
CFGL Configuration list
CLS Class
CMD Command
CTLD Controller description
DDIR Distributed directory
DEVD Device description
DIR Directory
DOC Document
DSTMF Distributed stream file
FILE Database file or device file
FLR Folder
JOBD Job description
JOBQ Job queue
LIB Library
LIND Line description
MSGQ Message queue
OUTQ Output queue
PGM Program
SBSD Subsystem description
SOMOBJ System Object Model object
STMF Stream file
SYMLNK Symbolic link
USRPRF User profile
}
LI := AItem as TIdOwnerFTPListItem;
LI.ModifiedAvail := False;
LI.SizeAvail := False;
LBuffer := AItem.Data;
LI.OwnerName := Fetch(LBuffer);
LBuffer := TrimLeft(LBuffer);
//we have to make sure that the size feild really exists or the
//the parser is thrown off
if (LBuffer <> '') and (IsNumeric(LBuffer[1])) then begin
LI.Size := IndyStrToInt64(FetchLength(LBuffer,9),0);
LI.SizeAvail := True;
LBuffer := TrimLeft(LBuffer);
end;
//Sometimes the date and time feilds will not present
if (LBuffer <> '') and (IsNumeric(LBuffer[1])) then begin
LDate := Trim(StrPart(LBuffer, 8));
if (LBuffer <> '') and (LBuffer[1] <> ' ') then begin
LDate := LDate + Fetch(LBuffer);
end;
if LDate <> '' then begin
LI.ModifiedDate := AS400Date(LDate);
LI.ModifiedAvail := True;
end;
LTime := Trim(StrPart(LBuffer, 8));
if (LBuffer <> '') and (LBuffer[1] <> ' ') then begin
LTime := LTime + Fetch(LBuffer);
end;
if LTime <> '' then begin
LI.ModifiedDate := LI.ModifiedDate + TimeHHMMSS(LTime);
end;
end;
//most of this data is manditory so things are less sensitive to positions
LBuffer := Trim(LBuffer);
LObjType := FetchLength(LBuffer,11);
//A file object is something like a file but it can contain members - treat as dir.
// Odd, I know.
//There are also several types of file objects
//note that I'm not completely sure about this so it's commented out. JPM
// if TextStartsWith(LObjType, '*FILE') then begin {do not localize}
// LI.ItemType := ditDirectory;
// end;
if IdGlobal.PosInStrArray(LObjType,DIR_TYPES)>-1 then begin {do not localize}
LI.ItemType := ditDirectory;
if TextEndsWith(LBuffer,'/') then begin
LBuffer := Fetch(LBuffer,'/');
end;
end;
LI.FileName := TrimLeft(LBuffer);
if LI.FileName = '' then begin
LI.FileName := LI.OwnerName;
LI.OwnerName := '';
end;
LI.LocalFileName := LowerCase(StripPath(AItem.FileName, '/'));
Result := True;
except
Result := False;
end;
end;
initialization
RegisterFTPListParser(TIdFTPLPAS400);
finalization
UnRegisterFTPListParser(TIdFTPLPAS400);
end.
|
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Unit1;
type
TForm3 = class(TForm)
Label1: TLabel;
EditWeight: TEdit;
Label2: TLabel;
EditHeight: TEdit;
Button1: TButton;
Memo1: TMemo;
Label3: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
username: string;
VAR_GLOBAL: TGlobalVar;
end;
var
Form3: TForm3;
implementation
uses calc;
{$R *.dfm}
Function CalculoIMC(Peso : real; Altura : Real) : string;
var
imc : real;
begin
try
altura := sqr(altura);
imc := peso/altura;
if (imc > 0) and (imc < 18.5)
then begin
result := 'Abaixo do Peso';
end else
if (imc >= 18.5) and (imc <= 24.9)
then begin
result := 'Peso Normal';
end else
if (imc >= 25) and (imc <= 29.9)
then begin
result := 'Sobrepeso';
end else
if (imc >= 30) and (imc <= 34.9)
then begin
result := 'Obesidade Grau I';
end else
if (imc >= 35) and (imc <= 39.9)
then begin
result := 'Obesidade Grau II';
end else
if (imc > 40)
then begin
result := 'Obesidade Grau III';
end;
except
result := 'Indefinido';
messagedlg('Ocorreu um erro durante o cálculo do IMC!' + #13 +
'Verifique se o peso e a altura da pessoa' + #13 +
'foram informados corretamente!' , MTERROR, [MBOK],0);
abort;
end;
end;
procedure TForm3.Button1Click(Sender: TObject);
var
result_calc: string;
begin
// Calc IMC
result_calc := CalculoIMC(StrToFloat(EditWeight.Text), StrToFloat(EditHeight.Text));
Memo1.Lines.Clear;
Memo1.Lines.Add( 'Olá '+VAR_GLOBAL.getUserName+' - ' + result_calc );
// Log
VAR_GLOBAL.addLog( VAR_GLOBAL.getUserName + ' calculou o IMC com peso de ' + EditWeight.Text + ' e altura de ' + EditHeight.Text + ' - resultado: ' + result_calc );
end;
end.
|
unit JunoApi4Delphi.Config;
interface
uses
JunoApi4Delphi.Interfaces;
type
TJunoApi4DelphiConig = class(TInterfacedObject, iJunoApi4DelphiConig)
private
FClientId : String;
FClientSecret : String;
FResourceToken : String;
FPublicToken : String;
FEnvironment : iEnvironment;
public
constructor Create;
destructor Destroy; override;
class function New : iJunoApi4DelphiConig;
function ClientId(Value : String) : iJunoApi4DelphiConig; overload;
function ClientId : String; overload;
function ClientSecret(Value : String) : iJunoApi4DelphiConig; overload;
function ClientSecret : String; overload;
function ResourceToken(Value : String) : iJunoApi4DelphiConig; overload;
function ResourceToken : String; overload;
function PublicToken(Value : String) : iJunoApi4DelphiConig; overload;
function PublicToken : String; overload;
function TokenTimeout : Integer;
function AuthorizationEndpoint : String;
function ResourceEndpoint : String;
function Sandbox : iJunoApi4DelphiConig;
function Production :iJunoApi4DelphiConig;
end;
implementation
uses
SandboxEnvironment, ProductionEnviroment;
{ TJunoApi4DelphiConig }
function TJunoApi4DelphiConig.ClientId(Value: String): iJunoApi4DelphiConig;
begin
Result := Self;
FClientId := Value;
end;
function TJunoApi4DelphiConig.AuthorizationEndpoint: String;
begin
Result := FEnvironment.AuthorizationServerEndpoint;
end;
function TJunoApi4DelphiConig.ClientId: String;
begin
Result := FClientId;
end;
function TJunoApi4DelphiConig.ClientSecret(Value: String): iJunoApi4DelphiConig;
begin
Result := Self;
FClientSecret := Value;
end;
function TJunoApi4DelphiConig.ClientSecret: String;
begin
Result := FClientSecret;
end;
constructor TJunoApi4DelphiConig.Create;
begin
end;
destructor TJunoApi4DelphiConig.Destroy;
begin
inherited;
end;
class function TJunoApi4DelphiConig.New: iJunoApi4DelphiConig;
begin
Result := Self.Create;
end;
function TJunoApi4DelphiConig.Production: iJunoApi4DelphiConig;
begin
Result := Self;
FEnvironment := TProductionEnviroment.New;
end;
function TJunoApi4DelphiConig.PublicToken: String;
begin
Result := FPublicToken;
end;
function TJunoApi4DelphiConig.PublicToken(Value: String): iJunoApi4DelphiConig;
begin
Result := Self;
FPublicToken := Value;
end;
function TJunoApi4DelphiConig.ResourceToken(
Value: String): iJunoApi4DelphiConig;
begin
Result := Self;
FResourceToken := Value;
end;
function TJunoApi4DelphiConig.ResourceEndpoint: String;
begin
Result := FEnvironment.ResourceServerEndpoint;
end;
function TJunoApi4DelphiConig.ResourceToken: String;
begin
Result := FResourceToken;
end;
function TJunoApi4DelphiConig.Sandbox: iJunoApi4DelphiConig;
begin
Result := Self;
FEnvironment := TSandboxEnvironment.New;
end;
function TJunoApi4DelphiConig.TokenTimeout: Integer;
begin
Result := 86400;
end;
end.
|
unit SelLis;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, ActnList, ImgList, Menus, ComCtrls, ToolWin, Grids, DBGrids,
Db, DBTables;
type
TFSellis = class(TForm)
ToolBar1: TToolBar;
Fin: TToolButton;
ToolButton2: TToolButton;
ToolButton3: TToolButton;
MainMenu1: TMainMenu;
Ventana1: TMenuItem;
Salir1: TMenuItem;
Ordenar1: TMenuItem;
porCodigo1: TMenuItem;
porNombre1: TMenuItem;
ActionList1: TActionList;
Cerrar: TAction;
Codigo: TAction;
Nombre: TAction;
Panel1: TPanel;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
ToolButton4: TToolButton;
ToolButton1: TToolButton;
Selec: TAction;
Seleccionar1: TMenuItem;
procedure CerrarExecute(Sender: TObject);
procedure CodigoExecute(Sender: TObject);
procedure NombreExecute(Sender: TObject);
procedure SelecExecute(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormKeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
FMultiselec: boolean;
lCerrar: boolean;
procedure SetMultiselec(const Value: boolean);
public
{ Public declarations }
property Multiselec: boolean read FMultiselec write SetMultiselec;
end;
var
FSellis: TFSellis;
implementation
uses
DMCons;
{$R *.DFM}
procedure TFSellis.CerrarExecute(Sender: TObject);
begin
ModalResult := mrCancel;
end;
procedure TFSellis.CodigoExecute(Sender: TObject);
begin
DCons.TLista.indexName := 'PrimaryKey'; // reemplazar por codigo
end;
procedure TFSellis.NombreExecute(Sender: TObject);
begin
DCons.TLista.IndexName := 'DENOMINA' // reemplazar por denominacion;
end;
procedure TFSellis.SelecExecute(Sender: TObject);
begin
if DCons.TListaLISTA.value <> '' then
ModalResult := mrOK
else
ModalResult := mrCancel;
end;
procedure TFSellis.FormCreate(Sender: TObject);
begin
if not ( DCons.TLista.active ) then
begin
DCons.TLista.Open;
lCerrar := true;
end;
end;
procedure TFSellis.FormDestroy(Sender: TObject);
begin
if ( lCerrar ) then
DCons.TLista.Close;
end;
procedure TFSellis.FormKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
SelecExecute( Sender )
else if Key = #27 then
ModalResult := mrCancel;
end;
procedure TFSellis.SetMultiselec(const Value: boolean);
begin
FMultiselec := Value;
if FMultiselec then
FSelLis.DBGrid1.Options := FSelLis.DBGrid1.Options + [dgMultiselect]
else
FSelLis.DBGrid1.Options := FSelLis.DBGrid1.Options - [dgMultiselect];
end;
end.
|
{$include lem_directives.inc}
unit LemMetaTerrain;
interface
uses
Classes,
UTools;
type
TMetaTerrain = class(TCollectionItem)
private
fWidth : Integer;
fHeight : Integer;
fImageLocation : Integer; // DOS history: data location of image in vgagr??.dat
protected
public
procedure Assign(Source: TPersistent); override;
published
property Width : Integer read fWidth write fWidth;
property Height : Integer read fHeight write fHeight;
property ImageLocation : Integer read fImageLocation write fImageLocation;
end;
TMetaTerrains = class(TCollectionEx)
private
function GetItem(Index: Integer): TMetaTerrain;
procedure SetItem(Index: Integer; const Value: TMetaTerrain);
protected
public
constructor Create;
function Add: TMetaTerrain;
function Insert(Index: Integer): TMetaTerrain;
property Items[Index: Integer]: TMetaTerrain read GetItem write SetItem; default;
end;
implementation
{ TMetaTerrain }
procedure TMetaTerrain.Assign(Source: TPersistent);
var
T: TMetaTerrain absolute Source;
begin
if Source is TMetaTerrain then
begin
fWidth := T.fWidth;
fHeight := T.fHeight;
fImageLocation := T.fImageLocation;
end
else inherited Assign(Source);
end;
{ TMetaTerrains }
function TMetaTerrains.Add: TMetaTerrain;
begin
Result := TMetaTerrain(inherited Add);
end;
constructor TMetaTerrains.Create;
begin
inherited Create(TMetaTerrain);
end;
function TMetaTerrains.GetItem(Index: Integer): TMetaTerrain;
begin
Result := TMetaTerrain(inherited GetItem(Index))
end;
function TMetaTerrains.Insert(Index: Integer): TMetaTerrain;
begin
Result := TMetaTerrain(inherited Insert(Index))
end;
procedure TMetaTerrains.SetItem(Index: Integer; const Value: TMetaTerrain);
begin
inherited SetItem(Index, Value);
end;
end.
|
unit Bird.Socket.Server;
interface
uses IdCustomTCPServer, IdHashSHA, IdSSLOpenSSL, IdContext, IdSSL, IdIOHandler, IdGlobal, IdCoderMIME, System.SysUtils,
Bird.Socket.Helpers, Bird.Socket.Consts, Bird.Socket.Types, Bird.Socket.Connection, System.Generics.Collections;
type
TBirdSocketServer = class(TIdCustomTCPServer)
private
FIdServerIOHandlerSSLOpenSSL: TIdServerIOHandlerSSLOpenSSL;
FIdHashSHA1: TIdHashSHA1;
FOnConnect: TEventListener;
FOnDisconnect: TEventListener;
FOnExecute: TEventListener;
FBirds: TBirds;
function ParseHeaders(const AValue: string): THeaders;
function GetEncodedHash(const ASecretKey: string): string;
function GetSuccessHandShakeMessage(const AHash: string): string;
function GetBirdFromContext(const AContext: TIdContext): TBirdSocketConnection;
procedure DoOnConnect(AContext: TIdContext);
procedure DoOnDisconnect(AContext: TIdContext);
procedure DoOnExecute(AContext: TIdContext);
protected
function DoExecute(ABird: TIdContext): Boolean; override;
procedure DoConnect(ABird: TIdContext); override;
public
constructor Create(const APort: Integer);
property OnExecute;
property Birds: TBirds read FBirds;
procedure InitSSL(AIdServerIOHandlerSSLOpenSSL: TIdServerIOHandlerSSLOpenSSL);
procedure AddEventListener(const AEventType: TEventType; const AEvent: TEventListener);
procedure Start; virtual; abstract;
procedure Stop;
destructor Destroy; override;
end;
implementation
procedure TBirdSocketServer.AddEventListener(const AEventType: TEventType; const AEvent: TEventListener);
begin
case AEventType of
TEventType.CONNECT:
FOnConnect := AEvent;
TEventType.EXECUTE:
FOnExecute := AEvent;
TEventType.DISCONNECT:
FOnDisconnect := AEvent;
end;
end;
procedure TBirdSocketServer.DoOnConnect(AContext: TIdContext);
begin
FBirds.Add(TBirdSocketConnection.Create(AContext));
if Assigned(FOnConnect) then
FOnConnect(FBirds.Last);
end;
constructor TBirdSocketServer.Create(const APort: Integer);
begin
inherited Create;
FBirds := TBirds.Create;
DefaultPort := APort;
Active := True;
FIdHashSHA1 := TIdHashSHA1.Create;
FIdServerIOHandlerSSLOpenSSL := nil;
OnConnect := DoOnConnect;
OnDisconnect := DoOnDisconnect;
OnExecute := DoOnExecute;
end;
destructor TBirdSocketServer.Destroy;
begin
Active := False;
FIdHashSHA1.DisposeOf;
FBirds.DisposeOf;
inherited;
end;
procedure TBirdSocketServer.DoOnDisconnect(AContext: TIdContext);
var
LBird: TBirdSocketConnection;
begin
LBird := GetBirdFromContext(AContext);
if Assigned(FOnDisconnect) then
FOnDisconnect(LBird);
FBirds.Remove(LBird);
LBird.Free;
end;
procedure TBirdSocketServer.DoConnect(ABird: TIdContext);
begin
if (ABird.Connection.IOHandler is TIdSSLIOHandlerSocketBase) then
TIdSSLIOHandlerSocketBase(ABird.Connection.IOHandler).PassThrough := False;
ABird.Connection.IOHandler.HandShaked := False;
inherited;
end;
function TBirdSocketServer.DoExecute(ABird: TIdContext): Boolean;
var
LBytes: TArray<Byte>;
LMessage: string;
LHeaders: THeaders;
begin
if not ABird.Connection.IOHandler.HandShaked then
begin
ABird.Connection.IOHandler.CheckForDataOnSource(TIMEOUT_DATA_ON_SOURCE);
if not ABird.Connection.IOHandler.InputBufferIsEmpty then
begin
try
ABird.Connection.IOHandler.InputBuffer.ExtractToBytes(TIdBytes(LBytes));
LMessage := IndyTextEncoding_UTF8.GetString(TIdBytes(LBytes));
except
end;
LHeaders := ParseHeaders(LMessage);
try
if LHeaders.ContainsKey(HEADERS_UPGRADE) and LHeaders.ContainsKey(HEADERS_AUTHORIZATION) then
if LHeaders[HEADERS_UPGRADE].ToLower.Equals(HEADERS_WEBSOCKET) then
begin
try
ABird.Connection.IOHandler.Write(GetSuccessHandShakeMessage(GetEncodedHash(LHeaders[HEADERS_AUTHORIZATION])),
IndyTextEncoding_UTF8);
except
end;
ABird.Connection.IOHandler.HandShaked := True;
end;
finally
LHeaders.DisposeOf;
end;
end;
end;
Result := inherited;
end;
procedure TBirdSocketServer.DoOnExecute(AContext: TIdContext);
begin
if Assigned(FOnExecute) then
FOnExecute(GetBirdFromContext(AContext));
end;
function TBirdSocketServer.GetBirdFromContext(const AContext: TIdContext): TBirdSocketConnection;
var
LBird: TBirdSocketConnection;
LBirds: TList<TBirdSocketConnection>;
begin
LBirds := FBirds.LockList;
try
for LBird in LBirds do
begin
if LBird.IsEquals(AContext) then
Exit(LBird);
end;
Result := TBirdSocketConnection.Create(AContext);
finally
FBirds.UnLockList
end;
end;
function TBirdSocketServer.GetEncodedHash(const ASecretKey: string): string;
begin
Result := TIdEncoderMIME.EncodeBytes(FIdHashSHA1.HashString(ASecretKey + '258EAFA5-E914-47DA-95CA-C5AB0DC85B11'));
end;
function TBirdSocketServer.GetSuccessHandShakeMessage(const AHash: string): string;
begin
Result := Format(
'HTTP/1.1 101 Switching Protocols'#13#10 +
'Upgrade: websocket'#13#10 +
'Connection: Upgrade'#13#10 +
'Sec-WebSocket-Accept: %s'#13#10#13#10, [AHash]);
end;
procedure TBirdSocketServer.InitSSL(AIdServerIOHandlerSSLOpenSSL: TIdServerIOHandlerSSLOpenSSL);
var
LActiveHandler: Boolean;
begin
LActiveHandler := Self.Active;
if LActiveHandler then
Self.Active := False;
FIdServerIOHandlerSSLOpenSSL := AIdServerIOHandlerSSLOpenSSL;
IOHandler := AIdServerIOHandlerSSLOpenSSL;
if LActiveHandler then
Self.Active := True;
end;
function TBirdSocketServer.ParseHeaders(const AValue: string): THeaders;
const
HEADER_NAME = 0;
HEADER_VALUE = 1;
var
LLines: TArray<string>;
LLine: string;
LSplittedLine: TArray<string>;
begin
Result := THeaders.Create;
LLines := AValue.Split([#13#10]);
for LLine in LLines do
begin
LSplittedLine := LLine.Split([': ']);
if (Length(LSplittedLine) > 1) then
Result.AddOrSetValue(Trim(LSplittedLine[HEADER_NAME]), Trim(LSplittedLine[HEADER_VALUE]));
end;
end;
procedure TBirdSocketServer.Stop;
begin
if Self.Active then
Self.StopListening;
end;
end.
|
unit eeButton;
{$I vtDefine.inc}
interface
uses
Windows,
Messages,
Graphics,
SysUtils,
Classes,
Controls,
StdCtrls,
Buttons;
type
TeeButton = class(TButton)
private
f_PrevCharCode : Word;
private
procedure WMChar(Var Msg: TWMChar); message WM_CHAR;
procedure WMKeyDown(Var Msg: TWMKeyDown); message WM_KEYDOWN;
procedure WMSysKeyDown(var Msg: TWMSysKeyDown); message WM_SYSKEYDOWN;
procedure WMEraseBkgnd(var Msg : TWMEraseBkgnd); message WM_ERASEBKGND;
public
constructor Create(AOwner : TComponent);
override;
end;
(* TeeBitBtn = class(TBitBtn)
private
f_PrevCharCode : Word;
private
procedure WMChar(Var Msg: TWMChar); message WM_CHAR;
procedure WMKeyDown(Var Msg: TWMKeyDown); message WM_KEYDOWN;
procedure WMSysKeyDown(var Msg: TWMSysKeyDown); message WM_SYSKEYDOWN;
procedure WMEraseBkgnd(var Msg : TWMEraseBkgnd); message WM_ERASEBKGND;
public
constructor Create(AOwner : TComponent);
override;
end;
TeeRadioButton = class(TRadioButton)
private
f_PrevCharCode : Word;
private
procedure WMChar(Var Msg: TWMChar); message WM_CHAR;
procedure WMKeyDown(Var Msg: TWMKeyDown); message WM_KEYDOWN;
procedure WMSysKeyDown(var Msg: TWMSysKeyDown); message WM_SYSKEYDOWN;
procedure WMEraseBkgnd(var Message : TWMEraseBkgnd); message WM_ERASEBKGND;
end;
TeeRadioButton1 = class(TeeRadioButton)
private
procedure WMMouseActivate(var Message: TMessage); message WM_MOUSEACTIVATE;
procedure WMLButtonDown(var Msg : TMessage{TWMLButtonDown});
message WM_LBUTTONDOWN;
{-}
protected
function CanFocus: Boolean; override;
procedure WndProc(var Message: TMessage); override;
end;//TeeRadioButton1*)
procedure Register;
implementation
{$IfDef eeNeedOvc}
uses
OvcBase,
OvcCmd,
OvcConst;
{$EndIf eeNeedOvc}
procedure Register;
begin
RegisterComponents('Everest', [TeeButton]);
end;
function IsHandledShortcut(var Msg: TWMKeyDown; var aCharCode: Word): Boolean;
{$IfDef eeNeedOvc}
var
l_Controller : TOvcController;
{$EndIf eeNeedOvc}
begin
aCharCode := 0;
Result := false;
{$IfDef eeNeedOvc}
l_Controller := GetDefController;
if Assigned(l_Controller) then
with l_Controller.EntryCommands do
if TranslateUsing([], TMessage(Msg), GetTickCount) = ccShortCut then
begin
Msg.Result := 0; {indicate that this message was processed}
aCharCode := Msg.CharCode;
Result := true;
end;
{$EndIf eeNeedOvc}
end;
constructor TeeButton.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
DoubleBuffered := True;
end;
procedure TeeButton.WMChar(Var Msg: TWMChar);
begin
if (f_PrevCharCode <> 0) and (Msg.CharCode = f_PrevCharCode) then
Exit;
inherited;
end;
procedure TeeButton.WMEraseBkgnd(var Msg: TWMEraseBkgnd);
begin
Msg.Result := Integer(True);
end;
procedure TeeButton.WMKeyDown(Var Msg: TWMKeyDown);
begin
if IsHandledShortcut(Msg, f_PrevCharCode) then
Exit;
inherited;
end;
procedure TeeButton.WMSysKeyDown(var Msg: TWMSysKeyDown);
begin
if IsHandledShortcut(Msg, f_PrevCharCode) then
Exit;
inherited;
end;
(*constructor TeeBitBtn.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
end;
procedure TeeBitBtn.WMChar(Var Msg: TWMChar);
begin
if (f_PrevCharCode <> 0) and (Msg.CharCode = f_PrevCharCode) then
Exit;
inherited;
end;
procedure TeeBitBtn.WMEraseBkgnd(var Msg: TWMEraseBkgnd);
begin
Msg.Result := Integer(True);
end;
procedure TeeBitBtn.WMKeyDown(Var Msg: TWMKeyDown);
begin
if IsHandledShortcut(Msg, f_PrevCharCode) then
Exit;
inherited;
end;
procedure TeeBitBtn.WMSysKeyDown(var Msg: TWMSysKeyDown);
begin
if IsHandledShortcut(Msg, f_PrevCharCode) then
Exit;
inherited;
end;
procedure TeeRadioButton.WMChar(Var Msg: TWMChar);
begin
if (f_PrevCharCode <> 0) and (Msg.CharCode = f_PrevCharCode) then
Exit;
inherited;
end;
procedure TeeRadioButton.WMEraseBkgnd(var Message: TWMEraseBkgnd);
begin
Message.Result := Integer(True);
end;
procedure TeeRadioButton.WMKeyDown(Var Msg: TWMKeyDown);
begin
if IsHandledShortcut(Msg, f_PrevCharCode) then
Exit;
inherited;
end;
procedure TeeRadioButton.WMSysKeyDown(var Msg: TWMSysKeyDown);
begin
if IsHandledShortcut(Msg, f_PrevCharCode) then
Exit;
inherited;
end;
// start class TeeRadioButton1
procedure TeeRadioButton1.WMMouseActivate(var Message: TMessage);
begin
if not (csDesigning in ComponentState) then
Message.Result := MA_NOACTIVATE
else
inherited;
end;
procedure TeeRadioButton1.WMLButtonDown(var Msg : TMessage{TWMLButtonDown});
//message WM_LBUTTONDOWN;
{-}
begin
if not (csDesigning in ComponentState) then
Checked := true
else
inherited;
end;
function TeeRadioButton1.CanFocus: Boolean;
begin
if not (csDesigning in ComponentState) then
Result := false
else
Result := inherited CanFocus;
end;
procedure TeeRadioButton1.WndProc(var Message: TMessage);
begin
case Message.Msg of
WM_LBUTTONDOWN, WM_LBUTTONDBLCLK:
if not (csDesigning in ComponentState) then
begin
Checked := true;
Exit;
end;//not (csDesigning in ComponentState)
end;//case Message.Msg
inherited;
end;*)
end.
|
unit TTSCRATTable;
interface
uses
Classes, DB, DBISAMTb, SysUtils, DBISAMTableAU, DataBuf;
type
TTTSCRATRecord = record
PCollateralCode: String[8];
PRate: Currency;
End;
TTTSCRATBuffer = class(TDataBuf)
protected
function PtrIndex(Index:integer):Pointer;override;
public
Data: TTTSCRATRecord;
function FieldNameToIndex(s:string):integer;override;
function FieldType(index:integer):TFieldType;override;
end;
TEITTSCRAT = (TTSCRATPrimaryKey);
TTTSCRATTable = class( TDBISAMTableAU )
private
FDFCollateralCode: TStringField;
FDFRate: TCurrencyField;
procedure SetPCollateralCode(const Value: String);
function GetPCollateralCode:String;
procedure SetPRate(const Value: Currency);
function GetPRate:Currency;
procedure SetEnumIndex(Value: TEITTSCRAT);
function GetEnumIndex: TEITTSCRAT;
protected
procedure CreateFields; reintroduce;
procedure SetActive(Value: Boolean); override;
procedure LoadFieldDefs(AStringList:TStringList);override;
procedure LoadIndexDefs(AStringList:TStringList);override;
public
function GetDataBuffer:TTTSCRATRecord;
procedure StoreDataBuffer(ABuffer:TTTSCRATRecord);
property DFCollateralCode: TStringField read FDFCollateralCode;
property DFRate: TCurrencyField read FDFRate;
property PCollateralCode: String read GetPCollateralCode write SetPCollateralCode;
property PRate: Currency read GetPRate write SetPRate;
published
property Active write SetActive;
property EnumIndex: TEITTSCRAT read GetEnumIndex write SetEnumIndex;
end; { TTTSCRATTable }
procedure Register;
implementation
procedure TTTSCRATTable.CreateFields;
begin
FDFCollateralCode := CreateField( 'CollateralCode' ) as TStringField;
FDFRate := CreateField( 'Rate' ) as TCurrencyField;
end; { TTTSCRATTable.CreateFields }
procedure TTTSCRATTable.SetActive(Value: Boolean);
begin
inherited SetActive(Value);
if Active then
CreateFields;
end; { TTTSCRATTable.SetActive }
procedure TTTSCRATTable.SetPCollateralCode(const Value: String);
begin
DFCollateralCode.Value := Value;
end;
function TTTSCRATTable.GetPCollateralCode:String;
begin
result := DFCollateralCode.Value;
end;
procedure TTTSCRATTable.SetPRate(const Value: Currency);
begin
DFRate.Value := Value;
end;
function TTTSCRATTable.GetPRate:Currency;
begin
result := DFRate.Value;
end;
procedure TTTSCRATTable.LoadFieldDefs(AStringList: TStringList);
begin
inherited;
with AstringList do
begin
Add('CollateralCode, String, 8, N');
Add('Rate, Currency, 0, N');
end;
end;
procedure TTTSCRATTable.LoadIndexDefs(AStringList: TStringList);
begin
inherited;
with AstringList do
begin
Add('PrimaryKey, CollateralCode, Y, Y, N, N');
end;
end;
procedure TTTSCRATTable.SetEnumIndex(Value: TEITTSCRAT);
begin
case Value of
TTSCRATPrimaryKey : IndexName := '';
end;
end;
function TTTSCRATTable.GetDataBuffer:TTTSCRATRecord;
var buf: TTTSCRATRecord;
begin
fillchar(buf, sizeof(buf), 0);
buf.PCollateralCode := DFCollateralCode.Value;
buf.PRate := DFRate.Value;
result := buf;
end;
procedure TTTSCRATTable.StoreDataBuffer(ABuffer:TTTSCRATRecord);
begin
DFCollateralCode.Value := ABuffer.PCollateralCode;
DFRate.Value := ABuffer.PRate;
end;
function TTTSCRATTable.GetEnumIndex: TEITTSCRAT;
var iname : string;
begin
result := TTSCRATPrimaryKey;
iname := uppercase(indexname);
if iname = '' then result := TTSCRATPrimaryKey;
end;
(********************************************)
(************ Register Component ************)
(********************************************)
procedure Register;
begin
RegisterComponents( 'TTS Tables', [ TTTSCRATTable, TTTSCRATBuffer ] );
end; { Register }
function TTTSCRATBuffer.FieldNameToIndex(s:string):integer;
const flist:array[1..2] of string = ('COLLATERALCODE','RATE' );
var x : integer;
begin
s := uppercase(s);
x := 1;
while (x <= 2) and (flist[x] <> s) do inc(x);
if x <= 2 then result := x else result := 0;
end;
function TTTSCRATBuffer.FieldType(index:integer):TFieldType;
begin
result := ftUnknown;
case index of
1 : result := ftString;
2 : result := ftCurrency;
end;
end;
function TTTSCRATBuffer.PtrIndex(index:integer):Pointer;
begin
result := nil;
case index of
1 : result := @Data.PCollateralCode;
2 : result := @Data.PRate;
end;
end;
end.
|
unit StrategyControl;
interface
uses
PlayerControl, WorldControl, GameControl, MoveControl;
type
TStrategy = class
public
constructor Create; virtual;
procedure Move(me: TPlayer; world: TWorld; game: TGame; move: TMove); virtual; abstract;
end;
implementation
constructor TStrategy.Create;
begin
inherited Create;
end;
end.
|
unit App;
{ Based on Simple_TextureCubemap.c from
Book: OpenGL(R) ES 2.0 Programming Guide
Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner
ISBN-10: 0321502795
ISBN-13: 9780321502797
Publisher: Addison-Wesley Professional
URLs: http://safari.informit.com/9780321563835
http://www.opengles-book.com }
{$INCLUDE 'Sample.inc'}
interface
uses
System.Classes,
Neslib.Ooogles,
Neslib.FastMath,
Sample.App,
Sample.Geometry;
type
TSimpleTextureCubeMapApp = class(TApplication)
private
FProgram: TGLProgram;
FAttrPosition: TGLVertexAttrib;
FAttrNormal: TGLVertexAttrib;
FUniSampler: TGLUniform;
FTexture: TGLTexture;
FSphere: TSphereGeometry;
public
procedure Initialize; override;
procedure Render(const ADeltaTimeSec, ATotalTimeSec: Double); override;
procedure Shutdown; override;
procedure KeyDown(const AKey: Integer; const AShift: TShiftState); override;
end;
implementation
uses
{$INCLUDE 'OpenGL.inc'}
System.UITypes,
Sample.Texture;
{ TSimpleTextureCubeMapApp }
procedure TSimpleTextureCubeMapApp.Initialize;
var
VertexShader, FragmentShader: TGLShader;
begin
{ Compile vertex and fragment shaders }
VertexShader.New(TGLShaderType.Vertex,
'attribute vec4 a_position;'#10+
'attribute vec3 a_normal;'#10+
'varying vec3 v_normal;'#10+
'void main()'#10+
'{'#10+
' gl_Position = a_position;'#10+
' v_normal = a_normal;'#10+
'}');
VertexShader.Compile;
FragmentShader.New(TGLShaderType.Fragment,
'precision mediump float;'#10+
'varying vec3 v_normal;'#10+
'uniform samplerCube s_texture;'#10+
'void main()'#10+
'{'#10+
' gl_FragColor = textureCube(s_texture, v_normal);'#10+
'}');
FragmentShader.Compile;
{ Link shaders into program }
FProgram.New(VertexShader, FragmentShader);
FProgram.Link;
{ We don't need the shaders anymore. Note that the shaders won't actually be
deleted until the program is deleted. }
VertexShader.Delete;
FragmentShader.Delete;
{ Initialize vertex attributes }
FAttrPosition.Init(FProgram, 'a_position');
FAttrNormal.Init(FProgram, 'a_normal');
{ Initialize uniform }
FUniSampler.Init(FProgram, 's_texture');
{ Load the texture }
FTexture := CreateSimpleTextureCubeMap;
{ Generate the geometry data }
FSphere.Generate(128, 0.75);
{ Set clear color to black }
gl.ClearColor(0, 0, 0, 0);
{ Enable culling }
gl.CullFace(TGLFace.Back);
gl.Enable(TGLCapability.CullFace);
end;
procedure TSimpleTextureCubeMapApp.KeyDown(const AKey: Integer; const AShift: TShiftState);
begin
{ Terminate app when Esc key is pressed }
if (AKey = vkEscape) then
Terminate;
end;
procedure TSimpleTextureCubeMapApp.Render(const ADeltaTimeSec, ATotalTimeSec: Double);
begin
{ Clear the color buffer }
gl.Clear([TGLClear.Color]);
{ Use the program }
FProgram.Use;
{ Set the data for the vertex attributes }
FAttrPosition.SetData<TVector3>(FSphere.Positions);
FAttrPosition.Enable;
FAttrNormal.SetData<TVector3>(FSphere.Normals);
FAttrNormal.Enable;
{ Bind the texture }
FTexture.BindToTextureUnit(0);
{ Set the texture sampler to texture unit to 0 }
FUniSampler.SetValue(0);
{ Draw the sphere }
FSphere.DrawWithIndices;
end;
procedure TSimpleTextureCubeMapApp.Shutdown;
begin
{ Release resources }
FTexture.Delete;
FProgram.Delete;
end;
end.
|
unit wwMinds;
interface
Uses
Types, Contnrs, IniFiles,
wwClasses, wwTypes;
type
TwwMind = class//(TThread)
private
f_CurrentThing: TwwThing;
FMaxThingAge: Integer;
FMaxThingLength: Integer;
FWeight: Integer;
FTotalLength: Int64;
FTotalWorms: Integer;
FTotalAge: Int64;
FAverageThinkTime: Integer;
FEnabled: Boolean;
function GetAverageLength: Integer;
procedure SetEnabled(const Value: Boolean);
protected
function CheckPoint(From: TPoint; Dir: TwwDirection): Boolean;
function GetCaption: String; virtual; abstract;
function GetEnglishCaption: String; virtual;
function IsFree(const aPOint: TPoint): Boolean;
function IsBusy(const aPOint: TPoint): Boolean;
function IsMe(const aPoint: TPoint): Boolean;
function Thinking: TwwDirection; virtual; abstract;
property Thing: TwwThing
read f_CurrentThing;
public
function Think(aFor: TwwThing): TwwDirection;
function FindTarget(aThing: TwwThing): TwwThing; virtual;
function IsLegal(aPoint: TPoint): Boolean;
procedure ReadValues(DataFile: TIniFile);
procedure WriteValues(DataFile: TIniFile);
procedure PostMorten(aThing: TwwThing);
public
property AverageLength: Integer
read GetAverageLength;
property Caption: String
read GetCaption;
property Enabled: Boolean read FEnabled write SetEnabled;
property EnglishCaption: String
read GetEnglishCaption;
property MaxThingLength: Integer read FMaxThingLength;
property MaxThingAge: Integer read FMaxThingAge;
property Weight: Integer
read FWeight
write FWeight;
property TotalLength: Int64
read FTotalLength;
property TotalWorms: Integer
read FTotalWorms;
property TotalAge: Int64
read FTotalAge;
property AverageThinkTime: Integer read FAverageThinkTime;
end;
TwwMindCenter = class(TObjectList)
private
FDataFileName: String;
FDataFile: TIniFile;
function GetMinds(Index: Integer): TwwMind;
public
constructor Create(aDataFileName: String); reintroduce;
destructor Destroy; override;
function RandomMind: TwwMind;
procedure AddMind(aMind: TwwMind);
procedure Resort;
property Minds[Index: Integer]: TwwMind
read GetMinds;
end;
implementation
Uses
Math,
WormsWorld, wwWorms, wwUtils;
{ TwwMind }
function TwwMind.GetEnglishCaption: String;
begin
Result:= ClassName;
end;
function TwwMind.IsBusy(const aPOint: TPoint): Boolean;
begin
Result:= f_CurrentThing.IsBusy(aPoint);
end;
function TwwMind.IsFree(const aPOint: TPoint): Boolean;
begin
Result:= f_CurrentThing.IsFree(aPoint);
end;
function TwwMind.IsMe(const aPoint: TPoint): Boolean;
begin
Result:= f_CurrentThing.IsMe(aPoint);
end;
function TwwMind.Think(aFor: TwwThing): TwwDirection;
begin
FMaxThingLength:= Max(aFor.Length, MaxThingLength);
FMaxThingAge:= Max(FMaxThingAge, aFor.Age);
f_CurrentThing:= aFor;
if (Thing <> nil) and (Thing is TwwWorm) then
begin
if (TwwWorm(Thing).Target = nil) or (TwwWorm(Thing).Target.IsDead) then
TwwWorm(Thing).Target:= FindTarget(Thing);
Result:= Thinking;
end
else
Result:= dtNone;
end;
function TwwMind.FindTarget(aThing: TwwThing): TwwThing;
begin
Result := (aThing.World as TWormsField).NearestTarget(aThing.Head.Position);
end;
function TwwMind.IsLegal(aPoint: TPoint): Boolean;
begin
Result := Thing.World.IsLegal(aPoint);
end;
procedure TwwMind.ReadValues(DataFile: TIniFile);
begin
with DataFile do
begin
FMaxThingLength:= ReadInteger(Caption, 'MaxLen', 0);
FMaxThingAge:= ReadInteger(Caption, 'MaxAge', 0);
FWeight:= ReadInteger(Caption, 'Weight', 0);
FTotalLength:= ReadInteger(Caption, 'TotalLen', 0);
FTotalAge:= ReadInteger(Caption, 'TotalAge', 0);
FTotalWorms:= ReadInteger(Caption, 'Worms', 0);
FAverageThinkTime:= ReadInteger(Caption, 'ThinkTime', 0);
FEnabled:= ReadBool(Caption, 'Enabled', True);
end;
end;
procedure TwwMind.SetEnabled(const Value: Boolean);
begin
FEnabled := Value;
end;
procedure TwwMind.WriteValues(DataFile: TIniFile);
begin
with DataFile do
begin
WriteInteger(Caption, 'MaxLen', FMaxThingLength);
WriteInteger(Caption, 'MaxAge', FMaxThingAge);
WriteInteger(Caption, 'Weight', FWeight);
WriteInteger(Caption, 'TotalLen', FTotalLength);
WriteInteger(Caption, 'TotalAge', FTotalAge);
WriteInteger(Caption, 'Worms', FTotalWorms);
WriteInteger(Caption, 'ThinkTime', FAverageThinkTime);
WriteBool(Caption, 'Enabled', FEnabled);
end;
end;
function TwwMind.CheckPoint(From: TPoint; Dir: TwwDirection): Boolean;
begin
Result:= IsFree(MovePoint(From, Dir));
end;
procedure TwwMind.PostMorten(aThing: TwwThing);
begin
Inc(FTotalAge, aThing.Age);
Inc(FTotalLength, aThing.Length);
Inc(FTotalWorms);
if (aThing is TwwWorm) and (TwwWorm(aThing).TargetCount <> 0) then
FAverageThinkTime:= Max(FAverageThinkTime, aThing.Age div TwwWorm(aThing).TargetCount)
else
FAverageThinkTime:= 0;
end;
function TwwMind.GetAverageLength: Integer;
begin
if TotalWorms <> 0 then
Result:= TotalLength div TotalWorms
else
Result:= 0;
end;
{ TwwMindCenter }
constructor TwwMindCenter.Create(aDataFileName: String);
begin
inherited Create;
FDataFileName:= aDataFileName;
FDataFile:= TIniFile.Create(FDataFileName);
end;
destructor TwwMindCenter.Destroy;
var
i: Integer;
begin
for i:=0 to Pred(Count) do
Minds[i].WriteValues(FDataFile);
FDataFile.Free;
inherited;
end;
function TwwMindCenter.GetMinds(Index: Integer): TwwMind;
begin
Result:= TwwMind(Items[Index]);
end;
function TwwMindCenter.RandomMind: TwwMind;
var
l_Total, l_Weight: Integer;
i,j, l_index: Integer;
l_Arr: array[0..99] of Integer;
begin
if Count > 0 then
begin
l_Total:= 0;
FillChar(l_arr, SizeOf(l_Arr), 0);
for i:= 0 to Pred(Count) do
begin
if Minds[i].Enabled then
begin
if Minds[i].AverageLength = 0 then
Inc(l_Total, 50)
else
Inc(l_Total, Minds[i].AverageLength);
end;
end; // for i
l_index:= 0;
for i:= 0 to Pred(Count) do
begin
if Minds[i].Enabled then
begin
if Minds[i].AverageLength = 0 then
l_Weight:= Round(50*100 / l_Total)
else
l_Weight:= Round(Minds[i].AverageLength*100 / l_Total);
for j:= l_index to Pred(Min(100, l_index+l_Weight)) do
l_Arr[j]:= i;
Inc(l_Index, l_Weight);
Minds[i].Weight:= l_Weight;
end; // Minds[i].Enabled
end; // for i
l_index:= RandomFrom(l_Arr);
Result:= Minds[l_index];
end
else
Result:= nil;
end;
procedure TwwMindCenter.AddMind(aMind: TwwMind);
begin
Add(aMind);
aMind.Enabled:= True;
aMind.ReadValues(FDataFile);
end;
function CompareLength(Item1, Item2: TObject): Integer;
begin
Result := CompareValue(TwwMind(Item1).MaxThingLength, TwwMind(Item2).MaxThingLength);
end;
procedure TwwMindCenter.Resort;
begin
Sort(@CompareLength);
end;
end.
|
unit CalcAll;
interface
uses
SysUtils,
Classes,
tfTypes,
tfBytes,
tfHashes;
procedure CalcHash(const FileName: string);
implementation
procedure CalcHash(const FileName: string);
const
BufSize = 16 * 1024;
var
HashName: array of string;
HashArr: array of THash;
Stream: TStream;
Buffer: array[0 .. BufSize - 1] of Byte;
I, N, HashCount, L: Integer;
begin
HashCount:= THash.AlgCount;
SetLength(HashName, HashCount);
SetLength(HashArr, HashCount);
L:= 0;
for I:= 0 to HashCount - 1 do begin
HashName[I]:= THash.AlgName(I);
if Length(HashName[I]) > L then L:= Length(HashName[I]);
HashArr[I]:= THash(HashName[I]);
end;
Stream:= TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite);
try
repeat
N:= Stream.Read(Buffer, BufSize);
if N <= 0 then Break
else begin
for I:= 0 to HashCount - 1 do begin
HashArr[I].Update(Buffer, N);
end;
end;
until False;
finally
Stream.Free;
end;
for I:= 0 to HashCount - 1 do begin
Writeln(HashName[I]:L, ': ', HashArr[I].Digest.ToHex);
end;
end;
end.
|
unit Main;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
NMUDP, ExtCtrls, IniFiles, StdCtrls, Misc, DataTypes;
type
TForm1 = class(TForm)
NMUDP1: TNMUDP;
Timer: TTimer;
StTxtP1: TStaticText;
StTxtP2: TStaticText;
CheckBox: TCheckBox;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure TimerTimer(Sender: TObject);
private
{ Private declarations }
procedure AppOnIdle(Sender: TObject; var Done: Boolean);
public
{ Public declarations }
PipFile:File of TPipFileRec;
PipTime:TPipTime;
TimerTicked:Boolean;
procedure SendNextRec;
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
var
PFSecond:TPipTime;
procedure TForm1.FormCreate(Sender: TObject);
const
Cfg='Config';
var
Ini:TIniFile;
FName:String;
Time:TSystemTime;
begin
Ini:=TIniFile.Create(GetModuleFullName+'.ini');
try
try
NMUDP1.RemoteHost:=Ini.ReadString(Cfg,'RemoteHost','');
NMUDP1.RemotePort:=Ini.ReadInteger(Cfg,'RemotePort',0);
FName:=Ini.ReadString(Cfg,'PipFileName','filenotfound');
AssignFile(PipFile,FName);
Reset(PipFile);
finally
Ini.Free;
end;
except
Close;
end;
GetLocalTime(Time);
PipTime.Year:=Time.wYear-1900;
PipTime.Month:=Time.wMonth;
PipTime.Day:=Time.wDay;
PipTime.Hour:=Time.wHour;
PipTime.Min:=Time.wMinute;
PipTime.Sec:=Time.wSecond;
FillChar(PFSecond,SizeOf(PFSecond),0);
PFSecond.Sec:=1;
Application.OnIdle:=AppOnIdle;
end;
procedure TForm1.SendNextRec;
type
TCharArray=packed array[0..15] of Char;
var
R:TPipFileRec;
Buf:TCharArray;
SR:TSclRec absolute Buf;
S:String;
begin
FillChar(Buf,SizeOf(Buf),0);
SR.Time:=PipTime;
NextPipTime(PipTime,PFSecond);
try
if EOF(PipFile) then Seek(PipFile,0);
Read(PipFile,R);
// Pressure 1
if (R.F1 and $02<>0)and(R.F1 and $04=0) then begin
SR.Number:=1;
SR.p:=R.p1;
NMUDP1.SendBuffer(Buf,SizeOf(Buf));
Str(R.p1:6:3,S);
end
else S:='Ραξι';
StTxtP1.Caption:=S;
// Pressure 2
if (R.F2 and $02<>0)and(R.F2 and $04=0) then begin
SR.Number:=2;
SR.p:=R.p2;
NMUDP1.SendBuffer(Buf,SizeOf(Buf));
Str(R.p2:6:3,S);
end
else S:='Ραξι';
StTxtP2.Caption:=S;
except
Halt(1);
end;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
CloseFile(PipFile);
end;
procedure TForm1.TimerTimer(Sender: TObject);
begin
if not CheckBox.Checked then SendNextRec;
TimerTicked:=True;
end;
procedure TForm1.AppOnIdle(Sender: TObject; var Done: Boolean);
var
i:Integer;
begin
if CheckBox.Checked and TimerTicked
then for i:=1 to 60 do SendNextRec;
TimerTicked:=False;
end;
end.
|
{ Subroutine SST_W_C_SCOPE_POP
*
* Restore the previous scope by popping it from the stack. This undoes what
* subroutine SST_W_C_SCOPE_PUSH does.
}
module sst_w_c_SCOPE_POP;
define sst_w_c_scope_pop;
%include 'sst_w_c.ins.pas';
procedure sst_w_c_scope_pop; {restore previous scope as current scope}
const
max_msg_parms = 1; {max parameters we can pass to a message}
var
dyn: sst_out_dyn_t; {saved current writing position}
msg_parm: {parameter references for messages}
array[1..max_msg_parms] of sys_parm_msg_t;
begin
dyn := sst_out.dyn_p^; {save current writing position data}
frame_scope_p := frame_scope_p^.prev_p; {set previous scope frame as current}
util_stack_pop (sst_stack, sizeof(frame_scope_p^)); {remove old stack frame}
%debug; write (sst_stack^.last_p^.curr_adr, ' ');
%debug; writeln ('SCOPE POP');
sst_scope_p := frame_scope_p^.scope_p; {restore to scope of old stack frame}
sst_names_p := sst_scope_p;
case frame_scope_p^.sment_type of {what kind of statement now writing ?}
sment_type_declg_k: begin {new statement type is global declarations}
sst_out.dyn_p := addr(pos_declg);
end;
sment_type_decll_k: begin {new statement type is local declarations}
sst_out.dyn_p := addr(frame_scope_p^.pos_decll);
end;
sment_type_exec_k: begin {new statement type is executable}
sst_out.dyn_p := addr(frame_scope_p^.pos_exec);
end;
otherwise
sys_msg_parm_int (msg_parm[1], ord(frame_scope_p^.sment_type));
sys_message_bomb ('sst_c_write', 'statement_type_curr_bad', msg_parm, 1);
end;
sst_out.dyn_p^ := dyn; {update new position of new statement to here}
end;
|
{ registerrx unit
Copyright (C) 2005-2010 Lagunov Aleksey alexs@yandex.ru and Lazarus team
original conception from rx library for Delphi (c)
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version with the following modification:
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent modules,and
to copy and distribute the resulting executable under terms of your choice,
provided that you also meet, for each linked independent module, the terms
and conditions of the license of that module. An independent module is a
module which is not derived from or based on this library. If you modify
this library, you may extend this exception to your version of the library,
but you are not obligated to do so. If you do not wish to do so, delete this
exception statement from your 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 Library General Public License
for more details.
You should have received a copy of the GNU Library General Public License
along with this library; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
}
unit registerrx;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, LResources, LazarusPackageIntf;
const
RxCtrllPageName = 'RX Controls';
RxToolsPageName = 'RX Tools';
procedure Register;
implementation
uses
PropEdits, folderlister, duallist, RxHistoryNavigator,
curredit, rxswitch, rxdice, rxtoolbar,
{$IFDEF USE_TRXXPManifest}
rxxpman,
{$ENDIF}
PageMngr,
{$IFDEF USE_TRxAppIcon}
RxAppIcon,
{$ENDIF}
Dialogs, ComponentEditors, DBPropEdits, rxctrls,
RxCustomChartPanel, AutoPanel, pickdate, tooledit, rxclock,
rxspin, RxTimeEdit, rxDateRangeEditUnit,
RxAboutDialog, RxViewsPanel, RxMDI;
{$IFDEF USE_TRxAppIcon}
procedure RegisterRxAppIcon;
begin
RegisterComponents(RxCtrllPageName,[TRxAppIcon]);
end;
{$ENDIF}
{$IFDEF USE_TRXXPManifest}
procedure RegisterRxXPMan;
begin
RegisterComponents(RxCtrllPageName,[TRXXPManifest]);
end;
{$ENDIF}
procedure RegisterPageMngr;
begin
RegisterComponents(RxCtrllPageName,[TPageManager]);
end;
procedure RegisterDualList;
begin
RegisterComponents(RxCtrllPageName,[TDualListDialog]);
end;
procedure RegisterCurrEdit;
begin
RegisterComponents(RxCtrllPageName,[TCurrencyEdit]);
end;
procedure RegisterRXSwitch;
begin
RegisterComponents(RxCtrllPageName,[TRxSwitch]);
end;
procedure RegisterRXDice;
begin
RegisterComponents(RxCtrllPageName,[TRxDice]);
end;
procedure RegisterFolderLister;
begin
RegisterComponents(RxCtrllPageName,[TFolderLister]);
end;
procedure RegisterRxToolBar;
begin
RegisterComponents(RxCtrllPageName,[TToolPanel]);
end;
procedure RegisterRxCtrls;
begin
RegisterComponents(RxCtrllPageName,[TRxLabel, TSecretPanel, TRxSpeedButton, TRxRadioGroup]);
end;
procedure RegisterChartPanel;
begin
RegisterComponents(RxCtrllPageName,[TRxChart]);
end;
procedure RegisterAutoPanel;
begin
RegisterComponents(RxCtrllPageName,[TAutoPanel]);
end;
procedure RegisterPickDate;
begin
RegisterComponents(RxCtrllPageName,[TRxCalendarGrid]);
end;
procedure RegisterToolEdit;
begin
RegisterComponents(RxCtrllPageName,[TRxDateEdit]);
end;
procedure RegisterRxClock;
begin
RegisterComponents(RxCtrllPageName,[TRxClock]);
end;
procedure RegisterRxSpin;
begin
RegisterComponents(RxCtrllPageName,[TRxSpinButton, TRxSpinEdit]);
end;
procedure RegisterRxTimeEdit;
begin
RegisterComponents(RxCtrllPageName,[TRxTimeEdit]);
end;
procedure RegisterRxAboutDialog;
begin
RegisterComponents(RxCtrllPageName,[TRxAboutDialog]);
end;
procedure RegisterRxViewsPanel;
begin
RegisterComponents(RxCtrllPageName,[TRxViewsPanel]);
end;
procedure RegisterRxMDI;
begin
RegisterComponents(RxCtrllPageName,[TRxMDICloseButton, TRxMDIPanel, TRxMDITasks]);
end;
procedure RegisterRxHistoryNavigator;
begin
RegisterComponents(RxToolsPageName,[TRxHistoryNavigator]);
end;
procedure RegisterrxDateRangeEditUnit;
begin
RegisterComponents(RxCtrllPageName,[TRxDateRangeEdit]);
end;
procedure Register;
begin
//RX
RegisterUnit('folderlister', @RegisterFolderLister);
RegisterUnit('duallist', @RegisterDualList);
RegisterUnit('curredit', @RegisterCurrEdit);
RegisterUnit('rxswitch', @RegisterRXSwitch);
RegisterUnit('rxdice', @RegisterRXDice);
{$IFDEF USE_TRXXPManifest}
RegisterUnit('RxXPMan', @RegisterRxXPMan);
{$ENDIF}
RegisterUnit('PageMngr', @RegisterPageMngr);
RegisterUnit('rxtoolbar', @RegisterRxToolBar);
{$IFDEF USE_TRxAppIcon}
RegisterUnit('rxappicon', @RegisterRxAppIcon);
{$ENDIF}
RegisterUnit('rxctrls', @RegisterRxCtrls);
RegisterUnit('RxCustomChartPanel', @RegisterChartPanel);
RegisterUnit('AutoPanel', @RegisterAutoPanel);
RegisterUnit('pickdate', @RegisterPickDate);
RegisterUnit('tooledit', @RegisterToolEdit);
RegisterUnit('rxclock', @RegisterRxClock);
RegisterUnit('rxspin', @RegisterRxSpin);
RegisterUnit('RxTimeEdit', @RegisterRxTimeEdit);
RegisterUnit('RxAboutDialog', @RegisterRxAboutDialog);
RegisterUnit('RxViewsPanel', @RegisterRxViewsPanel);
RegisterUnit('RxHistoryNavigator', @RegisterRxHistoryNavigator);
RegisterUnit('RxMDI', @RegisterRxMDI);
RegisterUnit('rxDateRangeEditUnit', @RegisterrxDateRangeEditUnit);
end;
initialization
{$i rx.lrs}
end.
|
{ *********************************************************** }
{ * TForge Library * }
{ * Copyright (c) Sergey Kasandrov 1997, 2016 * }
{ * ------------------------------------------------------- * }
{ * # engine unit * }
{ *********************************************************** }
{ * De Morgan's laws: * }
{ * # not(A and B) = (not A) or (not B) * }
{ * # not(A or B) = (not A) and (not B) * }
{ * also used: * }
{ * # -A = (not A) + 1 = not(A - 1) * }
{ * # not(A xor B) = (not A) xor B = A xor (not B) * }
{ * # (not A) xor (not B) = A xor B * }
{ *********************************************************** }
{
Win64 Register Usage
--------------------
RAX Volatile Return value register
RCX Volatile First integer argument
RDX Volatile Second integer argument
R8 Volatile Third integer argument
R9 Volatile Fourth integer argument
R10:R11 Volatile
R12:R15 Nonvolatile
RDI Nonvolatile
RSI Nonvolatile
RBX Nonvolatile
RBP Nonvolatile
RSP Nonvolatile
XMM0 Volatile First FP argument
XMM1 Volatile Second FP argument
XMM2 Volatile Third FP argument
XMM3 Volatile Fourth FP argument
XMM4:XMM5 Volatile
XMM6:XMM15 Nonvolatile
}
unit arrProcs;
{$I TFL.inc}
{$IFDEF TFL_LIMB32_CPU386_WIN32}
{$DEFINE ASM86}
{$ENDIF}
{$IFDEF TFL_LIMB32_CPUX64_WIN64}
{$DEFINE ASM64}
{$ENDIF}
interface
uses tfLimbs;
{ Utilities}
function arrGetLimbCount(A: PLimb; L: Cardinal): Cardinal;
{ Addition primitives }
function arrAdd(A, B, Res: PLimb; LA, LB: Cardinal): Boolean;
function arrAddLimb(A: PLimb; Limb: TLimb; Res: PLimb; LA: Cardinal): Boolean;
function arrInc(A: PLimb; Res: PLimb; L: Cardinal): Boolean;
function arrSelfAdd(A, B: PLimb; LA, LB: Cardinal): Boolean;
function arrSelfAddLimb(A: PLimb; Limb: TLimb; L: Cardinal): Boolean;
function arrSelfInc(A: PLimb; L: Cardinal): Boolean;
{ Subtraction primitives }
function arrSub(A, B, Res: PLimb; LA, LB: Cardinal): Boolean;
function arrSelfSub(A, B: PLimb; LA, LB: Cardinal): Boolean;
function arrSubLimb(A: PLimb; Limb: TLimb; Res: PLimb; L: Cardinal): Boolean;
function arrSelfSubLimb(A: PLimb; Limb: TLimb; L: Cardinal): Boolean;
function arrDec(A: PLimb; Res: PLimb; L: Cardinal): Boolean;
function arrSelfDec(A: PLimb; L: Cardinal): Boolean;
{ Multiplication primitives }
function arrMul(A, B, Res: PLimb; LA, LB: Cardinal): Boolean;
function arrMulLimb(A: PLimb; Limb: TLimb; Res: PLimb; L: Cardinal): Boolean;
function arrSelfMulLimb(A: PLimb; Limb: TLimb; L: Cardinal): Boolean;
function arrSqr(A, Res: PLimb; LA: Cardinal): Boolean;
{ Division primitives }
// normalized division (Divisor[DsrLen-1] and $80000000 <> 0)
// in: Dividend: Dividend;
// Divisor: Divisor;
// DndLen: Dividend Length
// DsrLen: Divisor Length
// out: Quotient:= Dividend div Divisor
// Dividend:= Dividend mod Divisor
procedure arrNormDivMod(Dividend, Divisor, Quotient: PLimb;
DndLen, DsrLen: TLimb);
procedure arrNormMod(Dividend, Divisor: PLimb;
DndLen, DsrLen: TLimb);
function arrDivModLimb(A, Q: PLimb; L, D: TLimb): TLimb;
function arrSelfDivModLimb(A: PLimb; L: Cardinal; D: TLimb): TLimb;
function arrCmp(A, B: PLimb; L: Cardinal): Integer;
function arrSqrt(A, Root: PLimb; LA: Cardinal): Cardinal;
{ Bitwise shifts }
function arrShlShort(A, Res: PLimb; LA, Shift: Cardinal): Cardinal;
function arrShrShort(A, Res: PLimb; LA, Shift: Cardinal): Cardinal;
function arrShlOne(A, Res: PLimb; LA: Cardinal): Cardinal;
function arrShrOne(A, Res: PLimb; LA: Cardinal): Cardinal;
function arrSelfShrOne(A: PLimb; LA: Cardinal): Cardinal;
{ Bitwise boolean }
procedure arrAnd(A, B, Res: PLimb; L: Cardinal);
procedure arrAndTwoCompl(A, B, Res: PLimb; LA, LB: Cardinal);
function arrAndTwoCompl2(A, B, Res: PLimb; LA, LB: Cardinal): Boolean;
procedure arrOr(A, B, Res: PLimb; LA, LB: Cardinal);
procedure arrOrTwoCompl(A, B, Res: PLimb; LA, LB: Cardinal);
procedure arrOrTwoCompl2(A, B, Res: PLimb; LA, LB: Cardinal);
procedure arrXor(A, B, Res: PLimb; LA, LB: Cardinal);
procedure arrXorTwoCompl(A, B, Res: PLimb; LA, LB: Cardinal);
procedure arrXorTwoCompl2(A, B, Res: PLimb; LA, LB: Cardinal);
implementation
{$IFDEF TFL_POINTERMATH}
{$POINTERMATH ON}
{$ELSE}
function GetLimb(P: PLimb; Offset: Cardinal): TLimb;
begin
Inc(P, Offset);
Result:= P^;
end;
{$ENDIF}
function arrGetLimbCount(A: PLimb; L: Cardinal): Cardinal;
begin
Assert(L > 0);
Inc(A, L - 1);
while (A^ = 0) and (L > 1) do begin
Dec(A);
Dec(L);
end;
Result:= L;
end;
{$IFDEF ASM86}
function arrAdd(A, B, Res: PLimb; LA, LB: Cardinal): Boolean;
asm
PUSH ESI
PUSH EDI
MOV EDI,ECX // EDI <-- Res
MOV ESI,EAX // ESI <-- A
MOV ECX,LA
SUB ECX,LB
PUSH ECX
MOV ECX,LB
CLC
@@Loop:
// MOV EAX,[ESI]
// LEA ESI,[ESI+4]
LODSD // EAX <-- [ESI], ESI <-- ESI + 4
ADC EAX,[EDX]
// MOV [EDI],EAX
// LEA EDI,[EDI+4]
STOSD // [EDI] <-- EAX, EDI <-- EDI + 4
LEA EDX,[EDX+4]
LOOP @@Loop
POP ECX // POP to keep carry
JECXZ @@Done
@@Loop2:
LODSD
ADC EAX, 0
STOSD
LOOP @@Loop2
@@Done:
SETC AL
MOVZX EAX,AL
MOV [EDI],EAX
POP EDI
POP ESI
end;
{$ELSE}
{$IFDEF ASM64}
function arrAdd(A, B, Res: PLimb; LA, LB: Cardinal): Boolean;
asm
MOV R10,RCX // R10 <-- A
MOV ECX,LB // ECX <-- LB
SUB R9,RCX // R9D <-- LA - LB
CLC
@@Loop:
MOV EAX,[R10]
LEA R10,[R10+4]
ADC EAX,[RDX]
MOV [R8],EAX
LEA R8,[R8+4]
LEA RDX,[RDX+4]
// LOOP @@Loop
DEC ECX
JNZ @@Loop
MOV ECX,R9D // ECX <-- LA - LB
JECXZ @@Done
@@Loop2:
MOV EAX,[R10]
LEA R10,[R10+4]
ADC EAX, 0
MOV [R8],EAX
LEA R8,[R8+4]
// LOOP @@Loop2
DEC ECX
JNZ @@Loop2
@@Done:
SETC AL
MOVZX EAX,AL
MOV [R8],EAX
end;
{$ELSE}
function arrAdd(A, B, Res: PLimb; LA, LB: Cardinal): Boolean;
var
CarryOut, CarryIn: Boolean;
Tmp: TLimb;
begin
Dec(LA, LB);
CarryIn:= False;
while LB > 0 do begin
Tmp:= A^ + B^;
CarryOut:= Tmp < A^;
Inc(A);
Inc(B);
if CarryIn then begin
Inc(Tmp);
CarryOut:= CarryOut or (Tmp = 0);
end;
CarryIn:= CarryOut;
Res^:= Tmp;
Inc(Res);
Dec(LB);
end;
while (LA > 0) and CarryIn do begin
Tmp:= A^ + 1;
CarryIn:= Tmp = 0;
Inc(A);
Res^:= Tmp;
Inc(Res);
Dec(LA);
end;
while (LA > 0) do begin
Res^:= A^;
Inc(A);
Inc(Res);
Dec(LA);
end;
Res^:= Ord(CarryIn);
Result:= CarryIn;
end;
{$ENDIF}
{$ENDIF}
{
Description:
Res:= A + Limb
Asserts:
L >= 1
Res must have enough space for L + 1 limbs
Remarks:
function returns True if carry is propagated out of A[L-1];
if function returns True the Res senior limb is set: Res[L] = 1
}
{$IFDEF ASM86}
function arrAddLimb(A: PLimb; Limb: TLimb; Res: PLimb; LA: Cardinal): Boolean;
asm
ADD EDX,[EAX] // Limb:= Limb + A[0]
MOV [ECX],EDX
MOV EDX,ECX
MOV ECX,LA
DEC ECX
JZ @@Done
PUSH ESI
LEA ESI,[EAX+4]
@@Loop:
LODSD // EAX <-- [ESI], ESI <-- ESI + 4
LEA EDX,[EDX+4]
ADC EAX,0
MOV [EDX],EAX
LOOP @@Loop
POP ESI
@@Done:
SETC AL
MOVZX EAX,AL
LEA EDX,[EDX+4]
MOV [EDX],EAX
end;
{$ELSE}
{$IFDEF ASM64}
function arrAddLimb(A: PLimb; Limb: TLimb; Res: PLimb; LA: Cardinal): Boolean;
{$IFDEF FPC}assembler; nostackframe;{$ENDIF}
asm
ADD EDX,[RCX] // Limb:= Limb + A[0]
MOV [R8],EDX
MOV RDX,R8
LEA R10,[RCX+4]
MOV RCX,R9
DEC ECX
JZ @@Done
@@Loop:
MOV EAX,[R10]
LEA R10,[R10+4]
LEA RDX,[RDX+4]
ADC EAX,0
MOV [RDX],EAX
DEC ECX
JNZ @@Loop
@@Done:
SETC AL
MOVZX EAX,AL
LEA RDX,[RDX+4]
MOV [RDX],EAX
end;
{$ELSE}
function arrAddLimb(A: PLimb; Limb: TLimb; Res: PLimb; LA: Cardinal): Boolean;
var
CarryIn: Boolean;
Tmp: TLimb;
begin
Tmp:= A^ + Limb;
CarryIn:= Tmp < Limb;
Inc(A);
Dec(LA);
Res^:= Tmp;
Inc(Res);
while (LA > 0) and CarryIn do begin
Tmp:= A^ + 1;
CarryIn:= Tmp = 0;
Inc(A);
Res^:= Tmp;
Inc(Res);
Dec(LA);
end;
while (LA > 0) do begin
Res^:= A^;
Inc(A);
Inc(Res);
Dec(LA);
end;
Res^:= Ord(CarryIn);
Result:= CarryIn;
end;
{$ENDIF}
{$ENDIF}
{$IFDEF ASM86}
function arrInc(A: PLimb; Res: PLimb; L: Cardinal): Boolean;
{$IFDEF FPC}assembler; nostackframe;{$ENDIF}
asm
PUSH DWORD [EAX]
POP DWORD [EDX]
ADD DWORD [EDX],1
DEC ECX
JZ @@Done
PUSH ESI
LEA ESI,[EAX+4]
// MOV ESI,EAX
@@Loop:
LODSD // EAX <-- [ESI], ESI <-- ESI + 4
LEA EDX,[EDX+4]
ADC EAX,0
MOV [EDX],EAX
LOOP @@Loop
POP ESI
@@Done:
SETC AL
MOVZX EAX,AL
LEA EDX,[EDX+4]
MOV [EDX],EAX
end;
{$ELSE}
{$IFDEF ASM64}
// RCX <-- A, RDX <--Res, R8D <-- L
function arrInc(A: PLimb; Res: PLimb; L: Cardinal): Boolean;
{$IFDEF FPC}assembler; nostackframe;{$ENDIF}
asm
MOV R9D,[RCX]
MOV [RDX],R9D
ADD DWORD [RDX],1
DEC R8D
JZ @@Done
@@Loop:
LEA RCX,[RCX+4]
LEA EDX,[RDX+4]
MOV EAX,[RCX]
ADC EAX,0
MOV [RDX],EAX
DEC R8D
JNZ @@Loop
@@Done:
SETC AL
MOVZX EAX,AL
LEA RDX,[RDX+4]
MOV [RDX],EAX
end;
{$ELSE}
function arrInc(A: PLimb; Res: PLimb; L: Cardinal): Boolean;
var
Tmp: TLimb;
begin
Tmp:= A^ + 1;
Res^:= Tmp;
// while we have carry from prev limb ..
while (Tmp = 0) do begin
Dec(L);
Inc(Res);
if (L = 0) then begin
Res^:= 1;
Result:= True;
Exit;
end;
Inc(A);
Tmp:= A^ + 1;
Res^:= Tmp;
end;
repeat
Inc(A);
Inc(Res);
Dec(L);
Res^:= A^;
until L = 0;
Res^:= 0;
Result:= False;
end;
{$ENDIF}
{$ENDIF}
function arrSelfAdd(A, B: PLimb; LA, LB: Cardinal): Boolean;
{$IFDEF WIN32_ASM86}
asm
PUSH ESI
PUSH EDI
MOV EDI,EAX // EDI <-- A
MOV ESI,EDX // ESI <-- B
SUB ECX,LB
PUSH ECX // -(SP) <-- LA - LB;
MOV ECX,LB
CLC
@@Loop:
LODSD // EAX <-- [ESI], ESI <-- ESI + 4
ADC EAX,[EDI]
STOSD // [EDI] <-- EAX, EDI <-- EDI + 4
LOOP @@Loop
MOV EAX,0
POP ECX // ECX <-- LA - LB;
JECXZ @@Done
@@Loop2:
ADC [EDI], 0
LEA EDI,[EDI+4]
JNC @@Exit
LOOP @@Loop2
@@Done:
JNC @@Exit
INC EAX
MOV [EDI],1
@@Exit:
POP EDI
POP ESI
end;
{$ELSE}
{$IFDEF WIN64_ASM86}
asm
.PUSHNV RSI
.PUSHNV RDI
MOV RDI,RCX // RDI <-- A
MOV RSI,RDX // RSI <-- B
SUB R8,R9 // R8 <-- LA - LB
MOV RCX,R9 // RCX <-- LB
CLC
@@Loop:
LODSD // EAX <-- [RSI], RSI <-- RSI + 4
ADC EAX,[RDI]
STOSD // [RDI] <-- EAX, RDI <-- RDI + 4
LOOP @@Loop
MOV EAX,0
MOV RCX,R8 // RCX <-- LA - LB;
JECXZ @@Done
@@Loop2:
ADC [RDI], 0
LEA RDI,[RDI+4]
JNC @@Exit
LOOP @@Loop2
@@Done:
JNC @@Exit
INC EAX
MOV [RDI],1
@@Exit:
end;
{$ELSE}
var
CarryOut, CarryIn: Boolean;
Tmp: TLimb;
begin
Dec(LA, LB);
CarryIn:= False;
while LB > 0 do begin
Tmp:= A^ + B^;
CarryOut:= Tmp < A^;
Inc(B);
if CarryIn then begin
Inc(Tmp);
CarryOut:= CarryOut or (Tmp = 0);
end;
CarryIn:= CarryOut;
A^:= Tmp;
Inc(A);
Dec(LB);
end;
while (LA > 0) and CarryIn do begin
Tmp:= A^ + 1;
CarryIn:= Tmp = 0;
A^:= Tmp;
Inc(A);
Dec(LA);
end;
// Inc(A, LA);
// A^:= Ord(CarryIn);
if CarryIn then A^:= 1;
Result:= CarryIn;
end;
{$ENDIF}
{$ENDIF}
{
Description:
A:= A + Limb
Asserts:
L >= 1 +
A must have enougth space for L + 1 limbs
Remarks:
function returns True if carry is propagated out of A[L-1];
if function returns True the A senior limb is set: A[L] = 1
}
function arrSelfAddLimb(A: PLimb; Limb: TLimb; L: Cardinal): Boolean;
{$IFDEF WIN32_ASM86}
asm
ADD [EAX],EDX
JNC @@Exit
DEC ECX
JECXZ @@Done
@@Loop:
LEA EAX,[EAX+4]
ADC [EAX], 0
JNC @@Exit
LOOP @@Loop
JNC @@Exit
@@Done:
LEA EAX,[EAX+4]
MOV [EAX],1
@@Exit:
SETC AL
MOVZX EAX,AL
end;
{$ELSE}
{$IFDEF WIN64_ASM86}
{$ELSE}
var
CarryIn: Boolean;
Tmp: TLimb;
begin
Tmp:= A^ + Limb;
CarryIn:= Tmp < Limb;
A^:= Tmp;
Inc(A);
Dec(L);
while (L > 0) and CarryIn do begin
Tmp:= A^ + 1;
CarryIn:= Tmp = 0;
A^:= Tmp;
Inc(A);
Dec(L);
end;
// Inc(A, L);
// A^:= Ord(CarryIn);
if CarryIn then A^:= 1;
Result:= CarryIn;
end;
{$ENDIF}
{$ENDIF}
{$IFDEF WIN32_ASM86}
function arrSelfInc(A: PLimb; L: Cardinal): Boolean;
asm
ADD [EAX],1
JNC @@Exit
MOV ECX,EDX
DEC ECX
JECXZ @@Done
@@Loop:
LEA EAX,[EAX+4]
ADC [EAX], 0
JNC @@Exit
LOOP @@Loop
JNC @@Exit
@@Done:
LEA EAX,[EAX+4]
MOV [EAX],1
@@Exit:
SETC AL
MOVZX EAX,AL
end;
{$ELSE}
function arrSelfInc(A: PLimb; L: Cardinal): Boolean;
var
Tmp: TLimb;
begin
Tmp:= A^ + 1;
A^:= Tmp;
// while we have carry from prev limb ..
while (Tmp = 0) do begin
Dec(L);
Inc(A);
if (L = 0) then begin
A^:= 1;
Result:= True;
Exit;
end;
Tmp:= A^ + 1;
A^:= Tmp;
end;
Result:= False;
end;
{$ENDIF}
{
Description:
Res:= A - B
Asserts:
LA >= LB >= 1
Res must have enough space for LA limbs
Remarks:
function returns True if borrow is propagated out of A[LA-1] (A < B);
if function returns True the Res is invalid
any (A = B = Res) coincidence is allowed
}
{$IFDEF ASM86}
function arrSub(A, B, Res: PLimb; LA, LB: Cardinal): Boolean;
asm
PUSH ESI
PUSH EDI
MOV EDI,ECX // EDI <-- Res
MOV ESI,EAX // ESI <-- A
MOV ECX,LA
SUB ECX,LB
PUSH ECX // -(SP) <-- LA - LB;
MOV ECX,LB
CLC
@@Loop:
LODSD // EAX <-- [ESI], ESI <-- ESI + 4
SBB EAX,[EDX]
STOSD // [EDI] <-- EAX, EDI <-- EDI + 4
LEA EDX,[EDX+4]
LOOP @@Loop
POP ECX // ECX <-- LA - LB;
JECXZ @@Done
@@Loop2:
LODSD
SBB EAX, 0
STOSD
LOOP @@Loop2
@@Done:
// MOV EAX,0
SETC AL
MOVZX EAX,AL // not needed really ..
@@Exit:
POP EDI
POP ESI
end;
{$ELSE}
{$IFDEF ASM64}
function arrSub(A, B, Res: PLimb; LA, LB: Cardinal): Boolean;
asm
MOV R10,RCX // R10 <-- A
MOV ECX,LB // ECX <-- LB
SUB R9,RCX // R9D <-- LA - LB
CLC
@@Loop:
MOV EAX,[R10]
LEA R10,[R10+4]
SBB EAX,[RDX]
MOV [R8],EAX
LEA R8,[R8+4]
LEA RDX,[RDX+4]
DEC ECX
JNZ @@Loop
MOV ECX,R9D // ECX <-- LA - LB
JECXZ @@Done
@@Loop2:
MOV EAX,[R10]
LEA R10,[R10+4]
SBB EAX, 0
MOV [R8],EAX
LEA R8,[R8+4]
DEC ECX
JNZ @@Loop2
@@Done:
SETC AL
MOVZX EAX,AL // not needed really ..
end;
{$ELSE}
function arrSub(A, B, Res: PLimb; LA, LB: Cardinal): Boolean;
var
BorrowOut, BorrowIn: Boolean;
Tmp: TLimb;
begin
Assert(LA >= LB);
Assert(LB >= 1);
Dec(LA, LB);
BorrowIn:= False;
while LB > 0 do begin
Tmp:= A^ - B^;
BorrowOut:= Tmp > A^;
Inc(A);
Inc(B);
if BorrowIn then begin
BorrowOut:= BorrowOut or (Tmp = 0);
Dec(Tmp);
end;
BorrowIn:= BorrowOut;
Res^:= Tmp;
Inc(Res);
Dec(LB);
end;
while (LA > 0) and BorrowIn do begin
Tmp:= A^;
BorrowIn:= Tmp = 0;
Dec(Tmp);
Inc(A);
Res^:= Tmp;
Inc(Res);
Dec(LA);
end;
while (LA > 0) do begin
Res^:= A^;
Inc(A);
Inc(Res);
Dec(LA);
end;
Result:= BorrowIn;
end;
{$ENDIF}
{$ENDIF}
{
Description:
A:= A - B
Asserts:
LA >= LB >= 1
Remarks:
function returns True if borrow is propagated out of A[LA-1] (A < B);
if function returns True the A is invalid
(A = B) coincidence is allowed
}
function arrSelfSub(A, B: PLimb; LA, LB: Cardinal): Boolean;
var
BorrowOut, BorrowIn: Boolean;
Tmp: TLimb;
begin
Dec(LA, LB);
BorrowIn:= False;
while LB > 0 do begin
Tmp:= A^ - B^;
BorrowOut:= Tmp > A^;
Inc(B);
if BorrowIn then begin
BorrowOut:= BorrowOut or (Tmp = 0);
Dec(Tmp);
end;
BorrowIn:= BorrowOut;
A^:= Tmp;
Inc(A);
Dec(LB);
end;
while (LA > 0) and BorrowIn do begin
Tmp:= A^;
BorrowIn:= Tmp = 0;
Dec(Tmp);
A^:= Tmp;
Inc(A);
Dec(LA);
end;
Result:= BorrowIn;
end;
{
Description:
Res:= A - Limb
Asserts:
L >= 1
Res must have enough space for L limbs
Remarks:
function returns True if borrow is propagated out of A[L-1] (A < B);
if function returns True the Res is invalid
}
function arrSubLimb(A: PLimb; Limb: TLimb; Res: PLimb; L: Cardinal): Boolean;
var
BorrowIn: Boolean;
Tmp: TLimb;
begin
Tmp:= A^ - Limb;
BorrowIn:= Tmp > A^;
Inc(A);
Dec(L);
Res^:= Tmp;
while (L > 0) and BorrowIn do begin
Tmp:= A^;
BorrowIn:= Tmp = 0;
Dec(Tmp);
Inc(A);
Inc(Res);
Res^:= Tmp;
Dec(L);
end;
while (L > 0) do begin
Inc(Res);
Res^:= A^;
Inc(A);
Dec(L);
end;
{
if BorrowIn then
// we get here if L = 1 and A[0] < Limb; set Res[0] = Limb - A[0]
Res^:= LongWord(-LongInt(Res^));
}
Result:= BorrowIn;
end;
{
Description:
A:= A - Limb
Asserts:
L >= 1
Remarks:
function returns True if borrow is propagated out of A[L-1] (A < B);
if function returns True the A is invalid
}
function arrSelfSubLimb(A: PLimb; Limb: TLimb; L: Cardinal): Boolean;
var
BorrowIn: Boolean;
Tmp: TLimb;
begin
Tmp:= A^ - Limb;
BorrowIn:= Tmp > A^;
A^:= Tmp;
Inc(A);
Dec(L);
while (L > 0) and BorrowIn do begin
Tmp:= A^;
BorrowIn:= Tmp = 0;
Dec(Tmp);
A^:= Tmp;
Inc(A);
Dec(L);
end;
Result:= BorrowIn;
end;
function arrDec(A: PLimb; Res: PLimb; L: Cardinal): Boolean;
var
Tmp: TLimb;
Borrow: Boolean;
begin
Tmp:= A^;
Borrow:= Tmp = 0;
Res^:= Tmp - 1;
while Borrow do begin
Dec(L);
if (L = 0) then begin
Result:= True;
Exit;
end;
Inc(A);
Inc(Res);
Tmp:= A^;
Borrow:= Tmp = 0;
Res^:= Tmp - 1;
end;
repeat
Inc(A);
Inc(Res);
Res^:= A^;
Dec(L);
until (L = 0);
Result:= False;
end;
function arrSelfDec(A: PLimb; L: Cardinal): Boolean;
var
Tmp: TLimb;
Borrow: Boolean;
begin
Tmp:= A^;
Borrow:= Tmp = 0;
A^:= Tmp - 1;
while Borrow do begin
Dec(L);
if (L = 0) then begin
Result:= True;
Exit;
end;
Inc(A);
Tmp:= A^;
Borrow:= Tmp = 0;
A^:= Tmp - 1;
end;
Result:= False;
end;
{ Bitwise boolean }
procedure arrAnd(A, B, Res: PLimb; L: Cardinal);
begin
Assert(L > 0);
repeat
Res^:= A^ and B^;
Inc(A);
Inc(B);
Inc(Res);
Dec(L);
until L = 0;
end;
// Res = A and (-B)) = A and not(B-1)
// B[0..LB-1] <> 0 because is abs of negative value
// Res[0..LA-1]
procedure arrAndTwoCompl(A, B, Res: PLimb; LA, LB: Cardinal);
var
Borrow: Boolean;
Tmp: TLimb;
begin
Assert(LA > 0);
Assert(LB > 0);
if LA >= LB then begin
Dec(LA, LB);
repeat
Tmp:= B^;
Borrow:= Tmp = 0;
Dec(Tmp);
Res^:= A^ and not Tmp;
Inc(A);
Inc(B);
Inc(Res);
Dec(LB);
// until (LB = 0) or not Borrow;
until not Borrow;
while (LB > 0) do begin
Res^:= A^ and not B^;
Inc(A);
Inc(B);
Inc(Res);
Dec(LB);
end;
if (LA > 0) then
Move(A^, Res^, LA * SizeOf(TLimb));
end
else begin { LA < LB }
repeat
Tmp:= B^;
Borrow:= Tmp = 0;
Dec(Tmp);
Res^:= A^ and not Tmp;
Inc(A);
Inc(B);
Inc(Res);
Dec(LA);
until (LA = 0) or not Borrow;
while (LA > 0) do begin
Res^:= A^ and not B^;
Inc(A);
Inc(B);
Inc(Res);
Dec(LA);
end;
end;
end;
(*
procedure arrAndTwoCompl(A, B, Res: PLimb; LA, LB: Cardinal);
var
Carry: Boolean;
Tmp: TLimb;
begin
if LA >= LB then begin
Assert(LB > 0);
Dec(LA, LB);
// Carry:= True;
repeat
Tmp:= not B^;
Inc(Tmp);
Carry:= Tmp = 0;
Res^:= A^ and Tmp;
Inc(A);
Inc(B);
Inc(Res);
Dec(LB);
until (LB = 0) or not Carry;
while (LB > 0) do begin
Res^:= A^ and not B^;
Inc(A);
Inc(B);
Inc(Res);
Dec(LB);
end;
while (LA > 0) and Carry do begin
Tmp:= A^ and TLimbInfo.MaxLimb;
Inc(Tmp);
Carry:= Tmp = 0;
Res^:= Tmp;
Inc(A);
Inc(Res);
Dec(LA);
end;
while (LA > 0) do begin
Res^:= A^ and TLimbInfo.MaxLimb;
Inc(A);
Inc(Res);
Dec(LA);
end;
end
else begin
Assert(LA > 0);
// Carry:= True;
repeat
Tmp:= not B^;
Inc(Tmp);
Carry:= Tmp = 0;
Res^:= A^ and Tmp;
Inc(A);
Inc(B);
Inc(Res);
Dec(LA);
until (LA = 0) or not Carry;
while (LA > 0) do begin
Res^:= A^ and not B^;
Inc(A);
Inc(B);
Inc(Res);
Dec(LA);
end;
end;
end;
*)
// A < 0, B < 0
// Res = -((-A) and (-B)) = -(not(A - 1) and not(B - 1)) =
// = not(not(A - 1) and not(B - 1)) + 1 =
// = ((A - 1) or (B - 1)) + 1
function arrAndTwoCompl2(A, B, Res: PLimb; LA, LB: Cardinal): Boolean;
var
CarryA, CarryB, CarryR: Boolean;
TmpA, TmpB: TLimb;
SaveRes: PLimb;
begin
Assert(LA >= LB);
Assert(LB > 0);
CarryA:= True;
CarryB:= True;
SaveRes:= Res;
Dec(LA, LB);
repeat
TmpA:= not A^;
if CarryA then begin
Inc(TmpA);
CarryA:= TmpA = 0;
end;
TmpB:= not B^;
if CarryB then begin
Inc(TmpB);
CarryB:= TmpB = 0;
end;
Res^:= TmpA and TmpB;
Inc(A);
Inc(B);
Inc(Res);
Dec(LB);
until (LB = 0);
while (LA > 0) do begin
TmpA:= not A^;
if CarryA then begin
Inc(TmpA);
CarryA:= TmpA = 0;
end;
// should be B = -0 to produce CarryB here
Assert(CarryB = False);
TmpB:= TLimbInfo.MaxLimb;
Res^:= TmpA and TmpB;
Inc(A);
Inc(Res);
Dec(LA);
end;
// CarryR:= True;
Result:= True;
repeat
SaveRes^:= not SaveRes^ + 1;
CarryR:= (SaveRes^ = 0);
Result:= Result and (SaveRes^ = 0);
Inc(SaveRes);
until (SaveRes = Res) or not CarryR;
while (SaveRes <> Res) do begin
SaveRes^:= not SaveRes^;
Result:= Result and (SaveRes^ = 0);
Inc(SaveRes);
end;
Res^:= Ord(Result);
end;
procedure arrOr(A, B, Res: PLimb; LA, LB: Cardinal);
begin
if (LA >= LB) then begin
LA:= LA - LB;
repeat
Res^:= A^ or B^;
Inc(A);
Inc(B);
Inc(Res);
Dec(LB);
until (LB = 0);
if (LA > 0) then
Move(A^, Res^, LA * SizeOf(TLimb));
end
else begin
LB:= LB - LA;
repeat
Res^:= A^ or B^;
Inc(A);
Inc(B);
Inc(Res);
Dec(LA);
until (LA = 0);
Move(B^, Res^, LB * SizeOf(TLimb));
end;
end;
// Res = -(A or (-B)) = -(A or not(B-1)) = not(A or not(B-1)) + 1 =
// = (not(A) and (B-1)) + 1
// B[0..LB-1] <> 0 because is abs of negative value
// Res[0..LB-1]
procedure arrOrTwoCompl(A, B, Res: PLimb; LA, LB: Cardinal);
var
Borrow, Carry: Boolean;
Tmp: TLimb;
begin
if LA >= LB then begin
Assert(LB > 0);
Dec(LA, LB);
Borrow:= True;
Carry:= True;
repeat
Tmp:= B^;
if Borrow then begin
Borrow:= Tmp = 0;
Dec(Tmp);
end;
Tmp:= not (A^) and Tmp;
if Carry then begin
Inc(Tmp);
Carry:= Tmp = 0;
end;
Res^:= Tmp;
Inc(A);
Inc(B);
Inc(Res);
Dec(LB);
until (LB = 0);
end
else begin
Assert(LA > 0);
Dec(LB, LA);
Borrow:= True;
Carry:= True;
repeat
Tmp:= B^;
if Borrow then begin
Borrow:= Tmp = 0;
Dec(Tmp);
end;
Tmp:= not (A^) and Tmp;
if Carry then begin
Inc(Tmp);
Carry:= Tmp = 0;
end;
Res^:= Tmp;
Inc(A);
Inc(B);
Inc(Res);
Dec(LA);
until (LA = 0);
repeat
Tmp:= B^;
if Borrow then begin
Borrow:= Tmp = 0;
Dec(Tmp);
end;
if Carry then begin
Inc(Tmp);
Carry:= Tmp = 0;
end;
Res^:= Tmp;
Inc(B);
Inc(Res);
Dec(LB);
until (LB = 0);
end;
end;
// Res = -((-A) or (-B)) = -(not(A-1) or not(B-1)) =
// = not(not(A-1) or not(B-1)) + 1 =
// = (A-1) and (B-1) + 1
procedure arrOrTwoCompl2(A, B, Res: PLimb; LA, LB: Cardinal);
var
BorrowA, BorrowB, CarryR: Boolean;
TmpA, TmpB, TmpR: TLimb;
L: Cardinal;
begin
BorrowA:= True;
BorrowB:= True;
CarryR:= True;
if (LA >= LB)
then L:= LB
else L:= LA;
Assert(L > 0);
repeat
TmpA:= A^;
if BorrowA then begin
BorrowA:= TmpA = 0;
Dec(TmpA);
end;
TmpB:= B^;
if BorrowB then begin
BorrowB:= TmpB = 0;
Dec(TmpB);
end;
TmpR:= TmpA and TmpB;
if CarryR then begin
Inc(TmpR);
CarryR:= TmpR = 0;
end;
Res^:= TmpR;
Inc(A);
Inc(B);
Inc(Res);
Dec(L);
until (L = 0);
end;
procedure arrXor(A, B, Res: PLimb; LA, LB: Cardinal);
begin
if (LA >= LB) then begin
LA:= LA - LB;
repeat
Res^:= A^ xor B^;
Inc(A);
Inc(B);
Inc(Res);
Dec(LB);
until (LB = 0);
if (LA > 0) then
Move(A^, Res^, LA * SizeOf(TLimb));
end
else begin
LB:= LB - LA;
repeat
Res^:= A^ xor B^;
Inc(A);
Inc(B);
Inc(Res);
Dec(LA);
until (LA = 0);
Move(B^, Res^, LB * SizeOf(TLimb));
end;
end;
// Res = -(A xor (-B)) = -(A xor not(B-1)) = not(A xor not(B-1)) + 1 =
// = (A xor (B-1)) + 1
// B[0..LB-1] <> 0 because is abs of negative value
procedure arrXorTwoCompl(A, B, Res: PLimb; LA, LB: Cardinal);
var
Borrow, Carry: Boolean;
Tmp: TLimb;
begin
if LA >= LB then begin
Assert(LB > 0);
Dec(LA, LB);
Borrow:= True;
Carry:= True;
repeat
Tmp:= B^;
if Borrow then begin
Borrow:= Tmp = 0;
Dec(Tmp);
end;
Tmp:= A^ xor Tmp;
if Carry then begin
Inc(Tmp);
Carry:= Tmp = 0;
end;
Res^:= Tmp;
Inc(A);
Inc(B);
Inc(Res);
Dec(LB);
until (LB = 0);
Assert(not Borrow);
while Carry and (LA > 0) do begin
Tmp:= A^ + 1;
Carry:= Tmp = 0;
Res^:= Tmp;
Inc(A);
Inc(Res);
Dec(LA);
end;
if (LA > 0) then
Move(A^, Res^, LA * SizeOf(TLimb));
end
else begin
Assert(LA > 0);
Dec(LB, LA);
Borrow:= True;
Carry:= True;
repeat
Tmp:= B^;
if Borrow then begin
Borrow:= Tmp = 0;
Dec(Tmp);
end;
Tmp:= A^ xor Tmp;
if Carry then begin
Inc(Tmp);
Carry:= Tmp = 0;
end;
Res^:= Tmp;
Inc(A);
Inc(B);
Inc(Res);
Dec(LA);
until (LA = 0);
repeat
Tmp:= B^;
if Borrow then begin
Borrow:= Tmp = 0;
Dec(Tmp);
end;
if Carry then begin
Inc(Tmp);
Carry:= Tmp = 0;
end;
Res^:= Tmp;
Inc(B);
Inc(Res);
Dec(LB);
until (LB = 0);
end;
end;
// Res = (-A) xor (-B) = not(A-1) xor not(B-1) =
// = (A-1) xor (B-1)
procedure arrXorTwoCompl2(A, B, Res: PLimb; LA, LB: Cardinal);
var
BorrowA, BorrowB: Boolean;
TmpA, TmpB: TLimb;
begin
Assert(LA > 0);
Assert(LB > 0);
BorrowA:= True;
BorrowB:= True;
if (LA >= LB) then begin
Dec(LA, LB);
repeat
TmpA:= A^;
if BorrowA then begin
BorrowA:= TmpA = 0;
Dec(TmpA);
end;
TmpB:= B^;
if BorrowB then begin
BorrowB:= TmpB = 0;
Dec(TmpB);
end;
Res^:= TmpA xor TmpB;
Inc(A);
Inc(B);
Inc(Res);
Dec(LB);
until (LB = 0);
if (LA > 0) then
Move(A^, Res^, LA * SizeOf(TLimb));
end
else begin
Dec(LB, LA);
repeat
TmpA:= A^;
if BorrowA then begin
BorrowA:= TmpA = 0;
Dec(TmpA);
end;
TmpB:= B^;
if BorrowB then begin
BorrowB:= TmpB = 0;
Dec(TmpB);
end;
Res^:= TmpA xor TmpB;
Inc(A);
Inc(B);
Inc(Res);
Dec(LA);
until (LA = 0);
Move(B^, Res^, LB * SizeOf(TLimb));
end;
end;
{
Description:
Res:= A * B
Asserts:
LA >= 1, LB >= 1
Res must have enough space for LA + LB limbs
Remarks:
none
}
{$IFDEF ASM86}
function arrMul(A, B, Res: PLimb; LA, LB: Cardinal): Boolean;
asm
PUSH ESI
PUSH EDI
PUSH EBX
PUSH EBP
PUSH EDX // B [SP+12]
PUSH LB
PUSH EAX // A, [SP+4]
PUSH LA
MOV EDI,ECX // Res
MOV ECX,LA
// ADD ECX,LB
PUSH EDI
XOR EAX,EAX
@@Clear:
MOV [EDI],EAX
LEA EDI,[EDI+4]
LOOP @@Clear
POP EDI
@@ExtLoop:
XOR EBX,EBX // Carry
MOV ESI,[ESP+12] // B
MOV EBP,[ESI]
LEA ESI,[ESI+4] // Inc(B);
MOV [ESP+12],ESI
MOV ECX,[ESP] // LA
MOV ESI,[ESP+4] // A
PUSH EDI
@@Loop:
LODSD // EAX <-- [ESI], ESI <-- ESI + 4
MUL EBP
ADD EAX,EBX
ADC EDX,0
ADD EAX,[EDI]
ADC EDX,0
STOSD // [EDI] <-- EAX, EDI <-- EDI + 4
MOV EBX,EDX
LOOP @@Loop
MOV [EDI],EBX
POP EDI
LEA EDI,[EDI+4] // Inc(Res);
DEC [ESP+8] // Dec(LB);
JNZ @@ExtLoop
OR EBX,EBX // Result:= Carry <> 0
SETNZ AL
ADD ESP,16
POP EBP
POP EBX
POP EDI
POP ESI
end;
{$ELSE}
{$IFDEF ASM64}
function arrMul(A, B, Res: PLimb; LA, LB: Cardinal): Boolean;
asm
PUSH RSI
PUSH RDI
PUSH RBX
PUSH RBP
PUSH R12
MOV R10D,LB // LB
MOV R11,RDX // B
MOV R12,RCX // A
MOV ECX,R9D // LA
MOV RDI,R8 // Res
XOR EAX,EAX
@@Clear:
MOV [RDI],EAX
LEA RDI,[RDI+4]
LOOP @@Clear
MOV RDI,R8 // Res
@@ExtLoop:
XOR EBX,EBX // Carry
MOV EBP,[R11] // B
MOV ECX,R9D // LA
MOV RSI,R12 // A
MOV RDI,R8 // Res
@@Loop:
LODSD // RAX <-- [RSI], RSI <-- RSI + 4
MUL EBP
ADD EAX,EBX
ADC EDX,0
ADD EAX,[RDI]
ADC EDX,0
STOSD // [RDI] <-- RAX, RDI <-- RDI + 4
MOV EBX,EDX
LOOP @@Loop
MOV [RDI],EBX
LEA R11,[R11+4] // Inc(B);
LEA R8,[R8+4] // Inc(Res);
DEC R10D // Dec(LB);
JNZ @@ExtLoop
OR EBX,EBX // Result:= Carry <> 0
SETNZ AL
POP R12
POP RBP
POP RBX
POP RDI
POP RSI
end;
{$ELSE}
function arrMul(A, B, Res: PLimb; LA, LB: Cardinal): Boolean;
var
PA, PRes: PLimb;
Cnt: Integer;
TmpB: TLimbVector;
TmpRes: TLimbVector;
Carry: TLimb;
begin
// FillChar(Res^, (LA + LB) * SizeOf(TLimb), 0);
FillChar(Res^, LA * SizeOf(TLimb), 0);
// while LB > 0 do begin
repeat
Carry:= 0;
if B^ <> 0 then begin
TmpB.Value:= B^;
PA:= A;
PRes:= Res;
Cnt:= LA;
while Cnt > 0 do begin
TmpRes.Value:= TmpB.Value * PA^ + Carry;
TmpRes.Value:= TmpRes.Value + PRes^;
PRes^:= TmpRes.Lo;
Inc(PRes);
Carry:= TmpRes.Hi;
Inc(PA);
Dec(Cnt);
end;
PRes^:= Carry;
end;
Inc(B);
Inc(Res);
Dec(LB);
// end;
until LB = 0;
Result:= Carry <> 0;
end;
{$ENDIF}
{$ENDIF}
function arrSqr(A, Res: PLimb; LA: Cardinal): Boolean;
var
PA, PB, PRes: PLimb;
LB, Cnt: Integer;
TmpB: TLimbVector;
TmpRes: TLimbVector;
Carry: TLimb;
begin
FillChar(Res^, LA * SizeOf(TLimb), 0);
PB:= A;
LB:= LA;
repeat
Carry:= 0;
if PB^ <> 0 then begin
TmpB.Value:= PB^;
PA:= A;
PRes:= Res;
Cnt:= LA;
while Cnt > 0 do begin
TmpRes.Value:= TmpB.Value * PA^ + Carry;
TmpRes.Value:= TmpRes.Value + PRes^;
PRes^:= TmpRes.Lo;
Inc(PRes);
Carry:= TmpRes.Hi;
Inc(PA);
Dec(Cnt);
end;
PRes^:= Carry;
end;
Inc(PB);
Inc(Res);
Dec(LB);
until LB = 0;
Result:= Carry <> 0;
end;
{$IFDEF ASM86}
function arrMulLimb(A: PLimb; Limb: TLimb; Res: PLimb; L: Cardinal): Boolean;
asm
PUSH ESI
PUSH EDI
PUSH EBX
PUSH EBP
MOV EDI,ECX // EDI <-- Res
MOV ESI,EAX // ESI <-- A
MOV ECX,L
XOR EBX,EBX // EBX = Carry
MOV EBP,EDX // EBP <-- Limb
@@Loop:
LODSD // EAX <-- [ESI], ESI <-- ESI + 4
// MOV EDX,EBP // Limb
// MUL EDX
MUL EBP
ADD EAX,EBX
ADC EDX,0
STOSD // [EDI] <-- EAX, EDI <-- EDI + 4
MOV EBX,EDX
LOOP @@Loop
MOV [EDI],EBX
OR EBX,EBX
SETNZ AL
POP EBP
POP EBX
POP EDI
POP ESI
end;
{$ELSE}
{$IFDEF ASM64}
function arrMulLimb(A: PLimb; Limb: TLimb; Res: PLimb; L: Cardinal): Boolean;
{$IFDEF FPC}assembler; nostackframe;{$ENDIF}
asm
MOV R10D,EDX // Limb
XOR R11,R11 // Carry
@@Loop:
MOV EAX,[RCX]
LEA RCX,[RCX+4]
MUL R10D
ADD EAX,R11D
ADC EDX,0
MOV [R8],EAX
LEA R8,[R8+4]
MOV R11D,EDX
DEC R9D
JNE @@Loop
MOV [R8],EDX
OR EDX,EDX
SETNZ AL
end;
{$ELSE}
function arrMulLimb(A: PLimb; Limb: TLimb; Res: PLimb; L: Cardinal): Boolean;
var
Tmp: TLimbVector;
Carry: Cardinal;
begin
Carry:= 0;
while L > 0 do begin
Tmp.Lo:= A^;
Tmp.Hi:= 0;
Tmp.Value:= Tmp.Value * Limb + Carry;
Res^:= Tmp.Lo;
Inc(A);
Inc(Res);
Carry:= Tmp.Hi;
Dec(L);
end;
Res^:= Carry;
Result:= Carry <> 0;
end;
{$ENDIF}
{$ENDIF}
// A:= A * Limb;
// A must have enough space for L + 1 limbs
// returns: True if senior (L+1)-th limb of the multiplication result is nonzero
function arrSelfMulLimb(A: PLimb; Limb: TLimb; L: Cardinal): Boolean;
var
Tmp: TLimbVector;
Carry: Cardinal;
begin
Carry:= 0;
while L > 0 do begin
Tmp.Lo:= A^;
Tmp.Hi:= 0;
Tmp.Value:= Tmp.Value * Limb + Carry;
A^:= Tmp.Lo;
Inc(A);
Carry:= Tmp.Hi;
Dec(L);
end;
A^:= Carry;
Result:= Carry <> 0;
end;
function arrCmp(A, B: PLimb; L: Cardinal): Integer;
begin
if L > 0 then begin
Inc(A, L - 1);
Inc(B, L - 1);
repeat
{$IFDEF TFL_EXITPARAM}
if A^ > B^ then Exit(1);
if A^ < B^ then Exit(-1);
{$ELSE}
if A^ > B^ then begin
Result:= 1;
Exit;
end;
if A^ < B^ then begin
Result:= -1;
Exit;
end;
{$ENDIF}
Dec(A);
Dec(B);
Dec(L);
until L = 0;
end;
{$IFDEF TFL_EXITPARAM}
Exit(0);
{$ELSE}
Result:= 0;
Exit;
{$ENDIF}
end;
// LA >= 1
// Root should have (LA + 1) shr 1 limbs at least
// returns:
// - 0: error occured (EOutOfMemory raised)
// > 0: Root Length in limbs
function arrSqrt(A, Root: PLimb; LA: Cardinal): Cardinal;
var
Shift: Cardinal;
HighLimb0: TLimb;
InitA, InitX, InitY: Cardinal;
NormalizedA: PLimb;
DivRem: PLimb;
X, Y, TmpXY: PLimb;
LNorm, L1, L2: Cardinal;
Diff: Integer;
P: PLimb;
Buffer: PLimb;
// Buffer structure:
// - NormalizedA: LA + 1 Limbs;
// - X: LA + 1 Limbs;
// - Y: LA + 1 Limbs;
// - DivRem: LA + 1 Limbs;
begin
Assert(LA > 0);
if LA = 1 then begin
// this may be incorrect if SizeOf(Limb) >= 8
// because Double mantisse < 64 bits
Root^:= TLimb(Trunc(Sqrt(A^)));
Result:= 1;
Exit;
end;
HighLimb0:= A[LA-1];
Shift:= SizeOf(TLimb) * 8;
while HighLimb0 <> 0 do begin
Dec(Shift);
HighLimb0:= HighLimb0 shr 1;
end;
Shift:= Shift and $FE; // Shift should be even
// A = $5.6BC75E2D.63100000 = 1.0000.0000.0000.0000.0000
// Sqrt(A) = $2.540BE400 = 100.0000.0000
Assert(LA > 1);
try
GetMem(Buffer, (LA + 1) * 4 * SizeOf(TLimb));
try
NormalizedA:= Buffer;
X:= Buffer + LA + 1;
Y:= X + LA + 1;
DivRem:= Y + LA + 1;
if Odd(LA) then begin
arrShlShort(A, @NormalizedA[1], LA, Shift);
NormalizedA[0]:= 0;
LNorm:= LA + 1;
end
else begin
arrShlShort(A, NormalizedA, LA, Shift);
LNorm:= LA;
end;
// NormalizedA = $56BC75E2.D6310000.00000000.00000000
// = 625.0000.0000.0000.0000 * 2^64
// Sqrt(NormalizedA) = 9502F900.00000000
// = 25.0000.0000 * 2^32
{
if LNorm = 2 then begin
// todo: arrNormDivMod requires LNorm >= 3
// so LNorm = 2 case should be treated separately here
Result:= 0;
Exit;
end;
}
P:= @NormalizedA[LNorm - 1];
L1:= 0;
while P <> NormalizedA do begin
if P^ = TLimbInfo.MaxLimb then begin
Inc(L1);
Dec(P);
end
else Break;
end;
if L1 >= LNorm shr 1 then begin
L1:= LNorm shr 1;
// we got the result, nothing else needed
FillChar(X^, L1 * SizeOf(TLimb), $FF);
end
else begin
if (L1 > 0) then begin
FillChar(X^, L1 * SizeOf(TLimb), $FF);
FillChar(Y^, L1 * SizeOf(TLimb), $FF);
{todo: P^ = TLimbInfo.MaxLimb - 1 case probably should be treated separately
// obtain root approximation from above of length Count or Count + 1
Assert(Count < LNorm shr 1);
if P^ = TLimbInfo.MaxLimb - 1 then begin
L1:= 0;
repeat
Dec(P);
if P^ <> 0 then Break;
Inc(L1);
until P = NormalizedA;
// todo: if (L1 = Count) and (
end
else ;
}
end
else begin
L1:= 1;
Y^:= (Trunc(Sqrt(NormalizedA[LNorm-1])) shl (TLimbInfo.BitSize shr 1))
or (TLimbInfo.MaxLimb shr (TLimbInfo.BitSize shr 1));
// the first iteration gives lower half of X^
Move(NormalizedA[LNorm-2], DivRem^, 2 * SizeOf(TLimb));
arrDivModLimb(DivRem, X, 2, Y^); // X:= DivRem div Y^
end;
{
HighLimb0:= NormalizedA[LNorm-1];
X^:= Trunc(Sqrt(HighLimb0));
X^:= (X^ shl (TLimbInfo.BitSize shr 1))
or (TLimbInfo.MaxLimb shr (TLimbInfo.BitSize shr 1));
}
// LNorm = 2 case should be treated separately
// because arrNormDivMod requires LNorm >= 3
if LNorm = 2 then begin
if X^ <> Y^ then begin
if X^ < Y^ then begin
TmpXY:= X;
X:= Y;
Y:= TmpXY;
end;
repeat
X^:= ((X^ + Y^) shr 1) or (1 shl (TLimbInfo.BitSize - 1));
if X^ <= Y^ then Break;
Move(NormalizedA[LNorm-2], DivRem^, 2 * SizeOf(TLimb));
arrDivModLimb(DivRem, Y, 2, X^); // Y:= DivRem div X^
until False;
end;
end
else begin
// we have approx L1 valid root limbs, L1 * 2 < LNorm
Assert(L1 * 2 < LNorm);
// L2:= 2 * L1;
repeat
L2:= L1 * 2;
if L2 > LNorm shr 1 then begin
L2:= LNorm shr 1;
end;
Move(X^, X[L2 - L1], L1 * SizeOf(TLimb));
FillChar(X^, (L2 - L1) * SizeOf(TLimb), $FF);
L1:= L2;
L2:= L1 * 2;
Move(NormalizedA[LNorm - L2], DivRem^, L2 * SizeOf(TLimb));
arrNormDivMod(DivRem, X, Y, L2, L1);
if L2 = LNorm then Break;
// carry is lost
arrSelfAdd(X, Y, L1, L1);
arrSelfShrOne(X, L1);
// restore carry
X[L1-1]:= X[L1-1] or (1 shl (TLimbInfo.BitSize - 1));
until False;
Diff:= arrCmp(X, Y, L1);
if Diff <> 0 then begin
// make sure X is approximation from above
if Diff < 0 then begin
TmpXY:= X;
X:= Y;
Y:= TmpXY;
end;
arrSelfAdd(Y, X, L1, L1);
arrSelfShrOne(Y, L1);
// restore carry
Y[L1-1]:= Y[L1-1] or (1 shl (TLimbInfo.BitSize - 1));
if arrCmp(X, Y, L1) > 0 then begin
repeat
Move(NormalizedA^, DivRem^, L2 * SizeOf(TLimb));
{
if (L1 = 1) then begin
arrDivModLimb(DivRem, Y, L2, X^);
end
else begin
}
arrNormDivMod(DivRem, X, Y, L2, L1);
// end;
arrSelfAdd(Y, X, L1, L1);
arrSelfShrOne(Y, L1);
// restore carry
Y[L1-1]:= Y[L1-1] or (1 shl (TLimbInfo.BitSize - 1));
if arrCmp(X, Y, L1) <= 0 then Break;
TmpXY:= X;
X:= Y;
Y:= TmpXY;
until False;
end;
end;
end;
end;
// X = 9502F900.00000000
// = 25.0000.0000 * 2^32
if Odd(LA) then Shift:= Shift + TLimbInfo.BitSize;
L1:= arrShrShort(X, Root, L1, Shift shr 1);
// Root = 2.540BE400
// = 100.0000.0000
Result:= arrGetLimbCount(Root, L1);
finally
FreeMem(Buffer);
end;
except
Result:= 0;
end;
end;
function arrShlShort(A, Res: PLimb; LA, Shift: Cardinal): Cardinal;
var
Tmp, Carry: TLimb;
begin
Assert(Shift < TLimbInfo.BitSize);
Result:= LA;
if Shift = 0 then begin
Move(A^, Res^, LA * SizeOf(TLimb));
end
else begin
Carry:= 0;
repeat
Tmp:= (A^ shl Shift) or Carry;
Carry:= A^ shr (TLimbInfo.BitSize - Shift);
Res^:= Tmp;
Inc(A);
Inc(Res);
Dec(LA);
until (LA = 0);
if Carry <> 0 then begin
Res^:= Carry;
Inc(Result);
end;
end;
end;
// Short Shift Right
// A = Res is acceptable
// LA >= 1
// Shift < 32
function arrShrShort(A, Res: PLimb; LA, Shift: Cardinal): Cardinal;
var
Carry: TLimb;
begin
// Assert(Shift < 32);
Result:= LA;
if Shift = 0 then begin
Move(A^, Res^, LA * SizeOf(TLimb));
end
else begin
Carry:= A^ shr Shift;
Inc(A);
Dec(LA);
while (LA > 0) do begin
Res^:= (A^ shl (TLimbInfo.BitSize - Shift)) or Carry;
Carry:= A^ shr Shift;
Inc(A);
Inc(Res);
Dec(LA);
end;
if (Carry <> 0) or (Result = 1) then begin
Res^:= Carry;
end
else begin
Dec(Result);
end;
end;
end;
function arrShlOne(A, Res: PLimb; LA: Cardinal): Cardinal;
var
Tmp, Carry: TLimb;
begin
Result:= LA;
Carry:= 0;
repeat
Tmp:= (A^ shl 1) or Carry;
Carry:= A^ shr (TLimbInfo.BitSize - 1);
Res^:= Tmp;
Inc(A);
Inc(Res);
Dec(LA);
until (LA = 0);
if Carry <> 0 then begin
Res^:= Carry;
Inc(Result);
end;
end;
function arrShrOne(A, Res: PLimb; LA: Cardinal): Cardinal;
var
Carry: TLimb;
begin
Result:= LA;
Carry:= A^ shr 1;
Inc(A);
Dec(LA);
while (LA > 0) do begin
Res^:= (A^ shl (TLimbInfo.BitSize - 1)) or Carry;
Carry:= A^ shr 1;
Inc(A);
Inc(Res);
Dec(LA);
end;
if (Carry <> 0) or (Result = 1) then begin
Res^:= Carry;
end
else begin
Dec(Result);
end;
end;
// LA >= 1
function arrSelfShrOne(A: PLimb; LA: Cardinal): Cardinal;
var
Res: PLimb;
begin
Result:= LA;
Res:= A;
Inc(A);
Dec(LA);
while (LA > 0) do begin
Res^:= (Res^ shr 1) or (A^ shl (TLimbInfo.BitSize - 1));
Inc(A);
Inc(Res);
Dec(LA);
end;
Res^:= Res^ shr 1;
if Res^ = 0 then Dec(Result);
end;
// Q := A div D;
// Result:= A mod D;
function arrDivModLimb(A, Q: PLimb; L, D: TLimb): TLimb;
var
Tmp: TLimbVector;
begin
Dec(L);
Inc(A, L);
Inc(Q, L);
Tmp.Lo:= A^;
if Tmp.Lo >= D then begin
Q^:= Tmp.Lo div D;
Tmp.Hi:= Tmp.Lo mod D;
end
else begin
Q^:= 0;
Tmp.Hi:= Tmp.Lo;
end;
while L > 0 do begin
Dec(A);
Dec(Q);
Tmp.Lo:= A^;
Q^:= TLimb(Tmp.Value div D);
Tmp.Hi:= TLimb(Tmp.Value mod D);
Dec(L);
end;
Result:= Tmp.Hi;
end;
function arrSelfDivModLimb(A: PLimb; L: Cardinal; D: TLimb): TLimb;
var
Tmp: TLimbVector;
begin
Dec(L);
Inc(A, L);
Tmp.Lo:= A^;
if Tmp.Lo >= D then begin
A^:= Tmp.Lo div D;
Tmp.Hi:= Tmp.Lo mod D;
end
else begin
A^:= 0;
Tmp.Hi:= Tmp.Lo;
end;
while L > 0 do begin
Dec(A);
Tmp.Lo:= A^;
A^:= TLimb(Tmp.Value div D);
Tmp.Hi:= TLimb(Tmp.Value mod D);
Dec(L);
end;
Result:= Tmp.Hi;
end;
// normalized division (Divisor[DsrLen-1] and $80000000 <> 0)
// in: Dividend: Dividend;
// Divisor: Divisor;
// DndLen: Dividend Length
// DsrLen: Divisor Length
// out: Quotient:= Dividend div Divisor
// Dividend:= Dividend mod Divisor
procedure arrNormDivMod(Dividend, Divisor, Quotient: PLimb;
DndLen, DsrLen: TLimb);
var
Tmp: TLimbVector;
PDnd, PDsr: PLimb;
QGuess, RGuess: TLimbVector;
LoopCount, Count: Integer;
TmpLimb, Carry: TLimb;
CarryIn, CarryOut: Boolean;
begin
Assert(DndLen > DsrLen);
Assert(DsrLen >= 2);
LoopCount:= DndLen - DsrLen;
Inc(Quotient, LoopCount);
{$IFDEF TFL_POINTERMATH}
PDnd:= Dividend + DndLen;
PDsr:= Divisor + DsrLen;
{$ELSE}
PDnd:= Dividend;
Inc(PDnd, DndLen);
PDsr:= Divisor;
Inc(PDsr, DsrLen);
{$ENDIF}
repeat
Dec(PDnd); // PDnd points to (current) senior dividend/remainder limb
Dec(PDsr); // PDns points to senior divisor limb
Assert(PDnd^ <= PDsr^);
Dec(Quotient);
// Делим число, составленное из двух старших цифр делимого на старшую цифру
// делителя; это даст нам оценку очередной цифры частного QGuess
if PDnd^ < PDsr^ then begin
{$IFDEF TFL_POINTERMATH}
Tmp.Lo:= (PDnd - 1)^;
{$ELSE}
Tmp.Lo:= GetLimb(PDnd, -1);
{$ENDIF}
Tmp.Hi:= PDnd^;
QGuess.Lo:= Tmp.Value div PDsr^;
QGuess.Hi:= 0;
RGuess.Lo:= Tmp.Value mod PDsr^;
RGuess.Hi:= 0;
end
else begin
QGuess.Lo:= 0;
QGuess.Hi:= 1;
{$IFDEF TFL_POINTERMATH}
RGuess.Lo:= (PDnd - 1)^;
{$ELSE}
RGuess.Lo:= GetLimb(PDnd, -1);
{$ENDIF}
RGuess.Hi:= 0;
end;
// Для точного значения цифры частного Q имеем
// QGuess - 2 <= Q <= QGuess;
// улучшаем оценку
repeat
if (QGuess.Hi = 0) then begin
// yмножаем вторую по старшинству цифру делителя на QGuess
{$IFDEF TFL_POINTERMATH}
Tmp.Value:= (PDsr - 1)^ * QGuess.Value;
if (Tmp.Hi < RGuess.Lo) then Break;
if (Tmp.Hi = RGuess.Lo) and
(Tmp.Lo <= (PDnd - 2)^) then Break;
{$ELSE}
Tmp.Value:= GetLimb(PDsr, -1) * QGuess.Value;
if (Tmp.Hi < RGuess.Lo) then Break;
if (Tmp.Hi = RGuess.Lo) and
(Tmp.Lo <= GetLimb(PDnd, -2)) then Break;
{$ENDIF}
Dec(QGuess.Lo);
end
else begin
QGuess.Lo:= TLimbInfo.MaxLimb;
QGuess.Hi:= 0;
end;
RGuess.Value:= RGuess.Value + PDsr^;
until RGuess.Hi <> 0;
// Здесь имеем QGuess - 1 <= Q <= QGuess;
// Вычитаем из делимого умноженный на QGuess делитель
Count:= DsrLen;
{$IFDEF TFL_POINTERMATH}
PDnd:= PDnd - Count;
{$ELSE}
PDnd:= PDnd;
Dec(PDnd, Count);
{$ENDIF}
PDsr:= Divisor;
Carry:= 0;
repeat
Tmp.Value:= PDsr^ * QGuess.Value + Carry;
Carry:= Tmp.Hi;
TmpLimb:= PDnd^ - Tmp.Lo;
if (TmpLimb > PDnd^) then Inc(Carry);
PDnd^:= TmpLimb;
Inc(PDnd);
Inc(PDsr);
Dec(Count);
until Count = 0;
TmpLimb:= PDnd^ - Carry;
if (TmpLimb > PDnd^) then begin
// если мы попали сюда значит QGuess = Q + 1;
// прибавляем делитель
Count:= DsrLen;
{$IFDEF TFL_POINTERMATH}
PDnd:= PDnd - Count;
{$ELSE}
PDnd:= PDnd;
Dec(PDnd, Count);
{$ENDIF}
PDsr:= Divisor;
CarryIn:= False;
repeat
TmpLimb:= PDnd^ + PDsr^;
CarryOut:= TmpLimb < PDnd^;
Inc(PDsr);
if CarryIn then begin
Inc(TmpLimb);
CarryOut:= CarryOut or (TmpLimb = 0);
end;
CarryIn:= CarryOut;
PDnd^:= TmpLimb;
Inc(PDnd);
Dec(Count);
until Count = 0;
Assert(CarryIn);
Dec(QGuess.Lo);
end;
// Возможно этот лимб больше не нужен и обнулять его необязательно
PDnd^:= 0;
Quotient^:= QGuess.Lo;
Dec(LoopCount);
until LoopCount = 0;
end;
// normalized division (Divisor[DsrLen-1] and $80000000 <> 0)
// in: Dividend: Dividend;
// Divisor: Divisor;
// DndLen: Dividend Length
// DsrLen: Divisor Length
// out: Dividend:= Dividend mod Divisor
procedure arrNormMod(Dividend, Divisor: PLimb;
DndLen, DsrLen: TLimb);
var
Tmp: TLimbVector;
PDnd, PDsr: PLimb;
QGuess, RGuess: TLimbVector;
LoopCount, Count: Integer;
TmpLimb, Carry: TLimb;
CarryIn, CarryOut: Boolean;
begin
Assert(DndLen > DsrLen);
Assert(DsrLen >= 2);
LoopCount:= DndLen - DsrLen;
{$IFDEF TFL_POINTERMATH}
PDnd:= Dividend + DndLen;
PDsr:= Divisor + DsrLen;
{$ELSE}
PDnd:= Dividend;
Inc(PDnd, DndLen);
PDsr:= Divisor;
Inc(PDsr, DsrLen);
{$ENDIF}
repeat
Dec(PDnd); // PDnd points to (current) senior dividend/remainder limb
Dec(PDsr); // PDns points to senior divisor limb
Assert(PDnd^ <= PDsr^);
// Делим число, составленное из двух старших цифр делимого на старшую цифру
// делителя; это даст нам оценку очередной цифры частного QGuess
if PDnd^ < PDsr^ then begin
{$IFDEF TFL_POINTERMATH}
Tmp.Lo:= (PDnd - 1)^;
{$ELSE}
Tmp.Lo:= GetLimb(PDnd, -1);
{$ENDIF}
Tmp.Hi:= PDnd^;
QGuess.Lo:= Tmp.Value div PDsr^;
QGuess.Hi:= 0;
RGuess.Lo:= Tmp.Value mod PDsr^;
RGuess.Hi:= 0;
end
else begin
QGuess.Lo:= 0;
QGuess.Hi:= 1;
{$IFDEF TFL_POINTERMATH}
RGuess.Lo:= (PDnd - 1)^;
{$ELSE}
RGuess.Lo:= GetLimb(PDnd, -1);
{$ENDIF}
RGuess.Hi:= 0;
end;
// Для точного значения цифры частного Q имеем
// QGuess - 2 <= Q <= QGuess;
// улучшаем оценку
repeat
if (QGuess.Hi = 0) then begin
// yмножаем вторую по старшинству цифру делителя на QGuess
{$IFDEF TFL_POINTERMATH}
Tmp.Value:= (PDsr - 1)^ * QGuess.Value;
if (Tmp.Hi < RGuess.Lo) then Break;
if (Tmp.Hi = RGuess.Lo) and
(Tmp.Lo <= (PDnd - 2)^) then Break;
{$ELSE}
Tmp.Value:= GetLimb(PDsr, -1) * QGuess.Value;
if (Tmp.Hi < RGuess.Lo) then Break;
if (Tmp.Hi = RGuess.Lo) and
(Tmp.Lo <= GetLimb(PDnd, -2)) then Break;
{$ENDIF}
Dec(QGuess.Lo);
end
else begin
QGuess.Lo:= TLimbInfo.MaxLimb;
QGuess.Hi:= 0;
end;
RGuess.Value:= RGuess.Value + PDsr^;
until RGuess.Hi <> 0;
// Здесь имеем QGuess - 1 <= Q <= QGuess;
// Вычитаем из делимого умноженный на QGuess делитель
Count:= DsrLen;
{$IFDEF TFL_POINTERMATH}
PDnd:= PDnd - Count;
{$ELSE}
PDnd:= PDnd;
Dec(PDnd, Count);
{$ENDIF}
PDsr:= Divisor;
Carry:= 0;
repeat
Tmp.Value:= PDsr^ * QGuess.Value + Carry;
Carry:= Tmp.Hi;
TmpLimb:= PDnd^ - Tmp.Lo;
if (TmpLimb > PDnd^) then Inc(Carry);
PDnd^:= TmpLimb;
Inc(PDnd);
Inc(PDsr);
Dec(Count);
until Count = 0;
TmpLimb:= PDnd^ - Carry;
if (TmpLimb > PDnd^) then begin
// если мы попали сюда значит QGuess = Q + 1;
// прибавляем делитель
Count:= DsrLen;
{$IFDEF TFL_POINTERMATH}
PDnd:= PDnd - Count;
{$ELSE}
PDnd:= PDnd;
Dec(PDnd, Count);
{$ENDIF}
PDsr:= Divisor;
CarryIn:= False;
repeat
TmpLimb:= PDnd^ + PDsr^;
CarryOut:= TmpLimb < PDnd^;
Inc(PDsr);
if CarryIn then begin
Inc(TmpLimb);
CarryOut:= CarryOut or (TmpLimb = 0);
end;
CarryIn:= CarryOut;
PDnd^:= TmpLimb;
Inc(PDnd);
Dec(Count);
until Count = 0;
Assert(CarryIn);
Dec(QGuess.Lo);
end;
// Возможно этот лимб больше не нужен и обнулять его необязательно
PDnd^:= 0;
Dec(LoopCount);
until LoopCount = 0;
end;
end.
|
program Kolmogorov(input, output);
const
MAX_SIZE = 1000;
type
range = 0 .. MAX_SIZE;
data = array[range] of real;
var
identifier : string;
dataArray : data;
i, size : integer;
sum : real;
procedure getData;
begin
i := 0;
read(identifier);
while not EOF do begin
read(dataArray[i]);
i := i + 1;
end
end;
procedure formatColumn(key : string; val : real);
var
spacesColumn : integer;
begin
spacesColumn := 17;
writeln(key, ' ' : spacesColumn - length(key), '|', '' : 5, val : 5:2, ' ' : spacesColumn - 12);
end;
function getAverage() : real;
begin
sum := 0.0;
for i := 0 to size do begin
sum := sum + dataArray[i];
end;
getAverage := sum / size;
end;
function getMedian() : real;
var
a, b : real;
begin
if size mod 2 <> 0 then
getMedian := dataArray[(size) div 2]
else begin
a := size div 2;
b := (size div 2) + 1;
getMedian := (a + b) / 2;
end;
end;
function getMode() : real;
var
mode : real;
temp, temp1 : integer;
begin
mode := dataArray[0];
temp := 1;
temp1 := 1;
for i := 1 to size - 1 do begin
if dataArray[i - 1] = dataArray[i] then
temp := temp + 1
else
temp := 1;
if temp >= temp1 then begin
mode := dataArray[i];
temp1 := temp
end;
end;
getMode := mode
end;
function getDeviation(var variance : real) : real;
var
summation, avg : real;
begin
summation := 0.0;
avg := getAverage();
for i := 1 to size do
summation := summation + sqr(avg - dataArray[i]);
variance := summation / size;
getDeviation := sqrt(variance);
end;
procedure swap(var a, b : real);
var
temp : real;
begin
temp := a; a := b; b := temp
end;
procedure shellSort(var v : data);
var
jump, n, m : range;
swapped : boolean;
begin
jump := size;
while jump > 1 do begin
jump := jump div 2;
repeat
swapped := false;
for m := 0 to (size - jump) do begin
n := m + jump;
if v[m] > v[n] then begin
swap(v[m], v[n]);
swapped := true;
end;
end;
until not swapped;
end;
end;
procedure outputResults();
var
min, max, variance : real;
begin
min := dataArray[1];
max := dataArray[size];
variance := 0.0;
writeln('-----------------------------------');
writeln(identifier);
writeln('-----------------------------------');
formatColumn('MEAN', getAverage());
formatColumn('MEDIAN', getMedian());
formatColumn('MODE', getMode());
formatColumn('STD DEVIATION', getDeviation(variance));
formatColumn('VARIANCE', variance);
formatColumn('SUM', sum);
formatColumn('MIN', min);
formatColumn('MAX', max);
formatColumn('RANGE', max - min);
formatColumn('COUNT', size);
writeln('-----------------------------------');
i := 0;
end;
begin
getData;
size := i;
shellSort(dataArray);
outputResults();
end. |
unit PlannerActions;
interface
uses
Classes, Planner, PlannerMonthView, ActnList, Clipbrd, Windows, Controls;
type
TPlannerAction = class(TAction)
private
FControl: TCustomControl;
procedure SetControl(Value: TCustomControl);
protected
function GetControl(Target: TObject): TCustomControl; virtual;
function GetControlItems(Target: TObject): TPlannerItems; virtual;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
public
destructor Destroy; override;
function HandlesTarget(Target: TObject): Boolean; override;
procedure UpdateTarget(Target: TObject); override;
property Control: TCustomControl read FControl write SetControl;
end;
TPlannerCut = class(TPlannerAction)
public
procedure ExecuteTarget(Target: TObject); override;
end;
TPlannerCopy = class(TPlannerAction)
public
procedure ExecuteTarget(Target: TObject); override;
end;
TPlannerPaste = class(TPlannerAction)
public
procedure UpdateTarget(Target: TObject); override;
procedure ExecuteTarget(Target: TObject); override;
end;
TPlannerDelete = class(TPlannerAction)
public
constructor Create(AOwner: TComponent); override;
procedure ExecuteTarget(Target: TObject); override;
end;
TPlannerInsert = class(TPlannerAction)
public
constructor Create(AOwner: TComponent); override;
procedure ExecuteTarget(Target: TObject); override;
end;
TPlannerEdit = class(TPlannerAction)
public
procedure ExecuteTarget(Target: TObject); override;
end;
implementation
{ TPlannerAction }
destructor TPlannerAction.Destroy;
begin
if Assigned(FControl) then
FControl.RemoveFreeNotification(Self);
inherited;
end;
function TPlannerAction.GetControl(Target: TObject): TCustomControl;
begin
{ We could hard cast Target as a TCustomEdit since HandlesTarget "should" be
called before ExecuteTarget and UpdateTarget, however, we're being safe. }
Result := Target as TCustomControl;
end;
function TPlannerAction.HandlesTarget(Target: TObject): Boolean;
var
res: Boolean;
begin
Result := false;
res := ((Control <> nil) and (Target = Control) or (Control = nil) and
((Target is TCustomPlanner) or (Target is TPlannerMonthView)));
if res then
begin
if (Target is TCustomPlanner) then
Result := (TCustomPlanner(Target).GridControl.Focused or TCustomPlanner(Target).Focused);
if (Target is TPlannerMonthView) then
Result := TPlannerMonthView(Target).Focused;
end;
end;
function TPlannerAction.GetControlItems(Target: TObject): TPlannerItems;
begin
Result := nil;
if (Target is TCustomPlanner) then
Result := TCustomPlanner(Target).Items;
if (Target is TPlannerMonthView) then
Result := TPlannerMonthView(Target).Items;
end;
procedure TPlannerAction.Notification(AComponent: TComponent;
Operation: TOperation);
begin
inherited Notification(AComponent, Operation);
if (Operation = opRemove) and (AComponent = Control) then Control := nil;
end;
procedure TPlannerAction.UpdateTarget(Target: TObject);
begin
if (Self is TPlannerCut) or (Self is TPlannerCopy) or (Self is TPlannerDelete) or (Self is TPlannerEdit) then
Enabled := Assigned(GetControlItems(Target).Selected);
end;
procedure TPlannerAction.SetControl(Value: TCustomControl);
begin
if Value <> FControl then
begin
FControl := Value;
if Value <> nil then Value.FreeNotification(Self);
end;
end;
{ TPlannerCopy }
procedure TPlannerCopy.ExecuteTarget(Target: TObject);
begin
GetControlItems(Target).CopyToClipboard;
end;
{ TPlannerCut }
procedure TPlannerCut.ExecuteTarget(Target: TObject);
begin
GetControlItems(Target).CutToClipboard;
end;
{ TPlannerPaste }
procedure TPlannerPaste.ExecuteTarget(Target: TObject);
begin
GetControlItems(Target).PasteFromClipboardAtPos;
end;
procedure TPlannerPaste.UpdateTarget(Target: TObject);
begin
Enabled := Clipboard.HasFormat(CF_PLANNERITEM);
end;
{ TPlannerDelete }
constructor TPlannerDelete.Create(AOwner: TComponent);
begin
inherited;
ShortCut := VK_DELETE;
end;
procedure TPlannerDelete.ExecuteTarget(Target: TObject);
begin
if (Target is TCustomPlanner) then
TCustomPlanner(Target).FreeItem(GetControlItems(Target).Selected);
if (Target is TPlannerMonthView) then
TPlannerMonthView(Target).FreeItem(GetControlItems(Target).Selected);
end;
{ TPlannerInsert }
constructor TPlannerInsert.Create(AOwner: TComponent);
begin
inherited;
ShortCut := VK_INSERT;
end;
procedure TPlannerInsert.ExecuteTarget(Target: TObject);
begin
if (Target is TCustomPlanner) then
TCustomPlanner(Target).CreateItemAtSelection;
if (Target is TPlannerMonthView) then
TPlannerMonthView(Target).CreateItemAtSelection;
end;
{ TPlannerEdit }
procedure TPlannerEdit.ExecuteTarget(Target: TObject);
begin
GetControlItems(Target).Selected.Edit;
end;
end.
|
unit CsReplyProcedures;
{* Класс для регистрации "ответных процедур" сервера для запросов от клиента. Синглетон. Используется для "логики по-умолчанию". Т.е. когда сервер у нас в приложении ОДИН }
// Модуль: "w:\common\components\rtl\Garant\cs\CsReplyProcedures.pas"
// Стереотип: "SimpleClass"
// Элемент модели: "TCsReplyProcedures" MUID: (5395B29D0177)
{$Include w:\common\components\rtl\Garant\cs\CsDefine.inc}
interface
{$If Defined(AppServerSide) AND NOT Defined(Nemesis)}
uses
l3IntfUses
, CsReplyProceduresWithRegistering
;
type
TCsReplyProcedures = class(TCsReplyProceduresWithRegistering)
{* Класс для регистрации "ответных процедур" сервера для запросов от клиента. Синглетон. Используется для "логики по-умолчанию". Т.е. когда сервер у нас в приложении ОДИН }
public
class function Instance: TCsReplyProcedures;
{* Метод получения экземпляра синглетона TCsReplyProcedures }
class function Exists: Boolean;
{* Проверяет создан экземпляр синглетона или нет }
end;//TCsReplyProcedures
{$IfEnd} // Defined(AppServerSide) AND NOT Defined(Nemesis)
implementation
{$If Defined(AppServerSide) AND NOT Defined(Nemesis)}
uses
l3ImplUses
, SysUtils
, l3Base
//#UC START# *5395B29D0177impl_uses*
//#UC END# *5395B29D0177impl_uses*
;
var g_TCsReplyProcedures: TCsReplyProcedures = nil;
{* Экземпляр синглетона TCsReplyProcedures }
procedure TCsReplyProceduresFree;
{* Метод освобождения экземпляра синглетона TCsReplyProcedures }
begin
l3Free(g_TCsReplyProcedures);
end;//TCsReplyProceduresFree
class function TCsReplyProcedures.Instance: TCsReplyProcedures;
{* Метод получения экземпляра синглетона TCsReplyProcedures }
begin
if (g_TCsReplyProcedures = nil) then
begin
l3System.AddExitProc(TCsReplyProceduresFree);
g_TCsReplyProcedures := Create;
end;
Result := g_TCsReplyProcedures;
end;//TCsReplyProcedures.Instance
class function TCsReplyProcedures.Exists: Boolean;
{* Проверяет создан экземпляр синглетона или нет }
begin
Result := g_TCsReplyProcedures <> nil;
end;//TCsReplyProcedures.Exists
{$IfEnd} // Defined(AppServerSide) AND NOT Defined(Nemesis)
end.
|
unit chromium_dom_xq;
interface
uses
sysutils,
cef_type, cef_api, cef_apiobj;
type
PDomTraverseParam = ^TDomTraverseParam;
TDomTraverseParam = record
PageId : integer;
Level : integer;
LevelStep1 : integer;
LevelStep2 : integer;
LevelStep3 : integer;
IsDoLog : Boolean;
ExParam : Pointer;
ExObject : TObject;
end;
TCefDomVisitProc = procedure (self: PCefDomVisitor; document: PCefDomDocument); stdcall;
TTraverseDomNode_Proc = procedure (ANode: PCefDomNode; ADomTraverseParam: PDomTraverseParam);
{ 遍历 html dom 节点 }
procedure TestTraverseChromiumDom(AClientObject: PCefClientObject; ACefDomVisitProc: TCefDomVisitProc);
var
ExTraverseDomNode_Proc: TTraverseDomNode_Proc = nil;
type
TInfoType_Xueqiu = (infxq_Undefine,
infxq_EPS, // earnings per share
infxq_PE, // price earning ratio
infxq_GeneralCapital,
infxq_NAPS, // 每股净资产 net asset per share
infxq_PB, // 市净率
infxq_Flow,
infxq_DPS,
infxq_PS
);
const
InfoKeyWord_Xueqiu: array[TInfoType_Xueqiu] of String = ('',
'每股收益',
'市盈率LYR/TTM', // 市盈率LYR 静态市盈率 市盈率TTM 动态市盈率
'总股本', // capitalization
'每股净资产',
'市净率TTM', // 每股股价与每股净资产的比率
'流通股本', // capital stock in circulation / Flow of equity
'每股股息', // Dividend Per Share
'市销率TTM' // 市销率( Price-to-sales,PS), PS = 总市值 除以主营业务收入或者 PS=股价 除以每股销售额
);
implementation
uses
UtilsLog,
cef_apilib,
cef_apilib_domvisitor;
procedure CheckHtmlValue(ADomTraverseParam: PDomTraverseParam; AName, AValue: string);
begin
if 1 = ADomTraverseParam.PageID then
begin
if 0 < Pos('每股收益', AValue) then
begin
Log('TraverseDomNode', 'Level' + IntToStr(ADomTraverseParam.Level) + ':' + AName + ':' + AValue);
end;
if 0 < Pos('每股净资产', AValue) then
begin
Log('TraverseDomNode', 'Level' + IntToStr(ADomTraverseParam.Level) + ':' + AName + ':' + AValue);
end;
if 0 < Pos('市盈率', AValue) then
begin
Log('TraverseDomNode', 'Level' + IntToStr(ADomTraverseParam.Level) + ':' + AName + ':' + AValue);
end;
if 0 < Pos('市净率', AValue) then
begin
Log('TraverseDomNode', 'Level' + IntToStr(ADomTraverseParam.Level) + ':' + AName + ':' + AValue);
end;
if 0 < Pos('市销率', AValue) then
begin
Log('TraverseDomNode', 'Level' + IntToStr(ADomTraverseParam.Level) + ':' + AName + ':' + AValue);
end;
end;
if 2 = ADomTraverseParam.PageID then
begin
if 0 < Pos('总股本', AValue) then
begin
Log('TraverseDomNode', 'Level' + IntToStr(ADomTraverseParam.Level) + ':' + AName + ':' + AValue);
end;
end;
end;
procedure TraverseDomNode_Proc(ANode: PCefDomNode; ADomTraverseParam: PDomTraverseParam);
var
tmpName: ustring;
tmpValue: ustring;
tmpAttrib: ustring;
tmpStr: ustring;
tmpCefStr: TCefString;
tmpChild: PCefDomNode;
tmpIsDoLog: Boolean;
tmpLevelStep1: Integer;
tmpLevelStep2: Integer;
tmpLevelStep3: Integer;
begin
{ 处理当前节点 }
tmpIsDoLog := ADomTraverseParam.IsDoLog;
tmpLevelStep1 := ADomTraverseParam.LevelStep1;
tmpLevelStep2 := ADomTraverseParam.LevelStep2;
tmpLevelStep3 := ADomTraverseParam.LevelStep3;
try
tmpName := CefStringFreeAndGet(ANode.get_name(ANode));
if SameText(tmpName, 'SCRIPT') then
exit;
if SameText(tmpName, 'span') then
exit;
tmpValue := '';
if SameText(tmpName, '#text') then
begin
tmpValue := CefStringFreeAndGet(ANode.get_value(ANode));
exit;
end;
if SameText(tmpName, 'TD') then
begin
tmpValue := CefStringFreeAndGet(ANode.get_element_inner_text(ANode));
end;
if SameText(tmpName, 'TABLE') then
begin
tmpCefStr := CefString('class');
tmpAttrib := CefStringFreeAndGet(ANode.get_element_attribute(ANode, @tmpCefStr));
if 1 = ADomTraverseParam.PageId then
begin
if SameText('topTable', tmpAttrib) then
begin
ADomTraverseParam.IsDoLog := True;//topTable
ADomTraverseParam.LevelStep1 := 1;
end;
end;
if 2 = ADomTraverseParam.PageId then
begin
if 0 < Pos('dataTable', tmpAttrib) then
begin
ADomTraverseParam.IsDoLog := True;//topTable
ADomTraverseParam.LevelStep1 := 1;
end;
end;
end;
if ADomTraverseParam.IsDoLog then
begin
//CheckHtmlValue(1, ADomTraverseParam, tmpName, tmpValue);
CheckHtmlValue(ADomTraverseParam, tmpName, tmpValue);
end;
tmpCefStr := CefString('href');
tmpAttrib := CefStringFreeAndGet(ANode.get_element_attribute(ANode, @tmpCefStr));
tmpStr := CefStringFreeAndGet(ANode.get_element_inner_text(ANode));
{ 处理子节点 }
ADomTraverseParam.Level := ADomTraverseParam.Level + 1;
tmpChild := ANode.get_first_child(ANode);
while tmpChild <> nil do
begin
TraverseDomNode_Proc(tmpChild, ADomTraverseParam);
tmpChild := tmpChild.get_next_sibling(tmpChild);
end;
ADomTraverseParam.Level := ADomTraverseParam.Level - 1;
finally
ADomTraverseParam.IsDoLog := tmpIsDoLog;
ADomTraverseParam.LevelStep1 := tmpLevelStep1;
ADomTraverseParam.LevelStep2 := tmpLevelStep2;
ADomTraverseParam.LevelStep3 := tmpLevelStep3;
end;
end;
procedure CefDomVisit_Proc(self: PCefDomVisitor; document: PCefDomDocument); stdcall;
var
tmpNode: PCefDomNode;
tmpDomTraverseParam: TDomTraverseParam;
begin
if document <> nil then
begin
tmpNode := document.get_document(document);
if tmpNode <> nil then
begin
FillChar(tmpDomTraverseParam, SizeOf(tmpDomTraverseParam), 0);
tmpDomTraverseParam.PageID := self.PageID;
if Assigned(ExTraverseDomNode_Proc) then
begin
ExTraverseDomNode_Proc(tmpNode, @tmpDomTraverseParam);
end else
begin
TraverseDomNode_Proc(tmpNode, @tmpDomTraverseParam);
end;
end;
end;
end;
procedure TestTraverseChromiumDom(AClientObject: PCefClientObject; ACefDomVisitProc: TCefDomVisitProc);
var
tmpMainFrame: PCefFrame;
begin
//FillChar(AClientObject.CefDomVisitor, SizeOf(AClientObject.CefDomVisitor), 0);
AClientObject.CefDomVisitor.CefClientObj := AClientObject;
tmpMainFrame := AClientObject.CefBrowser.get_main_frame(AClientObject.CefBrowser);
if tmpMainFrame <> nil then
begin
if Assigned(ACefDomVisitProc) then
begin
InitCefDomVisitor(@AClientObject.CefDomVisitor, AClientObject, ACefDomVisitProc);
end else
begin
InitCefDomVisitor(@AClientObject.CefDomVisitor, AClientObject, CefDomVisit_Proc);
end;
tmpMainFrame.visit_dom(tmpMainFrame, @AClientObject.CefDomVisitor.CefDomVisitor);
end;
end;
end.
|
program Project1;
Type
Str25=string[25];
TBookRec=
record
Title, Author, ISBN:str25;
Price:real;
end;
Procedure EnterNewBook(Var newBook:TBookRec);
begin
writeln('Please enter the book details: ');
write('Book Name: ');
readln(newBook.Title);
write('Author: ');
readln(newBook.Author);
write('ISBN: ');
readln(newBook.ISBN);
write('Price: ');
readln(newBook.Price);
end;
Procedure DisplayBookDetails(myBookRec:TBookRec);
begin
writeln('Here are the book details: ');
writeln;
writeln('Title: ',myBookRec.Title);
writeln('Author: ',myBookRec.Author);
writeln('ISBN: ',myBookRec.ISBN);
writeln('Price: ',myBookRec.Price);
end;
var
bookRec:TBookRec;
begin
enterNewBook(bookrec);
writeln('Thanks for entering the book details');
DisplayBookDetails(bookrec);
readln;
end.
{Passing Records as Arguments
It may become very useful when records are required to be passed through
arguments and this will be demonstrated shortly. I will use the same data structure,
pass it by reference as a parameter and return the value back through
the parameter also.}
|
unit rastan_hw;
interface
uses {$IFDEF WINDOWS}windows,{$ENDIF}
m68000,main_engine,controls_engine,gfx_engine,ym_2151,
msm5205,taitosnd,rom_engine,pal_engine,sound_engine;
function iniciar_rastan:boolean;
implementation
const
rastan_rom:array[0..5] of tipo_roms=(
(n:'b04-38.19';l:$10000;p:0;crc:$1c91dbb1),(n:'b04-37.7';l:$10000;p:$1;crc:$ecf20bdd),
(n:'b04-40.20';l:$10000;p:$20000;crc:$0930d4b3),(n:'b04-39.8';l:$10000;p:$20001;crc:$d95ade5e),
(n:'b04-42.21';l:$10000;p:$40000;crc:$1857a7cb),(n:'b04-43-1.9';l:$10000;p:$40001;crc:$ca4702ff));
rastan_char:array[0..3] of tipo_roms=(
(n:'b04-01.40';l:$20000;p:0;crc:$cd30de19),(n:'b04-03.39';l:$20000;p:$20000;crc:$ab67e064),
(n:'b04-02.67';l:$20000;p:$40000;crc:$54040fec),(n:'b04-04.66';l:$20000;p:$60000;crc:$94737e93));
rastan_sound:tipo_roms=(n:'b04-19.49';l:$10000;p:0;crc:$ee81fdd8);
rastan_sprites:array[0..3] of tipo_roms=(
(n:'b04-05.15';l:$20000;p:0;crc:$c22d94ac),(n:'b04-07.14';l:$20000;p:$20000;crc:$b5632a51),
(n:'b04-06.28';l:$20000;p:$40000;crc:$002ccf39),(n:'b04-08.27';l:$20000;p:$60000;crc:$feafca05));
rastan_adpcm:tipo_roms=(n:'b04-20.76';l:$10000;p:0;crc:$fd1a34cc);
var
scroll_x1,scroll_y1,scroll_x2,scroll_y2,adpcm_pos,adpcm_data:word;
bank_sound:array[0..3,$0..$3fff] of byte;
rom:array[0..$2ffff] of word;
ram1,ram3:array[0..$1fff] of word;
spritebank,sound_bank:byte;
ram2:array [0..$7fff] of word;
adpcm:array[0..$ffff] of byte;
procedure update_video_rastan;
var
f,x,y,nchar,atrib,color:word;
flipx,flipy:boolean;
begin
for f:=$fff downto $0 do begin
//background
atrib:=ram2[f*2];
color:=atrib and $7f;
if (gfx[0].buffer[f] or buffer_color[color]) then begin
x:=f mod 64;
y:=f div 64;
nchar:=ram2[$1+(f*2)] and $3fff;
flipx:=(atrib and $4000)<>0;
flipy:=(atrib and $8000)<>0;
put_gfx_flip(x*8,y*8,nchar,color shl 4,1,0,flipx,flipy);
gfx[0].buffer[f]:=false;
end;
//foreground
atrib:=ram2[$4000+(f*2)];
color:=atrib and $7f;
if (gfx[0].buffer[f+$1000] or buffer_color[color]) then begin
x:=f mod 64;
y:=f div 64;
nchar:=ram2[$4001+(f*2)] and $3fff;
flipx:=(atrib and $4000)<>0;
flipy:=(atrib and $8000)<>0;
put_gfx_trans_flip(x*8,y*8,nchar,color shl 4,2,0,flipx,flipy);
gfx[0].buffer[f+$1000]:=false;
end;
end;
scroll_x_y(1,3,scroll_x1,scroll_y1);
scroll_x_y(2,3,scroll_x2,scroll_y2);
//Sprites
for f:=$ff downto 0 do begin
nchar:=(ram3[$2+(f*4)]) and $fff;
if nchar<>0 then begin
atrib:=ram3[f*4];
color:=((atrib and $f) or ((spritebank and $f) shl 4)) shl 4;
put_gfx_sprite(nchar,color,(atrib and $4000)<>0,(atrib and $8000)<>0,1);
x:=(ram3[$3+(f*4)]+16) and $1ff;
y:=(ram3[$1+(f*4)]) and $1ff;
actualiza_gfx_sprite(x,y,3,1);
end;
end;
actualiza_trozo_final(16,8,320,240,3);
fillchar(buffer_color,MAX_COLOR_BUFFER,0);
end;
procedure eventos_rastan;
begin
if event.arcade then begin
if arcade_input.up[0] then marcade.in1:=(marcade.in1 and $fe) else marcade.in1:=(marcade.in1 or $1);
if arcade_input.down[0] then marcade.in1:=(marcade.in1 and $Fd) else marcade.in1:=(marcade.in1 or $2);
if arcade_input.left[0] then marcade.in1:=(marcade.in1 and $fb) else marcade.in1:=(marcade.in1 or $4);
if arcade_input.right[0] then marcade.in1:=(marcade.in1 and $F7) else marcade.in1:=(marcade.in1 or $8);
if arcade_input.but0[0] then marcade.in1:=(marcade.in1 and $df) else marcade.in1:=(marcade.in1 or $20);
if arcade_input.but1[0] then marcade.in1:=(marcade.in1 and $ef) else marcade.in1:=(marcade.in1 or $10);
if arcade_input.coin[0] then marcade.in0:=(marcade.in0 or $20) else marcade.in0:=(marcade.in0 and $df);
if arcade_input.coin[1] then marcade.in0:=(marcade.in0 or $40) else marcade.in0:=(marcade.in0 and $bf);
if arcade_input.start[0] then marcade.in0:=(marcade.in0 and $f7) else marcade.in0:=(marcade.in0 or $8);
if arcade_input.start[1] then marcade.in0:=(marcade.in0 and $ef) else marcade.in0:=(marcade.in0 or $10);
end;
end;
procedure rastan_principal;
var
frame_m,frame_s:single;
f:byte;
begin
init_controls(false,false,false,true);
frame_m:=m68000_0.tframes;
frame_s:=tc0140syt_0.z80.tframes;
while EmuStatus=EsRuning do begin
for f:=0 to $ff do begin
//Main CPU
m68000_0.run(frame_m);
frame_m:=frame_m+m68000_0.tframes-m68000_0.contador;
//Sound CPU
tc0140syt_0.z80.run(frame_s);
frame_s:=frame_s+tc0140syt_0.z80.tframes-tc0140syt_0.z80.contador;
if f=247 then begin
update_video_rastan;
m68000_0.irq[5]:=HOLD_LINE;
end;
end;
eventos_rastan;
video_sync;
end;
end;
function rastan_getword(direccion:dword):word;
begin
case direccion of
0..$5ffff:rastan_getword:=rom[direccion shr 1];
$10c000..$10ffff:rastan_getword:=ram1[(direccion and $3fff) shr 1];
$200000..$200fff:rastan_getword:=buffer_paleta[(direccion and $fff) shr 1];
$390000:rastan_getword:=marcade.in1;
$390002,$39000a:rastan_getword:=$ff;
$390004:rastan_getword:=$8f;
$390006:rastan_getword:=marcade.in0;
$390008:rastan_getword:=$fe;
$39000c..$39000f:rastan_getword:=$00;
$3e0002:if m68000_0.read_8bits_hi_dir then rastan_getword:=tc0140syt_0.comm_r;
$c00000..$c0ffff:rastan_getword:=ram2[(direccion and $ffff) shr 1];
$d00000..$d03fff:rastan_getword:=ram3[(direccion and $3fff) shr 1];
end;
end;
procedure rastan_putword(direccion:dword;valor:word);
procedure cambiar_color(tmp_color,numero:word);
var
color:tcolor;
begin
color.b:=pal5bit(tmp_color shr 10);
color.g:=pal5bit(tmp_color shr 5);
color.r:=pal5bit(tmp_color);
set_pal_color(color,numero);
buffer_color[(numero shr 4) and $7f]:=true;
end;
begin
case direccion of
0..$5ffff:; //ROM
$10c000..$10ffff:ram1[(direccion and $3fff) shr 1]:=valor;
$200000..$200fff:if buffer_paleta[(direccion and $fff) shr 1]<>valor then begin
buffer_paleta[(direccion and $fff) shr 1]:=valor;
cambiar_color(valor,(direccion and $fff) shr 1);
end;
$350008,$3c0000:;
$380000:spritebank:=(valor and $e0) shr 5;
$3e0000:tc0140syt_0.port_w(valor and $ff);
$3e0002:tc0140syt_0.comm_w(valor and $ff);
$c00000..$c03fff:if ram2[(direccion and $ffff) shr 1]<>valor then begin
ram2[(direccion and $ffff) shr 1]:=valor;
gfx[0].buffer[(direccion and $3fff) shr 2]:=true;
end;
$c04000..$c07fff,$c0c000..$c0ffff:ram2[(direccion and $ffff) shr 1]:=valor;
$c08000..$c0bfff:if ram2[(direccion and $ffff) shr 1]<>valor then begin
ram2[(direccion and $ffff) shr 1]:=valor;
gfx[0].buffer[((direccion and $3fff) shr 2)+$1000]:=true;
end;
$c20000:scroll_y1:=(512-valor) and $1ff;
$c20002:scroll_y2:=(512-valor) and $1ff;
$c40000:scroll_x1:=(512-valor) and $1ff;
$c40002:scroll_x2:=(512-valor) and $1ff;
$c50000..$c50003:;
$d00000..$d03fff:ram3[(direccion and $3fff) shr 1]:=valor;
end;
end;
function rastan_snd_getbyte(direccion:word):byte;
begin
case direccion of
0..$3fff,$8000..$8fff:rastan_snd_getbyte:=mem_snd[direccion];
$4000..$7fff:rastan_snd_getbyte:=bank_sound[sound_bank,direccion and $3fff];
$9001:rastan_snd_getbyte:=ym2151_0.status;
$a001:rastan_snd_getbyte:=tc0140syt_0.slave_comm_r;
end;
end;
procedure rastan_snd_putbyte(direccion:word;valor:byte);
begin
case direccion of
0..$7fff:; //ROM
$8000..$8fff:mem_snd[direccion]:=valor;
$9000:ym2151_0.reg(valor);
$9001:ym2151_0.write(valor);
$a000:tc0140syt_0.slave_port_w(valor);
$a001:tc0140syt_0.slave_comm_w(valor);
$b000:adpcm_pos:=(adpcm_pos and $00ff) or (valor shl 8);
$c000:msm5205_0.reset_w(0);
$d000:begin
msm5205_0.reset_w(1);
adpcm_pos:=adpcm_pos and $ff00;
end;
end;
end;
procedure sound_bank_rom(valor:byte);
begin
sound_bank:=valor and 3;
end;
procedure sound_instruccion;
begin
ym2151_0.update;
end;
procedure ym2151_snd_irq(irqstate:byte);
begin
tc0140syt_0.z80.change_irq(irqstate);
end;
procedure snd_adpcm;
begin
if (adpcm_data and $100)=0 then begin
msm5205_0.data_w(adpcm_data and $0f);
adpcm_data:=$100;
adpcm_pos:=(adpcm_pos+1) and $ffff;
end else begin
adpcm_data:=adpcm[adpcm_pos];
msm5205_0.data_w(adpcm_data shr 4);
end;
end;
//Main
procedure reset_rastan;
begin
m68000_0.reset;
tc0140syt_0.reset;
YM2151_0.reset;
msm5205_0.reset;
reset_audio;
marcade.in0:=$1f;
marcade.in1:=$ff;
sound_bank:=0;
scroll_x1:=0;
scroll_y1:=0;
scroll_x2:=0;
scroll_y2:=0;
adpcm_data:=$100;
adpcm_pos:=0;
end;
function iniciar_rastan:boolean;
const
pc_y:array[0..7] of dword=(0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16);
ps_x:array[0..15] of dword=(0, 4, $40000*8+0 ,$40000*8+4, 8+0, 8+4, $40000*8+8+0, $40000*8+8+4,
16+0, 16+4, $40000*8+16+0, $40000*8+16+4,24+0, 24+4, $40000*8+24+0, $40000*8+24+4);
ps_y:array[0..15] of dword=(0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32,
8*32, 9*32, 10*32, 11*32, 12*32, 13*32, 14*32, 15*32 );
var
memoria_temp:array[0..$7ffff] of byte;
begin
llamadas_maquina.bucle_general:=rastan_principal;
llamadas_maquina.reset:=reset_rastan;
iniciar_rastan:=false;
iniciar_audio(false);
screen_init(1,512,512);
screen_mod_scroll(1,512,512,511,512,256,511);
screen_init(2,512,512,true);
screen_mod_scroll(2,512,512,511,512,256,511);
screen_init(3,512,512,false,true);
iniciar_video(320,240);
//Main CPU
m68000_0:=cpu_m68000.create(8000000,256);
m68000_0.change_ram16_calls(rastan_getword,rastan_putword);
//Sound CPU
tc0140syt_0:=tc0140syt_chip.create(4000000,256);
tc0140syt_0.z80.change_ram_calls(rastan_snd_getbyte,rastan_snd_putbyte);
tc0140syt_0.z80.init_sound(sound_instruccion);
//Sound Chips
msm5205_0:=MSM5205_chip.create(384000,MSM5205_S48_4B,1,snd_adpcm);
ym2151_0:=ym2151_chip.create(4000000);
ym2151_0.change_port_func(sound_bank_rom);
ym2151_0.change_irq_func(ym2151_snd_irq);
//cargar roms
if not(roms_load16w(@rom,rastan_rom)) then exit;
//rom[$05FF9F]:=$fa; //Cheeeeeeeeat
//cargar sonido+ponerlas en su banco+adpcm
if not(roms_load(@memoria_temp,rastan_sound)) then exit;
copymemory(@mem_snd[0],@memoria_temp[0],$4000);
copymemory(@bank_sound[0,0],@memoria_temp[$0],$4000);
copymemory(@bank_sound[1,0],@memoria_temp[$4000],$4000);
copymemory(@bank_sound[2,0],@memoria_temp[$8000],$4000);
copymemory(@bank_sound[3,0],@memoria_temp[$c000],$4000);
if not(roms_load(@adpcm,rastan_adpcm)) then exit;
//convertir chars
if not(roms_load(@memoria_temp,rastan_char)) then exit;
init_gfx(0,8,8,$4000);
gfx[0].trans[0]:=true;
gfx_set_desc_data(4,0,16*8,0,1,2,3);
convert_gfx(0,0,@memoria_temp,@ps_x,@pc_y,false,false);
//convertir sprites
if not(roms_load(@memoria_temp,rastan_sprites)) then exit;
init_gfx(1,16,16,$1000);
gfx[1].trans[0]:=true;
gfx_set_desc_data(4,0,64*8,0,1,2,3);
convert_gfx(1,0,@memoria_temp,@ps_x,@ps_y,false,false);
//final
reset_rastan;
iniciar_rastan:=true;
end;
end.
|
{
Pascal version of "hello world!"
}
program HelloWorld(output);
begin
Write('hello world!')
end.
|
unit DW.UserDefaults.iOS;
{*******************************************************}
{ }
{ Kastri }
{ }
{ Delphi Worlds Cross-Platform Library }
{ }
{ Copyright 2020-2021 Dave Nottage under MIT license }
{ which is located in the root folder of this library }
{ }
{*******************************************************}
{$I DW.GlobalDefines.inc}
interface
uses
// iOS
iOSapi.Foundation;
type
TUserDefaults = record
public
class function GetValue(const AKey: string; const ADefault: string = ''): string; overload; static;
class function GetValue(const AKey: NSString): NSString; overload; static;
class procedure SetValue(const AKey, AValue: string); overload; static;
class procedure SetValue(const AKey: NSString; const AValue: NSObject); overload; static;
class procedure SetValue(const AKey: string; const AValue: NSObject); overload; static;
end;
implementation
uses
// macOS
Macapi.Helpers, Macapi.ObjectiveC,
// DW
DW.iOSapi.Helpers;
{ TUserDefaults }
class function TUserDefaults.GetValue(const AKey: string; const ADefault: string = ''): string;
var
LValue: NSString;
begin
LValue := TiOSHelperEx.StandardUserDefaults.stringForKey(StrToNSStr(AKey));
if LValue <> nil then
Result := NSStrToStr(LValue)
else
Result := ADefault;
end;
class procedure TUserDefaults.SetValue(const AKey, AValue: string);
begin
TiOSHelperEx.StandardUserDefaults.setObject(StringToID(AValue), StrToNSStr(AKey));
end;
class function TUserDefaults.GetValue(const AKey: NSString): NSString;
begin
Result := TiOSHelperEx.StandardUserDefaults.stringForKey(AKey);
end;
class procedure TUserDefaults.SetValue(const AKey: string; const AValue: NSObject);
begin
TiOSHelperEx.StandardUserDefaults.setObject(NSObjectToID(AValue), StrToNSStr(AKey));
end;
class procedure TUserDefaults.SetValue(const AKey: NSString; const AValue: NSObject);
begin
TiOSHelperEx.StandardUserDefaults.setObject(NSObjectToID(AValue), AKey);
end;
end.
|
{
This file is part of the Free Pascal run time library.
Copyright (c) 1999-2014 by Maciej Izak aka hnb (NewPascal project)
See the file COPYING.FPC, included in this distribution,
for details about the copyright.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
**********************************************************************}
unit SmartObj;
{$MODE DELPHI}
interface
uses
SysUtils, Classes;
type
TSmartObj<T: TObject> = record
// similar as overloading [] operators for property x[v: string]: integer read gx write sx; default;
Instance: T default; // default keyword for non property.
RefCount: PLongint;
procedure SmartFinalize();
class operator Initialize(var aRec: TSmartObj<T>);
class operator Finalize(var aRec: TSmartObj<T>);
class operator AddRef(var aRec: TSmartObj<T>);
class operator Copy(constref aSource: TSmartObj<T>; var aDest: TSmartObj<T>);
// implicit or explicit operator is used before "default" field
class operator Implicit(aObj: T): TSmartObj<T>;
procedure Assign(const aValue: T);
end;
implementation
procedure TSmartObj<T>.SmartFinalize();
begin
if RefCount <> nil then
if InterLockedDecrement(RefCount^)=0 then
begin
FreeMem(RefCount);
Instance.Free;
end;
end;
class operator TSmartObj<T>.Initialize(var aRec: TSmartObj<T>);
begin
aRec.RefCount := nil;
end;
class operator TSmartObj<T>.Finalize(var aRec: TSmartObj<T>);
begin
aRec.SmartFinalize();
end;
class operator TSmartObj<T>.AddRef(var aRec: TSmartObj<T>);
begin
if aRec.RefCount <> nil then
InterLockedIncrement(aRec.RefCount^);
end;
class operator TSmartObj<T>.Copy(constref aSource: TSmartObj<T>; var aDest: TSmartObj<T>);
begin
if aDest.RefCount <> nil then
aDest.SmartFinalize();
if aSource.RefCount <> nil then
InterLockedIncrement(aSource.RefCount^);
aDest.RefCount := aSource.RefCount;
aDest.Instance := aSource.Instance;
end;
class operator TSmartObj<T>.Implicit(aObj: T): TSmartObj<T>;
begin
Result.Assign(aObj);
end;
procedure TSmartObj<T>.Assign(const aValue: T);
begin
if RefCount <> nil then
SmartFinalize();
GetMem(RefCount, SizeOf(LongInt));
RefCount^ := 0;
InterLockedIncrement(RefCount^);
Instance := aValue;
end;
end.
|
PROGRAM SortMonth_b(INPUT, OUTPUT);
{Программа сравнивает введённые значения месяцев}
USES DateIO; {ReadMonth, WriteMonth}
PROCEDURE Copy(VAR F1, F2: TEXT);
VAR
Ch: CHAR;
BEGIN {Copy}
RESET(F1);
REWRITE(F2);
WHILE NOT EOLN(F1)
DO
BEGIN
READ(F1, Ch);
WRITE(F2, Ch)
END;
WRITELN(F2);
RESET(F2)
END; {Copy}
VAR
F1: TEXT;
MonthNameFirst, MonthNameSecond: Month;
BEGIN {SortMonth}
Copy(INPUT, F1);
IF NOT EOLN(F1)
THEN
ReadMonth(F1, MonthNameFirst);
IF NOT EOLN(F1)
THEN
ReadMonth(F1, MonthNameSecond);
IF (MonthNameFirst = NoMonth) OR (MonthNameSecond = NoMonth)
THEN
WRITE('Входные данные записаны неверно')
ELSE
IF MonthNameFirst = MonthNameSecond
THEN
BEGIN
WRITE('Оба месяца ');
WriteMonth(OUTPUT, MonthNameFirst)
END
ELSE
BEGIN
WriteMonth(OUTPUT, MonthNameFirst);
IF MonthNameFirst < MonthNameSecond
THEN
BEGIN
WRITE(' предшедствует ');
WriteMonth(OUTPUT, MonthNameSecond)
END
ELSE
BEGIN
WRITE(' следует за ');
WriteMonth(OUTPUT, MonthNameSecond)
END
END;
WRITELN
END. {SortMonth}
|
unit sdBasic;
{Basic code for double precision special functions}
interface
{$i std.inc}
{$ifdef BIT16}
{$N+}
{$endif}
{$ifdef NOBASM}
{$undef BASM}
{$endif}
uses DAMath;
(*************************************************************************
DESCRIPTION : Basic code for double precision special functions:
Definitions, constants, etc.
REQUIREMENTS : BP7, D1-D7/D9-D10/D12/D17-D18, FPC, VP, WDOSX
EXTERNAL DATA : ---
MEMORY USAGE : ---
DISPLAY MODE : ---
REMARK : ---
REFERENCES : Index in damath_info.txt/references
Version Date Author Modification
------- -------- ------- ------------------------------------------
1.00.00 05.02.13 W.Ehrhardt sdBasic: Initial BP7 version from AMath.sfbasic
1.00.01 05.02.13 we sdBasic: sfd_bernoulli
1.00.02 05.02.13 we sdMisc: sfd_agm, sfd_agm2
1.00.03 06.02.13 we sdEllInt: THexDblW constants for sfd_nome
1.00.04 06.02.13 we sdEllInt: adjusted some constants for double precision
1.00.05 06.02.13 we sdEllInt: changed test 0<x to x<-eps_d in sfd_ellint_?
1.00.06 06.02.13 we sdEllInt: changed test abs(t-Pi_2)
1.00.07 07.02.13 we sdMisc: sfd_LambertW, sfd_LambertW1
1.00.08 07.02.13 we sdEllInt: adjusted Carlson eps constants
1.00.09 07.02.13 we sdEllInt: sfd_EllipticPiC/CPi always with cel
1.00.10 07.02.13 we sdBasic: sfd_bernoulli with bx16 (halved iteration count)
1.00.11 07.02.13 we sdGamma: stirf, sfd_gaminv_small, sfd_gamma_medium
1.00.12 08.02.13 we sdGamma: sfd_lngcorr, sfd_gstar, lngamma_small, lanczos
1.00.13 08.02.13 we sdbasic: BoFHex as THexDblW
1.00.14 08.02.13 we sdGamma: sfd_fac, sfd_dfac, sfd_binomial, sfd_psi, sfd_poch1
1.00.15 08.02.13 we sdZeta: sfd_dilog, sfd_etaint, sfd_zetaint
1.00.16 09.02.13 we sdZeta: zetap with 53-bit logic from [19]
1.00.17 09.02.13 we sdZeta: etam1pos
1.00.18 09.02.13 we sdGamma: sfd_trigamma/tetragamma/pentagamma/polygamma
1.00.19 09.02.13 we sdZeta: sfd_cl2
1.00.20 10.02.13 we sdMisc: sfd_debye
1.00.21 10.02.13 we sdPoly: adjusted tol in lq_hf
1.00.22 10.02.13 we sdGamma: sfd_lngamma uses FacTab
1.00.23 10.02.13 we sdMisc: sfd_ri
1.00.24 10.02.13 we sdExpInt: sfd_ei
1.00.25 10.02.13 we sdExpInt: modified sfd_eiex to compute exp(x) if expx < 0
1.00.26 10.02.13 we sdExpInt: en_series avoids FPC nonsense
1.00.27 10.02.13 we sdExpInt: sfd_ssi, auxfg
1.00.28 11.02.13 we sdGamma: igam_aux, sfd_igprefix
1.00.29 11.02.13 we sdErf: erf_small, sfd_erfc_iusc, sfd_erfi
1.00.30 11.02.13 we sdErf: sfd_fresnel
1.00.31 12.02.13 we sdSDist: sfd_normstd_cdf, sfd_normstd_pdf
1.00.32 12.02.13 we sdZeta: sfd_fdm05, sfd_fdp05
1.00.33 12.02.13 we sdBessel: Constant IvMaxX in sfd_iv
1.00.34 12.02.13 we sdBessel: sfd_i0
1.00.35 12.02.13 we sdBessel: sfd_j0, sfd_y0, bess_m0p0
1.00.36 13.02.13 we sdBessel: sfd_j1, sfd_y1, bess_m1p1
1.00.37 13.02.13 we sdBessel: sfd_in
1.00.38 13.02.13 we sdBessel: fix two near overflow cases in bessel_jy
1.00.39 14.02.13 we sdBessel: Airy functions
1.00.40 14.02.13 we sdBessel: Kelvin functions
1.00.41 14.02.13 we sdBessel: Struve functions
1.00.42 15.02.13 we sdGamma: improved sfd_git
1.00.43 16.02.13 we sdZeta: improved sfd_zetah
1.00.44 20.02.13 we SpecFunD: SpecFunD_Version
1.00.45 01.03.13 we (some) Reduced some Chebyshev degrees
1.00.46 02.02.13 we sdBessel: Fixed value of IvMaxX in sfd_iv
1.01.00 15.03.13 we sdEllInt: Remaining Jacobi elliptic functions
1.01.01 25.03.13 we sdEllInt: Remaining inverse Jacobi elliptic functions
1.01.02 28.03.13 we sdZeta: sfd_zetah for s<0
1.01.03 28.03.13 we sdZeta: sfd_trilog
1.01.04 30.03.13 we sdZeta: sfd_zetah for a near 1 and s<0
1.01.05 30.03.13 we sdGamma: improved sfd_binomial
1.02.00 07.04.13 we sdSDist: Improved sfd_chi2_pdf for very small x
1.02.01 11.04.13 we sdZeta: sfd_fdp15
1.02.02 13.04.13 we sdSDist: k changed to longint in sfd_poisson_pmf
1.02.03 14.04.13 we sdSDist: sfd_rayleigh_pdf/cdf/inv
1.02.04 18.04.13 we sdGamma: improved sfd_beta
1.02.05 18.04.13 we sdGamma: ibeta_series with parameter normalised
1.02.06 18.04.13 we sdGamma: sfd_nnbeta
1.02.07 19.04.13 we sdSDist: sfd_maxwell_pdf/cdf/inv
1.02.08 20.04.13 we sdSDist: sfd_evt1_pdf/cdf/inv
1.02.09 20.04.13 we sdSDist: sfd_maxwell_cdf/inv with lower igamma functions
1.02.10 21.04.13 we sdGamma: lanczos_gm05 = lanczos_g - 0.5 in implementation
1.02.11 27.04.13 we sdGamma: polygam_negx for n=11,12
1.02.12 01.05.13 we SpecFunD: FresnelC/FresnelS
1.03.00 09.05.13 we sdBessel: Airy/Scorer functions sfd_airy_gi/hi
1.03.01 11.05.13 we sdGamma: improved sfd_polygamma for large order: e.g. (3001, 871)
1.03.02 13.05.13 we sdPoly: Change limits to 2e16 in p0ph,p1mh,p1ph
1.03.03 27.05.13 we sdHyperG: New Hypergeometric functions unit
1.03.04 27.05.13 we sdGamma: sfd_nnbeta for a<=0 or b<=0
1.03.05 31.05.13 we sdHyperG: AMath changes for sfd_chu
1.04.00 15.06.13 we sdBessel: Fix typo in h1v_large
1.04.01 15.06.13 we sdBessel: sfd_bess_kv2
1.04.02 15.06.13 we sdHyperG: Temme's chu and uabx from AMath
1.04.03 16.06.13 we sdHyperG: Whittaker functions sfd_whitm/sfd _whitw
1.04.04 28.06.13 we sdBessel: Check overflow / return INF in bessel_jy
1.04.05 28.06.13 we sdHyperG: sfd_0f1
1.04.06 01.07.13 we sdHyperG: sfd_0f1r
1.05.00 28.07.13 we sdHyperG: MAXIT=64 in h1f1_tricomi
1.05.01 28.07.13 we sdGamma: sfd_git for x<0
1.05.02 15.08.13 we sdSDist: Removed code fragment for y>1 in sfd_beta_inv
1.05.03 15.08.13 we sdSDist: Check a,b > 0 in sfd_beta_cdf
1.05.04 15.08.13 we sdSDist: sfd_kumaraswamy_pdf/cdf/inv
1.05.05 16.08.13 we sdZeta: sfd_zeta for small s
1.05.06 16.08.13 we sdZeta: sfd_polylog with sfd_zetaint
1.05.07 15.08.13 we sdErf: sfd_erf_z, sfd_erf_p, sfd_erf_q
1.05.08 18.08.13 we sdsDist: normal/normstd_pdf/cdf with erf_z and erf_p
1.06.00 07.09.13 we sdZeta: Improved sfd_zetah/hurwitz_formula
1.06.01 12.09.13 we sdZeta: Bernoulli polynomials sfd_bernpoly
1.06.02 18.09.13 we sdPoly: sfd_chebyshev_v/w
1.06.03 24.09.13 we sdMisc: sfd_cosint, sfd_sinint
1.06.04 25.09.13 we sdGamma: sfd_batemang
1.06.05 25.09.13 we (some) use const one_d to avoid FPC nonsense
1.06.06 26.09.13 we sdMisc: Fixed quasi-periodic code for sfd_cos/sinint
1.06.07 28.09.13 we sdEllInt: special_reduce_modpi, used in sfd_ellint_1/2/3 and sfd_hlambda
1.07.00 19.10.13 we sdsDist: sfd_moyal_pdf/cdf/inv
1.07.01 23.10.13 we sdEllInt: sfd_EllipticKim, sfd_EllipticECim
1.07.02 04.11.13 we sdSDist: improved sfd_t_pdf for small x^2/nu
1.08.00 26.12.13 we sdZeta: sfd_fdp25
1.09.00 24.03.14 we sdHyperG: chu_luke only with $ifdef in dchu
1.09.01 28.03.14 we sdBessel: sfd_yn with LnPi from DAMath
1.09.02 28.03.14 we sdHyperG: InfOrNan tests in sfd_1f1
1.10.00 18.04.14 we sdGamma: polygam_negx (larger n for x<0}
1.10.01 02.05.14 we sdZeta: sfd_harmonic
1.10.02 03.05.14 we sdZeta: sfd_harmonic2
1.10.03 04.05.14 we sdSDist: sfd_zipf_pmf/cdf
1.11.00 24.05.14 we sdMisc: sfd_ali functional inverse of sfc_li
1.11.01 29.05.14 we sdZeta: Removed redundancy in sfc_harmonic2
1.11.02 29.05.14 we sdZeta: polylogneg with array of single
1.11.03 30.05.14 we SpecFunD: Fix zipf_pmf/cdf function type
1.11.04 31.05.14 we sdZeta: Lobachevski sfd_llci, sfd_llsi; improved harm2core
1.11.05 04.06.14 we sdMisc: sfd_fpoly/sfd_lpoly
1.11.06 05.06.14 we sdSDist: sfd_levy_pdf/cdf/inv
1.12.00 16.06.14 we Incomplete/inverse functions moved to sdGamma2
1.12.01 16.06.14 we sdGamma: const lanczos_gm05: double
1.12.02 16.06.14 we sdGamma2: sfd_ibeta_inv (code from sdSDist)
1.12.03 16.06.14 we sdZeta: Fermi/Dirac, Lobachewsky, harmonic functions moved to sdZeta2
1.12.04 22.06.14 we sdGamma2: sfd_ilng (inverse of lngamma)
1.12.05 25.06.14 we sdGamma2: sfd_ipsi (inverse of psi)
1.12.06 03.07.14 we SpecFunD: ibeta_inv
1.12.07 13.07.14 we sdHyperG: sfc_pcfd,sfc_pcfu,sfc_pcfhh
1.13.00 30.07.14 we sdBasic: moebius[1..83]
1.13.01 30.07.14 we sdZeta: Improved and expanded primezeta sfd_pz
1.13.02 06.08.14 we sdGamma: First check IsNaND(x) in sfd_lngammas
1.13.03 06.08.14 we sdGamma: improved sfd_gdr_pos for small x
1.13.04 11.08.14 we sdBessel: Iv := PosInf_v if Kv,Kv1=0 in bessel_ik or if x >= IvMaxXH in sfc_iv
1.13.05 11.08.14 we sdGamma: special case x=x+y in sfd_beta
1.13.06 11.08.14 we sdHyperG: fix: sfc_pcfd,sfc_pcfu,sfc_pcfhh use double
1.13.07 17.08.14 we sdMisc: Catalan function sfd_catf
1.13.08 19.08.14 we sdHyperG: sfc_pcfv
1.13.09 20.08.14 we sdGamma: sfd_gamma_delta_ratio returns 1 if x=x+d
1.14.00 01.09.14 we sdHyperG: sfd_chu for x<0
1.14.01 04.09.14 we sdHyperG: fix h1f1_tricomi (division by t=0)
1.14.02 07.09.14 we sdSDist: sfd_logistic_inv uses logit function
1.14.03 06.10.14 we sdSDist: sfd_logistic_cdf uses logistic function
1.15.00 26.10.14 we sdHyperG: No Kummer transformation in 1F1 if b=0,-1,-2,...
1.15.01 29.10.14 we sdHyperG: 1F1 = 1 + a/b*(exp(x)-1) for very small a,b
1.15.02 07.11.14 we sdBasic: Small Bernoulli numbers B2nHex moved to DAMath
1.16.00 15.12.14 we sdGamma: small changes in sfc_batemang
1.16.01 16.12.14 we sdGamma2: Check IsNanOrInf in sfd_ilng
1.16.02 23.12.14 we sdSDist: sfd_invgamma_pdf/cdf/inv
1.16.03 26.12.14 we sdSDist: logarithmic (series) distribution
1.16.04 03.01.15 we sdSDist: sfd_wald_cdf/pdf/inv
1.16.05 05.01.15 we sdSDist: Error if k<1 in sfc_ls_cdf/pmf
1.16.06 05.01.15 we sdHyperG: Special case b=1 in gen_0f1
1.16.07 09.01.15 we sdMisc: Euler numbers sfd_euler
1.17.00 25.01.15 we sdExpInt: sfd_ali from sdMisc
1.17.01 25.01.15 we sdExpInt: sfd_ei_inv
1.17.02 28.03.15 we sdEllInt: sfd_cel_d, sfd_ellint_d
1.17.03 01.05.15 we sdExpInt: fix sfd_ei_inv for x Nan
1.18.00 18.05.15 we sdZeta: Improved sfd_etam1 (adjusted Borwein constants)
1.18.01 18.05.15 we sdZeta: sfd_polylogr and sfd_lerch for s >= -1
1.18.02 25.05.15 we sdZeta: sfd_lerch(1,s,a) for s<>1 and special case z=0
1.18.03 04.06.15 we sdBasic: remove CSInitD
1.18.04 04.06.15 we sdMisc: sfd_kepler
1.18.05 10.06.15 we sdBessel: new IJ_series replaces Jv_series
1.18.06 10.06.15 we sdBessel: rewrite of sfc_in: use IJ_series and CF1_I
1.18.07 10.06.15 we sdBessel: improved bess_m0p0/bess_m1p1 with rem_2pi_sym and Kahan summation
1.18.08 10.06.15 we sdBessel: sfd_struve_l/h, sfd_struve_l0/1 use sfd_struve_l
1.18.09 14.06.15 we sdBessel: sfd_struve_h/l with real nu >= 0
1.18.10 19.06.15 we sdBessel: scaled Airy functions sfd_airy_ais, sfd_airy_bis
1.18.11 22.06.15 we sdEllInt: avoid overflow in sfd_ell_rf, better arg checks in Carlson functions
1.18.12 22.06.15 we sdEllInt: Carlson sfd_ell_rg
1.18.13 26.06.15 we sdZeta2: Fix: Type double in sfd_fdp25 and harm2core
1.18.14 26.06.15 we sdHyperG: Fix: double variables in chu_negx
***************************************************************************)
(*-------------------------------------------------------------------------
(C) Copyright 2009-2015 Wolfgang Ehrhardt
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from
the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software in
a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
----------------------------------------------------------------------------*)
(*-------------------------------------------------------------------------
This Pascal code uses material and ideas from open source and public
domain libraries, see the file '3rdparty.ama' for the licenses.
---------------------------------------------------------------------------*)
const
SD_BaseVersion = '1.18.14';
const
RTE_NoConvergence: integer = 234; {RTE for no convergence, set negative}
{to continue (with inaccurate result)}
RTE_ArgumentRange: integer = 235; {RTE for argument(s) out of range, set}
{negative to continue with NAN result.}
{Tested if $R+ option is enabled}
procedure sincosPix2(x: double; var s,c: double);
{-Return s=sin(Pi/2*x^2), c=cos(Pi/2*x^2); (s,c)=(0,1) for abs(x) >= 2^53}
function sfd_bernoulli(n: integer): double;
{-Return the nth Bernoulli number, 0 if n<0 or odd n >= 3}
{#Z+}
{---------------------------------------------------------------------------}
{Moebius function æ(n) for small arguments}
const
n_moeb = 83;
moebius: array[1..n_moeb] of shortint = (
1, -1, -1, 0, -1, 1, -1, 0, 0, 1,
-1, 0, -1, 1, 1, 0, -1, 0, -1, 0,
1, 1, -1, 0, 0, 1, 0, 0, -1, -1,
-1, 0, 1, 1, 1, 0, -1, 1, 1, 0,
-1, -1, -1, 0, 0, 1, -1, 0, 0, 0,
1, 0, -1, 0, 1, 0, 1, 1, -1, 0,
-1, 1, 0, 0, 1, -1, -1, 0, 1, -1,
-1, 0, -1, 1, 0, 0, 1, -1, -1, 0,
0, 1, -1);
{---------------------------------------------------------------------------}
{Bernoulli numbers. The B(2n), n = 0..MaxB2nSmall are in DAMath}
const
MaxBernoulli = 259;
const
NBoF = 20;
BoFHex: array[0..NBoF] of THexDblW = ({Bernoulli(2k+2)/(2k+2)! }
($5555,$5555,$5555,$3FB5), {+8.3333333333333333336E-2}
($6C17,$16C1,$C16C,$BF56), {-1.3888888888888888888E-3}
($1567,$BC01,$566A,$3F01), {+3.3068783068783068783E-5}
($EF0B,$9334,$BD77,$BEAB), {-8.2671957671957671957E-7}
($0EBE,$2BF7,$6A8F,$3E56), {+2.0876756987868098980E-8}
($267F,$D644,$2805,$BE02), {-5.2841901386874931847E-10}
($9162,$C4E0,$6DB2,$3DAD), {+1.3382536530684678833E-11}
($955C,$1F79,$DA4E,$BD57), {-3.3896802963225828668E-13}
($2E9E,$1D65,$5587,$3D03), {+8.5860620562778445639E-15}
($ACF1,$68CA,$57D9,$BCAF), {-2.1748686985580618731E-16}
($376F,$F09C,$67E1,$3C59), {+5.5090028283602295151E-18}
($2B5C,$033A,$97D9,$BC04), {-1.3954464685812523341E-19}
($AD06,$D7C6,$B132,$3BB0), {+3.5347070396294674718E-21}
($1C16,$D59F,$0F72,$BB5B), {-8.9535174270375468504E-23}
($A26D,$A4CC,$EF2D,$3B05), {+2.2679524523376830603E-24}
($E38B,$F96D,$C77D,$BAB1), {-5.7447906688722024451E-26}
($1B62,$DE52,$D299,$3A5C), {+1.4551724756148649018E-27}
($74A7,$6565,$5CDE,$BA07), {-3.6859949406653101781E-29}
($4ADF,$DB3B,$EFE8,$39B2), {+9.3367342570950446721E-31}
($61FF,$9047,$B322,$B95E), {-2.3650224157006299346E-32}
($8464,$F932,$E25F,$3908)); {+5.9906717624821343044E-34}
{#Z-}
{$ifdef debug}
type
sfd_debug_str = string[255];
const
NDCTR = 8;
var
sfd_diagctr: array[0..NDCTR-1] of longint; {General counters for diagnostics}
sfd_debug_output: boolean; {Really doing the outputs if true}
procedure sfd_dump_diagctr;
{-writeln diagnostic counters}
procedure sfd_write_debug_str(const msg: sfd_debug_str);
{-Writeln or Outputdebugstr of msg}
{$endif}
implementation
{$ifdef Debug}
{$ifdef WIN32or64}
{$ifndef VirtualPascal}
{$define USE_OutputDebugString}
{$endif}
{$endif}
{$ifdef USE_OutputDebugString}
{$ifdef UNIT_SCOPE}
uses winapi.windows;
{$else}
uses windows;
{$endif}
{$endif}
{$endif}
{---------------------------------------------------------------------------}
procedure sincosPix2(x: double; var s,c: double);
{-Return s=sin(Pi/2*x^2), c=cos(Pi/2*x^2); (s,c)=(0,1) for abs(x) >= 2^53}
var
n,f,g: double;
begin
{Note that this routine is very sensible to argument changes! }
{Demo of sincosPix2 sensibility to argument changes }
{Computing sin(Pi/2*x^2) with sincosPix2 and MPArith for x=10000.1}
{mp_float default bit precision = 240, decimal precision = 72.2 }
{Machine eps for double = 2.22044604925E-0016 }
{d = x(double) = +10000.100000000000364 }
{x - d = -3.6379788070917129517E-13 }
{rel. diff = -3.6379424276674362773E-17 }
{a = sincosPix2 = 1.57073287395724723E-0002 }
{b = sin(Pi/2*x^2) = +1.5707317311820675753E-2 }
{c = sin(Pi/2*d^2) = +1.5707328739572472151E-2 }
{(c - b) = +1.1427751796397653663E-8 }
{(c - b)/b = +7.2754319337507758102E-7 }
{(c - a) = -1.2497147346576779516E-19 }
{(c - a)/b = -7.9562582829926944803E-18 }
if THexDblW(x)[3] and $7FF0 >= $4340 then begin
{abs(x) >= 2^53}
s := 0.0;
c := 1.0;
end
else begin
{c, s depend on frac(x) and int(x) mod 4. This code is based on }
{W. Van Snyder: Remark on algorithm 723: Fresnel integrals, 1993.}
{http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.101.7180}
{Fortran source from http://netlib.org/toms/723}
f := abs(x);
n := int(f);
f := f - n;
g := 2.0*frac(f*int(0.5*n));
if frac(0.5*n)=0.0 then sincosPi(0.5*f*f + g, s, c)
else begin
sincosPi((0.5*f*f + f) + g, c, s);
c := -c;
end;
end;
end;
{---------------------------------------------------------------------------}
function sfd_bernoulli(n: integer): double;
{-Return the nth Bernoulli number, 0 if n<0 or odd n >= 3}
var
bn,p4: double;
m: integer;
const
bx16: array[0..8] of THexDblw = ( {Bernoulli(16*n+128)}
($C7AA,$9397,$49D6,$D78B), {-5.2500923086774131347E+113}
($DC82,$055D,$312B,$DBFC), {-1.2806926804084747554E+135}
($F740,$CDB0,$7C97,$E095), {-1.8437723552033869952E+157}
($C6C9,$5F0A,$3B07,$E554), {-1.3116736213556958091E+180}
($6528,$135D,$5994,$EA34), {-3.9876744968232205368E+203}
($ED60,$24DA,$6069,$EF33), {-4.5902296220617917542E+227}
($3B1F,$D638,$879E,$F44F), {-1.8059559586909309354E+252}
($2A28,$6304,$1403,$F984), {-2.2244891682179835734E+277}
($3856,$7CD9,$8C92,$FED2)); {-7.9502125045885251673E+302}
begin
if odd(n) or (n<0) then begin
if n=1 then sfd_bernoulli := -0.5
else sfd_bernoulli := 0.0;
end
else begin
m := n div 2;
if m<=MaxB2nSmall then sfd_bernoulli := double(B2nHex[m])
else if n>MaxBernoulli then sfd_bernoulli := PosInf_d
else begin
{When n is even, B(2n) = -2*(-1)^n*m!/(2Pi)^m*zeta(m) with m=2n. For }
{large m (e.g. m>63) zeta(m) is very close to 1 and we can derive the}
{asymptotic recursion formula B(m+1) = -m*(m+1)/(2Pi)^2 * B(m). The }
{avg. iteration count is <2, the max.rel. error < 1.9*eps_d for n=100}
m := (n - 120) div 16;
bn := double(bx16[m]);
m := 16*m + 128;
p4 := 4.0*PiSqr;
if n>m then begin
while n>m do begin
inc(m,2);
bn := bn/p4*m*(1-m);
end;
end
else begin
while m>n do begin
bn := bn/m/(1-m)*p4;
dec(m,2);
end;
end;
sfd_bernoulli := bn;
end;
end;
end;
{$ifdef debug}
{$ifdef USE_OutputDebugString}
{---------------------------------------------------------------------------}
procedure sfd_write_debug_str(const msg: sfd_debug_str);
{-Writeln or Outputdebugstr of msg}
var
ax: ansistring;
begin
if sfd_debug_output then begin
if IsConsole then writeln(msg)
else begin
ax := msg;
OutputDebugString(pchar({$ifdef D12Plus}string{$endif}(ax)));
end;
end;
end;
{$else}
{---------------------------------------------------------------------------}
procedure sfd_write_debug_str(const msg: sfd_debug_str);
{-Writeln or Outputdebugstr of msg}
begin
if sfd_debug_output then writeln(msg);
end;
{$endif}
{---------------------------------------------------------------------------}
procedure sfd_dump_diagctr;
{-writeln diagnostic counters}
var
k: integer;
begin
write('Diag ctr:');
for k:=0 to NDCTR-1 do write(k:3,':',sfd_diagctr[k]);
writeln;
end;
begin
sfd_debug_output := false;
fillchar(sfd_diagctr, sizeof(sfd_diagctr),0);
{$endif}
end.
|
unit Sample.Assets;
{$INCLUDE 'Sample.inc'}
interface
uses
System.Classes,
System.SysUtils,
System.Zip;
type
{ Static class for managing assets.
For easy deployment, all assets are stored in a single ZIP file called
assets.zip. This ZIP file is linked into the executable as a resource named
ASSETS.
For maximum portability, all file names and folder names in the ZIP file
should be in lower case.
To add the assets.zip file to your project in Delphi, go to "Project |
Resources and Images..." and add the assets.zip file and set the "Resource
identifier" to ASSETS. }
TAssets = class // static
{$REGION 'Internal Declarations'}
private class var
FStream: TResourceStream;
FZipFile: TZipFile;
public
class constructor Create;
class destructor Destroy;
{$ENDREGION 'Internal Declarations'}
public
{ Initializes the asset manager.
Must be called before calling any other methods. }
class procedure Initialize; static;
{ Loads a file into a byte array.
Parameters:
APath: the path to the file in assets.zip. If the path contains
directories, forward slashes ('/') should be used.
Returns:
A byte array containing the file data. }
class function Load(const APath: String): TBytes; static;
{ Loads a file into a RawByteString.
Parameters:
APath: the path to the file in assets.zip. If the path contains
directories, forward slashes ('/') should be used.
Returns:
A RawByteString containing the file data. }
class function LoadRawByteString(const APath: String): RawByteString; static;
end;
implementation
uses
System.Types;
{ TAssets }
class constructor TAssets.Create;
begin
FStream := nil;
FZipFile := nil;
end;
class destructor TAssets.Destroy;
begin
FZipFile.DisposeOf;
FZipFile := nil;
FStream.DisposeOf;
FStream := nil;
end;
class procedure TAssets.Initialize;
begin
if (FStream = nil) then
FStream := TResourceStream.Create(HInstance, 'ASSETS', RT_RCDATA);
if (FZipFile = nil) then
begin
FZipFile := TZipFile.Create;
FZipFile.Open(FStream, TZipMode.zmRead);
end;
end;
class function TAssets.Load(const APath: String): TBytes;
begin
Assert(Assigned(FZipFile));
FZipFile.Read(APath, Result);
end;
class function TAssets.LoadRawByteString(const APath: String): RawByteString;
var
Data: TBytes;
begin
Assert(Assigned(FZipFile));
FZipFile.Read(APath, Data);
if (Data = nil) then
Result := ''
else
begin
SetLength(Result, Length(Data));
Move(Data[0], Result[Low(RawByteString)], Length(Data));
end;
end;
end.
|
unit dec0_hw;
interface
uses {$IFDEF WINDOWS}windows,{$ENDIF}
m68000,main_engine,controls_engine,gfx_engine,rom_engine,pal_engine,
ym_2203,ym_3812,oki6295,m6502,sound_engine,hu6280,misc_functions,
deco_bac06,mcs51;
function iniciar_dec0:boolean;
implementation
const
//Robocop
robocop_rom:array[0..3] of tipo_roms=(
(n:'ep05-4.11c';l:$10000;p:0;crc:$29c35379),(n:'ep01-4.11b';l:$10000;p:$1;crc:$77507c69),
(n:'ep04-3';l:$10000;p:$20000;crc:$39181778),(n:'ep00-3';l:$10000;p:$20001;crc:$e128541f));
robocop_mcu:tipo_roms=(n:'en_24_mb7124e.a2';l:$200;p:$0;crc:$b8e2ca98);
robocop_char:array[0..1] of tipo_roms=(
(n:'ep23';l:$10000;p:0;crc:$a77e4ab1),(n:'ep22';l:$10000;p:$10000;crc:$9fbd6903));
robocop_sound:tipo_roms=(n:'ep03-3';l:$8000;p:$8000;crc:$5b164b24);
robocop_oki:tipo_roms=(n:'ep02';l:$10000;p:0;crc:$711ce46f);
robocop_tiles1:array[0..3] of tipo_roms=(
(n:'ep20';l:$10000;p:0;crc:$1d8d38b8),(n:'ep21';l:$10000;p:$10000;crc:$187929b2),
(n:'ep18';l:$10000;p:$20000;crc:$b6580b5e),(n:'ep19';l:$10000;p:$30000;crc:$9bad01c7));
robocop_tiles2:array[0..3] of tipo_roms=(
(n:'ep14';l:$8000;p:0;crc:$ca56ceda),(n:'ep15';l:$8000;p:$8000;crc:$a945269c),
(n:'ep16';l:$8000;p:$10000;crc:$e7fa4d58),(n:'ep17';l:$8000;p:$18000;crc:$84aae89d));
robocop_sprites:array[0..7] of tipo_roms=(
(n:'ep07';l:$10000;p:$00000;crc:$495d75cf),(n:'ep06';l:$8000;p:$10000;crc:$a2ae32e2),
(n:'ep11';l:$10000;p:$20000;crc:$62fa425a),(n:'ep10';l:$8000;p:$30000;crc:$cce3bd95),
(n:'ep09';l:$10000;p:$40000;crc:$11bed656),(n:'ep08';l:$8000;p:$50000;crc:$c45c7b4c),
(n:'ep13';l:$10000;p:$60000;crc:$8fca9f28),(n:'ep12';l:$8000;p:$70000;crc:$3cd1d0c3));
robocop_dip:array [0..10] of def_dip=(
(mask:$0003;name:'Coin A';number:4;dip:((dip_val:$0;dip_name:'3C 1C'),(dip_val:$1;dip_name:'2C 1C'),(dip_val:$3;dip_name:'1C 1C'),(dip_val:$2;dip_name:'1C 2C'),(),(),(),(),(),(),(),(),(),(),(),())),
(mask:$000c;name:'Coin B';number:4;dip:((dip_val:$0;dip_name:'3C 1C'),(dip_val:$4;dip_name:'2C 1C'),(dip_val:$c;dip_name:'1C 1C'),(dip_val:$8;dip_name:'1C 2C'),(),(),(),(),(),(),(),(),(),(),(),())),
(mask:$0020;name:'Demo Sounds';number:2;dip:((dip_val:$0;dip_name:'Off'),(dip_val:$20;dip_name:'On'),(),(),(),(),(),(),(),(),(),(),(),(),(),())),
(mask:$0040;name:'Flip Screen';number:2;dip:((dip_val:$40;dip_name:'Off'),(dip_val:$0;dip_name:'On'),(),(),(),(),(),(),(),(),(),(),(),(),(),())),
(mask:$0080;name:'Cabinet';number:2;dip:((dip_val:$0;dip_name:'Upright'),(dip_val:$80;dip_name:'Cocktail'),(),(),(),(),(),(),(),(),(),(),(),(),(),())),
(mask:$0300;name:'Player Energy';number:4;dip:((dip_val:$100;dip_name:'Low'),(dip_val:$300;dip_name:'Medium'),(dip_val:$200;dip_name:'High'),(dip_val:$0;dip_name:'Very High'),(),(),(),(),(),(),(),(),(),(),(),())),
(mask:$0c00;name:'Difficulty';number:4;dip:((dip_val:$800;dip_name:'Easy'),(dip_val:$c00;dip_name:'Normal'),(dip_val:$400;dip_name:'Hard'),(dip_val:$000;dip_name:'Hardest'),(),(),(),(),(),(),(),(),(),(),(),())),
(mask:$1000;name:'Allow Continue';number:2;dip:((dip_val:$1000;dip_name:'Yes'),(dip_val:$0;dip_name:'No'),(),(),(),(),(),(),(),(),(),(),(),(),(),())),
(mask:$2000;name:'Bonus Stage Energy';number:2;dip:((dip_val:$0;dip_name:'Low'),(dip_val:$2000;dip_name:'High'),(),(),(),(),(),(),(),(),(),(),(),(),(),())),
(mask:$4000;name:'Brink Time';number:2;dip:((dip_val:$4000;dip_name:'Normal'),(dip_val:$0;dip_name:'Less'),(),(),(),(),(),(),(),(),(),(),(),(),(),())),());
//Baddudes
baddudes_rom:array[0..3] of tipo_roms=(
(n:'ei04-1.3c';l:$10000;p:0;crc:$4bf158a7),(n:'ei01-1.3a';l:$10000;p:$1;crc:$74f5110c),
(n:'ei06.6c';l:$10000;p:$40000;crc:$3ff8da57),(n:'ei03.6a';l:$10000;p:$40001;crc:$f8f2bd94));
baddudes_char:array[0..1] of tipo_roms=(
(n:'ei25.15j';l:$8000;p:0;crc:$bcf59a69),(n:'ei26.16j';l:$8000;p:$8000;crc:$9aff67b8));
baddudes_mcu:tipo_roms=(n:'ei31.9a';l:$1000;p:$0;crc:$2a8745d2);
baddudes_sound:tipo_roms=(n:'ei07.8a';l:$8000;p:$8000;crc:$9fb1ef4b);
baddudes_oki:tipo_roms=(n:'ei08.2c';l:$10000;p:0;crc:$3c87463e);
baddudes_tiles1:array[0..3] of tipo_roms=(
(n:'ei18.14d';l:$10000;p:0;crc:$05cfc3e5),(n:'ei20.17d';l:$10000;p:$10000;crc:$e11e988f),
(n:'ei22.14f';l:$10000;p:$20000;crc:$b893d880),(n:'ei24.17f';l:$10000;p:$30000;crc:$6f226dda));
baddudes_tiles2:array[0..1] of tipo_roms=(
(n:'ei30.9j';l:$10000;p:$20000;crc:$982da0d1),(n:'ei28.9f';l:$10000;p:$30000;crc:$f01ebb3b));
baddudes_sprites:array[0..7] of tipo_roms=(
(n:'ei15.16c';l:$10000;p:$00000;crc:$a38a7d30),(n:'ei16.17c';l:$8000;p:$10000;crc:$17e42633),
(n:'ei11.16a';l:$10000;p:$20000;crc:$3a77326c),(n:'ei12.17a';l:$8000;p:$30000;crc:$fea2a134),
(n:'ei13.13c';l:$10000;p:$40000;crc:$e5ae2751),(n:'ei14.14c';l:$8000;p:$50000;crc:$e83c760a),
(n:'ei09.13a';l:$10000;p:$60000;crc:$6901e628),(n:'ei10.14a';l:$8000;p:$70000;crc:$eeee8a1a));
baddudes_dip:array [0..7] of def_dip=(
(mask:$0003;name:'Coin A';number:4;dip:((dip_val:$0;dip_name:'3C 1C'),(dip_val:$1;dip_name:'2C 1C'),(dip_val:$3;dip_name:'1C 1C'),(dip_val:$2;dip_name:'1C 2C'),(),(),(),(),(),(),(),(),(),(),(),())),
(mask:$000c;name:'Coin B';number:4;dip:((dip_val:$0;dip_name:'3C 1C'),(dip_val:$4;dip_name:'2C 1C'),(dip_val:$c;dip_name:'1C 1C'),(dip_val:$8;dip_name:'1C 2C'),(),(),(),(),(),(),(),(),(),(),(),())),
(mask:$0020;name:'Demo Sounds';number:2;dip:((dip_val:$0;dip_name:'Off'),(dip_val:$20;dip_name:'On'),(),(),(),(),(),(),(),(),(),(),(),(),(),())),
(mask:$0040;name:'Flip Screen';number:2;dip:((dip_val:$40;dip_name:'Off'),(dip_val:$0;dip_name:'On'),(),(),(),(),(),(),(),(),(),(),(),(),(),())),
(mask:$0300;name:'Lives';number:4;dip:((dip_val:$100;dip_name:'1'),(dip_val:$300;dip_name:'3'),(dip_val:$200;dip_name:'5'),(dip_val:$0;dip_name:'Infinite'),(),(),(),(),(),(),(),(),(),(),(),())),
(mask:$0c00;name:'Difficulty';number:4;dip:((dip_val:$800;dip_name:'Easy'),(dip_val:$c00;dip_name:'Normal'),(dip_val:$400;dip_name:'Hard'),(dip_val:$000;dip_name:'Hardest'),(),(),(),(),(),(),(),(),(),(),(),())),
(mask:$1000;name:'Allow Continue';number:2;dip:((dip_val:$1000;dip_name:'Yes'),(dip_val:$0;dip_name:'No'),(),(),(),(),(),(),(),(),(),(),(),(),(),())),());
//Hippodrome
hippo_rom:array[0..3] of tipo_roms=(
(n:'ew02';l:$10000;p:0;crc:$df0d7dc6),(n:'ew01';l:$10000;p:$1;crc:$d5670aa7),
(n:'ew05';l:$10000;p:$20000;crc:$c76d65ec),(n:'ew00';l:$10000;p:$20001;crc:$e9b427a6));
hippo_mcu:tipo_roms=(n:'ew08';l:$10000;p:$0;crc:$53010534);
hippo_char:array[0..1] of tipo_roms=(
(n:'ew14';l:$10000;p:0;crc:$71ca593d),(n:'ew13';l:$10000;p:$10000;crc:$86be5fa7));
hippo_sound:tipo_roms=(n:'ew04';l:$8000;p:$8000;crc:$9871b98d);
hippo_oki:tipo_roms=(n:'ew03';l:$10000;p:0;crc:$b606924d);
hippo_tiles1:array[0..3] of tipo_roms=(
(n:'ew19';l:$8000;p:0;crc:$6b80d7a3),(n:'ew18';l:$8000;p:$8000;crc:$78d3d764),
(n:'ew20';l:$8000;p:$10000;crc:$ce9f5de3),(n:'ew21';l:$8000;p:$18000;crc:$487a7ba2));
hippo_tiles2:array[0..3] of tipo_roms=(
(n:'ew24';l:$8000;p:0;crc:$4e1bc2a4),(n:'ew25';l:$8000;p:$8000;crc:$9eb47dfb),
(n:'ew23';l:$8000;p:$10000;crc:$9ecf479e),(n:'ew22';l:$8000;p:$18000;crc:$e55669aa));
hippo_sprites:array[0..7] of tipo_roms=(
(n:'ew15';l:$10000;p:$00000;crc:$95423914),(n:'ew16';l:$10000;p:$10000;crc:$96233177),
(n:'ew10';l:$10000;p:$20000;crc:$4c25dfe8),(n:'ew11';l:$10000;p:$30000;crc:$f2e007fc),
(n:'ew06';l:$10000;p:$40000;crc:$e4bb8199),(n:'ew07';l:$10000;p:$50000;crc:$470b6989),
(n:'ew17';l:$10000;p:$60000;crc:$8c97c757),(n:'ew12';l:$10000;p:$70000;crc:$a2d244bc));
hippo_dip:array [0..8] of def_dip=(
(mask:$0003;name:'Coin A';number:4;dip:((dip_val:$0;dip_name:'3C 1C'),(dip_val:$1;dip_name:'2C 1C'),(dip_val:$3;dip_name:'1C 1C'),(dip_val:$2;dip_name:'1C 2C'),(),(),(),(),(),(),(),(),(),(),(),())),
(mask:$000c;name:'Coin B';number:4;dip:((dip_val:$0;dip_name:'3C 1C'),(dip_val:$4;dip_name:'2C 1C'),(dip_val:$c;dip_name:'1C 1C'),(dip_val:$8;dip_name:'1C 2C'),(),(),(),(),(),(),(),(),(),(),(),())),
(mask:$0020;name:'Demo Sounds';number:2;dip:((dip_val:$0;dip_name:'Off'),(dip_val:$20;dip_name:'On'),(),(),(),(),(),(),(),(),(),(),(),(),(),())),
(mask:$0040;name:'Flip Screen';number:2;dip:((dip_val:$40;dip_name:'Off'),(dip_val:$0;dip_name:'On'),(),(),(),(),(),(),(),(),(),(),(),(),(),())),
(mask:$0300;name:'Lives';number:4;dip:((dip_val:$100;dip_name:'1'),(dip_val:$300;dip_name:'3'),(dip_val:$200;dip_name:'3'),(dip_val:$0;dip_name:'5'),(),(),(),(),(),(),(),(),(),(),(),())),
(mask:$0c00;name:'Difficulty';number:4;dip:((dip_val:$800;dip_name:'Easy'),(dip_val:$c00;dip_name:'Normal'),(dip_val:$400;dip_name:'Hard'),(dip_val:$000;dip_name:'Hardest'),(),(),(),(),(),(),(),(),(),(),(),())),
(mask:$3000;name:'Player & Enemy Energy';number:4;dip:((dip_val:$1000;dip_name:'Very Low'),(dip_val:$2000;dip_name:'Low'),(dip_val:$3000;dip_name:'Medium'),(dip_val:$0;dip_name:'High'),(),(),(),(),(),(),(),(),(),(),(),())),
(mask:$4000;name:'Enemy Power Decrease on Continue';number:2;dip:((dip_val:$4000;dip_name:'2 Dots'),(dip_val:$0;dip_name:'3 Dots'),(),(),(),(),(),(),(),(),(),(),(),(),(),())),());
//Slyspy
slyspy_rom:array[0..3] of tipo_roms=(
(n:'fa14-4.17l';l:$10000;p:0;crc:$60f16e31),(n:'fa12-4.9l';l:$10000;p:$1;crc:$b9b9fdcf),
(n:'fa15.19l';l:$10000;p:$20000;crc:$04a79266),(n:'fa13.11l';l:$10000;p:$20001;crc:$641cc4b3));
slyspy_char:array[0..1] of tipo_roms=(
(n:'fa05.11a';l:$8000;p:0;crc:$09802924),(n:'fa04.9a';l:$8000;p:$8000;crc:$ec25b895));
slyspy_sound:tipo_roms=(n:'fa10.5h';l:$10000;p:$0;crc:$dfd2ff25);
slyspy_oki:tipo_roms=(n:'fa11.11k';l:$20000;p:0;crc:$4e547bad);
slyspy_tiles1:array[0..1] of tipo_roms=(
(n:'fa07.17a';l:$10000;p:$0;crc:$e932268b),(n:'fa06.15a';l:$10000;p:$10000;crc:$c4dd38c0));
slyspy_tiles2:array[0..1] of tipo_roms=(
(n:'fa09.22a';l:$20000;p:$0;crc:$1395e9be),(n:'fa08.21a';l:$20000;p:$20000;crc:$4d7464db));
slyspy_sprites:array[0..3] of tipo_roms=(
(n:'fa01.4a';l:$20000;p:$0;crc:$99b0cd92),(n:'fa03.7a';l:$20000;p:$20000;crc:$0e7ea74d),
(n:'fa00.2a';l:$20000;p:$40000;crc:$f7df3fd7),(n:'fa02.5a';l:$20000;p:$60000;crc:$84e8da9d));
slyspy_dip:array [0..8] of def_dip=(
(mask:$0003;name:'Coin A';number:4;dip:((dip_val:$0;dip_name:'3C 1C'),(dip_val:$1;dip_name:'2C 1C'),(dip_val:$3;dip_name:'1C 1C'),(dip_val:$2;dip_name:'1C 2C'),(),(),(),(),(),(),(),(),(),(),(),())),
(mask:$000c;name:'Coin B';number:4;dip:((dip_val:$0;dip_name:'3C 1C'),(dip_val:$4;dip_name:'2C 1C'),(dip_val:$c;dip_name:'1C 1C'),(dip_val:$8;dip_name:'1C 2C'),(),(),(),(),(),(),(),(),(),(),(),())),
(mask:$0020;name:'Demo Sounds';number:2;dip:((dip_val:$0;dip_name:'Off'),(dip_val:$20;dip_name:'On'),(),(),(),(),(),(),(),(),(),(),(),(),(),())),
(mask:$0040;name:'Flip Screen';number:2;dip:((dip_val:$40;dip_name:'Off'),(dip_val:$0;dip_name:'On'),(),(),(),(),(),(),(),(),(),(),(),(),(),())),
(mask:$0080;name:'Cabinet';number:2;dip:((dip_val:$0;dip_name:'Upright'),(dip_val:$80;dip_name:'Cocktail'),(),(),(),(),(),(),(),(),(),(),(),(),(),())),
(mask:$0300;name:'Energy';number:4;dip:((dip_val:$200;dip_name:'Low - 8 bars'),(dip_val:$300;dip_name:'Medium - 10 bars'),(dip_val:$100;dip_name:'High - 12 bars'),(dip_val:$0;dip_name:'Very High - 14 bars'),(),(),(),(),(),(),(),(),(),(),(),())),
(mask:$0c00;name:'Difficulty';number:4;dip:((dip_val:$800;dip_name:'Easy'),(dip_val:$c00;dip_name:'Normal'),(dip_val:$400;dip_name:'Hard'),(dip_val:$000;dip_name:'Hardest'),(),(),(),(),(),(),(),(),(),(),(),())),
(mask:$1000;name:'Allow Continue';number:2;dip:((dip_val:$1000;dip_name:'Yes'),(dip_val:$0;dip_name:'No'),(),(),(),(),(),(),(),(),(),(),(),(),(),())),());
//Boulder Dash
bouldash_rom:array[0..5] of tipo_roms=(
(n:'fw-15-2.17l';l:$10000;p:0;crc:$ca19a967),(n:'fw-12-2.9l';l:$10000;p:$1;crc:$242bdc2a),
(n:'fw-16-2.19l';l:$10000;p:$20000;crc:$b7217265),(n:'fw-13-2.11l';l:$10000;p:$20001;crc:$19209ef4),
(n:'fw-17-2.20l';l:$10000;p:$40000;crc:$78a632a1),(n:'fw-14-2.13l';l:$10000;p:$40001;crc:$69b6112d));
bouldash_char:array[0..1] of tipo_roms=(
(n:'fn-04';l:$10000;p:0;crc:$40f5a760),(n:'fn-05';l:$10000;p:$10000;crc:$824f2168));
bouldash_sound:tipo_roms=(n:'fn-10';l:$10000;p:$0;crc:$c74106e7);
bouldash_oki:tipo_roms=(n:'fn-11';l:$10000;p:0;crc:$990fd8d9);
bouldash_tiles1:array[0..1] of tipo_roms=(
(n:'fn-07';l:$10000;p:$0;crc:$eac6a3b3),(n:'fn-06';l:$10000;p:$10000;crc:$3feee292));
bouldash_tiles2:array[0..1] of tipo_roms=(
(n:'fn-09';l:$20000;p:$0;crc:$c2b27bd2),(n:'fn-08';l:$20000;p:$20000;crc:$5ac97178));
bouldash_sprites:array[0..3] of tipo_roms=(
(n:'fn-01';l:$10000;p:$0;crc:$9333121b),(n:'fn-03';l:$10000;p:$10000;crc:$254ba60f),
(n:'fn-00';l:$10000;p:$20000;crc:$ec18d098),(n:'fn-02';l:$10000;p:$30000;crc:$4f060cba));
bouldash_dip:array [0..9] of def_dip=(
(mask:$0007;name:'Coin A';number:8;dip:((dip_val:$0;dip_name:'3C 1C'),(dip_val:$1;dip_name:'2C 1C'),(dip_val:$07;dip_name:'1C 1C'),(dip_val:$06;dip_name:'1C 2C'),(dip_val:$05;dip_name:'1C 3C'),(dip_val:$04;dip_name:'1C 4C'),(dip_val:$03;dip_name:'1C 5C'),(dip_val:$02;dip_name:'1C 6C'),(),(),(),(),(),(),(),())),
(mask:$0038;name:'Coin B';number:8;dip:((dip_val:$0;dip_name:'3C 1C'),(dip_val:$8;dip_name:'2C 1C'),(dip_val:$38;dip_name:'1C 1C'),(dip_val:$30;dip_name:'1C 2C'),(dip_val:$28;dip_name:'1C 3C'),(dip_val:$20;dip_name:'1C 4C'),(dip_val:$18;dip_name:'1C 5C'),(dip_val:$10;dip_name:'1C 6C'),(),(),(),(),(),(),(),())),
(mask:$0040;name:'Flip Screen';number:2;dip:((dip_val:$40;dip_name:'Off'),(dip_val:$0;dip_name:'On'),(),(),(),(),(),(),(),(),(),(),(),(),(),())),
(mask:$0080;name:'Cabinet';number:2;dip:((dip_val:$0;dip_name:'Upright'),(dip_val:$80;dip_name:'Cocktail'),(),(),(),(),(),(),(),(),(),(),(),(),(),())),
(mask:$0300;name:'Lives';number:4;dip:((dip_val:$0;dip_name:'2'),(dip_val:$300;dip_name:'3'),(dip_val:$200;dip_name:'4'),(dip_val:$100;dip_name:'5'),(),(),(),(),(),(),(),(),(),(),(),())),
(mask:$0c00;name:'Difficulty';number:4;dip:((dip_val:$800;dip_name:'Easy'),(dip_val:$c00;dip_name:'Normal'),(dip_val:$400;dip_name:'Hard'),(dip_val:$000;dip_name:'Hardest'),(),(),(),(),(),(),(),(),(),(),(),())),
(mask:$2000;name:'Game Change Mode';number:2;dip:((dip_val:$2000;dip_name:'Part 1'),(dip_val:$0;dip_name:'Part 2'),(),(),(),(),(),(),(),(),(),(),(),(),(),())),
(mask:$4000;name:'Allow Continue';number:2;dip:((dip_val:$0;dip_name:'No'),(dip_val:$4000;dip_name:'Yes'),(),(),(),(),(),(),(),(),(),(),(),(),(),())),
(mask:$8000;name:'Demo Sounds';number:2;dip:((dip_val:$8000;dip_name:'Off'),(dip_val:$0;dip_name:'On'),(),(),(),(),(),(),(),(),(),(),(),(),(),())),());
var
rom:array[0..$2ffff] of word;
ram1:array[0..$fff] of word;
ram2:array[0..$1fff] of word;
sound_latch,prioridad,hippodrm_lsb,slyspy_state,slyspy_sound_state:byte;
//HU 6280
mcu_ram,mcu_shared_ram:array[0..$1fff] of byte;
//8751
i8751_return,i8751_command:word;
i8751_ports:array[0..3] of byte;
procedure update_video_robocop;
var
trans:byte;
begin
trans:=(prioridad and $4) shl 1;
if (prioridad and 1)<>0 then begin
bac06_0.tile_2.update_pf(1,false,false);
bac06_0.tile_3.update_pf(2,true,false);
//Pri pant
bac06_0.tile_2.show_pf;
if (prioridad and $02)<>0 then bac06_0.draw_sprites($8,trans,3);
bac06_0.tile_3.show_pf;
end else begin //invertidas
bac06_0.tile_3.update_pf(2,false,false);
bac06_0.tile_2.update_pf(1,true,false);
//Pri pant
bac06_0.tile_3.show_pf;
if (prioridad and $02)<>0 then bac06_0.draw_sprites($8,trans,3);
bac06_0.tile_2.show_pf;
end;
if (prioridad and $02)<>0 then bac06_0.draw_sprites($8,trans xor $08,3)
else bac06_0.draw_sprites(0,0,3);
//chars
bac06_0.tile_1.update_pf(0,true,false);
bac06_0.tile_1.show_pf;
actualiza_trozo_final(0,8,256,240,7);
end;
procedure update_video_baddudes;
begin
if (prioridad and 1)=0 then begin
bac06_0.tile_2.update_pf(1,false,true);
bac06_0.tile_3.update_pf(2,true,true);
//Pri pant
bac06_0.tile_2.show_pf;
bac06_0.tile_3.show_pf;
//prioridades
if (prioridad and $2)<>0 then bac06_0.tile_2.show_pf_pri;
bac06_0.draw_sprites(0,0,3);
if (prioridad and $4)<>0 then bac06_0.tile_3.show_pf_pri;
end else begin //invertidas
bac06_0.tile_3.update_pf(2,false,true);
bac06_0.tile_2.update_pf(1,true,true);
//Pri pant
bac06_0.tile_3.show_pf;
bac06_0.tile_2.show_pf;
//prioridades
if (prioridad and $2)<>0 then bac06_0.tile_3.show_pf_pri;
bac06_0.draw_sprites(0,0,3);
if (prioridad and $4)<>0 then bac06_0.tile_2.show_pf_pri;
end;
//chars
bac06_0.tile_1.update_pf(0,true,false);
bac06_0.tile_1.show_pf;
actualiza_trozo_final(0,8,256,240,7);
end;
procedure update_video_hippo;
begin
if (prioridad and 1)<>0 then begin
bac06_0.tile_2.update_pf(1,false,false);
bac06_0.tile_3.update_pf(2,true,false);
//Pri pant
bac06_0.tile_2.show_pf;
bac06_0.tile_3.show_pf;
end else begin //invertidas
bac06_0.tile_3.update_pf(2,false,false);
bac06_0.tile_2.update_pf(1,true,false);
//Pri pant
bac06_0.tile_3.show_pf;
bac06_0.tile_2.show_pf;
end;
bac06_0.draw_sprites(0,0,3);
//chars
bac06_0.tile_1.update_pf(0,true,false);
bac06_0.tile_1.show_pf;
actualiza_trozo_final(0,8,256,240,7);
end;
procedure update_video_slyspy;
begin
bac06_0.tile_3.update_pf(2,false,false);
bac06_0.tile_3.show_pf;
bac06_0.tile_2.update_pf(1,true,true);
bac06_0.tile_2.show_pf;
bac06_0.draw_sprites(0,0,3);
if (prioridad and $80)<>0 then bac06_0.tile_2.show_pf_pri;
bac06_0.tile_1.update_pf(0,true,false);
bac06_0.tile_1.show_pf;
actualiza_trozo_final(0,8,256,240,7);
end;
procedure eventos_dec0;
begin
if event.arcade then begin
//P1+P2
if arcade_input.up[0] then marcade.in0:=(marcade.in0 and $fffe) else marcade.in0:=(marcade.in0 or $1);
if arcade_input.down[0] then marcade.in0:=(marcade.in0 and $fffd) else marcade.in0:=(marcade.in0 or $2);
if arcade_input.left[0] then marcade.in0:=(marcade.in0 and $fffb) else marcade.in0:=(marcade.in0 or $4);
if arcade_input.right[0] then marcade.in0:=(marcade.in0 and $fff7) else marcade.in0:=(marcade.in0 or $8);
if arcade_input.but0[0] then marcade.in0:=(marcade.in0 and $ffef) else marcade.in0:=(marcade.in0 or $10);
if arcade_input.but1[0] then marcade.in0:=(marcade.in0 and $ffdf) else marcade.in0:=(marcade.in0 or $20);
if arcade_input.but2[0] then marcade.in0:=(marcade.in0 and $ffbf) else marcade.in0:=(marcade.in0 or $40);
if arcade_input.but3[0] then marcade.in0:=(marcade.in0 and $ff7f) else marcade.in0:=(marcade.in0 or $80);
if arcade_input.up[1] then marcade.in0:=(marcade.in0 and $feff) else marcade.in0:=(marcade.in0 or $100);
if arcade_input.down[1] then marcade.in0:=(marcade.in0 and $fdff) else marcade.in0:=(marcade.in0 or $200);
if arcade_input.left[1] then marcade.in0:=(marcade.in0 and $fbff) else marcade.in0:=(marcade.in0 or $400);
if arcade_input.right[1] then marcade.in0:=(marcade.in0 and $f7ff) else marcade.in0:=(marcade.in0 or $800);
if arcade_input.but0[1] then marcade.in0:=(marcade.in0 and $efff) else marcade.in0:=(marcade.in0 or $1000);
if arcade_input.but1[1] then marcade.in0:=(marcade.in0 and $dfff) else marcade.in0:=(marcade.in0 or $2000);
if arcade_input.but2[1] then marcade.in0:=(marcade.in0 and $bfff) else marcade.in0:=(marcade.in0 or $4000);
if arcade_input.but3[1] then marcade.in0:=(marcade.in0 and $7fff) else marcade.in0:=(marcade.in0 or $8000);
//SYSTEM
if arcade_input.but4[0] then marcade.in1:=(marcade.in1 and $fffe) else marcade.in1:=(marcade.in1 or $1);
if arcade_input.but4[1] then marcade.in1:=(marcade.in1 and $fffd) else marcade.in1:=(marcade.in1 or $2);
if arcade_input.start[0] then marcade.in1:=(marcade.in1 and $fffb) else marcade.in1:=(marcade.in1 or $4);
if arcade_input.start[1] then marcade.in1:=(marcade.in1 and $fff7) else marcade.in1:=(marcade.in1 or $8);
if arcade_input.coin[0] then marcade.in1:=(marcade.in1 and $ffef) else marcade.in1:=(marcade.in1 or $10);
if arcade_input.coin[1] then marcade.in1:=(marcade.in1 and $ffdf) else marcade.in1:=(marcade.in1 or $20);
end;
end;
procedure eventos_dec1;
begin
if event.arcade then begin
//P1+P2
if arcade_input.up[0] then marcade.in0:=(marcade.in0 and $fffe) else marcade.in0:=(marcade.in0 or $1);
if arcade_input.down[0] then marcade.in0:=(marcade.in0 and $fffd) else marcade.in0:=(marcade.in0 or $2);
if arcade_input.left[0] then marcade.in0:=(marcade.in0 and $fffb) else marcade.in0:=(marcade.in0 or $4);
if arcade_input.right[0] then marcade.in0:=(marcade.in0 and $fff7) else marcade.in0:=(marcade.in0 or $8);
if arcade_input.but0[0] then marcade.in0:=(marcade.in0 and $ffef) else marcade.in0:=(marcade.in0 or $10);
if arcade_input.but1[0] then marcade.in0:=(marcade.in0 and $ffdf) else marcade.in0:=(marcade.in0 or $20);
if arcade_input.but2[0] then marcade.in0:=(marcade.in0 and $ffbf) else marcade.in0:=(marcade.in0 or $40);
if arcade_input.start[0] then marcade.in0:=(marcade.in0 and $ff7f) else marcade.in0:=(marcade.in0 or $80);
if arcade_input.up[1] then marcade.in0:=(marcade.in0 and $feff) else marcade.in0:=(marcade.in0 or $100);
if arcade_input.down[1] then marcade.in0:=(marcade.in0 and $fdff) else marcade.in0:=(marcade.in0 or $200);
if arcade_input.left[1] then marcade.in0:=(marcade.in0 and $fbff) else marcade.in0:=(marcade.in0 or $400);
if arcade_input.right[1] then marcade.in0:=(marcade.in0 and $f7ff) else marcade.in0:=(marcade.in0 or $800);
if arcade_input.but0[1] then marcade.in0:=(marcade.in0 and $efff) else marcade.in0:=(marcade.in0 or $1000);
if arcade_input.but1[1] then marcade.in0:=(marcade.in0 and $dfff) else marcade.in0:=(marcade.in0 or $2000);
if arcade_input.but2[1] then marcade.in0:=(marcade.in0 and $bfff) else marcade.in0:=(marcade.in0 or $4000);
if arcade_input.start[1] then marcade.in0:=(marcade.in0 and $7eff) else marcade.in0:=(marcade.in0 or $8000);
//SYSTEM
if arcade_input.coin[0] then marcade.in1:=(marcade.in1 and $fffe) else marcade.in1:=(marcade.in1 or $1);
if arcade_input.coin[1] then marcade.in1:=(marcade.in1 and $fffd) else marcade.in1:=(marcade.in1 or $2);
end;
end;
procedure baddudes_principal;
var
frame_m,frame_s,frame_mcu:single;
f:word;
begin
init_controls(false,false,false,true);
frame_m:=m68000_0.tframes;
frame_s:=m6502_0.tframes;
frame_mcu:=mcs51_0.tframes;
while EmuStatus=EsRuning do begin
for f:=0 to 271 do begin
m68000_0.run(frame_m);
frame_m:=frame_m+m68000_0.tframes-m68000_0.contador;
m6502_0.run(frame_s);
frame_s:=frame_s+m6502_0.tframes-m6502_0.contador;
mcs51_0.run(frame_mcu);
frame_mcu:=frame_mcu+mcs51_0.tframes-mcs51_0.contador;
case f of
7:marcade.in1:=marcade.in1 and $7f;
247:begin
m68000_0.irq[6]:=HOLD_LINE;
update_video_baddudes;
marcade.in1:=marcade.in1 or $80;
end;
end;
end;
eventos_dec0;
video_sync;
end;
end;
procedure hippodrome_principal;
var
frame_m,frame_s,frame_mcu:single;
f:word;
begin
init_controls(false,false,false,true);
frame_m:=m68000_0.tframes;
frame_s:=m6502_0.tframes;
frame_mcu:=h6280_0.tframes;
while EmuStatus=EsRuning do begin
for f:=0 to 271 do begin
m68000_0.run(frame_m);
frame_m:=frame_m+m68000_0.tframes-m68000_0.contador;
m6502_0.run(frame_s);
frame_s:=frame_s+m6502_0.tframes-m6502_0.contador;
h6280_0.run(frame_mcu);
frame_mcu:=frame_mcu+h6280_0.tframes-h6280_0.contador;
case f of
7:marcade.in1:=marcade.in1 and $7f;
247:begin
m68000_0.irq[6]:=HOLD_LINE;
h6280_0.set_irq_line(0,HOLD_LINE);
update_video_hippo;
marcade.in1:=marcade.in1 or $80;
end;
end;
end;
eventos_dec0;
video_sync;
end;
end;
procedure robocop_principal;
var
frame_m,frame_s,frame_mcu:single;
f:word;
begin
init_controls(false,false,false,true);
frame_m:=m68000_0.tframes;
frame_s:=m6502_0.tframes;
frame_mcu:=h6280_0.tframes;
while EmuStatus=EsRuning do begin
for f:=0 to 271 do begin
m68000_0.run(frame_m);
frame_m:=frame_m+m68000_0.tframes-m68000_0.contador;
m6502_0.run(frame_s);
frame_s:=frame_s+m6502_0.tframes-m6502_0.contador;
h6280_0.run(frame_mcu);
frame_mcu:=frame_mcu+h6280_0.tframes-h6280_0.contador;
case f of
7:marcade.in1:=marcade.in1 and $7f;
247:begin
m68000_0.irq[6]:=HOLD_LINE;
update_video_robocop;
marcade.in1:=marcade.in1 or $80;
end;
end;
end;
eventos_dec0;
video_sync;
end;
end;
procedure slyspy_principal;
var
frame_m,frame_s:single;
f:word;
begin
init_controls(false,false,false,true);
frame_m:=m68000_0.tframes;
frame_s:=h6280_0.tframes;
while EmuStatus=EsRuning do begin
for f:=0 to 271 do begin
m68000_0.run(frame_m);
frame_m:=frame_m+m68000_0.tframes-m68000_0.contador;
h6280_0.run(frame_s);
frame_s:=frame_s+h6280_0.tframes-h6280_0.contador;
case f of
7:marcade.in1:=marcade.in1 and $f7;
247:begin
m68000_0.irq[6]:=HOLD_LINE;
update_video_slyspy;
marcade.in1:=marcade.in1 or 8;
end;
end;
end;
eventos_dec1;
video_sync;
end;
end;
procedure cambiar_color(numero:word);
var
color:tcolor;
begin
color.r:=buffer_paleta[numero] and $ff;
color.g:=buffer_paleta[numero] shr 8;
color.b:=buffer_paleta[$400+numero] and $ff;
set_pal_color(color,numero);
case numero of
$000..$0ff:bac06_0.tile_1.buffer_color[numero shr 4]:=true;
$200..$2ff:bac06_0.tile_2.buffer_color[(numero shr 4) and $f]:=true;
$300..$3ff:bac06_0.tile_3.buffer_color[(numero shr 4) and $f]:=true;
end;
end;
function dec0_getword(direccion:dword):word;
begin
case direccion of
$0..$5ffff:dec0_getword:=rom[direccion shr 1];
$180000..$180fff:dec0_getword:=mcu_shared_ram[(direccion and $fff) shr 1];
$242000..$24207f:dec0_getword:=bac06_0.tile_1.colscroll[(direccion and $7f) shr 1];
$242400..$2427ff:dec0_getword:=bac06_0.tile_1.rowscroll[(direccion and $3ff) shr 1];
$242800..$243fff:dec0_getword:=ram1[(direccion-$242800) shr 1];
$244000..$245fff:dec0_getword:=bac06_0.tile_1.data[(direccion and $1fff) shr 1];
$248000..$24807f:dec0_getword:=bac06_0.tile_2.colscroll[(direccion and $7f) shr 1];
$248400..$2487ff:dec0_getword:=bac06_0.tile_2.rowscroll[(direccion and $3ff) shr 1];
$24a000..$24a7ff:dec0_getword:=bac06_0.tile_2.data[(direccion and $7ff) shr 1];
$24c800..$24c87f:dec0_getword:=bac06_0.tile_3.colscroll[(direccion and $7f) shr 1];
$24cc00..$24cfff:dec0_getword:=bac06_0.tile_3.rowscroll[(direccion and $3ff) shr 1];
$24d000..$24d7ff:dec0_getword:=bac06_0.tile_3.data[(direccion and $7ff) shr 1];
$30c000:dec0_getword:=marcade.in0;
$30c002:dec0_getword:=marcade.in1;
$30c004:dec0_getword:=marcade.dswa;
$30c006:dec0_getword:=$ffff;
$30c008:dec0_getword:=i8751_return;
$310000..$3107ff:dec0_getword:=buffer_paleta[(direccion and $7ff) shr 1];
$314000..$3147ff:dec0_getword:=buffer_paleta[((direccion and $7ff) shr 1)+$400];
$ff8000..$ffbfff:dec0_getword:=ram2[(direccion and $3fff) shr 1];
$ffc000..$ffcfff:dec0_getword:=buffer_sprites_w[(direccion and $7ff) shr 1];
end;
end;
procedure dec0_putword(direccion:dword;valor:word);
begin
case direccion of
0..$5ffff:; //ROM
$180000..$180fff:begin
mcu_shared_ram[(direccion and $fff) shr 1]:=valor and $ff;
if ((direccion and $fff)=$ffe) then h6280_0.set_irq_line(0,HOLD_LINE);
end;
$240000..$240007:bac06_0.tile_1.change_control0((direccion and 7) shr 1,valor);
$240010..$240017:bac06_0.tile_1.change_control1((direccion and 7) shr 1,valor);
$242000..$24207f:bac06_0.tile_1.colscroll[(direccion and $7f) shr 1]:=valor;
$242400..$2427ff:bac06_0.tile_1.rowscroll[(direccion and $3ff) shr 1]:=valor;
$242800..$243fff:ram1[(direccion-$242800) shr 1]:=valor;
$244000..$245fff:if bac06_0.tile_1.data[(direccion and $1fff) shr 1]<>valor then begin
bac06_0.tile_1.data[(direccion and $1fff) shr 1]:=valor;
bac06_0.tile_1.buffer[(direccion and $1fff) shr 1]:=true;
end;
$246000..$246007:bac06_0.tile_2.change_control0((direccion and 7) shr 1,valor);
$246010..$246017:bac06_0.tile_2.change_control1((direccion and 7) shr 1,valor);
$248000..$24807f:bac06_0.tile_2.colscroll[(direccion and $7f) shr 1]:=valor;
$248400..$2487ff:bac06_0.tile_2.rowscroll[(direccion and $3ff) shr 1]:=valor;
$24a000..$24a7ff:if bac06_0.tile_2.data[(direccion and $7ff) shr 1]<>valor then begin
bac06_0.tile_2.data[(direccion and $7ff) shr 1]:=valor;
bac06_0.tile_2.buffer[(direccion and $7ff) shr 1]:=true;
end;
$24c000..$24c007:bac06_0.tile_3.change_control0((direccion and 7) shr 1,valor);
$24c010..$24c017:bac06_0.tile_3.change_control1((direccion and 7) shr 1,valor);
$24c800..$24c87f:bac06_0.tile_3.colscroll[(direccion and $7f) shr 1]:=valor;
$24cc00..$24cfff:bac06_0.tile_3.rowscroll[(direccion and $3ff) shr 1]:=valor;
$24d000..$24d7ff:if bac06_0.tile_3.data[(direccion and $7ff) shr 1]<>valor then begin
bac06_0.tile_3.data[(direccion and $7ff) shr 1]:=valor;
bac06_0.tile_3.buffer[(direccion and $7ff) shr 1]:=true;
end;
$30c010..$30c01f:case (direccion and $f) of
0:if prioridad<>(valor and $ff) then begin
prioridad:=valor and $ff;
fillchar(bac06_0.tile_2.buffer,$1000,1);
fillchar(bac06_0.tile_3.buffer,$1000,1);
end;
2:bac06_0.update_sprite_data(@buffer_sprites_w);
4:begin
sound_latch:=valor and $ff;
m6502_0.change_nmi(PULSE_LINE);
end;
6:begin
i8751_command:=valor;
if (i8751_ports[2] and 8)<>0 then mcs51_0.change_irq1(ASSERT_LINE);
end;
$e:begin
i8751_command:=0;
i8751_return:=0;
end;
end;
$310000..$3107ff:if buffer_paleta[(direccion and $7ff) shr 1]<>valor then begin
buffer_paleta[(direccion and $7ff) shr 1]:=valor;
cambiar_color((direccion and $7ff) shr 1);
end;
$314000..$3147ff:if buffer_paleta[((direccion and $7ff) shr 1)+$400]<>valor then begin
buffer_paleta[((direccion and $7ff) shr 1)+$400]:=valor;
cambiar_color((direccion and $7ff) shr 1);
end;
$ff8000..$ffbfff:ram2[(direccion and $3fff) shr 1]:=valor;
$ffc000..$ffcfff:buffer_sprites_w[(direccion and $7ff) shr 1]:=valor;
end;
end;
function dec0_snd_getbyte(direccion:word):byte;
begin
case direccion of
0..$7ff,$8000..$ffff:dec0_snd_getbyte:=mem_snd[direccion];
$3000:dec0_snd_getbyte:=sound_latch;
$3800:dec0_snd_getbyte:=oki_6295_0.read;
end;
end;
procedure dec0_snd_putbyte(direccion:word;valor:byte);
begin
case direccion of
0..$7ff:mem_snd[direccion]:=valor;
$800:ym2203_0.Control(valor);
$801:ym2203_0.Write(valor);
$1000:ym3812_0.control(valor);
$1001:ym3812_0.write(valor);
$3800:oki_6295_0.write(valor);
$8000..$ffff:; //ROM
end;
end;
procedure dec0_sound_update;
begin
ym3812_0.update;
ym2203_0.Update;
oki_6295_0.update;
end;
procedure snd_irq(irqstate:byte);
begin
m6502_0.change_irq(irqstate);
end;
procedure slyspy_snd_irq(irqstate:byte);
begin
h6280_0.set_irq_line(1,irqstate);
end;
function in_port1:byte;
begin
in_port1:=$ff;
end;
function in_port0:byte;
var
res:byte;
begin
res:=$ff;
// P0 connected to latches
if (i8751_ports[2] and $10)=0 then res:=res and (i8751_command shr 8);
if (i8751_ports[2] and $20)=0 then res:=res and (i8751_command and $ff);
in_port0:=res;
end;
procedure out_port0(valor:byte);
begin
i8751_ports[0]:=valor;
end;
procedure out_port1(valor:byte);
begin
i8751_ports[1]:=valor;
end;
procedure out_port3(valor:byte);
begin
i8751_ports[3]:=valor;
end;
procedure out_port2(valor:byte);
begin
if (((valor and 4)=0) and ((i8751_ports[2] and 4)<>0)) then m68000_0.irq[5]:=HOLD_LINE;
if (valor and 8)=0 then mcs51_0.change_irq1(CLEAR_LINE);
if (((valor and $40)<>0) and ((i8751_ports[2] and $40)=0)) then
i8751_return:=(i8751_return and $ff00) or i8751_ports[0];
if (((valor and $80)<>0) and ((i8751_ports[2] and $80)=0)) then
i8751_return:=(i8751_return and $00ff) or (i8751_ports[0] shl 8);
i8751_ports[2]:=valor;
end;
//Robocop
function robocop_mcu_getbyte(direccion:dword):byte;
begin
case direccion of
$1e00..$1fff:robocop_mcu_getbyte:=mem_misc[direccion and $1ff];
$1f0000..$1f1fff:robocop_mcu_getbyte:=mcu_ram[direccion and $1fff];
$1f2000..$1f3fff:robocop_mcu_getbyte:=mcu_shared_ram[direccion and $1fff];
end;
end;
procedure robocop_mcu_putbyte(direccion:dword;valor:byte);
begin
case direccion of
0..$ffff:; //ROM
$1f0000..$1f1fff:mcu_ram[direccion and $1fff]:=valor;
$1f2000..$1f3fff:mcu_shared_ram[direccion and $1fff]:=valor;
$1ff400..$1ff403:h6280_0.irq_status_w(direccion and $3,valor);
end;
end;
//Hippodrome
function hippo_mcu_getbyte(direccion:dword):byte;
var
tempw:word;
begin
case direccion of
0..$ffff:hippo_mcu_getbyte:=mem_misc[direccion];
$180000..$1800ff:hippo_mcu_getbyte:=mcu_shared_ram[direccion and $ff];
$1807ff:hippo_mcu_getbyte:=$ff;
$1d0000..$1d00ff:case hippodrm_lsb of //protecction
$45:hippo_mcu_getbyte:=$4e;
$92:hippo_mcu_getbyte:=$15;
end;
$1a1000..$1a17ff:begin
tempw:=bac06_0.tile_3.data[(direccion and $7ff) shr 1];
if (direccion and 1)<>0 then hippo_mcu_getbyte:=tempw shr 8
else hippo_mcu_getbyte:=tempw;
end;
$1f0000..$1f1fff:hippo_mcu_getbyte:=mcu_ram[direccion and $1fff];
$1ff402..$1ff403:hippo_mcu_getbyte:=marcade.in1 shr 7;
end;
end;
procedure hippo_mcu_putbyte(direccion:dword;valor:byte);
var
tempw:word;
begin
case direccion of
0..$ffff:; //ROM
$180000..$1800ff:mcu_shared_ram[direccion and $ff]:=valor;
$1a0000..$1a0007:begin
if (direccion and 1)<>0 then tempw:=(bac06_0.tile_3.control_0[(direccion and 7) shr 1] and $00ff) or (valor shl 8)
else tempw:=(bac06_0.tile_3.control_0[(direccion and 7) shr 1] and $ff00) or valor;
bac06_0.tile_3.change_control0((direccion and 7) shr 1,tempw);
end;
$1a0010..$1a001f:begin
if (direccion and 1)<>0 then tempw:=(bac06_0.tile_3.control_1[(direccion and 7) shr 1] and $00ff) or (valor shl 8)
else tempw:=(bac06_0.tile_3.control_1[(direccion and 7) shr 1] and $ff00) or valor;
bac06_0.tile_3.change_control1((direccion and 7) shr 1,tempw);
end;
$1a1000..$1a17ff:begin
if (direccion and 1)<>0 then tempw:=(bac06_0.tile_3.data[(direccion and $7ff) shr 1] and $00ff) or (valor shl 8)
else tempw:=(bac06_0.tile_3.data[(direccion and $7ff) shr 1] and $ff00) or valor;
if bac06_0.tile_3.data[(direccion and $7ff) shr 1]<>tempw then begin
bac06_0.tile_3.data[(direccion and $7ff) shr 1]:=tempw;
bac06_0.tile_3.buffer[(direccion and $7ff) shr 1]:=true;
end;
end;
$1d0000..$1d00ff:hippodrm_lsb:=valor;
$1f0000..$1f1fff:mcu_ram[direccion and $1fff]:=valor;
$1ff400..$1ff403:h6280_0.irq_status_w(direccion and $3,valor);
end;
end;
//Sly spy
procedure cambiar_color_dec1(numero:word);
var
color:tcolor;
begin
color.r:=pal4bit(buffer_paleta[numero]);
color.g:=pal4bit(buffer_paleta[numero] shr 4);
color.b:=pal4bit(buffer_paleta[numero] shr 8);
set_pal_color(color,numero);
case numero of
$000..$0ff:bac06_0.tile_1.buffer_color[numero shr 4]:=true;
$200..$2ff:bac06_0.tile_2.buffer_color[(numero shr 4) and $f]:=true;
$300..$3ff:bac06_0.tile_3.buffer_color[(numero shr 4) and $f]:=true;
end;
end;
function slyspy_getword(direccion:dword):word;
begin
case direccion of
$0..$5ffff:slyspy_getword:=rom[direccion shr 1];
$240000..$24ffff:case ((direccion and $ffff) or (slyspy_state*$10000)) of
$4000,$14000,$24000,$34000:slyspy_state:=(slyspy_state+1) and 3;
end;
$300800..$30087f:slyspy_getword:=bac06_0.tile_3.colscroll[(direccion and $7f) shr 1];
$300c00..$300fff:slyspy_getword:=bac06_0.tile_3.rowscroll[(direccion and $3ff) shr 1];
$301000..$3017ff:slyspy_getword:=bac06_0.tile_3.data[(direccion and $7ff) shr 1];
$304000..$307fff:slyspy_getword:=ram2[(direccion and $3fff) shr 1];
$308000..$3087ff:slyspy_getword:=buffer_sprites_w[(direccion and $7ff) shr 1];
$310000..$3107ff:slyspy_getword:=buffer_paleta[(direccion and $7ff) shr 1];
$314008..$31400f:case ((direccion and 7) shr 1) of
0:slyspy_getword:=marcade.dswa;
1:slyspy_getword:=marcade.in0;
2:slyspy_getword:=marcade.in1;
3:slyspy_getword:=$ffff;
end;
$31c000..$31c00f:case (direccion and $e) of
0,4:slyspy_getword:=0;
2:slyspy_getword:=$13;
6:slyspy_getword:=2;
$c:slyspy_getword:=ram2[$2028 shr 1] shr 8;
end;
end;
end;
procedure slyspy_putword(direccion:dword;valor:word);
var
tempw:word;
begin
case direccion of
0..$5ffff:; //ROM
$240000..$24ffff:case ((direccion and $ffff) or (slyspy_state*$10000)) of
$a000,$1a000,$2a000,$3a000:slyspy_state:=0;
//State 0
$0..$7:begin
if m68000_0.write_8bits_lo_dir then tempw:=(bac06_0.tile_2.control_0[(direccion and 7) shr 1] and $ff) or (valor and $ff00)
else if m68000_0.write_8bits_hi_dir then tempw:=(bac06_0.tile_2.control_0[(direccion and 7) shr 1] and $ff00) or (valor and $ff)
else tempw:=valor;
bac06_0.tile_2.change_control0((direccion and 7) shr 1,tempw);
end;
$10..$17:begin
if m68000_0.write_8bits_lo_dir then tempw:=(bac06_0.tile_2.control_1[(direccion and 7) shr 1] and $ff) or (valor and $ff00)
else if m68000_0.write_8bits_hi_dir then tempw:=(bac06_0.tile_2.control_1[(direccion and 7) shr 1] and $ff00) or (valor and $ff)
else tempw:=valor;
bac06_0.tile_2.change_control1((direccion and 7) shr 1,tempw,true);
end;
$2000..$207f:bac06_0.tile_2.colscroll[(direccion and $7f) shr 1]:=valor;
$2400..$27ff:bac06_0.tile_2.rowscroll[(direccion and $3ff) shr 1]:=valor;
$6000..$7fff:if bac06_0.tile_2.data[(direccion and $1fff) shr 1]<>valor then begin
bac06_0.tile_2.data[(direccion and $1fff) shr 1]:=valor;
bac06_0.tile_2.buffer[(direccion and $1fff) shr 1]:=true;
end;
$8000..$8007:begin
if m68000_0.write_8bits_lo_dir then tempw:=(bac06_0.tile_1.control_0[(direccion and 7) shr 1] and $ff) or (valor and $ff00)
else if m68000_0.write_8bits_hi_dir then tempw:=(bac06_0.tile_1.control_0[(direccion and 7) shr 1] and $ff00) or (valor and $ff)
else tempw:=valor;
bac06_0.tile_1.change_control0((direccion and 7) shr 1,tempw);
end;
$8010..$8017:begin
if m68000_0.write_8bits_lo_dir then tempw:=(bac06_0.tile_1.control_1[(direccion and 7) shr 1] and $ff) or (valor and $ff00)
else if m68000_0.write_8bits_hi_dir then tempw:=(bac06_0.tile_1.control_1[(direccion and 7) shr 1] and $ff00) or (valor and $ff)
else tempw:=valor;
bac06_0.tile_1.change_control1((direccion and 7) shr 1,tempw);
end;
$c000..$c07f:bac06_0.tile_1.colscroll[(direccion and $7f) shr 1]:=valor;
$c400..$c7ff:bac06_0.tile_1.rowscroll[(direccion and $3ff) shr 1]:=valor;
$e000..$ffff:begin
if m68000_0.write_8bits_lo_dir then tempw:=(bac06_0.tile_1.data[(direccion and $1fff) shr 1] and $ff) or (valor and $ff00)
else if m68000_0.write_8bits_hi_dir then tempw:=(bac06_0.tile_1.data[(direccion and $1fff) shr 1] and $ff00) or (valor and $ff)
else tempw:=valor;
if bac06_0.tile_1.data[(direccion and $1fff) shr 1]<>tempw then begin
bac06_0.tile_1.data[(direccion and $1fff) shr 1]:=tempw;
bac06_0.tile_1.buffer[(direccion and $1fff) shr 1]:=true;
end;
end;
//State 1
$18000..$19fff:begin
if m68000_0.write_8bits_lo_dir then tempw:=(bac06_0.tile_1.data[(direccion and $1fff) shr 1] and $ff) or (valor and $ff00)
else if m68000_0.write_8bits_hi_dir then tempw:=(bac06_0.tile_1.data[(direccion and $1fff) shr 1] and $ff00) or (valor and $ff)
else tempw:=valor;
if bac06_0.tile_1.data[(direccion and $1fff) shr 1]<>tempw then begin
bac06_0.tile_1.data[(direccion and $1fff) shr 1]:=tempw;
bac06_0.tile_1.buffer[(direccion and $1fff) shr 1]:=true;
end;
end;
$1c000..$1dfff:if bac06_0.tile_2.data[(direccion and $1fff) shr 1]<>valor then begin
bac06_0.tile_2.data[(direccion and $1fff) shr 1]:=valor;
bac06_0.tile_2.buffer[(direccion and $1fff) shr 1]:=true;
end;
// State 2
$20000..$21fff:if bac06_0.tile_2.data[(direccion and $1fff) shr 1]<>valor then begin
bac06_0.tile_2.data[(direccion and $1fff) shr 1]:=valor;
bac06_0.tile_2.buffer[(direccion and $1fff) shr 1]:=true;
end;
$22000..$23fff:begin
if m68000_0.write_8bits_lo_dir then tempw:=(bac06_0.tile_1.data[(direccion and $1fff) shr 1] and $ff) or (valor and $ff00)
else if m68000_0.write_8bits_hi_dir then tempw:=(bac06_0.tile_1.data[(direccion and $1fff) shr 1] and $ff00) or (valor and $ff)
else tempw:=valor;
if bac06_0.tile_1.data[(direccion and $1fff) shr 1]<>tempw then begin
bac06_0.tile_1.data[(direccion and $1fff) shr 1]:=tempw;
bac06_0.tile_1.buffer[(direccion and $1fff) shr 1]:=true;
end;
end;
$2e000..$2ffff:begin
if m68000_0.write_8bits_lo_dir then tempw:=(bac06_0.tile_1.data[(direccion and $1fff) shr 1] and $ff) or (valor and $ff00)
else if m68000_0.write_8bits_hi_dir then tempw:=(bac06_0.tile_1.data[(direccion and $1fff) shr 1] and $ff00) or (valor and $ff)
else tempw:=valor;
if bac06_0.tile_1.data[(direccion and $1fff) shr 1]<>tempw then begin
bac06_0.tile_1.data[(direccion and $1fff) shr 1]:=tempw;
bac06_0.tile_1.buffer[(direccion and $1fff) shr 1]:=true;
end;
end;
// State 3
$30000..$31fff:begin
if m68000_0.write_8bits_lo_dir then tempw:=(bac06_0.tile_1.data[(direccion and $1fff) shr 1] and $ff) or (valor and $ff00)
else if m68000_0.write_8bits_hi_dir then tempw:=(bac06_0.tile_1.data[(direccion and $1fff) shr 1] and $ff00) or (valor and $ff)
else tempw:=valor;
if bac06_0.tile_1.data[(direccion and $1fff) shr 1]<>tempw then begin
bac06_0.tile_1.data[(direccion and $1fff) shr 1]:=tempw;
bac06_0.tile_1.buffer[(direccion and $1fff) shr 1]:=true;
end;
end;
$38000..$39fff:if bac06_0.tile_2.data[(direccion and $1fff) shr 1]<>valor then begin
bac06_0.tile_2.data[(direccion and $1fff) shr 1]:=valor;
bac06_0.tile_2.buffer[(direccion and $1fff) shr 1]:=true;
end;
end;
$300000..$300007:bac06_0.tile_3.change_control0((direccion and 7) shr 1,valor);
$300010..$300017:bac06_0.tile_3.change_control1((direccion and 7) shr 1,valor);
$300800..$30087f:bac06_0.tile_3.colscroll[(direccion and $7f) shr 1]:=valor;
$300c00..$300fff:bac06_0.tile_3.rowscroll[(direccion and $3ff) shr 1]:=valor;
$301000..$3017ff:if bac06_0.tile_3.data[(direccion and $7ff) shr 1]<>valor then begin
bac06_0.tile_3.data[(direccion and $7ff) shr 1]:=valor;
bac06_0.tile_3.buffer[(direccion and $7ff) shr 1]:=true;
end;
$304000..$307fff:ram2[(direccion and $3fff) shr 1]:=valor;
$308000..$3087ff:bac06_0.sprite_ram[(direccion and $7ff) shr 1]:=valor;
$310000..$3107ff:if buffer_paleta[(direccion and $7ff) shr 1]<>valor then begin
buffer_paleta[(direccion and $7ff) shr 1]:=valor;
cambiar_color_dec1((direccion and $7ff) shr 1);
end;
$314000..$31400f:case ((direccion and $f) shr 1) of
0:begin
sound_latch:=valor and $ff;
h6280_0.set_irq_line(0,HOLD_LINE);
end;
1:prioridad:=valor and $ff;
end;
end;
end;
function slyspy_snd_getbyte(direccion:dword):byte;
begin
case direccion of
$0..$ffff:slyspy_snd_getbyte:=mem_snd[direccion];
$80000..$fffff:case ((direccion and $7ffff) or (slyspy_sound_state*$80000)) of
$20000,$a0000,$120000,$1a0000:slyspy_sound_state:=(slyspy_sound_state+1) and 3;
$50000,$d0000,$150000,$1d0000:slyspy_sound_state:=0;
//State 0
$60000:slyspy_snd_getbyte:=oki_6295_0.read;
$70000:slyspy_snd_getbyte:=sound_latch;
//State 1
$90000:slyspy_snd_getbyte:=oki_6295_0.read;
$c0000:slyspy_snd_getbyte:=sound_latch;
//State 2
$110000:slyspy_snd_getbyte:=sound_latch;
$130000:slyspy_snd_getbyte:=oki_6295_0.read;
//State 3
$1e0000:slyspy_snd_getbyte:=sound_latch;
$1f0000:slyspy_snd_getbyte:=oki_6295_0.read;
end;
$1f0000..$1fffff:slyspy_snd_getbyte:=mcu_ram[direccion and $1fff];
end;
end;
procedure slyspy_snd_putbyte(direccion:dword;valor:byte);
begin
case direccion of
0..$ffff:; //ROM
$80000..$fffff:case ((direccion and $7ffff) or (slyspy_sound_state*$80000)) of
//State 0
$10000:ym3812_0.control(valor);
$10001:ym3812_0.write(valor);
$30000:ym2203_0.Control(valor);
$30001:ym2203_0.Write(valor);
$60000:oki_6295_0.write(valor);
//State 1
$90000:oki_6295_0.write(valor);
$e0000:ym2203_0.Control(valor);
$e0001:ym2203_0.Write(valor);
$f0000:ym3812_0.control(valor);
$f0001:ym3812_0.write(valor);
//State 2
$130000:oki_6295_0.write(valor);
$140000:ym2203_0.Control(valor);
$140001:ym2203_0.Write(valor);
$170000:ym3812_0.control(valor);
$170001:ym3812_0.write(valor);
//State 3
$190000:ym3812_0.control(valor);
$190001:ym3812_0.write(valor);
$1c0000:ym2203_0.Control(valor);
$1c0001:ym2203_0.Write(valor);
$1f0000:oki_6295_0.write(valor);
end;
$1f0000..$1fffff:mcu_ram[direccion and $1fff]:=valor;
end;
end;
//Main
procedure reset_dec0;
begin
m68000_0.reset;
case main_vars.tipo_maquina of
157:begin
mcs51_0.reset;
i8751_return:=0;
i8751_command:=0;
i8751_ports[0]:=0;
i8751_ports[1]:=0;
i8751_ports[2]:=0;
i8751_ports[3]:=0;
m6502_0.reset;
end;
156,158:begin
h6280_0.reset;
m6502_0.reset;
end;
316,317:begin
h6280_0.reset;
slyspy_state:=0;
slyspy_sound_state:=0;
end;
end;
ym3812_0.reset;
ym2203_0.reset;
oki_6295_0.reset;
bac06_0.reset;
reset_audio;
marcade.in0:=$ffff;
marcade.in1:=$f7;
sound_latch:=0;
end;
function iniciar_dec0:boolean;
const
ps_x:array[0..15] of dword=(16*8+0, 16*8+1, 16*8+2, 16*8+3, 16*8+4, 16*8+5, 16*8+6, 16*8+7,
0, 1, 2, 3, 4, 5, 6, 7);
ps_y:array[0..15] of dword=(0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 );
var
memoria_temp:array[0..$7ffff] of byte;
memoria_temp2:array[0..$1ffff] of byte;
f:word;
procedure convert_chars(ch_num:word);
begin
init_gfx(0,8,8,ch_num);
gfx[0].trans[0]:=true;
gfx_set_desc_data(4,0,8*8,0,ch_num*8*8*2,ch_num*8*8*1,ch_num*8*8*3);
convert_gfx(0,0,@memoria_temp,@ps_x[8],@ps_y,false,false);
end;
procedure convert_tiles(num_gfx:byte;tl_num:word);
begin
init_gfx(num_gfx,16,16,tl_num);
gfx[num_gfx].trans[0]:=true;
gfx_set_desc_data(4,0,16*16,tl_num*16*16*1,tl_num*16*16*3,tl_num*16*16*0,tl_num*16*16*2);
convert_gfx(num_gfx,0,@memoria_temp,@ps_x,@ps_y,false,false);
end;
procedure init_sound_chips;
begin
ym3812_0:=ym3812_chip.create(YM3812_FM,3000000);
ym3812_0.change_irq_calls(snd_irq);
ym2203_0:=ym2203_chip.create(1500000);
oki_6295_0:=snd_okim6295.Create(1000000,OKIM6295_PIN7_HIGH);
end;
begin
case main_vars.tipo_maquina of
156:llamadas_maquina.bucle_general:=robocop_principal;
157:llamadas_maquina.bucle_general:=baddudes_principal;
158:llamadas_maquina.bucle_general:=hippodrome_principal;
316,317:llamadas_maquina.bucle_general:=slyspy_principal;
end;
llamadas_maquina.reset:=reset_dec0;
llamadas_maquina.fps_max:=57.444885;
iniciar_dec0:=false;
iniciar_audio(false);
//El video se inicia en el chip bac06!!!
//Main CPU
m68000_0:=cpu_m68000.create(10000000,272);
m68000_0.change_ram16_calls(dec0_getword,dec0_putword);
case main_vars.tipo_maquina of
156:begin //Robocop
bac06_0:=bac06_chip.create(false,false,false,$000,$200,$300,$fff,$7ff,$3ff,1,1,1,$100);
//cargar roms
if not(roms_load16w(@rom,robocop_rom)) then exit;
//cargar sonido
m6502_0:=cpu_m6502.create(1500000,272,TCPU_M6502);
m6502_0.change_ram_calls(dec0_snd_getbyte,dec0_snd_putbyte);
m6502_0.init_sound(dec0_sound_update);
init_sound_chips;
if not(roms_load(@mem_snd,robocop_sound)) then exit;
//MCU
h6280_0:=cpu_h6280.create(21477200 div 16,272);
h6280_0.change_ram_calls(robocop_mcu_getbyte,robocop_mcu_putbyte);
if not(roms_load(@mem_misc,robocop_mcu)) then exit;
//OKI rom
if not(roms_load(oki_6295_0.get_rom_addr,robocop_oki)) then exit;
//convertir chars
if not(roms_load(@memoria_temp,robocop_char)) then exit;
convert_chars($1000);
//tiles 1
if not(roms_load(@memoria_temp,robocop_tiles1)) then exit;
convert_tiles(1,$800);
//tiles 2
if not(roms_load(@memoria_temp,robocop_tiles2)) then exit;
convert_tiles(2,$400);
//sprites
if not(roms_load(@memoria_temp,robocop_sprites)) then exit;
convert_tiles(3,$1000);
//Dip
marcade.dswa:=$ff7f;
marcade.dswa_val:=@robocop_dip;
end;
157:begin //Baddudes
bac06_0:=bac06_chip.create(false,true,true,$000,$200,$300,$7ff,$7ff,$3ff,1,1,1,$100);
//cargar roms
if not(roms_load16w(@rom,baddudes_rom)) then exit;
//cargar sonido
m6502_0:=cpu_m6502.create(1500000,272,TCPU_M6502);
m6502_0.change_ram_calls(dec0_snd_getbyte,dec0_snd_putbyte);
m6502_0.init_sound(dec0_sound_update);
init_sound_chips;
if not(roms_load(@mem_snd,baddudes_sound)) then exit;
//MCU
mcs51_0:=cpu_mcs51.create(8000000,272);
mcs51_0.change_io_calls(in_port0,in_port1,in_port1,in_port1,out_port0,out_port1,out_port2,out_port3);
if not(roms_load(mcs51_0.get_rom_addr,baddudes_mcu)) then exit;
//OKI rom
if not(roms_load(oki_6295_0.get_rom_addr,baddudes_oki)) then exit;
//convertir chars
if not(roms_load(@memoria_temp,baddudes_char)) then exit;
convert_chars($800);
//tiles 1
if not(roms_load(@memoria_temp,baddudes_tiles1)) then exit;
convert_tiles(1,$800);
//tiles 2, ordenar
if not(roms_load(@memoria_temp,baddudes_tiles2)) then exit;
copymemory(@memoria_temp[$8000],@memoria_temp[$20000],$8000);
copymemory(@memoria_temp[$0],@memoria_temp[$28000],$8000);
copymemory(@memoria_temp[$18000],@memoria_temp[$30000],$8000);
copymemory(@memoria_temp[$10000],@memoria_temp[$38000],$8000);
convert_tiles(2,$400);
//sprites
if not(roms_load(@memoria_temp,baddudes_sprites)) then exit;
convert_tiles(3,$1000);
//Dip
marcade.dswa:=$ffff;
marcade.dswa_val:=@baddudes_dip;
end;
158:begin //Hippodrome
bac06_0:=bac06_chip.create(false,false,false,$000,$200,$300,$fff,$3ff,$3ff,1,1,1,$100);
//cargar roms
if not(roms_load16w(@rom,hippo_rom)) then exit;
//cargar sonido
m6502_0:=cpu_m6502.create(1500000,272,TCPU_M6502);
m6502_0.change_ram_calls(dec0_snd_getbyte,dec0_snd_putbyte);
m6502_0.init_sound(dec0_sound_update);
init_sound_chips;
if not(roms_load(@mem_snd,hippo_sound)) then exit;
//MCU+decrypt
h6280_0:=cpu_h6280.create(21477200 div 16,272);
h6280_0.change_ram_calls(hippo_mcu_getbyte,hippo_mcu_putbyte);
if not(roms_load(@mem_misc,hippo_mcu)) then exit;
for f:=0 to $ffff do mem_misc[f]:=bitswap8(mem_misc[f],0,6,5,4,3,2,1,7);
mem_misc[$189]:=$60; // RTS prot area
mem_misc[$1af]:=$60; // RTS prot area
mem_misc[$1db]:=$60; // RTS prot area
mem_misc[$21a]:=$60; // RTS prot area
//OKI rom
if not(roms_load(oki_6295_0.get_rom_addr,hippo_oki)) then exit;
//convertir chars
if not(roms_load(@memoria_temp,hippo_char)) then exit;
convert_chars($1000);
//tiles 1
if not(roms_load(@memoria_temp,hippo_tiles1)) then exit;
convert_tiles(1,$400);
//tiles 2
if not(roms_load(@memoria_temp,hippo_tiles2)) then exit;
convert_tiles(2,$400);
//sprites
if not(roms_load(@memoria_temp,hippo_sprites)) then exit;
convert_tiles(3,$1000);
//Dip
marcade.dswa:=$ffff;
marcade.dswa_val:=@hippo_dip;
end;
316:begin //Sly Spy
bac06_0:=bac06_chip.create(false,true,false,$000,$200,$300,$7ff,$3ff,$7ff,1,1,1,$100);
//cargar roms
m68000_0.change_ram16_calls(slyspy_getword,slyspy_putword);
if not(roms_load16w(@rom,slyspy_rom)) then exit;
//cargar sonido
h6280_0:=cpu_h6280.create(12000000 div 4,272);
h6280_0.change_ram_calls(slyspy_snd_getbyte,slyspy_snd_putbyte);
h6280_0.init_sound(dec0_sound_update);
init_sound_chips;
ym3812_0.change_irq_calls(slyspy_snd_irq);
if not(roms_load(@mem_snd,slyspy_sound)) then exit;
for f:=0 to $ffff do mem_snd[f]:=bitswap8(mem_snd[f],0,6,5,4,3,2,1,7);
//OKI rom
if not(roms_load(oki_6295_0.get_rom_addr,slyspy_oki)) then exit;
//convertir chars
if not(roms_load(@memoria_temp2,slyspy_char)) then exit;
copymemory(@memoria_temp[$0],@memoria_temp2[$4000],$4000);
copymemory(@memoria_temp[$4000],@memoria_temp2[$0],$4000);
copymemory(@memoria_temp[$8000],@memoria_temp2[$c000],$4000);
copymemory(@memoria_temp[$c000],@memoria_temp2[$8000],$4000);
convert_chars($800);
//tiles 1
if not(roms_load(@memoria_temp,slyspy_tiles1)) then exit;
convert_tiles(1,$400);
//tiles 2, ordenar
if not(roms_load(@memoria_temp,slyspy_tiles2)) then exit;
convert_tiles(2,$800);
//sprites
if not(roms_load(@memoria_temp,slyspy_sprites)) then exit;
convert_tiles(3,$1000);
//Dip
marcade.dswa:=$ff7f;
marcade.dswa_val:=@slyspy_dip;
end;
317:begin //Boulder Dash
bac06_0:=bac06_chip.create(false,true,false,$000,$200,$300,$fff,$3ff,$7ff,1,1,1,$100);
//cargar roms
m68000_0.change_ram16_calls(slyspy_getword,slyspy_putword);
if not(roms_load16w(@rom,bouldash_rom)) then exit;
//cargar sonido
h6280_0:=cpu_h6280.create(12000000 div 4,272);
h6280_0.change_ram_calls(slyspy_snd_getbyte,slyspy_snd_putbyte);
h6280_0.init_sound(dec0_sound_update);
init_sound_chips;
ym3812_0.change_irq_calls(slyspy_snd_irq);
if not(roms_load(@mem_snd,bouldash_sound)) then exit;
for f:=0 to $ffff do mem_snd[f]:=bitswap8(mem_snd[f],0,6,5,4,3,2,1,7);
//OKI rom
if not(roms_load(oki_6295_0.get_rom_addr,bouldash_oki)) then exit;
//convertir chars
if not(roms_load(@memoria_temp2,bouldash_char)) then exit;
copymemory(@memoria_temp[$0],@memoria_temp2[$8000],$8000);
copymemory(@memoria_temp[$8000],@memoria_temp2[$0],$8000);
copymemory(@memoria_temp[$18000],@memoria_temp2[$10000],$8000);
copymemory(@memoria_temp[$10000],@memoria_temp2[$18000],$8000);
convert_chars($1000);
//tiles 1
if not(roms_load(@memoria_temp,bouldash_tiles1)) then exit;
convert_tiles(1,$400);
//tiles 2, ordenar
if not(roms_load(@memoria_temp,bouldash_tiles2)) then exit;
convert_tiles(2,$800);
//sprites
if not(roms_load(@memoria_temp,bouldash_sprites)) then exit;
convert_tiles(3,$800);
//Dip
marcade.dswa:=$7f7f;
marcade.dswa_val:=@bouldash_dip;
end;
end;
//final
reset_dec0;
iniciar_dec0:=true;
end;
end.
|
unit deco_bac06;
interface
uses {$IFDEF WINDOWS}windows,{$ENDIF}
gfx_engine,main_engine,pal_engine;
type
tyle_chip=class
constructor create(screen,screen_pri:byte;color_add,num_mask:word;mult:byte);
destructor free;
public
data:array[0..$1fff] of word;
control_0,control_1:array[0..3] of word;
colscroll:array[0..$3f] of word;
rowscroll:array[0..$1ff] of word;
buffer_color:array[0..$f] of boolean;
buffer:array[0..$fff] of boolean;
procedure reset;
procedure update_pf(gfx_num:byte;trans,pri:boolean);
procedure show_pf;
procedure show_pf_pri;
procedure change_control0(pos,valor:word);
procedure change_control1(pos,valor:word;dec1:boolean=false);
private
pos_scroll_x:array[0..$ff] of word;
pos_scroll_y:array[0..$f] of word;
mult,screen,screen_pri:byte;
color_add,scroll_x,scroll_y,control,num_mask,long_bloque_x,long_bloque_y:word;
procedure update_16x16(gfx_num:byte;trans,pri:boolean);
procedure update_8x8(gfx_num:byte;trans:boolean);
end;
bac06_chip=class
constructor create(pri1,pri2,pri3:boolean;color_add1,color_add2,color_add3,num_mask1,num_mask2,num_mask3:word;mult1,mult2,mult3:byte;sprite_color:word);
destructor free;
public
tile_1,tile_2,tile_3:tyle_chip;
sprite_ram:array[0..$7ff] of word; //Para evitar el overflow del Act Fancer!
procedure reset;
procedure draw_sprites(pri_mask,pri_val,num_gfx:byte);
procedure update_sprite_data(data:pbyte);
private
sprite_color:word;
end;
var
bac06_0:bac06_chip;
implementation
constructor tyle_chip.create(screen,screen_pri:byte;color_add,num_mask:word;mult:byte);
begin
self.screen:=screen;
self.screen_pri:=screen_pri;
self.color_add:=color_add;
self.num_mask:=num_mask;
self.mult:=mult;
end;
destructor tyle_chip.free;
begin
end;
procedure tyle_chip.reset;
begin
fillchar(self.data,$2000*2,0);
fillchar(self.control_0,4*2,$ee);
fillchar(self.control_1,4*2,$ee);
self.scroll_x:=0;
self.scroll_y:=0;
self.long_bloque_x:=1;
self.long_bloque_y:=1;
self.control:=0;
fillchar(self.colscroll,$40*2,0);
fillchar(self.rowscroll,$200*2,0);
fillchar(self.pos_scroll_x,$100*2,0);
fillchar(self.pos_scroll_y,$10*2,0);
fillchar(self.buffer_color,$10,1);
fillchar(self.buffer,$1000,1);
end;
constructor bac06_chip.create(pri1,pri2,pri3:boolean;color_add1,color_add2,color_add3,num_mask1,num_mask2,num_mask3:word;mult1,mult2,mult3:byte;sprite_color:word);
var
sc_pri1,sc_pri2,sc_pri3:byte;
begin
if mult1<>0 then screen_init(1,1024*mult1,1024,true);
if mult2<>0 then screen_init(2,1024*mult2,1024,true);
if mult3<>0 then screen_init(3,1024*mult3,1024,true);
sc_pri1:=4;
sc_pri2:=5;
sc_pri3:=6;
if pri1 then screen_init(4,1024,1024,true)
else sc_pri1:=1;
if pri2 then screen_init(5,1024,1024,true)
else sc_pri2:=2;
if pri3 then screen_init(6,1024,1024,true)
else sc_pri3:=3;
screen_init(7,512,512,false,true);
self.tile_1:=tyle_chip.create(1,sc_pri1,color_add1,num_mask1,mult1);
self.tile_2:=tyle_chip.create(2,sc_pri2,color_add2,num_mask2,mult2);
self.tile_3:=tyle_chip.create(3,sc_pri3,color_add3,num_mask3,mult3);
self.sprite_color:=sprite_color;
iniciar_video(256,240);
end;
destructor bac06_chip.free;
begin
self.tile_1.free;
self.tile_2.free;
self.tile_3.free;
end;
procedure bac06_chip.reset;
begin
self.tile_1.reset;
self.tile_2.reset;
self.tile_3.reset;
fillchar(self.sprite_ram,$400*2,0);
end;
//Sprites
procedure bac06_chip.draw_sprites(pri_mask,pri_val,num_gfx:byte);
var
f,y,x,nchar:word;
color:byte;
fx,fy:boolean;
multi,inc,mult:integer;
begin
for f:=0 to $ff do begin
y:=self.sprite_ram[f*4];
if ((y and $8000)=0) then continue;
x:=self.sprite_ram[(f*4)+2];
color:=x shr 12;
if ((color and pri_mask)<>pri_val) then continue;
if (((x and $800)<>0) and ((main_vars.frames_sec and 1)<>0)) then continue;
fx:=(y and $2000)<>0;
fy:=(y and $4000)<>0;
multi:=(1 shl ((y and $1800) shr 11))-1; // 1x, 2x, 4x, 8x height
// multi = 0 1 3 7
nchar:=self.sprite_ram[(f*4)+1] and $fff;
x:=(240-x) and $1ff;
y:=(240-y) and $1ff;
nchar:=nchar and not(multi);
if fy then inc:=-1
else begin
nchar:=nchar+multi;
inc:=1;
end;
mult:=-16;
while (multi>=0) do begin
if nchar<>0 then begin
put_gfx_sprite(nchar-multi*inc,(color shl 4)+sprite_color,fx,fy,num_gfx);
actualiza_gfx_sprite(x,(y+mult*multi) and $1ff,7,num_gfx);
end;
multi:=multi-1;
end;
end;
end;
procedure bac06_chip.update_sprite_data(data:pbyte);
begin
copymemory(@self.sprite_ram,data,$400*2);
end;
//Video
procedure put_gfx_dec0(pos_x,pos_y,nchar,color:word;screen,ngfx:byte);
var
x,y:byte;
temp:pword;
pos:pbyte;
punto:word;
begin
pos:=gfx[ngfx].datos;
inc(pos,nchar*16*16);
for y:=0 to 15 do begin
temp:=punbuf;
for x:=0 to 15 do begin
punto:=gfx[ngfx].colores[pos^+color];
if (punto and $8)=$8 then temp^:=paleta[punto]
else temp^:=paleta[MAX_COLORES];
inc(pos);
inc(temp);
end;
putpixel(pos_x,pos_y+y,16,punbuf,screen);
end;
end;
procedure tyle_chip.update_8x8(gfx_num:byte;trans:boolean);
var
f,x,y,nchar,atrib,pos:word;
color:byte;
begin
for f:=0 to $fff do begin
case (self.control_0[3] and $3) of
0:begin
x:=f mod 128;
y:=f div 128;
pos:=(x and $1f)+((y and $1f) shl 5)+((x and $60) shl 5);
end;
1:begin
x:=f mod 64;
y:=f div 64;
pos:=(x and $1f)+((y and $1f) shl 5)+((y and $20) shl 5)+((x and $20) shl 6);
end;
2:begin
x:=f mod 32;
y:=f div 32;
pos:=(x and $1f)+((y and $7f) shl 5);
end;
end;
atrib:=self.data[pos];
color:=(atrib shr 12);
if (self.buffer[pos] or self.buffer_color[color]) then begin
nchar:=atrib and self.num_mask;
if trans then put_gfx_trans(x*8,y*8,nchar,(color shl 4)+self.color_add,self.screen,gfx_num)
else put_gfx(x*8,y*8,nchar,(color shl 4)+self.color_add,self.screen,gfx_num);
self.buffer[pos]:=false;
end;
end;
fillchar(self.buffer_color,$10,0);
end;
procedure tyle_chip.update_16x16(gfx_num:byte;trans,pri:boolean);
var
f,x,y,atrib,nchar,pos:word;
color:byte;
begin
for f:=0 to ($3ff*self.mult) do begin
case (self.control_0[3] and $3) of
0:begin
x:=f mod (64*self.mult);
y:=f div (64*self.mult);
pos:=(x and $f)+((y and $f) shl 4)+((x and $1f0) shl 4);
end;
1:begin
x:=f mod (32*self.mult);
y:=f div (32*self.mult);
pos:=(x and $f)+((y and $1f) shl 4)+((x and $f0) shl 5);
end;
2:begin
x:=f mod (16*self.mult);
y:=f div (16*self.mult);
pos:=(x and $f)+((y and $3f) shl 4)+((x and $70) shl 6);
end;
end;
atrib:=self.data[pos];
color:=(atrib shr 12);
if (self.buffer[pos] or self.buffer_color[color]) then begin
nchar:=atrib and self.num_mask;
if trans then put_gfx_trans(x*16,y*16,nchar,(color shl 4)+self.color_add,self.screen,gfx_num)
else put_gfx(x*16,y*16,nchar,(color shl 4)+color_add,self.screen,gfx_num);
if pri then begin
if (color and $8)=8 then put_gfx_dec0(x*16,y*16,nchar,(color shl 4)+self.color_add,self.screen_pri,gfx_num)
else put_gfx_block_trans(x*16,y*16,self.screen_pri,16,16);
end;
self.buffer[pos]:=false;
end;
end;
fillchar(self.buffer_color,$10,0);
end;
procedure tyle_chip.update_pf(gfx_num:byte;trans,pri:boolean);
begin
if (self.control_0[0] and 1)=0 then self.update_16x16(gfx_num,trans,pri)
else self.update_8x8(gfx_num,trans);
end;
procedure tyle_chip.show_pf;
begin
if self.control=0 then begin
scroll_x_y(self.screen,7,self.scroll_x,self.scroll_y);
end else begin
if (self.control and $4)<>0 then copymemory(@self.pos_scroll_x,@self.rowscroll,$100*2)
else fillchar(self.pos_scroll_x,$100*2,0);
if (self.control and $8)<>0 then copymemory(@self.pos_scroll_y,@self.colscroll,$10*2)
else fillchar(self.pos_scroll_y,$10*2,0);
scroll_xy_part(self.screen,7,self.long_bloque_x,self.long_bloque_y,@self.pos_scroll_x[0],@self.pos_scroll_y[0],self.scroll_x,self.scroll_y);
end;
end;
procedure tyle_chip.show_pf_pri;
begin
if self.control=0 then scroll_x_y(self.screen_pri,7,self.scroll_x,self.scroll_y)
else scroll_xy_part(self.screen_pri,7,self.long_bloque_x,self.long_bloque_y,@self.pos_scroll_x[0],@self.pos_scroll_y[0],self.scroll_x,self.scroll_y);
end;
procedure tyle_chip.change_control0(pos,valor:word);
var
tempw:word;
begin
if self.control_0[pos]=valor then exit;
self.control_0[pos]:=valor;
case pos of
0:self.control:=valor and $c;
3:begin
fillchar(self.buffer,$1000,1);
case (self.control_0[3] and $3) of
0:begin
tempw:=1024*self.mult;
screen_mod_scroll(self.screen,tempw,256,tempw-1,256,256,255);
screen_mod_scroll(self.screen_pri,tempw,256,tempw-1,256,256,255);
end;
1:begin
tempw:=512*self.mult;
screen_mod_scroll(self.screen,tempw,256,tempw-1,512,256,511);
screen_mod_scroll(self.screen_pri,tempw,256,tempw-1,512,256,511);
end;
2:begin
tempw:=256*self.mult;
screen_mod_scroll(self.screen,tempw,256,tempw-1,1024,256,1023);
screen_mod_scroll(self.screen_pri,tempw,256,tempw-1,1024,256,1023);
end;
end;
end;
end;
end;
procedure tyle_chip.change_control1(pos,valor:word;dec1:boolean=false);
begin
if self.control_1[pos]=valor then exit;
self.control_1[pos]:=valor;
case pos of
0:self.scroll_x:=valor;
1:self.scroll_y:=valor;
2:if dec1 then self.long_bloque_x:=16 shr (valor and $3)
else self.long_bloque_x:=1 shl (valor and $f);
3:self.long_bloque_y:=16 shl (valor and $f);
end;
end;
end.
|
unit Modbus;
{$IFDEF FPC}
{$MODE Delphi}
{$ENDIF}
interface
uses
Windows,
LCLIntf, LCLType, LMessages,
Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Spin, ExtCtrls, Grids, ThreadMB, Inifiles;
const
t_UINT16 = 0;
t_INT16 = 1;
t_UINT32 = 2;
t_INT32 = 3;
t_16O = 4;
t_FLOAT32 = 5;
LEN_TBYTEVAL = 4;
type
TByteVal = array[1..LEN_TBYTEVAL] of byte;
type
int = integer;
type
{ TForm1 }
TForm1 = class(TForm)
CB_TCP_IP: TCheckBox;
IP_addr: TEdit;
GroupBox1: TGroupBox;
Label27: TLabel;
Label28: TLabel;
Label29: TLabel;
Label301: TLabel;
Label302: TLabel;
ComboBox1: TComboBox;
ComboBox2: TComboBox;
ComboBox3: TComboBox;
ComboBox4: TComboBox;
ComboBox5: TComboBox;
Label303: TLabel;
RB_Fn10: TRadioButton;
RB_Fn6: TRadioButton;
RadioGroup3: TRadioGroup;
Shp_connect_tcp: TShape;
out_mess_st: TStaticText;
TCP_Port_SE: TSpinEdit;
SpinEdit300: TSpinEdit;
SpinEdit301: TSpinEdit;
SpinEdit302: TSpinEdit;
SpinEdit104: TSpinEdit;
SpinEdit105: TSpinEdit;
SpinEdit106: TSpinEdit;
SpinEdit107: TSpinEdit;
Label304: TLabel;
Label305: TLabel;
Label306: TLabel;
Label307: TLabel;
Label308: TLabel;
Shape1000: TShape;
Label311: TLabel;
CheckBox1: TCheckBox;
Button1: TButton;
Shape2: TShape;
Shape1: TShape;
Shape3: TShape;
Shape4: TShape;
Shape5: TShape;
Shape6: TShape;
Shape7: TShape;
Shape8: TShape;
Shape9: TShape;
Shape10: TShape;
Shape11: TShape;
Shape12: TShape;
Shape13: TShape;
Shape14: TShape;
Shape15: TShape;
Shape16: TShape;
Shape17: TShape;
Shape18: TShape;
Shape19: TShape;
Shape20: TShape;
Shape21: TShape;
Shape22: TShape;
Shape23: TShape;
Shape24: TShape;
Label901: TLabel;
Label902: TLabel;
Label903: TLabel;
CheckBox3: TCheckBox;
Label904: TLabel;
Label905: TLabel;
Label906: TLabel;
Label907: TLabel;
Label908: TLabel;
Label909: TLabel;
Label910: TLabel;
Label911: TLabel;
Label912: TLabel;
Label913: TLabel;
Label914: TLabel;
Label915: TLabel;
Label916: TLabel;
Label917: TLabel;
Label918: TLabel;
Label919: TLabel;
Label920: TLabel;
Label921: TLabel;
Label922: TLabel;
Label923: TLabel;
Label924: TLabel;
Shape25: TShape;
Shape26: TShape;
Shape27: TShape;
Shape28: TShape;
Shape29: TShape;
Shape30: TShape;
Shape31: TShape;
Shape32: TShape;
Shape33: TShape;
Shape34: TShape;
Shape35: TShape;
Shape36: TShape;
Shape37: TShape;
Shape38: TShape;
Shape39: TShape;
Shape40: TShape;
Shape41: TShape;
Shape42: TShape;
Shape43: TShape;
Shape44: TShape;
Shape45: TShape;
Shape46: TShape;
Shape47: TShape;
Shape48: TShape;
Label925: TLabel;
Label926: TLabel;
Label927: TLabel;
Label928: TLabel;
Label929: TLabel;
Label930: TLabel;
Label931: TLabel;
Label932: TLabel;
Label933: TLabel;
Label934: TLabel;
Label935: TLabel;
Label936: TLabel;
Label937: TLabel;
Label938: TLabel;
Label939: TLabel;
Label940: TLabel;
Label941: TLabel;
Label942: TLabel;
Label943: TLabel;
Label944: TLabel;
Label945: TLabel;
Label946: TLabel;
Label947: TLabel;
Label948: TLabel;
Shape49: TShape;
Shape50: TShape;
Shape51: TShape;
Shape52: TShape;
Shape53: TShape;
Shape54: TShape;
Shape55: TShape;
Shape56: TShape;
Shape57: TShape;
Shape58: TShape;
Shape59: TShape;
Shape60: TShape;
Shape61: TShape;
Shape62: TShape;
Shape63: TShape;
Shape64: TShape;
Shape65: TShape;
Shape66: TShape;
Shape67: TShape;
Shape68: TShape;
Shape69: TShape;
Shape70: TShape;
Shape71: TShape;
Shape72: TShape;
Label949: TLabel;
Label950: TLabel;
Label951: TLabel;
Label952: TLabel;
Label953: TLabel;
Label954: TLabel;
Label955: TLabel;
Label956: TLabel;
Label957: TLabel;
Label958: TLabel;
Label959: TLabel;
Label960: TLabel;
Label961: TLabel;
Label962: TLabel;
Label963: TLabel;
Label964: TLabel;
Label965: TLabel;
Label966: TLabel;
Label967: TLabel;
Label968: TLabel;
Label969: TLabel;
Label970: TLabel;
Label971: TLabel;
Label972: TLabel;
Shape73: TShape;
Shape74: TShape;
Shape75: TShape;
Shape76: TShape;
Shape77: TShape;
Shape78: TShape;
Shape79: TShape;
Shape80: TShape;
Shape81: TShape;
Shape82: TShape;
Shape83: TShape;
Shape84: TShape;
Shape85: TShape;
Shape86: TShape;
Shape87: TShape;
Shape88: TShape;
Shape89: TShape;
Shape90: TShape;
Shape91: TShape;
Shape92: TShape;
Shape93: TShape;
Shape94: TShape;
Shape95: TShape;
Shape96: TShape;
Label973: TLabel;
Label974: TLabel;
Label975: TLabel;
Label976: TLabel;
Label977: TLabel;
Label978: TLabel;
Label979: TLabel;
Label980: TLabel;
Label981: TLabel;
Label982: TLabel;
Label983: TLabel;
Label984: TLabel;
Label985: TLabel;
Label986: TLabel;
Label987: TLabel;
Label988: TLabel;
Label989: TLabel;
Label990: TLabel;
Label991: TLabel;
Label992: TLabel;
Label993: TLabel;
Label994: TLabel;
Label995: TLabel;
Label996: TLabel;
Shape97: TShape;
Shape98: TShape;
Shape99: TShape;
Shape100: TShape;
Shape101: TShape;
Shape102: TShape;
Shape103: TShape;
Shape104: TShape;
Shape105: TShape;
Shape106: TShape;
Shape107: TShape;
Shape108: TShape;
Shape109: TShape;
Shape110: TShape;
Shape111: TShape;
Shape112: TShape;
Shape113: TShape;
Shape114: TShape;
Shape115: TShape;
Shape116: TShape;
Shape117: TShape;
Shape118: TShape;
Shape119: TShape;
Shape120: TShape;
Label997: TLabel;
Label998: TLabel;
Label999: TLabel;
Label1000: TLabel;
Label1001: TLabel;
Label1002: TLabel;
Label1003: TLabel;
Label1004: TLabel;
Label1005: TLabel;
Label1006: TLabel;
Label1007: TLabel;
Label1008: TLabel;
Label1009: TLabel;
Label1010: TLabel;
Label1011: TLabel;
Label1012: TLabel;
Label1013: TLabel;
Label1014: TLabel;
Label1015: TLabel;
Label1016: TLabel;
Label1017: TLabel;
Label1018: TLabel;
Label1019: TLabel;
Label1020: TLabel;
StaticText1: TStaticText;
StaticText2: TStaticText;
StaticText3: TStaticText;
StaticText4: TStaticText;
StaticText5: TStaticText;
StaticText6: TStaticText;
StaticText7: TStaticText;
StaticText8: TStaticText;
StaticText9: TStaticText;
StaticText10: TStaticText;
StaticText11: TStaticText;
StaticText12: TStaticText;
StaticText13: TStaticText;
StaticText14: TStaticText;
StaticText15: TStaticText;
StaticText16: TStaticText;
StaticText17: TStaticText;
StaticText18: TStaticText;
StaticText19: TStaticText;
StaticText20: TStaticText;
StaticText21: TStaticText;
StaticText22: TStaticText;
StaticText23: TStaticText;
StaticText24: TStaticText;
StaticText25: TStaticText;
StaticText26: TStaticText;
StaticText27: TStaticText;
StaticText28: TStaticText;
StaticText29: TStaticText;
StaticText30: TStaticText;
StaticText31: TStaticText;
StaticText32: TStaticText;
StaticText33: TStaticText;
StaticText34: TStaticText;
StaticText35: TStaticText;
StaticText36: TStaticText;
StaticText37: TStaticText;
StaticText38: TStaticText;
StaticText39: TStaticText;
StaticText40: TStaticText;
StaticText41: TStaticText;
StaticText42: TStaticText;
StaticText43: TStaticText;
StaticText44: TStaticText;
StaticText45: TStaticText;
StaticText46: TStaticText;
StaticText47: TStaticText;
StaticText48: TStaticText;
StaticText49: TStaticText;
StaticText50: TStaticText;
StaticText51: TStaticText;
StaticText52: TStaticText;
StaticText53: TStaticText;
StaticText54: TStaticText;
StaticText55: TStaticText;
StaticText56: TStaticText;
StaticText57: TStaticText;
StaticText58: TStaticText;
StaticText59: TStaticText;
StaticText60: TStaticText;
StaticText61: TStaticText;
StaticText62: TStaticText;
StaticText63: TStaticText;
StaticText64: TStaticText;
StaticText65: TStaticText;
StaticText66: TStaticText;
StaticText67: TStaticText;
StaticText68: TStaticText;
StaticText69: TStaticText;
StaticText70: TStaticText;
StaticText71: TStaticText;
StaticText72: TStaticText;
StaticText73: TStaticText;
StaticText74: TStaticText;
StaticText75: TStaticText;
StaticText76: TStaticText;
StaticText77: TStaticText;
StaticText78: TStaticText;
StaticText79: TStaticText;
StaticText80: TStaticText;
StaticText81: TStaticText;
StaticText82: TStaticText;
StaticText83: TStaticText;
StaticText84: TStaticText;
StaticText85: TStaticText;
StaticText86: TStaticText;
StaticText87: TStaticText;
StaticText88: TStaticText;
StaticText89: TStaticText;
StaticText90: TStaticText;
StaticText91: TStaticText;
StaticText92: TStaticText;
StaticText93: TStaticText;
StaticText94: TStaticText;
StaticText95: TStaticText;
StaticText96: TStaticText;
StaticText97: TStaticText;
StaticText98: TStaticText;
StaticText99: TStaticText;
StaticText100: TStaticText;
StaticText101: TStaticText;
StaticText102: TStaticText;
StaticText103: TStaticText;
StaticText104: TStaticText;
StaticText105: TStaticText;
StaticText106: TStaticText;
StaticText107: TStaticText;
StaticText108: TStaticText;
StaticText109: TStaticText;
StaticText110: TStaticText;
StaticText111: TStaticText;
StaticText112: TStaticText;
StaticText113: TStaticText;
StaticText114: TStaticText;
StaticText115: TStaticText;
StaticText116: TStaticText;
StaticText117: TStaticText;
StaticText118: TStaticText;
StaticText119: TStaticText;
StaticText120: TStaticText;
StaticText121: TStaticText;
StaticText122: TStaticText;
StaticText123: TStaticText;
StaticText124: TStaticText;
StaticText125: TStaticText;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Label14: TLabel;
Label15: TLabel;
Label16: TLabel;
Label17: TLabel;
Label18: TLabel;
Label19: TLabel;
Label20: TLabel;
Label21: TLabel;
Label22: TLabel;
Label23: TLabel;
Label24: TLabel;
Label25: TLabel;
CheckBox2: TCheckBox;
Shape121: TShape;
Shape122: TShape;
Shape123: TShape;
Shape124: TShape;
Shape125: TShape;
Shape126: TShape;
Shape127: TShape;
Shape128: TShape;
Shape129: TShape;
Shape130: TShape;
Shape131: TShape;
Shape132: TShape;
Shape133: TShape;
Shape134: TShape;
Shape135: TShape;
Shape136: TShape;
Shape137: TShape;
Shape138: TShape;
Shape139: TShape;
Shape140: TShape;
Shape141: TShape;
Shape142: TShape;
Shape143: TShape;
Shape144: TShape;
Label126: TLabel;
Label127: TLabel;
Label128: TLabel;
Label129: TLabel;
Label130: TLabel;
Label131: TLabel;
Label132: TLabel;
Label133: TLabel;
Label134: TLabel;
Label135: TLabel;
Label136: TLabel;
Label137: TLabel;
Label138: TLabel;
Label139: TLabel;
Label140: TLabel;
Label141: TLabel;
Label142: TLabel;
Label143: TLabel;
Label144: TLabel;
Label145: TLabel;
Label146: TLabel;
Label147: TLabel;
Label148: TLabel;
Label149: TLabel;
Shape145: TShape;
Shape146: TShape;
Shape147: TShape;
Shape148: TShape;
Shape149: TShape;
Shape150: TShape;
Shape151: TShape;
Shape152: TShape;
Shape153: TShape;
Shape154: TShape;
Shape155: TShape;
Shape156: TShape;
Shape157: TShape;
Shape158: TShape;
Shape159: TShape;
Shape160: TShape;
Shape161: TShape;
Shape162: TShape;
Shape163: TShape;
Shape164: TShape;
Shape165: TShape;
Shape166: TShape;
Shape167: TShape;
Shape168: TShape;
Label150: TLabel;
Label151: TLabel;
Label152: TLabel;
Label153: TLabel;
Label154: TLabel;
Label155: TLabel;
Label156: TLabel;
Label157: TLabel;
Label158: TLabel;
Label159: TLabel;
Label160: TLabel;
Label161: TLabel;
Label162: TLabel;
Label163: TLabel;
Label164: TLabel;
Label165: TLabel;
Label166: TLabel;
Label167: TLabel;
Label168: TLabel;
Label169: TLabel;
Label170: TLabel;
Label171: TLabel;
Label172: TLabel;
Label173: TLabel;
Shape169: TShape;
Shape170: TShape;
Shape171: TShape;
Shape172: TShape;
Shape173: TShape;
Shape174: TShape;
Shape175: TShape;
Shape176: TShape;
Shape177: TShape;
Shape178: TShape;
Shape179: TShape;
Shape180: TShape;
Shape181: TShape;
Shape182: TShape;
Shape183: TShape;
Shape184: TShape;
Shape185: TShape;
Shape186: TShape;
Shape187: TShape;
Shape188: TShape;
Shape189: TShape;
Shape190: TShape;
Shape191: TShape;
Shape192: TShape;
Label174: TLabel;
Label175: TLabel;
Label176: TLabel;
Label177: TLabel;
Label178: TLabel;
Label179: TLabel;
Label180: TLabel;
Label181: TLabel;
Label182: TLabel;
Label183: TLabel;
Label184: TLabel;
Label185: TLabel;
Label186: TLabel;
Label187: TLabel;
Label188: TLabel;
Label189: TLabel;
Label190: TLabel;
Label191: TLabel;
Label192: TLabel;
Label193: TLabel;
Label194: TLabel;
Label195: TLabel;
Label196: TLabel;
Label197: TLabel;
Shape193: TShape;
Shape194: TShape;
Shape195: TShape;
Shape196: TShape;
Shape197: TShape;
Shape198: TShape;
Shape199: TShape;
Shape200: TShape;
Shape201: TShape;
Shape202: TShape;
Shape203: TShape;
Shape204: TShape;
Shape205: TShape;
Shape206: TShape;
Shape207: TShape;
Shape208: TShape;
Shape209: TShape;
Shape210: TShape;
Shape211: TShape;
Shape212: TShape;
Shape213: TShape;
Shape214: TShape;
Shape215: TShape;
Shape216: TShape;
Label198: TLabel;
Label199: TLabel;
Label200: TLabel;
Label201: TLabel;
Label202: TLabel;
Label203: TLabel;
Label204: TLabel;
Label205: TLabel;
Label206: TLabel;
Label207: TLabel;
Label208: TLabel;
Label209: TLabel;
Label210: TLabel;
Label211: TLabel;
Label212: TLabel;
Label213: TLabel;
Label214: TLabel;
Label215: TLabel;
Label216: TLabel;
Label217: TLabel;
Label219: TLabel;
Label220: TLabel;
Label221: TLabel;
Shape217: TShape;
Shape218: TShape;
Shape219: TShape;
Shape220: TShape;
Shape221: TShape;
Shape222: TShape;
Shape223: TShape;
Shape224: TShape;
Shape225: TShape;
Shape226: TShape;
Shape227: TShape;
Shape228: TShape;
Shape229: TShape;
Shape230: TShape;
Shape231: TShape;
Shape232: TShape;
Shape233: TShape;
Shape234: TShape;
Shape235: TShape;
Shape236: TShape;
Shape237: TShape;
Shape238: TShape;
Shape239: TShape;
Shape240: TShape;
Label222: TLabel;
Label223: TLabel;
Label224: TLabel;
Label225: TLabel;
Label226: TLabel;
Label227: TLabel;
Label228: TLabel;
Label229: TLabel;
Label230: TLabel;
Label231: TLabel;
Label232: TLabel;
Label233: TLabel;
Label234: TLabel;
Label235: TLabel;
Label236: TLabel;
Label237: TLabel;
Label238: TLabel;
Label239: TLabel;
Label240: TLabel;
Label241: TLabel;
Label242: TLabel;
Label243: TLabel;
Label244: TLabel;
Label245: TLabel;
Label218: TLabel;
SpinEdit1: TSpinEdit;
Label426: TLabel;
Button2: TButton;
SpinEdit3: TSpinEdit;
Label427: TLabel;
CheckBox4: TCheckBox;
Timeout_ms: TSpinEdit;
Label26: TLabel;
ZapisObmen: TCheckBox;
RadioGroup1: TRadioGroup;
RB_3xxx_f_4: TRadioButton;
RB_4xxx_f_3: TRadioButton;
RadioGroup2: TRadioGroup;
RBUINT16: TRadioButton;
RBINT16: TRadioButton;
RBUINT32: TRadioButton;
RBINT32: TRadioButton;
RB16O: TRadioButton;
RBFLOAT32: TRadioButton;
E_Write_4xxxx: TEdit;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure CB_TCP_IPChange(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure IP_addrChange(Sender: TObject);
procedure RBUINT16Click(Sender: TObject);
procedure RBINT16Click(Sender: TObject);
procedure RBUINT32Click(Sender: TObject);
procedure RBINT32Click(Sender: TObject);
procedure RB16OClick(Sender: TObject);
procedure RBFLOAT32Click(Sender: TObject);
procedure E_Write_4xxxxKeyPress(Sender: TObject; var Key: char);
procedure RB_Fn10Change(Sender: TObject);
procedure RB_Fn6Change(Sender: TObject);
procedure StaticText1Click(Sender: TObject);
procedure TCP_Port_SEChange(Sender: TObject);
procedure Timeout_msChange(Sender: TObject);
private
{ Private declarations }
public
ModBusThread: ThreadModB;
procedure TMB;
procedure Out_Last_mess;
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2, Math;
{$R *.dfm}
function CheckSummCRC2_m(s: string): string;
var
Generator: longint;
CRC: longint;
i: integer;
j: integer;
L: integer;
Bit: boolean;
Temp: byte;
CHrab: char;
Lenght: integer;
CRC16, chsumm: string;
begin
CRC16 := '';
Lenght := Length(s);
CRC := 65535;
Generator := 40961;
for i := 1 to Lenght do
begin
CHrab := s[i];
Temp := Ord(CHrab);
CRC := CRC xor Temp;
for j := 1 to 8 do
begin
Bit := True;
L := CRC and 1;
if L = 0 then
Bit := False;
CRC := CRC div 2;
if Bit = True then
CRC := CRC xor Generator;
end; // Next j;
end; // Next i
Str(CRC, s);
CRC16 := Chr(CRC mod 256) + Chr(CRC div 256);
chsumm := CRC16;
CheckSummCRC2_m := chsumm;
end;
function ControlSumm_m(st: string; NomDevInTh: integer): boolean;
var
str: string;
begin
if Length(st) > 2 then
begin
str := st;
Delete(str, length(str) - 2 + 1, 2);
str := str + CheckSummCRC2_m(str);
if str = st then
ControlSumm_m := True
else
ControlSumm_m := False;
end
else
ControlSumm_m := False;
end;
procedure AlarmCheck_m;
// Проверка на отсутсвие ответа или код ошибки
var
RegRab: longint;
S2: string;
CHrab: char;
begin
// Сначала все чисты как ангелы
Alarm := False;
// Form1.Shape1.Brush.Color := clGray ;
Form1.Label311.Caption := ' ';
// Если буфер пуст - устройство не ответило
if sr = '' then
begin
Form1.Shape1000.Brush.Color := clRed;
Form1.Label311.Font.Color := clMaroon;
Form1.Label311.Caption :=
' Нет связи с устройством ';
Alarm := True;
// NubmerReg :=99;
exit;
end;
if sr <> '' then
begin
// Во втором байте - либо код функции, либо код ошибки
CHrab := sr[2];
RegRab := Ord(CHrab);
if RegRab > 16 then
begin
Form1.Shape1000.Brush.Color := clRed;
Str(RegRab, S2);
Form1.Label311.Font.Color := clMaroon;
Form1.Label311.Caption := ' Ошибка устройства ' + S2;
Alarm := True;
end;
end;
if not (Alarm) then
Form1.Shape1000.Brush.Color := clLime;
if not (ControlSumm_m(sr, 0)) then
Form1.Label311.Caption := ' Ошибка контрольной суммы ';
end;
// **** Вывод регистров 4ххх в форму ****
procedure GUI4;
var
SR4: string;
i: integer;
l1: integer;
Lab: TStaticText;
Lab1: TLabel;
znak, Int_temp: integer;
Value: integer;
ValueLongword: longword;
INT1, INT2: integer;
pb: Pointer;
pr: ^single;
fval, fValue: real;
bv, bout1, bv2: TByteVal;
sml_int: smallint;
sml_int1: ^smallint;
begin
for i := 1 to 25 do
begin
l1 := 40000 + Form1.SpinEdit301.Value + i - 1;
Str(l1, SR4);
Lab1 := Form1.FindComponent('Label' + IntToStr(i)) as TLabel;
if Lab <> nil then
Lab1.Caption := SR4;
end;
for i := 1 to Form1.SpinEdit302.Value do
begin
if Type_Reg4XXX = t_UINT16 then
SR4 := IntToStr(Reg4[i]);
znak := 1;
if Type_Reg4XXX = t_INT16 then
begin
sml_int := (Reg4[i] and $FFFF);
SR4 := IntToStr(sml_int);
end;
if Type_Reg4XXX = t_UINT32 then
begin
INT1 := Reg4[i + 1];
INT2 := Reg4[i];
ValueLongword := (INT1 shl 16) + INT2;
if (i mod 2) = 1 then
SR4 := IntToStr(ValueLongword)
else
SR4 := '';
end;
if Type_Reg4XXX = t_INT32 then
begin
INT1 := Reg4[i + 1];
INT2 := Reg4[i];
Value := (((INT1) shl 16) + (INT2 and $FFFF));
if (i mod 2) = 1 then
SR4 := IntToStr(Value)
else
SR4 := '';
end;
if Type_Reg4XXX = t_16O then
begin
INT1 := Reg4[i];
INT1 := INT1 - $8000;
SR4 := IntToStr(INT1);
end;
if Type_Reg4XXX = t_FLOAT32 then
begin
INT1 := Reg4[i + 1];
INT2 := Reg4[i];
bv[2] := (INT1 and $FF);
bv[1] := INT1 shr 8;
bv[4] := (INT2 and $FF);
bv[3] := (INT2 shr 8); {and $FF00}
bv2[1] := bv[4];
bv2[2] := bv[3];
bv2[3] := bv[2];
bv2[4] := bv[1];
try
pb := @bv2[1];
pr := pb;
fval := pr^;
fValue := fval;
except
end;
if (i mod 2) = 1 then
SR4 := FloatToStrf(fValue, ffNumber, 10, 10)
else
SR4 := '';
end;
Lab := Form1.FindComponent('StaticText' + IntToStr(i)) as TStaticText;
if Lab <> nil then
begin
Lab.Color := clInfoBk;
Lab.Caption := SR4;
end;
end;
if form1.SpinEdit302.Value < 125 then
begin
for i := form1.SpinEdit302.Value + 1 to 125 do
begin
Lab := Form1.FindComponent('StaticText' + IntToStr(i)) as TStaticText;
if Lab <> nil then
begin
Lab.Color := clSilver;
Lab.Caption := ' ';
end;
end;
end;
end;
// **** Опрос регистров 4ххх ****
// *** Распаковка нулевых регистров
{
procedure Unpack0;
var
i : integer;
j : integer;
k : integer;
rabreg : integer;
rabreg1 : integer;
ch1 : char;
SRAB : string;
begin
for j := 1 to 15 do
begin
ch1 := sr[j + 3];
rabreg1 := ord(ch1);
str(rabreg1, SRAB);
k := 1;
for i := 1 to 8 do
begin
rabreg := rabreg1 and k;
if rabreg > 0 then
REG0[i + 8 * (j - 1)] := 1;
if rabreg = 0 then
REG0[i + 8 * (j - 1)] := 0;
// Неужели в Delphi отсутствует возведение в степень?
k := k * 2;
end;
end;
end; }
// Вывод 0хххх регистров на экран
procedure GUI0;
var
i: integer;
Lab: TShape;
Lab1: TLabel;
SRAB: string;
SRA1: string;
begin
for i := 1 to form1.SpinEdit107.Value do
begin
Lab := Form1.FindComponent('Shape' + IntToStr(i)) as TShape;
Lab.Brush.Color := clGray;
if REG0[i] = 1 then
Lab.Brush.Color := clLime;
Lab1 := Form1.FindComponent('Label' + IntToStr(i + 900)) as TLabel;
SRAB := IntToStr(Form1.SpinEdit106.Value + i - 1);
if (Form1.SpinEdit106.Value + i - 1) < 1000 then
SRA1 := '00';
if (Form1.SpinEdit106.Value + i - 1) < 100 then
SRA1 := '000';
if (Form1.SpinEdit106.Value + i - 1) < 10 then
SRA1 := '0000';
Lab1.Caption := SRA1 + SRAB;
end;
if form1.SpinEdit107.Value < 120 then
begin
for i := form1.SpinEdit107.Value + 1 to 120 do
begin
Lab := Form1.FindComponent('Shape' + IntToStr(i)) as TShape;
Lab.Brush.Color := clSilver;
Lab1 := Form1.FindComponent('Label' + IntToStr(i + 900)) as TLabel;
Lab1.Caption := ' ';
end;
end;
end;
// ***********************
// Вывод 1хххх регистров на экран
procedure GUI1;
var
i: integer;
Lab: TShape;
Lab1: TLabel;
SRAB: string;
SRA1: string;
begin
for i := 1 to form1.SpinEdit105.Value do
begin
Lab := Form1.FindComponent('Shape' + IntToStr(i + 120)) as TShape;
Lab.Brush.Color := clGray;
if REG1[i] = 1 then
Lab.Brush.Color := clLime;
Lab1 := Form1.FindComponent('Label' + IntToStr(i + 125)) as TLabel;
SRAB := IntToStr(Form1.SpinEdit104.Value + i - 1);
// Переделать
if (Form1.SpinEdit104.Value + i - 1) < 1000 then
SRA1 := '10';
if (Form1.SpinEdit104.Value + i - 1) < 100 then
SRA1 := '100';
if (Form1.SpinEdit104.Value + i - 1) < 10 then
SRA1 := '1000';
Lab1.Caption := SRA1 + SRAB;
end;
if form1.SpinEdit105.Value < 120 then
begin
for i := form1.SpinEdit105.Value + 1 to 120 do
begin
Lab := Form1.FindComponent('Shape' + IntToStr(i + 120)) as TShape;
Lab.Brush.Color := clSilver;
Lab1 := Form1.FindComponent('Label' + IntToStr(i + 125)) as TLabel;
Lab1.Caption := ' ';
end;
end;
end;
// ***********************
// *****Запись регистра 4ххх
procedure TForm1.Button1Click(Sender: TObject);
var
DataOutput: string;
t, INT_T: integer;
sml_int: smallint;
int_temp_lo, int_temp_hi: byte;
znak: integer;
val_int: integer;
val_longint: longint;
INT1: integer;
INT2: integer;
pr_int: ^longint;
L_int: longint;
val_single: single;
pb: Pointer;
int_temp: integer;
begin
NomerReg_write_4xxx := SpinEdit1.Value;
Val_write_4xxx := StrToFloatDef(Form1.E_Write_4xxxx.Text, 0);
end;
// Опрос контроллера по таймеру
procedure TForm1.TMB;
begin
try
ModBus_Prop_Th[1].port := ComboBox1.Text;
ModBus_Prop_Th[1].Skorost := StrToIntDef(ComboBox2.Text, 9600);
ModBus_Prop_Th[1].EON := ComboBox3.Text;
ModBus_Prop_Th[1].KolBit := StrToIntDef(ComboBox4.Text, 8);
;
ModBus_Prop_Th[1].OneOrTwo := StrToIntDef(ComboBox5.Text, 1);
;
;
ModBus_Prop_Th[1].AdressOfUstr := SpinEdit300.Value;
ModBus_Prop_Th[1].NachReg_1xxx := SpinEdit104.Value;
ModBus_Prop_Th[1].DlinaZprosa_1xxx := SpinEdit105.Value;
ModBus_Prop_Th[1].IsOpros_1xxx := CheckBox2.Checked;
ModBus_Prop_Th[1].NachReg_4xxx := SpinEdit301.Value;
ModBus_Prop_Th[1].DlinaZprosa_4xxx := SpinEdit302.Value;
ModBus_Prop_Th[1].IsOpros_4xxx := CheckBox1.Checked;
ModBus_Prop_Th[1].NachReg_0xxx := SpinEdit106.Value;
ModBus_Prop_Th[1].DlinaZprosa_0xxx := SpinEdit107.Value;
ModBus_Prop_Th[1].IsOpros_0xxx := CheckBox3.Checked;
if RB_3xxx_f_4.Checked then
ModBus_Prop_Th[1].Function_Reg_3_or_4 := 4
else
ModBus_Prop_Th[1].Function_Reg_3_or_4 := 3;
except
end;
if CheckBox3.Checked then
if TypeRegOut = 0 then
begin
AlarmCheck_m;
if not alarm then
begin
GUI0;
end;
Alarm := False;
end;
if CheckBox2.Checked then
if TypeRegOut = 1 then
begin
AlarmCheck_m;
if not alarm then
begin
GUI1;
end;
Alarm := False;
end;
if CheckBox1.Checked then
if TypeRegOut = 4 then
begin
AlarmCheck_m;
if not alarm then
begin
GUI4;
end;
Alarm := False;
end;
end;
procedure TForm1.Out_Last_mess;
begin
out_mess_st.Caption := Last_TCP_Mess;
if ModBus_rtu_over_TCP = 1 then
begin
if Is_Connect_socket then
Shp_connect_tcp.Brush.Color := clLime
else
Shp_connect_tcp.Brush.Color := clRed;
end
else
Shp_connect_tcp.Brush.Color := clForm;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
DataOutput: string;
t: integer;
begin
NomerReg_write_0xxx := SpinEdit3.Value;
Val_write_0xxx := CheckBox4.Checked;
end;
procedure TForm1.CB_TCP_IPChange(Sender: TObject);
begin
if CB_TCP_IP.Checked then
ModBus_rtu_over_TCP := 1
else
ModBus_rtu_over_TCP := 0;
end;
procedure TForm1.ComboBox1Change(Sender: TObject);
begin
end;
procedure TForm1.FormClose(Sender: TObject; var CloseAction: TCloseAction);
var
ini: TIniFile;
begin
ini := TIniFile.Create(ExtractFilePath(Application.ExeName) + 'modlook.ini');
ini.WriteInteger('param', 'addrUstr', SpinEdit300.Value);
ini.WriteInteger('param', 'begin1xx', SpinEdit104.Value);
ini.WriteInteger('param', 'begin1xx', SpinEdit104.Value);
ini.WriteInteger('param', 'len1xx', SpinEdit105.Value);
ini.WriteInteger('param', 'begin4xx', SpinEdit301.Value);
ini.WriteInteger('param', 'len4xx', SpinEdit302.Value);
ini.WriteInteger('param', 'begin0xx', SpinEdit106.Value);
ini.WriteInteger('param', 'len0xx', SpinEdit107.Value);
ini.WriteString('param', 'port', ComboBox1.Text);
ini.WriteString('param', 'speed', ComboBox2.Text);
ini.WriteString('param', 'parit', ComboBox3.Text);
ini.WriteString('tcp', 'host', IP_addr.Text);
ini.WriteInteger('tcp', 'port_tcp', TCP_Port_SE.Value);
ini.Free;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
ini: TIniFile;
begin
DecimalSeparator := '.';
Form2.Show;
ModBus_Prop_Th[1].port := ComboBox1.Text;
ModBus_Prop_Th[1].Skorost := StrToIntDef(ComboBox2.Text, 9600);
ModBus_Prop_Th[1].EON := ComboBox3.Text;
ModBus_Prop_Th[1].KolBit := StrToIntDef(ComboBox4.Text, 8);
;
ModBus_Prop_Th[1].OneOrTwo := StrToIntDef(ComboBox5.Text, 1);
;
;
ModBus_Prop_Th[1].AdressOfUstr := SpinEdit300.Value;
ModBus_Prop_Th[1].NachReg_1xxx := SpinEdit104.Value;
ModBus_Prop_Th[1].DlinaZprosa_1xxx := SpinEdit105.Value;
ModBus_Prop_Th[1].IsOpros_1xxx := CheckBox2.Checked;
ModBus_Prop_Th[1].NachReg_4xxx := SpinEdit301.Value;
ModBus_Prop_Th[1].DlinaZprosa_4xxx := SpinEdit302.Value;
ModBus_Prop_Th[1].IsOpros_4xxx := CheckBox1.Checked;
ModBus_Prop_Th[1].NachReg_0xxx := SpinEdit106.Value;
ModBus_Prop_Th[1].DlinaZprosa_0xxx := SpinEdit107.Value;
ModBus_Prop_Th[1].IsOpros_0xxx := CheckBox3.Checked;
ModBusThread := ThreadModB.Create(True);
;
ModBusThread.FreeOnTerminate := True;
ModBusThread.Priority := tpLower;
ModBusThread.Resume;
ini := TIniFile.Create(ExtractFilePath(Application.ExeName) + 'modlook.ini');
SpinEdit300.Value := ini.ReadInteger('param', 'addrUstr', 1);
SpinEdit104.Value := ini.ReadInteger('param', 'begin1xx', 1);
SpinEdit105.Value := ini.ReadInteger('param', 'len1xx', 120);
SpinEdit301.Value := ini.ReadInteger('param', 'begin4xx', 1);
SpinEdit302.Value := ini.ReadInteger('param', 'len4xx', 120);
SpinEdit106.Value := ini.ReadInteger('param', 'begin0xx', 1);
SpinEdit107.Value := ini.ReadInteger('param', 'len0xx', 120);
ComboBox1.Text := ini.ReadString('param', 'port', '\\.\COM1');
ComboBox2.Text := ini.ReadString('param', 'speed', '9600');
ComboBox3.Text := ini.ReadString('param', 'parit', 'N');
IP_addr.Text := ini.ReadString('tcp', 'host', '127.0.0.1');
TCP_Port_SE.Value := ini.ReadInteger('tcp', 'port_tcp', 4001);
Host_Thread := IP_addr.Text;
Port_Thread := TCP_Port_SE.Value;
ini.Free;
end;
procedure TForm1.IP_addrChange(Sender: TObject);
begin
Host_Thread := IP_addr.Text;
end;
procedure TForm1.RBUINT16Click(Sender: TObject);
begin
Type_Reg4XXX := t_UINT16;
end;
procedure TForm1.RBINT16Click(Sender: TObject);
begin
Type_Reg4XXX := t_INT16;
end;
procedure TForm1.RBUINT32Click(Sender: TObject);
begin
Type_Reg4XXX := t_UINT32;
end;
procedure TForm1.RBINT32Click(Sender: TObject);
begin
Type_Reg4XXX := t_INT32;
end;
procedure TForm1.RB16OClick(Sender: TObject);
begin
Type_Reg4XXX := t_16O;
end;
procedure TForm1.RBFLOAT32Click(Sender: TObject);
begin
Type_Reg4XXX := t_FLOAT32;
end;
procedure TForm1.E_Write_4xxxxKeyPress(Sender: TObject; var Key: char);
begin
case key of
'0'..'9', '-', #8: ;
'.', ',':
begin
key := DecimalSeparator;
if Pos(DecimalSeparator, E_Write_4xxxx.Text) <> 0 then
key := char(0);
end;
else
key := char(0);
end;
end;
procedure TForm1.RB_Fn10Change(Sender: TObject);
begin
if RB_Fn10.Checked then
Funct_write_4xxx := 10;
end;
procedure TForm1.RB_Fn6Change(Sender: TObject);
begin
if RB_Fn6.Checked then
Funct_write_4xxx := 6;
end;
procedure TForm1.StaticText1Click(Sender: TObject);
begin
end;
procedure TForm1.TCP_Port_SEChange(Sender: TObject);
begin
Port_Thread := TCP_Port_SE.Value;
end;
procedure TForm1.Timeout_msChange(Sender: TObject);
begin
Timeout_M := Timeout_ms.Value;
end;
end.
|
unit Main;
// Install OpenSSL libraries and delete the IDOpenSSLSetLibPath-line below,
// or extract the dlls libeay32.dll and ssleay32.dll to project root.
// Add client certificate and key to project root as client.crt and client.key.
// Modify URL as needed for the service.
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TfMain = class(TForm)
bStart: TButton;
mResult: TMemo;
edIP: TEdit;
Label1: TLabel;
procedure bStartClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
fMain: TfMain;
implementation
{$R *.dfm}
uses IdHTTP, IdSSLOpenSSL, IdSSLOpenSSLHeaders;
procedure TfMain.bStartClick(Sender: TObject);
var
S: TStringList;
M: TStream;
HTTP: TIdHTTP;
IOHandler: TIdSSLIOHandlerSocketOpenSSL;
begin
// Use OpenSSL libraries from project root
IdSSLOpenSSLHeaders.IdOpenSSLSetLibPath(GetCurrentDir());
S := TStringList.Create;
M := TMemoryStream.Create;
IOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(self);
HTTP := TIdHTTP.Create(self);
try
// Set client cert and key for connection
IOHandler.SSLOptions.CertFile := 'client.crt';
IOHandler.SSLOptions.KeyFile := 'client.key';
HTTP.IOHandler := IOHandler;
try
// Actual HTTP GET
HTTP.Get(edIP.Text, M);
except
on E: Exception do
begin
mResult.Lines.Add('Error with connection: ' + E.Message)
end;
end;
mResult.Lines.Add(Format('Response Code: %d', [HTTP.ResponseCode]));
mResult.Lines.Add(Format('Response Text: %s', [HTTP.ResponseText]));
M.Position := 0;
S.LoadFromStream(M);
mResult.Lines.AddStrings(S);
finally
S.Free;
M.Free;
IOHandler.Free;
HTTP.Free;
end;
end;
end.
|
unit FGX.ActiveNetworkInfo.Android;
interface
uses Android.Api.Network;
type
TActiveNetworkInfo = class
private
class var FJConnectivityManager: JConnectivityManager;
class constructor Create;
class function GetNetwork: JNetwork;
public
/// <summary>Check permission "android.permission.ACCESS_NETWORK_STATE"</summary>
class function CheckPermission: Boolean;
/// <summary>Indicates whether network connectivity exists and it is possible to establish connections and pass data.</summary>
class function IsConnected: Boolean;
/// <summary>Is Wi-Fi connection?</summary>
class function IsWifi: Boolean;
/// <summary>Is Mobile connection?</summary>
class function IsMobile: Boolean;
/// <summary>Is VPN connection?</summary>
end;
implementation
uses Java.Bridge,
System.SysUtils,
Androidapi.JNI,
Android.Api.JavaTypes,
Android.Api.ActivityAndView,
FGX.Platform.Android,
FGX.Helpers.Android,
FGX.Permissions;
{ TActiveNetworkInfo }
class function TActiveNetworkInfo.CheckPermission: Boolean;
const
ACCESS_NETWORK_STATE = 'android.permission.ACCESS_NETWORK_STATE';
var
LPermission: TArray<string>;
LPermissions: TArray<TfgPermissionInfo>;
LItem: TfgPermissionInfo;
LCheckResult: TPermissionCheckResult;
begin
LPermission := [ACCESS_NETWORK_STATE];
LPermissions := TfgPermissionService.CheckPermissions(LPermission);
LCheckResult := TPermissionCheckResult.Denied;
for LItem in LPermissions do
begin
if (LItem.PermissionId = ACCESS_NETWORK_STATE) then
begin
LCheckResult := LItem.CheckResult;
Break;
end;
end;
Result := LCheckResult = TPermissionCheckResult.Granted;
end;
class constructor TActiveNetworkInfo.Create;
begin
FJConnectivityManager := nil;
if CheckPermission then
FJConnectivityManager := TJConnectivityManager.Wrap
(TfgAndroidHelper.Context.getSystemService(TJContext.CONNECTIVITY_SERVICE));
end;
class function TActiveNetworkInfo.GetNetwork: JNetwork;
var
Network: JNetwork;
begin
Result := nil;
Create;
if FJConnectivityManager <> nil then
begin
Network := FJConnectivityManager.getActiveNetwork();
if Network <> nil then
Result := Network;
end;
end;
class function TActiveNetworkInfo.IsConnected: Boolean;
begin
Result := IsMobile or IsWifi;
end;
class function TActiveNetworkInfo.IsMobile: Boolean;
var
Network: JNetwork;
NetworkCapabilities: JNetworkCapabilities;
begin
Network := GetNetwork;
if Network <> nil then
begin
NetworkCapabilities := FJConnectivityManager.getNetworkCapabilities(Network);
Result := (NetworkCapabilities <> nil) and (NetworkCapabilities.hasTransport(TJNetworkCapabilities.TRANSPORT_CELLULAR()));
end
else
Result := False;
end;
class function TActiveNetworkInfo.IsWifi: Boolean;
var
Network: JNetwork;
NetworkCapabilities: JNetworkCapabilities;
begin
Network := GetNetwork;
if Network <> nil then
begin
NetworkCapabilities := FJConnectivityManager.getNetworkCapabilities(Network);
Result := (NetworkCapabilities <> nil) and (NetworkCapabilities.hasTransport(TJNetworkCapabilities.TRANSPORT_WIFI()));
end
else
Result := False;
end;
end.
|
program Lab2_Var9;
const x0 = 2.5; y0 = 4.0; a = 2.5; b = 4.0;
var x, y, vx, vy :Real;
begin
writeln('Write a point:');
readln(x, y);
vx := x - x0;
vy := y - y0;
if (vx >= 0.0) and (vy >= -vx) and (vx*vx/(a*a) + vy*vy/(b*b) <= 1.0)
then
begin
writeln('Inside');
end
else
writeln('Outside');
end.
|
unit InfoCANCELTable;
interface
uses
Classes, DB, DBISAMTb, SysUtils, DBISAMTableAU, DataBuf;
type
TInfoCANCELRecord = record
PTable: String[2];
PDays: Integer;
PPr_PCT: String[168];
PSr_PCT: String[168];
PModCount: SmallInt;
End;
TInfoCANCELClass2 = class
public
PTable: String[2];
PDays: Integer;
PPr_PCT: String[168];
PSr_PCT: String[168];
PModCount: SmallInt;
End;
// function CtoRInfoCANCEL(AClass:TInfoCANCELClass):TInfoCANCELRecord;
// procedure RtoCInfoCANCEL(ARecord:TInfoCANCELRecord;AClass:TInfoCANCELClass);
TInfoCANCELBuffer = class(TDataBuf)
protected
function PtrIndex(Index:integer):Pointer;override;
public
Data: TInfoCANCELRecord;
function FieldNameToIndex(s:string):integer;override;
function FieldType(index:integer):TFieldType;override;
end;
TEIInfoCANCEL = (InfoCANCELPrimaryKey);
TInfoCANCELTable = class( TDBISAMTableAU )
private
FDFTable: TStringField;
FDFDays: TIntegerField;
FDFPr_PCT: TStringField;
FDFSr_PCT: TStringField;
FDFModCount: TSmallIntField;
procedure SetPTable(const Value: String);
function GetPTable:String;
procedure SetPDays(const Value: Integer);
function GetPDays:Integer;
procedure SetPPr_PCT(const Value: String);
function GetPPr_PCT:String;
procedure SetPSr_PCT(const Value: String);
function GetPSr_PCT:String;
procedure SetPModCount(const Value: SmallInt);
function GetPModCount:SmallInt;
procedure SetEnumIndex(Value: TEIInfoCANCEL);
function GetEnumIndex: TEIInfoCANCEL;
protected
procedure CreateFields; reintroduce;
procedure SetActive(Value: Boolean); override;
procedure LoadFieldDefs(AStringList:TStringList);override;
procedure LoadIndexDefs(AStringList:TStringList);override;
public
function GetDataBuffer:TInfoCANCELRecord;
procedure StoreDataBuffer(ABuffer:TInfoCANCELRecord);
property DFTable: TStringField read FDFTable;
property DFDays: TIntegerField read FDFDays;
property DFPr_PCT: TStringField read FDFPr_PCT;
property DFSr_PCT: TStringField read FDFSr_PCT;
property DFModCount: TSmallIntField read FDFModCount;
property PTable: String read GetPTable write SetPTable;
property PDays: Integer read GetPDays write SetPDays;
property PPr_PCT: String read GetPPr_PCT write SetPPr_PCT;
property PSr_PCT: String read GetPSr_PCT write SetPSr_PCT;
property PModCount: SmallInt read GetPModCount write SetPModCount;
published
property Active write SetActive;
property EnumIndex: TEIInfoCANCEL read GetEnumIndex write SetEnumIndex;
end; { TInfoCANCELTable }
TInfoCANCELQuery = class( TDBISAMQueryAU )
private
FDFTable: TStringField;
FDFDays: TIntegerField;
FDFPr_PCT: TStringField;
FDFSr_PCT: TStringField;
FDFModCount: TSmallIntField;
procedure SetPTable(const Value: String);
function GetPTable:String;
procedure SetPDays(const Value: Integer);
function GetPDays:Integer;
procedure SetPPr_PCT(const Value: String);
function GetPPr_PCT:String;
procedure SetPSr_PCT(const Value: String);
function GetPSr_PCT:String;
procedure SetPModCount(const Value: SmallInt);
function GetPModCount:SmallInt;
protected
procedure CreateFields; reintroduce;
procedure SetActive(Value: Boolean); override;
public
function GetDataBuffer:TInfoCANCELRecord;
procedure StoreDataBuffer(ABuffer:TInfoCANCELRecord);
property DFTable: TStringField read FDFTable;
property DFDays: TIntegerField read FDFDays;
property DFPr_PCT: TStringField read FDFPr_PCT;
property DFSr_PCT: TStringField read FDFSr_PCT;
property DFModCount: TSmallIntField read FDFModCount;
property PTable: String read GetPTable write SetPTable;
property PDays: Integer read GetPDays write SetPDays;
property PPr_PCT: String read GetPPr_PCT write SetPPr_PCT;
property PSr_PCT: String read GetPSr_PCT write SetPSr_PCT;
property PModCount: SmallInt read GetPModCount write SetPModCount;
published
property Active write SetActive;
end; { TInfoCANCELTable }
procedure Register;
implementation
procedure TInfoCANCELTable.CreateFields;
begin
FDFTable := CreateField( 'Table' ) as TStringField;
FDFDays := CreateField( 'Days' ) as TIntegerField;
FDFPr_PCT := CreateField( 'Pr_PCT' ) as TStringField;
FDFSr_PCT := CreateField( 'Sr_PCT' ) as TStringField;
FDFModCount := CreateField( 'ModCount' ) as TSmallIntField;
end; { TInfoCANCELTable.CreateFields }
procedure TInfoCANCELTable.SetActive(Value: Boolean);
begin
inherited SetActive(Value);
if Active then
CreateFields;
end; { TInfoCANCELTable.SetActive }
procedure TInfoCANCELTable.SetPTable(const Value: String);
begin
DFTable.Value := Value;
end;
function TInfoCANCELTable.GetPTable:String;
begin
result := DFTable.Value;
end;
procedure TInfoCANCELTable.SetPDays(const Value: Integer);
begin
DFDays.Value := Value;
end;
function TInfoCANCELTable.GetPDays:Integer;
begin
result := DFDays.Value;
end;
procedure TInfoCANCELTable.SetPPr_PCT(const Value: String);
begin
DFPr_PCT.Value := Value;
end;
function TInfoCANCELTable.GetPPr_PCT:String;
begin
result := DFPr_PCT.Value;
end;
procedure TInfoCANCELTable.SetPSr_PCT(const Value: String);
begin
DFSr_PCT.Value := Value;
end;
function TInfoCANCELTable.GetPSr_PCT:String;
begin
result := DFSr_PCT.Value;
end;
procedure TInfoCANCELTable.SetPModCount(const Value: SmallInt);
begin
DFModCount.Value := Value;
end;
function TInfoCANCELTable.GetPModCount:SmallInt;
begin
result := DFModCount.Value;
end;
procedure TInfoCANCELTable.LoadFieldDefs(AStringList: TStringList);
begin
inherited;
with AstringList do
begin
Add('Table, String, 2, N');
Add('Days, Integer, 0, N');
Add('Pr_PCT, String, 168, N');
Add('Sr_PCT, String, 168, N');
Add('ModCount, SmallInt, 0, N');
end;
end;
procedure TInfoCANCELTable.LoadIndexDefs(AStringList: TStringList);
begin
inherited;
with AstringList do
begin
Add('PrimaryKey, Table;Days, Y, Y, N, N');
end;
end;
procedure TInfoCANCELTable.SetEnumIndex(Value: TEIInfoCANCEL);
begin
case Value of
InfoCANCELPrimaryKey : IndexName := '';
end;
end;
function TInfoCANCELTable.GetDataBuffer:TInfoCANCELRecord;
var buf: TInfoCANCELRecord;
begin
fillchar(buf, sizeof(buf), 0);
buf.PTable := DFTable.Value;
buf.PDays := DFDays.Value;
buf.PPr_PCT := DFPr_PCT.Value;
buf.PSr_PCT := DFSr_PCT.Value;
buf.PModCount := DFModCount.Value;
result := buf;
end;
procedure TInfoCANCELTable.StoreDataBuffer(ABuffer:TInfoCANCELRecord);
begin
DFTable.Value := ABuffer.PTable;
DFDays.Value := ABuffer.PDays;
DFPr_PCT.Value := ABuffer.PPr_PCT;
DFSr_PCT.Value := ABuffer.PSr_PCT;
DFModCount.Value := ABuffer.PModCount;
end;
function TInfoCANCELTable.GetEnumIndex: TEIInfoCANCEL;
var iname : string;
begin
result := InfoCANCELPrimaryKey;
iname := uppercase(indexname);
if iname = '' then result := InfoCANCELPrimaryKey;
end;
procedure TInfoCANCELQuery.CreateFields;
begin
FDFTable := CreateField( 'Table' ) as TStringField;
FDFDays := CreateField( 'Days' ) as TIntegerField;
FDFPr_PCT := CreateField( 'Pr_PCT' ) as TStringField;
FDFSr_PCT := CreateField( 'Sr_PCT' ) as TStringField;
FDFModCount := CreateField( 'ModCount' ) as TSmallIntField;
end; { TInfoCANCELQuery.CreateFields }
procedure TInfoCANCELQuery.SetActive(Value: Boolean);
begin
inherited SetActive(Value);
if Active then
CreateFields;
end; { TInfoCANCELQuery.SetActive }
procedure TInfoCANCELQuery.SetPTable(const Value: String);
begin
DFTable.Value := Value;
end;
function TInfoCANCELQuery.GetPTable:String;
begin
result := DFTable.Value;
end;
procedure TInfoCANCELQuery.SetPDays(const Value: Integer);
begin
DFDays.Value := Value;
end;
function TInfoCANCELQuery.GetPDays:Integer;
begin
result := DFDays.Value;
end;
procedure TInfoCANCELQuery.SetPPr_PCT(const Value: String);
begin
DFPr_PCT.Value := Value;
end;
function TInfoCANCELQuery.GetPPr_PCT:String;
begin
result := DFPr_PCT.Value;
end;
procedure TInfoCANCELQuery.SetPSr_PCT(const Value: String);
begin
DFSr_PCT.Value := Value;
end;
function TInfoCANCELQuery.GetPSr_PCT:String;
begin
result := DFSr_PCT.Value;
end;
procedure TInfoCANCELQuery.SetPModCount(const Value: SmallInt);
begin
DFModCount.Value := Value;
end;
function TInfoCANCELQuery.GetPModCount:SmallInt;
begin
result := DFModCount.Value;
end;
function TInfoCANCELQuery.GetDataBuffer:TInfoCANCELRecord;
var buf: TInfoCANCELRecord;
begin
fillchar(buf, sizeof(buf), 0);
buf.PTable := DFTable.Value;
buf.PDays := DFDays.Value;
buf.PPr_PCT := DFPr_PCT.Value;
buf.PSr_PCT := DFSr_PCT.Value;
buf.PModCount := DFModCount.Value;
result := buf;
end;
procedure TInfoCANCELQuery.StoreDataBuffer(ABuffer:TInfoCANCELRecord);
begin
DFTable.Value := ABuffer.PTable;
DFDays.Value := ABuffer.PDays;
DFPr_PCT.Value := ABuffer.PPr_PCT;
DFSr_PCT.Value := ABuffer.PSr_PCT;
DFModCount.Value := ABuffer.PModCount;
end;
(********************************************)
(************ Register Component ************)
(********************************************)
procedure Register;
begin
RegisterComponents( 'Info Tables', [ TInfoCANCELTable, TInfoCANCELQuery, TInfoCANCELBuffer ] );
end; { Register }
function TInfoCANCELBuffer.FieldNameToIndex(s:string):integer;
const flist:array[1..5] of string = ('TABLE','DAYS','PR_PCT','SR_PCT','MODCOUNT' );
var x : integer;
begin
s := uppercase(s);
x := 1;
while (x <= 5) and (flist[x] <> s) do inc(x);
if x <= 5 then result := x else result := 0;
end;
function TInfoCANCELBuffer.FieldType(index:integer):TFieldType;
begin
result := ftUnknown;
case index of
1 : result := ftString;
2 : result := ftInteger;
3 : result := ftString;
4 : result := ftString;
5 : result := ftSmallInt;
end;
end;
function TInfoCANCELBuffer.PtrIndex(index:integer):Pointer;
begin
result := nil;
case index of
1 : result := @Data.PTable;
2 : result := @Data.PDays;
3 : result := @Data.PPr_PCT;
4 : result := @Data.PSr_PCT;
5 : result := @Data.PModCount;
end;
end;
end.
|
{ RxCloseFormValidator unit
Copyright (C) 2005-2013 Lagunov Aleksey alexs@yandex.ru and Lazarus team
original conception from rx library for Delphi (c)
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version with the following modification:
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent modules,and
to copy and distribute the resulting executable under terms of your choice,
provided that you also meet, for each linked independent module, the terms
and conditions of the license of that module. An independent module is a
module which is not derived from or based on this library. If you modify
this library, you may extend this exception to your version of the library,
but you are not obligated to do so. If you do not wish to do so, delete this
exception statement from your 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 Library General Public License
for more details.
You should have received a copy of the GNU Library General Public License
along with this library; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
}
unit RxCloseFormValidator;
{$I rx.inc}
interface
uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, DB;
type
TRxCloseFormValidator = class;
TValidateEvent = procedure(AOwner:TRxCloseFormValidator; AControl:TWinControl; var Validate:boolean) of object;
{ TValidateItem }
TValidateItem = class(TCollectionItem)
private
FControl: TWinControl;
FEnabled: boolean;
FFieldCaption: string;
FOnValidate: TValidateEvent;
procedure SetControl(AValue: TWinControl);
procedure SetEnabled(AValue: boolean);
procedure SetFieldCaption(AValue: string);
function DBComponentField:TField;
protected
function GetDisplayName: string; override;
public
constructor Create(ACollection: TCollection); override;
destructor Destroy; override;
function CheckClose(AForm:TCustomForm):boolean;
function ErrorMessage:string;
procedure SetFocus;
published
property Control:TWinControl read FControl write SetControl;
property Enabled:boolean read FEnabled write SetEnabled default true;
property FieldCaption:string read FFieldCaption write SetFieldCaption;
property OnValidate:TValidateEvent read FOnValidate write FOnValidate;
end;
{ TValidateItems }
TValidateItems = class(TOwnedCollection)
private
function GetItems(Index: Integer): TValidateItem;
procedure SetItems(Index: Integer; AValue: TValidateItem);
public
property Items[Index: Integer]: TValidateItem read GetItems write SetItems; default;
end;
{ TRxCloseFormValidator }
TRxCloseFormValidator = class(TComponent)
private
FErrorMsgCaption: string;
FIgnoreDisabled: boolean;
FOnCloseQuery : TCloseQueryEvent;
FItems:TValidateItems;
procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
function GetItems: TValidateItems;
procedure SetCloseQueryHandler;
procedure SetItems(AValue: TValidateItems);
protected
procedure Notification(AComponent: TComponent;
Operation: TOperation); override;
procedure Loaded; override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function CheckCloseForm:boolean;
function ByControl(AControl: TWinControl):TValidateItem;
published
property ErrorMsgCaption:string read FErrorMsgCaption write FErrorMsgCaption;
property Items:TValidateItems read GetItems write SetItems;
property IgnoreDisabled:boolean read FIgnoreDisabled write FIgnoreDisabled default false;
end;
implementation
uses LCLType, StdCtrls, DbCtrls, typinfo, ComCtrls, ExtCtrls, rxconst;
{ TValidateItems }
function TValidateItems.GetItems(Index: Integer): TValidateItem;
begin
result := TValidateItem( inherited Items[Index] );
end;
procedure TValidateItems.SetItems(Index: Integer; AValue: TValidateItem);
begin
Items[Index].Assign( AValue );
end;
{constructor TValidateItems.Create;
begin
inherited Create(TValidateItem);
end;}
{ TValidateItem }
procedure TValidateItem.SetControl(AValue: TWinControl);
var
i:integer;
OwnForm, P:TComponent;
F:TField;
begin
if FControl=AValue then Exit;
FControl:=AValue;
if Assigned(FControl) and (FFieldCaption = '') then
begin
//Установим название поля по текст компоненты
if FControl is TCustomRadioGroup then
FFieldCaption:=TCustomRadioGroup(FControl).Caption
else
if FControl is TCustomCheckBox then
FFieldCaption:=TCustomCheckBox(FControl).Caption
else
if Assigned(FControl.Owner) then
begin
OwnForm:=FControl.Owner;
//Попробуем найти название поле - по тексту метки, которая связана с данным полем
for i:=0 to OwnForm.ComponentCount-1 do
begin
P:=OwnForm.Components[i];
if P is TLabel then
if TLabel(P).FocusControl = FControl then
begin
FFieldCaption:=TLabel(P).Caption;
break;
end;
end;
end;
if FFieldCaption = '' then
begin
F:=DBComponentField;
if Assigned(F) then
FFieldCaption:=F.DisplayLabel;
end;
end
end;
procedure TValidateItem.SetEnabled(AValue: boolean);
begin
if FEnabled=AValue then Exit;
FEnabled:=AValue;
end;
procedure TValidateItem.SetFieldCaption(AValue: string);
begin
if FFieldCaption=AValue then Exit;
FFieldCaption:=AValue;
end;
function TValidateItem.DBComponentField: TField;
var
P:TObject;
PI1, PI2:PPropInfo;
FiName:string;
DS:TDataSet;
begin
Result:=nil;
if not Assigned(FControl) then exit;
//Сначала проверим - вдруги это завязки на работу с БД
PI1:=GetPropInfo(Control, 'DataSource');
PI2:=GetPropInfo(Control, 'DataField');
if Assigned(PI1) and Assigned(PI2) then
begin
//Точно - БД
P:=GetObjectProp(Control, 'DataSource');
FiName:=GetPropValue(Control, 'DataField');
if Assigned(P) and (FiName<>'') then
begin
DS:=(P as TDataSource).DataSet;
if Assigned(DS) then
Result:=DS.FieldByName(FiName);
end;
end
end;
function TValidateItem.GetDisplayName: string;
begin
if Assigned(FControl) then
begin
if FEnabled then
Result:=FControl.Name + ' - validate'
else
Result:=FControl.Name + ' - disabled'
end
else
Result:=inherited GetDisplayName;
end;
constructor TValidateItem.Create(ACollection: TCollection);
begin
inherited Create(ACollection);
FEnabled:=true;
end;
destructor TValidateItem.Destroy;
begin
inherited Destroy;
end;
function TValidateItem.CheckClose(AForm: TCustomForm): boolean;
var
P:TObject;
PI1, PI2:PPropInfo;
FiName:string;
DS:TDataSet;
begin
Result:=true;
if not Assigned(FControl) then exit;
if (not FControl.Enabled) and (TRxCloseFormValidator(TValidateItems(Collection).Owner).IgnoreDisabled) then
exit;
if Assigned(FOnValidate) then
FOnValidate( TRxCloseFormValidator(TValidateItems(Collection).Owner), FControl, Result)
else
begin
if FControl = AForm.ActiveControl then
begin
AForm.SelectNext(FControl, true, true);
end;
//Сначала проверим - вдруги это завязки на работу с БД
PI1:=GetPropInfo(Control, 'DataSource');
PI2:=GetPropInfo(Control, 'DataField');
if Assigned(PI1) and Assigned(PI2) then
begin
//Точно - БД
//Проверка выполняется если только указан источник данных и поле в нём
P:=GetObjectProp(Control, 'DataSource');
FiName:=GetPropValue(Control, 'DataField');
if Assigned(P) and (FiName<>'') then
begin
DS:=(P as TDataSource).DataSet;
if Assigned(DS) then
Result:=not DS.FieldByName(FiName).IsNull;
end;
end
else
if Control is TCustomEdit then
Result:=TCustomEdit(Control).Text<>'';
end;
end;
function TValidateItem.ErrorMessage: string;
begin
Result:=Format(sReqValue, [FFieldCaption]);
end;
procedure TValidateItem.SetFocus;
var
P:TWinControl;
begin
if FControl is TWinControl then
begin
P:=TWinControl(FControl).Parent;
//Необходимо обработать случай нахождения компоненты на PageControl-e
while Assigned(P) and not (P is TCustomForm) do
begin
if P is TTabSheet then
TTabSheet(P).PageControl.ActivePage:=TTabSheet(P);
P:=P.Parent;
end;
TWinControl(FControl).SetFocus;
end;
end;
{ TRxCloseFormValidator }
procedure TRxCloseFormValidator.FormCloseQuery(Sender: TObject;
var CanClose: boolean);
begin
if Sender is TCustomForm then
begin
if TForm(Sender).ModalResult = mrOk then
begin
if CanClose and Assigned(FOnCloseQuery) then
FOnCloseQuery(Sender, CanClose);
if CanClose then
CanClose:=CheckCloseForm;
end;
end;
end;
function TRxCloseFormValidator.CheckCloseForm: boolean;
var
i:integer;
F:TComponent;
begin
F:=Owner;
while Assigned(F) and not (F is TCustomForm) do
F:=F.Owner;
Result:=false;
if not Assigned(F) then exit;
for i:=0 to FItems.Count-1 do
begin
if FItems[i].Enabled and (not FItems[i].CheckClose(F as TCustomForm)) then
begin
FItems[i].SetFocus;
Application.MessageBox(PChar(FItems[i].ErrorMessage), PChar(FErrorMsgCaption), MB_OK + MB_ICONERROR);
exit;
end;
end;
Result:=true;
end;
function TRxCloseFormValidator.ByControl(AControl: TWinControl): TValidateItem;
var
i:integer;
begin
Result:=nil;
for i:=0 to FItems.Count - 1 do
begin
if FItems[i].FControl = AControl then
begin
Result:=FItems[i];
exit;
end;
end;
raise Exception.CreateFmt(sExptControlNotFound, [Name]);
end;
function TRxCloseFormValidator.GetItems: TValidateItems;
begin
Result:=FItems;
end;
procedure TRxCloseFormValidator.SetCloseQueryHandler;
begin
if (csDesigning in ComponentState) or (not Assigned(Owner)) then exit;
if Owner is TCustomForm then
begin
FOnCloseQuery:=TForm(Owner).OnCloseQuery;
TForm(Owner).OnCloseQuery:=@FormCloseQuery;
end;
end;
procedure TRxCloseFormValidator.SetItems(AValue: TValidateItems);
begin
FItems.Assign(AValue);
end;
procedure TRxCloseFormValidator.Notification(AComponent: TComponent;
Operation: TOperation);
var
i:integer;
begin
inherited Notification(AComponent, Operation);
if AComponent = Self then exit;
if Operation = opRemove then
begin
for i:=0 to FItems.Count - 1 do
if FItems[i].Control = AComponent then
FItems[i].Control := nil;
end;
end;
procedure TRxCloseFormValidator.Loaded;
begin
inherited Loaded;
SetCloseQueryHandler;
end;
constructor TRxCloseFormValidator.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FErrorMsgCaption:=sCloseValidError;
FItems:=TValidateItems.Create(Self, TValidateItem);
end;
destructor TRxCloseFormValidator.Destroy;
begin
FreeAndNil(FItems);
inherited Destroy;
end;
end.
|
unit DelForExTestFiles;
{$OPTIMIZATION off}
interface
uses
Classes,
SysUtils,
TestFrameWork,
GX_CodeFormatterTypes,
GX_CodeFormatterSettings,
GX_CodeFormatterDefaultSettings,
GX_CodeFormatterEngine,
GX_GenericUtils;
type
TTestTestfiles = class(TTestCase)
private
FFormatter: TCodeFormatterEngine;
procedure TrimTrailingCrLf(_sl: TGxUnicodeStringList);
procedure TestFile(const _Filename: string; _AllowFailure: Boolean = False);
protected
function GetFormatSettings: TCodeFormatterEngineSettings; virtual; abstract;
function GetResultDir: string; virtual; abstract;
function GetConfigDirBS: string;
procedure SetUp; override;
procedure TearDown; override;
published
procedure testAbstractSealedClass;
procedure testAngledBrackets;
procedure testArabic;
procedure testAsm;
procedure testAsmProblem1;
procedure testAssemblerNewlines;
procedure testCharList;
procedure testClassVar;
procedure testCommentEnd;
procedure testCompilerDirectives;
procedure testConstSet;
procedure testConstSetWithComment;
procedure testConstSetWithCommentAtEnd;
procedure testControlChars;
procedure testDisableFormatComment;
procedure testDotFloat;
procedure testElseAtEnd;
procedure testEmptyProgram;
procedure testEmptyStringAssignment;
procedure testEmptyUnit;
procedure testFormula;
procedure testHashCharStrings;
procedure testHexNumbers;
procedure testIfdefs;
procedure testIfElseendif;
procedure testIfThenElse;
procedure testIfThenTry;
procedure testIndentComment;
procedure testJustOpeningComment;
procedure testJustOpeningStarCommentInAsm;
procedure testConstVar;
procedure testLargeFile;
procedure testOperatorOverloading;
procedure testQuotesError;
procedure testRecordMethod;
procedure testSingleElse;
procedure testSlashCommentToCurly;
procedure testStarCommentAtEol;
procedure testStrictVisibility;
procedure testStringWithSingleQuotes;
procedure testTabBeforeEndInAsm;
procedure testTripleQuotes;
procedure testUnmatchedElse;
procedure testUnmatchedEndif;
procedure testUnmatchedIfdef;
procedure testUnterminatedString;
procedure testClassProperties;
procedure testClassProperties2;
procedure testClassProperties3;
procedure testNestedClass;
procedure testNestedClass2;
procedure testNestedClass3;
procedure testNestedClass4;
procedure testNestedClass5;
procedure testNestedClass6;
procedure testClassInImplementation;
procedure testGenericClass;
procedure testGenericClass2;
procedure testfileGenericCreate;
procedure testfileFakeGenericCreate;
procedure testUsesWithComment;
procedure testTypeOf;
procedure testNestedEventType;
procedure TestNoFeedAfterThen;
procedure TestNoFeedAfterDo;
procedure TestUnicode;
procedure testAnonymousCurrentlyFails;
procedure testCurlyHalfCommentEndCurrentlyFails;
procedure testIfThenElse2CurrentlyFails;
procedure testComplexCurrentlyFails;
end;
type
TTestFilesHeadworkFormatting = class(TTestTestfiles)
protected
function GetFormatSettings: TCodeFormatterEngineSettings; override;
function GetResultDir: string; override;
published
end;
type
TTestFilesBorlandFormatting = class(TTestTestfiles)
protected
function GetFormatSettings: TCodeFormatterEngineSettings; override;
function GetResultDir: string; override;
end;
type
TTestFilesDelforFormatting = class(TTestTestfiles)
protected
function GetFormatSettings: TCodeFormatterEngineSettings; override;
function GetResultDir: string; override;
end;
type
TTestFilesDefaultFormatting = class(TTestTestfiles)
protected
function GetFormatSettings: TCodeFormatterEngineSettings; override;
function GetResultDir: string; override;
end;
type
TTestFilesTwmFormatting = class(TTestTestfiles)
protected
function GetFormatSettings: TCodeFormatterEngineSettings; override;
function GetResultDir: string; override;
end;
type
TTestFilesSpecial = class(TTestFilesTwmFormatting)
protected
function GetFormatSettings: TCodeFormatterEngineSettings; override;
function GetResultDir: string; override;
end;
implementation
uses
Dialogs,
GX_CodeFormatterConfigHandler;
{ TTestTestfiles }
function TTestTestfiles.GetConfigDirBS: string;
begin
Result := '..\release\';
end;
procedure TTestTestfiles.SetUp;
var
Settings: TCodeFormatterEngineSettings;
begin
inherited;
Settings := GetFormatSettings;
FFormatter := TCodeFormatterEngine.Create;
FFormatter.Settings.Settings := Settings;
end;
procedure TTestTestfiles.TearDown;
begin
inherited;
FFormatter.Free;
end;
procedure TTestTestfiles.TrimTrailingCrLf(_sl: TGxUnicodeStringList);
var
cnt: Integer;
begin
cnt := _sl.Count;
while cnt > 0 do begin
if _sl[cnt - 1] <> '' then
Exit;
Dec(cnt);
_sl.Delete(cnt);
end;
end;
type
EFileDoesNotExist = class(EAbort)
end;
procedure TTestTestfiles.TestFile(const _Filename: string; _AllowFailure: Boolean);
var
Filename: string;
InFile: string;
ExpectedFile: string;
ExpectedText: TGxUnicodeStringList;
st: TGxUnicodeStringList;
begin
Filename := 'testfile_' + _Filename + '.pas';
InFile := 'testcases\input\' + Filename;
ExpectedFile := 'testcases\expected-' + GetResultDir + '\' + Filename;
if not FileExists(InFile) then begin
ExpectedException := EFileDoesNotExist;
raise EFileDoesNotExist.Create('Input file does not exist');
end;
if not FileExists(ExpectedFile) then begin
ExpectedException := EFileDoesNotExist;
raise EFileDoesNotExist.Create('Expected file does not exist');
end;
ExpectedText := nil;
st := TGxUnicodeStringList.Create;
try
st.LoadFromFile(InFile);
ExpectedText := TGxUnicodeStringList.Create;
ExpectedText.LoadFromFile(ExpectedFile);
FFormatter.Execute(st);
try
TrimTrailingCrLf(ExpectedText);
TrimTrailingCrLf(st);
CheckEquals(ExpectedText.Text, st.Text, 'error in output');
except
st.SaveToFile('testcases\output-' + GetResultDir + '\' + Filename);
if not _AllowFailure then
raise;
end;
finally
ExpectedText.Free;
st.Free;
end;
end;
procedure TTestTestfiles.testStarCommentAtEol;
begin
TestFile('StarCommentAtEol');
end;
procedure TTestTestfiles.testSlashCommentToCurly;
begin
TestFile('SlashCommentToCurly');
end;
procedure TTestTestfiles.testStrictVisibility;
begin
TestFile('strictvisibility');
end;
procedure TTestTestfiles.testCompilerDirectives;
begin
TestFile('compilerdirectives');
end;
procedure TTestTestfiles.testComplexCurrentlyFails;
begin
TestFile('complex', True);
end;
procedure TTestTestfiles.testAssemblerNewlines;
begin
TestFile('assemblernewline');
end;
procedure TTestTestfiles.testIfdefs;
begin
TestFile('ifdefs');
end;
procedure TTestTestfiles.testUnmatchedIfdef;
begin
TestFile('unmatchedifdef');
end;
procedure TTestTestfiles.testUnmatchedElse;
begin
TestFile('unmatchedelse');
end;
procedure TTestTestfiles.testUnmatchedEndif;
begin
TestFile('unmatchedendif');
end;
procedure TTestTestfiles.testIfElseendif;
begin
TestFile('IfElseEndif');
end;
procedure TTestTestfiles.testIfThenElse;
begin
TestFile('ifthenelse');
end;
procedure TTestTestfiles.testIfThenElse2CurrentlyFails;
begin
TestFile('ifthenelse2');
end;
procedure TTestTestfiles.testIfThenTry;
begin
TestFile('ifthentry');
end;
procedure TTestTestfiles.testDisableFormatComment;
begin
TestFile('DisableFormatComment');
end;
procedure TTestTestfiles.testLargeFile;
begin
TestFile('xdom_3_1');
end;
procedure TTestTestfiles.testNestedClass;
begin
TestFile('NestedClass');
end;
procedure TTestTestfiles.testNestedClass2;
begin
TestFile('NestedClass2');
end;
procedure TTestTestfiles.testNestedClass3;
begin
TestFile('NestedClass3');
end;
procedure TTestTestfiles.testNestedClass4;
begin
TestFile('NestedClass4');
end;
procedure TTestTestfiles.testNestedClass5;
begin
TestFile('NestedClass5');
end;
procedure TTestTestfiles.testNestedClass6;
begin
TestFile('NestedClass6');
end;
procedure TTestTestfiles.testNestedEventType;
begin
TestFile('NestedEventType');
end;
procedure TTestTestfiles.TestNoFeedAfterDo;
begin
TestFile('NoFeedAfterDo');
end;
procedure TTestTestfiles.TestNoFeedAfterThen;
begin
TestFile('NoFeedAfterThen');
end;
procedure TTestTestfiles.testOperatorOverloading;
begin
TestFile('OperatorOverloading');
end;
procedure TTestTestfiles.testTripleQuotes;
begin
TestFile('triplequotes');
end;
procedure TTestTestfiles.testTypeOf;
begin
TestFile('TypeOf');
end;
procedure TTestTestfiles.TestUnicode;
begin
TestFile('unicode');
end;
procedure TTestTestfiles.testSingleElse;
begin
TestFile('singleelse');
end;
procedure TTestTestfiles.testQuotesError;
begin
TestFile('QuotesError');
end;
procedure TTestTestfiles.testRecordMethod;
begin
TestFile('RecordMethod');
end;
procedure TTestTestfiles.testJustOpeningComment;
begin
TestFile('OpeningCommentOnly');
end;
procedure TTestTestfiles.testElseAtEnd;
begin
TestFile('ElseAtEnd');
end;
procedure TTestTestfiles.testJustOpeningStarCommentInAsm;
begin
// I actually thought this would crash...
TestFile('OpeningStarCommentInAsm');
end;
procedure TTestTestfiles.testTabBeforeEndInAsm;
begin
TestFile('TabBeforeEndInAsm');
end;
procedure TTestTestfiles.testEmptyProgram;
begin
TestFile('EmptyProgram');
end;
procedure TTestTestfiles.testEmptyUnit;
begin
TestFile('EmptyUnit');
end;
procedure TTestTestfiles.testIndentComment;
begin
TestFile('IndentComment');
end;
procedure TTestTestfiles.testUnterminatedString;
begin
TestFile('UnterminatedString');
end;
procedure TTestTestfiles.testUsesWithComment;
begin
TestFile('UsesWithComment');
end;
procedure TTestTestfiles.testStringWithSingleQuotes;
begin
// note this actually contains a string with the TEXT #13#10:
// >hello ' #13#10);<
TestFile('StringWithSingleQuote');
end;
procedure TTestTestfiles.testEmptyStringAssignment;
begin
TestFile('EmptyStringAssignment');
end;
procedure TTestTestfiles.testHashCharStrings;
begin
TestFile('HashCharStrings');
end;
procedure TTestTestfiles.testDotFloat;
begin
TestFile('DotFloat');
end;
procedure TTestTestfiles.testHexNumbers;
begin
TestFile('HexNumbers');
end;
procedure TTestTestfiles.testConstSet;
begin
TestFile('ConstSet');
end;
procedure TTestTestfiles.testConstSetWithComment;
begin
TestFile('ConstSetWithComment');
end;
procedure TTestTestfiles.testConstSetWithCommentAtEnd;
begin
TestFile('ConstSetWithCommentAtEnd');
end;
procedure TTestTestfiles.testControlChars;
begin
TestFile('ControlChars');
end;
procedure TTestTestfiles.testConstVar;
begin
TestFile('ConstVar');
end;
procedure TTestTestfiles.testfileGenericCreate;
begin
TestFile('GenericCreate');
end;
procedure TTestTestfiles.testfileFakeGenericCreate;
begin
TestFile('FakeGenericCreate');
end;
procedure TTestTestfiles.testFormula;
begin
TestFile('Formula');
end;
procedure TTestTestfiles.testGenericClass;
begin
TestFile('GenericClass');
end;
procedure TTestTestfiles.testGenericClass2;
begin
TestFile('GenericClass2');
end;
procedure TTestTestfiles.testAbstractSealedClass;
begin
TestFile('AbstractSealedClass');
end;
procedure TTestTestfiles.testAngledBrackets;
begin
TestFile('AngledBrackets');
end;
procedure TTestTestfiles.testAnonymousCurrentlyFails;
begin
TestFile('Anonymous', True);
end;
procedure TTestTestfiles.testArabic;
begin
TestFile('Arabic');
end;
procedure TTestTestfiles.testAsm;
begin
TestFile('asm');
end;
procedure TTestTestfiles.testAsmProblem1;
begin
TestFile('AsmProblem1');
end;
procedure TTestTestfiles.testCharList;
begin
TestFile('CharList');
end;
procedure TTestTestfiles.testClassInImplementation;
begin
TestFile('ClassInImplementation');
end;
procedure TTestTestfiles.testClassProperties;
begin
TestFile('ClassProperties');
end;
procedure TTestTestfiles.testClassProperties2;
begin
TestFile('ClassProperties2');
end;
procedure TTestTestfiles.testClassProperties3;
begin
TestFile('ClassProperties3');
end;
procedure TTestTestfiles.testClassVar;
begin
TestFile('ClassVar');
end;
procedure TTestTestfiles.testCommentEnd;
begin
TestFile('CommentEnd');
end;
procedure TTestTestfiles.testCurlyHalfCommentEndCurrentlyFails;
begin
TestFile('CurlyHalfCommentEnd', True);
end;
{ TTestFilesHeadworkFormatting }
function TTestFilesHeadworkFormatting.GetFormatSettings: TCodeFormatterEngineSettings;
var
Settings: TCodeFormatterSettings;
begin
Settings := TCodeFormatterSettings.Create;
try
TCodeFormatterConfigHandler.ImportFromFile(GetConfigDirBS + 'FormatterSettings-headwork.ini', Settings);
Result := Settings.Settings;
finally
Settings.Free;
end;
end;
function TTestFilesHeadworkFormatting.GetResultDir: string;
begin
Result := 'headwork';
end;
{ TTestFilesBorlandFormatting }
function TTestFilesBorlandFormatting.GetFormatSettings: TCodeFormatterEngineSettings;
begin
Result := BorlandDefaults;
end;
function TTestFilesBorlandFormatting.GetResultDir: string;
begin
Result := 'borland';
end;
{ TTestFilesDelforFormatting }
function TTestFilesDelforFormatting.GetFormatSettings: TCodeFormatterEngineSettings;
var
Settings: TCodeFormatterSettings;
begin
Settings := TCodeFormatterSettings.Create;
try
TCodeFormatterConfigHandler.ImportFromFile(GetConfigDirBS + 'FormatterSettings-DelForEx.ini', Settings);
Result := Settings.Settings;
finally
Settings.Free;
end;
end;
function TTestFilesDelforFormatting.GetResultDir: string;
begin
Result := 'delforex';
end;
{ TTestFilesDefaultFormatting }
function TTestFilesDefaultFormatting.GetFormatSettings: TCodeFormatterEngineSettings;
var
Settings: TCodeFormatterSettings;
begin
Settings := TCodeFormatterSettings.Create;
try
Result := Settings.Settings;
finally
Settings.Free;
end;
end;
function TTestFilesDefaultFormatting.GetResultDir: string;
begin
Result := 'default'
end;
{ TTestFilesTwmFormatting }
function TTestFilesTwmFormatting.GetFormatSettings: TCodeFormatterEngineSettings;
var
Settings: TCodeFormatterSettings;
begin
Settings := TCodeFormatterSettings.Create;
try
TCodeFormatterConfigHandler.ImportFromFile(GetConfigDirBS + 'FormatterSettings-twm.ini', Settings);
Result := Settings.Settings;
finally
Settings.Free;
end;
end;
function TTestFilesTwmFormatting.GetResultDir: string;
begin
Result := 'twm';
end;
{ TTestFilesSpecial }
function TTestFilesSpecial.GetFormatSettings: TCodeFormatterEngineSettings;
begin
Result := inherited GetFormatSettings;
Result.ExceptSingle := True;
end;
function TTestFilesSpecial.GetResultDir: string;
begin
Result := 'special';
end;
initialization
RegisterTest(TTestFilesDefaultFormatting.Suite);
RegisterTest(TTestFilesHeadworkFormatting.Suite);
RegisterTest(TTestFilesBorlandFormatting.Suite);
RegisterTest(TTestFilesDelforFormatting.Suite);
RegisterTest(TTestFilesTwmFormatting.Suite);
RegisterTest(TTestFilesSpecial.Suite);
end.
|
unit KeyWordPack;
// Модуль: "w:\common\components\rtl\Garant\ScriptEngine\KeyWordPack.pas"
// Стереотип: "ScriptKeywordsPack"
// Элемент модели: "KeyWordPack" MUID: (55895F0A01BF)
{$Include w:\common\components\rtl\Garant\ScriptEngine\seDefine.inc}
interface
{$If NOT Defined(NoScripts)}
uses
l3IntfUses
, tfwScriptingInterfaces
, l3Interfaces
, tfwDictionary
;
{$IfEnd} // NOT Defined(NoScripts)
implementation
{$If NOT Defined(NoScripts)}
uses
l3ImplUses
, tfwClassLike
, TypInfo
, tfwPropertyLike
, tfwTypeInfo
, tfwScriptEngineExInterfaces
, SysUtils
, TtfwTypeRegistrator_Proxy
, tfwScriptingTypes
//#UC START# *55895F0A01BFimpl_uses*
//#UC END# *55895F0A01BFimpl_uses*
;
type
TkwPopKeyWordSetWord = {final} class(TtfwClassLike)
{* Слово скрипта pop:KeyWord:SetWord }
private
procedure SetWord(const aCtx: TtfwContext;
aKeyWord: TtfwKeyWord;
aWord: TtfwWord);
{* Реализация слова скрипта pop:KeyWord:SetWord }
protected
class function GetWordNameForRegister: AnsiString; override;
procedure DoDoIt(const aCtx: TtfwContext); override;
public
function GetResultTypeInfo(const aCtx: TtfwContext): PTypeInfo; override;
function GetAllParamsCount(const aCtx: TtfwContext): Integer; override;
function ParamsTypes: PTypeInfoArray; override;
end;//TkwPopKeyWordSetWord
TkwPopKeyWordWord = {final} class(TtfwPropertyLike)
{* Слово скрипта pop:KeyWord:Word }
private
function Word(const aCtx: TtfwContext;
aKeyWord: TtfwKeyWord): TtfwWord;
{* Реализация слова скрипта pop:KeyWord:Word }
protected
class function GetWordNameForRegister: AnsiString; override;
procedure DoDoIt(const aCtx: TtfwContext); override;
public
function GetResultTypeInfo(const aCtx: TtfwContext): PTypeInfo; override;
function GetAllParamsCount(const aCtx: TtfwContext): Integer; override;
function ParamsTypes: PTypeInfoArray; override;
procedure SetValuePrim(const aValue: TtfwStackValue;
const aCtx: TtfwContext); override;
end;//TkwPopKeyWordWord
TkwPopKeyWordName = {final} class(TtfwPropertyLike)
{* Слово скрипта pop:KeyWord:Name }
private
function Name(const aCtx: TtfwContext;
aKeyWord: TtfwKeyWord): Il3CString;
{* Реализация слова скрипта pop:KeyWord:Name }
protected
class function GetWordNameForRegister: AnsiString; override;
procedure DoDoIt(const aCtx: TtfwContext); override;
public
function GetResultTypeInfo(const aCtx: TtfwContext): PTypeInfo; override;
function GetAllParamsCount(const aCtx: TtfwContext): Integer; override;
function ParamsTypes: PTypeInfoArray; override;
procedure SetValuePrim(const aValue: TtfwStackValue;
const aCtx: TtfwContext); override;
end;//TkwPopKeyWordName
TkwPopKeyWordDictionary = {final} class(TtfwPropertyLike)
{* Слово скрипта pop:KeyWord:Dictionary }
private
function Dictionary(const aCtx: TtfwContext;
aKeyWord: TtfwKeyWord): TtfwDictionary;
{* Реализация слова скрипта pop:KeyWord:Dictionary }
protected
class function GetWordNameForRegister: AnsiString; override;
procedure DoDoIt(const aCtx: TtfwContext); override;
public
function GetResultTypeInfo(const aCtx: TtfwContext): PTypeInfo; override;
function GetAllParamsCount(const aCtx: TtfwContext): Integer; override;
function ParamsTypes: PTypeInfoArray; override;
procedure SetValuePrim(const aValue: TtfwStackValue;
const aCtx: TtfwContext); override;
end;//TkwPopKeyWordDictionary
procedure TkwPopKeyWordSetWord.SetWord(const aCtx: TtfwContext;
aKeyWord: TtfwKeyWord;
aWord: TtfwWord);
{* Реализация слова скрипта pop:KeyWord:SetWord }
//#UC START# *5673CF480040_5673CF480040_4DAEF23D00EE_Word_var*
var
l_Key : TtfwKeyWord;
//#UC END# *5673CF480040_5673CF480040_4DAEF23D00EE_Word_var*
begin
//#UC START# *5673CF480040_5673CF480040_4DAEF23D00EE_Word_impl*
l_Key := aWord.Key As TtfwKeyWord;
aKeyWord.SetWord(aCtx, aWord);
if (l_Key <> nil) then
aWord.Key := l_Key;
//#UC END# *5673CF480040_5673CF480040_4DAEF23D00EE_Word_impl*
end;//TkwPopKeyWordSetWord.SetWord
class function TkwPopKeyWordSetWord.GetWordNameForRegister: AnsiString;
begin
Result := 'pop:KeyWord:SetWord';
end;//TkwPopKeyWordSetWord.GetWordNameForRegister
function TkwPopKeyWordSetWord.GetResultTypeInfo(const aCtx: TtfwContext): PTypeInfo;
begin
Result := @tfw_tiVoid;
end;//TkwPopKeyWordSetWord.GetResultTypeInfo
function TkwPopKeyWordSetWord.GetAllParamsCount(const aCtx: TtfwContext): Integer;
begin
Result := 2;
end;//TkwPopKeyWordSetWord.GetAllParamsCount
function TkwPopKeyWordSetWord.ParamsTypes: PTypeInfoArray;
begin
Result := OpenTypesToTypes([TypeInfo(TtfwKeyWord), TypeInfo(TtfwWord)]);
end;//TkwPopKeyWordSetWord.ParamsTypes
procedure TkwPopKeyWordSetWord.DoDoIt(const aCtx: TtfwContext);
var l_aKeyWord: TtfwKeyWord;
var l_aWord: TtfwWord;
begin
try
l_aKeyWord := TtfwKeyWord(aCtx.rEngine.PopObjAs(TtfwKeyWord));
except
on E: Exception do
begin
RunnerError('Ошибка при получении параметра aKeyWord: TtfwKeyWord : ' + E.Message, aCtx);
Exit;
end;//on E: Exception
end;//try..except
try
l_aWord := TtfwWord(aCtx.rEngine.PopObjAs(TtfwWord));
except
on E: Exception do
begin
RunnerError('Ошибка при получении параметра aWord: TtfwWord : ' + E.Message, aCtx);
Exit;
end;//on E: Exception
end;//try..except
SetWord(aCtx, l_aKeyWord, l_aWord);
end;//TkwPopKeyWordSetWord.DoDoIt
function TkwPopKeyWordWord.Word(const aCtx: TtfwContext;
aKeyWord: TtfwKeyWord): TtfwWord;
{* Реализация слова скрипта pop:KeyWord:Word }
begin
Result := aKeyWord.Word;
end;//TkwPopKeyWordWord.Word
class function TkwPopKeyWordWord.GetWordNameForRegister: AnsiString;
begin
Result := 'pop:KeyWord:Word';
end;//TkwPopKeyWordWord.GetWordNameForRegister
function TkwPopKeyWordWord.GetResultTypeInfo(const aCtx: TtfwContext): PTypeInfo;
begin
Result := TypeInfo(TtfwWord);
end;//TkwPopKeyWordWord.GetResultTypeInfo
function TkwPopKeyWordWord.GetAllParamsCount(const aCtx: TtfwContext): Integer;
begin
Result := 1;
end;//TkwPopKeyWordWord.GetAllParamsCount
function TkwPopKeyWordWord.ParamsTypes: PTypeInfoArray;
begin
Result := OpenTypesToTypes([TypeInfo(TtfwKeyWord)]);
end;//TkwPopKeyWordWord.ParamsTypes
procedure TkwPopKeyWordWord.SetValuePrim(const aValue: TtfwStackValue;
const aCtx: TtfwContext);
begin
RunnerError('Нельзя присваивать значение readonly свойству Word', aCtx);
end;//TkwPopKeyWordWord.SetValuePrim
procedure TkwPopKeyWordWord.DoDoIt(const aCtx: TtfwContext);
var l_aKeyWord: TtfwKeyWord;
begin
try
l_aKeyWord := TtfwKeyWord(aCtx.rEngine.PopObjAs(TtfwKeyWord));
except
on E: Exception do
begin
RunnerError('Ошибка при получении параметра aKeyWord: TtfwKeyWord : ' + E.Message, aCtx);
Exit;
end;//on E: Exception
end;//try..except
aCtx.rEngine.PushObj(Word(aCtx, l_aKeyWord));
end;//TkwPopKeyWordWord.DoDoIt
function TkwPopKeyWordName.Name(const aCtx: TtfwContext;
aKeyWord: TtfwKeyWord): Il3CString;
{* Реализация слова скрипта pop:KeyWord:Name }
//#UC START# *55895FC003A4_55895FC003A4_4DAEF23D00EE_Word_var*
//#UC END# *55895FC003A4_55895FC003A4_4DAEF23D00EE_Word_var*
begin
//#UC START# *55895FC003A4_55895FC003A4_4DAEF23D00EE_Word_impl*
Result := aKeyWord.AsCStr;
//#UC END# *55895FC003A4_55895FC003A4_4DAEF23D00EE_Word_impl*
end;//TkwPopKeyWordName.Name
class function TkwPopKeyWordName.GetWordNameForRegister: AnsiString;
begin
Result := 'pop:KeyWord:Name';
end;//TkwPopKeyWordName.GetWordNameForRegister
function TkwPopKeyWordName.GetResultTypeInfo(const aCtx: TtfwContext): PTypeInfo;
begin
Result := @tfw_tiString;
end;//TkwPopKeyWordName.GetResultTypeInfo
function TkwPopKeyWordName.GetAllParamsCount(const aCtx: TtfwContext): Integer;
begin
Result := 1;
end;//TkwPopKeyWordName.GetAllParamsCount
function TkwPopKeyWordName.ParamsTypes: PTypeInfoArray;
begin
Result := OpenTypesToTypes([TypeInfo(TtfwKeyWord)]);
end;//TkwPopKeyWordName.ParamsTypes
procedure TkwPopKeyWordName.SetValuePrim(const aValue: TtfwStackValue;
const aCtx: TtfwContext);
begin
RunnerError('Нельзя присваивать значение readonly свойству Name', aCtx);
end;//TkwPopKeyWordName.SetValuePrim
procedure TkwPopKeyWordName.DoDoIt(const aCtx: TtfwContext);
var l_aKeyWord: TtfwKeyWord;
begin
try
l_aKeyWord := TtfwKeyWord(aCtx.rEngine.PopObjAs(TtfwKeyWord));
except
on E: Exception do
begin
RunnerError('Ошибка при получении параметра aKeyWord: TtfwKeyWord : ' + E.Message, aCtx);
Exit;
end;//on E: Exception
end;//try..except
aCtx.rEngine.PushString(Name(aCtx, l_aKeyWord));
end;//TkwPopKeyWordName.DoDoIt
function TkwPopKeyWordDictionary.Dictionary(const aCtx: TtfwContext;
aKeyWord: TtfwKeyWord): TtfwDictionary;
{* Реализация слова скрипта pop:KeyWord:Dictionary }
//#UC START# *55ED650A0047_55ED650A0047_4DAEF23D00EE_Word_var*
//#UC END# *55ED650A0047_55ED650A0047_4DAEF23D00EE_Word_var*
begin
//#UC START# *55ED650A0047_55ED650A0047_4DAEF23D00EE_Word_impl*
if (aKeyWord = nil) then
Result := nil
else
Result := aKeyWord.Dictionary As TtfwDictionary;
//#UC END# *55ED650A0047_55ED650A0047_4DAEF23D00EE_Word_impl*
end;//TkwPopKeyWordDictionary.Dictionary
class function TkwPopKeyWordDictionary.GetWordNameForRegister: AnsiString;
begin
Result := 'pop:KeyWord:Dictionary';
end;//TkwPopKeyWordDictionary.GetWordNameForRegister
function TkwPopKeyWordDictionary.GetResultTypeInfo(const aCtx: TtfwContext): PTypeInfo;
begin
Result := TypeInfo(TtfwDictionary);
end;//TkwPopKeyWordDictionary.GetResultTypeInfo
function TkwPopKeyWordDictionary.GetAllParamsCount(const aCtx: TtfwContext): Integer;
begin
Result := 1;
end;//TkwPopKeyWordDictionary.GetAllParamsCount
function TkwPopKeyWordDictionary.ParamsTypes: PTypeInfoArray;
begin
Result := OpenTypesToTypes([TypeInfo(TtfwKeyWord)]);
end;//TkwPopKeyWordDictionary.ParamsTypes
procedure TkwPopKeyWordDictionary.SetValuePrim(const aValue: TtfwStackValue;
const aCtx: TtfwContext);
begin
RunnerError('Нельзя присваивать значение readonly свойству Dictionary', aCtx);
end;//TkwPopKeyWordDictionary.SetValuePrim
procedure TkwPopKeyWordDictionary.DoDoIt(const aCtx: TtfwContext);
var l_aKeyWord: TtfwKeyWord;
begin
try
l_aKeyWord := TtfwKeyWord(aCtx.rEngine.PopObjAs(TtfwKeyWord));
except
on E: Exception do
begin
RunnerError('Ошибка при получении параметра aKeyWord: TtfwKeyWord : ' + E.Message, aCtx);
Exit;
end;//on E: Exception
end;//try..except
aCtx.rEngine.PushObj(Dictionary(aCtx, l_aKeyWord));
end;//TkwPopKeyWordDictionary.DoDoIt
initialization
TkwPopKeyWordSetWord.RegisterInEngine;
{* Регистрация pop_KeyWord_SetWord }
TkwPopKeyWordWord.RegisterInEngine;
{* Регистрация pop_KeyWord_Word }
TkwPopKeyWordName.RegisterInEngine;
{* Регистрация pop_KeyWord_Name }
TkwPopKeyWordDictionary.RegisterInEngine;
{* Регистрация pop_KeyWord_Dictionary }
TtfwTypeRegistrator.RegisterType(TypeInfo(TtfwKeyWord));
{* Регистрация типа TtfwKeyWord }
TtfwTypeRegistrator.RegisterType(TypeInfo(TtfwWord));
{* Регистрация типа TtfwWord }
TtfwTypeRegistrator.RegisterType(@tfw_tiString);
{* Регистрация типа Il3CString }
TtfwTypeRegistrator.RegisterType(TypeInfo(TtfwDictionary));
{* Регистрация типа TtfwDictionary }
{$IfEnd} // NOT Defined(NoScripts)
end.
|
unit TimesValueParsingTest;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FpcUnit, TestRegistry,
ParserBaseTestCase,
ValuesParsingBaseTest,
WpcScriptCommons,
WpcStatements,
WpcScriptParser;
type
{ TTimesValueParsingTest }
TTimesValueParsingTest = class(TValuesParsingBaseTest)
protected
function ParseAndGetTimesValue(TimesString : String) : LongWord;
procedure ParseAndEnsureScriptParseException(TimesString : String);
published
procedure ShouldParseTimesValue();
procedure ShouldRaiseScriptParseExceptionIfNoTimesValueGiven();
procedure ShouldRaiseScriptParseExceptionIfInvalidTimesValueGiven();
end;
implementation
{ TTimesValueParsingTest }
function TTimesValueParsingTest.ParseAndGetTimesValue(TimesString : String): LongWord;
var
WaitStatement : TWpcWaitStatement;
begin
if (ScriptLines <> nil) then FreeAndNil(ScriptLines);
ScriptLines := TStringList.Create();
try
ScriptLines.Add(WAIT_KEYWORD + ' 5s ' + TimesString + ' ' + TIMES_KEYWORD);
WrapInMainBranch(ScriptLines);
ParseScriptLines();
ReadMainBranchStatementsList();
AssertEquals(WRONG_NUMBER_OF_SATEMENTS, 1, MainBranchStatements.Count);
AssertTrue(WRONG_STATEMENT, WPC_WAIT_STATEMENT_ID = MainBranchStatements[0].GetId());
WaitStatement := TWpcWaitStatement(MainBranchStatements[0]);
Result := WaitStatement.GetTimes();
finally
FreeAndNil(ScriptLines);
FreeAndNil(Script);
end;
end;
procedure TTimesValueParsingTest.ParseAndEnsureScriptParseException(TimesString : String);
begin
if (ScriptLines <> nil) then FreeAndNil(ScriptLines);
ScriptLines := TStringList.Create();
try
ScriptLines.Add(WAIT_KEYWORD + ' 5s ' + TimesString + ' ' + TIMES_KEYWORD);
WrapInMainBranch(ScriptLines);
AssertScriptParseExceptionOnParse(1);
finally
FreeAndNil(ScriptLines);
end;
end;
procedure TTimesValueParsingTest.ShouldParseTimesValue();
const
VALID_TIMES_VALUES : Array[1..4] of LongWord = (1, 5, 100, 12345);
var
i : Integer;
begin
for i:=1 to Length(VALID_TIMES_VALUES) do begin
AssertEquals(FAILED_TO_PARSE + IntToStr(VALID_TIMES_VALUES[i]) + ' ' + TIMES_KEYWORD,
VALID_TIMES_VALUES[i],
ParseAndGetTimesValue(IntToStr(VALID_TIMES_VALUES[i])));
end;
end;
procedure TTimesValueParsingTest.ShouldRaiseScriptParseExceptionIfNoTimesValueGiven();
begin
ParseAndEnsureScriptParseException('');
end;
procedure TTimesValueParsingTest.ShouldRaiseScriptParseExceptionIfInvalidTimesValueGiven;
const
INVALID_TIMES_VALUES : Array[1..6] of String = ('0', '-1', '5.5', '5t', 'x', 'v5');
var
i : Integer;
begin
for i:=1 to Length(INVALID_TIMES_VALUES) do begin
ParseAndEnsureScriptParseException(INVALID_TIMES_VALUES[i]);
end;
end;
initialization
RegisterTest(VALUES_PARSER_TEST_SUITE_NAME, TTimesValueParsingTest);
end.
|
unit uDMSolicitacao;
interface
uses
System.SysUtils, System.Classes, uDM, Data.DB, Datasnap.DBClient, uRegras,
uSolicitacaoVO, uConverter, uSolicitacaoViewModel, Data.DBXJSON;
const
PROGRAMA_SOLICITACAO: Integer = 3;
type
TdmSolicitacao = class(TDataModule)
cdsCadastro: TClientDataSet;
cdsCadastroSol_Id: TAutoIncField;
cdsCadastroSol_Analista: TIntegerField;
cdsCadastroSol_Anexo: TStringField;
cdsCadastroSol_Cliente: TIntegerField;
cdsCadastroSol_Data: TDateField;
cdsCadastroSol_Desenvolvedor: TIntegerField;
cdsCadastroSol_Hora: TTimeField;
cdsCadastroSol_Modulo: TIntegerField;
cdsCadastroSol_Nivel: TIntegerField;
cdsCadastroSol_PrevisaoEntrega: TDateField;
cdsCadastroSol_Produto: TIntegerField;
cdsCadastroSol_Status: TIntegerField;
cdsCadastroSol_TempoPrevisto: TBCDField;
cdsCadastroSol_Tipo: TIntegerField;
cdsCadastroSol_Titulo: TStringField;
cdsCadastroSol_UsuarioAbertura: TIntegerField;
cdsCadastroSol_Versao: TStringField;
cdsCadastroSol_UsuarioAtendeAtual: TIntegerField;
cdsCadastroSol_Contato: TStringField;
cdsCadastroSol_Descricao: TMemoField;
cdsCadastroSol_DescricaoLiberacao: TMemoField;
cdsCadastroSol_VersaoId: TIntegerField;
cdsCadastroProd_Codigo: TIntegerField;
cdsCadastroProd_Nome: TWideStringField;
cdsCadastroSta_Codigo: TIntegerField;
cdsCadastroSta_Nome: TWideStringField;
cdsCadastroTip_Codigo: TIntegerField;
cdsCadastroTip_Nome: TWideStringField;
cdsCadastroUAb_Codigo: TIntegerField;
cdsCadastroAnal_Codigo: TIntegerField;
cdsCadastroCli_Codigo: TIntegerField;
cdsCadastroCli_Nome: TWideStringField;
cdsCadastroDesenv_Codigo: TIntegerField;
cdsCadastroMod_Codigo: TIntegerField;
cdsCadastroMod_Nome: TWideStringField;
cdsCadastroUAb_Nome: TWideStringField;
cdsCadastroAnal_Nome: TWideStringField;
cdsCadastroDesenv_Nome: TWideStringField;
cdsCadastroVer_Versao: TStringField;
procedure DataModuleCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
function ObterPorId(id: Integer): TSolicitacaoViewModel;
procedure IniciarTempo(AIdUsuarioLogado: Integer; ASolicitacaoViewModel: TSolicitacaoViewModel);
procedure FinalizarTempo(AIdUsuarioLogado: Integer; ASolicitacaoViewModel: TSolicitacaoViewModel;
AValidarUsuario: Boolean=True);
end;
var
dmSolicitacao: TdmSolicitacao;
implementation
{%CLASSGROUP 'Vcl.Controls.TControl'}
{$R *.dfm}
{ TdmSolicitacao }
procedure TdmSolicitacao.DataModuleCreate(Sender: TObject);
begin
cdsCadastro.RemoteServer := dm.DSPConexao;
end;
procedure TdmSolicitacao.FinalizarTempo(AIdUsuarioLogado: Integer;
ASolicitacaoViewModel: TSolicitacaoViewModel; AValidarUsuario: Boolean);
var
proxy: TServerMethods1Client;
objJson: TJSONValue;
begin
dm.Conectar;
proxy := TServerMethods1Client.Create(DM.Conexao.DBXConnection);
try
try
objJson := TConverte.ObjectToJSON(ASolicitacaoViewModel);
proxy.SolicitacaoFinalizarTempo(AIdUsuarioLogado, objJson, AValidarUsuario);
except
On E: Exception do
begin
raise Exception.Create(E.Message + ' TdmSolicitacao.FinalizarTempo');
end;
end;
finally
FreeAndNil(proxy);
dm.Desconectar;
end;
end;
procedure TdmSolicitacao.IniciarTempo(AIdUsuarioLogado: Integer; ASolicitacaoViewModel: TSolicitacaoViewModel);
var
proxy: TServerMethods1Client;
objJson: TJSONValue;
begin
dm.Conectar;
proxy := TServerMethods1Client.Create(DM.Conexao.DBXConnection);
try
try
objJson := TConverte.ObjectToJSON(ASolicitacaoViewModel);
proxy.SolicitacaoIniciarTempo(AIdUsuarioLogado, objJson);
except
On E: Exception do
begin
raise Exception.Create(E.Message + ' TdmSolicitacao.IniciarTempo');
end;
end;
finally
FreeAndNil(proxy);
dm.Desconectar;
end;
end;
function TdmSolicitacao.ObterPorId(id: Integer): TSolicitacaoViewModel;
var
proxy: TServerMethods1Client;
begin
dm.Conectar;
proxy := TServerMethods1Client.Create(DM.Conexao.DBXConnection);
try
try
Result := TConverte.JSONToObject<TSolicitacaoViewModel>(proxy.SolicitacaoObterPorId(id));
except
On E: Exception do
begin
raise Exception.Create(E.Message + ' TdmSolicitacao.ObterPorId');
end;
end;
finally
FreeAndNil(proxy);
dm.Desconectar;
end;
end;
end.
|
unit FFSUSERGRPTable;
interface
uses
Classes, DB, DBISAMTb, SysUtils, DBISAMTableAU, DataBuf;
type
TFFSUSERGRPRecord = record
PName: String[20];
PRights: String[250];
End;
TFFSUSERGRPBuffer = class(TDataBuf)
protected
function PtrIndex(Index:integer):Pointer;override;
public
Data: TFFSUSERGRPRecord;
function FieldNameToIndex(s:string):integer;override;
function FieldType(index:integer):TFieldType;override;
end;
TEIFFSUSERGRP = (FFSUSERGRPPrimaryKey);
TFFSUSERGRPTable = class( TDBISAMTableAU )
private
FDFName: TStringField;
FDFRights: TStringField;
procedure SetPName(const Value: ShortString);
function GetPName:ShortString;
procedure SetPRights(const Value: ShortString);
function GetPRights:ShortString;
procedure SetEnumIndex(Value: TEIFFSUSERGRP);
function GetEnumIndex: TEIFFSUSERGRP;
protected
procedure CreateFields; reintroduce;
procedure SetActive(Value: Boolean); override;
procedure LoadFieldDefs(AStringList:TStringList);override;
procedure LoadIndexDefs(AStringList:TStringList);override;
public
function GetDataBuffer:TFFSUSERGRPRecord;
procedure StoreDataBuffer(ABuffer:TFFSUSERGRPRecord);
property DFName: TStringField read FDFName;
property DFRights: TStringField read FDFRights;
property PName: ShortString read GetPName write SetPName;
property PRights: ShortString read GetPRights write SetPRights;
published
property Active write SetActive;
property EnumIndex: TEIFFSUSERGRP read GetEnumIndex write SetEnumIndex;
end; { TFFSUSERGRPTable }
procedure Register;
implementation
procedure TFFSUSERGRPTable.CreateFields;
begin
FDFName := CreateField( 'Name' ) as TStringField;
FDFRights := CreateField( 'Rights' ) as TStringField;
end; { TFFSUSERGRPTable.CreateFields }
procedure TFFSUSERGRPTable.SetActive(Value: Boolean);
begin
inherited SetActive(Value);
if Active then
CreateFields;
end; { TFFSUSERGRPTable.SetActive }
procedure TFFSUSERGRPTable.SetPName(const Value: ShortString);
begin
DFName.Value := Value;
end;
function TFFSUSERGRPTable.GetPName:ShortString;
begin
result := DFName.Value;
end;
procedure TFFSUSERGRPTable.SetPRights(const Value: ShortString);
begin
DFRights.Value := Value;
end;
function TFFSUSERGRPTable.GetPRights:ShortString;
begin
result := DFRights.Value;
end;
procedure TFFSUSERGRPTable.LoadFieldDefs(AStringList: TStringList);
begin
inherited;
with AstringList do
begin
Add('Name, String, 20, N');
Add('Rights, String, 250, N');
end;
end;
procedure TFFSUSERGRPTable.LoadIndexDefs(AStringList: TStringList);
begin
inherited;
with AstringList do
begin
Add('PrimaryKey, Name, Y, Y, N, N');
end;
end;
procedure TFFSUSERGRPTable.SetEnumIndex(Value: TEIFFSUSERGRP);
begin
case Value of
FFSUSERGRPPrimaryKey : IndexName := '';
end;
end;
function TFFSUSERGRPTable.GetDataBuffer:TFFSUSERGRPRecord;
var buf: TFFSUSERGRPRecord;
begin
fillchar(buf, sizeof(buf), 0);
buf.PName := DFName.Value;
buf.PRights := DFRights.Value;
result := buf;
end;
procedure TFFSUSERGRPTable.StoreDataBuffer(ABuffer:TFFSUSERGRPRecord);
begin
DFName.Value := ABuffer.PName;
DFRights.Value := ABuffer.PRights;
end;
function TFFSUSERGRPTable.GetEnumIndex: TEIFFSUSERGRP;
var iname : Shortstring;
begin
result := FFSUSERGRPPrimaryKey;
iname := uppercase(indexname);
if iname = '' then result := FFSUSERGRPPrimaryKey;
end;
(********************************************)
(************ Register Component ************)
(********************************************)
procedure Register;
begin
RegisterComponents( 'FFS Tables', [ TFFSUSERGRPTable, TFFSUSERGRPBuffer ] );
end; { Register }
function TFFSUSERGRPBuffer.FieldNameToIndex(s:string):integer;
const flist:array[1..2] of Shortstring = ('NAME','RIGHTS' );
var x : integer;
begin
s := uppercase(s);
x := 1;
while (x <= 2) and (flist[x] <> s) do inc(x);
if x <= 2 then result := x else result := 0;
end;
function TFFSUSERGRPBuffer.FieldType(index:integer):TFieldType;
begin
result := ftUnknown;
case index of
1 : result := ftString;
2 : result := ftString;
end;
end;
function TFFSUSERGRPBuffer.PtrIndex(index:integer):Pointer;
begin
result := nil;
case index of
1 : result := @Data.PName;
2 : result := @Data.PRights;
end;
end;
end.
|
unit uVars;
interface
uses Classes,
// Own units
UCommon;
type
TVars = class(THODObject)
FID: TStringList;
FValue: TStringList;
//** Конструктор.
constructor Create;
//** Деструктор.
destructor Destroy; override;
procedure Clear;
procedure ClearGameVars;
function Count: Integer;
procedure EmptyVar(const AVar: string);
function IsVar(const AVar: string): Boolean;
function GetStr(const AVar: string): string;
function GetStrInt(const AVar: string): string;
procedure SetStr(const AVar, AValue: string);
function GetInt(const AVar: string): Integer;
procedure SetInt(const AVar: string; const AValue: Integer);
function GetBool(const AVar: string): Boolean;
procedure SetBool(const AVar: string; const AValue: Boolean);
procedure SaveToFile(const AFileName: string);
procedure LoadFromFile(const AFileName: string);
procedure Inc(const VarName: string; Count: Integer = 1);
procedure Dec(const VarName: string; Count: Integer = 1);
procedure Let(Var1, Var2: string);
procedure ClampModify(VarName: string; Modifier, Min, Max: Integer);
end;
var
VM: TVars;
//** Имя персонажа.
PCName: string = '';
//** Правильность ввода имени персонажа.
procedure KeysName(var Key: Char);
//** Добавить разрешенный символ к имени персонажа.
procedure AddChar(C: string);
//** Время.
function GetTimeStr: string;
implementation
uses SysUtils;
function GetTimeStr: string;
var
D, W, M, T, I: Integer;
begin
D := 1;
W := 1;
M := 1;
T := VM.GetInt('Hero.Step') div 5000;
for I := 1 to T do
begin
Inc(D);
if (D > 7) then
begin
D := 1;
Inc(W);
if (W > 4) then
begin
W := 1;
Inc(M);
end;
end;
end;
Result := Format('Мес.: %d, Нед.: %d, День: %d', [M, W, D]);
end;
procedure AddChar(C: string);
begin
if (Length(PCName) < 10) then
begin
PCName := PCName + C;
end;
VM.SetStr('Hero.Name', Trim(PCName));
end;
procedure KeysName(var Key: Char);
const
C1 = 'abcdefghijklmnopqrstuvwxyz';
C2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
C3 = 'абвгдеєжзиіїйклмнопрстуфхцчшщюяьъэё';
C4 = 'АБВГДЕЄЖЗИІЇЙКЛМНОПРСТУФХЦЧШЩЮЯЬЪЭЁ';
C5 = '-';
Chars = C1 + C2 + C3 + C4 + C5;
begin
if (Pos(Key, Chars) > 0) then AddChar(Key);
end;
{ TVars }
procedure TVars.ClampModify(VarName: string; Modifier, Min, Max: Integer);
var
i: Integer;
function Clamp(Value, AMin, AMax: Integer): Integer;
begin
Result := Value;
if Value < AMin then
Result := AMin;
if Value > AMax then
Result := AMax;
end;
begin
i := GetInt(VarName);
System.Inc(i, Modifier);
i := Clamp(i, Min, Max);
SetInt(VarName, i);
end;
procedure TVars.Clear;
begin
FID.Clear;
FValue.Clear;
end;
constructor TVars.Create;
begin
FID := TStringList.Create;
FValue := TStringList.Create;
Self.Clear;
end;
destructor TVars.Destroy;
begin
FID.Free;
FValue.Free;
end;
function TVars.GetStr(const AVar: string): string;
var
i: Integer;
begin
i := FID.IndexOf(AVar);
if i < 0 then
Result := ''
else
Result := FValue[i];
end;
function TVars.GetStrInt(const AVar: string): string;
var
i: Integer;
begin
i := FID.IndexOf(AVar);
if (i < 0) or (FValue[i] = '') then
Result := '0'
else
Result := FValue[i];
end;
procedure TVars.SetStr(const AVar, AValue: string);
var
i: Integer;
begin
// if (AValue = '') then Exit;
i := FID.IndexOf(AVar);
{ if (AValue = '0') then
begin
if (I >= 0) then
begin
FID.Delete(I);
FValue.Delete(I);
end else Exit;
end; }
if (i < 0) then
begin
FID.Append(AVar);
FValue.Append(AValue);
end
else
FValue[i] := AValue;
end;
function TVars.GetInt(const AVar: string): Integer;
var
S: string;
begin
S := Trim(GetStr(AVar));
if S = '' then
Result := 0
else
Result := StrToInt(S);
end;
procedure TVars.SetInt(const AVar: string; const AValue: Integer);
begin
SetStr(AVar, IntToStr(AValue));
end;
function TVars.GetBool(const AVar: string): Boolean;
begin
Result := Trim(GetStr(AVar)) = 'TRUE';
end;
procedure TVars.SetBool(const AVar: string; const AValue: Boolean);
begin
if AValue then
SetStr(AVar, 'TRUE')
else
EmptyVar(AVar);
end;
procedure TVars.SaveToFile(const AFileName: string);
var
i: Integer;
S: TStringList;
begin
S := TStringList.Create;
for i := 0 to FID.Count - 1 do
S.Append(FID[i] + ',' + FValue[i]);
S.SaveToFile(AFileName);
S.Free;
end;
function TVars.Count: Integer;
begin
Result := FID.Count;
end;
function TVars.IsVar(const AVar: string): Boolean;
begin
Result := FID.IndexOf(AVar) > -1;
end;
procedure TVars.ClearGameVars;
var
i: Integer;
S: string;
begin
for i := FID.Count - 1 downto 0 do
begin
S := Copy(Trim(FID[i]), 1, 5);
if (S = 'Game.') then
Continue;
//FValue[I] := '';
FID.Delete(i);
FValue.Delete(i);
end;
end;
procedure TVars.Dec(const VarName: string; Count: Integer);
var
i: Integer;
begin
if (Count < 1) then
Exit;
i := GetInt(VarName);
System.Dec(i, Count);
SetInt(VarName, i);
end;
procedure TVars.Inc(const VarName: string; Count: Integer);
var
i: Integer;
begin
if (Count < 1) then
Exit;
i := GetInt(VarName);
System.inc(i, Count);
SetInt(VarName, i);
end;
procedure TVars.Let(Var1, Var2: string);
var
i: Integer;
S: string;
begin
i := FID.IndexOf(Var2);
if i < 0 then
S := ''
else
S := FValue[i];
i := FID.IndexOf(Var1);
if i < 0 then
begin
FID.Append(Var1);
FValue.Append(S);
end
else
FValue[i] := S;
end;
procedure TVars.LoadFromFile(const AFileName: string);
var
A: TStringList;
i, j: Integer;
S: string;
begin
A := TStringList.Create;
try
Self.Clear;
A.LoadFromFile(AFileName);
for i := 0 to A.Count - 1 do
begin
S := Trim(A[i]);
j := Pos(',', S);
Self.FID.Append(Trim(Copy(S, 1, j - 1)));
Self.FValue.Append(Trim(Copy(S, j + 1, Length(S))));
end;
finally
A.Free;
end;
end;
procedure TVars.EmptyVar(const AVar: string);
var
I: Integer;
begin
I := FID.IndexOf(AVar);
if (I < 0) then Exit;
FID.Delete(I);
FValue.Delete(I);
end;
initialization
VM := TVars.Create;
finalization
VM.Free;
end.
|
{
This file is part of the Free Component Library (FCL)
Copyright (c) 2018 by Michael Van Canneyt
Unit tests for Pascal-to-Javascript converter class.
See the file COPYING.FPC, included in this distribution,
for details about the copyright.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
**********************************************************************
Examples:
./testpas2js --suite=TestCLI_UnitSearch.
./testpas2js --suite=TestUS_Program
./testpas2js --suite=TestUS_UsesEmptyFileFail
}
unit TCUnitSearch;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, contnrs,
fpcunit, testregistry,
PScanner, PasTree,
{$IFDEF CheckPasTreeRefCount}PasResolveEval,{$ENDIF}
Pas2jsFileUtils, Pas2jsCompiler, Pas2JSPCUCompiler, Pas2jsFileCache, Pas2jsLogger,
tcmodules;
type
{ TTestCompiler }
TTestCompiler = class(TPas2jsPCUCompiler)
private
FExitCode: longint;
protected
function GetExitCode: Longint; override;
procedure SetExitCode(Value: Longint); override;
end;
{ TCLIFile }
TCLIFile = class
public
Filename: string;
Source: string;
Age: TPas2jsFileAgeTime;
Attr: TPas2jsFileAttr;
constructor Create(const aFilename, Src: string; aAge: TPas2jsFileAgeTime;
aAttr: TPas2jsFileAttr);
end;
{ TCLILogMsg }
TCLILogMsg = class
public
Msg: string;
MsgTxt: string;
MsgType: TMessageType;
MsgNumber: integer;
MsgFile: string;
MsgLine: integer;
MsgCol: integer;
end;
{ TCustomTestCLI }
TCustomTestCLI = class(TTestCase)
private
FCurDate: TDateTime;
FErrorCol: integer;
FErrorFile: string;
FErrorLine: integer;
FErrorMsg: string;
FErrorNumber: integer;
FWorkDir: string;
FCompilerExe: string;
FCompiler: TTestCompiler;
FDefaultFileAge: longint;
FFiles: TObjectList; // list of TCLIFile
FLogMsgs: TObjectList; // list ot TCLILogMsg
FParams: TStringList;
{$IFDEF EnablePasTreeGlobalRefCount}
FElementRefCountAtSetup: int64;
{$ENDIF}
function GetExitCode: integer;
function GetFiles(Index: integer): TCLIFile;
function GetLogMsgs(Index: integer): TCLILogMsg;
procedure SetExitCode(const AValue: integer);
procedure SetWorkDir(const AValue: string);
protected
procedure SetUp; override;
procedure TearDown; override;
procedure DoLog(Sender: TObject; const Msg: String);
Function OnReadDirectory(Dir: TPas2jsCachedDirectory): boolean; virtual;
Function OnReadFile(aFilename: string; var aSource: string): boolean; virtual;
procedure OnWriteFile(aFilename: string; Source: string); virtual;
procedure WriteSources;
public
constructor Create; override;
destructor Destroy; override;
procedure Compile(const Args: array of string; ExpectedExitCode: longint = 0);
property Compiler: TTestCompiler read FCompiler;
property CompilerExe: string read FCompilerExe write FCompilerExe;
property Params: TStringList read FParams;
property Files[Index: integer]: TCLIFile read GetFiles; // files an directories
function FileCount: integer;
function FindFile(Filename: string): TCLIFile; // files and directories
function ExpandFilename(const Filename: string): string;
function AddFile(Filename, Source: string): TCLIFile;
function AddFile(Filename: string; const SourceLines: array of string): TCLIFile;
function AddUnit(Filename: string; const Intf, Impl: array of string): TCLIFile;
function AddDir(Filename: string): TCLIFile;
procedure AssertFileExists(Filename: string);
property WorkDir: string read FWorkDir write SetWorkDir;
property DefaultFileAge: longint read FDefaultFileAge write FDefaultFileAge;
property ExitCode: integer read GetExitCode write SetExitCode;
property LogMsgs[Index: integer]: TCLILogMsg read GetLogMsgs;
function GetLogCount: integer;
property ErrorMsg: string read FErrorMsg write FErrorMsg;
property ErrorFile: string read FErrorFile write FErrorFile;
property ErrorLine: integer read FErrorLine write FErrorLine;
property ErrorCol: integer read FErrorCol write FErrorCol;
property ErrorNumber: integer read FErrorNumber write FErrorNumber;
property CurDate: TDateTime read FCurDate write FCurDate;
end;
{ TTestCLI_UnitSearch }
TTestCLI_UnitSearch = class(TCustomTestCLI)
published
procedure TestUS_CreateRelativePath;
procedure TestUS_Program;
procedure TestUS_UsesEmptyFileFail;
procedure TestUS_Program_o;
procedure TestUS_Program_FU;
procedure TestUS_Program_FU_o;
procedure TestUS_Program_FE_o;
procedure TestUS_IncludeSameDir;
procedure TestUS_UsesInFile;
procedure TestUS_UsesInFile_Duplicate;
procedure TestUS_UsesInFile_IndirectDuplicate;
procedure TestUS_UsesInFile_WorkNotEqProgDir;
end;
function LinesToStr(const Lines: array of string): string;
implementation
function LinesToStr(const Lines: array of string): string;
var
i: Integer;
begin
Result:='';
for i:=low(Lines) to high(Lines) do
Result:=Result+Lines[i]+LineEnding;
end;
{ TCLIFile }
constructor TCLIFile.Create(const aFilename, Src: string;
aAge: TPas2jsFileAgeTime; aAttr: TPas2jsFileAttr);
begin
Filename:=aFilename;
Source:=Src;
Age:=aAge;
Attr:=aAttr;
end;
{ TTestCompiler }
function TTestCompiler.GetExitCode: Longint;
begin
Result:=FExitCode;
end;
procedure TTestCompiler.SetExitCode(Value: Longint);
begin
FExitCode:=Value;
end;
{ TCustomTestCLI }
function TCustomTestCLI.GetFiles(Index: integer): TCLIFile;
begin
Result:=TCLIFile(FFiles[Index]);
end;
function TCustomTestCLI.GetExitCode: integer;
begin
Result:=Compiler.ExitCode;
end;
function TCustomTestCLI.GetLogMsgs(Index: integer): TCLILogMsg;
begin
Result:=TCLILogMsg(FLogMsgs[Index]);
end;
procedure TCustomTestCLI.SetExitCode(const AValue: integer);
begin
Compiler.ExitCode:=AValue;
end;
procedure TCustomTestCLI.SetWorkDir(const AValue: string);
var
NewValue: String;
begin
NewValue:=IncludeTrailingPathDelimiter(ExpandFileNamePJ(ResolveDots(AValue)));
if FWorkDir=NewValue then Exit;
FWorkDir:=NewValue;
end;
procedure TCustomTestCLI.SetUp;
begin
{$IFDEF EnablePasTreeGlobalRefCount}
FElementRefCountAtSetup:=TPasElement.GlobalRefCount;
{$ENDIF}
inherited SetUp;
FDefaultFileAge:=DateTimeToFileDate(Now);
WorkDir:=ExtractFilePath(ParamStr(0));
{$IFDEF Windows}
CompilerExe:='P:\bin\pas2js.exe';
{$ELSE}
CompilerExe:='/usr/bin/pas2js';
{$ENDIF}
FCompiler:=TTestCompiler.Create;
//FCompiler.ConfigSupport:=TPas2JSFileConfigSupport.Create(FCompiler);
Compiler.Log.OnLog:=@DoLog;
Compiler.FileCache.OnReadDirectory:=@OnReadDirectory;
Compiler.FileCache.OnReadFile:=@OnReadFile;
Compiler.FileCache.OnWriteFile:=@OnWriteFile;
end;
procedure TCustomTestCLI.TearDown;
{$IFDEF CheckPasTreeRefCount}
var
El: TPasElement;
i: integer;
{$ENDIF}
begin
FreeAndNil(FCompiler);
FParams.Clear;
FFiles.Clear;
FLogMsgs.Clear;
FErrorMsg:='';
FErrorFile:='';
FErrorLine:=0;
FErrorCol:=0;
FErrorNumber:=0;
inherited TearDown;
{$IFDEF EnablePasTreeGlobalRefCount}
if FElementRefCountAtSetup<>TPasElement.GlobalRefCount then
begin
writeln('TCustomTestCLI.TearDown GlobalRefCount Was='+IntToStr(FElementRefCountAtSetup)+' Now='+IntToStr(TPasElement.GlobalRefCount));
{$IFDEF CheckPasTreeRefCount}
El:=TPasElement.FirstRefEl;
while El<>nil do
begin
writeln(' ',GetObjName(El),' RefIds.Count=',El.RefIds.Count,':');
for i:=0 to El.RefIds.Count-1 do
writeln(' ',El.RefIds[i]);
El:=El.NextRefEl;
end;
{$ENDIF}
Halt;
Fail('TCustomTestCLI.TearDown Was='+IntToStr(FElementRefCountAtSetup)+' Now='+IntToStr(TPasElement.GlobalRefCount));
end;
{$ENDIF}
end;
procedure TCustomTestCLI.DoLog(Sender: TObject; const Msg: String);
var
LogMsg: TCLILogMsg;
begin
{$IF defined(VerbosePasResolver) or defined(VerbosePCUFiler)}
writeln('TCustomTestCLI.DoLog ',Msg,' File=',Compiler.Log.LastMsgFile,' Line=',Compiler.Log.LastMsgLine);
{$ENDIF}
LogMsg:=TCLILogMsg.Create;
LogMsg.Msg:=Msg;
LogMsg.MsgTxt:=Compiler.Log.LastMsgTxt;
LogMsg.MsgType:=Compiler.Log.LastMsgType;
LogMsg.MsgFile:=Compiler.Log.LastMsgFile;
LogMsg.MsgLine:=Compiler.Log.LastMsgLine;
LogMsg.MsgCol:=Compiler.Log.LastMsgCol;
LogMsg.MsgNumber:=Compiler.Log.LastMsgNumber;
FLogMsgs.Add(LogMsg);
if (LogMsg.MsgType<=mtError) then
begin
if (ErrorFile='')
or ((ErrorLine<1) and (LogMsg.MsgLine>0)) then
begin
ErrorMsg:=LogMsg.MsgTxt;
ErrorFile:=LogMsg.MsgFile;
ErrorLine:=LogMsg.MsgLine;
ErrorCol:=LogMsg.MsgCol;
end;
end;
end;
function TCustomTestCLI.OnReadDirectory(Dir: TPas2jsCachedDirectory): boolean;
var
i: Integer;
aFile: TCLIFile;
Path: String;
begin
Path:=Dir.Path;
//writeln('TCustomTestCLI.ReadDirectory START ',Path,' ',Dir.Count);
Dir.Add('.',DefaultFileAge,faDirectory,4096);
Dir.Add('..',DefaultFileAge,faDirectory,4096);
for i:=0 to FileCount-1 do
begin
aFile:=Files[i];
if CompareFilenames(ExtractFilePath(aFile.Filename),Path)<>0 then continue;
//writeln('TCustomTestCLI.ReadDirectory ',aFile.Filename);
Dir.Add(ExtractFileName(aFile.Filename),aFile.Age,aFile.Attr,length(aFile.Source));
end;
//writeln('TCustomTestCLI.ReadDirectory END ',Path,' ',Dir.Count);
Result:=true;
end;
function TCustomTestCLI.OnReadFile(aFilename: string; var aSource: string
): boolean;
var
aFile: TCLIFile;
begin
aFile:=FindFile(aFilename);
//writeln('TCustomTestCLI.ReadFile ',aFilename,' Found=',aFile<>nil);
if aFile=nil then exit(false);
if (faDirectory and aFile.Attr)>0 then
begin
{$IF defined(VerbosePasResolver) or defined(VerbosePCUFiler)}
writeln('[20180224000557] TCustomTestCLI.OnReadFile ',aFilename);
{$ENDIF}
EPas2jsFileCache.Create('TCustomTestCLI.OnReadFile: reading directory '+aFilename);
end;
aSource:=aFile.Source;
//writeln('TCustomTestCLI.OnReadFile ',aFile.Filename,' "',LeftStr(aFile.Source,50),'"');
Result:=true;
end;
procedure TCustomTestCLI.OnWriteFile(aFilename: string; Source: string);
var
aFile: TCLIFile;
{$IF defined(VerboseUnitQueue) or defined(VerbosePCUFiler)}
//i: Integer;
{$ENDIF}
begin
aFile:=FindFile(aFilename);
{$IF defined(VerboseUnitQueue) or defined(VerbosePCUFiler)}
writeln('TCustomTestCLI.WriteFile ',aFilename,' Found=',aFile<>nil,' SrcLen=',length(Source));
{$ENDIF}
if aFile<>nil then
begin
if (faDirectory and aFile.Attr)>0 then
begin
{$IF defined(VerboseUnitQueue) or defined(VerbosePCUFiler)}
writeln('[20180223175616] TCustomTestCLI.OnWriteFile ',aFilename);
{$ENDIF}
raise EPas2jsFileCache.Create('unable to write file to directory "'+aFilename+'"');
end;
end else
begin
{$IF defined(VerboseUnitQueue) or defined(VerbosePCUFiler)}
//writeln('TCustomTestCLI.OnWriteFile FFiles: ',FFiles.Count);
//for i:=0 to FFiles.Count-1 do
//begin
// aFile:=TCLIFile(FFiles[i]);
// writeln(' ',i,': Filename=',aFile.Filename,' ',CompareFilenames(aFile.Filename,aFilename),' Dir=',(aFile.Attr and faDirectory)>0,' Len=',length(aFile.Source));
//end;
{$ENDIF}
aFile:=TCLIFile.Create(aFilename,'',0,0);
FFiles.Add(aFile);
end;
aFile.Source:=Source;
aFile.Attr:=faNormal;
aFile.Age:=DateTimeToFileDate(CurDate);
writeln('TCustomTestCLI.OnWriteFile ',aFile.Filename,' Found=',FindFile(aFilename)<>nil,' "',LeftStr(aFile.Source,50),'" ');
end;
procedure TCustomTestCLI.WriteSources;
var
i, j, aRow, aCol: Integer;
aFile: TCLIFile;
SrcLines: TStringList;
Line, aFilename: String;
IsSrc: Boolean;
begin
writeln('TCustomTestCLI.WriteSources START');
aFilename:=ErrorFile;
aRow:=ErrorLine;
aCol:=ErrorCol;
SrcLines:=TStringList.Create;
try
for i:=0 to FileCount-1 do
begin
aFile:=Files[i];
if (faDirectory and aFile.Attr)>0 then continue;
writeln('Testcode:-File="',aFile.Filename,'"----------------------------------:');
SrcLines.Text:=aFile.Source;
IsSrc:=ExtractFilename(aFile.Filename)=ExtractFileName(aFilename);
for j:=1 to SrcLines.Count do
begin
Line:=SrcLines[j-1];
if IsSrc and (j=aRow) then
begin
write('*');
Line:=LeftStr(Line,aCol-1)+'|'+copy(Line,aCol,length(Line));
end;
writeln(Format('%:4d: ',[j]),Line);
end;
end;
finally
SrcLines.Free;
end;
end;
constructor TCustomTestCLI.Create;
begin
inherited Create;
FFiles:=TObjectList.Create(true);
FLogMsgs:=TObjectList.Create(true);
FParams:=TStringList.Create;
CurDate:=Now;
end;
destructor TCustomTestCLI.Destroy;
begin
FreeAndNil(FFiles);
FreeAndNil(FLogMsgs);
FreeAndNil(FParams);
inherited Destroy;
end;
procedure TCustomTestCLI.Compile(const Args: array of string;
ExpectedExitCode: longint);
var
i: Integer;
begin
AssertEquals('Initial System.ExitCode',0,system.ExitCode);
for i:=low(Args) to High(Args) do
Params.Add(Args[i]);
try
try
//writeln('TCustomTestCLI.Compile WorkDir=',WorkDir);
Compiler.Run(CompilerExe,WorkDir,Params,false);
except
on E: ECompilerTerminate do
begin
{$IF defined(VerbosePasResolver) or defined(VerbosePCUFiler)}
writeln('TCustomTestCLI.Compile ',E.ClassName,':',E.Message);
{$ENDIF}
end;
on E: Exception do
begin
{$IF defined(VerbosePasResolver) or defined(VerbosePCUFiler)}
writeln('TCustomTestCLI.Compile ',E.ClassName,':',E.Message);
{$ENDIF}
Fail('TCustomTestCLI.Compile '+E.ClassName+':'+E.Message);
end;
end;
finally
Compiler.Log.CloseOutputFile;
end;
if ExpectedExitCode<>ExitCode then
begin
WriteSources;
AssertEquals('ExitCode',ExpectedExitCode,ExitCode);
end;
end;
function TCustomTestCLI.FileCount: integer;
begin
Result:=FFiles.Count;
end;
function TCustomTestCLI.FindFile(Filename: string): TCLIFile;
var
i: Integer;
begin
Filename:=ExpandFilename(Filename);
for i:=0 to FileCount-1 do
if CompareFilenames(Files[i].Filename,Filename)=0 then
exit(Files[i]);
Result:=nil;
end;
function TCustomTestCLI.ExpandFilename(const Filename: string): string;
begin
Result:=SetDirSeparators(Filename);
if not FilenameIsAbsolute(Result) then
Result:=WorkDir+Result;
Result:=ResolveDots(Result);
end;
function TCustomTestCLI.AddFile(Filename, Source: string): TCLIFile;
begin
Filename:=ExpandFilename(Filename);
{$IFDEF VerbosePCUFiler}
writeln('TCustomTestCLI.AddFile ',Filename);
{$ENDIF}
Result:=FindFile(Filename);
if Result<>nil then
raise Exception.Create('[20180224001050] TCustomTestCLI.AddFile already exists: '+Filename);
Result:=TCLIFile.Create(Filename,Source,DefaultFileAge,faNormal);
FFiles.Add(Result);
AddDir(ExtractFilePath(Filename));
end;
function TCustomTestCLI.AddFile(Filename: string;
const SourceLines: array of string): TCLIFile;
begin
Result:=AddFile(Filename,LinesToStr(SourceLines));
end;
function TCustomTestCLI.AddUnit(Filename: string; const Intf,
Impl: array of string): TCLIFile;
var
Name: String;
begin
Name:=ExtractFilenameOnly(Filename);
Result:=AddFile(Filename,
'unit '+Name+';'+LineEnding
+'interface'+LineEnding
+LinesToStr(Intf)
+'implementation'+LineEnding
+LinesToStr(Impl)
+'end.'+LineEnding);
end;
function TCustomTestCLI.AddDir(Filename: string): TCLIFile;
var
p: Integer;
Dir: String;
aFile: TCLIFile;
begin
Result:=nil;
Filename:=IncludeTrailingPathDelimiter(ExpandFilename(Filename));
p:=length(Filename);
while p>1 do
begin
if Filename[p]=PathDelim then
begin
Dir:=LeftStr(Filename,p-1);
aFile:=FindFile(Dir);
if Result=nil then
Result:=aFile;
if aFile=nil then
begin
{$IFDEF VerbosePCUFiler}
writeln('TCustomTestCLI.AddDir add Dir=',Dir);
{$ENDIF}
FFiles.Add(TCLIFile.Create(Dir,'',DefaultFileAge,faDirectory));
end
else if (aFile.Attr and faDirectory)=0 then
begin
{$IFDEF VerbosePCUFiler}
writeln('[20180224001036] TCustomTestCLI.AddDir file exists: Dir=',Dir);
{$ENDIF}
raise EPas2jsFileCache.Create('[20180224001036] TCustomTestCLI.AddDir Dir='+Dir);
end;
dec(p);
end else
dec(p);
end;
end;
procedure TCustomTestCLI.AssertFileExists(Filename: string);
var
aFile: TCLIFile;
begin
aFile:=FindFile(Filename);
AssertNotNull('File not found: '+Filename,aFile);
end;
function TCustomTestCLI.GetLogCount: integer;
begin
Result:=FLogMsgs.Count;
end;
{ TTestCLI_UnitSearch }
procedure TTestCLI_UnitSearch.TestUS_CreateRelativePath;
procedure DoTest(Filename, BaseDirectory, Expected: string;
UsePointDirectory: boolean = false);
var
Actual: String;
begin
ForcePathDelims(Filename);
ForcePathDelims(BaseDirectory);
ForcePathDelims(Expected);
if not TryCreateRelativePath(Filename,BaseDirectory,UsePointDirectory,true,Actual) then
Actual:=Filename;
AssertEquals('TryCreateRelativePath(File='+Filename+',Base='+BaseDirectory+')',
Expected,Actual);
end;
begin
DoTest('/a','/a','');
DoTest('/a','/a','.',true);
DoTest('/a','/a/','');
DoTest('/a/b','/a/b','');
DoTest('/a/b','/a/b/','');
DoTest('/a','/a/','');
DoTest('/a','','/a');
DoTest('/a/b','/a','b');
DoTest('/a/b','/a/','b');
DoTest('/a/b','/a//','b');
DoTest('/a','/a/b','..');
DoTest('/a','/a/b/','..');
DoTest('/a','/a/b//','..');
DoTest('/a/','/a/b','..');
DoTest('/a','/a/b/c','../..');
DoTest('/a','/a/b//c','../..');
DoTest('/a','/a//b/c','../..');
DoTest('/a','/a//b/c/','../..');
DoTest('/a','/b','/a');
DoTest('~/bin','/','~/bin');
DoTest('$(HOME)/bin','/','$(HOME)/bin');
{$IFDEF MSWindows}
DoTest('D:\a\b\c.pas','D:\a\d\','..\b\c.pas');
{$ENDIF}
end;
procedure TTestCLI_UnitSearch.TestUS_Program;
begin
AddUnit('system.pp',[''],['']);
AddFile('test1.pas',[
'begin',
'end.']);
Compile(['test1.pas','-va']);
AssertNotNull('test1.js not found',FindFile('test1.js'));
end;
procedure TTestCLI_UnitSearch.TestUS_UsesEmptyFileFail;
begin
AddFile('system.pp','');
AddFile('test1.pas',[
'begin',
'end.']);
Compile(['test1.pas'],ExitCodeSyntaxError);
AssertEquals('ErrorMsg','Expected "unit"',ErrorMsg);
end;
procedure TTestCLI_UnitSearch.TestUS_Program_o;
begin
AddUnit('system.pp',[''],['']);
AddFile('test1.pas',[
'begin',
'end.']);
Compile(['test1.pas','-obla.js']);
AssertNotNull('bla.js not found',FindFile('bla.js'));
end;
procedure TTestCLI_UnitSearch.TestUS_Program_FU;
begin
AddUnit('system.pp',[''],['']);
AddFile('test1.pas',[
'begin',
'end.']);
AddDir('lib');
Compile(['test1.pas','-FUlib']);
AssertNotNull('lib/test1.js not found',FindFile('lib/test1.js'));
end;
procedure TTestCLI_UnitSearch.TestUS_Program_FU_o;
begin
AddUnit('system.pp',[''],['']);
AddFile('test1.pas',[
'begin',
'end.']);
AddDir('lib');
Compile(['test1.pas','-FUlib','-ofoo.js']);
AssertNotNull('lib/system.js not found',FindFile('lib/system.js'));
AssertNotNull('foo.js not found',FindFile('foo.js'));
end;
procedure TTestCLI_UnitSearch.TestUS_Program_FE_o;
begin
AddUnit('system.pp',[''],['']);
AddFile('test1.pas',[
'begin',
'end.']);
AddDir('lib');
Compile(['test1.pas','-FElib','-ofoo.js']);
AssertNotNull('lib/system.js not found',FindFile('lib/system.js'));
AssertNotNull('foo.js not found',FindFile('foo.js'));
end;
procedure TTestCLI_UnitSearch.TestUS_IncludeSameDir;
begin
AddUnit('system.pp',[''],['']);
AddFile('sub/defines.inc',[
'{$Define foo}',
'']);
AddUnit('sub/unit1.pas',
['{$I defines.inc}',
'{$ifdef foo}',
'var a: longint;',
'{$endif}'],
['']);
AddFile('test1.pas',[
'uses unit1;',
'begin',
' a:=3;',
'end.']);
AddDir('lib');
Compile(['test1.pas','-Fusub','-FElib','-ofoo.js']);
end;
procedure TTestCLI_UnitSearch.TestUS_UsesInFile;
begin
AddUnit('system.pp',[''],['']);
AddUnit('unit1.pas',
['uses bird in ''unit2.pas'';',
'var a: longint;'],
['']);
AddUnit('unit2.pas',
['var b: longint;'],
['']);
AddFile('test1.pas',[
'uses foo in ''unit1.pas'', bar in ''unit2.pas'';',
'begin',
' bar.b:=foo.a;',
' a:=b;',
'end.']);
Compile(['test1.pas','-Jc']);
end;
procedure TTestCLI_UnitSearch.TestUS_UsesInFile_Duplicate;
begin
AddUnit('system.pp',[''],['']);
AddUnit('unit1.pas',
['var a: longint;'],
['']);
AddUnit('sub/unit1.pas',
['var b: longint;'],
['']);
AddFile('test1.pas',[
'uses foo in ''unit1.pas'', bar in ''sub/unit1.pas'';',
'begin',
' bar.b:=foo.a;',
' a:=b;',
'end.']);
Compile(['test1.pas','-Jc'],ExitCodeSyntaxError);
AssertEquals('ErrorMsg','Duplicate file found: "'+WorkDir+'sub/unit1.pas" and "'+WorkDir+'unit1.pas"',ErrorMsg);
end;
procedure TTestCLI_UnitSearch.TestUS_UsesInFile_IndirectDuplicate;
begin
AddUnit('system.pp',[''],['']);
AddUnit('unit1.pas',
['var a: longint;'],
['']);
AddUnit('sub/unit1.pas',
['var b: longint;'],
['']);
AddUnit('unit2.pas',
['uses unit1 in ''unit1.pas'';'],
['']);
AddFile('test1.pas',[
'uses unit2, foo in ''sub/unit1.pas'';',
'begin',
'end.']);
Compile(['test1.pas','-Jc'],ExitCodeSyntaxError);
AssertEquals('ErrorMsg','Duplicate file found: "'+WorkDir+'unit1.pas" and "'+WorkDir+'sub/unit1.pas"',ErrorMsg);
end;
procedure TTestCLI_UnitSearch.TestUS_UsesInFile_WorkNotEqProgDir;
begin
AddUnit('system.pp',[''],['']);
AddUnit('sub/unit2.pas',
['var a: longint;'],
['']);
AddUnit('sub/unit1.pas',
['uses unit2;'],
['']);
AddFile('sub/test1.pas',[
'uses foo in ''unit1.pas'';',
'begin',
'end.']);
Compile(['sub/test1.pas','-Jc']);
end;
Initialization
RegisterTests([TTestCLI_UnitSearch]);
end.
|
unit TerritoryUnit;
interface
uses
REST.Json.Types, System.Generics.Collections, Generics.Defaults,
HttpQueryMemberAttributeUnit, JSONNullableAttributeUnit, NullableBasicTypesUnit,
GenericParametersUnit, TerritoryContourUnit, CommonTypesUnit, AddressUnit;
type
/// <summary>
/// Json schema for an Territory class, which is used for defining different type avoidance zones.
/// </summary>
/// <remarks>
/// https://github.com/route4me/json-schemas/blob/master/Territory.dtd
/// </remarks>
TTerritory = class(TGenericParameters)
private
// [JSONMarshalled(False)]
// [HttpQueryMember('territory_id')]
[JSONNameAttribute('territory_id')]
[Nullable]
FTerritoryId: NullableString;
[JSONNameAttribute('territory_name')]
[Nullable]
FTerritoryName: NullableString;
[JSONNameAttribute('territory_color')]
[Nullable]
FTerritoryColor: NullableString;
[JSONNameAttribute('member_id')]
[Nullable]
FMemberId: NullableString;
[JSONNameAttribute('addresses')]
[NullableArray(TSimpleInteger)]
FAddressIds: TArray<TSimpleInteger>;
// FAddressIds: TArray<integer>;
[JSONNameAttribute('territory')]
[NullableObject(TTerritoryContour)]
FTerritory: NullableObject;
function GetTerritory: TTerritoryContour;
procedure SetTerritory(const Value: TTerritoryContour);
public
constructor Create; overload; override;
constructor Create(TerritoryName, TerritoryColor: String; Territory: TTerritoryContour); reintroduce; overload;
destructor Destroy; override;
function Equals(Obj: TObject): Boolean; override;
/// <summary>
/// 32 character unique identifier
/// </summary>
property Id: NullableString read FTerritoryId write FTerritoryId;
/// <summary>
/// Territory name
/// </summary>
property Name: NullableString read FTerritoryName write FTerritoryName;
/// <summary>
/// Territory color
/// </summary>
property Color: NullableString read FTerritoryColor write FTerritoryColor;
/// <summary>
/// Member ID
/// </summary>
property MemberId: NullableString read FMemberId write FMemberId;
/// <summary>
/// Territory
/// </summary>
property Territory: TTerritoryContour read GetTerritory write SetTerritory;
/// <summary>
/// Territory
/// </summary>
// property AddressIds: TArray<integer> read FAddressIds;
property AddressIds: TArray<TSimpleInteger> read FAddressIds;
procedure AddAddressId(AddressId: integer);
end;
TTerritoryArray = TArray<TTerritory>;
TTerritoryList = TObjectList<TTerritory>;
function SortTerritorys(Territorys: TTerritoryArray): TTerritoryArray;
implementation
uses UtilsUnit;
function SortTerritorys(Territorys: TTerritoryArray): TTerritoryArray;
begin
SetLength(Result, Length(Territorys));
if Length(Territorys) = 0 then
Exit;
TArray.Copy<TTerritory>(Territorys, Result, Length(Territorys));
TArray.Sort<TTerritory>(Result, TComparer<TTerritory>.Construct(
function (const Territory1, Territory2: TTerritory): Integer
begin
Result := Territory1.FTerritoryId.Compare(Territory2.FTerritoryId);
end));
end;
constructor TTerritory.Create;
begin
Inherited Create;
FTerritoryId := NullableString.Null;
FTerritoryName := NullableString.Null;
FTerritoryColor := NullableString.Null;
FMemberId := NullableString.Null;
FTerritory := NullableObject.Null;
SetLength(FAddressIds, 0);
end;
procedure TTerritory.AddAddressId(AddressId: integer);
begin
SetLength(FAddressIds, Length(FAddressIds) + 1);
// FAddressIds[High(FAddressIds)] := AddressId;
FAddressIds[High(FAddressIds)] := TSimpleInteger.Create(AddressId);
end;
constructor TTerritory.Create(TerritoryName, TerritoryColor: String;
Territory: TTerritoryContour);
begin
Create;
FTerritoryName := TerritoryName;
FTerritoryColor := TerritoryColor;
FTerritory := Territory;
end;
destructor TTerritory.Destroy;
begin
FTerritory.Free;
inherited;
end;
function TTerritory.Equals(Obj: TObject): Boolean;
var
Other: TTerritory;
SortedData1, SortedData2: TArray<TSimpleInteger>;
i: integer;
begin
Result := False;
if not (Obj is TTerritory) then
Exit;
Other := TTerritory(Obj);
Result :=
(FTerritoryId = Other.FTerritoryId) and
(FTerritoryName = Other.FTerritoryName) and
(FTerritoryColor = Other.FTerritoryColor) and
(FMemberId = Other.FMemberId) and
(FTerritory = Other.FTerritory) and
(Length(FAddressIds) = Length(Other.FAddressIds));
if not Result then
Exit;
Result := False;
SortedData1 := SortSimpleIntegerArray(FAddressIds);
SortedData2 := SortSimpleIntegerArray(Other.FAddressIds);
for i := 0 to Length(SortedData1) - 1 do
if (SortedData1[i] <> SortedData2[i]) then
Exit;
Result := True;
end;
function TTerritory.GetTerritory: TTerritoryContour;
begin
if (FTerritory.IsNull) then
Result := nil
else
Result := FTerritory.Value as TTerritoryContour;
end;
procedure TTerritory.SetTerritory(const Value: TTerritoryContour);
begin
FTerritory := Value;
end;
end.
|
unit UniTree;
interface
uses
Windows, Classes, ComCtrls, SysUtils, uTreeview_destroy;
type
TUniTreeNode = class(TObject)
private
FParent: TUniTreeNode;
FNextSibling: TUniTreeNode;
FFirstChild: TUniTreeNode;
public
Caption: String;
constructor Create;
destructor Destroy; override;
property Parent: TUniTreeNode read FParent;
property NextSibling: TUniTreeNode read FNextSibling;
property FirstChild: TUniTreeNode read FFirstChild;
end;
TUniTreeNodes = class(TObject)
private
FList: TList;
FRoot: TUniTreeNode;
function GetTopItem: TUniTreeNode;
function GetCount: Integer;
function GetItem(Index: Integer): TUniTreeNode;
public
constructor Create;
destructor Destroy; override;
function IndexOf(Node: TUniTreeNode): Integer;
function Add(Parent: TUniTreeNode): TUniTreeNode;
function Insert(Sibling: TUniTreeNode): TUniTreeNode;
procedure Delete(Node: TUniTreeNode);
property TopItem: TUniTreeNode read GetTopItem;
property Count: Integer read GetCount;
property Items[Index: Integer]: TUniTreeNode read GetItem;
end;
implementation
// IMPLEMENTATION OF TUniTreeNode
constructor TUniTreeNode.Create;
begin
inherited;
Caption := '';
FParent := nil;
FNextSibling := nil;
FFirstChild := nil;
end;
destructor TUniTreeNode.Destroy;
begin
Caption := '';
FParent := nil;
FNextSibling := nil;
FFirstChild := nil;
inherited;
end;
// IMPLEMETATION OF TUniTreeNodes
constructor TUniTreeNodes.Create;
begin
inherited;
FList := TList.Create;
FRoot := TUniTreeNode.Create;
FRoot.Caption := 'Root';
end;
destructor TUniTreeNodes.Destroy;
begin
FreeAndNil(FList);
FreeAndNil(FRoot);
inherited;
end;
function TUniTreeNodes.GetTopItem: TUniTreeNode;
begin
Result := FRoot.FirstChild;
end;
function TUniTreeNodes.GetCount: Integer;
begin
Result := FList.Count;
end;
function TUniTreeNodes.GetItem(Index: Integer): TUniTreeNode;
begin
if (Index >= 0) and (Index < Count) then
Result := FList.Items[Index]
else
raise Exception.Create(Format('%s: Index=%d value is out of rande', [ClassName, Index]));
end;
function TUniTreeNodes.IndexOf(Node: TUniTreeNode): Integer;
var
Ok: Boolean;
begin
Ok := false;
Result := 0;
while (not Ok) and (Result < Count) do
begin
Ok := Items[Result] = Node;
if (not Ok) then
Inc(Result);
end;
if (not Ok) then
Result := -1;
end;
function TUniTreeNodes.Add(Parent: TUniTreeNode): TUniTreeNode;
var
Node, Child: TUniTreeNode;
begin
Node := TUniTreeNode.Create;
FList.Add(Node);
if (IndexOf(Parent) = -1) then
Parent := FRoot;
Node.FParent := Parent;
Child := Parent.FirstChild;
if (Child = nil) then
Parent.FFirstChild := Node
else
begin
while (Child.NextSibling <> nil) do
Child := Child.NextSibling;
Child.FNextSibling := Node;
end;
Result := Node;
end;
function TUniTreeNodes.Insert(Sibling: TUniTreeNode): TUniTreeNode;
var
Node, Parent, PrevChild: TUniTreeNode;
begin
Result := nil;
if (IndexOf(Sibling) = -1) then Exit;
Node := TUniTreeNode.Create;
FList.Add(Node);
Parent := Sibling.Parent;
PrevChild := Parent.FirstChild;
Node.FParent := Sibling.Parent;
if (PrevChild = Sibling) then
Parent.FFirstChild := Node
else
begin
while (PrevChild.NextSibling <> Sibling) do //no check for nil
PrevChild := PrevChild.NextSibling;
PrevChild.FNextSibling := Node;
end;
Node.FNextSibling := Sibling;
Result := Node;
end;
{
procedure TUniTreeNodes.Delete(Node: TUniTreeNode);
procedure DoDelete(Node: TUniTreeNode);
var
Parent, PrevChild, NodeTmp: TUniTreeNode;
begin
if (Node = nil) then Exit;
Parent := Node.Parent;
PrevChild := Parent.FirstChild;
if (PrevChild = Node) then
Parent.FFirstChild := nil
else
begin
while (PrevChild.NextSibling <> Node) do
PrevChild := PrevChild.NextSibling;
PrevChild.FNextSibling := nil;
end;
NodeTmp := Node.NextSibling;
FreeAndNil(Node);
Node := NodeTmp;
Node := Node.FirstChild;
if (Node <> nil) then
begin
DoDelete(Node);
Node := Node.NextSibling;
end;
end;
var
NodeTmp: TUniTreeNode;
begin
if (IndexOf(Node) = -1) then Exit;
while (Node <> nil) do
begin
NodeTmp := Node.NextSibling;
DoDelete(Node);
Node := NodeTmp;
end;
end;
}
procedure TUniTreeNodes.Delete(Node: TUniTreeNode);
procedure DoDereference(ANode: TUniTreeNode);
var
PredNode: TUniTreeNode;
begin
PredNode:=nil;
if (ANode.Parent.FirstChild <> ANode) then
begin
PredNode:=ANode.Parent.FirstChild;
while (PredNode.NextSibling <> ANode) do
PredNode:=PredNode.NextSibling;
end;
if (PredNode <> nil) then
PredNode.FNextSibling:=ANode.NextSibling
else
ANode.Parent.FFirstChild:=ANode.NextSibling;
end;
procedure DoDeleteNodes(ANode: TUniTreeNode);
var
LoopNode: TUniTreeNode;
DeleteNode: TUniTreeNode;
begin
LoopNode:=ANode;
while (LoopNode <> nil) do
begin
if (LoopNode.FirstChild <> nil) then DoDeleteNodes(LoopNode.FirstChild);
DeleteNode:=LoopNode;
LoopNode:=LoopNode.NextSibling;
FList.Delete(IndexOf(DeleteNode));
FreeAndNil(DeleteNode);
end;
end;
begin
if (Node <> nil) then
begin
DoDereference(Node);
if (Node.FirstChild <> nil) then DoDeleteNodes(Node.FirstChild);
FList.Delete(IndexOf(Node));
FreeAndNil(Node);
end;
end;
(*
procedure TUniTreeNodes.Delete(Node: TUniTreeNode);
procedure DoDeleteSibling(Node: TUniTreeNode);
var
BakNode: TUniTreeNode;
begin
if (Node.NextSibling <> nil) and (Node.NextSibling.FirstChild = nil) then
begin
BakNode := Node.NextSibling;
Node.FNextSibling := Node.NextSibling.NextSibling;
Form1.Memo1.Lines.Add('Del ' + BakNode.Caption);
FreeAndNil(BakNode);
end;
end;
procedure DoDeleteChild(Node: TUniTreeNode);
var
BakNode: TUniTreeNode;
begin
if (Node.FirstChild <> nil) and (Node.FirstChild.FirstChild = nil) and (Node.FirstChild.NextSibling = nil) then
begin
BakNode := Node.FirstChild;
Node.FFirstChild := nil;
Form1.Memo1.Lines.Add('Del ' + BakNode.Caption);
FreeAndNil(BakNode);
end;
end;
procedure DoDelete(Node: TUniTreeNode);
begin
DoDeleteSibling(Node);
DoDeleteChild(Node);
Node := Node.FirstChild;
while (Node <> nil) do
begin
// Form1.Memo1.Lines.Add(Node.Caption);
DoDelete(Node);
Node := Node.NextSibling;
end;
end;
var
BakNode: TUniTreeNode;
begin
if (IndexOf(Node) = -1) then Exit;
BakNode := Node;
{
Node := Node.FirstChild;
while (Node <> nil) do
begin
// Form1.Memo1.Lines.Add(Node.Caption);
DoDelete(Node);
Node := Node.NextSibling;
end;
}
Node := BakNode.FirstChild;
while (Node <> nil) and ((Node.FirstChild <> nil) or (Node.NextSibling <> nil)) do
begin
while (Node <> nil) do
begin
// Form1.Memo1.Lines.Add(Node.Caption);
DoDelete(Node);
Node := Node.NextSibling;
end;
Node := BakNode.FirstChild;
end;
Node := BakNode;
DoDeleteChild(Node);
end;
*)
end.
|
unit infosistemas.business.clientes;
interface
uses
System.Classes, System.SysUtils;
type
TClientesUtils = class(TObject)
public
constructor Create;
destructor Destroy; override;
function ValidateCPF(const CPF: string): boolean;
end;
implementation
{ TClientes }
constructor TClientesUtils.Create;
begin
inherited Create;
end;
destructor TClientesUtils.Destroy;
begin
inherited Destroy;
end;
function TClientesUtils.ValidateCPF(const CPF: string): boolean;
var
dig10, dig11: string;
s, i, r, peso: integer;
begin
//Valida se o CPF do cliente possui um formato válido.
// Validação básica inicial: não pode ser números iguais ou ter comprimento
//diferente do esperado (11).
Result := not
((CPF = '00000000000') or (CPF = '11111111111') or
(CPF = '22222222222') or (CPF = '33333333333') or
(CPF = '44444444444') or (CPF = '55555555555') or
(CPF = '66666666666') or (CPF = '77777777777') or
(CPF = '88888888888') or (CPF = '99999999999') or
(length(CPF) <> 11)) ;
if Result = False then
Exit;
// Protege o código para eventuais erros de conversão de tipo na função StrToInt
try
{ *-- Cálculo do 1o. Dígito Verificador --* }
s := 0;
peso := 10;
for i := 1 to 9 do
begin
s := s + (StrToInt(CPF[i]) * peso);
peso := peso - 1;
end;
r := 11 - (s mod 11);
if ((r = 10) or (r = 11)) then
dig10 := '0'
else
str(r:1, dig10); // converte um número no respectivo caractere numérico
{ *-- Cálculo do 2o. Dígito Verificador --* }
s := 0;
peso := 11;
for i := 1 to 10 do
begin
s := s + (StrToInt(CPF[i]) * peso);
peso := peso - 1;
end;
r := 11 - (s mod 11);
if ((r = 10) or (r = 11)) then
dig11 := '0'
else
str(r:1, dig11);
{ Verifica se os dígitos calculados conferem com os dígitos informados. }
Result := ((dig10 = CPF[10]) and (dig11 = CPF[11]));
except
Result := false
end;
end;
end.
|
unit uConfig;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils;
type
{ TConfig }
TConfig = class
private
ExePath:string; //слэш на конце
public
constructor Create;
destructor Destroy;override;
//полный абсолютный путь к базе данных
function BaseFile:string;
function DebugLogFile:string;
function DebugLogDirectory:string;
end;
var GlobalConfig:TConfig;
implementation
uses Forms;
{ TConfig }
constructor TConfig.Create;
begin
ExePath:=ExtractFilePath(Application.ExeName);
end;
destructor TConfig.Destroy;
begin
inherited Destroy;
end;
function TConfig.BaseFile: string;
begin
Result:=ExePath + 'base/germesorders.db3';
end;
function TConfig.DebugLogFile: string;
begin
Result:=ExePath + 'debug.log';
end;
function TConfig.DebugLogDirectory: string;
begin
Result:=ExePath + 'logs';
end;
initialization
GlobalConfig:=TConfig.Create;
finalization
FreeAndNil(GlobalConfig);
end.
|
unit UAccessPattern;
interface
uses IniFiles, Classes;
type
TPathTemplate = class(TObject)
private
FFileName: string;
FPattern: string;
FPath: string;
FOldWindows: Integer;
FNewWindows: string;
FCaption: string;
FIni: TIniFile;
FPatternBegin: string;
FPatternEnd: string;
FPatternBeginLength: Integer;
FPatternEndLength: Integer;
procedure SetPatternBegin(const Value: string);
procedure SetPatternEnd(const Value: string);
procedure SetCaption(const Value: string);
procedure SetPattern(const Value: string);
procedure SetNewWindows(const Value: string);
procedure SetOldWindows(const Value: Integer);
public
property FileName: string read FFileName;
property Pattern: string read FPattern write SetPattern;
property Path: string read FPath;
property Caption: string read FCaption write SetCaption;
property OldWindows: Integer read FOldWindows write SetOldWindows;
property NewWindows: string read FNewWindows write SetNewWindows;
property PatternBegin: string read FPatternBegin write SetPatternBegin;
property PatternEnd: string read FPatternEnd write SetPatternEnd;
property PatternBeginLength: Integer read FPatternBeginLength;
property PatternEndLength: Integer read FPatternEndLength;
constructor Create(const aFileName: string; const bCreateNew: Boolean =
True);
destructor Destroy; override;
procedure WritePattern(const aPattern: string; const aCaption: string
= ''; const aPath: string = ''; const aOldWindows: Integer = -1; const
aNewWindows: string = '');
function ReadString(const aPattern: string): string;
function GetPath(const aPathTemplate: string): string;
procedure GetPatterns(aList: TStrings);
procedure Save;
procedure DeletePattern(const aPattern: string);
end;
implementation
uses StrUtils, SysUtils, SAVLib, UAccessConstant;
{ TPathTemplate }
constructor TPathTemplate.Create(const aFileName: string; const bCreateNew:
Boolean = True);
begin
FIni := TIniFile.Create(aFileName);
FPatternBegin := FIni.ReadString(csPattern, 'begin', '~%%');
FPatternEnd := FIni.ReadString(csPattern, 'end', '%%~');
FPatternBeginLength := Length(FPatternBegin);
FPatternEndLength := Length(FPatternEnd);
if (bCreateNew) and (FileExists(aFileName) = False) then
begin
WritePattern('appdat', 'User Application Data', '', CSIDL_APPDATA,
GUIDToString(FOLDERID_RoamingAppData));
WritePattern('desktp', 'User Desktop', '', CSIDL_DESKTOP,
GUIDToString(FOLDERID_Desktop));
WritePattern('autrun', 'User Autorun', '', CSIDL_STARTUP,
GUIDToString(FOLDERID_Startup));
WritePattern('locapp', 'User Local Application Data', '',
CSIDL_LOCAL_APPDATA,
GUIDToString(FOLDERID_LocalAppData));
end;
end;
procedure TPathTemplate.DeletePattern(const aPattern: string);
begin
FIni.EraseSection(aPattern);
end;
destructor TPathTemplate.Destroy;
begin
FreeAndNil(FIni);
inherited;
end;
function TPathTemplate.GetPath(const aPathTemplate: string): string;
var
i, j, x, PosEnd1, n: Integer;
sPattern: string;
begin
i := Pos(FPatternBegin, aPathTemplate);
j := PosEx(FPatternEnd, aPathTemplate, i + FPatternBeginLength);
n := Length(aPathTemplate);
x := 1;
if (i > 0) and (j > 0) then
begin
Result := '';
PosEnd1 := i + FPatternBeginLength;
while (i > 0) and (j > 0) and (j > PosEnd1) and (x < n) do
begin
Result := Result + copy(aPathTemplate, x, i - x);
sPattern := Copy(aPathTemplate, PosEnd1, j - PosEnd1);
Result := Result + ReadString(sPattern);
x := j + FPatternEndLength;
i := PosEx(FPatternBegin, aPathTemplate, x);
j := PosEx(FPatternEnd, aPathTemplate, i + FPatternBeginLength);
PosEnd1 := i + FPatternBeginLength;
end;
if x <= n then
Result := Result + copy(aPathTemplate, x, n - x + 1)
end
else
Result := aPathTemplate;
end;
procedure TPathTemplate.GetPatterns(aList: TStrings);
var
i: Integer;
begin
FIni.ReadSections(aList);
i := 0;
while i < aList.Count do
begin
if aList[i] = csPattern then
begin
aList.Delete(i);
i := aList.Count;
end
else
Inc(i);
end;
end;
function TPathTemplate.ReadString(const aPattern: string): string;
var
sPath, sNewWind: string;
iOldWind: Integer;
begin
if FIni.SectionExists(aPattern) then
begin
sPath := Fini.ReadString(aPattern, 'path', '');
sNewWind := FIni.ReadString(aPattern, 'winnew', '');
iOldWind := FIni.ReadInteger(aPattern, 'winold', -1);
if sPath = '' then
Result := SAVLib.GetSpecialFolderLocation(iOldWind, StringToGUID(sNewWind))
else
Result := sPath;
end
else
Result := '';
end;
procedure TPathTemplate.Save;
begin
//FIni.UpdateFile;
end;
procedure TPathTemplate.SetCaption(const Value: string);
begin
FCaption := Value;
FIni.WriteString(FPattern, 'caption', Value);
end;
procedure TPathTemplate.SetNewWindows(const Value: string);
begin
FNewWindows := Value;
FIni.WriteString(FPattern, 'winnew', Value);
end;
procedure TPathTemplate.SetOldWindows(const Value: Integer);
begin
FOldWindows := Value;
FIni.WriteInteger(FPattern, 'winold', Value);
end;
procedure TPathTemplate.SetPattern(const Value: string);
begin
FPattern := Value;
FPath := Fini.ReadString(FPattern, 'path', '');
FCaption := FIni.ReadString(FPattern, 'caption', '');
FNewWindows := FIni.ReadString(FPattern, 'winnew', '');
FOldWindows := FIni.ReadInteger(FPattern, 'winold', -1);
end;
procedure TPathTemplate.SetPatternBegin(const Value: string);
begin
FPatternBegin := Value;
FPatternBeginLength := Length(Value);
FIni.WriteString(csPattern, 'begin', Value);
end;
procedure TPathTemplate.SetPatternEnd(const Value: string);
begin
FPatternEnd := Value;
FPatternEndLength := Length(Value);
FIni.WriteString(csPattern, 'end', Value);
end;
procedure TPathTemplate.WritePattern(const aPattern, aCaption, aPath: string;
const aOldWindows: Integer; const aNewWindows: string);
begin
FIni.WriteString(aPattern, 'caption', aCaption);
FIni.WriteString(aPattern, 'path', aPath);
FIni.WriteInteger(aPattern, 'winold', aOldWindows);
FIni.WriteString(aPattern, 'winnew', aNewWindows);
end;
end.
|
unit MazeMain;
interface
type
TMaze = array of array of (Wall, Pass, Visited);
TPos = record
PosX, PosY: Integer;
end;
TMazeSize = (Small, Medium, Large);
TMazeGenAlg = (HuntAKill, BackTrack, Prim);
TMazeSolveAlg = (BFS, DFS, LeftHand, RightHand);
TRoute = array of TPos;
TMazeStat = packed record
FileName: String[50];
DateTime: TDateTime;
MazeSeed: Integer;
MazeSize: TMazeSize;
GenStartPos: TPos;
StartPoint, EndPoint: TPos;
MazeGenAlg: TMazeGenAlg;
MazeSolveAlg: TMazeSolveAlg;
VisitedCells: packed record
Route: Integer;
FullRoute: Integer;
end;
TotalTime : packed record
SolvingTime: Integer;
GenTime: Integer;
end;
end;
const
MazeSize: array[TMazeSize, 0..1] of Integer = ((15, 15), (30, 30), (50, 50));
Procedure CleanMaze(var MazeToClean: TMaze);
function GetExitCell(const MazeToFind: TMaze): TPos;
function GetStartCell(const MazeToFind: TMaze): TPos;
function GetSolveAlgStr(const SolveAlg: TMazeSolveAlg): string;
function GetGenAlgStr(const GenAlg: TMazeGenAlg): string;
function GetMazeSizeStr(const MazeSize: TMazeSize): string;
implementation
Procedure CleanMaze(var MazeToClean: TMaze);
var
I: Integer;
J: Integer;
begin
for I := Low(MazeToClean) to High(MazeToClean) do
for J := Low(MazeToclean[I]) to High(MazeToClean[I]) do
MazeToClean[I,J] := Wall;
end;
function GetExitCell(const MazeToFind: TMaze): TPos;
var
I: Integer;
begin
for I := High(MazeToFind[0]) downto Low(MazeToFind[0]) do
if MazeToFind[High(MazeToFind), I] = Pass then
begin
Result.PosX := I;
Result.PosY := High(MazeToFind);
Exit;
end;
end;
function GetStartCell(const MazeToFind: TMaze): TPos;
var
I: Integer;
begin
for I := Low(MazeToFind[0]) to High(MazeToFind[0]) do
if MazeToFind[Low(MazeToFind), I] = Pass then
begin
Result.PosX := I;
Result.PosY := Low(MazeToFind);
Exit;
end;
end;
////////////////////////
//Get text equivalents//
// of types items //
////////////////////////
function GetGenAlgStr(const GenAlg: TMazeGenAlg): string;
begin
case GenAlg of
HuntAKill: Result := 'Hunt-and-Kill';
BackTrack: Result := 'Backtracker';
Prim: Result := 'Prim';
end;
end;
function GetMazeSizeStr(const MazeSize: TMazeSize): string;
begin
case MazeSize of
Small: Result := 'Малый';
Medium: Result := 'Средний';
Large: Result := 'Большой';
end;
end;
function GetSolveAlgStr(const SolveAlg: TMazeSolveAlg): string;
begin
case SolveAlg of
BFS: Result := 'BFS';
DFS: Result := 'DFS';
LeftHand: Result := 'Left hand';
RightHand: Result := 'Right hand';
end;
end;
end.
|
unit IdCTypes;
interface
{$i IdCompilerDefines.inc}
{This unit should not contain ANY program code. It is meant to be extremely
thin. The idea is that the unit will contain type mappings that used for headers
and API calls using the headers. The unit is here because in cross-platform
headers, the types may not always be the same as they would for Win32 on x86
Intel architecture. We also want to be completely compatiable with Borland
Delphi for Win32.}
{$IFDEF HAS_UNIT_ctypes}
uses
ctypes;
{$ENDIF}
{
IMPORTANT!!!
The types below are defined to hide architecture differences for various C++
types while also making this header compile with Borland Delphi.
}
type
{$IFDEF FPC}
TIdC_LONG = cLong;
PIdC_LONG = pcLong;
TIdC_ULONG = cuLong;
PIdC_ULONG = pculong;
TIdC_LONGLONG = clonglong;
PIdC_LONGLONG = pclonglong;
TIdC_ULONGLONG = culonglong;
PIdC_ULONGLONG = pculonglong;
TIdC_SHORT = cshort;
PIdC_SHORT = pcshort;
TIdC_USHORT = cuShort;
PIdC_USHORT = pcuShort;
TIdC_INT = cInt;
PIdC_INT = pcInt;
TIdC_UINT = cUInt;
PIdC_UINT = pcUInt;
TIdC_SIGNED = csigned;
PIdC_SIGNED = pcsigned;
TIdC_UNSIGNED = cunsigned;
PIdC_UNSIGNED = pcunsigned;
TIdC_INT8 = cint8;
PIdC_INT8 = pcint8;
TIdC_UINT8 = cuint8;
PIdC_UINT8 = pcuint8;
TIdC_INT16 = cint16;
PIdC_INT16 = pcint16;
TIdC_UINT16 = cuint16;
PIdC_UINT16 = pcuint16;
TIdC_INT32 = cint32;
PIdC_INT32 = pcint32;
TIdC_UINT32 = cint32;
PIdC_UINT32 = pcuint32;
TIdC_INT64 = cint64;
PIdC_INT64 = pcint64;
TIdC_UINT64 = cuint64;
PIdC_UINT64 = pcuint64;
TIdC_FLOAT = cfloat;
PIdC_FLOAT = pcfloat;
TIdC_DOUBLE = cdouble;
PIdC_DOUBLE = pcdouble;
TIdC_LONGDOUBLE = clongdouble;
PIdC_LONGDOUBLE = pclongdouble;
{$ELSE}
//this is necessary because Borland still doesn't support QWord
// (unsigned 64bit type).
qword = {$IFDEF HAS_UInt64}UInt64{$ELSE}Int64{$ENDIF};
TIdC_LONG = LongInt;
PIdC_LONG = ^TIdC_LONG;
TIdC_ULONG = LongWord;
PIdC_ULONG = ^TIdC_ULONG;
TIdC_LONGLONG = Int64;
PIdC_LONGLONG = ^TIdC_ULONGLONG;
TIdC_ULONGLONG = qword;
PIdC_ULONGLONG = ^TIdC_ULONGLONG;
TIdC_SHORT = smallint;
PIdC_SHORT = ^TIdC_SHORT;
TIdC_USHORT = Word;
PIdC_USHORT = ^TIdC_USHORT;
TIdC_INT = LongInt;
PIdC_INT = ^TIdC_INT;
TIdC_UINT = LongWord;
PIdC_UINT = ^TIdC_UINT;
TIdC_SIGNED = LongInt;
PIdC_SIGNED = ^TIdC_SIGNED;
TIdC_UNSIGNED = LongWord;
PIdC_UNSIGNED = ^TIdC_UNSIGNED;
TIdC_INT8 = shortint;
PIdC_INT8 = ^TIdC_INT8;
TIdC_UINT8 = byte;
PIdC_UINT8 = ^TIdC_UINT8;
TIdC_INT16 = smallint;
PIdC_INT16 = ^TIdC_INT16;
TIdC_UINT16 = word;
PIdC_UINT16 = ^TIdC_UINT16;
TIdC_INT32 = longint;
PIdC_INT32 = ^TIdC_INT32;
TIdC_UINT32 = longword;
PIdC_UINT32 = ^TIdC_UINT32;
TIdC_INT64 = Int64;
PIdC_INT64 = ^TIdC_INT64;
TIdC_UINT64 = qword;
PIdC_UINT64 = ^TIdC_UINT64;
TIdC_FLOAT = single;
PIdC_FLOAT = ^TIdC_FLOAT;
TIdC_DOUBLE = double;
PIdC_DOUBLE = ^TIdC_DOUBLE;
TIdC_LONGDOUBLE = extended;
PIdC_LONGDOUBLE = ^TIdC_LONGDOUBLE;
//Some headers require this in D5 or earlier.
//FreePascal already has this in its system unit.
{$IFNDEF HAS_PByte}PByte = ^Byte;{$ENDIF}
{$IFNDEF HAS_PWord}PWord = ^Word;{$ENDIF}
{$ENDIF}
implementation
end.
|
{ //************************************************************// }
{ // // }
{ // Código gerado pelo assistente // }
{ // // }
{ // Projeto MVCBr // }
{ // tireideletra.com.br / amarildo lacerda // }
{ //************************************************************// }
{ // Data: 08/04/2017 10:52:03 // }
{ //************************************************************// }
/// <summary>
/// Uma View representa a camada de apresentação ao usuário
/// deve esta associado a um controller onde ocorrerá
/// a troca de informações e comunicação com os Models
/// </summary>
unit TestViewView;
interface
uses
{$IFDEF FMX}FMX.Forms, {$ELSE}VCL.Forms, {$ENDIF}
System.SysUtils, System.Classes, MVCBr.Interf,
System.JSON,
MVCBr.View, MVCBr.FormView, MVCBr.Controller;
type
/// Interface para a VIEW
ITestViewView = interface(IView)
['{C32F6695-D88B-42C3-A605-04D878600545}']
// incluir especializacoes aqui
function getStubInt: integer;
end;
/// Object Factory que implementa a interface da VIEW
TTestViewView = class(TFormFactory { TFORM } , IView, IThisAs<TTestViewView>,
ITestViewView, IViewAs<ITestViewView>)
private
FInited: Boolean;
protected
procedure Init;
function Controller(const aController: IController): IView; override;
public
{ Public declarations }
class function New(aController: IController): IView;
function This: TObject; override;
function ThisAs: TTestViewView;
function ViewAs: ITestViewView;
function ShowView(const AProc: TProc<IView>): integer; override;
function Update: IView; override;
function GetShowModalStub: Boolean;
function getStubInt: integer;
function ViewEvent(AMessage: string; var AHandled: Boolean): IView;
overload; override;
function ViewEvent(AJson: TJsonValue; var AHandled: Boolean): IView;
overload; override;
end;
Implementation
{$R *.DFM}
function TTestViewView.Update: IView;
begin
result := self;
{ codigo para atualizar a View vai aqui... }
end;
function TTestViewView.ViewEvent(AJson: TJsonValue;
var AHandled: Boolean): IView;
var
txt: string;
begin
result := self;
if AJson.TryGetValue<string>('texto', txt) then
AHandled := txt = 'test';
end;
function TTestViewView.ViewAs: ITestViewView;
begin
result := self;
end;
function TTestViewView.ViewEvent(AMessage: string;
var AHandled: Boolean): IView;
begin
/// recebe um evento.
///
if AMessage = 'teste.event' then
AHandled := true;
end;
class function TTestViewView.New(aController: IController): IView;
begin
result := TTestViewView.create(nil);
result.Controller(aController);
end;
function TTestViewView.Controller(const aController: IController): IView;
begin
result := inherited Controller(aController);
if not FInited then
begin
Init;
FInited := true;
end;
end;
function TTestViewView.GetShowModalStub: Boolean;
begin
result := isShowModal;
end;
function TTestViewView.getStubInt: integer;
begin
result := 1;
end;
procedure TTestViewView.Init;
begin
// incluir incializações aqui
end;
function TTestViewView.This: TObject;
begin
result := inherited This;
end;
function TTestViewView.ThisAs: TTestViewView;
begin
result := self;
end;
function TTestViewView.ShowView(const AProc: TProc<IView>): integer;
begin
inherited;
end;
end.
|
unit Unbound.GameState;
interface
uses
System.SysUtils,
Pengine.IntMaths,
Pengine.GLGame,
Pengine.ICollections;
type
EGameState = class(Exception);
TGameStateClass = class of TGameState;
TGameStateManager = class;
TGameState = class
private
FManager: TGameStateManager;
FLoaded: Boolean;
function GetManager: TGameStateManager;
function GetGLGame: TGLGame;
function GetLoaded: Boolean;
procedure SetLoaded(const Value: Boolean);
protected
procedure DoLoad; virtual;
procedure DoUnload; virtual;
public
constructor Create(AManager: TGameStateManager);
destructor Destroy; override;
property Manager: TGameStateManager read GetManager;
property GLGame: TGLGame read GetGLGame;
property Loaded: Boolean read GetLoaded write SetLoaded;
procedure Load;
procedure Unload;
procedure Update; virtual;
procedure Render; virtual;
end;
TGameStateManager = class
private
FGLGame: TGLGame;
FStates: IObjectList<TGameState>;
function GetState(AStateClass: TGameStateClass): TGameState;
procedure Update;
procedure Render;
public
constructor Create(AGLGame: TGLGame);
property GLGame: TGLGame read FGLGame;
procedure AddState(AStateClass: TGameStateClass);
property States[AStateClass: TGameStateClass]: TGameState read GetState; default;
procedure Add<T: TGameState>; inline;
function Get<T: TGameState>: T; inline;
end;
implementation
{ TGameState }
function TGameState.GetManager: TGameStateManager;
begin
Result := FManager;
end;
destructor TGameState.Destroy;
begin
Unload;
inherited;
end;
procedure TGameState.DoLoad;
begin
// nothing
end;
procedure TGameState.DoUnload;
begin
// nothing
end;
function TGameState.GetGLGame: TGLGame;
begin
Result := Manager.GLGame;
end;
function TGameState.GetLoaded: Boolean;
begin
Result := FLoaded;
end;
procedure TGameState.SetLoaded(const Value: Boolean);
begin
if Value then
Load
else
Unload;
end;
constructor TGameState.Create(AManager: TGameStateManager);
begin
FManager := AManager;
end;
procedure TGameState.Load;
begin
if not Loaded then
begin
FLoaded := True;
DoLoad;
end;
end;
procedure TGameState.Unload;
begin
if Loaded then
begin
FLoaded := False;
DoUnload;
end;
end;
procedure TGameState.Update;
begin
// nothing
end;
procedure TGameState.Render;
begin
// nothing
end;
{ TGameStateManager }
function TGameStateManager.Get<T>: T;
begin
Result := T(States[T]);
end;
function TGameStateManager.GetState(AStateClass: TGameStateClass): TGameState;
var
State: TGameState;
begin
for State in FStates do
if State is AStateClass then
Exit(State);
raise EGameState.Create('Game-State not registered.');
end;
procedure TGameStateManager.Update;
var
State: TGameState;
begin
for State in FStates do
if State.Loaded then
State.Update;
end;
procedure TGameStateManager.Render;
var
State: TGameState;
begin
for State in FStates do
if State.Loaded then
State.Render;
end;
procedure TGameStateManager.Add<T>;
begin
AddState(T);
end;
procedure TGameStateManager.AddState(AStateClass: TGameStateClass);
begin
FStates.Add(AStateClass.Create(Self));
end;
constructor TGameStateManager.Create(AGLGame: TGLGame);
begin
FGLGame := AGLGame;
FStates := TObjectList<TGameState>.Create;
GLGame.OnUpdate.Add(Update);
GLGame.OnRender.Add(Render);
end;
end.
|
unit EmailOrdering.SharedData;
interface
uses
System.SysUtils;
type
TSharedData = class
private
class function GetConfigFilePath: string; static;
class function GetOrderLogPath: string; static;
class function GetHelpUrl: string; static;
public
class property ConfigFilePath: string read GetConfigFilePath;
class property OrderLogPath: string read GetOrderLogPath;
class property HelpUrl: string read GetHelpUrl;
end;
implementation
{ TSharedData }
class function TSharedData.GetHelpUrl: string;
begin
Result := 'http://10.1.1.15:7778/applications/AVIMark/Help';
end;
class function TSharedData.GetOrderLogPath: string;
begin
Result := format('%s\Wddc\EmailOrdering\%s', [System.SysUtils.GetEnvironmentVariable('ALLUSERSPROFILE')
,'orderlog.xml']);
end;
{ TSharedData }
class function TSharedData.GetConfigFilePath: string;
begin
Result := format('%s\Wddc\EmailOrdering\%s', [System.SysUtils.GetEnvironmentVariable('ALLUSERSPROFILE')
,'emailordering.config.json']);
end;
end.
|
unit MazePrint;
interface
uses
MazeMain, Graphics;
const
clFullRoute = clWebLightGreen;
clRoute = clGreen;
clStartPoint = clRed;
clExitPoint = clBlue;
Procedure CalcCellSize(Width, Height: Integer; MazeInd: TMazeSize; out XSize, YSize: Integer);
Procedure PrintMaze(const Canv: TCanvas; const MazeToPrint: TMaze; CellSizeX, CellSizeY: Integer);
Procedure PrintRoute(const Canv: TCanvas; const RouteToPrint: TRoute; CellSizeX, CellSizeY: Integer; CellColor: TColor);
Procedure PrintIOPoints(const Canv: TCanvas; const StartC, EndC: TPos; CellSizeX, CellSizeY: Integer);
implementation
//Get cell size
Procedure CalcCellSize(Width, Height: Integer; MazeInd: TMazeSize; out XSize, YSize: Integer);
begin
XSize := Trunc(Width/(MazeSize[MazeInd, 1]+4));
YSize := Trunc(Height/(MazeSize[MazeInd, 0]+4));
end;
//Print Maze use rectangles
Procedure PrintMaze(const Canv: TCanvas; const MazeToPrint: TMaze; CellSizeX, CellSizeY: Integer);
//CellSizeX, CellSizeY - sizes of cells to paint
var
RectX, RectY: Integer;
StartX{, StartY}: Integer;
I, J: Integer;
begin
RectX := CellSizeX;
RectY := CellSizeY;
StartX := RectX;
//StartY := RectY;
with Canv do
begin
Brush.Color := clBlack;
Pen.Color := clBlack;
for I := Low(MazeToPrint[0]) to Length(MazeToPrint[0])+1 do
Rectangle(RectX*(I+1), RectY, RectX*(I+1)+CellSizeX, RectY+CellSizeY);
//Cycle fot lines
for I := Low(MazeToPrint) to High(MazeToPrint) do
begin
RectX := StartX;
RectY := RectY + CellSizeY;
Rectangle(RectX, RectY, RectX+CellSizeX, RectY+CellSizeY);
//Cycle for collumns
//Print rectangle if Maze[i, J] - wall
for J := Low(MazeToPrint[I]) to High(MazeToPrint[I]) do
if MazeToPrint[I, J] = Wall then
Rectangle(RectX*(J+2), RectY, RectX*(J+2)+CellSizeX, RectY+CellSizeY);
Rectangle(RectX*(Length(MazeToPrint[I])+2), RectY, RectX*(Length(MazeToPrint[I])+2)+CellSizeX, RectY+CellSizeY);
end;
for I := Low(MazeToPrint[0]) to Length(MazeToPrint[0])+1 do
Rectangle(RectX*(I+1), RectY+CellSizeY, RectX*(I+1)+CellSizeX, RectY+CellSizeY*2);
end;
end;
//Print route cell by cell
Procedure PrintRoute(const Canv: TCanvas; const RouteToPrint: TRoute; CellSizeX, CellSizeY: Integer; CellColor: TColor);
var
I: Integer;
begin
with Canv do
begin
Brush.Color := CellColor;
Pen.Color := CellColor;
for I := Low(RouteToPrint) to High(RouteToPrint) do
Rectangle(CellSizeX*(RouteToPrint[I].PosX+2), CellSizeY*(RouteToPrint[I].PosY+2), CellSizeX*(RouteToPrint[I].PosX+2)+CellSizeX, CellSizeY*(RouteToPrint[I].PosY+2)+CellSizeY);
end;
end;
//Print 2 points Entry and Exit
Procedure PrintIOPoints(const Canv: TCanvas; const StartC, EndC: TPos; CellSizeX, CellSizeY: Integer);
begin
with Canv do
begin
Brush.Color := clStartPoint;
Pen.Color := clStartPoint;
Rectangle(CellSizeX*(StartC.PosX+2), CellSizeY*(StartC.PosY+2), CellSizeX*(StartC.PosX+2)+CellSizeX, CellSizeY*(StartC.PosY+2)+CellSizeY);
Brush.Color := clExitPoint;
Pen.Color := clExitPoint;
Rectangle(CellSizeX*(EndC.PosX+2), CellSizeY*(EndC.PosY+2), CellSizeX*(EndC.PosX+2)+CellSizeX, CellSizeY*(EndC.PosY+2)+CellSizeY);
end;
end;
end.
|
{$REGION 'Copyright (C) CMC Development Team'}
{ **************************************************************************
Copyright (C) 2015 CMC Development Team
CMC 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.
CMC 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 CMC. If not, see <http://www.gnu.org/licenses/>.
************************************************************************** }
{ **************************************************************************
Additional Copyright (C) for this modul:
Chromaprint: Audio fingerprinting toolkit
Copyright (C) 2010-2012 Lukas Lalinsky <lalinsky@gmail.com>
Lomont FFT: Fast Fourier Transformation
Original code by Chris Lomont, 2010-2012, http://www.lomont.org/Software/
************************************************************************** }
{$ENDREGION}
{$REGION 'Notes'}
{ **************************************************************************
See CP.Chromaprint.pas for more information
************************************************************************** }
unit CP.AudioConsumer;
{$IFDEF FPC}
{$MODE delphi}
{$ENDIF}
interface
uses
Classes, SysUtils,
CP.Def;
type
{ TAudioConsumer }
TAudioConsumer = class(TObject)
public
procedure Consume(Input: TSmallintArray; AOffset: integer; ALength: integer); virtual; abstract; // eigentlich abstract
destructor Destroy; override;
end;
implementation
{ TAudioConsumer }
destructor TAudioConsumer.Destroy;
begin
inherited Destroy;
end;
end.
|
unit clEmpresas;
interface
uses clPessoaJuridica, Vcl.Dialogs, System.SysUtils, clConexao;
type
TEmpresas = class(TPessoaJuridica)
protected
FCodigo: Integer;
FUsuario: String;
FDataCadastro: TDateTime;
FObs: String;
FManutencao: TDateTime;
FStatus: String;
conexao : TConexao;
private
FTipoDoc: String;
procedure SetCodigo(val: Integer);
procedure SetUsuario(val: String);
procedure SetManutencao(val: TDateTime);
procedure SetStatus(val: String);
procedure SetObs(val: String);
procedure SetDataCadastro(val: TDateTime);
procedure SetTipoDoc(val: String);
public
property DataCadastro: TDateTime read FDataCadastro write SetDataCadastro;
property Usuario: String read FUsuario write SetUsuario;
property Status: String read FStatus write SetStatus;
property Obs: String read FObs write SetObs;
property Manutencao: TDateTime read FManutencao write SetManutencao;
property Codigo: Integer read FCodigo write SetCodigo;
function Validar: Boolean;
function Exist(sFiltro: String): Boolean;
function Insert: Boolean;
constructor Create;
destructor Destroy; override;
function Update: Boolean;
function getObject(sId: String; sFiltro: String): Boolean;
function getObjects: Boolean;
function getField(sCampo: String; sColuna: String): String;
property TipoDoc: String read FTipoDoc write SetTipoDoc;
end;
const
TABLENAME = 'CAD_EMPRESAS';
implementation
uses clUtil, udm;
procedure TEmpresas.SetCodigo(val: Integer);
begin
FCodigo := val;
end;
procedure TEmpresas.SetUsuario(val: String);
begin
FUsuario := val;
end;
procedure TEmpresas.SetManutencao(val: TDateTime);
begin
FManutencao := val;
end;
procedure TEmpresas.SetStatus(val: String);
begin
FStatus := val;
end;
procedure TEmpresas.SetObs(val: String);
begin
FObs := val;
end;
procedure TEmpresas.SetDataCadastro(val: TDateTime);
begin
FDataCadastro := val;
end;
function TEmpresas.Validar: Boolean;
begin
try
Result := False;
if Self.Razao.IsEmpty then begin
MessageDlg('Informe o Nome ou Razão Social da Empresa!', mtWarning, [mbOK], 0);
Exit;
end;
if Self.Fantasia.IsEmpty then begin
MessageDlg('Informe o Nome Fantasia da Empresa!', mtWarning, [mbOK], 0);
Exit;
end;
if sELF.TipoDoc.IsEmpty then begin
MessageDlg('Informe o Tipo de Documento da Empresa (CPF ou CNPJ)!', mtWarning, [mbOK], 0);
Exit;
end;
if (not Self.Cnpj.IsEmpty) then begin
if Self.TipoDoc = 'CPF' then begin
if (not TUtil.CPF(Self.Cnpj)) then begin
MessageDlg('CPF informado está incorreto!', mtWarning, [mbOK], 0);
Exit;
end;
end
else if (not TUtil.Cnpj(Self.Cnpj)) then begin
MessageDlg('CNPJ informado está incorreto!', mtWarning, [mbOK], 0);
Exit;
end;
end
else begin
if Self.TipoDoc = 'CPF' then begin
MessageDlg('Informe o CPF da Empresa!', mtWarning, [mbOK], 0);
Exit;
end
else begin
MessageDlg('Informe o CNPJ da Empresa!', mtWarning, [mbOK], 0);
Exit;
end;
end;
if Self.Codigo = 0 then begin
if Self.Exist('CNPJ') then begin
if Self.TipoDoc = 'CPF' then begin
MessageDlg('CPF já cadastrado!', mtWarning, [mbOK], 0);
Exit;
end
else begin
MessageDlg('CNPJ já cadastrado!', mtWarning, [mbOK], 0);
Exit;
end;
end;
if Self.Exist('RAZAO') then begin
MessageDlg('Razão Social já cadastrada para outra Empresa!', mtWarning, [mbOK], 0);
Exit;
end;
if Self.Exist('FANTASIA') then begin
MessageDlg('Nome Fantasia já cadastrado para outra Empresa!', mtWarning, [mbOK], 0);
Exit;
end;
if Self.Exist('IE') then begin
MessageDlg('Inscrição Estadual já cadastrada para outra Empresa!', mtWarning, [mbOK], 0);
Exit;
end;
if Self.Exist('IEST') then begin
MessageDlg('Inscrição Estadual Substituição Tributária já cadastrada para outra Empresa!', mtWarning, [mbOK], 0);
Exit;
end;
if Self.Exist('IM') then begin
MessageDlg('Inscrição Municipal já cadastrada para outra Empresa!', mtWarning, [mbOK], 0);
Exit;
end;
end;
if Self.Status.IsEmpty then begin
MessageDlg('Informe o Status da Empresa!', mtWarning, [mbOK], 0);
Exit;
end;
Result := True;
except on E: Exception do
ShowMessage('Classe: ' + E.ClassName + chr(13) + 'Mensagem: ' + E.Message);
end;
end;
function TEmpresas.Exist(sFiltro: String): Boolean;
begin
try
Result := False;
if sFiltro.IsEmpty then begin
Exit;
end;
if (not conexao.VerifyConnZEOS(0)) then begin
MessageDlg('Erro ao estabelecer conexão ao banco de dados!', mtError, [mbCancel], 0);
Exit;
end;
if dm.qryGetObject.Active then begin
dm.qryGetObject.Close;
end;
dm.qryGetObject.SQL.Clear;
dm.qryGetObject.SQL.Add('SELECT * FROM ' + TABLENAME);
if sFiltro = 'CNPJ' then begin
dm.qryGetObject.SQL.Add(' WHERE NUM_CNPJ = :CNPJ');
dm.qryGetObject.ParamByName('CNPJ').AsString := Self.Cnpj;
end
else if sFiltro = 'RAZAO' then begin
dm.qryGetObject.SQL.Add(' WHERE DES_RAZAO_SOCIAL = :RAZAO');
dm.qryGetObject.ParamByName('RAZAO').AsString := Self.Razao;
end
else if sFiltro = 'FANTASIA' then begin
dm.qryGetObject.SQL.Add(' WHERE NOM_FANTASIA = :FANTASIA');
dm.qryGetObject.ParamByName('FANTASIA').AsString := Self.Fantasia;
end
else if sFiltro = 'IE' then begin
dm.qryGetObject.SQL.Add(' WHERE NUM_IE = :IE');
dm.qryGetObject.ParamByName('IE').AsString := Self.IE;
end
else if sFiltro = 'IEST' then begin
dm.qryGetObject.SQL.Add(' WHERE NUM_IEST = :IEST');
dm.qryGetObject.ParamByName('IEST').AsString := Self.IEST;
end
else if sFiltro = 'IM' then begin
dm.qryGetObject.SQL.Add(' WHERE NUM_IM = :IM');
dm.qryGetObject.ParamByName('IM').AsString := Self.IM;
end;
dm.ZConn.PingServer;
dm.qryGetObject.Open;
if (not dm.qryGetObject.IsEmpty) then begin
Result := True;
end;
dm.qryGetObject.Close;
dm.qryGetObject.SQL.Clear;
except on E: Exception do
ShowMessage('Classe: ' + E.ClassName + chr(13) + 'Mensagem: ' + E.Message);
end;
end;
function TEmpresas.Insert: Boolean;
begin
try
Result := False;
if (not conexao.VerifyConnZEOS(0)) then begin
MessageDlg('Erro ao estabelecer conexão ao banco de dados!', mtError, [mbCancel], 0);
Exit;
end;
if dm.qryCRUD.Active then begin
dm.qryCRUD.Close;
end;
dm.qryCRUD.SQL.Clear;
dm.qryCRUD.SQL.Text := 'INSERT INTO ' + TABLENAME + '(' +
'DES_RAZAO_SOCIAL, ' +
'NOM_FANTASIA, ' +
'DES_TIPO_DOC, ' +
'NUM_CNPJ, ' +
'NUM_IE, ' +
'NUM_IEST, ' +
'NUM_IM, ' +
'COD_CNAE, ' +
'COD_CRT, ' +
'COD_STATUS, ' +
'DES_OBSERVACAO, ' +
'DAT_CADASTRO, ' +
'NOM_USUARIO, ' +
'DAT_MANUTENCAO) ' +
'VALUES (' +
':CODIGO, ' +
':RAZAO, ' +
':FANTASIA, ' +
':TIPODOC, ' +
':CNPJ, ' +
':IE, ' +
':IEST, ' +
':IM, ' +
':CNAE, ' +
':CRT, ' +
':STATUS, ' +
':OBS, ' +
':CADASTRO, ' +
':USUARIO, ' +
':MANUTENCAO); ';
dm.qryCRUD.ParamByName('RAZAO').AsString := Self.Razao;
dm.qryCRUD.ParamByName('FANTASIA').AsString := Self.Fantasia;
dm.qryCRUD.ParamByName('TIPODOC').AsString := Self.TipoDoc;
dm.qryCRUD.ParamByName('CNPJ').AsString := Self.Cnpj;
dm.qryCRUD.ParamByName('IE').AsString := Self.IE;
dm.qryCRUD.ParamByName('IEST').AsString := Self.IEST;
dm.qryCRUD.ParamByName('IM').AsString := Self.IM;
dm.qryCRUD.ParamByName('CNAE').AsString := Self.Cnae;
dm.qryCRUD.ParamByName('CRT').AsInteger := Self.Crt;
dm.qryCRUD.ParamByName('STATUS').AsString := Self.Status;
dm.qryCRUD.ParamByName('OBS').AsString := Self.Obs;
dm.qryCRUD.ParamByName('CADASTRO').AsDate := Self.DataCadastro;
dm.qryCRUD.ParamByName('USUARIO').AsString := Self.Usuario;
dm.qryCRUD.ParamByName('MANUTENCAO').AsDateTime := Self.Manutencao;
dm.ZConn.PingServer;
dm.qryCRUD.ExecSQL;
dm.qryCRUD.Close;
dm.qryCRUD.SQL.Clear;
Result := True;
except on E: Exception do
ShowMessage('Classe: ' + E.ClassName + chr(13) + 'Mensagem: ' + E.Message);
end;
end;
constructor TEmpresas.Create;
begin
inherited Create;
conexao := TConexao.Create;
end;
destructor TEmpresas.Destroy;
begin
conexao.Free;
inherited Destroy;
end;
function TEmpresas.Update: Boolean;
begin
try
Result := False;
if (not conexao.VerifyConnZEOS(0)) then begin
MessageDlg('Erro ao estabelecer conexão ao banco de dados!', mtError, [mbCancel], 0);
Exit;
end;
if dm.qryCRUD.Active then begin
dm.qryCRUD.Close;
end;
dm.qryCRUD.SQL.Clear;
dm.qryCRUD.SQL.Text := 'UPDATE ' + TABLENAME + 'SET ' +
'COD_EMPRESA = :CODIGO, ' +
'DES_RAZAO_SOCIAL = :RAZAO, ' +
'NOM_FANTASIA = :FANTASIA, ' +
'DES_TIPO_DOC = :TIPODOC, ' +
'NUM_CNPJ = :CNPJ, ' +
'NUM_IE = :IE:, ' +
'NUM_IEST = :IEST, ' +
'NUM_IM = :IM, ' +
'COD_CNAE:CNAE, ' +
'COD_CRT = :CRT, ' +
'COD_STATUS = :STATUS, ' +
'DES_OBSERVACAO = :OBS, ' +
'DAT_CADASTRO = :CADASTRO, ' +
'NOM_USUARIO = :USUARIO, ' +
'DAT_MANUTENCAO = :MANUTENCAO ' +
'WHERE COD_EMPRESA = :CODIGO; ';
dm.qryCRUD.ParamByName('CODIGO').AsInteger := Self.Codigo;
dm.qryCRUD.ParamByName('RAZAO').AsString := Self.Razao;
dm.qryCRUD.ParamByName('FANTASIA').AsString := Self.Fantasia;
dm.qryCRUD.ParamByName('TIPODOC').AsString := Self.TipoDoc;
dm.qryCRUD.ParamByName('CNPJ').AsString := Self.Cnpj;
dm.qryCRUD.ParamByName('IE').AsString := Self.IE;
dm.qryCRUD.ParamByName('IEST').AsString := Self.IEST;
dm.qryCRUD.ParamByName('IM').AsString := Self.IM;
dm.qryCRUD.ParamByName('CNAE').AsString := Self.Cnae;
dm.qryCRUD.ParamByName('CRT').AsInteger := Self.Crt;
dm.qryCRUD.ParamByName('STATUS').AsString := Self.Status;
dm.qryCRUD.ParamByName('OBS').AsString := Self.Obs;
dm.qryCRUD.ParamByName('CADASTRO').AsDate := Self.DataCadastro;
dm.qryCRUD.ParamByName('USUARIO').AsString := Self.Usuario;
dm.qryCRUD.ParamByName('MANUTENCAO').AsDateTime := Self.Manutencao;
dm.ZConn.PingServer;
dm.qryCRUD.ExecSQL;
dm.qryCRUD.Close;
dm.qryCRUD.SQL.Clear;
Result := True;
except on E: Exception do
ShowMessage('Classe: ' + E.ClassName + chr(13) + 'Mensagem: ' + E.Message);
end;
end;
function TEmpresas.getObject(sId: String; sFiltro: String): Boolean;
begin
try
Result := False;
if sId.IsEmpty then begin
Exit;
end;
if sFiltro.IsEmpty then begin
Exit;
end;
if (not conexao.VerifyConnZEOS(0)) then begin
MessageDlg('Erro ao estabelecer conexão ao banco de dados!', mtError, [mbCancel], 0);
Exit;
end;
if dm.qryGetObject.Active then begin
dm.qryGetObject.Close;
end;
dm.qryGetObject.SQL.Clear;
dm.qryGetObject.SQL.Add('SELECT * FROM ' + TABLENAME);
if sFiltro = 'CODIGO' then begin
dm.qryGetObject.SQL.Add(' WHERE COD_EMPRESA = :CODIGO');
dm.qryGetObject.ParamByName('CODIGO').AsInteger := StrToInt(sId);
end
else if sFiltro = 'CNPJ' then begin
dm.qryGetObject.SQL.Add(' WHERE NUM_CNPJ = :CNPJ');
dm.qryGetObject.ParamByName('CNPJ').AsString := sId;
end
else if sFiltro = 'RAZAO' then begin
dm.qryGetObject.SQL.Add(' WHERE DES_RAZAO_SOCIAL LIKE (:RAZAO)');
dm.qryGetObject.ParamByName('RAZAO').AsString := QuotedStr('%' + sId + '%');
end
else if sFiltro = 'FANTASIA' then begin
dm.qryGetObject.SQL.Add(' WHERE NOM_FANTASIA LIKE (:FANTASIA)');
dm.qryGetObject.ParamByName('FANTASIA').AsString := QuotedStr('%' + sId + '%');
end
else if sFiltro = 'IE' then begin
dm.qryGetObject.SQL.Add(' WHERE NUM_IE = :IE');
dm.qryGetObject.ParamByName('IE').AsString := sId;
end
else if sFiltro = 'IEST' then begin
dm.qryGetObject.SQL.Add(' WHERE NUM_IEST = :IEST');
dm.qryGetObject.ParamByName('IEST').AsString := sId;
end
else if sFiltro = 'IM' then begin
dm.qryGetObject.SQL.Add(' WHERE NUM_IM = :IM');
dm.qryGetObject.ParamByName('IM').AsString := sId;
end
else if sFiltro = 'STATUS' then begin
dm.qryGetObject.SQL.Add(' WHERE COD_STATUS = :STATUS');
dm.qryGetObject.ParamByName('STATUS').AsString := sId;
end;
dm.ZConn.PingServer;
dm.qryGetObject.Open;
if (not dm.qryGetObject.IsEmpty) then begin
dm.qryGetObject.First;
Self.Codigo := dm.qryGetObject.FieldByName('COD_EMPRESA').AsInteger;
Self.Razao := dm.qryGetObject.FieldByName('DES_RAZAO_SOCIAL').AsString;
Self.Fantasia := dm.qryGetObject.FieldByName('NOM_FANTASIA').AsString;
Self.TipoDoc := dm.qryGetObject.FieldByName('DES_TIPO_DOC').AsString;
Self.Cnpj := dm.qryGetObject.FieldByName('NUM_CNPJ').AsString;
Self.IE := dm.qryGetObject.FieldByName('NUM_IE').AsString;
Self.IEST := dm.qryGetObject.FieldByName('NUM_IEST').AsString;
Self.IM := dm.qryGetObject.FieldByName('NUM_IM').AsString;
Self.Cnae := dm.qryGetObject.FieldByName('COD_CNAE').AsString;
Self.Crt := dm.qryGetObject.FieldByName('COD_CRT').AsInteger;
Self.Status := dm.qryGetObject.FieldByName('COD_STATUS').AsString;
Self.Obs := dm.qryGetObject.FieldByName('DES_OBSERVACAO').AsString;
Self.DataCadastro := dm.qryGetObject.FieldByName('DAT_CADASTRO').AsDateTime;
Self.Usuario := dm.qryGetObject.FieldByName('NOM_USUARIO').AsString;
Self.Manutencao := dm.qryGetObject.FieldByName('DAT_MANUTENCAO').AsDateTime;
Result := True;
end;
if (not Result) then begin
dm.qryGetObject.Close;
dm.qryGetObject.SQL.Clear;
end;
except on E: Exception do
ShowMessage('Classe: ' + E.ClassName + chr(13) + 'Mensagem: ' + E.Message);
end;
end;
function TEmpresas.getObjects: Boolean;
begin
try
Result := False;
if (not conexao.VerifyConnZEOS(0)) then begin
MessageDlg('Erro ao estabelecer conexão ao banco de dados!', mtError, [mbCancel], 0);
Exit;
end;
if dm.qryGetObject.Active then begin
dm.qryGetObject.Close;
end;
dm.qryGetObject.SQL.Clear;
dm.qryGetObject.SQL.Add('SELECT * FROM ' + TABLENAME);
dm.ZConn.PingServer;
dm.qryGetObject.Open;
if (not dm.qryGetObject.IsEmpty) then begin
Result := True;
Exit;
end;
dm.qryGetObject.Close;
dm.qryGetObject.SQL.Clear;
except on E: Exception do
ShowMessage('Classe: ' + E.ClassName + chr(13) + 'Mensagem: ' + E.Message);
end;
end;
function TEmpresas.getField(sCampo: String; sColuna: String): String;
begin
try
Result := '';
if sCampo.IsEmpty then begin
Exit;
end;
if sColuna.IsEmpty then begin
Exit;
end;
if (not conexao.VerifyConnZEOS(0)) then begin
MessageDlg('Erro ao estabelecer conexão ao banco de dados!', mtError, [mbCancel], 0);
Exit;
end;
if dm.qryFields.Active then begin
dm.qryFields.Close;
end;
dm.qryFields.SQL.Clear;
dm.qryFields.SQL.Add('SELECT ' + sCampo + ' FROM ' + TABLENAME);
if sColuna = 'CODIGO' then begin
dm.qryFields.SQL.Add(' WHERE COD_EMPRESA = :CODIGO');
dm.qryFields.ParamByName('CODIGO').AsInteger := Self.Codigo;
end
else if sColuna = 'CNPJ' then begin
dm.qryFields.SQL.Add(' WHERE NUM_CNPJ = :CNPJ');
dm.qryFields.ParamByName('CNPJ').AsString := Self.Cnpj;
end
else if sColuna = 'RAZAO' then begin
dm.qryFields.SQL.Add(' WHERE DES_RAZAO_SOCIAL = :RAZAO');
dm.qryFields.ParamByName('RAZAO').AsString := Self.Razao;
end
else if sColuna = 'FANTASIA' then begin
dm.qryFields.SQL.Add(' WHERE NOM_FANTASIA = :FANTASIA');
dm.qryFields.ParamByName('FANTASIA').AsString := Self.Fantasia;
end
else if sColuna = 'IE' then begin
dm.qryFields.SQL.Add(' WHERE NUM_IE = :IE');
dm.qryFields.ParamByName('IE').AsString := Self.IE;
end
else if sColuna = 'IEST' then begin
dm.qryFields.SQL.Add(' WHERE NUM_IEST = :IEST');
dm.qryFields.ParamByName('IEST').AsString := Self.IEST;
end
else if sColuna = 'IM' then begin
dm.qryFields.SQL.Add(' WHERE NUM_IM = :IM');
dm.qryFields.ParamByName('IM').AsString := Self.IM;
end;
dm.ZConn.PingServer;
dm.qryFields.Open;
if (not dm.qryFields.IsEmpty) then begin
dm.qryFields.First;
Result := dm.qryFields.FieldByName(sCampo).AsString;
end;
dm.qryFields.Close;
dm.qryFields.SQL.Clear;
except on E: Exception do
ShowMessage('Classe: ' + E.ClassName + chr(13) + 'Mensagem: ' + E.Message);
end;
end;
procedure TEmpresas.SetTipoDoc(val: String);
begin
FTIpoDoc := val;
end;
end.
|
{$REGION 'Copyright (C) CMC Development Team'}
{ **************************************************************************
Copyright (C) 2015 CMC Development Team
CMC 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.
CMC 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 CMC. If not, see <http://www.gnu.org/licenses/>.
************************************************************************** }
{ **************************************************************************
Additional Copyright (C) for this modul:
Chromaprint: Audio fingerprinting toolkit
Copyright (C) 2010-2012 Lukas Lalinsky <lalinsky@gmail.com>
Lomont FFT: Fast Fourier Transformation
Original code by Chris Lomont, 2010-2012, http://www.lomont.org/Software/
************************************************************************** }
{$ENDREGION}
{$REGION 'Notes'}
{ **************************************************************************
See CP.Chromaprint.pas for more information
************************************************************************** }
{$ENDREGION}
unit CP.AudioBuffer;
interface
uses
Classes,
CP.Def, CP.AudioConsumer;
type
TAudioBuffer = class(TAudioConsumer)
private
FData: TSmallintArray;
public
constructor Create;
destructor Destroy; override;
procedure Consume(Input: TSmallintArray; AOffset: integer; ALength: integer); override; // eigentlich abstract
function Data: TSmallintArray;
procedure Reset;
end;
implementation
{ TAudioBuffer }
procedure TAudioBuffer.Consume(Input: TSmallintArray; AOffset: integer; ALength: integer);
var
i, n: integer;
begin
n := Length(FData);
SetLength(FData, n + ALength - AOffset);
for i := AOffset to ALength - 1 do
begin
FData[n + i - AOffset] := Input[i];
end;
end;
constructor TAudioBuffer.Create;
begin
SetLength(FData, 0);
end;
function TAudioBuffer.Data: TSmallintArray;
begin
Result := FData;
end;
destructor TAudioBuffer.Destroy;
begin
SetLength(FData, 0);
inherited;
end;
procedure TAudioBuffer.Reset;
begin
SetLength(FData, 0);
end;
end.
|
unit tswitchbutton;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, ExtCtrls, Graphics, Controls,gtk;
type
{ TTSwitchButton }
TTSwitchButton = class(TImage)
private
{ Private declarations }
DBDownPict: TPicture;
DBUpPict: TPicture;
DBDisPict: TPicture;
DBEnabled: Boolean;
FUp: Boolean;
procedure SetDownPict(Value: TPicture);
procedure SetUpPict(Value: TPicture);
procedure SetDisPict(Value: TPicture);
public
{ Public declarations }
procedure SetEnabled(Value: Boolean); override;
Procedure SetOnOff(value:boolean);
Function ReadOnOff:boolean;
constructor Create(AOwner: TComponent); override;
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
Procedure Click; override;
destructor Destroy; override;
published
{ Published declarations }
property OnPict: TPicture read DBUpPict write SetUpPict;
property DownPict: TPicture read DBDownPict write SetDownPict;
property DisabledPict: TPicture read DBDisPict write SetDisPict;
property Enabled: Boolean read DBEnabled write SetEnabled;
Property Up:boolean read readonoff write setonoff;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Touch', [TTSwitchButton]);
end;
procedure TTSwitchButton.SetEnabled(Value: Boolean);
begin
if Value = True then
Picture:=DBUpPict
else Picture:=DBDisPict;
DBEnabled:=Value;
fup:=value;
end;
procedure TTSwitchButton.SetOnOff(value: boolean);
begin
fup:=value;
end;
function TTSwitchButton.ReadOnOff: boolean;
begin
result:=fup;
end;
constructor TTSwitchButton.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
DBDownPict:= TPicture.Create;
DBUpPict := TPicture.Create;
DBDisPict := TPicture.Create;
Picture:= DBUpPict;
fup:=true;
SetEnabled(true);
end;
procedure TTSwitchButton.SetUpPict(Value: TPicture);
begin
DBUpPict.Assign(Value);
end;
procedure TTSwitchButton.SetDownPict(Value: TPicture);
begin
DBDownPict.Assign(Value);
end;
procedure TTSwitchButton.SetDisPict(Value: TPicture);
begin
DBDisPict.Assign(Value);
end;
procedure TTSwitchButton.MouseMove(Shift: TShiftState; X, Y: Integer);
begin
inherited;
if DBEnabled=True then
if fUp then
if (X<0)or(X>Width)or(Y<0)or(Y>Height) then
begin
SetCaptureControl(Self);
if fup then Picture:=DBUpPict else picture:=dbdownpict;
end;
end;
procedure TTSwitchButton.Click;
begin
if Enabled=True then
begin
fup:=not fup;
if fup then picture:=dbuppict else picture:=dbdownpict;
end;
inherited Click;
end;
destructor TTSwitchButton.Destroy;
begin
DBDownPict.Free;
DBUpPict.Free;
DBDisPict.Free;
inherited Destroy;
end;
end.
|
{*********************************************************}
{* VPWAVDLG.PAS 1.03 *}
{*********************************************************}
{* ***** 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 Visual PlanIt *}
{* *}
{* The Initial Developer of the Original Code is TurboPower Software *}
{* *}
{* Portions created by TurboPower Software Inc. are Copyright (C) 2002 *}
{* TurboPower Software Inc. All Rights Reserved. *}
{* *}
{* Contributor(s): *}
{* *}
{* ***** END LICENSE BLOCK ***** *}
unit VpWavDlg;
{$I vp.inc}
interface
{$WARNINGS OFF} {Some of this stuff in here isn't platform friendly}
uses
{$IFDEF LCL}
LMessages,LCLProc,LCLType,LCLIntf,LResources,
{$ELSE}
Windows,
{$ENDIF}
Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
FileCtrl, StdCtrls, ExtCtrls, Buttons, VpBase, ComCtrls;
type
TFrmSoundDialog = class(TForm)
PageControl1: TPageControl;
TabSheet1: TTabSheet;
PlayButton: TSpeedButton;
// DriveComboBox1: TDriveComboBox;
// DirectoryListBox1: TDirectoryListBox;
FileListBox1: TFileListBox;
CBDefault: TCheckBox;
OkBtn: TButton;
CancelBtn: TButton;
procedure FileListBox1Change(Sender: TObject);
procedure PlayButtonClick(Sender: TObject);
procedure CBDefaultClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure OkBtnClick(Sender: TObject);
procedure CancelBtnClick(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
public
DingPath: string;
ReturnCode : TVpEditorReturnCode;
procedure Populate;
end;
function ExecuteSoundFinder(var DingPath: string): Boolean;
implementation
uses
{$IFNDEF LCL}
mmSystem,
{$ENDIF}
VpSR;
{$IFNDEF LCL}
{$R *.DFM}
{$ENDIF}
function ExecuteSoundFinder(var DingPath: string): Boolean;
var
SoundFinder: TfrmSoundDialog;
begin
Result := false;
Application.CreateForm(TfrmSoundDialog, SoundFinder);
try
SoundFinder.DingPath := DingPath;
SoundFinder.Populate;
SoundFinder.ShowModal;
if SoundFinder.ReturnCode = rtCommit then begin
if SoundFinder.CBDefault.Checked then
DingPath := ''
else
DingPath := SoundFinder.FileListBox1.FileName;
Result := true;
end;
finally
SoundFinder.Release;
end;
end;
{=====}
procedure TFrmSoundDialog.FileListBox1Change(Sender: TObject);
begin
if FileListBox1.Items.Count > 0 then begin
PlayButton.Enabled := true;
DingPath := FileListBox1.FileName;
end else begin
PlayButton.Enabled := false;
DingPath := '';
end;
end;
{=====}
procedure TFrmSoundDialog.PlayButtonClick(Sender: TObject);
begin
PlayButton.Enabled := false;
{$IFNDEF LCL}
SndPlaySound(PChar(FileListBox1.FileName), snd_Sync);
{$ENDIF}
PlayButton.Enabled := true;
end;
{=====}
procedure TFrmSoundDialog.Populate;
var
Drive: char;
begin
TabSheet1.Caption := RSSelectASound;
Self.Caption := RSSoundFinder;
CBDefault.Caption := RSDefaultSound;
OkBtn.Caption := RSOkBtn;
CancelBtn.Caption := RSCancelBtn;
if DingPath = '' then begin
CBDefault.Checked := true;
// DirectoryListBox1.Directory := ExtractFileDir(ParamStr(0));
end else begin
Drive := UpCase(ExtractFileDrive(DingPath)[1]);
if FileExists(DingPath) and (Drive in ['A'..'Z']) then begin
// DriveComboBox1.Drive := Drive;
// DirectoryListBox1.Directory := ExtractFileDir(DingPath);
FileListBox1.FileName := DingPath;
end else begin
// DirectoryListBox1.Directory := ExtractFileDir(ParamStr(0));
end;
end;
end;
{=====}
procedure TFrmSoundDialog.CBDefaultClick(Sender: TObject);
begin
// DriveComboBox1.Enabled := not CBDefault.Checked;
// DirectoryListBox1.Enabled := not CBDefault.Checked;
FileListBox1.Enabled := not CBDefault.Checked;
PlayButton.Enabled := not CBDefault.Checked;
end;
{=====}
procedure TFrmSoundDialog.FormCreate(Sender: TObject);
begin
ReturnCode := rtAbandon;
end;
{=====}
procedure TFrmSoundDialog.OkBtnClick(Sender: TObject);
begin
ReturnCode := rtCommit;
Close;
end;
{=====}
procedure TFrmSoundDialog.CancelBtnClick(Sender: TObject);
begin
Close;
end;
{=====}
procedure TFrmSoundDialog.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = VK_ESCAPE then
Close;
end;
initialization
{$IFDEF LCL}
{$I vpwavdlg.lrs}
{$ENDIF}
end.
|
unit FileOperations;
interface
uses
Windows, ShellApi, SysUtils;
const
// IProgressDialog
CLSID_ProgressDialog: TGUID = '{F8383852-FCD3-11D1-A6B9-006097DF5BD4}';
{$EXTERNALSYM CLSID_ProgressDialog}
// Progress objects exposed via QueryService
SID_SProgressUI: TGUID = '{F8383852-FCD3-11D1-A6B9-006097DF5BD4}'; //CLSID_ProgressDialog;
{$EXTERNALSYM SID_SProgressUI}
SID_IProgressDialog = '{EBBC7C04-315E-11D2-B62F-006097DF5BD4}';
IID_IProgressDialog: TGUID = SID_IProgressDialog;
// Flags for IProgressDialog::StartProgressDialog() (dwFlags)
// The flag space includes OPPROGDLG_ and PROGDLG_ values, please guarantee they don't conflict. See shobjidl.idl for OPPROGDLG_*
PROGDLG_NORMAL = $00000000; // default normal progress dlg behavior
{$EXTERNALSYM PROGDLG_NORMAL}
PROGDLG_MODAL = $00000001; // the dialog is modal to its hwndParent (default is modeless)
{$EXTERNALSYM PROGDLG_MODAL}
PROGDLG_AUTOTIME = $00000002; // automatically updates the "Line3" text with the "time remaining" (you cant call SetLine3 if you passs this!)
{$EXTERNALSYM PROGDLG_AUTOTIME}
PROGDLG_NOTIME = $00000004; // we dont show the "time remaining" if this is set. We need this if dwTotal < dwCompleted for sparse files
{$EXTERNALSYM PROGDLG_NOTIME}
PROGDLG_NOMINIMIZE = $00000008; // Do not have a minimize button in the caption bar.
{$EXTERNALSYM PROGDLG_NOMINIMIZE}
PROGDLG_NOPROGRESSBAR = $00000010; // Don't display the progress bar
{$EXTERNALSYM PROGDLG_NOPROGRESSBAR}
PROGDLG_MARQUEEPROGRESS = $00000020; // Use marquee progress (comctl32 v6 required)
{$EXTERNALSYM PROGDLG_MARQUEEPROGRESS}
PROGDLG_NOCANCEL = $00000040; // No cancel button (operation cannot be canceled) (use sparingly)
{$EXTERNALSYM PROGDLG_NOCANCEL}
// Time Actions (dwTimerAction)
PDTIMER_RESET = $00000001; // Reset the timer so the progress will be calculated from now until the first ::SetProgress() is called so
{$EXTERNALSYM PDTIMER_RESET}
// those this time will correspond to the values passed to ::SetProgress(). Only do this before ::SetProgress() is called.
PDTIMER_PAUSE = $00000002; // Progress has been suspended
{$EXTERNALSYM PDTIMER_PAUSE}
PDTIMER_RESUME = $00000003; // Progress has resumed
{$EXTERNALSYM PDTIMER_RESUME}
type
IProgressDialog = interface(IUnknown)
[SID_IProgressDialog]
function StartProgressDialog(hwndParent: HWND; const punkEnableModless: IUnknown;
dwFlags: DWORD; var pvResevered: Pointer): HRESULT; stdcall;
function StopProgressDialog: HRESULT; stdcall;
function SetTitle(pwzTitle:LPCWSTR): HRESULT; stdcall;
function SetAnimation(hInstAnimation: HINST; idAnimation: UINT): HRESULT; stdcall;
function HasUserCancelled: BOOL; stdcall;
function SetProgress(dwCompleted, dwTotal: DWORD): HRESULT; stdcall;
function SetProgress64(ullCompleted, ullTotal: UINT64): HRESULT; stdcall;
function SetLine(dwLineNum: DWORD; pwzString: LPCWSTR; fCompactPath: BOOL;
var pvResevered: Pointer): HRESULT; stdcall;
function SetCancelMsg(pwzCancelMsg: LPCWSTR; var pvResevered: Pointer): HRESULT; stdcall;
function Timer(dwTimerAction: DWORD; var pvResevered: Pointer): HRESULT; stdcall;
end;
PProgressInfoStruct = ^TProgressInfoStruct;
TProgressInfoStruct = record
ProgressDialog: IProgressDialog;
TotalSize: UINT64;
DoneSize: UINT64;
ShowFileNames: boolean;
SourceFileName: string;
DestFileName: string;
end;
EFileOperationUserAbort = class(Exception);
function FileOperation(var aFileOp: TSHFileOpStruct): Integer;
function CopyProgressRoutine(aTotalFileSize: TLargeInteger;
aTotalBytesTransferred: TLargeInteger; aStreamSize: TLargeInteger;
aStreamBytesTransferred: TLargeInteger; aStreamNumber: DWORD;
aCallbackReason: DWORD; aSourceFile: THandle; aDestinationFile: THandle;
aData: pointer): DWORD; stdcall;
const
FOF_NOCANCEL = $0800; // disabled cancel button
SHGFP_TYPE_CURRENT = 0; { current value for user, verify it exists }
SHGFP_TYPE_DEFAULT = 1; { default value, may not exist }
implementation
uses
ActiveX, ShlObj, Classes;
const
c_AllFilesMask = '*.*';
function AnsiToWide(aText: AnsiString): WideString;
var
l_wText: PWideChar;
l_ansiSize: integer;
l_wideSize: integer;
begin
l_wText := nil;
Result := '';
if (aText = '') then
Exit;
try
l_ansiSize := Length(aText) + 1;
l_wideSize := l_ansiSize * SizeOf(WideChar);
l_wText := AllocMem(l_wideSize);
try
MultiByteToWideChar(CP_ACP, 0, PChar(aText), l_ansiSize, l_wText, l_wideSize);
Result := l_wText;
finally
FreeMem(l_wText);
end;
except
end;
end;
function GetProgressDialog: IProgressDialog;
var
l_progressDialog: IProgressDialog;
begin
Result := nil;
if (LOBYTE(LOWORD(GetVersion)) < 5) then // under Windows 2000
Exit;
try
if (CoCreateInstance(CLSID_ProgressDialog, nil, CLSCTX_INPROC_SERVER, IID_IProgressDialog,
l_progressDialog) = S_OK) then
Result := l_progressDialog;
except
end;
end;
{$R-}
procedure GetFilesSize(const aPath: PChar; out aSize: UINT64);
var
l_SearchRec: TSearchRec;
l_SearchResult: Integer;
l_fileSize: integer;
l_filePath: string;
l_sizeInDir: UINT64;
begin
l_sizeInDir := 0;
l_SearchResult := FindFirst(aPath, Integer(faAnyFile), l_SearchRec);
try
while (l_SearchResult = 0) do
begin
l_filePath := '';
if ((l_SearchRec.Name = '.') or (l_SearchRec.Name = '..')) then
begin
l_SearchResult := FindNext(l_SearchRec);
Continue;
end;
if ((l_SearchRec.Attr and Integer(faDirectory)) = 0) then
aSize := aSize + l_SearchRec.Size
else
begin
l_filePath := IncludeTrailingPathDelimiter(IncludeTrailingPathDelimiter(ExtractFilePath(aPath)) + l_SearchRec.Name) +
c_AllFilesMask;
GetFilesSize(PChar(l_filePath), l_sizeInDir);
aSize := aSize + l_sizeInDir;
end;
l_SearchResult := FindNext(l_SearchRec);
end;
finally
FindClose(l_SearchRec);
end;
end;
{$R+}
function FileOperationInternal(var aFileOp: TSHFileOpStruct;
aProgressInfoStruct: PProgressInfoStruct): Integer;
var
l_SearchRec: TSearchRec;
l_SearchResult: Integer;
l_fromFileName: string;
l_toFileName: string;
l_result: BOOL;
l_recFileOpStruct: TSHFileOpStruct;
l_isDirectory: boolean;
function IsAborted: boolean;
begin
Result := False;
if (aProgressInfoStruct <> nil) and (aProgressInfoStruct^.ProgressDialog <> nil) then
Result := aProgressInfoStruct^.ProgressDialog.HasUserCancelled;
end;
begin
Result := S_OK;
l_SearchResult := FindFirst(aFileOp.pFrom, Integer(faAnyFile), l_SearchRec);
try
while (l_SearchResult = 0) do
begin
l_result := True;
l_fromFileName := '';
l_toFileName := '';
if ((l_SearchRec.Name = '.') or (l_SearchRec.Name = '..')) then
begin
l_SearchResult := FindNext(l_SearchRec);
Continue;
end;
l_isDirectory := ((l_SearchRec.Attr and Integer(faDirectory)) <> 0);
if (aFileOp.wFunc <> FO_RENAME) then
l_toFileName := IncludeTrailingPathDelimiter(aFileOp.pTo) +
ExtractFileName(l_SearchRec.Name)
else
l_toFileName := aFileOp.pTo;
if (not l_isDirectory) then
l_fromFileName := IncludeTrailingPathDelimiter(ExtractFilePath(aFileOp.pFrom)) +
ExtractFileName(l_SearchRec.Name)
else
begin
l_fromFileName := IncludeTrailingPathDelimiter(ExtractFilePath(aFileOp.pFrom)) +
IncludeTrailingPathDelimiter(ExtractFileName(l_SearchRec.Name)) + c_AllFilesMask;
FillChar(l_recFileOpStruct, SizeOf(l_recFileOpStruct), 0);
l_recFileOpStruct.wFunc := aFileOp.wFunc;
l_recFileOpStruct.pFrom := PChar(l_fromFileName);
l_recFileOpStruct.pTo := PChar(l_toFileName);
l_recFileOpStruct.fFlags := aFileOp.fFlags;
end;
if (aProgressInfoStruct <> nil) then
begin
aProgressInfoStruct^.SourceFileName := l_fromFileName;
aProgressInfoStruct^.DestFileName := l_toFileName;
end;
case aFileOp.wFunc of
FO_COPY:
if (not l_isDirectory) then
l_result := CopyFileEx(PChar(l_fromFileName), PChar(l_toFileName),
@CopyProgressRoutine, aProgressInfoStruct, nil, 0)
else
if ForceDirectories(l_toFileName) then
l_result := (FileOperationInternal(l_recFileOpStruct, aProgressInfoStruct) = S_OK);
FO_MOVE, FO_RENAME:
if (not l_isDirectory) then
l_result := MoveFileWithProgress(PChar(l_fromFileName), PChar(l_toFileName),
@CopyProgressRoutine, aProgressInfoStruct, 0)
else
if (ForceDirectories(l_toFileName)) then
if (FileOperationInternal(l_recFileOpStruct, aProgressInfoStruct) = S_OK) then
l_result := RemoveDirectory(PChar(ExtractFilePath(l_fromFileName)));
FO_DELETE:
if not l_isDirectory then
l_result := DeleteFile(l_fromFileName)
else
if (FileOperationInternal(l_recFileOpStruct, aProgressInfoStruct) = S_OK) then
RemoveDirectory(PChar(ExtractFilePath(l_fromFileName)));
end;
if IsAborted then
Raise(EFileOperationUserAbort.Create(''));
l_SearchResult := FindNext(l_SearchRec);
end;
finally
SysUtils.FindClose(l_SearchRec);
if (not l_result) then
Result := S_FALSE;
end;
end;
function FileOperation(var aFileOp: TSHFileOpStruct): Integer;
var
l_progressDialog: IProgressDialog;
l_progressInfoStruct: PProgressInfoStruct;
l_progressDialogFlags: DWORD;
l_nilPointer: pointer;
l_showDialog: HRESULT;
l_progressTitleA: string;
l_progressTitleW: WideString;
begin
Result := S_FALSE;
aFileOp.fAnyOperationsAborted := False;
if (LOWORD(LOBYTE(LOWORD(GetVersion))) < 5) then
begin
Result := SHFileOperation(aFileOp);
Exit;
end;
l_progressInfoStruct := nil;
l_progressDialog := nil;
l_showDialog := S_FALSE;
if ((aFileOp.fFlags and FOF_SILENT) = 0) then
begin
l_progressDialog := GetProgressDialog;
if (l_progressDialog <> nil) then
begin
l_progressTitleA := aFileOp.lpszProgressTitle;
l_progressTitleW := AnsiToWide(l_progressTitleA);
l_progressDialog.SetTitle(PWideChar(l_progressTitleW));
end;
try
GetMem(l_progressInfoStruct, SizeOf(TProgressInfoStruct));
FillChar(l_progressInfoStruct^, SizeOf(TProgressInfoStruct), 0);
with l_progressInfoStruct^ do
begin
ProgressDialog := l_progressDialog;
{$R-}
GetFilesSize(aFileOp.pFrom, TotalSize);
DoneSize := 0;
{$R+}
ShowFileNames := ((aFileOp.fFlags and FOF_SIMPLEPROGRESS) <> 0);
end;
l_progressDialogFlags := PROGDLG_NORMAL;
if ((aFileOp.fFlags and FOF_NOCANCEL) <> 0) then
l_progressDialogFlags := l_progressDialogFlags or PROGDLG_NOCANCEL;
if (aFileOp.wFunc in [FO_DELETE, FO_MOVE]) then
begin
if (LOBYTE(LOWORD(GetVersion)) >= 6) then // Vista up
l_progressDialogFlags := l_progressDialogFlags or PROGDLG_MARQUEEPROGRESS
else
l_progressDialogFlags := l_progressDialogFlags or PROGDLG_NOPROGRESSBAR;
end;
l_nilPointer := nil;
l_showDialog := l_progressInfoStruct.ProgressDialog.StartProgressDialog(0, nil, l_progressDialogFlags or PROGDLG_MODAL, l_nilPointer);
except
end;
end;
try
try
Result := FileOperationInternal(aFileOp, l_progressInfoStruct);
except
on E: EFileOperationUserAbort do
begin
Result := S_FALSE;
Exit;
end;
end;
finally
if l_progressInfoStruct <> nil then
begin
try
if ((l_progressInfoStruct.ProgressDialog <> nil) and (l_showDialog = S_OK)) then
l_progressInfoStruct.ProgressDialog.StopProgressDialog;
finally
FreeMem(l_progressInfoStruct);
end;
end;
aFileOp.fAnyOperationsAborted := (Result <> S_OK);
end;
end;
function CopyProgressRoutine(aTotalFileSize: TLargeInteger;
aTotalBytesTransferred: TLargeInteger; aStreamSize: TLargeInteger;
aStreamBytesTransferred: TLargeInteger; aStreamNumber: DWORD;
aCallbackReason: DWORD; aSourceFile: THandle; aDestinationFile: THandle;
aData: pointer): DWORD; stdcall;
var
l_progressDialog: IProgressDialog;
l_doneSize: Int64;
l_totalSize: Int64;
l_nilPointer: pointer;
l_percentDone: Integer;
begin
Result := PROGRESS_QUIET;
if aData = nil then
Exit;
try
{$R-}
if supports(PProgressInfoStruct(adata)^.ProgressDialog, IID_IProgressDialog, l_progressDialog) then
begin
l_doneSize := PProgressInfoStruct(aData)^.DoneSize + aTotalBytesTransferred;
l_totalSize := PProgressInfoStruct(aData)^.TotalSize;
l_percentDone := l_doneSize div (l_totalSize div 100);
l_progressDialog.SetProgress64(l_doneSize, l_totalSize);
l_nilPointer := nil;
if PProgressInfoStruct(aData)^.ShowFileNames then
begin
l_ProgressDialog.SetLine(1, PWideChar(AnsiToWide(Format('%d%s', [l_percentDone, '%']))), True, l_nilPointer);
l_ProgressDialog.SetLine(2, PWideChar(AnsiToWide(PProgressInfoStruct(aData)^.SourceFileName)), True, l_nilPointer);
l_ProgressDialog.SetLine(3, PWideChar(AnsiToWide(PProgressInfoStruct(aData)^.DestFileName)), True, l_nilPointer);
end;
if l_ProgressDialog.HasUserCancelled then
Result := PROGRESS_CANCEL
else
Result := PROGRESS_CONTINUE;
if aTotalBytesTransferred = aTotalFileSize then
PProgressInfoStruct(aData)^.DoneSize := PProgressInfoStruct(aData)^.DoneSize + aTotalBytesTransferred;
{$R+}
end;
except
end;
end;
end.
|
const generatedArraySize = 100;
const minRandomNumber = -9;
const maxRandomNumber = 9;
type integerArray = array [1..generatedArraySize] of integer;
function enterArraySize(): integer;
begin
write('Enter please array size between 1 and 100: ');
readln(Result);
end;
var arraySize: integer;
function generateRandomArray(): integerArray;
begin
arraySize := enterArraySize();
var generatedArray: integerArray;
for var index := 1 to arraySize do
begin
generatedArray[index] := Random(minRandomNumber, maxRandomNumber);
end;
Result := generatedArray;
end;
function generateBasedOnUserPreferences(): integerArray;
begin
arraySize := enterArraySize();
var generatedArray: integerArray;
for var index := 1 to arraySize do
begin
var arrayValue: integer;
write('Enter please array value: ');
readln(arrayValue);
generatedArray[index] := arrayValue;
end;
Result := generatedArray;
end;
procedure viewGeneratedArray(generatedArray: integerArray);
begin
write('[');
for var index := 1 to arraySize - 1 do
begin
write(generatedArray[index] + ', ');
end;
writeln(generatedArray[arraySize] + ']');
end;
function calculateArraySum(generatedArray: integerArray): integer;
begin
var sum: integer := 0;
for var index := 1 to arraySize do
begin
sum := sum + generatedArray[index];
end;
Result := sum;
end;
function calculateAverage(value: integer; count: integer): real;
begin
Result := value / count;
end;
function multiplyPositiveArrayNumbers(generatedArray: integerArray): integer;
begin
var multipliedPositiveNumbersResult: integer := 1;
var arrayHasPositive: boolean := false;
for var index := 1 to arraySize do
begin
if generatedArray[index] > 0 then
begin
arrayHasPositive := true;
multipliedPositiveNumbersResult := multipliedPositiveNumbersResult * generatedArray[index];
end;
end;
if arrayHasPositive = false then
begin
multipliedPositiveNumbersResult := 0;
end;
Result := multipliedPositiveNumbersResult;
end;
var selectedOption: integer;
begin
writeln('1. Generate random array;');
writeln('2. Enter values by yourself.');
write('Select please value generation option: ');
readln(selectedOption);
writeln;
var generatedArray: integerArray;
case selectedOption of
1: generatedArray := generateRandomArray();
2: generatedArray := generateBasedOnUserPreferences();
end;
write('Generated array: ');
viewGeneratedArray(generatedArray);
write('Sum of the array elements: ');
var sum: integer := calculateArraySum(generatedArray);
writeln(sum);
write('Average of the array elements: ');
var average: real := calculateAverage(sum, arraySize);
writeln(average);
write('Multiplied positive numbers of the array result: ');
var multipliedPositiveNumbersResult: integer := multiplyPositiveArrayNumbers(generatedArray);
writeln(multipliedPositiveNumbersResult);
end.
|
unit f2Application;
interface
uses
d2dTypes,
d2dInterfaces,
d2dApplication,
d2dGUIButtons,
f2Skins,
f2SettingsStorage;
type
Tf2Application = class(Td2dApplication)
private
f_DebugMode: Boolean;
f_DefaultButtonView: Id2dFramedButtonView;
f_DefaultTextFont: Id2dFont;
f_DefaultMenuFont: Id2dFont;
f_DefaultTexture: Id2dTexture;
f_IsFromExe: Boolean;
f_IsFromPack: Boolean;
f_LogToFile: Boolean;
f_QuestFileName: string;
f_QuestToOpen: string;
f_SavePath: AnsiString;
f_SettingsStorage: Tf2SettingsStorage;
f_Skin: Tf2Skin;
function pm_GetDefaultButtonView: Id2dFramedButtonView;
function pm_GetDefaultTextFont: Id2dFont;
function pm_GetDefaultMenuFont: Id2dFont;
function pm_GetDefaultTexture: Id2dTexture;
function pm_GetSavePath: AnsiString;
function pm_GetSettingsStorage: Tf2SettingsStorage;
protected
function Init: Boolean; override;
procedure LoadGlobalResources; override;
procedure UnloadGlobalResources; override;
public
constructor Create(aQuest: string; aLogToFile, aDebugMode: Boolean);
property DebugMode: Boolean read f_DebugMode write f_DebugMode;
property DefaultButtonView: Id2dFramedButtonView read pm_GetDefaultButtonView;
property DefaultTextFont: Id2dFont read pm_GetDefaultTextFont;
property DefaultMenuFont: Id2dFont read pm_GetDefaultMenuFont;
property DefaultTexture: Id2dTexture read pm_GetDefaultTexture;
property IsFromExe: Boolean read f_IsFromExe write f_IsFromExe;
property IsFromPack: Boolean read f_IsFromPack write f_IsFromPack;
property LogToFile: Boolean read f_LogToFile write f_LogToFile;
property QuestFileName: string read f_QuestFileName;
property QuestToOpen: string read f_QuestToOpen;
property SavePath: AnsiString read pm_GetSavePath;
property SettingsStorage: Tf2SettingsStorage read pm_GetSettingsStorage;
property Skin: Tf2Skin read f_Skin write f_Skin;
end;
implementation
uses
Windows,
ShlObj,
Classes,
MD5,
d2dCore,
d2dGUITypes,
d2dUtils,
f2ScnSplash,
f2ScnMain,
f2Utils,
f2FontLoad,
SysUtils
;
const
c_sLogExt = '.log';
c_sFullscreen = 'fullscreen';
c_sSplash = 'splash';
c_sMain = 'main';
c_sGssExt = '.gss';
sFireURQError = 'FireURQ: ОШИБКА';
sSkinXml = 'skin.xml';
sSkinError = 'Ошибка: skin.xml пуст или испорчен.';
SFileMaskMain = 'main.qst;main.qs1;main.qs2';
SFileMaskGame = 'game.qst;game.qs1;game.qs2';
SFileMaskAny = '*.qst;*.qs1;*.qs2';
SErrQSZError = 'Ошибка формата QSZ';
SFurqTexturePng = 'furq_texture.png';
SDefaultTextFont = 'serif';
SDefaultMenuFont = 'sans[16,0.8,0.2]';
c_s_DefaultPackName = 'fireurq.pak';
c_s_DefaultSkinName = 'furq_default_skin.xml';
procedure OutError(const aMsg: string);
begin
gD2DE.System_Log(aMsg);
MessageBox(gD2DE.WHandle, PAnsiChar(aMsg), sFireURQError, MB_OK + MB_ICONERROR);
end;
constructor Tf2Application.Create(aQuest: string; aLogToFile, aDebugMode: Boolean);
var
l_Dir: string;
l_Path: array[0..MAX_PATH] of Char;
begin
inherited Create(800, 600, True, 'FireURQ'); // do not localize
gD2DE.FixedFPS := 120;
l_Dir := ExtractFilePath(ParamStr(0));
if not IsDirWritable(l_Dir) then
begin
if SHGetSpecialFolderPath(0, @l_Path, CSIDL_APPDATA, True) then
begin
l_Dir := IncludeTrailingPathDelimiter(l_Path) + 'FireURQ'; // do not localize
ForceDirectories(l_Dir);
end;
end;
gD2DE.LogFileName := IncludeTrailingPathDelimiter(l_Dir) + ChangeFileExt(ExtractFileName(ParamStr(0)), c_sLogExt);
f_QuestFileName := aQuest;
f_LogToFile := aLogToFile;
f_DebugMode := aDebugMode;
end;
function Tf2Application.Init: Boolean;
var
l_Ext: string;
//l_ZipOffset: Longint;
l_FS : TStream;
l_FullScreen: Boolean;
l_QName: string;
l_SPath: string;
begin
Result := False;
l_SPath := ExtractFilePath(ParamStr(0)) + c_s_DefaultPackName;
if not FileExists(l_SPath) then
begin
OutError(Format('Не найдены ресурсы (файл %s). Что-то явно не так.', [c_s_DefaultPackName]));
Exit;
end;
D2AttachZipPack(l_SPath);
if not FileExists(f_QuestFileName) then
begin
OutError(Format('Файл %s не найден.', [f_QuestFileName]));
Exit;
end;
l_Ext := AnsiLowerCase(ExtractFileExt(f_QuestFileName));
if (l_Ext = '.qsz') {or (l_Ext = '.exe')} then // do not localize
begin
//l_ZipOffset := 0;
{
if (l_Ext = '.exe') then // do not localize
begin
l_FS := TFileStream.Create(f_QuestFileName, fmOpenRead or fmShareDenyWrite);
try
l_FS.Seek(-4, soFromEnd);
l_FS.ReadBuffer(l_ZipOffset, 4);
f_IsFromExe := True;
finally
l_FS.Free;
end;
end;
}
if D2AttachZipPack(f_QuestFileName{, l_ZipOffset}) then
begin
l_QName := gD2DE.Resource_FindInPacks(SFileMaskMain);
if l_QName = '' then
begin
l_QName := gD2DE.Resource_FindInPacks(SFileMaskGame);
if l_QName = '' then
l_QName := gD2DE.Resource_FindInPacks(SFileMaskAny);
end;
if l_QName <> '' then
begin
f_QuestToOpen := l_QName;
f_IsFromPack := True;
end
else
begin
gD2DE.Resource_RemovePack(f_QuestFileName);
OutError(SErrQSZError);
Exit;
end;
end
else
begin
OutError('Файл '+f_QuestFileName+' испорчен');
Exit;
end;
end
else
f_QuestToOpen := QuestFileName;
SetCurrentDir(ExtractFilePath(QuestFileName));
f_Skin := nil;
if gD2DE.Resource_Exists(sSkinXml, IsFromPack) then
begin
f_Skin := Tf2Skin.Create(sSkinXml, IsFromPack);
if f_Skin = nil then
OutError(sSkinError);
end;
if Skin = nil then
begin
if not gD2DE.Resource_Exists(c_s_DefaultSkinName) then
begin
OutError('Скин по-умолчанию не найден. Как это могло произойти?');
Exit;
end;
f_Skin := Tf2Skin.Create(c_s_DefaultSkinName);
end;
if SettingsStorage.IsVarExists(c_sFullscreen) then
l_FullScreen := SettingsStorage[c_sFullscreen] <> 0
else
l_FullScreen := Skin.FullScreen;
gD2DE.ScreenWidth := Skin.ScreenWidth;
gD2DE.ScreenHeight := Skin.ScreenHeight;
gD2DE.Windowed := not l_FullScreen;
AddScene(c_sSplash, Tf2SplashScene.Create(Self));
AddScene(c_sMain, Tf2MainScene.Create(Self));
CurrentScene := c_sSplash;
//CurrentScene := c_sMain;
Result := True;
end;
procedure Tf2Application.LoadGlobalResources;
begin
Skin.LoadResources;
end;
function Tf2Application.pm_GetDefaultButtonView: Id2dFramedButtonView;
begin
if f_DefaultButtonView = nil then
begin
f_DefaultButtonView := Td2dFramedButtonView.Create(DefaultTexture, 567, 47, 44, 44, 20, 4, DefaultTextFont);
with f_DefaultButtonView do
begin
StateColor[bsNormal] := $FFA0A0A0;
StateColor[bsFocused] := $FFA0A0FF;
StateColor[bsDisabled] := $FF606060;
StateColor[bsPressed] := $FFFFFFFF;
end;
end;
Result := f_DefaultButtonView;
end;
function Tf2Application.pm_GetDefaultTextFont: Id2dFont;
begin
if f_DefaultTextFont = nil then
f_DefaultTextFont := f2LoadFont(SDefaultTextFont);
Result := f_DefaultTextFont;
end;
function Tf2Application.pm_GetDefaultMenuFont: Id2dFont;
begin
if f_DefaultMenuFont = nil then
f_DefaultMenuFont := f2LoadFont(SDefaultMenuFont);
Result := f_DefaultMenuFont;
end;
function Tf2Application.pm_GetDefaultTexture: Id2dTexture;
begin
if f_DefaultTexture = nil then
begin
f_DefaultTexture := gD2DE.Texture_Load(SFurqTexturePng);
end;
Result := f_DefaultTexture;
end;
function Tf2Application.pm_GetSavePath: AnsiString;
var
l_FileName: AnsiString;
l_Path: array[0..MAX_PATH] of Char;
begin
if f_SavePath = '' then
begin
f_SavePath := ExtractFilePath(QuestFileName);
if not IsDirWritable(f_SavePath) then
begin
if SHGetSpecialFolderPath(0, @l_Path, CSIDL_APPDATA, True) then
begin
l_FileName := ExtractFileName(QuestFileName);
f_SavePath := IncludeTrailingPathDelimiter(l_Path) + 'FireURQ\' + ChangeFileExt(l_Filename, '_') + // do not localize
MD5DigestToStr(MD5File(QuestFileName));
ForceDirectories(f_SavePath);
end;
end;
end;
Result := f_SavePath;
end;
function Tf2Application.pm_GetSettingsStorage: Tf2SettingsStorage;
var
l_FileName: AnsiString;
begin
if f_SettingsStorage = nil then
begin
l_FileName := ExtractFileName(QuestFileName);
f_SettingsStorage := Tf2SettingsStorage.Create(IncludeTrailingPathDelimiter(SavePath) + ChangeFileExt(l_Filename, c_sGssExt));
end;
Result := f_SettingsStorage;
end;
procedure Tf2Application.UnloadGlobalResources;
begin
f_DefaultButtonView := nil;
f_DefaultTextFont := nil;
f_DefaultMenuFont := nil;
FreeAndNil(f_Skin);
FreeAndNil(f_SettingsStorage);
end;
end.
|
unit UnitMain;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, StrUtils;
type
{ TForm1 }
TheMisSpelled = (TEH, ETH, EHT); { enumeration of 'the' miss-spellings }
TForm1 = class(TForm)
LoadButton: TButton;
SaveButton: TButton;
CorrectButton: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
MemoBox: TMemo;
procedure CorrectButtonClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure LoadButtonClick(Sender: TObject);
procedure SaveButtonClick(Sender: TObject);
private
{ private declarations }
function ChangeText(var fText: String; theType: TheMisSpelled): Boolean;
public
{ public declarations }
end;
var
Form1: TForm1;
fileName: String;
fileData: TStringList;
openDialog: TOpenDialog;
implementation
{$R *.lfm}
{ TForm1 }
function TForm1.ChangeText(var fText: String; theType: TheMisSpelled): Boolean;
var
tChanged: Boolean;
begin
{ indicate no changes yet }
tChanged := False;
{ first see if the string contains the desired string }
case theType of
TEH:
if AnsiContainsStr(fText, 'teh') or AnsiContainsStr(fText, 'Teh') then
begin
fText := AnsiReplaceStr(fText, 'teh', 'the');
fText := AnsiReplaceStr(fText, 'Teh', 'The');
tChanged := True;
end;
ETH:
if AnsiContainsStr(fText, 'eth') then
begin
fText := AnsiReplaceStr(fText, 'eth', 'the');
tChanged := True;
end;
EHT:
if AnsiContainsStr(fText, 'eht') then
begin
fText := AnsiReplaceStr(fText, 'eht', 'the');
tChanged := True;
end;
end;
{ returns the changed status }
Result := tChanged;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
{ set the title of the form - our application title }
Form1.Caption := 'Very Simple Spelling Corrector';
{ disable all except the load file button }
SaveButton.Enabled := False;
CorrectButton.Enabled := False;
{ clear the file display box }
MemoBox.Clear;
{ Enable scroll bars for this memo box }
MemoBox.ScrollBars := ssBoth;
{ do not allow the user to directly type into the displayed file text }
MemoBox.ReadOnly := True;
{ set the font of the memo box to a mono-spaced one to ease reading }
MemoBox.Font.Name := 'Courier New';
{ set all of the labels to blank }
Label1.Caption := '';
Label2.Caption := '';
Label3.Caption := '';
Label4.Caption := '';
{ create the open dialog object - used by the GetTextFile routine }
openDialog := TOpenDialog.Create(self);
{ ask for only files that exist }
openDialog.Options := [ofFileMustExist];
{ ask for only text files }
openDialog.Filter := 'Text Files|*.txt';
{ create the string object that holds the file contents }
fileData := TStringList.Create;
end;
procedure TForm1.CorrectButtonClick(Sender: TObject);
var
fText: String;
line: Integer;
changeCounts: array[TEH..EHT] of Integer;
begin
{ set the changed line counts }
changeCounts[TEH] := 0;
changeCounts[ETH] := 0;
changeCounts[EHT] := 0;
{ process each line of the file one at a time }
for line := 0 to fileData.Count - 1 do
begin
{ store the current line in a single variable }
fText := fileData[line];
{ change the 3 chosen basic ways of misspelling 'the' }
if ChangeText(fText, TEH) then Inc(changeCounts[TEH]);
if ChangeText(fText, ETH) then Inc(changeCounts[ETH]);
if ChangeText(fText, EHT) then Inc(changeCounts[EHT]);
{ and store this padded string back into the string list }
fileData[line] := fText;
end;
{ redisplay the file }
MemoBox.Text := fileData.Text;
{ Display the changed line totals }
if changeCounts[TEH] = 1
then Label1.Caption := 'Teh/teh changed on 1 line'
else Label1.Caption := 'Teh/teh changed on ' + IntToStr(changeCounts[TEH]) + ' lines';
if changeCounts[ETH] = 1
then Label2.Caption := 'eth changed on 1 line'
else Label2.Caption := 'eth changed on ' + IntToStr(changeCounts[ETH]) + ' lines';
if changeCounts[EHT] = 1
then Label3.Caption := 'eht changed on 1 line'
else Label3.Caption := 'eht changed on ' + IntToStr(changeCounts[EHT]) + ' lines';
{ finally, indicate that the file is now eligible for saving }
SaveButton.Enabled := True;
{ and that no more corrections are necessary }
CorrectButton.Enabled := False;
end;
procedure TForm1.LoadButtonClick(Sender: TObject);
begin
{ display the file selection dialog }
if openDialog.Execute then
begin
{ save the file name }
fileName := openDialog.FileName;
{ now that we have the file loaded, enable the text correction button }
CorrectButton.Enabled := True;
{ load the file into our stringlist }
fileData.LoadFromFile(fileName);
end;
{ display the file in the file display box }
MemoBox.Text := fileData.Text;
{ clear the changed lines information }
Label1.Caption := '';
Label2.Caption := '';
Label3.Caption := '';
{ display the number of lines in the file }
Label4.Caption := fileName + ' has ' + IntToStr(fileData.Count) + ' lines of text';
end;
procedure TForm1.SaveButtonClick(Sender: TObject);
begin
{ simply save the contents of the file string list }
if fileName <> '' then
fileData.SaveToFile(fileName);
{ and disable the file save button }
SaveButton.Enabled := False;
end;
end.
|
unit gradtabstyle;
{$mode objfpc}{$H+}
{.$DEFINE DEBUGTAB}
{-------------------------------------
Style-Class for TGradTabControl
--------------------------------------}
interface
uses
Classes, SysUtils, Controls, Graphics, Buttons, ComCtrls, ExtCtrls, ugradbtn
{$IFDEF DEBUGTAB}
, sharedloggerlcl
{$ELSE}
, DummyLogger
{$ENDIF};
type
TStylePaintEvent = procedure(Sender: TCustomControl; AIndex: Integer;
Button: TGradButton; TargetCanvas: TCanvas; R: TRect;
BState : TButtonState) of object;
{ TGradTabStyleBase }
TStyleBaseOptions = set of (sbTabButton, sbLeftRightButton, sbBorderButton, sbCloseButton);
TGradTabStyleBase = class
private
FRoundedCorners: Boolean;
function GetHasCloseButtonPaint: Boolean;
function GetHasTabButtonPaint: Boolean;
function GetHasLeftRightButtonPaint: Boolean;
function GetHasBorderButtonPaint: Boolean;
protected
FTheTabControl: TCustomControl;
FOptions : TStyleBaseOptions;
public
constructor Create; virtual;
procedure TabControl(Sender: TCustomControl;
TargetCanvas: TCanvas); virtual; abstract;
procedure TabButton(Sender: TCustomControl; AIndex: Integer;
Button: TGradButton; TargetCanvas: TCanvas; R: TRect; BState : TButtonState); virtual; abstract;
procedure TabCloseButton(Sender: TCustomControl; AIndex: Integer;
Button: TGradButton; TargetCanvas: TCanvas; R: TRect; BState : TButtonState); virtual; abstract;
procedure TabButtonBorder(Sender: TCustomControl; AIndex: Integer;
Button: TGradButton; TargetCanvas: TCanvas; R: TRect; BState : TButtonState); virtual; abstract;
procedure TabLeftRightButton(Sender: TGradButton; TargetCanvas: TCanvas; R: TRect; BState : TButtonState); virtual; abstract;
procedure TabLeftRightBorderButton(Sender: TGradButton; TargetCanvas: TCanvas; R: TRect; BState : TButtonState); virtual; abstract;
procedure PrepareButton(Button: TGradButton); virtual;
property TheTabControl : TCustomControl read FTheTabControl write FTheTabControl;
property HasTabButtonPaint : Boolean read GetHasTabButtonPaint;
property HasLeftRightButtonPaint : Boolean read GetHasLeftRightButtonPaint;
property HasBorderButtonPaint : Boolean read GetHasBorderButtonPaint;
property HasCloseButtonPaint : Boolean read GetHasCloseButtonPaint;
property RoundedCorners : Boolean read FRoundedCorners write FRoundedCorners;
end;
{ TGradTabStandardStyle }
TGradTabStandardStyle = class(TGradTabStyleBase)
public
procedure TabControl(Sender: TCustomControl; TargetCanvas: TCanvas);
override;
end;
{ TGradTabVistaStyle }
TButtonVistaStyle = record
BorderColor : TColor;
InnerBorderColor : TColor;
TopStartColor : TColor;
TopStopColor : TColor;
BottomStartColor : TColor;
BottomStopColor : TColor;
end;
TGradTabVistaStyle = class(TGradTabStyleBase)
protected
Normal : TButtonVistaStyle;
Hover : TButtonVistaStyle;
ActiveButton : TButtonVistaStyle;
public
constructor Create; override;
procedure TabControl(Sender: TCustomControl; TargetCanvas: TCanvas);
override;
procedure TabButton(Sender: TCustomControl; AIndex: Integer;
Button: TGradButton; TargetCanvas: TCanvas; R: TRect; BState : TButtonState); override;
procedure TabCloseButton(Sender: TCustomControl; AIndex: Integer;
Button: TGradButton; TargetCanvas: TCanvas; R: TRect; BState: TButtonState); override;
procedure TabButtonBorder(Sender: TCustomControl; AIndex: Integer;
Button: TGradButton; TargetCanvas: TCanvas; R: TRect; BState : TButtonState); override;
procedure TabLeftRightButton(Sender: TGradButton; TargetCanvas: TCanvas;
R: TRect; BState: TButtonState); override;
procedure TabLeftRightBorderButton(Sender: TGradButton; TargetCanvas: TCanvas;
R: TRect; BState: TButtonState); override;
procedure PrepareButton(Button: TGradButton); override;
end;
{ TGradTabVistaBlueStyle }
TGradTabVistaBlueStyle = class(TGradTabVistaStyle)
public
constructor Create; override;
end;
procedure LoggerButtonVistaStyle(Self: TButtonVistaStyle; Name: String);
implementation
uses
ugradtabcontrol, LCLProc;
procedure LoggerButtonVistaStyle(Self: TButtonVistaStyle; Name: String);
procedure C(aName: String; aColor: TColor);
begin
Logger.Send(aName, ColorToString(aColor));
end;
begin
Logger.EnterMethod('Style: '+ Name);
C('BorderColor', Self.BorderColor);
C('InnerBorderColor', Self.InnerBorderColor);
C('TopStartColor', Self.TopStartColor);
C('TopStopColor', Self.TopStopColor);
C('BottomStartColor', Self.BottomStartColor);
C('BottomStopColor', Self.BottomStopColor);
Logger.ExitMethod('Style');
end;
{ TGradTabStyleBase }
function TGradTabStyleBase.GetHasCloseButtonPaint: Boolean;
begin
Result := sbCloseButton in FOptions;
end;
function TGradTabStyleBase.GetHasTabButtonPaint: Boolean;
begin
Result := sbTabButton in FOptions;
end;
function TGradTabStyleBase.GetHasLeftRightButtonPaint: Boolean;
begin
Result := sbLeftRightButton in FOptions;
end;
function TGradTabStyleBase.GetHasBorderButtonPaint: Boolean;
begin
Result := sbBorderButton in FOptions;
end;
constructor TGradTabStyleBase.Create;
begin
FOptions:= [];
FRoundedCorners := true;
end;
procedure TGradTabStyleBase.PrepareButton(Button: TGradButton);
begin
// nothing
end;
{ TGradTabStandardStyle }
procedure TGradTabStandardStyle.TabControl(Sender: TCustomControl;
TargetCanvas: TCanvas);
var
AClientRect : TRect;
begin
TargetCanvas.Brush.Color:=Sender.Color;
TargetCanvas.FillRect(0,0,Sender.Width, Sender.Height);
TargetCanvas.Pen.Color:=clBlack;
AClientRect := (Sender as TGradTabControl).GetClientRect;
TargetCanvas.Rectangle(AClientRect.Left-2, AClientRect.Top-2,
AClientRect.Right+2, AClientRect.Bottom+2);
end;
{ TGradTabVistaStyle }
constructor TGradTabVistaStyle.Create;
begin
inherited Create;
FOptions:=[sbTabButton, sbBorderButton, sbCloseButton, sbLeftRightButton];
with Normal do
begin
BorderColor:=TColor($8b8c90);
InnerBorderColor:= TColor($fbfcff);
TopStartColor := TColor($f2f2f2);
TopStopColor := TColor($ebebeb);
BottomStartColor := TColor($dddddb);
BottomStopColor := TColor($cfcfcf);
end;
with Hover do
begin
BorderColor:=RGBToColor(85, 121, 145);
InnerBorderColor:= RGBToColor(224, 255, 255);
TopStartColor := RGBToColor(233, 246, 254);
TopStopColor := RGBToColor(219, 238, 252);
BottomStartColor := RGBToColor(190, 231, 253);
BottomStopColor := RGBToColor(167, 217, 244);
end;
with ActiveButton do
begin
BorderColor:=TColor($8b8c91);
InnerBorderColor:= TColor($FFFFFF);
TopStartColor := TColor($FFFFFF);
TopStopColor := TColor($FFFFFF);
BottomStartColor := TColor($FFFFFF);
BottomStopColor := TColor($FFFFFF);
end;
end;
procedure TGradTabVistaStyle.TabControl(Sender: TCustomControl;
TargetCanvas: TCanvas);
var
AClientRect : TRect;
begin
TargetCanvas.Brush.Color:=clWhite;
TargetCanvas.FillRect(0,0,Sender.Width, Sender.Height);
TargetCanvas.Pen.Color:=Normal.BorderColor;
AClientRect := (Sender as TGradTabControl).GetClientRect;
TargetCanvas.Rectangle(AClientRect.Left-2, AClientRect.Top-2,
AClientRect.Right+2, AClientRect.Bottom+2);
end;
procedure TGradTabVistaStyle.TabButton(Sender: TCustomControl; AIndex: Integer;
Button: TGradButton; TargetCanvas: TCanvas; R: TRect; BState : TButtonState);
var
ColorSet: TButtonVistaStyle;
UpperRect, LowerRect : TRect;
FGradTabControl : TGradTabControl;
FGradientDirection : TGradientDirection;
begin
FGradTabControl := nil;
if Sender <> nil then
FGradTabControl := Sender as TGradTabControl;
if (FGradTabControl <> nil)
and (AIndex = FGradTabControl.PageIndex) then
BState := bsDown;
case BState of
bsDown: ColorSet := ActiveButton;
bsHot: ColorSet := Hover;
else ColorSet := Normal;
end;
UpperRect := R;
UpperRect.Bottom:= UpperRect.Bottom div 2;
LowerRect := R;
LowerRect.Top := UpperRect.Bottom;
case FGradTabControl.TabPosition of
tpTop, tpBottom: FGradientDirection := gdVertical;
tpLeft, tpRight:
if FGradTabControl.LongTabs then
FGradientDirection := gdVertical
else
FGradientDirection := gdHorizontal;
end;
with TargetCanvas do
begin
GradientFill(UpperRect, ColorSet.TopStartColor,
ColorSet.TopStopColor, FGradientDirection);
GradientFill(LowerRect, ColorSet.BottomStartColor,
ColorSet.BottomStopColor, FGradientDirection);
end;
end;
procedure TGradTabVistaStyle.TabCloseButton(Sender: TCustomControl;
AIndex: Integer; Button: TGradButton; TargetCanvas: TCanvas; R: TRect;
BState: TButtonState);
var
FGradTabControl : TGradTabControl;
begin
FGradTabControl := nil;
if Sender <> nil then
FGradTabControl := Sender as TGradTabControl;
if (FGradTabControl <> nil)
and (AIndex <> FGradTabControl.PageIndex) then
BState := bsUp;
TabButton(Sender, AIndex, Button, TargetCanvas, R, BState);
end;
procedure TGradTabVistaStyle.TabButtonBorder(Sender: TCustomControl; AIndex: Integer;
Button: TGradButton; TargetCanvas: TCanvas; R: TRect; BState : TButtonState);
var
ColorSet: TButtonVistaStyle;
Temp : Integer;
begin
//DebugLn('Border R: ',DbgS(R));
case BState of
bsDown: ColorSet := ActiveButton;
bsHot: ColorSet := Hover;
else ColorSet := Normal;
end;
Temp := 0;
if not RoundedCorners then
begin
if R.Left > 0 then
R.Left := R.Left -1;
if R.Right < Button.Width then
R.Right := R.Right + 1;
if R.Top > 0 then
R.Top := R.Top - 1;
if R.Bottom < Button.Height then
R.Bottom := R.Bottom + 1;
Temp := 1;
end;
with Button do
begin
//Top
if (bsTopLine in BorderSides) then
begin
TargetCanvas.Pen.Color:=ColorSet.BorderColor;
TargetCanvas.Line(R.Left,0,R.Right,0);
TargetCanvas.Pen.Color:=ColorSet.InnerBorderColor;
TargetCanvas.Line(R.Left,1,R.Right,1);
end;
//Left
if (bsLeftLine in BorderSides) then
begin
TargetCanvas.Pen.Color:=ColorSet.BorderColor;
TargetCanvas.Line(0,R.Top,0,R.Bottom);
TargetCanvas.Pen.Color:=ColorSet.InnerBorderColor;
TargetCanvas.Line(1,R.Top,1,R.Bottom);
end;
//Right
if (bsRightLine in BorderSides) then
begin
TargetCanvas.Pen.Color:=ColorSet.BorderColor;
TargetCanvas.Line(Width-1,R.Top,Width-1,R.Bottom);
TargetCanvas.Pen.Color:=ColorSet.InnerBorderColor;
TargetCanvas.Line(Width-2,R.Top,Width-2,R.Bottom);
end;
//Bottom
if (bsBottomLine in BorderSides) then
begin
TargetCanvas.Pen.Color:=ColorSet.BorderColor;
TargetCanvas.Line(R.Left,Height-1,R.Right,Height-1);
TargetCanvas.Pen.Color:=ColorSet.InnerBorderColor;
TargetCanvas.Line(R.Left,Height-2,R.Right,Height-2);
end;
//TopLeft
if (bsTopLine in BorderSides) AND (bsLeftLine in BorderSides) then
TargetCanvas.Pixels[1-Temp,1-Temp]:=ColorSet.BorderColor;
//TopRight
if (bsTopLine in BorderSides) AND (bsRightLine in BorderSides) then
TargetCanvas.Pixels[Width-2+Temp,1-Temp] := ColorSet.BorderColor;
//BottomLeft
if (bsBottomLine in BorderSides) AND (bsLeftLine in BorderSides) then
TargetCanvas.Pixels[1-Temp, Height-2+Temp]:=ColorSet.BorderColor;
//BottomRight
if (bsBottomLine in BorderSides) AND (bsRightLine in BorderSides) then
TargetCanvas.Pixels[Width-2+Temp,Height-2+Temp]:=ColorSet.BorderColor;
end;
end;
procedure TGradTabVistaStyle.TabLeftRightButton(Sender: TGradButton;
TargetCanvas: TCanvas; R: TRect; BState: TButtonState);
begin
if BState = bsDown then
BState := bsHot;
if Sender.Font.Color = clWhite then
Sender.Font.Color := clBlack;
TabButton(Sender.Owner as TCustomControl, 0, Sender, TargetCanvas, R, BState);
end;
procedure TGradTabVistaStyle.TabLeftRightBorderButton(Sender: TGradButton;
TargetCanvas: TCanvas; R: TRect; BState: TButtonState);
begin
if BState = bsDown then
BState := bsHot;
TabButtonBorder(Sender.Owner as TCustomControl, 0, Sender, TargetCanvas, R, BState);
end;
procedure TGradTabVistaStyle.PrepareButton(Button: TGradButton);
begin
Button.Font.Color:=clBlack;
end;
{ TGradTabVistaBlueStyle }
constructor TGradTabVistaBlueStyle.Create;
begin
inherited Create;
with Normal do
begin
BorderColor:=RGBToColor(145, 150, 162); //#9196A2
InnerBorderColor:= RGBToColor(224, 255, 255);
TopStartColor := RGBToColor(252, 253, 254);
TopStopColor := RGBToColor(231, 235, 255);
BottomStartColor := RGBToColor(207, 215, 235);
BottomStopColor := RGBToColor(221, 227, 243);
end;
with Hover do
begin
BorderColor:=RGBToColor(145, 150, 162); //#9196A2
InnerBorderColor:= RGBToColor(224, 255, 255);
TopStartColor := RGBToColor(232, 240, 251);
TopStopColor := RGBToColor(184, 212, 244);
BottomStartColor := RGBToColor(115, 176, 232);
BottomStopColor := RGBToColor(173, 208, 241);
end;
with ActiveButton do
begin
BorderColor:=RGBToColor(145, 150, 162); //#9196A2
InnerBorderColor:= TColor($FFFFFF);
TopStartColor := RGBToColor(255, 245, 224); //#FFF5E0
TopStopColor := RGBToColor(255, 222, 147); //#FFDE93
BottomStartColor := RGBToColor(255, 184, 17); //#FFB811
BottomStopColor := RGBToColor(255, 213, 114);
end;
LoggerButtonVistaStyle(ActiveButton, 'ActiveButton');
end;
end.
|
unit RichPreview;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
WPRteDefs, WpCtrMemo, WPCtrRich, StdCtrls, Menus, Buttons, ExtCtrls, {WPPreVw,} WPRuler,
ActnList, {WPObj, WPPrint,} ComCtrls, DBISAMTb, DBISAMTableAU, TTSNOTICETAGTable,
TextSpooler, ReportSetupDialog, Db, Htmlview, AcePrev, FFSTypes, AceXport,
gtClasses3, gtCstDocEng, gtCstPlnEng, gtCstPDFEng, gtPDFEng, gtExPDFEng,
acProgressBar, sBitBtn,
sDialogs, sMemo, sPageControl, sButton, sSpeedButton, sLabel, sPanel, System.Actions, HTMLUn2;
type
TfrmRichPreview = class(TForm)
Panel1: TsPanel;
btnPrint: TsSpeedButton;
MainMenu1: TMainMenu;
File1: TMenuItem;
Exit1: TMenuItem;
Navigat1: TMenuItem;
First1: TMenuItem;
Prior1: TMenuItem;
Next1: TMenuItem;
Last1: TMenuItem;
firstpage: TsSpeedButton;
PreviousPage: TsSpeedButton;
lbl1: TsLabel;
NextPage: TsSpeedButton;
LastPage: TsSpeedButton;
ActionList1: TActionList;
actFirst: TAction;
actPrior: TAction;
actNext: TAction;
actLast: TAction;
actPrint: TAction;
PageControl1: TsPageControl;
tabNotices: TsTabSheet;
tabRecap: TsTabSheet;
rich1: TWPRichText;
Print1: TMenuItem;
tblNoticeTag: TTTSNOTICETAGTable;
PrintDialog1: TPrintDialog;
rptDlg: TReportSetupDialog;
StdNotes: TsTabSheet;
Std1: TsMemo;
tabNoNotices: TsTabSheet;
TextSpooler1: TTextSpooler;
PrintDialog2: TPrintDialog;
tabHtml: TsTabSheet;
AcePreview1: TAcePreview;
HTMLViewer1: THTMLViewer;
Button1: TsButton;
tblNoticeTag2: TTTSNOTICETAGTable;
Panel2: TsPanel;
AProgressBar: TsProgressBar;
AProgressLabel: TsLabel;
SaveDialog1: TsSaveDialog;
btnSavePDF: TsSpeedButton;
SavePDFFileDialog: TsSaveDialog;
gtPDFEngine1: TgtPDFEngine;
rich3: TWPRichText;
btnClose: TsBitBtn;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Exit1Click(Sender: TObject);
procedure actFirstExecute(Sender: TObject);
procedure actPriorExecute(Sender: TObject);
procedure actNextExecute(Sender: TObject);
procedure actLastExecute(Sender: TObject);
procedure AcePrintRange(rptFileName: string; pageFrom, pageTo: integer);
procedure actPrintExecute(Sender: TObject);
procedure PageControl1Change(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure btnSavePDFClick(Sender: TObject);
// procedure Button2Click(Sender: TObject);
// procedure RTF2PDF( RTFname, PDFname : string);
private
{ Private declarations }
ViewMode: integer;
memStr: Tmemorystream;
rcount: integer;
FStdNotices: boolean;
FRptID: integer;
procedure UpdatePage;
procedure SetStdNotices(const Value: boolean);
property StdNotices: boolean read FStdNotices write SetStdNotices;
procedure SetRptID(const Value: integer);
public
{ Public declarations }
property RptID: integer read FRptID write SetRptID;
procedure PrintNoticeTexts(ARptID: integer; FromPreview: boolean; pagefrom, pageto: integer; AProgressBar: TsProgressBar; AProgressLabel: TsLabel);
procedure PrintSummary;
end;
var
frmRichPreview: TfrmRichPreview;
implementation
uses AceFile, Ticklertypes, datamod, ProgramSettings, Printers;
{$R *.DFM}
procedure TfrmRichPreview.FormCreate(Sender: TObject);
begin
memStr := TMemoryStream.Create;
ViewMode := 1;
PageControl1.ActivePageIndex := 2;
end;
procedure TfrmRichPreview.FormDestroy(Sender: TObject);
begin
tblNoticeTag.Active := False;
memstr.free;
end;
procedure TfrmRichPreview.UpdatePage;
var rno: integer;
begin
case ViewMode of
0: begin
if tblNoticetag.RecNo > 0 then
case tblNoticeTag.PStdNotice of
true: begin
rich1.Clear;
// rich1.MemoryFormat := fmPlainText; //VG 230717: Prop removed after WPTools4. Check if there are issues during the QA
rich1.Text := tblNoticeTag.DFNoticeText.AsString;
rich1.CPPosition := 1;
end;
false: begin
rich1.clear;
// rich1.MemoryFormat := fmRichText;
memstr.Clear;
tblNoticeTag.DFNoticeText.SaveToStream(memstr);
memstr.Position := 0;
rich1.LoadFromStream(memstr);
rich1.CPPosition := 1;
end;
end;
if tblNoticeTag.RecordCount = 0 then rno := 0
else rno := tblNoticeTag.RecNo;
lbl1.Caption := Format('Notice %d/%d', [rno, rcount]);
end;
1: begin {recap report}
lbl1.Caption := Format('Page %d/%d', [acepreview1.Page, acepreview1.pagecount]);
end;
3: begin {cover page}
end;
end; {case}
end;
procedure TfrmRichPreview.Exit1Click(Sender: TObject);
begin
modalresult := mrCancel;
end;
procedure TfrmRichPreview.actFirstExecute(Sender: TObject);
begin
case ViewMode of
0: tblNoticetag.first;
1: AcePreview1.FirstPage;
end;
UpdatePage;
end;
procedure TfrmRichPreview.actPriorExecute(Sender: TObject);
begin
case ViewMode of
0: tblNoticeTag.Prior;
1: AcePreview1.PriorPage;
end;
UpdatePage;
end;
procedure TfrmRichPreview.actNextExecute(Sender: TObject);
begin
case ViewMode of
0: tblNoticeTag.Next;
1: AcePreview1.NextPage;
end;
UpdatePage;
end;
procedure TfrmRichPreview.actLastExecute(Sender: TObject);
begin
case ViewMode of
0: tblNoticeTag.Last;
1: AcePreview1.LastPage;
end;
UpdatePage;
end;
procedure TfrmRichPreview.PrintNoticeTexts(ARptID: integer; FromPreview: boolean; pagefrom, pageto: integer; AProgressBar: TsProgressBar; AProgressLabel: TsLabel);
var r1, r2: integer;
tcount: integer;
lcBefore, lcAfter: integer;
prp: TParProps;
pcount: integer;
TmpOrientation: TPrinterOrientation;
procedure UpdateProgress;
begin
if (Aprogressbar = nil) or (AProgresslabel = nil) then exit;
AProgressbar.Visible := true;
AProgressLabel.Visible := true;
inc(pcount);
if tcount > 0 then AProgressbar.Position := (100 * pcount) div tcount
else AProgressbar.Position := 100;
AProgresslabel.Caption := 'Printing ' + inttostr(pcount) + ' of ' + inttostr(tcount);
AProgresslabel.Update;
AProgressbar.Update;
end;
procedure PrintStdNotices;
var lcount: integer;
// for inserting addresses
s, t: string[255];
x, lastline: integer;
slist: TStringList;
tf: TextFile;
begin
// #Miller - Get the file to print
TmpOrientation := Printer.Orientation;
Printer.Orientation := poPortrait;
TextSpooler1.filename := Dir(drReports) + 'StdNote.rpt';
slist := TStringList.create;
assignfile(tf, textSpooler1.FileName);
rewrite(tf);
// first record
tblNoticeTag.First;
tblNoticeTag.MoveBy(r1 - 1);
while (not tblNoticeTag.eof) and (tblNoticeTag.RecNo <= r2) do
begin
UpdateProgress;
slist.clear;
slist.Text := tblNoticeTag.DFNoticeText.AsString;
for x := 1 to 33 do
begin
if slist.Count >= x then writeln(tf, slist[x - 1])
else writeln(tf);
end;
tblNoticeTag.next;
end;
closefile(tf);
TextSpooler1.SpoolFile;
Printer.Orientation := TmpOrientation;
end;
procedure PrintLetters;
var
TmpView: Integer;
begin
TmpView := ViewMode;
ViewMode := 0;
TmpOrientation := Printer.Orientation;
Printer.Orientation := poPortrait;
rich1.BeginPrint;
tblNoticeTag.First;
tblNoticeTag.MoveBy(r1 - 1);
while (not tblNoticeTag.eof) and (tblNoticeTag.RecNo <= r2) do
begin
UpdatePage;
UpdateProgress;
rich1.Print;
tblNoticeTag.next;
end;
rich1.EndPrint;
Printer.Orientation := TmpOrientation;
ViewMode := TmpView;
end;
begin
case fromPreview of
false: begin
r1 := 1;
r2 := tblNoticeTag.RecordCount;
end;
true: begin
if pagefrom = 0 then
begin
r1 := 1;
r2 := tblNoticetag.RecordCount;
end
else
begin
r1 := pagefrom;
r2 := pageto;
end;
end;
end;
tcount := r2 - r1 + 1;
pcount := 0;
try
if tblNoticeTag.DFStdNotice.Value then PrintStdNotices
else PrintLetters;
finally
if assigned(AProgressbar) then AProgressbar.Visible := false;
if assigned(AProgresslabel) then AProgresslabel.visible := false;
end;
end;
procedure TfrmRichPreview.AcePrintRange(rptFileName: string; pageFrom, pageTo: integer);
var
aaf: TAceAceFile;
ap: TAcePrinter;
begin
ap := TAcePrinter.Create;
aaf := TAceAceFile.Create;
aaf.loadfromfile(rptDlg.ReportFileName);
ap.LoadPages(aaf, pageFrom, pageTo);
ap.free;
aaf.free;
end;
procedure TfrmRichPreview.actPrintExecute(Sender: TObject);
begin
case ViewMode of
0: begin
PrintDialog1.MinPage := 1;
PrintDialog1.MaxPage := tblNoticeTag.RecordCount;
PrintDialog1.FromPage := tblNoticeTag.RecNo;
PrintDialog1.ToPage := tblNoticeTag.RecNo;
PrintDialog1.Options := [poPrintToFile, poPageNums, poSelection];
if PrintDialog1.Execute then
if PrintDialog1.PrintRange = prAllPages then PrintNoticeTexts(RptID, True, 0, 0, nil, nil)
else PrintNoticeTexts(RptID, True, PrintDialog1.FromPage, PrintDialog1.ToPage, nil, nil);
end;
1: begin
PrintDialog2.MinPage := 1;
PrintDialog2.MaxPage := acepreview1.pagecount;
PrintDialog2.FromPage := 1;
PrintDialog2.ToPage := acepreview1.pagecount;
PrintDialog2.Options := [poPrintToFile, poPageNums, poSelection];
if PrintDialog2.Execute then
if PrintDialog2.PrintRange = prAllPages then PrintSummary
else AcePrintRange(rptDlg.ReportFileName, PrintDialog2.FromPage, PrintDialog2.ToPage);
end;
end;
end;
procedure TfrmRichPreview.SetStdNotices(const Value: boolean);
begin
FStdNotices := Value;
StdNotes.TabVisible := StdNotices;
tabNotices.TabVisible := not StdNotices;
end;
procedure TfrmRichPreview.SetRptID(const Value: integer);
begin
FRptID := Value;
tblNoticeTag.Active := False;
tblNoticeTag.DatabaseName := Dir(drReports);
tblNoticeTag.TableName := ReportTableName(rtNoticeTag, FRptID);
tblNoticeTag.Active := True;
if not tblNoticeTag.eof then StdNotices := tblNoticeTag.DFStdNotice.Value
else StdNotices := false;
rcount := tblNoticeTag.RecordCount;
rich1.InsertPointAttr.Hidden := true;
rptDlg.ReportFileName := Dir(drReports) + RptFileName(tickNoticePrint, RptID);
AcePreview1.LoadFromFile(rptDlg.ReportFileName);
UpdatePage;
end;
procedure TfrmRichPreview.PrintSummary;
begin
rptDlg.Destination := rdPrinter;
rptDlg.ShowReport;
end;
procedure TfrmRichPreview.PageControl1Change(Sender: TObject);
begin
if PageControl1.ActivePageindex = 2 then ViewMode := 1
else ViewMode := 0;
UpdatePage;
end;
procedure TfrmRichPreview.Button1Click(Sender: TObject);
var
rich2: TWPRichText;
pcount, tcount: integer;
begin
//ExportAceFileToPDF(rptDlg.ReportFileName,copy(rptDlg.ReportFileName,1,length(rptDlg.ReportFileName)-4)+'.pdf',1,true,true);
tblNoticeTag2.Active := False;
tblNoticeTag2.DatabaseName := Dir(drReports);
tblNoticeTag2.TableName := ReportTableName(rtNoticeTag, FRptID);
tblNoticeTag2.Active := True;
tblNoticeTag2.First;
rich2 := TWPRichText.Create(self);
rich2.clear;
pcount := 0;
//if (Aprogressbar = nil) or (AProgresslabel = nil) then exit;
AProgressbar.Visible := true;
AProgressLabel.Visible := true;
Panel2.Visible := true;
tcount := tblNoticeTag2.RecordCount;
while (not tblNoticeTag2.eof) do
begin
if tblNoticetag2.RecNo > 0 then
begin
case tblNoticeTag2.PStdNotice of
true: begin
// rich2.MemoryFormat := fmPlainText;
rich2.Text := tblNoticeTag2.DFNoticeText.AsString;
end;
false: begin
// rich2.MemoryFormat := fmRichText;
memstr.Clear;
tblNoticeTag2.DFNoticeText.SaveToStream(memstr);
memstr.Position := 0;
rich2.LoadFromStream(memstr);
end;
end;
end;
rich2.InputString(#12); //Page Break
inc(pcount);
if tcount > 0 then AProgressbar.Position := (100 * pcount) div tcount
else AProgressbar.Position := 100;
AProgresslabel.Caption := 'Exporting ' + inttostr(pcount) + ' of ' + inttostr(tcount);
AProgresslabel.Update;
AProgressbar.Update;
tblNoticeTag2.Next;
end;
AProgresslabel.Caption := 'Finished...... Please Wait...';
AProgressbar.Visible := false;
AProgressLabel.Visible := false;
Panel2.Visible := false;
savedialog1.FileName := rptDlg.ReportFileName;
if savedialog1.Execute then
begin
rich2.SaveToFile(copy(savedialog1.FileName, 1, length(savedialog1.FileName) - 4) + '.rtf');
end;
end;
procedure TfrmRichPreview.btnSavePDFClick(Sender: TObject);
var
LMetaFile: TMetaFile;
LMetaFileCanvas: TMetaFileCanvas;
LPaperWidth: Double;
LPaperHeight: Double;
LHDC: HDC;
LRect,RR: TRect;
LI,I1: Integer;
tempMode, r1, r2: integer;
pcount, tcount: integer;
procedure updateRich3;
var rno: integer;
begin
if tblNoticetag.RecNo > 0 then
case tblNoticeTag.PStdNotice of
true: begin
rich3.Clear;
// rich3.MemoryFormat := fmPlainText;
rich3.Text := tblNoticeTag.DFNoticeText.AsString;
rich3.CPPosition := 1;
end;
false: begin
rich3.clear;
// rich3.MemoryFormat := fmRichText;
memstr.Clear;
tblNoticeTag.DFNoticeText.SaveToStream(memstr);
memstr.Position := 0;
rich3.LoadFromStream(memstr);
rich3.CPPosition := 1;
end;
end;
if tblNoticeTag.RecordCount = 0 then rno := 0
else rno := tblNoticeTag.RecNo;
lbl1.Caption := Format('Notice %d/%d', [rno, rcount]);
end;
begin
rich3.clear;
LPaperWidth := rich3.Header.PageWidth / 1440.0;
LPaperHeight := rich3.Header.PageHeight / 1440.0;
LMetaFile := TMetafile.Create;
LHDC := GetDC(0);
LMetaFile.Height := Trunc(LPaperHeight * GetDeviceCaps(LHDC, LOGPIXELSY));
LMetaFile.Width := Trunc(LPaperWidth * GetDeviceCaps(LHDC, LOGPIXELSX));
LRect.Top := 0;
LRect.Left := 0;
LRect.Right := LMetaFile.Width;
LRect.Bottom := LMetaFile.Height;
r1 := 1;
r2 := tblNoticetag.RecordCount;
//if (Aprogressbar = nil) or (AProgresslabel = nil) then exit;
AProgressbar.Visible := true;
AProgressLabel.Visible := true;
Panel2.Visible := true;
tcount := tblNoticeTag.RecordCount;
pcount := 0;
//gtPDFEngine1.FileName := Dir(drReports) + 'Notice'; //Commented May 31 2010
with gtPDFEngine1 do
begin
//BeginDoc; //Commented May 31 2010
tblNoticeTag.First;
tblNoticeTag.MoveBy(r1 - 1);
while (not tblNoticeTag.eof) and (tblNoticeTag.RecNo <= r2) do
begin
//addded counter to make download name unique.. Sirisha June 2014..
FileName := Dir(drReports) + inttostr(pcount + 1) + '_Notice for Loan ' + trim(tblNoticeTag.PLoanNum) + ' on Date ' + FormatDateTime('mm-dd-yyyy', date) ;
BeginDoc;
Updaterich3;
// ExportRichText(memStr,
For I1 := 0 to (rich3.CountPages - 1) do begin
LMetaFileCanvas := TMetafileCanvas.Create(LMetaFile, 0);
rich3.PrintPageOnCanvas(LMetaFileCanvas, LRect,I1, [ppmUseBorders, ppmUseEvents], 100);
LMetaFileCanvas.Free;
PlayMetafile(LMetaFile);
// NewPage;
If I1 < (rich3.CountPages - 1) then begin
NewPage;
end; { if }
inc(pcount);
if tcount > 0 then AProgressbar.Position := (100 * pcount) div tcount
else AProgressbar.Position := 100;
AProgresslabel.Caption := 'Exporting ' + inttostr(pcount) + ' of ' + inttostr(tcount);
AProgresslabel.Update;
AProgressbar.Update;
end; {for}
// NewPage; //Commented May 31 2010
tblNoticeTag.next;
EndDoc;
end;
AProgresslabel.Caption := 'Finished...... Please Wait...';
AProgressbar.Visible := false;
AProgressLabel.Visible := false;
Panel2.Visible := false;
// EndDoc; //Commented May 31 2010
end;
// ViewMode := tempMode;
end;
end.
|
unit WAV.Chat;
interface
uses
Spring.Collections,
FMX.Graphics;
type
TChatElement = class
private
FDate: string;
FTime: string;
FUser: string;
public
property User: string read FUser write FUser;
property Date: string read FDate write FDate;
property Time: string read FTime write FTime;
end;
TTextChatElement = class(TChatElement)
private
FText: string;
public
property Text: string read FText write FText;
end;
TImageChatElement = class(TChatElement)
private
FImage: TBitmap;
public
constructor Create;
destructor Destroy; override;
property Image: TBitmap read FImage;
end;
TWhatsAppChat = class
private
FItems: IList<TChatElement>;
FBaseDirectory: string;
FUsers: IList<string>;
procedure ProcessLine(const ALine: string);
function SplitLine(const ALine: string; out AContent, AUser, ADate, ATime: string): Boolean;
function TryParseImage(const AContent: string; out AImageFile: string): Boolean;
procedure CollectUsers;
public
constructor Create;
procedure LoadFromDirectory(const APath: string);
property Items: IList<TChatElement> read FItems;
property Users: IList<string> read FUsers;
end;
implementation
uses
Types,
Classes,
IOUtils,
SysUtils,
StrUtils;
{ TImageChatElement }
constructor TImageChatElement.Create;
begin
inherited;
FImage := TBitmap.Create();
end;
destructor TImageChatElement.Destroy;
begin
FImage.Free();
inherited;
end;
{ TWhatsAppChat }
procedure TWhatsAppChat.CollectUsers;
var
LUsers: ISet<string>;
LElement: TChatElement;
begin
LUsers := TCollections.CreateSet<string>();
for LElement in FItems do
LUsers.Add(LElement.User);
FUsers.AddRange(LUsers);
end;
constructor TWhatsAppChat.Create;
begin
inherited;
FItems := TCollections.CreateObjectList<TChatElement>();
FUsers := TCollections.CreateList<string>();
end;
procedure TWhatsAppChat.LoadFromDirectory(const APath: string);
var
LFiles: TStringDynArray;
LChat: TStringList;
LLine: string;
begin
FItems.Clear();
FUsers.Clear();
FBaseDirectory := APath;
if TDirectory.Exists(APath) then
begin
LFiles := TDirectory.GetFiles(APath, 'WhatsApp Chat*.txt');
if Length(LFiles) > 0 then
begin
LChat := TStringList.Create();
try
LChat.LoadFromFile(LFiles[0], TEncoding.UTF8);
for LLine in LChat do
ProcessLine(LLine);
CollectUsers();
finally
LChat.Free();
end;
end;
end;
end;
procedure TWhatsAppChat.ProcessLine(const ALine: string);
var
LContent, LUser, LDate, LTime, LImage: string;
LElement: TChatElement;
LText: TTextChatElement;
LDateFormat: TFormatSettings;
LRealDate: TDateTime;
begin
if SplitLine(ALine, LContent, LUser, LDate, LTime) then
begin
//try to convert Date
LDateFormat := TFormatSettings.Create();
LDateFormat.ShortDateFormat := 'd.m.y';
if TryStrToDate(LDate, LRealDate, LDateFormat) then
begin
LDateFormat.ShortDateFormat := 'd. mmmm yyyy';
LDate := DateToStr(LRealDate, LDateFormat);
end;
if TryParseImage(LContent, LImage) then
begin
LElement := TImageChatElement.Create();
TImageChatElement(LElement).Image.LoadFromFile(LImage);
end
else
begin
LElement := TTextChatElement.Create();
TTextChatElement(LElement).Text := LContent;
end;
LElement.Date := LDate;
LElement.Time := LTime;
LElement.User := LUser;
FItems.Add(LElement);
end
else
begin
LElement := FItems.Last;
if LElement is TTextChatElement then
begin
LText := TTextChatElement(LElement);
LText.Text := LText.Text + Trim(ALine);
end
else
begin
LText := TTextChatElement.Create();
LText.User := LElement.User;
LText.Date := LElement.Date;
LText.Time := LElement.Time;
LText.Text := Trim(ALine);
FItems.Add(LText);
end;
end;
end;
function TWhatsAppChat.SplitLine(const ALine: string; out AContent, AUser,
ADate, ATime: string): Boolean;
var
LDateSeperator, LTimeSeperator, LUserSeperator: Integer;
begin
LDateSeperator := Pos(',', ALine);
LTimeSeperator := Pos('-', ALine);
LUserSeperator := PosEx(':', ALine, LTimeSeperator);
Result := (LDateSeperator > 0) and (LTimeSeperator > 0) and (LUserSeperator > 0);
AContent := Trim(Copy(ALine, LUserSeperator + 1, Length(ALine)));
AUser := Trim(Copy(ALine, LTimeSeperator + 1, LUserSeperator - LTimeSeperator - 1));
ATime := Trim(Copy(ALine, LDateSeperator + 1, LTimeSeperator - LDateSeperator - 1));
ADate := Trim(Copy(ALine, 1, LDateSeperator - 1));
end;
function TWhatsAppChat.TryParseImage(const AContent: string;
out AImageFile: string): Boolean;
const
CImageOpen = 'IMG-';
CSubMessageOpen = '(';
var
LSubPos: Integer;
LImage: string;
begin
Result := False;
if StartsStr(CImageOpen, AContent) then
begin
LSubPos := Pos(CSubMessageOpen, AContent);
if LSubPos > 1 then
begin
LImage := Trim(Copy(AContent, 1, LSubPos - 1));
LImage := TPath.Combine(FBaseDirectory, LImage);
if TFile.Exists(LImage) and MatchText(ExtractFileExt(LImage), ['.jpg', '.jpeg']) then
begin
AImageFile := LImage;
Exit(True);
end;
end;
end;
end;
end.
|
unit xn.dataset.cache;
interface
uses Generics.Collections, System.Classes, System.TypInfo, Vcl.Grids, Data.Db;
{$M+}
type
TBookmarkHelper = record helper for TBookmark
function AsString: string;
function Equals(aBookmark: TBookmark): Boolean;
end;
TxnDatasetCache = class
type
TxnField = string;
TxnRecord = class
strict private
fBookmark: TBookmark;
fFields: TList<TxnField>;
procedure FieldSet(aFieldIndex: integer; aValue: TxnField);
function FieldGet(aFieldIndex: integer): TxnField;
procedure FieldsCreate(aFieldCount: integer);
public
constructor Create(aFieldCount: integer);
destructor Destroy; override;
procedure Load(aDataset: TDataSet);
property Fields[aFieldIndex: integer]: TxnField read FieldGet write FieldSet;
property Bookmark: TBookmark read fBookmark write fBookmark;
end;
TxnRecords = class(TObjectList<TxnRecord>)
protected
function Find(aBookmark: TBookmark): TxnRecord;
end;
TxnDataLink = class(TDataLink)
strict private
fOwner: TxnDatasetCache;
strict protected
procedure DataEvent(Event: TDataEvent; Info: NativeInt); override;
public
constructor Create(aOwner: TxnDatasetCache);
destructor Destroy; override;
end;
strict private
fGrid: TStringGrid;
fStrings: TStrings;
fFieldsCount: integer;
fLogNo: integer;
fBookmark: TBookmark;
fBookmarkPrev: TBookmark;
fRecNo: integer;
fRecNoPrev: integer;
fRecords: TxnRecords;
fDataLink: TxnDataLink;
procedure GridSet(const aGrid: TStringGrid);
function GridGet: TStringGrid;
procedure StringsSet(const aStrings: TStrings);
function StringsGet: TStrings;
procedure FieldSet(aFieldIndex, aRecordIndex: integer; aValue: TxnField);
function FieldGet(aFieldIndex, aRecordIndex: integer): TxnField;
function RecordGet(aRecordIndex: integer): TxnRecord;
procedure RecordsCreate(aFieldCount: integer; aRecordCount: integer);
strict protected
procedure DataEvent(Event: TDataEvent; Info: NativeInt);
procedure Log(aMessage: string);
public
constructor Create(aDataSource: TDataSource; aFieldCount: integer); overload;
destructor Destroy; override;
procedure OnAfterPost(aDataset: TDataSet);
procedure OnAfterInsert(aDataset: TDataSet);
procedure OnNewRecord(aDataset: TDataSet);
procedure Load(aDataset: TDataSet);
procedure Clear;
function Append: TxnRecord;
function Find(aBookmark: TBookmark): TxnRecord;
function Get(aCol, aRow: integer): string;
function GetColCount: integer;
function GetRowCount: integer;
function FieldsCount: integer;
function RecordsCount: integer;
function RecNo: integer;
procedure PaintIndicator; overload;
procedure PaintGrid; overload;
property Fields[aFieldIndex, aRecordIndex: integer]: TxnField read FieldGet write FieldSet;
property Records[aRecordIndex: integer]: TxnRecord read RecordGet;
published
property Strings: TStrings read StringsGet write StringsSet;
property Grid: TStringGrid read GridGet write GridSet;
end;
implementation
uses System.SysUtils;
{ Functions }
function EventToString(aEvent: TDataEvent): string;
begin
Result := GetEnumName(TypeInfo(TDataEvent), integer(aEvent));
end;
function StateToString(aState: TDataSetState): string;
begin
Result := GetEnumName(TypeInfo(TDataSetState), integer(aState));
end;
{ TBookmarkHelper }
function TBookmarkHelper.AsString: string;
var
b: byte;
begin
for b in Self do
begin
if Result <> '' then
Result := Result + ':';
Result := Result + IntToHex(b, 2);
end;
end;
function TBookmarkHelper.Equals(aBookmark: TBookmark): Boolean;
begin
Result := SameText(Self.AsString, aBookmark.AsString);
end;
{ TxnDatasetCache }
function TxnDatasetCache.Append: TxnRecord;
begin
Result := TxnRecord.Create(FieldsCount());
fRecords.Add(Result);
end;
procedure TxnDatasetCache.Clear;
begin
fRecords.Clear;
end;
constructor TxnDatasetCache.Create(aDataSource: TDataSource; aFieldCount: integer);
begin
fGrid := nil;
fFieldsCount := aFieldCount;
fRecords := TxnRecords.Create;
fDataLink := TxnDataLink.Create(Self);
fDataLink.DataSource := aDataSource;
fLogNo := -1;
fRecNo := -1;
fRecNoPrev := -1;
SetLength(fBookmark, 0);
SetLength(fBookmarkPrev, 0);
end;
destructor TxnDatasetCache.Destroy;
begin
fDataLink.Free;
fRecords.Free;
inherited;
end;
function TxnDatasetCache.FieldsCount: integer;
begin
Result := fFieldsCount;
end;
function TxnDatasetCache.FieldGet(aFieldIndex, aRecordIndex: integer): TxnField;
begin
Result := fRecords[aRecordIndex].Fields[aFieldIndex];
end;
procedure TxnDatasetCache.FieldSet(aFieldIndex, aRecordIndex: integer; aValue: TxnField);
begin
fRecords[aRecordIndex].Fields[aFieldIndex] := aValue;
end;
function TxnDatasetCache.Find(aBookmark: TBookmark): TxnRecord;
begin
Result := fRecords.Find(aBookmark);
end;
function TxnDatasetCache.Get(aCol, aRow: integer): string;
begin
if (aCol < 1) or (aCol > FieldsCount) then
Exit('');
if (aRow < 1) or (aRow > RecordsCount) then
Exit('');
Result := fRecords[aRow - 1].Fields[aCol - 1]
end;
function TxnDatasetCache.GetColCount: integer;
begin
Result := FieldsCount()
end;
function TxnDatasetCache.GetRowCount: integer;
begin
Result := RecordsCount()
end;
function TxnDatasetCache.GridGet: TStringGrid;
begin
Result := fGrid;
end;
procedure TxnDatasetCache.GridSet(const aGrid: TStringGrid);
begin
fGrid := aGrid;
end;
procedure TxnDatasetCache.Load(aDataset: TDataSet);
begin
aDataset.First;
while not aDataset.Eof do
begin
Append.Load(aDataset);
aDataset.Next;
end;
end;
procedure TxnDatasetCache.Log(aMessage: string);
begin
Inc(fLogNo);
if Strings <> nil then
begin
Strings.insert(0, format('%4d %s', [fLogNo, aMessage]));
while Strings.Count > 40 do
Strings.Delete(Strings.Count - 1);
end;
end;
procedure TxnDatasetCache.OnAfterInsert(aDataset: TDataSet);
begin
Log('OnAfterInsert()');
Log(aDataset.Bookmark.AsString);
end;
procedure TxnDatasetCache.OnAfterPost(aDataset: TDataSet);
var
r: TxnRecord;
begin
Log('OnAfterPost()');
Log(StateToString(aDataset.State));
Log(aDataset.Bookmark.AsString);
exit;
r := Find(aDataset.Bookmark);
Assert(r <> nil, 'Record not found!');
r.Load(aDataset);
PaintGrid();
end;
procedure TxnDatasetCache.OnNewRecord(aDataset: TDataSet);
begin
Log('OnNewRecord()');
Log(StateToString(aDataset.State));
end;
procedure TxnDatasetCache.PaintGrid;
var
c: integer;
r: integer;
begin
Log('PaintGrid()');
fGrid.ColCount := GetColCount + 1;
fGrid.RowCount := GetRowCount + 1;
for c := 1 to GetColCount do
for r := 1 to GetRowCount do
fGrid.Cells[c, r] := Get(c, r);
end;
procedure TxnDatasetCache.PaintIndicator;
begin
Log('PaintIndicator()');
if fGrid = nil then
Exit
else if fGrid.RowCount < 1 then
Exit
else if fGrid.ColCount < 2 then
Exit;
if (fRecNo >= 0) and (fRecNo <= fGrid.RowCount) then
fGrid.Cells[0, fRecNo] := '-';
if (fRecNoPrev >= 0) and (fRecNoPrev <= fGrid.RowCount) then
fGrid.Cells[0, fRecNoPrev] := '';
end;
procedure TxnDatasetCache.DataEvent(Event: TDataEvent; Info: NativeInt);
// var
// f: TField;
begin
Log(StateToString(fDataLink.dataset.State));
// f := TField(Info);
// if f <> nil then
// begin
// UpdateCell(f.Index, fDataLink.dataset.RecNo - 1, f.AsString);
// end;
if fDataLink.dataset.RecNo <> fRecNo then
begin
fRecNoPrev := fRecNo;
fRecNo := fDataLink.dataset.RecNo;
PaintIndicator();
end;
end;
function TxnDatasetCache.RecordsCount: integer;
begin
Result := fRecords.Count;
end;
function TxnDatasetCache.RecNo: integer;
begin
Result := fRecNo;
end;
function TxnDatasetCache.RecordGet(aRecordIndex: integer): TxnRecord;
begin
Result := fRecords[aRecordIndex];
end;
procedure TxnDatasetCache.RecordsCreate(aFieldCount, aRecordCount: integer);
var
i: integer;
begin
for i := 0 to aRecordCount - 1 do
fRecords.Add(TxnRecord.Create(aFieldCount));
end;
function TxnDatasetCache.StringsGet: TStrings;
begin
Result := fStrings;
end;
procedure TxnDatasetCache.StringsSet(const aStrings: TStrings);
begin
fStrings := aStrings;
end;
{ TMemTable.TMemRecord }
constructor TxnDatasetCache.TxnRecord.Create(aFieldCount: integer);
begin
fFields := TList<TxnField>.Create;
FieldsCreate(aFieldCount);
end;
destructor TxnDatasetCache.TxnRecord.Destroy;
begin
fFields.Free;
inherited;
end;
function TxnDatasetCache.TxnRecord.FieldGet(aFieldIndex: integer): TxnField;
begin
Result := fFields[aFieldIndex];
end;
procedure TxnDatasetCache.TxnRecord.FieldsCreate(aFieldCount: integer);
var
i: integer;
begin
for i := 0 to aFieldCount - 1 do
fFields.Add('');
end;
procedure TxnDatasetCache.TxnRecord.FieldSet(aFieldIndex: integer; aValue: TxnField);
begin
fFields[aFieldIndex] := aValue
end;
procedure TxnDatasetCache.TxnRecord.Load(aDataset: TDataSet);
var
i: integer;
begin
Bookmark := aDataset.GetBookmark;
for i := 0 to aDataset.Fields.Count - 1 do
Fields[i] := aDataset.Fields[i].AsString;
end;
{ TxnDatasetCache.TxnDataLink }
constructor TxnDatasetCache.TxnDataLink.Create(aOwner: TxnDatasetCache);
begin
fOwner := aOwner;
end;
procedure TxnDatasetCache.TxnDataLink.DataEvent(Event: TDataEvent; Info: NativeInt);
begin
fOwner.DataEvent(Event, Info);
inherited;
end;
destructor TxnDatasetCache.TxnDataLink.Destroy;
begin
inherited;
end;
{ TxnDatasetCache.TxnRecords }
function TxnDatasetCache.TxnRecords.Find(aBookmark: TBookmark): TxnRecord;
var
i: integer;
begin
for i := 0 to Count - 1 do
if Items[i].Bookmark.Equals(aBookmark) then
Exit(Items[i]);
Exit(nil);
end;
end.
|
unit DictionContainerKeywordsPack;
{* Набор слов словаря для доступа к экземплярам контролов формы DictionContainer }
// Модуль: "w:\garant6x\implementation\Garant\GbaNemesis\View\Diction\DictionContainerKeywordsPack.pas"
// Стереотип: "ScriptKeywordsPack"
// Элемент модели: "DictionContainerKeywordsPack" MUID: (569AACBD24E7)
{$Include w:\garant6x\implementation\Garant\nsDefine.inc}
interface
{$If NOT Defined(Admin) AND NOT Defined(Monitorings) AND NOT Defined(NoScripts)}
uses
l3IntfUses
, vtProportionalPanel
, vtSizeablePanel
, vtPanel
, vtLabel
{$If NOT Defined(NoVCL)}
, ExtCtrls
{$IfEnd} // NOT Defined(NoVCL)
;
{$IfEnd} // NOT Defined(Admin) AND NOT Defined(Monitorings) AND NOT Defined(NoScripts)
implementation
{$If NOT Defined(Admin) AND NOT Defined(Monitorings) AND NOT Defined(NoScripts)}
uses
l3ImplUses
, DictionContainer_Form
, tfwControlString
{$If NOT Defined(NoVCL)}
, kwBynameControlPush
{$IfEnd} // NOT Defined(NoVCL)
, tfwScriptingInterfaces
, tfwPropertyLike
, TypInfo
, tfwTypeInfo
, TtfwClassRef_Proxy
, SysUtils
, TtfwTypeRegistrator_Proxy
, tfwScriptingTypes
;
type
Tkw_Form_DictionContainer = {final} class(TtfwControlString)
{* Слово словаря для идентификатора формы DictionContainer
----
*Пример использования*:
[code]
'aControl' форма::DictionContainer TryFocus ASSERT
[code] }
protected
function GetString: AnsiString; override;
class function GetWordNameForRegister: AnsiString; override;
end;//Tkw_Form_DictionContainer
Tkw_DictionContainer_Control_pnBackground = {final} class(TtfwControlString)
{* Слово словаря для идентификатора контрола pnBackground
----
*Пример использования*:
[code]
контрол::pnBackground TryFocus ASSERT
[code] }
protected
function GetString: AnsiString; override;
class procedure RegisterInEngine; override;
class function GetWordNameForRegister: AnsiString; override;
end;//Tkw_DictionContainer_Control_pnBackground
Tkw_DictionContainer_Control_pnBackground_Push = {final} class({$If NOT Defined(NoVCL)}
TkwBynameControlPush
{$IfEnd} // NOT Defined(NoVCL)
)
{* Слово словаря для контрола pnBackground
----
*Пример использования*:
[code]
контрол::pnBackground:push pop:control:SetFocus ASSERT
[code] }
protected
procedure DoDoIt(const aCtx: TtfwContext); override;
class function GetWordNameForRegister: AnsiString; override;
end;//Tkw_DictionContainer_Control_pnBackground_Push
Tkw_DictionContainer_Control_NavigatorZone = {final} class(TtfwControlString)
{* Слово словаря для идентификатора контрола NavigatorZone
----
*Пример использования*:
[code]
контрол::NavigatorZone TryFocus ASSERT
[code] }
protected
function GetString: AnsiString; override;
class procedure RegisterInEngine; override;
class function GetWordNameForRegister: AnsiString; override;
end;//Tkw_DictionContainer_Control_NavigatorZone
Tkw_DictionContainer_Control_NavigatorZone_Push = {final} class({$If NOT Defined(NoVCL)}
TkwBynameControlPush
{$IfEnd} // NOT Defined(NoVCL)
)
{* Слово словаря для контрола NavigatorZone
----
*Пример использования*:
[code]
контрол::NavigatorZone:push pop:control:SetFocus ASSERT
[code] }
protected
procedure DoDoIt(const aCtx: TtfwContext); override;
class function GetWordNameForRegister: AnsiString; override;
end;//Tkw_DictionContainer_Control_NavigatorZone_Push
Tkw_DictionContainer_Control_pnWorkArea = {final} class(TtfwControlString)
{* Слово словаря для идентификатора контрола pnWorkArea
----
*Пример использования*:
[code]
контрол::pnWorkArea TryFocus ASSERT
[code] }
protected
function GetString: AnsiString; override;
class procedure RegisterInEngine; override;
class function GetWordNameForRegister: AnsiString; override;
end;//Tkw_DictionContainer_Control_pnWorkArea
Tkw_DictionContainer_Control_pnWorkArea_Push = {final} class({$If NOT Defined(NoVCL)}
TkwBynameControlPush
{$IfEnd} // NOT Defined(NoVCL)
)
{* Слово словаря для контрола pnWorkArea
----
*Пример использования*:
[code]
контрол::pnWorkArea:push pop:control:SetFocus ASSERT
[code] }
protected
procedure DoDoIt(const aCtx: TtfwContext); override;
class function GetWordNameForRegister: AnsiString; override;
end;//Tkw_DictionContainer_Control_pnWorkArea_Push
Tkw_DictionContainer_Control_ChildZone = {final} class(TtfwControlString)
{* Слово словаря для идентификатора контрола ChildZone
----
*Пример использования*:
[code]
контрол::ChildZone TryFocus ASSERT
[code] }
protected
function GetString: AnsiString; override;
class procedure RegisterInEngine; override;
class function GetWordNameForRegister: AnsiString; override;
end;//Tkw_DictionContainer_Control_ChildZone
Tkw_DictionContainer_Control_ChildZone_Push = {final} class({$If NOT Defined(NoVCL)}
TkwBynameControlPush
{$IfEnd} // NOT Defined(NoVCL)
)
{* Слово словаря для контрола ChildZone
----
*Пример использования*:
[code]
контрол::ChildZone:push pop:control:SetFocus ASSERT
[code] }
protected
procedure DoDoIt(const aCtx: TtfwContext); override;
class function GetWordNameForRegister: AnsiString; override;
end;//Tkw_DictionContainer_Control_ChildZone_Push
Tkw_DictionContainer_Control_pnHeader = {final} class(TtfwControlString)
{* Слово словаря для идентификатора контрола pnHeader
----
*Пример использования*:
[code]
контрол::pnHeader TryFocus ASSERT
[code] }
protected
function GetString: AnsiString; override;
class procedure RegisterInEngine; override;
class function GetWordNameForRegister: AnsiString; override;
end;//Tkw_DictionContainer_Control_pnHeader
Tkw_DictionContainer_Control_pnHeader_Push = {final} class({$If NOT Defined(NoVCL)}
TkwBynameControlPush
{$IfEnd} // NOT Defined(NoVCL)
)
{* Слово словаря для контрола pnHeader
----
*Пример использования*:
[code]
контрол::pnHeader:push pop:control:SetFocus ASSERT
[code] }
protected
procedure DoDoIt(const aCtx: TtfwContext); override;
class function GetWordNameForRegister: AnsiString; override;
end;//Tkw_DictionContainer_Control_pnHeader_Push
Tkw_DictionContainer_Control_lbHeader = {final} class(TtfwControlString)
{* Слово словаря для идентификатора контрола lbHeader
----
*Пример использования*:
[code]
контрол::lbHeader TryFocus ASSERT
[code] }
protected
function GetString: AnsiString; override;
class procedure RegisterInEngine; override;
class function GetWordNameForRegister: AnsiString; override;
end;//Tkw_DictionContainer_Control_lbHeader
Tkw_DictionContainer_Control_lbHeader_Push = {final} class({$If NOT Defined(NoVCL)}
TkwBynameControlPush
{$IfEnd} // NOT Defined(NoVCL)
)
{* Слово словаря для контрола lbHeader
----
*Пример использования*:
[code]
контрол::lbHeader:push pop:control:SetFocus ASSERT
[code] }
protected
procedure DoDoIt(const aCtx: TtfwContext); override;
class function GetWordNameForRegister: AnsiString; override;
end;//Tkw_DictionContainer_Control_lbHeader_Push
Tkw_DictionContainer_Control_pbHeader = {final} class(TtfwControlString)
{* Слово словаря для идентификатора контрола pbHeader
----
*Пример использования*:
[code]
контрол::pbHeader TryFocus ASSERT
[code] }
protected
function GetString: AnsiString; override;
class procedure RegisterInEngine; override;
class function GetWordNameForRegister: AnsiString; override;
end;//Tkw_DictionContainer_Control_pbHeader
Tkw_DictionContainer_Control_pbHeader_Push = {final} class({$If NOT Defined(NoVCL)}
TkwBynameControlPush
{$IfEnd} // NOT Defined(NoVCL)
)
{* Слово словаря для контрола pbHeader
----
*Пример использования*:
[code]
контрол::pbHeader:push pop:control:SetFocus ASSERT
[code] }
protected
procedure DoDoIt(const aCtx: TtfwContext); override;
class function GetWordNameForRegister: AnsiString; override;
end;//Tkw_DictionContainer_Control_pbHeader_Push
Tkw_DictionContainer_Control_ParentZone = {final} class(TtfwControlString)
{* Слово словаря для идентификатора контрола ParentZone
----
*Пример использования*:
[code]
контрол::ParentZone TryFocus ASSERT
[code] }
protected
function GetString: AnsiString; override;
class procedure RegisterInEngine; override;
class function GetWordNameForRegister: AnsiString; override;
end;//Tkw_DictionContainer_Control_ParentZone
Tkw_DictionContainer_Control_ParentZone_Push = {final} class({$If NOT Defined(NoVCL)}
TkwBynameControlPush
{$IfEnd} // NOT Defined(NoVCL)
)
{* Слово словаря для контрола ParentZone
----
*Пример использования*:
[code]
контрол::ParentZone:push pop:control:SetFocus ASSERT
[code] }
protected
procedure DoDoIt(const aCtx: TtfwContext); override;
class function GetWordNameForRegister: AnsiString; override;
end;//Tkw_DictionContainer_Control_ParentZone_Push
TkwDictionContainerFormPnBackground = {final} class(TtfwPropertyLike)
{* Слово скрипта .TDictionContainerForm.pnBackground }
private
function pnBackground(const aCtx: TtfwContext;
aDictionContainerForm: TDictionContainerForm): TvtProportionalPanel;
{* Реализация слова скрипта .TDictionContainerForm.pnBackground }
protected
class function GetWordNameForRegister: AnsiString; override;
procedure DoDoIt(const aCtx: TtfwContext); override;
public
function GetResultTypeInfo(const aCtx: TtfwContext): PTypeInfo; override;
function GetAllParamsCount(const aCtx: TtfwContext): Integer; override;
function ParamsTypes: PTypeInfoArray; override;
procedure SetValuePrim(const aValue: TtfwStackValue;
const aCtx: TtfwContext); override;
end;//TkwDictionContainerFormPnBackground
TkwDictionContainerFormNavigatorZone = {final} class(TtfwPropertyLike)
{* Слово скрипта .TDictionContainerForm.NavigatorZone }
private
function NavigatorZone(const aCtx: TtfwContext;
aDictionContainerForm: TDictionContainerForm): TvtSizeablePanel;
{* Реализация слова скрипта .TDictionContainerForm.NavigatorZone }
protected
class function GetWordNameForRegister: AnsiString; override;
procedure DoDoIt(const aCtx: TtfwContext); override;
public
function GetResultTypeInfo(const aCtx: TtfwContext): PTypeInfo; override;
function GetAllParamsCount(const aCtx: TtfwContext): Integer; override;
function ParamsTypes: PTypeInfoArray; override;
procedure SetValuePrim(const aValue: TtfwStackValue;
const aCtx: TtfwContext); override;
end;//TkwDictionContainerFormNavigatorZone
TkwDictionContainerFormPnWorkArea = {final} class(TtfwPropertyLike)
{* Слово скрипта .TDictionContainerForm.pnWorkArea }
private
function pnWorkArea(const aCtx: TtfwContext;
aDictionContainerForm: TDictionContainerForm): TvtProportionalPanel;
{* Реализация слова скрипта .TDictionContainerForm.pnWorkArea }
protected
class function GetWordNameForRegister: AnsiString; override;
procedure DoDoIt(const aCtx: TtfwContext); override;
public
function GetResultTypeInfo(const aCtx: TtfwContext): PTypeInfo; override;
function GetAllParamsCount(const aCtx: TtfwContext): Integer; override;
function ParamsTypes: PTypeInfoArray; override;
procedure SetValuePrim(const aValue: TtfwStackValue;
const aCtx: TtfwContext); override;
end;//TkwDictionContainerFormPnWorkArea
TkwDictionContainerFormChildZone = {final} class(TtfwPropertyLike)
{* Слово скрипта .TDictionContainerForm.ChildZone }
private
function ChildZone(const aCtx: TtfwContext;
aDictionContainerForm: TDictionContainerForm): TvtSizeablePanel;
{* Реализация слова скрипта .TDictionContainerForm.ChildZone }
protected
class function GetWordNameForRegister: AnsiString; override;
procedure DoDoIt(const aCtx: TtfwContext); override;
public
function GetResultTypeInfo(const aCtx: TtfwContext): PTypeInfo; override;
function GetAllParamsCount(const aCtx: TtfwContext): Integer; override;
function ParamsTypes: PTypeInfoArray; override;
procedure SetValuePrim(const aValue: TtfwStackValue;
const aCtx: TtfwContext); override;
end;//TkwDictionContainerFormChildZone
TkwDictionContainerFormPnHeader = {final} class(TtfwPropertyLike)
{* Слово скрипта .TDictionContainerForm.pnHeader }
private
function pnHeader(const aCtx: TtfwContext;
aDictionContainerForm: TDictionContainerForm): TvtPanel;
{* Реализация слова скрипта .TDictionContainerForm.pnHeader }
protected
class function GetWordNameForRegister: AnsiString; override;
procedure DoDoIt(const aCtx: TtfwContext); override;
public
function GetResultTypeInfo(const aCtx: TtfwContext): PTypeInfo; override;
function GetAllParamsCount(const aCtx: TtfwContext): Integer; override;
function ParamsTypes: PTypeInfoArray; override;
procedure SetValuePrim(const aValue: TtfwStackValue;
const aCtx: TtfwContext); override;
end;//TkwDictionContainerFormPnHeader
TkwDictionContainerFormLbHeader = {final} class(TtfwPropertyLike)
{* Слово скрипта .TDictionContainerForm.lbHeader }
private
function lbHeader(const aCtx: TtfwContext;
aDictionContainerForm: TDictionContainerForm): TvtLabel;
{* Реализация слова скрипта .TDictionContainerForm.lbHeader }
protected
class function GetWordNameForRegister: AnsiString; override;
procedure DoDoIt(const aCtx: TtfwContext); override;
public
function GetResultTypeInfo(const aCtx: TtfwContext): PTypeInfo; override;
function GetAllParamsCount(const aCtx: TtfwContext): Integer; override;
function ParamsTypes: PTypeInfoArray; override;
procedure SetValuePrim(const aValue: TtfwStackValue;
const aCtx: TtfwContext); override;
end;//TkwDictionContainerFormLbHeader
TkwDictionContainerFormPbHeader = {final} class(TtfwPropertyLike)
{* Слово скрипта .TDictionContainerForm.pbHeader }
private
function pbHeader(const aCtx: TtfwContext;
aDictionContainerForm: TDictionContainerForm): TPaintBox;
{* Реализация слова скрипта .TDictionContainerForm.pbHeader }
protected
class function GetWordNameForRegister: AnsiString; override;
procedure DoDoIt(const aCtx: TtfwContext); override;
public
function GetResultTypeInfo(const aCtx: TtfwContext): PTypeInfo; override;
function GetAllParamsCount(const aCtx: TtfwContext): Integer; override;
function ParamsTypes: PTypeInfoArray; override;
procedure SetValuePrim(const aValue: TtfwStackValue;
const aCtx: TtfwContext); override;
end;//TkwDictionContainerFormPbHeader
TkwDictionContainerFormParentZone = {final} class(TtfwPropertyLike)
{* Слово скрипта .TDictionContainerForm.ParentZone }
private
function ParentZone(const aCtx: TtfwContext;
aDictionContainerForm: TDictionContainerForm): TvtPanel;
{* Реализация слова скрипта .TDictionContainerForm.ParentZone }
protected
class function GetWordNameForRegister: AnsiString; override;
procedure DoDoIt(const aCtx: TtfwContext); override;
public
function GetResultTypeInfo(const aCtx: TtfwContext): PTypeInfo; override;
function GetAllParamsCount(const aCtx: TtfwContext): Integer; override;
function ParamsTypes: PTypeInfoArray; override;
procedure SetValuePrim(const aValue: TtfwStackValue;
const aCtx: TtfwContext); override;
end;//TkwDictionContainerFormParentZone
function Tkw_Form_DictionContainer.GetString: AnsiString;
begin
Result := 'DictionContainerForm';
end;//Tkw_Form_DictionContainer.GetString
class function Tkw_Form_DictionContainer.GetWordNameForRegister: AnsiString;
begin
Result := 'форма::DictionContainer';
end;//Tkw_Form_DictionContainer.GetWordNameForRegister
function Tkw_DictionContainer_Control_pnBackground.GetString: AnsiString;
begin
Result := 'pnBackground';
end;//Tkw_DictionContainer_Control_pnBackground.GetString
class procedure Tkw_DictionContainer_Control_pnBackground.RegisterInEngine;
begin
inherited;
TtfwClassRef.Register(TvtProportionalPanel);
end;//Tkw_DictionContainer_Control_pnBackground.RegisterInEngine
class function Tkw_DictionContainer_Control_pnBackground.GetWordNameForRegister: AnsiString;
begin
Result := 'контрол::pnBackground';
end;//Tkw_DictionContainer_Control_pnBackground.GetWordNameForRegister
procedure Tkw_DictionContainer_Control_pnBackground_Push.DoDoIt(const aCtx: TtfwContext);
begin
aCtx.rEngine.PushString('pnBackground');
inherited;
end;//Tkw_DictionContainer_Control_pnBackground_Push.DoDoIt
class function Tkw_DictionContainer_Control_pnBackground_Push.GetWordNameForRegister: AnsiString;
begin
Result := 'контрол::pnBackground:push';
end;//Tkw_DictionContainer_Control_pnBackground_Push.GetWordNameForRegister
function Tkw_DictionContainer_Control_NavigatorZone.GetString: AnsiString;
begin
Result := 'NavigatorZone';
end;//Tkw_DictionContainer_Control_NavigatorZone.GetString
class procedure Tkw_DictionContainer_Control_NavigatorZone.RegisterInEngine;
begin
inherited;
TtfwClassRef.Register(TvtSizeablePanel);
end;//Tkw_DictionContainer_Control_NavigatorZone.RegisterInEngine
class function Tkw_DictionContainer_Control_NavigatorZone.GetWordNameForRegister: AnsiString;
begin
Result := 'контрол::NavigatorZone';
end;//Tkw_DictionContainer_Control_NavigatorZone.GetWordNameForRegister
procedure Tkw_DictionContainer_Control_NavigatorZone_Push.DoDoIt(const aCtx: TtfwContext);
begin
aCtx.rEngine.PushString('NavigatorZone');
inherited;
end;//Tkw_DictionContainer_Control_NavigatorZone_Push.DoDoIt
class function Tkw_DictionContainer_Control_NavigatorZone_Push.GetWordNameForRegister: AnsiString;
begin
Result := 'контрол::NavigatorZone:push';
end;//Tkw_DictionContainer_Control_NavigatorZone_Push.GetWordNameForRegister
function Tkw_DictionContainer_Control_pnWorkArea.GetString: AnsiString;
begin
Result := 'pnWorkArea';
end;//Tkw_DictionContainer_Control_pnWorkArea.GetString
class procedure Tkw_DictionContainer_Control_pnWorkArea.RegisterInEngine;
begin
inherited;
TtfwClassRef.Register(TvtProportionalPanel);
end;//Tkw_DictionContainer_Control_pnWorkArea.RegisterInEngine
class function Tkw_DictionContainer_Control_pnWorkArea.GetWordNameForRegister: AnsiString;
begin
Result := 'контрол::pnWorkArea';
end;//Tkw_DictionContainer_Control_pnWorkArea.GetWordNameForRegister
procedure Tkw_DictionContainer_Control_pnWorkArea_Push.DoDoIt(const aCtx: TtfwContext);
begin
aCtx.rEngine.PushString('pnWorkArea');
inherited;
end;//Tkw_DictionContainer_Control_pnWorkArea_Push.DoDoIt
class function Tkw_DictionContainer_Control_pnWorkArea_Push.GetWordNameForRegister: AnsiString;
begin
Result := 'контрол::pnWorkArea:push';
end;//Tkw_DictionContainer_Control_pnWorkArea_Push.GetWordNameForRegister
function Tkw_DictionContainer_Control_ChildZone.GetString: AnsiString;
begin
Result := 'ChildZone';
end;//Tkw_DictionContainer_Control_ChildZone.GetString
class procedure Tkw_DictionContainer_Control_ChildZone.RegisterInEngine;
begin
inherited;
TtfwClassRef.Register(TvtSizeablePanel);
end;//Tkw_DictionContainer_Control_ChildZone.RegisterInEngine
class function Tkw_DictionContainer_Control_ChildZone.GetWordNameForRegister: AnsiString;
begin
Result := 'контрол::ChildZone';
end;//Tkw_DictionContainer_Control_ChildZone.GetWordNameForRegister
procedure Tkw_DictionContainer_Control_ChildZone_Push.DoDoIt(const aCtx: TtfwContext);
begin
aCtx.rEngine.PushString('ChildZone');
inherited;
end;//Tkw_DictionContainer_Control_ChildZone_Push.DoDoIt
class function Tkw_DictionContainer_Control_ChildZone_Push.GetWordNameForRegister: AnsiString;
begin
Result := 'контрол::ChildZone:push';
end;//Tkw_DictionContainer_Control_ChildZone_Push.GetWordNameForRegister
function Tkw_DictionContainer_Control_pnHeader.GetString: AnsiString;
begin
Result := 'pnHeader';
end;//Tkw_DictionContainer_Control_pnHeader.GetString
class procedure Tkw_DictionContainer_Control_pnHeader.RegisterInEngine;
begin
inherited;
TtfwClassRef.Register(TvtPanel);
end;//Tkw_DictionContainer_Control_pnHeader.RegisterInEngine
class function Tkw_DictionContainer_Control_pnHeader.GetWordNameForRegister: AnsiString;
begin
Result := 'контрол::pnHeader';
end;//Tkw_DictionContainer_Control_pnHeader.GetWordNameForRegister
procedure Tkw_DictionContainer_Control_pnHeader_Push.DoDoIt(const aCtx: TtfwContext);
begin
aCtx.rEngine.PushString('pnHeader');
inherited;
end;//Tkw_DictionContainer_Control_pnHeader_Push.DoDoIt
class function Tkw_DictionContainer_Control_pnHeader_Push.GetWordNameForRegister: AnsiString;
begin
Result := 'контрол::pnHeader:push';
end;//Tkw_DictionContainer_Control_pnHeader_Push.GetWordNameForRegister
function Tkw_DictionContainer_Control_lbHeader.GetString: AnsiString;
begin
Result := 'lbHeader';
end;//Tkw_DictionContainer_Control_lbHeader.GetString
class procedure Tkw_DictionContainer_Control_lbHeader.RegisterInEngine;
begin
inherited;
TtfwClassRef.Register(TvtLabel);
end;//Tkw_DictionContainer_Control_lbHeader.RegisterInEngine
class function Tkw_DictionContainer_Control_lbHeader.GetWordNameForRegister: AnsiString;
begin
Result := 'контрол::lbHeader';
end;//Tkw_DictionContainer_Control_lbHeader.GetWordNameForRegister
procedure Tkw_DictionContainer_Control_lbHeader_Push.DoDoIt(const aCtx: TtfwContext);
begin
aCtx.rEngine.PushString('lbHeader');
inherited;
end;//Tkw_DictionContainer_Control_lbHeader_Push.DoDoIt
class function Tkw_DictionContainer_Control_lbHeader_Push.GetWordNameForRegister: AnsiString;
begin
Result := 'контрол::lbHeader:push';
end;//Tkw_DictionContainer_Control_lbHeader_Push.GetWordNameForRegister
function Tkw_DictionContainer_Control_pbHeader.GetString: AnsiString;
begin
Result := 'pbHeader';
end;//Tkw_DictionContainer_Control_pbHeader.GetString
class procedure Tkw_DictionContainer_Control_pbHeader.RegisterInEngine;
begin
inherited;
TtfwClassRef.Register(TPaintBox);
end;//Tkw_DictionContainer_Control_pbHeader.RegisterInEngine
class function Tkw_DictionContainer_Control_pbHeader.GetWordNameForRegister: AnsiString;
begin
Result := 'контрол::pbHeader';
end;//Tkw_DictionContainer_Control_pbHeader.GetWordNameForRegister
procedure Tkw_DictionContainer_Control_pbHeader_Push.DoDoIt(const aCtx: TtfwContext);
begin
aCtx.rEngine.PushString('pbHeader');
inherited;
end;//Tkw_DictionContainer_Control_pbHeader_Push.DoDoIt
class function Tkw_DictionContainer_Control_pbHeader_Push.GetWordNameForRegister: AnsiString;
begin
Result := 'контрол::pbHeader:push';
end;//Tkw_DictionContainer_Control_pbHeader_Push.GetWordNameForRegister
function Tkw_DictionContainer_Control_ParentZone.GetString: AnsiString;
begin
Result := 'ParentZone';
end;//Tkw_DictionContainer_Control_ParentZone.GetString
class procedure Tkw_DictionContainer_Control_ParentZone.RegisterInEngine;
begin
inherited;
TtfwClassRef.Register(TvtPanel);
end;//Tkw_DictionContainer_Control_ParentZone.RegisterInEngine
class function Tkw_DictionContainer_Control_ParentZone.GetWordNameForRegister: AnsiString;
begin
Result := 'контрол::ParentZone';
end;//Tkw_DictionContainer_Control_ParentZone.GetWordNameForRegister
procedure Tkw_DictionContainer_Control_ParentZone_Push.DoDoIt(const aCtx: TtfwContext);
begin
aCtx.rEngine.PushString('ParentZone');
inherited;
end;//Tkw_DictionContainer_Control_ParentZone_Push.DoDoIt
class function Tkw_DictionContainer_Control_ParentZone_Push.GetWordNameForRegister: AnsiString;
begin
Result := 'контрол::ParentZone:push';
end;//Tkw_DictionContainer_Control_ParentZone_Push.GetWordNameForRegister
function TkwDictionContainerFormPnBackground.pnBackground(const aCtx: TtfwContext;
aDictionContainerForm: TDictionContainerForm): TvtProportionalPanel;
{* Реализация слова скрипта .TDictionContainerForm.pnBackground }
begin
Result := aDictionContainerForm.pnBackground;
end;//TkwDictionContainerFormPnBackground.pnBackground
class function TkwDictionContainerFormPnBackground.GetWordNameForRegister: AnsiString;
begin
Result := '.TDictionContainerForm.pnBackground';
end;//TkwDictionContainerFormPnBackground.GetWordNameForRegister
function TkwDictionContainerFormPnBackground.GetResultTypeInfo(const aCtx: TtfwContext): PTypeInfo;
begin
Result := TypeInfo(TvtProportionalPanel);
end;//TkwDictionContainerFormPnBackground.GetResultTypeInfo
function TkwDictionContainerFormPnBackground.GetAllParamsCount(const aCtx: TtfwContext): Integer;
begin
Result := 1;
end;//TkwDictionContainerFormPnBackground.GetAllParamsCount
function TkwDictionContainerFormPnBackground.ParamsTypes: PTypeInfoArray;
begin
Result := OpenTypesToTypes([TypeInfo(TDictionContainerForm)]);
end;//TkwDictionContainerFormPnBackground.ParamsTypes
procedure TkwDictionContainerFormPnBackground.SetValuePrim(const aValue: TtfwStackValue;
const aCtx: TtfwContext);
begin
RunnerError('Нельзя присваивать значение readonly свойству pnBackground', aCtx);
end;//TkwDictionContainerFormPnBackground.SetValuePrim
procedure TkwDictionContainerFormPnBackground.DoDoIt(const aCtx: TtfwContext);
var l_aDictionContainerForm: TDictionContainerForm;
begin
try
l_aDictionContainerForm := TDictionContainerForm(aCtx.rEngine.PopObjAs(TDictionContainerForm));
except
on E: Exception do
begin
RunnerError('Ошибка при получении параметра aDictionContainerForm: TDictionContainerForm : ' + E.Message, aCtx);
Exit;
end;//on E: Exception
end;//try..except
aCtx.rEngine.PushObj(pnBackground(aCtx, l_aDictionContainerForm));
end;//TkwDictionContainerFormPnBackground.DoDoIt
function TkwDictionContainerFormNavigatorZone.NavigatorZone(const aCtx: TtfwContext;
aDictionContainerForm: TDictionContainerForm): TvtSizeablePanel;
{* Реализация слова скрипта .TDictionContainerForm.NavigatorZone }
begin
Result := aDictionContainerForm.NavigatorZone;
end;//TkwDictionContainerFormNavigatorZone.NavigatorZone
class function TkwDictionContainerFormNavigatorZone.GetWordNameForRegister: AnsiString;
begin
Result := '.TDictionContainerForm.NavigatorZone';
end;//TkwDictionContainerFormNavigatorZone.GetWordNameForRegister
function TkwDictionContainerFormNavigatorZone.GetResultTypeInfo(const aCtx: TtfwContext): PTypeInfo;
begin
Result := TypeInfo(TvtSizeablePanel);
end;//TkwDictionContainerFormNavigatorZone.GetResultTypeInfo
function TkwDictionContainerFormNavigatorZone.GetAllParamsCount(const aCtx: TtfwContext): Integer;
begin
Result := 1;
end;//TkwDictionContainerFormNavigatorZone.GetAllParamsCount
function TkwDictionContainerFormNavigatorZone.ParamsTypes: PTypeInfoArray;
begin
Result := OpenTypesToTypes([TypeInfo(TDictionContainerForm)]);
end;//TkwDictionContainerFormNavigatorZone.ParamsTypes
procedure TkwDictionContainerFormNavigatorZone.SetValuePrim(const aValue: TtfwStackValue;
const aCtx: TtfwContext);
begin
RunnerError('Нельзя присваивать значение readonly свойству NavigatorZone', aCtx);
end;//TkwDictionContainerFormNavigatorZone.SetValuePrim
procedure TkwDictionContainerFormNavigatorZone.DoDoIt(const aCtx: TtfwContext);
var l_aDictionContainerForm: TDictionContainerForm;
begin
try
l_aDictionContainerForm := TDictionContainerForm(aCtx.rEngine.PopObjAs(TDictionContainerForm));
except
on E: Exception do
begin
RunnerError('Ошибка при получении параметра aDictionContainerForm: TDictionContainerForm : ' + E.Message, aCtx);
Exit;
end;//on E: Exception
end;//try..except
aCtx.rEngine.PushObj(NavigatorZone(aCtx, l_aDictionContainerForm));
end;//TkwDictionContainerFormNavigatorZone.DoDoIt
function TkwDictionContainerFormPnWorkArea.pnWorkArea(const aCtx: TtfwContext;
aDictionContainerForm: TDictionContainerForm): TvtProportionalPanel;
{* Реализация слова скрипта .TDictionContainerForm.pnWorkArea }
begin
Result := aDictionContainerForm.pnWorkArea;
end;//TkwDictionContainerFormPnWorkArea.pnWorkArea
class function TkwDictionContainerFormPnWorkArea.GetWordNameForRegister: AnsiString;
begin
Result := '.TDictionContainerForm.pnWorkArea';
end;//TkwDictionContainerFormPnWorkArea.GetWordNameForRegister
function TkwDictionContainerFormPnWorkArea.GetResultTypeInfo(const aCtx: TtfwContext): PTypeInfo;
begin
Result := TypeInfo(TvtProportionalPanel);
end;//TkwDictionContainerFormPnWorkArea.GetResultTypeInfo
function TkwDictionContainerFormPnWorkArea.GetAllParamsCount(const aCtx: TtfwContext): Integer;
begin
Result := 1;
end;//TkwDictionContainerFormPnWorkArea.GetAllParamsCount
function TkwDictionContainerFormPnWorkArea.ParamsTypes: PTypeInfoArray;
begin
Result := OpenTypesToTypes([TypeInfo(TDictionContainerForm)]);
end;//TkwDictionContainerFormPnWorkArea.ParamsTypes
procedure TkwDictionContainerFormPnWorkArea.SetValuePrim(const aValue: TtfwStackValue;
const aCtx: TtfwContext);
begin
RunnerError('Нельзя присваивать значение readonly свойству pnWorkArea', aCtx);
end;//TkwDictionContainerFormPnWorkArea.SetValuePrim
procedure TkwDictionContainerFormPnWorkArea.DoDoIt(const aCtx: TtfwContext);
var l_aDictionContainerForm: TDictionContainerForm;
begin
try
l_aDictionContainerForm := TDictionContainerForm(aCtx.rEngine.PopObjAs(TDictionContainerForm));
except
on E: Exception do
begin
RunnerError('Ошибка при получении параметра aDictionContainerForm: TDictionContainerForm : ' + E.Message, aCtx);
Exit;
end;//on E: Exception
end;//try..except
aCtx.rEngine.PushObj(pnWorkArea(aCtx, l_aDictionContainerForm));
end;//TkwDictionContainerFormPnWorkArea.DoDoIt
function TkwDictionContainerFormChildZone.ChildZone(const aCtx: TtfwContext;
aDictionContainerForm: TDictionContainerForm): TvtSizeablePanel;
{* Реализация слова скрипта .TDictionContainerForm.ChildZone }
begin
Result := aDictionContainerForm.ChildZone;
end;//TkwDictionContainerFormChildZone.ChildZone
class function TkwDictionContainerFormChildZone.GetWordNameForRegister: AnsiString;
begin
Result := '.TDictionContainerForm.ChildZone';
end;//TkwDictionContainerFormChildZone.GetWordNameForRegister
function TkwDictionContainerFormChildZone.GetResultTypeInfo(const aCtx: TtfwContext): PTypeInfo;
begin
Result := TypeInfo(TvtSizeablePanel);
end;//TkwDictionContainerFormChildZone.GetResultTypeInfo
function TkwDictionContainerFormChildZone.GetAllParamsCount(const aCtx: TtfwContext): Integer;
begin
Result := 1;
end;//TkwDictionContainerFormChildZone.GetAllParamsCount
function TkwDictionContainerFormChildZone.ParamsTypes: PTypeInfoArray;
begin
Result := OpenTypesToTypes([TypeInfo(TDictionContainerForm)]);
end;//TkwDictionContainerFormChildZone.ParamsTypes
procedure TkwDictionContainerFormChildZone.SetValuePrim(const aValue: TtfwStackValue;
const aCtx: TtfwContext);
begin
RunnerError('Нельзя присваивать значение readonly свойству ChildZone', aCtx);
end;//TkwDictionContainerFormChildZone.SetValuePrim
procedure TkwDictionContainerFormChildZone.DoDoIt(const aCtx: TtfwContext);
var l_aDictionContainerForm: TDictionContainerForm;
begin
try
l_aDictionContainerForm := TDictionContainerForm(aCtx.rEngine.PopObjAs(TDictionContainerForm));
except
on E: Exception do
begin
RunnerError('Ошибка при получении параметра aDictionContainerForm: TDictionContainerForm : ' + E.Message, aCtx);
Exit;
end;//on E: Exception
end;//try..except
aCtx.rEngine.PushObj(ChildZone(aCtx, l_aDictionContainerForm));
end;//TkwDictionContainerFormChildZone.DoDoIt
function TkwDictionContainerFormPnHeader.pnHeader(const aCtx: TtfwContext;
aDictionContainerForm: TDictionContainerForm): TvtPanel;
{* Реализация слова скрипта .TDictionContainerForm.pnHeader }
begin
Result := aDictionContainerForm.pnHeader;
end;//TkwDictionContainerFormPnHeader.pnHeader
class function TkwDictionContainerFormPnHeader.GetWordNameForRegister: AnsiString;
begin
Result := '.TDictionContainerForm.pnHeader';
end;//TkwDictionContainerFormPnHeader.GetWordNameForRegister
function TkwDictionContainerFormPnHeader.GetResultTypeInfo(const aCtx: TtfwContext): PTypeInfo;
begin
Result := TypeInfo(TvtPanel);
end;//TkwDictionContainerFormPnHeader.GetResultTypeInfo
function TkwDictionContainerFormPnHeader.GetAllParamsCount(const aCtx: TtfwContext): Integer;
begin
Result := 1;
end;//TkwDictionContainerFormPnHeader.GetAllParamsCount
function TkwDictionContainerFormPnHeader.ParamsTypes: PTypeInfoArray;
begin
Result := OpenTypesToTypes([TypeInfo(TDictionContainerForm)]);
end;//TkwDictionContainerFormPnHeader.ParamsTypes
procedure TkwDictionContainerFormPnHeader.SetValuePrim(const aValue: TtfwStackValue;
const aCtx: TtfwContext);
begin
RunnerError('Нельзя присваивать значение readonly свойству pnHeader', aCtx);
end;//TkwDictionContainerFormPnHeader.SetValuePrim
procedure TkwDictionContainerFormPnHeader.DoDoIt(const aCtx: TtfwContext);
var l_aDictionContainerForm: TDictionContainerForm;
begin
try
l_aDictionContainerForm := TDictionContainerForm(aCtx.rEngine.PopObjAs(TDictionContainerForm));
except
on E: Exception do
begin
RunnerError('Ошибка при получении параметра aDictionContainerForm: TDictionContainerForm : ' + E.Message, aCtx);
Exit;
end;//on E: Exception
end;//try..except
aCtx.rEngine.PushObj(pnHeader(aCtx, l_aDictionContainerForm));
end;//TkwDictionContainerFormPnHeader.DoDoIt
function TkwDictionContainerFormLbHeader.lbHeader(const aCtx: TtfwContext;
aDictionContainerForm: TDictionContainerForm): TvtLabel;
{* Реализация слова скрипта .TDictionContainerForm.lbHeader }
begin
Result := aDictionContainerForm.lbHeader;
end;//TkwDictionContainerFormLbHeader.lbHeader
class function TkwDictionContainerFormLbHeader.GetWordNameForRegister: AnsiString;
begin
Result := '.TDictionContainerForm.lbHeader';
end;//TkwDictionContainerFormLbHeader.GetWordNameForRegister
function TkwDictionContainerFormLbHeader.GetResultTypeInfo(const aCtx: TtfwContext): PTypeInfo;
begin
Result := TypeInfo(TvtLabel);
end;//TkwDictionContainerFormLbHeader.GetResultTypeInfo
function TkwDictionContainerFormLbHeader.GetAllParamsCount(const aCtx: TtfwContext): Integer;
begin
Result := 1;
end;//TkwDictionContainerFormLbHeader.GetAllParamsCount
function TkwDictionContainerFormLbHeader.ParamsTypes: PTypeInfoArray;
begin
Result := OpenTypesToTypes([TypeInfo(TDictionContainerForm)]);
end;//TkwDictionContainerFormLbHeader.ParamsTypes
procedure TkwDictionContainerFormLbHeader.SetValuePrim(const aValue: TtfwStackValue;
const aCtx: TtfwContext);
begin
RunnerError('Нельзя присваивать значение readonly свойству lbHeader', aCtx);
end;//TkwDictionContainerFormLbHeader.SetValuePrim
procedure TkwDictionContainerFormLbHeader.DoDoIt(const aCtx: TtfwContext);
var l_aDictionContainerForm: TDictionContainerForm;
begin
try
l_aDictionContainerForm := TDictionContainerForm(aCtx.rEngine.PopObjAs(TDictionContainerForm));
except
on E: Exception do
begin
RunnerError('Ошибка при получении параметра aDictionContainerForm: TDictionContainerForm : ' + E.Message, aCtx);
Exit;
end;//on E: Exception
end;//try..except
aCtx.rEngine.PushObj(lbHeader(aCtx, l_aDictionContainerForm));
end;//TkwDictionContainerFormLbHeader.DoDoIt
function TkwDictionContainerFormPbHeader.pbHeader(const aCtx: TtfwContext;
aDictionContainerForm: TDictionContainerForm): TPaintBox;
{* Реализация слова скрипта .TDictionContainerForm.pbHeader }
begin
Result := aDictionContainerForm.pbHeader;
end;//TkwDictionContainerFormPbHeader.pbHeader
class function TkwDictionContainerFormPbHeader.GetWordNameForRegister: AnsiString;
begin
Result := '.TDictionContainerForm.pbHeader';
end;//TkwDictionContainerFormPbHeader.GetWordNameForRegister
function TkwDictionContainerFormPbHeader.GetResultTypeInfo(const aCtx: TtfwContext): PTypeInfo;
begin
Result := TypeInfo(TPaintBox);
end;//TkwDictionContainerFormPbHeader.GetResultTypeInfo
function TkwDictionContainerFormPbHeader.GetAllParamsCount(const aCtx: TtfwContext): Integer;
begin
Result := 1;
end;//TkwDictionContainerFormPbHeader.GetAllParamsCount
function TkwDictionContainerFormPbHeader.ParamsTypes: PTypeInfoArray;
begin
Result := OpenTypesToTypes([TypeInfo(TDictionContainerForm)]);
end;//TkwDictionContainerFormPbHeader.ParamsTypes
procedure TkwDictionContainerFormPbHeader.SetValuePrim(const aValue: TtfwStackValue;
const aCtx: TtfwContext);
begin
RunnerError('Нельзя присваивать значение readonly свойству pbHeader', aCtx);
end;//TkwDictionContainerFormPbHeader.SetValuePrim
procedure TkwDictionContainerFormPbHeader.DoDoIt(const aCtx: TtfwContext);
var l_aDictionContainerForm: TDictionContainerForm;
begin
try
l_aDictionContainerForm := TDictionContainerForm(aCtx.rEngine.PopObjAs(TDictionContainerForm));
except
on E: Exception do
begin
RunnerError('Ошибка при получении параметра aDictionContainerForm: TDictionContainerForm : ' + E.Message, aCtx);
Exit;
end;//on E: Exception
end;//try..except
aCtx.rEngine.PushObj(pbHeader(aCtx, l_aDictionContainerForm));
end;//TkwDictionContainerFormPbHeader.DoDoIt
function TkwDictionContainerFormParentZone.ParentZone(const aCtx: TtfwContext;
aDictionContainerForm: TDictionContainerForm): TvtPanel;
{* Реализация слова скрипта .TDictionContainerForm.ParentZone }
begin
Result := aDictionContainerForm.ParentZone;
end;//TkwDictionContainerFormParentZone.ParentZone
class function TkwDictionContainerFormParentZone.GetWordNameForRegister: AnsiString;
begin
Result := '.TDictionContainerForm.ParentZone';
end;//TkwDictionContainerFormParentZone.GetWordNameForRegister
function TkwDictionContainerFormParentZone.GetResultTypeInfo(const aCtx: TtfwContext): PTypeInfo;
begin
Result := TypeInfo(TvtPanel);
end;//TkwDictionContainerFormParentZone.GetResultTypeInfo
function TkwDictionContainerFormParentZone.GetAllParamsCount(const aCtx: TtfwContext): Integer;
begin
Result := 1;
end;//TkwDictionContainerFormParentZone.GetAllParamsCount
function TkwDictionContainerFormParentZone.ParamsTypes: PTypeInfoArray;
begin
Result := OpenTypesToTypes([TypeInfo(TDictionContainerForm)]);
end;//TkwDictionContainerFormParentZone.ParamsTypes
procedure TkwDictionContainerFormParentZone.SetValuePrim(const aValue: TtfwStackValue;
const aCtx: TtfwContext);
begin
RunnerError('Нельзя присваивать значение readonly свойству ParentZone', aCtx);
end;//TkwDictionContainerFormParentZone.SetValuePrim
procedure TkwDictionContainerFormParentZone.DoDoIt(const aCtx: TtfwContext);
var l_aDictionContainerForm: TDictionContainerForm;
begin
try
l_aDictionContainerForm := TDictionContainerForm(aCtx.rEngine.PopObjAs(TDictionContainerForm));
except
on E: Exception do
begin
RunnerError('Ошибка при получении параметра aDictionContainerForm: TDictionContainerForm : ' + E.Message, aCtx);
Exit;
end;//on E: Exception
end;//try..except
aCtx.rEngine.PushObj(ParentZone(aCtx, l_aDictionContainerForm));
end;//TkwDictionContainerFormParentZone.DoDoIt
initialization
Tkw_Form_DictionContainer.RegisterInEngine;
{* Регистрация Tkw_Form_DictionContainer }
Tkw_DictionContainer_Control_pnBackground.RegisterInEngine;
{* Регистрация Tkw_DictionContainer_Control_pnBackground }
Tkw_DictionContainer_Control_pnBackground_Push.RegisterInEngine;
{* Регистрация Tkw_DictionContainer_Control_pnBackground_Push }
Tkw_DictionContainer_Control_NavigatorZone.RegisterInEngine;
{* Регистрация Tkw_DictionContainer_Control_NavigatorZone }
Tkw_DictionContainer_Control_NavigatorZone_Push.RegisterInEngine;
{* Регистрация Tkw_DictionContainer_Control_NavigatorZone_Push }
Tkw_DictionContainer_Control_pnWorkArea.RegisterInEngine;
{* Регистрация Tkw_DictionContainer_Control_pnWorkArea }
Tkw_DictionContainer_Control_pnWorkArea_Push.RegisterInEngine;
{* Регистрация Tkw_DictionContainer_Control_pnWorkArea_Push }
Tkw_DictionContainer_Control_ChildZone.RegisterInEngine;
{* Регистрация Tkw_DictionContainer_Control_ChildZone }
Tkw_DictionContainer_Control_ChildZone_Push.RegisterInEngine;
{* Регистрация Tkw_DictionContainer_Control_ChildZone_Push }
Tkw_DictionContainer_Control_pnHeader.RegisterInEngine;
{* Регистрация Tkw_DictionContainer_Control_pnHeader }
Tkw_DictionContainer_Control_pnHeader_Push.RegisterInEngine;
{* Регистрация Tkw_DictionContainer_Control_pnHeader_Push }
Tkw_DictionContainer_Control_lbHeader.RegisterInEngine;
{* Регистрация Tkw_DictionContainer_Control_lbHeader }
Tkw_DictionContainer_Control_lbHeader_Push.RegisterInEngine;
{* Регистрация Tkw_DictionContainer_Control_lbHeader_Push }
Tkw_DictionContainer_Control_pbHeader.RegisterInEngine;
{* Регистрация Tkw_DictionContainer_Control_pbHeader }
Tkw_DictionContainer_Control_pbHeader_Push.RegisterInEngine;
{* Регистрация Tkw_DictionContainer_Control_pbHeader_Push }
Tkw_DictionContainer_Control_ParentZone.RegisterInEngine;
{* Регистрация Tkw_DictionContainer_Control_ParentZone }
Tkw_DictionContainer_Control_ParentZone_Push.RegisterInEngine;
{* Регистрация Tkw_DictionContainer_Control_ParentZone_Push }
TkwDictionContainerFormPnBackground.RegisterInEngine;
{* Регистрация DictionContainerForm_pnBackground }
TkwDictionContainerFormNavigatorZone.RegisterInEngine;
{* Регистрация DictionContainerForm_NavigatorZone }
TkwDictionContainerFormPnWorkArea.RegisterInEngine;
{* Регистрация DictionContainerForm_pnWorkArea }
TkwDictionContainerFormChildZone.RegisterInEngine;
{* Регистрация DictionContainerForm_ChildZone }
TkwDictionContainerFormPnHeader.RegisterInEngine;
{* Регистрация DictionContainerForm_pnHeader }
TkwDictionContainerFormLbHeader.RegisterInEngine;
{* Регистрация DictionContainerForm_lbHeader }
TkwDictionContainerFormPbHeader.RegisterInEngine;
{* Регистрация DictionContainerForm_pbHeader }
TkwDictionContainerFormParentZone.RegisterInEngine;
{* Регистрация DictionContainerForm_ParentZone }
TtfwTypeRegistrator.RegisterType(TypeInfo(TDictionContainerForm));
{* Регистрация типа TDictionContainerForm }
TtfwTypeRegistrator.RegisterType(TypeInfo(TvtProportionalPanel));
{* Регистрация типа TvtProportionalPanel }
TtfwTypeRegistrator.RegisterType(TypeInfo(TvtSizeablePanel));
{* Регистрация типа TvtSizeablePanel }
TtfwTypeRegistrator.RegisterType(TypeInfo(TvtPanel));
{* Регистрация типа TvtPanel }
TtfwTypeRegistrator.RegisterType(TypeInfo(TvtLabel));
{* Регистрация типа TvtLabel }
TtfwTypeRegistrator.RegisterType(TypeInfo(TPaintBox));
{* Регистрация типа TPaintBox }
{$IfEnd} // NOT Defined(Admin) AND NOT Defined(Monitorings) AND NOT Defined(NoScripts)
end.
|
unit MainUnit;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Buttons, Vcl.ExtCtrls,
Vcl.Samples.Spin, Vcl.Menus, Vcl.Grids, System.Generics.Collections,System.RegularExpressions,
Vcl.Imaging.jpeg, Vcl.ExtDlgs;
type
Coords = record
X: Integer;
Y: Integer;
end;
VertexList = TList<Coords>;
TMatrix = array of array of Byte;
TMainForm = class(TForm)
Visualizer: TImage;
MatrixGrid: TStringGrid;
SaveDialog: TSaveDialog;
OpenDialog: TOpenDialog;
MainMenu1: TMainMenu;
About1: TMenuItem;
File1: TMenuItem;
Open1: TMenuItem;
OrderSpinEdit: TSpinEdit;
Label2: TLabel;
Label1: TLabel;
ShowGraphButton: TButton;
Label3: TLabel;
SavePictureDialog: TSavePictureDialog;
procedure OrderSpinEditChange(Sender: TObject);
procedure SetSize(Size: Byte);
procedure FormCreate(Sender: TObject);
procedure Open1Click(Sender: TObject);
function CheckFile(): Boolean;
procedure DrawVertexes(Amount: Integer; var VertexCoords: VertexList);
procedure DrawLines(AdjMatrix: TMatrix; VertexCoords: VertexList);
procedure DrawGraph(AdjMatrix: TMatrix);
procedure ShowGraphButtonClick(Sender: TObject);
procedure GetMatrixFromGrid(var Matrix: TMatrix);
procedure DrawSpanningTree(VertexCoords: VertexList; AdjMatrix: TMatrix; Vertex: Integer);
procedure ClearScreen();
procedure InitUsed();
procedure MatrixGridSetEditText(Sender: TObject; ACol, ARow: Integer;
const Value: string);
procedure About1Click(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;
var
MainForm: TMainForm;
Used: array of Boolean;
const
DEFAULT_WIDTH = 490;
EXTENDED_WIDTH = 990;
VERTEXES_COLOR = $00B3B300;
BACKGROUND_COLOR = $001C1A13;
TREE_COLOR = $004F009D;
POINT_RAD = 10;
LINE_WIDTH = 5;
GRAPH_RAD = 150;
VERTEX_RAD = 30;
FONT_SIZE = 20;
implementation
{$R *.dfm}
procedure TMainForm.DrawVertexes(Amount: Integer;var VertexCoords: VertexList);
var
I, X, Y: Integer;
Center: Coords;
CurrPhi, Phi: Extended;
CurrCoords: Coords;
begin
VertexCoords := TList<Coords>.Create;
Phi := (2 * Pi) / Amount;
Center.X := Visualizer.Width div 2;
Center.Y := Visualizer.Height div 2;
with Visualizer.Canvas do
begin
Pen.Color := VERTEXES_COLOR;
Pen.Width := 1;
X := Center.X;
Y := Center.Y;
Font.Name := 'Segoe UI';
Font.Style := [fsBold];
Font.Color := VERTEXES_COLOR;
Font.Height := FONT_SIZE;
CurrPhi := 0;
for I := 0 to Amount - 1 do
begin
Brush.Color := VERTEXES_COLOR;
CurrPhi := CurrPhi + Phi;
Y := Round(Center.Y - GRAPH_RAD * Sin(CurrPhi));
X := Round(Center.X - GRAPH_RAD * Cos(CurrPhi));
Ellipse(X - VERTEX_RAD, Y - VERTEX_RAD, X + VERTEX_RAD, Y + VERTEX_RAD);
CurrCoords.X := X;
CurrCoords.Y := Y;
VertexCoords.Add(CurrCoords);
Brush.Color := BACKGROUND_COLOR;
if CurrPhi < Pi then
TextOut(X - 5 , Y - 64, IntToStr(I + 1))
else
TextOut(X - 5, Y + 32, IntToStr(I + 1));
end;
end;
end;
procedure TMainForm.DrawLines(AdjMatrix: TMatrix; VertexCoords: VertexList);
var
I, J: Byte;
InciedenceList: TList;
Line: String;
begin
for I := 0 to High(AdjMatrix) do
begin
for J := 0 to High(AdjMatrix) do
begin
if AdjMatrix[I][J] = 1 then
begin
with Visualizer.Canvas do
begin
Pen.Color := VERTEXES_COLOR;
Pen.Width := LINE_WIDTH;
MoveTo(VertexCoords.Items[I].X, VertexCoords.Items[I].Y);
LineTo(VertexCoords.Items[J].X, VertexCoords.Items[J].Y);
end;
end;
end;
end;
end;
procedure TMainForm.DrawGraph(AdjMatrix: TMatrix);
var
VertexCoords: VertexList;
begin
VertexCoords := TList<Coords>.Create;
DrawVertexes(Length(AdjMatrix), VertexCoords);
DrawLines(AdjMatrix, VertexCoords);
DrawSpanningTree(VertexCoords, AdjMatrix, 0);
end;
procedure TMainForm.DrawSpanningTree(VertexCoords: VertexList; AdjMatrix: TMatrix; Vertex: Integer);
var
I: integer;
begin
Used[Vertex] := true;
for i := 0 to High(AdjMatrix) do
if (AdjMatrix[Vertex, I] = 1) and not Used[I] then
begin
with Visualizer.Canvas do
begin
Pen.Color := TREE_COLOR;
Pen.Width := LINE_WIDTH;
Brush.Color := TREE_COLOR;
Ellipse(VertexCoords.Items[Vertex].X - POINT_RAD, VertexCoords.Items[Vertex].Y - POINT_RAD, VertexCoords.Items[Vertex].X + POINT_RAD, VertexCoords.Items[Vertex].Y + POINT_RAD);
Ellipse(VertexCoords.Items[I].X - POINT_RAD, VertexCoords.Items[I].Y - POINT_RAD, VertexCoords.Items[I].X + POINT_RAD, VertexCoords.Items[I].Y + POINT_RAD);
MoveTo(VertexCoords.Items[Vertex].X, VertexCoords.Items[Vertex].Y);
LineTo(VertexCoords.Items[I].X, VertexCoords.Items[I].Y);
end;
DrawSpanningTree(VertexCoords, AdjMatrix, I);
end;
end;
procedure TMainForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
CanClose := MessageDlg('Are you sure you want to leave the program?', mtConfirmation, mbYesNo, 0) = mrYes;
end;
procedure TMainForm.FormCreate(Sender: TObject);
begin
OrderSpinEdit.Text := IntToStr(10);
ClearScreen();
MainForm.Width := DEFAULT_WIDTH;
end;
procedure TMainForm.ClearScreen();
begin
with Visualizer.Canvas do
begin
Brush.Color := BACKGROUND_COLOR;
Rectangle(0,0,Visualizer.Width,Visualizer.Height);
end;
end;
procedure TMainForm.Open1Click(Sender: TObject);
var
I, J: Integer;
InputFile: TextFile;
IsCorrect: Boolean;
Buff: Integer;
begin
IsCorrect := CheckFile();
if IsCorrect then
begin
MainForm.Width := DEFAULT_WIDTH;
AssignFile(InputFile,OpenDialog.FileName);
Reset(InputFile);
Readln(InputFile);
for I := 1 to MatrixGrid.ColCount - 1 do
begin
for J := 1 to MatrixGrid.ColCount - 1 do
begin
Read(InputFile, Buff);
MatrixGrid.Cells[J, I] := IntToStr(Buff);
end;
Readln(InputFile);
end;
CloseFile(InputFile);
end;
end;
procedure TMainForm.About1Click(Sender: TObject);
begin
MessageDlg('The graph is given by the adjacency matrix. The program finds a spanning tree in a graph using the depth-first search method.', mtInformation, [mbOK], 0);
end;
function TMainForm.CheckFile(): Boolean;
var
Order: Integer;
InputFile: TextFile;
IsCorrect: Boolean;
Buff: Integer;
CountOfElements, CountOfLines: Integer;
begin
IsCorrect := False;
if OpenDialog.Execute then
begin
AssignFile(InputFile, OpenDialog.FileName);
Reset(InputFile);
CountOfElements := 0;
CountOfLines := 0;
IsCorrect := True;
if not SeekEOF(InputFile) then
begin
try
Readln(InputFile, Order);
except
IsCorrect := False;
end;
if IsCorrect and ((Order > 10) or (Order < 2)) then
begin
IsCorrect := False;
MessageDlg('Incorrect order in your file!', mtError, [mbOK], 0);
end;
if IsCorrect then
begin
try
while not SeekEOF(InputFile) and IsCorrect do
begin
Read(InputFile, Buff);
IsCorrect := (Buff = 0) or (Buff = 1);
CountOfElements := CountOfElements + 1;
if SeekEOLN(InputFile) then
CountOfLines := CountOfLines + 1;
end;
except
IsCorrect := False;
end;
end;
if IsCorrect and (CountOfElements = Order * Order) and (CountOfLines = Order) then
begin
OrderSpinEdit.Text := IntToStr(Order);
end
else
begin
IsCorrect := False;
MessageDlg('Incorrect data in the file or the matrix is entered incorrectly!', mtError, [mbOK], 0);
end;
end
else
MessageDlg('File is empty', mtError, [mbOK], 0);
CloseFile(InputFile);
end;
CheckFile := IsCorrect;
end;
procedure TMainForm.OrderSpinEditChange(Sender: TObject);
begin
SetSize(StrToInt(OrderSpinEdit.Text) + 1);
MainForm.Width := DEFAULT_WIDTH;
end;
procedure TMainForm.SetSize(Size: Byte);
var
I: Byte;
begin
MatrixGrid.ColCount := Size;
MatrixGrid.RowCount := Size;
MatrixGrid.DefaultColWidth := MatrixGrid.Width div (StrToInt(OrderSpinEdit.Text) + 1) - 2;
MatrixGrid.DefaultRowHeight := MatrixGrid.Height div (StrToInt(OrderSpinEdit.Text) + 1) - 2;
MatrixGrid.Font.Height := 200 div StrToInt(OrderSpinEdit.Text);
for I := 0 to Size - 1 do
begin
MatrixGrid.Rows[I].Clear;
MatrixGrid.Cols[I].Clear;
end;
for I := 0 to Size - 1 do
begin
MatrixGrid.Cells[0, I + 1] := IntToStr(I + 1);
end;
for I := 0 to Size - 1 do
begin
MatrixGrid.Cells[I + 1, 0] := IntToStr(I + 1);
end;
end;
procedure TMainForm.ShowGraphButtonClick(Sender: TObject);
var
Matrix: TMatrix;
Order: Byte;
IsCorrect: Boolean;
InciedenceList: TList;
begin
IsCorrect := True;
Order := StrToInt(OrderSpinEdit.Text);
SetLength(Matrix, Order, Order);
SetLength(Used, Order);
try
GetMatrixFromGrid(Matrix);
except
MessageDlg('Enter all values into the matrix!', mtError, [mbOK], 0);
IsCorrect := False;
end;
if isCorrect then
begin
MainForm.Width := EXTENDED_WIDTH;
ClearScreen;
InitUsed;
DrawGraph(Matrix);
end;
end;
procedure TMainForm.InitUsed();
var
I: Integer;
begin
for I := 0 to High(Used) do
Used[I] := False;
end;
procedure TMainForm.MatrixGridSetEditText(Sender: TObject; ACol, ARow: Integer;
const Value: string);
begin
if not TRegEx.IsMatch(Value, '^([01]{1})$') then
MatrixGrid.Cells[ACol, ARow] := TRegEx.Match(Value, '^([01]{1})').Value;
MainForm.Width := DEFAULT_WIDTH;
end;
procedure TMainForm.GetMatrixFromGrid(var Matrix: TMatrix);
var
I, J: Byte;
begin
for I := 0 to High(Matrix) do
for J := 0 to High(Matrix) do
Matrix[I][J] := StrToInt(MatrixGrid.Cells[J + 1 , I + 1]);
end;
end.
|
unit FBaseDosForm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,
UMisc, Gr32,
GameControl;
type
{-------------------------------------------------------------------------------
abstract black, fullscreen, ancestor form
-------------------------------------------------------------------------------}
TBaseDosForm = class(TForm)
private
fGameParams: TDosGameParams;
protected
procedure CreateParams(var Params: TCreateParams); override;
procedure BuildScreen; virtual;
procedure PrepareGameParams(Params: TDosGameParams); virtual; // always call inherited
property GameParams: TDosGameParams read fGameParams;
public
constructor Create(aOwner: TComponent); override;
function ShowScreen(Params: TDosGameParams): Integer; virtual;
end;
implementation
{$R *.dfm}
{ TBaseDosForm }
procedure TBaseDosForm.BuildScreen;
begin
//
end;
constructor TBaseDosForm.Create(aOwner: TComponent);
begin
inherited Create(aOwner);
Caption := 'Lemmix';
Color := clBlack;
BorderStyle := {bsSizeable} bsNone;
BorderIcons := [{biSystemMenu, biMinimize, biMaximize}];
WindowState := {wsNormal} wsMaximized;
Cursor := crNone;
end;
procedure TBaseDosForm.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
with Params.WindowClass do
begin
Style := Style or CS_OWNDC; // maybe faster screen output
end;
end;
procedure TBaseDosForm.PrepareGameParams(Params: TDosGameParams);
begin
fGameParams := Params;
end;
function TBaseDosForm.ShowScreen(Params: TDosGameParams): Integer;
begin
PrepareGameParams(Params);
BuildScreen;
Result := ShowModal;
end;
end.
|
{ *********************************************************************************** }
{ * 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 ClpSecP256R1FieldElement;
{$I ..\..\..\..\Include\CryptoLib.inc}
interface
uses
ClpNat256,
ClpMod,
ClpSecP256R1Curve,
ClpECFieldElement,
ClpIECFieldElement,
ClpSecP256R1Field,
ClpISecP256R1FieldElement,
ClpBigInteger,
ClpArrayUtils,
ClpCryptoLibTypes;
resourcestring
SInvalidValueForSecP256R1FieldElement =
'Value Invalid for SecP256R1FieldElement "%s"';
type
TSecP256R1FieldElement = class(TAbstractFpFieldElement,
ISecP256R1FieldElement)
strict private
function Equals(const other: ISecP256R1FieldElement): Boolean;
reintroduce; overload;
class function GetQ: TBigInteger; static; inline;
strict protected
var
Fx: TCryptoLibUInt32Array;
function GetFieldName: string; override;
function GetFieldSize: Int32; override;
function GetIsOne: Boolean; override;
function GetIsZero: Boolean; override;
function GetX: TCryptoLibUInt32Array; inline;
property X: TCryptoLibUInt32Array read GetX;
public
constructor Create(); overload;
constructor Create(const X: TBigInteger); overload;
constructor Create(const X: TCryptoLibUInt32Array); overload;
function TestBitZero: Boolean; override;
function ToBigInteger(): TBigInteger; override;
function Add(const b: IECFieldElement): IECFieldElement; override;
function AddOne(): IECFieldElement; override;
function Subtract(const b: IECFieldElement): IECFieldElement; override;
function Multiply(const b: IECFieldElement): IECFieldElement; override;
function Divide(const b: IECFieldElement): IECFieldElement; override;
function Negate(): IECFieldElement; override;
function Square(): IECFieldElement; override;
function Invert(): IECFieldElement; override;
/// <summary>
/// return a sqrt root - the routine verifies that the calculation
/// returns the right value - if <br />none exists it returns null.
/// </summary>
function Sqrt(): IECFieldElement; override;
function Equals(const other: IECFieldElement): Boolean; overload; override;
function GetHashCode(): {$IFDEF DELPHI}Int32; {$ELSE}PtrInt;
{$ENDIF DELPHI}override;
property IsZero: Boolean read GetIsZero;
property IsOne: Boolean read GetIsOne;
property FieldName: string read GetFieldName;
property FieldSize: Int32 read GetFieldSize;
class property Q: TBigInteger read GetQ;
end;
implementation
{ TSecP256R1FieldElement }
class function TSecP256R1FieldElement.GetQ: TBigInteger;
begin
result := TSecP256R1Curve.SecP256R1Curve_Q;
end;
function TSecP256R1FieldElement.GetX: TCryptoLibUInt32Array;
begin
result := Fx;
end;
constructor TSecP256R1FieldElement.Create;
begin
Inherited Create();
Fx := TNat256.Create();
end;
constructor TSecP256R1FieldElement.Create(const X: TBigInteger);
begin
if ((not(X.IsInitialized)) or (X.SignValue < 0) or (X.CompareTo(Q) >= 0)) then
begin
raise EArgumentCryptoLibException.CreateResFmt
(@SInvalidValueForSecP256R1FieldElement, ['x']);
end;
Inherited Create();
Fx := TSecP256R1Field.FromBigInteger(X);
end;
constructor TSecP256R1FieldElement.Create(const X: TCryptoLibUInt32Array);
begin
Inherited Create();
Fx := X;
end;
function TSecP256R1FieldElement.GetFieldName: string;
begin
result := 'SecP256R1Field';
end;
function TSecP256R1FieldElement.GetFieldSize: Int32;
begin
result := Q.BitLength;
end;
function TSecP256R1FieldElement.GetHashCode: {$IFDEF DELPHI}Int32; {$ELSE}PtrInt;
{$ENDIF DELPHI}
begin
result := Q.GetHashCode() xor TArrayUtils.GetArrayHashCode(Fx, 0, 8);
end;
function TSecP256R1FieldElement.GetIsOne: Boolean;
begin
result := TNat256.IsOne(Fx);
end;
function TSecP256R1FieldElement.GetIsZero: Boolean;
begin
result := TNat256.IsZero(Fx);
end;
function TSecP256R1FieldElement.Invert: IECFieldElement;
var
z: TCryptoLibUInt32Array;
begin
z := TNat256.Create();
TMod.Invert(TSecP256R1Field.P, Fx, z);
result := TSecP256R1FieldElement.Create(z);
end;
function TSecP256R1FieldElement.Multiply(const b: IECFieldElement)
: IECFieldElement;
var
z: TCryptoLibUInt32Array;
begin
z := TNat256.Create();
TSecP256R1Field.Multiply(Fx, (b as ISecP256R1FieldElement).X, z);
result := TSecP256R1FieldElement.Create(z);
end;
function TSecP256R1FieldElement.Negate: IECFieldElement;
var
z: TCryptoLibUInt32Array;
begin
z := TNat256.Create();
TSecP256R1Field.Negate(Fx, z);
result := TSecP256R1FieldElement.Create(z);
end;
function TSecP256R1FieldElement.Sqrt: IECFieldElement;
var
x1, t1, t2: TCryptoLibUInt32Array;
begin
// Raise this element to the exponent 2^254 - 2^222 + 2^190 + 2^94
x1 := Fx;
if ((TNat256.IsZero(x1)) or (TNat256.IsOne(x1))) then
begin
result := Self as IECFieldElement;
Exit;
end;
t1 := TNat256.Create();
t2 := TNat256.Create();
TSecP256R1Field.Square(x1, t1);
TSecP256R1Field.Multiply(t1, x1, t1);
TSecP256R1Field.SquareN(t1, 2, t2);
TSecP256R1Field.Multiply(t2, t1, t2);
TSecP256R1Field.SquareN(t2, 4, t1);
TSecP256R1Field.Multiply(t1, t2, t1);
TSecP256R1Field.SquareN(t1, 8, t2);
TSecP256R1Field.Multiply(t2, t1, t2);
TSecP256R1Field.SquareN(t2, 16, t1);
TSecP256R1Field.Multiply(t1, t2, t1);
TSecP256R1Field.SquareN(t1, 32, t1);
TSecP256R1Field.Multiply(t1, x1, t1);
TSecP256R1Field.SquareN(t1, 96, t1);
TSecP256R1Field.Multiply(t1, x1, t1);
TSecP256R1Field.SquareN(t1, 94, t1);
TSecP256R1Field.Multiply(t1, t1, t2);
if TNat256.Eq(x1, t2) then
begin
result := TSecP256R1FieldElement.Create(t1);
end
else
begin
result := Nil;
end;
end;
function TSecP256R1FieldElement.Square: IECFieldElement;
var
z: TCryptoLibUInt32Array;
begin
z := TNat256.Create();
TSecP256R1Field.Square(Fx, z);
result := TSecP256R1FieldElement.Create(z);
end;
function TSecP256R1FieldElement.Subtract(const b: IECFieldElement)
: IECFieldElement;
var
z: TCryptoLibUInt32Array;
begin
z := TNat256.Create();
TSecP256R1Field.Subtract(Fx, (b as ISecP256R1FieldElement).X, z);
result := TSecP256R1FieldElement.Create(z);
end;
function TSecP256R1FieldElement.TestBitZero: Boolean;
begin
result := TNat256.GetBit(Fx, 0) = 1;
end;
function TSecP256R1FieldElement.ToBigInteger: TBigInteger;
begin
result := TNat256.ToBigInteger(Fx);
end;
function TSecP256R1FieldElement.Add(const b: IECFieldElement): IECFieldElement;
var
z: TCryptoLibUInt32Array;
begin
z := TNat256.Create();
TSecP256R1Field.Add(Fx, (b as ISecP256R1FieldElement).X, z);
result := TSecP256R1FieldElement.Create(z);
end;
function TSecP256R1FieldElement.AddOne: IECFieldElement;
var
z: TCryptoLibUInt32Array;
begin
z := TNat256.Create();
TSecP256R1Field.AddOne(Fx, z);
result := TSecP256R1FieldElement.Create(z);
end;
function TSecP256R1FieldElement.Divide(const b: IECFieldElement)
: IECFieldElement;
var
z: TCryptoLibUInt32Array;
begin
z := TNat256.Create();
TMod.Invert(TSecP256R1Field.P, (b as ISecP256R1FieldElement).X, z);
TSecP256R1Field.Multiply(z, Fx, z);
result := TSecP256R1FieldElement.Create(z);
end;
function TSecP256R1FieldElement.Equals(const other
: ISecP256R1FieldElement): Boolean;
begin
if ((Self as ISecP256R1FieldElement) = other) then
begin
result := true;
Exit;
end;
if (other = Nil) then
begin
result := false;
Exit;
end;
result := TNat256.Eq(Fx, other.X);
end;
function TSecP256R1FieldElement.Equals(const other: IECFieldElement): Boolean;
begin
result := Equals(other as ISecP256R1FieldElement);
end;
end.
|
unit UserData;
interface
uses
Data,
Collections;
type
TUserFunction = class(TFunction)
protected
FCode : Ref<TList>;
FArgs : Ref<TList>;
public
constructor Create(code : Ref<TList>; parentContext : TContext);
destructor Destroy(); override;
property context : TContext read FContext;
property Args : Ref<TList> read FArgs;
property code : Ref<TList> read FCode;
function Copy() : TData; override;
function ToString : string; override;
end;
/// <summary>
/// An abstract object implementation for DLISP.
/// </summary>
TLispObject = class(TAbstractObject)
end;
implementation
{ TFunction }
function TUserFunction.Copy : TData;
var
fn : TUserFunction;
begin
fn := TUserFunction.Create(FCode, FContext.Parent);
Result := fn;
end;
constructor TUserFunction.Create(code : Ref<TList>; parentContext : TContext);
var
Args, list : TList;
I : Integer;
begin
FCode := code;
FContext := TContext.Create(parentContext);
// (fn [p1 p2 & ps] (...) (...))
Assert((code[0]() is TSymbol));
Assert(code[1]() is TList);
Assert(code().Size > 2);
// First argument is a list of symbols for arguments
// FArgs := TRef<TList>.Create(code[1]() as TList);
list := code[1]() as TList;
Args := TList.Create();
for I := 1 to list.Size - 1 do
begin
Args.Add(list[I]);
end;
FArgs := TRef<TList>.Create(Args);
end;
destructor TUserFunction.Destroy;
begin
FContext.Free;
inherited;
end;
function TUserFunction.ToString : string;
begin
Result := FCode.ToString;
end;
end.
|
{***********************************************************************************************************************
*
* TERRA Game Engine
* ==========================================
*
* Copyright (C) 2003, 2014 by SÚrgio Flores (relfos@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.
*
**********************************************************************************************************************
* TERRA_DebugDraw
* Implements debug drawing objects
***********************************************************************************************************************
}
Unit TERRA_DebugDraw;
{$I terra.inc}
Interface
Uses TERRA_String, TERRA_GraphicsManager, TERRA_Renderer, TERRA_Color, TERRA_BoundingBox, TERRA_Frustum,
TERRA_Ray, TERRA_Matrix4x4, TERRA_Vector3D, TERRA_Vector2D, TERRA_Utils, TERRA_SpriteManager,
TERRA_MeshSkeleton, TERRA_MeshAnimationNodes, TERRA_Collision2D, TERRA_Splines, TERRA_ClipRect, TERRA_Viewport;
// 2d drawing
Procedure DrawPoint2D(View:Viewport; Const P:Vector2D; FillColor:Color; Radius:Single = 2.0);
Procedure DrawLine2D(View:Viewport; Const A,B:Vector2D; LineColor:Color; LineWidth:Single = 1.0);
Procedure DrawCircle(View:Viewport; Const P:Vector2D; Radius:Single; LineColor:Color; LineWidth:Single = 1.0);
Procedure DrawRectangle(View:Viewport; Const A,B:Vector2D; LineColor:Color; LineWidth:Single = 1.0);
Procedure DrawFilledRect(View:Viewport; Const A,B:Vector2D; FillColor:Color);
Procedure DrawPolygon2D(View:Viewport; Poly:Polygon2D; LineColor:Color; LineWidth:Single = 1.0);
// 3d drawing
Procedure DrawPoint3D(View:Viewport; Const P:Vector3D; FillColor:Color; Radius:Single = 2.0);
Procedure DrawLine3D(View:Viewport; Const A,B:Vector3D; LineColor:Color; LineWidth:Single = 1.0);
Procedure DrawRay(View:Viewport; Const R:Ray; LineColor:Color; LineWidth:Single = 1.0; Length:Single =0);
Procedure DrawBoundingBox(View:Viewport; Const MyBox:BoundingBox; LineColor:Color; LineWidth:Single = 1.0);
Procedure DrawSpline(View:Viewport; S:Spline; LineColor:Color; LineWidth:Single = 1.0);
Procedure DrawFrustum(View:Viewport; F:Frustum; LineColor:Color; LineWidth:Single = 1.0);
Procedure DrawBone(View:Viewport; Bone:MeshBone; State:AnimationState; Const Transform:Matrix4x4; LineColor:Color; LineWidth:Single);
Procedure DrawSkeleton(View:Viewport; Skeleton:MeshSkeleton; State:AnimationState; Const Transform:Matrix4x4; LineColor:Color; LineWidth:Single);
(*Procedure DrawFrustum(Const MyFrustum:Frustum; Color:TERRA_Color.Color);
Procedure DrawPlane(Const Position, Normal:Vector3D; Scale:Single; Color:TERRA_Color.Color);
Procedure DrawPointCloud(Cloud:PointCloud2D; MyColor:Color; Layer:Single);
*)
Implementation
Uses TERRA_OS, TERRA_Math, TERRA_Texture;
Const
Layer = 20;
Function ConvertTo2D(View:Viewport; P:Vector3D):Vector2D;
Begin
P := View.ProjectPoint(P);
Result := VectorCreate2D(P.X, P.Y);
End;
Procedure DrawPoint2D(View:Viewport; Const P:Vector2D; FillColor:Color; Radius:Single = 2.0);
Var
A,B:Vector2D;
Begin
Radius := Radius * 0.5;
A.X := P.X - Radius;
A.Y := P.Y - Radius;
B.X := P.X + Radius;
B.Y := P.Y + Radius;
DrawFilledRect(View, A, B, FillColor);
End;
Procedure DrawLine2D(View:Viewport; Const A,B:Vector2D; LineColor:Color; LineWidth:Single);
Var
Tex:Texture;
DX, DY, Angle, Len:Single;
S:QuadSprite;
Begin
Tex := TextureManager.Instance.WhiteTexture;
If Tex = Nil Then
Exit;
DX := B.X - A.X;
DY := A.Y - B.Y;
Angle := Atan2(DY, DX);
S := SpriteManager.Instance.DrawSprite(Trunc(A.X), Trunc(A.Y), Layer, Tex);
S.SetColor(LineColor);
S.Rect.Width := Trunc(A.Distance(B));
S.Rect.Height := Trunc(LineWidth);
S.SetScaleAndRotation(1.0, Angle);
End;
Procedure DrawFilledRect(View:Viewport; Const A,B:Vector2D; FillColor:Color);
Var
I:Integer;
Tex:Texture;
MinX, MinY, MaxX, MaxY:Single;
S:QuadSprite;
Begin
Tex := TextureManager.Instance.WhiteTexture;
If Tex = Nil Then
Exit;
Tex.WrapMode := wrapAll;
MinX := Trunc(FloatMin(A.X, B.X));
MinY := Trunc(FloatMin(A.Y, B.Y));
MaxX := Trunc(FloatMax(A.X, B.X));
MaxY := Trunc(FloatMax(A.Y, B.Y));
S := SpriteManager.Instance.DrawSprite(MinX, MinY, Layer, Tex);
S.SetColor(FillColor);
S.Rect.Width := Trunc(MaxX-MinX);
S.Rect.Height := Trunc(MaxY-MinY);
// S.ClipRect := Clip;
End;
Procedure DrawRectangle(View:Viewport; Const A,B:Vector2D; LineColor:Color; LineWidth:Single = 1.0);
Var
I:Integer;
Tex:Texture;
MinX, MinY, MaxX, MaxY:Single;
S:QuadSprite;
Begin
Tex := TextureManager.Instance.WhiteTexture;
If Tex = Nil Then
Exit;
Tex.WrapMode := wrapAll;
MinX := Trunc(FloatMin(A.X, B.X));
MinY := Trunc(FloatMin(A.Y, B.Y));
MaxX := Trunc(FloatMax(A.X, B.X));
MaxY := Trunc(FloatMax(A.Y, B.Y));
S := SpriteManager.Instance.DrawSprite(MinX, MinY, Layer, Tex);
S.SetColor(LineColor);
S.Rect.Width := Trunc(MaxX-MinX);
S.Rect.Height := Trunc(LineWidth);
// S.ClipRect := Clip;
S := SpriteManager.Instance.DrawSprite(MinX, MinY, Layer, Tex);
S.SetColor(LineColor);
S.Rect.Width := Trunc(LineWidth);
S.Rect.Height := Trunc(MaxY-MinY);
// S.ClipRect := Clip;
S := SpriteManager.Instance.DrawSprite(MinX, MaxY, Layer, Tex);
S.SetColor(LineColor);
S.Rect.Width := Trunc(MaxX-MinX);
S.Rect.Height := Trunc(LineWidth);
// S.ClipRect := Clip;
S := SpriteManager.Instance.DrawSprite(MaxX, MinY, Layer, Tex);
S.SetColor(LineColor);
S.Rect.Width := Trunc(LineWidth);
S.Rect.Height := Trunc(MaxY-MinY);
// S.ClipRect := Clip;
End;
Procedure DrawCircle(View:Viewport; Const P:Vector2D; Radius:Single; LineColor:Color; LineWidth:Single = 1.0);
Const
SubDivs = 32;
Var
I:Integer;
A, B:Vector2D;
DX, DY, Angle:Single;
Begin
DX := 1.0;
DY := 0.0;
For I:=1 To SubDivs Do
Begin
Angle := (I/SubDivs) * PI * 2;
A := VectorCreate2D(P.X + DX * Radius, P.Y + DY * Radius);
DX := Cos(Angle);
DY := Sin(Angle);
B := VectorCreate2D(P.X + DX * Radius, P.Y + DY * Radius);
DrawLine2D(View, A, B, LineColor, LineWidth);
End;
End;
Procedure DrawPolygon2D(View:Viewport; Poly:Polygon2D; LineColor:Color; LineWidth:Single);
Var
I:Integer;
Begin
If (Poly.VertexCount<=0) Then
Exit;
For I:=0 To Pred(Poly.VertexCount) Do
DrawLine2D(View, Poly.Vertices[I], Poly.Vertices[Succ(I) Mod Poly.VertexCount], LineColor, LineWidth);
End;
Procedure DrawPoint3D(View:Viewport; Const P:Vector3D; FillColor:Color; Radius:Single);
Begin
DrawPoint2D(View, ConvertTo2D(View, P), FillColor, Radius);
End;
Procedure DrawLine3D(View:Viewport; Const A,B:Vector3D; LineColor:Color; LineWidth:Single);
Begin
DrawLine2D(View, ConvertTo2D(View, A), ConvertTo2D(View, B), LineColor, LineWidth);
End;
Procedure DrawRay(View:Viewport; Const R:Ray; LineColor:Color; LineWidth:Single = 1.0; Length:Single =0);
Var
P:Vector3D;
Begin
If Length<=0 Then
Length := 9999;
P := VectorAdd(R.Origin, VectorScale(R.Direction, Length));
DrawLine3D(View, R.Origin, P, LineColor, LineWidth);
End;
Procedure DrawBoundingBox(View:Viewport; Const MyBox:BoundingBox; LineColor:Color; LineWidth:Single);
Var
Min, Max:Vector3D;
Points:Array[0..7] Of Vector3D;
Begin
Min := MyBox.StartVertex;
Max := MyBox.EndVertex;
Points[0] := VectorCreate(Min.X, Min.Y, Min.Z);
Points[1] := VectorCreate(Max.X, Min.Y, Min.Z);
Points[2] := VectorCreate(Min.X, Min.Y, Max.Z);
Points[3] := VectorCreate(Max.X, Min.Y, Max.Z);
Points[4] := VectorCreate(Min.X, Max.Y, Min.Z);
Points[5] := VectorCreate(Max.X, Max.Y, Min.Z);
Points[6] := VectorCreate(Min.X, Max.Y, Max.Z);
Points[7] := VectorCreate(Max.X, Max.Y, Max.Z);
DrawLine3D(View, Points[0], Points[1], LineColor, LineWidth);
DrawLine3D(View, Points[0], Points[2], LineColor, LineWidth);
DrawLine3D(View, Points[1], Points[3], LineColor, LineWidth);
DrawLine3D(View, Points[2], Points[3], LineColor, LineWidth);
DrawLine3D(View, Points[4], Points[5], LineColor, LineWidth);
DrawLine3D(View, Points[4], Points[6], LineColor, LineWidth);
DrawLine3D(View, Points[5], Points[7], LineColor, LineWidth);
DrawLine3D(View, Points[6], Points[7], LineColor, LineWidth);
DrawLine3D(View, Points[0], Points[4], LineColor, LineWidth);
DrawLine3D(View, Points[1], Points[5], LineColor, LineWidth);
DrawLine3D(View, Points[2], Points[6], LineColor, LineWidth);
DrawLine3D(View, Points[3], Points[7], LineColor, LineWidth);
End;
Procedure DrawSpline(View:Viewport; S:Spline; LineColor:Color; LineWidth:Single = 1.0);
Const
SubDivs = 50;
Var
I:Integer;
A, B:Vector3D;
Begin
If (S.PointCount<=1) Then
Exit;
S.Update();
For I:=1 To SubDivs Do
Begin
A := S.GetPosition(((I-1)/SubDivs));
B := S.GetPosition((I/SubDivs));
DrawLine3D(View, A, B, LineColor, LineWidth);
End;
End;
Procedure DrawBone(View:Viewport; Bone:MeshBone; State:AnimationState; Const Transform:Matrix4x4; LineColor:Color; LineWidth:Single);
Var
A,B:Vector3D;
Begin
If (Bone = Nil) Or (Bone.Parent = Nil) Then
Exit;
A := State.Transforms[Bone.Index+1].Transform(VectorZero);
B := State.Transforms[Bone.Parent.Index+1].Transform(VectorZero);
DrawLine3D(View, A, B, LineColor, LineWidth);
End;
Procedure DrawSkeleton(View:Viewport; Skeleton:MeshSkeleton; State:AnimationState; Const Transform:Matrix4x4; LineColor:Color; LineWidth:Single);
Var
I:Integer;
Begin
If (Skeleton = Nil) Then
Exit;
For I:=0 To Pred(Skeleton.BoneCount) Do
DrawBone(View, Skeleton.GetBone(I), State, Transform, LineColor, LineWidth);
End;
Procedure DrawFrustum(View:Viewport; F:Frustum; LineColor:Color; LineWidth:Single);
Var
V:BoundingBoxVertices;
P:Array[0..3] Of Vector3D;
I:Integer;
Begin
V := F.Vertices;
P[0] := VectorCreate(V[2].X, V[2].Y, V[2].z);
P[1] := VectorCreate(V[1].X, V[1].Y, V[1].z);
P[2] := VectorCreate(V[3].X, V[3].Y, V[3].z);
P[3] := VectorCreate(V[4].X, V[4].Y, V[4].z);
For I:=1 To 3 Do
DrawLine3D(View, P[I-1], P[I], LineColor, LineWidth);
P[0] := VectorCreate(V[6].X, V[6].Y, V[6].z);
P[1] := VectorCreate(V[5].X, V[5].Y, V[5].z);
P[2] := VectorCreate(V[7].X, V[7].Y, V[7].z);
P[3] := VectorCreate(V[8].X, V[8].Y, V[8].z);
For I:=1 To 3 Do
DrawLine3D(View, P[I-1], P[I], LineColor, LineWidth);
P[0] := VectorCreate(V[1].X, V[1].Y, V[1].z);
P[1] := VectorCreate(V[3].X, V[3].Y, V[3].z);
P[2] := VectorCreate(V[7].X, V[7].Y, V[7].z);
P[3] := VectorCreate(V[5].X, V[5].Y, V[5].z);
For I:=1 To 3 Do
DrawLine3D(View, P[I-1], P[I], LineColor, LineWidth);
P[0] := VectorCreate(V[2].X, V[2].Y, V[2].z);
P[1] := VectorCreate(V[4].X, V[4].Y, V[4].z);
P[2] := VectorCreate(V[8].X, V[8].Y, V[8].z);
P[3] := VectorCreate(V[6].X, V[6].Y, V[6].z);
For I:=1 To 3 Do
DrawLine3D(View, P[I-1], P[I], LineColor, LineWidth);
End;
(*
Procedure DrawPointCloud(Cloud:PointCloud2D; MyColor:Color; Layer:Single);
Var
I:Integer;
Begin
glPointSize(3.0);
glBegin(GL_POINTS);
glColor4ub(MyColor.R, MyColor.G, MyColor.B, MyColor.A);
For I:=0 To Pred(Cloud.PointCount) Do
Begin
glVertex3f(Cloud.Points[I].X, Cloud.Points[I].Y, -Layer);
End;
glEnd();
End;
Procedure DrawPlane(Const Position, Normal:Vector3D; Scale:Single; Color:TERRA_Color.Color);
Var
U,V:Vector3D;
A,B,C,D:Vector3D;
Begin
If (Abs(Normal.Y)>Abs(Normal.X)) And (Abs(Normal.Y)>Abs(Normal.Z)) Then
Begin
U := VectorCreate(Normal.X, Normal.Z, Normal.Y);
End Else
Begin
U := VectorCreate(Normal.Z, Normal.Y, Normal.X);
End;
V := VectorCross(Normal, U);
A := VectorAdd(VectorScale(U, Scale), VectorScale(V, Scale));
B := VectorAdd(VectorScale(U, -Scale), VectorScale(V, Scale));
C := VectorAdd(VectorScale(U, -Scale), VectorScale(V, -Scale));
D := VectorAdd(VectorScale(U, Scale), VectorScale(V, -Scale));
GraphicsManager.Instance.EnableColorShader(Color, Matrix4x4Translation(Position));
glBegin(GL_QUADS);
glVertex3f(A.x, A.y, A.z);
glVertex3f(B.x, B.y, B.z);
glVertex3f(C.x, C.y, C.z);
glVertex3f(D.x, D.y, D.z);
glEnd();
End;
*)
End.
|
unit ExtractorError;
interface
// TODO: Richtige Ordnerliste mit Icons anzeigen?
uses
Forms, StdCtrls, ExtCtrls, Controls, Graphics, Classes, Dialogs,
ZipMstr19, SysUtils;
type
TErrorForm = class(TForm)
ErrorList: TListBox;
ErrorImg: TImage;
ErrorLabel: TLabel;
OKBtn: TButton;
SaveBtn: TButton;
SaveDialog: TSaveDialog;
procedure FormResize(Sender: TObject);
procedure SaveBtnClick(Sender: TObject);
public
function ErrorsAvailable: boolean;
procedure NewError(Filename: string; SkipType: TZMSkipTypes);
end;
var
ErrorForm: TErrorForm;
implementation
{$R *.dfm}
function SkipTypeToStr(SkipType: TZMSkipTypes): string;
begin
case SkipType of
stOnFreshen: result := 'stOnFreshen';
stNoOverwrite: result := 'stNoOverwrite';
stFileExists: result := 'stFileExists';
stBadPassword: result := 'stBadPassword';
stBadName: result := 'stBadName';
stCompressionUnknown: result := 'stCompressionUnknown';
stUnknownZipHost: result := 'stUnknownZipHost';
stZipFileFormatWrong: result := 'stZipFileFormatWrong';
stGeneralExtractError: result := 'stGeneralExtractError';
stUser: result := 'stUser';
stCannotDo: result := 'stCannotDo';
stNotFound: result := 'stNotFound';
stNoShare: result := 'stNoShare';
stNoAccess: result := 'stNoAccess';
stNoOpen: result := 'stNoOpen';
stDupName: result := 'stDupName';
stReadError: result := 'stReadError';
stSizeChange: result := 'stSizeChange';
end;
end;
function TErrorForm.ErrorsAvailable: boolean;
begin
result := ErrorList.Items.Count > 0;
end;
procedure TErrorForm.FormResize(Sender: TObject);
begin
ErrorList.Width := ClientWidth - ErrorList.Left - ErrorImg.Left;
ErrorList.Height := ClientHeight - ErrorList.Top - (2 * ErrorImg.Left + OkBtn.Height);
OkBtn.Top := ErrorList.Top + ErrorList.Height + ErrorImg.Left;
OkBtn.Left := ErrorList.Left + ErrorList.Width - OkBtn.Width;
SaveBtn.Top := OkBtn.Top;
end;
procedure TErrorForm.NewError(Filename: string; SkipType: TZMSkipTypes);
resourcestring
Lng_Err_Entry = '%s (Grund: %s)';
begin
// In future: Also add reason into list?
ErrorList.Items.Add(Format(Lng_Err_Entry, [Filename, SkipTypeToStr(SkipType)]));
end;
procedure TErrorForm.SaveBtnClick(Sender: TObject);
begin
if SaveDialog.Execute then
begin
ErrorList.Items.SaveToFile(SaveDialog.FileName);
end;
end;
end.
|
UNIT rbSendKeys;
INTERFACE
USES Windows, SysUtils, TlHelp32;
TYPE TKeyLST = RECORD
VKKEY :DWORD;
NAME :STRING;
END;
TYPE TTKeyLST = ^TKeyLST;
CONST CONST_VKKEY = $00000000;
CONST VK_0 = CONST_VKKEY + ORD('0');
CONST VK_1 = CONST_VKKEY + ORD('1');
CONST VK_2 = CONST_VKKEY + ORD('2');
CONST VK_3 = CONST_VKKEY + ORD('3');
CONST VK_4 = CONST_VKKEY + ORD('4');
CONST VK_5 = CONST_VKKEY + ORD('5');
CONST VK_6 = CONST_VKKEY + ORD('6');
CONST VK_7 = CONST_VKKEY + ORD('7');
CONST VK_8 = CONST_VKKEY + ORD('8');
CONST VK_9 = CONST_VKKEY + ORD('9');
CONST VK_A = CONST_VKKEY + ORD('A');
CONST VK_B = CONST_VKKEY + ORD('B');
CONST VK_C = CONST_VKKEY + ORD('C');
CONST VK_D = CONST_VKKEY + ORD('D');
CONST VK_E = CONST_VKKEY + ORD('E');
CONST VK_F = CONST_VKKEY + ORD('F');
CONST VK_G = CONST_VKKEY + ORD('G');
CONST VK_H = CONST_VKKEY + ORD('H');
CONST VK_I = CONST_VKKEY + ORD('I');
CONST VK_J = CONST_VKKEY + ORD('J');
CONST VK_K = CONST_VKKEY + ORD('K');
CONST VK_L = CONST_VKKEY + ORD('L');
CONST VK_M = CONST_VKKEY + ORD('M');
CONST VK_N = CONST_VKKEY + ORD('N');
CONST VK_O = CONST_VKKEY + ORD('O');
CONST VK_P = CONST_VKKEY + ORD('P');
CONST VK_Q = CONST_VKKEY + ORD('Q');
CONST VK_R = CONST_VKKEY + ORD('R');
CONST VK_S = CONST_VKKEY + ORD('S');
CONST VK_T = CONST_VKKEY + ORD('T');
CONST VK_U = CONST_VKKEY + ORD('U');
CONST VK_V = CONST_VKKEY + ORD('V');
CONST VK_W = CONST_VKKEY + ORD('W');
CONST VK_X = CONST_VKKEY + ORD('X');
CONST VK_Y = CONST_VKKEY + ORD('Y');
CONST VK_Z = CONST_VKKEY + ORD('Z');
CONST VK_NOTDEFINED = $FFFFFFFF;
VAR Key_VK_List:ARRAY[0..102+36] OF TKeyLST=(
(VKKEY:VK_NOTDEFINED ;NAME:'NONE ' ),
(VKKEY:VK_RETURN ;NAME:'VK_RETURN ' ),
(VKKEY:VK_PAUSE ;NAME:'VK_PAUSE ' ),
(VKKEY:VK_LEFT ;NAME:'VK_LEFT ' ),
(VKKEY:VK_UP ;NAME:'VK_UP ' ),
(VKKEY:VK_RIGHT ;NAME:'VK_RIGHT ' ),
(VKKEY:VK_DOWN ;NAME:'VK_DOWN ' ),
(VKKEY:VK_ESCAPE ;NAME:'VK_ESCAPE ' ),
(VKKEY:VK_LSHIFT ;NAME:'VK_LSHIFT ' ),
(VKKEY:VK_RSHIFT ;NAME:'VK_RSHIFT ' ),
(VKKEY:VK_LCONTROL ;NAME:'VK_LCONTROL ' ),
(VKKEY:VK_RCONTROL ;NAME:'VK_RCONTROL ' ),
(VKKEY:VK_LBUTTON ;NAME:'VK_LBUTTON ' ),
(VKKEY:VK_RBUTTON ;NAME:'VK_RBUTTON ' ),
(VKKEY:VK_MBUTTON ;NAME:'VK_MBUTTON ' ),
(VKKEY:VK_SPACE ;NAME:'VK_SPACE ' ),
(VKKEY:VK_0 ;NAME:'0 ' ),
(VKKEY:VK_1 ;NAME:'1 ' ),
(VKKEY:VK_2 ;NAME:'2 ' ),
(VKKEY:VK_3 ;NAME:'3 ' ),
(VKKEY:VK_4 ;NAME:'4 ' ),
(VKKEY:VK_5 ;NAME:'5 ' ),
(VKKEY:VK_6 ;NAME:'6 ' ),
(VKKEY:VK_7 ;NAME:'7 ' ),
(VKKEY:VK_8 ;NAME:'8 ' ),
(VKKEY:VK_9 ;NAME:'9 ' ),
(VKKEY:VK_A ;NAME:'A ' ),
(VKKEY:VK_B ;NAME:'B ' ),
(VKKEY:VK_C ;NAME:'C ' ),
(VKKEY:VK_D ;NAME:'D ' ),
(VKKEY:VK_E ;NAME:'E ' ),
(VKKEY:VK_F ;NAME:'F ' ),
(VKKEY:VK_G ;NAME:'G ' ),
(VKKEY:VK_H ;NAME:'H ' ),
(VKKEY:VK_I ;NAME:'I ' ),
(VKKEY:VK_J ;NAME:'J ' ),
(VKKEY:VK_K ;NAME:'K ' ),
(VKKEY:VK_L ;NAME:'L ' ),
(VKKEY:VK_M ;NAME:'M ' ),
(VKKEY:VK_N ;NAME:'N ' ),
(VKKEY:VK_O ;NAME:'O ' ),
(VKKEY:VK_P ;NAME:'P ' ),
(VKKEY:VK_Q ;NAME:'Q ' ),
(VKKEY:VK_R ;NAME:'R ' ),
(VKKEY:VK_S ;NAME:'S ' ),
(VKKEY:VK_T ;NAME:'T ' ),
(VKKEY:VK_U ;NAME:'U ' ),
(VKKEY:VK_V ;NAME:'V ' ),
(VKKEY:VK_W ;NAME:'W ' ),
(VKKEY:VK_X ;NAME:'X ' ),
(VKKEY:VK_Y ;NAME:'Y ' ),
(VKKEY:VK_Z ;NAME:'Z ' ),
(VKKEY:VK_CANCEL ;NAME:'VK_CANCEL ' ),
(VKKEY:VK_BACK ;NAME:'VK_BACK ' ),
(VKKEY:VK_TAB ;NAME:'VK_TAB ' ),
(VKKEY:VK_CLEAR ;NAME:'VK_CLEAR ' ),
(VKKEY:VK_SHIFT ;NAME:'VK_SHIFT ' ),
(VKKEY:VK_CONTROL ;NAME:'VK_CONTROL ' ),
(VKKEY:VK_MENU ;NAME:'VK_MENU ' ),
(VKKEY:VK_CAPITAL ;NAME:'VK_CAPITAL ' ),
(VKKEY:VK_KANA ;NAME:'VK_KANA ' ),
(VKKEY:VK_HANGUL ;NAME:'VK_HANGUL ' ),
(VKKEY:VK_JUNJA ;NAME:'VK_JUNJA ' ),
(VKKEY:VK_FINAL ;NAME:'VK_FINAL ' ),
(VKKEY:VK_HANJA ;NAME:'VK_HANJA ' ),
(VKKEY:VK_KANJI ;NAME:'VK_KANJI ' ),
(VKKEY:VK_CONVERT ;NAME:'VK_CONVERT ' ),
(VKKEY:VK_NONCONVERT ;NAME:'VK_NONCONVERT' ),
(VKKEY:VK_ACCEPT ;NAME:'VK_ACCEPT ' ),
(VKKEY:VK_MODECHANGE ;NAME:'VK_MODECHANGE' ),
(VKKEY:VK_PRIOR ;NAME:'VK_PRIOR ' ),
(VKKEY:VK_NEXT ;NAME:'VK_NEXT ' ),
(VKKEY:VK_END ;NAME:'VK_END ' ),
(VKKEY:VK_HOME ;NAME:'VK_HOME ' ),
(VKKEY:VK_SELECT ;NAME:'VK_SELECT ' ),
(VKKEY:VK_PRINT ;NAME:'VK_PRINT ' ),
(VKKEY:VK_EXECUTE ;NAME:'VK_EXECUTE ' ),
(VKKEY:VK_SNAPSHOT ;NAME:'VK_SNAPSHOT ' ),
(VKKEY:VK_INSERT ;NAME:'VK_INSERT ' ),
(VKKEY:VK_DELETE ;NAME:'VK_DELETE ' ),
(VKKEY:VK_HELP ;NAME:'VK_HELP ' ),
(VKKEY:VK_LWIN ;NAME:'VK_LWIN ' ),
(VKKEY:VK_RWIN ;NAME:'VK_RWIN ' ),
(VKKEY:VK_APPS ;NAME:'VK_APPS ' ),
(VKKEY:VK_NUMPAD0 ;NAME:'VK_NUMPAD0 ' ),
(VKKEY:VK_NUMPAD1 ;NAME:'VK_NUMPAD1 ' ),
(VKKEY:VK_NUMPAD2 ;NAME:'VK_NUMPAD2 ' ),
(VKKEY:VK_NUMPAD3 ;NAME:'VK_NUMPAD3 ' ),
(VKKEY:VK_NUMPAD4 ;NAME:'VK_NUMPAD4 ' ),
(VKKEY:VK_NUMPAD5 ;NAME:'VK_NUMPAD5 ' ),
(VKKEY:VK_NUMPAD6 ;NAME:'VK_NUMPAD6 ' ),
(VKKEY:VK_NUMPAD7 ;NAME:'VK_NUMPAD7 ' ),
(VKKEY:VK_NUMPAD8 ;NAME:'VK_NUMPAD8 ' ),
(VKKEY:VK_NUMPAD9 ;NAME:'VK_NUMPAD9 ' ),
(VKKEY:VK_MULTIPLY ;NAME:'VK_MULTIPLY ' ),
(VKKEY:VK_ADD ;NAME:'VK_ADD ' ),
(VKKEY:VK_SEPARATOR ;NAME:'VK_SEPARATOR ' ),
(VKKEY:VK_SUBTRACT ;NAME:'VK_SUBTRACT ' ),
(VKKEY:VK_DECIMAL ;NAME:'VK_DECIMAL ' ),
(VKKEY:VK_DIVIDE ;NAME:'VK_DIVIDE ' ),
(VKKEY:VK_F1 ;NAME:'VK_F1 ' ),
(VKKEY:VK_F2 ;NAME:'VK_F2 ' ),
(VKKEY:VK_F3 ;NAME:'VK_F3 ' ),
(VKKEY:VK_F4 ;NAME:'VK_F4 ' ),
(VKKEY:VK_F5 ;NAME:'VK_F5 ' ),
(VKKEY:VK_F6 ;NAME:'VK_F6 ' ),
(VKKEY:VK_F7 ;NAME:'VK_F7 ' ),
(VKKEY:VK_F8 ;NAME:'VK_F8 ' ),
(VKKEY:VK_F9 ;NAME:'VK_F9 ' ),
(VKKEY:VK_F10 ;NAME:'VK_F10 ' ),
(VKKEY:VK_F11 ;NAME:'VK_F11 ' ),
(VKKEY:VK_F12 ;NAME:'VK_F12 ' ),
(VKKEY:VK_F13 ;NAME:'VK_F13 ' ),
(VKKEY:VK_F14 ;NAME:'VK_F14 ' ),
(VKKEY:VK_F15 ;NAME:'VK_F15 ' ),
(VKKEY:VK_F16 ;NAME:'VK_F16 ' ),
(VKKEY:VK_F17 ;NAME:'VK_F17 ' ),
(VKKEY:VK_F18 ;NAME:'VK_F18 ' ),
(VKKEY:VK_F19 ;NAME:'VK_F19 ' ),
(VKKEY:VK_F20 ;NAME:'VK_F20 ' ),
(VKKEY:VK_F21 ;NAME:'VK_F21 ' ),
(VKKEY:VK_F22 ;NAME:'VK_F22 ' ),
(VKKEY:VK_F23 ;NAME:'VK_F23 ' ),
(VKKEY:VK_F24 ;NAME:'VK_F24 ' ),
(VKKEY:VK_NUMLOCK ;NAME:'VK_NUMLOCK ' ),
(VKKEY:VK_SCROLL ;NAME:'VK_SCROLL ' ),
(VKKEY:VK_LMENU ;NAME:'VK_LMENU ' ),
(VKKEY:VK_RMENU ;NAME:'VK_RMENU ' ),
(VKKEY:VK_PROCESSKEY ;NAME:'VK_PROCESSKEY' ),
(VKKEY:VK_ATTN ;NAME:'VK_ATTN ' ),
(VKKEY:VK_CRSEL ;NAME:'VK_CRSEL ' ),
(VKKEY:VK_EXSEL ;NAME:'VK_EXSEL ' ),
(VKKEY:VK_EREOF ;NAME:'VK_EREOF ' ),
(VKKEY:VK_PLAY ;NAME:'VK_PLAY ' ),
(VKKEY:VK_ZOOM ;NAME:'VK_ZOOM ' ),
(VKKEY:VK_NONAME ;NAME:'VK_NONAME ' ),
(VKKEY:VK_PA1 ;NAME:'VK_PA1 ' ),
(VKKEY:VK_OEM_CLEAR ;NAME:'VK_OEM_CLEAR ' ),
(VKKEY:0 ;NAME:'' )
);
FUNCTION KeybdVK_LST_COUNT:DWORD;
FUNCTION KeybdVK_LST(NUM:DWORD):TTKeyLST;
FUNCTION KeybdVK_STR(VK:DWORD):STRING;
PROCEDURE KeybdInputStart;
FUNCTION KeybdInputAdd(VKey: Byte; Flags: DWORD):BOOLEAN; OVERLOAD;
FUNCTION KeybdInputAdd(VKey: Byte):BOOLEAN; OVERLOAD;
FUNCTION KeybdInputAdd(VKey: CHAR; Flags: DWORD):BOOLEAN; OVERLOAD;
FUNCTION KeybdInputAdd(VKey: CHAR):BOOLEAN; OVERLOAD;
FUNCTION KeybdInputAdd(VKeySTR: ShortString; Flags: DWORD):BOOLEAN; OVERLOAD;
FUNCTION KeybdInputAdd(VKeySTR: ShortString):BOOLEAN; OVERLOAD;
FUNCTION KeybdInputAddKeysStr(S: ShortString):BOOLEAN;
PROCEDURE KeybdInputEnd(hndl:HWND; SLEEPTIME:WORD=0);
PROCEDURE KeybdPutKey(hndl:HWND; VK:DWORD; isPressed:BOOLEAN; SLEEPTIME:WORD);
PROCEDURE KeybdSendKey(Wnd,VK:DWORD; Ctrl,Alt,Shift:BOOLEAN);
PROCEDURE KeybdInit(KeysMAX:WORD);
FUNCTION processExists(exeFileName: string): THandle;
FUNCTION GetHWndByPID(const hPID: THandle): THandle;
CONST KEYEVENTF_KEYDOWN = 0;
IMPLEMENTATION
VAR KeyInputs: ARRAY of TInput;
KeyInputsMAX:WORD = 0;
KeyInputsCNT:WORD = 0;
PROCEDURE KeybdInputStart;
BEGIN
KeyInputsCNT:=0;
END;
//--------------------------------------------
FUNCTION KeybdInputAdd(VKey: Byte; Flags: DWORD):BOOLEAN; OVERLOAD;
BEGIN
IF KeyInputsCNT<KeyInputsMAX THEN BEGIN
KeyInputs[KeyInputsCNT].Itype := INPUT_KEYBOARD;
WITH KeyInputs[KeyInputsCNT].ki DO BEGIN
wVk := VKey;
wScan := MapVirtualKey(VKey, 0);
dwFlags := Flags;
END;
INC(KeyInputsCNT);
RESULT:=TRUE;
END ELSE BEGIN
RESULT:=FALSE;
END;
END;
FUNCTION KeybdInputAdd(VKey: CHAR; Flags: DWORD):BOOLEAN; OVERLOAD;
BEGIN
RESULT:=KeybdInputAdd(ORD(VKey), Flags);
END;
FUNCTION KeybdInputAdd(VKey: CHAR):BOOLEAN; OVERLOAD;
BEGIN
RESULT:=FALSE;
IF NOT KeybdInputAdd(VKey, 0) THEN EXIT;
IF NOT KeybdInputAdd(VKey, KEYEVENTF_KEYUP) THEN EXIT;
RESULT:=TRUE;
END;
FUNCTION KeybdInputAdd(VKey: BYTE):BOOLEAN; OVERLOAD;
BEGIN
RESULT:=KeybdInputAdd(CHAR(VKey));
END;
FUNCTION KeybdInputAdd(VKeySTR: ShortString; Flags: DWORD):BOOLEAN; OVERLOAD;
VAR N:LONGINT;
BEGIN
RESULT:=FALSE;
FOR N:=1 TO Length(VKeySTR) DO BEGIN
IF NOT KeybdInputAdd(VKeySTR[N], Flags) THEN EXIT;
END;
RESULT:=TRUE;
END;
FUNCTION KeybdInputAdd(VKeySTR: ShortString):BOOLEAN; OVERLOAD;
VAR N:LONGINT;
BEGIN
RESULT:=FALSE;
FOR N:=1 TO Length(VKeySTR) DO BEGIN
IF NOT KeybdInputAdd(CHAR(VKeySTR[N])) THEN EXIT;
END;
RESULT:=TRUE;
END;
FUNCTION KeybdVK_LST_COUNT:DWORD;
VAR N:LONGINT;
S:^STRING;
V:^DWORD;
BEGIN
N:=0;
REPEAT
RESULT:=N;
V:=@Key_VK_List[N].VKKEY;
S:=@Key_VK_List[N].NAME;
IF ((V^=0) AND (S^='')) THEN BREAK;
INC(N);
UNTIL FALSE;
END;
FUNCTION KeybdVK_LST(NUM:DWORD):TTKeyLST;
VAR N:LONGINT;
S:^STRING;
V:^DWORD;
BEGIN
N:=0;
REPEAT
RESULT:=@Key_VK_List[N];
V:=@Key_VK_List[N].VKKEY;
S:=@Key_VK_List[N].NAME;
IF ((V^=0) AND (S^='')) OR (N=NUM) THEN BREAK;
INC(N);
UNTIL FALSE;
END;
FUNCTION KeybdVK_STR(VK:DWORD):STRING;
VAR N:LONGINT;
S:^STRING;
V:^DWORD;
BEGIN
N:=0;
REPEAT
V:=@Key_VK_List[N].VKKEY;
S:=@Key_VK_List[N].NAME;
RESULT:=S^;
IF ((V^=0) AND (S^='')) OR (V^=VK) THEN BREAK;
INC(N);
UNTIL FALSE;
END;
//FUNCTION KeybdVK_VK()
// !"#$%&'()*+,-./0123456789:;<=>?
//@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
//`abcdefghijklmnopqrstuvwxyz{|}~
{
CONST KECHTBL:ARRAY[0..47] OF WORD=(
//$00..$0F
0,0,0,0,0,0,0,0,0,0,0,0,0,VK_RETURN,0,0,
//$10..$1F
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
//$20..$2F
// ! " # $ % & ' ( ) * + , - . /
$0420,$0431,$04DE,$0433,$0434,$0435,$0437,$00DE,$0439,$0430,$0438,$04BB,$00BC,$00BD,$00BE,$00BF,
//$30..$3F
//0 1 2 3 4 5 6 7 8 9 : ; < = > ?
$0030,$0031,$0032,$0033,$0034,$0035,$0036,$0037,$0038,$0039,$04BA,$00BA,$04BC,$00BB,$04BE,$04BF,
//$40..$4F
//@ A B C D E F G H I J K L M N O
$0432,$0041,$0042,$0043,$0044,$0045,$0046,$0047,$0048,$0049,$004A,$004B,$004C,$004D,$004E,$004F,
//$50..$5F
//P Q R S T U V W X Y Z [ \ ] ^ _
$0050,$0051,$0052,$0053,$0054,$0055,$0056,$0057,$0058,$0059,$005A,$00DB,$00DC,$00DD,$0436,$04BD,
//$60..$6F
//` a b c d e f g h i j k l m n o
$04C0,$0441,$0442,$0443,$0444,$0445,$0446,$0447,$0448,$0449,$044A,$044B,$044C,$044D,$044E,$044F,
//$70..$7F
//p q r s t u v w x y z } { | } { ~
$0050,$0051,$0052,$0053,$0054,$0055,$0056,$0057,$0058,$0059,$005A,$00DB,$00DC,$00DD,$0436,$04BD,
);
}
FUNCTION GetVKKeyFromChar(C:CHAR):BYTE;
BEGIN
END;
FUNCTION KeybdInputAddKeysStr(S: ShortString):BOOLEAN;
VAR N,M,I:LONGINT;
CAP:BOOLEAN;
SHI:BYTE;
US,LS,SS:ShortString;
BEGIN
FOR N:=1 TO Length(S) DO BEGIN
KeybdInputAdd(VK_MENU, 0);
SS:=IntToStr(BYTE(S[N]));
FOR I:=1 TO LENGTH(SS) DO BEGIN
KeybdInputAdd( VK_NUMPAD0+(BYTE(SS[I]) AND 15) );
END;
KeybdInputAdd(VK_MENU, KEYEVENTF_KEYUP);
END;
END;
//OUT:OLD HWND
FUNCTION KeybdHWND_Active(hndl:HWND):HWND;
VAR OLDHWND:HWND;
P: ^DWORD;
D: DWORD;
BEGIN
OLDHWND:=0;
IF hndl<>0 THEN BEGIN
OLDHWND := GetForegroundWindow();
P := @D;
SystemParametersInfo(//get flashing timeout on win98
SPI_GETFOREGROUNDLOCKTIMEOUT,
0,
P,
0);
SetForeGroundWindow(hndl);
END;
RESULT:=OLDHWND;
END;
FUNCTION KeybdHWND_Return(OLDHWND:HWND):BOOLEAN;
VAR P: ^DWORD;
D: DWORD;
BEGIN
IF OLDHWND<>0 THEN BEGIN
SystemParametersInfo(//set flashing TimeOut=0
SPI_SETFOREGROUNDLOCKTIMEOUT,
0,
nil,
0);
// SetForegroundWindow(TWinControl(TComponent(Self).Owner).Handle);
// SetForegroundWindow(TWinControl(TComponent(OLDHWND).Owner).Handle);
// SetForegroundWindow(Application.Handle);
SetForegroundWindow(OLDHWND);
// SLEEP(SLEEPTIME);
//->typecast working...
SystemParametersInfo(//set flashing TimeOut=previous value
SPI_SETFOREGROUNDLOCKTIMEOUT,
D,
nil,
0);
//SLEEP(SLEEPTIME);
FillChar(KeyInputs[0], SizeOf(KeyInputs), 0);
RESULT:=TRUE;
END ELSE BEGIN
RESULT:=FALSE;
END;
END;
PROCEDURE KeybdInputEnd(hndl:HWND; SLEEPTIME:WORD=0);
VAR OLDHWND:HWND;
BEGIN
OLDHWND:=KeybdHWND_Active(hndl);
SendInput(KeyInputsCNT, KeyInputs[0], SizeOf(KeyInputs[0]));
SLEEP(SLEEPTIME);
KeyInputsCNT:=0;
IF ( KeybdHWND_Return(OLDHWND) ) THEN BEGIN
SLEEP(SLEEPTIME);
END;
END;
PROCEDURE KeybdPutKey(hndl:HWND; VK:DWORD; isPressed:BOOLEAN; SLEEPTIME:WORD);
VAR OLDHWND:HWND;
BEGIN
OLDHWND:=KeybdHWND_Active(hndl);
IF (isPressed) THEN BEGIN
keybd_event(VK,0,KEYEVENTF_KEYDOWN, 0);
END ELSE BEGIN
keybd_event(VK,0,KEYEVENTF_KEYUP, 0);
END;
SLEEP(SLEEPTIME);
KeybdHWND_Return(OLDHWND);
END;
PROCEDURE KeybdSendKey(Wnd,VK:DWORD; Ctrl,Alt,Shift:BOOLEAN);
VAR
MC,MA,MS:BOOLEAN;
BEGIN
// Try to bring target window to foreground
ShowWindow(Wnd,SW_SHOW);
SetForegroundWindow(Wnd);
// Get current state of modifier keys
MC:=Hi(GetAsyncKeyState(VK_CONTROL))>127;
MA:=Hi(GetAsyncKeyState(VK_MENU))>127;
MS:=Hi(GetAsyncKeyState(VK_SHIFT))>127;
// Press modifier keys if necessary (unless already pressed by real user)
IF Ctrl<>MC THEN keybd_event(VK_CONTROL,0,Byte(MC)*KEYEVENTF_KEYUP,0);
IF Alt<>MA THEN keybd_event(VK_MENU,0,Byte(MA)*KEYEVENTF_KEYUP,0);
IF Shift<>MS THEN keybd_event(VK_SHIFT,0,Byte(MS)*KEYEVENTF_KEYUP,0);
// Press key
keybd_event(VK,0,KEYEVENTF_KEYDOWN,0);
keybd_event(VK,0,KEYEVENTF_KEYUP,0);
// Release modifier keys if necessary
IF Ctrl<>MC THEN keybd_event(VK_CONTROL,0,Byte(Ctrl)*KEYEVENTF_KEYUP,0);
IF Alt<>MA THEN keybd_event(VK_MENU,0,Byte(Alt)*KEYEVENTF_KEYUP,0);
IF Shift<>MS THEN keybd_event(VK_SHIFT,0,Byte(Shift)*KEYEVENTF_KEYUP,0);
END;
PROCEDURE KeybdInit(KeysMAX:WORD);
BEGIN
KeyInputsMAX := KeysMAX;
SetLength(KeyInputs, KeysMAX);
END;
FUNCTION processExists(exeFileName: string): THandle;
var
ContinueLoop: BOOL;
FSnapshotHandle: THandle;
FProcessEntry32: TProcessEntry32;
begin
FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
FProcessEntry32.dwSize := SizeOf(FProcessEntry32);
ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);
Result := 0;//False;
while Integer(ContinueLoop) <> 0 do
begin
if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) =
UpperCase(ExeFileName)) or (UpperCase(FProcessEntry32.szExeFile) =
UpperCase(ExeFileName))) then
begin
Result := FProcessEntry32.th32ProcessID;
//Result := True;
end;
ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);
end;
CloseHandle(FSnapshotHandle);
end;
function GetHWndByPID(const hPID: THandle): THandle;
type
PEnumInfo = ^TEnumInfo;
TEnumInfo = record
ProcessID: DWORD;
HWND: THandle;
end;
function EnumWindowsProc(Wnd: DWORD; var EI: TEnumInfo): Bool; stdcall;
var
PID: DWORD;
begin
GetWindowThreadProcessID(Wnd, @PID);
Result := (PID <> EI.ProcessID) or
(not IsWindowVisible(WND)) or
(not IsWindowEnabled(WND));
if not Result then EI.HWND := WND;
end;
function FindMainWindow(PID: DWORD): DWORD;
var
EI: TEnumInfo;
begin
EI.ProcessID := PID;
EI.HWND := 0;
EnumWindows(@EnumWindowsProc, Integer(@EI));
Result := EI.HWND;
end;
begin
if hPID<>0 then
Result:=FindMainWindow(hPID)
else
Result:=0;
end;
BEGIN
KeybdInit(1024);
END.
|
unit MainFormU;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls,
FMX.Platform, ActivityReceiverU;
type
TServiceInteractionForm = class(TForm)
StopServiceButton: TButton;
StartServiceButton: TButton;
ExitTimer: TTimer;
procedure StopServiceButtonClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word; var KeyChar: Char; Shift: TShiftState);
procedure StartServiceButtonClick(Sender: TObject);
procedure ExitTimerTimer(Sender: TObject);
private
{ Private declarations }
FReceiver: JActivityReceiver;
FReceiverRegistered: Boolean;
FServiceIsRunning: Boolean;
procedure RegisterReceiver;
procedure UnregisterReceiver;
procedure StartService;
procedure StopService;
public
{ Public declarations }
const SAMPLE_ACTIVITY_ACTION = 'SAMPLE_ACTIVITY_ACTION';
var AppEvents: IFMXApplicationEventService;
function ApplicationEventHandler(AAppEvent: TApplicationEvent;
AContext: TObject): Boolean;
end;
var
ServiceInteractionForm: TServiceInteractionForm;
implementation
uses
System.TypInfo,
FMX.Helpers.Android,
Androidapi.JNIBridge,
Androidapi.JNI,
Androidapi.JNI.JavaTypes,
Androidapi.JNI.GraphicsContentViewText, ServiceU;
{$R *.fmx}
function TServiceInteractionForm.ApplicationEventHandler(AAppEvent: TApplicationEvent;
AContext: TObject): Boolean;
begin
Log.d('', Self, 'ApplicationEventHandler', Format('+ %s',
[GetEnumName(TypeInfo(TApplicationEvent), Integer(AAppEvent))]));
Result := True;
// Clean up the UI display when app becomes active
// or is brought back to the foreground
case AAppEvent of
aeFinishedLaunching:
begin
//
end;
aeBecameActive:
begin
RegisterReceiver
end;
aeEnteredBackground:
begin
UnregisterReceiver
end;
aeWillterminate:
begin
//
end;
end;
Log.d('', Self, 'ApplicationEventHandler', '-');
end;
procedure TServiceInteractionForm.FormCreate(Sender: TObject);
begin
Log.d('TServiceInteractionForm.FormCreate');
//Set up event that triggers when app is brought back to foreground
if TPlatformServices.Current.SupportsPlatformService(
IFMXApplicationEventService,
IInterface(AppEvents)) then
AppEvents.SetApplicationEventHandler(ApplicationEventHandler);
StartService;
end;
procedure TServiceInteractionForm.FormDestroy(Sender: TObject);
begin
// if FServiceIsRunning then
// begin
// Log.d('TServiceInteractionForm.FormDestroy triggering the stop service code');
// StopService;
// Sleep(5000);
// end;
// Log.d('TServiceInteractionForm.FormDestroy exiting');
//After this point we crash
//TODO: work out why
end;
procedure TServiceInteractionForm.FormKeyDown(Sender: TObject; var Key: Word; var KeyChar: Char; Shift: TShiftState);
begin
Log.d('TServiceInteractionForm.FormKeyDown: Key = %d ($%0:x)', [Key]);
if Key = vkHardwareBack then
begin
Log.d('Subverting the Back key to act like Home');
Key := 0;
Log.d('Stopping the service');
StopService;
Log.d('Moving task to the background');
SharedActivity.moveTaskToBack(True);
Log.d('Starting the exit timer');
ExitTimer.Enabled := True;
end;
end;
procedure TServiceInteractionForm.ExitTimerTimer(Sender: TObject);
begin
Log.d('Exit timer has fired');
ExitTimer.Enabled := False;
Log.d('Terminating this activity');
SharedActivity.finish;
end;
procedure TServiceInteractionForm.RegisterReceiver;
var
Filter: JIntentFilter;
begin
if not FReceiverRegistered and (FReceiver <> nil) then
begin
//Register the activity's broadcast receiver which will pick up messages from the service
Filter := TJIntentFilter.Create;
Filter.addAction(StringToJString(TSampleService.SAMPLE_SERVICE_ACTION));
Log.d('Registering the activity receiver');
SharedActivity.registerReceiver(FReceiver, Filter);
FReceiverRegistered := True;
end
end;
procedure TServiceInteractionForm.StartService;
var
ServiceIntent: JIntent;
begin
if not FServiceIsRunning then
begin
//Create the form's broadcast receiver
Log.d('Creating activity receiver');
FReceiver := TJActivityReceiver.Create;
RegisterReceiver;
//Start the service
Log.d('Creating service intent');
ServiceIntent := TJIntent.JavaClass.init(SharedActivityContext,
TJLang_Class.JavaClass.forName(
StringToJString('com.blong.test.SampleService'),
True,
SharedActivity.getClassLoader));
Log.d('Service initiation intent created');
ServiceIntent.putExtra(StringToJString(TSampleService.ID_INT_START_VALUE), Integer(10));
Log.d('Starting service');
if SharedActivity.startService(serviceIntent) = nil then
Log.d('startService returned nil');
FServiceIsRunning := True;
end
end;
procedure TServiceInteractionForm.StartServiceButtonClick(Sender: TObject);
begin
StartService
end;
procedure TServiceInteractionForm.StopService;
var
Intent: JIntent;
begin
if FServiceIsRunning then
begin
UnregisterReceiver;
FReceiver := nil;
Intent := TJIntent.Create;
Intent.setAction(StringToJString(SAMPLE_ACTIVITY_ACTION));
Intent.putExtra(StringToJString(TSampleService.ID_INT_COMMAND), TSampleService.CMD_STOP_SERVICE);
Log.d('Broadcasting service stop intent');
SharedActivity.sendBroadcast(Intent);
FServiceIsRunning := False;
end;
end;
procedure TServiceInteractionForm.StopServiceButtonClick(Sender: TObject);
begin
StopService;
end;
procedure TServiceInteractionForm.UnregisterReceiver;
begin
if FReceiverRegistered and (FReceiver <> nil) then
begin
//Unregister the broadcast receiver
Log.d('Unregistering the activity receiver');
SharedActivity.unregisterReceiver(FReceiver);
FReceiverRegistered := False;
end;
end;
end.
|
{
$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.1 2004.02.03 5:44:18 PM czhower
Name changes
Rev 1.0 11/13/2002 08:00:40 AM JPMugaas
Base class for any mechanism that needs a username/password.
This links to a TIdUserPassProvider to allow application programmers
to only set the username/password once, instead of having to set it for
all SASL mechanisms they might want to use.
}
unit IdSASLUserPass;
interface
{$i IdCompilerDefines.inc}
uses
Classes,
IdSASL, IdUserPassProvider, IdBaseComponent,
IdException;
type
TIdSASLUserPass = class(TIdSASL)
protected
FUserPassProvider: TIdUserPassProvider;
procedure SetUserPassProvider(const Value: TIdUserPassProvider);
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
function GetUsername: string;
function GetPassword: string;
public
function IsReadyToStart: Boolean; override;
published
property UserPassProvider: TIdUserPassProvider read FUserPassProvider write SetUserPassProvider;
end;
EIdUserPassProviderUnassigned = class(EIdException);
implementation
uses IdResourceStringsProtocols;
{ TIdSASLUserPass }
function TIdSASLUserPass.GetPassword: string;
begin
if Assigned(FUserPassProvider) then begin
Result := FUserPassProvider.Password;
end else begin
raise EIdUserPassProviderUnassigned.Create(RSUnassignedUserPassProv);
end;
end;
function TIdSASLUserPass.GetUsername: string;
begin
if Assigned(FUserPassProvider) then begin
Result := FUserPassProvider.Username;
end else begin
raise EIdUserPassProviderUnassigned.Create(RSUnassignedUserPassProv);
end;
end;
function TIdSASLUserPass.IsReadyToStart;
begin
if Assigned(FUserPassProvider) then begin
Result := (FUserPassProvider.Username <> '');
end else begin
Result := False;
end;
end;
procedure TIdSASLUserPass.Notification(AComponent: TComponent; Operation: TOperation);
begin
if (Operation = opRemove) and (AComponent = FUserPassProvider) then begin
FUserPassProvider := nil;
end;
inherited Notification(AComponent, Operation);
end;
procedure TIdSASLUserPass.SetUserPassProvider(const Value: TIdUserPassProvider);
begin
if FUserPassProvider <> Value then begin
if Assigned(FUserPassProvider) then begin
FUserPassProvider.RemoveFreeNotification(Self);
end;
FUserPassProvider := Value;
if Assigned(FUserPassProvider) then begin
FUserPassProvider.FreeNotification(Self);
end;
end;
end;
end.
|
unit m3ArchiveStorage;
{* Хранилище с паковкой данных. }
{ Библиотека "M3" }
{ Автор: Люлин А.В. © }
{ Модуль: m3ArchiveStorage - }
{ Начат: 28.11.2001 16:21 }
{ $Id: m3ArchiveStorage.pas,v 1.16 2015/05/13 10:59:48 lulin Exp $ }
// $Log: m3ArchiveStorage.pas,v $
// Revision 1.16 2015/05/13 10:59:48 lulin
// - чистим код.
//
// Revision 1.15 2014/10/31 17:42:58 lulin
// - перетряхиваем код.
//
// Revision 1.14 2014/10/31 14:14:30 lulin
// - перетряхиваем код.
//
// Revision 1.13 2014/10/30 13:43:54 lulin
// - перетряхиваем код.
//
// Revision 1.12 2014/10/30 07:49:12 lulin
// - перетряхиваем код.
//
// Revision 1.11 2014/10/29 17:32:19 lulin
// - перетряхиваем код.
//
// Revision 1.10 2014/10/23 16:33:05 lulin
// - переносим на модель.
//
// Revision 1.9 2014/10/16 09:02:51 lulin
// - очередной раз удаляем "совсем старое хранилище".
//
// Revision 1.8 2014/10/13 10:28:52 lulin
// - отключаем "совсем старое хранилище".
//
// Revision 1.7 2014/10/03 09:44:33 lulin
// - готовимся к кешированию хранилищ, а точнее - менеджеров блоков и связанных с ними потоков.
//
// Revision 1.6 2014/09/24 10:32:52 lulin
// - даём более вменяемые названия.
//
// Revision 1.5 2014/09/16 16:30:27 lulin
// - бекап пытаемся писать в новом формате.
//
// Revision 1.4 2014/09/16 10:43:22 lulin
// - возвращаем старую реализацию хранилища.
//
// Revision 1.3 2009/03/19 16:28:30 lulin
// [$139443095].
//
// Revision 1.2 2005/01/31 10:28:46 lulin
// - bug fix: при попытке писать в непустой архивирующий поток - обламывались - внешние проявления - ломалось print preview.
//
// Revision 1.1 2004/09/02 08:09:47 law
// - cleanup.
//
// Revision 1.8 2004/08/31 15:42:07 law
// - bug fix: в PlugIn'е для Far'а не перезаписывались отредактированные файлы.
//
// Revision 1.7 2002/10/16 14:13:36 narry
// - change: добавлена возможность открытия/создания потока без сжатия.
//
// Revision 1.6 2002/06/17 14:24:15 law
// - new method: _OpenStore.
//
// Revision 1.5 2002/02/22 10:30:53 law
// - optimization: используем интерфейс Im3IndexedStorage.
//
// Revision 1.4 2002/01/18 14:54:16 law
// - change: процедуры *Storage и *Stream объединены в *Store.
//
// Revision 1.3 2002/01/10 13:18:26 law
// - change data struct: PWideChar -> Tl3PCharLen.
//
// Revision 1.2 2001/11/28 15:10:02 law
// - bug fix: поправлен PlugIn для Far'а - не читал архивированные хранилища.
//
// Revision 1.1 2001/11/28 14:19:31 law
// - new behavior: сделано создание хранилищ с автоматической паковкой.
//
{$I m3Define.inc}
interface
uses
Windows,
l3Types,
l3Base,
m3StorageInterfaces
;
type
Tm3ArchiveStorage = class
{* Хранилище с паковкой данных. }
public
class function Make(anAccess : Tm3StoreAccess;
const aStream : IStream;
aStorageType : Tm3StorageType): Im3StorageHolder;
end;//Tm3ArchiveStorage
implementation
uses
SysUtils,
ActiveX,
ComObj,
l3Interfaces,
m2AddDbg,
m2COMLib,
m3ArcMgr,
m3NewStorage,
m3RootStream,
m3RootStreamNew,
m3StorageHolder,
m3StoreHeaderDataNew
;
type
Tm3NewArchiveStorage = class(Tm3NewStorage)
{* Хранилище с паковкой данных. }
protected
// internal methods
function IsValidOpenMode(aStatStgMode: Integer): Boolean;
override;
{-}
class function IsPacked: Boolean;
override;
{-}
function CreateOpenStoreByName(const aStoreInfo : Tm3StoreInfo;
anAccess : Tm3StoreAccess;
aName : Tl3String;
aMode : Tm3StoreMode;
aUseCompression : Boolean): Tm3Store;
override;
{-}
procedure DoCreateStore(const AName : Tl3WString;
anAccess : Tm3StoreAccess;
aStoreType : Tm3StoreType;
out AStream : Tm3Store;
out AReturn : HRESULT;
aUseCompression : Boolean);
override;
{-}
end;//Tm3NewArchiveStorage
Tm3NewPluginArchiveStorage = class(Tm3NewArchiveStorage)
protected
// internal methods
class function ForPlugin: Boolean;
override;
{-}
end;//Tm3NewPluginArchiveStorage
// start class Tm3ArchiveStorage
class function Tm3ArchiveStorage.Make(anAccess : Tm3StoreAccess;
const aStream : IStream;
aStorageType : Tm3StorageType): Im3StorageHolder;
var
l_GUID : AnsiString;
begin
Assert((anAccess = STGM_READ) OR (anAccess = STGM_READWRITE));
l_GUID := m2COMCLSIDFromStream(m2COMSetPosition(0, aStream));
if (l_GUID = GUIDToString(GUID_NULL)) then
begin
if (anAccess = STGM_READWRITE) then
if (m2COMGetSize(aStream) = 0) then
l_GUID := GUIDToString(Tm3RootStreamNew.HeaderID);
end;//l_GUID = GUIDToString(GUID_NULL)
if (l_GUID = GUIDToString(Tm3RootStream.HeaderID)) OR
(l_GUID = GUIDToString(Tm3RootStreamNew.HeaderID)) then
begin
Case aStorageType of
m3_stArchive:
Result := Tm3StorageHolder.Make(Tm3NewArchiveStorage, anAccess, aStream);
m3_stPlugin:
Result := Tm3StorageHolder.Make(Tm3NewPluginArchiveStorage, anAccess, aStream);
else
Result := Tm3StorageHolder.Make(Tm3NewStorage, anAccess, aStream);
end;//Case UseCompression
end//l_GUID = GUIDToString(Tm3RootStream.HeaderID)..
else
OleError(STG_E_INVALIDHEADER);
end;
// start class Tm3NewArchiveStorage
class function Tm3NewArchiveStorage.IsPacked: Boolean;
//virtual;
{-}
begin
Result := true;
end;
function Tm3NewArchiveStorage.CreateOpenStoreByName(const aStoreInfo : Tm3StoreInfo;
anAccess : Tm3StoreAccess;
aName : Tl3String;
aMode : Tm3StoreMode;
aUseCompression : Boolean): Tm3Store;
//override;
{-}
var
l_StatStgMode : LongInt;
begin
Case aMode of
m3_smOpen :
begin
if (aStoreInfo.rStoreType = m3_stStream) then
begin
l_StatStgMode := anAccess;
if ForPlugin then
l_StatStgMode := l_StatStgMode AND not (STGM_WRITE OR STGM_READWRITE);
Result := inherited CreateOpenStoreByName(aStoreInfo, l_StatStgMode, aName, aMode, aUseCompression);
if (Result.rStream <> nil) then
begin
if (l_StatStgMode AND (STGM_WRITE OR STGM_READWRITE) = 0) then
Result.rStream := Tm3InflateStreamManager.MakeInterface(Result.rStream)
else
if aUseCompression then
begin
try
Result.rStream := Tm3DeflateStreamManager.MakeInterface(Self.Header.RootStreamManager.StoreHeaderDataClass.InheritsFrom(Tm3StoreHeaderDataNew), Result.rStream);
except
on Em2InvalidValue do
begin
// - непонятно почему запаковывающий поток пытается считать признак того
// что поток под ним уже архивированный - это оказывается не так
m2COMSetSize(0, Result.rStream);
// - обрезаем нижний поток, т.к. в архивированный поток все равно нельзя
// одновременно писать и читать
Result.rStream := Tm3DeflateStreamManager.MakeInterface(Self.Header.RootStreamManager.StoreHeaderDataClass.InheritsFrom(Tm3StoreHeaderDataNew), Result.rStream);
// - открываем запаковывающий поток вокруг пустого
end;//on EInvalidValue
end;//try..except
end;//aUseCompression
end;//Result <> nil
end else
Result := inherited CreateOpenStoreByName(aStoreInfo, anAccess, aName, aMode, aUseCompression);
end;//m3_smOpen
m3_smCreate :
begin
Result := inherited CreateOpenStoreByName(aStoreInfo, anAccess, aName, aMode, aUseCompression);
if (Result.rStream <> nil) AND (aStoreInfo.rStoreType = m3_stStream) then
begin
if (anAccess AND (STGM_WRITE OR STGM_READWRITE) <> 0) then
if aUseCompression then
Result.rStream := Tm3DeflateStreamManager.MakeInterface(Self.Header.RootStreamManager.StoreHeaderDataClass.InheritsFrom(Tm3StoreHeaderDataNew), Result.rStream);
end;//Result <> nil..
end;//m3_smCreate
end;//Case aMode
end;
procedure Tm3NewArchiveStorage.DoCreateStore(const AName : Tl3WString;
anAccess : Tm3StoreAccess;
aStoreType : Tm3StoreType;
out AStream : Tm3Store;
out AReturn : HRESULT;
aUseCompression : Boolean);
{-}
begin
inherited;
if ForPlugin then
if (aReturn = STG_E_FILEALREADYEXISTS) then
begin
aReturn := S_Ok;
DoOpenStore(aName, m3_saCreate, aStoreType, aStream, aReturn, aUseCompression);
end;//aReturn = STG_E_FILEALREADYEXISTS
end;
function Tm3NewArchiveStorage.IsValidOpenMode(AStatStgMode: Integer): Boolean;
//override;
{-}
begin
Result := inherited IsValidOpenMode(aStatStgMode);
if not Result then
Result := (aStatStgMode = m3_saCreate);
end;
// start class Tm3NewPluginArchiveStorage
class function Tm3NewPluginArchiveStorage.ForPlugin: Boolean;
//override;
{-}
begin
Result := true;
end;
end.
|
//
// Generated by SGWrapperGen - DO NOT EDIT!
//
// SwinGame exported library
//
{$I sgTrace.inc}
library SGSDK;
uses SysUtils, Strings, sgTrace, sgShared,
sgTimers, sgPhysics, sgCharacters, sgAudio, sgImages, SDL, sgAnimations, SDL_TTF, SDL_Image, sgInput, sgTypes, sgGraphics, sgGeometry, sgText, SDL_Mixer, sgCore, sgResources, sgCamera, sgSprites;
// The exception trap is used to ensure that exceptions do not propagate beyond the
// library boundary.
procedure TrapException(exc: Exception; fromMethod: String);
begin
HasException := true;
if Assigned(exc) then
ErrorMessage := 'Error from ' + fromMethod + ' - ' + exc.Message
else
ErrorMessage := 'Unknown error from ' + fromMethod;
{$IFDEF TRACE}
Trace('SGSDK.dll', 'Error', fromMethod, ErrorMessage);
{$ENDIF}
end;
// The following routines are used to copy array data
procedure TriCopyToPtr(tri: Point2DPtr; const fromTri: Triangle);
var
i: LongInt;
begin
for i := 0 to 2 do
begin
(tri + i)^ := fromTri[i];
end;
end;
procedure TriCopyFromPtr(var toTri: Triangle; tri: Point2DPtr);
var
i: LongInt;
begin
for i := 0 to 2 do
begin
toTri[i] := (tri + i)^;
end;
end;
procedure MatrixCopyToPtr(matrix: SinglePtr; const fromMatrix: Matrix2D);
var
i, j: LongInt;
begin
//WriteLn('************************');
for i := 0 to 2 do
begin
//Write('| ');
for j := 0 to 2 do
begin
//Write(fromMatrix[i,j]:4:2, ' ');
(matrix + (i * 3) + j)^ := fromMatrix[i,j];
//matrix[i,j] := fromMatrix[i,j];
end;
//Writeln('|');
end;
//WriteLn('************************');
end;
procedure MatrixCopyFromPtr(var toMatrix: Matrix2D; matrix: SinglePtr);
var
i, j: LongInt;
begin
//WriteLn('************************');
for i := 0 to 2 do
begin
//Write('| ');
for j := 0 to 2 do
begin
toMatrix[i,j] := (matrix + (i * 3) + j)^;
//toMatrix[i,j] := matrix[i,j];
//Write(toMatrix[i,j]:4:2, ' ');
end;
//Writeln('|');
end;
//WriteLn('************************');
end;
procedure LineCopyFromPtr(data: LineSegmentPtr; len: LongInt; out arr: LinesArray);
var
i: LongInt;
begin
if len < 0 then raise Exception.Create('Length of array cannot be negative');
SetLength(arr, len);
for i := 0 to len - 1 do
begin
arr[i] := (data + i)^;
end;
end;
procedure LineCopyToPtr(const arr: LinesArray; len: LongInt; data: LineSegmentPtr);
var
i: LongInt;
begin
if len < Length(arr) then raise Exception.Create('Error in array size to call expected length to be ' + IntToStr(len));
for i := Low(arr) to High(arr) do
begin
(data + i)^ := arr[i];
end;
end;
procedure TriangleCopyFromPtr(data: TrianglePtr; len: LongInt; out arr: TriangleArray);
var
i: LongInt;
begin
if len < 0 then raise Exception.Create('Length of array cannot be negative');
SetLength(arr, len);
for i := 0 to len - 1 do
begin
arr[i] := (data + i)^;
end;
end;
procedure TriangleCopyToPtr(const arr: TriangleArray; len: LongInt; data: TrianglePtr);
var
i: LongInt;
begin
if len < Length(arr) then raise Exception.Create('Error in array size to call expected length to be ' + IntToStr(len));
for i := Low(arr) to High(arr) do
begin
(data + i)^ := arr[i];
end;
end;
procedure BmpCopyFromPtr(bmp: BitmapPtr; len: LongInt; out arr: BitmapArray);
var
i: LongInt;
begin
if len < 0 then raise Exception.Create('Length of array cannot be negative');
SetLength(arr, len);
for i := 0 to len - 1 do
begin
arr[i] := (bmp + i)^;
end;
end;
procedure BmpCopyToPtr(const arr: BitmapArray; len: LongInt; bmp: BitmapPtr);
var
i: LongInt;
begin
if len < Length(arr) then raise Exception.Create('Error in array size to call expected length to be ' + IntToStr(len));
for i := Low(arr) to High(arr) do
begin
(bmp + i)^ := arr[i];
end;
end;
procedure LongIntCopyFromPtr(data: LongIntPtr; len: LongInt; out arr: LongIntArray);
var
i: LongInt;
begin
if len < 0 then raise Exception.Create('Length of array cannot be negative');
SetLength(arr, len);
for i := 0 to len - 1 do
begin
arr[i] := (data + i)^;
end;
end;
procedure LongIntCopyToPtr(const arr: LongIntArray; len: LongInt; data: LongIntPtr);
var
i: LongInt;
begin
if len < Length(arr) then raise Exception.Create('Error in array size to call expected length to be ' + IntToStr(len));
for i := Low(arr) to High(arr) do
begin
(data + i)^ := arr[i];
end;
end;
procedure Point2DCopyFromPtr(data: Point2DPtr; len: LongInt; out arr: Point2DArray);
var
i: LongInt;
begin
if len < 0 then raise Exception.Create('Length of array cannot be negative');
SetLength(arr, len);
for i := 0 to len - 1 do
begin
arr[i] := (data + i)^;
end;
end;
procedure Point2DCopyToPtr(const arr: Point2DArray; len: LongInt; data: Point2DPtr);
var
i: LongInt;
begin
if len < Length(arr) then raise Exception.Create('Error in array size to call expected length to be ' + IntToStr(len));
for i := Low(arr) to High(arr) do
begin
(data + i)^ := arr[i];
end;
end;
procedure StringCopyFromPtr(str: StringPtr; len: LongInt; out arr: StringArray);
var
i: LongInt;
begin
if len < 0 then raise Exception.Create('Length of array cannot be negative');
SetLength(arr, len);
for i := 0 to len - 1 do
begin
StrCopy(PChar(arr[i]), PChar((str + i)^));
end;
end;
procedure StringCopyToPtr(const arr: StringArray; len: LongInt; str: StringPtr);
var
i: LongInt;
begin
if len < Length(arr) then raise Exception.Create('Error in array size to call expected length to be ' + IntToStr(len));
for i := Low(arr) to High(arr) do
begin
StrCopy(PChar((str + i)^), PChar(arr[i]));
end;
end;
function sg_Animation_AnimationCurrentCell(anim: Animation): LongInt; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Animation_AnimationCurrentCell');
{$ENDIF}
try
result := sgAnimations.AnimationCurrentCell(anim);
Except on exc: Exception do
TrapException(exc, 'sg_Animation_AnimationCurrentCell');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Animation_AnimationCurrentCell');
{$ENDIF}
end;
function sg_Animation_AnimationEnded(anim: Animation): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Animation_AnimationEnded');
{$ENDIF}
try
result := sgAnimations.AnimationEnded(anim);
Except on exc: Exception do
TrapException(exc, 'sg_Animation_AnimationEnded');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Animation_AnimationEnded');
{$ENDIF}
end;
function sg_Animation_AnimationEnteredFrame(anim: Animation): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Animation_AnimationEnteredFrame');
{$ENDIF}
try
result := sgAnimations.AnimationEnteredFrame(anim);
Except on exc: Exception do
TrapException(exc, 'sg_Animation_AnimationEnteredFrame');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Animation_AnimationEnteredFrame');
{$ENDIF}
end;
function sg_Animation_AnimationFrameTime(anim: Animation): Single; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Animation_AnimationFrameTime');
{$ENDIF}
try
result := sgAnimations.AnimationFrameTime(anim);
Except on exc: Exception do
TrapException(exc, 'sg_Animation_AnimationFrameTime');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Animation_AnimationFrameTime');
{$ENDIF}
end;
function sg_Animation_AnimationIndex(temp: AnimationTemplate; name: PChar): LongInt; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Animation_AnimationIndex');
{$ENDIF}
try
result := sgAnimations.AnimationIndex(temp, name);
Except on exc: Exception do
TrapException(exc, 'sg_Animation_AnimationIndex');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Animation_AnimationIndex');
{$ENDIF}
end;
procedure sg_Animation_AnimationName(temp: AnimationTemplate; idx: LongInt; result: PChar); cdecl; export;
var
result_temp: String;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Animation_AnimationName');
{$ENDIF}
try
result_temp := sgAnimations.AnimationName(temp, idx);
StrCopy(result, PChar(result_temp));
Except on exc: Exception do
TrapException(exc, 'sg_Animation_AnimationName');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Animation_AnimationName');
{$ENDIF}
end;
function sg_Animation_AnimationTemplateNamed(name: PChar): AnimationTemplate; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Animation_AnimationTemplateNamed');
{$ENDIF}
try
result := sgAnimations.AnimationTemplateNamed(name);
Except on exc: Exception do
TrapException(exc, 'sg_Animation_AnimationTemplateNamed');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Animation_AnimationTemplateNamed');
{$ENDIF}
end;
procedure sg_Animation_AssignAnimation(anim: Animation; idx: LongInt; frames: AnimationTemplate); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Animation_AssignAnimation');
{$ENDIF}
try
sgAnimations.AssignAnimation(anim, idx, frames);
Except on exc: Exception do
TrapException(exc, 'sg_Animation_AssignAnimation');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Animation_AssignAnimation');
{$ENDIF}
end;
procedure sg_Animation_AssignAnimationNamed(anim: Animation; name: PChar; frames: AnimationTemplate); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Animation_AssignAnimationNamed');
{$ENDIF}
try
sgAnimations.AssignAnimation(anim, name, frames);
Except on exc: Exception do
TrapException(exc, 'sg_Animation_AssignAnimationNamed');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Animation_AssignAnimationNamed');
{$ENDIF}
end;
procedure sg_Animation_AssignAnimationNamedWithSound(anim: Animation; name: PChar; frames: AnimationTemplate; withSound: Boolean); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Animation_AssignAnimationNamedWithSound');
{$ENDIF}
try
sgAnimations.AssignAnimation(anim, name, frames, withSound);
Except on exc: Exception do
TrapException(exc, 'sg_Animation_AssignAnimationNamedWithSound');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Animation_AssignAnimationNamedWithSound');
{$ENDIF}
end;
procedure sg_Animation_AssignAnimationWithSound(anim: Animation; idx: LongInt; frames: AnimationTemplate; withSound: Boolean); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Animation_AssignAnimationWithSound');
{$ENDIF}
try
sgAnimations.AssignAnimation(anim, idx, frames, withSound);
Except on exc: Exception do
TrapException(exc, 'sg_Animation_AssignAnimationWithSound');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Animation_AssignAnimationWithSound');
{$ENDIF}
end;
function sg_Animation_CreateAnimation(identifier: LongInt; frames: AnimationTemplate; withSound: Boolean): Animation; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Animation_CreateAnimation');
{$ENDIF}
try
result := sgAnimations.CreateAnimation(identifier, frames, withSound);
Except on exc: Exception do
TrapException(exc, 'sg_Animation_CreateAnimation');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Animation_CreateAnimation');
{$ENDIF}
end;
function sg_Animation_CreateAnimationNamed(identifier: PChar; frames: AnimationTemplate): Animation; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Animation_CreateAnimationNamed');
{$ENDIF}
try
result := sgAnimations.CreateAnimation(identifier, frames);
Except on exc: Exception do
TrapException(exc, 'sg_Animation_CreateAnimationNamed');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Animation_CreateAnimationNamed');
{$ENDIF}
end;
function sg_Animation_CreateAnimationNamedWithSound(identifier: PChar; frames: AnimationTemplate; withSound: Boolean): Animation; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Animation_CreateAnimationNamedWithSound');
{$ENDIF}
try
result := sgAnimations.CreateAnimation(identifier, frames, withSound);
Except on exc: Exception do
TrapException(exc, 'sg_Animation_CreateAnimationNamedWithSound');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Animation_CreateAnimationNamedWithSound');
{$ENDIF}
end;
function sg_Animation_CreateAnimationWithSound(identifier: LongInt; frames: AnimationTemplate): Animation; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Animation_CreateAnimationWithSound');
{$ENDIF}
try
result := sgAnimations.CreateAnimation(identifier, frames);
Except on exc: Exception do
TrapException(exc, 'sg_Animation_CreateAnimationWithSound');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Animation_CreateAnimationWithSound');
{$ENDIF}
end;
procedure sg_Animation_DrawAnimation(ani: Animation; bmp: Bitmap; x: LongInt; y: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Animation_DrawAnimation');
{$ENDIF}
try
sgAnimations.DrawAnimation(ani, bmp, x, y);
Except on exc: Exception do
TrapException(exc, 'sg_Animation_DrawAnimation');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Animation_DrawAnimation');
{$ENDIF}
end;
procedure sg_Animation_DrawAnimationAtPoint(ani: Animation; bmp: Bitmap; var pt: Point2D); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Animation_DrawAnimationAtPoint');
{$ENDIF}
try
sgAnimations.DrawAnimation(ani, bmp, pt);
Except on exc: Exception do
TrapException(exc, 'sg_Animation_DrawAnimationAtPoint');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Animation_DrawAnimationAtPoint');
{$ENDIF}
end;
procedure sg_Animation_DrawAnimationOnScreen(ani: Animation; bmp: Bitmap; x: LongInt; y: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Animation_DrawAnimationOnScreen');
{$ENDIF}
try
sgAnimations.DrawAnimationOnScreen(ani, bmp, x, y);
Except on exc: Exception do
TrapException(exc, 'sg_Animation_DrawAnimationOnScreen');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Animation_DrawAnimationOnScreen');
{$ENDIF}
end;
procedure sg_Animation_DrawAnimationOnScreenAtPt(ani: Animation; bmp: Bitmap; var pt: Point2D); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Animation_DrawAnimationOnScreenAtPt');
{$ENDIF}
try
sgAnimations.DrawAnimationOnScreen(ani, bmp, pt);
Except on exc: Exception do
TrapException(exc, 'sg_Animation_DrawAnimationOnScreenAtPt');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Animation_DrawAnimationOnScreenAtPt');
{$ENDIF}
end;
procedure sg_Animation_DrawAnimationOntoDest(dest: Bitmap; ani: Animation; bmp: Bitmap; x: LongInt; y: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Animation_DrawAnimationOntoDest');
{$ENDIF}
try
sgAnimations.DrawAnimation(dest, ani, bmp, x, y);
Except on exc: Exception do
TrapException(exc, 'sg_Animation_DrawAnimationOntoDest');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Animation_DrawAnimationOntoDest');
{$ENDIF}
end;
procedure sg_Animation_DrawAnimationOntoDestAtPt(dest: Bitmap; ani: Animation; bmp: Bitmap; var pt: Point2D); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Animation_DrawAnimationOntoDestAtPt');
{$ENDIF}
try
sgAnimations.DrawAnimation(dest, ani, bmp, pt);
Except on exc: Exception do
TrapException(exc, 'sg_Animation_DrawAnimationOntoDestAtPt');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Animation_DrawAnimationOntoDestAtPt');
{$ENDIF}
end;
procedure sg_Animation_FreeAnimation(var ani: Animation); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Animation_FreeAnimation');
{$ENDIF}
try
sgAnimations.FreeAnimation(ani);
Except on exc: Exception do
TrapException(exc, 'sg_Animation_FreeAnimation');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Animation_FreeAnimation');
{$ENDIF}
end;
procedure sg_Animation_FreeAnimationTemplate(var framesToFree: AnimationTemplate); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Animation_FreeAnimationTemplate');
{$ENDIF}
try
sgAnimations.FreeAnimationTemplate(framesToFree);
Except on exc: Exception do
TrapException(exc, 'sg_Animation_FreeAnimationTemplate');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Animation_FreeAnimationTemplate');
{$ENDIF}
end;
function sg_Animation_HasAnimationTemplate(name: PChar): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Animation_HasAnimationTemplate');
{$ENDIF}
try
result := sgAnimations.HasAnimationTemplate(name);
Except on exc: Exception do
TrapException(exc, 'sg_Animation_HasAnimationTemplate');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Animation_HasAnimationTemplate');
{$ENDIF}
end;
function sg_Animation_LoadAnimationTemplate(filename: PChar): AnimationTemplate; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Animation_LoadAnimationTemplate');
{$ENDIF}
try
result := sgAnimations.LoadAnimationTemplate(filename);
Except on exc: Exception do
TrapException(exc, 'sg_Animation_LoadAnimationTemplate');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Animation_LoadAnimationTemplate');
{$ENDIF}
end;
function sg_Animation_MapAnimationTemplate(name: PChar; filename: PChar): AnimationTemplate; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Animation_MapAnimationTemplate');
{$ENDIF}
try
result := sgAnimations.MapAnimationTemplate(name, filename);
Except on exc: Exception do
TrapException(exc, 'sg_Animation_MapAnimationTemplate');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Animation_MapAnimationTemplate');
{$ENDIF}
end;
procedure sg_Animation_ReleaseAllAnimationTemplates(); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Animation_ReleaseAllAnimationTemplates');
{$ENDIF}
try
sgAnimations.ReleaseAllAnimationTemplates();
Except on exc: Exception do
TrapException(exc, 'sg_Animation_ReleaseAllAnimationTemplates');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Animation_ReleaseAllAnimationTemplates');
{$ENDIF}
end;
procedure sg_Animation_ReleaseAnimationTemplate(name: PChar); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Animation_ReleaseAnimationTemplate');
{$ENDIF}
try
sgAnimations.ReleaseAnimationTemplate(name);
Except on exc: Exception do
TrapException(exc, 'sg_Animation_ReleaseAnimationTemplate');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Animation_ReleaseAnimationTemplate');
{$ENDIF}
end;
procedure sg_Animation_ResetAnimation(anim: Animation); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Animation_ResetAnimation');
{$ENDIF}
try
sgAnimations.RestartAnimation(anim);
Except on exc: Exception do
TrapException(exc, 'sg_Animation_ResetAnimation');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Animation_ResetAnimation');
{$ENDIF}
end;
procedure sg_Animation_ResetAnimationWithSound(anim: Animation; withSound: Boolean); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Animation_ResetAnimationWithSound');
{$ENDIF}
try
sgAnimations.RestartAnimation(anim, withSound);
Except on exc: Exception do
TrapException(exc, 'sg_Animation_ResetAnimationWithSound');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Animation_ResetAnimationWithSound');
{$ENDIF}
end;
procedure sg_Animation_UpdateAnimation(anim: Animation); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Animation_UpdateAnimation');
{$ENDIF}
try
sgAnimations.UpdateAnimation(anim);
Except on exc: Exception do
TrapException(exc, 'sg_Animation_UpdateAnimation');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Animation_UpdateAnimation');
{$ENDIF}
end;
procedure sg_Animation_UpdateAnimationPct(anim: Animation; pct: Single); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Animation_UpdateAnimationPct');
{$ENDIF}
try
sgAnimations.UpdateAnimation(anim, pct);
Except on exc: Exception do
TrapException(exc, 'sg_Animation_UpdateAnimationPct');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Animation_UpdateAnimationPct');
{$ENDIF}
end;
procedure sg_Animation_UpdateAnimationPctAndSound(anim: Animation; pct: Single; withSound: Boolean); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Animation_UpdateAnimationPctAndSound');
{$ENDIF}
try
sgAnimations.UpdateAnimation(anim, pct, withSound);
Except on exc: Exception do
TrapException(exc, 'sg_Animation_UpdateAnimationPctAndSound');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Animation_UpdateAnimationPctAndSound');
{$ENDIF}
end;
function sg_Audio_AudioReady(): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Audio_AudioReady');
{$ENDIF}
try
result := sgAudio.AudioReady();
Except on exc: Exception do
TrapException(exc, 'sg_Audio_AudioReady');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Audio_AudioReady');
{$ENDIF}
end;
procedure sg_Audio_CloseAudio(); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Audio_CloseAudio');
{$ENDIF}
try
sgAudio.CloseAudio();
Except on exc: Exception do
TrapException(exc, 'sg_Audio_CloseAudio');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Audio_CloseAudio');
{$ENDIF}
end;
procedure sg_Audio_FadeMusicIn(mus: Music; ms: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Audio_FadeMusicIn');
{$ENDIF}
try
sgAudio.FadeMusicIn(mus, ms);
Except on exc: Exception do
TrapException(exc, 'sg_Audio_FadeMusicIn');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Audio_FadeMusicIn');
{$ENDIF}
end;
procedure sg_Audio_FadeMusicInWithLoops(mus: Music; loops: LongInt; ms: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Audio_FadeMusicInWithLoops');
{$ENDIF}
try
sgAudio.FadeMusicIn(mus, loops, ms);
Except on exc: Exception do
TrapException(exc, 'sg_Audio_FadeMusicInWithLoops');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Audio_FadeMusicInWithLoops');
{$ENDIF}
end;
procedure sg_Audio_FadeMusicOut(ms: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Audio_FadeMusicOut');
{$ENDIF}
try
sgAudio.FadeMusicOut(ms);
Except on exc: Exception do
TrapException(exc, 'sg_Audio_FadeMusicOut');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Audio_FadeMusicOut');
{$ENDIF}
end;
procedure sg_Audio_FreeMusic(var mus: Music); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Audio_FreeMusic');
{$ENDIF}
try
sgAudio.FreeMusic(mus);
Except on exc: Exception do
TrapException(exc, 'sg_Audio_FreeMusic');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Audio_FreeMusic');
{$ENDIF}
end;
procedure sg_Audio_FreeSoundEffect(var effect: SoundEffect); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Audio_FreeSoundEffect');
{$ENDIF}
try
sgAudio.FreeSoundEffect(effect);
Except on exc: Exception do
TrapException(exc, 'sg_Audio_FreeSoundEffect');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Audio_FreeSoundEffect');
{$ENDIF}
end;
function sg_Audio_HasMusic(name: PChar): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Audio_HasMusic');
{$ENDIF}
try
result := sgAudio.HasMusic(name);
Except on exc: Exception do
TrapException(exc, 'sg_Audio_HasMusic');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Audio_HasMusic');
{$ENDIF}
end;
function sg_Audio_HasSoundEffect(name: PChar): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Audio_HasSoundEffect');
{$ENDIF}
try
result := sgAudio.HasSoundEffect(name);
Except on exc: Exception do
TrapException(exc, 'sg_Audio_HasSoundEffect');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Audio_HasSoundEffect');
{$ENDIF}
end;
function sg_Audio_LoadMusic(filename: PChar): Music; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Audio_LoadMusic');
{$ENDIF}
try
result := sgAudio.LoadMusic(filename);
Except on exc: Exception do
TrapException(exc, 'sg_Audio_LoadMusic');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Audio_LoadMusic');
{$ENDIF}
end;
function sg_Audio_LoadSoundEffect(filename: PChar): SoundEffect; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Audio_LoadSoundEffect');
{$ENDIF}
try
result := sgAudio.LoadSoundEffect(filename);
Except on exc: Exception do
TrapException(exc, 'sg_Audio_LoadSoundEffect');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Audio_LoadSoundEffect');
{$ENDIF}
end;
function sg_Audio_MapMusic(name: PChar; filename: PChar): Music; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Audio_MapMusic');
{$ENDIF}
try
result := sgAudio.MapMusic(name, filename);
Except on exc: Exception do
TrapException(exc, 'sg_Audio_MapMusic');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Audio_MapMusic');
{$ENDIF}
end;
function sg_Audio_MapSoundEffect(name: PChar; filename: PChar): SoundEffect; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Audio_MapSoundEffect');
{$ENDIF}
try
result := sgAudio.MapSoundEffect(name, filename);
Except on exc: Exception do
TrapException(exc, 'sg_Audio_MapSoundEffect');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Audio_MapSoundEffect');
{$ENDIF}
end;
procedure sg_Audio_MusicFilename(mus: Music; result: PChar); cdecl; export;
var
result_temp: String;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Audio_MusicFilename');
{$ENDIF}
try
result_temp := sgAudio.MusicFilename(mus);
StrCopy(result, PChar(result_temp));
Except on exc: Exception do
TrapException(exc, 'sg_Audio_MusicFilename');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Audio_MusicFilename');
{$ENDIF}
end;
procedure sg_Audio_MusicName(mus: Music; result: PChar); cdecl; export;
var
result_temp: String;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Audio_MusicName');
{$ENDIF}
try
result_temp := sgAudio.MusicName(mus);
StrCopy(result, PChar(result_temp));
Except on exc: Exception do
TrapException(exc, 'sg_Audio_MusicName');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Audio_MusicName');
{$ENDIF}
end;
function sg_Audio_MusicNamed(name: PChar): Music; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Audio_MusicNamed');
{$ENDIF}
try
result := sgAudio.MusicNamed(name);
Except on exc: Exception do
TrapException(exc, 'sg_Audio_MusicNamed');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Audio_MusicNamed');
{$ENDIF}
end;
function sg_Audio_MusicPlaying(): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Audio_MusicPlaying');
{$ENDIF}
try
result := sgAudio.MusicPlaying();
Except on exc: Exception do
TrapException(exc, 'sg_Audio_MusicPlaying');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Audio_MusicPlaying');
{$ENDIF}
end;
function sg_Audio_MusicVolume(): Single; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Audio_MusicVolume');
{$ENDIF}
try
result := sgAudio.MusicVolume();
Except on exc: Exception do
TrapException(exc, 'sg_Audio_MusicVolume');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Audio_MusicVolume');
{$ENDIF}
end;
procedure sg_Audio_OpenAudio(); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Audio_OpenAudio');
{$ENDIF}
try
sgAudio.OpenAudio();
Except on exc: Exception do
TrapException(exc, 'sg_Audio_OpenAudio');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Audio_OpenAudio');
{$ENDIF}
end;
procedure sg_Audio_PlayMusicWithLoops(mus: Music; loops: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Audio_PlayMusicWithLoops');
{$ENDIF}
try
sgAudio.PlayMusic(mus, loops);
Except on exc: Exception do
TrapException(exc, 'sg_Audio_PlayMusicWithLoops');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Audio_PlayMusicWithLoops');
{$ENDIF}
end;
procedure sg_Audio_PlaySoundEffectWithLoopAndVolume(effect: SoundEffect; loops: LongInt; vol: Single); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Audio_PlaySoundEffectWithLoopAndVolume');
{$ENDIF}
try
sgAudio.PlaySoundEffect(effect, loops, vol);
Except on exc: Exception do
TrapException(exc, 'sg_Audio_PlaySoundEffectWithLoopAndVolume');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Audio_PlaySoundEffectWithLoopAndVolume');
{$ENDIF}
end;
procedure sg_Audio_ReleaseAllMusic(); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Audio_ReleaseAllMusic');
{$ENDIF}
try
sgAudio.ReleaseAllMusic();
Except on exc: Exception do
TrapException(exc, 'sg_Audio_ReleaseAllMusic');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Audio_ReleaseAllMusic');
{$ENDIF}
end;
procedure sg_Audio_ReleaseAllSoundEffects(); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Audio_ReleaseAllSoundEffects');
{$ENDIF}
try
sgAudio.ReleaseAllSoundEffects();
Except on exc: Exception do
TrapException(exc, 'sg_Audio_ReleaseAllSoundEffects');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Audio_ReleaseAllSoundEffects');
{$ENDIF}
end;
procedure sg_Audio_ReleaseMusic(name: PChar); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Audio_ReleaseMusic');
{$ENDIF}
try
sgAudio.ReleaseMusic(name);
Except on exc: Exception do
TrapException(exc, 'sg_Audio_ReleaseMusic');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Audio_ReleaseMusic');
{$ENDIF}
end;
procedure sg_Audio_ReleaseSoundEffect(name: PChar); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Audio_ReleaseSoundEffect');
{$ENDIF}
try
sgAudio.ReleaseSoundEffect(name);
Except on exc: Exception do
TrapException(exc, 'sg_Audio_ReleaseSoundEffect');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Audio_ReleaseSoundEffect');
{$ENDIF}
end;
procedure sg_Audio_SetMusicVolume(value: Single); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Audio_SetMusicVolume');
{$ENDIF}
try
sgAudio.SetMusicVolume(value);
Except on exc: Exception do
TrapException(exc, 'sg_Audio_SetMusicVolume');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Audio_SetMusicVolume');
{$ENDIF}
end;
procedure sg_Audio_SoundEffectFilename(effect: SoundEffect; result: PChar); cdecl; export;
var
result_temp: String;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Audio_SoundEffectFilename');
{$ENDIF}
try
result_temp := sgAudio.SoundEffectFilename(effect);
StrCopy(result, PChar(result_temp));
Except on exc: Exception do
TrapException(exc, 'sg_Audio_SoundEffectFilename');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Audio_SoundEffectFilename');
{$ENDIF}
end;
procedure sg_Audio_SoundEffectName(effect: SoundEffect; result: PChar); cdecl; export;
var
result_temp: String;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Audio_SoundEffectName');
{$ENDIF}
try
result_temp := sgAudio.SoundEffectName(effect);
StrCopy(result, PChar(result_temp));
Except on exc: Exception do
TrapException(exc, 'sg_Audio_SoundEffectName');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Audio_SoundEffectName');
{$ENDIF}
end;
function sg_Audio_SoundEffectNamed(name: PChar): SoundEffect; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Audio_SoundEffectNamed');
{$ENDIF}
try
result := sgAudio.SoundEffectNamed(name);
Except on exc: Exception do
TrapException(exc, 'sg_Audio_SoundEffectNamed');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Audio_SoundEffectNamed');
{$ENDIF}
end;
function sg_Audio_SoundEffectPlaying(effect: SoundEffect): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Audio_SoundEffectPlaying');
{$ENDIF}
try
result := sgAudio.SoundEffectPlaying(effect);
Except on exc: Exception do
TrapException(exc, 'sg_Audio_SoundEffectPlaying');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Audio_SoundEffectPlaying');
{$ENDIF}
end;
procedure sg_Audio_StopMusic(); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Audio_StopMusic');
{$ENDIF}
try
sgAudio.StopMusic();
Except on exc: Exception do
TrapException(exc, 'sg_Audio_StopMusic');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Audio_StopMusic');
{$ENDIF}
end;
procedure sg_Audio_StopSoundEffect(effect: SoundEffect); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Audio_StopSoundEffect');
{$ENDIF}
try
sgAudio.StopSoundEffect(effect);
Except on exc: Exception do
TrapException(exc, 'sg_Audio_StopSoundEffect');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Audio_StopSoundEffect');
{$ENDIF}
end;
function sg_Audio_TryOpenAudio(): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Audio_TryOpenAudio');
{$ENDIF}
try
result := sgAudio.TryOpenAudio();
Except on exc: Exception do
TrapException(exc, 'sg_Audio_TryOpenAudio');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Audio_TryOpenAudio');
{$ENDIF}
end;
function sg_Camera_CameraPos(): Point2D; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Camera_CameraPos');
{$ENDIF}
try
result := sgCamera.CameraPos();
Except on exc: Exception do
TrapException(exc, 'sg_Camera_CameraPos');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Camera_CameraPos');
{$ENDIF}
end;
function sg_Camera_CameraScreenRect(): Rectangle; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Camera_CameraScreenRect');
{$ENDIF}
try
result := sgCamera.CameraScreenRect();
Except on exc: Exception do
TrapException(exc, 'sg_Camera_CameraScreenRect');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Camera_CameraScreenRect');
{$ENDIF}
end;
function sg_Camera_CameraX(): Single; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Camera_CameraX');
{$ENDIF}
try
result := sgCamera.CameraX();
Except on exc: Exception do
TrapException(exc, 'sg_Camera_CameraX');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Camera_CameraX');
{$ENDIF}
end;
function sg_Camera_CameraY(): Single; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Camera_CameraY');
{$ENDIF}
try
result := sgCamera.CameraY();
Except on exc: Exception do
TrapException(exc, 'sg_Camera_CameraY');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Camera_CameraY');
{$ENDIF}
end;
procedure sg_Camera_CenterCameraOn(s: Sprite; var offset: Vector); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Camera_CenterCameraOn');
{$ENDIF}
try
sgCamera.CenterCameraOn(s, offset);
Except on exc: Exception do
TrapException(exc, 'sg_Camera_CenterCameraOn');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Camera_CenterCameraOn');
{$ENDIF}
end;
procedure sg_Camera_CenterCameraOnCharacter(c: Character; var offset: Vector); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Camera_CenterCameraOnCharacter');
{$ENDIF}
try
sgCamera.CenterCameraOn(c, offset);
Except on exc: Exception do
TrapException(exc, 'sg_Camera_CenterCameraOnCharacter');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Camera_CenterCameraOnCharacter');
{$ENDIF}
end;
procedure sg_Camera_CenterCameraOnWithXYOffset(s: Sprite; offsetX: LongInt; offsetY: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Camera_CenterCameraOnWithXYOffset');
{$ENDIF}
try
sgCamera.CenterCameraOn(s, offsetX, offsetY);
Except on exc: Exception do
TrapException(exc, 'sg_Camera_CenterCameraOnWithXYOffset');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Camera_CenterCameraOnWithXYOffset');
{$ENDIF}
end;
procedure sg_Camera_MoveCameraBy(var offset: Vector); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Camera_MoveCameraBy');
{$ENDIF}
try
sgCamera.MoveCameraBy(offset);
Except on exc: Exception do
TrapException(exc, 'sg_Camera_MoveCameraBy');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Camera_MoveCameraBy');
{$ENDIF}
end;
procedure sg_Camera_MoveCameraByXY(dx: Single; dy: Single); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Camera_MoveCameraByXY');
{$ENDIF}
try
sgCamera.MoveCameraBy(dx, dy);
Except on exc: Exception do
TrapException(exc, 'sg_Camera_MoveCameraByXY');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Camera_MoveCameraByXY');
{$ENDIF}
end;
procedure sg_Camera_MoveCameraTo(var pt: Point2D); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Camera_MoveCameraTo');
{$ENDIF}
try
sgCamera.MoveCameraTo(pt);
Except on exc: Exception do
TrapException(exc, 'sg_Camera_MoveCameraTo');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Camera_MoveCameraTo');
{$ENDIF}
end;
procedure sg_Camera_MoveCameraToXY(x: Single; y: Single); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Camera_MoveCameraToXY');
{$ENDIF}
try
sgCamera.MoveCameraTo(x, y);
Except on exc: Exception do
TrapException(exc, 'sg_Camera_MoveCameraToXY');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Camera_MoveCameraToXY');
{$ENDIF}
end;
function sg_Camera_PointOnScreen(var pt: Point2D): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Camera_PointOnScreen');
{$ENDIF}
try
result := sgCamera.PointOnScreen(pt);
Except on exc: Exception do
TrapException(exc, 'sg_Camera_PointOnScreen');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Camera_PointOnScreen');
{$ENDIF}
end;
function sg_Camera_RectOnScreen(var rect: Rectangle): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Camera_RectOnScreen');
{$ENDIF}
try
result := sgCamera.RectOnScreen(rect);
Except on exc: Exception do
TrapException(exc, 'sg_Camera_RectOnScreen');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Camera_RectOnScreen');
{$ENDIF}
end;
procedure sg_Camera_SetCameraPos(var value: Point2D); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Camera_SetCameraPos');
{$ENDIF}
try
sgCamera.SetCameraPos(value);
Except on exc: Exception do
TrapException(exc, 'sg_Camera_SetCameraPos');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Camera_SetCameraPos');
{$ENDIF}
end;
procedure sg_Camera_SetCameraX(value: Single); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Camera_SetCameraX');
{$ENDIF}
try
sgCamera.SetCameraX(value);
Except on exc: Exception do
TrapException(exc, 'sg_Camera_SetCameraX');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Camera_SetCameraX');
{$ENDIF}
end;
procedure sg_Camera_SetCameraY(value: Single); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Camera_SetCameraY');
{$ENDIF}
try
sgCamera.SetCameraY(value);
Except on exc: Exception do
TrapException(exc, 'sg_Camera_SetCameraY');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Camera_SetCameraY');
{$ENDIF}
end;
function sg_Camera_ToScreen(var worldPoint: Point2D): Point2D; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Camera_ToScreen');
{$ENDIF}
try
result := sgCamera.ToScreen(worldPoint);
Except on exc: Exception do
TrapException(exc, 'sg_Camera_ToScreen');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Camera_ToScreen');
{$ENDIF}
end;
function sg_Camera_ToScreenRect(var rect: Rectangle): Rectangle; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Camera_ToScreenRect');
{$ENDIF}
try
result := sgCamera.ToScreen(rect);
Except on exc: Exception do
TrapException(exc, 'sg_Camera_ToScreenRect');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Camera_ToScreenRect');
{$ENDIF}
end;
function sg_Camera_ToScreenX(worldX: Single): LongInt; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Camera_ToScreenX');
{$ENDIF}
try
result := sgCamera.ToScreenX(worldX);
Except on exc: Exception do
TrapException(exc, 'sg_Camera_ToScreenX');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Camera_ToScreenX');
{$ENDIF}
end;
function sg_Camera_ToScreenY(worldY: Single): LongInt; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Camera_ToScreenY');
{$ENDIF}
try
result := sgCamera.ToScreenY(worldY);
Except on exc: Exception do
TrapException(exc, 'sg_Camera_ToScreenY');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Camera_ToScreenY');
{$ENDIF}
end;
function sg_Camera_ToWorld(var screenPoint: Point2D): Point2D; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Camera_ToWorld');
{$ENDIF}
try
result := sgCamera.ToWorld(screenPoint);
Except on exc: Exception do
TrapException(exc, 'sg_Camera_ToWorld');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Camera_ToWorld');
{$ENDIF}
end;
function sg_Camera_ToWorldX(screenX: LongInt): Single; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Camera_ToWorldX');
{$ENDIF}
try
result := sgCamera.ToWorldX(screenX);
Except on exc: Exception do
TrapException(exc, 'sg_Camera_ToWorldX');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Camera_ToWorldX');
{$ENDIF}
end;
function sg_Camera_ToWorldY(screenY: LongInt): Single; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Camera_ToWorldY');
{$ENDIF}
try
result := sgCamera.ToWorldY(screenY);
Except on exc: Exception do
TrapException(exc, 'sg_Camera_ToWorldY');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Camera_ToWorldY');
{$ENDIF}
end;
function sg_Core_BlueOf(c: LongWord): Byte; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Core_BlueOf');
{$ENDIF}
try
result := sgCore.BlueOf(c);
Except on exc: Exception do
TrapException(exc, 'sg_Core_BlueOf');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Core_BlueOf');
{$ENDIF}
end;
function sg_Core_BrightnessOf(c: LongWord): Single; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Core_BrightnessOf');
{$ENDIF}
try
result := sgCore.BrightnessOf(c);
Except on exc: Exception do
TrapException(exc, 'sg_Core_BrightnessOf');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Core_BrightnessOf');
{$ENDIF}
end;
procedure sg_Core_CalculateFramerate(average: PChar; highest: PChar; lowest: PChar; out textColor: LongWord); cdecl; export;
var
average_temp: String;
highest_temp: String;
lowest_temp: String;
textColor_temp: Color;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Core_CalculateFramerate');
{$ENDIF}
try
sgCore.CalculateFramerate(average_temp, highest_temp, lowest_temp, textColor_temp);
StrCopy(average, PChar(average_temp));
StrCopy(highest, PChar(highest_temp));
StrCopy(lowest, PChar(lowest_temp));
textColor := textColor_temp;
Except on exc: Exception do
TrapException(exc, 'sg_Core_CalculateFramerate');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Core_CalculateFramerate');
{$ENDIF}
end;
procedure sg_Core_ChangeScreenSize(width: LongInt; height: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Core_ChangeScreenSize');
{$ENDIF}
try
sgCore.ChangeScreenSize(width, height);
Except on exc: Exception do
TrapException(exc, 'sg_Core_ChangeScreenSize');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Core_ChangeScreenSize');
{$ENDIF}
end;
procedure sg_Core_ColorComponents(c: LongWord; out r: Byte; out g: Byte; out b: Byte; out a: Byte); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Core_ColorComponents');
{$ENDIF}
try
sgCore.ColorComponents(c, r, g, b, a);
Except on exc: Exception do
TrapException(exc, 'sg_Core_ColorComponents');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Core_ColorComponents');
{$ENDIF}
end;
function sg_Core_ColorFromBitmap(bmp: Bitmap; apiColor: LongWord): Color; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Core_ColorFromBitmap');
{$ENDIF}
try
result := sgCore.ColorFrom(bmp, apiColor);
Except on exc: Exception do
TrapException(exc, 'sg_Core_ColorFromBitmap');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Core_ColorFromBitmap');
{$ENDIF}
end;
procedure sg_Core_ColorToString(c: LongWord; result: PChar); cdecl; export;
var
result_temp: String;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Core_ColorToString');
{$ENDIF}
try
result_temp := sgCore.ColorToString(c);
StrCopy(result, PChar(result_temp));
Except on exc: Exception do
TrapException(exc, 'sg_Core_ColorToString');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Core_ColorToString');
{$ENDIF}
end;
procedure sg_Core_Delay(time: UInt32); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Core_Delay');
{$ENDIF}
try
sgCore.Delay(time);
Except on exc: Exception do
TrapException(exc, 'sg_Core_Delay');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Core_Delay');
{$ENDIF}
end;
procedure sg_Core_ExceptionMessage(result: PChar); cdecl; export;
var
result_temp: String;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Core_ExceptionMessage');
{$ENDIF}
try
result_temp := sgCore.ExceptionMessage();
StrCopy(result, PChar(result_temp));
Except on exc: Exception do
TrapException(exc, 'sg_Core_ExceptionMessage');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Core_ExceptionMessage');
{$ENDIF}
end;
function sg_Core_ExceptionOccured(): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Core_ExceptionOccured');
{$ENDIF}
try
result := sgCore.ExceptionOccured();
Except on exc: Exception do
TrapException(exc, 'sg_Core_ExceptionOccured');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Core_ExceptionOccured');
{$ENDIF}
end;
function sg_Core_GetFramerate(): LongInt; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Core_GetFramerate');
{$ENDIF}
try
result := sgCore.GetFramerate();
Except on exc: Exception do
TrapException(exc, 'sg_Core_GetFramerate');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Core_GetFramerate');
{$ENDIF}
end;
function sg_Core_GetTicks(): UInt32; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Core_GetTicks');
{$ENDIF}
try
result := sgCore.GetTicks();
Except on exc: Exception do
TrapException(exc, 'sg_Core_GetTicks');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Core_GetTicks');
{$ENDIF}
end;
function sg_Core_GreenOf(c: LongWord): Byte; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Core_GreenOf');
{$ENDIF}
try
result := sgCore.GreenOf(c);
Except on exc: Exception do
TrapException(exc, 'sg_Core_GreenOf');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Core_GreenOf');
{$ENDIF}
end;
function sg_Core_HSBColor(hue: Single; saturation: Single; brightness: Single): Color; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Core_HSBColor');
{$ENDIF}
try
result := sgCore.HSBColor(hue, saturation, brightness);
Except on exc: Exception do
TrapException(exc, 'sg_Core_HSBColor');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Core_HSBColor');
{$ENDIF}
end;
procedure sg_Core_HSBValuesOf(c: LongWord; out h: Single; out s: Single; out b: Single); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Core_HSBValuesOf');
{$ENDIF}
try
sgCore.HSBValuesOf(c, h, s, b);
Except on exc: Exception do
TrapException(exc, 'sg_Core_HSBValuesOf');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Core_HSBValuesOf');
{$ENDIF}
end;
function sg_Core_HueOf(c: LongWord): Single; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Core_HueOf');
{$ENDIF}
try
result := sgCore.HueOf(c);
Except on exc: Exception do
TrapException(exc, 'sg_Core_HueOf');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Core_HueOf');
{$ENDIF}
end;
procedure sg_Core_OpenGraphicsWindow(caption: PChar; width: LongInt; height: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Core_OpenGraphicsWindow');
{$ENDIF}
try
sgCore.OpenGraphicsWindow(caption, width, height);
Except on exc: Exception do
TrapException(exc, 'sg_Core_OpenGraphicsWindow');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Core_OpenGraphicsWindow');
{$ENDIF}
end;
procedure sg_Core_ProcessEvents(); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Core_ProcessEvents');
{$ENDIF}
try
sgCore.ProcessEvents();
Except on exc: Exception do
TrapException(exc, 'sg_Core_ProcessEvents');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Core_ProcessEvents');
{$ENDIF}
end;
function sg_Core_RGBAColor(red: Byte; green: Byte; blue: Byte; alpha: Byte): Color; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Core_RGBAColor');
{$ENDIF}
try
result := sgCore.RGBAColor(red, green, blue, alpha);
Except on exc: Exception do
TrapException(exc, 'sg_Core_RGBAColor');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Core_RGBAColor');
{$ENDIF}
end;
function sg_Core_RGBAFloatColor(r: Single; g: Single; b: Single; a: Single): Color; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Core_RGBAFloatColor');
{$ENDIF}
try
result := sgCore.RGBAFloatColor(r, g, b, a);
Except on exc: Exception do
TrapException(exc, 'sg_Core_RGBAFloatColor');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Core_RGBAFloatColor');
{$ENDIF}
end;
function sg_Core_RGBFloatColor(r: Single; g: Single; b: Single): Color; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Core_RGBFloatColor');
{$ENDIF}
try
result := sgCore.RGBFloatColor(r, g, b);
Except on exc: Exception do
TrapException(exc, 'sg_Core_RGBFloatColor');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Core_RGBFloatColor');
{$ENDIF}
end;
function sg_Core_RandomColor(): Color; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Core_RandomColor');
{$ENDIF}
try
result := sgCore.RandomColor();
Except on exc: Exception do
TrapException(exc, 'sg_Core_RandomColor');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Core_RandomColor');
{$ENDIF}
end;
function sg_Core_RandomRGBColor(alpha: Byte): Color; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Core_RandomRGBColor');
{$ENDIF}
try
result := sgCore.RandomRGBColor(alpha);
Except on exc: Exception do
TrapException(exc, 'sg_Core_RandomRGBColor');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Core_RandomRGBColor');
{$ENDIF}
end;
function sg_Core_RedOf(c: LongWord): Byte; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Core_RedOf');
{$ENDIF}
try
result := sgCore.RedOf(c);
Except on exc: Exception do
TrapException(exc, 'sg_Core_RedOf');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Core_RedOf');
{$ENDIF}
end;
procedure sg_Core_RefreshScreen(); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Core_RefreshScreen');
{$ENDIF}
try
sgCore.RefreshScreen();
Except on exc: Exception do
TrapException(exc, 'sg_Core_RefreshScreen');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Core_RefreshScreen');
{$ENDIF}
end;
procedure sg_Core_RefreshScreenRestrictFPS(TargetFPS: UInt32); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Core_RefreshScreenRestrictFPS');
{$ENDIF}
try
sgCore.RefreshScreen(TargetFPS);
Except on exc: Exception do
TrapException(exc, 'sg_Core_RefreshScreenRestrictFPS');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Core_RefreshScreenRestrictFPS');
{$ENDIF}
end;
function sg_Core_Rnd(): Single; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Core_Rnd');
{$ENDIF}
try
result := sgCore.Rnd();
Except on exc: Exception do
TrapException(exc, 'sg_Core_Rnd');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Core_Rnd');
{$ENDIF}
end;
function sg_Core_RndUpto(ubound: LongInt): LongInt; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Core_RndUpto');
{$ENDIF}
try
result := sgCore.Rnd(ubound);
Except on exc: Exception do
TrapException(exc, 'sg_Core_RndUpto');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Core_RndUpto');
{$ENDIF}
end;
function sg_Core_SaturationOf(c: LongWord): Single; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Core_SaturationOf');
{$ENDIF}
try
result := sgCore.SaturationOf(c);
Except on exc: Exception do
TrapException(exc, 'sg_Core_SaturationOf');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Core_SaturationOf');
{$ENDIF}
end;
function sg_Core_ScreenHeight(): LongInt; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Core_ScreenHeight');
{$ENDIF}
try
result := sgCore.ScreenHeight();
Except on exc: Exception do
TrapException(exc, 'sg_Core_ScreenHeight');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Core_ScreenHeight');
{$ENDIF}
end;
function sg_Core_ScreenWidth(): LongInt; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Core_ScreenWidth');
{$ENDIF}
try
result := sgCore.ScreenWidth();
Except on exc: Exception do
TrapException(exc, 'sg_Core_ScreenWidth');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Core_ScreenWidth');
{$ENDIF}
end;
procedure sg_Core_SetIcon(filename: PChar); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Core_SetIcon');
{$ENDIF}
try
sgCore.SetIcon(filename);
Except on exc: Exception do
TrapException(exc, 'sg_Core_SetIcon');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Core_SetIcon');
{$ENDIF}
end;
procedure sg_Core_SwinGameVersion(result: PChar); cdecl; export;
var
result_temp: String;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Core_SwinGameVersion');
{$ENDIF}
try
result_temp := sgCore.SwinGameVersion();
StrCopy(result, PChar(result_temp));
Except on exc: Exception do
TrapException(exc, 'sg_Core_SwinGameVersion');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Core_SwinGameVersion');
{$ENDIF}
end;
procedure sg_Core_TakeScreenshot(basename: PChar); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Core_TakeScreenshot');
{$ENDIF}
try
sgCore.TakeScreenshot(basename);
Except on exc: Exception do
TrapException(exc, 'sg_Core_TakeScreenshot');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Core_TakeScreenshot');
{$ENDIF}
end;
procedure sg_Core_ToggleFullScreen(); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Core_ToggleFullScreen');
{$ENDIF}
try
sgCore.ToggleFullScreen();
Except on exc: Exception do
TrapException(exc, 'sg_Core_ToggleFullScreen');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Core_ToggleFullScreen');
{$ENDIF}
end;
procedure sg_Core_ToggleWindowBorder(); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Core_ToggleWindowBorder');
{$ENDIF}
try
sgCore.ToggleWindowBorder();
Except on exc: Exception do
TrapException(exc, 'sg_Core_ToggleWindowBorder');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Core_ToggleWindowBorder');
{$ENDIF}
end;
function sg_Core_TransparencyOf(c: LongWord): Byte; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Core_TransparencyOf');
{$ENDIF}
try
result := sgCore.TransparencyOf(c);
Except on exc: Exception do
TrapException(exc, 'sg_Core_TransparencyOf');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Core_TransparencyOf');
{$ENDIF}
end;
function sg_Core_WindowCloseRequested(): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Core_WindowCloseRequested');
{$ENDIF}
try
result := sgCore.WindowCloseRequested();
Except on exc: Exception do
TrapException(exc, 'sg_Core_WindowCloseRequested');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Core_WindowCloseRequested');
{$ENDIF}
end;
function sg_Geometry_AddVectors(var v1: Vector; var v2: Vector): Vector; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_AddVectors');
{$ENDIF}
try
result := sgGeometry.AddVectors(v1, v2);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_AddVectors');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_AddVectors');
{$ENDIF}
end;
procedure sg_Geometry_ApplyMatrix(m: SinglePtr; tri: Point2DPtr); cdecl; export;
var
m_temp: Matrix2D;
tri_temp: Triangle;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_ApplyMatrix');
{$ENDIF}
try
MatrixCopyFromPtr(m_temp, m);
TriCopyFromPtr(tri_temp, tri);
sgGeometry.ApplyMatrix(m_temp, tri_temp);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_ApplyMatrix');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_ApplyMatrix');
{$ENDIF}
end;
procedure sg_Geometry_ApplyMatrixToPoints(m: SinglePtr; pts: Point2DPtr; pts_len: LongInt); cdecl; export;
var
m_temp: Matrix2D;
pts_temp: Point2DArray;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_ApplyMatrixToPoints');
{$ENDIF}
try
MatrixCopyFromPtr(m_temp, m);
Point2DCopyFromPtr(pts, pts_len, pts_temp);
sgGeometry.ApplyMatrix(m_temp, pts_temp);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_ApplyMatrixToPoints');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_ApplyMatrixToPoints');
{$ENDIF}
end;
function sg_Geometry_CalculateAngle(x1: Single; y1: Single; x2: Single; y2: Single): Single; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_CalculateAngle');
{$ENDIF}
try
result := sgGeometry.CalculateAngle(x1, y1, x2, y2);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_CalculateAngle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_CalculateAngle');
{$ENDIF}
end;
function sg_Geometry_CalculateAngleBetween(var pt1: Point2D; var pt2: Point2D): Single; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_CalculateAngleBetween');
{$ENDIF}
try
result := sgGeometry.CalculateAngleBetween(pt1, pt2);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_CalculateAngleBetween');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_CalculateAngleBetween');
{$ENDIF}
end;
function sg_Geometry_CalculateAngleBetweenSprites(s1: Sprite; s2: Sprite): Single; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_CalculateAngleBetweenSprites');
{$ENDIF}
try
result := sgGeometry.CalculateAngle(s1, s2);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_CalculateAngleBetweenSprites');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_CalculateAngleBetweenSprites');
{$ENDIF}
end;
function sg_Geometry_CalculateAngleBetweenVectors(var v1: Vector; var v2: Vector): Single; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_CalculateAngleBetweenVectors');
{$ENDIF}
try
result := sgGeometry.CalculateAngle(v1, v2);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_CalculateAngleBetweenVectors');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_CalculateAngleBetweenVectors');
{$ENDIF}
end;
function sg_Geometry_CircleAt(var pt: Point2D; radius: LongInt): Circle; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_CircleAt');
{$ENDIF}
try
result := sgGeometry.CircleAt(pt, radius);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_CircleAt');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_CircleAt');
{$ENDIF}
end;
function sg_Geometry_CircleCenterPoint(var c: Circle): Point2D; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_CircleCenterPoint');
{$ENDIF}
try
result := sgGeometry.CenterPoint(c);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_CircleCenterPoint');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_CircleCenterPoint');
{$ENDIF}
end;
function sg_Geometry_CircleFromXY(x: Single; y: Single; radius: LongInt): Circle; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_CircleFromXY');
{$ENDIF}
try
result := sgGeometry.CircleAt(x, y, radius);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_CircleFromXY');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_CircleFromXY');
{$ENDIF}
end;
function sg_Geometry_CirclePrototypeFrom(var pt: Point2D; r: Single): ShapePrototype; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_CirclePrototypeFrom');
{$ENDIF}
try
result := sgGeometry.CirclePrototypeFrom(pt, r);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_CirclePrototypeFrom');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_CirclePrototypeFrom');
{$ENDIF}
end;
function sg_Geometry_CircleRadius(var c: Circle): LongInt; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_CircleRadius');
{$ENDIF}
try
result := sgGeometry.CircleRadius(c);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_CircleRadius');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_CircleRadius');
{$ENDIF}
end;
function sg_Geometry_CircleWithinRect(var c: Circle; var rect: Rectangle): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_CircleWithinRect');
{$ENDIF}
try
result := sgGeometry.CircleWithinRect(c, rect);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_CircleWithinRect');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_CircleWithinRect');
{$ENDIF}
end;
function sg_Geometry_CircleX(var c: Circle): Single; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_CircleX');
{$ENDIF}
try
result := sgGeometry.CircleX(c);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_CircleX');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_CircleX');
{$ENDIF}
end;
function sg_Geometry_CircleY(var c: Circle): Single; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_CircleY');
{$ENDIF}
try
result := sgGeometry.CircleY(c);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_CircleY');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_CircleY');
{$ENDIF}
end;
function sg_Geometry_ClosestPointOnCircle(var fromPt: Point2D; var c: Circle): Point2D; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_ClosestPointOnCircle');
{$ENDIF}
try
result := sgGeometry.ClosestPointOnCircle(fromPt, c);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_ClosestPointOnCircle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_ClosestPointOnCircle');
{$ENDIF}
end;
function sg_Geometry_ClosestPointOnLine(var fromPt: Point2D; var line: LineSegment): Point2D; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_ClosestPointOnLine');
{$ENDIF}
try
result := sgGeometry.ClosestPointOnLine(fromPt, line);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_ClosestPointOnLine');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_ClosestPointOnLine');
{$ENDIF}
end;
function sg_Geometry_ClosestPointOnLineFromCircle(var c: Circle; var line: LineSegment): Point2D; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_ClosestPointOnLineFromCircle');
{$ENDIF}
try
result := sgGeometry.ClosestPointOnLineFromCircle(c, line);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_ClosestPointOnLineFromCircle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_ClosestPointOnLineFromCircle');
{$ENDIF}
end;
function sg_Geometry_ClosestPointOnLineXY(x: Single; y: Single; var line: LineSegment): Point2D; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_ClosestPointOnLineXY');
{$ENDIF}
try
result := sgGeometry.ClosestPointOnLine(x, y, line);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_ClosestPointOnLineXY');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_ClosestPointOnLineXY');
{$ENDIF}
end;
function sg_Geometry_ClosestPointOnLinesFromCircle(var c: Circle; lines: LineSegmentPtr; lines_len: LongInt): Point2D; cdecl; export;
var
lines_temp: LinesArray;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_ClosestPointOnLinesFromCircle');
{$ENDIF}
try
LineCopyFromPtr(lines, lines_len, lines_temp);
result := sgGeometry.ClosestPointOnLinesFromCircle(c, lines_temp);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_ClosestPointOnLinesFromCircle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_ClosestPointOnLinesFromCircle');
{$ENDIF}
end;
function sg_Geometry_ClosestPointOnRectFromCircle(var c: Circle; var rect: Rectangle): Point2D; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_ClosestPointOnRectFromCircle');
{$ENDIF}
try
result := sgGeometry.ClosestPointOnRectFromCircle(c, rect);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_ClosestPointOnRectFromCircle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_ClosestPointOnRectFromCircle');
{$ENDIF}
end;
function sg_Geometry_Cosine(angle: Single): Single; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_Cosine');
{$ENDIF}
try
result := sgGeometry.Cosine(angle);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_Cosine');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_Cosine');
{$ENDIF}
end;
function sg_Geometry_DistantPointOnCircle(var pt: Point2D; var c: Circle): Point2D; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_DistantPointOnCircle');
{$ENDIF}
try
result := sgGeometry.DistantPointOnCircle(pt, c);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_DistantPointOnCircle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_DistantPointOnCircle');
{$ENDIF}
end;
function sg_Geometry_DistantPointOnCircleHeading(var pt: Point2D; var c: Circle; var heading: Vector; out oppositePt: Point2D): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_DistantPointOnCircleHeading');
{$ENDIF}
try
result := sgGeometry.DistantPointOnCircleHeading(pt, c, heading, oppositePt);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_DistantPointOnCircleHeading');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_DistantPointOnCircleHeading');
{$ENDIF}
end;
function sg_Geometry_DotProduct(var v1: Vector; var v2: Vector): Single; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_DotProduct');
{$ENDIF}
try
result := sgGeometry.DotProduct(v1, v2);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_DotProduct');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_DotProduct');
{$ENDIF}
end;
procedure sg_Geometry_FixRect(var x: Single; var y: Single; width: LongInt; height: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_FixRect');
{$ENDIF}
try
sgGeometry.FixRectangle(x, y, width, height);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_FixRect');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_FixRect');
{$ENDIF}
end;
procedure sg_Geometry_FixRectangle(var rect: Rectangle); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_FixRectangle');
{$ENDIF}
try
sgGeometry.FixRectangle(rect);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_FixRectangle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_FixRectangle');
{$ENDIF}
end;
procedure sg_Geometry_FreePrototype(var p: ShapePrototype); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_FreePrototype');
{$ENDIF}
try
sgGeometry.FreePrototype(p);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_FreePrototype');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_FreePrototype');
{$ENDIF}
end;
procedure sg_Geometry_FreeShape(var s: Shape); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_FreeShape');
{$ENDIF}
try
sgGeometry.FreeShape(s);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_FreeShape');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_FreeShape');
{$ENDIF}
end;
procedure sg_Geometry_IdentityMatrix(result: SinglePtr); cdecl; export;
var
result_temp: Matrix2D;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_IdentityMatrix');
{$ENDIF}
try
result_temp := sgGeometry.IdentityMatrix();
MatrixCopyToPtr(result, result_temp);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_IdentityMatrix');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_IdentityMatrix');
{$ENDIF}
end;
function sg_Geometry_InsetRectangle(var rect: Rectangle; insetAmount: LongInt): Rectangle; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_InsetRectangle');
{$ENDIF}
try
result := sgGeometry.InsetRectangle(rect, insetAmount);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_InsetRectangle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_InsetRectangle');
{$ENDIF}
end;
function sg_Geometry_Intersection(var rect1: Rectangle; var rect2: Rectangle): Rectangle; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_Intersection');
{$ENDIF}
try
result := sgGeometry.Intersection(rect1, rect2);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_Intersection');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_Intersection');
{$ENDIF}
end;
function sg_Geometry_InvertVector(var v: Vector): Vector; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_InvertVector');
{$ENDIF}
try
result := sgGeometry.InvertVector(v);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_InvertVector');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_InvertVector');
{$ENDIF}
end;
function sg_Geometry_LimitVector(var v: Vector; limit: Single): Vector; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_LimitVector');
{$ENDIF}
try
result := sgGeometry.LimitVector(v, limit);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_LimitVector');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_LimitVector');
{$ENDIF}
end;
function sg_Geometry_LineAsVector(var line: LineSegment): Vector; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_LineAsVector');
{$ENDIF}
try
result := sgGeometry.LineAsVector(line);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_LineAsVector');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_LineAsVector');
{$ENDIF}
end;
function sg_Geometry_LineCircleHit(var c: Circle; var velocity: Vector; lines: LineSegmentPtr; out found: LineSegment; lines_len: LongInt): Boolean; cdecl; export;
var
lines_temp: LinesArray;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_LineCircleHit');
{$ENDIF}
try
LineCopyFromPtr(lines, lines_len, lines_temp);
result := sgGeometry.LineCircleHit(c, velocity, lines_temp, found);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_LineCircleHit');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_LineCircleHit');
{$ENDIF}
end;
function sg_Geometry_LineCount(s: Shape): LongInt; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_LineCount');
{$ENDIF}
try
result := sgGeometry.LineCount(s);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_LineCount');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_LineCount');
{$ENDIF}
end;
function sg_Geometry_LineFrom(x1: Single; y1: Single; x2: Single; y2: Single): LineSegment; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_LineFrom');
{$ENDIF}
try
result := sgGeometry.LineFrom(x1, y1, x2, y2);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_LineFrom');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_LineFrom');
{$ENDIF}
end;
function sg_Geometry_LineFromPointToPoint(var pt1: Point2D; var pt2: Point2D): LineSegment; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_LineFromPointToPoint');
{$ENDIF}
try
result := sgGeometry.LineFrom(pt1, pt2);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_LineFromPointToPoint');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_LineFromPointToPoint');
{$ENDIF}
end;
function sg_Geometry_LineFromVector(var mv: Vector): LineSegment; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_LineFromVector');
{$ENDIF}
try
result := sgGeometry.LineFromVector(mv);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_LineFromVector');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_LineFromVector');
{$ENDIF}
end;
function sg_Geometry_LineFromVectorWithStartPoint(var pt: Point2D; var mv: Vector): LineSegment; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_LineFromVectorWithStartPoint');
{$ENDIF}
try
result := sgGeometry.LineFromVector(pt, mv);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_LineFromVectorWithStartPoint');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_LineFromVectorWithStartPoint');
{$ENDIF}
end;
function sg_Geometry_LineFromVectorWithStartXY(x: Single; y: Single; var mv: Vector): LineSegment; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_LineFromVectorWithStartXY');
{$ENDIF}
try
result := sgGeometry.LineFromVector(x, y, mv);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_LineFromVectorWithStartXY');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_LineFromVectorWithStartXY');
{$ENDIF}
end;
function sg_Geometry_LineIntersectionPoint(var line1: LineSegment; var line2: LineSegment; out pt: Point2D): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_LineIntersectionPoint');
{$ENDIF}
try
result := sgGeometry.LineIntersectionPoint(line1, line2, pt);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_LineIntersectionPoint');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_LineIntersectionPoint');
{$ENDIF}
end;
function sg_Geometry_LineIntersectsCircle(var l: LineSegment; var c: Circle): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_LineIntersectsCircle');
{$ENDIF}
try
result := sgGeometry.LineIntersectsCircle(l, c);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_LineIntersectsCircle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_LineIntersectsCircle');
{$ENDIF}
end;
function sg_Geometry_LineIntersectsLines(var line: LineSegment; lines: LineSegmentPtr; lines_len: LongInt): Boolean; cdecl; export;
var
lines_temp: LinesArray;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_LineIntersectsLines');
{$ENDIF}
try
LineCopyFromPtr(lines, lines_len, lines_temp);
result := sgGeometry.LineIntersectsLines(line, lines_temp);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_LineIntersectsLines');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_LineIntersectsLines');
{$ENDIF}
end;
function sg_Geometry_LineIntersectsRect(var line: LineSegment; var rect: Rectangle): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_LineIntersectsRect');
{$ENDIF}
try
result := sgGeometry.LineIntersectsRect(line, rect);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_LineIntersectsRect');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_LineIntersectsRect');
{$ENDIF}
end;
function sg_Geometry_LineListPrototypeFrom(points: Point2DPtr; points_len: LongInt): ShapePrototype; cdecl; export;
var
points_temp: Point2DArray;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_LineListPrototypeFrom');
{$ENDIF}
try
Point2DCopyFromPtr(points, points_len, points_temp);
result := sgGeometry.LineListPrototypeFrom(points_temp);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_LineListPrototypeFrom');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_LineListPrototypeFrom');
{$ENDIF}
end;
function sg_Geometry_LineMagnitudeSq(x1: Single; y1: Single; x2: Single; y2: Single): Single; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_LineMagnitudeSq');
{$ENDIF}
try
result := sgGeometry.LineMagnitudeSq(x1, y1, x2, y2);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_LineMagnitudeSq');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_LineMagnitudeSq');
{$ENDIF}
end;
function sg_Geometry_LineMagnitudeSqFromLine(var line: LineSegment): Single; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_LineMagnitudeSqFromLine');
{$ENDIF}
try
result := sgGeometry.LineMagnitudeSq(line);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_LineMagnitudeSqFromLine');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_LineMagnitudeSqFromLine');
{$ENDIF}
end;
function sg_Geometry_LineMidPoint(var line: LineSegment): Point2D; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_LineMidPoint');
{$ENDIF}
try
result := sgGeometry.LineMidPoint(line);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_LineMidPoint');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_LineMidPoint');
{$ENDIF}
end;
function sg_Geometry_LineNormal(var line: LineSegment): Vector; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_LineNormal');
{$ENDIF}
try
result := sgGeometry.LineNormal(line);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_LineNormal');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_LineNormal');
{$ENDIF}
end;
function sg_Geometry_LinePrototypeFrom(var startPt: Point2D; var endPt: Point2D): ShapePrototype; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_LinePrototypeFrom');
{$ENDIF}
try
result := sgGeometry.LinePrototypeFrom(startPt, endPt);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_LinePrototypeFrom');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_LinePrototypeFrom');
{$ENDIF}
end;
function sg_Geometry_LineSegmentsIntersect(var line1: LineSegment; var line2: LineSegment): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_LineSegmentsIntersect');
{$ENDIF}
try
result := sgGeometry.LineSegmentsIntersect(line1, line2);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_LineSegmentsIntersect');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_LineSegmentsIntersect');
{$ENDIF}
end;
function sg_Geometry_LineStripPrototypeFrom(points: Point2DPtr; points_len: LongInt): ShapePrototype; cdecl; export;
var
points_temp: Point2DArray;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_LineStripPrototypeFrom');
{$ENDIF}
try
Point2DCopyFromPtr(points, points_len, points_temp);
result := sgGeometry.LineStripPrototypeFrom(points_temp);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_LineStripPrototypeFrom');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_LineStripPrototypeFrom');
{$ENDIF}
end;
procedure sg_Geometry_LineToString(var ln: LineSegment; result: PChar); cdecl; export;
var
result_temp: String;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_LineToString');
{$ENDIF}
try
result_temp := sgGeometry.LineToString(ln);
StrCopy(result, PChar(result_temp));
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_LineToString');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_LineToString');
{$ENDIF}
end;
procedure sg_Geometry_LinesFromRect(var rect: Rectangle; result: LineSegmentPtr; result_len: LongInt); cdecl; export;
var
result_temp: LinesArray;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_LinesFromRect');
{$ENDIF}
try
result_temp := sgGeometry.LinesFrom(rect);
LineCopyToPtr(result_temp, result_len, result);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_LinesFromRect');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_LinesFromRect');
{$ENDIF}
end;
procedure sg_Geometry_LinesFromShape(s: Shape; result: LineSegmentPtr; result_len: LongInt); cdecl; export;
var
result_temp: LinesArray;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_LinesFromShape');
{$ENDIF}
try
result_temp := sgGeometry.LinesFrom(s);
LineCopyToPtr(result_temp, result_len, result);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_LinesFromShape');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_LinesFromShape');
{$ENDIF}
end;
procedure sg_Geometry_LinesFromTriangle(tri: Point2DPtr; result: LineSegmentPtr; result_len: LongInt); cdecl; export;
var
tri_temp: Triangle;
result_temp: LinesArray;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_LinesFromTriangle');
{$ENDIF}
try
TriCopyFromPtr(tri_temp, tri);
result_temp := sgGeometry.LinesFrom(tri_temp);
LineCopyToPtr(result_temp, result_len, result);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_LinesFromTriangle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_LinesFromTriangle');
{$ENDIF}
end;
procedure sg_Geometry_MatrixMultiply(m1: SinglePtr; m2: SinglePtr; result: SinglePtr); cdecl; export;
var
m1_temp: Matrix2D;
m2_temp: Matrix2D;
result_temp: Matrix2D;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_MatrixMultiply');
{$ENDIF}
try
MatrixCopyFromPtr(m1_temp, m1);
MatrixCopyFromPtr(m2_temp, m2);
result_temp := sgGeometry.MatrixMultiply(m1_temp, m2_temp);
MatrixCopyToPtr(result, result_temp);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_MatrixMultiply');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_MatrixMultiply');
{$ENDIF}
end;
function sg_Geometry_MatrixMultiplyVector(m: SinglePtr; var v: Vector): Vector; cdecl; export;
var
m_temp: Matrix2D;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_MatrixMultiplyVector');
{$ENDIF}
try
MatrixCopyFromPtr(m_temp, m);
result := sgGeometry.MatrixMultiply(m_temp, v);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_MatrixMultiplyVector');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_MatrixMultiplyVector');
{$ENDIF}
end;
procedure sg_Geometry_MatrixToString(m: SinglePtr; result: PChar); cdecl; export;
var
m_temp: Matrix2D;
result_temp: String;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_MatrixToString');
{$ENDIF}
try
MatrixCopyFromPtr(m_temp, m);
result_temp := sgGeometry.MatrixToString(m_temp);
StrCopy(result, PChar(result_temp));
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_MatrixToString');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_MatrixToString');
{$ENDIF}
end;
function sg_Geometry_MinimumPointsForKind(k: ShapeKind): LongInt; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_MinimumPointsForKind');
{$ENDIF}
try
result := sgGeometry.MinimumPointsForKind(k);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_MinimumPointsForKind');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_MinimumPointsForKind');
{$ENDIF}
end;
function sg_Geometry_PointAdd(var pt1: Point2D; var pt2: Point2D): Point2D; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_PointAdd');
{$ENDIF}
try
result := sgGeometry.PointAdd(pt1, pt2);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_PointAdd');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_PointAdd');
{$ENDIF}
end;
function sg_Geometry_PointAt(x: Single; y: Single): Point2D; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_PointAt');
{$ENDIF}
try
result := sgGeometry.PointAt(x, y);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_PointAt');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_PointAt');
{$ENDIF}
end;
function sg_Geometry_PointAtStartWithOffset(var startPoint: Point2D; var offset: Vector): Point2D; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_PointAtStartWithOffset');
{$ENDIF}
try
result := sgGeometry.PointAt(startPoint, offset);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_PointAtStartWithOffset');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_PointAtStartWithOffset');
{$ENDIF}
end;
function sg_Geometry_PointInCircle(var pt: Point2D; var c: Circle): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_PointInCircle');
{$ENDIF}
try
result := sgGeometry.PointInCircle(pt, c);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_PointInCircle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_PointInCircle');
{$ENDIF}
end;
function sg_Geometry_PointInRect(var pt: Point2D; var rect: Rectangle): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_PointInRect');
{$ENDIF}
try
result := sgGeometry.PointInRect(pt, rect);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_PointInRect');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_PointInRect');
{$ENDIF}
end;
function sg_Geometry_PointInRectXY(var pt: Point2D; x: Single; y: Single; w: Single; h: Single): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_PointInRectXY');
{$ENDIF}
try
result := sgGeometry.PointInRect(pt, x, y, w, h);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_PointInRectXY');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_PointInRectXY');
{$ENDIF}
end;
function sg_Geometry_PointInShape(var pt: Point2D; s: Shape): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_PointInShape');
{$ENDIF}
try
result := sgGeometry.PointInShape(pt, s);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_PointInShape');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_PointInShape');
{$ENDIF}
end;
function sg_Geometry_PointInTriangle(var pt: Point2D; tri: Point2DPtr): Boolean; cdecl; export;
var
tri_temp: Triangle;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_PointInTriangle');
{$ENDIF}
try
TriCopyFromPtr(tri_temp, tri);
result := sgGeometry.PointInTriangle(pt, tri_temp);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_PointInTriangle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_PointInTriangle');
{$ENDIF}
end;
function sg_Geometry_PointLineDistance(var pt: Point2D; var line: LineSegment): Single; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_PointLineDistance');
{$ENDIF}
try
result := sgGeometry.PointLineDistance(pt, line);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_PointLineDistance');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_PointLineDistance');
{$ENDIF}
end;
function sg_Geometry_PointOnLine(var pt: Point2D; var line: LineSegment): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_PointOnLine');
{$ENDIF}
try
result := sgGeometry.PointOnLine(pt, line);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_PointOnLine');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_PointOnLine');
{$ENDIF}
end;
function sg_Geometry_PointPointDistance(var pt1: Point2D; var pt2: Point2D): Single; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_PointPointDistance');
{$ENDIF}
try
result := sgGeometry.PointPointDistance(pt1, pt2);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_PointPointDistance');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_PointPointDistance');
{$ENDIF}
end;
function sg_Geometry_PointPrototypeFrom(var pt: Point2D): ShapePrototype; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_PointPrototypeFrom');
{$ENDIF}
try
result := sgGeometry.PointPrototypeFrom(pt);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_PointPrototypeFrom');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_PointPrototypeFrom');
{$ENDIF}
end;
procedure sg_Geometry_PointToString(var pt: Point2D; result: PChar); cdecl; export;
var
result_temp: String;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_PointToString');
{$ENDIF}
try
result_temp := sgGeometry.PointToString(pt);
StrCopy(result, PChar(result_temp));
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_PointToString');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_PointToString');
{$ENDIF}
end;
function sg_Geometry_PointXYInRect(x: Single; y: Single; var rect: Rectangle): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_PointXYInRect');
{$ENDIF}
try
result := sgGeometry.PointInRect(x, y, rect);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_PointXYInRect');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_PointXYInRect');
{$ENDIF}
end;
function sg_Geometry_PointXYInRectXY(ptX: Single; ptY: Single; x: Single; y: Single; w: Single; h: Single): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_PointXYInRectXY');
{$ENDIF}
try
result := sgGeometry.PointInRect(ptX, ptY, x, y, w, h);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_PointXYInRectXY');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_PointXYInRectXY');
{$ENDIF}
end;
function sg_Geometry_PointXYLineDistance(x: Single; y: Single; var line: LineSegment): Single; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_PointXYLineDistance');
{$ENDIF}
try
result := sgGeometry.PointLineDistance(x, y, line);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_PointXYLineDistance');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_PointXYLineDistance');
{$ENDIF}
end;
procedure sg_Geometry_PointsFromLine(var line: LineSegment; result: Point2DPtr; result_len: LongInt); cdecl; export;
var
result_temp: Point2DArray;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_PointsFromLine');
{$ENDIF}
try
result_temp := sgGeometry.PointsFrom(line);
Point2DCopyToPtr(result_temp, result_len, result);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_PointsFromLine');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_PointsFromLine');
{$ENDIF}
end;
procedure sg_Geometry_PointsFromRect(var rect: Rectangle; result: Point2DPtr; result_len: LongInt); cdecl; export;
var
result_temp: Point2DArray;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_PointsFromRect');
{$ENDIF}
try
result_temp := sgGeometry.PointsFrom(rect);
Point2DCopyToPtr(result_temp, result_len, result);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_PointsFromRect');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_PointsFromRect');
{$ENDIF}
end;
function sg_Geometry_PrototypeFrom(points: Point2DPtr; kind: ShapeKind; points_len: LongInt): ShapePrototype; cdecl; export;
var
points_temp: Point2DArray;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_PrototypeFrom');
{$ENDIF}
try
Point2DCopyFromPtr(points, points_len, points_temp);
result := sgGeometry.PrototypeFrom(points_temp, kind);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_PrototypeFrom');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_PrototypeFrom');
{$ENDIF}
end;
function sg_Geometry_PrototypeKind(p: ShapePrototype): ShapeKind; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_PrototypeKind');
{$ENDIF}
try
result := sgGeometry.PrototypeKind(p);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_PrototypeKind');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_PrototypeKind');
{$ENDIF}
end;
function sg_Geometry_PrototypePointCount(p: ShapePrototype): LongInt; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_PrototypePointCount');
{$ENDIF}
try
result := sgGeometry.PrototypePointCount(p);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_PrototypePointCount');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_PrototypePointCount');
{$ENDIF}
end;
procedure sg_Geometry_PrototypePoints(p: ShapePrototype; result: Point2DPtr; result_len: LongInt); cdecl; export;
var
result_temp: Point2DArray;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_PrototypePoints');
{$ENDIF}
try
result_temp := sgGeometry.PrototypePoints(p);
Point2DCopyToPtr(result_temp, result_len, result);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_PrototypePoints');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_PrototypePoints');
{$ENDIF}
end;
procedure sg_Geometry_PrototypeSetKind(p: ShapePrototype; value: ShapeKind); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_PrototypeSetKind');
{$ENDIF}
try
sgGeometry.PrototypeSetKind(p, value);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_PrototypeSetKind');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_PrototypeSetKind');
{$ENDIF}
end;
procedure sg_Geometry_PrototypeSetPoints(p: ShapePrototype; value: Point2DPtr; value_len: LongInt); cdecl; export;
var
value_temp: Point2DArray;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_PrototypeSetPoints');
{$ENDIF}
try
Point2DCopyFromPtr(value, value_len, value_temp);
sgGeometry.PrototypeSetPoints(p, value_temp);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_PrototypeSetPoints');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_PrototypeSetPoints');
{$ENDIF}
end;
function sg_Geometry_RayCircleIntersectDistance(var ray_origin: Point2D; var ray_heading: Vector; var c: Circle): Single; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_RayCircleIntersectDistance');
{$ENDIF}
try
result := sgGeometry.RayCircleIntersectDistance(ray_origin, ray_heading, c);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_RayCircleIntersectDistance');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_RayCircleIntersectDistance');
{$ENDIF}
end;
function sg_Geometry_RayIntersectionPoint(var fromPt: Point2D; var heading: Vector; var line: LineSegment; out pt: Point2D): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_RayIntersectionPoint');
{$ENDIF}
try
result := sgGeometry.RayIntersectionPoint(fromPt, heading, line, pt);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_RayIntersectionPoint');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_RayIntersectionPoint');
{$ENDIF}
end;
function sg_Geometry_RectangleAfterMove(var rect: Rectangle; var mv: Vector): Rectangle; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_RectangleAfterMove');
{$ENDIF}
try
result := sgGeometry.RectangleAfterMove(rect, mv);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_RectangleAfterMove');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_RectangleAfterMove');
{$ENDIF}
end;
function sg_Geometry_RectangleAtPoint(var pt: Point2D; width: LongInt; height: LongInt): Rectangle; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_RectangleAtPoint');
{$ENDIF}
try
result := sgGeometry.RectangleFrom(pt, width, height);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_RectangleAtPoint');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_RectangleAtPoint');
{$ENDIF}
end;
function sg_Geometry_RectangleBottom(var rect: Rectangle): Single; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_RectangleBottom');
{$ENDIF}
try
result := sgGeometry.RectangleBottom(rect);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_RectangleBottom');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_RectangleBottom');
{$ENDIF}
end;
function sg_Geometry_RectangleBottomLeft(var rect: Rectangle): Point2D; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_RectangleBottomLeft');
{$ENDIF}
try
result := sgGeometry.RectangleBottomLeft(rect);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_RectangleBottomLeft');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_RectangleBottomLeft');
{$ENDIF}
end;
function sg_Geometry_RectangleBottomRight(var rect: Rectangle): Point2D; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_RectangleBottomRight');
{$ENDIF}
try
result := sgGeometry.RectangleBottomRight(rect);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_RectangleBottomRight');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_RectangleBottomRight');
{$ENDIF}
end;
function sg_Geometry_RectangleCenter(var rect: Rectangle): Point2D; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_RectangleCenter');
{$ENDIF}
try
result := sgGeometry.RectangleCenter(rect);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_RectangleCenter');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_RectangleCenter');
{$ENDIF}
end;
function sg_Geometry_RectangleCenterBottom(var rect: Rectangle): Point2D; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_RectangleCenterBottom');
{$ENDIF}
try
result := sgGeometry.RectangleCenterBottom(rect);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_RectangleCenterBottom');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_RectangleCenterBottom');
{$ENDIF}
end;
function sg_Geometry_RectangleCenterLeft(var rect: Rectangle): Point2D; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_RectangleCenterLeft');
{$ENDIF}
try
result := sgGeometry.RectangleCenterLeft(rect);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_RectangleCenterLeft');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_RectangleCenterLeft');
{$ENDIF}
end;
function sg_Geometry_RectangleCenterRight(var rect: Rectangle): Point2D; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_RectangleCenterRight');
{$ENDIF}
try
result := sgGeometry.RectangleCenterRight(rect);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_RectangleCenterRight');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_RectangleCenterRight');
{$ENDIF}
end;
function sg_Geometry_RectangleCenterTop(var rect: Rectangle): Point2D; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_RectangleCenterTop');
{$ENDIF}
try
result := sgGeometry.RectangleCenterTop(rect);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_RectangleCenterTop');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_RectangleCenterTop');
{$ENDIF}
end;
function sg_Geometry_RectangleForPoints(var pt1: Point2D; var pt2: Point2D): Rectangle; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_RectangleForPoints');
{$ENDIF}
try
result := sgGeometry.RectangleFrom(pt1, pt2);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_RectangleForPoints');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_RectangleForPoints');
{$ENDIF}
end;
function sg_Geometry_RectangleFrom(x: Single; y: Single; w: LongInt; h: LongInt): Rectangle; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_RectangleFrom');
{$ENDIF}
try
result := sgGeometry.RectangleFrom(x, y, w, h);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_RectangleFrom');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_RectangleFrom');
{$ENDIF}
end;
function sg_Geometry_RectangleFromCircle(var c: Circle): Rectangle; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_RectangleFromCircle');
{$ENDIF}
try
result := sgGeometry.RectangleFrom(c);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_RectangleFromCircle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_RectangleFromCircle');
{$ENDIF}
end;
function sg_Geometry_RectangleFromLine(var line: LineSegment): Rectangle; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_RectangleFromLine');
{$ENDIF}
try
result := sgGeometry.RectangleFrom(line);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_RectangleFromLine');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_RectangleFromLine');
{$ENDIF}
end;
function sg_Geometry_RectangleFromLines(lines: LineSegmentPtr; lines_len: LongInt): Rectangle; cdecl; export;
var
lines_temp: LinesArray;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_RectangleFromLines');
{$ENDIF}
try
LineCopyFromPtr(lines, lines_len, lines_temp);
result := sgGeometry.RectangleFrom(lines_temp);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_RectangleFromLines');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_RectangleFromLines');
{$ENDIF}
end;
function sg_Geometry_RectangleFromTriangle(tri: Point2DPtr): Rectangle; cdecl; export;
var
tri_temp: Triangle;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_RectangleFromTriangle');
{$ENDIF}
try
TriCopyFromPtr(tri_temp, tri);
result := sgGeometry.RectangleFrom(tri_temp);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_RectangleFromTriangle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_RectangleFromTriangle');
{$ENDIF}
end;
function sg_Geometry_RectangleLeft(var rect: Rectangle): Single; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_RectangleLeft');
{$ENDIF}
try
result := sgGeometry.RectangleLeft(rect);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_RectangleLeft');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_RectangleLeft');
{$ENDIF}
end;
function sg_Geometry_RectangleOffset(var rect: Rectangle; var vec: Vector): Rectangle; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_RectangleOffset');
{$ENDIF}
try
result := sgGeometry.RectangleOffset(rect, vec);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_RectangleOffset');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_RectangleOffset');
{$ENDIF}
end;
function sg_Geometry_RectangleRight(var rect: Rectangle): Single; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_RectangleRight');
{$ENDIF}
try
result := sgGeometry.RectangleRight(rect);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_RectangleRight');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_RectangleRight');
{$ENDIF}
end;
procedure sg_Geometry_RectangleToString(var rect: Rectangle; result: PChar); cdecl; export;
var
result_temp: String;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_RectangleToString');
{$ENDIF}
try
result_temp := sgGeometry.RectangleToString(rect);
StrCopy(result, PChar(result_temp));
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_RectangleToString');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_RectangleToString');
{$ENDIF}
end;
function sg_Geometry_RectangleTop(var rect: Rectangle): Single; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_RectangleTop');
{$ENDIF}
try
result := sgGeometry.RectangleTop(rect);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_RectangleTop');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_RectangleTop');
{$ENDIF}
end;
function sg_Geometry_RectangleTopLeft(var rect: Rectangle): Point2D; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_RectangleTopLeft');
{$ENDIF}
try
result := sgGeometry.RectangleTopLeft(rect);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_RectangleTopLeft');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_RectangleTopLeft');
{$ENDIF}
end;
function sg_Geometry_RectangleTopRight(var rect: Rectangle): Point2D; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_RectangleTopRight');
{$ENDIF}
try
result := sgGeometry.RectangleTopRight(rect);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_RectangleTopRight');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_RectangleTopRight');
{$ENDIF}
end;
function sg_Geometry_RectanglesIntersect(var rect1: Rectangle; var rect2: Rectangle): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_RectanglesIntersect');
{$ENDIF}
try
result := sgGeometry.RectanglesIntersect(rect1, rect2);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_RectanglesIntersect');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_RectanglesIntersect');
{$ENDIF}
end;
procedure sg_Geometry_RotationMatrix(deg: Single; result: SinglePtr); cdecl; export;
var
result_temp: Matrix2D;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_RotationMatrix');
{$ENDIF}
try
result_temp := sgGeometry.RotationMatrix(deg);
MatrixCopyToPtr(result, result_temp);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_RotationMatrix');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_RotationMatrix');
{$ENDIF}
end;
procedure sg_Geometry_ScaleMatrix(scale: Single; result: SinglePtr); cdecl; export;
var
result_temp: Matrix2D;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_ScaleMatrix');
{$ENDIF}
try
result_temp := sgGeometry.ScaleMatrix(scale);
MatrixCopyToPtr(result, result_temp);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_ScaleMatrix');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_ScaleMatrix');
{$ENDIF}
end;
procedure sg_Geometry_ScaleMatrixByPoint(var scale: Point2D; result: SinglePtr); cdecl; export;
var
result_temp: Matrix2D;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_ScaleMatrixByPoint');
{$ENDIF}
try
result_temp := sgGeometry.ScaleMatrix(scale);
MatrixCopyToPtr(result, result_temp);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_ScaleMatrixByPoint');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_ScaleMatrixByPoint');
{$ENDIF}
end;
procedure sg_Geometry_ScaleRotateTranslateMatrix(var scale: Point2D; deg: Single; var translate: Point2D; result: SinglePtr); cdecl; export;
var
result_temp: Matrix2D;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_ScaleRotateTranslateMatrix');
{$ENDIF}
try
result_temp := sgGeometry.ScaleRotateTranslateMatrix(scale, deg, translate);
MatrixCopyToPtr(result, result_temp);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_ScaleRotateTranslateMatrix');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_ScaleRotateTranslateMatrix');
{$ENDIF}
end;
function sg_Geometry_ShapeAABB(shp: Shape): Rectangle; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_ShapeAABB');
{$ENDIF}
try
result := sgGeometry.ShapeAABB(shp);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_ShapeAABB');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_ShapeAABB');
{$ENDIF}
end;
procedure sg_Geometry_ShapeAddSubShape(parent: Shape; child: Shape); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_ShapeAddSubShape');
{$ENDIF}
try
sgGeometry.ShapeAddSubShape(parent, child);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_ShapeAddSubShape');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_ShapeAddSubShape');
{$ENDIF}
end;
function sg_Geometry_ShapeAngle(s: Shape): Single; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_ShapeAngle');
{$ENDIF}
try
result := sgGeometry.ShapeAngle(s);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_ShapeAngle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_ShapeAngle');
{$ENDIF}
end;
function sg_Geometry_ShapeAtPoint(p: ShapePrototype; var pt: Point2D): Shape; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_ShapeAtPoint');
{$ENDIF}
try
result := sgGeometry.ShapeAtPoint(p, pt);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_ShapeAtPoint');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_ShapeAtPoint');
{$ENDIF}
end;
function sg_Geometry_ShapeCircle(shp: Shape): Circle; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_ShapeCircle');
{$ENDIF}
try
result := sgGeometry.ShapeCircle(shp);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_ShapeCircle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_ShapeCircle');
{$ENDIF}
end;
function sg_Geometry_ShapeCircleOffset(shp: Shape; var offset: Point2D): Circle; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_ShapeCircleOffset');
{$ENDIF}
try
result := sgGeometry.ShapeCircle(shp, offset);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_ShapeCircleOffset');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_ShapeCircleOffset');
{$ENDIF}
end;
function sg_Geometry_ShapeColor(s: Shape): Color; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_ShapeColor');
{$ENDIF}
try
result := sgGeometry.ShapeColor(s);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_ShapeColor');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_ShapeColor');
{$ENDIF}
end;
function sg_Geometry_ShapeLine(shp: Shape): LineSegment; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_ShapeLine');
{$ENDIF}
try
result := sgGeometry.ShapeLine(shp);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_ShapeLine');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_ShapeLine');
{$ENDIF}
end;
function sg_Geometry_ShapeLineOffset(shp: Shape; var offset: Point2D): LineSegment; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_ShapeLineOffset');
{$ENDIF}
try
result := sgGeometry.ShapeLine(shp, offset);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_ShapeLineOffset');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_ShapeLineOffset');
{$ENDIF}
end;
procedure sg_Geometry_ShapeLines(shp: Shape; kind: ShapeKind; result: LineSegmentPtr; result_len: LongInt); cdecl; export;
var
result_temp: LinesArray;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_ShapeLines');
{$ENDIF}
try
result_temp := sgGeometry.ShapeLines(shp, kind);
LineCopyToPtr(result_temp, result_len, result);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_ShapeLines');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_ShapeLines');
{$ENDIF}
end;
procedure sg_Geometry_ShapeLinesWithOffset(shp: Shape; kind: ShapeKind; var offset: Point2D; result: LineSegmentPtr; result_len: LongInt); cdecl; export;
var
result_temp: LinesArray;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_ShapeLinesWithOffset');
{$ENDIF}
try
result_temp := sgGeometry.ShapeLines(shp, kind, offset);
LineCopyToPtr(result_temp, result_len, result);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_ShapeLinesWithOffset');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_ShapeLinesWithOffset');
{$ENDIF}
end;
function sg_Geometry_ShapePointCount(s: Shape): LongInt; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_ShapePointCount');
{$ENDIF}
try
result := sgGeometry.ShapePointCount(s);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_ShapePointCount');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_ShapePointCount');
{$ENDIF}
end;
procedure sg_Geometry_ShapePoints(s: Shape; result: Point2DPtr; result_len: LongInt); cdecl; export;
var
result_temp: Point2DArray;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_ShapePoints');
{$ENDIF}
try
result_temp := sgGeometry.ShapePoints(s);
Point2DCopyToPtr(result_temp, result_len, result);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_ShapePoints');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_ShapePoints');
{$ENDIF}
end;
function sg_Geometry_ShapeRectangleIntersect(shp: Shape; var rect: Rectangle): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_ShapeRectangleIntersect');
{$ENDIF}
try
result := sgGeometry.ShapeRectangleIntersect(shp, rect);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_ShapeRectangleIntersect');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_ShapeRectangleIntersect');
{$ENDIF}
end;
function sg_Geometry_ShapeScale(s: Shape): Point2D; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_ShapeScale');
{$ENDIF}
try
result := sgGeometry.ShapeScale(s);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_ShapeScale');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_ShapeScale');
{$ENDIF}
end;
procedure sg_Geometry_ShapeSetAngle(s: Shape; value: Single); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_ShapeSetAngle');
{$ENDIF}
try
sgGeometry.ShapeSetAngle(s, value);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_ShapeSetAngle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_ShapeSetAngle');
{$ENDIF}
end;
procedure sg_Geometry_ShapeSetColor(s: Shape; value: LongWord); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_ShapeSetColor');
{$ENDIF}
try
sgGeometry.ShapeSetColor(s, value);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_ShapeSetColor');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_ShapeSetColor');
{$ENDIF}
end;
procedure sg_Geometry_ShapeSetPrototype(s: Shape; value: ShapePrototype); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_ShapeSetPrototype');
{$ENDIF}
try
sgGeometry.ShapeSetPrototype(s, value);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_ShapeSetPrototype');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_ShapeSetPrototype');
{$ENDIF}
end;
procedure sg_Geometry_ShapeSetScale(s: Shape; var value: Point2D); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_ShapeSetScale');
{$ENDIF}
try
sgGeometry.ShapeSetScale(s, value);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_ShapeSetScale');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_ShapeSetScale');
{$ENDIF}
end;
function sg_Geometry_ShapeShapeKind(shp: Shape): ShapeKind; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_ShapeShapeKind');
{$ENDIF}
try
result := sgGeometry.ShapeShapeKind(shp);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_ShapeShapeKind');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_ShapeShapeKind');
{$ENDIF}
end;
function sg_Geometry_ShapeShapePrototype(s: Shape): ShapePrototype; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_ShapeShapePrototype');
{$ENDIF}
try
result := sgGeometry.ShapeShapePrototype(s);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_ShapeShapePrototype');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_ShapeShapePrototype');
{$ENDIF}
end;
procedure sg_Geometry_ShapeTriangle(shp: Shape; result: Point2DPtr); cdecl; export;
var
result_temp: Triangle;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_ShapeTriangle');
{$ENDIF}
try
result_temp := sgGeometry.ShapeTriangle(shp);
TriCopyToPtr(result, result_temp);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_ShapeTriangle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_ShapeTriangle');
{$ENDIF}
end;
procedure sg_Geometry_ShapeTriangleWithOffset(shp: Shape; var offset: Point2D; result: Point2DPtr); cdecl; export;
var
result_temp: Triangle;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_ShapeTriangleWithOffset');
{$ENDIF}
try
result_temp := sgGeometry.ShapeTriangle(shp, offset);
TriCopyToPtr(result, result_temp);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_ShapeTriangleWithOffset');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_ShapeTriangleWithOffset');
{$ENDIF}
end;
procedure sg_Geometry_ShapeTriangles(shp: Shape; kind: ShapeKind; result: TrianglePtr; result_len: LongInt); cdecl; export;
var
result_temp: TriangleArray;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_ShapeTriangles');
{$ENDIF}
try
result_temp := sgGeometry.ShapeTriangles(shp, kind);
TriangleCopyToPtr(result_temp, result_len, result);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_ShapeTriangles');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_ShapeTriangles');
{$ENDIF}
end;
procedure sg_Geometry_ShapeTrianglesOffset(shp: Shape; kind: ShapeKind; var offset: Point2D; result: TrianglePtr; result_len: LongInt); cdecl; export;
var
result_temp: TriangleArray;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_ShapeTrianglesOffset');
{$ENDIF}
try
result_temp := sgGeometry.ShapeTriangles(shp, kind, offset);
TriangleCopyToPtr(result_temp, result_len, result);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_ShapeTrianglesOffset');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_ShapeTrianglesOffset');
{$ENDIF}
end;
function sg_Geometry_Sine(angle: Single): Single; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_Sine');
{$ENDIF}
try
result := sgGeometry.Sine(angle);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_Sine');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_Sine');
{$ENDIF}
end;
function sg_Geometry_SubtractVectors(var v1: Vector; var v2: Vector): Vector; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_SubtractVectors');
{$ENDIF}
try
result := sgGeometry.SubtractVectors(v1, v2);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_SubtractVectors');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_SubtractVectors');
{$ENDIF}
end;
function sg_Geometry_Tangent(angle: Single): Single; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_Tangent');
{$ENDIF}
try
result := sgGeometry.Tangent(angle);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_Tangent');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_Tangent');
{$ENDIF}
end;
function sg_Geometry_TangentPoints(var fromPt: Point2D; var c: Circle; out p1: Point2D; out p2: Point2D): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_TangentPoints');
{$ENDIF}
try
result := sgGeometry.TangentPoints(fromPt, c, p1, p2);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_TangentPoints');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_TangentPoints');
{$ENDIF}
end;
procedure sg_Geometry_TranslationMatrix(dx: Single; dy: Single; result: SinglePtr); cdecl; export;
var
result_temp: Matrix2D;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_TranslationMatrix');
{$ENDIF}
try
result_temp := sgGeometry.TranslationMatrix(dx, dy);
MatrixCopyToPtr(result, result_temp);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_TranslationMatrix');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_TranslationMatrix');
{$ENDIF}
end;
procedure sg_Geometry_TranslationMatrixPt(var pt: Point2D; result: SinglePtr); cdecl; export;
var
result_temp: Matrix2D;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_TranslationMatrixPt');
{$ENDIF}
try
result_temp := sgGeometry.TranslationMatrix(pt);
MatrixCopyToPtr(result, result_temp);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_TranslationMatrixPt');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_TranslationMatrixPt');
{$ENDIF}
end;
function sg_Geometry_TriangleBarycenter(tri: Point2DPtr): Point2D; cdecl; export;
var
tri_temp: Triangle;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_TriangleBarycenter');
{$ENDIF}
try
TriCopyFromPtr(tri_temp, tri);
result := sgGeometry.TriangleBarycenter(tri_temp);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_TriangleBarycenter');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_TriangleBarycenter');
{$ENDIF}
end;
function sg_Geometry_TriangleFanPrototypeFrom(points: Point2DPtr; points_len: LongInt): ShapePrototype; cdecl; export;
var
points_temp: Point2DArray;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_TriangleFanPrototypeFrom');
{$ENDIF}
try
Point2DCopyFromPtr(points, points_len, points_temp);
result := sgGeometry.TriangleFanPrototypeFrom(points_temp);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_TriangleFanPrototypeFrom');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_TriangleFanPrototypeFrom');
{$ENDIF}
end;
procedure sg_Geometry_TriangleFrom(ax: Single; ay: Single; bx: Single; by: Single; cx: Single; cy: Single; result: Point2DPtr); cdecl; export;
var
result_temp: Triangle;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_TriangleFrom');
{$ENDIF}
try
result_temp := sgGeometry.TriangleFrom(ax, ay, bx, by, cx, cy);
TriCopyToPtr(result, result_temp);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_TriangleFrom');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_TriangleFrom');
{$ENDIF}
end;
procedure sg_Geometry_TriangleFromPoints(var a: Point2D; var b: Point2D; var c: Point2D; result: Point2DPtr); cdecl; export;
var
result_temp: Triangle;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_TriangleFromPoints');
{$ENDIF}
try
result_temp := sgGeometry.TriangleFrom(a, b, c);
TriCopyToPtr(result, result_temp);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_TriangleFromPoints');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_TriangleFromPoints');
{$ENDIF}
end;
function sg_Geometry_TriangleListPrototypeFrom(points: Point2DPtr; points_len: LongInt): ShapePrototype; cdecl; export;
var
points_temp: Point2DArray;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_TriangleListPrototypeFrom');
{$ENDIF}
try
Point2DCopyFromPtr(points, points_len, points_temp);
result := sgGeometry.TriangleListPrototypeFrom(points_temp);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_TriangleListPrototypeFrom');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_TriangleListPrototypeFrom');
{$ENDIF}
end;
function sg_Geometry_TrianglePrototypeFrom(var pt1: Point2D; var pt2: Point2D; var pt3: Point2D): ShapePrototype; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_TrianglePrototypeFrom');
{$ENDIF}
try
result := sgGeometry.TrianglePrototypeFrom(pt1, pt2, pt3);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_TrianglePrototypeFrom');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_TrianglePrototypeFrom');
{$ENDIF}
end;
function sg_Geometry_TriangleRectangleIntersect(tri: Point2DPtr; var rect: Rectangle): Boolean; cdecl; export;
var
tri_temp: Triangle;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_TriangleRectangleIntersect');
{$ENDIF}
try
TriCopyFromPtr(tri_temp, tri);
result := sgGeometry.TriangleRectangleIntersect(tri_temp, rect);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_TriangleRectangleIntersect');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_TriangleRectangleIntersect');
{$ENDIF}
end;
function sg_Geometry_TriangleStripPrototypeFrom(points: Point2DPtr; points_len: LongInt): ShapePrototype; cdecl; export;
var
points_temp: Point2DArray;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_TriangleStripPrototypeFrom');
{$ENDIF}
try
Point2DCopyFromPtr(points, points_len, points_temp);
result := sgGeometry.TriangleStripPrototypeFrom(points_temp);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_TriangleStripPrototypeFrom');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_TriangleStripPrototypeFrom');
{$ENDIF}
end;
procedure sg_Geometry_TriangleToString(tri: Point2DPtr; result: PChar); cdecl; export;
var
tri_temp: Triangle;
result_temp: String;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_TriangleToString');
{$ENDIF}
try
TriCopyFromPtr(tri_temp, tri);
result_temp := sgGeometry.TriangleToString(tri_temp);
StrCopy(result, PChar(result_temp));
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_TriangleToString');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_TriangleToString');
{$ENDIF}
end;
function sg_Geometry_TrianglesRectangleIntersect(tri: TrianglePtr; var rect: Rectangle; tri_len: LongInt): Boolean; cdecl; export;
var
tri_temp: TriangleArray;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_TrianglesRectangleIntersect');
{$ENDIF}
try
TriangleCopyFromPtr(tri, tri_len, tri_temp);
result := sgGeometry.TrianglesRectangleIntersect(tri_temp, rect);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_TrianglesRectangleIntersect');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_TrianglesRectangleIntersect');
{$ENDIF}
end;
function sg_Geometry_UnitVector(var v: Vector): Vector; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_UnitVector');
{$ENDIF}
try
result := sgGeometry.UnitVector(v);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_UnitVector');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_UnitVector');
{$ENDIF}
end;
procedure sg_Geometry_UpdateShapePoints(s: Shape); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_UpdateShapePoints');
{$ENDIF}
try
sgGeometry.UpdateShapePoints(s);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_UpdateShapePoints');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_UpdateShapePoints');
{$ENDIF}
end;
function sg_Geometry_VectorAngle(var v: Vector): Single; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_VectorAngle');
{$ENDIF}
try
result := sgGeometry.VectorAngle(v);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_VectorAngle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_VectorAngle');
{$ENDIF}
end;
function sg_Geometry_VectorFromAngle(angle: Single; magnitude: Single): Vector; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_VectorFromAngle');
{$ENDIF}
try
result := sgGeometry.VectorFromAngle(angle, magnitude);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_VectorFromAngle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_VectorFromAngle');
{$ENDIF}
end;
function sg_Geometry_VectorFromPointPtToRectangle(var pt: Point2D; var rect: Rectangle): Vector; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_VectorFromPointPtToRectangle');
{$ENDIF}
try
result := sgGeometry.VectorFromPointToRect(pt, rect);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_VectorFromPointPtToRectangle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_VectorFromPointPtToRectangle');
{$ENDIF}
end;
function sg_Geometry_VectorFromPointToRect(x: Single; y: Single; rectX: Single; rectY: Single; rectWidth: LongInt; rectHeight: LongInt): Vector; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_VectorFromPointToRect');
{$ENDIF}
try
result := sgGeometry.VectorFromPointToRect(x, y, rectX, rectY, rectWidth, rectHeight);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_VectorFromPointToRect');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_VectorFromPointToRect');
{$ENDIF}
end;
function sg_Geometry_VectorFromPointToRectangle(x: Single; y: Single; var rect: Rectangle): Vector; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_VectorFromPointToRectangle');
{$ENDIF}
try
result := sgGeometry.VectorFromPointToRect(x, y, rect);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_VectorFromPointToRectangle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_VectorFromPointToRectangle');
{$ENDIF}
end;
function sg_Geometry_VectorFromPoints(var p1: Point2D; var p2: Point2D): Vector; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_VectorFromPoints');
{$ENDIF}
try
result := sgGeometry.VectorFromPoints(p1, p2);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_VectorFromPoints');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_VectorFromPoints');
{$ENDIF}
end;
function sg_Geometry_VectorInRect(var v: Vector; var rect: Rectangle): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_VectorInRect');
{$ENDIF}
try
result := sgGeometry.VectorInRect(v, rect);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_VectorInRect');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_VectorInRect');
{$ENDIF}
end;
function sg_Geometry_VectorInRectXY(var v: Vector; x: Single; y: Single; w: Single; h: Single): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_VectorInRectXY');
{$ENDIF}
try
result := sgGeometry.VectorInRect(v, x, y, w, h);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_VectorInRectXY');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_VectorInRectXY');
{$ENDIF}
end;
function sg_Geometry_VectorIsZero(var v: Vector): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_VectorIsZero');
{$ENDIF}
try
result := sgGeometry.VectorIsZero(v);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_VectorIsZero');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_VectorIsZero');
{$ENDIF}
end;
function sg_Geometry_VectorMagnitude(var v: Vector): Single; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_VectorMagnitude');
{$ENDIF}
try
result := sgGeometry.VectorMagnitude(v);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_VectorMagnitude');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_VectorMagnitude');
{$ENDIF}
end;
function sg_Geometry_VectorMagnitudeSq(var v: Vector): Single; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_VectorMagnitudeSq');
{$ENDIF}
try
result := sgGeometry.VectorMagnitudeSq(v);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_VectorMagnitudeSq');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_VectorMagnitudeSq');
{$ENDIF}
end;
function sg_Geometry_VectorMultiply(var v: Vector; s: Single): Vector; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_VectorMultiply');
{$ENDIF}
try
result := sgGeometry.VectorMultiply(v, s);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_VectorMultiply');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_VectorMultiply');
{$ENDIF}
end;
function sg_Geometry_VectorNormal(var v: Vector): Vector; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_VectorNormal');
{$ENDIF}
try
result := sgGeometry.VectorNormal(v);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_VectorNormal');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_VectorNormal');
{$ENDIF}
end;
function sg_Geometry_VectorOutOfCircleFromCircle(var src: Circle; var bounds: Circle; var velocity: Vector): Vector; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_VectorOutOfCircleFromCircle');
{$ENDIF}
try
result := sgGeometry.VectorOutOfCircleFromCircle(src, bounds, velocity);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_VectorOutOfCircleFromCircle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_VectorOutOfCircleFromCircle');
{$ENDIF}
end;
function sg_Geometry_VectorOutOfCircleFromPoint(var pt: Point2D; var c: Circle; var velocity: Vector): Vector; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_VectorOutOfCircleFromPoint');
{$ENDIF}
try
result := sgGeometry.VectorOutOfCircleFromPoint(pt, c, velocity);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_VectorOutOfCircleFromPoint');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_VectorOutOfCircleFromPoint');
{$ENDIF}
end;
function sg_Geometry_VectorOutOfRectFromCircle(var c: Circle; var rect: Rectangle; var velocity: Vector): Vector; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_VectorOutOfRectFromCircle');
{$ENDIF}
try
result := sgGeometry.VectorOutOfRectFromCircle(c, rect, velocity);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_VectorOutOfRectFromCircle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_VectorOutOfRectFromCircle');
{$ENDIF}
end;
function sg_Geometry_VectorOutOfRectFromPoint(var pt: Point2D; var rect: Rectangle; var velocity: Vector): Vector; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_VectorOutOfRectFromPoint');
{$ENDIF}
try
result := sgGeometry.VectorOutOfRectFromPoint(pt, rect, velocity);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_VectorOutOfRectFromPoint');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_VectorOutOfRectFromPoint');
{$ENDIF}
end;
function sg_Geometry_VectorOutOfRectFromRect(var src: Rectangle; var bounds: Rectangle; var velocity: Vector): Vector; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_VectorOutOfRectFromRect');
{$ENDIF}
try
result := sgGeometry.VectorOutOfRectFromRect(src, bounds, velocity);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_VectorOutOfRectFromRect');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_VectorOutOfRectFromRect');
{$ENDIF}
end;
function sg_Geometry_VectorOutOfShapeFromRect(s: Shape; var bounds: Rectangle; var velocity: Vector): Vector; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_VectorOutOfShapeFromRect');
{$ENDIF}
try
result := sgGeometry.VectorOutOfShapeFromRect(s, bounds, velocity);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_VectorOutOfShapeFromRect');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_VectorOutOfShapeFromRect');
{$ENDIF}
end;
function sg_Geometry_VectorOverLinesFromCircle(var c: Circle; lines: LineSegmentPtr; var velocity: Vector; out maxIdx: LongInt; lines_len: LongInt): Vector; cdecl; export;
var
lines_temp: LinesArray;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_VectorOverLinesFromCircle');
{$ENDIF}
try
LineCopyFromPtr(lines, lines_len, lines_temp);
result := sgGeometry.VectorOverLinesFromCircle(c, lines_temp, velocity, maxIdx);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_VectorOverLinesFromCircle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_VectorOverLinesFromCircle');
{$ENDIF}
end;
function sg_Geometry_VectorTo(x: Single; y: Single; invertY: Boolean): Vector; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_VectorTo');
{$ENDIF}
try
result := sgGeometry.VectorTo(x, y, invertY);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_VectorTo');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_VectorTo');
{$ENDIF}
end;
function sg_Geometry_VectorToPoint(var p1: Point2D): Vector; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_VectorToPoint');
{$ENDIF}
try
result := sgGeometry.VectorToPoint(p1);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_VectorToPoint');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_VectorToPoint');
{$ENDIF}
end;
function sg_Geometry_VectorsEqual(var v1: Vector; var v2: Vector): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_VectorsEqual');
{$ENDIF}
try
result := sgGeometry.VectorsEqual(v1, v2);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_VectorsEqual');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_VectorsEqual');
{$ENDIF}
end;
procedure sg_Geometry_WidestPoints(var c: Circle; var along: Vector; out pt1: Point2D; out pt2: Point2D); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Geometry_WidestPoints');
{$ENDIF}
try
sgGeometry.WidestPoints(c, along, pt1, pt2);
Except on exc: Exception do
TrapException(exc, 'sg_Geometry_WidestPoints');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Geometry_WidestPoints');
{$ENDIF}
end;
procedure sg_Graphics_ClearScreenToBlack(); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_ClearScreenToBlack');
{$ENDIF}
try
sgGraphics.ClearScreen();
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_ClearScreenToBlack');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_ClearScreenToBlack');
{$ENDIF}
end;
procedure sg_Graphics_ClearScreenWithColor(toColor: LongWord); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_ClearScreenWithColor');
{$ENDIF}
try
sgGraphics.ClearScreen(toColor);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_ClearScreenWithColor');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_ClearScreenWithColor');
{$ENDIF}
end;
function sg_Graphics_CurrentBmpClip(bmp: Bitmap): Rectangle; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_CurrentBmpClip');
{$ENDIF}
try
result := sgGraphics.CurrentClip(bmp);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_CurrentBmpClip');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_CurrentBmpClip');
{$ENDIF}
end;
function sg_Graphics_CurrentScreenClip(): Rectangle; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_CurrentScreenClip');
{$ENDIF}
try
result := sgGraphics.CurrentClip();
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_CurrentScreenClip');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_CurrentScreenClip');
{$ENDIF}
end;
procedure sg_Graphics_DrawHorizontalLine(clr: LongWord; y: Single; x1: Single; x2: Single); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawHorizontalLine');
{$ENDIF}
try
sgGraphics.DrawHorizontalLine(clr, y, x1, x2);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawHorizontalLine');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawHorizontalLine');
{$ENDIF}
end;
procedure sg_Graphics_DrawHorizontalLineOnScreen(clr: LongWord; y: LongInt; x1: LongInt; x2: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawHorizontalLineOnScreen');
{$ENDIF}
try
sgGraphics.DrawHorizontalLineOnScreen(clr, y, x1, x2);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawHorizontalLineOnScreen');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawHorizontalLineOnScreen');
{$ENDIF}
end;
procedure sg_Graphics_DrawHorizontalLineOnto(dest: Bitmap; clr: LongWord; y: LongInt; x1: LongInt; x2: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawHorizontalLineOnto');
{$ENDIF}
try
sgGraphics.DrawHorizontalLine(dest, clr, y, x1, x2);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawHorizontalLineOnto');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawHorizontalLineOnto');
{$ENDIF}
end;
procedure sg_Graphics_DrawLine(clr: LongWord; xPosStart: Single; yPosStart: Single; xPosEnd: Single; yPosEnd: Single); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawLine');
{$ENDIF}
try
sgGraphics.DrawLine(clr, xPosStart, yPosStart, xPosEnd, yPosEnd);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawLine');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawLine');
{$ENDIF}
end;
procedure sg_Graphics_DrawLineOnScreen(clr: LongWord; xPosStart: LongInt; yPosStart: LongInt; xPosEnd: LongInt; yPosEnd: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawLineOnScreen');
{$ENDIF}
try
sgGraphics.DrawLineOnScreen(clr, xPosStart, yPosStart, xPosEnd, yPosEnd);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawLineOnScreen');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawLineOnScreen');
{$ENDIF}
end;
procedure sg_Graphics_DrawLineOnto(dest: Bitmap; clr: LongWord; xPosStart: LongInt; yPosStart: LongInt; xPosEnd: LongInt; yPosEnd: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawLineOnto');
{$ENDIF}
try
sgGraphics.DrawLine(dest, clr, xPosStart, yPosStart, xPosEnd, yPosEnd);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawLineOnto');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawLineOnto');
{$ENDIF}
end;
procedure sg_Graphics_DrawLinePts(clr: LongWord; var startPt: Point2D; var endPt: Point2D); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawLinePts');
{$ENDIF}
try
sgGraphics.DrawLine(clr, startPt, endPt);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawLinePts');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawLinePts');
{$ENDIF}
end;
procedure sg_Graphics_DrawLinePtsOnScreen(clr: LongWord; var startPt: Point2D; var endPt: Point2D); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawLinePtsOnScreen');
{$ENDIF}
try
sgGraphics.DrawLineOnScreen(clr, startPt, endPt);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawLinePtsOnScreen');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawLinePtsOnScreen');
{$ENDIF}
end;
procedure sg_Graphics_DrawLinePtsOnto(dest: Bitmap; clr: LongWord; var startPt: Point2D; var endPt: Point2D); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawLinePtsOnto');
{$ENDIF}
try
sgGraphics.DrawLine(dest, clr, startPt, endPt);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawLinePtsOnto');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawLinePtsOnto');
{$ENDIF}
end;
procedure sg_Graphics_DrawLineSegment(clr: LongWord; var line: LineSegment); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawLineSegment');
{$ENDIF}
try
sgGraphics.DrawLine(clr, line);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawLineSegment');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawLineSegment');
{$ENDIF}
end;
procedure sg_Graphics_DrawLineSegmentOnScreen(clr: LongWord; var line: LineSegment); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawLineSegmentOnScreen');
{$ENDIF}
try
sgGraphics.DrawLineOnScreen(clr, line);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawLineSegmentOnScreen');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawLineSegmentOnScreen');
{$ENDIF}
end;
procedure sg_Graphics_DrawLineSegmentOnto(dest: Bitmap; clr: LongWord; var line: LineSegment); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawLineSegmentOnto');
{$ENDIF}
try
sgGraphics.DrawLine(dest, clr, line);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawLineSegmentOnto');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawLineSegmentOnto');
{$ENDIF}
end;
procedure sg_Graphics_DrawLineSegments(clr: LongWord; lines: LineSegmentPtr; lines_len: LongInt); cdecl; export;
var
lines_temp: LinesArray;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawLineSegments');
{$ENDIF}
try
LineCopyFromPtr(lines, lines_len, lines_temp);
sgGraphics.DrawLines(clr, lines_temp);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawLineSegments');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawLineSegments');
{$ENDIF}
end;
procedure sg_Graphics_DrawOrFillCircle(clr: LongWord; filled: Boolean; var c: Circle); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawOrFillCircle');
{$ENDIF}
try
sgGraphics.DrawCircle(clr, filled, c);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawOrFillCircle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawOrFillCircle');
{$ENDIF}
end;
procedure sg_Graphics_DrawOrFillCircleAtPointOnScreen(clr: LongWord; filled: Boolean; var position: Point2D; radius: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawOrFillCircleAtPointOnScreen');
{$ENDIF}
try
sgGraphics.DrawCircleOnScreen(clr, filled, position, radius);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawOrFillCircleAtPointOnScreen');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawOrFillCircleAtPointOnScreen');
{$ENDIF}
end;
procedure sg_Graphics_DrawOrFillCircleOnScreen(clr: LongWord; filled: Boolean; var c: Circle); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawOrFillCircleOnScreen');
{$ENDIF}
try
sgGraphics.DrawCircleOnScreen(clr, filled, c);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawOrFillCircleOnScreen');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawOrFillCircleOnScreen');
{$ENDIF}
end;
procedure sg_Graphics_DrawOrFillCircleOnto(dest: Bitmap; clr: LongWord; filled: Boolean; var c: Circle); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawOrFillCircleOnto');
{$ENDIF}
try
sgGraphics.DrawCircle(dest, clr, filled, c);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawOrFillCircleOnto');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawOrFillCircleOnto');
{$ENDIF}
end;
procedure sg_Graphics_DrawOrFillEllipse(clr: LongWord; filled: Boolean; xPos: Single; yPos: Single; width: LongInt; height: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawOrFillEllipse');
{$ENDIF}
try
sgGraphics.DrawEllipse(clr, filled, xPos, yPos, width, height);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawOrFillEllipse');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawOrFillEllipse');
{$ENDIF}
end;
procedure sg_Graphics_DrawOrFillEllipseInRect(clr: LongWord; filled: Boolean; var source: Rectangle); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawOrFillEllipseInRect');
{$ENDIF}
try
sgGraphics.DrawEllipse(clr, filled, source);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawOrFillEllipseInRect');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawOrFillEllipseInRect');
{$ENDIF}
end;
procedure sg_Graphics_DrawOrFillEllipseInRectOnScreen(clr: LongWord; filled: Boolean; var source: Rectangle); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawOrFillEllipseInRectOnScreen');
{$ENDIF}
try
sgGraphics.DrawEllipseOnScreen(clr, filled, source);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawOrFillEllipseInRectOnScreen');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawOrFillEllipseInRectOnScreen');
{$ENDIF}
end;
procedure sg_Graphics_DrawOrFillEllipseInRectOnto(dest: Bitmap; clr: LongWord; filled: Boolean; var source: Rectangle); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawOrFillEllipseInRectOnto');
{$ENDIF}
try
sgGraphics.DrawEllipse(dest, clr, filled, source);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawOrFillEllipseInRectOnto');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawOrFillEllipseInRectOnto');
{$ENDIF}
end;
procedure sg_Graphics_DrawOrFillEllipseOnScreen(clr: LongWord; filled: Boolean; xPos: LongInt; yPos: LongInt; width: LongInt; height: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawOrFillEllipseOnScreen');
{$ENDIF}
try
sgGraphics.DrawEllipseOnScreen(clr, filled, xPos, yPos, width, height);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawOrFillEllipseOnScreen');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawOrFillEllipseOnScreen');
{$ENDIF}
end;
procedure sg_Graphics_DrawOrFillEllipseOnto(dest: Bitmap; clr: LongWord; filled: Boolean; xPos: LongInt; yPos: LongInt; width: LongInt; height: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawOrFillEllipseOnto');
{$ENDIF}
try
sgGraphics.DrawEllipse(dest, clr, filled, xPos, yPos, width, height);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawOrFillEllipseOnto');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawOrFillEllipseOnto');
{$ENDIF}
end;
procedure sg_Graphics_DrawOrFillPtCircle(clr: LongWord; filled: Boolean; xc: Single; yc: Single; radius: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawOrFillPtCircle');
{$ENDIF}
try
sgGraphics.DrawCircle(clr, filled, xc, yc, radius);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawOrFillPtCircle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawOrFillPtCircle');
{$ENDIF}
end;
procedure sg_Graphics_DrawOrFillPtCircleAtPoint(clr: LongWord; filled: Boolean; var position: Point2D; radius: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawOrFillPtCircleAtPoint');
{$ENDIF}
try
sgGraphics.DrawCircle(clr, filled, position, radius);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawOrFillPtCircleAtPoint');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawOrFillPtCircleAtPoint');
{$ENDIF}
end;
procedure sg_Graphics_DrawOrFillPtCircleAtPointOnto(dest: Bitmap; clr: LongWord; filled: Boolean; var point: Point2D; radius: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawOrFillPtCircleAtPointOnto');
{$ENDIF}
try
sgGraphics.DrawCircle(dest, clr, filled, point, radius);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawOrFillPtCircleAtPointOnto');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawOrFillPtCircleAtPointOnto');
{$ENDIF}
end;
procedure sg_Graphics_DrawOrFillPtCircleOnScreen(clr: LongWord; filled: Boolean; xc: Single; yc: Single; radius: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawOrFillPtCircleOnScreen');
{$ENDIF}
try
sgGraphics.DrawCircleOnScreen(clr, filled, xc, yc, radius);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawOrFillPtCircleOnScreen');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawOrFillPtCircleOnScreen');
{$ENDIF}
end;
procedure sg_Graphics_DrawOrFillPtCircleOnto(dest: Bitmap; clr: LongWord; filled: Boolean; xc: Single; yc: Single; radius: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawOrFillPtCircleOnto');
{$ENDIF}
try
sgGraphics.DrawCircle(dest, clr, filled, xc, yc, radius);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawOrFillPtCircleOnto');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawOrFillPtCircleOnto');
{$ENDIF}
end;
procedure sg_Graphics_DrawOrFillRectangle(clr: LongWord; filled: Boolean; xPos: Single; yPos: Single; width: LongInt; height: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawOrFillRectangle');
{$ENDIF}
try
sgGraphics.DrawRectangle(clr, filled, xPos, yPos, width, height);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawOrFillRectangle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawOrFillRectangle');
{$ENDIF}
end;
procedure sg_Graphics_DrawOrFillRectangleOnScreen(clr: LongWord; filled: Boolean; xPos: LongInt; yPos: LongInt; width: LongInt; height: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawOrFillRectangleOnScreen');
{$ENDIF}
try
sgGraphics.DrawRectangleOnScreen(clr, filled, xPos, yPos, width, height);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawOrFillRectangleOnScreen');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawOrFillRectangleOnScreen');
{$ENDIF}
end;
procedure sg_Graphics_DrawOrFillRectangleOnto(dest: Bitmap; clr: LongWord; filled: Boolean; xPos: LongInt; yPos: LongInt; width: LongInt; height: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawOrFillRectangleOnto');
{$ENDIF}
try
sgGraphics.DrawRectangle(dest, clr, filled, xPos, yPos, width, height);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawOrFillRectangleOnto');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawOrFillRectangleOnto');
{$ENDIF}
end;
procedure sg_Graphics_DrawOrFillRectangleRect(clr: LongWord; filled: Boolean; var source: Rectangle); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawOrFillRectangleRect');
{$ENDIF}
try
sgGraphics.DrawRectangle(clr, filled, source);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawOrFillRectangleRect');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawOrFillRectangleRect');
{$ENDIF}
end;
procedure sg_Graphics_DrawOrFillRectangleRectOnScreen(clr: LongWord; filled: Boolean; var source: Rectangle); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawOrFillRectangleRectOnScreen');
{$ENDIF}
try
sgGraphics.DrawRectangleOnScreen(clr, filled, source);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawOrFillRectangleRectOnScreen');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawOrFillRectangleRectOnScreen');
{$ENDIF}
end;
procedure sg_Graphics_DrawOrFillRectangleRectOnto(dest: Bitmap; clr: LongWord; filled: Boolean; var source: Rectangle); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawOrFillRectangleRectOnto');
{$ENDIF}
try
sgGraphics.DrawRectangle(dest, clr, filled, source);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawOrFillRectangleRectOnto');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawOrFillRectangleRectOnto');
{$ENDIF}
end;
procedure sg_Graphics_DrawOrFillShape(s: Shape; filled: Boolean); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawOrFillShape');
{$ENDIF}
try
sgGraphics.DrawShape(s, filled);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawOrFillShape');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawOrFillShape');
{$ENDIF}
end;
procedure sg_Graphics_DrawOrFillShapeOnScreen(s: Shape; filled: Boolean); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawOrFillShapeOnScreen');
{$ENDIF}
try
sgGraphics.DrawShapeOnScreen(s, filled);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawOrFillShapeOnScreen');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawOrFillShapeOnScreen');
{$ENDIF}
end;
procedure sg_Graphics_DrawOrFillShapeOnto(dest: Bitmap; s: Shape; filled: Boolean); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawOrFillShapeOnto');
{$ENDIF}
try
sgGraphics.DrawShape(dest, s, filled);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawOrFillShapeOnto');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawOrFillShapeOnto');
{$ENDIF}
end;
procedure sg_Graphics_DrawOrFillTriangle(clr: LongWord; filled: Boolean; tri: Point2DPtr); cdecl; export;
var
tri_temp: Triangle;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawOrFillTriangle');
{$ENDIF}
try
TriCopyFromPtr(tri_temp, tri);
sgGraphics.DrawTriangle(clr, filled, tri_temp);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawOrFillTriangle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawOrFillTriangle');
{$ENDIF}
end;
procedure sg_Graphics_DrawOrFillTriangleOnScreen(clr: LongWord; filled: Boolean; tri: Point2DPtr); cdecl; export;
var
tri_temp: Triangle;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawOrFillTriangleOnScreen');
{$ENDIF}
try
TriCopyFromPtr(tri_temp, tri);
sgGraphics.DrawTriangleOnScreen(clr, filled, tri_temp);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawOrFillTriangleOnScreen');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawOrFillTriangleOnScreen');
{$ENDIF}
end;
procedure sg_Graphics_DrawOrFillTriangleOnto(dest: Bitmap; clr: LongWord; filled: Boolean; tri: Point2DPtr); cdecl; export;
var
tri_temp: Triangle;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawOrFillTriangleOnto');
{$ENDIF}
try
TriCopyFromPtr(tri_temp, tri);
sgGraphics.DrawTriangle(dest, clr, filled, tri_temp);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawOrFillTriangleOnto');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawOrFillTriangleOnto');
{$ENDIF}
end;
procedure sg_Graphics_DrawPixel(clr: LongWord; x: Single; y: Single); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawPixel');
{$ENDIF}
try
sgGraphics.DrawPixel(clr, x, y);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawPixel');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawPixel');
{$ENDIF}
end;
procedure sg_Graphics_DrawPixelAtPoint(clr: LongWord; var position: Point2D); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawPixelAtPoint');
{$ENDIF}
try
sgGraphics.DrawPixel(clr, position);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawPixelAtPoint');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawPixelAtPoint');
{$ENDIF}
end;
procedure sg_Graphics_DrawPixelAtPointOnScreen(clr: LongWord; var position: Point2D); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawPixelAtPointOnScreen');
{$ENDIF}
try
sgGraphics.DrawPixelOnScreen(clr, position);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawPixelAtPointOnScreen');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawPixelAtPointOnScreen');
{$ENDIF}
end;
procedure sg_Graphics_DrawPixelAtPointOnto(dest: Bitmap; clr: LongWord; var position: Point2D); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawPixelAtPointOnto');
{$ENDIF}
try
sgGraphics.DrawPixel(dest, clr, position);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawPixelAtPointOnto');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawPixelAtPointOnto');
{$ENDIF}
end;
procedure sg_Graphics_DrawPixelOnScreen(clr: LongWord; x: LongInt; y: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawPixelOnScreen');
{$ENDIF}
try
sgGraphics.DrawPixelOnScreen(clr, x, y);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawPixelOnScreen');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawPixelOnScreen');
{$ENDIF}
end;
procedure sg_Graphics_DrawPixelOnto(dest: Bitmap; clr: LongWord; x: LongInt; y: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawPixelOnto');
{$ENDIF}
try
sgGraphics.DrawPixel(dest, clr, x, y);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawPixelOnto');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawPixelOnto');
{$ENDIF}
end;
procedure sg_Graphics_DrawShape(s: Shape); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawShape');
{$ENDIF}
try
sgGraphics.DrawShape(s);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawShape');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawShape');
{$ENDIF}
end;
procedure sg_Graphics_DrawShapeAsCircle(dest: Bitmap; s: Shape; filled: Boolean; var offset: Point2D); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawShapeAsCircle');
{$ENDIF}
try
sgGraphics.DrawShapeAsCircle(dest, s, filled, offset);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawShapeAsCircle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawShapeAsCircle');
{$ENDIF}
end;
procedure sg_Graphics_DrawShapeAsLine(dest: Bitmap; s: Shape; filled: Boolean; var offset: Point2D); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawShapeAsLine');
{$ENDIF}
try
sgGraphics.DrawShapeAsLine(dest, s, filled, offset);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawShapeAsLine');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawShapeAsLine');
{$ENDIF}
end;
procedure sg_Graphics_DrawShapeAsLineList(dest: Bitmap; s: Shape; filled: Boolean; var offset: Point2D); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawShapeAsLineList');
{$ENDIF}
try
sgGraphics.DrawShapeAsLineList(dest, s, filled, offset);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawShapeAsLineList');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawShapeAsLineList');
{$ENDIF}
end;
procedure sg_Graphics_DrawShapeAsLineStrip(dest: Bitmap; s: Shape; filled: Boolean; var offset: Point2D); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawShapeAsLineStrip');
{$ENDIF}
try
sgGraphics.DrawShapeAsLineStrip(dest, s, filled, offset);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawShapeAsLineStrip');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawShapeAsLineStrip');
{$ENDIF}
end;
procedure sg_Graphics_DrawShapeAsPoint(dest: Bitmap; s: Shape; filled: Boolean; var offset: Point2D); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawShapeAsPoint');
{$ENDIF}
try
sgGraphics.DrawShapeAsPoint(dest, s, filled, offset);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawShapeAsPoint');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawShapeAsPoint');
{$ENDIF}
end;
procedure sg_Graphics_DrawShapeAsTriangle(dest: Bitmap; s: Shape; filled: Boolean; var offset: Point2D); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawShapeAsTriangle');
{$ENDIF}
try
sgGraphics.DrawShapeAsTriangle(dest, s, filled, offset);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawShapeAsTriangle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawShapeAsTriangle');
{$ENDIF}
end;
procedure sg_Graphics_DrawShapeAsTriangleFan(dest: Bitmap; s: Shape; filled: Boolean; var offset: Point2D); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawShapeAsTriangleFan');
{$ENDIF}
try
sgGraphics.DrawShapeAsTriangleFan(dest, s, filled, offset);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawShapeAsTriangleFan');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawShapeAsTriangleFan');
{$ENDIF}
end;
procedure sg_Graphics_DrawShapeAsTriangleList(dest: Bitmap; s: Shape; filled: Boolean; var offset: Point2D); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawShapeAsTriangleList');
{$ENDIF}
try
sgGraphics.DrawShapeAsTriangleList(dest, s, filled, offset);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawShapeAsTriangleList');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawShapeAsTriangleList');
{$ENDIF}
end;
procedure sg_Graphics_DrawShapeAsTriangleStrip(dest: Bitmap; s: Shape; filled: Boolean; var offset: Point2D); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawShapeAsTriangleStrip');
{$ENDIF}
try
sgGraphics.DrawShapeAsTriangleStrip(dest, s, filled, offset);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawShapeAsTriangleStrip');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawShapeAsTriangleStrip');
{$ENDIF}
end;
procedure sg_Graphics_DrawShapeOnScreen(s: Shape); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawShapeOnScreen');
{$ENDIF}
try
sgGraphics.DrawShapeOnScreen(s);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawShapeOnScreen');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawShapeOnScreen');
{$ENDIF}
end;
procedure sg_Graphics_DrawShapeOnto(dest: Bitmap; s: Shape); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawShapeOnto');
{$ENDIF}
try
sgGraphics.DrawShape(dest, s);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawShapeOnto');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawShapeOnto');
{$ENDIF}
end;
procedure sg_Graphics_DrawTriangleFromPoints(clr: LongWord; x1: Single; y1: Single; x2: Single; y2: Single; x3: Single; y3: Single); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawTriangleFromPoints');
{$ENDIF}
try
sgGraphics.DrawTriangle(clr, x1, y1, x2, y2, x3, y3);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawTriangleFromPoints');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawTriangleFromPoints');
{$ENDIF}
end;
procedure sg_Graphics_DrawTriangleFromPointsOnScreen(clr: LongWord; x1: Single; y1: Single; x2: Single; y2: Single; x3: Single; y3: Single); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawTriangleFromPointsOnScreen');
{$ENDIF}
try
sgGraphics.DrawTriangleOnScreen(clr, x1, y1, x2, y2, x3, y3);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawTriangleFromPointsOnScreen');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawTriangleFromPointsOnScreen');
{$ENDIF}
end;
procedure sg_Graphics_DrawTriangleFromPointsOnto(dest: Bitmap; clr: LongWord; x1: Single; y1: Single; x2: Single; y2: Single; x3: Single; y3: Single); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawTriangleFromPointsOnto');
{$ENDIF}
try
sgGraphics.DrawTriangle(dest, clr, x1, y1, x2, y2, x3, y3);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawTriangleFromPointsOnto');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawTriangleFromPointsOnto');
{$ENDIF}
end;
procedure sg_Graphics_DrawVerticalLine(clr: LongWord; x: Single; y1: Single; y2: Single); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawVerticalLine');
{$ENDIF}
try
sgGraphics.DrawVerticalLine(clr, x, y1, y2);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawVerticalLine');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawVerticalLine');
{$ENDIF}
end;
procedure sg_Graphics_DrawVerticalLineOnScreen(clr: LongWord; x: LongInt; y1: LongInt; y2: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawVerticalLineOnScreen');
{$ENDIF}
try
sgGraphics.DrawVerticalLineOnScreen(clr, x, y1, y2);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawVerticalLineOnScreen');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawVerticalLineOnScreen');
{$ENDIF}
end;
procedure sg_Graphics_DrawVerticalLineOnto(dest: Bitmap; clr: LongWord; x: LongInt; y1: LongInt; y2: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_DrawVerticalLineOnto');
{$ENDIF}
try
sgGraphics.DrawVerticalLine(dest, clr, x, y1, y2);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_DrawVerticalLineOnto');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_DrawVerticalLineOnto');
{$ENDIF}
end;
procedure sg_Graphics_FillShape(s: Shape); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_FillShape');
{$ENDIF}
try
sgGraphics.FillShape(s);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_FillShape');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_FillShape');
{$ENDIF}
end;
procedure sg_Graphics_FillShapeOnScreen(s: Shape); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_FillShapeOnScreen');
{$ENDIF}
try
sgGraphics.FillShapeOnScreen(s);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_FillShapeOnScreen');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_FillShapeOnScreen');
{$ENDIF}
end;
procedure sg_Graphics_FillShapeOnto(dest: Bitmap; s: Shape); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_FillShapeOnto');
{$ENDIF}
try
sgGraphics.FillShape(dest, s);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_FillShapeOnto');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_FillShapeOnto');
{$ENDIF}
end;
procedure sg_Graphics_FillTriangleFromPoints(clr: LongWord; x1: Single; y1: Single; x2: Single; y2: Single; x3: Single; y3: Single); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_FillTriangleFromPoints');
{$ENDIF}
try
sgGraphics.FillTriangle(clr, x1, y1, x2, y2, x3, y3);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_FillTriangleFromPoints');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_FillTriangleFromPoints');
{$ENDIF}
end;
procedure sg_Graphics_FillTriangleFromPointsOnScreen(clr: LongWord; x1: Single; y1: Single; x2: Single; y2: Single; x3: Single; y3: Single); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_FillTriangleFromPointsOnScreen');
{$ENDIF}
try
sgGraphics.FillTriangleOnScreen(clr, x1, y1, x2, y2, x3, y3);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_FillTriangleFromPointsOnScreen');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_FillTriangleFromPointsOnScreen');
{$ENDIF}
end;
procedure sg_Graphics_FillTriangleFromPointsOnto(dest: Bitmap; clr: LongWord; x1: Single; y1: Single; x2: Single; y2: Single; x3: Single; y3: Single); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_FillTriangleFromPointsOnto');
{$ENDIF}
try
sgGraphics.FillTriangle(dest, clr, x1, y1, x2, y2, x3, y3);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_FillTriangleFromPointsOnto');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_FillTriangleFromPointsOnto');
{$ENDIF}
end;
function sg_Graphics_GetPixel(bmp: Bitmap; x: LongInt; y: LongInt): Color; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_GetPixel');
{$ENDIF}
try
result := sgGraphics.GetPixel(bmp, x, y);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_GetPixel');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_GetPixel');
{$ENDIF}
end;
function sg_Graphics_GetPixelFromScreen(x: LongInt; y: LongInt): Color; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_GetPixelFromScreen');
{$ENDIF}
try
result := sgGraphics.GetPixelFromScreen(x, y);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_GetPixelFromScreen');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_GetPixelFromScreen');
{$ENDIF}
end;
procedure sg_Graphics_PopClipBmp(bmp: Bitmap); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_PopClipBmp');
{$ENDIF}
try
sgGraphics.PopClip(bmp);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_PopClipBmp');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_PopClipBmp');
{$ENDIF}
end;
procedure sg_Graphics_PopClipScreen(); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_PopClipScreen');
{$ENDIF}
try
sgGraphics.PopClip();
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_PopClipScreen');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_PopClipScreen');
{$ENDIF}
end;
procedure sg_Graphics_PushClipRect(var r: Rectangle); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_PushClipRect');
{$ENDIF}
try
sgGraphics.PushClip(r);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_PushClipRect');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_PushClipRect');
{$ENDIF}
end;
procedure sg_Graphics_PushClipRectForBitmap(bmp: Bitmap; var r: Rectangle); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_PushClipRectForBitmap');
{$ENDIF}
try
sgGraphics.PushClip(bmp, r);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_PushClipRectForBitmap');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_PushClipRectForBitmap');
{$ENDIF}
end;
procedure sg_Graphics_PushClipXY(x: LongInt; y: LongInt; w: LongInt; h: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_PushClipXY');
{$ENDIF}
try
sgGraphics.PushClip(x, y, w, h);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_PushClipXY');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_PushClipXY');
{$ENDIF}
end;
procedure sg_Graphics_PutPixel(bmp: Bitmap; value: LongWord; x: LongInt; y: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_PutPixel');
{$ENDIF}
try
sgGraphics.PutPixel(bmp, value, x, y);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_PutPixel');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_PutPixel');
{$ENDIF}
end;
procedure sg_Graphics_ResetClip(); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_ResetClip');
{$ENDIF}
try
sgGraphics.ResetClip();
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_ResetClip');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_ResetClip');
{$ENDIF}
end;
procedure sg_Graphics_ResetClipForBitmap(bmp: Bitmap); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_ResetClipForBitmap');
{$ENDIF}
try
sgGraphics.ResetClip(bmp);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_ResetClipForBitmap');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_ResetClipForBitmap');
{$ENDIF}
end;
procedure sg_Graphics_SetBmpClip(bmp: Bitmap; var r: Rectangle); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_SetBmpClip');
{$ENDIF}
try
sgGraphics.SetClip(bmp, r);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_SetBmpClip');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_SetBmpClip');
{$ENDIF}
end;
procedure sg_Graphics_SetBmpClipXY(bmp: Bitmap; x: LongInt; y: LongInt; w: LongInt; h: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_SetBmpClipXY');
{$ENDIF}
try
sgGraphics.SetClip(bmp, x, y, w, h);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_SetBmpClipXY');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_SetBmpClipXY');
{$ENDIF}
end;
procedure sg_Graphics_SetClip(var r: Rectangle); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_SetClip');
{$ENDIF}
try
sgGraphics.SetClip(r);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_SetClip');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_SetClip');
{$ENDIF}
end;
procedure sg_Graphics_SetClipXY(x: LongInt; y: LongInt; w: LongInt; h: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Graphics_SetClipXY');
{$ENDIF}
try
sgGraphics.SetClip(x, y, w, h);
Except on exc: Exception do
TrapException(exc, 'sg_Graphics_SetClipXY');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Graphics_SetClipXY');
{$ENDIF}
end;
function sg_Images_BitmapCellCircle(bmp: Bitmap; var pt: Point2D): Circle; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_BitmapCellCircle');
{$ENDIF}
try
result := sgImages.BitmapCellCircle(bmp, pt);
Except on exc: Exception do
TrapException(exc, 'sg_Images_BitmapCellCircle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_BitmapCellCircle');
{$ENDIF}
end;
function sg_Images_BitmapCellCircleXY(bmp: Bitmap; x: LongInt; y: LongInt): Circle; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_BitmapCellCircleXY');
{$ENDIF}
try
result := sgImages.BitmapCellCircle(bmp, x, y);
Except on exc: Exception do
TrapException(exc, 'sg_Images_BitmapCellCircleXY');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_BitmapCellCircleXY');
{$ENDIF}
end;
function sg_Images_BitmapCellColumns(bmp: Bitmap): LongInt; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_BitmapCellColumns');
{$ENDIF}
try
result := sgImages.BitmapCellColumns(bmp);
Except on exc: Exception do
TrapException(exc, 'sg_Images_BitmapCellColumns');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_BitmapCellColumns');
{$ENDIF}
end;
function sg_Images_BitmapCellCount(bmp: Bitmap): LongInt; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_BitmapCellCount');
{$ENDIF}
try
result := sgImages.BitmapCellCount(bmp);
Except on exc: Exception do
TrapException(exc, 'sg_Images_BitmapCellCount');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_BitmapCellCount');
{$ENDIF}
end;
function sg_Images_BitmapCellHeight(bmp: Bitmap): LongInt; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_BitmapCellHeight');
{$ENDIF}
try
result := sgImages.BitmapCellHeight(bmp);
Except on exc: Exception do
TrapException(exc, 'sg_Images_BitmapCellHeight');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_BitmapCellHeight');
{$ENDIF}
end;
function sg_Images_BitmapCellOf(bmp: Bitmap; cell: LongInt): BitmapCell; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_BitmapCellOf');
{$ENDIF}
try
result := sgImages.BitmapCellOf(bmp, cell);
Except on exc: Exception do
TrapException(exc, 'sg_Images_BitmapCellOf');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_BitmapCellOf');
{$ENDIF}
end;
function sg_Images_BitmapCellRectangle(var pt: Point2D; bmp: Bitmap): Rectangle; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_BitmapCellRectangle');
{$ENDIF}
try
result := sgImages.BitmapCellRectangle(pt, bmp);
Except on exc: Exception do
TrapException(exc, 'sg_Images_BitmapCellRectangle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_BitmapCellRectangle');
{$ENDIF}
end;
function sg_Images_BitmapCellRectangleAtOrigin(bmp: Bitmap): Rectangle; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_BitmapCellRectangleAtOrigin');
{$ENDIF}
try
result := sgImages.BitmapCellRectangle(bmp);
Except on exc: Exception do
TrapException(exc, 'sg_Images_BitmapCellRectangleAtOrigin');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_BitmapCellRectangleAtOrigin');
{$ENDIF}
end;
function sg_Images_BitmapCellRectangleXY(x: Single; y: Single; bmp: Bitmap): Rectangle; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_BitmapCellRectangleXY');
{$ENDIF}
try
result := sgImages.BitmapCellRectangle(x, y, bmp);
Except on exc: Exception do
TrapException(exc, 'sg_Images_BitmapCellRectangleXY');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_BitmapCellRectangleXY');
{$ENDIF}
end;
function sg_Images_BitmapCellRows(bmp: Bitmap): LongInt; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_BitmapCellRows');
{$ENDIF}
try
result := sgImages.BitmapCellRows(bmp);
Except on exc: Exception do
TrapException(exc, 'sg_Images_BitmapCellRows');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_BitmapCellRows');
{$ENDIF}
end;
function sg_Images_BitmapCellWidth(bmp: Bitmap): LongInt; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_BitmapCellWidth');
{$ENDIF}
try
result := sgImages.BitmapCellWidth(bmp);
Except on exc: Exception do
TrapException(exc, 'sg_Images_BitmapCellWidth');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_BitmapCellWidth');
{$ENDIF}
end;
function sg_Images_BitmapCircle(bmp: Bitmap; var pt: Point2D): Circle; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_BitmapCircle');
{$ENDIF}
try
result := sgImages.BitmapCircle(bmp, pt);
Except on exc: Exception do
TrapException(exc, 'sg_Images_BitmapCircle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_BitmapCircle');
{$ENDIF}
end;
function sg_Images_BitmapCircleXY(bmp: Bitmap; x: LongInt; y: LongInt): Circle; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_BitmapCircleXY');
{$ENDIF}
try
result := sgImages.BitmapCircle(bmp, x, y);
Except on exc: Exception do
TrapException(exc, 'sg_Images_BitmapCircleXY');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_BitmapCircleXY');
{$ENDIF}
end;
function sg_Images_BitmapHeight(bmp: Bitmap): LongInt; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_BitmapHeight');
{$ENDIF}
try
result := sgImages.BitmapHeight(bmp);
Except on exc: Exception do
TrapException(exc, 'sg_Images_BitmapHeight');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_BitmapHeight');
{$ENDIF}
end;
function sg_Images_BitmapHeightForCell(var bmp: BitmapCell): LongInt; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_BitmapHeightForCell');
{$ENDIF}
try
result := sgImages.BitmapHeight(bmp);
Except on exc: Exception do
TrapException(exc, 'sg_Images_BitmapHeightForCell');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_BitmapHeightForCell');
{$ENDIF}
end;
procedure sg_Images_BitmapName(bmp: Bitmap; result: PChar); cdecl; export;
var
result_temp: String;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_BitmapName');
{$ENDIF}
try
result_temp := sgImages.BitmapName(bmp);
StrCopy(result, PChar(result_temp));
Except on exc: Exception do
TrapException(exc, 'sg_Images_BitmapName');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_BitmapName');
{$ENDIF}
end;
function sg_Images_BitmapNamed(name: PChar): Bitmap; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_BitmapNamed');
{$ENDIF}
try
result := sgImages.BitmapNamed(name);
Except on exc: Exception do
TrapException(exc, 'sg_Images_BitmapNamed');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_BitmapNamed');
{$ENDIF}
end;
function sg_Images_BitmapRectAtOrigin(bmp: Bitmap): Rectangle; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_BitmapRectAtOrigin');
{$ENDIF}
try
result := sgImages.BitmapRectangle(bmp);
Except on exc: Exception do
TrapException(exc, 'sg_Images_BitmapRectAtOrigin');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_BitmapRectAtOrigin');
{$ENDIF}
end;
function sg_Images_BitmapRectXY(x: Single; y: Single; bmp: Bitmap): Rectangle; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_BitmapRectXY');
{$ENDIF}
try
result := sgImages.BitmapRectangle(x, y, bmp);
Except on exc: Exception do
TrapException(exc, 'sg_Images_BitmapRectXY');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_BitmapRectXY');
{$ENDIF}
end;
function sg_Images_BitmapRectangleOfCell(src: Bitmap; cell: LongInt): Rectangle; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_BitmapRectangleOfCell');
{$ENDIF}
try
result := sgImages.BitmapRectangleOfCell(src, cell);
Except on exc: Exception do
TrapException(exc, 'sg_Images_BitmapRectangleOfCell');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_BitmapRectangleOfCell');
{$ENDIF}
end;
procedure sg_Images_BitmapSetCellDetails(bmp: Bitmap; width: LongInt; height: LongInt; columns: LongInt; rows: LongInt; count: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_BitmapSetCellDetails');
{$ENDIF}
try
sgImages.BitmapSetCellDetails(bmp, width, height, columns, rows, count);
Except on exc: Exception do
TrapException(exc, 'sg_Images_BitmapSetCellDetails');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_BitmapSetCellDetails');
{$ENDIF}
end;
function sg_Images_BitmapWidth(bmp: Bitmap): LongInt; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_BitmapWidth');
{$ENDIF}
try
result := sgImages.BitmapWidth(bmp);
Except on exc: Exception do
TrapException(exc, 'sg_Images_BitmapWidth');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_BitmapWidth');
{$ENDIF}
end;
function sg_Images_BitmapWidthForCell(var bmp: BitmapCell): LongInt; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_BitmapWidthForCell');
{$ENDIF}
try
result := sgImages.BitmapWidth(bmp);
Except on exc: Exception do
TrapException(exc, 'sg_Images_BitmapWidthForCell');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_BitmapWidthForCell');
{$ENDIF}
end;
procedure sg_Images_BitmapfileName(bmp: Bitmap; result: PChar); cdecl; export;
var
result_temp: String;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_BitmapfileName');
{$ENDIF}
try
result_temp := sgImages.BitmapfileName(bmp);
StrCopy(result, PChar(result_temp));
Except on exc: Exception do
TrapException(exc, 'sg_Images_BitmapfileName');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_BitmapfileName');
{$ENDIF}
end;
function sg_Images_BitmapsInterchangable(bmp1: Bitmap; bmp2: Bitmap): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_BitmapsInterchangable');
{$ENDIF}
try
result := sgImages.BitmapsInterchangable(bmp1, bmp2);
Except on exc: Exception do
TrapException(exc, 'sg_Images_BitmapsInterchangable');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_BitmapsInterchangable');
{$ENDIF}
end;
procedure sg_Images_ClearSurface(dest: Bitmap; toColor: LongWord); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_ClearSurface');
{$ENDIF}
try
sgImages.ClearSurface(dest, toColor);
Except on exc: Exception do
TrapException(exc, 'sg_Images_ClearSurface');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_ClearSurface');
{$ENDIF}
end;
procedure sg_Images_ClearSurfaceToBlack(dest: Bitmap); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_ClearSurfaceToBlack');
{$ENDIF}
try
sgImages.ClearSurface(dest);
Except on exc: Exception do
TrapException(exc, 'sg_Images_ClearSurfaceToBlack');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_ClearSurfaceToBlack');
{$ENDIF}
end;
function sg_Images_CreateBitmap(width: LongInt; height: LongInt): Bitmap; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_CreateBitmap');
{$ENDIF}
try
result := sgImages.CreateBitmap(width, height);
Except on exc: Exception do
TrapException(exc, 'sg_Images_CreateBitmap');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_CreateBitmap');
{$ENDIF}
end;
procedure sg_Images_DrawBitmap(src: Bitmap; x: Single; y: Single); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_DrawBitmap');
{$ENDIF}
try
sgImages.DrawBitmap(src, x, y);
Except on exc: Exception do
TrapException(exc, 'sg_Images_DrawBitmap');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_DrawBitmap');
{$ENDIF}
end;
procedure sg_Images_DrawBitmapAtPoint(src: Bitmap; var position: Point2D); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_DrawBitmapAtPoint');
{$ENDIF}
try
sgImages.DrawBitmap(src, position);
Except on exc: Exception do
TrapException(exc, 'sg_Images_DrawBitmapAtPoint');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_DrawBitmapAtPoint');
{$ENDIF}
end;
procedure sg_Images_DrawBitmapAtPointOnScreen(src: Bitmap; var position: Point2D); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_DrawBitmapAtPointOnScreen');
{$ENDIF}
try
sgImages.DrawBitmapOnScreen(src, position);
Except on exc: Exception do
TrapException(exc, 'sg_Images_DrawBitmapAtPointOnScreen');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_DrawBitmapAtPointOnScreen');
{$ENDIF}
end;
procedure sg_Images_DrawBitmapAtPointOnto(dest: Bitmap; src: Bitmap; var position: Point2D); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_DrawBitmapAtPointOnto');
{$ENDIF}
try
sgImages.DrawBitmap(dest, src, position);
Except on exc: Exception do
TrapException(exc, 'sg_Images_DrawBitmapAtPointOnto');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_DrawBitmapAtPointOnto');
{$ENDIF}
end;
procedure sg_Images_DrawBitmapCell(var src: BitmapCell; x: Single; y: Single); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_DrawBitmapCell');
{$ENDIF}
try
sgImages.DrawBitmapCell(src, x, y);
Except on exc: Exception do
TrapException(exc, 'sg_Images_DrawBitmapCell');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_DrawBitmapCell');
{$ENDIF}
end;
procedure sg_Images_DrawBitmapCellAtPoint(var src: BitmapCell; var position: Point2D); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_DrawBitmapCellAtPoint');
{$ENDIF}
try
sgImages.DrawBitmapCell(src, position);
Except on exc: Exception do
TrapException(exc, 'sg_Images_DrawBitmapCellAtPoint');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_DrawBitmapCellAtPoint');
{$ENDIF}
end;
procedure sg_Images_DrawBitmapCellAtPointOnScreen(var src: BitmapCell; var position: Point2D); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_DrawBitmapCellAtPointOnScreen');
{$ENDIF}
try
sgImages.DrawBitmapCellOnScreen(src, position);
Except on exc: Exception do
TrapException(exc, 'sg_Images_DrawBitmapCellAtPointOnScreen');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_DrawBitmapCellAtPointOnScreen');
{$ENDIF}
end;
procedure sg_Images_DrawBitmapCellAtPointOnto(dest: Bitmap; var src: BitmapCell; var position: Point2D); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_DrawBitmapCellAtPointOnto');
{$ENDIF}
try
sgImages.DrawBitmapCell(dest, src, position);
Except on exc: Exception do
TrapException(exc, 'sg_Images_DrawBitmapCellAtPointOnto');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_DrawBitmapCellAtPointOnto');
{$ENDIF}
end;
procedure sg_Images_DrawBitmapCellOnScreen(var src: BitmapCell; x: LongInt; y: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_DrawBitmapCellOnScreen');
{$ENDIF}
try
sgImages.DrawBitmapCellOnScreen(src, x, y);
Except on exc: Exception do
TrapException(exc, 'sg_Images_DrawBitmapCellOnScreen');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_DrawBitmapCellOnScreen');
{$ENDIF}
end;
procedure sg_Images_DrawBitmapCellOnto(dest: Bitmap; var src: BitmapCell; x: LongInt; y: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_DrawBitmapCellOnto');
{$ENDIF}
try
sgImages.DrawBitmapCell(dest, src, x, y);
Except on exc: Exception do
TrapException(exc, 'sg_Images_DrawBitmapCellOnto');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_DrawBitmapCellOnto');
{$ENDIF}
end;
procedure sg_Images_DrawBitmapOnScreen(src: Bitmap; x: LongInt; y: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_DrawBitmapOnScreen');
{$ENDIF}
try
sgImages.DrawBitmapOnScreen(src, x, y);
Except on exc: Exception do
TrapException(exc, 'sg_Images_DrawBitmapOnScreen');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_DrawBitmapOnScreen');
{$ENDIF}
end;
procedure sg_Images_DrawBitmapOnto(dest: Bitmap; src: Bitmap; x: LongInt; y: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_DrawBitmapOnto');
{$ENDIF}
try
sgImages.DrawBitmap(dest, src, x, y);
Except on exc: Exception do
TrapException(exc, 'sg_Images_DrawBitmapOnto');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_DrawBitmapOnto');
{$ENDIF}
end;
procedure sg_Images_DrawBitmapPart(src: Bitmap; srcX: LongInt; srcY: LongInt; srcW: LongInt; srcH: LongInt; x: Single; y: Single); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_DrawBitmapPart');
{$ENDIF}
try
sgImages.DrawBitmapPart(src, srcX, srcY, srcW, srcH, x, y);
Except on exc: Exception do
TrapException(exc, 'sg_Images_DrawBitmapPart');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_DrawBitmapPart');
{$ENDIF}
end;
procedure sg_Images_DrawBitmapPartFromRect(src: Bitmap; var source: Rectangle; x: Single; y: Single); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_DrawBitmapPartFromRect');
{$ENDIF}
try
sgImages.DrawBitmapPart(src, source, x, y);
Except on exc: Exception do
TrapException(exc, 'sg_Images_DrawBitmapPartFromRect');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_DrawBitmapPartFromRect');
{$ENDIF}
end;
procedure sg_Images_DrawBitmapPartFromRectAtPoint(src: Bitmap; var source: Rectangle; var position: Point2D); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_DrawBitmapPartFromRectAtPoint');
{$ENDIF}
try
sgImages.DrawBitmapPart(src, source, position);
Except on exc: Exception do
TrapException(exc, 'sg_Images_DrawBitmapPartFromRectAtPoint');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_DrawBitmapPartFromRectAtPoint');
{$ENDIF}
end;
procedure sg_Images_DrawBitmapPartFromRectAtPointOnScreen(src: Bitmap; var source: Rectangle; var position: Point2D); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_DrawBitmapPartFromRectAtPointOnScreen');
{$ENDIF}
try
sgImages.DrawBitmapPartOnScreen(src, source, position);
Except on exc: Exception do
TrapException(exc, 'sg_Images_DrawBitmapPartFromRectAtPointOnScreen');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_DrawBitmapPartFromRectAtPointOnScreen');
{$ENDIF}
end;
procedure sg_Images_DrawBitmapPartFromRectAtPointOnto(dest: Bitmap; src: Bitmap; var source: Rectangle; var position: Point2D); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_DrawBitmapPartFromRectAtPointOnto');
{$ENDIF}
try
sgImages.DrawBitmapPart(dest, src, source, position);
Except on exc: Exception do
TrapException(exc, 'sg_Images_DrawBitmapPartFromRectAtPointOnto');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_DrawBitmapPartFromRectAtPointOnto');
{$ENDIF}
end;
procedure sg_Images_DrawBitmapPartFromRectOnScreen(src: Bitmap; var source: Rectangle; x: LongInt; y: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_DrawBitmapPartFromRectOnScreen');
{$ENDIF}
try
sgImages.DrawBitmapPartOnScreen(src, source, x, y);
Except on exc: Exception do
TrapException(exc, 'sg_Images_DrawBitmapPartFromRectOnScreen');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_DrawBitmapPartFromRectOnScreen');
{$ENDIF}
end;
procedure sg_Images_DrawBitmapPartFromRectOnto(dest: Bitmap; src: Bitmap; var source: Rectangle; x: LongInt; y: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_DrawBitmapPartFromRectOnto');
{$ENDIF}
try
sgImages.DrawBitmapPart(dest, src, source, x, y);
Except on exc: Exception do
TrapException(exc, 'sg_Images_DrawBitmapPartFromRectOnto');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_DrawBitmapPartFromRectOnto');
{$ENDIF}
end;
procedure sg_Images_DrawBitmapPartOnScreen(src: Bitmap; srcX: LongInt; srcY: LongInt; srcW: LongInt; srcH: LongInt; x: LongInt; y: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_DrawBitmapPartOnScreen');
{$ENDIF}
try
sgImages.DrawBitmapPartOnScreen(src, srcX, srcY, srcW, srcH, x, y);
Except on exc: Exception do
TrapException(exc, 'sg_Images_DrawBitmapPartOnScreen');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_DrawBitmapPartOnScreen');
{$ENDIF}
end;
procedure sg_Images_DrawBitmapPartOnto(dest: Bitmap; src: Bitmap; srcX: LongInt; srcY: LongInt; srcW: LongInt; srcH: LongInt; x: LongInt; y: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_DrawBitmapPartOnto');
{$ENDIF}
try
sgImages.DrawBitmapPart(dest, src, srcX, srcY, srcW, srcH, x, y);
Except on exc: Exception do
TrapException(exc, 'sg_Images_DrawBitmapPartOnto');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_DrawBitmapPartOnto');
{$ENDIF}
end;
procedure sg_Images_DrawCell(src: Bitmap; cell: LongInt; var position: Point2D); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_DrawCell');
{$ENDIF}
try
sgImages.DrawCell(src, cell, position);
Except on exc: Exception do
TrapException(exc, 'sg_Images_DrawCell');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_DrawCell');
{$ENDIF}
end;
procedure sg_Images_DrawCellOnScreen(src: Bitmap; cell: LongInt; var position: Point2D); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_DrawCellOnScreen');
{$ENDIF}
try
sgImages.DrawCellOnScreen(src, cell, position);
Except on exc: Exception do
TrapException(exc, 'sg_Images_DrawCellOnScreen');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_DrawCellOnScreen');
{$ENDIF}
end;
procedure sg_Images_DrawCellOnScreenXY(src: Bitmap; cell: LongInt; x: Single; y: Single); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_DrawCellOnScreenXY');
{$ENDIF}
try
sgImages.DrawCellOnScreen(src, cell, x, y);
Except on exc: Exception do
TrapException(exc, 'sg_Images_DrawCellOnScreenXY');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_DrawCellOnScreenXY');
{$ENDIF}
end;
procedure sg_Images_DrawCellOnto(dest: Bitmap; src: Bitmap; cell: LongInt; var position: Point2D); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_DrawCellOnto');
{$ENDIF}
try
sgImages.DrawCell(dest, src, cell, position);
Except on exc: Exception do
TrapException(exc, 'sg_Images_DrawCellOnto');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_DrawCellOnto');
{$ENDIF}
end;
procedure sg_Images_DrawCellOntoXY(dest: Bitmap; src: Bitmap; cell: LongInt; x: Single; y: Single); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_DrawCellOntoXY');
{$ENDIF}
try
sgImages.DrawCell(dest, src, cell, x, y);
Except on exc: Exception do
TrapException(exc, 'sg_Images_DrawCellOntoXY');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_DrawCellOntoXY');
{$ENDIF}
end;
procedure sg_Images_DrawCellXY(src: Bitmap; cell: LongInt; x: Single; y: Single); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_DrawCellXY');
{$ENDIF}
try
sgImages.DrawCell(src, cell, x, y);
Except on exc: Exception do
TrapException(exc, 'sg_Images_DrawCellXY');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_DrawCellXY');
{$ENDIF}
end;
procedure sg_Images_FreeBitmap(var bitmapToFree: Bitmap); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_FreeBitmap');
{$ENDIF}
try
sgImages.FreeBitmap(bitmapToFree);
Except on exc: Exception do
TrapException(exc, 'sg_Images_FreeBitmap');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_FreeBitmap');
{$ENDIF}
end;
function sg_Images_HasBitmap(name: PChar): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_HasBitmap');
{$ENDIF}
try
result := sgImages.HasBitmap(name);
Except on exc: Exception do
TrapException(exc, 'sg_Images_HasBitmap');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_HasBitmap');
{$ENDIF}
end;
function sg_Images_LoadBitmap(filename: PChar): Bitmap; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_LoadBitmap');
{$ENDIF}
try
result := sgImages.LoadBitmap(filename);
Except on exc: Exception do
TrapException(exc, 'sg_Images_LoadBitmap');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_LoadBitmap');
{$ENDIF}
end;
function sg_Images_LoadBitmapWithTransparentColor(filename: PChar; transparent: Boolean; transparentColor: LongWord): Bitmap; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_LoadBitmapWithTransparentColor');
{$ENDIF}
try
result := sgImages.LoadBitmap(filename, transparent, transparentColor);
Except on exc: Exception do
TrapException(exc, 'sg_Images_LoadBitmapWithTransparentColor');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_LoadBitmapWithTransparentColor');
{$ENDIF}
end;
procedure sg_Images_MakeOpaque(bmp: Bitmap); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_MakeOpaque');
{$ENDIF}
try
sgImages.MakeOpaque(bmp);
Except on exc: Exception do
TrapException(exc, 'sg_Images_MakeOpaque');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_MakeOpaque');
{$ENDIF}
end;
procedure sg_Images_MakeTransparent(bmp: Bitmap); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_MakeTransparent');
{$ENDIF}
try
sgImages.MakeTransparent(bmp);
Except on exc: Exception do
TrapException(exc, 'sg_Images_MakeTransparent');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_MakeTransparent');
{$ENDIF}
end;
function sg_Images_MapBitmap(name: PChar; filename: PChar): Bitmap; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_MapBitmap');
{$ENDIF}
try
result := sgImages.MapBitmap(name, filename);
Except on exc: Exception do
TrapException(exc, 'sg_Images_MapBitmap');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_MapBitmap');
{$ENDIF}
end;
function sg_Images_MapTransparentBitmap(name: PChar; filename: PChar; transparentColor: LongWord): Bitmap; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_MapTransparentBitmap');
{$ENDIF}
try
result := sgImages.MapTransparentBitmap(name, filename, transparentColor);
Except on exc: Exception do
TrapException(exc, 'sg_Images_MapTransparentBitmap');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_MapTransparentBitmap');
{$ENDIF}
end;
procedure sg_Images_OptimiseBitmap(surface: Bitmap); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_OptimiseBitmap');
{$ENDIF}
try
sgImages.OptimiseBitmap(surface);
Except on exc: Exception do
TrapException(exc, 'sg_Images_OptimiseBitmap');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_OptimiseBitmap');
{$ENDIF}
end;
function sg_Images_PixelDrawnAtPoint(bmp: Bitmap; x: LongInt; y: LongInt): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_PixelDrawnAtPoint');
{$ENDIF}
try
result := sgImages.PixelDrawnAtPoint(bmp, x, y);
Except on exc: Exception do
TrapException(exc, 'sg_Images_PixelDrawnAtPoint');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_PixelDrawnAtPoint');
{$ENDIF}
end;
procedure sg_Images_ReleaseAllBitmaps(); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_ReleaseAllBitmaps');
{$ENDIF}
try
sgImages.ReleaseAllBitmaps();
Except on exc: Exception do
TrapException(exc, 'sg_Images_ReleaseAllBitmaps');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_ReleaseAllBitmaps');
{$ENDIF}
end;
procedure sg_Images_ReleaseBitmap(name: PChar); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_ReleaseBitmap');
{$ENDIF}
try
sgImages.ReleaseBitmap(name);
Except on exc: Exception do
TrapException(exc, 'sg_Images_ReleaseBitmap');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_ReleaseBitmap');
{$ENDIF}
end;
function sg_Images_RotateScaleBitmap(src: Bitmap; degRot: Single; scale: Single): Bitmap; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_RotateScaleBitmap');
{$ENDIF}
try
result := sgImages.RotateScaleBitmap(src, degRot, scale);
Except on exc: Exception do
TrapException(exc, 'sg_Images_RotateScaleBitmap');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_RotateScaleBitmap');
{$ENDIF}
end;
function sg_Images_SameBitmapCell(var bmp1: BitmapCell; var bmp2: BitmapCell): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_SameBitmapCell');
{$ENDIF}
try
result := sgImages.SameBitmapCell(bmp1, bmp2);
Except on exc: Exception do
TrapException(exc, 'sg_Images_SameBitmapCell');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_SameBitmapCell');
{$ENDIF}
end;
procedure sg_Images_SaveBitmap(src: Bitmap; filepath: PChar); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_SaveBitmap');
{$ENDIF}
try
sgImages.SaveBitmap(src, filepath);
Except on exc: Exception do
TrapException(exc, 'sg_Images_SaveBitmap');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_SaveBitmap');
{$ENDIF}
end;
procedure sg_Images_SaveToPNG(bmp: Bitmap; filename: PChar); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_SaveToPNG');
{$ENDIF}
try
sgImages.SaveToPNG(bmp, filename);
Except on exc: Exception do
TrapException(exc, 'sg_Images_SaveToPNG');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_SaveToPNG');
{$ENDIF}
end;
procedure sg_Images_SetOpacity(bmp: Bitmap; pct: Single); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_SetOpacity');
{$ENDIF}
try
sgImages.SetOpacity(bmp, pct);
Except on exc: Exception do
TrapException(exc, 'sg_Images_SetOpacity');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_SetOpacity');
{$ENDIF}
end;
procedure sg_Images_SetTransparentColor(src: Bitmap; clr: LongWord); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_SetTransparentColor');
{$ENDIF}
try
sgImages.SetTransparentColor(src, clr);
Except on exc: Exception do
TrapException(exc, 'sg_Images_SetTransparentColor');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_SetTransparentColor');
{$ENDIF}
end;
procedure sg_Images_SetupBitmapForCollisions(src: Bitmap); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Images_SetupBitmapForCollisions');
{$ENDIF}
try
sgImages.SetupBitmapForCollisions(src);
Except on exc: Exception do
TrapException(exc, 'sg_Images_SetupBitmapForCollisions');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Images_SetupBitmapForCollisions');
{$ENDIF}
end;
function sg_Input_AnyKeyPressed(): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Input_AnyKeyPressed');
{$ENDIF}
try
result := sgInput.AnyKeyPressed();
Except on exc: Exception do
TrapException(exc, 'sg_Input_AnyKeyPressed');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Input_AnyKeyPressed');
{$ENDIF}
end;
procedure sg_Input_EndReadingText(result: PChar); cdecl; export;
var
result_temp: String;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Input_EndReadingText');
{$ENDIF}
try
result_temp := sgInput.EndReadingText();
StrCopy(result, PChar(result_temp));
Except on exc: Exception do
TrapException(exc, 'sg_Input_EndReadingText');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Input_EndReadingText');
{$ENDIF}
end;
procedure sg_Input_HideMouse(); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Input_HideMouse');
{$ENDIF}
try
sgInput.HideMouse();
Except on exc: Exception do
TrapException(exc, 'sg_Input_HideMouse');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Input_HideMouse');
{$ENDIF}
end;
function sg_Input_KeyDown(key: KeyCode): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Input_KeyDown');
{$ENDIF}
try
result := sgInput.KeyDown(key);
Except on exc: Exception do
TrapException(exc, 'sg_Input_KeyDown');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Input_KeyDown');
{$ENDIF}
end;
procedure sg_Input_KeyName(key: KeyCode; result: PChar); cdecl; export;
var
result_temp: String;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Input_KeyName');
{$ENDIF}
try
result_temp := sgInput.KeyName(key);
StrCopy(result, PChar(result_temp));
Except on exc: Exception do
TrapException(exc, 'sg_Input_KeyName');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Input_KeyName');
{$ENDIF}
end;
function sg_Input_KeyTyped(key: KeyCode): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Input_KeyTyped');
{$ENDIF}
try
result := sgInput.KeyTyped(key);
Except on exc: Exception do
TrapException(exc, 'sg_Input_KeyTyped');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Input_KeyTyped');
{$ENDIF}
end;
function sg_Input_MouseClicked(button: MouseButton): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Input_MouseClicked');
{$ENDIF}
try
result := sgInput.MouseClicked(button);
Except on exc: Exception do
TrapException(exc, 'sg_Input_MouseClicked');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Input_MouseClicked');
{$ENDIF}
end;
function sg_Input_MouseDown(button: MouseButton): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Input_MouseDown');
{$ENDIF}
try
result := sgInput.MouseDown(button);
Except on exc: Exception do
TrapException(exc, 'sg_Input_MouseDown');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Input_MouseDown');
{$ENDIF}
end;
function sg_Input_MouseMovement(): Vector; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Input_MouseMovement');
{$ENDIF}
try
result := sgInput.MouseMovement();
Except on exc: Exception do
TrapException(exc, 'sg_Input_MouseMovement');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Input_MouseMovement');
{$ENDIF}
end;
function sg_Input_MousePosition(): Point2D; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Input_MousePosition');
{$ENDIF}
try
result := sgInput.MousePosition();
Except on exc: Exception do
TrapException(exc, 'sg_Input_MousePosition');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Input_MousePosition');
{$ENDIF}
end;
function sg_Input_MousePositionAsVector(): Vector; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Input_MousePositionAsVector');
{$ENDIF}
try
result := sgInput.MousePositionAsVector();
Except on exc: Exception do
TrapException(exc, 'sg_Input_MousePositionAsVector');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Input_MousePositionAsVector');
{$ENDIF}
end;
function sg_Input_MouseShown(): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Input_MouseShown');
{$ENDIF}
try
result := sgInput.MouseShown();
Except on exc: Exception do
TrapException(exc, 'sg_Input_MouseShown');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Input_MouseShown');
{$ENDIF}
end;
function sg_Input_MouseUp(button: MouseButton): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Input_MouseUp');
{$ENDIF}
try
result := sgInput.MouseUp(button);
Except on exc: Exception do
TrapException(exc, 'sg_Input_MouseUp');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Input_MouseUp');
{$ENDIF}
end;
function sg_Input_MouseX(): Single; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Input_MouseX');
{$ENDIF}
try
result := sgInput.MouseX();
Except on exc: Exception do
TrapException(exc, 'sg_Input_MouseX');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Input_MouseX');
{$ENDIF}
end;
function sg_Input_MouseY(): Single; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Input_MouseY');
{$ENDIF}
try
result := sgInput.MouseY();
Except on exc: Exception do
TrapException(exc, 'sg_Input_MouseY');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Input_MouseY');
{$ENDIF}
end;
procedure sg_Input_MoveMouse(x: UInt16; y: UInt16); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Input_MoveMouse');
{$ENDIF}
try
sgInput.MoveMouse(x, y);
Except on exc: Exception do
TrapException(exc, 'sg_Input_MoveMouse');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Input_MoveMouse');
{$ENDIF}
end;
procedure sg_Input_MoveMouseToPoint(var point: Point2D); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Input_MoveMouseToPoint');
{$ENDIF}
try
sgInput.MoveMouse(point);
Except on exc: Exception do
TrapException(exc, 'sg_Input_MoveMouseToPoint');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Input_MoveMouseToPoint');
{$ENDIF}
end;
function sg_Input_ReadingText(): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Input_ReadingText');
{$ENDIF}
try
result := sgInput.ReadingText();
Except on exc: Exception do
TrapException(exc, 'sg_Input_ReadingText');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Input_ReadingText');
{$ENDIF}
end;
procedure sg_Input_SetMouseVisible(show: Boolean); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Input_SetMouseVisible');
{$ENDIF}
try
sgInput.ShowMouse(show);
Except on exc: Exception do
TrapException(exc, 'sg_Input_SetMouseVisible');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Input_SetMouseVisible');
{$ENDIF}
end;
procedure sg_Input_ShowMouse(); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Input_ShowMouse');
{$ENDIF}
try
sgInput.ShowMouse();
Except on exc: Exception do
TrapException(exc, 'sg_Input_ShowMouse');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Input_ShowMouse');
{$ENDIF}
end;
procedure sg_Input_StartReadingText(textColor: LongWord; maxLength: LongInt; theFont: Font; x: LongInt; y: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Input_StartReadingText');
{$ENDIF}
try
sgInput.StartReadingText(textColor, maxLength, theFont, x, y);
Except on exc: Exception do
TrapException(exc, 'sg_Input_StartReadingText');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Input_StartReadingText');
{$ENDIF}
end;
procedure sg_Input_StartReadingTextWithText(text: PChar; textColor: LongWord; maxLength: LongInt; theFont: Font; x: LongInt; y: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Input_StartReadingTextWithText');
{$ENDIF}
try
sgInput.StartReadingTextWithText(text, textColor, maxLength, theFont, x, y);
Except on exc: Exception do
TrapException(exc, 'sg_Input_StartReadingTextWithText');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Input_StartReadingTextWithText');
{$ENDIF}
end;
procedure sg_Input_StartReadingTextWithTextAtPt(text: PChar; textColor: LongWord; maxLength: LongInt; theFont: Font; var pt: Point2D); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Input_StartReadingTextWithTextAtPt');
{$ENDIF}
try
sgInput.StartReadingTextWithText(text, textColor, maxLength, theFont, pt);
Except on exc: Exception do
TrapException(exc, 'sg_Input_StartReadingTextWithTextAtPt');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Input_StartReadingTextWithTextAtPt');
{$ENDIF}
end;
procedure sg_Input_StartReadingTextWithTextInArea(text: PChar; textColor: LongWord; maxLength: LongInt; theFont: Font; var area: Rectangle); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Input_StartReadingTextWithTextInArea');
{$ENDIF}
try
sgInput.StartReadingTextWithText(text, textColor, maxLength, theFont, area);
Except on exc: Exception do
TrapException(exc, 'sg_Input_StartReadingTextWithTextInArea');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Input_StartReadingTextWithTextInArea');
{$ENDIF}
end;
procedure sg_Input_StartReadingTextWithinArea(textColor: LongWord; maxLength: LongInt; theFont: Font; var area: Rectangle); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Input_StartReadingTextWithinArea');
{$ENDIF}
try
sgInput.StartReadingText(textColor, maxLength, theFont, area);
Except on exc: Exception do
TrapException(exc, 'sg_Input_StartReadingTextWithinArea');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Input_StartReadingTextWithinArea');
{$ENDIF}
end;
function sg_Input_TextEntryCancelled(): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Input_TextEntryCancelled');
{$ENDIF}
try
result := sgInput.TextEntryCancelled();
Except on exc: Exception do
TrapException(exc, 'sg_Input_TextEntryCancelled');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Input_TextEntryCancelled');
{$ENDIF}
end;
procedure sg_Input_TextReadAsASCII(result: PChar); cdecl; export;
var
result_temp: String;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Input_TextReadAsASCII');
{$ENDIF}
try
result_temp := sgInput.TextReadAsASCII();
StrCopy(result, PChar(result_temp));
Except on exc: Exception do
TrapException(exc, 'sg_Input_TextReadAsASCII');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Input_TextReadAsASCII');
{$ENDIF}
end;
function sg_Physics_BitmapAtPointsCollision(bmp1: Bitmap; var pt1: Point2D; bmp2: Bitmap; var pt2: Point2D): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Physics_BitmapAtPointsCollision');
{$ENDIF}
try
result := sgPhysics.BitmapCollision(bmp1, pt1, bmp2, pt2);
Except on exc: Exception do
TrapException(exc, 'sg_Physics_BitmapAtPointsCollision');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Physics_BitmapAtPointsCollision');
{$ENDIF}
end;
function sg_Physics_BitmapCollision(bmp1: Bitmap; x1: LongInt; y1: LongInt; bmp2: Bitmap; x2: LongInt; y2: LongInt): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Physics_BitmapCollision');
{$ENDIF}
try
result := sgPhysics.BitmapCollision(bmp1, x1, y1, bmp2, x2, y2);
Except on exc: Exception do
TrapException(exc, 'sg_Physics_BitmapCollision');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Physics_BitmapCollision');
{$ENDIF}
end;
function sg_Physics_BitmapPartAtPtRectCollision(bmp: Bitmap; var pt: Point2D; var part: Rectangle; var rect: Rectangle): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Physics_BitmapPartAtPtRectCollision');
{$ENDIF}
try
result := sgPhysics.BitmapRectCollision(bmp, pt, part, rect);
Except on exc: Exception do
TrapException(exc, 'sg_Physics_BitmapPartAtPtRectCollision');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Physics_BitmapPartAtPtRectCollision');
{$ENDIF}
end;
function sg_Physics_BitmapPartRectCollision(bmp: Bitmap; x: LongInt; y: LongInt; var part: Rectangle; var rect: Rectangle): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Physics_BitmapPartRectCollision');
{$ENDIF}
try
result := sgPhysics.BitmapRectCollision(bmp, x, y, part, rect);
Except on exc: Exception do
TrapException(exc, 'sg_Physics_BitmapPartRectCollision');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Physics_BitmapPartRectCollision');
{$ENDIF}
end;
function sg_Physics_BitmapPointCollision(bmp: Bitmap; x: LongInt; y: LongInt; ptX: Single; ptY: Single): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Physics_BitmapPointCollision');
{$ENDIF}
try
result := sgPhysics.BitmapPointCollision(bmp, x, y, ptX, ptY);
Except on exc: Exception do
TrapException(exc, 'sg_Physics_BitmapPointCollision');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Physics_BitmapPointCollision');
{$ENDIF}
end;
function sg_Physics_BitmapPointCollisionPart(bmp: Bitmap; x: LongInt; y: LongInt; var part: Rectangle; ptX: Single; ptY: Single): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Physics_BitmapPointCollisionPart');
{$ENDIF}
try
result := sgPhysics.BitmapPointCollisionPart(bmp, x, y, part, ptX, ptY);
Except on exc: Exception do
TrapException(exc, 'sg_Physics_BitmapPointCollisionPart');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Physics_BitmapPointCollisionPart');
{$ENDIF}
end;
function sg_Physics_BitmapPointPtCollision(bmp: Bitmap; x: LongInt; y: LongInt; var pt: Point2D): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Physics_BitmapPointPtCollision');
{$ENDIF}
try
result := sgPhysics.BitmapPointCollision(bmp, x, y, pt);
Except on exc: Exception do
TrapException(exc, 'sg_Physics_BitmapPointPtCollision');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Physics_BitmapPointPtCollision');
{$ENDIF}
end;
function sg_Physics_BitmapPointXYCollisionPart(bmp: Bitmap; x: LongInt; y: LongInt; var part: Rectangle; var pt: Point2D): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Physics_BitmapPointXYCollisionPart');
{$ENDIF}
try
result := sgPhysics.BitmapPointCollisionPart(bmp, x, y, part, pt);
Except on exc: Exception do
TrapException(exc, 'sg_Physics_BitmapPointXYCollisionPart');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Physics_BitmapPointXYCollisionPart');
{$ENDIF}
end;
function sg_Physics_BitmapRectCollision(bmp: Bitmap; x: LongInt; y: LongInt; rectX: LongInt; rectY: LongInt; rectWidth: LongInt; rectHeight: LongInt): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Physics_BitmapRectCollision');
{$ENDIF}
try
result := sgPhysics.BitmapRectCollision(bmp, x, y, rectX, rectY, rectWidth, rectHeight);
Except on exc: Exception do
TrapException(exc, 'sg_Physics_BitmapRectCollision');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Physics_BitmapRectCollision');
{$ENDIF}
end;
function sg_Physics_BitmapRectangleCollision(bmp: Bitmap; x: LongInt; y: LongInt; var rect: Rectangle): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Physics_BitmapRectangleCollision');
{$ENDIF}
try
result := sgPhysics.BitmapRectCollision(bmp, x, y, rect);
Except on exc: Exception do
TrapException(exc, 'sg_Physics_BitmapRectangleCollision');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Physics_BitmapRectangleCollision');
{$ENDIF}
end;
function sg_Physics_BitmapsPartsCollision(bmp1: Bitmap; var pt1: Point2D; var part1: Rectangle; bmp2: Bitmap; var pt2: Point2D; var part2: Rectangle): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Physics_BitmapsPartsCollision');
{$ENDIF}
try
result := sgPhysics.BitmapCollision(bmp1, pt1, part1, bmp2, pt2, part2);
Except on exc: Exception do
TrapException(exc, 'sg_Physics_BitmapsPartsCollision');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Physics_BitmapsPartsCollision');
{$ENDIF}
end;
function sg_Physics_CellBitmapCollision(bmp1: Bitmap; cell: LongInt; x1: LongInt; y1: LongInt; bmp2: Bitmap; x2: LongInt; y2: LongInt): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Physics_CellBitmapCollision');
{$ENDIF}
try
result := sgPhysics.CellBitmapCollision(bmp1, cell, x1, y1, bmp2, x2, y2);
Except on exc: Exception do
TrapException(exc, 'sg_Physics_CellBitmapCollision');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Physics_CellBitmapCollision');
{$ENDIF}
end;
function sg_Physics_CellBitmapCollisionAtPt(bmp1: Bitmap; cell: LongInt; var pt1: Point2D; bmp2: Bitmap; var pt2: Point2D): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Physics_CellBitmapCollisionAtPt');
{$ENDIF}
try
result := sgPhysics.CellBitmapCollision(bmp1, cell, pt1, bmp2, pt2);
Except on exc: Exception do
TrapException(exc, 'sg_Physics_CellBitmapCollisionAtPt');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Physics_CellBitmapCollisionAtPt');
{$ENDIF}
end;
function sg_Physics_CellBitmapPartCollision(bmp1: Bitmap; cell: LongInt; x1: LongInt; y1: LongInt; bmp2: Bitmap; x2: LongInt; y2: LongInt; var part: Rectangle): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Physics_CellBitmapPartCollision');
{$ENDIF}
try
result := sgPhysics.CellBitmapCollision(bmp1, cell, x1, y1, bmp2, x2, y2, part);
Except on exc: Exception do
TrapException(exc, 'sg_Physics_CellBitmapPartCollision');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Physics_CellBitmapPartCollision');
{$ENDIF}
end;
function sg_Physics_CellBitmapPartCollisionAtPt(bmp1: Bitmap; cell: LongInt; var pt1: Point2D; bmp2: Bitmap; var pt2: Point2D; var part: Rectangle): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Physics_CellBitmapPartCollisionAtPt');
{$ENDIF}
try
result := sgPhysics.CellBitmapCollision(bmp1, cell, pt1, bmp2, pt2, part);
Except on exc: Exception do
TrapException(exc, 'sg_Physics_CellBitmapPartCollisionAtPt');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Physics_CellBitmapPartCollisionAtPt');
{$ENDIF}
end;
function sg_Physics_CellCollision(bmp1: Bitmap; cell1: LongInt; x1: LongInt; y1: LongInt; bmp2: Bitmap; cell2: LongInt; x2: LongInt; y2: LongInt): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Physics_CellCollision');
{$ENDIF}
try
result := sgPhysics.CellCollision(bmp1, cell1, x1, y1, bmp2, cell2, x2, y2);
Except on exc: Exception do
TrapException(exc, 'sg_Physics_CellCollision');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Physics_CellCollision');
{$ENDIF}
end;
function sg_Physics_CellCollisionAtPt(bmp1: Bitmap; cell1: LongInt; var pt1: Point2D; bmp2: Bitmap; cell2: LongInt; var pt2: Point2D): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Physics_CellCollisionAtPt');
{$ENDIF}
try
result := sgPhysics.CellCollision(bmp1, cell1, pt1, bmp2, cell2, pt2);
Except on exc: Exception do
TrapException(exc, 'sg_Physics_CellCollisionAtPt');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Physics_CellCollisionAtPt');
{$ENDIF}
end;
function sg_Physics_CellRectCollision(bmp: Bitmap; cell: LongInt; x: LongInt; y: LongInt; var rect: Rectangle): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Physics_CellRectCollision');
{$ENDIF}
try
result := sgPhysics.CellRectCollision(bmp, cell, x, y, rect);
Except on exc: Exception do
TrapException(exc, 'sg_Physics_CellRectCollision');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Physics_CellRectCollision');
{$ENDIF}
end;
function sg_Physics_CellRectCollisionAtPt(bmp: Bitmap; cell: LongInt; var pt: Point2D; var rect: Rectangle): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Physics_CellRectCollisionAtPt');
{$ENDIF}
try
result := sgPhysics.CellRectCollision(bmp, cell, pt, rect);
Except on exc: Exception do
TrapException(exc, 'sg_Physics_CellRectCollisionAtPt');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Physics_CellRectCollisionAtPt');
{$ENDIF}
end;
function sg_Physics_CircleCircleCollision(var c1: Circle; var c2: Circle): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Physics_CircleCircleCollision');
{$ENDIF}
try
result := sgPhysics.CircleCircleCollision(c1, c2);
Except on exc: Exception do
TrapException(exc, 'sg_Physics_CircleCircleCollision');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Physics_CircleCircleCollision');
{$ENDIF}
end;
function sg_Physics_CircleLinesCollision(var c: Circle; lines: LineSegmentPtr; lines_len: LongInt): Boolean; cdecl; export;
var
lines_temp: LinesArray;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Physics_CircleLinesCollision');
{$ENDIF}
try
LineCopyFromPtr(lines, lines_len, lines_temp);
result := sgPhysics.CircleLinesCollision(c, lines_temp);
Except on exc: Exception do
TrapException(exc, 'sg_Physics_CircleLinesCollision');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Physics_CircleLinesCollision');
{$ENDIF}
end;
function sg_Physics_CircleRectCollision(var c: Circle; var rect: Rectangle): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Physics_CircleRectCollision');
{$ENDIF}
try
result := sgPhysics.CircleRectCollision(c, rect);
Except on exc: Exception do
TrapException(exc, 'sg_Physics_CircleRectCollision');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Physics_CircleRectCollision');
{$ENDIF}
end;
function sg_Physics_CircleTriangleCollision(var c: Circle; tri: Point2DPtr): Boolean; cdecl; export;
var
tri_temp: Triangle;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Physics_CircleTriangleCollision');
{$ENDIF}
try
TriCopyFromPtr(tri_temp, tri);
result := sgPhysics.CircleTriangleCollision(c, tri_temp);
Except on exc: Exception do
TrapException(exc, 'sg_Physics_CircleTriangleCollision');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Physics_CircleTriangleCollision');
{$ENDIF}
end;
procedure sg_Physics_CollideCircleCircle(s: Sprite; var c: Circle); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Physics_CollideCircleCircle');
{$ENDIF}
try
sgPhysics.CollideCircleCircle(s, c);
Except on exc: Exception do
TrapException(exc, 'sg_Physics_CollideCircleCircle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Physics_CollideCircleCircle');
{$ENDIF}
end;
procedure sg_Physics_CollideCircleLine(s: Sprite; var line: LineSegment); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Physics_CollideCircleLine');
{$ENDIF}
try
sgPhysics.CollideCircleLine(s, line);
Except on exc: Exception do
TrapException(exc, 'sg_Physics_CollideCircleLine');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Physics_CollideCircleLine');
{$ENDIF}
end;
procedure sg_Physics_CollideCircleLines(s: Sprite; lines: LineSegmentPtr; lines_len: LongInt); cdecl; export;
var
lines_temp: LinesArray;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Physics_CollideCircleLines');
{$ENDIF}
try
LineCopyFromPtr(lines, lines_len, lines_temp);
sgPhysics.CollideCircleLines(s, lines_temp);
Except on exc: Exception do
TrapException(exc, 'sg_Physics_CollideCircleLines');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Physics_CollideCircleLines');
{$ENDIF}
end;
procedure sg_Physics_CollideCircleRectangle(s: Sprite; var rect: Rectangle); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Physics_CollideCircleRectangle');
{$ENDIF}
try
sgPhysics.CollideCircleRectangle(s, rect);
Except on exc: Exception do
TrapException(exc, 'sg_Physics_CollideCircleRectangle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Physics_CollideCircleRectangle');
{$ENDIF}
end;
procedure sg_Physics_CollideCircles(s1: Sprite; s2: Sprite); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Physics_CollideCircles');
{$ENDIF}
try
sgPhysics.CollideCircles(s1, s2);
Except on exc: Exception do
TrapException(exc, 'sg_Physics_CollideCircles');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Physics_CollideCircles');
{$ENDIF}
end;
function sg_Physics_RectLineCollision(var rect: Rectangle; var line: LineSegment): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Physics_RectLineCollision');
{$ENDIF}
try
result := sgPhysics.RectLineCollision(rect, line);
Except on exc: Exception do
TrapException(exc, 'sg_Physics_RectLineCollision');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Physics_RectLineCollision');
{$ENDIF}
end;
function sg_Physics_SideForCollisionTest(var velocity: Vector): CollisionSide; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Physics_SideForCollisionTest');
{$ENDIF}
try
result := sgPhysics.SideForCollisionTest(velocity);
Except on exc: Exception do
TrapException(exc, 'sg_Physics_SideForCollisionTest');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Physics_SideForCollisionTest');
{$ENDIF}
end;
function sg_Physics_SpriteBitmapAtPointCollision(s: Sprite; bmp: Bitmap; var pt: Point2D): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Physics_SpriteBitmapAtPointCollision');
{$ENDIF}
try
result := sgPhysics.SpriteBitmapCollision(s, bmp, pt);
Except on exc: Exception do
TrapException(exc, 'sg_Physics_SpriteBitmapAtPointCollision');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Physics_SpriteBitmapAtPointCollision');
{$ENDIF}
end;
function sg_Physics_SpriteBitmapCollision(s: Sprite; bmp: Bitmap; x: Single; y: Single): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Physics_SpriteBitmapCollision');
{$ENDIF}
try
result := sgPhysics.SpriteBitmapCollision(s, bmp, x, y);
Except on exc: Exception do
TrapException(exc, 'sg_Physics_SpriteBitmapCollision');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Physics_SpriteBitmapCollision');
{$ENDIF}
end;
function sg_Physics_SpriteCircleLineCollision(s: Sprite; var line: LineSegment): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Physics_SpriteCircleLineCollision');
{$ENDIF}
try
result := sgPhysics.CircleLineCollision(s, line);
Except on exc: Exception do
TrapException(exc, 'sg_Physics_SpriteCircleLineCollision');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Physics_SpriteCircleLineCollision');
{$ENDIF}
end;
function sg_Physics_SpriteCollision(s1: Sprite; s2: Sprite): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Physics_SpriteCollision');
{$ENDIF}
try
result := sgPhysics.SpriteCollision(s1, s2);
Except on exc: Exception do
TrapException(exc, 'sg_Physics_SpriteCollision');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Physics_SpriteCollision');
{$ENDIF}
end;
function sg_Physics_SpriteRectCollision(s: Sprite; x: Single; y: Single; width: LongInt; height: LongInt): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Physics_SpriteRectCollision');
{$ENDIF}
try
result := sgPhysics.SpriteRectCollision(s, x, y, width, height);
Except on exc: Exception do
TrapException(exc, 'sg_Physics_SpriteRectCollision');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Physics_SpriteRectCollision');
{$ENDIF}
end;
function sg_Physics_SpriteRectLineCollision(s: Sprite; var line: LineSegment): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Physics_SpriteRectLineCollision');
{$ENDIF}
try
result := sgPhysics.RectLineCollision(s, line);
Except on exc: Exception do
TrapException(exc, 'sg_Physics_SpriteRectLineCollision');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Physics_SpriteRectLineCollision');
{$ENDIF}
end;
function sg_Physics_SpriteRectangleCollision(s: Sprite; var r: Rectangle): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Physics_SpriteRectangleCollision');
{$ENDIF}
try
result := sgPhysics.SpriteRectCollision(s, r);
Except on exc: Exception do
TrapException(exc, 'sg_Physics_SpriteRectangleCollision');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Physics_SpriteRectangleCollision');
{$ENDIF}
end;
function sg_Physics_SpriteShapeCollision(s: Sprite; shp: Shape): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Physics_SpriteShapeCollision');
{$ENDIF}
try
result := sgPhysics.SpriteShapeCollision(s, shp);
Except on exc: Exception do
TrapException(exc, 'sg_Physics_SpriteShapeCollision');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Physics_SpriteShapeCollision');
{$ENDIF}
end;
function sg_Physics_TriangleLineCollision(tri: Point2DPtr; var ln: LineSegment): Boolean; cdecl; export;
var
tri_temp: Triangle;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Physics_TriangleLineCollision');
{$ENDIF}
try
TriCopyFromPtr(tri_temp, tri);
result := sgPhysics.TriangleLineCollision(tri_temp, ln);
Except on exc: Exception do
TrapException(exc, 'sg_Physics_TriangleLineCollision');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Physics_TriangleLineCollision');
{$ENDIF}
end;
procedure sg_Resources_AppPath(result: PChar); cdecl; export;
var
result_temp: String;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Resources_AppPath');
{$ENDIF}
try
result_temp := sgResources.AppPath();
StrCopy(result, PChar(result_temp));
Except on exc: Exception do
TrapException(exc, 'sg_Resources_AppPath');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Resources_AppPath');
{$ENDIF}
end;
procedure sg_Resources_FilenameToResource(name: PChar; kind: ResourceKind; result: PChar); cdecl; export;
var
result_temp: String;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Resources_FilenameToResource');
{$ENDIF}
try
result_temp := sgResources.FilenameToResource(name, kind);
StrCopy(result, PChar(result_temp));
Except on exc: Exception do
TrapException(exc, 'sg_Resources_FilenameToResource');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Resources_FilenameToResource');
{$ENDIF}
end;
function sg_Resources_HasResourceBundle(name: PChar): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Resources_HasResourceBundle');
{$ENDIF}
try
result := sgResources.HasResourceBundle(name);
Except on exc: Exception do
TrapException(exc, 'sg_Resources_HasResourceBundle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Resources_HasResourceBundle');
{$ENDIF}
end;
procedure sg_Resources_LoadResourceBundle(name: PChar; showProgress: Boolean); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Resources_LoadResourceBundle');
{$ENDIF}
try
sgResources.LoadResourceBundle(name, showProgress);
Except on exc: Exception do
TrapException(exc, 'sg_Resources_LoadResourceBundle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Resources_LoadResourceBundle');
{$ENDIF}
end;
procedure sg_Resources_MapResourceBundle(name: PChar; filename: PChar; showProgress: Boolean); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Resources_MapResourceBundle');
{$ENDIF}
try
sgResources.MapResourceBundle(name, filename, showProgress);
Except on exc: Exception do
TrapException(exc, 'sg_Resources_MapResourceBundle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Resources_MapResourceBundle');
{$ENDIF}
end;
procedure sg_Resources_PathToOtherResource(filename: PChar; result: PChar); cdecl; export;
var
result_temp: String;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Resources_PathToOtherResource');
{$ENDIF}
try
result_temp := sgResources.PathToResource(filename);
StrCopy(result, PChar(result_temp));
Except on exc: Exception do
TrapException(exc, 'sg_Resources_PathToOtherResource');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Resources_PathToOtherResource');
{$ENDIF}
end;
procedure sg_Resources_PathToOtherResourceWithBase(path: PChar; filename: PChar; result: PChar); cdecl; export;
var
result_temp: String;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Resources_PathToOtherResourceWithBase');
{$ENDIF}
try
result_temp := sgResources.PathToResourceWithBase(path, filename);
StrCopy(result, PChar(result_temp));
Except on exc: Exception do
TrapException(exc, 'sg_Resources_PathToOtherResourceWithBase');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Resources_PathToOtherResourceWithBase');
{$ENDIF}
end;
procedure sg_Resources_PathToResource(filename: PChar; kind: ResourceKind; result: PChar); cdecl; export;
var
result_temp: String;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Resources_PathToResource');
{$ENDIF}
try
result_temp := sgResources.PathToResource(filename, kind);
StrCopy(result, PChar(result_temp));
Except on exc: Exception do
TrapException(exc, 'sg_Resources_PathToResource');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Resources_PathToResource');
{$ENDIF}
end;
procedure sg_Resources_PathToResourceWithBase(path: PChar; filename: PChar; kind: ResourceKind; result: PChar); cdecl; export;
var
result_temp: String;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Resources_PathToResourceWithBase');
{$ENDIF}
try
result_temp := sgResources.PathToResourceWithBase(path, filename, kind);
StrCopy(result, PChar(result_temp));
Except on exc: Exception do
TrapException(exc, 'sg_Resources_PathToResourceWithBase');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Resources_PathToResourceWithBase');
{$ENDIF}
end;
procedure sg_Resources_PathToResourceWithSubPaths(filename: PChar; kind: ResourceKind; subPaths: StringPtr; result: PChar; subPaths_len: LongInt); cdecl; export;
var
subPaths_temp: StringArray;
result_temp: String;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Resources_PathToResourceWithSubPaths');
{$ENDIF}
try
StringCopyFromPtr(subPaths, subPaths_len, subPaths_temp);
result_temp := sgResources.PathToResource(filename, kind, subPaths_temp);
StrCopy(result, PChar(result_temp));
Except on exc: Exception do
TrapException(exc, 'sg_Resources_PathToResourceWithSubPaths');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Resources_PathToResourceWithSubPaths');
{$ENDIF}
end;
procedure sg_Resources_RegisterFreeNotifier(fn: FreeNotifier); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Resources_RegisterFreeNotifier');
{$ENDIF}
try
sgResources.RegisterFreeNotifier(fn);
Except on exc: Exception do
TrapException(exc, 'sg_Resources_RegisterFreeNotifier');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Resources_RegisterFreeNotifier');
{$ENDIF}
end;
procedure sg_Resources_ReleaseAllResources(); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Resources_ReleaseAllResources');
{$ENDIF}
try
sgResources.ReleaseAllResources();
Except on exc: Exception do
TrapException(exc, 'sg_Resources_ReleaseAllResources');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Resources_ReleaseAllResources');
{$ENDIF}
end;
procedure sg_Resources_ReleaseResourceBundle(name: PChar); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Resources_ReleaseResourceBundle');
{$ENDIF}
try
sgResources.ReleaseResourceBundle(name);
Except on exc: Exception do
TrapException(exc, 'sg_Resources_ReleaseResourceBundle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Resources_ReleaseResourceBundle');
{$ENDIF}
end;
procedure sg_Resources_SetAppPath(path: PChar); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Resources_SetAppPath');
{$ENDIF}
try
sgResources.SetAppPath(path);
Except on exc: Exception do
TrapException(exc, 'sg_Resources_SetAppPath');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Resources_SetAppPath');
{$ENDIF}
end;
procedure sg_Resources_SetAppPathWithExe(path: PChar; withExe: Boolean); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Resources_SetAppPathWithExe');
{$ENDIF}
try
sgResources.SetAppPath(path, withExe);
Except on exc: Exception do
TrapException(exc, 'sg_Resources_SetAppPathWithExe');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Resources_SetAppPathWithExe');
{$ENDIF}
end;
procedure sg_Resources_ShowLogos(); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Resources_ShowLogos');
{$ENDIF}
try
sgResources.ShowLogos();
Except on exc: Exception do
TrapException(exc, 'sg_Resources_ShowLogos');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Resources_ShowLogos');
{$ENDIF}
end;
function sg_Sprites_CenterPoint(s: Sprite): Point2D; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_CenterPoint');
{$ENDIF}
try
result := sgSprites.CenterPoint(s);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_CenterPoint');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_CenterPoint');
{$ENDIF}
end;
function sg_Sprites_CreateBasicSprite(layer: Bitmap): Sprite; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_CreateBasicSprite');
{$ENDIF}
try
result := sgSprites.CreateSprite(layer);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_CreateBasicSprite');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_CreateBasicSprite');
{$ENDIF}
end;
function sg_Sprites_CreateLayeredSprite(layers: BitmapPtr; layers_len: LongInt): Sprite; cdecl; export;
var
layers_temp: BitmapArray;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_CreateLayeredSprite');
{$ENDIF}
try
BmpCopyFromPtr(layers, layers_len, layers_temp);
result := sgSprites.CreateSprite(layers_temp);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_CreateLayeredSprite');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_CreateLayeredSprite');
{$ENDIF}
end;
function sg_Sprites_CreateLayeredSpriteWithAnimationTemplate(layers: BitmapPtr; ani: AnimationTemplate; layers_len: LongInt): Sprite; cdecl; export;
var
layers_temp: BitmapArray;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_CreateLayeredSpriteWithAnimationTemplate');
{$ENDIF}
try
BmpCopyFromPtr(layers, layers_len, layers_temp);
result := sgSprites.CreateSprite(layers_temp, ani);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_CreateLayeredSpriteWithAnimationTemplate');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_CreateLayeredSpriteWithAnimationTemplate');
{$ENDIF}
end;
function sg_Sprites_CreateLayeredSpriteWithLayerNames(layers: BitmapPtr; layerNames: StringPtr; layers_len: LongInt; layerNames_len: LongInt): Sprite; cdecl; export;
var
layers_temp: BitmapArray;
layerNames_temp: StringArray;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_CreateLayeredSpriteWithLayerNames');
{$ENDIF}
try
BmpCopyFromPtr(layers, layers_len, layers_temp);
StringCopyFromPtr(layerNames, layerNames_len, layerNames_temp);
result := sgSprites.CreateSprite(layers_temp, layerNames_temp);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_CreateLayeredSpriteWithLayerNames');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_CreateLayeredSpriteWithLayerNames');
{$ENDIF}
end;
function sg_Sprites_CreateLayeredSpriteWithLayerNamesAndAnimationTemplate(layers: BitmapPtr; layerNames: StringPtr; ani: AnimationTemplate; layers_len: LongInt; layerNames_len: LongInt): Sprite; cdecl; export;
var
layers_temp: BitmapArray;
layerNames_temp: StringArray;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_CreateLayeredSpriteWithLayerNamesAndAnimationTemplate');
{$ENDIF}
try
BmpCopyFromPtr(layers, layers_len, layers_temp);
StringCopyFromPtr(layerNames, layerNames_len, layerNames_temp);
result := sgSprites.CreateSprite(layers_temp, layerNames_temp, ani);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_CreateLayeredSpriteWithLayerNamesAndAnimationTemplate');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_CreateLayeredSpriteWithLayerNamesAndAnimationTemplate');
{$ENDIF}
end;
function sg_Sprites_CreateSpriteWithAnimation(layer: Bitmap; ani: AnimationTemplate): Sprite; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_CreateSpriteWithAnimation');
{$ENDIF}
try
result := sgSprites.CreateSprite(layer, ani);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_CreateSpriteWithAnimation');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_CreateSpriteWithAnimation');
{$ENDIF}
end;
function sg_Sprites_CreateSpriteWithLayer(layer: Bitmap; layerName: PChar): Sprite; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_CreateSpriteWithLayer');
{$ENDIF}
try
result := sgSprites.CreateSprite(layer, layerName);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_CreateSpriteWithLayer');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_CreateSpriteWithLayer');
{$ENDIF}
end;
function sg_Sprites_CreateSpriteWithLayerAndAnimation(layer: Bitmap; layerName: PChar; ani: AnimationTemplate): Sprite; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_CreateSpriteWithLayerAndAnimation');
{$ENDIF}
try
result := sgSprites.CreateSprite(layer, layerName, ani);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_CreateSpriteWithLayerAndAnimation');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_CreateSpriteWithLayerAndAnimation');
{$ENDIF}
end;
procedure sg_Sprites_DrawSpriteOffsetPoint(s: Sprite; var position: Point2D); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_DrawSpriteOffsetPoint');
{$ENDIF}
try
sgSprites.DrawSprite(s, position);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_DrawSpriteOffsetPoint');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_DrawSpriteOffsetPoint');
{$ENDIF}
end;
procedure sg_Sprites_DrawSpriteOffsetXY(s: Sprite; xOffset: LongInt; yOffset: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_DrawSpriteOffsetXY');
{$ENDIF}
try
sgSprites.DrawSprite(s, xOffset, yOffset);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_DrawSpriteOffsetXY');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_DrawSpriteOffsetXY');
{$ENDIF}
end;
procedure sg_Sprites_FreeSprite(var s: Sprite); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_FreeSprite');
{$ENDIF}
try
sgSprites.FreeSprite(s);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_FreeSprite');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_FreeSprite');
{$ENDIF}
end;
function sg_Sprites_IsSpriteOffscreen(s: Sprite): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_IsSpriteOffscreen');
{$ENDIF}
try
result := sgSprites.IsSpriteOffscreen(s);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_IsSpriteOffscreen');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_IsSpriteOffscreen');
{$ENDIF}
end;
procedure sg_Sprites_MoveSprite(s: Sprite; pct: Single); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_MoveSprite');
{$ENDIF}
try
sgSprites.MoveSprite(s, pct);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_MoveSprite');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_MoveSprite');
{$ENDIF}
end;
procedure sg_Sprites_MoveSpriteTo(s: Sprite; x: LongInt; y: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_MoveSpriteTo');
{$ENDIF}
try
sgSprites.MoveSpriteTo(s, x, y);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_MoveSpriteTo');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_MoveSpriteTo');
{$ENDIF}
end;
procedure sg_Sprites_MoveSpriteVecPct(s: Sprite; var velocity: Vector; pct: Single); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_MoveSpriteVecPct');
{$ENDIF}
try
sgSprites.MoveSprite(s, velocity, pct);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_MoveSpriteVecPct');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_MoveSpriteVecPct');
{$ENDIF}
end;
procedure sg_Sprites_ReplayAnimationWithSound(s: Sprite; withSound: Boolean); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_ReplayAnimationWithSound');
{$ENDIF}
try
sgSprites.SpriteReplayAnimation(s, withSound);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_ReplayAnimationWithSound');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_ReplayAnimationWithSound');
{$ENDIF}
end;
function sg_Sprites_SpriteAddLayer(s: Sprite; newLayer: Bitmap; layerName: PChar): LongInt; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteAddLayer');
{$ENDIF}
try
result := sgSprites.SpriteAddLayer(s, newLayer, layerName);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteAddLayer');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteAddLayer');
{$ENDIF}
end;
procedure sg_Sprites_SpriteAddValue(s: Sprite; name: PChar); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteAddValue');
{$ENDIF}
try
sgSprites.SpriteAddValue(s, name);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteAddValue');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteAddValue');
{$ENDIF}
end;
procedure sg_Sprites_SpriteAddValueWithInitialValue(s: Sprite; name: PChar; initVal: Single); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteAddValueWithInitialValue');
{$ENDIF}
try
sgSprites.SpriteAddValue(s, name, initVal);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteAddValueWithInitialValue');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteAddValueWithInitialValue');
{$ENDIF}
end;
function sg_Sprites_SpriteAnimationHasEnded(s: Sprite): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteAnimationHasEnded');
{$ENDIF}
try
result := sgSprites.SpriteAnimationHasEnded(s);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteAnimationHasEnded');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteAnimationHasEnded');
{$ENDIF}
end;
procedure sg_Sprites_SpriteBringLayerForward(s: Sprite; visibleLayer: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteBringLayerForward');
{$ENDIF}
try
sgSprites.SpriteBringLayerForward(s, visibleLayer);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteBringLayerForward');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteBringLayerForward');
{$ENDIF}
end;
procedure sg_Sprites_SpriteBringLayerToFront(s: Sprite; visibleLayer: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteBringLayerToFront');
{$ENDIF}
try
sgSprites.SpriteBringLayerToFront(s, visibleLayer);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteBringLayerToFront');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteBringLayerToFront');
{$ENDIF}
end;
function sg_Sprites_SpriteCircle(s: Sprite): Circle; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteCircle');
{$ENDIF}
try
result := sgSprites.SpriteCircle(s);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteCircle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteCircle');
{$ENDIF}
end;
function sg_Sprites_SpriteCollisionBitmap(s: Sprite): Bitmap; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteCollisionBitmap');
{$ENDIF}
try
result := sgSprites.SpriteCollisionBitmap(s);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteCollisionBitmap');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteCollisionBitmap');
{$ENDIF}
end;
function sg_Sprites_SpriteCollisionCircle(s: Sprite): Circle; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteCollisionCircle');
{$ENDIF}
try
result := sgSprites.SpriteCollisionCircle(s);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteCollisionCircle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteCollisionCircle');
{$ENDIF}
end;
function sg_Sprites_SpriteCollisionKind(s: Sprite): CollisionTestKind; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteCollisionKind');
{$ENDIF}
try
result := sgSprites.SpriteCollisionKind(s);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteCollisionKind');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteCollisionKind');
{$ENDIF}
end;
function sg_Sprites_SpriteCollisionRectangle(s: Sprite): Rectangle; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteCollisionRectangle');
{$ENDIF}
try
result := sgSprites.SpriteCollisionRectangle(s);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteCollisionRectangle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteCollisionRectangle');
{$ENDIF}
end;
function sg_Sprites_SpriteCurrentCell(s: Sprite): LongInt; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteCurrentCell');
{$ENDIF}
try
result := sgSprites.SpriteCurrentCell(s);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteCurrentCell');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteCurrentCell');
{$ENDIF}
end;
function sg_Sprites_SpriteCurrentCellRectangle(s: Sprite): Rectangle; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteCurrentCellRectangle');
{$ENDIF}
try
result := sgSprites.SpriteCurrentCellRectangle(s);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteCurrentCellRectangle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteCurrentCellRectangle');
{$ENDIF}
end;
function sg_Sprites_SpriteDX(s: Sprite): Single; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteDX');
{$ENDIF}
try
result := sgSprites.SpriteDX(s);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteDX');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteDX');
{$ENDIF}
end;
function sg_Sprites_SpriteDY(s: Sprite): Single; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteDY');
{$ENDIF}
try
result := sgSprites.SpriteDY(s);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteDY');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteDY');
{$ENDIF}
end;
function sg_Sprites_SpriteHeading(s: Sprite): Single; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteHeading');
{$ENDIF}
try
result := sgSprites.SpriteHeading(s);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteHeading');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteHeading');
{$ENDIF}
end;
function sg_Sprites_SpriteHeight(s: Sprite): LongInt; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteHeight');
{$ENDIF}
try
result := sgSprites.SpriteHeight(s);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteHeight');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteHeight');
{$ENDIF}
end;
procedure sg_Sprites_SpriteHideLayer(s: Sprite; id: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteHideLayer');
{$ENDIF}
try
sgSprites.SpriteHideLayer(s, id);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteHideLayer');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteHideLayer');
{$ENDIF}
end;
procedure sg_Sprites_SpriteHideLayerNamed(s: Sprite; name: PChar); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteHideLayerNamed');
{$ENDIF}
try
sgSprites.SpriteHideLayer(s, name);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteHideLayerNamed');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteHideLayerNamed');
{$ENDIF}
end;
function sg_Sprites_SpriteLayerAtIdx(s: Sprite; idx: LongInt): Bitmap; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteLayerAtIdx');
{$ENDIF}
try
result := sgSprites.SpriteLayer(s, idx);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteLayerAtIdx');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteLayerAtIdx');
{$ENDIF}
end;
function sg_Sprites_SpriteLayerCircle(s: Sprite; idx: LongInt): Circle; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteLayerCircle');
{$ENDIF}
try
result := sgSprites.SpriteLayerCircle(s, idx);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteLayerCircle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteLayerCircle');
{$ENDIF}
end;
function sg_Sprites_SpriteLayerCount(s: Sprite): LongInt; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteLayerCount');
{$ENDIF}
try
result := sgSprites.SpriteLayerCount(s);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteLayerCount');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteLayerCount');
{$ENDIF}
end;
function sg_Sprites_SpriteLayerHeight(s: Sprite; idx: LongInt): LongInt; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteLayerHeight');
{$ENDIF}
try
result := sgSprites.SpriteLayerHeight(s, idx);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteLayerHeight');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteLayerHeight');
{$ENDIF}
end;
function sg_Sprites_SpriteLayerIndex(s: Sprite; name: PChar): LongInt; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteLayerIndex');
{$ENDIF}
try
result := sgSprites.SpriteLayerIndex(s, name);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteLayerIndex');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteLayerIndex');
{$ENDIF}
end;
procedure sg_Sprites_SpriteLayerName(s: Sprite; idx: LongInt; result: PChar); cdecl; export;
var
result_temp: String;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteLayerName');
{$ENDIF}
try
result_temp := sgSprites.SpriteLayerName(s, idx);
StrCopy(result, PChar(result_temp));
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteLayerName');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteLayerName');
{$ENDIF}
end;
function sg_Sprites_SpriteLayerNamed(s: Sprite; name: PChar): Bitmap; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteLayerNamed');
{$ENDIF}
try
result := sgSprites.SpriteLayer(s, name);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteLayerNamed');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteLayerNamed');
{$ENDIF}
end;
function sg_Sprites_SpriteLayerNamedCircle(s: Sprite; name: PChar): Circle; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteLayerNamedCircle');
{$ENDIF}
try
result := sgSprites.SpriteLayerCircle(s, name);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteLayerNamedCircle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteLayerNamedCircle');
{$ENDIF}
end;
function sg_Sprites_SpriteLayerNamedHeight(s: Sprite; name: PChar): LongInt; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteLayerNamedHeight');
{$ENDIF}
try
result := sgSprites.SpriteLayerHeight(s, name);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteLayerNamedHeight');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteLayerNamedHeight');
{$ENDIF}
end;
function sg_Sprites_SpriteLayerNamedRectangle(s: Sprite; name: PChar): Rectangle; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteLayerNamedRectangle');
{$ENDIF}
try
result := sgSprites.SpriteLayerRectangle(s, name);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteLayerNamedRectangle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteLayerNamedRectangle');
{$ENDIF}
end;
function sg_Sprites_SpriteLayerNamedWidth(s: Sprite; name: PChar): LongInt; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteLayerNamedWidth');
{$ENDIF}
try
result := sgSprites.SpriteLayerWidth(s, name);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteLayerNamedWidth');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteLayerNamedWidth');
{$ENDIF}
end;
function sg_Sprites_SpriteLayerOffset(s: Sprite; idx: LongInt): Point2D; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteLayerOffset');
{$ENDIF}
try
result := sgSprites.SpriteLayerOffset(s, idx);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteLayerOffset');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteLayerOffset');
{$ENDIF}
end;
function sg_Sprites_SpriteLayerOffsetNamed(s: Sprite; name: PChar): Point2D; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteLayerOffsetNamed');
{$ENDIF}
try
result := sgSprites.SpriteLayerOffset(s, name);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteLayerOffsetNamed');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteLayerOffsetNamed');
{$ENDIF}
end;
procedure sg_Sprites_SpriteLayerOffsets(s: Sprite; result: Point2DPtr; result_len: LongInt); cdecl; export;
var
result_temp: Point2DArray;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteLayerOffsets');
{$ENDIF}
try
result_temp := sgSprites.SpriteLayerOffsets(s);
Point2DCopyToPtr(result_temp, result_len, result);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteLayerOffsets');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteLayerOffsets');
{$ENDIF}
end;
function sg_Sprites_SpriteLayerRectangle(s: Sprite; idx: LongInt): Rectangle; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteLayerRectangle');
{$ENDIF}
try
result := sgSprites.SpriteLayerRectangle(s, idx);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteLayerRectangle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteLayerRectangle');
{$ENDIF}
end;
function sg_Sprites_SpriteLayerWidth(s: Sprite; idx: LongInt): LongInt; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteLayerWidth');
{$ENDIF}
try
result := sgSprites.SpriteLayerWidth(s, idx);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteLayerWidth');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteLayerWidth');
{$ENDIF}
end;
procedure sg_Sprites_SpriteLayers(s: Sprite; result: BitmapPtr; result_len: LongInt); cdecl; export;
var
result_temp: BitmapArray;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteLayers');
{$ENDIF}
try
result_temp := sgSprites.SpriteLayers(s);
BmpCopyToPtr(result_temp, result_len, result);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteLayers');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteLayers');
{$ENDIF}
end;
function sg_Sprites_SpriteMass(s: Sprite): Single; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteMass');
{$ENDIF}
try
result := sgSprites.SpriteMass(s);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteMass');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteMass');
{$ENDIF}
end;
function sg_Sprites_SpriteOnScreenAt(s: Sprite; x: LongInt; y: LongInt): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteOnScreenAt');
{$ENDIF}
try
result := sgSprites.SpriteOnScreenAt(s, x, y);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteOnScreenAt');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteOnScreenAt');
{$ENDIF}
end;
function sg_Sprites_SpriteOnScreenAtPoint(s: Sprite; var pt: Point2D): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteOnScreenAtPoint');
{$ENDIF}
try
result := sgSprites.SpriteOnScreenAt(s, pt);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteOnScreenAtPoint');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteOnScreenAtPoint');
{$ENDIF}
end;
function sg_Sprites_SpritePosition(s: Sprite): Point2D; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpritePosition');
{$ENDIF}
try
result := sgSprites.SpritePosition(s);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpritePosition');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpritePosition');
{$ENDIF}
end;
procedure sg_Sprites_SpriteReplayAnimation(s: Sprite); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteReplayAnimation');
{$ENDIF}
try
sgSprites.SpriteReplayAnimation(s);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteReplayAnimation');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteReplayAnimation');
{$ENDIF}
end;
function sg_Sprites_SpriteRotation(s: Sprite): Single; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteRotation');
{$ENDIF}
try
result := sgSprites.SpriteRotation(s);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteRotation');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteRotation');
{$ENDIF}
end;
function sg_Sprites_SpriteScale(s: Sprite): Single; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteScale');
{$ENDIF}
try
result := sgSprites.SpriteScale(s);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteScale');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteScale');
{$ENDIF}
end;
function sg_Sprites_SpriteScreenRectangle(s: Sprite): Rectangle; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteScreenRectangle');
{$ENDIF}
try
result := sgSprites.SpriteScreenRectangle(s);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteScreenRectangle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteScreenRectangle');
{$ENDIF}
end;
procedure sg_Sprites_SpriteSendLayerBackward(s: Sprite; visibleLayer: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteSendLayerBackward');
{$ENDIF}
try
sgSprites.SpriteSendLayerBackward(s, visibleLayer);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteSendLayerBackward');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteSendLayerBackward');
{$ENDIF}
end;
procedure sg_Sprites_SpriteSendLayerToBack(s: Sprite; visibleLayer: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteSendLayerToBack');
{$ENDIF}
try
sgSprites.SpriteSendLayerToBack(s, visibleLayer);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteSendLayerToBack');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteSendLayerToBack');
{$ENDIF}
end;
procedure sg_Sprites_SpriteSetCollisionBitmap(s: Sprite; bmp: Bitmap); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteSetCollisionBitmap');
{$ENDIF}
try
sgSprites.SpriteSetCollisionBitmap(s, bmp);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteSetCollisionBitmap');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteSetCollisionBitmap');
{$ENDIF}
end;
procedure sg_Sprites_SpriteSetCollisionKind(s: Sprite; value: CollisionTestKind); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteSetCollisionKind');
{$ENDIF}
try
sgSprites.SpriteSetCollisionKind(s, value);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteSetCollisionKind');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteSetCollisionKind');
{$ENDIF}
end;
procedure sg_Sprites_SpriteSetDX(s: Sprite; value: Single); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteSetDX');
{$ENDIF}
try
sgSprites.SpriteSetDX(s, value);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteSetDX');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteSetDX');
{$ENDIF}
end;
procedure sg_Sprites_SpriteSetDY(s: Sprite; value: Single); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteSetDY');
{$ENDIF}
try
sgSprites.SpriteSetDY(s, value);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteSetDY');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteSetDY');
{$ENDIF}
end;
procedure sg_Sprites_SpriteSetHeading(s: Sprite; value: Single); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteSetHeading');
{$ENDIF}
try
sgSprites.SpriteSetHeading(s, value);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteSetHeading');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteSetHeading');
{$ENDIF}
end;
procedure sg_Sprites_SpriteSetLayerOffset(s: Sprite; idx: LongInt; var value: Point2D); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteSetLayerOffset');
{$ENDIF}
try
sgSprites.SpriteSetLayerOffset(s, idx, value);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteSetLayerOffset');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteSetLayerOffset');
{$ENDIF}
end;
procedure sg_Sprites_SpriteSetLayerOffsetNamed(s: Sprite; name: PChar; var value: Point2D); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteSetLayerOffsetNamed');
{$ENDIF}
try
sgSprites.SpriteSetLayerOffset(s, name, value);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteSetLayerOffsetNamed');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteSetLayerOffsetNamed');
{$ENDIF}
end;
procedure sg_Sprites_SpriteSetLayerOffsets(s: Sprite; value: Point2DPtr; value_len: LongInt); cdecl; export;
var
value_temp: Point2DArray;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteSetLayerOffsets');
{$ENDIF}
try
Point2DCopyFromPtr(value, value_len, value_temp);
sgSprites.SpriteSetLayerOffsets(s, value_temp);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteSetLayerOffsets');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteSetLayerOffsets');
{$ENDIF}
end;
procedure sg_Sprites_SpriteSetMass(s: Sprite; value: Single); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteSetMass');
{$ENDIF}
try
sgSprites.SpriteSetMass(s, value);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteSetMass');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteSetMass');
{$ENDIF}
end;
procedure sg_Sprites_SpriteSetPosition(s: Sprite; var value: Point2D); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteSetPosition');
{$ENDIF}
try
sgSprites.SpriteSetPosition(s, value);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteSetPosition');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteSetPosition');
{$ENDIF}
end;
procedure sg_Sprites_SpriteSetRotation(s: Sprite; value: Single); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteSetRotation');
{$ENDIF}
try
sgSprites.SpriteSetRotation(s, value);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteSetRotation');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteSetRotation');
{$ENDIF}
end;
procedure sg_Sprites_SpriteSetScale(s: Sprite; value: Single); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteSetScale');
{$ENDIF}
try
sgSprites.SpriteSetScale(s, value);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteSetScale');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteSetScale');
{$ENDIF}
end;
procedure sg_Sprites_SpriteSetSpeed(s: Sprite; value: Single); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteSetSpeed');
{$ENDIF}
try
sgSprites.SpriteSetSpeed(s, value);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteSetSpeed');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteSetSpeed');
{$ENDIF}
end;
procedure sg_Sprites_SpriteSetValue(s: Sprite; idx: LongInt; val: Single); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteSetValue');
{$ENDIF}
try
sgSprites.SpriteSetValue(s, idx, val);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteSetValue');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteSetValue');
{$ENDIF}
end;
procedure sg_Sprites_SpriteSetValueNamed(s: Sprite; name: PChar; val: Single); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteSetValueNamed');
{$ENDIF}
try
sgSprites.SpriteSetValue(s, name, val);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteSetValueNamed');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteSetValueNamed');
{$ENDIF}
end;
procedure sg_Sprites_SpriteSetVelocity(s: Sprite; var value: Vector); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteSetVelocity');
{$ENDIF}
try
sgSprites.SpriteSetVelocity(s, value);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteSetVelocity');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteSetVelocity');
{$ENDIF}
end;
procedure sg_Sprites_SpriteSetX(s: Sprite; value: Single); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteSetX');
{$ENDIF}
try
sgSprites.SpriteSetX(s, value);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteSetX');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteSetX');
{$ENDIF}
end;
procedure sg_Sprites_SpriteSetY(s: Sprite; value: Single); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteSetY');
{$ENDIF}
try
sgSprites.SpriteSetY(s, value);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteSetY');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteSetY');
{$ENDIF}
end;
function sg_Sprites_SpriteShowLayer(s: Sprite; id: LongInt): LongInt; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteShowLayer');
{$ENDIF}
try
result := sgSprites.SpriteShowLayer(s, id);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteShowLayer');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteShowLayer');
{$ENDIF}
end;
function sg_Sprites_SpriteShowLayerNamed(s: Sprite; name: PChar): LongInt; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteShowLayerNamed');
{$ENDIF}
try
result := sgSprites.SpriteShowLayer(s, name);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteShowLayerNamed');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteShowLayerNamed');
{$ENDIF}
end;
function sg_Sprites_SpriteSpeed(s: Sprite): Single; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteSpeed');
{$ENDIF}
try
result := sgSprites.SpriteSpeed(s);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteSpeed');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteSpeed');
{$ENDIF}
end;
procedure sg_Sprites_SpriteStartAnimation(s: Sprite; idx: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteStartAnimation');
{$ENDIF}
try
sgSprites.SpriteStartAnimation(s, idx);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteStartAnimation');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteStartAnimation');
{$ENDIF}
end;
procedure sg_Sprites_SpriteStartAnimationNamed(s: Sprite; named: PChar); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteStartAnimationNamed');
{$ENDIF}
try
sgSprites.SpriteStartAnimation(s, named);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteStartAnimationNamed');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteStartAnimationNamed');
{$ENDIF}
end;
procedure sg_Sprites_SpriteStartAnimationNamedWithSound(s: Sprite; named: PChar; withSound: Boolean); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteStartAnimationNamedWithSound');
{$ENDIF}
try
sgSprites.SpriteStartAnimation(s, named, withSound);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteStartAnimationNamedWithSound');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteStartAnimationNamedWithSound');
{$ENDIF}
end;
procedure sg_Sprites_SpriteStartAnimationWithSound(s: Sprite; idx: LongInt; withSound: Boolean); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteStartAnimationWithSound');
{$ENDIF}
try
sgSprites.SpriteStartAnimation(s, idx, withSound);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteStartAnimationWithSound');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteStartAnimationWithSound');
{$ENDIF}
end;
procedure sg_Sprites_SpriteToggleLayerNamedVisible(s: Sprite; name: PChar); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteToggleLayerNamedVisible');
{$ENDIF}
try
sgSprites.SpriteToggleLayerVisible(s, name);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteToggleLayerNamedVisible');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteToggleLayerNamedVisible');
{$ENDIF}
end;
procedure sg_Sprites_SpriteToggleLayerVisible(s: Sprite; id: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteToggleLayerVisible');
{$ENDIF}
try
sgSprites.SpriteToggleLayerVisible(s, id);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteToggleLayerVisible');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteToggleLayerVisible');
{$ENDIF}
end;
function sg_Sprites_SpriteValue(s: Sprite; index: LongInt): Single; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteValue');
{$ENDIF}
try
result := sgSprites.SpriteValue(s, index);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteValue');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteValue');
{$ENDIF}
end;
function sg_Sprites_SpriteValueCount(s: Sprite): LongInt; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteValueCount');
{$ENDIF}
try
result := sgSprites.SpriteValueCount(s);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteValueCount');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteValueCount');
{$ENDIF}
end;
function sg_Sprites_SpriteValueNamed(s: Sprite; name: PChar): Single; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteValueNamed');
{$ENDIF}
try
result := sgSprites.SpriteValue(s, name);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteValueNamed');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteValueNamed');
{$ENDIF}
end;
procedure sg_Sprites_SpriteValueNames(s: Sprite; result: StringPtr; result_len: LongInt); cdecl; export;
var
result_temp: StringArray;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteValueNames');
{$ENDIF}
try
result_temp := sgSprites.SpriteValueNames(s);
StringCopyToPtr(result_temp, result_len, result);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteValueNames');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteValueNames');
{$ENDIF}
end;
function sg_Sprites_SpriteVelocity(s: Sprite): Vector; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteVelocity');
{$ENDIF}
try
result := sgSprites.SpriteVelocity(s);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteVelocity');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteVelocity');
{$ENDIF}
end;
function sg_Sprites_SpriteVisibleIndexOfLayer(s: Sprite; id: LongInt): LongInt; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteVisibleIndexOfLayer');
{$ENDIF}
try
result := sgSprites.SpriteVisibleIndexOfLayer(s, id);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteVisibleIndexOfLayer');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteVisibleIndexOfLayer');
{$ENDIF}
end;
function sg_Sprites_SpriteVisibleIndexOfLayerNamed(s: Sprite; name: PChar): LongInt; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteVisibleIndexOfLayerNamed');
{$ENDIF}
try
result := sgSprites.SpriteVisibleIndexOfLayer(s, name);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteVisibleIndexOfLayerNamed');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteVisibleIndexOfLayerNamed');
{$ENDIF}
end;
function sg_Sprites_SpriteVisibleLayer(s: Sprite; idx: LongInt): LongInt; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteVisibleLayer');
{$ENDIF}
try
result := sgSprites.SpriteVisibleLayer(s, idx);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteVisibleLayer');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteVisibleLayer');
{$ENDIF}
end;
function sg_Sprites_SpriteVisibleLayerCount(s: Sprite): LongInt; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteVisibleLayerCount');
{$ENDIF}
try
result := sgSprites.SpriteVisibleLayerCount(s);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteVisibleLayerCount');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteVisibleLayerCount');
{$ENDIF}
end;
procedure sg_Sprites_SpriteVisibleLayerIds(s: Sprite; result: LongIntPtr; result_len: LongInt); cdecl; export;
var
result_temp: LongIntArray;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteVisibleLayerIds');
{$ENDIF}
try
result_temp := sgSprites.SpriteVisibleLayerIds(s);
LongIntCopyToPtr(result_temp, result_len, result);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteVisibleLayerIds');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteVisibleLayerIds');
{$ENDIF}
end;
function sg_Sprites_SpriteWidth(s: Sprite): LongInt; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteWidth');
{$ENDIF}
try
result := sgSprites.SpriteWidth(s);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteWidth');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteWidth');
{$ENDIF}
end;
function sg_Sprites_SpriteX(s: Sprite): Single; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteX');
{$ENDIF}
try
result := sgSprites.SpriteX(s);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteX');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteX');
{$ENDIF}
end;
function sg_Sprites_SpriteY(s: Sprite): Single; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_SpriteY');
{$ENDIF}
try
result := sgSprites.SpriteY(s);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_SpriteY');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_SpriteY');
{$ENDIF}
end;
procedure sg_Sprites_UpdateSpriteAnimationPctWithSound(s: Sprite; pct: Single; withSound: Boolean); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_UpdateSpriteAnimationPctWithSound');
{$ENDIF}
try
sgSprites.UpdateSpriteAnimation(s, pct, withSound);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_UpdateSpriteAnimationPctWithSound');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_UpdateSpriteAnimationPctWithSound');
{$ENDIF}
end;
procedure sg_Sprites_UpdateSpritePctWithSound(s: Sprite; pct: Single; withSound: Boolean); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_UpdateSpritePctWithSound');
{$ENDIF}
try
sgSprites.UpdateSprite(s, pct, withSound);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_UpdateSpritePctWithSound');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_UpdateSpritePctWithSound');
{$ENDIF}
end;
function sg_Sprites_VectorFromCenterSpriteToPoint(s: Sprite; var pt: Point2D): Vector; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_VectorFromCenterSpriteToPoint');
{$ENDIF}
try
result := sgSprites.VectorFromCenterSpriteToPoint(s, pt);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_VectorFromCenterSpriteToPoint');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_VectorFromCenterSpriteToPoint');
{$ENDIF}
end;
function sg_Sprites_VectorFromTo(s1: Sprite; s2: Sprite): Vector; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Sprites_VectorFromTo');
{$ENDIF}
try
result := sgSprites.VectorFromTo(s1, s2);
Except on exc: Exception do
TrapException(exc, 'sg_Sprites_VectorFromTo');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Sprites_VectorFromTo');
{$ENDIF}
end;
procedure sg_Text_DrawFrameRateWithSimpleFont(x: LongInt; y: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Text_DrawFrameRateWithSimpleFont');
{$ENDIF}
try
sgText.DrawFramerate(x, y);
Except on exc: Exception do
TrapException(exc, 'sg_Text_DrawFrameRateWithSimpleFont');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Text_DrawFrameRateWithSimpleFont');
{$ENDIF}
end;
procedure sg_Text_DrawFramerate(x: LongInt; y: LongInt; font: Font); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Text_DrawFramerate');
{$ENDIF}
try
sgText.DrawFramerate(x, y, font);
Except on exc: Exception do
TrapException(exc, 'sg_Text_DrawFramerate');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Text_DrawFramerate');
{$ENDIF}
end;
procedure sg_Text_DrawSimpleText(theText: PChar; textColor: LongWord; x: Single; y: Single); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Text_DrawSimpleText');
{$ENDIF}
try
sgText.DrawText(theText, textColor, x, y);
Except on exc: Exception do
TrapException(exc, 'sg_Text_DrawSimpleText');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Text_DrawSimpleText');
{$ENDIF}
end;
procedure sg_Text_DrawSimpleTextOnBitmap(dest: Bitmap; theText: PChar; textColor: LongWord; x: Single; y: Single); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Text_DrawSimpleTextOnBitmap');
{$ENDIF}
try
sgText.DrawText(dest, theText, textColor, x, y);
Except on exc: Exception do
TrapException(exc, 'sg_Text_DrawSimpleTextOnBitmap');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Text_DrawSimpleTextOnBitmap');
{$ENDIF}
end;
procedure sg_Text_DrawSimpleTextOnScreen(theText: PChar; textColor: LongWord; x: Single; y: Single); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Text_DrawSimpleTextOnScreen');
{$ENDIF}
try
sgText.DrawTextOnScreen(theText, textColor, x, y);
Except on exc: Exception do
TrapException(exc, 'sg_Text_DrawSimpleTextOnScreen');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Text_DrawSimpleTextOnScreen');
{$ENDIF}
end;
procedure sg_Text_DrawSimpleTextPt(theText: PChar; textColor: LongWord; var pt: Point2D); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Text_DrawSimpleTextPt');
{$ENDIF}
try
sgText.DrawText(theText, textColor, pt);
Except on exc: Exception do
TrapException(exc, 'sg_Text_DrawSimpleTextPt');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Text_DrawSimpleTextPt');
{$ENDIF}
end;
procedure sg_Text_DrawText(theText: PChar; textColor: LongWord; theFont: Font; x: Single; y: Single); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Text_DrawText');
{$ENDIF}
try
sgText.DrawText(theText, textColor, theFont, x, y);
Except on exc: Exception do
TrapException(exc, 'sg_Text_DrawText');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Text_DrawText');
{$ENDIF}
end;
procedure sg_Text_DrawTextAtPoint(theText: PChar; textColor: LongWord; theFont: Font; var pt: Point2D); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Text_DrawTextAtPoint');
{$ENDIF}
try
sgText.DrawText(theText, textColor, theFont, pt);
Except on exc: Exception do
TrapException(exc, 'sg_Text_DrawTextAtPoint');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Text_DrawTextAtPoint');
{$ENDIF}
end;
procedure sg_Text_DrawTextLines(theText: PChar; textColor: LongWord; backColor: LongWord; theFont: Font; align: FontAlignment; x: Single; y: Single; w: LongInt; h: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Text_DrawTextLines');
{$ENDIF}
try
sgText.DrawTextLines(theText, textColor, backColor, theFont, align, x, y, w, h);
Except on exc: Exception do
TrapException(exc, 'sg_Text_DrawTextLines');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Text_DrawTextLines');
{$ENDIF}
end;
procedure sg_Text_DrawTextLinesInRect(theText: PChar; textColor: LongWord; backColor: LongWord; theFont: Font; align: FontAlignment; var withinRect: Rectangle); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Text_DrawTextLinesInRect');
{$ENDIF}
try
sgText.DrawTextLines(theText, textColor, backColor, theFont, align, withinRect);
Except on exc: Exception do
TrapException(exc, 'sg_Text_DrawTextLinesInRect');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Text_DrawTextLinesInRect');
{$ENDIF}
end;
procedure sg_Text_DrawTextLinesInRectOnBitmap(dest: Bitmap; theText: PChar; textColor: LongWord; backColor: LongWord; theFont: Font; align: FontAlignment; var withinRect: Rectangle); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Text_DrawTextLinesInRectOnBitmap');
{$ENDIF}
try
sgText.DrawTextLines(dest, theText, textColor, backColor, theFont, align, withinRect);
Except on exc: Exception do
TrapException(exc, 'sg_Text_DrawTextLinesInRectOnBitmap');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Text_DrawTextLinesInRectOnBitmap');
{$ENDIF}
end;
procedure sg_Text_DrawTextLinesInRectOnScreen(theText: PChar; textColor: LongWord; backColor: LongWord; theFont: Font; align: FontAlignment; var withinRect: Rectangle); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Text_DrawTextLinesInRectOnScreen');
{$ENDIF}
try
sgText.DrawTextLinesOnScreen(theText, textColor, backColor, theFont, align, withinRect);
Except on exc: Exception do
TrapException(exc, 'sg_Text_DrawTextLinesInRectOnScreen');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Text_DrawTextLinesInRectOnScreen');
{$ENDIF}
end;
procedure sg_Text_DrawTextLinesOnBitmap(dest: Bitmap; theText: PChar; textColor: LongWord; backColor: LongWord; theFont: Font; align: FontAlignment; x: LongInt; y: LongInt; w: LongInt; h: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Text_DrawTextLinesOnBitmap');
{$ENDIF}
try
sgText.DrawTextLines(dest, theText, textColor, backColor, theFont, align, x, y, w, h);
Except on exc: Exception do
TrapException(exc, 'sg_Text_DrawTextLinesOnBitmap');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Text_DrawTextLinesOnBitmap');
{$ENDIF}
end;
procedure sg_Text_DrawTextLinesOnScreen(theText: PChar; textColor: LongWord; backColor: LongWord; theFont: Font; align: FontAlignment; x: LongInt; y: LongInt; w: LongInt; h: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Text_DrawTextLinesOnScreen');
{$ENDIF}
try
sgText.DrawTextLinesOnScreen(theText, textColor, backColor, theFont, align, x, y, w, h);
Except on exc: Exception do
TrapException(exc, 'sg_Text_DrawTextLinesOnScreen');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Text_DrawTextLinesOnScreen');
{$ENDIF}
end;
procedure sg_Text_DrawTextOnBitmap(dest: Bitmap; theText: PChar; textColor: LongWord; theFont: Font; x: LongInt; y: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Text_DrawTextOnBitmap');
{$ENDIF}
try
sgText.DrawText(dest, theText, textColor, theFont, x, y);
Except on exc: Exception do
TrapException(exc, 'sg_Text_DrawTextOnBitmap');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Text_DrawTextOnBitmap');
{$ENDIF}
end;
procedure sg_Text_DrawTextOnBitmapAtPoint(dest: Bitmap; theText: PChar; textColor: LongWord; theFont: Font; var pt: Point2D); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Text_DrawTextOnBitmapAtPoint');
{$ENDIF}
try
sgText.DrawText(dest, theText, textColor, theFont, pt);
Except on exc: Exception do
TrapException(exc, 'sg_Text_DrawTextOnBitmapAtPoint');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Text_DrawTextOnBitmapAtPoint');
{$ENDIF}
end;
procedure sg_Text_DrawTextOnScreen(theText: PChar; textColor: LongWord; theFont: Font; x: LongInt; y: LongInt); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Text_DrawTextOnScreen');
{$ENDIF}
try
sgText.DrawTextOnScreen(theText, textColor, theFont, x, y);
Except on exc: Exception do
TrapException(exc, 'sg_Text_DrawTextOnScreen');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Text_DrawTextOnScreen');
{$ENDIF}
end;
procedure sg_Text_DrawTextOnScreenAtPoint(theText: PChar; textColor: LongWord; theFont: Font; var pt: Point2D); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Text_DrawTextOnScreenAtPoint');
{$ENDIF}
try
sgText.DrawTextOnScreen(theText, textColor, theFont, pt);
Except on exc: Exception do
TrapException(exc, 'sg_Text_DrawTextOnScreenAtPoint');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Text_DrawTextOnScreenAtPoint');
{$ENDIF}
end;
function sg_Text_FontFontStyle(font: Font): FontStyle; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Text_FontFontStyle');
{$ENDIF}
try
result := sgText.FontFontStyle(font);
Except on exc: Exception do
TrapException(exc, 'sg_Text_FontFontStyle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Text_FontFontStyle');
{$ENDIF}
end;
procedure sg_Text_FontNameFor(fontName: PChar; size: LongInt; result: PChar); cdecl; export;
var
result_temp: String;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Text_FontNameFor');
{$ENDIF}
try
result_temp := sgText.FontNameFor(fontName, size);
StrCopy(result, PChar(result_temp));
Except on exc: Exception do
TrapException(exc, 'sg_Text_FontNameFor');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Text_FontNameFor');
{$ENDIF}
end;
function sg_Text_FontNamed(name: PChar): Font; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Text_FontNamed');
{$ENDIF}
try
result := sgText.FontNamed(name);
Except on exc: Exception do
TrapException(exc, 'sg_Text_FontNamed');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Text_FontNamed');
{$ENDIF}
end;
function sg_Text_FontNamedWithSize(name: PChar; size: LongInt): Font; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Text_FontNamedWithSize');
{$ENDIF}
try
result := sgText.FontNamed(name, size);
Except on exc: Exception do
TrapException(exc, 'sg_Text_FontNamedWithSize');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Text_FontNamedWithSize');
{$ENDIF}
end;
procedure sg_Text_FontSetStyle(font: Font; value: FontStyle); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Text_FontSetStyle');
{$ENDIF}
try
sgText.FontSetStyle(font, value);
Except on exc: Exception do
TrapException(exc, 'sg_Text_FontSetStyle');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Text_FontSetStyle');
{$ENDIF}
end;
procedure sg_Text_FreeFont(var fontToFree: Font); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Text_FreeFont');
{$ENDIF}
try
sgText.FreeFont(fontToFree);
Except on exc: Exception do
TrapException(exc, 'sg_Text_FreeFont');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Text_FreeFont');
{$ENDIF}
end;
function sg_Text_HasFont(name: PChar): Boolean; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Text_HasFont');
{$ENDIF}
try
result := sgText.HasFont(name);
Except on exc: Exception do
TrapException(exc, 'sg_Text_HasFont');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Text_HasFont');
{$ENDIF}
end;
function sg_Text_LoadFont(fontName: PChar; size: LongInt): Font; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Text_LoadFont');
{$ENDIF}
try
result := sgText.LoadFont(fontName, size);
Except on exc: Exception do
TrapException(exc, 'sg_Text_LoadFont');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Text_LoadFont');
{$ENDIF}
end;
function sg_Text_MapFont(name: PChar; filename: PChar; size: LongInt): Font; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Text_MapFont');
{$ENDIF}
try
result := sgText.MapFont(name, filename, size);
Except on exc: Exception do
TrapException(exc, 'sg_Text_MapFont');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Text_MapFont');
{$ENDIF}
end;
procedure sg_Text_ReleaseAllFonts(); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Text_ReleaseAllFonts');
{$ENDIF}
try
sgText.ReleaseAllFonts();
Except on exc: Exception do
TrapException(exc, 'sg_Text_ReleaseAllFonts');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Text_ReleaseAllFonts');
{$ENDIF}
end;
procedure sg_Text_ReleaseFont(name: PChar); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Text_ReleaseFont');
{$ENDIF}
try
sgText.ReleaseFont(name);
Except on exc: Exception do
TrapException(exc, 'sg_Text_ReleaseFont');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Text_ReleaseFont');
{$ENDIF}
end;
function sg_Text_TextAlignmentFrom(str: PChar): FontAlignment; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Text_TextAlignmentFrom');
{$ENDIF}
try
result := sgText.TextAlignmentFrom(str);
Except on exc: Exception do
TrapException(exc, 'sg_Text_TextAlignmentFrom');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Text_TextAlignmentFrom');
{$ENDIF}
end;
function sg_Text_TextHeight(theFont: Font; theText: PChar): LongInt; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Text_TextHeight');
{$ENDIF}
try
result := sgText.TextHeight(theFont, theText);
Except on exc: Exception do
TrapException(exc, 'sg_Text_TextHeight');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Text_TextHeight');
{$ENDIF}
end;
function sg_Text_TextWidth(theFont: Font; theText: PChar): LongInt; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Text_TextWidth');
{$ENDIF}
try
result := sgText.TextWidth(theFont, theText);
Except on exc: Exception do
TrapException(exc, 'sg_Text_TextWidth');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Text_TextWidth');
{$ENDIF}
end;
function sg_Timers_CreateTimer(): Timer; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Timers_CreateTimer');
{$ENDIF}
try
result := sgTimers.CreateTimer();
Except on exc: Exception do
TrapException(exc, 'sg_Timers_CreateTimer');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Timers_CreateTimer');
{$ENDIF}
end;
procedure sg_Timers_FreeTimer(var toFree: Timer); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Timers_FreeTimer');
{$ENDIF}
try
sgTimers.FreeTimer(toFree);
Except on exc: Exception do
TrapException(exc, 'sg_Timers_FreeTimer');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Timers_FreeTimer');
{$ENDIF}
end;
procedure sg_Timers_PauseTimer(toPause: Timer); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Timers_PauseTimer');
{$ENDIF}
try
sgTimers.PauseTimer(toPause);
Except on exc: Exception do
TrapException(exc, 'sg_Timers_PauseTimer');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Timers_PauseTimer');
{$ENDIF}
end;
procedure sg_Timers_ResetTimer(tmr: Timer); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Timers_ResetTimer');
{$ENDIF}
try
sgTimers.ResetTimer(tmr);
Except on exc: Exception do
TrapException(exc, 'sg_Timers_ResetTimer');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Timers_ResetTimer');
{$ENDIF}
end;
procedure sg_Timers_ResumeTimer(toUnpause: Timer); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Timers_ResumeTimer');
{$ENDIF}
try
sgTimers.ResumeTimer(toUnpause);
Except on exc: Exception do
TrapException(exc, 'sg_Timers_ResumeTimer');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Timers_ResumeTimer');
{$ENDIF}
end;
procedure sg_Timers_StartTimer(toStart: Timer); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Timers_StartTimer');
{$ENDIF}
try
sgTimers.StartTimer(toStart);
Except on exc: Exception do
TrapException(exc, 'sg_Timers_StartTimer');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Timers_StartTimer');
{$ENDIF}
end;
procedure sg_Timers_StopTimer(toStop: Timer); cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Timers_StopTimer');
{$ENDIF}
try
sgTimers.StopTimer(toStop);
Except on exc: Exception do
TrapException(exc, 'sg_Timers_StopTimer');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Timers_StopTimer');
{$ENDIF}
end;
function sg_Timers_TimerTicks(toGet: Timer): UInt32; cdecl; export;
begin
{$IFDEF TRACE}
TraceEnter('SGSDK.dll', 'sg_Timers_TimerTicks');
{$ENDIF}
try
result := sgTimers.TimerTicks(toGet);
Except on exc: Exception do
TrapException(exc, 'sg_Timers_TimerTicks');
end;
{$IFDEF TRACE}
TraceExit('SGSDK.dll', 'sg_Timers_TimerTicks');
{$ENDIF}
end;
{$ifdef UNIX}
{$ifndef DARWIN}
end.
{$endif}
{$endif}
exports
sg_Animation_AnimationCurrentCell name 'sg_Animation_AnimationCurrentCell',
sg_Animation_AnimationEnded name 'sg_Animation_AnimationEnded',
sg_Animation_AnimationEnteredFrame name 'sg_Animation_AnimationEnteredFrame',
sg_Animation_AnimationFrameTime name 'sg_Animation_AnimationFrameTime',
sg_Animation_AnimationIndex name 'sg_Animation_AnimationIndex',
sg_Animation_AnimationName name 'sg_Animation_AnimationName',
sg_Animation_AnimationTemplateNamed name 'sg_Animation_AnimationTemplateNamed',
sg_Animation_AssignAnimation name 'sg_Animation_AssignAnimation',
sg_Animation_AssignAnimationNamed name 'sg_Animation_AssignAnimationNamed',
sg_Animation_AssignAnimationNamedWithSound name 'sg_Animation_AssignAnimationNamedWithSound',
sg_Animation_AssignAnimationWithSound name 'sg_Animation_AssignAnimationWithSound',
sg_Animation_CreateAnimation name 'sg_Animation_CreateAnimation',
sg_Animation_CreateAnimationNamed name 'sg_Animation_CreateAnimationNamed',
sg_Animation_CreateAnimationNamedWithSound name 'sg_Animation_CreateAnimationNamedWithSound',
sg_Animation_CreateAnimationWithSound name 'sg_Animation_CreateAnimationWithSound',
sg_Animation_DrawAnimation name 'sg_Animation_DrawAnimation',
sg_Animation_DrawAnimationAtPoint name 'sg_Animation_DrawAnimationAtPoint',
sg_Animation_DrawAnimationOnScreen name 'sg_Animation_DrawAnimationOnScreen',
sg_Animation_DrawAnimationOnScreenAtPt name 'sg_Animation_DrawAnimationOnScreenAtPt',
sg_Animation_DrawAnimationOntoDest name 'sg_Animation_DrawAnimationOntoDest',
sg_Animation_DrawAnimationOntoDestAtPt name 'sg_Animation_DrawAnimationOntoDestAtPt',
sg_Animation_FreeAnimation name 'sg_Animation_FreeAnimation',
sg_Animation_FreeAnimationTemplate name 'sg_Animation_FreeAnimationTemplate',
sg_Animation_HasAnimationTemplate name 'sg_Animation_HasAnimationTemplate',
sg_Animation_LoadAnimationTemplate name 'sg_Animation_LoadAnimationTemplate',
sg_Animation_MapAnimationTemplate name 'sg_Animation_MapAnimationTemplate',
sg_Animation_ReleaseAllAnimationTemplates name 'sg_Animation_ReleaseAllAnimationTemplates',
sg_Animation_ReleaseAnimationTemplate name 'sg_Animation_ReleaseAnimationTemplate',
sg_Animation_ResetAnimation name 'sg_Animation_ResetAnimation',
sg_Animation_ResetAnimationWithSound name 'sg_Animation_ResetAnimationWithSound',
sg_Animation_UpdateAnimation name 'sg_Animation_UpdateAnimation',
sg_Animation_UpdateAnimationPct name 'sg_Animation_UpdateAnimationPct',
sg_Animation_UpdateAnimationPctAndSound name 'sg_Animation_UpdateAnimationPctAndSound',
sg_Audio_AudioReady name 'sg_Audio_AudioReady',
sg_Audio_CloseAudio name 'sg_Audio_CloseAudio',
sg_Audio_FadeMusicIn name 'sg_Audio_FadeMusicIn',
sg_Audio_FadeMusicInWithLoops name 'sg_Audio_FadeMusicInWithLoops',
sg_Audio_FadeMusicOut name 'sg_Audio_FadeMusicOut',
sg_Audio_FreeMusic name 'sg_Audio_FreeMusic',
sg_Audio_FreeSoundEffect name 'sg_Audio_FreeSoundEffect',
sg_Audio_HasMusic name 'sg_Audio_HasMusic',
sg_Audio_HasSoundEffect name 'sg_Audio_HasSoundEffect',
sg_Audio_LoadMusic name 'sg_Audio_LoadMusic',
sg_Audio_LoadSoundEffect name 'sg_Audio_LoadSoundEffect',
sg_Audio_MapMusic name 'sg_Audio_MapMusic',
sg_Audio_MapSoundEffect name 'sg_Audio_MapSoundEffect',
sg_Audio_MusicFilename name 'sg_Audio_MusicFilename',
sg_Audio_MusicName name 'sg_Audio_MusicName',
sg_Audio_MusicNamed name 'sg_Audio_MusicNamed',
sg_Audio_MusicPlaying name 'sg_Audio_MusicPlaying',
sg_Audio_MusicVolume name 'sg_Audio_MusicVolume',
sg_Audio_OpenAudio name 'sg_Audio_OpenAudio',
sg_Audio_PlayMusicWithLoops name 'sg_Audio_PlayMusicWithLoops',
sg_Audio_PlaySoundEffectWithLoopAndVolume name 'sg_Audio_PlaySoundEffectWithLoopAndVolume',
sg_Audio_ReleaseAllMusic name 'sg_Audio_ReleaseAllMusic',
sg_Audio_ReleaseAllSoundEffects name 'sg_Audio_ReleaseAllSoundEffects',
sg_Audio_ReleaseMusic name 'sg_Audio_ReleaseMusic',
sg_Audio_ReleaseSoundEffect name 'sg_Audio_ReleaseSoundEffect',
sg_Audio_SetMusicVolume name 'sg_Audio_SetMusicVolume',
sg_Audio_SoundEffectFilename name 'sg_Audio_SoundEffectFilename',
sg_Audio_SoundEffectName name 'sg_Audio_SoundEffectName',
sg_Audio_SoundEffectNamed name 'sg_Audio_SoundEffectNamed',
sg_Audio_SoundEffectPlaying name 'sg_Audio_SoundEffectPlaying',
sg_Audio_StopMusic name 'sg_Audio_StopMusic',
sg_Audio_StopSoundEffect name 'sg_Audio_StopSoundEffect',
sg_Audio_TryOpenAudio name 'sg_Audio_TryOpenAudio',
sg_Camera_CameraPos name 'sg_Camera_CameraPos',
sg_Camera_CameraScreenRect name 'sg_Camera_CameraScreenRect',
sg_Camera_CameraX name 'sg_Camera_CameraX',
sg_Camera_CameraY name 'sg_Camera_CameraY',
sg_Camera_CenterCameraOn name 'sg_Camera_CenterCameraOn',
sg_Camera_CenterCameraOnCharacter name 'sg_Camera_CenterCameraOnCharacter',
sg_Camera_CenterCameraOnWithXYOffset name 'sg_Camera_CenterCameraOnWithXYOffset',
sg_Camera_MoveCameraBy name 'sg_Camera_MoveCameraBy',
sg_Camera_MoveCameraByXY name 'sg_Camera_MoveCameraByXY',
sg_Camera_MoveCameraTo name 'sg_Camera_MoveCameraTo',
sg_Camera_MoveCameraToXY name 'sg_Camera_MoveCameraToXY',
sg_Camera_PointOnScreen name 'sg_Camera_PointOnScreen',
sg_Camera_RectOnScreen name 'sg_Camera_RectOnScreen',
sg_Camera_SetCameraPos name 'sg_Camera_SetCameraPos',
sg_Camera_SetCameraX name 'sg_Camera_SetCameraX',
sg_Camera_SetCameraY name 'sg_Camera_SetCameraY',
sg_Camera_ToScreen name 'sg_Camera_ToScreen',
sg_Camera_ToScreenRect name 'sg_Camera_ToScreenRect',
sg_Camera_ToScreenX name 'sg_Camera_ToScreenX',
sg_Camera_ToScreenY name 'sg_Camera_ToScreenY',
sg_Camera_ToWorld name 'sg_Camera_ToWorld',
sg_Camera_ToWorldX name 'sg_Camera_ToWorldX',
sg_Camera_ToWorldY name 'sg_Camera_ToWorldY',
sg_Core_BlueOf name 'sg_Core_BlueOf',
sg_Core_BrightnessOf name 'sg_Core_BrightnessOf',
sg_Core_CalculateFramerate name 'sg_Core_CalculateFramerate',
sg_Core_ChangeScreenSize name 'sg_Core_ChangeScreenSize',
sg_Core_ColorComponents name 'sg_Core_ColorComponents',
sg_Core_ColorFromBitmap name 'sg_Core_ColorFromBitmap',
sg_Core_ColorToString name 'sg_Core_ColorToString',
sg_Core_Delay name 'sg_Core_Delay',
sg_Core_ExceptionMessage name 'sg_Core_ExceptionMessage',
sg_Core_ExceptionOccured name 'sg_Core_ExceptionOccured',
sg_Core_GetFramerate name 'sg_Core_GetFramerate',
sg_Core_GetTicks name 'sg_Core_GetTicks',
sg_Core_GreenOf name 'sg_Core_GreenOf',
sg_Core_HSBColor name 'sg_Core_HSBColor',
sg_Core_HSBValuesOf name 'sg_Core_HSBValuesOf',
sg_Core_HueOf name 'sg_Core_HueOf',
sg_Core_OpenGraphicsWindow name 'sg_Core_OpenGraphicsWindow',
sg_Core_ProcessEvents name 'sg_Core_ProcessEvents',
sg_Core_RGBAColor name 'sg_Core_RGBAColor',
sg_Core_RGBAFloatColor name 'sg_Core_RGBAFloatColor',
sg_Core_RGBFloatColor name 'sg_Core_RGBFloatColor',
sg_Core_RandomColor name 'sg_Core_RandomColor',
sg_Core_RandomRGBColor name 'sg_Core_RandomRGBColor',
sg_Core_RedOf name 'sg_Core_RedOf',
sg_Core_RefreshScreen name 'sg_Core_RefreshScreen',
sg_Core_RefreshScreenRestrictFPS name 'sg_Core_RefreshScreenRestrictFPS',
sg_Core_Rnd name 'sg_Core_Rnd',
sg_Core_RndUpto name 'sg_Core_RndUpto',
sg_Core_SaturationOf name 'sg_Core_SaturationOf',
sg_Core_ScreenHeight name 'sg_Core_ScreenHeight',
sg_Core_ScreenWidth name 'sg_Core_ScreenWidth',
sg_Core_SetIcon name 'sg_Core_SetIcon',
sg_Core_SwinGameVersion name 'sg_Core_SwinGameVersion',
sg_Core_TakeScreenshot name 'sg_Core_TakeScreenshot',
sg_Core_ToggleFullScreen name 'sg_Core_ToggleFullScreen',
sg_Core_ToggleWindowBorder name 'sg_Core_ToggleWindowBorder',
sg_Core_TransparencyOf name 'sg_Core_TransparencyOf',
sg_Core_WindowCloseRequested name 'sg_Core_WindowCloseRequested',
sg_Geometry_AddVectors name 'sg_Geometry_AddVectors',
sg_Geometry_ApplyMatrix name 'sg_Geometry_ApplyMatrix',
sg_Geometry_ApplyMatrixToPoints name 'sg_Geometry_ApplyMatrixToPoints',
sg_Geometry_CalculateAngle name 'sg_Geometry_CalculateAngle',
sg_Geometry_CalculateAngleBetween name 'sg_Geometry_CalculateAngleBetween',
sg_Geometry_CalculateAngleBetweenSprites name 'sg_Geometry_CalculateAngleBetweenSprites',
sg_Geometry_CalculateAngleBetweenVectors name 'sg_Geometry_CalculateAngleBetweenVectors',
sg_Geometry_CircleAt name 'sg_Geometry_CircleAt',
sg_Geometry_CircleCenterPoint name 'sg_Geometry_CircleCenterPoint',
sg_Geometry_CircleFromXY name 'sg_Geometry_CircleFromXY',
sg_Geometry_CirclePrototypeFrom name 'sg_Geometry_CirclePrototypeFrom',
sg_Geometry_CircleRadius name 'sg_Geometry_CircleRadius',
sg_Geometry_CircleWithinRect name 'sg_Geometry_CircleWithinRect',
sg_Geometry_CircleX name 'sg_Geometry_CircleX',
sg_Geometry_CircleY name 'sg_Geometry_CircleY',
sg_Geometry_ClosestPointOnCircle name 'sg_Geometry_ClosestPointOnCircle',
sg_Geometry_ClosestPointOnLine name 'sg_Geometry_ClosestPointOnLine',
sg_Geometry_ClosestPointOnLineFromCircle name 'sg_Geometry_ClosestPointOnLineFromCircle',
sg_Geometry_ClosestPointOnLineXY name 'sg_Geometry_ClosestPointOnLineXY',
sg_Geometry_ClosestPointOnLinesFromCircle name 'sg_Geometry_ClosestPointOnLinesFromCircle',
sg_Geometry_ClosestPointOnRectFromCircle name 'sg_Geometry_ClosestPointOnRectFromCircle',
sg_Geometry_Cosine name 'sg_Geometry_Cosine',
sg_Geometry_DistantPointOnCircle name 'sg_Geometry_DistantPointOnCircle',
sg_Geometry_DistantPointOnCircleHeading name 'sg_Geometry_DistantPointOnCircleHeading',
sg_Geometry_DotProduct name 'sg_Geometry_DotProduct',
sg_Geometry_FixRect name 'sg_Geometry_FixRect',
sg_Geometry_FixRectangle name 'sg_Geometry_FixRectangle',
sg_Geometry_FreePrototype name 'sg_Geometry_FreePrototype',
sg_Geometry_FreeShape name 'sg_Geometry_FreeShape',
sg_Geometry_IdentityMatrix name 'sg_Geometry_IdentityMatrix',
sg_Geometry_InsetRectangle name 'sg_Geometry_InsetRectangle',
sg_Geometry_Intersection name 'sg_Geometry_Intersection',
sg_Geometry_InvertVector name 'sg_Geometry_InvertVector',
sg_Geometry_LimitVector name 'sg_Geometry_LimitVector',
sg_Geometry_LineAsVector name 'sg_Geometry_LineAsVector',
sg_Geometry_LineCircleHit name 'sg_Geometry_LineCircleHit',
sg_Geometry_LineCount name 'sg_Geometry_LineCount',
sg_Geometry_LineFrom name 'sg_Geometry_LineFrom',
sg_Geometry_LineFromPointToPoint name 'sg_Geometry_LineFromPointToPoint',
sg_Geometry_LineFromVector name 'sg_Geometry_LineFromVector',
sg_Geometry_LineFromVectorWithStartPoint name 'sg_Geometry_LineFromVectorWithStartPoint',
sg_Geometry_LineFromVectorWithStartXY name 'sg_Geometry_LineFromVectorWithStartXY',
sg_Geometry_LineIntersectionPoint name 'sg_Geometry_LineIntersectionPoint',
sg_Geometry_LineIntersectsCircle name 'sg_Geometry_LineIntersectsCircle',
sg_Geometry_LineIntersectsLines name 'sg_Geometry_LineIntersectsLines',
sg_Geometry_LineIntersectsRect name 'sg_Geometry_LineIntersectsRect',
sg_Geometry_LineListPrototypeFrom name 'sg_Geometry_LineListPrototypeFrom',
sg_Geometry_LineMagnitudeSq name 'sg_Geometry_LineMagnitudeSq',
sg_Geometry_LineMagnitudeSqFromLine name 'sg_Geometry_LineMagnitudeSqFromLine',
sg_Geometry_LineMidPoint name 'sg_Geometry_LineMidPoint',
sg_Geometry_LineNormal name 'sg_Geometry_LineNormal',
sg_Geometry_LinePrototypeFrom name 'sg_Geometry_LinePrototypeFrom',
sg_Geometry_LineSegmentsIntersect name 'sg_Geometry_LineSegmentsIntersect',
sg_Geometry_LineStripPrototypeFrom name 'sg_Geometry_LineStripPrototypeFrom',
sg_Geometry_LineToString name 'sg_Geometry_LineToString',
sg_Geometry_LinesFromRect name 'sg_Geometry_LinesFromRect',
sg_Geometry_LinesFromShape name 'sg_Geometry_LinesFromShape',
sg_Geometry_LinesFromTriangle name 'sg_Geometry_LinesFromTriangle',
sg_Geometry_MatrixMultiply name 'sg_Geometry_MatrixMultiply',
sg_Geometry_MatrixMultiplyVector name 'sg_Geometry_MatrixMultiplyVector',
sg_Geometry_MatrixToString name 'sg_Geometry_MatrixToString',
sg_Geometry_MinimumPointsForKind name 'sg_Geometry_MinimumPointsForKind',
sg_Geometry_PointAdd name 'sg_Geometry_PointAdd',
sg_Geometry_PointAt name 'sg_Geometry_PointAt',
sg_Geometry_PointAtStartWithOffset name 'sg_Geometry_PointAtStartWithOffset',
sg_Geometry_PointInCircle name 'sg_Geometry_PointInCircle',
sg_Geometry_PointInRect name 'sg_Geometry_PointInRect',
sg_Geometry_PointInRectXY name 'sg_Geometry_PointInRectXY',
sg_Geometry_PointInShape name 'sg_Geometry_PointInShape',
sg_Geometry_PointInTriangle name 'sg_Geometry_PointInTriangle',
sg_Geometry_PointLineDistance name 'sg_Geometry_PointLineDistance',
sg_Geometry_PointOnLine name 'sg_Geometry_PointOnLine',
sg_Geometry_PointPointDistance name 'sg_Geometry_PointPointDistance',
sg_Geometry_PointPrototypeFrom name 'sg_Geometry_PointPrototypeFrom',
sg_Geometry_PointToString name 'sg_Geometry_PointToString',
sg_Geometry_PointXYInRect name 'sg_Geometry_PointXYInRect',
sg_Geometry_PointXYInRectXY name 'sg_Geometry_PointXYInRectXY',
sg_Geometry_PointXYLineDistance name 'sg_Geometry_PointXYLineDistance',
sg_Geometry_PointsFromLine name 'sg_Geometry_PointsFromLine',
sg_Geometry_PointsFromRect name 'sg_Geometry_PointsFromRect',
sg_Geometry_PrototypeFrom name 'sg_Geometry_PrototypeFrom',
sg_Geometry_PrototypeKind name 'sg_Geometry_PrototypeKind',
sg_Geometry_PrototypePointCount name 'sg_Geometry_PrototypePointCount',
sg_Geometry_PrototypePoints name 'sg_Geometry_PrototypePoints',
sg_Geometry_PrototypeSetKind name 'sg_Geometry_PrototypeSetKind',
sg_Geometry_PrototypeSetPoints name 'sg_Geometry_PrototypeSetPoints',
sg_Geometry_RayCircleIntersectDistance name 'sg_Geometry_RayCircleIntersectDistance',
sg_Geometry_RayIntersectionPoint name 'sg_Geometry_RayIntersectionPoint',
sg_Geometry_RectangleAfterMove name 'sg_Geometry_RectangleAfterMove',
sg_Geometry_RectangleAtPoint name 'sg_Geometry_RectangleAtPoint',
sg_Geometry_RectangleBottom name 'sg_Geometry_RectangleBottom',
sg_Geometry_RectangleBottomLeft name 'sg_Geometry_RectangleBottomLeft',
sg_Geometry_RectangleBottomRight name 'sg_Geometry_RectangleBottomRight',
sg_Geometry_RectangleCenter name 'sg_Geometry_RectangleCenter',
sg_Geometry_RectangleCenterBottom name 'sg_Geometry_RectangleCenterBottom',
sg_Geometry_RectangleCenterLeft name 'sg_Geometry_RectangleCenterLeft',
sg_Geometry_RectangleCenterRight name 'sg_Geometry_RectangleCenterRight',
sg_Geometry_RectangleCenterTop name 'sg_Geometry_RectangleCenterTop',
sg_Geometry_RectangleForPoints name 'sg_Geometry_RectangleForPoints',
sg_Geometry_RectangleFrom name 'sg_Geometry_RectangleFrom',
sg_Geometry_RectangleFromCircle name 'sg_Geometry_RectangleFromCircle',
sg_Geometry_RectangleFromLine name 'sg_Geometry_RectangleFromLine',
sg_Geometry_RectangleFromLines name 'sg_Geometry_RectangleFromLines',
sg_Geometry_RectangleFromTriangle name 'sg_Geometry_RectangleFromTriangle',
sg_Geometry_RectangleLeft name 'sg_Geometry_RectangleLeft',
sg_Geometry_RectangleOffset name 'sg_Geometry_RectangleOffset',
sg_Geometry_RectangleRight name 'sg_Geometry_RectangleRight',
sg_Geometry_RectangleToString name 'sg_Geometry_RectangleToString',
sg_Geometry_RectangleTop name 'sg_Geometry_RectangleTop',
sg_Geometry_RectangleTopLeft name 'sg_Geometry_RectangleTopLeft',
sg_Geometry_RectangleTopRight name 'sg_Geometry_RectangleTopRight',
sg_Geometry_RectanglesIntersect name 'sg_Geometry_RectanglesIntersect',
sg_Geometry_RotationMatrix name 'sg_Geometry_RotationMatrix',
sg_Geometry_ScaleMatrix name 'sg_Geometry_ScaleMatrix',
sg_Geometry_ScaleMatrixByPoint name 'sg_Geometry_ScaleMatrixByPoint',
sg_Geometry_ScaleRotateTranslateMatrix name 'sg_Geometry_ScaleRotateTranslateMatrix',
sg_Geometry_ShapeAABB name 'sg_Geometry_ShapeAABB',
sg_Geometry_ShapeAddSubShape name 'sg_Geometry_ShapeAddSubShape',
sg_Geometry_ShapeAngle name 'sg_Geometry_ShapeAngle',
sg_Geometry_ShapeAtPoint name 'sg_Geometry_ShapeAtPoint',
sg_Geometry_ShapeCircle name 'sg_Geometry_ShapeCircle',
sg_Geometry_ShapeCircleOffset name 'sg_Geometry_ShapeCircleOffset',
sg_Geometry_ShapeColor name 'sg_Geometry_ShapeColor',
sg_Geometry_ShapeLine name 'sg_Geometry_ShapeLine',
sg_Geometry_ShapeLineOffset name 'sg_Geometry_ShapeLineOffset',
sg_Geometry_ShapeLines name 'sg_Geometry_ShapeLines',
sg_Geometry_ShapeLinesWithOffset name 'sg_Geometry_ShapeLinesWithOffset',
sg_Geometry_ShapePointCount name 'sg_Geometry_ShapePointCount',
sg_Geometry_ShapePoints name 'sg_Geometry_ShapePoints',
sg_Geometry_ShapeRectangleIntersect name 'sg_Geometry_ShapeRectangleIntersect',
sg_Geometry_ShapeScale name 'sg_Geometry_ShapeScale',
sg_Geometry_ShapeSetAngle name 'sg_Geometry_ShapeSetAngle',
sg_Geometry_ShapeSetColor name 'sg_Geometry_ShapeSetColor',
sg_Geometry_ShapeSetPrototype name 'sg_Geometry_ShapeSetPrototype',
sg_Geometry_ShapeSetScale name 'sg_Geometry_ShapeSetScale',
sg_Geometry_ShapeShapeKind name 'sg_Geometry_ShapeShapeKind',
sg_Geometry_ShapeShapePrototype name 'sg_Geometry_ShapeShapePrototype',
sg_Geometry_ShapeTriangle name 'sg_Geometry_ShapeTriangle',
sg_Geometry_ShapeTriangleWithOffset name 'sg_Geometry_ShapeTriangleWithOffset',
sg_Geometry_ShapeTriangles name 'sg_Geometry_ShapeTriangles',
sg_Geometry_ShapeTrianglesOffset name 'sg_Geometry_ShapeTrianglesOffset',
sg_Geometry_Sine name 'sg_Geometry_Sine',
sg_Geometry_SubtractVectors name 'sg_Geometry_SubtractVectors',
sg_Geometry_Tangent name 'sg_Geometry_Tangent',
sg_Geometry_TangentPoints name 'sg_Geometry_TangentPoints',
sg_Geometry_TranslationMatrix name 'sg_Geometry_TranslationMatrix',
sg_Geometry_TranslationMatrixPt name 'sg_Geometry_TranslationMatrixPt',
sg_Geometry_TriangleBarycenter name 'sg_Geometry_TriangleBarycenter',
sg_Geometry_TriangleFanPrototypeFrom name 'sg_Geometry_TriangleFanPrototypeFrom',
sg_Geometry_TriangleFrom name 'sg_Geometry_TriangleFrom',
sg_Geometry_TriangleFromPoints name 'sg_Geometry_TriangleFromPoints',
sg_Geometry_TriangleListPrototypeFrom name 'sg_Geometry_TriangleListPrototypeFrom',
sg_Geometry_TrianglePrototypeFrom name 'sg_Geometry_TrianglePrototypeFrom',
sg_Geometry_TriangleRectangleIntersect name 'sg_Geometry_TriangleRectangleIntersect',
sg_Geometry_TriangleStripPrototypeFrom name 'sg_Geometry_TriangleStripPrototypeFrom',
sg_Geometry_TriangleToString name 'sg_Geometry_TriangleToString',
sg_Geometry_TrianglesRectangleIntersect name 'sg_Geometry_TrianglesRectangleIntersect',
sg_Geometry_UnitVector name 'sg_Geometry_UnitVector',
sg_Geometry_UpdateShapePoints name 'sg_Geometry_UpdateShapePoints',
sg_Geometry_VectorAngle name 'sg_Geometry_VectorAngle',
sg_Geometry_VectorFromAngle name 'sg_Geometry_VectorFromAngle',
sg_Geometry_VectorFromPointPtToRectangle name 'sg_Geometry_VectorFromPointPtToRectangle',
sg_Geometry_VectorFromPointToRect name 'sg_Geometry_VectorFromPointToRect',
sg_Geometry_VectorFromPointToRectangle name 'sg_Geometry_VectorFromPointToRectangle',
sg_Geometry_VectorFromPoints name 'sg_Geometry_VectorFromPoints',
sg_Geometry_VectorInRect name 'sg_Geometry_VectorInRect',
sg_Geometry_VectorInRectXY name 'sg_Geometry_VectorInRectXY',
sg_Geometry_VectorIsZero name 'sg_Geometry_VectorIsZero',
sg_Geometry_VectorMagnitude name 'sg_Geometry_VectorMagnitude',
sg_Geometry_VectorMagnitudeSq name 'sg_Geometry_VectorMagnitudeSq',
sg_Geometry_VectorMultiply name 'sg_Geometry_VectorMultiply',
sg_Geometry_VectorNormal name 'sg_Geometry_VectorNormal',
sg_Geometry_VectorOutOfCircleFromCircle name 'sg_Geometry_VectorOutOfCircleFromCircle',
sg_Geometry_VectorOutOfCircleFromPoint name 'sg_Geometry_VectorOutOfCircleFromPoint',
sg_Geometry_VectorOutOfRectFromCircle name 'sg_Geometry_VectorOutOfRectFromCircle',
sg_Geometry_VectorOutOfRectFromPoint name 'sg_Geometry_VectorOutOfRectFromPoint',
sg_Geometry_VectorOutOfRectFromRect name 'sg_Geometry_VectorOutOfRectFromRect',
sg_Geometry_VectorOutOfShapeFromRect name 'sg_Geometry_VectorOutOfShapeFromRect',
sg_Geometry_VectorOverLinesFromCircle name 'sg_Geometry_VectorOverLinesFromCircle',
sg_Geometry_VectorTo name 'sg_Geometry_VectorTo',
sg_Geometry_VectorToPoint name 'sg_Geometry_VectorToPoint',
sg_Geometry_VectorsEqual name 'sg_Geometry_VectorsEqual',
sg_Geometry_WidestPoints name 'sg_Geometry_WidestPoints',
sg_Graphics_ClearScreenToBlack name 'sg_Graphics_ClearScreenToBlack',
sg_Graphics_ClearScreenWithColor name 'sg_Graphics_ClearScreenWithColor',
sg_Graphics_CurrentBmpClip name 'sg_Graphics_CurrentBmpClip',
sg_Graphics_CurrentScreenClip name 'sg_Graphics_CurrentScreenClip',
sg_Graphics_DrawHorizontalLine name 'sg_Graphics_DrawHorizontalLine',
sg_Graphics_DrawHorizontalLineOnScreen name 'sg_Graphics_DrawHorizontalLineOnScreen',
sg_Graphics_DrawHorizontalLineOnto name 'sg_Graphics_DrawHorizontalLineOnto',
sg_Graphics_DrawLine name 'sg_Graphics_DrawLine',
sg_Graphics_DrawLineOnScreen name 'sg_Graphics_DrawLineOnScreen',
sg_Graphics_DrawLineOnto name 'sg_Graphics_DrawLineOnto',
sg_Graphics_DrawLinePts name 'sg_Graphics_DrawLinePts',
sg_Graphics_DrawLinePtsOnScreen name 'sg_Graphics_DrawLinePtsOnScreen',
sg_Graphics_DrawLinePtsOnto name 'sg_Graphics_DrawLinePtsOnto',
sg_Graphics_DrawLineSegment name 'sg_Graphics_DrawLineSegment',
sg_Graphics_DrawLineSegmentOnScreen name 'sg_Graphics_DrawLineSegmentOnScreen',
sg_Graphics_DrawLineSegmentOnto name 'sg_Graphics_DrawLineSegmentOnto',
sg_Graphics_DrawLineSegments name 'sg_Graphics_DrawLineSegments',
sg_Graphics_DrawOrFillCircle name 'sg_Graphics_DrawOrFillCircle',
sg_Graphics_DrawOrFillCircleAtPointOnScreen name 'sg_Graphics_DrawOrFillCircleAtPointOnScreen',
sg_Graphics_DrawOrFillCircleOnScreen name 'sg_Graphics_DrawOrFillCircleOnScreen',
sg_Graphics_DrawOrFillCircleOnto name 'sg_Graphics_DrawOrFillCircleOnto',
sg_Graphics_DrawOrFillEllipse name 'sg_Graphics_DrawOrFillEllipse',
sg_Graphics_DrawOrFillEllipseInRect name 'sg_Graphics_DrawOrFillEllipseInRect',
sg_Graphics_DrawOrFillEllipseInRectOnScreen name 'sg_Graphics_DrawOrFillEllipseInRectOnScreen',
sg_Graphics_DrawOrFillEllipseInRectOnto name 'sg_Graphics_DrawOrFillEllipseInRectOnto',
sg_Graphics_DrawOrFillEllipseOnScreen name 'sg_Graphics_DrawOrFillEllipseOnScreen',
sg_Graphics_DrawOrFillEllipseOnto name 'sg_Graphics_DrawOrFillEllipseOnto',
sg_Graphics_DrawOrFillPtCircle name 'sg_Graphics_DrawOrFillPtCircle',
sg_Graphics_DrawOrFillPtCircleAtPoint name 'sg_Graphics_DrawOrFillPtCircleAtPoint',
sg_Graphics_DrawOrFillPtCircleAtPointOnto name 'sg_Graphics_DrawOrFillPtCircleAtPointOnto',
sg_Graphics_DrawOrFillPtCircleOnScreen name 'sg_Graphics_DrawOrFillPtCircleOnScreen',
sg_Graphics_DrawOrFillPtCircleOnto name 'sg_Graphics_DrawOrFillPtCircleOnto',
sg_Graphics_DrawOrFillRectangle name 'sg_Graphics_DrawOrFillRectangle',
sg_Graphics_DrawOrFillRectangleOnScreen name 'sg_Graphics_DrawOrFillRectangleOnScreen',
sg_Graphics_DrawOrFillRectangleOnto name 'sg_Graphics_DrawOrFillRectangleOnto',
sg_Graphics_DrawOrFillRectangleRect name 'sg_Graphics_DrawOrFillRectangleRect',
sg_Graphics_DrawOrFillRectangleRectOnScreen name 'sg_Graphics_DrawOrFillRectangleRectOnScreen',
sg_Graphics_DrawOrFillRectangleRectOnto name 'sg_Graphics_DrawOrFillRectangleRectOnto',
sg_Graphics_DrawOrFillShape name 'sg_Graphics_DrawOrFillShape',
sg_Graphics_DrawOrFillShapeOnScreen name 'sg_Graphics_DrawOrFillShapeOnScreen',
sg_Graphics_DrawOrFillShapeOnto name 'sg_Graphics_DrawOrFillShapeOnto',
sg_Graphics_DrawOrFillTriangle name 'sg_Graphics_DrawOrFillTriangle',
sg_Graphics_DrawOrFillTriangleOnScreen name 'sg_Graphics_DrawOrFillTriangleOnScreen',
sg_Graphics_DrawOrFillTriangleOnto name 'sg_Graphics_DrawOrFillTriangleOnto',
sg_Graphics_DrawPixel name 'sg_Graphics_DrawPixel',
sg_Graphics_DrawPixelAtPoint name 'sg_Graphics_DrawPixelAtPoint',
sg_Graphics_DrawPixelAtPointOnScreen name 'sg_Graphics_DrawPixelAtPointOnScreen',
sg_Graphics_DrawPixelAtPointOnto name 'sg_Graphics_DrawPixelAtPointOnto',
sg_Graphics_DrawPixelOnScreen name 'sg_Graphics_DrawPixelOnScreen',
sg_Graphics_DrawPixelOnto name 'sg_Graphics_DrawPixelOnto',
sg_Graphics_DrawShape name 'sg_Graphics_DrawShape',
sg_Graphics_DrawShapeAsCircle name 'sg_Graphics_DrawShapeAsCircle',
sg_Graphics_DrawShapeAsLine name 'sg_Graphics_DrawShapeAsLine',
sg_Graphics_DrawShapeAsLineList name 'sg_Graphics_DrawShapeAsLineList',
sg_Graphics_DrawShapeAsLineStrip name 'sg_Graphics_DrawShapeAsLineStrip',
sg_Graphics_DrawShapeAsPoint name 'sg_Graphics_DrawShapeAsPoint',
sg_Graphics_DrawShapeAsTriangle name 'sg_Graphics_DrawShapeAsTriangle',
sg_Graphics_DrawShapeAsTriangleFan name 'sg_Graphics_DrawShapeAsTriangleFan',
sg_Graphics_DrawShapeAsTriangleList name 'sg_Graphics_DrawShapeAsTriangleList',
sg_Graphics_DrawShapeAsTriangleStrip name 'sg_Graphics_DrawShapeAsTriangleStrip',
sg_Graphics_DrawShapeOnScreen name 'sg_Graphics_DrawShapeOnScreen',
sg_Graphics_DrawShapeOnto name 'sg_Graphics_DrawShapeOnto',
sg_Graphics_DrawTriangleFromPoints name 'sg_Graphics_DrawTriangleFromPoints',
sg_Graphics_DrawTriangleFromPointsOnScreen name 'sg_Graphics_DrawTriangleFromPointsOnScreen',
sg_Graphics_DrawTriangleFromPointsOnto name 'sg_Graphics_DrawTriangleFromPointsOnto',
sg_Graphics_DrawVerticalLine name 'sg_Graphics_DrawVerticalLine',
sg_Graphics_DrawVerticalLineOnScreen name 'sg_Graphics_DrawVerticalLineOnScreen',
sg_Graphics_DrawVerticalLineOnto name 'sg_Graphics_DrawVerticalLineOnto',
sg_Graphics_FillShape name 'sg_Graphics_FillShape',
sg_Graphics_FillShapeOnScreen name 'sg_Graphics_FillShapeOnScreen',
sg_Graphics_FillShapeOnto name 'sg_Graphics_FillShapeOnto',
sg_Graphics_FillTriangleFromPoints name 'sg_Graphics_FillTriangleFromPoints',
sg_Graphics_FillTriangleFromPointsOnScreen name 'sg_Graphics_FillTriangleFromPointsOnScreen',
sg_Graphics_FillTriangleFromPointsOnto name 'sg_Graphics_FillTriangleFromPointsOnto',
sg_Graphics_GetPixel name 'sg_Graphics_GetPixel',
sg_Graphics_GetPixelFromScreen name 'sg_Graphics_GetPixelFromScreen',
sg_Graphics_PopClipBmp name 'sg_Graphics_PopClipBmp',
sg_Graphics_PopClipScreen name 'sg_Graphics_PopClipScreen',
sg_Graphics_PushClipRect name 'sg_Graphics_PushClipRect',
sg_Graphics_PushClipRectForBitmap name 'sg_Graphics_PushClipRectForBitmap',
sg_Graphics_PushClipXY name 'sg_Graphics_PushClipXY',
sg_Graphics_PutPixel name 'sg_Graphics_PutPixel',
sg_Graphics_ResetClip name 'sg_Graphics_ResetClip',
sg_Graphics_ResetClipForBitmap name 'sg_Graphics_ResetClipForBitmap',
sg_Graphics_SetBmpClip name 'sg_Graphics_SetBmpClip',
sg_Graphics_SetBmpClipXY name 'sg_Graphics_SetBmpClipXY',
sg_Graphics_SetClip name 'sg_Graphics_SetClip',
sg_Graphics_SetClipXY name 'sg_Graphics_SetClipXY',
sg_Images_BitmapCellCircle name 'sg_Images_BitmapCellCircle',
sg_Images_BitmapCellCircleXY name 'sg_Images_BitmapCellCircleXY',
sg_Images_BitmapCellColumns name 'sg_Images_BitmapCellColumns',
sg_Images_BitmapCellCount name 'sg_Images_BitmapCellCount',
sg_Images_BitmapCellHeight name 'sg_Images_BitmapCellHeight',
sg_Images_BitmapCellOf name 'sg_Images_BitmapCellOf',
sg_Images_BitmapCellRectangle name 'sg_Images_BitmapCellRectangle',
sg_Images_BitmapCellRectangleAtOrigin name 'sg_Images_BitmapCellRectangleAtOrigin',
sg_Images_BitmapCellRectangleXY name 'sg_Images_BitmapCellRectangleXY',
sg_Images_BitmapCellRows name 'sg_Images_BitmapCellRows',
sg_Images_BitmapCellWidth name 'sg_Images_BitmapCellWidth',
sg_Images_BitmapCircle name 'sg_Images_BitmapCircle',
sg_Images_BitmapCircleXY name 'sg_Images_BitmapCircleXY',
sg_Images_BitmapHeight name 'sg_Images_BitmapHeight',
sg_Images_BitmapHeightForCell name 'sg_Images_BitmapHeightForCell',
sg_Images_BitmapName name 'sg_Images_BitmapName',
sg_Images_BitmapNamed name 'sg_Images_BitmapNamed',
sg_Images_BitmapRectAtOrigin name 'sg_Images_BitmapRectAtOrigin',
sg_Images_BitmapRectXY name 'sg_Images_BitmapRectXY',
sg_Images_BitmapRectangleOfCell name 'sg_Images_BitmapRectangleOfCell',
sg_Images_BitmapSetCellDetails name 'sg_Images_BitmapSetCellDetails',
sg_Images_BitmapWidth name 'sg_Images_BitmapWidth',
sg_Images_BitmapWidthForCell name 'sg_Images_BitmapWidthForCell',
sg_Images_BitmapfileName name 'sg_Images_BitmapfileName',
sg_Images_BitmapsInterchangable name 'sg_Images_BitmapsInterchangable',
sg_Images_ClearSurface name 'sg_Images_ClearSurface',
sg_Images_ClearSurfaceToBlack name 'sg_Images_ClearSurfaceToBlack',
sg_Images_CreateBitmap name 'sg_Images_CreateBitmap',
sg_Images_DrawBitmap name 'sg_Images_DrawBitmap',
sg_Images_DrawBitmapAtPoint name 'sg_Images_DrawBitmapAtPoint',
sg_Images_DrawBitmapAtPointOnScreen name 'sg_Images_DrawBitmapAtPointOnScreen',
sg_Images_DrawBitmapAtPointOnto name 'sg_Images_DrawBitmapAtPointOnto',
sg_Images_DrawBitmapCell name 'sg_Images_DrawBitmapCell',
sg_Images_DrawBitmapCellAtPoint name 'sg_Images_DrawBitmapCellAtPoint',
sg_Images_DrawBitmapCellAtPointOnScreen name 'sg_Images_DrawBitmapCellAtPointOnScreen',
sg_Images_DrawBitmapCellAtPointOnto name 'sg_Images_DrawBitmapCellAtPointOnto',
sg_Images_DrawBitmapCellOnScreen name 'sg_Images_DrawBitmapCellOnScreen',
sg_Images_DrawBitmapCellOnto name 'sg_Images_DrawBitmapCellOnto',
sg_Images_DrawBitmapOnScreen name 'sg_Images_DrawBitmapOnScreen',
sg_Images_DrawBitmapOnto name 'sg_Images_DrawBitmapOnto',
sg_Images_DrawBitmapPart name 'sg_Images_DrawBitmapPart',
sg_Images_DrawBitmapPartFromRect name 'sg_Images_DrawBitmapPartFromRect',
sg_Images_DrawBitmapPartFromRectAtPoint name 'sg_Images_DrawBitmapPartFromRectAtPoint',
sg_Images_DrawBitmapPartFromRectAtPointOnScreen name 'sg_Images_DrawBitmapPartFromRectAtPointOnScreen',
sg_Images_DrawBitmapPartFromRectAtPointOnto name 'sg_Images_DrawBitmapPartFromRectAtPointOnto',
sg_Images_DrawBitmapPartFromRectOnScreen name 'sg_Images_DrawBitmapPartFromRectOnScreen',
sg_Images_DrawBitmapPartFromRectOnto name 'sg_Images_DrawBitmapPartFromRectOnto',
sg_Images_DrawBitmapPartOnScreen name 'sg_Images_DrawBitmapPartOnScreen',
sg_Images_DrawBitmapPartOnto name 'sg_Images_DrawBitmapPartOnto',
sg_Images_DrawCell name 'sg_Images_DrawCell',
sg_Images_DrawCellOnScreen name 'sg_Images_DrawCellOnScreen',
sg_Images_DrawCellOnScreenXY name 'sg_Images_DrawCellOnScreenXY',
sg_Images_DrawCellOnto name 'sg_Images_DrawCellOnto',
sg_Images_DrawCellOntoXY name 'sg_Images_DrawCellOntoXY',
sg_Images_DrawCellXY name 'sg_Images_DrawCellXY',
sg_Images_FreeBitmap name 'sg_Images_FreeBitmap',
sg_Images_HasBitmap name 'sg_Images_HasBitmap',
sg_Images_LoadBitmap name 'sg_Images_LoadBitmap',
sg_Images_LoadBitmapWithTransparentColor name 'sg_Images_LoadBitmapWithTransparentColor',
sg_Images_MakeOpaque name 'sg_Images_MakeOpaque',
sg_Images_MakeTransparent name 'sg_Images_MakeTransparent',
sg_Images_MapBitmap name 'sg_Images_MapBitmap',
sg_Images_MapTransparentBitmap name 'sg_Images_MapTransparentBitmap',
sg_Images_OptimiseBitmap name 'sg_Images_OptimiseBitmap',
sg_Images_PixelDrawnAtPoint name 'sg_Images_PixelDrawnAtPoint',
sg_Images_ReleaseAllBitmaps name 'sg_Images_ReleaseAllBitmaps',
sg_Images_ReleaseBitmap name 'sg_Images_ReleaseBitmap',
sg_Images_RotateScaleBitmap name 'sg_Images_RotateScaleBitmap',
sg_Images_SameBitmapCell name 'sg_Images_SameBitmapCell',
sg_Images_SaveBitmap name 'sg_Images_SaveBitmap',
sg_Images_SaveToPNG name 'sg_Images_SaveToPNG',
sg_Images_SetOpacity name 'sg_Images_SetOpacity',
sg_Images_SetTransparentColor name 'sg_Images_SetTransparentColor',
sg_Images_SetupBitmapForCollisions name 'sg_Images_SetupBitmapForCollisions',
sg_Input_AnyKeyPressed name 'sg_Input_AnyKeyPressed',
sg_Input_EndReadingText name 'sg_Input_EndReadingText',
sg_Input_HideMouse name 'sg_Input_HideMouse',
sg_Input_KeyDown name 'sg_Input_KeyDown',
sg_Input_KeyName name 'sg_Input_KeyName',
sg_Input_KeyTyped name 'sg_Input_KeyTyped',
sg_Input_MouseClicked name 'sg_Input_MouseClicked',
sg_Input_MouseDown name 'sg_Input_MouseDown',
sg_Input_MouseMovement name 'sg_Input_MouseMovement',
sg_Input_MousePosition name 'sg_Input_MousePosition',
sg_Input_MousePositionAsVector name 'sg_Input_MousePositionAsVector',
sg_Input_MouseShown name 'sg_Input_MouseShown',
sg_Input_MouseUp name 'sg_Input_MouseUp',
sg_Input_MouseX name 'sg_Input_MouseX',
sg_Input_MouseY name 'sg_Input_MouseY',
sg_Input_MoveMouse name 'sg_Input_MoveMouse',
sg_Input_MoveMouseToPoint name 'sg_Input_MoveMouseToPoint',
sg_Input_ReadingText name 'sg_Input_ReadingText',
sg_Input_SetMouseVisible name 'sg_Input_SetMouseVisible',
sg_Input_ShowMouse name 'sg_Input_ShowMouse',
sg_Input_StartReadingText name 'sg_Input_StartReadingText',
sg_Input_StartReadingTextWithText name 'sg_Input_StartReadingTextWithText',
sg_Input_StartReadingTextWithTextAtPt name 'sg_Input_StartReadingTextWithTextAtPt',
sg_Input_StartReadingTextWithTextInArea name 'sg_Input_StartReadingTextWithTextInArea',
sg_Input_StartReadingTextWithinArea name 'sg_Input_StartReadingTextWithinArea',
sg_Input_TextEntryCancelled name 'sg_Input_TextEntryCancelled',
sg_Input_TextReadAsASCII name 'sg_Input_TextReadAsASCII',
sg_Physics_BitmapAtPointsCollision name 'sg_Physics_BitmapAtPointsCollision',
sg_Physics_BitmapCollision name 'sg_Physics_BitmapCollision',
sg_Physics_BitmapPartAtPtRectCollision name 'sg_Physics_BitmapPartAtPtRectCollision',
sg_Physics_BitmapPartRectCollision name 'sg_Physics_BitmapPartRectCollision',
sg_Physics_BitmapPointCollision name 'sg_Physics_BitmapPointCollision',
sg_Physics_BitmapPointCollisionPart name 'sg_Physics_BitmapPointCollisionPart',
sg_Physics_BitmapPointPtCollision name 'sg_Physics_BitmapPointPtCollision',
sg_Physics_BitmapPointXYCollisionPart name 'sg_Physics_BitmapPointXYCollisionPart',
sg_Physics_BitmapRectCollision name 'sg_Physics_BitmapRectCollision',
sg_Physics_BitmapRectangleCollision name 'sg_Physics_BitmapRectangleCollision',
sg_Physics_BitmapsPartsCollision name 'sg_Physics_BitmapsPartsCollision',
sg_Physics_CellBitmapCollision name 'sg_Physics_CellBitmapCollision',
sg_Physics_CellBitmapCollisionAtPt name 'sg_Physics_CellBitmapCollisionAtPt',
sg_Physics_CellBitmapPartCollision name 'sg_Physics_CellBitmapPartCollision',
sg_Physics_CellBitmapPartCollisionAtPt name 'sg_Physics_CellBitmapPartCollisionAtPt',
sg_Physics_CellCollision name 'sg_Physics_CellCollision',
sg_Physics_CellCollisionAtPt name 'sg_Physics_CellCollisionAtPt',
sg_Physics_CellRectCollision name 'sg_Physics_CellRectCollision',
sg_Physics_CellRectCollisionAtPt name 'sg_Physics_CellRectCollisionAtPt',
sg_Physics_CircleCircleCollision name 'sg_Physics_CircleCircleCollision',
sg_Physics_CircleLinesCollision name 'sg_Physics_CircleLinesCollision',
sg_Physics_CircleRectCollision name 'sg_Physics_CircleRectCollision',
sg_Physics_CircleTriangleCollision name 'sg_Physics_CircleTriangleCollision',
sg_Physics_CollideCircleCircle name 'sg_Physics_CollideCircleCircle',
sg_Physics_CollideCircleLine name 'sg_Physics_CollideCircleLine',
sg_Physics_CollideCircleLines name 'sg_Physics_CollideCircleLines',
sg_Physics_CollideCircleRectangle name 'sg_Physics_CollideCircleRectangle',
sg_Physics_CollideCircles name 'sg_Physics_CollideCircles',
sg_Physics_RectLineCollision name 'sg_Physics_RectLineCollision',
sg_Physics_SideForCollisionTest name 'sg_Physics_SideForCollisionTest',
sg_Physics_SpriteBitmapAtPointCollision name 'sg_Physics_SpriteBitmapAtPointCollision',
sg_Physics_SpriteBitmapCollision name 'sg_Physics_SpriteBitmapCollision',
sg_Physics_SpriteCircleLineCollision name 'sg_Physics_SpriteCircleLineCollision',
sg_Physics_SpriteCollision name 'sg_Physics_SpriteCollision',
sg_Physics_SpriteRectCollision name 'sg_Physics_SpriteRectCollision',
sg_Physics_SpriteRectLineCollision name 'sg_Physics_SpriteRectLineCollision',
sg_Physics_SpriteRectangleCollision name 'sg_Physics_SpriteRectangleCollision',
sg_Physics_SpriteShapeCollision name 'sg_Physics_SpriteShapeCollision',
sg_Physics_TriangleLineCollision name 'sg_Physics_TriangleLineCollision',
sg_Resources_AppPath name 'sg_Resources_AppPath',
sg_Resources_FilenameToResource name 'sg_Resources_FilenameToResource',
sg_Resources_HasResourceBundle name 'sg_Resources_HasResourceBundle',
sg_Resources_LoadResourceBundle name 'sg_Resources_LoadResourceBundle',
sg_Resources_MapResourceBundle name 'sg_Resources_MapResourceBundle',
sg_Resources_PathToOtherResource name 'sg_Resources_PathToOtherResource',
sg_Resources_PathToOtherResourceWithBase name 'sg_Resources_PathToOtherResourceWithBase',
sg_Resources_PathToResource name 'sg_Resources_PathToResource',
sg_Resources_PathToResourceWithBase name 'sg_Resources_PathToResourceWithBase',
sg_Resources_PathToResourceWithSubPaths name 'sg_Resources_PathToResourceWithSubPaths',
sg_Resources_RegisterFreeNotifier name 'sg_Resources_RegisterFreeNotifier',
sg_Resources_ReleaseAllResources name 'sg_Resources_ReleaseAllResources',
sg_Resources_ReleaseResourceBundle name 'sg_Resources_ReleaseResourceBundle',
sg_Resources_SetAppPath name 'sg_Resources_SetAppPath',
sg_Resources_SetAppPathWithExe name 'sg_Resources_SetAppPathWithExe',
sg_Resources_ShowLogos name 'sg_Resources_ShowLogos',
sg_Sprites_CenterPoint name 'sg_Sprites_CenterPoint',
sg_Sprites_CreateBasicSprite name 'sg_Sprites_CreateBasicSprite',
sg_Sprites_CreateLayeredSprite name 'sg_Sprites_CreateLayeredSprite',
sg_Sprites_CreateLayeredSpriteWithAnimationTemplate name 'sg_Sprites_CreateLayeredSpriteWithAnimationTemplate',
sg_Sprites_CreateLayeredSpriteWithLayerNames name 'sg_Sprites_CreateLayeredSpriteWithLayerNames',
sg_Sprites_CreateLayeredSpriteWithLayerNamesAndAnimationTemplate name 'sg_Sprites_CreateLayeredSpriteWithLayerNamesAndAnimationTemplate',
sg_Sprites_CreateSpriteWithAnimation name 'sg_Sprites_CreateSpriteWithAnimation',
sg_Sprites_CreateSpriteWithLayer name 'sg_Sprites_CreateSpriteWithLayer',
sg_Sprites_CreateSpriteWithLayerAndAnimation name 'sg_Sprites_CreateSpriteWithLayerAndAnimation',
sg_Sprites_DrawSpriteOffsetPoint name 'sg_Sprites_DrawSpriteOffsetPoint',
sg_Sprites_DrawSpriteOffsetXY name 'sg_Sprites_DrawSpriteOffsetXY',
sg_Sprites_FreeSprite name 'sg_Sprites_FreeSprite',
sg_Sprites_IsSpriteOffscreen name 'sg_Sprites_IsSpriteOffscreen',
sg_Sprites_MoveSprite name 'sg_Sprites_MoveSprite',
sg_Sprites_MoveSpriteTo name 'sg_Sprites_MoveSpriteTo',
sg_Sprites_MoveSpriteVecPct name 'sg_Sprites_MoveSpriteVecPct',
sg_Sprites_ReplayAnimationWithSound name 'sg_Sprites_ReplayAnimationWithSound',
sg_Sprites_SpriteAddLayer name 'sg_Sprites_SpriteAddLayer',
sg_Sprites_SpriteAddValue name 'sg_Sprites_SpriteAddValue',
sg_Sprites_SpriteAddValueWithInitialValue name 'sg_Sprites_SpriteAddValueWithInitialValue',
sg_Sprites_SpriteAnimationHasEnded name 'sg_Sprites_SpriteAnimationHasEnded',
sg_Sprites_SpriteBringLayerForward name 'sg_Sprites_SpriteBringLayerForward',
sg_Sprites_SpriteBringLayerToFront name 'sg_Sprites_SpriteBringLayerToFront',
sg_Sprites_SpriteCircle name 'sg_Sprites_SpriteCircle',
sg_Sprites_SpriteCollisionBitmap name 'sg_Sprites_SpriteCollisionBitmap',
sg_Sprites_SpriteCollisionCircle name 'sg_Sprites_SpriteCollisionCircle',
sg_Sprites_SpriteCollisionKind name 'sg_Sprites_SpriteCollisionKind',
sg_Sprites_SpriteCollisionRectangle name 'sg_Sprites_SpriteCollisionRectangle',
sg_Sprites_SpriteCurrentCell name 'sg_Sprites_SpriteCurrentCell',
sg_Sprites_SpriteCurrentCellRectangle name 'sg_Sprites_SpriteCurrentCellRectangle',
sg_Sprites_SpriteDX name 'sg_Sprites_SpriteDX',
sg_Sprites_SpriteDY name 'sg_Sprites_SpriteDY',
sg_Sprites_SpriteHeading name 'sg_Sprites_SpriteHeading',
sg_Sprites_SpriteHeight name 'sg_Sprites_SpriteHeight',
sg_Sprites_SpriteHideLayer name 'sg_Sprites_SpriteHideLayer',
sg_Sprites_SpriteHideLayerNamed name 'sg_Sprites_SpriteHideLayerNamed',
sg_Sprites_SpriteLayerAtIdx name 'sg_Sprites_SpriteLayerAtIdx',
sg_Sprites_SpriteLayerCircle name 'sg_Sprites_SpriteLayerCircle',
sg_Sprites_SpriteLayerCount name 'sg_Sprites_SpriteLayerCount',
sg_Sprites_SpriteLayerHeight name 'sg_Sprites_SpriteLayerHeight',
sg_Sprites_SpriteLayerIndex name 'sg_Sprites_SpriteLayerIndex',
sg_Sprites_SpriteLayerName name 'sg_Sprites_SpriteLayerName',
sg_Sprites_SpriteLayerNamed name 'sg_Sprites_SpriteLayerNamed',
sg_Sprites_SpriteLayerNamedCircle name 'sg_Sprites_SpriteLayerNamedCircle',
sg_Sprites_SpriteLayerNamedHeight name 'sg_Sprites_SpriteLayerNamedHeight',
sg_Sprites_SpriteLayerNamedRectangle name 'sg_Sprites_SpriteLayerNamedRectangle',
sg_Sprites_SpriteLayerNamedWidth name 'sg_Sprites_SpriteLayerNamedWidth',
sg_Sprites_SpriteLayerOffset name 'sg_Sprites_SpriteLayerOffset',
sg_Sprites_SpriteLayerOffsetNamed name 'sg_Sprites_SpriteLayerOffsetNamed',
sg_Sprites_SpriteLayerOffsets name 'sg_Sprites_SpriteLayerOffsets',
sg_Sprites_SpriteLayerRectangle name 'sg_Sprites_SpriteLayerRectangle',
sg_Sprites_SpriteLayerWidth name 'sg_Sprites_SpriteLayerWidth',
sg_Sprites_SpriteLayers name 'sg_Sprites_SpriteLayers',
sg_Sprites_SpriteMass name 'sg_Sprites_SpriteMass',
sg_Sprites_SpriteOnScreenAt name 'sg_Sprites_SpriteOnScreenAt',
sg_Sprites_SpriteOnScreenAtPoint name 'sg_Sprites_SpriteOnScreenAtPoint',
sg_Sprites_SpritePosition name 'sg_Sprites_SpritePosition',
sg_Sprites_SpriteReplayAnimation name 'sg_Sprites_SpriteReplayAnimation',
sg_Sprites_SpriteRotation name 'sg_Sprites_SpriteRotation',
sg_Sprites_SpriteScale name 'sg_Sprites_SpriteScale',
sg_Sprites_SpriteScreenRectangle name 'sg_Sprites_SpriteScreenRectangle',
sg_Sprites_SpriteSendLayerBackward name 'sg_Sprites_SpriteSendLayerBackward',
sg_Sprites_SpriteSendLayerToBack name 'sg_Sprites_SpriteSendLayerToBack',
sg_Sprites_SpriteSetCollisionBitmap name 'sg_Sprites_SpriteSetCollisionBitmap',
sg_Sprites_SpriteSetCollisionKind name 'sg_Sprites_SpriteSetCollisionKind',
sg_Sprites_SpriteSetDX name 'sg_Sprites_SpriteSetDX',
sg_Sprites_SpriteSetDY name 'sg_Sprites_SpriteSetDY',
sg_Sprites_SpriteSetHeading name 'sg_Sprites_SpriteSetHeading',
sg_Sprites_SpriteSetLayerOffset name 'sg_Sprites_SpriteSetLayerOffset',
sg_Sprites_SpriteSetLayerOffsetNamed name 'sg_Sprites_SpriteSetLayerOffsetNamed',
sg_Sprites_SpriteSetLayerOffsets name 'sg_Sprites_SpriteSetLayerOffsets',
sg_Sprites_SpriteSetMass name 'sg_Sprites_SpriteSetMass',
sg_Sprites_SpriteSetPosition name 'sg_Sprites_SpriteSetPosition',
sg_Sprites_SpriteSetRotation name 'sg_Sprites_SpriteSetRotation',
sg_Sprites_SpriteSetScale name 'sg_Sprites_SpriteSetScale',
sg_Sprites_SpriteSetSpeed name 'sg_Sprites_SpriteSetSpeed',
sg_Sprites_SpriteSetValue name 'sg_Sprites_SpriteSetValue',
sg_Sprites_SpriteSetValueNamed name 'sg_Sprites_SpriteSetValueNamed',
sg_Sprites_SpriteSetVelocity name 'sg_Sprites_SpriteSetVelocity',
sg_Sprites_SpriteSetX name 'sg_Sprites_SpriteSetX',
sg_Sprites_SpriteSetY name 'sg_Sprites_SpriteSetY',
sg_Sprites_SpriteShowLayer name 'sg_Sprites_SpriteShowLayer',
sg_Sprites_SpriteShowLayerNamed name 'sg_Sprites_SpriteShowLayerNamed',
sg_Sprites_SpriteSpeed name 'sg_Sprites_SpriteSpeed',
sg_Sprites_SpriteStartAnimation name 'sg_Sprites_SpriteStartAnimation',
sg_Sprites_SpriteStartAnimationNamed name 'sg_Sprites_SpriteStartAnimationNamed',
sg_Sprites_SpriteStartAnimationNamedWithSound name 'sg_Sprites_SpriteStartAnimationNamedWithSound',
sg_Sprites_SpriteStartAnimationWithSound name 'sg_Sprites_SpriteStartAnimationWithSound',
sg_Sprites_SpriteToggleLayerNamedVisible name 'sg_Sprites_SpriteToggleLayerNamedVisible',
sg_Sprites_SpriteToggleLayerVisible name 'sg_Sprites_SpriteToggleLayerVisible',
sg_Sprites_SpriteValue name 'sg_Sprites_SpriteValue',
sg_Sprites_SpriteValueCount name 'sg_Sprites_SpriteValueCount',
sg_Sprites_SpriteValueNamed name 'sg_Sprites_SpriteValueNamed',
sg_Sprites_SpriteValueNames name 'sg_Sprites_SpriteValueNames',
sg_Sprites_SpriteVelocity name 'sg_Sprites_SpriteVelocity',
sg_Sprites_SpriteVisibleIndexOfLayer name 'sg_Sprites_SpriteVisibleIndexOfLayer',
sg_Sprites_SpriteVisibleIndexOfLayerNamed name 'sg_Sprites_SpriteVisibleIndexOfLayerNamed',
sg_Sprites_SpriteVisibleLayer name 'sg_Sprites_SpriteVisibleLayer',
sg_Sprites_SpriteVisibleLayerCount name 'sg_Sprites_SpriteVisibleLayerCount',
sg_Sprites_SpriteVisibleLayerIds name 'sg_Sprites_SpriteVisibleLayerIds',
sg_Sprites_SpriteWidth name 'sg_Sprites_SpriteWidth',
sg_Sprites_SpriteX name 'sg_Sprites_SpriteX',
sg_Sprites_SpriteY name 'sg_Sprites_SpriteY',
sg_Sprites_UpdateSpriteAnimationPctWithSound name 'sg_Sprites_UpdateSpriteAnimationPctWithSound',
sg_Sprites_UpdateSpritePctWithSound name 'sg_Sprites_UpdateSpritePctWithSound',
sg_Sprites_VectorFromCenterSpriteToPoint name 'sg_Sprites_VectorFromCenterSpriteToPoint',
sg_Sprites_VectorFromTo name 'sg_Sprites_VectorFromTo',
sg_Text_DrawFrameRateWithSimpleFont name 'sg_Text_DrawFrameRateWithSimpleFont',
sg_Text_DrawFramerate name 'sg_Text_DrawFramerate',
sg_Text_DrawSimpleText name 'sg_Text_DrawSimpleText',
sg_Text_DrawSimpleTextOnBitmap name 'sg_Text_DrawSimpleTextOnBitmap',
sg_Text_DrawSimpleTextOnScreen name 'sg_Text_DrawSimpleTextOnScreen',
sg_Text_DrawSimpleTextPt name 'sg_Text_DrawSimpleTextPt',
sg_Text_DrawText name 'sg_Text_DrawText',
sg_Text_DrawTextAtPoint name 'sg_Text_DrawTextAtPoint',
sg_Text_DrawTextLines name 'sg_Text_DrawTextLines',
sg_Text_DrawTextLinesInRect name 'sg_Text_DrawTextLinesInRect',
sg_Text_DrawTextLinesInRectOnBitmap name 'sg_Text_DrawTextLinesInRectOnBitmap',
sg_Text_DrawTextLinesInRectOnScreen name 'sg_Text_DrawTextLinesInRectOnScreen',
sg_Text_DrawTextLinesOnBitmap name 'sg_Text_DrawTextLinesOnBitmap',
sg_Text_DrawTextLinesOnScreen name 'sg_Text_DrawTextLinesOnScreen',
sg_Text_DrawTextOnBitmap name 'sg_Text_DrawTextOnBitmap',
sg_Text_DrawTextOnBitmapAtPoint name 'sg_Text_DrawTextOnBitmapAtPoint',
sg_Text_DrawTextOnScreen name 'sg_Text_DrawTextOnScreen',
sg_Text_DrawTextOnScreenAtPoint name 'sg_Text_DrawTextOnScreenAtPoint',
sg_Text_FontFontStyle name 'sg_Text_FontFontStyle',
sg_Text_FontNameFor name 'sg_Text_FontNameFor',
sg_Text_FontNamed name 'sg_Text_FontNamed',
sg_Text_FontNamedWithSize name 'sg_Text_FontNamedWithSize',
sg_Text_FontSetStyle name 'sg_Text_FontSetStyle',
sg_Text_FreeFont name 'sg_Text_FreeFont',
sg_Text_HasFont name 'sg_Text_HasFont',
sg_Text_LoadFont name 'sg_Text_LoadFont',
sg_Text_MapFont name 'sg_Text_MapFont',
sg_Text_ReleaseAllFonts name 'sg_Text_ReleaseAllFonts',
sg_Text_ReleaseFont name 'sg_Text_ReleaseFont',
sg_Text_TextAlignmentFrom name 'sg_Text_TextAlignmentFrom',
sg_Text_TextHeight name 'sg_Text_TextHeight',
sg_Text_TextWidth name 'sg_Text_TextWidth',
sg_Timers_CreateTimer name 'sg_Timers_CreateTimer',
sg_Timers_FreeTimer name 'sg_Timers_FreeTimer',
sg_Timers_PauseTimer name 'sg_Timers_PauseTimer',
sg_Timers_ResetTimer name 'sg_Timers_ResetTimer',
sg_Timers_ResumeTimer name 'sg_Timers_ResumeTimer',
sg_Timers_StartTimer name 'sg_Timers_StartTimer',
sg_Timers_StopTimer name 'sg_Timers_StopTimer',
sg_Timers_TimerTicks name 'sg_Timers_TimerTicks';end.
|
unit ReceivedMessage;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Menus, Placemnt;
type
TReceivedMessageForm = class(TForm)
MainMenu: TMainMenu;
FileMI: TMenuItem;
ClearMI: TMenuItem;
MessageTextMemo: TMemo;
ActionPanel: TPanel;
FormPlacement: TFormPlacement;
MessageTextSaveDialog: TSaveDialog;
SaveMI: TMenuItem;
ReplyButton: TButton;
CloseButton: TButton;
procedure ReplyButtonClick(Sender: TObject);
procedure SaveMIClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure ClearMIClick(Sender: TObject);
private
{ Private declarations }
procedure Save;
procedure Clear;
public
{ Public declarations }
AnswerNeeded: Boolean;
end;
var
ReceivedMessageForm: TReceivedMessageForm;
implementation
{$R *.dfm}
procedure TReceivedMessageForm.ReplyButtonClick(Sender: TObject);
begin
AnswerNeeded := True;
end;
procedure TReceivedMessageForm.SaveMIClick(Sender: TObject);
begin
Save;
end;
procedure TReceivedMessageForm.FormCreate(Sender: TObject);
begin
AnswerNeeded := False;
end;
procedure TReceivedMessageForm.Clear;
begin
MessageTextMemo.Lines.Clear;
end;
procedure TReceivedMessageForm.Save;
begin
with MessageTextSaveDialog do
begin
if Execute then
begin
MessageTextMemo.Lines.SaveToFile(FileName);
end;
end;
end;
procedure TReceivedMessageForm.ClearMIClick(Sender: TObject);
begin
Clear;
end;
end.
|
{
$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.2 12/2/2004 4:23:54 PM JPMugaas
Adjusted for changes in Core.
Rev 1.1 4/12/2003 10:24:08 PM GGrieve
Fix to Compile
Rev 1.0 11/13/2002 07:54:06 AM JPMugaas
2000-May-18: J. Peter Mugaas
-Ported to Indy
2000-Jan-13: MTL
-13-JAN-2000 MTL: Moved to new Palette Scheme (Winshoes Servers)
1999-May-13: Ozz Nixon
-Final version
}
unit IdHostnameServer;
interface
{$i IdCompilerDefines.inc}
{
Original Author: Ozz Nixon
Based on RFC 953
}
uses
IdAssignedNumbers,
IdContext,
IdCustomTCPServer;
Const
KnownCommands: array [0..8] of string =
(
'HNAME', {Do not Localize}
'HADDR', {Do not Localize}
'ALL', {Do not Localize}
'HELP', {Do not Localize}
'VERSION', {Do not Localize}
'ALL-OLD', {Do not Localize}
'DOMAINS', {Do not Localize}
'ALL-DOM', {Do not Localize}
'ALL-INGWAY' {Do not Localize}
);
Type
THostNameOneParmEvent = procedure(AThread: TIdContext; const AParam: String) of object;
TIdHostNameServer = class(TIdCustomTCPServer)
protected
FOnCommandHNAME: THostNameOneParmEvent;
FOnCommandHADDR: THostNameOneParmEvent;
FOnCommandALL: TIdContextEvent;
FOnCommandHELP: TIdContextEvent;
FOnCommandVERSION: TIdContextEvent;
FOnCommandALLOLD: TIdContextEvent;
FOnCommandDOMAINS: TIdContextEvent;
FOnCommandALLDOM: TIdContextEvent;
FOnCommandALLINGWAY: TIdContextEvent;
//
function DoExecute(AContext: TIdContext): Boolean; override;
procedure InitComponent; override;
published
property OnCommandHNAME: THostNameOneParmEvent read fOnCommandHNAME write fOnCommandHNAME;
property OnCommandHADDR: THostNameOneParmEvent read fOnCommandHADDR write fOnCommandHADDR;
property OnCommandALL: TIdContextEvent read fOnCommandALL write fOnCommandALL;
property OnCommandHELP: TIdContextEvent read fOnCommandHELP write fOnCommandHELP;
property OnCommandVERSION: TIdContextEvent read fOnCommandVERSION write fOnCommandVERSION;
property OnCommandALLOLD: TIdContextEvent read fOnCommandALLOLD write fOnCommandALLOLD;
property OnCommandDOMAINS: TIdContextEvent read fOnCommandDOMAINS write fOnCommandDOMAINS;
property OnCommandALLDOM: TIdContextEvent read fOnCommandALLDOM write fOnCommandALLDOM;
property OnCommandALLINGWAY: TIdContextEvent read fOnCommandALLINGWAY write fOnCommandALLINGWAY;
end;
implementation
uses
IdGlobalCore,
IdGlobal;
procedure TIdHostNameServer.InitComponent;
begin
inherited InitComponent;
DefaultPort := IdPORT_HOSTNAME;
end;
function TIdHostNameServer.DoExecute(AContext: TIdContext): Boolean;
var
S: String;
begin
Result := True;
while AContext.Connection.Connected do
begin
S := AContext.Connection.IOHandler.ReadLn;
case PosInStrArray(Fetch(S, CHAR32), KnownCommands, False) of
0 : {hname}
if Assigned(OnCommandHNAME) then
OnCommandHNAME(AContext, S);
1 : {haddr}
if Assigned(OnCommandHADDR) then
OnCommandHADDR(AContext, S);
2 : {all}
if Assigned(OnCommandALL) then
OnCommandALL(AContext);
3 : {help}
if Assigned(OnCommandHELP) then
OnCommandHELP(AContext);
4 : {version}
if Assigned(OnCommandVERSION) then
OnCommandVERSION(AContext);
5 : {all-old}
if Assigned(OnCommandALLOLD) then
OnCommandALLOLD(AContext);
6 : {domains}
if Assigned(OnCommandDOMAINS) then
OnCommandDOMAINS(AContext);
7 : {all-dom}
if Assigned(OnCommandALLDOM) then
OnCommandALLDOM(AContext);
8 : {all-ingway}
if Assigned(OnCommandALLINGWAY) then
OnCommandALLINGWAY(AContext);
end;
end;
AContext.Connection.Disconnect;
end;
end.
|
{
$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.24 10/14/2004 1:45:32 PM BGooijen
{ Beauty fixes ;)
}
{
{ Rev 1.23 10/14/2004 1:05:48 PM BGooijen
{ set PerformReply to false, else "200 OK" was added behind the document body
}
{
{ Rev 1.22 09.08.2004 09:30:00 OMonien
{ changed disconnect handling. Previous implementation failed when exceptions
{ ocured in command handler.
}
{
{ Rev 1.21 08.08.2004 10:35:56 OMonien
{ Greeting removed
}
{
Rev 1.20 6/11/2004 9:36:28 AM DSiders
Added "Do not Localize" comments.
}
{
{ Rev 1.19 2004.05.20 1:39:24 PM czhower
{ Last of the IdStream updates
}
{
{ Rev 1.18 2004.05.20 11:37:20 AM czhower
{ IdStreamVCL
}
{
{ Rev 1.17 4/19/2004 7:07:38 PM BGooijen
{ the remote headers are now passed to the OnHTTPDocument event
}
{
{ Rev 1.16 4/18/2004 11:31:26 PM BGooijen
{ Fixed POST
{ Build CONNECT
{ fixed some bugs where chars were replaced when that was not needed ( thus
{ causing corrupt data )
}
{
{ Rev 1.15 2004.04.13 10:24:24 PM czhower
{ Bug fix for when user changes stream.
}
{
{ Rev 1.14 2004.02.03 5:45:12 PM czhower
{ Name changes
}
{
{ Rev 1.13 1/21/2004 2:42:52 PM JPMugaas
{ InitComponent
}
{
{ Rev 1.12 10/25/2003 06:52:12 AM JPMugaas
{ Updated for new API changes and tried to restore some functionality.
}
{
{ Rev 1.11 2003.10.24 10:43:10 AM czhower
{ TIdSTream to dos
}
{
Rev 1.10 10/17/2003 12:10:08 AM DSiders
Added localization comments.
}
{
{ Rev 1.9 2003.10.12 3:50:44 PM czhower
{ Compile todos
}
{
{ Rev 1.8 7/13/2003 7:57:38 PM SPerry
{ fixed problem with commandhandlers
}
{
{ Rev 1.6 5/25/2003 03:54:42 AM JPMugaas
}
{
{ Rev 1.5 2/24/2003 08:56:50 PM JPMugaas
}
{
Rev 1.4 1/20/2003 1:15:44 PM BGooijen
Changed to TIdTCPServer / TIdCmdTCPServer classes
}
{
{ Rev 1.3 1-14-2003 19:19:22 BGooijen
{ The first line of the header was sent to the server twice, fixed that.
}
{
{ Rev 1.2 1-1-2003 21:52:06 BGooijen
{ Changed for TIdContext
}
{
{ Rev 1.1 12-29-2002 13:00:02 BGooijen
{ - Works on Indy 10 now
{ - Cleaned up some code
}
{
{ Rev 1.0 2002.11.22 8:37:50 PM czhower
}
{
{ Rev 1.0 2002.11.22 8:37:16 PM czhower
}
unit IdHTTPProxyServer;
interface
{
Indy HTTP proxy Server
Original Programmer: Bas Gooijen (bas_gooijen@yahoo.com)
Current Maintainer: Bas Gooijen
Code is given to the Indy Pit Crew.
Modifications by Chad Z. Hower (Kudzu)
Quick Notes:
Revision History:
10-May-2002: Created Unit.
}
uses
// Classes,
IdObjs,
IdAssignedNumbers,
IdGlobal,
IdHeaderList,
IdTCPConnection,
IdCmdTCPServer,
IdCommandHandlers;
const
IdPORT_HTTPProxy = 8080;
type
{ not needed (yet)
TIdHTTPProxyServerThread = class( TIdPeerThread )
protected
// what needs to be stored...
fUser: string;
fPassword: string;
public
constructor Create( ACreateSuspended: Boolean = True ) ; override;
destructor Destroy; override;
// Any functions for vars
property Username: string read fUser write fUser;
property Password: string read fPassword write fPassword;
end;
}
TIdHTTPProxyServer = class;
TOnHTTPDocument = procedure(ASender: TIdHTTPProxyServer; const ADocument: string;
var VStream: TIdStream; const AHeaders: TIdHeaderList) of object;
TIdHTTPProxyServer = class(TIdCmdTCPServer)
protected
FOnHTTPDocument: TOnHTTPDocument;
// CommandHandlers
procedure CommandGET(ASender: TIdCommand);
procedure CommandPOST(ASender: TIdCommand);
procedure CommandHEAD(ASender: TIdCommand);
procedure CommandConnect(ASender: TIdCommand); // for ssl
procedure DoHTTPDocument(const ADocument: string; var VStream: TIdStream; const AHeaders: TIdHeaderList);
procedure InitializeCommandHandlers; override;
procedure TransferData(ASrc: TIdTCPConnection; ADest: TIdTCPConnection; const ADocument: string;
const ASize: Integer; const AHeaders: TIdHeaderList);
procedure InitComponent; override;
published
property DefaultPort default IdPORT_HTTPProxy;
property OnHTTPDocument: TOnHTTPDocument read FOnHTTPDocument write FOnHTTPDocument;
end;
implementation
uses
IdResourceStrings, IdReplyRFC, IdSYs, IdTCPClient, IdURI, IdGlobalProtocols;
procedure TIdHTTPProxyServer.InitializeCommandHandlers;
begin
inherited;
with CommandHandlers.Add do begin
Command := 'GET'; {do not localize}
OnCommand := CommandGet;
ParseParams := True;
Disconnect := true;
end;
with CommandHandlers.Add do
begin
Command := 'POST'; {do not localize}
OnCommand := CommandPOST;
ParseParams := True;
Disconnect := true;
end;
with CommandHandlers.Add do
begin
Command := 'HEAD'; {do not localize}
OnCommand := CommandHEAD;
ParseParams := True;
Disconnect := true;
end;
with CommandHandlers.Add do
begin
Command := 'CONNECT'; {do not localize}
OnCommand := Commandconnect;
ParseParams := True;
Disconnect := true;
end;
//HTTP Servers/Proxies do not send a greeting
Greeting.Clear;
end;
procedure TIdHTTPProxyServer.TransferData(
ASrc: TIdTCPConnection;
ADest: TIdTCPConnection;
const ADocument: string;
const ASize: Integer;
const AHeaders: TIdHeaderList
);
//TODO: This captures then sends. This is great and we need this as an option for proxies that
// modify data. However we also need another option that writes as it captures.
// Two modes? Intercept and not?
var
LStream: TIdStream;
begin
//TODO: Have an event to let the user perform stream creation
LStream := TIdMemoryStream.Create; try
ASrc.IOHandler.ReadStream(LStream, ASize, ASize = -1);
LStream.Position := 0;
DoHTTPDocument(ADocument, LStream, AHeaders);
// Need to recreate IdStream, DoHTTPDocument passes it as a var and user can change the
// stream that is returned
ADest.IOHandler.Write(LStream);
finally Sys.FreeAndNil(LStream); end;
end;
procedure TIdHTTPProxyServer.CommandGET( ASender: TIdCommand ) ;
var
LClient: TIdTCPClient;
LDocument: string;
LHeaders: TIdHeaderList;
LRemoteHeaders: TIdHeaderList;
LURI: TIdURI;
LPageSize: Integer;
begin
ASender.PerformReply := false;
LHeaders := TIdHeaderList.Create; try
ASender.Context.Connection.IOHandler.Capture(LHeaders, '');
LClient := TIdTCPClient.Create(nil); try
LURI := TIdURI.Create(ASender.Params.Strings[0]); try
LClient.Port := Sys.StrToInt(LURI.Port, 80);
LClient.Host := LURI.Host;
//We have to remove the host and port from the request
LDocument := LURI.Path + LURI.Document + LURI.Params;
finally Sys.FreeAndNil(LURI); end;
LClient.Connect; try
LClient.IOHandler.WriteLn('GET ' + LDocument + ' HTTP/1.0'); {Do not Localize}
LClient.IOHandler.Write(LHeaders);
LClient.IOHandler.WriteLn('');
LRemoteHeaders := TIdHeaderList.Create; try
LClient.IOHandler.Capture(LRemoteHeaders, '');
ASender.Context.Connection.IOHandler.Write(LRemoteHeaders);
ASender.Context.Connection.IOHandler.WriteLn('');
LPageSize := Sys.StrToInt(LRemoteHeaders.Values['Content-Length'], -1) ; {Do not Localize}
TransferData(LClient, ASender.Context.Connection, LDocument, LPageSize, LRemoteHeaders);
finally Sys.FreeAndNil(LRemoteHeaders); end;
finally LClient.Disconnect; end;
finally Sys.FreeAndNil(LClient); end;
finally Sys.FreeAndNil(LHeaders); end;
end;
procedure TIdHTTPProxyServer.CommandPOST( ASender: TIdCommand ) ;
var
LClient: TIdTCPClient;
LDocument: string;
LHeaders: TIdHeaderList;
LRemoteHeaders: TIdHeaderList;
LURI: TIdURI;
LPageSize: Integer;
LPostStream: TIdMemoryStream;
begin
ASender.PerformReply := false;
LHeaders := TIdHeaderList.Create; try
ASender.Context.Connection.IOHandler.Capture(LHeaders, '');
LPostStream:= TIdMemorystream.Create;
try
LPostStream.size:=Sys.StrToInt( LHeaders.Values['Content-Length'], 0 ); {Do not Localize}
ASender.Context.Connection.IOHandler.ReadStream(LPostStream,LPostStream.Size,false);
LClient := TIdTCPClient.Create(nil); try
LURI := TIdURI.Create(ASender.Params.Strings[0]); try
LClient.Port := Sys.StrToInt(LURI.Port, 80);
LClient.Host := LURI.Host;
//We have to remove the host and port from the request
LDocument := LURI.Path + LURI.Document + LURI.Params;
finally Sys.FreeAndNil(LURI); end;
LClient.Connect; try
LClient.IOHandler.WriteLn('POST ' + LDocument + ' HTTP/1.0'); {Do not Localize}
LClient.IOHandler.Write(LHeaders);
LClient.IOHandler.WriteLn('');
LClient.IOHandler.Write(LPostStream,0,false);
LRemoteHeaders := TIdHeaderList.Create; try
LClient.IOHandler.Capture(LRemoteHeaders, '');
ASender.Context.Connection.IOHandler.Write(LRemoteHeaders);
ASender.Context.Connection.IOHandler.Writeln('');
LPageSize := Sys.StrToInt(LRemoteHeaders.Values['Content-Length'], -1) ; {Do not Localize}
TransferData(LClient, ASender.Context.Connection, LDocument, LPageSize, LRemoteHeaders);
finally Sys.FreeAndNil(LRemoteHeaders); end;
finally LClient.Disconnect; end;
finally Sys.FreeAndNil(LClient); end;
finally Sys.FreeAndNil(LPostStream); end;
finally Sys.FreeAndNil(LHeaders); end;
end;
procedure TIdHTTPProxyServer.CommandConnect( ASender: TIdCommand ) ;
var
LHeaders: tidheaderlist;
LClient: TIdTCPClient;
LRemoteHost: string;
LBuffer:TIdBytes;
begin
ASender.PerformReply := false;
LHeaders := TIdHeaderList.Create; try
ASender.Context.Connection.IOHandler.Capture(LHeaders, '');
LRemoteHost := ASender.Params.Strings[0];
LClient := TIdTCPClient.Create(nil); try
LClient.Host := Fetch(LRemoteHost,':',True);
LClient.Port := Sys.StrToInt(LRemoteHost, 443);
LClient.Connect; try
ASender.Context.Connection.IOHandler.WriteLn('');
ASender.Context.Connection.IOHandler.WriteLn('HTTP/1.0 200 Connection established'); {do not localize}
ASender.Context.Connection.IOHandler.WriteLn('Proxy-agent: Indy-Proxy/1.1'); {do not localize}
ASender.Context.Connection.IOHandler.WriteLn('');
ASender.Context.Connection.IOHandler.ReadTimeout:=100;
LClient.IOHandler.ReadTimeout:=100;
while ASender.Context.Connection.Connected and LClient.Connected do begin
ASender.Context.Connection.IOHandler.ReadBytes(LBuffer,-1,true);
LClient.IOHandler.Write(LBuffer);
SetLength(LBuffer,0);
LClient.IOHandler.ReadBytes(LBuffer,-1,true);
ASender.Context.Connection.IOHandler.Write(LBuffer);
SetLength(LBuffer,0);
end;
finally LClient.Disconnect; end;
finally Sys.FreeAndNil(LClient); end;
finally Sys.FreeAndNil(LHeaders); end;
end;
procedure TIdHTTPProxyServer.CommandHEAD( ASender: TIdCommand ) ;
begin
end;
procedure TIdHTTPProxyServer.InitComponent;
begin
inherited;
DefaultPort := IdPORT_HTTPProxy;
Greeting.Text.Text := ''; // RS
ReplyUnknownCommand.Text.Text := ''; // RS
end;
procedure TIdHTTPProxyServer.DoHTTPDocument(const ADocument: string; var VStream: TIdStream; const AHeaders: TIdHeaderList);
begin
if Assigned(OnHTTPDocument) then begin
OnHTTPDocument(Self, ADocument, VStream, AHeaders);
end;
end;
end.
|
unit AddOrderUnit;
interface
uses SysUtils, BaseExampleUnit, OrderUnit;
type
TAddOrder = class(TBaseExample)
public
function Execute: TOrder;
end;
implementation
function TAddOrder.Execute: TOrder;
var
ErrorString: String;
Order: TOrder;
begin
Order := TOrder.Create();
try
Order.Address1 := 'Test Address1';
Order.AddressAlias := 'Test AddressAlias';
Order.FirstName := 'John';
Order.CachedLatitude := 37.773972;
Order.CachedLongitude := -122.431297;
Result := Route4MeManager.Order.Add(Order, ErrorString);
WriteLn('');
if (Result <> nil) then
begin
WriteLn('AddOrder executed successfully');
WriteLn(Format('Order ID: %d', [Result.Id.Value]));
end
else
WriteLn(Format('AddOrder error: "%s"', [ErrorString]));
finally
FreeAndNil(Order);
end;
end;
end.
|
unit FavProtocol;
interface
const
fvkFolder = 0;
fvkLink = 1;
const
chrPathSeparator = '/';
chrPropSeparator = #1;
chrItemSeparator = #2;
function SerializeItemProps( Id, Kind : integer; Name, Info : string; SubItemCount : integer ) : string;
procedure UnSerializeItemProps( ItemProps : string; out Id, Kind : integer; out Name, Info : string; out SubItemCount : integer );
function ExtractParentLocation( Location : string ) : string;
implementation
uses
CompStringsParser, SysUtils;
function SerializeItemProps( Id, Kind : integer; Name, Info : string; SubItemCount : integer ) : string;
begin
result :=
IntToStr(Id) + chrPropSeparator +
IntToStr(Kind) + chrPropSeparator +
Name + chrPropSeparator +
Info + chrPropSeparator +
IntToStr(SubItemCount) + chrPropSeparator;
end;
procedure UnSerializeItemProps( ItemProps : string; out Id, Kind : integer; out Name, Info : string; out SubItemCount : integer );
var
p : integer;
begin
p := 1;
Id := StrToInt(GetNextStringUpTo( ItemProps, p, chrPropSeparator ));
Kind := StrToInt(GetNextStringUpTo( ItemProps, p, chrPropSeparator ));
Name := GetNextStringUpTo( ItemProps, p, chrPropSeparator );
Info := GetNextStringUpTo( ItemProps, p, chrPropSeparator );
SubItemCount := StrToInt(GetNextStringUpTo( ItemProps, p, chrPropSeparator ));
end;
function ExtractParentLocation( Location : string ) : string;
var
idStr : string;
oldpos, pos : integer;
begin
if Location <> ''
then
begin
pos := 1;
repeat
oldpos := pos;
idStr := GetNextStringUpTo( Location, pos, chrPathSeparator );
if idStr <> ''
then
begin
result := system.copy( Location, 1, oldpos - 1 );
end;
until idStr = '';
end
else result := '';
end;
end.
|
unit clBancos;
interface
uses clConexao;
type
TBancos = class(TObject)
private
function getCodigo: String;
function getNome: String;
procedure setCodigo(const Value: String);
procedure setNome(const Value: String);
function getOperacao: String;
procedure setOperacao(const Value: String);
protected
_codigo: String;
_nome: String;
_operacao: String;
_conexao: TConexao;
public
constructor Create;
destructor Destroy;
property Codigo: String read getCodigo write setCodigo;
property Nome: String read getNome write setNome;
property Operacao: String read getOperacao write setOperacao;
function Validar(): Boolean;
function Exist(): Boolean;
function getObject(id, filtro: String): Boolean;
function getObjects(): Boolean;
function getField(campo, coluna: String): String;
function Insert(): Boolean;
function Update(): Boolean;
end;
const
TABLENAME = 'TBBANCOS';
implementation
uses Variants, SysUtils, udm, clUtil, Math, Dialogs, DB, ZAbstractRODataset,
ZDataset,
ZAbstractDataset;
{ TBancos }
constructor TBancos.Create;
begin
_conexao := TConexao.Create;
if (not _conexao.VerifyConnZEOS(0)) then
begin
MessageDlg('Erro ao estabelecer conexão ao banco de dados (' +
Self.ClassName + ') !', mtError, [mbCancel], 0);
end;
end;
destructor TBancos.Destroy;
begin
_conexao.Free;
end;
function TBancos.getCodigo: String;
begin
Result := _codigo;
end;
function TBancos.getNome: String;
begin
Result := _nome;
end;
function TBancos.getOperacao: String;
begin
Result := _operacao;
end;
function TBancos.Validar(): Boolean;
begin
Result := False;
if TUtil.Empty(Self.Codigo) then
begin
MessageDlg('Informe o código do Banco.', mtWarning, [mbOK], 0);
Exit;
end;
if TUtil.Empty(Self.Nome) then
begin
MessageDlg('Informe o nome do Banco.', mtWarning, [mbOK], 0);
Exit;
end;
if Self.Operacao = 'I' then
begin
if Self.Exist() then
begin
MessageDlg('Código de Banco já cadastrado!', mtWarning, [mbOK], 0);
Exit
end;
end;
Result := True;
end;
function TBancos.Exist(): Boolean;
begin
try
Result := False;
with dm.qryGeral do
begin
Close;
SQL.Clear;
SQL.Add('SELECT * FROM ' + TABLENAME);
SQL.Add('WHERE COD_BANCO = :CODIGO');
ParamByName('CODIGO').AsString := Self.Codigo;
dm.ZConn.Reconnect;
Open;
if not(IsEmpty) then
begin
Result := True;
end;
Close;
SQL.Clear;
end;
Except
on E: Exception do
begin
ShowMessage('Classe: ' + E.ClassName + chr(13) + 'Mensagem: ' +
E.Message);
end;
end;
end;
function TBancos.getObject(id, filtro: String): Boolean;
begin
try
Result := False;
with dm.qryGetObject do
begin
Close;
SQL.Clear;
SQL.Add('SELECT * FROM ' + TABLENAME);
if filtro = 'CODIGO' then
begin
SQL.Add('WHERE COD_BANCO = :CODIGO');
ParamByName('CODIGO').AsString := id;
end;
if filtro = 'NOME' then
begin
SQL.Add('WHERE NOM_BANCO = :NOME');
ParamByName('NOME').AsString := id;
end;
dm.ZConn.Reconnect;
Open;
if not(IsEmpty) then
begin
First;
if RecordCount = 1 then
begin
Self.Codigo := FieldByName('COD_BANCO').AsString;
Self.Nome := FieldByName('NOM_BANCO').AsString;
Close;
SQL.Clear;
end
end
else
begin
Close;
SQL.Clear;
Exit;
end;
end;
Result := True;
Except
on E: Exception do
begin
ShowMessage('Classe: ' + E.ClassName + chr(13) + 'Mensagem: ' +
E.Message);
end;
end;
end;
function TBancos.getObjects(): Boolean;
begin
try
Result := False;
with dm.qryGetObject do
begin
Close;
SQL.Clear;
SQL.Add('SELECT * FROM ' + TABLENAME);
dm.ZConn.Reconnect;
Open;
if IsEmpty then
begin
Close;
SQL.Clear;
Exit;
end;
First;
end;
Result := True;
Except
on E: Exception do
begin
ShowMessage('Classe: ' + E.ClassName + chr(13) + 'Mensagem: ' +
E.Message);
end;
end;
end;
function TBancos.getField(campo, coluna: String): String;
begin
try
Result := '';
if TUtil.Empty(campo) then
begin
Exit;
end;
if TUtil.Empty(coluna) then
begin
Exit;
end;
with dm.qryGetObject do
begin
Close;
SQL.Clear;
SQL.Add('SELECT ' + campo + ' FROM ' + TABLENAME);
if coluna = 'CODIGO' then
begin
SQL.Add('WHERE COD_BANCO = :CODIGO');
ParamByName('CODIGO').AsString := Self.Codigo;
end;
if coluna = 'NOME' then
begin
SQL.Add('WHERE NOM_BANCO = :NOME');
ParamByName('NOME').AsString := Self.Nome;
end;
dm.ZConn.Reconnect;
Open;
if not(IsEmpty) then
begin
Result := FieldByName(campo).AsString;
end;
Close;
SQL.Clear;
end;
Except
on E: Exception do
begin
ShowMessage('Classe: ' + E.ClassName + chr(13) + 'Mensagem: ' +
E.Message);
end;
end;
end;
function TBancos.Insert(): Boolean;
begin
try
Result := False;
with dm.qryCRUD do
begin
SQL.Text := 'INSERT INTO ' + TABLENAME + ' (' + 'COD_BANCO, ' +
'NOM_BANCO) ' + 'VALUES (' + ':CODIGO, ' + ':NOME)';
ParamByName('CODIGO').AsString := Self.Codigo;
ParamByName('NOME').AsString := Self.Nome;
dm.ZConn.Reconnect;
ExecSQL;
Close;
SQL.Clear;
end;
Result := True;
Except
on E: Exception do
begin
ShowMessage('Classe: ' + E.ClassName + chr(13) + 'Mensagem: ' +
E.Message);
end;
end;
end;
function TBancos.Update(): Boolean;
begin
try
Result := False;
with dm.qryCRUD do
begin
SQL.Text := 'UPDATE ' + TABLENAME + ' SET ' + 'NOM_BANCO = :NOME ' +
'WHERE COD_BANCO = :CODIGO';
ParamByName('CODIGO').AsString := Self.Codigo;
ParamByName('NOME').AsString := Self.Nome;
dm.ZConn.Reconnect;
ExecSQL;
Close;
SQL.Clear;
end;
Result := True;
Except
on E: Exception do
begin
ShowMessage('Classe: ' + E.ClassName + chr(13) + 'Mensagem: ' +
E.Message);
end;
end;
end;
procedure TBancos.setCodigo(const Value: String);
begin
_codigo := Value;
end;
procedure TBancos.setNome(const Value: String);
begin
_nome := Value;
end;
procedure TBancos.setOperacao(const Value: String);
begin
_operacao := Value;
end;
end.
|
unit entrada;
interface
uses
SysUtils, DateUtils;
type
T_Entrada = class(TObject)
private
F_Id: Integer;
F_Tanque_Id: Integer;
F_Litros: Double;
F_ValorPorLitro: Double;
F_ValorDaEntrada: Double;
F_DataHora: TDateTime;
// F_Id
function getId(): Integer;
procedure setId(pId: Integer);
// F_Tanque_Id
function getTanque_Id(): Integer;
procedure setTanque_Id(pTanque_Id: Integer);
// F_Litros
function getLitros(): Double;
procedure setLitros(pLitros: Double);
// F_ValorPorLitro
function getValorPorLitro(): Double;
procedure setValorPorLitro(pValorPorLitro: Double);
// F_ValorDaEntrada
function getValorDaEntrada(): Double;
// F_DataHora
function getDataHora(): TDateTime;
procedure setDataHora(pDataHora: TDateTime);
procedure Totalizar();
public
constructor Create(
pId: Integer;
pTanque_Id: Integer;
pLitros: Double;
pValorPorLitro: Double;
pDataHora: TDateTime
); overload;
constructor Create(); overload;
published
property Id: Integer read getId write setId;
property Tanque_Id: Integer read getTanque_Id write setTanque_Id;
property Litros: Double read getLitros write setLitros;
property ValorPorLitro: Double read getValorPorLitro write setValorPorLitro;
property ValorDaEntrada: Double read getValorDaEntrada; // somente leitura
property DataHora: TDateTime read getDataHora write setDataHora;
end;
implementation
constructor T_Entrada.Create(
pId: Integer;
pTanque_Id: Integer;
pLitros: Double;
pValorPorLitro: Double;
pDataHora: TDateTime
);
begin
if (pDataHora = 0) then
pDataHora := Now();
F_Id := pId;
F_Tanque_Id := pTanque_Id;
F_Litros := pLitros;
F_ValorPorLitro := pValorPorLitro;
F_DataHora := pDataHora;
Totalizar();
end;
constructor T_Entrada.Create();
begin
//
end;
procedure T_Entrada.Totalizar();
begin
try
F_ValorDaEntrada := F_Litros * F_ValorPorLitro;
except
end;
end;
// F_Id
function T_Entrada.getId(): Integer;
begin
result := F_Id;
end;
procedure T_Entrada.setId(pId: Integer);
begin
F_Id := pId;
end;
// F_Tanque_Id
function T_Entrada.getTanque_Id(): Integer;
begin
result := F_Tanque_Id;
end;
procedure T_Entrada.setTanque_Id(pTanque_Id: Integer);
begin
F_Tanque_Id := pTanque_Id;
end;
// F_Litros
function T_Entrada.getLitros(): Double;
begin
result := F_Litros;
end;
procedure T_Entrada.setLitros(pLitros: Double);
begin
F_Litros := pLitros;
Totalizar();
end;
// F_ValorPorLitro
function T_Entrada.getValorPorLitro(): Double;
begin
result := F_ValorPorLitro;
end;
procedure T_Entrada.setValorPorLitro(pValorPorLitro: Double);
begin
F_ValorPorLitro := pValorPorLitro;
Totalizar();
end;
// F_ValorDaEntrada
function T_Entrada.getValorDaEntrada(): Double;
begin
result := F_ValorDaEntrada;
end;
// F_DataHora
function T_Entrada.getDataHora(): TDateTime;
begin
result := F_DataHora;
end;
procedure T_Entrada.setDataHora(pDataHora: TDateTime);
begin
F_DataHora := pDataHora;
end;
end.
|
unit uHelloWorld;
interface
uses uEvo;
type
THelloWorld = class(TBFPrgValidatorBase)
public
procedure GetInput(Index: integer; var S: string); override;
function ValidateResult: single; override;
class function CommandSet: string; override;
function MaxSteps: integer; override;
end;
implementation
uses
Math,
SysUtils;
{ THelloWorld }
class function THelloWorld.CommandSet: string;
begin
Result := '.<>[]-+';
end;
procedure THelloWorld.GetInput(Index: integer; var S: string);
begin
S := '0';
end;
function THelloWorld.MaxSteps: integer;
begin
Result := 2000;
end;
function THelloWorld.ValidateResult: single;
begin
Result:= exp(-Random);
FProgram.Correct := 'Hello World!'#10 = Output;
end;
end.
|
////////// INSTRUMENTS //////////
var
MI : IMemoryInstrument;
Probe : IMemoryInstrument;
FreqGen : IFrequencyGeneratorInstrument;
FreqCnt : IFrequencyCounterInstrument;
Term : ITerminalInstrument;
Switch : ICrosspointSwitchInstrument;
TermChar : Char;
function MemoryInstrument : IMemoryInstrument;
begin
if MI = nil then
MI := MemoryInstrumentManager.GetMemoryInstrumentByDesignator('MI1');
Result := MI;
end;
function ProbeInstrument : IMemoryInstrument;
begin
if Probe = nil then
Probe := MemoryInstrumentManager.GetMemoryInstrumentByDesignator('PROBE1');
Result := Probe;
end;
function FreqGenInstrument : IFrequencyGeneratorInstrument;
begin
if FreqGen = nil then
FreqGen := FrequencyGeneratorInstrumentManager.GetInstrumentByDesignator('FREQGEN1');
Result := FreqGen;
end;
function FreqCntInstrument : IFrequencyCounterInstrument;
begin
if FreqCnt = nil then
FreqCnt := FrequencyCounterInstrumentManager.GetInstrumentByDesignator('FREQCNT1');
Result := FreqCnt;
end;
function TerminalInstrument : ITerminalInstrument;
begin
if Term = nil then
Term := TerminalInstrumentManager.GetInstrumentByDesignator('T1');
Result := Term;
end;
function SwitchInstrument : ICrosspointSwitchInstrument;
begin
if Switch = nil then
Switch := CrosspointSwitchInstrumentManager.GetInstrumentByDesignator('CPS1');
Result := Switch;
end;
////////// COMMON //////////
function GetBaseFolder : string;
begin
Result := ExtractFilePath(GetRunningScriptProjectName);
end;
procedure TForm1.Form1Create(Sender: TObject);
begin
MI := nil;
Probe := nil;
FreqGen := nil;
FreqCnt := nil;
Term := nil;
Switch := nil;
TermChar := #33;
end;
procedure TForm1.SignalLinkManager1Poll(Sender: TObject);
var
S : string;
InputName : widestring;
OutputName : widestring;
i : integer;
begin
Label_FreqGen_CurFreq .Caption := IntToStr (FreqGenInstrument.Frequency);
Label_FreqGen_CurTimeBase.Caption := IntToStr (FreqGenInstrument.TimeBase);
Label_FreqGen_Suspended .Caption := BoolToStr(FreqGenInstrument.Suspended, True);
Label_FreqCnt_CurTimeBase.Caption := IntToStr (FreqCntInstrument.TimeBase);
if FreqCntInstrument.ChannelA.EdgePolarity = eEdgeRising then
Label_FreqCntA_EdgePolarity.Caption := 'Rising'
else
Label_FreqCntA_EdgePolarity.Caption := 'Falling';
if FreqCntInstrument.ChannelB.EdgePolarity = eEdgeRising then
Label_FreqCntB_EdgePolarity.Caption := 'Rising'
else
Label_FreqCntB_EdgePolarity.Caption := 'Falling';
case FreqCntInstrument.ChannelA.MeasureMode of
eMeasureMode_Frequency : Label_FreqCntA_MeasureMode.Caption := 'Frequency';
eMeasureMode_Period : Label_FreqCntA_MeasureMode.Caption := 'Period';
eMeasureMode_Count : Label_FreqCntA_MeasureMode.Caption := 'Count';
end;
case FreqCntInstrument.ChannelB.MeasureMode of
eMeasureMode_Frequency : Label_FreqCntB_MeasureMode.Caption := 'Frequency';
eMeasureMode_Period : Label_FreqCntB_MeasureMode.Caption := 'Period';
eMeasureMode_Count : Label_FreqCntB_MeasureMode.Caption := 'Count';
end;
Label_FreqCntA_Gating .Caption := FloatToStr (FreqCntInstrument.ChannelA.Gating);
Label_FreqCntB_Gating .Caption := FloatToStr (FreqCntInstrument.ChannelB.Gating);
Label_FreqCntA_Suspended .Caption := BoolToStr (FreqCntInstrument.ChannelA.Suspended, True);
Label_FreqCntB_Suspended .Caption := BoolToStr (FreqCntInstrument.ChannelB.Suspended, True);
Label_FreqCntA_Measured .Caption := FloatToStr (FreqCntInstrument.ChannelA.Measured);
Label_FreqCntB_Measured .Caption := FloatToStr (FreqCntInstrument.ChannelB.Measured);
S := '';
InputName := '';
OutputName := '';
For i := 0 To SwitchInstrument.GetConnectionCount - 1 Do
Begin
If S <> '' Then
S := S + ', ';
SwitchInstrument.GetConnection(i, InputName, OutputName);
S := S + InputName + ' -> ' + OutputName;
End;
Label_CPS_Connectivity.Caption := S;
end;
////////// MEMORY UTILS //////////
procedure TestMemoryWrite(const MI : IMemoryInstrument);
var
Buffer : PByteArray;
i : integer;
begin
if MI = nil then exit;
Buffer := AllocateByteArray(26);
For i := 0 To 25 Do
SetByteArrayElement(Buffer, i, Ord('A') + i);
MI.Write(Buffer, 0, 26);
FreeByteArray(Buffer);
end;
procedure TestMemoryRead(const MI : IMemoryInstrument);
var
Buffer : PByteArray;
i : integer;
S : String;
V : Byte;
begin
if MI = nil then exit;
Buffer := AllocateByteArray(16);
MI.Read(Buffer, 0, 16);
S := 'Data:'#13#10;
For i := 0 To 15 Do
Begin
V := GetByteArrayElement(Buffer, i);
S := S + #13#10 + IntToStr(i) + ': ' + IntToStr(V);
End;
FreeByteArray(Buffer);
ShowInfo(S);
end;
procedure TestMemoryLoad(const MI : IMemoryInstrument);
begin
if MI = nil then exit;
MI.LoadFromFile(GetBaseFolder + 'NBIMain.pas', 0, 64);
end;
procedure TestMemorySave(const MI : IMemoryInstrument);
begin
if MI = nil then exit;
MI.SaveToFile(GetBaseFolder + 'mem.bin', 0, 64);
end;
////////// MEMORY INSTRUMENT //////////
procedure TForm1.InstrumentButton1Click(Sender: TObject);
begin
TestMemoryRead(MemoryInstrument);
end;
procedure TForm1.InstrumentButton2Click(Sender: TObject);
begin
TestMemoryWrite(MemoryInstrument);
end;
procedure TForm1.InstrumentButton3Click(Sender: TObject);
begin
TestMemoryLoad(MemoryInstrument);
end;
procedure TForm1.InstrumentButton4Click(Sender: TObject);
begin
TestMemorySave(MemoryInstrument);
end;
////////// WB_PROBE //////////
procedure TForm1.InstrumentButton5Click(Sender: TObject);
begin
TestMemoryRead(ProbeInstrument);
end;
procedure TForm1.InstrumentButton6Click(Sender: TObject);
begin
TestMemoryWrite(ProbeInstrument);
end;
procedure TForm1.InstrumentButton7Click(Sender: TObject);
begin
TestMemoryLoad(ProbeInstrument);
end;
procedure TForm1.InstrumentButton8Click(Sender: TObject);
begin
TestMemorySave(ProbeInstrument);
end;
////////// FREQUENCY GENERATOR //////////
procedure TForm1.InstrumentButton9Click(Sender: TObject);
begin
FreqGenInstrument.Suspended := not FreqGenInstrument.Suspended;
if FreqGenInstrument.Suspended then
InstrumentButton9.Caption := 'Resume'
else
InstrumentButton9.Caption := 'Suspend';
end;
procedure TForm1.InstrumentButton10Click(Sender: TObject);
begin
if FreqGenInstrument.TimeBase = 50000000 then
FreqGenInstrument.TimeBase := 25000000
else
FreqGenInstrument.TimeBase := 50000000;
end;
procedure TForm1.InstrumentButton11Click(Sender: TObject);
begin
if FreqGenInstrument.Frequency = 1000000 then
FreqGenInstrument.Frequency := 1
else
FreqGenInstrument.Frequency := 1000000;
end;
////////// FREQUENCY COUNTER //////////
procedure TForm1.InstrumentButton12Click(Sender: TObject);
begin
if FreqCntInstrument.TimeBase = 50000000 then
FreqCntInstrument.TimeBase := 25000000
else
FreqCntInstrument.TimeBase := 50000000;
end;
////////// TERMINAL //////////
procedure TForm1.InstrumentButton13Click(Sender: TObject);
begin
TerminalInstrument.PutChar(TermChar);
TermChar := Chr(Ord(TermChar) + 1);
end;
procedure TForm1.InstrumentButton14Click(Sender: TObject);
begin
TerminalInstrument.PutString('This line is added from the script');
end;
procedure TForm1.InstrumentButton15Click(Sender: TObject);
begin
TerminalInstrument.SaveContent(GetBaseFolder + 'terminal.txt');
end;
procedure TForm1.InstrumentButton16Click(Sender: TObject);
begin
ShowMessage(TerminalInstrument.GetContent);
end;
////////// CROSSPOINT SWITCH //////////
procedure TForm1.InstrumentButton17Click(Sender: TObject);
begin
SwitchInstrument.BeginReconnect;
if SwitchInstrument.ConnectionExists('BRIGHTNESS', 'DEBUG') then
begin
SwitchInstrument.RemoveConnection('BRIGHTNESS', 'DEBUG');
SwitchInstrument.AddConnection ('CONTRAST' , 'DEBUG');
end
else
begin
SwitchInstrument.RemoveConnection('CONTRAST' , 'DEBUG');
SwitchInstrument.AddConnection ('BRIGHTNESS', 'DEBUG');
end;
SwitchInstrument.EndReconnect;
end;
|
unit MsgComposerHandlerViewer;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, TiledPanel, MultiBMPButton, StdCtrls, VisualControls,
FramedButton, OpaquePanel, GradientBox, InternationalizerComponent,
ComCtrls;
type
TMsgComposerHandlerView =
class(TVisualControl)
Panel1: TOpaquePanel;
HeaderPanel: TPanel;
TiledPanel2: TPanel;
SendBtn: TFramedButton;
Panel2: TPanel;
TiledPanel1: TPanel;
TiledPanel3: TPanel;
DestAddr: TEdit;
Subject: TEdit;
Label1: TLabel;
Label2: TLabel;
Panel3: TPanel;
SaveBtn: TFramedButton;
CloseBtn: TFramedButton;
StatusPanel: TPanel;
InternationalizerComponent1: TInternationalizerComponent;
MsgBody: TRichEdit;
procedure TiledPanel3Resize(Sender: TObject);
procedure DestAddrChange(Sender: TObject);
procedure SendBtnClick(Sender: TObject);
procedure SaveBtnClick(Sender: TObject);
procedure CloseBtnClick(Sender: TObject);
procedure DestAddrKeyPress(Sender: TObject; var Key: Char);
procedure SubjectKeyPress(Sender: TObject; var Key: Char);
procedure FormShow(Sender: TObject);
procedure MsgBodyChange(Sender: TObject);
private
fOnMsgSend : TNotifyEvent;
fOnMsgSave : TNotifyEvent;
fOnMsgClose : TNotifyEvent;
public
procedure CheckButtons;
procedure startNewMessage;
procedure startReplyMessage;
procedure startOpenMessage;
procedure startForwardMessage;
public
property OnMsgSend : TNotifyEvent read fOnMsgSend write fOnMsgSend;
property OnMsgSave : TNotifyEvent read fOnMsgSave write fOnMsgSave;
property OnMsgClose : TNotifyEvent read fOnMsgClose write fOnMsgClose;
protected
procedure SetParent(which : TWinControl); override;
end;
implementation
uses
Literals, CoolSB;
const
clComposerStatusLine = $00223300;
CMaxCharMail = 10*1024;
{$R *.DFM}
procedure TMsgComposerHandlerView.TiledPanel3Resize(Sender: TObject);
begin
DestAddr.Width := TiledPanel3.Width - 8;
Subject.Width := TiledPanel3.Width - 8;
end;
procedure TMsgComposerHandlerView.CheckButtons;
begin
SendBtn.Enabled := (DestAddr.Text <> '') and (Subject.Text <> '');
SaveBtn.Enabled := (DestAddr.Text <> '') and (Subject.Text <> '');
end;
procedure TMsgComposerHandlerView.DestAddrChange(Sender: TObject);
begin
CheckButtons;
if StatusPanel.Color <> clComposerStatusLine
then
begin
StatusPanel.Color := clComposerStatusLine;
StatusPanel.Caption := '';
end;
end;
procedure TMsgComposerHandlerView.SendBtnClick(Sender: TObject);
begin
if Assigned(fOnMsgSend)
then fOnMsgSend(Sender);
end;
procedure TMsgComposerHandlerView.SaveBtnClick(Sender: TObject);
begin
if Assigned(fOnMsgSave)
then fOnMsgSave(Sender);
end;
procedure TMsgComposerHandlerView.CloseBtnClick(Sender: TObject);
begin
if Assigned(fOnMsgClose)
then fOnMsgClose(Sender);
end;
procedure TMsgComposerHandlerView.DestAddrKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13
then Subject.SetFocus;
end;
procedure TMsgComposerHandlerView.SubjectKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13
then MsgBody.SetFocus;
end;
procedure TMsgComposerHandlerView.FormShow(Sender: TObject);
begin
DestAddr.SetFocus;
end;
procedure TMsgComposerHandlerView.startNewMessage;
begin
DestAddr.SetFocus;
StatusPanel.Color := clComposerStatusLine;
StatusPanel.Caption := '';
end;
procedure TMsgComposerHandlerView.startReplyMessage;
begin
MsgBody.SetFocus;
MsgBody.SelStart := 0;
StatusPanel.Color := clComposerStatusLine;
StatusPanel.Caption := '';
end;
procedure TMsgComposerHandlerView.startOpenMessage;
begin
MsgBody.SetFocus;
MsgBody.SelStart := 0;
StatusPanel.Color := clComposerStatusLine;
StatusPanel.Caption := '';
end;
procedure TMsgComposerHandlerView.startForwardMessage;
begin
MsgBody.SelStart := 0;
StatusPanel.Color := clComposerStatusLine;
StatusPanel.Caption := '';
DestAddr.SetFocus;
end;
procedure TMsgComposerHandlerView.MsgBodyChange(Sender: TObject);
var
ln : integer;
s : string;
begin
StatusPanel.Color := clComposerStatusLine;
ln := MsgBody.Lines.Count;
if ln = 1
then StatusPanel.Caption := GetLiteral('Literal255')
else StatusPanel.Caption := GetFormattedLiteral('Literal256', [ln]);
if length(MsgBody.Text)>CMaxCharMail
then
begin
showmessage(GetLiteral('Literal492'));
s := MsgBody.Text;
Setlength(s, CMaxCharMail);
MsgBody.Text := s;
end;
end;
procedure TMsgComposerHandlerView.SetParent(which: TWinControl);
begin
inherited;
if InitSkinImage and (which<>nil)
then
begin
InitializeCoolSB(MsgBody.Handle);
if hThemeLib <> 0
then SetWindowTheme(MsgBody.Handle, ' ', ' ');
end;
end;
end.
|
{
Clever Internet Suite
Copyright (C) 2013 Clever Components
All Rights Reserved
www.CleverComponents.com
}
unit clInternetConnection;
interface
{$I clVer.inc}
uses
{$IFNDEF DELPHIXE2}
Windows, SysUtils, Classes, SyncObjs,
{$ELSE}
Winapi.Windows, System.SysUtils, System.Classes, System.SyncObjs, System.Types,
{$ENDIF}
clDCUtils, clWinInet, clSyncUtils, clWUtils;
type
TclInternetConnection = class;
EclTimeoutInternetError = class(EclInternetError);
TclInternetAction = class
private
FOwner: TclInternetConnection;
FInternet: HINTERNET;
FAccessor: TCriticalSection;
protected
FErrorCode: Integer;
FErrorText: string;
procedure NotifyTerminate(AInternet: HINTERNET); virtual;
procedure Execute; virtual;
procedure Terminate;
public
constructor Create(AOwner: TclInternetConnection; AInternet: HINTERNET);
destructor Destroy; override;
function FireAction(ATimeOut: Integer; AIsSilent: Boolean = False): Boolean; virtual;
property Internet: HINTERNET read FInternet;
end;
TclInternetActionClass = class of TclInternetAction;
TclActionEvent = procedure (Sender: TObject; Action: TclInternetAction) of object;
TclStatusCallbackEvent = procedure (Sender: TObject; Action: TclInternetAction;
AInternetStatus: Integer; AStatusInformation: PByte; AStatusInformationLength: Integer) of object;
TclInternetConnection = class(TComponent)
private
FActionList: TList;
FBeginEvent: THandle;
FTerminateEvent: THandle;
FWaitEvent: THandle;
FEndEvent: THandle;
FThread: THandle;
FInternetAction: TclInternetAction;
FSynchronizer: TclThreadSynchronizer;
FEventAction: TclInternetAction;
FEventInternetStatus: Integer;
FEventStatusInfo: PByte;
FEventStatusInfoLength: Integer;
FOnActionAdded: TclActionEvent;
FOnActionRemoved: TclActionEvent;
FOnBeforeFireAction: TclActionEvent;
FOnAfterFireAction: TclActionEvent;
FOnStatusCallback: TclStatusCallbackEvent;
procedure AssignWaitMembers;
procedure FireInternetAction(Action: TclInternetAction; ATimeOut: Integer);
procedure FireNotifyTerminate(AInternet: HINTERNET);
function GetAction(Index: Integer): TclInternetAction;
procedure AddAction(Action: TclInternetAction);
procedure RemoveAction(Action: TclInternetAction);
procedure SetStatusCallbackIfNeed(Action: TclInternetAction);
procedure SyncActionAdded;
procedure SyncActionRemoved;
procedure SyncAfterFireAction;
procedure SyncBeforeFireAction;
procedure SyncStatusCallback;
procedure InternalSynchronize(Method: TThreadMethod);
protected
procedure DoActionAdded(Action: TclInternetAction); dynamic;
procedure DoActionRemoved(Action: TclInternetAction); dynamic;
procedure DoBeforeFireAction(Action: TclInternetAction); dynamic;
procedure DoAfterFireAction(Action: TclInternetAction); dynamic;
procedure DoStatusCallback(Action: TclInternetAction; AInternetStatus: Integer;
AStatusInformation: PByte; AStatusInformationLength: Integer); dynamic;
procedure Stop;
function GetActionByHandle(hInet: HINTERNET): TclInternetAction;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Close;
function GetActionByClass(AClass: TclInternetActionClass): TclInternetAction;
published
property OnActionAdded: TclActionEvent read FOnActionAdded write FOnActionAdded;
property OnActionRemoved: TclActionEvent read FOnActionRemoved write FOnActionRemoved;
property OnAfterFireAction: TclActionEvent read FOnAfterFireAction write FOnAfterFireAction;
property OnBeforeFireAction: TclActionEvent read FOnBeforeFireAction write FOnBeforeFireAction;
property OnStatusCallback: TclStatusCallbackEvent
read FOnStatusCallback write FOnStatusCallback;
end;
TclInternetResourceAction = class(TclInternetAction)
protected
FhResource: HINTERNET;
procedure NotifyTerminate(AInternet: HINTERNET); override;
procedure Execute; override;
public
destructor Destroy; override;
procedure CloseResource;
property hResource: HINTERNET read FhResource;
end;
TclInternetOpenAction = class(TclInternetResourceAction)
private
FlpszAgent: string;
FdwAccessType: DWORD;
FlpszProxy: string;
FlpszProxyBypass: string;
FdwFlags: DWORD;
protected
procedure Execute; override;
public
constructor Create(AOwner: TclInternetConnection; lpszAgent: string; dwAccessType: DWORD;
lpszProxy, lpszProxyBypass: string; dwFlags: DWORD);
end;
TclOpenURLAction = class(TclInternetResourceAction)
private
FlpszUrl: string;
FlpszHeaders: string;
FdwFlags: DWORD;
protected
procedure Execute; override;
public
constructor Create(AOwner: TclInternetConnection; hInet: HINTERNET; lpszUrl,
lpszHeaders: string; dwFlags: DWORD);
end;
TclConnectAction = class(TclInternetResourceAction)
private
FlpszServerName: string;
FnServerPort: INTERNET_PORT;
FlpszUsername: string;
FlpszPassword: string;
FdwService: DWORD;
FdwFlags: DWORD;
protected
procedure Execute; override;
public
constructor Create(AOwner: TclInternetConnection; hInet: HINTERNET; lpszServerName: string;
nServerPort: INTERNET_PORT; lpszUsername, lpszPassword: string; dwService, dwFlags: DWORD);
end;
TclFtpFindFirstFileAction = class(TclInternetResourceAction)
private
FhConnect: HINTERNET;
FlpFindFileData: TWin32FindData;
FlpszSearchFile: string;
FdwFlags: DWORD;
protected
procedure Execute; override;
public
constructor Create(AOwner: TclInternetConnection; hInet, hConnect: HINTERNET;
lpszSearchFile: string; dwFlags: DWORD);
property lpFindFileData: TWin32FindData read FlpFindFileData;
end;
TclFtpGetFileSizeAction = class(TclInternetAction)
private
FhFile: HINTERNET;
FFileSize: Int64;
protected
procedure Execute; override;
public
constructor Create(AOwner: TclInternetConnection; hInet, hFile: HINTERNET);
property FileSize: Int64 read FFileSize;
end;
TclFtpOpenFileAction = class(TclInternetResourceAction)
private
FhConnect: HINTERNET;
FlpszFileName: string;
FdwAccess: DWORD;
FdwFlags: DWORD;
protected
procedure Execute; override;
public
constructor Create(AOwner: TclInternetConnection; hInet, hConnect: HINTERNET; lpszFileName: string;
dwAccess: DWORD; dwFlags: DWORD);
end;
TclFtpCreateDirectoryAction = class(TclInternetAction)
private
FhConnect: HINTERNET;
FlpszDirectory: string;
protected
procedure Execute; override;
public
constructor Create(AOwner: TclInternetConnection; hInet, hConnect: HINTERNET; lpszDirectory: string);
end;
TclHttpOpenRequestAction = class(TclInternetResourceAction)
private
FhConnect: HINTERNET;
FlpszVerb: string;
FlpszObjectName: string;
FlpszVersion: string;
FlpszReferrer: string;
FlplpszAcceptTypes: PLPSTR;
FdwFlags: DWORD;
protected
procedure Execute; override;
public
constructor Create(AOwner: TclInternetConnection;
hInet, hConnect: HINTERNET; lpszVerb, lpszObjectName, lpszVersion, lpszReferrer: string;
lplpszAcceptTypes: PLPSTR; dwFlags: DWORD);
end;
TclHttpSendRequestAction = class(TclInternetAction)
private
FhRequest: HINTERNET;
FlpszHeaders: string;
FlpOptional: Pointer;
FdwOptionalLength: DWORD;
protected
procedure Execute; override;
public
constructor Create(AOwner: TclInternetConnection; hInet, hRequest: HINTERNET;
lpszHeaders: string; lpOptional: Pointer;
dwOptionalLength: DWORD);
end;
TclHttpSendRequestExAction = class(TclInternetAction)
private
FhRequest: HINTERNET;
FlpBuffersIn: PInternetBuffers;
FlpBuffersOut: PInternetBuffers;
FdwFlags: DWORD;
protected
procedure Execute; override;
public
constructor Create(AOwner: TclInternetConnection; hInet: HINTERNET; hRequest: HINTERNET;
lpBuffersIn: PInternetBuffers; lpBuffersOut: PInternetBuffers;
dwFlags: DWORD);
end;
TclHttpEndRequestAction = class(TclInternetAction)
private
FhRequest: HINTERNET;
FlpBuffersOut: PInternetBuffers;
FdwFlags: DWORD;
protected
procedure Execute; override;
public
constructor Create(AOwner: TclInternetConnection; hInet, hRequest: HINTERNET;
lpBuffersOut: PInternetBuffers; dwFlags: DWORD);
end;
TclInternetReadFileAction = class(TclInternetAction)
private
FhFile: HINTERNET;
FlpBuffer: Pointer;
FdwNumberOfBytesToRead: DWORD;
FlpdwNumberOfBytesRead: DWORD;
protected
procedure Execute; override;
public
constructor Create(AOwner: TclInternetConnection; hInet, hFile: HINTERNET; lpBuffer: Pointer);
property dwNumberOfBytesToRead: DWORD read FdwNumberOfBytesToRead write FdwNumberOfBytesToRead;
property lpdwNumberOfBytesRead: DWORD read FlpdwNumberOfBytesRead;
end;
TclInternetWriteFileAction = class(TclInternetAction)
private
FhFile: HINTERNET;
FlpBuffer: Pointer;
FdwNumberOfBytesToWrite: DWORD;
FlpdwNumberOfBytesWritten: DWORD;
protected
procedure Execute; override;
public
constructor Create(AOwner: TclInternetConnection; hInet, hFile: HINTERNET);
property lpBuffer: Pointer read FlpBuffer write FlpBuffer;
property dwNumberOfBytesToWrite: DWORD read FdwNumberOfBytesToWrite write FdwNumberOfBytesToWrite;
property lpdwNumberOfBytesWritten: DWORD read FlpdwNumberOfBytesWritten;
end;
implementation
uses
clUtils;
{ TclOpenURLAction }
constructor TclOpenURLAction.Create(AOwner: TclInternetConnection; hInet: HINTERNET; lpszUrl,
lpszHeaders: string; dwFlags: DWORD);
begin
inherited Create(AOwner, hInet);
FlpszUrl := lpszUrl;
FlpszHeaders := lpszHeaders;
FdwFlags := dwFlags;
end;
procedure TclOpenURLAction.Execute;
var
Headers: PclChar;
begin
FhResource := nil;
Headers := nil;
if (FlpszHeaders <> '') then
begin
Headers := PclChar(GetTclString(FlpszHeaders));
end;
FhResource := InternetOpenUrl(Internet, PclChar(GetTclString(FlpszUrl)), Headers, Length(FlpszHeaders), FdwFlags, DWORD(FOwner));
inherited Execute();
end;
{ TclInternetConnection }
function WaitProc(Instance: TclInternetConnection): Integer;
var
arr: array[0..1] of THandle;
waitevent: THandle;
begin
arr[0] := Instance.FBeginEvent;
arr[1] := Instance.FEndEvent;
waitevent := Instance.FWaitEvent;
repeat
if (WaitForMultipleObjects(2, @arr, False, INFINITE) = WAIT_OBJECT_0) then
begin
if (Instance.FInternetAction <> nil) then
begin
try
Instance.FInternetAction.Execute();
except
end;
SetEvent(waitevent);
end;
end else
begin
Break;
end;
until False;
Result := 0;
end;
procedure TclInternetConnection.AssignWaitMembers;
var
id: DWORD;
begin
if (FBeginEvent = 0) then
begin
FBeginEvent := CreateEvent(nil, False, False, nil);
FTerminateEvent := CreateEvent(nil, False, False, nil);
FWaitEvent := CreateEvent(nil, False, False, nil);
FEndEvent := CreateEvent(nil, False, False, nil);
FThread := BeginThread(nil, 0, @WaitProc, Pointer(Self), 0, id);
end;
end;
procedure TclInternetConnection.Stop();
begin
SetEvent(FTerminateEvent);
end;
procedure TclInternetConnection.Close;
procedure DoneItem(var AItem: THandle);
begin
if (AItem <> 0) then
begin
CloseHandle(AItem);
AItem := 0;
end;
end;
begin
Stop();
while ((FActionList <> nil) and (FActionList.Count > 0)) do
begin
GetAction(0).Free();
end;
SetEvent(FEndEvent);
WaitForSingleObject(FThread, INFINITE);
DoneItem(FThread);
DoneItem(FTerminateEvent);
DoneItem(FBeginEvent);
DoneItem(FWaitEvent);
DoneItem(FEndEvent);
end;
constructor TclInternetConnection.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FSynchronizer := TclThreadSynchronizer.Create();
FActionList := TList.Create();
FInternetAction := nil;
end;
destructor TclInternetConnection.Destroy;
begin
Close();
FActionList.Free();
FActionList := nil;
FSynchronizer.Free();
inherited Destroy();
end;
procedure TclInternetConnection.FireInternetAction(Action: TclInternetAction; ATimeOut: Integer);
var
arr: array[0..1] of THandle;
begin
if (csDestroying in ComponentState) then Exit;
FInternetAction := Action;
try
DoBeforeFireAction(Action);
AssignWaitMembers();
SetEvent(FBeginEvent);
arr[0] := FWaitEvent;
arr[1] := FTerminateEvent;
case WaitForMultipleObjects(2, @arr, False, DWORD(ATimeOut)) of
WAIT_OBJECT_0 + 1:
begin
Action.Terminate();
WaitForSingleObject(FWaitEvent, INFINITE);
end;
WAIT_TIMEOUT:
begin
Action.Terminate();
WaitForSingleObject(FWaitEvent, INFINITE);
raise EclTimeoutInternetError.Create(cRequestTimeOut, WAIT_TIMEOUT);
end;
else
begin
DoAfterFireAction(Action);
SetStatusCallbackIfNeed(Action);
end;
end;
finally
FInternetAction := nil;
end;
end;
procedure TclInternetConnection.FireNotifyTerminate(AInternet: HINTERNET);
var
i: Integer;
Item: TclInternetAction;
begin
if (csDestroying in ComponentState) then Exit;
for i := 0 to FActionList.Count - 1 do
begin
Item := GetAction(i);
if (Item <> FInternetAction) then
begin
Item.NotifyTerminate(AInternet);
end;
end;
end;
function TclInternetConnection.GetAction(Index: Integer): TclInternetAction;
begin
Result := TclInternetAction(FActionList[Index]);
end;
function TclInternetConnection.GetActionByClass(AClass: TclInternetActionClass): TclInternetAction;
var
i: Integer;
begin
if not (csDestroying in ComponentState) then
begin
for i := 0 to FActionList.Count - 1 do
begin
Result := GetAction(i);
if Result.InheritsFrom(AClass) then Exit;
end;
end;
Result := nil;
end;
procedure StatusCallbackHandler(hInet: HINTERNET; dwContext: DWORD;
AInternetStatus: DWORD; AStatusInformation: PByte; AStatusInformationLength: DWORD); stdcall;
var
inst: TclInternetConnection;
begin
inst := TclInternetConnection(dwContext);
inst.DoStatusCallback(inst.GetActionByHandle(hInet),
AInternetStatus, AStatusInformation, AStatusInformationLength);
end;
procedure TclInternetConnection.SetStatusCallbackIfNeed(Action: TclInternetAction);
begin
if (csDestroying in ComponentState) then Exit;
if (Action is TclInternetOpenAction)
and Assigned(OnStatusCallback) then
begin
InternetSetStatusCallback(TclInternetOpenAction(Action).hResource, @StatusCallbackHandler);
end;
end;
procedure TclInternetConnection.AddAction(Action: TclInternetAction);
begin
if (FActionList <> nil) then
begin
FActionList.Add(Action);
DoActionAdded(Action);
end;
end;
procedure TclInternetConnection.RemoveAction(Action: TclInternetAction);
begin
if (FActionList <> nil) then
begin
FActionList.Remove(Action);
DoActionRemoved(Action);
end;
end;
procedure TclInternetConnection.DoActionAdded(Action: TclInternetAction);
begin
if Assigned(OnActionAdded) then
begin
FEventAction := Action;
InternalSynchronize(SyncActionAdded);
end;
end;
procedure TclInternetConnection.SyncActionAdded;
begin
OnActionAdded(Self, FEventAction);
end;
procedure TclInternetConnection.DoActionRemoved(Action: TclInternetAction);
begin
if Assigned(OnActionRemoved) then
begin
FEventAction := Action;
InternalSynchronize(SyncActionRemoved);
end;
end;
procedure TclInternetConnection.SyncActionRemoved;
begin
OnActionRemoved(Self, FEventAction);
end;
procedure TclInternetConnection.DoAfterFireAction(Action: TclInternetAction);
begin
if Assigned(OnAfterFireAction) then
begin
FEventAction := Action;
InternalSynchronize(SyncAfterFireAction);
end;
end;
procedure TclInternetConnection.SyncAfterFireAction;
begin
OnAfterFireAction(Self, FEventAction);
end;
procedure TclInternetConnection.DoBeforeFireAction(Action: TclInternetAction);
begin
if Assigned(OnBeforeFireAction) then
begin
FEventAction := Action;
InternalSynchronize(SyncBeforeFireAction);
end;
end;
procedure TclInternetConnection.SyncBeforeFireAction;
begin
OnBeforeFireAction(Self, FEventAction);
end;
procedure TclInternetConnection.DoStatusCallback(
Action: TclInternetAction; AInternetStatus: Integer;
AStatusInformation: PByte; AStatusInformationLength: Integer);
begin
if Assigned(OnStatusCallback) then
begin
FEventAction := Action;
FEventInternetStatus := AInternetStatus;
FEventStatusInfo := AStatusInformation;
FEventStatusInfoLength := AStatusInformationLength;
InternalSynchronize(SyncStatusCallback);
end;
end;
procedure TclInternetConnection.SyncStatusCallback;
begin
OnStatusCallback(Self, FEventAction, FEventInternetStatus,
FEventStatusInfo, FEventStatusInfoLength);
end;
function TclInternetConnection.GetActionByHandle(hInet: HINTERNET): TclInternetAction;
var
i: Integer;
begin
if not (csDestroying in ComponentState) then
begin
for i := 0 to FActionList.Count - 1 do
begin
Result := GetAction(i);
if (Result is TclInternetResourceAction)
and ((Result as TclInternetResourceAction).hResource = hInet) then Exit;
end;
end;
Result := nil;
end;
procedure TclInternetConnection.InternalSynchronize(Method: TThreadMethod);
begin
FSynchronizer.Synchronize(Method);
end;
{ TclInternetAction }
constructor TclInternetAction.Create(AOwner: TclInternetConnection; AInternet: HINTERNET);
begin
inherited Create();
FAccessor := TCriticalSection.Create();
FInternet := AInternet;
FOwner := AOwner;
if (FOwner <> nil) then
begin
FOwner.AddAction(Self);
end;
end;
destructor TclInternetAction.Destroy;
begin
if (FOwner <> nil) then
begin
FOwner.RemoveAction(Self);
end;
FAccessor.Free();
inherited Destroy();
end;
procedure TclInternetAction.Execute;
begin
FErrorCode := clGetLastError();
FErrorText := EclInternetError.GetLastErrorText(FErrorCode);
end;
function TclInternetAction.FireAction(ATimeOut: Integer; AIsSilent: Boolean): Boolean;
begin
FErrorCode := 0;
FErrorText := '';
Assert(FOwner <> nil);
FOwner.FireInternetAction(Self, ATimeOut);
Result := (FErrorText = '');
if (not Result) and (not AIsSilent) then
begin
raise EclInternetError.Create(FErrorText, FErrorCode);
end;
end;
procedure TclInternetAction.NotifyTerminate(AInternet: HINTERNET);
begin
end;
procedure TclInternetAction.Terminate;
begin
FAccessor.Enter();
try
if (FInternet <> nil) then
begin
if (FOwner <> nil) then
begin
FOwner.FireNotifyTerminate(FInternet);
end;
InternetCloseHandle(FInternet);
FInternet := nil;
end;
finally
FAccessor.Leave();
end;
end;
{ TclConnectAction }
constructor TclConnectAction.Create(AOwner: TclInternetConnection; hInet: HINTERNET;
lpszServerName: string; nServerPort: INTERNET_PORT;
lpszUsername, lpszPassword: string; dwService, dwFlags: DWORD);
begin
inherited Create(AOwner, hInet);
FlpszServerName := lpszServerName;
FnServerPort := nServerPort;
FlpszUsername := lpszUsername;
FlpszPassword := lpszPassword;
FdwService := dwService;
FdwFlags := dwFlags;
end;
procedure TclConnectAction.Execute;
var
Username, Password: PclChar;
begin
FhResource := nil;
Username := nil;
Password := nil;
if (FlpszUsername <> '') then
begin
Username := PclChar(GetTclString(FlpszUsername));
end;
if (FlpszPassword <> '') then
begin
Password := PclChar(GetTclString(FlpszPassword));
end;
FhResource := InternetConnect(Internet, PclChar(GetTclString(FlpszServerName)), FnServerPort, Username,
Password, FdwService, FdwFlags, DWORD(FOwner));
inherited Execute();
end;
{ TclFtpFindFirstFileAction }
constructor TclFtpFindFirstFileAction.Create(AOwner: TclInternetConnection; hInet, hConnect: HINTERNET;
lpszSearchFile: string; dwFlags: DWORD);
begin
inherited Create(AOwner, hInet);
FhConnect := hConnect;
FlpszSearchFile := lpszSearchFile;
FdwFlags := dwFlags;
end;
procedure TclFtpFindFirstFileAction.Execute;
begin
FhResource := nil;
FhResource := FtpFindFirstFile(FhConnect, PChar(FlpszSearchFile), FlpFindFileData, FdwFlags, DWORD(FOwner));
inherited Execute();
end;
{ TclInternetResourceAction }
procedure TclInternetResourceAction.CloseResource;
begin
if (FhResource <> nil) then
begin
InternetCloseHandle(FhResource);
FhResource := nil;
end;
end;
destructor TclInternetResourceAction.Destroy;
begin
CloseResource();
inherited Destroy;
end;
procedure TclInternetResourceAction.Execute;
begin
if FhResource = nil then
begin
inherited Execute();
end;
end;
procedure TclInternetResourceAction.NotifyTerminate(AInternet: HINTERNET);
begin
if (FhResource = AInternet) then
begin
FhResource := nil;
end;
end;
{ TclInternetOpenAction }
constructor TclInternetOpenAction.Create(AOwner: TclInternetConnection; lpszAgent: string;
dwAccessType: DWORD; lpszProxy, lpszProxyBypass: string; dwFlags: DWORD);
begin
inherited Create(AOwner, nil);
FlpszAgent := lpszAgent;
FdwAccessType := dwAccessType;
FlpszProxy := Trim(lpszProxy);
FlpszProxyBypass := Trim(lpszProxyBypass);
FdwFlags := dwFlags;
end;
procedure TclInternetOpenAction.Execute;
var
Proxy, ProxyBypass: PclChar;
begin
FhResource := nil;
Proxy := nil;
ProxyBypass := nil;
if (FlpszProxy <> '') then
begin
Proxy := PclChar(GetTclString(FlpszProxy));
end;
if (FlpszProxyBypass <> '') then
begin
ProxyBypass := PclChar(GetTclString(FlpszProxyBypass));
end;
FhResource := InternetOpen(PclChar(GetTclString(FlpszAgent)), FdwAccessType, Proxy, ProxyBypass, FdwFlags);
inherited Execute();
end;
{ TclFtpOpenFileAction }
constructor TclFtpOpenFileAction.Create(AOwner: TclInternetConnection;
hInet, hConnect: HINTERNET; lpszFileName: string; dwAccess, dwFlags: DWORD);
begin
inherited Create(AOwner, hInet);
FhConnect := hConnect;
FlpszFileName := lpszFileName;
FdwAccess := dwAccess;
FdwFlags := dwFlags;
end;
procedure TclFtpOpenFileAction.Execute;
begin
FhResource := nil;
FhResource := FtpOpenFile(FhConnect, PclChar(GetTclString(FlpszFileName)), FdwAccess, FdwFlags, DWORD(FOwner));
inherited Execute();
end;
{ TclHttpOpenRequestAction }
constructor TclHttpOpenRequestAction.Create(AOwner: TclInternetConnection;
hInet, hConnect: HINTERNET; lpszVerb, lpszObjectName, lpszVersion, lpszReferrer: string;
lplpszAcceptTypes: PLPSTR; dwFlags: DWORD);
begin
inherited Create(AOwner, hInet);
FhConnect := hConnect;
FlpszVerb := lpszVerb;
FlpszObjectName := lpszObjectName;
FlpszVersion := lpszVersion;
FlpszReferrer := lpszReferrer;
FlplpszAcceptTypes := lplpszAcceptTypes;
FdwFlags := dwFlags;
end;
procedure TclHttpOpenRequestAction.Execute;
var
Verb, Version, Referrer: PclChar;
begin
FhResource := nil;
Verb := nil;
Version := nil;
Referrer := nil;
if (FlpszVerb <> '') then
begin
Verb := PclChar(GetTclString(FlpszVerb));
end;
if (FlpszVersion <> '') then
begin
Version := PclChar(GetTclString(FlpszVersion));
end;
if (FlpszReferrer <> '') then
begin
Referrer := PclChar(GetTclString(FlpszReferrer));
end;
FhResource := HttpOpenRequest(FhConnect, Verb, PclChar(GetTclString(FlpszObjectName)), Version,
Referrer, FlplpszAcceptTypes, FdwFlags, DWORD(FOwner));
inherited Execute();
end;
{ TclHttpSendRequestExAction }
constructor TclHttpSendRequestExAction.Create(AOwner: TclInternetConnection;
hInet, hRequest: HINTERNET;
lpBuffersIn, lpBuffersOut: PInternetBuffers; dwFlags: DWORD);
begin
inherited Create(AOwner, hInet);
FhRequest := hRequest;
FlpBuffersIn := lpBuffersIn;
FlpBuffersOut := lpBuffersOut;
FdwFlags := dwFlags;
end;
procedure TclHttpSendRequestExAction.Execute;
begin
if not HttpSendRequestEx(FhRequest, FlpBuffersIn, FlpBuffersOut, FdwFlags, DWORD(FOwner)) then
begin
inherited Execute();
end;
end;
{ TclHttpEndRequestAction }
constructor TclHttpEndRequestAction.Create(AOwner: TclInternetConnection;
hInet, hRequest: HINTERNET; lpBuffersOut: PInternetBuffers; dwFlags: DWORD);
begin
inherited Create(AOwner, hInet);
FhRequest := hRequest;
FlpBuffersOut := lpBuffersOut;
FdwFlags := dwFlags;
end;
procedure TclHttpEndRequestAction.Execute;
begin
if not HttpEndRequest(FhRequest, FlpBuffersOut, FdwFlags, DWORD(FOwner)) then
begin
inherited Execute();
end;
end;
{ TclHttpSendRequestAction }
constructor TclHttpSendRequestAction.Create(AOwner: TclInternetConnection;
hInet, hRequest: HINTERNET; lpszHeaders: string;
lpOptional: Pointer; dwOptionalLength: DWORD);
begin
inherited Create(AOwner, hInet);
FhRequest := hRequest;
FlpszHeaders := lpszHeaders;
FlpOptional := lpOptional;
FdwOptionalLength := dwOptionalLength;
end;
procedure TclHttpSendRequestAction.Execute;
var
Headers: PclChar;
begin
Headers := nil;
if (FlpszHeaders <> '') then
begin
Headers := PclChar(GetTclString(FlpszHeaders));
end;
if not HttpSendRequest(FhRequest, Headers, Length(FlpszHeaders), FlpOptional, FdwOptionalLength) then
begin
inherited Execute();
end;
end;
{ TclInternetReadFileAction }
constructor TclInternetReadFileAction.Create(AOwner: TclInternetConnection;
hInet, hFile: HINTERNET; lpBuffer: Pointer);
begin
inherited Create(AOwner, hInet);
FhFile := hFile;
FlpBuffer := lpBuffer;
end;
procedure TclInternetReadFileAction.Execute;
begin
if not InternetReadFile(FhFile, FlpBuffer, FdwNumberOfBytesToRead, FlpdwNumberOfBytesRead) then
begin
inherited Execute();
end;
end;
{ TclInternetWriteFileAction }
constructor TclInternetWriteFileAction.Create(AOwner: TclInternetConnection;
hInet, hFile: HINTERNET);
begin
inherited Create(AOwner, hInet);
FhFile := hFile;
end;
procedure TclInternetWriteFileAction.Execute;
begin
if (not InternetWriteFile(FhFile, FlpBuffer, FdwNumberOfBytesToWrite, FlpdwNumberOfBytesWritten))
or (FdwNumberOfBytesToWrite <> FlpdwNumberOfBytesWritten) then
begin
inherited Execute();
end;
end;
{ TclFtpCreateDirectoryAction }
constructor TclFtpCreateDirectoryAction.Create(AOwner: TclInternetConnection;
hInet, hConnect: HINTERNET; lpszDirectory: string);
begin
inherited Create(AOwner, hInet);
FhConnect := hConnect;
FlpszDirectory := lpszDirectory;
end;
procedure TclFtpCreateDirectoryAction.Execute;
begin
if not (FtpCreateDirectory(FhConnect, PclChar(GetTclString(FlpszDirectory)))) then
begin
inherited Execute();
end;
end;
{ TclFtpGetFileSizeAction }
constructor TclFtpGetFileSizeAction.Create(AOwner: TclInternetConnection;
hInet, hFile: HINTERNET);
begin
inherited Create(AOwner, hInet);
FhFile := hFile;
end;
procedure TclFtpGetFileSizeAction.Execute;
var
p: DWORD;
pp: Int64;
begin
p := 0;
FFileSize := FtpGetFileSize(FhFile, @p);
pp := p;
FFileSize := FFileSize or (pp shl 32);
end;
end.
|
unit CacheServerReportForm;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls, ExtCtrls, StdCtrls, SyncObjs;
type
TCacheServerReport = class(TForm)
Panel1: TPanel;
Image1: TImage;
PageControl1: TPageControl;
General: TTabSheet;
Label1: TLabel;
GlobalPath: TEdit;
Browse: TButton;
Initialize: TButton;
LocalPath: TEdit;
Button1: TButton;
Label2: TLabel;
Label3: TLabel;
Port: TEdit;
procedure InitializeClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
end;
var
CacheServerReport: TCacheServerReport;
implementation
uses
Registry, CacheRegistryKeys, FileCtrl, ShellAPI, RDOInterfaces,
WinSockRDOConnectionsServer, RDORootServer, CacheCommon;
{$R *.DFM}
type
TWorldRegistyServer =
class(TRDORootServer)
private
fCachePath : WideString;
published
function RegisterWorld(const WorldName, ServerName : WideString; ServerPort : integer) : variant;
property CachePath : WideString read fCachePath;
end;
// TWorldRegistyServer
function TWorldRegistyServer.RegisterWorld(const WorldName, ServerName : WideString; ServerPort : integer) : variant;
var
Reg : TRegistry;
aux : string;
begin
try
Reg := TRegistry.Create;
try
aux := WorldsKey + WorldName;
Reg.RootKey := HKEY_LOCAL_MACHINE;
Reg.CreateKey(aux);
if Reg.OpenKey(aux, false)
then
begin
Reg.WriteString('Server', ServerName);
Reg.WriteInteger('Port', ServerPort);
Reg.RegistryConnect('');
result := true;
end
else result := false;
finally
Reg.Free;
end;
except
result := false;
end;
end;
// RemoveFullPath
function RemoveFullPath(const Path : string) : boolean;
var
FileOp : TSHFileOpStruct;
tmp : array[0..MAX_PATH] of char;
begin
fillchar(tmp, sizeof(tmp), 0);
strpcopy(tmp, Path);
// If Path is a folder the last '\' must be removed.
if Path[length(Path)] = '\'
then tmp[length(Path)-1] := #0;
with FileOp do
begin
wFunc := FO_DELETE;
Wnd := 0;
pFrom := tmp;
pTo := nil;
fFlags := FOF_NOCONFIRMATION or FOF_SILENT;
hNameMappings := nil;
end;
result := SHFileOperation( FileOp ) = 0;
end;
var
CachePath : string = '';
CacheServer : TWorldRegistyServer = nil;
// TCacheServerReport
procedure TCacheServerReport.InitializeClick(Sender: TObject);
var
Reg : TRegistry;
ServerConn : IRDOConnectionsServer;
begin
try
ServerConn := TWinSockRDOConnectionsServer.Create(StrToInt(Port.Text), 1);
CacheServer := TWorldRegistyServer.Create(ServerConn, WSObjectCacherName);
CacheServer.fCachePath := GlobalPath.Text;
if (System.pos('cache', lowercase(LocalPath.Text)) <> 0) and DirectoryExists(LocalPath.Text)
then RemoveFullPath(LocalPath.Text);
ForceDirectories(LocalPath.Text);
// >> Sharing goes here!
Initialize.Enabled := false;
// Save the path in the registry
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_LOCAL_MACHINE;
if Reg.OpenKey( CacheKey, true )
then
begin
// >>
Reg.WriteString( 'GlobalPath', GlobalPath.Text );
Reg.WriteString( 'RootPath', LocalPath.Text );
Reg.RegistryConnect( '' );
end
finally
Reg.Free;
end;
except
Application.MessageBox( 'Cannot initialize the server', 'Model Server', MB_ICONERROR or MB_OK );
end;
Application.Minimize;
end;
procedure TCacheServerReport.FormCreate(Sender: TObject);
var
Reg : TRegistry;
begin
try
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_LOCAL_MACHINE;
if Reg.OpenKey( CacheKey, false )
then
begin
LocalPath.Text := Reg.ReadString( 'RootPath' );
GlobalPath.Text := Reg.ReadString( 'GlobalPath' );
end;
finally
Reg.Free;
end;
except
end;
end;
end.
|
unit UAccessADGroup;
interface
uses Classes, UAccessBase, UAccessContainer;
type
TSAVAccessADGroup = class(TSAVAccessContainer)
private
FPriority: Integer;
procedure SetPriority(const Value: Integer);
protected
public
property Priority: Integer read FPriority write SetPriority;
constructor Create; overload;
constructor Create(aBase: TSAVAccessBase; const aCaption, aSID, aPriority,
aDescription:
string);
overload;
procedure Save; override;
function Load(aSID: string = ''): Boolean; override;
procedure Open(aBase: TSAVAccessBase; const aCaption, aSID: string; const
aDescription: string = ''; const aParam: string = ''; const aVersion:
TVersionString = ''); override;
procedure GetUsersSID(List: TStrings; const aDomain: string; const aSID:
Boolean = False);
overload;
procedure Clear; override;
procedure UpdateVersion; override;
end;
implementation
uses SysUtils, VKDBFDataSet, VKDBFNTX, VKDBFIndex, VKDBFSorters,
UAccessConstant, SAVLib_DBF, IniFiles, MsAD;
{ TSAVAccessGroup }
procedure TSAVAccessADGroup.Clear;
begin
inherited;
FPriority := 0;
end;
constructor TSAVAccessADGroup.Create(aBase: TSAVAccessBase; const aCaption,
aSID, aPriority, aDescription: string);
begin
Create;
Open(aBase, aCaption, aSID, aDescription, aPriority);
Save;
end;
constructor TSAVAccessADGroup.Create;
begin
inherited Create;
ContainerType := 'A';
end;
procedure TSAVAccessADGroup.GetUsersSID(List: TStrings; const aDomain: string;
const aSID: Boolean =
False);
var
i: Integer;
adns: string;
begin
List.Clear;
adns := GetDNSDomainName(aDomain);
GetAllGroupUsers(Caption, GetDomainController(aDomain), List);
if aSID then
for i := 0 to List.Count - 1 do
List[i] := List[i] + '=' + GetSID(List[i], adns);
end;
function TSAVAccessADGroup.Load(aSID: string): Boolean;
var
table1: TVKDBFNTX;
s: string;
begin
if aSID = '' then
s := SID
else
s := aSID;
table1 := TVKDBFNTX.Create(nil);
InitOpenDBF(table1, IncludeTrailingPathDelimiter(Bases.JournalsDir)
+ csTableADGroups, 66);
table1.Open;
Result := table1.Locate(csFieldSID, s, []);
if Result then
begin
SID := s;
Caption := table1.fieldByName(csFieldCaption).AsString;
Description := table1.FieldByName(csFieldDescription).AsString;
ID := table1.FieldByName(csFieldID).AsInteger;
Priority := table1.FieldByName(csFieldPrority).AsInteger;
WorkDir := IncludeTrailingPathDelimiter(Bases.ADGroupsDir) + SID;
ReadVersion;
end;
table1.Close;
FreeAndNil(table1);
end;
procedure TSAVAccessADGroup.Open(aBase: TSAVAccessBase; const aCaption, aSID,
aDescription, aParam: string; const aVersion: TVersionString);
begin
WorkDir := IncludeTrailingPathDelimiter(aBase.ADGroupsDir) + aSID;
inherited Open(aBase, aCaption, aSID, aDescription, aParam, aVersion);
FPriority := StrToIntDef(aParam, 0);
end;
procedure TSAVAccessADGroup.Save;
var
table1: TVKDBFNTX;
j: Integer;
begin
inherited;
table1 := TVKDBFNTX.Create(nil);
SAVLib_DBF.InitOpenDBF(table1, Bases.JournalsPath + csTableADGroups, 66);
with table1.Indexes.Add as TVKNTXIndex do
NTXFileName := Bases.JournalsPath + csIndexADGroupName;
with table1.Indexes.Add as TVKNTXIndex do
NTXFileName := Bases.JournalsPath + csIndexADGroupVersion;
table1.Open;
if table1.FLock then
begin
if not (table1.Locate(csFieldSID, SID, [])) then
begin
table1.Append;
j := table1.GetNextAutoInc(csFieldID);
if SID = '' then
SID := IntToStr(j);
table1.FieldByName(csFieldSID).AsString := SID;
table1.FieldByName(csFieldID).AsInteger := j;
end
else
table1.Edit;
table1.FieldByName(csFieldPrority).AsInteger := FPriority;
table1.FieldByName(csFieldCaption).AsString := Caption;
table1.FieldByName(csFieldDescription).AsString := Description;
table1.FieldByName(csFieldVersion).AsString := GetNewVersion;
Version := table1.FieldByName(csFieldVersion).AsString;
ID := table1.FieldByName(csFieldID).AsInteger;
table1.Post;
table1.UnLock;
end
else
raise Exception.Create(csFLockError + Table1.DBFFileName);
table1.Close;
FreeAndNil(table1);
WorkDir := IncludeTrailingPathDelimiter(Bases.ADGroupsDir) + SID;
ForceDirectories(WorkDir);
WriteVersion;
end;
procedure TSAVAccessADGroup.SetPriority(const Value: Integer);
begin
FPriority := Value;
end;
procedure TSAVAccessADGroup.UpdateVersion;
var
table1: TVKDBFNTX;
begin
inherited;
table1 := TVKDBFNTX.Create(nil);
InitOpenDBF(table1, Bases.JournalsPath + csTableADGroups, 66);
with table1.Indexes.Add as TVKNTXIndex do
NTXFileName := Bases.JournalsPath + csIndexADGroupVersion;
table1.Open;
if table1.Locate(csFieldSID, SID, []) then
begin
if table1.FLock then
begin
table1.Edit;
table1.FieldByName(csFieldVersion).AsString := Version;
table1.Post;
table1.UnLock;
end
else
raise Exception.Create(csFLockError + Table1.DBFFileName);
end;
table1.Close;
FreeAndNil(table1);
end;
end.
|
unit xn.Items;
interface
uses System.Generics.Collections, System.Generics.Defaults;
type
IxnItems<T> = interface
['{74A8B69A-6A88-4CCF-9B8B-15DDDD05EB6F}']
function GetEnumerator: TEnumerator<T>;
function Count: integer;
function ItemGet(aIndex: integer): T;
property Items[aIndex: integer]: T read ItemGet; default;
end;
TxnItems<T> = class(TInterfacedObject, IxnItems<T>)
strict protected
fItems: TList<T>;
public
constructor Create; virtual;
destructor Destroy; override;
function GetEnumerator: TEnumerator<T>; virtual;
function Count: integer; virtual;
function ItemGet(aIndex: integer): T; virtual;
property Items[aIndex: integer]: T read ItemGet; default;
end;
implementation
{ TxnItems<T> }
function TxnItems<T>.Count: integer;
begin
Result := fItems.Count;
end;
constructor TxnItems<T>.Create;
begin
fItems := TList<T>.Create;
end;
destructor TxnItems<T>.Destroy;
begin
fItems.Free;
inherited;
end;
function TxnItems<T>.GetEnumerator: TEnumerator<T>;
begin
Result := fItems.GetEnumerator;
end;
function TxnItems<T>.ItemGet(aIndex: integer): T;
begin
Result := fItems[aIndex];
end;
end.
|
unit ServiceForma;
{$I defines.inc}
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DBCtrlsEh, Mask, StdCtrls, DBCtrls, OkCancel_frame, ExtCtrls,
DB, FIBDataSet, pFIBDataSet, DBLookupEh, Buttons, PrjConst,
FIBDatabase, pFIBDatabase, DBGridEh, CnErrorProvider, Vcl.ComCtrls;
type
TServiceForm = class(TForm)
pnlSrv: TPanel;
Label1: TLabel;
Label2: TLabel;
pnlNotice: TPanel;
Label6: TLabel;
cbShowService: TDBCheckBoxEh;
edName: TDBEditEh;
edShortName: TDBEditEh;
edDim: TDBEditEh;
dsPaymentType: TpFIBDataSet;
srcPaymentType: TDataSource;
dsService: TpFIBDataSet;
srcService: TDataSource;
gbInet: TGroupBox;
cbItsInet: TDBCheckBoxEh;
pnlPayType: TGroupBox;
Label3: TLabel;
eIPBegin: TDBEditEh;
Label5: TLabel;
eIPEnd: TDBEditEh;
Label8: TLabel;
pnlPeriodSrv: TPanel;
lbl1: TLabel;
gbDIGIT: TGroupBox;
pnlFull: TPanel;
lbl4: TLabel;
cbCalcType: TDBComboBoxEh;
lblFullMonthDays1: TLabel;
edtFullMonthDays: TDBNumberEditEh;
lblFullMonthDays2: TLabel;
cbBusinessType: TDBLookupComboboxEh;
btn1: TSpeedButton;
pnlAllDays: TPanel;
chkAUTOOFF: TDBCheckBoxEh;
pnlAddToMin: TPanel;
edtEXTID: TDBEditEh;
lbl2: TLabel;
edtDigExtID: TDBEditEh;
pnlShift: TPanel;
lblshift: TLabel;
edtShift: TDBNumberEditEh;
lbl3: TLabel;
pnlAUTO: TPanel;
lbl5: TLabel;
edtPRIORITY: TDBNumberEditEh;
chkPOSITIVE: TDBCheckBoxEh;
trSWrite: TpFIBTransaction;
trSRead: TpFIBTransaction;
cnError: TCnErrorProvider;
chkOnlyOne: TDBCheckBoxEh;
pnlBottom: TPanel;
btnOk: TBitBtn;
btnCancel: TBitBtn;
pgc1: TPageControl;
tsNotice: TTabSheet;
tsWeb: TTabSheet;
mmoDESCRIPTION: TDBMemoEh;
pnlNote: TPanel;
Label4: TLabel;
Notice: TDBMemoEh;
pnlTop: TPanel;
lbl6: TLabel;
edtTAGSTR: TDBEditEh;
edtTAGINT: TDBNumberEditEh;
chkONLY_ONE: TDBCheckBoxEh;
procedure cbItsInetClick(Sender: TObject);
procedure eIPEndEnter(Sender: TObject);
procedure eIPEndExit(Sender: TObject);
procedure cbBusinessTypeChange(Sender: TObject);
procedure cbCalcTypeChange(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure btn1Click(Sender: TObject);
procedure dsServiceNewRecord(DataSet: TDataSet);
procedure chkAUTOOFFClick(Sender: TObject);
procedure btnOkClick(Sender: TObject);
procedure edtDigExtIDKeyPress(Sender: TObject; var Key: Char);
procedure dsServiceAfterOpen(DataSet: TDataSet);
private
{ Private declarations }
FCanEdit: Boolean;
fSrvType: Integer;
procedure Save;
procedure SetCalcTypeReadOnly;
public
//
end;
function ViewService(const aServ_ID, aType_ID: int64): int64;
implementation
uses
DM, AtrCommon, StrUtils, AtrStrUtils, pFIBQuery;
{$R *.dfm}
function ViewService(const aServ_ID, aType_ID: int64): int64;
var
b: Integer;
begin
with TServiceForm.Create(application) do
try
FCanEdit := (dmMain.AllowedAction(rght_Dictionary_full));
FCanEdit := FCanEdit or (dmMain.AllowedAction(rght_Dictionary_Services));
// может редактировать если разрешено редактировать все
fSrvType := aType_ID;
dsPaymentType.Active := false;
pnlPayType.Visible := false;
dsService.ParamByName('Service_Id').AsInt64 := aServ_ID;
dsService.Open;
if dsService.FieldByName('SHOW_SERVICE').IsNull then
b := 1
else
b := dsService['SHOW_SERVICE'];
cbShowService.Checked := (b = 1);
pnlPeriodSrv.Visible := (aType_ID = 0);
if aType_ID = 0 then
begin
cbItsInetClick(cbItsInet);
if dsService.FieldByName('BUSINESS_TYPE').IsNull then
b := -1
else
begin
b := dsService['BUSINESS_TYPE'];
end;
gbInet.Visible := (aType_ID = 0) and (b = 1);
gbDIGIT.Visible := (aType_ID = 0) and (b = 2);
end
else
begin
cbItsInet.Visible := false;
gbInet.Visible := false;
end;
btnOk.Enabled := FCanEdit;
if (ShowModal = mrOk) and (dsService.State in [dsEdit, dsInsert]) then
begin
if cbShowService.Checked then
dsService['SHOW_SERVICE'] := 1
else
dsService['SHOW_SERVICE'] := 0;
if aType_ID = 0 then
begin
if VarIsNull(dsService.FieldByName('CALC_TYPE').NewValue) then
dsService['CALC_TYPE'] := 0
else if dsService.FieldByName('CALC_TYPE').NewValue <> 1 then
dsService['EXTRA'] := 0;
end;
dsService.Post;
result := dsService['SERVICE_ID'];
end
else
begin
result := -1;
end;
finally
free;
end
end;
procedure TServiceForm.btn1Click(Sender: TObject);
var
s: string;
begin
if dsService.FieldByName('SERVICE_ID').IsNull then
Exit;
s := '';
with TpFIBQuery.Create(Nil) do
try
DataBase := dmMain.dbTV;
Transaction := dmMain.trReadQ;
SQL.Text := 'select IP from GET_FREE_INET_IP(' + dsService.FieldByName('SERVICE_ID').AsString + ')';
Transaction.StartTransaction;
ExecQuery;
if not EOF then
s := FieldByName('IP').Value;
Close;
Transaction.Commit;
finally
free;
end;
ShowMessage('IP: ' + s);
end;
procedure TServiceForm.cbBusinessTypeChange(Sender: TObject);
begin
if VarIsNull(cbBusinessType.Value) then
Exit;
if not VarIsNumeric(cbBusinessType.Value) then
Exit;
gbInet.Visible := (cbBusinessType.Value = 1);
gbDIGIT.Visible := (cbBusinessType.Value = 2);
end;
procedure TServiceForm.cbCalcTypeChange(Sender: TObject);
begin
if VarIsNull(cbCalcType.Value) then
Exit;
pnlShift.Visible := (cbCalcType.Value = 0) and (dsService['SRV_TYPE_ID'] = 0);
pnlFull.Visible := (cbCalcType.Value = 1) and (dsService['SRV_TYPE_ID'] = 0);
pnlAllDays.Visible := (dsService['SRV_TYPE_ID'] = 0) and
((cbCalcType.Value = 0) or (cbCalcType.Value = 1) or (cbCalcType.Value = 2) or (cbCalcType.Value = 3) or
(cbCalcType.Value = 5));
pnlAddToMin.Visible := (cbCalcType.Value = 3) and (dsService['SRV_TYPE_ID'] = 0);
end;
procedure TServiceForm.cbItsInetClick(Sender: TObject);
begin
if cbItsInet.Checked then
gbInet.Height := 75
else
gbInet.Height := cbItsInet.Height + 3;
edtEXTID.TabStop := cbItsInet.Checked;
eIPBegin.TabStop := cbItsInet.Checked;
eIPEnd.TabStop := cbItsInet.Checked;
end;
procedure TServiceForm.chkAUTOOFFClick(Sender: TObject);
begin
pnlAUTO.Visible := chkAUTOOFF.Checked;
end;
procedure TServiceForm.dsServiceAfterOpen(DataSet: TDataSet);
begin
SetCalcTypeReadOnly();
end;
procedure TServiceForm.dsServiceNewRecord(DataSet: TDataSet);
begin
dsService['SHIFT_MONTHS'] := 0;
dsService['EXTRA'] := 0;
dsService['SHOW_SERVICE'] := 1;
dsService['SRV_TYPE_ID'] := fSrvType;
end;
procedure TServiceForm.edtDigExtIDKeyPress(Sender: TObject; var Key: Char);
begin
if (not(((Key >= '0') and (Key <= '9')) or (Key = ',') or (Key = #8))) then
Key := #0;
end;
procedure TServiceForm.eIPEndEnter(Sender: TObject);
begin
if (dmMain.GetIniValue('KBDSWITCH') = '0') then
SetKeyboardLayout('EN')
else
dmMain.SaveKLAndSelectEnglish;
end;
procedure TServiceForm.eIPEndExit(Sender: TObject);
begin
if (dmMain.GetIniValue('KBDSWITCH') = '0') then
SetKeyboardLayout(dmMain.GetIniValue('KEYBOARD'))
else
dmMain.RestoreKL;
if (Sender as TDBEditEh).Text = '' then
Exit;
(Sender as TDBEditEh).Text := ReplaceStr((Sender as TDBEditEh).Text, ',', '.');
if not CheckIP((Sender as TDBEditEh).Text) then
begin
ShowMessage(rsIPIncorrect);
(Sender as TDBEditEh).SetFocus;
end;
end;
procedure TServiceForm.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if ((Shift = [ssCtrl]) and (Ord(Key) = VK_RETURN) and (btnOk.Enabled)) then
Save;
end;
procedure TServiceForm.btnOkClick(Sender: TObject);
begin
Save;
end;
procedure TServiceForm.Save;
var
errors: Boolean;
begin
errors := false;
if ((pnlFull.Visible) // какой-то бред. не работает без сравнения с true
and (edtFullMonthDays.Value = 0)) then
begin
cnError.SetError(edtFullMonthDays, rsDayNotZerro, iaMiddleLeft, bsNeverBlink);
errors := true;
ModalResult := mrNone;
end
else
cnError.Dispose(edtFullMonthDays);
if not errors then
begin
ModalResult := mrOk;
end;
end;
procedure TServiceForm.SetCalcTypeReadOnly;
begin
if dsService.FieldByName('SERVICE_ID').IsNull then
Exit;
with TpFIBQuery.Create(Nil) do
begin
try
DataBase := dmMain.dbTV;
Transaction := dmMain.trReadQ;
SQL.Text := 'select count(*) cnt from subscr_serv s where s.Serv_Id = :SID';
ParamByName('SID').AsInteger := dsService['SERVICE_ID'];
Transaction.StartTransaction;
ExecQuery;
cbCalcType.ReadOnly := (FieldByName('cnt').Value > 0);
Close;
Transaction.Commit;
finally
free;
end;
end;
end;
end.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.