Leaked source code of windows server 2003
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.

247 lines
10 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. * HwxSetAlphabet
  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)
  49. #define ALC_KANJI_RARE 0x00004000 // Common Kanji (JPN)
  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 0x00FE0000 // Reserved for future use.
  53. #define ALC_OEM 0xFF000000 // OEM recognizer-specific.
  54. // Useful groupings
  55. #define ALC_ALPHA (ALC_LCALPHA | ALC_UCALPHA)
  56. #define ALC_ALPHANUMERIC (ALC_ALPHA | ALC_NUMERIC)
  57. #define ALC_KANA (ALC_HIRAGANA | ALC_KATAKANA)
  58. #define ALC_KANJI_ALL (ALC_KANJI_COMMON | ALC_KANJI_RARE)
  59. #define ALC_HANGUL_ALL (ALC_HANGUL_COMMON | ALC_HANGUL_RARE)
  60. #define ALC_EXTENDED_SYM (ALC_MATH | ALC_MONETARY | ALC_OTHER)
  61. #define ALC_SYS_MINIMUM (ALC_ALPHANUMERIC | ALC_PUNC | ALC_WHITE)
  62. #define ALC_SYS_DEFAULT (ALC_SYS_MINIMUM | ALC_COMMON_SYMBOLS)
  63. // Standard configurations for various languages.
  64. #define ALC_USA_COMMON (ALC_SYS_DEFAULT)
  65. #define ALC_USA_EXTENDED (ALC_USA_COMMON | ALC_EXTENDED_SYM)
  66. #define ALC_JPN_COMMON (ALC_SYS_DEFAULT | ALC_KANA | ALC_KANJI_COMMON)
  67. #define ALC_JPN_EXTENDED (ALC_JPN_COMMON | ALC_EXTENDED_SYM | ALC_KANJI_RARE)
  68. #define ALC_CHS_COMMON (ALC_SYS_DEFAULT | ALC_KANJI_COMMON)
  69. #define ALC_CHS_EXTENDED (ALC_CHS_COMMON | ALC_EXTENDED_SYM | ALC_KANJI_RARE)
  70. #define ALC_CHT_COMMON (ALC_SYS_DEFAULT | ALC_KANJI_COMMON)
  71. #define ALC_CHT_EXTENDED (ALC_CHT_COMMON | ALC_EXTENDED_SYM | ALC_KANJI_RARE)
  72. #define ALC_KOR_COMMON (ALC_SYS_DEFAULT | ALC_HANGUL_COMMON | ALC_KANJI_COMMON)
  73. #define ALC_KOR_EXTENDED (ALC_KOR_COMMON | ALC_EXTENDED_SYM | ALC_HANGUL_RARE | ALC_KANJI_RARE)
  74. // Define ALC mask type.
  75. typedef LONG ALC; // Enabled Alphabet
  76. typedef ALC *PALC; // ptr to ALC
  77. // Handwriting Recognizer:
  78. DECLARE_HANDLE(HRC); // Handwriting Recognition Context
  79. typedef HRC *PHRC;
  80. // Filled in by HwxGetResults().
  81. // The rgChar array is actually a variable sized array of alternate results. The number of
  82. // alternates is passed into HwxGetResults().
  83. typedef struct tagHWXRESULTS {
  84. USHORT indxBox; // zero-based index into guide structure where char was written
  85. WCHAR rgChar[1]; // variable-sized array of characters returned
  86. } HWXRESULTS, *PHWXRESULTS;
  87. // Passed in to HwxSetGuide(). Specifies where the boxes are on the screen.
  88. // All positions are in scaled screen coordinates. You should do the scaling so
  89. // that cyWriting is around 1000. To avoid speed and rounding problems you should
  90. // use an integral multiple of your actual size.
  91. // JRB: FIXME: Check description above is correct!!!
  92. // NOTE: the current code requires that the writing area be centered. E.g. You
  93. // need to set cxBox, cxOffset and cxWriting such that:
  94. // cxBox == 2 * cxOffset + cxWriting
  95. typedef struct tagHWXGUIDE {
  96. // Number of input boxes in each direction.
  97. UINT cHorzBox;
  98. UINT cVertBox;
  99. // Upper left corner of input area.
  100. INT xOrigin;
  101. INT yOrigin;
  102. // Width and height of a single box.
  103. UINT cxBox;
  104. UINT cyBox;
  105. // Offset within a box to the upper left of the writing area.
  106. UINT cxOffset;
  107. UINT cyOffset;
  108. // Width and height of writing area.
  109. UINT cxWriting;
  110. UINT cyWriting;
  111. // Baseline and midline information for western alphabets. They are measured from
  112. // the top of the writing area. These fields are not used and must be set to zero
  113. // for the Far East languages (Japanese, Chinese, and Korean). They must be set to
  114. // the correct values for English or any other language based on Latin letters.
  115. UINT cyMid;
  116. UINT cyBase;
  117. // Writing direction
  118. UINT nDir;
  119. } HWXGUIDE, *PHWXGUIDE;
  120. // The following are the currently planned handwriting directions. Note that a given recognizer
  121. // may not support the requested direction, if this is the case, HwxSetGuide will return an error.
  122. #define HWX_HORIZONTAL 0
  123. #define HWX_BIDIRECTIONAL 1
  124. #define HWX_VERTICAL 2
  125. // For FE recognizers we would like to be able to enter partial characters and have the recognizer
  126. // attempt to 'fill in the gaps'. This is most useful for difficult or rare characters with many
  127. // strokes. The following values can be passed to HwxSetPartial
  128. #define HWX_PARTIAL_ALL 0 // The whole character must be written (default)
  129. #define HWX_PARTIAL_ORDER 1 // The stroke order does matter
  130. #define HWX_PARTIAL_FREE 2 // The stroke order doesn't matter
  131. // Called once to initialize DLL.
  132. // On failure, use GetLastError() to identify the cause of the error.
  133. BOOL WINAPI HwxConfig();
  134. // Called to create an HRC before any ink is collected. You can pass in NULL
  135. // for the parameter, but if you pass in an old HRC, it copies the old settings (such
  136. // as alphabet, guide structure, previous context, etc.)
  137. // JRB: FIXME: Make above description of what's copied clearer.
  138. // On failure, use GetLastError() to identify the cause of the error.
  139. HRC WINAPI HwxCreate(HRC);
  140. // Called to destroy an HRC after recognition is complete.
  141. // On failure, use GetLastError() to identify the cause of the error.
  142. BOOL WINAPI HwxDestroy(HRC);
  143. // Tells the HRC where the boxes on the screen are.
  144. // On failure, use GetLastError() to identify the cause of the error.
  145. BOOL WINAPI HwxSetGuide(HRC, HWXGUIDE *);
  146. // Limits the set of characters the recognizer can return. (See ALC values above.)
  147. // On failure, use GetLastError() to identify the cause of the error.
  148. BOOL WINAPI HwxALCValid(HRC, ALC);
  149. // Reorders the characters the recognizer returns so that selected characters
  150. // appear at the top of the list. (See ALC values above.)
  151. // On failure, use GetLastError() to identify the cause of the error.
  152. BOOL WINAPI HwxALCPriority(HRC, ALC);
  153. // Sets parameter for partial recognition.
  154. // On failure, use GetLastError() to identify the cause of the error.
  155. // JRB: FIXME: Need to define the legal values for second argument.
  156. BOOL WINAPI HwxSetPartial(HRC, UINT);
  157. // Sets abort address. If the number of strokes currently doesn't match the value
  158. // written at the address, the current recognition is halted. This only works for
  159. // HwxSetPartial modes HWX_PARTIAL_FRONT and HWX_PARTIAL_ANY
  160. // On failure, use GetLastError() to identify the cause of the error.
  161. BOOL WINAPI HwxSetAbort(HRC, UINT *);
  162. // Adds ink to the HRC.
  163. // Takes the HRC, the array of points, the count of points, and
  164. // the time stamp of the first mouse event in the stroke. The
  165. // time stamp should be taken directly from the MSG structure
  166. // for the mouse down event. The points should be scaled to
  167. // match the guide structure.
  168. // On failure, use GetLastError() to identify the cause of the error.
  169. BOOL WINAPI HwxInput(HRC, POINT *, UINT, DWORD);
  170. // Called after last ink is added. You cannot add anymore ink
  171. // to the HRC after this has been called.
  172. // On failure, use GetLastError() to identify the cause of the error.
  173. BOOL WINAPI HwxEndInput(HRC);
  174. // Recognizes as much ink as it can.
  175. // On failure, use GetLastError() to identify the cause of the error.
  176. BOOL WINAPI HwxProcess(HRC);
  177. // Retrieves the results from an HRC. This may be called repeatedly. This allows you
  178. // to get results for several characters at a time. The return value is the number of
  179. // characters actually returned. The results for those characters are put in the
  180. // rgBoxResults buffer that was passed in.
  181. // Returns -1 on error.
  182. // On failure, use GetLastError() to identify the cause of the error.
  183. INT WINAPI HwxGetResults(
  184. HRC hrc, // HRC containing results
  185. UINT cAlt, // number of alternates
  186. UINT iFirst, // index of first character to return
  187. UINT cBoxRes, // number of characters to return
  188. HWXRESULTS *rgBoxResults // array of cBoxRes ranked lists
  189. );
  190. // Tells the HRC what the previous character was for context purposes.
  191. // On failure, use GetLastError() to identify the cause of the error.
  192. BOOL WINAPI HwxSetContext(HRC, WCHAR);
  193. // Tells you how many results can be retrieved from HwxGetResults.
  194. // Returns -1 on error.
  195. // On failure, use GetLastError() to identify the cause of the error.
  196. INT WINAPI HwxResultsAvailable(HRC);
  197. #ifdef __cplusplus
  198. }
  199. #endif // __cplusplus
  200. // @CESYSGEN ENDIF
  201. #endif // #define _INC_RECOG