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.

201 lines
5.7 KiB

  1. /****************************************************************************
  2. GDATA.J
  3. Owner: cslim
  4. Copyright (c) 1997-1999 Microsoft Corporation
  5. Instance data and Shared memory data management functions
  6. History:
  7. 14-JUL-1999 cslim Copied from IME98 source tree
  8. *****************************************************************************/
  9. #if !defined (_GDATA_H__INCLUDED_)
  10. #define _GDATA_H__INCLUDED_
  11. #include "ui.h"
  12. class CIMEData;
  13. PUBLIC BOOL InitSharedData();
  14. VOID InitImeData(CIMEData& ImeData);
  15. PUBLIC BOOL CloseSharedMemory();
  16. #define IMEDATA_MAGIC_NUMBER 0x12345678 // This will repesent whether IMEDATA initialized or not
  17. // Type of IME Hangul keyboard layout
  18. enum _KeyBoardType
  19. {
  20. KL_2BEOLSIK = 0, KL_3BEOLSIK_390, KL_3BEOLSIK_FINAL
  21. };
  22. #define NUM_OF_IME_KL 3
  23. ///////////////////////////////////////////////////////////////////////////////
  24. // Global data S H A R E D to all IME instance
  25. struct IMEDATA
  26. {
  27. ULONG ulMagic;
  28. // Workarea
  29. RECT rcWorkArea;
  30. // Configuration of the IME
  31. UINT uiCurrentKeylayout;
  32. BOOL fJasoDel; // Backspace : delete per jaso or char
  33. // which means All ISO-10646 hangul.
  34. BOOL fKSC5657Hanja; // K1(KSC-5657) Hanja enable
  35. BOOL fCandUnicodeTT;
  36. // Status window
  37. UINT uNumOfButtons;
  38. //_StatusButtonTypes ButtonTypes[MAX_NUM_OF_STATUS_BUTTONS];
  39. INT iCurButtonSize;
  40. INT xStatusWi; // width of status window
  41. INT yStatusHi; // high of status window
  42. LONG xStatusRel, yStatusRel;
  43. INT xButtonWi;
  44. INT yButtonHi;
  45. INT cxStatLeftMargin, cxStatRightMargin,
  46. cyStatMargin, cyStatButton;
  47. RECT rcButtonArea;
  48. POINT ptStatusPos;
  49. // Candidate window
  50. INT xCandWi;
  51. INT yCandHi;
  52. // Comp window pos
  53. POINT ptCompPos;
  54. // This should be last - ia64 alignment issue
  55. StatusButton StatusButtons[MAX_NUM_OF_STATUS_BUTTONS];
  56. };
  57. typedef IMEDATA *LPIMEDATA;
  58. //////////////////////////////////////////////////////////////////////////////
  59. // I N S T A N C E D A T A
  60. // Per Process Data
  61. struct INSTDATA
  62. {
  63. HINSTANCE hInst; // IME DLL instance handle
  64. DWORD dwSystemInfoFlags;
  65. BOOL fISO10646; // XWansung area hangul enabled,
  66. BOOL f16BitApps;
  67. };
  68. typedef INSTDATA *LPINSTDATA;
  69. // Global variables
  70. PUBLIC BOOL vfUnicode;
  71. PUBLIC INSTDATA vInstData;
  72. PUBLIC LPINSTDATA vpInstData;
  73. /////////////////////////////////////////////////////////////////////////////
  74. // Class CIMEData
  75. //
  76. // Purpose : Shared memory handling across process boundary.
  77. // This use MapViewOfFile() to mapping local process memory and Unlock
  78. // automatically when reference count become zero
  79. // Note : Currently Read only flag behaves same as R/W flag.
  80. class CIMEData
  81. {
  82. public:
  83. enum LockType { SMReadOnly, SMReadWrite };
  84. CIMEData(LockType lockType=SMReadWrite);
  85. ~CIMEData() { UnlockSharedMemory(); }
  86. static BOOL InitSharedData();
  87. static BOOL CloseSharedMemory();
  88. void InitImeData();
  89. LPIMEDATA LockROSharedData();
  90. LPIMEDATA LockRWSharedData();
  91. BOOL UnlockSharedMemory();
  92. LPIMEDATA operator->() { DbgAssert(m_pImedata != 0); return m_pImedata; }
  93. LPIMEDATA GetGDataRaw() { DbgAssert(m_pImedata != 0); return m_pImedata; }
  94. UINT GetCurrentBeolsik() { return (m_pImedata ? m_pImedata->uiCurrentKeylayout : 0); }
  95. VOID SetCurrentBeolsik(UINT icurBeolsik);
  96. BOOL GetJasoDel() { return (m_pImedata ? m_pImedata->fJasoDel : 1); }
  97. VOID SetJasoDel(BOOL fJasoDel) { m_pImedata->fJasoDel = fJasoDel; }
  98. BOOL GetKSC5657Hanja() { return (m_pImedata ? m_pImedata->fKSC5657Hanja : 0); }
  99. VOID SetKSC5657Hanja(BOOL f5657) { m_pImedata->fKSC5657Hanja = f5657; }
  100. private:
  101. LPIMEDATA m_pImedata;
  102. static IMEDATA m_ImeDataDef;
  103. PRIVATE HANDLE m_vhSharedData;
  104. };
  105. inline
  106. CIMEData::CIMEData(LockType lockType)
  107. {
  108. DbgAssert(m_vhSharedData != 0);
  109. Dbg(DBGID_IMEDATA, TEXT("CIMEData(): Const"));
  110. m_pImedata = 0;
  111. LockRWSharedData();
  112. ZeroMemory(&m_ImeDataDef, sizeof(IMEDATA));
  113. // If failed to allocate or map shared memory, use static default data instead.
  114. if (m_pImedata == NULL)
  115. {
  116. m_pImedata = &m_ImeDataDef;
  117. return;
  118. }
  119. }
  120. inline
  121. LPIMEDATA CIMEData::LockROSharedData()
  122. {
  123. DbgAssert(m_vhSharedData != 0);
  124. Dbg(DBGID_IMEDATA, TEXT("CIMEData::LockROSharedData()"));
  125. if (m_vhSharedData)
  126. m_pImedata = (LPIMEDATA)MapViewOfFile(m_vhSharedData, FILE_MAP_READ, 0, 0, 0);
  127. DbgAssert(m_pImedata != 0);
  128. return m_pImedata;
  129. }
  130. inline
  131. LPIMEDATA CIMEData::LockRWSharedData()
  132. {
  133. DbgAssert(m_vhSharedData != 0);
  134. Dbg(DBGID_IMEDATA, TEXT("CIMEData::LockRWSharedData()"));
  135. if (m_vhSharedData)
  136. {
  137. Dbg(DBGID_IMEDATA, TEXT("CIMEData::LockRWSharedData(): m_vhSharedData is null call MapViewOfFile"));
  138. m_pImedata = (LPIMEDATA)MapViewOfFile(m_vhSharedData, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0);
  139. }
  140. DbgAssert(m_pImedata != 0);
  141. return m_pImedata;
  142. }
  143. // For unlocking shared memory
  144. inline
  145. BOOL CIMEData::UnlockSharedMemory()
  146. {
  147. Dbg(DBGID_IMEDATA, TEXT("CIMEData::UnlockSharedMemory(): Lock count zero UnmapViewOfFile"));
  148. if (m_pImedata != &m_ImeDataDef)
  149. {
  150. UnmapViewOfFile(m_pImedata);
  151. }
  152. m_pImedata = 0;
  153. return fTrue;
  154. }
  155. inline
  156. VOID CIMEData::SetCurrentBeolsik(UINT uicurBeolsik)
  157. {
  158. DbgAssert(/*uicurBeolsik>=KL_2BEOLSIK &&*/ uicurBeolsik<=KL_3BEOLSIK_FINAL);
  159. if (uicurBeolsik<=KL_3BEOLSIK_FINAL)
  160. m_pImedata->uiCurrentKeylayout = uicurBeolsik;
  161. }
  162. #endif // _GDATA_H__INCLUDED_