text
stringlengths
14
6.51M
unit EffectEditor; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ComCtrls, Vcl.ExtCtrls, Vcl.Buttons, GraphicsSpeedButton, MediaPlayTrackBar, GraphicsButton, Vcl.StdCtrls, Vcl.Menus, Vcl.Samples.Spin, VideoConverterInt, VideoEffectInt; type TfrmEffect = class(TForm) palRender: TPanel; palConsole: TPanel; StatusBar1: TStatusBar; tbSeek: TMediaPlayTrackBar; PageControl1: TPageControl; btnPlay: TGraphicsSpeedButton; TabSheet1: TTabSheet; TabSheet2: TTabSheet; lblBrightness: TLabel; tbBrightness: TTrackBar; lblContrast: TLabel; tbContrast: TTrackBar; lblHue: TLabel; tbHue: TTrackBar; lblSaturation: TLabel; tbSaturation: TTrackBar; lblLightness: TLabel; tbLightness: TTrackBar; TabSheet3: TTabSheet; btnRotateLeft: TGraphicsButton; btnRotateRight: TGraphicsButton; btnFlipHorizontal: TGraphicsButton; btnFlipVertical: TGraphicsButton; lblRotateFlip: TLabel; btnReset1: TButton; btnReset2: TButton; procedure FormCreate(Sender: TObject); procedure palRenderResize(Sender: TObject); procedure btnPlayClick(Sender: TObject); procedure tbSeekChange(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure tbBrightnessChange(Sender: TObject); procedure tbContrastChange(Sender: TObject); procedure tbHueChange(Sender: TObject); procedure tbSaturationChange(Sender: TObject); procedure tbLightnessChange(Sender: TObject); procedure btnRotateLeftClick(Sender: TObject); procedure btnRotateRightClick(Sender: TObject); procedure btnFlipHorizontalClick(Sender: TObject); procedure btnFlipVerticalClick(Sender: TObject); procedure btnReset1Click(Sender: TObject); procedure btnReset2Click(Sender: TObject); private { Private declarations } FChanging: Boolean; FPlayer : Pointer; FPlaying : Boolean; FDuration: Integer; FItem : PVCItem; procedure Pause(); procedure OnPause(); procedure SetTimeInfo(sec: Integer); private procedure OnProgress(var msg: TMessage); message VC_VIDEO_RENDER_PROGRESS; procedure OnPlayEnd(var msg: TMessage); message VC_VIDEO_RENDER_END; protected { protected declarations } procedure CreateParams(var Params: TCreateParams); override; public { Public declarations } procedure InitForm(Item: PVCItem); end; implementation {$R *.dfm} uses ImageResource, Functions, Main; procedure TfrmEffect.btnReset1Click(Sender: TObject); var Params: BrightnessContrastParams; begin FChanging := TRUE; tbBrightness.Position := 0; tbContrast.Position := 0; Params.m_Brightness := 0; Params.m_Contrast := 0; vcSetVideoEffect(FItem, IID_BrightnessContrast, @Params, sizeof(Params)); FChanging := FALSE; end; procedure TfrmEffect.btnReset2Click(Sender: TObject); var Params: HueSaturationLightnessParams; begin FChanging := TRUE; tbHue.Position := 0; tbSaturation.Position := 0; tbLightness.Position := 0; Params.m_Hue := 0; Params.m_Saturation := 0; Params.m_Lightness := 0; vcSetVideoEffect(FItem, IID_HueSaturationLightness, @Params, sizeof(Params)); FChanging := FALSE; end; procedure TfrmEffect.btnRotateLeftClick(Sender: TObject); var Params: Integer; begin Params := 0; vcGetVideoEffect(FItem, IID_RotateFlip, @Params, sizeof(Params)); Params := CalcRotateFlip(Params, Rotate_Left); vcSetVideoEffect(FItem, IID_RotateFlip, @Params, sizeof(Params)); lblRotateFlip.Caption := RotateFlipString(Params); end; procedure TfrmEffect.btnRotateRightClick(Sender: TObject); var Params: Integer; begin if FChanging then exit; Params := 0; vcGetVideoEffect(FItem, IID_RotateFlip, @Params, sizeof(Params)); Params := CalcRotateFlip(Params, Rotate_Right); vcSetVideoEffect(FItem, IID_RotateFlip, @Params, sizeof(Params)); lblRotateFlip.Caption := RotateFlipString(Params); end; procedure TfrmEffect.CreateParams(var Params: TCreateParams); begin inherited; Params.WndParent := 0; Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW; end; procedure TfrmEffect.FormClose(Sender: TObject; var Action: TCloseAction); begin if FPlayer <> nil then begin vcVideoPlayerDestroy(FPlayer); FPlayer := nil; end; frmMain.Show(); Action := caFree; end; procedure TfrmEffect.FormCreate(Sender: TObject); begin btnPlay.SetImage(imagePlay); btnRotateLeft.SetImage(imageRotateLeft); btnRotateRight.SetImage(imageRotateRight); btnFlipHorizontal.SetImage(imageFlipHorizontal); btnFlipVertical.SetImage(imageFlipVertical); PageControl1.ActivePageIndex := 0; end; procedure TfrmEffect.palRenderResize(Sender: TObject); begin if FPlayer <> nil then begin vcVideoPlayerResize(FPlayer); end; end; procedure TfrmEffect.tbBrightnessChange(Sender: TObject); var Params: BrightnessContrastParams; begin if FChanging then exit; vcGetVideoEffect(FItem, IID_BrightnessContrast, @Params, sizeof(Params)); Params.m_Brightness := tbBrightness.Position; vcSetVideoEffect(FItem, IID_BrightnessContrast, @Params, sizeof(Params)); end; procedure TfrmEffect.tbContrastChange(Sender: TObject); var Params: BrightnessContrastParams; begin if FChanging then exit; vcGetVideoEffect(FItem, IID_BrightnessContrast, @Params, sizeof(Params)); Params.m_Contrast := tbContrast.Position; vcSetVideoEffect(FItem, IID_BrightnessContrast, @Params, sizeof(Params)); end; procedure TfrmEffect.tbHueChange(Sender: TObject); var Params: HueSaturationLightnessParams; begin if FChanging then exit; vcGetVideoEffect(FItem, IID_HueSaturationLightness, @Params, sizeof(Params)); Params.m_Hue := tbHue.Position; vcSetVideoEffect(FItem, IID_HueSaturationLightness, @Params, sizeof(Params)); end; procedure TfrmEffect.tbLightnessChange(Sender: TObject); var Params: HueSaturationLightnessParams; begin if FChanging then exit; vcGetVideoEffect(FItem, IID_HueSaturationLightness, @Params, sizeof(Params)); Params.m_Lightness := tbLightness.Position; vcSetVideoEffect(FItem, IID_HueSaturationLightness, @Params, sizeof(Params)); end; procedure TfrmEffect.tbSaturationChange(Sender: TObject); var Params: HueSaturationLightnessParams; begin if FChanging then exit; vcGetVideoEffect(FItem, IID_HueSaturationLightness, @Params, sizeof(Params)); Params.m_Saturation := tbSaturation.Position; vcSetVideoEffect(FItem, IID_HueSaturationLightness, @Params, sizeof(Params)); end; procedure TfrmEffect.tbSeekChange(Sender: TObject); var Pos: Integer; begin Pos := tbSeek.Position; SetTimeInfo(Pos); vcVideoPlayerSeekTo(FPlayer, Pos * AV_TIME_BASE_LL); OnPause(); end; procedure TfrmEffect.Pause(); begin if FPlaying then begin vcVideoPlayerPause(FPlayer); FPlaying := FALSE; btnPlay.SetImage(imagePlay); end; end; procedure TfrmEffect.OnPause(); begin if FPlaying then begin FPlaying := FALSE; btnPlay.SetImage(imagePlay); end; end; procedure TfrmEffect.btnFlipHorizontalClick(Sender: TObject); var Params: Integer; begin if FChanging then exit; Params := 0; vcGetVideoEffect(FItem, IID_RotateFlip, @Params, sizeof(Params)); Params := CalcRotateFlip(Params, Flip_Horizontal); vcSetVideoEffect(FItem, IID_RotateFlip, @Params, sizeof(Params)); lblRotateFlip.Caption := RotateFlipString(Params); end; procedure TfrmEffect.btnFlipVerticalClick(Sender: TObject); var Params: Integer; begin if FChanging then exit; Params := 0; vcGetVideoEffect(FItem, IID_RotateFlip, @Params, sizeof(Params)); Params := CalcRotateFlip(Params, Flip_Vertical); vcSetVideoEffect(FItem, IID_RotateFlip, @Params, sizeof(Params)); lblRotateFlip.Caption := RotateFlipString(Params); end; procedure TfrmEffect.btnPlayClick(Sender: TObject); begin if FPlaying then begin vcVideoPlayerPause(FPlayer); FPlaying := FALSE; btnPlay.SetImage(imagePlay); end else begin vcVideoPlayerResume(FPlayer); FPlaying := TRUE; btnPlay.SetImage(imagePause); end; end; procedure TfrmEffect.InitForm(Item: PVCItem); var Params1: BrightnessContrastParams; Params2: HueSaturationLightnessParams; Params3: Integer; begin FItem := Item; Self.HandleNeeded; Self.Caption := Item.m_MediaInfo.m_szFileName; FPlayer := vcCreateVideoPlayer(palRender.Handle, Self.Handle, Item, VC_VIDEO_RENDER_MODE_DEST); FDuration := (Item.m_MediaInfo.m_Duration + AV_TIME_BASE_LL - 1) div AV_TIME_BASE_LL; tbSeek.Max := FDuration; vcGetVideoEffect(FItem, IID_BrightnessContrast, @Params1, sizeof(Params1)); tbBrightness.Position := Params1.m_Brightness; tbContrast.Position := Params1.m_Contrast; vcGetVideoEffect(FItem, IID_HueSaturationLightness, @Params2, sizeof(Params2)); tbHue.Position := Params2.m_Hue; tbSaturation.Position := Params2.m_Saturation; tbLightness.Position := Params2.m_Lightness; vcGetVideoEffect(FItem, IID_RotateFlip, @Params3, sizeof(Params3)); lblRotateFlip.Caption := RotateFlipString(Params3); end; procedure TfrmEffect.OnProgress(var msg: TMessage); begin tbSeek.Position := msg.LParam; SetTimeInfo(msg.LParam); end; procedure TfrmEffect.OnPlayEnd(var msg: TMessage); begin FPlaying := FALSE; btnPlay.SetImage(imagePlay); end; procedure TfrmEffect.SetTimeInfo(sec: Integer); begin StatusBar1.Panels[1].Text := GetDurationProcString(sec, FDuration); end; end.
unit uFunctions; {$M+} interface uses System.SysUtils, System.Classes, JclIDEUtils, System.StrUtils; type TRegisterPath = class(TObject) private { private declarations } FVersions: TStringList; FPlataforms: TStringList; FLibrayPath: TStringList; FLibrarySearchPath: TStringList; FDebugDCUPath: TStringList; procedure setVersions(const Value: string); procedure setLibrayPath(const Value: string); procedure setLibrarySearchPath(const Value: string); procedure setDebugDCUPath(const Value: string); procedure setPlataforms(const Value: string); function getInstallation(const version: Integer): TJclBorRADToolInstallation; function getPlataformByStr(const aStr: string): TJclBDSPlatform; protected { protected declarations } public { public declarations } constructor Create(AOwner: TComponent); reintroduce; destructor Destroy; reintroduce; //function checkParams: Boolean; procedure registerPath; published { published declarations } property versions: string write setVersions; property plataform: string write setPlataforms; property librayPath: string write setLibrayPath; property librarySearchPath: string write setLibrarySearchPath; property debugDCUPath: string write setDebugDCUPath; end; implementation procedure TRegisterPath.setDebugDCUPath(const Value: string); begin FDebugDCUPath.Text := StringReplace(Value, ';', sLineBreak, [rfReplaceAll]); end; procedure TRegisterPath.setLibrarySearchPath(const Value: string); begin FLibrarySearchPath.Text := StringReplace(Value, ';', sLineBreak, [rfReplaceAll]); end; procedure TRegisterPath.setLibrayPath(const Value: string); begin FLibrayPath.Text := StringReplace(Value, ';', sLineBreak, [rfReplaceAll]); end; procedure TRegisterPath.setPlataforms(const Value: string); begin FPlataforms.Text := StringReplace(Value, ';', sLineBreak, [rfReplaceAll]); end; procedure TRegisterPath.setVersions(const Value: string); begin FVersions.Text := StringReplace(Value, ';', sLineBreak, [rfReplaceAll]); end; constructor TRegisterPath.Create(AOwner: TComponent); begin inherited Create; FVersions := TStringList.Create; FPlataforms := TStringList.Create; FLibrayPath := TStringList.Create; FLibrarySearchPath := TStringList.Create; FDebugDCUPath := TStringList.Create; end; destructor TRegisterPath.Destroy; begin FVersions.Free; FPlataforms.Free; FLibrayPath.Free; FLibrarySearchPath.Free; FDebugDCUPath.Free; end; function TRegisterPath.getInstallation(const version: Integer): TJclBorRADToolInstallation; var delphiList: TJclBorRADToolInstallations; I: Integer; begin Result := nil; delphiList := TJclBorRADToolInstallations.Create; try for I := 0 to delphiList.Count do begin if delphiList.DelphiVersionInstalled[version] then begin Result := delphiList.Installations[I]; Break; end; end; finally delphiList.Free; end; end; procedure TRegisterPath.registerPath; var iVersion: Integer; iPlataform: Integer; installation: TJclBorRADToolInstallation; begin for iVersion := 0 to FVersions.Count do begin installation := getInstallation(StrToInt(FVersions[iVersion])); if not Assigned(installation) then Exit; with installation do begin for iPlataform := 0 to FPlataforms.Count do begin AddToLibraryBrowsingPath(FLibrayPath.Text, getPlataformByStr(FPlataforms[iPlataform])); AddToLibrarySearchPath(FLibrarySearchPath.Text, getPlataformByStr(FPlataforms[iPlataform])); AddToDebugDCUPath(FDebugDCUPath.Text, getPlataformByStr(FPlataforms[iPlataform])); end; end; end; end; function TRegisterPath.getPlataformByStr(const aStr: string): TJclBDSPlatform; begin if MatchText('win32', aStr) then Result := bpWin32 else if MatchText('win64', aStr) then Result := bpWin64 else Result := bpOSX32; end; end.
unit UGSE_PCVutils; interface uses UContainer, MSXML6_TLB, Windows, SysUtils, Classes, UGSEUploadXML; const strXML = 'XML'; strPDF = 'PDF'; strENV = 'ENV'; strXML241 = 'XML'; strYes = 'Yes'; strNo = 'No'; //data directory, file dataSubDir = 'data'; dataFile = 'data.xml'; //dataFile XPATHs xpReportFile = '/PCV_UPLOADER/Files/File[@Type="%s"]'; xpSummaryField = '/PCV_UPLOADER/ReportSummary/%s'; //PCV request XML elRoot = 'PCV-XML'; ndHeader = 'Header'; ndCreated = 'Created'; ndGMTOffset = 'GMTOffset'; ndECN = 'ECN'; ecnBT = 'BRAD'; ndUserName = 'UserName'; ndPassword = 'Password'; ndTransactionId = 'TransactionId'; ndTransactionType = 'TransactionType'; trType45 = '45'; trType50 = '50'; ndDetail = 'Detail'; ndData = 'Data'; ndFormList = 'FormList'; ndForm = 'Form'; attrPrimary = 'Primary'; attrName = 'Name'; ndAddress = 'Address'; ndCity = 'City'; ndState = 'State'; ndZip = 'Zip'; ndFormName = 'FormName'; ndLicenseNumber = 'LicenseNumber'; ndInspectDate = 'InspectDate'; ndAsIs = 'AsIs'; ndAsRepaired = 'AsRepaired'; ndRepairesAmount = 'RepairsAmount'; ndEstimatedMarketDays = 'EstimatedMarketDays'; ndPropertyCondition = 'PropertyCondition'; ndOccupancy = 'Occupancy'; ndYearBuilt = 'YearBuilt'; ndBedrooms = 'Bedrooms'; ndBathrooms = 'Bathrooms'; ndTotalRooms = 'TotalRooms'; ndDom = 'EstimatedMarketDays'; ndSquareFootage = 'SquareFootage'; ndBasementSize = 'BasementSize'; ndLotSize = 'LotSize'; ndPool = 'Pool'; ndSpa = 'Spa'; ndOriginalSoftware = 'OriginalSoftware'; ndOriginalFileType = 'OriginalFileType'; ndFile = 'File'; attrCategory = 'Category'; ndType = 'Type'; ndName = 'Name'; ndContent = 'Content'; ctgVendor = 'Vendor'; ctgMismo = 'MISMO'; ctgEnv = 'ENV'; ctgMismo241 = 'MISMO241'; pdfFileName = 'Appraisal.pdf'; xmlFileName = 'MISMO.xml'; envFileName = 'AiReadyFile.env'; xml241FileName = 'MISMO241.xml'; //PCV Responce XPATHs xpValidated = '/PCV-XML/Acknowledgement/Validated'; xpMessage = '/PCV-XML/Acknowledgement/Message'; xpAIReady = '/PCV-XML/Acknowledgement/AIReady'; xpMismo241 = '/PCV-XML/Acknowledgement/Mismo241'; //occupancy strOccupancyOwner = 'OWNER'; strOccupancyTenant = 'TENANT'; strOccupancyVacant = 'VACANT'; timeout = 300000; //5 minutes strTrue = 'True'; strFalse = 'False'; procedure CreateChildNode(xmlDoc: IXMLDOMDocument2;parent: IXMLDOMNode; nodeName: String; nodeText: String); function CreateXML45Request(doc: TContainer; uploader: TUploadUADXML) : String; function GetXMLNodeText(xmlDoc: IXMLDOMDocument2; xPath: String): String; function ParsePCVResponse(resp: String; var msg: String; var isENV: Boolean; var is241: Boolean): Boolean; function Get64baseFileContent(fPath: String): String; function CreateXML50Request(doc: TContainer; uploader: TUploadUADXML): String; procedure CreateNodeAttribute(xmlDOC: IXMLDOMDocument2; node: IXMLDOMNode; attrName: String; attrValue: String); function FormatPropertyConditionsForPCV( reportStr: String): String; function GetPCVAppraisalType(doc: TContainer): String; implementation uses UGlobals, UStatus, UGridMgr, UBase, UBase64, UUtil2, ShellAPI, UAMC_XMLUtils, UForm; procedure CreateChildNode(xmlDoc: IXMLDOMDocument2;parent: IXMLDOMNode; nodeName: String; nodeText: String); var childNode: IXMLDOMNode; begin childNode := xmlDoc.CreateNode(NODE_ELEMENT,nodeName,''); childNode.appendChild(xmlDoc.CreateTextNode(nodeText)); parent.appendChild(childNode); end; function CreateXML45Request(doc: TContainer; uploader: TUploadUADXML) : String; const addrContID = 101; cityStateZipContID = 102; var xml45: IXMLDomDocument2; node: IXMLDomNode; tzi: TTimeZoneInformation; nodeText: String; curText: String; begin result := ''; xml45 := CoDomDocument60.Create; with xml45 do begin documentElement := createElement(elRoot); //root element node := CreateNode(NODE_ELEMENT,ndHeader,''); //node header documentElement.appendChild(node); CreateChildNode(xml45,node,ndCreated,DateTimeToStr(Now)); //date GetTimeZoneInformation(tzi); nodeText := IntToStr(-tzi.Bias div 60); CreateChildNode(xml45,node,ndGMTOffset,nodeText); //time offset CreateChildNode(xml45,node,ndECN,ecnBT); //ecn with uploader do begin CreateChildNode(xml45,node,ndUserName,FUserID); //user name CreateChildNode(xml45,node,ndPassword,FUserPassword); //password CreateChildNode(xml45,node,ndTransactionId,FOrderID); //transaction ID end; CreateChildNode(xml45,node,ndTransactionType,trType45); //transaction type node := CreateNode(NODE_ELEMENT,ndDetail,''); //node detail documentElement.appendChild(node); node := node.appendChild(CreateNode(NODE_ELEMENT,ndData,'')); //node data if assigned(doc.GetCellByID(cSubjectAddressCellID)) then //report has subject address cells begin CreateChildNode(xml45,node,ndAddress,doc.GetCellTextByID(cSubjectAddressCellID)); //street address CreateChildNode(xml45,node,ndCity,doc.GetCellTextByID(cSubjectCityCellID)); //city CreateChildNode(xml45,node,ndState,doc.GetCellTextByID(cSubjectStateCellID)); //state CreateChildNode(xml45,node,ndZip,doc.GetCellTextByID(cSubjectZipCellID)); //zip end else if doc.FindContextData(addrContID, curText) then //check comparable form begin CreateChildNode(xml45,node,ndAddress,curText); if doc.FindContextData(cityStateZipContID, curText) then begin CreateChildNode(xml45,node,ndCity,ParseCityStateZip3(curText, cmdGetCity)); //city CreateChildNode(xml45,node,ndState,ParseCityStateZip3(curText, cmdGetState)); //state CreateChildNode(xml45,node,ndZip,ParseCityStateZip3(curText, cmdGetZip)); end; end else begin ShowNotice('Cannot find the property address in the report!',false); exit; end; end; result := xml45.xml; {//test test test xml45.save('C:\temp\xml45.xml'); ShellExecute(self.Handle, 'open','C:\temp\xml45.xml',nil,nil,SW_SHOW); //test test test } end; function ParsePCVResponse(resp: String; var msg: String; var isENV: Boolean; var is241: Boolean): Boolean; var xmlDoc: IXMLDOMDocument2; begin result := false; msg := 'unknown error'; isEnv := false; is241 := false; xmlDoc := CoDomDocument60.Create; with xmlDoc do begin async := false; setProperty('SelectionLanguage', 'XPath'); xmlDoc.loadXML(resp); if parseError.errorCode <> 0 then begin ShowNotice('Invalid response XML'); exit; end; end; result := CompareText(strYes,GetXMLNodeText(xmlDoc,xpValidated)) = 0; if result then msg := '' else msg := GetXMLNodeText(xmlDoc,xpMessage); isENV := CompareText(strYes,GetXMLNodeText(xmlDoc,xpAIReady)) = 0; is241 := CompareText(strYes,GetXMLNodeText(xmlDoc,xpMismo241)) = 0; end; function GetXMLNodeText(xmlDoc: IXMLDOMDocument2; xPath: String): String; var node: IXMLDOMNode; begin result := ''; node := xmlDoc.selectSingleNode(xPath); if assigned(node) then result := node.text; end; function Get64baseFileContent(fPath: String): String; var fStream: TFileStream; decStr: String; begin result := ''; if not FileExists(fPath) then exit; fStream := TFileStream.Create(fPath, fmOpenRead); try fStream.Seek(0,soFromBeginning); SetLength(decStr,fStream.size); fStream.Read(PChar(decStr)^, length(decStr)); result := Base64Encode(decStr); finally fStream.Free; end; end; function CreateXML50Request(doc: TContainer; uploader: TUploadUADXML): String; var xml50: IXMLDomDocument2; node,subNode, subSubNode, formNode: IXMLDomNode; tzi: TTimeZoneInformation; nodeText: String; docGrid: TGridMgr; subjProperty: String; reportFormName, formName: String; fileIndex: Integer; begin result := ''; xml50 := CoDomDocument60.Create; xml50.documentElement := xml50.createElement(elRoot); //root element node := xml50.CreateNode(NODE_ELEMENT,ndHeader,''); //node header xml50.documentElement.appendChild(node); CreateChildNode(xml50,node,ndCreated,DateTimeToStr(Now)); //date GetTimeZoneInformation(tzi); nodeText := IntToStr(-tzi.Bias div 60); CreateChildNode(xml50,node,ndGMTOffset,nodeText); //time offset CreateChildNode(xml50,node,ndECN,ecnBT); //ecn CreateChildNode(xml50,node,ndUserName,uploader.FUserID); //user name CreateChildNode(xml50,node,ndPassword,uploader.FUserPassword); //password CreateChildNode(xml50,node,ndTransactionId,uploader.FOrderID); //transaction ID CreateChildNode(xml50,node,ndTransactionType,trType50); //transaction type node := xml50.CreateNode(NODE_ELEMENT,ndDetail,''); //node detail xml50.documentElement.appendChild(node); subNode := node.appendChild(xml50.CreateNode(NODE_ELEMENT,ndData,'')); //node data reportFormName := GetPCVAppraisalType(doc); if length(reportFormName) > 0 then CreateChildNode(xml50,subNode,ndFormName,reportFormName); if assigned(doc.GetCellByID(cStateLicense)) or assigned(doc.GetCellByID(cStateCertificate)) or assigned(doc.GetCellByID(cStateLicenseOther)) then begin subjProperty := trim(doc.GetCellTextByID(cStateLicense)); if length(subjProperty) = 0 then begin subjProperty := trim(doc.GetCellTextByID(cStateCertificate)); if length(subjProperty) = 0 then subjProperty := trim(doc.GetCellTextByID(cStateLicenseOther)); end; if length(subjProperty) > 0 then // we have to catch it on review stage CreateChildNode(xml50,subNode,ndLicenseNumber,subjProperty); end; if compareText(reportFormName,'FNM1004D') = 0 then //1004D has different cellID for inspection date than the other forms CreateChildNode(xml50,subNode,ndInspectDate,doc.GetCellTextByID(cSubjectInspectionDate1004D)) else CreateChildNode(xml50,subNode,ndInspectDate,doc.GetCellTextByID(cSubjectInspectionDate)); CreateChildNode(xml50,subNode,ndAsIs,doc.GetCellTextByID(cSubjectMarketValue)); //CreateChildNode(xml50,subNode,ndEstimatedMarketDays, //we do not have cellID for Estimated MarketDays subjProperty := ''; if doc.GetCheckBoxValueByID(cSubjectOccupancyOwner) then subjProperty := strOccupancyOwner else if doc.GetCheckBoxValueByID(cSubjectOccupancyTenant) then subjProperty := strOccupancyTenant else if doc.GetCheckBoxValueByID(cSubjectOccupancyVacant) then subjProperty := strOccupancyVacant; CreateChildNode(xml50,subNode,ndOccupancy,subjProperty); CreateChildNode(xml50,subNode,ndYearBuilt,doc.GetCellTextByID(cSubjectYearBuilt)); CreateChildNode(xml50,subNode,ndBasementSize,doc.GetCellTextByID(cSubjectBasementSize)); CreateChildNode(xml50,subNode,ndLotSize,doc.GetCellTextByID(cSubjectLotSize)); CreateChildNode(xml50,subNode,ndPool,doc.GetCellTextByID(cSubjectPool)); //CreateChildNode(xml50,subNode,ndSpa, //we do not have spa cell if length(trim(doc.GetCellTextByID(cReoRepairesAmount))) > 0 then //customer fill out Reo Addendum begin CreateChildNode(xml50,subNode,ndRepairesAmount,doc.GetCellTextByID(cReoRepairesAmount)); CreateChildNode(xml50,subNode,ndAsRepaired,doc.GetCellTextByID(cReoAsRepaired)); end else CreateChildNode(xml50,subNode,ndAsRepaired,doc.GetCellTextByID(cSubjectMarketValue)); // no Reo Addendum docGrid := TGridMgr.Create(true); try docGrid.BuildGrid(doc, gtSales); docGrid.GetSubject(cCompPropCondition,subjProperty); CreateChildNode(xml50,subNode,ndPropertyCondition,FormatPropertyConditionsForPCV(subjProperty)); docGrid.GetSubject(cCompTotalRooms,subjProperty); CreateChildNode(xml50,subNode,ndTotalRooms,subjProperty); docGrid.GetSubject(cCompBedRooms,subjProperty); CreateChildNode(xml50,subNode,ndBedrooms,subjProperty); docGrid.GetSubject(cCompBathRooms,subjProperty); CreateChildNode(xml50,subNode,ndBathrooms,subjProperty); docGrid.GetSubject(cCompGLA,subjProperty); CreateChildNode(xml50,subNode,ndSquareFootage,subjProperty); docGrid.BuildGrid(doc, gtListing); docGrid.GetSubject(cCompDOM,subjProperty); CreateChildNode(xml50,subNode,ndDom,subjProperty); finally docGrid.Free; end; subSubNode := subNode.appendChild(xml50.CreateNode(NODE_ELEMENT,ndFormList,'')); //node FileList for fileIndex := 0 to doc.docForm.Count - 1 do begin formNode := subSubNode.appendChild(xml50.createNode(NODE_ELEMENT,ndform,'')); formName := ExtractFileName(doc.docForm[fileIndex].frmInfo.fFormFilePath); if IsPrimaryAppraisalForm(doc.docForm[fileIndex].FormID) then begin CreateNodeAttribute(xml50,formNode,attrPrimary,strTrue); if doc.UADEnabled then formName := formName + 'UAD'; end else CreateNodeAttribute(xml50,formNode,attrPrimary,strFalse); CreateNodeAttribute(xml50,formNode,attrName,formName); end; with uploader do begin subNode := node.appendChild(xml50.CreateNode(NODE_ELEMENT,ndFile,'')); //node XML file CreateNodeAttribute(xml50,subNode,attrCategory,ctgMismo); CreateChildNode(xml50,subNode,ndType,strXML); CreateChildNode(xml50,subNode,ndName,xmlFileName); CreateChildNode(xml50,subNode,ndContent,Base64Encode(FReportXML)); subNode := node.appendChild(xml50.CreateNode(NODE_ELEMENT,ndFile,'')); //node PDF file CreateNodeAttribute(xml50,subNode,attrCategory,ctgVendor); CreateChildNode(xml50,subNode,ndType,strPDF); CreateChildNode(xml50,subNode,ndName,pdfFileName); CreateChildNode(xml50,subNode,ndContent,Get64baseFileContent(FTmpPDFPath)); if uploader.FNeedENV and (length(uploader.FReportENVpath) > 0) then begin subNode := node.appendChild(xml50.CreateNode(NODE_ELEMENT,ndFile,'')); //node ENV file CreateNodeAttribute(xml50,subNode,attrCategory,ctgEnv); CreateChildNode(xml50,subNode,ndType,strENV); CreateChildNode(xml50,subNode,ndName,envFileName); CreateChildNode(xml50,subNode,ndContent,Get64baseFileContent(FReportENVpath)); end; if uploader.FNeedMismo241 and (length(FReportXML241) > 0) then begin subNode := node.appendChild(xml50.CreateNode(NODE_ELEMENT,ndFile,'')); //node XML241 file CreateNodeAttribute(xml50,subNode,attrCategory,ctgMismo241); CreateChildNode(xml50,subNode,ndType,strXml241); CreateChildNode(xml50,subNode,ndName,xml241FileName); CreateChildNode(xml50,subNode,ndContent,Base64Encode(FReportXML241)); end; end; result := xml50.xml; //xml50.save('C:\pcvXML50.xml'); //test test test //xml50.save('C:\temp\xml50.xml'); //ShellExecute(doc.Handle, 'open','C:\ClickForms\PCVUploader\xml45.xml',nil,nil,SW_SHOW); //test test test end; procedure CreateNodeAttribute(xmlDOC: IXMLDOMDocument2; node: IXMLDOMNode; attrName: String; attrValue: String); var attr: IXMLDOMAttribute; begin attr := xmlDoc.createAttribute(attrName); attr.value := attrValue; node.attributes.setNamedItem(attr); end; //PCV lookup for XML50 differs from UAD standard. So we need to convert function FormatPropertyConditionsForPCV( reportStr: String): String; begin result := ''; if CompareText(reportStr,'C1') = 0 then result := 'XLNT'; if CompareText(reportStr,'C2') = 0 then result := 'VERY'; if CompareText(reportStr,'C3') = 0 then result := 'GOOD'; if CompareText(reportStr,'C4') = 0 then result := 'AVG'; if CompareText(reportStr,'C5') = 0 then result := 'FAIR'; if CompareText(reportStr,'C6') = 0 then result := 'POOR'; end; //PCV allows appraisals with stand alone forms which are not primary forms on our list function GetPCVAppraisalType(doc: TContainer): String; const PrimaryForms: Array[1..19] of Integer = (9,11,279,39,41,340,342,344,345,347,349,351,353,355,357,360,43,95,4031); //form IDs StandAloneForms: Array[1..3] of Integer = (fkMain, fkAddenda, fkMisc); //form type. forms can exists in the appraisal wo primary form var appraisalFormIndex: Integer; formID: Integer; formName: String; standAloneFormName: String; //not primary form standAloneformID: Integer; function isFormPrimary(formID: Integer): Boolean; var index: Integer; begin result := false; for index := 1 to length(PrimaryForms) do if formID = Primaryforms[index] then begin result := true; exit; end; end; function isFormStandAlone(formType: Integer): Boolean; var index: Integer; begin result := false; for index := 1 to length(StandAloneForms) do if formType = StandAloneForms[index] then begin result := true; exit; end; end; begin result := ''; formID := 0; standAloneFormName := ''; standAloneFormID := 0; if not assigned(doc) then exit; if doc.docForm.Count = 0 then exit; for appraisalFormIndex := 0 to doc.docForm.Count - 1 do if isFormPrimary(doc.docForm[appraisalFormIndex].frmInfo.fFormUID) then begin formID := doc.docForm[appraisalFormIndex].frmInfo.fFormUID; formName := doc.docForm[appraisalFormIndex].frmInfo.fFormName; break; end else if isFormStandAlone(doc.docForm[appraisalFormIndex].frmInfo.fFormKindID) and (standAloneFormID = 0) then //count the only 1st stand alone form begin standAloneformID := doc.docForm[appraisalFormIndex].frmInfo.fFormUID; standAloneFormName := doc.docForm[appraisalFormIndex].frmInfo.fFormName; end; if formID = 0 then //no primary form in the appraisal if standAloneFormID > 0 then begin formID := standAloneFormID; formName := standAloneFormName; end; if formID > 0 then case formID of 9: formName := 'VacantLand'; 11, 279: formName := 'MobileHome'; 43: formName := 'FRE2070'; 87: formName := 'ERC2001'; 95: formName := 'ERC2003'; 29: formName := 'FNM1007'; 32: formName := 'FNM216'; else begin formName := StringReplace(formName, ' ', '', [rfReplaceAll]); //remove spaces formName := StringReplace(formName, 'FNMA', 'FNM', [rfReplaceAll]); //abbreviate formName := StringReplace(formName, 'Certification', '', [rfReplaceAll]);//remove Cert end; end; result := formName; end; end.
{******************************************************************************} { } { Indy (Internet Direct) - Internet Protocols Simplified } { } { https://www.indyproject.org/ } { https://gitter.im/IndySockets/Indy } { } {******************************************************************************} { } { This file is part of the Indy (Internet Direct) project, and is offered } { under the dual-licensing agreement described on the Indy website. } { (https://www.indyproject.org/license/) } { } { Copyright: } { (c) 1993-2020, Chad Z. Hower and the Indy Pit Crew. All rights reserved. } { } {******************************************************************************} { } { Originally written by: Fabian S. Biehn } { fbiehn@aagon.com (German & English) } { } { Contributers: } { Here could be your name } { } {******************************************************************************} unit IdOpenSSLHeaders_bn; interface // Headers for OpenSSL 1.1.1 // bn.h {$i IdCompilerDefines.inc} uses IdCTypes, IdGlobal, IdOpenSSLConsts, IdOpenSSLHeaders_ossl_typ; const BN_FLG_MALLOCED = $01; BN_FLG_STATIC_DATA = $02; (* * avoid leaking exponent information through timing, * BN_mod_exp_mont() will call BN_mod_exp_mont_consttime, * BN_div() will call BN_div_no_branch, * BN_mod_inverse() will call BN_mod_inverse_no_branch. *) BN_FLG_CONSTTIME = $04; BN_FLG_SECURE = $08; (* Values for |top| in BN_rand() *) BN_RAND_TOP_ANY = -1; BN_RAND_TOP_ONE = 0; BN_RAND_TOP_TWO = 1; (* Values for |bottom| in BN_rand() *) BN_RAND_BOTTOM_ANY = 0; BN_RAND_BOTTOM_ODD = 1; (* BN_BLINDING flags *) BN_BLINDING_NO_UPDATE = $00000001; BN_BLINDING_NO_RECREATE = $00000002; type BN_ULONG = TIdC_ULONG; BN_GENCB_set_old_cb = procedure (a: TIdC_INT; b: TIdC_INT; c: Pointer); cdecl; BN_GENCB_set_cb = function (a: TIdC_INT; b: TIdC_INT; c: PBN_GENCB): TIdC_INT; cdecl; var procedure BN_set_flags(b: PBIGNUM; n: TIdC_INT); function BN_get_flags(b: PBIGNUM; n: TIdC_INT): TIdC_INT; (* * get a clone of a BIGNUM with changed flags, for *temporary* use only (the * two BIGNUMs cannot be used in parallel!). Also only for *read only* use. The * value |dest| should be a newly allocated BIGNUM obtained via BN_new() that * has not been otherwise initialised or used. *) procedure BN_with_flags(dest: PBIGNUM; b: PBIGNUM; flags: TIdC_INT); (* Wrapper function to make using BN_GENCB easier *) function BN_GENCB_call(cb: PBN_GENCB; a: TIdC_INT; b: TIdC_INT): TIdC_INT; function BN_GENCB_new: PBN_GENCB; procedure BN_GENCB_free(cb: PBN_GENCB); (* Populate a PBN_GENCB structure with an "old"-style callback *) procedure BN_GENCB_set_old(gencb: PBN_GENCB; callback: BN_GENCB_set_old_cb; cb_arg: Pointer); (* Populate a PBN_GENCB structure with a "new"-style callback *) procedure BN_GENCB_set(gencb: PBN_GENCB; callback: BN_GENCB_set_cb; cb_arg: Pointer); function BN_GENCB_get_arg(cb: PBN_GENCB): Pointer; (* * BN_prime_checks_for_size() returns the number of Miller-Rabin iterations * that will be done for checking that a random number is probably prime. The * error rate for accepting a composite number as prime depends on the size of * the prime |b|. The error rates used are for calculating an RSA key with 2 primes, * and so the level is what you would expect for a key of double the size of the * prime. * * This table is generated using the algorithm of FIPS PUB 186-4 * Digital Signature Standard (DSS), section F.1, page 117. * (https://dx.doi.org/10.6028/NIST.FIPS.186-4) * * The following magma script was used to generate the output: * securitybits:=125; * k:=1024; * for t:=1 to 65 do * for M:=3 to Floor(2*Sqrt(k-1)-1) do * S:=0; * // Sum over m * for m:=3 to M do * s:=0; * // Sum over j * for j:=2 to m do * s+:=(RealField(32)!2)^-(j+(k-1)/j); * end for; * S+:=2^(m-(m-1)*t)*s; * end for; * A:=2^(k-2-M*t); * B:=8*(Pi(RealField(32))^2-6)/3*2^(k-2)*S; * pkt:=2.00743*Log(2)*k*2^-k*(A+B); * seclevel:=Floor(-Log(2,pkt)); * if seclevel ge securitybits then * printf "k: %5o, security: %o bits (t: %o, M: %o)\n",k,seclevel,t,M; * break; * end if; * end for; * if seclevel ge securitybits then break; end if; * end for; * * It can be run online at: * http://magma.maths.usyd.edu.au/calc * * And will output: * k: 1024, security: 129 bits (t: 6, M: 23) * * k is the number of bits of the prime, securitybits is the level we want to * reach. * * prime length | RSA key size | # MR tests | security level * -------------+--------------|------------+--------------- * (b) >= 6394 | >= 12788 | 3 | 256 bit * (b) >= 3747 | >= 7494 | 3 | 192 bit * (b) >= 1345 | >= 2690 | 4 | 128 bit * (b) >= 1080 | >= 2160 | 5 | 128 bit * (b) >= 852 | >= 1704 | 5 | 112 bit * (b) >= 476 | >= 952 | 5 | 80 bit * (b) >= 400 | >= 800 | 6 | 80 bit * (b) >= 347 | >= 694 | 7 | 80 bit * (b) >= 308 | >= 616 | 8 | 80 bit * (b) >= 55 | >= 110 | 27 | 64 bit * (b) >= 6 | >= 12 | 34 | 64 bit *) // # define BN_prime_checks_for_size(b) ((b) >= 3747 ? 3 : \ // (b) >= 1345 ? 4 : \ // (b) >= 476 ? 5 : \ // (b) >= 400 ? 6 : \ // (b) >= 347 ? 7 : \ // (b) >= 308 ? 8 : \ // (b) >= 55 ? 27 : \ // (* b >= 6 *) 34) // // # define BN_num_bytes(a) ((BN_num_bits(a)+7)/8) function BN_abs_is_word(a: PBIGNUM; w: BN_ULONG): TIdC_INT; function BN_is_zero(a: PBIGNUM): TIdC_INT; function BN_is_one(a: PBIGNUM): TIdC_INT; function BN_is_word(a: PBIGNUM; w: BN_ULONG): TIdC_INT; function BN_is_odd(a: PBIGNUM): TIdC_INT; // # define BN_one(a) (BN_set_word((a),1)) procedure BN_zero_ex(a: PBIGNUM); function BN_value_one: PBIGNUM; function BN_options: PIdAnsiChar; function BN_CTX_new: PBN_CTX; function BN_CTX_secure_new: PBN_CTX; procedure BN_CTX_free(c: PBN_CTX); procedure BN_CTX_start(ctx: PBN_CTX); function BN_CTX_get(ctx: PBN_CTX): PBIGNUM; procedure BN_CTX_end(ctx: PBN_CTX); function BN_rand(rnd: PBIGNUM; bits: TIdC_INT; top: TIdC_INT; bottom: TIdC_INT): TIdC_INT; function BN_priv_rand(rnd: PBIGNUM; bits: TIdC_INT; top: TIdC_INT; bottom: TIdC_INT): TIdC_INT; function BN_rand_range(rnd: PBIGNUM; range: PBIGNUM): TIdC_INT; function BN_priv_rand_range(rnd: PBIGNUM; range: PBIGNUM): TIdC_INT; function BN_pseudo_rand(rnd: PBIGNUM; bits: TIdC_INT; top: TIdC_INT; bottom: TIdC_INT): TIdC_INT; function BN_pseudo_rand_range(rnd: PBIGNUM; range: PBIGNUM): TIdC_INT; function BN_num_bits(a: PBIGNUM): TIdC_INT; function BN_num_bits_word(l: BN_ULONG): TIdC_INT; function BN_security_bits(L: TIdC_INT; N: TIdC_INT): TIdC_INT; function BN_new: PBIGNUM; function BN_secure_new: PBIGNUM; procedure BN_clear_free(a: PBIGNUM); function BN_copy(a: PBIGNUM; b: PBIGNUM): PBIGNUM; procedure BN_swap(a: PBIGNUM; b: PBIGNUM); function BN_bin2bn(const s: PByte; len: TIdC_INT; ret: PBIGNUM): PBIGNUM; function BN_bn2bin(const a: PBIGNUM; to_: PByte): TIdC_INT; function BN_bn2binpad(const a: PBIGNUM; to_: PByte; tolen: TIdC_INT): TIdC_INT; function BN_lebin2bn(const s: PByte; len: TIdC_INT; ret: PBIGNUM): PBIGNUM; function BN_bn2lebinpad(a: PBIGNUM; to_: PByte; tolen: TIdC_INT): TIdC_INT; function BN_mpi2bn(const s: PByte; len: TIdC_INT; ret: PBIGNUM): PBIGNUM; function BN_bn2mpi(a: PBIGNUM; to_: PByte): TIdC_INT; function BN_sub(r: PBIGNUM; const a: PBIGNUM; const b: PBIGNUM): TIdC_INT; function BN_usub(r: PBIGNUM; const a: PBIGNUM; const b: PBIGNUM): TIdC_INT; function BN_uadd(r: PBIGNUM; const a: PBIGNUM; const b: PBIGNUM): TIdC_INT; function BN_add(r: PBIGNUM; const a: PBIGNUM; const b: PBIGNUM): TIdC_INT; function BN_mul(r: PBIGNUM; const a: PBIGNUM; const b: PBIGNUM; ctx: PBN_CTX): TIdC_INT; function BN_sqr(r: PBIGNUM; const a: PBIGNUM; ctx: PBN_CTX): TIdC_INT; (** BN_set_negative sets sign of a BIGNUM * \param b pointer to the BIGNUM object * \param n 0 if the BIGNUM b should be positive and a value != 0 otherwise *) procedure BN_set_negative(b: PBIGNUM; n: TIdC_INT); (** BN_is_negative returns 1 if the BIGNUM is negative * \param b pointer to the BIGNUM object * \return 1 if a < 0 and 0 otherwise *) function BN_is_negative(b: PBIGNUM): TIdC_INT; function BN_div(dv: PBIGNUM; rem: PBIGNUM; const m: PBIGNUM; const d: PBIGNUM; ctx: PBN_CTX): TIdC_INT; // # define BN_mod(rem,m,d,ctx) BN_div(NULL,(rem),(m),(d),(ctx)) function BN_nnmod(r: PBIGNUM; const m: PBIGNUM; const d: PBIGNUM; ctx: PBN_CTX): TIdC_INT; function BN_mod_add(r: PBIGNUM; const a: PBIGNUM; const b: PBIGNUM; const m: PBIGNUM; ctx: PBN_CTX): TIdC_INT; function BN_mod_add_quick(r: PBIGNUM; const a: PBIGNUM; const b: PBIGNUM; const m: PBIGNUM): TIdC_INT; function BN_mod_sub(r: PBIGNUM; const a: PBIGNUM; const b: PBIGNUM; const m: PBIGNUM; ctx: PBN_CTX): TIdC_INT; function BN_mod_sub_quick(r: PBIGNUM; const a: PBIGNUM; const b: PBIGNUM; const m: PBIGNUM): TIdC_INT; function BN_mod_mul(r: PBIGNUM; const a: PBIGNUM; const b: PBIGNUM; const m: PBIGNUM; ctx: PBN_CTX): TIdC_INT; function BN_mod_sqr(r: PBIGNUM; const a: PBIGNUM; const m: PBIGNUM; ctx: PBN_CTX): TIdC_INT; function BN_mod_lshift1(r: PBIGNUM; const a: PBIGNUM; const m: PBIGNUM; ctx: PBN_CTX): TIdC_INT; function BN_mod_lshift1_quick(r: PBIGNUM; const a: PBIGNUM; const m: PBIGNUM): TIdC_INT; function BN_mod_lshift(r: PBIGNUM; const a: PBIGNUM; n: TIdC_INT; const m: PBIGNUM; ctx: PBN_CTX): TIdC_INT; function BN_mod_lshift_quick(r: PBIGNUM; const a: PBIGNUM; n: TIdC_INT; const m: PBIGNUM): TIdC_INT; function BN_mod_word(const a: PBIGNUM; w: BN_ULONG): BN_ULONG; function BN_div_word(a: PBIGNUM; w: BN_ULONG): BN_ULONG; function BN_mul_word(a: PBIGNUM; w: BN_ULONG): TIdC_INT; function BN_add_word(a: PBIGNUM; w: BN_ULONG): TIdC_INT; function BN_sub_word(a: PBIGNUM; w: BN_ULONG): TIdC_INT; function BN_set_word(a: PBIGNUM; w: BN_ULONG): TIdC_INT; function BN_get_word(const a: PBIGNUM): BN_ULONG; function BN_cmp(const a: PBIGNUM; const b: PBIGNUM): TIdC_INT; procedure BN_free(a: PBIGNUM); function BN_is_bit_set(const a: PBIGNUM; n: TIdC_INT): TIdC_INT; function BN_lshift(r: PBIGNUM; const a: PBIGNUM; n: TIdC_INT): TIdC_INT; function BN_lshift1(r: PBIGNUM; const a: PBIGNUM): TIdC_INT; function BN_exp(r: PBIGNUM; a: PBIGNUM; p: PBIGNUM; ctx: PBN_CTX): TIdC_INT; function BN_mod_exp(r: PBIGNUM; a: PBIGNUM; p: PBIGNUM; const m: PBIGNUM; ctx: PBN_CTX): TIdC_INT; function BN_mod_exp_mont(r: PBIGNUM; a: PBIGNUM; p: PBIGNUM; m: PBIGNUM; ctx: PBN_CTX; m_ctx: PBN_MONT_CTX): TIdC_INT; function BN_mod_exp_mont_consttime(rr: PBIGNUM; a: PBIGNUM; p: PBIGNUM; m: PBIGNUM; ctx: PBN_CTX; in_mont: PBN_MONT_CTX): TIdC_INT; function BN_mod_exp_mont_word(r: PBIGNUM; a: BN_ULONG; p: PBIGNUM; m: PBIGNUM; ctx: PBN_CTX; m_ctx: PBN_MONT_CTX): TIdC_INT; function BN_mod_exp2_mont(r: PBIGNUM; const a1: PBIGNUM; const p1: PBIGNUM; const a2: PBIGNUM; const p2: PBIGNUM; const m: PBIGNUM; ctx: PBN_CTX; m_ctx: PBN_MONT_CTX): TIdC_INT; function BN_mod_exp_simple(r: PBIGNUM; a: PBIGNUM; p: PBIGNUM; m: PBIGNUM; ctx: PBN_CTX): TIdC_INT; function BN_mask_bits(a: PBIGNUM; n: TIdC_INT): TIdC_INT; function BN_print(bio: PBIO; a: PBIGNUM): TIdC_INT; function BN_reciprocal(r: PBIGNUM; m: PBIGNUM; len: TIdC_INT; ctx: PBN_CTX): TIdC_INT; function BN_rshift(r: PBIGNUM; a: PBIGNUM; n: TIdC_INT): TIdC_INT; function BN_rshift1(r: PBIGNUM; a: PBIGNUM): TIdC_INT; procedure BN_clear(a: PBIGNUM); function BN_dup(const a: PBIGNUM): PBIGNUM; function BN_ucmp(a: PBIGNUM; b: PBIGNUM): TIdC_INT; function BN_set_bit(a: PBIGNUM; n: TIdC_INT): TIdC_INT; function BN_clear_bit(a: PBIGNUM; n: TIdC_INT): TIdC_INT; function BN_bn2hex(a: PBIGNUM): PIdAnsiChar; function BN_bn2dec(a: PBIGNUM): PIdAnsiChar; function BN_hex2bn(a: PPBIGNUM; str: PIdAnsiChar): TIdC_INT; function BN_dec2bn(a: PPBIGNUM; str: PIdAnsiChar): TIdC_INT; function BN_asc2bn(a: PPBIGNUM; str: PIdAnsiChar): TIdC_INT; function BN_gcd(r: PBIGNUM; a: PBIGNUM; b: PBIGNUM; ctx: PBN_CTX): TIdC_INT; function BN_kronecker(a: PBIGNUM; b: PBIGNUM; ctx: PBN_CTX): TIdC_INT; function BN_mod_inverse(ret: PBIGNUM; a: PBIGNUM; const n: PBIGNUM; ctx: PBN_CTX): PBIGNUM; function BN_mod_sqrt(ret: PBIGNUM; a: PBIGNUM; const n: PBIGNUM; ctx: PBN_CTX): PBIGNUM; procedure BN_consttime_swap(swap: BN_ULONG; a: PBIGNUM; b: PBIGNUM; nwords: TIdC_INT); function BN_generate_prime_ex(ret: PBIGNUM; bits: TIdC_INT; safe: TIdC_INT; const add: PBIGNUM; const rem: PBIGNUM; cb: PBN_GENCB): TIdC_INT; function BN_is_prime_ex(const p: PBIGNUM; nchecks: TIdC_INT; ctx: PBN_CTX; cb: PBN_GENCB): TIdC_INT; function BN_is_prime_fasttest_ex(const p: PBIGNUM; nchecks: TIdC_INT; ctx: PBN_CTX; do_trial_division: TIdC_INT; cb: PBN_GENCB): TIdC_INT; function BN_X931_generate_Xpq(Xp: PBIGNUM; Xq: PBIGNUM; nbits: TIdC_INT; ctx: PBN_CTX): TIdC_INT; function BN_X931_derive_prime_ex(p: PBIGNUM; p1: PBIGNUM; p2: PBIGNUM; const Xp: PBIGNUM; const Xp1: PBIGNUM; const Xp2: PBIGNUM; const e: PBIGNUM; ctx: PBN_CTX; cb: PBN_GENCB): TIdC_INT; function BN_X931_generate_prime_ex(p: PBIGNUM; p1: PBIGNUM; p2: PBIGNUM; Xp1: PBIGNUM; Xp2: PBIGNUM; Xp: PBIGNUM; const e: PBIGNUM; ctx: PBN_CTX; cb: PBN_GENCB): TIdC_INT; function BN_MONT_CTX_new: PBN_MONT_CTX; function BN_mod_mul_montgomery(r: PBIGNUM; const a: PBIGNUM; const b: PBIGNUM; mont: PBN_MONT_CTX; ctx: PBN_CTX): TIdC_INT; function BN_to_montgomery(r: PBIGNUM; a: PBIGNUM; mont: PBN_MONT_CTX; ctx: PBN_CTX): TIdC_INT; function BN_from_montgomery(r: PBIGNUM; a: PBIGNUM; mont: PBN_MONT_CTX; ctx: PBN_CTX): TIdC_INT; procedure BN_MONT_CTX_free(mont: PBN_MONT_CTX); function BN_MONT_CTX_set(mont: PBN_MONT_CTX; mod_: PBIGNUM; ctx: PBN_CTX): TIdC_INT; function BN_MONT_CTX_copy(to_: PBN_MONT_CTX; from: PBN_MONT_CTX): PBN_MONT_CTX; // function BN_MONT_CTX_set_locked(pmont: ^PBN_MONT_CTX; lock: CRYPTO_RWLOCK; mod_: PBIGNUM; ctx: PBN_CTX): PBN_MONT_CTX; function BN_BLINDING_new(const A: PBIGNUM; const Ai: PBIGNUM; mod_: PBIGNUM): PBN_BLINDING; procedure BN_BLINDING_free(b: PBN_BLINDING); function BN_BLINDING_update(b: PBN_BLINDING; ctx: PBN_CTX): TIdC_INT; function BN_BLINDING_convert(n: PBIGNUM; b: PBN_BLINDING; ctx: PBN_CTX): TIdC_INT; function BN_BLINDING_invert(n: PBIGNUM; b: PBN_BLINDING; ctx: PBN_CTX): TIdC_INT; function BN_BLINDING_convert_ex(n: PBIGNUM; r: PBIGNUM; b: PBN_BLINDING; v4: PBN_CTX): TIdC_INT; function BN_BLINDING_invert_ex(n: PBIGNUM; r: PBIGNUM; b: PBN_BLINDING; v2: PBN_CTX): TIdC_INT; function BN_BLINDING_is_current_thread(b: PBN_BLINDING): TIdC_INT; procedure BN_BLINDING_set_current_thread(b: PBN_BLINDING); function BN_BLINDING_lock(b: PBN_BLINDING): TIdC_INT; function BN_BLINDING_unlock(b: PBN_BLINDING): TIdC_INT; function BN_BLINDING_get_flags(v1: PBN_BLINDING): TIdC_ULONG; procedure BN_BLINDING_set_flags(v1: PBN_BLINDING; v2: TIdC_ULONG); // function BN_BLINDING_create_param(PBN_BLINDING *b, // PBIGNUM *e, PBIGNUM *m, PBN_CTX *ctx, // function ( // r: PBIGNUM; // a: PBIGNUM; // p: PBIGNUM; // m: PBIGNUM; // ctx: PBN_CTX; // m_ctx: PBN_MONT_CTX): TIdC_INT, // PBN_MONT_CTX *m_ctx): PBN_BLINDING; procedure BN_RECP_CTX_free(recp: PBN_RECP_CTX); function BN_RECP_CTX_set(recp: PBN_RECP_CTX; rdiv: PBIGNUM; ctx: PBN_CTX): TIdC_INT; function BN_mod_mul_reciprocal(r: PBIGNUM; x: PBIGNUM; y: PBIGNUM; recp: PBN_RECP_CTX; ctx: PBN_CTX): TIdC_INT; function BN_mod_exp_recp(r: PBIGNUM; a: PBIGNUM; p: PBIGNUM; m: PBIGNUM; ctx: PBN_CTX): TIdC_INT; function BN_div_recp(dv: PBIGNUM; rem: PBIGNUM; m: PBIGNUM; recp: PBN_RECP_CTX; ctx: PBN_CTX): TIdC_INT; (* * Functions for arithmetic over binary polynomials represented by BIGNUMs. * The BIGNUM::neg property of BIGNUMs representing binary polynomials is * ignored. Note that input arguments are not const so that their bit arrays * can be expanded to the appropriate size if needed. *) (* * r = a + b *) function BN_GF2m_add(r: PBIGNUM; a: PBIGNUM; b: PBIGNUM): TIdC_INT; // # define BN_GF2m_sub(r, a, b) BN_GF2m_add(r, a, b) (* * r=a mod p *) function BN_GF2m_mod(r: PBIGNUM; a: PBIGNUM; p: PBIGNUM): TIdC_INT; (* r = (a * b) mod p *) function BN_GF2m_mod_mul(r: PBIGNUM; a: PBIGNUM; b: PBIGNUM; p: PBIGNUM; ctx: PBN_CTX): TIdC_INT; (* r = (a * a) mod p *) function BN_GF2m_mod_sqr(r: PBIGNUM; a: PBIGNUM; p: PBIGNUM; ctx: PBN_CTX): TIdC_INT; (* r = (1 / b) mod p *) function BN_GF2m_mod_inv(r: PBIGNUM; b: PBIGNUM; p: PBIGNUM; ctx: PBN_CTX): TIdC_INT; (* r = (a / b) mod p *) function BN_GF2m_mod_div(r: PBIGNUM; a: PBIGNUM; b: PBIGNUM; p: PBIGNUM; ctx: PBN_CTX): TIdC_INT; (* r = (a ^ b) mod p *) function BN_GF2m_mod_exp(r: PBIGNUM; a: PBIGNUM; b: PBIGNUM; p: PBIGNUM; ctx: PBN_CTX): TIdC_INT; (* r = sqrt(a) mod p *) function BN_GF2m_mod_sqrt(r: PBIGNUM; a: PBIGNUM; p: PBIGNUM; ctx: PBN_CTX): TIdC_INT; (* r^2 + r = a mod p *) function BN_GF2m_mod_solve_quad(r: PBIGNUM; a: PBIGNUM; p: PBIGNUM; ctx: PBN_CTX): TIdC_INT; // # define BN_GF2m_cmp(a, b) BN_ucmp((a), (b)) (*- * Some functions allow for representation of the irreducible polynomials * as an unsigned int[], say p. The irreducible f(t) is then of the form: * t^p[0] + t^p[1] + ... + t^p[k] * where m = p[0] > p[1] > ... > p[k] = 0. *) (* r = a mod p *) // function BN_GF2m_mod_arr(r: PBIGNUM; a: PBIGNUM; p: array of TIdC_INT): TIdC_INT; (* r = (a * b) mod p *) // function BN_GF2m_mod_mul_arr(r: PBIGNUM; a: PBIGNUM; p: PBIGNUM; p: array of TIdC_INT; ctx: PBN_CTX): TIdC_INT; (* r = (a * a) mod p *) // function BN_GF2m_mod_sqr_arr(r: PBIGNUM; a: PBIGNUM; p: array of TIdC_INT; ctx: PBN_CTX): TIdC_INT; (* r = (1 / b) mod p *) // function BN_GF2m_mod_inv_arr(r: PBIGNUM; b: PBIGNUM; p: array of TIdC_INT; ctx: PBN_CTX): TIdC_INT; (* r = (a / b) mod p *) // function BN_GF2m_mod_div_arr(r: PBIGNUM; a: PBIGNUM; b: PBIGNUM; p: array of TIdC_INT; ctx: PBN_CTX): TIdC_INT; (* r = (a ^ b) mod p *) // function BN_GF2m_mod_exp_arr(r: PBIGNUM; a: PBIGNUM; b: PBIGNUM; p: array of TIdC_INT; ctx: PBN_CTX): TIdC_INT; (* r = sqrt(a) mod p *) // function BN_GF2m_mod_sqrt_arr(r: PBIGNUM; a: PBIGNUM; p: array of TIdC_INT; ctx: PBN_CTX): TIdC_INT; (* r^2 + r = a mod p *) // function BN_GF2m_mod_solve_quad_arr(r: PBIGNUM; a: PBIGNUM; p: array of TIdC_INT; ctx: PBN_CTX): TIdC_INT; // function BN_GF2m_poly2arr(a: PBIGNUM; p: array of TIdC_INT; max: TIdC_INT): TIdC_INT; // function BN_GF2m_arr2poly(p: array of TIdC_INT; a: PBIGNUM): TIdC_INT; (* * faster mod functions for the 'NIST primes' 0 <= a < p^2 *) function BN_nist_mod_192(r: PBIGNUM; a: PBIGNUM; p: PBIGNUM; ctx: PBN_CTX): TIdC_INT; function BN_nist_mod_224(r: PBIGNUM; a: PBIGNUM; p: PBIGNUM; ctx: PBN_CTX): TIdC_INT; function BN_nist_mod_256(r: PBIGNUM; a: PBIGNUM; p: PBIGNUM; ctx: PBN_CTX): TIdC_INT; function BN_nist_mod_384(r: PBIGNUM; a: PBIGNUM; p: PBIGNUM; ctx: PBN_CTX): TIdC_INT; function BN_nist_mod_521(r: PBIGNUM; a: PBIGNUM; p: PBIGNUM; ctx: PBN_CTX): TIdC_INT; function BN_get0_nist_prime_192: PBIGNUM; function BN_get0_nist_prime_224: PBIGNUM; function BN_get0_nist_prime_256: PBIGNUM; function BN_get0_nist_prime_384: PBIGNUM; function BN_get0_nist_prime_521: PBIGNUM; //int (*BN_nist_mod_func(const BIGNUM *p)) (BIGNUM *r, const BIGNUM *a, // const BIGNUM *field, BN_CTX *ctx); function BN_generate_dsa_nonce(out_: PBIGNUM; range: PBIGNUM; priv: PBIGNUM; const message_: PByte; message_len: TIdC_SIZET; ctx: PBN_CTX): TIdC_INT; (* Primes from RFC 2409 *) function BN_get_rfc2409_prime_768(bn: PBIGNUM ): PBIGNUM; function BN_get_rfc2409_prime_1024(bn: PBIGNUM): PBIGNUM; (* Primes from RFC 3526 *) function BN_get_rfc3526_prime_1536(bn: PBIGNUM): PBIGNUM; function BN_get_rfc3526_prime_2048(bn: PBIGNUM): PBIGNUM; function BN_get_rfc3526_prime_3072(bn: PBIGNUM): PBIGNUM; function BN_get_rfc3526_prime_4096(bn: PBIGNUM): PBIGNUM; function BN_get_rfc3526_prime_6144(bn: PBIGNUM): PBIGNUM; function BN_get_rfc3526_prime_8192(bn: PBIGNUM): PBIGNUM; function BN_bntest_rand(rnd: PBIGNUM; bits: TIdC_INT; top: TIdC_INT; bottom: TIdC_INT): TIdC_INT; implementation end.
(****************************************************************************** PROYECTO FACTURACION ELECTRONICA Copyright (C) 2010-2014 - Bambu Code SA de CV - Ing. Luis Carrasco Libreria usada para interactuar con la libreria OpenSSL y exportar sus metodos de hashing/digestion usando una llave privada. Este archivo pertenece al proyecto de codigo abierto de Bambu Code: http://bambucode.com/codigoabierto La licencia de este codigo fuente se encuentra en: http://github.com/bambucode/tfacturaelectronica/blob/master/LICENCIA ******************************************************************************) unit ClaseOpenSSL; interface uses libeay32, SysUtils, Windows, OpenSSLUtils, libeay32plus; type {$IF Compilerversion >= 20} TCadenaUTF8 = RawByteString; {$ELSE} TCadenaUTF8 = UTF8String; {$IFEND} TTipoDigestionOpenSSL = (tdMD5, tdSHA1); ENoExisteArchivoException = class(Exception); ECertificadoLlaveEsFiel = class(Exception); ECertificadoFallaLecturaException = class(Exception); ELlaveFormatoIncorrectoException = class(Exception); ELlaveLecturaException = class(Exception); ELlavePrivadaClaveIncorrectaException = class(Exception); ELlavePareceSerFiel = class(Exception); ELongitudBufferPequenoException = class(Exception); ///<summary>Clase que representa a la liberia OpenSSL y que tiene /// metodos usados para generar el sello digital (digestion md5) y /// lectura de la llave privada en su formato nativo binario (.key) ///</summary> TOpenSSL = class private fArchivoLlavePrivada: String; fClaveLlavePrivada: String; private function ObtenerLlavePrivadaDesencriptada(const aRutaLlavePrivada, aClaveLlavePrivada: String): pEVP_PKEY; ///<summary>Funcion usada para convertir un buffer de bytes /// en caracteres 'imprimibles' (codificacion base64). ///</summary> function BinToBase64(const PDat: PBYTE; const DatLen: DWORD): String; function ObtenerUltimoMensajeDeError: string; public /// <summary>Crea el objeto, inicializa la liberia OpenSSL, y establece la llave privada a usar</summary> constructor Create(); overload; /// <summary>Prueba abrir la llave privada, si tiene exito regresa informacion de la llave, si falla /// lanza una excepcion segun el tipo de error que se tuvo</summary> /// <param name="Ruta">Ruta completa al archivo de llave privada a usar /// (archivo con extension .key)</param> /// <param name="ClaveLlavePrivada">La clave privada a usar para abrir el archivo de llave privada</param> function AbrirLlavePrivada(Ruta, ClaveLlavePrivada : String) : pPKCS8_Priv_Key_Info; {$REGION 'Documentation'} /// <summary> /// Hace una digestion (hashing) de la Cadena segun el Tipo de /// digestion y regresa el resultado en formato base64 /// </summary> /// <param name="ArchivoLlavePrivada"> /// Ruta completa al archivo de llave privada a usar (archivo con /// extension .key) /// </param> /// <param name="ClaveLlavePrivada"> /// La clave privada a usar para abrir el archivo de llave privada /// </param> /// <param name="sCadena"> /// Cadena a la cual se va a hacer la digestion (pre-codificada en /// UTF8) /// </param> /// <param name="trTipo"> /// Tipo de digestion a realizar (tdMD5, tdSHA1) /// </param> /// <remarks> /// <note type="warning"> /// Esta funcion debe de recibir RawByteString en Delphi 2009 o /// superior y tipo UTF8String en Delphi 2007 de lo contrario no /// copiara correctamente los datos en memoria regresando sellos /// invalidos. /// </note> /// </remarks> {$ENDREGION} function HacerDigestion(ArchivoLlavePrivada, ClaveLlavePrivada: String; sCadena: TCadenaUTF8; trTipo: TTipoDigestionOpenSSL) : String; /// <summary>Obtiene un certificado con sus propiedades llenas</summary> /// <param name="sArchivo">Ruta completa del archivo de certificado (extension .cer)</param> function ObtenerCertificado(sArchivo: String) : TX509Certificate; destructor Destroy; override; {$REGION 'Documentation'} /// <summary> /// <para> /// Se encarga de guardar la llave privada (previamente /// desencriptada usando el metodo AbrirLlavePrivada) a formato /// Base64 (PEM). /// </para> /// <para> /// Funcion necesaria para el timbrado/cancelacion de algunos PACs. /// </para> /// </summary> /// <param name="aLlaveAbierta"> /// Llave previamente abierta /// </param> /// <param name="aArchivoDestino"> /// Ruta del archivo .PEM a guardar /// </param> {$ENDREGION} procedure GuardarLlavePrivadaEnPEM(const aLlaveAbierta: pPKCS8_Priv_Key_Info; const aArchivoDestino: String); function ObtenerModulusDeCertificado(const aRutaCertificado: string): String; function ObtenerModulusDeLlavePrivada(const aRutaLlavePrivada, aClaveLlavePrivada: String): String; end; implementation uses {$IFDEF CODESITE} CodeSiteLogging, {$ENDIF} StrUtils; constructor TOpenSSL.Create(); begin OpenSSL_add_all_algorithms; OpenSSL_add_all_ciphers; OpenSSL_add_all_digests; ERR_load_crypto_strings; end; destructor TOpenSSL.Destroy; begin EVP_cleanup; inherited; end; // Funcion obtenida de: DelphiAccess - http://www.delphiaccess.com/forum/index.php?topic=3092.0 // Usuario: axesys function TOpenSSL.BinToBase64(const PDat: PBYTE; const DatLen: DWORD): string; const BaseTable: string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; var s, s1: string; i, p, len, n, Addnum: DWORD; PBin: PBYTE; begin result := ''; S := ''; addnum := 0; PBin := PDat; for i := 1 to DatLen do begin S := S + IntToHex(PBin^, 2); PBin := PBYTE(DWORD(PDat) + i); end; case (length(s) mod 3) of 0: addnum := 0; 1: begin s := s + '00'; addnum := 2; end; 2: begin s := s + '0'; addnum := 1; end; end; len := length(s) div 3; for i := 1 to len do begin s1 := midstr(S, i * 3 - 2, 3); p := strtoint('$' + s1); n := p div 64; result := result + basetable[n + 1]; n := p mod 64; result := result + basetable[n + 1]; end; if addnum = 1 then result := result + '=='; if addnum = 2 then result[length(result)] := '='; end; // Regresa el ultimo mensaje de error reportado por la liberia de OpenSSL // Funcion copiada de OpenSSLUtils.pas de Marco Ferrante function TOpenSSL.ObtenerUltimoMensajeDeError: string; var {$IF CompilerVersion >= 20} ErrMsg: array [0..160] of AnsiChar; {$ELSE} ErrMsg: array [0..160] of Char; {$IFEND} begin {$WARNINGS OFF} ERR_error_string(ERR_get_error, @ErrMsg); result := StrPas(PAnsiChar(@ErrMsg)); {$WARNINGS ON} end; procedure TOpenSSL.GuardarLlavePrivadaEnPEM(const aLlaveAbierta: pPKCS8_Priv_Key_Info; const aArchivoDestino: String); var bioArchivoPEM: pBIO; begin bioArchivoPEM := BIO_new(BIO_s_file()); try if BIO_write_filename(bioArchivoPEM, ToChar(aArchivoDestino)) = 0 then raise Exception.Create('Error al intentar guardar llave privada en formato PEM:' + ObtenerUltimoMensajeDeError()) else PEM_write_bio_PKCS8_PRIV_KEY_INFO(bioArchivoPEM, aLlaveAbierta); finally BIO_free(bioArchivoPEM); end; end; function TOpenSSL.AbrirLlavePrivada(Ruta, ClaveLlavePrivada : String) : pPKCS8_Priv_Key_Info; var bioArchivoLlave : pBIO; sMsgErr: String; p8 : pX509_SIG; p8inf : pPKCS8_Priv_Key_Info; {$IF CompilerVersion >= 20} p8pass: PAnsiChar; {$ELSE} p8pass: PChar; {$IFEND} begin // Creamos el objeto en memoria para leer la llave en formato binario .DER (.KEY) bioArchivoLlave := BIO_new(BIO_s_file()); if Not FileExists(Ruta) then Raise ENoExisteArchivoException.Create('El archivo de llave privada no existe.'); // Checamos que la extension de la llave privada sea la correcta if AnsiPos('.PEM', Uppercase(Ruta)) > 0 then Raise ELlaveFormatoIncorrectoException.Create('La llave privada debe de ser el archivo binario (.key, .cer) y ' + 'no el formato base64 .pem'); // Leemos el archivo de llave binario en el objeto creado en memoria // DIferentes parametros si usa Delphi 2009 o superior... {$IF CompilerVersion >= 20} if BIO_read_filename(bioArchivoLlave, PWideChar(AnsiString(Ruta))) = 0 then {$ELSE} if BIO_read_filename(bioArchivoLlave, PChar(AnsiString(Ruta))) = 0 then {$IFEND} raise ELlaveLecturaException.Create('Error al leer llave privada. Error reportado: '+ ObtenerUltimoMensajeDeError); // Checamos que la clave no esté vacia if Trim(ClaveLlavePrivada) = '' then raise ELlavePrivadaClaveIncorrectaException.Create('La clave de la llave privada esta vacia'); // Convertimos al tipo adecuado de acuerdo a la version de Delphi... {$IF CompilerVersion >= 20} // Delphi 2009 o superior p8pass:=PAnsiChar(AnsiString(ClaveLlavePrivada)); {$ELSE} p8pass:=PChar(AnsiString(ClaveLlavePrivada)); {$IFEND} p8:=nil; p8inf:=nil; try // Leemos la llave en formato binario (PKCS8) p8 := d2i_PKCS8_bio(bioArchivoLlave, nil); if not Assigned(p8) then raise ELlaveLecturaException.Create('Error al leer llave privada. Error reportado: '+ ObtenerUltimoMensajeDeError); // Des encriptamos la llave en memoria usando la clave proporcionada p8inf := PKCS8_decrypt(p8, p8pass, StrLen(p8pass)); if Not Assigned(p8inf) then begin sMsgErr:=ObtenerUltimoMensajeDeError; // TODO: Crear excepciones para los diferentes tipos de error que puede haber al // tratar de desencriptar la llave privada // Llave incorrecta (Mensaje exacto: 23077074:PKCS12 routines:PKCS12_pbe_crype:pkcs12 cipherfinal error) if ((AnsiPos('cipherfinal error', sMsgErr) > 0) or // clave incorrecta (AnsiPos('bad decrypt', sMsgErr) > 0)) // clave incorrecta then raise ELlavePrivadaClaveIncorrectaException.Create('La clave de la llave privada fue incorrecta') else if (AnsiPos('unknown pbe algorithm', sMsgErr) > 0) then // Clave vacia o pertenece a la FIEL Raise ELlavePareceSerFiel.Create('Al parecer la llave privada pertenece a la FIEL') else raise ELlaveLecturaException.Create('Error desconocido al desencriptar llave privada. Error reportado: '+ ObtenerUltimoMensajeDeError); end; finally // Liberamos las variables usadas en memoria X509_SIG_free(p8); BIO_free(bioArchivoLlave); end; Result:=p8inf; end; // Metodo creado por Luis Carrasco (luis@bambucode.com) con ayuda de // Marco Ferrante <marco@csita.unige.it> // Lee una llave binaria (.key) que tiene formato DER en memoria // para ser usada para hacer una digestion MD5, SHA1, etc. sin necesidad // de crear y usar un archivo PEM primero function TOpenSSL.ObtenerLlavePrivadaDesencriptada(const aRutaLlavePrivada, aClaveLlavePrivada: String): pEVP_PKEY; var p8inf : pPKCS8_Priv_Key_Info; resLlave : pEVP_PKEY; begin // Abrimos la llave privada p8inf:=AbrirLlavePrivada(aRutaLlavePrivada, aClaveLlavePrivada); // Convierte la llave de formato PKCS8 a PEM (en memoria) resLlave := EVP_PKCS82PKEY(p8inf); // Se tuvo exito al desencriptar la llave??? Result:=resLlave; // NOTA: Es responsabilidad de el metodo que llama a esta funcion de ejecutar el // siguiente codigo EVP_PKEY_free(pkey); una vez usado el resultado de la misma end; function TOpenSSL.ObtenerCertificado(sArchivo: String) : TX509Certificate; var CertX509: TX509Certificate; llavePublica: PEVP_PKEY; bioModulus: pBIO; rsaInfo: pRSA; Inbuf: Array[0..255] of AnsiChar; const _ERROR_LECTURA_CERTIFICADO = 'Unable to read certificate'; begin CertX509:=TX509Certificate.Create; try CertX509.LoadFromFile(sArchivo, DER); Result:=CertX509; except On E:Exception do begin if AnsiPos(_ERROR_LECTURA_CERTIFICADO, E.Message) > 0 then begin raise ECertificadoFallaLecturaException.Create('No fue posible leer certificado'); end; Result:=nil; end; end; end; function TOpenSSL.ObtenerModulusDeLlavePrivada(const aRutaLlavePrivada, aClaveLlavePrivada: String): String; var rsaInfo: pRSA; bioModulus: pBIO; llaveDesencriptada: pEVP_PKEY; Inbuf: Array[0..1000] of AnsiChar; longitudModulus : Integer; begin llaveDesencriptada := ObtenerLlavePrivadaDesencriptada(aRutaLlavePrivada, aClaveLlavePrivada); // Obtenemos las propiedades RSA de la Llave privada rsaInfo := EVP_PKEY_get1_RSA(llaveDesencriptada); // Creamos un BIO en memoria para almacenar el dato del Modulus bioModulus := BIO_new(BIO_s_mem()); try // Asignamos el Modulus (propieda N del record RSA, rsa.c linea 336) if rsaInfo.n <> nil then begin // La funcion BN_print copia el apuntador del BIGNUMBER del modulus con un formato amigable dentro del BIO if BN_print(bioModulus, rsaInfo.n) <= 0 then raise Exception.Create('No fue posible obtner el Modulus de la Llave Privada'); // Leemos el Modulus del BIO en el buffer de cadena longitudModulus := BIO_read(bioModulus, @Inbuf, SizeOf(Inbuf)); {$IFDEF CODESITE} CodeSite.Send('Modulus Llave Privada', Copy(StrPas(InBuf), 1, longitudModulus)); {$ENDIF}; Result := Copy(StrPas(InBuf), 1, longitudModulus); end else Result := ''; finally // Liberamos el BIO que teniamos en memoria BIO_free_all(bioModulus); EVP_PKEY_free(llaveDesencriptada); end; end; function TOpenSSL.HacerDigestion(ArchivoLlavePrivada, ClaveLlavePrivada: String; sCadena: TCadenaUTF8; trTipo: TTipoDigestionOpenSSL) : String; var mdctx: EVP_MD_CTX; {$IF CompilerVersion >= 20} Inbuf: Array[0..999999] of AnsiChar; // Antes [0..8192] Outbuf: array [0..1024] of AnsiChar; {$ELSE} Inbuf: Array[0..999999] of Char; Outbuf: array [0..1024] of Char; {$IFEND} ekLlavePrivada: pEVP_PKEY; Len, Tam: cardinal; begin fArchivoLlavePrivada:=ArchivoLlavePrivada; fClaveLlavePrivada:= ClaveLlavePrivada; Len:=0; ekLlavePrivada := ObtenerLlavePrivadaDesencriptada(fArchivoLlavePrivada, fClaveLlavePrivada); //SetLength(Inbuf, 8192); // StrLen(@sCadena) //SetCodePage(sCadena, 0, False); // Forzamos a eliminar el "Code Page" de la cadena Tam:=Length(sCadena); // Obtenemos el tamaño de la cadena original try StrPLCopy(inbuf, sCadena, Tam); // Copiamos la cadena original al buffer de entrada except On E:Exception do begin if Pos('Access', E.Message) > 0 then Raise ELongitudBufferPequenoException.Create('Error de sellado digital: La cadena original fue mas grande que el tamaño del buffer,' + 'por favor intente aumentando el tamaño del buffer.'); end; end; if not Assigned(ekLlavePrivada) then Raise ELlaveLecturaException.Create('No fue posible leer la llave privada'); // Establecemos el tipo de digestion a realizar case trTipo of tdMD5: EVP_SignInit(@mdctx,EVP_md5()); tdSHA1: EVP_SignInit(@mdctx,EVP_sha1()); end; // Establece los datos que vamos a usar EVP_SignUpdate(@mdctx,@inbuf,StrLen(inbuf)); // Realiza la digestion usando la llave privada que obtuvimos y leimos en memoria EVP_SignFinal(@mdctx,@outbuf,Len,ekLlavePrivada); // Liberamos el puntero a la llave privada usada previamente EVP_PKEY_free(ekLlavePrivada); // Regresa los resultados en formato Base64 Result := BinToBase64(@outbuf,Len); end; function TOpenSSL.ObtenerModulusDeCertificado(const aRutaCertificado: string): String; var llavePublica: PEVP_PKEY; bioModulus: pBIO; rsaInfo: pRSA; Inbuf: Array[0..1000] of AnsiChar; certificadoX509: TX509Certificate; longitudModulus: Integer; begin bioModulus := BIO_new(BIO_s_mem()); try certificadoX509 := TX509Certificate.Create; certificadoX509.LoadFromFile(aRutaCertificado); // Obtenemos la llave publica del certificado llavePublica := X509_get_pubkey(certificadoX509.fCertificate); if (llavePublica <> nil) then begin // Replicamos el codigo de x509.c lineas 820 -> 830 if llavePublica.ktype = EVP_PKEY_RSA then begin rsaInfo := EVP_PKEY_get1_RSA(llavePublica); if BN_print(bioModulus, rsaInfo.n) <= 0 then raise Exception.Create('No fue posible obtener el Modulus del Certificado'); // Leemos el Modulus del BIO en el buffer de cadena longitudModulus := BIO_read(bioModulus, @Inbuf, SizeOf(Inbuf)); {$IFDEF CODESITE} CodeSite.Send('Modulus Certificado', Copy(StrPas(InBuf), 1, longitudModulus)); {$ENDIF}; Result := Copy(StrPas(InBuf), 1, longitudModulus); end else raise Exception.Create('No se soporta la lectura de certificados que no son RSA'); end; finally BIO_free_all(bioModulus); certificadoX509.Free; end; end; initialization finalization end.
unit FMX.CodeReader; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Filter.Effects, FMX.Layouts, FMX.Controls.Presentation, FMX.StdCtrls, FMX.Objects, System.IOUtils, System.Messaging, FMX.Media, FMX.Surfaces, FMX.Platform, DW.Camera, DW.Types, DW.NativeImage, ZXing.ScanManager, ZXing.BarcodeFormat, ZXing.ReadResult, FMX.Android.Permissions; Type TCodeType = (Code1DVertical, Code1DHorizontal, Code2D); TCodeResult = Procedure (aCode : String) Of Object; [ComponentPlatformsAttribute (pidAllPlatforms)] TCodeReader = Class(TControl) Private FCamera : TCamera; FPreview : TLayout; FMask : TNativeImage; FIcon : TNativeImage; FScan : TScanManager; FTimer : TTimer; FImageStream : TMemoryStream; FCodeType : TCodeType; FOnCodeReady : TCodeResult; FAudio : TMediaPlayer; FIconColor : TAlphaColor; FIcoQRCode : TBitmap; FIcoBarcode : TBitmap; FicoBarCode90 : TBitmap; FInProcess : Boolean; FPlaySound : Boolean; FShowMask : Boolean; FShowIconTypes : Boolean; FText : String; FTextCheck : String; FMaxImageWidth : Integer; FValidSamples : Integer; FValidCount : Integer; FImageHeight : Integer; FImageWidth : Integer; FTimerThread : Cardinal; FOnImageCaptured : TNotifyEvent; FOnStop : TNotifyEvent; FOnStart : TNotifyEvent; function GetIsActive : Boolean; function GetBeepVolume : Single; procedure SetCodeType (const Value: TCodeType); procedure SetIconColor (const Value: TAlphaColor); procedure SetBeepVolume (const Value: Single); procedure AppEventMessage (const Sender: TObject; const M: TMessage); procedure CameraImageCaptured(Sender: TObject; const AImageStream: TStream); procedure TimerSampling (Sender: TObject); procedure TypeSelect (Sender: TObject); Procedure CreateMask; procedure CreateCamera; procedure ShowIcon; Protected Procedure Resize; Override; Procedure DoCodeReady; Virtual; Procedure Click; Override; PRocedure Paint; Override; Public Constructor Create(aOwner : TComponent); Override; Destructor Destroy; Override; Procedure Start; Procedure Stop; Property IsActive : Boolean Read GetIsActive; Published Property CodeType : TCodeType Read FCodeType Write SetCodeType; Property ShowMask : Boolean Read FShowMask Write FShowMask; Property ShowIconTypes : Boolean Read FShowIconTypes Write FShowIconTypes; Property InProcess : Boolean Read FInProcess; Property PlaySound : Boolean Read FPlaySound Write FPlaySound; Property BeepVolume : Single Read GetBeepVolume Write SetBeepVolume; Property Text : String Read FText; Property IConColor : TAlphaColor Read FIconColor Write SetIconColor; Property MaxImageWidth : Integer Read FMaxImageWidth Write FmaxImageWidth; Property ValidSamples : Integer Read FValidSamples Write FValidSamples; Property ImageWidth : Integer Read FImageWidth; Property ImageHeight : Integer Read FImageHeight; Property ImageStream : TMemoryStream Read FImageStream; Property OnCodeReady : TCodeResult Read FOnCodeReady Write FOnCodeReady; Property OnImageCaptured : TNotifyEvent Read FOnImageCaptured Write FOnImageCaptured; Property OnStart : TNotifyEvent Read FOnStart Write FOnStart; Property OnStop : TNotifyEvent Read FOnStop Write FOnStop; Property HitTest; Property Width; Property Height; Property Size; Property Position; Property Align; Property Anchors; Property Padding; Property Margins; Property Enabled; Property Visible; End; implementation {$R ..\pkg\FMX.Resources.res } { TCodeReader } Procedure TCodeReader.CreateCamera; Begin FCamera := TCamera.Create; FCamera.CameraPosition := TDevicePosition.Back; FCamera.OnImageCaptured := CameraImageCaptured; FCamera.OnAuthorizationStatus := Nil; FCamera.OnStatusChange := Nil; FCamera.PreviewControl.Parent := FPreview; FCamera.MaxImageWidth := FMaxImageWidth; FCamera.MaxPreviewWidth := 720; End; constructor TCodeReader.Create(aOwner: TComponent); Procedure CreatePreview; Begin FPreview := TLayout.Create(Self); FPreview.Stored := False; FPreview.Align := TAlignLayout.Contents; FPreview.Parent := Self; FPreview.Visible := False; FPreview.HitTest := False; End; Procedure CreateMaskView; Begin FMask := TNativeImage.Create(Self); FMask.Stored := False; FMask.Align := TAlignLayout.Client; FMask.Parent := Self; FMask.Visible := False; FMask.HitTest := False; FMask.BringToFront; End; Procedure CreateTimer; Begin FTimer := TTimer.Create(Self); FTimer.Stored := False; FTimer.Enabled := False; FTimer.OnTimer := TimerSampling; End; Procedure CreateBeep; Var LRC : TResourceStream; LAudioPath : String; Begin LAudioPath := System.IOUtils.TPath.Combine(System.IOUtils.TPath.GetDocumentsPath, 'beep.wav'); If Not FileExists(LAudioPath) Then Begin LRC := TResourceStream.Create(HInstance, 'is_Beep', RT_RCDATA); LRC.SaveToFile(LAudioPath); LRC.DisposeOf; End; FAudio := TMediaPlayer.Create(Self); FAudio.Stored := False; FAudio.FileName := LAudioPath; End; Procedure CreateIcons; Var LRC : TResourceStream; Begin FIcoQRCode := TBitmap.Create; FIcoBarcode := TBitmap.Create; FIcoBarCode90 := TBitmap.Create; FIcon := TNativeImage.Create(Self); FIcon.Stored := False; FIcon.Parent := Self; FIcon.Tag := 0; FIcon.OnClick := TypeSelect; FIcon.HitTest := True; FIcon.Visible := False; LRC := TResourceStream.Create(HInstance, 'is_QRCodeScan', RT_RCDATA); FIcoQRCode.LoadFromStream(LRC); LRC.DisposeOf; LRC := TResourceStream.Create(HInstance, 'is_BarCodeScan', RT_RCDATA); FIcoBarCode .LoadFromStream(LRC); FIcoBarCode90.LoadFromStream(LRC); LRC.DisposeOf; FIcoBarCode90.Rotate(90); End; begin inherited; CreatePreview; CreateMaskView; CreateTimer; CreateBeep; CreateIcons; FCamera := Nil; ClipChildren := True; FPlaySound := True; FShowMask := True; FShowIconTypes := True; FMaxImageWidth := 2100; FValidSamples := 2; FValidCount := 0; IconColor := TAlphaColors.White; FImageStream := TMemoryStream.Create; FScan := TScanManager .Create(TBarcodeFormat.Auto, Nil); FCodeType := TCodeType.Code1DVertical; TMessageManager.DefaultManager.SubscribeToMessage(TApplicationEventMessage, AppEventMessage); SetSize(100, 100); end; destructor TCodeReader.Destroy; begin If FCamera <> Nil Then Begin if FCamera.IsActive then Begin While FInProcess do Sleep(50); FCamera.IsActive := False; End; FCamera.DisposeOf; End; FPreview .DisposeOf; FMask .DisposeOf; FImageStream .DisposeOf; FScan .DisposeOf; FIcoQRCode .DisposeOf; FIcoBarcode .DisposeOf; FIcoBarCode90.DisposeOf; FIcon .DisposeOf; inherited; end; procedure TCodeReader.AppEventMessage(const Sender: TObject; const M: TMessage); var LEvent: TApplicationEvent; begin LEvent := TApplicationEventMessage(M).Value.Event; If LEvent = TApplicationEvent.EnteredBackground Then Stop; end; procedure TCodeReader.DoCodeReady; begin TTHread.Queue(Nil, Procedure Begin FTextCheck := ''; FAudio.Play; OnCodeReady(FText); End); end; procedure TCodeReader.CameraImageCaptured(Sender: TObject; const AImageStream: TStream); Var {$IFDEF IOS} LSurf : TBitmapSurface; {$ENDIF} T : Cardinal; W, H : Integer; X, Y : Integer; Off : Integer; Buf : TArray<Byte>; Lums : TArray<Byte>; begin if FInProcess then Exit; FInProcess := True; FText := ''; FTimerThread := TThread.GetTickCount; FImageWidth := FCamera.CapturedWidth; FImageHeight := FCamera.CapturedHeight; {$IFDEF ANDROID} If FCamera.CameraOrientation = 90 Then Begin T := AImageStream.Size; H := FCamera.CapturedHeight; AImageStream.Position := 0; SetLength(Buf, AImageStream.Size); AImageStream.Read(Buf, AImageStream.Size); case Self.CodeType of Code1DVertical: Begin W := Trunc(FCamera.CapturedWidth); H := Trunc(FCamera.CapturedHeight/4); SetLength(Lums, W*H); for Y := Trunc(H*1.5) to Trunc(H*1.5)+H-1 do System.Move(Buf[W*Y], Lums[W*(Y-Trunc(H*1.5))], W); End; Code1DHorizontal: Begin W := Trunc(FCamera.CapturedWidth/4); Off := Trunc(W *1.5); SetLength(Lums, W*H); for Y := 0 to H-1 do System.Move(Buf[FCamera.CapturedWidth*Y+Off], Lums[W*Y], W); End; Code2D: Begin W := Trunc(FCamera.CapturedWidth/2); Off := Trunc(FCamera.CapturedWidth/4); SetLength(Lums, W*H); for Y := 0 to H-1 do System.Move(Buf[FCamera.CapturedWidth*Y+Off], Lums[W*Y], W); End; end; FImageWidth := W; FImageHeight := H; FImageStream.Clear; FImageStream.WriteData(Lums, W*H); End Else Begin FImageStream.Clear; FImageStream.LoadFromStream(AImageStream); End; {$ELSE} FImageStream.Clear; FImageStream.LoadFromStream(AImageStream); {$ENDIF} FImageStream.Position := 0; if Assigned(FOnImageCaptured) then OnImageCaptured(Self); TThread.CreateAnonymousThread( Procedure Var Code : TReadResult; Begin Try {$IFDEF IOS} LSurf := TBitmapSurface.Create; LSurf.SetSize(FImageWidth, FImageHeight); TBitmapCodecManager.LoadFromStream(FImageStream, LSurf, 0); Code := FScan.Scan(LSurf); LSurf.DisposeOf; {$ELSE} Code := FScan.Scan(FImageStream, FImageWidth, FImageHeight); {$ENDIF} if Code <> Nil then Begin if Code.Text <> FTextCheck then FValidCount := 0; if FValidCount = 0 then FTextCheck := Code.Text; if FTextCheck = Code.text then Inc(FValidCount); if FValidCount = FValidSamples then FText := Code.text; Code.DisposeOf; End Else FValidCount := 0; Except End; FInProcess := False; if Not(FText.IsEmpty) And Assigned(OnCodeReady) then DoCodeReady; FTimer.Interval := 25; FTimer.Enabled := True; End).Start; end; procedure TCodeReader.Click; begin inherited; If FCamera.IsActive Then FCamera.DoFocus; end; procedure TCodeReader.TimerSampling(Sender: TObject); begin FTimer.Enabled := False; FScan .EnableQRCode := FCodeType = TCodeType.Code2D; if Assigned(FCamera) And FCamera.IsActive Then If Not(FInProcess) then Begin FCamera.CaptureImage; End Else Begin FTimer.Interval := 400; FTimer.Enabled := FCamera.IsActive; End; end; procedure TCodeReader.CreateMask; Var LBitmap : TBitmap; LStream : TMemoryStream; LRect : TRectF; LEffect : TColorKeyAlphaEffect; W, H, S : Single; LScr : IFMXScreenService; begin if FShowMask then Begin if TPlatformServices.Current.SupportsPlatformService(IFMXScreenService, LScr) then S := LScr.GetScreenScale Else S := 1; W := Width * S; H := Height * S; LEffect := TColorKeyAlphaEffect.Create(Self); LStream := TMemoryStream.Create; LBitmap := TBitmap.Create; LBitmap.SetSize(Trunc(W), Trunc(H)); LBitmap.Clear(TalphaColors.Null); LBitmap.Canvas.BeginScene; case FCodeType of Code1DVertical : LRect := TRectF.Create(W/2 - (50*S), 10*S, W/2+(50*S), H-(10*S)); Code1DHorizontal : LRect := TRectF.Create((10*S), H/2 - (50*S), W-(10*S), H/2+(50*S)); Code2D : LRect := TRectF.Create(W/2-(150*S), H/2-(150*S), W/2+(150*S), H/2+(150*S)); end; LBitmap.Canvas.Fill.Color := TAlphaColors.Black; LBitmap.Canvas.FillRect(TRectF.Create(0, 0, W, H), 0, 0, [], 0.6); LBitmap.Canvas.Fill.Color := TAlphaColors.White; LBitmap.Canvas.FillRect(LRect, 12*S, 12*S, AllCorners, 1); LBitmap.Canvas.EndScene; LEffect.ColorKey := TAlphaColorRec.White; LEffect.Tolerance := 0.1; LEffect.ProcessEffect(LBitmap.Canvas, LBitmap, 0); LBitmap.SaveToStream(LStream); FMask.LoadFromStream(LStream); LStream.DisposeOf; LBitmap.DisposeOf; LEffect.DisposeOf; FMask.BringToFront; FIcon.BringToFront; End; ShowIcon; end; procedure TCodeReader.Resize; begin inherited; CreateMask; end; procedure TCodeReader.ShowIcon; begin if FShowIconTypes then Begin FIcon.Width := 40; FIcon.Height := 40; FIcon.Position.X := Width - 48; FIcon.Position.Y := 8; case FCodeType of Code1DVertical : FIcon.LoadFromBitmap(FIcoBarCode90); Code1DHorizontal : FIcon.LoadFromBitmap(FIcoBarCode); Code2D : FIcon.LoadFromBitmap(FIcoQRCode); end; FIcon.BringToFront; End; end; procedure TCodeReader.TypeSelect(Sender: TObject); Var T : Integer; begin T := FIcon.Tag; Inc(T); if T > 2 then T := 0; case T of 0 : SetCodeType(TCodeType.Code1DHorizontal); 1 : SetCodeType(TCodeType.Code1DVertical); 2 : SetCodeType(TCodeType.Code2D); end; FIcon.Tag := T; end; procedure TCodeReader.SetCodeType(const Value: TCodeType); begin If FCodeType <> Value Then Begin FCodeType := Value; CreateMask; End; end; procedure TCodeReader.SetIconColor(const Value: TAlphaColor); Var LEffect : TFillRGBEffect; begin FIconColor := Value; LEffect := TFillRGBEffect.Create(Self); LEffect.Color := FIconColor; LEffect.ProcessEffect(FIcoQRCode .Canvas, FIcoQRCode, 0); LEffect.ProcessEffect(FIcoBarCode .Canvas, FIcoBarCode, 0); LEffect.ProcessEffect(FIcoBarCode90.Canvas, FIcoBarCode90, 0); LEffect.DisposeOf; ShowIcon; end; function TCodeReader.GetIsActive: Boolean; begin Result := (FCamera <> Nil) And FCamera.IsActive; end; function TCodeReader.GetBeepVolume: Single; begin Result := FAudio.Volume; end; procedure TCodeReader.Paint; begin inherited; if (csDesigning in ComponentState) And Not Locked then DrawDesignBorder; end; procedure TCodeReader.SetBeepVolume(const Value: Single); begin FAudio.Volume := Value; end; procedure TCodeReader.Start; begin if FCamera = Nil then CreateCamera; FPreview.Size := Self.Size; FPreview.Visible := True; FMask .Visible := FShowMask; FIcon .Visible := FShowIconTypes; FCamera .IsActive := True; FTimer .Interval := 800; FTimer .Enabled := True; FInProcess := False; if Assigned(FOnStart) then FOnStart(Self); end; procedure TCodeReader.Stop; begin while FInProcess do Sleep(50); if FCamera <> Nil then Begin FTimer .Enabled := False; FCamera .IsActive := False; FPreview.Visible := False; FMask .Visible := False; FIcon .Visible := False; FInProcess := False; if Assigned(FOnStop) then FOnStop(Self); End; end; Initialization RegisterFMXClasses([TCodeReader]); end.
unit Utils.Message; interface uses Windows, Forms, Utils.Types, SysUtils, UMensagem, Vcl.Graphics, UConfigIni; type TTipoMsg = (tmInformacao, tmAtencao, tmQuestao, tmErro, tmSucesso); TTipoBotoes = (tbOk, tbOkCancelar, tbSimNao, tbSimNaoCancelar); TMensagens = class class function ShowMessage(const aMsg: string; aCaption: string; aIcone: TTipoMsg; aBotoes: TTipoBotoes): Integer; overload; class function ShowMessage(const aMsg: string): Integer; overload; class function ShowMessage(const aMsg: string; aCaption: string): Integer; overload; class function ShowMessage(const aMsg: string; aCaption: string; aIcone: TTipoMsg): Integer; overload; class function ShowMessage(const aMsg: string; aCaption: string; aBotoes: TTipoBotoes): Integer; overload; class function ShowMessage(const aMsg: string; aIcone: TTipoMsg): Integer; overload; class function ShowMessage(const aMsg: string; aBotoes: TTipoBotoes): Integer; overload; class function ShowMessage(const aMsg: string; aIcone: TTipoMsg; aBotoes: TTipoBotoes): Integer; overload; end; implementation { TMensagens } class function TMensagens.ShowMessage(const aMsg: string; aCaption: string; aIcone: TTipoMsg; aBotoes: TTipoBotoes): Integer; var loForm: TFMensagem; Imagem: string; vCor: TColor; begin loForm := TFMensagem.Create(nil); try loForm.btnSim.Hide; loForm.btnNao.Hide; loForm.btnCancelar.Hide; loForm.btnOK.Hide; case aBotoes of tbOk: begin loForm.btnOK.Show; end; tbOkCancelar: begin loForm.btnOK.Show; loForm.btnCancelar.Show; end; tbSimNao: begin loForm.btnSim.Show; loForm.btnNao.Show; end; tbSimNaoCancelar: begin loForm.btnSim.Show; loForm.btnNao.Show; loForm.btnCancelar.Show; end; end; case aIcone of tmInformacao: begin Imagem := 'ImgInformacao.png'; vCor := $00FFF31C; end; tmAtencao: begin Imagem := 'ImgAtencao.png'; vCor := $000FCDFD; end; tmQuestao: begin Imagem := 'ImgPergunta.png'; vCor := $00FF8080; end; tmErro: begin Imagem := 'ImgErro.png'; vCor := $000000E1; end; tmSucesso: begin Imagem := 'ImgSucesso.png'; vCor := $0000EA00; end; end; loForm.Image1.Picture.LoadFromFile(TConfigIni.CaminhoImagens + Imagem); loForm.lblTitulo.Color := vCor; loForm.pnlLateral.Color := vCor; loForm.lblTitulo.Caption := aCaption; loForm.lblMensagem.HTMLText.Text := '<P align="center">' + aMsg + '</P>'; loForm.ShowModal; Result := loForm.Resultado; finally FreeAndNil(loForm); end; end; class function TMensagens.ShowMessage(const aMsg: string): Integer; begin Result := ShowMessage(aMsg,'Atenção!',tmInformacao,tbOk); end; class function TMensagens.ShowMessage(const aMsg: string; aCaption: string): Integer; begin Result := ShowMessage(aMsg,aCaption,tmInformacao,tbOk); end; class function TMensagens.ShowMessage(const aMsg: string; aCaption: string; aIcone: TTipoMsg): Integer; begin Result := ShowMessage(aMsg,aCaption,aIcone,tbOk); end; class function TMensagens.ShowMessage(const aMsg: string; aCaption: string; aBotoes: TTipoBotoes): Integer; begin Result := ShowMessage(aMsg,aCaption,tmInformacao,aBotoes); end; class function TMensagens.ShowMessage(const aMsg: string; aIcone: TTipoMsg): Integer; begin Result := ShowMessage(aMsg,'Atenção!',aIcone,tbOk); end; class function TMensagens.ShowMessage(const aMsg: string; aBotoes: TTipoBotoes): Integer; begin Result := ShowMessage(aMsg,'Atenção!',tmInformacao,aBotoes); end; class function TMensagens.ShowMessage(const aMsg: string; aIcone: TTipoMsg; aBotoes: TTipoBotoes): Integer; begin Result := ShowMessage(aMsg,'Atenção!',aIcone,aBotoes); end; end.
unit XFaceTransferInHexString; (* * Compface - 48x48x1 image compression and decompression * * Copyright (c) James Ashton - Sydney University - June 1990. * * Written 11th November 1989. * * Delphi conversion Copyright (c) Nicholas Ring February 2012 * * Permission is given to distribute these sources, as long as the * copyright messages are not removed, and no monies are exchanged. * * No responsibility is taken for any errors on inaccuracies inherent * either to the comments or the code of this program, but if reported * to me, then an attempt will be made to fix them. *) {$IFDEF FPC}{$mode delphi}{$ENDIF} interface uses XFaceInterfaces; type { THexStrTransferIn } TXFaceTransferInHexString = class(TInterfacedObject, IXFaceTransferIn) private FHexString : string; public constructor Create(const AHexString : string); procedure StartTransfer(); function TransferIn(const AIndex : Cardinal) : Byte; procedure EndTransfer(); end; implementation uses SysUtils; { THexStrTransferIn } constructor TXFaceTransferInHexString.Create(const AHexString : string); begin inherited Create(); FHexString := AHexString; end; procedure TXFaceTransferInHexString.StartTransfer(); begin end; function TXFaceTransferInHexString.TransferIn(const AIndex : Cardinal) : Byte; begin Result := StrToIntDef('0x' + Copy(FHexString, (AIndex - 1) * 2 + 1, 2), 0); end; procedure TXFaceTransferInHexString.EndTransfer(); begin end; end.
unit View.Produto; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, View.Template, Vcl.StdCtrls, Vcl.Buttons, Vcl.ExtCtrls, Vcl.ComCtrls, Model; type TProdutoView = class(TTemplateView) EDTDescricao: TLabeledEdit; EDTCusto: TLabeledEdit; EDTPrecoVenda: TLabeledEdit; procedure EDTPrecoVendaExit(Sender: TObject); procedure EDTCustoExit(Sender: TObject); procedure EDTCustoKeyPress(Sender: TObject; var Key: Char); procedure EDTPrecoVendaKeyPress(Sender: TObject; var Key: Char); private public procedure SetViewByModel(const AModel: TModel); override; procedure SetModelByView; override; function Validate: Boolean; override; procedure CreateController; override; procedure CleanModel; override; end; var ProdutoView: TProdutoView; implementation uses Controller.Produto, Model.Produto, Util.View; {$R *.dfm} { TProdutoView } procedure TProdutoView.CleanModel; begin inherited; Model := TProduto.Create; end; procedure TProdutoView.CreateController; begin inherited; Controller := TProdutoController.Create; end; procedure TProdutoView.EDTCustoExit(Sender: TObject); begin inherited; EDTCusto.Text := FormatFloat(FormatoFloat, StrToFloatDef(EDTCusto.Text, 0)); end; procedure TProdutoView.EDTCustoKeyPress(Sender: TObject; var Key: Char); begin inherited; EditFloatKeyPress(Sender, Key); end; procedure TProdutoView.EDTPrecoVendaExit(Sender: TObject); begin inherited; EDTPrecoVenda.Text := FormatFloat(FormatoFloat, StrToFloatDef(EDTPrecoVenda.Text, 0)); end; procedure TProdutoView.EDTPrecoVendaKeyPress(Sender: TObject; var Key: Char); begin inherited; EditFloatKeyPress(Sender, Key); end; procedure TProdutoView.SetModelByView; begin inherited; with TProduto(Model) do begin Descricao := EDTDescricao.Text; Custo := StrToFloatDef(EDTCusto.Text, 0); PrecoVenda := StrToFloatDef(EDTPrecoVenda.Text, 0); end; end; procedure TProdutoView.SetViewByModel(const AModel: TModel); begin inherited; with TProduto(AModel) do begin EDTDescricao.Text := Descricao; EDTCusto.Text := FormatFloat(FormatoFloat, Custo); EDTPrecoVenda.Text := FormatFloat(FormatoFloat, PrecoVenda); end; end; function TProdutoView.Validate: Boolean; var LMensagem: string; begin LMensagem := EmptyStr; Result := True; if Trim(EDTDescricao.Text).IsEmpty then begin LMensagem := 'Informe a Descrição'; EDTDescricao.SetFocus; Result := False; end else if not LMensagem.Trim.IsEmpty then begin Application.MessageBox(PWideChar(LMensagem), 'Atenção', MB_OK + MB_ICONWARNING); end; end; end.
{*******************************************************} { } { Delphi FireMonkey Platform } { Copyright(c) 2012-2013 Embarcadero Technologies, Inc. } { } {*******************************************************} unit FMX.FontGlyphs.iOS; interface uses System.Types, System.Classes, System.SysUtils, System.UITypes, System.UIConsts, System.Generics.Collections, System.Generics.Defaults, Macapi.ObjectiveC, Macapi.CoreFoundation, iOSapi.CocoaTypes, iOSapi.CoreGraphics, iOSapi.Foundation, iOSapi.CoreText, iOSapi.UIKit, FMX.Types, FMX.Surfaces, FMX.FontGlyphs, FMX.PixelFormats; {$SCOPEDENUMS ON} type TIOSFontGlyphManager = class(TFontGlyphManager) private FBits: PAlphaColorRecArray; FColorSpace: CGColorSpaceRef; FFontRef: CTFontRef; FDefaultBaseline: Single; FDefaultVerticalAdvance: Single; procedure GetDefaultBaseline; protected procedure LoadResource; override; procedure FreeResource; override; function DoGetGlyph(const Char: UCS4Char; const Settings: TFontGlyphSettings): TFontGlyph; override; public constructor Create; destructor Destroy; override; end; implementation uses System.Math, System.Character, FMX.Graphics; const BitmapSize = 256; { TIOSFontGlyphManager } constructor TIOSFontGlyphManager.Create; begin inherited Create; GetMem(FBits, BitmapSize * BitmapSize * 4); FColorSpace := CGColorSpaceCreateDeviceRGB; end; destructor TIOSFontGlyphManager.Destroy; begin CGColorSpaceRelease(FColorSpace); FreeMem(FBits); inherited; end; procedure TIOSFontGlyphManager.LoadResource; const //Rotating matrix to simulate Italic font attribute ItalicMatrix: CGAffineTransform = ( a: 1; b: 0; c: 0.176326981; //~tan(10 degrees) d: 1; tx: 0; ty: 0 ); var NewFontRef: CTFontRef; Matrix: PCGAffineTransform; begin Matrix := nil; FFontRef := CTFontCreateWithName(CFSTR(CurrentSettings.Family), CurrentSettings.Size * CurrentSettings.Scale, nil); try if TFontStyle.fsItalic in CurrentSettings.Style then begin NewFontRef := CTFontCreateCopyWithSymbolicTraits(FFontRef, 0, nil, kCTFontItalicTrait, kCTFontItalicTrait); if Assigned(NewFontRef) then begin CFRelease(FFontRef); FFontRef := NewFontRef; end else begin Matrix := @ItalicMatrix; //Font has no Italic version, applying transform matrix NewFontRef := CTFontCreateWithName(CFSTR(CurrentSettings.Family), CurrentSettings.Size * CurrentSettings.Scale, @ItalicMatrix); if Assigned(NewFontRef) then begin CFRelease(FFontRef); FFontRef := NewFontRef; end; end; end; if TFontStyle.fsBold in CurrentSettings.Style then begin NewFontRef := CTFontCreateCopyWithSymbolicTraits(FFontRef, 0, Matrix, kCTFontBoldTrait, kCTFontBoldTrait); if Assigned(NewFontRef) then begin CFRelease(FFontRef); FFontRef := NewFontRef; end; end; // GetDefaultBaseline; except CFRelease(FFontRef); end; end; procedure TIOSFontGlyphManager.FreeResource; begin if Assigned(FFontRef) then CFRelease(FFontRef); end; procedure TIOSFontGlyphManager.GetDefaultBaseline; var Chars: string; Str: CFStringRef; Frame: CTFrameRef; Attr: CFMutableAttributedStringRef; Underline: CFNumberRef; LValue: Cardinal; Path: CGMutablePathRef; Bounds: CGRect; FrameSetter: CTFramesetterRef; // Metrics Line: CTLineRef; Lines: CFArrayRef; Runs: CFArrayRef; Run: CTRunRef; Ascent, Descent, Leading: CGFloat; BaseLinePos: CGPoint; begin Path := CGPathCreateMutable(); Bounds := CGRectMake(0, 0, $FFFF, BitmapSize); CGPathAddRect(Path, nil, Bounds); Chars := 'a'; Str := CFStringCreateWithCharacters(kCFAllocatorDefault, PChar(Chars), 1); Attr := CFAttributedStringCreateMutable(kCFAllocatorDefault, 0); CFAttributedStringReplaceString(Attr, CFRangeMake(0, 0), Str); CFAttributedStringBeginEditing(Attr); try // Font if Assigned(FFontRef) then CFAttributedStringSetAttribute(Attr, CFRangeMake(0, 1), kCTFontAttributeName, FFontRef); //Underline if TFontStyle.fsUnderline in CurrentSettings.Style then begin LValue := kCTUnderlineStyleSingle; Underline := CFNumberCreate(nil, kCFNumberSInt32Type, @LValue); CFAttributedStringSetAttribute(Attr, CFRangeMake(0, 1), kCTUnderlineStyleAttributeName, Underline); end; finally CFAttributedStringEndEditing(Attr); end; FrameSetter := CTFramesetterCreateWithAttributedString(CFAttributedStringRef(Attr)); CFRelease(Attr); Frame := CTFramesetterCreateFrame(FrameSetter, CFRangeMake(0, 0), Path, nil); CFRelease(FrameSetter); CFRelease(Str); // Metrics Lines := CTFrameGetLines(Frame); Line := CTLineRef(CFArrayGetValueAtIndex(Lines, 0)); Runs := CTLineGetGlyphRuns(Line); Run := CFArrayGetValueAtIndex(Runs, 0); CTRunGetTypographicBounds(Run, CFRangeMake(0, 1), @Ascent, @Descent, @Leading); CTFrameGetLineOrigins(Frame, CFRangeMake(0, 0), @BaseLinePos); FDefaultBaseline := BitmapSize - BaseLinePos.y; FDefaultVerticalAdvance := FDefaultBaseline + Descent; CFRelease(Frame); CFRelease(Path); end; procedure PathApplierFunction(info: Pointer; const element: PCGPathElement); cdecl; var P, P1, P2: PPointF; begin P := PPointF(element^.points); case element.type_ of kCGPathElementMoveToPoint: TPathData(info).MoveTo(P^); kCGPathElementAddLineToPoint: TPathData(info).LineTo(P^); kCGPathElementAddQuadCurveToPoint: begin P1 := P; Inc(P1); TPathData(info).QuadCurveTo(P^, P1^); end; kCGPathElementAddCurveToPoint: begin P1 := P; Inc(P1); P2 := P1; Inc(P2); TPathData(info).CurveTo(P^, P1^, P2^); end; kCGPathElementCloseSubpath: TPathData(info).ClosePath; end; end; function TIOSFontGlyphManager.DoGetGlyph(const Char: UCS4Char; const Settings: TFontGlyphSettings): TFontGlyph; var CharsString: string; CharsStringLength: Integer; Str: CFStringRef; Frame: CTFrameRef; Attr: CFMutableAttributedStringRef; Underline: CFNumberRef; LValue: Cardinal; Path: CGMutablePathRef; Bounds: CGRect; Rgba: array [0..3] of Single; TextColor: CGColorRef; FrameSetter: CTFramesetterRef; Context: CGContextRef; I, J: Integer; Color: TAlphaColorRec; C: Byte; GlyphRect: TRect; // Metrics Line: CTLineRef; Lines: CFArrayRef; Runs: CFArrayRef; Run: CTRunRef; Ascent, Descent, Leading: CGFloat; Size: CGSize; GlyphStyle: TFontGlyphStyles; BaseLinePos: CGPoint; BaseLineOffset: Single; // RunGlyphCount: CFIndex; glyph: CGGlyph; glyphMatrix: CGAffineTransform; position: CGPoint; glyphPath: CGPathRef; M: TMatrix; LImageChar: Boolean; begin LImageChar := ((Char >= $1F0A0) and (Char <= $1F0FF)) or ((Char >= $1F300) and (Char <= $1F5FF)) or ((Char >= $1F600) and (Char <= $1F64F)) or ((Char >= $1F680) and (Char <= $1F6FF)) or ((Char >= $1F700) and (Char <= $1F77F)); Path := CGPathCreateMutable(); Bounds := CGRectMake(0, 0, $FFFF, BitmapSize); CGPathAddRect(Path, nil, Bounds); CharsString := System.Char.ConvertFromUtf32(Char); CharsStringLength := CharsString.Length; Str := CFStringCreateWithCharacters(kCFAllocatorDefault, PChar(CharsString), CharsStringLength); Attr := CFAttributedStringCreateMutable(kCFAllocatorDefault, 0); CFAttributedStringReplaceString(Attr, CFRangeMake(0, 0), Str); CFAttributedStringBeginEditing(Attr); try // Font if Assigned(FFontRef) then CFAttributedStringSetAttribute(Attr, CFRangeMake(0, CharsStringLength), kCTFontAttributeName, FFontRef); //Underline if TFontStyle.fsUnderline in CurrentSettings.Style then begin LValue := kCTUnderlineStyleSingle; Underline := CFNumberCreate(nil, kCFNumberSInt32Type, @LValue); CFAttributedStringSetAttribute(Attr, CFRangeMake(0, CharsStringLength), kCTUnderlineStyleAttributeName, Underline); end; // Color Rgba[0] := 1; Rgba[1] := 1; Rgba[2] := 1; Rgba[3] := 1; TextColor := CGColorCreate(FColorSpace, @Rgba[0]); try CFAttributedStringSetAttribute(Attr, CFRangeMake(0, CharsStringLength), kCTForegroundColorAttributeName, TextColor); finally CFRelease(TextColor); end; finally CFAttributedStringEndEditing(Attr); end; FrameSetter := CTFramesetterCreateWithAttributedString(CFAttributedStringRef(Attr)); CFRelease(Attr); Frame := CTFramesetterCreateFrame(FrameSetter, CFRangeMake(0, 0), Path, nil); CFRelease(FrameSetter); CFRelease(Str); Context := CGBitmapContextCreate(FBits, BitmapSize, BitmapSize, 8, BitmapSize * 4, FColorSpace, kCGImageAlphaPremultipliedLast); // Metrics Lines := CTFrameGetLines(Frame); Line := CTLineRef(CFArrayGetValueAtIndex(Lines, 0)); Runs := CTLineGetGlyphRuns(Line); Run := CFArrayGetValueAtIndex(Runs, 0); Bounds := CTRunGetImageBounds(Run, Context, CFRangeMake(0, 1)); CTRunGetAdvances(Run, CFRangeMake(0, 1), @Size); CTRunGetTypographicBounds(Run, CFRangeMake(0, 1), @Ascent, @Descent, @Leading); GlyphRect := Rect(Trunc(Bounds.origin.x), Max(Trunc(Ascent - Bounds.origin.y - Bounds.size.height) - 1, 0), Ceil(Bounds.origin.x + Bounds.size.width), Round(Ascent + Descent + Descent)); CTFrameGetLineOrigins(Frame, CFRangeMake(0, 0), @BaseLinePos); BaseLineOffset := BitmapSize - BaseLinePos.y; GlyphStyle := []; if ((Bounds.size.width = 0) and (Bounds.size.height = 0)) or not HasGlyph(Char) then GlyphStyle := [TFontGlyphStyle.NoGlyph]; if TFontGlyphSetting.gsPath in Settings then GlyphStyle := GlyphStyle + [TFontGlyphStyle.HasPath]; if LImageChar then GlyphStyle := GlyphStyle + [TFontGlyphStyle.ColorGlyph]; Result := TFontGlyph.Create(Point(GlyphRect.Left, GlyphRect.Top), Round(Size.width), Round(FDefaultVerticalAdvance), GlyphStyle); if (TFontGlyphSetting.gsBitmap in Settings) and (HasGlyph(Char) or ((Bounds.size.width > 0) and (Bounds.size.height > 0))) then begin FillChar(FBits^, BitmapSize * Round(Ascent + Descent + Descent) * 4, 0); if not SameValue(FDefaultBaseline - BaseLineOffset, 0, Epsilon) then CGContextTranslateCTM(Context, 0, -Abs(FDefaultBaseline - BaseLineOffset)); CTFrameDraw(Frame, Context); Result.Bitmap.SetSize(GlyphRect.Width, GlyphRect.Height, TPixelFormat.pfA8R8G8B8); if TFontGlyphSetting.gsPremultipliedAlpha in Settings then begin for I := GlyphRect.Top to GlyphRect.Bottom - 1 do Move(PAlphaColorArray(FBits)^[I * BitmapSize + Max(GlyphRect.Left, 0)], Result.Bitmap.GetPixelAddr(0, I - GlyphRect.Top)^, Result.Bitmap.Pitch); end else for I := GlyphRect.Left to GlyphRect.Right - 1 do for J := GlyphRect.Top to GlyphRect.Bottom - 1 do begin Color := FBits[J * BitmapSize + I]; if Color.R > 0 then begin C := (Color.R + Color.G + Color.B) div 3; Result.Bitmap.Pixels[I - GlyphRect.Left, J - GlyphRect.Top] := MakeColor($FF, $FF, $FF, C); end end; end; //Path if TFontGlyphSetting.gsPath in Settings then begin RunGlyphCount := CTRunGetGlyphCount(Run); for I := 0 to RunGlyphCount - 1 do begin CTRunGetGlyphs(Run, CFRangeMake(I, 1), @glyph); CTRunGetPositions(run, CFRangeMake(I, 1), @position); glyphMatrix := CGAffineTransformTranslate(CGAffineTransformIdentity, position.x, position.y); glyphPath := CTFontCreatePathForGlyph(FFontRef, glyph, @glyphMatrix); if Assigned(glyphPath) then begin CGPathApply(glyphPath, Result.Path, @PathApplierFunction); CFRelease(glyphPath); end; end; M := TMatrix.Identity; M.m22 := -1; Result.Path.ApplyMatrix(M); end; CGContextRelease(Context); CFRelease(Frame); CFRelease(Path); end; end.
PROGRAM FirstFamilyFined(INPUT,OUTPUT); { 0) Автор - Чернов Андрей 1)Общими требованиями к лабораторной работе являются: - организовать ввод данных из файла в понятной для пользователя форме; - обеспечить возможность многократных запросов без повторного запуска программы. - организовать в основной памяти с помощью указателей стек из очередей. - обеспечить операции ведения очереди из вершины стека, расширения и сокращения стека, выдачи содержимого стека (9).} USES CRT; CONST HeaderMain = '---------- Главное меню ------------'; Separator = '------------------------------------'; TYPE DATAELEMENT = STRING[40]; {----------------------------- Очередь-type: ----------------------------------} QUEUECOUNT = INTEGER; QUEUENODEPOINTER = ^QUEUENODE; {указательный тип данных на элемент стека} QUEUENODE = RECORD queueData : DATAELEMENT; {информационное поле} nextNode : QUEUENODEPOINTER; {ссылка на следующий элемент очереди} END; QUEUE = RECORD name : STRING[40]; {содержит имя очереди} front : QUEUENODEPOINTER; {указывает на начало очереди} rear : QUEUENODEPOINTER; {указывает на конец очереди} END; QUEUEPOINTER = ^QUEUE; {------------------------------------------------------------------------------} {------------------------------ Стек type: ------------------------------------} STACKCOUNT = INTEGER; STACKPOINTER = ^STACKNODE; {указательный тип данных на узел стека} STACKNODE = RECORD stackData : QUEUE; {информационное поле} nextNode : STACKPOINTER; {связь со следующим узлом стека} END; STACK = RECORD top: STACKPOINTER; END; {------------------------------------------------------------------------------} VAR S : STACK; {filename: STRING[40];} f: TEXT; PROCEDURE Message(mess: STRING); BEGIN WRITELN(mess); READLN; { пауза } {HALT} { конец } END; {//////////////////////////////////////////////////////////////////////////////} {------- Процедура CreateStack создает новый стек и инициализирует его --------} PROCEDURE CreateStack(VAR S : STACK); { PRE: Стек отсутствует POST: Стек S создан и инициализирован} BEGIN S.top := NIL; END; {//////////////////////////////////////////////////////////////////////////////} {------- Процедура CreateQueue создает новую очередь и инициализирует ее ------} FUNCTION CreateQueue() : QUEUE; { PRE: Очередь отсутствует POST: Очередь Q создана и инициализирована} VAR Q : QUEUE; BEGIN WRITE('Введите имя создаваемой очереди: '); READLN(Q.name); Q.front := NIL; Q.rear := NIL; CreateQueue := Q; END; {//////////////////////////////////////////////////////////////////////////////} {-------------------Функция IsStackEmpty проверяет пуст ли стек ---------------} FUNCTION IsStackEmpty(VAR S : STACK) : BOOLEAN; { PRE: Стек S уже создан (существует) POST: Функция вернет TRUE или FALSE в зависимости от пуст или нет стек} BEGIN IF (S.top = NIL) THEN BEGIN IsStackEmpty := TRUE; END ELSE BEGIN IsStackEmpty := FALSE; END; END; {//////////////////////////////////////////////////////////////////////////////} {-------------------Функция IsQueueEmpty проверяет пуста ли очередь -----------} FUNCTION IsQueueEmpty(VAR Q : QUEUE) : BOOLEAN; { PRE: Очередь Q уже существует POST: Функция вернет TRUE или FALSE в зависимости от пуста ли очередь} BEGIN IF ( (Q.front = NIL) AND (Q.rear = NIL) ) THEN BEGIN IsQueueEmpty := TRUE; END ELSE BEGIN IsQueueEmpty := FALSE; END; END; {//////////////////////////////////////////////////////////////////////////////} {--------------------- Процедура ClearStack очищает стек ----------------------} PROCEDURE ClearStack(VAR S : STACK); {maybe another clean без temp} { PRE: Стек S уже создан (существует) POST: Из стека S удалены все находившиеся в нем элементы. Стек пуст} VAR tempPointer : STACKPOINTER; tempData : QUEUE; BEGIN IF (S.top = NIL) THEN WRITELN('Стек уже пуст.') ELSE BEGIN WHILE NOT IsStackEmpty(S) DO BEGIN IF (S.top = NIL) THEN BEGIN Message('Стек пуст.'); END ELSE BEGIN NEW(tempPointer); {вначале выделяем память под узел стека} tempPointer := S.top; S.top := tempPointer^.nextNode; {вершина теперь указывает на след узел} DISPOSE(tempPointer); END; END; WRITELN('Стек очищен.'); END; END; {//////////////////////////////////////////////////////////////////////////////} {------------------------------Функция PushNode -------------------------------} PROCEDURE PushNode(tempPointer : STACKPOINTER; VAR S : STACK); { PRE: Связный стек уже создан, а tempPointer указывает на узел, который еще не помещен в стек POST: Узел tempPointer протолкнули в стек S} BEGIN IF (tempPointer = NIL) THEN WRITELN(' Попытка протолкнуть в стек несуществующий узел. ') ELSE BEGIN tempPointer^.nextNode := S.top; { "новый узел" указывает на прежнюю вершину стека } S.top := tempPointer; { установили указатель вершины стека на "новый узел" } END END; {//////////////////////////////////////////////////////////////////////////////} {------------------------------Функция Push -----------------------------------} PROCEDURE Push(Q : QUEUE; VAR S : STACK); { PRE: Стек S уже существует POST: Элемент Q был сохранен в стеке в качестве его верхнего элемента } VAR tempPointer : STACKPOINTER; BEGIN NEW(tempPointer); {вначале выделяем память под узел стека} tempPointer^.stackData := Q; {Положим данные в соотв поле нового узла стека} PushNode(tempPointer, S); END; {//////////////////////////////////////////////////////////////////////////////} {-------------Процедура создания новой очереди и ее помещение в стек ----------} PROCEDURE CreateQueueAndPush(VAR S : STACK); VAR Q : QUEUE; BEGIN Q := CreateQueue(); IF ( IsQueueEmpty(Q) = FALSE) THEN BEGIN Push(Q, S); WRITELN('Очередь "', Q.name,'" занесена в стек.'); END ELSE BEGIN IF (Q.name = '') THEN WRITELN('Нечего заносить в стек. У очереди должно быть имя.') ELSE BEGIN Push(Q, S); WRITELN('Очередь "', Q.name,'" занесена в стек (пустая).'); END; END; END; {//////////////////////////////////////////////////////////////////////////////} {------------------------------Функция PeekOnTopStack -------------------------} FUNCTION PeekOnTopStack(VAR S : STACK) : QUEUEPOINTER; { PRE: Стек S уже создан (существует) и не пуст (есть проверка) POST: Указатель на очередь в вершине стека возвращен значением функции} BEGIN IF (S.top = NIL) THEN BEGIN WRITELN('В стеке нет очередей.'); PeekOnTopStack := NIL; END ELSE PeekOnTopStack := @(S.top^.stackData); END; {//////////////////////////////////////////////////////////////////////////////} {------------------------------Функция Dequeue --------------------------------} FUNCTION Dequeue (VAR pQ: QUEUEPOINTER) : DATAELEMENT; {протолкнуть очередь} { PRE: Очередь существует POST: Первый узел очереди изъят! из очереди и возвращен значением функции} VAR tempQueueNodePointer : QUEUENODEPOINTER; tempData : DATAELEMENT; BEGIN IF (IsQueueEmpty(pQ^) = TRUE) THEN BEGIN WRITE('В очереди "', pQ^.name, '" нет элементов.'); END ELSE BEGIN {извлечем головной элемент как результат функции} NEW(tempQueueNodePointer); {вначале выделяем память под временный узел} tempQueueNodePointer := pQ^.front; {врем указ будет теперь головн элем очереди} IF (pQ^.front^.nextNode <> NIL) THEN BEGIN pQ^.front := pQ^.front^.nextNode; {головной элемент указывает на след за головным узел очереди} tempData := tempQueueNodePointer^.queueData; DISPOSE(tempQueueNodePointer); Dequeue := tempData; END ELSE BEGIN tempData := tempQueueNodePointer^.queueData; DISPOSE(tempQueueNodePointer); pQ^.rear := NIL; pQ^.front := NIL; Dequeue := tempData; END; END; END; {//////////////////////////////////////////////////////////////////////////////} {------------------------------Функция Pop-------------------------------------} FUNCTION Pop(VAR S : STACK) : QUEUE; { PRE: Стек S уже создан (существует) и не пуст (есть проверка) POST: Элемент стека был снят с вершины стека и возвращен значением функции} VAR tempPointer : STACKPOINTER; tempData : QUEUE; BEGIN IF (S.top = NIL) THEN BEGIN WRITELN('Недопустима операция POP из пустого стека..'); END ELSE BEGIN NEW(tempPointer); {вначале выделяем память под узел стека} tempPointer := S.top; S.top := tempPointer^.nextNode; {вершина теперь указывает на след узел} tempData := tempPointer^.stackData; DISPOSE(tempPointer); Pop := tempData; END; END; {//////////////////////////////////////////////////////////////////////////////} {------------- Процедура POP одной очереди из стека и ее вывод ----------------} PROCEDURE PopQueueAndPrint(VAR pQ : QUEUEPOINTER); VAR tempData : DATAELEMENT; BEGIN IF (IsQueueEmpty(pQ^) = TRUE) THEN BEGIN WRITE('Очередь "', pQ^.name,'". Элементы отсутствуют.'); END ELSE BEGIN WRITELN('Имя очереди: "', pQ^.name,'".'); WRITE('Элементы очереди: '); WHILE (IsQueueEmpty(pQ^) <> TRUE) DO BEGIN tempData := Dequeue(pQ); WRITE('"',tempData, '" '); END; END; WRITELN; END; {//////////////////////////////////////////////////////////////////////////////} {----------------- Процедура PrintStack выводит содержимое стека на экран -----} PROCEDURE PrintStack(VAR S : STACK); VAR Q : QUEUE; pQ : QUEUEPOINTER; BEGIN IF IsStackEmpty(S) THEN BEGIN WRITELN('Стек пуст.'); END ELSE BEGIN WHILE NOT IsStackEmpty(S) DO BEGIN Q := Pop(S); pQ := @Q; PopQueueAndPrint(pQ); END; END; END; {//////////////////////////////////////////////////////////////////////////////} {---------- Процедура PrintStackTop выводит содержимое top.стека на экран -----} PROCEDURE PrintStackTop(VAR S : STACK); VAR Q : QUEUE; pQ : QUEUEPOINTER; BEGIN IF (IsStackEmpty(S) = TRUE) THEN BEGIN WRITELN('Стек пуст.'); END ELSE BEGIN Q := Pop(S); pQ := @Q; PopQueueAndPrint(pQ); END; END; {//////////////////////////////////////////////////////////////////////////////} {------------------------------------------------------------------------------} FUNCTION PeekOnQueueFront (VAR pQ: QUEUEPOINTER) : DATAELEMENT; { PRE: Очередь существует POST: Значение головного узла возвращено функцией без его изъятия из очереди} VAR tempQueuePointer : QUEUENODEPOINTER; tempData : DATAELEMENT; BEGIN WITH pQ^ DO BEGIN IF (IsQueueEmpty(pQ^) = TRUE) THEN BEGIN WRITELN('В очереди "', pQ^.name, '" нет элементов.'); END ELSE BEGIN {вернем головной элемент как результат функции} NEW(tempQueuePointer); {вначале выделяем память под временный узел} tempQueuePointer := front; {врем указ будет теперь головн элем очереди} IF (front^.nextNode <> NIL) THEN BEGIN tempData := tempQueuePointer^.queueData; PeekOnQueueFront := tempData; END ELSE BEGIN tempData := tempQueuePointer^.queueData; rear := NIL; front := NIL; PeekOnQueueFront := tempData; END END; END; END; {//////////////////////////////////////////////////////////////////////////////} {------------- Процедура вывода очереди на экран ------------------------------} PROCEDURE PeekQueue(VAR pQ: QUEUEPOINTER); VAR tempQueueNodePointer : QUEUENODEPOINTER; BEGIN IF IsQueueEmpty(pQ^) THEN BEGIN WRITELN('Очередь "', pQ^.name, '". Пустая.'); END ELSE BEGIN WRITELN('Имя очереди: "', pQ^.name,'".'); WRITE('Элементы очереди: '); NEW(tempQueueNodePointer); tempQueueNodePointer := pQ^.front; WHILE (tempQueueNodePointer <> NIL) DO BEGIN WRITE(tempQueueNodePointer^.queueData, '; '); tempQueueNodePointer := tempQueueNodePointer^.nextNode; END; DISPOSE(tempQueueNodePointer); WRITELN; END; END; {//////////////////////////////////////////////////////////////////////////////} {------------- Процедура очистки очереди ------------------------------} PROCEDURE ClearQueue(VAR pQ: QUEUEPOINTER); VAR queueElemForClear : DATAELEMENT; BEGIN IF (IsQueueEmpty(pQ^) = TRUE) THEN WRITE('Очередь "', pQ^.name,'" уже пуста.'); WHILE (IsQueueEmpty(pQ^) = FALSE) DO BEGIN queueElemForClear := Dequeue(pQ); IF (IsQueueEmpty(pQ^) = TRUE) THEN WRITE('Очередь "', pQ^.name,'" очищена.'); END; WRITELN; END; {//////////////////////////////////////////////////////////////////////////////} {------- Процедура Append2Queue добавляет элемент в конец очереди -------------} PROCEDURE Append2Queue(qElem : DATAELEMENT; VAR pQ : QUEUEPOINTER); { PRE: Очередь Q уже существует POST: Узел с данными, на который указывает tempQueuePointer, помещен в очередь в качестве ее последнего (хвостового) элемента} VAR tempQueuePointer : QUEUENODEPOINTER; {вновь добавляемый узел в конец очереди} BEGIN NEW(tempQueuePointer); {вначале выделяем память под узел очереди} tempQueuePointer^.queueData := qElem; {Положим данные в соотв поле нового узла стека} IF (tempQueuePointer = NIL) THEN Message(' Попытка добавить в очередь несуществующий узел. ') ELSE BEGIN WITH pQ^ DO IF IsQueueEmpty(pQ^) THEN BEGIN {Очередь пуста, а значит установим и front и rear так, чтобы они указывали на tempQueuePointer - ед. узел в очереди} front := tempQueuePointer; rear := tempQueuePointer; END ELSE {очередь не пуста, а значит } BEGIN {1) предыдущий хвост.узел будет теперь } rear^.nextNode := tempQueuePointer; {указывать на новый хвост.узел.} rear := tempQueuePointer; {2) обновим сам хвост} END; tempQueuePointer^.nextNode := NIL; {3) укажем, что новый узел находится в конце очереди} END; END; {//////////////////////////////////////////////////////////////////////////////} {-------------Процедура Записи в очередь данных с клавиатуры ------------------} PROCEDURE Write2QueueOnStack(VAR pQ: QUEUEPOINTER; VAR S: STACK); VAR qElem : DATAELEMENT; writeFlag : BOOLEAN; BEGIN writeFlag:= TRUE; WRITELN(Separator); WHILE (writeFlag = TRUE) DO BEGIN WRITE('Введите строку для помещения в очередь "', pQ^.name); WRITE('" или "exit" для завершения ввода: '); READLN(qElem); IF ( (qElem = 'EXIT') OR (qElem = 'exit') ) THEN BEGIN writeFlag := FALSE; END ELSE BEGIN Append2Queue(qElem, pQ); END; END; WRITELN(Separator); END; {//////////////////////////////////////////////////////////////////////////////} PROCEDURE MenuQueue(VAR S : STACK); forward; {------------- Процедура MenuMain для вывода основного меню и работы с ним-----} PROCEDURE MenuMain(VAR S : STACK); VAR Option : INTEGER; BEGIN WRITELN(HeaderMain); WRITELN('1. Создать новую очередь (PUSH).'); WRITELN('2. Работа с очередью на стеке.'); WRITELN('3. POP и PRINT одну очередь из стека.'); WRITELN('4. POP и PRINT все очереди стека.'); WRITELN('5. Очистить стек.'); WRITELN('6. Очистить экран.'); WRITELN('7. Выход.'); WRITELN(Separator); WRITE('Сделайте выбор и нажмите соответствующую цифру: '); READLN(Option); CASE Option OF 1: CreateQueueAndPush(S); 2: MenuQueue(S); 3: PrintStackTop(S); 4: PrintStack(S); 5: ClearStack(S); 6: CLRSCR; 7: BEGIN ClearStack(S); HALT; END; ELSE WRITELN('Выберите существующий пункт из меню.'); END; MenuMain(S); END; {//////////////////////////////////////////////////////////////////////////////} {------------- Процедура MenuQueue для работы с очередью на стеке -------------} PROCEDURE MenuQueue(VAR S : STACK); VAR Option : INTEGER; pQ : QUEUEPOINTER; BEGIN pQ := PeekOnTopStack(S); IF (pQ = NIL) THEN Option := 5 ELSE BEGIN WRITELN('---- Работа с очередью ', pQ^.name,' на стеке ----'); WRITELN('1. Добавить элементы в очередь на стеке.'); WRITELN('2. Протолкнуть очередь, с выводом головного элемента.'); WRITELN('3. Просмотреть название и содержимое очереди на стеке (без удаления).'); WRITELN('4. Очистить содержимое очереди на стеке.'); WRITELN('5. Выход в главное меню работы со стеком.'); WRITELN('6. Очистить экран.'); WRITELN(Separator); WRITE('Сделайте выбор и нажмите соответствующую цифру: '); READLN(Option); END; CASE Option OF 1: Write2QueueOnStack(pQ, S);{+} 2: WRITELN(Dequeue(pQ)); 3: PeekQueue(pQ); 4: ClearQueue(pQ); 5: MenuMain(S); 6: CLRSCR; ELSE WRITELN('Выберите существующий пункт из меню.'); END; MenuQueue(S); END; {//////////////////////////////////////////////////////////////////////////////} {--------------------------- Основная программа -------------------------------} BEGIN CLRSCR; {SetConsoleCP(866); SetConsoleOutputCP(866);} {IF ParamCount<1 THEN Message('Не указан исходный файл') ELSE ASSIGN(f, ParamStr(1)); filename := ParamStr(1);} {$I-} { отключение прерывания при ошибке ввода } {RESET(f);} {$I+} { восстановление системной реакции на ошибку } {IF IOResult <> 0 THEN BEGIN Message('Ошибка открытия файла '+filename); END;} CreateStack(S); MenuMain(S); END.
{***************************************************************************} { } { DelphiUIAutomation } { } { Copyright 2015 JHC Systems Limited } { } {***************************************************************************} { } { Licensed under the Apache License, Version 2.0 (the "License"); } { you may not use this file except in compliance with the License. } { You may obtain a copy of the License at } { } { http://www.apache.org/licenses/LICENSE-2.0 } { } { Unless required by applicable law or agreed to in writing, software } { distributed under the License is distributed on an "AS IS" BASIS, } { WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. } { See the License for the specific language governing permissions and } { limitations under the License. } { } {***************************************************************************} unit DelphiUIAutomation.RadioButton; interface uses DelphiUIAutomation.Base, UIAutomationClient_TLB; type IAutomationRadioButton = interface (IAutomationBase) ['{B40E22FF-6E10-4E9C-8900-48C4D1F83F19}'] ///<summary> /// Selects the control ///</summary> function Select: HRESULT; end; /// <summary> /// Represents a radio button control /// </summary> TAutomationRadioButton = class (TAutomationBase, IAutomationRadioButton) private FSelectionItemPattern : IUIAutomationSelectionItemPattern; public ///<summary> /// Selects the control ///</summary> function Select: HRESULT; constructor Create(element : IUIAutomationElement); override; end; implementation uses DelphiUIAutomation.PatternIDs; { TAutomationRadioButton } constructor TAutomationRadioButton.Create(element: IUIAutomationElement); begin inherited Create(element); FSelectionItemPattern := getSelectionItemPattern; end; function TAutomationRadioButton.Select: HRESULT; begin result := FSelectionItemPattern.Select; end; end.
unit SimThyrServices; { SimThyr Project } { A numerical simulator of thyrotropic feedback control } { Version 3.3.1 } { (c) J. W. Dietrich, 1994 - 2014 } { (c) Ludwig Maximilian University of Munich 1995 - 2002 } { (c) Ruhr University of Bochum 2005 - 2014 } { This unit provides some global functions } { Source code released under the BSD License } { See http://simthyr.sourceforge.net for details } {$mode objfpc}{$R+} interface uses Classes, SysUtils, Grids, StdCtrls, Dialogs, Forms, SimThyrTypes, SimThyrResources, UnitConverter, DOM, XMLRead, FileUtil {$IFDEF win32} , Windows, Win32Proc {$ELSE} {$IFDEF LCLCarbon} , MacOSAll {$ENDIF} , Unix {$ENDIF} ; const iuSystemScript = -1; iuCurrentScript = -2; iuWordSelectTable = 0; iuWordWrapTable = 1; iuNumberPartsTable = 2; iuUnTokenTable = 3; iuWhiteSpaceList = 4; type tSaveMode = (TimeSeries, Plot); var gSaveMode: tSaveMode; function OSVersion: Str255; procedure bell; function EncodeGreek(theString: string): string; function DecodeGreek(theString: string): string; function NodeContent(theRoot: TDOMNode; Name: string): string; procedure VarFromNode(theRoot: TDOMNode; Name: string; var theVar: real); function SimpleNode(Doc: TXMLDocument; Name, Value: string): TDOMNode; procedure ClearResultContents(var theContents: tResultContent); procedure writeaTableCell(theTable: TStringGrid; theCell: TableCell; theString: Str255); procedure writeTableCells(theTable: TStringGrid; theContents: tResultContent); procedure SetStatusBarPanel0(curr, max: string); procedure writeaMemoLine(theMemo: TMemo; theString: Str255); procedure SetFileName(theForm: TForm; const FileName: string); procedure ShowImplementationMessage; procedure ShowFormatMessage; implementation uses SimThyrLog; function OSVersion: Str255; {returns the major version of the operating system} begin {$IFDEF LCLcarbon} OSVersion := 'Mac OS X 10.'; {$ELSE} {$IFDEF Linux} OSVersion := 'Linux Kernel '; {$ELSE} {$IFDEF UNIX} OSVersion := 'Unix '; {$ELSE} {$IFDEF WINDOWS} if WindowsVersion = wv95 then OSVersion := 'Windows 95 ' else if WindowsVersion = wvNT4 then OSVersion := 'Windows NT v.4 ' else if WindowsVersion = wv98 then OSVersion := 'Windows 98 ' else if WindowsVersion = wvMe then OSVersion := 'Windows ME ' else if WindowsVersion = wv2000 then OSVersion := 'Windows 2000 ' else if WindowsVersion = wvXP then OSVersion := 'Windows XP ' else if WindowsVersion = wvServer2003 then OSVersion := 'Windows Server 2003 ' else if WindowsVersion = wvVista then OSVersion := 'Windows Vista ' else if WindowsVersion = wv7 then OSVersion := 'Windows 7 ' //else if WindowsVersion = wv8 then // for future LCL versions // OSVersion := 'Windows 8 ' else OSVersion := 'Windows '; {$ENDIF} {$ENDIF} {$ENDIF} {$ENDIF} end; procedure bell; {platform-independent implementation of acustical warning} var s:longint; begin {$IFDEF win32} MessageBeep(0); {$ELSE} {$IFDEF LCLCarbon} SysBeep(30); {$ELSE} s := Shell('echo -ne ''\007'''); {s := fpSystem('echo -ne "\a"');} {s := fpSystem('tput bel');} {beep;} {$ENDIF} {$ENDIF} end; function EncodeGreek(theString: string): string; {encodes greek mu letter as ASCII substitution sequence} var theFlags: TReplaceFlags; begin theFlags := [rfReplaceAll, rfIgnoreCase]; Result := StringReplace(theString, #194#181, 'mc', theFlags); end; function DecodeGreek(theString: string): string; {decodes ASCII substitution sequence for greek mu letter} begin result := UTF8Decode(StringReplace(theString, 'mc', PrefixLabel[4], [rfReplaceAll, rfIgnoreCase])); end; function NodeContent(theRoot: TDOMNode; Name: string): string; {supports XML routines, gets the contents of a node in a file} var theNode: TDOMNode; theText: String; begin if assigned(theRoot) then begin theNode := theRoot.FindNode(Name); if assigned(theNode) then begin try theText := theNode.TextContent; if theText <> '' then Result := UTF8Encode(theText); except Result := 'NA'; end; theNode.Destroy; end else Result := 'NA'; end; end; procedure VarFromNode(theRoot: TDOMNode; Name: string; var theVar: real); {supports XML routines} var oldSep: char; theString: string; begin oldSep := DefaultFormatSettings.DecimalSeparator; DefaultFormatSettings.DecimalSeparator := kPERIOD; theString := NodeContent(theRoot, Name); if theString <> 'NA' then theVar := StrToFloat(theString); DefaultFormatSettings.DecimalSeparator := oldSep; end; function SimpleNode(Doc: TXMLDocument; Name, Value: string): TDOMNode; {supports XML routines, creates an XML node from the contents of a string} var ItemNode, TextNode: TDOMNode; begin ItemNode := Doc.CreateElement(Name); TextNode := Doc.CreateTextNode(UTF8Decode(Value)); ItemNode.AppendChild(TextNode); Result := ItemNode; end; procedure ClearResultContents(var theContents: tResultContent); {deletes a row} var counter: integer; begin for counter := 1 to RES_MAX_COLS do theContents[counter] := ' '; end; procedure writeaTableCell(theTable: TStringGrid; theCell: TableCell; theString: Str255); {set the conents of a cell in a StringGrid to the contents of a string} begin theTable.Cells[theCell.x, theCell.y] := theString; end; procedure writeTableCells(theTable: TStringGrid; theContents: tResultContent); {writes a vector of values to the last line of a StringGrid} var j: integer; theCell: TableCell; theString: Str255; begin theTable.Tag := theTable.Tag + 1; if theTable.Tag > GridRows - 1 then theTable.RowCount := theTable.RowCount + 1; theCell.y := theTable.Tag; for j := 0 to RES_MAX_COLS - 1 do begin theString := theContents[j]; theCell.x := j; writeaTableCell(theTable, theCell, theString); end; end; procedure SetStatusBarPanel0(curr, max: string); {updates progress indicator in status bar} begin SimThyrLogWindow.StatusBar1.Panels[0].Text := ' ' + curr + ':' + max; end; procedure writeaMemoLine(theMemo: TMemo; theString: Str255); {emulates writeln for a memo} begin {$IFDEF win32} theMemo.Lines.Text := theMemo.Lines.Text + kCRLF + theString; {$ELSE} {$IFDEF LCLCarbon} theMemo.Lines.Text := theMemo.Lines.Text + kRETURN + theString; {$ELSE} theMemo.Lines.Text := theMemo.Lines.Text + kLF + theString; {$ENDIF} {$ENDIF} end; procedure SetFileName(theForm: TForm; const FileName: string); {sets the title of a window to file name} begin theForm.Caption := ExtractFileName(FileName); end; procedure ShowImplementationMessage; {error message} begin bell; ShowMessage(IMPLEMENTATION_MESSAGE); end; procedure ShowFormatMessage; {error message} begin bell; ShowMessage(FORMAT_MESSAGE); end; end.
unit La24UsbScanThread; interface uses Windows, Classes, Extctrls, Graphics, SysUtils, Forms, IniFiles, ADC_Const, IADCDevice, DllClient, IFactory, VT_Drivers, ADCUtility, DataClass, Procs, CommonScanThread, Config, UsbDeviceUtils, SyncObjs, Logger; //модуль исключительно для платы ЛА-И24USB // модуль для сбора данных, непрерывно получаемых с платы // особенностью является то, что плата выдаёт данные непрерывно и сохраняет их в буфере DMA // через механизм DMA.Размер буфера DMA фиксированный - 32768 отсчётов. //сбор делается без LAAUtility! type RCommand = record command: TArduinoCommand; operand: integer; end; TLa24UsbScanThread = class( TCommonScanThread ) private fLAxClient: TDllClient; fLAxFactory: TIFactory; fADCDevice: TIADCDevice; fNumChannels: integer; //число каналов сканирования (их в 2 раза больше чем каналов в настройках, так как дТ + Т) fPortSingleBuffer: array[0..0] of byte; fPortMultiBuffer: TPortMultiBuffer; fPortDataLength: word; fDevDescriptor: TUsbDeviceDescriptor; //дескриптор параметров каналов прибора, его конструктор читает параметры из файла настроек прибора fPortOperation: boolean; //признак того, что поток занят исполнением команды fDisableCommandBufferAccess: boolean; //запретить доступ к буферу команд, для слуюаев, когда производится модификация буфера fCommandBuffer: array of RCommand; //буфер команд для исполнения fCommandTempBuffer: array of RCommand; //рабочий буфер команд для исполнения, не модифицируется извне fCurrDMACounter, fOldDMAcounter, fDeltaCounter: integer; //данные внутреннего DMA счётчика у ЛА24USB procedure SetupHardware( ); procedure SendCommands( ); function PerformCommand( aCommand: TArduinoCommand; aOperand: integer ): byte; protected procedure Execute; override; public constructor Create( ); procedure DigitalPortOut( aValue: byte ); override; procedure DigitalPortMultiOut( aValue: TPortMultiBuffer ); override; function DigitalPortCommandOut( aCommand: TArduinoCommand; aOperand: integer ): boolean; override; procedure StartADC( ); override; procedure StopADC( ); override; procedure Cleanup( Sender: TObject ); override; end; implementation uses TypInfo, ScanDlg; const BOARD_NAME = 'Lai24USB'; MAX_CHANNELS = 4; SAMPLES_PER_CHANNEL = 16; // буфер ДМА отдаёт значения блоками по 16 отсчётов на каждый канал, независимо от частоты опроса DMA_BUFFER_SIZE = 32768 * MAX_CHANNELS; //размер циклического буфера DMA в отсчётах DATA_DIVIDER = 256; //делитель для данных - 256, так как данные в трёх старших байтах) // DATA_DIVIDER = 256; //делитель для данных (по умолчанию - 256, так как данные в трёх старших байтах) //дополнительно умножаем ещё на число, на которое искуссвенно снижаем разрядность, чтобы не было численного переполнения //например если данные делим на 4, так как иначе возникает переполнение при отрисовке, //то соответственно, максимальный диапазон будет -2 097 152 .. 2 097 152 constructor TLa24UsbScanThread.Create( ); var devSettings: TiniFile; begin inherited Create( ); //читаем параметры каналов //OnTerminate := Cleanup; devSettings := TINIFile.Create( gConfig.fProgramDataPath + 'Devices.ini' ); fDevDescriptor := TUsbDeviceDescriptor.Create( devSettings ); fNumChannels := gConfig.NumberOfHardwareChannels * 2; if fNumChannels > MAX_CHANNELS then raise Exception.Create( 'Превышено число каналов для интерфейса ЛАи24USB. Максимальное количество независимых каналов - 4.' ); try SetupHardware( ); except on E: Exception do begin ErrBox( gLogger, ClassName, E.Message ); fFatalError := true; fErrorMessage := E.Message; end; end; devSettings.Free; end; procedure TLa24UsbScanThread.Execute; var i: integer; tValue, dtValue: integer; buffer: array of longint; channel: byte; additionalRead: integer; bufValue: integer; res: integer; begin try SetLength( buffer, SAMPLES_PER_CHANNEL * MAX_CHANNELS ); //fADCDevice.Start( ); while not Terminated do begin if fSuspended then begin Sleep( 1 ); Continue; end; // WaitForSingleObject( hEventForCaptureTh, INFINITE ); tValue := 0; //счетчик в отсчетах res := fADCDevice.Get( ADC_GET_DMACOUNTER, @fCurrDMACounter ); if res <> 1 then begin Terminate; raise Exception.Create( GetErrMsg( res ) ); end; if ( fCurrDMACounter = fOldDMAcounter ) then begin //данные ещё не готовы, пропускаем итерацию if fPortOperation then begin //взведён флаг, что необходимо выполнить //простые операции с портом типа вывода единственного значения в порт. if fPortDataLength > 0 then //вывод в порт массива значений begin for i := 0 to fPortDataLength - 1 do begin fADCDevice.PortIO( ADC_PORTIO_OUTB, @fPortMultiBuffer[i], 1 ); DelayUS( 300 ); end; fPortDataLength := 0; end else fADCDevice.PortIO( ADC_PORTIO_OUTB, @fPortSingleBuffer, 1 ); fPortOperation := false; end else if ( Length( fCommandBuffer ) > 0 ) and ( fUseDeviceControl ) then //в буфере команд накопились команды, //и команды разрешено посылать в порт SendCommands( ); Sleep( 1 ); end else begin if fOldDMAcounter > fCurrDMACounter then //значит надо дочитать с конца, и потом считать с начала, т.к. перешли через кольцо буфера begin fDeltaCounter := DMA_BUFFER_SIZE - fOldDMAcounter + fCurrDMACounter; additionalRead := DMA_BUFFER_SIZE - fOldDMAcounter; if fDeltaCounter > Length( buffer ) then begin //если получилось так, что мы проскочили очередную готовность данных //и их набралось больше чем размер буфера данных SetLength( buffer, fDeltaCounter ); end; fADCDevice.GetData( gConfig.usbGetDataMode, @buffer[0], additionalRead, fOldDMAcounter ); fADCDevice.GetData( gConfig.usbGetDataMode, @buffer[additionalRead - 1], fCurrDMACounter, 0 ); end else begin fDeltaCounter := fCurrDMACounter - fOldDMAcounter; if fDeltaCounter > Length( buffer ) then begin //если получилось так, что мы проскочили очередную готовность данных //и их набралось больше чем размер буфера данных SetLength( buffer, fDeltaCounter ); end; fADCDevice.GetData( gConfig.usbGetDataMode, @buffer[0], fDeltaCounter, fOldDMAcounter ); end; i := 0; //данные считали в буфер, теперь переместим данные в массив точек while i <= High( buffer ) do begin if i mod MAX_CHANNELS = 0 then //начало данных очередного канала begin for channel := 0 to gConfig.numberOfHardwareChannels - 1 do begin bufValue := buffer[i + channel * 2] div ( DATA_DIVIDER * gConfig.rawDataDivider ); tValue := bufValue + fDevDescriptor.getTempChannelOffset( channel ); tValue := tValue * gConfig.TADCMultiplier - gConfig.tOffset; if fCurrTime > fDataClass.GetItemCount( ) - 1 then fDataClass.SetItemsLength( Round( fDataClass.GetItemCount( ) + gConfig.frequency * 60 ), false ); //увеличиваем длину массива данных на одну минуту fDataClass.items[fCurrTime, channel + fStartChannelNo].t := CheckTRange( tValue ); fDataClass.items[fCurrTime, channel + fStartChannelNo].tc := gTempCalibrationTable.GetRealValue( tValue ); bufValue := buffer[i + 1 + channel * 2] div ( DATA_DIVIDER * gConfig.rawDataDivider ); dtValue := bufValue + fDevDescriptor.getDiffTempChannelOffset( channel ) - gConfig.dTScaleOffset + gConfig.dTSignalOffset; fDataClass.items[fCurrTime, channel + fStartChannelNo].dt := CheckDtRange( dtValue, fDataClass.items[fCurrTime, channel].tc ); fDataClass.items[fCurrTime, channel + fStartChannelNo].dtc := gDiffTempCalibrationTable.GetRealValue( dtValue, gTempCalibrationTable.GetRealValue( tValue ) ); end; //обрабатываем паузу в начале сканирования if GetTickCount( ) > fStartTime * fDataClass.fPeriod + gConfig.scanDeadZone then Inc( fCurrTime ); end; Inc( i ); end; end; fOldDMAcounter := fCurrDMACounter; if fCurrTime = 0 then fDataClass.fTimeCounter := 0 else //что это за херня ??? fDataClass.fTimeCounter := fCurrTime - 1; end; except on E: Exception do begin fFatalError := true; fErrorCode := ERR_DO_EXECUTE_THREAD; fErrorMessage := ERR_DO_EXECUTE_THREAD_MSG + ' - ' + E.Message; DoOnException( ); end; end; end; function TLa24UsbScanThread.DigitalPortCommandOut( aCommand: TArduinoCommand; aOperand: integer ): boolean; var len: word; begin //ждём, пока буфер команд не освободитьтся для работы while fDisableCommandBufferAccess do Sleep( 1 ); //используем критическую секцию, чтобы больше не было вызовов данного метода ни от кого try // if fCS.TryEnter then begin fDisableCommandBufferAccess := true; //лочим буфер команд для работы len := Length( fCommandBuffer ); SetLength( fCommandBuffer, len + 1 ); fCommandBuffer[len].command := aCommand; fCommandBuffer[len].operand := aOperand; Result := true; fDisableCommandBufferAccess := false; //освобождаем буфер команд для работы end // else // Result := false finally // fCS.Leave; //Log( 'fCS.Leave' ); end; end; procedure TLa24UsbScanThread.DigitalPortMultiOut( aValue: TPortMultiBuffer ); begin if Length( aValue ) > 0 then begin fPortMultiBuffer := aValue; fPortDataLength := Length( aValue ); fPortOperation := true; end; end; procedure TLa24UsbScanThread.DigitalPortOut( aValue: byte ); begin fPortSingleBuffer[0] := aValue; fPortOperation := true; end; function TLa24UsbScanThread.PerformCommand( aCommand: TArduinoCommand; aOperand: integer ): byte; const BYTE_RESET: byte = 128; BYTE_COMMAND_STROBE: byte = 64; g = 1111; var command: byte; b: byte; outbuf: TPortMultiBuffer; inbuf: array[0..0] of byte; i: integer; operand: longword; operand0: byte; operand1: byte; operand2: byte; operand3: byte; serviceByte: byte; begin // fADCDevice.PortIO( ADC_PORTIO_INB, @inbuf[0], 1 ); //b := inbuf[0]; SetLength( outbuf, 7 ); operand := Abs( aOperand ); // operand0 := ( operand and 64512 ) shr 10; // operand1 := ( operand and 1008 ) shr 4; // operand2 := ( operand and 15 ) shl 2; operand0 := ( operand and $FC0000 ) shr 18; operand1 := ( operand and $3F000 ) shr 12; operand2 := ( operand and $FC0 ) shr 6; operand3 := ( operand and $3F ); serviceByte := 0; if aOperand < 0 then serviceByte := SetBit( serviceByte, 1 ); if GetParityBit32( operand ) = 1 then serviceByte := SetBit( serviceByte, 0 ); outbuf[0] := BYTE_RESET; outbuf[1] := BYTE_COMMAND_STROBE or Ord( aCommand ); outbuf[2] := operand0; outbuf[3] := BYTE_COMMAND_STROBE or operand1; outbuf[4] := operand2; outbuf[5] := BYTE_COMMAND_STROBE or operand3; outbuf[6] := serviceByte; for i := 0 to 6 do begin fADCDevice.PortIO( ADC_PORTIO_OUTB, @outbuf[i], 1 ); DelayUS( fDigitalPortSendPeriod ); end; //читаем с шины результат выполнения команды DelayUS( fDigitalPortSendPeriod * 2 ); inbuf[0] := 0; fADCDevice.PortIO( ADC_PORTIO_INB, @inbuf[0], 1 ); b := inbuf[0]; if not ( b and 128 = 128 ) then // не установлен бит успешного приёма команды Result := fErrorCode or ERR_SEND_COMMAND_PARITY_CHECK; if b and 64 = 64 then Result := fErrorCode or ERR_PERFORM_COMMAND; end; procedure TLa24UsbScanThread.Cleanup( Sender: TObject ); begin gLogger.Debug( ClassName, 'Cleanup' ); if fADCDevice <> nil then begin fADCDevice.Stop( ); fADCDevice.Release; end; SetLength( fCommandBuffer, 0 ); SetLength( fCommandTempBuffer, 0 ); SetLength( fPortMultiBuffer, 0 ); FreeAndNil( fDevDescriptor ); // ResetEvent( hEventForCaptureTh ); gLogger.Error( ClassName, 'Cleanup Ok' ); end; procedure TLa24UsbScanThread.SendCommands( ); var res: byte; doCommand: boolean; count: integer; i: word; //workBuffer: array of RCommand; //рабочий буфер команд для исполнения begin //ждём, пока буфер команд не освободитьтся для работы if fDisableCommandBufferAccess then exit; // if fDisableCommandBufferAccess do // Sleep( 1 ); fDisableCommandBufferAccess := true; //лочим буфер команд для работы //перепысываем команды на выполнение в рабочий буфер, чтобы не занимать основной буфер команд надолго SetLength( fCommandTempBuffer, Length( fCommandBuffer ) ); for i := 0 to Length( fCommandBuffer ) - 1 do begin if Length( fCommandTempBuffer ) <> Length( fCommandBuffer ) then raise Exception.Create( 'fuck!' ); fCommandTempBuffer[i] := fCommandBuffer[i]; end; SetLength( fCommandBuffer, 0 ); fDisableCommandBufferAccess := false; //освобождаем буфер команд gLogger.Debug( ClassName, 'Performing ' + IntToStr( Length( fCommandTempBuffer ) ) + ' commands from buffer.' ); fErrorCode := ERR_NO_ERROR; for i := 0 to Length( fCommandTempBuffer ) - 1 do begin //команды выполняем с неск-кими попытками если была ошибка чётности count := 0; doCommand := true; while doCommand do begin gLogger.Debug( ClassName, 'Perform command: ' + GetEnumName( TypeInfo( TArduinoCommand ), Ord( fCommandTempBuffer[i].command ) ) + '(' + IntToStr( Ord( fCommandTempBuffer[i].command ) ) + ') : ' + IntToStr( fCommandTempBuffer[i].operand ) ); res := PerformCommand( fCommandTempBuffer[i].command, fCommandTempBuffer[i].operand ); if res = ERR_NO_ERROR then begin gLogger.Debug( ClassName, ' OK!' ); break; end else if res and ERR_PERFORM_COMMAND = ERR_PERFORM_COMMAND then begin fErrorCode := fErrorCode or ERR_PERFORM_COMMAND; gLogger.Error( ClassName, ' Error PERFORM COMMAND: ERR_PERFORM_COMMAND' ); break; end else if ( res and ERR_SEND_COMMAND_PARITY_CHECK = ERR_SEND_COMMAND_PARITY_CHECK ) and ( count <= 1 ) then begin //если это ошибка чётности (ощшбка передачи), то повторяем один раз, затем отваливаемся fErrorCode := fErrorCode or ERR_SEND_COMMAND_PARITY_CHECK; gLogger.Error( ClassName, ' Error SEND COMMAND: ERR_SEND_COMMAND_PARITY_CHECK' ); Inc( count ); end else if ( res and ERR_SEND_COMMAND_PARITY_CHECK = ERR_SEND_COMMAND_PARITY_CHECK ) and ( count > 1 ) then begin //если это ошибка чётности (ощшбка передачи), то повторяем один раз, затем отваливаемся fErrorCode := fErrorCode or ERR_SEND_COMMAND_PARITY_CHECK; gLogger.Error( ClassName, ' Error SEND COMMAND:ERR_SEND_COMMAND_PARITY_CHECK' ); break; end; end; end; SetLength( fCommandTempBuffer, 0 ); end; procedure TLa24UsbScanThread.SetupHardware; var gains: TIntegerArray; chNumbers: TIntegerArray; fAdcParams: ADCParametersDMA; fAdcParamsEx: ADCParametersDMAEx; resultingFreq: single; i, res: integer; begin fADCDevice := GetADCDevice( BOARD_NAME ); res := fADCDevice.Setup( BASE_ADDRESS, 0, 0, 0 ); if res <> 1 then raise Exception.Create( GetErrMsg( res ) ); SetLength( gains, fNumChannels ); SetLength( chNumbers, fNumChannels ); chNumbers := fDevDescriptor.getChannelNumbers; gains := fDevDescriptor.getChannelGains; // Инициализируем структуру параметров DMAEX, её надо устанавливать ДО инициализации основной структуры DMA fAdcParamsEx.Create; with fAdcParamsEx do begin m_pnGains := Pointer( gains ); m_pnChannels := Pointer( chNumbers ); m_nSize := MAX_CHANNELS; //сканируем всегда 4 канала, чтобы быстрее готовился блок данных m_nControl := ADC_DMAEX_CONTROL_GAIN; m_nSyncLevel[0] := 0; m_nSyncLevel[1] := 0; end; // if res <> 1 then // raise Exception.Create( GetErrMsg( res ) ); // Инициализируем основную структуру параметров DMA fAdcParams.Create; with fAdcParams do begin m_nStartOf := ADCPARAM_START_TIMER; // источник запусков m_nIntOf := 0; // для данного случая не важно m_nDMABlockSize := 0; // для данного случая не важно m_nDMAMode := $01000000; //Режим непрерывного сбора m_fFreqStart := gConfig.frequency; //частота сбора данных m_nTimerStart := 0; // канал таймера для запусков m_fFreqPack := 0; // для пакетного сбора (0 - не используется) m_nTimerPack := 0; // для пакетного сбора m_nFirstChannel := 0; // первый канал m_nChannelNumber := MAX_CHANNELS; // количество каналов на Usb плате m_nGain := 1; //общий коэффициент усиления end; i := 0; // Log(i); res := fADCDevice.Init( ADC_INIT_MODE_INIT, @fAdcParams, @resultingFreq ); if res <> 1 then raise Exception.Create( GetErrMsg( res ) ); res := fADCDevice.Init( ADC_INIT_MODE_INIT, @fAdcParamsEx, @resultingFreq ); if res <> 1 then raise Exception.Create( GetErrMsg( res ) ); if fDevDescriptor.IsDifferentialMode( ) then begin i := 1; res := fADCDevice.Get( ADC_SET_ADCMODE_DIFF, @i ); if res <> 1 then raise Exception.Create( GetErrMsg( res ) ); end; end; procedure TLa24UsbScanThread.StartADC; begin gLogger.Debug( ClassName, 'StartADC' ); inherited; fCurrDMACounter := 0; fOldDMAcounter := 0; fDeltaCounter := 0; //fADCDevice.Stop( ); //ниже выхывается полный инит АЦП иначе были сбои при первом старте АЦП после подключения, первый раз стартовал, а потом не всегда стартовал SetupHardware( ); // SetupHardware( ); // fADCDevice.Stop( ); fADCDevice.Start( ); //а потом чтобы победить глюк под вин 7 64 ещё раз вызывается Sleep( 100 ); fADCDevice.Stop( ); SetupHardware( ); fADCDevice.Start( ); end; procedure TLa24UsbScanThread.StopADC; begin gLogger.Debug( ClassName, 'StopADC' ); fADCDevice.Stop( ); end; end.
(* Copyright (c) 2012-2014, Stefan Glienke All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name of this library nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *) unit DSharp.Interception.PolicySet; interface uses DSharp.Interception, DSharp.Interception.MethodImplementationInfo, Generics.Collections, Rtti; type TPolicySet = class(TList<IInjectionPolicy>) private function CalculateHandlersFor(Member: TMethodImplementationInfo): TArray<ICallHandler>; public constructor Create(const Policies: array of IInjectionPolicy); function GetPoliciesFor(Method: TMethodImplementationInfo): TArray<IInjectionPolicy>; function GetPoliciesNotFor(Method: TMethodImplementationInfo): TArray<IInjectionPolicy>; function GetHandlersFor(Member: TMethodImplementationInfo): TArray<ICallHandler>; end; implementation { TPolicySet } constructor TPolicySet.Create(const Policies: array of IInjectionPolicy); begin inherited Create; AddRange(Policies); end; function TPolicySet.CalculateHandlersFor( Member: TMethodImplementationInfo): TArray<ICallHandler>; var ordered: TList<ICallHandler>; nonOrdered: TList<ICallHandler>; policy: IInjectionPolicy; handler: ICallHandler; inserted: Boolean; i: Integer; begin ordered := TList<ICallHandler>.Create; nonOrdered := TList<ICallHandler>.Create; try for policy in Self do begin for handler in policy.GetHandlersFor(Member) do begin if not Assigned(handler) then Continue; if handler.Order <> 0 then begin inserted := False; for i := ordered.Count - 1 downto 0 do begin if ordered[i].Order <= handler.Order then begin ordered.Insert(i + 1, handler); inserted := True; Break; end; end; if not inserted then begin ordered.Insert(0, handler); end; end else begin nonOrdered.Add(handler); end; end; end; ordered.AddRange(nonOrdered); Result := ordered.ToArray; finally ordered.Free; nonOrdered.Free; end; end; function TPolicySet.GetHandlersFor( Member: TMethodImplementationInfo): TArray<ICallHandler>; begin Result := CalculateHandlersFor(Member); end; function TPolicySet.GetPoliciesFor( Method: TMethodImplementationInfo): TArray<IInjectionPolicy>; var policy: IInjectionPolicy; begin for policy in Self do begin if policy.Matches(Method) then begin SetLength(Result, Length(Result) + 1); Result[High(Result)] := policy; end; end; end; function TPolicySet.GetPoliciesNotFor( Method: TMethodImplementationInfo): TArray<IInjectionPolicy>; var policy: IInjectionPolicy; begin for policy in Self do begin if not policy.Matches(Method) then begin SetLength(Result, Length(Result) + 1); Result[High(Result)] := policy; end; end; end; end.
unit NvmlApi; {$mode objfpc}{$H+} interface uses Classes, SysUtils; const NvLib = 'nvml.dll'; NvmlInitFlagNoAttach = 2; NvmlInitFlagNoGpus = 1; NvmlDevicePciBusIdBufferSize = 32; NvmlDevicePciBusIdBufferV2Size = 16; type NvHandle = PtrUInt; NvDeviceArchitecture = Byte; ENvSystemException = class(Exception); TNvmlTemperatureSensors = (nvTemperatureGpu = 0, nvTemperatureCount); TNvmlTemperatureThresholds = (nvTemperatureThresholdShutdown = 0, nvTemperatureThresholdSlowdown, nvTemperatureThresholdMemMax, nvTemperatureThresholdGpuMax, nvTemperatureThresholdCount); TNvmlReturn = (nvSuccess = 0, nvErrorUnInitialized = 1, nvErrorInvalidArgument = 2, nvErrorNotSupported = 3, nvErrorNoPermission = 4, nvErrorAlreadyInitialized = 5, nvErrorNotFound = 6, nvErrorInsufficientSize = 7, nvErrorInsufficientPower = 8, nvErrorDriverNotLoaded = 9, nvErrorTimeout = 10, nvErrorIrqIssue = 11, nvErrorLibraryNotFound = 12, nvErrorFunctionNotFound = 13, nvErrorCorruptedInforom = 14, nvErrorGpuIsLost = 15, nvErrorResetRequired = 16, nvErrorOperatingSystem = 17, nvErrorLibRmVersionMismatch = 18, nvErrorInUse = 19, nvErrorMemory = 20, nvErrorNoData = 21, nvErrorVgpuEccNotSupported = 22, nvErrorInsufficientResources = 23, nvErrorUnknown = 999); TNvmlEnableState = (nvFeatureDisable = 0, nvFeatureEnable); TNvmlRestrictedApi = (nvRestrictedApiSetApplicationClock = 0, nvRestrictedApiSetAutoBoostedClocks, nvRestrictedApiCount); TNvmlClockType = (nvClockGraphics = 0, nvClockSm, nvClockMem, nvClockVideo, nvClockCount); TNvmlDeviceAttributes = record MultiprocessorCount: Cardinal; SharedCopyEngineCount: Cardinal; SharedDecoderCount: Cardinal; SharedEncoderCount: Cardinal; SharedJpegCount: Cardinal; SharedOfaCount: Cardinal; GpuInstanceSliceCount: Cardinal; ComputeInstanceSliceCount: Cardinal; MemorySizeMB: UInt64; end; TNvmlPciInfo = record BusIdLegacy: array [0..NvmlDevicePciBusIdBufferV2Size] of Int8; Domain: Cardinal; Bus: Cardinal; Device: Cardinal; PciSubSystemId: Cardinal; BusId: array [0..NvmlDevicePciBusIdBufferSize] of Int8; end; procedure NvInitWithFlags(flags: Cardinal); procedure NvInitV2; procedure NvShutDown; function NvCudaDriverVersionMajor(version: Integer): Integer; function NvSystemGetCudaDriverVersion: Integer; function NvmlSystemGetCudaDriverVersionV2: Integer; function NvSystemGetDriverVersion(length: Cardinal = 20): Ansistring; function NvSystemGetNVMLVersion(Length: Cardinal = 20): Ansistring; function NvDeviceGetHandleByIndexV2(index: Cardinal): NvHandle; function NvDeviceGetAPIRestriction(device: NvHandle; apiType: TNvmlRestrictedApi): TNvmlEnableState; function NvDeviceGetApplicationsClock(device: NvHandle; clockType: TNvmlClockType): Cardinal; function NvDeviceGetArchitecture(device: NvHandle): NvDeviceArchitecture; function NvDeviceGetAttributes(device: NvHandle): TNvmlDeviceAttributes; function NvDeviceGetPciInfoV3(device: NvHandle): TNvmlPciInfo; function NvDeviceGetName(device: NvHandle; length: Cardinal = 20): String; function NvDeviceGetCountV2: Cardinal; function NvDeviceGetTemperature(device: NvHandle; sensorType: TNvmlTemperatureSensors): Cardinal; function NvDeviceGetTemperatureThreshold(device: NvHandle; thresholdType: TNvmlTemperatureThresholds): Cardinal; function NvDeviceGetClockInfo(Device: NvHandle; ClockType: TNvmlClockType): Cardinal; implementation function nvmlInitWithFlags(flags: Cardinal): TNvmlReturn; cdecl; external NvLib; function nvmlInit_v2: TNvmlReturn; cdecl; external NvLib; function nvmlShutdown: TNvmlReturn; cdecl; external NvLib; function nvmlSystemGetCudaDriverVersion(out cudaDriverVersion: Integer): TNvmlReturn; cdecl; external NvLib; function nvmlSystemGetCudaDriverVersion_v2(out cudaDriverVersion: Integer): TNvmlReturn; cdecl; external NvLib; function nvmlSystemGetDriverVersion(version: PChar; length: Cardinal): TNvmlReturn; cdecl; external NvLib; function nvmlSystemGetNVMLVersion(version: PChar; length: Cardinal): TNvmlReturn; cdecl; external NvLib; function nvmlSystemGetProcessName(pid: Byte; Name: PChar; length: Cardinal): TNvmlReturn; cdecl; external NvLib; function nvmlDeviceGetHandleByIndex_v2(index: Cardinal; out device: NvHandle): TNvmlReturn; cdecl; external NvLib; function nvmlDeviceGetAPIRestriction(device: NvHandle; apiType: TNvmlRestrictedApi; out isRestricted: TNvmlEnableState): TNvmlReturn; cdecl; external NvLib; function nvmlDeviceGetApplicationsClock(device: NvHandle; clockType: TNvmlClockType; out clockMHz: Cardinal): TNvmlReturn; cdecl; external NvLib; function nvmlDeviceGetArchitecture(device: NvHandle; out arch: NvDeviceArchitecture): TNvmlReturn; cdecl; external NvLib; function nvmlDeviceGetAttributes(device: NvHandle; out attributes: TNvmlDeviceAttributes): TNvmlReturn; cdecl; external NvLib; function nvmlDeviceGetPciInfo_v3(device: NvHandle; out pci: TNvmlPciInfo): TNvmlReturn; cdecl; external NvLib; function nvmlDeviceGetName(device: NvHandle; deviceName: PChar; length: Cardinal): TNvmlReturn; cdecl; external NvLib; function nvmlDeviceGetCount_v2(out deviceCount: Cardinal): TNvmlReturn; cdecl; external NvLib; function nvmlDeviceGetTemperature(device: NvHandle; sensorType: TNvmlTemperatureSensors; out temp: Cardinal): TNvmlReturn; cdecl; external NvLib; function nvmlDeviceGetTemperatureThreshold(device: NvHandle; thresholdType: TNvmlTemperatureThresholds; out temp: Cardinal): TNvmlReturn; cdecl; external NvLib; function nvmlDeviceGetClockInfo(Device: NvHandle; ClockType: TNvmlClockType; out clock: Cardinal): TNvmlReturn; cdecl; external NvLib; procedure NvInitWithFlags(flags: Cardinal); var res: TNvmlReturn; ex: String; begin res := nvmlInitWithFlags(flags); if nvSuccess <> res then begin WriteStr(ex, res); raise ENvSystemException.Create(ex); end; end; procedure NvInitV2; var res: TNvmlReturn; ex: String; begin res := nvmlInit_v2; if nvSuccess <> res then begin WriteStr(ex, res); raise ENvSystemException.Create(ex); end; end; procedure NvShutDown; var res: TNvmlReturn; ex: String; begin res := nvmlShutdown; if nvSuccess <> res then begin WriteStr(ex, res); raise ENvSystemException.Create(ex); end; end; function NvCudaDriverVersionMajor(version: Integer): Integer; begin Result := version div 1000; end; function NvmlSystemGetCudaDriverVersionV2: Integer; var version: Integer; ex: String; res: TNvmlReturn; begin res := nvmlSystemGetCudaDriverVersion(version); if nvSuccess <> res then begin WriteStr(ex, res); raise ENvSystemException.Create(ex); end; Result := version; end; function NvSystemGetDriverVersion(length: Cardinal): Ansistring; var version: PChar; res: TNvmlReturn; ex: String; begin version := StrAlloc(length); res := nvmlSystemGetDriverVersion(version, length); if nvSuccess <> res then begin WriteStr(ex, res); StrDispose(version); raise ENvSystemException.Create(ex); end; Result := version; StrDispose(version); end; function NvSystemGetNVMLVersion(Length: Cardinal): Ansistring; var version: PChar; res: TNvmlReturn; ex: String; begin version := StrAlloc(Length); res := nvmlSystemGetNVMLVersion(version, Length); if nvSuccess <> res then begin WriteStr(ex, res); StrDispose(version); raise ENvSystemException.Create(ex); end; Result := version; StrDispose(version); end; function NvDeviceGetHandleByIndexV2(index: Cardinal): NvHandle; var handle: NvHandle; res: TNvmlReturn; ex: String; begin handle := 0; res := nvmlDeviceGetHandleByIndex_v2(index, handle); if nvSuccess <> res then begin WriteStr(ex, res); raise ENvSystemException.Create(ex); end; Result := handle; end; function NvDeviceGetAPIRestriction(device: NvHandle; apiType: TNvmlRestrictedApi): TNvmlEnableState; var state: TNvmlEnableState; ex: String; res: TNvmlReturn; begin res := nvmlDeviceGetAPIRestriction(device, apiType, state); if nvSuccess <> res then begin WriteStr(ex, res); raise ENvSystemException.Create(ex); end; Result := state; end; function NvDeviceGetApplicationsClock(device: NvHandle; clockType: TNvmlClockType): Cardinal; var clock: Cardinal; res: TNvmlReturn; ex: String; begin res := nvmlDeviceGetApplicationsClock(device, clockType, clock); if nvSuccess <> res then begin WriteStr(ex, res); raise ENvSystemException.Create(ex); end; Result := clock; end; function NvDeviceGetArchitecture(device: NvHandle): NvDeviceArchitecture; var res: TNvmlReturn; arch: NvDeviceArchitecture; ex: String; begin res := nvmlDeviceGetArchitecture(device, arch); if nvSuccess <> res then begin WriteStr(ex, res); raise ENvSystemException.Create(ex); end; Result := arch; end; function NvDeviceGetAttributes(device: NvHandle): TNvmlDeviceAttributes; var res: TNvmlReturn; attributes: TNvmlDeviceAttributes; ex: String; begin res := nvmlDeviceGetAttributes(device, attributes); if nvSuccess <> res then begin WriteStr(ex, res); raise ENvSystemException.Create(ex); end; Result := attributes; end; function NvDeviceGetPciInfoV3(device: NvHandle): TNvmlPciInfo; var res: TNvmlReturn; info: TNvmlPciInfo; ex: String; begin res := nvmlDeviceGetPciInfo_v3(device, info); if nvSuccess <> res then begin WriteStr(ex, res); raise ENvSystemException.Create(ex); end; Result := info; end; function NvDeviceGetName(device: NvHandle; length: Cardinal): String; var res: TNvmlReturn; ex: String; deviceName: PChar; begin deviceName := StrAlloc(length); res := nvmlDeviceGetName(device, deviceName, length); if nvSuccess <> res then begin WriteStr(ex, res); StrDispose(deviceName); raise ENvSystemException.Create(ex); end; Result := deviceName; StrDispose(deviceName); end; function NvDeviceGetCountV2: Cardinal; var Count: Cardinal; ex: String; res: TNvmlReturn; begin res := nvmlDeviceGetCount_v2(Count); if nvSuccess <> res then begin WriteStr(ex, res); raise ENvSystemException.Create(ex); end; Result := Count; end; function NvDeviceGetTemperature(device: NvHandle; sensorType: TNvmlTemperatureSensors): Cardinal; var temp: Cardinal; ex: String; res: TNvmlReturn; begin temp := 0; res := nvmlDeviceGetTemperature(device, sensorType, temp); if nvSuccess <> res then begin WriteStr(ex, res); raise ENvSystemException.Create(ex); end; Result := temp; end; function NvDeviceGetTemperatureThreshold(device: NvHandle; thresholdType: TNvmlTemperatureThresholds): Cardinal; var temp: Cardinal; ex: String; res: TNvmlReturn; begin temp := 0; res := nvmlDeviceGetTemperatureThreshold(device, thresholdType, temp); if nvSuccess <> res then begin WriteStr(ex, res); raise ENvSystemException.Create(ex); end; Result := temp; end; function NvDeviceGetClockInfo(Device: NvHandle; ClockType: TNvmlClockType): Cardinal; var Ex: String; Res: TNvmlReturn; Speed: Cardinal; begin Res := nvmlDeviceGetClockInfo(Device, ClockType, Speed); if nvSuccess <> res then begin WriteStr(Ex, Res); raise ENvSystemException.Create(Ex); end; Result:= Speed; end; function NvSystemGetCudaDriverVersion: Integer; var version: Integer; ex: String; res: TNvmlReturn; begin res := nvmlSystemGetCudaDriverVersion(version); if nvSuccess <> res then begin WriteStr(ex, res); raise ENvSystemException.Create(ex); end; Result := version; end; end.
{***************************************************************************} { } { DUnitX } { } { Copyright (C) 2015 Vincent Parrett & Contributors } { } { vincent@finalbuilder.com } { http://www.finalbuilder.com } { } { } {***************************************************************************} { } { Licensed under the Apache License, Version 2.0 (the "License"); } { you may not use this file except in compliance with the License. } { You may obtain a copy of the License at } { } { http://www.apache.org/licenses/LICENSE-2.0 } { } { Unless required by applicable law or agreed to in writing, software } { distributed under the License is distributed on an "AS IS" BASIS, } { WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. } { See the License for the specific language governing permissions and } { limitations under the License. } { } {***************************************************************************} unit DUnitX.Expert.CodeGen.Templates; interface {$I DUnitX.inc} resourcestring { Delphi template code } STestDPR = 'program %0:s;'#13#10 + #13#10 + '{$IFNDEF TESTINSIGHT}'#13#10 + '{$APPTYPE CONSOLE}'#13#10 + '{$ENDIF}'#13#10 + '{$STRONGLINKTYPES ON}'#13#10 + 'uses'#13#10 + '%1:s' + {$IFDEF USE_NS} ' System.SysUtils,'#13#10 + {$ELSE} ' SysUtils,'#13#10 + {$ENDIF} '{$IFDEF TESTINSIGHT}'#13#10 + ' TestInsight.DUnitX,'#13#10 + '{$ELSE}'#13#10 + ' DUnitX.Loggers.Console,'#13#10 + ' DUnitX.Loggers.Xml.NUnit,'#13#10 + '{$ENDIF}'#13#10 + ' DUnitX.TestFramework;'#13#10 + #13#10 + '{ keep comment here to protect the following conditional from being removed by the IDE when adding a unit }'#13#10 + '{$IFNDEF TESTINSIGHT}'#13#10 + 'var'#13#10 + ' runner: ITestRunner;'#13#10 + ' results: IRunResults;'#13#10 + ' logger: ITestLogger;'#13#10 + ' nunitLogger : ITestLogger;'#13#10 + '{$ENDIF}'#13#10 + 'begin'#13#10 + '{$IFDEF TESTINSIGHT}'#13#10 + ' TestInsight.DUnitX.RunRegisteredTests;'#13#10 + '{$ELSE}'#13#10 + ' try'#13#10 + ' //Check command line options, will exit if invalid'#13#10 + ' TDUnitX.CheckCommandLine;'#13#10 + ' //Create the test runner'#13#10 + ' runner := TDUnitX.CreateRunner;'#13#10 + ' //Tell the runner to use RTTI to find Fixtures'#13#10 + ' runner.UseRTTI := True;'#13#10 + ' //When true, Assertions must be made during tests;'#13#10 + ' runner.FailsOnNoAsserts := False;'#13#10 + #13#10 + ' //tell the runner how we will log things'#13#10 + ' //Log to the console window if desired'#13#10 + ' if TDUnitX.Options.ConsoleMode <> TDunitXConsoleMode.Off then'#13#10 + ' begin'#13#10 + ' logger := TDUnitXConsoleLogger.Create(TDUnitX.Options.ConsoleMode = TDunitXConsoleMode.Quiet);'#13#10 + ' runner.AddLogger(logger);'#13#10 + ' end;'#13#10 + ' //Generate an NUnit compatible XML File'#13#10 + ' nunitLogger := TDUnitXXMLNUnitFileLogger.Create(TDUnitX.Options.XMLOutputFile);'#13#10 + ' runner.AddLogger(nunitLogger);'#13#10 + #13#10 + ' //Run tests'#13#10 + ' results := runner.Execute;'#13#10 + ' if not results.AllPassed then'#13#10 + ' System.ExitCode := EXIT_ERRORS;'#13#10 + #13#10 + ' {$IFNDEF CI}'#13#10 + ' //We don''t want this happening when running under CI.'#13#10 + ' if TDUnitX.Options.ExitBehavior = TDUnitXExitBehavior.Pause then'#13#10 + ' begin'#13#10 + ' System.Write(''Done.. press <Enter> key to quit.'');'#13#10 + ' System.Readln;'#13#10 + ' end;'#13#10 + ' {$ENDIF}'#13#10 + ' except'#13#10 + ' on E: Exception do'#13#10 + ' System.Writeln(E.ClassName, '': '', E.Message);'#13#10 + ' end;'#13#10 + '{$ENDIF}'#13#10 + 'end.'#13#10; // 0 - Unit Name // 1 - Class Name // 2 - Setup/TearDown Methods - Interface // 3 - Sample Methods - Interface // 4 - Setup/TearDown Methods - Implementation // 5 - Sample Methods - Implementation STestUnit = 'unit %0:s;'#13#10 + #13#10 + 'interface'#13#10 + #13#10 + 'uses'#13#10 + ' DUnitX.TestFramework;'#13#10 + #13#10 + 'type'#13#10 + ' [TestFixture]'#13#10 + ' %1:s = class'#13#10 + ' public'#13#10 + '%2:s%3:s' + ' end;'#13#10 + #13#10 + 'implementation'#13#10 + '%4:s%5:s' + #13#10 + 'initialization'#13#10 + ' TDUnitX.RegisterTestFixture(%1:s);'#13#10 + #13#10 + 'end.'#13#10; SSetupTearDownIntf = ' [Setup]'#13#10 + ' procedure Setup;'#13#10 + ' [TearDown]'#13#10 + ' procedure TearDown;'#13#10; // 0 - Class Name SSetupTearDownImpl = #13#10 + 'procedure %0:s.Setup;'#13#10 + 'begin'#13#10 + 'end;'#13#10 + #13#10 + 'procedure %0:s.TearDown;'#13#10 + 'begin'#13#10 + 'end;'#13#10; SSampleMethodsIntf = ' // Sample Methods'#13#10 + ' // Simple single Test'#13#10 + ' [Test]'#13#10 + ' procedure Test1;'#13#10 + ' // Test with TestCase Attribute to supply parameters.'#13#10 + ' [Test]'#13#10 + ' [TestCase(''TestA'',''1,2'')]'#13#10 + ' [TestCase(''TestB'',''3,4'')]'#13#10 + ' procedure Test2(const AValue1 : Integer;const AValue2 : Integer);'#13#10; // 0 - Class Name //TODO: Show Examples of calling Assert SSampleMethodsImpl = #13#10 + 'procedure %0:s.Test1;'#13#10 + 'begin'#13#10 + 'end;'#13#10 + #13#10 + 'procedure %0:s.Test2(const AValue1 : Integer;const AValue2 : Integer);'#13#10 + 'begin'#13#10 + 'end;'#13#10; SDefaultClassName = 'TMyTestObject'; { C++Builder template code } STestCBPROJ = '#include <System.Sysutils.hpp>'#13#10 + '#include <DUnitX.Loggers.Console.hpp>'#13#10 + '#include <DUnitX.Loggers.Xml.NUnit.hpp>'#13#10 + '#include <DUnitX.TestFramework.hpp>'#13#10 + '#include <stdio.h>'#13#10 + #13#10 + 'int main()'#13#10 + '{'#13#10 + ' try'#13#10 + ' {'#13#10 + ' TDUnitX::CheckCommandLine();'#13#10 + ' _di_ITestRunner runner = TDUnitX::CreateRunner();'#13#10 + ' _di_ITestLogger logger(*new TDUnitXConsoleLogger(true));'#13#10 + ' runner->AddLogger(logger);'#13#10 + #13#10 + ' _di_ITestLogger nunitLogger(*new TDUnitXXMLNUnitFileLogger(TDUnitX::Options->XMLOutputFile));'#13#10 + ' runner->AddLogger(nunitLogger);'#13#10 + #13#10 + ' _di_IRunResults results = runner->Execute();'#13#10 + #13#10 + '#if !defined(CI)'#13#10 + ' if (TDUnitX::Options->ExitBehavior == TDUnitXExitBehavior::Pause)'#13#10 + ' {'#13#10 + ' printf("Done.. press <Enter> key to quit.");'#13#10 + ' getchar();'#13#10 + ' }'#13#10 + '#endif'#13#10 + #13#10 + ' return results->AllPassed ? EXIT_SUCCESS : EXIT_FAILURE;'#13#10 + ' }'#13#10 + ' catch(System::Sysutils::Exception& Ex)'#13#10 + ' {'#13#10 + ' printf("Exception: ''''%s''''\n", AnsiString(Ex.Message).c_str());'#13#10 + ' }'#13#10 + ' return EXIT_FAILURE;'#13#10 + '}'; STestCPPUnit = '#include <DUnitX.TestFramework.hpp>'#13#10 + '#include <stdio.h>'#13#10 + #13#10 + '#pragma option --xrtti'#13#10 + #13#10 + 'class __declspec(delphirtti) %1:s : public TObject'#13#10 + '{'#13#10 + 'public:'#13#10 + '%2:s' + #13#10 + '__published:'#13#10 + '%3:s' + '};'#13#10 + #13#10 + #13#10 + '%4:s' + #13#10 + '%5:s' + #13#10 + 'static void registerTests()'#13#10 + '{'#13#10 + ' TDUnitX::RegisterTestFixture(__classid(%1:s));'#13#10 + '}'#13#10 + '#pragma startup registerTests 33'; SSetupTearDownCPPIntf = ' virtual void __fastcall SetUp();'#13#10 + ' virtual void __fastcall TearDown();'#13#10; SSetupTearDownCPPImpl = 'void __fastcall %0:s::SetUp()'#13#10 + '{'#13#10 + '}'#13#10 + #13#10 + 'void __fastcall %0:s::TearDown()'#13#10 + '{'#13#10 + '}'#13#10; SSampleMethodsCPPIntf = ' void __fastcall Test1();'#13#10 + ' void __fastcall Test2();'#13#10; SSampleMethodsCPPImpl = 'void __fastcall %0:s::Test1()'#13#10 + '{'#13#10 + ' // TODO'#13#10 + ' String s("Hello");'#13#10 + ' Dunitx::Testframework::Assert::IsTrue(s == "Hello");'#13#10 + '}'#13#10 + #13#10 + 'void __fastcall %0:s::Test2()'#13#10 + '{'#13#10 + ' // TODO'#13#10 + ' String s("Hello");'#13#10 + ' Dunitx::Testframework::Assert::IsTrue(s == "Bonjour"); // This fails for illustrative purposes'#13#10 + '}'#13#10; implementation end.
unit NtUtils.Security.Sid; { The module adds support for common operations on Security Identifiers. } interface uses Ntapi.WinNt, Ntapi.ntseapi, Ntapi.WinBase, NtUtils; const SERVICE_SID_DOMAIN = 'NT SERVICE'; TASK_SID_DOMAIN = 'NT TASK'; { Construction } // Build a new SID function RtlxCreateSid( out Sid: ISid; const IdentifyerAuthority: TSidIdentifierAuthority; [opt] const SubAuthouritiesArray: TArray<Cardinal> = nil ): TNtxStatus; // Build a new SID without failing function RtlxMakeSid( const IdentifyerAuthority: TSidIdentifierAuthority; [opt] const SubAuthouritiesArray: TArray<Cardinal> = nil ): ISid; // Validate the intput buffer and capture a copy as a SID function RtlxCopySid( [in] Buffer: PSid; out NewSid: ISid ): TNtxStatus; { Information } // Retrieve a copy of identifier authority of a SID as UIn64 function RtlxIdentifierAuthoritySid( const Sid: ISid ): UInt64; // Retrieve an array of sub-authorities of a SID function RtlxSubAuthoritiesSid( const Sid: ISid ): TArray<Cardinal>; // Check if two SIDs are equal function RtlxEqualSids( const Sid1: ISid; const Sid2: ISid ): Boolean; // Retrieve the RID (the last sub-authority) of a SID function RtlxRidSid( const Sid: ISid; Default: Cardinal = 0 ): Cardinal; // Construct a child SID (add a sub authority) function RtlxMakeChildSid( out ChildSid: ISid; const ParentSid: ISid; Rid: Cardinal ): TNtxStatus; // Construct a parent SID (remove the last sub authority) function RtlxMakeParentSid( out ParentSid: ISid; const ChildSid: ISid ): TNtxStatus; // Construct a sibling SID (change the last sub authority) function RtlxMakeSiblingSid( out SiblingSid: ISid; const SourceSid: ISid; Rid: Cardinal ): TNtxStatus; // Sorting function RtlxCompareSids( const SidA: ISid; const SidB: ISid ): Integer; { Custom SID Representation } type // A prototype for registering custom recognizers that convert strings to SIDs TSidNameRecognizer = function ( const SidString: String; out Sid: ISid ): Boolean; // A prototype for registering custom lookup providers TSidNameProvider = function ( const Sid: ISid; out SidType: TSidNameUse; out SidDomain: String; out SidUser: String ): Boolean; // Add a function for recognizing custom names for SIDs procedure RtlxRegisterSidNameRecognizer( const Recognizer: TSidNameRecognizer ); // Add a function for represnting SIDs under custom names procedure RtlxRegisterSidNameProvider( const Provider: TSidNameProvider ); // Convert a SID to a human readable form using custom (fake) name providers function RtlxLookupSidInCustomProviders( const Sid: ISid; out SidType: TSidNameUse; out DomainName: String; out UserName: String ): Boolean; { SDDL } // Convert a SID to its SDDL representation function RtlxSidToString( const Sid: ISid ): String; // Convert SDDL string to a SID function RtlxStringToSid( const SDDL: String; out Sid: ISid ): TNtxStatus; // A converter from SDDL string to a SID for use with array conversion function RtlxStringToSidConverter( const SDDL: String; out Sid: ISid ): Boolean; { Well known SIDs } // Derive a service SID from a service name function RtlxCreateServiceSid( const ServiceName: String; out Sid: ISid ): TNtxStatus; // Derive a virtual account SID function RtlxCreateVirtualAccountSid( const ServiceName: String; BaseSubAuthority: Cardinal; out Sid: ISid ): TNtxStatus; // Construct a well-known SID function SddlxCreateWellKnownSid( WellKnownSidType: TWellKnownSidType; out Sid: ISid ): TNtxStatus; implementation uses Ntapi.ntdef, Ntapi.ntrtl, Ntapi.ntstatus, NtUtils.SysUtils, NtUtils.Errors; {$BOOLEVAL OFF} {$IFOPT R+}{$DEFINE R+}{$ENDIF} {$IFOPT Q+}{$DEFINE Q+}{$ENDIF} { Construction } function RtlxCreateSid; var i: Integer; begin IMemory(Sid) := Auto.AllocateDynamic( RtlLengthRequiredSid(Length(SubAuthouritiesArray))); Result.Location := 'RtlInitializeSid'; Result.Status := RtlInitializeSid(Sid.Data, @IdentifyerAuthority, Length(SubAuthouritiesArray)); // Fill in the sub authorities if Result.IsSuccess then for i := 0 to High(SubAuthouritiesArray) do RtlSubAuthoritySid(Sid.Data, i)^ := SubAuthouritiesArray[i]; end; function RtlxMakeSid; var i: Integer; begin IMemory(Result) := Auto.AllocateDynamic( RtlLengthRequiredSid(Length(SubAuthouritiesArray))); if not RtlInitializeSid(Result.Data, @IdentifyerAuthority, Length(SubAuthouritiesArray)).IsSuccess then begin // Construct manually on failure Result.Data.Revision := SID_REVISION; Result.Data.SubAuthorityCount := Length(SubAuthouritiesArray); Result.Data.IdentifierAuthority := IdentifyerAuthority; end; // Fill in the sub authorities for i := 0 to High(SubAuthouritiesArray) do RtlSubAuthoritySid(Result.Data, i)^ := SubAuthouritiesArray[i]; end; function RtlxCopySid; begin if not Assigned(Buffer) or not RtlValidSid(Buffer) then begin Result.Location := 'RtlValidSid'; Result.Status := STATUS_INVALID_SID; Exit; end; IMemory(NewSid) := Auto.AllocateDynamic(RtlLengthSid(Buffer)); Result.Location := 'RtlCopySid'; Result.Status := RtlCopySid(RtlLengthSid(Buffer), NewSid.Data, Buffer); end; { Information } function RtlxIdentifierAuthoritySid; begin Result := RtlIdentifierAuthoritySid(Sid.Data)^; end; function RtlxSubAuthoritiesSid; var i: Integer; begin SetLength(Result, RtlSubAuthorityCountSid(Sid.Data)^); for i := 0 to High(Result) do Result[i] := RtlSubAuthoritySid(Sid.Data, i)^; end; function RtlxEqualSids; begin Result := RtlEqualSid(Sid1.Data, Sid2.Data); end; function RtlxRidSid; begin if RtlSubAuthorityCountSid(Sid.Data)^ > 0 then Result := RtlSubAuthoritySid(Sid.Data, RtlSubAuthorityCountSid(Sid.Data)^ - 1)^ else Result := Default; end; function RtlxMakeChildSid; begin // Add a new sub authority at the end Result := RtlxCreateSid(ChildSid, RtlIdentifierAuthoritySid(ParentSid.Data)^, Concat(RtlxSubAuthoritiesSid(ParentSid), [Rid])); end; function RtlxMakeParentSid; var SubAuthorities: TArray<Cardinal>; begin // Retrieve existing sub authorities SubAuthorities := RtlxSubAuthoritiesSid(ChildSid); if Length(SubAuthorities) > 0 then begin // Drop the last one Delete(SubAuthorities, High(SubAuthorities), 1); Result := RtlxCreateSid(ParentSid, RtlIdentifierAuthoritySid(ChildSid.Data)^, SubAuthorities); end else begin // No parent SID available Result.Location := 'RtlxMakeParentSid'; Result.Status := STATUS_INVALID_SID; end; end; function RtlxMakeSiblingSid; var SubAuthorities: TArray<Cardinal>; begin SubAuthorities := RtlxSubAuthoritiesSid(SourceSid); if Length(SubAuthorities) > 0 then begin // Replace the RID SubAuthorities[High(SubAuthorities)] := Rid; Result := RtlxCreateSid(SiblingSid, RtlIdentifierAuthoritySid(SourceSid.Data)^, SubAuthorities); end else begin // No RID present Result.Location := 'RtlxMakeSiblingSid'; Result.Status := STATUS_INVALID_SID; end; end; function RtlxCompareSids; var i: Integer; A, B: PSid; begin A := SidA.Data; B := SidB.Data; // Compare identifier authorities if UInt64(RtlIdentifierAuthoritySid(A)^) < UInt64(RtlIdentifierAuthoritySid(B)^) then Exit(-1); if UInt64(RtlIdentifierAuthoritySid(A)^) > UInt64(RtlIdentifierAuthoritySid(B)^) then Exit(1); i := 0; Result := 0; // Compare sub authorities while (Result = 0) and (i < RtlSubAuthorityCountSid(A)^) and (i < RtlSubAuthorityCountSid(B)^) do begin if RtlSubAuthoritySid(A, i)^ < RtlSubAuthoritySid(B, i)^ then Exit(-1); if RtlSubAuthoritySid(A, i)^ > RtlSubAuthoritySid(B, i)^ then Exit(1); Inc(i); end; // The shorter SID goes first Result := Integer(RtlSubAuthorityCountSid(A)^) - RtlSubAuthorityCountSid(B)^; end; { SID name parsing } function TryStrToUInt64Ex(S: String; out Value: UInt64): Boolean; var E: Integer; begin if RtlxPrefixString('0x', S) then begin Delete(S, Low(S), 2); Insert('$', S, Low(S)); end; Val(S, Value, E); Result := (E = 0); end; function RtlxZeroSubAuthorityStringToSid( const SDDL: String; out Sid: ISid ): Boolean; var IdAuthority: UInt64; begin // Despite RtlConvertSidToUnicodeString's ability to convert SIDs with // zero sub authorities to SDDL, ConvertStringSidToSidW cannot convert them // back. Fix this issue by parsing them manually. // Expected formats for an SID with 0 sub authorities: // S-1-(\d+) | S-1-(0x[A-F\d]+) // where the value fits into a 6-byte (48-bit) buffer Result := RtlxPrefixString('S-1-', SDDL) and TryStrToUInt64Ex(Copy(SDDL, Length('S-1-') + 1, Length(SDDL)), IdAuthority) and (IdAuthority < UInt64(1) shl 48) and RtlxCreateSid(Sid, IdAuthority).IsSuccess; end; function RtlxLogonStringToSid( const StringSid: String; out Sid: ISid ): Boolean; const FULL_PREFIX = 'NT AUTHORITY\LogonSessionId_'; SHORT_PREFIX = 'LogonSessionId_'; var LogonIdStr: String; SplitIndex: Integer; LogonIdHighString, LogonIdLowString: String; LogonIdHigh, LogonIdLow: Cardinal; i: Integer; begin // LSA lookup functions automatically convert S-1-5-5-X-Y to // NT AUTHORITY\LogonSessionId_X_Y and then refuse to parse them back. // Fix this issue by parsing such strings manually. // Check if the string has the logon SID prefix and strip it if RtlxPrefixString(FULL_PREFIX, StringSid) then LogonIdStr := Copy(StringSid, Length(FULL_PREFIX) + 1, Length(StringSid)) else if RtlxPrefixString(SHORT_PREFIX, StringSid) then LogonIdStr := Copy(StringSid, Length(SHORT_PREFIX) + 1, Length(StringSid)) else Exit(False); // Find the underscore between high and low parts SplitIndex := -1; for i := Low(LogonIdStr) to High(LogonIdStr) do if LogonIdStr[i] = '_' then begin SplitIndex := i; Break; end; if SplitIndex < 0 then Exit(False); // Split the string LogonIdHighString := Copy(LogonIdStr, 1, SplitIndex - Low(String)); LogonIdLowString := Copy(LogonIdStr, SplitIndex - Low(String) + 2, Length(LogonIdStr) - SplitIndex + Low(String)); // Parse and construct the SID Result := (Length(LogonIdHighString) > 0) and (Length(LogonIdLowString) > 0) and RtlxStrToUInt(LogonIdHighString, LogonIdHigh) and RtlxStrToUInt(LogonIdLowString, LogonIdLow) and RtlxCreateSid(Sid, SECURITY_NT_AUTHORITY, [SECURITY_LOGON_IDS_RID, LogonIdHigh, LogonIdLow]).IsSuccess; end; function RtlxServiceNameToSid( const StringSid: String; out Sid: ISid ): Boolean; const PREFIX = SERVICE_SID_DOMAIN + '\'; ALL_SERVICES = PREFIX + 'ALL SERVICES'; begin // Service SIDs are determenistically derived from the service name. // We can parse them even without the help of LSA. Result := False; if not RtlxPrefixString(PREFIX, StringSid) then Exit; // NT SERVICE\ALL SERVICES is a reserved name if RtlxEqualStrings(ALL_SERVICES, StringSid) then Result := RtlxCreateSid(Sid, SECURITY_NT_AUTHORITY, [SECURITY_SERVICE_ID_BASE_RID, SECURITY_SERVICE_ID_GROUP_RID]).IsSuccess else Result := RtlxCreateServiceSid(Copy(StringSid, Length(PREFIX) + 1, Length(StringSid)), Sid).IsSuccess; end; function RtlxTaskNameToSid( const StringSid: String; out Sid: ISid ): Boolean; const PREFIX = TASK_SID_DOMAIN + '\'; begin // Task SIDs are determenistically derived from the task path name. // We can parse them even without the help of LSA. Result := RtlxPrefixString(PREFIX, StringSid) and RtlxCreateVirtualAccountSid(Copy(StringSid, Length(PREFIX) + 1, Length(StringSid)), SECURITY_TASK_ID_BASE_RID, Sid).IsSuccess; end; var CustomSidNameRecognizers: TArray<TSidNameRecognizer>; CustomSidNameProviders: TArray<TSidNameProvider>; procedure RtlxRegisterSidNameRecognizer; begin // Recognizers from other modules SetLength(CustomSidNameRecognizers, Length(CustomSidNameRecognizers) + 1); CustomSidNameRecognizers[High(CustomSidNameRecognizers)] := Recognizer; end; procedure RtlxRegisterSidNameProvider; begin // Providers from other modules SetLength(CustomSidNameProviders, Length(CustomSidNameProviders) + 1); CustomSidNameProviders[High(CustomSidNameProviders)] := Provider; end; function RtlxLookupSidInCustomProviders; var Provider: TSidNameProvider; begin for Provider in CustomSidNameProviders do if Provider(Sid, SidType, DomainName, UserName) then begin Assert(SidType in VALID_SID_TYPES, 'Invalid SID type for custom provider'); Exit(True); end; Result := False; end; { SDDL } function RtlxSidToString; var SDDL: TNtUnicodeString; Buffer: array [0 .. SECURITY_MAX_SID_STRING_CHARACTERS - 1] of WideChar; begin // Since SDDL permits hexadecimals, we can use them to represent some SIDs // in a more user-friendly way. case RtlxIdentifierAuthoritySid(SID) of // Integrity: S-1-16-X SECURITY_MANDATORY_LABEL_AUTHORITY: if RtlSubAuthorityCountSid(SID.Data)^ = 1 then Exit('S-1-16-' + RtlxUIntToStr(RtlSubAuthoritySid(SID.Data, 0)^, 16, 4)); // Trust: S-1-19-X-X SECURITY_PROCESS_TRUST_AUTHORITY: if RtlSubAuthorityCountSid(SID.Data)^ = 2 then Exit('S-1-19-' + RtlxUIntToStr(RtlSubAuthoritySid(SID.Data, 0)^, 16, 3) + '-' + RtlxUIntToStr(RtlSubAuthoritySid(SID.Data, 1)^, 16, 4)); end; SDDL.Length := 0; SDDL.MaximumLength := SizeOf(Buffer); SDDL.Buffer := Buffer; if NT_SUCCESS(RtlConvertSidToUnicodeString(SDDL, Sid.Data, False)) then Result := SDDL.ToString else Result := '(invalid SID)'; end; function RtlxStringToSid; var Buffer: PSid; BufferDeallocator: IAutoReleasable; Recognizer: TSidNameRecognizer; begin // Try well-known name recognizers defined in this module if RtlxZeroSubAuthorityStringToSid(SDDL, Sid) or RtlxLogonStringToSid(SDDL, Sid) or RtlxServiceNameToSid(SDDL, Sid) or RtlxTaskNameToSid(SDDL, Sid) then begin Result.Status := STATUS_SUCCESS; Exit; end; // Try other custom recognizers for Recognizer in CustomSidNameRecognizers do if Recognizer(SDDL, Sid) then begin Assert(Assigned(Sid), 'Custom SID recognizer returned nil.'); Result.Status := STATUS_SUCCESS; Exit; end; // Usual SDDL conversion Result.Location := 'ConvertStringSidToSidW'; Result.Win32Result := ConvertStringSidToSidW(PWideChar(SDDL), Buffer); if not Result.IsSuccess then Exit; BufferDeallocator := AdvxDelayLocalFree(Buffer); Result := RtlxCopySid(Buffer, Sid); end; function RtlxStringToSidConverter; begin // Use this function with TArrayHelper.Convert<String, ISid> Result := RtlxStringToSid(SDDL, Sid).IsSuccess; end; { Well-known SIDs } function RtlxCreateServiceSid; var SidLength: Cardinal; begin Result.Location := 'RtlCreateServiceSid'; SidLength := RtlLengthRequiredSid(SECURITY_SERVICE_ID_RID_COUNT); IMemory(Sid) := Auto.AllocateDynamic(SidLength); repeat Result.Status := RtlCreateServiceSid(TNtUnicodeString.From(ServiceName), Sid.Data, SidLength); until not NtxExpandBufferEx(Result, IMemory(Sid), SidLength, nil); end; function RtlxCreateVirtualAccountSid; var SidLength: Cardinal; begin Result.Location := 'RtlCreateVirtualAccountSid'; SidLength := RtlLengthRequiredSid(SECURITY_VIRTUALACCOUNT_ID_RID_COUNT); IMemory(Sid) := Auto.AllocateDynamic(SidLength); repeat Result.Status := RtlCreateVirtualAccountSid(TNtUnicodeString.From( ServiceName), BaseSubAuthority, Sid.Data, SidLength); until not NtxExpandBufferEx(Result, IMemory(Sid), SidLength, nil); end; function SddlxCreateWellKnownSid; var Required: Cardinal; begin Result.Location := 'CreateWellKnownSid'; IMemory(Sid) := Auto.AllocateDynamic(0); repeat Required := Sid.Size; Result.Win32Result := CreateWellKnownSid(WellKnownSidType, nil, Sid.Data, Required); until not NtxExpandBufferEx(Result, IMemory(Sid), Required, nil); end; end.
unit ISessionUnit; interface uses IGetSelfUnit; type ISession = interface (IGetSelf) procedure Start; procedure Commit; procedure Rollback; function GetIsStarted: Boolean; property IsStarted: Boolean read GetIsStarted; end; implementation end.
program FFchapters; {$mode objfpc}{$H+} {$MACRO ON} {____________________________________________________________ | _______________________________________________________ | | | | | | | FFmpeg based chapter creation | | | | (c) 2018 Alexander Feuster (alexander.feuster@web.de) | | | | http://www.github.com/feuster | | | |_______________________________________________________| | |___________________________________________________________} //define program basics {$DEFINE PROGVERSION:='1.2'} {___________________________________________________________} uses {$IFDEF UNIX}{$IFDEF UseCThreads} cthreads, {$ENDIF}{$ENDIF} Classes, SysUtils, CustApp, { you can add units after this } Windows, StrUtils, math, crt, LazUTF8; type { TApp } TApp = class(TCustomApplication) protected procedure DoRun; override; public constructor Create(TheOwner: TComponent); override; destructor Destroy; override; procedure WriteHelp; virtual; function WindowsOSLanguage: String; end; const //program title STR_Title: String = ' __________________________________________________ '+#13#10+ '| ______________________________________________ |'+#13#10+ '| | | |'+#13#10+ '| |**********************************************| |'+#13#10+ '| | FFmpeg based chapter creation | |'+#13#10+ '| | (c) 2018 Alexander Feuster | |'+#13#10+ '| | http://www.github.com/feuster | |'+#13#10+ '| |______________________________________________| |'+#13#10+ '|__________________________________________________|'+#13#10; //CPU architecture STR_CPU: String = {$I %FPCTARGET%}; //Build date&time STR_Build: String = {$I %DATE%}+' '+{$I %TIME%}; //Date STR_Date: String = {$I %DATE%}; //message strings STR_Warning: String = 'Warning: '; STR_Info: String = 'Info: '; STR_Error: String = 'Error: '; STR_Debug: String = 'Debug: '; STR_Space: String = ' '; var Debug: Boolean; InputFile: TStringList; OutputFile: TStringList; Chapters: TStringList; ChapterFile: String; LogFile: String; Counter: Integer; ReadLine: String; Buffer: String; TIMECODE_Time: Extended; TIMECODE_Sec: Extended; TIMECODE_Sec_Frac:Extended; Hours: Integer; Minutes: Integer; Seconds: Integer; MilliSeconds: Integer; Chapter: Integer; ChapterText: String; Chapter_Diff: Extended; STR_Title_CPU: String; { TApp } function TApp.WindowsOSLanguage: String; //Helper function to determine OS language (derived from http://wiki.freepascal.org/Windows_system_language/de) var chrCountry: array [0..255] of char; begin chrCountry[0]:=Chr(0); //initialize first char as 0 to get rid of annoying compiler warning GetLocaleInfo(GetSystemDefaultLCID, LOCALE_SLANGUAGE, chrCountry, SizeOf(chrCountry) - 1); Result:=chrCountry; end; procedure TApp.DoRun; label CleanUp; var ErrorMsg: String; StepBuffer: Extended; //program version STR_Version: String = PROGVERSION; begin //add CPU architecture info to title if STR_CPU='x86_64' then STR_Title_CPU:=StringReplace(STR_Title,'**********************************************',' FFchapters V'+STR_Version+' (64Bit) ',[]) else if STR_CPU='i386' then STR_Title_CPU:=StringReplace(STR_Title,'**********************************************',' FFchapters V'+STR_Version+' (32Bit) ',[]) else STR_Title_CPU:=StringReplace(STR_Title,'**********************************************',' FFchapters V'+STR_Version+' ',[]); //show application title WriteLn(UTF8toConsole(STR_Title_CPU)); try //quick check parameters ErrorMsg:=CheckOptions('hbls:i:o:', 'help buildinfo license step: input: output:'); if ErrorMsg<>'' then begin WriteLn(#13#10+STR_Error+' '+ErrorMsg+#13#10); Terminate; Exit; end; //parse parameters for help if HasOption('h', 'help') then begin WriteHelp; Terminate; Exit; end; //parse parameters for buildinfo if HasOption('b', 'buildinfo') then begin WriteLn(UTF8toConsole(STR_Title_CPU)); WriteLn(UTF8toConsole('Build info: '+STR_Build)); Terminate; Exit; end; //show license info if HasOption('l', 'license') then begin //show FFchapters license WriteLn('FFchapters V'+STR_Version+' (c) '+STR_Date[1..4]+' Alexander Feuster (alexander.feuster@web.de)'+#13#10+ 'http://www.github.com/feuster'+#13#10+ 'This program is provided "as-is" without any warranties for any data loss,'+#13#10+ 'device defects etc. Use at own risk!'+#13#10+ 'Free for personal use. Commercial use is prohibited without permission.'+#13#10); Terminate; Exit; end; { add your program here } //Check for debug mode if FileExists(ExtractFilePath(ParamStr(0))+'debug') then begin Debug:=true; WriteLn(STR_Warning+'debug mode active'+#13#10); end else Debug:=false; //check commandline arguments if ParamCount=0 then begin WriteLn(STR_Error+'No start arguments given'); WriteLn(STR_Info+'For help try'); WriteLn(STR_Space, ExtractFileName(ExeName), ' --help'+#13#10); Terminate; Exit; end; //check if input file is available if HasOption('i', 'input') then begin LogFile:=(GetOptionValue('i', 'input')); if FileExists(LogFile)=false then begin WriteLn(STR_Error+'Input file "'+UTF8toConsole(LogFile)+'" does not exist'+#13#10); Terminate; Exit; end; end else begin WriteLn(STR_Error+'No input file set'+#13#10); Terminate; Exit; end; //check for chapter file path parameter if HasOption('o', 'output') then begin ChapterFile:=(GetOptionValue('o', 'output')); end else begin ChapterFile:=ChangeFileExt(LogFile,'_Chapters.txt'); WriteLn(STR_Warning+'Output file not set'); WriteLn(STR_Info+'using "'+UTF8toConsole(ChapterFile)+'" as Output file'+#13#10); end; //minimal difference between chapter timecodes (default) Chapter_Diff:= 120.0; //parse parameters for steps between chapter timecodes (override default) if HasOption('s', 'step') then begin StepBuffer:=StrToFloat(GetOptionValue('s', 'step')); if StepBuffer>-1 then Chapter_Diff:=StepBuffer; end; if Chapter_Diff=0 then WriteLn(UTF8toConsole(STR_Info+'using all analyzed chapters without difference step')) else WriteLn(UTF8toConsole(STR_Info+'Chapter step set to '+FloatToStr(Chapter_Diff))+'s'); //create work stringlists InputFile:=TStringList.Create; InputFile.LoadFromFile(LogFile); OutputFile:=TStringList.Create; Chapters:=TStringList.Create; //set chapter text according to Windows OS language writeln(STR_Info+'detected "'+WindowsOSLanguage+'" as default Windows OS language'); if AnsiPos('deutsch',LowerCase(WindowsOSLanguage))>0 then begin WriteLn(STR_Info+'using german "Kapitel" as generic chapter text'+#13#10); ChapterText:='Kapitel ' end else begin WriteLn(STR_Info+'using english/international "Chapter" as generic chapter text'+#13#10); ChapterText:='Chapter '; end; //define Decimal Separator of FFMPEG analyzer statistics timecodes DefaultFormatSettings.DecimalSeparator:='.'; //parse FFMPEG analyzer statistics for Counter:=0 to InputFile.Count-1 do begin //do not create more than 99 chapters if Chapter>98 then begin WriteLn(STR_Info+'already 99 chapters created. Stopping now.'); break; end; //read FFMPEG analyzer statistics line ReadLine:=InputFile.Strings[Counter]; //extract timecodes from FFMPEG scence change detection if AnsiPos('Parsed_showinfo',ReadLine)>0 then begin if AnsiPos('pts_time',readLine)>0 then begin Buffer:=AnsiRightStr(ReadLine,Length(ReadLine)-AnsiPos('pts_time:',ReadLine)-8); Buffer:=AnsiLeftStr(Buffer,AnsiPos(' ',Buffer)-1); //Padding needed for later sorting if AnsiPos('.',Buffer)=0 then Buffer:=Buffer+'.00'; while (AnsiPos('.',Buffer)<=Length(Buffer)-3) and (Length(Buffer)>5) do Buffer:=AnsiLeftStr(Buffer,AnsiPos('.',Buffer)-1); if AnsiPos('.',Buffer)=0 then Buffer:=Buffer+'.00'; if AnsiMidStr(Buffer,Length(Buffer)-1,1)='.' then Buffer:=Buffer+'0'; Buffer:=PadLeft(Buffer,16); Chapters.Add(Buffer); //DEBUG: print timecode if Debug then WriteLn(STR_Debug+'Scenechange "pts_time": '+Buffer); end; end; //extract timecodes from FFMPEG black detection if AnsiPos('blackdetect',ReadLine)>0 then begin if AnsiPos('black_start',readLine)>0 then begin Buffer:=AnsiRightStr(ReadLine,Length(ReadLine)-AnsiPos('black_start:',ReadLine)-11); Buffer:=AnsiLeftStr(Buffer,AnsiPos(' ',Buffer)-1); //Padding needed for later sorting if AnsiPos('.',Buffer)=0 then Buffer:=Buffer+'.00'; while (AnsiPos('.',Buffer)<=Length(Buffer)-3) and (Length(Buffer)>5) do Buffer:=AnsiLeftStr(Buffer,AnsiPos('.',Buffer)-1); if AnsiPos('.',Buffer)=0 then Buffer:=Buffer+'.00'; if AnsiMidStr(Buffer,Length(Buffer)-1,1)='.' then Buffer:=Buffer+'0'; Buffer:=PadLeft(Buffer,16); Chapters.Add(Buffer); //DEBUG: print timecode if Debug then WriteLn(STR_Debug+'Black "black_start": '+Buffer); end; end; //extract timecodes from FFMPEG black frame detection if AnsiPos('Parsed_blackframe',ReadLine)>0 then begin if AnsiPos(' t:',readLine)>0 then begin Buffer:=AnsiRightStr(ReadLine,Length(ReadLine)-AnsiPos(' t:',ReadLine)-2); Buffer:=AnsiLeftStr(Buffer,AnsiPos(' ',Buffer)-5); //Padding needed for later sorting if AnsiPos('.',Buffer)=0 then Buffer:=Buffer+'.00'; while (AnsiPos('.',Buffer)<=Length(Buffer)-3) and (Length(Buffer)>5) do Buffer:=AnsiLeftStr(Buffer,AnsiPos('.',Buffer)-1); if AnsiPos('.',Buffer)=0 then Buffer:=Buffer+'.00'; if AnsiMidStr(Buffer,Length(Buffer)-1,1)='.' then Buffer:=Buffer+'0'; Buffer:=PadLeft(Buffer,16); Chapters.Add(Buffer); //DEBUG: print timecode if Debug then WriteLn(STR_Debug+'Blackframe "t": '+Buffer); end; end; end; //check if chapter timecodes are available or quit if Chapters.Count=0 then begin WriteLn(STR_Error+'no chapter timecodes found'+#13#10); goto CleanUp; end; //sort chapters from lowest to highest timecode Chapters.Sort; //trim padding which is not needed anymore after sorting for Chapter:=0 to Chapters.Count-1 do begin Chapters.Strings[Chapter]:=Trim(Chapters.Strings[Chapter]); end; //DEBUG: store created timecodes in file if Debug then begin WriteLn(STR_Debug+'storing sorted timecodes in "'+UTF8toConsole(ChangeFileExt(ChapterFile,'_timecodes.txt'))+'"'+#13#10); Chapters.SaveToFile(ChangeFileExt(ChapterFile,'_timecodes.txt')); end; //remove chapters whose timecodes are to close together Chapter:=Chapters.Count-1; if Chapter_Diff>0 then begin while Chapter>0 do begin if StrToFloat(Chapters.Strings[Chapter])<=StrToFloat(Chapters.Strings[Chapter-1])+Chapter_Diff then begin //DEBUG: print deleted timecode if Debug then WriteLn(STR_Debug+'timecodes time diff below '+FloatToStr(Chapter_Diff)+'s for chapters #'+FormatFloat('00',Chapter-1)+' '+Chapters.Strings[Chapter-1]+'s (deleted) <-> #'+FormatFloat('00',Chapter)+' '+Chapters.Strings[Chapter]+'s (not deleted)'); Chapters.Delete(Chapter-1); Chapter:=Chapters.Count-1; end else dec(Chapter); end; end; //check if lowest entry has minimum timecode entry difference to start timecode 00:00:00 if Chapter_Diff>0 then begin if StrToFloat(Chapters.Strings[0])<Chapter_Diff then Chapters.Delete(0); end; //convert timecodes to hh:mm:ss.mmm time format for Chapter:=0 to Chapters.Count-1 do begin //split the floating point timecode seconds in integer and fracture parts TIMECODE_Time:=StrToFloat(Chapters.Strings[Chapter]); TIMECODE_Sec:=Trunc(TIMECODE_Time); TIMECODE_Sec_Frac:=SimpleRoundTo(Frac(TIMECODE_Time),-2); //convert timecode values parts to hh:mm:ss time values Hours:=Round(Trunc(TIMECODE_Sec/3600)); TIMECODE_Sec:=TIMECODE_Sec-(Hours*3600); Minutes:=Round(Trunc(TIMECODE_Sec/60)); TIMECODE_Sec:=TIMECODE_Sec-(Minutes*60); Seconds:=Round(Trunc(TIMECODE_Sec)); MilliSeconds:=Round(TIMECODE_Sec_Frac*1000); //add chapter time to temporary chapter list Chapters.Strings[Chapter]:=FormatFloat('00',Hours)+':'+FormatFloat('00',Minutes)+':'+FormatFloat('00',Seconds)+'.'+FormatFloat('000',MilliSeconds); end; //create first chapter entry for static start position OutputFile.Add('CHAPTER01=00:00:00.000'); OutputFile.Add('CHAPTER01NAME=Kapitel 1'); //create dynamic chapter entries according to available chapter times for Chapter:=0 to Chapters.Count-1 do begin OutputFile.Add('CHAPTER'+FormatFloat('00',CHAPTER+2)+'='+Chapters.Strings[Chapter]); OutputFile.Add('CHAPTER'+FormatFloat('00',CHAPTER+2)+'NAME='+ChapterText+IntToStr(Chapter+2)); end; //create chapter file WriteLn(STR_Info+'creating chapter file "'+UTF8toConsole(ChapterFile)+'" with'); WriteLn(STR_Info+'['+IntToStr(Chapters.Count)+'] chapters'+#13#10); OutputFile.SaveToFile(ChapterFile); //Clean up CleanUp: if InputFile<>NIL then InputFile.Free; if OutputFile<>NIL then OutputFile.Free; if Chapters<>NIL then Chapters.Free; //stop program loop WriteLn(STR_Info+'exit program now'+#13#10); //stop program loop on exception with error message Except on E: Exception do begin WriteLn(STR_Error+'fatal error "'+E.Message+'"'+#13#10); end; end; //terminate program Terminate; end; constructor TApp.Create(TheOwner: TComponent); begin inherited Create(TheOwner); StopOnException:=True; end; destructor TApp.Destroy; begin inherited Destroy; end; procedure TApp.WriteHelp; begin { add your help code here } WriteLn(STR_Title_CPU); WriteLn('Build info: ', ExtractFileName(ExeName), ' -b (--buildinfo)'); WriteLn(' Shows the build info.'+#13#10); WriteLn('License info: ', ExtractFileName(ExeName), ' -l (--license)'); WriteLn(' Shows the license info.'+#13#10); WriteLn('Help: ', ExtractFileName(ExeName), ' -h (--help)'); WriteLn(' Shows this help text.'+#13#10); WriteLn('Input File: ', ExtractFileName(ExeName), ' -i (--input=) <Filepath>'); WriteLn(' Sets the full path to the log file with raw chapters log output from ffmpeg.'+#13#10); WriteLn('Chapter File: ', ExtractFileName(ExeName), ' -o (--output=) <Filepath>'); WriteLn(' Sets the outputpath for the generated chapter file.'+#13#10); WriteLn('Chapter Step: ', ExtractFileName(ExeName), ' -s (--step=) <seconds>'); WriteLn(' Sets the step difference in seconds between two chapters.'); WriteLn(' Set to 0 to use all analyzed chapters.'+#13#10); WriteLn('Usage: ', ExtractFileName(ExeName), ' -i <FFmpeg_Log_File> -o <Chapter_Output_File> (-s <seconds>)'+#13#10); WriteLn(''); WriteLn('FFmpeg Log: FFchapters needs a log file with all raw information for the chapter extraction.'); WriteLn(' This log file can be created by using a FFmpeg filter combination: Scene, Black and Blackframe detection'+#13#10); WriteLn('FFmpeg example commandline:'); WriteLn('ffmpeg -i "Video_File" -vf blackdetect=d=1.0:pic_th=0.90:pix_th=0.00,blackframe=98:32,"select=''gt(scene,0.75)'',showinfo" -an -f null - 2> "FFmpeg_Log_File"'); end; var Application: TApp; begin Application:=TApp.Create(nil); Application.Run; Application.Free; end.
{******************************************************************************* This file is part of the Open Chemera Library. This work is public domain (see README.TXT). ******************************************************************************** Author: Ludwig Krippahl Date: 31.3.2011 Purpose: Geometric docking module Name from original algorithm (Boolean Geometric Interaction Evaluation) Revisions: TO DO: split up *******************************************************************************} unit bogie; {$mode objfpc}{$H+} interface uses SysUtils,basetypes,linegrids,dockdomains,surface,geomutils,docktasks; type { TModelManager } TModelManager=class private FModels:TDockModels; FMinOverlap:Integer; FLastModel:Integer; public CurrentRotation:TQuaternion; GridScale:TFloat; ProbeGridTransVec:TCoord; property Models:TDockModels read FModels; property MinimumOverlap:Integer read FMinOverlap; constructor Create(NumModels,MinOverlap:Integer;DockModels:TDockModels); function AddModel(Score,X,Y,Z:Integer):Integer; procedure ImportModels(const CSet:TConstraintSet); procedure ExportModels(var CSet:TConstraintSet); end; TModelManagers=array of TModelManager; { TDockManager } TDockManager=class private //These are copies so they cannot be changed outside FTargetCoords,FProbeCoords:TCoords; FTargetRads,FProbeRads:TFloats; FResolution:TFloat; //add coord and radius for soft docking FRotations:TQuaternions; FAxes:TCoords; FCurrentRotation:Integer; FTargetGrid,FProbeGrid:TDockingGrid; FConstraintSets:TConstraintSets; FModelManagers:TModelManagers; procedure ClearModelManagers; public //Statistics DigitizationTicks,ConstraintTicks,DomainTicks,ScoringTicks:Integer; property TargetGrid:TDockingGrid read FTargetGrid; property ProbeGrid:TDockingGrid read FProbeGrid; property CurrentRotation:Integer read FCurrentRotation write FCurrentRotation; function TotalRotations:Integer; function Models(DockIx:Integer):TDockModels; function ModelGroupsCount:Integer; constructor Create(TargCoords:TCoords;TargRads:TFloats; ProbCoords:TCoords;ProbRads:TFloats; AResolution:TFLoat); procedure Free; procedure ImportConstraintSets(var CSets:TConstraintSets); procedure ExportResults(var CSets:TConstraintSets); procedure BuildTargetGrid; procedure BuildProbeGrid(Rotation:TQuaternion;gzlPrints:Integer); procedure BuildRotations(Job:TDockRun); function Dock(NumSteps:Integer=1;CalcStats:Boolean=False):Boolean; //Returns true if finished end; implementation { TModelManager } constructor TModelManager.Create(NumModels, MinOverlap: Integer;DockModels:TDockModels); var f:Integer; begin inherited Create; SetLength(FModels,NumModels); for f:=0 to High(FModels) do if f<Length(DockModels) then FModels[f]:=DockModels[f] else begin FModels[f].OverlapScore:=-1; FModels[f].TransVec:=NullVector; FModels[f].Rotation:=IdentityQuaternion; end; FLastModel:=High(DockModels); if FLastModel>=0 then FMinOverlap:=Min(FModels[FLastModel].OverlapScore,MinOverlap) else FMinOverlap:=MinOverlap; end; function TModelManager.AddModel(Score, X, Y, Z: Integer): Integer; var ix1,ix2:Integer; begin if Score>FMinOverlap then { TODO : Interaction tests here } begin ix1:=0; while FModels[ix1].OverlapScore>=Score do ix1:=ix1+1; //This must stop if Score>FMinOverlap if FLastModel<High(FModels) then Inc(FLastModel); ix2:=FLastModel; while ix2>ix1 do begin FModels[ix2]:=FModels[ix2-1]; Dec(ix2); end; FModels[ix1].OverlapScore:=Score; FModels[ix1].TransVec:=Add(ProbeGridTransvec, Coord(X*GridScale,Y*GridScale,Z*GridScale)); FModels[ix1].Rotation:=CurrentRotation; if FLastModel=High(FModels) then FMinOverlap:=FModels[FLastModel].OverlapScore; Result:=FMinOverlap; end; end; procedure TModelManager.ImportModels(const CSet: TConstraintSet); var f:Integer; begin for f:=0 to High(CSet.DockModels) do begin if f>High(FModels) then Break; FModels[f]:=CSet.DockModels[f]; end; FMinOverlap:=Max(FMinOverlap,FModels[High(FModels)].OverlapScore); end; procedure TModelManager.ExportModels(var CSet: TConstraintSet); begin CSet.DockModels:=Copy(FModels,0,Length(FModels)); end; { TDockManager } procedure TDockManager.ClearModelManagers; var f:Integer; begin for f:=0 to High(FModelManagers) do FModelManagers[f].Free; FModelManagers:=nil; end; function TDockManager.TotalRotations: Integer; begin Result:=Length(FRotations); end; function TDockManager.Models(DockIx: Integer): TDockModels; begin Result:=FModelManagers[DockIx].Models; end; function TDockManager.ModelGroupsCount: Integer; begin Result:=Length(FModelManagers); end; constructor TDockManager.Create(TargCoords:TCoords;TargRads:TFloats; ProbCoords:TCoords;ProbRads:TFloats; AResolution:TFLoat); begin inherited Create; Assert((Length(TargCoords)=Length(TargRads)) and (Length(ProbCoords)=Length(ProbRads)), 'Mismatching coordinate and radius arrays'); FTargetCoords:=Copy(TargCoords,0,Length(TargCoords)); FProbeCoords:=Copy(ProbCoords,0,Length(ProbCoords)); FTargetRads:=Copy(TargRads,0,Length(TargRads)); FProbeRads:=Copy(ProbRads,0,Length(ProbRads)); FResolution:=AResolution; FTargetGrid:=TDockingGrid.Create(FResolution); FProbeGrid:=TDockingGrid.Create(FResolution); FModelManagers:=nil; end; procedure TDockManager.Free; begin FTargetGrid.Free; FProbeGrid.Free; ClearModelManagers; inherited Free; end; procedure TDockManager.ImportConstraintSets(var CSets: TConstraintSets); var f:Integer; begin FConstraintSets:=CSets; ClearModelManagers; SetLength(FModelManagers,Length(FConstraintSets)); for f:=0 to High(FModelManagers) do begin FModelManagers[f]:=TModelManager.Create(FConstraintSets[f].NumModels, FConstraintSets[f].MinOverlap, FConstraintSets[f].DockModels); FModelManagers[f].GridScale:=FResolution; FModelManagers[f].ImportModels(CSets[f]); end; end; procedure TDockManager.ExportResults(var CSets: TConstraintSets); var f:Integer; begin for f:=0 to High(FModelManagers) do FModelManagers[f].ExportModels(CSets[f]); end; procedure TDockManager.BuildTargetGrid; begin FTargetGrid.BuildFromSpheres(20,FTargetCoords,FTargetRads); end; procedure TDockManager.BuildProbeGrid(Rotation: TQuaternion;gzlPrints:Integer); var tmpcoords:TCoords; begin tmpcoords:=Rotate(FProbeCoords,Rotation); FProbeGrid.BuildFromSpheres(gzlPrints,tmpcoords,FProbeRads); end; procedure TDockManager.BuildRotations(Job: TDockRun); var f:Integer; begin FRotations:=Job.Rotations; SetLength(FAxes,Length(FRotations)); for f:=0 to High(Job.AxisIndexes) do FAxes[f]:=Job.Axes[Job.AxisIndexes[f]]; end; function TDockManager.Dock(NumSteps: Integer; CalcStats: Boolean): Boolean; var dockdomain:TDockDomain; f:Integer; ticktime:DWORD; avgTimePrint:Integer; begin avgTimePrint:=0; while (FCurrentRotation<High(FRotations)) and (NumSteps>0) do begin Inc(FCurrentRotation); Dec(NumSteps); if CalcStats then ticktime:=GetTickCount; BuildProbeGrid(FRotations[FCurrentRotation],avgTimePrint); if CalcStats then begin DigitizationTicks:=GetTimeInteval(ticktime); ConstraintTicks:=0; DomainTicks:=0; ScoringTicks:=0; end; for f:=0 to High(FConstraintSets) do begin FModelManagers[f].CurrentRotation:=FRotations[FCurrentRotation]; dockdomain:=TDockDomain.Create(FTargetGrid,FProbeGrid); dockdomain.ConstraintManager.ImportConstraints(FConstraintSets[f].Constraints, FRotations[FCurrentRotation],FAxes[FCurrentRotation]); if CalcStats then ConstraintTicks:=ConstraintTicks+GetTimeInteval(ticktime); dockdomain.AssignModelManager(@FModelManagers[f].AddModel); dockdomain.MinimumOverlap:=FModelManagers[f].MinimumOverlap; dockdomain.RemoveCores:=True; dockdomain.BuildInitialDomain; if CalcStats then DomainTicks:=DomainTicks+GetTimeInteval(ticktime); FModelManagers[f].ProbeGridTransVec:=Subtract(FProbeGrid.TransVec,FTargetGrid.TransVec); dockdomain.Score; if CalcStats then ScoringTicks:=ScoringTicks+GetTimeInteval(ticktime); dockdomain.Free; end; end; Result:=FCurrentRotation=High(FRotations); end; end.
unit uwinapi; {$mode objfpc}{$H+} interface uses Windows; const PW_CLIENTONLY = $00000001; INTERNET_MAX_PATH_LENGTH = 2048; INTERNET_MAX_SCHEME_LENGTH = 32; INTERNET_MAX_URL_LENGTH = INTERNET_MAX_SCHEME_LENGTH + Length('://') + 1 + INTERNET_MAX_PATH_LENGTH; AD_APPLY_SAVE = $00000001; AD_APPLY_HTMLGEN = $00000002; AD_APPLY_REFRESH = $00000004; AD_APPLY_ALL = AD_APPLY_SAVE or AD_APPLY_HTMLGEN or AD_APPLY_REFRESH; AD_APPLY_FORCE = $00000008; AD_APPLY_BUFFERED_REFRESH = $00000010; AD_APPLY_DYNAMICREFRESH = $00000020; type PCompPos = ^TCompPos; _tagCOMPPOS = record dwSize: DWORD; iLeft: integer; iTop: integer; dwWidth: DWORD; dwHeight: DWORD; izIndex: integer; fCanResize: BOOL; fCanResizeX: BOOL; fCanResizeY: BOOL; iPreferredLeftPercent: integer; iPreferredTopPercent: integer; end; COMPPOS = _tagCOMPPOS; TCompPos = _tagCOMPPOS; PCompStateInfo = ^TCompStateInfo; _tagCOMPSTATEINFO = record dwSize: DWORD; iLeft: integer; iTop: integer; dwWidth: DWORD; dwHeight: DWORD; dwItemState: DWORD; end; COMPSTATEINFO = _tagCOMPSTATEINFO; TCompStateInfo = _tagCOMPSTATEINFO; PWallPaperOpt = ^TWallPaperOpt; _tagWALLPAPEROPT = record dwSize: DWORD; dwStyle: DWORD; end; WALLPAPEROPT = _tagWALLPAPEROPT; TWallPaperOpt = _tagWALLPAPEROPT; PComponentsOpt = ^TComponentsOpt; _tagCOMPONENTSOPT = record dwSize: DWORD; fEnableComponents: BOOL; fActiveDesktop: BOOL; end; COMPONENTSOPT = _tagCOMPONENTSOPT; TComponentsOpt = _tagCOMPONENTSOPT; PComponent = ^COMPONENT; _tagCOMPONENT = record dwSize: DWORD; dwID: DWORD; iComponentType: integer; fChecked: BOOL; fDirty: BOOL; fNoScroll: BOOL; cpPos: COMPPOS; wszFriendlyName: array[0..MAX_PATH - 1] of widechar; wszSource: array[0..INTERNET_MAX_URL_LENGTH - 1] of widechar; wszSubscribedURL: array[0..INTERNET_MAX_URL_LENGTH - 1] of widechar; dwCurItemState: DWORD; csiOriginal: TCompStateInfo; csiRestored: TCompStateInfo; end; COMPONENT = _tagCOMPONENT; IActiveDesktop = interface(IUnknown) ['{F490EB00-1240-11D1-9888-006097DEACF9}'] function ApplyChanges(dwFlags: DWORD): HResult; stdcall; function GetWallpaper(pwszWallpaper: PWideChar; cchWallpaper: UINT; dwReserved: DWORD): HResult; stdcall; function SetWallpaper(pwszWallpaper: PWideChar; dwReserved: DWORD): HResult; stdcall; function GetWallpaperOptions(out pwpo: TWallPaperOpt; dwReserved: DWORD): HResult; stdcall; function SetWallpaperOptions(const pwpo: TWallPaperOpt; dwReserved: DWORD): HResult; stdcall; function GetPattern(pwszPattern: PWideChar; cchPattern: UINT; dwReserved: DWORD): HResult; stdcall; function SetPattern(pwszPattern: PWideChar; dwReserved: DWORD): HResult; stdcall; function GetDesktopItemOptions(out pco: TComponentsOpt; dwReserved: DWORD): HResult; stdcall; function SetDesktopItemOptions(const pco: TComponentsOpt; dwReserved: DWORD): HResult; stdcall; function AddDesktopItem(var pcomp: COMPONENT; dwReserved: DWORD): HResult; stdcall; function AddDesktopItemWithUI(hwnd: HWND; var pcomp: COMPONENT; dwReserved: DWORD): HResult; stdcall; function ModifyDesktopItem(var pcomp: COMPONENT; dwFlags: DWORD): HResult; stdcall; function RemoveDesktopItem(var pcomp: COMPONENT; dwReserved: DWORD): HResult; stdcall; function GetDesktopItemCount(out lpiCount: integer; dwReserved: DWORD): HResult; stdcall; function GetDesktopItem(nComponent: integer; var pcomp: COMPONENT; dwReserved: DWORD): HResult; stdcall; function GetDesktopItemByID(dwID: ULONG; var pcomp: COMPONENT; dwReserved: DWORD): HResult; stdcall; function GenerateDesktopItemHtml(pwszFileName: PWideChar; var pcomp: COMPONENT; dwReserved: DWORD): HResult; stdcall; function AddUrl(hwnd: HWND; pszSource: PWideChar; var pcomp: COMPONENT; dwFlags: DWORD): HResult; stdcall; function GetDesktopItemBySource(pwszSource: PWideChar; var pcomp: COMPONENT; dwReserved: DWORD): HResult; stdcall; end; implementation end.
unit Main; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, ExtCtrls, Dialogs, StdCtrls, ImgList, ActnList, ToolWin, ComCtrls, tiFocusPanel, tiVTTreeView, tiRoundedPanel, tiSplitter, tiObject, tiVirtualTrees, FtiAutoEditFrame, tiBOMExploration, tiVTAbstract; type TFtiBOMExplorer = class(TForm) spnlMain: TtiSplitterPanel; TV: TtiVTTreeView; pnlRight: TPanel; actConnectDB: TAction; actDisconnectDB: TAction; ilNormal: TImageList; actRefresh: TAction; actPost: TAction; actAppend: TAction; actDelete: TAction; actCull: TAction; ilDisabled: TImageList; ilHot: TImageList; ActionList: TActionList; tbDataRow: TToolBar; tbRefresh: TToolButton; tbAppend: TToolButton; tbDelete: TToolButton; tbPost: TToolButton; tbCull: TToolButton; actSelectBOM: TAction; pnlBOMStatus: TPanel; imgBOMIcon: TImage; lblBOMName: TLabel; imgAliasIcon: TImage; lblAliasName: TLabel; imgRegistrarIcon: TImage; lblRegistrarName: TLabel; lblBOM: TLabel; Separator2: TLabel; lblAlias: TLabel; Separator3: TLabel; lblRegistrar: TLabel; pnlView: TPanel; imgViewIcon: TImage; lblView: TLabel; pnlViewHolder: TPanel; cbView: TComboBox; Separator5: TLabel; imgViewPointIcon: TImage; lblViewPoint: TLabel; pnlViewPointHolder: TPanel; cbViewPoint: TComboBox; actExit: TAction; tbMain: TToolBar; tbSelectBOM: TToolButton; tbConnect: TToolButton; tbDisconnect: TToolButton; tbExit: TToolButton; procedure actExitExecute(Sender: TObject); procedure cbViewPointChange(Sender: TObject); procedure cbViewChange(Sender: TObject); procedure actSelectBOMExecute(Sender: TObject); procedure actCullExecute(Sender: TObject); procedure ActionsUpdate(Action: TBasicAction; var Handled: Boolean); procedure actDeleteExecute(Sender: TObject); procedure actAppendExecute(Sender: TObject); procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); procedure actRefreshExecute(Sender: TObject); procedure actPostExecute(Sender: TObject); procedure actDisconnectDBExecute(Sender: TObject); procedure actConnectDBExecute(Sender: TObject); procedure FormCreate(Sender: TObject); procedure TVSelectNode(ptiVTTreeView: TtiVTTreeView; pNode: PVirtualNode; AData: TtiObject); private ChildFrame: TtiAutoEditFrame; DBConnected: Boolean; View: TtiBOMEView; ViewPoint: TtiBOMEViewPoint; ExplorableBOM: TtiExplorableBOM; Alias: TtiAlias; Registrar: TtiBOMERegistrar; procedure RefreshTree(NodeToInit: PVirtualNode; Expanded: Boolean = False; SelectLastChild: Boolean = False); function DeletedDetected(AData: TtiObject): Boolean; procedure CullNode(Recursive: Boolean = True); procedure BOMChanged; procedure ViewChanged; procedure ViewPointChanged; procedure PopulateViews; procedure PopulateViewPoints; procedure UpdateView; procedure UpdateViewPoint; function AttemptDisconnect: Boolean; procedure ApplyResourceStrings; procedure OnChildFrameValidate(Sender: TObject; Buffer: TtiObject; var Valid: Boolean); procedure OnChildFrameCommit(Sender: TObject; Buffer: TtiObject); procedure ConnectDB; procedure DisconnectDB; procedure CancelEditing; function QueryFinishEditing(AllowCancel: Boolean = True): Boolean; function FinishEditing(AllowCancel: Boolean = True): Boolean; procedure SetupEditing(Node: PVirtualNode); function CommitChildFrame: Boolean; procedure RollbackChildFrame; function SelectedNode: PVirtualNode; function QueryDisconnect: Boolean; public procedure SetBOM(AExplorableBOM: TtiExplorableBOM; AAlias: TtiAlias; ARegistrar: TtiBOMERegistrar); end; var FtiBOMExplorer: TFtiBOMExplorer; implementation {$R *.dfm} uses tiConstants , tiDialogs , tiOPFManager , FtiValidationErrors , tiHelperClasses , FtiSelectBOMDlg , tiVisitor , Transit_BOM ; resourcestring SApplyBufferChanges = 'Changes have been made in the edit buffer. Apply changes?'; SCaption = 'tiOPF Business Object Model Explorer'; SactConnectDB = 'Connect'; SactDisconnectDB = 'Disconnect'; SactRefresh = 'Refresh'; SactPost = 'Post'; SactAppend = 'Append'; SactDelete = 'Delete'; SactCull = 'Cull'; SSaveChanges = 'Changes have not been saved. Save Now?'; SactSelectBOM = ' Select BOM'; SlblBOMCaption = 'BOM: '; SlblAliasCaption = 'Alias: '; SlblRegistrarCaption = 'Registrar: '; SlblViewCaption = 'View: '; SlblViewPointCaption = 'ViewPoint: '; SactExitCaption = 'Exit'; { TFtiBOMExplorer } procedure TFtiBOMExplorer.actConnectDBExecute(Sender: TObject); begin ConnectDB; UpdateView; UpdateViewPoint; end; procedure TFtiBOMExplorer.actCullExecute(Sender: TObject); begin if not FinishEditing then Exit; CullNode; end; procedure TFtiBOMExplorer.actDisconnectDBExecute(Sender: TObject); begin AttemptDisconnect; end; procedure TFtiBOMExplorer.actExitExecute(Sender: TObject); begin Close; end; procedure TFtiBOMExplorer.actAppendExecute(Sender: TObject); var AData: TtiObject; ANode: PVirtualNode; Mapping: TtiVTTVDataMapping; CanInsert: Boolean; begin if not FinishEditing then Exit; ANode := SelectedNode; AData := TV.GetObjectFromNode(ANode); //GOTCHA: ideally the code would work like this //TV.DoInsert(Self); //but it doesn't work because it checks for GUI button visibility, which //we don't use, so we need to re-invent the wheel Mapping := TV.GetMappingForNode(ANode); if not (Assigned(Mapping) and Mapping.CanInsert and Assigned(Mapping.OnInsert)) then Exit; CanInsert := True; if Assigned(Mapping.OnCanInsert) then Mapping.OnCanInsert(TV, ANode, AData, CanInsert); if not CanInsert then Exit; Mapping.OnInsert(TV, ANode, AData); //reset GUI - select newly appended child RefreshTree(ANode, False, True); SetupEditing(ANode); end; procedure TFtiBOMExplorer.actDeleteExecute(Sender: TObject); var Mapping: TtiVTTVDataMapping; CanDelete: Boolean; AData: TtiObject; ANode: PVirtualNode; begin CancelEditing; //ideally the code would work like this //TV.DoDelete(Self); //GOTCHA: doesn't work because it checks for GUI button visibility too //instead, re-invent the wheel ANode := SelectedNode; AData := TV.GetObjectFromNode(ANode); Mapping := TV.GetMappingForNode(ANode); if not (Assigned(Mapping) and Mapping.CanDelete) then Exit; CanDelete := True; if Assigned(Mapping.OnCanDelete) then Mapping.OnCanDelete(TV, ANode, AData, CanDelete); if not CanDelete then Exit; if Assigned(Mapping.OnDelete) then Mapping.OnDelete(TV, ANode, AData); //mark the object for deletion, and update the GUI AData.Deleted := True; SetupEditing(SelectedNode); end; procedure TFtiBOMExplorer.actRefreshExecute(Sender: TObject); var AData: TtiObject; ANode: PVirtualNode; PurgeVisitor: TVisSkeletonPurge; begin //this routine refeshes the selected object with current info in the database //through iteration, all objects lower in the tree are also affected //posClean -> no change (database is the same as in-memory copy) //posPK -> posClean (rest of object will be retrieved - but this app doesn't use this state) //posCreate -> will disappear (never having been persisted) //posUpdate -> posClean (changes discarded) //posDelete -> posClean (pending deletion cancelled) //posDeleted -> will disappear (no longer in the database) CancelEditing; AData := TV.SelectedData; ANode := SelectedNode; //in-memory-only objects should be culled rather than refreshed if AData.ObjectState in [posCreate, posDeleted] then begin CullNode(False); Exit; end; {GOTCHA: There is no way in TtiObject to tell whether an object is merely a container, such as the statically-created skeleton of the BOM, or the list holding details in a master-detail relationship between peristent objects. ObjectState is not helpful, since reading such objects sets ObjectState to posClean. Such objects need to 'purge' themselves of persisted objects so they can be reloaded. This function is not in TtiObject, so two klugey classes have been created, called TtiSkeletonObject/TtiSkeletonList, for this purpose. Purge is not the same as TtiObjectList.Clear, since skeletons could implement 0..1 relationship, or be a compound list (e.g. a list of lists). Purge sets ObjectState to posEmpty.} {so rather than calling AData.Purge; instead create a visitor to purge TtiSkeletonX descendents} PurgeVisitor := TVisSkeletonPurge.Create; try AData.Iterate(PurgeVisitor); finally PurgeVisitor.Free; end; {when a non-skeleton is selected, we need to trick tiOPF into re-loading the object based on its primary key the automap will do this as-is, but the DBIndependant achieves this through the _ReadFromPK visitors} if AData.ObjectState <> posEmpty then AData.ObjectState := posPK; { See the code comments in Transit_BOM for the class TCustomObject } if AData is TCustomObject then TCustomObject(AData).Read; //update GUI RefreshTree(ANode); SetupEditing(SelectedNode); end; procedure TFtiBOMExplorer.actSelectBOMExecute(Sender: TObject); var Dialog: TtiSelectBOMDlg; AExplorableBOM: TtiExplorableBOM; AAlias: TtiAlias; ARegistrar: TtiBOMERegistrar; begin if not QueryDisconnect then Exit; Dialog := TtiSelectBOMDlg.Create(nil); try AExplorableBOM := ExplorableBOM; AAlias := Alias; ARegistrar := Registrar; if Dialog.Execute(AExplorableBOM, AAlias, ARegistrar) then begin //undo existing settings DisconnectDB; Registrar.UnregisterItems; //copy new values ExplorableBOM := AExplorableBOM; Alias := AAlias; Registrar := ARegistrar; //reflect new settings BOMChanged; end; finally Dialog.Free; end; end; procedure TFtiBOMExplorer.ActionsUpdate(Action: TBasicAction; var Handled: Boolean); var Mapping: TtiVTTVDataMapping; Node: PVirtualNode; SelectionMade: Boolean; AData: TtiObject; begin Mapping := nil; //compiler warning scarecrow AData := nil; //compiler warning scarecrow actSelectBOM.Enabled := BOMEDictionary.BOMs.Count > 0; actConnectDB.Enabled := not DBConnected; actDisconnectDB.Enabled := DBConnected; Node := SelectedNode; SelectionMade := DBConnected and Assigned(Node); if SelectionMade then begin Mapping := TV.GetMappingForNode(Node); AData := TV.GetObjectFromNode(Node); end; actRefresh.Enabled := SelectionMade; //Detecting Dirty and Deleted applies throughout hierarchy actPost.Enabled := SelectionMade and AData.Dirty; actCull.Enabled := SelectionMade and DeletedDetected(AData); actAppend.Enabled := SelectionMade and Mapping.CanInsert; actDelete.Enabled := SelectionMade and Mapping.CanDelete and (AData.ObjectState in [posUpdate, posClean]); end; procedure TFtiBOMExplorer.ApplyResourceStrings; begin Caption := SCaption; actConnectDB.Caption := SactConnectDB; actDisconnectDB.Caption := SactDisconnectDB; actRefresh.Caption := SactRefresh; actPost.Caption := SactPost; actAppend.Caption := SactAppend; actDelete.Caption := SactDelete; actCull.Caption := SactCull; actSelectBOM.Caption := SactSelectBOM; lblBOM.Caption := SlblBOMCaption; lblAlias.Caption := SlblAliasCaption; lblRegistrar.Caption := SlblRegistrarCaption; lblView.Caption := SlblViewCaption; lblViewPoint.Caption := SlblViewPointCaption; actExit.Caption := SactExitCaption; end; function TFtiBOMExplorer.AttemptDisconnect: Boolean; begin Result := QueryDisconnect; if Result then DisconnectDB; end; procedure TFtiBOMExplorer.actPostExecute(Sender: TObject); begin if FinishEditing then begin { See the code comments in Transit_BOM for the class TCustomObject } if TV.SelectedData is TCustomObject then TCustomObject(TV.SelectedData).Save; //ObjectState can change to posClean or posDeleted, so we must update GUI SetupEditing(SelectedNode); end; end; procedure TFtiBOMExplorer.BOMChanged; begin if not Assigned(ExplorableBOM) then Exit; Registrar.RegisterItems; lblBOMName.Caption := ExplorableBOM.Name; lblAliasName.Caption := Alias.Name; lblRegistrarName.Caption := Registrar.Name; PopulateViews; PopulateViewPoints; ViewChanged; ViewPointChanged; end; procedure TFtiBOMExplorer.CancelEditing; begin if Assigned(ChildFrame) then begin RollbackChildFrame; FreeAndNil(ChildFrame); end; end; procedure TFtiBOMExplorer.cbViewChange(Sender: TObject); begin if cbView.ItemIndex >= 0 then if (View <> cbView.Items.Objects[cbView.ItemIndex]) then begin View := TtiBOMEView(cbView.Items.Objects[cbView.ItemIndex]); ViewChanged; end; end; procedure TFtiBOMExplorer.cbViewPointChange(Sender: TObject); begin if cbViewPoint.ItemIndex >= 0 then if (ViewPoint <> cbViewPoint.Items.Objects[cbViewPoint.ItemIndex]) then begin ViewPoint := TtiBOMEViewPoint( cbViewPoint.Items.Objects[cbViewPoint.ItemIndex]); ViewPointChanged; end; end; function TFtiBOMExplorer.CommitChildFrame: Boolean; begin Result := True; if Assigned(ChildFrame) then if Assigned(ChildFrame.Data) then begin if ChildFrame.DataModified then begin Result := ChildFrame.Validate; if Result then ChildFrame.CommitBuffer; end; end; end; procedure TFtiBOMExplorer.ConnectDB; begin with Alias do gTIOPFManager.ConnectDatabase( DatabaseName, UserName, Password, Params, PerLayerName); // gTIOPFManager.DefaultDBConnectionName := DBConnected := True; end; procedure TFtiBOMExplorer.CullNode(Recursive: Boolean = True); var ANode: PVirtualNode; AData: TtiObject; FreeDeletedVisitor: TVisFreeDeleted; RemoveSubject: Boolean; begin {this routine culls objects in memory that have been are not in the database because they have already been deleted or were never persisted (posCreate) Unlike TtiObjectList.FreeDeleted, this routine uses a visitor to cull down the hierarchy} ANode := SelectedNode; AData := TV.GetObjectFromNode(ANode); RemoveSubject := AData.ObjectState in [posCreate, posDeleted]; if Recursive then begin {GOTCHA: Objects don't notify their owners when they are freed, so we must do it manually. There is no polymorphic way to do this if the owner is TtiObject, so we do NOT notify those owners here IF AData is not owned by a list, this will blow up unless AData's class has implemented free notification} FreeDeletedVisitor := TVisFreeDeleted.Create; try FreeDeletedVisitor.IterationStyle := isBottomUpSinglePass; AData.Iterate(FreeDeletedVisitor); finally FreeDeletedVisitor.Free; end; end else //only remove current node (e.g. posCreate) begin if Assigned(AData.Owner) and (AData.Owner is TtiObjectList) then TtiObjectLIst(AData.Owner).Remove(AData) else //GOTCHA: this will blow up if concrete class doesn't notify its owner AData.Free; end; //reset GUI if RemoveSubject then begin TV.SetObjectForNode(ANode, nil); ANode := ANode.Parent; end; RefreshTree(ANode, RemoveSubject); SetupEditing(ANode); end; function TFtiBOMExplorer.DeletedDetected(AData: TtiObject): Boolean; var Visitor: TVisDetectDeleted; begin Visitor := TvisDetectDeleted.Create; try AData.Iterate(Visitor); Result:=Visitor.Detected; finally Visitor.Free; end; end; procedure TFtiBOMExplorer.DisconnectDB; begin TV.Data := nil; with Alias do gTIOPFManager.DisconnectDatabase( DatabaseName, PerLayerName); DBConnected := False; end; function TFtiBOMExplorer.QueryDisconnect: Boolean; var DlgResult: Integer; begin //there are 2 stages to allow disconnecting //1) ask what to do with the dirty edit buffer //2) ask what to do with dirty objects Result := True; if DBConnected then begin if not QueryFinishEditing then begin Result := False; Exit; end; if ViewPoint.Root.Dirty then begin DlgResult := MessageDlg(SSaveChanges, mtConfirmation, [mbYes, mbNo, mbCancel], 0); case DlgResult of mrYes: begin //save all changes to db { See the code comments in Transit_BOM for the class TCustomObject } if ViewPoint.Root is TCustomObject then TCustomObject(ViewPoint.Root).Save; end; mrNo: begin end; //do nothing - abandon changes else Result := False; end; end; if Result and Assigned(ChildFrame) then FreeAndNil(ChildFrame); end; end; function TFtiBOMExplorer.FinishEditing(AllowCancel: Boolean = True): Boolean; begin Result := QueryFinishEditing(AllowCancel); if Result then FreeAndNil(ChildFrame); end; procedure TFtiBOMExplorer.FormCloseQuery(Sender: TObject; var CanClose: Boolean); begin if DBConnected then CanClose := AttemptDisconnect else CanClose := True; if CanClose then Registrar.UnregisterItems; end; procedure TFtiBOMExplorer.FormCreate(Sender: TObject); begin ApplyResourceStrings; DBConnected := False; end; procedure TFtiBOMExplorer.OnChildFrameCommit(Sender: TObject; Buffer: TtiObject); begin TV.RefreshCurrentNode; end; procedure TFtiBOMExplorer.OnChildFrameValidate(Sender: TObject; Buffer: TtiObject; var Valid: Boolean); var ErrorMsgs: TStringList; begin ErrorMsgs := TStringList.Create; try Valid := Buffer.IsValid(ErrorMsgs); if not Valid then TtiValidationErrorsDlg.Execute(Buffer, ErrorMsgs); finally ErrorMsgs.Free; end; end; procedure TFtiBOMExplorer.PopulateViewPoints; var I: Integer; begin if not Assigned(ExplorableBOM) then Exit; cbViewPoint.Items.Clear; if ExplorableBOM.ViewPoints.Count > 0 then begin for I := 0 to ExplorableBOM.ViewPoints.Count - 1 do cbViewPoint.Items.AddObject(ExplorableBOM.ViewPoints[I].Name, ExplorableBOM.ViewPoints[I]); ViewPoint := ExplorableBOM.ViewPoints[0]; cbViewPoint.ItemIndex := 0; end; end; procedure TFtiBOMExplorer.PopulateViews; var I: Integer; begin if not Assigned(ExplorableBOM) then Exit; cbView.Items.Clear; if ExplorableBOM.Views.Count > 0 then begin for I := 0 to ExplorableBOM.Views.Count - 1 do cbView.Items.AddObject(ExplorableBOM.Views[I].Name, ExplorableBOM.Views[I]); View := ExplorableBOM.Views[0]; cbView.ItemIndex := 0; end; end; function TFtiBOMExplorer.QueryFinishEditing(AllowCancel: Boolean): Boolean; var DlgResult: Integer; begin Result := True; if Assigned(ChildFrame) then begin if ChildFrame.DataModified then begin if AllowCancel then DlgResult := MessageDlg(SApplyBufferChanges, mtConfirmation, [mbYes, mbNo, mbCancel], 0) else DlgResult := MessageDlg(SApplyBufferChanges, mtConfirmation, [mbYes, mbNo], 0); case DlgResult of mrYes: begin //try committing, but if it doesn't validate, treat like a cancel operation, if allowed if not CommitChildFrame then if AllowCancel then Result := False; ; end; mrNo: RollbackChildFrame; else Result := False; end; end; end; end; procedure TFtiBOMExplorer.RefreshTree(NodeToInit: PVirtualNode; Expanded, SelectLastChild: Boolean); var NodeToSelect: PVirtualNode; begin TV.VT.ReinitNode(NodeToInit,True); NodeToSelect := nil; if SelectLastChild then NodeToSelect := TV.VT.GetLastChild(NodeToInit); if not Assigned(NodeToSelect) then NodeToSelect := NodeToInit; TV.VT.Selected[NodeToSelect] := True; TV.VT.FocusedNode := NodeToSelect; if Expanded then TV.VT.Expanded[NodeToSelect] := True; TV.VT.ScrollIntoView(NodeToSelect, True); end; procedure TFtiBOMExplorer.RollbackChildFrame; begin if Assigned(ChildFrame) then if Assigned(ChildFrame.Data) then ChildFrame.RollbackBuffer; end; function TFtiBOMExplorer.SelectedNode: PVirtualNode; begin Result := TV.VT.GetFirstSelected; end; procedure TFtiBOMExplorer.SetBOM(AExplorableBOM: TtiExplorableBOM; AAlias: TtiAlias; ARegistrar: TtiBOMERegistrar); begin ExplorableBOM := AExplorableBOM; Alias := AAlias; Registrar := ARegistrar; BOMChanged; end; procedure TFtiBOMExplorer.SetupEditing(Node: PVirtualNode); var Mapping: TtiVTTVDataMapping; begin //SetupEditing can be called twice when selected node changes within another operation if Assigned(ChildFrame) then Exit; ChildFrame := TtiAutoEditFrame.Create(Self); ChildFrame.OnCommit := OnChildFrameCommit; ChildFrame.OnValidate := OnChildFrameValidate; Mapping := TV.GetMappingForNode(Node); ChildFrame.ReadOnly := not Mapping.CanEdit; ChildFrame.Data := TV.GetObjectFromNode(Node); ChildFrame.Parent := pnlRight; ChildFrame.Align := alClient; ChildFrame.Show; end; procedure TFtiBOMExplorer.TVSelectNode(ptiVTTreeView: TtiVTTreeView; pNode: PVirtualNode; AData: TtiObject); begin //GOTCHA: sometimes TreeView fires this event before node re-initialization //is complete, causes AVs //GOTCHA: When the user changes nodes, we can't prevent it even when the //current node editing dowsn't validate. Our only option is to rollback //the edit buffer, with no option for the user to cancel //to avoid this problem, the TreeView needs a OnCanSelect event FinishEditing(False); //tear-down SetupEditing(pNode); //setup end; procedure TFtiBOMExplorer.UpdateView; var I: Integer; begin //GOTCHA: assigning DataMappings triggers a tiOPF bug, //TtiVTTVDataMapping.Assign must be implemented for this to work //TV.DataMappings := View.TreeMappings; //assign manually TV.DataMappings.Clear; for I := 0 to View.TreeMappings.Count - 1 do with TV.DataMappings.Add do begin CanDelete := View.TreeMappings.Items[I].CanDelete; CanEdit := View.TreeMappings.Items[I].CanEdit; CanInsert := View.TreeMappings.Items[I].CanInsert; CanView := View.TreeMappings.Items[I].CanView; ImageIndex := View.TreeMappings.Items[I].ImageIndex; DisplayPropName := View.TreeMappings.Items[I].DisplayPropName; DataClass := View.TreeMappings.Items[I].DataClass; OnDeriveNodeText := View.TreeMappings.Items[I].OnDeriveNodeText; OnCanEdit := View.TreeMappings.Items[I].OnCanEdit; OnCanInsert := View.TreeMappings.Items[I].OnCanInsert; OnCanDelete := View.TreeMappings.Items[I].OnCanDelete; OnInsert := View.TreeMappings.Items[I].OnInsert; OnEdit := View.TreeMappings.Items[I].OnEdit; OnDelete := View.TreeMappings.Items[I].OnDelete; end; end; procedure TFtiBOMExplorer.UpdateViewPoint; begin { See the code comments in Transit_BOM for the class TCustomObject } if ViewPoint.Root is TCustomObject then TCustomObject(ViewPoint.Root).Read; TV.Data := nil; TV.Data := ViewPoint.Root; end; procedure TFtiBOMExplorer.ViewChanged; begin if DBConnected then begin FinishEditing(False); UpdateView; SetupEditing(SelectedNode); end; end; procedure TFtiBOMExplorer.ViewPointChanged; begin if DBConnected then begin FinishEditing(False); UpdateViewPoint; end; end; end.
unit main; {$I Synopse.inc} {$I HPPas.inc} interface uses SysUtils, Classes, Math, Variants, TypInfo, {$ifdef MSWINDOWS} Windows, {$endif} SynCommons, HPPas, HppMagic, HppTypeCast, HppSysUtils, HppScript, ParseNumberTest, JSONTest, DynamicInvokeTest; procedure ConsoleMain; implementation procedure TestStringHeader; var s: string; {$if SizeOf(Char)=1} s2: UTF16String; {$else } s2: RawByteString; {$ifend} {$ifdef MSWINDOWS} bs: WideString; {$endif} begin Writeln('------- StringHeader test -------'); while True do begin Writeln('enter any string(for back, enter <break>) :'); Readln(s); if SameText(SysUtils.Trim(s), 'break') then Break; if SameText(SysUtils.Trim(s), '') then Continue; Writeln('length: ', LengthOf(s)); Writeln('detail: ', StringInfo(s)); {$ifdef MSWINDOWS} bs := WideString(s); Writeln('Rtl.Length(bs): ', Length(bs)); Writeln('LengthOf(bs): ', LengthOf(bs)); {$endif} {$if SizeOf(Char)=1} s2 := UTF16String(s); Writeln('LengthOf(UTF16str): ', LengthOf(s2)); Writeln('detail(UTF16str): ', StringInfo(s2)); {$else } s2 := RawByteString(s); Writeln('LengthOf(AnsiStr): ', LengthOf(s2)); Writeln('detail(AnsiStr): ', StringInfo(s2)); {$ifend} end; end; type T3BytesRecord = packed record a: Byte; b: Word; end; T4BytesRecord = packed record a: Word; b: Word; end; TPointerRecord = packed record a: Pointer; end; TStringRecord = packed record a: string; b: Integer; end; TVariantRecord = packed record a: Variant; end; TStringArray = array [0..8] of array [Boolean] of TStringRecord; function TestRecord3(_1: Integer; _2: T3BytesRecord; const _3: T3BytesRecord; var _4: T3BytesRecord): T3BytesRecord; begin Result.a := _2.a + _3.a + _4.a; Result.b := _2.b + _3.b + _4.b; end; function TestRecord4(_1: Integer; _2: T4BytesRecord; const _3: T4BytesRecord; var _4: T4BytesRecord): T4BytesRecord; begin Result.a := _2.a + _3.a + _4.a; Result.b := _2.b + _3.b + _4.b; end; function TestPointerRecord(_1: Integer; _2: TPointerRecord; const _3: TPointerRecord; var _4: TPointerRecord): TPointerRecord; begin PtrInt(Result.a) := PtrInt(_2.a) + PtrInt(_3.a) + PtrInt(_4.a); end; function TestStringRecord(_1: Integer; _2: TStringRecord; const _3: TStringRecord; var _4: TStringRecord): TStringRecord; begin Result.a := _2.a + _3.a + _4.a; end; function TestVariantRecord(_1: Integer; _2: TVariantRecord; const _3: TVariantRecord; var _4: TVariantRecord): TVariantRecord; begin Result.a := _2.a + _3.a + _4.a; end; function GetArrayTypeDesc(ATypeInfo: PTypeInfo): string; var ptd: PArrayTypeData; begin ptd := PArrayTypeData(GetTypeData(ATypeInfo)); Result := string(ATypeInfo.Name) + ' Size: ' + {$if defined(FPC) and defined(VER2_6)} IntToStr(ptd^.Size * ptd^.ElCount) {$else} IntToStr(ptd^.Size) {$ifend} + ', ElCount: ' + IntToStr(ptd^.ElCount) + ', ElType: ' + string(GetElementType(ptd^.ElType).Name) {$ifdef ISDELPHI2010_OR_FPC_NEWRTTI} + ', DimCount: ' + IntToStr(ptd^.DimCount) {$endif} end; procedure aa; var rec3: T3BytesRecord; rec4: T4BytesRecord; ptrrec: TPointerRecord; str: TStringRecord; v: TVariantRecord; sarr1, sarr2: TStringArray; begin rec3.a := 1; rec3.b := 2; rec3 := TestRecord3(2, rec3, rec3, rec3); Writeln(rec3.a, ' ', rec3.b); rec4.a := 1; rec4.b := 2; rec4 := TestRecord4(2, rec4, rec4, rec4); Writeln(rec4.a, ' ', rec4.b); PtrInt(ptrrec.a) := 1; ptrrec := TestPointerRecord(2, ptrrec, ptrrec, ptrrec); Writeln(PtrInt(ptrrec.a)); str.a := 'str '; str := TestStringRecord(2, str, str, str); Writeln(str.a); Writeln('SizeOfType(TStringRecord): ', SizeOfType(TypeInfo(TStringRecord))); Writeln('SizeOfType(TVariantRecord): ', SizeOfType(TypeInfo(TVariantRecord))); Writeln('SizeOfType(TStringArray): ', SizeOfType(TypeInfo(TStringArray))); Writeln(PTypeInfo(TypeInfo(TStringRecord))^.name); Writeln(PTypeInfo(TypeInfo(TVariantRecord))^.name); Writeln(PTypeInfo(TypeInfo(TStringArray))^.name); Writeln(GetArrayTypeDesc(PTypeInfo(TypeInfo(TStringArray)))); sarr2 := sarr1; v.a := 'str '; v := TestVariantRecord(2, v, v, v); Writeln(str.a); //pti := TypeInfo(T3BytesRecord); //Writeln(Ord(pti^.Kind), ' ', pti^.Name); end; procedure ShowHelp; begin Writeln('enter corresponding index to select an command'); Writeln(' 0: show this help'); Writeln(' 1: test [HppTypeCast.ParseNumber]'); Writeln(' 2: benchmark [number parsing]'); Writeln(' 3: test [HppJSONParse] '); Writeln(' 4: test [integer +-/*]'); Writeln(' 5: test [invoke with array of const parameters]'); Writeln(' 6: test [invoke with array of Rtti.TValue parameters]'); end; procedure ConsoleMain; var s: string; number: TNumber; begin RandSeed := Integer(GetTickCount64); Randomize; aa; //TestStringHeader; //PrintSizeOf; test3; test4; //HppVariantsTest; //TestRttiSerialize; //TestSmartString; //FunctionTest_SynTypeCast_ParseNumber; //IntegerTest; //TestInt64NegOperation; Writeln('*************** test and benchmark ***************'); ShowHelp; while True do begin Write('<: '); Readln(s); s := SysUtils.Trim(s); if (s = '') or (s = 'exit') then Break; ParseNumber(s, number.data, [scoStrict, scoIntegerOnly]); if not number.IsInteger then begin Writeln('invalid command'); Continue; end; case number.ToInt32 of 0: ShowHelp; 1: FunctionTest_HppTypeCast_ParseNumber; 2: NumberParsingBenchmark; 3: FunctionTest_HppJSONParser; 4: IntegerTest; 5: TestInvokeWithArrayOfConst; 6: TestInvokeWithArrayOfRttiValue; else Writeln('invalid command'); end; end; end; end.
unit View.GroupListForm; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, View.TemplateForm, Data.DB, Vcl.Menus, GrdPMenu, JvComponentBase, JvFormPlacement, Vcl.Grids, Vcl.DBGrids, JvExDBGrids, JvDBGrid, Vcl.ExtCtrls, Spring.Collections, Model.Interfaces, Model.ProSu.Interfaces, Spring.Data.ObjectDataSet, Model.Fabrication, Model.LanguageDictionary, Model.Declarations, Model.FormDeclarations; type TGroupListForm = class(TTemplateForm) procedure FormCreate(Sender: TObject); private fViewModel : IGroupListViewModelInterface; fPossibleParentGroupId : Integer; procedure NotificationFromProvider(const notifyClass : INotificationClass); procedure SetViewModel(const newViewModel: IGroupListViewModelInterface); function GetViewModel : IGroupListViewModelInterface; function GetProvider : IProviderInterface; override; procedure UpdateLabelsText; override; procedure OpenDataset; override; procedure NewGroup(aDS : TDataset); public procedure AddNew; override; procedure DeleteCurrent; override; //this placed in the ancestor type (TTemplateForm)... procedure EditCurrent; override; procedure Print; override; property ViewModel : IGroupListViewModelInterface read GetViewModel write SetViewModel default nil; property Provider: IProviderInterface read GetProvider default nil; end; var GroupListForm: TGroupListForm; implementation uses Model.ProSu.InterfaceActions, Model.ProSu.Subscriber, Model.ProSu.Provider, MainDM, Model.Group, ViewModel.GroupList, View.GroupEdit; {$R *.dfm} procedure TGroupListForm.AddNew; begin try TGroupEditForm.Execute(efcmdAdd, ViewModel.SubscriberToEdit, fObjectDataset); finally fObjectDataset.Cancel; end; end; procedure TGroupListForm.DeleteCurrent; begin inherited; end; procedure TGroupListForm.EditCurrent; begin TGroupEditForm.Execute(efcmdEdit, ViewModel.SubscriberToEdit, fObjectDataset); end; procedure TGroupListForm.FormCreate(Sender: TObject); begin inherited; ViewModel.SubscriberToEdit.SetUpdateSubscriberMethod(NotificationFromProvider); end; function TGroupListForm.GetProvider: IProviderInterface; begin Result := ViewModel.Provider; end; function TGroupListForm.GetViewModel: IGroupListViewModelInterface; begin if not Assigned(fViewModel) then fViewModel := CreateGroupListViewModelClass; Result := FViewModel; end; procedure TGroupListForm.NewGroup(aDS: TDataset); begin end; procedure TGroupListForm.NotificationFromProvider( const notifyClass: INotificationClass); var tmpNotifClass : TNotificationClass; tmpErrorNotifClass : TErrorNotificationClass; begin if notifyClass is TNotificationClass then begin tmpNotifClass := notifyClass as TNotificationClass; end; if notifyClass is TErrorNotificationClass then begin tmpErrorNotifClass := notifyClass as TErrorNotificationClass; end; end; procedure TGroupListForm.OpenDataset; begin fObjectDataset.DataList := ViewModel.Model.GetAllGroups(DMMain.Company.CompanyId, ''); fObjectDataset.Open; DataSource1.DataSet := fObjectDataset; end; procedure TGroupListForm.Print; begin inherited; end; procedure TGroupListForm.SetViewModel( const newViewModel: IGroupListViewModelInterface); begin fViewModel := newViewModel; if not Assigned(fViewModel) then raise Exception.Create('Group List View Model is required!'); fViewModel.Provider.Subscribe(ViewModel.SubscriberToEdit); end; procedure TGroupListForm.UpdateLabelsText; begin inherited; end; var CreateForm : TFactoryMethod<TTemplateForm>; initialization CreateForm := function : TTemplateForm begin if not DMMain.Authorize('111,112,113,114,115') then raise Exception.Create(Model.LanguageDictionary.MessageDictionary().GetMessage('SNotAuthorized')+#13#10+'TCityListForm'); Result := TGroupListForm.Create(Application); end; MyFactory.RegisterForm<TGroupListForm>('TGroupListForm', CreateForm); end.
unit USpotClass; interface uses SysUtils, Windows, Classes, Messages, Generics.Collections, Generics.Defaults, System.DateUtils, UzLogConst, UzLogGlobal{$IFNDEF ZLOG_TELNET}, UzLogQSO, UzLogSpc{$ENDIF}; type TSpotSource = ( ssSelf = 0, ssCluster, ssSelfFromZServer, ssClusterFromZServer ); TBaseSpot = class protected FTime : TDateTime; // moved from TBSdata 2.6e FCall : string; FNumber : string; FFreqHz : TFrequency; FCtyIndex : integer; FZone : integer; FNewCty : boolean; FNewZone : boolean; FWorked : boolean; FBand : TBand; FMode : TMode; FSpotSource: TSpotSource; FSpotGroup: Integer; FCQ: Boolean; FNewJaMulti: Boolean; FReportedBy: string; FIsDomestic: Boolean; procedure SetCall(v: string); function GetIsNewMulti(): Boolean; // newcty or newzone function GetIsPortable(): Boolean; public constructor Create; virtual; function FreqKHzStr : string; function InText : string; virtual; abstract; procedure FromText(S : string); virtual; abstract; procedure Assign(O: TBaseSpot); virtual; property IsNewMulti: Boolean read GetIsNewMulti; property IsPortable: Boolean read GetIsPortable; property IsDomestic: Boolean read FIsDomestic write FIsDomestic; property Time: TDateTime read FTime write FTime; property Call: string read FCall write SetCall; property Number: string read FNumber write FNumber; property FreqHz: TFrequency read FFreqHz write FFreqHz; property CtyIndex: Integer read FCtyIndex write FCtyIndex; property Zone: Integer read FZone write FZone; property NewCty: Boolean read FNewCty write FNewCty; property NewZone: Boolean read FNewZone write FNewZone; property Worked: Boolean read FWorked write FWorked; property Band: TBand read FBand write FBand; property Mode: TMode read FMode write FMode; property SpotSource: TSpotSource read FSpotSource write FSpotSource; property SpotGroup: Integer read FSpotGroup write FSpotGroup; property CQ: Boolean read FCQ write FCQ; property NewJaMulti: Boolean read FNewJaMulti write FNewJaMulti; property ReportedBy: string read FReportedBy write FReportedBy; end; TSpot = class(TBaseSpot) protected FTimeStr : string; FComment : string; public constructor Create; override; function Analyze(S : string) : boolean; // true if successful function ClusterSummary : string; function InText : string; override; procedure FromText(S : string); override; procedure Assign(O: TBaseSpot); override; property TimeStr: string read FTimeStr write FTimeStr; property Comment: string read FComment write FComment; end; TBSData = class(TBaseSpot) protected FBold : boolean; FIndex: Integer; public constructor Create; override; function LabelStr : string; function InText : string; override; procedure FromText(S : string); override; procedure Assign(O: TBaseSpot); override; property Bold: Boolean read FBold write FBold; property Index: Integer read FIndex write FIndex; end; TSpotList = class(TObjectList<TSpot>) public constructor Create(OwnsObjects: Boolean = True); end; TBSDataFreqAscComparer = class(TComparer<TBSData>) public function Compare(const Left, Right: TBSData): Integer; override; end; TBSDataFreqDescComparer = class(TComparer<TBSData>) public function Compare(const Left, Right: TBSData): Integer; override; end; TBSDataTimeAscComparer = class(TComparer<TBSData>) public function Compare(const Left, Right: TBSData): Integer; override; end; TBSDataTimeDescComparer = class(TComparer<TBSData>) public function Compare(const Left, Right: TBSData): Integer; override; end; TBSSortMethod = (soBsFreqAsc = 0, soBsFreqDesc, soBsTimeAsc, soBsTimeDesc ); TBSList = class(TObjectList<TBSData>) private FFreqAscComparer: TBSDataFreqAscComparer; FFreqDescComparer: TBSDataFreqDescComparer; FTimeAscComparer: TBSDataTimeAscComparer; FTimeDescComparer: TBSDataTimeDescComparer; public constructor Create(OwnsObjects: Boolean = True); destructor Destroy(); override; procedure Sort(SortMethod: TBSSortMethod); overload; function BinarySearch(SortMethod: TBSSortMethod; D: TBSData): Integer; overload; end; {$IFNDEF ZLOG_TELNET} procedure SpotCheckWorked(Sp: TBaseSpot; fWorkedScrub: Boolean = False); {$ENDIF} var hLookupServer: HWND; {$IFNDEF ZLOG_TELNET} function ExecLookup(strCallsign: string; b: TBand): string; function FindLookupServer(): HWND; {$ENDIF} implementation {$IFNDEF ZLOG_TELNET} uses UzLogContest, Main; {$ENDIF} constructor TBaseSpot.Create; begin FTime := Now; FCall := ''; FNumber := ''; FFreqHz := 0; FNewCty := false; FNewZone := false; FCtyIndex := 0; FZone := 0; FWorked := False; FBand := b19; FMode := mCW; FSpotSource := ssSelf; FSpotGroup := 1; FCQ := False; FNewJaMulti := False; FReportedBy := ''; FIsDomestic := True; end; constructor TSpot.Create; begin inherited; ReportedBy := ''; TimeStr := '0000Z'; Comment := ''; end; constructor TBSData.Create; begin inherited; FBold := False; FIndex := 0; end; function TBSData.LabelStr : string; begin Result := FreqkHzStr + ' ' + Call; if Number <> '' then begin Result := Result + ' [' + Number + ']'; end; end; function TSpot.Analyze(S : string) : boolean; var temp, temp2 : string; i : integer; sjis: AnsiString; {$IFNDEF ZLOG_TELNET} b: TBand; {$ENDIF} begin Result := False; if length(S) < 5 then exit; {$IFDEF DEBUG} OutputDebugString(PChar('[' + S + ']')); {$ENDIF} temp := TrimRight(TrimLeft(S)); i := pos('DX de', temp); if i > 1 then begin Delete(temp, 1, i); end; if pos('DX de', temp) = 1 then begin //000000000111111111122222222223333333333444444444455555555556666666666777777 //123456789012345678901234567890123456789012345678901234567890123456789012345 //DX de W1NT-6-#: 14045.0 V3MIWTJ CW 16 dB 21 WPM CQ 1208Z //DX de W3LPL-#: 14010.6 SM5DYC CW 14 dB 22 WPM CQ 1208Z sjis := AnsiString(temp); TimeStr := string(Copy(sjis, 71, 5)); Comment := string(Copy(sjis, 40, 30)); Call := Trim(string(Copy(sjis, 27, 12))); if Pos('CQ', Comment) > 0 then begin CQ := True; end; i := pos(':', temp); if i > 0 then begin temp2 := copy(temp, 7, i - 7); ReportedBy := temp2; end else begin exit; end; Delete(temp, 1, i); temp := TrimLeft(temp); // Freq. i := pos(' ', temp); if i > 0 then begin temp2 := copy(temp, 1, i - 1); end else begin exit; end; try FreqHz := Round(StrToFloat(temp2)*1000); except on EConvertError do exit; end; {$IFDEF ZLOG_TELNET} Band := TBand(GetBandIndex(FreqHz, 0)); {$ELSE} b := dmZLogGlobal.BandPlan.FreqToBand(FreqHz); if b = bUnknown then begin Exit; end; Band := b; {$ENDIF} Result := True; end else if Pos('To ALL', temp) = 1 then begin Exit; end else if dmZLogGlobal.Settings.FClusterIgnoreSHDX = False then begin // check for SH/DX responses i := length(temp); if i = 0 then begin exit; end; if temp[i] = '>' then begin i := pos(' <', temp); if i > 0 then begin ReportedBy := copy(temp, i+2, 255); ReportedBy := copy(ReportedBy, 1, length(ReportedBy)-1); end else begin exit; end; Delete(temp, i, 255); end else begin exit; end; i := pos(' ', temp); if i > 0 then begin temp2 := copy(temp, 1, i - 1); end else begin exit; end; try FreqHz := Round(StrToFloat(temp2) * 1000); except on EConvertError do exit; end; {$IFDEF ZLOG_TELNET} Band := TBand(GetBandIndex(FreqHz, 0)); {$ELSE} b := dmZLogGlobal.BandPlan.FreqToBand(FreqHz); if b = bUnknown then begin Exit; end; Band := b; {$ENDIF} Delete(temp, 1, i); temp := TrimLeft(temp); i := pos(' ', temp); if i > 0 then begin Call := copy(temp, 1, i - 1); end else begin exit; end; Delete(temp, 1, i); temp := TrimLeft(temp); i := pos(' ', temp); if i > 0 then begin Delete(temp, 1, i); end else begin exit; end; temp := TrimLeft(temp); if pos('Z', temp) = 5 then begin TimeStr := copy(temp, 1, 5); Delete(temp, 1, 6); Comment := temp; end else begin exit; end; Result := True; end; end; Function TBaseSpot.FreqKHzStr : string; begin Result := kHzStr(FreqHz); end; Function TSpot.ClusterSummary : string; begin Result := FillLeft(FreqKHzStr, 8) + ' ' + FillRight(FCall, 11) + ' ' + FTimeStr + ' ' + FillLeft(FComment, 30) + '<'+ FReportedBy + '>'; end; function TSpot.InText : string; begin Result := ''; end; procedure TSpot.FromText(S : string); begin // end; procedure TSpot.Assign(O: TBaseSpot); begin Inherited Assign(O); FReportedBy := TSpot(O).FReportedBy; FTimeStr := TSpot(O).FTimeStr; FComment := TSpot(O).FComment; end; function TBaseSpot.GetIsNewMulti(): Boolean; begin Result := NewCty or NewZone or NewJaMulti; end; function TBaseSpot.GetIsPortable(): Boolean; begin Result := (Pos('/', FCall) > 0); end; procedure TBaseSpot.SetCall(v: string); begin FCall := v; FIsDomestic := UzLogGlobal.IsDomestic(v); end; procedure TBaseSpot.Assign(O: TBaseSpot); begin FTime := O.FTime; FCall := O.FCall; FNumber := O.FNumber; FFreqHz := O.FFreqHz; FCtyIndex := O.FCtyIndex; FZone := O.FZone; FNewCty := O.FNewCty; FNewZone := O.FNewZone;; FWorked := O.FWorked; FBand := O.FBand;; FMode := O.FMode;; FSpotSource := O.FSpotSource; FSpotGroup := O.FSpotGroup; FCQ := O.FCQ; FNewJaMulti := O.FNewJaMulti; FReportedBy := O.ReportedBy; end; function TBSData.InText : string; (* Call : string; FreqHz : LongInt; CtyIndex : integer; Zone : integer; NewCty : boolean; NewZone : boolean; Worked : boolean; Band : TBand; Mode : TMode; Time : TDateTime; LabelRect : TRect; *) var SL: TStringList; begin SL := TStringList.Create(); SL.Delimiter := '%'; SL.StrictDelimiter := True; try SL.Add(Call); SL.Add(IntToStr(FreqHz)); SL.Add(IntToStr(Ord(Band))); SL.Add(IntToStr(Ord(Mode))); SL.Add(FloatToStr(Time)); SL.Add(ZBoolToStr(CQ)); SL.Add(Number); SL.Add(ReportedBy); Result := SL.DelimitedText; finally SL.Free(); end; end; procedure TBSData.FromText(S : string); var SL: TStringList; begin SL := TStringList.Create(); SL.Delimiter := '%'; SL.StrictDelimiter := True; try SL.DelimitedText := S + '%%%%%%%%'; Call := SL[0]; FreqHz := StrToIntDef(SL[1], 0); Band := TBand(StrToIntDef(SL[2], Integer(b19))); Mode := TMode(StrToIntDef(SL[3], Integer(mCW))); Time := StrToFloatDef(SL[4], 0); CQ := ZStrToBool(SL[5]); Number := SL[6]; ReportedBy := SL[7]; finally SL.Free(); end; end; procedure TBSData.Assign(O: TBaseSpot); begin Inherited Assign(O); FBold := TBSData(O).FBold; end; constructor TSpotList.Create(OwnsObjects: Boolean); begin Inherited Create(OwnsObjects); end; { TBSDataFreqAscComparer } function TBSDataFreqAscComparer.Compare(const Left, Right: TBSData): Integer; var diff: TFrequency; begin if (Left.FreqHz - Right.FreqHz) = 0 then begin Result := (Left.Index - Right.Index); end else begin diff := Left.FreqHz - Right.FreqHz; if diff < 0 then begin Result := -1; end else begin Result := 1; end; end; end; { TBSDataFreqDescComparer } function TBSDataFreqDescComparer.Compare(const Left, Right: TBSData): Integer; var diff: TFrequency; begin if (Left.FreqHz - Right.FreqHz) = 0 then begin Result := (Right.Index - Left.Index); end else begin diff := Right.FreqHz - Left.FreqHz; if diff < 0 then begin Result := -1; end else begin Result := 1; end; end; end; { TBSDataTimeAscComparer } function TBSDataTimeAscComparer.Compare(const Left, Right: TBSData): Integer; begin if CompareDateTime(Left.Time, Right.Time) = 0 then begin Result := (Left.Index - Right.Index); end else begin Result := CompareDateTime(Left.Time, Right.Time); end; end; { TBSDataTimeDescComparer } function TBSDataTimeDescComparer.Compare(const Left, Right: TBSData): Integer; begin if CompareDateTime(Left.Time, Right.Time) = 0 then begin Result := (Right.Index - Left.Index); end else begin Result := CompareDateTime(Right.Time, Left.Time); end; end; { TBSList } constructor TBSList.Create(OwnsObjects: Boolean); begin Inherited Create(OwnsObjects); FFreqAscComparer := TBSDataFreqAscComparer.Create(); FFreqDescComparer := TBSDataFreqDescComparer.Create(); FTimeAscComparer := TBSDataTimeAscComparer.Create(); FTimeDescComparer := TBSDataTimeDescComparer.Create(); end; destructor TBSList.Destroy(); begin Inherited; FFreqAscComparer.Free(); FFreqDescComparer.Free(); FTimeAscComparer.Free(); FTimeDescComparer.Free(); end; procedure TBSList.Sort(SortMethod: TBSSortMethod); var i: Integer; begin for i := 0 to Count - 1 do begin Items[i].Index := i; end; case SortMethod of soBsFreqAsc: Sort(FFreqAscComparer); soBsFreqDesc: Sort(FFreqDescComparer); soBsTimeAsc: Sort(FTimeAscComparer); soBsTimeDesc: Sort(FTimeDescComparer); end; end; function TBSList.BinarySearch(SortMethod: TBSSortMethod; D: TBSData): Integer; var NewIndex: Integer; begin NewIndex := 0; case SortMethod of soBsFreqAsc: BinarySearch(D, NewIndex, FFreqAscComparer); soBsFreqDesc: BinarySearch(D, NewIndex, FFreqDescComparer); soBsTimeAsc: BinarySearch(D, NewIndex, FTimeAscComparer); soBsTimeDesc: BinarySearch(D, NewIndex, FTimeDescComparer); end; Result := NewIndex; end; {$IFNDEF ZLOG_TELNET} procedure SpotCheckWorked(Sp: TBaseSpot; fWorkedScrub: Boolean); var multi: string; SD, SD2: TSuperData; Q: TQSO; begin // 交信済みか確認する Sp.Worked := Log.IsWorked(Sp.Call, Sp.Band); // NR未入力の場合 if (Sp.Number = '') and (fWorkedScrub = False) then begin // 他のバンドで交信済みならマルチを取得 if Log.IsOtherBandWorked(Sp.Call, Sp.Band, multi) = True then begin Sp.Number := multi; end else begin // 他のバンドで未交信ならSPCデータよりマルチを取得 SD := TSuperData.Create(); Sd.Callsign := Sp.Call; SD2 := MainForm.SuperCheckList.ObjectOf(SD); if SD2 <> nil then begin Sp.Number := SD2.Number; end; // SPCからも取得できない場合はLookup Serverに依頼する if (Sp.Number = '') and (Sp.IsPortable = False) and (Sp.IsDomestic = True) then begin Sp.Number := ExecLookup(Sp.Call, Sp.Band); end; SD.Free(); end; end; // そのマルチはSp.BandでNEW MULTIか if Sp.Number <> '' then begin Q := TQSO.Create(); try Q.Callsign := Sp.Call; Q.Band := Sp.Band; Q.Mode := Sp.Mode; Q.NrRcvd := Sp.Number; multi := MyContest.MultiForm.ExtractMulti(Q); Sp.NewJaMulti := Log.IsNewMulti(Sp.Band, multi); finally Q.Free(); end; end; end; function ExecLookup(strCallsign: string; b: TBand): string; var callsign_atom: ATOM; number_atom: ATOM; S: string; r: LRESULT; szWindowText: array[0..255] of Char; nLen: Integer; reqcode: Integer; begin if dmZLogGlobal.Settings._bandscope_use_lookup_server = False then begin Result := ''; Exit; end; if hLookupServer = 0 then begin hLookupServer := FindLookupServer(); end; if hLookupServer = 0 then begin Result := ''; Exit; end; if (MyContest is TFDContest) or (MyContest is TSixDownContest) then begin if (b >= b2400) then begin reqcode := 1; end else begin reqcode := 0; end; end else begin if Pos('$Q', MyContest.SentStr) > 0 then begin // city reqcode := 1; end else begin // prov reqcode := 0; end; end; S := strCallsign; callsign_atom := GlobalAddAtom(PChar(S)); r := SendMessage(hLookupServer, (WM_USER+501), callsign_atom, reqcode); if r = 0 then begin Result := ''; Exit; end; ZeroMemory(@szWindowText, SizeOf(szWindowText)); number_atom := LOWORD(r); nLen := GlobalGetAtomName(number_atom, PChar(@szWindowText), SizeOf(szWindowText)); if (nLen = 0) then begin Result := ''; Exit; end; GlobalDeleteAtom(number_atom); Result := StrPas(szWindowText); end; function FindLookupServer(): HWND; var wnd: HWND; begin wnd := FindWindow(PChar('TformQthLookup'), nil); Result := wnd; end; initialization hLookupServer := FindLookupServer(); {$ENDIF} end.
unit utlFuncoes; interface uses IniFiles, Windows, Messages, SysUtils, Dialogs, Forms, SqlExpr, Graphics, bslXprocs, bslMSG, utlClasses, Buttons, jpeg, dataLGN; procedure PutArquivoINI(Adb : TConfigDataBase); function GetArquivoINI(var db : TConfigDataBase) : Boolean; function GetValorString(ATable : string = ''; ACampo : string = ''; AFiltro : string = ''; ACondicao : string = '') : string; overload; function AjustarData(AData : TDate) : String; implementation procedure PutArquivoINI(Adb : TConfigDataBase); var SYSLGN : TIniFile; begin try try SYSLGN := TIniFile.Create(ExtractFilePath(ParamStr(0)) + 'SYSLGN.INI'); SYSLGN.WriteString('DADOS','DRIVERNAME',Adb.DriverName); SYSLGN.WriteString('DADOS','HOSTNAME',Adb.HostName); SYSLGN.WriteString('DADOS','DATABASE',Adb.DataBase); SYSLGN.WriteString('DADOS','USERNAME',Adb.UserName); SYSLGN.WriteString('DADOS','PASSWORD',Adb.Password); SYSLGN.WriteString('DADOS','PORT',Adb.port); except on E:Exception do begin DesktopAlert('Erro ao gravar arquivo SYSLGN.INI '+E.Message, daErro); Exit; end; end; finally FreeAndNil(SYSLGN); end; end; function GetArquivoINI(var db : TConfigDataBase) : Boolean; var SYSLGN : TIniFile; begin try SYSLGN := TIniFile.Create(ExtractFilePath(ParamStr(0)) + 'SYSLGN.INI'); Result := True; db := TConfigDataBase.Create; db.DriverName := SYSLGN.ReadString('DADOS','DRIVERNAME', ''); db.HostName := SYSLGN.ReadString('DADOS','HOSTNAME', ''); db.DataBase := SYSLGN.ReadString('DADOS','DATABASE', ''); db.UserName := SYSLGN.ReadString('DADOS','USERNAME', ''); db.Password := SYSLGN.ReadString('DADOS','PASSWORD', ''); db.port := SYSLGN.ReadString('DADOS','PORT', ''); except on E:Exception do begin DesktopAlert('Erro ao ler arquivo SYSLGN.INI '+E.Message, daErro); Result := False; Exit; end; end; end; function GetValorString(ATable : string = ''; ACampo : string = ''; AFiltro : string = ''; ACondicao : string = '') : string; overload; var qu : TSQLQuery; begin try try qu := TSQLQuery.Create(nil); qu.SQLConnection := dmLGN.dbLGN; qu.SQL.Clear; qu.SQL.Add(LowerCase('SELECT '+ACampo+' FROM '+ATable+' WHERE ('+AFiltro+' = '+ACondicao+')')); qu.Active := True; if not qu.IsEmpty then Result := qu.FieldByName(ACampo).AsString else Result := ''; except on E:Exception do begin qu.Close; Result := ''; end; end; finally qu.Close; FreeAndNil(qu); end; end; function AjustarData(AData : TDate) : String; begin Result := ''; if (AData) > 0 then Result := QuotedStr(FormatDateTime('yyyy-mm-dd', AData)); end; end.
(* En este código se presenta la implementación del algoritmo de ordenación por selección en sus variantes creciente y decreciente. *) program ordenacionSeleccion; const N = 10; Type rango = 2 .. N; arreglo = array [1..N] of integer; var i : integer; a : arreglo; Function maximo(ultimo: rango; A: arreglo): rango; var j, max : 1..n; begin max := 1; for j := 2 to ultimo do if A[j] > A[max] then max := j; maximo := max end; Function minimo(ultimo: rango; A: arreglo): rango; var j, min : 1..n; begin min := 1; for j := 2 to ultimo do if A[j] < A[min] then min := j; minimo := min end; Procedure OrdSelCrec(var A: arreglo); var i, mayor: 1..n; temp : integer; begin for i := n downto 2 do begin mayor := maximo(i,A); temp := A[mayor]; A[mayor] := A[i]; A[i] := temp end; end; Procedure OrdSelDecre(var A: arreglo); var i, menor: 1..n; temp : integer; begin for i := n downto 2 do begin menor := minimo(i,A); temp := A[menor]; A[menor] := A[i]; A[i] := temp end; end; begin { programa principal } randomize; { creo un arreglo aleatorio } for i := 1 to N do a[i] := random(100); writeln('Arreglo sin ordenar:'); write('['); for i := 1 to (N-1) do write(a[i], ', '); write(a[N]); writeln(']'); writeln; { lo ordeno crecientemente } OrdSelCrec(a); writeln('Arreglo ordenado crecientemente:'); write('['); for i := 1 to (N-1) do write(a[i], ', '); write(a[N]); writeln(']'); writeln; { lo ordeno decrecientemente } OrdSelDecre(a); writeln('Arreglo ordenado decrecientemente:'); write('['); for i := 1 to (N-1) do write(a[i], ', '); write(a[N]); writeln(']'); end.
unit UGSEInterface; { ClickForms Application } { Bradford Technologies, Inc. } { All Rights Reserved } { Source Code Copyrighted © 1998-2011 by Bradford Technologies, Inc. } interface uses Contnrs, UCell, UContainer, UForm, UAMC_XMLUtils, uCraftXML, uGlobals, IniFiles, DateUtils, StrUtils; //CREATING MISMO XML Document function ComposeGSEAppraisalXMLReport(AContainer: TContainer; var XMLVer: String; ExportForm: BooleanArray; Info: TMiscInfo; ErrList: TObjectList; LocType: Integer=0; NonUADXMLData: Boolean=False): string; //Saving MISMO XML Documents procedure SaveAsGSEAppraisalXMLReport(AContainer: TContainer; AFileName: string; LocType: Integer=0; NonUADXMLData: Boolean=False); overload; procedure SaveAsGSEAppraisalXMLReport(AContainer: TContainer; ExportForm: BooleanArray; AFileName: string; LocType: Integer=0; NonUADXMLData: Boolean=False); overload; procedure SaveAsGSEAppraisalXMLReport(AContainer: TContainer; ExportForm: BooleanArray; AFileName: string; Info: TMiscInfo; LocType: Integer=0; NonUADXMLData: Boolean=False); overload; procedure CreateGSEAppraisalXMLReport(AContainer: TContainer; ExportForm: BooleanArray; AFileName: string; Info: TMiscInfo; LocType: Integer=0; NonUADXMLData: Boolean=False); //function GetMismoReportType(AContainer: TContainer): String; //procedure VerifyXMLReport(); not used 01/19/2018 function ValidateXML(doc: TContainer; xmlReport: String): Boolean; var XMLReportPath : String; XMLReportName : String; implementation uses Forms, SysUtils, Classes, Math, Dialogs, Types, UMain, UStatus, USysInfo, ULicUser, UUtil2, UUtil1, MSXML6_TLB, UGSEImportExport, UGSEEnvelope, UBase, UPage, UMath, UEditor, uCraftClass, UGridMgr, UWindowsInfo, uInternetUtils, UBase64, UGraphics, UActiveForms, uDocCommands, UUADConfiguration, UAMC_RELSOrder, UUADUtils, UStrings; const ttSales = 1; //types of grids ttRentals = 2; ttListings = 3; GSE_XMLVersion = 'GSE2.6'; //XML version for GSE reports ClickFormsName = 'ClickFORMS'; FORM_ELEMENT_NAME = '//_FORM'; ADDENDUM_ELEMENT_NAME = '//_ADDENDUM'; CHECK_CELL_TRUE_TEXT = 'X'; CHECK_CELL_FALSE_TEXT = ''; IMPORT_CELL_ID_OFFSET = 50000; SOFTWARE_NAME_CELLID = 2990; SOFTWARE_VERSION_CELLID = 2991; GSE_VERSION_CELLID = 10507; const FORM_ID = 10000; PROPERTY_SKETCH = 11001; LOCATION_MAP = 11002; PLAT_MAP = 11011; FLOOD_MAP = 11012; SUBJECT_PHOTOS = 11003; MISC_PHOTOS = 11010; COMPARABLE_SALE_PHOTOS = 11004; COMPARABLE_LISTING_PHOTOS = 11005; COMPARABLE_RENTAL_PHOTOS = 11006; SIGNATURE = 11007; INVOICE = 11008; ADDITIONAL_COMMENTS = 11009; COMPARABLE_IMAGE_CELLID = 11900; REPORT_TYPE_CELLID = 2646; COVER_PHOTO_CELLID = 2645; GRID_NET_POSITIVE_CELLID = 1050; GRID_NET_NEGATIVE_CELLID = 1051; OTHER_FORM = 10499; OTHER_ADDENDUM = 11000; //REVIEW - CONSTANTS DUPLICATED IN UMISMOINTERFACE FMX_1004 = 340; FMX_1004_CERT = 341; FMX_1004_XCOMP = 363; FMX_1004P = 4218; FMX_1004PCERT = 4219; FMAC_70H = 4365; //1004 2019 FMAC_70HCERT = 4366; FMX_1004C = 342; FMX_1004C_XCOMP = 365; FMX_1004C_CERT = 343; FMX_1004D = 344; FMX_1025 = 349; FMX_1025_XCOMP = 364; FMX_1025_XRENT = 368; FMX_1025_CERT = 350; FMX_1073 = 345; FMX_1073_XCOMP = 367; FMX_1073_CERT = 346; FMX_2090 = 351; FMX_2090_XCOMP = 366; FMX_2090_CERT = 352; FMX_2055 = 355; FMX_2055_XCOMP = 363; FMX_2055_CERT = 356; FMX_1075 = 347; FMX_1075_XCOMP = 367; FMX_1075_CERT = 348; FMX_2095 = 353; FMX_2095_XCOMP = 366; FMX_2095_COMP = 354; FMX_2000 = 357; FMX_2000_XCOMP = 363; FMX_2000_INST = 358; FMX_2000_CERT = 359; FMX_2000A = 360; FMX_2000A_XCOMP = 364; FMX_2000A_INST = 361; FMX_2000A_CERT = 362; ERC_1994 = 84; ERC_2001 = 87; ERC_2003 = 95; ERC_BMA_1996 = 85; FMAE_1004_1993 = 1; FMAE_1004_1993_XCOMPS = 2; FMAE_1073_1997 = 7; FMAE_1073_1997_XCOMPS = 8; LAND_APPRAISAL = 9; LAND_APPRAISAL_XCOMPS = 10; FMAE_1025_1994 = 18; FMAE_1025_1994_XLISTS = 19; FMAE_1025_1994_XRENTS = 20; FMAE_1025_1994_XCOMPS = 21; COMPLETION_CERTIFICATE_LEGAL = 30; FMAE_2055_1996 = 37; FMAE_2055_1996_XCOMPS = 38; FMAE_2065_1996 = 39; FMAE_2065_1996_XCOMPS = 40; FMAE_2075_1997 = 41; FMAE_2070 = 43; MOBILE_HOME = 11; COMPLETION_CERTIFICATE_1 = 775; COMPLETION_CERTIFICATE_2 = 777; // V6.9.9 modified 102709 JWyatt to change use of the DEFAULT_PROPERTY_SKETCH_FORMID // constant to the global variable cSkFormLegalUID. // DEFAULT_PROPERTY_SKETCH_FORMID = 201; DEFAULT_LOCATION_MAP_FORMID = 101; DEFAULT_PLAT_MAP_FORMID = 103; DEFAULT_FLOOD_MAP_FORMID = 102; DEFAULT_SUBJECT_PHOTOS_FORMID = 301; DEFAULT_PHOTOS_FORMID = 0; DEFAULT_MAP_FORMID = 0; DEFAULT_COMMENTS_FORMID = 98; DEFAULT_INVOICE_FORMID = 220; DEFAULT_SIGNATURE_FORMID = 0; COMPARABLE_SALE_PHOTOS_FORMID = 0; COMPARABLE_LISTING_PHOTOS_FORMID = 0; COMPARABLE_RENTAL_PHOTOS_FORMID = 0; //Some constants for Addendum comment exporting - when we have multi comments ADDENDUM_TEXT = 'AppraisalAddendumText'; ADDENDUM_TEXT_IDENTIFIER = 'AppraisalAddendumTextIdentiier'; ADDENDUM_TEXT_DESCRIPTION = 'AppraisalAddendumTextDescription'; //NOTE - these cellIDs to do not XPaths or they are wrong MAIN_FORM_SUMMARY_COMMENT_CELLXID = 917; EXTRA_SALES_GRID_FORM_SUMMARY_COMMENT_CELLID = 2727; EXTRA_RENTAL_GRID_FORM_COMMENT_CELLID = 2754; EXTRA_LISTING_GRID_FORM_COMMENT_CELLID = 2755; EXTRA_SALES_GRID_FORM_PREVIOUS_SALES_CELLID = 2729; EXTRA_SALES_GRID_FORM_COMMENT_CELLID = 111; //dummy cellid type TImageFormat = (if_Unknown, if_BMP, if_PNG, if_GIF, if_PCX, if_JPG, if_PCD, if_TGA, if_TIF, if_EPS, if_WMF, if_EMF, if_DIB, if_DFX, if_None); TArrayOfForms = array of TDocForm; /// summary: An event for mapping cell locator information for use with an export document. TMapCellLocaterEvent = procedure(const XID: Integer; const Cell: TBaseCell; const Translator: TMISMOTranslator); const TABLE_PHOTO_NAMES : array[TComparableType] of string = ('ComparableSalesPhotos', 'ComparableRentalPhotos', 'ComparableListingPhotos'); COMPARABLE_TYPES : array[0..10] of TComparable = (cSubject, cComp1, cComp2, cComp3, cComp4, cComp5, cComp6, cComp7, cComp8, cComp9, cCompOther); IMAGE_CAPTION_ATTRIBUTE_NAMES : array[0..3] of string = ('_FirstCaptionText', '_SecondCaptionText', '_ThirdCaptionText', '_FourthCaptionText'); IMAGE_FORMAT_TAGS : array[TImageFormat] of string = ('Unknown', 'cfi_BMP', 'cfi_PNG', 'cfi_GIF', 'cfi_PCX', 'cfi_JPG', 'cfi_PCD', 'cfi_TGA', 'cfi_TIF', 'cfi_EPS', 'cfi_WMF', 'cfi_EMF', 'cfi_DIB', 'cfi_DFX', 'None'); IMAGE_FORMAT_MIME : array[TImageFormat] of string = ('image', 'image/bmp', 'image/png', 'image/gif', 'image', 'image/jpeg', 'image/x-photo-cd', 'image/targa', 'image/tiff', 'image', 'image/windows/metafile', 'image/windows/metafile', 'image', 'image', ''); /// summary: Exports the specified cell. procedure ExportCell(const ISUAD: Boolean; const Cell: TBaseCell; const Translator: TMISMOTranslator; const MapLocator: TMapCellLocaterEvent = nil; const ColumnNumber: Integer = -1); var Configuration: IXMLDOMElement; DataPoint: IXMLDOMNode; Value: String; XIDInteger: Integer; XIDString: String; begin // re-map xid datapoint for MISMO 2.6 GSE if IsUAD then begin Configuration := TUADConfiguration.Cell(Cell.FCellXID, Cell.UID); Configuration := TUADConfiguration.Mismo(Configuration, True); if Assigned(Configuration) then DataPoint := Configuration.selectSingleNode('DataPoints/DataPoint') else DataPoint := nil; end else DataPoint := nil; // get export value if Assigned(DataPoint) then begin XIDString := DataPoint.attributes.getNamedItem('XID').text; XIDInteger := StrToInt(XIDString); if Cell.FEmptyCell then Value := DataPoint.text // default else begin // Handle check box cells with default data point values to make sure // that checked boxes are the reverse of their default. That is, // if unchecked is 'Y', the default, then checked is 'N'. if (Cell.ClassName = 'TChkBoxCell') and (Trim(DataPoint.text) <> '') then begin if Cell.Text = '' then Value := DataPoint.text else if DataPoint.text = 'Y' then Value := 'N' else Value := 'Y'; end else Value := Cell.Text; end; end else begin XIDString := IntToStr(Cell.FCellXID); XIDInteger := Cell.FCellXID; Value := Cell.Text; //special handling for checkboxes in non UAD forms (1004D specifically) where datapoinr is nil //if corresponding attribute has to be included in XML even checkbox is not checked. if Cell.ClassNameIs('TChkBoxCell') then case XIDInteger of 2606,2607: //1004D alternative checkboxes update and completition if TChkBoxCell(cell).FChecked then value := 'Y' else value := 'N' end; end; // 090711 JWyatt Special cases where 'Description' is actually a whole number format // 091412 JWyatt Special cases where 'Age' or "Year Built" is approximate (ex. "~76") case Cell.FCellXID of 67, 976, 1004: Value := StringReplace(Value, ',', '', [rfReplaceAll]); 151, 996, 1809, 2247: Value := StringReplace(Value, '~', '', [rfReplaceAll]); end; // export through the mismo translator if (XIDInteger > 0) then begin if not (Value = '') then begin if (ColumnNumber > -1) then Translator.ExportValue(XIDInteger, EMPTY_STRING, IntToStr(ColumnNumber), Value) else Translator.ExportValue(XIDInteger, Value); end; // cell locator if Assigned(MapLocator) then MapLocator(XIDInteger, Cell, Translator); end; end; /// summary: Exports GSEData for the specified cell. function GetTextAsGSEData(const DataPtXID: Integer; const Cell: TBaseCell; const Translator: TMISMOTranslator; const ExportedList: TExportedList = nil; const MapLocator: TMapCellLocaterEvent = nil; const ColumnNumber: Integer = -1): String; var CellText, CityStZip, sUnit, SrcDesc, itemStr, tmpStr: String; PosGSE, PosIdx, Amt: Integer; Mo, Yr: Integer; Page: TDocPage; TmpCell: TBaseCell; begin Result := ''; CellText := GetUADLinkedComments((Cell.ParentPage.ParentForm.ParentDocument as TContainer), Cell); if CellText <> '' then case DataPtXID of // subject address 46, 2141, 47, 48, 49: if Cell.FCellXID = DataPtXID then Result := CellText; // site area 151, 996, 1809, 2247: begin tmpStr := GetOnlyDigits(CellText); if Length(tmpStr) > 0 then Result := tmpStr; end; // attic exists (none) & car storage (none) 311, 346: begin tmpStr := CellText; if tmpStr = 'X' then Result := 'N' else Result := 'Y' end; // Subject Condition comments 520: begin tmpStr := CellText; PosIdx := Pos('Bathrooms-', tmpStr); if PosIdx = 0 then PosIdx := Pos('No updates in the prior 15 years', tmpStr); if PosIdx > 0 then begin tmpStr := Copy(tmpStr, PosIdx, Length(tmpStr)); PosIdx := Pos(';', tmpStr); if PosIdx > 0 then Result := Copy(tmpStr, Succ(PosIdx), Length(tmpStr)) else Result := tmpStr; end else Result := tmpStr; end; // Management type - homeowner's association only 827: if CellText = 'X' then begin Page := Cell.ParentPage as TDocPage; TmpCell := Page.GetCellByID(828); if (TmpCell = nil) or (TmpCell.Text <> 'X') then begin TmpCell := Page.GetCellByID(829); if (TmpCell = nil) or (TmpCell.Text <> 'X') then Result := 'X'; end; end; // Management type - developer only 828: if CellText = 'X' then begin Page := Cell.ParentPage as TDocPage; TmpCell := Page.GetCellByID(827); if (TmpCell <> nil) then begin if (TmpCell.Text <> 'X') then begin TmpCell := Page.GetCellByID(829); if (TmpCell = nil) or (TmpCell.Text <> 'X') then Result := 'X'; end; end else begin TmpCell := Page.GetCellByID(2462); if (TmpCell <> nil) then begin if (TmpCell.Text <> 'X') then begin TmpCell := Page.GetCellByID(829); if (TmpCell = nil) or (TmpCell.Text <> 'X') then Result := 'X'; end; end; end; end; // Management type - agent only 829: if CellText = 'X' then begin Page := Cell.ParentPage as TDocPage; TmpCell := Page.GetCellByID(827); if (TmpCell <> nil) then begin if (TmpCell.Text <> 'X') then begin TmpCell := Page.GetCellByID(828); if (TmpCell = nil) or (TmpCell.Text <> 'X') then Result := 'X'; end; end else begin TmpCell := Page.GetCellByID(2462); if (TmpCell <> nil) then begin if (TmpCell.Text <> 'X') then begin TmpCell := Page.GetCellByID(828); if (TmpCell = nil) or (TmpCell.Text <> 'X') then Result := 'X'; end; end; end; end; // Management type - other/multiple managers 4459: begin PosIdx := 0; Page := Cell.ParentPage as TDocPage; TmpCell := Page.GetCellByID(827); if (TmpCell <> nil) then begin if TmpCell.Text = 'X' then PosIdx := 1; TmpCell := Page.GetCellByID(828); if (TmpCell <> nil) and (TmpCell.Text = 'X') then PosIdx := PosIdx + 2; TmpCell := Page.GetCellByID(829); if (TmpCell <> nil) and (TmpCell.Text = 'X') then PosIdx := PosIdx + 4; if (PosIdx > 2) and (DataPtXID = 4459) then case PosIdx of 3, 5, 6, 7: Result := MgmtGrp[PosIdx]; end; end else begin TmpCell := Page.GetCellByID(2462); if (TmpCell <> nil) then begin if TmpCell.Text = 'X' then PosIdx := 2; TmpCell := Page.GetCellByID(828); if (TmpCell <> nil) and (TmpCell.Text = 'X') then PosIdx := PosIdx + 1; TmpCell := Page.GetCellByID(829); if (TmpCell <> nil) and (TmpCell.Text = 'X') then PosIdx := PosIdx + 4; if (PosIdx > 2) and (DataPtXID = 4459) then case PosIdx of 3, 5, 6, 7: Result := CoopGrp[PosIdx]; end; end; end; end; // PUD detached unit type 2109: if CellText = 'X' then begin Page := Cell.ParentPage as TDocPage; TmpCell := Page.GetCellByID(2147); if (TmpCell = nil) or (TmpCell.Text <> 'X') then Result := 'X'; end; // PUD attached unit type 2147: if CellText = 'X' then begin Page := Cell.ParentPage as TDocPage; TmpCell := Page.GetCellByID(2109); if (TmpCell = nil) or (TmpCell.Text <> 'X') then Result := 'X'; end; // PUD attached & detached unit type 4438: begin Page := Cell.ParentPage as TDocPage; if Cell.FCellXID = 2109 then TmpCell := Page.GetCellByID(2147) else TmpCell := Page.GetCellByID(2109); if (TmpCell <> nil) and (CellText = 'X') and (TmpCell.Text = 'X') then Result := 'X'; end; // Commercial space description 2116: begin tmpStr := CellText; PosGSE := Pos(';', tmpStr); if (PosGSE > 0) then Result := Copy(tmpStr, Succ(PosGSE), Length(tmpStr)); end; // Commercial space percentage 4416: begin tmpStr := CellText; PosGSE := Pos('%', tmpStr); if (tmpStr <> '') and (PosGSE > 0) then begin Amt := StrToIntDef(Copy(tmpStr, 1, Pred(PosGSE)), -1); if (Amt > -1) then Result := IntToStr(Amt); end; end; 4415: begin if Trim(CellText) <> '' then if Copy(CellText, 1, 1) = '~' then Result := 'Y' else Result := 'N'; end; 4425: begin if Trim(CellText) <> '' then if Copy(CellText, 1, 1) = '~' then Result := 'Y' else Result := 'N'; end; // subject condition 4400: begin tmpStr := Copy(CellText, 1, 2); if (Trim(tmpStr) <> '') then begin PosGSE := AnsiIndexStr(tmpStr, ConditionListTypCode); if PosGSE > -1 then Result := ConditionListTypCode[PosGSE]; end; end; // subject condition updates in last 15 years 4401: begin tmpStr := CellText; if (Trim(tmpStr) <> '') and (tmpStr[3] = ';') then begin if Copy(tmpStr, 4, Length(Kitchen)) = Kitchen then Result := 'Y' else if Copy(tmpStr, 4, Length(NoUpd15Yrs)) = NoUpd15Yrs then Result := 'N'; end; end; // subject condition kitchen updates 4402: begin tmpStr := CellText; if (Trim(tmpStr) <> '') and (tmpStr[3] = ';') then if Copy(tmpStr, 4, Length(Kitchen)) = Kitchen then Result := Copy(Kitchen, 1, Pred(Length(Kitchen))); end; // subject condition bathroom updates 4403: begin tmpStr := CellText; if (Trim(tmpStr) <> '') and (tmpStr[3] = ';') then if Copy(tmpStr, 4, 8) = Kitchen then begin tmpStr := Copy(tmpStr, 4, Length(tmpStr)); PosGSE := Pos(';', tmpStr); if (PosGSE > 0) then begin tmpStr := Copy(tmpStr, Succ(PosGSE), Length(tmpStr)); if Copy(tmpStr, 1, Length(Bathroom)) = Bathroom then Result := Copy(Bathroom, 1, Pred(Length(Bathroom))); end; end; end; // subject condition kitchen updated or remodeled 4404: begin tmpStr := CellText; if (Trim(tmpStr) <> '') and (tmpStr[3] = ';') then begin tmpStr := Copy(tmpStr, (4 + Length(Kitchen)), Length(tmpStr)); if (tmpStr <> '') then begin PosGSE := Pos(';', tmpStr); if (PosGSE > 0) then tmpStr := Copy(tmpStr, 1, Pred(PosGSE)); PosGSE := Pos('-', tmpStr); if (PosGSE > 0) then tmpStr := Copy(tmpStr, 1, Pred(PosGSE)); PosGSE := AnsiIndexStr(tmpStr, ImprovementListTypTxt); if PosGSE > -1 then Result := ImprovementListTypXML[PosGSE]; end; end; end; // subject condition bathroom updated or remodeled 4405: begin tmpStr := CellText; if (Trim(tmpStr) <> '') and (tmpStr[3] = ';') then begin tmpStr := Copy(tmpStr, 4, Length(tmpStr)); PosGSE := Pos(';', tmpStr); if (PosGSE > 0) then begin tmpStr := Copy(tmpStr, Succ(PosGSE), Length(tmpStr)); if Copy(tmpStr, 1, Length(Bathroom)) = Bathroom then begin tmpStr := Copy(tmpStr, Succ(Length(Bathroom)), Length(tmpStr)); if (tmpStr <> '') then begin PosGSE := Pos(';', tmpStr); if (PosGSE > 0) then tmpStr := Copy(tmpStr, 1, Pred(PosGSE)); PosGSE := Pos('-', tmpStr); if (PosGSE > 0) then tmpStr := Copy(tmpStr, 1, Pred(PosGSE)); PosGSE := AnsiIndexStr(tmpStr, ImprovementListTypTxt); if PosGSE > -1 then Result := ImprovementListTypXML[PosGSE]; end; end; end; end; end; // subject condition kitchen updated or remodeled timeframe 4406: begin tmpStr := CellText; if (Trim(tmpStr) <> '') then begin //get text beyond C#;Kitchen- tmpStr := Copy(tmpStr, (4 + Length(Kitchen)), Length(tmpStr)); if (tmpStr <> '') then begin PosGSE := Pos(';', tmpStr); if (PosGSE > 0) then begin tmpStr := Copy(tmpStr, 1, Pred(PosGSE)); PosGSE := Pos('-', tmpStr); //get the timeframe text if (PosGSE > 0) then tmpStr := Copy(tmpStr, Succ(PosGSE), Length(tmpStr)); PosGSE := AnsiIndexStr(tmpStr, ImprovementListYrsTxt); if PosGSE > -1 then Result := ImprovementListYrsXML[PosGSE]; end; end; end; end; // subject condition bathroom updated or remodeled timeframe 4407: begin tmpStr := CellText; if (Trim(tmpStr) <> '') then begin //get text beyond C#;Kitchen- tmpStr := Copy(tmpStr, (4 + Length(Kitchen)), Length(tmpStr)); if (tmpStr <> '') then begin PosGSE := Pos(';', tmpStr); if (PosGSE > 0) then begin //get text beyond C#;Kitchen-updated-one to five years ago tmpStr := Copy(tmpStr, Succ(PosGSE) + Length(Bathroom), Length(tmpStr)); PosGSE := Pos(';', tmpStr); if (PosGSE > 0) then begin //get text beyond Kitchen declarations tmpStr := Copy(tmpStr, 1, Pred(PosGSE)); PosGSE := Pos('-', tmpStr); //get the timeframe text if (PosGSE > 0) then tmpStr := Copy(tmpStr, Succ(PosGSE), Length(tmpStr)); PosGSE := AnsiIndexStr(tmpStr, ImprovementListYrsTxt); if PosGSE > -1 then Result := ImprovementListYrsXML[PosGSE]; end; end; end; end; end; 4409: // contract sale analysis type begin tmpStr := CellText; PosIdx := Pos(';', tmpStr); if (PosIdx > 0) then begin tmpStr := Copy(tmpStr, 1, Pred(PosIdx)); PosGSE := AnsiIndexStr(tmpStr, SalesTypesTxt); if PosGSE > -1 then Result := SalesTypesXML[PosGSE]; end; end; 4410: // financial concession amount begin tmpStr := CellText; PosIdx := Pos(';', tmpStr); if (PosIdx > 0) then begin tmpStr := Copy(tmpStr, 1, Pred(PosIdx)); if (Trim(tmpStr) <> '') and (tmpStr[1] = '$') then tmpStr := Copy(tmpStr, 2, Length(TmpStr)); Result := IntToStr(StrToIntDef(TmpStr, 0)); end; end; 4411: // undefined financial concession indicator begin tmpStr := CellText; PosIdx := Pos(';', tmpStr); if (PosIdx > 0) then begin tmpStr := Copy(tmpStr, Succ(PosIdx), Length(TmpStr)); PosIdx := Pos(';', tmpStr); if (PosIdx > 0) and (Copy(tmpStr, 1, Pred(PosIdx)) = UADUnkFinAssistance) then Result := 'Y' else Result := 'N'; end; end; 4408: // subject source days on market (number or "Unk") begin tmpStr := CellText; PosIdx := Pos(';', tmpStr); if (PosIdx > 0) then begin TmpStr := Copy(tmpStr, 1, Pred(PosIdx)); if Copy(tmpStr, 1, 4) = DOMHint then Result := Copy(tmpStr, 5, Length(TmpStr)); end; end; // influence type - Beneficial, Adverse, Neutral 4412, 4419: begin tmpStr := CellText; if (Trim(tmpStr) <> '') and (tmpStr[2] = ';') then begin PosGSE := AnsiIndexStr(tmpStr[1], InfluenceDisplay); if PosGSE > -1 then Result := InfluenceList[PosGSE]; end; end; // first view rating factor 4413: begin tmpStr := CellText; if (Trim(tmpStr) <> '') and (tmpStr[2] = ';') then begin tmpStr := Copy(tmpStr, 3, Length(tmpStr)); PosGSE := Pos(';', tmpStr); if (tmpStr <> '') and (PosGSE > 0) then begin PosIdx := AnsiIndexStr(Copy(tmpStr, 1, Pred(PosGSE)), ViewListDisplay); if PosIdx > -1 then Result := ViewListXML[PosIdx]; end; end; end; // second view rating factor 4414: begin tmpStr := CellText; if (Trim(tmpStr) <> '') and (tmpStr[2] = ';') then begin tmpStr := Copy(tmpStr, 3, Length(tmpStr)); PosGSE := Pos(';', tmpStr); if (tmpStr <> '') and (PosGSE > 0) then begin PosIdx := AnsiIndexStr(Copy(tmpStr, Succ(PosGSE), Length(tmpStr)), ViewListDisplay); if PosIdx > -1 then Result := ViewListXML[PosIdx]; end; end; end; // first location rating factor 4420: begin tmpStr := CellText; if (Trim(tmpStr) <> '') and (tmpStr[2] = ';') then begin tmpStr := Copy(tmpStr, 3, Length(tmpStr)); PosGSE := Pos(';', tmpStr); if (tmpStr <> '') and (PosGSE > 0) then begin PosIdx := AnsiIndexStr(Copy(tmpStr, 1, Pred(PosGSE)), LocListDisplay); if PosIdx > -1 then Result := LocListXML[PosIdx]; end; end; end; // second location rating factor 4421: begin tmpStr := CellText; if (Trim(tmpStr) <> '') and (tmpStr[2] = ';') then begin tmpStr := Copy(tmpStr, 3, Length(tmpStr)); PosGSE := Pos(';', tmpStr); if (tmpStr <> '') and (PosGSE > 0) then begin PosIdx := AnsiIndexStr(Copy(tmpStr, Succ(PosGSE), Length(tmpStr)), LocListDisplay); if PosIdx > -1 then Result := LocListXML[PosIdx]; end; end; end; // construction quality 4517: begin tmpStr := CellText; if (Trim(tmpStr) <> '') then begin PosGSE := AnsiIndexStr(tmpStr, QualityListTypCode); if PosGSE > -1 then Result := QualityListTypCode[PosGSE]; end; end; // basement total square footage 4426: begin tmpStr := CellText; PosIdx := Pos('sf', tmpStr); if PosIdx > 0 then begin Amt := StrToIntDef(Copy(tmpStr, 1, Pred(PosIdx)), -1); if (Amt > -1) then Result := IntToStr(Amt); end; end; // basement finished square footage 4427: begin tmpStr := CellText; PosIdx := Pos('sf', tmpStr); if PosIdx > 0 then begin tmpStr := Copy(tmpStr, (PosIdx + 2), Length(tmpStr)); PosIdx := Pos('sf', tmpStr); Amt := StrToIntDef(Copy(tmpStr, 1, Pred(PosIdx)), -1); if (Amt > -1) then Result := IntToStr(Amt); end; end; // basement access 4519: begin tmpStr := Copy(CellText, (Length(CellText) - 1), 2); if Length(tmpStr) = 2 then PosIdx := AnsiIndexStr(tmpStr, BsmtAccessDisplay) else PosIdx := -1; if PosIdx > -1 then Result := BsmtAccessListXML[PosIdx]; end; // basement rec room count 4428: begin tmpStr := CellText; PosIdx := Pos('rr', tmpStr); if PosIdx > 0 then begin Amt := StrToIntDef(Copy(tmpStr, 1, Pred(PosIdx)), -1); if (Amt > -1) then Result := IntToStr(Amt); end; end; // basement bedroom count 4429: begin tmpStr := CellText; PosIdx := Pos('rr', tmpStr); if PosIdx > 0 then begin tmpStr := Copy(tmpStr, (PosIdx + 2), Length(tmpStr)); PosIdx := Pos('br', tmpStr); if PosIdx > 0 then begin Amt := StrToIntDef(Copy(tmpStr, 1, Pred(PosIdx)), -1); if (Amt > -1) then Result := IntToStr(Amt); end; end; end; // basement bathroom count 4430: begin tmpStr := CellText; PosIdx := Pos('br', tmpStr); if PosIdx > 0 then begin tmpStr := Copy(tmpStr, (PosIdx + 2), Length(tmpStr)); PosIdx := Pos('ba', tmpStr); if PosIdx > 0 then begin if StrToFloatDef(Copy(tmpStr, 1, Pred(PosIdx)), -1) > -1 then Result := Copy(tmpStr, 1, Pred(PosIdx)); end; end; end; // basement other room count 4520: begin tmpStr := CellText; PosIdx := Pos('ba', tmpStr); if PosIdx > 0 then begin tmpStr := Copy(tmpStr, (PosIdx + 2), Length(tmpStr)); if tmpStr[Length(tmpStr)] = 'o' then begin Amt := StrToIntDef(Copy(tmpStr, 1, Pred(Length(tmpStr))), -1); if (Amt > -1) then Result := IntToStr(Amt); end; end; end; 4431: begin SrcDesc := ''; tmpStr := CellText; PosGSE := Pos(';', tmpStr); if PosGSE > 0 then repeat SrcDesc := SrcDesc + Copy(tmpStr, 1, PosGSE); tmpStr := Copy(tmpStr, Succ(PosGSE), Length(tmpStr)); PosGSE := Pos(';', tmpStr); until PosGSE = 0; if (Length(SrcDesc) > 0) and (SrcDesc[Length(SrcDesc)] = ';') then SrcDesc := Copy(SrcDesc, 1, Pred(Length(SrcDesc))); Result := SrcDesc; end; // sale or financing concessions financing type 4432: begin tmpStr := CellText; PosIdx := Pos(';', tmpStr); if (PosIdx >= 0) then begin tmpStr := Copy(tmpStr, 1, Pred(PosIdx)); if tmpStr <> '' then begin PosIdx := AnsiIndexStr(tmpStr, FinDesc); if PosIdx >= 0 then Result := FinType[PosIdx] else Result := FinType[MaxFinTypes]; end; end; end; // sale or financing concessions financing type "Other" description 4433: begin tmpStr := CellText; PosIdx := Pos(';', tmpStr); if (PosIdx >= 0) then begin tmpStr := Copy(tmpStr, 1, Pred(PosIdx)); if tmpStr <> '' then begin PosIdx := AnsiIndexStr(tmpStr, FinDesc); if PosIdx < 0 then Result := tmpStr; end; end; end; // grid date of sale - comparables only status type 4434: begin tmpStr := CellText; PosIdx := AnsiIndexStr(tmpStr[1], DOSTypes); if PosIdx < 0 then PosIdx := AnsiIndexStr(tmpStr, DOSTypes); if PosIdx >= 0 then Result := DOSTypesXML[PosIdx]; end; // grid date of sale - comparables only short date description #1 4435: begin tmpStr := CellText; if (Copy(tmpStr, 4, 1) = '/') then begin Mo := StrToIntDef(Copy(tmpStr, 2, 2), 0); Yr := StrToIntDef(Copy(tmpStr, 5, 2), -1); if ((Yr >= 0) and ((Mo > 0) and (Mo < 13))) then Result := Copy(tmpStr, 2, 5); end else if (Length(tmpStr) = 4) and (tmpStr[1] = 'c') and (Copy(tmpStr, 2, 3) = 'Unk') then Result := 'Unk'; end; // grid date of sale - comparables only short date description #2 4418: begin tmpStr := CellText; if (Copy(tmpStr, 11, 1) = '/') then begin Mo := StrToIntDef(Copy(tmpStr, 9, 2), 0); Yr := StrToIntDef(Copy(tmpStr, 12, 2), -1); if ((Yr >= 0) and ((Mo > 0) and (Mo < 13))) then Result := Copy(tmpStr, 9, 5); end; end; 4510, 4595, 4597, 4599: Result := Format('%-16.12f', [(Cell as TGeocodedGridCell).Latitude]); 4511, 4596, 4598, 4600: Result := Format('%-16.12f', [(Cell as TGeocodedGridCell).Longitude]); // first "Other" view rating factor 4512: begin tmpStr := CellText; if (Trim(tmpStr) <> '') and (tmpStr[2] = ';') then begin tmpStr := Copy(tmpStr, 3, Length(tmpStr)); if tmpStr <> '' then begin PosGSE := Pos(';', tmpStr); if PosGSE > 0 then itemStr := Copy(tmpStr, 1, Pred(PosGSE)) else itemStr := tmpStr; PosIdx := AnsiIndexStr(itemStr, ViewListDisplay); if (PosIdx < 0) and (itemStr <> '') then Result := itemStr; end; end; end; // second "Other" view rating factor 4513: begin tmpStr := CellText; if (Trim(tmpStr) <> '') and (tmpStr[2] = ';') then begin tmpStr := Copy(tmpStr, 3, Length(tmpStr)); if tmpStr <> '' then begin PosGSE := Pos(';', tmpStr); if PosGSE > 0 then itemStr := Copy(tmpStr, 1, Pred(PosGSE)) else itemStr := tmpStr; if (PosGSE > 0) and (itemStr <> '') then begin itemStr := Copy(tmpStr, Succ(PosGSE), Length(tmpStr)); if itemStr <> '' then begin PosIdx := AnsiIndexStr(itemStr, ViewListDisplay); if PosIdx < 0 then Result := itemStr; end end; end; end; end; // first "Other" location rating factor 4514: begin tmpStr := CellText; if (Trim(tmpStr) <> '') and (tmpStr[2] = ';') then begin tmpStr := Copy(tmpStr, 3, Length(tmpStr)); if tmpStr <> '' then begin PosGSE := Pos(';', tmpStr); if PosGSE > 0 then itemStr := Copy(tmpStr, 1, Pred(PosGSE)) else itemStr := tmpStr; PosIdx := AnsiIndexStr(itemStr, LocListDisplay); if (PosIdx < 0) and (itemStr <> '') then Result := itemStr; end; end; end; // second "Other" location rating factor 4515: begin tmpStr := CellText; if (Trim(tmpStr) <> '') and (tmpStr[2] = ';') then begin tmpStr := Copy(tmpStr, 3, Length(tmpStr)); if tmpStr <> '' then begin PosGSE := Pos(';', tmpStr); if PosGSE > 0 then itemStr := Copy(tmpStr, 1, Pred(PosGSE)) else itemStr := tmpStr; if (PosGSE > 0) and (itemStr <> '') then begin itemStr := Copy(tmpStr, Succ(PosGSE), Length(tmpStr)); if itemStr <> '' then begin PosIdx := AnsiIndexStr(itemStr, LocListDisplay); if PosIdx < 0 then Result := itemStr; end end; end; end; end; 4527: if (Cell.FCellXID = 41) or (Cell.FCellXID = 926) then begin CityStZip := CellText; PosGSE := Pos(',',CityStZip); if PosGSE > 0 then // If there are 2 commas in the address then retrieve the unit if Pos(',', Copy(CityStZip, Succ(PosGSE), Length(CityStZip))) > 0 then Result := Copy(cityStZip, 1, Pred(PosGSE)); end; 4528: if (Cell.FCellXID = 41) or (Cell.FCellXID = 926) then begin sUnit := ''; CityStZip := CellText; PosGSE := Pos(',',CityStZip); if PosGSE > 0 then begin // If there is a unit number (2 commas in the address) then // retrieve the unit and capture only the city, state and zip // for further processing if Pos(',', Copy(CityStZip, Succ(PosGSE), Length(CityStZip))) > 0 then begin sUnit := Copy(cityStZip, 1, Pred(PosGSE)); CityStZip := Copy(CityStZip, Succ(PosGSE), Length(CityStZip)); end; end; Result := ParseCityStateZip3(CityStZip, cmdGetCity); end; 4529: if (Cell.FCellXID = 41) or (Cell.FCellXID = 926) then begin sUnit := ''; CityStZip := CellText; PosGSE := Pos(',',CityStZip); if PosGSE > 0 then begin // If there is a unit number (2 commas in the address) then // retrieve the unit and capture only the city, state and zip // for further processing if Pos(',', Copy(CityStZip, Succ(PosGSE), Length(CityStZip))) > 0 then begin sUnit := Copy(cityStZip, 1, Pred(PosGSE)); CityStZip := Copy(CityStZip, Succ(PosGSE), Length(CityStZip)); end; end; Result := ParseCityStateZip3(CityStZip, cmdGetState); end; 4530: if (Cell.FCellXID = 41) or (Cell.FCellXID = 926) then begin sUnit := ''; CityStZip := CellText; PosGSE := Pos(',',CityStZip); if PosGSE > 0 then begin // If there is a unit number (2 commas in the address) then // retrieve the unit and capture only the city, state and zip // for further processing if Pos(',', Copy(CityStZip, Succ(PosGSE), Length(CityStZip))) > 0 then begin sUnit := Copy(cityStZip, 1, Pred(PosGSE)); CityStZip := Copy(CityStZip, Succ(PosGSE), Length(CityStZip)); end; end; Result := ParseCityStateZip3(CityStZip, cmdGetZip); end; 4531: begin tmpStr := CellText; PosGSE := Pos(';', tmpStr); if PosGSE > 0 then repeat tmpStr := Copy(tmpStr, Succ(PosGSE), Length(tmpStr)); PosGSE := Pos(';', tmpStr); until PosGSE = 0; if tmpStr <> '' then begin PosGSE := Pos('DOM', tmpStr); if PosGSE > 0 then Result := Trim(Copy(tmpStr, (PosGSE + 3), Length(tmpStr))); end; end; // sales or financing concessions type 4532: begin tmpStr := CellText; PosIdx := AnsiIndexStr(tmpStr, SalesTypesDisplay); if (PosIdx >= 0) then Result := SalesTypesXML[PosIdx]; end; // sales or financing concessions amount 4533: begin tmpStr := CellText; PosIdx := Pos(';', tmpStr); if (PosIdx >= 0) then Result := Copy(tmpStr, Succ(PosIdx), Length(tmpStr)); end; // grid date of sale - comparables only short date description #2 4534: begin tmpStr := CellText; if ((tmpStr[1] = 's') and (Copy(tmpStr, 8, Length(tmpStr)) = 'Unk')) or ((tmpStr[1] = 'c') and (Copy(tmpStr, 2, Length(tmpStr)) = 'Unk')) then Result := 'Y' else Result := 'N'; end; // appraiser or supervisor single line address (XID 1660, 1737)-name 4545, 4563: begin tmpStr := CellText; PosIdx := Pos(',', tmpStr); if (PosIdx >= 0) then Result := Copy(tmpStr, 1, Pred(PosIdx)); end; // appraiser or supervisor address2-city 4547, 4585: Result := ParseCityStateZip3(CellText, cmdGetCity); // appraiser or supervisor address2-state 4548, 4586: Result := ParseCityStateZip3(CellText, cmdGetState); // appraiser or supervisor address2-zip 4549, 4587: Result := ParseCityStateZip3(CellText, cmdGetZip); else Result := CellText; end; end; /// summary: Exports GSEData for the specified cell. procedure ExportGSEData(const Cell: TBaseCell; const Translator: TMISMOTranslator; const ExportedList: TExportedList = nil; const MapLocator: TMapCellLocaterEvent = nil; const ColumnNumber: Integer = -1); var Configuration: IXMLDOMElement; DataPoint: IXMLDOMNode; DataPointList: IXMLDOMNodeList; GSEData: TStringList; Index: Integer; Value: String; XIDInteger: Integer; XIDString: String; begin GSEData := TStringList.Create; try GSEData.CommaText := Cell.GSEData; //need to load in UAD Database becuase it has the defaults for the fields Configuration := TUADConfiguration.Cell(Cell.FCellXID, Cell.UID); Configuration := TUADConfiguration.Mismo(Configuration, True); if Assigned(Configuration) then begin DataPointList := Configuration.selectNodes('DataPoints/DataPoint'); for Index := 0 to DataPointList.length - 1 do begin DataPoint := DataPointList.item[Index]; XIDString := DataPoint.attributes.getNamedItem('XID').text; XIDInteger := StrToInt(XIDString); // get export value // 050912 New method retrieves data from cell text, even if data points exist Value := GetTextAsGSEData(XIDInteger, Cell, Translator, nil, MapLocator, ColumnNumber); if Value = '' then Value := DataPoint.text; // get the default // 050912 Was: {if (GSEData.Values[XIDString] = '') then begin Value := GetTextAsGSEData(XIDInteger, Cell, Translator, nil, MapLocator, ColumnNumber); if Value = '' then Value := DataPoint.text; // get the default end else Value := GSEData.Values[XIDString];} // 090711 JWyatt Special cases where 'Description' is actually a whole number format case Cell.FCellXID of 67, 976, 1004: Value := StringReplace(Value, ',', '', [rfReplaceAll]); end; // export through the mismo translator if (XIDInteger > 0) then begin if not (Value = '') then begin if (ColumnNumber > -1) then Translator.ExportValue(XIDInteger, EMPTY_STRING, IntToStr(ColumnNumber), Value) else if not Assigned(ExportedList) then Translator.ExportValue(XIDInteger, Value) else if not ExportedList.HasBeenExported(XIDInteger) then Translator.ExportValue(XIDInteger, Value); end; // map cell locator if Assigned(MapLocator) then MapLocator(XIDInteger, Cell, Translator); end; end; end; finally GSEData.Destroy; end; end; /// summary: Embeds cell locator information within the export document. /// remarks: Replaces the previously exported value since this export document // is exclusively for use with cell locating. procedure MapEmbeddedLocater(const XID: Integer; const Cell: TBaseCell; const Translator: TMISMOTranslator); const CIdentificationType = 'Loc'; var Coordinates: TPoint; UID: CellUID; Value: String; begin UID := Cell.UID; Value := Format('P%d.%d', [UID.Pg + 1, UID.Num + 1]); if (Cell is TGridCell) then begin (Cell as TGridCell).GetCoordinates(Coordinates); Translator.ExportValue(XID, CIdentificationType, IntToStr(Coordinates.Y), Value); end else Translator.ExportValue(XID, CIdentificationType, EMPTY_STRING, Value); end; /// summary: Stores XPath cell locator information within the document container. procedure MapXPathLocater(const XID: Integer; const Cell: TBaseCell; const Translator: TMISMOTranslator); var Document: TContainer; begin Document := Cell.ParentPage.ParentForm.ParentDocument as TContainer; Document.CellXPathList.AddItem(Cell.InstanceID, Translator.Mappings.Find(XID).XPath); end; function ExtensionToImageType(AnExtension : string) : TImageFormat; begin if Copy(AnExtension, 1, 1) = '.' then System.Delete(AnExtension, 1, 1); if SameText(AnExtension, 'bmp') then Result := if_BMP else if SameText(AnExtension, 'jpg') or SameText(AnExtension, 'jpeg') then Result := if_JPG else if SameText(AnExtension, 'tif') or SameText(AnExtension, 'tiff') then Result := if_TIF else if SameText(AnExtension, 'tga') or SameText(AnExtension, 'targa') then Result := if_TGA else if SameText(AnExtension, 'gif') then Result := if_GIF else if SameText(AnExtension, 'png') then Result := if_PNG else if SameText(AnExtension, 'pcd') then Result := if_PCD else if SameText(AnExtension, 'emf') then Result := if_EMF else if SameText(AnExtension, 'wmf') then Result := if_WMF else Result := if_Unknown; end; function ExtensionToMime(const AnExtension : string) : string; begin Result := IMAGE_FORMAT_MIME[ExtensionToImageType(AnExtension)]; end; function MimeToExtension(AMime : string) : string; begin if SameText(AMime, 'image/bmp') then Result := 'bmp' else if SameText(AMime, 'image/jpeg') then Result := 'jpeg' else if SameText(AMime, 'image/tiff') then Result := 'tiff' else if SameText(AMime, 'image/targa') then Result := 'targa' else if SameText(AMime, 'image/gif') then Result := 'gif' else if SameText(AMime, 'image/png') then Result := 'png' else if SameText(AMime, 'image/x-photo-cd') then Result := 'pcd' else if SameText(AMime, 'image/windows/metafile') then Result := 'emf' else if SameText(AMime, 'image/windows/metafile') then Result := 'wmf' else raise Exception.Create('Unrecognized mime type ' + AMime); end; function ImageLibTypeToImageFormat(const AString : string) : TImageFormat; begin if AString = uGraphics.cfi_DIB then Result := if_DIB else if AString = uGraphics.cfi_BMP then Result := if_BMP else if AString = uGraphics.cfi_PNG then Result := if_PNG else if AString = uGraphics.cfi_GIF then Result := if_GIF else if AString = uGraphics.cfi_PCX then Result := if_PCX else if AString = uGraphics.cfi_JPG then Result := if_JPG else if AString = uGraphics.cfi_PCD then Result := if_PCD else if AString = uGraphics.cfi_TGA then Result := if_TGA else if AString = uGraphics.cfi_TIF then Result := if_TIF else if AString = uGraphics.cfi_WMF then Result := if_WMF else if AString = uGraphics.cfi_EMF then Result := if_EMF else Result := if_Unknown; end; (* //###REMOVE - DUPLICATE - NOT USED IN THIS UNIT function IsFalseGridCell(ACellID : Integer) : Boolean; begin Result := True; case ACellID of 4 : ; // Case Number Identifier 35 : ; // Client (Company) Name 36 : ; // Client Street Address 45 : ; // Borrower Unparsed Name 46 : ; // Property Address 47 : ; // Property City 48 : ; // Property State 49 : ; // Property Postal Code 50 : ; // Property Country 92 : ; // Driveway Surface Comment 114 : ; 146 : ; // Living Unit Count 151 : ; // Subject structure built year 229 : ; // Total Room Count 230 : ; // Total Bedroom Count 231 : ; // Total Bathroom Count 232 : ; // Gross Living Area Square Feet Count 309 : ; // Kitchen Equipment Type Other Description 333 : ; // Structure Deck Detailed Description 335 : ; // Structure Porch Detailed Description 337 : ; // Structure Fence Detailed Description 340 : ; // Structure Pool Detailed Description 344 : ; // Structure Exterior Features Other Description 349 : ; // Structure Car Storage (Garage) 355 : ; // Structure Car Storage (Carport) 360 : ; // Structure Car Storage (Driveway) Parking Spaces Count 920 : ; // Sales Comparison Researched Count 921 : ; // Sales Comparison Low Price Range 922 : ; // Sales Comparison High Price Range 924 : ; // Extra Item One Name 2009 : ; // Extra Item One Name 2073 : ; // Extra Item One Name 1091 : ; // Listing Comparison Researched Count 1092 : ; // Listing Comparison Low Price Range 1093 : ; // Listing Comparison High Price Range 2010 : ; // Page number placeholder 2028 : ; // Structure Woodstove count 2090 : ; // Data Source Description 2742..2746 : ; // Rental grid summary cells 2275..2306 : ; // Rental grid unit cells else Result := False; end; end; *) //### DUPLICATED IN UMISMOINTERFCE function IsPublicAppraisalFormType(AFormID : Integer) : Boolean; begin case AFormID of FMX_1004, FMX_1004P, FMX_1004C, FMX_1004D, ERC_1994, ERC_2001, ERC_2003, FMX_1073, FMX_1075, FMX_1025, FMX_2000, FMX_2000A, FMX_2055, MOBILE_HOME, LAND_APPRAISAL, COMPLETION_CERTIFICATE_LEGAL, // 442 FMAE_1004_1993, FMAE_1073_1997, FMAE_1025_1994, FMAE_2055_1996, FMAE_2065_1996, FMAE_2075_1997, FMAE_2070: Result := True; else Result := False; end; end; //used to check for data before creating elements function FormCellsHaveText(AForm: TDocForm; const CellIDs: Array of Integer): Boolean; var len,i: Integer; begin result := False; len := length(CellIDs); for i := 0 to len -1 do if length(Trim(AForm.GetCellTextByXID_MISMO(CellIDs[i]))) > 0 then begin result := True; break; end; end; function MISMOBoolean(value: Boolean): String; begin result := 'N'; if value then result := 'Y'; end; function MISMODate(ADoc: TContainer; ACell: TBaseCell; ErrList: TObjectList): String; var AValue: String; ADate: TDateTime; begin result := ''; if assigned(ACell) then begin AValue := ACell.GetText; if IsValidDateTimeWithDiffSeparator(AValue, ADate) then result := FormatDateTime('yyyy-mm-dd', ADate) else result := AValue; //this is RELS Specific exception end; end; //----------------------------------- // Start of the Export XML Routines //----------------------------------- procedure ExportReportAttributes(doc: TContainer; exportForm: BooleanArray; ATranslator: TMISMOTranslator; Info: TMiscInfo; IsVer2_6: Boolean; XMLVer: String); //var // fName, fVers: String; begin ATranslator.ExportValue(SOFTWARE_NAME_CELLID, ClickFormsName); //Producing Software Name ATranslator.ExportValue(SOFTWARE_VERSION_CELLID, SysInfo.AppVersion); //Producing Software Version ATranslator.ExportValue(2995, StringReplace(XMLVer, '_', '.', [rfReplaceAll])); //MISMOVersionID - GSE // 030411 JWyatt The VendorVersionIdentifier is not supported for version // 2.6 reports if not IsVer2_6 then ATranslator.ExportValue(GSE_VERSION_CELLID, GSE_XMLVersion); //GSE version of XML ATranslator.ExportValue(2992, doc.GetCellTextByXID_MISMO(2992, exportForm)); //AppraisalScopeOfWorkDescription ATranslator.ExportValue(2993, doc.GetCellTextByXID_MISMO(2993, exportForm)); //AppraisalIntendedUserDescription ATranslator.ExportValue(2994, doc.GetCellTextByXID_MISMO(2994, exportForm)); //AppraisalIntendedUseDescription // If we're not processing a UAD compliant report & there is report info // declared then we can export the following attributes. If this is a UAD // compliant report, exporting these attributes will cause the XML to // be invalid when validated using the MISMO schema. {********** THESE ARE FOR ELS *******************} if (not IsVer2_6) and assigned(Info) then begin //set undue influence on appraiser ATranslator.ExportValue(10503, Info.FHasUndueInfluence); if (length(Info.FUndueInfluenceDesc) > 0) then ATranslator.ExportValue(10504, Info.FUndueInfluenceDesc); //pass on the order ID in Vendor Transaction Identifier ATranslator.ExportValue(10505, Info.FOrderID); //pass on the appraiser ID in Appraiser Identifier ATranslator.ExportValue(10506, Info.FAppraiserID); //pass on only if it is true that ClickForms review was overridden if Info.FRevOverride then ATranslator.ExportValue(10508, Info.FRevOverride); end; // The following code fragment along with the variables above have been // commented for a long time and their use is unknown. (* --- AppraisalFormType is handled by AppraisalReportContentType //Set Major form type if AppraisalMajorFormName(doc, fName, fVers) then //have a major form begin ATranslator.ExportValue(10500, fName); ATranslator.ExportValue(10501, fVers); end else //unknown major form begin ATranslator.ExportValue(10500, 'Other'); ATranslator.ExportValue(10501, 'Unknown'); ATranslator.ExportValue(10502, fName); end; *) end; procedure ExportReportEmbededPDF(doc: TContainer; ATranslator: TMISMOTranslator; Info: TMiscInfo; V2_6Element:TXMLElement=nil); // PDFPath: string ); const errCannotFindPDFFile = 'Cannot find the PDF file %s!'; var AStream: TFileStream; pdfStr, EncodedStr : string; AnElement: TXMLElement; begin if assigned(Info) and Info.FEmbedPDF then begin if not fileExists(Info.FPDFFileToEmbed) then raise Exception.Create(Format(errCannotFindPDFFile,[Info.FPDFFileToEmbed])); AStream := TFileStream.Create(Info.FPDFFileToEmbed, fmOpenRead); try SetLength(pdfStr, AStream.Size); AStream.Read(PChar(pdfStr)^,length(pdfStr)); finally AStream.Free; end; if length(pdfStr) > 0 then begin EncodedStr := UBase64.Base64Encode(pdfStr); if Assigned(V2_6Element) then begin AnElement := V2_6Element; AnElement := AnElement.AddElement('IMAGE'); AnElement.AttributeValues['_SequenceIdentifier'] := '1'; AnElement.AttributeValues['_Name'] := 'AppraisalForm'; end else AnElement := ATranslator.XML.FindElement('REPORT'); with AnElement.AddElement('EMBEDDED_FILE') do begin AttributeValues['_Type'] := 'PDF'; AttributeValues['_EncodingType'] := 'Base64'; AttributeValues['_Name'] := 'AppraisalReport'; AttributeValues['MIMEType'] := 'application/pdf'; AddElement('DOCUMENT').RawText := EncodedStr; end; end; end; end; //This is ugly because we went from Data Centric to Form Centric so now each form has to be checked //and certain elements created based on what is in the signature block. This could be rethought and //probably made simplier to code and understand. // Version 7.2.8 090110 JWyatt The ExpireDateExists variable and the checks for form ID 794 // are included to address unique XML addresses assigned to this form. This was discussed // in a meeting today and it was agreed that this code should be revised to use only // XML IDs in the next release. procedure ExportFormSigners(ADoc: TContainer; AForm: TDocForm; AElement: TXMLElement; ErrList: TObjectList); var Signer, Person, Signature, Contact, Inspection, License: TXMLElement; CityStZip, Phone, Fax, Email: String; hasSignature: Boolean; ExpireDateExists: Boolean; // These variables are declared to handle special processing for cell XID 2008 ChkBoxUID: CellUID; InspDateCell: TBaseCell; InspDateSet: Boolean; begin //IMPORTANT- make sure we skip these cells in main export loop //Exported Appraiser CellIDs //7,1684,9,10,11,12,13,5,14,15,16 //17,18,19,20,21,5008,2098,2096,2097 //1149,1150,1151,2009,1660,1678 if FormCellsHaveText(AForm, [7,22,1402]) or //appraiser names FormCellsHaveText(AForm, [1150,1151])then //inspection checkboxes Signer := AElement.AddElement('SIGNERS') //create single SIGNER element for form else exit; //Is the appraiser's name on this form? // if Length(AForm.GetCellTextByXID_MISMO(7))>0 then if FormCellsHaveText(AForm, [7,1150,1151]) then //signature or inspection checkboxes begin Person := Signer.AddElement('APPRAISER'); Person.AttributeValues['_Name'] := AForm.GetCellTextByXID_MISMO(7); Person.AttributeValues['_CompanyName'] := AForm.GetCellTextByXID_MISMO(1684); Person.AttributeValues['_StreetAddress'] := AForm.GetCellTextByXID_MISMO(9); CityStZip := AForm.GetCellTextByXID_MISMO(10); //Appraiser City, St, Zip Person.AttributeValues['_StreetAddress2'] := CityStZip; Person.AttributeValues['_City'] := ParseCityStateZip3(CityStZip, 1); //Appraiser City Person.AttributeValues['_State'] := ParseCityStateZip3(CityStZip, 2); //Appraiser State Person.AttributeValues['_PostalCode'] := ParseCityStateZip3(CityStZip, 3); //Appraiser Zip Person.AttributeValues['AppraisalFormsUnparsedAddress'] := AForm.GetCellTextByXID_MISMO(1660); if FormCellsHaveText(AForm, [14,15,16]) then begin Contact := Person.AddElement('CONTACT_DETAIL'); Phone := AForm.GetCellTextByXID_MISMO(14); if length(phone)> 0 then Contact.AddElement('CONTACT_POINT', ['_Type', 'Phone', '_Value', Phone]); fax := AForm.GetCellTextByXID_MISMO(15); if length(fax)>0 then Contact.AddElement('CONTACT_POINT', ['_Type', 'Fax', '_Value', Fax]); email := AForm.GetCellTextByXID_MISMO(16); if length(email)>0 then Contact.AddElement('CONTACT_POINT', ['_Type', 'Email', '_Value', email]); end; (* <FIELD ID="17" XPath="//VALUATION_RESPONSE/PARTIES/APPRAISER/APPRAISER_LICENSE/@_ExpirationDate"/> <FIELD ID="18" XPath="//VALUATION_RESPONSE/PARTIES/APPRAISER/APPRAISER_LICENSE[@_Type=&dq;Certificate&dq;]/@_Identifier"/> <FIELD ID="19" XPath="//VALUATION_RESPONSE/PARTIES/APPRAISER/APPRAISER_LICENSE/.[@_Type=&dq;Certificate&dq;]/@_State"/> <FIELD ID="20" XPath="//VALUATION_RESPONSE/PARTIES/APPRAISER/APPRAISER_LICENSE[@_Type=&dq;License&dq;]/@_Identifier"/> <FIELD ID="21" XPath="//VALUATION_RESPONSE/PARTIES/APPRAISER/APPRAISER_LICENSE/.[@_Type=&dq;License&dq;]/@_State"/> <FIELD ID="5008" XPath="//VALUATION_RESPONSE/PARTIES/APPRAISER/APPRAISER_LICENSE/@_Identifier"/> <FIELD ID="2098" XPath="//VALUATION_RESPONSE/PARTIES/APPRAISER/APPRAISER_LICENSE/@_State"/> <FIELD ID="2096" XPath="//VALUATION_RESPONSE/PARTIES/APPRAISER/APPRAISER_LICENSE[@_Type=&dq;Other&dq;]/@_Identifier"/> <FIELD ID="2097" XPath="//VALUATION_RESPONSE/PARTIES/APPRAISER/APPRAISER_LICENSE[@_Type=&dq;Other&dq;]/@_TypeOtherDescription"/> *) //Appraiser License Configurations License := nil; if FormCellsHaveText(AForm, [20,21]) then //has License Identifier begin ExpireDateExists := (Trim(AForm.GetCellText(1,263)) <> ''); if (AForm.FormID = 794) and ExpireDateExists then Person.AddElement('APPRAISER_LICENSE'); License := Person.AddElement('APPRAISER_LICENSE', ['_Type', 'License']); License.AttributeValues['_Identifier'] := AForm.GetCellTextByXID_MISMO(20); License.AttributeValues['_State'] := AForm.GetCellTextByXID_MISMO(21); if not (length(AForm.GetCellTextByXID_MISMO(21))>0) then License.AttributeValues['_State'] := AForm.GetCellTextByXID_MISMO(2098); if (AForm.FormID = 794) and ExpireDateExists then License := License.ParentElement; License.AttributeValues['_ExpirationDate'] := MISMODate(ADoc, AForm.GetCellByXID_MISMO(17), ErrList); end; if FormCellsHaveText(AForm, [18,19]) then //has Certificate Identifier begin ExpireDateExists := (Trim(AForm.GetCellText(1,263)) <> ''); if (AForm.FormID = 794) and (not FormCellsHaveText(AForm, [20,21])) and ExpireDateExists then Person.AddElement('APPRAISER_LICENSE'); License := Person.AddElement('APPRAISER_LICENSE', ['_Type', 'Certificate']); License.AttributeValues['_Identifier'] := AForm.GetCellTextByXID_MISMO(18); License.AttributeValues['_State'] := AForm.GetCellTextByXID_MISMO(19); if not (length(AForm.GetCellTextByXID_MISMO(19))>0) then License.AttributeValues['_State'] := AForm.GetCellTextByXID_MISMO(2098); if (AForm.FormID = 794) and ExpireDateExists then License := License.ParentElement; License.AttributeValues['_ExpirationDate'] := MISMODate(ADoc, AForm.GetCellByXID_MISMO(17), ErrList); end; if FormCellsHaveText(AForm, [2096,2097]) then //has Other Identifier begin License := Person.AddElement('APPRAISER_LICENSE', ['_Type', 'Other']); License.AttributeValues['_Identifier'] := AForm.GetCellTextByXID_MISMO(2096); License.AttributeValues['_TypeOtherDescription'] := AForm.GetCellTextByXID_MISMO(2097); License.AttributeValues['_State'] := AForm.GetCellTextByXID_MISMO(2098); License.AttributeValues['_ExpirationDate'] := MISMODate(ADoc, AForm.GetCellByXID_MISMO(17), ErrList); end; if FormCellsHaveText(AForm, [1517]) then //has unknown Identifier begin License := Person.AddElement('APPRAISER_LICENSE'); License.AttributeValues['_Identifier'] := AForm.GetCellTextByXID_MISMO(1517); License.AttributeValues['_State'] := AForm.GetCellTextByXID_MISMO(2098); License.AttributeValues['_ExpirationDate'] := MISMODate(ADoc, AForm.GetCellByXID_MISMO(17), ErrList); end; if FormCellsHaveText(AForm, [5008]) then //has Other (License or Certificate) Identifier begin License := Person.AddElement('APPRAISER_LICENSE', ['_Type', 'Other']); License.AttributeValues['_TypeOtherDescription'] := AForm.GetCellTextByXID_MISMO(5008); License.AttributeValues['_State'] := AForm.GetCellTextByXID_MISMO(2098); License.AttributeValues['_ExpirationDate'] := MISMODate(ADoc, AForm.GetCellByXID_MISMO(17), ErrList); end; if not assigned(License) and FormCellsHaveText(AForm, [2098,17]) then //only entered exp or date begin License := Person.AddElement('APPRAISER_LICENSE'); License.AttributeValues['_State'] := AForm.GetCellTextByXID_MISMO(2098); License.AttributeValues['_ExpirationDate'] := MISMODate(ADoc, AForm.GetCellByXID_MISMO(17), ErrList); end; (* <FIELD ID="1149" XPath="//VALUATION_RESPONSE/PARTIES/APPRAISER/INSPECTION[@AppraisalInspectionPropertyType=&dq;Subject&dq;]/.[@AppraisalInspectionType=&dq;None&dq;]"/> <FIELD ID="1150" XPath="//VALUATION_RESPONSE/PARTIES/APPRAISER/INSPECTION[@AppraisalInspectionPropertyType=&dq;Subject&dq;]/.[@AppraisalInspectionType=&dq;ExteriorOnly&dq;]"/> <FIELD ID="1151" XPath="//VALUATION_RESPONSE/PARTIES/APPRAISER/INSPECTION[@AppraisalInspectionPropertyType=&dq;Subject&dq;]/.[@AppraisalInspectionType=&dq;ExteriorAndInterior&dq;]"/> <FIELD ID="2009" XPath="//VALUATION_RESPONSE/PARTIES/APPRAISER/INSPECTION[@AppraisalInspectionPropertyType=&dq;Subject&dq;]/@InspectionDate"/> *) //Appraiser's Date and Type of Inspection if FormCellsHaveText(AForm, [1149,1150,1151,2009]) then begin Inspection := Person.AddElement('INSPECTION', ['AppraisalInspectionPropertyType', 'Subject']); if CompareText(AForm.GetCellTextByXID_MISMO(1149), 'X')=0 then Inspection.AttributeValues['AppraisalInspectionType'] := 'None'; if CompareText(AForm.GetCellTextByXID_MISMO(1150), 'X')=0 then Inspection.AttributeValues['AppraisalInspectionType'] := 'ExteriorOnly'; if CompareText(AForm.GetCellTextByXID_MISMO(1151), 'X')=0 then Inspection.AttributeValues['AppraisalInspectionType'] := 'ExteriorAndInterior'; if length(AForm.GetCellTextByXID_MISMO(2009))> 0 then Inspection.AttributeValues['InspectionDate'] := MISMODate(ADoc, AForm.GetCellByXID_MISMO(2009), ErrList); end; //Appraiser's Signature and Date // Version 7.2.7 082710 JWyatt Add special case check for the FNMA 2000 & 2000A // certification forms. They have a "Reviewer" signature panel but the associated // IDs (name, company name, company address, etc.) are the APPRAISER element IDs // in the XML, not the REVIEW_APPRAISER IDs. This was a RELS requirement so, in // these case, we must check for "Reviewer" to determine whether or not there // is a signature affixed. if (AForm.FormID = FMX_2000_INST) or (AForm.FormID = FMX_2000A_INST) then hasSignature := ADoc.docSignatures.SignatureIndexOf('Reviewer') > -1 else hasSignature := ADoc.docSignatures.SignatureIndexOf('Appraiser') > -1; if hasSignature or (Length(AForm.GetCellTextByXID_MISMO(5))>0) then //is there a signature date begin Signature := Person.AddElement('SIGNATURE'); Signature.AttributeValues['_Date'] := MISMODate(ADoc, AForm.GetCellByXID_MISMO(5), ErrList); Signature.AttributeValues['_AffixedIndicator'] := MISMOBoolean(hasSignature); end; end; {--SUPERVIOR-------------------------------------------------------------} //Exported Supervisor CellIDs //6,22,23,24,42,25,26,27,276,277 //5018,2099,28,29,30,32,33 //1152,1153,1154,2008,1155,1156,2100,1679 //Is the supervisor's name on this form? if length(AForm.GetCellTextByXID_MISMO(22))>0 then begin Person := Signer.AddElement('SUPERVISOR'); Person.AttributeValues['_Name'] := AForm.GetCellTextByXID_MISMO(22); Person.AttributeValues['_CompanyName'] := AForm.GetCellTextByXID_MISMO(23); Person.AttributeValues['_StreetAddress'] := AForm.GetCellTextByXID_MISMO(24); CityStZip := AForm.GetCellTextByXID_MISMO(42); //Supervisor City, St, Zip Person.AttributeValues['_StreetAddress2'] := CityStZip; Person.AttributeValues['_City'] := ParseCityStateZip3(CityStZip, 1); //Supervisor City Person.AttributeValues['_State'] := ParseCityStateZip3(CityStZip, 2); //Supervisor State Person.AttributeValues['_PostalCode'] := ParseCityStateZip3(CityStZip, 3); //Supervisor Zip if FormCellsHaveText(AForm, [276,277]) then begin Contact := Person.AddElement('CONTACT_DETAIL'); Phone := AForm.GetCellTextByXID_MISMO(276); if length(phone)> 0 then Contact.AddElement('CONTACT_POINT', ['_Type', 'Phone', '_Value', Phone]); email := AForm.GetCellTextByXID_MISMO(277); if length(email)>0 then Contact.AddElement('CONTACT_POINT', ['_Type', 'Email', '_Value', email]); end; (* <FIELD ID="5018" XPath="//VALUATION_RESPONSE/PARTIES/SUPERVISOR/APPRAISER_LICENSE/@_Identifier"/> <FIELD ID="2099" XPath="//VALUATION_RESPONSE/PARTIES/SUPERVISOR/APPRAISER_LICENSE/@_State"/> <FIELD ID="28" XPath="//VALUATION_RESPONSE/PARTIES/SUPERVISOR/APPRAISER_LICENSE/@_ExpirationDate"/> <FIELD ID="29" XPath="//VALUATION_RESPONSE/PARTIES/SUPERVISOR/APPRAISER_LICENSE[@_Type=&dq;Certificate&dq;]/@_Identifier"/> <FIELD ID="30" XPath="//VALUATION_RESPONSE/PARTIES/SUPERVISOR/APPRAISER_LICENSE/.[@_Type=&dq;Certificate&dq;]/@_State"/> <FIELD ID="32" XPath="//VALUATION_RESPONSE/PARTIES/SUPERVISOR/APPRAISER_LICENSE[@_Type=&dq;License&dq;]/@_Identifier"/> <FIELD ID="33" XPath="//VALUATION_RESPONSE/PARTIES/SUPERVISOR/APPRAISER_LICENSE/.[@_Type=&dq;License&dq;]/@_State"/> *) //Supervisor License Configurations License := nil; if FormCellsHaveText(AForm, [32,33]) then //has License Identifier begin ExpireDateExists := (Trim(AForm.GetCellText(1,270)) <> ''); if (AForm.FormID = 794) and ExpireDateExists then Person.AddElement('APPRAISER_LICENSE'); License := Person.AddElement('APPRAISER_LICENSE', ['_Type', 'License']); License.AttributeValues['_Identifier'] := AForm.GetCellTextByXID_MISMO(32); License.AttributeValues['_State'] := AForm.GetCellTextByXID_MISMO(33); if not (length(AForm.GetCellTextByXID_MISMO(33))>0) then License.AttributeValues['_State'] := AForm.GetCellTextByXID_MISMO(2099); if (AForm.FormID = 794) and ExpireDateExists then License := License.ParentElement; License.AttributeValues['_ExpirationDate'] := MISMODate(ADoc, AForm.GetCellByXID_MISMO(28), ErrList); end; if FormCellsHaveText(AForm, [29,30]) then //has Certificate Identifier begin ExpireDateExists := (Trim(AForm.GetCellText(1,270)) <> ''); if (AForm.FormID = 794) and (not FormCellsHaveText(AForm, [32,33])) and ExpireDateExists then Person.AddElement('APPRAISER_LICENSE'); License := Person.AddElement('APPRAISER_LICENSE', ['_Type', 'Certificate']); License.AttributeValues['_Identifier'] := AForm.GetCellTextByXID_MISMO(29); License.AttributeValues['_State'] := AForm.GetCellTextByXID_MISMO(30); if not (length(AForm.GetCellTextByXID_MISMO(30))>0) then License.AttributeValues['_State'] := AForm.GetCellTextByXID_MISMO(2099); if (AForm.FormID = 794) and ExpireDateExists then License := License.ParentElement; License.AttributeValues['_ExpirationDate'] := MISMODate(ADoc, AForm.GetCellByXID_MISMO(28), ErrList); end; if FormCellsHaveText(AForm, [5018]) then //has unknown Identifier begin License := Person.AddElement('APPRAISER_LICENSE', ['_Type', 'Other']); License.AttributeValues['_TypeOtherDescription'] := AForm.GetCellTextByXID_MISMO(5018); License.AttributeValues['_State'] := AForm.GetCellTextByXID_MISMO(2099); License.AttributeValues['_ExpirationDate'] := MISMODate(ADoc, AForm.GetCellByXID_MISMO(28), ErrList); end; if not assigned(License) and FormCellsHaveText(AForm, [2099,28]) then //only entered exp or date begin License := Person.AddElement('APPRAISER_LICENSE'); License.AttributeValues['_State'] := AForm.GetCellTextByXID_MISMO(2099); License.AttributeValues['_ExpirationDate'] := MISMODate(ADoc, AForm.GetCellByXID_MISMO(28), ErrList); end; (* <FIELD ID="1152" XPath="//VALUATION_RESPONSE/PARTIES/SUPERVISOR/INSPECTION[@AppraisalInspectionPropertyType=&dq;Subject&dq;]/.[@AppraisalInspectionType=&dq;None&dq;]"/> <FIELD ID="1153" XPath="//VALUATION_RESPONSE/PARTIES/SUPERVISOR/INSPECTION[@AppraisalInspectionPropertyType=&dq;Subject&dq;]/.[@AppraisalInspectionType=&dq;ExteriorOnly&dq;]"/> <FIELD ID="1154" XPath="//VALUATION_RESPONSE/PARTIES/SUPERVISOR/INSPECTION[@AppraisalInspectionPropertyType=&dq;Subject&dq;]/.[@AppraisalInspectionType=&dq;ExteriorAndInterior&dq;]"/> <FIELD ID="2008" XPath="//VALUATION_RESPONSE/PARTIES/SUPERVISOR/INSPECTION[@AppraisalInspectionPropertyType=&dq;Subject&dq;]/@InspectionDate"/> <FIELD ID="1155" XPath="//VALUATION_RESPONSE/PARTIES/SUPERVISOR/INSPECTION[@AppraisalInspectionPropertyType=&dq;Comparable&dq;]/.[@AppraisalInspectionType=&dq;None&dq;]"/> <FIELD ID="1156" XPath="//VALUATION_RESPONSE/PARTIES/SUPERVISOR/INSPECTION[@AppraisalInspectionPropertyType=&dq;Comparable&dq;]/.[@AppraisalInspectionType=&dq;ExteriorOnly&dq;]"/> <FIELD ID="2100" XPath="//VALUATION_RESPONSE/PARTIES/SUPERVISOR/INSPECTION[@AppraisalInspectionPropertyType=&dq;Comparable&dq;]/@InspectionDate"/> NOT USED <FIELD ID="1665" XPath="//VALUATION_RESPONSE/PARTIES/SUPERVISOR/INSPECTION/@InspectionDate"/> *) //Supervisor's Date and Type of Subject Inspection if FormCellsHaveText(AForm, [1152,1153,1154,2008]) then begin Inspection := Person.AddElement('INSPECTION', ['AppraisalInspectionPropertyType', 'Subject']); if CompareText(AForm.GetCellTextByXID_MISMO(1152), 'X')=0 then Inspection.AttributeValues['AppraisalInspectionType'] := 'None'; InspDateSet := False; if CompareText(AForm.GetCellTextByXID_MISMO(1153), 'X')=0 then begin InspDateSet := True; Inspection.AttributeValues['AppraisalInspectionType'] := 'ExteriorOnly'; // Retrieve the first date with cell XID = 2008 if length(AForm.GetCellTextByXID_MISMO(2008))> 0 then Inspection.AttributeValues['InspectionDate'] := MISMODate(ADoc, AForm.GetCellByXID_MISMO(2008), ErrList); end; // If the exterior/interior box is checked we need to retrieve the date from the // following cell so it overrides the prior XID 2008 value (ex. Form ID 341). if CompareText(AForm.GetCellTextByXID_MISMO(1154), 'X')=0 then begin InspDateSet := True; Inspection.AttributeValues['AppraisalInspectionType'] := 'ExteriorAndInterior'; ChkBoxUID := AForm.GetCellByXID_MISMO(1154).UID; InspDateCell := AForm.GetCell(Succ(ChkBoxUID.Pg), (ChkBoxUID.Num + 2)); if length(InspDateCell.Text) > 0 then Inspection.AttributeValues['InspectionDate'] := MISMODate(ADoc, InspDateCell, ErrList); end; // If neither the exterior-only or the exterior/interior boxes is checked // we need to retrieve the date from the XID 2008 cell (ex. Form ID 29). if (not InspDateSet) and (length(AForm.GetCellTextByXID_MISMO(2008))> 0) then Inspection.AttributeValues['InspectionDate'] := MISMODate(ADoc, AForm.GetCellByXID_MISMO(2008), ErrList); end; //Supervisor's Date and Type of Comparable Inspection if FormCellsHaveText(AForm, [1155,1156,2100]) then begin Inspection := Person.AddElement('INSPECTION', ['AppraisalInspectionPropertyType', 'Comparable']); if CompareText(AForm.GetCellTextByXID_MISMO(1155), 'X')=0 then Inspection.AttributeValues['AppraisalInspectionType'] := 'None'; if CompareText(AForm.GetCellTextByXID_MISMO(1156), 'X')=0 then Inspection.AttributeValues['AppraisalInspectionType'] := 'ExteriorOnly'; if length(AForm.GetCellTextByXID_MISMO(2100))> 0 then Inspection.AttributeValues['InspectionDate'] := MISMODate(ADoc, AForm.GetCellByXID_MISMO(2100), ErrList); end; //Supervisor's Signature and Date hasSignature := (ADoc.docSignatures.SignatureIndexOf('Supervisor') > -1); if hasSignature or (length(AForm.GetCellTextByXID_MISMO(6))>0) then //is there a signature date begin Signature := Person.AddElement('SIGNATURE'); Signature.AttributeValues['_Date'] := MISMODate(ADoc, AForm.GetCellByXID_MISMO(6), ErrList); Signature.AttributeValues['_AffixedIndicator'] := MISMOBoolean(hasSignature); end; end; {--REVIEWER ---------------------------------------------} //Exported Review Appraiser CellIDs //1402, 1403,1666,1499,1504,1505,1506,1728,1507,1508,1509 //1510,1511,1512,1513,1514,1517,1518,1520,1521 //1522,1523,1524,1658,1730 //Is the reviewer's name on this form if Length(AForm.GetCellTextByXID_MISMO(1402))>0 then begin Person := Signer.AddElement('REVIEW_APPRAISER'); Person.AttributeValues['_Name'] := AForm.GetCellTextByXID_MISMO(1402); Person.AttributeValues['_CompanyName'] := AForm.GetCellTextByXID_MISMO(1403); Person.AttributeValues['_StreetAddress'] := AForm.GetCellTextByXID_MISMO(1666); CityStZip := AForm.GetCellTextByXID_MISMO(1499); //Reviewer City, St, Zip Person.AttributeValues['_StreetAddress2'] := CityStZip; Person.AttributeValues['_City'] := ParseCityStateZip3(CityStZip, 1); //Reviewer City Person.AttributeValues['_State'] := ParseCityStateZip3(CityStZip, 2); //Reviewer State Person.AttributeValues['_PostalCode'] := ParseCityStateZip3(CityStZip, 3); //Reviewer Zip Person.AttributeValues['AppraisalFormsUnparsedAddress'] := AForm.GetCellTextByXID_MISMO(1730); if FormCellsHaveText(AForm, [1507,1508,1509]) then begin Contact := Person.AddElement('CONTACT_DETAIL'); Phone := AForm.GetCellTextByXID_MISMO(1507); if length(phone)> 0 then Contact.AddElement('CONTACT_POINT', ['_Type', 'Phone', '_Value', Phone]); fax := AForm.GetCellTextByXID_MISMO(1508); if length(fax)>0 then Contact.AddElement('CONTACT_POINT', ['_Type', 'Fax', '_Value', Fax]); email := AForm.GetCellTextByXID_MISMO(1509); if length(email)>0 then Contact.AddElement('CONTACT_POINT', ['_Type', 'Email', '_Value', email]); end; (* <FIELD ID="1510" XPath="//VALUATION_RESPONSE/PARTIES/REVIEW_APPRAISER/APPRAISER_LICENSE/@_ExpirationDate"/> <FIELD ID="1511" XPath="//VALUATION_RESPONSE/PARTIES/REVIEW_APPRAISER/APPRAISER_LICENSE[@_Type=&dq;License&dq;]/@_Identifier"/> <FIELD ID="1512" XPath="//VALUATION_RESPONSE/PARTIES/REVIEW_APPRAISER/APPRAISER_LICENSE/.[@_Type=&dq;License&dq;]/@_State"/> <FIELD ID="1513" XPath="//VALUATION_RESPONSE/PARTIES/REVIEW_APPRAISER/APPRAISER_LICENSE[@_Type=&dq;Certificate&dq;]/@_Identifier"/> <FIELD ID="1514" XPath="//VALUATION_RESPONSE/PARTIES/REVIEW_APPRAISER/APPRAISER_LICENSE/.[@_Type=&dq;Certificate&dq;]/@_State"/> <FIELD ID="1517" XPath="//VALUATION_RESPONSE/PARTIES/REVIEW_APPRAISER/APPRAISER_LICENSE/@_Identifier"/> <FIELD ID="1518" XPath="//VALUATION_RESPONSE/PARTIES/REVIEW_APPRAISER/APPRAISER_LICENSE/@_State"/> <FIELD ID="1520" XPath="//VALUATION_RESPONSE/PARTIES/REVIEW_APPRAISER/APPRAISER_LICENSE[@_Type=&dq;Other&dq;]/@_Identifier"/> <FIELD ID="1521" XPath="//VALUATION_RESPONSE/PARTIES/REVIEW_APPRAISER/APPRAISER_LICENSE[@_Type=&dq;Other&dq;]/@_TypeOtherDescription"/> *) //Reviewer's License Configurations License := nil; if FormCellsHaveText(AForm, [1511,1512]) then //has License Identifier begin License := Person.AddElement('APPRAISER_LICENSE', ['_Type', 'License']); License.AttributeValues['_Identifier'] := AForm.GetCellTextByXID_MISMO(1511); License.AttributeValues['_State'] := AForm.GetCellTextByXID_MISMO(1512); License.AttributeValues['_ExpirationDate'] := MISMODate(ADoc, AForm.GetCellByXID_MISMO(1510), ErrList); end; if FormCellsHaveText(AForm, [1513,1514]) then //has Certificate Identifier begin License := Person.AddElement('APPRAISER_LICENSE', ['_Type', 'Certificate']); License.AttributeValues['_Identifier'] := AForm.GetCellTextByXID_MISMO(1513); License.AttributeValues['_State'] := AForm.GetCellTextByXID_MISMO(1514); License.AttributeValues['_ExpirationDate'] := MISMODate(ADoc, AForm.GetCellByXID_MISMO(1510), ErrList); end; if FormCellsHaveText(AForm, [1520,1521]) then //has Other Identifier begin License := Person.AddElement('APPRAISER_LICENSE', ['_Type', 'Other']); License.AttributeValues['_Identifier'] := AForm.GetCellTextByXID_MISMO(1520); License.AttributeValues['_TypeOtherDescription'] := AForm.GetCellTextByXID_MISMO(1521); License.AttributeValues['_State'] := AForm.GetCellTextByXID_MISMO(1518); License.AttributeValues['_ExpirationDate'] := MISMODate(ADoc, AForm.GetCellByXID_MISMO(1510), ErrList); end; if FormCellsHaveText(AForm, [1517]) then //has unknown Identifier begin License := Person.AddElement('APPRAISER_LICENSE'); License.AttributeValues['_Identifier'] := AForm.GetCellTextByXID_MISMO(1517); License.AttributeValues['_State'] := AForm.GetCellTextByXID_MISMO(1518); License.AttributeValues['_ExpirationDate'] := MISMODate(ADoc, AForm.GetCellByXID_MISMO(1510), ErrList); end; if not assigned(License) and FormCellsHaveText(AForm, [1518,1510]) then //only entered exp and state begin License := Person.AddElement('APPRAISER_LICENSE'); License.AttributeValues['_State'] := AForm.GetCellTextByXID_MISMO(1518); License.AttributeValues['_ExpirationDate'] := MISMODate(ADoc, AForm.GetCellByXID_MISMO(1510), ErrList); end; (* <FIELD ID="1522" XPath="//VALUATION_RESPONSE/PARTIES/REVIEW_APPRAISER/INSPECTION[@AppraisalInspectionPropertyType=&dq;Subject&dq;]/.[@AppraisalInspectionType=&dq;None&dq;]"/> <FIELD ID="1523" XPath="//VALUATION_RESPONSE/PARTIES/REVIEW_APPRAISER/INSPECTION[@AppraisalInspectionPropertyType=&dq;Subject&dq;]/.[@AppraisalInspectionType=&dq;ExteriorOnly&dq;]"/> <FIELD ID="1524" XPath="//VALUATION_RESPONSE/PARTIES/REVIEW_APPRAISER/INSPECTION[@AppraisalInspectionPropertyType=&dq;Subject&dq;]/.[@AppraisalInspectionType=&dq;ExteriorAndInterior&dq;]"/> <FIELD ID="1658" XPath="//VALUATION_RESPONSE/PARTIES/REVIEW_APPRAISER/INSPECTION/@InspectionDate"/> *) //Reviewer's Date and Type of Inspection if FormCellsHaveText(AForm, [1522,1523,1524,1658]) then begin Inspection := Person.AddElement('INSPECTION', ['AppraisalInspectionPropertyType', 'Subject']); if CompareText(AForm.GetCellTextByXID_MISMO(1522), 'X')=0 then Inspection.AttributeValues['AppraisalInspectionType'] := 'None'; if CompareText(AForm.GetCellTextByXID_MISMO(1523), 'X')=0 then Inspection.AttributeValues['AppraisalInspectionType'] := 'ExteriorOnly'; if CompareText(AForm.GetCellTextByXID_MISMO(1524), 'X')=0 then Inspection.AttributeValues['AppraisalInspectionType'] := 'ExteriorAndInterior'; if length(AForm.GetCellTextByXID_MISMO(1658))> 0 then Inspection.AttributeValues['InspectionDate'] := MISMODate(ADoc, AForm.GetCellByXID_MISMO(1658), ErrList); end; //Reviewer's Signature and Date hasSignature := (ADoc.docSignatures.SignatureIndexOf('Reviewer') > -1); if hasSignature or (length(AForm.GetCellTextByXID_MISMO(1728))>0) then //is there a signature date begin Signature := Person.AddElement('SIGNATURE'); Signature.AttributeValues['_Date'] := MISMODate(ADoc, AForm.GetCellByXID_MISMO(1728), ErrList); Signature.AttributeValues['_AffixedIndicator'] := MISMOBoolean(hasSignature); end; end; end; procedure ExportFormImages(ADoc: TContainer; AForm: TDocForm; AElement: TXMLElement; ErrList: TObjectList); // Version 7.2.7 JWyatt Revise to output the 1st and/or 2nd text lines associated with // a given photo cell. The routine uses association files (ex. A000301.txt) to determine // the text cell locations, by sequence number, and then concatenate the lines into the // _CaptionComment XML element. const cFormAssocFolder= 'Converters\FormAssociations\'; //where form photo association maps are kept var PageCounter, CellCounter, PhotoCounter : Integer; ThisPage: TDocPage; ThisCell: TBaseCell; formName, otherDesc: String; imgID, imgName, imgCaption: String; FormAssocFile: TMemIniFile; AssocFilePath, FormSection, FormIdent: String; AssocFileExists: Boolean; Cmnt1Text, Cmnt2Text: String; Cmnt1AdjStr, Cmnt2AdjStr: String; Cmnt1AdjVal, Cmnt2AdjVal, ErrCode: Integer; function ConcatCmnts(C1, C2: String): String; begin if Trim(C1) <> '' then result := Trim(C1) + '/' + Trim(C2) else result := Trim(C2); end; begin FormAssocFile := nil; try AssocFilePath := IncludeTrailingPathDelimiter(appPref_DirTools) + cFormAssocFolder + 'A' + Format('%6.6d', [AForm.FormID]) + '.txt'; AssocFileExists := FileExists(AssocFilePath); if AssocFileExists then FormAssocFile := TMemIniFile.Create(AssocFilePath); for PageCounter := 0 to AForm.frmPage.Count - 1 do //for each page begin PhotoCounter := 1; ThisPage := AForm.frmPage[PageCounter]; if (ThisPage.pgData <> nil) then //make sure page has data cells begin FormSection := 'Pg' + IntToStr(Succ(PageCounter)); for CellCounter := 0 to ThisPage.pgData.Count - 1 do begin ThisCell := ThisPage.pgData[CellCounter]; if (ThisCell is TGraphicCell) then begin Cmnt1Text := ''; Cmnt2Text := ''; if Assigned(FormAssocFile) then begin FormIdent := 'Assoc' + IntToStr(PhotoCounter); Cmnt1AdjStr := FormAssocFile.ReadString(FormSection, FormIdent + 'ID1', ''); Val(Cmnt1AdjStr, Cmnt1AdjVal, ErrCode); if ErrCode <> 0 then Cmnt1Text := Cmnt1AdjStr else if Cmnt1AdjVal <> 0 then Cmnt1Text := ThisPage.pgData[CellCounter+Cmnt1AdjVal].GetText; Cmnt2AdjStr := FormAssocFile.ReadString(FormSection, FormIdent + 'ID2', ''); Val(Cmnt2AdjStr, Cmnt2AdjVal, ErrCode); if ErrCode <> 0 then Cmnt2Text := Cmnt2AdjStr else if Cmnt2AdjVal <> 0 then Cmnt2Text := ThisPage.pgData[CellCounter+Cmnt2AdjVal].GetText; end; formName := GetReportFormType(AForm, otherDesc); imgID := GetImageIdentifier(ThisCell.FCellXID, PhotoCounter, formName); if TGraphicCell(ThisCell).HasImage then imgName := 'HasImage' else imgName := 'NoImage'; imgCaption := ConcatCmnts(Cmnt1Text, Cmnt2Text); with AElement.AddElement('IMAGE') do begin AttributeValues['_Identifier'] := imgID; AttributeValues['_Name'] := imgName; AttributeValues['_CaptionComment'] := imgCaption; end; Inc(PhotoCounter); end; end; end; end; finally FormAssocFile.Free; end; end; procedure ExportFormAddendumText(AForm: TDocForm; AElement: TXMLElement); var Comment: TXMLElement; begin if length(AForm.GetCellTextByXID_MISMO(1218))>0 then //there are generic additional comments begin Comment := AElement.AddElement('COMMENT', ['AppraisalAddendumTextIdentifier', 'Additional']); Comment.AttributeValues['AppraisalAddendumText'] := AForm.GetCellTextByXID_MISMO(1218); end; if length(AForm.GetCellTextByXID_MISMO(1293))>0 then //there are report validation comments begin Comment := AElement.AddElement('COMMENT', ['AppraisalAddendumTextIdentifier', 'Additional']); Comment.AttributeValues['AppraisalAddendumText'] := AForm.GetCellTextByXID_MISMO(1293); end; if length(AForm.GetCellTextByXID_MISMO(2729))>0 then //there are additional sales history comments begin Comment := AElement.AddElement('COMMENT', ['AppraisalAddendumTextIdentifier', 'History']); Comment.AttributeValues['AppraisalAddendumText'] := AForm.GetCellTextByXID_MISMO(2729); end; if length(AForm.GetCellTextByXID_MISMO(1676))>0 then //there are additional rental comments begin Comment := AElement.AddElement('COMMENT', ['AppraisalAddendumTextIdentifier', 'Rental']); Comment.AttributeValues['AppraisalAddendumText'] := AForm.GetCellTextByXID_MISMO(1676); end; (* if length(AForm.GetCellTextByXID_MISMO(1676))>0 then //there are additional rental comments begin Comment := AElement.AddElement('COMMENT', ['AppraisalAddendumTextIdentifier', 'ComparableTimeAdjustment']); Comment.AttributeValues['AppraisalAddendumText'] := AForm.GetCellTextByXID_MISMO(1676); end; *) end; // 052611 JWyatt Add the following procedure to export comments from addendums // when the version is 2.6 or 2.6GSE. This is similar to the procedure above // except the AppraisalAddendumText is not part of element COMMENT procedure ExportFormAddendumText_2_6(AForm: TDocForm; AElement: TXMLElement); begin if length(AForm.GetCellTextByXID_MISMO(1218))>0 then //there are generic additional comments AElement.AttributeValues['AppraisalAddendumText'] := AForm.GetCellTextByXID_MISMO(1218); if length(AForm.GetCellTextByXID_MISMO(1293))>0 then //there are report validation comments AElement.AttributeValues['AppraisalAddendumText'] := AForm.GetCellTextByXID_MISMO(1293); if length(AForm.GetCellTextByXID_MISMO(2729))>0 then //there are additional sales history comments AElement.AttributeValues['AppraisalAddendumText'] := AForm.GetCellTextByXID_MISMO(2729); if length(AForm.GetCellTextByXID_MISMO(1676))>0 then //there are additional rental comments AElement.AttributeValues['AppraisalAddendumText'] := AForm.GetCellTextByXID_MISMO(1676); end; procedure ExportReportFormList(doc: TContainer; ATranslator: TMISMOTranslator; ExportList: BooleanArray; ErrList: TObjectList; var Frm1004MCSeqID: Integer; IsVer2_6: Boolean; Info: TMiscInfo); var f,SeqNo, formUID, PriFormCntr, PriFormUID: Integer; ThisForm: TDocForm; FormType, OtherDesc, FormXPath: String; FormIdentifier: String; IsPrimary, IsPriUCDPForm, PDFIsEmbedded, SetMISMOType: Boolean; SetAppraisalFormType: Boolean; ThisElement: TXMLElement; FormTypeCounter: TStringList; // The following variable is added to capture the type in case it needs // to be adjusted for UAD compliant reports. MISMOType, MISMOTypeVersionID: String; FormName: String; //is this form on the list to be exported? function ExportThisForm(n: Integer; ExpFormList: BooleanArray): Boolean; begin if not assigned(ExpFormList) then result := True else result := ExpFormList[n]; end; begin //setup the generic form counter FormTypeCounter := TStringList.create; FormTypeCounter.Duplicates := dupIgnore; Frm1004MCSeqID := -1; SetAppraisalFormType := False; try // The following sequence looks for a generic primary form ID and checks // to see if we have a UCDP primary form. If the latter then this is the // form we will use as the primary instead of the generic. IsPriUCDPForm := False; PriFormUID := 0; PriFormCntr := -1; repeat PriFormCntr := Succ(PriFormCntr); if ExportThisForm(PriFormCntr, ExportList) then //form can be unselected begin ThisForm := doc.docForm[PriFormCntr]; formUID := ThisForm.frmInfo.fFormUID; if IsPrimaryAppraisalForm(formUID) then PriFormUID := formUID; if IsVer2_6 then if Is2_6PrimaryAppraisalForm(formUID) then begin PriFormUID := formUID; IsPriUCDPForm := True; end; end; until IsPriUCDPForm or (PriFormCntr = (doc.docForm.count - 1)); SeqNo := 1; IsPrimary := False; PDFIsEmbedded := False; if assigned(doc) then if ATranslator.FindMapping(FORM_ID, FormXPath) then //gets XPath for REPORT/FORM for f := 0 to doc.docForm.count-1 do if ExportThisForm(f, ExportList) then begin ThisForm := doc.docForm[f]; formUID := ThisForm.frmInfo.fFormUID; ThisElement := ATranslator.XML.AddElement(FormXPath); //REPORT/FORM ThisElement.AttributeValues['AppraisalReportContentSequenceIdentifier'] := IntToStr(SeqNo); //classify the form if IsVer2_6 then FormType := Get2_6ReportFormType(ThisForm, OtherDesc) else FormType := GetReportFormType(ThisForm, OtherDesc); ThisElement.AttributeValues['AppraisalReportContentType'] := FormType; if FormType = 'Other' then ThisElement.AttributeValues['AppraisalReportContentTypeOtherDescription'] := OtherDesc; FormName := GetReportFormName(ThisForm); //playing with fire here. The formID should set the MISMO name - not Sheri! //FreddieMac requested specific AppraisalReportContentName what is not suit for form name displaying in UI if ThisForm.frmInfo.fFormUID = 4365 then //FMAC H70 form formName := 'PropertyDataCollectionPlusDesktopReview'; ThisElement.AttributeValues['AppraisalReportContentName'] := FormName; if FormName = 'FNMA 1004MC' then Frm1004MCSeqID := SeqNo; { move it to main forms handling //change this to a call to pull back the right enumerated name if pos('1004P', trim(FormName)) > 0 then //PAM: force 1004P to use 1004 mismo type FormName:= StringReplace(FormName, '1004P', '1004', [rfReplaceAll]); //to handle main form and cert form } MISMOType := FormName; if IsVer2_6 and not SetAppraisalFormType then begin SetMISMOType := False; case FormUID of 3: begin MISMOType:= 'FNM1004B'; SetMISMOType := True; end; 9: begin MISMOType:= 'VacantLand'; SetMISMOType := True; end; 11,279: begin MISMOType:= 'MobileHome'; SetMISMOType := True; end; 39,41,340,342,344,345,347,349,351,353,355,357,360, 4218, 4365: //4218 added 1004P, 4365 added 1004 2019 begin if (FormUID = 4218) or (FormUID = 4365) then // The forms 1004P and FMAC H70 still 1004 as MISMO report type MISMOType := 'FNM 1004'; MISMOType:= StringReplace(MISMOType, ' ', '', [rfReplaceAll]); //remove spaces MISMOType:= StringReplace(MISMOType, 'FNMA', 'FNM', [rfReplaceAll]); //abbreviate MISMOType:= StringReplace(MISMOType, 'Certification', '', [rfReplaceAll]);//remove Cert SetMISMOType := True; case FormUID of //need mismo type version to distinguish from regular 1004 4218: MISMOTypeVersionID := '2017'; 4365: MISMOTypeVersionID := '2019'; end; end; 43: begin MISMOType:= StringReplace(MISMOType, ' ', '', [rfReplaceAll]); MISMOType:= StringReplace(MISMOType, 'FMAC', 'FRE', [rfReplaceAll]); MISMOType:= StringReplace(MISMOType, 'Certification', '', [rfReplaceAll]); SetMISMOType := True; end; 87: begin MISMOType:= 'ERC2001'; SetMISMOType := True; end; 95: begin MISMOType:= 'ERC2003'; SetMISMOType := True; end; end; if SetMISMOType then begin ATranslator.ExportValue(10500, MISMOType); //attribute AppraisalFormType, see AppraisalMap2.6.xml SetAppraisalFormType := True; if length(MISMOTypeVersionID) > 0 then ATranslator.ExportValue(10501,MISMOTypeVersionID); //attribute AppraisalFormVersionIdentifier, see AppraisalMap2.6.xml end; end; //Set Industry Standard Identifier FormIdentifier := GetIndustryFormIdentifier(FormType, formUID, FormTypeCounter, doc.UADEnabled); ThisElement.AttributeValues['AppraisalReportContentIdentifier'] := FormIdentifier; //Set the IsPrimaryForm Indicator if not IsPrimary then //if primary has not been found... begin IsPrimary := (formUID = PriFormUID); if IsPrimary then ThisElement.AttributeValues['AppraisalReportContentIsPrimaryFormIndicator'] := 'Y' else ThisElement.AttributeValues['AppraisalReportContentIsPrimaryFormIndicator'] := 'N'; end else //primary has been located, all other forms are not primary ThisElement.AttributeValues['AppraisalReportContentIsPrimaryFormIndicator'] := 'N'; // This attribute is in case we have additional descriptive data - we do not {ThisElement.AttributeValues['AppraisalReportContentDescription'] := ThisForm.frmInfo.fFormKindName;} // 052611 JWyatt Add the call to export comments from addendums // when the version is 2.6 or 2.6GSE. if IsVer2_6 then begin // 060611 JWyatt If this is not the UAD comment form then // export text on the form. If it is the UAD comment form // then we don't export here, the comments are saved in the // DataPoints and exported along with other DataPoint values. if (not doc.UADEnabled) or (ThisForm.FormID <> CUADCommentAddendum) then ExportFormAddendumText_2_6(ThisForm, ThisElement); end else begin //Export "Additional" Comment Text on the Form ExportFormAddendumText(ThisForm, ThisElement); // If we're not processing a 2.6-compatible report then export // any signature, date, inspection, license cells for appraiser, // supervisor and/or reviewer ExportFormSigners(doc, ThisForm, ThisElement, ErrList); //"ThisElement" is the FORM element for ThisForm end; ExportFormImages(doc, ThisForm, ThisElement, ErrList); //Export IMAGE element if has image cell //Whis this called here? //Was it becuase at onetime the PDF was put into the form? //Its now in the Report - right, so this code can go away. if IsVer2_6 and (not doc.UADEnabled) and IsPrimary and (not PDFIsEmbedded) then begin ExportReportEmbededPDF(doc, ATranslator, Info, ThisElement); PDFIsEmbedded := True; end; inc(SeqNo); end; finally FormTypeCounter.Free; end; end; procedure ExportReportPartiesParsedAddess(doc: TContainer; exportForm: BooleanArray; ATranslator: TMISMOTranslator); begin //Lender ATranslator.ExportValue(37, doc.GetCellTextByXID_MISMO(37, exportForm)); //Lender Address ATranslator.ExportValue(38, doc.GetCellTextByXID_MISMO(38, exportForm)); //Lender City ATranslator.ExportValue(39, doc.GetCellTextByXID_MISMO(39, exportForm)); //Lender State ATranslator.ExportValue(40, doc.GetCellTextByXID_MISMO(40, exportForm)); //Lender Zip end; //this is special routine for extracting the Sales Concession Amt form the Sales Concession Comment text //Clickforms does not have a specific cell for the Amt, others do, so we have special extraction code to get it procedure ExportSalesContractConsessions(doc: TContainer; exportForm: BooleanArray; ATranslator: TMISMOTranslator; IsVer2_6: Boolean); var Counter: Integer; SalesComissionText: String; SalesComissionAmt: String; begin SalesComissionAmt := ''; SalesComissionText := doc.GetCellTextByXID_MISMO(2057, exportForm); //get description SalesComissionAmt := GetFirstNumInStr(SalesComissionText, False, Counter); //parse and get first value if (not IsVer2_6) and (Length(SalesComissionAmt) > 0) then //###JB - is this correct?? ATranslator.ExportValue(2642, SalesComissionAmt); end; procedure ExportMergedCells(doc: TContainer; CellMainXID: Integer; ExportList: BooleanArray; ATranslator: TMISMOTranslator; const ListXIDs: array of Integer); var FormNum, XIDCount, XIDNum: Integer; ConcatText: String; ThisForm: TDocForm; CellTxt: TBaseCell; //is this form on the list to be exported? function ExportThisForm(n: Integer; ExpFormList: BooleanArray): Boolean; begin if not assigned(ExpFormList) then result := True else result := ExpFormList[n]; end; begin ConcatText := ''; XIDCount := Length(ListXIDs); if assigned(doc) and (XIDCount > 0) then for FormNum := 0 to doc.docForm.count-1 do if ExportThisForm(FormNum, ExportList) then begin ThisForm := doc.docForm[FormNum]; for XIDNum := 0 to Pred(XIDCount) do begin CellTxt := ThisForm.GetCellByXID_MISMO(ListXIDs[XIDNum]); if CellTxt <> nil then begin if Trim(CellTxt.Text) <> '' then if CellTxt.FCellXID = CellMainXID then ConcatText := Trim(CellTxt.Text) + ConcatText else ConcatText := ConcatText + ' ' + Trim(CellTxt.Text); end end; end; if Trim(ConcatText) <> '' then ATranslator.ExportValue(CellMainXID, ConcatText); //Lender Address end; procedure ExportTableCells(AContainer: TContainer; ATableType: Integer; ErrList: TObjectList; ATranslator: TMISMOTranslator; IsUAD: Boolean; IsVer2_6: Boolean; var ListCompOffset: Integer; NonUADXMLData: Boolean; LocType: Integer=0); // Version 7.2.8 083110 JWyatt The FormAssocFile and related variables and code are included // to address unique XML addresses assigned to form ID 794. This was discussed in a meeting // today and it was agreed that this code should be revised to use only XML IDs in a future // release. const cFormAssocFolder = 'Converters\FormAssociations\'; //where form photo association maps are kept MaxAdjID = 7; MaxRentID = 4; StdAdjID: array[1..MaxAdjID] of Integer = (947,954,1052,1053,1054,1682,1683); RentalAdjID: array[1..MaxAdjID] of Integer = (1299,1259,1256,1257,1258,1264,1265); RentalBathID: array[1..MaxRentID] of Integer = (2258,2259,2260,2261); RentalGLAID: array[1..MaxRentID] of Integer = (2262,2263,2264,2265); var SubColumnCounter, RowCounter, ColCounter, ColIdx, Cntr : Integer; ThisGridManager : TGridMgr; ThisCell: TBaseCell; ThisCellNo, OrigCellXID : Integer; ThisCellText : string; ThisColumn : TCompColumn; Err: TComplianceError; NetAdjValue: Double; NetPct, GrossPct: String; AdjIDs: array[1..7] of Integer; AdjIDCount, FormIDHldr, TmpAdjID: Integer; FormAssocFile: TMemIniFile; AssocFilePath, FormSection: String; ListAsSale: Boolean; MapCellLocaterEvent: TMapCellLocaterEvent; CompIsExported: Boolean; RentBathQty, RentGLA: Double; ThisForm: TdocForm; AltCell: TBaseCell; AltUID: CellUID; AltPg, AltCellXID: Integer; function ConcatNextCell(CurCell, NextCell: TBaseCell): String; begin if NextCell = nil then Result := CurCell.Text else if Trim(CurCell.Text) = '' then Result := NextCell.Text else Result := Trim(CurCell.Text) + ' ' + Trim(NextCell.Text); end; begin ListAsSale := False; FormIDHldr := 0; ThisGridManager := TGridMgr.Create; try // Set the std adjustment cell IDs in case the SalesAdjMap.txt file does not exist for AdjIDCount := 1 to MaxAdjID do if ATableType = ttRentals then AdjIDs[AdjIDCount] := RentalAdjID[AdjIDCount] else AdjIDs[AdjIDCount] := StdAdjID[AdjIDCount]; ThisGridManager.BuildGrid(AContainer, ATableType); for ColCounter := 0 to ThisGridManager.Count - 1 do // ThisGridManager is a TObjectList of TCompColumns begin ThisColumn := ThisGridManager.Comp[ColCounter]; if assigned(ThisColumn) then begin // The following code checks the current form ID, checks for the // sales adjustment map file and resets the adjustment IDs if // necessary. Currently, only the 794 and 834 forms require // special adjustments (see 8/31/10 note above). if (FormIDHldr = 0) or (FormIDHldr <> ThisColumn.FCX.FormID) then begin FormIDHldr := ThisColumn.FCX.FormID; FormAssocFile := nil; ListAsSale := False; try AssocFilePath := IncludeTrailingPathDelimiter(appPref_DirTools) + cFormAssocFolder + 'SalesAdjMap.txt'; if FileExists(AssocFilePath) then begin FormAssocFile := TMemIniFile.Create(AssocFilePath); FormSection := 'Form' + Format('%6.6d', [ThisColumn.FCX.FormID]); for AdjIDCount := 1 to MaxAdjID do begin TmpAdjID := FormAssocFile.ReadInteger(FormSection, 'ID' + IntToStr(AdjIDCount), 0); if TmpAdjID > 0 then AdjIDs[AdjIDCount] := TmpAdjID; end; ListAsSale := FormAssocFile.ReadBool(FormSection, 'ListAsSale', False); end; finally FormAssocFile.Free; end; end; if ListAsSale and (ColCounter <> 0) then ColIdx := ColCounter + ListCompOffset else ColIdx := ColCounter; CompIsExported := False; for RowCounter := 0 to ThisColumn.RowCount - 1 do begin for SubColumnCounter := 0 to 1 do begin ThisCellText := ''; ThisCellNo := ThisColumn.GetCellNumber(Point(SubColumnCounter,RowCounter)); ThisCell := ThisColumn.GetCellByCoord(Point(SubColumnCounter,RowCounter)); if Assigned(ThisCell) then try OrigCellXID := ThisCell.FCellXID; if IsVer2_6 then case ThisCell.FCellXID of // Following cell XID have no corresponding path in the // 2.6 schema so are skipped for now. 937..939, 1302, 1400, 1401, 1670, 1671: Continue; // Special mapping for non-UAD 'Other' subject adjustment descriptions // to match schema and Appendix B specification 1020: if (not IsUAD) and (ColCounter = 0) and (ATableType = ttSales) then ThisCell.FCellXID := 4077; 1022: if (not IsUAD) and (ColCounter = 0) and (ATableType = ttSales) then ThisCell.FCellXID := 4079; 1032: if (not IsUAD) and (ColCounter = 0) and (ATableType = ttSales) then ThisCell.FCellXID := 4081; // concatenate with next cell (XID 1302 - Form 29) 1303: begin ThisCellText := ThisCell.Text; ThisCell.Text := ConcatNextCell(ThisCell, ThisColumn.GetCellByCoord(Point(SubColumnCounter,Succ(RowCounter)))); end; //Handle hidden cells with prior sales grid on a different page (1025, 1073, etc.). // It is possible for the visible data to be different than the hidden data. We need // to make sure we export the visible data - otherwise the XML & PDF will not match. 934, 935, 936, 2074: begin if (ColCounter < 4) and (ThisCell.FLocalCTxID > 0) then begin case ThisCell.FCellXID of 934: AltCellXID := 9001; 935: AltCellXID := 9002; 936: AltCellXID := 9003; 2074: AltCellXID := 9004; end; ThisForm := AContainer.docForm[ThisCell.UID.Form]; for AltPg := 0 to Pred(ThisForm.frmPage.Count) do begin AltCell := ThisForm.frmPage[AltPg].GetCellByXID(AltCellXID); if AltCell <> nil then begin AltUID := AltCell.UID; AltUID.Num := AltUID.Num + (ColCounter * 4); AltCell := ThisForm.GetCell(Succ(AltUID.Pg), Succ(AltUID.Num)); if AltCell = nil then Continue else ThisCell.Text := AltCell.Text; end; end; end; end; end; case LocType of 1: MapCellLocaterEvent := MapXPathLocater; 2: MapCellLocaterEvent := MapEmbeddedLocater; else MapCellLocaterEvent := nil; end; if IsUAD then begin if not CompIsExported then CompIsExported := (Trim(ThisCell.Text) <> ''); ExportGSEData(ThisCell, ATranslator, nil, MapCellLocaterEvent, ColIdx); ExportCell(False, ThisCell, ATranslator, MapCellLocaterEvent, ColIdx); end else if (ThisCell.FCellXID > 0) then begin if not CompIsExported then CompIsExported := (Trim(ThisCell.Text) <> ''); ExportCell(IsUAD, ThisCell, ATranslator, MapCellLocaterEvent, ColIdx); end; // restore any original text contents due to concatenating if ThisCellText <> '' then ThisCell.Text := ThisCellText; ThisCell.FCellXID := OrigCellXID; except on E: Exception do begin if assigned(ErrList) then begin Err := TComplianceError.Create; Err.FCX.FormID := 0; //don't search by FormID Err.FCX.Form := ThisColumn.CellCX.Form; //search by form index Err.FCX.Occur := 0; //don't search by occurance Err.FCX.Pg := ThisColumn.CellCX.Pg; //search by page Err.FCX.Num := ThisCellNo - 1; //search by cell sequence (zero based) Err.FMsg := E.Message; ErrList.Add(Err); end; ThisCell.FCellXID := OrigCellXID; end; end; end; end; //For tables get the last items in the column; only do the comps, not subject column. if ((ATableType = ttSales) or (ATableType = ttRentals) or ((ATableType = ttListings) and ListAsSale) or ((ATableType = ttListings) and (ThisColumn.FCX.FormID = 794))) and (ColCounter > 0) and CompIsExported then begin if ThisColumn.HasAdjSalesPriceCell and ThisColumn.HasNetAdjustmentCell then begin //set the comp adjusted price ATranslator.ExportValue(AdjIDs[2],'',IntToStr(ColIdx),ThisColumn.AdjSalePrice); //get the net adjustment for the comp NetAdjValue := GetValidNumber(ThisColumn.NetAdjustment); ATranslator.ExportValue(AdjIDs[3],'',IntToStr(ColIdx), NetAdjValue); //set if its a postive or negative adjustent if NetAdjValue >= 0 then ATranslator.ExportValue(AdjIDs[4],'',IntToStr(ColIdx), 'Y') else ATranslator.ExportValue(AdjIDs[5],'',IntToStr(ColIdx), 'N'); // add in the net and gross values ThisColumn.GetNetAndGrossAdjPercent(NetPct, GrossPct, AdjIDs[1]); ATranslator.ExportValue(AdjIDs[6],'',IntToStr(ColIdx), NetPct); //net percent for comp ATranslator.ExportValue(AdjIDs[7],'',IntToStr(ColIdx), GrossPct); //gross percent for comp end; end; //For rental tables get/set the subject's GLA and Bathroom counts from the column; if (ColCounter = 0) and (ATableType = ttRentals) and CompIsExported then begin ThisCell := ThisColumn.GetCellByID(RentalBathID[1]); if ThisCell <> nil then begin RentBathQty := GetValidNumber(ThisCell.Text); for Cntr := 2 to MaxRentID do begin ThisCell := ThisColumn.GetCellByID(RentalBathID[Cntr]); if ThisCell <> nil then RentBathQty := RentBathQty + GetValidNumber(ThisCell.Text); end; ATranslator.ExportValue(231,'',IntToStr(ColIdx), RentBathQty); end; ThisCell := ThisColumn.GetCellByID(RentalGLAID[1]); if ThisCell <> nil then begin RentGLA := GetValidNumber(ThisCell.Text); for Cntr := 2 to MaxRentID do begin ThisCell := ThisColumn.GetCellByID(RentalGLAID[Cntr]); if ThisCell <> nil then RentGLA := RentGLA + GetValidNumber(ThisCell.Text); end; ATranslator.ExportValue(232,'',IntToStr(ColIdx), RentGLA); end; end; end; end; finally ListCompOffset := ListCompOffset + Pred(ThisGridManager.Count); ThisGridManager.Free; end; end; procedure ExportTableCells2(ExpFormList: BooleanArray; AContainer: TContainer; ATableType: Integer; ErrList: TObjectList; ATranslator: TMISMOTranslator; IsUAD: Boolean; IsVer2_6: Boolean; var ListCompOffset: Integer; NonUADXMLData: Boolean; LocType: Integer=0); // Version 7.2.8 083110 JWyatt The FormAssocFile and related variables and code are included // to address unique XML addresses assigned to form ID 794. This was discussed in a meeting // today and it was agreed that this code should be revised to use only XML IDs in a future // release. const cFormAssocFolder = 'Converters\FormAssociations\'; //where form photo association maps are kept MaxAdjID = 7; MaxRentID = 4; StdAdjID: array[1..MaxAdjID] of Integer = (947,954,1052,1053,1054,1682,1683); RentalAdjID: array[1..MaxAdjID] of Integer = (1299,1259,1256,1257,1258,1264,1265); RentalBathID: array[1..MaxRentID] of Integer = (2258,2259,2260,2261); RentalGLAID: array[1..MaxRentID] of Integer = (2262,2263,2264,2265); var SubColumnCounter, RowCounter, ColCounter, ColIdx, Cntr : Integer; ThisGridManager : TGridMgr; ThisCell: TBaseCell; ThisCellNo, OrigCellXID : Integer; ThisCellText : string; ThisColumn : TCompColumn; Err: TComplianceError; NetAdjValue: Double; NetPct, GrossPct: String; AdjIDs: array[1..7] of Integer; AdjIDCount, FormIDHldr, TmpAdjID: Integer; FormAssocFile: TMemIniFile; AssocFilePath, FormSection: String; ListAsSale: Boolean; MapCellLocaterEvent: TMapCellLocaterEvent; CompIsExported: Boolean; RentBathQty, RentGLA: Double; ThisForm: TdocForm; AltCell: TBaseCell; AltUID: CellUID; AltPg, AltCellXID: Integer; formIDList:TStringList; aFormID: String; function ConcatNextCell(CurCell, NextCell: TBaseCell): String; begin if NextCell = nil then Result := CurCell.Text else if Trim(CurCell.Text) = '' then Result := NextCell.Text else Result := Trim(CurCell.Text) + ' ' + Trim(NextCell.Text); end; function GetFormIDList(ExpFormList: BooleanArray):String; var f: Integer; include:Boolean; aString: String; begin result := ''; for f := 0 to AContainer.docForm.count-1 do begin if not assigned(ExpFormList) then include := True else include := ExpFormList[f]; if include then begin aString := Format('%d',[AContainer.docForm[f].frmInfo.fFormUID]); result := result + ',' + aString; end; end; end; begin ListAsSale := False; FormIDHldr := 0; ThisGridManager := TGridMgr.Create; FormIDList := TStringList.Create; try // Set the std adjustment cell IDs in case the SalesAdjMap.txt file does not exist for AdjIDCount := 1 to MaxAdjID do if ATableType = ttRentals then AdjIDs[AdjIDCount] := RentalAdjID[AdjIDCount] else AdjIDs[AdjIDCount] := StdAdjID[AdjIDCount]; // ThisGridManager.BuildGrid(AContainer, ATableType); ThisGridManager.BuildGrid2(AContainer, ATableType,ExpFormList); FormIDList.CommaText := GetFormIDList(ExpFormList); for ColCounter := 0 to ThisGridManager.Count - 1 do // ThisGridManager is a TObjectList of TCompColumns begin ThisColumn := ThisGridManager.Comp[ColCounter]; if assigned(ThisColumn) then begin // The following code checks the current form ID, checks for the // sales adjustment map file and resets the adjustment IDs if // necessary. Currently, only the 794 and 834 forms require // special adjustments (see 8/31/10 note above). aFormID := Format('%d',[ThisColumn.FCX.FormID]); if (FormIDHldr = 0) or (FormIDHldr <> ThisColumn.FCX.FormID) and (FormIDList.IndexOf(aFormID) <> -1) then begin FormIDHldr := ThisColumn.FCX.FormID; FormAssocFile := nil; ListAsSale := False; try AssocFilePath := IncludeTrailingPathDelimiter(appPref_DirTools) + cFormAssocFolder + 'SalesAdjMap.txt'; if FileExists(AssocFilePath) then begin FormAssocFile := TMemIniFile.Create(AssocFilePath); FormSection := 'Form' + Format('%6.6d', [ThisColumn.FCX.FormID]); for AdjIDCount := 1 to MaxAdjID do begin TmpAdjID := FormAssocFile.ReadInteger(FormSection, 'ID' + IntToStr(AdjIDCount), 0); if TmpAdjID > 0 then AdjIDs[AdjIDCount] := TmpAdjID; end; ListAsSale := FormAssocFile.ReadBool(FormSection, 'ListAsSale', False); end; finally FormAssocFile.Free; end; end; if ListAsSale and (ColCounter <> 0) then ColIdx := ColCounter + ListCompOffset else ColIdx := ColCounter; CompIsExported := False; for RowCounter := 0 to ThisColumn.RowCount - 1 do begin for SubColumnCounter := 0 to 1 do begin ThisCellText := ''; ThisCellNo := ThisColumn.GetCellNumber(Point(SubColumnCounter,RowCounter)); ThisCell := ThisColumn.GetCellByCoord(Point(SubColumnCounter,RowCounter)); if Assigned(ThisCell) then try OrigCellXID := ThisCell.FCellXID; if IsVer2_6 then case ThisCell.FCellXID of //do not allow sublect listing price and price per GLA from Extra listing for //1004, 1073, 1075, 2055 (form IDS: 3545, 888, 888, 3545) //overwrite subject price from comparable grid 947, 953: if (ATableType = ttListings) and (colCounter = 0) and ((ThisColumn.FCX.FormID = 3545) or (ThisColumn.FCX.FormID = 888)) then continue; // Following cell XID have no corresponding path in the // 2.6 schema so are skipped for now. 937..939, 1302, 1400, 1401, 1670, 1671: Continue; // Special mapping for non-UAD 'Other' subject adjustment descriptions // to match schema and Appendix B specification 1020: if (not IsUAD) and (ColCounter = 0) and (ATableType = ttSales) then ThisCell.FCellXID := 4077; 1022: if (not IsUAD) and (ColCounter = 0) and (ATableType = ttSales) then ThisCell.FCellXID := 4079; 1032: if (not IsUAD) and (ColCounter = 0) and (ATableType = ttSales) then ThisCell.FCellXID := 4081; // concatenate with next cell (XID 1302 - Form 29) 1303: begin ThisCellText := ThisCell.Text; ThisCell.Text := ConcatNextCell(ThisCell, ThisColumn.GetCellByCoord(Point(SubColumnCounter,Succ(RowCounter)))); end; //Handle hidden cells with prior sales grid on a different page (1025, 1073, etc.). // It is possible for the visible data to be different than the hidden data. We need // to make sure we export the visible data - otherwise the XML & PDF will not match. 934, 935, 936, 2074: begin if (ColCounter < 4) and (ThisCell.FLocalCTxID > 0) then begin case ThisCell.FCellXID of 934: AltCellXID := 9001; 935: AltCellXID := 9002; 936: AltCellXID := 9003; 2074: AltCellXID := 9004; end; ThisForm := AContainer.docForm[ThisCell.UID.Form]; for AltPg := 0 to Pred(ThisForm.frmPage.Count) do begin AltCell := ThisForm.frmPage[AltPg].GetCellByXID(AltCellXID); if AltCell <> nil then begin AltUID := AltCell.UID; AltUID.Num := AltUID.Num + (ColCounter * 4); AltCell := ThisForm.GetCell(Succ(AltUID.Pg), Succ(AltUID.Num)); if AltCell = nil then Continue else ThisCell.Text := AltCell.Text; end; end; end; end; end; case LocType of 1: MapCellLocaterEvent := MapXPathLocater; 2: MapCellLocaterEvent := MapEmbeddedLocater; else MapCellLocaterEvent := nil; end; if IsUAD then begin if not CompIsExported then CompIsExported := (Trim(ThisCell.Text) <> ''); ExportGSEData(ThisCell, ATranslator, nil, MapCellLocaterEvent, ColIdx); ExportCell(False, ThisCell, ATranslator, MapCellLocaterEvent, ColIdx); end else if (ThisCell.FCellXID > 0) then begin if not CompIsExported then CompIsExported := (Trim(ThisCell.Text) <> ''); ExportCell(IsUAD, ThisCell, ATranslator, MapCellLocaterEvent, ColIdx); end; // restore any original text contents due to concatenating if ThisCellText <> '' then ThisCell.Text := ThisCellText; ThisCell.FCellXID := OrigCellXID; except on E: Exception do begin if assigned(ErrList) then begin Err := TComplianceError.Create; Err.FCX.FormID := 0; //don't search by FormID Err.FCX.Form := ThisColumn.CellCX.Form; //search by form index Err.FCX.Occur := 0; //don't search by occurance Err.FCX.Pg := ThisColumn.CellCX.Pg; //search by page Err.FCX.Num := ThisCellNo - 1; //search by cell sequence (zero based) Err.FMsg := E.Message; ErrList.Add(Err); end; ThisCell.FCellXID := OrigCellXID; end; end; end; end; //For tables get the last items in the column; only do the comps, not subject column. if ((ATableType = ttSales) or (ATableType = ttRentals) or ((ATableType = ttListings) and ListAsSale) or ((ATableType = ttListings) and (ThisColumn.FCX.FormID = 794))) and (ColCounter > 0) and CompIsExported then begin if ThisColumn.HasAdjSalesPriceCell and ThisColumn.HasNetAdjustmentCell then begin //set the comp adjusted price ATranslator.ExportValue(AdjIDs[2],'',IntToStr(ColIdx),ThisColumn.AdjSalePrice); //get the net adjustment for the comp NetAdjValue := GetValidNumber(ThisColumn.NetAdjustment); ATranslator.ExportValue(AdjIDs[3],'',IntToStr(ColIdx), NetAdjValue); //set if its a postive or negative adjustent if NetAdjValue >= 0 then ATranslator.ExportValue(AdjIDs[4],'',IntToStr(ColIdx), 'Y') else ATranslator.ExportValue(AdjIDs[5],'',IntToStr(ColIdx), 'N'); // add in the net and gross values ThisColumn.GetNetAndGrossAdjPercent(NetPct, GrossPct, AdjIDs[1]); ATranslator.ExportValue(AdjIDs[6],'',IntToStr(ColIdx), NetPct); //net percent for comp ATranslator.ExportValue(AdjIDs[7],'',IntToStr(ColIdx), GrossPct); //gross percent for comp end; end; //For rental tables get/set the subject's GLA and Bathroom counts from the column; if (ColCounter = 0) and (ATableType = ttRentals) and CompIsExported then begin ThisCell := ThisColumn.GetCellByID(RentalBathID[1]); if ThisCell <> nil then begin RentBathQty := GetValidNumber(ThisCell.Text); for Cntr := 2 to MaxRentID do begin ThisCell := ThisColumn.GetCellByID(RentalBathID[Cntr]); if ThisCell <> nil then RentBathQty := RentBathQty + GetValidNumber(ThisCell.Text); end; ATranslator.ExportValue(231,'',IntToStr(ColIdx), RentBathQty); end; ThisCell := ThisColumn.GetCellByID(RentalGLAID[1]); if ThisCell <> nil then begin RentGLA := GetValidNumber(ThisCell.Text); for Cntr := 2 to MaxRentID do begin ThisCell := ThisColumn.GetCellByID(RentalGLAID[Cntr]); if ThisCell <> nil then RentGLA := RentGLA + GetValidNumber(ThisCell.Text); end; ATranslator.ExportValue(232,'',IntToStr(ColIdx), RentGLA); end; end; end; end; finally ListCompOffset := ListCompOffset + Pred(ThisGridManager.Count); ThisGridManager.Free; FormIDList.Free; end; end; //Verify XML function GetXMLReportName (FullPath: String): String; var selectEXE: TOpenDialog; path: String; begin selectEXE := TOpenDialog.Create(nil); try if FileExists(FullPath) then begin selectEXE.InitialDir := ExtractFilePath(FullPath); selectEXE.Filename := ExtractFileName(FullPath); end else selectEXE.InitialDir := VerifyInitialDir('AppraisalWorld', ApplicationFolder); selectEXE.DefaultExt := 'xml'; selectEXE.Filter := 'Report XML (*.xml)|*.xml'; //'*.xml|All Files (*.*)|*.*'; selectEXE.FilterIndex := 1; selectEXE.Title := 'Select a XML Report file to verify:'; if (selectEXE.Execute) then begin path := selectEXE.Filename; XMLReportPath:=SysUtils.ExtractFilePath(path); XMLReportName := ExtractFileName(path); result := path; end; finally selectEXE.Free; end; end; {procedure VerifyXMLReport (); var Doc: DOMDocument40; fileName, output, parseString: String; begin parseString := '<!DOCTYPE VALUATION_RESPONSE SYSTEM "AppraisalXML.dtd">'; Doc := CoDOMDocument40.Create(); Doc.resolveExternals := true; Doc.validateOnParse := true; if (XMLReportName <> '') then fileName := GetXMLReportName (XMLReportName) else fileName:= GetXMLReportName('C:\AppraisalWorld\Report\Sample_Appraisal_File.xml'); if FileExists(XML_DTD) then CopyFile(XML_DTD, XMLReportPath+'\AppraisalXML.dtd', true) else raise Exception.Create('The MISMO DTD verification file could not be found. Please ensure it has been installed properly.'); if Not FileExists(fileName) then ShowNotice ('Report not found') else Doc.load(fileName); if Doc.parseError.errorCode <> 0 then begin output := Doc.parseError.reason + #13#10 + ' In: ' + Doc.parseError.srcText ; ShowNotice (output); end else ShowNotice ('No errors found'); if FileExists(XMLReportPath+'\AppraisalXML.dtd') then DeleteFile(XMLReportPath+'\AppraisalXML.dtd'); end; } function CheckForFileName(var AFileName: String): Boolean; var SaveFile: TSaveDialog; begin // 040611 JWyatt Revised to use default file name, if supplied result := False; SaveFile := TSaveDialog.Create(nil); try if (length(AFileName) > 0) and FileExists(AFileName) then DeleteFile(AFileName); saveFile.FileName := AFileName; SaveFile.Title := 'Specify a file name for the XML Report'; saveFile.InitialDir := appPref_DirUADXMLFiles; SaveFile.DefaultExt := 'xml'; SaveFile.Filter := 'XML File(.xml)|*.xml'; SaveFile.FilterIndex := 1; SaveFile.Options := SaveFile.Options + [ofOverwritePrompt]; if SaveFile.Execute then begin AFileName := SaveFile.FileName; appPref_DirUADXMLFiles := ExtractFilePath(AFileName); result := True; end; finally SaveFile.Free; end; end; procedure SaveAsGSEAppraisalXMLReport(AContainer: TContainer; AFileName: string; LocType: Integer=0; NonUADXMLData: Boolean=False); begin SaveAsGSEAppraisalXMLReport(AContainer, nil, AFileName, LocType, NonUADXMLData); end; procedure SaveAsGSEAppraisalXMLReport(AContainer: TContainer; ExportForm: BooleanArray; AFileName: string; LocType: Integer=0; NonUADXMLData: Boolean=False); begin SaveAsGSEAppraisalXMLReport(AContainer, ExportForm, AFileName, nil, LocType, NonUADXMLData); end; procedure SaveAsGSEAppraisalXMLReport(AContainer: TContainer; ExportForm: BooleanArray; AFileName: string; Info: TMiscInfo; LocType: Integer=0; NonUADXMLData: Boolean=False); begin if CheckForFileName(AFileName) then CreateGSEAppraisalXMLReport(AContainer, ExportForm, AFileName, Info, LocType, NonUADXMLData); end; //This call is used for RELS procedure CreateGSEAppraisalXMLReport(AContainer: TContainer; ExportForm: BooleanArray; AFileName: string; Info: TMiscInfo; LocType: Integer=0; NonUADXMLData: Boolean=False); var xmlReport, XSD_FileName, XMLVer: String; srcXMLDoc: IXMLDOMDocument2; cache: IXMLDOMSchemaCollection; begin if IsXMLSetup(AContainer) then begin if LocType = 2 then begin xmlReport := ComposeGSEAppraisalXMLReport(AContainer, XMLVer, ExportForm, Info, nil, 0, NonUADXMLData); xmlReport := xmlReport + ComposeGSEAppraisalXMLReport(AContainer, XMLVer, ExportForm, Info, nil, LocType); end else xmlReport := ComposeGSEAppraisalXMLReport(AContainer, XMLVer, ExportForm, Info, nil, LocType, NonUADXMLData); uWindowsInfo.WriteFile(AFileName, xmlReport); if FileExists(AFileName) then begin XSD_FileName := IncludeTrailingPathDelimiter(appPref_DirMISMO) + MISMO_XPathFilename + XMLVer + '.xsd'; if FileExists(XSD_FileName) then begin cache := CoXMLSchemaCache60.Create; srcXMLDoc := CoDomDocument60.Create; srcXMLDoc.async := false; srcXMLDoc.setProperty('SelectionLanguage', 'XPath'); cache.add('',XSD_FileName); srcXMLDoc.schemas := cache; srcXMLDoc.loadXML(xmlReport); if srcXMLDoc.parseError.errorCode <> 0 then ShowAlert(atWarnAlert, 'ClickFORMS has detected issues validating your XML file, ' + ExtractFileName(AFileName) + '. For assistance please e-mail your ClickFORMS report (the "clk" file) to uad@bradfordsoftware.com.'); end else ShowAlert(atStopAlert, 'The XML validation schema file, ' + ExtractFileName(XSD_FileName) + ', cannot be found. The XML file was not properly validated.'); end; end else ShowAlert(atStopAlert, 'There was a problem creating the XML file.'); end; //This is the main code for creating UAD XML file (either MISMO26 or MISMO26_GSE) function ComposeGSEAppraisalXMLReport(AContainer: TContainer; var XMLVer: String; ExportForm: BooleanArray; Info: TMiscInfo; ErrList: TObjectList; LocType: Integer=0; NonUADXMLData: Boolean=False): string; var FormCounter, PageCounter, CellCounter, ThisIndex, ListCompOffset : Integer; ThisPage: TDocPage; ThisCell: TBaseCell; ThisTranslator: TMISMOTranslator; ExportedCell: TExportedList; Err: TComplianceError; ThisForm: TdocForm; Counter: Integer; DividedCellContent: TStringList; exportThisForm: Boolean; // The following five variables are added for control and processing of UAD // compliant reports. IsUAD, IsVer2_6: Boolean; MapCellLocaterEvent: TMapCellLocaterEvent; RELSOrder: RELSOrderInfo; Frm1004MCSeqID: Integer; //on some forms, the cell text is continued on another cell. These cells have the same ID //and are handled here as divided cells. At the end, these cells are exported as one export procedure HandleDividedCells; begin ThisIndex := DividedCellContent.IndexOfObject(TObject(ThisCell.FCellXID)); if ThisIndex <> -1 then begin DividedCellContent.Strings[ThisIndex] := TrimLeft(DividedCellContent.Strings[ThisIndex] + ' ') + Trim(ThisCell.Text); end else DividedCellContent.AddObject(ThisCell.Text, TObject(ThisCell.FCellXID)); end; //In some cases we have to skip XML node for checkbox if the general None //checkbox checked. For example skip Garage types (Garage,Covered, or Open) //if Garage storage None checked. It is forms 1073, 1075. //There are the other such cases. function SkipDependOn(page: TDocPage; masterCellXID: integer; Translator: TMISMOTranslator): Boolean; var masterCell: TBaseCell; cellText: String; begin result := false; masterCell := page.GetCellByXID(masterCellXID); if masterCell is TchkBoxCell then begin cellText := GetTextAsGSEData(masterCell.FCellXID, masterCell, Translator); result := CompareText(cellText,'N') = 0; end; end; begin Result := ''; ThisTranslator := nil; ExportedCell := nil; //make sure we have a container if assigned(AContainer) then try if Assigned(AContainer.docEditor) and (AContainer.docEditor is TEditor) then (AContainer.docEditor as TEditor).SaveChanges; AContainer.ProcessCurCell(True); //get the latest text // 081811 JWyatt We need a better method than the following so // we can remove RELS-specific code from here and make this module // more generic. We don't yet know what other AMCs & AMC suppliers // want and the impact. RELSOrder := ReadRELSOrderInfoFromReport(AContainer); if RELSOrder.OrderID > 0 then begin if RELSOrder.Version = RELSUADVer then XMLVer := UADVer else XMLVer := NonUADVer; end else if (XMLVer = '') then if AContainer.UADEnabled then XMLVer := UADVer else XMLVer := NonUADVer; IsUAD := AContainer.UADEnabled and (XMLVer = UADVer); // 050411 JWyatt Move SetupMISMO call after XMLVer setup in case we're // exporting a non-UAD report SetupMISMO(AContainer, XMLVer); //set the file paths ThisTranslator := TMISMOTranslator.Create; //create the export translator DividedCellContent := TStringList.Create; // ExportedCell := TExportedList.Create(AContainer, CountReportCells(AContainer)); //set the list for exported cell IDs ExportedCell := TExportedList.Create(AContainer, CountReportCells2(AContainer, ExportForm)); //set the list for exported cell IDs try IsVer2_6 := ((XMLVer = UADVer) or (XMLVer = NonUADVer)); AContainer.CellXPathList.Clear; ThisTranslator.RaiseComplianceError := assigned(ErrList); //do we save the complliance errors ThisTranslator.OnExport := ExportedCell.StoreID; //save cell id on export into ExportList //first checkpoint - do we have a translator with a map if not assigned(ThisTranslator.Mappings) then raise Exception.Create('Problems were encountered with the MISMO Data. The XML file could not be created.'); //ThisTranslator.BeginExport(stAppraisalResponse); ThisTranslator.BeginExport(stAppraisal); //second checkpoint - do we have the appraisal DTD file if FileExists(XML_DTD) then begin ThisTranslator.XML.DocType.LoadFromFile(XML_DTD); ThisTranslator.XML.IncludeDTD := False; end else raise Exception.Create('The MISMO DTD file was not found. The XML file could not be created.'); //Start exporting XML //export all data that is not on form ExportReportAttributes(AContainer, ExportForm, ThisTranslator, Info, IsVer2_6, XMLVer); ExportReportFormList(AContainer, ThisTranslator, ExportForm, ErrList, Frm1004MCSeqID, IsVer2_6, Info); if XMLVer = UADVer then ExportReportEmbededPDF(AContainer, ThisTranslator, Info); ExportReportPartiesParsedAddess(AContainer, ExportForm, ThisTranslator); ExportSalesContractConsessions(AContainer, ExportForm, ThisTranslator, IsVer2_6); //special so we don't have to add cells to all forms ExportMergedCells(AContainer, MAIN_FORM_SUMMARY_COMMENT_CELLXID, ExportForm, ThisTranslator, [917,2727]); ListCompOffset := 0; ExportTableCells2(ExportForm, AContainer, ttSales, ErrList, ThisTranslator, IsUAD, IsVer2_6, ListCompOffset, NonUADXMLData, LocType); //export the Sales Comp Grid if (ListCompOffset < 0) then ListCompOffset := 0; ExportTableCells2(ExportForm, AContainer, ttListings , ErrList, ThisTranslator, IsUAD, IsVer2_6, ListCompOffset, NonUADXMLData, LocType); //export the Listing Comp Grid ListCompOffset := 0; ExportTableCells2(ExportForm, AContainer, ttRentals , ErrList, ThisTranslator, IsUAD, IsVer2_6, ListCompOffset, NonUADXMLData, LocType); //export the Rental Comp Grid //--- these might be handled in the ExportFormList - if photos are wanted // ExportTablePhotoCells(ctSales, ThisTranslator); // ExportTablePhotoCells(ctRentals, ThisTranslator); // ExportTablePhotoCells(ctListings, ThisTranslator); for FormCounter := 0 to AContainer.docForm.count - 1 do //for each form begin exportThisForm := True; //assume we will export this form if assigned(ExportForm) then //if we have non-nil export list exportThisForm := ExportForm[formCounter]; //check if its on list to export if exportThisForm then //do we export it? begin ThisForm := AContainer.docForm[FormCounter]; for PageCounter := 0 to ThisForm.frmPage.Count - 1 do //for each page begin ThisPage := ThisForm.frmPage[PageCounter]; if (ThisPage.pgData <> nil) then //make sure page has data cells begin for CellCounter := 0 to ThisPage.pgData.Count - 1 do begin ThisCell := ThisPage.pgData[CellCounter]; // exclude page number cells if (ThisCell.FCellXID = CELL_PGNUM_XID) then Continue; if (ThisCell.FCellXID <> 0) and //has an XPath not (ThisCell is TGraphicCell) and //not a graphical cell not (ThisCell is TGridCell) and //not a grid cell not (ThisCell is TInvisibleCell) and //not a invisible cell not ExportedCell.HasBeenExported(ThisCell.FCellXID) then //not already exported begin //exclude these cells - handled in special way if not IsVer2_6 then case ThisCell.FCellXID of 2731: begin HandleDividedCells; // Instructions to the appraiser on Land form Continue; end; // If we're NOT processing a UAD-compatible report then // we need to skip the 'already exported' items. For UAD // compliant reports these items have not previously // been exported. //Signer - Appraiser - already exported 5,7,1684,9,10,11,12,13,14,15,16,17,18,19,20,21,5008,2098, 2096,2097,1149,1150,1151,2009,1660,1678: Continue; //Signer - Reviewer - already exported 1402, 1403,1666,1499,1504,1505,1506,1728,1507,1508,1509, 1510,1511,1512,1513,1514,1517,1518,1520,1521, 1522,1523,1524,1658,1729,1730: Continue; //Signer - Supervisor - already exported 6,22,23,24,42,25,26,27,276,277,5018,2099,28,29,30,32,33, 1152,1153,1154,2008,1155,1156,2100,1679: Continue; //general comments & special XComp comments 917,1218,2727,2729,1676: Continue; end; if IsVer2_6 then case ThisCell.FCellXID of // Special handling for the 1004MC & Comparable Rent license/certification cells 17, 28, 2098, 2099: if (ThisForm.FormID = 850) or (ThisForm.FormID = 29) then Continue; 5008, 5018: Continue; // Following cell XID are exported elsewhere, are not used // or have no corresponding path in the 2.6 schema so are // skipped. 1, 405..407, 451, 526, 677..680, 682..685, 690, 906..909, 928, 937..939, 951, 1035, 1036, 1046, 1050, 1099..1101, 1202, 1225..1227, 1264..1278, 1282, 1313, 1314, 1331..1362, 1370, 1371, 1376, 1377, 1379..1386, 1390, 1400, 1401, 1670, 1671, 1406..1434, 1525..1636, 1639..1659, 1669, 1677, 1689..1694, 1728, 1730, 1740..1783, 1913..1945, 1954..1991, 2031, 2073, 917, 2165..2172, 2175..2214, 2324, 2331..2334, 2364, 2727, 2728, 2729, 2731, 3159, 3163, 3253, 3255, 3258, 3259, 3915, 3916, 3930..3932, 3934..3936, 3956..3961, 4070..4074, 4228, 4236: Continue; //forms 1073,1075 Car storage None checked 349,2000,3591: if SkipDependOn(thisPage, 346, ThisTranslator) then continue; //MISMO XML schema allowes the only one appraiser license per XML 20: //state license # if Acontainer.GetCellByXID_MISMO(18, ExportForm).HasData then //check state certificate # continue; 2096, 2097 : //other state license #, description if AContainer.GetCellByXID_MISMO(18, ExportForm).HasData or Acontainer.GetCellByXID_MISMO(20, ExportForm).HasData then // check state license and state certificate continue; end; case ThisCell.FCellXID of // already exported above in Photo, Map, or Sketch addemdums // Version 7.2.7 JWyatt Add declarations for IDs 2870-2881 used // on the Subject Interior Photos form (ID 919). // Version 7.2.8 JWyatt Add declarations for IDs 2882-2887 used // on the Untitled Subject Interior Photos form (ID 936). 1157, 1158, 1163..1168, 1205..1213, 1219..1221, 2617..2642, 2870..2887, 5076, 9001..9004: Continue; end; // select cell locater mapping proc case LocType of 1: MapCellLocaterEvent := MapXPathLocater; 2: MapCellLocaterEvent := MapEmbeddedLocater; else MapCellLocaterEvent := nil; end; // export try case ThisCell.FCellXID of // Handle 1004MC specially to use the found sequence ID 2763..2857: if IsUAD and (Trim(ThisCell.Text) <> '') then begin ExportGSEData(ThisCell, ThisTranslator, ExportedCell, MapCellLocaterEvent, Frm1004MCSeqID); if (not ExportedCell.HasBeenExported(ThisCell.FCellXID)) then ExportCell(False, ThisCell, ThisTranslator, MapCellLocaterEvent, Frm1004MCSeqID); end else ExportCell(False, ThisCell, ThisTranslator, MapCellLocaterEvent, Frm1004MCSeqID); else if IsUAD then begin ExportGSEData(ThisCell, ThisTranslator, ExportedCell, MapCellLocaterEvent); if (not ExportedCell.HasBeenExported(ThisCell.FCellXID)) then ExportCell(False, ThisCell, ThisTranslator, MapCellLocaterEvent); end else begin ExportCell(False, ThisCell, ThisTranslator, MapCellLocaterEvent); end; end; except on E: EMISMOFormatError do begin if assigned(ErrList) then begin Err := TComplianceError.Create; Err.FCX.FormID := 0; //don't search by FormID Err.FCX.Form := FormCounter; //search by form index Err.FCX.Occur := 0; //don't search by occurance Err.FCX.Pg := PageCounter; //search by page Err.FCX.Num := CellCounter; //search by cell sequence Err.FMsg := E.Message; ErrList.Add(Err); end; end; on E: Exception do; end; end; end; end; end; for Counter := 0 to DividedCellContent.Count - 1 do begin ThisTranslator.ExportValue(Integer(DividedCellContent.Objects[Counter]), DividedCellContent.Strings[Counter]); end; DividedCellContent.Clear; end; end; //DONE - this is the resulting XML text Result := SetUADSpecialXML(ThisTranslator.EndExport); except on E : Exception do begin ThisTranslator.CancelExport; ShowAlert(atWarnAlert, E.Message); end; end; finally if assigned(ThisTranslator) then ThisTranslator.Free; If assigned(ExportedCell) then ExportedCell.Free; if assigned(DividedCellContent) then DividedCellContent.Free; end; end; function ValidateXML(doc: TContainer; xmlReport: String): Boolean; var XSD_FileName: String; cache: IXMLDOMSchemaCollection; srcXMLDoc: IXMLDomDocument2; XMLVer: String; begin result := false; if doc.UADEnabled then XMLVer := UADVer else XMLVer := NonUADVer; XSD_FileName := IncludeTrailingPathDelimiter(appPref_DirMISMO) + MISMO_XPathFilename + XMLVer + '.xsd'; if FileExists(XSD_FileName) then begin cache := CoXMLSchemaCache60.Create; srcXMLDoc := CoDomDocument60.Create; srcXMLDoc.async := false; srcXMLDoc.setProperty('SelectionLanguage', 'XPath'); cache.add('',XSD_FileName); srcXMLDoc.schemas := cache; srcXMLDoc.loadXML(xmlReport); if srcXMLDoc.parseError.errorCode <> 0 then ShowAlert(atWarnAlert, 'ClickFORMS has detected issues validating your XML file.' + '. For assistance please e-mail your ClickFORMS report (the "clk" file) to uad@bradfordsoftware.com.') else result := true; end else ShowAlert(atStopAlert, 'The XML validation schema file, ' + ExtractFileName(XSD_FileName) + ', cannot be found. The XML file was not properly validated.'); end; end.
{******************************************************************************} { } { WiRL: RESTful Library for Delphi } { } { Copyright (c) 2015-2019 WiRL Team } { } { https://github.com/delphi-blocks/WiRL } { } {******************************************************************************} unit Server.Resources; interface uses System.Classes, System.SysUtils, System.JSON, System.NetEncoding, WiRL.Core.Engine, WiRL.Core.Application, WiRL.Core.Registry, WiRL.Core.Attributes, WiRL.http.Accept.MediaType, WiRL.http.URL, WiRL.Core.MessageBody.Default, WiRL.Core.Auth.Context, WiRL.http.Request, WiRL.http.Response; type [Path('/helloworld')] THelloWorldResource = class private [Context] Request: TWiRLRequest; [Context] AuthContext: TWiRLAuthContext; public [GET] [Produces(TMediaType.TEXT_PLAIN + TMediaType.WITH_CHARSET_UTF8)] function HelloWorld(): string; [GET, Path('/time')] [Produces(TMediaType.TEXT_PLAIN)] function WhatTimeIsIt: TDateTime; [GET, Path('/echostring/{AString}')] [Produces(TMediaType.TEXT_PLAIN)] function EchoString([PathParam] AString: string): string; [GET, Path('/reversestring/{AString}')] [Produces(TMediaType.TEXT_PLAIN)] function ReverseString([PathParam] AString: string): string; [GET, Path('/params/{AOne}/{ATwo}')] [Produces(TMediaType.TEXT_PLAIN)] function Params([PathParam] AOne: string; [PathParam] ATwo: string): string; [GET, Path('/authinfo'), Produces(TMediaType.APPLICATION_JSON)] function GetAuthInfo: string; [GET, Path('/sum/{Addendo1}/{Addendo2}')] [Produces(TMediaType.TEXT_PLAIN)] function Somma( [PathParam] Addendo1: Integer; [PathParam] Addendo2: Integer): Integer; [GET, Path('/exception'), Produces(TMediaType.APPLICATION_JSON)] function TestException: string; [POST, Path('/postexample'), Produces(TMediaType.TEXT_PLAIN)] function PostExample([BodyParam] AContent: string): string; [POST, Path('/postjsonexample'), Produces(TMediaType.TEXT_PLAIN), Consumes(TMediaType.APPLICATION_JSON)] function PostJSONExample([BodyParam] AContent: TJSONObject): string; [POST, Path('/postjsonarray'), Produces(TMediaType.TEXT_PLAIN), Consumes(TMediaType.APPLICATION_JSON)] function PostJSONArrayExample([BodyParam] AContent: TJSONArray): string; [POST, Path('/poststream'), Produces(TMediaType.TEXT_PLAIN), Consumes(TMediaType.APPLICATION_OCTET_STREAM)] function PostStreamExample([BodyParam] AContent: TStream): string; [POST, Path('/multipart'), Produces(TMediaType.APPLICATION_JSON), Consumes(TMediaType.MULTIPART_FORM_DATA)] function PostMultiPartExample( [FormParam] AValue: string; [FormParam] AContent: TStream; [FormParam] AJSON: TJSONObject ): TJSONObject; end; [Path('/entity')] TEntityResource = class private [Context] URL: TWiRLURL; public [GET, Path('/url')] [Produces(TMediaType.APPLICATION_JSON)] function EchoURL: TJSONObject; [GET, Path('/image')] [Produces('image/png')] function GetImage: TStream; [GET, Path('/pdf')] [Produces('application/pdf')] function GetPDF: TStream; end; implementation uses System.DateUtils, System.StrUtils, System.IOUtils, WiRL.Core.JSON, WiRL.http.Accept.Language; { THelloWorldResource } function THelloWorldResource.EchoString(AString: string): string; begin Result := AString; end; function THelloWorldResource.GetAuthInfo: string; begin Result := TJSONHelper.ToJSON(AuthContext.Subject.JSON); end; function THelloWorldResource.HelloWorld(): string; var LLang: TAcceptLanguage; begin LLang := TAcceptLanguage.Create('it'); try if Request.AcceptableLanguages.Contains(LLang) then Result := 'Ciao Mondo!' else Result := 'Hello World!'; finally LLang.Free; end; end; function THelloWorldResource.Params(AOne, ATwo: string): string; begin Result := 'One: ' + AOne + sLineBreak + 'Two: ' + ATwo; end; function THelloWorldResource.PostExample(AContent: string): string; var LArray: TJSONArray; LElement: TJSONValue; begin Result := 'PostExample:'; LArray := TJSONObject.ParseJSONValue(AContent) as TJSONArray; try for LElement in LArray do begin if Result <> '' then Result := Result + sLineBreak; Result := Result + 'Element: ' + TJSONHelper.ToJSON(LElement); end; finally LArray.Free; end; end; function THelloWorldResource.PostJSONArrayExample(AContent: TJSONArray): string; begin Result := 'Array len: ' + IntToStr(AContent.Count); end; function THelloWorldResource.PostJSONExample(AContent: TJSONObject): string; begin Result := 'Name=' + AContent.GetValue<string>('name'); end; function THelloWorldResource.PostMultiPartExample( [FormParam] AValue: string; [FormParam] AContent: TStream; [FormParam] AJSON: TJSONObject ): TJSONObject; var LContentBuffer: TBytes; begin SetLength(LContentBuffer, AContent.Size); AContent.ReadBuffer(LContentBuffer, AContent.Size); Result := TJSONObject.Create; Result .AddPair('AValue', AValue) .AddPair('AJSON', AJSON.ToJSON) .AddPair('AContent', TNetEncoding.Base64.EncodeBytesToString(LContentBuffer)); end; function THelloWorldResource.PostStreamExample(AContent: TStream): string; begin Result := 'Stream len: ' + IntToStr(AContent.Size); end; function THelloWorldResource.ReverseString(AString: string): string; begin Result := System.StrUtils.ReverseString(AString); end; function THelloWorldResource.Somma(Addendo1, Addendo2: Integer): Integer; begin Result := Addendo1 + Addendo2; end; function THelloWorldResource.TestException: string; begin raise Exception.Create('User Error Message'); end; function THelloWorldResource.WhatTimeIsIt: TDateTime; begin Result := Now; end; { TEntityResource } function TEntityResource.EchoURL: TJSONObject; begin Result := URL.ToJSONObject; end; function TEntityResource.GetImage: TStream; var LFileName: string; begin LFileName := IncludeTrailingPathDelimiter( TDirectory.GetParent( TDirectory.GetParent( TDirectory.GetParent(TWiRLEngine.ServerDirectory)))) + 'WiRL-logo.png'; Result := TFileStream.Create(LFileName, fmOpenRead or fmShareDenyWrite); end; function TEntityResource.GetPDF: TStream; var LFileName: string; begin LFileName := IncludeTrailingPathDelimiter( TDirectory.GetParent( TDirectory.GetParent( TDirectory.GetParent(TWiRLEngine.ServerDirectory)))) + 'WiRL-doc.pdf'; Result := TFileStream.Create(LFileName, fmOpenRead or fmShareDenyWrite); end; initialization TWiRLResourceRegistry.Instance.RegisterResource<THelloWorldResource>; TWiRLResourceRegistry.Instance.RegisterResource<TEntityResource>; end.
{ $HDR$} {**********************************************************************} { Unit archived using Team Coherence } { Team Coherence is Copyright 2002 by Quality Software Components } { } { For further information / comments, visit our WEB site at } { http://www.TeamCoherence.com } {**********************************************************************} {} { $Log: 13155: LookOut.pas { { Rev 1.0 2003-03-20 14:03:30 peter } { { Rev 1.0 2003-03-17 10:14:24 Supervisor } {** TLookOut components Written by Peter Thornqvist Copyright © 1997 by Peter Thornqvist; all rights reserved Part of EQ Soft Delphi Component Pack Contact: support@eq-soft.se Status: Free for non-commercial use. Source and commercial license demands a fee. See readme.txt file for details. Version: 1.18 Description: COMPONENTS: TLookOut - derived from TCustomControl properties: ActivePage:TLookOutPage set this to the TLookOutPage owned by the TLookOut that you want to be active. You can achieve the same result by calling each TLookOutPage objects Click method. AutoSize:boolean if set to true, will size the TLookOutPage objects to fit inside the TLookOut. Note that when rezising (in design mode) you must sometimes toggle this property to update the onscreen image. Smooth:boolean; if true, the lookout page(s) scrolls smoothly when clicked ImageSize:TImageSize sets the ImageSize of all TLookOuts that the TLookOut is parent to if the TLookOuts have their ParentImageSize property set to true Pages[Index:integer]:TLookOutPage A read / write array property for the Pages currently assigned to the TLookout. The pages are sorted in insertion order, that is, the last page inserted is the last one in the array. PageCount:integer The number of pages assigned to this TLookOut. methods: function AddPage:TLookOutPage Adds a page as the last page to the TLookOut events: procedure OnClick:TNotifyEvent Called when the ActivePage changes TLookOutPage - derived from TCustomControl properties: AutoCenter:boolean if set to true, will place all owned components in the horizontal middle of the TLookOutPage object Caption:TCaption sets the caption of the button (default 'Outlook') PopUpMenu:TPopUpMenu specify a popupmenu to show when right-clicking the TLookOutPage ImageSize:TImageSize sets the ImageSize of all TLookOutButtons that the TLookOutPage is parent to if the TLookOutButtons have their ParentImageSize property set to True ParentImageSize:boolean; if set to true, sets ImageSize according to it's parent ( same system as with Font / ParentFont) assuming that Parent is TLookOut Bitmap:TBitmap: specifies a bitmap that is used as a background on the TLookOutPage. Automatically tiles, but does not scroll along with the buttons Buttons[Index:integer]:TLookOutButton Use this to access the buttons assigned to this page as an array property. If you want to rearrange buttons in the array, use the ExchangeButtons procedure. ButtonCount:integer The number of buttons assigned to this page. methods: procedure Click simulates a click on the CaptionButton. Makes this TLookOutPage the active one if it is contained in a TLookOut procedure UpArrow simulates a click on the UpArrow only called if the arrowbutton is visible procedure DownArrow simulates a click on the DownArrow only called if the arrowbutton is visible function AddButton:TLookOutButton Adds a button to the page. The button will be placed as the bottom most button in the page. procedure ExchangeButtons(Index1,Index2:integer); Changes the placement in the Buttons array for buttons at Index1 and Index2. Use this when you want to rearrange buttons. TLookOutButton - derived from TGraphicControl properties: ButtonBorder:TButtonBorder =(bbDark,bbLight,bbMono) when set to bbDark, draws a darkgray / black border around the button when it has focus. When set to bbLight, draws a white /gray border instead When set to bbMono draws a white / black border ImageIndex:integer specify what image in the imagelist to display. 0 is the first image ImageSize:TImageSize = (isSmall,isLarge) when set to isLarge, the Image is displayed above the caption, else the image is displayed to the left of the image. Default is isLarge LargeImages: TImageList specify which ImageList to use for the isLarge state SmallImages: TImageList specify which ImageList to use for the isSmall state Spacing:integer specify how much larger than the bitmap the border is, i.e. if Spacing is set to 0 (zero), the buttonborder will be drawn right on the edge of the bitmap. A positive value will make the border larger than the bitmap and a negative value will make it smaller. Default is 4. ImageSize:TImageSize sets the ImageSize of all TLookOutButtons that the TLookOutPage is parent to if the TLookOutButtons have their ParentImageSize property set to True ParentImageSize:boolean; if set to true, sets ImageSize according to it's parent ( same system as with Font / ParentFont) assuming that Parent is TLookOut WordWrapping for long captions (isLarge only) and ellipsises (...) when caption extends beyond the buttons ClientRect (this happens automatically, no properties to set) TSpacer - derived from TGraphicControl The TSpacer component is a convenience component meant to be used when you need a little space between components. Just drop it were you want it and set the height to your liking. Has no methods, standard properties. TExpress - derived from TLookOutPage The TExpress is a single page TLookOut that simulates the look and functionality of the "buttonbox" in MS Outlook Express (included with IE 4.0). It has only one page of buttons and "popup" arrowbuttons at the upper and lower bounds. The TExpress is derived from TLookOutPage and shares most of it's properties, but adds one by itself: property ButtonHeight:integer (default = 60) All buttons in a TExpress share the same height and they always fill its entire width. Set the ButtonHeight of the TExpress to adjust all Children controls Height In addition, the TExpress do not have the AutoCenter property - it's obsolete as all children fill the entire width of the TExpress. TExpressButton - same as the TLookOutButton, but has added properties: property FillColor: TColor (default=clBtnFace) Specifies the color to fill the button with when the mouse enters the button. Setting this = clNone, will make the button transparent under all conditions. property Offset:integer(default = 1) Specifies how much the button will move down and right when pressed. Setting this to 0 will make only the border appear pressed. Offset = 1 mimicks the look of all standard buttons. HISTORY: July 22: Due to changes in the way up /down arrows are implemented, they are always visible in design mode, but will show /hide as appropriate at run-time. Added a component editor to make it a bit easier to select and scroll the contents of the components. Right click on any of the TLookOutPage or TLookOut components to see a menu of things you can do. Double-clicking a TLookOutPage will make it the active lookout if it is contained within a TLookOut. You can also select this option from the pop-up menu ("Activate"). In addition, you can scroll the contents of the TLookOutPage by right-clicking and selecting either "scroll up" or "scroll down". You can also scroll the TLookOutPage contents in design mode by clicking the up/down arrows Adding buttons and lookouts from the speed menu also works now... July 23: Added the component editor. Rewrote the scrolling code (simpler, nicer, better working). Added Smooth property to TLookOutPage. Not altogether pleased. Will work more on this. Added popupmenu to TLookOutButtons and TLookOutPage. Added ImageSize and ParentImageSize properties. Added Bitmap property. July 29: Added HiLiteFont property to TLookOutPage and TLookOutButton. The font used changes to HiLiteFont when the mouse enters the button Set to the same as Font as default. August 1: Changed the name of all components. See rename.txt for details. Added (protected) FillColor and Offset to TLookOutButton If FillColor (default = clNone) is not clNone, the background will be filled with the specified color and the border will be drawn around the edge of the button. Otherwise it will stay transparent. Offset (default = 0) specifies the amount the button (incl. image and text) moves down and to the left when the button is pressed. The default for the standard lookout is to not move at all, but the TExpressButton use the standard offset - 1. Derived TExpressButton and set the properties to mimick an Outlook Express button. Only needed a constructor implementation (9 lines of code) to set it up. Sometimes OOP can be very simple... ( You could also move the new properties from the protected to the published field of TOutlookButton. If you have this source, no one is going to stop you. ) August 4: Finished the (first) implementation of TExpress - an Outlook Express work and look-alike. Doesn't (yet) scroll quite like the Outlook Express, but I'll fix that (real) soon. Also added a component editor similar to the other ones. Added the bbMono type to TButtonBorder: bbMono is a border with white top and black bottom (in the default Windows color scheme). August 18: Added ShowPressed (boolean) property to TLookOutPage: When true, Pagebutton appears pressed when, uh... pressed. Rewrote CalcArrows and ScrollChildren (changed declaration of this too) procedures so it's now possible to rearrange buttons at designtime (at last!). Did some (small) fixes to the drag events. Changed the Buttons popupmenu implementation so the popup's PopupComponent property gets set properly (bug reported by Andrew Jackson). Added AutoRepeat property to TLookOutPage. set to true to make the arrowbuttons autoclick within intervall TimeDelay (=100). Initial delay is controlled by InitTime(=400). NOTE: This uses a timer (actually two), so if you're concerned with preservation of system resources don't use AutoRepeat. The timer(s) are only active while the button is down, so the penalty shouldn't be too severe, but it might get noticeable. August 23 Added EditCaption method to TLookOutPage: allows you to edit the caption of the page alá Outlook - shows a TEdit to write new text into. Pressing ESC or clicking with the mouse outside the TEdit will discards the changes, pressing Enter keeps them. Added speedkey handling (Alt+Letter) to Page and Button (thanks to Davendra Patel) September 3: Added EnableAdjust and DisableAdjust methods to TLookOutPage: calling DisableAdjust disables scrolling until a matching call to EnableAdjust is made. Use this if you add components to the page at runtime but they don't appear in increasing order, i.e. the first button loaded might be the last one in the page. September 9: Rewrote the Paint code for TLookOutButtons: mainly broke out the frame painting to minimize flicker on Enter / Exit and when clicking the button (offset = 0). Februari 6 (1998): Added Pages, PageCount properties and AddPage function to TLookOut Added Buttons,ButtonCount properties and AddButton,ExchangeButtons function to TLookOutPage Februari 16: Added Data (a pointer) property to TExpressButton and TLookOutButton. Use it to store your own Data in a button. Changed the text drawing for ImageSize = isSmall so the frame doesn't overwrite text. Changed DrawTextEx to DrawText. I wasn't using the last parameter anyway and DrawTextEx doesn't work on NT 3.51. April 29: Added EditCaption to TCustomLookoutButton. Added OnEdited events to TCustomLookoutButton and to TLookoutPage May 6: Version 1.18 Added GroupIndex to TLookoutbutton and TExpressButton. Works like TSpeedButton but without the AllowAllUp property (always allows) June 10: Added FlatButtons property to TLookout: now you can display the top buttons on the pages with the new flat style as seen in Outlook 98. Rewrote NC paint code a little. Small change to TExpress ButtonHeight handler. August 5: Added defines to work w. Delphi 4 October 29: Fixed bug in AddButton. The buttons appeared in random order if several buttons were added at once. The buttons never got a chance to realign before the next button was added. Now Top is forced to (or at least close to) the correct value at creation. (OutEdit.pas): Added "AddPage" to the LookOutPage Component Editor so it's now easier to add several pages to the TLookout at designtime without havinf to rearrange the existing ones to get access to the TLookout } unit LookOut; {$IFNDEF WIN32} Lookout is for Win32 only! {$ENDIF} interface {$I VER.INC } uses Windows, Messages, SysUtils, Forms, Classes, Graphics, Controls, StdCtrls, ExtCtrls, Buttons, Menus {$IFDEF D4_AND_UP },ImgList, ActnList{$ENDIF}; const CM_IMAGESIZECHANGED = CM_BASE + 100; CM_LEAVEBUTTON = CM_BASE + 101; CM_LOOKOUTBUTTONPRESSED = CM_BASE + 102; type TImageSize = (isSmall,isLarge); TButtonBorder =(bbDark,bbLight,bbMono); TSpacer = class(TGraphicControl) protected procedure Paint;override; public constructor Create(AOwner:TComponent); override; published property Align; end; TUpArrowBtn = class(TSpeedButton) private FTimer:TTimer; FAutoRepeat,FDown,FFlat,FInsideButton:boolean; procedure SetFlat(Value:boolean); procedure CmDesignHitTest(var Message:TCmDesignHitTest);message CM_DESIGNHITTEST; procedure CMMouseEnter(var Message:TMessage); message CM_MOUSEENTER; procedure CMMouseLeave(var Message:TMessage); message CM_MOUSELEAVE; protected procedure OnTime(Sender:TObject);virtual; procedure Paint;override; procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override; procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override; public procedure Click;override; constructor Create(AOwner:TComponent);override; published property Flat:boolean read FFlat write SetFlat default False; property AutoRepeat:boolean read FAutoRepeat write FAutoRepeat default True; end; TDownArrowBtn = class(TUpArrowBtn) protected procedure Paint;override; procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override; procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override; procedure OnTime(Sender:TObject);override; public constructor Create(AOwner:TComponent);override; end; TLookoutEditedEvent = procedure (Sender:TObject;var Caption:string) of object; TCustomLookOutButton = class(TGraphicControl) private FEdit:TEdit; FData :Pointer; FPImSize :boolean; FInsideButton :boolean; FDown :boolean; FStayDown :boolean; FCentered :boolean; FImageIndex :integer; FSpacing :integer; FOffset :integer; FImageSize :TImageSize; FImageRect :TRect; FTextRect :TRect; FFillColor :TColor; FHiFont :TFont; FButtonBorder :TButtonBorder; FPopUpMenu :TPopUpMenu; FCaption :TCaption; FGroupIndex :integer; FSmallImages :TImageList; FLargeImages :TImageList; FOnEdited :TLookoutEditedEvent; FLargeImageChangeLink:TChangeLink; FSmallImageChangeLink:TChangeLink; FMouseEnter:TNotifyEvent; FMouseExit:TNotifyEvent; procedure SetGroupIndex(Value:integer); procedure UpdateExclusive; procedure SetCentered(Value:boolean); procedure SetDown(Value:boolean); procedure SetOffset(Value:integer); procedure SetFillColor(Value:TColor); procedure SetHiFont(Value:TFont); procedure SetSpacing(Value:integer); procedure SetPImSize(Value:boolean); procedure SetButtonBorder(Value:TButtonBorder); procedure SetCaption(Value:TCaption); procedure SetSmallImages(Value:TImageList); procedure SetLargeImages(Value:TImageList); procedure SetImageIndex(Value:integer); procedure SetImageSize(Value:TImageSize); procedure DrawSmallImages; procedure DrawLargeImages; procedure ImageListChange(Sender: TObject); procedure CMDialogChar(var Message: TCMDialogChar); message CM_DIALOGCHAR; procedure CMButtonPressed(var Message: TMessage); message CM_LOOKOUTBUTTONPRESSED; procedure CMMouseEnter(var Message: TMessage); message CM_MOUSEENTER; procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE; procedure CMParentImageSizeChanged(var Message:TMessage);message CM_IMAGESIZECHANGED; procedure CMLeaveButton(var Msg:TMessage);message CM_LEAVEBUTTON; procedure WMEraseBkgnd(var M : TWMEraseBkgnd);message WM_ERASEBKGND; protected procedure DoOnEdited(var Caption:string);virtual; procedure EditKeyDown(Sender: TObject; var Key: Char); procedure EditMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure PaintFrame;virtual; procedure SetParent(AParent: TWinControl);override; procedure Paint;override; procedure MouseEnter;virtual; procedure MouseExit;virtual; procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override; procedure MouseMove(Shift: TShiftState; X, Y: Integer); override; procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override; property FillColor:TColor read FFillColor write SetFillColor default clNone; property Offset:integer read FOffset write SetOffset default 0; property ButtonBorder:TButtonBorder read FButtonBorder write SetButtonBorder default bbDark; property Caption:TCaption read FCaption write SetCaption; property Centered:boolean read FCentered write SetCentered; property Down:boolean read FStayDown write SetDown default False; property HiLiteFont:TFont read FHiFont write SetHiFont; property ImageIndex:integer read FImageIndex write SetImageIndex; property ImageSize:TImageSize read FImageSize write SetImageSize default isLarge; property ParentImageSize:boolean read FPImSize write SetPImSize default True; property PopUpMenu:TPopUpMenu read FPopUpMenu write FPopUpMenu; property LargeImages:TImageList read FLargeImages write SetLargeImages; property Spacing:integer read FSpacing write SetSpacing default 4; { border offset from bitmap } property SmallImages:TImagelist read FSmallImages write SetSmallImages; property Data:Pointer read FData write FData; property GroupIndex:integer read FGroupIndex write SetGroupIndex default 0; property OnEdited:TLookoutEditedEvent read FOnEdited write FOnEdited; {$IFDEF D4_AND_UP } procedure ActionChange(Sender: TObject; CheckDefaults: Boolean);override; {$ENDIF } public constructor Create(AOwner:TComponent);override; destructor Destroy;override; procedure Notification(AComponent: TComponent; Operation: TOperation); override; procedure Click; override; procedure Assign(Source:TPersistent);override; procedure EditCaption; published property Align; property DragCursor; property DragMode; property Enabled; property Font; property Height default 60; property Left; property ParentFont; property ParentShowHint; property ShowHint; property Top; property Visible; property Width default 60; property OnMouseEnter:TNotifyEvent read FMouseEnter write FMouseEnter; property OnMouseExit:TNotifyEvent read FMouseExit write FMouseEXit; property OnClick; property OnMouseDown; property OnMouseMove; property OnMouseUp; property OnDragDrop; property OnDragOver; property OnEndDrag; property OnStartDrag; {$IFDEF D4_AND_UP } property Action; property Anchors; property Constraints; property BiDiMode; property ParentBiDiMode; property DragKind; property OnEndDock; property OnStartDock; {$ENDIF} end; TLookOutButton = class(TCustomLookOutButton) public property Data; published property ButtonBorder; property Caption; property Down; property GroupIndex; property HiLiteFont; property ImageIndex; property ImageSize; property ParentImageSize; property PopUpMenu; property LargeImages; property Spacing; property SmallImages; property OnEdited; end; TExpressButton = class(TCustomLookOutButton) public constructor Create(AOwner:TComponent);override; property Data; published property Down; property FillColor default clBtnFace; property GroupIndex; property Offset default 1; property ButtonBorder default bbLight; property Caption; property HiLiteFont; property ImageIndex; property ImageSize; property ParentImageSize; property PopUpMenu; property LargeImages; property Spacing; property SmallImages; property OnEdited; end; TLookOut = class; TLookOutPage = class(TCustomControl) private { Private declarations } FEdit:TEdit; FAutoRepeat,FAutoCenter,FPImSize,FInsideButton,FDown,FShowPressed:boolean; FMargin,FTopControl:integer; FPopUpMenu:TPopUpMenu; FOnClick:TNotifyEvent; FDwnArrow:TDownArrowBtn; FScrolling:integer; FUpArrow:TUpArrowBtn; FCaption:TCaption; FBitmap:TBitmap; FImageSize:TImageSize; FManager:TLookOut; FOnCollapse:TNotifyEvent; FHiFont:TFont; FButtons:TList; FActiveButton:TCustomLookOutButton; FOnEdited :TLookoutEditedEvent; procedure SetActiveButton(Value:TCustomLookOutButton); procedure EditMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState;X, Y: Integer); procedure EditKeyDown(Sender: TObject; var Key: Char); procedure SetAutoRepeat(Value:boolean); procedure SetHiFont(Value:TFont); procedure SetImageSize(Value:TImageSize); procedure SetPImSize(Value:boolean); procedure SetBitmap(Value:TBitmap); procedure SetCaption(Value:TCaption); procedure SetMargin(Value:integer); procedure SetButton(Index:integer;Value:TLookOutButton); function GetButton(Index:integer):TLookOutButton; function GetButtonCount:integer; procedure SetAutoCenter(Value:boolean); function IsVisible(Control:TControl):boolean; procedure CMDialogChar(var Message: TCMDialogChar);message CM_DIALOGCHAR; procedure CMMouseLeave(var Message: TMessage);message CM_MOUSELEAVE; procedure CMEnabledChanged(var Message: TMessage); message CM_ENABLEDCHANGED; procedure WMEraseBkGnd(var Message:TWMEraseBkGnd); message WM_ERASEBKGND; procedure CMParentImageSizeChanged(var Message: TMessage); message CM_IMAGESIZECHANGED; procedure TileBitmap; protected { Protected declarations } procedure DoOnEdited(var Caption:string);virtual; procedure UpArrowClick(Sender:TObject);virtual; procedure DownArrowClick(Sender:TObject);virtual; procedure DrawTopButton; virtual; procedure CalcArrows;virtual; procedure ScrollChildren(Start:word);virtual; procedure AlignControls(Control:TControl;var Rect:TRect);override; procedure SetParent(AParent: TWinControl);override; procedure CreateWnd;override; procedure SmoothScroll(aControl:TControl;NewTop,Intervall:integer;Smooth:boolean);virtual; procedure Notification(AComponent: TComponent; Operation: TOperation); override; procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override; procedure MouseMove(Shift: TShiftState; X, Y: Integer); override; procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override; procedure Paint;override; public { Public declarations } procedure Click;override; procedure DownArrow; procedure UpArrow; function AddButton:TLookOutButton; procedure ExchangeButtons(Button1,Button2:TCustomLookOutButton);virtual; procedure EditCaption;virtual; procedure DisableAdjust; procedure EnableAdjust; constructor Create(AOwner:TComponent);override; destructor Destroy;override; property Buttons[Index:integer]:TLookOutButton read GetButton write SetButton; property ButtonCount:integer read GetButtonCount; property ActiveButton:TCustomLookOutButton read FActiveButton write SetActiveButton; published { Published declarations } property Align; property AutoRepeat:boolean read FAutoRepeat write SetAutoRepeat default False; property Bitmap:TBitmap read FBitmap write SetBitmap; property AutoCenter: boolean read FAutoCenter write SetAutoCenter default False; property ImageSize:TImageSize read FImageSize write SetImageSize default isLarge; property HiLiteFont:TFont read FHiFont write SetHiFont; property ParentImageSize:boolean read FPImSize write SetPImSize default True; property ShowPressed:boolean read FShowPressed write FShowPressed default False; property Caption:TCaption read FCaption write SetCaption; property Color; property DragCursor; property DragMode; property ShowHint; property Visible; property Enabled; property Font; property ParentFont; property ParentShowHint; property PopUpMenu:TPopUpMenu read FPopUpMenu write FPopUpMenu; property Left; property Top; property Width; property Height; property Cursor; property Hint; property Margin:integer read FMargin write SetMargin default 0; property OnEdited:TLookoutEditedEvent read FOnEdited write FOnEdited; property OnClick:TNotifyEvent read FOnClick write FOnClick; property OnMouseDown; property OnMouseMove; property OnMouseUp; property OnDragDrop; property OnDragOver; property OnEndDrag; property OnStartDrag; {$IFDEF D4_AND_UP } property Anchors; property Constraints; property BiDiMode; property ParentBiDiMode; property DragKind; property OnEndDock; property OnStartDock; { only for containers: } property DockSite; property UseDockManager; property OnCanResize; property OnConstrainedResize; property OnDockDrop; property OnDockOver; property OnGetSiteInfo; {$ENDIF} end; TLookOut = class(TCustomControl) private FAutoSize,FScroll,FCollapsing:boolean; FBorderStyle:TBorderStyle; FOnCollapse,FOnClick:TNotifyEvent; FActivePage,FCurrentPage:TLookOutPage; FPages:TList; FImageSize:TImageSize; FFlatButtons:boolean; procedure SetImageSize(Value:TImageSize); procedure SetBorderStyle(Value:TBorderStyle); procedure SetAutoSize(Value:boolean); procedure UpdateControls; procedure DoCollapse(Sender:TObject); procedure SetActiveOutLook(Value:TLookOutPage); function GetActiveOutlook:TLookOutPage; function GetPageCount:integer; function GetPage(Index:integer):TLookOutPage; procedure SetPage(Index:integer;Value:TLookOutPage); procedure SetFlatButtons(Value:boolean); procedure WMNCCalcSize(var Message: TWMNCCalcSize); message WM_NCCALCSIZE; procedure WMNCPaint(var Message: TMessage); message WM_NCPAINT; protected procedure SmoothScroll(aControl:TControl;NewTop,Intervall:integer;Smooth:boolean);virtual; procedure Paint;override; procedure Notification(AComponent:TComponent;Operation:TOperation);override; public constructor Create(AOwner:TComponent);override; destructor Destroy;override; function AddPage:TLookOutPage; property Pages[Index:integer]:TLookOutPage read GetPage write SetPage; property PageCount:integer read GetPageCount; published property ActivePage:TLookOutPage read GetActiveOutlook write SetActiveOutlook; property Align; property AutoSize:boolean read FAutoSize write SetAutoSize default false; property BorderStyle:TBorderStyle read FBorderStyle write SetBorderStyle default bsSingle; property Color default clBtnShadow; property FlatButtons:boolean read FFlatButtons write SetFlatButtons default false; property DragCursor; property DragMode; property ImageSize:TImageSize read FImageSize write SetImageSize default isLarge; property ShowHint; property Smooth:boolean read FScroll write FScroll default False; property Visible; property Enabled; property Left; property Top; property Width default 92; property Height default 300; property Cursor; property Hint; property OnClick:TNotifyEvent read FOnClick write FOnClick; property OnDragDrop; property OnDragOver; property OnEndDrag; property OnStartDrag; {$IFDEF D4_AND_UP } property Anchors; property Constraints; property BiDiMode; property ParentBiDiMode; property DragKind; property OnEndDock; property OnStartDock; { only for containers: } property DockSite; property UseDockManager; property OnCanResize; property OnConstrainedResize; property OnDockDrop; property OnDockOver; property OnGetSiteInfo; {$ENDIF} end; TExpress = class(TLookOutPage) private FBorderStyle:TBorderStyle; FButtonHeight:integer; procedure SetButtonHeight(Value:integer); protected procedure CalcArrows;override; procedure ScrollChildren(Start:word);override; procedure DrawTopButton; override; procedure Paint;override; procedure CreateWnd;override; procedure WMNCPaint(var Message: TMessage); message WM_NCPAINT; procedure WMNCCalcSize(var Message: TWMNCCalcSize); message WM_NCCALCSIZE; public constructor Create(AOwner:TComponent);override; function AddButton:TExpressButton; published property AutoCenter: boolean read FAutoCenter; property ButtonHeight:integer read FButtonHeight write SetButtonHeight default 60; property ImageSize default isLarge; end; procedure Register; implementation const ScrollSpeed = 20; bHeight = 19; InitTime = 400; TimeDelay = 120; procedure Register; begin RegisterComponents('EQ', [TExpress, TLookOut, TLookOutPage, TExpressButton]); end; { utility } { this creates a correctly masked bitmap - for use with D2 TImageList } { procedure CreateMaskedImageList(ImageList:TImageList); var Bmp:TBitmap;i:integer; begin Bmp := TBitmap.Create; Bmp.Width := ImageList.Width; Bmp.Height := ImageList.Height; try for i := 0 to ImageList.Count - 1 do begin ImageList.GetBitmap(i,Bmp); ImageList.ReplaceMasked(i,Bmp,Bmp.TransparentColor); end; finally Bmp.Free; end; end; } { returns number of visible children } { function NoOfVisibles(Control:TWinControl):integer; var R:TRect;i:integer; begin R := Control.ClientRect; Result := 0; if (Control = nil) then Exit; for i := 0 to Control.ControlCount - 1 do if (PtInRect(R,Point(R.Left + 1,Control.Controls[i].Top)) and PtInRect(R,Point(R.Left + 1,Control.Controls[i].Top + Control.Controls[i].Height))) then Inc(Result); end; } { function IMax(Val1,Val2:integer):integer; begin Result := Val1; if Val2 > Val1 then Result := Val2; end; function IMin(Val1,Val2:integer):integer; begin Result := Val1; if Val2 < Val1 then Result := Val2; end; } { returns Atleast if Value < AtLeast, Val1 otherwise } { function IAtLeast(Value,AtLeast:integer):integer; begin Result := Value; if Value < AtLeast then Result := AtLeast; end; } { TLookOutEdit } type TLookOutEdit=class(TEdit) private procedure CMExit(var Message: TCMExit); message CM_EXIT; end; procedure TLookOutEdit.CMExit(var Message: TCMExit); begin Visible := False; end; { TSpacer } constructor TSpacer.Create(Aowner:TComponent); begin inherited Create(AOwner); SetBounds(0,0,80,10); end; procedure TSpacer.Paint; begin if csDesigning in ComponentState then begin with Canvas do begin Brush.Color := clBlack; FrameRect(GetClientRect); end; end; end; { TUpArrowBtn } constructor TUpArrowBtn.Create(AOwner:TComponent); var FSize:word; begin inherited Create(AOwner); ControlStyle := [csCaptureMouse, csClickEvents, csSetCaption,csOpaque]; ParentColor := True; FDown := False; FInsideButton := False; FAutoRepeat := False; FFlat := False; FSize := GetSystemMetrics(SM_CXVSCROLL); SetBounds(0,0,FSize,FSize); end; procedure TUpArrowBtn.SetFlat(Value:boolean); begin if FFlat <> Value then begin FFlat := Value; Invalidate; end; end; procedure TUpArrowBtn.CMMouseEnter(var Message:TMessage); begin if not FInsideButton then begin FInsideButton := True; if FFlat then Invalidate; end; end; procedure TUpArrowBtn.CMMouseLeave(var Message:TMessage); begin if FInsideButton then begin FInsideButton := False; // FDown := False; if FFlat then Invalidate; end; end; procedure TUpArrowBtn.CmDesignHitTest(var Message:TCmDesignHitTest); begin Message.Result := 0; end; procedure TUpArrowBtn.Paint; var Flags:integer;R:TRect; begin R := GetClientRect; if FDown then Flags := DFCS_PUSHED else Flags := 0; if not Enabled then Flags := Flags or DFCS_INACTIVE; if FFlat and not FInsideButton then begin Flags := Flags or DFCS_FLAT; OffsetRect(R,0,-2); end; if FFlat then InflateRect(R,1,1); Canvas.Brush.Color := Color; Canvas.Pen.Color := Color; DrawFrameControl(Canvas.Handle,R,DFC_SCROLL,DFCS_SCROLLUP or Flags); if FFlat and FInsideButton then begin R := GetClientRect; if FDown then Frame3d(Canvas,R,clBlack,clWhite,1) else Frame3d(Canvas,R,clWhite,clBlack,1); end; end; procedure TUpArrowBtn.Click; begin if Enabled then begin inherited Click; ReleaseCapture; if Assigned(Parent) then Parent.Invalidate else Invalidate; end; end; procedure TUpArrowBtn.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin FDown := True; inherited MouseDown(Button, Shift, X, Y); if Parent is TLookOutPage then FAutoRepeat := TLookOutPage(Parent).AutoRepeat; if FAutoRepeat then begin if not Assigned(FTimer) then FTimer := TTimer.Create(self); with FTimer do begin OnTimer := OnTime; Interval := InitTime; Enabled := True; end; end; Repaint; end; procedure TUpArrowBtn.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin inherited MouseUp(Button, Shift, X, Y); if Assigned(FTimer) then begin FTimer.Free; FTimer := nil; end; FDown := False; (Parent as TLookOutPage).UpArrowClick(self); end; procedure TUpArrowBtn.OnTime(Sender:TObject); var R:TRect; begin FTimer.Interval := TimeDelay; if FDown and MouseCapture and Visible then begin (Parent as TLookOutPage).UpArrowClick(self); R := Parent.ClientRect; R := Rect(R.Left,R.Top+Top,R.Right,R.Top + bHeight); InvalidateRect(Parent.Handle,@R,False); Parent.Update; end; end; { TDownArrowBtn } constructor TDownArrowBtn.Create(AOwner:TComponent); var FSize:word; begin inherited Create(AOwner); ControlStyle := [csCaptureMouse, csClickEvents, csSetCaption,csOpaque]; ParentColor := True; FDown := False; FInsideButton := False; FFlat := False; FSize := GetSystemMetrics(SM_CXVSCROLL); SetBounds(0,0,FSize,FSize); end; procedure TDownArrowBtn.Paint; var Flags:integer;R:TRect; begin R := GetClientRect; if FDown then Flags := DFCS_PUSHED else Flags := 0; if not Enabled then Flags := Flags or DFCS_INACTIVE; if FFlat and not FInsideButton then begin Flags := Flags or DFCS_FLAT; OffsetRect(R,0,2); end; if FFlat then InflateRect(R,1,1); Canvas.Brush.Color := Color; Canvas.Pen.Color := Color; DrawFrameControl(Canvas.Handle,R,DFC_SCROLL,DFCS_SCROLLDOWN or Flags); if FFlat and FInsideButton then begin R := GetClientRect; if FDown then Frame3d(Canvas,R,clBlack,clBtnShadow,1) else Frame3d(Canvas,R,clWhite,clBlack,1); end; end; procedure TDownArrowBtn.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin FDown := True; inherited MouseDown(Button, Shift, X, Y); if Parent is TLookOutPage then FAutoRepeat := TLookOutPage(Parent).AutoRepeat; if FAutoRepeat then begin if not Assigned(FTimer) then FTimer := TTimer.Create(self); with FTimer do begin OnTimer := OnTime; Interval := InitTime; Enabled := True; end; end; Repaint; end; procedure TDownArrowBtn.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin // inherited MouseUp(Button, Shift, X, Y); if Assigned(OnMouseUp) then OnMouseUp(self,Button,Shift,X,y); FDown := False; (Parent as TLookOutPage).DownArrowClick(self); // Parent.ScrollBy(0,-50); if Assigned(FTimer) then begin FTimer.Free; FTimer := nil; end; Repaint; end; procedure TDownArrowBtn.OnTime(Sender:TObject); var R:TRect; begin FTimer.Interval := TimeDelay; if FDown and MouseCapture and Visible then begin (Parent as TLookOutPage).DownArrowClick(self); R := Parent.ClientRect; R := Rect(R.Left,R.Bottom-bHeight,R.Right,R.Bottom); InvalidateRect(Parent.Handle,@R,False); Parent.Update; end; end; { TCustomLookOutButton } constructor TCustomLookOutButton.Create(AOwner:TComponent); begin inherited Create(AOwner); ControlStyle := [csCaptureMouse,csClickEvents]; FButtonBorder := bbDark; FPImSize := True; FImageSize := isLarge; FFillColor := clNone; FSpacing := 4; FOffset := 0; FStayDown := False; FHiFont := TFont.Create; FHiFont.Assign(Font); Width := 60; Height := 60; FLargeImageChangeLink := TChangeLink.Create; FSmallImageChangeLink := TChangeLink.Create; FLargeImageChangeLink.OnChange := ImageListChange; FSmallImageChangeLink.OnChange := ImageListChange; end; destructor TCustomLookOutButton.Destroy; begin if Assigned(FEdit) then FEdit.Free; FLargeImageChangeLink.Free; FSmallImageChangeLink.Free; FHiFont.Free; inherited Destroy; end; procedure TCustomLookOutButton.Click; begin inherited Click; end; procedure TCustomLookOutButton.EditCaption; begin if not Assigned(FEdit) then begin FEdit := TLookOutEdit.Create(nil); FEdit.Parent := self.Parent; FEdit.Visible := false; end; FEdit.SetBounds(Left + FTextRect.Left,Top + FTextRect.Top, Width,FTextRect.Bottom - FTextRect.Top); with FEdit do begin Text := FCaption; BorderStyle := bsNone; AutoSelect := True; OnKeyPress := EditKeydown; OnMouseDown := EditMouseDown; if not Visible then Show; SetFocus; SetCapture(FEdit.Handle); SelStart := 0; SelLength := Length(FCaption); end; end; procedure TCustomLookOutButton.DoOnEdited(var Caption:string); begin if Assigned(FOnEdited) then FOnEdited(self,Caption); end; procedure TCustomLookOutButton.EditKeyDown(Sender: TObject; var Key: Char); var aCaption:string;Modify:boolean; begin Modify := False; if (Sender = FEdit) then case Key of #13: begin aCaption := FEdit.Text; DoOnEdited(aCaption); FEdit.Text := aCaption; Key := #0; Modify := True; if FEdit.Handle = GetCapture then ReleaseCapture; FEdit.Hide; FEdit.Free; FEdit := nil; Screen.Cursor := crDefault; end; #27: begin Key := #0; if FEdit.Handle = GetCapture then ReleaseCapture; FEdit.Hide; FEdit.Free; FEdit := nil; Screen.Cursor := crDefault; end; end; { case } if Modify then FCaption := aCaption; end; procedure TCustomLookOutButton.EditMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if Assigned(FEdit) then begin if not PtInRect(FEdit.ClientRect,Point(X,Y)) or ((Button = mbRight) and FEdit.Visible) then begin if FEdit.Handle = GetCapture then ReleaseCapture; Screen.Cursor := crDefault; FEdit.Hide; FEdit.Free; FEdit := nil; end else begin ReleaseCapture; Screen.Cursor := crIBeam; SetCapture(FEdit.Handle); end; end; end; procedure TCustomLookOutButton.Assign(Source:TPersistent); begin if Source is TCustomLookOutButton then begin Offset := TCustomLookOutButton(Source).Offset; Height := TCustomLookOutButton(Source).Height; Width := TCustomLookOutButton(Source).Width; ButtonBorder := TCustomLookOutButton(Source).ButtonBorder; Caption := TCustomLookOutButton(Source).Caption; Centered := TCustomLookOutButton(Source).Centered; Down := TCustomLookOutButton(Source).Down; Font := TCustomLookOutButton(Source).Font; HiLiteFont := TCustomLookOutButton(Source).HiLiteFont; ParentImageSize := TCustomLookOutButton(Source).ParentImageSize; ImageSize := TCustomLookOutButton(Source).ImageSize; ImageIndex := TCustomLookOutButton(Source).ImageIndex; LargeImages := TCustomLookOutButton(Source).LargeImages; SmallImages := TCustomLookOutButton(Source).SmallImages; Spacing := TCustomLookOutButton(Source).Spacing; Exit; end; inherited Assign(Source); end; procedure TCustomLookOutButton.CMDialogChar(var Message: TCMDialogChar); begin with Message do if IsAccel(CharCode, FCaption) and Enabled then begin Click; Result := 1; end else inherited; end; procedure TCustomLookOutButton.SetGroupIndex(Value:integer); begin if FGroupIndex <> Value then begin FGroupIndex := Value; UpdateExclusive; end; end; procedure TCustomLookOutButton.UpdateExclusive; var Msg: TMessage; begin if (FGroupIndex <> 0) and (Parent <> nil) then begin Msg.Msg := CM_LOOKOUTBUTTONPRESSED; Msg.WParam := FGroupIndex; Msg.LParam := Longint(Self); Msg.Result := 0; Parent.Broadcast(Msg); end; end; procedure TCustomLookOutButton.SetCentered(Value:boolean); begin if FCentered <> Value then begin FCentered := Value; Repaint; end; end; procedure TCustomLookOutButton.SetDown(Value:boolean); begin if FStayDown <> Value then begin FStayDown := Value; if FStayDown then begin FInsideButton := True; FDown := True; end else FDown := False; if FStayDown then UpdateExclusive; Invalidate; end; end; procedure TCustomLookOutButton.SetOffset(Value:integer); begin if FOffset <> Value then FOffset := Value; end; procedure TCustomLookOutButton.SetCaption(Value:TCaption); begin if FCaption <> Value then begin FCaption := Value; Invalidate; end; end; procedure TCustomLookOutButton.SetButtonBorder(Value:TButtonBorder); begin if FButtonBorder <> Value then begin FButtonBorder := Value; Invalidate; end; end; procedure TCustomLookOutButton.SetSmallImages(Value:TImageList); begin if FSmallImages <> nil then FSmallImages.UnRegisterChanges(FSmallImageChangeLink); FSmallImages := Value; if FSmallImages <> nil then FSmallImages.RegisterChanges(FSmallImageChangeLink); Repaint; end; procedure TCustomLookOutButton.SetLargeImages(Value:TImageList); begin if Assigned(FLargeImages) then FLargeImages.UnRegisterChanges(FLargeImageChangeLink); FLargeImages := Value; if Assigned(FLargeImages) then FLargeImages.RegisterChanges(FLargeImageChangeLink); Repaint; end; procedure TCustomLookOutButton.SetImageIndex(Value:integer); begin if FImageIndex <> Value then begin FImageIndex := Value; Invalidate; end; end; procedure TCustomLookOutButton.SetImageSize(Value:TImageSize); begin if FImageSize <> Value then begin FImageSize := Value; if csDesigning in ComponentState then SetPImSize(False); Invalidate; end; end; procedure TCustomLookOutButton.SetFillColor(Value:TColor); begin if FFillColor <> Value then begin FFillColor := Value; Repaint; end; end; procedure TCustomLookOutButton.SetHiFont(Value:TFont); begin FHiFont.Assign(Value); if FHiFont <> Font then Invalidate; end; procedure TCustomLookOutButton.SetSpacing(Value:integer); begin if FSpacing <> Value then begin FSpacing := Value; Invalidate; end; end; procedure TCustomLookOutButton.SetPImSize(Value:boolean); begin FPImSize := Value; if FPImSize and (Parent is TLookOutPage) then SetImageSize((Parent as TLookOutPage).ImageSize); end; procedure TCustomLookOutButton.Paint; var R:TRect;Flags,h:integer; begin R := GetClientRect; with Canvas do begin if csDesigning in ComponentState then begin Brush.Color := clBlack; FrameRect(R); end; if (FImageSize = isSmall) and Assigned(FSmallImages) then begin FImageRect.Left := FSpacing; FImageRect.Right := FImageRect.Left + FSmallImages.Width; FImageRect.Top := (Height - FSmallImages.Height) div 2; FImageRect.Bottom := FImageRect.Top + FSmallImages.Height; end else if Assigned(FLargeImages) then begin FImageRect.Left := (Width - FLargeImages.Width) div 2; FImageRect.Right := FImageRect.Left + FLargeImages.Width; FImageRect.Top := FSpacing; FImageRect.Bottom := FImageRect.Top + FLargeImages.Height; end; PaintFrame; Flags := DT_END_ELLIPSIS or DT_EDITCONTROL; if (FImageSize = isSmall) and Assigned(FSmallImages) then begin DrawSmallImages; Flags := Flags or DT_VCENTER or DT_SINGLELINE; // W := FSmallImages.Width; end else if (FImageSize = isLarge) and Assigned(FLargeImages) then begin DrawLargeImages; // W := FLargeImages.Width; Flags := Flags or DT_WORDBREAK or DT_CENTER; end; end; { draw text } if Length(Caption) > 0 then begin if FInsideButton then Canvas.Font := FHiFont else Canvas.Font := Font; // W := FSpacing + W; SetBkMode(Canvas.Handle,Windows.Transparent); R := GetClientRect; if (ImageSize = isLarge) and Assigned(FLargeImages) then R.Top := R.Top + FLargeImages.Height + (FSpacing * 2) else if (ImageSize = isSmall) and Assigned(FSmallImages) then R.Left := R.Left + FSmallImages.Width + (FSpacing * 3) else Flags := DT_END_ELLIPSIS or DT_EDITCONTROL or DT_WORDBREAK or DT_CENTER or DT_VCENTER; if FDown then OffsetRect(R,FOffset,FOffset); FTextRect := R; h := DrawText(Canvas.Handle,PChar(Caption),-1,FTextRect,Flags or DT_CALCRECT); if (ImageSize = isLarge) then begin FTextRect.Top := R.Top; FTextRect.Bottom := FTextRect.Top + h; FTextRect.Right := R.Left + Canvas.TextWidth(Caption); end else begin FTextRect.Top := (Height - Canvas.TextHeight(Caption)) div 2; FTextRect.Bottom := FTextRect.Top + Canvas.TextHeight(Caption); FTextRect.Right := R.Left + Canvas.TextWidth(Caption); end; DrawText(Canvas.Handle,PChar(Caption),-1,R,Flags); end; end; procedure TCustomLookOutButton.DrawSmallImages; begin if FDown then OffsetRect(FImageRect,FOffset,FOffset); FSmallImages.Draw(Canvas,FImageRect.Left,FImageRect.Top,FImageIndex); { ImageList_DrawEx(FSmallImages.Handle,FImageIndex,Canvas.Handle, FImageRect.Left,FImageRect.Top,0,0,clNone,clNone,ILD_TRANSPARENT);} end; procedure TCustomLookOutButton.DrawLargeImages; begin if FDown then OffsetRect(FImageRect,FOffset,FOffset); FLargeImages.Draw(Canvas,FImageRect.Left,FImageRect.Top,FImageIndex); { ImageList_DrawEx(FLargeImages.Handle,FImageIndex,Canvas.Handle, FImageRect.Left,FImageRect.Top,0,0,clNone,clNone,ILD_TRANSPARENT);} end; procedure TCustomLookOutButton.PaintFrame; var R:TRect; begin R := GetClientRect; if csDesigning in ComponentState then begin Canvas.Brush.Color := clBlack; Canvas.FrameRect(R); end; if not Enabled then Exit; if (FInsideButton or (csDesigning in ComponentState)) then begin if (FFillColor = clNone) then begin R := FImageRect; InflateRect(R,Spacing,Spacing); end else begin { fill it up! } Canvas.Brush.Color := FFillColor; Windows.FillRect(Canvas.Handle,R,Canvas.Brush.Handle); end; if FDown then begin if FButtonBorder = bbDark then Frame3D(Canvas,R,cl3DDkShadow,clBtnFace,1) else if FButtonBorder = bbLight then Frame3D(Canvas,R,clBtnShadow,clBtnHighLight,1) else Frame3D(Canvas,R,cl3DDkShadow,clBtnHighLight,1) end else case FButtonBorder of bbDark:Frame3D(Canvas,R,clBtnFace,cl3DDkShadow,1); bbLight:Frame3D(Canvas,R,clBtnHighLight,clBtnShadow,1); else Frame3D(Canvas,R,clBtnHighLight,cl3DDkShadow,1); end; end; end; procedure TCustomLookOutButton.ImageListChange(Sender: TObject); begin Invalidate; end; procedure TCustomLookOutButton.WMEraseBkgnd(var M : TWMEraseBkgnd); begin inherited; end; procedure TCustomLookOutButton.CMParentImageSizeChanged(var Message:TMessage); var FTmp:boolean; begin if (Message.LParam <> Longint(self)) and FPImSize then begin FTmp := FPImSize; SetImageSize(TImageSize(Message.WParam)); FPImSize := FTmp; end; end; procedure TCustomLookOutButton.CMButtonPressed(var Message: TMessage); var Sender: TCustomLookOutButton; begin if Message.WParam = FGroupIndex then begin Sender := TCustomLookOutButton(Message.LParam); if Sender <> Self then begin if Sender.Down and FDown then begin FStayDown := False; FDown := false; FInsideButton := false; Invalidate; end; end; end; end; procedure TCustomLookOutButton.MouseEnter; begin if Assigned(FMouseEnter) then FMouseEnter(Self); end; procedure TCustomLookOutButton.MouseExit; begin if Assigned(FMouseExit) then FMouseExit(Self); end; procedure TCustomLookOutButton.CMMouseEnter(var Message: TMessage); begin inherited; MouseEnter; if not FInsideButton then begin FInsideButton := True; if FFillColor = clNone then PaintFrame else Invalidate; end; end; procedure TCustomLookOutButton.CMMouseLeave(var Message: TMessage); begin inherited; MouseExit; if FInsideButton and not FStayDown then begin FInsideButton:= False; Invalidate; end; end; procedure TCustomLookOutButton.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); var tmp:TPoint;Msg:TMsg; begin if Parent is TLookOutPage then TLookOutPage(Parent).ActiveButton := self; inherited MouseDown(Button, Shift, X, Y); if (Button = mbRight) then begin if Assigned(FPopUpMenu) then begin { calc where to put menu } tmp := ClientToScreen(Point(X, Y)); FPopUpMenu.PopupComponent := self; FPopUpMenu.Popup(tmp.X, tmp.Y); { wait 'til menu is done } while PeekMessage(Msg, 0, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE) do ; end; { release button } if not FStayDown then FDown := False; end else if FInsideButton and (Button = mbLeft) then FDown := True else if not FStayDown then FDown := False; if FGroupIndex <> 0 then SetDown(not FStayDown); if (FOffset = 0) then PaintFrame else Invalidate; // Parent.Update; end; procedure TCustomLookOutButton.MouseMove(Shift: TShiftState; X, Y: Integer); var Msg:TMessage; begin inherited MouseMove(Shift, X, Y); if PtInRect(GetClientRect,Point(X,Y)) then { entire button } begin if not FInsideButton then begin FInsideButton := True; { notify others } Msg.Msg := CM_LEAVEBUTTON; Msg.WParam := 0; Msg.LParam := Longint(self); Msg.Result := 0; Invalidate; Parent.Broadcast(Msg); end; end else if FInsideButton then begin FInsideButton := False; Invalidate; end; end; procedure TCustomLookOutButton.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin inherited MouseUp(Button, Shift, X, Y); if FDown and not FStayDown then begin FDown := False; if (FOffset = 0) then PaintFrame else Invalidate; // Parent.Update; end; end; procedure TCustomLookOutButton.CMLeaveButton(var Msg:TMessage); begin if (Msg.LParam <> longint(self)) and FInsideButton and not FStayDown then begin FInsideButton := False; // FDown := False; Invalidate; end; end; procedure TCustomLookOutButton.SetParent(AParent: TWinControl); begin if (AParent <> Parent) then begin if (Parent <> nil) and (Parent is TLookOutPage) then TLookOutPage(Parent).FButtons.Delete(TLookOutPage(Parent).FButtons.IndexOf(self)); if (AParent <> nil) and (AParent is TLookOutPage) then TLookOutPage(AParent).FButtons.Add(self); end; inherited SetParent(AParent); end; procedure TCustomLookOutButton.Notification(AComponent: TComponent; Operation: TOperation); begin inherited Notification(AComponent,Operation); if Operation = opRemove then begin if AComponent = FSmallImages then FSmallImages := nil; if AComponent = FLargeImages then FLargeImages := nil; if AComponent = FPopUpMenu then FPopUpMenu := nil; end; Invalidate; end; {$IFDEF D4_AND_UP } procedure TCustomLookOutButton.ActionChange(Sender: TObject; CheckDefaults: Boolean); begin if Action is TCustomAction then with TCustomAction(Sender) do begin if not CheckDefaults or (Self.Caption = '') then Self.Caption := Caption; if not CheckDefaults or (Self.Enabled = True) then Self.Enabled := Enabled; if not CheckDefaults or (Self.Hint = '') then Self.Hint := Hint; if not CheckDefaults or (Self.ImageIndex = -1) then Self.ImageIndex := ImageIndex; if not CheckDefaults or (Self.Visible = True) then Self.Visible := Visible; if not CheckDefaults or not Assigned(Self.OnClick) then Self.OnClick := OnExecute; end; end; {$ENDIF } { TExpressButton } constructor TExpressButton.Create(AOwner:TComponent); begin inherited Create(AOwner); FillColor := clBtnFace; Offset := 1; FButtonBorder := bbLight; FHiFont.Color := clBlack; Font.Color := clWhite; end; { TLookOutPage } constructor TLookOutPage.Create(AOwner:TComponent); begin inherited Create(AOwner); ControlStyle := [csAcceptsControls,csCaptureMouse,csSetCaption]; Color := clBtnShadow; FScrolling := 0; FCaption := 'Outlook'; FButtons := TList.Create; FDown := False; FShowPressed := False; SetBounds(0,0,92,100); FInsideButton := False; FHiFont := TFont.Create; FHiFont.Assign(Font); FMargin := 0; FTopControl := 0; FPImSize := True; FAutoRepeat := False; FBitmap := TBitmap.Create; end; destructor TLookOutPage.Destroy; begin if Assigned(FEdit) then FEdit.Free; FUpArrow.Free; FDwnArrow.Free; FBitmap.Free; FHiFont.Free; FButtons.Free; inherited Destroy; end; procedure TLookOutPage.DisableAdjust; begin Inc(FScrolling); end; procedure TLookOutPage.EnableAdjust; begin Dec(FScrolling); end; procedure TLookOutPage.DownArrow; begin if Enabled then DownArrowClick(self); Invalidate; end; procedure TLookOutPage.UpArrow; begin if Enabled then UpArrowClick(self); Invalidate; end; procedure TLookOutPage.ExchangeButtons(Button1,Button2:TCustomLookOutButton); var tmp1:integer; begin tmp1 := Button1.Top; Button1.Top := Button2.Top; Button2.Top := tmp1; FButtons.Exchange(FButtons.IndexOf(Button1),FButtons.IndexOf(Button2)); end; function TLookOutPage.AddButton:TLookOutButton; var i:integer; begin Result := TLookOutButton.Create(Self.Owner); i := ButtonCount; Result.ImageIndex := i; if ButtonCount > 0 then Result.Top := Buttons[i - 1].Top + Buttons[i - 1].Height else Result.Top := bHeight + 1; Result.Parent := self; RequestAlign; if Assigned(FUpArrow) and Assigned(FDwnArrow) then begin FUpArrow.SetZOrder(True); FDwnArrow.SetZOrder(True); end; end; procedure TLookOutPage.DoOnEdited(var Caption:string); begin if self is TExpress then Exit; if Assigned(FOnEdited) then FOnEdited(self,Caption); end; procedure TLookOutPage.EditCaption; begin if Self is TExpress then Exit; if not Assigned(FEdit) then begin FEdit := TLookOutEdit.Create(nil); FEdit.Parent := self; end else if not FEdit.Visible then FEdit.Show; with FEdit do begin Text := FCaption; // BorderStyle := bsNone; SetBounds(0,0,Width,bHeight); AutoSelect := True; OnKeyPress := EditKeydown; OnMouseDown := EditMouseDown; SetFocus; SetCapture(FEdit.Handle); SelStart := 0; SelLength := Length(FCaption); end; end; procedure TLookOutPage.EditMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if Assigned(FEdit) then begin if not PtInRect(FEdit.ClientRect,Point(X,Y)) or ((Button = mbRight) and FEdit.Visible) then begin if FEdit.Handle = GetCapture then ReleaseCapture; Screen.Cursor := crDefault; FEdit.Hide; FEdit.Free; FEdit := nil; end else begin ReleaseCapture; Screen.Cursor := crIBeam; SetCapture(FEdit.Handle); end; end; end; procedure TLookOutPage.EditKeyDown(Sender: TObject; var Key: Char); var aCaption:string;Modify:boolean; begin Modify := False; if (Sender = FEdit) then case Key of #13: begin Key := #0; aCaption := FEdit.Text; DoOnEdited(aCaption); FEdit.Text := aCaption; Modify := True; if FEdit.Handle = GetCapture then ReleaseCapture; FEdit.Hide; FEdit.Free; FEdit := nil; Screen.Cursor := crDefault; end; #27: begin Key := #0; if FEdit.Handle = GetCapture then ReleaseCapture; FEdit.Hide; FEdit.Free; FEdit := nil; Screen.Cursor := crDefault; end; end; { case } if Modify then FCaption := aCaption; end; procedure TLookOutPage.CMDialogChar(var Message: TCMDialogChar); begin with Message do if IsAccel(CharCode, FCaption) and Enabled then begin Click; Result := 1; end else inherited; end; procedure TLookOutPage.SetActiveButton(Value:TCustomLookOutButton); begin if (Value <> nil) and (FActiveButton <> Value) and (Value.Parent = self) then FActiveButton := Value; end; procedure TLookOutPage.SetParent(AParent: TWinControl); begin if (AParent <> Parent) then begin if (Parent <> nil) and (Parent is TLookOut) then TLookOut(Parent).FPages.Delete(TLookOut(Parent).FPages.IndexOf(self)); if (AParent <> nil) and (AParent is TLookOut) then TLookOut(AParent).FPages.Add(self); end; inherited SetParent(AParent); end; procedure TLookOutPage.Notification(AComponent: TComponent; Operation: TOperation); begin inherited Notification(AComponent,Operation); if (Operation = opRemove) then begin if (AComponent = FPopUpMenu) then FPopUpMenu := nil; end; if (Operation = opInsert) then begin if not (csDesigning in ComponentState) and Assigned(FUpArrow) and Assigned(FDwnArrow) then begin FUpArrow.SetZOrder(True); FDwnArrow.SetZOrder(True); end; end; end; procedure TLookOutPage.AlignControls(Control:TControl;var Rect:TRect); begin inherited AlignControls(Control,Rect); end; procedure TLookOutPage.SmoothScroll(aControl:TControl;NewTop,Intervall:integer;Smooth:boolean); begin if Smooth and not (csDesigning in ComponentState) and not (csLoading in ComponentState) then begin if (aControl.Top < NewTop) then if (aControl.Top > 0) then begin while aControl.Top < NewTop do begin aControl.Top := aControl.Top + Intervall; Application.ProcessMessages; end; end else begin while aControl.Top < NewTop do begin aControl.Top := aControl.Top - Intervall; Application.ProcessMessages; end; end else if (aControl.Top > 0) then begin while aControl.Top > NewTop do begin aControl.Top := aControl.Top - Intervall; Application.ProcessMessages; end; end else begin while aControl.Top > NewTop do begin aControl.Top := aControl.Top + Intervall; Application.ProcessMessages; end; end; end; { adjust } aControl.Top := NewTop; Application.ProcessMessages; end; function Compare(Item1,Item2:Pointer):integer; begin Result := TControl(Item1).Top - TControl(Item2).Top; end; procedure TLookOutPage.ScrollChildren(Start:word); var R:TRect;i,x,aCount:integer;{AList:TList;}aControl:TControl; begin if FScrolling <> 0 then Exit; if (csReading in ComponentState) or (csLoading in ComponentState) or (csWriting in ComponentState) or (csDestroying in ComponentState) then Exit; { draw all owned controls } if (ControlCount < 3) then begin if Assigned(FUpArrow) and Assigned(FDwnArrow) then begin FUpArrow.Visible := False; FDwnArrow.Visible := False; end; Exit; end; R := GetClientRect; x := Width; aCount := GetButtonCount; if aCount = 0 then Exit; FButtons.Sort(Compare); for i := 0 to aCount - 1 do begin aControl := FButtons[i]; if not aControl.Visible then Continue; if aControl.Align <> alNone then aControl.Align := alNone; if (i < FTopControl) then aControl.Top := -(aControl.Height+1) * (aCount - i) else if (Start > Height) then aControl.Top := (Height + 1) * (i + 1) else begin aControl.Top := Start + FMargin; Inc(Start,(aControl.Height + FMargin)); end; if FAutoCenter then aControl.Left := (x - aControl.Width) div 2; end; end; procedure TLookOutPage.CreateWnd; var R:TRect; begin inherited CreateWnd; R := GetClientRect; if not Assigned(FUpArrow) then begin FUpArrow := TUpArrowBtn.Create(nil); FUpArrow.Parent := self; end; if not Assigned(FDwnArrow) then begin FDwnArrow := TDownArrowBtn.Create(nil); FDwnArrow.Parent := self; end; with FUpArrow do begin Visible := False; SetBounds(R.Right - 23,R.Top + 25,16,16); SetZorder(True); end; with FDwnArrow do begin Visible := False; SetBounds(R.Right - 23,R.Bottom - 23,16,16); SetZorder(True); end; if Assigned(Parent) and (Parent is TLookOut) then begin FManager := TLookOut(Parent); FOnCollapse := FManager.FOnCollapse; end; end; procedure TLookOutPage.Click; begin if not Enabled then Exit; if Assigned(FOnCollapse) then FOnCollapse(Self); inherited Click; end; procedure TLookOutPage.CMEnabledChanged(var Message: TMessage); begin if not (Assigned(FUpArrow) or Assigned(FDwnArrow)) then Exit; if not(Enabled) then begin FUpArrow.Enabled := False; FDwnArrow.Enabled := False; end else begin FUpArrow.Enabled := True; FDwnArrow.Enabled := True; end; inherited; Refresh; end; function TLookOutPage.IsVisible(Control:TControl):boolean; var R:TRect; begin Result := False; if (Control = nil) then Exit; R := GetClientRect; Result := (PtInRect(R,Point(R.Left + 1,Control.Top)) and PtInRect(R,Point(R.Left + 1,Control.Top + Control.Height))); end; procedure TLookOutPage.SetAutoRepeat(Value:boolean); begin if FAutoRepeat <> Value then begin FAutoRepeat := Value; if Assigned(FUpArrow) and Assigned(FDwnArrow) then begin FUpArrow.AutoRepeat := FAutoRepeat; FDwnArrow.AutoRepeat := FAutoRepeat; end; end; end; procedure TLookOutPage.SetHiFont(Value:TFont); begin FHiFont.Assign(Value); if FHiFont <> Font then DrawTopButton; end; procedure TLookOutPage.SetButton(Index:integer;Value:TLookOutButton); begin FButtons[Index] := Value; end; function TLookOutPage.GetButton(Index:integer):TLookOutButton; begin Result := TLookOutButton(FButtons[Index]); end; function TLookOutPage.GetButtonCount:integer; begin Result := FButtons.Count; end; procedure TLookOutPage.SetAutoCenter(Value:boolean); begin if FAutoCenter <> Value then begin FAutoCenter := Value; if FAutoCenter then ScrollChildren(bHeight + 7 - FMargin); end; end; procedure TLookOutPage.SetMargin(Value:integer); begin if FMargin <> Value then begin FMargin := Value; Repaint; end; end; procedure TLookOutPage.SetImageSize(Value:TImageSize); var Message:TMessage; begin if FImageSize <> Value then begin FImageSize := Value; if csDesigning in ComponentState then SetPImSize(False); { notify children } Message.Msg := CM_IMAGESIZECHANGED; Message.WParam := Longint(Ord(FImageSize)); Message.LParam := Longint(self); Message.Result := 0; if Parent <> nil then Parent.Broadcast(Message); Broadcast(Message); end; end; procedure TLookOutPage.SetPImSize(Value:boolean); begin FPImSize := Value; if FPImSize and (FManager <> nil) then SetImageSize(FManager.ImageSize); end; procedure TLookOutPage.CMParentImageSizeChanged(var Message:TMessage); var FTmp:boolean; begin if (Message.LParam <> Longint(self)) and FPImSize then begin FTmp := FPImSize; SetImageSize(TImageSize(Message.WParam)); FPImSize := FTmp; end; end; procedure TLookOutPage.SetBitmap(Value:TBitmap); begin FBitmap.Assign(Value); if FBitmap.Empty then ControlStyle := ControlStyle - [csOpaque] else ControlStyle := ControlStyle + [csOpaque]; // RecreateWnd; Invalidate; end; procedure TLookOutPage.SetCaption(Value:TCaption); begin FCaption := Value; Invalidate; end; { determine if arrows should be visible } procedure TLookOutPage.CalcArrows; var i:integer;R:TRect;AList:TList; begin if Assigned(FUpArrow) and Assigned(FDwnArrow) then begin if Height < 65 then begin // FUpArrow.Visible := False; // FDwnArrow.Visible := False; FDwnArrow.Top := FUpArrow.Top + 16; Exit; end; R := GetClientRect; FUpArrow.SetBounds(R.Right - 23,R.Top + 25,16,16); FDwnArrow.SetBounds(R.Right - 23,R.Bottom - 23,16,16); AList := TList.Create; try for i := 0 to ControlCount - 1 do begin if (Controls[i] = FUpArrow ) or (Controls[i] = FDwnArrow ) or (Controls[i] = FEdit) then Continue; if not Controls[i].Visible and not (csDesigning in ComponentState) then Continue; AList.Insert(AList.Count,Controls[i]); end; if AList.Count = 0 then Exit; AList.Sort(Compare); FDwnArrow.Visible := not IsVisible(AList.Items[AList.Count - 1]); FUpArrow.Visible := not IsVisible(AList.Items[0]); finally AList.Free; end; end; end; procedure TLookOutPage.UpArrowClick(Sender:TObject); begin if (FScrolling = 0) and (FTopControl > 0) then Dec(FTopControl); end; procedure TLookOutPage.DownArrowClick(Sender:TObject); begin if (FScrolling = 0) and (FTopControl < ControlCount - 3) then Inc(FTopControl); end; procedure TLookOutPage.Paint; begin inherited Paint; if not FBitmap.Empty then begin ControlStyle := ControlStyle + [csOpaque]; TileBitmap; end else ControlStyle := ControlStyle - [csOpaque]; DrawTopButton; CalcArrows; ScrollChildren(bHeight + 7 - FMargin); end; procedure TLookOutPage.DrawTopButton; var R,R2:TRect;DC:hDC;FFlat,FPush:boolean; begin if FInsideButton then Canvas.Font := FHiFont else Canvas.Font := self.Font; Canvas.Brush.Color := clBtnFace; DC := Canvas.Handle; R := GetClientRect; { draw top button } R.Bottom := bHeight; Canvas.FillRect(R); FPush := FShowPressed and FDown; FFlat := Assigned(FManager) and (FManager.FFlatButtons); if FFlat then begin if FManager.ActivePage = self then begin R2 := GetClientRect; R2.Top := R.Bottom; Frame3d(Canvas,R2,cl3DDkShadow,clBtnFace,1); end; if FPush then Frame3D(Canvas,R,clBtnShadow,clBtnHighlight,1) else if FInsideButton then begin Frame3D(Canvas,R,clBtnHighLight,cl3DDkShadow,1); Frame3D(Canvas,R,clBtnFace,clBtnShadow,1); end else Frame3D(Canvas,R,clBtnHighlight,clBtnShadow,1) end else begin if FPush then begin Frame3D(Canvas,R,cl3DDkShadow,clBtnHighlight,1); Frame3D(Canvas,R,clBtnShadow,clBtnFace,1); end else begin Frame3D(Canvas,R,clBtnHighlight,cl3DDkShadow,1); Frame3D(Canvas,R,clBtnFace,clBtnShadow,1); end; end; { draw top caption } R := GetClientRect; R.Bottom := bHeight; SetBkMode(DC,Windows.Transparent); if FCaption <> '' then begin if not Enabled then begin { draw disabled text } SetTextColor(DC,ColorToRGB(clBtnHighLight)); OffsetRect(R,1,1); DrawText(DC, PChar(FCaption), Length(FCaption), R, DT_CENTER or DT_VCENTER or DT_SINGLELINE); OffsetRect(R,-1,-1); SetTextColor(DC,ColorToRGB(clBtnShadow)); end else SetTextColor(DC,ColorToRGB(Canvas.Font.Color)); if FShowPressed and FDown then OffsetRect(R,1,1); DrawText(DC, PChar(FCaption), Length(FCaption), R, DT_CENTER or DT_VCENTER or DT_SINGLELINE); end; end; procedure TLookOutPage.TileBitmap; var X, Y, W, H: LongInt; Dest,Source:TRect; Tmp:TBitmap; begin if not FBitmap.Empty then begin with FBitmap do begin W := Width; H := Height; end; Tmp := TBitmap.Create; Tmp.Width := Width; Tmp.Height := Height; Y := 0; Source := Rect(0,0,W,H); while y < Height do begin X := 0; while X < Width do begin Dest := Rect(X,Y,X+W,Y+H); Tmp.Canvas.CopyRect(Dest,FBitmap.Canvas,Source); Inc(X, W); end; Inc(Y, H); end; Canvas.Draw(0,0,Tmp); Tmp.Free; end; end; procedure TLookOutPage.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); var R:TRect;tmp:TPoint;Msg:TMsg; begin inherited MouseDown(Button, Shift, X, Y); if Assigned(FPopUpMenu) and (Button = mbRight) then begin { calc where to put menu } tmp := ClientToScreen(Point(X, Y)); FPopUpMenu.PopupComponent := self; FPopUpMenu.Popup(tmp.X, tmp.Y); { wait 'til menu is done } while PeekMessage(Msg, 0, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE) do ; FDown := False; end else begin R := GetClientRect; R.Bottom := bHeight; if PtInRect(R,Point(X,Y)) and (Button = mbLeft) then begin FDown := True; DrawTopButton; end; end; end; procedure TLookOutPage.MouseMove(Shift: TShiftState; X, Y: Integer); var R:TRect; begin R := GetClientRect; R.Bottom := bHeight; if PtInRect(R,Point(X,Y)) then begin if not FInsideButton then begin FInsideButton := True; DrawTopButton; end end else if FInsideButton or FDown then begin FInsideButton := False; // FDown := False; DrawTopButton; end; inherited MouseMove(Shift, X, Y); end; procedure TLookOutPage.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); var R:TRect; begin inherited MouseUp(Button, Shift, X, Y); if not Enabled then Exit; FDown := False; R := GetClientRect; R.Bottom := bHeight; if PtInRect(R,Point(X,Y)) and (Button = mbLeft) then begin if Assigned(FOnCollapse) then FOnCollapse(self); if Assigned(FOnClick) then FOnClick(self); end; DrawTopButton; end; procedure TLookOutPage.CMMouseLeave(var Message: TMessage); begin inherited; if FInsideButton then begin FInsideButton:= False; // FDown := False; DrawTopButton; end; end; procedure TLookOutPage.WMEraseBkGnd(var Message: TWMEraseBkGnd); begin Message.Result := 1; end; { TLookOut} procedure TLookOut.SetFlatButtons(Value:boolean); // var i:integer; begin if FFlatButtons <> Value then begin FFlatButtons := Value; // for i := 0 to PageCount - 1 do // Pages[i].DrawTopButton; RecreateWnd; end; end; constructor TLookOut.Create(AOwner:TComponent); begin inherited Create(AOwner); ControlStyle := [csAcceptsControls, csCaptureMouse, csClickEvents, csSetCaption, csOpaque]; FPages := TList.Create; Width := 92; Height := 300; FBorderStyle := bsSingle; FAutoSize := False; FScroll := False; FFlatButtons := false; Color := clBtnFace; FOnCollapse := DoCollapse; FImageSize := isLarge; end; destructor TLookOut.Destroy; begin FPages.Free; inherited Destroy; end; function TLookOut.AddPage:TLookOutPage; begin Result := TLookOutPage.Create(self.Owner); Result.Parent := self; Result.Top := PageCount * bHeight; end; procedure TLookOut.Notification(AComponent:TComponent;Operation:TOperation); var i:integer; begin inherited Notification(AComponent,Operation); if (Operation = opRemove) then begin if (AComponent = FActivePage) then FActivePage := nil; if (AComponent) = FCurrentPage then FCurrentPage := nil; if (AComponent is TLookoutPage) and (TLookOutPage(AComponent).Parent = self) then begin i := FPages.IndexOf(AComponent); if i > -1 then FPages.Delete(i); end; end else // insertion if (AComponent is TLookoutPage) and (TLookoutPage(AComponent).Parent = self) then begin if FPages.IndexOf(AComponent) = -1 then FPages.Add(AComponent); end; // if Canvas <> nil then Invalidate; end; procedure TLookOut.UpdateControls; begin if FCollapsing then Exit; if (FCurrentPage <> nil) then DoCollapse(FCurrentPage) else if (FActivePage <> nil) then DoCollapse(FActivePage) else if (ControlCount > 0) and (Controls[0] is TLookOutPage) then DoCollapse(Controls[0]); end; procedure TLookOut.SetAutoSize(Value:boolean); begin if FAutoSize <> Value then begin FAutoSize := Value; if FAutoSize then UpdateControls; end; end; procedure TLookOut.SetImageSize(Value:TImageSize); var Message:TMessage; begin if FImageSize <> Value then begin FImageSize := Value; { notify children } Message.Msg := CM_IMAGESIZECHANGED; Message.WParam := Longint(Ord(FImageSize)); Message.LParam := Longint(self); Message.Result := 0; Broadcast(Message); end; end; procedure TLookOut.SetBorderStyle(Value:TBorderStyle); begin if FBorderStyle <> Value then begin FBorderStyle := Value; RecreateWnd; end; end; { calculate which TLookOutPage should be visible and which should not } procedure TLookOut.DoCollapse(Sender:TObject); var C:TControl; done:boolean; vis,i,ht,ofs,bh,cc,flt:integer; begin FCollapsing := true; if Sender is TLookOutPage then begin FCurrentPage := TLookOutPage(Sender); FActivePage := FCurrentPage; FCurrentPage.DrawTopButton; end; if Assigned(FOnClick) then FOnClick(Sender); cc := ControlCount - 1; done := false; ht := Height; vis := 0; ofs := 0; { make sure non-visible pages don't mess up the display } for i := 0 to cc do if Controls[i].Visible then Inc(vis); if Height <= (bHeight * vis) + 65 then Exit; if FFlatButtons then flt := 2 else flt := 4; for i := 0 to cc do begin C := Controls[i]; if not C.Visible then begin Inc(ofs); Continue; end; C.Align := alNone; bh := bHeight + 1; if FAutoSize then C.SetBounds(0,C.Top,Width-flt,C.Height); C.Height := ht - (vis - 1) * bh; if (C = Sender) then done := true; if (C = Sender) or (i = 0) then { first or caller } SmoothScroll(C,(i - ofs) * bh,ScrollSpeed,FScroll) else if done and (C <> Sender) then { place at bottom } SmoothScroll(C,ht - (vis - i + ofs ) * bh - flt + 1,ScrollSpeed,FScroll) else { place at top } SmoothScroll(C,(i - ofs) * bh,ScrollSpeed,FScroll); end; FCollapsing := false; end; procedure TLookOut.SmoothScroll(aControl:TControl;NewTop,Intervall:integer;Smooth:boolean); begin if Smooth and not (csDesigning in ComponentState) then begin if aControl.Top < NewTop then while aControl.Top < NewTop do begin aControl.Top := aControl.Top + Intervall; Application.ProcessMessages; end else while aControl.Top > NewTop do begin aControl.Top := aControl.Top - Intervall; Application.ProcessMessages; end; end; { adjust } aControl.Top := NewTop; Application.ProcessMessages; end; procedure TLookOut.SetActiveOutLook(Value:TLookOutPage); var i:integer; begin if (FActivePage = Value) or FCollapsing then Exit; if (Value <> nil) and (Value.Parent = self) and (Value.Visible) then DoCollapse(Value) else if (PageCount > 0) then for i := 0 to PageCount - 1 do if Pages[i].Visible then DoCollapse(Pages[i]) else FActivePage := nil; end; function TLookOut.GetActiveOutlook:TLookOutPage; begin if csDesigning in ComponentState then Result := FActivePage else Result := FCurrentPage; end; function TLookOut.GetPageCount:integer; begin Result := FPages.Count; end; function TLookOut.GetPage(Index:integer):TLookOutPage; begin Result := TLookOutPage(FPages[Index]); end; procedure TLookOut.SetPage(Index:integer;Value:TLookOutPage); begin FPages[Index] := Value; end; procedure TLookOut.WMNCCalcSize(var Message: TWMNCCalcSize); begin with Message.CalcSize_Params^ do if FFlatButtons then InflateRect(rgrc[0], -1, -1) else InflateRect(rgrc[0], -2, -2); inherited; end; procedure TLookOut.WMNCPaint(var Message: TMessage); var DC: HDC; RC, RW: TRect; begin DC := GetWindowDC(Handle); try Windows.GetClientRect(Handle, RC); GetWindowRect(Handle, RW); MapWindowPoints(0, Handle, RW, 2); OffsetRect(RC, -RW.Left, -RW.Top); ExcludeClipRect(DC, RC.Left, RC.Top, RC.Right, RC.Bottom); OffsetRect(RW, -RW.Left, -RW.Top); if FBorderStyle = bsSingle then DrawEdge(DC,RW,EDGE_SUNKEN,BF_RECT) else begin Canvas.Brush.Color := Color; Windows.FrameRect(DC,RW,Canvas.Brush.Handle); InflateRect(RW,-1,-1); Windows.FrameRect(DC,RW,Canvas.Brush.Handle); InflateRect(RW,1,1); end; { Erase parts not drawn } IntersectClipRect(DC, RW.Left, RW.Top, RW.Right, RW.Bottom); finally ReleaseDC(Handle, DC); end; end; procedure TLookOut.Paint; begin if not (Visible or (csDesigning in ComponentState)) then Exit; Canvas.Brush.Color := Color; Canvas.FillRect(GetClientRect); { make TLookOuts adjust to Managers size } if (ControlCount > 0) and FAutoSize then UpdateControls; end; { TExpress } constructor TExpress.Create(AOwner:TComponent); begin inherited Create(AOwner); ImageSize := isLarge; FBorderStyle := bsSingle; FTopControl := 0; FButtonHeight := 60; end; procedure TExpress.Paint; begin if not FBitmap.Empty then begin ControlStyle := ControlStyle + [csOpaque]; TileBitmap; end else begin ControlStyle := ControlStyle - [csOpaque]; Canvas.Brush.Color := Color; Canvas.FillRect(GetClientRect); end; CalcArrows; ScrollChildren(0); end; function TExpress.AddButton:TExpressButton; var i:integer; begin Result := TExpressButton.Create(Self.Owner); i := ButtonCount; Result.ImageIndex := i; if ButtonCount > 0 then Result.Top := Buttons[i - 1].Top + Buttons[i - 1].Height else Result.Top := 0; Result.Parent := self; RequestAlign; if Assigned(FUpArrow) and Assigned(FDwnArrow) then begin FUpArrow.SetZOrder(True); FDwnArrow.SetZOrder(True); end; end; { procedure TExpress.SetButton(Index:integer;Value:TExpressButton); begin inherited SetButton(Index,Value); end; function TExpress.GetButton(Index:integer):TExpressButton; begin Result := TExpressButton(inherited GetButton(Index)); end; function TExpress.GetButtonCount:integer; begin inherited GetButtonCount; end; } procedure TExpress.CalcArrows; var i:integer;R:TRect;AList:TList; begin if Assigned(FUpArrow) and Assigned(FDwnArrow) then begin if Height < 65 then begin // FDwnArrow.Top := FUpArrow.Top + 16; Exit; end; R := GetClientRect; AList := TList.Create; try for i := 0 to ControlCount - 1 do begin if (Controls[i] = FUpArrow ) or (Controls[i] = FDwnArrow ) or (Controls[i] = FEdit) then Continue; if not (Controls[i].Visible or (csDesigning in ComponentState)) then Continue; AList.Insert(AList.Count,Controls[i]); end; if AList.Count = 0 then Exit; AList.Sort(Compare); FDwnArrow.Visible := not IsVisible(AList.Items[AList.Count - 1]); FUpArrow.Visible := not IsVisible(AList.Items[0]); finally AList.Free; end; end; end; procedure TExpress.ScrollChildren(Start:word); var i:integer; begin { size all children to width of TExpress } for i := 0 to ControlCount - 1 do if (Controls[i] = FDwnArrow) or (Controls[i] = FUpArrow) or (Controls[i] is TLookoutEdit) then Continue else Controls[i].SetBounds(0,Controls[i].Top,Width - 4,FButtonHeight); if Assigned(FUpArrow) then Start := 12 * Ord(FUpArrow.Visible) else Start := 0; inherited ScrollChildren(Start); end; procedure TExpress.DrawTopButton; begin { do nothing } end; procedure TExpress.SetButtonHeight(Value:integer); var i:integer; begin if FButtonHeight <> Value then begin FButtonHeight := Value; for i := 0 to ButtonCount - 1 do // Iterate Buttons[i].Height := FButtonHeight; end; end; procedure TExpress.WMNCCalcSize(var Message: TWMNCCalcSize); begin with Message.CalcSize_Params^ do InflateRect(rgrc[0], -2, -2); inherited; end; procedure TExpress.CreateWnd; begin inherited CreateWnd; if not Assigned(FUpArrow) then FUpArrow := TUpArrowBtn.Create(nil); if not Assigned(FDwnArrow) then FDwnArrow := TDownArrowBtn.Create(nil); with FUpArrow do begin Parent := self; Flat := True; Height := 13; Align := alTop; SetZOrder(True); end; with FDwnArrow do begin Parent := self; Flat := True; Height := 13; Align := alBottom; SetZOrder(True); end; end; procedure TExpress.WMNCPaint(var Message: TMessage); var DC: HDC; RC, RW: TRect; begin DC := GetWindowDC(Handle); try Windows.GetClientRect(Handle, RC); GetWindowRect(Handle, RW); MapWindowPoints(0, Handle, RW, 2); OffsetRect(RC, -RW.Left, -RW.Top); ExcludeClipRect(DC, RC.Left, RC.Top, RC.Right, RC.Bottom); OffsetRect(RW, -RW.Left, -RW.Top); if FBorderStyle = bsSingle then DrawEdge(DC,RW,EDGE_SUNKEN,BF_RECT) else begin if csDesigning in ComponentState then Canvas.Brush.Color := clBlack else Canvas.Brush.Color := Color; Windows.FrameRect(DC,RW,Canvas.Brush.Handle); InflateRect(RW,-1,-1); if csDesigning in ComponentState then Canvas.Brush.Color := Color; Windows.FrameRect(DC,RW,Canvas.Brush.Handle); InflateRect(RW,1,1); end; { Erase parts not drawn } IntersectClipRect(DC, RW.Left, RW.Top, RW.Right, RW.Bottom); finally ReleaseDC(Handle, DC); end; end; end.
unit UClientFloodInsights; { ClickForms Application } { Bradford Technologies, Inc. } { All Rights Reserved } { Source Code Copyrighted © 1998-2009 by Bradford Technologies, Inc. } { This unit interfaces to the Flood Insightes webservice unit} interface uses Classes, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdHTTP, ExtCtrls, SysUtils,StdCtrls, Graphics, IdException; const Flood_UserWantsMap = 1; Flood_UserWantsDataOnly = 0; type EHTTPCLientError = class(Exception); TFloodInsightClient = class(TComponent) private //added by vivek, this variable is fisrt used with GetMap() and then in GetMapEx to //read the individual candidate info as needed ResponseStr: String; FidHTTP : TidHTTP; FISAPIURL: string; //server URL FAccountID: string; //users account FPin: string; //some pin or access code FMapHeight: Integer; //map height FMapWidth: Integer; //map width FWantsMap: Integer; //=1 gets map; =0 no map is charged to user FipnXMLData: string; //markers for data coming back FipnMapData: string; FipnAccountID: string; //tag names for request data going to server FipnPin: string; FipnIconLabel: string; FipnCity: string; FipnPlus4: string; FipnState: string; FipnStreetAddress: string; FipnZip: string; FipnMapHeight: string; FipnMapWidth: string; FipnOptionalMap: String; //option to charge for map or not //added by Vivek FipnGeoResult: String; FipnCensusBlockID: String; FipnLon: String; FipnLat: String; //10/19/2005 FipnZoom: String; FipnImageID: String; FipnLocPtX: String; FipnLocPtY: String; //Input values FSubjectLabel: string; FSubjectStreetAddress: string; FSubjectCity: string; FSubjectState: string; FSubjectZip: string; FSubjectPlus4: string; //added new by vivek FSubjectLon :String; FSubjectLat :String; FSubjectGeoResult :String; FSubjectCensusBlockID :String; FSubjectMapHeight :String; FSubjectMapWidth :String; //VR 10/19/05 FSubjectImageID :String; FSubjectZoom :String; FSubjectLocPtX :String; FSubjectLocPtY :String; FSubjectImageURL: string; FSubjectImageName: String; //Output values FMapJPEG: TMemoryStream; //jpeg obj of image FCensusTract: string; //result census tract FLongitude: string; //result FLatitude: string; //result FCommunityID: string; //result FCommunityName: string; //result FZone: string; //result FPanel: string; //result FPanelDate: string; //result FFIPSCode: string; //result FSHFAResult: string; //result FSHFANearBy: String; //result FSFHAPhrase: string; //result FZipPlus4: string; //result FMapNumber: String; //result //added by vivek FMulAddressList: TStringList; FGeoResult: String; procedure SetPanelDate(const Value: String); procedure ParseTheXML(XMLStr: String); function BuildMultipleResultList(XMLStr: String): Boolean; function BuildMapQueryStr(XMLStr: String; ListBoxIndex: Integer): String; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; //definitions updated by vivek, MultiAddressList will return the multiple addresses //in case more than one results are found. GetMapEx() will be used for getting the //map for an address from this list. //adds the legends and flood zone text onto the map function FinalizeFloodMap(): boolean; function GetCFDB_Map(IsFloodMap: Boolean=True):String; function GetCFAW_Map():String; function GetCFDB_MapEx(ListBoxIndex: Integer):String; function GetCFAW_MapEx(ListBoxIndex: Integer):String; function GetCFDB_SpottedMap(RequestStr: string): String; function GetCFAW_SpottedMap(RequestStr: string): String; published property AccountID: string read FAccountID write FAccountID; property Pin: string read FPin write FPin; property ISAPIURL: string read FISAPIURL write FISAPIURL; property MapHeight: Integer read FMapHeight write FMapHeight; property MapWidth: Integer read FMapWidth write FMapWidth; property WantsMap: Integer read FWantsMap write FWantsMap; property SubjectLabel: string read FsubjectLabel write FsubjectLabel; property SubjectStreetAddress: string read FsubjectStreetAddress write FsubjectStreetAddress; property SubjectCity: string read FsubjectCity write FsubjectCity; property SubjectState: string read FsubjectState write FsubjectState; property SubjectZip: string read FsubjectZip write FsubjectZip; property SubjectPlus4: string read FsubjectPlus4 write FsubjectPlus4; //added by vivek property SubjectLon: string read FSubjectLon write FSubjectLon; property SubjectLat: string read FSubjectLat write FSubjectLat; property SubjectGeoResult :string read FSubjectGeoResult write FSubjectGeoResult; property SubjectCensusBlockID :string read FSubjectCensusBlockID write FSubjectCensusBlockID; property SubjectMapHeight :string read FSubjectMapHeight write FSubjectMapHeight; property SubjectMapWidth :string read FSubjectMapWidth write FSubjectMapWidth; //10/19/2005 property SubjectImageID :string read FSubjectImageID write FSubjectImageID; property SubjectZoom :string read FSubjectZoom write FSubjectZoom; property SubjectLocPtX :string read FSubjectLocPtX write FSubjectLocPtX; property SubjectLocPtY :string read FSubjectLocPtY write FSubjectLocPtY; property SubjectImageURL :string read FSubjectImageURL write FSubjectImageURL; property SubjectImageName: String read FSubjectImageName write FSubjectImageName; {results coming back from server} property FloodMap: TMemoryStream read FMapJpeg write FMapJpeg; property CensusTract : string read FCensusTract write FCensusTract; property Longitude: String read FLongitude write FLongitude; property Latitude: String read FLatitude write FLatitude; property CommunityID: String read FCommunityID write FCommunityID; property CommunityName: String read FCommunityName write FCommunityName; property Zone: String read FZone write FZone; property Panel: String read FPanel write FPanel; property PanelDate: String read FPanelDate write SetPanelDate; property FIPSCode: String read FFIPSCode write FFIPSCode; property SHFAResult: String read FSHFAResult write FSHFAResult; property SFHAPhrase: String read FSFHAPhrase write FSFHAPhrase; property SHFANearBy: String read FSHFANearBy write FSHFANearBy; property ZipPlus4: string read FZipPlus4 write FZipPlus4; property MapNumber: String read FMapNumber write FMapNumber; //added by vivek property MulAddressList: TStringList read FMulAddressList write FMulAddressList; property GeoResult: String read FGeoResult write FGeoResult; {Tag Names for the Request Variables} property ipnAccountID : string read FipnAccountID write FipnAccountID; property ipnPin: string read FipnPin write FipnPin; property ipnIconLabel : string read FipnIconLabel write FipnIconLabel; property ipnCity : string read FipnCity write FipnCity; property ipnMapHeight : string read FipnMapHeight write FipnMapHeight; property ipnMapWidth : string read FipnMapWidth write FipnMapWidth; property ipnPlus4 : string read FipnPlus4 write FipnPlus4; property ipnState : string read FipnState write FipnState; property ipnStreetAddress : string read FipnStreetAddress write FipnStreetAddress; property ipnZip : string read FipnZip write FipnZip; property ipnOptionalMap: string read FipnOptionalMap write FipnOptionalMap; //added by vivek property ipnGeoResult: string read FipnGeoResult write FipnGeoResult; property ipnCensusBlockID: string read FipnCensusBlockID write FipnCensusBlockID; property ipnLon: string read FipnLon write FipnLon; property ipnLat: string read FipnLat write FipnLat; property ipnZoom: string read FipnZoom write FipnZoom; property ipnImageID: string read FipnImageID write FipnImageID; property ipnLocPtX: string read FipnLocPtX write FipnLocPtX; property ipnLocPtY: string read FipnLocPtY write FipnLocPtY; {Name of markers in the response string} property ipnMapData : string read FipnMapData write FipnMapData; property ipnXMLData : string read FipnXMLData write FipnXMLData; end; implementation uses Jpeg, XMLIntf, XMLDoc, StrUtils, UWebUtils, UGlobals, UStatus, UUtil3; const FloodMapLegendJPG = 'FloodInsightsLegend.jpg'; SErrorNoAccess = 'Could not access the server.'; SErrorNoISAPIURL = 'ISAPIURL property is blank, assign a valid URL and try again'; { TFloodInsightClient } constructor TFloodInsightClient.Create(AOwner: TComponent); begin inherited Create(AOwner); FloodMap := TMemoryStream.Create; MulAddressList := TStringList.Create; // Defaults FISAPIURL := 'http://localhost/scripts/FloodServer.dll/GetFloodInfo'; FMapWidth := 7150; FMapHeight := 11000; ipnXMLData := 'XMLData'; //marker in response ipnMapData := 'MapData'; //marker in response // ipnAccountID := 'AccountID'; //var names in request // ipnPin := 'Pin'; //changed by vivek ipnAccountID := 'CustomerID'; //var names in request ipnPin := 'CustomerPin'; ipnIconLabel := 'txtText'; ipnStreetAddress := 'txtStreet'; ipnCity := 'txtCity'; ipnState := 'txtState'; ipnZip := 'txtZip'; ipnPlus4 := 'txtPlus4'; ipnMapWidth := 'txtMapWidth'; ipnMapHeight := 'txtMapHeight'; ipnOptionalMap := 'txtReturnMap'; //added by Vivek ipnGeoResult := 'txtGeoResult'; ipnCensusBlockID := 'txtCensusBlockID'; ipnLon := 'txtLon'; ipnLat := 'txtLat'; //10/19/2005 ipnZoom := 'txtZoom'; ipnImageID := 'txtImageID'; ipnLocPtX := 'txtLocPtX'; ipnLocPtY := 'txtLocPtY'; end; destructor TFloodInsightClient.Destroy; begin FloodMap.Free; //image memory stream MulAddressList.Free; inherited Destroy; end; function TFloodInsightClient.GetCFDB_Map(IsFloodMap: Boolean=True):String; var XMLStr: String; RequestStr: string; XMLDataStartPos : Integer; begin if ISAPIURL = '' then raise EHTTPCLientError.Create(SErrorNoISAPIURL); // The base location of the ISAPI dll on the IIS server. RequestStr := ISAPIURL; // Now start adding the parameters to the QueryStr, separate them with '&'s RequestStr := RequestStr + 'GetFloodInfo?' + ipnAccountID + '=' + URLEncode(AccountID) + '&' + ipnPin + '=' + URLEncode(Pin) + '&' + ipnMapWidth + '=' + IntToStr(MapWidth) + '&' + ipnMapHeight + '=' + IntToStr(MapHeight) + '&' + ipnZoom + '=' + URLEncode(SubjectZoom) + '&' + ipnIconLabel + '=' + URLEncode(SubjectLabel) + '&' + ipnStreetAddress + '=' + URLEncode(SubjectStreetAddress) + '&' + ipnCity + '=' + URLEncode(SubjectCity) + '&' + ipnState + '=' + URLEncode(SubjectState) + '&' + ipnZip + '=' + URLEncode(SubjectZip) + '&' + ipnPlus4 + '=' + URLEncode(SubjectPlus4) + '&' + ipnOptionalMap + '=' + IntToStr(WantsMap); (* txtReturnMap = '1' if we want the map txtReturnMap = '0' if we don't want the map *) (* if demoMode then begin FloodMap.LoadFromFile(ApplicationFolder + 'Samples\SampleFloodMap.jpg'); FloodMap.Position := 0; Result := 'Single'; Exit; end; *) FIdHTTP := TIdHTTP.Create(self); try try if DemoMode then ResponseStr := LoadDemoStringFromFile('DemoFloodMap.txt') else ResponseStr := FidHTTP.Get(RequestStr); //make query, get response // SaveDemoStringToFile(RequestStr,'RequestFloodMap.txt'); //DEMO // SaveDemoStringToFile(ResponseStr,'ResponseFloodMap.txt'); //DEMO // SaveDemoStringToFile(ResponseStr,'DemoFloodMap.txt'); //DEMO if IsFloodMap then begin //check if responsestr is empty return a ERROR msg if Length(ResponseStr) = 0 then begin Result := 'Error'; raise Exception.Create('The flood map was not received. Please check that the correct address was given.'); end; if pos('Notice Code:',ResponseStr) > 0 then //Error Messages from CustDB subscription service are starting with 'Notice Code:' begin Result := srCustDBRspNotAvailable; exit; end; //check if we need to display a message if compareText(ResponseStr, 'SeeMsg') = 0 then //? bradford flood server never return this begin result := ''; exit; end; //check if the response from server is an error if pos('Error: ', ResponseStr) = 1 then //some othe error begin Result := 'Error'; Delete(ResponseStr, 1, length('Error: ')); //get rid of error word if pos('You are not presently recognized as a Flood Maps User', ResponseStr) > 0 then begin result := srCustDBRspNotAvailable; exit; end else raise Exception.Create(ResponseStr); //raise the exception to be shown to user end; end; if (not ((Result = srCustDBRspIsEmpty) or (Result = srCustDBRspIsError) or (Result = srCustDBRspNotAvailable))) then begin //check if the response from server contains multiple result if pos('<?xml', ResponseStr) = 1 then begin Result := 'Multiple'; //parse and show it in the listbox if not BuildMultipleResultList(ResponseStr) then begin Result := 'Error'; raise Exception.Create('Error creating the multiple address result list.'); end; end; //check if the response from server contains the map if pos(ipnXMLData, ResponseStr) = 1 then begin //the response has two parts: XML Data and Jpeg Image, the tags indicate the dividers XMLDataStartPos := Pos(ipnXMLData, ResponseStr) + Length(ipnXMLData) + 1; XMLStr := Copy(ResponseStr, XMLDataStartPos, Pos(ipnMapData, ResponseStr) - XMLDataStartPos - 1); try ParseTheXML(XMLStr); //extract the xml values Result := 'Single'; except begin Result := 'Error'; ShowNotice('There is a problem geo-coding the address. The results may be invalid. Please recheck the address.'); end; end; //find the start of the Image Data and delete everything before it Delete(ResponseStr, 1, Pos(ipnMapData, ResponseStr) + Length(ipnMapData)); if length(ResponseStr) > 0 then //extract the image begin FloodMap.WriteBuffer(ResponseStr[1], Length(ResponseStr)); FloodMap.Position := 0; //add legends and text to the map if not FinalizeFloodMap() then begin result := 'Error'; raise Exception.Create('The flood map was not received. Please check that the correct address was given.'); end else result := 'Single'; end else begin Result := 'Error'; raise Exception.Create('The flood map was not received. Please check that the correct address was given.'); end; end; if pos('Error', ResponseStr) > 0 then begin Result := 'Error'; raise Exception.Create(ResponseStr); end; end; except on E: Exception do begin Result := 'Error'; raise Exception.Create(E.message); end; end; finally FIdHTTP.Free; end; end; function TFloodInsightClient.GetCFAW_Map():String; var XMLStr: String; RequestStr: string; XMLDataStartPos : Integer; begin if ISAPIURL = '' then raise EHTTPCLientError.Create(SErrorNoISAPIURL); // The base location of the ISAPI dll on the IIS server. RequestStr := ISAPIURL; // Now start adding the parameters to the QueryStr, separate them with '&'s RequestStr := RequestStr + 'GetFloodInfo?' + ipnAccountID + '=' + URLEncode(AccountID) + '&' + ipnPin + '=' + URLEncode(Pin) + '&' + ipnMapWidth + '=' + IntToStr(MapWidth) + '&' + ipnMapHeight + '=' + IntToStr(MapHeight) + '&' + ipnZoom + '=' + URLEncode(SubjectZoom) + '&' + ipnIconLabel + '=' + URLEncode(SubjectLabel) + '&' + ipnStreetAddress + '=' + URLEncode(SubjectStreetAddress) + '&' + ipnCity + '=' + URLEncode(SubjectCity) + '&' + ipnState + '=' + URLEncode(SubjectState) + '&' + ipnZip + '=' + URLEncode(SubjectZip) + '&' + ipnPlus4 + '=' + URLEncode(SubjectPlus4) + '&' + ipnOptionalMap + '=' + IntToStr(WantsMap); (* txtReturnMap = '1' if we want the map txtReturnMap = '0' if we don't want the map *) (* if demoMode then begin FloodMap.LoadFromFile(ApplicationFolder + 'Samples\SampleFloodMap.jpg'); FloodMap.Position := 0; Result := 'Single'; Exit; end; *) FIdHTTP := TIdHTTP.Create(self); try try if DemoMode then ResponseStr := LoadDemoStringFromFile('DemoFloodMap.txt') else ResponseStr := FidHTTP.Get(RequestStr); //make query, get response // SaveDemoStringToFile(ResponseStr,'DemoFloodMap.txt'); //DEMO //check if responsestr is empty return a ERROR msg if Length(ResponseStr) = 0 then Result := srCustDBRspIsEmpty else if pos('Error: ', ResponseStr) = 1 then //check if the response from server is an error Result := srCustDBRspIsError else begin //check if the response from server contains multiple result if pos('<?xml', ResponseStr) = 1 then begin Result := 'Multiple'; //parse and show it in the listbox if not BuildMultipleResultList(ResponseStr) then begin Result := 'Error'; raise Exception.Create('Error creating the multiple address result list.'); end; end; //check if the response from server contains the map if pos(ipnXMLData, ResponseStr) = 1 then begin //the response has two parts: XML Data and Jpeg Image, the tags indicate the dividers XMLDataStartPos := Pos(ipnXMLData, ResponseStr) + Length(ipnXMLData) + 1; XMLStr := Copy(ResponseStr, XMLDataStartPos, Pos(ipnMapData, ResponseStr) - XMLDataStartPos - 1); try ParseTheXML(XMLStr); //extract the xml values Result := 'Single'; except begin Result := 'Error'; ShowNotice('There is a problem geo-coding the address. The results may be invalid. Please recheck the address.'); end; end; //find the start of the Image Data and delete everything before it Delete(ResponseStr, 1, Pos(ipnMapData, ResponseStr) + Length(ipnMapData)); if length(ResponseStr) > 0 then //extract the image begin FloodMap.WriteBuffer(ResponseStr[1], Length(ResponseStr)); FloodMap.Position := 0; //add legends and text to the map if not FinalizeFloodMap() then begin result := 'Error'; raise Exception.Create('The flood map was not received. Please check that the correct address was given.'); end else result := 'Single'; end else begin Result := 'Error'; raise Exception.Create('The flood map was not received. Please check that the correct address was given.'); end; end; end; except on E: Exception do begin Result := 'Error'; raise Exception.Create(E.message); end; end; finally FIdHTTP.Free; end; end; function TFloodInsightClient.BuildMultipleResultList(XMLStr: String): Boolean; var XMLDOM: IXMLDocument; CdGeoResultsNode: IXMLNode; CdCandidatesNode: IXMLNode; CdCandidateNode: IXMLNode; //local variables to hold the values of Candidate Nodes lvtxtStreet, lvtxtCity, lvtxtState, lvtxtZip, lvtxtPlus4, lvtxtLon, lvtxtLat, lvtxtGeoResult, lvtxtFirm, lvtxtCensusId, lvtxtPrecision: String; I: Integer; begin Result := True; XMLDOM := LoadXMLData(XMLStr); //clear the property MulAddressList MulAddressList.Clear; if not XMLDOM.IsEmptyDoc then begin //read the top most CdGeoResults node CdGeoResultsNode := XMLDOM.ChildNodes.FindNode('CdGeoResults'); if CdGeoResultsNode <> nil then begin //read CdCandidates CdCandidatesNode := CdGeoResultsNode.ChildNodes.FindNode('CdCandidates'); if CdCandidatesNode <> nil then begin //check how many child nodes are there if CdCandidatesNode.ChildNodes.Count > 1 then begin for I := 0 to CdCandidatesNode.ChildNodes.Count - 1 do begin //read CdCandidates CdCandidateNode := CdCandidatesNode.ChildNodes[I]; lvtxtStreet := CdCandidateNode.ChildNodes['txtStreet'].Text; lvtxtCity := CdCandidateNode.ChildNodes['txtCity'].Text; lvtxtState := CdCandidateNode.ChildNodes['txtState'].Text; lvtxtZip := CdCandidateNode.ChildNodes['txtZip'].Text; lvtxtPlus4 := CdCandidateNode.ChildNodes['txtPlus4'].Text; lvtxtLon := CdCandidateNode.ChildNodes['txtLon'].Text; lvtxtLat := CdCandidateNode.ChildNodes['txtLat'].Text; lvtxtGeoResult := CdCandidateNode.ChildNodes['txtGeoResult'].Text; lvtxtFirm := CdCandidateNode.ChildNodes['txtFirm'].Text; lvtxtCensusId := CdCandidateNode.ChildNodes['txtCensusBlockId'].Text; lvtxtPrecision := CdCandidateNode.ChildNodes['txtPrecision'].Text; MulAddressList.Add(lvtxtStreet + ', ' + lvtxtCity + ', ' + lvtxtState + ', ' + lvtxtZip + ', ' + lvtxtPlus4); end; end; end else Result := False; end else Result := False; end else Result := False; end; function TFloodInsightClient.GetCFDB_MapEx(ListBoxIndex: Integer): String; var XMLStr: String; RequestStr: string; XMLDataStartPos : Integer; FIdHTTP : TidHTTP; begin Result := ''; FIdHTTP := TIdHTTP.Create(self); try // The base location of the ISAPI dll on the IIS server. RequestStr := ISAPIURL; RequestStr := RequestStr + 'GetMapInfo?' + BuildMapQueryStr(ResponseStr, ListBoxIndex); ResponseStr := FidHTTP.Get(RequestStr); if Length(ResponseStr) = 0 then begin result := 'Error'; raise Exception.Create('The flood map was not received. Please check that the correct address was given.'); end; //check if response is map result if pos(ipnXMLData, ResponseStr) = 1 then begin //parse the result XML and get the map //the response has two parts: XML Data and Jpeg Image, the tags indicate the dividers XMLDataStartPos := Pos(ipnXMLData, ResponseStr) + Length(ipnXMLData) + 1; XMLStr := Copy(ResponseStr, XMLDataStartPos, Pos(ipnMapData, ResponseStr) - XMLDataStartPos - 1); try ParseTheXML(XMLStr); //extract the xml values result := 'Single'; except begin result := 'Error'; raise Exception.Create('There is a problem geo-coding the address. The results may be invalid. Please recheck the address.'); end; end; //find the start of the Image Data and delete everything before it Delete(ResponseStr, 1, Pos(ipnMapData, ResponseStr) + Length(ipnMapData)); if length(ResponseStr) > 0 then //extract the image begin FloodMap.WriteBuffer(ResponseStr[1], Length(ResponseStr)); FloodMap.Position := 0; if not FinalizeFloodMap() then begin result := 'Error'; raise Exception.Create('The flood map was not received. Please check that the correct address was given.'); end else result := 'Single'; end else begin result := 'Error'; raise Exception.Create('The flood map was not received. Please check that the correct address was given.'); end; end else begin result := 'Error'; raise Exception.Create('The flood map was not received. Please check that the correct address was given.'); end; finally FIdHTTP.Free; end; end; function TFloodInsightClient.GetCFAW_MapEx(ListBoxIndex: Integer): String; {var XMLStr: String; RequestStr: string; XMLDataStartPos : Integer; FIdHTTP : TidHTTP;} begin Result := ''; end; function TFloodInsightClient.GetCFDB_SpottedMap(RequestStr: string): String; var XMLStr: String; XMLDataStartPos : Integer; FIdHTTP : TidHTTP; begin Result := ''; if Length(RequestStr) = 0 then begin result := 'Error'; raise Exception.Create('The re-spotting information was not saved with this report or it has been expired.'); end; FIdHTTP := TIdHTTP.Create(self); try // The base location of the ISAPI dll on the IIS server. RequestStr := ISAPIURL + 'GetSpottedMap?' + RequestStr + '&CustomerId=' + URLEncode(AccountID) + '&CustomerPin=' + URLEncode(Pin); ResponseStr := FidHTTP.Get(RequestStr); //do the work if Length(ResponseStr) = 0 then begin result := 'Error'; raise Exception.Create('The flood map was not received. Please check that the correct address was given.'); end; if POS('Error', ResponseStr) > 0 then begin result := 'Error'; raise Exception.Create('The subject cannot be repositioned. The original flood map and session expired. Please redo the flood certification.'); end; //check if response is map result if pos(ipnXMLData, ResponseStr) = 1 then begin //parse the result XML and get the map //the response has two parts: XML Data and Jpeg Image, the tags indicate the dividers XMLDataStartPos := Pos(ipnXMLData, ResponseStr) + Length(ipnXMLData) + 1; XMLStr := Copy(ResponseStr, XMLDataStartPos, Pos(ipnMapData, ResponseStr) - XMLDataStartPos - 1); try ParseTheXML(XMLStr); //extract the xml values result := 'Single'; except begin result := 'Error'; raise Exception.Create('There is a problem geo-coding the address. The results may be invalid. Please recheck the address.'); end; end; //find the start of the Image Data and delete everything before it Delete(ResponseStr, 1, Pos(ipnMapData, ResponseStr) + Length(ipnMapData)); if length(ResponseStr) > 0 then //extract the image begin FloodMap.WriteBuffer(ResponseStr[1], Length(ResponseStr)); FloodMap.Position := 0; if not FinalizeFloodMap() then begin result := 'Error'; raise Exception.Create('The flood map was not received. Please check that the correct address was given.'); end else result := 'Single'; end else begin result := 'Error'; raise Exception.Create('The flood map was not received. Please check that the correct address was given.'); end; end else begin result := 'Error'; raise Exception.Create('The flood map was not received. Please check that the correct address was given.'); end; finally FIdHTTP.Free; end; end; function TFloodInsightClient.GetCFAW_SpottedMap(RequestStr: string): String; {var XMLStr: String; XMLDataStartPos : Integer; FIdHTTP : TidHTTP;} begin Result := ''; {if Length(RequestStr) = 0 then begin result := 'Error'; raise Exception.Create('The re-spotting information was not saved with this report or it has been expired.'); end; FIdHTTP := TIdHTTP.Create(self); try // The base location of the ISAPI dll on the IIS server. RequestStr := ISAPIURL + 'GetSpottedMap?' + RequestStr + '&CustomerId=' + URLEncode(AccountID) + '&CustomerPin=' + URLEncode(Pin); ResponseStr := FidHTTP.Get(RequestStr); //do the work if Length(ResponseStr) = 0 then begin result := 'Error'; raise Exception.Create('The flood map was not received. Please check that the correct address was given.'); end; if POS('Error', ResponseStr) > 0 then begin result := 'Error'; raise Exception.Create('The subject cannot be repositioned. The original flood map and session expired. Please redo the flood certification.'); end; //check if response is map result if pos(ipnXMLData, ResponseStr) = 1 then begin //parse the result XML and get the map //the response has two parts: XML Data and Jpeg Image, the tags indicate the dividers XMLDataStartPos := Pos(ipnXMLData, ResponseStr) + Length(ipnXMLData) + 1; XMLStr := Copy(ResponseStr, XMLDataStartPos, Pos(ipnMapData, ResponseStr) - XMLDataStartPos - 1); try ParseTheXML(XMLStr); //extract the xml values result := 'Single'; except begin result := 'Error'; raise Exception.Create('There is a problem geo-coding the address. The results may be invalid. Please recheck the address.'); end; end; //find the start of the Image Data and delete everything before it Delete(ResponseStr, 1, Pos(ipnMapData, ResponseStr) + Length(ipnMapData)); if length(ResponseStr) > 0 then //extract the image begin FloodMap.WriteBuffer(ResponseStr[1], Length(ResponseStr)); FloodMap.Position := 0; if not FinalizeFloodMap() then begin result := 'Error'; raise Exception.Create('The flood map was not received. Please check that the correct address was given.'); end else result := 'Single'; end else begin result := 'Error'; raise Exception.Create('The flood map was not received. Please check that the correct address was given.'); end; end else begin result := 'Error'; raise Exception.Create('The flood map was not received. Please check that the correct address was given.'); end; finally FIdHTTP.Free; end;} end; function TFloodInsightClient.BuildMapQueryStr(XMLStr: String; ListBoxIndex: Integer): String; var XMLDOM: IXMLDocument; CdGeoResultsNode: IXMLNode; CdCandidatesNode: IXMLNode; CdCandidateNode: IXMLNode; //local variables to hold the values of Candidate Nodes lvtxtStreet, lvtxtCity, lvtxtState, lvtxtZip, lvtxtPlus4, lvtxtLon, lvtxtLat, lvtxtGeoResult, lvtxtFirm, lvtxtCensusId, lvtxtPrecision: String; RequestStr: String; begin XMLDOM := LoadXMLData(XMLStr); if not XMLDOM.IsEmptyDoc then begin //read the top most CdGeoResults node CdGeoResultsNode := XMLDOM.ChildNodes.FindNode('CdGeoResults'); if CdGeoResultsNode <> nil then begin //read CdCandidates CdCandidatesNode := CdGeoResultsNode.ChildNodes.FindNode('CdCandidates'); if CdCandidatesNode <> nil then begin //read CdCandidates for specified node CdCandidateNode := CdCandidatesNode.ChildNodes[ListBoxIndex]; lvtxtStreet := CdCandidateNode.ChildNodes['txtStreet'].Text; lvtxtCity := CdCandidateNode.ChildNodes['txtCity'].Text; lvtxtState := CdCandidateNode.ChildNodes['txtState'].Text; lvtxtZip := CdCandidateNode.ChildNodes['txtZip'].Text; lvtxtPlus4 := CdCandidateNode.ChildNodes['txtPlus4'].Text; lvtxtLon := CdCandidateNode.ChildNodes['txtLon'].Text; lvtxtLat := CdCandidateNode.ChildNodes['txtLat'].Text; lvtxtGeoResult := CdCandidateNode.ChildNodes['txtGeoResult'].Text; lvtxtFirm := CdCandidateNode.ChildNodes['txtFirm'].Text; lvtxtCensusId := CdCandidateNode.ChildNodes['txtCensusBlockId'].Text; lvtxtPrecision := CdCandidateNode.ChildNodes['txtPrecision'].Text; //build and return the RequestStr RequestStr := ipnAccountID + '=' + URLEncode(AccountID) + '&' + ipnPin + '=' + URLEncode(Pin) + '&' + ipnMapWidth + '=' + URLEncode(IntToStr(MapWidth)) + '&' + ipnMapHeight + '=' + URLEncode(IntToStr(MapHeight)) + '&' + ipnZoom + '=' + URLEncode(SubjectZoom) + '&' + ipnIconLabel + '=' + URLEncode(SubjectLabel) + '&' + ipnStreetAddress + '=' + URLEncode(lvtxtStreet) + '&' + ipnCity + '=' + URLEncode(lvtxtCity) + '&' + ipnState + '=' + URLEncode(lvtxtState) + '&' + ipnZip + '=' + URLEncode(lvtxtZip) + '&' + ipnPlus4 + '=' + URLEncode(lvtxtPlus4) + '&' + ipnLon + '=' + URLEncode(lvtxtLon) + '&' + ipnLat + '=' + URLEncode(lvtxtLat) + '&' + ipnGeoResult + '=' + URLEncode(lvtxtGeoResult) + '&' + ipnCensusBlockID + '=' + URLEncode(lvtxtCensusId); Result := RequestStr; end else result := 'Error'; end else result := 'Error'; end else result := 'Error'; end; procedure TFloodInsightClient.SetPanelDate(const Value: String); var yr,mo,dy: String; begin FPanelDate := Value; if length(Value) = 8 then begin yr := copy(Value, 1, 4); mo := copy(Value, 5, 2); dy := copy(Value, 7, 2); FPanelDate := mo+'/'+dy+'/'+yr; end; end; procedure TFloodInsightClient.ParseTheXML(XMLStr: String); var errText, s: String; p: integer; XMLDOM : IXMLDocument; ResultNode, LocNode, TestNode, FloodNode, FloodResultNode,FloodFeatureNode, MapNode: IXMLNode; begin XMLDOM := LoadXMLData(XMLStr); //XMLDOM.SaveToFile('C:\Projects\FloodMap.XML'); if not XMLDOM.IsEmptyDoc then try //start loading in the result values into property holders ResultNode := XMLDom.ChildNodes.FindNode('CdRmResult'); LocNode := ResultNode.ChildNodes.FindNode('Location'); MapNode := ResultNode.ChildNodes.FindNode('Map'); if assigned(MapNode) then begin SubjectImageID := MapNode.ChildNodes['ImageID'].Text; SubjectZoom := MapNode.ChildNodes['Zoom'].Text; SubjectZip := LocNode.ChildNodes['Zip'].Text; SubjectPlus4 := LocNode.ChildNodes['Plus4'].Text; s := MapNode.ChildNodes['ImageURL'].Text; p := POS('/',s); SubjectImageURL := Copy(s,0,p-1); end; //for geocoding accuracy GeoResult := LocNode.ChildNodes['GeocodeResult'].Text; //Location info ZipPlus4 := SubjectZip + '-' + LocNode.ChildNodes['Plus4'].Text; CensusTract := LocNode.ChildNodes['CensusBlock'].Text; Longitude := LocNode.ChildNodes['Longitude'].Text; Latitude := LocNode.ChildNodes['Latitude'].Text; TestNode := ResultNode.ChildNodes.FindNode('Tests'); FloodNode := TestNode.ChildNodes.FindNode('Flood'); FloodResultNode := FloodNode.ChildNodes.FindNode('Result'); //Flood Test Results MapNumber := FloodResultNode.ChildNodes['MapNumber'].Text; SHFAResult := FloodResultNode.ChildNodes['SFHA'].Text; SHFANearBy := FloodResultNode.ChildNodes['Nearby'].Text; // if Uppercase(SHFANearBy) = 'YES' then // SFHAPhrase := FloodResultNode.ChildNodes['FzDdPhrase'].Text // else if Uppercase(SHFANearBy) = 'NO' then // SFHAPhrase := 'Not within 250 feet' // else // SFHAPhrase := 'Unknown'; if POS('IN', Uppercase(SHFAResult)) > 0 then SFHAPhrase := 'Within 250 feet' else if POS('OUT', Uppercase(SHFAResult)) > 0 then SFHAPhrase := 'Not within 250 feet' else SFHAPhrase := 'Unknown'; //Flood Test Features FloodFeatureNode := FloodNode.ChildNodes.FindNode('Features'); FloodFeatureNode := FloodFeatureNode.ChildNodes.FindNode('Feature1'); CommunityID := FloodFeatureNode.ChildNodes['Community'].Text; CommunityName := FloodFeatureNode.ChildNodes['Community_Name'].Text; Zone := FloodFeatureNode.ChildNodes['Zone'].Text; Panel := FloodFeatureNode.ChildNodes['Panel'].Text; PanelDate := FloodFeatureNode.ChildNodes['Panel_Dte'].Text; FIPSCode := FloodFeatureNode.ChildNodes['FIPS'].Text; //---------------------------------------------------------------------------------------------------- // This is a bit of a hack, but the panel and community numbers are concatenated in the floodmap dll, which // is incorrect when the community is a county or unincorporated area. After talking with Yakov I was afraid // to change the behavior in the dll. When the dll is corrected this can be removed. The offending function // in UFloodMap is : // procedure SpecialHackfor240_CombineCommunityAndPanel(ResultNode: IXMLNode); Todd //---------------------------------------------------------------------------------------------------- if ((Pos('CITY OF', UpperCase(CommunityName)) = 0) and (Pos('TOWN OF', UpperCase(CommunityName)) = 0)) then begin Panel := AnsiReplaceStr(Panel, CommunityID, FIPSCode + 'C'); end; except if assigned(FloodNode) then begin errText := FloodNode.ChildNodes['CdErrors'].text; raise Exception.create(errText); end else raise; end; end; function TFloodInsightClient.FinalizeFloodMap(): Boolean; var LegendImage, MapImage, TempImage: TJPEGImage; TempDisplayImage: TImage; x,y,z: integer; sLegendPath, vSFHA, v250, vComm, vCommName, vZone, vPanel, vPanelDt, vFIPS, vCensus: String; hasLegend: Boolean; begin Result := True; (* Ticket #1265: no longer need to fill in the legend sLegendPath := IncludeTrailingPathDelimiter(appPref_DirMapping) + 'FloodInsights\' + FloodMapLegendJPG; hasLegend := FileExists(sLegendPath); //create the jpg image instances LegendImage := TJPEGImage.create; TempImage := TJPEGImage.create; TempDisplayImage := TImage.Create(Self); MapImage := TJPEGImage.create; try try FloodMap.Position := 0; MapImage.LoadFromStream(FloodMap); //load into jpeg handler TempDisplayImage.Height := 807; TempDisplayImage.Width := 532; TempDisplayImage.Visible := False; vSFHA := SHFAResult; v250 := SHFANearBy; //WAS SFHAPhrase; vComm := CommunityID; vCommName := CommunityName; vZone := Zone; vPanel := Panel; vPanelDt := PanelDate; vFIPS := FIPSCode; vCensus := CensusTract; //legend image if hasLegend then LegendImage.LoadFromFile(sLegendPath) else ShowNotice('The legend for the map was not found. The map will be created anyway.'); //draws both of these images on the cavas TempDisplayImage.Canvas.Draw(0,0,MapImage); TempDisplayImage.Canvas.Draw(7,640,LegendImage); //draws the bottm white box TempDisplayImage.Canvas.Brush.Color := clwhite; TempDisplayImage.Canvas.FillRect(Rect(222,600,600,807)); //draws the title backgroud TempDisplayImage.Canvas.Brush.Color := clgray; TempDisplayImage.Canvas.FillRect(Rect(0,604,532,620)); //draws the titles TempDisplayImage.Canvas.Font.Color := clWhite; TempDisplayImage.Canvas.Font.Size := 8; TempDisplayImage.Canvas.Font.Name := 'Arial'; TempDisplayImage.Canvas.Font.Style := [fsBold]; TempDisplayImage.Canvas.TextOut(5,606,'Flood Map Legends'); TempDisplayImage.Canvas.TextOut(208,606,'Flood Zone Determination'); //draws the vertile lines for border and divider of bottom box TempDisplayImage.Canvas.Brush.Color := clblack; //verticle line Left TempDisplayImage.Canvas.FillRect(Rect(0,620,1,807)); //verticle line middle // TempDisplayImage.Canvas.FillRect(Rect(202,620,203,807)); TempDisplayImage.Canvas.FillRect(Rect(193,620,194,807)); //verticle line right TempDisplayImage.Canvas.FillRect(Rect(531,620,532,807)); //draws horizontal lines //top line TempDisplayImage.Canvas.FillRect(Rect(0,604,540,605)); //top second line TempDisplayImage.Canvas.FillRect(Rect(0,620,540,621)); //bottom line TempDisplayImage.Canvas.FillRect(Rect(0,814,540,815)); //draws the legend title TempDisplayImage.Canvas.Brush.Color := clwhite; TempDisplayImage.Canvas.Font.Color := clBlack; TempDisplayImage.Canvas.Font.Style := []; TempDisplayImage.Canvas.TextOut(7,625,'Flood Zones'); //draws the legend descriptions TempDisplayImage.Canvas.Font.Size := 7; TempDisplayImage.Canvas.Font.Style := [fsbold]; TempDisplayImage.Canvas.Font.Name := 'arial narrow'; x:=27; //left y:=640; //top z:=19; // line spacing TempDisplayImage.Canvas.TextOut(x,y,'Areas inundated by 500-year flooding'); Inc(y,z); TempDisplayImage.Canvas.TextOut(x,y-4,'Areas outside of the 100 and 500 year flood'); TempDisplayImage.Canvas.TextOut(x,y+6,'plains'); Inc(y,z); TempDisplayImage.Canvas.TextOut(x,y,'Areas inundated by 100-year flooding'); Inc(y,z); TempDisplayImage.Canvas.TextOut(x,y-4,'Areas inundated by 100-year flooding with'); TempDisplayImage.Canvas.TextOut(x,y+6,'velocity hazard'); Inc(y,z); TempDisplayImage.Canvas.TextOut(x,y,'Floodway areas'); Inc(y,z); TempDisplayImage.Canvas.TextOut(x,y-5,'Floodway areas with velocity hazard'); Inc(y,z); TempDisplayImage.Canvas.TextOut(x,y-7,'Areas of undetermined but possible flood'); TempDisplayImage.Canvas.TextOut(x,y+4,'hazard'); Inc(y,z); TempDisplayImage.Canvas.TextOut(x,y-4,'Areas not mapped on any published FIRM'); //draws the dynamic text specfic to the map image TempDisplayImage.Canvas.Font.Size := 8; TempDisplayImage.Canvas.Font.Style := []; TempDisplayImage.Canvas.Brush.Color := clwhite; TempDisplayImage.Canvas.Font.Name := 'tahoma'; x:=200; //left y:=622; //top z:=13; // line spacing TempDisplayImage.Canvas.TextOut(x,y,'SFHA (Flood Zone): '); TempDisplayImage.Canvas.Font.Style := [fsBold]; TempDisplayImage.Canvas.TextOut(x+100,y,vSFHA); Inc(y,z); TempDisplayImage.Canvas.Font.Style := []; TempDisplayImage.Canvas.TextOut(x,y,'Within 250 ft. of multiple flood zones? '); TempDisplayImage.Canvas.Font.Style := [fsBold]; TempDisplayImage.Canvas.TextOut(x+188,y,v250); Inc(y,z); TempDisplayImage.Canvas.Font.Style := []; TempDisplayImage.Canvas.TextOut(x,y,'Community: '); TempDisplayImage.Canvas.Font.Style := [fsBold]; TempDisplayImage.Canvas.TextOut(x+63,y,vComm); Inc(y,z); TempDisplayImage.Canvas.Font.Style := []; TempDisplayImage.Canvas.TextOut(x,y,'Community Name: '); TempDisplayImage.Canvas.Font.Style := [fsBold]; TempDisplayImage.Canvas.TextOut(x+95,y,vCommName); Inc(y,z); TempDisplayImage.Canvas.Font.Style := []; TempDisplayImage.Canvas.TextOut(x,y,'Zone: '); Inc(x,30); TempDisplayImage.Canvas.Font.Style := [fsBold]; TempDisplayImage.Canvas.TextOut(x,y,vZone); Inc(x,20); TempDisplayImage.Canvas.Font.Style := []; TempDisplayImage.Canvas.TextOut(x,y,' Panel: '); Inc(x,35); TempDisplayImage.Canvas.Font.Style := [fsBold]; TempDisplayImage.Canvas.TextOut(x,y,vPanel); Inc(x,100); TempDisplayImage.Canvas.Font.Style := []; TempDisplayImage.Canvas.TextOut(x,y,' Panel Date: '); Inc(x,63); TempDisplayImage.Canvas.Font.Style := [fsBold]; TempDisplayImage.Canvas.TextOut(x,y,vPanelDt); Inc(y,z); x:=208; TempDisplayImage.Canvas.Font.Style := []; TempDisplayImage.Canvas.TextOut(x,y,'FIPS Code: '); Inc(x,57); TempDisplayImage.Canvas.Font.Style := [fsBold]; TempDisplayImage.Canvas.TextOut(x,y,vFIPS); Inc(x,45); TempDisplayImage.Canvas.Font.Style := []; TempDisplayImage.Canvas.TextOut(x,y,' Census Tract: '); Inc(x,77); TempDisplayImage.Canvas.Font.Style := [fsBold]; TempDisplayImage.Canvas.TextOut(x,y,vCensus); //draws the disclaimer TempDisplayImage.Canvas.Font.Size := 7; TempDisplayImage.Canvas.Font.Style := []; TempDisplayImage.Canvas.Font.Name := 'tahoma'; x:=200; //left y:=711; //top z:=9; // line spacing TempDisplayImage.Canvas.TextOut(x,y,'This Report is for the sole benefit of the Customer that ordered and paid for the'); Inc(y,z); TempDisplayImage.Canvas.TextOut(x,y,'Report and is based on the property information provided by that Customer.' ); Inc(y,z); TempDisplayImage.Canvas.TextOut(x,y,'That Customer''s use of this Report is subject to the terms agreed to by that'); Inc(y,z); TempDisplayImage.Canvas.TextOut(x,y,'Customer when accessing this product. No third party is authorized to use or'); Inc(y,z); TempDisplayImage.Canvas.TextOut(x,y,'rely on this Report for any purpose. THE SELLER OF THIS REPORT MAKES'); Inc(y,z); TempDisplayImage.Canvas.TextOut(x,y,'NO REPRESENTATIONS OR WARRANTIES TO ANY PARTY'); Inc(y,z); TempDisplayImage.Canvas.TextOut(x,y,'CONCERNING THE CONTENT,ACCURACY OR COMPLETENESS OF'); Inc(y,z); TempDisplayImage.Canvas.TextOut(x,y,'THIS REPORT INCLUDING ANY WARRANTY OF MERCHANTABILITY OR'); Inc(y,z); TempDisplayImage.Canvas.TextOut(x,y,'FITNESS FOR A PARTICULAR PURPOSE. The seller of this Report shall'); Inc(y,z); TempDisplayImage.Canvas.TextOut(x,y,'not have any liability to any third party for any use or misuse of this Report.'); Inc(y,z); //save the final image in jpg format now for compression TempImage.Assign(TempDisplayImage.Picture.Graphic); TempImage.CompressionQuality := 100; TempImage.Compress; //save the flood map with legends and text back to the memory stream FloodMap.Clear; TempImage.SaveToStream(FloodMap); FloodMap.Position := 0; except on E: Exception do result := False; end finally LegendImage.Free; TempImage.Free; MapImage.Free; TempDisplayImage.Free; end; *) end; end.
{*------------------------------------------------------------------------------ 共通ユーティリティユニット @Author $Author$ @Version $Id$ -------------------------------------------------------------------------------} unit CommonUtil; interface { 宣言部 } uses Windows; function IsNumeric(S : String) : Boolean; function IsDebugging() : Boolean; function IsWildcard(const iPattern: String): Boolean; function GetLastErrorString(ErrorCode: Integer): String; function GetComputerNameString(): String; function GetUserNameString(): String; implementation { 実装部 } {*------------------------------------------------------------------------------ メモリ領域確保 (from SysUtils.pas of Delphi VCL) @param Size ParameterDescription @return ResultDescription ------------------------------------------------------------------------------*} function AllocMem(Size: Cardinal): Pointer; begin GetMem(Result, Size); FillChar(Result^, Size, 0); end; {*------------------------------------------------------------------------------ 数値か? @param S 文字列 @return 結果 ------------------------------------------------------------------------------*} function IsNumeric(S : String) : Boolean; var E : Integer; R : Integer; begin Val(S, R, E); Result := (E = 0); end; {*------------------------------------------------------------------------------ デバッグ中か? @return 結果 ------------------------------------------------------------------------------*} function IsDebugging() : Boolean; begin Result := (DebugHook <> 0) end; {*------------------------------------------------------------------------------ ワイルドカード文字が存在しているか? (*,? 文字判定) @param Pattern 判定したい文字列 @return ワイルドカード文字が存在していた場合 True ------------------------------------------------------------------------------*} function IsWildcard(const iPattern: String): Boolean; begin Result := (Pos('*', iPattern) <> 0) or (Pos('?', iPattern) <> 0); end; {*------------------------------------------------------------------------------ GetLastError()関数で取得できるエラーコードからエラーメッセージ名を取得 @param ErrorCode エラーコード(GetLastErrorから取得できるエラーコード対応) @return エラーメッセージ(OSの言語対応 ------------------------------------------------------------------------------*} function GetLastErrorString(ErrorCode: Integer): String; const MAX_MES = 512; var Buf: PChar; begin Buf := AllocMem(MAX_MES); try FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, nil, ErrorCode, (SUBLANG_DEFAULT shl 10) + LANG_NEUTRAL, Buf, MAX_MES, nil); finally Result := Buf; FreeMem(Buf); end; end; {*------------------------------------------------------------------------------ コンピュータ名取得 @return コンピュータ名 ------------------------------------------------------------------------------*} function GetComputerNameString(): String; var buf: array[0..MAX_COMPUTERNAME_LENGTH] of Char; bufSize: DWORD; begin bufSize := SizeOf(buf); if GetComputerName(buf, bufSize) then Result := buf else Result := ''; end; {*------------------------------------------------------------------------------ ユーザー名称取得 @return ユーザー名称 ------------------------------------------------------------------------------*} function GetUserNameString(): String; var buf: array[0..255] of Char; bufSize: DWORD; begin bufSize := SizeOf(buf); if GetUserName(buf, bufSize) then begin Result := Buf end else begin Result := ''; end; end; end.
{******************************************************************************} { } { WiRL: RESTful Library for Delphi } { } { Copyright (c) 2015-2019 WiRL Team } { } { https://github.com/delphi-blocks/WiRL } { } {******************************************************************************} unit WiRL.Client.SubResource; {$I ..\Core\WiRL.inc} interface uses System.SysUtils, System.Classes, WiRL.Client.Resource, WiRL.http.Client, WiRL.Client.Application; type {$IFDEF HAS_NEW_PIDS} [ComponentPlatformsAttribute(pidWin32 or pidWin64 or pidOSX32 or pidiOSSimulator32 or pidiOSDevice32 or pidAndroid32Arm)] {$ELSE} [ComponentPlatformsAttribute(pidWin32 or pidWin64 or pidOSX32 or pidiOSSimulator or pidiOSDevice or pidAndroid)] {$ENDIF} TWiRLClientSubResource = class(TWiRLClientResource) private FParentResource: TWiRLClientResource; protected function GetPath: string; override; function GetClient: TWiRLClient; override; function GetApplication: TWiRLClientApplication; override; public constructor Create(AOwner: TComponent); override; published property ParentResource: TWiRLClientResource read FParentResource write FParentResource; end; implementation uses WiRL.Client.Utils, WiRL.http.URL; { TWiRLClientSubResource } constructor TWiRLClientSubResource.Create(AOwner: TComponent); begin inherited; if TWiRLComponentHelper.IsDesigning(Self) then FParentResource := TWiRLComponentHelper.FindDefault<TWiRLClientResource>(Self); end; function TWiRLClientSubResource.GetApplication: TWiRLClientApplication; begin if Assigned(FParentResource) then Result := FParentResource.Application else Result := inherited GetApplication; end; function TWiRLClientSubResource.GetClient: TWiRLClient; begin if Assigned(SpecificClient) then Result := SpecificClient else if Assigned(FParentResource) then Result := FParentResource.Client else Result := inherited GetClient; end; function TWiRLClientSubResource.GetPath: string; begin if Assigned(FParentResource) then Result := TWiRLURL.CombinePath([FParentResource.Path, Resource]) else Result := inherited GetPath; end; end.
unit DomainObjectRepository; interface uses DomainObjectUnit, DomainObjectListUnit, VariantListUnit; type IDomainObjectRepository = interface ['{7CE44677-0B89-45C1-9168-21D7B07371DE}'] function Add(DomainObject: TDomainObject): Boolean; function AddDomainObjectList(DomainObjectList: TDomainObjectList): Boolean; function Update(DomainObject: TDomainObject): Boolean; function UpdateDomainObjectList(DomainObjectList: TDomainObjectList): Boolean; function Remove(DomainObject: TDomainObject): Boolean; function RemoveDomainObjectList(DomainObjectList: TDomainObjectList): Boolean; function FindDomainObjectByIdentity(Identity: Variant): TDomainObject; function FindDomainObjectsByIdentities(const Identities: TVariantList): TDomainObjectList; function LoadAll: TDomainObjectList; end; implementation end.
// Author: Wayne Buchner // Student ID: 6643140 // Date: 03/04/2011 // Program: Median.pas // Description: Calculate the Median value from an array program Median; uses SysUtils, math; function Median (const data: array of Integer):Double; var dataLength : Integer; begin dataLength := Floor(Length(data)/2); if Length(data) Mod 2 = 0 then begin result := (data[dataLength-1] + data[dataLength])/2; end else begin result := data[dataLength]; end; end; procedure Main(); var i : Integer; data: array of Integer; begin // change length of array to test here. SetLength(data,15); for i:= 0 to Length(data) do begin data[i] := i+1; WriteLn(data[i]); end; WriteLn('Median is : ',Median(data):4:2); end; begin Main(); end.
(*============================================================================ -----BEGIN PGP SIGNED MESSAGE----- This code (c) 1994, 1997 Graham THE Ollis GENERAL NOTES ============= This is 16bit DOS TURBO PASCAL source code. It has been tested using TURBO PASCAL 7.0. You will need AT LEAST version 5.0 to compile this source code. You may need 7.0. This is a generic pascal header for all my old pascal programs. Most of these programs were written before I really got excited enough about 32bit operating systems. In general this code dates back to 1994. Some of it is important enough that I still work on it. For the most part though, it's not the best code and it's probably the worst example of documentation in all of computer science. oh well, you've been warned. PGP NOTES ========= This PGP signed message is provided in the hopes that it will prove useful and informative. My name is Graham THE Ollis <ollisg@ns.arizona.edu> and my public PGP key can be found by fingering my university account: finger ollisg@u.arizona.edu LEGAL NOTES =========== You are free to use, modify and distribute this source code provided these headers remain in tact. If you do make modifications to these programs, i'd appreciate it if you documented your changes and leave some contact information so that others can blame you and me, rather than just me. If you maintain a anonymous ftp site or bbs feel free to archive this stuff away. If your pressing CDs for commercial purposes again have fun. It would be nice if you let me know about it though. HOWEVER- there is no written or implied warranty. If you don't trust this code then delete it NOW. I will in no way be held responsible for any losses incurred by your using this software. CONTACT INFORMATION =================== You may contact me for just about anything relating to this code through e-mail. Please put something in the subject line about the program you are working with. The source file would be best in this case (e.g. frag.pas, hexed.pas ... etc) ollisg@ns.arizona.edu ollisg@idea-bank.com ollisg@lanl.gov The first address is the most likely to work. all right. that all said... HAVE FUN! -----BEGIN PGP SIGNATURE----- Version: 2.6.2 iQCVAwUBMv1UFoazF2irQff1AQFYNgQAhjiY/Dh3gSpk921FQznz4FOwqJtAIG6N QTBdR/yQWrkwHGfPTw9v8LQHbjzl0jjYUDKR9t5KB7vzFjy9q3Y5lVHJaaUAU4Jh e1abPhL70D/vfQU3Z0R+02zqhjfsfKkeowJvKNdlqEe1/kSCxme9mhJyaJ0CDdIA 40nefR18NrA= =IQEZ -----END PGP SIGNATURE----- ============================================================================== | second.pas | allow viewing two files on just ONE screen. wow. just like windows | only FAST! you know... it's too bad no one will ever actually read | these comments. | | History: | Date Author Comment | ---- ------ ------- | -- --- 94 G. Ollis created and developed program ============================================================================*) {$I-} Unit Second; INTERFACE Uses Header,CHFILE; {++PROCEDURES++++++++++++++++++++++++++++++++++++++++++++++++++++++++++} Procedure AdditionalFile(Var D:DataType; InpFileName:MaskString; Bo:Boolean); Procedure SwapFiles(Var D:DataType); Procedure SearchDiff(Var D:DataType); {++FUNCTIONS+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++} {++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++} IMPLEMENTATION Uses CRT,UModify,ViewU,FUTIL,CFG,OutCRT,VConvert,Cursor; {----------------------------------------------------------------------} Procedure AdditionalFile(Var D:DataType; InpFileName:MaskString; Bo:Boolean); Var count:Word; i:Word; Error:Integer; b:byte; Begin Window(1,6,80,9); TextAttr:=ICFG.Lolight; ClrScr; AutomaticTUse:=False; If (Secondary<>Nil) Then Begin Window(1,1,80,25); If Not ReallyDispose(Secondary^) Then Exit; Close(Secondary^.stream); Dispose(Secondary^.D); Dispose(Secondary); Secondary:=Nil; Exit; End; If MaxAvail<SizeOf(DataType)+SizeOf(binaryimage) Then Begin ErrorMsg('Not enough memory.'); Exit; End; New(Secondary); Secondary^.BlockStart:=-1; Secondary^.BlockFinish:=-2; SvTextScreen; If NOT Bo Then Secondary^.FN:=ChooseFileName('HEXED version '+versionnumber,'Load Secondary File',InpFileName) Else Secondary^.FN:=InpFileName; FilePath:=Secondary^.FN; RsTextScreen; If (SizeOf(BinaryImage)>MaxAvail) Then Begin ErrorMsg('Not enough memory'); Dispose(Secondary); Secondary:=Nil; Exit; End; If (Secondary^.FN='') Then With Secondary ^ Do Begin Secondary^.FN:='NONAME.DAT'; Assign(Secondary^.stream,Secondary^.FN); ReWrite(Secondary^.stream,1); B:=$00; BlockWrite(Secondary^.stream,B,1); Close(Secondary^.stream); End; New(Secondary^.D); FillChar(Secondary^.D^,imagesize,0); Assign(Secondary^.stream,Secondary^.FN); Reset(Secondary^.stream,1); Error:=IOResult; If Error<>0 Then Begin ErrorMsg('Error opening file for read '+IntToStr(Error,0)); Dispose(Secondary^.D); Dispose(Secondary); Secondary:=Nil; Exit; End; If FileSize(Secondary^.stream)>imagesize-1 Then BlockRead(Secondary^.stream,Secondary^.D^,imagesize-1,Error) Else BlockRead(Secondary^.stream,Secondary^.D^,FileSize(Secondary^.stream)); Secondary^.offset:=0; Error:=IOResult; If Error<>0 Then Begin ErrorMsg('Error reading file '+IntToStr(Error,0)); If Secondary^.D<>Nil Then Dispose(Secondary^.D); Dispose(Secondary); Secondary:=Nil; Exit; End; Secondary^.Changes:=False; Secondary^.EOF:=SizeOfFile(Secondary^.FN); Secondary^.X:=D.X; Secondary^.BlockStart:=-1; Secondary^.BlockStart:=-2; Relocate(Secondary^); CheckFileType(Secondary^); End; {------------------------------------------------------------------------} Procedure SwapFiles(Var D:DataType); Var tmp:DataType; tmpImage:BinaryImagePointer; F:File Of BinaryImage; Error:Integer; Begin If Secondary=Nil Then Exit; tmp:=Secondary^; Secondary^:=D; D:=tmp; If HelpDir='' Then Assign(F,'VIRT.000') Else Assign(F,HelpDir+'\VIRT.000'); Rewrite(F); Error:=IOResult; If Error<>0 Then Exit; Write(F,Secondary^.D^); Error:=IOResult; If Error<>0 Then Begin ErrorMsg('Error writing temp file'); CloseWindow; Exit; End; Close(F); Secondary^.D^:=D.D^; Reset(F); Error:=IOResult; If Error<>0 Then Begin ErrorMsg('Error opeing temp file'); Exit; End; Read(F,D.D^); If Error<>0 Then Begin ErrorMsg('Error reading temp file'); Exit; End; Close(F); Erase(F); Repeat Until IOResult=0; tmpImage:=Secondary^.D; Secondary^.D:=D.D; D.D:=tmpImage; WriteScreen(D); End; {------------------------------------------------------------------------} Procedure SearchDiff(Var D:DataType); Var SaveX,SaveOffset:LongInt; I:Word; Begin If Secondary=Nil Then Exit; SaveSegment(D); SaveX:=D.X; SaveOffset:=D.Offset; D.offset:=D.X+D.offset; Secondary^.offset:=D.offset; D.X:=1; Secondary^.X:=1; OpenWindow(10,10,70,12,ICFG.MsgColor); GotoXY(1,1); Write('Comparing ',D.FN,' to ',Secondary^.FN); HideCursor; While (D.offset+D.X<D.EOF) And NOT KeyPressed Do Begin GotoXY(1,2); Writeln('checking segment at offset :',D.X+D.offset,'/',D.EOF); Write('$',Long2Str(D.X+D.offset),'/$',Long2Str(D.EOF)); RestoreSegment(D); RestoreSegment(Secondary^); For I:=1 To imagesize Do If D.D^[I]<>Secondary^.D^[I] Then Begin D.X:=I; CloseWindow; ShowCursor; Exit; End; D.offset:=D.offset+imagesize-100; Secondary^.offset:=D.offset; D.X:=1; Secondary^.X:=1; End; CloseWindow; D.X:=SaveX; D.Offset:=SaveOffset; RestoreSegment(D); If KeyPressed Then Readkey; ShowCursor; End; {======================================================================} End.
unit UMathResid3; { ClickForms Application } { Bradford Technologies, Inc. } { All Rights Reserved } { Source Code Copyrighted © 1998-2008 by Bradford Technologies, Inc. } { This is unit for the Appraisal Institute forms } interface uses UGlobals, UContainer; const fmAI_SiteValuation = 374; fmAI_MarketAnalysis = 372; fmAI_Improvements = 373; fmAI_CostApproach = 376; fmAI_IncomeApproach = 377; fmAI_SalesApproach = 378; fmAI_XComps = 391; fmAI_XRental = 392; fmAI_XSites = 393; fmAI_PhotoComps = 388; fmAI_PhotoSites = 389; fmAI_PhotoRentals = 390; fmAI_Map = 383; fmAI_Exhibit = 384; fmAI_Comments = 382; fmAI_LandSummary = 848; fmAI_LandMktAnalysis = 1303; fmAI_LandSiteVal = 1304; fmAI_RestrictedUse = 847; fmAI_ResUseMktAnalysis = 1307; fmAI_ResUseImpAnalysis = 1308; fmAI_ResUseSiteEval = 1309; fmAI_ResUseCostApproach = 1310; fmAI_ResUseIncomeApproach = 1311; fmAI_ResUseSalesComp = 1312; fmAI_ResidentialSummary = 846; fmAI_SumMktAnalysis = 1315; fmAI_SumImpAnalysis = 1316; fmAI_SumSiteEval = 1317; fmAI_SumCostApproach = 1318; fmAI_SumIncomeApproach = 1319; fmAI_SumSalesComp = 1320; fmAI_ResSumXComps = 939; fmAI_ResSumXRental = 940; fmAI_ResSumXSites = 941; fmAI_LiquidValue = 921; fmAI_CostApproach_1323 = 1323; //Ticket #1342: AI math fmAI_AIRestricted_1321 = 1321; //Ticket #1342: AI math fmAI_AIResidential_1322 = 1322; //Ticket #1342: AI math fmAI_CostApproach_1324 = 1324; //Ticket #1342: AI math fmAI_AILandSummary_1325 = 1325; //Ticket #1342: AI math fmAI_ExtraComp_1328 = 1328; //Ticket #1342: mimic form 941 with more cells in transfer section function ProcessForm0374Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; function ProcessForm0373Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; function ProcessForm0376Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; function ProcessForm0372Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; function ProcessForm0377Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; function ProcessForm0378Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; function ProcessForm0382Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; function ProcessForm0383Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; function ProcessForm0384Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; function ProcessForm0391Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; function ProcessForm0392Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; function ProcessForm0393Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; function ProcessForm0388Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; function ProcessForm0389Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; function ProcessForm0390Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; function ProcessForm0848Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; function ProcessForm1303Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; function ProcessForm1304Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; function ProcessForm0847Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; function ProcessForm1307Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; function ProcessForm1308Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; function ProcessForm1309Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; function ProcessForm1310Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; function ProcessForm1311Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; function ProcessForm1312Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; function ProcessForm0846Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; function ProcessForm1315Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; function ProcessForm1316Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; function ProcessForm1317Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; function ProcessForm1318Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; function ProcessForm1319Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; function ProcessForm1320Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; function ProcessForm0939Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; function ProcessForm0940Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; function ProcessForm0941Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; function ProcessForm0921Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; //Ticket #1342 Add new maths for new AI forms function ProcessForm1323Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; function ProcessForm1321Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; function ProcessForm1322Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; function ProcessForm1324Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; function ProcessForm1325Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; function ProcessForm1328Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; implementation uses Dialogs, SysUtils, Math, UUtil1, UStatus, UBase, UForm, UPage, UCell, UMath, UStrings; //calc functional depr function CalcDeprLessPhy(doc: TContainer; CX: CellUID; V1, V2, V3: Double): Double; var VR: double; begin result := 0; // V1 = funct depr percent // V2 = new cost // V3 = Phy Depr if (V2-V3)>0 then //phy depr cannot be larger begin VR := (V2-V3)*(V1/100); result := VR; end; end; function F0374C1Adjustments(doc: TContainer; CX: CellUID) : Integer; const SalesAmt = 34; AcrePrice = 35; TotalAdj = 58; FinalAmt = 59; PlusChk = 56; NegChk = 57; InfoNet = 3; InfoGross = 4; var NetAdj,GrsAdj: Double; saleValue, NetPct, GrsPct: Double; begin NetAdj := 0; GrsAdj := 0; GetNetGrosAdjs(doc, mcx(cx,37), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,39), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,41), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,43), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,45), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,47), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,49), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,51), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,53), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,55), NetAdj, GrsAdj); SetCellValue(doc, mcx(cx,TotalAdj), NetAdj); //set sum of Adj if (NetAdj>=0) then SetCellChkMark(doc, mcx(cx,PlusChk), True) //toggle the checkmarks else SetCellChkMark(doc, mcx(cx,NegChk), True); NetPct := 0; GrsPct := 0; if appPref_AppraiserUseLandPriceUnits then saleValue := GetCellValue(doc, mcx(cx,AcrePrice)) else saleValue := GetCellValue(doc, mcx(cx,salesAmt)); //calc the net/grs percents if saleValue <> 0 then begin NetPct := (NetAdj / saleValue) * 100; GrsPct := (GrsAdj / saleValue) * 100; SumOfWeightedValues := SumOfWeightedValues + (1-GrsPct/100) * (saleValue+ NetAdj); SumOfWeights := SumOfWeights + (1-GrsPct/100); end; SetInfoCellValue(doc, mcx(cx,infoNet), NetPct); SetInfoCellValue(doc, mcx(cx,infoGross), GrsPct); //set the info cells result := SetCellValue(doc, mcx(cx,FinalAmt), saleValue+ NetAdj); //set final adj price end; function F0846SiteValuationC1Adjustments(doc: TContainer; CX: CellUID) : Integer; const SalesAmt = 35; AcrePrice = 36; TotalAdj = 59; FinalAmt = 60; PlusChk = 57; NegChk = 58; InfoNet = 1; InfoGross = 2; var NetAdj,GrsAdj: Double; saleValue, NetPct, GrsPct: Double; begin NetAdj := 0; GrsAdj := 0; GetNetGrosAdjs(doc, mcx(cx,38), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,40), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,42), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,44), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,46), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,48), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,50), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,52), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,54), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,56), NetAdj, GrsAdj); SetCellValue(doc, mcx(cx,TotalAdj), NetAdj); //set sum of Adj if (NetAdj>=0) then SetCellChkMark(doc, mcx(cx,PlusChk), True) //toggle the checkmarks else SetCellChkMark(doc, mcx(cx,NegChk), True); NetPct := 0; GrsPct := 0; if appPref_AppraiserUseLandPriceUnits then saleValue := GetCellValue(doc, mcx(cx,AcrePrice)) else saleValue := GetCellValue(doc, mcx(cx,salesAmt)); //calc the net/grs percents if saleValue <> 0 then begin NetPct := (NetAdj / saleValue) * 100; GrsPct := (GrsAdj / saleValue) * 100; SumOfWeightedValues := SumOfWeightedValues + (1-GrsPct/100) * (saleValue+ NetAdj); SumOfWeights := SumOfWeights + (1-GrsPct/100); end; SetInfoCellValue(doc, mcx(cx,infoNet), NetPct); SetInfoCellValue(doc, mcx(cx,infoGross), GrsPct); //set the info cells result := SetCellValue(doc, mcx(cx,FinalAmt), saleValue+ NetAdj); //set final adj price end; function F0846SiteValuationC2Adjustments(doc: TContainer; CX: CellUID) : Integer; const SalesAmt = 66; AcrePrice = 67; TotalAdj = 90; FinalAmt = 91; PlusChk = 88; NegChk = 89; InfoNet = 3; InfoGross = 4; var NetAdj,GrsAdj: Double; saleValue, NetPct, GrsPct: Double; begin NetAdj := 0; GrsAdj := 0; GetNetGrosAdjs(doc, mcx(cx,69), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,71), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,73), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,75), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,77), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,79), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,81), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,83), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,85), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,87), NetAdj, GrsAdj); SetCellValue(doc, mcx(cx,TotalAdj), NetAdj); //set sum of Adj if (NetAdj>=0) then SetCellChkMark(doc, mcx(cx,PlusChk), True) //toggle the checkmarks else SetCellChkMark(doc, mcx(cx,NegChk), True); NetPct := 0; GrsPct := 0; if appPref_AppraiserUseLandPriceUnits then saleValue := GetCellValue(doc, mcx(cx,AcrePrice)) else saleValue := GetCellValue(doc, mcx(cx,salesAmt)); //calc the net/grs percents if saleValue <> 0 then begin NetPct := (NetAdj / saleValue) * 100; GrsPct := (GrsAdj / saleValue) * 100; SumOfWeightedValues := SumOfWeightedValues + (1-GrsPct/100) * (saleValue+ NetAdj); SumOfWeights := SumOfWeights + (1-GrsPct/100); end; SetInfoCellValue(doc, mcx(cx,infoNet), NetPct); SetInfoCellValue(doc, mcx(cx,infoGross), GrsPct); //set the info cells result := SetCellValue(doc, mcx(cx,FinalAmt), saleValue+ NetAdj); //set final adj price end; function F0846SiteValuationC3Adjustments(doc: TContainer; CX: CellUID) : Integer; const SalesAmt = 97; AcrePrice = 98; TotalAdj = 121; FinalAmt = 122; PlusChk = 119; NegChk = 120; InfoNet = 5; InfoGross = 6; var NetAdj,GrsAdj: Double; saleValue, NetPct, GrsPct: Double; begin NetAdj := 0; GrsAdj := 0; GetNetGrosAdjs(doc, mcx(cx,100), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,102), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,104), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,106), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,108), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,110), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,112), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,114), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,116), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,118), NetAdj, GrsAdj); SetCellValue(doc, mcx(cx,TotalAdj), NetAdj); //set sum of Adj if (NetAdj>=0) then SetCellChkMark(doc, mcx(cx,PlusChk), True) //toggle the checkmarks else SetCellChkMark(doc, mcx(cx,NegChk), True); NetPct := 0; GrsPct := 0; if appPref_AppraiserUseLandPriceUnits then saleValue := GetCellValue(doc, mcx(cx,AcrePrice)) else saleValue := GetCellValue(doc, mcx(cx,salesAmt)); //calc the net/grs percents if saleValue <> 0 then begin NetPct := (NetAdj / saleValue) * 100; GrsPct := (GrsAdj / saleValue) * 100; SumOfWeightedValues := SumOfWeightedValues + (1-GrsPct/100) * (saleValue+ NetAdj); SumOfWeights := SumOfWeights + (1-GrsPct/100); end; SetInfoCellValue(doc, mcx(cx,infoNet), NetPct); SetInfoCellValue(doc, mcx(cx,infoGross), GrsPct); //set the info cells result := SetCellValue(doc, mcx(cx,FinalAmt), saleValue+ NetAdj); //set final adj price end; function F1317SiteValuationC1Adjustments(doc: TContainer; CX: CellUID) : Integer; const SalesAmt = 35; AcrePrice = 36; TotalAdj = 59; FinalAmt = 60; PlusChk = 57; NegChk = 58; InfoNet = 1; InfoGross = 2; var NetAdj,GrsAdj: Double; saleValue, NetPct, GrsPct: Double; begin NetAdj := 0; GrsAdj := 0; GetNetGrosAdjs(doc, mcx(cx,38), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,40), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,42), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,44), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,46), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,48), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,50), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,52), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,54), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,56), NetAdj, GrsAdj); SetCellValue(doc, mcx(cx,TotalAdj), NetAdj); //set sum of Adj if (NetAdj>=0) then SetCellChkMark(doc, mcx(cx,PlusChk), True) //toggle the checkmarks else SetCellChkMark(doc, mcx(cx,NegChk), True); NetPct := 0; GrsPct := 0; if appPref_AppraiserUseLandPriceUnits then saleValue := GetCellValue(doc, mcx(cx,AcrePrice)) else saleValue := GetCellValue(doc, mcx(cx,salesAmt)); //calc the net/grs percents if saleValue <> 0 then begin NetPct := (NetAdj / saleValue) * 100; GrsPct := (GrsAdj / saleValue) * 100; SumOfWeightedValues := SumOfWeightedValues + (1-GrsPct/100) * (saleValue+ NetAdj); SumOfWeights := SumOfWeights + (1-GrsPct/100); end; SetInfoCellValue(doc, mcx(cx,infoNet), NetPct); SetInfoCellValue(doc, mcx(cx,infoGross), GrsPct); //set the info cells result := SetCellValue(doc, mcx(cx,FinalAmt), saleValue+ NetAdj); //set final adj price end; function F1317SiteValuationC2Adjustments(doc: TContainer; CX: CellUID) : Integer; const SalesAmt = 66; AcrePrice = 67; TotalAdj = 90; FinalAmt = 91; PlusChk = 88; NegChk = 89; InfoNet = 3; InfoGross = 4; var NetAdj,GrsAdj: Double; saleValue, NetPct, GrsPct: Double; begin NetAdj := 0; GrsAdj := 0; GetNetGrosAdjs(doc, mcx(cx,69), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,71), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,73), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,75), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,77), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,79), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,81), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,83), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,85), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,87), NetAdj, GrsAdj); SetCellValue(doc, mcx(cx,TotalAdj), NetAdj); //set sum of Adj if (NetAdj>=0) then SetCellChkMark(doc, mcx(cx,PlusChk), True) //toggle the checkmarks else SetCellChkMark(doc, mcx(cx,NegChk), True); NetPct := 0; GrsPct := 0; if appPref_AppraiserUseLandPriceUnits then saleValue := GetCellValue(doc, mcx(cx,AcrePrice)) else saleValue := GetCellValue(doc, mcx(cx,salesAmt)); //calc the net/grs percents if saleValue <> 0 then begin NetPct := (NetAdj / saleValue) * 100; GrsPct := (GrsAdj / saleValue) * 100; SumOfWeightedValues := SumOfWeightedValues + (1-GrsPct/100) * (saleValue+ NetAdj); SumOfWeights := SumOfWeights + (1-GrsPct/100); end; SetInfoCellValue(doc, mcx(cx,infoNet), NetPct); SetInfoCellValue(doc, mcx(cx,infoGross), GrsPct); //set the info cells result := SetCellValue(doc, mcx(cx,FinalAmt), saleValue+ NetAdj); //set final adj price end; function F1317SiteValuationC3Adjustments(doc: TContainer; CX: CellUID) : Integer; const SalesAmt = 97; AcrePrice = 98; TotalAdj = 121; FinalAmt = 122; PlusChk = 119; NegChk = 120; InfoNet = 5; InfoGross = 6; var NetAdj,GrsAdj: Double; saleValue, NetPct, GrsPct: Double; begin NetAdj := 0; GrsAdj := 0; GetNetGrosAdjs(doc, mcx(cx,100), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,102), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,104), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,106), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,108), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,110), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,112), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,114), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,116), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,118), NetAdj, GrsAdj); SetCellValue(doc, mcx(cx,TotalAdj), NetAdj); //set sum of Adj if (NetAdj>=0) then SetCellChkMark(doc, mcx(cx,PlusChk), True) //toggle the checkmarks else SetCellChkMark(doc, mcx(cx,NegChk), True); NetPct := 0; GrsPct := 0; if appPref_AppraiserUseLandPriceUnits then saleValue := GetCellValue(doc, mcx(cx,AcrePrice)) else saleValue := GetCellValue(doc, mcx(cx,salesAmt)); //calc the net/grs percents if saleValue <> 0 then begin NetPct := (NetAdj / saleValue) * 100; GrsPct := (GrsAdj / saleValue) * 100; SumOfWeightedValues := SumOfWeightedValues + (1-GrsPct/100) * (saleValue+ NetAdj); SumOfWeights := SumOfWeights + (1-GrsPct/100); end; SetInfoCellValue(doc, mcx(cx,infoNet), NetPct); SetInfoCellValue(doc, mcx(cx,infoGross), GrsPct); //set the info cells result := SetCellValue(doc, mcx(cx,FinalAmt), saleValue+ NetAdj); //set final adj price end; function F0374C2Adjustments(doc: TContainer; CX: CellUID) : Integer; const SalesAmt = 65; AcrePrice = 66; TotalAdj = 89; FinalAmt = 90; PlusChk = 87; NegChk = 88; InfoNet = 5; InfoGross = 6; var NetAdj,GrsAdj: Double; saleValue, NetPct, GrsPct: Double; begin NetAdj := 0; GrsAdj := 0; GetNetGrosAdjs(doc, mcx(cx,68), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,70), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,72), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,74), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,76), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,78), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,80), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,82), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,84), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,86), NetAdj, GrsAdj); SetCellValue(doc, mcx(cx,TotalAdj), NetAdj); //set sum of Adj if (NetAdj>=0) then SetCellChkMark(doc, mcx(cx,PlusChk), True) //toggle the checkmarks else SetCellChkMark(doc, mcx(cx,NegChk), True); NetPct := 0; GrsPct := 0; if appPref_AppraiserUseLandPriceUnits then saleValue := GetCellValue(doc, mcx(cx,AcrePrice)) else saleValue := GetCellValue(doc, mcx(cx,salesAmt)); //calc the net/grs percents if saleValue <> 0 then begin NetPct := (NetAdj / saleValue) * 100; GrsPct := (GrsAdj / saleValue) * 100; SumOfWeightedValues := SumOfWeightedValues + (1-GrsPct/100) * (saleValue+ NetAdj); SumOfWeights := SumOfWeights + (1-GrsPct/100); end; SetInfoCellValue(doc, mcx(cx,infoNet), NetPct); SetInfoCellValue(doc, mcx(cx,infoGross), GrsPct); //set the info cells result := SetCellValue(doc, mcx(cx,FinalAmt), saleValue+ NetAdj); //set final adj price end; function F0374C3Adjustments(doc: TContainer; CX: CellUID) : Integer; const SalesAmt = 96; AcrePrice = 97; TotalAdj = 120; FinalAmt = 121; PlusChk = 118; NegChk = 119; InfoNet = 7; InfoGross = 8; var NetAdj,GrsAdj: Double; saleValue, NetPct, GrsPct: Double; begin NetAdj := 0; GrsAdj := 0; GetNetGrosAdjs(doc, mcx(cx,99), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,101), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,103), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,105), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,107), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,109), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,111), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,113), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,115), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,117), NetAdj, GrsAdj); SetCellValue(doc, mcx(cx,TotalAdj), NetAdj); //set sum of Adj if (NetAdj>=0) then SetCellChkMark(doc, mcx(cx,PlusChk), True) //toggle the checkmarks else SetCellChkMark(doc, mcx(cx,NegChk), True); NetPct := 0; GrsPct := 0; if appPref_AppraiserUseLandPriceUnits then saleValue := GetCellValue(doc, mcx(cx,AcrePrice)) else saleValue := GetCellValue(doc, mcx(cx,salesAmt)); //calc the net/grs percents if saleValue <> 0 then begin NetPct := (NetAdj / saleValue) * 100; GrsPct := (GrsAdj / saleValue) * 100; SumOfWeightedValues := SumOfWeightedValues + (1-GrsPct/100) * (saleValue+ NetAdj); SumOfWeights := SumOfWeights + (1-GrsPct/100); end; SetInfoCellValue(doc, mcx(cx,infoNet), NetPct); SetInfoCellValue(doc, mcx(cx,infoGross), GrsPct); //set the info cells result := SetCellValue(doc, mcx(cx,FinalAmt), saleValue+ NetAdj); //set final adj price end; function F0377C1Adjustments(doc: TContainer; CX: CellUID): Integer; begin result := SalesGridAdjustment(doc, CX, 45,74,75,72,73,2,3, [47,49,51,53,55,57,59,61,63,65,67,69,71]); end; function F0846IncomeAppC1Adjustments(doc: TContainer; CX: CellUID): Integer; begin result := SalesGridAdjustment(doc, CX, 46,77,78,75,76,1,2, [48,50,52,54,56,58,60,62,64,66,68,70,72,74]); end; function F0940IncomeAppC1Adjustments(doc: TContainer; CX: CellUID): Integer; begin result := SalesGridAdjustment(doc, CX, 48,79,80,77,78,1,2, [50,52,54,56,58,60,62,64,66,68,70,72,74,76]); end; function F0847IncomeAppC1Adjustments(doc: TContainer; CX: CellUID): Integer; begin result := SalesGridAdjustment(doc, CX, 46,77,78,75,76,1,2, [48,50,52,54,56,58,60,62,64,66,68,70,72,74]); end; function F0377C2Adjustments(doc: TContainer; CX: CellUID): Integer; begin result := SalesGridAdjustment(doc, CX, 90,119,120,117,118,4,5, [92,94,96,98,100,102,104,106,108,110,112,114,116]); end; function F0846IncomeAppC2Adjustments(doc: TContainer; CX: CellUID): Integer; begin result := SalesGridAdjustment(doc, CX, 93,124,125,122,123,3,4, [95,97,99,101,103,105,107,109,111,113,115,117,119,121]); end; function F0940IncomeAppC2Adjustments(doc: TContainer; CX: CellUID): Integer; begin result := SalesGridAdjustment(doc, CX, 96,127,128,125,126,3,4, [98,100,102,104,106,108,110,112,114,116,118,120,122,124]); end; function F0847IncomeAppC2Adjustments(doc: TContainer; CX: CellUID): Integer; begin result := SalesGridAdjustment(doc, CX, 93,124,125,122,123,3,4, [95,97,99,101,103,105,107,109,111,113,115,117,119,121]); end; function F0377C3Adjustments(doc: TContainer; CX: CellUID): Integer; begin result := SalesGridAdjustment(doc, CX, 135,164,165,162,163,6,7, [137,139,141,143,145,147,149,151,153,155,157,159,161]); end; function F0846IncomeAppC3Adjustments(doc: TContainer; CX: CellUID): Integer; begin result := SalesGridAdjustment(doc, CX, 140,171,172,169,170,5,6, [142,144,146,148,150,152,154,156,158,160,162,164,166,168]); end; function F0940IncomeAppC3Adjustments(doc: TContainer; CX: CellUID): Integer; begin result := SalesGridAdjustment(doc, CX, 144,175,176,173,174,5,6, [146,148,150,152,154,156,158,160,162,164,166,168,170,172]); end; function F0847IncomeAppC3Adjustments(doc: TContainer; CX: CellUID): Integer; begin result := SalesGridAdjustment(doc, CX, 140,171,172,169,170,5,6, [142,144,146,148,150,152,154,156,158,160,162,164,166,168]); end; function F0378C1Adjustments(doc: TContainer; CX: CellUID): Integer; begin result := SalesGridAdjustment(doc, CX, 45,100,101,98,99,3,4, [53,55,57,59,61,63,65,67,69,71,73,75,77,79,81,83,85,87,89,91,93,95,97]); end; function F0846SalesCompAppC1Adjustments(doc: TContainer; CX: CellUID): Integer; begin result := SalesGridAdjustment(doc, CX, 50,104,105,102,103,1,2, [57,59,61,63,65,67,69,71,73,75,77,79,81,83,85,87,89,91,93,95,97,99,101]); end; function F0847SalesCompAppC1Adjustments(doc: TContainer; CX: CellUID): Integer; begin result := SalesGridAdjustment(doc, CX, 50,104,105,102,103,1,2, [57,59,61,63,65,67,69,71,73,75,77,79,81,83,85,87,89,91,93,95,97,99,101]); end; function F0939SalesCompAppC1Adjustments(doc: TContainer; CX: CellUID): Integer; begin result := SalesGridAdjustment(doc, CX, 52,106,107,104,105,1,2, [59,61,63,65,67,69,71,73,75,77,79,81,83,85,87,89,91,93,95,97,99,101,103]); end; function F1328SalesCompAppC1Adjustments(doc: TContainer; CX: CellUID): Integer; begin result := SalesGridAdjustment(doc, CX, 52,106,107,104,105,1,2, [59,61,63,65,67,69,71,73,75,77,79,81,83,85,87,89,91,93,95,97,99,101,103]); end; function F1309SalesCompAppC1Adjustments(doc: TContainer; CX: CellUID): Integer; begin result := SalesGridAdjustment(doc, CX, 35,59,60,57,58,1,2, [38,40,42,44,46,48,50,52,54,56]); end; function F1312SalesCompAppC1Adjustments(doc: TContainer; CX: CellUID): Integer; begin result := SalesGridAdjustment(doc, CX, 50,104,105,102,103,1,2, [57,59,61,63,65,67,69,71,73,75,77,79,81,83,85,87,89,91,93,95,97,99,101]); end; function F0378C2Adjustments(doc: TContainer; CX: CellUID): Integer; begin result := SalesGridAdjustment(doc, CX, 106,161,162,159,160,5,6, [114,116,118,120,122,124,126,128,130,132,134,136,138,140,142,144,146,148,150,152,154,156,158]); end; function F0846SalesCompAppC2Adjustments(doc: TContainer; CX: CellUID): Integer; begin result := SalesGridAdjustment(doc, CX, 113,167,168,165,166,3,4, [120,122,124,126,128,130,132,134,136,138,140,142,144,146,148,150,152,154,156,158,160,162,164]); end; function F0847SalesCompAppC2Adjustments(doc: TContainer; CX: CellUID): Integer; begin result := SalesGridAdjustment(doc, CX, 113,167,168,165,166,3,4, [120,122,124,126,128,130,132,134,136,138,140,142,144,146,148,150,152,154,156,158,160,162,164]); end; function F0939SalesCompAppC2Adjustments(doc: TContainer; CX: CellUID): Integer; begin result := SalesGridAdjustment(doc, CX, 116,170,171,168,169,3,4, [123,125,127,129,131,133,135,137,139,141,143,145,147,149,151,153,155,157,159,161,163,165,167]); end; function F1328SalesCompAppC2Adjustments(doc: TContainer; CX: CellUID): Integer; begin result := SalesGridAdjustment(doc, CX, 116,170,171,168,169,3,4, [123,125,127,129,131,133,135,137,139,141,143,145,147,149,151,153,155,157,159,161,163,165,167]); end; function F1309SalesCompAppC2Adjustments(doc: TContainer; CX: CellUID): Integer; begin result := SalesGridAdjustment(doc, CX, 66,90,91,88,89,3,4, [69,71,73,75,77,79,81,83,85,87]); end; function F1312SalesCompAppC2Adjustments(doc: TContainer; CX: CellUID): Integer; begin result := SalesGridAdjustment(doc, CX, 113,167,168,165,166,3,4, [120,122,124,126,128,130,132,134,136,138,140,142,144,146,148,150,152,154,156,158,160,162,164]); end; function F0378C3Adjustments(doc: TContainer; CX: CellUID): Integer; begin result := SalesGridAdjustment(doc, CX, 167,222,223,220,221,7,8, [175,177,179,181,183,185,187,189,191,193,195,197,199,201,203,205,207,209,211,213,215,217,219]); end; function F0846SalesCompAppC3Adjustments(doc: TContainer; CX: CellUID): Integer; begin result := SalesGridAdjustment(doc, CX, 176,230,231,228,229,5,6, [183,185,187,189,191,193,195,197,199,201,203,205,207,209,211,213,215,217,219,221,223,225,227]); end; function F0847SalesCompAppC3Adjustments(doc: TContainer; CX: CellUID): Integer; begin result := SalesGridAdjustment(doc, CX, 176,230,231,228,229,5,6, [183,185,187,189,191,193,195,197,199,201,203,205,207,209,211,213,215,217,219,221,223,225,227]); end; function F0939SalesCompAppC3Adjustments(doc: TContainer; CX: CellUID): Integer; begin result := SalesGridAdjustment(doc, CX, 180,234,235,232,233,5,6, [187,189,191,193,195,197,199,201,203,205,207,209,211,213,215,217,219,221,223,225,227,229,231]); end; function F1328SalesCompAppC3Adjustments(doc: TContainer; CX: CellUID): Integer; begin result := SalesGridAdjustment(doc, CX, 180,234,235,232,233,5,6, [187,189,191,193,195,197,199,201,203,205,207,209,211,213,215,217,219,221,223,225,227,229,231]); end; function F1309SalesCompAppC3Adjustments(doc: TContainer; CX: CellUID): Integer; begin result := SalesGridAdjustment(doc, CX, 97,121,122,119,120,5,6, [100,102,104,106,108,110,112,114,116,118]); end; function F1312SalesCompAppC3Adjustments(doc: TContainer; CX: CellUID): Integer; begin result := SalesGridAdjustment(doc, CX, 176,230,231,228,229,5,6, [183,185,187,189,191,193,195,197,199,201,203,205,207,209,211,213,215,217,219,221,223,225,227]); end; function F0391C1Adjustments(doc: TContainer; CX: CellUID): Integer; begin result := SalesGridAdjustment(doc, CX, 47,102,103,100,101,3,4, [55,57,59,61,63,65,67,69,71,73,75,77,79,81,83,85,87,89,91,93,95,97,99]); end; function F0391C2Adjustments(doc: TContainer; CX: CellUID): Integer; begin result := SalesGridAdjustment(doc, CX, 109,164,165,162,163,5,6, [117,119,121,123,125,127,129,131,133,135,137,139,141,143,145,147,149,151,153,155,157,159,161]); end; function F0391C3Adjustments(doc: TContainer; CX: CellUID): Integer; begin result := SalesGridAdjustment(doc, CX, 171,226,227,224,225,7,8, [179,181,183,185,187,189,191,193,195,197,199,201,203,205,207,209,211,213,215,217,219,221,223]); end; function F0392C1Adjustments(doc: TContainer; CX: CellUID): Integer; begin result := SalesGridAdjustment(doc, CX, 47,76,77,74,75,2,3, [49,51,53,55,57,59,61,63,65,67,69,71,73]); end; function F0392C2Adjustments(doc: TContainer; CX: CellUID): Integer; begin result := SalesGridAdjustment(doc, CX, 93,122,123,120,121,4,5, [95,97,99,101,103,105,107,109,111,113,115,117,119]); end; function F0392C3Adjustments(doc: TContainer; CX: CellUID): Integer; begin result := SalesGridAdjustment(doc, CX, 139,168,169,166,167,6,7, [141,143,145,147,149,151,153,155,157,159,161,163,165]); end; function F0393C1Adjustments(doc: TContainer; CX: CellUID) : Integer; const SalesAmt = 36; AcrePrice = 37; TotalAdj = 60; FinalAmt = 61; PlusChk = 58; NegChk = 59; InfoNet = 3; InfoGross = 4; var NetAdj,GrsAdj: Double; saleValue, NetPct, GrsPct: Double; begin NetAdj := 0; GrsAdj := 0; GetNetGrosAdjs(doc, mcx(cx,39), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,41), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,43), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,45), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,47), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,49), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,51), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,53), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,55), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,57), NetAdj, GrsAdj); SetCellValue(doc, mcx(cx,TotalAdj), NetAdj); //set sum of Adj if (NetAdj>=0) then SetCellChkMark(doc, mcx(cx,PlusChk), True) //toggle the checkmarks else SetCellChkMark(doc, mcx(cx,NegChk), True); NetPct := 0; GrsPct := 0; if appPref_AppraiserUseLandPriceUnits then saleValue := GetCellValue(doc, mcx(cx,AcrePrice)) else saleValue := GetCellValue(doc, mcx(cx,salesAmt)); //calc the net/grs percents if saleValue <> 0 then begin NetPct := (NetAdj / saleValue) * 100; GrsPct := (GrsAdj / saleValue) * 100; SumOfWeightedValues := SumOfWeightedValues + (1-GrsPct/100) * (saleValue+ NetAdj); SumOfWeights := SumOfWeights + (1-GrsPct/100); end; SetInfoCellValue(doc, mcx(cx,infoNet), NetPct); SetInfoCellValue(doc, mcx(cx,infoGross), GrsPct); //set the info cells result := SetCellValue(doc, mcx(cx,FinalAmt), saleValue+ NetAdj); //set final adj price end; function F0393C2Adjustments(doc: TContainer; CX: CellUID) : Integer; const SalesAmt = 68; AcrePrice = 69; TotalAdj = 92; FinalAmt = 93; PlusChk = 90; NegChk = 91; InfoNet = 5; InfoGross = 6; var NetAdj,GrsAdj: Double; saleValue, NetPct, GrsPct: Double; begin NetAdj := 0; GrsAdj := 0; GetNetGrosAdjs(doc, mcx(cx,71), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,73), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,75), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,77), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,79), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,81), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,83), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,85), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,87), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,89), NetAdj, GrsAdj); SetCellValue(doc, mcx(cx,TotalAdj), NetAdj); //set sum of Adj if (NetAdj>=0) then SetCellChkMark(doc, mcx(cx,PlusChk), True) //toggle the checkmarks else SetCellChkMark(doc, mcx(cx,NegChk), True); NetPct := 0; GrsPct := 0; if appPref_AppraiserUseLandPriceUnits then saleValue := GetCellValue(doc, mcx(cx,AcrePrice)) else saleValue := GetCellValue(doc, mcx(cx,salesAmt)); //calc the net/grs percents if saleValue <> 0 then begin NetPct := (NetAdj / saleValue) * 100; GrsPct := (GrsAdj / saleValue) * 100; SumOfWeightedValues := SumOfWeightedValues + (1-GrsPct/100) * (saleValue+ NetAdj); SumOfWeights := SumOfWeights + (1-GrsPct/100); end; SetInfoCellValue(doc, mcx(cx,infoNet), NetPct); SetInfoCellValue(doc, mcx(cx,infoGross), GrsPct); //set the info cells result := SetCellValue(doc, mcx(cx,FinalAmt), saleValue+ NetAdj); //set final adj price end; function F0393C3Adjustments(doc: TContainer; CX: CellUID) : Integer; const SalesAmt = 100; AcrePrice = 101; TotalAdj = 124; FinalAmt = 125; PlusChk = 122; NegChk = 123; InfoNet = 7; InfoGross = 8; var NetAdj,GrsAdj: Double; saleValue, NetPct, GrsPct: Double; begin NetAdj := 0; GrsAdj := 0; GetNetGrosAdjs(doc, mcx(cx,103), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,105), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,107), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,109), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,111), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,113), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,115), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,117), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,119), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,121), NetAdj, GrsAdj); SetCellValue(doc, mcx(cx,TotalAdj), NetAdj); //set sum of Adj if (NetAdj>=0) then SetCellChkMark(doc, mcx(cx,PlusChk), True) //toggle the checkmarks else SetCellChkMark(doc, mcx(cx,NegChk), True); NetPct := 0; GrsPct := 0; if appPref_AppraiserUseLandPriceUnits then saleValue := GetCellValue(doc, mcx(cx,AcrePrice)) else saleValue := GetCellValue(doc, mcx(cx,salesAmt)); //calc the net/grs percents if saleValue <> 0 then begin NetPct := (NetAdj / saleValue) * 100; GrsPct := (GrsAdj / saleValue) * 100; SumOfWeightedValues := SumOfWeightedValues + (1-GrsPct/100) * (saleValue+ NetAdj); SumOfWeights := SumOfWeights + (1-GrsPct/100); end; SetInfoCellValue(doc, mcx(cx,infoNet), NetPct); SetInfoCellValue(doc, mcx(cx,infoGross), GrsPct); //set the info cells result := SetCellValue(doc, mcx(cx,FinalAmt), saleValue+ NetAdj); //set final adj price end; function F0941C1Adjustments(doc: TContainer; CX: CellUID) : Integer; const SalesAmt = 37; AcrePrice = 38; TotalAdj = 61; FinalAmt = 62; PlusChk = 59; NegChk = 60; InfoNet = 1; InfoGross = 2; var NetAdj,GrsAdj: Double; saleValue, NetPct, GrsPct: Double; begin NetAdj := 0; GrsAdj := 0; GetNetGrosAdjs(doc, mcx(cx,40), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,42), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,44), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,46), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,48), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,50), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,52), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,54), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,56), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,58), NetAdj, GrsAdj); SetCellValue(doc, mcx(cx,TotalAdj), NetAdj); //set sum of Adj if (NetAdj>=0) then SetCellChkMark(doc, mcx(cx,PlusChk), True) //toggle the checkmarks else SetCellChkMark(doc, mcx(cx,NegChk), True); NetPct := 0; GrsPct := 0; if appPref_AppraiserUseLandPriceUnits then saleValue := GetCellValue(doc, mcx(cx,AcrePrice)) else saleValue := GetCellValue(doc, mcx(cx,salesAmt)); //calc the net/grs percents if saleValue <> 0 then begin NetPct := (NetAdj / saleValue) * 100; GrsPct := (GrsAdj / saleValue) * 100; SumOfWeightedValues := SumOfWeightedValues + (1-GrsPct/100) * (saleValue+ NetAdj); SumOfWeights := SumOfWeights + (1-GrsPct/100); end; SetInfoCellValue(doc, mcx(cx,infoNet), NetPct); SetInfoCellValue(doc, mcx(cx,infoGross), GrsPct); //set the info cells result := SetCellValue(doc, mcx(cx,FinalAmt), saleValue+ NetAdj); //set final adj price end; function F0941C2Adjustments(doc: TContainer; CX: CellUID) : Integer; const SalesAmt = 69; AcrePrice = 70; TotalAdj = 93; FinalAmt = 94; PlusChk = 91; NegChk = 92; InfoNet = 3; InfoGross = 4; var NetAdj,GrsAdj: Double; saleValue, NetPct, GrsPct: Double; begin NetAdj := 0; GrsAdj := 0; GetNetGrosAdjs(doc, mcx(cx,72), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,74), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,76), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,78), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,80), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,82), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,84), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,86), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,88), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,90), NetAdj, GrsAdj); SetCellValue(doc, mcx(cx,TotalAdj), NetAdj); //set sum of Adj if (NetAdj>=0) then SetCellChkMark(doc, mcx(cx,PlusChk), True) //toggle the checkmarks else SetCellChkMark(doc, mcx(cx,NegChk), True); NetPct := 0; GrsPct := 0; if appPref_AppraiserUseLandPriceUnits then saleValue := GetCellValue(doc, mcx(cx,AcrePrice)) else saleValue := GetCellValue(doc, mcx(cx,salesAmt)); //calc the net/grs percents if saleValue <> 0 then begin NetPct := (NetAdj / saleValue) * 100; GrsPct := (GrsAdj / saleValue) * 100; SumOfWeightedValues := SumOfWeightedValues + (1-GrsPct/100) * (saleValue+ NetAdj); SumOfWeights := SumOfWeights + (1-GrsPct/100); end; SetInfoCellValue(doc, mcx(cx,infoNet), NetPct); SetInfoCellValue(doc, mcx(cx,infoGross), GrsPct); //set the info cells result := SetCellValue(doc, mcx(cx,FinalAmt), saleValue+ NetAdj); //set final adj price end; function F0941C3Adjustments(doc: TContainer; CX: CellUID) : Integer; const SalesAmt = 101; AcrePrice = 102; TotalAdj = 125; FinalAmt = 126; PlusChk = 123; NegChk = 124; InfoNet = 5; InfoGross = 6; var NetAdj,GrsAdj: Double; saleValue, NetPct, GrsPct: Double; begin NetAdj := 0; GrsAdj := 0; GetNetGrosAdjs(doc, mcx(cx,104), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,106), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,108), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,110), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,112), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,114), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,116), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,118), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,120), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,122), NetAdj, GrsAdj); SetCellValue(doc, mcx(cx,TotalAdj), NetAdj); //set sum of Adj if (NetAdj>=0) then SetCellChkMark(doc, mcx(cx,PlusChk), True) //toggle the checkmarks else SetCellChkMark(doc, mcx(cx,NegChk), True); NetPct := 0; GrsPct := 0; if appPref_AppraiserUseLandPriceUnits then saleValue := GetCellValue(doc, mcx(cx,AcrePrice)) else saleValue := GetCellValue(doc, mcx(cx,salesAmt)); //calc the net/grs percents if saleValue <> 0 then begin NetPct := (NetAdj / saleValue) * 100; GrsPct := (GrsAdj / saleValue) * 100; SumOfWeightedValues := SumOfWeightedValues + (1-GrsPct/100) * (saleValue+ NetAdj); SumOfWeights := SumOfWeights + (1-GrsPct/100); end; SetInfoCellValue(doc, mcx(cx,infoNet), NetPct); SetInfoCellValue(doc, mcx(cx,infoGross), GrsPct); //set the info cells result := SetCellValue(doc, mcx(cx,FinalAmt), saleValue+ NetAdj); //set final adj price end; function F0848C1Adjustments(doc: TContainer; CX: CellUID) : Integer; const SalesAmt = 35; AcrePrice = 36; TotalAdj = 59; FinalAmt = 60; PlusChk = 57; NegChk = 58; InfoNet = 1; InfoGross = 2; var NetAdj,GrsAdj: Double; saleValue, NetPct, GrsPct: Double; begin NetAdj := 0; GrsAdj := 0; GetNetGrosAdjs(doc, mcx(cx,38), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,40), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,42), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,44), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,46), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,48), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,50), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,52), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,54), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,56), NetAdj, GrsAdj); SetCellValue(doc, mcx(cx,TotalAdj), NetAdj); //set sum of Adj if (NetAdj>=0) then SetCellChkMark(doc, mcx(cx,PlusChk), True) //toggle the checkmarks else SetCellChkMark(doc, mcx(cx,NegChk), True); NetPct := 0; GrsPct := 0; if appPref_AppraiserUseLandPriceUnits then saleValue := GetCellValue(doc, mcx(cx,AcrePrice)) else saleValue := GetCellValue(doc, mcx(cx,salesAmt)); //calc the net/grs percents if saleValue <> 0 then begin NetPct := (NetAdj / saleValue) * 100; GrsPct := (GrsAdj / saleValue) * 100; SumOfWeightedValues := SumOfWeightedValues + (1-GrsPct/100) * (saleValue+ NetAdj); SumOfWeights := SumOfWeights + (1-GrsPct/100); end; SetInfoCellValue(doc, mcx(cx,infoNet), NetPct); SetInfoCellValue(doc, mcx(cx,infoGross), GrsPct); //set the info cells result := SetCellValue(doc, mcx(cx,FinalAmt), saleValue+ NetAdj); //set final adj price end; function F0848C2Adjustments(doc: TContainer; CX: CellUID) : Integer; const SalesAmt = 66; AcrePrice = 67; TotalAdj = 90; FinalAmt = 91; PlusChk = 88; NegChk = 89; InfoNet = 3; InfoGross = 4; var NetAdj,GrsAdj: Double; saleValue, NetPct, GrsPct: Double; begin NetAdj := 0; GrsAdj := 0; GetNetGrosAdjs(doc, mcx(cx,69), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,71), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,73), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,75), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,77), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,79), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,81), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,83), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,85), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,87), NetAdj, GrsAdj); SetCellValue(doc, mcx(cx,TotalAdj), NetAdj); //set sum of Adj if (NetAdj>=0) then SetCellChkMark(doc, mcx(cx,PlusChk), True) //toggle the checkmarks else SetCellChkMark(doc, mcx(cx,NegChk), True); NetPct := 0; GrsPct := 0; if appPref_AppraiserUseLandPriceUnits then saleValue := GetCellValue(doc, mcx(cx,AcrePrice)) else saleValue := GetCellValue(doc, mcx(cx,salesAmt)); //calc the net/grs percents if saleValue <> 0 then begin NetPct := (NetAdj / saleValue) * 100; GrsPct := (GrsAdj / saleValue) * 100; SumOfWeightedValues := SumOfWeightedValues + (1-GrsPct/100) * (saleValue+ NetAdj); SumOfWeights := SumOfWeights + (1-GrsPct/100); end; SetInfoCellValue(doc, mcx(cx,infoNet), NetPct); SetInfoCellValue(doc, mcx(cx,infoGross), GrsPct); //set the info cells result := SetCellValue(doc, mcx(cx,FinalAmt), saleValue+ NetAdj); //set final adj price end; function F0848C3Adjustments(doc: TContainer; CX: CellUID) : Integer; const SalesAmt = 97; AcrePrice = 98; TotalAdj = 121; FinalAmt = 122; PlusChk = 119; NegChk = 120; InfoNet = 5; InfoGross = 6; var NetAdj,GrsAdj: Double; saleValue, NetPct, GrsPct: Double; begin NetAdj := 0; GrsAdj := 0; GetNetGrosAdjs(doc, mcx(cx,100), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,102), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,104), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,106), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,108), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,110), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,112), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,114), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,116), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,118), NetAdj, GrsAdj); SetCellValue(doc, mcx(cx,TotalAdj), NetAdj); //set sum of Adj if (NetAdj>=0) then SetCellChkMark(doc, mcx(cx,PlusChk), True) //toggle the checkmarks else SetCellChkMark(doc, mcx(cx,NegChk), True); NetPct := 0; GrsPct := 0; if appPref_AppraiserUseLandPriceUnits then saleValue := GetCellValue(doc, mcx(cx,AcrePrice)) else saleValue := GetCellValue(doc, mcx(cx,salesAmt)); //calc the net/grs percents if saleValue <> 0 then begin NetPct := (NetAdj / saleValue) * 100; GrsPct := (GrsAdj / saleValue) * 100; SumOfWeightedValues := SumOfWeightedValues + (1-GrsPct/100) * (saleValue+ NetAdj); SumOfWeights := SumOfWeights + (1-GrsPct/100); end; SetInfoCellValue(doc, mcx(cx,infoNet), NetPct); SetInfoCellValue(doc, mcx(cx,infoGross), GrsPct); //set the info cells result := SetCellValue(doc, mcx(cx,FinalAmt), saleValue+ NetAdj); //set final adj price end; function F1304C1Adjustments(doc: TContainer; CX: CellUID) : Integer; const SalesAmt = 35; AcrePrice = 36; TotalAdj = 59; FinalAmt = 60; PlusChk = 57; NegChk = 58; InfoNet = 1; InfoGross = 2; var NetAdj,GrsAdj: Double; saleValue, NetPct, GrsPct: Double; begin NetAdj := 0; GrsAdj := 0; GetNetGrosAdjs(doc, mcx(cx,38), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,40), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,42), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,44), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,46), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,48), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,50), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,52), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,54), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,56), NetAdj, GrsAdj); SetCellValue(doc, mcx(cx,TotalAdj), NetAdj); //set sum of Adj if (NetAdj>=0) then SetCellChkMark(doc, mcx(cx,PlusChk), True) //toggle the checkmarks else SetCellChkMark(doc, mcx(cx,NegChk), True); NetPct := 0; GrsPct := 0; if appPref_AppraiserUseLandPriceUnits then saleValue := GetCellValue(doc, mcx(cx,AcrePrice)) else saleValue := GetCellValue(doc, mcx(cx,salesAmt)); //calc the net/grs percents if saleValue <> 0 then begin NetPct := (NetAdj / saleValue) * 100; GrsPct := (GrsAdj / saleValue) * 100; SumOfWeightedValues := SumOfWeightedValues + (1-GrsPct/100) * (saleValue+ NetAdj); SumOfWeights := SumOfWeights + (1-GrsPct/100); end; SetInfoCellValue(doc, mcx(cx,infoNet), NetPct); SetInfoCellValue(doc, mcx(cx,infoGross), GrsPct); //set the info cells result := SetCellValue(doc, mcx(cx,FinalAmt), saleValue+ NetAdj); //set final adj price end; function F1304C2Adjustments(doc: TContainer; CX: CellUID) : Integer; const SalesAmt = 66; AcrePrice = 67; TotalAdj = 90; FinalAmt = 91; PlusChk = 88; NegChk = 89; InfoNet = 3; InfoGross = 4; var NetAdj,GrsAdj: Double; saleValue, NetPct, GrsPct: Double; begin NetAdj := 0; GrsAdj := 0; GetNetGrosAdjs(doc, mcx(cx,69), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,71), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,73), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,75), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,77), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,79), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,81), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,83), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,85), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,87), NetAdj, GrsAdj); SetCellValue(doc, mcx(cx,TotalAdj), NetAdj); //set sum of Adj if (NetAdj>=0) then SetCellChkMark(doc, mcx(cx,PlusChk), True) //toggle the checkmarks else SetCellChkMark(doc, mcx(cx,NegChk), True); NetPct := 0; GrsPct := 0; if appPref_AppraiserUseLandPriceUnits then saleValue := GetCellValue(doc, mcx(cx,AcrePrice)) else saleValue := GetCellValue(doc, mcx(cx,salesAmt)); //calc the net/grs percents if saleValue <> 0 then begin NetPct := (NetAdj / saleValue) * 100; GrsPct := (GrsAdj / saleValue) * 100; SumOfWeightedValues := SumOfWeightedValues + (1-GrsPct/100) * (saleValue+ NetAdj); SumOfWeights := SumOfWeights + (1-GrsPct/100); end; SetInfoCellValue(doc, mcx(cx,infoNet), NetPct); SetInfoCellValue(doc, mcx(cx,infoGross), GrsPct); //set the info cells result := SetCellValue(doc, mcx(cx,FinalAmt), saleValue+ NetAdj); //set final adj price end; function F1304C3Adjustments(doc: TContainer; CX: CellUID) : Integer; const SalesAmt = 97; AcrePrice = 98; TotalAdj = 121; FinalAmt = 122; PlusChk = 119; NegChk = 120; InfoNet = 5; InfoGross = 6; var NetAdj,GrsAdj: Double; saleValue, NetPct, GrsPct: Double; begin NetAdj := 0; GrsAdj := 0; GetNetGrosAdjs(doc, mcx(cx,100), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,102), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,104), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,106), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,108), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,110), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,112), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,114), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,116), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,118), NetAdj, GrsAdj); SetCellValue(doc, mcx(cx,TotalAdj), NetAdj); //set sum of Adj if (NetAdj>=0) then SetCellChkMark(doc, mcx(cx,PlusChk), True) //toggle the checkmarks else SetCellChkMark(doc, mcx(cx,NegChk), True); NetPct := 0; GrsPct := 0; if appPref_AppraiserUseLandPriceUnits then saleValue := GetCellValue(doc, mcx(cx,AcrePrice)) else saleValue := GetCellValue(doc, mcx(cx,salesAmt)); //calc the net/grs percents if saleValue <> 0 then begin NetPct := (NetAdj / saleValue) * 100; GrsPct := (GrsAdj / saleValue) * 100; SumOfWeightedValues := SumOfWeightedValues + (1-GrsPct/100) * (saleValue+ NetAdj); SumOfWeights := SumOfWeights + (1-GrsPct/100); end; SetInfoCellValue(doc, mcx(cx,infoNet), NetPct); SetInfoCellValue(doc, mcx(cx,infoGross), GrsPct); //set the info cells result := SetCellValue(doc, mcx(cx,FinalAmt), saleValue+ NetAdj); //set final adj price end; function F1311C1IncomeAdjs(doc: TContainer; CX: CellUID) : Integer; const SalesAmt = 46; TotalAdj = 77; FinalAmt = 78; PlusChk = 75; NegChk = 76; InfoNet = 1; InfoGross = 2; var NetAdj,GrsAdj: Double; saleValue, NetPct, GrsPct: Double; begin NetAdj := 0; GrsAdj := 0; GetNetGrosAdjs(doc, mcx(cx,48), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,50), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,52), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,54), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,56), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,58), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,60), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,62), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,64), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,66), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,68), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,70), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,72), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,74), NetAdj, GrsAdj); SetCellValue(doc, mcx(cx,TotalAdj), NetAdj); //set sum of Adj if (NetAdj>=0) then SetCellChkMark(doc, mcx(cx,PlusChk), True) //toggle the checkmarks else SetCellChkMark(doc, mcx(cx,NegChk), True); NetPct := 0; GrsPct := 0; saleValue := GetCellValue(doc, mcx(cx,salesAmt)); //calc the net/grs percents if saleValue <> 0 then begin NetPct := (NetAdj / saleValue) * 100; GrsPct := (GrsAdj / saleValue) * 100; SumOfWeightedValues := SumOfWeightedValues + (1-GrsPct/100) * (saleValue+ NetAdj); SumOfWeights := SumOfWeights + (1-GrsPct/100); end; SetInfoCellValue(doc, mcx(cx,infoNet), NetPct); SetInfoCellValue(doc, mcx(cx,infoGross), GrsPct); //set the info cells result := SetCellValue(doc, mcx(cx,FinalAmt), (saleValue + NetAdj)); //set final adj price end; function F1311C2IncomeAdjs(doc: TContainer; CX: CellUID) : Integer; const SalesAmt = 93; TotalAdj = 124; FinalAmt = 125; PlusChk = 122; NegChk = 123; InfoNet = 3; InfoGross = 4; var NetAdj,GrsAdj: Double; saleValue, NetPct, GrsPct: Double; begin NetAdj := 0; GrsAdj := 0; GetNetGrosAdjs(doc, mcx(cx,95), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,97), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,99), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,101), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,103), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,105), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,107), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,109), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,111), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,113), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,115), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,117), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,119), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,121), NetAdj, GrsAdj); SetCellValue(doc, mcx(cx,TotalAdj), NetAdj); //set sum of Adj if (NetAdj>=0) then SetCellChkMark(doc, mcx(cx,PlusChk), True) //toggle the checkmarks else SetCellChkMark(doc, mcx(cx,NegChk), True); NetPct := 0; GrsPct := 0; saleValue := GetCellValue(doc, mcx(cx,salesAmt)); //calc the net/grs percents if saleValue <> 0 then begin NetPct := (NetAdj / saleValue) * 100; GrsPct := (GrsAdj / saleValue) * 100; SumOfWeightedValues := SumOfWeightedValues + (1-GrsPct/100) * (saleValue+ NetAdj); SumOfWeights := SumOfWeights + (1-GrsPct/100); end; SetInfoCellValue(doc, mcx(cx,infoNet), NetPct); SetInfoCellValue(doc, mcx(cx,infoGross), GrsPct); //set the info cells result := SetCellValue(doc, mcx(cx,FinalAmt), (saleValue + NetAdj)); //set final adj price end; function F1311C3IncomeAdjs(doc: TContainer; CX: CellUID) : Integer; const SalesAmt = 140; TotalAdj = 171; FinalAmt = 172; PlusChk = 169; NegChk = 170; InfoNet = 5; InfoGross = 6; var NetAdj,GrsAdj: Double; saleValue, NetPct, GrsPct: Double; begin NetAdj := 0; GrsAdj := 0; GetNetGrosAdjs(doc, mcx(cx,142), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,144), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,146), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,148), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,150), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,152), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,154), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,156), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,158), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,160), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,162), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,164), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,166), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,168), NetAdj, GrsAdj); SetCellValue(doc, mcx(cx,TotalAdj), NetAdj); //set sum of Adj if (NetAdj>=0) then SetCellChkMark(doc, mcx(cx,PlusChk), True) //toggle the checkmarks else SetCellChkMark(doc, mcx(cx,NegChk), True); NetPct := 0; GrsPct := 0; saleValue := GetCellValue(doc, mcx(cx,salesAmt)); //calc the net/grs percents if saleValue <> 0 then begin NetPct := (NetAdj / saleValue) * 100; GrsPct := (GrsAdj / saleValue) * 100; SumOfWeightedValues := SumOfWeightedValues + (1-GrsPct/100) * (saleValue+ NetAdj); SumOfWeights := SumOfWeights + (1-GrsPct/100); end; SetInfoCellValue(doc, mcx(cx,infoNet), NetPct); SetInfoCellValue(doc, mcx(cx,infoGross), GrsPct); //set the info cells result := SetCellValue(doc, mcx(cx,FinalAmt), (saleValue + NetAdj)); //set final adj price end; function F0940C1IncomeAdjs(doc: TContainer; CX: CellUID) : Integer; const SalesAmt = 48; TotalAdj = 79; FinalAmt = 80; PlusChk = 77; NegChk = 78; InfoNet = 1; InfoGross = 2; var NetAdj,GrsAdj: Double; saleValue, NetPct, GrsPct: Double; begin NetAdj := 0; GrsAdj := 0; GetNetGrosAdjs(doc, mcx(cx,50), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,52), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,54), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,56), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,58), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,60), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,62), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,64), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,66), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,68), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,70), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,72), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,74), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,76), NetAdj, GrsAdj); SetCellValue(doc, mcx(cx,TotalAdj), NetAdj); //set sum of Adj if (NetAdj>=0) then SetCellChkMark(doc, mcx(cx,PlusChk), True) //toggle the checkmarks else SetCellChkMark(doc, mcx(cx,NegChk), True); NetPct := 0; GrsPct := 0; saleValue := GetCellValue(doc, mcx(cx,salesAmt)); //calc the net/grs percents if saleValue <> 0 then begin NetPct := (NetAdj / saleValue) * 100; GrsPct := (GrsAdj / saleValue) * 100; SumOfWeightedValues := SumOfWeightedValues + (1-GrsPct/100) * (saleValue+ NetAdj); SumOfWeights := SumOfWeights + (1-GrsPct/100); end; SetInfoCellValue(doc, mcx(cx,infoNet), NetPct); SetInfoCellValue(doc, mcx(cx,infoGross), GrsPct); //set the info cells result := SetCellValue(doc, mcx(cx,FinalAmt), (saleValue + NetAdj)); //set final adj price end; function F0940C2IncomeAdjs(doc: TContainer; CX: CellUID) : Integer; const SalesAmt = 96; TotalAdj = 127; FinalAmt = 128; PlusChk = 125; NegChk = 126; InfoNet = 3; InfoGross = 4; var NetAdj,GrsAdj: Double; saleValue, NetPct, GrsPct: Double; begin NetAdj := 0; GrsAdj := 0; GetNetGrosAdjs(doc, mcx(cx,98), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,100), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,102), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,104), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,106), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,108), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,110), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,112), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,114), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,116), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,118), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,120), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,122), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,124), NetAdj, GrsAdj); SetCellValue(doc, mcx(cx,TotalAdj), NetAdj); //set sum of Adj if (NetAdj>=0) then SetCellChkMark(doc, mcx(cx,PlusChk), True) //toggle the checkmarks else SetCellChkMark(doc, mcx(cx,NegChk), True); NetPct := 0; GrsPct := 0; saleValue := GetCellValue(doc, mcx(cx,salesAmt)); //calc the net/grs percents if saleValue <> 0 then begin NetPct := (NetAdj / saleValue) * 100; GrsPct := (GrsAdj / saleValue) * 100; SumOfWeightedValues := SumOfWeightedValues + (1-GrsPct/100) * (saleValue+ NetAdj); SumOfWeights := SumOfWeights + (1-GrsPct/100); end; SetInfoCellValue(doc, mcx(cx,infoNet), NetPct); SetInfoCellValue(doc, mcx(cx,infoGross), GrsPct); //set the info cells result := SetCellValue(doc, mcx(cx,FinalAmt), (saleValue + NetAdj)); //set final adj price end; function F0940C3IncomeAdjs(doc: TContainer; CX: CellUID) : Integer; const SalesAmt = 144; TotalAdj = 175; FinalAmt = 176; PlusChk = 173; NegChk = 174; InfoNet = 5; InfoGross = 6; var NetAdj,GrsAdj: Double; saleValue, NetPct, GrsPct: Double; begin NetAdj := 0; GrsAdj := 0; GetNetGrosAdjs(doc, mcx(cx,146), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,148), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,150), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,152), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,154), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,156), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,158), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,160), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,162), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,164), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,166), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,168), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,170), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,172), NetAdj, GrsAdj); SetCellValue(doc, mcx(cx,TotalAdj), NetAdj); //set sum of Adj if (NetAdj>=0) then SetCellChkMark(doc, mcx(cx,PlusChk), True) //toggle the checkmarks else SetCellChkMark(doc, mcx(cx,NegChk), True); NetPct := 0; GrsPct := 0; saleValue := GetCellValue(doc, mcx(cx,salesAmt)); //calc the net/grs percents if saleValue <> 0 then begin NetPct := (NetAdj / saleValue) * 100; GrsPct := (GrsAdj / saleValue) * 100; SumOfWeightedValues := SumOfWeightedValues + (1-GrsPct/100) * (saleValue+ NetAdj); SumOfWeights := SumOfWeights + (1-GrsPct/100); end; SetInfoCellValue(doc, mcx(cx,infoNet), NetPct); SetInfoCellValue(doc, mcx(cx,infoGross), GrsPct); //set the info cells result := SetCellValue(doc, mcx(cx,FinalAmt), (saleValue + NetAdj)); //set final adj price end; function F0847C1SiteAdjs(doc: TContainer; CX: CellUID) : Integer; const SalesAmt = 35; AcrePrice = 36; TotalAdj = 59; FinalAmt = 60; PlusChk = 57; NegChk = 58; InfoNet = 1; InfoGross = 2; var NetAdj,GrsAdj: Double; saleValue, NetPct, GrsPct: Double; begin NetAdj := 0; GrsAdj := 0; GetNetGrosAdjs(doc, mcx(cx,38), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,40), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,42), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,44), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,46), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,48), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,50), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,52), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,54), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,56), NetAdj, GrsAdj); SetCellValue(doc, mcx(cx,TotalAdj), NetAdj); //set sum of Adj if (NetAdj>=0) then SetCellChkMark(doc, mcx(cx,PlusChk), True) //toggle the checkmarks else SetCellChkMark(doc, mcx(cx,NegChk), True); NetPct := 0; GrsPct := 0; if appPref_AppraiserUseLandPriceUnits then saleValue := GetCellValue(doc, mcx(cx,AcrePrice)) else saleValue := GetCellValue(doc, mcx(cx,salesAmt)); //calc the net/grs percents if saleValue <> 0 then begin NetPct := (NetAdj / saleValue) * 100; GrsPct := (GrsAdj / saleValue) * 100; SumOfWeightedValues := SumOfWeightedValues + (1-GrsPct/100) * (saleValue+ NetAdj); SumOfWeights := SumOfWeights + (1-GrsPct/100); end; SetInfoCellValue(doc, mcx(cx,infoNet), NetPct); SetInfoCellValue(doc, mcx(cx,infoGross), GrsPct); //set the info cells result := SetCellValue(doc, mcx(cx,FinalAmt), (saleValue + NetAdj)); //set final adj price end; function F0847C2SiteAdjs(doc: TContainer; CX: CellUID) : Integer; const SalesAmt = 66; AcrePrice = 67; TotalAdj = 90; FinalAmt = 91; PlusChk = 88; NegChk = 89; InfoNet = 3; InfoGross = 4; var NetAdj,GrsAdj: Double; saleValue, NetPct, GrsPct: Double; begin NetAdj := 0; GrsAdj := 0; GetNetGrosAdjs(doc, mcx(cx,69), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,71), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,73), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,75), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,77), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,79), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,81), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,83), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,85), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,87), NetAdj, GrsAdj); SetCellValue(doc, mcx(cx,TotalAdj), NetAdj); //set sum of Adj if (NetAdj>=0) then SetCellChkMark(doc, mcx(cx,PlusChk), True) //toggle the checkmarks else SetCellChkMark(doc, mcx(cx,NegChk), True); NetPct := 0; GrsPct := 0; if appPref_AppraiserUseLandPriceUnits then saleValue := GetCellValue(doc, mcx(cx,AcrePrice)) else saleValue := GetCellValue(doc, mcx(cx,salesAmt)); //calc the net/grs percents if saleValue <> 0 then begin NetPct := (NetAdj / saleValue) * 100; GrsPct := (GrsAdj / saleValue) * 100; SumOfWeightedValues := SumOfWeightedValues + (1-GrsPct/100) * (saleValue+ NetAdj); SumOfWeights := SumOfWeights + (1-GrsPct/100); end; SetInfoCellValue(doc, mcx(cx,infoNet), NetPct); SetInfoCellValue(doc, mcx(cx,infoGross), GrsPct); //set the info cells result := SetCellValue(doc, mcx(cx,FinalAmt), (saleValue + NetAdj)); //set final adj price end; function F0847C3SiteAdjs(doc: TContainer; CX: CellUID) : Integer; const SalesAmt = 97; AcrePrice = 98; TotalAdj = 121; FinalAmt = 122; PlusChk = 119; NegChk = 120; InfoNet = 5; InfoGross = 6; var NetAdj,GrsAdj: Double; saleValue, NetPct, GrsPct: Double; begin NetAdj := 0; GrsAdj := 0; GetNetGrosAdjs(doc, mcx(cx,100), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,102), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,104), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,106), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,108), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,110), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,112), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,114), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,116), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,118), NetAdj, GrsAdj); SetCellValue(doc, mcx(cx,TotalAdj), NetAdj); //set sum of Adj if (NetAdj>=0) then SetCellChkMark(doc, mcx(cx,PlusChk), True) //toggle the checkmarks else SetCellChkMark(doc, mcx(cx,NegChk), True); NetPct := 0; GrsPct := 0; if appPref_AppraiserUseLandPriceUnits then saleValue := GetCellValue(doc, mcx(cx,AcrePrice)) else saleValue := GetCellValue(doc, mcx(cx,salesAmt)); //calc the net/grs percents if saleValue <> 0 then begin NetPct := (NetAdj / saleValue) * 100; GrsPct := (GrsAdj / saleValue) * 100; SumOfWeightedValues := SumOfWeightedValues + (1-GrsPct/100) * (saleValue+ NetAdj); SumOfWeights := SumOfWeights + (1-GrsPct/100); end; SetInfoCellValue(doc, mcx(cx,infoNet), NetPct); SetInfoCellValue(doc, mcx(cx,infoGross), GrsPct); //set the info cells result := SetCellValue(doc, mcx(cx,FinalAmt), (saleValue + NetAdj)); //set final adj price end; function F0847C1IncomeAdjs(doc: TContainer; CX: CellUID) : Integer; const SalesAmt = 46; TotalAdj = 77; FinalAmt = 78; PlusChk = 75; NegChk = 76; InfoNet = 1; InfoGross = 2; var NetAdj,GrsAdj: Double; saleValue, NetPct, GrsPct: Double; begin NetAdj := 0; GrsAdj := 0; GetNetGrosAdjs(doc, mcx(cx,48), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,50), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,52), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,54), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,56), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,58), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,60), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,62), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,64), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,66), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,68), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,70), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,72), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,74), NetAdj, GrsAdj); SetCellValue(doc, mcx(cx,TotalAdj), NetAdj); //set sum of Adj if (NetAdj>=0) then SetCellChkMark(doc, mcx(cx,PlusChk), True) //toggle the checkmarks else SetCellChkMark(doc, mcx(cx,NegChk), True); NetPct := 0; GrsPct := 0; saleValue := GetCellValue(doc, mcx(cx,salesAmt)); //calc the net/grs percents if saleValue <> 0 then begin NetPct := (NetAdj / saleValue) * 100; GrsPct := (GrsAdj / saleValue) * 100; SumOfWeightedValues := SumOfWeightedValues + (1-GrsPct/100) * (saleValue+ NetAdj); SumOfWeights := SumOfWeights + (1-GrsPct/100); end; SetInfoCellValue(doc, mcx(cx,infoNet), NetPct); SetInfoCellValue(doc, mcx(cx,infoGross), GrsPct); //set the info cells result := SetCellValue(doc, mcx(cx,FinalAmt), (saleValue + NetAdj)); //set final adj price end; function F0847C2IncomeAdjs(doc: TContainer; CX: CellUID) : Integer; const SalesAmt = 93; TotalAdj = 124; FinalAmt = 125; PlusChk = 122; NegChk = 123; InfoNet = 3; InfoGross = 4; var NetAdj,GrsAdj: Double; saleValue, NetPct, GrsPct: Double; begin NetAdj := 0; GrsAdj := 0; GetNetGrosAdjs(doc, mcx(cx,95), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,97), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,99), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,101), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,103), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,105), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,107), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,109), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,111), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,113), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,115), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,117), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,119), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,121), NetAdj, GrsAdj); SetCellValue(doc, mcx(cx,TotalAdj), NetAdj); //set sum of Adj if (NetAdj>=0) then SetCellChkMark(doc, mcx(cx,PlusChk), True) //toggle the checkmarks else SetCellChkMark(doc, mcx(cx,NegChk), True); NetPct := 0; GrsPct := 0; saleValue := GetCellValue(doc, mcx(cx,salesAmt)); //calc the net/grs percents if saleValue <> 0 then begin NetPct := (NetAdj / saleValue) * 100; GrsPct := (GrsAdj / saleValue) * 100; SumOfWeightedValues := SumOfWeightedValues + (1-GrsPct/100) * (saleValue+ NetAdj); SumOfWeights := SumOfWeights + (1-GrsPct/100); end; SetInfoCellValue(doc, mcx(cx,infoNet), NetPct); SetInfoCellValue(doc, mcx(cx,infoGross), GrsPct); //set the info cells result := SetCellValue(doc, mcx(cx,FinalAmt), (saleValue + NetAdj)); //set final adj price end; function F0847C3IncomeAdjs(doc: TContainer; CX: CellUID) : Integer; const SalesAmt = 140; TotalAdj = 171; FinalAmt = 172; PlusChk = 169; NegChk = 170; InfoNet = 5; InfoGross = 6; var NetAdj,GrsAdj: Double; saleValue, NetPct, GrsPct: Double; begin NetAdj := 0; GrsAdj := 0; GetNetGrosAdjs(doc, mcx(cx,142), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,144), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,146), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,148), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,150), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,152), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,154), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,156), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,158), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,160), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,162), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,164), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,166), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,168), NetAdj, GrsAdj); SetCellValue(doc, mcx(cx,TotalAdj), NetAdj); //set sum of Adj if (NetAdj>=0) then SetCellChkMark(doc, mcx(cx,PlusChk), True) //toggle the checkmarks else SetCellChkMark(doc, mcx(cx,NegChk), True); NetPct := 0; GrsPct := 0; saleValue := GetCellValue(doc, mcx(cx,salesAmt)); //calc the net/grs percents if saleValue <> 0 then begin NetPct := (NetAdj / saleValue) * 100; GrsPct := (GrsAdj / saleValue) * 100; SumOfWeightedValues := SumOfWeightedValues + (1-GrsPct/100) * (saleValue+ NetAdj); SumOfWeights := SumOfWeights + (1-GrsPct/100); end; SetInfoCellValue(doc, mcx(cx,infoNet), NetPct); SetInfoCellValue(doc, mcx(cx,infoGross), GrsPct); //set the info cells result := SetCellValue(doc, mcx(cx,FinalAmt), (saleValue + NetAdj)); //set final adj price end; function F1309C1SiteAdjs(doc: TContainer; CX: CellUID) : Integer; const SalesAmt = 35; AcrePrice = 36; TotalAdj = 59; FinalAmt = 60; PlusChk = 57; NegChk = 58; InfoNet = 1; InfoGross = 2; var NetAdj,GrsAdj: Double; saleValue, NetPct, GrsPct: Double; begin NetAdj := 0; GrsAdj := 0; GetNetGrosAdjs(doc, mcx(cx,38), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,40), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,42), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,44), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,46), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,48), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,50), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,52), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,54), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,56), NetAdj, GrsAdj); SetCellValue(doc, mcx(cx,TotalAdj), NetAdj); //set sum of Adj if (NetAdj>=0) then SetCellChkMark(doc, mcx(cx,PlusChk), True) //toggle the checkmarks else SetCellChkMark(doc, mcx(cx,NegChk), True); NetPct := 0; GrsPct := 0; if appPref_AppraiserUseLandPriceUnits then saleValue := GetCellValue(doc, mcx(cx,AcrePrice)) else saleValue := GetCellValue(doc, mcx(cx,salesAmt)); //calc the net/grs percents if saleValue <> 0 then begin NetPct := (NetAdj / saleValue) * 100; GrsPct := (GrsAdj / saleValue) * 100; SumOfWeightedValues := SumOfWeightedValues + (1-GrsPct/100) * (saleValue+ NetAdj); SumOfWeights := SumOfWeights + (1-GrsPct/100); end; SetInfoCellValue(doc, mcx(cx,infoNet), NetPct); SetInfoCellValue(doc, mcx(cx,infoGross), GrsPct); //set the info cells result := SetCellValue(doc, mcx(cx,FinalAmt), (saleValue + NetAdj)); //set final adj price end; function F1309C2SiteAdjs(doc: TContainer; CX: CellUID) : Integer; const SalesAmt = 66; AcrePrice = 67; TotalAdj = 90; FinalAmt = 91; PlusChk = 88; NegChk = 89; InfoNet = 3; InfoGross = 4; var NetAdj,GrsAdj: Double; saleValue, NetPct, GrsPct: Double; begin NetAdj := 0; GrsAdj := 0; GetNetGrosAdjs(doc, mcx(cx,69), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,71), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,73), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,75), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,77), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,79), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,81), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,83), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,85), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,87), NetAdj, GrsAdj); SetCellValue(doc, mcx(cx,TotalAdj), NetAdj); //set sum of Adj if (NetAdj>=0) then SetCellChkMark(doc, mcx(cx,PlusChk), True) //toggle the checkmarks else SetCellChkMark(doc, mcx(cx,NegChk), True); NetPct := 0; GrsPct := 0; if appPref_AppraiserUseLandPriceUnits then saleValue := GetCellValue(doc, mcx(cx,AcrePrice)) else saleValue := GetCellValue(doc, mcx(cx,salesAmt)); //calc the net/grs percents if saleValue <> 0 then begin NetPct := (NetAdj / saleValue) * 100; GrsPct := (GrsAdj / saleValue) * 100; SumOfWeightedValues := SumOfWeightedValues + (1-GrsPct/100) * (saleValue+ NetAdj); SumOfWeights := SumOfWeights + (1-GrsPct/100); end; SetInfoCellValue(doc, mcx(cx,infoNet), NetPct); SetInfoCellValue(doc, mcx(cx,infoGross), GrsPct); //set the info cells result := SetCellValue(doc, mcx(cx,FinalAmt), (saleValue + NetAdj)); //set final adj price end; function F1309C3SiteAdjs(doc: TContainer; CX: CellUID) : Integer; const SalesAmt = 97; AcrePrice = 98; TotalAdj = 121; FinalAmt = 122; PlusChk = 119; NegChk = 120; InfoNet = 5; InfoGross = 6; var NetAdj,GrsAdj: Double; saleValue, NetPct, GrsPct: Double; begin NetAdj := 0; GrsAdj := 0; GetNetGrosAdjs(doc, mcx(cx,100), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,102), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,104), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,106), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,108), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,110), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,112), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,114), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,116), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,118), NetAdj, GrsAdj); SetCellValue(doc, mcx(cx,TotalAdj), NetAdj); //set sum of Adj if (NetAdj>=0) then SetCellChkMark(doc, mcx(cx,PlusChk), True) //toggle the checkmarks else SetCellChkMark(doc, mcx(cx,NegChk), True); NetPct := 0; GrsPct := 0; if appPref_AppraiserUseLandPriceUnits then saleValue := GetCellValue(doc, mcx(cx,AcrePrice)) else saleValue := GetCellValue(doc, mcx(cx,salesAmt)); //calc the net/grs percents if saleValue <> 0 then begin NetPct := (NetAdj / saleValue) * 100; GrsPct := (GrsAdj / saleValue) * 100; SumOfWeightedValues := SumOfWeightedValues + (1-GrsPct/100) * (saleValue+ NetAdj); SumOfWeights := SumOfWeights + (1-GrsPct/100); end; SetInfoCellValue(doc, mcx(cx,infoNet), NetPct); SetInfoCellValue(doc, mcx(cx,infoGross), GrsPct); //set the info cells result := SetCellValue(doc, mcx(cx,FinalAmt), (saleValue + NetAdj)); //set final adj price end; (* function F1312C1SiteAdjs(doc: TContainer; CX: CellUID) : Integer; const SalesAmt = 35; AcrePrice = 36; TotalAdj = 59; FinalAmt = 60; PlusChk = 57; NegChk = 58; InfoNet = 1; InfoGross = 2; var NetAdj,GrsAdj: Double; saleValue, NetPct, GrsPct: Double; begin NetAdj := 0; GrsAdj := 0; GetNetGrosAdjs(doc, mcx(cx,38), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,40), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,42), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,44), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,46), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,48), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,50), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,52), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,54), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,56), NetAdj, GrsAdj); SetCellValue(doc, mcx(cx,TotalAdj), NetAdj); //set sum of Adj if (NetAdj>=0) then SetCellChkMark(doc, mcx(cx,PlusChk), True) //toggle the checkmarks else SetCellChkMark(doc, mcx(cx,NegChk), True); NetPct := 0; GrsPct := 0; if appPref_AppraiserUseLandPriceUnits then saleValue := GetCellValue(doc, mcx(cx,AcrePrice)) else saleValue := GetCellValue(doc, mcx(cx,salesAmt)); //calc the net/grs percents if saleValue <> 0 then begin NetPct := (NetAdj / saleValue) * 100; GrsPct := (GrsAdj / saleValue) * 100; SumOfWeightedValues := SumOfWeightedValues + (1-GrsPct/100) * (saleValue+ NetAdj); SumOfWeights := SumOfWeights + (1-GrsPct/100); end; SetInfoCellValue(doc, mcx(cx,infoNet), NetPct); SetInfoCellValue(doc, mcx(cx,infoGross), GrsPct); //set the info cells result := SetCellValue(doc, mcx(cx,FinalAmt), (saleValue + NetAdj)); //set final adj price end; function F1312C2SiteAdjs(doc: TContainer; CX: CellUID) : Integer; const SalesAmt = 66; AcrePrice = 67; TotalAdj = 90; FinalAmt = 91; PlusChk = 88; NegChk = 89; InfoNet = 3; InfoGross = 4; var NetAdj,GrsAdj: Double; saleValue, NetPct, GrsPct: Double; begin NetAdj := 0; GrsAdj := 0; GetNetGrosAdjs(doc, mcx(cx,69), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,71), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,73), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,75), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,77), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,79), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,81), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,83), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,85), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,87), NetAdj, GrsAdj); SetCellValue(doc, mcx(cx,TotalAdj), NetAdj); //set sum of Adj if (NetAdj>=0) then SetCellChkMark(doc, mcx(cx,PlusChk), True) //toggle the checkmarks else SetCellChkMark(doc, mcx(cx,NegChk), True); NetPct := 0; GrsPct := 0; if appPref_AppraiserUseLandPriceUnits then saleValue := GetCellValue(doc, mcx(cx,AcrePrice)) else saleValue := GetCellValue(doc, mcx(cx,salesAmt)); //calc the net/grs percents if saleValue <> 0 then begin NetPct := (NetAdj / saleValue) * 100; GrsPct := (GrsAdj / saleValue) * 100; SumOfWeightedValues := SumOfWeightedValues + (1-GrsPct/100) * (saleValue+ NetAdj); SumOfWeights := SumOfWeights + (1-GrsPct/100); end; SetInfoCellValue(doc, mcx(cx,infoNet), NetPct); SetInfoCellValue(doc, mcx(cx,infoGross), GrsPct); //set the info cells result := SetCellValue(doc, mcx(cx,FinalAmt), (saleValue + NetAdj)); //set final adj price end; function F1312C3SiteAdjs(doc: TContainer; CX: CellUID) : Integer; const SalesAmt = 97; AcrePrice = 98; TotalAdj = 121; FinalAmt = 122; PlusChk = 119; NegChk = 120; InfoNet = 5; InfoGross = 6; var NetAdj,GrsAdj: Double; saleValue, NetPct, GrsPct: Double; begin NetAdj := 0; GrsAdj := 0; GetNetGrosAdjs(doc, mcx(cx,100), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,102), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,104), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,106), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,108), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,110), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,112), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,114), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,116), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,118), NetAdj, GrsAdj); SetCellValue(doc, mcx(cx,TotalAdj), NetAdj); //set sum of Adj if (NetAdj>=0) then SetCellChkMark(doc, mcx(cx,PlusChk), True) //toggle the checkmarks else SetCellChkMark(doc, mcx(cx,NegChk), True); NetPct := 0; GrsPct := 0; if appPref_AppraiserUseLandPriceUnits then saleValue := GetCellValue(doc, mcx(cx,AcrePrice)) else saleValue := GetCellValue(doc, mcx(cx,salesAmt)); //calc the net/grs percents if saleValue <> 0 then begin NetPct := (NetAdj / saleValue) * 100; GrsPct := (GrsAdj / saleValue) * 100; SumOfWeightedValues := SumOfWeightedValues + (1-GrsPct/100) * (saleValue+ NetAdj); SumOfWeights := SumOfWeights + (1-GrsPct/100); end; SetInfoCellValue(doc, mcx(cx,infoNet), NetPct); SetInfoCellValue(doc, mcx(cx,infoGross), GrsPct); //set the info cells result := SetCellValue(doc, mcx(cx,FinalAmt), (saleValue + NetAdj)); //set final adj price end; *) //calc functional depr function F0376CalcDeprLessPhy(doc: TContainer; CX: CellUID): Integer; var V1,V2,V3, VR: double; begin result := 0; V1 := GetCellValue(doc, mcx(cx,32)); //funct depr percent V2 := GetCellValue(doc, mcx(cx,29)); //new cost V3 := GetCellValue(doc, mcx(cx,31)); //Phy Depr if (V2-V3)>0 then //phy depr cannot be larger begin VR := (V2-V3)*(V1/100); result := SetCellValue(doc, mcx(cx,33), VR); end; end; //calc functional depr function F0846CalcDeprLessPhy(doc: TContainer; CX: CellUID): Integer; var V1,V2,V3, VR: double; begin result := 0; V1 := GetCellValue(doc, mcx(cx,32)); //funct depr percent V2 := GetCellValue(doc, mcx(cx,29)); //new cost V3 := GetCellValue(doc, mcx(cx,31)); //Phy Depr if (V2-V3)>0 then //phy depr cannot be larger begin VR := (V2-V3)*(V1/100); result := SetCellValue(doc, mcx(cx,33), VR); end; end; //calc functional depr function F0847CalcDeprLessPhy(doc: TContainer; CX: CellUID): Integer; var V1,V2,V3, VR: double; begin result := 0; V1 := GetCellValue(doc, mcx(cx,32)); //funct depr percent V2 := GetCellValue(doc, mcx(cx,29)); //new cost V3 := GetCellValue(doc, mcx(cx,31)); //Phy Depr if (V2-V3)>0 then //phy depr cannot be larger begin VR := (V2-V3)*(V1/100); result := SetCellValue(doc, mcx(cx,33), VR); end; end; //calc external depr function F0376CalcDeprLessPhyNFunct(doc: TContainer; CX: CellUID): Integer; var V1,V2,V3,V4,VR: Double; begin result := 0; V1 := GetCellValue(doc, mcx(cx,34)); //extrn depr percent V2 := GetCellValue(doc, mcx(cx,29)); //new cost V3 := GetCellValue(doc, mcx(cx,31)); //Phy Depr V4 := GetCellValue(doc, mcx(cx,33)); //Funct Depr if (V2-V3-V4) > 0 then begin VR := (V2-V3-V4)*(V1/100); result := SetCellValue(doc, mcx(cx,35), VR); end; end; //calc external depr function F0846CalcDeprLessPhyNFunct(doc: TContainer; CX: CellUID): Integer; var V1,V2,V3,V4,VR: Double; begin result := 0; V1 := GetCellValue(doc, mcx(cx,34)); //extrn depr percent V2 := GetCellValue(doc, mcx(cx,29)); //new cost V3 := GetCellValue(doc, mcx(cx,31)); //Phy Depr V4 := GetCellValue(doc, mcx(cx,33)); //Funct Depr if (V2-V3-V4) > 0 then begin VR := (V2-V3-V4)*(V1/100); result := SetCellValue(doc, mcx(cx,35), VR); end; end; //calc external depr function F0847CalcDeprLessPhyNFunct(doc: TContainer; CX: CellUID): Integer; var V1,V2,V3,V4,VR: Double; begin result := 0; V1 := GetCellValue(doc, mcx(cx,34)); //extrn depr percent V2 := GetCellValue(doc, mcx(cx,29)); //new cost V3 := GetCellValue(doc, mcx(cx,31)); //Phy Depr V4 := GetCellValue(doc, mcx(cx,33)); //Funct Depr if (V2-V3-V4) > 0 then begin VR := (V2-V3-V4)*(V1/100); result := SetCellValue(doc, mcx(cx,35), VR); end; end; function F1319C1IncomeAdjs(doc: TContainer; CX: CellUID) : Integer; const SalesAmt = 46; TotalAdj = 77; FinalAmt = 78; PlusChk = 75; NegChk = 76; InfoNet = 1; InfoGross = 2; var NetAdj,GrsAdj: Double; saleValue, NetPct, GrsPct: Double; begin NetAdj := 0; GrsAdj := 0; GetNetGrosAdjs(doc, mcx(cx,48), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,50), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,52), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,54), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,56), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,58), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,60), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,62), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,64), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,66), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,68), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,70), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,72), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,74), NetAdj, GrsAdj); SetCellValue(doc, mcx(cx,TotalAdj), NetAdj); //set sum of Adj if (NetAdj>=0) then SetCellChkMark(doc, mcx(cx,PlusChk), True) //toggle the checkmarks else SetCellChkMark(doc, mcx(cx,NegChk), True); NetPct := 0; GrsPct := 0; saleValue := GetCellValue(doc, mcx(cx,salesAmt)); //calc the net/grs percents if saleValue <> 0 then begin NetPct := (NetAdj / saleValue) * 100; GrsPct := (GrsAdj / saleValue) * 100; SumOfWeightedValues := SumOfWeightedValues + (1-GrsPct/100) * (saleValue+ NetAdj); SumOfWeights := SumOfWeights + (1-GrsPct/100); end; SetInfoCellValue(doc, mcx(cx,infoNet), NetPct); SetInfoCellValue(doc, mcx(cx,infoGross), GrsPct); //set the info cells result := SetCellValue(doc, mcx(cx,FinalAmt), (saleValue + NetAdj)); //set final adj price end; function F1319C2IncomeAdjs(doc: TContainer; CX: CellUID) : Integer; const SalesAmt = 93; TotalAdj = 124; FinalAmt = 125; PlusChk = 122; NegChk = 123; InfoNet = 3; InfoGross = 4; var NetAdj,GrsAdj: Double; saleValue, NetPct, GrsPct: Double; begin NetAdj := 0; GrsAdj := 0; GetNetGrosAdjs(doc, mcx(cx,95), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,97), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,99), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,101), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,103), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,105), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,107), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,109), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,111), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,113), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,115), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,117), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,119), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,121), NetAdj, GrsAdj); SetCellValue(doc, mcx(cx,TotalAdj), NetAdj); //set sum of Adj if (NetAdj>=0) then SetCellChkMark(doc, mcx(cx,PlusChk), True) //toggle the checkmarks else SetCellChkMark(doc, mcx(cx,NegChk), True); NetPct := 0; GrsPct := 0; saleValue := GetCellValue(doc, mcx(cx,salesAmt)); //calc the net/grs percents if saleValue <> 0 then begin NetPct := (NetAdj / saleValue) * 100; GrsPct := (GrsAdj / saleValue) * 100; SumOfWeightedValues := SumOfWeightedValues + (1-GrsPct/100) * (saleValue+ NetAdj); SumOfWeights := SumOfWeights + (1-GrsPct/100); end; SetInfoCellValue(doc, mcx(cx,infoNet), NetPct); SetInfoCellValue(doc, mcx(cx,infoGross), GrsPct); //set the info cells result := SetCellValue(doc, mcx(cx,FinalAmt), (saleValue + NetAdj)); //set final adj price end; function F1319C3IncomeAdjs(doc: TContainer; CX: CellUID) : Integer; const SalesAmt = 140; TotalAdj = 171; FinalAmt = 172; PlusChk = 169; NegChk = 170; InfoNet = 5; InfoGross = 6; var NetAdj,GrsAdj: Double; saleValue, NetPct, GrsPct: Double; begin NetAdj := 0; GrsAdj := 0; GetNetGrosAdjs(doc, mcx(cx,142), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,144), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,146), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,148), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,150), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,152), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,154), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,156), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,158), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,160), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,162), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,164), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,166), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,168), NetAdj, GrsAdj); SetCellValue(doc, mcx(cx,TotalAdj), NetAdj); //set sum of Adj if (NetAdj>=0) then SetCellChkMark(doc, mcx(cx,PlusChk), True) //toggle the checkmarks else SetCellChkMark(doc, mcx(cx,NegChk), True); NetPct := 0; GrsPct := 0; saleValue := GetCellValue(doc, mcx(cx,salesAmt)); //calc the net/grs percents if saleValue <> 0 then begin NetPct := (NetAdj / saleValue) * 100; GrsPct := (GrsAdj / saleValue) * 100; SumOfWeightedValues := SumOfWeightedValues + (1-GrsPct/100) * (saleValue+ NetAdj); SumOfWeights := SumOfWeights + (1-GrsPct/100); end; SetInfoCellValue(doc, mcx(cx,infoNet), NetPct); SetInfoCellValue(doc, mcx(cx,infoGross), GrsPct); //set the info cells result := SetCellValue(doc, mcx(cx,FinalAmt), (saleValue + NetAdj)); //set final adj price end; function ProcessForm0372Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; begin if Cmd > 0 then repeat case Cmd of 1: Cmd := LandUseSum(doc, CX, 2, [30,31,32,33,34,36]); 2: Cmd := SiteDimension(doc, CX, MCX(cx,47)); else Cmd := 0; end; until Cmd = 0; result := 0; end; function ProcessForm0373Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; begin if Cmd > 0 then repeat case Cmd of 1: cmd := SumABC(doc, mcx(cx,79), mcx(CX,90), mcx(CX,102), mcx(cx,107)); 2: cmd := SumABC(doc, mcx(cx,80), mcx(cx,91), mcx(cx,103), mcx(cx,108)); 3: cmd := SumABC(doc, mcx(cx,83), mcx(cx,94), mcx(cx,106), mcx(cx,109)); else Cmd := 0; end; until Cmd = 0; result := 0; end; function ProcessForm0374Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; begin if Cmd > 0 then repeat case Cmd of 1: Cmd := F0374C1Adjustments(doc, cx); 2: Cmd := F0374C2Adjustments(doc, cx); 3: Cmd := F0374C3Adjustments(doc, cx); 4: Cmd := CalcWeightedAvg(doc, [846,847,848,374,393]); //calc wtAvg of main and xcomps forms 5: Cmd := DivideAB(doc, mcx(cx,12), mcx(CX,16), mcx(CX,14)); 6: Cmd := DivideAB(doc, mcx(cx,34), mcx(CX,40), mcx(CX,35)); 7: Cmd := DivideAB(doc, mcx(cx,65), mcx(CX,71), mcx(CX,66)); 8: Cmd := DivideAB(doc, mcx(cx,96), mcx(CX,102), mcx(CX,97)); 9: Cmd := ProcessMultipleCmds(ProcessForm0374Math, doc, CX,[1,6]); 10: Cmd := ProcessMultipleCmds(ProcessForm0374Math, doc, CX,[2,7]); 11: Cmd := ProcessMultipleCmds(ProcessForm0374Math, doc, CX,[3,8]); 12: begin //Math ID 12 is for Weighted Average F0374C1Adjustments(doc, cx); //sum of adjs F0374C2Adjustments(doc, cx); //sum of adjs F0374C3Adjustments(doc, cx); //sum of adjs Cmd := 0; end; else Cmd := 0; end; until Cmd = 0 else case Cmd of //special processing (negative cmds) UpdateNetGrossID: begin ProcessForm0374Math(doc, 1, CX); ProcessForm0374Math(doc, 2, CX); ProcessForm0374Math(doc, 3, CX); end; WeightedAvergeID: begin ProcessForm0374Math(doc, 12, CX); end; end; result := 0; end; function ProcessForm0376Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; begin if Cmd > 0 then repeat case Cmd of 1: cmd := MultAB(doc, mcx(cx,8), mcx(CX,9), mcx(CX,10)); 2: cmd := MultAB(doc, mcx(cx,11), mcx(CX,12), mcx(CX,13)); 3: cmd := MultAB(doc, mcx(cx,14), mcx(CX,15), mcx(CX,16)); 4: cmd := MultAB(doc, mcx(cx,17), mcx(CX,18), mcx(CX,19)); 5: cmd := MultAB(doc, mcx(cx,20), mcx(CX,21), mcx(CX,22)); 6: cmd := SumCellArray(doc, cx, [10,13,16,19,22,24,26,28], 29); 8: Cmd := MultPercentAB(doc, mcx(cx,29), mcx(cx,30),mcx(cx,31)); //phy dep precent entered 9: cmd := F0376CalcDeprLessPhy(doc, cx); //funct depr entered 10: cmd := F0376CalcDeprLessPhyNFunct(doc, cx); //external depr entered 11: cmd := SumABC(doc, mcx(cx,31), mcx(cx,33), mcx(cx,35), mcx(cx,36)); //sum depr 12: cmd := SubtAB(doc, MCX(cx,29), mcx(cx,36), mcx(cx,37)); //depr value of improvements 13: cmd := SumCellArray(doc, cx, [37,38,40,42,44,45], 46); 14: cmd := RoundByValR(doc, cx, 46, 49, 500); 15: cmd := ProcessMultipleCmds(ProcessForm0376Math, doc, CX,[8,9,10,12]); else Cmd := 0; end; until Cmd = 0; result := 0; end; function ProcessForm0377Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; begin if Cmd > 0 then repeat case Cmd of 1: cmd := SubtABCD(doc, mcx(cx,38), mcx(cx,40), mcx(cx,42), mcx(cx,44), mcx(CX,45)); 2,3: Cmd := F0377C1Adjustments(doc, cx); 4: cmd := SubtABCD(doc, mcx(cx,83), mcx(cx,85), mcx(cx,87), mcx(cx,89), mcx(CX,90)); 5,6: Cmd := F0377C2Adjustments(doc, cx); 7: cmd := SubtABCD(doc, mcx(cx,128), mcx(cx,130), mcx(cx,132), mcx(cx,134), mcx(CX,135)); 8,9: Cmd := F0377C3Adjustments(doc, cx); 10: cmd := MultAB(doc, mcx(cx,193), mcx(CX,194), mcx(CX,195)); else Cmd := 0; end; until Cmd = 0; result := 0; end; function ProcessForm0378Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; begin if Cmd > 0 then repeat case Cmd of 1: Cmd := DivideABPercent(doc, mcx(cx,9), mcx(CX,8), mcx(CX,10)); 2: Cmd := DivideAB(doc, mcx(cx,9), mcx(CX,26), mcx(CX,13)); 3: Cmd := ProcessMultipleCmds(ProcessForm0378Math, doc, CX,[2,1]); 4: Cmd := DivideABPercent(doc, mcx(cx,45), mcx(CX,44), mcx(CX,46)); 5: Cmd := DivideAB(doc, mcx(cx,45), mcx(CX,76), mcx(CX,49)); 6: Cmd := ProcessMultipleCmds(ProcessForm0378Math, doc, CX,[5,4,7]); 7: Cmd := F0378C1Adjustments(doc, cx); 9: Cmd := DivideABPercent(doc, mcx(cx,106), mcx(CX,105), mcx(CX,107)); 10: Cmd := DivideAB(doc, mcx(CX,106), mcx(CX,137), mcx(CX,110)); 11: Cmd := ProcessMultipleCmds(ProcessForm0378Math, doc, CX,[10,9,12]); 12: Cmd := F0378C2Adjustments(doc, cx); 14: Cmd := DivideABPercent(doc, mcx(CX,167), mcx(CX,166), mcx(CX,168)); 15: Cmd := DivideAB(doc, mcx(CX,167), mcx(CX,198), mcx(CX,171)); 16: Cmd := ProcessMultipleCmds(ProcessForm0378Math, doc, CX,[15,14,17]); 17: Cmd := F0378C3Adjustments(doc, cx); 18: Cmd := CalcWeightedAvg(doc, [846,847,378,391]); //calc wtAvg of main and xcomps forms 19: begin //Math ID 18 is for Weighted Average F0378C1Adjustments(doc, cx); //sum of adjs F0378C2Adjustments(doc, cx); //sum of adjs F0378C3Adjustments(doc, cx); //sum of adjs Cmd := 0; end; else Cmd := 0; end; until Cmd = 0 else case Cmd of //special processing (negative cmds) UpdateNetGrossID: begin ProcessForm0378Math(doc, 1, CX); ProcessForm0378Math(doc, 2, CX); ProcessForm0378Math(doc, 3, CX); end; WeightedAvergeID: begin ProcessForm0378Math(doc, 19, CX); end; end; result := 0; end; function ProcessForm0391Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; begin if Cmd > 0 then repeat case Cmd of 1: Cmd := DivideABPercent(doc, mcx(cx,10), mcx(CX,9), mcx(CX,11)); 2: Cmd := DivideAB(doc, mcx(cx,10), mcx(CX,27), mcx(CX,14)); 3: Cmd := ProcessMultipleCmds(ProcessForm0391Math, doc, CX,[2,1]); 4: Cmd := DivideABPercent(doc, mcx(cx,47), mcx(CX,46), mcx(CX,48)); 5: Cmd := DivideAB(doc, mcx(CX,47), mcx(CX,78), mcx(CX,51)); 6: Cmd := ProcessMultipleCmds(ProcessForm0391Math, doc, CX,[5,4,7]); 7: Cmd := F0391C1Adjustments(doc, cx); 9: Cmd := DivideABPercent(doc, mcx(cx,109), mcx(CX,108), mcx(CX,110)); 10: Cmd := DivideAB(doc, mcx(CX,109), mcx(CX,140), mcx(CX,113)); 11: Cmd := ProcessMultipleCmds(ProcessForm0391Math, doc, CX,[10,9,12]); 12: Cmd := F0391C2Adjustments(doc, cx); 14: Cmd := DivideABPercent(doc, mcx(CX,171), mcx(CX,170), mcx(CX,172)); 15: Cmd := DivideAB(doc, mcx(CX,171), mcx(CX,202), mcx(CX,175)); 16: Cmd := ProcessMultipleCmds(ProcessForm0391Math, doc, CX,[15,14,17]); 17: Cmd := F0391C3Adjustments(doc, cx); //dynamic form name 20: cmd := SetXXXPageTitleBarName(doc, cx, 'Extra Comps', 42,104,166); 19: cmd := SetXXXPageTitle(doc, cx, 'EXTRA COMPARABLES','', 42,104,166, 2); 21: cmd := ConfigXXXInstance(doc, cx, 42,104,166); //calc wtAvg of main and xcomps forms 22: Cmd := CalcWeightedAvg(doc, [846,847,378,391]); 23: begin //Math ID 23 is for Weighted Average F0391C1Adjustments(doc, cx); //sum of adjs F0391C2Adjustments(doc, cx); //sum of adjs F0391C3Adjustments(doc, cx); //sum of adjs Cmd := 0; end; else Cmd := 0; end; until Cmd = 0 else case Cmd of //special processing (negative cmds) UpdateNetGrossID: begin ProcessForm0391Math(doc, 1, CX); ProcessForm0391Math(doc, 2, CX); ProcessForm0391Math(doc, 3, CX); end; WeightedAvergeID: begin ProcessForm0391Math(doc, 23, CX); end; end; result := 0; end; function ProcessForm0392Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; begin if Cmd > 0 then repeat case Cmd of 1: cmd := SubtABCD(doc, mcx(cx,40), mcx(cx,42), mcx(cx,44), mcx(cx,46), mcx(CX,47)); 2,3: Cmd := F0392C1Adjustments(doc, cx); 4: cmd := SubtABCD(doc, mcx(cx,86), mcx(cx,88), mcx(cx,90), mcx(cx,92), mcx(CX,93)); 5,6: Cmd := F0392C2Adjustments(doc, cx); 7: cmd := SubtABCD(doc, mcx(cx,132), mcx(cx,134), mcx(cx,136), mcx(cx,138), mcx(CX,139)); 8,9: Cmd := F0392C3Adjustments(doc, cx); //dynamic form name 11: cmd := SetXXXPageTitleBarName(doc, cx, 'Extra Rentals', 32,78,124); 10: cmd := SetXXXPageTitle(doc, cx, 'EXTRA RENTALS','', 32,78,124, 2); 12: cmd := ConfigXXXInstance(doc, cx, 32,78,124); else Cmd := 0; end; until Cmd = 0; result := 0; end; function ProcessForm0393Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; begin if Cmd > 0 then repeat case Cmd of 1: Cmd := F0393C1Adjustments(doc, cx); 2: Cmd := F0393C2Adjustments(doc, cx); 3: Cmd := F0393C3Adjustments(doc, cx); 4: Cmd := CalcWeightedAvg(doc, [846,847,848,374,393]); //calc wtAvg of main and xcomps forms 5: Cmd := DivideAB(doc, mcx(cx,13), mcx(CX,17), mcx(CX,15)); 6: Cmd := DivideAB(doc, mcx(CX,36), mcx(CX,42), mcx(CX,37)); 7: Cmd := DivideAB(doc, mcx(cx,68), mcx(CX,74), mcx(CX,69)); 8: Cmd := DivideAB(doc, mcx(cx,100), mcx(CX,106), mcx(CX,101)); 9: Cmd := ProcessMultipleCmds(ProcessForm0393Math, doc, CX,[1,6]); 10: Cmd := ProcessMultipleCmds(ProcessForm0393Math, doc, CX,[2,7]); 11: Cmd := ProcessMultipleCmds(ProcessForm0393Math, doc, CX,[3,8]); //dynamic form name 13: cmd := SetXXXPageTitleBarName(doc, cx, 'Extra Sites', 30,62,94); 12: cmd := SetXXXPageTitle(doc, cx, 'EXTRA SITES','', 30,62,94, 2); 14: cmd := ConfigXXXInstance(doc, cx, 30,62,94); 15: begin //Math ID 15 is for Weighted Average F0393C1Adjustments(doc, cx); //sum of adjs F0393C2Adjustments(doc, cx); //sum of adjs F0393C3Adjustments(doc, cx); //sum of adjs Cmd := 0; end; else Cmd := 0; end; until Cmd = 0 else case Cmd of //special processing (negative cmds) UpdateNetGrossID: begin ProcessForm0393Math(doc, 1, CX); ProcessForm0393Math(doc, 2, CX); ProcessForm0393Math(doc, 3, CX); end; WeightedAvergeID: begin ProcessForm0393Math(doc, 15, CX); end; end; result := 0; end; function ProcessForm0388Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; begin if Cmd > 0 then repeat case Cmd of //dynamic form name 1: cmd := SetXXXPageTitleBarName(doc, cx, 'Photo Comparables', 7,11,15); 2: cmd := SetXXXPageTitle(doc, cx, 'COMPARABLES','PHOTO COMPARABLES',7,11,15, 2); 3: cmd := ConfigPhotoXXXInstance(doc, cx, 7,11,15); else Cmd := 0; end; until Cmd = 0; result := 0; end; function ProcessForm0389Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; begin if Cmd > 0 then repeat case Cmd of //dynamic form name 1: cmd := SetXXXPageTitleBarName(doc, cx, 'Photo Sites', 7,11,15); 2: cmd := SetXXXPageTitle(doc, cx, 'SITES','PHOTO SITES',7,11,15, 2); 3: cmd := ConfigPhotoXXXInstance(doc, cx, 7,11,15); else Cmd := 0; end; until Cmd = 0; result := 0; end; function ProcessForm0390Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; begin if Cmd > 0 then repeat case Cmd of //dynamic form name 1: cmd := SetXXXPageTitleBarName(doc, cx, 'Photo Rentals', 7,11,15); 2: cmd := SetXXXPageTitle(doc, cx, 'RENTALS','PHOTO RENTALS',7,11,15, 2); 3: cmd := ConfigPhotoXXXInstance(doc, cx, 7,11,15); else Cmd := 0; end; until Cmd = 0; result := 0; end; function ProcessForm0383Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; begin if Cmd > 0 then repeat case Cmd of 1: cmd := SetPageTitleBarName(doc, CX); else Cmd := 0; end; until Cmd = 0; result := 0; end; function ProcessForm0384Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; begin if Cmd > 0 then repeat case Cmd of 1: cmd := SetPageTitleBarName(doc, CX); else Cmd := 0; end; until Cmd = 0; result := 0; end; function ProcessForm0382Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; begin if Cmd > 0 then repeat case Cmd of 1: cmd := SetPageTitleBarName(doc, CX); else Cmd := 0; end; until Cmd = 0; result := 0; end; function ProcessForm0848Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; begin if Cmd > 0 then repeat case Cmd of 1: Cmd := F0848C1Adjustments(doc, cx); 2: Cmd := F0848C2Adjustments(doc, cx); 3: Cmd := F0848C3Adjustments(doc, cx); 4: Cmd := CalcWeightedAvg(doc, [848,374,393]); //calc wtAvg of main and xcomps forms 5: Cmd := DivideAB(doc, mcx(cx,12), mcx(CX,17), mcx(CX,14)); 6: Cmd := DivideAB(doc, mcx(CX,35), mcx(CX,41), mcx(CX,36)); 7: Cmd := DivideAB(doc, mcx(cx,66), mcx(CX,72), mcx(CX,67)); 8: Cmd := DivideAB(doc, mcx(cx,97), mcx(CX,103), mcx(CX,98)); 9: Cmd := ProcessMultipleCmds(ProcessForm0848Math, doc, CX,[1,6]); 10: Cmd := ProcessMultipleCmds(ProcessForm0848Math, doc, CX,[2,7]); 11: Cmd := ProcessMultipleCmds(ProcessForm0848Math, doc, CX,[3,8]); 12: Cmd := LandUseSum(doc, CX, 2, [30,31,32,33,34,36]); 13: Cmd := SiteDimension(doc, CX, MCX(cx,47)); 14: begin //Math ID 14 is for Weighted Average F0848C1Adjustments(doc, cx); //sum of adjs F0848C2Adjustments(doc, cx); //sum of adjs F0848C3Adjustments(doc, cx); //sum of adjs Cmd := 0; end; else Cmd := 0; end; until Cmd = 0 else case Cmd of //special processing (negative cmds) UpdateNetGrossID: begin ProcessForm0848Math(doc, 1, CX); ProcessForm0848Math(doc, 2, CX); ProcessForm0848Math(doc, 3, CX); end; WeightedAvergeID: begin ProcessForm0848Math(doc, 14, CX); end; end; result := 0; end; function ProcessForm0847Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; begin if Cmd > 0 then repeat case Cmd of //Site Evaluation ----------------------------------------------------------------------- 1: Cmd := F0847C1SiteAdjs(doc, cx); 2: Cmd := F0847C2SiteAdjs(doc, cx); 3: Cmd := F0847C3SiteAdjs(doc, cx); 4: Cmd := CalcWeightedAvg(doc, [847,374,393]); 5: Cmd := DivideAB(doc, mcx(cx,12), mcx(CX,17), mcx(CX,14)); 6: Cmd := DivideAB(doc, mcx(CX,35), mcx(CX,41), mcx(CX,36)); 7: Cmd := DivideAB(doc, mcx(cx,66), mcx(CX,72), mcx(CX,67)); 8: Cmd := DivideAB(doc, mcx(cx,97), mcx(CX,103), mcx(CX,98)); 9: Cmd := ProcessMultipleCmds(ProcessForm0847Math, doc, CX,[1,6]); 10: Cmd := ProcessMultipleCmds(ProcessForm0847Math, doc, CX,[2,7]); 11: Cmd := ProcessMultipleCmds(ProcessForm0847Math, doc, CX,[3,8]); //Market Area Analysis ------------------------------------------------------------------- 12: Cmd := LandUseSum(doc, CX, 2, [30,31,32,33,34,36]); //Improvements Analysis ------------------------------------------------------------------ 13: Cmd := SiteDimension(doc, CX, MCX(cx,47)); 14: Cmd := SumABC(doc, mcx(cx,78), mcx(CX,89), mcx(CX,101), mcx(cx,106)); 15: Cmd := SumABC(doc, mcx(cx,79), mcx(cx,90), mcx(cx,102), mcx(cx,107)); 16: Cmd := SumABC(doc, mcx(cx,82), mcx(cx,93), mcx(cx,105), mcx(cx,108)); //Cost Approach ------------------------------------------------------------------------- 17: Cmd := MultAB(doc, mcx(cx,8), mcx(CX,9), mcx(CX,10)); 18: Cmd := MultAB(doc, mcx(cx,11), mcx(CX,12), mcx(CX,13)); 19: Cmd := MultAB(doc, mcx(cx,14), mcx(CX,15), mcx(CX,16)); 20: Cmd := MultAB(doc, mcx(cx,17), mcx(CX,18), mcx(CX,19)); 21: Cmd := MultAB(doc, mcx(cx,20), mcx(CX,21), mcx(CX,22)); 22: Cmd := SumCellArray(doc, cx, [10,13,16,19,22,24,26,28], 29); //total cost new 25: Cmd := MultPercentAB(doc, mcx(cx,29), mcx(cx,30),mcx(cx,31)); //phy dep precent entered 26: Cmd := F0847CalcDeprLessPhy(doc, cx); //funct depr entered 27: Cmd := F0847CalcDeprLessPhyNFunct(doc, cx); //external depr entered 29: begin Cmd := SumABC(doc, mcx(cx,31), mcx(cx,33), mcx(cx,35), mcx(cx,36)); //sum depr SetCellValue(doc, mcx(cx,37), (-1 * GetCellValue(doc, mcx(cx,36)))); //set negative in accum end; 30: Cmd := SubtAB(doc, MCX(cx,29), mcx(cx,36), mcx(cx,38)); //depr value of improvements 31: Cmd := SumCellArray(doc, cx, [38,39,41,43,45,46], 47); //indictaed value 32: begin RoundByValR(doc, cx, 47, 50, 500); //cost approach value Cmd := CalcWeightedAvg(doc, [847,940,1311]); //calc wtAvg of main and xcomps forms end; 23: Cmd := ProcessMultipleCmds(ProcessForm0847Math, doc, CX,[25,26,27,30]); //Income Approach ------------------------------------------------------------------------ 33: Cmd := SubtABCD(doc, mcx(cx,39), mcx(cx,41), mcx(cx,43), mcx(cx,45), mcx(CX,46)); 34,35: Cmd := F0847IncomeAppC1Adjustments(doc, cx); 36: Cmd := SubtABCD(doc, mcx(cx,86), mcx(cx,88), mcx(cx,90), mcx(cx,92), mcx(CX,93)); 37,38: Cmd := F0847IncomeAppC2Adjustments(doc, cx); 39: Cmd := SubtABCD(doc, mcx(cx,133), mcx(cx,135), mcx(cx,137), mcx(cx,139), mcx(CX,140)); 40,41: Cmd := F0847IncomeAppC3Adjustments(doc, cx); 42: Cmd := MultAB(doc, mcx(cx,200), mcx(CX,201), mcx(CX,202)); //Sales Comparison Approach---------------------------------------------------------------- 43: Cmd := DivideABPercent(doc, mcx(cx,10), mcx(CX,9), mcx(CX,12)); 44: Cmd := DivideAB(doc, mcx(cx,10), mcx(CX,28), mcx(CX,15)); 45: Cmd := ProcessMultipleCmds(ProcessForm0847Math, doc, CX,[44,43,61]); 46: Cmd := DivideABPercent(doc, mcx(cx,50), mcx(CX,49), mcx(CX,52)); 47: Cmd := DivideAB(doc, mcx(cx,50), mcx(cx,80), mcx(cx,55)); //price/sqft 48: Cmd := ProcessMultipleCmds(ProcessForm0847Math, doc, CX,[47,46,49,62]); 49: Cmd := F0847SalesCompAppC1Adjustments(doc, cx); 51: Cmd := DivideABPercent(doc, mcx(cx,113), mcx(CX,112), mcx(CX,115)); 52: Cmd := DivideAB(doc, mcx(cx,113), mcx(cx,143), mcx(cx,118)); //price/sqft 53: Cmd := ProcessMultipleCmds(ProcessForm0847Math, doc, CX,[52,51,54,63]); 54: Cmd := F0847SalesCompAppC2Adjustments(doc, cx); 56: Cmd := DivideABPercent(doc, mcx(CX,176), mcx(CX,175), mcx(CX,178)); 57: Cmd := DivideAB(doc, mcx(cx,176), mcx(cx,206), mcx(cx,181)); //price/sqft 58: Cmd := ProcessMultipleCmds(ProcessForm0847Math, doc, CX,[57,56,59,64]); 59: Cmd := F0847SalesCompAppC3Adjustments(doc, cx); 61: Cmd := DivideABPercent(doc, mcx(cx,10), mcx(CX,8), mcx(CX,11)); 62: Cmd := DivideABPercent(doc, mcx(cx,50), mcx(CX,48), mcx(CX,51)); 63: Cmd := DivideABPercent(doc, mcx(cx,113), mcx(CX,111), mcx(CX,114)); 64: Cmd := DivideABPercent(doc, mcx(cx,176), mcx(CX,174), mcx(CX,177)); 60: Cmd := CalcWeightedAvg(doc, [846,847,378,391]); //calc wtAvg of main and xcomps forms 65: begin //Math ID 32 is for Weighted Average F0847SalesCompAppC1Adjustments(doc, cx); //sum of adjs F0847SalesCompAppC2Adjustments(doc, cx); //sum of adjs F0847SalesCompAppC3Adjustments(doc, cx); //sum of adjs Cmd := 0; end; else Cmd := 0; end; until Cmd = 0 else case Cmd of //special processing (negative cmds) UpdateNetGrossID: begin ProcessForm0847Math(doc, 1, CX); ProcessForm0847Math(doc, 2, CX); ProcessForm0847Math(doc, 3, CX); end; WeightedAvergeID: begin CX.pg := 7; ProcessForm0847Math(doc, 65, CX); end; end; result := 0; end; function ProcessForm1303Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; begin if Cmd > 0 then repeat case Cmd of 12: Cmd := LandUseSum(doc, CX, 2, [30,31,32,33,34,36]); 13: Cmd := SiteDimension(doc, CX, MCX(cx,47)); else Cmd := 0; end; until Cmd = 0; result := 0; end; function ProcessForm1304Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; begin if Cmd > 0 then repeat case Cmd of 1: Cmd := F1304C1Adjustments(doc, cx); 2: Cmd := F1304C2Adjustments(doc, cx); 3: Cmd := F1304C3Adjustments(doc, cx); 4: Cmd := CalcWeightedAvg(doc, [941,1304,1309,1317]); //calc wtAvg of main and xcomps forms 5: Cmd := DivideAB(doc, mcx(cx,12), mcx(CX,17), mcx(CX,14)); 6: Cmd := DivideAB(doc, mcx(CX,35), mcx(CX,41), mcx(CX,36)); 7: Cmd := DivideAB(doc, mcx(cx,66), mcx(CX,72), mcx(CX,67)); 8: Cmd := DivideAB(doc, mcx(cx,97), mcx(CX,103), mcx(CX,98)); 9: Cmd := ProcessMultipleCmds(ProcessForm1304Math, doc, CX,[1,6]); 10: Cmd := ProcessMultipleCmds(ProcessForm1304Math, doc, CX,[2,7]); 11: Cmd := ProcessMultipleCmds(ProcessForm1304Math, doc, CX,[3,8]); 14: begin //Math ID 14 is for Weighted Average F1304C1Adjustments(doc, cx); //sum of adjs F1304C2Adjustments(doc, cx); //sum of adjs F1304C3Adjustments(doc, cx); //sum of adjs Cmd := 0; end; else Cmd := 0; end; until Cmd = 0 else case Cmd of //special processing (negative cmds) UpdateNetGrossID: begin ProcessForm1304Math(doc, 1, CX); ProcessForm1304Math(doc, 2, CX); ProcessForm1304Math(doc, 3, CX); end; WeightedAvergeID: begin ProcessForm1304Math(doc, 14, CX); end; end; result := 0; end; function ProcessForm1307Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; begin if Cmd > 0 then repeat case Cmd of 12: Cmd := LandUseSum(doc, CX, 2, [30,31,32,33,34,36]); 13: Cmd := SiteDimension(doc, CX, MCX(cx,47)); else Cmd := 0; end; until Cmd = 0; result := 0; end; function ProcessForm1308Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; begin if Cmd > 0 then repeat case Cmd of 14: Cmd := SumABC(doc, mcx(cx,78), mcx(CX,89), mcx(CX,101), mcx(cx,106)); 15: Cmd := SumABC(doc, mcx(cx,79), mcx(cx,90), mcx(cx,102), mcx(cx,107)); 16: Cmd := SumABC(doc, mcx(cx,82), mcx(cx,93), mcx(cx,105), mcx(cx,108)); else Cmd := 0; end; until Cmd = 0; result := 0; end; function ProcessForm1309Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; begin if Cmd > 0 then repeat case Cmd of //Site Evaluation ----------------------------------------------------------------------- 1: Cmd := F1309C1SiteAdjs(doc, cx); 2: Cmd := F1309C2SiteAdjs(doc, cx); 3: Cmd := F1309C3SiteAdjs(doc, cx); 4: Cmd := CalcWeightedAvg(doc, [941,1304,1309,1317]); 5: Cmd := DivideAB(doc, mcx(cx,12), mcx(CX,17), mcx(CX,14)); 6: Cmd := DivideAB(doc, mcx(CX,35), mcx(CX,41), mcx(CX,36)); 7: Cmd := DivideAB(doc, mcx(cx,66), mcx(CX,72), mcx(CX,67)); 8: Cmd := DivideAB(doc, mcx(cx,97), mcx(CX,103), mcx(CX,98)); 9: Cmd := ProcessMultipleCmds(ProcessForm1309Math, doc, CX,[1,6]); 10: Cmd := ProcessMultipleCmds(ProcessForm1309Math, doc, CX,[2,7]); 11: Cmd := ProcessMultipleCmds(ProcessForm1309Math, doc, CX,[3,8]); 65: begin //Math ID 65 is for Weighted Average F1309SalesCompAppC1Adjustments(doc, cx); //sum of adjs F1309SalesCompAppC2Adjustments(doc, cx); //sum of adjs F1309SalesCompAppC3Adjustments(doc, cx); //sum of adjs Cmd := 0; end; else Cmd := 0; end; until Cmd = 0 else case Cmd of //special processing (negative cmds) UpdateNetGrossID: begin ProcessForm1309Math(doc, 1, CX); ProcessForm1309Math(doc, 2, CX); ProcessForm1309Math(doc, 3, CX); end; WeightedAvergeID: begin ProcessForm1309Math(doc, 65, CX); end; end; result := 0; end; function ProcessForm1310Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; begin if Cmd > 0 then repeat case Cmd of //Cost Approach ------------------------------------------------------------------------- 17: Cmd := MultAB(doc, mcx(cx,8), mcx(CX,9), mcx(CX,10)); 18: Cmd := MultAB(doc, mcx(cx,11), mcx(CX,12), mcx(CX,13)); 19: Cmd := MultAB(doc, mcx(cx,14), mcx(CX,15), mcx(CX,16)); 20: Cmd := MultAB(doc, mcx(cx,17), mcx(CX,18), mcx(CX,19)); 21: Cmd := MultAB(doc, mcx(cx,20), mcx(CX,21), mcx(CX,22)); 22: Cmd := SumCellArray(doc, cx, [10,13,16,19,22,24,26,28], 29); //total cost new 25: Cmd := MultPercentAB(doc, mcx(cx,29), mcx(cx,30), mcx(cx,31)); //phy dep precent entered 26: Cmd := F0847CalcDeprLessPhy(doc, cx); //funct depr entered 27: Cmd := F0847CalcDeprLessPhyNFunct(doc, cx); //external depr entered 29: begin Cmd := SumABC(doc, mcx(cx,31), mcx(cx,33), mcx(cx,35), mcx(cx,36)); //sum depr SetCellValue(doc, mcx(cx,37), (-1 * GetCellValue(doc, mcx(cx,36)))); //set negative in accum end; 30: Cmd := SubtAB(doc, MCX(cx,29), mcx(cx,36), mcx(cx,38)); //depr value of improvements 31: Cmd := SumCellArray(doc, cx, [38,40,42,44,45], 46); //indictaed value 32: Cmd := RoundByValR(doc, cx, 46, 49, 500); //cost approach value 23: Cmd := ProcessMultipleCmds(ProcessForm1310Math, doc, CX,[25,26,27,30]); else Cmd := 0; end; until Cmd = 0; result := 0; end; function ProcessForm1311Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; begin if Cmd > 0 then repeat case Cmd of 34: Cmd := F1311C1IncomeAdjs(doc, cx); 37: Cmd := F1311C2IncomeAdjs(doc, cx); 40: Cmd := F1311C3IncomeAdjs(doc, cx); //Income Approach ------------------------------------------------------------------------ 33: Cmd := SubtABCD(doc, mcx(cx,39), mcx(cx,41), mcx(cx,43), mcx(cx,45), mcx(CX,46)); 35: Cmd := ProcessMultipleCmds(ProcessForm1311Math, doc, CX,[34]); 36: Cmd := SubtABCD(doc, mcx(cx,86), mcx(cx,88), mcx(cx,90), mcx(cx,92), mcx(CX,93)); 38: Cmd := ProcessMultipleCmds(ProcessForm1311Math, doc, CX,[37]); 39: Cmd := SubtABCD(doc, mcx(cx,133), mcx(cx,135), mcx(cx,137), mcx(cx,139), mcx(CX,140)); 41: Cmd := ProcessMultipleCmds(ProcessForm1311Math, doc, CX,[40]); 42: Cmd := CalcWeightedAvg(doc, [940,1311,1319]); 43: Cmd := MultAB(doc, mcx(cx,200), mcx(CX,201), mcx(CX,202)); 65: begin //Math ID 65 is for Weighted Average F1311C1IncomeAdjs(doc, cx); //sum of adjs F1311C2IncomeAdjs(doc, cx); //sum of adjs F1311C3IncomeAdjs(doc, cx); //sum of adjs Cmd := 0; end; else Cmd := 0; end; until Cmd = 0 else case Cmd of //special processing (negative cmds) UpdateNetGrossID: begin ProcessForm1311Math(doc, 34, CX); ProcessForm1311Math(doc, 37, CX); ProcessForm1311Math(doc, 40, CX); end; WeightedAvergeID: begin ProcessForm1311Math(doc, 65, CX); end; end; result := 0; end; function ProcessForm1312Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; begin if Cmd > 0 then repeat case Cmd of // 1: Cmd := F1312C1SiteAdjs(doc, cx); //this is wrong. We should use math id 49,54,59 for adjustment // 2: Cmd := F1312C2SiteAdjs(doc, cx); // 3: Cmd := F1312C3SiteAdjs(doc, cx); //Sales Comparison Approach---------------------------------------------------------------- 43: Cmd := DivideABPercent(doc, mcx(cx,10), mcx(CX,9), mcx(CX,12)); 44: Cmd := DivideAB(doc, mcx(cx,10), mcx(CX,28), mcx(CX,15)); 45: Cmd := ProcessMultipleCmds(ProcessForm1312Math, doc, CX,[44,43,61]); 46: Cmd := DivideABPercent(doc, mcx(cx,50), mcx(CX,49), mcx(CX,52)); 47: Cmd := DivideAB(doc, mcx(cx,50), mcx(cx,80), mcx(cx,55)); //price/sqft 48: Cmd := ProcessMultipleCmds(ProcessForm1312Math, doc, CX,[47,46,49,62]); 49: Cmd := F1312SalesCompAppC1Adjustments(doc, cx); 51: Cmd := DivideABPercent(doc, mcx(cx,113), mcx(CX,112), mcx(CX,115)); 52: Cmd := DivideAB(doc, mcx(cx,113), mcx(cx,143), mcx(cx,118)); //price/sqft 53: Cmd := ProcessMultipleCmds(ProcessForm1312Math, doc, CX,[52,51,54,63]); 54: Cmd := F1312SalesCompAppC2Adjustments(doc, cx); 56: Cmd := DivideABPercent(doc, mcx(CX,176), mcx(CX,175), mcx(CX,178)); 57: Cmd := DivideAB(doc, mcx(cx,176), mcx(cx,206), mcx(cx,181)); //price/sqft 58: Cmd := ProcessMultipleCmds(ProcessForm1312Math, doc, CX,[57,56,59,64]); 59: Cmd := F1312SalesCompAppC3Adjustments(doc, cx); 61: Cmd := DivideABPercent(doc, mcx(cx,10), mcx(CX,8), mcx(CX,11)); 62: Cmd := DivideABPercent(doc, mcx(cx,50), mcx(CX,48), mcx(CX,51)); 63: Cmd := DivideABPercent(doc, mcx(cx,113), mcx(CX,111), mcx(CX,114)); 64: Cmd := DivideABPercent(doc, mcx(cx,176), mcx(CX,174), mcx(CX,177)); 60: Cmd := CalcWeightedAvg(doc, [939,1312,1320]); //calc wtAvg of main and xcomps forms 65: begin //Math ID 65 is for Weighted Average F1312SalesCompAppC1Adjustments(doc, cx); //sum of adjs F1312SalesCompAppC2Adjustments(doc, cx); //sum of adjs F1312SalesCompAppC3Adjustments(doc, cx); //sum of adjs Cmd := 0; end; else Cmd := 0; end; until Cmd = 0 else case Cmd of //special processing (negative cmds) UpdateNetGrossID: begin // ProcessForm1312Math(doc, 1, CX); // ProcessForm1312Math(doc, 2, CX); // ProcessForm1312Math(doc, 3, CX); ProcessForm1312Math(doc, 65, CX); //ticket #1241 end; WeightedAvergeID: begin ProcessForm1312Math(doc, 65, CX); end; end; result := 0; end; function ProcessForm0846Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; begin if Cmd > 0 then repeat case Cmd of //Site Evaluation ----------------------------------------------------------------------- 1: Cmd := F0846SiteValuationC1Adjustments(doc, cx); 2: Cmd := F0846SiteValuationC2Adjustments(doc, cx); 3: Cmd := F0846SiteValuationC3Adjustments(doc, cx); 4: Cmd := CalcWeightedAvg(doc, [846,374,378,391,393]); //calc wtAvg of main and xcomps forms 5: Cmd := DivideAB(doc, mcx(cx,12), mcx(CX,17), mcx(CX,14)); 6: Cmd := DivideAB(doc, mcx(cx,35), mcx(CX,41), mcx(CX,36)); 7: Cmd := DivideAB(doc, mcx(cx,66), mcx(CX,72), mcx(CX,67)); 8: Cmd := DivideAB(doc, mcx(cx,97), mcx(CX,103), mcx(CX,98)); 9: Cmd := ProcessMultipleCmds(ProcessForm0846Math, doc, CX,[1,6]); 10: Cmd := ProcessMultipleCmds(ProcessForm0846Math, doc, CX,[2,7]); 11: Cmd := ProcessMultipleCmds(ProcessForm0846Math, doc, CX,[3,8]); //Market Area Analysis ------------------------------------------------------------------- 12: Cmd := LandUseSum(doc, CX, 2, [30,31,32,33,34,36]); //Improvements Analysis ------------------------------------------------------------------ 13: Cmd := SiteDimension(doc, CX, MCX(cx,47)); 14: Cmd := SumABC(doc, mcx(cx,78), mcx(CX,89), mcx(CX,101), mcx(cx,106)); 15: Cmd := SumABC(doc, mcx(cx,79), mcx(cx,90), mcx(cx,102), mcx(cx,107)); 16: Cmd := SumABC(doc, mcx(cx,82), mcx(cx,93), mcx(cx,105), mcx(cx,108)); //Cost Approach ------------------------------------------------------------------------- 17: Cmd := MultAB(doc, mcx(cx,8), mcx(CX,9), mcx(CX,10)); 18: Cmd := MultAB(doc, mcx(cx,11), mcx(CX,12), mcx(CX,13)); 19: Cmd := MultAB(doc, mcx(cx,14), mcx(CX,15), mcx(CX,16)); 20: Cmd := MultAB(doc, mcx(cx,17), mcx(CX,18), mcx(CX,19)); 21: Cmd := MultAB(doc, mcx(cx,20), mcx(CX,21), mcx(CX,22)); 22: Cmd := SumCellArray(doc, cx, [10,13,16,19,22,24,26,28], 29); //total cost new 25: Cmd := MultPercentAB(doc, mcx(cx,29), mcx(cx,30),mcx(cx,31)); //phy dep precent entered 26: Cmd := F0847CalcDeprLessPhy(doc, cx); //funct depr entered 27: Cmd := F0847CalcDeprLessPhyNFunct(doc, cx); //external depr entered 29: begin Cmd := SumABC(doc, mcx(cx,31), mcx(cx,33), mcx(cx,35), mcx(cx,36)); //sum depr SetCellValue(doc, mcx(cx,37), (-1 * GetCellValue(doc, mcx(cx,36)))); //set negative in accum end; 30: Cmd := SubtAB(doc, MCX(cx,29), mcx(cx,36), mcx(cx,38)); //depr value of improvements 31: Cmd := SumCellArray(doc, cx, [38,39,41,43,45,46], 47); //indictaed value 32: Cmd := RoundByValR(doc, cx, 47, 50, 500); //cost approach value 23: Cmd := ProcessMultipleCmds(ProcessForm0847Math, doc, CX,[25,26,27,30]); //Income Approach ------------------------------------------------------------------------ 33: Cmd := SubtABCD(doc, mcx(cx,39), mcx(cx,41), mcx(cx,43), mcx(cx,45), mcx(CX,46)); 34,35: begin F0846IncomeAppC1Adjustments(doc, cx); Cmd := CalcWeightedAvg(doc, [846,940,1319]); //calc wtAvg of main and xcomps forms end; 36: Cmd := SubtABCD(doc, mcx(cx,86), mcx(cx,88), mcx(cx,90), mcx(cx,92), mcx(CX,93)); 37,38: begin F0846IncomeAppC2Adjustments(doc, cx); Cmd := CalcWeightedAvg(doc, [846,940,1319]); //calc wtAvg of main and xcomps forms end; 39: Cmd := SubtABCD(doc, mcx(cx,133), mcx(cx,135), mcx(cx,137), mcx(cx,139), mcx(CX,140)); 40,41: begin F0846IncomeAppC3Adjustments(doc, cx); Cmd := CalcWeightedAvg(doc, [846,940,1319]); //calc wtAvg of main and xcomps forms end; 42: Cmd := MultAB(doc, mcx(cx,200), mcx(CX,201), mcx(CX,202)); //Sales Comparison Approach---------------------------------------------------------------- 43: Cmd := DivideABPercent(doc, mcx(cx,10), mcx(CX,9), mcx(CX,12)); 44: Cmd := DivideAB(doc, mcx(cx,10), mcx(CX,28), mcx(CX,15)); 45: Cmd := ProcessMultipleCmds(ProcessForm0846Math, doc, CX,[44,43,61]); 46: Cmd := DivideABPercent(doc, mcx(cx,50), mcx(CX,49), mcx(CX,52)); 47: Cmd := DivideAB(doc, mcx(cx,50), mcx(cx,80), mcx(cx,55)); //price/sqft 48: Cmd := ProcessMultipleCmds(ProcessForm0846Math, doc, CX,[47,46,49,62]); 49: Cmd := F0846SalesCompAppC1Adjustments(doc, cx); 51: Cmd := DivideABPercent(doc, mcx(cx,113), mcx(CX,112), mcx(CX,115)); 52: Cmd := DivideAB(doc, mcx(cx,113), mcx(cx,143), mcx(cx,118)); //price/sqft 53: Cmd := ProcessMultipleCmds(ProcessForm0846Math, doc, CX,[52,51,54,63]); 54: Cmd := F0846SalesCompAppC2Adjustments(doc, cx); 56: Cmd := DivideABPercent(doc, mcx(CX,176), mcx(CX,175), mcx(CX,178)); 57: Cmd := DivideAB(doc, mcx(cx,176), mcx(cx,206), mcx(cx,181)); //price/sqft 58: Cmd := ProcessMultipleCmds(ProcessForm0846Math, doc, CX,[57,56,59,64]); 59: Cmd := F0846SalesCompAppC3Adjustments(doc, cx); 61: Cmd := DivideABPercent(doc, mcx(cx,10), mcx(CX,8), mcx(CX,11)); 62: Cmd := DivideABPercent(doc, mcx(cx,50), mcx(CX,48), mcx(CX,51)); 63: Cmd := DivideABPercent(doc, mcx(cx,113), mcx(CX,111), mcx(CX,114)); 64: Cmd := DivideABPercent(doc, mcx(cx,176), mcx(CX,174), mcx(CX,177)); 60: Cmd := CalcWeightedAvg(doc, [846,847,378,391]); //calc wtAvg of main and xcomps forms 65: begin //Math ID 12 is for Weighted Average F0846SalesCompAppC1Adjustments(doc, cx); //sum of adjs F0846SalesCompAppC2Adjustments(doc, cx); //sum of adjs F0846SalesCompAppC3Adjustments(doc, cx); //sum of adjs Cmd := 0; end; else Cmd := 0; end; until Cmd = 0 else case Cmd of //special processing (negative cmds) UpdateNetGrossID: begin ProcessForm0846Math(doc, 1, CX); ProcessForm0846Math(doc, 2, CX); ProcessForm0846Math(doc, 3, CX); end; WeightedAvergeID: begin CX.pg := 7; ProcessForm0846Math(doc, 65, CX); end; end; result := 0; end; function ProcessForm1315Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; begin if Cmd > 0 then repeat case Cmd of 12: Cmd := LandUseSum(doc, CX, 2, [30,31,32,33,34,36]); 13: Cmd := SiteDimension(doc, CX, MCX(cx,47)); else Cmd := 0; end; until Cmd = 0; result := 0; end; function ProcessForm1316Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; begin if Cmd > 0 then repeat case Cmd of //Improvements Analysis ------------------------------------------------------------------ // 13: Cmd := SiteDimension(doc, CX, MCX(cx,47)); //Ticket #1342: no site dimension on the form 14: Cmd := SumABC(doc, mcx(cx,78), mcx(CX,89), mcx(CX,101), mcx(cx,106)); 15: Cmd := SumABC(doc, mcx(cx,79), mcx(cx,90), mcx(cx,102), mcx(cx,107)); 16: Cmd := SumABC(doc, mcx(cx,82), mcx(cx,93), mcx(cx,105), mcx(cx,108)); else Cmd := 0; end; until Cmd = 0; result := 0; end; function ProcessForm1317Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; begin if Cmd > 0 then repeat case Cmd of //Site Evaluation ----------------------------------------------------------------------- 1: Cmd := F1317SiteValuationC1Adjustments(doc, cx); 2: Cmd := F1317SiteValuationC2Adjustments(doc, cx); 3: Cmd := F1317SiteValuationC3Adjustments(doc, cx); 4: Cmd := CalcWeightedAvg(doc, [941,1304,1309,1317]); //calc wtAvg of main and xcomps forms 5: Cmd := DivideAB(doc, mcx(cx,12), mcx(CX,17), mcx(CX,14)); 6: Cmd := DivideAB(doc, mcx(cx,35), mcx(CX,41), mcx(CX,36)); 7: Cmd := DivideAB(doc, mcx(cx,66), mcx(CX,72), mcx(CX,67)); 8: Cmd := DivideAB(doc, mcx(cx,97), mcx(CX,103), mcx(CX,98)); 9: Cmd := ProcessMultipleCmds(ProcessForm1317Math, doc, CX,[1,6]); 10: Cmd := ProcessMultipleCmds(ProcessForm1317Math, doc, CX,[2,7]); 11: Cmd := ProcessMultipleCmds(ProcessForm1317Math, doc, CX,[3,8]); 65: begin //Math ID 65 is for Weighted Average F1317SiteValuationC1Adjustments(doc, cx); //sum of adjs F1317SiteValuationC2Adjustments(doc, cx); //sum of adjs F1317SiteValuationC3Adjustments(doc, cx); //sum of adjs Cmd := 0; end; else Cmd := 0; end; until Cmd = 0 else case Cmd of //special processing (negative cmds) UpdateNetGrossID: begin ProcessForm1317Math(doc, 1, CX); ProcessForm1317Math(doc, 2, CX); ProcessForm1317Math(doc, 3, CX); end; WeightedAvergeID: begin ProcessForm1317Math(doc, 65, CX); end; end; result := 0; end; function ProcessForm1318Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; begin if Cmd > 0 then repeat case Cmd of //Cost Approach ------------------------------------------------------------------------- 17: Cmd := MultAB(doc, mcx(cx,8), mcx(CX,9), mcx(CX,10)); 18: Cmd := MultAB(doc, mcx(cx,11), mcx(CX,12), mcx(CX,13)); 19: Cmd := MultAB(doc, mcx(cx,14), mcx(CX,15), mcx(CX,16)); 20: Cmd := MultAB(doc, mcx(cx,17), mcx(CX,18), mcx(CX,19)); 21: Cmd := MultAB(doc, mcx(cx,20), mcx(CX,21), mcx(CX,22)); 22: Cmd := SumCellArray(doc, cx, [10,13,16,19,22,24,26,28], 29); //total cost new 25: Cmd := MultPercentAB(doc, mcx(cx,29), mcx(cx,30), mcx(cx,31)); //phy dep precent entered 26: Cmd := F0847CalcDeprLessPhy(doc, cx); //funct depr entered 27: Cmd := F0847CalcDeprLessPhyNFunct(doc, cx); //external depr entered 29: begin Cmd := SumABC(doc, mcx(cx,31), mcx(cx,33), mcx(cx,35), mcx(cx,36)); //sum depr SetCellValue(doc, mcx(cx,37), (-1 * GetCellValue(doc, mcx(cx,36)))); //set negative in accum end; 30: Cmd := SubtAB(doc, MCX(cx,29), mcx(cx,36), mcx(cx,38)); //depr value of improvements 31: Cmd := SumCellArray(doc, cx, [38,40,42,44,45], 46); //indictaed value 32: Cmd := RoundByValR(doc, cx, 46, 49, 500); //cost approach value 23: Cmd := ProcessMultipleCmds(ProcessForm1310Math, doc, CX,[25,26,27,30]); else Cmd := 0; end; until Cmd = 0; result := 0; end; //Ticket #1342: new math for Cost Approach 1323 function ProcessForm1323Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; begin if Cmd > 0 then repeat case Cmd of //Cost Approach ------------------------------------------------------------------------- 17: Cmd := MultAB(doc, mcx(cx,8), mcx(CX,9), mcx(CX,10)); 18: Cmd := MultAB(doc, mcx(cx,11), mcx(CX,12), mcx(CX,13)); 19: Cmd := MultAB(doc, mcx(cx,14), mcx(CX,15), mcx(CX,16)); 20: Cmd := MultAB(doc, mcx(cx,17), mcx(CX,18), mcx(CX,19)); 21: Cmd := MultAB(doc, mcx(cx,20), mcx(CX,21), mcx(CX,22)); 22: begin SumCellArray(doc, cx, [10,13,16,19,22,24,26,28], 29); //total cost new Cmd := ProcessMultipleCmds(ProcessForm1323Math, doc, CX, [29, 23, 32]); end; 29: begin SumABC(doc, mcx(cx,30), mcx(cx,31), mcx(cx,32), mcx(cx,33)); //sum depr SetCellValue(doc, mcx(cx,34), (-1 * GetCellValue(doc, mcx(cx,33)))); //set negative in accum Cmd := SumAB(doc, mcx(cx,29), mcx(cx,34), mcx(cx,35)); //sum depr end; 30: Cmd := SubtAB(doc, MCX(cx,29), mcx(cx,33), mcx(cx,35)); //depr value of improvements 31: Cmd := SumCellArray(doc, cx, [35,37,39,41,42], 43); //indictaed value 32: Cmd := RoundByValR(doc, cx, 43, 46, 500); //cost approach value 23: begin SumCellArray(doc, cx, [35,37,39,41,42], 43); Cmd := RoundByValR(doc, cx, 43, 46, 500); end; else Cmd := 0; end; until Cmd = 0; result := 0; end; //Ticket #1342: new math for Cost Approach 1323 function ProcessForm1324Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; begin if Cmd > 0 then repeat case Cmd of //Cost Approach ------------------------------------------------------------------------- 17: Cmd := MultAB(doc, mcx(cx,8), mcx(CX,9), mcx(CX,10)); 18: Cmd := MultAB(doc, mcx(cx,11), mcx(CX,12), mcx(CX,13)); 19: Cmd := MultAB(doc, mcx(cx,14), mcx(CX,15), mcx(CX,16)); 20: Cmd := MultAB(doc, mcx(cx,17), mcx(CX,18), mcx(CX,19)); 21: Cmd := MultAB(doc, mcx(cx,20), mcx(CX,21), mcx(CX,22)); 22: begin SumCellArray(doc, cx, [10,13,16,19,22,24,26,28], 29); //total cost new Cmd := ProcessMultipleCmds(ProcessForm1323Math, doc, CX, [29, 23, 32]); end; 29: begin SumABC(doc, mcx(cx,30), mcx(cx,31), mcx(cx,32), mcx(cx,33)); //sum depr SetCellValue(doc, mcx(cx,34), (-1 * GetCellValue(doc, mcx(cx,33)))); //set negative in accum Cmd := SumAB(doc, mcx(cx,29), mcx(cx,34), mcx(cx,35)); //sum depr end; 30: Cmd := SubtAB(doc, MCX(cx,29), mcx(cx,33), mcx(cx,35)); //depr value of improvements 31: Cmd := SumCellArray(doc, cx, [35,37,39,41,42], 43); //indictaed value 32: Cmd := RoundByValR(doc, cx, 43, 46, 500); //cost approach value 23: begin SumCellArray(doc, cx, [35,37,39,41,42], 43); Cmd := RoundByValR(doc, cx, 43, 46, 500); end; else Cmd := 0; end; until Cmd = 0; result := 0; end; function ProcessForm1319Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; begin if Cmd > 0 then repeat case Cmd of 34: Cmd := F1319C1IncomeAdjs(doc, cx); 37: Cmd := F1319C2IncomeAdjs(doc, cx); 40: Cmd := F1319C3IncomeAdjs(doc, cx); //Income Approach ------------------------------------------------------------------------ 33: Cmd := SubtABCD(doc, mcx(cx,39), mcx(cx,41), mcx(cx,43), mcx(cx,45), mcx(CX,46)); 35: Cmd := ProcessMultipleCmds(ProcessForm1319Math, doc, CX,[34]); 36: Cmd := SubtABCD(doc, mcx(cx,86), mcx(cx,88), mcx(cx,90), mcx(cx,92), mcx(CX,93)); 38: Cmd := ProcessMultipleCmds(ProcessForm1319Math, doc, CX,[37]); 39: Cmd := SubtABCD(doc, mcx(cx,133), mcx(cx,135), mcx(cx,137), mcx(cx,139), mcx(CX,140)); 41: Cmd := ProcessMultipleCmds(ProcessForm1319Math, doc, CX,[40]); 42: Cmd := CalcWeightedAvg(doc, [940,1311,1319]); 43: Cmd := MultAB(doc, mcx(cx,200), mcx(CX,201), mcx(CX,202)); 65: begin //Math ID 65 is for Weighted Average F1319C1IncomeAdjs(doc, cx); //sum of adjs F1319C2IncomeAdjs(doc, cx); //sum of adjs F1319C3IncomeAdjs(doc, cx); //sum of adjs Cmd := 0; end; else Cmd := 0; end; until Cmd = 0 else case Cmd of //special processing (negative cmds) UpdateNetGrossID: begin ProcessForm1319Math(doc, 34, CX); ProcessForm1319Math(doc, 37, CX); ProcessForm1319Math(doc, 40, CX); end; WeightedAvergeID: begin ProcessForm1319Math(doc, 65, CX); end; end; result := 0; end; function F1320SalesCompAppC1Adjustments(doc: TContainer; CX: CellUID): Integer; //Ticket #1342: use it's own form to reference cell begin result := SalesGridAdjustment(doc, CX, 50,104,105,102,103,1,2, [57,59,61,63,65,67,69,71,73,75,77,79,81,83,85,87,89,91,93,95,97,99,101]); end; function F1320SalesCompAppC2Adjustments(doc: TContainer; CX: CellUID): Integer; //Ticket #1342 use it's own form to reference begin result := SalesGridAdjustment(doc, CX, 113,167,168,165,166,3,4, [120,122,124,126,128,130,132,134,136,138,140,142,144,146,148,150,152,154,156,158,160,162,164]); end; function F1320SalesCompAppC3Adjustments(doc: TContainer; CX: CellUID): Integer; //Ticket #1342 use it's own form to reference begin result := SalesGridAdjustment(doc, CX, 176,230,231,228,229,5,6, [183,185,187,189,191,193,195,197,199,201,203,205,207,209,211,213,215,217,219,221,223,225,227]); end; function ProcessForm1320Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; begin if Cmd > 0 then repeat case Cmd of //Sales Comparison Approach---------------------------------------------------------------- 43: Cmd := DivideABPercent(doc, mcx(cx,10), mcx(CX,9), mcx(CX,12)); 44: Cmd := DivideAB(doc, mcx(cx,10), mcx(CX,28), mcx(CX,15)); 45: Cmd := ProcessMultipleCmds(ProcessForm1320Math, doc, CX,[44,43,61]); 46: Cmd := DivideABPercent(doc, mcx(cx,50), mcx(CX,49), mcx(CX,52)); 47: Cmd := DivideAB(doc, mcx(cx,50), mcx(cx,80), mcx(cx,55)); //price/sqft 48: Cmd := ProcessMultipleCmds(ProcessForm1320Math, doc, CX,[47,46,49,62]); 49: Cmd := F1320SalesCompAppC1Adjustments(doc, cx); 51: Cmd := DivideABPercent(doc, mcx(cx,113), mcx(CX,112), mcx(CX,115)); 52: Cmd := DivideAB(doc, mcx(cx,113), mcx(cx,143), mcx(cx,118)); //price/sqft 53: Cmd := ProcessMultipleCmds(ProcessForm1320Math, doc, CX,[52,51,54,63]); 54: Cmd := F1320SalesCompAppC2Adjustments(doc, cx); 56: Cmd := DivideABPercent(doc, mcx(CX,176), mcx(CX,175), mcx(CX,178)); 57: Cmd := DivideAB(doc, mcx(cx,176), mcx(cx,206), mcx(cx,181)); //price/sqft 58: Cmd := ProcessMultipleCmds(ProcessForm1320Math, doc, CX,[57,56,59,64]); 59: Cmd := F1320SalesCompAppC3Adjustments(doc, cx); 61: Cmd := DivideABPercent(doc, mcx(cx,10), mcx(CX,8), mcx(CX,11)); 62: Cmd := DivideABPercent(doc, mcx(cx,50), mcx(CX,48), mcx(CX,51)); 63: Cmd := DivideABPercent(doc, mcx(cx,113), mcx(CX,111), mcx(CX,114)); 64: Cmd := DivideABPercent(doc, mcx(cx,176), mcx(CX,174), mcx(CX,177)); 60: Cmd := CalcWeightedAvg(doc, [939,1312,1320]); //calc wtAvg of main and xcomps forms 65: begin //Math ID 12 is for Weighted Average F1320SalesCompAppC1Adjustments(doc, cx); //sum of adjs F1320SalesCompAppC2Adjustments(doc, cx); //sum of adjs F1320SalesCompAppC3Adjustments(doc, cx); //sum of adjs Cmd := 0; end; else Cmd := 0; end; until Cmd = 0 else case Cmd of //special processing (negative cmds) UpdateNetGrossID: begin ProcessForm1320Math(doc, 1, CX); ProcessForm1320Math(doc, 2, CX); ProcessForm1320Math(doc, 3, CX); end; WeightedAvergeID: begin ProcessForm1320Math(doc, 65, CX); end; end; result := 0; end; function ProcessForm0939Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; begin if Cmd > 0 then repeat case Cmd of 1: Cmd := F0939SalesCompAppC1Adjustments(doc, cx); 2: Cmd := F0939SalesCompAppC2Adjustments(doc, cx); 3: Cmd := F0939SalesCompAppC3Adjustments(doc, cx); //dynamic form name 40: cmd := SetXXXPageTitleBarName(doc, cx, 'Extra Comps', 44,108,172); 41: cmd := SetXXXPageTitle(doc, cx, 'EXTRA COMPARABLES','', 44,108,172, 2); 42: cmd := ConfigXXXInstance(doc, cx, 44,108,172); //Sales Comparison Approach---------------------------------------------------------------- 43: Cmd := DivideABPercent(doc, mcx(cx,11), mcx(CX,10), mcx(CX,13)); 44: Cmd := DivideAB(doc, mcx(cx,11), mcx(CX,29), mcx(CX,16)); 45: Cmd := ProcessMultipleCmds(ProcessForm0939Math, doc, CX,[44,43,61]); 46: Cmd := DivideABPercent(doc, mcx(cx,52), mcx(CX,51), mcx(CX,54)); 47: Cmd := DivideAB(doc, mcx(cx,52), mcx(cx,82), mcx(cx,57)); //price/sqft 48: Cmd := ProcessMultipleCmds(ProcessForm0939Math, doc, CX,[47,46,49,62]); 49: Cmd := F0939SalesCompAppC1Adjustments(doc, cx); 51: Cmd := DivideABPercent(doc, mcx(cx,116), mcx(CX,115), mcx(CX,118)); 52: Cmd := DivideAB(doc, mcx(cx,116), mcx(cx,146), mcx(cx,121)); //price/sqft 53: Cmd := ProcessMultipleCmds(ProcessForm0939Math, doc, CX,[52,51,54,63]); 54: Cmd := F0939SalesCompAppC2Adjustments(doc, cx); 56: Cmd := DivideABPercent(doc, mcx(CX,180), mcx(CX,179), mcx(CX,182)); 57: Cmd := DivideAB(doc, mcx(cx,180), mcx(cx,210), mcx(cx,185)); //price/sqft 58: Cmd := ProcessMultipleCmds(ProcessForm0939Math, doc, CX,[57,56,59,64]); 59: Cmd := F0939SalesCompAppC3Adjustments(doc, cx); 61: Cmd := DivideABPercent(doc, mcx(cx,11), mcx(CX,9), mcx(CX,12)); 62: Cmd := DivideABPercent(doc, mcx(cx,52), mcx(CX,50), mcx(CX,53)); 63: Cmd := DivideABPercent(doc, mcx(cx,116), mcx(CX,114), mcx(CX,117)); 64: Cmd := DivideABPercent(doc, mcx(cx,180), mcx(CX,178), mcx(CX,181)); 60: Cmd := CalcWeightedAvg(doc, [939,1312,1320]); //calc wtAvg of main and xcomps forms 65: begin //Math ID 12 is for Weighted Average F0939SalesCompAppC1Adjustments(doc, cx); //sum of adjs F0939SalesCompAppC2Adjustments(doc, cx); //sum of adjs F0939SalesCompAppC3Adjustments(doc, cx); //sum of adjs Cmd := 0; end; else Cmd := 0; end; until Cmd = 0 else case Cmd of //special processing (negative cmds) UpdateNetGrossID: begin ProcessForm0939Math(doc, 1, CX); ProcessForm0939Math(doc, 2, CX); ProcessForm0939Math(doc, 3, CX); end; WeightedAvergeID: begin CX.pg := 0; ProcessForm0939Math(doc, 65, CX); end; end; result := 0; end; function ProcessForm0940Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; begin if Cmd > 0 then repeat case Cmd of //dynamic form name 1: cmd := SetXXXPageTitleBarName(doc, cx, 'Extra Rentals', 33,81,129); 2: cmd := SetXXXPageTitle(doc, cx, 'EXTRA RENTALS','', 33,81,129, 2); 3: cmd := ConfigXXXInstance(doc, cx, 33,81,129); //Income Approach ------------------------------------------------------------------------ 34: Cmd := F0940C1IncomeAdjs(doc, cx); 37: Cmd := F0940C2IncomeAdjs(doc, cx); 40: Cmd := F0940C3IncomeAdjs(doc, cx); 33: Cmd := SubtABCD(doc, mcx(cx,41), mcx(cx,43), mcx(cx,45), mcx(cx,47), mcx(CX,48)); 35: Cmd := F0940IncomeAppC1Adjustments(doc, cx); 36: Cmd := SubtABCD(doc, mcx(cx,89), mcx(cx,91), mcx(cx,93), mcx(cx,95), mcx(CX,96)); 38: Cmd := F0940IncomeAppC2Adjustments(doc, cx); 39: Cmd := SubtABCD(doc, mcx(cx,137), mcx(cx,139), mcx(cx,141), mcx(cx,143), mcx(CX,144)); 41: Cmd := F0940IncomeAppC3Adjustments(doc, cx); 42: Cmd := CalcWeightedAvg(doc, [940,1311,1319]); 65: begin //Math ID 65 is for Weighted Average F0940C1IncomeAdjs(doc, cx); //sum of adjs F0940C2IncomeAdjs(doc, cx); //sum of adjs F0940C3IncomeAdjs(doc, cx); //sum of adjs Cmd := 0; end; else Cmd := 0; end; until Cmd = 0 else case Cmd of //special processing (negative cmds) UpdateNetGrossID: begin ProcessForm0940Math(doc, 34, CX); ProcessForm0940Math(doc, 37, CX); ProcessForm0940Math(doc, 40, CX); end; WeightedAvergeID: begin ProcessForm0940Math(doc, 65, CX); end; end; result := 0; end; function ProcessForm0941Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; begin if Cmd > 0 then repeat case Cmd of 1: Cmd := F0941C1Adjustments(doc, cx); 2: Cmd := F0941C2Adjustments(doc, cx); 3: Cmd := F0941C3Adjustments(doc, cx); 4: Cmd := CalcWeightedAvg(doc, [941,1304,1309,1317]); //calc wtAvg of main and xcomps forms 5: Cmd := DivideAB(doc, mcx(cx,13), mcx(CX,18), mcx(CX,15)); 6: Cmd := DivideAB(doc, mcx(CX,37), mcx(CX,43), mcx(CX,38)); 7: Cmd := DivideAB(doc, mcx(cx,69), mcx(CX,75), mcx(CX,70)); 8: Cmd := DivideAB(doc, mcx(cx,101), mcx(CX,107), mcx(CX,102)); 9: Cmd := ProcessMultipleCmds(ProcessForm0941Math, doc, CX,[1,6]); 10: Cmd := ProcessMultipleCmds(ProcessForm0941Math, doc, CX,[2,7]); 11: Cmd := ProcessMultipleCmds(ProcessForm0941Math, doc, CX,[3,8]); //dynamic form name 13: cmd := SetXXXPageTitleBarName(doc, cx, 'Extra Sites', 31,63,95); 12: cmd := SetXXXPageTitle(doc, cx, 'EXTRA SITES','', 31,63,95, 2); 14: cmd := ConfigXXXInstance(doc, cx, 31,63,95); 15: begin //Math ID 15 is for Weighted Average F0941C1Adjustments(doc, cx); //sum of adjs F0941C2Adjustments(doc, cx); //sum of adjs F0941C3Adjustments(doc, cx); //sum of adjs Cmd := 0; end; else Cmd := 0; end; until Cmd = 0 else case Cmd of //special processing (negative cmds) UpdateNetGrossID: begin ProcessForm0941Math(doc, 1, CX); ProcessForm0941Math(doc, 2, CX); ProcessForm0941Math(doc, 3, CX); end; WeightedAvergeID: begin ProcessForm0941Math(doc, 15, CX); end; end; result := 0; end; function F0921C1Adjustments(doc: TContainer; CX: CellUID): Integer; begin result := SalesGridAdjustment(doc, CX, 50,104,105,102,103,3,4, [57,59,61,63,65,67,69,71,73,75,77,79,81,83,85,87,89,91,93,95,97,99,101]); end; function F0921C2Adjustments(doc: TContainer; CX: CellUID): Integer; begin result := SalesGridAdjustment(doc, CX, 113,167,168,165,166,5,6, [120,122,124,126,128,130,132,134,136,138,140,142,144,146,148,150,152,154,156,158,160,162,164]); end; function F0921C3Adjustments(doc: TContainer; CX: CellUID): Integer; begin result := SalesGridAdjustment(doc, CX, 176,230,231,228,229,7,8, [183,185,187,189,191,193,195,197,199,201,203,205,207,209,211,213,215,217,219,221,223,225,227]); end; function ProcessForm0921Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; begin if Cmd > 0 then repeat case Cmd of 43: begin DivideABPercent(doc, mcx(cx,10), mcx(CX,8), mcx(CX,11)); Cmd := DivideABPercent(doc, mcx(cx,10), mcx(CX,9), mcx(CX,12)); end; 44: Cmd := DivideAB(doc, mcx(cx,10), mcx(CX,28), mcx(CX,15)); 45: Cmd := ProcessMultipleCmds(ProcessForm0921Math, doc, CX,[44,43]); 46: begin DivideABPercent(doc, mcx(cx,50), mcx(CX,48), mcx(CX,51)); Cmd := DivideABPercent(doc, mcx(cx,50), mcx(CX,49), mcx(CX,52)); end; 47: Cmd := DivideAB(doc, mcx(CX,50), mcx(CX,80), mcx(CX,55)); 48: Cmd := ProcessMultipleCmds(ProcessForm0921Math, doc, CX,[47,46,49]); 49: Cmd := F0921C1Adjustments(doc, cx); 51: begin DivideABPercent(doc, mcx(cx,113), mcx(CX,111), mcx(CX,114)); Cmd := DivideABPercent(doc, mcx(cx,113), mcx(CX,112), mcx(CX,115)); end; 52: Cmd := DivideAB(doc, mcx(CX,113), mcx(CX,143), mcx(CX,118)); 53: Cmd := ProcessMultipleCmds(ProcessForm0921Math, doc, CX,[52,51,54]); 54: Cmd := F0921C2Adjustments(doc, cx); 56: begin DivideABPercent(doc, mcx(CX,176), mcx(CX,174), mcx(CX,177)); Cmd := DivideABPercent(doc, mcx(CX,176), mcx(CX,175), mcx(CX,178)); end; 57: Cmd := DivideAB(doc, mcx(CX,176), mcx(CX,206), mcx(CX,181)); 58: Cmd := ProcessMultipleCmds(ProcessForm0921Math, doc, CX,[57,56,59]); 59: Cmd := F0921C3Adjustments(doc, cx); //calc wtAvg of main and xcomps forms 60: Cmd := CalcWeightedAvg(doc, [378,391,921]); //calc wtAvg of main and xcomps forms 61: begin //Math ID 61 is for Weighted Average F0921C1Adjustments(doc, cx); //sum of adjs F0921C2Adjustments(doc, cx); //sum of adjs F0921C3Adjustments(doc, cx); //sum of adjs Cmd := 0; end; else Cmd := 0; end; until Cmd = 0 else case Cmd of //special processing (negative cmds) UpdateNetGrossID: begin ProcessForm0921Math(doc, 49, CX); ProcessForm0921Math(doc, 54, CX); ProcessForm0921Math(doc, 59, CX); end; WeightedAvergeID: begin CX.pg := 1; ProcessForm0921Math(doc, 61, CX); end; end; result := 0; end; function LoadComment_AP(aMemberID: Integer; doc: TContainer; frm: TDocForm; cx:CellUID; CANCellNo:Integer): Integer; const AI_CertForm_ID = 1326; //Appraiser Section math id ap_SRA = 1; ap_MAI = 2; ap_SRPA = 3; ap_GRS = 4; ap_RRS = 5; ap_CAN = 6; ap_PRAC = 7; Can_CertComment = 'completed the Standards and Ethics Education Requirements for Candidates of the Appraisal Institute.'; Prac_CertComment = 'completed the continuing education program for Practicing Affiliates of the Appraisal Institute.'; Des_CertComment = 'completed the continuing education program for Designated Members of the Appraisal Institute.'; var CertComment: String; DesYesNo, aYesNo, cYesNo, pYesNo: String; i, APCellNo: Integer; begin result := 0; APCellNo := 10; //cell seqno of check box for first Destination check box for i:= 0 to 4 do begin DesYesNo := trim(GetCellString(doc, mcx(cx, APCellNo+i))); if DesYesNo = 'X' then break; //if any of the 5 check box is checked end; cYesNo := trim(GetCellString(doc, mcx(cx,CANCellNo))); pYesNo := trim(GetCellString(doc, mcx(cx,CANCellNo+1))); if not assigned(frm) then exit; if frm.frmInfo.fFormUID <> AI_CertForm_ID then exit; //we do this for form #1325 AI cert form only case aMemberID of ap_SRA..ap_RRS: begin aYesNo := trim(GetCellString(doc, mcx(cx, cx.Num+1))); //check for the check box checked if aYesNo = 'X' then //if any of the 1-5 checkbox checked, use Designation comment CertComment := Des_CertComment else //when all 1-5 unchecked, only set if can or prac checked begin CertComment := ''; if trim(GetCellString(doc, mcx(cx, CANCellNo))) = 'X' then CertComment := Can_CertCOmment else if trim(GetCellString(doc, mcx(cx, CANCellNo+1)))= 'X' then CertComment := Prac_CertComment; end; end; ap_CAN: //if candidate check box checked, only set the comment if none of the 1-5 check box checked begin cYesNo := trim(GetCellString(doc, mcx(cx, cx.Num+1))); if (cYesNo = 'X') and (DesYesNo = '') then CertComment := Can_CertComment else CertComment := trim(frm.GetCellText(2, 18)); //load the existing comment end; ap_PRAC: //if practice check box checked, only set the comment if none of the 1-5 check box is checked begin pYesNo := trim(GetCellString(doc, mcx(cx, cx.Num+1))); if (pYesNo = 'X') and (DesYesNo = '') then CertComment := Prac_CertComment else CertComment := trim(frm.GetCellText(2, 18)); //load the existing comment end; end; if (DesYesNo='') and (cYesNo='') and (pYesNo='') then frm.SetCellText(2, 18, '') else frm.SetCellText(2, 18, CertComment); end; function LoadComment_CP(aMemberID: Integer; doc: TContainer; frm: TDocForm; cx:CellUID; CANCellNo:Integer): Integer; const AI_CertForm_ID = 1326; //Co-Appriaser Section math id cp_SRA = 8; cp_MAI = 9; cp_SRPA = 10; cp_GRS = 11; cp_RRS = 12; cp_CAN = 13; cp_PRAC = 14; Can_CertComment = 'completed the Standards and Ethics Education Requirements for Candidates of the Appraisal Institute.'; Prac_CertComment = 'completed the continuing education program for Practicing Affiliates of the Appraisal Institute.'; Des_CertComment = 'completed the continuing education program for Designated Members of the Appraisal Institute.'; var CertComment: String; DesYesNo, aYesNo, cYesNo, pYesNo: String; i, CPCellNo: Integer; begin result := 0; CPCellNo := 20; //cell seqno of check box for first Destination check box for i:= 0 to 4 do begin DesYesNo := trim(GetCellString(doc, mcx(cx, CPCellNo+i))); if DesYesNo = 'X' then break; //if any of the 5 check box is checked end; cYesNo := trim(GetCellString(doc, mcx(cx,CANCellNo))); pYesNo := trim(GetCellString(doc, mcx(cx,CANCellNo+1))); if not assigned(frm) then exit; if frm.frmInfo.fFormUID <> AI_CertForm_ID then exit; //we do this for form #1325 AI cert form only case aMemberID of cp_SRA..cp_RRS: begin aYesNo := trim(GetCellString(doc, mcx(cx, cx.Num+1))); //check for the check box checked if aYesNo = 'X' then //if any of the 1-5 checkbox checked, use Designation comment CertComment := Des_CertComment else //when all 1-5 unchecked, only set if can or prac checked begin CertComment := ''; if trim(GetCellString(doc, mcx(cx, CANCellNo))) = 'X' then CertComment := Can_CertCOmment else if trim(GetCellString(doc, mcx(cx, CANCellNo+1)))= 'X' then CertComment := Prac_CertComment; end; end; cp_CAN: //if candidate check box checked, only set the comment if none of the 1-5 check box checked begin cYesNo := trim(GetCellString(doc, mcx(cx, cx.Num+1))); if (cYesNo = 'X') and (DesYesNo = '') then CertComment := Can_CertComment else CertComment := trim(frm.GetCellText(2, 30)); //load the existing comment end; cp_PRAC: //if practice check box checked, only set the comment if none of the 1-5 check box is checked begin pYesNo := trim(GetCellString(doc, mcx(cx, cx.Num+1))); if (pYesNo = 'X') and (DesYesNo = '') then CertComment := Prac_CertComment else CertComment := trim(frm.GetCellText(2, 30)); //load the existing comment end; end; if (DesYesNo='') and (cYesNo='') and (pYesNo='') then frm.SetCellText(2, 30, '') else frm.SetCellText(2, 30, CertComment); end; function ProcessForm1321Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; const AI_CertForm_ID = 1326; //Appraiser Section math id ap_SRA = 1; ap_MAI = 2; ap_SRPA = 3; ap_GRS = 4; ap_RRS = 5; ap_CAN = 6; ap_PRAC = 7; //Co-Appriaser Section math id cp_SRA = 8; cp_MAI = 9; cp_SRPA = 10; cp_GRS = 11; cp_RRS = 12; cp_CAN = 13; cp_PRAC = 14; ap_CandidateCellNo = 15; cp_CandidateCellNo = 25; var frm: TDocForm; begin if Cmd > 0 then begin frm := doc.GetFormByOccurance(AI_CertForm_ID, 0, True); //occur is zero based if assigned(frm) then begin repeat case Cmd of //Math id 1-7 is for Appraiser section, Math id 8-14 is for Co-Appraiser section 1..7: Cmd := LoadComment_AP(Cmd,doc, frm, cx, ap_CandidateCellNo); 8..14: Cmd := LoadComment_CP(Cmd,doc, frm, cx, cp_CandidateCellNo); else Cmd := 0; end; until Cmd = 0; end; end; result := 0; end; function ProcessForm1322Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; const AI_CertForm_ID = 1326; //Appraiser Section math id ap_SRA = 1; ap_MAI = 2; ap_SRPA = 3; ap_GRS = 4; ap_RRS = 5; ap_CAN = 6; ap_PRAC = 7; //Co-Appriaser Section math id cp_SRA = 8; cp_MAI = 9; cp_SRPA = 10; cp_GRS = 11; cp_RRS = 12; cp_CAN = 13; cp_PRAC = 14; ap_CandidateCellNo = 15; cp_CandidateCellNo = 25; var frm: TDocForm; begin if Cmd > 0 then begin frm := doc.GetFormByOccurance(AI_CertForm_ID, 0, True); //occur is zero based if assigned(frm) then begin repeat case Cmd of //Math id 1-7 is for Appraiser section, Math id 8-14 is for Co-Appraiser section 1..7: Cmd := LoadComment_AP(Cmd,doc, frm, cx, ap_CandidateCellNo); 8..14: Cmd := LoadComment_CP(Cmd,doc, frm, cx, cp_CandidateCellNo); else Cmd := 0; end; until Cmd = 0; end; end; result := 0; end; function ProcessForm1325Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; const AI_CertForm_ID = 1326; //Appraiser Section math id ap_SRA = 1; ap_MAI = 2; ap_SRPA = 3; ap_GRS = 4; ap_RRS = 5; ap_CAN = 6; ap_PRAC = 7; //Co-Appriaser Section math id cp_SRA = 8; cp_MAI = 9; cp_SRPA = 10; cp_GRS = 11; cp_RRS = 12; cp_CAN = 13; cp_PRAC = 14; ap_CandidateCellNo = 15; cp_CandidateCellNo = 25; var frm: TDocForm; begin if Cmd > 0 then begin frm := doc.GetFormByOccurance(AI_CertForm_ID, 0, True); //occur is zero based if assigned(frm) then begin repeat case Cmd of //Math id 1-7 is for Appraiser section, Math id 8-14 is for Co-Appraiser section 1..7: Cmd := LoadComment_AP(Cmd,doc, frm, cx, ap_CandidateCellNo); 8..14: Cmd := LoadComment_CP(Cmd,doc, frm, cx, cp_CandidateCellNo); else Cmd := 0; end; until Cmd = 0; end; end; result := 0; end; function F1328C1Adjustments(doc: TContainer; CX: CellUID) : Integer; const SalesAmt = 37; AcrePrice = 38; TotalAdj = 61; FinalAmt = 62; PlusChk = 59; NegChk = 60; InfoNet = 1; InfoGross = 2; var NetAdj,GrsAdj: Double; saleValue, NetPct, GrsPct: Double; begin NetAdj := 0; GrsAdj := 0; GetNetGrosAdjs(doc, mcx(cx,40), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,42), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,44), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,46), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,48), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,50), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,52), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,54), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,56), NetAdj, GrsAdj); GetNetGrosAdjs(doc, mcx(cx,58), NetAdj, GrsAdj); SetCellValue(doc, mcx(cx,TotalAdj), NetAdj); //set sum of Adj if (NetAdj>=0) then SetCellChkMark(doc, mcx(cx,PlusChk), True) //toggle the checkmarks else SetCellChkMark(doc, mcx(cx,NegChk), True); NetPct := 0; GrsPct := 0; if appPref_AppraiserUseLandPriceUnits then saleValue := GetCellValue(doc, mcx(cx,AcrePrice)) else saleValue := GetCellValue(doc, mcx(cx,salesAmt)); //calc the net/grs percents if saleValue <> 0 then begin NetPct := (NetAdj / saleValue) * 100; GrsPct := (GrsAdj / saleValue) * 100; SumOfWeightedValues := SumOfWeightedValues + (1-GrsPct/100) * (saleValue+ NetAdj); SumOfWeights := SumOfWeights + (1-GrsPct/100); end; SetInfoCellValue(doc, mcx(cx,infoNet), NetPct); SetInfoCellValue(doc, mcx(cx,infoGross), GrsPct); //set the info cells result := SetCellValue(doc, mcx(cx,FinalAmt), saleValue+ NetAdj); //set final adj price end; //New math for form 1328: AI Extra comp mimic from math 939 function ProcessForm1328Math(doc: TContainer; Cmd: Integer; CX: CellUID): Integer; begin if Cmd > 0 then repeat case Cmd of 1: Cmd := F1328SalesCompAppC1Adjustments(doc, cx); 2: Cmd := F1328SalesCompAppC2Adjustments(doc, cx); 3: Cmd := F1328SalesCompAppC3Adjustments(doc, cx); //dynamic form name 40: cmd := SetXXXPageTitleBarName(doc, cx, 'Extra Comps', 44,108,172); 41: cmd := SetXXXPageTitle(doc, cx, 'EXTRA COMPARABLES','', 44,108,172, 2); 42: cmd := ConfigXXXInstance(doc, cx, 44,108,172); //Sales Comparison Approach---------------------------------------------------------------- 43: Cmd := DivideABPercent(doc, mcx(cx,11), mcx(CX,10), mcx(CX,13)); 44: Cmd := DivideAB(doc, mcx(cx,11), mcx(CX,29), mcx(CX,16)); 45: Cmd := ProcessMultipleCmds(ProcessForm1328Math, doc, CX,[44,43,61]); 46: Cmd := DivideABPercent(doc, mcx(cx,52), mcx(CX,51), mcx(CX,54)); 47: Cmd := DivideAB(doc, mcx(cx,52), mcx(cx,82), mcx(cx,57)); //price/sqft 48: Cmd := ProcessMultipleCmds(ProcessForm1328Math, doc, CX,[47,46,49,62]); 49: Cmd := F1328SalesCompAppC1Adjustments(doc, cx); 51: Cmd := DivideABPercent(doc, mcx(cx,116), mcx(CX,115), mcx(CX,118)); 52: Cmd := DivideAB(doc, mcx(cx,116), mcx(cx,146), mcx(cx,121)); //price/sqft 53: Cmd := ProcessMultipleCmds(ProcessForm1328Math, doc, CX,[52,51,54,63]); 54: Cmd := F1328SalesCompAppC2Adjustments(doc, cx); 56: Cmd := DivideABPercent(doc, mcx(CX,180), mcx(CX,179), mcx(CX,182)); 57: Cmd := DivideAB(doc, mcx(cx,180), mcx(cx,210), mcx(cx,185)); //price/sqft 58: Cmd := ProcessMultipleCmds(ProcessForm1328Math, doc, CX,[57,56,59,64]); 59: Cmd := F1328SalesCompAppC3Adjustments(doc, cx); 61: Cmd := DivideABPercent(doc, mcx(cx,11), mcx(CX,9), mcx(CX,12)); 62: Cmd := DivideABPercent(doc, mcx(cx,52), mcx(CX,50), mcx(CX,53)); 63: Cmd := DivideABPercent(doc, mcx(cx,116), mcx(CX,114), mcx(CX,117)); 64: Cmd := DivideABPercent(doc, mcx(cx,180), mcx(CX,178), mcx(CX,181)); 60: Cmd := CalcWeightedAvg(doc, [1328,1312,1320]); //calc wtAvg of main and xcomps forms 65: begin //Math ID 12 is for Weighted Average F1328SalesCompAppC1Adjustments(doc, cx); //sum of adjs F1328SalesCompAppC2Adjustments(doc, cx); //sum of adjs F1328SalesCompAppC3Adjustments(doc, cx); //sum of adjs Cmd := 0; end; else Cmd := 0; end; until Cmd = 0 else case Cmd of //special processing (negative cmds) UpdateNetGrossID: begin ProcessForm1328Math(doc, 1, CX); ProcessForm1328Math(doc, 2, CX); ProcessForm1328Math(doc, 3, CX); end; WeightedAvergeID: begin CX.pg := 0; ProcessForm1328Math(doc, 65, CX); end; end; result := 0; end; end.
unit BuildScripts; interface uses DUtils, D3Vectors, Buildings, Solvation; var FactionType: array of TFactionType; Faction: array of TFaction; NeighborhoodType: array of TNeighborhoodType; Neighborhood: array of TNeighborhood; procedure LoadBuildScript; function BuildNeighborhoodFromType(NT: TNeighborhoodType): TNeighborhood; implementation uses Math, Randomity, SysUtils; var BuildLog: String; procedure Log(S: String); begin BuildLog := BuildLog + S + #13#10; end; type TParsedAction = record bAssignment: Boolean; LValue, RValue: String; SubScript: TStringArray; end; TParsedActionArray = array of TParsedAction; function DumpFileToStringArray(FN: String; bIncludeEmpties: Boolean = True): TStringArray; var Buf: String; I, J, oJ: Integer; begin Buf := DumpFileToString(FN) + #0; //Convert CRLFs, CRs, and LFs to NULs. Buf := StringReplace(Buf, #13#10, #0, [rfReplaceAll]); Buf := StringReplaceC(Buf, #13, #0); Buf := StringReplaceC(Buf, #10, #0); J := 0; for I := 1 to Length(Buf) do if Buf[I] = #0 then Inc(J); SetLength(Result, J); I := 0; oJ := 1; for J := 1 to Length(Buf) do if Buf[J] = #0 then begin if (J > oJ) or bIncludeEmpties then begin Result[I] := Copy(Buf, oJ, J - oJ); Inc(I); end; oJ := J + 1; end; SetLength(Result, I); //We injected a line-end at the end, so there's no trailing line to deal with. Buf := ''; end; function GetTabLevel(S: String): Integer; var I: Integer; begin for I := 1 to Length(S) do if S[I] <> #9 then begin Result := I - 1; Exit; end ; Result := Length(S); end; function ExtractContinue(var S: String): Boolean; begin Result := S[Length(S)] = ':'; if Result then SetLength(S, Length(S)-1); end; procedure AddStr(var A: TStringArray; S: String); var I: Integer; begin I := Length(A); SetLength(A, I + 1); A[I] := S; end; function GetSubScript(FromScript: TStringArray; var NextIndex: Integer; ParentTabLevel: Integer; ParentType, ParentNom: String): TStringArray; var Lin2, Lin2A: String; I: Integer; begin SetLength(Result, 0); while (NextIndex < Length(FromScript)) and (GetTabLevel(FromScript[NextIndex]) > ParentTabLevel) do begin AddStr(Result, FromScript[NextIndex]); Inc(NextIndex); end; if NextIndex < Length(FromScript) then begin Lin2 := FromScript[NextIndex]; if GetTabLevel(Lin2) = ParentTabLevel then begin Lin2 := Trim(Lin2); I := Pos(' ', Lin2); if I = 0 then begin Lin2A := ''; end else begin Lin2A := UpperCase(Trim(Copy(Lin2, I + 1, MAXINT))); Lin2 := UpperCase(Trim(Copy(Lin2, 1, I - 1))); end; if Lin2 = 'END' then begin Inc(NextIndex); if (Length(Lin2A) <> 0) and (Lin2A <> ParentType) then Log('Build script warning: end specifier "' + Lin2A + '" did not match "' + ParentType + '" on ' + ParentNom + '.') ; end; end; end; end; function ParseScript(Script: TStringArray): TParsedActionArray; var I, LI, NextLI: Integer; ThisTabLevel: Integer; Lin: String; bContinues: Boolean; begin SetLength(Result, 0); LI := 0; while LI <= High(Script) do begin NextLI := LI + 1; Lin := Script[LI]; ThisTabLevel := GetTabLevel(Lin); Lin := Trim(Lin); bContinues := ExtractContinue(Lin); I := Length(Result); SetLength(Result, I+1); with Result[I] do begin I := Pos('=', Lin); bAssignment := I <> 0; if bAssignment then begin LValue := UpperCase(Trim(Copy(Lin, 1, I - 1))); RValue := Trim(Copy(Lin, I + 1, MAXINT)); if bContinues then SubScript := GetSubScript(Script, NextLI, ThisTabLevel, LValue, RValue) else SetLength(SubScript, 0) ; end else begin LValue := Lin; RValue := ''; end; end; LI := NextLI; end; end; function FTFromScript(ScriptLin: TStringArray; NewNom: String): TFactionType; var PAI: Integer; ParsedAction: TParsedActionArray; begin Result := TFactionType.Create; Result.Nom := NewNom; ParsedAction := ParseScript(ScriptLin); for PAI := 0 to High(ParsedAction) do with ParsedAction[PAI] do begin if bAssignment then begin Log('Build script warning: unrecognized assignment "' + LValue + ' = ' + RValue + '" in FactionType ' + Result.Nom + '.'); end else begin //Directive. Log('Build script warning: unrecognized directive "' + LValue + '" in FactionType ' + Result.Nom + '.'); end; end; end; function FFromScript(ScriptLin: TStringArray; NewNom: String): TFaction; var I, PAI: Integer; ParsedAction: TParsedActionArray; UT: String; begin Result := TFaction.Create; Result.Nom := NewNom; ParsedAction := ParseScript(ScriptLin); for PAI := 0 to High(ParsedAction) do with ParsedAction[PAI] do begin if bAssignment then begin if LValue = 'TYPE' then begin Result.FactionType := nil; //Needs a for/else; use of a sentinel is a hack. UT := UpperCase(RValue); for I := 0 to High(FactionType) do if UpperCase(FactionType[I].Nom) = UT then begin Result.FactionType := FactionType[I]; Break; end ; if Result.FactionType = nil then Log('Build script warning: unrecognized faction type "' + RValue + '" in Faction ' + Result.Nom + '.') ; end else begin Log('Build script warning: unrecognized assignment "' + LValue + ' = ' + RValue + '" in Faction ' + Result.Nom + '.'); end; end else begin //Directive. Log('Build script warning: unrecognized directive "' + LValue + '" in Faction ' + Result.Nom + '.'); end; end; end; function BTFromScript(ScriptLin: TStringArray; NewNom: String): TBuildingType; var PAI: Integer; ParsedAction: TParsedActionArray; ActivityMain, ActivitySub, UT: String; GI, I: Integer; GearToken: TStringArray; begin Result := TBuildingType.Create; Result.Nom := NewNom; Result.Common := 1; Result.PriceFactor := 1; Result.bSINlessOK := RandBit; Result.BuildFunc := GenericBuilding; ParsedAction := ParseScript(ScriptLin); for PAI := 0 to High(ParsedAction) do with ParsedAction[PAI] do begin if bAssignment then begin if LValue = 'COMMON' then try Result.Common := Round(Solve(RValue)); except Log('Build script warning: invalid Common "' + RValue + '" in BuildingType ' + Result.Nom + '.'); end else if LValue = 'PRICEFACTOR' then try Result.PriceFactor := Solve(RValue); except Log('Build script warning: invalid PriceFactor "' + RValue + '" in BuildingType ' + Result.Nom + '.'); end else if LValue = 'SINLESSOK' then begin if UpperCase(RValue) = 'TRUE' then Result.bSINlessOK := True else if UpperCase(RValue) = 'FALSE' then Result.bSINlessOK := False else Log('Build script warning: invalid SINlessOK "' + RValue + '" in BuildingType ' + Result.Nom + '.') ; end else if LValue = 'FUNC' then begin if UpperCase(RValue) = 'CUBISTTUMORBUILDING' then Result.BuildFunc := CubistTumorBuilding else if UpperCase(RValue) = 'GENSKYSCRAPERBUILDING' then Result.BuildFunc := GenSkyscraperBuilding else if UpperCase(RValue) = 'GENERICBUILDING' then Result.BuildFunc := GenericBuilding else if UpperCase(RValue) = 'PARKINGBUILDING' then Result.BuildFunc := ParkingBuilding else if UpperCase(RValue) = 'SMALLPARKBUILDING' then Result.BuildFunc := SmallParkBuilding else Log('Build script warning: invalid Func "' + RValue + '" in BuildingType ' + Result.Nom + '.') ; end else if LValue = 'FACTIONBASE' then begin Result.FactionBase := nil; //Needs a for/else; use of a sentinel is a hack. UT := UpperCase(RValue); for I := 0 to High(FactionType) do if UpperCase(FactionType[I].Nom) = UT then begin Result.FactionBase := FactionType[I]; Break; end ; if Result.FactionBase = nil then Log('Build script warning: unrecognized FactionBase "' + RValue + '" in BuildingType ' + Result.Nom + '.') ; end else if LValue = 'FACTIONLINK' then begin Result.FactionLink := nil; //Needs a for/else; use of a sentinel is a hack. UT := UpperCase(RValue); for I := 0 to High(Faction) do if UpperCase(Faction[I].Nom) = UT then begin Result.FactionLink := Faction[I]; Break; end ; if Result.FactionLink = nil then Log('Build script warning: unrecognized FactionLink "' + RValue + '" in BuildingType ' + Result.Nom + '.') ; end else if LValue = 'ACTIVITY' then begin if Length(RValue) = 0 then begin Result.Activity := acNone; Result.ShopGear := []; end else begin I := Pos('(', RValue); if (I <> 0) and (RValue[Length(RValue)] = ')') then begin ActivityMain := UpperCase(Trim(Copy(RValue, 1, I - 1))); ActivitySub := Trim(Copy(RValue, I + 1, Length(RValue) - I - 1)); end else begin ActivityMain := UpperCase(RValue); ActivitySub := ''; end; if ActivityMain = 'SLEEP' then begin Result.Activity := acSleep; Result.ShopGear := []; end else if ActivityMain = 'HEAL' then begin Result.Activity := acHeal; Result.ShopGear := []; end else if ActivityMain = 'SHOP' then begin Result.Activity := acShop; Result.ShopGear := []; GearToken := StrTokenize(ActivitySub, ','); for GI := 0 to High(GearToken) do begin ActivitySub := Trim(GearToken[GI]); if UpperCase(ActivitySub) = 'WEAPON' then Include(Result.ShopGear, gtWeapon) else if UpperCase(ActivitySub) = 'VEHICLE' then Include(Result.ShopGear, gtVehicle) else Log('Build script warning: invalid shop gear token "' + ActivitySub + '"(in Activity "' + RValue + '") in BuildingType ' + Result.Nom + '.') ; end; end else Log('Build script warning: invalid Activity "' + RValue + '" in BuildingType ' + Result.Nom + '.') ; end; end else begin Log('Build script warning: unrecognized assignment "' + LValue + ' = ' + RValue + '" in BuildingType ' + Result.Nom + '.'); end; end else begin //Directive. Log('Build script warning: unrecognized directive "' + LValue + '" in BuildingType ' + Result.Nom + '.'); end; end; end; function NTFromScript(ScriptLin: TStringArray; NewNom: String): TNeighborhoodType; var I, PAI: Integer; ParsedAction: TParsedActionArray; NewBuildingType: TBuildingType; begin Result := TNeighborhoodType.Create; Result.Nom := NewNom; Result.BasePropertyValue := 128; ParsedAction := ParseScript(ScriptLin); for PAI := 0 to High(ParsedAction) do with ParsedAction[PAI] do begin if bAssignment then begin if LValue = 'BLOCKMERGESTART' then try Result.BlockMergeStart := Solve(RValue); except Log('Build script warning: invalid BlockMergeStart "' + RValue + '" in NeighborhoodType ' + Result.Nom + '.'); end else if LValue = 'BLOCKMERGESUSTAIN' then try Result.BlockMergeSustain := Solve(RValue); except Log('Build script warning: invalid BlockMergeSustain "' + RValue + '" in NeighborhoodType ' + Result.Nom + '.'); end else if LValue = 'BASEPROPERTYVALUE' then try Result.BasePropertyValue := Solve(RValue); except Log('Build script warning: invalid BasePropertyValue "' + RValue + '" in NeighborhoodType ' + Result.Nom + '.'); end else if LValue = 'PROPERTYCENTERBOOST' then try Result.PropertyCenterBoost := Solve(RValue); except Log('Build script warning: invalid PropertyCenterBoost "' + RValue + '" in NeighborhoodType ' + Result.Nom + '.'); end else if LValue = 'BUILDINGTYPE' then begin NewBuildingType := BTFromScript(SubScript, RValue); I := Length(Result.BuildingType); SetLength(Result.BuildingType, I+1); Result.BuildingType[I] := NewBuildingType; Inc(Result.TotCommon, NewBuildingType.Common); end else begin Log('Build script warning: unrecognized assignment "' + LValue + ' = ' + RValue + '" in NeighborhoodType ' + Result.Nom + '.'); end; end else begin //Directive. Log('Build script warning: unrecognized directive "' + LValue + '" in NeighborhoodType ' + Result.Nom + '.'); end; end; end; procedure LoadBuildScript; var I, PAI: Integer; ParsedAction: TParsedActionArray; NewFactionType: TFactionType; NewFaction: TFaction; NewNeighborhoodType: TNeighborhoodType; begin ParsedAction := ParseScript(DumpFileToStringArray('Build.cfs', False)); for PAI := 0 to High(ParsedAction) do with ParsedAction[PAI] do begin if bAssignment then begin if LValue = 'FACTIONTYPE' then begin NewFactionType := FTFromScript(SubScript, RValue); I := Length(FactionType); SetLength(FactionType, I+1); FactionType[I] := NewFactionType; end else if LValue = 'FACTION' then begin NewFaction := FFromScript(SubScript, RValue); I := Length(Faction); SetLength(Faction, I+1); Faction[I] := NewFaction; end else if LValue = 'NEIGHBORHOODTYPE' then begin NewNeighborhoodType := NTFromScript(SubScript, RValue); I := Length(NeighborhoodType); SetLength(NeighborhoodType, I+1); NeighborhoodType[I] := NewNeighborhoodType; end else begin Log('Build script warning: unrecognized assignment "' + LValue + ' = ' + RValue + '".'); end; end else begin //Directive. Log('Build script warning: unrecognized directive "' + LValue + '".'); end; end; DumpStringToFile(BuildLog, 'BuildLoad.log'); BuildLog := ''; end; function BuildNeighborhoodFromType(NT: TNeighborhoodType): TNeighborhood; const ValuePivot = 10; //Half the max coordinate in a single direction. var I, C, D, iX, iZ: Integer; begin Result := TNeighborhood.Create; Result.NeighborhoodType := NT; for iX := Low(Result.CityBlock) to High(Result.CityBlock) do for iZ := Low(Result.CityBlock[iX]) to High(Result.CityBlock[iX]) do with Result.CityBlock[iX, iZ] do begin D := Max(Abs(iX), Abs(iZ)); //Manhattan distance from center. PropertyValue := Round( NT.BasePropertyValue + NT.PropertyCenterBoost*(ValuePivot - D) ); BuildingType := nil; //Needs a for/else; use of a sentinel is a hack. C := RandN(NT.TotCommon); for I := 0 to High(NT.BuildingType) do begin Dec(C, NT.BuildingType[I].Common); if C < 0 then begin BuildingType := NT.BuildingType[I]; Break; end; end; if BuildingType = nil then begin Log('Build warning: dropped off end of Building Type array in Neighborhood Type "' + NT.Nom + '". TotCommon > sum of Common? Picking one at random.'); BuildingType := NT.BuildingType[RandN(Length(NT.BuildingType))]; end; LinkedFaction := BuildingType.FactionLink; if BuildingType.FactionBase <> nil then begin LinkedFaction := TFaction.Create; with LinkedFaction do begin FactionType := BuildingType.FactionBase; Inc(FactionType.AutoIndex); Nom := FactionType.Nom + ' ' + IntToStr(FactionType.AutoIndex); //Log('Build debug: created faction "' + Nom + '".'); end; I := Length(Faction); SetLength(Faction, I + 1); Faction[I] := LinkedFaction; end; Building := BuildingType.BuildFunc(Result.CityBlock[iX, iZ]); OffsetBuilding(Building, Vector(26*iX, 0, 26*iZ)); end ; DumpStringToFile(BuildLog, 'BuildEx.log'); BuildLog := ''; end; end.
(*:Helper routines for Lischke's Virtual Treeview. @author Primoz Gabrijelcic @desc <pre> (c) 2023 Primoz Gabrijelcic Free for personal and commercial use. No rights reserved. Author : Primoz Gabrijelcic Creation date : 2002-09-18 Last modification : 2023-04-04 Version : 1.09 </pre>*)(* History: 1.09: 2023-04-04 - Implemented VTTotalColumnWidth. 1.08: 2022-05-12 - Implemented VTWidestVisibleColumn. 1.07: 2017-03-20 - Implemented VTGetNodeDataInt64 and VTSetNodeDataInt64. 1.06: 2015-09-17 - Added VTGetTopParent. - Added VTFilter. 1.05: 2008-02-29 - Added helpers to store/restore header layout: VTGetHeaderAsString, VTSetHeaderFromString. 1.04a: 2007-05-17 - Removed two warnings introduced in 1.04. 1.04: 2007-02-20 - Added capability to access more than just first 4 bytes of the node data to VT(Get|Set)NodeData[Int] procedures. 1.03: 2005-11-22 - Added method VTResort. 1.02: 2005-10-07 - Added function VTHighestVisibleColumn. 1.01: 2005-09-30 - Declared cxDateTime and GpTime editors. 1.0a: 2005-03-25 - Fixed accvio in VTGetNodeData. 1.0: 2002-09-18 - Created & released. *) unit GpVirtualTree; interface uses VirtualTrees, VirtualTrees.Types; type TFilterProc = reference to procedure (node: PVirtualNode; var isVisible: boolean); procedure VTFilter(vt: TVirtualStringTree; filter: TFilterProc); procedure VTFindAndSelect(vt: TVirtualStringTree; nodeText: string; columnIndex: integer = -1; forceSelect: boolean = true); function VTFindNode(vt: TVirtualStringTree; nodeText: string; columnIndex: integer = -1): PVirtualNode; function VTGetHeaderAsString(header: TVTHeader): string; function VTGetNodeData(vt: TBaseVirtualTree; node: PVirtualNode = nil; ptrOffset: integer = 0): pointer; function VTGetNodeDataInt(vt: TBaseVirtualTree; node: PVirtualNode = nil; ptrOffset: integer = 0): integer; function VTGetNodeDataInt64(vt: TBaseVirtualTree; node: PVirtualNode = nil): integer; function VTGetText(vt: TVirtualStringTree; node: PVirtualNode = nil; columnIndex: integer = -1): string; function VTGetTopParent(vt: TVirtualStringTree; node: PVirtualNode = nil): PVirtualNode; function VTHighestVisibleColumn(vt: TBaseVirtualTree): integer; procedure VTResort(vt: TVirtualStringTree); procedure VTSelectNode(vt: TBaseVirtualTree; node: PVirtualNode); procedure VTSetCheck(vt: TBaseVirtualTree; node: PVirtualNode; checkif, uncheckif: boolean); procedure VTSetHeaderFromString(header: TVTHeader; const value: string); procedure VTSetNodeData(vt: TBaseVirtualTree; value: pointer; node: PVirtualNode = nil; ptrOffset: integer = 0); procedure VTSetNodeDataInt(vt: TBaseVirtualTree; value: integer; node: PVirtualNode = nil; ptrOffset: integer = 0); procedure VTSetNodeDataInt64(vt: TBaseVirtualTree; value: integer; node: PVirtualNode = nil); function VTTotalColumnWidth(vt: TBaseVirtualTree): integer; function VTWidestVisibleColumn(vt: TBaseVirtualTree): integer; implementation uses Windows, SysUtils, Classes, OmniXMLUtils, GpStuff, GpStreams; type TVirtualTreeFriend = class(TBaseVirtualTree) end; { globals } procedure VTFilter(vt: TVirtualStringTree; filter: TFilterProc); var isVisible: boolean; node : PVirtualNode; begin vt.BeginUpdate; try node := vt.GetFirst; while assigned(node) do begin filter(node, isVisible); vt.IsFiltered[node] := not isVisible; node := vt.GetNext(node); end; finally vt.EndUpdate; end; end; { VTFilter } {:Find the node with a specified caption, then focus and select it. Assumes that virtual treeview doesn't use columns. If node is not found, either unselects and unfocuses all nodes (if 'forceSelect' is False) or selects and focuses first node (if 'forceSelect' is True) @since 2002-09-18 } procedure VTFindAndSelect(vt: TVirtualStringTree; nodeText: string; columnIndex: integer; forceSelect: boolean); var node: PVirtualNode; begin if (columnIndex < 0) and (vt.Header.Columns.Count > 0) then columnIndex := 0; node := VTFindNode(vt, nodeText, columnIndex); if (not assigned(node)) and forceSelect then node := vt.GetFirst; VTSelectNode(vt, node); end; { VTFindAndSelect } {:Find the node with a specified caption. Assumes that virtual treeview doesn't use columns. @since 2002-09-18 } function VTFindNode(vt: TVirtualStringTree; nodeText: string; columnIndex: integer): PVirtualNode; begin if nodeText = '' then Result := nil else begin if (columnIndex < 0) and (vt.Header.Columns.Count > 0) then columnIndex := 0; Result := vt.GetFirst; while assigned(Result) do begin if AnsiSameText(vt.Text[Result,columnIndex], nodeText) then Exit; Result := vt.GetNext(Result); end; //while end; end; { VTFindNode } {:Return node data as a pointer. If 'node' parameter is not specified, return data for the focused node. @since 2002-09-18 } function VTGetNodeData(vt: TBaseVirtualTree; node: PVirtualNode; ptrOffset: integer): pointer; begin Result := nil; if not assigned(node) then node := vt.FocusedNode; if assigned(node) then Result := pointer(pointer(int64(vt.GetNodeData(node)) + ptrOffset * SizeOf(pointer))^); end; { VTGetNodeData } {:Returns node data as an integer. If 'node' parameter is not specified, returns data for the focused node. @since 2002-09-18 } function VTGetNodeDataInt(vt: TBaseVirtualTree; node: PVirtualNode; ptrOffset: integer): integer; begin Result := integer(VTGetNodeData(vt, node, ptrOffset)); end; { VTGetNodeDataInt } {:Returns node data as an integer. If 'node' parameter is not specified, returns data for the focused node. } function VTGetNodeDataInt64(vt: TBaseVirtualTree; node: PVirtualNode): integer; begin Result := 0; if not assigned(node) then node := vt.FocusedNode; if assigned(node) then Result := PInt64(vt.GetNodeData(node))^; end; { VTGetNodeDataInt } {:Returns caption of the specified node. If node is not specified, focus node is used. @since 2002-09-18 } function VTGetText(vt: TVirtualStringTree; node: PVirtualNode; columnIndex: integer): string; begin if not assigned(node) then node := vt.FocusedNode; if (columnIndex < 0) and (vt.Header.Columns.Count > 0) then columnIndex := 0; if assigned(node) then Result := vt.Text[node, columnIndex] else Result := ''; end; { VTGetText } {:Returns index of rightmost visible column. @since 2005-10-07 } function VTHighestVisibleColumn(vt: TBaseVirtualTree): integer; var column : TVirtualTreeColumn; highestVisible: cardinal; iHeaderCol : integer; begin Result := -1; highestVisible := 0; for iHeaderCol := 0 to TVirtualTreeFriend(vt).Header.Columns.Count-1 do begin column := TVirtualTreeFriend(vt).Header.Columns[iHeaderCol]; if coVisible in Column.Options then if column.Position > highestVisible then begin highestVisible := column.Position; Result := iHeaderCol; end; end; end; { VTHighestVisibleColumn } function VTTotalColumnWidth(vt: TBaseVirtualTree): integer; var column : TVirtualTreeColumn; iHeaderCol: integer; begin Result := 0; for iHeaderCol := 0 to TVirtualTreeFriend(vt).Header.Columns.Count-1 do begin column := TVirtualTreeFriend(vt).Header.Columns[iHeaderCol]; if coVisible in Column.Options then Inc(Result, column.Width); end; end; { VTTotalColumnWidth } function VTWidestVisibleColumn(vt: TBaseVirtualTree): integer; var column : TVirtualTreeColumn; iHeaderCol: integer; maxWidth : integer; begin Result := -1; maxWidth := 0; for iHeaderCol := 0 to TVirtualTreeFriend(vt).Header.Columns.Count-1 do begin column := TVirtualTreeFriend(vt).Header.Columns[iHeaderCol]; if coVisible in Column.Options then if column.Width > maxWidth then begin maxWidth := column.Width; Result := iHeaderCol; end; end; end; { VTWidestVisibleColumn } {:Resorts the tree using the current settings. @since 2005-11-22 } procedure VTResort(vt: TVirtualStringTree); begin vt.SortTree(vt.Header.SortColumn, vt.Header.SortDirection); end; { VTResort } {:Selects and focuses specified node. @since 2002-09-18 } procedure VTSelectNode(vt: TBaseVirtualTree; node: PVirtualNode); begin vt.ClearSelection; if assigned(node) then vt.Selected[node] := true; vt.FocusedNode := node; end; { VTSelectNode } {:Sets check state of the specified node. @since 2002-09-18 } procedure VTSetCheck(vt: TBaseVirtualTree; node: PVirtualNode; checkif, uncheckif: boolean); begin if checkif then vt.CheckState[node] := csCheckedNormal else if uncheckif then vt.CheckState[node] := csUncheckedNormal else vt.CheckState[node] := csMixedNormal; end; { VTSetCheck } {:Set node data as a pointer. If 'node' parameter is not specified, set data for the focused node. @since 2002-09-18 } procedure VTSetNodeData(vt: TBaseVirtualTree; value: pointer; node: PVirtualNode; ptrOffset: integer); begin if not assigned(node) then node := vt.FocusedNode; pointer(pointer(int64(vt.GetNodeData(node)) + ptrOffset * SizeOf(pointer))^) := value; end; { VTSetNodeData } {:Set node data as an integer. If 'node' parameter is not specified, set data for the focused node. @since 2002-09-18 } procedure VTSetNodeDataInt(vt: TBaseVirtualTree; value: integer; node: PVirtualNode; ptrOffset: integer); begin VTSetNodeData(vt, pointer(value), node, ptrOffset); end; { VTSetNodeDataInt } procedure VTSetNodeDataInt64(vt: TBaseVirtualTree; value: integer; node: PVirtualNode); begin if not assigned(node) then node := vt.FocusedNode; PInt64(vt.GetNodeData(node))^ := value; end; { VTSetNodeDataInt64 } function VTGetHeaderAsString(header: TVTHeader): string; var buf: IGpBuffer; begin buf := TGpBuffer.Create; header.SaveToStream(buf.AsStream); buf.AsStream.GoToStart; Result := Base64Encode(buf.AsStream); end; { VTGetHeaderAsString } procedure VTSetHeaderFromString(header: TVTHeader; const value: string); var buf: IGpBuffer; begin buf := TGpBuffer.Create(Base64Decode(value)); buf.AsStream.GoToStart; try header.LoadFromStream(buf.AsStream); except header.RestoreColumns; end; end; { VTSetHeaderFromString } function VTGetTopParent(vt: TVirtualStringTree; node: PVirtualNode = nil): PVirtualNode; begin if not assigned(node) then node := vt.FocusedNode; if not assigned(node) then Exit(nil); while vt.NodeParent[node] <> nil do node := vt.NodeParent[node]; Result := node; end; { VTGetTopParent } end.
{*****************************************************************************} { BindAPI } { Copyright (C) 2020 Paolo Morandotti } { Unit Test.Controller } {*****************************************************************************} { } {Permission is hereby granted, free of charge, to any person obtaining } {a copy of this software and associated documentation files (the "Software"), } {to deal in the Software without restriction, including without limitation } {the rights to use, copy, modify, merge, publish, distribute, sublicense, } {and/or sell copies of the Software, and to permit persons to whom the } {Software is furnished to do so, subject to the following conditions: } { } {The above copyright notice and this permission notice shall be included in } {all copies or substantial portions of the Software. } { } {THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS } {OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, } {FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE } {AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER } {LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING } {FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS } {IN THE SOFTWARE. } {*****************************************************************************} unit Test.Controller; interface uses System.Classes, System.RTTI, plBindAPI.ClassFactory; type TFieldObject = class private FInt: Integer; FStr: string; public property IntProp: Integer read FInt write FInt; property StrProp: string read FStr write FStr; end; TTestController = class(TInterfacedObject) function DoubleOf(const NewValue, OldValue: TValue): TValue; procedure TestEventBind(Sender: TObject); private FCurrentText: string; FDoubleValue: integer; FLowerText: string; FNewValue: integer; FTestObject: TFieldObject; FUpperText: string; procedure SetCurrentText(const Value: string); public constructor Create; destructor Destroy; override; property CurrentText: string read FCurrentText write SetCurrentText; property UpperText: string read FUpperText write FUpperText; property LowerText: string read FLowerText write FLowerText; property NewValue: integer read FNewValue write FNewValue; property DoubleValue: integer read FDoubleValue write FDoubleValue; property TestObject: TFieldObject read FTestObject write FTestObject; end; TTestSecond = class(TInterfacedObject) private FStrBidirectional: string; public property StrBidirectional: string read FStrBidirectional write FStrBidirectional; end; implementation uses System.SysUtils, Vcl.Dialogs; { TTestController } constructor TTestController.Create; begin inherited; FTestObject := TFieldObject.Create; end; destructor TTestController.Destroy; begin TestObject.Free; inherited; end; function TTestController.DoubleOf(const NewValue, OldValue: TValue): TValue; begin Result := NewValue.AsInteger * 2; end; procedure TTestController.SetCurrentText(const Value: string); begin FCurrentText := Value; FLowerText := AnsiLowerCase(Value); FUpperText := AnsiUpperCase(Value); end; procedure TTestController.TestEventBind(Sender: TObject); begin FLowerText := ''; FUpperText := ''; ShowMessage('Done.'); end; initialization TplClassManager.RegisterClass(TTestController, true); TplClassManager.RegisterClass(TTestSecond, true); end.
PROGRAM LISTA_DUPLAMENTE_ENCADEADA; USES CRT; TYPE AP_NO = ^NO; NO = RECORD DADO : STRING; {dado da lista} ESQ : AP_NO; {aponta para o elemento da esquerda} DIR : AP_NO; {aponta para o elemento da direita} END; AP_DESCRITOR = ^DESCRITOR; DESCRITOR = RECORD I,F : AP_NO;{Aponta para o incio-I e fim-F da lista} N : INTEGER; { numero de elementos na lista} X : AP_DESCRITOR; END; VAR LISTA,P : Ap_No; D : Ap_DEscritor; VALOR : string; VAZIO : BOOLEAN; TECLA : char; CONT : INTEGER; { Cria o descritor lista zerando o descritor e seus apontadores } procedure criar (var d : AP_descritor); begin new(d); d^.i :=nil; d^.n :=0; d^.f :=nil; end; { insere um elemento a esquerda da lista } procedure insere_esq (VAR d:ap_descritor; VAR valor:string); var P, Q : ap_no; begin new(p); p^.dado:=valor; P^.ESQ := NIL; if d^.n=0 then begin d^.i :=p; {lista vazia} d^.f :=p; d^.n :=1; p^.DIR := nil; end else begin Q := D^.I; Q^.ESQ := P; p^.DIR:= Q; {lista cheia} d^.i:=p; d^.n:=d^.n+1; end; end; { insere um elemento a direita da lista } procedure insere_dir (VAR d:ap_descritor; VAR valor:string); var p,q: ap_no; begin new(p); p^.dado:=valor; p^.DIR:=nil; if d^.n=0 then begin d^.i:=p; {lista vazia} d^.f:=p; d^.n:=1; P^.ESQ := NIL; end else begin Q := D^.F; {lista cheia} D^.F := P; Q^.DIR := P; P^.ESQ := Q; D^.N := D^.N+1; end; end; {insere no meio sendo que se o meio e impar coloca a esquerda } {se tem 3 elementos, sera inserido na segundao posicao e seguintes} {movidos para frente} {tendo assim 4 elementos} procedure insere_meio (VAR d:ap_descritor; VAR valor:string); var p,q,atual : ap_no; x, cont : integer; begin new(p); p^.dado:=valor; if d^.n=0 then begin d^.i:=p; {lista vazia} d^.f:=p; d^.n:=1; P^.ESQ := NIL; p^.DIR:=nil; end else if d^.n=1 then begin p^.DIR:=nil; Q := D^.F; {lista com um elemento} D^.F := P; Q^.DIR := P; P^.ESQ := Q; D^.N := D^.N+1; end else begin x := (d^.n div 2); {acha o meio} atual := d^.i; cont := 1; while cont <> x do begin atual := atual^.dir; cont := cont + 1; end; q := atual^.dir; p^.dir := q; p^.esq := atual; {faz a inclusao} atual^.dir := p; q^.esq := p; D^.N := D^.N+1; end; end; { remove um elemento da esquerda da lista } procedure remove_esq (VAR d:ap_descritor;VAR valor:string); var P,Q : ap_no; begin if d^.n=0 then {testa se esta vazia} begin VAZIO := TRUE; WRITELN; writeln('lista esta vazia'); TECLA := READKEY; end else begin {lista nao vazia, remove} P := D^.I; VALOR := P^.DADO; D^.I := p^.DIR; Q := D^.I; Q^.ESQ := NIL; D^.N := D^.N-1; dispose(p); if d^.n=0 then {testa se a lista ficou vazia} begin d^.f:=nil; end; end; end; { remove um elemento da esquerda da lista } procedure remove_dir (VAR d:ap_descritor; VAR valor:string); var p,q : ap_no; begin if d^.n=0 then begin VAZIO := TRUE; WRITELN; writeln('lista esta vazia'); TECLA := READKEY; end else BEGIN P := D^.F; VALOR := P^.DADO; if d^.n = 1 then begin VALOR := P^.DADO; d^.i := nil; d^.f := nil; d^.n := 0; end else begin Q := P^.ESQ; Q^.DIR := P^.DIR; D^.F := Q; D^.N := D^.N -1; end; DISPOSE(P); END; end; (************ PROGRAMA PRINCIPAL ****************) begin clrscr; criar( d ); repeat VAZIO := FALSE; write ('1 - Insere direita '); write ('2 - Insere esquerda '); writeln('3 - Remove esquerda '); write ('4 - Remove direita '); write ('5 - Insere no meio '); writeln('ESC - Sai para S.O. '); writeln; write('Qual a opcao (1-2-3-4-5) => '); tecla := readkey; case (tecla) of '1' : begin write('digite o valor :'); readln(valor); insere_dir ( d ,valor); end; '2' : BEGIN write('digite o valor :'); readln(valor); insere_esq ( d ,valor); END; '3' : BEGIN remove_esq ( d ,valor); IF VAZIO <> TRUE THEN WRITELN('VALOR REMOVIDO DA ESQUERDA ',VALOR); END; '4' : BEGIN remove_dir ( d ,valor); IF VAZIO <> TRUE THEN WRITELN('VALOR REMOVIDO DA DIREITA ',VALOR); END; '5' : BEGIN write('digite o valor :'); readln(valor); insere_meio ( d ,valor); END; end; writeln('VALOR DO DESCRITOR ',d^.n); IF (VAZIO <> TRUE) AND (D^.N <> 0) THEN BEGIN P := D^.I; CONT := 1; WRITELN; WHILE (P^.DIR <> NIL) DO BEGIN WRITE(' ELE [',CONT,']= ',P^.DADO); P := P^.DIR; CONT := CONT + 1; END; WRITE(' ELE [',CONT,']= ',P^.DADO); END; TECLA := READKEY; WRITELN; until tecla = #27; end.
unit frmAlert; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, System.Generics.Collections, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.StdCtrls; type TAlertManager = class; /// <summary> /// Окно уведомления /// </summary> TAlertForm = class(TForm) LiveTimer: TTimer; Image: TImage; lTitle: TLabel; lMsg: TLabel; procedure LiveTimerTimer(Sender: TObject); procedure FormDestroy(Sender: TObject); strict private FOwner: TAlertManager; private procedure SetMessage(const Value: string); procedure SetTitle(const Value: string); function GetMessage: string; function GetTitle: string; procedure SetIcon(const Value: HICON); public /// <summary> /// Конструктор окна /// </summary> /// <param name="AOwner"> /// Менеджер уведомлений /// </param> /// <param name="ATitle"> /// Заголовок уведомления /// </param> /// <param name="AMsg"> /// Текст уведомления /// </param> /// <param name="AInterval"> /// Время жизни уведомления /// </param> constructor Create(AOwner: TAlertManager; const ATitle: string = ''; const AMsg: string = ''; const AInterval: Int64 = 10000); reintroduce; /// <summary> /// Заголовок уведомления /// </summary> property Title: string read GetTitle write SetTitle; /// <summary> /// Текст уведомления /// </summary> property Msg: string read GetMessage write SetMessage; /// <summary> /// Дескриптор иконки в окне уведомления /// </summary> property Icon: HICON write SetIcon; end; /// <summary> /// Менеджер уведомлений /// </summary> TAlertManager = class strict private FAlerts: TList<HWND>; private procedure UpdateAlertPos; protected procedure UnregisterAlert(const hAlert: THandle); public constructor Create; destructor Destroy; override; /// <summary> /// Метод создает и регистрирует уведомление /// </summary> /// <param name="ATitle"> /// Заголовок уведомления /// </param> /// <param name="AMsg"> /// Текст уведомления /// </param> /// <param name="AIcon"> /// Дескриптор иконки в окне уведомления /// </param> procedure RegisterAlert(const ATitle, AMsg: string; const AIcon: HICON); end; implementation {$R *.dfm} { TAlertForm } constructor TAlertForm.Create(AOwner: TAlertManager; const ATitle, AMsg: string; const AInterval: Int64); begin inherited Create(Application); FOwner := AOwner; LiveTimer.Interval := AInterval; LiveTimer.Enabled := True; self.Title := ATitle; self.Msg := AMsg; end; procedure TAlertForm.FormDestroy(Sender: TObject); begin if Assigned(FOwner) then FOwner.UnregisterAlert(self.Handle); end; function TAlertForm.GetMessage: string; begin Result := lMsg.Caption; end; function TAlertForm.GetTitle: string; begin Result := lTitle.Caption; end; procedure TAlertForm.LiveTimerTimer(Sender: TObject); begin LiveTimer.Enabled := False; while self.AlphaBlendValue > 0 do begin self.AlphaBlendValue := self.AlphaBlendValue - 5; Sleep(5); Application.ProcessMessages; end; self.Destroy; end; procedure TAlertForm.SetIcon(const Value: HICON); begin Image.Picture.Icon.Handle := Value; end; procedure TAlertForm.SetMessage(const Value: string); begin lMsg.Caption := Value; end; procedure TAlertForm.SetTitle(const Value: string); begin lTitle.Caption := Value; end; { TAlertManager } constructor TAlertManager.Create; begin inherited Create; FAlerts := TList<HWND>.Create; end; destructor TAlertManager.Destroy; begin FreeAndNil(FAlerts); inherited Destroy; end; procedure TAlertManager.RegisterAlert(const ATitle, AMsg: string; const AIcon: HICON); var Alert: TAlertForm; begin Alert := TAlertForm.Create(self, ATitle, AMsg); Alert.Icon := AIcon; FAlerts.Add(Alert.Handle); UpdateAlertPos; end; procedure TAlertManager.UnregisterAlert(const hAlert: THandle); begin if FAlerts.Contains(hAlert) then begin FAlerts.Extract(hAlert); UpdateAlertPos; end; end; procedure TAlertManager.UpdateAlertPos; var x, y, cx, cy: Integer; hAlert: HWND; Rect: TRect; begin x := Screen.WorkAreaWidth; y := Screen.WorkAreaHeight; for hAlert in FAlerts do begin if GetWindowRect(hAlert, Rect) then begin cx := Rect.Width; cy := Rect.Height; Dec(y, Rect.Height + 2); SetWindowPos(hAlert, HWND_TOPMOST, x - Rect.Width - 10, y, cx, cy, SWP_SHOWWINDOW + SWP_NOACTIVATE); end; end; end; end.
unit DasmDefs; (* The generic disassembler basic definitions module of the DCU32INT utility by Alexei Hmelnov. ---------------------------------------------------------------------------- E-Mail: alex@icc.ru http://hmelnov.icc.ru/DCU/ ---------------------------------------------------------------------------- See the file "readme.txt" for more details. ------------------------------------------------------------------------ IMPORTANT NOTE: This software is provided 'as-is', without any expressed or implied warranty. In no event will the author 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. 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. *) interface const nf = $40000000; nm = nf-1; hEA = $7FFFFFFF; type THBMName = integer; { Debug info for register usage: } type TRegVarInfoProc = function(ProcOfs: integer; hReg: THBMName; Ofs,Size: integer; var hDecl: integer): AnsiString of object; const GetRegVarInfo: TRegVarInfoProc = Nil; const crJmp=0; crJCond=1; crCall=2; type TReadCommandProc = function: boolean; TShowCommandProc = procedure; TRegCommandRefProc = procedure(RefP: LongInt; RefKind: Byte; IP: Pointer); TCheckCommandRefsProc = function (RegRef: TRegCommandRefProc; CmdOfs: Cardinal; IP: Pointer): integer{crX}; TDisassembler = record ReadCommand: TReadCommandProc; ShowCommand: TShowCommandProc; CheckCommandRefs: TCheckCommandRefsProc; end ; type TIncPtr = PAnsiChar; var CodePtr, PrevCodePtr: TIncPtr; var Disassembler: TDisassembler; procedure SetDisassembler(AReadCommand: TReadCommandProc; AShowCommand: TShowCommandProc; ACheckCommandRefs: TCheckCommandRefsProc); implementation procedure SetDisassembler(AReadCommand: TReadCommandProc; AShowCommand: TShowCommandProc; ACheckCommandRefs: TCheckCommandRefsProc); begin Disassembler.ReadCommand := AReadCommand; Disassembler.ShowCommand := AShowCommand; Disassembler.CheckCommandRefs := ACheckCommandRefs; end ; end.
// ========================================================================== // // Copyright(c) 2012-2014 Embarcadero Technologies, Inc. // // ========================================================================== // // Delphi-C++ Library Bridge // Interface for library FlatBox2D // unit Box2D.Dynamics; interface uses Box2D.Collision, Box2D.Common, Box2DTypes; const b2_minPulleyLength = 2.000000; type {$MinEnumSize 4} b2BodyType = (b2_staticBody = 0, b2_kinematicBody = 1, b2_dynamicBody = 2); {$MinEnumSize 1} Pb2BodyType = ^b2BodyType; {$MinEnumSize 4} b2JointType = (e_unknownJoint = 0, e_revoluteJoint = 1, e_prismaticJoint = 2, e_distanceJoint = 3, e_pulleyJoint = 4, e_mouseJoint = 5, e_gearJoint = 6, e_wheelJoint = 7, e_weldJoint = 8, e_frictionJoint = 9, e_ropeJoint = 10, e_motorJoint = 11); {$MinEnumSize 1} Pb2JointType = ^b2JointType; {$MinEnumSize 4} b2LimitState = (e_inactiveLimit = 0, e_atLowerLimit = 1, e_atUpperLimit = 2, e_equalLimits = 3); {$MinEnumSize 1} Pb2LimitState = ^b2LimitState; b2JointHandle = THandle; Pb2JointHandle = ^b2JointHandle; b2ContactHandle = THandle; Pb2ContactHandle = ^b2ContactHandle; b2WorldHandle = THandle; Pb2WorldHandle = ^b2WorldHandle; b2BodyHandle = THandle; Pb2BodyHandle = ^b2BodyHandle; b2ContactFilterHandle = THandle; Pb2ContactFilterHandle = ^b2ContactFilterHandle; b2ContactListenerHandle = THandle; Pb2ContactListenerHandle = ^b2ContactListenerHandle; b2ContactManagerHandle = THandle; Pb2ContactManagerHandle = ^b2ContactManagerHandle; b2IslandHandle = THandle; Pb2IslandHandle = ^b2IslandHandle; b2DestructionListenerHandle = THandle; Pb2DestructionListenerHandle = ^b2DestructionListenerHandle; b2QueryCallbackHandle = THandle; Pb2QueryCallbackHandle = ^b2QueryCallbackHandle; b2RayCastCallbackHandle = THandle; Pb2RayCastCallbackHandle = ^b2RayCastCallbackHandle; b2ChainAndCircleContactHandle = THandle; Pb2ChainAndCircleContactHandle = ^b2ChainAndCircleContactHandle; b2ChainAndPolygonContactHandle = THandle; Pb2ChainAndPolygonContactHandle = ^b2ChainAndPolygonContactHandle; b2CircleContactHandle = THandle; Pb2CircleContactHandle = ^b2CircleContactHandle; b2ContactSolverHandle = THandle; Pb2ContactSolverHandle = ^b2ContactSolverHandle; b2EdgeAndCircleContactHandle = THandle; Pb2EdgeAndCircleContactHandle = ^b2EdgeAndCircleContactHandle; b2EdgeAndPolygonContactHandle = THandle; Pb2EdgeAndPolygonContactHandle = ^b2EdgeAndPolygonContactHandle; b2PolygonAndCircleContactHandle = THandle; Pb2PolygonAndCircleContactHandle = ^b2PolygonAndCircleContactHandle; b2PolygonContactHandle = THandle; Pb2PolygonContactHandle = ^b2PolygonContactHandle; b2DistanceJointHandle = THandle; Pb2DistanceJointHandle = ^b2DistanceJointHandle; b2FrictionJointHandle = THandle; Pb2FrictionJointHandle = ^b2FrictionJointHandle; b2GearJointHandle = THandle; Pb2GearJointHandle = ^b2GearJointHandle; b2MotorJointHandle = THandle; Pb2MotorJointHandle = ^b2MotorJointHandle; b2MouseJointHandle = THandle; Pb2MouseJointHandle = ^b2MouseJointHandle; b2PrismaticJointHandle = THandle; Pb2PrismaticJointHandle = ^b2PrismaticJointHandle; b2PulleyJointHandle = THandle; Pb2PulleyJointHandle = ^b2PulleyJointHandle; b2RevoluteJointHandle = THandle; Pb2RevoluteJointHandle = ^b2RevoluteJointHandle; b2RopeJointHandle = THandle; Pb2RopeJointHandle = ^b2RopeJointHandle; b2WeldJointHandle = THandle; Pb2WeldJointHandle = ^b2WeldJointHandle; b2WheelJointHandle = THandle; Pb2WheelJointHandle = ^b2WheelJointHandle; Pb2Fixture = ^b2Fixture; PPb2Fixture = ^Pb2Fixture; Pb2FixtureDef = ^b2FixtureDef; PPb2FixtureDef = ^Pb2FixtureDef; Pb2JointEdge = ^b2JointEdge; PPb2JointEdge = ^Pb2JointEdge; Pb2ContactEdge = ^b2ContactEdge; PPb2ContactEdge = ^Pb2ContactEdge; Pb2BodyDef = ^b2BodyDef; PPb2BodyDef = ^Pb2BodyDef; Pb2Filter = ^b2Filter; PPb2Filter = ^Pb2Filter; Pb2FixtureProxy = ^b2FixtureProxy; PPb2FixtureProxy = ^Pb2FixtureProxy; Pb2Profile = ^b2Profile; PPb2Profile = ^Pb2Profile; Pb2TimeStep = ^b2TimeStep; PPb2TimeStep = ^Pb2TimeStep; Pb2Position = ^b2Position; PPb2Position = ^Pb2Position; Pb2Velocity = ^b2Velocity; PPb2Velocity = ^Pb2Velocity; Pb2SolverData = ^b2SolverData; PPb2SolverData = ^Pb2SolverData; Pb2ContactVelocityConstraint = ^b2ContactVelocityConstraint; PPb2ContactVelocityConstraint = ^Pb2ContactVelocityConstraint; Pb2ContactImpulse = ^b2ContactImpulse; PPb2ContactImpulse = ^Pb2ContactImpulse; Pb2JointDef = ^b2JointDef; PPb2JointDef = ^Pb2JointDef; b2ContactCreateFcn = function(param1: Pb2Fixture; param2: Integer; param3: Pb2Fixture; param4: Integer; param5: b2BlockAllocatorHandle): b2ContactHandle; stdcall; b2ContactDestroyFcn = procedure(param1: b2ContactHandle; param2: b2BlockAllocatorHandle); stdcall; Pb2ContactRegister = ^b2ContactRegister; PPb2ContactRegister = ^Pb2ContactRegister; Pb2VelocityConstraintPoint = ^b2VelocityConstraintPoint; PPb2VelocityConstraintPoint = ^Pb2VelocityConstraintPoint; Pb2ContactSolverDef = ^b2ContactSolverDef; PPb2ContactSolverDef = ^Pb2ContactSolverDef; Pb2Jacobian = ^b2Jacobian; PPb2Jacobian = ^Pb2Jacobian; Pb2DistanceJointDef = ^b2DistanceJointDef; PPb2DistanceJointDef = ^Pb2DistanceJointDef; Pb2FrictionJointDef = ^b2FrictionJointDef; PPb2FrictionJointDef = ^Pb2FrictionJointDef; Pb2GearJointDef = ^b2GearJointDef; PPb2GearJointDef = ^Pb2GearJointDef; Pb2MotorJointDef = ^b2MotorJointDef; PPb2MotorJointDef = ^Pb2MotorJointDef; Pb2MouseJointDef = ^b2MouseJointDef; PPb2MouseJointDef = ^Pb2MouseJointDef; Pb2PrismaticJointDef = ^b2PrismaticJointDef; PPb2PrismaticJointDef = ^Pb2PrismaticJointDef; Pb2PulleyJointDef = ^b2PulleyJointDef; PPb2PulleyJointDef = ^Pb2PulleyJointDef; Pb2RevoluteJointDef = ^b2RevoluteJointDef; PPb2RevoluteJointDef = ^Pb2RevoluteJointDef; Pb2RopeJointDef = ^b2RopeJointDef; PPb2RopeJointDef = ^Pb2RopeJointDef; Pb2WeldJointDef = ^b2WeldJointDef; PPb2WeldJointDef = ^Pb2WeldJointDef; Pb2WheelJointDef = ^b2WheelJointDef; PPb2WheelJointDef = ^Pb2WheelJointDef; { ===== Records ===== } { A body definition holds all the data needed to construct a rigid body. You can safely re-use body definitions. Shapes are added to a body after construction.} b2BodyDef = record &type: b2BodyType; { The body type: static, kinematic, or dynamic. Note: if a dynamic body would have zero mass, the mass is set to one.} position: b2Vec2; { The world position of the body. Avoid creating bodies at the origin since this can lead to many overlapping shapes.} angle: Single; { The world angle of the body in radians.} linearVelocity: b2Vec2; { The linear velocity of the body's origin in world co-ordinates.} angularVelocity: Single; { The angular velocity of the body.} linearDamping: Single; { Linear damping is use to reduce the linear velocity. The damping parameter can be larger than 1.0f but the damping effect becomes sensitive to the time step when the damping parameter is large.} angularDamping: Single; { Angular damping is use to reduce the angular velocity. The damping parameter can be larger than 1.0f but the damping effect becomes sensitive to the time step when the damping parameter is large.} allowSleep: Boolean; { Set this flag to false if this body should never fall asleep. Note that this increases CPU usage.} awake: Boolean; { Is this body initially awake or sleeping?} fixedRotation: Boolean; { Should this body be prevented from rotating? Useful for characters.} bullet: Boolean; { Is this a fast moving body that should be prevented from tunneling through other moving bodies? Note that all bodies are prevented from tunneling through kinematic and static bodies. This setting is only considered on dynamic bodies. @warning You should use this flag sparingly since it increases processing time.} active: Boolean; { Does this body start out active?} userData: Pointer; { Use this to store application specific body data.} gravityScale: Single; { Scale the gravity applied to this body.} class function Create: b2BodyDef; static; cdecl; end; { A rigid body. These are created via b2World::CreateBody.} b2BodyWrapper = record FHandle: b2BodyHandle; class operator Implicit(handle: b2BodyHandle): b2BodyWrapper; overload; class operator Implicit(wrapper: b2BodyWrapper): b2BodyHandle; overload; { Creates a fixture and attach it to this body. Use this function if you need to set some fixture parameters, like friction. Otherwise you can create the fixture directly from a shape. If the density is non-zero, this function automatically updates the mass of the body. Contacts are not created until the next time step. @param def the fixture definition. @warning This function is locked during callbacks.} function CreateFixture(def: Pb2FixtureDef): Pb2Fixture; overload; cdecl; { Creates a fixture from a shape and attach it to this body. This is a convenience function. Use b2FixtureDef if you need to set parameters like friction, restitution, user data, or filtering. If the density is non-zero, this function automatically updates the mass of the body. @param shape the shape to be cloned. @param density the shape density (set to zero for static bodies). @warning This function is locked during callbacks.} function CreateFixture(shape: b2ShapeHandle; density: Single): Pb2Fixture; overload; cdecl; { Destroy a fixture. This removes the fixture from the broad-phase and destroys all contacts associated with this fixture. This will automatically adjust the mass of the body if the body is dynamic and the fixture has positive density. All fixtures attached to a body are implicitly destroyed when the body is destroyed. @param fixture the fixture to be removed. @warning This function is locked during callbacks.} procedure DestroyFixture(fixture: Pb2Fixture); cdecl; { Set the position of the body's origin and rotation. Manipulating a body's transform may cause non-physical behavior. Note: contacts are updated on the next call to b2World::Step. @param position the world position of the body's local origin. @param angle the world rotation in radians.} procedure SetTransform(const [ref] position: b2Vec2; angle: Single); cdecl; { Get the body transform for the body's origin. @return the world transform of the body's origin.} function GetTransform: Pb2Transform; cdecl; { Get the world body origin position. @return the world position of the body's origin.} function GetPosition: Pb2Vec2; cdecl; { Get the angle in radians. @return the current world rotation angle in radians.} function GetAngle: Single; cdecl; { Get the world position of the center of mass.} function GetWorldCenter: Pb2Vec2; cdecl; { Get the local position of the center of mass.} function GetLocalCenter: Pb2Vec2; cdecl; { Set the linear velocity of the center of mass. @param v the new linear velocity of the center of mass.} procedure SetLinearVelocity(const [ref] v: b2Vec2); cdecl; { Get the linear velocity of the center of mass. @return the linear velocity of the center of mass.} function GetLinearVelocity: Pb2Vec2; cdecl; { Set the angular velocity. @param omega the new angular velocity in radians/second.} procedure SetAngularVelocity(omega: Single); cdecl; { Get the angular velocity. @return the angular velocity in radians/second.} function GetAngularVelocity: Single; cdecl; { Apply a force at a world point. If the force is not applied at the center of mass, it will generate a torque and affect the angular velocity. This wakes up the body. @param force the world force vector, usually in Newtons (N). @param point the world position of the point of application. @param wake also wake up the body} procedure ApplyForce(const [ref] force: b2Vec2; const [ref] point: b2Vec2; wake: Boolean); cdecl; { Apply a force to the center of mass. This wakes up the body. @param force the world force vector, usually in Newtons (N). @param wake also wake up the body} procedure ApplyForceToCenter(const [ref] force: b2Vec2; wake: Boolean); cdecl; { Apply a torque. This affects the angular velocity without affecting the linear velocity of the center of mass. This wakes up the body. @param torque about the z-axis (out of the screen), usually in N-m. @param wake also wake up the body} procedure ApplyTorque(torque: Single; wake: Boolean); cdecl; { Apply an impulse at a point. This immediately modifies the velocity. It also modifies the angular velocity if the point of application is not at the center of mass. This wakes up the body. @param impulse the world impulse vector, usually in N-seconds or kg-m/s. @param point the world position of the point of application. @param wake also wake up the body} procedure ApplyLinearImpulse(const [ref] impulse: b2Vec2; const [ref] point: b2Vec2; wake: Boolean); cdecl; { Apply an angular impulse. @param impulse the angular impulse in units of kg*m*m/s @param wake also wake up the body} procedure ApplyAngularImpulse(impulse: Single; wake: Boolean); cdecl; { Get the total mass of the body. @return the mass, usually in kilograms (kg).} function GetMass: Single; cdecl; { Get the rotational inertia of the body about the local origin. @return the rotational inertia, usually in kg-m^2.} function GetInertia: Single; cdecl; { Get the mass data of the body. @return a struct containing the mass, inertia and center of the body.} procedure GetMassData(data: Pb2MassData); cdecl; { Set the mass properties to override the mass properties of the fixtures. Note that this changes the center of mass position. Note that creating or destroying fixtures can also alter the mass. This function has no effect if the body isn't dynamic. @param massData the mass properties.} procedure SetMassData(data: Pb2MassData); cdecl; { This resets the mass properties to the sum of the mass properties of the fixtures. This normally does not need to be called unless you called SetMassData to override the mass and you later want to reset the mass.} procedure ResetMassData; cdecl; { Get the world coordinates of a point given the local coordinates. @param localPoint a point on the body measured relative the the body's origin. @return the same point expressed in world coordinates.} function GetWorldPoint(const [ref] localPoint: b2Vec2): b2Vec2; cdecl; { Get the world coordinates of a vector given the local coordinates. @param localVector a vector fixed in the body. @return the same vector expressed in world coordinates.} function GetWorldVector(const [ref] localVector: b2Vec2): b2Vec2; cdecl; { Gets a local point relative to the body's origin given a world point. @param a point in world coordinates. @return the corresponding local point relative to the body's origin.} function GetLocalPoint(const [ref] worldPoint: b2Vec2): b2Vec2; cdecl; { Gets a local vector given a world vector. @param a vector in world coordinates. @return the corresponding local vector.} function GetLocalVector(const [ref] worldVector: b2Vec2): b2Vec2; cdecl; { Get the world linear velocity of a world point attached to this body. @param a point in world coordinates. @return the world velocity of a point.} function GetLinearVelocityFromWorldPoint(const [ref] worldPoint: b2Vec2): b2Vec2; cdecl; { Get the world velocity of a local point. @param a point in local coordinates. @return the world velocity of a point.} function GetLinearVelocityFromLocalPoint(const [ref] localPoint: b2Vec2): b2Vec2; cdecl; { Get the linear damping of the body.} function GetLinearDamping: Single; cdecl; { Set the linear damping of the body.} procedure SetLinearDamping(linearDamping: Single); cdecl; { Get the angular damping of the body.} function GetAngularDamping: Single; cdecl; { Set the angular damping of the body.} procedure SetAngularDamping(angularDamping: Single); cdecl; { Get the gravity scale of the body.} function GetGravityScale: Single; cdecl; { Set the gravity scale of the body.} procedure SetGravityScale(scale: Single); cdecl; { Set the type of this body. This may alter the mass and velocity.} procedure SetType(_type: b2BodyType); cdecl; { Get the type of this body.} function GetType: b2BodyType; cdecl; { Should this body be treated like a bullet for continuous collision detection?} procedure SetBullet(flag: Boolean); cdecl; { Is this body treated like a bullet for continuous collision detection?} function IsBullet: Boolean; cdecl; { You can disable sleeping on this body. If you disable sleeping, the body will be woken.} procedure SetSleepingAllowed(flag: Boolean); cdecl; { Is this body allowed to sleep} function IsSleepingAllowed: Boolean; cdecl; { Set the sleep state of the body. A sleeping body has very low CPU cost. @param flag set to true to wake the body, false to put it to sleep.} procedure SetAwake(flag: Boolean); cdecl; { Get the sleeping state of this body. @return true if the body is awake.} function IsAwake: Boolean; cdecl; { Set the active state of the body. An inactive body is not simulated and cannot be collided with or woken up. If you pass a flag of true, all fixtures will be added to the broad-phase. If you pass a flag of false, all fixtures will be removed from the broad-phase and all contacts will be destroyed. Fixtures and joints are otherwise unaffected. You may continue to create/destroy fixtures and joints on inactive bodies. Fixtures on an inactive body are implicitly inactive and will not participate in collisions, ray-casts, or queries. Joints connected to an inactive body are implicitly inactive. An inactive body is still owned by a b2World object and remains in the body list.} procedure SetActive(flag: Boolean); cdecl; { Get the active state of the body.} function IsActive: Boolean; cdecl; { Set this body to have fixed rotation. This causes the mass to be reset.} procedure SetFixedRotation(flag: Boolean); cdecl; { Does this body have fixed rotation?} function IsFixedRotation: Boolean; cdecl; { Get the list of all fixtures attached to this body.} function GetFixtureList: Pb2Fixture; cdecl; { Get the list of all joints attached to this body.} function GetJointList: Pb2JointEdge; cdecl; { Get the list of all contacts attached to this body. @warning this list changes during the time step and you may miss some collisions if you don't use b2ContactListener.} function GetContactList: Pb2ContactEdge; cdecl; { Get the next body in the world's body list.} function GetNext: b2BodyHandle; cdecl; { Get the user data pointer that was provided in the body definition.} function GetUserData: Pointer; cdecl; { Set the user data. Use this to store your application specific data.} procedure SetUserData(data: Pointer); cdecl; { Get the parent world of this body.} function GetWorld: b2WorldHandle; cdecl; { Dump this body to a log file} procedure Dump; cdecl; end; b2ContactManagerWrapper = record FHandle: b2ContactManagerHandle; private function Get_m_broadPhase: b2BroadPhaseHandle; cdecl; procedure Set_m_broadPhase(aNewValue: b2BroadPhaseHandle); cdecl; function Get_m_contactList: b2ContactHandle; cdecl; procedure Set_m_contactList(aNewValue: b2ContactHandle); cdecl; function Get_m_contactCount: Integer; cdecl; procedure Set_m_contactCount(aNewValue: Integer); cdecl; function Get_m_contactFilter: b2ContactFilterHandle; cdecl; procedure Set_m_contactFilter(aNewValue: b2ContactFilterHandle); cdecl; function Get_m_contactListener: b2ContactListenerHandle; cdecl; procedure Set_m_contactListener(aNewValue: b2ContactListenerHandle); cdecl; function Get_m_allocator: b2BlockAllocatorHandle; cdecl; procedure Set_m_allocator(aNewValue: b2BlockAllocatorHandle); cdecl; public class function Create: b2ContactManagerWrapper; static; cdecl; procedure Destroy; cdecl; class operator Implicit(handle: b2ContactManagerHandle): b2ContactManagerWrapper; overload; class operator Implicit(wrapper: b2ContactManagerWrapper): b2ContactManagerHandle; overload; procedure AddPair(proxyUserDataA: Pointer; proxyUserDataB: Pointer); cdecl; procedure FindNewContacts; cdecl; procedure Destroy_(c: b2ContactHandle); cdecl; procedure Collide; cdecl; property m_broadPhase: b2BroadPhaseHandle read Get_m_broadPhase write Set_m_broadPhase; property m_contactList: b2ContactHandle read Get_m_contactList write Set_m_contactList; property m_contactCount: Integer read Get_m_contactCount write Set_m_contactCount; property m_contactFilter: b2ContactFilterHandle read Get_m_contactFilter write Set_m_contactFilter; property m_contactListener: b2ContactListenerHandle read Get_m_contactListener write Set_m_contactListener; property m_allocator: b2BlockAllocatorHandle read Get_m_allocator write Set_m_allocator; end; { This holds contact filtering data.} b2Filter = record categoryBits: Word; { The collision category bits. Normally you would just set one bit.} maskBits: Word; { The collision mask bits. This states the categories that this shape would accept for collision.} groupIndex: SmallInt; { Collision groups allow a certain group of objects to never collide (negative) or always collide (positive). Zero means no collision group. Non-zero group filtering always wins against the mask bits.} class function Create: b2Filter; static; cdecl; end; { A fixture definition is used to create a fixture. This class defines an abstract fixture definition. You can reuse fixture definitions safely.} b2FixtureDef = record shape: b2ShapeHandle; { The shape, this must be set. The shape will be cloned, so you can create the shape on the stack.} userData: Pointer; { Use this to store application specific fixture data.} friction: Single; { The friction coefficient, usually in the range [0,1].} restitution: Single; { The restitution (elasticity) usually in the range [0,1].} density: Single; { The density, usually in kg/m^2.} isSensor: Boolean; { A sensor shape collects contact information but never generates a collision response.} filter: b2Filter; { Contact filtering data.} class function Create: b2FixtureDef; static; cdecl; end; { This proxy is used internally to connect fixtures to the broad-phase.} b2FixtureProxy = record aabb: b2AABB; fixture: Pb2Fixture; childIndex: Integer; proxyId: Integer; class function Create: b2FixtureProxy; static; cdecl; end; { A fixture is used to attach a shape to a body for collision detection. A fixture inherits its transform from its parent. Fixtures hold additional non-geometric data such as friction, collision filters, etc. Fixtures are created via b2Body::CreateFixture. @warning you cannot reuse fixtures.} b2Fixture = record private m_density: Single; m_next: Pb2Fixture; m_body: b2BodyHandle; m_shape: b2ShapeHandle; m_friction: Single; m_restitution: Single; m_proxies: Pb2FixtureProxy; m_proxyCount: Integer; m_filter: b2Filter; m_isSensor: Boolean; m_userData: Pointer; public { Get the type of the child shape. You can use this to down cast to the concrete shape. @return the shape type.} function GetType: Integer; cdecl; { Get the child shape. You can modify the child shape, however you should not change the number of vertices because this will crash some collision caching mechanisms. Manipulating the shape may lead to non-physical behavior.} function GetShape: b2ShapeHandle; cdecl; { Set if this fixture is a sensor.} procedure SetSensor(sensor: Boolean); cdecl; { Is this fixture a sensor (non-solid)? @return the true if the shape is a sensor.} function IsSensor: Boolean; cdecl; { Set the contact filtering data. This will not update contacts until the next time step when either parent body is active and awake. This automatically calls Refilter.} procedure SetFilterData(const [ref] filter: b2Filter); cdecl; { Get the contact filtering data.} function GetFilterData: Pb2Filter; cdecl; { Call this if you want to establish collision that was previously disabled by b2ContactFilter::ShouldCollide.} procedure Refilter; cdecl; { Get the parent body of this fixture. This is NULL if the fixture is not attached. @return the parent body.} function GetBody: b2BodyHandle; cdecl; { Get the next fixture in the parent body's fixture list. @return the next shape.} function GetNext: Pb2Fixture; cdecl; { Get the user data that was assigned in the fixture definition. Use this to store your application specific data.} function GetUserData: Pointer; cdecl; { Set the user data. Use this to store your application specific data.} procedure SetUserData(data: Pointer); cdecl; { Test a point for containment in this fixture. @param p a point in world coordinates.} function TestPoint(const [ref] p: b2Vec2): Boolean; cdecl; { Cast a ray against this shape. @param output the ray-cast results. @param input the ray-cast input parameters.} function RayCast(output: Pb2RayCastOutput; const [ref] input: b2RayCastInput; childIndex: Integer): Boolean; cdecl; { Get the mass data for this fixture. The mass data is based on the density and the shape. The rotational inertia is about the shape's origin. This operation may be expensive.} procedure GetMassData(massData: Pb2MassData); cdecl; { Set the density of this fixture. This will _not_ automatically adjust the mass of the body. You must call b2Body::ResetMassData to update the body's mass.} procedure SetDensity(density: Single); cdecl; { Get the density of this fixture.} function GetDensity: Single; cdecl; { Get the coefficient of friction.} function GetFriction: Single; cdecl; { Set the coefficient of friction. This will _not_ change the friction of existing contacts.} procedure SetFriction(friction: Single); cdecl; { Get the coefficient of restitution.} function GetRestitution: Single; cdecl; { Set the coefficient of restitution. This will _not_ change the restitution of existing contacts.} procedure SetRestitution(restitution: Single); cdecl; { Get the fixture's AABB. This AABB may be enlarge and/or stale. If you need a more accurate AABB, compute it using the shape and the body transform.} function GetAABB(childIndex: Integer): Pb2AABB; cdecl; { Dump this fixture to the log file.} procedure Dump(bodyIndex: Integer); cdecl; end; { Profiling data. Times are in milliseconds.} b2Profile = record step: Single; collide: Single; solve: Single; solveInit: Single; solveVelocity: Single; solvePosition: Single; broadphase: Single; solveTOI: Single; class function Create: b2Profile; static; cdecl; end; { This is an internal structure.} b2TimeStep = record dt: Single; inv_dt: Single; dtRatio: Single; velocityIterations: Integer; positionIterations: Integer; warmStarting: Boolean; class function Create: b2TimeStep; static; cdecl; end; { This is an internal structure.} b2Position = record c: b2Vec2; a: Single; class function Create: b2Position; static; cdecl; end; { This is an internal structure.} b2Velocity = record v: b2Vec2; w: Single; class function Create: b2Velocity; static; cdecl; end; { Solver Data} b2SolverData = record step: b2TimeStep; positions: Pb2Position; velocities: Pb2Velocity; class function Create: b2SolverData; static; cdecl; end; { This is an internal class.} b2IslandWrapper = record FHandle: b2IslandHandle; private function Get_m_allocator: b2StackAllocatorHandle; cdecl; procedure Set_m_allocator(aNewValue: b2StackAllocatorHandle); cdecl; function Get_m_listener: b2ContactListenerHandle; cdecl; procedure Set_m_listener(aNewValue: b2ContactListenerHandle); cdecl; function Get_m_bodies: Pb2BodyHandle; cdecl; procedure Set_m_bodies(aNewValue: Pb2BodyHandle); cdecl; function Get_m_contacts: Pb2ContactHandle; cdecl; procedure Set_m_contacts(aNewValue: Pb2ContactHandle); cdecl; function Get_m_joints: Pb2JointHandle; cdecl; procedure Set_m_joints(aNewValue: Pb2JointHandle); cdecl; function Get_m_positions: Pb2Position; cdecl; procedure Set_m_positions(aNewValue: Pb2Position); cdecl; function Get_m_velocities: Pb2Velocity; cdecl; procedure Set_m_velocities(aNewValue: Pb2Velocity); cdecl; function Get_m_bodyCount: Integer; cdecl; procedure Set_m_bodyCount(aNewValue: Integer); cdecl; function Get_m_jointCount: Integer; cdecl; procedure Set_m_jointCount(aNewValue: Integer); cdecl; function Get_m_contactCount: Integer; cdecl; procedure Set_m_contactCount(aNewValue: Integer); cdecl; function Get_m_bodyCapacity: Integer; cdecl; procedure Set_m_bodyCapacity(aNewValue: Integer); cdecl; function Get_m_contactCapacity: Integer; cdecl; procedure Set_m_contactCapacity(aNewValue: Integer); cdecl; function Get_m_jointCapacity: Integer; cdecl; procedure Set_m_jointCapacity(aNewValue: Integer); cdecl; public class function Create(bodyCapacity: Integer; contactCapacity: Integer; jointCapacity: Integer; allocator: b2StackAllocatorHandle; listener: b2ContactListenerHandle): b2IslandWrapper; static; cdecl; procedure Destroy; cdecl; class operator Implicit(handle: b2IslandHandle): b2IslandWrapper; overload; class operator Implicit(wrapper: b2IslandWrapper): b2IslandHandle; overload; procedure Clear; cdecl; procedure Solve(profile: Pb2Profile; const [ref] step: b2TimeStep; const [ref] gravity: b2Vec2; allowSleep: Boolean); cdecl; procedure SolveTOI(const [ref] subStep: b2TimeStep; toiIndexA: Integer; toiIndexB: Integer); cdecl; procedure Add(body: b2BodyHandle); cdecl; procedure Add2(contact: b2ContactHandle); cdecl; procedure Add3(joint: b2JointHandle); cdecl; procedure Report(constraints: Pb2ContactVelocityConstraint); cdecl; property m_allocator: b2StackAllocatorHandle read Get_m_allocator write Set_m_allocator; property m_listener: b2ContactListenerHandle read Get_m_listener write Set_m_listener; property m_bodies: Pb2BodyHandle read Get_m_bodies write Set_m_bodies; property m_contacts: Pb2ContactHandle read Get_m_contacts write Set_m_contacts; property m_joints: Pb2JointHandle read Get_m_joints write Set_m_joints; property m_positions: Pb2Position read Get_m_positions write Set_m_positions; property m_velocities: Pb2Velocity read Get_m_velocities write Set_m_velocities; property m_bodyCount: Integer read Get_m_bodyCount write Set_m_bodyCount; property m_jointCount: Integer read Get_m_jointCount write Set_m_jointCount; property m_contactCount: Integer read Get_m_contactCount write Set_m_contactCount; property m_bodyCapacity: Integer read Get_m_bodyCapacity write Set_m_bodyCapacity; property m_contactCapacity: Integer read Get_m_contactCapacity write Set_m_contactCapacity; property m_jointCapacity: Integer read Get_m_jointCapacity write Set_m_jointCapacity; end; { Joints and fixtures are destroyed when their associated body is destroyed. Implement this listener so that you may nullify references to these joints and shapes.} b2DestructionListenerWrapper = record FHandle: b2DestructionListenerHandle; class operator Implicit(handle: b2DestructionListenerHandle): b2DestructionListenerWrapper; overload; class operator Implicit(wrapper: b2DestructionListenerWrapper): b2DestructionListenerHandle; overload; { Called when any joint is about to be destroyed due to the destruction of one of its attached bodies.} procedure SayGoodbye(joint: b2JointHandle); overload; cdecl; { Called when any fixture is about to be destroyed due to the destruction of its parent body.} procedure SayGoodbye(fixture: Pb2Fixture); overload; cdecl; end; { Implement this class to provide collision filtering. In other words, you can implement this class if you want finer control over contact creation.} b2ContactFilterWrapper = record FHandle: b2ContactFilterHandle; class function Create: b2ContactFilterWrapper; static; cdecl; procedure Destroy; cdecl; class operator Implicit(handle: b2ContactFilterHandle): b2ContactFilterWrapper; overload; class operator Implicit(wrapper: b2ContactFilterWrapper): b2ContactFilterHandle; overload; { Return true if contact calculations should be performed between these two shapes. @warning for performance reasons this is only called when the AABBs begin to overlap.} function ShouldCollide(fixtureA: Pb2Fixture; fixtureB: Pb2Fixture): Boolean; cdecl; end; { Contact impulses for reporting. Impulses are used instead of forces because sub-step forces may approach infinity for rigid body collisions. These match up one-to-one with the contact points in b2Manifold.} b2ContactImpulse = record normalImpulses: array[0..1] of Single; tangentImpulses: array[0..1] of Single; count: Integer; class function Create: b2ContactImpulse; static; cdecl; end; { Implement this class to get contact information. You can use these results for things like sounds and game logic. You can also get contact results by traversing the contact lists after the time step. However, you might miss some contacts because continuous physics leads to sub-stepping. Additionally you may receive multiple callbacks for the same contact in a single time step. You should strive to make your callbacks efficient because there may be many callbacks per time step. @warning You cannot create/destroy Box2D entities inside these callbacks.} b2ContactListenerWrapper = record FHandle: b2ContactListenerHandle; class function Create: b2ContactListenerWrapper; static; cdecl; procedure Destroy; cdecl; class operator Implicit(handle: b2ContactListenerHandle): b2ContactListenerWrapper; overload; class operator Implicit(wrapper: b2ContactListenerWrapper): b2ContactListenerHandle; overload; { Called when two fixtures begin to touch.} procedure BeginContact(contact: b2ContactHandle); cdecl; { Called when two fixtures cease to touch.} procedure EndContact(contact: b2ContactHandle); cdecl; { This is called after a contact is updated. This allows you to inspect a contact before it goes to the solver. If you are careful, you can modify the contact manifold (e.g. disable contact). A copy of the old manifold is provided so that you can detect changes. Note: this is called only for awake bodies. Note: this is called even when the number of contact points is zero. Note: this is not called for sensors. Note: if you set the number of contact points to zero, you will not get an EndContact callback. However, you may get a BeginContact callback the next step.} procedure PreSolve(contact: b2ContactHandle; oldManifold: Pb2Manifold); cdecl; { This lets you inspect a contact after the solver is finished. This is useful for inspecting impulses. Note: the contact manifold does not include time of impact impulses, which can be arbitrarily large if the sub-step is small. Hence the impulse is provided explicitly in a separate data structure. Note: this is only called for contacts that are touching, solid, and awake.} procedure PostSolve(contact: b2ContactHandle; impulse: Pb2ContactImpulse); cdecl; end; { Callback class for AABB queries. See b2World::Query} b2QueryCallbackWrapper = record FHandle: b2QueryCallbackHandle; class operator Implicit(handle: b2QueryCallbackHandle): b2QueryCallbackWrapper; overload; class operator Implicit(wrapper: b2QueryCallbackWrapper): b2QueryCallbackHandle; overload; { Called for each fixture found in the query AABB. @return false to terminate the query.} function ReportFixture(fixture: Pb2Fixture): Boolean; cdecl; end; { Callback class for ray casts. See b2World::RayCast} b2RayCastCallbackWrapper = record FHandle: b2RayCastCallbackHandle; class operator Implicit(handle: b2RayCastCallbackHandle): b2RayCastCallbackWrapper; overload; class operator Implicit(wrapper: b2RayCastCallbackWrapper): b2RayCastCallbackHandle; overload; { Called for each fixture found in the query. You control how the ray cast proceeds by returning a float: return -1: ignore this fixture and continue return 0: terminate the ray cast return fraction: clip the ray to this point return 1: don't clip the ray and continue @param fixture the fixture hit by the ray @param point the point of initial intersection @param normal the normal vector at the point of intersection @return -1 to filter, 0 to terminate, fraction to clip the ray for closest hit, 1 to continue} function ReportFixture(fixture: Pb2Fixture; const [ref] point: b2Vec2; const [ref] normal: b2Vec2; fraction: Single): Single; cdecl; end; { The world class manages all physics entities, dynamic simulation, and asynchronous queries. The world also contains efficient memory management facilities.} b2WorldWrapper = record FHandle: b2WorldHandle; class function Create(const [ref] gravity: b2Vec2): b2WorldWrapper; static; cdecl; procedure Destroy; cdecl; class operator Implicit(handle: b2WorldHandle): b2WorldWrapper; overload; class operator Implicit(wrapper: b2WorldWrapper): b2WorldHandle; overload; { Register a destruction listener. The listener is owned by you and must remain in scope.} procedure SetDestructionListener(listener: b2DestructionListenerHandle); cdecl; { Register a contact filter to provide specific control over collision. Otherwise the default filter is used (b2_defaultFilter). The listener is owned by you and must remain in scope.} procedure SetContactFilter(filter: b2ContactFilterHandle); cdecl; { Register a contact event listener. The listener is owned by you and must remain in scope.} procedure SetContactListener(listener: b2ContactListenerHandle); cdecl; { Register a routine for debug drawing. The debug draw functions are called inside with b2World::DrawDebugData method. The debug draw object is owned by you and must remain in scope.} procedure SetDebugDraw(debugDraw: b2DrawHandle); cdecl; { Create a rigid body given a definition. No reference to the definition is retained. @warning This function is locked during callbacks.} function CreateBody(def: Pb2BodyDef): b2BodyHandle; cdecl; { Destroy a rigid body given a definition. No reference to the definition is retained. This function is locked during callbacks. @warning This automatically deletes all associated shapes and joints. @warning This function is locked during callbacks.} procedure DestroyBody(body: b2BodyHandle); cdecl; { Create a joint to constrain bodies together. No reference to the definition is retained. This may cause the connected bodies to cease colliding. @warning This function is locked during callbacks.} function CreateJoint(def: Pb2JointDef): b2JointHandle; cdecl; { Destroy a joint. This may cause the connected bodies to begin colliding. @warning This function is locked during callbacks.} procedure DestroyJoint(joint: b2JointHandle); cdecl; { Take a time step. This performs collision detection, integration, and constraint solution. @param timeStep the amount of time to simulate, this should not vary. @param velocityIterations for the velocity constraint solver. @param positionIterations for the position constraint solver.} procedure Step(timeStep: Single; velocityIterations: Integer; positionIterations: Integer); cdecl; { Manually clear the force buffer on all bodies. By default, forces are cleared automatically after each call to Step. The default behavior is modified by calling SetAutoClearForces. The purpose of this function is to support sub-stepping. Sub-stepping is often used to maintain a fixed sized time step under a variable frame-rate. When you perform sub-stepping you will disable auto clearing of forces and instead call ClearForces after all sub-steps are complete in one pass of your game loop. @see SetAutoClearForces} procedure ClearForces; cdecl; { Call this to draw shapes and other debug draw data. This is intentionally non-const.} procedure DrawDebugData; cdecl; { Query the world for all fixtures that potentially overlap the provided AABB. @param callback a user implemented callback class. @param aabb the query box.} procedure QueryAABB(callback: b2QueryCallbackHandle; const [ref] aabb: b2AABB); cdecl; { Ray-cast the world for all fixtures in the path of the ray. Your callback controls whether you get the closest point, any point, or n-points. The ray-cast ignores shapes that contain the starting point. @param callback a user implemented callback class. @param point1 the ray starting point @param point2 the ray ending point} procedure RayCast(callback: b2RayCastCallbackHandle; const [ref] point1: b2Vec2; const [ref] point2: b2Vec2); cdecl; { Get the world body list. With the returned body, use b2Body::GetNext to get the next body in the world list. A NULL body indicates the end of the list. @return the head of the world body list.} function GetBodyList: b2BodyHandle; cdecl; { Get the world joint list. With the returned joint, use b2Joint::GetNext to get the next joint in the world list. A NULL joint indicates the end of the list. @return the head of the world joint list.} function GetJointList: b2JointHandle; cdecl; { Get the world contact list. With the returned contact, use b2Contact::GetNext to get the next contact in the world list. A NULL contact indicates the end of the list. @return the head of the world contact list. @warning contacts are created and destroyed in the middle of a time step. Use b2ContactListener to avoid missing contacts.} function GetContactList: b2ContactHandle; cdecl; { Enable/disable sleep.} procedure SetAllowSleeping(flag: Boolean); cdecl; function GetAllowSleeping: Boolean; cdecl; { Enable/disable warm starting. For testing.} procedure SetWarmStarting(flag: Boolean); cdecl; function GetWarmStarting: Boolean; cdecl; { Enable/disable continuous physics. For testing.} procedure SetContinuousPhysics(flag: Boolean); cdecl; function GetContinuousPhysics: Boolean; cdecl; { Enable/disable single stepped continuous physics. For testing.} procedure SetSubStepping(flag: Boolean); cdecl; function GetSubStepping: Boolean; cdecl; { Get the number of broad-phase proxies.} function GetProxyCount: Integer; cdecl; { Get the number of bodies.} function GetBodyCount: Integer; cdecl; { Get the number of joints.} function GetJointCount: Integer; cdecl; { Get the number of contacts (each may have 0 or more contact points).} function GetContactCount: Integer; cdecl; { Get the height of the dynamic tree.} function GetTreeHeight: Integer; cdecl; { Get the balance of the dynamic tree.} function GetTreeBalance: Integer; cdecl; { Get the quality metric of the dynamic tree. The smaller the better. The minimum is 1.} function GetTreeQuality: Single; cdecl; { Change the global gravity vector.} procedure SetGravity(const [ref] gravity: b2Vec2); cdecl; { Get the global gravity vector.} function GetGravity: b2Vec2; cdecl; { Is the world locked (in the middle of a time step).} function IsLocked: Boolean; cdecl; { Set flag to control automatic clearing of forces after each time step.} procedure SetAutoClearForces(flag: Boolean); cdecl; { Get the flag that controls automatic clearing of forces after each time step.} function GetAutoClearForces: Boolean; cdecl; { Shift the world origin. Useful for large worlds. The body shift formula is: position -= newOrigin @param newOrigin the new origin with respect to the old origin} procedure ShiftOrigin(const [ref] newOrigin: b2Vec2); cdecl; { Get the contact manager for testing.} function GetContactManager: b2ContactManagerHandle; cdecl; { Get the current profile.} function GetProfile: Pb2Profile; cdecl; { Dump the world into the log file. @warning this should be called outside of a time step.} procedure Dump; cdecl; end; b2ContactRegister = record createFcn: b2ContactCreateFcn; destroyFcn: b2ContactDestroyFcn; primary: Boolean; class function Create: b2ContactRegister; static; cdecl; end; { A contact edge is used to connect bodies and contacts together in a contact graph where each body is a node and each contact is an edge. A contact edge belongs to a doubly linked list maintained in each attached body. Each contact has two contact nodes, one for each attached body.} b2ContactEdge = record other: b2BodyHandle; {< provides quick access to the other body attached.} contact: b2ContactHandle; {< the contact} prev: Pb2ContactEdge; {< the previous contact edge in the body's contact list} next: Pb2ContactEdge; {< the next contact edge in the body's contact list} class function Create: b2ContactEdge; static; cdecl; end; { The class manages contact between two shapes. A contact exists for each overlapping AABB in the broad-phase (except if filtered). Therefore a contact object may exist that has no contact points.} b2ContactWrapper = record FHandle: b2ContactHandle; class operator Implicit(handle: b2ContactHandle): b2ContactWrapper; overload; class operator Implicit(wrapper: b2ContactWrapper): b2ContactHandle; overload; { Get the contact manifold. Do not modify the manifold unless you understand the internals of Box2D.} function GetManifold: Pb2Manifold; cdecl; { Get the world manifold.} procedure GetWorldManifold(worldManifold: Pb2WorldManifold); cdecl; { Is this contact touching?} function IsTouching: Boolean; cdecl; { Enable/disable this contact. This can be used inside the pre-solve contact listener. The contact is only disabled for the current time step (or sub-step in continuous collisions).} procedure SetEnabled(flag: Boolean); cdecl; { Has this contact been disabled?} function IsEnabled: Boolean; cdecl; { Get the next contact in the world's contact list.} function GetNext: b2ContactHandle; cdecl; { Get fixture A in this contact.} function GetFixtureA: Pb2Fixture; cdecl; { Get the child primitive index for fixture A.} function GetChildIndexA: Integer; cdecl; { Get fixture B in this contact.} function GetFixtureB: Pb2Fixture; cdecl; { Get the child primitive index for fixture B.} function GetChildIndexB: Integer; cdecl; { Override the default friction mixture. You can call this in b2ContactListener::PreSolve. This value persists until set or reset.} procedure SetFriction(friction: Single); cdecl; { Get the friction.} function GetFriction: Single; cdecl; { Reset the friction mixture to the default value.} procedure ResetFriction; cdecl; { Override the default restitution mixture. You can call this in b2ContactListener::PreSolve. The value persists until you set or reset.} procedure SetRestitution(restitution: Single); cdecl; { Get the restitution.} function GetRestitution: Single; cdecl; { Reset the restitution to the default value.} procedure ResetRestitution; cdecl; { Set the desired tangent speed for a conveyor belt behavior. In meters per second.} procedure SetTangentSpeed(speed: Single); cdecl; { Get the desired tangent speed. In meters per second.} function GetTangentSpeed: Single; cdecl; { Evaluate this contact with your own manifold and transforms.} procedure Evaluate(manifold: Pb2Manifold; const [ref] xfA: b2Transform; const [ref] xfB: b2Transform); cdecl; end; b2ChainAndCircleContactWrapper = record FHandle: b2ChainAndCircleContactHandle; class function Create(fixtureA: Pb2Fixture; indexA: Integer; fixtureB: Pb2Fixture; indexB: Integer): b2ChainAndCircleContactWrapper; static; cdecl; procedure Destroy; cdecl; class operator Implicit(handle: b2ChainAndCircleContactHandle): b2ChainAndCircleContactWrapper; overload; class operator Implicit(wrapper: b2ChainAndCircleContactWrapper): b2ChainAndCircleContactHandle; overload; { Get the contact manifold. Do not modify the manifold unless you understand the internals of Box2D.} function GetManifold: Pb2Manifold; cdecl; { Get the world manifold.} procedure GetWorldManifold(worldManifold: Pb2WorldManifold); cdecl; { Is this contact touching?} function IsTouching: Boolean; cdecl; { Enable/disable this contact. This can be used inside the pre-solve contact listener. The contact is only disabled for the current time step (or sub-step in continuous collisions).} procedure SetEnabled(flag: Boolean); cdecl; { Has this contact been disabled?} function IsEnabled: Boolean; cdecl; { Get the next contact in the world's contact list.} function GetNext: b2ContactHandle; cdecl; { Get fixture A in this contact.} function GetFixtureA: Pb2Fixture; cdecl; { Get the child primitive index for fixture A.} function GetChildIndexA: Integer; cdecl; { Get fixture B in this contact.} function GetFixtureB: Pb2Fixture; cdecl; { Get the child primitive index for fixture B.} function GetChildIndexB: Integer; cdecl; { Override the default friction mixture. You can call this in b2ContactListener::PreSolve. This value persists until set or reset.} procedure SetFriction(friction: Single); cdecl; { Get the friction.} function GetFriction: Single; cdecl; { Reset the friction mixture to the default value.} procedure ResetFriction; cdecl; { Override the default restitution mixture. You can call this in b2ContactListener::PreSolve. The value persists until you set or reset.} procedure SetRestitution(restitution: Single); cdecl; { Get the restitution.} function GetRestitution: Single; cdecl; { Reset the restitution to the default value.} procedure ResetRestitution; cdecl; { Set the desired tangent speed for a conveyor belt behavior. In meters per second.} procedure SetTangentSpeed(speed: Single); cdecl; { Get the desired tangent speed. In meters per second.} function GetTangentSpeed: Single; cdecl; { Evaluate this contact with your own manifold and transforms.} procedure Evaluate(manifold: Pb2Manifold; const [ref] xfA: b2Transform; const [ref] xfB: b2Transform); cdecl; function Create_(fixtureA: Pb2Fixture; indexA: Integer; fixtureB: Pb2Fixture; indexB: Integer; allocator: b2BlockAllocatorHandle): b2ContactHandle; cdecl; procedure Destroy_(contact: b2ContactHandle; allocator: b2BlockAllocatorHandle); cdecl; end; b2ChainAndPolygonContactWrapper = record FHandle: b2ChainAndPolygonContactHandle; class function Create(fixtureA: Pb2Fixture; indexA: Integer; fixtureB: Pb2Fixture; indexB: Integer): b2ChainAndPolygonContactWrapper; static; cdecl; procedure Destroy; cdecl; class operator Implicit(handle: b2ChainAndPolygonContactHandle): b2ChainAndPolygonContactWrapper; overload; class operator Implicit(wrapper: b2ChainAndPolygonContactWrapper): b2ChainAndPolygonContactHandle; overload; { Get the contact manifold. Do not modify the manifold unless you understand the internals of Box2D.} function GetManifold: Pb2Manifold; cdecl; { Get the world manifold.} procedure GetWorldManifold(worldManifold: Pb2WorldManifold); cdecl; { Is this contact touching?} function IsTouching: Boolean; cdecl; { Enable/disable this contact. This can be used inside the pre-solve contact listener. The contact is only disabled for the current time step (or sub-step in continuous collisions).} procedure SetEnabled(flag: Boolean); cdecl; { Has this contact been disabled?} function IsEnabled: Boolean; cdecl; { Get the next contact in the world's contact list.} function GetNext: b2ContactHandle; cdecl; { Get fixture A in this contact.} function GetFixtureA: Pb2Fixture; cdecl; { Get the child primitive index for fixture A.} function GetChildIndexA: Integer; cdecl; { Get fixture B in this contact.} function GetFixtureB: Pb2Fixture; cdecl; { Get the child primitive index for fixture B.} function GetChildIndexB: Integer; cdecl; { Override the default friction mixture. You can call this in b2ContactListener::PreSolve. This value persists until set or reset.} procedure SetFriction(friction: Single); cdecl; { Get the friction.} function GetFriction: Single; cdecl; { Reset the friction mixture to the default value.} procedure ResetFriction; cdecl; { Override the default restitution mixture. You can call this in b2ContactListener::PreSolve. The value persists until you set or reset.} procedure SetRestitution(restitution: Single); cdecl; { Get the restitution.} function GetRestitution: Single; cdecl; { Reset the restitution to the default value.} procedure ResetRestitution; cdecl; { Set the desired tangent speed for a conveyor belt behavior. In meters per second.} procedure SetTangentSpeed(speed: Single); cdecl; { Get the desired tangent speed. In meters per second.} function GetTangentSpeed: Single; cdecl; { Evaluate this contact with your own manifold and transforms.} procedure Evaluate(manifold: Pb2Manifold; const [ref] xfA: b2Transform; const [ref] xfB: b2Transform); cdecl; function Create_(fixtureA: Pb2Fixture; indexA: Integer; fixtureB: Pb2Fixture; indexB: Integer; allocator: b2BlockAllocatorHandle): b2ContactHandle; cdecl; procedure Destroy_(contact: b2ContactHandle; allocator: b2BlockAllocatorHandle); cdecl; end; b2CircleContactWrapper = record FHandle: b2CircleContactHandle; class function Create(fixtureA: Pb2Fixture; fixtureB: Pb2Fixture): b2CircleContactWrapper; static; cdecl; procedure Destroy; cdecl; class operator Implicit(handle: b2CircleContactHandle): b2CircleContactWrapper; overload; class operator Implicit(wrapper: b2CircleContactWrapper): b2CircleContactHandle; overload; { Get the contact manifold. Do not modify the manifold unless you understand the internals of Box2D.} function GetManifold: Pb2Manifold; cdecl; { Get the world manifold.} procedure GetWorldManifold(worldManifold: Pb2WorldManifold); cdecl; { Is this contact touching?} function IsTouching: Boolean; cdecl; { Enable/disable this contact. This can be used inside the pre-solve contact listener. The contact is only disabled for the current time step (or sub-step in continuous collisions).} procedure SetEnabled(flag: Boolean); cdecl; { Has this contact been disabled?} function IsEnabled: Boolean; cdecl; { Get the next contact in the world's contact list.} function GetNext: b2ContactHandle; cdecl; { Get fixture A in this contact.} function GetFixtureA: Pb2Fixture; cdecl; { Get the child primitive index for fixture A.} function GetChildIndexA: Integer; cdecl; { Get fixture B in this contact.} function GetFixtureB: Pb2Fixture; cdecl; { Get the child primitive index for fixture B.} function GetChildIndexB: Integer; cdecl; { Override the default friction mixture. You can call this in b2ContactListener::PreSolve. This value persists until set or reset.} procedure SetFriction(friction: Single); cdecl; { Get the friction.} function GetFriction: Single; cdecl; { Reset the friction mixture to the default value.} procedure ResetFriction; cdecl; { Override the default restitution mixture. You can call this in b2ContactListener::PreSolve. The value persists until you set or reset.} procedure SetRestitution(restitution: Single); cdecl; { Get the restitution.} function GetRestitution: Single; cdecl; { Reset the restitution to the default value.} procedure ResetRestitution; cdecl; { Set the desired tangent speed for a conveyor belt behavior. In meters per second.} procedure SetTangentSpeed(speed: Single); cdecl; { Get the desired tangent speed. In meters per second.} function GetTangentSpeed: Single; cdecl; { Evaluate this contact with your own manifold and transforms.} procedure Evaluate(manifold: Pb2Manifold; const [ref] xfA: b2Transform; const [ref] xfB: b2Transform); cdecl; function Create_(fixtureA: Pb2Fixture; indexA: Integer; fixtureB: Pb2Fixture; indexB: Integer; allocator: b2BlockAllocatorHandle): b2ContactHandle; cdecl; procedure Destroy_(contact: b2ContactHandle; allocator: b2BlockAllocatorHandle); cdecl; end; b2VelocityConstraintPoint = record rA: b2Vec2; rB: b2Vec2; normalImpulse: Single; tangentImpulse: Single; normalMass: Single; tangentMass: Single; velocityBias: Single; class function Create: b2VelocityConstraintPoint; static; cdecl; end; b2ContactVelocityConstraint = record points: array[0..1] of b2VelocityConstraintPoint; normal: b2Vec2; normalMass: b2Mat22; K: b2Mat22; indexA: Integer; indexB: Integer; invMassA: Single; invMassB: Single; invIA: Single; invIB: Single; friction: Single; restitution: Single; tangentSpeed: Single; pointCount: Integer; contactIndex: Integer; class function Create: b2ContactVelocityConstraint; static; cdecl; end; b2ContactSolverDef = record step: b2TimeStep; contacts: b2ContactHandle; count: Integer; positions: Pb2Position; velocities: Pb2Velocity; allocator: b2StackAllocatorHandle; class function Create: b2ContactSolverDef; static; cdecl; end; b2ContactSolverWrapper = record FHandle: b2ContactSolverHandle; private function Get_m_step: b2TimeStep; cdecl; procedure Set_m_step(aNewValue: b2TimeStep); cdecl; function Get_m_step_P: Pb2TimeStep; cdecl; function Get_m_positions: Pb2Position; cdecl; procedure Set_m_positions(aNewValue: Pb2Position); cdecl; function Get_m_velocities: Pb2Velocity; cdecl; procedure Set_m_velocities(aNewValue: Pb2Velocity); cdecl; function Get_m_allocator: b2StackAllocatorHandle; cdecl; procedure Set_m_allocator(aNewValue: b2StackAllocatorHandle); cdecl; function Get_m_velocityConstraints: Pb2ContactVelocityConstraint; cdecl; procedure Set_m_velocityConstraints(aNewValue: Pb2ContactVelocityConstraint); cdecl; function Get_m_contacts: Pb2ContactHandle; cdecl; procedure Set_m_contacts(aNewValue: Pb2ContactHandle); cdecl; function Get_m_count: Integer; cdecl; procedure Set_m_count(aNewValue: Integer); cdecl; public class function Create(def: Pb2ContactSolverDef): b2ContactSolverWrapper; static; cdecl; procedure Destroy; cdecl; class operator Implicit(handle: b2ContactSolverHandle): b2ContactSolverWrapper; overload; class operator Implicit(wrapper: b2ContactSolverWrapper): b2ContactSolverHandle; overload; procedure InitializeVelocityConstraints; cdecl; procedure WarmStart; cdecl; procedure SolveVelocityConstraints; cdecl; procedure StoreImpulses; cdecl; function SolvePositionConstraints: Boolean; cdecl; function SolveTOIPositionConstraints(toiIndexA: Integer; toiIndexB: Integer): Boolean; cdecl; property m_step: b2TimeStep read Get_m_step write Set_m_step; property m_step_P: Pb2TimeStep read Get_m_step_P; property m_positions: Pb2Position read Get_m_positions write Set_m_positions; property m_velocities: Pb2Velocity read Get_m_velocities write Set_m_velocities; property m_allocator: b2StackAllocatorHandle read Get_m_allocator write Set_m_allocator; property m_velocityConstraints: Pb2ContactVelocityConstraint read Get_m_velocityConstraints write Set_m_velocityConstraints; property m_contacts: Pb2ContactHandle read Get_m_contacts write Set_m_contacts; property m_count: Integer read Get_m_count write Set_m_count; end; b2EdgeAndCircleContactWrapper = record FHandle: b2EdgeAndCircleContactHandle; class function Create(fixtureA: Pb2Fixture; fixtureB: Pb2Fixture): b2EdgeAndCircleContactWrapper; static; cdecl; procedure Destroy; cdecl; class operator Implicit(handle: b2EdgeAndCircleContactHandle): b2EdgeAndCircleContactWrapper; overload; class operator Implicit(wrapper: b2EdgeAndCircleContactWrapper): b2EdgeAndCircleContactHandle; overload; { Get the contact manifold. Do not modify the manifold unless you understand the internals of Box2D.} function GetManifold: Pb2Manifold; cdecl; { Get the world manifold.} procedure GetWorldManifold(worldManifold: Pb2WorldManifold); cdecl; { Is this contact touching?} function IsTouching: Boolean; cdecl; { Enable/disable this contact. This can be used inside the pre-solve contact listener. The contact is only disabled for the current time step (or sub-step in continuous collisions).} procedure SetEnabled(flag: Boolean); cdecl; { Has this contact been disabled?} function IsEnabled: Boolean; cdecl; { Get the next contact in the world's contact list.} function GetNext: b2ContactHandle; cdecl; { Get fixture A in this contact.} function GetFixtureA: Pb2Fixture; cdecl; { Get the child primitive index for fixture A.} function GetChildIndexA: Integer; cdecl; { Get fixture B in this contact.} function GetFixtureB: Pb2Fixture; cdecl; { Get the child primitive index for fixture B.} function GetChildIndexB: Integer; cdecl; { Override the default friction mixture. You can call this in b2ContactListener::PreSolve. This value persists until set or reset.} procedure SetFriction(friction: Single); cdecl; { Get the friction.} function GetFriction: Single; cdecl; { Reset the friction mixture to the default value.} procedure ResetFriction; cdecl; { Override the default restitution mixture. You can call this in b2ContactListener::PreSolve. The value persists until you set or reset.} procedure SetRestitution(restitution: Single); cdecl; { Get the restitution.} function GetRestitution: Single; cdecl; { Reset the restitution to the default value.} procedure ResetRestitution; cdecl; { Set the desired tangent speed for a conveyor belt behavior. In meters per second.} procedure SetTangentSpeed(speed: Single); cdecl; { Get the desired tangent speed. In meters per second.} function GetTangentSpeed: Single; cdecl; { Evaluate this contact with your own manifold and transforms.} procedure Evaluate(manifold: Pb2Manifold; const [ref] xfA: b2Transform; const [ref] xfB: b2Transform); cdecl; function Create_(fixtureA: Pb2Fixture; indexA: Integer; fixtureB: Pb2Fixture; indexB: Integer; allocator: b2BlockAllocatorHandle): b2ContactHandle; cdecl; procedure Destroy_(contact: b2ContactHandle; allocator: b2BlockAllocatorHandle); cdecl; end; b2EdgeAndPolygonContactWrapper = record FHandle: b2EdgeAndPolygonContactHandle; class function Create(fixtureA: Pb2Fixture; fixtureB: Pb2Fixture): b2EdgeAndPolygonContactWrapper; static; cdecl; procedure Destroy; cdecl; class operator Implicit(handle: b2EdgeAndPolygonContactHandle): b2EdgeAndPolygonContactWrapper; overload; class operator Implicit(wrapper: b2EdgeAndPolygonContactWrapper): b2EdgeAndPolygonContactHandle; overload; { Get the contact manifold. Do not modify the manifold unless you understand the internals of Box2D.} function GetManifold: Pb2Manifold; cdecl; { Get the world manifold.} procedure GetWorldManifold(worldManifold: Pb2WorldManifold); cdecl; { Is this contact touching?} function IsTouching: Boolean; cdecl; { Enable/disable this contact. This can be used inside the pre-solve contact listener. The contact is only disabled for the current time step (or sub-step in continuous collisions).} procedure SetEnabled(flag: Boolean); cdecl; { Has this contact been disabled?} function IsEnabled: Boolean; cdecl; { Get the next contact in the world's contact list.} function GetNext: b2ContactHandle; cdecl; { Get fixture A in this contact.} function GetFixtureA: Pb2Fixture; cdecl; { Get the child primitive index for fixture A.} function GetChildIndexA: Integer; cdecl; { Get fixture B in this contact.} function GetFixtureB: Pb2Fixture; cdecl; { Get the child primitive index for fixture B.} function GetChildIndexB: Integer; cdecl; { Override the default friction mixture. You can call this in b2ContactListener::PreSolve. This value persists until set or reset.} procedure SetFriction(friction: Single); cdecl; { Get the friction.} function GetFriction: Single; cdecl; { Reset the friction mixture to the default value.} procedure ResetFriction; cdecl; { Override the default restitution mixture. You can call this in b2ContactListener::PreSolve. The value persists until you set or reset.} procedure SetRestitution(restitution: Single); cdecl; { Get the restitution.} function GetRestitution: Single; cdecl; { Reset the restitution to the default value.} procedure ResetRestitution; cdecl; { Set the desired tangent speed for a conveyor belt behavior. In meters per second.} procedure SetTangentSpeed(speed: Single); cdecl; { Get the desired tangent speed. In meters per second.} function GetTangentSpeed: Single; cdecl; { Evaluate this contact with your own manifold and transforms.} procedure Evaluate(manifold: Pb2Manifold; const [ref] xfA: b2Transform; const [ref] xfB: b2Transform); cdecl; function Create_(fixtureA: Pb2Fixture; indexA: Integer; fixtureB: Pb2Fixture; indexB: Integer; allocator: b2BlockAllocatorHandle): b2ContactHandle; cdecl; procedure Destroy_(contact: b2ContactHandle; allocator: b2BlockAllocatorHandle); cdecl; end; b2PolygonAndCircleContactWrapper = record FHandle: b2PolygonAndCircleContactHandle; class function Create(fixtureA: Pb2Fixture; fixtureB: Pb2Fixture): b2PolygonAndCircleContactWrapper; static; cdecl; procedure Destroy; cdecl; class operator Implicit(handle: b2PolygonAndCircleContactHandle): b2PolygonAndCircleContactWrapper; overload; class operator Implicit(wrapper: b2PolygonAndCircleContactWrapper): b2PolygonAndCircleContactHandle; overload; { Get the contact manifold. Do not modify the manifold unless you understand the internals of Box2D.} function GetManifold: Pb2Manifold; cdecl; { Get the world manifold.} procedure GetWorldManifold(worldManifold: Pb2WorldManifold); cdecl; { Is this contact touching?} function IsTouching: Boolean; cdecl; { Enable/disable this contact. This can be used inside the pre-solve contact listener. The contact is only disabled for the current time step (or sub-step in continuous collisions).} procedure SetEnabled(flag: Boolean); cdecl; { Has this contact been disabled?} function IsEnabled: Boolean; cdecl; { Get the next contact in the world's contact list.} function GetNext: b2ContactHandle; cdecl; { Get fixture A in this contact.} function GetFixtureA: Pb2Fixture; cdecl; { Get the child primitive index for fixture A.} function GetChildIndexA: Integer; cdecl; { Get fixture B in this contact.} function GetFixtureB: Pb2Fixture; cdecl; { Get the child primitive index for fixture B.} function GetChildIndexB: Integer; cdecl; { Override the default friction mixture. You can call this in b2ContactListener::PreSolve. This value persists until set or reset.} procedure SetFriction(friction: Single); cdecl; { Get the friction.} function GetFriction: Single; cdecl; { Reset the friction mixture to the default value.} procedure ResetFriction; cdecl; { Override the default restitution mixture. You can call this in b2ContactListener::PreSolve. The value persists until you set or reset.} procedure SetRestitution(restitution: Single); cdecl; { Get the restitution.} function GetRestitution: Single; cdecl; { Reset the restitution to the default value.} procedure ResetRestitution; cdecl; { Set the desired tangent speed for a conveyor belt behavior. In meters per second.} procedure SetTangentSpeed(speed: Single); cdecl; { Get the desired tangent speed. In meters per second.} function GetTangentSpeed: Single; cdecl; { Evaluate this contact with your own manifold and transforms.} procedure Evaluate(manifold: Pb2Manifold; const [ref] xfA: b2Transform; const [ref] xfB: b2Transform); cdecl; function Create_(fixtureA: Pb2Fixture; indexA: Integer; fixtureB: Pb2Fixture; indexB: Integer; allocator: b2BlockAllocatorHandle): b2ContactHandle; cdecl; procedure Destroy_(contact: b2ContactHandle; allocator: b2BlockAllocatorHandle); cdecl; end; b2PolygonContactWrapper = record FHandle: b2PolygonContactHandle; class function Create(fixtureA: Pb2Fixture; fixtureB: Pb2Fixture): b2PolygonContactWrapper; static; cdecl; procedure Destroy; cdecl; class operator Implicit(handle: b2PolygonContactHandle): b2PolygonContactWrapper; overload; class operator Implicit(wrapper: b2PolygonContactWrapper): b2PolygonContactHandle; overload; { Get the contact manifold. Do not modify the manifold unless you understand the internals of Box2D.} function GetManifold: Pb2Manifold; cdecl; { Get the world manifold.} procedure GetWorldManifold(worldManifold: Pb2WorldManifold); cdecl; { Is this contact touching?} function IsTouching: Boolean; cdecl; { Enable/disable this contact. This can be used inside the pre-solve contact listener. The contact is only disabled for the current time step (or sub-step in continuous collisions).} procedure SetEnabled(flag: Boolean); cdecl; { Has this contact been disabled?} function IsEnabled: Boolean; cdecl; { Get the next contact in the world's contact list.} function GetNext: b2ContactHandle; cdecl; { Get fixture A in this contact.} function GetFixtureA: Pb2Fixture; cdecl; { Get the child primitive index for fixture A.} function GetChildIndexA: Integer; cdecl; { Get fixture B in this contact.} function GetFixtureB: Pb2Fixture; cdecl; { Get the child primitive index for fixture B.} function GetChildIndexB: Integer; cdecl; { Override the default friction mixture. You can call this in b2ContactListener::PreSolve. This value persists until set or reset.} procedure SetFriction(friction: Single); cdecl; { Get the friction.} function GetFriction: Single; cdecl; { Reset the friction mixture to the default value.} procedure ResetFriction; cdecl; { Override the default restitution mixture. You can call this in b2ContactListener::PreSolve. The value persists until you set or reset.} procedure SetRestitution(restitution: Single); cdecl; { Get the restitution.} function GetRestitution: Single; cdecl; { Reset the restitution to the default value.} procedure ResetRestitution; cdecl; { Set the desired tangent speed for a conveyor belt behavior. In meters per second.} procedure SetTangentSpeed(speed: Single); cdecl; { Get the desired tangent speed. In meters per second.} function GetTangentSpeed: Single; cdecl; { Evaluate this contact with your own manifold and transforms.} procedure Evaluate(manifold: Pb2Manifold; const [ref] xfA: b2Transform; const [ref] xfB: b2Transform); cdecl; function Create_(fixtureA: Pb2Fixture; indexA: Integer; fixtureB: Pb2Fixture; indexB: Integer; allocator: b2BlockAllocatorHandle): b2ContactHandle; cdecl; procedure Destroy_(contact: b2ContactHandle; allocator: b2BlockAllocatorHandle); cdecl; end; b2Jacobian = record linear: b2Vec2; angularA: Single; angularB: Single; class function Create: b2Jacobian; static; cdecl; end; { A joint edge is used to connect bodies and joints together in a joint graph where each body is a node and each joint is an edge. A joint edge belongs to a doubly linked list maintained in each attached body. Each joint has two joint nodes, one for each attached body.} b2JointEdge = record other: b2BodyHandle; {< provides quick access to the other body attached.} joint: b2JointHandle; {< the joint} prev: Pb2JointEdge; {< the previous joint edge in the body's joint list} next: Pb2JointEdge; {< the next joint edge in the body's joint list} class function Create: b2JointEdge; static; cdecl; end; { Joint definitions are used to construct joints.} b2JointDef = record &type: b2JointType; { The joint type is set automatically for concrete joint types.} userData: Pointer; { Use this to attach application specific data to your joints.} bodyA: b2BodyHandle; { The first attached body.} bodyB: b2BodyHandle; { The second attached body.} collideConnected: Boolean; { Set this flag to true if the attached bodies should collide.} class function Create: b2JointDef; static; cdecl; end; { The base joint class. Joints are used to constraint two bodies together in various fashions. Some joints also feature limits and motors.} b2JointWrapper = record FHandle: b2JointHandle; class operator Implicit(handle: b2JointHandle): b2JointWrapper; overload; class operator Implicit(wrapper: b2JointWrapper): b2JointHandle; overload; { Get the type of the concrete joint.} function GetType: b2JointType; cdecl; { Get the first body attached to this joint.} function GetBodyA: b2BodyHandle; cdecl; { Get the second body attached to this joint.} function GetBodyB: b2BodyHandle; cdecl; { Get the anchor point on bodyA in world coordinates.} function GetAnchorA: b2Vec2; cdecl; { Get the anchor point on bodyB in world coordinates.} function GetAnchorB: b2Vec2; cdecl; { Get the reaction force on bodyB at the joint anchor in Newtons.} function GetReactionForce(inv_dt: Single): b2Vec2; cdecl; { Get the reaction torque on bodyB in N*m.} function GetReactionTorque(inv_dt: Single): Single; cdecl; { Get the next joint the world joint list.} function GetNext: b2JointHandle; cdecl; { Get the user data pointer.} function GetUserData: Pointer; cdecl; { Set the user data pointer.} procedure SetUserData(data: Pointer); cdecl; { Short-cut function to determine if either body is inactive.} function IsActive: Boolean; cdecl; { Get collide connected. Note: modifying the collide connect flag won't work correctly because the flag is only checked when fixture AABBs begin to overlap.} function GetCollideConnected: Boolean; cdecl; { Dump this joint to the log file.} procedure Dump; cdecl; { Shift the origin for any points stored in world coordinates.} procedure ShiftOrigin(const [ref] newOrigin: b2Vec2); cdecl; end; { Distance joint definition. This requires defining an anchor point on both bodies and the non-zero length of the distance joint. The definition uses local anchor points so that the initial configuration can violate the constraint slightly. This helps when saving and loading a game. @warning Do not use a zero or short length.} b2DistanceJointDef = record &type: b2JointType; { The joint type is set automatically for concrete joint types.} userData: Pointer; { Use this to attach application specific data to your joints.} bodyA: b2BodyHandle; { The first attached body.} bodyB: b2BodyHandle; { The second attached body.} collideConnected: Boolean; { Set this flag to true if the attached bodies should collide.} Filler1 : TDWordFiller; localAnchorA: b2Vec2; { The local anchor point relative to bodyA's origin.} localAnchorB: b2Vec2; { The local anchor point relative to bodyB's origin.} length: Single; { The natural length between the anchor points.} frequencyHz: Single; { The mass-spring-damper frequency in Hertz. A value of 0 disables softness.} dampingRatio: Single; { The damping ratio. 0 = no damping, 1 = critical damping.} Filler2 : TDWordFiller; class function Create: b2DistanceJointDef; static; cdecl; { Initialize the bodies, anchors, and length using the world anchors.} procedure Initialize(bodyA: b2BodyHandle; bodyB: b2BodyHandle; const [ref] anchorA: b2Vec2; const [ref] anchorB: b2Vec2); cdecl; end; { A distance joint constrains two points on two bodies to remain at a fixed distance from each other. You can view this as a massless, rigid rod.} b2DistanceJointWrapper = record FHandle: b2DistanceJointHandle; procedure Destroy; cdecl; class operator Implicit(handle: b2DistanceJointHandle): b2DistanceJointWrapper; overload; class operator Implicit(wrapper: b2DistanceJointWrapper): b2DistanceJointHandle; overload; { Get the type of the concrete joint.} function GetType: b2JointType; cdecl; { Get the first body attached to this joint.} function GetBodyA: b2BodyHandle; cdecl; { Get the second body attached to this joint.} function GetBodyB: b2BodyHandle; cdecl; { Get the anchor point on bodyA in world coordinates.} function GetAnchorA: b2Vec2; cdecl; { Get the anchor point on bodyB in world coordinates.} function GetAnchorB: b2Vec2; cdecl; { Get the reaction force on bodyB at the joint anchor in Newtons.} function GetReactionForce(inv_dt: Single): b2Vec2; cdecl; { Get the reaction torque on bodyB in N*m.} function GetReactionTorque(inv_dt: Single): Single; cdecl; { Get the next joint the world joint list.} function GetNext: b2JointHandle; cdecl; { Get the user data pointer.} function GetUserData: Pointer; cdecl; { Set the user data pointer.} procedure SetUserData(data: Pointer); cdecl; { Short-cut function to determine if either body is inactive.} function IsActive: Boolean; cdecl; { Get collide connected. Note: modifying the collide connect flag won't work correctly because the flag is only checked when fixture AABBs begin to overlap.} function GetCollideConnected: Boolean; cdecl; { Dump this joint to the log file.} procedure Dump; cdecl; { Shift the origin for any points stored in world coordinates.} procedure ShiftOrigin(const [ref] newOrigin: b2Vec2); cdecl; { The local anchor point relative to bodyA's origin.} function GetLocalAnchorA: Pb2Vec2; cdecl; { The local anchor point relative to bodyB's origin.} function GetLocalAnchorB: Pb2Vec2; cdecl; { Set/get the natural length. Manipulating the length can lead to non-physical behavior when the frequency is zero.} procedure SetLength(length: Single); cdecl; function GetLength: Single; cdecl; { Set/get frequency in Hz.} procedure SetFrequency(hz: Single); cdecl; function GetFrequency: Single; cdecl; { Set/get damping ratio.} procedure SetDampingRatio(ratio: Single); cdecl; function GetDampingRatio: Single; cdecl; end; { Friction joint definition.} b2FrictionJointDef = record &type: b2JointType; { The joint type is set automatically for concrete joint types.} userData: Pointer; { Use this to attach application specific data to your joints.} bodyA: b2BodyHandle; { The first attached body.} bodyB: b2BodyHandle; { The second attached body.} collideConnected: Boolean; { Set this flag to true if the attached bodies should collide.} localAnchorA: b2Vec2; { The local anchor point relative to bodyA's origin.} localAnchorB: b2Vec2; { The local anchor point relative to bodyB's origin.} maxForce: Single; { The maximum friction force in N.} maxTorque: Single; { The maximum friction torque in N-m.} class function Create: b2FrictionJointDef; static; cdecl; { Initialize the bodies, anchors, axis, and reference angle using the world anchor and world axis.} procedure Initialize(bodyA: b2BodyHandle; bodyB: b2BodyHandle; const [ref] anchor: b2Vec2); cdecl; end; { Friction joint. This is used for top-down friction. It provides 2D translational friction and angular friction.} b2FrictionJointWrapper = record FHandle: b2FrictionJointHandle; procedure Destroy; cdecl; class operator Implicit(handle: b2FrictionJointHandle): b2FrictionJointWrapper; overload; class operator Implicit(wrapper: b2FrictionJointWrapper): b2FrictionJointHandle; overload; { Get the type of the concrete joint.} function GetType: b2JointType; cdecl; { Get the first body attached to this joint.} function GetBodyA: b2BodyHandle; cdecl; { Get the second body attached to this joint.} function GetBodyB: b2BodyHandle; cdecl; { Get the anchor point on bodyA in world coordinates.} function GetAnchorA: b2Vec2; cdecl; { Get the anchor point on bodyB in world coordinates.} function GetAnchorB: b2Vec2; cdecl; { Get the reaction force on bodyB at the joint anchor in Newtons.} function GetReactionForce(inv_dt: Single): b2Vec2; cdecl; { Get the reaction torque on bodyB in N*m.} function GetReactionTorque(inv_dt: Single): Single; cdecl; { Get the next joint the world joint list.} function GetNext: b2JointHandle; cdecl; { Get the user data pointer.} function GetUserData: Pointer; cdecl; { Set the user data pointer.} procedure SetUserData(data: Pointer); cdecl; { Short-cut function to determine if either body is inactive.} function IsActive: Boolean; cdecl; { Get collide connected. Note: modifying the collide connect flag won't work correctly because the flag is only checked when fixture AABBs begin to overlap.} function GetCollideConnected: Boolean; cdecl; { Dump this joint to the log file.} procedure Dump; cdecl; { Shift the origin for any points stored in world coordinates.} procedure ShiftOrigin(const [ref] newOrigin: b2Vec2); cdecl; { The local anchor point relative to bodyA's origin.} function GetLocalAnchorA: Pb2Vec2; cdecl; { The local anchor point relative to bodyB's origin.} function GetLocalAnchorB: Pb2Vec2; cdecl; { Set the maximum friction force in N.} procedure SetMaxForce(force: Single); cdecl; { Get the maximum friction force in N.} function GetMaxForce: Single; cdecl; { Set the maximum friction torque in N*m.} procedure SetMaxTorque(torque: Single); cdecl; { Get the maximum friction torque in N*m.} function GetMaxTorque: Single; cdecl; end; { Gear joint definition. This definition requires two existing revolute or prismatic joints (any combination will work).} b2GearJointDef = record &type: b2JointType; { The joint type is set automatically for concrete joint types.} userData: Pointer; { Use this to attach application specific data to your joints.} bodyA: b2BodyHandle; { The first attached body.} bodyB: b2BodyHandle; { The second attached body.} collideConnected: Boolean; { Set this flag to true if the attached bodies should collide.} joint1: b2JointHandle; { The first revolute/prismatic joint attached to the gear joint.} joint2: b2JointHandle; { The second revolute/prismatic joint attached to the gear joint.} ratio: Single; { The gear ratio. @see b2GearJoint for explanation.} class function Create: b2GearJointDef; static; cdecl; end; { A gear joint is used to connect two joints together. Either joint can be a revolute or prismatic joint. You specify a gear ratio to bind the motions together: coordinate1 + ratio * coordinate2 = constant The ratio can be negative or positive. If one joint is a revolute joint and the other joint is a prismatic joint, then the ratio will have units of length or units of 1/length. @warning You have to manually destroy the gear joint if joint1 or joint2 is destroyed.} b2GearJointWrapper = record FHandle: b2GearJointHandle; procedure Destroy; cdecl; class operator Implicit(handle: b2GearJointHandle): b2GearJointWrapper; overload; class operator Implicit(wrapper: b2GearJointWrapper): b2GearJointHandle; overload; { Get the type of the concrete joint.} function GetType: b2JointType; cdecl; { Get the first body attached to this joint.} function GetBodyA: b2BodyHandle; cdecl; { Get the second body attached to this joint.} function GetBodyB: b2BodyHandle; cdecl; { Get the anchor point on bodyA in world coordinates.} function GetAnchorA: b2Vec2; cdecl; { Get the anchor point on bodyB in world coordinates.} function GetAnchorB: b2Vec2; cdecl; { Get the reaction force on bodyB at the joint anchor in Newtons.} function GetReactionForce(inv_dt: Single): b2Vec2; cdecl; { Get the reaction torque on bodyB in N*m.} function GetReactionTorque(inv_dt: Single): Single; cdecl; { Get the next joint the world joint list.} function GetNext: b2JointHandle; cdecl; { Get the user data pointer.} function GetUserData: Pointer; cdecl; { Set the user data pointer.} procedure SetUserData(data: Pointer); cdecl; { Short-cut function to determine if either body is inactive.} function IsActive: Boolean; cdecl; { Get collide connected. Note: modifying the collide connect flag won't work correctly because the flag is only checked when fixture AABBs begin to overlap.} function GetCollideConnected: Boolean; cdecl; { Dump this joint to the log file.} procedure Dump; cdecl; { Shift the origin for any points stored in world coordinates.} procedure ShiftOrigin(const [ref] newOrigin: b2Vec2); cdecl; { Get the first joint.} function GetJoint1: b2JointHandle; cdecl; { Get the second joint.} function GetJoint2: b2JointHandle; cdecl; { Set/Get the gear ratio.} procedure SetRatio(ratio: Single); cdecl; function GetRatio: Single; cdecl; end; { Motor joint definition.} b2MotorJointDef = record &type: b2JointType; { The joint type is set automatically for concrete joint types.} userData: Pointer; { Use this to attach application specific data to your joints.} bodyA: b2BodyHandle; { The first attached body.} bodyB: b2BodyHandle; { The second attached body.} collideConnected: Boolean; { Set this flag to true if the attached bodies should collide.} linearOffset: b2Vec2; { Position of bodyB minus the position of bodyA, in bodyA's frame, in meters.} angularOffset: Single; { The bodyB angle minus bodyA angle in radians.} maxForce: Single; { The maximum motor force in N.} maxTorque: Single; { The maximum motor torque in N-m.} correctionFactor: Single; { Position correction factor in the range [0,1].} class function Create: b2MotorJointDef; static; cdecl; { Initialize the bodies and offsets using the current transforms.} procedure Initialize(bodyA: b2BodyHandle; bodyB: b2BodyHandle); cdecl; end; { A motor joint is used to control the relative motion between two bodies. A typical usage is to control the movement of a dynamic body with respect to the ground.} b2MotorJointWrapper = record FHandle: b2MotorJointHandle; procedure Destroy; cdecl; class operator Implicit(handle: b2MotorJointHandle): b2MotorJointWrapper; overload; class operator Implicit(wrapper: b2MotorJointWrapper): b2MotorJointHandle; overload; { Get the type of the concrete joint.} function GetType: b2JointType; cdecl; { Get the first body attached to this joint.} function GetBodyA: b2BodyHandle; cdecl; { Get the second body attached to this joint.} function GetBodyB: b2BodyHandle; cdecl; { Get the anchor point on bodyA in world coordinates.} function GetAnchorA: b2Vec2; cdecl; { Get the anchor point on bodyB in world coordinates.} function GetAnchorB: b2Vec2; cdecl; { Get the reaction force on bodyB at the joint anchor in Newtons.} function GetReactionForce(inv_dt: Single): b2Vec2; cdecl; { Get the reaction torque on bodyB in N*m.} function GetReactionTorque(inv_dt: Single): Single; cdecl; { Get the next joint the world joint list.} function GetNext: b2JointHandle; cdecl; { Get the user data pointer.} function GetUserData: Pointer; cdecl; { Set the user data pointer.} procedure SetUserData(data: Pointer); cdecl; { Short-cut function to determine if either body is inactive.} function IsActive: Boolean; cdecl; { Get collide connected. Note: modifying the collide connect flag won't work correctly because the flag is only checked when fixture AABBs begin to overlap.} function GetCollideConnected: Boolean; cdecl; { Dump this joint to the log file.} procedure Dump; cdecl; { Shift the origin for any points stored in world coordinates.} procedure ShiftOrigin(const [ref] newOrigin: b2Vec2); cdecl; { Set/get the target linear offset, in frame A, in meters.} procedure SetLinearOffset(const [ref] linearOffset: b2Vec2); cdecl; function GetLinearOffset: Pb2Vec2; cdecl; { Set/get the target angular offset, in radians.} procedure SetAngularOffset(angularOffset: Single); cdecl; function GetAngularOffset: Single; cdecl; { Set the maximum friction force in N.} procedure SetMaxForce(force: Single); cdecl; { Get the maximum friction force in N.} function GetMaxForce: Single; cdecl; { Set the maximum friction torque in N*m.} procedure SetMaxTorque(torque: Single); cdecl; { Get the maximum friction torque in N*m.} function GetMaxTorque: Single; cdecl; { Set the position correction factor in the range [0,1].} procedure SetCorrectionFactor(factor: Single); cdecl; { Get the position correction factor in the range [0,1].} function GetCorrectionFactor: Single; cdecl; end; { Mouse joint definition. This requires a world target point, tuning parameters, and the time step.} b2MouseJointDef = record &type: b2JointType; { The joint type is set automatically for concrete joint types.} userData: Pointer; { Use this to attach application specific data to your joints.} bodyA: b2BodyHandle; { The first attached body.} bodyB: b2BodyHandle; { The second attached body.} collideConnected: Boolean; { Set this flag to true if the attached bodies should collide.} Filler1 : TDWordFiller; target: b2Vec2; { The initial world target point. This is assumed to coincide with the body anchor initially.} maxForce: Single; { The maximum constraint force that can be exerted to move the candidate body. Usually you will express as some multiple of the weight (multiplier * mass * gravity).} frequencyHz: Single; { The response speed.} dampingRatio: Single; { The damping ratio. 0 = no damping, 1 = critical damping.} Filler2 : TDWordFiller; class function Create: b2MouseJointDef; static; cdecl; end; { A mouse joint is used to make a point on a body track a specified world point. This a soft constraint with a maximum force. This allows the constraint to stretch and without applying huge forces. NOTE: this joint is not documented in the manual because it was developed to be used in the testbed. If you want to learn how to use the mouse joint, look at the testbed.} b2MouseJointWrapper = record FHandle: b2MouseJointHandle; procedure Destroy; cdecl; class operator Implicit(handle: b2MouseJointHandle): b2MouseJointWrapper; overload; class operator Implicit(wrapper: b2MouseJointWrapper): b2MouseJointHandle; overload; { Get the type of the concrete joint.} function GetType: b2JointType; cdecl; { Get the first body attached to this joint.} function GetBodyA: b2BodyHandle; cdecl; { Get the second body attached to this joint.} function GetBodyB: b2BodyHandle; cdecl; { Get the anchor point on bodyA in world coordinates.} function GetAnchorA: b2Vec2; cdecl; { Get the anchor point on bodyB in world coordinates.} function GetAnchorB: b2Vec2; cdecl; { Get the reaction force on bodyB at the joint anchor in Newtons.} function GetReactionForce(inv_dt: Single): b2Vec2; cdecl; { Get the reaction torque on bodyB in N*m.} function GetReactionTorque(inv_dt: Single): Single; cdecl; { Get the next joint the world joint list.} function GetNext: b2JointHandle; cdecl; { Get the user data pointer.} function GetUserData: Pointer; cdecl; { Set the user data pointer.} procedure SetUserData(data: Pointer); cdecl; { Short-cut function to determine if either body is inactive.} function IsActive: Boolean; cdecl; { Get collide connected. Note: modifying the collide connect flag won't work correctly because the flag is only checked when fixture AABBs begin to overlap.} function GetCollideConnected: Boolean; cdecl; { Dump this joint to the log file.} procedure Dump; cdecl; { Shift the origin for any points stored in world coordinates.} procedure ShiftOrigin(const [ref] newOrigin: b2Vec2); cdecl; { Use this to update the target point.} procedure SetTarget(const [ref] target: b2Vec2); cdecl; function GetTarget: Pb2Vec2; cdecl; { Set/get the maximum force in Newtons.} procedure SetMaxForce(force: Single); cdecl; function GetMaxForce: Single; cdecl; { Set/get the frequency in Hertz.} procedure SetFrequency(hz: Single); cdecl; function GetFrequency: Single; cdecl; { Set/get the damping ratio (dimensionless).} procedure SetDampingRatio(ratio: Single); cdecl; function GetDampingRatio: Single; cdecl; end; { Prismatic joint definition. This requires defining a line of motion using an axis and an anchor point. The definition uses local anchor points and a local axis so that the initial configuration can violate the constraint slightly. The joint translation is zero when the local anchor points coincide in world space. Using local anchors and a local axis helps when saving and loading a game.} b2PrismaticJointDef = record &type: b2JointType; { The joint type is set automatically for concrete joint types.} userData: Pointer; { Use this to attach application specific data to your joints.} bodyA: b2BodyHandle; { The first attached body.} bodyB: b2BodyHandle; { The second attached body.} collideConnected: Boolean; { Set this flag to true if the attached bodies should collide.} Filler1 : TDWordFiller; localAnchorA: b2Vec2; { The local anchor point relative to bodyA's origin.} localAnchorB: b2Vec2; { The local anchor point relative to bodyB's origin.} localAxisA: b2Vec2; { The local translation unit axis in bodyA.} referenceAngle: Single; { The constrained angle between the bodies: bodyB_angle - bodyA_angle.} enableLimit: Boolean; { Enable/disable the joint limit.} lowerTranslation: Single; { The lower translation limit, usually in meters.} upperTranslation: Single; { The upper translation limit, usually in meters.} enableMotor: Boolean; { Enable/disable the joint motor.} maxMotorForce: Single; { The maximum motor torque, usually in N-m.} motorSpeed: Single; { The desired motor speed in radians per second.} Filler2 : TDWordFiller; class function Create: b2PrismaticJointDef; static; cdecl; { Initialize the bodies, anchors, axis, and reference angle using the world anchor and unit world axis.} procedure Initialize(bodyA: b2BodyHandle; bodyB: b2BodyHandle; const [ref] anchor: b2Vec2; const [ref] axis: b2Vec2); cdecl; end; { A prismatic joint. This joint provides one degree of freedom: translation along an axis fixed in bodyA. Relative rotation is prevented. You can use a joint limit to restrict the range of motion and a joint motor to drive the motion or to model joint friction.} b2PrismaticJointWrapper = record FHandle: b2PrismaticJointHandle; procedure Destroy; cdecl; class operator Implicit(handle: b2PrismaticJointHandle): b2PrismaticJointWrapper; overload; class operator Implicit(wrapper: b2PrismaticJointWrapper): b2PrismaticJointHandle; overload; { Get the type of the concrete joint.} function GetType: b2JointType; cdecl; { Get the first body attached to this joint.} function GetBodyA: b2BodyHandle; cdecl; { Get the second body attached to this joint.} function GetBodyB: b2BodyHandle; cdecl; { Get the anchor point on bodyA in world coordinates.} function GetAnchorA: b2Vec2; cdecl; { Get the anchor point on bodyB in world coordinates.} function GetAnchorB: b2Vec2; cdecl; { Get the reaction force on bodyB at the joint anchor in Newtons.} function GetReactionForce(inv_dt: Single): b2Vec2; cdecl; { Get the reaction torque on bodyB in N*m.} function GetReactionTorque(inv_dt: Single): Single; cdecl; { Get the next joint the world joint list.} function GetNext: b2JointHandle; cdecl; { Get the user data pointer.} function GetUserData: Pointer; cdecl; { Set the user data pointer.} procedure SetUserData(data: Pointer); cdecl; { Short-cut function to determine if either body is inactive.} function IsActive: Boolean; cdecl; { Get collide connected. Note: modifying the collide connect flag won't work correctly because the flag is only checked when fixture AABBs begin to overlap.} function GetCollideConnected: Boolean; cdecl; { Dump this joint to the log file.} procedure Dump; cdecl; { Shift the origin for any points stored in world coordinates.} procedure ShiftOrigin(const [ref] newOrigin: b2Vec2); cdecl; { The local anchor point relative to bodyA's origin.} function GetLocalAnchorA: Pb2Vec2; cdecl; { The local anchor point relative to bodyB's origin.} function GetLocalAnchorB: Pb2Vec2; cdecl; { The local joint axis relative to bodyA.} function GetLocalAxisA: Pb2Vec2; cdecl; { Get the reference angle.} function GetReferenceAngle: Single; cdecl; { Get the current joint translation, usually in meters.} function GetJointTranslation: Single; cdecl; { Get the current joint translation speed, usually in meters per second.} function GetJointSpeed: Single; cdecl; { Is the joint limit enabled?} function IsLimitEnabled: Boolean; cdecl; { Enable/disable the joint limit.} procedure EnableLimit(flag: Boolean); cdecl; { Get the lower joint limit, usually in meters.} function GetLowerLimit: Single; cdecl; { Get the upper joint limit, usually in meters.} function GetUpperLimit: Single; cdecl; { Set the joint limits, usually in meters.} procedure SetLimits(lower: Single; upper: Single); cdecl; { Is the joint motor enabled?} function IsMotorEnabled: Boolean; cdecl; { Enable/disable the joint motor.} procedure EnableMotor(flag: Boolean); cdecl; { Set the motor speed, usually in meters per second.} procedure SetMotorSpeed(speed: Single); cdecl; { Get the motor speed, usually in meters per second.} function GetMotorSpeed: Single; cdecl; { Set the maximum motor force, usually in N.} procedure SetMaxMotorForce(force: Single); cdecl; function GetMaxMotorForce: Single; cdecl; { Get the current motor force given the inverse time step, usually in N.} function GetMotorForce(inv_dt: Single): Single; cdecl; end; { Pulley joint definition. This requires two ground anchors, two dynamic body anchor points, and a pulley ratio.} b2PulleyJointDef = record &type: b2JointType; { The joint type is set automatically for concrete joint types.} userData: Pointer; { Use this to attach application specific data to your joints.} bodyA: b2BodyHandle; { The first attached body.} bodyB: b2BodyHandle; { The second attached body.} collideConnected: Boolean; { Set this flag to true if the attached bodies should collide.} Filler1 : TDWordFiller; groundAnchorA: b2Vec2; { The first ground anchor in world coordinates. This point never moves.} groundAnchorB: b2Vec2; { The second ground anchor in world coordinates. This point never moves.} localAnchorA: b2Vec2; { The local anchor point relative to bodyA's origin.} localAnchorB: b2Vec2; { The local anchor point relative to bodyB's origin.} lengthA: Single; { The a reference length for the segment attached to bodyA.} lengthB: Single; { The a reference length for the segment attached to bodyB.} ratio: Single; { The pulley ratio, used to simulate a block-and-tackle.} Filler2 : TDWordFiller; class function Create: b2PulleyJointDef; static; cdecl; { Initialize the bodies, anchors, lengths, max lengths, and ratio using the world anchors.} procedure Initialize(bodyA: b2BodyHandle; bodyB: b2BodyHandle; const [ref] groundAnchorA: b2Vec2; const [ref] groundAnchorB: b2Vec2; const [ref] anchorA: b2Vec2; const [ref] anchorB: b2Vec2; ratio: Single); cdecl; end; { The pulley joint is connected to two bodies and two fixed ground points. The pulley supports a ratio such that: length1 + ratio * length2 <= constant Yes, the force transmitted is scaled by the ratio. Warning: the pulley joint can get a bit squirrelly by itself. They often work better when combined with prismatic joints. You should also cover the the anchor points with static shapes to prevent one side from going to zero length.} b2PulleyJointWrapper = record FHandle: b2PulleyJointHandle; procedure Destroy; cdecl; class operator Implicit(handle: b2PulleyJointHandle): b2PulleyJointWrapper; overload; class operator Implicit(wrapper: b2PulleyJointWrapper): b2PulleyJointHandle; overload; { Get the type of the concrete joint.} function GetType: b2JointType; cdecl; { Get the first body attached to this joint.} function GetBodyA: b2BodyHandle; cdecl; { Get the second body attached to this joint.} function GetBodyB: b2BodyHandle; cdecl; { Get the anchor point on bodyA in world coordinates.} function GetAnchorA: b2Vec2; cdecl; { Get the anchor point on bodyB in world coordinates.} function GetAnchorB: b2Vec2; cdecl; { Get the reaction force on bodyB at the joint anchor in Newtons.} function GetReactionForce(inv_dt: Single): b2Vec2; cdecl; { Get the reaction torque on bodyB in N*m.} function GetReactionTorque(inv_dt: Single): Single; cdecl; { Get the next joint the world joint list.} function GetNext: b2JointHandle; cdecl; { Get the user data pointer.} function GetUserData: Pointer; cdecl; { Set the user data pointer.} procedure SetUserData(data: Pointer); cdecl; { Short-cut function to determine if either body is inactive.} function IsActive: Boolean; cdecl; { Get collide connected. Note: modifying the collide connect flag won't work correctly because the flag is only checked when fixture AABBs begin to overlap.} function GetCollideConnected: Boolean; cdecl; { Dump this joint to the log file.} procedure Dump; cdecl; { Shift the origin for any points stored in world coordinates.} procedure ShiftOrigin(const [ref] newOrigin: b2Vec2); cdecl; { Get the first ground anchor.} function GetGroundAnchorA: b2Vec2; cdecl; { Get the second ground anchor.} function GetGroundAnchorB: b2Vec2; cdecl; { Get the current length of the segment attached to bodyA.} function GetLengthA: Single; cdecl; { Get the current length of the segment attached to bodyB.} function GetLengthB: Single; cdecl; { Get the pulley ratio.} function GetRatio: Single; cdecl; { Get the current length of the segment attached to bodyA.} function GetCurrentLengthA: Single; cdecl; { Get the current length of the segment attached to bodyB.} function GetCurrentLengthB: Single; cdecl; end; { Revolute joint definition. This requires defining an anchor point where the bodies are joined. The definition uses local anchor points so that the initial configuration can violate the constraint slightly. You also need to specify the initial relative angle for joint limits. This helps when saving and loading a game. The local anchor points are measured from the body's origin rather than the center of mass because: 1. you might not know where the center of mass will be. 2. if you add/remove shapes from a body and recompute the mass, the joints will be broken.} b2RevoluteJointDef = record &type: b2JointType; { The joint type is set automatically for concrete joint types.} userData: Pointer; { Use this to attach application specific data to your joints.} bodyA: b2BodyHandle; { The first attached body.} bodyB: b2BodyHandle; { The second attached body.} collideConnected: Boolean; { Set this flag to true if the attached bodies should collide.} Filler1 : TDWordFiller; localAnchorA: b2Vec2; { The local anchor point relative to bodyA's origin.} localAnchorB: b2Vec2; { The local anchor point relative to bodyB's origin.} referenceAngle: Single; { The bodyB angle minus bodyA angle in the reference state (radians).} enableLimit: Boolean; { A flag to enable joint limits.} lowerAngle: Single; { The lower angle for the joint limit (radians).} upperAngle: Single; { The upper angle for the joint limit (radians).} enableMotor: Boolean; { A flag to enable the joint motor.} motorSpeed: Single; { The desired motor speed. Usually in radians per second.} maxMotorTorque: Single; { The maximum motor torque used to achieve the desired motor speed. Usually in N-m.} Filler2 : TDWordFiller; class function Create: b2RevoluteJointDef; static; cdecl; { Initialize the bodies, anchors, and reference angle using a world anchor point.} procedure Initialize(bodyA: b2BodyHandle; bodyB: b2BodyHandle; const [ref] anchor: b2Vec2); cdecl; end; { A revolute joint constrains two bodies to share a common point while they are free to rotate about the point. The relative rotation about the shared point is the joint angle. You can limit the relative rotation with a joint limit that specifies a lower and upper angle. You can use a motor to drive the relative rotation about the shared point. A maximum motor torque is provided so that infinite forces are not generated.} b2RevoluteJointWrapper = record FHandle: b2RevoluteJointHandle; procedure Destroy; cdecl; class operator Implicit(handle: b2RevoluteJointHandle): b2RevoluteJointWrapper; overload; class operator Implicit(wrapper: b2RevoluteJointWrapper): b2RevoluteJointHandle; overload; { Get the type of the concrete joint.} function GetType: b2JointType; cdecl; { Get the first body attached to this joint.} function GetBodyA: b2BodyHandle; cdecl; { Get the second body attached to this joint.} function GetBodyB: b2BodyHandle; cdecl; { Get the anchor point on bodyA in world coordinates.} function GetAnchorA: b2Vec2; cdecl; { Get the anchor point on bodyB in world coordinates.} function GetAnchorB: b2Vec2; cdecl; { Get the reaction force on bodyB at the joint anchor in Newtons.} function GetReactionForce(inv_dt: Single): b2Vec2; cdecl; { Get the reaction torque on bodyB in N*m.} function GetReactionTorque(inv_dt: Single): Single; cdecl; { Get the next joint the world joint list.} function GetNext: b2JointHandle; cdecl; { Get the user data pointer.} function GetUserData: Pointer; cdecl; { Set the user data pointer.} procedure SetUserData(data: Pointer); cdecl; { Short-cut function to determine if either body is inactive.} function IsActive: Boolean; cdecl; { Get collide connected. Note: modifying the collide connect flag won't work correctly because the flag is only checked when fixture AABBs begin to overlap.} function GetCollideConnected: Boolean; cdecl; { Dump this joint to the log file.} procedure Dump; cdecl; { Shift the origin for any points stored in world coordinates.} procedure ShiftOrigin(const [ref] newOrigin: b2Vec2); cdecl; { The local anchor point relative to bodyA's origin.} function GetLocalAnchorA: Pb2Vec2; cdecl; { The local anchor point relative to bodyB's origin.} function GetLocalAnchorB: Pb2Vec2; cdecl; { Get the reference angle.} function GetReferenceAngle: Single; cdecl; { Get the current joint angle in radians.} function GetJointAngle: Single; cdecl; { Get the current joint angle speed in radians per second.} function GetJointSpeed: Single; cdecl; { Is the joint limit enabled?} function IsLimitEnabled: Boolean; cdecl; { Enable/disable the joint limit.} procedure EnableLimit(flag: Boolean); cdecl; { Get the lower joint limit in radians.} function GetLowerLimit: Single; cdecl; { Get the upper joint limit in radians.} function GetUpperLimit: Single; cdecl; { Set the joint limits in radians.} procedure SetLimits(lower: Single; upper: Single); cdecl; { Is the joint motor enabled?} function IsMotorEnabled: Boolean; cdecl; { Enable/disable the joint motor.} procedure EnableMotor(flag: Boolean); cdecl; { Set the motor speed in radians per second.} procedure SetMotorSpeed(speed: Single); cdecl; { Get the motor speed in radians per second.} function GetMotorSpeed: Single; cdecl; { Set the maximum motor torque, usually in N-m.} procedure SetMaxMotorTorque(torque: Single); cdecl; function GetMaxMotorTorque: Single; cdecl; { Get the current motor torque given the inverse time step. Unit is N*m.} function GetMotorTorque(inv_dt: Single): Single; cdecl; end; { Rope joint definition. This requires two body anchor points and a maximum lengths. Note: by default the connected objects will not collide. see collideConnected in b2JointDef.} b2RopeJointDef = record &type: b2JointType; { The joint type is set automatically for concrete joint types.} userData: Pointer; { Use this to attach application specific data to your joints.} bodyA: b2BodyHandle; { The first attached body.} bodyB: b2BodyHandle; { The second attached body.} collideConnected: Boolean; { Set this flag to true if the attached bodies should collide.} Filler1 : TDWordFiller; localAnchorA: b2Vec2; { The local anchor point relative to bodyA's origin.} localAnchorB: b2Vec2; { The local anchor point relative to bodyB's origin.} maxLength: Single; { The maximum length of the rope. Warning: this must be larger than b2_linearSlop or the joint will have no effect.} Filler2 : TDWordFiller; class function Create: b2RopeJointDef; static; cdecl; end; { A rope joint enforces a maximum distance between two points on two bodies. It has no other effect. Warning: if you attempt to change the maximum length during the simulation you will get some non-physical behavior. A model that would allow you to dynamically modify the length would have some sponginess, so I chose not to implement it that way. See b2DistanceJoint if you want to dynamically control length.} b2RopeJointWrapper = record FHandle: b2RopeJointHandle; procedure Destroy; cdecl; class operator Implicit(handle: b2RopeJointHandle): b2RopeJointWrapper; overload; class operator Implicit(wrapper: b2RopeJointWrapper): b2RopeJointHandle; overload; { Get the type of the concrete joint.} function GetType: b2JointType; cdecl; { Get the first body attached to this joint.} function GetBodyA: b2BodyHandle; cdecl; { Get the second body attached to this joint.} function GetBodyB: b2BodyHandle; cdecl; { Get the anchor point on bodyA in world coordinates.} function GetAnchorA: b2Vec2; cdecl; { Get the anchor point on bodyB in world coordinates.} function GetAnchorB: b2Vec2; cdecl; { Get the reaction force on bodyB at the joint anchor in Newtons.} function GetReactionForce(inv_dt: Single): b2Vec2; cdecl; { Get the reaction torque on bodyB in N*m.} function GetReactionTorque(inv_dt: Single): Single; cdecl; { Get the next joint the world joint list.} function GetNext: b2JointHandle; cdecl; { Get the user data pointer.} function GetUserData: Pointer; cdecl; { Set the user data pointer.} procedure SetUserData(data: Pointer); cdecl; { Short-cut function to determine if either body is inactive.} function IsActive: Boolean; cdecl; { Get collide connected. Note: modifying the collide connect flag won't work correctly because the flag is only checked when fixture AABBs begin to overlap.} function GetCollideConnected: Boolean; cdecl; { Dump this joint to the log file.} procedure Dump; cdecl; { Shift the origin for any points stored in world coordinates.} procedure ShiftOrigin(const [ref] newOrigin: b2Vec2); cdecl; { The local anchor point relative to bodyA's origin.} function GetLocalAnchorA: Pb2Vec2; cdecl; { The local anchor point relative to bodyB's origin.} function GetLocalAnchorB: Pb2Vec2; cdecl; { Set/Get the maximum length of the rope.} procedure SetMaxLength(length: Single); cdecl; function GetMaxLength: Single; cdecl; function GetLimitState: b2LimitState; cdecl; end; { Weld joint definition. You need to specify local anchor points where they are attached and the relative body angle. The position of the anchor points is important for computing the reaction torque.} b2WeldJointDef = record &type: b2JointType; { The joint type is set automatically for concrete joint types.} userData: Pointer; { Use this to attach application specific data to your joints.} bodyA: b2BodyHandle; { The first attached body.} bodyB: b2BodyHandle; { The second attached body.} collideConnected: Boolean; { Set this flag to true if the attached bodies should collide.} Filler1 : TDWordFiller; localAnchorA: b2Vec2; { The local anchor point relative to bodyA's origin.} localAnchorB: b2Vec2; { The local anchor point relative to bodyB's origin.} referenceAngle: Single; { The bodyB angle minus bodyA angle in the reference state (radians).} frequencyHz: Single; { The mass-spring-damper frequency in Hertz. Rotation only. Disable softness with a value of 0.} dampingRatio: Single; { The damping ratio. 0 = no damping, 1 = critical damping.} Filler2 : TDWordFiller; class function Create: b2WeldJointDef; static; cdecl; { Initialize the bodies, anchors, and reference angle using a world anchor point.} procedure Initialize(bodyA: b2BodyHandle; bodyB: b2BodyHandle; const [ref] anchor: b2Vec2); cdecl; end; { A weld joint essentially glues two bodies together. A weld joint may distort somewhat because the island constraint solver is approximate.} b2WeldJointWrapper = record FHandle: b2WeldJointHandle; procedure Destroy; cdecl; class operator Implicit(handle: b2WeldJointHandle): b2WeldJointWrapper; overload; class operator Implicit(wrapper: b2WeldJointWrapper): b2WeldJointHandle; overload; { Get the type of the concrete joint.} function GetType: b2JointType; cdecl; { Get the first body attached to this joint.} function GetBodyA: b2BodyHandle; cdecl; { Get the second body attached to this joint.} function GetBodyB: b2BodyHandle; cdecl; { Get the anchor point on bodyA in world coordinates.} function GetAnchorA: b2Vec2; cdecl; { Get the anchor point on bodyB in world coordinates.} function GetAnchorB: b2Vec2; cdecl; { Get the reaction force on bodyB at the joint anchor in Newtons.} function GetReactionForce(inv_dt: Single): b2Vec2; cdecl; { Get the reaction torque on bodyB in N*m.} function GetReactionTorque(inv_dt: Single): Single; cdecl; { Get the next joint the world joint list.} function GetNext: b2JointHandle; cdecl; { Get the user data pointer.} function GetUserData: Pointer; cdecl; { Set the user data pointer.} procedure SetUserData(data: Pointer); cdecl; { Short-cut function to determine if either body is inactive.} function IsActive: Boolean; cdecl; { Get collide connected. Note: modifying the collide connect flag won't work correctly because the flag is only checked when fixture AABBs begin to overlap.} function GetCollideConnected: Boolean; cdecl; { Dump this joint to the log file.} procedure Dump; cdecl; { Shift the origin for any points stored in world coordinates.} procedure ShiftOrigin(const [ref] newOrigin: b2Vec2); cdecl; { The local anchor point relative to bodyA's origin.} function GetLocalAnchorA: Pb2Vec2; cdecl; { The local anchor point relative to bodyB's origin.} function GetLocalAnchorB: Pb2Vec2; cdecl; { Get the reference angle.} function GetReferenceAngle: Single; cdecl; { Set/get frequency in Hz.} procedure SetFrequency(hz: Single); cdecl; function GetFrequency: Single; cdecl; { Set/get damping ratio.} procedure SetDampingRatio(ratio: Single); cdecl; function GetDampingRatio: Single; cdecl; end; { Wheel joint definition. This requires defining a line of motion using an axis and an anchor point. The definition uses local anchor points and a local axis so that the initial configuration can violate the constraint slightly. The joint translation is zero when the local anchor points coincide in world space. Using local anchors and a local axis helps when saving and loading a game.} b2WheelJointDef = record &type: b2JointType; { The joint type is set automatically for concrete joint types.} userData: Pointer; { Use this to attach application specific data to your joints.} bodyA: b2BodyHandle; { The first attached body.} bodyB: b2BodyHandle; { The second attached body.} collideConnected: Boolean; { Set this flag to true if the attached bodies should collide.} Filler1 : TDWordFiller; localAnchorA: b2Vec2; { The local anchor point relative to bodyA's origin.} localAnchorB: b2Vec2; { The local anchor point relative to bodyB's origin.} localAxisA: b2Vec2; { The local translation axis in bodyA.} enableMotor: Boolean; { Enable/disable the joint motor.} maxMotorTorque: Single; { The maximum motor torque, usually in N-m.} motorSpeed: Single; { The desired motor speed in radians per second.} frequencyHz: Single; { Suspension frequency, zero indicates no suspension} dampingRatio: Single; { Suspension damping ratio, one indicates critical damping} Filler2 : TDWordFiller; class function Create: b2WheelJointDef; static; cdecl; { Initialize the bodies, anchors, axis, and reference angle using the world anchor and world axis.} procedure Initialize(bodyA: b2BodyHandle; bodyB: b2BodyHandle; const [ref] anchor: b2Vec2; const [ref] axis: b2Vec2); cdecl; end; { A wheel joint. This joint provides two degrees of freedom: translation along an axis fixed in bodyA and rotation in the plane. In other words, it is a point to line constraint with a rotational motor and a linear spring/damper. This joint is designed for vehicle suspensions.} b2WheelJointWrapper = record FHandle: b2WheelJointHandle; procedure Destroy; cdecl; class operator Implicit(handle: b2WheelJointHandle): b2WheelJointWrapper; overload; class operator Implicit(wrapper: b2WheelJointWrapper): b2WheelJointHandle; overload; { Get the type of the concrete joint.} function GetType: b2JointType; cdecl; { Get the first body attached to this joint.} function GetBodyA: b2BodyHandle; cdecl; { Get the second body attached to this joint.} function GetBodyB: b2BodyHandle; cdecl; { Get the anchor point on bodyA in world coordinates.} function GetAnchorA: b2Vec2; cdecl; { Get the anchor point on bodyB in world coordinates.} function GetAnchorB: b2Vec2; cdecl; { Get the reaction force on bodyB at the joint anchor in Newtons.} function GetReactionForce(inv_dt: Single): b2Vec2; cdecl; { Get the reaction torque on bodyB in N*m.} function GetReactionTorque(inv_dt: Single): Single; cdecl; { Get the next joint the world joint list.} function GetNext: b2JointHandle; cdecl; { Get the user data pointer.} function GetUserData: Pointer; cdecl; { Set the user data pointer.} procedure SetUserData(data: Pointer); cdecl; { Short-cut function to determine if either body is inactive.} function IsActive: Boolean; cdecl; { Get collide connected. Note: modifying the collide connect flag won't work correctly because the flag is only checked when fixture AABBs begin to overlap.} function GetCollideConnected: Boolean; cdecl; { Dump this joint to the log file.} procedure Dump; cdecl; { Shift the origin for any points stored in world coordinates.} procedure ShiftOrigin(const [ref] newOrigin: b2Vec2); cdecl; { The local anchor point relative to bodyA's origin.} function GetLocalAnchorA: Pb2Vec2; cdecl; { The local anchor point relative to bodyB's origin.} function GetLocalAnchorB: Pb2Vec2; cdecl; { The local joint axis relative to bodyA.} function GetLocalAxisA: Pb2Vec2; cdecl; { Get the current joint translation, usually in meters.} function GetJointTranslation: Single; cdecl; { Get the current joint translation speed, usually in meters per second.} function GetJointSpeed: Single; cdecl; { Is the joint motor enabled?} function IsMotorEnabled: Boolean; cdecl; { Enable/disable the joint motor.} procedure EnableMotor(flag: Boolean); cdecl; { Set the motor speed, usually in radians per second.} procedure SetMotorSpeed(speed: Single); cdecl; { Get the motor speed, usually in radians per second.} function GetMotorSpeed: Single; cdecl; { Set/Get the maximum motor force, usually in N-m.} procedure SetMaxMotorTorque(torque: Single); cdecl; function GetMaxMotorTorque: Single; cdecl; { Get the current motor torque given the inverse time step, usually in N-m.} function GetMotorTorque(inv_dt: Single): Single; cdecl; { Set/Get the spring frequency in hertz. Setting the frequency to zero disables the spring.} procedure SetSpringFrequencyHz(hz: Single); cdecl; function GetSpringFrequencyHz: Single; cdecl; { Set/Get the spring damping ratio} procedure SetSpringDampingRatio(ratio: Single); cdecl; function GetSpringDampingRatio: Single; cdecl; end; { ===== Delegate interfaces ===== } Ib2DestructionListener = interface ['{2DDB25E4-9B99-E391-EF9A-62D1BDC2ABAC}'] procedure SayGoodbye(joint: b2JointHandle); overload; cdecl; procedure SayGoodbye(fixture: Pb2Fixture); overload; cdecl; end; Ib2ContactFilter = interface ['{9BE3CC10-3001-AA1F-3A69-3AF908806081}'] function ShouldCollide(fixtureA: Pb2Fixture; fixtureB: Pb2Fixture): Boolean; cdecl; end; Ib2ContactListener = interface ['{457D45B8-C600-3A28-CE8D-7ED8741412D8}'] procedure BeginContact(contact: b2ContactHandle); cdecl; procedure EndContact(contact: b2ContactHandle); cdecl; procedure PreSolve(contact: b2ContactHandle; oldManifold: Pb2Manifold); cdecl; procedure PostSolve(contact: b2ContactHandle; impulse: Pb2ContactImpulse); cdecl; end; Ib2QueryCallback = interface ['{FA12D838-B458-10AB-2E02-61056056D805}'] function ReportFixture(fixture: Pb2Fixture): Boolean; cdecl; end; Ib2RayCastCallback = interface ['{8E1114AB-969E-8C96-98C4-41096DDCBFA5}'] function ReportFixture(fixture: Pb2Fixture; const [ref] point: b2Vec2; const [ref] normal: b2Vec2; fraction: Single): Single; cdecl; end; { ===== CreateDestroy of Delegate interfaces ===== } function Create_b2DestructionListener_delegate(Intf: Ib2DestructionListener): b2DestructionListenerHandle; cdecl; procedure Destroy_b2DestructionListener_delegate(handle: b2DestructionListenerHandle); cdecl; function Create_b2ContactFilter_delegate(Intf: Ib2ContactFilter): b2ContactFilterHandle; cdecl; procedure Destroy_b2ContactFilter_delegate(handle: b2ContactFilterHandle); cdecl; function Create_b2ContactListener_delegate(Intf: Ib2ContactListener): b2ContactListenerHandle; cdecl; procedure Destroy_b2ContactListener_delegate(handle: b2ContactListenerHandle); cdecl; function Create_b2QueryCallback_delegate(Intf: Ib2QueryCallback): b2QueryCallbackHandle; cdecl; procedure Destroy_b2QueryCallback_delegate(handle: b2QueryCallbackHandle); cdecl; function Create_b2RayCastCallback_delegate(Intf: Ib2RayCastCallback): b2RayCastCallbackHandle; cdecl; procedure Destroy_b2RayCastCallback_delegate(handle: b2RayCastCallbackHandle); cdecl; function b2MixFriction(friction1: Single; friction2: Single): Single; cdecl; function b2MixRestitution(restitution1: Single; restitution2: Single): Single; cdecl; implementation const {$IFDEF MSWINDOWS} LIB_NAME = 'FlatBox2DDyn.dll'; {$IFDEF WIN64} _PU = ''; {$ELSE} _PU = '_'; {$ENDIF} {$ENDIF} {$IFDEF ANDROID} LIB_NAME = 'libFlatBox2D.a'; _PU = ''; {$ENDIF} {$IFDEF MACOS} {$IFDEF IOS} LIB_NAME = 'libFlatBox2D.a'; {$ELSE} LIB_NAME = 'libFlatBox2DDyn.dylib'; {$ENDIF} {$IFDEF UNDERSCOREIMPORTNAME} _PU = '_'; {$ELSE} _PU = ''; {$ENDIF} {$ENDIF} function Create_b2DestructionListener_delegate; cdecl; external LIB_NAME name _PU + 'Create_b2DestructionListener_delegate' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure Destroy_b2DestructionListener_delegate; cdecl; external LIB_NAME name _PU + 'Destroy_b2DestructionListener_delegate' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function Create_b2ContactFilter_delegate; cdecl; external LIB_NAME name _PU + 'Create_b2ContactFilter_delegate' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure Destroy_b2ContactFilter_delegate; cdecl; external LIB_NAME name _PU + 'Destroy_b2ContactFilter_delegate' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function Create_b2ContactListener_delegate; cdecl; external LIB_NAME name _PU + 'Create_b2ContactListener_delegate' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure Destroy_b2ContactListener_delegate; cdecl; external LIB_NAME name _PU + 'Destroy_b2ContactListener_delegate' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function Create_b2QueryCallback_delegate; cdecl; external LIB_NAME name _PU + 'Create_b2QueryCallback_delegate' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure Destroy_b2QueryCallback_delegate; cdecl; external LIB_NAME name _PU + 'Destroy_b2QueryCallback_delegate' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function Create_b2RayCastCallback_delegate; cdecl; external LIB_NAME name _PU + 'Create_b2RayCastCallback_delegate' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure Destroy_b2RayCastCallback_delegate; cdecl; external LIB_NAME name _PU + 'Destroy_b2RayCastCallback_delegate' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; { ===== Record methods: import and definition ===== } function b2BodyDef_Create: b2BodyDef; cdecl; external LIB_NAME name _PU + 'b2BodyDef_b2BodyDef_1' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; class function b2BodyDef.Create: b2BodyDef; cdecl; begin Result := b2BodyDef_Create; end; class operator b2BodyWrapper.Implicit(handle: b2BodyHandle): b2BodyWrapper; begin Result.FHandle := handle; end; class operator b2BodyWrapper.Implicit(wrapper: b2BodyWrapper): b2BodyHandle; begin Result := wrapper.FHandle; end; function b2Body_CreateFixture(_self: b2BodyHandle; def: Pb2FixtureDef): Pb2Fixture; overload; cdecl; external LIB_NAME name _PU + 'b2Body_CreateFixture' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2BodyWrapper.CreateFixture(def: Pb2FixtureDef): Pb2Fixture; cdecl; begin Result := b2Body_CreateFixture(FHandle, def) end; function b2Body_CreateFixture(_self: b2BodyHandle; shape: b2ShapeHandle; density: Single): Pb2Fixture; overload; cdecl; external LIB_NAME name _PU + 'b2Body_CreateFixture2' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2BodyWrapper.CreateFixture(shape: b2ShapeHandle; density: Single): Pb2Fixture; cdecl; begin Result := b2Body_CreateFixture(FHandle, shape, density) end; procedure b2Body_DestroyFixture(_self: b2BodyHandle; fixture: Pb2Fixture); cdecl; external LIB_NAME name _PU + 'b2Body_DestroyFixture' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2BodyWrapper.DestroyFixture(fixture: Pb2Fixture); cdecl; begin b2Body_DestroyFixture(FHandle, fixture) end; procedure b2Body_SetTransform(_self: b2BodyHandle; const [ref] position: b2Vec2; angle: Single); cdecl; external LIB_NAME name _PU + 'b2Body_SetTransform' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2BodyWrapper.SetTransform(const [ref] position: b2Vec2; angle: Single); cdecl; begin b2Body_SetTransform(FHandle, position, angle) end; function b2Body_GetTransform(_self: b2BodyHandle): Pb2Transform; cdecl; external LIB_NAME name _PU + 'b2Body_GetTransform' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2BodyWrapper.GetTransform: Pb2Transform; cdecl; begin Result := b2Body_GetTransform(FHandle) end; function b2Body_GetPosition(_self: b2BodyHandle): Pb2Vec2; cdecl; external LIB_NAME name _PU + 'b2Body_GetPosition' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2BodyWrapper.GetPosition: Pb2Vec2; cdecl; begin Result := b2Body_GetPosition(FHandle) end; function b2Body_GetAngle(_self: b2BodyHandle): Single; cdecl; external LIB_NAME name _PU + 'b2Body_GetAngle' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2BodyWrapper.GetAngle: Single; cdecl; begin Result := b2Body_GetAngle(FHandle) end; function b2Body_GetWorldCenter(_self: b2BodyHandle): Pb2Vec2; cdecl; external LIB_NAME name _PU + 'b2Body_GetWorldCenter' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2BodyWrapper.GetWorldCenter: Pb2Vec2; cdecl; begin Result := b2Body_GetWorldCenter(FHandle) end; function b2Body_GetLocalCenter(_self: b2BodyHandle): Pb2Vec2; cdecl; external LIB_NAME name _PU + 'b2Body_GetLocalCenter' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2BodyWrapper.GetLocalCenter: Pb2Vec2; cdecl; begin Result := b2Body_GetLocalCenter(FHandle) end; procedure b2Body_SetLinearVelocity(_self: b2BodyHandle; const [ref] v: b2Vec2); cdecl; external LIB_NAME name _PU + 'b2Body_SetLinearVelocity' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2BodyWrapper.SetLinearVelocity(const [ref] v: b2Vec2); cdecl; begin b2Body_SetLinearVelocity(FHandle, v) end; function b2Body_GetLinearVelocity(_self: b2BodyHandle): Pb2Vec2; cdecl; external LIB_NAME name _PU + 'b2Body_GetLinearVelocity' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2BodyWrapper.GetLinearVelocity: Pb2Vec2; cdecl; begin Result := b2Body_GetLinearVelocity(FHandle) end; procedure b2Body_SetAngularVelocity(_self: b2BodyHandle; omega: Single); cdecl; external LIB_NAME name _PU + 'b2Body_SetAngularVelocity' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2BodyWrapper.SetAngularVelocity(omega: Single); cdecl; begin b2Body_SetAngularVelocity(FHandle, omega) end; function b2Body_GetAngularVelocity(_self: b2BodyHandle): Single; cdecl; external LIB_NAME name _PU + 'b2Body_GetAngularVelocity' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2BodyWrapper.GetAngularVelocity: Single; cdecl; begin Result := b2Body_GetAngularVelocity(FHandle) end; procedure b2Body_ApplyForce(_self: b2BodyHandle; const [ref] force: b2Vec2; const [ref] point: b2Vec2; wake: Boolean); cdecl; external LIB_NAME name _PU + 'b2Body_ApplyForce' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2BodyWrapper.ApplyForce(const [ref] force: b2Vec2; const [ref] point: b2Vec2; wake: Boolean); cdecl; begin b2Body_ApplyForce(FHandle, force, point, wake) end; procedure b2Body_ApplyForceToCenter(_self: b2BodyHandle; const [ref] force: b2Vec2; wake: Boolean); cdecl; external LIB_NAME name _PU + 'b2Body_ApplyForceToCenter' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2BodyWrapper.ApplyForceToCenter(const [ref] force: b2Vec2; wake: Boolean); cdecl; begin b2Body_ApplyForceToCenter(FHandle, force, wake) end; procedure b2Body_ApplyTorque(_self: b2BodyHandle; torque: Single; wake: Boolean); cdecl; external LIB_NAME name _PU + 'b2Body_ApplyTorque' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2BodyWrapper.ApplyTorque(torque: Single; wake: Boolean); cdecl; begin b2Body_ApplyTorque(FHandle, torque, wake) end; procedure b2Body_ApplyLinearImpulse(_self: b2BodyHandle; const [ref] impulse: b2Vec2; const [ref] point: b2Vec2; wake: Boolean); cdecl; external LIB_NAME name _PU + 'b2Body_ApplyLinearImpulse' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2BodyWrapper.ApplyLinearImpulse(const [ref] impulse: b2Vec2; const [ref] point: b2Vec2; wake: Boolean); cdecl; begin b2Body_ApplyLinearImpulse(FHandle, impulse, point, wake) end; procedure b2Body_ApplyAngularImpulse(_self: b2BodyHandle; impulse: Single; wake: Boolean); cdecl; external LIB_NAME name _PU + 'b2Body_ApplyAngularImpulse' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2BodyWrapper.ApplyAngularImpulse(impulse: Single; wake: Boolean); cdecl; begin b2Body_ApplyAngularImpulse(FHandle, impulse, wake) end; function b2Body_GetMass(_self: b2BodyHandle): Single; cdecl; external LIB_NAME name _PU + 'b2Body_GetMass' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2BodyWrapper.GetMass: Single; cdecl; begin Result := b2Body_GetMass(FHandle) end; function b2Body_GetInertia(_self: b2BodyHandle): Single; cdecl; external LIB_NAME name _PU + 'b2Body_GetInertia' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2BodyWrapper.GetInertia: Single; cdecl; begin Result := b2Body_GetInertia(FHandle) end; procedure b2Body_GetMassData(_self: b2BodyHandle; data: Pb2MassData); cdecl; external LIB_NAME name _PU + 'b2Body_GetMassData' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2BodyWrapper.GetMassData(data: Pb2MassData); cdecl; begin b2Body_GetMassData(FHandle, data) end; procedure b2Body_SetMassData(_self: b2BodyHandle; data: Pb2MassData); cdecl; external LIB_NAME name _PU + 'b2Body_SetMassData' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2BodyWrapper.SetMassData(data: Pb2MassData); cdecl; begin b2Body_SetMassData(FHandle, data) end; procedure b2Body_ResetMassData(_self: b2BodyHandle); cdecl; external LIB_NAME name _PU + 'b2Body_ResetMassData' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2BodyWrapper.ResetMassData; cdecl; begin b2Body_ResetMassData(FHandle) end; function b2Body_GetWorldPoint(_self: b2BodyHandle; const [ref] localPoint: b2Vec2): b2Vec2; cdecl; external LIB_NAME name _PU + 'b2Body_GetWorldPoint' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2BodyWrapper.GetWorldPoint(const [ref] localPoint: b2Vec2): b2Vec2; cdecl; begin Result := b2Body_GetWorldPoint(FHandle, localPoint) end; function b2Body_GetWorldVector(_self: b2BodyHandle; const [ref] localVector: b2Vec2): b2Vec2; cdecl; external LIB_NAME name _PU + 'b2Body_GetWorldVector' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2BodyWrapper.GetWorldVector(const [ref] localVector: b2Vec2): b2Vec2; cdecl; begin Result := b2Body_GetWorldVector(FHandle, localVector) end; function b2Body_GetLocalPoint(_self: b2BodyHandle; const [ref] worldPoint: b2Vec2): b2Vec2; cdecl; external LIB_NAME name _PU + 'b2Body_GetLocalPoint' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2BodyWrapper.GetLocalPoint(const [ref] worldPoint: b2Vec2): b2Vec2; cdecl; begin Result := b2Body_GetLocalPoint(FHandle, worldPoint) end; function b2Body_GetLocalVector(_self: b2BodyHandle; const [ref] worldVector: b2Vec2): b2Vec2; cdecl; external LIB_NAME name _PU + 'b2Body_GetLocalVector' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2BodyWrapper.GetLocalVector(const [ref] worldVector: b2Vec2): b2Vec2; cdecl; begin Result := b2Body_GetLocalVector(FHandle, worldVector) end; function b2Body_GetLinearVelocityFromWorldPoint(_self: b2BodyHandle; const [ref] worldPoint: b2Vec2): b2Vec2; cdecl; external LIB_NAME name _PU + 'b2Body_GetLinearVelocityFromWorldPoint' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2BodyWrapper.GetLinearVelocityFromWorldPoint(const [ref] worldPoint: b2Vec2): b2Vec2; cdecl; begin Result := b2Body_GetLinearVelocityFromWorldPoint(FHandle, worldPoint) end; function b2Body_GetLinearVelocityFromLocalPoint(_self: b2BodyHandle; const [ref] localPoint: b2Vec2): b2Vec2; cdecl; external LIB_NAME name _PU + 'b2Body_GetLinearVelocityFromLocalPoint' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2BodyWrapper.GetLinearVelocityFromLocalPoint(const [ref] localPoint: b2Vec2): b2Vec2; cdecl; begin Result := b2Body_GetLinearVelocityFromLocalPoint(FHandle, localPoint) end; function b2Body_GetLinearDamping(_self: b2BodyHandle): Single; cdecl; external LIB_NAME name _PU + 'b2Body_GetLinearDamping' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2BodyWrapper.GetLinearDamping: Single; cdecl; begin Result := b2Body_GetLinearDamping(FHandle) end; procedure b2Body_SetLinearDamping(_self: b2BodyHandle; linearDamping: Single); cdecl; external LIB_NAME name _PU + 'b2Body_SetLinearDamping' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2BodyWrapper.SetLinearDamping(linearDamping: Single); cdecl; begin b2Body_SetLinearDamping(FHandle, linearDamping) end; function b2Body_GetAngularDamping(_self: b2BodyHandle): Single; cdecl; external LIB_NAME name _PU + 'b2Body_GetAngularDamping' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2BodyWrapper.GetAngularDamping: Single; cdecl; begin Result := b2Body_GetAngularDamping(FHandle) end; procedure b2Body_SetAngularDamping(_self: b2BodyHandle; angularDamping: Single); cdecl; external LIB_NAME name _PU + 'b2Body_SetAngularDamping' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2BodyWrapper.SetAngularDamping(angularDamping: Single); cdecl; begin b2Body_SetAngularDamping(FHandle, angularDamping) end; function b2Body_GetGravityScale(_self: b2BodyHandle): Single; cdecl; external LIB_NAME name _PU + 'b2Body_GetGravityScale' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2BodyWrapper.GetGravityScale: Single; cdecl; begin Result := b2Body_GetGravityScale(FHandle) end; procedure b2Body_SetGravityScale(_self: b2BodyHandle; scale: Single); cdecl; external LIB_NAME name _PU + 'b2Body_SetGravityScale' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2BodyWrapper.SetGravityScale(scale: Single); cdecl; begin b2Body_SetGravityScale(FHandle, scale) end; procedure b2Body_SetType(_self: b2BodyHandle; _type: b2BodyType); cdecl; external LIB_NAME name _PU + 'b2Body_SetType' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2BodyWrapper.SetType(_type: b2BodyType); cdecl; begin b2Body_SetType(FHandle, _type) end; function b2Body_GetType(_self: b2BodyHandle): b2BodyType; cdecl; external LIB_NAME name _PU + 'b2Body_GetType' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2BodyWrapper.GetType: b2BodyType; cdecl; begin Result := b2Body_GetType(FHandle) end; procedure b2Body_SetBullet(_self: b2BodyHandle; flag: Boolean); cdecl; external LIB_NAME name _PU + 'b2Body_SetBullet' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2BodyWrapper.SetBullet(flag: Boolean); cdecl; begin b2Body_SetBullet(FHandle, flag) end; function b2Body_IsBullet(_self: b2BodyHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2Body_IsBullet' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2BodyWrapper.IsBullet: Boolean; cdecl; begin Result := b2Body_IsBullet(FHandle) end; procedure b2Body_SetSleepingAllowed(_self: b2BodyHandle; flag: Boolean); cdecl; external LIB_NAME name _PU + 'b2Body_SetSleepingAllowed' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2BodyWrapper.SetSleepingAllowed(flag: Boolean); cdecl; begin b2Body_SetSleepingAllowed(FHandle, flag) end; function b2Body_IsSleepingAllowed(_self: b2BodyHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2Body_IsSleepingAllowed' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2BodyWrapper.IsSleepingAllowed: Boolean; cdecl; begin Result := b2Body_IsSleepingAllowed(FHandle) end; procedure b2Body_SetAwake(_self: b2BodyHandle; flag: Boolean); cdecl; external LIB_NAME name _PU + 'b2Body_SetAwake' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2BodyWrapper.SetAwake(flag: Boolean); cdecl; begin b2Body_SetAwake(FHandle, flag) end; function b2Body_IsAwake(_self: b2BodyHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2Body_IsAwake' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2BodyWrapper.IsAwake: Boolean; cdecl; begin Result := b2Body_IsAwake(FHandle) end; procedure b2Body_SetActive(_self: b2BodyHandle; flag: Boolean); cdecl; external LIB_NAME name _PU + 'b2Body_SetActive' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2BodyWrapper.SetActive(flag: Boolean); cdecl; begin b2Body_SetActive(FHandle, flag) end; function b2Body_IsActive(_self: b2BodyHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2Body_IsActive' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2BodyWrapper.IsActive: Boolean; cdecl; begin Result := b2Body_IsActive(FHandle) end; procedure b2Body_SetFixedRotation(_self: b2BodyHandle; flag: Boolean); cdecl; external LIB_NAME name _PU + 'b2Body_SetFixedRotation' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2BodyWrapper.SetFixedRotation(flag: Boolean); cdecl; begin b2Body_SetFixedRotation(FHandle, flag) end; function b2Body_IsFixedRotation(_self: b2BodyHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2Body_IsFixedRotation' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2BodyWrapper.IsFixedRotation: Boolean; cdecl; begin Result := b2Body_IsFixedRotation(FHandle) end; function b2Body_GetFixtureList(_self: b2BodyHandle): Pb2Fixture; cdecl; external LIB_NAME name _PU + 'b2Body_GetFixtureList' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2BodyWrapper.GetFixtureList: Pb2Fixture; cdecl; begin Result := b2Body_GetFixtureList(FHandle) end; function b2Body_GetJointList(_self: b2BodyHandle): Pb2JointEdge; cdecl; external LIB_NAME name _PU + 'b2Body_GetJointList' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2BodyWrapper.GetJointList: Pb2JointEdge; cdecl; begin Result := b2Body_GetJointList(FHandle) end; function b2Body_GetContactList(_self: b2BodyHandle): Pb2ContactEdge; cdecl; external LIB_NAME name _PU + 'b2Body_GetContactList' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2BodyWrapper.GetContactList: Pb2ContactEdge; cdecl; begin Result := b2Body_GetContactList(FHandle) end; function b2Body_GetNext(_self: b2BodyHandle): b2BodyHandle; cdecl; external LIB_NAME name _PU + 'b2Body_GetNext' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2BodyWrapper.GetNext: b2BodyHandle; cdecl; begin Result := b2Body_GetNext(FHandle) end; function b2Body_GetUserData(_self: b2BodyHandle): Pointer; cdecl; external LIB_NAME name _PU + 'b2Body_GetUserData' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2BodyWrapper.GetUserData: Pointer; cdecl; begin Result := b2Body_GetUserData(FHandle) end; procedure b2Body_SetUserData(_self: b2BodyHandle; data: Pointer); cdecl; external LIB_NAME name _PU + 'b2Body_SetUserData' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2BodyWrapper.SetUserData(data: Pointer); cdecl; begin b2Body_SetUserData(FHandle, data) end; function b2Body_GetWorld(_self: b2BodyHandle): b2WorldHandle; cdecl; external LIB_NAME name _PU + 'b2Body_GetWorld' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2BodyWrapper.GetWorld: b2WorldHandle; cdecl; begin Result := b2Body_GetWorld(FHandle) end; procedure b2Body_Dump(_self: b2BodyHandle); cdecl; external LIB_NAME name _PU + 'b2Body_Dump' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2BodyWrapper.Dump; cdecl; begin b2Body_Dump(FHandle) end; function b2ContactManager_Create: b2ContactManagerHandle; cdecl; external LIB_NAME name _PU + 'b2ContactManager_b2ContactManager_1' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; class function b2ContactManagerWrapper.Create: b2ContactManagerWrapper; cdecl; begin Result.FHandle := b2ContactManager_Create; end; procedure b2ContactManager_Destroy(_self: b2ContactManagerHandle); cdecl; external LIB_NAME name _PU + 'b2ContactManager_dtor' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ContactManagerWrapper.Destroy; cdecl; begin b2ContactManager_Destroy(FHandle); end; class operator b2ContactManagerWrapper.Implicit(handle: b2ContactManagerHandle): b2ContactManagerWrapper; begin Result.FHandle := handle; end; class operator b2ContactManagerWrapper.Implicit(wrapper: b2ContactManagerWrapper): b2ContactManagerHandle; begin Result := wrapper.FHandle; end; procedure b2ContactManager_AddPair(_self: b2ContactManagerHandle; proxyUserDataA: Pointer; proxyUserDataB: Pointer); cdecl; external LIB_NAME name _PU + 'b2ContactManager_AddPair' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ContactManagerWrapper.AddPair(proxyUserDataA: Pointer; proxyUserDataB: Pointer); cdecl; begin b2ContactManager_AddPair(FHandle, proxyUserDataA, proxyUserDataB) end; procedure b2ContactManager_FindNewContacts(_self: b2ContactManagerHandle); cdecl; external LIB_NAME name _PU + 'b2ContactManager_FindNewContacts' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ContactManagerWrapper.FindNewContacts; cdecl; begin b2ContactManager_FindNewContacts(FHandle) end; procedure b2ContactManager_Destroy_(_self: b2ContactManagerHandle; c: b2ContactHandle); cdecl; external LIB_NAME name _PU + 'b2ContactManager_Destroy' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ContactManagerWrapper.Destroy_(c: b2ContactHandle); cdecl; begin b2ContactManager_Destroy_(FHandle, c) end; procedure b2ContactManager_Collide(_self: b2ContactManagerHandle); cdecl; external LIB_NAME name _PU + 'b2ContactManager_Collide' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ContactManagerWrapper.Collide; cdecl; begin b2ContactManager_Collide(FHandle) end; function b2ContactManager_Get_m_broadPhase(_self: b2ContactManagerHandle): b2BroadPhaseHandle; cdecl; external LIB_NAME name _PU + 'b2ContactManager_Get_m_broadPhase' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ContactManager_Set_m_broadPhase(_self: b2ContactManagerHandle; aNewValue: b2BroadPhaseHandle); cdecl; external LIB_NAME name _PU + 'b2ContactManager_Set_m_broadPhase' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ContactManagerWrapper.Get_m_broadPhase: b2BroadPhaseHandle; cdecl; begin Result := b2ContactManager_Get_m_broadPhase(FHandle); end; procedure b2ContactManagerWrapper.Set_m_broadPhase(aNewValue: b2BroadPhaseHandle); cdecl; begin b2ContactManager_Set_m_broadPhase(FHandle, aNewValue); end; function b2ContactManager_Get_m_contactList(_self: b2ContactManagerHandle): b2ContactHandle; cdecl; external LIB_NAME name _PU + 'b2ContactManager_Get_m_contactList' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ContactManager_Set_m_contactList(_self: b2ContactManagerHandle; aNewValue: b2ContactHandle); cdecl; external LIB_NAME name _PU + 'b2ContactManager_Set_m_contactList' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ContactManagerWrapper.Get_m_contactList: b2ContactHandle; cdecl; begin Result := b2ContactManager_Get_m_contactList(FHandle); end; procedure b2ContactManagerWrapper.Set_m_contactList(aNewValue: b2ContactHandle); cdecl; begin b2ContactManager_Set_m_contactList(FHandle, aNewValue); end; function b2ContactManager_Get_m_contactCount(_self: b2ContactManagerHandle): Integer; cdecl; external LIB_NAME name _PU + 'b2ContactManager_Get_m_contactCount' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ContactManager_Set_m_contactCount(_self: b2ContactManagerHandle; aNewValue: Integer); cdecl; external LIB_NAME name _PU + 'b2ContactManager_Set_m_contactCount' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ContactManagerWrapper.Get_m_contactCount: Integer; cdecl; begin Result := b2ContactManager_Get_m_contactCount(FHandle); end; procedure b2ContactManagerWrapper.Set_m_contactCount(aNewValue: Integer); cdecl; begin b2ContactManager_Set_m_contactCount(FHandle, aNewValue); end; function b2ContactManager_Get_m_contactFilter(_self: b2ContactManagerHandle): b2ContactFilterHandle; cdecl; external LIB_NAME name _PU + 'b2ContactManager_Get_m_contactFilter' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ContactManager_Set_m_contactFilter(_self: b2ContactManagerHandle; aNewValue: b2ContactFilterHandle); cdecl; external LIB_NAME name _PU + 'b2ContactManager_Set_m_contactFilter' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ContactManagerWrapper.Get_m_contactFilter: b2ContactFilterHandle; cdecl; begin Result := b2ContactManager_Get_m_contactFilter(FHandle); end; procedure b2ContactManagerWrapper.Set_m_contactFilter(aNewValue: b2ContactFilterHandle); cdecl; begin b2ContactManager_Set_m_contactFilter(FHandle, aNewValue); end; function b2ContactManager_Get_m_contactListener(_self: b2ContactManagerHandle): b2ContactListenerHandle; cdecl; external LIB_NAME name _PU + 'b2ContactManager_Get_m_contactListener' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ContactManager_Set_m_contactListener(_self: b2ContactManagerHandle; aNewValue: b2ContactListenerHandle); cdecl; external LIB_NAME name _PU + 'b2ContactManager_Set_m_contactListener' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ContactManagerWrapper.Get_m_contactListener: b2ContactListenerHandle; cdecl; begin Result := b2ContactManager_Get_m_contactListener(FHandle); end; procedure b2ContactManagerWrapper.Set_m_contactListener(aNewValue: b2ContactListenerHandle); cdecl; begin b2ContactManager_Set_m_contactListener(FHandle, aNewValue); end; function b2ContactManager_Get_m_allocator(_self: b2ContactManagerHandle): b2BlockAllocatorHandle; cdecl; external LIB_NAME name _PU + 'b2ContactManager_Get_m_allocator' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ContactManager_Set_m_allocator(_self: b2ContactManagerHandle; aNewValue: b2BlockAllocatorHandle); cdecl; external LIB_NAME name _PU + 'b2ContactManager_Set_m_allocator' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ContactManagerWrapper.Get_m_allocator: b2BlockAllocatorHandle; cdecl; begin Result := b2ContactManager_Get_m_allocator(FHandle); end; procedure b2ContactManagerWrapper.Set_m_allocator(aNewValue: b2BlockAllocatorHandle); cdecl; begin b2ContactManager_Set_m_allocator(FHandle, aNewValue); end; function b2Filter_Create: b2Filter; cdecl; external LIB_NAME name _PU + 'b2Filter_b2Filter_1' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; class function b2Filter.Create: b2Filter; cdecl; begin Result := b2Filter_Create; end; function b2FixtureDef_Create: b2FixtureDef; cdecl; external LIB_NAME name _PU + 'b2FixtureDef_b2FixtureDef_1' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; class function b2FixtureDef.Create: b2FixtureDef; cdecl; begin Result := b2FixtureDef_Create; end; function b2FixtureProxy_Create: b2FixtureProxy; cdecl; external LIB_NAME name _PU + 'b2FixtureProxy_b2FixtureProxy' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; class function b2FixtureProxy.Create: b2FixtureProxy; cdecl; begin Result := b2FixtureProxy_Create; end; function b2Fixture_GetType(_self: Pb2Fixture): Integer; cdecl; external LIB_NAME name _PU + 'b2Fixture_GetType' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2Fixture.GetType: Integer; cdecl; begin Result := b2Fixture_GetType(@Self) end; function b2Fixture_GetShape(_self: Pb2Fixture): b2ShapeHandle; cdecl; external LIB_NAME name _PU + 'b2Fixture_GetShape' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2Fixture.GetShape: b2ShapeHandle; cdecl; begin Result := b2Fixture_GetShape(@Self) end; procedure b2Fixture_SetSensor(_self: Pb2Fixture; sensor: Boolean); cdecl; external LIB_NAME name _PU + 'b2Fixture_SetSensor' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2Fixture.SetSensor(sensor: Boolean); cdecl; begin b2Fixture_SetSensor(@Self, sensor) end; function b2Fixture_IsSensor(_self: Pb2Fixture): Boolean; cdecl; external LIB_NAME name _PU + 'b2Fixture_IsSensor' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2Fixture.IsSensor: Boolean; cdecl; begin Result := b2Fixture_IsSensor(@Self) end; procedure b2Fixture_SetFilterData(_self: Pb2Fixture; const [ref] filter: b2Filter); cdecl; external LIB_NAME name _PU + 'b2Fixture_SetFilterData' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2Fixture.SetFilterData(const [ref] filter: b2Filter); cdecl; begin b2Fixture_SetFilterData(@Self, filter) end; function b2Fixture_GetFilterData(_self: Pb2Fixture): Pb2Filter; cdecl; external LIB_NAME name _PU + 'b2Fixture_GetFilterData' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2Fixture.GetFilterData: Pb2Filter; cdecl; begin Result := b2Fixture_GetFilterData(@Self) end; procedure b2Fixture_Refilter(_self: Pb2Fixture); cdecl; external LIB_NAME name _PU + 'b2Fixture_Refilter' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2Fixture.Refilter; cdecl; begin b2Fixture_Refilter(@Self) end; function b2Fixture_GetBody(_self: Pb2Fixture): b2BodyHandle; cdecl; external LIB_NAME name _PU + 'b2Fixture_GetBody' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2Fixture.GetBody: b2BodyHandle; cdecl; begin Result := b2Fixture_GetBody(@Self) end; function b2Fixture_GetNext(_self: Pb2Fixture): Pb2Fixture; cdecl; external LIB_NAME name _PU + 'b2Fixture_GetNext' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2Fixture.GetNext: Pb2Fixture; cdecl; begin Result := b2Fixture_GetNext(@Self) end; function b2Fixture_GetUserData(_self: Pb2Fixture): Pointer; cdecl; external LIB_NAME name _PU + 'b2Fixture_GetUserData' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2Fixture.GetUserData: Pointer; cdecl; begin Result := b2Fixture_GetUserData(@Self) end; procedure b2Fixture_SetUserData(_self: Pb2Fixture; data: Pointer); cdecl; external LIB_NAME name _PU + 'b2Fixture_SetUserData' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2Fixture.SetUserData(data: Pointer); cdecl; begin b2Fixture_SetUserData(@Self, data) end; function b2Fixture_TestPoint(_self: Pb2Fixture; const [ref] p: b2Vec2): Boolean; cdecl; external LIB_NAME name _PU + 'b2Fixture_TestPoint' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2Fixture.TestPoint(const [ref] p: b2Vec2): Boolean; cdecl; begin Result := b2Fixture_TestPoint(@Self, p) end; function b2Fixture_RayCast(_self: Pb2Fixture; output: Pb2RayCastOutput; const [ref] input: b2RayCastInput; childIndex: Integer): Boolean; cdecl; external LIB_NAME name _PU + 'b2Fixture_RayCast' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2Fixture.RayCast(output: Pb2RayCastOutput; const [ref] input: b2RayCastInput; childIndex: Integer): Boolean; cdecl; begin Result := b2Fixture_RayCast(@Self, output, input, childIndex) end; procedure b2Fixture_GetMassData(_self: Pb2Fixture; massData: Pb2MassData); cdecl; external LIB_NAME name _PU + 'b2Fixture_GetMassData' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2Fixture.GetMassData(massData: Pb2MassData); cdecl; begin b2Fixture_GetMassData(@Self, massData) end; procedure b2Fixture_SetDensity(_self: Pb2Fixture; density: Single); cdecl; external LIB_NAME name _PU + 'b2Fixture_SetDensity' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2Fixture.SetDensity(density: Single); cdecl; begin b2Fixture_SetDensity(@Self, density) end; function b2Fixture_GetDensity(_self: Pb2Fixture): Single; cdecl; external LIB_NAME name _PU + 'b2Fixture_GetDensity' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2Fixture.GetDensity: Single; cdecl; begin Result := b2Fixture_GetDensity(@Self) end; function b2Fixture_GetFriction(_self: Pb2Fixture): Single; cdecl; external LIB_NAME name _PU + 'b2Fixture_GetFriction' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2Fixture.GetFriction: Single; cdecl; begin Result := b2Fixture_GetFriction(@Self) end; procedure b2Fixture_SetFriction(_self: Pb2Fixture; friction: Single); cdecl; external LIB_NAME name _PU + 'b2Fixture_SetFriction' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2Fixture.SetFriction(friction: Single); cdecl; begin b2Fixture_SetFriction(@Self, friction) end; function b2Fixture_GetRestitution(_self: Pb2Fixture): Single; cdecl; external LIB_NAME name _PU + 'b2Fixture_GetRestitution' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2Fixture.GetRestitution: Single; cdecl; begin Result := b2Fixture_GetRestitution(@Self) end; procedure b2Fixture_SetRestitution(_self: Pb2Fixture; restitution: Single); cdecl; external LIB_NAME name _PU + 'b2Fixture_SetRestitution' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2Fixture.SetRestitution(restitution: Single); cdecl; begin b2Fixture_SetRestitution(@Self, restitution) end; function b2Fixture_GetAABB(_self: Pb2Fixture; childIndex: Integer): Pb2AABB; cdecl; external LIB_NAME name _PU + 'b2Fixture_GetAABB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2Fixture.GetAABB(childIndex: Integer): Pb2AABB; cdecl; begin Result := b2Fixture_GetAABB(@Self, childIndex) end; procedure b2Fixture_Dump(_self: Pb2Fixture; bodyIndex: Integer); cdecl; external LIB_NAME name _PU + 'b2Fixture_Dump' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2Fixture.Dump(bodyIndex: Integer); cdecl; begin b2Fixture_Dump(@Self, bodyIndex) end; function b2Profile_Create: b2Profile; cdecl; external LIB_NAME name _PU + 'b2Profile_b2Profile' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; class function b2Profile.Create: b2Profile; cdecl; begin Result := b2Profile_Create; end; function b2TimeStep_Create: b2TimeStep; cdecl; external LIB_NAME name _PU + 'b2TimeStep_b2TimeStep' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; class function b2TimeStep.Create: b2TimeStep; cdecl; begin Result := b2TimeStep_Create; end; function b2Position_Create: b2Position; cdecl; external LIB_NAME name _PU + 'b2Position_b2Position' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; class function b2Position.Create: b2Position; cdecl; begin Result := b2Position_Create; end; function b2Velocity_Create: b2Velocity; cdecl; external LIB_NAME name _PU + 'b2Velocity_b2Velocity' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; class function b2Velocity.Create: b2Velocity; cdecl; begin Result := b2Velocity_Create; end; function b2SolverData_Create: b2SolverData; cdecl; external LIB_NAME name _PU + 'b2SolverData_b2SolverData' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; class function b2SolverData.Create: b2SolverData; cdecl; begin Result := b2SolverData_Create; end; function b2Island_Create(bodyCapacity: Integer; contactCapacity: Integer; jointCapacity: Integer; allocator: b2StackAllocatorHandle; listener: b2ContactListenerHandle): b2IslandHandle; cdecl; external LIB_NAME name _PU + 'b2Island_b2Island_1' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; class function b2IslandWrapper.Create(bodyCapacity: Integer; contactCapacity: Integer; jointCapacity: Integer; allocator: b2StackAllocatorHandle; listener: b2ContactListenerHandle): b2IslandWrapper; cdecl; begin Result.FHandle := b2Island_Create(bodyCapacity, contactCapacity, jointCapacity, allocator, listener); end; procedure b2Island_Destroy(_self: b2IslandHandle); cdecl; external LIB_NAME name _PU + 'b2Island_dtor' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2IslandWrapper.Destroy; cdecl; begin b2Island_Destroy(FHandle); end; class operator b2IslandWrapper.Implicit(handle: b2IslandHandle): b2IslandWrapper; begin Result.FHandle := handle; end; class operator b2IslandWrapper.Implicit(wrapper: b2IslandWrapper): b2IslandHandle; begin Result := wrapper.FHandle; end; procedure b2Island_Clear(_self: b2IslandHandle); cdecl; external LIB_NAME name _PU + 'b2Island_Clear' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2IslandWrapper.Clear; cdecl; begin b2Island_Clear(FHandle) end; procedure b2Island_Solve(_self: b2IslandHandle; profile: Pb2Profile; const [ref] step: b2TimeStep; const [ref] gravity: b2Vec2; allowSleep: Boolean); cdecl; external LIB_NAME name _PU + 'b2Island_Solve' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2IslandWrapper.Solve(profile: Pb2Profile; const [ref] step: b2TimeStep; const [ref] gravity: b2Vec2; allowSleep: Boolean); cdecl; begin b2Island_Solve(FHandle, profile, step, gravity, allowSleep) end; procedure b2Island_SolveTOI(_self: b2IslandHandle; const [ref] subStep: b2TimeStep; toiIndexA: Integer; toiIndexB: Integer); cdecl; external LIB_NAME name _PU + 'b2Island_SolveTOI' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2IslandWrapper.SolveTOI(const [ref] subStep: b2TimeStep; toiIndexA: Integer; toiIndexB: Integer); cdecl; begin b2Island_SolveTOI(FHandle, subStep, toiIndexA, toiIndexB) end; procedure b2Island_Add(_self: b2IslandHandle; body: b2BodyHandle); cdecl; external LIB_NAME name _PU + 'b2Island_Add' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2IslandWrapper.Add(body: b2BodyHandle); cdecl; begin b2Island_Add(FHandle, body) end; procedure b2Island_Add2(_self: b2IslandHandle; contact: b2ContactHandle); cdecl; external LIB_NAME name _PU + 'b2Island_Add2' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2IslandWrapper.Add2(contact: b2ContactHandle); cdecl; begin b2Island_Add2(FHandle, contact) end; procedure b2Island_Add3(_self: b2IslandHandle; joint: b2JointHandle); cdecl; external LIB_NAME name _PU + 'b2Island_Add3' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2IslandWrapper.Add3(joint: b2JointHandle); cdecl; begin b2Island_Add3(FHandle, joint) end; procedure b2Island_Report(_self: b2IslandHandle; constraints: Pb2ContactVelocityConstraint); cdecl; external LIB_NAME name _PU + 'b2Island_Report' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2IslandWrapper.Report(constraints: Pb2ContactVelocityConstraint); cdecl; begin b2Island_Report(FHandle, constraints) end; function b2Island_Get_m_allocator(_self: b2IslandHandle): b2StackAllocatorHandle; cdecl; external LIB_NAME name _PU + 'b2Island_Get_m_allocator' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2Island_Set_m_allocator(_self: b2IslandHandle; aNewValue: b2StackAllocatorHandle); cdecl; external LIB_NAME name _PU + 'b2Island_Set_m_allocator' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2IslandWrapper.Get_m_allocator: b2StackAllocatorHandle; cdecl; begin Result := b2Island_Get_m_allocator(FHandle); end; procedure b2IslandWrapper.Set_m_allocator(aNewValue: b2StackAllocatorHandle); cdecl; begin b2Island_Set_m_allocator(FHandle, aNewValue); end; function b2Island_Get_m_listener(_self: b2IslandHandle): b2ContactListenerHandle; cdecl; external LIB_NAME name _PU + 'b2Island_Get_m_listener' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2Island_Set_m_listener(_self: b2IslandHandle; aNewValue: b2ContactListenerHandle); cdecl; external LIB_NAME name _PU + 'b2Island_Set_m_listener' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2IslandWrapper.Get_m_listener: b2ContactListenerHandle; cdecl; begin Result := b2Island_Get_m_listener(FHandle); end; procedure b2IslandWrapper.Set_m_listener(aNewValue: b2ContactListenerHandle); cdecl; begin b2Island_Set_m_listener(FHandle, aNewValue); end; function b2Island_Get_m_bodies(_self: b2IslandHandle): Pb2BodyHandle; cdecl; external LIB_NAME name _PU + 'b2Island_Get_m_bodies' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2Island_Set_m_bodies(_self: b2IslandHandle; aNewValue: Pb2BodyHandle); cdecl; external LIB_NAME name _PU + 'b2Island_Set_m_bodies' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2IslandWrapper.Get_m_bodies: Pb2BodyHandle; cdecl; begin Result := b2Island_Get_m_bodies(FHandle); end; procedure b2IslandWrapper.Set_m_bodies(aNewValue: Pb2BodyHandle); cdecl; begin b2Island_Set_m_bodies(FHandle, aNewValue); end; function b2Island_Get_m_contacts(_self: b2IslandHandle): Pb2ContactHandle; cdecl; external LIB_NAME name _PU + 'b2Island_Get_m_contacts' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2Island_Set_m_contacts(_self: b2IslandHandle; aNewValue: Pb2ContactHandle); cdecl; external LIB_NAME name _PU + 'b2Island_Set_m_contacts' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2IslandWrapper.Get_m_contacts: Pb2ContactHandle; cdecl; begin Result := b2Island_Get_m_contacts(FHandle); end; procedure b2IslandWrapper.Set_m_contacts(aNewValue: Pb2ContactHandle); cdecl; begin b2Island_Set_m_contacts(FHandle, aNewValue); end; function b2Island_Get_m_joints(_self: b2IslandHandle): Pb2JointHandle; cdecl; external LIB_NAME name _PU + 'b2Island_Get_m_joints' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2Island_Set_m_joints(_self: b2IslandHandle; aNewValue: Pb2JointHandle); cdecl; external LIB_NAME name _PU + 'b2Island_Set_m_joints' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2IslandWrapper.Get_m_joints: Pb2JointHandle; cdecl; begin Result := b2Island_Get_m_joints(FHandle); end; procedure b2IslandWrapper.Set_m_joints(aNewValue: Pb2JointHandle); cdecl; begin b2Island_Set_m_joints(FHandle, aNewValue); end; function b2Island_Get_m_positions(_self: b2IslandHandle): Pb2Position; cdecl; external LIB_NAME name _PU + 'b2Island_Get_m_positions' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2Island_Set_m_positions(_self: b2IslandHandle; aNewValue: Pb2Position); cdecl; external LIB_NAME name _PU + 'b2Island_Set_m_positions' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2IslandWrapper.Get_m_positions: Pb2Position; cdecl; begin Result := b2Island_Get_m_positions(FHandle); end; procedure b2IslandWrapper.Set_m_positions(aNewValue: Pb2Position); cdecl; begin b2Island_Set_m_positions(FHandle, aNewValue); end; function b2Island_Get_m_velocities(_self: b2IslandHandle): Pb2Velocity; cdecl; external LIB_NAME name _PU + 'b2Island_Get_m_velocities' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2Island_Set_m_velocities(_self: b2IslandHandle; aNewValue: Pb2Velocity); cdecl; external LIB_NAME name _PU + 'b2Island_Set_m_velocities' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2IslandWrapper.Get_m_velocities: Pb2Velocity; cdecl; begin Result := b2Island_Get_m_velocities(FHandle); end; procedure b2IslandWrapper.Set_m_velocities(aNewValue: Pb2Velocity); cdecl; begin b2Island_Set_m_velocities(FHandle, aNewValue); end; function b2Island_Get_m_bodyCount(_self: b2IslandHandle): Integer; cdecl; external LIB_NAME name _PU + 'b2Island_Get_m_bodyCount' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2Island_Set_m_bodyCount(_self: b2IslandHandle; aNewValue: Integer); cdecl; external LIB_NAME name _PU + 'b2Island_Set_m_bodyCount' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2IslandWrapper.Get_m_bodyCount: Integer; cdecl; begin Result := b2Island_Get_m_bodyCount(FHandle); end; procedure b2IslandWrapper.Set_m_bodyCount(aNewValue: Integer); cdecl; begin b2Island_Set_m_bodyCount(FHandle, aNewValue); end; function b2Island_Get_m_jointCount(_self: b2IslandHandle): Integer; cdecl; external LIB_NAME name _PU + 'b2Island_Get_m_jointCount' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2Island_Set_m_jointCount(_self: b2IslandHandle; aNewValue: Integer); cdecl; external LIB_NAME name _PU + 'b2Island_Set_m_jointCount' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2IslandWrapper.Get_m_jointCount: Integer; cdecl; begin Result := b2Island_Get_m_jointCount(FHandle); end; procedure b2IslandWrapper.Set_m_jointCount(aNewValue: Integer); cdecl; begin b2Island_Set_m_jointCount(FHandle, aNewValue); end; function b2Island_Get_m_contactCount(_self: b2IslandHandle): Integer; cdecl; external LIB_NAME name _PU + 'b2Island_Get_m_contactCount' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2Island_Set_m_contactCount(_self: b2IslandHandle; aNewValue: Integer); cdecl; external LIB_NAME name _PU + 'b2Island_Set_m_contactCount' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2IslandWrapper.Get_m_contactCount: Integer; cdecl; begin Result := b2Island_Get_m_contactCount(FHandle); end; procedure b2IslandWrapper.Set_m_contactCount(aNewValue: Integer); cdecl; begin b2Island_Set_m_contactCount(FHandle, aNewValue); end; function b2Island_Get_m_bodyCapacity(_self: b2IslandHandle): Integer; cdecl; external LIB_NAME name _PU + 'b2Island_Get_m_bodyCapacity' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2Island_Set_m_bodyCapacity(_self: b2IslandHandle; aNewValue: Integer); cdecl; external LIB_NAME name _PU + 'b2Island_Set_m_bodyCapacity' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2IslandWrapper.Get_m_bodyCapacity: Integer; cdecl; begin Result := b2Island_Get_m_bodyCapacity(FHandle); end; procedure b2IslandWrapper.Set_m_bodyCapacity(aNewValue: Integer); cdecl; begin b2Island_Set_m_bodyCapacity(FHandle, aNewValue); end; function b2Island_Get_m_contactCapacity(_self: b2IslandHandle): Integer; cdecl; external LIB_NAME name _PU + 'b2Island_Get_m_contactCapacity' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2Island_Set_m_contactCapacity(_self: b2IslandHandle; aNewValue: Integer); cdecl; external LIB_NAME name _PU + 'b2Island_Set_m_contactCapacity' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2IslandWrapper.Get_m_contactCapacity: Integer; cdecl; begin Result := b2Island_Get_m_contactCapacity(FHandle); end; procedure b2IslandWrapper.Set_m_contactCapacity(aNewValue: Integer); cdecl; begin b2Island_Set_m_contactCapacity(FHandle, aNewValue); end; function b2Island_Get_m_jointCapacity(_self: b2IslandHandle): Integer; cdecl; external LIB_NAME name _PU + 'b2Island_Get_m_jointCapacity' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2Island_Set_m_jointCapacity(_self: b2IslandHandle; aNewValue: Integer); cdecl; external LIB_NAME name _PU + 'b2Island_Set_m_jointCapacity' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2IslandWrapper.Get_m_jointCapacity: Integer; cdecl; begin Result := b2Island_Get_m_jointCapacity(FHandle); end; procedure b2IslandWrapper.Set_m_jointCapacity(aNewValue: Integer); cdecl; begin b2Island_Set_m_jointCapacity(FHandle, aNewValue); end; class operator b2DestructionListenerWrapper.Implicit(handle: b2DestructionListenerHandle): b2DestructionListenerWrapper; begin Result.FHandle := handle; end; class operator b2DestructionListenerWrapper.Implicit(wrapper: b2DestructionListenerWrapper): b2DestructionListenerHandle; begin Result := wrapper.FHandle; end; procedure b2DestructionListener_SayGoodbye(_self: b2DestructionListenerHandle; joint: b2JointHandle); overload; cdecl; external LIB_NAME name _PU + 'b2DestructionListener_SayGoodbye' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2DestructionListenerWrapper.SayGoodbye(joint: b2JointHandle); cdecl; begin b2DestructionListener_SayGoodbye(FHandle, joint) end; procedure b2DestructionListener_SayGoodbye(_self: b2DestructionListenerHandle; fixture: Pb2Fixture); overload; cdecl; external LIB_NAME name _PU + 'b2DestructionListener_SayGoodbye2' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2DestructionListenerWrapper.SayGoodbye(fixture: Pb2Fixture); cdecl; begin b2DestructionListener_SayGoodbye(FHandle, fixture) end; function b2ContactFilter_Create: b2ContactFilterHandle; cdecl; external LIB_NAME name _PU + 'b2ContactFilter_b2ContactFilter' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; class function b2ContactFilterWrapper.Create: b2ContactFilterWrapper; cdecl; begin Result.FHandle := b2ContactFilter_Create; end; procedure b2ContactFilter_Destroy(_self: b2ContactFilterHandle); cdecl; external LIB_NAME name _PU + 'b2ContactFilter_dtor' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ContactFilterWrapper.Destroy; cdecl; begin b2ContactFilter_Destroy(FHandle); end; class operator b2ContactFilterWrapper.Implicit(handle: b2ContactFilterHandle): b2ContactFilterWrapper; begin Result.FHandle := handle; end; class operator b2ContactFilterWrapper.Implicit(wrapper: b2ContactFilterWrapper): b2ContactFilterHandle; begin Result := wrapper.FHandle; end; function b2ContactFilter_ShouldCollide(_self: b2ContactFilterHandle; fixtureA: Pb2Fixture; fixtureB: Pb2Fixture): Boolean; cdecl; external LIB_NAME name _PU + 'b2ContactFilter_ShouldCollide' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ContactFilterWrapper.ShouldCollide(fixtureA: Pb2Fixture; fixtureB: Pb2Fixture): Boolean; cdecl; begin Result := b2ContactFilter_ShouldCollide(FHandle, fixtureA, fixtureB) end; function b2ContactImpulse_Create: b2ContactImpulse; cdecl; external LIB_NAME name _PU + 'b2ContactImpulse_b2ContactImpulse' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; class function b2ContactImpulse.Create: b2ContactImpulse; cdecl; begin Result := b2ContactImpulse_Create; end; function b2ContactListener_Create: b2ContactListenerHandle; cdecl; external LIB_NAME name _PU + 'b2ContactListener_b2ContactListener' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; class function b2ContactListenerWrapper.Create: b2ContactListenerWrapper; cdecl; begin Result.FHandle := b2ContactListener_Create; end; procedure b2ContactListener_Destroy(_self: b2ContactListenerHandle); cdecl; external LIB_NAME name _PU + 'b2ContactListener_dtor' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ContactListenerWrapper.Destroy; cdecl; begin b2ContactListener_Destroy(FHandle); end; class operator b2ContactListenerWrapper.Implicit(handle: b2ContactListenerHandle): b2ContactListenerWrapper; begin Result.FHandle := handle; end; class operator b2ContactListenerWrapper.Implicit(wrapper: b2ContactListenerWrapper): b2ContactListenerHandle; begin Result := wrapper.FHandle; end; procedure b2ContactListener_BeginContact(_self: b2ContactListenerHandle; contact: b2ContactHandle); cdecl; external LIB_NAME name _PU + 'b2ContactListener_BeginContact' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ContactListenerWrapper.BeginContact(contact: b2ContactHandle); cdecl; begin b2ContactListener_BeginContact(FHandle, contact) end; procedure b2ContactListener_EndContact(_self: b2ContactListenerHandle; contact: b2ContactHandle); cdecl; external LIB_NAME name _PU + 'b2ContactListener_EndContact' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ContactListenerWrapper.EndContact(contact: b2ContactHandle); cdecl; begin b2ContactListener_EndContact(FHandle, contact) end; procedure b2ContactListener_PreSolve(_self: b2ContactListenerHandle; contact: b2ContactHandle; oldManifold: Pb2Manifold); cdecl; external LIB_NAME name _PU + 'b2ContactListener_PreSolve' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ContactListenerWrapper.PreSolve(contact: b2ContactHandle; oldManifold: Pb2Manifold); cdecl; begin b2ContactListener_PreSolve(FHandle, contact, oldManifold) end; procedure b2ContactListener_PostSolve(_self: b2ContactListenerHandle; contact: b2ContactHandle; impulse: Pb2ContactImpulse); cdecl; external LIB_NAME name _PU + 'b2ContactListener_PostSolve' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ContactListenerWrapper.PostSolve(contact: b2ContactHandle; impulse: Pb2ContactImpulse); cdecl; begin b2ContactListener_PostSolve(FHandle, contact, impulse) end; class operator b2QueryCallbackWrapper.Implicit(handle: b2QueryCallbackHandle): b2QueryCallbackWrapper; begin Result.FHandle := handle; end; class operator b2QueryCallbackWrapper.Implicit(wrapper: b2QueryCallbackWrapper): b2QueryCallbackHandle; begin Result := wrapper.FHandle; end; function b2QueryCallback_ReportFixture(_self: b2QueryCallbackHandle; fixture: Pb2Fixture): Boolean; cdecl; external LIB_NAME name _PU + 'b2QueryCallback_ReportFixture' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2QueryCallbackWrapper.ReportFixture(fixture: Pb2Fixture): Boolean; cdecl; begin Result := b2QueryCallback_ReportFixture(FHandle, fixture) end; class operator b2RayCastCallbackWrapper.Implicit(handle: b2RayCastCallbackHandle): b2RayCastCallbackWrapper; begin Result.FHandle := handle; end; class operator b2RayCastCallbackWrapper.Implicit(wrapper: b2RayCastCallbackWrapper): b2RayCastCallbackHandle; begin Result := wrapper.FHandle; end; function b2RayCastCallback_ReportFixture(_self: b2RayCastCallbackHandle; fixture: Pb2Fixture; const [ref] point: b2Vec2; const [ref] normal: b2Vec2; fraction: Single): Single; cdecl; external LIB_NAME name _PU + 'b2RayCastCallback_ReportFixture' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2RayCastCallbackWrapper.ReportFixture(fixture: Pb2Fixture; const [ref] point: b2Vec2; const [ref] normal: b2Vec2; fraction: Single): Single; cdecl; begin Result := b2RayCastCallback_ReportFixture(FHandle, fixture, point, normal, fraction) end; function b2World_Create(const [ref] gravity: b2Vec2): b2WorldHandle; cdecl; external LIB_NAME name _PU + 'b2World_b2World_1' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; class function b2WorldWrapper.Create(const [ref] gravity: b2Vec2): b2WorldWrapper; cdecl; begin Result.FHandle := b2World_Create(gravity); end; procedure b2World_Destroy(_self: b2WorldHandle); cdecl; external LIB_NAME name _PU + 'b2World_dtor' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2WorldWrapper.Destroy; cdecl; begin b2World_Destroy(FHandle); end; class operator b2WorldWrapper.Implicit(handle: b2WorldHandle): b2WorldWrapper; begin Result.FHandle := handle; end; class operator b2WorldWrapper.Implicit(wrapper: b2WorldWrapper): b2WorldHandle; begin Result := wrapper.FHandle; end; procedure b2World_SetDestructionListener(_self: b2WorldHandle; listener: b2DestructionListenerHandle); cdecl; external LIB_NAME name _PU + 'b2World_SetDestructionListener' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2WorldWrapper.SetDestructionListener(listener: b2DestructionListenerHandle); cdecl; begin b2World_SetDestructionListener(FHandle, listener) end; procedure b2World_SetContactFilter(_self: b2WorldHandle; filter: b2ContactFilterHandle); cdecl; external LIB_NAME name _PU + 'b2World_SetContactFilter' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2WorldWrapper.SetContactFilter(filter: b2ContactFilterHandle); cdecl; begin b2World_SetContactFilter(FHandle, filter) end; procedure b2World_SetContactListener(_self: b2WorldHandle; listener: b2ContactListenerHandle); cdecl; external LIB_NAME name _PU + 'b2World_SetContactListener' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2WorldWrapper.SetContactListener(listener: b2ContactListenerHandle); cdecl; begin b2World_SetContactListener(FHandle, listener) end; procedure b2World_SetDebugDraw(_self: b2WorldHandle; debugDraw: b2DrawHandle); cdecl; external LIB_NAME name _PU + 'b2World_SetDebugDraw' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2WorldWrapper.SetDebugDraw(debugDraw: b2DrawHandle); cdecl; begin b2World_SetDebugDraw(FHandle, debugDraw) end; function b2World_CreateBody(_self: b2WorldHandle; def: Pb2BodyDef): b2BodyHandle; cdecl; external LIB_NAME name _PU + 'b2World_CreateBody' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WorldWrapper.CreateBody(def: Pb2BodyDef): b2BodyHandle; cdecl; begin Result := b2World_CreateBody(FHandle, def) end; procedure b2World_DestroyBody(_self: b2WorldHandle; body: b2BodyHandle); cdecl; external LIB_NAME name _PU + 'b2World_DestroyBody' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2WorldWrapper.DestroyBody(body: b2BodyHandle); cdecl; begin b2World_DestroyBody(FHandle, body) end; function b2World_CreateJoint(_self: b2WorldHandle; def: Pb2JointDef): b2JointHandle; cdecl; external LIB_NAME name _PU + 'b2World_CreateJoint' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WorldWrapper.CreateJoint(def: Pb2JointDef): b2JointHandle; cdecl; begin Result := b2World_CreateJoint(FHandle, def) end; procedure b2World_DestroyJoint(_self: b2WorldHandle; joint: b2JointHandle); cdecl; external LIB_NAME name _PU + 'b2World_DestroyJoint' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2WorldWrapper.DestroyJoint(joint: b2JointHandle); cdecl; begin b2World_DestroyJoint(FHandle, joint) end; procedure b2World_Step(_self: b2WorldHandle; timeStep: Single; velocityIterations: Integer; positionIterations: Integer); cdecl; external LIB_NAME name _PU + 'b2World_Step' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2WorldWrapper.Step(timeStep: Single; velocityIterations: Integer; positionIterations: Integer); cdecl; begin b2World_Step(FHandle, timeStep, velocityIterations, positionIterations) end; procedure b2World_ClearForces(_self: b2WorldHandle); cdecl; external LIB_NAME name _PU + 'b2World_ClearForces' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2WorldWrapper.ClearForces; cdecl; begin b2World_ClearForces(FHandle) end; procedure b2World_DrawDebugData(_self: b2WorldHandle); cdecl; external LIB_NAME name _PU + 'b2World_DrawDebugData' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2WorldWrapper.DrawDebugData; cdecl; begin b2World_DrawDebugData(FHandle) end; procedure b2World_QueryAABB(_self: b2WorldHandle; callback: b2QueryCallbackHandle; const [ref] aabb: b2AABB); cdecl; external LIB_NAME name _PU + 'b2World_QueryAABB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2WorldWrapper.QueryAABB(callback: b2QueryCallbackHandle; const [ref] aabb: b2AABB); cdecl; begin b2World_QueryAABB(FHandle, callback, aabb) end; procedure b2World_RayCast(_self: b2WorldHandle; callback: b2RayCastCallbackHandle; const [ref] point1: b2Vec2; const [ref] point2: b2Vec2); cdecl; external LIB_NAME name _PU + 'b2World_RayCast' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2WorldWrapper.RayCast(callback: b2RayCastCallbackHandle; const [ref] point1: b2Vec2; const [ref] point2: b2Vec2); cdecl; begin b2World_RayCast(FHandle, callback, point1, point2) end; function b2World_GetBodyList(_self: b2WorldHandle): b2BodyHandle; cdecl; external LIB_NAME name _PU + 'b2World_GetBodyList' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WorldWrapper.GetBodyList: b2BodyHandle; cdecl; begin Result := b2World_GetBodyList(FHandle) end; function b2World_GetJointList(_self: b2WorldHandle): b2JointHandle; cdecl; external LIB_NAME name _PU + 'b2World_GetJointList' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WorldWrapper.GetJointList: b2JointHandle; cdecl; begin Result := b2World_GetJointList(FHandle) end; function b2World_GetContactList(_self: b2WorldHandle): b2ContactHandle; cdecl; external LIB_NAME name _PU + 'b2World_GetContactList' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WorldWrapper.GetContactList: b2ContactHandle; cdecl; begin Result := b2World_GetContactList(FHandle) end; procedure b2World_SetAllowSleeping(_self: b2WorldHandle; flag: Boolean); cdecl; external LIB_NAME name _PU + 'b2World_SetAllowSleeping' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2WorldWrapper.SetAllowSleeping(flag: Boolean); cdecl; begin b2World_SetAllowSleeping(FHandle, flag) end; function b2World_GetAllowSleeping(_self: b2WorldHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2World_GetAllowSleeping' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WorldWrapper.GetAllowSleeping: Boolean; cdecl; begin Result := b2World_GetAllowSleeping(FHandle) end; procedure b2World_SetWarmStarting(_self: b2WorldHandle; flag: Boolean); cdecl; external LIB_NAME name _PU + 'b2World_SetWarmStarting' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2WorldWrapper.SetWarmStarting(flag: Boolean); cdecl; begin b2World_SetWarmStarting(FHandle, flag) end; function b2World_GetWarmStarting(_self: b2WorldHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2World_GetWarmStarting' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WorldWrapper.GetWarmStarting: Boolean; cdecl; begin Result := b2World_GetWarmStarting(FHandle) end; procedure b2World_SetContinuousPhysics(_self: b2WorldHandle; flag: Boolean); cdecl; external LIB_NAME name _PU + 'b2World_SetContinuousPhysics' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2WorldWrapper.SetContinuousPhysics(flag: Boolean); cdecl; begin b2World_SetContinuousPhysics(FHandle, flag) end; function b2World_GetContinuousPhysics(_self: b2WorldHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2World_GetContinuousPhysics' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WorldWrapper.GetContinuousPhysics: Boolean; cdecl; begin Result := b2World_GetContinuousPhysics(FHandle) end; procedure b2World_SetSubStepping(_self: b2WorldHandle; flag: Boolean); cdecl; external LIB_NAME name _PU + 'b2World_SetSubStepping' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2WorldWrapper.SetSubStepping(flag: Boolean); cdecl; begin b2World_SetSubStepping(FHandle, flag) end; function b2World_GetSubStepping(_self: b2WorldHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2World_GetSubStepping' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WorldWrapper.GetSubStepping: Boolean; cdecl; begin Result := b2World_GetSubStepping(FHandle) end; function b2World_GetProxyCount(_self: b2WorldHandle): Integer; cdecl; external LIB_NAME name _PU + 'b2World_GetProxyCount' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WorldWrapper.GetProxyCount: Integer; cdecl; begin Result := b2World_GetProxyCount(FHandle) end; function b2World_GetBodyCount(_self: b2WorldHandle): Integer; cdecl; external LIB_NAME name _PU + 'b2World_GetBodyCount' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WorldWrapper.GetBodyCount: Integer; cdecl; begin Result := b2World_GetBodyCount(FHandle) end; function b2World_GetJointCount(_self: b2WorldHandle): Integer; cdecl; external LIB_NAME name _PU + 'b2World_GetJointCount' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WorldWrapper.GetJointCount: Integer; cdecl; begin Result := b2World_GetJointCount(FHandle) end; function b2World_GetContactCount(_self: b2WorldHandle): Integer; cdecl; external LIB_NAME name _PU + 'b2World_GetContactCount' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WorldWrapper.GetContactCount: Integer; cdecl; begin Result := b2World_GetContactCount(FHandle) end; function b2World_GetTreeHeight(_self: b2WorldHandle): Integer; cdecl; external LIB_NAME name _PU + 'b2World_GetTreeHeight' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WorldWrapper.GetTreeHeight: Integer; cdecl; begin Result := b2World_GetTreeHeight(FHandle) end; function b2World_GetTreeBalance(_self: b2WorldHandle): Integer; cdecl; external LIB_NAME name _PU + 'b2World_GetTreeBalance' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WorldWrapper.GetTreeBalance: Integer; cdecl; begin Result := b2World_GetTreeBalance(FHandle) end; function b2World_GetTreeQuality(_self: b2WorldHandle): Single; cdecl; external LIB_NAME name _PU + 'b2World_GetTreeQuality' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WorldWrapper.GetTreeQuality: Single; cdecl; begin Result := b2World_GetTreeQuality(FHandle) end; procedure b2World_SetGravity(_self: b2WorldHandle; const [ref] gravity: b2Vec2); cdecl; external LIB_NAME name _PU + 'b2World_SetGravity' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2WorldWrapper.SetGravity(const [ref] gravity: b2Vec2); cdecl; begin b2World_SetGravity(FHandle, gravity) end; function b2World_GetGravity(_self: b2WorldHandle): b2Vec2; cdecl; external LIB_NAME name _PU + 'b2World_GetGravity' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WorldWrapper.GetGravity: b2Vec2; cdecl; begin Result := b2World_GetGravity(FHandle) end; function b2World_IsLocked(_self: b2WorldHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2World_IsLocked' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WorldWrapper.IsLocked: Boolean; cdecl; begin Result := b2World_IsLocked(FHandle) end; procedure b2World_SetAutoClearForces(_self: b2WorldHandle; flag: Boolean); cdecl; external LIB_NAME name _PU + 'b2World_SetAutoClearForces' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2WorldWrapper.SetAutoClearForces(flag: Boolean); cdecl; begin b2World_SetAutoClearForces(FHandle, flag) end; function b2World_GetAutoClearForces(_self: b2WorldHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2World_GetAutoClearForces' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WorldWrapper.GetAutoClearForces: Boolean; cdecl; begin Result := b2World_GetAutoClearForces(FHandle) end; procedure b2World_ShiftOrigin(_self: b2WorldHandle; const [ref] newOrigin: b2Vec2); cdecl; external LIB_NAME name _PU + 'b2World_ShiftOrigin' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2WorldWrapper.ShiftOrigin(const [ref] newOrigin: b2Vec2); cdecl; begin b2World_ShiftOrigin(FHandle, newOrigin) end; function b2World_GetContactManager(_self: b2WorldHandle): b2ContactManagerHandle; cdecl; external LIB_NAME name _PU + 'b2World_GetContactManager' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WorldWrapper.GetContactManager: b2ContactManagerHandle; cdecl; begin Result := b2World_GetContactManager(FHandle) end; function b2World_GetProfile(_self: b2WorldHandle): Pb2Profile; cdecl; external LIB_NAME name _PU + 'b2World_GetProfile' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WorldWrapper.GetProfile: Pb2Profile; cdecl; begin Result := b2World_GetProfile(FHandle) end; procedure b2World_Dump(_self: b2WorldHandle); cdecl; external LIB_NAME name _PU + 'b2World_Dump' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2WorldWrapper.Dump; cdecl; begin b2World_Dump(FHandle) end; function b2ContactRegister_Create: b2ContactRegister; cdecl; external LIB_NAME name _PU + 'b2ContactRegister_b2ContactRegister' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; class function b2ContactRegister.Create: b2ContactRegister; cdecl; begin Result := b2ContactRegister_Create; end; function b2ContactEdge_Create: b2ContactEdge; cdecl; external LIB_NAME name _PU + 'b2ContactEdge_b2ContactEdge_1' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; class function b2ContactEdge.Create: b2ContactEdge; cdecl; begin Result := b2ContactEdge_Create; end; class operator b2ContactWrapper.Implicit(handle: b2ContactHandle): b2ContactWrapper; begin Result.FHandle := handle; end; class operator b2ContactWrapper.Implicit(wrapper: b2ContactWrapper): b2ContactHandle; begin Result := wrapper.FHandle; end; function b2Contact_GetManifold(_self: b2ContactHandle): Pb2Manifold; cdecl; external LIB_NAME name _PU + 'b2Contact_GetManifold' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ContactWrapper.GetManifold: Pb2Manifold; cdecl; begin Result := b2Contact_GetManifold(FHandle) end; procedure b2Contact_GetWorldManifold(_self: b2ContactHandle; worldManifold: Pb2WorldManifold); cdecl; external LIB_NAME name _PU + 'b2Contact_GetWorldManifold' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ContactWrapper.GetWorldManifold(worldManifold: Pb2WorldManifold); cdecl; begin b2Contact_GetWorldManifold(FHandle, worldManifold) end; function b2Contact_IsTouching(_self: b2ContactHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2Contact_IsTouching' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ContactWrapper.IsTouching: Boolean; cdecl; begin Result := b2Contact_IsTouching(FHandle) end; procedure b2Contact_SetEnabled(_self: b2ContactHandle; flag: Boolean); cdecl; external LIB_NAME name _PU + 'b2Contact_SetEnabled' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ContactWrapper.SetEnabled(flag: Boolean); cdecl; begin b2Contact_SetEnabled(FHandle, flag) end; function b2Contact_IsEnabled(_self: b2ContactHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2Contact_IsEnabled' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ContactWrapper.IsEnabled: Boolean; cdecl; begin Result := b2Contact_IsEnabled(FHandle) end; function b2Contact_GetNext(_self: b2ContactHandle): b2ContactHandle; cdecl; external LIB_NAME name _PU + 'b2Contact_GetNext' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ContactWrapper.GetNext: b2ContactHandle; cdecl; begin Result := b2Contact_GetNext(FHandle) end; function b2Contact_GetFixtureA(_self: b2ContactHandle): Pb2Fixture; cdecl; external LIB_NAME name _PU + 'b2Contact_GetFixtureA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ContactWrapper.GetFixtureA: Pb2Fixture; cdecl; begin Result := b2Contact_GetFixtureA(FHandle) end; function b2Contact_GetChildIndexA(_self: b2ContactHandle): Integer; cdecl; external LIB_NAME name _PU + 'b2Contact_GetChildIndexA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ContactWrapper.GetChildIndexA: Integer; cdecl; begin Result := b2Contact_GetChildIndexA(FHandle) end; function b2Contact_GetFixtureB(_self: b2ContactHandle): Pb2Fixture; cdecl; external LIB_NAME name _PU + 'b2Contact_GetFixtureB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ContactWrapper.GetFixtureB: Pb2Fixture; cdecl; begin Result := b2Contact_GetFixtureB(FHandle) end; function b2Contact_GetChildIndexB(_self: b2ContactHandle): Integer; cdecl; external LIB_NAME name _PU + 'b2Contact_GetChildIndexB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ContactWrapper.GetChildIndexB: Integer; cdecl; begin Result := b2Contact_GetChildIndexB(FHandle) end; procedure b2Contact_SetFriction(_self: b2ContactHandle; friction: Single); cdecl; external LIB_NAME name _PU + 'b2Contact_SetFriction' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ContactWrapper.SetFriction(friction: Single); cdecl; begin b2Contact_SetFriction(FHandle, friction) end; function b2Contact_GetFriction(_self: b2ContactHandle): Single; cdecl; external LIB_NAME name _PU + 'b2Contact_GetFriction' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ContactWrapper.GetFriction: Single; cdecl; begin Result := b2Contact_GetFriction(FHandle) end; procedure b2Contact_ResetFriction(_self: b2ContactHandle); cdecl; external LIB_NAME name _PU + 'b2Contact_ResetFriction' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ContactWrapper.ResetFriction; cdecl; begin b2Contact_ResetFriction(FHandle) end; procedure b2Contact_SetRestitution(_self: b2ContactHandle; restitution: Single); cdecl; external LIB_NAME name _PU + 'b2Contact_SetRestitution' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ContactWrapper.SetRestitution(restitution: Single); cdecl; begin b2Contact_SetRestitution(FHandle, restitution) end; function b2Contact_GetRestitution(_self: b2ContactHandle): Single; cdecl; external LIB_NAME name _PU + 'b2Contact_GetRestitution' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ContactWrapper.GetRestitution: Single; cdecl; begin Result := b2Contact_GetRestitution(FHandle) end; procedure b2Contact_ResetRestitution(_self: b2ContactHandle); cdecl; external LIB_NAME name _PU + 'b2Contact_ResetRestitution' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ContactWrapper.ResetRestitution; cdecl; begin b2Contact_ResetRestitution(FHandle) end; procedure b2Contact_SetTangentSpeed(_self: b2ContactHandle; speed: Single); cdecl; external LIB_NAME name _PU + 'b2Contact_SetTangentSpeed' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ContactWrapper.SetTangentSpeed(speed: Single); cdecl; begin b2Contact_SetTangentSpeed(FHandle, speed) end; function b2Contact_GetTangentSpeed(_self: b2ContactHandle): Single; cdecl; external LIB_NAME name _PU + 'b2Contact_GetTangentSpeed' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ContactWrapper.GetTangentSpeed: Single; cdecl; begin Result := b2Contact_GetTangentSpeed(FHandle) end; procedure b2Contact_Evaluate(_self: b2ContactHandle; manifold: Pb2Manifold; const [ref] xfA: b2Transform; const [ref] xfB: b2Transform); cdecl; external LIB_NAME name _PU + 'b2Contact_Evaluate' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ContactWrapper.Evaluate(manifold: Pb2Manifold; const [ref] xfA: b2Transform; const [ref] xfB: b2Transform); cdecl; begin b2Contact_Evaluate(FHandle, manifold, xfA, xfB) end; function b2ChainAndCircleContact_Create(fixtureA: Pb2Fixture; indexA: Integer; fixtureB: Pb2Fixture; indexB: Integer): b2ChainAndCircleContactHandle; cdecl; external LIB_NAME name _PU + 'b2ChainAndCircleContact_b2ChainAndCircleContact_1' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; class function b2ChainAndCircleContactWrapper.Create(fixtureA: Pb2Fixture; indexA: Integer; fixtureB: Pb2Fixture; indexB: Integer): b2ChainAndCircleContactWrapper; cdecl; begin Result.FHandle := b2ChainAndCircleContact_Create(fixtureA, indexA, fixtureB, indexB); end; procedure b2ChainAndCircleContact_Destroy(_self: b2ChainAndCircleContactHandle); cdecl; external LIB_NAME name _PU + 'b2ChainAndCircleContact_dtor' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ChainAndCircleContactWrapper.Destroy; cdecl; begin b2ChainAndCircleContact_Destroy(FHandle); end; class operator b2ChainAndCircleContactWrapper.Implicit(handle: b2ChainAndCircleContactHandle): b2ChainAndCircleContactWrapper; begin Result.FHandle := handle; end; class operator b2ChainAndCircleContactWrapper.Implicit(wrapper: b2ChainAndCircleContactWrapper): b2ChainAndCircleContactHandle; begin Result := wrapper.FHandle; end; function b2ChainAndCircleContact_GetManifold(_self: b2ChainAndCircleContactHandle): Pb2Manifold; cdecl; external LIB_NAME name _PU + 'b2ChainAndCircleContact_GetManifold' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ChainAndCircleContactWrapper.GetManifold: Pb2Manifold; cdecl; begin Result := b2ChainAndCircleContact_GetManifold(FHandle) end; procedure b2ChainAndCircleContact_GetWorldManifold(_self: b2ChainAndCircleContactHandle; worldManifold: Pb2WorldManifold); cdecl; external LIB_NAME name _PU + 'b2ChainAndCircleContact_GetWorldManifold' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ChainAndCircleContactWrapper.GetWorldManifold(worldManifold: Pb2WorldManifold); cdecl; begin b2ChainAndCircleContact_GetWorldManifold(FHandle, worldManifold) end; function b2ChainAndCircleContact_IsTouching(_self: b2ChainAndCircleContactHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2ChainAndCircleContact_IsTouching' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ChainAndCircleContactWrapper.IsTouching: Boolean; cdecl; begin Result := b2ChainAndCircleContact_IsTouching(FHandle) end; procedure b2ChainAndCircleContact_SetEnabled(_self: b2ChainAndCircleContactHandle; flag: Boolean); cdecl; external LIB_NAME name _PU + 'b2ChainAndCircleContact_SetEnabled' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ChainAndCircleContactWrapper.SetEnabled(flag: Boolean); cdecl; begin b2ChainAndCircleContact_SetEnabled(FHandle, flag) end; function b2ChainAndCircleContact_IsEnabled(_self: b2ChainAndCircleContactHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2ChainAndCircleContact_IsEnabled' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ChainAndCircleContactWrapper.IsEnabled: Boolean; cdecl; begin Result := b2ChainAndCircleContact_IsEnabled(FHandle) end; function b2ChainAndCircleContact_GetNext(_self: b2ChainAndCircleContactHandle): b2ContactHandle; cdecl; external LIB_NAME name _PU + 'b2ChainAndCircleContact_GetNext' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ChainAndCircleContactWrapper.GetNext: b2ContactHandle; cdecl; begin Result := b2ChainAndCircleContact_GetNext(FHandle) end; function b2ChainAndCircleContact_GetFixtureA(_self: b2ChainAndCircleContactHandle): Pb2Fixture; cdecl; external LIB_NAME name _PU + 'b2ChainAndCircleContact_GetFixtureA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ChainAndCircleContactWrapper.GetFixtureA: Pb2Fixture; cdecl; begin Result := b2ChainAndCircleContact_GetFixtureA(FHandle) end; function b2ChainAndCircleContact_GetChildIndexA(_self: b2ChainAndCircleContactHandle): Integer; cdecl; external LIB_NAME name _PU + 'b2ChainAndCircleContact_GetChildIndexA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ChainAndCircleContactWrapper.GetChildIndexA: Integer; cdecl; begin Result := b2ChainAndCircleContact_GetChildIndexA(FHandle) end; function b2ChainAndCircleContact_GetFixtureB(_self: b2ChainAndCircleContactHandle): Pb2Fixture; cdecl; external LIB_NAME name _PU + 'b2ChainAndCircleContact_GetFixtureB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ChainAndCircleContactWrapper.GetFixtureB: Pb2Fixture; cdecl; begin Result := b2ChainAndCircleContact_GetFixtureB(FHandle) end; function b2ChainAndCircleContact_GetChildIndexB(_self: b2ChainAndCircleContactHandle): Integer; cdecl; external LIB_NAME name _PU + 'b2ChainAndCircleContact_GetChildIndexB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ChainAndCircleContactWrapper.GetChildIndexB: Integer; cdecl; begin Result := b2ChainAndCircleContact_GetChildIndexB(FHandle) end; procedure b2ChainAndCircleContact_SetFriction(_self: b2ChainAndCircleContactHandle; friction: Single); cdecl; external LIB_NAME name _PU + 'b2ChainAndCircleContact_SetFriction' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ChainAndCircleContactWrapper.SetFriction(friction: Single); cdecl; begin b2ChainAndCircleContact_SetFriction(FHandle, friction) end; function b2ChainAndCircleContact_GetFriction(_self: b2ChainAndCircleContactHandle): Single; cdecl; external LIB_NAME name _PU + 'b2ChainAndCircleContact_GetFriction' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ChainAndCircleContactWrapper.GetFriction: Single; cdecl; begin Result := b2ChainAndCircleContact_GetFriction(FHandle) end; procedure b2ChainAndCircleContact_ResetFriction(_self: b2ChainAndCircleContactHandle); cdecl; external LIB_NAME name _PU + 'b2ChainAndCircleContact_ResetFriction' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ChainAndCircleContactWrapper.ResetFriction; cdecl; begin b2ChainAndCircleContact_ResetFriction(FHandle) end; procedure b2ChainAndCircleContact_SetRestitution(_self: b2ChainAndCircleContactHandle; restitution: Single); cdecl; external LIB_NAME name _PU + 'b2ChainAndCircleContact_SetRestitution' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ChainAndCircleContactWrapper.SetRestitution(restitution: Single); cdecl; begin b2ChainAndCircleContact_SetRestitution(FHandle, restitution) end; function b2ChainAndCircleContact_GetRestitution(_self: b2ChainAndCircleContactHandle): Single; cdecl; external LIB_NAME name _PU + 'b2ChainAndCircleContact_GetRestitution' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ChainAndCircleContactWrapper.GetRestitution: Single; cdecl; begin Result := b2ChainAndCircleContact_GetRestitution(FHandle) end; procedure b2ChainAndCircleContact_ResetRestitution(_self: b2ChainAndCircleContactHandle); cdecl; external LIB_NAME name _PU + 'b2ChainAndCircleContact_ResetRestitution' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ChainAndCircleContactWrapper.ResetRestitution; cdecl; begin b2ChainAndCircleContact_ResetRestitution(FHandle) end; procedure b2ChainAndCircleContact_SetTangentSpeed(_self: b2ChainAndCircleContactHandle; speed: Single); cdecl; external LIB_NAME name _PU + 'b2ChainAndCircleContact_SetTangentSpeed' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ChainAndCircleContactWrapper.SetTangentSpeed(speed: Single); cdecl; begin b2ChainAndCircleContact_SetTangentSpeed(FHandle, speed) end; function b2ChainAndCircleContact_GetTangentSpeed(_self: b2ChainAndCircleContactHandle): Single; cdecl; external LIB_NAME name _PU + 'b2ChainAndCircleContact_GetTangentSpeed' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ChainAndCircleContactWrapper.GetTangentSpeed: Single; cdecl; begin Result := b2ChainAndCircleContact_GetTangentSpeed(FHandle) end; procedure b2ChainAndCircleContact_Evaluate(_self: b2ChainAndCircleContactHandle; manifold: Pb2Manifold; const [ref] xfA: b2Transform; const [ref] xfB: b2Transform); cdecl; external LIB_NAME name _PU + 'b2ChainAndCircleContact_Evaluate' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ChainAndCircleContactWrapper.Evaluate(manifold: Pb2Manifold; const [ref] xfA: b2Transform; const [ref] xfB: b2Transform); cdecl; begin b2ChainAndCircleContact_Evaluate(FHandle, manifold, xfA, xfB) end; function b2ChainAndCircleContact_Create_(_self: b2ChainAndCircleContactHandle; fixtureA: Pb2Fixture; indexA: Integer; fixtureB: Pb2Fixture; indexB: Integer; allocator: b2BlockAllocatorHandle): b2ContactHandle; cdecl; external LIB_NAME name _PU + 'b2ChainAndCircleContact_Create' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ChainAndCircleContactWrapper.Create_(fixtureA: Pb2Fixture; indexA: Integer; fixtureB: Pb2Fixture; indexB: Integer; allocator: b2BlockAllocatorHandle): b2ContactHandle; cdecl; begin Result := b2ChainAndCircleContact_Create_(FHandle, fixtureA, indexA, fixtureB, indexB, allocator) end; procedure b2ChainAndCircleContact_Destroy_(_self: b2ChainAndCircleContactHandle; contact: b2ContactHandle; allocator: b2BlockAllocatorHandle); cdecl; external LIB_NAME name _PU + 'b2ChainAndCircleContact_Destroy' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ChainAndCircleContactWrapper.Destroy_(contact: b2ContactHandle; allocator: b2BlockAllocatorHandle); cdecl; begin b2ChainAndCircleContact_Destroy_(FHandle, contact, allocator) end; function b2ChainAndPolygonContact_Create(fixtureA: Pb2Fixture; indexA: Integer; fixtureB: Pb2Fixture; indexB: Integer): b2ChainAndPolygonContactHandle; cdecl; external LIB_NAME name _PU + 'b2ChainAndPolygonContact_b2ChainAndPolygonContact_1' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; class function b2ChainAndPolygonContactWrapper.Create(fixtureA: Pb2Fixture; indexA: Integer; fixtureB: Pb2Fixture; indexB: Integer): b2ChainAndPolygonContactWrapper; cdecl; begin Result.FHandle := b2ChainAndPolygonContact_Create(fixtureA, indexA, fixtureB, indexB); end; procedure b2ChainAndPolygonContact_Destroy(_self: b2ChainAndPolygonContactHandle); cdecl; external LIB_NAME name _PU + 'b2ChainAndPolygonContact_dtor' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ChainAndPolygonContactWrapper.Destroy; cdecl; begin b2ChainAndPolygonContact_Destroy(FHandle); end; class operator b2ChainAndPolygonContactWrapper.Implicit(handle: b2ChainAndPolygonContactHandle): b2ChainAndPolygonContactWrapper; begin Result.FHandle := handle; end; class operator b2ChainAndPolygonContactWrapper.Implicit(wrapper: b2ChainAndPolygonContactWrapper): b2ChainAndPolygonContactHandle; begin Result := wrapper.FHandle; end; function b2ChainAndPolygonContact_GetManifold(_self: b2ChainAndPolygonContactHandle): Pb2Manifold; cdecl; external LIB_NAME name _PU + 'b2ChainAndPolygonContact_GetManifold' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ChainAndPolygonContactWrapper.GetManifold: Pb2Manifold; cdecl; begin Result := b2ChainAndPolygonContact_GetManifold(FHandle) end; procedure b2ChainAndPolygonContact_GetWorldManifold(_self: b2ChainAndPolygonContactHandle; worldManifold: Pb2WorldManifold); cdecl; external LIB_NAME name _PU + 'b2ChainAndPolygonContact_GetWorldManifold' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ChainAndPolygonContactWrapper.GetWorldManifold(worldManifold: Pb2WorldManifold); cdecl; begin b2ChainAndPolygonContact_GetWorldManifold(FHandle, worldManifold) end; function b2ChainAndPolygonContact_IsTouching(_self: b2ChainAndPolygonContactHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2ChainAndPolygonContact_IsTouching' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ChainAndPolygonContactWrapper.IsTouching: Boolean; cdecl; begin Result := b2ChainAndPolygonContact_IsTouching(FHandle) end; procedure b2ChainAndPolygonContact_SetEnabled(_self: b2ChainAndPolygonContactHandle; flag: Boolean); cdecl; external LIB_NAME name _PU + 'b2ChainAndPolygonContact_SetEnabled' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ChainAndPolygonContactWrapper.SetEnabled(flag: Boolean); cdecl; begin b2ChainAndPolygonContact_SetEnabled(FHandle, flag) end; function b2ChainAndPolygonContact_IsEnabled(_self: b2ChainAndPolygonContactHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2ChainAndPolygonContact_IsEnabled' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ChainAndPolygonContactWrapper.IsEnabled: Boolean; cdecl; begin Result := b2ChainAndPolygonContact_IsEnabled(FHandle) end; function b2ChainAndPolygonContact_GetNext(_self: b2ChainAndPolygonContactHandle): b2ContactHandle; cdecl; external LIB_NAME name _PU + 'b2ChainAndPolygonContact_GetNext' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ChainAndPolygonContactWrapper.GetNext: b2ContactHandle; cdecl; begin Result := b2ChainAndPolygonContact_GetNext(FHandle) end; function b2ChainAndPolygonContact_GetFixtureA(_self: b2ChainAndPolygonContactHandle): Pb2Fixture; cdecl; external LIB_NAME name _PU + 'b2ChainAndPolygonContact_GetFixtureA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ChainAndPolygonContactWrapper.GetFixtureA: Pb2Fixture; cdecl; begin Result := b2ChainAndPolygonContact_GetFixtureA(FHandle) end; function b2ChainAndPolygonContact_GetChildIndexA(_self: b2ChainAndPolygonContactHandle): Integer; cdecl; external LIB_NAME name _PU + 'b2ChainAndPolygonContact_GetChildIndexA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ChainAndPolygonContactWrapper.GetChildIndexA: Integer; cdecl; begin Result := b2ChainAndPolygonContact_GetChildIndexA(FHandle) end; function b2ChainAndPolygonContact_GetFixtureB(_self: b2ChainAndPolygonContactHandle): Pb2Fixture; cdecl; external LIB_NAME name _PU + 'b2ChainAndPolygonContact_GetFixtureB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ChainAndPolygonContactWrapper.GetFixtureB: Pb2Fixture; cdecl; begin Result := b2ChainAndPolygonContact_GetFixtureB(FHandle) end; function b2ChainAndPolygonContact_GetChildIndexB(_self: b2ChainAndPolygonContactHandle): Integer; cdecl; external LIB_NAME name _PU + 'b2ChainAndPolygonContact_GetChildIndexB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ChainAndPolygonContactWrapper.GetChildIndexB: Integer; cdecl; begin Result := b2ChainAndPolygonContact_GetChildIndexB(FHandle) end; procedure b2ChainAndPolygonContact_SetFriction(_self: b2ChainAndPolygonContactHandle; friction: Single); cdecl; external LIB_NAME name _PU + 'b2ChainAndPolygonContact_SetFriction' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ChainAndPolygonContactWrapper.SetFriction(friction: Single); cdecl; begin b2ChainAndPolygonContact_SetFriction(FHandle, friction) end; function b2ChainAndPolygonContact_GetFriction(_self: b2ChainAndPolygonContactHandle): Single; cdecl; external LIB_NAME name _PU + 'b2ChainAndPolygonContact_GetFriction' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ChainAndPolygonContactWrapper.GetFriction: Single; cdecl; begin Result := b2ChainAndPolygonContact_GetFriction(FHandle) end; procedure b2ChainAndPolygonContact_ResetFriction(_self: b2ChainAndPolygonContactHandle); cdecl; external LIB_NAME name _PU + 'b2ChainAndPolygonContact_ResetFriction' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ChainAndPolygonContactWrapper.ResetFriction; cdecl; begin b2ChainAndPolygonContact_ResetFriction(FHandle) end; procedure b2ChainAndPolygonContact_SetRestitution(_self: b2ChainAndPolygonContactHandle; restitution: Single); cdecl; external LIB_NAME name _PU + 'b2ChainAndPolygonContact_SetRestitution' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ChainAndPolygonContactWrapper.SetRestitution(restitution: Single); cdecl; begin b2ChainAndPolygonContact_SetRestitution(FHandle, restitution) end; function b2ChainAndPolygonContact_GetRestitution(_self: b2ChainAndPolygonContactHandle): Single; cdecl; external LIB_NAME name _PU + 'b2ChainAndPolygonContact_GetRestitution' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ChainAndPolygonContactWrapper.GetRestitution: Single; cdecl; begin Result := b2ChainAndPolygonContact_GetRestitution(FHandle) end; procedure b2ChainAndPolygonContact_ResetRestitution(_self: b2ChainAndPolygonContactHandle); cdecl; external LIB_NAME name _PU + 'b2ChainAndPolygonContact_ResetRestitution' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ChainAndPolygonContactWrapper.ResetRestitution; cdecl; begin b2ChainAndPolygonContact_ResetRestitution(FHandle) end; procedure b2ChainAndPolygonContact_SetTangentSpeed(_self: b2ChainAndPolygonContactHandle; speed: Single); cdecl; external LIB_NAME name _PU + 'b2ChainAndPolygonContact_SetTangentSpeed' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ChainAndPolygonContactWrapper.SetTangentSpeed(speed: Single); cdecl; begin b2ChainAndPolygonContact_SetTangentSpeed(FHandle, speed) end; function b2ChainAndPolygonContact_GetTangentSpeed(_self: b2ChainAndPolygonContactHandle): Single; cdecl; external LIB_NAME name _PU + 'b2ChainAndPolygonContact_GetTangentSpeed' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ChainAndPolygonContactWrapper.GetTangentSpeed: Single; cdecl; begin Result := b2ChainAndPolygonContact_GetTangentSpeed(FHandle) end; procedure b2ChainAndPolygonContact_Evaluate(_self: b2ChainAndPolygonContactHandle; manifold: Pb2Manifold; const [ref] xfA: b2Transform; const [ref] xfB: b2Transform); cdecl; external LIB_NAME name _PU + 'b2ChainAndPolygonContact_Evaluate' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ChainAndPolygonContactWrapper.Evaluate(manifold: Pb2Manifold; const [ref] xfA: b2Transform; const [ref] xfB: b2Transform); cdecl; begin b2ChainAndPolygonContact_Evaluate(FHandle, manifold, xfA, xfB) end; function b2ChainAndPolygonContact_Create_(_self: b2ChainAndPolygonContactHandle; fixtureA: Pb2Fixture; indexA: Integer; fixtureB: Pb2Fixture; indexB: Integer; allocator: b2BlockAllocatorHandle): b2ContactHandle; cdecl; external LIB_NAME name _PU + 'b2ChainAndPolygonContact_Create' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ChainAndPolygonContactWrapper.Create_(fixtureA: Pb2Fixture; indexA: Integer; fixtureB: Pb2Fixture; indexB: Integer; allocator: b2BlockAllocatorHandle): b2ContactHandle; cdecl; begin Result := b2ChainAndPolygonContact_Create_(FHandle, fixtureA, indexA, fixtureB, indexB, allocator) end; procedure b2ChainAndPolygonContact_Destroy_(_self: b2ChainAndPolygonContactHandle; contact: b2ContactHandle; allocator: b2BlockAllocatorHandle); cdecl; external LIB_NAME name _PU + 'b2ChainAndPolygonContact_Destroy' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ChainAndPolygonContactWrapper.Destroy_(contact: b2ContactHandle; allocator: b2BlockAllocatorHandle); cdecl; begin b2ChainAndPolygonContact_Destroy_(FHandle, contact, allocator) end; function b2CircleContact_Create(fixtureA: Pb2Fixture; fixtureB: Pb2Fixture): b2CircleContactHandle; cdecl; external LIB_NAME name _PU + 'b2CircleContact_b2CircleContact_1' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; class function b2CircleContactWrapper.Create(fixtureA: Pb2Fixture; fixtureB: Pb2Fixture): b2CircleContactWrapper; cdecl; begin Result.FHandle := b2CircleContact_Create(fixtureA, fixtureB); end; procedure b2CircleContact_Destroy(_self: b2CircleContactHandle); cdecl; external LIB_NAME name _PU + 'b2CircleContact_dtor' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2CircleContactWrapper.Destroy; cdecl; begin b2CircleContact_Destroy(FHandle); end; class operator b2CircleContactWrapper.Implicit(handle: b2CircleContactHandle): b2CircleContactWrapper; begin Result.FHandle := handle; end; class operator b2CircleContactWrapper.Implicit(wrapper: b2CircleContactWrapper): b2CircleContactHandle; begin Result := wrapper.FHandle; end; function b2CircleContact_GetManifold(_self: b2CircleContactHandle): Pb2Manifold; cdecl; external LIB_NAME name _PU + 'b2CircleContact_GetManifold' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2CircleContactWrapper.GetManifold: Pb2Manifold; cdecl; begin Result := b2CircleContact_GetManifold(FHandle) end; procedure b2CircleContact_GetWorldManifold(_self: b2CircleContactHandle; worldManifold: Pb2WorldManifold); cdecl; external LIB_NAME name _PU + 'b2CircleContact_GetWorldManifold' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2CircleContactWrapper.GetWorldManifold(worldManifold: Pb2WorldManifold); cdecl; begin b2CircleContact_GetWorldManifold(FHandle, worldManifold) end; function b2CircleContact_IsTouching(_self: b2CircleContactHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2CircleContact_IsTouching' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2CircleContactWrapper.IsTouching: Boolean; cdecl; begin Result := b2CircleContact_IsTouching(FHandle) end; procedure b2CircleContact_SetEnabled(_self: b2CircleContactHandle; flag: Boolean); cdecl; external LIB_NAME name _PU + 'b2CircleContact_SetEnabled' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2CircleContactWrapper.SetEnabled(flag: Boolean); cdecl; begin b2CircleContact_SetEnabled(FHandle, flag) end; function b2CircleContact_IsEnabled(_self: b2CircleContactHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2CircleContact_IsEnabled' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2CircleContactWrapper.IsEnabled: Boolean; cdecl; begin Result := b2CircleContact_IsEnabled(FHandle) end; function b2CircleContact_GetNext(_self: b2CircleContactHandle): b2ContactHandle; cdecl; external LIB_NAME name _PU + 'b2CircleContact_GetNext' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2CircleContactWrapper.GetNext: b2ContactHandle; cdecl; begin Result := b2CircleContact_GetNext(FHandle) end; function b2CircleContact_GetFixtureA(_self: b2CircleContactHandle): Pb2Fixture; cdecl; external LIB_NAME name _PU + 'b2CircleContact_GetFixtureA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2CircleContactWrapper.GetFixtureA: Pb2Fixture; cdecl; begin Result := b2CircleContact_GetFixtureA(FHandle) end; function b2CircleContact_GetChildIndexA(_self: b2CircleContactHandle): Integer; cdecl; external LIB_NAME name _PU + 'b2CircleContact_GetChildIndexA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2CircleContactWrapper.GetChildIndexA: Integer; cdecl; begin Result := b2CircleContact_GetChildIndexA(FHandle) end; function b2CircleContact_GetFixtureB(_self: b2CircleContactHandle): Pb2Fixture; cdecl; external LIB_NAME name _PU + 'b2CircleContact_GetFixtureB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2CircleContactWrapper.GetFixtureB: Pb2Fixture; cdecl; begin Result := b2CircleContact_GetFixtureB(FHandle) end; function b2CircleContact_GetChildIndexB(_self: b2CircleContactHandle): Integer; cdecl; external LIB_NAME name _PU + 'b2CircleContact_GetChildIndexB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2CircleContactWrapper.GetChildIndexB: Integer; cdecl; begin Result := b2CircleContact_GetChildIndexB(FHandle) end; procedure b2CircleContact_SetFriction(_self: b2CircleContactHandle; friction: Single); cdecl; external LIB_NAME name _PU + 'b2CircleContact_SetFriction' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2CircleContactWrapper.SetFriction(friction: Single); cdecl; begin b2CircleContact_SetFriction(FHandle, friction) end; function b2CircleContact_GetFriction(_self: b2CircleContactHandle): Single; cdecl; external LIB_NAME name _PU + 'b2CircleContact_GetFriction' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2CircleContactWrapper.GetFriction: Single; cdecl; begin Result := b2CircleContact_GetFriction(FHandle) end; procedure b2CircleContact_ResetFriction(_self: b2CircleContactHandle); cdecl; external LIB_NAME name _PU + 'b2CircleContact_ResetFriction' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2CircleContactWrapper.ResetFriction; cdecl; begin b2CircleContact_ResetFriction(FHandle) end; procedure b2CircleContact_SetRestitution(_self: b2CircleContactHandle; restitution: Single); cdecl; external LIB_NAME name _PU + 'b2CircleContact_SetRestitution' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2CircleContactWrapper.SetRestitution(restitution: Single); cdecl; begin b2CircleContact_SetRestitution(FHandle, restitution) end; function b2CircleContact_GetRestitution(_self: b2CircleContactHandle): Single; cdecl; external LIB_NAME name _PU + 'b2CircleContact_GetRestitution' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2CircleContactWrapper.GetRestitution: Single; cdecl; begin Result := b2CircleContact_GetRestitution(FHandle) end; procedure b2CircleContact_ResetRestitution(_self: b2CircleContactHandle); cdecl; external LIB_NAME name _PU + 'b2CircleContact_ResetRestitution' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2CircleContactWrapper.ResetRestitution; cdecl; begin b2CircleContact_ResetRestitution(FHandle) end; procedure b2CircleContact_SetTangentSpeed(_self: b2CircleContactHandle; speed: Single); cdecl; external LIB_NAME name _PU + 'b2CircleContact_SetTangentSpeed' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2CircleContactWrapper.SetTangentSpeed(speed: Single); cdecl; begin b2CircleContact_SetTangentSpeed(FHandle, speed) end; function b2CircleContact_GetTangentSpeed(_self: b2CircleContactHandle): Single; cdecl; external LIB_NAME name _PU + 'b2CircleContact_GetTangentSpeed' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2CircleContactWrapper.GetTangentSpeed: Single; cdecl; begin Result := b2CircleContact_GetTangentSpeed(FHandle) end; procedure b2CircleContact_Evaluate(_self: b2CircleContactHandle; manifold: Pb2Manifold; const [ref] xfA: b2Transform; const [ref] xfB: b2Transform); cdecl; external LIB_NAME name _PU + 'b2CircleContact_Evaluate' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2CircleContactWrapper.Evaluate(manifold: Pb2Manifold; const [ref] xfA: b2Transform; const [ref] xfB: b2Transform); cdecl; begin b2CircleContact_Evaluate(FHandle, manifold, xfA, xfB) end; function b2CircleContact_Create_(_self: b2CircleContactHandle; fixtureA: Pb2Fixture; indexA: Integer; fixtureB: Pb2Fixture; indexB: Integer; allocator: b2BlockAllocatorHandle): b2ContactHandle; cdecl; external LIB_NAME name _PU + 'b2CircleContact_Create' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2CircleContactWrapper.Create_(fixtureA: Pb2Fixture; indexA: Integer; fixtureB: Pb2Fixture; indexB: Integer; allocator: b2BlockAllocatorHandle): b2ContactHandle; cdecl; begin Result := b2CircleContact_Create_(FHandle, fixtureA, indexA, fixtureB, indexB, allocator) end; procedure b2CircleContact_Destroy_(_self: b2CircleContactHandle; contact: b2ContactHandle; allocator: b2BlockAllocatorHandle); cdecl; external LIB_NAME name _PU + 'b2CircleContact_Destroy' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2CircleContactWrapper.Destroy_(contact: b2ContactHandle; allocator: b2BlockAllocatorHandle); cdecl; begin b2CircleContact_Destroy_(FHandle, contact, allocator) end; function b2VelocityConstraintPoint_Create: b2VelocityConstraintPoint; cdecl; external LIB_NAME name _PU + 'b2VelocityConstraintPoint_b2VelocityConstraintPoint' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; class function b2VelocityConstraintPoint.Create: b2VelocityConstraintPoint; cdecl; begin Result := b2VelocityConstraintPoint_Create; end; function b2ContactVelocityConstraint_Create: b2ContactVelocityConstraint; cdecl; external LIB_NAME name _PU + 'b2ContactVelocityConstraint_b2ContactVelocityConstraint' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; class function b2ContactVelocityConstraint.Create: b2ContactVelocityConstraint; cdecl; begin Result := b2ContactVelocityConstraint_Create; end; function b2ContactSolverDef_Create: b2ContactSolverDef; cdecl; external LIB_NAME name _PU + 'b2ContactSolverDef_b2ContactSolverDef' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; class function b2ContactSolverDef.Create: b2ContactSolverDef; cdecl; begin Result := b2ContactSolverDef_Create; end; function b2ContactSolver_Create(def: Pb2ContactSolverDef): b2ContactSolverHandle; cdecl; external LIB_NAME name _PU + 'b2ContactSolver_b2ContactSolver_1' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; class function b2ContactSolverWrapper.Create(def: Pb2ContactSolverDef): b2ContactSolverWrapper; cdecl; begin Result.FHandle := b2ContactSolver_Create(def); end; procedure b2ContactSolver_Destroy(_self: b2ContactSolverHandle); cdecl; external LIB_NAME name _PU + 'b2ContactSolver_dtor' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ContactSolverWrapper.Destroy; cdecl; begin b2ContactSolver_Destroy(FHandle); end; class operator b2ContactSolverWrapper.Implicit(handle: b2ContactSolverHandle): b2ContactSolverWrapper; begin Result.FHandle := handle; end; class operator b2ContactSolverWrapper.Implicit(wrapper: b2ContactSolverWrapper): b2ContactSolverHandle; begin Result := wrapper.FHandle; end; procedure b2ContactSolver_InitializeVelocityConstraints(_self: b2ContactSolverHandle); cdecl; external LIB_NAME name _PU + 'b2ContactSolver_InitializeVelocityConstraints' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ContactSolverWrapper.InitializeVelocityConstraints; cdecl; begin b2ContactSolver_InitializeVelocityConstraints(FHandle) end; procedure b2ContactSolver_WarmStart(_self: b2ContactSolverHandle); cdecl; external LIB_NAME name _PU + 'b2ContactSolver_WarmStart' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ContactSolverWrapper.WarmStart; cdecl; begin b2ContactSolver_WarmStart(FHandle) end; procedure b2ContactSolver_SolveVelocityConstraints(_self: b2ContactSolverHandle); cdecl; external LIB_NAME name _PU + 'b2ContactSolver_SolveVelocityConstraints' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ContactSolverWrapper.SolveVelocityConstraints; cdecl; begin b2ContactSolver_SolveVelocityConstraints(FHandle) end; procedure b2ContactSolver_StoreImpulses(_self: b2ContactSolverHandle); cdecl; external LIB_NAME name _PU + 'b2ContactSolver_StoreImpulses' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ContactSolverWrapper.StoreImpulses; cdecl; begin b2ContactSolver_StoreImpulses(FHandle) end; function b2ContactSolver_SolvePositionConstraints(_self: b2ContactSolverHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2ContactSolver_SolvePositionConstraints' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ContactSolverWrapper.SolvePositionConstraints: Boolean; cdecl; begin Result := b2ContactSolver_SolvePositionConstraints(FHandle) end; function b2ContactSolver_SolveTOIPositionConstraints(_self: b2ContactSolverHandle; toiIndexA: Integer; toiIndexB: Integer): Boolean; cdecl; external LIB_NAME name _PU + 'b2ContactSolver_SolveTOIPositionConstraints' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ContactSolverWrapper.SolveTOIPositionConstraints(toiIndexA: Integer; toiIndexB: Integer): Boolean; cdecl; begin Result := b2ContactSolver_SolveTOIPositionConstraints(FHandle, toiIndexA, toiIndexB) end; function b2ContactSolver_Get_m_step(_self: b2ContactSolverHandle): b2TimeStep; cdecl; external LIB_NAME name _PU + 'b2ContactSolver_Get_m_step' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ContactSolver_Set_m_step(_self: b2ContactSolverHandle; aNewValue: b2TimeStep); cdecl; external LIB_NAME name _PU + 'b2ContactSolver_Set_m_step' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ContactSolver_Get_m_step_P(_self: b2ContactSolverHandle): Pb2TimeStep; cdecl; external LIB_NAME name _PU + 'b2ContactSolver_Get_m_step_P' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ContactSolverWrapper.Get_m_step: b2TimeStep; cdecl; begin Result := b2ContactSolver_Get_m_step(FHandle); end; procedure b2ContactSolverWrapper.Set_m_step(aNewValue: b2TimeStep); cdecl; begin b2ContactSolver_Set_m_step(FHandle, aNewValue); end; function b2ContactSolverWrapper.Get_m_step_P: Pb2TimeStep; cdecl; begin Result := b2ContactSolver_Get_m_step_P(FHandle); end; function b2ContactSolver_Get_m_positions(_self: b2ContactSolverHandle): Pb2Position; cdecl; external LIB_NAME name _PU + 'b2ContactSolver_Get_m_positions' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ContactSolver_Set_m_positions(_self: b2ContactSolverHandle; aNewValue: Pb2Position); cdecl; external LIB_NAME name _PU + 'b2ContactSolver_Set_m_positions' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ContactSolverWrapper.Get_m_positions: Pb2Position; cdecl; begin Result := b2ContactSolver_Get_m_positions(FHandle); end; procedure b2ContactSolverWrapper.Set_m_positions(aNewValue: Pb2Position); cdecl; begin b2ContactSolver_Set_m_positions(FHandle, aNewValue); end; function b2ContactSolver_Get_m_velocities(_self: b2ContactSolverHandle): Pb2Velocity; cdecl; external LIB_NAME name _PU + 'b2ContactSolver_Get_m_velocities' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ContactSolver_Set_m_velocities(_self: b2ContactSolverHandle; aNewValue: Pb2Velocity); cdecl; external LIB_NAME name _PU + 'b2ContactSolver_Set_m_velocities' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ContactSolverWrapper.Get_m_velocities: Pb2Velocity; cdecl; begin Result := b2ContactSolver_Get_m_velocities(FHandle); end; procedure b2ContactSolverWrapper.Set_m_velocities(aNewValue: Pb2Velocity); cdecl; begin b2ContactSolver_Set_m_velocities(FHandle, aNewValue); end; function b2ContactSolver_Get_m_allocator(_self: b2ContactSolverHandle): b2StackAllocatorHandle; cdecl; external LIB_NAME name _PU + 'b2ContactSolver_Get_m_allocator' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ContactSolver_Set_m_allocator(_self: b2ContactSolverHandle; aNewValue: b2StackAllocatorHandle); cdecl; external LIB_NAME name _PU + 'b2ContactSolver_Set_m_allocator' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ContactSolverWrapper.Get_m_allocator: b2StackAllocatorHandle; cdecl; begin Result := b2ContactSolver_Get_m_allocator(FHandle); end; procedure b2ContactSolverWrapper.Set_m_allocator(aNewValue: b2StackAllocatorHandle); cdecl; begin b2ContactSolver_Set_m_allocator(FHandle, aNewValue); end; function b2ContactSolver_Get_m_velocityConstraints(_self: b2ContactSolverHandle): Pb2ContactVelocityConstraint; cdecl; external LIB_NAME name _PU + 'b2ContactSolver_Get_m_velocityConstraints' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ContactSolver_Set_m_velocityConstraints(_self: b2ContactSolverHandle; aNewValue: Pb2ContactVelocityConstraint); cdecl; external LIB_NAME name _PU + 'b2ContactSolver_Set_m_velocityConstraints' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ContactSolverWrapper.Get_m_velocityConstraints: Pb2ContactVelocityConstraint; cdecl; begin Result := b2ContactSolver_Get_m_velocityConstraints(FHandle); end; procedure b2ContactSolverWrapper.Set_m_velocityConstraints(aNewValue: Pb2ContactVelocityConstraint); cdecl; begin b2ContactSolver_Set_m_velocityConstraints(FHandle, aNewValue); end; function b2ContactSolver_Get_m_contacts(_self: b2ContactSolverHandle): Pb2ContactHandle; cdecl; external LIB_NAME name _PU + 'b2ContactSolver_Get_m_contacts' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ContactSolver_Set_m_contacts(_self: b2ContactSolverHandle; aNewValue: Pb2ContactHandle); cdecl; external LIB_NAME name _PU + 'b2ContactSolver_Set_m_contacts' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ContactSolverWrapper.Get_m_contacts: Pb2ContactHandle; cdecl; begin Result := b2ContactSolver_Get_m_contacts(FHandle); end; procedure b2ContactSolverWrapper.Set_m_contacts(aNewValue: Pb2ContactHandle); cdecl; begin b2ContactSolver_Set_m_contacts(FHandle, aNewValue); end; function b2ContactSolver_Get_m_count(_self: b2ContactSolverHandle): Integer; cdecl; external LIB_NAME name _PU + 'b2ContactSolver_Get_m_count' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2ContactSolver_Set_m_count(_self: b2ContactSolverHandle; aNewValue: Integer); cdecl; external LIB_NAME name _PU + 'b2ContactSolver_Set_m_count' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2ContactSolverWrapper.Get_m_count: Integer; cdecl; begin Result := b2ContactSolver_Get_m_count(FHandle); end; procedure b2ContactSolverWrapper.Set_m_count(aNewValue: Integer); cdecl; begin b2ContactSolver_Set_m_count(FHandle, aNewValue); end; function b2EdgeAndCircleContact_Create(fixtureA: Pb2Fixture; fixtureB: Pb2Fixture): b2EdgeAndCircleContactHandle; cdecl; external LIB_NAME name _PU + 'b2EdgeAndCircleContact_b2EdgeAndCircleContact_1' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; class function b2EdgeAndCircleContactWrapper.Create(fixtureA: Pb2Fixture; fixtureB: Pb2Fixture): b2EdgeAndCircleContactWrapper; cdecl; begin Result.FHandle := b2EdgeAndCircleContact_Create(fixtureA, fixtureB); end; procedure b2EdgeAndCircleContact_Destroy(_self: b2EdgeAndCircleContactHandle); cdecl; external LIB_NAME name _PU + 'b2EdgeAndCircleContact_dtor' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2EdgeAndCircleContactWrapper.Destroy; cdecl; begin b2EdgeAndCircleContact_Destroy(FHandle); end; class operator b2EdgeAndCircleContactWrapper.Implicit(handle: b2EdgeAndCircleContactHandle): b2EdgeAndCircleContactWrapper; begin Result.FHandle := handle; end; class operator b2EdgeAndCircleContactWrapper.Implicit(wrapper: b2EdgeAndCircleContactWrapper): b2EdgeAndCircleContactHandle; begin Result := wrapper.FHandle; end; function b2EdgeAndCircleContact_GetManifold(_self: b2EdgeAndCircleContactHandle): Pb2Manifold; cdecl; external LIB_NAME name _PU + 'b2EdgeAndCircleContact_GetManifold' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2EdgeAndCircleContactWrapper.GetManifold: Pb2Manifold; cdecl; begin Result := b2EdgeAndCircleContact_GetManifold(FHandle) end; procedure b2EdgeAndCircleContact_GetWorldManifold(_self: b2EdgeAndCircleContactHandle; worldManifold: Pb2WorldManifold); cdecl; external LIB_NAME name _PU + 'b2EdgeAndCircleContact_GetWorldManifold' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2EdgeAndCircleContactWrapper.GetWorldManifold(worldManifold: Pb2WorldManifold); cdecl; begin b2EdgeAndCircleContact_GetWorldManifold(FHandle, worldManifold) end; function b2EdgeAndCircleContact_IsTouching(_self: b2EdgeAndCircleContactHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2EdgeAndCircleContact_IsTouching' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2EdgeAndCircleContactWrapper.IsTouching: Boolean; cdecl; begin Result := b2EdgeAndCircleContact_IsTouching(FHandle) end; procedure b2EdgeAndCircleContact_SetEnabled(_self: b2EdgeAndCircleContactHandle; flag: Boolean); cdecl; external LIB_NAME name _PU + 'b2EdgeAndCircleContact_SetEnabled' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2EdgeAndCircleContactWrapper.SetEnabled(flag: Boolean); cdecl; begin b2EdgeAndCircleContact_SetEnabled(FHandle, flag) end; function b2EdgeAndCircleContact_IsEnabled(_self: b2EdgeAndCircleContactHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2EdgeAndCircleContact_IsEnabled' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2EdgeAndCircleContactWrapper.IsEnabled: Boolean; cdecl; begin Result := b2EdgeAndCircleContact_IsEnabled(FHandle) end; function b2EdgeAndCircleContact_GetNext(_self: b2EdgeAndCircleContactHandle): b2ContactHandle; cdecl; external LIB_NAME name _PU + 'b2EdgeAndCircleContact_GetNext' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2EdgeAndCircleContactWrapper.GetNext: b2ContactHandle; cdecl; begin Result := b2EdgeAndCircleContact_GetNext(FHandle) end; function b2EdgeAndCircleContact_GetFixtureA(_self: b2EdgeAndCircleContactHandle): Pb2Fixture; cdecl; external LIB_NAME name _PU + 'b2EdgeAndCircleContact_GetFixtureA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2EdgeAndCircleContactWrapper.GetFixtureA: Pb2Fixture; cdecl; begin Result := b2EdgeAndCircleContact_GetFixtureA(FHandle) end; function b2EdgeAndCircleContact_GetChildIndexA(_self: b2EdgeAndCircleContactHandle): Integer; cdecl; external LIB_NAME name _PU + 'b2EdgeAndCircleContact_GetChildIndexA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2EdgeAndCircleContactWrapper.GetChildIndexA: Integer; cdecl; begin Result := b2EdgeAndCircleContact_GetChildIndexA(FHandle) end; function b2EdgeAndCircleContact_GetFixtureB(_self: b2EdgeAndCircleContactHandle): Pb2Fixture; cdecl; external LIB_NAME name _PU + 'b2EdgeAndCircleContact_GetFixtureB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2EdgeAndCircleContactWrapper.GetFixtureB: Pb2Fixture; cdecl; begin Result := b2EdgeAndCircleContact_GetFixtureB(FHandle) end; function b2EdgeAndCircleContact_GetChildIndexB(_self: b2EdgeAndCircleContactHandle): Integer; cdecl; external LIB_NAME name _PU + 'b2EdgeAndCircleContact_GetChildIndexB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2EdgeAndCircleContactWrapper.GetChildIndexB: Integer; cdecl; begin Result := b2EdgeAndCircleContact_GetChildIndexB(FHandle) end; procedure b2EdgeAndCircleContact_SetFriction(_self: b2EdgeAndCircleContactHandle; friction: Single); cdecl; external LIB_NAME name _PU + 'b2EdgeAndCircleContact_SetFriction' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2EdgeAndCircleContactWrapper.SetFriction(friction: Single); cdecl; begin b2EdgeAndCircleContact_SetFriction(FHandle, friction) end; function b2EdgeAndCircleContact_GetFriction(_self: b2EdgeAndCircleContactHandle): Single; cdecl; external LIB_NAME name _PU + 'b2EdgeAndCircleContact_GetFriction' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2EdgeAndCircleContactWrapper.GetFriction: Single; cdecl; begin Result := b2EdgeAndCircleContact_GetFriction(FHandle) end; procedure b2EdgeAndCircleContact_ResetFriction(_self: b2EdgeAndCircleContactHandle); cdecl; external LIB_NAME name _PU + 'b2EdgeAndCircleContact_ResetFriction' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2EdgeAndCircleContactWrapper.ResetFriction; cdecl; begin b2EdgeAndCircleContact_ResetFriction(FHandle) end; procedure b2EdgeAndCircleContact_SetRestitution(_self: b2EdgeAndCircleContactHandle; restitution: Single); cdecl; external LIB_NAME name _PU + 'b2EdgeAndCircleContact_SetRestitution' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2EdgeAndCircleContactWrapper.SetRestitution(restitution: Single); cdecl; begin b2EdgeAndCircleContact_SetRestitution(FHandle, restitution) end; function b2EdgeAndCircleContact_GetRestitution(_self: b2EdgeAndCircleContactHandle): Single; cdecl; external LIB_NAME name _PU + 'b2EdgeAndCircleContact_GetRestitution' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2EdgeAndCircleContactWrapper.GetRestitution: Single; cdecl; begin Result := b2EdgeAndCircleContact_GetRestitution(FHandle) end; procedure b2EdgeAndCircleContact_ResetRestitution(_self: b2EdgeAndCircleContactHandle); cdecl; external LIB_NAME name _PU + 'b2EdgeAndCircleContact_ResetRestitution' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2EdgeAndCircleContactWrapper.ResetRestitution; cdecl; begin b2EdgeAndCircleContact_ResetRestitution(FHandle) end; procedure b2EdgeAndCircleContact_SetTangentSpeed(_self: b2EdgeAndCircleContactHandle; speed: Single); cdecl; external LIB_NAME name _PU + 'b2EdgeAndCircleContact_SetTangentSpeed' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2EdgeAndCircleContactWrapper.SetTangentSpeed(speed: Single); cdecl; begin b2EdgeAndCircleContact_SetTangentSpeed(FHandle, speed) end; function b2EdgeAndCircleContact_GetTangentSpeed(_self: b2EdgeAndCircleContactHandle): Single; cdecl; external LIB_NAME name _PU + 'b2EdgeAndCircleContact_GetTangentSpeed' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2EdgeAndCircleContactWrapper.GetTangentSpeed: Single; cdecl; begin Result := b2EdgeAndCircleContact_GetTangentSpeed(FHandle) end; procedure b2EdgeAndCircleContact_Evaluate(_self: b2EdgeAndCircleContactHandle; manifold: Pb2Manifold; const [ref] xfA: b2Transform; const [ref] xfB: b2Transform); cdecl; external LIB_NAME name _PU + 'b2EdgeAndCircleContact_Evaluate' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2EdgeAndCircleContactWrapper.Evaluate(manifold: Pb2Manifold; const [ref] xfA: b2Transform; const [ref] xfB: b2Transform); cdecl; begin b2EdgeAndCircleContact_Evaluate(FHandle, manifold, xfA, xfB) end; function b2EdgeAndCircleContact_Create_(_self: b2EdgeAndCircleContactHandle; fixtureA: Pb2Fixture; indexA: Integer; fixtureB: Pb2Fixture; indexB: Integer; allocator: b2BlockAllocatorHandle): b2ContactHandle; cdecl; external LIB_NAME name _PU + 'b2EdgeAndCircleContact_Create' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2EdgeAndCircleContactWrapper.Create_(fixtureA: Pb2Fixture; indexA: Integer; fixtureB: Pb2Fixture; indexB: Integer; allocator: b2BlockAllocatorHandle): b2ContactHandle; cdecl; begin Result := b2EdgeAndCircleContact_Create_(FHandle, fixtureA, indexA, fixtureB, indexB, allocator) end; procedure b2EdgeAndCircleContact_Destroy_(_self: b2EdgeAndCircleContactHandle; contact: b2ContactHandle; allocator: b2BlockAllocatorHandle); cdecl; external LIB_NAME name _PU + 'b2EdgeAndCircleContact_Destroy' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2EdgeAndCircleContactWrapper.Destroy_(contact: b2ContactHandle; allocator: b2BlockAllocatorHandle); cdecl; begin b2EdgeAndCircleContact_Destroy_(FHandle, contact, allocator) end; function b2EdgeAndPolygonContact_Create(fixtureA: Pb2Fixture; fixtureB: Pb2Fixture): b2EdgeAndPolygonContactHandle; cdecl; external LIB_NAME name _PU + 'b2EdgeAndPolygonContact_b2EdgeAndPolygonContact_1' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; class function b2EdgeAndPolygonContactWrapper.Create(fixtureA: Pb2Fixture; fixtureB: Pb2Fixture): b2EdgeAndPolygonContactWrapper; cdecl; begin Result.FHandle := b2EdgeAndPolygonContact_Create(fixtureA, fixtureB); end; procedure b2EdgeAndPolygonContact_Destroy(_self: b2EdgeAndPolygonContactHandle); cdecl; external LIB_NAME name _PU + 'b2EdgeAndPolygonContact_dtor' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2EdgeAndPolygonContactWrapper.Destroy; cdecl; begin b2EdgeAndPolygonContact_Destroy(FHandle); end; class operator b2EdgeAndPolygonContactWrapper.Implicit(handle: b2EdgeAndPolygonContactHandle): b2EdgeAndPolygonContactWrapper; begin Result.FHandle := handle; end; class operator b2EdgeAndPolygonContactWrapper.Implicit(wrapper: b2EdgeAndPolygonContactWrapper): b2EdgeAndPolygonContactHandle; begin Result := wrapper.FHandle; end; function b2EdgeAndPolygonContact_GetManifold(_self: b2EdgeAndPolygonContactHandle): Pb2Manifold; cdecl; external LIB_NAME name _PU + 'b2EdgeAndPolygonContact_GetManifold' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2EdgeAndPolygonContactWrapper.GetManifold: Pb2Manifold; cdecl; begin Result := b2EdgeAndPolygonContact_GetManifold(FHandle) end; procedure b2EdgeAndPolygonContact_GetWorldManifold(_self: b2EdgeAndPolygonContactHandle; worldManifold: Pb2WorldManifold); cdecl; external LIB_NAME name _PU + 'b2EdgeAndPolygonContact_GetWorldManifold' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2EdgeAndPolygonContactWrapper.GetWorldManifold(worldManifold: Pb2WorldManifold); cdecl; begin b2EdgeAndPolygonContact_GetWorldManifold(FHandle, worldManifold) end; function b2EdgeAndPolygonContact_IsTouching(_self: b2EdgeAndPolygonContactHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2EdgeAndPolygonContact_IsTouching' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2EdgeAndPolygonContactWrapper.IsTouching: Boolean; cdecl; begin Result := b2EdgeAndPolygonContact_IsTouching(FHandle) end; procedure b2EdgeAndPolygonContact_SetEnabled(_self: b2EdgeAndPolygonContactHandle; flag: Boolean); cdecl; external LIB_NAME name _PU + 'b2EdgeAndPolygonContact_SetEnabled' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2EdgeAndPolygonContactWrapper.SetEnabled(flag: Boolean); cdecl; begin b2EdgeAndPolygonContact_SetEnabled(FHandle, flag) end; function b2EdgeAndPolygonContact_IsEnabled(_self: b2EdgeAndPolygonContactHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2EdgeAndPolygonContact_IsEnabled' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2EdgeAndPolygonContactWrapper.IsEnabled: Boolean; cdecl; begin Result := b2EdgeAndPolygonContact_IsEnabled(FHandle) end; function b2EdgeAndPolygonContact_GetNext(_self: b2EdgeAndPolygonContactHandle): b2ContactHandle; cdecl; external LIB_NAME name _PU + 'b2EdgeAndPolygonContact_GetNext' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2EdgeAndPolygonContactWrapper.GetNext: b2ContactHandle; cdecl; begin Result := b2EdgeAndPolygonContact_GetNext(FHandle) end; function b2EdgeAndPolygonContact_GetFixtureA(_self: b2EdgeAndPolygonContactHandle): Pb2Fixture; cdecl; external LIB_NAME name _PU + 'b2EdgeAndPolygonContact_GetFixtureA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2EdgeAndPolygonContactWrapper.GetFixtureA: Pb2Fixture; cdecl; begin Result := b2EdgeAndPolygonContact_GetFixtureA(FHandle) end; function b2EdgeAndPolygonContact_GetChildIndexA(_self: b2EdgeAndPolygonContactHandle): Integer; cdecl; external LIB_NAME name _PU + 'b2EdgeAndPolygonContact_GetChildIndexA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2EdgeAndPolygonContactWrapper.GetChildIndexA: Integer; cdecl; begin Result := b2EdgeAndPolygonContact_GetChildIndexA(FHandle) end; function b2EdgeAndPolygonContact_GetFixtureB(_self: b2EdgeAndPolygonContactHandle): Pb2Fixture; cdecl; external LIB_NAME name _PU + 'b2EdgeAndPolygonContact_GetFixtureB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2EdgeAndPolygonContactWrapper.GetFixtureB: Pb2Fixture; cdecl; begin Result := b2EdgeAndPolygonContact_GetFixtureB(FHandle) end; function b2EdgeAndPolygonContact_GetChildIndexB(_self: b2EdgeAndPolygonContactHandle): Integer; cdecl; external LIB_NAME name _PU + 'b2EdgeAndPolygonContact_GetChildIndexB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2EdgeAndPolygonContactWrapper.GetChildIndexB: Integer; cdecl; begin Result := b2EdgeAndPolygonContact_GetChildIndexB(FHandle) end; procedure b2EdgeAndPolygonContact_SetFriction(_self: b2EdgeAndPolygonContactHandle; friction: Single); cdecl; external LIB_NAME name _PU + 'b2EdgeAndPolygonContact_SetFriction' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2EdgeAndPolygonContactWrapper.SetFriction(friction: Single); cdecl; begin b2EdgeAndPolygonContact_SetFriction(FHandle, friction) end; function b2EdgeAndPolygonContact_GetFriction(_self: b2EdgeAndPolygonContactHandle): Single; cdecl; external LIB_NAME name _PU + 'b2EdgeAndPolygonContact_GetFriction' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2EdgeAndPolygonContactWrapper.GetFriction: Single; cdecl; begin Result := b2EdgeAndPolygonContact_GetFriction(FHandle) end; procedure b2EdgeAndPolygonContact_ResetFriction(_self: b2EdgeAndPolygonContactHandle); cdecl; external LIB_NAME name _PU + 'b2EdgeAndPolygonContact_ResetFriction' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2EdgeAndPolygonContactWrapper.ResetFriction; cdecl; begin b2EdgeAndPolygonContact_ResetFriction(FHandle) end; procedure b2EdgeAndPolygonContact_SetRestitution(_self: b2EdgeAndPolygonContactHandle; restitution: Single); cdecl; external LIB_NAME name _PU + 'b2EdgeAndPolygonContact_SetRestitution' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2EdgeAndPolygonContactWrapper.SetRestitution(restitution: Single); cdecl; begin b2EdgeAndPolygonContact_SetRestitution(FHandle, restitution) end; function b2EdgeAndPolygonContact_GetRestitution(_self: b2EdgeAndPolygonContactHandle): Single; cdecl; external LIB_NAME name _PU + 'b2EdgeAndPolygonContact_GetRestitution' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2EdgeAndPolygonContactWrapper.GetRestitution: Single; cdecl; begin Result := b2EdgeAndPolygonContact_GetRestitution(FHandle) end; procedure b2EdgeAndPolygonContact_ResetRestitution(_self: b2EdgeAndPolygonContactHandle); cdecl; external LIB_NAME name _PU + 'b2EdgeAndPolygonContact_ResetRestitution' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2EdgeAndPolygonContactWrapper.ResetRestitution; cdecl; begin b2EdgeAndPolygonContact_ResetRestitution(FHandle) end; procedure b2EdgeAndPolygonContact_SetTangentSpeed(_self: b2EdgeAndPolygonContactHandle; speed: Single); cdecl; external LIB_NAME name _PU + 'b2EdgeAndPolygonContact_SetTangentSpeed' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2EdgeAndPolygonContactWrapper.SetTangentSpeed(speed: Single); cdecl; begin b2EdgeAndPolygonContact_SetTangentSpeed(FHandle, speed) end; function b2EdgeAndPolygonContact_GetTangentSpeed(_self: b2EdgeAndPolygonContactHandle): Single; cdecl; external LIB_NAME name _PU + 'b2EdgeAndPolygonContact_GetTangentSpeed' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2EdgeAndPolygonContactWrapper.GetTangentSpeed: Single; cdecl; begin Result := b2EdgeAndPolygonContact_GetTangentSpeed(FHandle) end; procedure b2EdgeAndPolygonContact_Evaluate(_self: b2EdgeAndPolygonContactHandle; manifold: Pb2Manifold; const [ref] xfA: b2Transform; const [ref] xfB: b2Transform); cdecl; external LIB_NAME name _PU + 'b2EdgeAndPolygonContact_Evaluate' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2EdgeAndPolygonContactWrapper.Evaluate(manifold: Pb2Manifold; const [ref] xfA: b2Transform; const [ref] xfB: b2Transform); cdecl; begin b2EdgeAndPolygonContact_Evaluate(FHandle, manifold, xfA, xfB) end; function b2EdgeAndPolygonContact_Create_(_self: b2EdgeAndPolygonContactHandle; fixtureA: Pb2Fixture; indexA: Integer; fixtureB: Pb2Fixture; indexB: Integer; allocator: b2BlockAllocatorHandle): b2ContactHandle; cdecl; external LIB_NAME name _PU + 'b2EdgeAndPolygonContact_Create' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2EdgeAndPolygonContactWrapper.Create_(fixtureA: Pb2Fixture; indexA: Integer; fixtureB: Pb2Fixture; indexB: Integer; allocator: b2BlockAllocatorHandle): b2ContactHandle; cdecl; begin Result := b2EdgeAndPolygonContact_Create_(FHandle, fixtureA, indexA, fixtureB, indexB, allocator) end; procedure b2EdgeAndPolygonContact_Destroy_(_self: b2EdgeAndPolygonContactHandle; contact: b2ContactHandle; allocator: b2BlockAllocatorHandle); cdecl; external LIB_NAME name _PU + 'b2EdgeAndPolygonContact_Destroy' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2EdgeAndPolygonContactWrapper.Destroy_(contact: b2ContactHandle; allocator: b2BlockAllocatorHandle); cdecl; begin b2EdgeAndPolygonContact_Destroy_(FHandle, contact, allocator) end; function b2PolygonAndCircleContact_Create(fixtureA: Pb2Fixture; fixtureB: Pb2Fixture): b2PolygonAndCircleContactHandle; cdecl; external LIB_NAME name _PU + 'b2PolygonAndCircleContact_b2PolygonAndCircleContact_1' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; class function b2PolygonAndCircleContactWrapper.Create(fixtureA: Pb2Fixture; fixtureB: Pb2Fixture): b2PolygonAndCircleContactWrapper; cdecl; begin Result.FHandle := b2PolygonAndCircleContact_Create(fixtureA, fixtureB); end; procedure b2PolygonAndCircleContact_Destroy(_self: b2PolygonAndCircleContactHandle); cdecl; external LIB_NAME name _PU + 'b2PolygonAndCircleContact_dtor' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2PolygonAndCircleContactWrapper.Destroy; cdecl; begin b2PolygonAndCircleContact_Destroy(FHandle); end; class operator b2PolygonAndCircleContactWrapper.Implicit(handle: b2PolygonAndCircleContactHandle): b2PolygonAndCircleContactWrapper; begin Result.FHandle := handle; end; class operator b2PolygonAndCircleContactWrapper.Implicit(wrapper: b2PolygonAndCircleContactWrapper): b2PolygonAndCircleContactHandle; begin Result := wrapper.FHandle; end; function b2PolygonAndCircleContact_GetManifold(_self: b2PolygonAndCircleContactHandle): Pb2Manifold; cdecl; external LIB_NAME name _PU + 'b2PolygonAndCircleContact_GetManifold' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PolygonAndCircleContactWrapper.GetManifold: Pb2Manifold; cdecl; begin Result := b2PolygonAndCircleContact_GetManifold(FHandle) end; procedure b2PolygonAndCircleContact_GetWorldManifold(_self: b2PolygonAndCircleContactHandle; worldManifold: Pb2WorldManifold); cdecl; external LIB_NAME name _PU + 'b2PolygonAndCircleContact_GetWorldManifold' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2PolygonAndCircleContactWrapper.GetWorldManifold(worldManifold: Pb2WorldManifold); cdecl; begin b2PolygonAndCircleContact_GetWorldManifold(FHandle, worldManifold) end; function b2PolygonAndCircleContact_IsTouching(_self: b2PolygonAndCircleContactHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2PolygonAndCircleContact_IsTouching' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PolygonAndCircleContactWrapper.IsTouching: Boolean; cdecl; begin Result := b2PolygonAndCircleContact_IsTouching(FHandle) end; procedure b2PolygonAndCircleContact_SetEnabled(_self: b2PolygonAndCircleContactHandle; flag: Boolean); cdecl; external LIB_NAME name _PU + 'b2PolygonAndCircleContact_SetEnabled' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2PolygonAndCircleContactWrapper.SetEnabled(flag: Boolean); cdecl; begin b2PolygonAndCircleContact_SetEnabled(FHandle, flag) end; function b2PolygonAndCircleContact_IsEnabled(_self: b2PolygonAndCircleContactHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2PolygonAndCircleContact_IsEnabled' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PolygonAndCircleContactWrapper.IsEnabled: Boolean; cdecl; begin Result := b2PolygonAndCircleContact_IsEnabled(FHandle) end; function b2PolygonAndCircleContact_GetNext(_self: b2PolygonAndCircleContactHandle): b2ContactHandle; cdecl; external LIB_NAME name _PU + 'b2PolygonAndCircleContact_GetNext' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PolygonAndCircleContactWrapper.GetNext: b2ContactHandle; cdecl; begin Result := b2PolygonAndCircleContact_GetNext(FHandle) end; function b2PolygonAndCircleContact_GetFixtureA(_self: b2PolygonAndCircleContactHandle): Pb2Fixture; cdecl; external LIB_NAME name _PU + 'b2PolygonAndCircleContact_GetFixtureA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PolygonAndCircleContactWrapper.GetFixtureA: Pb2Fixture; cdecl; begin Result := b2PolygonAndCircleContact_GetFixtureA(FHandle) end; function b2PolygonAndCircleContact_GetChildIndexA(_self: b2PolygonAndCircleContactHandle): Integer; cdecl; external LIB_NAME name _PU + 'b2PolygonAndCircleContact_GetChildIndexA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PolygonAndCircleContactWrapper.GetChildIndexA: Integer; cdecl; begin Result := b2PolygonAndCircleContact_GetChildIndexA(FHandle) end; function b2PolygonAndCircleContact_GetFixtureB(_self: b2PolygonAndCircleContactHandle): Pb2Fixture; cdecl; external LIB_NAME name _PU + 'b2PolygonAndCircleContact_GetFixtureB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PolygonAndCircleContactWrapper.GetFixtureB: Pb2Fixture; cdecl; begin Result := b2PolygonAndCircleContact_GetFixtureB(FHandle) end; function b2PolygonAndCircleContact_GetChildIndexB(_self: b2PolygonAndCircleContactHandle): Integer; cdecl; external LIB_NAME name _PU + 'b2PolygonAndCircleContact_GetChildIndexB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PolygonAndCircleContactWrapper.GetChildIndexB: Integer; cdecl; begin Result := b2PolygonAndCircleContact_GetChildIndexB(FHandle) end; procedure b2PolygonAndCircleContact_SetFriction(_self: b2PolygonAndCircleContactHandle; friction: Single); cdecl; external LIB_NAME name _PU + 'b2PolygonAndCircleContact_SetFriction' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2PolygonAndCircleContactWrapper.SetFriction(friction: Single); cdecl; begin b2PolygonAndCircleContact_SetFriction(FHandle, friction) end; function b2PolygonAndCircleContact_GetFriction(_self: b2PolygonAndCircleContactHandle): Single; cdecl; external LIB_NAME name _PU + 'b2PolygonAndCircleContact_GetFriction' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PolygonAndCircleContactWrapper.GetFriction: Single; cdecl; begin Result := b2PolygonAndCircleContact_GetFriction(FHandle) end; procedure b2PolygonAndCircleContact_ResetFriction(_self: b2PolygonAndCircleContactHandle); cdecl; external LIB_NAME name _PU + 'b2PolygonAndCircleContact_ResetFriction' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2PolygonAndCircleContactWrapper.ResetFriction; cdecl; begin b2PolygonAndCircleContact_ResetFriction(FHandle) end; procedure b2PolygonAndCircleContact_SetRestitution(_self: b2PolygonAndCircleContactHandle; restitution: Single); cdecl; external LIB_NAME name _PU + 'b2PolygonAndCircleContact_SetRestitution' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2PolygonAndCircleContactWrapper.SetRestitution(restitution: Single); cdecl; begin b2PolygonAndCircleContact_SetRestitution(FHandle, restitution) end; function b2PolygonAndCircleContact_GetRestitution(_self: b2PolygonAndCircleContactHandle): Single; cdecl; external LIB_NAME name _PU + 'b2PolygonAndCircleContact_GetRestitution' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PolygonAndCircleContactWrapper.GetRestitution: Single; cdecl; begin Result := b2PolygonAndCircleContact_GetRestitution(FHandle) end; procedure b2PolygonAndCircleContact_ResetRestitution(_self: b2PolygonAndCircleContactHandle); cdecl; external LIB_NAME name _PU + 'b2PolygonAndCircleContact_ResetRestitution' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2PolygonAndCircleContactWrapper.ResetRestitution; cdecl; begin b2PolygonAndCircleContact_ResetRestitution(FHandle) end; procedure b2PolygonAndCircleContact_SetTangentSpeed(_self: b2PolygonAndCircleContactHandle; speed: Single); cdecl; external LIB_NAME name _PU + 'b2PolygonAndCircleContact_SetTangentSpeed' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2PolygonAndCircleContactWrapper.SetTangentSpeed(speed: Single); cdecl; begin b2PolygonAndCircleContact_SetTangentSpeed(FHandle, speed) end; function b2PolygonAndCircleContact_GetTangentSpeed(_self: b2PolygonAndCircleContactHandle): Single; cdecl; external LIB_NAME name _PU + 'b2PolygonAndCircleContact_GetTangentSpeed' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PolygonAndCircleContactWrapper.GetTangentSpeed: Single; cdecl; begin Result := b2PolygonAndCircleContact_GetTangentSpeed(FHandle) end; procedure b2PolygonAndCircleContact_Evaluate(_self: b2PolygonAndCircleContactHandle; manifold: Pb2Manifold; const [ref] xfA: b2Transform; const [ref] xfB: b2Transform); cdecl; external LIB_NAME name _PU + 'b2PolygonAndCircleContact_Evaluate' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2PolygonAndCircleContactWrapper.Evaluate(manifold: Pb2Manifold; const [ref] xfA: b2Transform; const [ref] xfB: b2Transform); cdecl; begin b2PolygonAndCircleContact_Evaluate(FHandle, manifold, xfA, xfB) end; function b2PolygonAndCircleContact_Create_(_self: b2PolygonAndCircleContactHandle; fixtureA: Pb2Fixture; indexA: Integer; fixtureB: Pb2Fixture; indexB: Integer; allocator: b2BlockAllocatorHandle): b2ContactHandle; cdecl; external LIB_NAME name _PU + 'b2PolygonAndCircleContact_Create' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PolygonAndCircleContactWrapper.Create_(fixtureA: Pb2Fixture; indexA: Integer; fixtureB: Pb2Fixture; indexB: Integer; allocator: b2BlockAllocatorHandle): b2ContactHandle; cdecl; begin Result := b2PolygonAndCircleContact_Create_(FHandle, fixtureA, indexA, fixtureB, indexB, allocator) end; procedure b2PolygonAndCircleContact_Destroy_(_self: b2PolygonAndCircleContactHandle; contact: b2ContactHandle; allocator: b2BlockAllocatorHandle); cdecl; external LIB_NAME name _PU + 'b2PolygonAndCircleContact_Destroy' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2PolygonAndCircleContactWrapper.Destroy_(contact: b2ContactHandle; allocator: b2BlockAllocatorHandle); cdecl; begin b2PolygonAndCircleContact_Destroy_(FHandle, contact, allocator) end; function b2PolygonContact_Create(fixtureA: Pb2Fixture; fixtureB: Pb2Fixture): b2PolygonContactHandle; cdecl; external LIB_NAME name _PU + 'b2PolygonContact_b2PolygonContact_1' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; class function b2PolygonContactWrapper.Create(fixtureA: Pb2Fixture; fixtureB: Pb2Fixture): b2PolygonContactWrapper; cdecl; begin Result.FHandle := b2PolygonContact_Create(fixtureA, fixtureB); end; procedure b2PolygonContact_Destroy(_self: b2PolygonContactHandle); cdecl; external LIB_NAME name _PU + 'b2PolygonContact_dtor' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2PolygonContactWrapper.Destroy; cdecl; begin b2PolygonContact_Destroy(FHandle); end; class operator b2PolygonContactWrapper.Implicit(handle: b2PolygonContactHandle): b2PolygonContactWrapper; begin Result.FHandle := handle; end; class operator b2PolygonContactWrapper.Implicit(wrapper: b2PolygonContactWrapper): b2PolygonContactHandle; begin Result := wrapper.FHandle; end; function b2PolygonContact_GetManifold(_self: b2PolygonContactHandle): Pb2Manifold; cdecl; external LIB_NAME name _PU + 'b2PolygonContact_GetManifold' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PolygonContactWrapper.GetManifold: Pb2Manifold; cdecl; begin Result := b2PolygonContact_GetManifold(FHandle) end; procedure b2PolygonContact_GetWorldManifold(_self: b2PolygonContactHandle; worldManifold: Pb2WorldManifold); cdecl; external LIB_NAME name _PU + 'b2PolygonContact_GetWorldManifold' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2PolygonContactWrapper.GetWorldManifold(worldManifold: Pb2WorldManifold); cdecl; begin b2PolygonContact_GetWorldManifold(FHandle, worldManifold) end; function b2PolygonContact_IsTouching(_self: b2PolygonContactHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2PolygonContact_IsTouching' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PolygonContactWrapper.IsTouching: Boolean; cdecl; begin Result := b2PolygonContact_IsTouching(FHandle) end; procedure b2PolygonContact_SetEnabled(_self: b2PolygonContactHandle; flag: Boolean); cdecl; external LIB_NAME name _PU + 'b2PolygonContact_SetEnabled' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2PolygonContactWrapper.SetEnabled(flag: Boolean); cdecl; begin b2PolygonContact_SetEnabled(FHandle, flag) end; function b2PolygonContact_IsEnabled(_self: b2PolygonContactHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2PolygonContact_IsEnabled' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PolygonContactWrapper.IsEnabled: Boolean; cdecl; begin Result := b2PolygonContact_IsEnabled(FHandle) end; function b2PolygonContact_GetNext(_self: b2PolygonContactHandle): b2ContactHandle; cdecl; external LIB_NAME name _PU + 'b2PolygonContact_GetNext' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PolygonContactWrapper.GetNext: b2ContactHandle; cdecl; begin Result := b2PolygonContact_GetNext(FHandle) end; function b2PolygonContact_GetFixtureA(_self: b2PolygonContactHandle): Pb2Fixture; cdecl; external LIB_NAME name _PU + 'b2PolygonContact_GetFixtureA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PolygonContactWrapper.GetFixtureA: Pb2Fixture; cdecl; begin Result := b2PolygonContact_GetFixtureA(FHandle) end; function b2PolygonContact_GetChildIndexA(_self: b2PolygonContactHandle): Integer; cdecl; external LIB_NAME name _PU + 'b2PolygonContact_GetChildIndexA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PolygonContactWrapper.GetChildIndexA: Integer; cdecl; begin Result := b2PolygonContact_GetChildIndexA(FHandle) end; function b2PolygonContact_GetFixtureB(_self: b2PolygonContactHandle): Pb2Fixture; cdecl; external LIB_NAME name _PU + 'b2PolygonContact_GetFixtureB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PolygonContactWrapper.GetFixtureB: Pb2Fixture; cdecl; begin Result := b2PolygonContact_GetFixtureB(FHandle) end; function b2PolygonContact_GetChildIndexB(_self: b2PolygonContactHandle): Integer; cdecl; external LIB_NAME name _PU + 'b2PolygonContact_GetChildIndexB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PolygonContactWrapper.GetChildIndexB: Integer; cdecl; begin Result := b2PolygonContact_GetChildIndexB(FHandle) end; procedure b2PolygonContact_SetFriction(_self: b2PolygonContactHandle; friction: Single); cdecl; external LIB_NAME name _PU + 'b2PolygonContact_SetFriction' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2PolygonContactWrapper.SetFriction(friction: Single); cdecl; begin b2PolygonContact_SetFriction(FHandle, friction) end; function b2PolygonContact_GetFriction(_self: b2PolygonContactHandle): Single; cdecl; external LIB_NAME name _PU + 'b2PolygonContact_GetFriction' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PolygonContactWrapper.GetFriction: Single; cdecl; begin Result := b2PolygonContact_GetFriction(FHandle) end; procedure b2PolygonContact_ResetFriction(_self: b2PolygonContactHandle); cdecl; external LIB_NAME name _PU + 'b2PolygonContact_ResetFriction' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2PolygonContactWrapper.ResetFriction; cdecl; begin b2PolygonContact_ResetFriction(FHandle) end; procedure b2PolygonContact_SetRestitution(_self: b2PolygonContactHandle; restitution: Single); cdecl; external LIB_NAME name _PU + 'b2PolygonContact_SetRestitution' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2PolygonContactWrapper.SetRestitution(restitution: Single); cdecl; begin b2PolygonContact_SetRestitution(FHandle, restitution) end; function b2PolygonContact_GetRestitution(_self: b2PolygonContactHandle): Single; cdecl; external LIB_NAME name _PU + 'b2PolygonContact_GetRestitution' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PolygonContactWrapper.GetRestitution: Single; cdecl; begin Result := b2PolygonContact_GetRestitution(FHandle) end; procedure b2PolygonContact_ResetRestitution(_self: b2PolygonContactHandle); cdecl; external LIB_NAME name _PU + 'b2PolygonContact_ResetRestitution' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2PolygonContactWrapper.ResetRestitution; cdecl; begin b2PolygonContact_ResetRestitution(FHandle) end; procedure b2PolygonContact_SetTangentSpeed(_self: b2PolygonContactHandle; speed: Single); cdecl; external LIB_NAME name _PU + 'b2PolygonContact_SetTangentSpeed' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2PolygonContactWrapper.SetTangentSpeed(speed: Single); cdecl; begin b2PolygonContact_SetTangentSpeed(FHandle, speed) end; function b2PolygonContact_GetTangentSpeed(_self: b2PolygonContactHandle): Single; cdecl; external LIB_NAME name _PU + 'b2PolygonContact_GetTangentSpeed' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PolygonContactWrapper.GetTangentSpeed: Single; cdecl; begin Result := b2PolygonContact_GetTangentSpeed(FHandle) end; procedure b2PolygonContact_Evaluate(_self: b2PolygonContactHandle; manifold: Pb2Manifold; const [ref] xfA: b2Transform; const [ref] xfB: b2Transform); cdecl; external LIB_NAME name _PU + 'b2PolygonContact_Evaluate' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2PolygonContactWrapper.Evaluate(manifold: Pb2Manifold; const [ref] xfA: b2Transform; const [ref] xfB: b2Transform); cdecl; begin b2PolygonContact_Evaluate(FHandle, manifold, xfA, xfB) end; function b2PolygonContact_Create_(_self: b2PolygonContactHandle; fixtureA: Pb2Fixture; indexA: Integer; fixtureB: Pb2Fixture; indexB: Integer; allocator: b2BlockAllocatorHandle): b2ContactHandle; cdecl; external LIB_NAME name _PU + 'b2PolygonContact_Create' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PolygonContactWrapper.Create_(fixtureA: Pb2Fixture; indexA: Integer; fixtureB: Pb2Fixture; indexB: Integer; allocator: b2BlockAllocatorHandle): b2ContactHandle; cdecl; begin Result := b2PolygonContact_Create_(FHandle, fixtureA, indexA, fixtureB, indexB, allocator) end; procedure b2PolygonContact_Destroy_(_self: b2PolygonContactHandle; contact: b2ContactHandle; allocator: b2BlockAllocatorHandle); cdecl; external LIB_NAME name _PU + 'b2PolygonContact_Destroy' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2PolygonContactWrapper.Destroy_(contact: b2ContactHandle; allocator: b2BlockAllocatorHandle); cdecl; begin b2PolygonContact_Destroy_(FHandle, contact, allocator) end; function b2Jacobian_Create: b2Jacobian; cdecl; external LIB_NAME name _PU + 'b2Jacobian_b2Jacobian' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; class function b2Jacobian.Create: b2Jacobian; cdecl; begin Result := b2Jacobian_Create; end; function b2JointEdge_Create: b2JointEdge; cdecl; external LIB_NAME name _PU + 'b2JointEdge_b2JointEdge' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; class function b2JointEdge.Create: b2JointEdge; cdecl; begin Result := b2JointEdge_Create; end; function b2JointDef_Create: b2JointDef; cdecl; external LIB_NAME name _PU + 'b2JointDef_b2JointDef_1' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; class function b2JointDef.Create: b2JointDef; cdecl; begin Result := b2JointDef_Create; end; class operator b2JointWrapper.Implicit(handle: b2JointHandle): b2JointWrapper; begin Result.FHandle := handle; end; class operator b2JointWrapper.Implicit(wrapper: b2JointWrapper): b2JointHandle; begin Result := wrapper.FHandle; end; function b2Joint_GetType(_self: b2JointHandle): b2JointType; cdecl; external LIB_NAME name _PU + 'b2Joint_GetType' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2JointWrapper.GetType: b2JointType; cdecl; begin Result := b2Joint_GetType(FHandle) end; function b2Joint_GetBodyA(_self: b2JointHandle): b2BodyHandle; cdecl; external LIB_NAME name _PU + 'b2Joint_GetBodyA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2JointWrapper.GetBodyA: b2BodyHandle; cdecl; begin Result := b2Joint_GetBodyA(FHandle) end; function b2Joint_GetBodyB(_self: b2JointHandle): b2BodyHandle; cdecl; external LIB_NAME name _PU + 'b2Joint_GetBodyB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2JointWrapper.GetBodyB: b2BodyHandle; cdecl; begin Result := b2Joint_GetBodyB(FHandle) end; function b2Joint_GetAnchorA(_self: b2JointHandle): b2Vec2; cdecl; external LIB_NAME name _PU + 'b2Joint_GetAnchorA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2JointWrapper.GetAnchorA: b2Vec2; cdecl; begin Result := b2Joint_GetAnchorA(FHandle) end; function b2Joint_GetAnchorB(_self: b2JointHandle): b2Vec2; cdecl; external LIB_NAME name _PU + 'b2Joint_GetAnchorB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2JointWrapper.GetAnchorB: b2Vec2; cdecl; begin Result := b2Joint_GetAnchorB(FHandle) end; function b2Joint_GetReactionForce(_self: b2JointHandle; inv_dt: Single): b2Vec2; cdecl; external LIB_NAME name _PU + 'b2Joint_GetReactionForce' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2JointWrapper.GetReactionForce(inv_dt: Single): b2Vec2; cdecl; begin Result := b2Joint_GetReactionForce(FHandle, inv_dt) end; function b2Joint_GetReactionTorque(_self: b2JointHandle; inv_dt: Single): Single; cdecl; external LIB_NAME name _PU + 'b2Joint_GetReactionTorque' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2JointWrapper.GetReactionTorque(inv_dt: Single): Single; cdecl; begin Result := b2Joint_GetReactionTorque(FHandle, inv_dt) end; function b2Joint_GetNext(_self: b2JointHandle): b2JointHandle; cdecl; external LIB_NAME name _PU + 'b2Joint_GetNext' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2JointWrapper.GetNext: b2JointHandle; cdecl; begin Result := b2Joint_GetNext(FHandle) end; function b2Joint_GetUserData(_self: b2JointHandle): Pointer; cdecl; external LIB_NAME name _PU + 'b2Joint_GetUserData' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2JointWrapper.GetUserData: Pointer; cdecl; begin Result := b2Joint_GetUserData(FHandle) end; procedure b2Joint_SetUserData(_self: b2JointHandle; data: Pointer); cdecl; external LIB_NAME name _PU + 'b2Joint_SetUserData' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2JointWrapper.SetUserData(data: Pointer); cdecl; begin b2Joint_SetUserData(FHandle, data) end; function b2Joint_IsActive(_self: b2JointHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2Joint_IsActive' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2JointWrapper.IsActive: Boolean; cdecl; begin Result := b2Joint_IsActive(FHandle) end; function b2Joint_GetCollideConnected(_self: b2JointHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2Joint_GetCollideConnected' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2JointWrapper.GetCollideConnected: Boolean; cdecl; begin Result := b2Joint_GetCollideConnected(FHandle) end; procedure b2Joint_Dump(_self: b2JointHandle); cdecl; external LIB_NAME name _PU + 'b2Joint_Dump' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2JointWrapper.Dump; cdecl; begin b2Joint_Dump(FHandle) end; procedure b2Joint_ShiftOrigin(_self: b2JointHandle; const [ref] newOrigin: b2Vec2); cdecl; external LIB_NAME name _PU + 'b2Joint_ShiftOrigin' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2JointWrapper.ShiftOrigin(const [ref] newOrigin: b2Vec2); cdecl; begin b2Joint_ShiftOrigin(FHandle, newOrigin) end; function b2DistanceJointDef_Create: b2DistanceJointDef; cdecl; external LIB_NAME name _PU + 'b2DistanceJointDef_b2DistanceJointDef_1' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; class function b2DistanceJointDef.Create: b2DistanceJointDef; cdecl; begin Result := b2DistanceJointDef_Create; end; procedure b2DistanceJointDef_Initialize(_self: Pb2DistanceJointDef; bodyA: b2BodyHandle; bodyB: b2BodyHandle; const [ref] anchorA: b2Vec2; const [ref] anchorB: b2Vec2); cdecl; external LIB_NAME name _PU + 'b2DistanceJointDef_Initialize' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2DistanceJointDef.Initialize(bodyA: b2BodyHandle; bodyB: b2BodyHandle; const [ref] anchorA: b2Vec2; const [ref] anchorB: b2Vec2); cdecl; begin b2DistanceJointDef_Initialize(@Self, bodyA, bodyB, anchorA, anchorB) end; procedure b2DistanceJoint_Destroy(_self: b2DistanceJointHandle); cdecl; external LIB_NAME name _PU + 'b2DistanceJoint_dtor' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2DistanceJointWrapper.Destroy; cdecl; begin b2DistanceJoint_Destroy(FHandle); end; class operator b2DistanceJointWrapper.Implicit(handle: b2DistanceJointHandle): b2DistanceJointWrapper; begin Result.FHandle := handle; end; class operator b2DistanceJointWrapper.Implicit(wrapper: b2DistanceJointWrapper): b2DistanceJointHandle; begin Result := wrapper.FHandle; end; function b2DistanceJoint_GetType(_self: b2DistanceJointHandle): b2JointType; cdecl; external LIB_NAME name _PU + 'b2DistanceJoint_GetType' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2DistanceJointWrapper.GetType: b2JointType; cdecl; begin Result := b2DistanceJoint_GetType(FHandle) end; function b2DistanceJoint_GetBodyA(_self: b2DistanceJointHandle): b2BodyHandle; cdecl; external LIB_NAME name _PU + 'b2DistanceJoint_GetBodyA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2DistanceJointWrapper.GetBodyA: b2BodyHandle; cdecl; begin Result := b2DistanceJoint_GetBodyA(FHandle) end; function b2DistanceJoint_GetBodyB(_self: b2DistanceJointHandle): b2BodyHandle; cdecl; external LIB_NAME name _PU + 'b2DistanceJoint_GetBodyB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2DistanceJointWrapper.GetBodyB: b2BodyHandle; cdecl; begin Result := b2DistanceJoint_GetBodyB(FHandle) end; function b2DistanceJoint_GetAnchorA(_self: b2DistanceJointHandle): b2Vec2; cdecl; external LIB_NAME name _PU + 'b2DistanceJoint_GetAnchorA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2DistanceJointWrapper.GetAnchorA: b2Vec2; cdecl; begin Result := b2DistanceJoint_GetAnchorA(FHandle) end; function b2DistanceJoint_GetAnchorB(_self: b2DistanceJointHandle): b2Vec2; cdecl; external LIB_NAME name _PU + 'b2DistanceJoint_GetAnchorB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2DistanceJointWrapper.GetAnchorB: b2Vec2; cdecl; begin Result := b2DistanceJoint_GetAnchorB(FHandle) end; function b2DistanceJoint_GetReactionForce(_self: b2DistanceJointHandle; inv_dt: Single): b2Vec2; cdecl; external LIB_NAME name _PU + 'b2DistanceJoint_GetReactionForce' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2DistanceJointWrapper.GetReactionForce(inv_dt: Single): b2Vec2; cdecl; begin Result := b2DistanceJoint_GetReactionForce(FHandle, inv_dt) end; function b2DistanceJoint_GetReactionTorque(_self: b2DistanceJointHandle; inv_dt: Single): Single; cdecl; external LIB_NAME name _PU + 'b2DistanceJoint_GetReactionTorque' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2DistanceJointWrapper.GetReactionTorque(inv_dt: Single): Single; cdecl; begin Result := b2DistanceJoint_GetReactionTorque(FHandle, inv_dt) end; function b2DistanceJoint_GetNext(_self: b2DistanceJointHandle): b2JointHandle; cdecl; external LIB_NAME name _PU + 'b2DistanceJoint_GetNext' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2DistanceJointWrapper.GetNext: b2JointHandle; cdecl; begin Result := b2DistanceJoint_GetNext(FHandle) end; function b2DistanceJoint_GetUserData(_self: b2DistanceJointHandle): Pointer; cdecl; external LIB_NAME name _PU + 'b2DistanceJoint_GetUserData' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2DistanceJointWrapper.GetUserData: Pointer; cdecl; begin Result := b2DistanceJoint_GetUserData(FHandle) end; procedure b2DistanceJoint_SetUserData(_self: b2DistanceJointHandle; data: Pointer); cdecl; external LIB_NAME name _PU + 'b2DistanceJoint_SetUserData' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2DistanceJointWrapper.SetUserData(data: Pointer); cdecl; begin b2DistanceJoint_SetUserData(FHandle, data) end; function b2DistanceJoint_IsActive(_self: b2DistanceJointHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2DistanceJoint_IsActive' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2DistanceJointWrapper.IsActive: Boolean; cdecl; begin Result := b2DistanceJoint_IsActive(FHandle) end; function b2DistanceJoint_GetCollideConnected(_self: b2DistanceJointHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2DistanceJoint_GetCollideConnected' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2DistanceJointWrapper.GetCollideConnected: Boolean; cdecl; begin Result := b2DistanceJoint_GetCollideConnected(FHandle) end; procedure b2DistanceJoint_Dump(_self: b2DistanceJointHandle); cdecl; external LIB_NAME name _PU + 'b2DistanceJoint_Dump' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2DistanceJointWrapper.Dump; cdecl; begin b2DistanceJoint_Dump(FHandle) end; procedure b2DistanceJoint_ShiftOrigin(_self: b2DistanceJointHandle; const [ref] newOrigin: b2Vec2); cdecl; external LIB_NAME name _PU + 'b2DistanceJoint_ShiftOrigin' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2DistanceJointWrapper.ShiftOrigin(const [ref] newOrigin: b2Vec2); cdecl; begin b2DistanceJoint_ShiftOrigin(FHandle, newOrigin) end; function b2DistanceJoint_GetLocalAnchorA(_self: b2DistanceJointHandle): Pb2Vec2; cdecl; external LIB_NAME name _PU + 'b2DistanceJoint_GetLocalAnchorA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2DistanceJointWrapper.GetLocalAnchorA: Pb2Vec2; cdecl; begin Result := b2DistanceJoint_GetLocalAnchorA(FHandle) end; function b2DistanceJoint_GetLocalAnchorB(_self: b2DistanceJointHandle): Pb2Vec2; cdecl; external LIB_NAME name _PU + 'b2DistanceJoint_GetLocalAnchorB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2DistanceJointWrapper.GetLocalAnchorB: Pb2Vec2; cdecl; begin Result := b2DistanceJoint_GetLocalAnchorB(FHandle) end; procedure b2DistanceJoint_SetLength(_self: b2DistanceJointHandle; length: Single); cdecl; external LIB_NAME name _PU + 'b2DistanceJoint_SetLength' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2DistanceJointWrapper.SetLength(length: Single); cdecl; begin b2DistanceJoint_SetLength(FHandle, length) end; function b2DistanceJoint_GetLength(_self: b2DistanceJointHandle): Single; cdecl; external LIB_NAME name _PU + 'b2DistanceJoint_GetLength' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2DistanceJointWrapper.GetLength: Single; cdecl; begin Result := b2DistanceJoint_GetLength(FHandle) end; procedure b2DistanceJoint_SetFrequency(_self: b2DistanceJointHandle; hz: Single); cdecl; external LIB_NAME name _PU + 'b2DistanceJoint_SetFrequency' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2DistanceJointWrapper.SetFrequency(hz: Single); cdecl; begin b2DistanceJoint_SetFrequency(FHandle, hz) end; function b2DistanceJoint_GetFrequency(_self: b2DistanceJointHandle): Single; cdecl; external LIB_NAME name _PU + 'b2DistanceJoint_GetFrequency' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2DistanceJointWrapper.GetFrequency: Single; cdecl; begin Result := b2DistanceJoint_GetFrequency(FHandle) end; procedure b2DistanceJoint_SetDampingRatio(_self: b2DistanceJointHandle; ratio: Single); cdecl; external LIB_NAME name _PU + 'b2DistanceJoint_SetDampingRatio' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2DistanceJointWrapper.SetDampingRatio(ratio: Single); cdecl; begin b2DistanceJoint_SetDampingRatio(FHandle, ratio) end; function b2DistanceJoint_GetDampingRatio(_self: b2DistanceJointHandle): Single; cdecl; external LIB_NAME name _PU + 'b2DistanceJoint_GetDampingRatio' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2DistanceJointWrapper.GetDampingRatio: Single; cdecl; begin Result := b2DistanceJoint_GetDampingRatio(FHandle) end; function b2FrictionJointDef_Create: b2FrictionJointDef; cdecl; external LIB_NAME name _PU + 'b2FrictionJointDef_b2FrictionJointDef_1' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; class function b2FrictionJointDef.Create: b2FrictionJointDef; cdecl; begin Result := b2FrictionJointDef_Create; end; procedure b2FrictionJointDef_Initialize(_self: Pb2FrictionJointDef; bodyA: b2BodyHandle; bodyB: b2BodyHandle; const [ref] anchor: b2Vec2); cdecl; external LIB_NAME name _PU + 'b2FrictionJointDef_Initialize' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2FrictionJointDef.Initialize(bodyA: b2BodyHandle; bodyB: b2BodyHandle; const [ref] anchor: b2Vec2); cdecl; begin b2FrictionJointDef_Initialize(@Self, bodyA, bodyB, anchor) end; procedure b2FrictionJoint_Destroy(_self: b2FrictionJointHandle); cdecl; external LIB_NAME name _PU + 'b2FrictionJoint_dtor' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2FrictionJointWrapper.Destroy; cdecl; begin b2FrictionJoint_Destroy(FHandle); end; class operator b2FrictionJointWrapper.Implicit(handle: b2FrictionJointHandle): b2FrictionJointWrapper; begin Result.FHandle := handle; end; class operator b2FrictionJointWrapper.Implicit(wrapper: b2FrictionJointWrapper): b2FrictionJointHandle; begin Result := wrapper.FHandle; end; function b2FrictionJoint_GetType(_self: b2FrictionJointHandle): b2JointType; cdecl; external LIB_NAME name _PU + 'b2FrictionJoint_GetType' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2FrictionJointWrapper.GetType: b2JointType; cdecl; begin Result := b2FrictionJoint_GetType(FHandle) end; function b2FrictionJoint_GetBodyA(_self: b2FrictionJointHandle): b2BodyHandle; cdecl; external LIB_NAME name _PU + 'b2FrictionJoint_GetBodyA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2FrictionJointWrapper.GetBodyA: b2BodyHandle; cdecl; begin Result := b2FrictionJoint_GetBodyA(FHandle) end; function b2FrictionJoint_GetBodyB(_self: b2FrictionJointHandle): b2BodyHandle; cdecl; external LIB_NAME name _PU + 'b2FrictionJoint_GetBodyB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2FrictionJointWrapper.GetBodyB: b2BodyHandle; cdecl; begin Result := b2FrictionJoint_GetBodyB(FHandle) end; function b2FrictionJoint_GetAnchorA(_self: b2FrictionJointHandle): b2Vec2; cdecl; external LIB_NAME name _PU + 'b2FrictionJoint_GetAnchorA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2FrictionJointWrapper.GetAnchorA: b2Vec2; cdecl; begin Result := b2FrictionJoint_GetAnchorA(FHandle) end; function b2FrictionJoint_GetAnchorB(_self: b2FrictionJointHandle): b2Vec2; cdecl; external LIB_NAME name _PU + 'b2FrictionJoint_GetAnchorB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2FrictionJointWrapper.GetAnchorB: b2Vec2; cdecl; begin Result := b2FrictionJoint_GetAnchorB(FHandle) end; function b2FrictionJoint_GetReactionForce(_self: b2FrictionJointHandle; inv_dt: Single): b2Vec2; cdecl; external LIB_NAME name _PU + 'b2FrictionJoint_GetReactionForce' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2FrictionJointWrapper.GetReactionForce(inv_dt: Single): b2Vec2; cdecl; begin Result := b2FrictionJoint_GetReactionForce(FHandle, inv_dt) end; function b2FrictionJoint_GetReactionTorque(_self: b2FrictionJointHandle; inv_dt: Single): Single; cdecl; external LIB_NAME name _PU + 'b2FrictionJoint_GetReactionTorque' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2FrictionJointWrapper.GetReactionTorque(inv_dt: Single): Single; cdecl; begin Result := b2FrictionJoint_GetReactionTorque(FHandle, inv_dt) end; function b2FrictionJoint_GetNext(_self: b2FrictionJointHandle): b2JointHandle; cdecl; external LIB_NAME name _PU + 'b2FrictionJoint_GetNext' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2FrictionJointWrapper.GetNext: b2JointHandle; cdecl; begin Result := b2FrictionJoint_GetNext(FHandle) end; function b2FrictionJoint_GetUserData(_self: b2FrictionJointHandle): Pointer; cdecl; external LIB_NAME name _PU + 'b2FrictionJoint_GetUserData' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2FrictionJointWrapper.GetUserData: Pointer; cdecl; begin Result := b2FrictionJoint_GetUserData(FHandle) end; procedure b2FrictionJoint_SetUserData(_self: b2FrictionJointHandle; data: Pointer); cdecl; external LIB_NAME name _PU + 'b2FrictionJoint_SetUserData' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2FrictionJointWrapper.SetUserData(data: Pointer); cdecl; begin b2FrictionJoint_SetUserData(FHandle, data) end; function b2FrictionJoint_IsActive(_self: b2FrictionJointHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2FrictionJoint_IsActive' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2FrictionJointWrapper.IsActive: Boolean; cdecl; begin Result := b2FrictionJoint_IsActive(FHandle) end; function b2FrictionJoint_GetCollideConnected(_self: b2FrictionJointHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2FrictionJoint_GetCollideConnected' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2FrictionJointWrapper.GetCollideConnected: Boolean; cdecl; begin Result := b2FrictionJoint_GetCollideConnected(FHandle) end; procedure b2FrictionJoint_Dump(_self: b2FrictionJointHandle); cdecl; external LIB_NAME name _PU + 'b2FrictionJoint_Dump' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2FrictionJointWrapper.Dump; cdecl; begin b2FrictionJoint_Dump(FHandle) end; procedure b2FrictionJoint_ShiftOrigin(_self: b2FrictionJointHandle; const [ref] newOrigin: b2Vec2); cdecl; external LIB_NAME name _PU + 'b2FrictionJoint_ShiftOrigin' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2FrictionJointWrapper.ShiftOrigin(const [ref] newOrigin: b2Vec2); cdecl; begin b2FrictionJoint_ShiftOrigin(FHandle, newOrigin) end; function b2FrictionJoint_GetLocalAnchorA(_self: b2FrictionJointHandle): Pb2Vec2; cdecl; external LIB_NAME name _PU + 'b2FrictionJoint_GetLocalAnchorA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2FrictionJointWrapper.GetLocalAnchorA: Pb2Vec2; cdecl; begin Result := b2FrictionJoint_GetLocalAnchorA(FHandle) end; function b2FrictionJoint_GetLocalAnchorB(_self: b2FrictionJointHandle): Pb2Vec2; cdecl; external LIB_NAME name _PU + 'b2FrictionJoint_GetLocalAnchorB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2FrictionJointWrapper.GetLocalAnchorB: Pb2Vec2; cdecl; begin Result := b2FrictionJoint_GetLocalAnchorB(FHandle) end; procedure b2FrictionJoint_SetMaxForce(_self: b2FrictionJointHandle; force: Single); cdecl; external LIB_NAME name _PU + 'b2FrictionJoint_SetMaxForce' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2FrictionJointWrapper.SetMaxForce(force: Single); cdecl; begin b2FrictionJoint_SetMaxForce(FHandle, force) end; function b2FrictionJoint_GetMaxForce(_self: b2FrictionJointHandle): Single; cdecl; external LIB_NAME name _PU + 'b2FrictionJoint_GetMaxForce' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2FrictionJointWrapper.GetMaxForce: Single; cdecl; begin Result := b2FrictionJoint_GetMaxForce(FHandle) end; procedure b2FrictionJoint_SetMaxTorque(_self: b2FrictionJointHandle; torque: Single); cdecl; external LIB_NAME name _PU + 'b2FrictionJoint_SetMaxTorque' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2FrictionJointWrapper.SetMaxTorque(torque: Single); cdecl; begin b2FrictionJoint_SetMaxTorque(FHandle, torque) end; function b2FrictionJoint_GetMaxTorque(_self: b2FrictionJointHandle): Single; cdecl; external LIB_NAME name _PU + 'b2FrictionJoint_GetMaxTorque' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2FrictionJointWrapper.GetMaxTorque: Single; cdecl; begin Result := b2FrictionJoint_GetMaxTorque(FHandle) end; function b2GearJointDef_Create: b2GearJointDef; cdecl; external LIB_NAME name _PU + 'b2GearJointDef_b2GearJointDef_1' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; class function b2GearJointDef.Create: b2GearJointDef; cdecl; begin Result := b2GearJointDef_Create; end; procedure b2GearJoint_Destroy(_self: b2GearJointHandle); cdecl; external LIB_NAME name _PU + 'b2GearJoint_dtor' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2GearJointWrapper.Destroy; cdecl; begin b2GearJoint_Destroy(FHandle); end; class operator b2GearJointWrapper.Implicit(handle: b2GearJointHandle): b2GearJointWrapper; begin Result.FHandle := handle; end; class operator b2GearJointWrapper.Implicit(wrapper: b2GearJointWrapper): b2GearJointHandle; begin Result := wrapper.FHandle; end; function b2GearJoint_GetType(_self: b2GearJointHandle): b2JointType; cdecl; external LIB_NAME name _PU + 'b2GearJoint_GetType' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2GearJointWrapper.GetType: b2JointType; cdecl; begin Result := b2GearJoint_GetType(FHandle) end; function b2GearJoint_GetBodyA(_self: b2GearJointHandle): b2BodyHandle; cdecl; external LIB_NAME name _PU + 'b2GearJoint_GetBodyA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2GearJointWrapper.GetBodyA: b2BodyHandle; cdecl; begin Result := b2GearJoint_GetBodyA(FHandle) end; function b2GearJoint_GetBodyB(_self: b2GearJointHandle): b2BodyHandle; cdecl; external LIB_NAME name _PU + 'b2GearJoint_GetBodyB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2GearJointWrapper.GetBodyB: b2BodyHandle; cdecl; begin Result := b2GearJoint_GetBodyB(FHandle) end; function b2GearJoint_GetAnchorA(_self: b2GearJointHandle): b2Vec2; cdecl; external LIB_NAME name _PU + 'b2GearJoint_GetAnchorA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2GearJointWrapper.GetAnchorA: b2Vec2; cdecl; begin Result := b2GearJoint_GetAnchorA(FHandle) end; function b2GearJoint_GetAnchorB(_self: b2GearJointHandle): b2Vec2; cdecl; external LIB_NAME name _PU + 'b2GearJoint_GetAnchorB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2GearJointWrapper.GetAnchorB: b2Vec2; cdecl; begin Result := b2GearJoint_GetAnchorB(FHandle) end; function b2GearJoint_GetReactionForce(_self: b2GearJointHandle; inv_dt: Single): b2Vec2; cdecl; external LIB_NAME name _PU + 'b2GearJoint_GetReactionForce' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2GearJointWrapper.GetReactionForce(inv_dt: Single): b2Vec2; cdecl; begin Result := b2GearJoint_GetReactionForce(FHandle, inv_dt) end; function b2GearJoint_GetReactionTorque(_self: b2GearJointHandle; inv_dt: Single): Single; cdecl; external LIB_NAME name _PU + 'b2GearJoint_GetReactionTorque' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2GearJointWrapper.GetReactionTorque(inv_dt: Single): Single; cdecl; begin Result := b2GearJoint_GetReactionTorque(FHandle, inv_dt) end; function b2GearJoint_GetNext(_self: b2GearJointHandle): b2JointHandle; cdecl; external LIB_NAME name _PU + 'b2GearJoint_GetNext' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2GearJointWrapper.GetNext: b2JointHandle; cdecl; begin Result := b2GearJoint_GetNext(FHandle) end; function b2GearJoint_GetUserData(_self: b2GearJointHandle): Pointer; cdecl; external LIB_NAME name _PU + 'b2GearJoint_GetUserData' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2GearJointWrapper.GetUserData: Pointer; cdecl; begin Result := b2GearJoint_GetUserData(FHandle) end; procedure b2GearJoint_SetUserData(_self: b2GearJointHandle; data: Pointer); cdecl; external LIB_NAME name _PU + 'b2GearJoint_SetUserData' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2GearJointWrapper.SetUserData(data: Pointer); cdecl; begin b2GearJoint_SetUserData(FHandle, data) end; function b2GearJoint_IsActive(_self: b2GearJointHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2GearJoint_IsActive' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2GearJointWrapper.IsActive: Boolean; cdecl; begin Result := b2GearJoint_IsActive(FHandle) end; function b2GearJoint_GetCollideConnected(_self: b2GearJointHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2GearJoint_GetCollideConnected' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2GearJointWrapper.GetCollideConnected: Boolean; cdecl; begin Result := b2GearJoint_GetCollideConnected(FHandle) end; procedure b2GearJoint_Dump(_self: b2GearJointHandle); cdecl; external LIB_NAME name _PU + 'b2GearJoint_Dump' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2GearJointWrapper.Dump; cdecl; begin b2GearJoint_Dump(FHandle) end; procedure b2GearJoint_ShiftOrigin(_self: b2GearJointHandle; const [ref] newOrigin: b2Vec2); cdecl; external LIB_NAME name _PU + 'b2GearJoint_ShiftOrigin' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2GearJointWrapper.ShiftOrigin(const [ref] newOrigin: b2Vec2); cdecl; begin b2GearJoint_ShiftOrigin(FHandle, newOrigin) end; function b2GearJoint_GetJoint1(_self: b2GearJointHandle): b2JointHandle; cdecl; external LIB_NAME name _PU + 'b2GearJoint_GetJoint1' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2GearJointWrapper.GetJoint1: b2JointHandle; cdecl; begin Result := b2GearJoint_GetJoint1(FHandle) end; function b2GearJoint_GetJoint2(_self: b2GearJointHandle): b2JointHandle; cdecl; external LIB_NAME name _PU + 'b2GearJoint_GetJoint2' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2GearJointWrapper.GetJoint2: b2JointHandle; cdecl; begin Result := b2GearJoint_GetJoint2(FHandle) end; procedure b2GearJoint_SetRatio(_self: b2GearJointHandle; ratio: Single); cdecl; external LIB_NAME name _PU + 'b2GearJoint_SetRatio' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2GearJointWrapper.SetRatio(ratio: Single); cdecl; begin b2GearJoint_SetRatio(FHandle, ratio) end; function b2GearJoint_GetRatio(_self: b2GearJointHandle): Single; cdecl; external LIB_NAME name _PU + 'b2GearJoint_GetRatio' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2GearJointWrapper.GetRatio: Single; cdecl; begin Result := b2GearJoint_GetRatio(FHandle) end; function b2MotorJointDef_Create: b2MotorJointDef; cdecl; external LIB_NAME name _PU + 'b2MotorJointDef_b2MotorJointDef_1' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; class function b2MotorJointDef.Create: b2MotorJointDef; cdecl; begin Result := b2MotorJointDef_Create; end; procedure b2MotorJointDef_Initialize(_self: Pb2MotorJointDef; bodyA: b2BodyHandle; bodyB: b2BodyHandle); cdecl; external LIB_NAME name _PU + 'b2MotorJointDef_Initialize' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2MotorJointDef.Initialize(bodyA: b2BodyHandle; bodyB: b2BodyHandle); cdecl; begin b2MotorJointDef_Initialize(@Self, bodyA, bodyB) end; procedure b2MotorJoint_Destroy(_self: b2MotorJointHandle); cdecl; external LIB_NAME name _PU + 'b2MotorJoint_dtor' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2MotorJointWrapper.Destroy; cdecl; begin b2MotorJoint_Destroy(FHandle); end; class operator b2MotorJointWrapper.Implicit(handle: b2MotorJointHandle): b2MotorJointWrapper; begin Result.FHandle := handle; end; class operator b2MotorJointWrapper.Implicit(wrapper: b2MotorJointWrapper): b2MotorJointHandle; begin Result := wrapper.FHandle; end; function b2MotorJoint_GetType(_self: b2MotorJointHandle): b2JointType; cdecl; external LIB_NAME name _PU + 'b2MotorJoint_GetType' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2MotorJointWrapper.GetType: b2JointType; cdecl; begin Result := b2MotorJoint_GetType(FHandle) end; function b2MotorJoint_GetBodyA(_self: b2MotorJointHandle): b2BodyHandle; cdecl; external LIB_NAME name _PU + 'b2MotorJoint_GetBodyA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2MotorJointWrapper.GetBodyA: b2BodyHandle; cdecl; begin Result := b2MotorJoint_GetBodyA(FHandle) end; function b2MotorJoint_GetBodyB(_self: b2MotorJointHandle): b2BodyHandle; cdecl; external LIB_NAME name _PU + 'b2MotorJoint_GetBodyB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2MotorJointWrapper.GetBodyB: b2BodyHandle; cdecl; begin Result := b2MotorJoint_GetBodyB(FHandle) end; function b2MotorJoint_GetAnchorA(_self: b2MotorJointHandle): b2Vec2; cdecl; external LIB_NAME name _PU + 'b2MotorJoint_GetAnchorA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2MotorJointWrapper.GetAnchorA: b2Vec2; cdecl; begin Result := b2MotorJoint_GetAnchorA(FHandle) end; function b2MotorJoint_GetAnchorB(_self: b2MotorJointHandle): b2Vec2; cdecl; external LIB_NAME name _PU + 'b2MotorJoint_GetAnchorB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2MotorJointWrapper.GetAnchorB: b2Vec2; cdecl; begin Result := b2MotorJoint_GetAnchorB(FHandle) end; function b2MotorJoint_GetReactionForce(_self: b2MotorJointHandle; inv_dt: Single): b2Vec2; cdecl; external LIB_NAME name _PU + 'b2MotorJoint_GetReactionForce' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2MotorJointWrapper.GetReactionForce(inv_dt: Single): b2Vec2; cdecl; begin Result := b2MotorJoint_GetReactionForce(FHandle, inv_dt) end; function b2MotorJoint_GetReactionTorque(_self: b2MotorJointHandle; inv_dt: Single): Single; cdecl; external LIB_NAME name _PU + 'b2MotorJoint_GetReactionTorque' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2MotorJointWrapper.GetReactionTorque(inv_dt: Single): Single; cdecl; begin Result := b2MotorJoint_GetReactionTorque(FHandle, inv_dt) end; function b2MotorJoint_GetNext(_self: b2MotorJointHandle): b2JointHandle; cdecl; external LIB_NAME name _PU + 'b2MotorJoint_GetNext' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2MotorJointWrapper.GetNext: b2JointHandle; cdecl; begin Result := b2MotorJoint_GetNext(FHandle) end; function b2MotorJoint_GetUserData(_self: b2MotorJointHandle): Pointer; cdecl; external LIB_NAME name _PU + 'b2MotorJoint_GetUserData' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2MotorJointWrapper.GetUserData: Pointer; cdecl; begin Result := b2MotorJoint_GetUserData(FHandle) end; procedure b2MotorJoint_SetUserData(_self: b2MotorJointHandle; data: Pointer); cdecl; external LIB_NAME name _PU + 'b2MotorJoint_SetUserData' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2MotorJointWrapper.SetUserData(data: Pointer); cdecl; begin b2MotorJoint_SetUserData(FHandle, data) end; function b2MotorJoint_IsActive(_self: b2MotorJointHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2MotorJoint_IsActive' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2MotorJointWrapper.IsActive: Boolean; cdecl; begin Result := b2MotorJoint_IsActive(FHandle) end; function b2MotorJoint_GetCollideConnected(_self: b2MotorJointHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2MotorJoint_GetCollideConnected' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2MotorJointWrapper.GetCollideConnected: Boolean; cdecl; begin Result := b2MotorJoint_GetCollideConnected(FHandle) end; procedure b2MotorJoint_Dump(_self: b2MotorJointHandle); cdecl; external LIB_NAME name _PU + 'b2MotorJoint_Dump' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2MotorJointWrapper.Dump; cdecl; begin b2MotorJoint_Dump(FHandle) end; procedure b2MotorJoint_ShiftOrigin(_self: b2MotorJointHandle; const [ref] newOrigin: b2Vec2); cdecl; external LIB_NAME name _PU + 'b2MotorJoint_ShiftOrigin' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2MotorJointWrapper.ShiftOrigin(const [ref] newOrigin: b2Vec2); cdecl; begin b2MotorJoint_ShiftOrigin(FHandle, newOrigin) end; procedure b2MotorJoint_SetLinearOffset(_self: b2MotorJointHandle; const [ref] linearOffset: b2Vec2); cdecl; external LIB_NAME name _PU + 'b2MotorJoint_SetLinearOffset' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2MotorJointWrapper.SetLinearOffset(const [ref] linearOffset: b2Vec2); cdecl; begin b2MotorJoint_SetLinearOffset(FHandle, linearOffset) end; function b2MotorJoint_GetLinearOffset(_self: b2MotorJointHandle): Pb2Vec2; cdecl; external LIB_NAME name _PU + 'b2MotorJoint_GetLinearOffset' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2MotorJointWrapper.GetLinearOffset: Pb2Vec2; cdecl; begin Result := b2MotorJoint_GetLinearOffset(FHandle) end; procedure b2MotorJoint_SetAngularOffset(_self: b2MotorJointHandle; angularOffset: Single); cdecl; external LIB_NAME name _PU + 'b2MotorJoint_SetAngularOffset' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2MotorJointWrapper.SetAngularOffset(angularOffset: Single); cdecl; begin b2MotorJoint_SetAngularOffset(FHandle, angularOffset) end; function b2MotorJoint_GetAngularOffset(_self: b2MotorJointHandle): Single; cdecl; external LIB_NAME name _PU + 'b2MotorJoint_GetAngularOffset' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2MotorJointWrapper.GetAngularOffset: Single; cdecl; begin Result := b2MotorJoint_GetAngularOffset(FHandle) end; procedure b2MotorJoint_SetMaxForce(_self: b2MotorJointHandle; force: Single); cdecl; external LIB_NAME name _PU + 'b2MotorJoint_SetMaxForce' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2MotorJointWrapper.SetMaxForce(force: Single); cdecl; begin b2MotorJoint_SetMaxForce(FHandle, force) end; function b2MotorJoint_GetMaxForce(_self: b2MotorJointHandle): Single; cdecl; external LIB_NAME name _PU + 'b2MotorJoint_GetMaxForce' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2MotorJointWrapper.GetMaxForce: Single; cdecl; begin Result := b2MotorJoint_GetMaxForce(FHandle) end; procedure b2MotorJoint_SetMaxTorque(_self: b2MotorJointHandle; torque: Single); cdecl; external LIB_NAME name _PU + 'b2MotorJoint_SetMaxTorque' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2MotorJointWrapper.SetMaxTorque(torque: Single); cdecl; begin b2MotorJoint_SetMaxTorque(FHandle, torque) end; function b2MotorJoint_GetMaxTorque(_self: b2MotorJointHandle): Single; cdecl; external LIB_NAME name _PU + 'b2MotorJoint_GetMaxTorque' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2MotorJointWrapper.GetMaxTorque: Single; cdecl; begin Result := b2MotorJoint_GetMaxTorque(FHandle) end; procedure b2MotorJoint_SetCorrectionFactor(_self: b2MotorJointHandle; factor: Single); cdecl; external LIB_NAME name _PU + 'b2MotorJoint_SetCorrectionFactor' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2MotorJointWrapper.SetCorrectionFactor(factor: Single); cdecl; begin b2MotorJoint_SetCorrectionFactor(FHandle, factor) end; function b2MotorJoint_GetCorrectionFactor(_self: b2MotorJointHandle): Single; cdecl; external LIB_NAME name _PU + 'b2MotorJoint_GetCorrectionFactor' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2MotorJointWrapper.GetCorrectionFactor: Single; cdecl; begin Result := b2MotorJoint_GetCorrectionFactor(FHandle) end; function b2MouseJointDef_Create: b2MouseJointDef; cdecl; external LIB_NAME name _PU + 'b2MouseJointDef_b2MouseJointDef_1' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; class function b2MouseJointDef.Create: b2MouseJointDef; cdecl; begin Result := b2MouseJointDef_Create; end; procedure b2MouseJoint_Destroy(_self: b2MouseJointHandle); cdecl; external LIB_NAME name _PU + 'b2MouseJoint_dtor' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2MouseJointWrapper.Destroy; cdecl; begin b2MouseJoint_Destroy(FHandle); end; class operator b2MouseJointWrapper.Implicit(handle: b2MouseJointHandle): b2MouseJointWrapper; begin Result.FHandle := handle; end; class operator b2MouseJointWrapper.Implicit(wrapper: b2MouseJointWrapper): b2MouseJointHandle; begin Result := wrapper.FHandle; end; function b2MouseJoint_GetType(_self: b2MouseJointHandle): b2JointType; cdecl; external LIB_NAME name _PU + 'b2MouseJoint_GetType' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2MouseJointWrapper.GetType: b2JointType; cdecl; begin Result := b2MouseJoint_GetType(FHandle) end; function b2MouseJoint_GetBodyA(_self: b2MouseJointHandle): b2BodyHandle; cdecl; external LIB_NAME name _PU + 'b2MouseJoint_GetBodyA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2MouseJointWrapper.GetBodyA: b2BodyHandle; cdecl; begin Result := b2MouseJoint_GetBodyA(FHandle) end; function b2MouseJoint_GetBodyB(_self: b2MouseJointHandle): b2BodyHandle; cdecl; external LIB_NAME name _PU + 'b2MouseJoint_GetBodyB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2MouseJointWrapper.GetBodyB: b2BodyHandle; cdecl; begin Result := b2MouseJoint_GetBodyB(FHandle) end; function b2MouseJoint_GetAnchorA(_self: b2MouseJointHandle): b2Vec2; cdecl; external LIB_NAME name _PU + 'b2MouseJoint_GetAnchorA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2MouseJointWrapper.GetAnchorA: b2Vec2; cdecl; begin Result := b2MouseJoint_GetAnchorA(FHandle) end; function b2MouseJoint_GetAnchorB(_self: b2MouseJointHandle): b2Vec2; cdecl; external LIB_NAME name _PU + 'b2MouseJoint_GetAnchorB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2MouseJointWrapper.GetAnchorB: b2Vec2; cdecl; begin Result := b2MouseJoint_GetAnchorB(FHandle) end; function b2MouseJoint_GetReactionForce(_self: b2MouseJointHandle; inv_dt: Single): b2Vec2; cdecl; external LIB_NAME name _PU + 'b2MouseJoint_GetReactionForce' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2MouseJointWrapper.GetReactionForce(inv_dt: Single): b2Vec2; cdecl; begin Result := b2MouseJoint_GetReactionForce(FHandle, inv_dt) end; function b2MouseJoint_GetReactionTorque(_self: b2MouseJointHandle; inv_dt: Single): Single; cdecl; external LIB_NAME name _PU + 'b2MouseJoint_GetReactionTorque' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2MouseJointWrapper.GetReactionTorque(inv_dt: Single): Single; cdecl; begin Result := b2MouseJoint_GetReactionTorque(FHandle, inv_dt) end; function b2MouseJoint_GetNext(_self: b2MouseJointHandle): b2JointHandle; cdecl; external LIB_NAME name _PU + 'b2MouseJoint_GetNext' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2MouseJointWrapper.GetNext: b2JointHandle; cdecl; begin Result := b2MouseJoint_GetNext(FHandle) end; function b2MouseJoint_GetUserData(_self: b2MouseJointHandle): Pointer; cdecl; external LIB_NAME name _PU + 'b2MouseJoint_GetUserData' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2MouseJointWrapper.GetUserData: Pointer; cdecl; begin Result := b2MouseJoint_GetUserData(FHandle) end; procedure b2MouseJoint_SetUserData(_self: b2MouseJointHandle; data: Pointer); cdecl; external LIB_NAME name _PU + 'b2MouseJoint_SetUserData' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2MouseJointWrapper.SetUserData(data: Pointer); cdecl; begin b2MouseJoint_SetUserData(FHandle, data) end; function b2MouseJoint_IsActive(_self: b2MouseJointHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2MouseJoint_IsActive' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2MouseJointWrapper.IsActive: Boolean; cdecl; begin Result := b2MouseJoint_IsActive(FHandle) end; function b2MouseJoint_GetCollideConnected(_self: b2MouseJointHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2MouseJoint_GetCollideConnected' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2MouseJointWrapper.GetCollideConnected: Boolean; cdecl; begin Result := b2MouseJoint_GetCollideConnected(FHandle) end; procedure b2MouseJoint_Dump(_self: b2MouseJointHandle); cdecl; external LIB_NAME name _PU + 'b2MouseJoint_Dump' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2MouseJointWrapper.Dump; cdecl; begin b2MouseJoint_Dump(FHandle) end; procedure b2MouseJoint_ShiftOrigin(_self: b2MouseJointHandle; const [ref] newOrigin: b2Vec2); cdecl; external LIB_NAME name _PU + 'b2MouseJoint_ShiftOrigin' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2MouseJointWrapper.ShiftOrigin(const [ref] newOrigin: b2Vec2); cdecl; begin b2MouseJoint_ShiftOrigin(FHandle, newOrigin) end; procedure b2MouseJoint_SetTarget(_self: b2MouseJointHandle; const [ref] target: b2Vec2); cdecl; external LIB_NAME name _PU + 'b2MouseJoint_SetTarget' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2MouseJointWrapper.SetTarget(const [ref] target: b2Vec2); cdecl; begin b2MouseJoint_SetTarget(FHandle, target) end; function b2MouseJoint_GetTarget(_self: b2MouseJointHandle): Pb2Vec2; cdecl; external LIB_NAME name _PU + 'b2MouseJoint_GetTarget' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2MouseJointWrapper.GetTarget: Pb2Vec2; cdecl; begin Result := b2MouseJoint_GetTarget(FHandle) end; procedure b2MouseJoint_SetMaxForce(_self: b2MouseJointHandle; force: Single); cdecl; external LIB_NAME name _PU + 'b2MouseJoint_SetMaxForce' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2MouseJointWrapper.SetMaxForce(force: Single); cdecl; begin b2MouseJoint_SetMaxForce(FHandle, force) end; function b2MouseJoint_GetMaxForce(_self: b2MouseJointHandle): Single; cdecl; external LIB_NAME name _PU + 'b2MouseJoint_GetMaxForce' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2MouseJointWrapper.GetMaxForce: Single; cdecl; begin Result := b2MouseJoint_GetMaxForce(FHandle) end; procedure b2MouseJoint_SetFrequency(_self: b2MouseJointHandle; hz: Single); cdecl; external LIB_NAME name _PU + 'b2MouseJoint_SetFrequency' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2MouseJointWrapper.SetFrequency(hz: Single); cdecl; begin b2MouseJoint_SetFrequency(FHandle, hz) end; function b2MouseJoint_GetFrequency(_self: b2MouseJointHandle): Single; cdecl; external LIB_NAME name _PU + 'b2MouseJoint_GetFrequency' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2MouseJointWrapper.GetFrequency: Single; cdecl; begin Result := b2MouseJoint_GetFrequency(FHandle) end; procedure b2MouseJoint_SetDampingRatio(_self: b2MouseJointHandle; ratio: Single); cdecl; external LIB_NAME name _PU + 'b2MouseJoint_SetDampingRatio' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2MouseJointWrapper.SetDampingRatio(ratio: Single); cdecl; begin b2MouseJoint_SetDampingRatio(FHandle, ratio) end; function b2MouseJoint_GetDampingRatio(_self: b2MouseJointHandle): Single; cdecl; external LIB_NAME name _PU + 'b2MouseJoint_GetDampingRatio' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2MouseJointWrapper.GetDampingRatio: Single; cdecl; begin Result := b2MouseJoint_GetDampingRatio(FHandle) end; function b2PrismaticJointDef_Create: b2PrismaticJointDef; cdecl; external LIB_NAME name _PU + 'b2PrismaticJointDef_b2PrismaticJointDef_1' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; class function b2PrismaticJointDef.Create: b2PrismaticJointDef; cdecl; begin Result := b2PrismaticJointDef_Create; end; procedure b2PrismaticJointDef_Initialize(_self: Pb2PrismaticJointDef; bodyA: b2BodyHandle; bodyB: b2BodyHandle; const [ref] anchor: b2Vec2; const [ref] axis: b2Vec2); cdecl; external LIB_NAME name _PU + 'b2PrismaticJointDef_Initialize' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2PrismaticJointDef.Initialize(bodyA: b2BodyHandle; bodyB: b2BodyHandle; const [ref] anchor: b2Vec2; const [ref] axis: b2Vec2); cdecl; begin b2PrismaticJointDef_Initialize(@Self, bodyA, bodyB, anchor, axis) end; procedure b2PrismaticJoint_Destroy(_self: b2PrismaticJointHandle); cdecl; external LIB_NAME name _PU + 'b2PrismaticJoint_dtor' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2PrismaticJointWrapper.Destroy; cdecl; begin b2PrismaticJoint_Destroy(FHandle); end; class operator b2PrismaticJointWrapper.Implicit(handle: b2PrismaticJointHandle): b2PrismaticJointWrapper; begin Result.FHandle := handle; end; class operator b2PrismaticJointWrapper.Implicit(wrapper: b2PrismaticJointWrapper): b2PrismaticJointHandle; begin Result := wrapper.FHandle; end; function b2PrismaticJoint_GetType(_self: b2PrismaticJointHandle): b2JointType; cdecl; external LIB_NAME name _PU + 'b2PrismaticJoint_GetType' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PrismaticJointWrapper.GetType: b2JointType; cdecl; begin Result := b2PrismaticJoint_GetType(FHandle) end; function b2PrismaticJoint_GetBodyA(_self: b2PrismaticJointHandle): b2BodyHandle; cdecl; external LIB_NAME name _PU + 'b2PrismaticJoint_GetBodyA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PrismaticJointWrapper.GetBodyA: b2BodyHandle; cdecl; begin Result := b2PrismaticJoint_GetBodyA(FHandle) end; function b2PrismaticJoint_GetBodyB(_self: b2PrismaticJointHandle): b2BodyHandle; cdecl; external LIB_NAME name _PU + 'b2PrismaticJoint_GetBodyB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PrismaticJointWrapper.GetBodyB: b2BodyHandle; cdecl; begin Result := b2PrismaticJoint_GetBodyB(FHandle) end; function b2PrismaticJoint_GetAnchorA(_self: b2PrismaticJointHandle): b2Vec2; cdecl; external LIB_NAME name _PU + 'b2PrismaticJoint_GetAnchorA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PrismaticJointWrapper.GetAnchorA: b2Vec2; cdecl; begin Result := b2PrismaticJoint_GetAnchorA(FHandle) end; function b2PrismaticJoint_GetAnchorB(_self: b2PrismaticJointHandle): b2Vec2; cdecl; external LIB_NAME name _PU + 'b2PrismaticJoint_GetAnchorB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PrismaticJointWrapper.GetAnchorB: b2Vec2; cdecl; begin Result := b2PrismaticJoint_GetAnchorB(FHandle) end; function b2PrismaticJoint_GetReactionForce(_self: b2PrismaticJointHandle; inv_dt: Single): b2Vec2; cdecl; external LIB_NAME name _PU + 'b2PrismaticJoint_GetReactionForce' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PrismaticJointWrapper.GetReactionForce(inv_dt: Single): b2Vec2; cdecl; begin Result := b2PrismaticJoint_GetReactionForce(FHandle, inv_dt) end; function b2PrismaticJoint_GetReactionTorque(_self: b2PrismaticJointHandle; inv_dt: Single): Single; cdecl; external LIB_NAME name _PU + 'b2PrismaticJoint_GetReactionTorque' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PrismaticJointWrapper.GetReactionTorque(inv_dt: Single): Single; cdecl; begin Result := b2PrismaticJoint_GetReactionTorque(FHandle, inv_dt) end; function b2PrismaticJoint_GetNext(_self: b2PrismaticJointHandle): b2JointHandle; cdecl; external LIB_NAME name _PU + 'b2PrismaticJoint_GetNext' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PrismaticJointWrapper.GetNext: b2JointHandle; cdecl; begin Result := b2PrismaticJoint_GetNext(FHandle) end; function b2PrismaticJoint_GetUserData(_self: b2PrismaticJointHandle): Pointer; cdecl; external LIB_NAME name _PU + 'b2PrismaticJoint_GetUserData' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PrismaticJointWrapper.GetUserData: Pointer; cdecl; begin Result := b2PrismaticJoint_GetUserData(FHandle) end; procedure b2PrismaticJoint_SetUserData(_self: b2PrismaticJointHandle; data: Pointer); cdecl; external LIB_NAME name _PU + 'b2PrismaticJoint_SetUserData' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2PrismaticJointWrapper.SetUserData(data: Pointer); cdecl; begin b2PrismaticJoint_SetUserData(FHandle, data) end; function b2PrismaticJoint_IsActive(_self: b2PrismaticJointHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2PrismaticJoint_IsActive' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PrismaticJointWrapper.IsActive: Boolean; cdecl; begin Result := b2PrismaticJoint_IsActive(FHandle) end; function b2PrismaticJoint_GetCollideConnected(_self: b2PrismaticJointHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2PrismaticJoint_GetCollideConnected' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PrismaticJointWrapper.GetCollideConnected: Boolean; cdecl; begin Result := b2PrismaticJoint_GetCollideConnected(FHandle) end; procedure b2PrismaticJoint_Dump(_self: b2PrismaticJointHandle); cdecl; external LIB_NAME name _PU + 'b2PrismaticJoint_Dump' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2PrismaticJointWrapper.Dump; cdecl; begin b2PrismaticJoint_Dump(FHandle) end; procedure b2PrismaticJoint_ShiftOrigin(_self: b2PrismaticJointHandle; const [ref] newOrigin: b2Vec2); cdecl; external LIB_NAME name _PU + 'b2PrismaticJoint_ShiftOrigin' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2PrismaticJointWrapper.ShiftOrigin(const [ref] newOrigin: b2Vec2); cdecl; begin b2PrismaticJoint_ShiftOrigin(FHandle, newOrigin) end; function b2PrismaticJoint_GetLocalAnchorA(_self: b2PrismaticJointHandle): Pb2Vec2; cdecl; external LIB_NAME name _PU + 'b2PrismaticJoint_GetLocalAnchorA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PrismaticJointWrapper.GetLocalAnchorA: Pb2Vec2; cdecl; begin Result := b2PrismaticJoint_GetLocalAnchorA(FHandle) end; function b2PrismaticJoint_GetLocalAnchorB(_self: b2PrismaticJointHandle): Pb2Vec2; cdecl; external LIB_NAME name _PU + 'b2PrismaticJoint_GetLocalAnchorB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PrismaticJointWrapper.GetLocalAnchorB: Pb2Vec2; cdecl; begin Result := b2PrismaticJoint_GetLocalAnchorB(FHandle) end; function b2PrismaticJoint_GetLocalAxisA(_self: b2PrismaticJointHandle): Pb2Vec2; cdecl; external LIB_NAME name _PU + 'b2PrismaticJoint_GetLocalAxisA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PrismaticJointWrapper.GetLocalAxisA: Pb2Vec2; cdecl; begin Result := b2PrismaticJoint_GetLocalAxisA(FHandle) end; function b2PrismaticJoint_GetReferenceAngle(_self: b2PrismaticJointHandle): Single; cdecl; external LIB_NAME name _PU + 'b2PrismaticJoint_GetReferenceAngle' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PrismaticJointWrapper.GetReferenceAngle: Single; cdecl; begin Result := b2PrismaticJoint_GetReferenceAngle(FHandle) end; function b2PrismaticJoint_GetJointTranslation(_self: b2PrismaticJointHandle): Single; cdecl; external LIB_NAME name _PU + 'b2PrismaticJoint_GetJointTranslation' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PrismaticJointWrapper.GetJointTranslation: Single; cdecl; begin Result := b2PrismaticJoint_GetJointTranslation(FHandle) end; function b2PrismaticJoint_GetJointSpeed(_self: b2PrismaticJointHandle): Single; cdecl; external LIB_NAME name _PU + 'b2PrismaticJoint_GetJointSpeed' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PrismaticJointWrapper.GetJointSpeed: Single; cdecl; begin Result := b2PrismaticJoint_GetJointSpeed(FHandle) end; function b2PrismaticJoint_IsLimitEnabled(_self: b2PrismaticJointHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2PrismaticJoint_IsLimitEnabled' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PrismaticJointWrapper.IsLimitEnabled: Boolean; cdecl; begin Result := b2PrismaticJoint_IsLimitEnabled(FHandle) end; procedure b2PrismaticJoint_EnableLimit(_self: b2PrismaticJointHandle; flag: Boolean); cdecl; external LIB_NAME name _PU + 'b2PrismaticJoint_EnableLimit' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2PrismaticJointWrapper.EnableLimit(flag: Boolean); cdecl; begin b2PrismaticJoint_EnableLimit(FHandle, flag) end; function b2PrismaticJoint_GetLowerLimit(_self: b2PrismaticJointHandle): Single; cdecl; external LIB_NAME name _PU + 'b2PrismaticJoint_GetLowerLimit' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PrismaticJointWrapper.GetLowerLimit: Single; cdecl; begin Result := b2PrismaticJoint_GetLowerLimit(FHandle) end; function b2PrismaticJoint_GetUpperLimit(_self: b2PrismaticJointHandle): Single; cdecl; external LIB_NAME name _PU + 'b2PrismaticJoint_GetUpperLimit' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PrismaticJointWrapper.GetUpperLimit: Single; cdecl; begin Result := b2PrismaticJoint_GetUpperLimit(FHandle) end; procedure b2PrismaticJoint_SetLimits(_self: b2PrismaticJointHandle; lower: Single; upper: Single); cdecl; external LIB_NAME name _PU + 'b2PrismaticJoint_SetLimits' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2PrismaticJointWrapper.SetLimits(lower: Single; upper: Single); cdecl; begin b2PrismaticJoint_SetLimits(FHandle, lower, upper) end; function b2PrismaticJoint_IsMotorEnabled(_self: b2PrismaticJointHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2PrismaticJoint_IsMotorEnabled' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PrismaticJointWrapper.IsMotorEnabled: Boolean; cdecl; begin Result := b2PrismaticJoint_IsMotorEnabled(FHandle) end; procedure b2PrismaticJoint_EnableMotor(_self: b2PrismaticJointHandle; flag: Boolean); cdecl; external LIB_NAME name _PU + 'b2PrismaticJoint_EnableMotor' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2PrismaticJointWrapper.EnableMotor(flag: Boolean); cdecl; begin b2PrismaticJoint_EnableMotor(FHandle, flag) end; procedure b2PrismaticJoint_SetMotorSpeed(_self: b2PrismaticJointHandle; speed: Single); cdecl; external LIB_NAME name _PU + 'b2PrismaticJoint_SetMotorSpeed' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2PrismaticJointWrapper.SetMotorSpeed(speed: Single); cdecl; begin b2PrismaticJoint_SetMotorSpeed(FHandle, speed) end; function b2PrismaticJoint_GetMotorSpeed(_self: b2PrismaticJointHandle): Single; cdecl; external LIB_NAME name _PU + 'b2PrismaticJoint_GetMotorSpeed' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PrismaticJointWrapper.GetMotorSpeed: Single; cdecl; begin Result := b2PrismaticJoint_GetMotorSpeed(FHandle) end; procedure b2PrismaticJoint_SetMaxMotorForce(_self: b2PrismaticJointHandle; force: Single); cdecl; external LIB_NAME name _PU + 'b2PrismaticJoint_SetMaxMotorForce' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2PrismaticJointWrapper.SetMaxMotorForce(force: Single); cdecl; begin b2PrismaticJoint_SetMaxMotorForce(FHandle, force) end; function b2PrismaticJoint_GetMaxMotorForce(_self: b2PrismaticJointHandle): Single; cdecl; external LIB_NAME name _PU + 'b2PrismaticJoint_GetMaxMotorForce' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PrismaticJointWrapper.GetMaxMotorForce: Single; cdecl; begin Result := b2PrismaticJoint_GetMaxMotorForce(FHandle) end; function b2PrismaticJoint_GetMotorForce(_self: b2PrismaticJointHandle; inv_dt: Single): Single; cdecl; external LIB_NAME name _PU + 'b2PrismaticJoint_GetMotorForce' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PrismaticJointWrapper.GetMotorForce(inv_dt: Single): Single; cdecl; begin Result := b2PrismaticJoint_GetMotorForce(FHandle, inv_dt) end; function b2PulleyJointDef_Create: b2PulleyJointDef; cdecl; external LIB_NAME name _PU + 'b2PulleyJointDef_b2PulleyJointDef_1' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; class function b2PulleyJointDef.Create: b2PulleyJointDef; cdecl; begin Result := b2PulleyJointDef_Create; end; procedure b2PulleyJointDef_Initialize(_self: Pb2PulleyJointDef; bodyA: b2BodyHandle; bodyB: b2BodyHandle; const [ref] groundAnchorA: b2Vec2; const [ref] groundAnchorB: b2Vec2; const [ref] anchorA: b2Vec2; const [ref] anchorB: b2Vec2; ratio: Single); cdecl; external LIB_NAME name _PU + 'b2PulleyJointDef_Initialize' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2PulleyJointDef.Initialize(bodyA: b2BodyHandle; bodyB: b2BodyHandle; const [ref] groundAnchorA: b2Vec2; const [ref] groundAnchorB: b2Vec2; const [ref] anchorA: b2Vec2; const [ref] anchorB: b2Vec2; ratio: Single); cdecl; begin b2PulleyJointDef_Initialize(@Self, bodyA, bodyB, groundAnchorA, groundAnchorB, anchorA, anchorB, ratio) end; procedure b2PulleyJoint_Destroy(_self: b2PulleyJointHandle); cdecl; external LIB_NAME name _PU + 'b2PulleyJoint_dtor' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2PulleyJointWrapper.Destroy; cdecl; begin b2PulleyJoint_Destroy(FHandle); end; class operator b2PulleyJointWrapper.Implicit(handle: b2PulleyJointHandle): b2PulleyJointWrapper; begin Result.FHandle := handle; end; class operator b2PulleyJointWrapper.Implicit(wrapper: b2PulleyJointWrapper): b2PulleyJointHandle; begin Result := wrapper.FHandle; end; function b2PulleyJoint_GetType(_self: b2PulleyJointHandle): b2JointType; cdecl; external LIB_NAME name _PU + 'b2PulleyJoint_GetType' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PulleyJointWrapper.GetType: b2JointType; cdecl; begin Result := b2PulleyJoint_GetType(FHandle) end; function b2PulleyJoint_GetBodyA(_self: b2PulleyJointHandle): b2BodyHandle; cdecl; external LIB_NAME name _PU + 'b2PulleyJoint_GetBodyA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PulleyJointWrapper.GetBodyA: b2BodyHandle; cdecl; begin Result := b2PulleyJoint_GetBodyA(FHandle) end; function b2PulleyJoint_GetBodyB(_self: b2PulleyJointHandle): b2BodyHandle; cdecl; external LIB_NAME name _PU + 'b2PulleyJoint_GetBodyB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PulleyJointWrapper.GetBodyB: b2BodyHandle; cdecl; begin Result := b2PulleyJoint_GetBodyB(FHandle) end; function b2PulleyJoint_GetAnchorA(_self: b2PulleyJointHandle): b2Vec2; cdecl; external LIB_NAME name _PU + 'b2PulleyJoint_GetAnchorA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PulleyJointWrapper.GetAnchorA: b2Vec2; cdecl; begin Result := b2PulleyJoint_GetAnchorA(FHandle) end; function b2PulleyJoint_GetAnchorB(_self: b2PulleyJointHandle): b2Vec2; cdecl; external LIB_NAME name _PU + 'b2PulleyJoint_GetAnchorB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PulleyJointWrapper.GetAnchorB: b2Vec2; cdecl; begin Result := b2PulleyJoint_GetAnchorB(FHandle) end; function b2PulleyJoint_GetReactionForce(_self: b2PulleyJointHandle; inv_dt: Single): b2Vec2; cdecl; external LIB_NAME name _PU + 'b2PulleyJoint_GetReactionForce' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PulleyJointWrapper.GetReactionForce(inv_dt: Single): b2Vec2; cdecl; begin Result := b2PulleyJoint_GetReactionForce(FHandle, inv_dt) end; function b2PulleyJoint_GetReactionTorque(_self: b2PulleyJointHandle; inv_dt: Single): Single; cdecl; external LIB_NAME name _PU + 'b2PulleyJoint_GetReactionTorque' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PulleyJointWrapper.GetReactionTorque(inv_dt: Single): Single; cdecl; begin Result := b2PulleyJoint_GetReactionTorque(FHandle, inv_dt) end; function b2PulleyJoint_GetNext(_self: b2PulleyJointHandle): b2JointHandle; cdecl; external LIB_NAME name _PU + 'b2PulleyJoint_GetNext' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PulleyJointWrapper.GetNext: b2JointHandle; cdecl; begin Result := b2PulleyJoint_GetNext(FHandle) end; function b2PulleyJoint_GetUserData(_self: b2PulleyJointHandle): Pointer; cdecl; external LIB_NAME name _PU + 'b2PulleyJoint_GetUserData' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PulleyJointWrapper.GetUserData: Pointer; cdecl; begin Result := b2PulleyJoint_GetUserData(FHandle) end; procedure b2PulleyJoint_SetUserData(_self: b2PulleyJointHandle; data: Pointer); cdecl; external LIB_NAME name _PU + 'b2PulleyJoint_SetUserData' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2PulleyJointWrapper.SetUserData(data: Pointer); cdecl; begin b2PulleyJoint_SetUserData(FHandle, data) end; function b2PulleyJoint_IsActive(_self: b2PulleyJointHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2PulleyJoint_IsActive' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PulleyJointWrapper.IsActive: Boolean; cdecl; begin Result := b2PulleyJoint_IsActive(FHandle) end; function b2PulleyJoint_GetCollideConnected(_self: b2PulleyJointHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2PulleyJoint_GetCollideConnected' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PulleyJointWrapper.GetCollideConnected: Boolean; cdecl; begin Result := b2PulleyJoint_GetCollideConnected(FHandle) end; procedure b2PulleyJoint_Dump(_self: b2PulleyJointHandle); cdecl; external LIB_NAME name _PU + 'b2PulleyJoint_Dump' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2PulleyJointWrapper.Dump; cdecl; begin b2PulleyJoint_Dump(FHandle) end; procedure b2PulleyJoint_ShiftOrigin(_self: b2PulleyJointHandle; const [ref] newOrigin: b2Vec2); cdecl; external LIB_NAME name _PU + 'b2PulleyJoint_ShiftOrigin' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2PulleyJointWrapper.ShiftOrigin(const [ref] newOrigin: b2Vec2); cdecl; begin b2PulleyJoint_ShiftOrigin(FHandle, newOrigin) end; function b2PulleyJoint_GetGroundAnchorA(_self: b2PulleyJointHandle): b2Vec2; cdecl; external LIB_NAME name _PU + 'b2PulleyJoint_GetGroundAnchorA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PulleyJointWrapper.GetGroundAnchorA: b2Vec2; cdecl; begin Result := b2PulleyJoint_GetGroundAnchorA(FHandle) end; function b2PulleyJoint_GetGroundAnchorB(_self: b2PulleyJointHandle): b2Vec2; cdecl; external LIB_NAME name _PU + 'b2PulleyJoint_GetGroundAnchorB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PulleyJointWrapper.GetGroundAnchorB: b2Vec2; cdecl; begin Result := b2PulleyJoint_GetGroundAnchorB(FHandle) end; function b2PulleyJoint_GetLengthA(_self: b2PulleyJointHandle): Single; cdecl; external LIB_NAME name _PU + 'b2PulleyJoint_GetLengthA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PulleyJointWrapper.GetLengthA: Single; cdecl; begin Result := b2PulleyJoint_GetLengthA(FHandle) end; function b2PulleyJoint_GetLengthB(_self: b2PulleyJointHandle): Single; cdecl; external LIB_NAME name _PU + 'b2PulleyJoint_GetLengthB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PulleyJointWrapper.GetLengthB: Single; cdecl; begin Result := b2PulleyJoint_GetLengthB(FHandle) end; function b2PulleyJoint_GetRatio(_self: b2PulleyJointHandle): Single; cdecl; external LIB_NAME name _PU + 'b2PulleyJoint_GetRatio' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PulleyJointWrapper.GetRatio: Single; cdecl; begin Result := b2PulleyJoint_GetRatio(FHandle) end; function b2PulleyJoint_GetCurrentLengthA(_self: b2PulleyJointHandle): Single; cdecl; external LIB_NAME name _PU + 'b2PulleyJoint_GetCurrentLengthA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PulleyJointWrapper.GetCurrentLengthA: Single; cdecl; begin Result := b2PulleyJoint_GetCurrentLengthA(FHandle) end; function b2PulleyJoint_GetCurrentLengthB(_self: b2PulleyJointHandle): Single; cdecl; external LIB_NAME name _PU + 'b2PulleyJoint_GetCurrentLengthB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2PulleyJointWrapper.GetCurrentLengthB: Single; cdecl; begin Result := b2PulleyJoint_GetCurrentLengthB(FHandle) end; function b2RevoluteJointDef_Create: b2RevoluteJointDef; cdecl; external LIB_NAME name _PU + 'b2RevoluteJointDef_b2RevoluteJointDef_1' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; class function b2RevoluteJointDef.Create: b2RevoluteJointDef; cdecl; begin Result := b2RevoluteJointDef_Create; end; procedure b2RevoluteJointDef_Initialize(_self: Pb2RevoluteJointDef; bodyA: b2BodyHandle; bodyB: b2BodyHandle; const [ref] anchor: b2Vec2); cdecl; external LIB_NAME name _PU + 'b2RevoluteJointDef_Initialize' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2RevoluteJointDef.Initialize(bodyA: b2BodyHandle; bodyB: b2BodyHandle; const [ref] anchor: b2Vec2); cdecl; begin b2RevoluteJointDef_Initialize(@Self, bodyA, bodyB, anchor) end; procedure b2RevoluteJoint_Destroy(_self: b2RevoluteJointHandle); cdecl; external LIB_NAME name _PU + 'b2RevoluteJoint_dtor' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2RevoluteJointWrapper.Destroy; cdecl; begin b2RevoluteJoint_Destroy(FHandle); end; class operator b2RevoluteJointWrapper.Implicit(handle: b2RevoluteJointHandle): b2RevoluteJointWrapper; begin Result.FHandle := handle; end; class operator b2RevoluteJointWrapper.Implicit(wrapper: b2RevoluteJointWrapper): b2RevoluteJointHandle; begin Result := wrapper.FHandle; end; function b2RevoluteJoint_GetType(_self: b2RevoluteJointHandle): b2JointType; cdecl; external LIB_NAME name _PU + 'b2RevoluteJoint_GetType' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2RevoluteJointWrapper.GetType: b2JointType; cdecl; begin Result := b2RevoluteJoint_GetType(FHandle) end; function b2RevoluteJoint_GetBodyA(_self: b2RevoluteJointHandle): b2BodyHandle; cdecl; external LIB_NAME name _PU + 'b2RevoluteJoint_GetBodyA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2RevoluteJointWrapper.GetBodyA: b2BodyHandle; cdecl; begin Result := b2RevoluteJoint_GetBodyA(FHandle) end; function b2RevoluteJoint_GetBodyB(_self: b2RevoluteJointHandle): b2BodyHandle; cdecl; external LIB_NAME name _PU + 'b2RevoluteJoint_GetBodyB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2RevoluteJointWrapper.GetBodyB: b2BodyHandle; cdecl; begin Result := b2RevoluteJoint_GetBodyB(FHandle) end; function b2RevoluteJoint_GetAnchorA(_self: b2RevoluteJointHandle): b2Vec2; cdecl; external LIB_NAME name _PU + 'b2RevoluteJoint_GetAnchorA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2RevoluteJointWrapper.GetAnchorA: b2Vec2; cdecl; begin Result := b2RevoluteJoint_GetAnchorA(FHandle) end; function b2RevoluteJoint_GetAnchorB(_self: b2RevoluteJointHandle): b2Vec2; cdecl; external LIB_NAME name _PU + 'b2RevoluteJoint_GetAnchorB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2RevoluteJointWrapper.GetAnchorB: b2Vec2; cdecl; begin Result := b2RevoluteJoint_GetAnchorB(FHandle) end; function b2RevoluteJoint_GetReactionForce(_self: b2RevoluteJointHandle; inv_dt: Single): b2Vec2; cdecl; external LIB_NAME name _PU + 'b2RevoluteJoint_GetReactionForce' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2RevoluteJointWrapper.GetReactionForce(inv_dt: Single): b2Vec2; cdecl; begin Result := b2RevoluteJoint_GetReactionForce(FHandle, inv_dt) end; function b2RevoluteJoint_GetReactionTorque(_self: b2RevoluteJointHandle; inv_dt: Single): Single; cdecl; external LIB_NAME name _PU + 'b2RevoluteJoint_GetReactionTorque' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2RevoluteJointWrapper.GetReactionTorque(inv_dt: Single): Single; cdecl; begin Result := b2RevoluteJoint_GetReactionTorque(FHandle, inv_dt) end; function b2RevoluteJoint_GetNext(_self: b2RevoluteJointHandle): b2JointHandle; cdecl; external LIB_NAME name _PU + 'b2RevoluteJoint_GetNext' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2RevoluteJointWrapper.GetNext: b2JointHandle; cdecl; begin Result := b2RevoluteJoint_GetNext(FHandle) end; function b2RevoluteJoint_GetUserData(_self: b2RevoluteJointHandle): Pointer; cdecl; external LIB_NAME name _PU + 'b2RevoluteJoint_GetUserData' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2RevoluteJointWrapper.GetUserData: Pointer; cdecl; begin Result := b2RevoluteJoint_GetUserData(FHandle) end; procedure b2RevoluteJoint_SetUserData(_self: b2RevoluteJointHandle; data: Pointer); cdecl; external LIB_NAME name _PU + 'b2RevoluteJoint_SetUserData' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2RevoluteJointWrapper.SetUserData(data: Pointer); cdecl; begin b2RevoluteJoint_SetUserData(FHandle, data) end; function b2RevoluteJoint_IsActive(_self: b2RevoluteJointHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2RevoluteJoint_IsActive' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2RevoluteJointWrapper.IsActive: Boolean; cdecl; begin Result := b2RevoluteJoint_IsActive(FHandle) end; function b2RevoluteJoint_GetCollideConnected(_self: b2RevoluteJointHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2RevoluteJoint_GetCollideConnected' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2RevoluteJointWrapper.GetCollideConnected: Boolean; cdecl; begin Result := b2RevoluteJoint_GetCollideConnected(FHandle) end; procedure b2RevoluteJoint_Dump(_self: b2RevoluteJointHandle); cdecl; external LIB_NAME name _PU + 'b2RevoluteJoint_Dump' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2RevoluteJointWrapper.Dump; cdecl; begin b2RevoluteJoint_Dump(FHandle) end; procedure b2RevoluteJoint_ShiftOrigin(_self: b2RevoluteJointHandle; const [ref] newOrigin: b2Vec2); cdecl; external LIB_NAME name _PU + 'b2RevoluteJoint_ShiftOrigin' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2RevoluteJointWrapper.ShiftOrigin(const [ref] newOrigin: b2Vec2); cdecl; begin b2RevoluteJoint_ShiftOrigin(FHandle, newOrigin) end; function b2RevoluteJoint_GetLocalAnchorA(_self: b2RevoluteJointHandle): Pb2Vec2; cdecl; external LIB_NAME name _PU + 'b2RevoluteJoint_GetLocalAnchorA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2RevoluteJointWrapper.GetLocalAnchorA: Pb2Vec2; cdecl; begin Result := b2RevoluteJoint_GetLocalAnchorA(FHandle) end; function b2RevoluteJoint_GetLocalAnchorB(_self: b2RevoluteJointHandle): Pb2Vec2; cdecl; external LIB_NAME name _PU + 'b2RevoluteJoint_GetLocalAnchorB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2RevoluteJointWrapper.GetLocalAnchorB: Pb2Vec2; cdecl; begin Result := b2RevoluteJoint_GetLocalAnchorB(FHandle) end; function b2RevoluteJoint_GetReferenceAngle(_self: b2RevoluteJointHandle): Single; cdecl; external LIB_NAME name _PU + 'b2RevoluteJoint_GetReferenceAngle' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2RevoluteJointWrapper.GetReferenceAngle: Single; cdecl; begin Result := b2RevoluteJoint_GetReferenceAngle(FHandle) end; function b2RevoluteJoint_GetJointAngle(_self: b2RevoluteJointHandle): Single; cdecl; external LIB_NAME name _PU + 'b2RevoluteJoint_GetJointAngle' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2RevoluteJointWrapper.GetJointAngle: Single; cdecl; begin Result := b2RevoluteJoint_GetJointAngle(FHandle) end; function b2RevoluteJoint_GetJointSpeed(_self: b2RevoluteJointHandle): Single; cdecl; external LIB_NAME name _PU + 'b2RevoluteJoint_GetJointSpeed' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2RevoluteJointWrapper.GetJointSpeed: Single; cdecl; begin Result := b2RevoluteJoint_GetJointSpeed(FHandle) end; function b2RevoluteJoint_IsLimitEnabled(_self: b2RevoluteJointHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2RevoluteJoint_IsLimitEnabled' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2RevoluteJointWrapper.IsLimitEnabled: Boolean; cdecl; begin Result := b2RevoluteJoint_IsLimitEnabled(FHandle) end; procedure b2RevoluteJoint_EnableLimit(_self: b2RevoluteJointHandle; flag: Boolean); cdecl; external LIB_NAME name _PU + 'b2RevoluteJoint_EnableLimit' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2RevoluteJointWrapper.EnableLimit(flag: Boolean); cdecl; begin b2RevoluteJoint_EnableLimit(FHandle, flag) end; function b2RevoluteJoint_GetLowerLimit(_self: b2RevoluteJointHandle): Single; cdecl; external LIB_NAME name _PU + 'b2RevoluteJoint_GetLowerLimit' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2RevoluteJointWrapper.GetLowerLimit: Single; cdecl; begin Result := b2RevoluteJoint_GetLowerLimit(FHandle) end; function b2RevoluteJoint_GetUpperLimit(_self: b2RevoluteJointHandle): Single; cdecl; external LIB_NAME name _PU + 'b2RevoluteJoint_GetUpperLimit' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2RevoluteJointWrapper.GetUpperLimit: Single; cdecl; begin Result := b2RevoluteJoint_GetUpperLimit(FHandle) end; procedure b2RevoluteJoint_SetLimits(_self: b2RevoluteJointHandle; lower: Single; upper: Single); cdecl; external LIB_NAME name _PU + 'b2RevoluteJoint_SetLimits' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2RevoluteJointWrapper.SetLimits(lower: Single; upper: Single); cdecl; begin b2RevoluteJoint_SetLimits(FHandle, lower, upper) end; function b2RevoluteJoint_IsMotorEnabled(_self: b2RevoluteJointHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2RevoluteJoint_IsMotorEnabled' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2RevoluteJointWrapper.IsMotorEnabled: Boolean; cdecl; begin Result := b2RevoluteJoint_IsMotorEnabled(FHandle) end; procedure b2RevoluteJoint_EnableMotor(_self: b2RevoluteJointHandle; flag: Boolean); cdecl; external LIB_NAME name _PU + 'b2RevoluteJoint_EnableMotor' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2RevoluteJointWrapper.EnableMotor(flag: Boolean); cdecl; begin b2RevoluteJoint_EnableMotor(FHandle, flag) end; procedure b2RevoluteJoint_SetMotorSpeed(_self: b2RevoluteJointHandle; speed: Single); cdecl; external LIB_NAME name _PU + 'b2RevoluteJoint_SetMotorSpeed' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2RevoluteJointWrapper.SetMotorSpeed(speed: Single); cdecl; begin b2RevoluteJoint_SetMotorSpeed(FHandle, speed) end; function b2RevoluteJoint_GetMotorSpeed(_self: b2RevoluteJointHandle): Single; cdecl; external LIB_NAME name _PU + 'b2RevoluteJoint_GetMotorSpeed' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2RevoluteJointWrapper.GetMotorSpeed: Single; cdecl; begin Result := b2RevoluteJoint_GetMotorSpeed(FHandle) end; procedure b2RevoluteJoint_SetMaxMotorTorque(_self: b2RevoluteJointHandle; torque: Single); cdecl; external LIB_NAME name _PU + 'b2RevoluteJoint_SetMaxMotorTorque' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2RevoluteJointWrapper.SetMaxMotorTorque(torque: Single); cdecl; begin b2RevoluteJoint_SetMaxMotorTorque(FHandle, torque) end; function b2RevoluteJoint_GetMaxMotorTorque(_self: b2RevoluteJointHandle): Single; cdecl; external LIB_NAME name _PU + 'b2RevoluteJoint_GetMaxMotorTorque' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2RevoluteJointWrapper.GetMaxMotorTorque: Single; cdecl; begin Result := b2RevoluteJoint_GetMaxMotorTorque(FHandle) end; function b2RevoluteJoint_GetMotorTorque(_self: b2RevoluteJointHandle; inv_dt: Single): Single; cdecl; external LIB_NAME name _PU + 'b2RevoluteJoint_GetMotorTorque' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2RevoluteJointWrapper.GetMotorTorque(inv_dt: Single): Single; cdecl; begin Result := b2RevoluteJoint_GetMotorTorque(FHandle, inv_dt) end; function b2RopeJointDef_Create: b2RopeJointDef; cdecl; external LIB_NAME name _PU + 'b2RopeJointDef_b2RopeJointDef_1' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; class function b2RopeJointDef.Create: b2RopeJointDef; cdecl; begin Result := b2RopeJointDef_Create; end; procedure b2RopeJoint_Destroy(_self: b2RopeJointHandle); cdecl; external LIB_NAME name _PU + 'b2RopeJoint_dtor' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2RopeJointWrapper.Destroy; cdecl; begin b2RopeJoint_Destroy(FHandle); end; class operator b2RopeJointWrapper.Implicit(handle: b2RopeJointHandle): b2RopeJointWrapper; begin Result.FHandle := handle; end; class operator b2RopeJointWrapper.Implicit(wrapper: b2RopeJointWrapper): b2RopeJointHandle; begin Result := wrapper.FHandle; end; function b2RopeJoint_GetType(_self: b2RopeJointHandle): b2JointType; cdecl; external LIB_NAME name _PU + 'b2RopeJoint_GetType' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2RopeJointWrapper.GetType: b2JointType; cdecl; begin Result := b2RopeJoint_GetType(FHandle) end; function b2RopeJoint_GetBodyA(_self: b2RopeJointHandle): b2BodyHandle; cdecl; external LIB_NAME name _PU + 'b2RopeJoint_GetBodyA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2RopeJointWrapper.GetBodyA: b2BodyHandle; cdecl; begin Result := b2RopeJoint_GetBodyA(FHandle) end; function b2RopeJoint_GetBodyB(_self: b2RopeJointHandle): b2BodyHandle; cdecl; external LIB_NAME name _PU + 'b2RopeJoint_GetBodyB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2RopeJointWrapper.GetBodyB: b2BodyHandle; cdecl; begin Result := b2RopeJoint_GetBodyB(FHandle) end; function b2RopeJoint_GetAnchorA(_self: b2RopeJointHandle): b2Vec2; cdecl; external LIB_NAME name _PU + 'b2RopeJoint_GetAnchorA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2RopeJointWrapper.GetAnchorA: b2Vec2; cdecl; begin Result := b2RopeJoint_GetAnchorA(FHandle) end; function b2RopeJoint_GetAnchorB(_self: b2RopeJointHandle): b2Vec2; cdecl; external LIB_NAME name _PU + 'b2RopeJoint_GetAnchorB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2RopeJointWrapper.GetAnchorB: b2Vec2; cdecl; begin Result := b2RopeJoint_GetAnchorB(FHandle) end; function b2RopeJoint_GetReactionForce(_self: b2RopeJointHandle; inv_dt: Single): b2Vec2; cdecl; external LIB_NAME name _PU + 'b2RopeJoint_GetReactionForce' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2RopeJointWrapper.GetReactionForce(inv_dt: Single): b2Vec2; cdecl; begin Result := b2RopeJoint_GetReactionForce(FHandle, inv_dt) end; function b2RopeJoint_GetReactionTorque(_self: b2RopeJointHandle; inv_dt: Single): Single; cdecl; external LIB_NAME name _PU + 'b2RopeJoint_GetReactionTorque' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2RopeJointWrapper.GetReactionTorque(inv_dt: Single): Single; cdecl; begin Result := b2RopeJoint_GetReactionTorque(FHandle, inv_dt) end; function b2RopeJoint_GetNext(_self: b2RopeJointHandle): b2JointHandle; cdecl; external LIB_NAME name _PU + 'b2RopeJoint_GetNext' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2RopeJointWrapper.GetNext: b2JointHandle; cdecl; begin Result := b2RopeJoint_GetNext(FHandle) end; function b2RopeJoint_GetUserData(_self: b2RopeJointHandle): Pointer; cdecl; external LIB_NAME name _PU + 'b2RopeJoint_GetUserData' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2RopeJointWrapper.GetUserData: Pointer; cdecl; begin Result := b2RopeJoint_GetUserData(FHandle) end; procedure b2RopeJoint_SetUserData(_self: b2RopeJointHandle; data: Pointer); cdecl; external LIB_NAME name _PU + 'b2RopeJoint_SetUserData' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2RopeJointWrapper.SetUserData(data: Pointer); cdecl; begin b2RopeJoint_SetUserData(FHandle, data) end; function b2RopeJoint_IsActive(_self: b2RopeJointHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2RopeJoint_IsActive' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2RopeJointWrapper.IsActive: Boolean; cdecl; begin Result := b2RopeJoint_IsActive(FHandle) end; function b2RopeJoint_GetCollideConnected(_self: b2RopeJointHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2RopeJoint_GetCollideConnected' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2RopeJointWrapper.GetCollideConnected: Boolean; cdecl; begin Result := b2RopeJoint_GetCollideConnected(FHandle) end; procedure b2RopeJoint_Dump(_self: b2RopeJointHandle); cdecl; external LIB_NAME name _PU + 'b2RopeJoint_Dump' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2RopeJointWrapper.Dump; cdecl; begin b2RopeJoint_Dump(FHandle) end; procedure b2RopeJoint_ShiftOrigin(_self: b2RopeJointHandle; const [ref] newOrigin: b2Vec2); cdecl; external LIB_NAME name _PU + 'b2RopeJoint_ShiftOrigin' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2RopeJointWrapper.ShiftOrigin(const [ref] newOrigin: b2Vec2); cdecl; begin b2RopeJoint_ShiftOrigin(FHandle, newOrigin) end; function b2RopeJoint_GetLocalAnchorA(_self: b2RopeJointHandle): Pb2Vec2; cdecl; external LIB_NAME name _PU + 'b2RopeJoint_GetLocalAnchorA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2RopeJointWrapper.GetLocalAnchorA: Pb2Vec2; cdecl; begin Result := b2RopeJoint_GetLocalAnchorA(FHandle) end; function b2RopeJoint_GetLocalAnchorB(_self: b2RopeJointHandle): Pb2Vec2; cdecl; external LIB_NAME name _PU + 'b2RopeJoint_GetLocalAnchorB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2RopeJointWrapper.GetLocalAnchorB: Pb2Vec2; cdecl; begin Result := b2RopeJoint_GetLocalAnchorB(FHandle) end; procedure b2RopeJoint_SetMaxLength(_self: b2RopeJointHandle; length: Single); cdecl; external LIB_NAME name _PU + 'b2RopeJoint_SetMaxLength' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2RopeJointWrapper.SetMaxLength(length: Single); cdecl; begin b2RopeJoint_SetMaxLength(FHandle, length) end; function b2RopeJoint_GetMaxLength(_self: b2RopeJointHandle): Single; cdecl; external LIB_NAME name _PU + 'b2RopeJoint_GetMaxLength' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2RopeJointWrapper.GetMaxLength: Single; cdecl; begin Result := b2RopeJoint_GetMaxLength(FHandle) end; function b2RopeJoint_GetLimitState(_self: b2RopeJointHandle): b2LimitState; cdecl; external LIB_NAME name _PU + 'b2RopeJoint_GetLimitState' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2RopeJointWrapper.GetLimitState: b2LimitState; cdecl; begin Result := b2RopeJoint_GetLimitState(FHandle) end; function b2WeldJointDef_Create: b2WeldJointDef; cdecl; external LIB_NAME name _PU + 'b2WeldJointDef_b2WeldJointDef_1' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; class function b2WeldJointDef.Create: b2WeldJointDef; cdecl; begin Result := b2WeldJointDef_Create; end; procedure b2WeldJointDef_Initialize(_self: Pb2WeldJointDef; bodyA: b2BodyHandle; bodyB: b2BodyHandle; const [ref] anchor: b2Vec2); cdecl; external LIB_NAME name _PU + 'b2WeldJointDef_Initialize' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2WeldJointDef.Initialize(bodyA: b2BodyHandle; bodyB: b2BodyHandle; const [ref] anchor: b2Vec2); cdecl; begin b2WeldJointDef_Initialize(@Self, bodyA, bodyB, anchor) end; procedure b2WeldJoint_Destroy(_self: b2WeldJointHandle); cdecl; external LIB_NAME name _PU + 'b2WeldJoint_dtor' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2WeldJointWrapper.Destroy; cdecl; begin b2WeldJoint_Destroy(FHandle); end; class operator b2WeldJointWrapper.Implicit(handle: b2WeldJointHandle): b2WeldJointWrapper; begin Result.FHandle := handle; end; class operator b2WeldJointWrapper.Implicit(wrapper: b2WeldJointWrapper): b2WeldJointHandle; begin Result := wrapper.FHandle; end; function b2WeldJoint_GetType(_self: b2WeldJointHandle): b2JointType; cdecl; external LIB_NAME name _PU + 'b2WeldJoint_GetType' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WeldJointWrapper.GetType: b2JointType; cdecl; begin Result := b2WeldJoint_GetType(FHandle) end; function b2WeldJoint_GetBodyA(_self: b2WeldJointHandle): b2BodyHandle; cdecl; external LIB_NAME name _PU + 'b2WeldJoint_GetBodyA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WeldJointWrapper.GetBodyA: b2BodyHandle; cdecl; begin Result := b2WeldJoint_GetBodyA(FHandle) end; function b2WeldJoint_GetBodyB(_self: b2WeldJointHandle): b2BodyHandle; cdecl; external LIB_NAME name _PU + 'b2WeldJoint_GetBodyB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WeldJointWrapper.GetBodyB: b2BodyHandle; cdecl; begin Result := b2WeldJoint_GetBodyB(FHandle) end; function b2WeldJoint_GetAnchorA(_self: b2WeldJointHandle): b2Vec2; cdecl; external LIB_NAME name _PU + 'b2WeldJoint_GetAnchorA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WeldJointWrapper.GetAnchorA: b2Vec2; cdecl; begin Result := b2WeldJoint_GetAnchorA(FHandle) end; function b2WeldJoint_GetAnchorB(_self: b2WeldJointHandle): b2Vec2; cdecl; external LIB_NAME name _PU + 'b2WeldJoint_GetAnchorB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WeldJointWrapper.GetAnchorB: b2Vec2; cdecl; begin Result := b2WeldJoint_GetAnchorB(FHandle) end; function b2WeldJoint_GetReactionForce(_self: b2WeldJointHandle; inv_dt: Single): b2Vec2; cdecl; external LIB_NAME name _PU + 'b2WeldJoint_GetReactionForce' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WeldJointWrapper.GetReactionForce(inv_dt: Single): b2Vec2; cdecl; begin Result := b2WeldJoint_GetReactionForce(FHandle, inv_dt) end; function b2WeldJoint_GetReactionTorque(_self: b2WeldJointHandle; inv_dt: Single): Single; cdecl; external LIB_NAME name _PU + 'b2WeldJoint_GetReactionTorque' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WeldJointWrapper.GetReactionTorque(inv_dt: Single): Single; cdecl; begin Result := b2WeldJoint_GetReactionTorque(FHandle, inv_dt) end; function b2WeldJoint_GetNext(_self: b2WeldJointHandle): b2JointHandle; cdecl; external LIB_NAME name _PU + 'b2WeldJoint_GetNext' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WeldJointWrapper.GetNext: b2JointHandle; cdecl; begin Result := b2WeldJoint_GetNext(FHandle) end; function b2WeldJoint_GetUserData(_self: b2WeldJointHandle): Pointer; cdecl; external LIB_NAME name _PU + 'b2WeldJoint_GetUserData' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WeldJointWrapper.GetUserData: Pointer; cdecl; begin Result := b2WeldJoint_GetUserData(FHandle) end; procedure b2WeldJoint_SetUserData(_self: b2WeldJointHandle; data: Pointer); cdecl; external LIB_NAME name _PU + 'b2WeldJoint_SetUserData' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2WeldJointWrapper.SetUserData(data: Pointer); cdecl; begin b2WeldJoint_SetUserData(FHandle, data) end; function b2WeldJoint_IsActive(_self: b2WeldJointHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2WeldJoint_IsActive' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WeldJointWrapper.IsActive: Boolean; cdecl; begin Result := b2WeldJoint_IsActive(FHandle) end; function b2WeldJoint_GetCollideConnected(_self: b2WeldJointHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2WeldJoint_GetCollideConnected' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WeldJointWrapper.GetCollideConnected: Boolean; cdecl; begin Result := b2WeldJoint_GetCollideConnected(FHandle) end; procedure b2WeldJoint_Dump(_self: b2WeldJointHandle); cdecl; external LIB_NAME name _PU + 'b2WeldJoint_Dump' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2WeldJointWrapper.Dump; cdecl; begin b2WeldJoint_Dump(FHandle) end; procedure b2WeldJoint_ShiftOrigin(_self: b2WeldJointHandle; const [ref] newOrigin: b2Vec2); cdecl; external LIB_NAME name _PU + 'b2WeldJoint_ShiftOrigin' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2WeldJointWrapper.ShiftOrigin(const [ref] newOrigin: b2Vec2); cdecl; begin b2WeldJoint_ShiftOrigin(FHandle, newOrigin) end; function b2WeldJoint_GetLocalAnchorA(_self: b2WeldJointHandle): Pb2Vec2; cdecl; external LIB_NAME name _PU + 'b2WeldJoint_GetLocalAnchorA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WeldJointWrapper.GetLocalAnchorA: Pb2Vec2; cdecl; begin Result := b2WeldJoint_GetLocalAnchorA(FHandle) end; function b2WeldJoint_GetLocalAnchorB(_self: b2WeldJointHandle): Pb2Vec2; cdecl; external LIB_NAME name _PU + 'b2WeldJoint_GetLocalAnchorB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WeldJointWrapper.GetLocalAnchorB: Pb2Vec2; cdecl; begin Result := b2WeldJoint_GetLocalAnchorB(FHandle) end; function b2WeldJoint_GetReferenceAngle(_self: b2WeldJointHandle): Single; cdecl; external LIB_NAME name _PU + 'b2WeldJoint_GetReferenceAngle' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WeldJointWrapper.GetReferenceAngle: Single; cdecl; begin Result := b2WeldJoint_GetReferenceAngle(FHandle) end; procedure b2WeldJoint_SetFrequency(_self: b2WeldJointHandle; hz: Single); cdecl; external LIB_NAME name _PU + 'b2WeldJoint_SetFrequency' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2WeldJointWrapper.SetFrequency(hz: Single); cdecl; begin b2WeldJoint_SetFrequency(FHandle, hz) end; function b2WeldJoint_GetFrequency(_self: b2WeldJointHandle): Single; cdecl; external LIB_NAME name _PU + 'b2WeldJoint_GetFrequency' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WeldJointWrapper.GetFrequency: Single; cdecl; begin Result := b2WeldJoint_GetFrequency(FHandle) end; procedure b2WeldJoint_SetDampingRatio(_self: b2WeldJointHandle; ratio: Single); cdecl; external LIB_NAME name _PU + 'b2WeldJoint_SetDampingRatio' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2WeldJointWrapper.SetDampingRatio(ratio: Single); cdecl; begin b2WeldJoint_SetDampingRatio(FHandle, ratio) end; function b2WeldJoint_GetDampingRatio(_self: b2WeldJointHandle): Single; cdecl; external LIB_NAME name _PU + 'b2WeldJoint_GetDampingRatio' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WeldJointWrapper.GetDampingRatio: Single; cdecl; begin Result := b2WeldJoint_GetDampingRatio(FHandle) end; function b2WheelJointDef_Create: b2WheelJointDef; cdecl; external LIB_NAME name _PU + 'b2WheelJointDef_b2WheelJointDef_1' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; class function b2WheelJointDef.Create: b2WheelJointDef; cdecl; begin Result := b2WheelJointDef_Create; end; procedure b2WheelJointDef_Initialize(_self: Pb2WheelJointDef; bodyA: b2BodyHandle; bodyB: b2BodyHandle; const [ref] anchor: b2Vec2; const [ref] axis: b2Vec2); cdecl; external LIB_NAME name _PU + 'b2WheelJointDef_Initialize' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2WheelJointDef.Initialize(bodyA: b2BodyHandle; bodyB: b2BodyHandle; const [ref] anchor: b2Vec2; const [ref] axis: b2Vec2); cdecl; begin b2WheelJointDef_Initialize(@Self, bodyA, bodyB, anchor, axis) end; procedure b2WheelJoint_Destroy(_self: b2WheelJointHandle); cdecl; external LIB_NAME name _PU + 'b2WheelJoint_dtor' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2WheelJointWrapper.Destroy; cdecl; begin b2WheelJoint_Destroy(FHandle); end; class operator b2WheelJointWrapper.Implicit(handle: b2WheelJointHandle): b2WheelJointWrapper; begin Result.FHandle := handle; end; class operator b2WheelJointWrapper.Implicit(wrapper: b2WheelJointWrapper): b2WheelJointHandle; begin Result := wrapper.FHandle; end; function b2WheelJoint_GetType(_self: b2WheelJointHandle): b2JointType; cdecl; external LIB_NAME name _PU + 'b2WheelJoint_GetType' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WheelJointWrapper.GetType: b2JointType; cdecl; begin Result := b2WheelJoint_GetType(FHandle) end; function b2WheelJoint_GetBodyA(_self: b2WheelJointHandle): b2BodyHandle; cdecl; external LIB_NAME name _PU + 'b2WheelJoint_GetBodyA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WheelJointWrapper.GetBodyA: b2BodyHandle; cdecl; begin Result := b2WheelJoint_GetBodyA(FHandle) end; function b2WheelJoint_GetBodyB(_self: b2WheelJointHandle): b2BodyHandle; cdecl; external LIB_NAME name _PU + 'b2WheelJoint_GetBodyB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WheelJointWrapper.GetBodyB: b2BodyHandle; cdecl; begin Result := b2WheelJoint_GetBodyB(FHandle) end; function b2WheelJoint_GetAnchorA(_self: b2WheelJointHandle): b2Vec2; cdecl; external LIB_NAME name _PU + 'b2WheelJoint_GetAnchorA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WheelJointWrapper.GetAnchorA: b2Vec2; cdecl; begin Result := b2WheelJoint_GetAnchorA(FHandle) end; function b2WheelJoint_GetAnchorB(_self: b2WheelJointHandle): b2Vec2; cdecl; external LIB_NAME name _PU + 'b2WheelJoint_GetAnchorB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WheelJointWrapper.GetAnchorB: b2Vec2; cdecl; begin Result := b2WheelJoint_GetAnchorB(FHandle) end; function b2WheelJoint_GetReactionForce(_self: b2WheelJointHandle; inv_dt: Single): b2Vec2; cdecl; external LIB_NAME name _PU + 'b2WheelJoint_GetReactionForce' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WheelJointWrapper.GetReactionForce(inv_dt: Single): b2Vec2; cdecl; begin Result := b2WheelJoint_GetReactionForce(FHandle, inv_dt) end; function b2WheelJoint_GetReactionTorque(_self: b2WheelJointHandle; inv_dt: Single): Single; cdecl; external LIB_NAME name _PU + 'b2WheelJoint_GetReactionTorque' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WheelJointWrapper.GetReactionTorque(inv_dt: Single): Single; cdecl; begin Result := b2WheelJoint_GetReactionTorque(FHandle, inv_dt) end; function b2WheelJoint_GetNext(_self: b2WheelJointHandle): b2JointHandle; cdecl; external LIB_NAME name _PU + 'b2WheelJoint_GetNext' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WheelJointWrapper.GetNext: b2JointHandle; cdecl; begin Result := b2WheelJoint_GetNext(FHandle) end; function b2WheelJoint_GetUserData(_self: b2WheelJointHandle): Pointer; cdecl; external LIB_NAME name _PU + 'b2WheelJoint_GetUserData' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WheelJointWrapper.GetUserData: Pointer; cdecl; begin Result := b2WheelJoint_GetUserData(FHandle) end; procedure b2WheelJoint_SetUserData(_self: b2WheelJointHandle; data: Pointer); cdecl; external LIB_NAME name _PU + 'b2WheelJoint_SetUserData' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2WheelJointWrapper.SetUserData(data: Pointer); cdecl; begin b2WheelJoint_SetUserData(FHandle, data) end; function b2WheelJoint_IsActive(_self: b2WheelJointHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2WheelJoint_IsActive' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WheelJointWrapper.IsActive: Boolean; cdecl; begin Result := b2WheelJoint_IsActive(FHandle) end; function b2WheelJoint_GetCollideConnected(_self: b2WheelJointHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2WheelJoint_GetCollideConnected' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WheelJointWrapper.GetCollideConnected: Boolean; cdecl; begin Result := b2WheelJoint_GetCollideConnected(FHandle) end; procedure b2WheelJoint_Dump(_self: b2WheelJointHandle); cdecl; external LIB_NAME name _PU + 'b2WheelJoint_Dump' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2WheelJointWrapper.Dump; cdecl; begin b2WheelJoint_Dump(FHandle) end; procedure b2WheelJoint_ShiftOrigin(_self: b2WheelJointHandle; const [ref] newOrigin: b2Vec2); cdecl; external LIB_NAME name _PU + 'b2WheelJoint_ShiftOrigin' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2WheelJointWrapper.ShiftOrigin(const [ref] newOrigin: b2Vec2); cdecl; begin b2WheelJoint_ShiftOrigin(FHandle, newOrigin) end; function b2WheelJoint_GetLocalAnchorA(_self: b2WheelJointHandle): Pb2Vec2; cdecl; external LIB_NAME name _PU + 'b2WheelJoint_GetLocalAnchorA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WheelJointWrapper.GetLocalAnchorA: Pb2Vec2; cdecl; begin Result := b2WheelJoint_GetLocalAnchorA(FHandle) end; function b2WheelJoint_GetLocalAnchorB(_self: b2WheelJointHandle): Pb2Vec2; cdecl; external LIB_NAME name _PU + 'b2WheelJoint_GetLocalAnchorB' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WheelJointWrapper.GetLocalAnchorB: Pb2Vec2; cdecl; begin Result := b2WheelJoint_GetLocalAnchorB(FHandle) end; function b2WheelJoint_GetLocalAxisA(_self: b2WheelJointHandle): Pb2Vec2; cdecl; external LIB_NAME name _PU + 'b2WheelJoint_GetLocalAxisA' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WheelJointWrapper.GetLocalAxisA: Pb2Vec2; cdecl; begin Result := b2WheelJoint_GetLocalAxisA(FHandle) end; function b2WheelJoint_GetJointTranslation(_self: b2WheelJointHandle): Single; cdecl; external LIB_NAME name _PU + 'b2WheelJoint_GetJointTranslation' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WheelJointWrapper.GetJointTranslation: Single; cdecl; begin Result := b2WheelJoint_GetJointTranslation(FHandle) end; function b2WheelJoint_GetJointSpeed(_self: b2WheelJointHandle): Single; cdecl; external LIB_NAME name _PU + 'b2WheelJoint_GetJointSpeed' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WheelJointWrapper.GetJointSpeed: Single; cdecl; begin Result := b2WheelJoint_GetJointSpeed(FHandle) end; function b2WheelJoint_IsMotorEnabled(_self: b2WheelJointHandle): Boolean; cdecl; external LIB_NAME name _PU + 'b2WheelJoint_IsMotorEnabled' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WheelJointWrapper.IsMotorEnabled: Boolean; cdecl; begin Result := b2WheelJoint_IsMotorEnabled(FHandle) end; procedure b2WheelJoint_EnableMotor(_self: b2WheelJointHandle; flag: Boolean); cdecl; external LIB_NAME name _PU + 'b2WheelJoint_EnableMotor' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2WheelJointWrapper.EnableMotor(flag: Boolean); cdecl; begin b2WheelJoint_EnableMotor(FHandle, flag) end; procedure b2WheelJoint_SetMotorSpeed(_self: b2WheelJointHandle; speed: Single); cdecl; external LIB_NAME name _PU + 'b2WheelJoint_SetMotorSpeed' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2WheelJointWrapper.SetMotorSpeed(speed: Single); cdecl; begin b2WheelJoint_SetMotorSpeed(FHandle, speed) end; function b2WheelJoint_GetMotorSpeed(_self: b2WheelJointHandle): Single; cdecl; external LIB_NAME name _PU + 'b2WheelJoint_GetMotorSpeed' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WheelJointWrapper.GetMotorSpeed: Single; cdecl; begin Result := b2WheelJoint_GetMotorSpeed(FHandle) end; procedure b2WheelJoint_SetMaxMotorTorque(_self: b2WheelJointHandle; torque: Single); cdecl; external LIB_NAME name _PU + 'b2WheelJoint_SetMaxMotorTorque' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2WheelJointWrapper.SetMaxMotorTorque(torque: Single); cdecl; begin b2WheelJoint_SetMaxMotorTorque(FHandle, torque) end; function b2WheelJoint_GetMaxMotorTorque(_self: b2WheelJointHandle): Single; cdecl; external LIB_NAME name _PU + 'b2WheelJoint_GetMaxMotorTorque' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WheelJointWrapper.GetMaxMotorTorque: Single; cdecl; begin Result := b2WheelJoint_GetMaxMotorTorque(FHandle) end; function b2WheelJoint_GetMotorTorque(_self: b2WheelJointHandle; inv_dt: Single): Single; cdecl; external LIB_NAME name _PU + 'b2WheelJoint_GetMotorTorque' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WheelJointWrapper.GetMotorTorque(inv_dt: Single): Single; cdecl; begin Result := b2WheelJoint_GetMotorTorque(FHandle, inv_dt) end; procedure b2WheelJoint_SetSpringFrequencyHz(_self: b2WheelJointHandle; hz: Single); cdecl; external LIB_NAME name _PU + 'b2WheelJoint_SetSpringFrequencyHz' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2WheelJointWrapper.SetSpringFrequencyHz(hz: Single); cdecl; begin b2WheelJoint_SetSpringFrequencyHz(FHandle, hz) end; function b2WheelJoint_GetSpringFrequencyHz(_self: b2WheelJointHandle): Single; cdecl; external LIB_NAME name _PU + 'b2WheelJoint_GetSpringFrequencyHz' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WheelJointWrapper.GetSpringFrequencyHz: Single; cdecl; begin Result := b2WheelJoint_GetSpringFrequencyHz(FHandle) end; procedure b2WheelJoint_SetSpringDampingRatio(_self: b2WheelJointHandle; ratio: Single); cdecl; external LIB_NAME name _PU + 'b2WheelJoint_SetSpringDampingRatio' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; procedure b2WheelJointWrapper.SetSpringDampingRatio(ratio: Single); cdecl; begin b2WheelJoint_SetSpringDampingRatio(FHandle, ratio) end; function b2WheelJoint_GetSpringDampingRatio(_self: b2WheelJointHandle): Single; cdecl; external LIB_NAME name _PU + 'b2WheelJoint_GetSpringDampingRatio' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2WheelJointWrapper.GetSpringDampingRatio: Single; cdecl; begin Result := b2WheelJoint_GetSpringDampingRatio(FHandle) end; function b2MixFriction(friction1: Single; friction2: Single): Single; cdecl; external LIB_NAME name _PU + 'Dynamics_b2MixFriction' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; function b2MixRestitution(restitution1: Single; restitution2: Single): Single; cdecl; external LIB_NAME name _PU + 'Dynamics_b2MixRestitution' {$IF DEFINED(ANDROID)} dependency 'gnustl_static' {$ELSEIF DEFINED(IOS)} {$ENDIF}; initialization {$IF defined(CPUX64)} Assert(Sizeof(b2BodyDef) = 64, 'Size mismatch in b2BodyDef'); Assert(Sizeof(b2ContactEdge) = 32, 'Size mismatch in b2ContactEdge'); Assert(Sizeof(b2ContactRegister) = 24, 'Size mismatch in b2ContactRegister'); Assert(Sizeof(b2ContactSolverDef) = 64, 'Size mismatch in b2ContactSolverDef'); Assert(Sizeof(b2DistanceJointDef) = 72, 'Size mismatch in b2DistanceJointDef'); Assert(Sizeof(b2Fixture) = 72, 'Size mismatch in b2Fixture'); Assert(Sizeof(b2FixtureDef) = 40, 'Size mismatch in b2FixtureDef'); Assert(Sizeof(b2FixtureProxy) = 32, 'Size mismatch in b2FixtureProxy'); Assert(Sizeof(b2FrictionJointDef) = 64, 'Size mismatch in b2FrictionJointDef'); Assert(Sizeof(b2GearJointDef) = 64, 'Size mismatch in b2GearJointDef'); Assert(Sizeof(b2JointDef) = 40, 'Size mismatch in b2JointDef'); Assert(Sizeof(b2JointEdge) = 32, 'Size mismatch in b2JointEdge'); Assert(Sizeof(b2MotorJointDef) = 64, 'Size mismatch in b2MotorJointDef'); Assert(Sizeof(b2MouseJointDef) = 64, 'Size mismatch in b2MouseJointDef'); Assert(Sizeof(b2PrismaticJointDef) = 96, 'Size mismatch in b2PrismaticJointDef'); Assert(Sizeof(b2PulleyJointDef) = 88, 'Size mismatch in b2PulleyJointDef'); Assert(Sizeof(b2RevoluteJointDef) = 88, 'Size mismatch in b2RevoluteJointDef'); Assert(Sizeof(b2RopeJointDef) = 64, 'Size mismatch in b2RopeJointDef'); Assert(Sizeof(b2SolverData) = 40, 'Size mismatch in b2SolverData'); Assert(Sizeof(b2WeldJointDef) = 72, 'Size mismatch in b2WeldJointDef'); Assert(Sizeof(b2WheelJointDef) = 88, 'Size mismatch in b2WheelJointDef'); {$ELSE} Assert(Sizeof(b2BodyDef) = 52, 'Size mismatch in b2BodyDef'); Assert(Sizeof(b2ContactEdge) = 16, 'Size mismatch in b2ContactEdge'); Assert(Sizeof(b2ContactRegister) = 12, 'Size mismatch in b2ContactRegister'); Assert(Sizeof(b2ContactSolverDef) = 44, 'Size mismatch in b2ContactSolverDef'); Assert(Sizeof(b2DistanceJointDef) = 48, 'Size mismatch in b2DistanceJointDef'); Assert(Sizeof(b2Fixture) = 44, 'Size mismatch in b2Fixture'); Assert(Sizeof(b2FixtureDef) = 28, 'Size mismatch in b2FixtureDef'); Assert(Sizeof(b2FixtureProxy) = 28, 'Size mismatch in b2FixtureProxy'); Assert(Sizeof(b2FrictionJointDef) = 44, 'Size mismatch in b2FrictionJointDef'); Assert(Sizeof(b2GearJointDef) = 32, 'Size mismatch in b2GearJointDef'); Assert(Sizeof(b2JointDef) = 20, 'Size mismatch in b2JointDef'); Assert(Sizeof(b2JointEdge) = 16, 'Size mismatch in b2JointEdge'); Assert(Sizeof(b2MotorJointDef) = 44, 'Size mismatch in b2MotorJointDef'); Assert(Sizeof(b2MouseJointDef) = 40, 'Size mismatch in b2MouseJointDef'); Assert(Sizeof(b2PrismaticJointDef) = 72, 'Size mismatch in b2PrismaticJointDef'); Assert(Sizeof(b2PulleyJointDef) = 64, 'Size mismatch in b2PulleyJointDef'); Assert(Sizeof(b2RevoluteJointDef) = 64, 'Size mismatch in b2RevoluteJointDef'); Assert(Sizeof(b2RopeJointDef) = 40, 'Size mismatch in b2RopeJointDef'); Assert(Sizeof(b2SolverData) = 32, 'Size mismatch in b2SolverData'); Assert(Sizeof(b2WeldJointDef) = 48, 'Size mismatch in b2WeldJointDef'); Assert(Sizeof(b2WheelJointDef) = 64, 'Size mismatch in b2WheelJointDef'); {$ENDIF} Assert(Sizeof(b2ContactImpulse) = 20, 'Size mismatch in b2ContactImpulse'); Assert(Sizeof(b2ContactVelocityConstraint) = 156, 'Size mismatch in b2ContactVelocityConstraint'); Assert(Sizeof(b2Filter) = 6, 'Size mismatch in b2Filter'); Assert(Sizeof(b2Jacobian) = 16, 'Size mismatch in b2Jacobian'); Assert(Sizeof(b2Position) = 12, 'Size mismatch in b2Position'); Assert(Sizeof(b2Profile) = 32, 'Size mismatch in b2Profile'); Assert(Sizeof(b2TimeStep) = 24, 'Size mismatch in b2TimeStep'); Assert(Sizeof(b2Velocity) = 12, 'Size mismatch in b2Velocity'); Assert(Sizeof(b2VelocityConstraintPoint) = 36, 'Size mismatch in b2VelocityConstraintPoint'); end.
unit uSetting; {$mode objfpc}{$H+} interface uses Classes, SysUtils; type { ISetting } ISetting = interface ['{0EA92F37-F025-4F19-B1F5-4EB64DF4E8C8}'] function GetBackupTimeout: dword; function GetDeveloperImage: String; function GetDeveloperLibrary: String; function GetKeepAliveTimeout: dword; function GetKeepAliveAddress: Byte; function GetLastLink: string; function GetRepeats: Byte; function GetResponseTimeout: dword; function GetTimeout: dword; function GetUserImage: String; function GetUserLibrary: String; procedure SetBackupTimeout(const aBackupTimeout: dword); procedure SetDeveloperImage(const aDeveloperImage: String); procedure SetDeveloperLibrary(const aDeveloperLibrary: String); procedure SetKeepAliveAddress(const aKeepAliveAddress: Byte); procedure SetKeepAliveTimeout(const aKeepAliveTimeout: dword); procedure SetLastLink(AValue: string); procedure SetRepeats(const aRepeats: Byte); procedure SetResponseTimeout(const aResponseTimeout: dword); procedure SetTimeout(const aTimeout: dword); procedure SetUserImage(const aUserImage: String); procedure SetUserLibrary(const aUserLibrary: String); function GetBaudRate: dword; procedure SetBaudRate(const aBaudRate: dword); function GetParity: Byte; procedure SetParity(const aParity: Byte); function GetByteSize: Byte; procedure SetByteSize(const aByteSize: Byte); function GetStopBits: Byte; procedure SetStopBits(const aStopBits: Byte); function GetThreeAndHalf: Byte; procedure SetThreeAndHalf(const aThreeAndHalf: Byte); // Ip function GetIp: String; procedure SetIp(const aIp: String); // Порт function GetPort: Word; procedure SetPort(const aPort: Word); function GetServerPort: Word; procedure SetServerPort(const aPort: Word); function GetUpdateEveryStart: Boolean; function GetUpdateEveryWeek: Boolean; procedure SetUpdateEveryWeek(AValue: Boolean); procedure SetUpdateEveryStart(AValue: Boolean); property BaudRate: dword read GetBaudRate write SetBaudRate; property ByteSize: Byte read GetByteSize write SetByteSize; property Parity: Byte read GetParity write SetParity; property StopBits: Byte read GetStopBits write SetStopBits; property ThreeAndHalf: Byte read GetThreeAndHalf write SetThreeAndHalf; property Ip: String read GetIp write SetIp; property Port: Word read GetPort write SetPort; property ServerPort: Word read GetServerPort write SetServerPort; property KeepAliveAddress: Byte read GetKeepAliveAddress write SetKeepAliveAddress; property KeepAliveTimeout: dword read GetKeepAliveTimeout write SetKeepAliveTimeout; property Timeout: dword read GetTimeout write SetTimeout; property ResponseTimeout: dword read GetResponseTimeout write SetResponseTimeout; property BackupTimeout: dword read GetBackupTimeout write SetBackupTimeout; property Repeats: Byte read GetRepeats write SetRepeats; property DeveloperLibrary: String read GetDeveloperLibrary write SetDeveloperLibrary; property DeveloperImage: String read GetDeveloperImage write SetDeveloperImage; property UserLibrary: String read GetUserLibrary write SetUserLibrary; property UserImage: String read GetUserImage write SetUserImage; property UpdateEveryStart: Boolean read GetUpdateEveryStart write SetUpdateEveryStart; property UpdateEveryWeek: Boolean read GetUpdateEveryWeek write SetUpdateEveryWeek; function GetUserData: string; property UserData: string read GetUserData; property LastLink: string read GetLastLink write SetLastLink; end; function GetSetting(const aFileName: string = ''): ISetting; external 'setting.dll'; function GetRegSetting: ISetting; external 'setting.dll'; implementation end.
unit DW.Base64.Helpers; {*******************************************************} { } { Kastri Free } { } { DelphiWorlds Cross-Platform Library } { } {*******************************************************} {$I DW.GlobalDefines.inc} interface uses // RTL System.Classes; type TBase64Helper = record public class function CompressEncode(const ASource: string): string; overload; static; class function CompressEncode(const AStream: TStream): string; overload; static; class function DecodeDecompress(const ASource: string): string; overload; static; class procedure DecodeDecompress(const ASource: string; const AStream: TStream); overload; static; end; implementation uses // RTL System.SysUtils, System.ZLib, System.NetEncoding; { TBase64Helper } class function TBase64Helper.CompressEncode(const ASource: string): string; var LStream: TStream; begin LStream := TStringStream.Create(ASource); try Result := CompressEncode(LStream); finally LStream.Free; end; end; class function TBase64Helper.CompressEncode(const AStream: TStream): string; var LCompressedStream: TStream; LBase64Stream: TStringStream; begin AStream.Position := 0; LCompressedStream := TMemoryStream.Create; try ZCompressStream(AStream, LCompressedStream); LCompressedStream.Position := 0; LBase64Stream := TStringStream.Create('', TEncoding.ASCII); try TNetEncoding.Base64.Encode(LCompressedStream, LBase64Stream); Result := LBase64Stream.DataString; finally LBase64Stream.Free; end; finally LCompressedStream.Free; end; end; class function TBase64Helper.DecodeDecompress(const ASource: string): string; var LStringStream: TStringStream; begin LStringStream := TStringStream.Create; try DecodeDecompress(ASource, LStringStream); Result := LStringStream.DataString; finally LStringStream.Free; end; end; class procedure TBase64Helper.DecodeDecompress(const ASource: string; const AStream: TStream); var LCompressedStream: TStream; LBase64Stream: TStream; begin AStream.Position := 0; LCompressedStream := TMemoryStream.Create; try LBase64Stream := TStringStream.Create(ASource, TEncoding.ASCII); try TNetEncoding.Base64.Decode(LBase64Stream, LCompressedStream); LCompressedStream.Position := 0; ZDecompressStream(LCompressedStream, AStream); finally LBase64Stream.Free; end; finally LCompressedStream.Free; end; end; end.
unit uVersaoSO; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Registry; type TForm1 = class(TForm) Button2: TButton; Label1: TLabel; function GetOSVersion(var MajorVersion, MinorVersion, Build: DWORD) : String; function ObterVersaoWindows : String; function IsWindows64: Boolean; procedure Button2Click(Sender: TObject); procedure FormShow(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} function TForm1.GetOSVersion(var MajorVersion, MinorVersion, Build: DWORD): String; var VersionInfo: TOSVersionInfo; vPlatform: string; begin VersionInfo.dwOSVersionInfoSize := SizeOf(VersionInfo); GetVersionEx(VersionInfo); with VersionInfo do begin case dwPlatformId of VER_PLATFORM_WIN32s: vPlatform := 'Windows 3x'; VER_PLATFORM_WIN32_WINDOWS: vPlatform := 'Windows 95'; VER_PLATFORM_WIN32_NT: vPlatform := 'Windows NT'; // 2000, XP, Vista, 7, 8, 8.1 end; MajorVersion := dwMajorVersion; MinorVersion := dwMinorVersion; Build := dwBuildNumber; Result := vPlatform; end; end; function TForm1.ObterVersaoWindows: String; var vNome, vVersao, vCurrentBuild, VBits: String; Reg: TRegistry; begin Reg := TRegistry.Create; //Criando um Registro na Memória Reg.Access := KEY_READ; //Colocando nosso Registro em modo Leitura Reg.RootKey := HKEY_LOCAL_MACHINE; //Definindo a Raiz //Abrindo a chave desejada Reg.OpenKey('\SOFTWARE\Microsoft\Windows NT\CurrentVersion\', true); //Obtendo os Parâmetros desejados vNome := Reg.ReadString('ProductName'); vVersao := Reg.ReadString('CurrentVersion'); vCurrentBuild := Reg.ReadString('CurrentBuild'); if IsWindows64 = true then begin //Montando uma String com a Versão e alguns detalhes // Result := vNome + ' - ' + vVersao + ' - ' + vCurrentBuild; // showmessage('O sistema windows é 64 Bits') Result := vNome + ' - ' + vVersao + ' - 64 Bits' end else begin //Montando uma String com a Versão e alguns detalhes //Result := vNome + ' - ' + vVersao + ' - ' + vCurrentBuild; //showmessage('O sistema windows é 32 Bits'); Result := vNome + ' - ' + vVersao + ' - 32 Bits' end; end; procedure TForm1.Button2Click(Sender: TObject); begin ShowMessage(ObterVersaoWindows); end; function TForm1.IsWindows64: Boolean; type TIsWow64Process = function(AHandle:THandle; var AIsWow64: BOOL): BOOL; stdcall; var vKernel32Handle: DWORD; vIsWow64Process: TIsWow64Process; vIsWow64: BOOL; begin Result := False; vKernel32Handle := LoadLibrary('kernel32.dll'); if (vKernel32Handle = 0) then Exit; try @vIsWow64Process := GetProcAddress(vKernel32Handle, 'IsWow64Process'); if not Assigned(vIsWow64Process) then Exit; vIsWow64 := False; if (vIsWow64Process(GetCurrentProcess, vIsWow64)) then Result := vIsWow64; finally FreeLibrary(vKernel32Handle); end; end; procedure TForm1.FormShow(Sender: TObject); begin Label1.Caption := ObterVersaoWindows; end; end.
unit uMain; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Menus, uAbastecimento, uBomba, uEmpresaDao, uGlobal, Vcl.StdCtrls, uRelAbastecimentos; type TfMain = class(TForm) MainMenu1: TMainMenu; Cadastro1: TMenuItem; Sair1: TMenuItem; anque1: TMenuItem; Bomba1: TMenuItem; Relatrio1: TMenuItem; Relatriodeabastecimento1: TMenuItem; Vendas1: TMenuItem; Abastecimentos1: TMenuItem; Label1: TLabel; Label2: TLabel; lblRazao: TLabel; lblFantasia: TLabel; Label3: TLabel; lblImposto: TLabel; procedure anque1Click(Sender: TObject); procedure Sair1Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure Abastecimentos1Click(Sender: TObject); procedure Bomba1Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure Relatriodeabastecimento1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var fMain: TfMain; implementation {$R *.dfm} uses uLib, uTanque, ClasseEmpresa; procedure TfMain.Abastecimentos1Click(Sender: TObject); begin Application.CreateForm(tfAbastecimento, fAbastecimento); fAbastecimento.showmodal; end; procedure TfMain.anque1Click(Sender: TObject); begin MostrarForm(tfTanque,fTanque); end; procedure TfMain.Bomba1Click(Sender: TObject); begin MostrarForm(tfBomba,fBomba); end; procedure TfMain.FormClose(Sender: TObject; var Action: TCloseAction); begin freeAndNil(objEmpresa); end; procedure TfMain.FormCreate(Sender: TObject); var objDao : TEmpresaDao; begin if not ConectaBanco then begin if Pergunta('Não foi possível conectar ao banco!'+sLineBreak+'Encerrar aplicação ? ','Atenção') then Application.Terminate; end; try objDao := TEmpresaDao.create; objEmpresa := TEmpresa.create; objEmpresa.idEmpresa := 1; objDao.getById(objEmpresa); lblRazao.caption := objEmpresa.razaosocial; lblFantasia.caption := objEmpresa.nomeempresa; lblImposto.caption := floattostr(objEmpresa.porcentagemImposto); finally freeAndNil(objDao); end; end; procedure TfMain.Relatriodeabastecimento1Click(Sender: TObject); begin application.CreateForm(TfRelAbastecimentos, fRelAbastecimentos); fRelAbastecimentos.ShowModal; end; procedure TfMain.Sair1Click(Sender: TObject); begin if Pergunta('Deseja finalizar o sistema?','Atenção.') then Application.Terminate end; end.
unit mbDi01; { ULMBDI01.DPR ================================================================ File: mbDI01.PAS Library Call Demonstrated: cbDIn() for MetraByte cards Purpose: Reads a byte from a digital input port. Demonstration: Configures FIRSTPORTA for input and reads the value on the port. Other Library Calls: cbErrHandling() Special Requirements: Board 1 must have a digital input port. (c) Copyright 1995 - 2002, Measurement Computing Corp. All rights reserved. =========================================================================== } interface uses SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, cbw; type TfrmDIO = class(TForm) tmrDIn: TTimer; cmdStart: TButton; cmdQuit: TButton; MemoData: TMemo; EditBoardNum: TEdit; LabelBoardNum: TLabel; procedure tmrDInTimer(Sender: TObject); procedure cmdStartClick(Sender: TObject); procedure cmdQuitClick(Sender: TObject); procedure FormCreate(Sender: TObject); procedure EditBoardNumChange(Sender: TObject); private { Private declarations } public { Public declarations } end; var frmDIO: TfrmDIO; implementation {$R *.DFM} var BoardNum : Integer = 1; ULStat: Integer; DataValue: Word; BitValue: Integer; PowerVal: Integer; PortNum: Integer; ErrReporting: Integer; ErrHandling: Integer; ValString: String; Result: Integer; RevLevel: Single; const Zero: Integer = 0; One: Integer = 1; procedure TfrmDIO.FormCreate(Sender: TObject); begin {declare Revision Level} RevLevel := CURRENTREVNUM; ULStat := cbDeclareRevision(RevLevel); { set up internal error handling for the Universal Library } ErrReporting := PRINTALL; {set Universal Library to print all errors} ErrHandling := STOPALL; {set Universal Library to stop on errors} ULStat := cbErrHandling(ErrReporting, ErrHandling); MemoData.Text := 'Click Start to read digital inputs...'; PortNum:=FIRSTPORTA; end; procedure TfrmDIO.cmdStartClick(Sender: TObject); begin tmrDIn.Enabled := True; end; procedure TfrmDIO.tmrDInTimer(Sender: TObject); var I : integer; begin { read the 7 bits digital input and display Parameters: BoardNum :the number used by CB.CFG to describe this board PortNum :the input port DataValue :the value read from the port } ULStat := cbDIn (BoardNum, PortNum, DataValue); If ULStat <> 0 then exit; { display the value collected from the port } MemoData.Text := Format('The byte value at FIRSTPORTA is %d', [DataValue]); MemoData.Lines.Add (' '); { parse DataValue into bit values to indicate on/off status } ValString := ' '; MemoData.Lines.Add ('Bit status is:'); MemoData.Lines.Add (' 7 6 5 4 3 2 1 0'); for I := 0 to 7 do begin BitValue := Zero; PowerVal := 1 shl (I); Result := DataValue and PowerVal; if Result <> 0 then begin BitValue := One; end; ValString := ' ' + (IntToStr(BitValue)) + ValString; end; MemoData.Lines.Add (ValString); end; procedure TfrmDIO.cmdQuitClick(Sender: TObject); begin tmrDIn.Enabled := False; Close; end; procedure TfrmDIO.EditBoardNumChange(Sender: TObject); var i : integer; begin i:=StrToInt(EditBoardNum.Text); if (i<1) or (i>15) then EditBoardNum.Text:='1'; BoardNum:=StrToInt(EditBoardNum.Text); end; end.
// ============================================================================= // Module name : $RCSfile: TextMessage.pas,v $ // description : This unit implements a methodes and properties of a class for // text message. // Compiler : Delphi 2007 // Author : 2015-11-20 /bsu/ // History : //============================================================================== unit TextMessage; {$M+} interface uses Classes; type //define message level EMessageLevel = ( ML_EVER, //forced information ML_INFO, //general information ML_WARNING, //warning message ML_ERROR, //error message ML_FATAL //fatal message ); TTextMessenger = class(TInterfacedObject) protected t_msgintern: TStrings; //saves messages. it is created in constructor t_msgextern: TStrings; //default pointing to t_msgintern, but it will be replaced by SetMessages e_threshold: EMessageLevel; //indicates threshold of message level. The message which has greater level than this value, can be appended to t_msg b_tstamp: boolean; //indicats, whether the time stamp should be prepended, default true protected procedure SetMessages(const msgs: TStrings); function GetLines(): integer; function GetLineText(idx: integer): string; function FormatMsg(const text: string; const sender: string; const level: EMessageLevel; var msg: string): boolean; public constructor Create(); destructor Destroy(); override; property Messages: TStrings read t_msgextern write SetMessages; property MessageThreshold: EMessageLevel read e_threshold write e_threshold; property TimeStamp: boolean read b_tstamp write b_tstamp; property CountLines: integer read GetLines; property LineText[idx: integer]: string read GetLineText; procedure AddMessage(const text: string; const sender: string = ''; const level: EMessageLevel = ML_INFO); procedure AddEmptyLine(); procedure UpdateMessage(const text: string; const sender: string = ''; const level: EMessageLevel = ML_INFO); procedure ExportMessages(const fname: string); procedure Clear(const bextern: boolean = false); end; ITextMessengerImpl = interface function GetMessenger(): TTextMessenger; procedure SetMessenger(tmessenger: TTextMessenger); procedure AddMessage(const text: string; const level: EMessageLevel = ML_INFO); procedure AddEmptyLine(); procedure UpdateMessage(const text: string; const level: EMessageLevel = ML_INFO); procedure SetMessageThreshold(const msglevel: EMessageLevel); property Messenger: TTextMessenger read GetMessenger write SetMessenger; end; TTextMessengerImpl = class(TInterfacedObject, ITextMessengerImpl) protected t_messenger: TTextMessenger; s_ownername: string; public constructor Create(const oname: string); overload; function GetMessenger(): TTextMessenger; procedure SetMessenger(tmessenger: TTextMessenger); procedure AddMessage(const text: string; const level: EMessageLevel = ML_INFO); procedure AddEmptyLine(); procedure UpdateMessage(const text: string; const level: EMessageLevel = ML_INFO); procedure SetMessageThreshold(const msglevel: EMessageLevel); property Messenger: TTextMessenger read GetMessenger write SetMessenger; property OwnerName: string read s_ownername write s_ownername; end; implementation uses SysUtils; //define constant strings for EMessageLevel const CSTR_MLKEYS: array[EMessageLevel] of string = ( 'info', 'info', 'warning', 'error', 'fatal' ); constructor TTextMessenger.Create(); begin inherited Create(); t_msgintern := TStringList.Create; t_msgextern := t_msgintern; e_threshold := ML_INFO; b_tstamp := true; end; destructor TTextMessenger.Destroy(); begin t_msgintern.Clear; t_msgintern.Free; inherited Destroy; end; procedure TTextMessenger.AddMessage(const text: string; const sender: string; const level: EMessageLevel); var s_msg: string; begin if (FormatMsg(text, sender, level, s_msg)) then begin t_msgintern.Add(s_msg); if (t_msgextern <> t_msgintern) then t_msgextern.Add(s_msg); end; end; procedure TTextMessenger.AddEmptyLine(); begin t_msgintern.Add(''); if (t_msgextern <> t_msgintern) then t_msgextern.Add(''); end; procedure TTextMessenger.UpdateMessage(const text: string; const sender: string; const level: EMessageLevel); var s_msg: string; begin if (FormatMsg(text, sender, level, s_msg)) then begin if (t_msgintern.Count > 0) then begin t_msgintern[t_msgintern.Count - 1] := s_msg; if ((t_msgextern <> t_msgintern) and (t_msgextern.Count > 0)) then t_msgextern[t_msgextern.Count - 1] := s_msg; end else begin t_msgintern.Add(s_msg); if (t_msgextern <> t_msgintern) then t_msgextern.Add(s_msg); end; end; end; procedure TTextMessenger.ExportMessages(const fname: string); begin t_msgintern.SaveToFile(fname); end; procedure TTextMessenger.Clear(const bextern: boolean); begin t_msgintern.Clear(); if (bextern) then t_msgextern.Clear(); end; procedure TTextMessenger.SetMessages(const msgs: TStrings); begin if assigned(msgs) then t_msgextern := msgs else t_msgextern := t_msgintern; end; function TTextMessenger.GetLines(): integer; begin result := t_msgintern.Count; end; function TTextMessenger.GetLineText(idx: integer): string; begin result := ''; if ((idx >= 0) and (idx < t_msgintern.Count)) then result := t_msgintern[idx]; end; function TTextMessenger.FormatMsg(const text: string; const sender: string; const level: EMessageLevel; var msg: string): boolean; begin if ((level >= e_threshold) or (level = ML_EVER)) then begin result := true; if (sender <> '' ) then msg := '[' + sender + ']' + text else msg := text; msg := '[' + CSTR_MLKEYS[level] + ']' + msg; if b_tstamp then msg := '[' + FormatDateTime('hh:nn:ss.zzz', Time()) + ']: ' + msg; end else result := false; end; constructor TTextMessengerImpl.Create(const oname: string); begin inherited Create(); s_ownername := oname; end; function TTextMessengerImpl.GetMessenger(): TTextMessenger; begin result := t_messenger; end; procedure TTextMessengerImpl.SetMessenger(tmessenger: TTextMessenger); begin t_messenger := tmessenger; end; // ============================================================================= // Description : append a new message in t_messenger // Parameter : text, text of the message to update // level, message level, see the definition of EMessageLevel // Exceptions : -- // First author : 2016-08-26 /bsu/ // History : // ============================================================================= procedure TTextMessengerImpl.AddMessage(const text: string; const level: EMessageLevel); begin if assigned(t_messenger) then begin t_messenger.AddMessage(format('%s', [text]), s_ownername, level); end; end; procedure TTextMessengerImpl.AddEmptyLine(); begin if assigned(t_messenger) then t_messenger.AddEmptyLine(); end; // ============================================================================= // Description : update the text of last message, which is appended through // function AddMessage // Parameter : text, text of the message to update // Exceptions : -- // First author : 2016-06-15 /bsu/ // History : // ============================================================================= procedure TTextMessengerImpl.UpdateMessage(const text: string; const level: EMessageLevel); begin if assigned(t_messenger) then begin t_messenger.UpdateMessage(format('%s', [text]), s_ownername, level); end; end; procedure TTextMessengerImpl.SetMessageThreshold(const msglevel: EMessageLevel); begin if assigned(t_messenger) then t_messenger.MessageThreshold := msglevel; end; end.
{******************************************************************************} { } { Indy (Internet Direct) - Internet Protocols Simplified } { } { https://www.indyproject.org/ } { https://gitter.im/IndySockets/Indy } { } {******************************************************************************} { } { This file is part of the Indy (Internet Direct) project, and is offered } { under the dual-licensing agreement described on the Indy website. } { (https://www.indyproject.org/license/) } { } { Copyright: } { (c) 1993-2020, Chad Z. Hower and the Indy Pit Crew. All rights reserved. } { } {******************************************************************************} { } { Originally written by: Fabian S. Biehn } { fbiehn@aagon.com (German & English) } { } { Contributers: } { Here could be your name } { } {******************************************************************************} unit IdOpenSSLSocketServer; interface {$i IdCompilerDefines.inc} uses IdOpenSSLSocket, IdStackConsts; type TIdOpenSSLSocketServer = class(TIdOpenSSLSocket) public function Accept( const AHandle: TIdStackSocketHandle): Boolean; end; implementation uses IdOpenSSLExceptionResourcestrings, IdOpenSSLExceptions, IdOpenSSLHeaders_ssl, IdCTypes; { TIdOpenSSLSocketServer } function TIdOpenSSLSocketServer.Accept( const AHandle: TIdStackSocketHandle): Boolean; var LReturnCode: TIdC_INT; LShouldRetry: Boolean; begin FSSL := StartSSL(FContext); SSL_set_fd(FSSL, AHandle); repeat LReturnCode := SSL_accept(FSSL); Result := LReturnCode = 1; LShouldRetry := ShouldRetry(FSSL, LReturnCode); if not LShouldRetry and (LReturnCode < 0) then raise EIdOpenSSLAcceptError.Create(FSSL, LReturnCode, ''); until not LShouldRetry; end; end.
unit DSharp.Core.Events.Tests; interface implementation uses Classes, DSharp.Core.Events, Generics.Collections, TestFramework; type TRecord = record a, b, c, d, e: Integer; end; TKeyEvent = procedure(const AInterface: IInterface; var AKey: Word; var AKeyChar: WideChar; AShift: TShiftState) of object; {$M+} TProc = reference to procedure; TProcInt64 = reference to procedure(const AValue: Int64); TProcNotifyEvent = reference to procedure(const AValue: TNotifyEvent); TProcRecordInt = reference to procedure(AValue: TRecord; i: Integer); TNotifyProc = reference to procedure(Sender: TObject); {$M-} TNotifyProcEvent = class(TEventBase<TNotifyProc>) procedure InternalInvoke(Sender: TObject); procedure InitInvoke; override; end; TEventTestCase = class(TTestCase) private FEventCalled: Boolean; FKeyEvent: Event<TKeyEvent>; FProc1, FProc2: Event<TProc>; FProcInt64: Event<TProcInt64>; FProcNotifyEvent: Event<TProcNotifyEvent>; FProcRecordInt: Event<TProcRecordInt>; FNotifyEvent: TEvent<TNotifyEvent>; procedure TestKeyEvent(const AInterface: IInterface; var AKey: Word; var AKeyChar: WideChar; AShift: TShiftState); procedure TestProc1; procedure TestProc2; procedure TestNotifyEvent(Sender: TObject); published procedure TestSignatureWithSet; procedure TestCascadeInvoke; procedure TestConstInt64; procedure TestEventParam; procedure TestRecordParam; procedure TestDelegateMethodCompatibility; procedure TestMemoryManagement; procedure TestReferenceCounting; end; { TNotifyProcEvent } procedure TNotifyProcEvent.InternalInvoke(Sender: TObject); var i: Integer; begin for i := 0 to Count - 1 do Handler[i].Invoke(Sender); end; procedure TNotifyProcEvent.InitInvoke; begin SetInvoke(@TNotifyProcEvent.InternalInvoke); end; { TEventTestCase } procedure TEventTestCase.TestKeyEvent(const AInterface: IInterface; var AKey: Word; var AKeyChar: WideChar; AShift: TShiftState); begin FEventCalled := True; CheckTrue(AKey = 0); CheckTrue(AKeyChar = 'K'); CheckTrue(AShift = []); end; procedure TEventTestCase.TestProc1; begin FProc1.Invoke; end; procedure TEventTestCase.TestProc2; begin FEventCalled := True; end; procedure TEventTestCase.TestNotifyEvent(Sender: TObject); begin FEventCalled := Sender = Self; end; procedure TEventTestCase.TestEventParam; begin FProcNotifyEvent.Add( procedure(const AValue: TNotifyEvent) begin AValue(Self); end); FProcNotifyEvent.Invoke(TestNotifyEvent); CheckTrue(FEventCalled); end; type TTest = class procedure Handler(Sender: TObject); end; procedure TTest.Handler(Sender: TObject); begin end; procedure TEventTestCase.TestMemoryManagement; var e: IEvent<TNotifyEvent>; t: TTest; p: PByte; begin t := TTest.Create; e := TEvent<TNotifyEvent>.Create; e.Add(t.Handler); p := PByte(t); // free instance before the event its handler is attached to gets freed t.Free; // simulate memory reuse (the ugly way) p^ := 255; // at the end of the method the event gets freed and calls Notify for each attached handler // this may cause errors when that method does not check for the TMethod.Data part correctly // it needs to do so for delegate types end; procedure TEventTestCase.TestRecordParam; var r: TRecord; begin r.a := 1; r.b := 2; r.c := 3; r.d := 4; r.e := 5; FProcRecordInt.Add( procedure(AValue: TRecord; i: Integer) begin FEventCalled := (AValue.a = 1) and (AValue.b = 2) and (AValue.c = 3) and (AValue.d = 4) and (AValue.e = 5) and (i = 6); AValue.c := 7; end); FProcRecordInt.Invoke(r, 6); CheckTrue(FEventCalled); CheckEquals(r.c, 3); end; procedure TEventTestCase.TestReferenceCounting; var e: IEvent<TNotifyProc>; begin e := TNotifyProcEvent.Create; e.Add(procedure(Sender: TObject) begin FEventCalled := Sender = Self end); e.Add(procedure(Sender: TObject) begin FEventCalled := Sender = Self end); e.Invoke(Self); end; procedure TEventTestCase.TestSignatureWithSet; var Key: Word; KeyChar: WideChar; begin FKeyEvent.Add(TestKeyEvent); Key := 0; KeyChar := 'K'; FKeyEvent.Invoke(nil, Key, KeyChar, []); CheckTrue(FEventCalled); end; procedure TEventTestCase.TestCascadeInvoke; begin FProc1.Add(TestProc1); FProc2.Add(TestProc2); FProc2.Invoke(); CheckTrue(FEventCalled); end; procedure TEventTestCase.TestConstInt64; begin FProcInt64.Add( procedure(const AValue: Int64) begin FEventCalled := AValue = 1; end); FProcInt64.Invoke(1); CheckTrue(FEventCalled); end; procedure TEventTestCase.TestDelegateMethodCompatibility; begin FNotifyEvent := TEvent<TNotifyEvent>.Create; FNotifyEvent.Add<TNotifyProc>( procedure(Sender: TObject) begin FEventCalled := Sender = Self; end); FNotifyEvent.Invoke(Self); CheckTrue(FEventCalled); FNotifyEvent.Free; end; initialization RegisterTest('DSharp.Core.Events', TEventTestCase.Suite); end.
unit NetAddr; INTERFACE uses Sockets ,SysUtils ; {Redefine socaddr here, becouse original is too short for ipv6 and unix} type tSockAddrL = packed record sa_family: sa_family_t; sa_data: array [0..107] of byte; end; type tSockAddr= type tSockAddrL deprecated; TYPE {$PACKENUM 1} tFamily=(afNil=0, afInet=1, afInet6 ); { Network-byte-ordered words } Word2=array [1..2] of byte; {0..65535} Word4=array [1..4] of byte; {0..4294967295} { Object to store Socket Address } t= packed object function Length :word; { Returns length of the structure based on address family } procedure ToSocket( var sockaddr :tSockAddrL ); {$HINT Not actually testet, byt seems to work} procedure FromSocket( var sockaddr :tSockAddrL ); {$HINT Not actually testet, byt seems to work} procedure ToString( var str :String ); {$HINT Not actually testet, byt seems to work} procedure FromString( str :String ); {$HINT Not actually testet, byt seems to work} function Hash:Word; procedure LocalHost( af: tFamily ); {Generate localhost address of address family af.} {$HINT Not actually testet, byt seems to work} procedure Clear; function isNil:boolean; public data :packed record case Family : tFamily of { note: maximum family is 32 so byte is enough } afInet :( inet :packed record port: Word; addr: tInAddr; end; ); afInet6 :( inet6 :packed record port: Word; addr: tIn6Addr; end; ); afNil :( pad_pV4IlkA4mKQL :packed array [0..22] of byte; ); end; end; tNetAddr=t; {alias} function ConvertFamily( a:tFamily ): sa_family_t; operator := (net : Word2) host:word; operator := (net : Word4) host:Dword; operator := (host : word) net:Word2; operator := (host : Dword) net:Word4; Operator = (aa, ab :t) b : boolean; operator := ( at : t) aString : string; operator := ( aString : string) at : t; { Operator := (aa :t ) r : pSockAddr; Operator := ( aa :pSockAddr ) r : t; } IMPLEMENTATION Operator = (aa, ab :Sockets.tInAddr) b : boolean; begin b:=aa.s_addr=ab.s_addr; end; Operator = (aa, ab :t) b : boolean; begin b:=false; if aa.data.Family<>ab.data.Family then exit; case aa.data.Family of afInet: if (aa.data.inet.port<>ab.data.inet.port) or (aa.data.inet.addr<>ab.data.inet.addr) then exit; afNil: {null addresses are always equal}; else AbstractError; end; b:=true; end; function t.Length :Word; begin result:=(sizeof(self)-sizeof(data))+sizeof(data.Family); case data.Family of afNil: ; afInet: result+=sizeof( data.inet ); afInet6: result+=sizeof( data.inet6 ); else result:=sizeof(self); end; end; function ConvertFamily( a:tFamily ): sa_family_t; begin case a of afInet: result:=Sockets.AF_INET; afInet6: result:=Sockets.AF_INET6; else AbstractError; end; end; procedure t.ToSocket( var sockaddr :tSockAddrL ); begin case data.family of afInet: begin sockaddr.sa_family:=Sockets.AF_INET; Move(data.inet, sockaddr.sa_data, sizeof(data.inet) ); end; afInet6: begin sockaddr.sa_family:=Sockets.AF_INET6; with tInetSockAddr6(pointer(@sockaddr)^) do begin sin6_port:=data.inet6.port; sin6_flowinfo:=0; sin6_addr:=data.inet6.addr; sin6_scope_id:=0; end; end; else AbstractError; end; end; procedure t.FromSocket( var sockaddr :tSockAddrL ); begin case sockaddr.sa_family of Sockets.AF_INET: begin data.family:=afInet; move(sockaddr.sa_data, data.inet, sizeof(data.inet) ); end; Sockets.AF_INET6: begin data.family:=afInet6; move(sockaddr.sa_data, data.inet6, sizeof(data.inet6) ); end; else raise Exception.Create('Unknown AF '+IntToStr(sockaddr.sa_family)); end; end; procedure t.ToString( var str :String ); begin case data.Family of afInet: begin str:='//ip4/'+Sockets.NetAddrToStr(data.inet.addr)+ '/'+IntToStr(ShortNetToHost(data.inet.port)); end; afInet6: begin str:='//ip6/'+Sockets.NetAddrToStr6(data.inet6.addr)+ '/'+IntToStr(ShortNetToHost(data.inet6.port)); end; afNil: str:='//nil'; else str:='//nil/UnknownAddressFamily'; end; end; procedure t.FromString( str :String ); var i:integer; var fam:string; begin if System.Length(str)=0 then begin Clear; exit end; if Copy(str,1,2)<>'//' then raise eConvertError.Create(''); Delete(str,1,2); i:=pos('/',str); if i=0 then i:=System.Length(str)+1; fam:=copy(str,1,i-1); delete(str,1,i); if fam='ip4' then begin data.family:=afInet; i:=pos('/',str); if i=0 then i:=System.Length(str)+1; fam:=copy(str,1,i-1); delete(str,1,i); data.inet.addr:=StrToNetAddr(fam); i:=pos('/',str); if i=0 then i:=System.Length(str)+1; fam:=copy(str,1,i-1); delete(str,1,i); data.inet.port:=ShortHostToNet(StrToInt(fam)); end else if fam='ip6' then begin data.family:=afInet6; i:=pos('/',str); if i=0 then i:=System.Length(str)+1; fam:=copy(str,1,i-1); delete(str,1,i); data.inet6.addr:=StrToNetAddr6(fam); i:=pos('/',str); if i=0 then i:=System.Length(str)+1; fam:=copy(str,1,i-1); delete(str,1,i); data.inet6.port:=ShortHostToNet(StrToInt(fam)); end else if fam='nil' then begin data.family:=afNil; end else raise eConvertError.Create(''); end; function t.Hash:word; var h:word; var i:byte; procedure hashstep(v:byte); begin h:=((h shl 5)and $FFFF) xor ((h shr 2)and $FFFF) xor v; end; begin h:=0; assert(sizeof(data.family)=1,'simple set size'+IntToStr(sizeof(data.family))); hashstep(byte(data.family)); case data.Family of afInet: for i:=1 to 4 do HashStep(data.inet.addr.s_bytes[i]); afInet6: for i:=1 to 16 do HashStep(data.inet6.addr.u6_addr8[i]); else AbstractError; end; case data.Family of afInet,afInet6: begin HashStep(data.inet.port and $FF); HashStep((data.inet.port shr 8) and $FF); end; end; result:=h; end; const cLocalHostIP4:Sockets.tInAddr=( s_bytes:(127,0,0,1) ); const cLocalIP4Port:word=1030; procedure t.LocalHost( af: tFamily ); begin data.Family:=af; case af of afInet: begin data.inet.port:=ShortHostToNet(cLocalIP4Port); data.inet.addr:=cLocalHostIP4; end; afNil: ; else AbstractError; end; end; procedure t.Clear; begin self.data.family:=afNil; end; function t.isNil:boolean; begin isNil:= self.data.family=afNil; end; operator := ( at : t) aString : string; begin at.ToString( aString ); end; operator := ( aString : string) at : t; begin at.FromString( aString ); end; operator := (net : Word2) host:word; var pnet:^word; begin pnet:=@net; host:=ShortNetToHost( pnet^ ); end; operator := (net : Word4) host:Dword; var pnet:^DWord; begin pnet:=@net; host:=LEtoN( pnet^ ); end; operator := (host : word) net:Word2; var pnet:^Word; begin pnet:=@net; pnet^:= ShortHostToNet( host ); end; operator := (host : Dword) net:Word4; var pnet:^DWord; begin pnet:=@net; pnet^:=NtoLE( host ); end; END.
unit uMain; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls; type TfrmRTXCMakeTemplate = class(TForm) grp1: TGroupBox; lbl1: TLabel; edt_ProjectName: TEdit; btn_Make: TButton; chk_MakeActiveX: TCheckBox; procedure FormCreate(Sender: TObject); procedure btn_MakeClick(Sender: TObject); private FTemplateDir: string; procedure MakeActiveXTemplate; procedure MakePluginTemplate; public { Public declarations } end; var frmRTXCMakeTemplate: TfrmRTXCMakeTemplate; implementation {$R *.dfm} uses System.Zip; function DeleteLeftRight(const s: string): string; begin Result := s; Delete(Result, 1, 1); Delete(Result, Length(Result), 1); end; procedure TfrmRTXCMakeTemplate.btn_MakeClick(Sender: TObject); begin if Length(edt_ProjectName.Text) = 0 then begin ShowMessage('请输入一个工程名!'); Exit; end; if chk_MakeActiveX.Checked then begin FTemplateDir := ExtractFilePath(ParamStr(0)) + 'Template\' + edt_ProjectName.Text + 'Group'; if not DirectoryExists(FTemplateDir) then CreateDir(FTemplateDir); MakePluginTemplate; MakeActiveXTemplate; end else begin FTemplateDir := ExtractFilePath(ParamStr(0)) + 'Template'; MakePluginTemplate; end; end; procedure TfrmRTXCMakeTemplate.FormCreate(Sender: TObject); begin FTemplateDir := ExtractFilePath(ParamStr(0)) + 'Template'; if not DirectoryExists(FTemplateDir) then CreateDir(FTemplateDir); end; procedure TfrmRTXCMakeTemplate.MakeActiveXTemplate; var ResStream: TResourceStream; Zip: TZipFile; StrStream: TStringStream; LibGUID, InterfaceGUID, InterfaceEventsGUID, CoClassGUID: string; ProjectName, CodeStr, ProjectDir: string; Buffer: TBytes; const UTF8Data: array[0..2] of byte = ($EF, $BB, $BF); begin ProjectName := edt_ProjectName.Text; ProjectDir := FTemplateDir + PathDelim + ProjectName + 'Ocx'; if not DirectoryExists(ProjectDir) then CreateDir(ProjectDir); ResStream := TResourceStream.Create(HInstance, 'ACTIVEXTEMPLATE', 'ZIPDATA'); try Zip := TZipFile.Create; try LibGUID := TGUID.NewGuid.ToString; InterfaceGUID := TGUID.NewGuid.ToString; InterfaceEventsGUID := TGUID.NewGuid.ToString; CoClassGUID := TGUID.NewGuid.ToString; Zip.Open(ResStream, zmRead); StrStream := TStringStream.Create; try // RTXC{%PROJECTNAME%}ActiveXContainer.pas Zip.Read('RTXC{%PROJECTNAME%}ActiveXContainer.pas', Buffer); StrStream.Write(Buffer, Length(Buffer)); StrStream.Position := 0; CodeStr := StringReplace(StrStream.DataString, '<%PROJECTNAME%>', ProjectName, [rfReplaceAll]); CodeStr := StringReplace(CodeStr, '<%CURRENTDATETIME%>', FormatDateTime('yyyy/MM/dd hh:mm:ss', Now), []); StrStream.Clear; StrStream.WriteString(CodeStr); StrStream.SaveToFile(ProjectDir + PathDelim + Format('RTXC%sActiveXContainer.pas', [ProjectName])); // RTXC{%PROJECTNAME%}ActiveXContainerLib.ridl StrStream.Clear; Zip.Read('RTXC{%PROJECTNAME%}ActiveXContainerLib.ridl', Buffer); StrStream.Write(Buffer, Length(Buffer)); StrStream.Position := 0; CodeStr := StringReplace(StrStream.DataString, '<%PROJECTNAME%>', ProjectName, [rfReplaceAll]); CodeStr := StringReplace(CodeStr, '<%CURRENTDATETIME%>', FormatDateTime('yyyy/MM/dd hh:mm:ss', Now), []); CodeStr := StringReplace(CodeStr, '<%LIBRARYGUID%>', DeleteLeftRight(LibGUID), [rfReplaceAll]); CodeStr := StringReplace(CodeStr, '<%INTERFACEGUID%>', DeleteLeftRight(InterfaceGUID), [rfReplaceAll]); CodeStr := StringReplace(CodeStr, '<%INTERFACEEVENTSGUID%>', DeleteLeftRight(InterfaceEventsGUID), [rfReplaceAll]); CodeStr := StringReplace(CodeStr, '<%COCLASSGUID%>', DeleteLeftRight(CoClassGUID), [rfReplaceAll]); StrStream.Clear; StrStream.WriteString(CodeStr); StrStream.SaveToFile(ProjectDir + PathDelim + Format('RTXC%sActiveXContainerLib.ridl', [ProjectName])); // RTXC{%PROJECTNAME%}ActiveXContainerLib_TLB.pas StrStream.Clear; Zip.Read('RTXC{%PROJECTNAME%}ActiveXContainerLib_TLB.pas', Buffer); StrStream.Write(Buffer, Length(Buffer)); StrStream.Position := 0; CodeStr := StringReplace(StrStream.DataString, '<%PROJECTNAME%>', ProjectName, [rfReplaceAll]); CodeStr := StringReplace(CodeStr, '<%CURRENTDATETIME%>', FormatDateTime('yyyy/MM/dd hh:mm:ss', Now), [rfReplaceAll]); CodeStr := StringReplace(CodeStr, '<%LIBRARYGUID%>', LibGUID, [rfReplaceAll]); CodeStr := StringReplace(CodeStr, '<%INTERFACEGUID%>', InterfaceGUID, [rfReplaceAll]); CodeStr := StringReplace(CodeStr, '<%INTERFACEEVENTSGUID%>', InterfaceEventsGUID, [rfReplaceAll]); CodeStr := StringReplace(CodeStr, '<%COCLASSGUID%>', CoClassGUID, [rfReplaceAll]); StrStream.Clear; StrStream.WriteString(CodeStr); StrStream.SaveToFile(ProjectDir + PathDelim + Format('RTXC%sActiveXContainerLib_TLB.pas', [ProjectName])); // RTXC{%PROJECTNAME%}Ocx.dpr StrStream.Clear; Zip.Read('RTXC{%PROJECTNAME%}Ocx.dpr', Buffer); StrStream.Write(Buffer, Length(Buffer)); StrStream.Position := 0; CodeStr := StringReplace(StrStream.DataString, '<%PROJECTNAME%>', ProjectName, [rfReplaceAll]); StrStream.Clear; StrStream.WriteString(CodeStr); StrStream.SaveToFile(ProjectDir + PathDelim + Format('RTXC%sOcx.dpr', [ProjectName])); // RTXC{%PROJECTNAME%}Ocx.dproj StrStream.Clear; Zip.Read('RTXC{%PROJECTNAME%}Ocx.dproj', Buffer); StrStream.Write(Buffer, 3, Length(Buffer) - 3); StrStream.Position := 0; CodeStr := StringReplace(StrStream.DataString, '<%DPRGUID%>', TGuid.NewGuid.ToString, [rfReplaceAll]); CodeStr := StringReplace(CodeStr, '<%PROJECTNAME%>', ProjectName, [rfReplaceAll]); StrStream.Clear; StrStream.Write(UTF8Data, 3); StrStream.WriteString(CodeStr); StrStream.SaveToFile(ProjectDir + PathDelim + Format('RTXC%sOcx.dproj', [ProjectName])); // ReadMe.txt StrStream.Clear; Zip.Read('ReadMe.txt', Buffer); StrStream.Write(Buffer, Length(Buffer)); StrStream.Position := 0; CodeStr := StringReplace(StrStream.DataString, '<%PROJECTNAME%>', ProjectName, [rfReplaceAll]); CodeStr := StringReplace(CodeStr, '<%COCLASSGUID%>', CoClassGUID, [rfReplaceAll]); StrStream.Clear; StrStream.WriteString(CodeStr); StrStream.SaveToFile(ProjectDir + PathDelim + 'ReadMe.txt'); // ufrmMainForm.pas Zip.Extract('ufrmMainForm.pas', ProjectDir + PathDelim); // ufrmMainForm.dfm Zip.Extract('ufrmMainForm.dfm', ProjectDir + PathDelim); finally StrStream.Free; end; finally Zip.Free; end; finally ResStream.Free; end; end; procedure TfrmRTXCMakeTemplate.MakePluginTemplate; var ResStream: TResourceStream; Zip: TZipFile; StrStream: TStringStream; LibGUID, InterfaceGUID, InterfaceEventsGUID, CoClassGUID: string; ProjectName, CodeStr, ProjectDir: string; Buffer: TBytes; const UTF8Data: array[0..2] of byte = ($EF, $BB, $BF); begin ProjectName := edt_ProjectName.Text; ProjectDir := FTemplateDir + PathDelim + 'RTXC' + ProjectName; if not DirectoryExists(ProjectDir) then CreateDir(ProjectDir); ResStream := TResourceStream.Create(HInstance, 'PLUGINTEMPLATE', 'ZIPDATA'); try Zip := TZipFile.Create; try LibGUID := TGUID.NewGuid.ToString; InterfaceGUID := TGUID.NewGuid.ToString; InterfaceEventsGUID := TGUID.NewGuid.ToString; CoClassGUID := TGUID.NewGuid.ToString; Zip.Open(ResStream, zmRead); StrStream := TStringStream.Create; try // RTXC.Plugin.pas Zip.Read('RTXC.Plugin.pas', Buffer); StrStream.Write(Buffer, Length(Buffer)); StrStream.Position := 0; CodeStr := StringReplace(StrStream.DataString, '<%PROJECTNAME%>', ProjectName, [rfReplaceAll]); CodeStr := StringReplace(CodeStr, '<%CURRENTDATETIME%>', FormatDateTime('yyyy/MM/dd hh:mm:ss', Now), [rfReplaceAll]); StrStream.Clear; StrStream.WriteString(CodeStr); StrStream.SaveToFile(ProjectDir + PathDelim + 'RTXC.Plugin.pas'); // RTXC{%PROJECTNAME%}PluginLib.ridl StrStream.Clear; Zip.Read('RTXC{%PROJECTNAME%}PluginLib.ridl', Buffer); StrStream.Write(Buffer, Length(Buffer)); StrStream.Position := 0; CodeStr := StringReplace(StrStream.DataString, '<%PROJECTNAME%>', ProjectName, [rfReplaceAll]); CodeStr := StringReplace(CodeStr, '<%CURRENTDATETIME%>', FormatDateTime('yyyy/MM/dd hh:mm:ss', Now), [rfReplaceAll]); CodeStr := StringReplace(CodeStr, '<%LIBRARYGUID%>', DeleteLeftRight(LibGUID), [rfReplaceAll]); CodeStr := StringReplace(CodeStr, '<%COCLASSGUID%>', DeleteLeftRight(CoClassGUID), [rfReplaceAll]); StrStream.Clear; StrStream.WriteString(CodeStr); StrStream.SaveToFile(ProjectDir + PathDelim + Format('RTXC%sPluginLib.ridl', [ProjectName])); // RTXC{%PROJECTNAME%}PluginLib_TLB.pas StrStream.Clear; Zip.Read('RTXC{%PROJECTNAME%}PluginLib_TLB.pas', Buffer); StrStream.Write(Buffer, Length(Buffer)); StrStream.Position := 0; CodeStr := StringReplace(StrStream.DataString, '<%PROJECTNAME%>', ProjectName, [rfReplaceAll]); CodeStr := StringReplace(CodeStr, '<%CURRENTDATETIME%>', FormatDateTime('yyyy/MM/dd hh:mm:ss', Now), [rfReplaceAll]); CodeStr := StringReplace(CodeStr, '<%LIBRARYGUID%>', LibGUID, [rfReplaceAll]); CodeStr := StringReplace(CodeStr, '<%COCLASSGUID%>', CoClassGUID, [rfReplaceAll]); StrStream.Clear; StrStream.WriteString(CodeStr); StrStream.SaveToFile(ProjectDir + PathDelim + Format('RTXC%sPluginLib_TLB.pas', [ProjectName])); // RTXC{%PROJECTNAME%}.dpr StrStream.Clear; Zip.Read('RTXC{%PROJECTNAME%}.dpr', Buffer); StrStream.Write(Buffer, Length(Buffer)); StrStream.Position := 0; CodeStr := StringReplace(StrStream.DataString, '<%PROJECTNAME%>', ProjectName, [rfReplaceAll]); StrStream.Clear; StrStream.WriteString(CodeStr); StrStream.SaveToFile(ProjectDir + PathDelim + Format('RTXC%s.dpr', [ProjectName])); // RTXC{%PROJECTNAME%}.dproj StrStream.Clear; Zip.Read('RTXC{%PROJECTNAME%}.dproj', Buffer); StrStream.Write(Buffer, 3, Length(Buffer) - 3); StrStream.Position := 0; CodeStr := StringReplace(StrStream.DataString, '<%DPRGUID%>', TGuid.NewGuid.ToString, [rfReplaceAll]); CodeStr := StringReplace(CodeStr, '<%PROJECTNAME%>', ProjectName, [rfReplaceAll]); StrStream.Clear; StrStream.Write(UTF8Data, 3); StrStream.WriteString(CodeStr); StrStream.SaveToFile(ProjectDir + PathDelim + Format('RTXC%s.dproj', [ProjectName])); // ReadMe.txt StrStream.Clear; Zip.Read('ReadMe.txt', Buffer); StrStream.Write(Buffer, Length(Buffer)); StrStream.Position := 0; CodeStr := StringReplace(StrStream.DataString, '<%PROJECTNAME%>', ProjectName, [rfReplaceAll]); CodeStr := StringReplace(CodeStr, '<%COCLASSGUID%>', CoClassGUID, [rfReplaceAll]); StrStream.Clear; StrStream.WriteString(CodeStr); StrStream.SaveToFile(ProjectDir + PathDelim + 'ReadMe.txt'); finally StrStream.Free; end; finally Zip.Free; end; finally ResStream.Free; end; end; end.
unit SubstractMrpLogWin; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, CommUtils, StdCtrls, ExtCtrls, IniFiles, ComCtrls, ToolWin, ImgList, MrpLogReader2, ComObj; type TfrmSubstractMrpLog = class(TForm) leMrpLog: TLabeledEdit; btnMrpLog: TButton; ImageList1: TImageList; ToolBar1: TToolBar; ToolButton2: TToolButton; tbSave: TToolButton; ToolButton3: TToolButton; ToolButton4: TToolButton; leNumber: TLabeledEdit; procedure btnMrpLogClick(Sender: TObject); procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure ToolButton4Click(Sender: TObject); procedure tbSaveClick(Sender: TObject); private { Private declarations } procedure SaveLog(const sfile: string; lst: TList); public { Public declarations } class procedure ShowForm; end; implementation {$R *.dfm} class procedure TfrmSubstractMrpLog.ShowForm; var frmSubstractMrpLog: TfrmSubstractMrpLog; begin frmSubstractMrpLog := TfrmSubstractMrpLog.Create(nil); frmSubstractMrpLog.ShowModal; frmSubstractMrpLog.Free; end; procedure TfrmSubstractMrpLog.btnMrpLogClick(Sender: TObject); var sfile: string; begin if not ExcelOpenDialog(sfile) then Exit; leMrpLog.Text := sfile; end; procedure TfrmSubstractMrpLog.FormCreate(Sender: TObject); var ini: TIniFile; begin ini := TIniFile.Create(AppIni); try leMrpLog.Text := ini.ReadString(Self.ClassName, leMrpLog.Name, ''); leNumber.Text := ini.ReadString(self.ClassName, leNumber.Name, ''); finally ini.Free; end; end; procedure TfrmSubstractMrpLog.FormDestroy(Sender: TObject); var ini: TIniFile; begin ini := TIniFile.Create(AppIni); try ini.WriteString(self.ClassName, leMrpLog.Name, leMrpLog.Text); ini.WriteString(Self.ClassName, leNumber.Name, leNumber.Text); finally ini.Free; end; end; procedure TfrmSubstractMrpLog.ToolButton4Click(Sender: TObject); begin Close; end; function ListSortCompare(Item1, Item2: Pointer): Integer; var p1, p2: PMrpLogRecord; begin p1 := Item1; p2 := Item2; if p1^.id > p2^.id then Result := 1 else if p1^.id < p2^.id then Result := -1 else Result := 0; end; procedure TfrmSubstractMrpLog.SaveLog(const sfile: string; lst: TList); var ExcelApp, WorkBook: Variant; aMrpLogRecordPtr: PMrpLogRecord; irow: Integer; i: Integer; begin // 开始保存 Excel try ExcelApp := CreateOleObject('Excel.Application' ); ExcelApp.Visible := False; ExcelApp.Caption := '应用程序调用 Microsoft Excel'; except on e: Exception do begin MessageBox(Handle, PChar(e.Message), '金蝶提示', 0); Exit; end; end; WorkBook := ExcelApp.WorkBooks.Add; while ExcelApp.Sheets.Count > 1 do begin ExcelApp.Sheets[1].Delete; end; ExcelApp.Sheets[1].Name := 'Mrp Log(' + leNumber.Text + ')'; try irow := 1; ExcelApp.Cells[irow, 1].Value := 'ID'; ExcelApp.Cells[irow, 2].Value := '父ID'; ExcelApp.Cells[irow, 3].Value := '物料'; ExcelApp.Cells[irow, 4].Value := '物料名称'; ExcelApp.Cells[irow, 5].Value := '需求日期'; ExcelApp.Cells[irow, 6].Value := '建议下单日期'; ExcelApp.Cells[irow, 7].Value := '需求数量'; ExcelApp.Cells[irow, 8].Value := '可用库存'; ExcelApp.Cells[irow, 9].Value := 'OPO'; ExcelApp.Cells[irow, 10].Value := '净需求'; ExcelApp.Cells[irow, 11].Value := '替代组'; ExcelApp.Cells[irow, 12].Value := 'MRP控制者'; ExcelApp.Cells[irow, 13].Value := '采购员'; ExcelApp.Cells[irow, 14].Value := 'MRP区域'; ExcelApp.Cells[irow, 15].Value := '上层料号'; ExcelApp.Cells[irow, 16].Value := '根料号'; ExcelApp.Cells[irow, 17].Value := 'L/T'; irow := irow + 1; for i := 0 to lst.Count - 1 do begin aMrpLogRecordPtr := lst[i]; ExcelApp.Cells[irow, 1].Value := aMrpLogRecordPtr^.id;// 'ID'; ExcelApp.Cells[irow, 2].Value := aMrpLogRecordPtr^.pid;//'父ID'; ExcelApp.Cells[irow, 3].Value := aMrpLogRecordPtr^.snumber;//'物料'; ExcelApp.Cells[irow, 4].Value := aMrpLogRecordPtr^.sname;//'物料名称'; ExcelApp.Cells[irow, 5].Value := aMrpLogRecordPtr^.dt;//'需求日期'; ExcelApp.Cells[irow, 6].Value := aMrpLogRecordPtr^.dtReq; ExcelApp.Cells[irow, 7].Value := aMrpLogRecordPtr^.dqty;//'需求数量'; ExcelApp.Cells[irow, 8].Value := aMrpLogRecordPtr^.dqtyStock;//'可用库存'; ExcelApp.Cells[irow, 9].Value := aMrpLogRecordPtr^.dqtyOPO;//'OPO'; ExcelApp.Cells[irow, 10].Value := aMrpLogRecordPtr^.dqtyNet;//'净需求'; ExcelApp.Cells[irow, 11].Value := aMrpLogRecordPtr^.sGroup;//'替代组'; ExcelApp.Cells[irow, 12].Value := aMrpLogRecordPtr^.sMrp;//'MRP控制者'; ExcelApp.Cells[irow, 13].Value := aMrpLogRecordPtr^.sBuyer;//'采购员'; ExcelApp.Cells[irow, 14].Value := aMrpLogRecordPtr^.sArea;//'MRP区域'; ExcelApp.Cells[irow, 15].Value := aMrpLogRecordPtr^.spnumber;//'上层料号'; ExcelApp.Cells[irow, 16].Value := aMrpLogRecordPtr^.srnumber;//'根料号'; ExcelApp.Cells[irow, 17].Value := aMrpLogRecordPtr^.slt;//'L/T'; irow := irow + 1; end; WorkBook.SaveAs(sfile); ExcelApp.ActiveWorkBook.Saved := True; //新加的,设置已经保存 finally WorkBook.Close; ExcelApp.Quit; end; end; {* 查找指定的值是否在当前数组中(数组已经是有序的) *} function SearchData(sl: TStringList; id: longint ): Integer; var idMid: integer; idLow, idHigh: integer; begin idLow := 0; idHigh := sl.Count - 1; while ( idLow <= idHigh ) do begin if idLow = idHigh then begin if PMrpLogRecord(sl.Objects[ idLow ]).id = id then begin Result := idLow; end else begin Result := -1; end; Exit; end; idMid := ( idLow + idHigh ) div 2; if PMrpLogRecord(sl.Objects[ idMid ]).id = id then begin Result := idMid; Exit; end; if PMrpLogRecord(sl.Objects[ idMid ]).id > id then idHigh := idMid - 1; if PMrpLogRecord(sl.Objects[ idMid ]).id < id then idLow := idMid + 1; end; Result := -1; end; procedure TfrmSubstractMrpLog.tbSaveClick(Sender: TObject); var aMrpLogReader2: TMrpLogReader2; aMrpLogRecordPtr: PMrpLogRecord; lstID: TList; i: Integer; ig: Integer; sfile: string; idx: Integer; begin if not ExcelSaveDialog(sfile) then Exit; lstID := TList.Create; aMrpLogReader2 := TMrpLogReader2.Create(leMrpLog.Text, nil); try for i := 0 to aMrpLogReader2.Count - 1 do begin aMrpLogRecordPtr := aMrpLogReader2.Items[i]; if aMrpLogRecordPtr^.snumber = leNumber.Text then begin lstID.Add(aMrpLogRecordPtr); aMrpLogRecordPtr^.bCalc := True; for ig := 0 to aMrpLogReader2.Count - 1 do begin if aMrpLogReader2.Items[ig]^.bCalc then Continue; if aMrpLogReader2.Items[ig]^.sGroup = aMrpLogRecordPtr^.sGroup then begin lstID.Add(aMrpLogReader2.Items[ig]); aMrpLogReader2.Items[ig]^.bCalc := True; end; end; while aMrpLogRecordPtr^.pid <> 0 do begin idx := SearchData(aMrpLogReader2.FList, aMrpLogRecordPtr^.pid); // 根据ID查找 if idx >= 0 then begin aMrpLogRecordPtr := aMrpLogReader2.Items[idx]; lstID.Add(aMrpLogRecordPtr); aMrpLogRecordPtr^.bCalc := True; if aMrpLogRecordPtr^.sGroup <> '0' then begin for ig := 0 to aMrpLogReader2.Count - 1 do // 查找同替代组 begin if aMrpLogReader2.Items[ig]^.bCalc then Continue; if aMrpLogReader2.Items[ig]^.sGroup = aMrpLogRecordPtr^.sGroup then begin lstID.Add(aMrpLogReader2.Items[ig]); aMrpLogReader2.Items[ig]^.bCalc := True; end; end; end; end else raise Exception.Create('id not found ' + IntToStr(aMrpLogRecordPtr^.pid)); end; end; end; lstID.Sort(ListSortCompare); SaveLog(sfile, lstID); MessageBox(Handle, '完成', '提示', 0); finally aMrpLogReader2.Free; lstID.Free; end; end; end.
unit LoadMerlinReportTest; interface uses TestFramework, frxClass, frxDBSet, Classes, frxDesgn; type TLoadReportTest = class (TTestCase) private Stream: TStringStream; Report: TfrxReport; OKPO : array of string; procedure LoadReportFromFile(ReportName, ReportPath: string); procedure TStrArrAdd(const A : array of string); protected // подготавливаем данные для тестирования procedure SetUp; override; // возвращаем данные для тестирования procedure TearDown; override; published procedure LoadAllReportFormTest; end; implementation uses Authentication, FormStorage, CommonData, Storage, UtilConst; const ReportPath = '..\Reports\Merlin'; { TLoadReportTest } procedure TLoadReportTest.TStrArrAdd(const A : array of string); var i : integer; begin SetLength(OKPO, Length(a)); for i := Low(A) to High(A) do OKPO[i] := A[i]; end; procedure TLoadReportTest.LoadReportFromFile(ReportName, ReportPath: string); begin // Загрузка из файла в репорт Report.LoadFromFile(ReportPath); // Сохранение отчета в базу Stream.Clear; Report.SaveToStream(Stream); Stream.Position := 0; TdsdFormStorageFactory.GetStorage.SaveReport(Stream, ReportName); // Считывание отчета из базы Report.LoadFromStream(TdsdFormStorageFactory.GetStorage.LoadReport(ReportName)); end; procedure TLoadReportTest.LoadAllReportFormTest; var i : integer; begin LoadReportFromFile('PrintMovement_Cash', ReportPath + '\PrintMovement_Cash.fr3'); LoadReportFromFile('PrintMovement_Service', ReportPath + '\PrintMovement_Service.fr3'); LoadReportFromFile('PrintReport_UnitBalance', ReportPath + '\PrintReport_UnitBalance.fr3'); LoadReportFromFile('PrintReport_CashBalance', ReportPath + '\PrintReport_CashBalance.fr3'); LoadReportFromFile('PrintReport_CashBalance(InfoMoney)', ReportPath + '\PrintReport_CashBalance(InfoMoney).fr3'); //LoadReportFromFile('PrintCash', ReportPath + '\PrintCash.fr3'); end; procedure TLoadReportTest.SetUp; begin inherited; TAuthentication.CheckLogin(TStorageFactory.GetStorage, 'Админ', gc_AdminPassword, gc_User); Report := TfrxReport.Create(nil); Stream := TStringStream.Create; end; procedure TLoadReportTest.TearDown; begin inherited; Report.Free; Stream.Free end; initialization TestFramework.RegisterTest('Загрузка отчетов', TLoadReportTest.Suite); end.
//Only compile for the LINUX platform. {$IF NOT Defined(LINUX)} {$MESSAGE Fatal 'AT.Linux.Folders.pas only compiles for the LINUX platform.'} {$ENDIF} // ****************************************************************** // // Program Name : Angelic Tech Linux Library // Program Version: 2017 // Platform(s) : Linux // Framework : None // // Filename : AT.Linux.Folders.pas // File Version : 2017.04 // Date Created : 21-Apr-2017 // Author : Matthew Vesperman // // Description: // // Linux folder routines. // // Revision History: // // v1.00 : Initial version // // ****************************************************************** // // COPYRIGHT © 2017 - PRESENT Angelic Technology // ALL RIGHTS RESERVED WORLDWIDE // // ****************************************************************** /// <summary> /// Contains routines that return folder paths for the Linux /// platform. /// </summary> unit AT.Linux.Folders; interface /// <summary> /// Calculates the path to the application's data folder. /// </summary> /// <param name="AAppID"> /// The name of the folder to store the application's data. /// </param> /// <returns> /// A string containing the application's data path. /// </returns> /// <remarks> /// Linux does not have a "COMMON" app data folder option. /// </remarks> function GetAppDataDirectory(const AAppID: String = ''): string; /// <summary> /// Retrieves the location of the app's executable file. /// </summary> /// <returns> /// A string containing the absolute path to the app's executable /// file. /// </returns> function GetAppDirectory: string; /// <summary> /// Calculates the path to the application's documents folder. /// </summary> /// <param name="ADocPath"> /// The name of the folder to store the application's documents. /// </param> /// <returns> /// A string containing the application's documents path. /// </returns> /// <remarks> /// Linux does not have a "COMMON" app documents folder option. /// </remarks> function GetDocumentDirectory(const ADocPath: String = ''): string; /// <summary> /// Retrieves the current user's home folder. /// </summary> /// <returns> /// A String containing the current user's home folder. /// </returns> function GetHomeDirectory: string; implementation uses System.IOUtils, System.SysUtils; function GetAppDataDirectory(const AAppID: String = ''): string; begin Result := IncludeTrailingPathDelimiter(GetHomeDirectory); if (NOT AAppID.IsEmpty) then begin Result := Format('%s.%s', [Result, AAppID]); Result := IncludeTrailingPathDelimiter(Result); TDirectory.CreateDirectory(Result); end; end; function GetAppDirectory: string; begin Result := ParamStr(0); Result := TPath.GetDirectoryName(Result); Result := IncludeTrailingPathDelimiter(Result); end; function GetDocumentDirectory(const ADocPath: String = ''): string; begin Result := IncludeTrailingPathDelimiter(GetHomeDirectory); Result := Format('%sDocuments', [Result]); Result := IncludeTrailingPathDelimiter(Result); if (NOT ADocPath.IsEmpty) then begin Result := Format('%s%s', [Result, ADocPath]); Result := IncludeTrailingPathDelimiter(Result); end; TDirectory.CreateDirectory(Result); end; function GetHomeDirectory: string; begin Result := TPath.GetHomePath; end; end.
unit RepositorioProdutoHasMateria; interface uses DB, Auditoria, Repositorio; type TRepositorioProdutoHasMateria = class(TRepositorio) protected function Get (Dataset :TDataSet) :TObject; overload; override; function GetNomeDaTabela :String; override; function GetIdentificador(Objeto :TObject) :Variant; override; function GetRepositorio :TRepositorio; override; protected function SQLGet :String; override; function SQLSalvar :String; override; function SQLGetAll :String; override; function SQLRemover :String; override; function SQLGetExiste(campo: String): String; override; protected function IsInsercao(Objeto :TObject) :Boolean; override; protected procedure SetParametros (Objeto :TObject ); override; procedure SetIdentificador(Objeto :TObject; Identificador :Variant); override; //============================================================================== // Auditoria //============================================================================== protected procedure SetCamposIncluidos(Auditoria :TAuditoria; Objeto :TObject); override; procedure SetCamposAlterados(Auditoria :TAuditoria; AntigoObjeto, Objeto :TObject); override; procedure SetCamposExcluidos(Auditoria :TAuditoria; Objeto :TObject); override; end; implementation uses SysUtils, ProdutoHasMateria; { TRepositorioProdutoHasMateria } function TRepositorioProdutoHasMateria.Get(Dataset: TDataSet): TObject; var ProdutoHasMateria :TProdutoHasMateria; begin ProdutoHasMateria := TProdutoHasMateria.Create; ProdutoHasMateria.Codigo := self.FQuery.FieldByName('codigo').AsInteger; ProdutoHasMateria.codigo_produto := self.FQuery.FieldByName('codigo_produto').AsInteger; ProdutoHasMateria.codigo_materia := self.FQuery.FieldByName('codigo_materia').AsInteger; result := ProdutoHasMateria; end; function TRepositorioProdutoHasMateria.GetIdentificador(Objeto: TObject): Variant; begin result := TProdutoHasMateria(Objeto).Codigo; end; function TRepositorioProdutoHasMateria.GetNomeDaTabela: String; begin result := 'produtos_has_materias'; end; function TRepositorioProdutoHasMateria.GetRepositorio: TRepositorio; begin result := TRepositorioProdutoHasMateria.Create; end; function TRepositorioProdutoHasMateria.IsInsercao(Objeto: TObject): Boolean; begin result := (TProdutoHasMateria(Objeto).Codigo <= 0); end; procedure TRepositorioProdutoHasMateria.SetCamposAlterados(Auditoria :TAuditoria; AntigoObjeto, Objeto :TObject); var ProdutoHasMateriaAntigo :TProdutoHasMateria; ProdutoHasMateriaNovo :TProdutoHasMateria; begin ProdutoHasMateriaAntigo := (AntigoObjeto as TProdutoHasMateria); ProdutoHasMateriaNovo := (Objeto as TProdutoHasMateria); if (ProdutoHasMateriaAntigo.codigo_produto <> ProdutoHasMateriaNovo.codigo_produto) then Auditoria.AdicionaCampoAlterado('codigo_produto', IntToStr(ProdutoHasMateriaAntigo.codigo_produto), IntToStr(ProdutoHasMateriaNovo.codigo_produto)); if (ProdutoHasMateriaAntigo.codigo_materia <> ProdutoHasMateriaNovo.codigo_materia) then Auditoria.AdicionaCampoAlterado('codigo_materia', IntToStr(ProdutoHasMateriaAntigo.codigo_materia), IntToStr(ProdutoHasMateriaNovo.codigo_materia)); end; procedure TRepositorioProdutoHasMateria.SetCamposExcluidos(Auditoria :TAuditoria; Objeto :TObject); var ProdutoHasMateria :TProdutoHasMateria; begin ProdutoHasMateria := (Objeto as TProdutoHasMateria); Auditoria.AdicionaCampoExcluido('codigo', IntToStr(ProdutoHasMateria.codigo)); Auditoria.AdicionaCampoExcluido('codigo_produto', IntToStr(ProdutoHasMateria.codigo_produto)); Auditoria.AdicionaCampoExcluido('codigo_materia', IntToStr(ProdutoHasMateria.codigo_materia)); end; procedure TRepositorioProdutoHasMateria.SetCamposIncluidos(Auditoria :TAuditoria; Objeto :TObject); var ProdutoHasMateria :TProdutoHasMateria; begin ProdutoHasMateria := (Objeto as TProdutoHasMateria); Auditoria.AdicionaCampoIncluido('codigo', IntToStr(ProdutoHasMateria.codigo)); Auditoria.AdicionaCampoIncluido('codigo_produto', IntToStr(ProdutoHasMateria.codigo_produto)); Auditoria.AdicionaCampoIncluido('codigo_materia', IntToStr(ProdutoHasMateria.codigo_materia)); end; procedure TRepositorioProdutoHasMateria.SetIdentificador(Objeto: TObject; Identificador: Variant); begin TProdutoHasMateria(Objeto).Codigo := Integer(Identificador); end; procedure TRepositorioProdutoHasMateria.SetParametros(Objeto: TObject); var ProdutoHasMateria :TProdutoHasMateria; begin ProdutoHasMateria := (Objeto as TProdutoHasMateria); self.FQuery.ParamByName('codigo').AsInteger := ProdutoHasMateria.Codigo; self.FQuery.ParamByName('codigo_produto').AsInteger := ProdutoHasMateria.codigo_produto; self.FQuery.ParamByName('codigo_materia').AsInteger := ProdutoHasMateria.codigo_materia; end; function TRepositorioProdutoHasMateria.SQLGet: String; begin result := 'select * from produtos_has_materias where codigo = :ncod'; end; function TRepositorioProdutoHasMateria.SQLGetAll: String; begin result := 'select * from produtos_has_materias'; end; function TRepositorioProdutoHasMateria.SQLGetExiste(campo: String): String; begin result := 'select '+ campo +' from produtos_has_materias where '+ campo +' = :ncampo'; end; function TRepositorioProdutoHasMateria.SQLRemover: String; begin result := ' delete from produtos_has_materias where codigo = :codigo '; end; function TRepositorioProdutoHasMateria.SQLSalvar: String; begin result := 'update or insert into produtos_has_materias (codigo, codigo_produto, codigo_materia) '+ ' values (:codigo, :codigo_produto, :codigo_materia) '; end; end.
program postfix(input,output,infile); type stacktype=^stackrecord; data=integer; stackrecord=record info:data; next:stacktype; end; expressiontype=array[1..30] of integer; var stack:stacktype; expression1,expression2:expressiontype; x,thing,y:integer; ch:char; infile:text; {----------------------------------INITIALIZESTACK} procedure initializestack(var stack:stacktype); begin stack:=nil end; {----------------------------------HEADER} procedure header; begin writeln('Mike Carson'); writeln('APCSCI period 2'); writeln('POSTFIX THING'); writeln; end; {----------------------------------EMPTY} function empty(stack:stacktype):boolean; begin empty:=(stack=nil); end; {----------------------------------PUSH} procedure push(item:data; var stack:stacktype); var newelement:stacktype; begin new(newelement); newelement^.info:=item; newelement^.next:=stack; stack:=newelement; end; {---------------------------------POP} procedure pop(var item:data; var stack:stacktype); var element:stacktype; begin element:=stack; item:=element^.info; stack:=stack^.next; dispose(element); end; {-------------------------------FIGURE} procedure figure(ch:char; var stack:stacktype); var x,y:integer; begin pop(x,stack); pop(y,stack); if ch='*' then push(y*x,stack) else if ch='+' then push(y+x,stack) else if ch='/' then push(trunc(y/x),stack) else if ch='-' then push(y-x,stack); end; {-------------------------------READANDDECIDE} procedure ReadAndDecide(var infile:text; var stack:stacktype); var ch:char; begin while not eoln(infile) do begin read(infile,ch); write(ch); if ord(ch)>47 then push(ord(ch)-48,stack) else figure(ch,stack); end; readln(infile); end; {-------------------------------INPRI} function inpri(ch:char):integer; begin if ch='*' then inpri:=2 else if ch='/' then inpri:=2 else if ch='+' then inpri:=1 else if ch='-' then inpri:=1 else if ch='(' then inpri:=3 else if ch=')' then inpri:=0 else if ch='$' then inpri:=0; end; {-------------------------------OUTPRI} function outpri(ch:char):integer; begin if ch='*' then outpri:=2 else if ch='/' then outpri:=2 else if ch='+' then outpri:=1 else if ch='-' then outpri:=1 else if ch='(' then outpri:=0 else if ch='$' then outpri:=0; end; {-------------------------------TRANSLATE} procedure translate(var stack:stacktype; var expression1,expression2:expressiontype; var x:integer); var ch:char; dumber,ctr,ctr2,dum:integer; begin push(ord('$'),stack); ctr:=0; ctr2:=0; dumber:=x; while ctr<=dumber do begin ctr:=1+ctr; ch:=chr(expression1[ctr]); if (ord(ch)>47) then begin ctr2:=ctr2+1; expression2[ctr2]:=ord(ch); end else if ch=')' then begin repeat pop(dum,stack); ctr2:=ctr2+1; expression2[ctr2]:=dum; pop(dum,stack); until (chr(dum))='('; x:=x-2; end else if ord(ch)<48 then begin if (inpri(ch)<=outpri(chr(stack^.info))) then begin pop(dum,stack); if dum>40 then begin ctr2:=ctr2+1; expression2[ctr2]:=dum; end; end; push(ord(ch),stack); end; end; while stack^.info<>ord('$') do begin pop(dum,stack); if dum>40 then begin ctr2:=ctr2+1; expression2[ctr2]:=dum; end; end; end; {-------------------------------ORIG} procedure orig(var infile:text; var expression1:expressiontype; var x:integer); var ch:char; p:integer; begin for p:=1 to 30 do expression1[p]:=0; x:=0; while not eoln(infile) do begin x:=x+1; read(infile,ch); expression1[x]:=ord(ch); write(ch); end; end; {-------------------------------WRITEXP} procedure writexp(expression:expressiontype; length:integer); var counter:integer; begin for counter:=1 to length do begin { if expression[counter]>39 then} write(chr(expression[counter])); end; writeln; end; {-------------------------------INITEXP} procedure initexp(expression:expressiontype); var o:integer; begin for o:=1 to 30 do expression[o]:=0; end; {-------------------------------MAIN} begin header; assign(infile,'postfix.txt'); reset(infile); initializestack(stack); while not eof(infile) do begin read(infile,ch); if ch='1' then begin writeln('1. Evaluating a postfix expression:'); ReadAndDecide(infile,stack); pop(thing,stack); writeln(' = ',thing); writeln; initializestack(stack); end else if ch='2' then begin writeln('2. Converting infix to postfix:'); orig(infile,expression1,x); initexp(expression2); translate(stack,expression1,expression2,x); write(' converted to postfix is '); writexp(expression2,x); writeln; writeln; initializestack(stack); end else if ch='3' then begin writeln('3. Evaluating infix expression:'); orig(infile,expression1,x); initexp(expression2); translate(stack,expression1,expression2,x); writeln; writexp(expression2,x); for y:=1 to x do begin if expression2[y]>47 then push(expression2[y]-48,stack) else figure(chr(expression2[y]),stack); end; pop(thing,stack); writeln(' = ',thing); initializestack(stack); writeln; end; end; end. 
{ Invokable implementation File for TPulseWS which implements IPulseWS } unit PulseWSImpl; interface uses InvokeRegistry, Types, XSBuiltIns, PulseWSIntf, Rda_TLB, CommunicationObj; type { TPulseWS } TPulseWS = class(TCommObj, IPulseWS) public // IPulse function Get_N1CH1: Integer; safecall; function Get_N2: Integer; safecall; function Get_N3: Integer; safecall; function Get_N4: Integer; safecall; function Get_N5: Integer; safecall; function Get_N6: Integer; safecall; function Get_N1CH2: Integer; safecall; function Get_Frecuencia: Integer; safecall; function Get_TxRxPulso: TxPulseEnum; safecall; // IPulseControl procedure Set_N1CH1(Value: Integer); safecall; procedure Set_N2(Value: Integer); safecall; procedure Set_N3(Value: Integer); safecall; procedure Set_N4(Value: Integer); safecall; procedure Set_N5(Value: Integer); safecall; procedure Set_N6(Value: Integer); safecall; procedure Set_N1CH2(Value: Integer); safecall; procedure Set_Frecuencia(Value: Integer); safecall; function CheckCredentials : boolean; override; end; implementation uses SysUtils, ElbrusTypes, Elbrus, Config, Radars, Description, Users; { TPulseWS } function TPulseWS.CheckCredentials: boolean; begin result := CheckAuthHeader >= ul_Service; end; function TPulseWS.Get_Frecuencia: Integer; begin Result := Snapshot.Trigger_Rate; end; function TPulseWS.Get_N1CH1: Integer; begin Result := Snapshot.Counter_Times[N1CH1_Counter]; end; function TPulseWS.Get_N1CH2: Integer; begin Result := Snapshot.Counter_Times[N1CH2_Counter]; end; function TPulseWS.Get_N2: Integer; begin Result := Snapshot.Counter_Times[N2_Counter]; end; function TPulseWS.Get_N3: Integer; begin Result := Snapshot.Counter_Times[N3_Counter]; end; function TPulseWS.Get_N4: Integer; begin Result := Snapshot.Counter_Times[N4_Counter]; end; function TPulseWS.Get_N5: Integer; begin Result := Snapshot.Counter_Times[N5_Counter]; end; function TPulseWS.Get_N6: Integer; begin Result := Snapshot.Counter_Times[N6_Counter]; end; function TPulseWS.Get_TxRxPulso: TxPulseEnum; begin result := TxPulseEnum( Snapshot.Pulse ); end; procedure TPulseWS.Set_Frecuencia(Value: Integer); begin if InControl then Elbrus.Set_Frecuencia_N1(Value); end; procedure TPulseWS.Set_N1CH1(Value: Integer); begin if InControl then Elbrus.Set_Counter_Time(N1CH1_Counter, Value); end; procedure TPulseWS.Set_N1CH2(Value: Integer); begin if InControl then Elbrus.Set_Counter_Time(N1CH2_Counter, Value); end; procedure TPulseWS.Set_N2(Value: Integer); begin if InControl then Elbrus.Set_Counter_Time(N2_Counter, Value); end; procedure TPulseWS.Set_N3(Value: Integer); begin if InControl then Elbrus.Set_Counter_Time(N3_Counter, Value); end; procedure TPulseWS.Set_N4(Value: Integer); begin if InControl then Elbrus.Set_Counter_Time(N4_Counter, Value); end; procedure TPulseWS.Set_N5(Value: Integer); begin if InControl then Elbrus.Set_Counter_Time(N5_Counter, Value); end; procedure TPulseWS.Set_N6(Value: Integer); begin if InControl then Elbrus.Set_Counter_Time(N6_Counter, Value); end; initialization { Invokable classes must be registered } InvRegistry.RegisterInvokableClass(TPulseWS); end.
unit SearchDlg.Results; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls; type TSearchResultsForm = class(TForm) BottomPanel: TPanel; BottomBevel: TBevel; ButtonExit: TButton; ButtonGo: TButton; SearchList: TListBox; ButtonRetry: TButton; TopPanel: TPanel; QueryTextLabel: TLabel; ResultLabel: TLabel; procedure ButtonExitClick(Sender: TObject); procedure ButtonRetryClick(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure ButtonGoClick(Sender: TObject); procedure SearchListDblClick(Sender: TObject); protected procedure CreateParams(var Params: TCreateParams); override; public procedure Reset; end; implementation uses Main, Dialog.Message; {$R *.dfm} procedure TSearchResultsForm.ButtonExitClick(Sender: TObject); begin Close; end; procedure TSearchResultsForm.ButtonGoClick(Sender: TObject); begin if SearchList.ItemIndex <> -1 then begin MainForm.GotoItem(TBrowserListItem(SearchList.Items.Objects[SearchList.ItemIndex]).RecPtr); MainForm.Show; end else ShowMessage('Нет выбранных записей!'); end; procedure TSearchResultsForm.ButtonRetryClick(Sender: TObject); begin Close; MainForm.ActionSearch.Execute; end; procedure TSearchResultsForm.CreateParams(var Params: TCreateParams); begin inherited CreateParams(Params); Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW; end; procedure TSearchResultsForm.FormDestroy(Sender: TObject); begin Reset; end; procedure TSearchResultsForm.Reset; var i: Integer; begin for i := 0 to SearchList.Items.Count - 1 do SearchList.Items.Objects[i].Free; SearchList.Clear; end; procedure TSearchResultsForm.SearchListDblClick(Sender: TObject); begin if SearchList.ItemIndex <> -1 then ButtonGoClick(Sender); end; end.
unit ProdutoFornecedor; interface uses SysUtils, Perfil, Contnrs; type TProdutoFornecedor = class private Fcodigo_fornecedor: integer; Fcodigo: integer; Fcodigo_Produto: integer; Fcodigo_Produto_fornecedor: String; procedure Setcodigo(const Value: integer); procedure Setcodigo_fornecedor(const Value: integer); procedure Setcodigo_Produto(const Value: integer); procedure Setcodigo_Produto_fornecedor(const Value: String); public property codigo :integer read Fcodigo write Setcodigo; property codigo_Produto :integer read Fcodigo_Produto write Setcodigo_Produto; property codigo_fornecedor :integer read Fcodigo_fornecedor write Setcodigo_fornecedor; property codigo_Produto_fornecedor :String read Fcodigo_Produto_fornecedor write Setcodigo_Produto_fornecedor; public constructor create(pCodigoProduto, pCodigoFornecedor :integer; pCodigoProdutoFornecedor :String);overload; constructor create;overload; end; implementation { TProdutoFornecedor } constructor TProdutoFornecedor.create(pCodigoProduto, pCodigoFornecedor: integer; pCodigoProdutoFornecedor: String); begin self.Fcodigo := 0; self.Fcodigo_Produto := pCodigoProduto; self.Fcodigo_fornecedor := pCodigoFornecedor; self.Fcodigo_Produto_fornecedor := pCodigoProdutoFornecedor; end; constructor TProdutoFornecedor.create; begin end; procedure TProdutoFornecedor.Setcodigo(const Value: integer); begin Fcodigo := Value; end; procedure TProdutoFornecedor.Setcodigo_fornecedor(const Value: integer); begin Fcodigo_fornecedor := Value; end; procedure TProdutoFornecedor.Setcodigo_Produto(const Value: integer); begin Fcodigo_Produto := Value; end; procedure TProdutoFornecedor.Setcodigo_Produto_fornecedor( const Value: String); begin Fcodigo_Produto_fornecedor := Value; end; end.
{***********************************************************} { Exemplo de lançamento de nota fiscal orientado a objetos, } { com banco de dados Oracle } { Reinaldo Silveira - reinaldopsilveira@gmail.com } { Franca/SP - set/2019 } {***********************************************************} unit U_Fornecedor; interface uses U_BaseControl, System.SysUtils, Data.DB, Vcl.Controls; type TTipoBusca = (tbID, tbRazao, tbFantasia, tbCNPJ); TFornecedor = class(TBaseControl) private FCNPJ: String; FRAZAOSOCIAL: String; FFORNECEDOR_ID: Integer; FNOMEFANTASIA: String; procedure SetCNPJ(const Value: String); procedure SetFORNECEDOR_ID(const Value: Integer); procedure SetNOMEFANTASIA(const Value: String); procedure SetRAZAOSOCIAL(const Value: String); { private declarations } protected { protected declarations } public { public declarations } property FORNECEDOR_ID: Integer read FFORNECEDOR_ID write SetFORNECEDOR_ID; property RAZAOSOCIAL: String read FRAZAOSOCIAL write SetRAZAOSOCIAL; property NOMEFANTASIA: String read FNOMEFANTASIA write SetNOMEFANTASIA; property CNPJ: String read FCNPJ write SetCNPJ; function BuscaDados(pBusca: Variant; pBuscarPor: TTipoBusca): Boolean; function Pesquisa(pPesq: String = ''): Boolean; end; implementation { TFornecedor } uses U_Pesquisa; function TFornecedor.BuscaDados(pBusca: Variant; pBuscarPor: TTipoBusca): Boolean; begin Query.Close; Query.SQL.Clear; Query.SQL.Add('select FORNECEDOR_ID, '); Query.SQL.Add(' RAZAOSOCIAL, '); Query.SQL.Add(' NOMEFANTASIA, '); Query.SQL.Add(' CNPJ '); Query.SQL.Add('from TB_FORNECEDOR '); case pBuscarPor of tbID : Query.SQL.Add(Format('where FORNECEDOR_ID = %d', [Integer(pBusca)])); tbRazao : Query.SQL.Add(Format('where RAZAOSOCIAL = %s', [QuotedStr(pBusca)])); tbFantasia: Query.SQL.Add(Format('where NOMEFANTASIA = %s', [QuotedStr(pBusca)])); tbCNPJ : Query.SQL.Add(Format('where CNPJ = %s', [QuotedStr(pBusca)])); end; Query.Open; Result := not Query.IsEmpty; FFORNECEDOR_ID := Query.Fields[0].AsInteger; FRAZAOSOCIAL := Query.Fields[1].AsString; FNOMEFANTASIA := Query.Fields[2].AsString; FCNPJ := Query.Fields[3].AsString; end; function TFornecedor.Pesquisa(pPesq: String): Boolean; begin if not Assigned(F_Pesquisa) then F_Pesquisa := TF_Pesquisa.Create(Self); try F_Pesquisa.Caption := 'Pesquisa de Fornecedores'; F_Pesquisa.SQL_BASE := 'select FORNECEDOR_ID as "Código", RAZAOSOCIAL as "Razão social", NOMEFANTASIA as "Nome fantasia" from TB_FORNECEDOR'; F_Pesquisa.SQL_WHERE := 'where RAZAOSOCIAL like %s'; F_Pesquisa.SQL_ORDER := 'order by RAZAOSOCIAL'; F_Pesquisa.edtPesquisa.Text := pPesq; F_Pesquisa.ShowModal; Result := F_Pesquisa.ModalResult = mrOk; if Result then Result := BuscaDados(F_Pesquisa.ID, tbID); finally FreeAndNil(F_Pesquisa); end; end; procedure TFornecedor.SetCNPJ(const Value: String); begin FCNPJ := Value; end; procedure TFornecedor.SetFORNECEDOR_ID(const Value: Integer); begin FFORNECEDOR_ID := Value; end; procedure TFornecedor.SetNOMEFANTASIA(const Value: String); begin FNOMEFANTASIA := Value; end; procedure TFornecedor.SetRAZAOSOCIAL(const Value: String); begin FRAZAOSOCIAL := Value; end; end.
unit View.CityEdit; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, View.TemplateEdit, Data.DB, JvComponentBase, JvFormPlacement, Vcl.StdCtrls, Vcl.ExtCtrls, Model.LanguageDictionary, Model.ProSu.Interfaces, Model.ProSu.Provider, Model.Declarations, Spring.Data.ObjectDataset, Model.FormDeclarations, Vcl.DBCtrls, Vcl.Mask; type TCityEditForm = class(TTemplateEdit) labelCityName: TLabel; labelCountryId: TLabel; edCityName: TDBEdit; edCountryId: TDBLookupComboBox; dsCountry: TDataSource; labelCityCode: TLabel; edCityCode: TDBEdit; procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); private { Private declarations } fCountryDataset : TObjectDataset; protected class procedure CheckAuthorize(cmd : TBrowseFormCommand); override; class function RequiredPermission(cmd: TBrowseFormCommand) : string; override; public { Public declarations } end; implementation uses Spring.Collections, MainDM; {$R *.dfm} class procedure TCityEditForm.CheckAuthorize(cmd: TBrowseFormCommand); begin if not DMMain.Authorize(RequiredPermission(cmd)) then raise Exception.Create(Model.LanguageDictionary.MessageDictionary().GetMessage('SNotAuthorized')+#13#10+'TCityEditForm'); end; class function TCityEditForm.RequiredPermission(cmd: TBrowseFormCommand): string; begin Result := '>????<'; case cmd of efcmdAdd: Result := '3012'; efcmdEdit: Result := '3013'; efcmdDelete: Result := '3014'; efcmdViewDetail: Result := '3015'; end; end; procedure TCityEditForm.FormCreate(Sender: TObject); begin inherited; Caption := ComponentDictionary.GetText(Self.ClassName, 'Caption'); labelCityName.Caption := ComponentDictionary.GetText(ClassName, 'labelCityName.Caption'); labelCityCode.Caption := ComponentDictionary.GetText(ClassName, 'labelCityCode.Caption'); labelCountryId.Caption := ComponentDictionary.GetText(ClassName, 'labelCountryId.Caption'); fCountryDataset := TObjectDataset.Create(self); fCountryDataset.DataList := DMMain.Session.FindAll<TCountry> as IObjectList; fCountryDataset.Open; dsCountry.DataSet := fCountryDataset; end; procedure TCityEditForm.FormDestroy(Sender: TObject); begin inherited; fCountryDataset.Free; end; end.
unit mnChinese; interface uses mnSystem, mnDateTime; {-------------------------------- 将一位数转换成中文。例如,“0”转为“零”,“6”转为“六”。 Capital表示是否大写,大写中文如“壹贰叁”。 Zero表示“0”转为什么,缺省是“零”,但有时有别的需求,比如转成“〇”。 如果Digit不在0-9内,将抛出异常。 Tested in TestUnit. --------------------------------} function mnChineseDigit(const Digit: Integer; const Capital: Boolean = False; const Zero: string = '零'): string; {-------------------------------- 将一个数字逐位转换成中文。例如,“5403”转为“五四零三”。 Capital表示是否大写,大写中文如“壹贰叁”。 Zero表示“0”转为什么,缺省是“零”,但有时有别的需求,比如转成“〇”。 Tested in TestUnit. --------------------------------} function mnChineseNumber(const Value: Integer; const Capital: Boolean = False; const Zero: string = '零'): string; {-------------------------------- 将一个整数转换成中文。例如,“5403”转为“五千四百零三”。 Capital表示是否大写,大写中文如“壹贰叁”。 Zero表示“0”转为什么,缺省是“零”,但有时有别的需求,比如转成“〇”。 Tested in TestUnit. --------------------------------} function mnChineseInt(const Value: Integer; const Capital: Boolean = False; const Zero: string = '零'): string; {-------------------------------- 将一个日期转换成中文。例如,“1982-10-29”转为“一九八二年十月二十九日”。 也就是说,年使用数字逐位方式转换,月和日使用整数方式转换。 Capital表示是否大写,大写中文如“壹贰叁”。 Zero表示“0”转为什么,缺省是“零”,但有时有别的需求,比如转成“〇”。 Tested in TestUnit. --------------------------------} function mnChineseDate(const Value: TDateTime; const Capital: Boolean = False; const Zero: string = '零'): string; {-------------------------------- 将一个浮点数转换成以万表示的字符串。例如,“87654320”转为“8765.43万”。 DecimalDigits表示转换成字符串时,保留的小数位数。如果是-1,说明不做任何舍入操作。 Tested in TestUnit. --------------------------------} function mnFloatToWanStr (const Value: Extended; const DecimalDigits: Integer = -1): string; {-------------------------------- 将一个浮点数转换成以亿表示的字符串。例如,“876543200000”转为“8765.43亿”。 DecimalDigits表示转换成字符串时,保留的小数位数。如果是-1,说明不做任何舍入操作。 Tested in TestUnit. --------------------------------} function mnFloatToYiStr (const Value: Extended; const DecimalDigits: Integer = -1): string; {-------------------------------- 将一个浮点数根据其大小,转换为以万表示或以亿表示的字符串。大于1亿或小于负1亿,以亿表示,否则以万表示。 DecimalDigits表示转换成字符串时,保留的小数位数。如果是-1,说明不做任何舍入操作。 Tested in TestUnit. --------------------------------} function mnFloatToWanYiStr(const Value: Extended; const DecimalDigits: Integer = -1): string; {-------------------------------- 将以万表示或以亿表示的字符串,转换为浮点数。 支持字符串里存在千位分隔符或空格。 例如,“8765万”转为“87650000”,“8,765.432 亿”转为“876543200000”。 Tested in TestUnit. --------------------------------} function mnWanYiStrToFloat(const S: string): Extended; {-------------------------------- 将一个时间单位转换为中文表示。 ForDuration表示该中文表示是否用于指示一段持续时间。 若ForDuration为True,六个时间单位将分别转换为“年”、“个月”、“天”、“小时”、“分钟”、“秒”。 否则,转换为标准表示“年”、“月”、“日”、“时”、“分”、“秒”。 Tested in TestUnit. --------------------------------} function mnTimeUnitToChinese(const TimeUnit: mnTTimeUnit; const ForDuration: Boolean = False): string; {-------------------------------- 将一个农历日期转换为中文表示。 Capital表示是否大写,大写中文如“壹贰叁”。 Zero表示“0”转为什么,缺省是“零”,但有时有别的需求,比如转成“〇”。 允许不完整的农历日期。 不完整的农历日期是指,年、月、日不需要全部指定,没有指定的可传入0。 如果年、月、日都为0,则返回空串。 Tested in TestUnit. --------------------------------} function mnLunarDateToChinese(const LunarDate: mnTLunarDate; const Capital: Boolean = False; const Zero: string = '零'): string; {-------------------------------- 将一个星座转换为中文表示。 Tested in TestUnit. --------------------------------} function mnConstellation12ToChinese(const Constellation12: mnTConstellation12): string; {-------------------------------- 将一个生肖转换为中文表示。 Tested in TestUnit. --------------------------------} function mnAnimal12ToChinese(const Animal12: mnTAnimal12): string; implementation uses mnResStrsU, SysUtils, StrUtils, Math, mnString, mnDebug; function mnChineseDigit(const Digit: Integer; const Capital: Boolean = False; const Zero: string = '零'): string; begin if Capital then begin case Digit of 0: Result := Zero; 1: Result := '壹'; 2: Result := '贰'; 3: Result := '叁'; 4: Result := '肆'; 5: Result := '伍'; 6: Result := '陆'; 7: Result := '柒'; 8: Result := '捌'; 9: Result := '玖'; else mnCreateError(SDigitNotIn0To9, [Digit]); end; end else begin case Digit of 0: Result := Zero; 1: Result := '一'; 2: Result := '二'; 3: Result := '三'; 4: Result := '四'; 5: Result := '五'; 6: Result := '六'; 7: Result := '七'; 8: Result := '八'; 9: Result := '九'; else mnCreateError(SDigitNotIn0To9, [Digit]); end; end; end; function mnChineseNumber(const Value: Integer; const Capital: Boolean = False; const Zero: string = '零'): string; var VarValue: Integer; Negative: Boolean; begin Result := ''; VarValue := Value; Negative := VarValue < 0; if Negative then VarValue := -VarValue; while VarValue > 0 do begin Result := mnChineseDigit(VarValue mod 10, Capital, Zero) + Result; VarValue := VarValue div 10; end; if Result = '' then Result := Zero; if Negative then Result := '负' + Result; end; function mnChineseInt(const Value: Integer; const Capital: Boolean = False; const Zero: string = '零'): string; var VarValue: Integer; Negative: Boolean; ZeroLen: Integer; begin Result := ''; VarValue := Value; Negative := VarValue < 0; if Negative then VarValue := -VarValue; ZeroLen := Length(Zero); if VarValue >= 100000000 then begin Result := Result + mnChineseInt(VarValue div 100000000, Capital, Zero) + mnChooseStr(Capital, '億', '亿'); VarValue := VarValue mod 100000000; end; if VarValue >= 10000 then begin Result := Result + mnChineseInt(VarValue div 10000, Capital, Zero) + mnChooseStr(Capital, '萬', '万'); VarValue := VarValue mod 10000; end else if Result <> '' then Result := Result + Zero; if VarValue >= 1000 then begin Result := Result + mnChineseDigit(VarValue div 1000, Capital, Zero) + mnChooseStr(Capital, '仟', '千'); VarValue := VarValue mod 1000; end else if (Result <> '') and not mnEndsStr(Zero, Result) then Result := Result + Zero; if VarValue >= 100 then begin Result := Result + mnChineseDigit(VarValue div 100, Capital, Zero) + mnChooseStr(Capital, '佰', '百'); VarValue := VarValue mod 100; end else if (Result <> '') and not mnEndsStr(Zero, Result) then Result := Result + Zero; if VarValue >= 10 then begin Result := Result + mnChineseDigit(VarValue div 10, Capital, Zero) + mnChooseStr(Capital, '拾', '十'); VarValue := VarValue mod 10; end else if (Result <> '') and not mnEndsStr(Zero, Result) then Result := Result + Zero; if VarValue > 0 then Result := Result + mnChineseDigit(VarValue, Capital, Zero) else if Result = '' then Result := Zero; // if no leading characters, “一十” can be reduced to “十” if (LeftBStr(Result, 4) = '一十') or (LeftBStr(Result, 4) = '壹拾') then Result := Copy(Result, 3); // if there is leading characters, last “零” is ignored if (Length(Result) <> ZeroLen) and mnEndsStr(Zero, Result) then Result := mnTruncBRight(Result, ZeroLen); if Negative then Result := '负' + Result; end; function mnChineseDate(const Value: TDateTime; const Capital: Boolean = False; const Zero: string = '零'): string; var Year, Month, Day: Word; begin DecodeDate(Value, Year, Month, Day); Result := Format('%s年%s月%s日', [mnChineseNumber(Year, Capital, Zero), mnChineseInt(Month, Capital, Zero), mnChineseInt(Day, Capital, Zero)]); end; function mnFloatToWanStr (const Value: Extended; const DecimalDigits: Integer = -1): string; begin Result := mnFloatToStr(Value/10000, DecimalDigits) + '万'; end; function mnFloatToYiStr (const Value: Extended; const DecimalDigits: Integer = -1): string; begin Result := mnFloatToStr(Value/100000000, DecimalDigits) + '亿'; end; function mnFloatToWanYiStr(const Value: Extended; const DecimalDigits: Integer = -1): string; begin if (Value >= 100000000) or (Value <= -100000000) then Result := mnFloatToYiStr(Value, DecimalDigits) else Result := mnFloatToWanStr(Value, DecimalDigits); end; function mnWanYiStrToFloat(const S: string): Extended; var varS: string; BasicUnit: string; begin varS := mnDiscardDelimiter(', ', S); BasicUnit := RightBStr(varS, 2); if BasicUnit = '万' then begin varS := mnTruncBRight(varS, 2); Result := SimpleRoundTo(StrToFloat(varS) * 10000, -10); end else if BasicUnit = '亿' then begin varS := mnTruncBRight(varS, 2); Result := SimpleRoundTo(StrToFloat(varS) * 100000000, -6); end else begin mnCreateError(SWrongWanYiStrFormat, [S]); Result := 0; end; end; function mnTimeUnitToChinese(const TimeUnit: mnTTimeUnit; const ForDuration: Boolean = False): string; begin case TimeUnit of tuYear: Result := mnChooseStr(ForDuration, '年', '年'); tuMonth: Result := mnChooseStr(ForDuration, '个月', '月'); tuDay: Result := mnChooseStr(ForDuration, '天', '日'); tuHour: Result := mnChooseStr(ForDuration, '小时', '时'); tuMinute: Result := mnChooseStr(ForDuration, '分钟', '分'); tuSecond: Result := mnChooseStr(ForDuration, '秒', '秒'); else mnCreateError(SIllegalTimeUnit); end; end; function mnLunarDateToChinese(const LunarDate: mnTLunarDate; const Capital: Boolean = False; const Zero: string = '零'): string; begin if LunarDate.Year = 0 then Result := '' else Result := mnChineseNumber(LunarDate.Year, Capital, Zero) + '年'; if LunarDate.Month = 0 then Result := Result + mnChooseStr(LunarDate.Day = 0, '', '某月') else begin if LunarDate.IsLeapMonth then Result := Result + '闰'; if (LunarDate.Month = 1) and not LunarDate.IsLeapMonth then Result := Result + '正月' else Result := Result + mnChineseInt(LunarDate.Month, Capital, Zero) + '月'; end; if LunarDate.Day = 0 then Result := Result + '' else begin if mnBetweenII(LunarDate.Day, 21, 29) then begin Result := Result + '廿'; Result := Result + mnChineseInt(LunarDate.Day mod 10, Capital, Zero); end else begin if LunarDate.Day <= 10 then Result := Result + '初'; Result := Result + mnChineseInt(LunarDate.Day, Capital, Zero); end; end; end; function mnConstellation12ToChinese(const Constellation12: mnTConstellation12): string; begin case Constellation12 of ctAries: Result := '白羊'; ctTaurus: Result := '金牛'; ctGemini: Result := '双子'; ctCancer: Result := '巨蟹'; ctLeo: Result := '狮子'; ctVirgo: Result := '处女'; ctLibra: Result := '天秤'; ctScorpio: Result := '天蝎'; ctSagittarius: Result := '射手'; ctCapricorn: Result := '摩羯'; ctAquarius: Result := '水瓶'; ctPisces: Result := '双鱼'; else mnNeverGoesHere; end; end; function mnAnimal12ToChinese(const Animal12: mnTAnimal12): string; begin case Animal12 of atRat: Result := '鼠'; atOx: Result := '牛'; atTiger: Result := '虎'; atRabbit: Result := '兔'; atDragon: Result := '龙'; atSnake: Result := '蛇'; atHorse: Result := '马'; atRam: Result := '羊'; atMonkey: Result := '猴'; atRooster: Result := '鸡'; atDog: Result := '狗'; atPig: Result := '猪'; else mnNeverGoesHere; end; end; end.
unit dbTest; interface uses TestFramework, ZConnection, ZDataset, Classes; type TdbTest = class (TTestCase) protected ScriptDirectory: String; ZConnection: TZConnection; ZQuery: TZQuery; // подготавливаем данные для тестирования procedure SetUp; override; // возвращаем данные для тестирования procedure TearDown; override; // получение поличества записей procedure DirectoryLoad(Directory: string); // procedure FileLoad(FileName: string); public // загрузка процедура из определенной директории procedure ProcedureLoad; virtual; procedure Test; virtual; end; var // Список добавленных Id InsertedIdObjectList: TStringList; // Список добавленных дефолтов DefaultValueList: TStringList; // Список добавленных Id InsertedIdMovementItemList: TStringList; // Список добавленных Id InsertedIdMovementList: TStringList; implementation uses zLibUtil, SysUtils, ObjectTest, UnilWin; { TdbTest } procedure TdbTest.SetUp; begin inherited; ZConnection := TConnectionFactory.GetConnection; ZConnection.Connected := true; ZQuery := TZQuery.Create(nil); ZQuery.Connection := ZConnection; end; procedure TdbTest.TearDown; begin inherited; if Assigned(InsertedIdMovementItemList) then with TMovementItemTest.Create do while InsertedIdMovementItemList.Count > 0 do Delete(StrToInt(InsertedIdMovementItemList[0])); if Assigned(InsertedIdMovementList) then with TMovementTest.Create do while InsertedIdMovementList.Count > 0 do Delete(StrToInt(InsertedIdMovementList[0])); if Assigned(InsertedIdObjectList) then with TObjectTest.Create do while InsertedIdObjectList.Count > 0 do Delete(StrToInt(InsertedIdObjectList[0])); ZConnection.Free; ZQuery.Free; end; procedure TdbTest.DirectoryLoad(Directory: string); var iFilesCount: Integer; saFound: TStrings; i: integer; begin saFound := TStringList.Create; try FilesInDir('*.sql', Directory, iFilesCount, saFound); TStringList(saFound).Sort; for I := 0 to saFound.Count - 1 do ExecFile(saFound[i], ZQuery); finally saFound.Free end; end; procedure TdbTest.FileLoad(FileName: string); begin ExecFile(FileName, ZQuery); end; procedure TdbTest.ProcedureLoad; var iFilesCount: Integer; saFound: TStrings; i: integer; begin DirectoryLoad(ScriptDirectory); end; procedure TdbTest.Test; begin end; initialization InsertedIdObjectList := TStringList.Create; InsertedIdObjectList.Sorted := true; DefaultValueList := TStringList.Create; InsertedIdMovementItemList := TStringList.Create; InsertedIdMovementItemList.Sorted := true;; InsertedIdMovementList := TStringList.Create; InsertedIdMovementList.Sorted := true; end.
unit FindUnit.ResultsImportanceCalculator; interface uses FindUnit.Settings, System.Classes, System.Math; type TResultImportanceCalculator = class(TObject) private FResult: TStrings; FBaseSearchString: string; FCurClass: string; FMostRelevantIdx: integer; function GetCurClass(ClassName: string): string; function GetPointsForItem(Item: string): Integer; function LevenshteinDistance(Item1, Item2: string): integer; function RodrigoDistanceCalculator(Item1, Item2: string): Integer; public procedure Config(Results: TStrings; BaseSearchString: string); procedure Process; property MostRelevantIdx: integer read FMostRelevantIdx write FMostRelevantIdx; end; implementation uses FindUnit.Utils, System.StrUtils, System.SysUtils; { TResultImportanceCalculator } function TResultImportanceCalculator.LevenshteinDistance(Item1, Item2: string): integer; var d : array of array of integer; i,j,cost : integer; begin { Compute the edit-distance between two strings. Algorithm and description may be found at either of these two links: http://en.wikipedia.org/wiki/Levenshtein_distance http://www.google.com/search?q=Levenshtein+distance } //initialize our cost array SetLength(d,Length(Item1)+1); for i := Low(d) to High(d) do begin SetLength(d[i],Length(Item2)+1); end; for i := Low(d) to High(d) do begin d[i,0] := i; for j := Low(d[i]) to High(d[i]) do begin d[0,j] := j; end; end; //store our costs in a 2-d grid for i := Low(d)+1 to High(d) do begin for j := Low(d[i])+1 to High(d[i]) do begin if Item1[i] = Item2[j] then begin cost := 0; end else begin cost := 1; end; //to use "Min", add "Math" to your uses clause! d[i,j] := Min(Min( d[i-1,j]+1, //deletion d[i,j-1]+1), //insertion d[i-1,j-1]+cost //substitution ); end; //for j end; //for i //now that we've stored the costs, return the final one Result := d[Length(Item1),Length(Item2)]; //dynamic arrays are reference counted. //no need to deallocate them end; procedure TResultImportanceCalculator.Config(Results: TStrings; BaseSearchString: string); begin FBaseSearchString := Trim(BaseSearchString); FResult := Results; end; function TResultImportanceCalculator.GetCurClass(ClassName: string): string; var Base: string; begin Base := ReverseString(FBaseSearchString); if TextExists('-', Base, True) then Result := Trim(Fetch(Base, '-')); Result := ReverseString(Trim(Fetch(Base, '.'))); end; function TResultImportanceCalculator.GetPointsForItem(Item: string): Integer; begin if GlobalSettings.UseDefaultSearchMatch then Result := RodrigoDistanceCalculator(Item, FBaseSearchString) else Result := LevenshteinDistance(Item, FBaseSearchString); end; procedure TResultImportanceCalculator.Process; var iItem: Integer; MostImportantItemPoints: Integer; CurPoints: Integer; begin FMostRelevantIdx := -1; FCurClass := GetCurClass(FCurClass); MostImportantItemPoints := -100000; for iItem := 0 to FResult.Count -1 do begin CurPoints := GetPointsForItem(FResult[iItem]); if CurPoints > MostImportantItemPoints then begin MostImportantItemPoints := CurPoints; FMostRelevantIdx := iItem; end; end; end; function TResultImportanceCalculator.RodrigoDistanceCalculator(Item1, Item2: string): Integer; var FullClass: string; function MatchesFullName: Boolean; begin Result := FCurClass.ToUpper = GetCurClass(Item2).ToUpper; end; function MatchesPlusSpace: Boolean; begin Result := String(Item1.ToUpper + ' ').Contains(GetCurClass(Item2).ToUpper + ' '); end; begin FullClass := '.' + Item2; if TextExists(FullClass, Item1, True) then begin Result := 1000 + (1000 - Length(Item1)); if MatchesFullName then Inc(Result, 100); if MatchesPlusSpace then Inc(Result, 100); end else if TextExists(FullClass, Item1, False) then begin Result := 100 + (100 - Length(Item1)); if MatchesFullName then Inc(Result, 50); if MatchesPlusSpace then Inc(Result, 50); end else begin Result := 0 - Item1.Length; if MatchesFullName then Inc(Result, 5); if MatchesPlusSpace then Inc(Result, 5); end end; end.
unit UCheckSeverDown; interface uses windows, messages, Classes, Controls, SysUtils, U2chTicket, UAsync, StrSub, StrUtils; type TCheckServerDown = class(TObject) protected lastModified: String; procGet: TAsyncReq; Content: TStringList; FResponse: TNotifyEvent; procedure OnDone(Sender: TASyncReq); procedure Response(AAsyncReq: TAsyncReq); public constructor Create; destructor Destroy; override; function InitInfo: Boolean; function CheckDown(Domain: String): Boolean; property OnResponse: TNotifyEvent read FResponse write FResponse; end; var CheckServerDownInst: TCheckServerDown; implementation uses Main; const SERVER_FOR_DOWNCHECK = 'http://users72.psychedance.com/imode.html'; SERVER_OK = '›'; SERVER_DOWN ='~'; TMPFILENAME = 'serverdown'; { TCheckServerDown } constructor TCheckServerDown.Create; begin lastModified := ''; procGet := nil; Content := TStringList.Create; end; destructor TCheckServerDown.Destroy; begin Content.Free; inherited; end; procedure TCheckServerDown.OnDone(Sender: TASyncReq); var index: Integer; TmpList: TStringList; stream: TPSStream; begin if Sender <> procGet then exit; procGet := nil; Main.Log('yusers72.psychedance.comz:' + Sender.IdHTTP.ResponseText); case Sender.IdHTTP.ResponseCode of 200: begin TmpList := TStringList.Create; TmpList.Text := Sender.Content; TmpList.SaveToFile(i2ch.GetLogDir + '\' + TMPFILENAME + '.html'); stream := TPSStream.Create(Sender.GetLastModified); try stream.SaveToFile(i2ch.GetLogDir + '\' + TMPFILENAME + '.idb'); except end; stream.Free; Content.Clear; for index := 0 to TmpList.Count - 1 do begin if AnsiStartsStr(SERVER_OK, TmpList.Strings[index]) or AnsiStartsStr(SERVER_DOWN, TmpList.Strings[index]) then Content.Add(TmpList.Strings[index]); end; TmpList.Free; end; 304: begin if not FileExists(i2ch.GetLogDir + '\' + TMPFILENAME + '.html') then Content.Clear else begin TmpList := TStringList.Create; TmpList.LoadFromFile(i2ch.GetLogDir + '\' + TMPFILENAME + '.html'); Content.Clear; for index := 0 to TmpList.Count - 1 do begin if AnsiStartsStr(SERVER_OK, TmpList.Strings[index]) or AnsiStartsStr(SERVER_DOWN, TmpList.Strings[index]) then Content.Add(TmpList.Strings[index]); end; TmpList.Free; end; end; else Content.Clear; end; //case Response(Sender); end; procedure TCheckServerDown.Response(AAsyncReq: TAsyncReq); begin if Assigned(FResponse) then FResponse(Self); end; function TCheckServerDown.InitInfo: Boolean; var stream: TPSStream; begin if FileExists(i2ch.GetLogDir + '\' + TMPFILENAME + '.html') and FileExists(i2ch.GetLogDir + '\' + TMPFILENAME + '.idb') then begin stream := TPSStream.Create(''); try stream.LoadFromFile(i2ch.GetLogDir + '\' + TMPFILENAME + '.idb'); lastModified := stream.DataString; except end; stream.Free; end; procGet := AsyncManager.Get(SERVER_FOR_DOWNCHECK, OnDone, ticket2ch.OnChottoPreConnect, lastModified); result := (procGet <> nil); end; function TCheckServerDown.CheckDown(Domain: String): Boolean; var index: Integer; target: String; begin if Domain = '' then begin result := false; exit; end; target := LeftStr(Domain, Pos('.', Domain) - 1); for index := 0 to Content.Count - 1 do begin if 0 < Pos(target, Content.Strings[index]) then begin if AnsiStartsStr(SERVER_OK, Content.Strings[index]) then result := true else if AnsiStartsStr(SERVER_DOWN, Content.Strings[index]) then result := false else result := true; exit; end; end; result := true; end; end.
unit mnString; interface uses Classes, DB, mnSystem; {-------------------------------- 在半角字符串和全角字符串之间转换。DBC为半角,SBC为全角。 Tested in TestUnit. --------------------------------} function mnDBCToSBC(const S: string): string; function mnSBCToDBC(const S: string): string; {-------------------------------- 查找指定单位在S中的第一次出现或最后一次出现,返回出现的位置。 支持的单位有: - 指定字符 - 指定Delimiters字符集中的任意字符 - 指定字符串(此时返回匹配子串的第一个字符的位置) 对指定单位的查找是大小写敏感的。除不带Ansi的字符串调用外,其余调用都支持MBCS。 如果指定单位没有出现,返回0。 注意一:VCL中的标准LastDelimiter函数,在MBCS上存在bug,因此进行了重写。 注意二:mnFirstPos和mnAnsiFirstPos等同于VCL中的Pos和AnsiPos,故略去。 Tested in TestUnit. --------------------------------} function mnLastChar (const Ch: Char; const S: string): Integer; function mnFirstChar(const Ch: Char; const S: string): Integer; function mnLastDelimiter (const Delimiters, S: string): Integer; function mnFirstDelimiter(const Delimiters, S: string): Integer; function mnLastPos (const Substr, S: string): Integer; function mnAnsiLastPos(const Substr, S: string): Integer; {-------------------------------- 从Offset开始,在S中查找指定子串。 如果没有找到任何SubStr,或Offset小于1,或Offset大于S的长度,返回0。 同VCL中的标准PosEx函数类似,但支持MBCS。有趣的是,VCL中包含了Pos、PosEx和AnsiPos,仅仅缺少AnsiPosEx。 Tested in TestUnit. --------------------------------} function mnAnsiPosEx(const SubStr, S: string; Offset: Integer = 1): Integer; {-------------------------------- 确保字符串中的指定字节没有截断一个双字节字符。 如果指定字节是双字节字符的首字节,则使之指向其尾字节。 Tested in TestUnit. --------------------------------} function mnSettleByte(const S: string; const Index: Integer): Integer; {-------------------------------- 判断一个字符是否是纯ASCII字符,或一个字符串是否所有字符都是纯ASCII字符。 纯ASCII字符指ASCII值小于128的字符。 Tested in TestUnit. --------------------------------} function mnIsASCIIChar(const Ch: Char): Boolean; inline; function mnIsASCIIStr(const S: string): Boolean; {-------------------------------- 判断指定Delimiters字符集中的所有字符,是否都在S中出现。支持MBCS。 Tested in TestUnit. --------------------------------} function mnContainDelimiters(const Delimiters, S: string): Boolean; {-------------------------------- 判断一个字符串是否以指定子串开始,或以指定子串结束。不支持MBCS。 VCL中的标准StartsStr和EndsStr函数支持MBCS,因此在不需要MBCS的场合会降低效率。 Tested in TestUnit. --------------------------------} function mnStartsStr(const SubStr, S: string): Boolean; function mnEndsStr(const SubStr, S: string): Boolean; {-------------------------------- 统计一个字符串的开始处或结束处,指定子串连续出现的次数。不支持MBCS。 如果SubStr为空串,返回0。 Tested in TestUnit. --------------------------------} function mnStartsStrCount(const SubStr, S: string): Integer; function mnEndsStrCount(const SubStr, S: string): Integer; {-------------------------------- 将SubStr插入到S的指定位置,插入后,子串第一个字符的位置为Index。和MBCS无关。 如果Index小于1,则插入到最前面。如果Index大于S的长度,则插入到最后面。 Tested in TestUnit. --------------------------------} function mnInsertStr(const SubStr, S: string; const Index: Integer): string; {-------------------------------- 从S中删除第Index个开始的连续Count个字符。和MBCS无关。 如果Index小于1或大于S的长度,则不进行任何操作。如果Count过长,则删除到字符串末尾为止。 和mnTruncBMiddle功能相同。 Tested in TestUnit. --------------------------------} function mnDeleteStr(const S: string; const Index, Count: Integer): string; {-------------------------------- 截短一个字符串,从左边或右边截去指定长度的子串。支持MBCS。 如果长度过长,将截去所有内容而最终返回空串。 Tested in TestUnit. --------------------------------} function mnTruncLeft (const S: string; Count: Integer): string; function mnTruncRight(const S: string; Count: Integer): string; {-------------------------------- 截去一个字符串的中间部分、指定长度的子串。支持MBCS。 如果长度过长,将截到字符串末尾为止。 如果Start越界,将抛出异常。 Tested in TestUnit. --------------------------------} function mnTruncMiddle(const S: string; Start, Count: Integer): string; {-------------------------------- 截短一个字符串,从左边或右边截去指定数量的字节。和MBCS无关。 如果字节数过多,将截去所有内容而最终返回空串。 Tested in TestUnit. --------------------------------} function mnTruncBLeft (const S: string; Count: Integer): string; inline; function mnTruncBRight(const S: string; Count: Integer): string; inline; {-------------------------------- 截去一个字符串的中间部分、指定数量的字节。和MBCS无关。 如果长度过长,将截到字符串末尾为止。 如果Start越界,将抛出异常。 和mnDeleteStr功能相同。 Tested in TestUnit. --------------------------------} function mnTruncBMiddle(const S: string; Start, Count: Integer): string; {-------------------------------- 得到S的子串。方式是,查找指定单位在S中的第一次出现或最后一次出现,返回初秀之前或末日秀之后的子串。 支持的单位有: - 指定字符 - 指定Delimiters字符集中的任意字符 - 指定字符串 对指定单位的查找是大小写敏感的。除不带Ansi的字符串调用外,其余调用都支持MBCS。 如果指定单位没有出现,返回空串。 Tested in TestUnit. --------------------------------} function mnLeftStrToChar (const Ch: Char; const S: string): string; function mnRightStrToChar(const Ch: Char; const S: string): string; function mnLeftStrToDelimiter (const Delimiters, S: string): string; function mnRightStrToDelimiter(const Delimiters, S: string): string; function mnLeftStrTo (const Substr, S: string): string; function mnRightStrTo (const Substr, S: string): string; function mnAnsiLeftStrTo (const Substr, S: string): string; function mnAnsiRightStrTo(const Substr, S: string): string; {-------------------------------- 截短S。方式是,查找指定单位在S中的第一次出现或最后一次出现,将初秀之前或末日秀之后的子串,连同指定单位一起截去。 支持的单位有: - 指定字符 - 指定Delimiters字符集中的任意字符 - 指定字符串 对指定单位的查找是大小写敏感的。除不带Ansi的字符串调用外,其余调用都支持MBCS。 如果指定单位没有出现,不截去任何字符,返回S。 Tested in TestUnit. --------------------------------} function mnTruncLeftOverChar (const Ch: Char; const S: string): string; function mnTruncRightOverChar(const Ch: Char; const S: string): string; function mnTruncLeftOverDelimiter (const Delimiters, S: string): string; function mnTruncRightOverDelimiter(const Delimiters, S: string): string; function mnTruncLeftOver (const Substr, S: string): string; function mnTruncRightOver (const Substr, S: string): string; function mnAnsiTruncLeftOver (const Substr, S: string): string; function mnAnsiTruncRightOver(const Substr, S: string): string; {-------------------------------- 截短S并得到其被截去的子串。 方式是,查找指定单位在S中的第一次出现或最后一次出现,返回初秀之前或末日秀之后的子串,并截短S本身。 相当于LeftRightStrTo和TruncLeftRightOver的组合。 支持的单位有: - 指定字符 - 指定Delimiters字符集中的任意字符 - 指定字符串 对指定单位的查找是大小写敏感的。除不带Ansi的字符串调用外,其余调用都支持MBCS。 如果指定单位没有出现,返回空串,同时S不变。 Tested in TestUnit. --------------------------------} function mnCutLeftByChar (const Ch: Char; var S: string): string; function mnCutRightByChar(const Ch: Char; var S: string): string; function mnCutLeftByDelimiter (const Delimiters: string; var S: string): string; function mnCutRightByDelimiter(const Delimiters: string; var S: string): string; function mnCutLeftBy (const Substr: string; var S: string): string; function mnCutRightBy (const Substr: string; var S: string): string; function mnAnsiCutLeftBy (const Substr: string; var S: string): string; function mnAnsiCutRightBy(const Substr: string; var S: string): string; {-------------------------------- 如果S以指定单位开始,或以指定单位结束,则截去指定单位,返回S的剩余部分。否则,直接返回S。 如果S以连续多个指定单位开始或结束,则只会截去一个指定单位。 相当于先用StartsEndsStr判断,若满足条件,则使用TruncLeftRightOver。 支持的单位有: - 指定字符 - 指定Delimiters字符集中的任意字符 - 指定字符串 对指定单位的判断是大小写敏感的。除不带Ansi的字符串调用外,其余调用都支持MBCS。 Tested in TestUnit. --------------------------------} function mnRemoveLeftChar (const Ch: Char; const S: string): string; function mnRemoveRightChar(const Ch: Char; const S: string): string; function mnRemoveLeftDelimiter (const Delimiters, S: string): string; function mnRemoveRightDelimiter(const Delimiters, S: string): string; function mnRemoveLeft (const Substr, S: string): string; function mnRemoveRight (const Substr, S: string): string; function mnAnsiRemoveLeft (const Substr, S: string): string; function mnAnsiRemoveRight(const Substr, S: string): string; {-------------------------------- 确保S以指定单位开始或结束,即,若S不以指定单位开始或结束,则在S的前面或后面加上指定单位。 支持的单位有: - 指定字符 - 指定Delimiters字符集中的任意字符 - 指定字符串 对指定单位的判断是大小写敏感的。除不带Ansi的字符串调用外,其余调用都支持MBCS。 Tested in TestUnit. --------------------------------} function mnEnsureLeftChar (const Ch: Char; const S: string): string; function mnEnsureRightChar(const Ch: Char; const S: string): string; function mnEnsureLeft (const Substr, S: string): string; function mnEnsureRight (const Substr, S: string): string; function mnAnsiEnsureLeft (const Substr, S: string): string; function mnAnsiEnsureRight(const Substr, S: string): string; {-------------------------------- 如果S不为空,则在开始处或结束处加上指定单位。和MBCS无关。 支持的单位有: - 指定字符 - 指定字符串 Tested in TestUnit. --------------------------------} function mnAppendLeftCharIfNotEmpty (const Ch: Char; const S: string): string; function mnAppendRightCharIfNotEmpty(const Ch: Char; const S: string): string; function mnAppendLeftIfNotEmpty (const Substr, S: string): string; function mnAppendRightIfNotEmpty (const Substr, S: string): string; {-------------------------------- 统计在S中指定单位的出现次数。 支持的单位有: - 指定字符 - 指定Delimiters字符集中的任意字符 - 指定字符串 对指定单位的查找是大小写敏感的。除不带Ansi的字符串调用外,其余调用都支持MBCS。 Tested in TestUnit. --------------------------------} function mnCountChar(const Ch: Char; const S: string): Integer; function mnCountDelimiter(const Delimiters, S: string): Integer; function mnCount(const Substr, S: string): Integer; function mnAnsiCount(const Substr, S: string): Integer; {-------------------------------- 删去S中所有的指定单位。 支持的单位有: - 指定字符 - 指定Delimiters字符集中的任意字符 - 指定字符串 对指定单位的查找是大小写敏感的。除不带Ansi的字符串调用外,其余调用都支持MBCS。 Tested in TestUnit. --------------------------------} function mnDiscardChar(const Ch: Char; const S: string): string; function mnDiscardDelimiter(const Delimiters, S: string): string; function mnDiscard(const Substr, S: string): string; function mnAnsiDiscard(const Substr, S: string): string; {-------------------------------- 在S中,所有的指定单位如果连续出现,删去多余的,仅保留一份。 非连续出现的子串全部保留。 支持的单位有: - 指定字符 - 指定Delimiters字符集中的任意字符(字符集中不同字符的连续出现也会被处理) - 指定字符串 对指定单位的查找是大小写敏感的。除不带Ansi的字符串调用外,其余调用都支持MBCS。 Tested in TestUnit. --------------------------------} function mnShrinkChar(const Ch: Char; const S: string): string; function mnShrinkDelimiter(const Delimiters, S: string): string; function mnShrink(const Substr, S: string): string; function mnAnsiShrink(const Substr, S: string): string; {-------------------------------- 在S中,截去左边和右边所有的指定单位。 支持的单位有: - 指定字符串 - 指定字符串数组中的任意字符串 对指定单位的匹配是大小写敏感的。不支持MBCS。 Tested in TestUnit. --------------------------------} function mnTrim(const SubStr: string; const S: string): string; function mnTrimStrs(const SubStrs: array of string; const S: string): string; {-------------------------------- 将S往左或往右扩展到新的长度,不足的位置用FillingChar补齐。 Tested in TestUnit. --------------------------------} function mnExpandLeft (const S: string; const NewLength: Integer; const FillingChar: Char): string; function mnExpandRight(const S: string; const NewLength: Integer; const FillingChar: Char): string; {-------------------------------- 将一个整数扩展成需要的长度,不足的位置在前面缺省用0补齐。 Tested in TestUnit. --------------------------------} function mnExpandInt(const Value: Integer; const RequiredLength: Integer; const FillingChar: Char = '0'): string; type {-------------------------------- 用于调用mnCompareStr函数时传入参数,以指定比较方式。 scoCaseSensitive:大小写敏感。 scoWholeWordOnly:整词匹配。 --------------------------------} mnTStrComparisonOption = (scoCaseSensitive, scoWholeWordOnly); mnTStrComparisonOptions = set of mnTStrComparisonOption; {-------------------------------- 比较两个字符串,可传入是否大小写敏感或整词匹配的设置。 如果非整词匹配,则使用SMajor作为主串,SMinor作为子串。 ResultWhenMinorIsEmpty表示当子串为空串时,如何返回。 Tested in TestUnit. --------------------------------} function mnCompareStr(SMajor, SMinor: string; const Options: mnTStrComparisonOptions; const ResultWhenMinorIsEmpty: Boolean = True): Boolean; {-------------------------------- 以数字方式比较两个字符串。 如果A>B,返回值>0。如果A=B,返回值=0。如果A<B,返回值<0。 以数字方式是指,将字符串左边尽可能多的字符转换为整数,并对整数进行比较。(不支持负数) 如果某一字符串左边没有数字,则它大于另一有数字的字符串。 如果两个字符串左边都没有数字,则使用普通的字符串比较AnsiCompareStr。 Tested in TestUnit. --------------------------------} function mnCompareStrInNumberStyle(const SA: string; const SB: string): Integer; {-------------------------------- 在S中查找所有指定子串,并替换成新串。 该查找是大小写敏感的。 替换不是递归的。也就是说,如果替换的新串导致了新的子串匹配,这个新匹配不会再被替换。 VCL中的标准AnsiReplaceStr函数支持MBCS,因此在不需要MBCS的场合会降低效率。 Tested in TestUnit. --------------------------------} function mnReplaceStr(const S, OldStr, NewStr: string): string; {-------------------------------- 与mnReplaceStr相似,但使用整字匹配的查找。 Tested in TestUnit. --------------------------------} function mnReplaceStrWholeWord(const S, OldStr, NewStr: string): string; {-------------------------------- 与mnReplaceStr相似,但只替换指定子串的第一次出现。 VCL中的标准StringReplace函数支持MBCS,因此在不需要MBCS的场合会降低效率。 Tested in TestUnit. --------------------------------} function mnReplaceStrOnce(const S, OldStr, NewStr: string): string; {-------------------------------- 从Offset开始,在S中查找以SubstrHead开始、以SubstrTail结尾的子串。 该查找是大小写敏感的。 如果Offset没有越界,并且子串能够被找到,返回True。查找失败时返回False,只有Head却没有Tail,也意味着失败。 当返回True时,SubstrBeginPos返回该子串的起始位置(第一个字符的索引),SubstrEndPos返回该子串的结束位置(最后一个字符的索引加1), SubstrBody返回Head和Tail之间的子串内容。 如果只需要Body而不需要BeginPos和EndPos,可以调用第二种简洁的重载形式。 Tested in TestUnit. --------------------------------} function mnFindStrBetween (const S, SubstrHead, SubstrTail: string; var SubstrBeginPos, SubstrEndPos: Integer; var SubstrBody: string; Offset: Integer = 1): Boolean; overload; function mnFindStrBetween (const S, SubstrHead, SubstrTail: string; var SubstrBody: string; Offset: Integer = 1): Boolean; overload; function mnAnsiFindStrBetween(const S, SubstrHead, SubstrTail: string; var SubstrBeginPos, SubstrEndPos: Integer; var SubstrBody: string; Offset: Integer = 1): Boolean; overload; function mnAnsiFindStrBetween(const S, SubstrHead, SubstrTail: string; var SubstrBody: string; Offset: Integer = 1): Boolean; overload; {-------------------------------- 在S中查找所有以SubstrHead开始、以SubstrTail结尾的子串,并替换成新串。 新串的内容可以是指定的固定串,也可以是以原子串的Body为name,从NameValuePairs中查出的value。 该查找是大小写敏感的。 替换不是递归的。也就是说,如果替换的新串导致了新的子串匹配,这个新匹配不会再被替换。 如果没有指定SubstrHead和SubstrTail,则使用mnStdSeparator1作为SubstrHead和SubstrTail。 Tested in TestUnit. --------------------------------} function mnReplaceStrBetween (const S, SubstrHead, SubstrTail, NewStr: string): string; overload; function mnReplaceStrBetween (const S, SubstrHead, SubstrTail: string; NameValuePairs: TStrings): string; overload; function mnReplaceStrBetween (const S, NewStr: string): string; overload; function mnReplaceStrBetween (const S: string; NameValuePairs: TStrings): string; overload; function mnAnsiReplaceStrBetween(const S, SubstrHead, SubstrTail, NewStr: string): string; overload; function mnAnsiReplaceStrBetween(const S, SubstrHead, SubstrTail: string; NameValuePairs: TStrings): string; overload; function mnAnsiReplaceStrBetween(const S, NewStr: string): string; overload; function mnAnsiReplaceStrBetween(const S: string; NameValuePairs: TStrings): string; overload; {-------------------------------- 将一组数据联接成单个字符串。每两个相连的数据元素间,用Connector连接。 HasBorder表示是否需要在第一个元素前和最后一个元素后放置Connector。 如果数据组为空,则联接出空串,再根据HasBorder判断是否要在两边放置Connector。 数据组的来源可以是: - 一个静态或动态的字符串数组 - 一个TStrings变量 - 一个DataSet中所有记录在指定字段上的值 - 一个Fields在指定的多个字段上的值 Tested in TestUnit. --------------------------------} function mnCombine(const Strs: array of string; const Connector: string = mnStdConnector1; const HasBorder: Boolean = False): string; overload; function mnCombine(Strs: TStrings; const Connector: string = mnStdConnector1; const HasBorder: Boolean = False): string; overload; function mnCombine(DataSet: TDataSet; const FieldName: string; const Connector: string = mnStdConnector1; const HasBorder: Boolean = False): string; overload; function mnCombine(Fields: TFields; FieldNames: mnTFieldNames; const Connector: string = mnStdConnector1; const HasBorder: Boolean = False): string; overload; function mnCombine(Fields: TFields; FieldNames: TStrings; const Connector: string = mnStdConnector1; const HasBorder: Boolean = False): string; overload; function mnCombine(Fields: TFields; const FieldNames: array of string; const Connector: string = mnStdConnector1; const HasBorder: Boolean = False): string; overload; {-------------------------------- 将单个字符串分割成一组字符串,在每个Separator处进行分割。 返回分割后的字符串数量。 HasBorder表示在第一个元素前和最后一个元素后,是否存在Separator。 分割后的字符串组放在OutSplittedStrs中,但OutSplittedStrs原有的数据不会清空。 注意:如果原始字符串为空串(除去HasBorder的影响后),则分割后也会得到一个空串,而不是得到零个字符串。 Tested in TestUnit. --------------------------------} function mnSplit (const S: string; OutSplittedStrs: TStrings; const Separator: string = mnStdSeparator1; const HasBorder: Boolean = False): Integer; function mnAnsiSplit(const S: string; OutSplittedStrs: TStrings; const Separator: string = mnStdSeparator1; const HasBorder: Boolean = False): Integer; {-------------------------------- 将一个字符串分割成一组字符串。分隔符不是固定的,而是任意以SeparatorHead开始、以SeparatorTail结尾的子串。 返回分割后的字符串数量。 分割后的字符串组放在OutSplittedStrs中,但OutSplittedStrs原有的数据不会清空。 所有分隔符的Body,也就是Head和Tail之间的内容,存放在OutSeparatorBodies中,但OutSeparatorBodies原有的数据不会被清空。 注意:如果原始字符串为空串,则分割后也会得到一个空串,而不是得到零个字符串。 Tested in TestUnit. --------------------------------} function mnSplitBetween (const S: string; OutSplittedStrs: TStrings; OutSeparatorBodies: TStrings; const SeparatorHead, SeparatorTail: string): Integer; function mnAnsiSplitBetween(const S: string; OutSplittedStrs: TStrings; OutSeparatorBodies: TStrings; const SeparatorHead, SeparatorTail: string): Integer; {-------------------------------- 将一个字符串分割成一组字符串,在每个固定的长度处进行分割。和MBCS无关。 返回分割后的字符串数量。 分割后的字符串组放在OutSplittedStrs中,但OutSplittedStrs原有的数据不会清空。 注意:如果原始字符串为空串,则分割后也会得到一个空串,而不是得到零个字符串。 Tested in TestUnit. --------------------------------} function mnSplitByLen(const S: string; OutSplittedStrs: TStrings; const SplittedLen: Integer): Integer; {-------------------------------- 字符串模式,可用来匹配字符串,并对符合模式的字符串,从中提取出参数的值。 模式中允许有0或多个参数,每个参数以ParamHead开始,以ParamTail结尾。Head和Tail之间的Body就是参数名称。 参数可以匹配任意字符,模式中参数以外的字符,称为固定段,必须精确匹配。 例如,设ParamHead和ParamTail都是“%”,则“abc%p1%def%p2%gh”表示有名为p1和p2的两个参数的模式,它匹配“abc111def222gh”。 注意:格式里不能有两个连续的参数,否则系统将无法分清每个参数的值。 还可用来实现字符串。 即提供一个NameValuePairs,对每个参数,根据参数名称,从NameValuePairs中查出对应值,替换回模式串里。 等同于mnReplaceStrBetween和mnAnsiReplaceStrBetween。但在需要多次实现时,由于不用每次都重新解析参数,因而可提高执行效率。 在某种意义上,实现可看成是匹配的逆向操作,反之亦然。 注意:在实现时,格式里可以有两个连续的参数,这不会有任何逻辑问题。 Tested in TestUnit. --------------------------------} type mnTStringPattern = class private FPattern: string; FPatternSections: mnTStrList; FPatternParams: mnTStrList; FPatternParsed: Boolean; procedure SetPattern(const Value: string); public // 解析模式到PatternSections和PatternParams。带Ansi的支持MBCS procedure ParsePattern; procedure AnsiParsePattern; public // 模式串,用来赋值以定义模式 property Pattern: string read FPattern write SetPattern; // 从模式串中解析出的固定段,用来执行匹配 property PatternSections: mnTStrList read FPatternSections; // 从模式串中解析出的参数,用来执行匹配 property PatternParams: mnTStrList read FPatternParams; // 模式串是否已被解析。新赋值的模式串将在第一次匹配或实现时被解析,这样只要模式串没有改变,一次解析后可用来执行多次匹配或实现 property PatternParsed: Boolean read FPatternParsed; // 将整个文本文件加载为模式 procedure LoadPatternFromFile(const FileName: string); overload; private FParamHead: string; FParamTail: string; FIgnoreUnnamedParams: Boolean; FAutoClearPairs: Boolean; public // 定位参数的开始,缺省为mnStdSeparator1 property ParamHead: string read FParamHead write FParamHead; // 定位参数的结束,缺省为mnStdSeparator1 property ParamTail: string read FParamTail write FParamTail; // 如果为True,则没有名字的参数不会被存入ParamPairs。缺省为True property IgnoreUnnamedParams: Boolean read FIgnoreUnnamedParams write FIgnoreUnnamedParams; // 如果为True,则在每次匹配前会自动清除原有的ParamPairs,缺省为True property AutoClearPairs: Boolean read FAutoClearPairs write FAutoClearPairs; private FWorkStr: string; FParamPairs: mnTStrList; FPartBeginPos: Integer; FPartEndPos: Integer; function GetParamValue(ParamName: string): string; function GetParamValueAsInt(ParamName: string): Integer; function GetParamValueAsFloat(ParamName: string): Extended; function GetParamValueAsDT(ParamName: string): TDateTime; function GetParamValueAsCurr(ParamName: string): Currency; public // 在执行一次匹配后,存储匹配对象字符串 property WorkStr: string read FWorkStr; // 在执行一次成功匹配后,每个参数的值会取出,同参数名一起,组成name-value对存入 property ParamPairs: mnTStrList read FParamPairs; // 在执行一次成功匹配后,可以调用这些属性,根据参数名,从ParamPairs里读取不同类型的参数值 property ParamValue [ParamName: string]: string read GetParamValue; property ParamValueAsInt [ParamName: string]: Integer read GetParamValueAsInt; property ParamValueAsFloat[ParamName: string]: Extended read GetParamValueAsFloat; property ParamValueAsDT [ParamName: string]: TDateTime read GetParamValueAsDT; property ParamValueAsCurr [ParamName: string]: Currency read GetParamValueAsCurr; // 在执行一次成功匹配子串后,返回该子串的起始位置(第一个字符的索引) property PartBeginPos: Integer read FPartBeginPos; // 在执行一次成功匹配子串后,返回该子串的结束位置(最后一个字符的索引加1) property PartEndPos: Integer read FPartEndPos; // 清除ParamPairs里的所有内容 procedure ClearParamPairs; public constructor Create; destructor Destroy; override; public // 匹配一个字符串,返回匹配结果成功或失败。带Ansi的支持MBCS function Match(const S: string): Boolean; function AnsiMatch(const S: string): Boolean; // 从Offset开始,匹配一个字符串的部分子串,返回匹配结果成功或失败。带Ansi的支持MBCS function MatchSub(const S: string; const Offset: Integer = 1): Boolean; function AnsiMatchSub(const S: string; const Offset: Integer = 1): Boolean; // 以上次MatchSub的结束位置作为Offset,继续匹配下一个子串,返回匹配结果成功或失败。带Ansi的支持MBCS function MatchNextSub: Boolean; function AnsiMatchNextSub: Boolean; // 准备开始一个子串序列的匹配,在准备完成后,就可以使用while MatchNextSub do的循环来不断匹配子串 procedure PrepareSubSequence(const S: string); public // 从NameValuePairs根据参数名取值,以实现一个字符串。带Ansi的支持MBCS function Realize(NameValuePairs: TStrings): string; function AnsiRealize(NameValuePairs: TStrings): string; end; var {-------------------------------- 预先准备好的,已实例化的一个mnTStringPattern变量。在临时需要mnTStringPattern时,可以很方便地调用。 --------------------------------} ppPattern: mnTStringPattern; type {-------------------------------- 文本的编码方式,有Ansi、Unicode Little-Endian、Unicode Big-Endian、UTF8等。 --------------------------------} mnTTextEncoding = (teAnsi, teUnicodeLE, teUnicodeBE, teUTF8); const {-------------------------------- 表明文本编码方式的头字节。 --------------------------------} mnUnicodeLEBOM = #$FF#$FE; mnUnicodeBEBOM = #$FE#$FF; mnUTF8BOM = #$EF#$BB#$BF; {-------------------------------- 根据头字节,得到文本的编码方式。 Tested in TestUnit. --------------------------------} function mnGetTextEncoding(const S: string): mnTTextEncoding; {-------------------------------- 以string形式表达WideString。 与直接将WideString赋值给string不同的是,本函数不处理任何编码转换, 而仅仅是将WideString的每个字节逐一变成string的每个字节。 Tested in TestUnit. --------------------------------} function mnExpressWideString(const WS: WideString): string; type {-------------------------------- 特殊的字符串:所有字符全都是数字。 --------------------------------} mnTDigitStr = string; {-------------------------------- 特殊的字符串:所有字符全都是字母或数字。 --------------------------------} mnTDigletStr = string; {-------------------------------- 生成一个长度指定、内容随机的字符串。 mnRandomStr:内容在Candidates字符串中随机选择。若Candidates为空串,则在任意字符中随机选择。 mnRandomDigitStr:内容在全部数字字符中随机选择。 mnRandomDigletStr:内容在全部字母加数字字符中随机选择。 mnRandomUpperDigletStr:内容在全部大写字母加数字字符中随机选择。 mnRandomLowerDigletStr:内容在全部小写字母加数字字符中随机选择。 Tested in TestUnit. --------------------------------} function mnRandomStr (const Len: Integer; const Candidates: string = ''): string; function mnRandomDigitStr (const Len: Integer): mnTDigitStr; function mnRandomDigletStr(const Len: Integer): mnTDigletStr; function mnRandomUpperDigletStr(const Len: Integer): mnTDigletStr; function mnRandomLowerDigletStr(const Len: Integer): mnTDigletStr; {-------------------------------- 将普通字符串编码解码成全都是数字的字符串,或全都是字母或数字的字符串。 Capital指示全都是字母或数字的字符串里,字母使用大写或小写。 Tested in TestUnit. --------------------------------} function mnEncodeToDigitStr (const S: string): mnTDigitStr; function mnDecodeFromDigitStr (const S: mnTDigitStr): string; function mnEncodeToDigletStr (const S: string; const Capital: Boolean = True): mnTDigletStr; function mnDecodeFromDigletStr(const S: mnTDigletStr): string; {-------------------------------- 在字符串里插入大量随机生成的字符进行隐蔽,每个字符用DisguiseLen个字符来掩饰。 掩饰字符可以是任意字符,或全部数字字符,或全部字母加数字字符。 用一个统一的显露函数。 Capital指示用作掩饰的全部字母加数字字符里,字母使用大写或小写。 Tested in TestUnit. --------------------------------} function mnHideStr (const S: string; const DisguiseLen: Integer = 4): string; function mnHideDigitStr (const S: string; const DisguiseLen: Integer = 4): mnTDigitStr; function mnHideDigletStr(const S: string; const Capital: Boolean = True; const DisguiseLen: Integer = 4): mnTDigletStr; function mnRevealStr (const S: string; const DisguiseLen: Integer = 4): string; implementation uses SysUtils, StrUtils, mnResStrsU, Variants, mnFile, Windows; function mnDBCToSBC(const S: string): string; var i: Integer; B: Byte; begin Result := ''; for i := 1 to Length(S) do if ByteType(S, i) = mbSingleByte then begin B := Ord(S[i]); if B = 32 then begin Result := Result + Chr(41377 div 256); Result := Result + Chr(41377 mod 256); end else if (B >= 33) and (B <= 126) then begin Result := Result + Chr((B + 41856) div 256); Result := Result + Chr((B + 41856) mod 256); end else Result := Result + S[i]; end else Result := Result + S[i]; end; function mnSBCToDBC(const S: string): string; var i: Integer; W: Word; begin Result := ''; for i := 1 to Length(S) do if ByteType(S, i) = mbLeadByte then begin W := Ord(S[i]) * 256 + Ord(S[i+1]); if W = 41377 then Result := Result + ' ' else if (W >= 41889) and (W <= 41982) then Result := Result + Chr(W - 41856) else Result := Result + S[i] + S[i+1]; end else if ByteType(S, i) = mbSingleByte then Result := Result + S[i]; end; function mnLastChar (const Ch: Char; const S: string): Integer; begin for Result := Length(S) downto 1 do if (ByteType(S, Result) = mbSingleByte) and (S[Result] = Ch) then Exit; Result := 0; end; function mnFirstChar(const Ch: Char; const S: string): Integer; begin for Result := 1 to Length(S) do if (ByteType(S, Result) = mbSingleByte) and (S[Result] = Ch) then Exit; Result := 0; end; function mnLastDelimiter (const Delimiters, S: string): Integer; var P: PChar; begin P := PChar(Delimiters); for Result := Length(S) downto 1 do if (ByteType(S, Result) = mbSingleByte) and (StrScan(P, S[Result]) <> nil) then Exit; Result := 0; end; function mnFirstDelimiter(const Delimiters, S: string): Integer; var P: PChar; begin P := PChar(Delimiters); for Result := 1 to Length(S) do if (ByteType(S, Result) = mbSingleByte) and (StrScan(P, S[Result]) <> nil) then Exit; Result := 0; end; function mnLastPos (const Substr, S: string): Integer; begin Result := Pos(ReverseString(Substr), ReverseString(S)); if Result > 0 then Result := Length(S) - Length(Substr) - Result + 2; end; function mnAnsiLastPos(const Substr, S: string): Integer; begin Result := AnsiPos(ReverseString(Substr), ReverseString(S)); if Result > 0 then Result := Length(S) - Length(Substr) - Result + 2; end; function mnAnsiPosEx(const SubStr, S: string; Offset: Integer = 1): Integer; begin if (Offset < 1) or (Offset > Length(S)) then Result := 0 else if Offset = 1 then Result := AnsiPos(SubStr, S) else begin mnCreateErrorIf(ByteType(S, Offset) = mbTrailByte, SAnsiPosOffsetOnTrailByte, [Offset, S]); Result := AnsiPos(SubStr, Copy(S, Offset)); if Result <> 0 then Result := Result + Offset - 1; end; end; function mnSettleByte(const S: string; const Index: Integer): Integer; begin if ByteType(S, Index) = mbLeadByte then Result := Index + 1 else Result := Index; end; function mnIsASCIIChar(const Ch: Char): Boolean; inline; begin Result := Ord(Ch) < 128; end; function mnIsASCIIStr(const S: string): Boolean; var ch: Char; begin Result := True; for ch in S do if not mnIsASCIIChar(Ch) then begin Result := False; Exit; end; end; function mnContainDelimiters(const Delimiters, S: string): Boolean; var ch: Char; begin Result := True; for ch in Delimiters do if mnFirstChar(ch, S) = 0 then begin Result := False; Exit; end; end; function mnStartsStr(const SubStr, S: string): Boolean; begin Result := SameStr(SubStr, Copy(S, 1, Length(SubStr))); end; function mnEndsStr(const SubStr, S: string): Boolean; begin Result := SameStr(SubStr, Copy(S, Length(S)-Length(SubStr)+1)); end; function mnStartsStrCount(const SubStr, S: string): Integer; var varS: string; begin if SubStr = '' then begin Result := 0; Exit; end; varS := S; Result := 0; while mnStartsStr(SubStr, varS) do begin varS := Copy(varS, Length(Substr)+1); Inc(Result); end; end; function mnEndsStrCount(const SubStr, S: string): Integer; var varS: string; begin if SubStr = '' then begin Result := 0; Exit; end; varS := S; Result := 0; while mnEndsStr(SubStr, varS) do begin varS := Copy(varS, 1, Length(varS)-Length(Substr)); Inc(Result); end; end; function mnInsertStr(const SubStr, S: string; const Index: Integer): string; begin Result := S; Insert(Substr, Result, Index); end; function mnDeleteStr(const S: string; const Index, Count: Integer): string; begin Result := S; Delete(Result, Index, Count); end; function mnTruncLeft (const S: string; Count: Integer): string; begin Result := mnTruncBLeft(S, Length(LeftStr(S, Count))); end; function mnTruncRight(const S: string; Count: Integer): string; begin Result := mnTruncBRight(S, Length(RightStr(S, Count))); end; function mnTruncMiddle(const S: string; Start, Count: Integer): string; var Mid: string; begin mnCreateErrorIf((Start < 1) or (Start > Length(S)), STruncMiddleIndexError, [Start, Length(S)]); Mid := MidStr(S, Start, Count); Result := Copy(S, 1, Start-1) + Copy(S, Start+Length(Mid)); end; function mnTruncBLeft (const S: string; Count: Integer): string; inline; begin Result := Copy(S, Count+1); end; function mnTruncBRight(const S: string; Count: Integer): string; inline; begin Result := Copy(S, 1, Length(S)-Count); end; function mnTruncBMiddle(const S: string; Start, Count: Integer): string; var Mid: string; begin mnCreateErrorIf((Start < 1) or (Start > Length(S)), STruncBMiddleIndexError, [Start, Length(S)]); Mid := MidBStr(S, Start, Count); Result := Copy(S, 1, Start-1) + Copy(S, Start+Length(Mid)); end; function mnLeftStrToChar (const Ch: Char; const S: string): string; var i: Integer; begin i := mnFirstChar(Ch, S); if i = 0 then Result := '' else Result := Copy(S, 1, i-1); end; function mnRightStrToChar(const Ch: Char; const S: string): string; var i: Integer; begin i := mnLastChar(Ch, S); if i = 0 then Result := '' else Result := Copy(S, i+1); end; function mnLeftStrToDelimiter (const Delimiters, S: string): string; var i: Integer; begin i := mnFirstDelimiter(Delimiters, S); if i = 0 then Result := '' else Result := Copy(S, 1, i-1); end; function mnRightStrToDelimiter(const Delimiters, S: string): string; var i: Integer; begin i := mnLastDelimiter(Delimiters, S); if i = 0 then Result := '' else Result := Copy(S, i+1); end; function mnLeftStrTo (const Substr, S: string): string; var i: Integer; begin i := Pos(Substr, S); if i = 0 then Result := '' else Result := Copy(S, 1, i-1); end; function mnRightStrTo (const Substr, S: string): string; var i: Integer; begin i := mnLastPos(Substr, S); if i = 0 then Result := '' else Result := Copy(S, i+Length(Substr)); end; function mnAnsiLeftStrTo (const Substr, S: string): string; var i: Integer; begin i := AnsiPos(Substr, S); if i = 0 then Result := '' else Result := Copy(S, 1, i-1); end; function mnAnsiRightStrTo(const Substr, S: string): string; var i: Integer; begin i := mnAnsiLastPos(Substr, S); if i = 0 then Result := '' else Result := Copy(S, i+Length(Substr)); end; function mnTruncLeftOverChar (const Ch: Char; const S: string): string; var i: Integer; begin i := mnFirstChar(Ch, S); if i = 0 then Result := S else Result := Copy(S, i+1); end; function mnTruncRightOverChar(const Ch: Char; const S: string): string; var i: Integer; begin i := mnLastChar(Ch, S); if i = 0 then Result := S else Result := Copy(S, 1, i-1); end; function mnTruncLeftOverDelimiter (const Delimiters, S: string): string; var i: Integer; begin i := mnFirstDelimiter(Delimiters, S); if i = 0 then Result := S else Result := Copy(S, i+1); end; function mnTruncRightOverDelimiter(const Delimiters, S: string): string; var i: Integer; begin i := mnLastDelimiter(Delimiters, S); if i = 0 then Result := S else Result := Copy(S, 1, i-1); end; function mnTruncLeftOver (const Substr, S: string): string; var i: Integer; begin i := Pos(Substr, S); if i = 0 then Result := S else Result := Copy(S, i+Length(Substr)); end; function mnTruncRightOver (const Substr, S: string): string; var i: Integer; begin i := mnLastPos(Substr, S); if i = 0 then Result := S else Result := Copy(S, 1, i-1); end; function mnAnsiTruncLeftOver (const Substr, S: string): string; var i: Integer; begin i := AnsiPos(Substr, S); if i = 0 then Result := S else Result := Copy(S, i+Length(Substr)); end; function mnAnsiTruncRightOver(const Substr, S: string): string; var i: Integer; begin i := mnAnsiLastPos(Substr, S); if i = 0 then Result := S else Result := Copy(S, 1, i-1); end; function mnCutLeftByChar (const Ch: Char; var S: string): string; var i: Integer; begin i := mnFirstChar(Ch, S); if i = 0 then begin Result := ''; end else begin Result := Copy(S, 1, i-1); S := Copy(S, i+1); end; end; function mnCutRightByChar(const Ch: Char; var S: string): string; var i: Integer; begin i := mnLastChar(Ch, S); if i = 0 then begin Result := ''; end else begin Result := Copy(S, i+1); S := Copy(S, 1, i-1); end; end; function mnCutLeftByDelimiter (const Delimiters: string; var S: string): string; var i: Integer; begin i := mnFirstDelimiter(Delimiters, S); if i = 0 then begin Result := ''; end else begin Result := Copy(S, 1, i-1); S := Copy(S, i+1); end; end; function mnCutRightByDelimiter(const Delimiters: string; var S: string): string; var i: Integer; begin i := mnLastDelimiter(Delimiters, S); if i = 0 then begin Result := ''; end else begin Result := Copy(S, i+1); S := Copy(S, 1, i-1); end; end; function mnCutLeftBy (const Substr: string; var S: string): string; var i: Integer; begin i := Pos(Substr, S); if i = 0 then begin Result := ''; end else begin Result := Copy(S, 1, i-1); S := Copy(S, i+Length(Substr)); end; end; function mnCutRightBy (const Substr: string; var S: string): string; var i: Integer; begin i := mnLastPos(Substr, S); if i = 0 then begin Result := ''; end else begin Result := Copy(S, i+Length(Substr)); S := Copy(S, 1, i-1); end; end; function mnAnsiCutLeftBy (const Substr: string; var S: string): string; var i: Integer; begin i := AnsiPos(Substr, S); if i = 0 then begin Result := ''; end else begin Result := Copy(S, 1, i-1); S := Copy(S, i+Length(Substr)); end; end; function mnAnsiCutRightBy(const Substr: string; var S: string): string; var i: Integer; begin i := mnAnsiLastPos(Substr, S); if i = 0 then begin Result := ''; end else begin Result := Copy(S, i+Length(Substr)); S := Copy(S, 1, i-1); end; end; function mnRemoveLeftChar (const Ch: Char; const S: string): string; begin if S = '' then begin Result := ''; Exit; end; if S[1] = Ch then Result := Copy(S, 2) else Result := S; end; function mnRemoveRightChar(const Ch: Char; const S: string): string; var Len: Integer; begin if S = '' then begin Result := ''; Exit; end; Len := Length(S); if S[Len] = Ch then Result := Copy(S, 1, Len-1) else Result := S; end; function mnRemoveLeftDelimiter (const Delimiters, S: string): string; var P: PChar; begin if S = '' then begin Result := ''; Exit; end; P := PChar(Delimiters); if (ByteType(S, 1) = mbSingleByte) and (StrScan(P, S[1]) <> nil) then Result := Copy(S, 2) else Result := S; end; function mnRemoveRightDelimiter(const Delimiters, S: string): string; var P: PChar; Len: Integer; begin if S = '' then begin Result := ''; Exit; end; P := PChar(Delimiters); Len := Length(S); if (ByteType(S, Len) = mbSingleByte) and (StrScan(P, S[Len]) <> nil) then Result := Copy(S, 1, Len-1) else Result := S; end; function mnRemoveLeft (const Substr, S: string): string; begin if S = '' then begin Result := ''; Exit; end; if mnStartsStr(Substr, S) then Result := Copy(S, Length(Substr)+1) else Result := S; end; function mnRemoveRight (const Substr, S: string): string; begin if S = '' then begin Result := ''; Exit; end; if mnEndsStr(Substr, S) then Result := Copy(S, 1, Length(S)-Length(Substr)) else Result := S; end; function mnAnsiRemoveLeft (const Substr, S: string): string; begin if S = '' then begin Result := ''; Exit; end; if StartsStr(Substr, S) then Result := Copy(S, Length(Substr)+1) else Result := S; end; function mnAnsiRemoveRight(const Substr, S: string): string; begin if S = '' then begin Result := ''; Exit; end; if EndsStr(Substr, S) then Result := Copy(S, 1, Length(S)-Length(Substr)) else Result := S; end; function mnEnsureLeftChar (const Ch: Char; const S: string): string; begin if S = '' then begin Result := Ch; Exit; end; if S[1] = Ch then Result := S else Result := Ch + S; end; function mnEnsureRightChar(const Ch: Char; const S: string): string; var Len: Integer; begin if S = '' then begin Result := Ch; Exit; end; Len := Length(S); if S[Len] = Ch then Result := S else Result := S + Ch; end; function mnEnsureLeft (const Substr, S: string): string; begin if S = '' then begin Result := Substr; Exit; end; if mnStartsStr(Substr, S) then Result := S else Result := Substr + S; end; function mnEnsureRight (const Substr, S: string): string; begin if S = '' then begin Result := Substr; Exit; end; if mnEndsStr(Substr, S) then Result := S else Result := S + Substr; end; function mnAnsiEnsureLeft (const Substr, S: string): string; begin if S = '' then begin Result := Substr; Exit; end; if StartsStr(Substr, S) then Result := S else Result := Substr + S; end; function mnAnsiEnsureRight(const Substr, S: string): string; begin if S = '' then begin Result := Substr; Exit; end; if EndsStr(Substr, S) then Result := S else Result := S + Substr; end; function mnAppendLeftCharIfNotEmpty (const Ch: Char; const S: string): string; begin if S = '' then Result := S else Result := Ch + S; end; function mnAppendRightCharIfNotEmpty(const Ch: Char; const S: string): string; begin if S = '' then Result := S else Result := S + Ch; end; function mnAppendLeftIfNotEmpty (const Substr, S: string): string; begin if S = '' then Result := S else Result := Substr + S; end; function mnAppendRightIfNotEmpty (const Substr, S: string): string; begin if S = '' then Result := S else Result := S + Substr; end; function mnCountChar(const Ch: Char; const S: string): Integer; var i: Integer; begin Result := 0; for i := 1 to Length(S) do if (ByteType(S, i) = mbSingleByte) and (S[i] = Ch) then Inc(Result); end; function mnCountDelimiter(const Delimiters, S: string): Integer; var P: PChar; i: Integer; begin P := PChar(Delimiters); Result := 0; for i := 1 to Length(S) do if (ByteType(S, i) = mbSingleByte) and (StrScan(P, S[i]) <> nil) then Inc(Result); end; function mnCount(const Substr, S: string): Integer; var Position: Integer; begin Result := 0; Position := 1; repeat Position := PosEx(Substr, S, Position); if Position > 0 then begin Inc(Result); Position := Position + Length(Substr); if Position > Length(S) then Position := 0; end; until Position = 0; end; function mnAnsiCount(const Substr, S: string): Integer; var Position: Integer; begin Result := 0; Position := 1; repeat Position := mnAnsiPosEx(Substr, S, Position); if Position > 0 then begin Inc(Result); Position := Position + Length(Substr); if Position > Length(S) then Position := 0; end; until Position = 0; end; function mnDiscardChar(const Ch: Char; const S: string): string; var i: Integer; begin Result := ''; for i := 1 to Length(S) do begin if (ByteType(S, i) <> mbSingleByte) or (S[i] <> Ch) then Result := Result + S[i]; end; end; function mnDiscardDelimiter(const Delimiters, S: string): string; var P: PChar; i: Integer; begin P := PChar(Delimiters); Result := ''; for i := 1 to Length(S) do begin if (ByteType(S, i) <> mbSingleByte) or (StrScan(P, S[i]) = nil) then Result := Result + S[i]; end; end; function mnDiscard(const Substr, S: string): string; var Position, Offset: Integer; begin Result := ''; Offset := 1; repeat Position := PosEx(Substr, S, Offset); if Position > 0 then begin Result := Result + Copy(S, Offset, Position-Offset); Offset := Position + Length(Substr); if Offset > Length(S) then Position := 0; end; until Position = 0; Result := Result + Copy(S, Offset); end; function mnAnsiDiscard(const Substr, S: string): string; var Position, Offset: Integer; begin Result := ''; Offset := 1; repeat Position := mnAnsiPosEx(Substr, S, Offset); if Position > 0 then begin Result := Result + Copy(S, Offset, Position-Offset); Offset := Position + Length(Substr); if Offset > Length(S) then Position := 0; end; until Position = 0; Result := Result + Copy(S, Offset); end; function mnShrinkChar(const Ch: Char; const S: string): string; var i: Integer; begin Result := ''; i := 1; while i <= Length(S) do begin Result := Result + S[i]; if (ByteType(S, i) = mbSingleByte) and (S[i] = Ch) then repeat Inc(i); until (ByteType(S, i) <> mbSingleByte) or (S[i] <> Ch) else Inc(i); end; end; function mnShrinkDelimiter(const Delimiters, S: string): string; var P: PChar; i: Integer; begin P := PChar(Delimiters); Result := ''; i := 1; while i <= Length(S) do begin Result := Result + S[i]; if (ByteType(S, i) = mbSingleByte) and (StrScan(P, S[i]) <> nil) then repeat Inc(i); until (ByteType(S, i) <> mbSingleByte) or (StrScan(P, S[i]) = nil) else Inc(i); end; end; function mnShrink(const Substr, S: string): string; var Position, Offset: Integer; begin Result := ''; Offset := 1; repeat Position := PosEx(Substr, S, Offset); if Position > 0 then begin Result := Result + Copy(S, Offset, Position-Offset+Length(Substr)); Offset := Position + Length(Substr); while Copy(S, Offset, Length(SubStr)) = Substr do Offset := Offset + Length(Substr); if Offset > Length(S) then Position := 0; end; until Position = 0; Result := Result + Copy(S, Offset); end; function mnAnsiShrink(const Substr, S: string): string; var Position, Offset: Integer; begin Result := ''; Offset := 1; repeat Position := mnAnsiPosEx(Substr, S, Offset); if Position > 0 then begin Result := Result + Copy(S, Offset, Position-Offset+Length(Substr)); Offset := Position + Length(Substr); while Copy(S, Offset, Length(SubStr)) = Substr do Offset := Offset + Length(Substr); if Offset > Length(S) then Position := 0; end; until Position = 0; Result := Result + Copy(S, Offset); end; function mnTrim(const SubStr: string; const S: string): string; var NeedContinue: Boolean; begin Result := S; // 截去左边 NeedContinue := True; while NeedContinue do begin NeedContinue := False; if mnStartsStr(Substr, Result) then begin Result := mnTruncBLeft(Result, Length(Substr)); NeedContinue := True; end; end; // 截去右边 NeedContinue := True; while NeedContinue do begin NeedContinue := False; if mnEndsStr(Substr, Result) then begin Result := mnTruncBRight(Result, Length(Substr)); NeedContinue := True; end; end; end; function mnTrimStrs(const SubStrs: array of string; const S: string): string; var NeedContinue: Boolean; SubStr: string; begin Result := S; // 截去左边 NeedContinue := True; while NeedContinue do begin NeedContinue := False; for SubStr in SubStrs do if mnStartsStr(Substr, Result) then begin Result := mnTruncBLeft(Result, Length(Substr)); NeedContinue := True; Break; end; end; // 截去右边 NeedContinue := True; while NeedContinue do begin NeedContinue := False; for SubStr in SubStrs do if mnEndsStr(Substr, Result) then begin Result := mnTruncBRight(Result, Length(Substr)); NeedContinue := True; Break; end; end; end; function mnExpandLeft (const S: string; const NewLength: Integer; const FillingChar: Char): string; begin Result := StringOfChar(FillingChar, NewLength-Length(S)) + S; end; function mnExpandRight(const S: string; const NewLength: Integer; const FillingChar: Char): string; begin Result := S + StringOfChar(FillingChar, NewLength-Length(S)); end; function mnExpandInt(const Value: Integer; const RequiredLength: Integer; const FillingChar: Char = '0'): string; begin Result := mnExpandLeft(IntToStr(Value), RequiredLength, FillingChar); end; function mnCompareStr(SMajor, SMinor: string; const Options: mnTStrComparisonOptions; const ResultWhenMinorIsEmpty: Boolean = True): Boolean; begin if SMinor = '' then begin Result := ResultWhenMinorIsEmpty; Exit; end; if not (scoCaseSensitive in Options) then begin SMajor := LowerCase(SMajor); SMinor := LowerCase(SMinor); end; if scoWholeWordOnly in Options then Result := SMajor = SMinor else Result := AnsiPos(SMinor, SMajor) > 0; end; function mnCompareStrInNumberStyle(const SA: string; const SB: string): Integer; var IntA, IntB: Integer; StrIsIntA, StrIsIntB: Boolean; begin try IntA := mnLLStrToInt(SA); StrIsIntA := True; except IntA := 0; StrIsIntA := False; end; try IntB := mnLLStrToInt(SB); StrIsIntB := True; except IntB := 0; StrIsIntB := False; end; if StrIsIntA and StrIsIntB then Result := mnChooseInt(IntA, IntB, 1, 0, -1) else if StrIsIntA then Result := -1 else if StrIsIntB then Result := 1 else Result := AnsiCompareStr(SA, SB); end; function mnReplaceStr(const S, OldStr, NewStr: string): string; var Position, Offset: Integer; begin Result := ''; Offset := 1; repeat Position := PosEx(OldStr, S, Offset); if Position > 0 then begin Result := Result + Copy(S, Offset, Position-Offset) + NewStr; Offset := Position + Length(OldStr); if Offset > Length(S) then Position := 0; end; until Position = 0; Result := Result + Copy(S, Offset); end; function mnReplaceStrWholeWord(const S, OldStr, NewStr: string): string; var Position, Offset: Integer; function IsIdChar(const Index: Integer): Boolean; begin if (Index < 1) or (Index > Length(S)) then Result := False else Result := mnIsLetter(S[Index]) or mnIsDigit(S[Index]) or (S[Index] = '_'); end; begin Result := ''; Offset := 1; repeat Position := PosEx(OldStr, S, Offset); if Position > 0 then begin if (IsIdChar(Position) and IsIdChar(Position-1)) or (IsIdChar(Position + Length(OldStr) - 1) and IsIdChar(Position + Length(OldStr))) then // not Whole Word, don't replace Result := Result + Copy(S, Offset, Position-Offset) + OldStr else Result := Result + Copy(S, Offset, Position-Offset) + NewStr; Offset := Position + Length(OldStr); if Offset > Length(S) then Position := 0; end; until Position = 0; Result := Result + Copy(S, Offset); end; function mnReplaceStrOnce(const S, OldStr, NewStr: string): string; var Position: Integer; begin Position := Pos(OldStr, S); if Position > 0 then Result := Copy(S, 1, Position-1) + NewStr + Copy(S, Position+Length(OldStr)) else Result := S; end; function mnFindStrBetween (const S, SubstrHead, SubstrTail: string; var SubstrBeginPos, SubstrEndPos: Integer; var SubstrBody: string; Offset: Integer = 1): Boolean; overload; var HeadPos, TailPos: Integer; begin Result := mnBetweenII(Offset, 1, Length(S)); if not Result then Exit; HeadPos := PosEx(SubstrHead, S, Offset); Result := HeadPos <> 0; if not Result then Exit; TailPos := PosEx(SubstrTail, S, HeadPos + Length(SubstrHead)); Result := TailPos <> 0; if not Result then Exit; SubstrBeginPos := HeadPos; SubstrEndPos := TailPos + Length(SubstrTail); SubstrBody := Copy(S, HeadPos + Length(SubstrHead), TailPos - HeadPos - Length(SubstrHead)); end; function mnFindStrBetween (const S, SubstrHead, SubstrTail: string; var SubstrBody: string; Offset: Integer = 1): Boolean; overload; var SubstrBeginPos, SubstrEndPos: Integer; begin Result := mnFindStrBetween(S, SubstrHead, SubstrTail, SubstrBeginPos, SubstrEndPos, SubstrBody, Offset); end; function mnAnsiFindStrBetween(const S, SubstrHead, SubstrTail: string; var SubstrBeginPos, SubstrEndPos: Integer; var SubstrBody: string; Offset: Integer = 1): Boolean; overload; var HeadPos, TailPos: Integer; begin Result := mnBetweenII(Offset, 1, Length(S)); if not Result then Exit; HeadPos := mnAnsiPosEx(SubstrHead, S, Offset); Result := HeadPos <> 0; if not Result then Exit; TailPos := mnAnsiPosEx(SubstrTail, S, HeadPos + Length(SubstrHead)); Result := TailPos <> 0; if not Result then Exit; SubstrBeginPos := HeadPos; SubstrEndPos := TailPos + Length(SubstrTail); SubstrBody := Copy(S, HeadPos + Length(SubstrHead), TailPos - HeadPos - Length(SubstrHead)); end; function mnAnsiFindStrBetween(const S, SubstrHead, SubstrTail: string; var SubstrBody: string; Offset: Integer = 1): Boolean; overload; var SubstrBeginPos, SubstrEndPos: Integer; begin Result := mnAnsiFindStrBetween(S, SubstrHead, SubstrTail, SubstrBeginPos, SubstrEndPos, SubstrBody, Offset); end; function mnReplaceStrBetween (const S, SubstrHead, SubstrTail, NewStr: string): string; overload; var Position, SubstrBeginPos, SubstrEndPos: Integer; SubStrBody: string; SubstrFound: Boolean; begin Result := ''; Position := 1; repeat SubstrFound := mnFindStrBetween(S, SubstrHead, SubstrTail, SubstrBeginPos, SubstrEndPos, SubStrBody, Position); if SubstrFound then begin Result := Result + Copy(S, Position, SubstrBeginPos-Position) + NewStr; Position := SubstrEndPos; end else Result := Result + Copy(S, Position); until not SubstrFound; end; function mnReplaceStrBetween (const S, SubstrHead, SubstrTail: string; NameValuePairs: TStrings): string; overload; var Position, SubstrBeginPos, SubstrEndPos: Integer; SubStrBody: string; SubstrFound: Boolean; begin Result := ''; Position := 1; repeat SubstrFound := mnFindStrBetween(S, SubstrHead, SubstrTail, SubstrBeginPos, SubstrEndPos, SubStrBody, Position); if SubstrFound then begin Result := Result + Copy(S, Position, SubstrBeginPos-Position) + NameValuePairs.Values[SubStrBody];; Position := SubstrEndPos; end else Result := Result + Copy(S, Position); until not SubstrFound; end; function mnReplaceStrBetween (const S, NewStr: string): string; overload; begin Result := mnReplaceStrBetween(S, mnStdSeparator1, mnStdSeparator1, NewStr); end; function mnReplaceStrBetween (const S: string; NameValuePairs: TStrings): string; overload; begin Result := mnReplaceStrBetween(S, mnStdSeparator1, mnStdSeparator1, NameValuePairs); end; function mnAnsiReplaceStrBetween(const S, SubstrHead, SubstrTail, NewStr: string): string; overload; var Position, SubstrBeginPos, SubstrEndPos: Integer; SubStrBody: string; SubstrFound: Boolean; begin Result := ''; Position := 1; repeat SubstrFound := mnAnsiFindStrBetween(S, SubstrHead, SubstrTail, SubstrBeginPos, SubstrEndPos, SubStrBody, Position); if SubstrFound then begin Result := Result + Copy(S, Position, SubstrBeginPos-Position) + NewStr; Position := SubstrEndPos; end else Result := Result + Copy(S, Position); until not SubstrFound; end; function mnAnsiReplaceStrBetween(const S, SubstrHead, SubstrTail: string; NameValuePairs: TStrings): string; overload; var Position, SubstrBeginPos, SubstrEndPos: Integer; SubStrBody: string; SubstrFound: Boolean; begin Result := ''; Position := 1; repeat SubstrFound := mnAnsiFindStrBetween(S, SubstrHead, SubstrTail, SubstrBeginPos, SubstrEndPos, SubStrBody, Position); if SubstrFound then begin Result := Result + Copy(S, Position, SubstrBeginPos-Position) + NameValuePairs.Values[SubStrBody];; Position := SubstrEndPos; end else Result := Result + Copy(S, Position); until not SubstrFound; end; function mnAnsiReplaceStrBetween(const S, NewStr: string): string; overload; begin Result := mnAnsiReplaceStrBetween(S, mnStdSeparator1, mnStdSeparator1, NewStr); end; function mnAnsiReplaceStrBetween(const S: string; NameValuePairs: TStrings): string; overload; begin Result := mnAnsiReplaceStrBetween(S, mnStdSeparator1, mnStdSeparator1, NameValuePairs); end; function mnCombine(const Strs: array of string; const Connector: string = mnStdConnector1; const HasBorder: Boolean = False): string; overload; var i: Integer; begin Result := ''; for i := Low(Strs) to High(Strs) do begin if i <> Low(Strs) then Result := Result + Connector; Result := Result + Strs[i]; end; if HasBorder then Result := Connector + Result + Connector; end; function mnCombine(Strs: TStrings; const Connector: string = mnStdConnector1; const HasBorder: Boolean = False): string; overload; var i: Integer; begin Result := ''; for i := 0 to Strs.Count-1 do begin if i <> 0 then Result := Result + Connector; Result := Result + Strs[i]; end; if HasBorder then Result := Connector + Result + Connector; end; function mnCombine(DataSet: TDataSet; const FieldName: string; const Connector: string = mnStdConnector1; const HasBorder: Boolean = False): string; overload; begin Result := ''; while not DataSet.Eof do begin if Result <> '' then Result := Result + Connector; Result := Result + DataSet.FieldByName(FieldName).AsString; DataSet.Next; end; if HasBorder then Result := Connector + Result + Connector; end; function mnCombine(Fields: TFields; FieldNames: mnTFieldNames; const Connector: string = mnStdConnector1; const HasBorder: Boolean = False): string; overload; var StrsFieldNames: mnTStrList; begin StrsFieldNames := mnTStrList.Create; try mnSplitFieldNames(FieldNames, StrsFieldNames); Result := mnCombine(Fields, StrsFieldNames, Connector, HasBorder); finally StrsFieldNames.Free; end; end; function mnCombine(Fields: TFields; FieldNames: TStrings; const Connector: string = mnStdConnector1; const HasBorder: Boolean = False): string; overload; var i: Integer; begin Result := ''; for i := 0 to FieldNames.Count-1 do begin if i <> 0 then Result := Result + Connector; Result := Result + Fields.FieldByName(FieldNames[i]).AsString; end; if HasBorder then Result := Connector + Result + Connector; end; function mnCombine(Fields: TFields; const FieldNames: array of string; const Connector: string = mnStdConnector1; const HasBorder: Boolean = False): string; overload; var i: Integer; begin Result := ''; for i := Low(FieldNames) to High(FieldNames) do begin if i <> Low(FieldNames) then Result := Result + Connector; Result := Result + Fields.FieldByName(FieldNames[i]).AsString; end; if HasBorder then Result := Connector + Result + Connector; end; function mnSplit (const S: string; OutSplittedStrs: TStrings; const Separator: string = mnStdSeparator1; const HasBorder: Boolean = False): Integer; var varS: string; begin varS := S; if HasBorder then begin mnCreateErrorIf(not mnStartsStr(Separator, S) or not mnEndsStr(Separator, S), SSplitWithoutBorder, [S]); varS := Copy(varS, Length(Separator)+1, Length(varS)-2*Length(Separator)); end; Result := 0; repeat if Pos(Separator, varS) = 0 then begin OutSplittedStrs.Append(varS); Inc(Result); Exit; end else begin OutSplittedStrs.Append(mnCutLeftBy(Separator, varS)); Inc(Result); end; until False; end; function mnAnsiSplit(const S: string; OutSplittedStrs: TStrings; const Separator: string = mnStdSeparator1; const HasBorder: Boolean = False): Integer; var varS: string; begin varS := S; if HasBorder then begin mnCreateErrorIf(not AnsiStartsStr(Separator, S) or not AnsiEndsStr(Separator, S), SSplitWithoutBorder, [S]); varS := Copy(varS, Length(Separator)+1, Length(varS)-2*Length(Separator)); end; Result := 0; repeat if AnsiPos(Separator, varS) = 0 then begin OutSplittedStrs.Append(varS); Inc(Result); Exit; end else begin OutSplittedStrs.Append(mnAnsiCutLeftBy(Separator, varS)); Inc(Result); end; until False; end; function mnSplitBetween (const S: string; OutSplittedStrs: TStrings; OutSeparatorBodies: TStrings; const SeparatorHead, SeparatorTail: string): Integer; var CurrPos, SeparatorBeginPos, SeparatorEndPos: Integer; SubStrBody: string; SeparatorFound: Boolean; begin Result := 1; CurrPos := 1; repeat SeparatorFound := mnFindStrBetween(S, SeparatorHead, SeparatorTail, SeparatorBeginPos, SeparatorEndPos, SubStrBody, CurrPos); if SeparatorFound then begin OutSplittedStrs.Append(Copy(S, CurrPos, SeparatorBeginPos-CurrPos)); OutSeparatorBodies.Append(SubStrBody); CurrPos := SeparatorEndPos; Inc(Result); end else OutSplittedStrs.Append(Copy(S, CurrPos)); until not SeparatorFound; end; function mnAnsiSplitBetween(const S: string; OutSplittedStrs: TStrings; OutSeparatorBodies: TStrings; const SeparatorHead, SeparatorTail: string): Integer; var CurrPos, SeparatorBeginPos, SeparatorEndPos: Integer; SubStrBody: string; SeparatorFound: Boolean; begin Result := 1; CurrPos := 1; repeat SeparatorFound := mnAnsiFindStrBetween(S, SeparatorHead, SeparatorTail, SeparatorBeginPos, SeparatorEndPos, SubStrBody, CurrPos); if SeparatorFound then begin OutSplittedStrs.Append(Copy(S, CurrPos, SeparatorBeginPos-CurrPos)); OutSeparatorBodies.Append(SubStrBody); CurrPos := SeparatorEndPos; Inc(Result); end else OutSplittedStrs.Append(Copy(S, CurrPos)); until not SeparatorFound; end; function mnSplitByLen(const S: string; OutSplittedStrs: TStrings; const SplittedLen: Integer): Integer; var i: Integer; begin mnCreateErrorIf(SplittedLen <= 0, SSplittedLenNegative, [SplittedLen]); Result := (Length(S)-1) div SplittedLen + 1; for i := 1 to Result do OutSplittedStrs.Add(MidBStr(S, (i-1)*SplittedLen+1, SplittedLen)); end; { mnTStringPattern } procedure mnTStringPattern.SetPattern(const Value: string); begin FPattern := Value; FPatternSections.Clear; FPatternParams.Clear; FPatternParsed := False; end; procedure mnTStringPattern.ParsePattern; begin if not FPatternParsed then begin mnSplitBetween(FPattern, FPatternSections, FPatternParams, FParamHead, FParamTail); FPatternParsed := True; end; end; procedure mnTStringPattern.AnsiParsePattern; begin if not FPatternParsed then begin mnAnsiSplitBetween(FPattern, FPatternSections, FPatternParams, FParamHead, FParamTail); FPatternParsed := True; end; end; procedure mnTStringPattern.LoadPatternFromFile(const FileName: string); begin Pattern := mnLoadStrFromFile(FileName); end; function mnTStringPattern.GetParamValue(ParamName: string): string; begin Result := FParamPairs.Values[ParamName]; end; function mnTStringPattern.GetParamValueAsInt(ParamName: string): Integer; begin Result := StrToInt(FParamPairs.Values[ParamName]); end; function mnTStringPattern.GetParamValueAsFloat(ParamName: string): Extended; begin Result := StrToFloat(FParamPairs.Values[ParamName]); end; function mnTStringPattern.GetParamValueAsDT(ParamName: string): TDateTime; begin Result := StrToDateTime(FParamPairs.Values[ParamName]); end; function mnTStringPattern.GetParamValueAsCurr(ParamName: string): Currency; begin Result := StrToCurr(FParamPairs.Values[ParamName]); end; procedure mnTStringPattern.ClearParamPairs; begin FParamPairs.Clear; end; constructor mnTStringPattern.Create; begin FPattern := ''; FPatternSections := mnTStrList.Create; FPatternParams := mnTStrList.Create; FPatternParsed := False; FParamHead := mnStdSeparator1; FParamTail := mnStdSeparator1; FIgnoreUnnamedParams := True; FAutoClearPairs := True; FWorkStr := ''; FParamPairs := mnTStrList.Create; end; destructor mnTStringPattern.Destroy; begin FPatternSections.Free; FPatternParams.Free; FParamPairs.Free; inherited; end; function mnTStringPattern.Match(const S: string): Boolean; var varS: string; FirstSection, LastSection: string; Pairs: mnTStrList; ParamValue: string; i: Integer; begin ParsePattern; Result := False; FWorkStr := S; varS := S; // no parameters if FPatternParams.Count = 0 then begin Result := S = FPattern; if Result then FParamPairs.Clear; Exit; end; // check first section FirstSection := FPatternSections.First; if FirstSection <> '' then if mnStartsStr(FirstSection, varS) then varS := mnTruncBLeft(varS, Length(FirstSection)) else Exit; // check last section LastSection := FPatternSections.Last; if LastSection <> '' then if mnEndsStr(LastSection, varS) then varS := mnTruncBRight(varS, Length(LastSection)) else Exit; Pairs := mnTStrList.Create; try for i := 1 to FPatternSections.Count-2 do begin // check each section mnCreateErrorIf(FPatternSections[i] = '', SContinuousTwoParams, [FPattern]); if Pos(FPatternSections[i], varS) = 0 then Exit; ParamValue := mnCutLeftBy(FPatternSections[i], varS); if not FIgnoreUnnamedParams or (FPatternParams[i-1] <> '') then Pairs.Append(FPatternParams[i-1] + '=' + ParamValue); end; if not FIgnoreUnnamedParams or (FPatternParams.Last <> '') then Pairs.Append(FPatternParams.Last + '=' + varS); if FAutoClearPairs then FParamPairs.Clear; FParamPairs.AddStrings(Pairs); Result := True; finally Pairs.Free; end; end; function mnTStringPattern.AnsiMatch(const S: string): Boolean; var varS: string; FirstSection, LastSection: string; Pairs: mnTStrList; ParamValue: string; i: Integer; begin AnsiParsePattern; Result := False; FWorkStr := S; varS := S; // no parameters if FPatternParams.Count = 0 then begin Result := S = FPattern; if Result then FParamPairs.Clear; Exit; end; // check first section FirstSection := FPatternSections.First; if FirstSection <> '' then if AnsiStartsStr(FirstSection, varS) then varS := mnTruncBLeft(varS, Length(FirstSection)) else Exit; // check last section LastSection := FPatternSections.Last; if LastSection <> '' then if AnsiEndsStr(LastSection, varS) then varS := mnTruncBRight(varS, Length(LastSection)) else Exit; Pairs := mnTStrList.Create; try for i := 1 to FPatternSections.Count-2 do begin // check each section mnCreateErrorIf(FPatternSections[i] = '', SContinuousTwoParams, [FPattern]); if AnsiPos(FPatternSections[i], varS) = 0 then Exit; ParamValue := mnAnsiCutLeftBy(FPatternSections[i], varS); if not FIgnoreUnnamedParams or (FPatternParams[i-1] <> '') then Pairs.Append(FPatternParams[i-1] + '=' + ParamValue); end; if not FIgnoreUnnamedParams or (FPatternParams.Last <> '') then Pairs.Append(FPatternParams.Last + '=' + varS); if FAutoClearPairs then FParamPairs.Clear; FParamPairs.AddStrings(Pairs); Result := True; finally Pairs.Free; end; end; function mnTStringPattern.MatchSub(const S: string; const Offset: Integer): Boolean; var varS: string; FirstSection, LastSection: string; Pairs: mnTStrList; ParamValue: string; i: Integer; BeginPos, EndPos: Integer; begin ParsePattern; Result := False; FWorkStr := S; varS := S; // check validity of Offset if not mnBetweenII(Offset, 1, Length(S)) then Exit; // no parameters if FPatternParams.Count = 0 then begin BeginPos := PosEx(FPattern, S, Offset); EndPos := BeginPos + Length(FPattern); Result := BeginPos > 0; if Result then begin FPartBeginPos := BeginPos; FPartEndPos := EndPos; FParamPairs.Clear; end; Exit; end; // locate the first section FirstSection := FPatternSections.First; if FirstSection = '' then begin // Offset leads the part BeginPos := Offset; EndPos := BeginPos; varS := Copy(varS, EndPos); end else begin // find the first section to lead the part BeginPos := PosEx(FirstSection, S, Offset); EndPos := BeginPos + Length(FirstSection); if BeginPos = 0 then Exit; varS := Copy(varS, EndPos); end; Pairs := mnTStrList.Create; try for i := 1 to FPatternSections.Count-2 do begin // check each section mnCreateErrorIf(FPatternSections[i] = '', SContinuousTwoParams, [FPattern]); if Pos(FPatternSections[i], varS) = 0 then Exit; ParamValue := mnCutLeftBy(FPatternSections[i], varS); if not FIgnoreUnnamedParams or (FPatternParams[i-1] <> '') then Pairs.Append(FPatternParams[i-1] + '=' + ParamValue); EndPos := EndPos + Length(ParamValue) + Length(FPatternSections[i]); end; // locate the last section LastSection := FPatternSections.Last; if LastSection = '' then begin // all leaving string are value of last param EndPos := Length(S) + 1; if not IgnoreUnnamedParams or (FPatternParams.Last <> '') then Pairs.Append(FPatternParams.Last + '=' + varS); end else begin // find the last section to end the part if Pos(LastSection, varS) = 0 then Exit; ParamValue := mnCutLeftBy(LastSection, varS); if not IgnoreUnnamedParams or (FPatternParams.Last <> '') then Pairs.Append(FPatternParams.Last + '=' + ParamValue); EndPos := EndPos + Length(ParamValue) + Length(LastSection); end; if FAutoClearPairs then FParamPairs.Clear; FParamPairs.AddStrings(Pairs); FPartBeginPos := BeginPos; FPartEndPos := EndPos; Result := True; finally Pairs.Free; end; end; function mnTStringPattern.AnsiMatchSub(const S: string; const Offset: Integer): Boolean; var varS: string; FirstSection, LastSection: string; Pairs: mnTStrList; ParamValue: string; i: Integer; BeginPos, EndPos: Integer; begin AnsiParsePattern; Result := False; FWorkStr := S; varS := S; // check validity of Offset if not mnBetweenII(Offset, 1, Length(S)) then Exit; // no parameters if FPatternParams.Count = 0 then begin BeginPos := mnAnsiPosEx(FPattern, S, Offset); EndPos := BeginPos + Length(FPattern); Result := BeginPos > 0; if Result then begin FPartBeginPos := BeginPos; FPartEndPos := EndPos; FParamPairs.Clear; end; Exit; end; // locate the first section FirstSection := FPatternSections.First; if FirstSection = '' then begin // Offset leads the part BeginPos := Offset; EndPos := BeginPos; varS := Copy(varS, EndPos); end else begin // find the first section to lead the part BeginPos := mnAnsiPosEx(FirstSection, S, Offset); EndPos := BeginPos + Length(FirstSection); if BeginPos = 0 then Exit; varS := Copy(varS, EndPos); end; Pairs := mnTStrList.Create; try for i := 1 to FPatternSections.Count-2 do begin // check each section mnCreateErrorIf(FPatternSections[i] = '', SContinuousTwoParams, [FPattern]); if AnsiPos(FPatternSections[i], varS) = 0 then Exit; ParamValue := mnAnsiCutLeftBy(FPatternSections[i], varS); if not FIgnoreUnnamedParams or (FPatternParams[i-1] <> '') then Pairs.Append(FPatternParams[i-1] + '=' + ParamValue); EndPos := EndPos + Length(ParamValue) + Length(FPatternSections[i]); end; // locate the last section LastSection := FPatternSections.Last; if LastSection = '' then begin // all leaving string are value of last param EndPos := Length(S) + 1; if not IgnoreUnnamedParams or (FPatternParams.Last <> '') then Pairs.Append(FPatternParams.Last + '=' + varS); end else begin // find the last section to end the part if AnsiPos(LastSection, varS) = 0 then Exit; ParamValue := mnAnsiCutLeftBy(LastSection, varS); if not IgnoreUnnamedParams or (FPatternParams.Last <> '') then Pairs.Append(FPatternParams.Last + '=' + ParamValue); EndPos := EndPos + Length(ParamValue) + Length(LastSection); end; if FAutoClearPairs then FParamPairs.Clear; FParamPairs.AddStrings(Pairs); FPartBeginPos := BeginPos; FPartEndPos := EndPos; Result := True; finally Pairs.Free; end; end; function mnTStringPattern.MatchNextSub: Boolean; begin Result := MatchSub(FWorkStr, FPartEndPos); end; function mnTStringPattern.AnsiMatchNextSub: Boolean; begin Result := AnsiMatchSub(FWorkStr, FPartEndPos); end; procedure mnTStringPattern.PrepareSubSequence(const S: string); begin FWorkStr := S; FParamPairs.Clear; FPartBeginPos := 1; FPartEndPos := 1; end; function mnTStringPattern.Realize(NameValuePairs: TStrings): string; var i: Integer; begin ParsePattern; Result := ''; for i := 0 to FPatternSections.Count-1 do begin if i <> 0 then Result := Result + NameValuePairs.Values[FPatternParams[i-1]]; Result := Result + FPatternSections[i]; end; end; function mnTStringPattern.AnsiRealize(NameValuePairs: TStrings): string; var i: Integer; begin AnsiParsePattern; Result := ''; for i := 0 to FPatternSections.Count-1 do begin if i <> 0 then Result := Result + NameValuePairs.Values[FPatternParams[i-1]]; Result := Result + FPatternSections[i]; end; end; function mnGetTextEncoding(const S: string): mnTTextEncoding; begin if mnStartsStr(mnUnicodeLEBOM, S) then Result := teUnicodeLE else if mnStartsStr(mnUnicodeBEBOM, S) then Result := teUnicodeBE else if mnStartsStr(mnUTF8BOM, S) then Result := teUTF8 else Result := teAnsi; end; function mnExpressWideString(const WS: WideString): string; var WSLen: Integer; i: Integer; begin WSLen := Length(WS); SetLength(Result, WSLen * SizeOf(WideChar)); for i := 1 to WSLen do begin Result[i*2-1] := Chr(Lo(Word(WS[i]))); Result[i*2] := Chr(Hi(Word(WS[i]))); end; end; function mnRandomStr (const Len: Integer; const Candidates: string = ''): string; var i: Integer; PResult: PByte; begin SetLength(Result, Len); PResult := PByte(Result); for i := 1 to Len do begin if Candidates = '' then PResult^ := Random(256) else PResult^ := Ord(Candidates[Random(Length(Candidates))+1]); Inc(PResult); end; end; function mnRandomDigitStr (const Len: Integer): mnTDigitStr; var i: Integer; PResult: PByte; begin SetLength(Result, Len); PResult := PByte(Result); for i := 1 to Len do begin PResult^ := mnDigitIntToByte(Random(10)); Inc(PResult); end; end; function mnRandomDigletStr(const Len: Integer): mnTDigletStr; var i, r: Integer; PResult: PByte; begin SetLength(Result, Len); PResult := PByte(Result); for i := 1 to Len do begin r := Random(62); if r < 10 then PResult^ := mnDigitIntToByte(r) else if r < 36 then PResult^ := Ord('A') - 10 + r else PResult^ := Ord('a') - 36 + r; Inc(PResult); end; end; function mnRandomUpperDigletStr(const Len: Integer): mnTDigletStr; var i: Integer; PResult: PByte; begin SetLength(Result, Len); PResult := PByte(Result); for i := 1 to Len do begin PResult^ := mnDigletIntToByte(Random(36), True); Inc(PResult); end; end; function mnRandomLowerDigletStr(const Len: Integer): mnTDigletStr; var i: Integer; PResult: PByte; begin SetLength(Result, Len); PResult := PByte(Result); for i := 1 to Len do begin PResult^ := mnDigletIntToByte(Random(36), False); Inc(PResult); end; end; function mnEncodeToDigitStr (const S: string): mnTDigitStr; var i: Integer; PResult: PByte; B: Byte; begin SetLength(Result, Length(S) * 3); PResult := PByte(Result); for i := 1 to Length(S) do begin B := Ord(S[i]); PResult^ := mnDigitIntToByte(B shr 6); Inc(PResult); PResult^ := mnDigitIntToByte((B shr 3) and $7); Inc(PResult); PResult^ := mnDigitIntToByte(B and $7); Inc(PResult); end; end; function mnDecodeFromDigitStr (const S: mnTDigitStr): string; var i: Integer; PResult, PS: PByte; begin SetLength(Result, Length(S) div 3); PResult := PByte(Result); PS := PByte(S); for i := 1 to Length(Result) do begin PResult^ := mnByteToDigitInt(PS^); Inc(PS); PResult^ := (PResult^ shl 3) + mnByteToDigitInt(PS^); Inc(PS); PResult^ := (PResult^ shl 3) + mnByteToDigitInt(PS^); Inc(PS); Inc(PResult); end; end; function mnEncodeToDigletStr (const S: string; const Capital: Boolean = True): mnTDigletStr; var i: Integer; PResult: PByte; B: Byte; begin SetLength(Result, Length(S) * 2); PResult := PByte(Result); for i := 1 to Length(S) do begin B := Ord(S[i]); PResult^ := mnDigletIntToByte(B shr 4, Capital); Inc(PResult); PResult^ := mnDigletIntToByte(B and $F, Capital); Inc(PResult); end; end; function mnDecodeFromDigletStr(const S: mnTDigletStr): string; var i: Integer; PResult, PS: PByte; HB, LB: Byte; begin SetLength(Result, Length(S) div 2); PResult := PByte(Result); PS := PByte(S); for i := 1 to Length(Result) do begin HB := mnByteToDigletInt(PS^); Inc(PS); LB := mnByteToDigletInt(PS^); Inc(PS); PResult^ := (HB shl 4) + LB; Inc(PResult); end; end; function mnHideStr (const S: string; const DisguiseLen: Integer = 4): string; var i: Integer; PResult, PS: PByte; begin Result := mnRandomStr(Length(S) * (DisguiseLen + 1) + DisguiseLen); PResult := PByte(Result); PS := PByte(S); for i := 1 to Length(S) do begin Inc(PResult, DisguiseLen); PResult^ := PS^; Inc(PResult); Inc(PS); end; end; function mnHideDigitStr (const S: string; const DisguiseLen: Integer = 4): mnTDigitStr; var i: Integer; PResult, PS: PByte; begin Result := mnRandomDigitStr(Length(S) * (DisguiseLen + 1) + DisguiseLen); PResult := PByte(Result); PS := PByte(S); for i := 1 to Length(S) do begin Inc(PResult, DisguiseLen); PResult^ := PS^; Inc(PResult); Inc(PS); end; end; function mnHideDigletStr(const S: string; const Capital: Boolean = True; const DisguiseLen: Integer = 4): mnTDigletStr; var i: Integer; PResult, PS: PByte; begin if Capital then Result := mnRandomUpperDigletStr(Length(S) * (DisguiseLen + 1) + DisguiseLen) else Result := mnRandomLowerDigletStr(Length(S) * (DisguiseLen + 1) + DisguiseLen); PResult := PByte(Result); PS := PByte(S); for i := 1 to Length(S) do begin Inc(PResult, DisguiseLen); PResult^ := PS^; Inc(PResult); Inc(PS); end; end; function mnRevealStr (const S: string; const DisguiseLen: Integer = 4): string; var i: Integer; PResult, PS: PByte; begin SetLength(Result, (Length(S) + 1) div (DisguiseLen + 1) - 1); PResult := PByte(Result); PS := PByte(S); for i := 1 to Length(Result) do begin Inc(PS, DisguiseLen); PResult^ := PS^; Inc(PS); Inc(PResult); end; end; initialization ppPattern := mnTStringPattern.Create; finalization ppPattern.Free; end.
{ ╔═════════════════════════════╗ ║ _______ _______ _______ ║ ║ ( ____ \( )( ____ \ ║ ║ | ( \/| () () || ( \/ ║ ║ | (_____ | || || || (_____ ║ ║ (_____ )| |(_)| |(_____ ) ║ ║ ) || | | | ) | ║ ║ /\____) || ) ( |/\____) | ║ ║ \_______)|/ \|\_______) ║ ║Sea creatures by: warleyalex ║ ╚═════════════════════════════╝ } unit Form1; interface uses FireSpriteAtlas, MainView, W3C.Console, W3C.HTML5, W3C.DOM, ECMA.JSON, SmartCL.Forms, SmartCL.Application, uMDButton; type TForm1 = class(TW3Form) private {$I 'Form1:intf'} FParticles: TMainView; procedure StartStop(Sender: TObject); protected procedure HandleBackButtonClicked(Sender: TObject); procedure FormActivated; override; procedure InitializeForm; override; procedure InitializeObject; override; procedure FinalizeObject; override; procedure Resize; override; end; implementation (*================== TForm1 ==========================*) { TForm1 } procedure TForm1.InitializeObject; begin inherited; {$I 'Form1:impl'} FParticles := TMainView.Create(Self); FParticles.Width:= 800; FParticles.Height:= 600; FParticles.OnClick := StartStop; end; procedure TForm1.FinalizeObject; begin FParticles.Free; inherited; end; procedure TForm1.InitializeForm; begin inherited; // this is a good place to initialize components end; procedure TForm1.FormActivated; begin inherited FormActivated; FParticles.Start; end; procedure TForm1.HandleBackButtonClicked(Sender: TObject); begin FParticles.Stop; end; procedure TForm1.StartStop(Sender: TObject); begin FParticles.Toggle; end; procedure TForm1.Resize; //var DeltaY: Integer; begin inherited; /* if Assigned(FParticles) then begin DeltaY := btn1.Top + btn1.Height + 10; FParticles.SetBounds(10, DeltaY, Width - 20, Height - (10 + DeltaY)); end;*/ end; initialization Forms.RegisterForm({$I %FILE%}, TForm1); end.
{ ------------- === ------------- ALL_DATES.PAS Working with Dates - compares, checks etc... } Unit All_Dates; {------------------------------------} INTERFACE {------------------------------------} TYPE { Day, Month, Year [ ;-) ] } Date_Rec=record Day:Byte; Mon:Byte; Year:Word end; { greater ( > ), lower ( < ) or equal ( = ) } CmpResult = ( cmp_LO , cmp_EQ , cmp_GR ); CONST DaysInMonth:array[1..12] of Byte = ( 31,29,31,30,31,30,31,31,30,31,30,31 ); {check leap year} Function YearIsLeap(Year:Word):Boolean; { check correct of date } Function DateIsCorrect(d:Date_rec):Boolean; { comparing two dates } function CompareDates(A,B:Date_rec):CmpResult; {------------------------------------------} IMPLEMENTATION {----------------------------------------- } Function YearIsLeap(Year:Word):Boolean; begin if ( Year mod 4 = 0 ) then begin if ( Year mod 100 = 0 ) then YearIsLeap:=false else YearIsLeap:= true end else begin if ( Year mod 400 = 0 ) then YearIsLeap := true else YearIsLeap := false; end; end; {maybe OK} Function DateIsCorrect(d:Date_rec):Boolean; Begin if (( d.Day = 0 ) or ( d.Mon = 0 ) or ( d.Year = 0 )) or ( d.Year<1970 ) or ( d.Mon>12 ) or ( (d.Day>DaysInMonth[d.Mon]) ) or ( (d.Day=29) and (d.Mon=2) and not YearIsLeap(d.Year) ) then DateIsCorrect:=false else DateIsCorrect:=true; end; function CompareDates(A,B:Date_Rec):CmpResult; begin if A.Year < B.Year then { * bydlocoder-style * } CompareDates := cmp_Lo else if A.Year > B.Year then CompareDates := cmp_Gr else if A.Mon < B.Mon then CompareDates := cmp_Lo else if A.Mon > B.Mon then CompareDates := cmp_Gr else if A.Day < B.Day then CompareDates := cmp_Lo else if A.Day > B.Day then CompareDates := cmp_Gr else CompareDates := cmp_Eq ; end; END.
unit WeaponSound; interface uses xr_strings, Console; type ref_sound = packed record _p:{ref_sound_data_ptr}pointer; end; type pref_sound = ^ref_sound; type HUD_SOUND_ITEM_SSnd = packed record snd:ref_sound; delay:single; volume:single; end; type pHUD_SOUND_ITEM_SSnd = ^HUD_SOUND_ITEM_SSnd; type HUD_SOUND_ITEM = packed record m_alias:shared_str; m_activeSnd:pHUD_SOUND_ITEM_SSnd; sounds_start:pHUD_SOUND_ITEM_SSnd; sounds_end:pHUD_SOUND_ITEM_SSnd; sounds_mem:pHUD_SOUND_ITEM_SSnd; end; type pHUD_SOUND_ITEM = ^HUD_SOUND_ITEM; type HUD_SOUND_COLLECTION = packed record first:pHUD_SOUND_ITEM; last:pHUD_SOUND_ITEM; mem:pHUD_SOUND_ITEM; end; type pHUD_SOUND_COLLECTION = ^HUD_SOUND_COLLECTION; function Init(dwFlags:cardinal):boolean; procedure HUD_SOUND_COLLECTION__LoadSound(hcs:pHUD_SOUND_COLLECTION; section:PChar; line:PChar; alias:PChar; snd_type:cardinal);stdcall; procedure HUD_SOUND_COLLECTION_LoadSoundIfNotLoaded(hcs:pHUD_SOUND_COLLECTION; section:PChar; line:PChar; alias:PChar; snd_type:cardinal); stdcall; implementation uses BaseGameData, sysutils, MatVectors, HudItems, Objects, gunsl_config, dynamic_caster; /////////////////////////////////////////Engine wrappers//////////////////////////////////////////////////////////// procedure HUD_SOUND_COLLECTION__LoadSound(hcs:pHUD_SOUND_COLLECTION; section:PChar; line:PChar; alias:PChar; snd_type:cardinal);stdcall; asm pushad pushfd push snd_type push alias push line push section mov eax, hcs mov ebx, xrgame_addr add ebx, $287560 call ebx // HUD_SOUND_COLLECTION::LoadSound popfd popad end; procedure HUD_SOUND_COLLECTION__PlaySound(hcs:pHUD_SOUND_COLLECTION; alias:PChar; position:pFVector3; parent:pCObject; hud_mode:boolean; looped:boolean=false; index:byte=$FF);stdcall; asm pushad mov esi, hcs mov edi, alias movzx eax, index push eax movzx eax, looped push eax movzx eax, hud_mode push eax push parent push position mov eax, xrgame_addr add eax, $287380 call eax popad end; procedure HUD_SOUND_ITEM__StopSound(hud_snd:pHUD_SOUND_ITEM); stdcall; asm pushad mov eax, xrGame_addr add eax, $2872B0 mov edi, hud_snd call eax popad end; procedure HUD_SOUND_ITEM__DestroySound(hud_snd:pHUD_SOUND_ITEM); stdcall; asm pushad mov eax, xrGame_addr add eax, $287120 mov esi, hud_snd call eax popad end; procedure HUD_SOUND_COLLECTION__SetPosition(collection:pHUD_SOUND_COLLECTION; alias:PChar; pos:pFVector3); stdcall; asm pushad push pos mov edi, alias mov eax, collection mov ebx, xrGame_addr add ebx, $287460 call ebx popad end; procedure HUD_SOUND_COLLECTION_UnLoadSound(collection:pHUD_SOUND_COLLECTION; snd:pHUD_SOUND_ITEM); stdcall; begin if snd=nil then begin Log('HUD_SOUND_COLLECTION_UnLoadSound got snd=nil!', true); exit; end; HUD_SOUND_ITEM__StopSound(snd); HUD_SOUND_ITEM__DestroySound(snd); collection.last:=(pHUD_SOUND_ITEM(cardinal(collection.last)-sizeof(HUD_SOUND_ITEM))); if snd<>collection.last then snd^:=collection.last^; end; function HUD_SOUND_COLLECTION__FindSoundItem(collection:pHUD_SOUND_COLLECTION; alias:PChar):pHUD_SOUND_ITEM; stdcall; var i:pHUD_SOUND_ITEM; begin result:=nil; i:=collection.first; while cardinal(i)<cardinal(collection.last) do begin if StrComp(@i.m_alias.p_.value, alias)=0 then begin result:=i; break; end; i:= pHUD_SOUND_ITEM(cardinal(i)+sizeof(HUD_SOUND_ITEM)); end; end; procedure HUD_SOUND_COLLECTION_LoadSoundIfNotLoaded(hcs:pHUD_SOUND_COLLECTION; section:PChar; line:PChar; alias:PChar; snd_type:cardinal); stdcall; begin if HUD_SOUND_COLLECTION__FindSoundItem(hcs, alias) = nil then begin HUD_SOUND_COLLECTION__LoadSound(hcs, section, line, alias, snd_type); end; end; //////////////////////////////////////////////PATCHES//////////////////////////////////////////////////////////////////////// procedure HUD_SOUND_COLLECTION__LoadSound_Patch; stdcall; asm pushad push eax push esi call HUD_SOUND_COLLECTION_UnLoadSound popad end; procedure UpdateSoundsPos(collection:pHUD_SOUND_COLLECTION; pos:pFVector3);stdcall; var snd:pHUD_SOUND_ITEM; begin snd:=collection.first; while(snd<>collection.last) do begin if snd.m_activeSnd<>nil then begin HUD_SOUND_COLLECTION__SetPosition(collection, @snd.m_alias.p_.value, pos); end; snd:=pHUD_SOUND_ITEM(cardinal(snd)+sizeof(HUD_SOUND_ITEM)); end; end; procedure CWeaponMagazined__UpdateSounds_Patch(); stdcall; asm lea edx, [esp+$c] pushad push edx push esi call UpdateSoundsPos popad pop edi //ret addr push edx jmp edi end; //Правка на отключение прерывания звука при его рестарте (для стрельбы главным образом) procedure ref_sound__play_at_pos(this:pref_sound; O:pointer; pos:pFVector3; flags:cardinal; d:single); stdcall; asm pushad push d push flags push pos push o push this mov ecx, xrgame_addr; mov ecx, [ecx+$4DB300] mov ecx, [ecx] mov edi, [ecx] mov eax, [edi+$38] call eax popad end; procedure ref_sound__play_no_feedback(this:pref_sound; O:pointer; flags:cardinal; d:single; pos:pFVector3; vol:psingle; freq:psingle; range:pFVector2); stdcall; asm pushad push range push freq push vol push pos push d push flags push O push this mov ecx, xrgame_addr; mov ecx, [ecx+$4DB300] mov ecx, [ecx] mov edi, [ecx] mov eax, [edi+$3C] call eax popad end; function DecideHowToPlaySnd(snd:pHUD_SOUND_ITEM; O:pointer; pos:pFVector3; flags:cardinal):boolean; stdcall; const sm_Looped:cardinal = $1; begin if (Console.flags and FLG_SNDUNLOCK=0) or (snd.m_activeSnd.volume>=0) or ((flags and sm_Looped)<>0) then begin ref_sound__play_at_pos(@snd.m_activeSnd.snd, O, pos, flags, snd.m_activeSnd.delay); result:=true; end else begin ref_sound__play_no_feedback(@snd.m_activeSnd.snd, O, flags, snd.m_activeSnd.delay, pos,nil,nil,nil); result:=false; end; end; procedure HUD_SOUND_ITEM__PlaySound_Patch(); asm push ebp mov ebp, esp pushad push [ebp+$14] push [ebp+$10] push [ebp+$c] push edi call DecideHowToPlaySnd popad pop ebp ret $14 end; procedure PlaySoundWhenAnimStarts(itm:pCHudItem; anim_name:pshared_str); stdcall; var o:pCObject; pos:FVector3; snd_name:string; hud_sect:PChar; snd_type:cardinal; pwpn:pCWeapon; begin // log('PlaySnd'); // log (inttohex(cardinal(itm),8)); // log(PChar(@anim_name.p_.value)); if itm.m_object=nil then exit; o:=pCObject(itm.m_object); pos:= pFVector3(@o.base_IRenderable.renderable.xform.c)^; hud_sect:=PChar(@itm.hud_sect.p_.value); //Если на оружии глушитель и прописан звук для него - играем звук с глушителем, иначе всё как обычно pwpn:=dynamic_cast(itm, 0, RTTI_CHudItem, RTTI_CWeapon, false); if pwpn<>nil then begin if (pwpn.m_flagsAddOnState and AddOnState_Flag_Silencer)>0 then begin snd_name:='snd_sil_'+PChar(@anim_name.p_.value); if not game_ini_line_exist(hud_sect, PChar(snd_name)) then begin snd_name:='snd_'+PChar(@anim_name.p_.value); end; end else begin snd_name:='snd_'+PChar(@anim_name.p_.value); end; end else begin snd_name:='snd_'+PChar(@anim_name.p_.value); end; if game_ini_line_exist(hud_sect, PChar(snd_name)) then begin snd_type:=game_ini_r_int_def(hud_sect, PChar(snd_name+'_aitype'), -1); HUD_SOUND_COLLECTION__LoadSound(@itm.m_sounds, hud_sect, PChar(snd_name), PChar(snd_name), snd_type); HUD_SOUND_COLLECTION__PlaySound(@itm.m_sounds, PChar(snd_name),@pos, o, CHudItem__GetHUDmode(itm)); end; //Но у нас может быть необходимо проиграть еще один звук... Например, для гаусса и болтовок сам выстрел в пространстве никак не связан с перезарядкой snd_name:='sec_'+snd_name; if game_ini_line_exist(hud_sect, PChar(snd_name)) then begin snd_type:=game_ini_r_int_def(hud_sect, PChar(snd_name+'_aitype'), -1); HUD_SOUND_COLLECTION__LoadSound(@itm.m_sounds, hud_sect, PChar(snd_name), PChar(snd_name), snd_type); HUD_SOUND_COLLECTION__PlaySound(@itm.m_sounds, PChar(snd_name),@pos, o, CHudItem__GetHUDmode(itm)); end; end; procedure CHudItem__PlayHudMotion_Patch(); stdcall asm pushad push eax push ecx call PlaySoundWhenAnimStarts popad pop esi //ret addr push edi push esi //ret addr mov esi, [eax] test esi, esi end; procedure CHudItem__Load_PrepareSoundContainer(itm:pCHudItem; hsc:pHUD_SOUND_COLLECTION); stdcall; var i, sz:integer; hud_sect:PChar; begin hud_sect:=PChar(@itm.hud_sect.p_.value); sz:=game_ini_r_int_def(hud_sect, 'min_sound_container_size', 64); //раздуваем хранилище до указанных в конфиге размеров //log('Insreasing HUD_SOUND_COLLECTION on '+hud_sect+' on '+inttostr(sz)+' item(s)'); for i:=0 to sz-1 do begin HUD_SOUND_COLLECTION__LoadSound(hsc, hud_sect, PChar('_tmp_snd_'+inttostr(i)), PChar('_tmp_snd_'+inttostr(i)), $FFFFFFFF); end; for i:=0 to sz-1 do begin HUD_SOUND_COLLECTION_UnLoadSound(hsc, HUD_SOUND_COLLECTION__FindSoundItem(hsc, PChar('_tmp_snd_'+inttostr(i)))); end; end; procedure CHudItem__Load_Patch(); stdcall; asm mov [esi+$40], eax pop eax //ret addr push edi push eax lea eax, [esi+$44] pushad push eax push esi call CHudItem__Load_PrepareSoundContainer popad end; function Init(dwFlags:cardinal):boolean; var addr:cardinal; begin result:=false; if dwFlags and FLG_PATCH_GAME >0 then begin //[bug] баг иногда проявляется при попытках заюзать смену звука у оружия (в апгрейдах, например) - нужна перезагрузка звука в HUD_SOUND_COLLECTION вместо вылета. addr:=xrGame_addr+$287596; if not nop_code(addr, 37) then exit; if not WriteJump(addr, cardinal(@HUD_SOUND_COLLECTION__LoadSound_Patch), 5, true) then exit; //обновляем позиции всех звуков addr:=xrGame_addr+$261426; if not WriteJump(addr, cardinal(@CWeaponMagazined__UpdateSounds_Patch), 5, true) then exit; //фикс обрыва звука addr:=xrGame_addr+$28723F; if not WriteJump(addr, cardinal(@HUD_SOUND_ITEM__PlaySound_Patch), 5, true) then exit; //назначение звука при старте анимы addr:=xrGame_addr+$286BA7; if not WriteJump(addr, cardinal(@CHudItem__PlayHudMotion_Patch), 5, true) then exit; //отключаем стандартную схему назначения звука путем вырезания CHudItem__PlaySound addr:=xrGame_addr+$286510; if not WriteJump(addr, xrGame_addr+$286545, 5, false) then exit; //Подготовка контейнера на указанное число звуков addr:=xrGame_addr+$2864FC; if not WriteJump(addr, cardinal(@CHudItem__Load_Patch), 7, true) then exit; end; result:=true; end; end.
unit qFichaIndividualRecBimestral; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, qFichaIndividual, DB, kbmMemTable, ZAbstractRODataset, ZAbstractDataset, ZDataset, QuickRpt, TeEngine, Series, TeeProcs, Chart, DBChart, QrTee, QRCtrls, ComCtrls, StdCtrls, ExtCtrls, uFramePeriodo, Buttons, JvXPCore, JvXPButtons, JvExControls, JvColorBox, JvColorButton, uFrameAluno, uFrameClasse, uClasseBoletim; type TfrmFichaIndividualRecBim2 = class(TfrmFichaIndividual) rlbRecBim1: TQRLabel; rlbMediaBim1: TQRLabel; rlbRecBim2: TQRLabel; rlbMediaBim2: TQRLabel; rlbRecBim3: TQRLabel; rlbMediaBim3: TQRLabel; rlbMediaBim4: TQRLabel; rlbRecBim4: TQRLabel; cbFrequenciaTotal: TCheckBox; cbExibirAssis: TCheckBox; procedure qrBoletimBeforePrint(Sender: TCustomQuickRep; var PrintReport: Boolean); procedure GrpFtBoletimBeforePrint(Sender: TQRCustomBand; var PrintBand: Boolean); procedure cbObservacoesExtrasClick(Sender: TObject); procedure linhaDetalheBeforePrint(Sender: TQRCustomBand; var PrintBand: Boolean); protected procedure PreencheNotasFaltas(Periodo: Integer; Linha: TlinhaBoletim); override; private { Private declarations } public exibirPerFalta,exibirMediaNota,nomeDisp : string; { Public declarations } end; var frmFichaIndividualRecBim2: TfrmFichaIndividualRecBim2; implementation uses uDMPrincipal, uClasseCriterio; {$R *.dfm} { TfrmFichaIndividualRecBim2 } procedure TfrmFichaIndividualRecBim2.cbObservacoesExtrasClick(Sender: TObject); begin inherited; if cbObservacoesExtras.Checked then Height := Height + 20 else Height := Height - 20; end; procedure TfrmFichaIndividualRecBim2.GrpFtBoletimBeforePrint(Sender: TQRCustomBand; var PrintBand: Boolean); var temp:integer; begin temp := GrpFtBoletim.Height; inherited; if cbObservacoesExtras.Checked then GrpFtBoletim.Height := temp + mmObservarcoesExtras.Height else GrpFtBoletim.Height := temp; end; procedure TfrmFichaIndividualRecBim2.linhaDetalheBeforePrint(Sender: TQRCustomBand; var PrintBand: Boolean); var ibim: integer; Primario: Boolean; begin inherited; DMPrincipal.OpenSQL(sqlCursos, 'SELECT * FROM Cursos WHERE idCursos = ' + fraClasse.CodCurso); Primario := ((fraClasse.CodCurso = '10') or (sqlCursosModeloHistorico.AsInteger =1) or (sqlCursosModeloHistorico.AsInteger =3)) and (fraClasse.Serie <= DMPrincipal.qry_ParametrosSerieFaltasGeral.AsString); if (Vazio) or (not Boletins[IndBoletimAtual][IndDiscAtual].Exibir) then begin if DMPrincipal.qry_ParametrosTracosCampoemBrancoBoletim.Value = 1 then begin rlbMediaBim1.Caption:= '--------'; rlbMediaBim2.Caption:= '--------'; rlbMediaBim3.Caption:= '--------'; rlbMediaBim4.Caption:= '--------'; // rlbPercFalta.Caption:= '--------'; rlbFaltas1.Caption := '--------'; rlbFaltas2.Caption := '--------'; rlbFaltas3.Caption := '--------'; rlbFaltas4.Caption := '--------'; end else begin rlbMediaBim1.Caption:= ''; rlbMediaBim2.Caption:= ''; rlbMediaBim3.Caption:= ''; rlbMediaBim4.Caption:= ''; // rlbPercFalta.Caption:= ''; rlbFaltas1.Caption := ''; rlbFaltas2.Caption := ''; rlbFaltas3.Caption := ''; rlbFaltas4.Caption := ''; rlbSituacao.caption := ''; end; for ibim := 1 to DMPrincipal.Letivo.NumPeriodos do if (DMPrincipal.qry_ParametrosTracosCampoemBrancoBoletim.Value = 1) Then begin getLabel('rlbMediaBim', iBim).Caption := '--------'; getLabel('rlbRecBim', iBim).Caption := '--------'; getLabel('rlbFaltas', iBim).Caption := '--------'; end else begin getLabel('rlbMediaBim', iBim).Caption := ''; getLabel('rlbRecBim', iBim).Caption := ''; getLabel('rlbFaltas', iBim).Caption := ''; end; end; rlbMediaBim2.Enabled := (DMPrincipal.Letivo.NumPeriodos >= 2) and (fraPeriodo.Periodo >= 2); rlbMediaBim3.Enabled := (DMPrincipal.Letivo.NumPeriodos >= 3) and (fraPeriodo.Periodo >= 3); rlbMediaBim4.Enabled := (DMPrincipal.Letivo.NumPeriodos >= 4) and (fraPeriodo.Periodo >= 4); rlbRecBim2.Enabled := (DMPrincipal.Letivo.NumPeriodos >= 2) and (fraPeriodo.Periodo >= 2); rlbRecBim3.Enabled := (DMPrincipal.Letivo.NumPeriodos >= 3) and (fraPeriodo.Periodo >= 3); rlbRecBim4.Enabled := (DMPrincipal.Letivo.NumPeriodos >= 4) and (fraPeriodo.Periodo >= 4); rlbFaltas1.Enabled := True; rlbFaltas2.Enabled := (DMPrincipal.Letivo.NumPeriodos >= 2) and (fraPeriodo.Periodo >= 2); rlbFaltas3.Enabled := (DMPrincipal.Letivo.NumPeriodos >= 3) and (fraPeriodo.Periodo >= 3); rlbFaltas4.Enabled := (DMPrincipal.Letivo.NumPeriodos >= 4) and (fraPeriodo.Periodo >= 4); if Primario then begin rlbfaltas1.Enabled := False; rlbfaltas2.Enabled := False; rlbfaltas3.Enabled := False; rlbfaltas4.Enabled := False; end; rlbMediaFinal.Enabled := DMPrincipal.qry_ParametrosMediaFinalBol.Value = 1; if rlbNomeDisciplina.Caption = '' then begin rlbsituacao.Caption := ''; rlbMediaFinal.Caption := ''; end; if exibirPerFalta = '' then rlbFreq.caption := ''; end; procedure TfrmFichaIndividualRecBim2.PreencheNotasFaltas(Periodo: Integer; Linha: TlinhaBoletim); begin getLabel('rlbFaltas', Periodo).Top := 0; // inherited; //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx getLabel('rlbMediaBim', Periodo).Caption := ''; getLabel('rlbNotaBim', Periodo).Caption := ''; if Vazio then begin if DMPrincipal.qry_ParametrosTracosCampoemBrancoBoletim.Value = 1 then getLabel('rlbRecBim', Periodo).Caption := '--------' else getLabel('rlbRecBim', Periodo).Caption := ''; end else if linha.Dispensa[Periodo] <> '' then begin getLabel('rlbRecBim', Periodo).Caption := linha.Dispensa[Periodo]; if DMPrincipal.qry_Parametros.FieldByName('DispFalta').AsInteger = 1 then getLabel('rlbFaltas', Periodo).Caption := linha.dispensa[Periodo] else begin if linha.Faltas[Periodo] <> 0 then getLabel('rlbFaltas', Periodo).Caption := IntToStr(linha.Faltas[Periodo]) else begin if DMPrincipal.qry_ParametrosTracosCampoemBrancoBoletim.Value = 1 then getLabel('rlbFaltas', Periodo).Caption := '--------' else getLabel('rlbFaltas', Periodo).Caption := ''; end; end; end else begin SetNota(linha.NotasNormal[Periodo], getLabel('rlbNotaBim', Periodo), Linha, cnbNotaPeriodo, Periodo); SetNota(linha.NotasRec[Periodo], getLabel('rlbRecBim', Periodo), Linha, cnbNotaPeriodo, Periodo); SetNota(linha.Notas[Periodo], getLabel('rlbMediaBim', Periodo), Linha, cnbNotaPeriodo, Periodo); if not Primario then begin //Deixar em branco caso o aluno nao possua falta cadastrada (Não esquecer de usar no before print da banda o exibirMediaNota) if cbFrequenciaTotal.Checked then begin if nomeDisp <> rlbNomeDisciplina.Caption then begin nomeDisp := rlbNomeDisciplina.Caption; exibirPerFalta := ''; exibirMediaNota := ''; end; exibirPerFalta := exibirPerFalta + DMPrincipal.ExSQL('SELECT SUM(Falta) '+ 'FROM NotasFaltas '+ 'WHERE AnoLetivo = ' + QuotedStr(vUser.AnoLetivo) + ' AND Mat = ' + QuotedStr(rlbMatAluno.Caption) + ' AND Disc = ' + QuotedStr(Linha.CodDisciplina) ); exibirMediaNota:= exibirMediaNota + DMPrincipal.ExSQL('SELECT SUM(Nota) '+ 'FROM NotasFaltas '+ 'WHERE AnoLetivo = ' + QuotedStr(vUser.AnoLetivo) + ' AND Mat = ' + QuotedStr(rlbMatAluno.Caption) + ' AND Disc = ' + QuotedStr(Linha.CodDisciplina) ); if exibirPerFalta <> '' then begin rlbFreq.Caption := FormatFloat('0.00', StrToFloat(linha.PecFaltas)); rlbSituacao.Caption := ''; end else rlbFreq.Caption := ''; rlbFreq.Enabled := fraPeriodo.Periodo >= 4; end; if linha.Faltas[Periodo] = 0 then begin if DMPrincipal.qry_ParametrosTracosCampoemBrancoBoletim.Value = 1 then getLabel('rlbFaltas', Periodo).Caption := '--------' else getLabel('rlbFaltas', Periodo).Caption := '' end else getLabel('rlbFaltas', Periodo).Caption := IntToStr(linha.Faltas[Periodo]); end; end; if exibirMediaNota = '' then begin rlbMediaFinal.Caption := ''; rlbSituacao.Caption := ''; end; if exibirPerFalta = '' then rlbFreq.Caption := ''; end; procedure TfrmFichaIndividualRecBim2.qrBoletimBeforePrint(Sender: TCustomQuickRep; var PrintReport: Boolean); begin inherited; Qrshape4.width := 1046; if chkMostrarFoto.Checked then Qrshape4.width := 939; rlbDataEmissaoExtenso.Caption := DMPrincipal.qry_ParametrosCid.Value + ', ' + FormatDateTime('dd" de "mmmm" de "yyyy', date); QRShape3.Enabled := cbExibirAssis.Checked; rlbNomeSecretaria.Enabled := cbExibirAssis.Checked; rlbSecretariaLinha1.Enabled := cbExibirAssis.Checked; QRShape1.Enabled := cbExibirAssis.Checked; rlbNomeDiretor.Enabled := cbExibirAssis.Checked; rlbDiretorLinha1.Enabled := cbExibirAssis.Checked; rlbSecretariaLinha2.Enabled := cbExibirAssis.Checked; rlbDiretorLinha2.Enabled := cbExibirAssis.Checked; qrAssinatura.Enabled := cbExibirAssis.Checked; end; end.
unit OAuth2.Contract.Repository.Client; interface uses OAuth2.Contract.Entity.Client; type IOAuth2ClientRepository = interface ['{B6D9BC26-7634-4567-92DA-134BB1BB4658}'] function GetClientEntity(AClientIdentifier: string): IOAuth2ClientEntity; function ValidateClient(AClientIdentifier: string; AClientSecret: string; AGrantType: string): Boolean; end; implementation end.
unit SORM.Model.Conexao.Firedac.Conexao; interface uses SORM.Model.Conexao.Interfaces, FireDAC.Stan.Intf, FireDAC.Stan.Option, FireDAC.Stan.Error, FireDAC.UI.Intf, FireDAC.Phys.Intf, FireDAC.Stan.Def, FireDAC.Stan.Pool, FireDAC.Stan.Async, FireDAC.Phys, FireDAC.VCLUI.Wait, Data.DB, FireDAC.Comp.Client, FireDAC.Phys.FBDef, FireDAC.Phys.IBBase, FireDAC.Phys.FB; Type TModelConexaoFiredac = class(TInterfacedObject, IModelConexao) private FConexao : TFDConnection; public constructor Create(); destructor Destroy; override; class function New: IModelConexao; function Connection: TCustomConnection; function Firedac : TFDConnection; end; implementation uses System.SysUtils; { TModelConexaoFiredac } function TModelConexaoFiredac.Connection: TCustomConnection; begin Result := FConexao; end; constructor TModelConexaoFiredac.Create; begin FConexao := TFDConnection.Create(nil); FConexao.Params.DriverID := 'FB'; FConexao.Params.Database := 'D:\Usr\React\Database\SITE.FDB'; FConexao.Params.UserName := 'SYSDBA'; FConexao.Params.Password := 'masterkey'; FConexao.Connected := True; end; destructor TModelConexaoFiredac.Destroy; begin FreeAndNil(FConexao); inherited; end; function TModelConexaoFiredac.Firedac: TFDConnection; begin Result := TFDConnection(FConexao); end; class function TModelConexaoFiredac.New: IModelConexao; begin result := Self.Create; end; end.
unit LoadBoatReportTest; interface uses TestFramework, frxClass, frxDBSet, Classes, frxDesgn; type TLoadReportTest = class (TTestCase) private Stream: TStringStream; Report: TfrxReport; OKPO : array of string; procedure LoadReportFromFile(ReportName, ReportPath: string); procedure TStrArrAdd(const A : array of string); protected // подготавливаем данные для тестирования procedure SetUp; override; // возвращаем данные для тестирования procedure TearDown; override; published procedure LoadAllReportFormTest; end; implementation uses Authentication, FormStorage, CommonData, Storage, UtilConst; const ReportPath = '..\Reports\Boat'; { TLoadReportTest } procedure TLoadReportTest.TStrArrAdd(const A : array of string); var i : integer; begin SetLength(OKPO, Length(a)); for i := Low(A) to High(A) do OKPO[i] := A[i]; end; procedure TLoadReportTest.LoadReportFromFile(ReportName, ReportPath: string); begin // Загрузка из файла в репорт Report.LoadFromFile(ReportPath); // Сохранение отчета в базу Stream.Clear; Report.SaveToStream(Stream); Stream.Position := 0; TdsdFormStorageFactory.GetStorage.SaveReport(Stream, ReportName); // Считывание отчета из базы Report.LoadFromStream(TdsdFormStorageFactory.GetStorage.LoadReport(ReportName)); end; procedure TLoadReportTest.LoadAllReportFormTest; var i : integer; begin LoadReportFromFile('PrintMovement_Invoice', ReportPath + '\PrintMovement_Invoice.fr3'); exit; LoadReportFromFile('PrintReport_OrderClientByBoatGoods', ReportPath + '\PrintReport_OrderClientByBoatGoods.fr3'); exit; LoadReportFromFile('PrintReport_OrderClientByBoat', ReportPath + '\PrintReport_OrderClientByBoat.fr3'); LoadReportFromFile('PrintReport_OrderClientByBoatMov', ReportPath + '\PrintReport_OrderClientByBoatMov.fr3'); { LoadReportFromFile('PrintMovement_ProductionUnionCalc', ReportPath + '\PrintMovement_ProductionUnionCalc.fr3'); LoadReportFromFile('PrintMovement_ProductionUnion', ReportPath + '\PrintMovement_ProductionUnion.fr3'); LoadReportFromFile('PrintMovement_OrderInternal', ReportPath + '\PrintMovement_OrderInternal.fr3'); exit; LoadReportFromFile('Отчет Движение по комплектующим (партия заказ)', ReportPath + '\Отчет Движение по комплектующим (партия заказ).fr3'); LoadReportFromFile('Отчет Движение по комплектующим (кол-во)', ReportPath + '\Отчет Движение по комплектующим (кол-во).fr3'); LoadReportFromFile('Отчет Движение по комплектующим (вх цена)', ReportPath + '\Отчет Движение по комплектующим (вх цена).fr3'); LoadReportFromFile('PrintMovement_Send_3', ReportPath + '\PrintMovement_Send_3.fr3'); LoadReportFromFile('PrintMovement_Send_2', ReportPath + '\PrintMovement_Send_2.fr3'); LoadReportFromFile('PrintMovement_Send', ReportPath + '\PrintMovement_Send.fr3'); LoadReportFromFile('PrintMovement_IncomeSticker', ReportPath + '\PrintMovement_IncomeSticker.fr3'); exit; LoadReportFromFile('PrintReport_ProductionPersonal', ReportPath + '\PrintReport_ProductionPersonal.fr3'); LoadReportFromFile('PrintObject_Personal_barcode', ReportPath + '\PrintObject_Personal_barcode.fr3'); LoadReportFromFile('PrintMovement_OrderClientBarcode', ReportPath + '\PrintMovement_OrderClientBarcode.fr3'); LoadReportFromFile('PrintMovement_ProductionPersonal', ReportPath + '\PrintMovement_ProductionPersonal.fr3'); } LoadReportFromFile('PrintReceiptGoods_Structure', ReportPath + '\PrintReceiptGoods_Structure.fr3'); //LoadReportFromFile('PrintReceiptProdModel_StructureGoods', ReportPath + '\PrintReceiptProdModel_StructureGoods.fr3'); LoadReportFromFile('PrintReceiptProdModelGoods_Structure', ReportPath + '\PrintReceiptProdModelGoods_Structure.fr3'); LoadReportFromFile('PrintReceiptProdModel_Structure', ReportPath + '\PrintReceiptProdModel_Structure.fr3'); LoadReportFromFile('PrintProduct_StructureGoods', ReportPath + '\PrintProduct_StructureGoods.fr3'); LoadReportFromFile('PrintProduct_OrderConfirmation', ReportPath + '\PrintProduct_OrderConfirmation.fr3'); LoadReportFromFile('PrintProduct_Structure', ReportPath + '\PrintProduct_Structure.fr3'); LoadReportFromFile('PrintProduct_Offer', ReportPath + '\PrintProduct_Offer.fr3'); // LoadReportFromFile('Анализ продаж1', ReportPath + '\Анализ продаж1.fr3'); // LoadReportFromFile('Анализ продаж (группа)', ReportPath + '\Анализ продаж (группа).fr3'); // LoadReportFromFile('Анализ продаж (линия_группа)', ReportPath + '\Анализ продаж (линия_группа).fr3'); // LoadReportFromFile('Анализ продаж (торговая марка)', ReportPath + '\Анализ продаж (торговая марка).fr3'); // // LoadReportFromFile('PrintReport_SaleReturnIn_BarCode', ReportPath + '\PrintReport_SaleReturnIn_BarCode.fr3'); // LoadReportFromFile('PrintReport_SaleReturnIn', ReportPath + '\PrintReport_SaleReturnIn.fr3'); // LoadReportFromFile('PrintReport_ClientDebt', ReportPath + '\PrintReport_ClientDebt.fr3'); // LoadReportFromFile('PrintReport_Sale', ReportPath + '\PrintReport_Sale.fr3'); // LoadReportFromFile('PrintReport_ReturnIn', ReportPath + '\PrintReport_ReturnIn.fr3'); // LoadReportFromFile('PrintReport_Uniform', ReportPath + '\PrintReport_Uniform.fr3'); // LoadReportFromFile('PrintReport_Goods_RemainsCurrent', ReportPath + '\PrintReport_Goods_RemainsCurrent.fr3'); // LoadReportFromFile('Print_Check_GoodsAccount', ReportPath + '\Print_Check_GoodsAccount.fr3'); // LoadReportFromFile('Print_Check', ReportPath + '\Print_Check.fr3'); // LoadReportFromFile('Движение по покупателю (Акт сверки)', ReportPath + '\Движение по покупателю (Акт сверки).fr3'); // LoadReportFromFile('Движение по покупателю', ReportPath + '\Движение по покупателю.fr3'); // LoadReportFromFile('Отчет по расчетам', ReportPath + '\Отчет по расчетам.fr3'); // LoadReportFromFile('PrintMovement_Income', ReportPath + '\PrintMovement_Income.fr3'); // LoadReportFromFile('PrintMovement_IncomeIn', ReportPath + '\Приход от поставщика вх цена.fr3'); // LoadReportFromFile('PrintMovement_ReturnOut', ReportPath + '\PrintMovement_ReturnOut.fr3'); // LoadReportFromFile('PrintMovement_Send', ReportPath + '\PrintMovement_Send.fr3'); // LoadReportFromFile('PrintMovement_SendIn', ReportPath + '\PrintMovement_SendIn.fr3'); // LoadReportFromFile('PrintMovement_Loss', ReportPath + '\PrintMovement_Loss.fr3'); // LoadReportFromFile('PrintMovement_IncomeSticker', ReportPath + '\PrintMovement_IncomeSticker.fr3'); end; procedure TLoadReportTest.SetUp; begin inherited; TAuthentication.CheckLogin(TStorageFactory.GetStorage, 'Админ', gc_AdminPassword, gc_User); Report := TfrxReport.Create(nil); Stream := TStringStream.Create; end; procedure TLoadReportTest.TearDown; begin inherited; Report.Free; Stream.Free end; initialization TestFramework.RegisterTest('Загрузка отчетов', TLoadReportTest.Suite); end.
program test; uses NoiseFunc, BMP; const SOURCE = 'example.bmp'; function LoadFile(Filename : String) : array of byte; var F : File; Size : int64; Ret : array of byte; begin if not FileExists(Filename) then begin Result := nil; exit; end; WriteLn('Reading ', Filename, ' file...'); Assign(F, Filename); Reset(F); Size := FileSize(F); WriteLn('Filesize: ' , Size, ' bytes'); SetLength(Ret, Size); for i : integer := 0 to Size-1 do Read(F, Ret[i]); Close(F); WriteLn('File has been read'); Result := Ret; end; procedure SaveToFile(Filename: String; bmp: array of byte); var F: file; begin Assign(F, Filename); Rewrite(F); for i: integer := 0 to Length(bmp) - 1 do Write(F, bmp[i]); Close(F); WriteLn('BMP saved to ', Filename); end; var RowData, originalRowData : array of byte; pixelsRowArray : array of byte; pixelsArray : array[,] of byte; glassPixels, wavePixels, randomPixels, blurPixels : List<List<Pixel>>; orig, np, wave, ran, blur, all : List<List<Pixel>>; begin RowData := LoadFile(SOURCE); SetLength(originalRowData, RowData.Length); System.Array.Copy(RowData, 0, originalRowData, 0, RowData.Length); if RowData = nil then begin WriteLn('File ' + SOURCE + ' does not exist'); exit; end; WriteLn('Got row byte array'); if (not BMP.CheckBMPType(RowData) = 19778) AND (not BMP.CheckBMPType(RowData) = 16973) then begin WriteLn('This is not BMP file! Fail'); exit(); end else WriteLn('BMP file detected. Bits per pixel: ', BMP.GetBitcount(RowData), '. Pixel data size: ', BMP.GetSizeimage(RowData), '.'); BMP.GetPictureData(RowData); WriteLn('Width = ', BMP.width, ' | Height = ', BMP.height); pixelsRowArray := BMP.GetPixelsByteArray(RowData); orig := BuildPixels(pixelsRowArray); glassPixels := BuildPixels(pixelsRowArray); wavePixels := BuildPixels(pixelsRowArray); randomPixels := BuildPixels(pixelsRowArray); blurPixels := BuildPixels(pixelsRowArray); var glassCoeff, waveCoeff, ranCoeff, blurCoeff : integer; Write('Enter glass coefficient: '); repeat try ReadLn(glassCoeff); except on Exception do WriteLn('This is an invalid value! Try again.'); end; until glassCoeff <> 0; Write('Enter wave coefficient: '); repeat try ReadLn(waveCoeff); except on Exception do WriteLn('This is an invalid value! Try again.'); end; until waveCoeff <> 0; Write('Enter randomWave coefficient: '); repeat try ReadLn(ranCoeff); except on Exception do WriteLn('This is an invalid value! Try again.'); end; until ranCoeff <> 0; Write('Enter blur division: '); repeat try ReadLn(blurCoeff); except on Exception do WriteLn('This is an invalid value(default: 16)! Try again.'); end; until blurCoeff <> 0; np := NoiseFunc.GetGlassNoise(glassPixels, glassCoeff); BMP.SavePixels(RowData, np); SaveToFile('newG.bmp', RowData); wave := NoiseFunc.GetWaveNoise(wavePixels, waveCoeff); BMP.SavePixels(RowData, wave); SaveToFile('newW.bmp', RowData); ran := NoiseFunc.GetRandomWave(randomPixels, ranCoeff); BMP.SavePixels(RowData, ran); SaveToFile('newC.bmp', RowData); blur := NoiseFunc.GetBlur(blurPixels, blurCoeff); BMP.SavePixels(RowData, blur); SaveToFile('newB.bmp', RowData); all := BMP.ConcatPixels(np, wave, blur, orig); BMP.width *= 2; BMP.height *= 2; BMP.additional := BMP.width mod 4; BMP.totalPixelsBytesCount := ((BMP.width*3)+additional)*BMP.height; BMP.SavePixels(RowData, all); SaveToFile('output.bmp', RowData); end.
unit SnadnSpusteni; // Implementace podpory krabicky snadneho spusteni. interface uses Classes, IniFiles, StrUtils, SysUtils; type TSSData = record enabled:boolean; MtbAdr:Smallint; //adresa mtb AutRezim:Smallint; //pri klepnuti na zelene tlacitko spustit aut rezim... IN_Start:Smallint; //tlacitko na zapnuti IN_Pause:Smallint; //tlacitko na pozastaveni IN_Stop:Smallint; //talcitko na vypnuti IN_Repeat:Smallint; //tlacitko na opakovani IN_Reset:Smallint; //tlacitko na reset OUT_Ready:Smallint; //indikace pripraveno OUT_Start:Smallint; //indikace spusteno OUT_Pause:Smallint; //indikace pozastaveno OUT_Stop:Smallint; //indikace vypnuto OUT_Repeat:Smallint; //indikace opakovani end; TSS=class //adresy krabicky snadne spusteni private config:TSSData; RepeatDown:Boolean; public procedure Update(); //filesystem i/o procedure LoadData(ini:TMemIniFile); procedure SaveData(ini:TMemIniFile); function GetData():TSSData; procedure SetData(data:TSSData); end; var SS : TSS; implementation uses GetSystems, TBlok, AC, TechnologieRCS, fMain, TBloky, Logging, ACDatabase, Prevody, RCS; //////////////////////////////////////////////////////////////////////////////// procedure TSS.LoadData(ini:TMemIniFile); begin Self.config.enabled := ini.ReadBool('Snadne Spusteni', 'enabled',false); Self.config.MtbAdr := ini.ReadInteger('Snadne Spusteni', 'MtbAdr',-1); Self.config.AutRezim := ini.ReadInteger('Snadne Spusteni', 'AutRezim',-1); Self.config.IN_Start := ini.ReadInteger('Snadne Spusteni', 'IN_Start',-1); Self.config.IN_Pause := ini.ReadInteger('Snadne Spusteni', 'IN_Pause',-1); Self.config.IN_Stop := ini.ReadInteger('Snadne Spusteni', 'IN_Stop',-1); Self.config.IN_Repeat := ini.ReadInteger('Snadne Spusteni', 'IN_Repeat',-1); Self.config.IN_Reset := ini.ReadInteger('Snadne Spusteni', 'IN_Reset',-1); Self.config.OUT_Ready := ini.ReadInteger('Snadne Spusteni', 'OUT_Ready',-1); Self.config.OUT_Start := ini.ReadInteger('Snadne Spusteni', 'OUT_Start',-1); Self.config.OUT_Pause := ini.ReadInteger('Snadne Spusteni', 'OUT_Pause',-1); Self.config.OUT_Stop := ini.ReadInteger('Snadne Spusteni', 'OUT_Stop',-1); Self.config.OUT_Repeat := ini.ReadInteger('Snadne Spusteni', 'OUT_Repeat',-1); end;//procedure procedure TSS.SaveData(ini:TMemIniFile); begin ini.WriteBool('Snadne Spusteni', 'enabled',Self.config.enabled); ini.WriteInteger('Snadne Spusteni', 'MtbAdr',Self.config.MtbAdr); ini.WriteInteger('Snadne Spusteni', 'AutRezim',Self.config.AutRezim); ini.WriteInteger('Snadne Spusteni', 'IN_Start',Self.config.IN_Start); ini.WriteInteger('Snadne Spusteni', 'IN_Pause',Self.config.IN_Pause); ini.WriteInteger('Snadne Spusteni', 'IN_Stop',Self.config.IN_Stop); ini.WriteInteger('Snadne Spusteni', 'IN_Repeat',Self.config.IN_Repeat); ini.WriteInteger('Snadne Spusteni', 'IN_Reset',Self.config.IN_Reset); ini.WriteInteger('Snadne Spusteni', 'OUT_Ready',Self.config.OUT_Ready); ini.WriteInteger('Snadne Spusteni', 'OUT_Start',Self.config.OUT_Start); ini.WriteInteger('Snadne Spusteni', 'OUT_Stop',Self.config.OUT_Stop); ini.WriteInteger('Snadne Spusteni', 'OUT_Repeat',Self.config.OUT_Repeat); end;//procedure //////////////////////////////////////////////////////////////////////////////// procedure TSS.Update(); var AC:TAC; begin if ((not Self.config.enabled) or (not GetFunctions.GetSystemStart) or (Self.config.AutRezim >= ACDb.ACs.Count)) then Exit; AC := ACDb.ACs[Self.config.AutRezim]; if ((not RCSi.IsModule(Self.config.MtbAdr)) or (RCSi.IsModuleFailure(Self.config.MtbAdr))) then Exit(); //vstupy: try if ((Self.config.IN_Start > -1) and (not AC.running) and (AC.ready) and (RCSi.GetInput(Self.config.MtbAdr,Self.config.IN_Start) = isOn)) then AC.Start(); if ((Self.config.IN_Pause > -1) and (AC.running) and (RCSi.GetInput(Self.config.MtbAdr,Self.config.IN_Pause) = isOn)) then AC.Pause(); if ((Self.config.IN_Stop > -1) and (AC.running) and (RCSi.GetInput(Self.config.MtbAdr,Self.config.IN_Stop) = isOn)) then AC.Stop(); if (Self.config.IN_Repeat > -1) then begin if (RCSi.GetInput(Self.config.MtbAdr,Self.config.IN_Repeat) = isOn) then begin if (not Self.RepeatDown) then begin Self.RepeatDown := true; AC.repeating := not AC.repeating; end;//if not Self.config.RepeatDown end else begin if (Self.RepeatDown) then Self.RepeatDown := false; end; end;//if IN_Repeat_Used if ((Self.config.IN_Reset > -1) and (RCSi.GetInput(Self.config.MtbAdr,Self.config.IN_Reset) = isOn)) then begin // reset zatim neimplementovan end; // vystupy; if (Self.config.OUT_Ready > -1) then RCSi.SetOutput(Self.config.MtbAdr, Self.config.OUT_Ready, PrevodySoustav.BoolToInt((not AC.running) and (AC.ready))); if (Self.config.OUT_Start > -1) then RCSi.SetOutput(Self.config.MtbAdr, Self.config.OUT_Start, PrevodySoustav.BoolToInt(AC.running)); if (Self.config.OUT_Pause > -1) then RCSi.SetOutput(Self.config.MtbAdr, Self.config.OUT_Pause, PrevodySoustav.BoolToInt((not AC.running) and (AC.ACKrok > -1))); if (Self.config.OUT_Stop > -1) then RCSi.SetOutput(Self.config.MtbAdr, Self.config.OUT_Stop, PrevodySoustav.BoolToInt(not AC.running)); if (Self.config.OUT_Repeat > -1) then RCSi.SetOutput(Self.config.MtbAdr, Self.config.OUT_Repeat, PrevodySoustav.BoolToInt(AC.repeating)); except end; end;//procedure //////////////////////////////////////////////////////////////////////////////// function TSS.GetData():TSSData; begin Result := Self.config; end;//function procedure TSS.SetData(data:TSSData); begin Self.config := data; end;//procedure //////////////////////////////////////////////////////////////////////////////// initialization SS := TSS.Create(); finalization SS.Free; end.//unit
unit Facade.SubSystem.SubSystem1; interface type TSubSystem1 = class public function Operation1 : string; function OperationN : string; end; implementation { TSubSystem1 } function TSubSystem1.Operation1: string; begin Result := 'Subsystem1: Ready!'; end; function TSubSystem1.OperationN: string; begin Result := 'Subsystem1: Go!'; end; end.
unit uCtConector; interface uses uRoutingServicesCtConector; type // CLASSE UTILIZADA PARA CONEXAO COM O PABX AVAYA. // ESTA CLASSE EH DESCENDENTE DE TODA HIERARQUIA QUE IMPLEMENTA A COMUNICACAO // COM O PABX, DEVENDO SER UTILIZADA DIRETAMENTE EM QUALQUER IMPLEMENTACAO. // TODA SOLICITACAO AO PABX DEVE SER FEITA ATRAVES DAS FUNCOES EXISTENTES NESTA // CLASSE, SENDO QUE SEUS RETORNOS NÃO SIGNIFICAM QUE A SOLICITACAO FOI ATENDIDA, // MAS QUE ELA FOI ENVIADA AO PABX. // O CODIGO INTEIRO RETORNADO PELAS FUNCIOES É, NA VERDADE, O INVOKEID DA // SOLICITACAO QUE DEVE SER 'CASADO' COM O INVOKEID DA CONFIRMACAO EM QUESTAO. // POR EXEMPLO: // QUANDO FOR NECESSARIO REALIZAR UMA CHAMADA PREDITIVA (MAKEPREDICTIVECALL), // A UTILIZACAO DEVE SER A SEGUINTE: // PRIMEIRAMENTE DEVE SER IMPLEMENTADO O TRATADOR DE EVENTO DE CONFIRMACAO // PARA O MAKEPREDICTIVECALL, COM PROTOTYPE DEFINIDO EM uCtEvents: { procedure MinhaClasse.DoOnMakePredictiveCallConf( Sender : TObject; InvokeID : TInvokeID; newCall : ConnectionID_t; ucid : ATTUCID_t ); begin // NESTE EVENTO TENHO TUDO QUE EU PRECISO: // - INVOKEID QUE SERA BATIDO COM O OBTIDO NA CHAMADA DO METODO //MakePredictiveCall; // - CALLID DA NOVA CHAMADA EM newCall.callId. // A PARTIR DO INSTANTE QUE RECEBI ESTA CONFIRMACAO, TENHO CERTEZA QUE O // PABX ESTÁ EFETIVAMENTE PROCESSANDO MINHA REQUISICAO. // OUTRAS FUNCIONALIDADES (QUE NAO O MAKEPREDICTIVECALL) FUNCIONAM DE FORMA // ANÁLOGA. end; } // EM SEGUIDA PODE SER IMPLEMENTADA A CHAMADA DO METODO: { var ctResult : Integer begin ctResult := Objeto.MakePredictiveCall(Parametros); if ctResult >= 0 then begin // SOLICITACAO FEITA COM SUCESSO // GUARDAR O VALOR DE ctResult PARA QUE ELE SEJA BATIDO COM A CONFIRMACAO // NO EVENTO OnCSTAMakePredictiveCallConf OU ATE MESMO AS TRANSICOES DE UMA // MAQUINA DE ESTADOS QUE AGUARDARÁ A CONFIRMACAO. end else begin // ERRO NA SOLICITACAO. A UNIT uTranslations PODE SER UTILIZADA PARA MELHOR // DESCRICAO DO ERRO. ShowMessage( Format( 'Erro em MakePredictiveCall: %s', [ CtReturnToStr( ctResult ) ] ); end; end; } TCtConector = class( TRoutingServicesCtConector ); implementation end.
unit Compute_u; interface uses SysUtils, Windows, Messages, Variants, Classes, Graphics, Controls, Forms, Dialogs, TeEngine, Series, ExtCtrls, TeeProcs, Chart, StdCtrls, Buttons, Advanced, Compress_u, ULZMAEncoder, ULZMACommon; type TDlgCompute = class(TForm) LZMAChart: TChart; BtnOk: TBitBtn; BtnCancel: TBitBtn; gbOptions: TGroupBox; gbCurrentMode: TGroupBox; Label1: TLabel; cbPriority: TComboBox; btnCompute: TBitBtn; Level: TBarSeries; procedure FormCreate(Sender: TObject); procedure SearchDir(Dir: string); procedure btnComputeClick(Sender: TObject); procedure BtnCancelClick(Sender: TObject); function CompressStream(InStream,OutStream:Tstream;CompressLevel:TMZFCompressionLevel):Boolean; private { Private declarations } public SelectedStamp:TMZFCompressionLevel; Files:TStringList; { Public declarations } end; var DlgCompute: TDlgCompute; Stop:Boolean; implementation {$R *.dfm} procedure TDlgCompute.SearchDir(Dir: string); var SR: TSearchRec; FindRes: Integer; begin FindRes := FindFirst(Dir + '*.*', faAnyFile, SR); while FindRes = 0 do begin if ((SR.Attr and faDirectory) = faDirectory) and ((SR.Name = '.') or (SR.Name = '..')) then begin FindRes := FindNext(SR); Continue; end; if ((SR.Attr and faDirectory) = faDirectory) then begin SearchDir(Dir + SR.Name + '\'); FindRes := FindNext(SR); Continue; end; Files.Add(Dir + SR.Name);//Add to list FindRes := FindNext(SR); end; FindClose(FindRes); end; procedure TDlgCompute.FormCreate(Sender: TObject); begin Stop:=False; Files:=TStringList.Create; end; function TDlgCompute.CompressStream(InStream,OutStream:Tstream;CompressLevel:TMZFCompressionLevel):Boolean; Var Data:Byte; encoder:TLZMAEncoder; i:Byte; Begin InStream.Position:=0; encoder:=TLZMAEncoder.Create; encoder.SetAlgorithm(1); encoder.SetDictionarySize(CompressLevel.DictitionarySize); encoder.SetMatchFinder(CompressLevel.MathFinder); encoder.SeNumFastBytes(CompressLevel.FastBytes); encoder.SetLcLpPb(CompressLevel.LiteralContextBits,CompressLevel.LiteralPosBits,CompressLevel.PosBits); encoder.WriteCoderProperties(outStream); for i := 0 to 7 do WriteByte(outStream,(InStream.Size shr (8 * i)) and $FF); encoder.Code(InStream,OutStream,-1,-1); Data:=0; End; procedure TDlgCompute.btnComputeClick(Sender: TObject); Var InStream,OutStream,WAD:TMemoryStream; FileIndex:LongWord; aTPriority,aPPriority:Integer; FileDir:String; OperationIndex:Byte; Results:Array[0..5]Of Byte; InSize,OutSize:LongWord; begin BtnOk.Enabled:=False; BtnCompute.Enabled:=False; cbPriority.Enabled:=False; Case cbPriority.ItemIndex Of 0:Begin aTPriority:=THREAD_PRIORITY_IDLE; aPPriority:=IDLE_PRIORITY_CLASS; End; 1:Begin aTPriority:=THREAD_PRIORITY_BELOW_NORMAL; aPPriority:=NORMAL_PRIORITY_CLASS; End; 2:Begin aTPriority:=THREAD_PRIORITY_NORMAL; aPPriority:=NORMAL_PRIORITY_CLASS; End; 3:Begin aTPriority:=THREAD_PRIORITY_HIGHEST; aPPriority:=HIGH_PRIORITY_CLASS; End; 4:Begin aTPriority:=THREAD_PRIORITY_TIME_CRITICAL; aPPriority:=REALTIME_PRIORITY_CLASS; End; End; SetPriority(aPPriority,aTPriority); For FileIndex:=0 To Files.Count-1 Do Begin If Stop Then Exit; FileDir:=ExtractFileDir(Files.Strings[FileIndex]); If FileDir[Length(FileDir)]<>'\' Then FileDir:=FileDir+'\'; If ExtractFileExt(Files.Strings[FileIndex])='.*' Then Begin //showmessage(FileDir); SearchDir(FileDir); //Files.Delete(FileIndex); End; End; FileIndex:=0; While FileIndex<=Files.Count-1 Do Begin If Stop Then Exit; If ExtractFileExt(Files.Strings[FileIndex])='.*' Then Begin Files.Delete(FileIndex); End Else Inc(FileIndex); End; WAD:=TMemoryStream.Create; For FileIndex:=0 To Files.Count-1 Do Begin If Stop Then Exit; InStream:=TMemoryStream.Create; InStream.LoadFromFile(Files.Strings[FileIndex]); InStream.SaveToStream(WAD); //WAD.Position:=WAD.Size; InStream.Free; End; Application.ProcessMessages; InStream:=TMemoryStream.Create; Wad.Position:=0; CompressStream(WAD,InStream,SelectedStamp); Results[0]:=100-GetPercentDone(0,InStream.Size,WAD.Size); Level.Add(Results[0],'Current',clBlue); InStream.Free; Application.ProcessMessages; For OperationIndex:=1 To 5 Do Begin Case OperationIndex Of 1:Begin SelectedStamp.DictitionarySize:=16; SelectedStamp.MathFinder:=0; SelectedStamp.FastBytes:=5; SelectedStamp.LiteralContextBits:=8; SelectedStamp.LiteralPosBits:=4; SelectedStamp.PosBits:=4; SelectedStamp.EncodeAlgorithm:=eaAES256; SelectedStamp.Priority:=2; End; 2:Begin SelectedStamp.DictitionarySize:=20; SelectedStamp.MathFinder:=0; SelectedStamp.FastBytes:=80; SelectedStamp.LiteralContextBits:=6; SelectedStamp.LiteralPosBits:=2; SelectedStamp.PosBits:=2; SelectedStamp.EncodeAlgorithm:=eaAES256; SelectedStamp.Priority:=2; End; 3:Begin SelectedStamp.DictitionarySize:=24; SelectedStamp.MathFinder:=1; SelectedStamp.FastBytes:=128; SelectedStamp.LiteralContextBits:=3; SelectedStamp.LiteralPosBits:=1; SelectedStamp.PosBits:=2; SelectedStamp.EncodeAlgorithm:=eaAES256; SelectedStamp.Priority:=3; End; 4:Begin SelectedStamp.DictitionarySize:=25; SelectedStamp.MathFinder:=1; SelectedStamp.FastBytes:=200; SelectedStamp.LiteralContextBits:=2; SelectedStamp.LiteralPosBits:=0; SelectedStamp.PosBits:=1; SelectedStamp.EncodeAlgorithm:=eaAES256; SelectedStamp.Priority:=3; End; 5:Begin SelectedStamp.DictitionarySize:=28; SelectedStamp.MathFinder:=2; SelectedStamp.FastBytes:=273; SelectedStamp.LiteralContextBits:=0; SelectedStamp.LiteralPosBits:=0; SelectedStamp.PosBits:=0; SelectedStamp.EncodeAlgorithm:=eaAES256; SelectedStamp.Priority:=4; End; End; Wad.Position:=0; Application.ProcessMessages; InStream:=TMemoryStream.Create; CompressStream(WAD,InStream,SelectedStamp); Results[OperationIndex]:=100-GetPercentDone(0,InStream.Size,WAD.Size); Level.Add(Results[OperationIndex],Format('Level %d',[OperationIndex]),clRed); InStream.Free; End; WAD.Free; SetPriority(NORMAL_PRIORITY_CLASS,THREAD_PRIORITY_NORMAL); BtnOk.Enabled:=True; end; procedure TDlgCompute.BtnCancelClick(Sender: TObject); begin Stop:=True; ModalResult:=mrCancel; end; end.
unit untMain; 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.Controls.Presentation, FMX.ListBox, ksTypes, ksTableView, ksSegmentButtons; type TForm24 = class(TForm) ksTableView1: TksTableView; ToolBar2: TToolBar; ToolBar1: TToolBar; Label1: TLabel; ksSegmentButtons1: TksSegmentButtons; Label2: TLabel; switchSelect: TSwitch; procedure FormCreate(Sender: TObject); procedure ksSegmentButtons1Change(Sender: TObject); procedure switchSelectSwitch(Sender: TObject); procedure ksTableView1IndicatorExpand(Sender: TObject; AItem: TksTableViewItem; ABackground: TAlphaColor; var AForeground: TAlphaColor); procedure ksTableView1ItemClick(Sender: TObject; x, y: Single; AItem: TksTableViewItem; AId: string; ARowObj: TksTableViewItemObject); private { Private declarations } public { Public declarations } end; var Form24: TForm24; implementation uses System.UIConsts; {$R *.fmx} procedure TForm24.FormCreate(Sender: TObject); begin ksTableView1.BeginUpdate; try ksTableView1.Items.AddItem('Red', atMore).IndicatorColor := claRed; ksTableView1.Items.AddItem('Orange', atMore).IndicatorColor := claOrange; ksTableView1.Items.AddItem('Yellow', atMore).IndicatorColor := claYellow; ksTableView1.Items.AddItem('Green', atMore).IndicatorColor := claGreenyellow; ksTableView1.Items.AddItem('Blue', atMore).IndicatorColor := claBlue; ksTableView1.Items.AddItem('Indigo', atMore).IndicatorColor := claIndigo; ksTableView1.Items.AddItem('Violet', atMore).IndicatorColor := claViolet; finally ksTableView1.EndUpdate; end; end; procedure TForm24.ksSegmentButtons1Change(Sender: TObject); begin case ksSegmentButtons1.ItemIndex of 0: ksTableView1.RowIndicators.Alignment := TksTableViewRowIndicatorAlign.ksRowIndicatorLeft; 1: ksTableView1.RowIndicators.Alignment := TksTableViewRowIndicatorAlign.ksRowIndicatorRight; end; end; procedure TForm24.ksTableView1IndicatorExpand(Sender: TObject; AItem: TksTableViewItem; ABackground: TAlphaColor; var AForeground: TAlphaColor); begin if ABackground = claRed then AForeground := claWhite; if ABackground = claOrange then AForeground := claWhite; if ABackground = claBlue then AForeground := claWhite; if ABackground = claIndigo then AForeground := claWhite; if ABackground = claViolet then AForeground := claWhite; end; procedure TForm24.ksTableView1ItemClick(Sender: TObject; x, y: Single; AItem: TksTableViewItem; AId: string; ARowObj: TksTableViewItemObject); begin ShowMessage(aid); end; procedure TForm24.switchSelectSwitch(Sender: TObject); begin ksTableView1.RowIndicators.SelectRow := switchSelect.IsChecked; ksTableView1.SelectionOptions.ShowSelection := not switchSelect.IsChecked; end; end.
{hint: Pascal files location: ...\AppBatteryManagerDemo1\jni } unit unit1; {$mode delphi} interface uses {$IFDEF UNIX}{$IFDEF UseCThreads} cthreads, {$ENDIF}{$ENDIF} Classes, SysUtils, AndroidWidget, Laz_And_Controls, batterymanager; type { TAndroidModule1 } TAndroidModule1 = class(jForm) jBatteryManager1: jBatteryManager; jButton1: jButton; jTextView1: jTextView; procedure jBatteryManager1Charging(Sender: TObject; batteryAtPercentLevel: integer; pluggedBy: TChargePlug); procedure jBatteryManager1DisCharging(Sender: TObject; batteryAtPercentLevel: integer); procedure jBatteryManager1Full(Sender: TObject; batteryAtPercentLevel: integer); procedure jBatteryManager1NotCharging(Sender: TObject; batteryAtPercentLevel: integer); procedure jBatteryManager1Unknown(Sender: TObject; batteryAtPercentLevel: integer); procedure jButton1Click(Sender: TObject); private {private declarations} public {public declarations} end; var AndroidModule1: TAndroidModule1; implementation {$R *.lfm} { TAndroidModule1 } procedure TAndroidModule1.jBatteryManager1Charging(Sender: TObject; batteryAtPercentLevel: integer; pluggedBy: TChargePlug); begin case pluggedBy of cpUSB: ShowMessage('Charging... by USB: '+IntToStr(batteryAtPercentLevel)+'%'); cpAC: ShowMessage('Charging... by AC: '+IntToStr(batteryAtPercentLevel)+'%'); cpUnknown: ShowMessage('Charging... : '+IntToStr(batteryAtPercentLevel)+'%'); end; end; procedure TAndroidModule1.jBatteryManager1DisCharging(Sender: TObject; batteryAtPercentLevel: integer); begin ShowMessage('DisCharging... : '+IntToStr(batteryAtPercentLevel)+'%'); end; procedure TAndroidModule1.jBatteryManager1Full(Sender: TObject; batteryAtPercentLevel: integer); begin ShowMessage('Full... : '+IntToStr(batteryAtPercentLevel)+'%'); end; procedure TAndroidModule1.jBatteryManager1NotCharging(Sender: TObject; batteryAtPercentLevel: integer); begin ShowMessage('NotCharging... : '+IntToStr(batteryAtPercentLevel)+'%'); end; procedure TAndroidModule1.jBatteryManager1Unknown(Sender: TObject; batteryAtPercentLevel: integer); begin ShowMessage('Unknown... : '+IntToStr(batteryAtPercentLevel)+'%'); end; procedure TAndroidModule1.jButton1Click(Sender: TObject); begin ShowMessage('Battery = '+ IntToStr(jBatteryManager1.GetBatteryPercent())+'%') end; end.
unit GLImages; interface uses SysUtils, DUtils; type TGLImage = class protected W, H: Integer; Buf: array of TRGBAColor; public bAntialias: Boolean; constructor Create; virtual; property Width: Integer read W; property Height: Integer read H; procedure Resize(NewWidth, NewHeight: Integer; FillColor: TRGBAColor); virtual; function GetPixel(X, Y: Integer): TRGBAColor; virtual; procedure SetPixel(X, Y: Integer; NewColor: TRGBAColor); virtual; property Pixel[X, Y: Integer]: TRGBAColor read GetPixel write SetPixel; function GetGreyPixel(X, Y: Integer): Byte; virtual; procedure SetGreyPixel(X, Y: Integer; NewColor: Byte); virtual; property GreyPixel[X, Y: Integer]: Byte read GetGreyPixel write SetGreyPixel; function BakeToA: LongWord; virtual; function BakeToL: LongWord; virtual; function BakeToLA: LongWord; virtual; function BakeToRGBA: LongWord; virtual; end; EGLImageError = class(Exception); implementation uses GL, GLU, GLD; procedure SetAntialias(bAntialias: Boolean); begin if bAntialias then begin glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); end else begin glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); end; end; constructor TGLImage.Create; begin bAntialias := True; end; procedure TGLImage.Resize(NewWidth, NewHeight: Integer; FillColor: TRGBAColor); var I: Integer; begin //if NewWidth < 0 then raise EGLImageError.Create('Resize to width ' + IntToStr(NewWidth) + ' is invalid.'); //if NewHeight < 0 then raise EGLImageError.Create('Resize to height ' + IntToStr(NewHeight) + ' is invalid.'); SetLength(Buf, 0); W := NewWidth; H := NewHeight; SetLength(Buf, W * H); for I := 0 to High(Buf) do Buf[I] := FillColor ; end; function TGLImage.GetPixel(X, Y: Integer): TRGBAColor; begin if X < 0 then raise EGLImageError.Create('GetPixel X=' + IntToStr(X) + ' is off the image.'); if Y < 0 then raise EGLImageError.Create('GetPixel Y=' + IntToStr(Y) + ' is off the image.'); if X >= W then raise EGLImageError.Create('GetPixel X=' + IntToStr(X) + ' is off the image.'); if Y >= H then raise EGLImageError.Create('GetPixel Y=' + IntToStr(Y) + ' is off the image.'); Result := Buf[X + Y*Width]; end; procedure TGLImage.SetPixel(X, Y: Integer; NewColor: TRGBAColor); begin if X < 0 then raise EGLImageError.Create('SetPixel X=' + IntToStr(X) + ' is off the image.'); if Y < 0 then raise EGLImageError.Create('SetPixel Y=' + IntToStr(Y) + ' is off the image.'); if X >= W then raise EGLImageError.Create('SetPixel X=' + IntToStr(X) + ' is off the image.'); if Y >= H then raise EGLImageError.Create('SetPixel Y=' + IntToStr(Y) + ' is off the image.'); Buf[X + Y*Width] := NewColor; end; function TGLImage.GetGreyPixel(X, Y: Integer): Byte; begin if X < 0 then raise EGLImageError.Create('GetPixel X=' + IntToStr(X) + ' is off the image.'); if Y < 0 then raise EGLImageError.Create('GetPixel Y=' + IntToStr(Y) + ' is off the image.'); if X >= W then raise EGLImageError.Create('GetPixel X=' + IntToStr(X) + ' is off the image.'); if Y >= H then raise EGLImageError.Create('GetPixel Y=' + IntToStr(Y) + ' is off the image.'); with Buf[X + Y*Width] do Result := (R + G + B + 1) div 3 ; end; procedure TGLImage.SetGreyPixel(X, Y: Integer; NewColor: Byte); begin if X < 0 then raise EGLImageError.Create('SetPixel X=' + IntToStr(X) + ' is off the image.'); if Y < 0 then raise EGLImageError.Create('SetPixel Y=' + IntToStr(Y) + ' is off the image.'); if X >= W then raise EGLImageError.Create('SetPixel X=' + IntToStr(X) + ' is off the image.'); if Y >= H then raise EGLImageError.Create('SetPixel Y=' + IntToStr(Y) + ' is off the image.'); with Buf[X + Y*Width] do begin R := NewColor; G := NewColor; B := NewColor; end; end; function TGLImage.BakeToA: LongWord; var BufRaw: array of Word; I: Integer; begin SetLength(BufRaw, W * H); for I := 0 to High(BufRaw) do BufRaw[I] := (Buf[I].A shl 8) or $00FF ; glGenTextures(1, @Result); SetBoundTexture(Result); gluBuild2DMipmaps(GL_TEXTURE_2D, 2, W, H, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, @BufRaw[0]); SetLength(BufRaw, 0); SetAntialias(bAntialias); end; function TGLImage.BakeToL: LongWord; var BufRaw: array of Byte; I: Integer; begin SetLength(BufRaw, W * H); for I := 0 to High(BufRaw) do with Buf[I] do BufRaw[I] := (R + B + G + 1) div 3 ; glGenTextures(1, @Result); SetBoundTexture(Result); gluBuild2DMipmaps(GL_TEXTURE_2D, 1, W, H, GL_LUMINANCE, GL_UNSIGNED_BYTE, @BufRaw[0]); SetLength(BufRaw, 0); SetAntialias(bAntialias); end; function TGLImage.BakeToLA: LongWord; var BufRaw: array of Word; I: Integer; begin SetLength(BufRaw, W * H); for I := 0 to High(BufRaw) do with Buf[I] do BufRaw[I] := (A shl 8) or ((R + B + G + 1) div 3) ; glGenTextures(1, @Result); SetBoundTexture(Result); gluBuild2DMipmaps(GL_TEXTURE_2D, 2, W, H, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, @BufRaw[0]); SetLength(BufRaw, 0); SetAntialias(bAntialias); end; function TGLImage.BakeToRGBA: LongWord; begin glGenTextures(1, @Result); SetBoundTexture(Result); gluBuild2DMipmaps(GL_TEXTURE_2D, 4, W, H, GL_RGBA, GL_UNSIGNED_BYTE, @Buf[0]); SetAntialias(bAntialias); end; end.
PROGRAM Rev(INPUT, OUTPUT); PROCEDURE Reverse (VAR F: TEXT); VAR Ch: CHAR; BEGIN { Reverse } IF NOT EOLN(F) THEN BEGIN READ(Ch); WRITE(Ch) END END; { Reverse } BEGIN { Rev } Reverse(INPUT); WRITELN END. { Rev }
unit IEasyDriver; ////////////////////////////////////////////////////////////////////////// // Revision : 11-03-2003 ////////////////////////////////////////////////////////////////////////// interface uses KernelIOP; const // LOWORD is major version, HIWORD is minor version (minor:16|major:16) // minor|major ED_MAJOR_VERSION = $1; // essential change ED_MINOR_VERSION = $0; // not essential change ED_CURRENT_VERSION = (ED_MAJOR_VERSION or (ED_MINOR_VERSION shl 16)); // Setup EASYDEVICESETUP_TYPE = $1000; DEVICESETUP_TYPE = $1001; DEVICELINK_TYPE = $1002; // Low level PORTIO_TYPE = $1010; PORTIOS_TYPE = $1011; PORTIO4ISR_TYPE = $1012; PORTIOFLASH_TYPE = $1020; PORTIODAC_TYPE = $1021; PORTIOTIMER_TYPE = $1022; PORTIOPLL_TYPE = $1023; // Interrupt INTERRUPTEVENT_TYPE = $1030; INTERRUPTCALL_TYPE = $1031; DEVICEREADYWAIT_TYPE = $1032; // Get Information from device DEVICEINFO_TYPE = $1040; // Easy TRANSFERDATA_TYPE = $1100; // Error IEASYDRIVER_ERROR_NOT_SUPPORTED_DEVICE = -1; IEASYDRIVER_ERROR_NOT_SUPPORTED_VERSION = -2; IEASYDRIVER_ERROR_NOT_INITIALIZATION_DEVICE = -3; IEASYDRIVER_ERROR_OUT_OF_RANGE = -4; type // Base class... ParametersBase = object m_nType : Integer; m_nSizeOf : Integer; end; PParametersBase = ^ParametersBase; TIEasyDriver = class public Function AddRef : Cardinal; virtual; StdCall; abstract; Function Release : Cardinal; virtual; StdCall; abstract; // return > 0 if success // return == 0 if operation not support // return < 0 if error, return IEASYDRIVER_ERROR_... code, call GetLastError() function for details Function IO(P : PParametersBase) : Integer; virtual; StdCall; abstract; end; PIEasyDriver = ^TIEasyDriver; // Device IO or memory space DIOP_rec = record Case Integer Of 0: (m_uType: Cardinal;); // Common fields 1: (m_cUsed, // if == 0 then not used (???) m_cType, // IO or memory m_cRangeAccess, // BYTE, WORD, DWORD ... (bits mask) m_cGranulity: Byte); // 1, 2, 4, ... end; DeviceIOPort = object m_types : DIOP_rec; m_uBase, // Base Address m_uSize : Cardinal; // Range of address space m_pAdr : Pointer; // linear address for memory access end; const DEVICEIOPORT_RANGE_BYTE = $01; // byte access DEVICEIOPORT_RANGE_WORD = $02; // word access DEVICEIOPORT_RANGE_DWORD = $04; // dword access DEVICEIOPORT_RANGE_QWORD = $08; // qword access DEVICEIOPORT_RANGE_32 = $10; // for next version DEVICEIOPORT_RANGE_1K = $20; // for next version DEVICEIOPORT_RANGE_2K = $40; // for next version DEVICEIOPORT_RANGE_4K = $80; // for next version type // Definition... IBaseDevice = class public end; PIBaseDevice = ^IBaseDevice; //////////////////////////////////////////// // Setup structures //////////////////////////////////////////// // Get device parameters from system registry or P&P and Init EasyDeviceSetup = object ( ParametersBase ) public m_szDeviceName : PChar; // Device name m_nDeviceNumber : Integer; // Device number Constructor Create; end; // Get device driver interface and setup from user DeviceSetup = object ( ParametersBase ) public m_DevicePort: packed array [1..6] of DeviceIOPort; // Device Ports structures ( if m_cUsed == 0 then not m_uDRQ : packed array [1..2] of Cardinal; // DRQ channells ( 0 if not used ) m_uIRQ : packed array [1..2] of Cardinal; // IRQ channells ( 0 if not used ) Constructor Create; end; // Structure for Link by other... DeviceLink = object ( ParametersBase ) public m_nLinkType : Integer; // Type of link m_pIBaseDevice : PIBaseDevice; // pointer to interface IBaseDevice Constructor Create; end; ///////////////////////////////////////////////////// // Low level programming structures ///////////////////////////////////////////////////// // Single Virtual port IO PortIO = object ( ParametersBase ) public m_nPort : Cardinal; // Virtual Port number (register number) m_Modes : KIOP_ModeRec; m_Masks : KIOP_MaskRec; m_Values : KIOP_ValueRec; Constructor Create; end; // Multiply Virtual port IOs PortIOs = object ( ParametersBase ) public m_nKIOP : Integer; // Number of KIOP fields m_pKIOP : ^KIOP; // Pointer to KIOP structures Constructor Create; end; // Multiply Virtual port IOs for ISR PortIO4ISR = object ( PortIOs ) public Constructor Create; end; // Flash memory operations PortIOFlash = object ( ParametersBase ) public m_nMode : Integer; // Operation mode m_nSize : Integer; // Size of transfer m_pData : Pointer; // Pointer to Transfer data Constructor Create; end; // Tuning & internal DACs operations PIODAC_DataRec = record Case Cardinal of // DAC data 0: (m_uData : Cardinal;); 1: (m_wData : Word;); 2: (m_cData : Byte;); end; PortIODAC = object ( ParametersBase ) public m_nNumber : Integer; // DAC number m_Datas : PIODAC_DataRec; Constructor Create; end; // i8254 & owher timer operations PIOTimer_ModeRec = record Case Cardinal of 0: (m_uMode : Cardinal;); // Timer mode and R/W 1: (m_wMode, // Timer mode m_wRW : Word;); // R/W flag end; PortIOTimer = object ( ParametersBase ) public m_nNumber : Integer; // Timer Number m_Modes : PIOTimer_ModeRec; m_uValue : Cardinal; // Timer counter Constructor Create; end; // PLL frequensy syntese PortIOPLL = object ( ParametersBase ) public m_nNumber : Integer; // PLL Number m_fFreq : Single; // PLL freq Constructor Create; end; //////////////////////////////////////////////////// // Synchronise structures //////////////////////////////////////////////////// // Struct for interrupt processing IE_MsgRec = record Case Integer of 0: (m_uMessage : Cardinal;); // message ID 1: (m_hEvent: Integer;); // handle to Event end; InterruptEvent = object ( ParametersBase ) public m_nIntOf : Cardinal; // Interrupt mode m_hWnd : Cardinal; // HWND if(m_hWnd == 0) use m_hEvent m_IEMsg : IE_MsgRec; // else use m_uMessage m_iLParam : Cardinal; // LPARAM (any 32 bit value) Constructor Create; end; // Struct for interrupt CallBack processing InterruptCall = object ( ParametersBase ) public m_nIntOf : Cardinal; // Interrupt mode m_pFun : function (P : Pointer) : Integer; StdCall; // int (__stdcall* m_pProc)(void *); // CallBack routine m_pData : Pointer; // Data for CallBack call Constructor Create; end; // Struct for Synchronise ( use Interrupt or Ready port ) DRW_ICaseRec = record Case Integer of 0: (m_pInterruptEvent : ^InterruptEvent;); // if Ready then signal or send 1: (m_pInterruptCall : ^InterruptCall;); // if Ready then call 2: (m_pPortIOs : ^PortIOs;); // if !interrupt for special ways end; DeviceReadyWait = object ( ParametersBase ) public m_uTimeOut : Cardinal; // Time out in milliseconds m_IntOf : DRW_ICaseRec; Constructor Create; end; ////////////////////////////////////// // Device info ////////////////////////////////////// DI_ValueRec = record Case Integer of 0: (m_nValue : Integer;); 1: (m_uValue : Cardinal;); 2: (m_fValue : Single;); 3: (m_pChar : PChar;); 4: (m_pInt : ^Integer;); 5: (m_pCardin : ^Cardinal;); 6: (m_pSingle : ^Single;); 7: (m_pDeviceSetup : ^DeviceSetup;); 8: (m_pDeviceLink : ^DeviceLink;); end; DeviceInfo = object ( ParametersBase ) public m_nItemType : Integer; // Type of request m_nItems : Integer; // Number of returned items m_Datas : DI_ValueRec; // Data (depends of m_nItemType) Constructor Create; end; TD_NGainRec = record Case Integer of 0: (m_nGainNumber : Integer); // Gains number ( if <= 0 then not use ) 1: (m_nGainCount, // Gain number m_nGainFormat : Word;); // Gain format end; TD_PNGainRec = record Case Integer of 0: (m_nGain : Integer;); // Gain value if m_nGainNumber == 1 1: (m_fGain : Single;); // Gain value if m_nGainNumber == 1 2: (m_pnGainList : ^Integer;); // Gain list if m_nGainNumber > 1 3: (m_pfGainList : ^Single;); // Gain list if m_nGainNumber > 1 end; TransferData = object ( ParametersBase ) public m_nStartOf : Integer; // Start mode m_nIntOf : Integer; // Interrupt mode m_nControl : Integer; // Special flags m_fFreqStart : Single; // ADC freq or Packet freq m_nTimerStart : Integer; // then Timer number m_fFreqPack : Single; // ADC freq for Packet mode m_nTimerPack : Integer; // then Timer number m_nChannellNumber: Integer; // Number of channells m_nFirstChannell: Integer; // First channel ( if m_nFirstChannell == 0 then use m_pnChannellList ) m_pnChannellList: ^Integer; // Channell list array m_nGainRec : TD_NGainRec; m_GainRec : TD_PNGainRec; m_nSynchroMode : Integer; // Synchronisation mode m_nSynchroLevel : packed array [1..2] of Integer; // Synchronisation level m_nNumberOfBlocks: Integer; // Number m_nBlockSize : Integer; // Size one block m_nTransferType : Integer; m_pData : Pointer; m_pParametersBase: ^ParametersBase; // PortIO, PortIOs... for special ways Constructor Create; end; implementation Constructor EasyDeviceSetup.Create; begin m_nType := EASYDEVICESETUP_TYPE; m_nSizeOf := SizeOf(EasyDeviceSetup); end; Constructor DeviceSetup.Create; begin m_nType := DEVICESETUP_TYPE; m_nSizeOf := SizeOf(DeviceSetup); end; Constructor DeviceLink.Create; begin m_nType := DEVICELINK_TYPE; m_nSizeOf := SizeOf(DeviceLink); end; Constructor PortIO.Create; begin m_nType := PORTIO_TYPE; m_nSizeOf := SizeOf(PortIO); end; Constructor PortIOs.Create; begin m_nType := PORTIOS_TYPE; m_nSizeOf := SizeOf(PortIOs); end; Constructor PortIO4ISR.Create; begin m_nType := PORTIO4ISR_TYPE; m_nSizeOf := SizeOf(PortIO4ISR); end; Constructor PortIOFlash.Create; begin m_nType := PORTIOFLASH_TYPE; m_nSizeOf := SizeOf(PortIOFlash); end; Constructor PortIODAC.Create; begin m_nType := PORTIODAC_TYPE; m_nSizeOf := SizeOf(PortIODAC); end; Constructor PortIOTimer.Create; begin m_nType := PORTIOTIMER_TYPE; m_nSizeOf := SizeOf(PortIOTimer); end; Constructor PortIOPLL.Create; begin m_nType := PORTIOPLL_TYPE; m_nSizeOf := SizeOf(PortIOPLL); end; Constructor InterruptEvent.Create; begin m_nType := INTERRUPTEVENT_TYPE; m_nSizeOf := SizeOf(InterruptEvent); end; Constructor InterruptCall.Create; begin m_nType := INTERRUPTCALL_TYPE; m_nSizeOf := SizeOf(InterruptCall); end; Constructor DeviceReadyWait.Create; begin m_nType := DEVICEREADYWAIT_TYPE; m_nSizeOf := SizeOf(DeviceReadyWait); end; Constructor DeviceInfo.Create; begin m_nType := DEVICEINFO_TYPE; m_nSizeOf := SizeOf(DeviceInfo); end; Constructor TransferData.Create; begin m_nType := TRANSFERDATA_TYPE; m_nSizeOf := SizeOf(TransferData); end; end.
{ search-api Copyright (c) 2019 mr-highball Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. } unit search.api; {$mode delphi} interface uses Classes, SysUtils, search.types; type { TSearchAPIImpl } (* base implementation for ISearchAPI *) TSearchAPIImpl = class(TInterfacedObject,ISearchAPI) strict private FSettings: ISearchSettings; FResSettings: IResourceSettings; FResult: ISearchResult; strict protected function GetPage: IPaginated; function GetResourceSettings: IResourceSettings; function GetResult: ISearchResult; function GetSettings: ISearchSettings; //children override function DoGetPage: IPaginated;virtual;abstract; function DoGetResourceSettings: IResourceSettings;virtual;abstract; function DoGetSettings: ISearchSettings;virtual;abstract; function DoGetEmptyResourceSettings: IResourceSettings;virtual;abstract; function DoGetEmptySearchSettings: ISearchSettings;virtual;abstract; function DoSearch: ISearchResult;virtual;abstract; public //-------------------------------------------------------------------------- //properties //-------------------------------------------------------------------------- property Page : IPaginated read GetPage; property Settings : ISearchSettings read GetSettings; property ResourceSettings : IResourceSettings read GetResourceSettings; property Result : ISearchResult read GetResult; //-------------------------------------------------------------------------- //methods //-------------------------------------------------------------------------- function EmptyResourceSettings: IResourceSettings; function EmptySettings: ISearchSettings; function Search: ISearchResult; constructor Create;virtual;overload; destructor destroy; override; end; implementation { TSearchAPIImpl } function TSearchAPIImpl.EmptyResourceSettings: IResourceSettings; begin FResSettings:=nil; FResSettings:=DoGetEmptyResourceSettings; Result:=FResSettings; end; function TSearchAPIImpl.EmptySettings: ISearchSettings; begin FSettings:=nil; FSettings:=DoGetEmptySearchSettings; Result:=FSettings; end; function TSearchAPIImpl.GetPage: IPaginated; begin Result:=DoGetPage; end; function TSearchAPIImpl.GetResourceSettings: IResourceSettings; begin Result:=FResSettings; end; function TSearchAPIImpl.GetResult: ISearchResult; begin Result:=FResult; end; function TSearchAPIImpl.GetSettings: ISearchSettings; begin Result:=FSettings; end; function TSearchAPIImpl.Search: ISearchResult; begin { TODO -ohighball : validated requested settings before calling dosearch } FResult:=DoSearch; Result:=FResult; end; constructor TSearchAPIImpl.Create; begin EmptySettings; EmptyResourceSettings; FResult:=nil; end; destructor TSearchAPIImpl.destroy; begin FSettings:=nil; FResSettings:=nil; FResult:=nil; inherited destroy; end; end.
{*******************************************************} { } { Delphi FireMonkey Platform } { Copyright(c) 2013-2021 Embarcadero Technologies, Inc. } { All rights reserved } { } {*******************************************************} unit FMX.VirtualKeyboard.Android; interface {$SCOPEDENUMS ON} uses System.Classes, System.Types, System.Messaging, Androidapi.JNI.GraphicsContentViewText, Androidapi.JNI.Embarcadero, Androidapi.JNIBridge, FMX.Types, FMX.VirtualKeyboard; type TVirtualKeyboardAndroid = class; TKeyboardStateChangedListener = class(TJavaLocal, JOnKeyboardStateChangedListener) private [Weak] FKeyboardService: TVirtualKeyboardAndroid; FNeedNotifyAboutFrameChanges: Boolean; FPreviousVKRect: TRect; public constructor Create(const AService: TVirtualKeyboardAndroid); { JOnKeyboardStateChangedListener } procedure onVirtualKeyboardWillShown; cdecl; procedure onVirtualKeyboardFrameChanged(newFrame: JRect); cdecl; procedure onVirtualKeyboardWillHidden; cdecl; end; TVirtualKeyboardAndroid = class(TInterfacedObject, IFMXVirtualKeyboardService) private FKeyboardStateListener: TKeyboardStateChangedListener; FTransient: Boolean; procedure RegisterService; procedure UnregisterService; protected function IsAutoShow: Boolean; function DefineNativeView(const AObject: TFmxObject): JView; procedure SendNotificationAboutKeyboardEvent(const AVKRect: TRect); public constructor Create; destructor Destroy; override; { IFMXVirtualKeyboardService } function ShowVirtualKeyboard(const AControl: TFmxObject): Boolean; function HideVirtualKeyboard: Boolean; function GetVirtualKeyboardState: TVirtualKeyboardStates; procedure SetTransientState(Value: Boolean); property VirtualKeyboardState: TVirtualKeyboardStates read GetVirtualKeyboardState; end; implementation uses System.SysUtils, FMX.Forms, FMX.Controls, FMX.Controls.Presentation, FMX.Platform, FMX.Platform.Android, FMX.Platform.UI.Android, FMX.Presentation.Android.Style, FMX.Text; { TAndroidVirtualKeyboardService } function TVirtualKeyboardAndroid.IsAutoShow: Boolean; begin Result := VKAutoShowMode in [TVKAutoShowMode.Always, TVKAutoShowMode.DefinedBySystem]; end; procedure TVirtualKeyboardAndroid.RegisterService; begin if not TPlatformServices.Current.SupportsPlatformService(IFMXVirtualKeyboardService) then TPlatformServices.Current.AddPlatformService(IFMXVirtualKeyboardService, Self); end; procedure TVirtualKeyboardAndroid.UnregisterService; begin TPlatformServices.Current.RemovePlatformService(IFMXVirtualKeyboardService); end; constructor TVirtualKeyboardAndroid.Create; begin inherited; RegisterService; _AddRef; FKeyboardStateListener := TKeyboardStateChangedListener.Create(Self); MainActivity.getVirtualKeyboard.addOnKeyboardStateChangedListener(FKeyboardStateListener); end; function TVirtualKeyboardAndroid.DefineNativeView(const AObject: TFmxObject): JView; function IsNativeControl: Boolean; begin Result := (AObject is TPresentedControl) and (TPresentedControl(AObject).ControlType = TControlType.Platform); end; function GetNativeView: JView; begin Result := JView(TPresentedControl(AObject).PresentationProxy.NativeObject); end; function GetFormView: JView; begin Result := WindowHandleToPlatform(TCommonCustomForm(TControl(AObject).Root.GetObject).Handle).View; end; function IsNativeStyledControl: Boolean; begin Result := (AObject is TPresentedControl) and (TPresentedControl(AObject).Presentation is TAndroidStyledPresentation); end; function IsFormAvailable: Boolean; begin Result := (AObject is TControl) and (TControl(AObject).Root <> nil) and TCommonCustomForm(TControl(AObject).Root.GetObject).IsHandleAllocated; end; begin // For Styled-native controls we redirect text-input system to form. Form will deliver key event to focused fmx control. if IsNativeStyledControl and IsFormAvailable then Result := GetFormView else if IsNativeControl then Result := GetNativeView else if Supports(AObject, ITextInput) then Result := MainActivity.getEditText else if IsFormAvailable then Result := GetFormView else Result := nil; end; destructor TVirtualKeyboardAndroid.Destroy; begin MainActivity.getVirtualKeyboard.removeOnKeyboardStateChangedListener(FKeyboardStateListener); FreeAndNil(FKeyboardStateListener); UnregisterService; inherited; end; function TVirtualKeyboardAndroid.GetVirtualKeyboardState: TVirtualKeyboardStates; begin Result := []; if IsAutoShow then Include(Result, TVirtualKeyboardState.AutoShow); if FTransient then Include(Result, TVirtualKeyboardState.Transient); if MainActivity.getVirtualKeyboard.isVirtualKeyboardShown then Include(Result, TVirtualKeyboardState.Visible); end; function TVirtualKeyboardAndroid.HideVirtualKeyboard: Boolean; begin Result := False; try if not FTransient then Result := MainActivity.getVirtualKeyboard.hide; except Application.HandleException(Screen.ActiveForm); end; end; function TVirtualKeyboardAndroid.ShowVirtualKeyboard(const AControl: TFmxObject): Boolean; function IsNotFocused(const AControl: TFmxObject): Boolean; begin Result := (AControl is TControl) and not TControl(AControl).IsFocused; end; var View: JView; begin View := DefineNativeView(AControl); // The Android native text input system requires setting focus for working with Soft Keyboard. if IsNotFocused(AControl) then TControl(AControl).SetFocus; Result := MainActivity.getVirtualKeyboard.showFor(View); end; procedure TVirtualKeyboardAndroid.SendNotificationAboutKeyboardEvent(const AVKRect: TRect); var Message: TVKStateChangeMessage; begin Message := TVKStateChangeMessage.Create(TVirtualKeyboardState.Visible in VirtualKeyboardState, AVKRect); TMessageManager.DefaultManager.SendMessage(Self, Message, True); end; procedure TVirtualKeyboardAndroid.SetTransientState(Value: Boolean); begin FTransient := Value; end; { TKeyboardStateChangedListener } constructor TKeyboardStateChangedListener.Create(const AService: TVirtualKeyboardAndroid); begin inherited Create; FKeyboardService := AService; FNeedNotifyAboutFrameChanges := False; FPreviousVKRect := TRect.Empty; end; procedure TKeyboardStateChangedListener.onVirtualKeyboardWillShown; begin FNeedNotifyAboutFrameChanges := FNeedNotifyAboutFrameChanges or not (TVirtualKeyboardState.Visible in FKeyboardService.VirtualKeyboardState); end; procedure TKeyboardStateChangedListener.onVirtualKeyboardFrameChanged(newFrame: JRect); var VKRect: TRect; begin VKRect.TopLeft := ConvertPixelToPoint(TPointF.Create(newFrame.Left, newFrame.Top)).Round; VKRect.BottomRight := ConvertPixelToPoint(TPointF.Create(newFrame.Right, newFrame.Bottom)).Round; // https://quality.embarcadero.com/browse/RSP-24737 // I made the conclusion that the event onVirtualKeyboardWillHidden and onVirtualKeyboardWillShown // are inconsistent. often the onVirtualKeyboardWillHidden is not fired (for exemple when you // click on the return key of the keybord in the bottom left) and sometime (more hard to reproduce // but I guarantee I see it) the onVirtualKeyboardWillShown is not fired. But what seam consistant // is the fire to this function onVirtualKeyboardFrameChanged with good value for VKRect // So I decide to only take care of this event if (FPreviousVKRect <> VKRect) then try FKeyboardService.SendNotificationAboutKeyboardEvent(VKRect); FPreviousVKRect := VKRect; finally FNeedNotifyAboutFrameChanges := False; end; end; procedure TKeyboardStateChangedListener.onVirtualKeyboardWillHidden; begin FNeedNotifyAboutFrameChanges := FNeedNotifyAboutFrameChanges or (TVirtualKeyboardState.Visible in FKeyboardService.VirtualKeyboardState); end; end.
{******************************************************************************} { } { Indy (Internet Direct) - Internet Protocols Simplified } { } { https://www.indyproject.org/ } { https://gitter.im/IndySockets/Indy } { } {******************************************************************************} { } { This file is part of the Indy (Internet Direct) project, and is offered } { under the dual-licensing agreement described on the Indy website. } { (https://www.indyproject.org/license/) } { } { Copyright: } { (c) 1993-2020, Chad Z. Hower and the Indy Pit Crew. All rights reserved. } { } {******************************************************************************} { } { Originally written by: Fabian S. Biehn } { fbiehn@aagon.com (German & English) } { } { Contributers: } { Here could be your name } { } {******************************************************************************} // This File is auto generated! // Any change to this file should be made in the // corresponding unit in the folder "intermediate"! // Generation date: 23.07.2021 14:40:17 unit IdOpenSSLHeaders_objects; interface // Headers for OpenSSL 1.1.1 // objects.h {$i IdCompilerDefines.inc} uses Classes, IdCTypes, IdGlobal, IdOpenSSLConsts, IdOpenSSLHeaders_ossl_typ; type obj_name_st = record type_: TIdC_INT; alias: TIdC_INT; name: PIdAnsiChar; data: PIdAnsiChar; end; OBJ_NAME = obj_name_st; POBJ_NAME = ^OBJ_NAME; //# define OBJ_create_and_add_object(a,b,c) OBJ_create(a,b,c) procedure Load(const ADllHandle: TIdLibHandle; const AFailed: TStringList); procedure UnLoad; var OBJ_NAME_init: function: TIdC_INT cdecl = nil; //TIdC_INT OBJ_NAME_new_index(TIdC_ULONG (*hash_func) (const PIdAnsiChar *); // TIdC_INT (*cmp_func) (const PIdAnsiChar *; const PIdAnsiChar *); // void (*free_func) (const PIdAnsiChar *; TIdC_INT; const PIdAnsiChar *)); OBJ_NAME_get: function(const name: PIdAnsiChar; type_: TIdC_INT): PIdAnsiChar cdecl = nil; OBJ_NAME_add: function(const name: PIdAnsiChar; type_: TIdC_INT; const data: PIdAnsiChar): TIdC_INT cdecl = nil; OBJ_NAME_remove: function(const name: PIdAnsiChar; type_: TIdC_INT): TIdC_INT cdecl = nil; OBJ_NAME_cleanup: procedure(type_: TIdC_INT) cdecl = nil; // void OBJ_NAME_do_all(TIdC_INT type_; void (*fn) (const OBJ_NAME *; void *arg); // void *arg); // void OBJ_NAME_do_all_sorted(TIdC_INT type_; // void (*fn) (const OBJ_NAME *; void *arg); // void *arg); OBJ_dup: function(const o: PASN1_OBJECT): PASN1_OBJECT cdecl = nil; OBJ_nid2obj: function(n: TIdC_INT): PASN1_OBJECT cdecl = nil; OBJ_nid2ln: function(n: TIdC_INT): PIdAnsiChar cdecl = nil; OBJ_nid2sn: function(n: TIdC_INT): PIdAnsiChar cdecl = nil; OBJ_obj2nid: function(const o: PASN1_OBJECT): TIdC_INT cdecl = nil; OBJ_txt2obj: function(const s: PIdAnsiChar; no_name: TIdC_INT): PASN1_OBJECT cdecl = nil; OBJ_obj2txt: function(buf: PIdAnsiChar; buf_len: TIdC_INT; const a: PASN1_OBJECT; no_name: TIdC_INT): TIdC_INT cdecl = nil; OBJ_txt2nid: function(const s: PIdAnsiChar): TIdC_INT cdecl = nil; OBJ_ln2nid: function(const s: PIdAnsiChar): TIdC_INT cdecl = nil; OBJ_sn2nid: function(const s: PIdAnsiChar): TIdC_INT cdecl = nil; OBJ_cmp: function(const a: PASN1_OBJECT; const b: PASN1_OBJECT): TIdC_INT cdecl = nil; // const void *OBJ_bsearch_(const void *key; const void *base; TIdC_INT num; TIdC_INT size; // TIdC_INT (*cmp) (const void *; const void *)); // const void *OBJ_bsearch_ex_(const void *key; const void *base; TIdC_INT num; // TIdC_INT size; // TIdC_INT (*cmp) (const void *; const void *); // TIdC_INT flags); //# define _DECLARE_OBJ_BSEARCH_CMP_FN(scope; type1; type2; nm) \ // static TIdC_INT nm##_cmp_BSEARCH_CMP_FN(const void *; const void *); \ // static TIdC_INT nm##_cmp(type1 const *; type2 const *); \ // scope type2 * OBJ_bsearch_##nm(type1 *key; type2 const *base; TIdC_INT num) // //# define DECLARE_OBJ_BSEARCH_CMP_FN(type1; type2; cmp) \ // _DECLARE_OBJ_BSEARCH_CMP_FN(static; type1; type2; cmp) //# define DECLARE_OBJ_BSEARCH_GLOBAL_CMP_FN(type1; type2; nm) \ // type2 * OBJ_bsearch_##nm(type1 *key; type2 const *base; TIdC_INT num) (* * Unsolved problem: if a type is actually a pointer type, like * nid_triple is, then its impossible to get a const where you need * it. Consider: * * typedef TIdC_INT nid_triple[3]; * const void *a_; * const nid_triple const *a = a_; * * The assignment discards a const because what you really want is: * * const TIdC_INT const * const *a = a_; * * But if you do that, you lose the fact that a is an array of 3 ints, * which breaks comparison functions. * * Thus we end up having to cast, sadly, or unpack the * declarations. Or, as I finally did in this case, declare nid_triple * to be a struct, which it should have been in the first place. * * Ben, August 2008. * * Also, strictly speaking not all types need be const, but handling * the non-constness means a lot of complication, and in practice * comparison routines do always not touch their arguments. *) //# define IMPLEMENT_OBJ_BSEARCH_CMP_FN(type1, type2, nm) \ // static TIdC_INT nm##_cmp_BSEARCH_CMP_FN(const void *a_; const void *b_) \ // { \ // type1 const *a = a_; \ // type2 const *b = b_; \ // return nm##_cmp(a;b); \ // } \ // static type2 *OBJ_bsearch_##nm(type1 *key; type2 const *base; TIdC_INT num) \ // { \ // return (type2 *)OBJ_bsearch_(key; base; num; sizeof(type2); \ // nm##_cmp_BSEARCH_CMP_FN); \ // } \ // extern void dummy_prototype(void) // //# define IMPLEMENT_OBJ_BSEARCH_GLOBAL_CMP_FN(type1; type2; nm) \ // static TIdC_INT nm##_cmp_BSEARCH_CMP_FN(const void *a_; const void *b_) \ // { \ // type1 const *a = a_; \ // type2 const *b = b_; \ // return nm##_cmp(a;b); \ // } \ // type2 *OBJ_bsearch_##nm(type1 *key; type2 const *base; TIdC_INT num) \ // { \ // return (type2 *)OBJ_bsearch_(key; base; num; sizeof(type2); \ // nm##_cmp_BSEARCH_CMP_FN); \ // } \ // extern void dummy_prototype(void) // //# define OBJ_bsearch(type1;key;type2;base;num;cmp) \ // ((type2 *)OBJ_bsearch_(CHECKED_PTR_OF(type1;key);CHECKED_PTR_OF(type2;base); \ // num;sizeof(type2); \ // ((void)CHECKED_PTR_OF(type1;cmp##_type_1); \ // (void)CHECKED_PTR_OF(type2;cmp##_type_2); \ // cmp##_BSEARCH_CMP_FN))) // //# define OBJ_bsearch_ex(type1;key;type2;base;num;cmp;flags) \ // ((type2 *)OBJ_bsearch_ex_(CHECKED_PTR_OF(type1;key);CHECKED_PTR_OF(type2;base); \ // num;sizeof(type2); \ // ((void)CHECKED_PTR_OF(type1;cmp##_type_1); \ // (void)type_2=CHECKED_PTR_OF(type2;cmp##_type_2); \ // cmp##_BSEARCH_CMP_FN));flags) OBJ_new_nid: function(num: TIdC_INT): TIdC_INT cdecl = nil; OBJ_add_object: function(const obj: PASN1_OBJECT): TIdC_INT cdecl = nil; OBJ_create: function(const oid: PIdAnsiChar; const sn: PIdAnsiChar; const ln: PIdAnsiChar): TIdC_INT cdecl = nil; OBJ_create_objects: function(in_: PBIO): TIdC_INT cdecl = nil; OBJ_length: function(const obj: PASN1_OBJECT): TIdC_SIZET cdecl = nil; OBJ_get0_data: function(const obj: PASN1_OBJECT): PByte cdecl = nil; OBJ_find_sigid_algs: function(signid: TIdC_INT; pdig_nid: PIdC_INT; ppkey_nid: PIdC_INT): TIdC_INT cdecl = nil; OBJ_find_sigid_by_algs: function(psignid: PIdC_INT; dig_nid: TIdC_INT; pkey_nid: TIdC_INT): TIdC_INT cdecl = nil; OBJ_add_sigid: function(signid: TIdC_INT; dig_id: TIdC_INT; pkey_id: TIdC_INT): TIdC_INT cdecl = nil; OBJ_sigid_free: procedure cdecl = nil; implementation procedure Load(const ADllHandle: TIdLibHandle; const AFailed: TStringList); function LoadFunction(const AMethodName: string; const AFailed: TStringList): Pointer; begin Result := LoadLibFunction(ADllHandle, AMethodName); if not Assigned(Result) then AFailed.Add(AMethodName); end; begin OBJ_NAME_init := LoadFunction('OBJ_NAME_init', AFailed); OBJ_NAME_get := LoadFunction('OBJ_NAME_get', AFailed); OBJ_NAME_add := LoadFunction('OBJ_NAME_add', AFailed); OBJ_NAME_remove := LoadFunction('OBJ_NAME_remove', AFailed); OBJ_NAME_cleanup := LoadFunction('OBJ_NAME_cleanup', AFailed); OBJ_dup := LoadFunction('OBJ_dup', AFailed); OBJ_nid2obj := LoadFunction('OBJ_nid2obj', AFailed); OBJ_nid2ln := LoadFunction('OBJ_nid2ln', AFailed); OBJ_nid2sn := LoadFunction('OBJ_nid2sn', AFailed); OBJ_obj2nid := LoadFunction('OBJ_obj2nid', AFailed); OBJ_txt2obj := LoadFunction('OBJ_txt2obj', AFailed); OBJ_obj2txt := LoadFunction('OBJ_obj2txt', AFailed); OBJ_txt2nid := LoadFunction('OBJ_txt2nid', AFailed); OBJ_ln2nid := LoadFunction('OBJ_ln2nid', AFailed); OBJ_sn2nid := LoadFunction('OBJ_sn2nid', AFailed); OBJ_cmp := LoadFunction('OBJ_cmp', AFailed); OBJ_new_nid := LoadFunction('OBJ_new_nid', AFailed); OBJ_add_object := LoadFunction('OBJ_add_object', AFailed); OBJ_create := LoadFunction('OBJ_create', AFailed); OBJ_create_objects := LoadFunction('OBJ_create_objects', AFailed); OBJ_length := LoadFunction('OBJ_length', AFailed); OBJ_get0_data := LoadFunction('OBJ_get0_data', AFailed); OBJ_find_sigid_algs := LoadFunction('OBJ_find_sigid_algs', AFailed); OBJ_find_sigid_by_algs := LoadFunction('OBJ_find_sigid_by_algs', AFailed); OBJ_add_sigid := LoadFunction('OBJ_add_sigid', AFailed); OBJ_sigid_free := LoadFunction('OBJ_sigid_free', AFailed); end; procedure UnLoad; begin OBJ_NAME_init := nil; OBJ_NAME_get := nil; OBJ_NAME_add := nil; OBJ_NAME_remove := nil; OBJ_NAME_cleanup := nil; OBJ_dup := nil; OBJ_nid2obj := nil; OBJ_nid2ln := nil; OBJ_nid2sn := nil; OBJ_obj2nid := nil; OBJ_txt2obj := nil; OBJ_obj2txt := nil; OBJ_txt2nid := nil; OBJ_ln2nid := nil; OBJ_sn2nid := nil; OBJ_cmp := nil; OBJ_new_nid := nil; OBJ_add_object := nil; OBJ_create := nil; OBJ_create_objects := nil; OBJ_length := nil; OBJ_get0_data := nil; OBJ_find_sigid_algs := nil; OBJ_find_sigid_by_algs := nil; OBJ_add_sigid := nil; OBJ_sigid_free := nil; end; end.
unit Unit1; { PlatformDemo Copyright (c) 2014 Steven Binns Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License, as described at http://www.apache.org/licenses/ and http://www.pp4s.co.uk/licenses/ } interface uses System.Types, SmartCL.System, SmartCL.Components, SmartCL.Application, SmartCL.Game, SmartCL.GameApp, SmartCL.Graphics; type TPlayer = class(TObject) public radius: integer; x, y, xSpeed, ySpeed, grav: real; //ySpeed is positive moving up. moveLeft, moveRight: boolean; leftKey, rightKey, jumpKey: integer; colour: string; constructor Create(newX, newY, newR, newLk, newRk, newJk: integer; newColour: String); end; TPlatform = class(TObject) public x, y, width, height: real; constructor create(newX, newY, newW, newH: real); end; TCanvasProject = class(TW3CustomGameApplication) private players : array[1..2] of TPlayer; platforms: array[0..3] of TPlatform; collision: boolean; gvWidth, gvHeight: integer; function checkVCollision(k, subject: integer): boolean; function checkHCollision(k, subject: integer): boolean; protected procedure ApplicationStarting; override; procedure ApplicationClosing; override; procedure PaintView(Canvas: TW3Canvas); override; procedure KeyDownEvent(mCode: integer); procedure KeyUpEvent(mCode: integer); end; implementation { TCanvasProject} {General functions} function TCanvasProject.checkVCollision(k, subject : integer): boolean; function hAlignment: boolean; //Nested function //If player's right extremity to right of left edge of platform k and //player's left extremity to left of right edge of platform k then return true. begin result := false; if (players[subject].x + players[subject].radius > platforms[k].x) and (players[subject].x - players[subject].radius < platforms[k].x + platforms[k].width) then result := true; end; begin result := false; //If ascending and horizontally aligned and //top of player under bottom of platform k and // next move would enter platform k then return true. if (players[subject].ySpeed > 0) and hAlignment and (players[subject].y - players[subject].radius > platforms[k].y + platforms[k].height) and (players[subject].y - players[subject].yspeed - players[subject].radius < platforms[k].y + platforms[k].height) then result := true; //If descending and horizontally aligned and // bottom of player under top of platform k and // next move would enter platform k then return true. if (players[subject].yspeed < 0) and hAlignment and (players[subject].y + players[subject].radius < platforms[k].y) and (players[subject].y + players[subject].radius - players[subject].ySpeed > platforms[k].y) then result := true; if (players[subject].yspeed = 0) and hAlignment and (players[subject].y + players[subject].radius = platforms[k].y) and (players[subject].y + players[subject].radius + 1 > platforms[k].y) then result := true; end; function TCanvasProject.checkHCollision(k, subject: integer): boolean; function vAlignment: boolean; //Nested function begin result := false; if (players[subject].y - players[subject].radius < platforms[k].y + platforms[k].height) and (players[subject].y + players[subject].radius > platforms[k].y) then result := true; end; begin result := false; //If moving right and vertically aligned and //player's right extremity to left or same as platform's left edge and //next move would enter platform then return true. if (players[subject].xspeed > 0) and vAlignment and (players[subject].x + players[subject].radius <= platforms[k].x) and (players[subject].x + players[subject].radius + players[subject].xSpeed > platforms[k].x) then result := true; //If moving left and vertically aligned and //player's left extremity to right or same as platform's right edge and //next move would enter platform then return true. if (players[subject].xspeed < 0 ) and vAlignment and (players[subject].x - players[subject].radius >= platforms[k].x + platforms[k].width) and (players[subject].x - players[subject].radius + players[subject].xspeed < platforms[k].x + platforms[k].width) then result := true; end; procedure TCanvasProject.KeyDownEvent(mCode: integer); var i : integer; begin for i := 1 to 2 do case mCode of players[i].leftKey: if players[i].moveRight = false then players[i].moveLeft := true; players[i].rightKey: if players[i].moveLeft = false then players[i].moveRight := true; players[i].jumpKey: if players[i].ySpeed = 0 then players[i].ySpeed := 5; end; end; procedure TCanvasProject.KeyUpEvent(mCode: integer); var i : integer; begin for i := 1 to 2 do case mCode of players[i].leftKey: players[i].moveLeft := false; players[i].rightKey: players[i].moveRight := false; end; end; procedure TCanvasProject.ApplicationStarting; begin inherited; players[1] := TPlayer.Create(150, 50, 5, 37, 39, 38, 'red'); //lKey:left rKey:right jKey:up players[2] := TPlayer.Create(50, 50, 5, 65, 68, 87, 'blue'); //lKey:a rKey:d jKey:w asm window.onkeydown = function(e) { TCanvasProject.KeyDownEvent(Self,e.keyCode); } window.onkeyup = function(e) { TCanvasProject.KeyUpEvent(Self,e.keyCode); } end; KeyDownEvent(0); KeyUpEvent(0); GameView.Width := 300; GameView.Height := 150; gvWidth := 300; gvHeight := 150; platforms[0] := TPlatform.create(50, GameView.Height - 30, 20, 5); platforms[1] := TPlatform.create(100, GameView.Height - 35, 15, 2); platforms[2] := TPlatform.create(150, GameView.Height - 45, 20, 10); platforms[3] := TPlatform.create(200, GameView.Height - 55, 5, 3); GameView.Delay := 10; GameView.StartSession(True); end; procedure TCanvasProject.PaintView(Canvas: TW3Canvas); var i, j, k : integer; begin for j := 1 to 2 do // Step players begin // Players will gain speed up to a max value while key pressed. if (players[j].moveRight = true) and (players[j].xSpeed < 3) then players[j].xSpeed += 0.25; if (players[j].moveLeft = true) and (players[j].xSpeed > -3) then players[j].xSpeed -= 0.25; //Check for horizontal collisions. collision := false; for k := 0 to 3 do begin if checkHCollision(k, j) = true then begin collision := true; break; //Collision platform's number = k end; end; if collision = false then //Continue to move. players[j].x += players[j].xSpeed else //Horizontal collision begin //Prevent player from entering platform and stop horizontal movement. if players[j].xSpeed > 0 then begin players[j].x := platforms[k].x - players[j].radius; players[j].xSpeed := 0; end; if players[j].xSpeed < 0 then begin players[j].x := platforms[k].x + platforms[k].width + players[j].radius; players[j].xSpeed := 0; end; end; //Keep players horizontally in the GameView. if players[j].x + players[j].radius > gvWidth then players[j].x := gvWidth - players[j].radius; if players[j].x - players[j].radius < 0 then players[j].x := players[j].radius; //Create horizontal friction by reducing the speed. if (players[j].moveLeft = false) and (players[j].moveRight = false) then begin if players[j].xSpeed < 0 then players[j].xSpeed += 0.125 else if players[j].xSpeed > 0 then players[j].xSpeed -= 0.125; end; //Deal with jumping and gravity collision := false; for k := 0 to 3 do begin if checkVCollision(k, j) = true then begin collision := true; break; //k holds platform number of collision end; end; if collision = false then begin players[j].y -= players[j].ySpeed; if players[j].y + players[j].radius < gvHeight then begin players[j].ySpeed -= players[j].grav; players[j].grav += 0.1; end else begin //Player has reached the floor so position it exactly on the floor. players[j].y := gvHeight - players[j].radius; players[j].ySpeed := 0; players[j].grav := 0; end; end else //vertical collision begin if players[j].ySpeed > 0 then //Hits bottom of platform k begin //Position it just under platform. players[j].y := platforms[k].y + platforms[k].height + players[j].radius; players[j].ySpeed := 0; players[j].grav := 0; end; if players[j].yspeed < 0 then //Hits top of platform k begin //Place it on platform k. players[j].y := platforms[k].y - players[j].radius; players[j].ySpeed := 0; players[j].grav := 0; end; end; end; //Finished stepping players // Clear background with colour gray. Canvas.FillStyle := 'gray'; Canvas.FillRect(0, 0, gvWidth, gvHeight); //Draw circles for players. for i := 1 to 2 do begin Canvas.FillStyle := players[i].colour; Canvas.BeginPath; Canvas.Ellipse(players[i].x - players[i].radius, players[i].y - players[i].radius, players[i].x + players[i].radius, players[i].y + players[i].radius); //leftX, topY, rightX, bottomY Canvas.Fill; end; {Draw platforms} for k := 0 to 3 do begin Canvas.FillStyle := 'black'; Canvas.FillRect(round(platforms[k].x), round(platforms[k].y), round(platforms[k].width), round(platforms[k].height)); end; end; procedure TCanvasProject.ApplicationClosing; begin GameView.EndSession; inherited; end; {TPlayer constructor} constructor TPlayer.Create(newX, newY, newR, newLk, newRk, newJk: integer; newColour: string); begin x := newX; y := newY; radius := newR; leftKey := newLk; rightKey := newRk; jumpKey := newJk; xSpeed := 0; ySpeed := 0; grav := 0; colour := newColour; end; {TPlatform constructor} constructor TPlatform.create(newX, newY, newW, newH : real); begin x := newX; y := newY; width := newW; height := newH; end; end.
{*********************************************************************************** ** SISTEMA...............: Vida Nova Gestão de Vendas 2019 ** ** PARA EMPRESAS.........: Micro e Pequena Empresa ** ** LINGUAGEM/DB..........: Delphi 10.3 Rio / Firebird 2.5 ** ** ------------------------------------------------------------------------------ ** ** ** ** AUTOR/PROGRAMADOR.....: Bruno Batista ** ** E-MAIL................: batista.bjs@gmail.com ** ** ------------------------------------------------------------------------------ ** ** Código pertencente ao cliente sob proteção autoral. ** ** Não comercializável sem prévia autorização do mesmo. ** ***********************************************************************************} unit Classe.CEP; interface uses {$I units.rtl.inc}; type TCEP = Class private { Private declarations } FCEP : String; FTipo : String; FEndereco : String; FNumero : String; FComplemento : String; FBairro : String; FIDCidade : Integer; FCidade : String; FIDUF : Integer; FUF : String; public { Public declarations } constructor Create; property CEP : String read FCEP Write FCEP; property Tipo : String read FTipo Write FTipo; property Endereco : String read FEndereco Write FEndereco; property Numero : String read FNumero Write FNumero; property Complemento : String read FComplemento Write FComplemento; property Bairro : String read FBairro write FBairro; property IDCidade : Integer read FIDCidade write FIDCidade; property Cidade : String read FCidade write FCidade; property IDUF : Integer read FIDUF write FIDUF; property UF : String read FUF write FUF; end; implementation { TCEP } constructor TCEP.Create; begin FCEP :=''; FEndereco :=''; FNumero :=''; FComplemento :=''; FBairro :=''; FIDCidade :=0; FCidade :=''; FIDUF :=0; FUF :=''; end; end.
unit UAspekt; {$mode objfpc}{$H+} interface uses fgl; type TAspekt = class private protected FGewichtung: Double; public procedure Durchlauf(Datum: TDate); virtual; abstract; procedure Treffer; virtual; abstract; function Wert (Datum: TDate): Double; virtual; abstract; published property Gewichtung: Double read FGewichtung; end; type TStandardAspektliste = specialize TFPGObjectList<TAspekt>; TAspektliste = class (TStandardAspektliste) public procedure Durchlauf(Datum: TDate); procedure Treffer; end; implementation procedure TAspektliste.Durchlauf(Datum: TDate); var i: Integer; begin for i := 0 to Self.Count -1 do Self.Items[i].Durchlauf(Datum); end; procedure TAspektliste.Treffer; var i: Integer; begin for i := 0 to Self.Count -1 do Self.Items[i].Treffer; end; end.
unit SequenceNumberGeneratorUnit; interface uses INumberGeneratorUnit; type TSequenceNumberGenerator = class (TInterfacedObject, INumberGenerator) protected FCurrentNumber: LongInt; function InternalGetCurrentNumber: LongInt; virtual; function InternalGetNextNumber: LongInt; virtual; procedure InternalReset; virtual; public function GetCurrentNumber: LongInt; function GetNextNumber: LongInt; procedure Reset; property CurrentNumber: LongInt read GetCurrentNumber; end; implementation { TSequenceNumberGenerator } function TSequenceNumberGenerator.GetCurrentNumber: LongInt; begin Result := InternalGetCurrentNumber; end; function TSequenceNumberGenerator.GetNextNumber: LongInt; begin Result := InternalGetNextNumber; end; procedure TSequenceNumberGenerator.Reset; begin InternalReset; end; function TSequenceNumberGenerator.InternalGetCurrentNumber: LongInt; begin Result := FCurrentNumber; end; function TSequenceNumberGenerator.InternalGetNextNumber: LongInt; begin Inc(FCurrentNumber); Result := FCurrentNumber; end; procedure TSequenceNumberGenerator.InternalReset; begin FCurrentNumber := 0; end; end.
(* Copyright (c) 2012-2014, Stefan Glienke All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name of this library nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *) unit DSharp.Interception.AttributeDrivenPolicy; interface uses DSharp.Interception, DSharp.Interception.InjectionPolicy, DSharp.Interception.MethodImplementationInfo, Rtti; type TAttributeDrivenPolicy = class(TInjectionPolicy) private FAttributeMatchingRule: IMatchingRule; protected function DoesMatch(Member: TMethodImplementationInfo): Boolean; override; function DoGetHandlersFor(Member: TMethodImplementationInfo): TArray<ICallHandler>; override; public constructor Create; end; implementation uses DSharp.Core.Reflection, DSharp.Core.Utils, DSharp.Interception.AttributeDrivenPolicyMatchingRule; { TAttributeDrivenPolicy } constructor TAttributeDrivenPolicy.Create; begin inherited Create('Attribute Driven Policy'); FAttributeMatchingRule := TAttributeDrivenPolicyMatchingRule.Create; end; function TAttributeDrivenPolicy.DoesMatch(Member: TMethodImplementationInfo): Boolean; var matchesInterface: Boolean; matchesImplementation: Boolean; begin matchesInterface := IfThen(Assigned(Member.InterfaceMethodInfo), FAttributeMatchingRule.Matches(Member.InterfaceMethodInfo)); matchesImplementation := FAttributeMatchingRule.Matches(Member.ImplementationMethodInfo); Result := matchesInterface or matchesImplementation; end; function TAttributeDrivenPolicy.DoGetHandlersFor( Member: TMethodImplementationInfo): TArray<ICallHandler>; var attribute: HandlerAttribute; begin if Assigned(Member.InterfaceMethodInfo) then begin for attribute in Member.InterfaceMethodInfo.GetAllAttributes<HandlerAttribute>(True) do begin SetLength(Result, Length(Result) + 1); Result[High(Result)] := attribute.CreateHandler; end; end; if Assigned(Member.ImplementationMethodInfo) then begin for attribute in Member.ImplementationMethodInfo.GetAllAttributes<HandlerAttribute>(True) do begin SetLength(Result, Length(Result) + 1); Result[High(Result)] := attribute.CreateHandler; end; end; end; end.
unit TabCtrls; interface uses Windows,SysUtils,Classes,ComCtrls; type TTabControlEx = class(TTabControl) private FTextVertical: Boolean; FActiveFont: TFont; procedure SetTextVertical(const Value: Boolean); procedure SetActiveFont(const Value: TFont); protected procedure DrawTab(TabIndex: Integer; const Rect: TRect; Active: Boolean); override; public constructor Create(AOwner : TComponent); override; published property TextVertical : Boolean read FTextVertical write SetTextVertical default True; property ActiveFont : TFont read FActiveFont write SetActiveFont; end; implementation procedure TabControl1DrawTab(Control: TCustomTabControl; Caption: Integer; const Rect: TRect; Font: TFont); var MyRect : TRect; S,S1 : String; i,len : integer; P : Pchar; MultiBytes : boolean; begin MyRect := Rect; Inc(MyRect.left,Margin); Inc(MyRect.Top,Margin); S:=Caption; P:=Pchar(S); len := length(s); MultiBytes := false; S1 := ''; for i:=1 to len do begin if P^>#127 then begin S1 := S1 + P^; if MultiBytes then begin MultiBytes:=false; if i<len then S1:=S1+LineBreak; end else MultiBytes := true; end else begin MultiBytes := false; S1 := S1+P^; if i<len then S1:=S1+LineBreak; end; Inc(P); end; Control.Canvas.Font := Font; Windows.DrawText(Control.Canvas.Handle, Pchar(S1), -1, MyRect, DT_EDITCONTROL or DT_WORDBREAK{ or DT_NOCLIP}); end; { TTabControlEx } constructor TTabControlEx.Create(AOwner: TComponent); begin inherited; FTextVertical := true; FActiveFont := TFont.Create; end; procedure TTabControlEx.DrawTab(TabIndex: Integer; const Rect: TRect; Active: Boolean); begin if Assigned(FOnDrawTab) then inherited else ; end; procedure TTabControlEx.SetActiveFont(const Value: TFont); begin FActiveFont.Assign(Value); end; procedure TTabControlEx.SetTextVertical(const Value: Boolean); begin if FTextVertical <> Value then begin FTextVertical := Value; if TabPosition in [tpLeft, tpRight] then Invalidate(); end; end; end.
unit DbDriverSqlite; {$mode objfpc}{$H+} interface uses Classes, SysUtils, DbUnit, sqldb, sqlite3conn; type { TDbDriverSQLite } TDbDriverSQLite = class(TDbDriver) private db: TSQLite3Connection; Active: Boolean; procedure CheckTable(TableInfo: TDbTableInfo); protected procedure DebugSQL(AMsg: string); virtual; public constructor Create(); //destructor Destroy(); override; function Open(ADbName: string): Boolean; override; function Close(): Boolean; override; function GetTable(AItemList: TDbItemList; Filter: string = ''): Boolean; override; function SetTable(AItemList: TDbItemList; Filter: string = ''): Boolean; override; function GetDBItem(const AValue: string): TDBItem; override; function SetDBItem(AItem: TDBItem): Boolean; override; end; implementation // === TDbDriverSQLite === constructor TDbDriverSQLite.Create(); begin inherited Create(); self.Active := False; end; procedure TDbDriverSQLite.CheckTable(TableInfo: TDbTableInfo); var sl: TStringList; s, sn, st, sql: string; i: Integer; begin if not Assigned(db) then Exit; if TableInfo.Valid then Exit; if Self.TableInfoList.IndexOf(TableInfo) >= 0 then Exit; // get table info //sql:='SELECT * FROM sqlite_master WHERE type=''table'' and name='''+TableInfo.TableName+''''; //DebugSQL(sql); //rs:=db.SchemaTableInfo(TableInfo.TableName); sl := TStringList.Create(); try DB.GetFieldNames(TableInfo.TableName, sl); if sl.Count <= 0 then begin s := ''; for i := 0 to TableInfo.FieldsCount - 1 do begin sn := TableInfo.FieldNames[i]; st := TableInfo.Types[i]; if Length(s) > 0 then s := s + ','; s := s + '''' + sn + ''''; if sn = 'id' then begin s := s + ' INTEGER PRIMARY KEY NOT NULL'; TableInfo.KeyFieldName := sn; end else if st = 'I' then s := s + ' INTEGER NOT NULL' else if st = 'S' then s := s + ' TEXT NOT NULL' else if st = 'B' then s := s + ' INTEGER NOT NULL' else if st = 'D' then s := s + ' TEXT NOT NULL' //else if st = '' then // nothing; else if st[1] = 'L' then s := s + ' INTEGER NOT NULL'; end; sql := 'CREATE TABLE ''' + TableInfo.TableName + ''' (' + s + ')'; DebugSQL(sql); try DB.ExecuteDirect(sql); finally end; end; finally sl.Free; end; TableInfo.Valid := True; Self.TableInfoList.Add(TableInfo); end; procedure TDbDriverSQLite.DebugSQL(AMsg: string); begin if Assigned(OnDebugSQL) then OnDebugSQL(AMsg); end; function TDbDriverSQLite.Open(ADbName: string): Boolean; begin DbName := ADbName; Result := True; if Assigned(db) then FreeAndNil(db); db := TSQLite3Connection.Create(nil); try DB.DatabaseName := ADbName + '.sqlite'; DB.Open(); except FreeAndNil(db); Result := False; end; Active := Result; end; function TDbDriverSQLite.Close(): Boolean; begin Result := True; TableInfoList.Clear(); if not Active then Exit; if not Assigned(db) then Exit; DB.Close(); FreeAndNil(db); end; function TDbDriverSQLite.GetTable(AItemList: TDbItemList; Filter: string = ''): Boolean; var //rs: IMkSqlStmt; Query: TSQLQuery; i, n, m: Integer; Item: TDbItem; fn, sql: string; fl: TStringList; FilterOk: Boolean; begin Result := False; if not Active then Exit; if not Assigned(AItemList) then Exit; if not Assigned(db) then Exit; CheckTable(AItemList.DbTableInfo); fl := TStringList.Create(); // filters try fl.CommaText := Filter; sql := 'SELECT * FROM "' + AItemList.DbTableInfo.TableName + '"'; // filters if fl.Count > 0 then sql := sql + ' WHERE '; for m := 0 to fl.Count - 1 do begin if m > 0 then sql := sql + ' AND '; sql := sql + '"' + fl.Names[m] + '"="' + fl.ValueFromIndex[m] + '"'; end; finally FreeAndNil(fl); end; DebugSQL(sql); Query := TSQLQuery.Create(nil); try Query.DataBase := db; //rs:=db.Exec(sql); Query.SQL.Text := sql; Query.Open(); while not Query.EOF do begin i := Query.FieldValues['id']; Item := AItemList.GetItemByID(i); if not Assigned(Item) then Item := AItemList.NewItem(); for n := 0 to AItemList.DbTableInfo.FieldsCount - 1 do begin fn := AItemList.DbTableInfo.FieldNames[n]; // field name Item.SetValue(fn, Query.FieldValues[fn]); end; Query.Next(); end; Result := True; finally FreeAndNil(Query); end; end; function TDbDriverSQLite.SetTable(AItemList: TDbItemList; Filter: string = ''): Boolean; var i, n: Integer; Item: TDbItem; fn, iv, vl, sql: string; begin Result := False; if (not Active) or (not Assigned(AItemList)) or (not Assigned(db)) then Exit; CheckTable(AItemList.DbTableInfo); for i := 0 to AItemList.Count - 1 do begin vl := ''; Item := AItemList.GetItem(i); for n := 0 to AItemList.DbTableInfo.FieldsCount - 1 do begin fn := AItemList.DbTableInfo.FieldNames[n]; // field name iv := Item.GetValue(fn); // field value if n > 0 then vl := vl + ','; vl := vl + '"' + iv + '"'; //vl:=vl+fn+'='''+iv+''''; end; sql := 'INSERT OR REPLACE INTO "' + AItemList.DbTableInfo.TableName + '" VALUES (' + vl + ')'; DebugSQL(sql); //sql:='UPDATE '+AItemList.DbTableInfo.TableName+' SET '+vl+' WHERE ROWID='+IntToStr(Item.ID); try DB.ExecuteDirect(sql); Result := True; finally end; end; end; function TDbDriverSQLite.GetDBItem(const AValue: string): TDBItem; var sTableName, sItemID, fn, sql: string; i: Integer; TableInfo: TDbTableInfo; Query: TSQLQuery; begin Result := nil; if not Assigned(db) then Exit; i := Pos('~', AValue); sTableName := Copy(AValue, 1, i - 1); sItemID := Copy(AValue, i + 1, MaxInt); TableInfo := Self.GetDbTableInfo(sTableName); if not Assigned(TableInfo) then Exit; sql := 'SELECT * FROM ' + TableInfo.TableName + ' WHERE id="' + sItemID + '"'; DebugSQL(sql); Query := TSQLQuery.Create(nil); try Query.DataBase := db; Query.SQL.Text := sql; Query.Open(); while not Query.EOF do begin Result := TDbItem.Create(TableInfo); for i := 0 to TableInfo.FieldsCount - 1 do begin fn := TableInfo.FieldNames[i]; // field name Result.SetValue(fn, Query.FieldValues[fn]); end; Query.Next(); end; finally FreeAndNil(Query); end; end; function TDbDriverSQLite.SetDBItem(AItem: TDBItem): Boolean; var n: Integer; Item: TDbItem; TableInfo: TDbTableInfo; fn, iv, vl, sql: string; begin Result := False; if (not Active) or (not Assigned(AItem)) or (not Assigned(db)) then Exit; TableInfo := AItem.DbTableInfo; if not Assigned(TableInfo) then Exit; CheckTable(TableInfo); vl := ''; for n := 0 to TableInfo.FieldsCount - 1 do begin fn := TableInfo.FieldNames[n]; // field name iv := AItem.GetValue(fn); if n > 0 then vl := vl + ','; vl := vl + '"' + iv + '"'; //vl:=vl+fn+'='''+iv+''''; end; sql := 'INSERT OR REPLACE INTO "' + TableInfo.TableName + '" VALUES (' + vl + ')'; DebugSQL(sql); //sql:='UPDATE '+AItemList.DbTableInfo.TableName+' SET '+vl+' WHERE ROWID='+IntToStr(Item.ID); try DB.ExecuteDirect(sql); Result := True; finally end; end; end.
unit PropertyEditor; interface uses SysUtils,dsgnintf,classes, extctrls, stdctrls, LookupControls, controls,extdlgs, typinfo, DbTables, DBLists, DB, QueryDialog, DQueryDialog, PTable, PLabelPanel,PKindEdit, PGoodsEdit, PRelationEdit,PStaffEdit,PDBCounterEdit,PDBStaffEdit, PLookupEdit ,PDBLookupEdit ,PLookupCombox ,PDBLookupCombox, Pimage,PBitBtn,PDBEdit,PDBVendorEdit,PDBKindEdit,PDBMemonoEdit, PCounterEdit,PMemoEdit; procedure Register; implementation { TFilenameProperty} type TPPicFileNameProperty = class (TStringProperty) public function GetAttributes: TPropertyAttributes; override; procedure Edit; override; end; function TPPicFileNameProperty.GetAttributes: TPropertyAttributes; begin Result := [paDialog]; end; procedure TPPicFileNameProperty.Edit ; var dlg: TOpenPictureDialog; begin dlg := TOpenPictureDialog.Create(nil); try if dlg.Execute then SetValue(dlg.FileName); finally dlg.Free; end; end; { TPSubFieldControlProperty } type TPUpperProperty = class (TStringProperty) public function GetValue: string; override; procedure SetValue(const Value: string); override; end; function TPUpperProperty.GetValue : string; begin Result := UpperCase(inherited GetValue); end; procedure TPUpperProperty.SetValue( const Value: string); begin inherited SetValue(UpperCase(Value)); end; type TPSubFieldControlProperty = class(TComponentProperty) procedure GetValues(Proc: TGetStrProc); override; end; procedure TPSubFieldControlProperty.GetValues(Proc: TGetStrProc); var I: Integer; Component: TComponent; begin for I := 0 to Designer.Form.ComponentCount - 1 do begin Component := Designer.Form.Components[I]; //if (Component.InheritsFrom(TPLabelPanel)) and (Component.Name <> '') then if (Component.InheritsFrom(TPLabelPanel) or (Component is TCustomLabel) or (Component is TCustomPanel) ) and (Component.Name <> '') then Proc(Component.Name); end; end; { TPDBStringProperty } type TPDBStringProperty = class(TStringProperty) public function GetAttributes: TPropertyAttributes; override; procedure GetValueList(List: TStrings); virtual; procedure GetValues(Proc: TGetStrProc); override; end; function TPDBStringProperty.GetAttributes: TPropertyAttributes; begin Result := [paValueList, paSortList, paMultiSelect]; end; procedure TPDBStringProperty.GetValues(Proc: TGetStrProc); var I: Integer; Values: TStringList; begin Values := TStringList.Create; try GetValueList(Values); for I := 0 to Values.Count - 1 do Proc(Values[I]); finally Values.Free; end; end; procedure TPDBStringProperty.GetValueList(List: TStrings); begin end; { TPDatabaseNameProperty } type TPDatabaseNameProperty = class(TPDBStringProperty) public procedure GetValueList(List: TStrings); override; end; procedure TPDatabaseNameProperty.GetValueList(List: TStrings); begin Session.GetDatabaseNames(List); end; { TPMemoEditTableNameProperty } type TPMemoEditTableNameProperty = class(TPDBStringProperty) public procedure GetValueList(List: TStrings); override; end; procedure TPMemoEditTableNameProperty.GetValueList(List: TStrings); begin Session.GetTableNames((GetComponent(0) as TPMemoEdit).DatabaseName, '', True, False, List); end; { TPmemoeditFieldNameProperty } type TPMemoEditFieldNameProperty = class(TPDBStringProperty) public procedure GetValueList(List: TStrings); override; end; procedure TPMemoEditFieldNameProperty.GetValueList(List: TStrings); var Table: TTable; begin begin Table := TTable.Create(GetComponent(0) as TPMemoEdit); try with GetComponent(0) as TPMemoEdit do begin if DataBaseName = '' then begin List.Clear; exit; end; Table.DatabaseName := DatabaseName; Table.TableName := TableName; Table.GetFieldNames(List); end; finally Table.Free; end; end; end; { TPmemoeditForeignFieldNameProperty } type TPMemoEditForeignFieldNameProperty = class(TPDBStringProperty) public procedure GetValueList(List: TStrings); override; end; procedure TPMemoEditForeignFieldNameProperty.GetValueList(List: TStrings); var Table: TTable; begin begin Table := TTable.Create(GetComponent(0) as TPMemoEdit); try with GetComponent(0) as TPMemoEdit do begin Table.DatabaseName := DatabaseName; Table.TableName := RefrenTableName; Table.GetFieldNames(List); end; finally Table.Free; end; end; end; { TPTableNameProperty } type TPTableNameProperty = class(TPDBStringProperty) public procedure GetValueList(List: TStrings); override; end; procedure TPTableNameProperty.GetValueList(List: TStrings); begin Session.GetTableNames((GetComponent(0) as TQueryDialog).DatabaseName, '', True, False, List); end; { TPDTableNameProperty } type TPDTableNameProperty = class(TPDBStringProperty) public procedure GetValueList(List: TStrings); override; end; procedure TPDTableNameProperty.GetValueList(List: TStrings); begin Session.GetTableNames((GetComponent(0) as TDQueryDialog).DatabaseName, '', True, False, List); end; { TPTableTableNameProperty } type TPTableTableNameProperty = class(TPDBStringProperty) public procedure GetValueList(List: TStrings); override; end; procedure TPTableTableNameProperty.GetValueList(List: TStrings); begin Session.GetTableNames((GetComponent(0) as TPTable).DatabaseName, '', True, False, List); end; { TPLookupControlDataSourceProperty} type TPLookupControlDataSourceProperty = class ( TPDBStringProperty) public procedure GetValueList(List: TStrings);override; end; procedure TPLookupControlDataSourceProperty.GetValueList(List: TStrings); var i : integer; begin end; { TPCounterEditTableNameProperty } type TPCounterEditTableNameProperty = class(TPDBStringProperty) public procedure GetValueList(List: TStrings); override; end; procedure TPCounterEditTableNameProperty.GetValueList(List: TStrings); begin Session.GetTableNames((GetComponent(0) as TPCounterEdit).DatabaseName, '', True, False, List); end; type TPLookupControlTableNameProperty = class(TPDBStringProperty) public procedure GetValueList(List: TStrings); override; end; procedure TPLookupControlTableNameProperty.GetValueList(List: TStrings); begin Session.GetTableNames((GetComponent(0) as TPLookupControl).DatabaseName, '', True, False, List); end; { TPLookupControlFieldNameProperty } type TPLookupControlFieldNameProperty = class(TPDBStringProperty) public procedure GetValueList(List: TStrings); override; end; procedure TPLookupControlFieldNameProperty.GetValueList(List: TStrings); var Table: TTable; begin begin Table := TTable.Create(GetComponent(0) as TPLookupControl); try with GetComponent(0) as TPLookupControl do begin Table.DatabaseName := DatabaseName; Table.TableName := TableName; Table.GetFieldNames(List); end; finally Table.Free; end; end; end; { TPRelationTableNameProperty } type TPRelationTableNameProperty = class(TPDBStringProperty) public procedure GetValueList(List: TStrings); override; end; procedure TPRelationTableNameProperty.GetValueList(List: TStrings); begin Session.GetTableNames((GetComponent(0) as TPRelationEdit).DatabaseName, '', True, False, List); end; { TPRelationFieldNameProperty } type TPRelationFieldNameProperty = class(TPDBStringProperty) public procedure GetValueList(List: TStrings); override; end; procedure TPRelationFieldNameProperty.GetValueList(List: TStrings); var Table: TTable; begin begin Table := TTable.Create(GetComponent(0) as TPRelationEdit); try with GetComponent(0) as TPRelationEdit do begin Table.DatabaseName := DatabaseName; Table.TableName := TableName; Table.GetFieldNames(List); end; finally Table.Free; end; end; end; { TPMasterKeyFieldProperty } type TPMasterKeyFieldProperty = class(TPDBStringProperty) public procedure GetValueList(List: TStrings); override; end; procedure TPMasterKeyFieldProperty.GetValueList(List: TStrings); var Table: TTable; begin begin Table := TTable.Create(GetComponent(0) as TDQueryDialog); try with GetComponent(0) as TDQueryDialog do begin Table.DatabaseName := DatabaseName; Table.TableName := MasterTableName; Table.GetFieldNames(List); end; finally Table.Free; end; end; end; { TPDetailKeyFieldProperty } type TPDetailKeyFieldProperty = class(TPDBStringProperty) public procedure GetValueList(List: TStrings); override; end; procedure TPDetailKeyFieldProperty.GetValueList(List: TStrings); var Table: TTable; begin begin Table := TTable.Create(GetComponent(0) as TDQueryDialog); try with GetComponent(0) as TDQueryDialog do begin Table.DatabaseName := DatabaseName; Table.TableName := DetailTableName; Table.GetFieldNames(List); end; finally Table.Free; end; end; end; { TPDBLookupControlFieldProperty } type TPDBLookupControlFieldProperty = class(TPDBStringProperty) public procedure GetValueList(List: TStrings); override; function GetDataSourcePropName: string; virtual; end; function TPDBLookupControlFieldProperty.GetDataSourcePropName: string; begin Result := 'DataSource'; end; procedure TPDBLookupControlFieldProperty.GetValueList(List: TStrings); var Instance: TComponent; PropInfo: PPropInfo; DataSource: TDataSource; begin Instance := TComponent(GetComponent(0)); PropInfo := TypInfo.GetPropInfo(Instance.ClassInfo, GetDataSourcePropName); if (PropInfo <> nil) and (PropInfo^.PropType^.Kind = tkClass) then begin DataSource := TObject(GetOrdProp(Instance, PropInfo)) as TDataSource; if (DataSource <> nil) then TTable(DataSource.DataSet).GetFieldNames(List); end; end; procedure Register; begin RegisterPropertyEditor(TypeInfo(string), TPBitBtn, 'PicFileName', TPPicFileNameProperty); RegisterPropertyEditor(TypeInfo(string), TPImage, 'PreDefPicFileName', TPPicFileNameProperty); RegisterPropertyEditor(TypeInfo(string), nil, 'ResourceName', TPUpperProperty); RegisterPropertyEditor(TypeInfo(TControl), TPLookupCombox, 'ListFieldControl', TPSubFieldControlProperty); RegisterPropertyEditor(TypeInfo(TControl), TPDBLookupCombox, 'ListFieldControl', TPSubFieldControlProperty); RegisterPropertyEditor(TypeInfo(TControl), TPLookupEdit, 'ListFieldControl', TPSubFieldControlProperty); RegisterPropertyEditor(TypeInfo(TControl), TPDBLookupEdit, 'ListFieldControl', TPSubFieldControlProperty); RegisterPropertyEditor(TypeInfo(TControl), TPDBEdit, 'ListFieldControl', TPSubFieldControlProperty); RegisterPropertyEditor(TypeInfo(TControl), TPDBCounterEdit, 'ListFieldControl', TPSubFieldControlProperty); RegisterPropertyEditor(TypeInfo(TControl), TPDBVendorEdit, 'ListFieldControl', TPSubFieldControlProperty); RegisterPropertyEditor(TypeInfo(TControl), TPDBStaffEdit, 'ListFieldControl', TPSubFieldControlProperty); RegisterPropertyEditor(TypeInfo(TControl), TPDBKindEdit, 'ListFieldControl', TPSubFieldControlProperty); RegisterPropertyEditor(TypeInfo(TControl), TPDBMemonoEdit, 'ListFieldControl', TPSubFieldControlProperty); RegisterPropertyEditor(TypeInfo(string), TQueryDialog, 'DatabaseName', TPDatabaseNameProperty); RegisterPropertyEditor(TypeInfo(string), TQueryDialog, 'TableName', TPTableNameProperty); RegisterPropertyEditor(TypeInfo(string), TPMemoEdit, 'DataBaseName', TPDatabaseNameProperty); RegisterPropertyEditor(TypeInfo(string), TPMemoEdit, 'TableName', TPMemoEditTableNameProperty); RegisterPropertyEditor(TypeInfo(string), TPMemoEdit, 'ForeignTableName', TPMemoEditTableNameProperty); RegisterPropertyEditor(TypeInfo(string), TPMemoEdit, 'FieldName', TPMemoEditFieldNameProperty); RegisterPropertyEditor(TypeInfo(string), TPMemoEdit, 'ForeignFieldName', TPMemoEditForeignFieldNameProperty); RegisterPropertyEditor(TypeInfo(string), TPCounterEdit, 'DataBaseName', TPDatabaseNameProperty); RegisterPropertyEditor(TypeInfo(string), TPCounterEdit, 'TableName', TPCounterEditTableNameProperty); RegisterPropertyEditor(TypeInfo(string), TPLookupControl, 'DatabaseName', TPDatabaseNameProperty); RegisterPropertyEditor(TypeInfo(string), TPLookupControl, 'TableName', TPLookupControlTableNameProperty); RegisterPropertyEditor(TypeInfo(string), TPLookupControl, 'KeyField', TPLookupControlFieldNameProperty); RegisterPropertyEditor(TypeInfo(string), TPLookupControl, 'ListField', TPLookupControlFieldNameProperty); RegisterPropertyEditor(TypeInfo(string), TPDBLookupCombox, 'DataField', TPDBLookupControlFieldProperty); RegisterPropertyEditor(TypeInfo(string), TPDBLookupEdit, 'DataField', TPDBLookupControlFieldProperty); RegisterPropertyEditor(TypeInfo(string), TPDBCounterEdit, 'DataField', TPDBLookupControlFieldProperty); RegisterPropertyEditor(TypeInfo(string), TPDBStaffEdit, 'DataField', TPDBLookupControlFieldProperty); RegisterPropertyEditor(TypeInfo(string), TPTable, 'DatabaseName', TPDatabaseNameProperty); RegisterPropertyEditor(TypeInfo(string), TPTable, 'TableName', TPTableTableNameProperty); RegisterPropertyEditor(TypeInfo(string), TDQueryDialog, 'DatabaseName', TPDatabaseNameProperty); RegisterPropertyEditor(TypeInfo(string), TDQueryDialog, 'MasterTableName', TPDTableNameProperty); RegisterPropertyEditor(TypeInfo(string), TDQueryDialog, 'DetailTableName', TPDTableNameProperty); RegisterPropertyEditor(TypeInfo(string), TDQueryDialog, 'MasterKeyField', TPMasterKeyFieldProperty); RegisterPropertyEditor(TypeInfo(string), TDQueryDialog, 'DetailKeyField', TPDetailKeyFieldProperty); RegisterPropertyEditor(TypeInfo(string), TPKindEdit, 'DatabaseName', TPDatabaseNameProperty); RegisterPropertyEditor(TypeInfo(string), TPGoodsEdit, 'DatabaseName', TPDatabaseNameProperty); RegisterPropertyEditor(TypeInfo(string), TPRelationEdit, 'DatabaseName', TPDatabaseNameProperty); RegisterPropertyEditor(TypeInfo(string), TPRelationEdit, 'TableName', TPRelationTableNameProperty); RegisterPropertyEditor(TypeInfo(string), TPRelationEdit, 'LookField', TPRelationFieldNameProperty); RegisterPropertyEditor(TypeInfo(string), TPRelationEdit, 'LookSubField', TPRelationFieldNameProperty); RegisterPropertyEditor(TypeInfo(string), TPStaffEdit, 'DatabaseName', TPDatabaseNameProperty); end; end.
unit Project87.Rocket; interface uses Strope.Math, Project87.BaseUnit, Project87.Types.GameObject; const ROCKET_SPEED = 80; ROCKET_LIFE_TIME = 4; ROCKET_PRECIZION = 35 * 35; START_DELAY = 0.35; FRICTION = 2.5; EXPLODE_TIME = 0.2; type TRocket = class (TGameObject) private FDamageRadius: Single; FDamage: Single; FOwner: TOwner; FLifetime: Single; FDirection: TVectorF; FAim: TVectorF; FStartDelay: Single; FExplosionAnimation: Single; FExplosion: Boolean; procedure Explode; procedure HitNearestShips; public constructor CreateRocket(const APosition, AVelocity, AAim: TVector2F; AAngle, ADamage, ADamageRadius: Single; AOwner: TOwner); procedure OnDraw; override; procedure OnUpdate(const ADelta: Double); override; procedure OnCollide(OtherObject: TPhysicalObject); override; end; implementation uses SysUtils, QApplication.Application, QEngine.Texture, Generics.Collections, Project87.Hero, Project87.BaseEnemy, Project87.Asteroid, Project87.Resources; {$REGION ' TRocket '} constructor TRocket.CreateRocket(const APosition, AVelocity, AAim: TVector2F; AAngle, ADamage, ADamageRadius: Single; AOwner: TOwner); begin inherited Create; FAim := AAim; FLifetime := ROCKET_LIFE_TIME; FDamage := ADamage; FDamageRadius := ADamageRadius; FPreviosPosition := APosition; FPosition := APosition; FVelocity := AVelocity; FAngle := AAngle; FOwner := AOwner; FStartDelay := START_DELAY; end; procedure TRocket.OnDraw; var BlowSize: Single; begin if not (FExplosion) then TheResources.RocketTexture.Draw(FPosition, Vec2F(64, 8), FAngle - 90, $FFFFFFFF, 1) else begin BlowSize := (1 - Abs(FExplosionAnimation / EXPLODE_TIME * 2 - 1)) * FDamageRadius * 0.5; TheResources.FieldTexture.Draw(FPosition, Vec2F(BlowSize, BlowSize), FAngle, $FFFFFFFF) end; end; procedure TRocket.OnUpdate(const ADelta: Double); begin if (FStartDelay < 0) then begin FLifetime := FLifetime - ADelta; if FLifetime < 0 then Explode; FVelocity := FVelocity + FDirection * ROCKET_SPEED; end else begin FAngle := RotateToAngle(FAngle, GetAngle(FPosition, FAim), 8); FStartDelay := FStartDelay - ADelta; FVelocity := FVelocity * (1 - ADelta * FRICTION); if FStartDelay < 0 then begin FDirection := (FAim - FPosition).Normalize; FAngle := GetAngle(FPosition, FAim); end; end; if FExplosion then begin if FExplosionAnimation > 0 then FExplosionAnimation := FExplosionAnimation - ADelta else begin FIsDead := True; end; end; end; procedure TRocket.HitNearestShips; var Ships: TList<TPhysicalObject>; Current: TPhysicalObject; Distance: Single; begin Ships := TObjectManager.GetInstance.GetObjects(TBaseUnit); for Current in Ships do if not Current.IsDead then begin if (Current is TBaseEnemy) and (FOwner = oPlayer) then if (Current.Position - FPosition).LengthSqr < FDamageRadius * FDamageRadius then begin Distance := 1 - (Current.Position - FPosition).Length / FDamageRadius; TBaseEnemy(Current).Hit(Distance * FDamage); end; if (Current is THeroShip) and (FOwner = oEnemy) then if (Current.Position - FPosition).LengthSqr < FDamageRadius * FDamageRadius then begin Distance := 1 - (Current.Position - FPosition).Length / FDamageRadius; THeroShip(Current).Hit(Distance * FDamage); end; end; Ships.Free; end; procedure TRocket.Explode; begin if not FExplosion then begin HitNearestShips; FExplosionAnimation := EXPLODE_TIME; FStartDelay := 1; FVelocity := ZeroVectorF; FExplosion := True; end; end; procedure TRocket.OnCollide(OtherObject: TPhysicalObject); var I: Word; CollideVector: TVectorF; begin if (OtherObject is TBaseEnemy) and (FOwner = oPlayer) then begin Explode(); end; if (OtherObject is TAsteroid) and not FExplosion then begin Explode(); for i := 0 to 3 + Random(10) do TAsteroid(OtherObject).Hit(GetAngle(OtherObject.Position, FPosition) + Random(30) - 15, 1); end; if (OtherObject is THeroShip) and (FOwner = oEnemy) then begin Explode(); end; end; {$ENDREGION} end.
unit uDemoValidateEmail; interface uses uDemo; type TDemoValidateEmail = class(TDemo) strict private function IsValidEmail(const Email: String): Boolean; strict protected procedure Run; override; public class function Description: String; override; end; implementation uses RegularExpressions; { TDemoValidateEmail } class function TDemoValidateEmail.Description: String; begin Result := 'Samples\Verify That Strings are in Valid E-Mail Format'; end; {$REGION} /// The following code example uses the class static <A>TRegex.IsMatch</A> /// method to verify that a string is in valid e-mail format. The /// <B>IsValidEmail</B> method returns <B>True</B> if the string contains a /// valid e-mail address and <B>False</B> if it does not, but takes no other /// action. You can use <B>IsValidEmail</B> to filter out e-mail addresses /// containing invalid characters before your application stores the addresses /// in a database or displays them in a web page. function TDemoValidateEmail.IsValidEmail(const Email: String): Boolean; begin Result := TRegex.IsMatch(Email, '^([0-9a-zA-Z]([-\.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$'); end; procedure TDemoValidateEmail.Run; var Email: String; begin Email := 'foo@bar.com'; if IsValidEmail(Email) then Log(Email + ' is valid') else Log(Email + ' is invalid!'); Email := 'foo@bar/com'; if IsValidEmail(Email) then Log(Email + ' is valid') else Log(Email + ' is invalid!'); end; {$ENDREGION} initialization RegisterDemo(TDemoValidateEmail); end.