Смекни!
smekni.com

Система распознавания объектов в миллиметровом диапазоне радиоволн (стр. 20 из 23)

function AnsiFromSyvAppGesture(syv: TSYV): Byte;

{Константы обработки входных значений декодирования}

const

rec_OEM = –1024;

rec_Language = –48;

rec_Guide = –47;

rec_ParamError = –46;

rec_InvalidRef = –45;

rec_RectExclude = –44;

rec_RectBound = –43;

rec_PCM = –42;

rec_ResultMode = –41;

rec_HWnd = –40;

rec_ALC = –39;

rec_ErrorLevel = –38;

rec_CLVerify = –37;

rec_Dict = –36;

rec_HRec = –35;

rec_BadEventRef = –33;

rec_NoCollection = –32;

rec_Debug = –32;

rec_PointerEvent = –31;

rec_BadHPenData = –9;

rec_OOM = –8;

rec_NoInput = –7;

rec_NoTablet = –6;

rec_Busy = –5;

rec_BufferTooSmall = –4;

rec_Abort = –3;

rec_Overflow = –1;

rec_OK = 0;

rec_TermBound = 1;

rec_TermEx = 2;

rec_TermPenUp = 3;

rec_TermRange = 4;

rec_TermTimeOut = 5;

rec_Done = 6;

rec_TermOEM = 512;

type

POEMPenInfo = ^TOEMPenInfo;

TOEMPenInfo = record

wPdt: Word;

wValueMax: Word;

wDistinct: Word;

end;

const

pdt_Null = 0;

pdt_Pressure = 1;

pdt_Height = 2;

pdt_AngleXY = 3;

pdt_AngleZ = 4;

pdt_BarrelRotation = 5;

pdt_OEMSpecific = 16;

MaxOEMDataWords = 6;

type

PPenPacket = ^TPenPacket;

TPenPacket = record

wTabletX: Word;

wTabletY: Word;

wPDK: Word;

rgwOemData: array[0..MaxOEMDataWords – 1] of Word;

end;

type

TRawHook = function(PenPacket: PPenPacket): Bool;

type

PPenInfo = ^TPenInfo;

TPenInfo = record

cxRawWidth: Word;

cyRawHeight: Word;

wDistinctWidth: Word;

wDistinctHeight: Word;

nSamplingRate: Integer;

nSamplingDist: Integer;

lPdc: Longint;

cPens: Integer;

cbOemData: Integer;

rgoempeninfo: array[0..MaxOEMDataWords – 1] of TOEMPenInfo;

rgwReserved: array[0..7] of Word;

end;

const

pdc_Integrated = $00000001;

pdc_Proximity = $00000002;

pdc_Range = $00000004;

pdc_Invert = $00000008;

pdc_Relative = $00000010;

pdc_Barrel1 = $00000020;

pdc_Barrel2 = $00000040;

pdc_Barrel3 = $00000080;

type

PStrokeInfo = ^TStrokeInfo;

TStrokeInfo = record

cPnt: Word;

cbPnts: Word;

wPDK: Word;

dwTick: Longint;

end;

type

PCalbStruct = ^TCalbStruct;

TCalbStruct = record

wOffsetX: Integer;

wOffsetY: Integer;

wDistinctWidth: Integer;

wDistinctHeight: Integer;

end;

const

drv_SetPenDriverEntryPoints = drv_Reserved+1;

drv_RemovePenDriverEntryPoints = drv_Reserved+2;

drv_SetPenSamplingRate = drv_Reserved+3;

drv_SetPenSamplingDist = drv_Reserved+4;

drv_GetCalibration = drv_Reserved+11;

drv_SetCalibration = drv_Reserved+12;

const

pdk_Up = $0000;

pdk_Down = $0001;

pdk_Barrel1 = $0002;

pdk_Barrel2 = $0004;

pdk_Barrel3 = $0008;

pdk_Transition = $0010;

pdk_Inverted = $0080;

pdk_OutOfRange = $4000;

pdk_Driver = $8000;

pdk_TipMask = $0001;

pdk_Switches = pdk_Down or pdk_Barrel1 or pdk_Barrel2 or

pdk_Barrel3;

