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.

446 lines
14 KiB

  1. /*************************************************
  2. * imedefs.h *
  3. * *
  4. * Copyright (C) 1999 Microsoft Inc. *
  5. * *
  6. *************************************************/
  7. // debug flag
  8. #define DEB_FATAL 0
  9. #define DEB_ERR 1
  10. #define DEB_WARNING 2
  11. #define DEB_TRACE 3
  12. #ifdef _WIN32
  13. void FAR cdecl _DebugOut(UINT, LPCSTR, ...);
  14. #endif
  15. #define NATIVE_CHARSET ANSI_CHARSET
  16. #define NATIVE_LANGUAGE 0x0409
  17. #ifdef UNICODE
  18. #define NATIVE_CP 1200
  19. #define ALT_NATIVE_CP 938
  20. #define MAX_EUDC_CHARS 6217
  21. #else
  22. #define NATIVE_CP 950
  23. #define ALT_NATIVE_CP 938
  24. #define MAX_EUDC_CHARS 5809
  25. #endif
  26. #define SIGN_CWIN 0x4E495743
  27. #define SIGN__TBL 0x4C42545F
  28. // table load status
  29. #define TBL_NOTLOADED 0
  30. #define TBL_LOADED 1
  31. #define TBL_LOADERR 2
  32. // error MessageBox flags
  33. #define ERRMSG_LOAD_0 0x0010
  34. #define ERRMSG_LOAD_1 0x0020
  35. #define ERRMSG_LOAD_2 0x0040
  36. #define ERRMSG_LOAD_3 0x0080
  37. #define ERRMSG_LOAD_USRDIC 0x0400
  38. #define ERRMSG_MEM_0 0x1000
  39. #define ERRMSG_MEM_1 0x2000
  40. #define ERRMSG_MEM_2 0x4000
  41. #define ERRMSG_MEM_3 0x8000
  42. #define ERRMSG_MEM_USRDIC 0x00040000
  43. // hack flag, I borrow one bit from fdwErrMsg for reverse conversion
  44. #define NO_REV_LENGTH 0x80000000
  45. // state of composition
  46. #define CST_INIT 0
  47. #define CST_INPUT 1
  48. #define CST_CHOOSE 2
  49. #define CST_SYMBOL 3
  50. #define CST_ALPHABET 4 // not in iImeState
  51. #define CST_ALPHANUMERIC 6 // not in iImeState
  52. #define CST_INVALID 7 // not in iImeState
  53. #define CST_BLOCKINPUT 8 // not in iImeState
  54. #define CST_IME_HOTKEYS 0x40 // not in iImeState
  55. #define CST_RESEND_RESULT (CST_IME_HOTKEYS)
  56. #define CST_PREVIOUS_COMP (CST_IME_HOTKEYS+1)
  57. #define CST_TOGGLE_UI (CST_IME_HOTKEYS+2)
  58. // IME specific constants
  59. #define CANDPERPAGE 9
  60. #define CHOOSE_PREVPAGE 0x10
  61. #define CHOOSE_NEXTPAGE 0x11
  62. #define CHOOSE_CIRCLE 0x12
  63. #define CHOOSE_HOME 0x13
  64. #define MAXSTRLEN 32
  65. #define MAXCAND 256
  66. #define CAND_PROMPT_PHRASE 0
  67. #define CAND_PROMPT_QUICK_VIEW 1
  68. #define CAND_PROMPT_NORMAL 2
  69. // max composition ways of one big5 code, it is for reverse conversion
  70. #if defined(ROMANIME)
  71. #define MAX_COMP 0
  72. #elif defined(WINIME)
  73. #define MAX_COMP 1
  74. #else
  75. #define MAX_COMP 10
  76. #endif
  77. #define MAX_COMP_BUF 10
  78. // border for UI
  79. #define UI_MARGIN 4
  80. #define STATUS_DIM_X 24
  81. #define STATUS_DIM_Y 24
  82. #define CAND_PROMPT_DIM_X 80
  83. #define CAND_PROMPT_DIM_Y 16
  84. #define PAGE_DIM_X 16
  85. #define PAGE_DIM_Y CAND_PROMPT_DIM_Y
  86. // if UI_MOVE_OFFSET == WINDOW_NOTDRAG, not in drag operation
  87. #define WINDOW_NOT_DRAG 0xFFFFFFFF
  88. // window extra for composition window
  89. #define UI_MOVE_OFFSET 0
  90. #define UI_MOVE_XY 4
  91. // window extra for context menu owner
  92. #define CMENU_HUIWND 0
  93. #define CMENU_MENU 4
  94. #define WM_USER_DESTROY (WM_USER + 0x0400)
  95. #define WM_USER_UICHANGE (WM_USER + 0x0401)
  96. // the flags for GetNearCaretPosition
  97. #define NEAR_CARET_FIRST_TIME 0x0001
  98. #define NEAR_CARET_CANDIDATE 0x0002
  99. // the flag for an opened or start UI
  100. #define IMN_PRIVATE_TOGGLE_UI 0x0001
  101. #define IMN_PRIVATE_CMENUDESTROYED 0x0002
  102. #define IMN_PRIVATE_COMPOSITION_SIZE 0x0003
  103. #define IMN_PRIVATE_UPDATE_PREDICT 0x0004
  104. #define IMN_PRIVATE_UPDATE_SOFTKBD 0x0006
  105. #define IMN_PRIVATE_PAGEUP 0x0007
  106. #define MSG_COMPOSITION 0x0000001
  107. #define MSG_START_COMPOSITION 0x0000002
  108. #define MSG_END_COMPOSITION 0x0000004
  109. #define MSG_ALREADY_START 0x0000008
  110. #define MSG_CHANGE_CANDIDATE 0x0000010
  111. #define MSG_OPEN_CANDIDATE 0x0000020
  112. #define MSG_CLOSE_CANDIDATE 0x0000040
  113. #define MSG_ALREADY_OPEN 0x0000080
  114. #define MSG_GUIDELINE 0x0000100
  115. #define MSG_IMN_COMPOSITIONPOS 0x0000200
  116. #define MSG_IMN_COMPOSITIONSIZE 0x0000400
  117. #define MSG_IMN_UPDATE_PREDICT 0x0000800
  118. #define MSG_IMN_UPDATE_SOFTKBD 0x0002000
  119. #define MSG_ALREADY_SOFTKBD 0x0004000
  120. #define MSG_IMN_PAGEUP 0x0008000
  121. // original reserve for old array, now we switch to new, no one use yet
  122. #define MSG_CHANGE_CANDIDATE2 0x1000000
  123. #define MSG_OPEN_CANDIDATE2 0x2000000
  124. #define MSG_CLOSE_CANDIDATE2 0x4000000
  125. #define MSG_ALREADY_OPEN2 0x8000000
  126. #define MSG_STATIC_STATE (MSG_ALREADY_START|MSG_ALREADY_OPEN|MSG_ALREADY_SOFTKBD|MSG_ALREADY_OPEN2)
  127. #define MSG_IMN_TOGGLE_UI 0x0400000
  128. #define MSG_IN_IMETOASCIIEX 0x0800000
  129. #define ISC_HIDE_COMP_WINDOW 0x00400000
  130. #define ISC_HIDE_CAND_WINDOW 0x00800000
  131. #define ISC_HIDE_SOFTKBD 0x01000000
  132. #define ISC_LAZY_OPERATION (ISC_HIDE_COMP_WINDOW|ISC_HIDE_CAND_WINDOW|ISC_HIDE_SOFTKBD)
  133. #define ISC_SHOW_SOFTKBD 0x02000000
  134. #define ISC_OPEN_STATUS_WINDOW 0x04000000
  135. #define ISC_OFF_CARET_UI 0x08000000
  136. #define ISC_SHOW_PRIV_UI (ISC_SHOW_SOFTKBD|ISC_OPEN_STATUS_WINDOW|ISC_OFF_CARET_UI)
  137. #define ISC_SHOW_UI_ALL (ISC_SHOWUIALL|ISC_SHOW_SOFTKBD|ISC_OPEN_STATUS_WINDOW)
  138. #define ISC_SETCONTEXT_UI (ISC_SHOWUIALL|ISC_SHOW_SOFTKBD)
  139. #if (ISC_SHOWUIALL & (ISC_LAZY_OPERATION|ISC_SHOW_PRIV_UI))
  140. #error bit confliction
  141. #endif
  142. // the virtual key value
  143. #define VK_OEM_SEMICLN 0xba // ; :
  144. #define VK_OEM_EQUAL 0xbb // = +
  145. #define VK_OEM_COMMA 0xBC // , <
  146. #define VK_OEM_MINUS 0xBD // - _
  147. #define VK_OEM_PERIOD 0xBE // . >
  148. #define VK_OEM_SLASH 0xBF // / ?
  149. #define VK_OEM_3 0xC0 // ` ~
  150. #define VK_OEM_LBRACKET 0xdb // [ {
  151. #define VK_OEM_BSLASH 0xdc // \ |
  152. #define VK_OEM_RBRACKET 0xdd // ] }
  153. #define VK_OEM_QUOTE 0xde // ' "
  154. typedef DWORD UNALIGNED FAR *LPUNADWORD;
  155. typedef WORD UNALIGNED FAR *LPUNAWORD;
  156. typedef WCHAR UNALIGNED *LPUNAWSTR;
  157. #define NFULLABC 95
  158. typedef struct tagFullABC {
  159. WORD wFullABC[NFULLABC];
  160. } FULLABC;
  161. typedef FULLABC *PFULLABC;
  162. typedef FULLABC NEAR *NPFULLABC;
  163. typedef FULLABC FAR *LPFULLABC;
  164. #define NSYMBOL 0x40
  165. typedef struct tagSymbol {
  166. WORD wSymbol[NSYMBOL];
  167. } SYMBOL;
  168. typedef SYMBOL *PSYMBOL;
  169. typedef SYMBOL NEAR *NPSYMBOL;
  170. typedef SYMBOL FAR *LPSYMBOL;
  171. #define NUM_OF_IME_HOTKEYS 3
  172. #define MAX_NAME_LENGTH 32
  173. typedef struct tagImeG { // global structure, can be shared by all
  174. // IMEs, the seperation (IMEL and IMEG) is
  175. // only useful in UNI-IME, other IME can use
  176. // one data structure
  177. RECT rcWorkArea; // the work area of applications
  178. // full shape space (reversed internal code)
  179. WORD wFullSpace;
  180. // full shape chars (internal code)
  181. WORD wFullABC[NFULLABC];
  182. UINT uAnsiCodePage;
  183. // the system charset is not NATIVE_CHARSET
  184. BOOL fDiffSysCharSet;
  185. // Chinese char width & height
  186. int xChiCharWi;
  187. int yChiCharHi;
  188. // symbol chars (internal code)
  189. WORD wSymbol[NSYMBOL];
  190. // setting of UI
  191. int iPara;
  192. int iPerp;
  193. int iParaTol;
  194. int iPerpTol;
  195. } IMEG;
  196. typedef IMEG *PIMEG;
  197. typedef IMEG NEAR *NPIMEG;
  198. typedef IMEG FAR *LPIMEG;
  199. typedef struct tagPRIVCONTEXT { // IME private data for each context
  200. BOOL fdwImeMsg; // what messages should be generated
  201. DWORD dwCompChar; // wParam of WM_IME_COMPOSITION
  202. DWORD fdwGcsFlag; // lParam for WM_IME_COMPOSITION
  203. DWORD fdwInit; // position init
  204. int iImeState; // the composition state - input, choose, or
  205. // input data
  206. BYTE bSeq[8]; // sequence code of input char
  207. DWORD dwPattern;
  208. int iInputEnd;
  209. // the previous dwPageStart before page up
  210. DWORD dwPrevPageStart;
  211. } PRIVCONTEXT;
  212. typedef PRIVCONTEXT *PPRIVCONTEXT;
  213. typedef PRIVCONTEXT NEAR *NPPRIVCONTEXT;
  214. typedef PRIVCONTEXT FAR *LPPRIVCONTEXT;
  215. typedef struct tagUIPRIV { // IME private UI data
  216. HWND hCompWnd; // composition window
  217. int nShowCompCmd;
  218. HWND hCandWnd; // candidate window for composition
  219. int nShowCandCmd;
  220. HWND hSoftKbdWnd; // soft keyboard window
  221. int nShowSoftKbdCmd;
  222. HWND hStatusWnd; // status window
  223. int nShowStatusCmd;
  224. DWORD fdwSetContext; // the actions to take at set context time
  225. HIMC hCacheIMC; // the recent selected hIMC
  226. HWND hCMenuWnd; // a window owner for context menu
  227. } UIPRIV;
  228. typedef UIPRIV *PUIPRIV;
  229. typedef UIPRIV NEAR *NPUIPRIV;
  230. typedef UIPRIV FAR *LPUIPRIV;
  231. typedef struct tagNEARCARET { // for near caret offset calculatation
  232. int iLogFontFacX;
  233. int iLogFontFacY;
  234. int iParaFacX;
  235. int iPerpFacX;
  236. int iParaFacY;
  237. int iPerpFacY;
  238. } NEARCARET;
  239. typedef NEARCARET *PNEARCARET;
  240. typedef NEARCARET NEAR *NPNEARCARET;
  241. typedef NEARCARET FAR *LPNEARCARET;
  242. #ifndef RC_INVOKED
  243. #pragma pack(1)
  244. #endif
  245. typedef struct tagMETHODNAME {
  246. BYTE achMethodName[6];
  247. } METHODNAME;
  248. typedef METHODNAME *PMETHODNAME;
  249. typedef METHODNAME NEAR *NPMETHODNAME;
  250. typedef METHODNAME FAR *LPMETHODNAME;
  251. #ifndef RC_INVOKED
  252. #pragma pack()
  253. #endif
  254. extern HINSTANCE hInst;
  255. extern IMEG sImeG;
  256. extern int iDx[3 * CANDPERPAGE];
  257. extern const TCHAR szDigit[];
  258. extern const BYTE bUpper[];
  259. extern const WORD fMask[];
  260. extern const TCHAR szRegNearCaret[];
  261. extern const TCHAR szPhraseDic[];
  262. extern const TCHAR szPhrasePtr[];
  263. extern const TCHAR szPerp[];
  264. extern const TCHAR szPara[];
  265. extern const TCHAR szPerpTol[];
  266. extern const TCHAR szParaTol[];
  267. extern const NEARCARET ncUIEsc[], ncAltUIEsc[];
  268. extern const POINT ptInputEsc[], ptAltInputEsc[];
  269. extern const TCHAR szRegRevKL[];
  270. extern const TCHAR szRegUserDic[];
  271. extern const TCHAR szRegAppUser[];
  272. extern const TCHAR szRegModeConfig[];
  273. extern const BYTE bChar2VirtKey[];
  274. int WINAPI LibMain(HANDLE, WORD, WORD, LPSTR); // init.c
  275. void PASCAL InitImeUIData(LPIMEL); // init.c
  276. void PASCAL SetCompLocalData(LPIMEL); // init.c
  277. void PASCAL SetUserSetting(
  278. LPCTSTR, DWORD, LPBYTE, DWORD); // init.c
  279. void PASCAL AddCodeIntoCand(LPCANDIDATELIST, UINT); // compose.c
  280. void PASCAL CompWord(
  281. WORD, HIMC, LPINPUTCONTEXT, LPCOMPOSITIONSTRING,
  282. LPGUIDELINE, LPPRIVCONTEXT); // compose.c
  283. UINT PASCAL Finalize(
  284. HIMC, LPINPUTCONTEXT, LPCOMPOSITIONSTRING,
  285. LPPRIVCONTEXT, BOOL); // compose.c
  286. void PASCAL CompEscapeKey(LPINPUTCONTEXT, LPCOMPOSITIONSTRING,
  287. LPPRIVCONTEXT); // compose.c
  288. void PASCAL InitCompStr(LPCOMPOSITIONSTRING); // ddis.c
  289. BOOL PASCAL ClearCand(LPINPUTCONTEXT); // ddis.c
  290. BOOL PASCAL Select(
  291. LPINPUTCONTEXT, BOOL); // ddis.c
  292. UINT PASCAL TranslateImeMessage(LPTRANSMSGLIST, LPINPUTCONTEXT,
  293. LPPRIVCONTEXT); // toascii.c
  294. void PASCAL GenerateMessage(HIMC, LPINPUTCONTEXT,
  295. LPPRIVCONTEXT); // notify.c
  296. void PASCAL CompCancel(HIMC, LPINPUTCONTEXT); // notify.c
  297. BOOL PASCAL LoadTable(LPINSTDATAL, LPIMEL); // dic.c
  298. void PASCAL FreeTable(LPINSTDATAL); // dic.c
  299. void PASCAL SearchTbl(
  300. UINT, LPCANDIDATELIST, LPPRIVCONTEXT); // search.c
  301. void PASCAL DrawDragBorder(HWND, LONG, LONG); // uisubs.c
  302. void PASCAL DrawFrameBorder(HDC, HWND); // uisubs.c
  303. HWND PASCAL GetCompWnd(HWND); // compui.c
  304. void PASCAL GetNearCaretPosition(
  305. LPPOINT, UINT, UINT, LPPOINT, LPPOINT, BOOL); // compui.c
  306. BOOL PASCAL AdjustCompPosition(
  307. LPINPUTCONTEXT, LPPOINT, LPPOINT); // compui.c
  308. void PASCAL SetCompPosition(
  309. HWND, LPINPUTCONTEXT); // compui.c
  310. void PASCAL SetCompWindow(
  311. HWND); // compui.c
  312. void PASCAL MoveDefaultCompPosition(
  313. HWND); // compui.c
  314. void PASCAL ShowComp(
  315. HWND, int); // compui.c
  316. void PASCAL CreateCompWindow(HWND); // compui.c
  317. void PASCAL ChangeCompositionSize(
  318. HWND); // compui.c
  319. void PASCAL SelectOneCand(
  320. HIMC, LPINPUTCONTEXT, LPCOMPOSITIONSTRING,
  321. LPPRIVCONTEXT, LPCANDIDATELIST);
  322. LRESULT CALLBACK UIWndProc(HWND, UINT, WPARAM, LPARAM); // ui.c
  323. LRESULT CALLBACK CompWndProc(HWND, UINT, WPARAM, LPARAM); // compui.c