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.

328 lines
7.3 KiB

  1. /*
  2. * _COMMON.H
  3. *
  4. * Purpose:
  5. * RICHEDIT private common definitions
  6. *
  7. * Copyright (c) 1995-1998, Microsoft Corporation. All rights reserved.
  8. */
  9. #ifndef _COMMON_H
  10. #define _COMMON_H
  11. // REVIEW macro.
  12. //
  13. #define __LINE(l) #l
  14. #define __LINE_(l) __LINE(l)
  15. #define _LINE_ __LINE_(__LINE__)
  16. #define REVIEW __FILE__ "(" __LINE_(__LINE__) ") : "
  17. #pragma message ("Compiling Common.H")
  18. #ifdef NT
  19. #ifndef WINNT
  20. #define WINNT
  21. #endif
  22. #endif
  23. #define _UNICODE
  24. #ifndef STRICT
  25. #define STRICT
  26. #endif
  27. #define NOSHELLDEBUG //disables asserts in shell.h
  28. #include <limits.h>
  29. #if defined(DEBUG) && !defined(PEGASUS)
  30. #include <stdio.h>
  31. #endif
  32. #define WINVER 0x0500
  33. #include <windows.h>
  34. #include <windowsx.h>
  35. #include <winable.h>
  36. #ifndef MACPORT
  37. #include "imm.h"
  38. #else
  39. #include <tchar.h>
  40. #include "wlmimm.h"
  41. #endif //MACPORT
  42. /*
  43. * Types
  44. */
  45. #include <ourtypes.h>
  46. // for the benefit of the outside world, richedit.h uses cpMax instead
  47. // of cpMost. I highly prefer cpMost
  48. #ifdef cpMax
  49. #error "cpMax hack won't work"
  50. #endif
  51. #define cpMax cpMost
  52. #include <richedit.h>
  53. #include <richole.h>
  54. #undef cpMax
  55. #include "_debug.h"
  56. // Return TRUE if LF <= ch <= CR. NB: ch must be unsigned;
  57. // TCHAR and unsigned short give wrong results!
  58. #define IN_RANGE(n1, b, n2) ((unsigned)((b) - (n1)) <= unsigned((n2) - (n1)))
  59. #define IsASCIIDigit(b) IN_RANGE('0', b, '9')
  60. #define IsASCIIEOP(ch) IN_RANGE(LF, ch, CR)
  61. #define IsZerowidthCharacter(ch) IN_RANGE(ZWSP, ch, RTLMARK)
  62. // disable
  63. // 4710 : function not inlined
  64. // 4512 : assignment operator not generated
  65. // 4201 : nameless struct union
  66. // 4100 : unreferenced formal;
  67. // 4706 : assignment within conditional expression (oould be bad, but common)
  68. // 4127 : conditional expression is constant (if (1))
  69. // 4242 : truncation warning
  70. // 4244 : truncation warning
  71. #pragma warning (disable : 4710 4512 4201 4100 4127 4706 4242 4244)
  72. #pragma warning(3:4121) // structure is sensitive to alignment
  73. #pragma warning(3:4130) // logical operation on address of string constant
  74. #pragma warning(3:4132) // const object should be initialized
  75. #pragma warning(3:4509) // use of SEH with destructor
  76. // Our Win32 wrapper class
  77. #include "_w32sys.h"
  78. #include "resource.h"
  79. // Use explicit ASCII values for LF and CR, since MAC compilers
  80. // interchange values of '\r' and '\n'
  81. #define LF 10
  82. #define CR 13
  83. #define FF 12
  84. #define TAB TEXT('\t')
  85. //#define CELL 7
  86. #define CELL TAB
  87. #define EURO 0x20AC
  88. #define VT TEXT('\v')
  89. #define PS 0x2029
  90. #define SOFTHYPHEN 0xAD
  91. #define BOM 0xFEFF
  92. #define BULLET 0x2022
  93. #define EMDASH 0x2014
  94. #define EMSPACE 0x2003
  95. #define ENDASH 0x2013
  96. #define ENQUAD 0x2000
  97. #define ENSPACE 0x2002
  98. #define KASHIDA 0x0640
  99. #define LDBLQUOTE 0x201c
  100. #define LQUOTE 0x2018
  101. #define LTRMARK 0x200E
  102. #define RDBLQUOTE 0x201D
  103. #define RQUOTE 0x2019
  104. #define RTLMARK 0x200F
  105. #define SOFTHYPHEN 0xAD
  106. #define UTF16 0xDC00
  107. #define UTF16_LEAD 0xD800
  108. #define UTF16_TRAIL 0xDC00
  109. #define ZWSP 0x200B
  110. #define ZWJ 0x200D
  111. #define ZWNJ 0x200C
  112. /*
  113. * IsEOP(ch)
  114. *
  115. * @func
  116. * Used to determine if ch is an EOP char, i.e., CR, LF, VT, FF, PS, or
  117. * LS (Unicode paragraph/line separator). For speed, this function is
  118. * inlined.
  119. *
  120. * @rdesc
  121. * TRUE if ch is an end-of-paragraph char
  122. */
  123. __inline BOOL IsEOP(unsigned ch)
  124. {
  125. return IN_RANGE(LF, ch, CR) || (ch | 1) == PS;
  126. }
  127. BOOL IsRTF(char *pstr);
  128. #include <tom.h>
  129. #define CP_INFINITE tomForward
  130. #include "zmouse.h"
  131. #include "stddef.h"
  132. #include "_util.h"
  133. #ifdef DEBUG
  134. #define EM_DBGPED (WM_USER + 150)
  135. #endif
  136. #define EM_GETCODEPAGE (WM_USER + 151)
  137. // MIN
  138. #ifdef min
  139. #undef min
  140. #endif
  141. #define __min(a,b) (((a) < (b)) ? (a) : (b))
  142. inline int min(int v1, int v2) {return __min(v1, v2);}
  143. inline UINT min(UINT v1, UINT v2) {return __min(v1, v2);}
  144. inline float min(float v1, float v2) {return __min(v1, v2);}
  145. inline double min(double v1, double v2) {return __min(v1, v2);}
  146. inline __int64 min(__int64 v1, __int64 v2) {return __min(v1, v2);}
  147. // MAX
  148. #ifdef max
  149. #undef max
  150. #endif
  151. #define __max(a,b) (((a) > (b)) ? (a) : (b))
  152. inline int max(int v1, int v2) {return __max(v1, v2);}
  153. inline UINT max(UINT v1, UINT v2) {return __max(v1, v2);}
  154. inline float max(float v1, float v2) {return __max(v1, v2);}
  155. inline double max(double v1, double v2) {return __max(v1, v2);}
  156. inline __int64 max(__int64 v1, __int64 v2) {return __max(v1, v2);}
  157. // ABS
  158. #ifdef abs
  159. #undef abs
  160. #endif
  161. #define __abs(a) (((a) < 0) ? 0 - (a) : (a))
  162. #pragma function(abs)
  163. inline int __cdecl abs(int v) {return __abs(v);}
  164. // The abs val of a UINT is just that number. If we were to pass the value on to
  165. // the __abs macro we'd get a warning because (a) < 0 will always be false. This
  166. // fix allows us to compile cleanly *and* keep the same behavior as before.
  167. inline UINT abs(UINT v) {return v;}
  168. inline float abs(float v) {return __abs(v);}
  169. inline double abs(double v) {return __abs(v);}
  170. inline __int64 abs(__int64 v) {return __abs(v);}
  171. #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
  172. #include "_cfpf.h"
  173. // Interesting OS versions
  174. #define VERS4 4
  175. // conversions between byte and character counts
  176. #define CbOfCch(_x) ((_x) * 2)
  177. #define CchOfCb(_x) ((_x) / 2)
  178. #define cKinsokuCategories 16
  179. #define OLEstrcmp wcscmp
  180. #define OLEstrcpy wcscpy
  181. #define OLEsprintf wsprintf
  182. #define OLEstrlen wcslen
  183. // index (window long) of the PED
  184. #define ibPed 0
  185. #define RETID_BGND_RECALC 0x01af
  186. #define RETID_AUTOSCROLL 0x01b0
  187. #define RETID_SMOOTHSCROLL 0x01b1
  188. #define RETID_DRAGDROP 0x01b2
  189. #define RETID_MAGELLANTRACK 0x01b3
  190. // Count of characters in CRLF marker
  191. #define cchCRLF 2
  192. #define cchCR 1
  193. // RichEdit 1.0 uses a CRLF for an EOD marker
  194. #define CCH_EOD_10 2
  195. // RichEdit 2.0 uses a simple CR for the EOD marker
  196. #define CCH_EOD_20 1
  197. extern const TCHAR szCRLF[];
  198. extern const TCHAR szCR[];
  199. extern HINSTANCE hinstRE; // DLL instance
  200. #include <shellapi.h>
  201. #ifndef MACPORT
  202. #ifdef DUAL_FORMATETC
  203. #undef DUAL_FORMATETC
  204. #endif
  205. #define DUAL_FORMATETC FORMATETC
  206. #endif
  207. #include "WIN2MAC.h"
  208. extern "C"
  209. {
  210. LRESULT CALLBACK RichEditWndProc(HWND, UINT, WPARAM, LPARAM);
  211. LRESULT CALLBACK RichEditANSIWndProc(HWND, UINT, WPARAM, LPARAM);
  212. }
  213. // Multi-Threading support
  214. extern CRITICAL_SECTION g_CriticalSection;
  215. // a class to simplify critical section management
  216. class CLock
  217. {
  218. public:
  219. CLock()
  220. {
  221. EnterCriticalSection(&g_CriticalSection);
  222. }
  223. ~CLock()
  224. {
  225. LeaveCriticalSection(&g_CriticalSection);
  226. }
  227. };
  228. enum HITTEST
  229. {
  230. HT_Undefined = 0, // Hit hasn't been determined
  231. HT_Nothing,
  232. HT_OutlineSymbol,
  233. HT_LeftOfText,
  234. HT_BulletArea,
  235. HT_RightOfText,
  236. HT_Text, // All hits are in text from HT_Text on so
  237. HT_Link, // if(hit >= HT_Text) identifies text of some kind
  238. HT_Italic,
  239. HT_Object
  240. };
  241. #define ST_CHECKPROTECTION 0x8000
  242. #define ST_10REPLACESEL 0x10000000
  243. #define ST_10WM_SETTEXT 0x20000000
  244. /* REListbox1.0 Window Class. */
  245. // For Windows CE to avaoid possible conflicts on WIn95.
  246. #define CELISTBOX_CLASSA "REListBoxCEA"
  247. #define CELISTBOX_CLASSW L"REListBoxCEW"
  248. #ifndef MACPORT
  249. #define LISTBOX_CLASSW L"REListBox20W"
  250. #define COMBOBOX_CLASSW L"REComboBox20W"
  251. #else /*----------------------MACPORT */
  252. #define LISTBOX_CLASSW TEXT("REListBox20W") /* MACPORT change */
  253. #define COMBOBOX_CLASSW TEXT("REComboBox20W") /* MACPORT change */
  254. #endif /* MACPORT */
  255. #ifdef DEBUG
  256. //Debug api for dumping CTxtStory arrays.
  257. extern "C" {
  258. extern void DumpDoc(void *);
  259. }
  260. #endif
  261. #endif