const

pcm_Penup = $00000001;

pcm_Range = $00000002;

pcm_Invert = $00000020;

pcm_RectExclude = $00002000;

pcm_RectBound = $00004000;

pcm_Timeout = $00008000;

pcm_AddDefaults = rc_LDefaultFlags; { $80000000 }

procedure PostVirtualKeyEvent(vk: Word; fUp: Bool);

procedure PostVirtualMouseEvent(wMouseFlag: Word; xPos, yPos: Integer);

procedure AtomicVirtualEvent(fBegin: Bool);

const

vwm_MouseMove = $0001;

vwm_MouseLeftDown = $0002;

vwm_MouseLeftUp = $0004;

vwm_MouseRightDown = $0008;

vwm_MouseRightUp = $0010;

const

cl_Null = 0;

cl_Minimum = 1;

cl_Maximum = 100;

InkWidth_Minimum = 0;

InkWidth_Maximum = 15;

enum_Minimum = 1;

enum_Maximum = 4096;

MaxDictionaries = 16;

type

PGuide = ^TGuide;

TGuide = record

xOrigin: Integer;

yOrigin: Integer;

cxBox: Integer;

cyBox: Integer;

cxBase: Integer;

cyBase: Integer;

cHorzBox: Integer;

cVertBox: Integer;

cyMid: Integer;

end;

type

TRCYieldProc = function : Bool;

const

cbRcLanguageMax = 44;

cbRcUserMax = 32;

cbRcrgbfAlcMax = 32;

cwRcReservedMax = 8;

type

PRC = ^TRC;

TRC = record

HRec: THRec;

hw: HWnd;

wEventRef: Word;

wRcPreferences: Word;

lRcOptions: Longint;

lpfnYield: TRCYieldProc;

lpUser: array[0..cbRcUserMax–1] of Byte;

wCountry: Word;

wIntlPreferences: Word;

lpLanguage: array[0..cbRcLanguageMax–1] of Char;

rglpdf: array[0..MaxDictionaries–1] of TDF;

wTryDictionary: Word;

clErrorLevel: TCL;

alc: TALC;

alcPriority: TALC;

rgbfAlc: array[0..cbRcrgbfAlcMax–1] of Byte;

wResultMode: Word;

wTimeOut: Word;

lPcm: Longint;

rectBound: TRect;

rectExclude: TRect;

guide: TGuide;

wRcOrient: Word;

wRcDirect: Word;

nInkWidth: Integer;

rgbInk: TColorRef;

dwAppParam: Longint;

dwDictParam: Longint;

dwRecognizer: Longint;

rgwReserved: array[0..cwRcReservedMax–1] of Word;

end;

type

THPenData = THandle;

type

PSYC = ^TSYC;

TSYC = record

wStrokeFirst: Word;

wPntFirst: Word;

wStrokeLast: Word;

wPntLast: Word;

fLastSyc: Bool;

end;

const

wPntAll = $FFFF;

iSycNull = –1;

type

PSYE = ^TSYE;

TSYE = record

syv: TSYV;

lRecogVal: Longint;

cl: TCL;

iSyc: Integer;

end;

const

MaxHotSpot = 8;

type

PSYG = ^TSYG;

TSYG = record

rgpntHotSpots: array[0..MaxHotSpot–1] of TPoint;

cHotSpot: Integer;

nFirstBox: Integer;

lRecogVal: Longint;

lpsye: PSYE;

cSye: Integer;

lpsyc: PSYC;

cSyc: Integer;

end;

type

TEnumProc = function(syv: PSYV; i: Integer; P: Pointer): Integer;

type

PRCResult = ^TRCResult;

TRCResult = record

syg: TSYG;

wResultsType: Word;

cSyv: Integer;

lpsyv: PSYV;

HSyv: THandle;

nBaseLine: Integer;

nMidLine: Integer;

hPenData: THPenData;

rectBoundInk: TRect;

pntEnd: TPoint;

lprc: PRC;

end;

const

rcrt_Default = $0000;

rcrt_Unidentified = $0001;

rcrt_Gesture = $0002;

rcrt_NoSymbolMatch = $0004;

rcrt_Private = $4000;

