home *** CD-ROM | disk | FTP | other *** search
/ Team Palmtops 7 / Palmtops_numero07.iso / WinCE / SDKWindowsCE / AutoPC / apcsdk10.exe / data1.cab / Emulation_Include_Files / recog.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-05-13  |  10.8 KB  |  288 lines

  1. /***************************************************************************\
  2. *                                                                            *
  3. * RECOG.H - Handwriting functions, types, and definitions                    *
  4. *                                                                            *
  5. *           Version 1.0                                                     *
  6. *                                                                            *
  7. *            Copyright (c) 1992-1996 Microsoft Corp. All rights reserved.    *
  8. *                                                                            *
  9. \***************************************************************************/
  10.  
  11. #ifndef _INC_RECOG
  12. #define _INC_RECOG
  13.  
  14. #include <windows.h>
  15.  
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif /* __cplusplus */
  19.  
  20. // @CESYSGEN IF CE_MODULES_HWXUSA
  21.  
  22. /* The constants below are used with HwxSetAlphabet */
  23.  
  24. // Enabled Alphabet:
  25. #define ALC_DEFAULT          0x00000000L // nothing
  26. #define ALC_LCALPHA          0x00000001L // a..z
  27. #define ALC_UCALPHA          0x00000002L // A..Z
  28. #define ALC_NUMERIC          0x00000004L // 0..9
  29. #define ALC_PUNC             0x00000008L // !-;`"?()&.,; and backslash
  30. #define ALC_MATH             0x00000010L // %^*()-+={}<>,/.
  31. #define ALC_MONETARY         0x00000020L // ,.$ or local
  32. #define ALC_OTHER            0x00000040L // @#|_~[]
  33. #define ALC_ASCII            0x00000080L // restrict to 7-bit chars 20..7f
  34. #define ALC_WHITE            0x00000100L // white space
  35. #define ALC_NONPRINT         0x00000200L // sp tab ret ctrl glyphs
  36. #define ALC_DBCS             0x00000400L // allow DBCS variety of SBCS
  37. #define ALC_JIS1             0x00000800L // kanji JPN, ShiftJIS 1 only
  38. #define    ALC_NUMERIC_PUNC     0x00001000L // Non digit characters in numbers
  39. #define ALC_GESTURE          0x00004000L // gestures
  40. #define ALC_USEBITMAP        0x00008000L // use rc.rgbfAlc to enable chars
  41. #define ALC_HIRAGANA         0x00010000L // hiragana JPN
  42. #define ALC_KATAKANA         0x00020000L // katakana JPN
  43. #define ALC_JIS2             0x00040000L // kanji JPN, ShiftJIS 2+3
  44. #define ALC_GLOBALPRIORITY   0x10000000L
  45. #define ALC_BEGINPUNC        0x20000000L // English: [ { ( " etc.
  46. #define ALC_ENDPUNC          0x40000000L // English: ] } ) " etc.
  47. #define ALC_OEM              0x0FF80000L // OEM recognizer-specific
  48. #define ALC_RESERVED         0x80002000L // avail for future use
  49. #define ALC_NOPRIORITY       0x00000000L // for alcPriority == none
  50.  
  51. #define ALC_ALPHA\
  52.     (ALC_LCALPHA | ALC_UCALPHA)                                // 0x00000003L
  53.  
  54. #define ALC_ALPHANUMERIC\
  55.     (ALC_ALPHA | ALC_NUMERIC)                                  // 0x00000007L
  56.  
  57. #define ALC_SYSMINIMUM\
  58.     (ALC_ALPHANUMERIC | ALC_PUNC | ALC_WHITE)                  // 0x0000010FL
  59.  
  60. #define ALC_ALL\
  61.     (ALC_SYSMINIMUM | ALC_MATH | ALC_MONETARY\
  62.     | ALC_OTHER | ALC_NONPRINT)                                // 0x0000037FL
  63.  
  64. #define ALC_KANJISYSMINIMUM\
  65.     (ALC_SYSMINIMUM | ALC_HIRAGANA | ALC_KATAKANA | ALC_JIS1)  // 0x0003090FL
  66.  
  67. #define ALC_KANJIALL\
  68.     (ALC_ALL | ALC_HIRAGANA | ALC_KATAKANA | ALC_JIS1 | ALC_JIS2) // 0x00070B7FL
  69.  
  70. /* Special Symbol Values potentially returned by HwxGetResults. */
  71.  
  72. #define SYV_NULL                0x00000000L    // Filler when list is not full
  73.  
  74. /* Possible High Words of SYVs */
  75.  
  76. #define SYVHI_FIRST             0        // first valid value
  77. #define SYVHI_SPECIAL           0
  78. #define SYVHI_ANSI              1
  79. #define SYVHI_GESTURE           2
  80. #define SYVHI_KANJI             3    // This is the only one actually used
  81. #define SYVHI_SHAPE             4
  82. #define SYVHI_UNICODE           5
  83. #define SYVHI_VKEY              6
  84. #define SYVHI_LAST              6        // last valid value
  85.  
  86. #ifndef RC_INVOKED                // ... rest of file of no interest to rc compiler
  87.  
  88. /* Used in HwxInput in the STROKEINFO structure */
  89.  
  90. #define PDK_NULL                0x0000  // default to no flags set
  91. #define PDK_UP                  0x0000  // PDK_NULL alias
  92. #define PDK_DOWN                0x0001  // pentip switch ON due to contact
  93. #define PDK_BARREL1             0x0002  // barrel1 switch depressed
  94. #define PDK_BARREL2             0x0004  // ditto 2
  95. #define PDK_BARREL3             0x0008  // ditto 3
  96. #define PDK_SWITCHES            0x000f  // sum of down + barrels 1,2,3
  97. #define PDK_TRANSITION          0x0010  // set by GetPenHwData
  98. #define PDK_UNUSED10            0x0020
  99. #define PDK_UNUSED20            0x0040
  100. #define PDK_INVERTED            0x0080  // other end of pen used as tip
  101. #define PDK_PENIDMASK           0x0F00  // bits 8..11 physical pen id (0..15)
  102. #define PDK_UNUSED1000          0x1000
  103. #define PDK_INKSTOPPED          0x2000  // Inking stopped
  104. #define PDK_OUTOFRANGE          0x4000  // pen left range (OEM data invalid)
  105. #define PDK_DRIVER              0x8000  // pen (not mouse) event
  106.  
  107. #define PDK_TIPMASK             0x0001  // mask for testing PDK_DOWN
  108. #define PDK_EVENT               PDK_TRANSITION  // alias         /* ;Internal */
  109.  
  110. // General HRC API return values (HRCR_xx):
  111. #define HRCR_COMPLETE           3       // finished recognition
  112. #define HRCR_OK                 1       // success
  113. #define HRCR_ERROR              (-1)    // invalid param or unspecified error
  114. #define HRCR_MEMERR             (-2)    // memory error
  115.  
  116. // ProcessHRC time constants:
  117. #define PH_MAX                  0xFFFFFFFFL   // recognize rest of ink
  118.  
  119. // SYV macros:
  120. #define FIsSpecial(syv)         (HIWORD((syv))==SYVHI_SPECIAL)
  121. #define FIsAnsi(syv)            (HIWORD((syv))==SYVHI_ANSI)
  122. #define FIsGesture(syv)         (HIWORD((syv))==SYVHI_GESTURE)
  123. #define FIsKanji(syv)           (HIWORD((syv))==SYVHI_KANJI)
  124. #define FIsShape(syv)           (HIWORD((syv))==SYVHI_SHAPE)
  125. #define FIsUniCode(syv)         (HIWORD((syv))==SYVHI_UNICODE)
  126. #define FIsVKey(syv)            (HIWORD((syv))==SYVHI_VKEY)
  127.  
  128. #define ChSyvToAnsi(syv)        ((BYTE) (LOBYTE(LOWORD((syv)))))
  129. #define WSyvToKanji(syv)        ((WORD) (LOWORD((syv))))
  130. #define SyvCharacterToSymbol(c) ((LONG)(unsigned char)(c) | 0x00010000)
  131. #define SyvKanjiToSymbol(c)     ((LONG)(UINT)(c) | 0x00030000)
  132.  
  133. // Simple typedefs
  134. typedef LONG                    ALC;    // Enabled Alphabet
  135. typedef LONG                    SYV;    // Symbol Value
  136.  
  137. #ifndef DECLARE_HANDLE32
  138. #define    DECLARED_HANDLE32
  139. #define DECLARE_HANDLE32(name)\
  140.     struct name##__ { int unused; };\
  141.     typedef const struct name##__ FAR* name
  142. #endif //!DECLARE_HANDLE32
  143.  
  144. typedef ALC FAR*                PALC;        // ptr to ALC
  145. typedef SYV FAR*                PSYV;        // ptr to SYV
  146. typedef ALC FAR*                LPALC;       // ptr to ALC
  147. typedef SYV FAR*                LPSYV;       // ptr to SYV
  148.  
  149. // This structure contains all the information about a stroke except the points
  150.  
  151. typedef struct tagSTROKEINFO    // 1.0 stroke header
  152. {
  153.     UINT cPnt;                   // count of points in stroke
  154.     UINT cbPnts;                 // size of stroke in bytes
  155.     UINT wPdk;                   // state of stroke
  156.     DWORD dwTick;                // time at beginning of stroke
  157. } STROKEINFO, *PSTROKEINFO, FAR *LPSTROKEINFO;
  158.  
  159. // Handwriting Recognizer:
  160.  
  161. DECLARE_HANDLE32(HRC);          // Handwriting Recognition Context
  162. DECLARE_HANDLE(HINKSET);        // handle to an inkset
  163.  
  164. typedef HRC FAR* PHRC;
  165. typedef HRC FAR* LPHRC;
  166. typedef HINKSET FAR* LPHINKSET;
  167.  
  168. /* Returned from HwxGetResults */
  169.  
  170. typedef struct tagBOXRESULTS    // 2.0
  171. {
  172.     UINT indxBox;        // zero-based index in guide structure where char was written
  173.     HINKSET hinksetBox;    // unused
  174.     SYV rgSyv[1];        // variable-sized array of characters returned
  175. } BOXRESULTS, *PBOXRESULTS, FAR *LPBOXRESULTS;
  176.  
  177. /* Passed in to HwxSetGuide.  Specifies where the boxes are on the screen */
  178.  
  179. typedef struct tagGUIDE         // 1.0 guide structure
  180. {
  181.     int xOrigin;                 // left edge of first box (screen coord)
  182.     int yOrigin;                 // top edge of first box (screen coord)
  183.     int cxBox;                   // width of a single box
  184.     int cyBox;                   // height of a single box
  185.     int cxBase;                  // in-box x-margin to guideline
  186.     int cyBase;                  // in-box y offset from top to baseline
  187.     int cHorzBox;                // count of boxed columns
  188.     int cVertBox;                // count of boxed rows
  189.     int cyMid;                   // 0 or distance from baseline to midline
  190. } GUIDE, *PGUIDE, FAR *LPGUIDE;
  191.  
  192. /* Called once to initialize DLL */
  193.  
  194. BOOL      WINAPI HwxConfig();
  195.  
  196. /* Called to create an HRC before any ink is collected. You can pass in NULL
  197. for the parameter, but if you pass in an old HRC, it copies the old settings (such
  198. as alphabet, guide structure, previous context, etc.)  */
  199.  
  200. HRC       WINAPI HwxCreate(HRC);
  201.  
  202. /* Called to destroy an HRC after recognition is complete */
  203.  
  204. int       WINAPI HwxDestroy(HRC);
  205.  
  206. /* Tells the HRC where the boxes on the screen are. Third parameter is first visible
  207. box.  (Should probably always be zero.) */
  208.  
  209. int       WINAPI HwxSetGuide(HRC, GUIDE *, UINT);
  210.  
  211. /* Limits the set of characters the recognizer can return.  (See ALC values above.) */
  212.  
  213. int       WINAPI HwxSetAlphabet(HRC, ALC);
  214.  
  215. /* Sets parameter for partial recognition */
  216.  
  217. int          WINAPI HwxSetPartial(HRC, DWORD);
  218.  
  219. /* Sets abort address */
  220.  
  221. int          WINAPI HwxSetAbort(HRC, DWORD *);
  222.  
  223. /* Adds ink to the HRC. */
  224.  
  225. int       WINAPI HwxInput(HRC, POINT *, STROKEINFO *);
  226.  
  227. /* Called after last ink is added.  You cannot add anymore ink
  228. to the HRC after this has been called. */
  229.  
  230.  
  231. int       WINAPI HwxEndInput(HRC);
  232.  
  233. /* Recognizes as much ink as it can */
  234.  
  235. int       WINAPI HwxProcess(HRC);
  236.  
  237. /* Retreives the results from an HRC. This may be called repeatedly. This allows you
  238. to get restults from several characters at a time. The return value is the number of
  239. characters actually returned. */
  240.  
  241. int WINAPI HwxGetResults(
  242.     HRC hrc,    // HRC containing results
  243.     UINT cAlt,    // Number of alternates
  244.     UINT iSyv,    // index of first character to return
  245.     UINT cBoxRes, // number of characters to return
  246.     BOXRESULTS *rgBoxResults    // array of cBoxRes ranked lists
  247. );
  248.  
  249. /* Tells the HRC what the previous character was for context purposes. */
  250.  
  251. int       WINAPI HwxSetContext(HRC, WCHAR);
  252.  
  253. /* Tells you how many results can be retrieved from HwxGetResults */
  254.  
  255. int       WINAPI HwxResultsAvailable(HRC);
  256.  
  257. /* Suggested sequence for using these APIs:
  258.  
  259.     HwxConfig (once only)
  260.         HwxCreate (once per recognition panel)
  261.         HwxSetGuide
  262.         HwxSetAlphabet
  263.         HwxSetContext    (if there is a previous character)
  264.             HwxInput    (as the user writes)
  265.             HwxProcess  (To Process the ink input)
  266.             HwxResultsAvailable (Find out if new results are available)
  267.                 HwxGetResults   (every time there are any results available)
  268.         HwxEndInput (When user is done inputting ink)
  269.         HwxProcess  (To Process the ink input)
  270.         HwxGetResults (to get the last characters)
  271.         HwxDestroy
  272. */
  273.  
  274. #endif 
  275.  
  276. #ifdef DECLARED_HANDLE32
  277. #undef DECLARE_HANDLE32
  278. #undef DECLARED_HANDLE32
  279. #endif
  280.  
  281. // @CESYSGEN ENDIF
  282.  
  283. #ifdef __cplusplus
  284. }
  285. #endif // __cplusplus
  286.  
  287. #endif // #define _INC_RECOG
  288.