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.

219 lines
6.0 KiB

  1. /****************************************************************************
  2. GDATA.H
  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. class CIMEData;
  12. extern BOOL InitSharedData();
  13. VOID InitImeData(CIMEData& ImeData);
  14. extern BOOL CloseSharedMemory();
  15. #define IMEDATA_MAGIC_NUMBER 0x12345678 // This will repesent whether IMEDATA initialized or not
  16. // Type of IME Hangul keyboard layout
  17. enum _KeyBoardType
  18. {
  19. KL_2BEOLSIK = 0, KL_3BEOLSIK_390 = 1, KL_3BEOLSIK_FINAL = 2
  20. };
  21. #define NUM_OF_IME_KL 3
  22. ///////////////////////////////////////////////////////////////////////////////
  23. // UI Decls
  24. enum StatusButtonTypes
  25. {
  26. HAN_ENG_TOGGLE_BUTTON,
  27. JUNJA_BANJA_TOGGLE_BUTTON,
  28. HANJA_CONV_BUTTON,
  29. IME_PAD_BUTTON,
  30. NULL_BUTTON = 0xFF
  31. };
  32. #define MAX_NUM_OF_STATUS_BUTTONS 4
  33. // Button status
  34. #define BTNSTATE_NORMAL 0 // normal
  35. #define BTNSTATE_ONMOUSE 1 // mouse cursor on the button
  36. #define BTNSTATE_PUSHED 2 // pushed
  37. #define BTNSTATE_DOWN 4 // pushed
  38. #define BTNSTATE_HANJACONV 8 // If hanja conv mode, button always pushed
  39. // Button size
  40. #define BTN_SMALL 0
  41. #define BTN_MIDDLE 1
  42. #define BTN_LARGE 2
  43. struct StatusButton
  44. {
  45. StatusButtonTypes m_ButtonType;
  46. WORD m_BmpNormalID, m_BmpOnMouseID, m_BmpPushedID, m_BmpDownOnMouseID;
  47. WORD m_ToolTipStrID;
  48. INT m_uiButtonState;
  49. BOOL m_fEnable;
  50. };
  51. ///////////////////////////////////////////////////////////////////////////////
  52. // Global data S H A R E D to all IME instance
  53. struct IMEDATA
  54. {
  55. ULONG ulMagic;
  56. // Workarea
  57. RECT rcWorkArea;
  58. // Configuration of the IME: TIP uses following data to share user setting.
  59. UINT uiCurrentKeylayout;
  60. BOOL fJasoDel; // Backspace : delete per jaso or char
  61. // which means All ISO-10646 hangul.
  62. BOOL fKSC5657Hanja; // K1(KSC-5657) Hanja enable
  63. BOOL fCandUnicodeTT;
  64. // Status window data: Not used by TIP
  65. UINT uNumOfButtons;
  66. INT iCurButtonSize;
  67. INT xStatusWi; // width of status window
  68. INT yStatusHi; // high of status window
  69. LONG xStatusRel, yStatusRel;
  70. INT xButtonWi;
  71. INT yButtonHi;
  72. INT cxStatLeftMargin, cxStatRightMargin,
  73. cyStatMargin, cyStatButton;
  74. RECT rcButtonArea;
  75. POINT ptStatusPos;
  76. // Candidate window
  77. INT xCandWi;
  78. INT yCandHi;
  79. // Comp window pos
  80. POINT ptCompPos;
  81. // This should be last - ia64 alignment issue
  82. StatusButton StatusButtons[MAX_NUM_OF_STATUS_BUTTONS];
  83. };
  84. typedef IMEDATA *LPIMEDATA;
  85. /////////////////////////////////////////////////////////////////////////////
  86. // Class CIMEData
  87. //
  88. // Purpose : Shared memory handling across process boundary.
  89. // This use MapViewOfFile() to mapping local process memory and Unlock
  90. // automatically when reference count become zero
  91. // Note : Currently Read only flag behaves same as R/W flag.
  92. class CIMEData
  93. {
  94. public:
  95. enum LockType { SMReadOnly, SMReadWrite };
  96. CIMEData(LockType lockType=SMReadWrite);
  97. ~CIMEData() { UnlockSharedMemory(); }
  98. static BOOL InitSharedData();
  99. static BOOL CloseSharedMemory();
  100. void InitImeData();
  101. LPIMEDATA LockROSharedData();
  102. LPIMEDATA LockRWSharedData();
  103. BOOL UnlockSharedMemory();
  104. LPIMEDATA operator->() { Assert(m_pImedata != 0); return m_pImedata; }
  105. LPIMEDATA GetGDataRaw() { Assert(m_pImedata != 0); return m_pImedata; }
  106. UINT GetCurrentBeolsik() { return m_pImedata->uiCurrentKeylayout; }
  107. VOID SetCurrentBeolsik(UINT icurBeolsik);
  108. BOOL GetJasoDel() { return m_pImedata->fJasoDel; }
  109. VOID SetJasoDel(BOOL fJasoDel) { m_pImedata->fJasoDel = fJasoDel; }
  110. BOOL GetKSC5657Hanja() { return m_pImedata->fKSC5657Hanja; }
  111. VOID SetKSC5657Hanja(BOOL f5657) { m_pImedata->fKSC5657Hanja = f5657; }
  112. private:
  113. LPIMEDATA m_pImedata;
  114. static IMEDATA m_ImeDataDef;
  115. static HANDLE m_vhSharedData;
  116. };
  117. inline
  118. CIMEData::CIMEData(LockType lockType)
  119. {
  120. Assert(m_vhSharedData != 0);
  121. DebugMsg(DM_TRACE, TEXT("CIMEData(): Const"));
  122. m_pImedata = 0;
  123. LockRWSharedData();
  124. ZeroMemory(&m_ImeDataDef, sizeof(IMEDATA));
  125. // If failed to allocate or map shared memory, use static default data instead.
  126. if (m_pImedata == NULL)
  127. {
  128. m_pImedata = &m_ImeDataDef;
  129. return;
  130. }
  131. }
  132. inline
  133. LPIMEDATA CIMEData::LockROSharedData()
  134. {
  135. Assert(m_vhSharedData != 0);
  136. DebugMsg(DM_TRACE, TEXT("CIMEData::LockROSharedData()"));
  137. if (m_vhSharedData)
  138. m_pImedata = (LPIMEDATA)MapViewOfFile(m_vhSharedData, FILE_MAP_READ, 0, 0, 0);
  139. Assert(m_pImedata != 0);
  140. return m_pImedata;
  141. }
  142. inline
  143. LPIMEDATA CIMEData::LockRWSharedData()
  144. {
  145. Assert(m_vhSharedData != 0);
  146. DebugMsg(DM_TRACE, TEXT("CIMEData::LockRWSharedData()"));
  147. if (m_vhSharedData)
  148. {
  149. DebugMsg(DM_TRACE, TEXT("CIMEData::LockRWSharedData(): m_vhSharedData is null call MapViewOfFile"));
  150. m_pImedata = (LPIMEDATA)MapViewOfFile(m_vhSharedData, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0);
  151. }
  152. Assert(m_pImedata != 0);
  153. return m_pImedata;
  154. }
  155. // For unlocking shared memory
  156. inline
  157. BOOL CIMEData::UnlockSharedMemory()
  158. {
  159. DebugMsg(DM_TRACE, TEXT("CIMEData::UnlockSharedMemory(): Lock count zero UnmapViewOfFile"));
  160. if (m_pImedata != &m_ImeDataDef)
  161. {
  162. UnmapViewOfFile(m_pImedata);
  163. }
  164. m_pImedata = 0;
  165. return fTrue;
  166. }
  167. inline
  168. VOID CIMEData::SetCurrentBeolsik(UINT uicurBeolsik)
  169. {
  170. Assert(uicurBeolsik<=KL_3BEOLSIK_FINAL);
  171. if (uicurBeolsik <= KL_3BEOLSIK_FINAL)
  172. m_pImedata->uiCurrentKeylayout = uicurBeolsik;
  173. }
  174. #endif // _GDATA_H__INCLUDED_