rcrt_NoRecog = $8000;

rcrt_AlreadyProcessed = $0008;

rcrt_GestureTranslated = $0010;

rcrt_GestureToKeys = $0020;

hkp_SetHook = 0;

hkp_Unhook = $FFFF;

hwr_Results = 0;

hwr_AppWide = 1;

pen_NoInkWidth = 0;

const

rpa_Default = 1;

{ GetGlobalRC возвращает кода}

const

ggrc_OK = 0;

ggrc_DictBufTooSmall = 1;

ggrc_ParamError = 2;

{ SetGlobalRC устанавливает код}

const

sgrc_OK = $0000;

sgrc_User = $0001;

sgrc_ParamError = $0002;

sgrc_RC = $0004;

sgrc_Recognizer = $0008;

sgrc_Dictionary = $0010;

sgrc_INIFile = $0020;

{ Макро }

function GetWEventRef: Word;

function InstallRecognizer(lpszRecogName: PChar): THRec;

procedure UninstallRecognizer(HRec: THRec);

function GetGlobalRC(lprc: PRC; lpDefRecog: PChar; lpDefDict: PChar;

cbDefDictMax: Integer): Word;

function SetGlobalRC(lprc: PRC; lpDefRecog: PChar; lpDefDict: PChar): Word;

procedure RegisterPenApp(wFlags: Word; fRegister: Bool);

function IsPenAware: Word;

function SetRecogHook(whrHook: Word; hkpPosition: Word; HWndHook: HWnd): Bool;

procedure InitRC(hw: HWnd; lprc: PRC);

function Recognize(lprc: PRC): TRec;

function RecognizeData(lprc: PRC; hPenData: THPenData): TRec;

function TrainInk(lprc: PRC; hPenData: THPenData; lpsyv: PSYV): Bool;

function TrainContext(lprcresult: PRCResult; lpsye: PSYE; cSye: Integer;

lpsyc: PSYC; cSyc: Integer): Bool;

function ProcessWriting(hw: HWnd; lprc: PRC): TRec;

function CorrectWriting(hw:HWnd; lpBuf:PChar; cbBuf: Word; lprc: PRC;

dwCwrFlags: Longint; dwReserved: Longint): Bool;

procedure EmulatePen(fPen: Bool);

function GetSymbolMaxLength(lpsyg: PSYG): Integer;

function GetSymbolCount(lpsyg: PSYG): Integer;

procedure FirstSymbolFromGraph(lpsyg: PSYG; lpsyv: PSYV; cSyvMax: Integer;

lpcSyv: PInteger);

function EnumSymbols(lpsyg: PSYG; wMaxStr: Word; lpEnumFunc: TEnumProc;

lvData: Pointer): Word;

function TPtoDP(lpPnt: PPoint; cPnt: Integer): Bool;

function DPtoTP(lpPnt: PPoint; cPnt: Integer): Bool;

procedure BoundingRectFromPoints(lpPnt: PPoint; cPnt: Integer;

lpRectBound: PRect);

function SymbolToCharacter(lpsyv: PSYV; cSyv: Integer; lpstr: PStr;

lpnConv: PInteger): Bool;

function CharacterToSymbol(lpstr: PStr; cSyv: Integer; lpsyv: PSYV): Integer;

function GetVersionPenWin: Word;

function ExecuteGesture(hw: HWnd; syv: TSYV; lprcresult: PRCResult): Bool;

const

alc_All = $000043FF;

alc_Default = $00000000;

alc_LCAlpha = $00000001;

alc_UCAlpha = $00000002;

alc_Alpha = $00000003;

alc_Numeric = $00000004;

alc_Alphanumeric = $00000007;

alc_Punc = $00000008;

alc_Math = $00000010;

alc_Monetary = $00000020;

alc_Other = $00000040;

alc_White = $00000100;

alc_NonPrint = $00000200;

alc_Gesture = $00004000;

alc_UseBitmap = $00008000;

alc_DBCS = $00000400;

alc_Hiragana = $00010000;

alc_Katakana = $00020000;

alc_Kanji = $00040000;

alc_OEM = $0FF80000;

alc_Reserved = $F0003800;

