Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

249 lines
9.9 KiB

  1. /***************************************************************************\
  2. *
  3. * RECOG.H - Handwriting functions, types, and definitions
  4. *
  5. * Version 1.1
  6. *
  7. * Copyright (c) 1992-1998 Microsoft Corp. All rights reserved.
  8. *
  9. \***************************************************************************/
  10. #ifndef _INC_RECOG
  11. #define _INC_RECOG
  12. // @CESYSGEN IF CE_MODULES_HWXUSA || CE_MODULES_HWXJPN
  13. #include <windows.h>
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif /* __cplusplus */
  17. /* Suggested sequence for using these APIs:
  18. *
  19. * HwxConfig (once only)
  20. * HwxCreate (once per recognition panel)
  21. * HwxSetGuide
  22. * HwxALCValid
  23. * HwxSetContext (if there is a previous character)
  24. * HwxInput (as the user writes)
  25. * HwxProcess (to process the ink input)
  26. * HwxResultsAvailable (find out if new results are available)
  27. * HwxGetResults (every time there are any results available)
  28. * HwxEndInput (when user is done inputting ink)
  29. * HwxProcess (to process the ink input)
  30. * HwxGetResults (to get the last characters)
  31. * HwxDestroy
  32. */
  33. // The constants below are used with HWXSetAlphabet(). These specify which
  34. // character groupings to recognize.
  35. #define ALC_WHITE 0x00000001 // White space.
  36. #define ALC_LCALPHA 0x00000002 // a..z
  37. #define ALC_UCALPHA 0x00000004 // A..Z
  38. #define ALC_NUMERIC 0x00000008 // 0..9
  39. #define ALC_PUNC 0x00000010 // Standard punc., language dependent.
  40. #define ALC_NUMERIC_PUNC 0x00000020 // Non digit characters in numbers.
  41. #define ALC_MATH 0x00000040 // %^*()-+={}<>,/. (??? language dependent ???)
  42. #define ALC_MONETARY 0x00000080 // Punct. in local monetary expressions.
  43. #define ALC_COMMON_SYMBOLS 0x00000100 // Commonly used symbols from all categories.
  44. #define ALC_OTHER 0x00000200 // Other punctuation not typically used.
  45. #define ALC_ASCII 0x00000400 // 7-bit chars 20..7F
  46. #define ALC_HIRAGANA 0x00000800 // Hiragana (JPN)
  47. #define ALC_KATAKANA 0x00001000 // Katakana (JPN)
  48. #define ALC_KANJI_COMMON 0x00002000 // Common Kanji (JPN, CHS, CHT and KOR)
  49. #define ALC_KANJI_RARE 0x00004000 // Common Kanji (JPN, CHS, CHT and KOR)
  50. #define ALC_HANGUL_COMMON 0x00008000 // Common Hangul used in Korea.
  51. #define ALC_HANGUL_RARE 0x00010000 // The rest of the Hangul used in Korea.
  52. #define ALC_UNUSED 0x00F80000 // Reserved for future use.
  53. #define ALC_OEM 0xFF000000 // OEM recognizer-specific.
  54. #define ALC_BOPOMOFO 0x00020000 // Bopomofo used in Taiwan (CHT traditional chinese)
  55. #define ALC_JAMO 0x00040000 // Jamos used in Korea.
  56. // Useful groupings
  57. #define ALC_ALPHA (ALC_LCALPHA | ALC_UCALPHA)
  58. #define ALC_ALPHANUMERIC (ALC_ALPHA | ALC_NUMERIC)
  59. #define ALC_KANA (ALC_HIRAGANA | ALC_KATAKANA)
  60. #define ALC_KANJI_ALL (ALC_KANJI_COMMON | ALC_KANJI_RARE)
  61. #define ALC_HANGUL_ALL (ALC_HANGUL_COMMON | ALC_HANGUL_RARE)
  62. #define ALC_EXTENDED_SYM (ALC_MATH | ALC_MONETARY | ALC_OTHER)
  63. #define ALC_SYS_MINIMUM (ALC_ALPHANUMERIC | ALC_PUNC | ALC_WHITE)
  64. #define ALC_SYS_DEFAULT (ALC_SYS_MINIMUM | ALC_COMMON_SYMBOLS)
  65. // Standard configurations for various languages.
  66. #define ALC_USA_COMMON (ALC_SYS_DEFAULT)
  67. #define ALC_USA_EXTENDED (ALC_USA_COMMON | ALC_EXTENDED_SYM)
  68. #define ALC_JPN_COMMON (ALC_SYS_DEFAULT | ALC_KANA | ALC_KANJI_COMMON)
  69. #define ALC_JPN_EXTENDED (ALC_JPN_COMMON | ALC_EXTENDED_SYM | ALC_KANJI_RARE)
  70. #define ALC_CHS_COMMON (ALC_SYS_DEFAULT | ALC_KANJI_COMMON)
  71. #define ALC_CHS_EXTENDED (ALC_CHS_COMMON | ALC_EXTENDED_SYM | ALC_KANJI_RARE)
  72. #define ALC_CHT_COMMON (ALC_SYS_DEFAULT | ALC_KANJI_COMMON)
  73. #define ALC_CHT_EXTENDED (ALC_CHT_COMMON | ALC_EXTENDED_SYM | ALC_KANJI_RARE)
  74. #define ALC_KOR_COMMON (ALC_SYS_DEFAULT | ALC_HANGUL_COMMON | ALC_JAMO)
  75. #define ALC_KOR_EXTENDED (ALC_KOR_COMMON | ALC_EXTENDED_SYM | ALC_HANGUL_RARE | ALC_KANJI_COMMON | ALC_KANJI_RARE)
  76. // Define ALC mask type.
  77. typedef LONG ALC; // Enabled Alphabet
  78. typedef ALC *PALC; // ptr to ALC
  79. // Handwriting Recognizer:
  80. DECLARE_HANDLE(HRC); // Handwriting Recognition Context
  81. typedef HRC *PHRC;
  82. // Filled in by HwxGetResults().
  83. // The rgChar array is actually a variable sized array of alternate results. The number of
  84. // alternates is passed into HwxGetResults().
  85. typedef struct tagHWXRESULTS {
  86. USHORT indxBox; // zero-based index into guide structure where char was written
  87. WCHAR rgChar[1]; // variable-sized array of characters returned
  88. } HWXRESULTS, *PHWXRESULTS;
  89. // Passed in to HwxSetGuide(). Specifies where the boxes are on the screen.
  90. // All positions are in scaled screen coordinates. You should do the scaling so
  91. // that cyWriting is around 1000. To avoid speed and rounding problems you should
  92. // use an integral multiple of your actual size.
  93. // JRB: FIXME: Check description above is correct!!!
  94. // NOTE: the current code requires that the writing area be centered. E.g. You
  95. // need to set cxBox, cxOffset and cxWriting such that:
  96. // cxBox == 2 * cxOffset + cxWriting
  97. typedef struct tagHWXGUIDE {
  98. // Number of input boxes in each direction.
  99. UINT cHorzBox;
  100. UINT cVertBox;
  101. // Upper left corner of input area.
  102. INT xOrigin;
  103. INT yOrigin;
  104. // Width and height of a single box.
  105. UINT cxBox;
  106. UINT cyBox;
  107. // Offset within a box to the upper left of the writing area.
  108. UINT cxOffset;
  109. UINT cyOffset;
  110. // Width and height of writing area.
  111. UINT cxWriting;
  112. UINT cyWriting;
  113. // Baseline and midline information for western alphabets. They are measured from
  114. // the top of the writing area. These fields are not used and must be set to zero
  115. // for the Far East languages (Japanese, Chinese, and Korean). They must be set to
  116. // the correct values for English or any other language based on Latin letters.
  117. UINT cyMid;
  118. UINT cyBase;
  119. // Writing direction
  120. UINT nDir;
  121. } HWXGUIDE, *PHWXGUIDE;
  122. // The following are the currently planned handwriting directions. Note that a given recognizer
  123. // may not support the requested direction, if this is the case, HwxSetGuide will return an error.
  124. #define HWX_HORIZONTAL 0
  125. #define HWX_BIDIRECTIONAL 1
  126. #define HWX_VERTICAL 2
  127. // For FE recognizers we would like to be able to enter partial characters and have the recognizer
  128. // attempt to 'fill in the gaps'. This is most useful for difficult or rare characters with many
  129. // strokes. The following values can be passed to HwxSetPartial
  130. #define HWX_PARTIAL_ALL 0 // The whole character must be written (default)
  131. #define HWX_PARTIAL_ORDER 1 // The stroke order does matter
  132. #define HWX_PARTIAL_FREE 2 // The stroke order doesn't matter
  133. // Called once to initialize DLL.
  134. // On failure, use GetLastError() to identify the cause of the error.
  135. BOOL WINAPI HwxConfig();
  136. // Called to create an HRC before any ink is collected. You can pass in NULL
  137. // for the parameter, but if you pass in an old HRC, it copies the old settings (such
  138. // as alphabet, guide structure, previous context, etc.)
  139. // JRB: FIXME: Make above description of what's copied clearer.
  140. // On failure, use GetLastError() to identify the cause of the error.
  141. HRC WINAPI HwxCreate(HRC);
  142. // Called to destroy an HRC after recognition is complete.
  143. // On failure, use GetLastError() to identify the cause of the error.
  144. BOOL WINAPI HwxDestroy(HRC);
  145. // Tells the HRC where the boxes on the screen are.
  146. // On failure, use GetLastError() to identify the cause of the error.
  147. BOOL WINAPI HwxSetGuide(HRC, HWXGUIDE *);
  148. // Limits the set of characters the recognizer can return. (See ALC values above.)
  149. // On failure, use GetLastError() to identify the cause of the error.
  150. BOOL WINAPI HwxALCValid(HRC, ALC);
  151. // Reorders the characters the recognizer returns so that selected characters
  152. // appear at the top of the list. (See ALC values above.)
  153. // On failure, use GetLastError() to identify the cause of the error.
  154. BOOL WINAPI HwxALCPriority(HRC, ALC);
  155. // Sets parameter for partial recognition.
  156. // On failure, use GetLastError() to identify the cause of the error.
  157. // JRB: FIXME: Need to define the legal values for second argument.
  158. BOOL WINAPI HwxSetPartial(HRC, UINT);
  159. // Sets abort address. If the number of strokes currently doesn't match the value
  160. // written at the address, the current recognition is halted. This only works for
  161. // HwxSetPartial modes HWX_PARTIAL_FRONT and HWX_PARTIAL_ANY
  162. // On failure, use GetLastError() to identify the cause of the error.
  163. BOOL WINAPI HwxSetAbort(HRC, UINT *);
  164. // Adds ink to the HRC.
  165. // Takes the HRC, the array of points, the count of points, and
  166. // the time stamp of the first mouse event in the stroke. The
  167. // time stamp should be taken directly from the MSG structure
  168. // for the mouse down event. The points should be scaled to
  169. // match the guide structure.
  170. // On failure, use GetLastError() to identify the cause of the error.
  171. BOOL WINAPI HwxInput(HRC, POINT *, UINT, DWORD);
  172. // Called after last ink is added. You cannot add anymore ink
  173. // to the HRC after this has been called.
  174. // On failure, use GetLastError() to identify the cause of the error.
  175. BOOL WINAPI HwxEndInput(HRC);
  176. // Recognizes as much ink as it can.
  177. // On failure, use GetLastError() to identify the cause of the error.
  178. BOOL WINAPI HwxProcess(HRC);
  179. // Retrieves the results from an HRC. This may be called repeatedly. This allows you
  180. // to get results for several characters at a time. The return value is the number of
  181. // characters actually returned. The results for those characters are put in the
  182. // rgBoxResults buffer that was passed in.
  183. // Returns -1 on error.
  184. // On failure, use GetLastError() to identify the cause of the error.
  185. INT WINAPI HwxGetResults(
  186. HRC hrc, // HRC containing results
  187. UINT cAlt, // number of alternates
  188. UINT iFirst, // index of first character to return
  189. UINT cBoxRes, // number of characters to return
  190. HWXRESULTS *rgBoxResults // array of cBoxRes ranked lists
  191. );
  192. // Tells the HRC what the previous character was for context purposes.
  193. // On failure, use GetLastError() to identify the cause of the error.
  194. BOOL WINAPI HwxSetContext(HRC, WCHAR);
  195. // Tells you how many results can be retrieved from HwxGetResults.
  196. // Returns -1 on error.
  197. // On failure, use GetLastError() to identify the cause of the error.
  198. INT WINAPI HwxResultsAvailable(HRC);
  199. #ifdef __cplusplus
  200. }
  201. #endif // __cplusplus
  202. // @CESYSGEN ENDIF
  203. #endif // #define _INC_RECOG