freepy.h
上传用户:shdz666
上传日期:2007-01-03
资源大小:566k
文件大小:7k
源码类别:

输入法编程

开发平台:

Visual C++

  1. /*
  2.  * Copyright (C) 1999.4  Li ZhenChun
  3.  *
  4.  * This program is free software; you can redistribute it and/or modify
  5.  * it under the terms of the GNU General Public License as published by
  6.  * the Free Software Foundation; either version 2 of the License; or
  7.  * (at your option) any later version.
  8.  *
  9.  * This program is distributed in the hope that is will be useful, but
  10.  * WITHOUT ANY WARRANTY; without even the implied warranty of 
  11.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12.  * General Public License for more details.
  13.  *
  14.  * You should have received a copy of the GNU General Public License
  15.  * along with this program; if not, write to the Free Software
  16.  * Foundation, Inc., 675 Mass Ave, Cambridge, M A 02139, USA.
  17.  *
  18.  * Author: Li ZhenChun  email: zhchli@163.net or zhchli@126.com
  19.  * 
  20.  */
  21. #ifndef _FREEPY_H_
  22. #define _FREEPY_H_
  23. #include <tchar.h>
  24. #include <windows.h>
  25. #include <stdio.h>
  26. #include "imm.h"
  27. #include "indicml.h"
  28. #include "vksub.h"
  29. #include "HZfreepy.h"
  30. #include "resource.h"
  31. /**********************************************************************/
  32. /*                                                                    */
  33. /*      Define                                                        */
  34. /*                                                                    */
  35. /**********************************************************************/
  36. #define GB_QUFIRST  0xA1
  37. #define GB_QULAST   0xF7
  38. #define GB_WEIFIRST 0xA1
  39. #define GB_WEILAST  0xFE
  40. #define PHTOCHMODEL      _T("词定字模式:")
  41. #define IMODEL           _T("i模式:")
  42. #define UMODEL           _T("u模式:")
  43. #define VMODEL           _T("v模式:")
  44. #define ATOMTIP          _T("自由拼音")
  45. #define FREEPYFILENAME   _T("freepy.ime")
  46. #define UICLASSNAME      _T("FREEPYUI")
  47. #define COMPCLASSNAME    _T("FREEPYCOMP")
  48. #define CANDCLASSNAME    _T("FREEPYCAND")
  49. #define STATUSCLASSNAME  _T("FREEPYSTATUS")
  50. #define EDIT_ADD         1
  51. #define EDIT_BACK        2
  52. #define EDIT_DELETE      3
  53. /* Conversion Mode */
  54. #define CONVERSION_SET_PUNCT        0x01
  55. #define CONVERSION_SET_FULLSHAPE    0x02
  56. #define CONVERSION_SET_SORT         0x0100
  57. #define CONVERSION_SET_FUZZYC       0x0200
  58. #define CONVERSION_SET_FUZZYN       0x0400
  59. #define CONVERSION_SET_FUZZYH       0x0800
  60. #define CONVERSION_SET_FUZZYB       0x1000
  61. #define CONVERSION_SET_FOLLOW       0x2000
  62. #define CONVERSION_SET_GBK          0x4000
  63. #define CONVERSION_SET_SHAPE        0x8000
  64. #define CONVERSION_MODE_PHRASETOCHAR 0x01
  65. #define CONVERSION_MODE_I            0x02
  66. #define CONVERSION_MODE_U            0x04
  67. #define CONVERSION_MODE_V            0x08
  68. /* The flags of FIGWL_MOUSE */
  69. #define FIM_CAPUTURED 0x01
  70. #define FIM_MOVED     0x02
  71. /* special messages */
  72. #define WM_UI_COMPMOVE (WM_USER+601)
  73. /* WndExtra of child UI windows */
  74. #define FIGWL_MOUSE         4
  75. #define FIGWL_SVRWND        8
  76. #define UICHILDEXTRASIZE    12
  77. /* define GET LP for COMPOSITIONSTRING members. */
  78. #define GETLPCOMPSTR(lpcs) (LPTSTR)((LPBYTE)(lpcs) + (lpcs)->dwCompStrOffset)
  79. #define GETLPRESULTSTR(lpcs) (LPTSTR)((LPBYTE)(lpcs) + (lpcs)->dwResultStrOffset)
  80. #define GETLPCANDSTR(lpcs,i) (LPTSTR)((LPBYTE)(lpcs) + (lpcs)->dwOffset[i])
  81. /**********************************************************************/
  82. /*                                                                    */
  83. /*      Externs                                                       */
  84. /*                                                                    */
  85. /**********************************************************************/
  86. #ifndef _NO_EXTERN_
  87. extern HINSTANCE  hInst;
  88. extern HKL        hFreePYKL;
  89. extern LPDWORD    lpdwCurTransKey;
  90. extern UINT       uNumTransKey;
  91. extern BOOL       fOverTransKey;
  92. extern WORD       wConversionMode;
  93. extern WORD       wConversionSet;
  94. extern SIZE       sizeCand[2];
  95. extern BYTE bComp[];
  96. extern BYTE bNoComp[];
  97. #endif //_NO_EXTERN_
  98. /**********************************************************************/
  99. /*                                                                    */
  100. /*      Structures                                                    */
  101. /*                                                                    */
  102. /**********************************************************************/
  103. typedef struct _tagMYCOMPSTR{
  104.     COMPOSITIONSTRING cs;
  105.     TCHAR             szCompStr[MAXCOMPSIZE];
  106.     TCHAR             szResultStr[MAXCOMPSIZE];
  107. FREEPYCOMP        FreePYComp;
  108. } MYCOMPSTR, NEAR *PMYCOMPSTR, FAR *LPMYCOMPSTR;
  109. typedef struct _tagMYCAND{
  110.     CANDIDATEINFO  ci;
  111.     CANDIDATELIST  cl;
  112.     DWORD          offset[MAXCANDSTRNUM];
  113.     TCHAR          szCandStr[MAXCANDSTRNUM][MAXCANDSTRSIZE];
  114. FREEPYCAND     FreePYCand;
  115. } MYCAND, NEAR *PMYCAND, FAR *LPMYCAND;
  116. typedef struct _tagUICHILD{
  117.     HWND    hWnd;
  118. POINT   pt;
  119. SIZE    sz;
  120. } UICHILD, NEAR *PUICHILD, FAR *LPUICHILD;
  121. typedef struct _tagUIEXTRA{
  122.     UICHILD  uiStatus;
  123.     UICHILD  uiCand;
  124. UICHILD  uiComp;
  125. } UIEXTRA, NEAR *PUIEXTRA, FAR *LPUIEXTRA;
  126. typedef struct _tagGENEMSG{
  127.     UINT msg;
  128.     WPARAM wParam;
  129.     LPARAM lParam;
  130. } GENEMSG, NEAR *PGENEMSG, FAR *LPGENEMSG;
  131. /**********************************************************************/
  132. /*                                                                    */
  133. /*      Functions                                                     */
  134. /*                                                                    */
  135. /**********************************************************************/
  136. //freepy.c
  137. BOOL WINAPI DllMain (HINSTANCE,DWORD,LPVOID);
  138. BOOL IMERegisterClass( HANDLE);
  139. LRESULT WINAPI UIWndProc(HWND,UINT,WPARAM,LPARAM);
  140. LONG NotifyHandle(HIMC, HWND, UINT, WPARAM, LPARAM);
  141. LONG ControlHandle(HIMC , HWND , UINT , WPARAM , LPARAM );
  142. //handle.c
  143. BOOL IMEKeyupHandler( HIMC,WPARAM,LPARAM,LPBYTE);
  144. BOOL IMEKeydownHandler( HIMC,WPARAM,LPARAM,LPBYTE);
  145. BOOL KeydownHandler( HIMC,WORD,LONG,LPBYTE);
  146. BOOL CharHandler( HIMC,WORD,LONG);
  147. //subs.c
  148. BOOL IsCompStr(HIMC);
  149. void InitCompStr(LPCOMPOSITIONSTRING);
  150. void ClearCompStr(LPCOMPOSITIONSTRING);
  151. BOOL IsCandidate(HIMC);
  152. void InitCandInfo(LPCANDIDATEINFO);
  153. void ClearCandidate(LPCANDIDATEINFO);
  154. HKL GetMyHKL();
  155. void UpdateIndicIcon(HIMC);
  156. BOOL MyIsIMEMessage(UINT);
  157. BOOL MakeResultString( HIMC,BOOL);
  158. BOOL GenerateMessage(HIMC, LPDWORD,LPGENEMSG);
  159. BOOL GenerateMessageToTransKey(LPDWORD,LPGENEMSG);
  160. void DrawUIBorder( LPRECT );
  161. void DragUI( HWND ,HWND, UINT , WPARAM , LPARAM,BOOL);
  162. void SelectCandFromCandlist( HIMC, WORD );
  163. void DeleteCharBackward(HIMC,WORD);
  164. void DeleteCharForward(HIMC,WORD);
  165. void SpaceSelect(HIMC,WORD);
  166. void SetPaintColor(HDC , WORD);
  167. void SelectForwardFromCand(HIMC,LPCANDIDATELIST);
  168. void SelectBackwardFromCand(HIMC,LPCANDIDATELIST);
  169. BOOL WINAPI ConfigDialogProc(HWND ,UINT,WPARAM,LPARAM);
  170. //uicand.c
  171. LRESULT WINAPI CandWndProc(HWND,UINT,WPARAM,LPARAM);
  172. void CreateCandWindow( HWND ,LPUIEXTRA );
  173. void MoveCandWindow(HWND , LPUIEXTRA , LPINPUTCONTEXT);
  174. void PaintCandWindow( HWND);
  175. void HideCandWindow( LPUIEXTRA );
  176. //uicomp.c
  177. LRESULT WINAPI CompWndProc(HWND,UINT,WPARAM,LPARAM);
  178. void CreateCompWindow( HWND, LPUIEXTRA);
  179. void MoveCompWindow( HWND,LPUIEXTRA ,LPINPUTCONTEXT);
  180. void PaintCompWindow( HWND );
  181. void HideCompWindow(LPUIEXTRA);
  182. //uistatus.c
  183. LRESULT WINAPI StatusWndProc(HWND,UINT,WPARAM,LPARAM);
  184. void UpdateStatusWindow(LPUIEXTRA );
  185. void CreateStatusWindow( HWND , LPUIEXTRA );
  186. #endif /* _FREEPY_H_ */