alc_NoPriority = $00000000;

alc_SysMinimum = alc_Alphanumeric or

alc_Punc or alc_White or

alc_Gesture;

{ macros }

function MpAlcB(lprc: PRC; i: Word): PByte;

function MpIbf(i: Word): Byte;

procedure SetAlcBitAnsi(lprc: PRC; i: Word);

procedure ResetAlcBitAnsi(lprc: PRC; i: Word);

function IsAlcBitAnsi(lprc: PRC; i: Word): Boolean;

const

rcd_Default = 0;

rcd_LR = 1;

rcd_RL = 2;

rcd_TB = 3;

rcd_BT = 4;

const

rco_NoPointerEvent = $00000001;

rco_SaveAllData = $00000002;

rco_SaveHPenData = $00000004;

rco_NoFlashUnknown = $00000008;

rco_TabletCoord = $00000010;

rco_NoSpaceBreak = $00000020;

rco_NoHideCursor = $00000040;

rco_NoHook = $00000080;

rco_Boxed = $00000100;

rco_Suggest = $00000200;

rco_DisableGesMap = $00000400;

rco_NoFlashCursor = $00000800;

rco_ColdRecog = $00008000;

const

rcp_LeftHand = $0001;

rcp_MapChar = $0004;

const

rcor_Normal = 1;

rcor_Right = 2;

rcor_Upsidedown = 3;

rcor_Left = 4;

rrm_Stroke = 0;

rrm_Symbol = 1;

rrm_Word = 2;

rrm_NewLine = 3;

rrm_Complete = 16;

rcip_AllAnsiChar = $0001;

rcip_Mask = $0001;

cwr_StripCR = $00000001;

cwr_StripLF = $00000002;

cwr_StripTAB = $00000004;

cwr_SingleLineEdit = $00000007;

cwr_Title = $00000010;

cwr_KKConvert = $00000020;

const

map_GestOGES = rcrt_Gesture or rcrt_GestureTranslated;

map_GestOVKeys = rcrt_GestureToKeys or rcrt_AlreadyProcessed;

{ макросы }

function IsGestureToGesture(lprcresult: PRCResult): Boolean;

function IsGestureToVkeys(lprcresult: PRCResult): Boolean;

procedure SetAlreadyProcessed(lprcresult: PRCResult);

type

PPenDataHeader = ^TPenDataHeader;

TPenDataHeader = record

wVersion: Word;

cbSizeUsed: Word;

cStrokes: Word;

cPnt: Word;

cPntStrokeMax: Word;

rectBound: TRect;

wPndts: Word;

nInkWidth: Integer;

rgbInk: Longint;

end;

const

pdts_LOMetric = $0000;

pdts_HIMetric = $0001;

pdts_HIEnglish = $0002;

pdts_ScaleMax = $0003;

pdts_Display = $0003;

pdts_Arbitrary = $0004;

pdts_ScaleMask = $000F;

pdts_StandardScale = pdts_HIEnglish;

pdts_NoPenInfo = $0100;

pdts_NoUpPoints = $0200;

pdts_NoOEMData = $0400;

pdts_NoColinear = $0800;

pdts_Compressed = $8000;

pdts_CompressMethod = $00F0;

pdts_Compress2ndDeriv = $0010;

pdtt_Default = $0000;

pdtt_PenInfo = pdts_NoPenInfo;

pdtt_UpPoints = pdts_NoUpPoints;

pdtt_OEMdata = pdts_NoOEMData;

pdtt_Colinear = pdts_NoColinear;

pdtt_Compress = pdts_Compressed;

pdtt_Decompress = $4000;

pdtt_All = pdtt_PenInfo or pdtt_UpPoints or pdtt_OEMdata or pdtt_Colinear;

function DestroyPenData(hPenData: THPenData): Boolean;

procedure EndEnumStrokes(hPenData: THPenData);

function IsPenEvent(Message: Word; lExtraInfo: Longint): Bool;

function GetPenAsyncState(wPDK: Word): Bool;

function GetPenDataInfo(hPenData: THPenData; lppendataheader: PPenDataHeader;

lpPenInfo: PPenInfo; dwReserved: Longint): Bool;

function GetPenDataStroke(lppendata: PPenDataHeader; wStroke: Word;

lplpPoint: PPoint; lplpvOem: Pointer; lpsi: PStrokeInfo ): Bool;

function GetPointsFromPenData(hPenData: PPenDataHeader; wStroke, wPnt, cPnt: Word;

lppoint: PPoint): Bool;

procedure DrawPenData(DC: HDC; lprect: PRect; hPenData: THPenData);

function MetricScalePenData(hPenData: THPenData; wPdts: Word): Bool;

function ResizePenData(hPenData: THPenData; lprect: PRect): Bool;

function OffsetPenData(hPenData: THPenData; dx, dy: Integer): Bool;

function RedisplayPenData(DC:HDC; hPenData: THPenData; lpDelta: PPoint;

lpExt: PPoint; nInkWidth: Integer; rgbColor: Longint): Bool;

function CompactPenData(hPenData: THPenData; wTrimOptions: Word): THPenData;

function DuplicatePenData(hPenData:THPenData; gmemFlags: Word): THPenData;

function CreatePenData(lpPenInfo: PPenInfo; cbOemData: Integer;

wPdtScale: Word; gmemFlags: Word): THPenData;

function AddPointsPenData(hPenData: THPenData; lpPnt: PPoint;

lpvOemData: Pointer; lpsiNew: PStrokeInfo): THPenData;

function BeginEnumStrokes(hPenData: THPenData): PPenDataHeader;

function DictionarySearch(lprc: PRC; lpsye: PSYE; cSye: Integer;

lpsyv: PSYV; cSyvMax: Integer): Bool;

const

he_GetRC = 3;

he_SetRC = 4;

he_GetInflate = 5;

he_SetInflate = 6;

he_GetUnderline = 7;

he_SetUnderline = 8;

he_GetInkHandle = 9;

he_SetInkMode = 10;

he_StopInkMode = 11;

he_GetRCResultCode = 12;

he_DefaultFont = 13;

he_CharPosition = 14;

he_CharOffset = 15;

he_GetRCResult = 22;

he_KKConvert = 30;

he_GetKKConvert = 31;

he_CancelKKConvert = 32;

he_FixKKConvert = 33;

hekk_Default = 0;

hekk_Convert = 1;

hekk_Candidate = 2;

hep_NoRecog = 0;

hep_Recog = 1;

hep_WaitForTap = 2;

hn_EndRec = 4;

hn_DelayedRecogFail = 5;

hn_RCResult = 20;

hn_EndKKConvert = 30;

type

PRectOfs = ^TRectOfs;

TRectOfs = record

dLeft: Integer;

dTop: Integer;

dRight: Integer;

dBottom: Integer;

end;

{Конроль за идентификацией данных}

type

PBoxLayout = ^TBoxLayout;

TBoxLayout = record

cyCusp: Integer;

cyEndCusp: Integer;

Style: Word;

rgbText: Longint;

rgbBox: Longint;

rgbSelect: Longint;

end;

const

bxs_None = 0;

bxs_Rect = 1;

bxs_EndTextmark = 2;

bxs_Mask = 3;

he_GetBoxLayout = 20;

he_SetBoxLayout = 21;

bxd_CellWidth = 12;

bxd_CellHeight = 16;

bxd_BaseHeight = 13;

bxd_BaseHorz = 0;

bxd_CuspHeight = 2;

bxd_EndCuspHeight = 4;

function ShowKeyboard(Handle: HWnd; wCommand: Word; lpPnt: PPoint;

lpSKBInfo: PSKBInfo): Bool;

const

cbn_EndRec = 16;

cbn_DelayedRecogFail = 17;

cbn_RcResult = 18;

implementation

type

LongRec = record

Lo, Hi: Word;

end;

WordRec = record

Lo, Hi: Byte;

end;

{ translations of macros }

function ChSyvToAnsi(syv: Longint): Byte;

begin

ChSyvToAnsi := WordRec(LongRec(syv).Lo).Lo;

end;

function SyvCharacterToSymbol(c: Char): Longint;

begin

SyvCharacterToSymbol := Byte(c) or $10000;